@dereekb/dbx-firebase 2.1.0 → 3.0.0

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 (149) hide show
  1. package/_index.scss +18 -0
  2. package/esm2020/lib/auth/auth.mjs +10 -0
  3. package/esm2020/lib/auth/error.mjs +28 -0
  4. package/esm2020/lib/auth/firebase.auth.module.mjs +34 -0
  5. package/esm2020/lib/auth/index.mjs +6 -0
  6. package/esm2020/lib/auth/login/firebase.login.module.mjs +274 -0
  7. package/esm2020/lib/auth/login/index.mjs +26 -0
  8. package/esm2020/lib/auth/login/login.anonymous.component.mjs +22 -0
  9. package/esm2020/lib/auth/login/login.apple.component.mjs +22 -0
  10. package/esm2020/lib/auth/login/login.button.component.mjs +139 -0
  11. package/esm2020/lib/auth/login/login.component.mjs +43 -0
  12. package/esm2020/lib/auth/login/login.context.back.component.mjs +27 -0
  13. package/esm2020/lib/auth/login/login.context.directive.mjs +25 -0
  14. package/esm2020/lib/auth/login/login.context.mjs +7 -0
  15. package/esm2020/lib/auth/login/login.email.component.mjs +23 -0
  16. package/esm2020/lib/auth/login/login.email.content.component.mjs +105 -0
  17. package/esm2020/lib/auth/login/login.email.form.component.mjs +35 -0
  18. package/esm2020/lib/auth/login/login.email.recovery.form.component.mjs +21 -0
  19. package/esm2020/lib/auth/login/login.facebook.component.mjs +22 -0
  20. package/esm2020/lib/auth/login/login.github.component.mjs +22 -0
  21. package/esm2020/lib/auth/login/login.google.component.mjs +22 -0
  22. package/esm2020/lib/auth/login/login.list.component.mjs +87 -0
  23. package/esm2020/lib/auth/login/login.microsoft.component.mjs +22 -0
  24. package/esm2020/lib/auth/login/login.mjs +3 -0
  25. package/esm2020/lib/auth/login/login.password.mjs +4 -0
  26. package/esm2020/lib/auth/login/login.service.mjs +134 -0
  27. package/esm2020/lib/auth/login/login.terms.component.mjs +26 -0
  28. package/esm2020/lib/auth/login/login.terms.mjs +3 -0
  29. package/esm2020/lib/auth/login/login.terms.simple.component.mjs +39 -0
  30. package/esm2020/lib/auth/login/login.twitter.component.mjs +22 -0
  31. package/esm2020/lib/auth/login/register.component.mjs +24 -0
  32. package/esm2020/lib/auth/login/register.email.component.mjs +21 -0
  33. package/esm2020/lib/auth/service/firebase.auth.rxjs.mjs +39 -0
  34. package/esm2020/lib/auth/service/firebase.auth.service.mjs +99 -0
  35. package/esm2020/lib/auth/service/index.mjs +3 -0
  36. package/esm2020/lib/firebase/emulators.mjs +3 -0
  37. package/esm2020/lib/firebase/firebase.emulator.module.mjs +36 -0
  38. package/esm2020/lib/firebase/firebase.module.mjs +188 -0
  39. package/esm2020/lib/firebase/index.mjs +5 -0
  40. package/esm2020/lib/firebase/options.mjs +2 -0
  41. package/esm2020/lib/firestore/firebase.firestore.context.service.mjs +23 -0
  42. package/esm2020/lib/firestore/firebase.firestore.mjs +6 -0
  43. package/esm2020/lib/firestore/firebase.firestore.module.mjs +31 -0
  44. package/esm2020/lib/firestore/index.mjs +4 -0
  45. package/esm2020/lib/function/firebase.function.module.mjs +47 -0
  46. package/esm2020/lib/function/index.mjs +2 -0
  47. package/esm2020/lib/index.mjs +7 -2
  48. package/esm2020/lib/model/error.mjs +6 -0
  49. package/esm2020/lib/model/index.mjs +5 -0
  50. package/esm2020/lib/model/loader/collection.loader.instance.mjs +101 -0
  51. package/esm2020/lib/model/loader/collection.loader.mjs +2 -0
  52. package/esm2020/lib/model/loader/index.mjs +3 -0
  53. package/esm2020/lib/model/model.module.mjs +17 -0
  54. package/esm2020/lib/model/store/index.mjs +14 -0
  55. package/esm2020/lib/model/store/model.store.module.mjs +41 -0
  56. package/esm2020/lib/model/store/store.collection.change.directive.mjs +54 -0
  57. package/esm2020/lib/model/store/store.collection.change.if.directive.mjs +57 -0
  58. package/esm2020/lib/model/store/store.collection.directive.mjs +52 -0
  59. package/esm2020/lib/model/store/store.collection.list.directive.mjs +27 -0
  60. package/esm2020/lib/model/store/store.collection.mjs +50 -0
  61. package/esm2020/lib/model/store/store.document.auth.directive.mjs +33 -0
  62. package/esm2020/lib/model/store/store.document.directive.mjs +46 -0
  63. package/esm2020/lib/model/store/store.document.mjs +81 -0
  64. package/esm2020/lib/model/store/store.document.router.directive.mjs +53 -0
  65. package/esm2020/lib/model/store/store.subcollection.document.mjs +37 -0
  66. package/esm2020/lib/model/store/store.subcollection.mjs +37 -0
  67. package/esm2020/lib/model/store/store.subcollection.rxjs.mjs +42 -0
  68. package/esm2020/lib/module.mjs +17 -0
  69. package/fesm2015/dereekb-dbx-firebase.mjs +2266 -2
  70. package/fesm2015/dereekb-dbx-firebase.mjs.map +1 -1
  71. package/fesm2020/dereekb-dbx-firebase.mjs +2247 -2
  72. package/fesm2020/dereekb-dbx-firebase.mjs.map +1 -1
  73. package/lib/auth/auth.d.ts +4 -0
  74. package/lib/auth/error.d.ts +9 -0
  75. package/lib/auth/firebase.auth.module.d.ts +12 -0
  76. package/lib/auth/index.d.ts +5 -0
  77. package/lib/auth/login/_login.scss +72 -0
  78. package/lib/auth/login/firebase.login.module.d.ts +48 -0
  79. package/lib/auth/login/index.d.ts +25 -0
  80. package/lib/auth/login/login.anonymous.component.d.ts +8 -0
  81. package/lib/auth/login/login.apple.component.d.ts +8 -0
  82. package/lib/auth/login/login.button.component.d.ts +51 -0
  83. package/lib/auth/login/login.component.d.ts +14 -0
  84. package/lib/auth/login/login.context.back.component.d.ts +9 -0
  85. package/lib/auth/login/login.context.d.ts +6 -0
  86. package/lib/auth/login/login.context.directive.d.ts +10 -0
  87. package/lib/auth/login/login.d.ts +7 -0
  88. package/lib/auth/login/login.email.component.d.ts +8 -0
  89. package/lib/auth/login/login.email.content.component.d.ts +39 -0
  90. package/lib/auth/login/login.email.form.component.d.ts +21 -0
  91. package/lib/auth/login/login.email.recovery.form.component.d.ts +11 -0
  92. package/lib/auth/login/login.facebook.component.d.ts +8 -0
  93. package/lib/auth/login/login.github.component.d.ts +8 -0
  94. package/lib/auth/login/login.google.component.d.ts +8 -0
  95. package/lib/auth/login/login.list.component.d.ts +28 -0
  96. package/lib/auth/login/login.microsoft.component.d.ts +8 -0
  97. package/lib/auth/login/login.password.d.ts +4 -0
  98. package/lib/auth/login/login.service.d.ts +115 -0
  99. package/lib/auth/login/login.terms.component.d.ts +10 -0
  100. package/lib/auth/login/login.terms.d.ts +4 -0
  101. package/lib/auth/login/login.terms.simple.component.d.ts +11 -0
  102. package/lib/auth/login/login.twitter.component.d.ts +8 -0
  103. package/lib/auth/login/register.component.d.ts +13 -0
  104. package/lib/auth/login/register.email.component.d.ts +8 -0
  105. package/lib/auth/service/firebase.auth.rxjs.d.ts +21 -0
  106. package/lib/auth/service/firebase.auth.service.d.ts +49 -0
  107. package/lib/auth/service/index.d.ts +2 -0
  108. package/lib/firebase/emulators.d.ts +52 -0
  109. package/lib/firebase/firebase.emulator.module.d.ts +12 -0
  110. package/lib/firebase/firebase.module.d.ts +50 -0
  111. package/lib/firebase/index.d.ts +4 -0
  112. package/lib/firebase/options.d.ts +6 -0
  113. package/lib/firestore/firebase.firestore.context.service.d.ts +11 -0
  114. package/lib/firestore/firebase.firestore.d.ts +5 -0
  115. package/lib/firestore/firebase.firestore.module.d.ts +17 -0
  116. package/lib/firestore/index.d.ts +3 -0
  117. package/lib/function/firebase.function.module.d.ts +24 -0
  118. package/lib/function/index.d.ts +1 -0
  119. package/lib/index.d.ts +6 -1
  120. package/lib/model/error.d.ts +5 -0
  121. package/lib/model/index.d.ts +4 -0
  122. package/lib/model/loader/collection.loader.d.ts +38 -0
  123. package/lib/model/loader/collection.loader.instance.d.ts +52 -0
  124. package/lib/model/loader/index.d.ts +2 -0
  125. package/lib/model/model.module.d.ts +7 -0
  126. package/lib/model/store/index.d.ts +13 -0
  127. package/lib/model/store/model.store.module.d.ts +11 -0
  128. package/lib/model/store/store.collection.change.directive.d.ts +30 -0
  129. package/lib/model/store/store.collection.change.if.directive.d.ts +24 -0
  130. package/lib/model/store/store.collection.d.ts +47 -0
  131. package/lib/model/store/store.collection.directive.d.ts +30 -0
  132. package/lib/model/store/store.collection.list.directive.d.ts +13 -0
  133. package/lib/model/store/store.document.auth.directive.d.ts +19 -0
  134. package/lib/model/store/store.document.d.ts +69 -0
  135. package/lib/model/store/store.document.directive.d.ts +34 -0
  136. package/lib/model/store/store.document.router.directive.d.ts +25 -0
  137. package/lib/model/store/store.subcollection.d.ts +31 -0
  138. package/lib/model/store/store.subcollection.document.d.ts +31 -0
  139. package/lib/model/store/store.subcollection.rxjs.d.ts +23 -0
  140. package/lib/module.d.ts +7 -0
  141. package/lib/style/_all-core.scss +6 -0
  142. package/lib/style/_all-theme.scss +6 -0
  143. package/lib/style/_all-typography.scss +6 -0
  144. package/lib/style/_config.scss +20 -0
  145. package/lib/style/_core.scss +9 -0
  146. package/lib/style/_mixin.scss +3 -0
  147. package/lib/style/_theming.scss +19 -0
  148. package/lib/style/_variables.scss +1 -0
  149. package/package.json +21 -12
@@ -1,8 +1,2253 @@
1
- const test = '';
1
+ import * as i4 from '@angular/material/button';
2
+ import { MatButtonModule } from '@angular/material/button';
3
+ import * as i2 from '@angular/material/icon';
4
+ import { MatIconModule } from '@angular/material/icon';
5
+ import * as i6 from '@angular/common';
6
+ import { CommonModule } from '@angular/common';
7
+ import * as i0 from '@angular/core';
8
+ import { Injectable, Optional, Component, InjectionToken, Inject, Input, Directive, EventEmitter, Output, NgModule, Injector, forwardRef, Host } from '@angular/core';
9
+ import { of, switchMap, shareReplay, map, timeout, startWith, distinctUntilChanged, from, BehaviorSubject, combineLatest, tap, firstValueFrom, Subject, throttleTime, NEVER, filter, take, exhaustMap, first } from 'rxjs';
10
+ import { filterMaybe, isNot, SubscriptionObject, cleanupDestroyable, accumulatorFlattenPageListLoadingState, useFirst, successResult, beginLoading, loadingStateFromObs, errorResult, cleanup } from '@dereekb/rxjs';
11
+ import * as i3$1 from '@dereekb/dbx-core';
12
+ import { loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, authUserIdentifier, DbxInjectionContext, AbstractForwardDbxInjectionContextDirective, DBX_INJECTION_COMPONENT_DATA, DbxInjectionComponentModule, DbxAuthService, AbstractSubscriptionDirective, AbstractIfDirective, LockSetComponentStore } from '@dereekb/dbx-core';
13
+ import * as i1 from '@angular/fire/auth';
14
+ import { authState, GoogleAuthProvider, FacebookAuthProvider, TwitterAuthProvider, GithubAuthProvider, signInWithPopup, createUserWithEmailAndPassword, signInWithEmailAndPassword, signInAnonymously, provideAuth, getAuth, connectAuthEmulator } from '@angular/fire/auth';
15
+ import { sendPasswordResetEmail } from 'firebase/auth';
16
+ import { addToSet, removeFromSet, filterMaybeValues, mapIterable, asArray, excludeValuesFromArray, containsStringAnyCase, forEachKeyValue, readableError, isMaybeSo } from '@dereekb/util';
17
+ import * as i3 from '@dereekb/dbx-web';
18
+ import { DbxRouterAnchorModule, DbxReadableErrorModule, DbxActionModule, DbxButtonModule } from '@dereekb/dbx-web';
19
+ import * as i1$1 from '@dereekb/dbx-form';
20
+ import { AbstractAsyncFormlyFormDirective, usernamePasswordLoginFields, ProvideFormlyContext, AbstractSyncFormlyFormDirective, emailField, DbxFormIoModule, DbxFormModule, DbxFormlyModule, DbxFormActionModule, DbxFormFormlyTextFieldModule } from '@dereekb/dbx-form';
21
+ import { initializeApp } from 'firebase/app';
22
+ import * as i5 from '@angular/fire/app';
23
+ import { provideFirebaseApp } from '@angular/fire/app';
24
+ import * as i3$2 from '@angular/fire/storage';
25
+ import { provideStorage, getStorage, connectStorageEmulator } from '@angular/fire/storage';
26
+ import * as i4$1 from '@angular/fire/functions';
27
+ import { provideFunctions, getFunctions, connectFunctionsEmulator, Functions } from '@angular/fire/functions';
28
+ import * as i1$2 from '@angular/fire/firestore';
29
+ import { provideFirestore, getFirestore, connectFirestoreEmulator, enableIndexedDbPersistence, Firestore } from '@angular/fire/firestore';
30
+ import { firebaseFirestoreContextFactory, iterationQueryDocChangeWatcher, firebaseQueryItemAccumulator, documentDataWithId } from '@dereekb/firebase';
31
+ import { shareReplay as shareReplay$1 } from 'rxjs/operators';
32
+
33
+ /**
34
+ * Derives a user state from the input firebase auth service.
35
+ *
36
+ * @param dbxFirebaseAuthService
37
+ * @param stateForLoggedInUser Optional function that returns an observable for the user's state if they are logged in and not an anonymous user.
38
+ * @returns
39
+ */
40
+ function authUserStateFromFirebaseAuthService(dbxFirebaseAuthService, stateForLoggedInUser = () => of('user')) {
41
+ return dbxFirebaseAuthService.hasAuthUser$.pipe(switchMap((hasUser) => {
42
+ let obs;
43
+ if (hasUser) {
44
+ obs = dbxFirebaseAuthService.isAnonymousUser$.pipe(switchMap((isAnon) => isAnon ? of('anon') : stateForLoggedInUser(dbxFirebaseAuthService)));
45
+ }
46
+ else {
47
+ obs = of('none');
48
+ }
49
+ return obs;
50
+ }), shareReplay(1));
51
+ }
52
+ /**
53
+ * Convenience function to read a value from an IdTokenResult off of the current user.
54
+ *
55
+ * @param dbxFirebaseAuthService
56
+ * @param readBooleanFromIdToken
57
+ * @param defaultValue
58
+ * @returns
59
+ */
60
+ function readValueFromIdToken(dbxFirebaseAuthService, readBooleanFromIdToken, defaultValue) {
61
+ return dbxFirebaseAuthService.currentAuthUserInfo$.pipe(switchMap((x) => {
62
+ if (x) {
63
+ return dbxFirebaseAuthService.idTokenResult$.pipe(switchMap(x => readBooleanFromIdToken(x)));
64
+ }
65
+ else {
66
+ return of(defaultValue);
67
+ }
68
+ }));
69
+ }
70
+
71
+ function authUserInfoFromAuthUser(user) {
72
+ return {
73
+ displayName: user?.displayName,
74
+ email: user.email,
75
+ phoneNumber: user.phoneNumber,
76
+ photoURL: user.photoURL,
77
+ uid: user.uid
78
+ };
79
+ }
80
+
81
+ class DbxFirebaseAuthServiceDelegate {
82
+ }
83
+ const DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE = {
84
+ authUserStateObs(dbxFirebaseAuthService) {
85
+ return authUserStateFromFirebaseAuthService(dbxFirebaseAuthService);
86
+ },
87
+ authRolesObs(dbxFirebaseAuthService) {
88
+ return dbxFirebaseAuthService.authUserState$.pipe(map(x => x === 'user' ? new Set(['user']) : new Set()));
89
+ },
90
+ isOnboarded(dbxFirebaseAuthService) {
91
+ return dbxFirebaseAuthService.authUserState$.pipe(map(x => x === 'user'));
92
+ }
93
+ };
94
+ class DbxFirebaseAuthService {
95
+ constructor(firebaseAuth, delegate) {
96
+ this.firebaseAuth = firebaseAuth;
97
+ this._authState$ = authState(this.firebaseAuth);
98
+ this.currentAuthUser$ = this._authState$.pipe(timeout({
99
+ first: 1000,
100
+ with: () => this._authState$.pipe(startWith(null))
101
+ }), distinctUntilChanged(), shareReplay(1));
102
+ this.currentAuthUserInfo$ = this.currentAuthUser$.pipe(map((x) => (x) ? authUserInfoFromAuthUser(x) : undefined));
103
+ this.authUser$ = this.currentAuthUser$.pipe(filterMaybe());
104
+ this.authUserInfo$ = this.authUser$.pipe(map(authUserInfoFromAuthUser));
105
+ this.hasAuthUser$ = this.currentAuthUser$.pipe(map(x => Boolean(x)), distinctUntilChanged(), shareReplay(1));
106
+ this.isAnonymousUser$ = this.authUser$.pipe(map(x => x.isAnonymous), distinctUntilChanged(), shareReplay(1));
107
+ this.isNotAnonymousUser$ = this.isAnonymousUser$.pipe(isNot());
108
+ this.isLoggedIn$ = this.hasAuthUser$;
109
+ this.isNotLoggedIn$ = this.isLoggedIn$.pipe(isNot());
110
+ this.onLogIn$ = loggedInObsFromIsLoggedIn(this.isLoggedIn$);
111
+ this.onLogOut$ = loggedOutObsFromIsLoggedIn(this.isLoggedIn$);
112
+ this.userIdentifier$ = this.currentAuthUser$.pipe(map(x => authUserIdentifier(x?.uid)));
113
+ this.idTokenResult$ = this.authUser$.pipe(switchMap(x => x.getIdTokenResult()));
114
+ this.claims$ = this.idTokenResult$.pipe(map(x => x.claims));
115
+ delegate = delegate ?? DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE;
116
+ this.authUserState$ = delegate.authUserStateObs(this).pipe(distinctUntilChanged(), shareReplay(1));
117
+ this.authRoles$ = delegate.authRolesObs(this);
118
+ this.isOnboarded$ = delegate.isOnboarded(this);
119
+ }
120
+ logInWithGoogle() {
121
+ return this.logInWithPopup(new GoogleAuthProvider());
122
+ }
123
+ logInWithFacebook() {
124
+ return this.logInWithPopup(new FacebookAuthProvider());
125
+ }
126
+ logInWithTwitter() {
127
+ return this.logInWithPopup(new TwitterAuthProvider());
128
+ }
129
+ logInWithGithub() {
130
+ return this.logInWithPopup(new GithubAuthProvider());
131
+ }
132
+ logInWithApple() {
133
+ throw new Error('todo');
134
+ }
135
+ logInWithMicrosoft() {
136
+ // return this.logInWithPopup(new MicrosoftAuthProvider());
137
+ throw new Error('todo');
138
+ }
139
+ logInWithPhone() {
140
+ throw new Error('todo');
141
+ // return signInWithPhoneNumber(this.firebaseAuth, )
142
+ }
143
+ logInWithPopup(provider, resolver) {
144
+ return signInWithPopup(this.firebaseAuth, provider, resolver);
145
+ }
146
+ registerWithEmailAndPassword(email, password) {
147
+ return createUserWithEmailAndPassword(this.firebaseAuth, email, password);
148
+ }
149
+ sendPasswordResetEmail(email) {
150
+ return sendPasswordResetEmail(this.firebaseAuth, email);
151
+ }
152
+ logInWithEmailAndPassword(email, password) {
153
+ return signInWithEmailAndPassword(this.firebaseAuth, email, password);
154
+ }
155
+ logInAsAnonymous() {
156
+ return signInAnonymously(this.firebaseAuth);
157
+ }
158
+ logOut() {
159
+ return this.firebaseAuth.signOut();
160
+ }
161
+ }
162
+ DbxFirebaseAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthService, deps: [{ token: i1.Auth }, { token: DbxFirebaseAuthServiceDelegate, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
163
+ DbxFirebaseAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthService });
164
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthService, decorators: [{
165
+ type: Injectable
166
+ }], ctorParameters: function () { return [{ type: i1.Auth }, { type: DbxFirebaseAuthServiceDelegate, decorators: [{
167
+ type: Optional
168
+ }] }]; } });
169
+
170
+ class DbxFirebaseLoginTermsConfig {
171
+ }
172
+
173
+ class DbxFirebaseLoginTermsSimpleComponent {
174
+ constructor(dbxFirebaseLoginTermsConfig) {
175
+ this.dbxFirebaseLoginTermsConfig = dbxFirebaseLoginTermsConfig;
176
+ this.tosAnchor = {
177
+ url: this.dbxFirebaseLoginTermsConfig.tosUrl,
178
+ target: '_blank'
179
+ };
180
+ this.privacyAnchor = {
181
+ url: this.dbxFirebaseLoginTermsConfig.privacyUrl,
182
+ target: '_blank'
183
+ };
184
+ }
185
+ }
186
+ DbxFirebaseLoginTermsSimpleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginTermsSimpleComponent, deps: [{ token: DbxFirebaseLoginTermsConfig }], target: i0.ɵɵFactoryTarget.Component });
187
+ DbxFirebaseLoginTermsSimpleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginTermsSimpleComponent, selector: "ng-component", ngImport: i0, template: `
188
+ <div class="dbx-firebase-login-terms-view">
189
+ <dbx-link [anchor]="tosAnchor">Terms</dbx-link>
190
+ <span class="dbx-link-spacer"></span>
191
+ <dbx-link [anchor]="privacyAnchor">Privacy</dbx-link>
192
+ </div>
193
+ `, isInline: true, components: [{ type: i3.DbxAnchorLinkComponent, selector: "dbx-link", inputs: ["anchor", "ref", "href"] }] });
194
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginTermsSimpleComponent, decorators: [{
195
+ type: Component,
196
+ args: [{
197
+ template: `
198
+ <div class="dbx-firebase-login-terms-view">
199
+ <dbx-link [anchor]="tosAnchor">Terms</dbx-link>
200
+ <span class="dbx-link-spacer"></span>
201
+ <dbx-link [anchor]="privacyAnchor">Privacy</dbx-link>
202
+ </div>
203
+ `
204
+ }]
205
+ }], ctorParameters: function () { return [{ type: DbxFirebaseLoginTermsConfig }]; } });
206
+
207
+ const DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG = {
208
+ minLength: 6
209
+ };
210
+
211
+ /**
212
+ * Default providers to inject.
213
+ */
214
+ const DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN = new InjectionToken('DefaultDbxFirebaseAuthLoginProviders');
215
+ const DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN = new InjectionToken('DefaultDbxFirebaseAuthLoginTermsComponentClass');
216
+ const DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN = new InjectionToken('DefaultDbxFirebaseAuthLoginPasswordConfig');
217
+ /**
218
+ * Service used for registering components used for logging in.
219
+ *
220
+ * Default providers can be configured by the DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN injectable value.
221
+ */
222
+ class DbxFirebaseAuthLoginService {
223
+ constructor(defaultProviders, passwordConfig, termsComponentClass = DbxFirebaseLoginTermsSimpleComponent) {
224
+ this.termsComponentClass = termsComponentClass;
225
+ this._enableAll = false;
226
+ this._providers = new Map();
227
+ this._assets = new Map();
228
+ this._enabled = new Set();
229
+ if (defaultProviders) {
230
+ defaultProviders.forEach((x) => this.register(x, false));
231
+ }
232
+ this._passwordConfig = passwordConfig ?? DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG;
233
+ }
234
+ /**
235
+ * Used to register a provider. If a provider is already registered, this will override it by default.
236
+ *
237
+ * @param provider
238
+ * @param override
239
+ */
240
+ register(provider, override = true) {
241
+ if (override || !this._providers.has(provider.loginMethodType)) {
242
+ this._providers.set(provider.loginMethodType, provider);
243
+ if (provider.assets) {
244
+ this.updateAssetsForProvider(provider.loginMethodType, provider.assets);
245
+ }
246
+ return true;
247
+ }
248
+ else {
249
+ return false;
250
+ }
251
+ }
252
+ /**
253
+ * Updates the assets for a provider type.
254
+ *
255
+ * @param type
256
+ * @param assets
257
+ */
258
+ updateAssetsForProvider(type, assets) {
259
+ const current = this._assets.get(type);
260
+ const update = {
261
+ ...current,
262
+ ...assets
263
+ };
264
+ this._assets.set(type, update);
265
+ }
266
+ // MARK: Enable/Disable
267
+ /**
268
+ * Enables all providers and any providers that will be registered.
269
+ */
270
+ setEnableAll(enableAll = true) {
271
+ this._enableAll = enableAll;
272
+ }
273
+ clearEnabled() {
274
+ this._enabled = new Set();
275
+ }
276
+ /**
277
+ * Enables all of the specified types.
278
+ *
279
+ * @param types
280
+ */
281
+ enable(types) {
282
+ addToSet(this._enabled, types);
283
+ }
284
+ disable(types) {
285
+ removeFromSet(this._enabled, types);
286
+ }
287
+ // MARK: Get
288
+ getRegisteredTypes() {
289
+ return Array.from(this._providers.keys());
290
+ }
291
+ getEnabledTypes() {
292
+ return (this._enableAll) ? this.getRegisteredTypes() : Array.from(this._enabled);
293
+ }
294
+ getLoginProvider(type) {
295
+ return this._providers.get(type);
296
+ }
297
+ getLoginProviders(types) {
298
+ return filterMaybeValues(mapIterable(types ?? [], (x) => this._providers.get(x)));
299
+ }
300
+ getRegisterProvider(type) {
301
+ return this._providers.get(type);
302
+ }
303
+ getRegisterProviders(types) {
304
+ return filterMaybeValues(mapIterable(types ?? [], (x) => this._providers.get(x))).filter(x => x.registrationComponentClass !== false);
305
+ }
306
+ getProviderAssets(type) {
307
+ return this._assets.get(type);
308
+ }
309
+ getPasswordConfig() {
310
+ return this._passwordConfig;
311
+ }
312
+ setPasswordConfig(passwordConfig) {
313
+ this._passwordConfig = passwordConfig;
314
+ }
315
+ }
316
+ DbxFirebaseAuthLoginService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthLoginService, deps: [{ token: DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN, optional: true }, { token: DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN, optional: true }, { token: DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
317
+ DbxFirebaseAuthLoginService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthLoginService, providedIn: 'root' });
318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthLoginService, decorators: [{
319
+ type: Injectable,
320
+ args: [{
321
+ providedIn: 'root',
322
+ }]
323
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
324
+ type: Optional
325
+ }, {
326
+ type: Inject,
327
+ args: [DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN]
328
+ }] }, { type: undefined, decorators: [{
329
+ type: Optional
330
+ }, {
331
+ type: Inject,
332
+ args: [DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN]
333
+ }] }, { type: i0.Type, decorators: [{
334
+ type: Optional
335
+ }, {
336
+ type: Inject,
337
+ args: [DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN]
338
+ }] }]; } });
339
+
340
+ /**
341
+ * Injection token for a DbxInjectionContext for DbxFirebaseLoginContext.
342
+ */
343
+ class DbxFirebaseLoginContext extends DbxInjectionContext {
344
+ }
345
+
346
+ /**
347
+ * Login button and action.
348
+ */
349
+ class DbxFirebaseLoginButtonComponent {
350
+ constructor() {
351
+ this.handleAction = (value) => {
352
+ const loginPromise = this.config.handleLogin();
353
+ return from(loginPromise);
354
+ };
355
+ this.onActionSuccess = (value) => {
356
+ // todo: show checkmark on success?
357
+ };
358
+ }
359
+ get iconUrl() {
360
+ return this.config?.iconUrl;
361
+ }
362
+ get icon() {
363
+ return this.config?.icon;
364
+ }
365
+ get text() {
366
+ return this.config?.text;
367
+ }
368
+ get buttonColor() {
369
+ return this.config?.buttonColor ?? 'transparent';
370
+ }
371
+ get buttonTextColor() {
372
+ return this.config?.buttonTextColor;
373
+ }
374
+ }
375
+ DbxFirebaseLoginButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
376
+ DbxFirebaseLoginButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: { config: "config" }, host: { classAttribute: "dbx-firebase-login-button" }, ngImport: i0, template: `
377
+ <ng-container dbxAction [dbxActionHandler]="handleAction" dbxActionValue
378
+ [dbxActionSuccessHandler]="onActionSuccess">
379
+ <dbx-button dbxActionButton [customTextColor]="buttonTextColor" [customButtonColor]="buttonColor" [raised]="true">
380
+ <div class="dbx-firebase-login-button-content">
381
+ <span class="dbx-firebase-login-button-icon dbx-icon-spacer">
382
+ <img *ngIf="iconUrl" [src]="iconUrl"/>
383
+ <mat-icon *ngIf="icon">{{icon}}</mat-icon>
384
+ </span>
385
+ <span class="dbx-firebase-login-button-text">{{ text }}</span>
386
+ </div>
387
+ </dbx-button>
388
+ </ng-container>
389
+ `, isInline: true, components: [{ type: i3.DbxButtonComponent, selector: "dbx-button", inputs: ["type", "raised", "stroked", "flat", "color", "customButtonColor", "customTextColor", "customSpinnerColor"] }, { type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i3$1.DbxActionDirective, selector: "dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]", exportAs: ["action", "dbxAction"] }, { type: i3$1.DbxActionValueDirective, selector: "[dbxActionValue]", inputs: ["dbxActionValue"] }, { type: i3$1.DbxActionHandlerDirective, selector: "[dbxActionHandler]", inputs: ["dbxActionHandler"] }, { type: i3$1.DbxActionSuccessHandlerDirective, selector: "[dbxActionSuccessHandler]", inputs: ["dbxActionSuccessHandler"] }, { type: i3$1.DbxActionButtonDirective, selector: "[dbxActionButton]" }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
390
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginButtonComponent, decorators: [{
391
+ type: Component,
392
+ args: [{
393
+ selector: 'dbx-firebase-login-button',
394
+ template: `
395
+ <ng-container dbxAction [dbxActionHandler]="handleAction" dbxActionValue
396
+ [dbxActionSuccessHandler]="onActionSuccess">
397
+ <dbx-button dbxActionButton [customTextColor]="buttonTextColor" [customButtonColor]="buttonColor" [raised]="true">
398
+ <div class="dbx-firebase-login-button-content">
399
+ <span class="dbx-firebase-login-button-icon dbx-icon-spacer">
400
+ <img *ngIf="iconUrl" [src]="iconUrl"/>
401
+ <mat-icon *ngIf="icon">{{icon}}</mat-icon>
402
+ </span>
403
+ <span class="dbx-firebase-login-button-text">{{ text }}</span>
404
+ </div>
405
+ </dbx-button>
406
+ </ng-container>
407
+ `,
408
+ host: {
409
+ 'class': 'dbx-firebase-login-button'
410
+ }
411
+ }]
412
+ }], propDecorators: { config: [{
413
+ type: Input
414
+ }] } });
415
+ class DbxFirebaseLoginButtonContainerComponent {
416
+ }
417
+ DbxFirebaseLoginButtonContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginButtonContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
418
+ DbxFirebaseLoginButtonContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container", ngImport: i0, template: `
419
+ <div class="dbx-firebase-login-button-container">
420
+ <ng-content></ng-content>
421
+ </div>
422
+ `, isInline: true });
423
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginButtonContainerComponent, decorators: [{
424
+ type: Component,
425
+ args: [{
426
+ selector: 'dbx-firebase-login-button-container',
427
+ template: `
428
+ <div class="dbx-firebase-login-button-container">
429
+ <ng-content></ng-content>
430
+ </div>
431
+ `
432
+ }]
433
+ }] });
434
+ const DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE = `
435
+ <dbx-firebase-login-button-container>
436
+ <dbx-firebase-login-button [config]="config"></dbx-firebase-login-button>
437
+ </dbx-firebase-login-button-container>
438
+ `;
439
+ class AbstractConfiguredDbxFirebaseLoginButtonDirective {
440
+ constructor(dbxFirebaseAuthService, dbxFirebaseAuthLoginService, dbxFirebaseLoginContext) {
441
+ this.dbxFirebaseAuthService = dbxFirebaseAuthService;
442
+ this.dbxFirebaseAuthLoginService = dbxFirebaseAuthLoginService;
443
+ this.dbxFirebaseLoginContext = dbxFirebaseLoginContext;
444
+ }
445
+ ngOnInit() {
446
+ const assets = this.assetConfig;
447
+ this._config = {
448
+ text: assets.loginText ?? `<loginText not configured>`,
449
+ icon: assets.loginIcon,
450
+ iconUrl: assets.logoUrl,
451
+ buttonColor: assets.backgroundColor,
452
+ buttonTextColor: assets.textColor,
453
+ handleLogin: () => this.handleLogin()
454
+ };
455
+ }
456
+ get providerConfig() {
457
+ return this.dbxFirebaseAuthLoginService.getLoginProvider(this.loginProvider);
458
+ }
459
+ get assetConfig() {
460
+ return this.dbxFirebaseAuthLoginService.getProviderAssets(this.loginProvider) ?? {};
461
+ }
462
+ get config() {
463
+ return this._config;
464
+ }
465
+ }
466
+ AbstractConfiguredDbxFirebaseLoginButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractConfiguredDbxFirebaseLoginButtonDirective, deps: [{ token: DbxFirebaseAuthService }, { token: DbxFirebaseAuthLoginService }, { token: DbxFirebaseLoginContext }], target: i0.ɵɵFactoryTarget.Directive });
467
+ AbstractConfiguredDbxFirebaseLoginButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: AbstractConfiguredDbxFirebaseLoginButtonDirective, ngImport: i0 });
468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractConfiguredDbxFirebaseLoginButtonDirective, decorators: [{
469
+ type: Directive
470
+ }], ctorParameters: function () { return [{ type: DbxFirebaseAuthService }, { type: DbxFirebaseAuthLoginService }, { type: DbxFirebaseLoginContext }]; } });
471
+
472
+ class DbxFirebaseLoginAppleComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
473
+ constructor() {
474
+ super(...arguments);
475
+ this.loginProvider = 'apple';
476
+ }
477
+ handleLogin() {
478
+ return this.dbxFirebaseAuthService.logInWithApple();
479
+ }
480
+ }
481
+ DbxFirebaseLoginAppleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginAppleComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
482
+ DbxFirebaseLoginAppleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginAppleComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
483
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginAppleComponent, decorators: [{
484
+ type: Component,
485
+ args: [{
486
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
487
+ }]
488
+ }] });
489
+
490
+ const DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY = 'default';
491
+ const OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY = 'oauth';
492
+
493
+ class DbxFirebaseLoginAnonymousComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
494
+ constructor() {
495
+ super(...arguments);
496
+ this.loginProvider = 'anonymous';
497
+ }
498
+ handleLogin() {
499
+ return this.dbxFirebaseAuthService.logInAsAnonymous();
500
+ }
501
+ }
502
+ DbxFirebaseLoginAnonymousComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginAnonymousComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
503
+ DbxFirebaseLoginAnonymousComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginAnonymousComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
504
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginAnonymousComponent, decorators: [{
505
+ type: Component,
506
+ args: [{
507
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
508
+ }]
509
+ }] });
510
+
511
+ /**
512
+ * Pre-configured login component that displays all configured login types.
513
+ */
514
+ class DbxFirebaseLoginListComponent {
515
+ constructor(dbxFirebaseAuthLoginService) {
516
+ this.dbxFirebaseAuthLoginService = dbxFirebaseAuthLoginService;
517
+ this._loginMode = new BehaviorSubject('login');
518
+ this._inputProviderCategories = new BehaviorSubject(undefined);
519
+ this._omitProviderTypes = new BehaviorSubject(undefined);
520
+ this._inputProviderTypes = new BehaviorSubject(undefined);
521
+ this.providerTypes$ = combineLatest([this._inputProviderTypes, this._omitProviderTypes]).pipe(map(([providerTypes, omitProviderTypes]) => {
522
+ const baseTypes = (providerTypes) ? asArray(providerTypes) : this.dbxFirebaseAuthLoginService.getEnabledTypes();
523
+ const types = (omitProviderTypes) ? excludeValuesFromArray(baseTypes, asArray(omitProviderTypes)) : baseTypes;
524
+ return types;
525
+ }), shareReplay(1));
526
+ this.providers$ = combineLatest([this.providerTypes$, this._inputProviderCategories]).pipe(map(([x, inputProviderCategories]) => {
527
+ const providerCategories = asArray(inputProviderCategories);
528
+ let providers = this.dbxFirebaseAuthLoginService.getLoginProviders(x);
529
+ if (providerCategories.length) {
530
+ const categories = new Set(providerCategories);
531
+ providers = providers.filter(x => containsStringAnyCase(categories, x.category ?? ''));
532
+ }
533
+ return providers;
534
+ }));
535
+ this.providerInjectionConfigs$ = combineLatest([this._loginMode, this.providers$]).pipe(map(([mode, providers]) => {
536
+ const mapFn = (mode === 'register') ?
537
+ ((x) => ({ componentClass: x.registrationComponentClass ?? x.componentClass })) :
538
+ ((x) => ({ componentClass: x.componentClass }));
539
+ return providers.map(mapFn);
540
+ }));
541
+ }
542
+ ngOnDestroy() {
543
+ this._loginMode.complete();
544
+ this._inputProviderCategories.complete();
545
+ this._omitProviderTypes.complete();
546
+ this._inputProviderTypes.complete();
547
+ }
548
+ set loginMode(loginMode) {
549
+ this._loginMode.next(loginMode);
550
+ }
551
+ set providerTypes(providerTypes) {
552
+ this._inputProviderTypes.next(providerTypes);
553
+ }
554
+ set omitProviderTypes(providerTypes) {
555
+ this._omitProviderTypes.next(providerTypes);
556
+ }
557
+ set providerCategories(providerCategories) {
558
+ this._inputProviderCategories.next(providerCategories);
559
+ }
560
+ }
561
+ DbxFirebaseLoginListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginListComponent, deps: [{ token: DbxFirebaseAuthLoginService }], target: i0.ɵɵFactoryTarget.Component });
562
+ DbxFirebaseLoginListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginListComponent, selector: "dbx-firebase-login-list", inputs: { loginMode: "loginMode", providerTypes: "providerTypes", omitProviderTypes: "omitProviderTypes", providerCategories: "providerCategories" }, host: { classAttribute: "dbx-firebase-login-list" }, ngImport: i0, template: `
563
+ <div class="dbx-firebase-login-item" *ngFor="let config of (providerInjectionConfigs$ | async)">
564
+ <dbx-injection [config]="config"></dbx-injection>
565
+ </div>
566
+ `, isInline: true, components: [{ type: i3$1.DbxInjectionComponent, selector: "dbx-injection, [dbxInjection], [dbx-injection]", inputs: ["config", "template"] }], directives: [{ type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i6.AsyncPipe } });
567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginListComponent, decorators: [{
568
+ type: Component,
569
+ args: [{
570
+ selector: 'dbx-firebase-login-list',
571
+ template: `
572
+ <div class="dbx-firebase-login-item" *ngFor="let config of (providerInjectionConfigs$ | async)">
573
+ <dbx-injection [config]="config"></dbx-injection>
574
+ </div>
575
+ `,
576
+ host: {
577
+ 'class': 'dbx-firebase-login-list'
578
+ }
579
+ }]
580
+ }], ctorParameters: function () { return [{ type: DbxFirebaseAuthLoginService }]; }, propDecorators: { loginMode: [{
581
+ type: Input
582
+ }], providerTypes: [{
583
+ type: Input
584
+ }], omitProviderTypes: [{
585
+ type: Input
586
+ }], providerCategories: [{
587
+ type: Input
588
+ }] } });
589
+
590
+ /**
591
+ * DbxFirebaseLoginContext implementation.
592
+ */
593
+ class DbxFirebaseLoginContextDirective extends AbstractForwardDbxInjectionContextDirective {
594
+ }
595
+ DbxFirebaseLoginContextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginContextDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
596
+ DbxFirebaseLoginContextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginContextDirective, selector: "[dbxFirebaseLoginContext]", providers: [{
597
+ provide: DbxFirebaseLoginContext,
598
+ useExisting: DbxFirebaseLoginContextDirective
599
+ }], usesInheritance: true, ngImport: i0 });
600
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginContextDirective, decorators: [{
601
+ type: Directive,
602
+ args: [{
603
+ 'selector': '[dbxFirebaseLoginContext]',
604
+ providers: [{
605
+ provide: DbxFirebaseLoginContext,
606
+ useExisting: DbxFirebaseLoginContextDirective
607
+ }]
608
+ }]
609
+ }] });
610
+
611
+ /**
612
+ * Pre-configured login component that displays all configured login types.
613
+ */
614
+ class DbxFirebaseLoginComponent {
615
+ constructor() {
616
+ this.loginMode = 'login';
617
+ }
618
+ }
619
+ DbxFirebaseLoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
620
+ DbxFirebaseLoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginComponent, selector: "dbx-firebase-login", inputs: { loginMode: "loginMode", providerTypes: "providerTypes", omitProviderTypes: "omitProviderTypes", providerCategories: "providerCategories" }, host: { properties: { "class": "{ \"dbx-firebase-register\": loginMode === \"register\" }" }, classAttribute: "d-block dbx-firebase-login" }, ngImport: i0, template: `
621
+ <ng-container *dbxInjectionContext dbxFirebaseLoginContext>
622
+ <dbx-firebase-login-list [providerTypes]="providerTypes" [omitProviderTypes]="omitProviderTypes" [providerCategories]="providerCategories" [loginMode]="loginMode"></dbx-firebase-login-list>
623
+ </ng-container>
624
+ `, isInline: true, components: [{ type: DbxFirebaseLoginListComponent, selector: "dbx-firebase-login-list", inputs: ["loginMode", "providerTypes", "omitProviderTypes", "providerCategories"] }], directives: [{ type: i3$1.DbxInjectionContextDirective, selector: "[dbxInjectionContext]", inputs: ["config"] }, { type: DbxFirebaseLoginContextDirective, selector: "[dbxFirebaseLoginContext]" }] });
625
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginComponent, decorators: [{
626
+ type: Component,
627
+ args: [{
628
+ selector: 'dbx-firebase-login',
629
+ template: `
630
+ <ng-container *dbxInjectionContext dbxFirebaseLoginContext>
631
+ <dbx-firebase-login-list [providerTypes]="providerTypes" [omitProviderTypes]="omitProviderTypes" [providerCategories]="providerCategories" [loginMode]="loginMode"></dbx-firebase-login-list>
632
+ </ng-container>
633
+ `,
634
+ host: {
635
+ 'class': 'd-block dbx-firebase-login',
636
+ '[class]': '{ "dbx-firebase-register": loginMode === "register" }'
637
+ }
638
+ }]
639
+ }], propDecorators: { loginMode: [{
640
+ type: Input
641
+ }], providerTypes: [{
642
+ type: Input
643
+ }], omitProviderTypes: [{
644
+ type: Input
645
+ }], providerCategories: [{
646
+ type: Input
647
+ }] } });
648
+
649
+ const FIREBASE_AUTH_USER_NOT_FOUND_ERROR = 'auth/user-not-found';
650
+ const FIREBASE_AUTH_NETWORK_REQUEST_ERROR = 'auth/network-request-error';
651
+ function firebaseAuthErrorToReadableError(inputError) {
652
+ const code = inputError.code;
653
+ let error;
654
+ switch (code) {
655
+ case FIREBASE_AUTH_USER_NOT_FOUND_ERROR:
656
+ error = {
657
+ code,
658
+ message: 'A user with this email address was not found.'
659
+ };
660
+ break;
661
+ case FIREBASE_AUTH_NETWORK_REQUEST_ERROR:
662
+ error = {
663
+ code,
664
+ message: 'Could not reach the server.'
665
+ };
666
+ break;
667
+ default:
668
+ error = {
669
+ code,
670
+ message: 'An error occured.'
671
+ };
672
+ break;
673
+ }
674
+ return error;
675
+ }
676
+
677
+ class DbxFirebaseEmailFormComponent extends AbstractAsyncFormlyFormDirective {
678
+ constructor() {
679
+ super(...arguments);
680
+ this._config = new BehaviorSubject({ loginMode: 'login' });
681
+ this.fields$ = this._config.pipe(map(({ loginMode = 'login', passwordConfig }) => {
682
+ const fields = usernamePasswordLoginFields({ username: 'email', password: passwordConfig, verifyPassword: (loginMode === 'register') });
683
+ return fields;
684
+ }));
685
+ }
686
+ set config(config) {
687
+ this._config.next(config);
688
+ }
689
+ ngOnDestroy() {
690
+ super.ngOnDestroy();
691
+ this._config.complete();
692
+ }
693
+ }
694
+ DbxFirebaseEmailFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmailFormComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
695
+ DbxFirebaseEmailFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseEmailFormComponent, selector: "dbx-firebase-email-form", inputs: { config: "config" }, providers: [ProvideFormlyContext()], usesInheritance: true, ngImport: i0, template: `<dbx-formly></dbx-formly>`, isInline: true, components: [{ type: i1$1.DbxFormlyFormComponent, selector: "dbx-formly", exportAs: ["formly"] }] });
696
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmailFormComponent, decorators: [{
697
+ type: Component,
698
+ args: [{
699
+ template: `<dbx-formly></dbx-formly>`,
700
+ selector: 'dbx-firebase-email-form',
701
+ providers: [ProvideFormlyContext()]
702
+ }]
703
+ }], propDecorators: { config: [{
704
+ type: Input
705
+ }] } });
706
+
707
+ class DbxFirebaseEmailRecoveryFormComponent extends AbstractSyncFormlyFormDirective {
708
+ constructor() {
709
+ super(...arguments);
710
+ this.fields = [emailField({ required: true })];
711
+ }
712
+ }
713
+ DbxFirebaseEmailRecoveryFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmailRecoveryFormComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
714
+ DbxFirebaseEmailRecoveryFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseEmailRecoveryFormComponent, selector: "dbx-firebase-email-recovery-form", providers: [ProvideFormlyContext()], usesInheritance: true, ngImport: i0, template: `<dbx-formly></dbx-formly>`, isInline: true, components: [{ type: i1$1.DbxFormlyFormComponent, selector: "dbx-formly", exportAs: ["formly"] }] });
715
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmailRecoveryFormComponent, decorators: [{
716
+ type: Component,
717
+ args: [{
718
+ template: `<dbx-formly></dbx-formly>`,
719
+ selector: 'dbx-firebase-email-recovery-form',
720
+ providers: [ProvideFormlyContext()]
721
+ }]
722
+ }] });
723
+
724
+ class DbxFirebaseLoginEmailContentComponent {
725
+ constructor(dbxFirebaseAuthService, config) {
726
+ this.dbxFirebaseAuthService = dbxFirebaseAuthService;
727
+ this.config = config;
728
+ this.formConfig = {
729
+ loginMode: this.config.loginMode,
730
+ passwordConfig: this.config.passwordConfig
731
+ };
732
+ this._emailMode = new BehaviorSubject('login');
733
+ this.emailMode$ = this._emailMode.asObservable();
734
+ this.forgotAnchor = {
735
+ onClick: () => {
736
+ this.openRecovery();
737
+ }
738
+ };
739
+ this.doneOrCancelled = new EventEmitter();
740
+ this.handleLoginAction = (value) => {
741
+ this.emailFormValue = value;
742
+ this.recoveryFormValue = { email: value.username }; // cache value for recovery
743
+ let result;
744
+ if (this.loginMode === 'register') {
745
+ result = this.dbxFirebaseAuthService.registerWithEmailAndPassword(value.username, value.password);
746
+ }
747
+ else {
748
+ result = this.dbxFirebaseAuthService.logInWithEmailAndPassword(value.username, value.password).catch((error) => {
749
+ throw firebaseAuthErrorToReadableError(error);
750
+ });
751
+ }
752
+ return from(result).pipe(tap(() => {
753
+ this.doneOrCancelled.next(true);
754
+ }));
755
+ };
756
+ this.handleRecoveryAction = (value) => {
757
+ this.recoveryFormValue = value;
758
+ this.emailFormValue = { username: value.email, password: '' };
759
+ let result = this.dbxFirebaseAuthService.sendPasswordResetEmail(value.email);
760
+ return from(result).pipe(tap(() => {
761
+ this.onRecoveringSuccess();
762
+ }));
763
+ };
764
+ }
765
+ ngOnDestroy() {
766
+ this._emailMode.complete();
767
+ }
768
+ static openEmailLoginContext(dbxFirebaseLoginContext, config) {
769
+ return dbxFirebaseLoginContext.showContext({
770
+ config: {
771
+ componentClass: DbxFirebaseLoginEmailContentComponent,
772
+ data: config
773
+ },
774
+ use: (instance) => firstValueFrom(instance.doneOrCancelled)
775
+ });
776
+ }
777
+ get loginMode() {
778
+ return this.config.loginMode;
779
+ }
780
+ get isLoginMode() {
781
+ return this.loginMode === 'login';
782
+ }
783
+ get isRegisterMode() {
784
+ return this.loginMode === 'register';
785
+ }
786
+ get buttonText() {
787
+ return this.config.loginMode === 'register' ? 'Register' : 'Log In';
788
+ }
789
+ // MARK: Recovery
790
+ openRecovery() {
791
+ this._emailMode.next('recover');
792
+ }
793
+ // MARK: Recovering
794
+ onRecoveringSuccess() {
795
+ }
796
+ // MARK: Cancel
797
+ onCancel() {
798
+ this.doneOrCancelled.next(false);
799
+ }
800
+ onCancelReset() {
801
+ this.doneOrCancelled.next(false);
802
+ }
803
+ }
804
+ DbxFirebaseLoginEmailContentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginEmailContentComponent, deps: [{ token: DbxFirebaseAuthService }, { token: DBX_INJECTION_COMPONENT_DATA }], target: i0.ɵɵFactoryTarget.Component });
805
+ DbxFirebaseLoginEmailContentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginEmailContentComponent, selector: "ng-component", ngImport: i0, template: "<div class=\"dbx-firebase-login-email-content\">\n <ng-container [ngSwitch]=\"emailMode$ | async\">\n <ng-container *ngSwitchCase=\"'login'\">\n <ng-container *ngTemplateOutlet=\"loginView\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'recover'\">\n <ng-container *ngTemplateOutlet=\"resetPassword\"></ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<!-- Login View -->\n<ng-template #loginView>\n <ng-container dbxAction [dbxActionHandler]=\"handleLoginAction\">\n <dbx-firebase-email-form [config]=\"formConfig\" dbxActionForm [dbxFormSource]=\"emailFormValue\">\n </dbx-firebase-email-form>\n <div class=\"dbx-firebase-login-email-forgot-prompt\" *ngIf=\"isLoginMode\">\n <dbx-link [anchor]=\"forgotAnchor\">Forgot Password?</dbx-link>\n </div>\n <div class=\"dbx-flex\">\n <dbx-button class=\"dbx-wide-button\" [text]=\"buttonText\" [raised]=\"true\" color=\"primary\" dbxActionButton>\n </dbx-button>\n <dbx-button-spacer></dbx-button-spacer>\n <span class=\"dbx-spacer\"></span>\n <button mat-flat-button (click)=\"onCancel()\">Cancel</button>\n </div>\n <dbx-error dbxActionError></dbx-error>\n </ng-container>\n</ng-template>\n\n<!-- Reset Password View -->\n<ng-template #resetPassword>\n <ng-container dbxAction [dbxActionHandler]=\"handleRecoveryAction\">\n <dbx-firebase-email-recovery-form dbxActionForm [dbxFormSource]=\"recoveryFormValue\">\n </dbx-firebase-email-recovery-form>\n <p class=\"dbx-hint\">An email will be sent to the above address to help you reset your password.</p>\n <div class=\"dbx-flex\">\n <dbx-button class=\"dbx-wide-button\" text=\"Send Recovery Email\" [raised]=\"true\" color=\"primary\" dbxActionButton>\n </dbx-button>\n <span class=\"dbx-spacer\"></span>\n <button mat-flat-button (click)=\"onCancelReset()\">Cancel Recovery</button>\n </div>\n <dbx-error dbxActionError></dbx-error>\n </ng-container>\n</ng-template>\n", components: [{ type: DbxFirebaseEmailFormComponent, selector: "dbx-firebase-email-form", inputs: ["config"] }, { type: i3.DbxAnchorLinkComponent, selector: "dbx-link", inputs: ["anchor", "ref", "href"] }, { type: i3.DbxButtonComponent, selector: "dbx-button", inputs: ["type", "raised", "stroked", "flat", "color", "customButtonColor", "customTextColor", "customSpinnerColor"] }, { type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3.DbxReadableErrorComponent, selector: "dbx-error", inputs: ["error"] }, { type: DbxFirebaseEmailRecoveryFormComponent, selector: "dbx-firebase-email-recovery-form" }], directives: [{ type: i6.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i6.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i6.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3$1.DbxActionDirective, selector: "dbx-action,[dbxAction],dbx-action-context,[dbxActionContext]", exportAs: ["action", "dbxAction"] }, { type: i3$1.DbxActionHandlerDirective, selector: "[dbxActionHandler]", inputs: ["dbxActionHandler"] }, { type: i1$1.DbxActionFormDirective, selector: "[dbxActionForm]", inputs: ["dbxActionFormValidator", "dbxActionFormModified", "formDisabledOnWorking"] }, { type: i1$1.DbxFormSourceDirective, selector: "[dbxFormSource]", inputs: ["dbxFormSourceMode", "dbxFormSource"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$1.DbxActionButtonDirective, selector: "[dbxActionButton]" }, { type: i3.DbxButtonSpacerDirective, selector: "dbx-button-spacer,dbxButtonSpacer" }, { type: i3.DbxActionErrorDirective, selector: "[dbxActionError]" }], pipes: { "async": i6.AsyncPipe } });
806
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginEmailContentComponent, decorators: [{
807
+ type: Component,
808
+ args: [{ template: "<div class=\"dbx-firebase-login-email-content\">\n <ng-container [ngSwitch]=\"emailMode$ | async\">\n <ng-container *ngSwitchCase=\"'login'\">\n <ng-container *ngTemplateOutlet=\"loginView\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'recover'\">\n <ng-container *ngTemplateOutlet=\"resetPassword\"></ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<!-- Login View -->\n<ng-template #loginView>\n <ng-container dbxAction [dbxActionHandler]=\"handleLoginAction\">\n <dbx-firebase-email-form [config]=\"formConfig\" dbxActionForm [dbxFormSource]=\"emailFormValue\">\n </dbx-firebase-email-form>\n <div class=\"dbx-firebase-login-email-forgot-prompt\" *ngIf=\"isLoginMode\">\n <dbx-link [anchor]=\"forgotAnchor\">Forgot Password?</dbx-link>\n </div>\n <div class=\"dbx-flex\">\n <dbx-button class=\"dbx-wide-button\" [text]=\"buttonText\" [raised]=\"true\" color=\"primary\" dbxActionButton>\n </dbx-button>\n <dbx-button-spacer></dbx-button-spacer>\n <span class=\"dbx-spacer\"></span>\n <button mat-flat-button (click)=\"onCancel()\">Cancel</button>\n </div>\n <dbx-error dbxActionError></dbx-error>\n </ng-container>\n</ng-template>\n\n<!-- Reset Password View -->\n<ng-template #resetPassword>\n <ng-container dbxAction [dbxActionHandler]=\"handleRecoveryAction\">\n <dbx-firebase-email-recovery-form dbxActionForm [dbxFormSource]=\"recoveryFormValue\">\n </dbx-firebase-email-recovery-form>\n <p class=\"dbx-hint\">An email will be sent to the above address to help you reset your password.</p>\n <div class=\"dbx-flex\">\n <dbx-button class=\"dbx-wide-button\" text=\"Send Recovery Email\" [raised]=\"true\" color=\"primary\" dbxActionButton>\n </dbx-button>\n <span class=\"dbx-spacer\"></span>\n <button mat-flat-button (click)=\"onCancelReset()\">Cancel Recovery</button>\n </div>\n <dbx-error dbxActionError></dbx-error>\n </ng-container>\n</ng-template>\n" }]
809
+ }], ctorParameters: function () { return [{ type: DbxFirebaseAuthService }, { type: undefined, decorators: [{
810
+ type: Inject,
811
+ args: [DBX_INJECTION_COMPONENT_DATA]
812
+ }] }]; } });
813
+
814
+ class DbxFirebaseLoginEmailComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
815
+ constructor() {
816
+ super(...arguments);
817
+ this.loginProvider = 'email';
818
+ }
819
+ handleLogin() {
820
+ return DbxFirebaseLoginEmailContentComponent.openEmailLoginContext(this.dbxFirebaseLoginContext, { loginMode: 'login', passwordConfig: this.dbxFirebaseAuthLoginService.getPasswordConfig() });
821
+ }
822
+ }
823
+ DbxFirebaseLoginEmailComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginEmailComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
824
+ DbxFirebaseLoginEmailComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginEmailComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
825
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginEmailComponent, decorators: [{
826
+ type: Component,
827
+ args: [{
828
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
829
+ }]
830
+ }] });
831
+
832
+ class DbxFirebaseLoginFacebookComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
833
+ constructor() {
834
+ super(...arguments);
835
+ this.loginProvider = 'facebook';
836
+ }
837
+ handleLogin() {
838
+ return this.dbxFirebaseAuthService.logInWithFacebook();
839
+ }
840
+ }
841
+ DbxFirebaseLoginFacebookComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginFacebookComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
842
+ DbxFirebaseLoginFacebookComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginFacebookComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
843
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginFacebookComponent, decorators: [{
844
+ type: Component,
845
+ args: [{
846
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
847
+ }]
848
+ }] });
849
+
850
+ class DbxFirebaseLoginGoogleComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
851
+ constructor() {
852
+ super(...arguments);
853
+ this.loginProvider = 'google';
854
+ }
855
+ handleLogin() {
856
+ return this.dbxFirebaseAuthService.logInWithGoogle();
857
+ }
858
+ }
859
+ DbxFirebaseLoginGoogleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginGoogleComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
860
+ DbxFirebaseLoginGoogleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginGoogleComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
861
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginGoogleComponent, decorators: [{
862
+ type: Component,
863
+ args: [{
864
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
865
+ }]
866
+ }] });
867
+
868
+ /**
869
+ * Pre-configured register component that displays all configured login types and their registration components.
870
+ */
871
+ class DbxFirebaseRegisterComponent {
872
+ }
873
+ DbxFirebaseRegisterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseRegisterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
874
+ DbxFirebaseRegisterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseRegisterComponent, selector: "dbx-firebase-register", inputs: { providerTypes: "providerTypes", omitProviderTypes: "omitProviderTypes", providerCategories: "providerCategories" }, ngImport: i0, template: `<dbx-firebase-login loginMode="register" [providerTypes]="providerTypes" [omitProviderTypes]="omitProviderTypes" [providerCategories]="providerCategories"></dbx-firebase-login>`, isInline: true, components: [{ type: DbxFirebaseLoginComponent, selector: "dbx-firebase-login", inputs: ["loginMode", "providerTypes", "omitProviderTypes", "providerCategories"] }] });
875
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseRegisterComponent, decorators: [{
876
+ type: Component,
877
+ args: [{
878
+ selector: 'dbx-firebase-register',
879
+ template: `<dbx-firebase-login loginMode="register" [providerTypes]="providerTypes" [omitProviderTypes]="omitProviderTypes" [providerCategories]="providerCategories"></dbx-firebase-login>`
880
+ }]
881
+ }], propDecorators: { providerTypes: [{
882
+ type: Input
883
+ }], omitProviderTypes: [{
884
+ type: Input
885
+ }], providerCategories: [{
886
+ type: Input
887
+ }] } });
888
+
889
+ class DbxFirebaseLoginGitHubComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
890
+ constructor() {
891
+ super(...arguments);
892
+ this.loginProvider = 'github';
893
+ }
894
+ handleLogin() {
895
+ return this.dbxFirebaseAuthService.logInWithGithub();
896
+ }
897
+ }
898
+ DbxFirebaseLoginGitHubComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginGitHubComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
899
+ DbxFirebaseLoginGitHubComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginGitHubComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
900
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginGitHubComponent, decorators: [{
901
+ type: Component,
902
+ args: [{
903
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
904
+ }]
905
+ }] });
906
+
907
+ class DbxFirebaseLoginTwitterComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
908
+ constructor() {
909
+ super(...arguments);
910
+ this.loginProvider = 'twitter';
911
+ }
912
+ handleLogin() {
913
+ return this.dbxFirebaseAuthService.logInWithTwitter();
914
+ }
915
+ }
916
+ DbxFirebaseLoginTwitterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginTwitterComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
917
+ DbxFirebaseLoginTwitterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginTwitterComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
918
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginTwitterComponent, decorators: [{
919
+ type: Component,
920
+ args: [{
921
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
922
+ }]
923
+ }] });
924
+
925
+ class DbxFirebaseLoginMicrosoftComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
926
+ constructor() {
927
+ super(...arguments);
928
+ this.loginProvider = 'microsoft';
929
+ }
930
+ handleLogin() {
931
+ return this.dbxFirebaseAuthService.logInWithMicrosoft();
932
+ }
933
+ }
934
+ DbxFirebaseLoginMicrosoftComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginMicrosoftComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
935
+ DbxFirebaseLoginMicrosoftComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginMicrosoftComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "\n <dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n </dbx-firebase-login-button-container>\n", isInline: true, components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
936
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginMicrosoftComponent, decorators: [{
937
+ type: Component,
938
+ args: [{
939
+ template: DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE
940
+ }]
941
+ }] });
942
+
943
+ class DbxFirebaseRegisterEmailComponent extends AbstractConfiguredDbxFirebaseLoginButtonDirective {
944
+ constructor() {
945
+ super(...arguments);
946
+ this.loginProvider = 'email';
947
+ }
948
+ handleLogin() {
949
+ return DbxFirebaseLoginEmailContentComponent.openEmailLoginContext(this.dbxFirebaseLoginContext, { loginMode: 'register', passwordConfig: this.dbxFirebaseAuthLoginService.getPasswordConfig() });
950
+ }
951
+ }
952
+ DbxFirebaseRegisterEmailComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseRegisterEmailComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
953
+ DbxFirebaseRegisterEmailComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseRegisterEmailComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n</dbx-firebase-login-button-container>\n", components: [{ type: DbxFirebaseLoginButtonContainerComponent, selector: "dbx-firebase-login-button-container" }, { type: DbxFirebaseLoginButtonComponent, selector: "dbx-firebase-login-button", inputs: ["config"] }] });
954
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseRegisterEmailComponent, decorators: [{
955
+ type: Component,
956
+ args: [{ template: "<dbx-firebase-login-button-container>\n <dbx-firebase-login-button [config]=\"config\"></dbx-firebase-login-button>\n</dbx-firebase-login-button-container>\n" }]
957
+ }] });
958
+
959
+ class DbxFirebaseLoginTermsComponent {
960
+ constructor(dbxFirebaseAuthLoginService) {
961
+ this.dbxFirebaseAuthLoginService = dbxFirebaseAuthLoginService;
962
+ this.config = {
963
+ componentClass: this.dbxFirebaseAuthLoginService.termsComponentClass
964
+ };
965
+ }
966
+ }
967
+ DbxFirebaseLoginTermsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginTermsComponent, deps: [{ token: DbxFirebaseAuthLoginService }], target: i0.ɵɵFactoryTarget.Component });
968
+ DbxFirebaseLoginTermsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginTermsComponent, selector: "dbx-firebase-login-terms", host: { classAttribute: "dbx-firebase-login-terms d-block" }, ngImport: i0, template: `<dbx-injection [config]="config"></dbx-injection>`, isInline: true, components: [{ type: i3$1.DbxInjectionComponent, selector: "dbx-injection, [dbxInjection], [dbx-injection]", inputs: ["config", "template"] }] });
969
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginTermsComponent, decorators: [{
970
+ type: Component,
971
+ args: [{
972
+ selector: 'dbx-firebase-login-terms',
973
+ template: `<dbx-injection [config]="config"></dbx-injection>`,
974
+ host: {
975
+ 'class': 'dbx-firebase-login-terms d-block',
976
+ }
977
+ }]
978
+ }], ctorParameters: function () { return [{ type: DbxFirebaseAuthLoginService }]; } });
979
+
980
+ class DbxFirebaseLoginContextBackButtonComponent {
981
+ constructor() {
982
+ this.onCancel = new EventEmitter();
983
+ this.anchor = {
984
+ onClick: () => this.onCancel.emit()
985
+ };
986
+ }
987
+ }
988
+ DbxFirebaseLoginContextBackButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginContextBackButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
989
+ DbxFirebaseLoginContextBackButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseLoginContextBackButtonComponent, selector: "dbx-firebase-login-context-back-button", outputs: { onCancel: "onCancel" }, ngImport: i0, template: `
990
+ <dbx-link [anchor]="anchor">Choose other login method.</dbx-link>
991
+ `, isInline: true, components: [{ type: i3.DbxAnchorLinkComponent, selector: "dbx-link", inputs: ["anchor", "ref", "href"] }] });
992
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginContextBackButtonComponent, decorators: [{
993
+ type: Component,
994
+ args: [{
995
+ 'selector': 'dbx-firebase-login-context-back-button',
996
+ 'template': `
997
+ <dbx-link [anchor]="anchor">Choose other login method.</dbx-link>
998
+ `
999
+ }]
1000
+ }], propDecorators: { onCancel: [{
1001
+ type: Output
1002
+ }] } });
1003
+
1004
+ class DbxFirebaseLoginModuleRootConfig extends DbxFirebaseLoginTermsConfig {
1005
+ }
1006
+ function defaultFirebaseAuthLoginProvidersFactory() {
1007
+ // NOTE: Asset URLS are from Firebase.
1008
+ // https://firebase.google.com/docs/auth/web/firebaseui
1009
+ const baseFirebaseJSUrl = `https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth`;
1010
+ // NOTE: Colors are from https://brandcolors.net/
1011
+ return [{
1012
+ category: DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY,
1013
+ loginMethodType: 'email',
1014
+ componentClass: DbxFirebaseLoginEmailComponent,
1015
+ registrationComponentClass: DbxFirebaseRegisterEmailComponent,
1016
+ assets: {
1017
+ logoUrl: `${baseFirebaseJSUrl}/mail.svg`,
1018
+ loginText: 'Continue with Email',
1019
+ backgroundColor: '#ea4335',
1020
+ textColor: '#FFF'
1021
+ }
1022
+ }, {
1023
+ category: OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY,
1024
+ loginMethodType: 'google',
1025
+ componentClass: DbxFirebaseLoginGoogleComponent,
1026
+ assets: {
1027
+ logoUrl: `${baseFirebaseJSUrl}/google.svg`,
1028
+ loginText: 'Continue with Google',
1029
+ backgroundColor: '#FFF',
1030
+ textColor: '#757575'
1031
+ }
1032
+ }, {
1033
+ category: OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY,
1034
+ loginMethodType: 'facebook',
1035
+ componentClass: DbxFirebaseLoginFacebookComponent,
1036
+ assets: {
1037
+ logoUrl: `${baseFirebaseJSUrl}/facebook.svg`,
1038
+ loginText: 'Continue with Facebook',
1039
+ backgroundColor: '#4267B2',
1040
+ textColor: '#FFF'
1041
+ }
1042
+ }, {
1043
+ category: OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY,
1044
+ loginMethodType: 'twitter',
1045
+ componentClass: DbxFirebaseLoginTwitterComponent,
1046
+ assets: {
1047
+ logoUrl: `${baseFirebaseJSUrl}/twitter.svg`,
1048
+ loginText: 'Continue with Twitter',
1049
+ backgroundColor: '#1da1f2',
1050
+ textColor: '#FFF'
1051
+ }
1052
+ }, {
1053
+ category: OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY,
1054
+ loginMethodType: 'github',
1055
+ componentClass: DbxFirebaseLoginGitHubComponent,
1056
+ assets: {
1057
+ logoUrl: `${baseFirebaseJSUrl}/github.svg`,
1058
+ loginText: 'Continue with Github',
1059
+ backgroundColor: '#333',
1060
+ textColor: '#FFF'
1061
+ }
1062
+ },
1063
+ {
1064
+ category: DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY,
1065
+ loginMethodType: 'anonymous',
1066
+ componentClass: DbxFirebaseLoginAnonymousComponent,
1067
+ assets: {
1068
+ loginIcon: 'account_circle',
1069
+ loginText: 'Continue as Guest',
1070
+ backgroundColor: '#000',
1071
+ textColor: '#FFF'
1072
+ }
1073
+ }];
1074
+ }
1075
+ /**
1076
+ * Contains components related to logging in.
1077
+ */
1078
+ class DbxFirebaseLoginModule {
1079
+ constructor(config, dbxFirebaseAuthLoginService) {
1080
+ if (config.enabledLoginMethods === true) {
1081
+ dbxFirebaseAuthLoginService.setEnableAll();
1082
+ }
1083
+ else {
1084
+ dbxFirebaseAuthLoginService.enable(config.enabledLoginMethods); // enable the types in the service.
1085
+ }
1086
+ }
1087
+ static forRoot(config) {
1088
+ return {
1089
+ ngModule: DbxFirebaseLoginModule,
1090
+ providers: [{
1091
+ provide: DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN,
1092
+ useFactory: defaultFirebaseAuthLoginProvidersFactory
1093
+ }, {
1094
+ provide: DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN,
1095
+ useValue: config.termsComponentClass
1096
+ }, {
1097
+ provide: DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN,
1098
+ useValue: config.passwordConfig
1099
+ }, {
1100
+ provide: DbxFirebaseLoginModuleRootConfig,
1101
+ useValue: config
1102
+ }, {
1103
+ provide: DbxFirebaseLoginTermsConfig,
1104
+ useValue: config
1105
+ }]
1106
+ };
1107
+ }
1108
+ }
1109
+ DbxFirebaseLoginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginModule, deps: [{ token: DbxFirebaseLoginModuleRootConfig }, { token: DbxFirebaseAuthLoginService }], target: i0.ɵɵFactoryTarget.NgModule });
1110
+ DbxFirebaseLoginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginModule, declarations: [DbxFirebaseLoginComponent,
1111
+ DbxFirebaseLoginContextDirective,
1112
+ DbxFirebaseLoginContextBackButtonComponent,
1113
+ DbxFirebaseRegisterComponent,
1114
+ DbxFirebaseLoginListComponent,
1115
+ DbxFirebaseLoginButtonComponent,
1116
+ DbxFirebaseLoginButtonContainerComponent,
1117
+ DbxFirebaseLoginEmailComponent,
1118
+ DbxFirebaseLoginEmailContentComponent,
1119
+ DbxFirebaseEmailFormComponent,
1120
+ DbxFirebaseEmailRecoveryFormComponent,
1121
+ DbxFirebaseRegisterEmailComponent,
1122
+ DbxFirebaseLoginGoogleComponent,
1123
+ DbxFirebaseLoginGitHubComponent,
1124
+ DbxFirebaseLoginTwitterComponent,
1125
+ DbxFirebaseLoginAppleComponent,
1126
+ DbxFirebaseLoginMicrosoftComponent,
1127
+ DbxFirebaseLoginFacebookComponent,
1128
+ DbxFirebaseLoginAnonymousComponent,
1129
+ DbxFirebaseLoginTermsComponent,
1130
+ DbxFirebaseLoginTermsSimpleComponent], imports: [CommonModule,
1131
+ MatIconModule,
1132
+ MatButtonModule,
1133
+ DbxRouterAnchorModule,
1134
+ DbxFormIoModule,
1135
+ DbxFormModule,
1136
+ DbxFormlyModule,
1137
+ DbxFormActionModule,
1138
+ DbxFormFormlyTextFieldModule,
1139
+ DbxReadableErrorModule,
1140
+ DbxActionModule,
1141
+ DbxButtonModule,
1142
+ DbxInjectionComponentModule], exports: [DbxFirebaseLoginComponent,
1143
+ DbxFirebaseLoginContextDirective,
1144
+ DbxFirebaseLoginContextBackButtonComponent,
1145
+ DbxFirebaseRegisterComponent,
1146
+ DbxFirebaseLoginListComponent,
1147
+ DbxFirebaseLoginButtonComponent,
1148
+ DbxFirebaseLoginButtonContainerComponent,
1149
+ DbxFirebaseLoginEmailComponent,
1150
+ DbxFirebaseLoginEmailContentComponent,
1151
+ DbxFirebaseEmailFormComponent,
1152
+ DbxFirebaseEmailRecoveryFormComponent,
1153
+ DbxFirebaseRegisterEmailComponent,
1154
+ DbxFirebaseLoginGoogleComponent,
1155
+ DbxFirebaseLoginGitHubComponent,
1156
+ DbxFirebaseLoginTwitterComponent,
1157
+ DbxFirebaseLoginAppleComponent,
1158
+ DbxFirebaseLoginMicrosoftComponent,
1159
+ DbxFirebaseLoginFacebookComponent,
1160
+ DbxFirebaseLoginAnonymousComponent,
1161
+ DbxFirebaseLoginTermsComponent,
1162
+ DbxFirebaseLoginTermsSimpleComponent] });
1163
+ DbxFirebaseLoginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginModule, providers: [], imports: [[
1164
+ CommonModule,
1165
+ MatIconModule,
1166
+ MatButtonModule,
1167
+ DbxRouterAnchorModule,
1168
+ DbxFormIoModule,
1169
+ DbxFormModule,
1170
+ DbxFormlyModule,
1171
+ DbxFormActionModule,
1172
+ DbxFormFormlyTextFieldModule,
1173
+ DbxReadableErrorModule,
1174
+ DbxActionModule,
1175
+ DbxButtonModule,
1176
+ DbxInjectionComponentModule
1177
+ ]] });
1178
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseLoginModule, decorators: [{
1179
+ type: NgModule,
1180
+ args: [{
1181
+ imports: [
1182
+ CommonModule,
1183
+ MatIconModule,
1184
+ MatButtonModule,
1185
+ DbxRouterAnchorModule,
1186
+ DbxFormIoModule,
1187
+ DbxFormModule,
1188
+ DbxFormlyModule,
1189
+ DbxFormActionModule,
1190
+ DbxFormFormlyTextFieldModule,
1191
+ DbxReadableErrorModule,
1192
+ DbxActionModule,
1193
+ DbxButtonModule,
1194
+ DbxInjectionComponentModule
1195
+ ],
1196
+ declarations: [
1197
+ DbxFirebaseLoginComponent,
1198
+ DbxFirebaseLoginContextDirective,
1199
+ DbxFirebaseLoginContextBackButtonComponent,
1200
+ DbxFirebaseRegisterComponent,
1201
+ DbxFirebaseLoginListComponent,
1202
+ DbxFirebaseLoginButtonComponent,
1203
+ DbxFirebaseLoginButtonContainerComponent,
1204
+ DbxFirebaseLoginEmailComponent,
1205
+ DbxFirebaseLoginEmailContentComponent,
1206
+ DbxFirebaseEmailFormComponent,
1207
+ DbxFirebaseEmailRecoveryFormComponent,
1208
+ DbxFirebaseRegisterEmailComponent,
1209
+ DbxFirebaseLoginGoogleComponent,
1210
+ DbxFirebaseLoginGitHubComponent,
1211
+ DbxFirebaseLoginTwitterComponent,
1212
+ DbxFirebaseLoginAppleComponent,
1213
+ DbxFirebaseLoginMicrosoftComponent,
1214
+ DbxFirebaseLoginFacebookComponent,
1215
+ DbxFirebaseLoginAnonymousComponent,
1216
+ DbxFirebaseLoginTermsComponent,
1217
+ DbxFirebaseLoginTermsSimpleComponent
1218
+ ],
1219
+ exports: [
1220
+ DbxFirebaseLoginComponent,
1221
+ DbxFirebaseLoginContextDirective,
1222
+ DbxFirebaseLoginContextBackButtonComponent,
1223
+ DbxFirebaseRegisterComponent,
1224
+ DbxFirebaseLoginListComponent,
1225
+ DbxFirebaseLoginButtonComponent,
1226
+ DbxFirebaseLoginButtonContainerComponent,
1227
+ DbxFirebaseLoginEmailComponent,
1228
+ DbxFirebaseLoginEmailContentComponent,
1229
+ DbxFirebaseEmailFormComponent,
1230
+ DbxFirebaseEmailRecoveryFormComponent,
1231
+ DbxFirebaseRegisterEmailComponent,
1232
+ DbxFirebaseLoginGoogleComponent,
1233
+ DbxFirebaseLoginGitHubComponent,
1234
+ DbxFirebaseLoginTwitterComponent,
1235
+ DbxFirebaseLoginAppleComponent,
1236
+ DbxFirebaseLoginMicrosoftComponent,
1237
+ DbxFirebaseLoginFacebookComponent,
1238
+ DbxFirebaseLoginAnonymousComponent,
1239
+ DbxFirebaseLoginTermsComponent,
1240
+ DbxFirebaseLoginTermsSimpleComponent
1241
+ ],
1242
+ providers: []
1243
+ }]
1244
+ }], ctorParameters: function () { return [{ type: DbxFirebaseLoginModuleRootConfig }, { type: DbxFirebaseAuthLoginService }]; } });
1245
+
1246
+ class DbxFirebaseAuthModule {
1247
+ static forRoot(config) {
1248
+ const providers = [
1249
+ DbxFirebaseAuthService,
1250
+ {
1251
+ provide: DbxAuthService,
1252
+ useExisting: DbxFirebaseAuthService
1253
+ }
1254
+ ];
1255
+ if (config.delegateFactory) {
1256
+ providers.push({
1257
+ provide: DbxFirebaseAuthServiceDelegate,
1258
+ useFactory: config.delegateFactory,
1259
+ deps: [Injector]
1260
+ });
1261
+ }
1262
+ return {
1263
+ ngModule: DbxFirebaseAuthModule,
1264
+ providers
1265
+ };
1266
+ }
1267
+ }
1268
+ DbxFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1269
+ DbxFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthModule });
1270
+ DbxFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthModule });
1271
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseAuthModule, decorators: [{
1272
+ type: NgModule,
1273
+ args: [{}]
1274
+ }] });
1275
+
1276
+ class DbxFirebaseParsedEmulatorsConfig {
1277
+ }
1278
+
1279
+ // TODO: remove "as any" typescript casting - https://github.com/angular/angularfire/issues/3086
1280
+ /**
1281
+ * Default firebase firestore provider module.
1282
+ */
1283
+ class DbxFirebaseDefaultFirestoreProviderModule {
1284
+ }
1285
+ DbxFirebaseDefaultFirestoreProviderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirestoreProviderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1286
+ DbxFirebaseDefaultFirestoreProviderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirestoreProviderModule, imports: [i1$2.FirestoreModule] });
1287
+ DbxFirebaseDefaultFirestoreProviderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirestoreProviderModule, imports: [[
1288
+ provideFirestore(((injector) => {
1289
+ const firestore = getFirestore();
1290
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1291
+ if (emulators?.useEmulators && emulators?.firestore) {
1292
+ connectFirestoreEmulator(firestore, emulators.firestore.host, emulators.firestore.port, {});
1293
+ }
1294
+ enableIndexedDbPersistence(firestore);
1295
+ return firestore;
1296
+ }))
1297
+ ]] });
1298
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirestoreProviderModule, decorators: [{
1299
+ type: NgModule,
1300
+ args: [{
1301
+ imports: [
1302
+ provideFirestore(((injector) => {
1303
+ const firestore = getFirestore();
1304
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1305
+ if (emulators?.useEmulators && emulators?.firestore) {
1306
+ connectFirestoreEmulator(firestore, emulators.firestore.host, emulators.firestore.port, {});
1307
+ }
1308
+ enableIndexedDbPersistence(firestore);
1309
+ return firestore;
1310
+ }))
1311
+ ]
1312
+ }]
1313
+ }] });
1314
+ /**
1315
+ * Default firebase auth provider module.
1316
+ */
1317
+ class DbxFirebaseDefaultAuthProviderModule {
1318
+ }
1319
+ DbxFirebaseDefaultAuthProviderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultAuthProviderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1320
+ DbxFirebaseDefaultAuthProviderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultAuthProviderModule, imports: [i1.AuthModule] });
1321
+ DbxFirebaseDefaultAuthProviderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultAuthProviderModule, imports: [[
1322
+ provideAuth(((injector) => {
1323
+ const auth = getAuth();
1324
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1325
+ if (emulators?.useEmulators && emulators?.auth) {
1326
+ connectAuthEmulator(auth, `http://${emulators.auth.host}:${emulators.auth.port}`);
1327
+ }
1328
+ return auth;
1329
+ }))
1330
+ ]] });
1331
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultAuthProviderModule, decorators: [{
1332
+ type: NgModule,
1333
+ args: [{
1334
+ imports: [
1335
+ provideAuth(((injector) => {
1336
+ const auth = getAuth();
1337
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1338
+ if (emulators?.useEmulators && emulators?.auth) {
1339
+ connectAuthEmulator(auth, `http://${emulators.auth.host}:${emulators.auth.port}`);
1340
+ }
1341
+ return auth;
1342
+ }))
1343
+ ]
1344
+ }]
1345
+ }] });
1346
+ /**
1347
+ * Default firebase storage provider module.
1348
+ */
1349
+ class DbxFirebaseDefaultStorageProviderModule {
1350
+ }
1351
+ DbxFirebaseDefaultStorageProviderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultStorageProviderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1352
+ DbxFirebaseDefaultStorageProviderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultStorageProviderModule, imports: [i3$2.StorageModule] });
1353
+ DbxFirebaseDefaultStorageProviderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultStorageProviderModule, imports: [[
1354
+ provideStorage(((injector) => {
1355
+ const storage = getStorage();
1356
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1357
+ if (emulators?.useEmulators && emulators?.storage) {
1358
+ connectStorageEmulator(storage, emulators.storage.host, emulators.storage.port, {});
1359
+ }
1360
+ return storage;
1361
+ }))
1362
+ ]] });
1363
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultStorageProviderModule, decorators: [{
1364
+ type: NgModule,
1365
+ args: [{
1366
+ imports: [
1367
+ provideStorage(((injector) => {
1368
+ const storage = getStorage();
1369
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1370
+ if (emulators?.useEmulators && emulators?.storage) {
1371
+ connectStorageEmulator(storage, emulators.storage.host, emulators.storage.port, {});
1372
+ }
1373
+ return storage;
1374
+ }))
1375
+ ]
1376
+ }]
1377
+ }] });
1378
+ /**
1379
+ * Default firebase functions provider module.
1380
+ */
1381
+ class DbxFirebaseDefaultFunctionsProviderModule {
1382
+ }
1383
+ DbxFirebaseDefaultFunctionsProviderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFunctionsProviderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1384
+ DbxFirebaseDefaultFunctionsProviderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFunctionsProviderModule, imports: [i4$1.FunctionsModule] });
1385
+ DbxFirebaseDefaultFunctionsProviderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFunctionsProviderModule, imports: [[
1386
+ provideFunctions(((injector) => {
1387
+ const functions = getFunctions();
1388
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1389
+ if (emulators?.useEmulators && emulators?.functions) {
1390
+ connectFunctionsEmulator(functions, emulators.functions.host, emulators.functions.port);
1391
+ }
1392
+ return functions;
1393
+ }))
1394
+ ]] });
1395
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFunctionsProviderModule, decorators: [{
1396
+ type: NgModule,
1397
+ args: [{
1398
+ imports: [
1399
+ provideFunctions(((injector) => {
1400
+ const functions = getFunctions();
1401
+ const emulators = injector.get(DbxFirebaseParsedEmulatorsConfig, undefined);
1402
+ if (emulators?.useEmulators && emulators?.functions) {
1403
+ connectFunctionsEmulator(functions, emulators.functions.host, emulators.functions.port);
1404
+ }
1405
+ return functions;
1406
+ }))
1407
+ ]
1408
+ }]
1409
+ }] });
1410
+ const DBX_FIREBASE_OPTIONS_TOKEN = new InjectionToken('DbxFirebaseOptions');
1411
+ /**
1412
+ * Default provider module.
1413
+ */
1414
+ class DbxFirebaseDefaultFirebaseProvidersModule {
1415
+ static forRoot(firebaseOptions) {
1416
+ return {
1417
+ ngModule: DbxFirebaseDefaultFirebaseProvidersModule,
1418
+ providers: [{
1419
+ provide: DBX_FIREBASE_OPTIONS_TOKEN,
1420
+ useValue: firebaseOptions
1421
+ }]
1422
+ };
1423
+ }
1424
+ }
1425
+ DbxFirebaseDefaultFirebaseProvidersModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirebaseProvidersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1426
+ DbxFirebaseDefaultFirebaseProvidersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirebaseProvidersModule, imports: [DbxFirebaseDefaultFirestoreProviderModule, DbxFirebaseDefaultAuthProviderModule, DbxFirebaseDefaultStorageProviderModule, DbxFirebaseDefaultFunctionsProviderModule, i5.FirebaseAppModule] });
1427
+ DbxFirebaseDefaultFirebaseProvidersModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirebaseProvidersModule, imports: [[
1428
+ DbxFirebaseDefaultFirestoreProviderModule,
1429
+ DbxFirebaseDefaultAuthProviderModule,
1430
+ DbxFirebaseDefaultStorageProviderModule,
1431
+ DbxFirebaseDefaultFunctionsProviderModule,
1432
+ provideFirebaseApp(((injector) => {
1433
+ const firebaseOptions = injector.get(DBX_FIREBASE_OPTIONS_TOKEN);
1434
+ return initializeApp(firebaseOptions);
1435
+ }))
1436
+ ]] });
1437
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDefaultFirebaseProvidersModule, decorators: [{
1438
+ type: NgModule,
1439
+ args: [{
1440
+ imports: [
1441
+ DbxFirebaseDefaultFirestoreProviderModule,
1442
+ DbxFirebaseDefaultAuthProviderModule,
1443
+ DbxFirebaseDefaultStorageProviderModule,
1444
+ DbxFirebaseDefaultFunctionsProviderModule,
1445
+ provideFirebaseApp(((injector) => {
1446
+ const firebaseOptions = injector.get(DBX_FIREBASE_OPTIONS_TOKEN);
1447
+ return initializeApp(firebaseOptions);
1448
+ }))
1449
+ ]
1450
+ }]
1451
+ }] });
1452
+
1453
+ /**
1454
+ * Used to configure the DbxFirebaseEmulatorsConfig provider.
1455
+ */
1456
+ class DbxFirebaseEmulatorModule {
1457
+ static forRoot(config) {
1458
+ const defaultHost = config.host ?? 'localhost';
1459
+ function emulatorConfig(emulator) {
1460
+ return (emulator) ? { host: emulator.host ?? defaultHost, port: emulator.port } : undefined;
1461
+ }
1462
+ const finalConfig = {
1463
+ useEmulators: config.useEmulators !== false,
1464
+ auth: emulatorConfig(config.auth),
1465
+ firestore: emulatorConfig(config.firestore),
1466
+ storage: emulatorConfig(config.storage),
1467
+ functions: emulatorConfig(config.functions),
1468
+ database: emulatorConfig(config.database)
1469
+ };
1470
+ return {
1471
+ ngModule: DbxFirebaseEmulatorModule,
1472
+ providers: [{
1473
+ provide: DbxFirebaseParsedEmulatorsConfig,
1474
+ useValue: finalConfig
1475
+ }]
1476
+ };
1477
+ }
1478
+ }
1479
+ DbxFirebaseEmulatorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmulatorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1480
+ DbxFirebaseEmulatorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmulatorModule });
1481
+ DbxFirebaseEmulatorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmulatorModule });
1482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseEmulatorModule, decorators: [{
1483
+ type: NgModule
1484
+ }] });
1485
+
1486
+ /**
1487
+ * Token to access the FirestoreContext value.
1488
+ */
1489
+ const DBX_FIRESTORE_CONTEXT_TOKEN = new InjectionToken('DBX_FIRESTORE_CONTEXT_TOKEN');
1490
+
1491
+ /**
1492
+ * Used to initialize the FirestoreCollection for a DbxFirebase app.
1493
+ */
1494
+ class DbxFirebaseFirestoreCollectionModule {
1495
+ static forRoot(config) {
1496
+ return {
1497
+ ngModule: DbxFirebaseFirestoreCollectionModule,
1498
+ providers: [{
1499
+ provide: DBX_FIRESTORE_CONTEXT_TOKEN,
1500
+ useFactory: firebaseFirestoreContextFactory,
1501
+ deps: [Firestore]
1502
+ }, {
1503
+ provide: config.appCollectionClass,
1504
+ useFactory: config.collectionFactory,
1505
+ deps: [DBX_FIRESTORE_CONTEXT_TOKEN]
1506
+ }]
1507
+ };
1508
+ }
1509
+ }
1510
+ DbxFirebaseFirestoreCollectionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFirestoreCollectionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1511
+ DbxFirebaseFirestoreCollectionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFirestoreCollectionModule });
1512
+ DbxFirebaseFirestoreCollectionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFirestoreCollectionModule });
1513
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFirestoreCollectionModule, decorators: [{
1514
+ type: NgModule
1515
+ }] });
1516
+
1517
+ /**
1518
+ * Service that provides access to the app's FirestoreContext.
1519
+ */
1520
+ class DbxFirestoreContextService {
1521
+ constructor(firestoreContext) {
1522
+ this.firestoreContext = firestoreContext;
1523
+ }
1524
+ }
1525
+ DbxFirestoreContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirestoreContextService, deps: [{ token: DBX_FIRESTORE_CONTEXT_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
1526
+ DbxFirestoreContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirestoreContextService, providedIn: 'root' });
1527
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirestoreContextService, decorators: [{
1528
+ type: Injectable,
1529
+ args: [{
1530
+ providedIn: 'root'
1531
+ }]
1532
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1533
+ type: Inject,
1534
+ args: [DBX_FIRESTORE_CONTEXT_TOKEN]
1535
+ }] }]; } });
1536
+
1537
+ /**
1538
+ * Used to initialize the LazyFirebaseFunctions type for a DbxFirebase app.
1539
+ */
1540
+ class DbxFirebaseFunctionsModule {
1541
+ static forRoot(config) {
1542
+ const providers = [{
1543
+ provide: config.functionsGetterToken,
1544
+ useFactory: config.functionsGetterFactory,
1545
+ deps: [Functions]
1546
+ }];
1547
+ if (config.functionsConfigMap) {
1548
+ forEachKeyValue(config.functionsConfigMap, {
1549
+ forEach: ([key, entry]) => {
1550
+ const provide = entry[0];
1551
+ providers.push({
1552
+ provide,
1553
+ useFactory: (lazyFunctions) => {
1554
+ const getter = lazyFunctions[key];
1555
+ if (!getter) {
1556
+ throw new Error(`Could not create provider for firebase function getter "${provide}" as the getter was unavailable.`);
1557
+ }
1558
+ else {
1559
+ return getter();
1560
+ }
1561
+ },
1562
+ deps: [config.functionsGetterToken]
1563
+ });
1564
+ }
1565
+ });
1566
+ }
1567
+ return {
1568
+ ngModule: DbxFirebaseFunctionsModule,
1569
+ providers
1570
+ };
1571
+ }
1572
+ }
1573
+ DbxFirebaseFunctionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFunctionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1574
+ DbxFirebaseFunctionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFunctionsModule });
1575
+ DbxFirebaseFunctionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFunctionsModule });
1576
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseFunctionsModule, decorators: [{
1577
+ type: NgModule
1578
+ }] });
1579
+
1580
+ /**
1581
+ * DbxFirebaseModelLoader implementation within an instance.
1582
+ */
1583
+ class DbxFirebaseCollectionLoaderInstance {
1584
+ constructor(_initConfig) {
1585
+ this._initConfig = _initConfig;
1586
+ this._collection = new BehaviorSubject(this._initConfig?.collection);
1587
+ this._maxPages = new BehaviorSubject(this._initConfig?.maxPages);
1588
+ this._itemsPerPage = new BehaviorSubject(this._initConfig?.itemsPerPage);
1589
+ this._constraints = new BehaviorSubject(this._initConfig?.constraints);
1590
+ this._restart = new Subject();
1591
+ this._maxPagesSub = new SubscriptionObject();
1592
+ this.collection$ = this._collection.pipe(distinctUntilChanged());
1593
+ this.constraints$ = this._constraints.pipe(distinctUntilChanged());
1594
+ this.iteratorFilter$ = combineLatest([
1595
+ this._itemsPerPage.pipe(distinctUntilChanged()),
1596
+ this.constraints$
1597
+ ]).pipe(map(([limit, constraints]) => ({ limit, constraints, maxPageLoadLimit: this.maxPages })), shareReplay(1));
1598
+ this.firestoreIteration$ = this.collection$.pipe(switchMap((collection) => {
1599
+ if (collection) {
1600
+ return combineLatest([this.iteratorFilter$, this._restart.pipe(startWith(undefined))]).pipe(throttleTime(100, undefined, { trailing: true }), // prevent rapid changes and executing filters too quickly.
1601
+ map(([iteratorFilter]) => collection.firestoreIteration(iteratorFilter)), cleanupDestroyable(), // cleanup the iteration
1602
+ shareReplay(1));
1603
+ }
1604
+ else {
1605
+ return NEVER; // don't emit anything until collection is provided.
1606
+ }
1607
+ }), cleanupDestroyable(), // cleanup the iteration
1608
+ shareReplay(1));
1609
+ this.queryChangeWatcher$ = this.firestoreIteration$.pipe(map(instance => iterationQueryDocChangeWatcher({ instance })), shareReplay(1));
1610
+ this.accumulator$ = this.firestoreIteration$.pipe(map(x => firebaseQueryItemAccumulator(x)), cleanupDestroyable(), shareReplay(1));
1611
+ this.pageLoadingState$ = this.accumulator$.pipe(switchMap(x => accumulatorFlattenPageListLoadingState(x)), shareReplay(1));
1612
+ }
1613
+ init() {
1614
+ // When max pages changes, update the iteration's max page limit.
1615
+ this._maxPagesSub.subscription = this._maxPages.pipe(distinctUntilChanged(), filterMaybe(), // do not pass null/undefined values
1616
+ switchMap((maxPageLoadLimit) => this.firestoreIteration$.pipe(tap((iteration) => {
1617
+ iteration.maxPageLoadLimit = maxPageLoadLimit;
1618
+ })))).subscribe();
1619
+ }
1620
+ destroy() {
1621
+ this._maxPages.complete();
1622
+ this._collection.complete();
1623
+ this._constraints.complete();
1624
+ this._itemsPerPage.complete();
1625
+ this._restart.complete();
1626
+ this._maxPagesSub.destroy();
1627
+ }
1628
+ // MARK: Inputs
1629
+ get maxPages() {
1630
+ return this._maxPages.value;
1631
+ }
1632
+ set maxPages(maxPages) {
1633
+ if (this.maxPages != maxPages) {
1634
+ this._maxPages.next(maxPages);
1635
+ }
1636
+ }
1637
+ get itemsPerPage() {
1638
+ return this._itemsPerPage.value;
1639
+ }
1640
+ set itemsPerPage(itemsPerPage) {
1641
+ if (this.itemsPerPage != itemsPerPage) {
1642
+ this._itemsPerPage.next(itemsPerPage);
1643
+ }
1644
+ }
1645
+ get constraints() {
1646
+ return this._constraints.value;
1647
+ }
1648
+ set constraints(constraints) {
1649
+ this._constraints.next(constraints);
1650
+ }
1651
+ get collection() {
1652
+ return this._collection.value;
1653
+ }
1654
+ set collection(collection) {
1655
+ this._collection.next(collection);
1656
+ }
1657
+ // MARK: DbxFirebaseModelList
1658
+ next() {
1659
+ useFirst(this.firestoreIteration$, (x) => x.next());
1660
+ }
1661
+ restart() {
1662
+ this._restart.next();
1663
+ }
1664
+ setConstraints(constraints) {
1665
+ this.constraints = constraints;
1666
+ }
1667
+ setCollection(firestoreCollection) {
1668
+ this.collection = firestoreCollection;
1669
+ }
1670
+ }
1671
+ function dbxFirebaseCollectionLoaderInstance(config) {
1672
+ return new DbxFirebaseCollectionLoaderInstance(config);
1673
+ }
1674
+ function dbxFirebaseCollectionLoaderInstanceWithCollection(collection) {
1675
+ return new DbxFirebaseCollectionLoaderInstance({ collection });
1676
+ }
1677
+
1678
+ /**
1679
+ * Abstract directive that contains a DbxFirebaseCollectionStore and provides an interface for communicating with other directives.
1680
+ */
1681
+ class DbxFirebaseCollectionStoreDirective {
1682
+ constructor(store) {
1683
+ this.store = store;
1684
+ this.pageLoadingState$ = this.store.pageLoadingState$;
1685
+ }
1686
+ // MARK: Inputs
1687
+ set maxPages(maxPages) {
1688
+ this.store.setMaxPages(maxPages);
1689
+ }
1690
+ set itemsPerPage(itemsPerPage) {
1691
+ this.store.setItemsPerPage(itemsPerPage);
1692
+ }
1693
+ set constraints(constraints) {
1694
+ this.store.setConstraints(constraints);
1695
+ }
1696
+ next() {
1697
+ this.store.next();
1698
+ }
1699
+ restart() {
1700
+ this.store.restart();
1701
+ }
1702
+ setConstraints(constraints) {
1703
+ this.store.setConstraints(constraints);
1704
+ }
1705
+ }
1706
+ DbxFirebaseCollectionStoreDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionStoreDirective, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1707
+ DbxFirebaseCollectionStoreDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseCollectionStoreDirective, inputs: { maxPages: "maxPages", itemsPerPage: "itemsPerPage", constraints: "constraints" }, ngImport: i0 });
1708
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionStoreDirective, decorators: [{
1709
+ type: Directive
1710
+ }], ctorParameters: function () { return [{ type: undefined }]; }, propDecorators: { maxPages: [{
1711
+ type: Input
1712
+ }], itemsPerPage: [{
1713
+ type: Input
1714
+ }], constraints: [{
1715
+ type: Input
1716
+ }] } });
1717
+ function provideDbxFirebaseCollectionStoreDirective(sourceType, storeType) {
1718
+ const providers = [{
1719
+ provide: DbxFirebaseCollectionStoreDirective,
1720
+ useExisting: forwardRef(() => sourceType)
1721
+ }];
1722
+ if (storeType) {
1723
+ providers.push(storeType);
1724
+ }
1725
+ return providers;
1726
+ }
1727
+
1728
+ /**
1729
+ * Used to watch query doc changes and respond to them accordingly.
1730
+ */
1731
+ class DbxFirebaseCollectionChangeDirective extends AbstractSubscriptionDirective {
1732
+ constructor(dbxFirebaseCollectionStoreDirective) {
1733
+ super();
1734
+ this.dbxFirebaseCollectionStoreDirective = dbxFirebaseCollectionStoreDirective;
1735
+ this._mode = new BehaviorSubject('manual');
1736
+ this.mode$ = this._mode.pipe(distinctUntilChanged());
1737
+ this.event$ = this.dbxFirebaseCollectionStoreDirective.store.queryChangeWatcher$.pipe(switchMap((x) => x.event$.pipe(filter(x => x.type !== 'none'), // do not share 'none' events.
1738
+ take(1), // only need one event to mark as change is available.
1739
+ startWith({
1740
+ time: new Date(),
1741
+ type: 'none'
1742
+ }))), shareReplay(1));
1743
+ this.hasChangeAvailable$ = this.event$.pipe(map(x => x.type !== 'none'), shareReplay(1));
1744
+ }
1745
+ ngOnInit() {
1746
+ this.sub = combineLatest([this.mode$, this.hasChangeAvailable$]).pipe(filter(([mode, hasChange]) => mode === 'auto' && hasChange)).subscribe(() => {
1747
+ this.restart();
1748
+ });
1749
+ }
1750
+ ngOnDestroy() {
1751
+ super.ngOnDestroy();
1752
+ this._mode.complete();
1753
+ }
1754
+ get mode() {
1755
+ return this._mode.value;
1756
+ }
1757
+ set mode(mode) {
1758
+ this._mode.next(mode || 'manual');
1759
+ }
1760
+ restart() {
1761
+ this.dbxFirebaseCollectionStoreDirective.store.restart();
1762
+ }
1763
+ }
1764
+ DbxFirebaseCollectionChangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionChangeDirective, deps: [{ token: DbxFirebaseCollectionStoreDirective }], target: i0.ɵɵFactoryTarget.Directive });
1765
+ DbxFirebaseCollectionChangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseCollectionChangeDirective, selector: "[dbxFirebaseCollectionChange]", inputs: { mode: ["dbxFirebaseCollectionChange", "mode"] }, usesInheritance: true, ngImport: i0 });
1766
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionChangeDirective, decorators: [{
1767
+ type: Directive,
1768
+ args: [{
1769
+ selector: '[dbxFirebaseCollectionChange]'
1770
+ }]
1771
+ }], ctorParameters: function () { return [{ type: DbxFirebaseCollectionStoreDirective }]; }, propDecorators: { mode: [{
1772
+ type: Input,
1773
+ args: ['dbxFirebaseCollectionChange']
1774
+ }] } });
1775
+
1776
+ /**
1777
+ * Structural directive that displays the content when the target change is detected.
1778
+ *
1779
+ * Can specify which changes to appear on.
1780
+ */
1781
+ class DbxFirebaseCollectionHasChangeDirective extends AbstractIfDirective {
1782
+ constructor(templateRef, viewContainer, directive) {
1783
+ super(templateRef, viewContainer);
1784
+ this.directive = directive;
1785
+ this._mode = new BehaviorSubject('addedAndRemoved');
1786
+ this.show$ = combineLatest([this._mode, this.directive.event$]).pipe(map(([mode, event]) => {
1787
+ let show = false;
1788
+ if (event.type !== 'none') {
1789
+ switch (mode) {
1790
+ case 'all':
1791
+ show = true;
1792
+ break;
1793
+ case 'addedAndRemoved':
1794
+ show = event.type === 'addedAndRemoved' || event.type === 'added' || event.type === 'removed';
1795
+ break;
1796
+ default:
1797
+ show = event.type === mode;
1798
+ break;
1799
+ }
1800
+ }
1801
+ return show;
1802
+ }), shareReplay(1));
1803
+ }
1804
+ get mode() {
1805
+ return this._mode.value;
1806
+ }
1807
+ set mode(mode) {
1808
+ this._mode.next(mode || 'addedAndRemoved');
1809
+ }
1810
+ ngOnDestroy() {
1811
+ super.ngOnDestroy();
1812
+ this._mode.complete();
1813
+ }
1814
+ }
1815
+ DbxFirebaseCollectionHasChangeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionHasChangeDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: DbxFirebaseCollectionChangeDirective }], target: i0.ɵɵFactoryTarget.Directive });
1816
+ DbxFirebaseCollectionHasChangeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseCollectionHasChangeDirective, selector: "[dbxFirebaseCollectionHasChange]", inputs: { mode: ["dbxFirebaseCollectionHasChange", "mode"] }, usesInheritance: true, ngImport: i0 });
1817
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionHasChangeDirective, decorators: [{
1818
+ type: Directive,
1819
+ args: [{
1820
+ selector: '[dbxFirebaseCollectionHasChange]'
1821
+ }]
1822
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: DbxFirebaseCollectionChangeDirective }]; }, propDecorators: { mode: [{
1823
+ type: Input,
1824
+ args: ['dbxFirebaseCollectionHasChange']
1825
+ }] } });
1826
+
1827
+ /**
1828
+ * Directive that connects a host DbxListView to a DbxFirebaseCollectionStoreDirective to pass data for rendering items from a collection and query parameters.
1829
+ */
1830
+ class DbxFirebaseCollectionListDirective {
1831
+ constructor(dbxFirebaseCollectionStoreDirective, dbxListViewWrapper) {
1832
+ this.dbxFirebaseCollectionStoreDirective = dbxFirebaseCollectionStoreDirective;
1833
+ this.dbxListViewWrapper = dbxListViewWrapper;
1834
+ this.dbxListViewWrapper.state$ = this.dbxFirebaseCollectionStoreDirective.pageLoadingState$;
1835
+ }
1836
+ }
1837
+ DbxFirebaseCollectionListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionListDirective, deps: [{ token: DbxFirebaseCollectionStoreDirective }, { token: i3.DbxListViewWrapper, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1838
+ DbxFirebaseCollectionListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseCollectionListDirective, selector: "[dbxFirebaseCollectionList]", ngImport: i0 });
1839
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseCollectionListDirective, decorators: [{
1840
+ type: Directive,
1841
+ args: [{
1842
+ selector: '[dbxFirebaseCollectionList]'
1843
+ }]
1844
+ }], ctorParameters: function () { return [{ type: DbxFirebaseCollectionStoreDirective }, { type: i3.DbxListViewWrapper, decorators: [{
1845
+ type: Host
1846
+ }] }]; } });
1847
+
1848
+ /**
1849
+ * Abstract directive that contains a DbxFirebaseDocumentStore and provides an interface for communicating with other directives.
1850
+ */
1851
+ class DbxFirebaseDocumentStoreDirective {
1852
+ constructor(store) {
1853
+ this.store = store;
1854
+ this.exists$ = this.store.exists$;
1855
+ this.document$ = this.store.document$;
1856
+ this.documentLoadingState$ = this.store.documentLoadingState$;
1857
+ this.id$ = this.store.id$;
1858
+ this.ref$ = this.store.ref$;
1859
+ this.snapshot$ = this.store.snapshot$;
1860
+ this.snapshotLoadingState$ = this.store.snapshotLoadingState$;
1861
+ this.data$ = this.store.data$;
1862
+ this.loadingState$ = this.store.dataLoadingState$;
1863
+ }
1864
+ // MARK: Inputs
1865
+ set id(id) {
1866
+ this.store.setId(id);
1867
+ }
1868
+ set ref(ref) {
1869
+ this.store.setRef(ref);
1870
+ }
1871
+ }
1872
+ DbxFirebaseDocumentStoreDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDocumentStoreDirective, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1873
+ DbxFirebaseDocumentStoreDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseDocumentStoreDirective, inputs: { id: "id", ref: "ref" }, ngImport: i0 });
1874
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDocumentStoreDirective, decorators: [{
1875
+ type: Directive
1876
+ }], ctorParameters: function () { return [{ type: undefined }]; }, propDecorators: { id: [{
1877
+ type: Input
1878
+ }], ref: [{
1879
+ type: Input
1880
+ }] } });
1881
+ function provideDbxFirebaseDocumentStoreDirective(sourceType, storeType) {
1882
+ const providers = [{
1883
+ provide: DbxFirebaseDocumentStoreDirective,
1884
+ useExisting: forwardRef(() => sourceType)
1885
+ }];
1886
+ if (storeType) {
1887
+ providers.push(storeType);
1888
+ }
1889
+ return providers;
1890
+ }
1891
+
1892
+ /**
1893
+ * Utility directive for a host DbxFirebaseDocumentStoreDirective that sets the document's ID to match the ID of the current user.
1894
+ *
1895
+ * This is useful for cases where each document is keyed by the user (I.E. implements UserRelatedById).
1896
+ */
1897
+ class DbxFirebaseDocumentAuthIdDirective extends AbstractSubscriptionDirective {
1898
+ constructor(dbxFirebaseAuthService, dbxFirebaseDocumentStoreDirective) {
1899
+ super();
1900
+ this.dbxFirebaseAuthService = dbxFirebaseAuthService;
1901
+ this.dbxFirebaseDocumentStoreDirective = dbxFirebaseDocumentStoreDirective;
1902
+ }
1903
+ ngOnInit() {
1904
+ this.sub = this.dbxFirebaseDocumentStoreDirective.store.setId(this.dbxFirebaseAuthService.userIdentifier$);
1905
+ }
1906
+ }
1907
+ DbxFirebaseDocumentAuthIdDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDocumentAuthIdDirective, deps: [{ token: DbxFirebaseAuthService }, { token: DbxFirebaseDocumentStoreDirective, host: true }], target: i0.ɵɵFactoryTarget.Directive });
1908
+ DbxFirebaseDocumentAuthIdDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseDocumentAuthIdDirective, selector: "[dbxFirebaseDocumentAuthId]", usesInheritance: true, ngImport: i0 });
1909
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDocumentAuthIdDirective, decorators: [{
1910
+ type: Directive,
1911
+ args: [{
1912
+ selector: '[dbxFirebaseDocumentAuthId]'
1913
+ }]
1914
+ }], ctorParameters: function () { return [{ type: DbxFirebaseAuthService }, { type: DbxFirebaseDocumentStoreDirective, decorators: [{
1915
+ type: Host
1916
+ }] }]; } });
1917
+
1918
+ const DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY = 'id';
1919
+ /**
1920
+ * Used for synchronizing the document store id to the param of the route.
1921
+ */
1922
+ class DbxFirebaseDocumentStoreRouteIdDirective extends AbstractSubscriptionDirective {
1923
+ constructor(dbxFirebaseDocumentStoreDirective, dbxRouterService) {
1924
+ super();
1925
+ this.dbxFirebaseDocumentStoreDirective = dbxFirebaseDocumentStoreDirective;
1926
+ this.dbxRouterService = dbxRouterService;
1927
+ this._idParamKey = new BehaviorSubject(DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY);
1928
+ this.idParamKey$ = this._idParamKey.asObservable();
1929
+ this.idFromParams$ = combineLatest([this.idParamKey$, this.dbxRouterService.params$]).pipe(map(([key, params]) => {
1930
+ return params[key] ?? undefined;
1931
+ }), distinctUntilChanged(), shareReplay$1(1));
1932
+ }
1933
+ ngOnInit() {
1934
+ this.sub = this.dbxFirebaseDocumentStoreDirective.store.setId(this.idFromParams$);
1935
+ }
1936
+ ngOnDestroy() {
1937
+ super.ngOnDestroy();
1938
+ this._idParamKey.complete();
1939
+ }
1940
+ // MARK: Input
1941
+ get idParam() {
1942
+ return this._idParamKey.value;
1943
+ }
1944
+ set idParam(idParam) {
1945
+ this._idParamKey.next(idParam || DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY);
1946
+ }
1947
+ }
1948
+ DbxFirebaseDocumentStoreRouteIdDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDocumentStoreRouteIdDirective, deps: [{ token: DbxFirebaseDocumentStoreDirective, host: true }, { token: i3$1.DbxRouterService }], target: i0.ɵɵFactoryTarget.Directive });
1949
+ DbxFirebaseDocumentStoreRouteIdDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.2", type: DbxFirebaseDocumentStoreRouteIdDirective, selector: "[dbxFirebaseDocumentStoreRouteId]", inputs: { idParam: ["dbxFirebaseDocumentStoreRouteId", "idParam"] }, usesInheritance: true, ngImport: i0 });
1950
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseDocumentStoreRouteIdDirective, decorators: [{
1951
+ type: Directive,
1952
+ args: [{
1953
+ selector: '[dbxFirebaseDocumentStoreRouteId]'
1954
+ }]
1955
+ }], ctorParameters: function () { return [{ type: DbxFirebaseDocumentStoreDirective, decorators: [{
1956
+ type: Host
1957
+ }] }, { type: i3$1.DbxRouterService }]; }, propDecorators: { idParam: [{
1958
+ type: Input,
1959
+ args: ['dbxFirebaseDocumentStoreRouteId']
1960
+ }] } });
1961
+
1962
+ class DbxFirebaseModelStoreModule {
1963
+ }
1964
+ DbxFirebaseModelStoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1965
+ DbxFirebaseModelStoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelStoreModule, declarations: [DbxFirebaseCollectionListDirective,
1966
+ DbxFirebaseCollectionChangeDirective,
1967
+ DbxFirebaseCollectionHasChangeDirective,
1968
+ DbxFirebaseDocumentStoreRouteIdDirective,
1969
+ DbxFirebaseDocumentAuthIdDirective], exports: [DbxFirebaseCollectionListDirective,
1970
+ DbxFirebaseCollectionChangeDirective,
1971
+ DbxFirebaseCollectionHasChangeDirective,
1972
+ DbxFirebaseDocumentStoreRouteIdDirective,
1973
+ DbxFirebaseDocumentAuthIdDirective] });
1974
+ DbxFirebaseModelStoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelStoreModule, imports: [[]] });
1975
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelStoreModule, decorators: [{
1976
+ type: NgModule,
1977
+ args: [{
1978
+ imports: [],
1979
+ declarations: [
1980
+ DbxFirebaseCollectionListDirective,
1981
+ DbxFirebaseCollectionChangeDirective,
1982
+ DbxFirebaseCollectionHasChangeDirective,
1983
+ DbxFirebaseDocumentStoreRouteIdDirective,
1984
+ DbxFirebaseDocumentAuthIdDirective
1985
+ ],
1986
+ exports: [
1987
+ DbxFirebaseCollectionListDirective,
1988
+ DbxFirebaseCollectionChangeDirective,
1989
+ DbxFirebaseCollectionHasChangeDirective,
1990
+ DbxFirebaseDocumentStoreRouteIdDirective,
1991
+ DbxFirebaseDocumentAuthIdDirective
1992
+ ]
1993
+ }]
1994
+ }] });
1995
+
1996
+ /**
1997
+ * Used for storing the state of a Person and related email threads.
1998
+ */
1999
+ class AbstractDbxFirebaseCollectionStore extends LockSetComponentStore {
2000
+ constructor() {
2001
+ super(...arguments);
2002
+ // MARK: Effects
2003
+ this.setMaxPages = this.effect((input) => {
2004
+ return input.pipe(switchMap((maxPages) => this.loader$.pipe(tap((x) => x.maxPages = maxPages))));
2005
+ });
2006
+ this.setItemsPerPage = this.effect((input) => {
2007
+ return input.pipe(switchMap((itemsPerPage) => this.loader$.pipe(tap((x) => x.itemsPerPage = itemsPerPage))));
2008
+ });
2009
+ this.setConstraints = this.effect((input) => {
2010
+ return input.pipe(switchMap((constraints) => this.loader$.pipe(tap((x) => x.setConstraints(constraints)))));
2011
+ });
2012
+ this.next = this.effect((input) => {
2013
+ return input.pipe(exhaustMap(() => this.loader$.pipe(first(), tap((x) => x.next()))));
2014
+ });
2015
+ this.restart = this.effect((input) => {
2016
+ return input.pipe(exhaustMap(() => this.loader$.pipe(first(), tap((x) => x.restart()))));
2017
+ });
2018
+ // MARK: Accessors
2019
+ this.currentFirestoreCollection$ = this.state$.pipe(map((x) => x.firestoreCollection), distinctUntilChanged(), shareReplay(1));
2020
+ this.firestoreCollection$ = this.currentFirestoreCollection$.pipe(filterMaybe());
2021
+ this.loader$ = this.currentFirestoreCollection$.pipe(switchMap((collection) => this.state$.pipe(first(), map(x => dbxFirebaseCollectionLoaderInstance({
2022
+ collection,
2023
+ maxPages: x.maxPages,
2024
+ itemsPerPage: x.itemsPerPage,
2025
+ constraints: x.constraints
2026
+ })))), cleanupDestroyable(), distinctUntilChanged(), shareReplay(1));
2027
+ this.firestoreIteration$ = this.loader$.pipe(switchMap(x => x.firestoreIteration$));
2028
+ this.queryChangeWatcher$ = this.loader$.pipe(switchMap(x => x.queryChangeWatcher$));
2029
+ this.accumulator$ = this.loader$.pipe(switchMap(x => x.accumulator$));
2030
+ this.pageLoadingState$ = this.loader$.pipe(switchMap(x => x.pageLoadingState$));
2031
+ this.setFirestoreCollection = this.updater((state, firestoreCollection) => ({ ...state, firestoreCollection }));
2032
+ }
2033
+ }
2034
+ AbstractDbxFirebaseCollectionStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseCollectionStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
2035
+ AbstractDbxFirebaseCollectionStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseCollectionStore });
2036
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseCollectionStore, decorators: [{
2037
+ type: Injectable
2038
+ }] });
2039
+
2040
+ const DBX_FIREBASE_MODEL_DOES_NOT_EXIST_ERROR = 'DOES_NOT_EXIST';
2041
+ function modelDoesNotExistError() {
2042
+ return readableError(DBX_FIREBASE_MODEL_DOES_NOT_EXIST_ERROR, 'The document does not exist.');
2043
+ }
2044
+
2045
+ /**
2046
+ * Used for storing the state of a Person and related email threads.
2047
+ */
2048
+ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
2049
+ constructor() {
2050
+ super(...arguments);
2051
+ // MARK: Effects
2052
+ // MARK: Accessors
2053
+ this.currentFirestoreCollection$ = this.state$.pipe(map((x) => x.firestoreCollection), distinctUntilChanged(), shareReplay(1));
2054
+ this.firestoreCollection$ = this.currentFirestoreCollection$.pipe(filterMaybe());
2055
+ this.currentInputId$ = this.state$.pipe(map(x => x.id), distinctUntilChanged(), shareReplay(1));
2056
+ this.inputId$ = this.currentInputId$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
2057
+ this.currentInputRef$ = this.state$.pipe(map(x => x.ref), distinctUntilChanged(), shareReplay(1));
2058
+ this.inputRef$ = this.currentInputRef$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
2059
+ this.currentDocument$ = combineLatest([this.currentFirestoreCollection$, this.currentInputId$, this.currentInputRef$]).pipe(map(([collection, id, ref]) => {
2060
+ let document;
2061
+ if (collection) {
2062
+ if (ref) {
2063
+ document = collection.documentAccessor().loadDocument(ref);
2064
+ }
2065
+ else if (id) {
2066
+ document = collection.documentAccessor().loadDocumentForPath(id);
2067
+ }
2068
+ }
2069
+ return document;
2070
+ }), distinctUntilChanged(), shareReplay(1));
2071
+ this.document$ = this.currentDocument$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
2072
+ this.documentLoadingState$ = this.currentDocument$.pipe(map(x => (x) ? successResult(x) : beginLoading()), shareReplay(1));
2073
+ this.id$ = this.document$.pipe(map(x => x.id), shareReplay());
2074
+ this.ref$ = this.document$.pipe(map(x => x.documentRef), shareReplay());
2075
+ this.snapshot$ = this.document$.pipe(switchMap(x => x.accessor.stream()), shareReplay(1));
2076
+ this.snapshotLoadingState$ = this.currentDocument$.pipe(switchMap(_ => loadingStateFromObs(this.snapshot$)), shareReplay(1));
2077
+ this.currentData$ = this.document$.pipe(switchMap(x => x.accessor.stream().pipe(map(y => documentDataWithId(y)))), shareReplay(1));
2078
+ this.data$ = this.currentDocument$.pipe(switchMap(() => this.currentData$.pipe(filterMaybe())), shareReplay(1));
2079
+ this.dataLoadingState$ = this.snapshotLoadingState$.pipe(map((x) => {
2080
+ let result;
2081
+ if (x.value) {
2082
+ const data = documentDataWithId(x.value);
2083
+ if (data) {
2084
+ result = successResult(data);
2085
+ }
2086
+ else {
2087
+ result = errorResult(modelDoesNotExistError());
2088
+ }
2089
+ }
2090
+ else {
2091
+ result = {
2092
+ ...x,
2093
+ value: undefined
2094
+ };
2095
+ }
2096
+ return result;
2097
+ }), shareReplay(1));
2098
+ this.exists$ = this.currentData$.pipe(map(x => isMaybeSo(x)), shareReplay(1));
2099
+ this.doesNotExist$ = this.exists$.pipe(map(x => !x), shareReplay(1));
2100
+ // MARK: State Changes
2101
+ /**
2102
+ * Sets the id of the document to load.
2103
+ */
2104
+ this.setId = this.updater((state, id) => (id) ? ({ ...state, id, ref: undefined }) : ({ ...state, id }));
2105
+ /**
2106
+ * Sets the ref of the document to load.
2107
+ */
2108
+ this.setRef = this.updater((state, ref) => (ref) ? ({ ...state, id: undefined, ref }) : ({ ...state, ref }));
2109
+ this.setFirestoreCollection = this.updater((state, firestoreCollection) => ({ ...state, firestoreCollection }));
2110
+ }
2111
+ }
2112
+ AbstractDbxFirebaseDocumentStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
2113
+ AbstractDbxFirebaseDocumentStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentStore });
2114
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentStore, decorators: [{
2115
+ type: Injectable
2116
+ }] });
2117
+
2118
+ function setParentStoreEffect(store) {
2119
+ return store.effect((input) => {
2120
+ return input.pipe(map((parentStore) => {
2121
+ let result;
2122
+ if (parentStore) {
2123
+ result = store.setParent(parentStore.currentDocument$);
2124
+ }
2125
+ else {
2126
+ result = undefined;
2127
+ }
2128
+ // set as the parent lock set too
2129
+ store.setParentLockSet(parentStore);
2130
+ return result;
2131
+ }), cleanup((sub) => {
2132
+ if (sub) {
2133
+ sub.unsubscribe();
2134
+ }
2135
+ }));
2136
+ });
2137
+ }
2138
+ function setParentEffect(store) {
2139
+ return store.effect((input) => {
2140
+ return input.pipe(switchMap((parent) => {
2141
+ store._setParentDocument(parent);
2142
+ if (parent) {
2143
+ return store.collectionFactory$.pipe(tap((collectionFactory) => {
2144
+ const collection = collectionFactory(parent);
2145
+ store.setFirestoreCollection(collection);
2146
+ }));
2147
+ }
2148
+ else {
2149
+ // clear the current collection
2150
+ store.setFirestoreCollection(undefined);
2151
+ // do nothing until a parent is returned.
2152
+ return NEVER;
2153
+ }
2154
+ }));
2155
+ });
2156
+ }
2157
+
2158
+ /**
2159
+ * Abstract DbxFirebaseCollectionStore that has a parent document from which is derives it's FiresbaseCollection from.
2160
+ */
2161
+ class AbstractDbxFirebaseCollectionWithParentStore extends AbstractDbxFirebaseCollectionStore {
2162
+ constructor() {
2163
+ super(...arguments);
2164
+ // MARK: Effects
2165
+ this.setParent = setParentEffect(this);
2166
+ this.setParentStore = setParentStoreEffect(this);
2167
+ // MARK: Accessors
2168
+ this.currentParent$ = this.state$.pipe(map(x => x.parent), distinctUntilChanged(), shareReplay(1));
2169
+ this.parent$ = this.currentParent$.pipe(filterMaybe());
2170
+ this.currentCollectionFactory$ = this.state$.pipe(map(x => x.collectionFactory), distinctUntilChanged(), shareReplay(1));
2171
+ this.collectionFactory$ = this.currentCollectionFactory$.pipe(filterMaybe());
2172
+ // MARK: State Changes
2173
+ /**
2174
+ * Sets the collection factory function to use.
2175
+ */
2176
+ this.setCollectionFactory = this.updater((state, collectionFactory) => ({ ...state, collectionFactory }));
2177
+ /**
2178
+ * Sets the parent on the current state.
2179
+ */
2180
+ this._setParentDocument = this.updater((state, parent) => ({ ...state, parent }));
2181
+ }
2182
+ }
2183
+ AbstractDbxFirebaseCollectionWithParentStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseCollectionWithParentStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
2184
+ AbstractDbxFirebaseCollectionWithParentStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseCollectionWithParentStore });
2185
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseCollectionWithParentStore, decorators: [{
2186
+ type: Injectable
2187
+ }] });
2188
+
2189
+ /**
2190
+ * Abstract DbxFirebaseDocumentStore that has a parent document from which is derives it's FiresbaseCollection from.
2191
+ */
2192
+ class AbstractDbxFirebaseDocumentWithParentStore extends AbstractDbxFirebaseDocumentStore {
2193
+ constructor() {
2194
+ super(...arguments);
2195
+ // MARK: Effects
2196
+ this.setParent = setParentEffect(this);
2197
+ this.setParentStore = setParentStoreEffect(this);
2198
+ // MARK: Accessors
2199
+ this.currentParent$ = this.state$.pipe(map(x => x.parent), distinctUntilChanged(), shareReplay(1));
2200
+ this.parent$ = this.currentParent$.pipe(filterMaybe());
2201
+ this.currentCollectionFactory$ = this.state$.pipe(map(x => x.collectionFactory), distinctUntilChanged(), shareReplay(1));
2202
+ this.collectionFactory$ = this.currentCollectionFactory$.pipe(filterMaybe());
2203
+ // MARK: State Changes
2204
+ /**
2205
+ * Sets the collection factory function to use.
2206
+ */
2207
+ this.setCollectionFactory = this.updater((state, collectionFactory) => ({ ...state, collectionFactory }));
2208
+ /**
2209
+ * Sets the parent on the current state.
2210
+ */
2211
+ this._setParentDocument = this.updater((state, parent) => ({ ...state, parent }));
2212
+ }
2213
+ }
2214
+ AbstractDbxFirebaseDocumentWithParentStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentWithParentStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
2215
+ AbstractDbxFirebaseDocumentWithParentStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentWithParentStore });
2216
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentWithParentStore, decorators: [{
2217
+ type: Injectable
2218
+ }] });
2219
+
2220
+ class DbxFirebaseModelModule {
2221
+ }
2222
+ DbxFirebaseModelModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2223
+ DbxFirebaseModelModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelModule, exports: [DbxFirebaseModelStoreModule] });
2224
+ DbxFirebaseModelModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelModule, imports: [DbxFirebaseModelStoreModule] });
2225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModelModule, decorators: [{
2226
+ type: NgModule,
2227
+ args: [{
2228
+ exports: [
2229
+ DbxFirebaseModelStoreModule
2230
+ ]
2231
+ }]
2232
+ }] });
2233
+
2234
+ class DbxFirebaseModule {
2235
+ }
2236
+ DbxFirebaseModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2237
+ DbxFirebaseModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModule, exports: [DbxFirebaseModelModule] });
2238
+ DbxFirebaseModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModule, imports: [DbxFirebaseModelModule] });
2239
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: DbxFirebaseModule, decorators: [{
2240
+ type: NgModule,
2241
+ args: [{
2242
+ exports: [
2243
+ DbxFirebaseModelModule
2244
+ ]
2245
+ }]
2246
+ }] });
2
2247
 
3
2248
  /**
4
2249
  * Generated bundle index. Do not edit.
5
2250
  */
6
2251
 
7
- export { test };
2252
+ export { AbstractConfiguredDbxFirebaseLoginButtonDirective, AbstractDbxFirebaseCollectionStore, AbstractDbxFirebaseCollectionWithParentStore, AbstractDbxFirebaseDocumentStore, AbstractDbxFirebaseDocumentWithParentStore, DBX_FIREBASE_MODEL_DOES_NOT_EXIST_ERROR, DBX_FIREBASE_OPTIONS_TOKEN, DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY, DBX_FIRESTORE_CONTEXT_TOKEN, DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE, DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN, DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY, DbxFirebaseAuthLoginService, DbxFirebaseAuthModule, DbxFirebaseAuthService, DbxFirebaseAuthServiceDelegate, DbxFirebaseCollectionChangeDirective, DbxFirebaseCollectionHasChangeDirective, DbxFirebaseCollectionListDirective, DbxFirebaseCollectionLoaderInstance, DbxFirebaseCollectionStoreDirective, DbxFirebaseDefaultAuthProviderModule, DbxFirebaseDefaultFirebaseProvidersModule, DbxFirebaseDefaultFirestoreProviderModule, DbxFirebaseDefaultFunctionsProviderModule, DbxFirebaseDefaultStorageProviderModule, DbxFirebaseDocumentAuthIdDirective, DbxFirebaseDocumentStoreDirective, DbxFirebaseDocumentStoreRouteIdDirective, DbxFirebaseEmailFormComponent, DbxFirebaseEmailRecoveryFormComponent, DbxFirebaseEmulatorModule, DbxFirebaseFirestoreCollectionModule, DbxFirebaseFunctionsModule, DbxFirebaseLoginAnonymousComponent, DbxFirebaseLoginAppleComponent, DbxFirebaseLoginButtonComponent, DbxFirebaseLoginButtonContainerComponent, DbxFirebaseLoginComponent, DbxFirebaseLoginContext, DbxFirebaseLoginContextBackButtonComponent, DbxFirebaseLoginContextDirective, DbxFirebaseLoginEmailComponent, DbxFirebaseLoginEmailContentComponent, DbxFirebaseLoginFacebookComponent, DbxFirebaseLoginGitHubComponent, DbxFirebaseLoginGoogleComponent, DbxFirebaseLoginListComponent, DbxFirebaseLoginMicrosoftComponent, DbxFirebaseLoginModule, DbxFirebaseLoginModuleRootConfig, DbxFirebaseLoginTermsComponent, DbxFirebaseLoginTermsSimpleComponent, DbxFirebaseLoginTwitterComponent, DbxFirebaseModelModule, DbxFirebaseModelStoreModule, DbxFirebaseModule, DbxFirebaseParsedEmulatorsConfig, DbxFirebaseRegisterComponent, DbxFirebaseRegisterEmailComponent, DbxFirestoreContextService, FIREBASE_AUTH_NETWORK_REQUEST_ERROR, FIREBASE_AUTH_USER_NOT_FOUND_ERROR, OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY, authUserInfoFromAuthUser, authUserStateFromFirebaseAuthService, dbxFirebaseCollectionLoaderInstance, dbxFirebaseCollectionLoaderInstanceWithCollection, defaultFirebaseAuthLoginProvidersFactory, firebaseAuthErrorToReadableError, modelDoesNotExistError, provideDbxFirebaseCollectionStoreDirective, provideDbxFirebaseDocumentStoreDirective, readValueFromIdToken, setParentEffect, setParentStoreEffect };
8
2253
  //# sourceMappingURL=dereekb-dbx-firebase.mjs.map