UNPKG

92.6 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators')) :
3 typeof define === 'function' && define.amd ? define('@ngrx/store', ['exports', '@angular/core', 'rxjs', 'rxjs/operators'], factory) :
4 (global = global || self, factory((global.ngrx = global.ngrx || {}, global.ngrx.store = {}), global.ng.core, global.rxjs, global.rxjs.operators));
5}(this, (function (exports, ngCore, rxjs, operators) { 'use strict';
6
7 /*! *****************************************************************************
8 Copyright (c) Microsoft Corporation.
9
10 Permission to use, copy, modify, and/or distribute this software for any
11 purpose with or without fee is hereby granted.
12
13 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 PERFORMANCE OF THIS SOFTWARE.
20 ***************************************************************************** */
21 /* global Reflect, Promise */
22 var extendStatics = function (d, b) {
23 extendStatics = Object.setPrototypeOf ||
24 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25 function (d, b) { for (var p in b)
26 if (b.hasOwnProperty(p))
27 d[p] = b[p]; };
28 return extendStatics(d, b);
29 };
30 function __extends(d, b) {
31 extendStatics(d, b);
32 function __() { this.constructor = d; }
33 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34 }
35 var __assign = function () {
36 __assign = Object.assign || function __assign(t) {
37 for (var s, i = 1, n = arguments.length; i < n; i++) {
38 s = arguments[i];
39 for (var p in s)
40 if (Object.prototype.hasOwnProperty.call(s, p))
41 t[p] = s[p];
42 }
43 return t;
44 };
45 return __assign.apply(this, arguments);
46 };
47 function __rest(s, e) {
48 var t = {};
49 for (var p in s)
50 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51 t[p] = s[p];
52 if (s != null && typeof Object.getOwnPropertySymbols === "function")
53 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55 t[p[i]] = s[p[i]];
56 }
57 return t;
58 }
59 function __decorate(decorators, target, key, desc) {
60 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
62 r = Reflect.decorate(decorators, target, key, desc);
63 else
64 for (var i = decorators.length - 1; i >= 0; i--)
65 if (d = decorators[i])
66 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
67 return c > 3 && r && Object.defineProperty(target, key, r), r;
68 }
69 function __param(paramIndex, decorator) {
70 return function (target, key) { decorator(target, key, paramIndex); };
71 }
72 function __metadata(metadataKey, metadataValue) {
73 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
74 return Reflect.metadata(metadataKey, metadataValue);
75 }
76 function __awaiter(thisArg, _arguments, P, generator) {
77 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
78 return new (P || (P = Promise))(function (resolve, reject) {
79 function fulfilled(value) { try {
80 step(generator.next(value));
81 }
82 catch (e) {
83 reject(e);
84 } }
85 function rejected(value) { try {
86 step(generator["throw"](value));
87 }
88 catch (e) {
89 reject(e);
90 } }
91 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
92 step((generator = generator.apply(thisArg, _arguments || [])).next());
93 });
94 }
95 function __generator(thisArg, body) {
96 var _ = { label: 0, sent: function () { if (t[0] & 1)
97 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
98 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
99 function verb(n) { return function (v) { return step([n, v]); }; }
100 function step(op) {
101 if (f)
102 throw new TypeError("Generator is already executing.");
103 while (_)
104 try {
105 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
106 return t;
107 if (y = 0, t)
108 op = [op[0] & 2, t.value];
109 switch (op[0]) {
110 case 0:
111 case 1:
112 t = op;
113 break;
114 case 4:
115 _.label++;
116 return { value: op[1], done: false };
117 case 5:
118 _.label++;
119 y = op[1];
120 op = [0];
121 continue;
122 case 7:
123 op = _.ops.pop();
124 _.trys.pop();
125 continue;
126 default:
127 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
128 _ = 0;
129 continue;
130 }
131 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
132 _.label = op[1];
133 break;
134 }
135 if (op[0] === 6 && _.label < t[1]) {
136 _.label = t[1];
137 t = op;
138 break;
139 }
140 if (t && _.label < t[2]) {
141 _.label = t[2];
142 _.ops.push(op);
143 break;
144 }
145 if (t[2])
146 _.ops.pop();
147 _.trys.pop();
148 continue;
149 }
150 op = body.call(thisArg, _);
151 }
152 catch (e) {
153 op = [6, e];
154 y = 0;
155 }
156 finally {
157 f = t = 0;
158 }
159 if (op[0] & 5)
160 throw op[1];
161 return { value: op[0] ? op[1] : void 0, done: true };
162 }
163 }
164 var __createBinding = Object.create ? (function (o, m, k, k2) {
165 if (k2 === undefined)
166 k2 = k;
167 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
168 }) : (function (o, m, k, k2) {
169 if (k2 === undefined)
170 k2 = k;
171 o[k2] = m[k];
172 });
173 function __exportStar(m, exports) {
174 for (var p in m)
175 if (p !== "default" && !exports.hasOwnProperty(p))
176 __createBinding(exports, m, p);
177 }
178 function __values(o) {
179 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
180 if (m)
181 return m.call(o);
182 if (o && typeof o.length === "number")
183 return {
184 next: function () {
185 if (o && i >= o.length)
186 o = void 0;
187 return { value: o && o[i++], done: !o };
188 }
189 };
190 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
191 }
192 function __read(o, n) {
193 var m = typeof Symbol === "function" && o[Symbol.iterator];
194 if (!m)
195 return o;
196 var i = m.call(o), r, ar = [], e;
197 try {
198 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
199 ar.push(r.value);
200 }
201 catch (error) {
202 e = { error: error };
203 }
204 finally {
205 try {
206 if (r && !r.done && (m = i["return"]))
207 m.call(i);
208 }
209 finally {
210 if (e)
211 throw e.error;
212 }
213 }
214 return ar;
215 }
216 function __spread() {
217 for (var ar = [], i = 0; i < arguments.length; i++)
218 ar = ar.concat(__read(arguments[i]));
219 return ar;
220 }
221 function __spreadArrays() {
222 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
223 s += arguments[i].length;
224 for (var r = Array(s), k = 0, i = 0; i < il; i++)
225 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
226 r[k] = a[j];
227 return r;
228 }
229 ;
230 function __await(v) {
231 return this instanceof __await ? (this.v = v, this) : new __await(v);
232 }
233 function __asyncGenerator(thisArg, _arguments, generator) {
234 if (!Symbol.asyncIterator)
235 throw new TypeError("Symbol.asyncIterator is not defined.");
236 var g = generator.apply(thisArg, _arguments || []), i, q = [];
237 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
238 function verb(n) { if (g[n])
239 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
240 function resume(n, v) { try {
241 step(g[n](v));
242 }
243 catch (e) {
244 settle(q[0][3], e);
245 } }
246 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
247 function fulfill(value) { resume("next", value); }
248 function reject(value) { resume("throw", value); }
249 function settle(f, v) { if (f(v), q.shift(), q.length)
250 resume(q[0][0], q[0][1]); }
251 }
252 function __asyncDelegator(o) {
253 var i, p;
254 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
255 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
256 }
257 function __asyncValues(o) {
258 if (!Symbol.asyncIterator)
259 throw new TypeError("Symbol.asyncIterator is not defined.");
260 var m = o[Symbol.asyncIterator], i;
261 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
262 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
263 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
264 }
265 function __makeTemplateObject(cooked, raw) {
266 if (Object.defineProperty) {
267 Object.defineProperty(cooked, "raw", { value: raw });
268 }
269 else {
270 cooked.raw = raw;
271 }
272 return cooked;
273 }
274 ;
275 var __setModuleDefault = Object.create ? (function (o, v) {
276 Object.defineProperty(o, "default", { enumerable: true, value: v });
277 }) : function (o, v) {
278 o["default"] = v;
279 };
280 function __importStar(mod) {
281 if (mod && mod.__esModule)
282 return mod;
283 var result = {};
284 if (mod != null)
285 for (var k in mod)
286 if (Object.hasOwnProperty.call(mod, k))
287 __createBinding(result, mod, k);
288 __setModuleDefault(result, mod);
289 return result;
290 }
291 function __importDefault(mod) {
292 return (mod && mod.__esModule) ? mod : { default: mod };
293 }
294 function __classPrivateFieldGet(receiver, privateMap) {
295 if (!privateMap.has(receiver)) {
296 throw new TypeError("attempted to get private field on non-instance");
297 }
298 return privateMap.get(receiver);
299 }
300 function __classPrivateFieldSet(receiver, privateMap, value) {
301 if (!privateMap.has(receiver)) {
302 throw new TypeError("attempted to set private field on non-instance");
303 }
304 privateMap.set(receiver, value);
305 return value;
306 }
307
308 /**
309 * @fileoverview added by tsickle
310 * Generated from: src/globals.ts
311 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
312 */
313 /** @type {?} */
314 var REGISTERED_ACTION_TYPES = {};
315 /**
316 * @return {?}
317 */
318 function resetRegisteredActionTypes() {
319 var e_1, _a;
320 try {
321 for (var _b = __values(Object.keys(REGISTERED_ACTION_TYPES)), _c = _b.next(); !_c.done; _c = _b.next()) {
322 var key = _c.value;
323 delete REGISTERED_ACTION_TYPES[key];
324 }
325 }
326 catch (e_1_1) { e_1 = { error: e_1_1 }; }
327 finally {
328 try {
329 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
330 }
331 finally { if (e_1) throw e_1.error; }
332 }
333 }
334
335 /**
336 * \@description
337 * Creates a configured `Creator` function that, when called, returns an object in the shape of the `Action` interface.
338 *
339 * Action creators reduce the explicitness of class-based action creators.
340 *
341 * \@usageNotes
342 *
343 * **Declaring an action creator**
344 *
345 * Without additional metadata:
346 * ```ts
347 * export const increment = createAction('[Counter] Increment');
348 * ```
349 * With additional metadata:
350 * ```ts
351 * export const loginSuccess = createAction(
352 * '[Auth/API] Login Success',
353 * props<{ user: User }>()
354 * );
355 * ```
356 * With a function:
357 * ```ts
358 * export const loginSuccess = createAction(
359 * '[Auth/API] Login Success',
360 * (response: Response) => response.user
361 * );
362 * ```
363 *
364 * **Dispatching an action**
365 *
366 * Without additional metadata:
367 * ```ts
368 * store.dispatch(increment());
369 * ```
370 * With additional metadata:
371 * ```ts
372 * store.dispatch(loginSuccess({ user: newUser }));
373 * ```
374 *
375 * **Referencing an action in a reducer**
376 *
377 * Using a switch statement:
378 * ```ts
379 * switch (action.type) {
380 * // ...
381 * case AuthApiActions.loginSuccess.type: {
382 * return {
383 * ...state,
384 * user: action.user
385 * };
386 * }
387 * }
388 * ```
389 * Using a reducer creator:
390 * ```ts
391 * on(AuthApiActions.loginSuccess, (state, { user }) => ({ ...state, user }))
392 * ```
393 *
394 * **Referencing an action in an effect**
395 * ```ts
396 * effectName$ = createEffect(
397 * () => this.actions$.pipe(
398 * ofType(AuthApiActions.loginSuccess),
399 * // ...
400 * )
401 * );
402 * ```
403 * @template T, C
404 * @param {?} type Describes the action that will be dispatched
405 * @param {?=} config Additional metadata needed for the handling of the action. See {\@link createAction#usage-notes Usage Notes}.
406 *
407 * @return {?}
408 */
409 function createAction(type, config) {
410 REGISTERED_ACTION_TYPES[type] = (REGISTERED_ACTION_TYPES[type] || 0) + 1;
411 if (typeof config === 'function') {
412 return defineType(type, ( /**
413 * @param {...?} args
414 * @return {?}
415 */function () {
416 var args = [];
417 for (var _i = 0; _i < arguments.length; _i++) {
418 args[_i] = arguments[_i];
419 }
420 return (Object.assign(Object.assign({}, config.apply(void 0, __spread(args))), { type: type }));
421 }));
422 }
423 /** @type {?} */
424 var as = config ? config._as : 'empty';
425 switch (as) {
426 case 'empty':
427 return defineType(type, ( /**
428 * @return {?}
429 */function () { return ({ type: type }); }));
430 case 'props':
431 return defineType(type, ( /**
432 * @param {?} props
433 * @return {?}
434 */function (props) { return (Object.assign(Object.assign({}, props), { type: type })); }));
435 default:
436 throw new Error('Unexpected config.');
437 }
438 }
439 /**
440 * @template P
441 * @return {?}
442 */
443 function props() {
444 return { _as: 'props', _p: ( /** @type {?} */(undefined)) };
445 }
446 /**
447 * @template C
448 * @param {?} creators
449 * @return {?}
450 */
451 function union(creators) {
452 return ( /** @type {?} */(undefined));
453 }
454 /**
455 * @template T
456 * @param {?} type
457 * @param {?} creator
458 * @return {?}
459 */
460 function defineType(type, creator) {
461 return Object.defineProperty(creator, 'type', {
462 value: type,
463 writable: false,
464 });
465 }
466
467 /** @type {?} */
468 var INIT = ( /** @type {?} */('@ngrx/store/init'));
469 var ActionsSubject = /** @class */ (function (_super) {
470 __extends(ActionsSubject, _super);
471 function ActionsSubject() {
472 return _super.call(this, { type: INIT }) || this;
473 }
474 /**
475 * @param {?} action
476 * @return {?}
477 */
478 ActionsSubject.prototype.next = function (action) {
479 if (typeof action === 'function') {
480 throw new TypeError("\n Dispatch expected an object, instead it received a function.\n If you're using the createAction function, make sure to invoke the function\n before dispatching the action. For example, someAction should be someAction().");
481 }
482 else if (typeof action === 'undefined') {
483 throw new TypeError("Actions must be objects");
484 }
485 else if (typeof action.type === 'undefined') {
486 throw new TypeError("Actions must have a type property");
487 }
488 _super.prototype.next.call(this, action);
489 };
490 /**
491 * @return {?}
492 */
493 ActionsSubject.prototype.complete = function () {
494 /* noop */
495 };
496 /**
497 * @return {?}
498 */
499 ActionsSubject.prototype.ngOnDestroy = function () {
500 _super.prototype.complete.call(this);
501 };
502 return ActionsSubject;
503 }(rxjs.BehaviorSubject));
504 ActionsSubject.decorators = [
505 { type: ngCore.Injectable }
506 ];
507 /** @nocollapse */
508 ActionsSubject.ctorParameters = function () { return []; };
509 /** @type {?} */
510 var ACTIONS_SUBJECT_PROVIDERS = [ActionsSubject];
511
512 /**
513 * @fileoverview added by tsickle
514 * Generated from: src/tokens.ts
515 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
516 */
517 /** @type {?} */
518 var _ROOT_STORE_GUARD = new ngCore.InjectionToken('@ngrx/store Internal Root Guard');
519 /** @type {?} */
520 var _INITIAL_STATE = new ngCore.InjectionToken('@ngrx/store Internal Initial State');
521 /** @type {?} */
522 var INITIAL_STATE = new ngCore.InjectionToken('@ngrx/store Initial State');
523 /** @type {?} */
524 var REDUCER_FACTORY = new ngCore.InjectionToken('@ngrx/store Reducer Factory');
525 /** @type {?} */
526 var _REDUCER_FACTORY = new ngCore.InjectionToken('@ngrx/store Internal Reducer Factory Provider');
527 /** @type {?} */
528 var INITIAL_REDUCERS = new ngCore.InjectionToken('@ngrx/store Initial Reducers');
529 /** @type {?} */
530 var _INITIAL_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Initial Reducers');
531 /** @type {?} */
532 var STORE_FEATURES = new ngCore.InjectionToken('@ngrx/store Store Features');
533 /** @type {?} */
534 var _STORE_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Store Reducers');
535 /** @type {?} */
536 var _FEATURE_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Feature Reducers');
537 /** @type {?} */
538 var _FEATURE_CONFIGS = new ngCore.InjectionToken('@ngrx/store Internal Feature Configs');
539 /** @type {?} */
540 var _STORE_FEATURES = new ngCore.InjectionToken('@ngrx/store Internal Store Features');
541 /** @type {?} */
542 var _FEATURE_REDUCERS_TOKEN = new ngCore.InjectionToken('@ngrx/store Internal Feature Reducers Token');
543 /** @type {?} */
544 var FEATURE_REDUCERS = new ngCore.InjectionToken('@ngrx/store Feature Reducers');
545 /**
546 * User-defined meta reducers from StoreModule.forRoot()
547 * @type {?}
548 */
549 var USER_PROVIDED_META_REDUCERS = new ngCore.InjectionToken('@ngrx/store User Provided Meta Reducers');
550 /**
551 * Meta reducers defined either internally by \@ngrx/store or by library authors
552 * @type {?}
553 */
554 var META_REDUCERS = new ngCore.InjectionToken('@ngrx/store Meta Reducers');
555 /**
556 * Concats the user provided meta reducers and the meta reducers provided on the multi
557 * injection token
558 * @type {?}
559 */
560 var _RESOLVED_META_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Resolved Meta Reducers');
561 /**
562 * Runtime checks defined by the user via an InjectionToken
563 * Defaults to `_USER_RUNTIME_CHECKS`
564 * @type {?}
565 */
566 var USER_RUNTIME_CHECKS = new ngCore.InjectionToken('@ngrx/store User Runtime Checks Config');
567 /**
568 * Runtime checks defined by the user via forRoot()
569 * @type {?}
570 */
571 var _USER_RUNTIME_CHECKS = new ngCore.InjectionToken('@ngrx/store Internal User Runtime Checks Config');
572 /**
573 * Runtime checks currently in use
574 * @type {?}
575 */
576 var _ACTIVE_RUNTIME_CHECKS = new ngCore.InjectionToken('@ngrx/store Internal Runtime Checks');
577 /** @type {?} */
578 var _ACTION_TYPE_UNIQUENESS_CHECK = new ngCore.InjectionToken('@ngrx/store Check if Action types are unique');
579
580 /**
581 * @fileoverview added by tsickle
582 * Generated from: src/utils.ts
583 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
584 */
585 /**
586 * \@description
587 * Combines reducers for individual features into a single reducer.
588 *
589 * You can use this function to delegate handling of state transitions to multiple reducers, each acting on their
590 * own sub-state within the root state.
591 *
592 * \@usageNotes
593 *
594 * **Example combining two feature reducers into one "root" reducer**
595 *
596 * ```ts
597 * export const reducer = combineReducers({
598 * featureA: featureAReducer,
599 * featureB: featureBReducer
600 * });
601 * ```
602 *
603 * You can also override the initial states of the sub-features:
604 * ```ts
605 * export const reducer = combineReducers({
606 * featureA: featureAReducer,
607 * featureB: featureBReducer
608 * }, {
609 * featureA: { counterA: 13 },
610 * featureB: { counterB: 37 }
611 * });
612 * ```
613 * @param {?} reducers An object mapping keys of the root state to their corresponding feature reducer.
614 * @param {?=} initialState Provides a state value if the current state is `undefined`, as it is initially.
615 * @return {?} A reducer function.
616 *
617 */
618 function combineReducers(reducers, initialState) {
619 if (initialState === void 0) { initialState = {}; }
620 /** @type {?} */
621 var reducerKeys = Object.keys(reducers);
622 /** @type {?} */
623 var finalReducers = {};
624 for (var i = 0; i < reducerKeys.length; i++) {
625 /** @type {?} */
626 var key = reducerKeys[i];
627 if (typeof reducers[key] === 'function') {
628 finalReducers[key] = reducers[key];
629 }
630 }
631 /** @type {?} */
632 var finalReducerKeys = Object.keys(finalReducers);
633 return ( /**
634 * @param {?} state
635 * @param {?} action
636 * @return {?}
637 */function combination(state, action) {
638 state = state === undefined ? initialState : state;
639 /** @type {?} */
640 var hasChanged = false;
641 /** @type {?} */
642 var nextState = {};
643 for (var i = 0; i < finalReducerKeys.length; i++) {
644 /** @type {?} */
645 var key = finalReducerKeys[i];
646 /** @type {?} */
647 var reducer = finalReducers[key];
648 /** @type {?} */
649 var previousStateForKey = state[key];
650 /** @type {?} */
651 var nextStateForKey = reducer(previousStateForKey, action);
652 nextState[key] = nextStateForKey;
653 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
654 }
655 return hasChanged ? nextState : state;
656 });
657 }
658 /**
659 * @template T
660 * @param {?} object
661 * @param {?} keyToRemove
662 * @return {?}
663 */
664 function omit(object, keyToRemove) {
665 return Object.keys(object)
666 .filter(( /**
667 * @param {?} key
668 * @return {?}
669 */function (key) { return key !== keyToRemove; }))
670 .reduce(( /**
671 * @param {?} result
672 * @param {?} key
673 * @return {?}
674 */function (result, key) {
675 var _a;
676 return Object.assign(result, (_a = {}, _a[key] = object[key], _a));
677 }), {});
678 }
679 /**
680 * @param {...?} functions
681 * @return {?}
682 */
683 function compose() {
684 var functions = [];
685 for (var _i = 0; _i < arguments.length; _i++) {
686 functions[_i] = arguments[_i];
687 }
688 return ( /**
689 * @param {?} arg
690 * @return {?}
691 */function (arg) {
692 if (functions.length === 0) {
693 return arg;
694 }
695 /** @type {?} */
696 var last = functions[functions.length - 1];
697 /** @type {?} */
698 var rest = functions.slice(0, -1);
699 return rest.reduceRight(( /**
700 * @param {?} composed
701 * @param {?} fn
702 * @return {?}
703 */function (composed, fn) { return fn(composed); }), last(arg));
704 });
705 }
706 /**
707 * @template T, V
708 * @param {?} reducerFactory
709 * @param {?=} metaReducers
710 * @return {?}
711 */
712 function createReducerFactory(reducerFactory, metaReducers) {
713 if (Array.isArray(metaReducers) && metaReducers.length > 0) {
714 (( /** @type {?} */(reducerFactory))) = compose.apply(null, __spread(metaReducers, [
715 reducerFactory,
716 ]));
717 }
718 return ( /**
719 * @param {?} reducers
720 * @param {?=} initialState
721 * @return {?}
722 */function (reducers, initialState) {
723 /** @type {?} */
724 var reducer = reducerFactory(reducers);
725 return ( /**
726 * @param {?} state
727 * @param {?} action
728 * @return {?}
729 */function (state, action) {
730 state = state === undefined ? (( /** @type {?} */(initialState))) : state;
731 return reducer(state, action);
732 });
733 });
734 }
735 /**
736 * @template T, V
737 * @param {?=} metaReducers
738 * @return {?}
739 */
740 function createFeatureReducerFactory(metaReducers) {
741 /** @type {?} */
742 var reducerFactory = Array.isArray(metaReducers) && metaReducers.length > 0
743 ? compose.apply(void 0, __spread(metaReducers)) : ( /**
744 * @param {?} r
745 * @return {?}
746 */function (r) { return r; });
747 return ( /**
748 * @param {?} reducer
749 * @param {?=} initialState
750 * @return {?}
751 */function (reducer, initialState) {
752 reducer = reducerFactory(reducer);
753 return ( /**
754 * @param {?} state
755 * @param {?} action
756 * @return {?}
757 */function (state, action) {
758 state = state === undefined ? initialState : state;
759 return reducer(state, action);
760 });
761 });
762 }
763
764 /**
765 * @abstract
766 */
767 var ReducerObservable = /** @class */ (function (_super) {
768 __extends(ReducerObservable, _super);
769 function ReducerObservable() {
770 return _super !== null && _super.apply(this, arguments) || this;
771 }
772 return ReducerObservable;
773 }(rxjs.Observable));
774 /**
775 * @abstract
776 */
777 var ReducerManagerDispatcher = /** @class */ (function (_super) {
778 __extends(ReducerManagerDispatcher, _super);
779 function ReducerManagerDispatcher() {
780 return _super !== null && _super.apply(this, arguments) || this;
781 }
782 return ReducerManagerDispatcher;
783 }(ActionsSubject));
784 /** @type {?} */
785 var UPDATE = ( /** @type {?} */('@ngrx/store/update-reducers'));
786 var ReducerManager = /** @class */ (function (_super) {
787 __extends(ReducerManager, _super);
788 /**
789 * @param {?} dispatcher
790 * @param {?} initialState
791 * @param {?} reducers
792 * @param {?} reducerFactory
793 */
794 function ReducerManager(dispatcher, initialState, reducers, reducerFactory) {
795 var _this = _super.call(this, reducerFactory(reducers, initialState)) || this;
796 _this.dispatcher = dispatcher;
797 _this.initialState = initialState;
798 _this.reducers = reducers;
799 _this.reducerFactory = reducerFactory;
800 return _this;
801 }
802 /**
803 * @param {?} feature
804 * @return {?}
805 */
806 ReducerManager.prototype.addFeature = function (feature) {
807 this.addFeatures([feature]);
808 };
809 /**
810 * @param {?} features
811 * @return {?}
812 */
813 ReducerManager.prototype.addFeatures = function (features) {
814 /** @type {?} */
815 var reducers = features.reduce(( /**
816 * @param {?} reducerDict
817 * @param {?} __1
818 * @return {?}
819 */function (reducerDict, _a) {
820 var reducers = _a.reducers, reducerFactory = _a.reducerFactory, metaReducers = _a.metaReducers, initialState = _a.initialState, key = _a.key;
821 /** @type {?} */
822 var reducer = typeof reducers === 'function'
823 ? createFeatureReducerFactory(metaReducers)(reducers, initialState)
824 : createReducerFactory(reducerFactory, metaReducers)(reducers, initialState);
825 reducerDict[key] = reducer;
826 return reducerDict;
827 }), ( /** @type {?} */({})));
828 this.addReducers(reducers);
829 };
830 /**
831 * @param {?} feature
832 * @return {?}
833 */
834 ReducerManager.prototype.removeFeature = function (feature) {
835 this.removeFeatures([feature]);
836 };
837 /**
838 * @param {?} features
839 * @return {?}
840 */
841 ReducerManager.prototype.removeFeatures = function (features) {
842 this.removeReducers(features.map(( /**
843 * @param {?} p
844 * @return {?}
845 */function (p) { return p.key; })));
846 };
847 /**
848 * @param {?} key
849 * @param {?} reducer
850 * @return {?}
851 */
852 ReducerManager.prototype.addReducer = function (key, reducer) {
853 var _a;
854 this.addReducers((_a = {}, _a[key] = reducer, _a));
855 };
856 /**
857 * @param {?} reducers
858 * @return {?}
859 */
860 ReducerManager.prototype.addReducers = function (reducers) {
861 this.reducers = Object.assign(Object.assign({}, this.reducers), reducers);
862 this.updateReducers(Object.keys(reducers));
863 };
864 /**
865 * @param {?} featureKey
866 * @return {?}
867 */
868 ReducerManager.prototype.removeReducer = function (featureKey) {
869 this.removeReducers([featureKey]);
870 };
871 /**
872 * @param {?} featureKeys
873 * @return {?}
874 */
875 ReducerManager.prototype.removeReducers = function (featureKeys) {
876 var _this = this;
877 featureKeys.forEach(( /**
878 * @param {?} key
879 * @return {?}
880 */function (key) {
881 _this.reducers = ( /** @type {?} */(omit(_this.reducers, key) /*TODO(#823)*/));
882 }));
883 this.updateReducers(featureKeys);
884 };
885 /**
886 * @private
887 * @param {?} featureKeys
888 * @return {?}
889 */
890 ReducerManager.prototype.updateReducers = function (featureKeys) {
891 this.next(this.reducerFactory(this.reducers, this.initialState));
892 this.dispatcher.next(( /** @type {?} */({
893 type: UPDATE,
894 features: featureKeys,
895 })));
896 };
897 /**
898 * @return {?}
899 */
900 ReducerManager.prototype.ngOnDestroy = function () {
901 this.complete();
902 };
903 return ReducerManager;
904 }(rxjs.BehaviorSubject));
905 ReducerManager.decorators = [
906 { type: ngCore.Injectable }
907 ];
908 /** @nocollapse */
909 ReducerManager.ctorParameters = function () { return [
910 { type: ReducerManagerDispatcher },
911 { type: undefined, decorators: [{ type: ngCore.Inject, args: [INITIAL_STATE,] }] },
912 { type: undefined, decorators: [{ type: ngCore.Inject, args: [INITIAL_REDUCERS,] }] },
913 { type: undefined, decorators: [{ type: ngCore.Inject, args: [REDUCER_FACTORY,] }] }
914 ]; };
915 if (false) {
916 /**
917 * @type {?}
918 * @private
919 */
920 ReducerManager.prototype.dispatcher;
921 /**
922 * @type {?}
923 * @private
924 */
925 ReducerManager.prototype.initialState;
926 /**
927 * @type {?}
928 * @private
929 */
930 ReducerManager.prototype.reducers;
931 /**
932 * @type {?}
933 * @private
934 */
935 ReducerManager.prototype.reducerFactory;
936 }
937 /** @type {?} */
938 var REDUCER_MANAGER_PROVIDERS = [
939 ReducerManager,
940 { provide: ReducerObservable, useExisting: ReducerManager },
941 { provide: ReducerManagerDispatcher, useExisting: ActionsSubject },
942 ];
943
944 var ScannedActionsSubject = /** @class */ (function (_super) {
945 __extends(ScannedActionsSubject, _super);
946 function ScannedActionsSubject() {
947 return _super !== null && _super.apply(this, arguments) || this;
948 }
949 /**
950 * @return {?}
951 */
952 ScannedActionsSubject.prototype.ngOnDestroy = function () {
953 this.complete();
954 };
955 return ScannedActionsSubject;
956 }(rxjs.Subject));
957 ScannedActionsSubject.decorators = [
958 { type: ngCore.Injectable }
959 ];
960 /** @type {?} */
961 var SCANNED_ACTIONS_SUBJECT_PROVIDERS = [
962 ScannedActionsSubject,
963 ];
964
965 /**
966 * @abstract
967 */
968 var StateObservable = /** @class */ (function (_super) {
969 __extends(StateObservable, _super);
970 function StateObservable() {
971 return _super !== null && _super.apply(this, arguments) || this;
972 }
973 return StateObservable;
974 }(rxjs.Observable));
975 /**
976 * @template T
977 */
978 var State = /** @class */ (function (_super) {
979 __extends(State, _super);
980 /**
981 * @param {?} actions$
982 * @param {?} reducer$
983 * @param {?} scannedActions
984 * @param {?} initialState
985 */
986 function State(actions$, reducer$, scannedActions, initialState) {
987 var _this = _super.call(this, initialState) || this;
988 /** @type {?} */
989 var actionsOnQueue$ = actions$.pipe(operators.observeOn(rxjs.queueScheduler));
990 /** @type {?} */
991 var withLatestReducer$ = actionsOnQueue$.pipe(operators.withLatestFrom(reducer$));
992 /** @type {?} */
993 var seed = { state: initialState };
994 /** @type {?} */
995 var stateAndAction$ = withLatestReducer$.pipe(operators.scan(reduceState, seed));
996 _this.stateSubscription = stateAndAction$.subscribe(( /**
997 * @param {?} __0
998 * @return {?}
999 */function (_a) {
1000 var state = _a.state, action = _a.action;
1001 _this.next(state);
1002 scannedActions.next(( /** @type {?} */(action)));
1003 }));
1004 return _this;
1005 }
1006 /**
1007 * @return {?}
1008 */
1009 State.prototype.ngOnDestroy = function () {
1010 this.stateSubscription.unsubscribe();
1011 this.complete();
1012 };
1013 return State;
1014 }(rxjs.BehaviorSubject));
1015 State.INIT = INIT;
1016 State.decorators = [
1017 { type: ngCore.Injectable }
1018 ];
1019 /** @nocollapse */
1020 State.ctorParameters = function () { return [
1021 { type: ActionsSubject },
1022 { type: ReducerObservable },
1023 { type: ScannedActionsSubject },
1024 { type: undefined, decorators: [{ type: ngCore.Inject, args: [INITIAL_STATE,] }] }
1025 ]; };
1026 if (false) {
1027 /** @type {?} */
1028 State.INIT;
1029 /**
1030 * @type {?}
1031 * @private
1032 */
1033 State.prototype.stateSubscription;
1034 }
1035 /**
1036 * @template T, V
1037 * @param {?=} stateActionPair
1038 * @param {?=} __1
1039 * @return {?}
1040 */
1041 function reduceState(stateActionPair, _a) {
1042 if (stateActionPair === void 0) { stateActionPair = { state: undefined }; }
1043 var _b = __read(_a, 2), action = _b[0], reducer = _b[1];
1044 var state = stateActionPair.state;
1045 return { state: reducer(state, action), action: action };
1046 }
1047 /** @type {?} */
1048 var STATE_PROVIDERS = [
1049 State,
1050 { provide: StateObservable, useExisting: State },
1051 ];
1052
1053 /**
1054 * @template T
1055 */
1056 var Store = /** @class */ (function (_super) {
1057 __extends(Store, _super);
1058 /**
1059 * @param {?} state$
1060 * @param {?} actionsObserver
1061 * @param {?} reducerManager
1062 */
1063 function Store(state$, actionsObserver, reducerManager) {
1064 var _this = _super.call(this) || this;
1065 _this.actionsObserver = actionsObserver;
1066 _this.reducerManager = reducerManager;
1067 _this.source = state$;
1068 return _this;
1069 }
1070 /**
1071 * @template Props, K
1072 * @param {?} pathOrMapFn
1073 * @param {...?} paths
1074 * @return {?}
1075 */
1076 Store.prototype.select = function (pathOrMapFn) {
1077 var paths = [];
1078 for (var _i = 1; _i < arguments.length; _i++) {
1079 paths[_i - 1] = arguments[_i];
1080 }
1081 return (( /** @type {?} */(select))).call.apply((( /** @type {?} */(select))), __spread([null, pathOrMapFn], paths))(this);
1082 };
1083 /**
1084 * @template R
1085 * @param {?} operator
1086 * @return {?}
1087 */
1088 Store.prototype.lift = function (operator) {
1089 /** @type {?} */
1090 var store = new Store(this, this.actionsObserver, this.reducerManager);
1091 store.operator = operator;
1092 return store;
1093 };
1094 /**
1095 * @template V
1096 * @param {?} action
1097 * @return {?}
1098 */
1099 Store.prototype.dispatch = function (action) {
1100 this.actionsObserver.next(action);
1101 };
1102 /**
1103 * @param {?} action
1104 * @return {?}
1105 */
1106 Store.prototype.next = function (action) {
1107 this.actionsObserver.next(action);
1108 };
1109 /**
1110 * @param {?} err
1111 * @return {?}
1112 */
1113 Store.prototype.error = function (err) {
1114 this.actionsObserver.error(err);
1115 };
1116 /**
1117 * @return {?}
1118 */
1119 Store.prototype.complete = function () {
1120 this.actionsObserver.complete();
1121 };
1122 /**
1123 * @template State, Actions
1124 * @param {?} key
1125 * @param {?} reducer
1126 * @return {?}
1127 */
1128 Store.prototype.addReducer = function (key, reducer) {
1129 this.reducerManager.addReducer(key, reducer);
1130 };
1131 /**
1132 * @template Key
1133 * @param {?} key
1134 * @return {?}
1135 */
1136 Store.prototype.removeReducer = function (key) {
1137 this.reducerManager.removeReducer(key);
1138 };
1139 return Store;
1140 }(rxjs.Observable));
1141 Store.decorators = [
1142 { type: ngCore.Injectable }
1143 ];
1144 /** @nocollapse */
1145 Store.ctorParameters = function () { return [
1146 { type: StateObservable },
1147 { type: ActionsSubject },
1148 { type: ReducerManager }
1149 ]; };
1150 if (false) {
1151 /**
1152 * @type {?}
1153 * @private
1154 */
1155 Store.prototype.actionsObserver;
1156 /**
1157 * @type {?}
1158 * @private
1159 */
1160 Store.prototype.reducerManager;
1161 }
1162 /** @type {?} */
1163 var STORE_PROVIDERS = [Store];
1164 /**
1165 * @template T, Props, K
1166 * @param {?} pathOrMapFn
1167 * @param {?=} propsOrPath
1168 * @param {...?} paths
1169 * @return {?}
1170 */
1171 function select(pathOrMapFn, propsOrPath) {
1172 var paths = [];
1173 for (var _i = 2; _i < arguments.length; _i++) {
1174 paths[_i - 2] = arguments[_i];
1175 }
1176 return ( /**
1177 * @param {?} source$
1178 * @return {?}
1179 */function selectOperator(source$) {
1180 /** @type {?} */
1181 var mapped$;
1182 if (typeof pathOrMapFn === 'string') {
1183 /** @type {?} */
1184 var pathSlices = __spread([( /** @type {?} */(propsOrPath))], paths).filter(Boolean);
1185 mapped$ = source$.pipe(operators.pluck.apply(void 0, __spread([pathOrMapFn], pathSlices)));
1186 }
1187 else if (typeof pathOrMapFn === 'function') {
1188 mapped$ = source$.pipe(operators.map(( /**
1189 * @param {?} source
1190 * @return {?}
1191 */function (source) { return pathOrMapFn(source, ( /** @type {?} */(propsOrPath))); })));
1192 }
1193 else {
1194 throw new TypeError("Unexpected type '" + typeof pathOrMapFn + "' in select operator," +
1195 " expected 'string' or 'function'");
1196 }
1197 return mapped$.pipe(operators.distinctUntilChanged());
1198 });
1199 }
1200
1201 /**
1202 * @fileoverview added by tsickle
1203 * Generated from: src/flags.ts
1204 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1205 */
1206 /** @type {?} */
1207 var _ngrxMockEnvironment = false;
1208 /**
1209 * @param {?} value
1210 * @return {?}
1211 */
1212 function setNgrxMockEnvironment(value) {
1213 _ngrxMockEnvironment = value;
1214 }
1215 /**
1216 * @return {?}
1217 */
1218 function isNgrxMockEnvironment() {
1219 return _ngrxMockEnvironment;
1220 }
1221
1222 /**
1223 * @record
1224 * @template State, Result, ProjectorFn
1225 */
1226 function MemoizedSelector() { }
1227 if (false) {
1228 /** @type {?} */
1229 MemoizedSelector.prototype.projector;
1230 /** @type {?} */
1231 MemoizedSelector.prototype.setResult;
1232 /** @type {?} */
1233 MemoizedSelector.prototype.clearResult;
1234 /**
1235 * @return {?}
1236 */
1237 MemoizedSelector.prototype.release = function () { };
1238 }
1239 /**
1240 * @record
1241 * @template State, Props, Result, ProjectorFn
1242 */
1243 function MemoizedSelectorWithProps() { }
1244 if (false) {
1245 /** @type {?} */
1246 MemoizedSelectorWithProps.prototype.projector;
1247 /** @type {?} */
1248 MemoizedSelectorWithProps.prototype.setResult;
1249 /** @type {?} */
1250 MemoizedSelectorWithProps.prototype.clearResult;
1251 /**
1252 * @return {?}
1253 */
1254 MemoizedSelectorWithProps.prototype.release = function () { };
1255 }
1256 /**
1257 * @param {?} a
1258 * @param {?} b
1259 * @return {?}
1260 */
1261 function isEqualCheck(a, b) {
1262 return a === b;
1263 }
1264 /**
1265 * @param {?} args
1266 * @param {?} lastArguments
1267 * @param {?} comparator
1268 * @return {?}
1269 */
1270 function isArgumentsChanged(args, lastArguments, comparator) {
1271 for (var i = 0; i < args.length; i++) {
1272 if (!comparator(args[i], lastArguments[i])) {
1273 return true;
1274 }
1275 }
1276 return false;
1277 }
1278 /**
1279 * @param {?} projectionFn
1280 * @param {?} isResultEqual
1281 * @return {?}
1282 */
1283 function resultMemoize(projectionFn, isResultEqual) {
1284 return defaultMemoize(projectionFn, isEqualCheck, isResultEqual);
1285 }
1286 /**
1287 * @param {?} projectionFn
1288 * @param {?=} isArgumentsEqual
1289 * @param {?=} isResultEqual
1290 * @return {?}
1291 */
1292 function defaultMemoize(projectionFn, isArgumentsEqual, isResultEqual) {
1293 if (isArgumentsEqual === void 0) { isArgumentsEqual = isEqualCheck; }
1294 if (isResultEqual === void 0) { isResultEqual = isEqualCheck; }
1295 /** @type {?} */
1296 var lastArguments = null;
1297 // tslint:disable-next-line:no-any anything could be the result.
1298 /** @type {?} */
1299 var lastResult = null;
1300 /** @type {?} */
1301 var overrideResult;
1302 /**
1303 * @return {?}
1304 */
1305 function reset() {
1306 lastArguments = null;
1307 lastResult = null;
1308 }
1309 /**
1310 * @param {?=} result
1311 * @return {?}
1312 */
1313 function setResult(result) {
1314 if (result === void 0) { result = undefined; }
1315 overrideResult = { result: result };
1316 }
1317 /**
1318 * @return {?}
1319 */
1320 function clearResult() {
1321 overrideResult = undefined;
1322 }
1323 // tslint:disable-next-line:no-any anything could be the result.
1324 /**
1325 * @return {?}
1326 */
1327 function memoized() {
1328 if (overrideResult !== undefined) {
1329 return overrideResult.result;
1330 }
1331 if (!lastArguments) {
1332 lastResult = projectionFn.apply(null, ( /** @type {?} */(arguments)));
1333 lastArguments = arguments;
1334 return lastResult;
1335 }
1336 if (!isArgumentsChanged(arguments, lastArguments, isArgumentsEqual)) {
1337 return lastResult;
1338 }
1339 /** @type {?} */
1340 var newResult = projectionFn.apply(null, ( /** @type {?} */(arguments)));
1341 lastArguments = arguments;
1342 if (isResultEqual(lastResult, newResult)) {
1343 return lastResult;
1344 }
1345 lastResult = newResult;
1346 return newResult;
1347 }
1348 return { memoized: memoized, reset: reset, setResult: setResult, clearResult: clearResult };
1349 }
1350 /**
1351 * @param {...?} input
1352 * @return {?}
1353 */
1354 function createSelector() {
1355 var input = [];
1356 for (var _i = 0; _i < arguments.length; _i++) {
1357 input[_i] = arguments[_i];
1358 }
1359 return createSelectorFactory(defaultMemoize).apply(void 0, __spread(input));
1360 }
1361 /**
1362 * @param {?} state
1363 * @param {?} selectors
1364 * @param {?} props
1365 * @param {?} memoizedProjector
1366 * @return {?}
1367 */
1368 function defaultStateFn(state, selectors, props, memoizedProjector) {
1369 if (props === undefined) {
1370 /** @type {?} */
1371 var args_1 = (( /** @type {?} */(selectors))).map(( /**
1372 * @param {?} fn
1373 * @return {?}
1374 */function (fn) { return fn(state); }));
1375 return memoizedProjector.memoized.apply(null, args_1);
1376 }
1377 /** @type {?} */
1378 var args = (( /** @type {?} */(selectors))).map(( /**
1379 * @param {?} fn
1380 * @return {?}
1381 */function (fn) { return fn(state, props); }));
1382 return memoizedProjector.memoized.apply(null, __spread(args, [props]));
1383 }
1384 /**
1385 *
1386 * \@usageNotes
1387 *
1388 * **Creating a Selector Factory Where Array Order Does Not Matter**
1389 *
1390 * ```ts
1391 * function removeMatch(arr: string[], target: string): string[] {
1392 * const matchIndex = arr.indexOf(target);
1393 * return [...arr.slice(0, matchIndex), ...arr.slice(matchIndex + 1)];
1394 * }
1395 *
1396 * function orderDoesNotMatterComparer(a: any, b: any): boolean {
1397 * if (!Array.isArray(a) || !Array.isArray(b)) {
1398 * return a === b;
1399 * }
1400 * if (a.length !== b.length) {
1401 * return false;
1402 * }
1403 * let tempB = [...b];
1404 * function reduceToDetermineIfArraysContainSameContents(
1405 * previousCallResult: boolean,
1406 * arrayMember: any
1407 * ): boolean {
1408 * if (previousCallResult === false) {
1409 * return false;
1410 * }
1411 * if (tempB.includes(arrayMember)) {
1412 * tempB = removeMatch(tempB, arrayMember);
1413 * return true;
1414 * }
1415 * return false;
1416 * }
1417 * return a.reduce(reduceToDetermineIfArraysContainSameContents, true);
1418 * }
1419 *
1420 * export const creactOrderDoesNotMatterSelector = createSelectorFactory(
1421 * (projectionFun) => defaultMemoize(
1422 * projectionFun,
1423 * orderDoesNotMatterComparer,
1424 * orderDoesNotMatterComparer
1425 * )
1426 * );
1427 * ```
1428 *
1429 * **Creating an Alternative Memoization Strategy**
1430 *
1431 * ```ts
1432 * function serialize(x: any): string {
1433 * return JSON.stringify(x);
1434 * }
1435 *
1436 * export const createFullHistorySelector = createSelectorFactory(
1437 * (projectionFunction) => {
1438 * const cache = {};
1439 *
1440 * function memoized() {
1441 * const serializedArguments = serialize(...arguments);
1442 * if (cache[serializedArguments] != null) {
1443 * cache[serializedArguments] = projectionFunction.apply(null, arguments);
1444 * }
1445 * return cache[serializedArguments];
1446 * }
1447 * return {
1448 * memoized,
1449 * reset: () => {},
1450 * setResult: () => {},
1451 * clearResult: () => {},
1452 * };
1453 * }
1454 * );
1455 * ```
1456 *
1457 *
1458 * @param {?} memoize The function used to memoize selectors
1459 * @param {?=} options Config Object that may include a `stateFn` function defining how to return the selector's value, given the entire `Store`'s state, parent `Selector`s, `Props`, and a `MemoizedProjection`
1460 *
1461 * @return {?}
1462 */
1463 function createSelectorFactory(memoize, options) {
1464 if (options === void 0) { options = {
1465 stateFn: defaultStateFn,
1466 }; }
1467 return ( /**
1468 * @param {...?} input
1469 * @return {?}
1470 */function () {
1471 var input = [];
1472 for (var _i = 0; _i < arguments.length; _i++) {
1473 input[_i] = arguments[_i];
1474 }
1475 /** @type {?} */
1476 var args = input;
1477 if (Array.isArray(args[0])) {
1478 var _a = __read(args), head = _a[0], tail = _a.slice(1);
1479 args = __spread(head, tail);
1480 }
1481 /** @type {?} */
1482 var selectors = args.slice(0, args.length - 1);
1483 /** @type {?} */
1484 var projector = args[args.length - 1];
1485 /** @type {?} */
1486 var memoizedSelectors = selectors.filter(( /**
1487 * @param {?} selector
1488 * @return {?}
1489 */function (selector) { return selector.release && typeof selector.release === 'function'; }));
1490 /** @type {?} */
1491 var memoizedProjector = memoize(( /**
1492 * @param {...?} selectors
1493 * @return {?}
1494 */function () {
1495 var selectors = [];
1496 for (var _i = 0; _i < arguments.length; _i++) {
1497 selectors[_i] = arguments[_i];
1498 }
1499 return projector.apply(null, selectors);
1500 }));
1501 /** @type {?} */
1502 var memoizedState = defaultMemoize(( /**
1503 * @param {?} state
1504 * @param {?} props
1505 * @return {?}
1506 */function (state, props) {
1507 return options.stateFn.apply(null, [
1508 state,
1509 selectors,
1510 props,
1511 memoizedProjector,
1512 ]);
1513 }));
1514 /**
1515 * @return {?}
1516 */
1517 function release() {
1518 memoizedState.reset();
1519 memoizedProjector.reset();
1520 memoizedSelectors.forEach(( /**
1521 * @param {?} selector
1522 * @return {?}
1523 */function (selector) { return selector.release(); }));
1524 }
1525 return Object.assign(memoizedState.memoized, {
1526 release: release,
1527 projector: memoizedProjector.memoized,
1528 setResult: memoizedState.setResult,
1529 clearResult: memoizedState.clearResult,
1530 });
1531 });
1532 }
1533 /**
1534 * @param {?} featureName
1535 * @return {?}
1536 */
1537 function createFeatureSelector(featureName) {
1538 return createSelector(( /**
1539 * @param {?} state
1540 * @return {?}
1541 */function (state) {
1542 /** @type {?} */
1543 var featureState = state[featureName];
1544 if (!isNgrxMockEnvironment() && ngCore.isDevMode() && !(featureName in state)) {
1545 console.warn("@ngrx/store: The feature name \"" + featureName + "\" does " +
1546 'not exist in the state, therefore createFeatureSelector ' +
1547 'cannot access it. Be sure it is imported in a loaded module ' +
1548 ("using StoreModule.forRoot('" + featureName + "', ...) or ") +
1549 ("StoreModule.forFeature('" + featureName + "', ...). If the default ") +
1550 'state is intended to be undefined, as is the case with router ' +
1551 'state, this development-only warning message can be ignored.');
1552 }
1553 return featureState;
1554 }), ( /**
1555 * @param {?} featureState
1556 * @return {?}
1557 */function (featureState) { return featureState; }));
1558 }
1559
1560 /**
1561 * @fileoverview added by tsickle
1562 * Generated from: src/meta-reducers/utils.ts
1563 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1564 */
1565 /** @type {?} */
1566 var RUNTIME_CHECK_URL = 'https://ngrx.io/guide/store/configuration/runtime-checks';
1567 /**
1568 * @param {?} target
1569 * @return {?}
1570 */
1571 function isUndefined(target) {
1572 return target === undefined;
1573 }
1574 /**
1575 * @param {?} target
1576 * @return {?}
1577 */
1578 function isNull(target) {
1579 return target === null;
1580 }
1581 /**
1582 * @param {?} target
1583 * @return {?}
1584 */
1585 function isArray(target) {
1586 return Array.isArray(target);
1587 }
1588 /**
1589 * @param {?} target
1590 * @return {?}
1591 */
1592 function isString(target) {
1593 return typeof target === 'string';
1594 }
1595 /**
1596 * @param {?} target
1597 * @return {?}
1598 */
1599 function isBoolean(target) {
1600 return typeof target === 'boolean';
1601 }
1602 /**
1603 * @param {?} target
1604 * @return {?}
1605 */
1606 function isNumber(target) {
1607 return typeof target === 'number';
1608 }
1609 /**
1610 * @param {?} target
1611 * @return {?}
1612 */
1613 function isObjectLike(target) {
1614 return typeof target === 'object' && target !== null;
1615 }
1616 /**
1617 * @param {?} target
1618 * @return {?}
1619 */
1620 function isObject(target) {
1621 return isObjectLike(target) && !isArray(target);
1622 }
1623 /**
1624 * @param {?} target
1625 * @return {?}
1626 */
1627 function isPlainObject(target) {
1628 if (!isObject(target)) {
1629 return false;
1630 }
1631 /** @type {?} */
1632 var targetPrototype = Object.getPrototypeOf(target);
1633 return targetPrototype === Object.prototype || targetPrototype === null;
1634 }
1635 /**
1636 * @param {?} target
1637 * @return {?}
1638 */
1639 function isFunction(target) {
1640 return typeof target === 'function';
1641 }
1642 /**
1643 * @param {?} target
1644 * @return {?}
1645 */
1646 function isComponent(target) {
1647 return isFunction(target) && target.hasOwnProperty('ɵcmp');
1648 }
1649 /**
1650 * @param {?} target
1651 * @param {?} propertyName
1652 * @return {?}
1653 */
1654 function hasOwnProperty(target, propertyName) {
1655 return Object.prototype.hasOwnProperty.call(target, propertyName);
1656 }
1657
1658 /**
1659 * @fileoverview added by tsickle
1660 * Generated from: src/meta-reducers/immutability_reducer.ts
1661 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1662 */
1663 /**
1664 * @param {?} reducer
1665 * @param {?} checks
1666 * @return {?}
1667 */
1668 function immutabilityCheckMetaReducer(reducer, checks) {
1669 return ( /**
1670 * @param {?} state
1671 * @param {?} action
1672 * @return {?}
1673 */function (state, action) {
1674 /** @type {?} */
1675 var act = checks.action(action) ? freeze(action) : action;
1676 /** @type {?} */
1677 var nextState = reducer(state, act);
1678 return checks.state() ? freeze(nextState) : nextState;
1679 });
1680 }
1681 /**
1682 * @param {?} target
1683 * @return {?}
1684 */
1685 function freeze(target) {
1686 Object.freeze(target);
1687 /** @type {?} */
1688 var targetIsFunction = isFunction(target);
1689 Object.getOwnPropertyNames(target).forEach(( /**
1690 * @param {?} prop
1691 * @return {?}
1692 */function (prop) {
1693 // Ignore Ivy properties, ref: https://github.com/ngrx/platform/issues/2109#issuecomment-582689060
1694 if (prop.startsWith('ɵ')) {
1695 return;
1696 }
1697 if (hasOwnProperty(target, prop) &&
1698 (targetIsFunction
1699 ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments'
1700 : true)) {
1701 /** @type {?} */
1702 var propValue = target[prop];
1703 if ((isObjectLike(propValue) || isFunction(propValue)) &&
1704 !Object.isFrozen(propValue)) {
1705 freeze(propValue);
1706 }
1707 }
1708 }));
1709 return target;
1710 }
1711
1712 /**
1713 * @param {?} reducer
1714 * @param {?} checks
1715 * @return {?}
1716 */
1717 function serializationCheckMetaReducer(reducer, checks) {
1718 return ( /**
1719 * @param {?} state
1720 * @param {?} action
1721 * @return {?}
1722 */function (state, action) {
1723 if (checks.action(action)) {
1724 /** @type {?} */
1725 var unserializableAction = getUnserializable(action);
1726 throwIfUnserializable(unserializableAction, 'action');
1727 }
1728 /** @type {?} */
1729 var nextState = reducer(state, action);
1730 if (checks.state()) {
1731 /** @type {?} */
1732 var unserializableState = getUnserializable(nextState);
1733 throwIfUnserializable(unserializableState, 'state');
1734 }
1735 return nextState;
1736 });
1737 }
1738 /**
1739 * @param {?=} target
1740 * @param {?=} path
1741 * @return {?}
1742 */
1743 function getUnserializable(target, path) {
1744 if (path === void 0) { path = []; }
1745 // Guard against undefined and null, e.g. a reducer that returns undefined
1746 if ((isUndefined(target) || isNull(target)) && path.length === 0) {
1747 return {
1748 path: ['root'],
1749 value: target,
1750 };
1751 }
1752 /** @type {?} */
1753 var keys = Object.keys(target);
1754 return keys.reduce(( /**
1755 * @param {?} result
1756 * @param {?} key
1757 * @return {?}
1758 */function (result, key) {
1759 if (result) {
1760 return result;
1761 }
1762 /** @type {?} */
1763 var value = (( /** @type {?} */(target)))[key];
1764 // Ignore Ivy components
1765 if (isComponent(value)) {
1766 return result;
1767 }
1768 if (isUndefined(value) ||
1769 isNull(value) ||
1770 isNumber(value) ||
1771 isBoolean(value) ||
1772 isString(value) ||
1773 isArray(value)) {
1774 return false;
1775 }
1776 if (isPlainObject(value)) {
1777 return getUnserializable(value, __spread(path, [key]));
1778 }
1779 return {
1780 path: __spread(path, [key]),
1781 value: value,
1782 };
1783 }), false);
1784 }
1785 /**
1786 * @param {?} unserializable
1787 * @param {?} context
1788 * @return {?}
1789 */
1790 function throwIfUnserializable(unserializable, context) {
1791 if (unserializable === false) {
1792 return;
1793 }
1794 /** @type {?} */
1795 var unserializablePath = unserializable.path.join('.');
1796 /** @type {?} */
1797 var error = new Error("Detected unserializable " + context + " at \"" + unserializablePath + "\". " + RUNTIME_CHECK_URL + "#strict" + context + "serializability");
1798 error.value = unserializable.value;
1799 error.unserializablePath = unserializablePath;
1800 throw error;
1801 }
1802
1803 /**
1804 * @fileoverview added by tsickle
1805 * Generated from: src/meta-reducers/inNgZoneAssert_reducer.ts
1806 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1807 */
1808 /**
1809 * @param {?} reducer
1810 * @param {?} checks
1811 * @return {?}
1812 */
1813 function inNgZoneAssertMetaReducer(reducer, checks) {
1814 return ( /**
1815 * @param {?} state
1816 * @param {?} action
1817 * @return {?}
1818 */function (state, action) {
1819 if (checks.action(action) && !ngCore.NgZone.isInAngularZone()) {
1820 throw new Error("Action '" + action.type + "' running outside NgZone. " + RUNTIME_CHECK_URL + "#strictactionwithinngzone");
1821 }
1822 return reducer(state, action);
1823 });
1824 }
1825
1826 /**
1827 * @fileoverview added by tsickle
1828 * Generated from: src/meta-reducers/index.ts
1829 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1830 */
1831
1832 /**
1833 * @param {?=} runtimeChecks
1834 * @return {?}
1835 */
1836 function createActiveRuntimeChecks(runtimeChecks) {
1837 if (ngCore.isDevMode()) {
1838 return Object.assign({ strictStateSerializability: false, strictActionSerializability: false, strictStateImmutability: true, strictActionImmutability: true, strictActionWithinNgZone: false, strictActionTypeUniqueness: false }, runtimeChecks);
1839 }
1840 return {
1841 strictStateSerializability: false,
1842 strictActionSerializability: false,
1843 strictStateImmutability: false,
1844 strictActionImmutability: false,
1845 strictActionWithinNgZone: false,
1846 strictActionTypeUniqueness: false,
1847 };
1848 }
1849 /**
1850 * @param {?} __0
1851 * @return {?}
1852 */
1853 function createSerializationCheckMetaReducer(_a) {
1854 var strictActionSerializability = _a.strictActionSerializability, strictStateSerializability = _a.strictStateSerializability;
1855 return ( /**
1856 * @param {?} reducer
1857 * @return {?}
1858 */function (reducer) { return strictActionSerializability || strictStateSerializability
1859 ? serializationCheckMetaReducer(reducer, {
1860 action: ( /**
1861 * @param {?} action
1862 * @return {?}
1863 */function (action) { return strictActionSerializability && !ignoreNgrxAction(action); }),
1864 state: ( /**
1865 * @return {?}
1866 */function () { return strictStateSerializability; }),
1867 })
1868 : reducer; });
1869 }
1870 /**
1871 * @param {?} __0
1872 * @return {?}
1873 */
1874 function createImmutabilityCheckMetaReducer(_a) {
1875 var strictActionImmutability = _a.strictActionImmutability, strictStateImmutability = _a.strictStateImmutability;
1876 return ( /**
1877 * @param {?} reducer
1878 * @return {?}
1879 */function (reducer) { return strictActionImmutability || strictStateImmutability
1880 ? immutabilityCheckMetaReducer(reducer, {
1881 action: ( /**
1882 * @param {?} action
1883 * @return {?}
1884 */function (action) { return strictActionImmutability && !ignoreNgrxAction(action); }),
1885 state: ( /**
1886 * @return {?}
1887 */function () { return strictStateImmutability; }),
1888 })
1889 : reducer; });
1890 }
1891 /**
1892 * @param {?} action
1893 * @return {?}
1894 */
1895 function ignoreNgrxAction(action) {
1896 return action.type.startsWith('@ngrx');
1897 }
1898 /**
1899 * @param {?} __0
1900 * @return {?}
1901 */
1902 function createInNgZoneCheckMetaReducer(_a) {
1903 var strictActionWithinNgZone = _a.strictActionWithinNgZone;
1904 return ( /**
1905 * @param {?} reducer
1906 * @return {?}
1907 */function (reducer) { return strictActionWithinNgZone
1908 ? inNgZoneAssertMetaReducer(reducer, {
1909 action: ( /**
1910 * @param {?} action
1911 * @return {?}
1912 */function (action) { return strictActionWithinNgZone && !ignoreNgrxAction(action); }),
1913 })
1914 : reducer; });
1915 }
1916 /**
1917 * @param {?=} runtimeChecks
1918 * @return {?}
1919 */
1920 function provideRuntimeChecks(runtimeChecks) {
1921 return [
1922 {
1923 provide: _USER_RUNTIME_CHECKS,
1924 useValue: runtimeChecks,
1925 },
1926 {
1927 provide: USER_RUNTIME_CHECKS,
1928 useFactory: _runtimeChecksFactory,
1929 deps: [_USER_RUNTIME_CHECKS],
1930 },
1931 {
1932 provide: _ACTIVE_RUNTIME_CHECKS,
1933 deps: [USER_RUNTIME_CHECKS],
1934 useFactory: createActiveRuntimeChecks,
1935 },
1936 {
1937 provide: META_REDUCERS,
1938 multi: true,
1939 deps: [_ACTIVE_RUNTIME_CHECKS],
1940 useFactory: createImmutabilityCheckMetaReducer,
1941 },
1942 {
1943 provide: META_REDUCERS,
1944 multi: true,
1945 deps: [_ACTIVE_RUNTIME_CHECKS],
1946 useFactory: createSerializationCheckMetaReducer,
1947 },
1948 {
1949 provide: META_REDUCERS,
1950 multi: true,
1951 deps: [_ACTIVE_RUNTIME_CHECKS],
1952 useFactory: createInNgZoneCheckMetaReducer,
1953 },
1954 ];
1955 }
1956 /**
1957 * @return {?}
1958 */
1959 function checkForActionTypeUniqueness() {
1960 return [
1961 {
1962 provide: _ACTION_TYPE_UNIQUENESS_CHECK,
1963 multi: true,
1964 deps: [_ACTIVE_RUNTIME_CHECKS],
1965 useFactory: _actionTypeUniquenessCheck,
1966 },
1967 ];
1968 }
1969 /**
1970 * @param {?} runtimeChecks
1971 * @return {?}
1972 */
1973 function _runtimeChecksFactory(runtimeChecks) {
1974 return runtimeChecks;
1975 }
1976 /**
1977 * @param {?} config
1978 * @return {?}
1979 */
1980 function _actionTypeUniquenessCheck(config) {
1981 if (!config.strictActionTypeUniqueness) {
1982 return;
1983 }
1984 /** @type {?} */
1985 var duplicates = Object.entries(REGISTERED_ACTION_TYPES)
1986 .filter(( /**
1987 * @param {?} __0
1988 * @return {?}
1989 */function (_a) {
1990 var _b = __read(_a, 2), registrations = _b[1];
1991 return registrations > 1;
1992 }))
1993 .map(( /**
1994 * @param {?} __0
1995 * @return {?}
1996 */function (_a) {
1997 var _b = __read(_a, 1), type = _b[0];
1998 return type;
1999 }));
2000 if (duplicates.length) {
2001 throw new Error("Action types are registered more than once, " + duplicates
2002 .map(( /**
2003 * @param {?} type
2004 * @return {?}
2005 */function (type) { return "\"" + type + "\""; }))
2006 .join(', ') + ". " + RUNTIME_CHECK_URL + "#strictactiontypeuniqueness");
2007 }
2008 }
2009
2010 /**
2011 * @fileoverview added by tsickle
2012 * Generated from: src/store_module.ts
2013 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2014 */
2015 var StoreRootModule = /** @class */ (function () {
2016 /**
2017 * @param {?} actions$
2018 * @param {?} reducer$
2019 * @param {?} scannedActions$
2020 * @param {?} store
2021 * @param {?} guard
2022 * @param {?} actionCheck
2023 */
2024 function StoreRootModule(actions$, reducer$, scannedActions$, store, guard, actionCheck) {
2025 }
2026 return StoreRootModule;
2027 }());
2028 StoreRootModule.decorators = [
2029 { type: ngCore.NgModule, args: [{},] }
2030 ];
2031 /** @nocollapse */
2032 StoreRootModule.ctorParameters = function () { return [
2033 { type: ActionsSubject },
2034 { type: ReducerObservable },
2035 { type: ScannedActionsSubject },
2036 { type: Store },
2037 { type: undefined, decorators: [{ type: ngCore.Optional }, { type: ngCore.Inject, args: [_ROOT_STORE_GUARD,] }] },
2038 { type: undefined, decorators: [{ type: ngCore.Optional }, { type: ngCore.Inject, args: [_ACTION_TYPE_UNIQUENESS_CHECK,] }] }
2039 ]; };
2040 var StoreFeatureModule = /** @class */ (function () {
2041 /**
2042 * @param {?} features
2043 * @param {?} featureReducers
2044 * @param {?} reducerManager
2045 * @param {?} root
2046 * @param {?} actionCheck
2047 */
2048 function StoreFeatureModule(features, featureReducers, reducerManager, root, actionCheck) {
2049 this.features = features;
2050 this.featureReducers = featureReducers;
2051 this.reducerManager = reducerManager;
2052 /** @type {?} */
2053 var feats = features.map(( /**
2054 * @param {?} feature
2055 * @param {?} index
2056 * @return {?}
2057 */function (feature, index) {
2058 /** @type {?} */
2059 var featureReducerCollection = featureReducers.shift();
2060 /** @type {?} */
2061 var reducers = ( /** @type {?} */(featureReducerCollection /*TODO(#823)*/))[index];
2062 return Object.assign(Object.assign({}, feature), { reducers: reducers, initialState: _initialStateFactory(feature.initialState) });
2063 }));
2064 reducerManager.addFeatures(feats);
2065 }
2066 /**
2067 * @return {?}
2068 */
2069 StoreFeatureModule.prototype.ngOnDestroy = function () {
2070 this.reducerManager.removeFeatures(this.features);
2071 };
2072 return StoreFeatureModule;
2073 }());
2074 StoreFeatureModule.decorators = [
2075 { type: ngCore.NgModule, args: [{},] }
2076 ];
2077 /** @nocollapse */
2078 StoreFeatureModule.ctorParameters = function () { return [
2079 { type: Array, decorators: [{ type: ngCore.Inject, args: [_STORE_FEATURES,] }] },
2080 { type: Array, decorators: [{ type: ngCore.Inject, args: [FEATURE_REDUCERS,] }] },
2081 { type: ReducerManager },
2082 { type: StoreRootModule },
2083 { type: undefined, decorators: [{ type: ngCore.Optional }, { type: ngCore.Inject, args: [_ACTION_TYPE_UNIQUENESS_CHECK,] }] }
2084 ]; };
2085 if (false) {
2086 /**
2087 * @type {?}
2088 * @private
2089 */
2090 StoreFeatureModule.prototype.features;
2091 /**
2092 * @type {?}
2093 * @private
2094 */
2095 StoreFeatureModule.prototype.featureReducers;
2096 /**
2097 * @type {?}
2098 * @private
2099 */
2100 StoreFeatureModule.prototype.reducerManager;
2101 }
2102 /**
2103 * @record
2104 * @template T, V
2105 */
2106 function StoreConfig() { }
2107 if (false) {
2108 /** @type {?|undefined} */
2109 StoreConfig.prototype.initialState;
2110 /** @type {?|undefined} */
2111 StoreConfig.prototype.reducerFactory;
2112 /** @type {?|undefined} */
2113 StoreConfig.prototype.metaReducers;
2114 }
2115 /**
2116 * @record
2117 * @template T, V
2118 */
2119 function RootStoreConfig() { }
2120 if (false) {
2121 /** @type {?|undefined} */
2122 RootStoreConfig.prototype.runtimeChecks;
2123 }
2124 /**
2125 * An object with the name and the reducer for the feature.
2126 * @record
2127 * @template T, V
2128 */
2129 function FeatureSlice() { }
2130 if (false) {
2131 /** @type {?} */
2132 FeatureSlice.prototype.name;
2133 /** @type {?} */
2134 FeatureSlice.prototype.reducer;
2135 }
2136 var StoreModule = /** @class */ (function () {
2137 function StoreModule() {
2138 }
2139 /**
2140 * @param {?} reducers
2141 * @param {?=} config
2142 * @return {?}
2143 */
2144 StoreModule.forRoot = function (reducers, config) {
2145 if (config === void 0) { config = {}; }
2146 return {
2147 ngModule: StoreRootModule,
2148 providers: [
2149 {
2150 provide: _ROOT_STORE_GUARD,
2151 useFactory: _provideForRootGuard,
2152 deps: [[Store, new ngCore.Optional(), new ngCore.SkipSelf()]],
2153 },
2154 { provide: _INITIAL_STATE, useValue: config.initialState },
2155 {
2156 provide: INITIAL_STATE,
2157 useFactory: _initialStateFactory,
2158 deps: [_INITIAL_STATE],
2159 },
2160 { provide: _INITIAL_REDUCERS, useValue: reducers },
2161 {
2162 provide: _STORE_REDUCERS,
2163 useExisting: reducers instanceof ngCore.InjectionToken ? reducers : _INITIAL_REDUCERS,
2164 },
2165 {
2166 provide: INITIAL_REDUCERS,
2167 deps: [ngCore.Injector, _INITIAL_REDUCERS, [new ngCore.Inject(_STORE_REDUCERS)]],
2168 useFactory: _createStoreReducers,
2169 },
2170 {
2171 provide: USER_PROVIDED_META_REDUCERS,
2172 useValue: config.metaReducers ? config.metaReducers : [],
2173 },
2174 {
2175 provide: _RESOLVED_META_REDUCERS,
2176 deps: [META_REDUCERS, USER_PROVIDED_META_REDUCERS],
2177 useFactory: _concatMetaReducers,
2178 },
2179 {
2180 provide: _REDUCER_FACTORY,
2181 useValue: config.reducerFactory
2182 ? config.reducerFactory
2183 : combineReducers,
2184 },
2185 {
2186 provide: REDUCER_FACTORY,
2187 deps: [_REDUCER_FACTORY, _RESOLVED_META_REDUCERS],
2188 useFactory: createReducerFactory,
2189 },
2190 ACTIONS_SUBJECT_PROVIDERS,
2191 REDUCER_MANAGER_PROVIDERS,
2192 SCANNED_ACTIONS_SUBJECT_PROVIDERS,
2193 STATE_PROVIDERS,
2194 STORE_PROVIDERS,
2195 provideRuntimeChecks(config.runtimeChecks),
2196 checkForActionTypeUniqueness(),
2197 ],
2198 };
2199 };
2200 /**
2201 * @param {?} featureNameOrSlice
2202 * @param {?=} reducersOrConfig
2203 * @param {?=} config
2204 * @return {?}
2205 */
2206 StoreModule.forFeature = function (featureNameOrSlice, reducersOrConfig, config) {
2207 if (config === void 0) { config = {}; }
2208 return {
2209 ngModule: StoreFeatureModule,
2210 providers: [
2211 {
2212 provide: _FEATURE_CONFIGS,
2213 multi: true,
2214 useValue: typeof featureNameOrSlice === 'string' ? config : {},
2215 },
2216 {
2217 provide: STORE_FEATURES,
2218 multi: true,
2219 useValue: {
2220 key: typeof featureNameOrSlice === 'string'
2221 ? featureNameOrSlice
2222 : featureNameOrSlice.name,
2223 reducerFactory: !(config instanceof ngCore.InjectionToken) && config.reducerFactory
2224 ? config.reducerFactory
2225 : combineReducers,
2226 metaReducers: !(config instanceof ngCore.InjectionToken) && config.metaReducers
2227 ? config.metaReducers
2228 : [],
2229 initialState: !(config instanceof ngCore.InjectionToken) && config.initialState
2230 ? config.initialState
2231 : undefined,
2232 },
2233 },
2234 {
2235 provide: _STORE_FEATURES,
2236 deps: [ngCore.Injector, _FEATURE_CONFIGS, STORE_FEATURES],
2237 useFactory: _createFeatureStore,
2238 },
2239 {
2240 provide: _FEATURE_REDUCERS,
2241 multi: true,
2242 useValue: typeof featureNameOrSlice === 'string'
2243 ? reducersOrConfig
2244 : featureNameOrSlice.reducer,
2245 },
2246 {
2247 provide: _FEATURE_REDUCERS_TOKEN,
2248 multi: true,
2249 useExisting: reducersOrConfig instanceof ngCore.InjectionToken
2250 ? reducersOrConfig
2251 : _FEATURE_REDUCERS,
2252 },
2253 {
2254 provide: FEATURE_REDUCERS,
2255 multi: true,
2256 deps: [
2257 ngCore.Injector,
2258 _FEATURE_REDUCERS,
2259 [new ngCore.Inject(_FEATURE_REDUCERS_TOKEN)],
2260 ],
2261 useFactory: _createFeatureReducers,
2262 },
2263 checkForActionTypeUniqueness(),
2264 ],
2265 };
2266 };
2267 return StoreModule;
2268 }());
2269 StoreModule.decorators = [
2270 { type: ngCore.NgModule, args: [{},] }
2271 ];
2272 /**
2273 * @param {?} injector
2274 * @param {?} reducers
2275 * @return {?}
2276 */
2277 function _createStoreReducers(injector, reducers) {
2278 return reducers instanceof ngCore.InjectionToken ? injector.get(reducers) : reducers;
2279 }
2280 /**
2281 * @param {?} injector
2282 * @param {?} configs
2283 * @param {?} featureStores
2284 * @return {?}
2285 */
2286 function _createFeatureStore(injector, configs, featureStores) {
2287 return featureStores.map(( /**
2288 * @param {?} feat
2289 * @param {?} index
2290 * @return {?}
2291 */function (feat, index) {
2292 if (configs[index] instanceof ngCore.InjectionToken) {
2293 /** @type {?} */
2294 var conf = injector.get(configs[index]);
2295 return {
2296 key: feat.key,
2297 reducerFactory: conf.reducerFactory
2298 ? conf.reducerFactory
2299 : combineReducers,
2300 metaReducers: conf.metaReducers ? conf.metaReducers : [],
2301 initialState: conf.initialState,
2302 };
2303 }
2304 return feat;
2305 }));
2306 }
2307 /**
2308 * @param {?} injector
2309 * @param {?} reducerCollection
2310 * @return {?}
2311 */
2312 function _createFeatureReducers(injector, reducerCollection) {
2313 /** @type {?} */
2314 var reducers = reducerCollection.map(( /**
2315 * @param {?} reducer
2316 * @return {?}
2317 */function (reducer) {
2318 return reducer instanceof ngCore.InjectionToken ? injector.get(reducer) : reducer;
2319 }));
2320 return reducers;
2321 }
2322 /**
2323 * @param {?} initialState
2324 * @return {?}
2325 */
2326 function _initialStateFactory(initialState) {
2327 if (typeof initialState === 'function') {
2328 return initialState();
2329 }
2330 return initialState;
2331 }
2332 /**
2333 * @param {?} metaReducers
2334 * @param {?} userProvidedMetaReducers
2335 * @return {?}
2336 */
2337 function _concatMetaReducers(metaReducers, userProvidedMetaReducers) {
2338 return metaReducers.concat(userProvidedMetaReducers);
2339 }
2340 /**
2341 * @param {?} store
2342 * @return {?}
2343 */
2344 function _provideForRootGuard(store) {
2345 if (store) {
2346 throw new TypeError("StoreModule.forRoot() called twice. Feature modules should use StoreModule.forFeature() instead.");
2347 }
2348 return 'guarded';
2349 }
2350
2351 /**
2352 * @fileoverview added by tsickle
2353 * Generated from: src/reducer_creator.ts
2354 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2355 */
2356 /**
2357 * Return type of the `on` fn.
2358 * Contains the action reducer coupled to one or more action types.
2359 * @record
2360 * @template State, Creators
2361 */
2362 function ReducerTypes() { }
2363 if (false) {
2364 /** @type {?} */
2365 ReducerTypes.prototype.reducer;
2366 /** @type {?} */
2367 ReducerTypes.prototype.types;
2368 }
2369 /**
2370 * @record
2371 * @template State, Creators
2372 */
2373 function OnReducer() { }
2374 /**
2375 * \@description
2376 * Associates actions with a given state change function.
2377 * A state change function must be provided as the last parameter.
2378 *
2379 * \@usageNotes
2380 * ```ts
2381 * on(AuthApiActions.loginSuccess, (state, { user }) => ({ ...state, user }))
2382 * ```
2383 * @template State, Creators
2384 * @param {...?} args `ActionCreator`'s followed by a state change function.
2385 *
2386 * @return {?} an association of action types with a state change function.
2387 *
2388 */
2389 function on() {
2390 var args = [];
2391 for (var _i = 0; _i < arguments.length; _i++) {
2392 args[_i] = arguments[_i];
2393 }
2394 // This could be refactored when TS releases the version with this fix:
2395 // https://github.com/microsoft/TypeScript/pull/41544
2396 /** @type {?} */
2397 var reducer = ( /** @type {?} */(args.pop()));
2398 /** @type {?} */
2399 var types = ( /** @type {?} */((( /** @type {?} */((( /** @type {?} */((( /** @type {?} */(args)))))).map(( /**
2400 * @param {?} creator
2401 * @return {?}
2402 */function (creator) { return creator.type; })))))));
2403 return { reducer: reducer, types: types };
2404 }
2405 /**
2406 * \@description
2407 * Creates a reducer function to handle state transitions.
2408 *
2409 * Reducer creators reduce the explicitness of reducer functions with switch statements.
2410 *
2411 * \@usageNotes
2412 *
2413 * - Must be used with `ActionCreator`'s (returned by `createAction`). Cannot be used with class-based action creators.
2414 * - The returned `ActionReducer` should additionally be wrapped with another function, if you are using View Engine AOT.
2415 * In case you are using Ivy (or only JIT View Engine) the extra wrapper function is not required.
2416 *
2417 * **Declaring a reducer creator**
2418 *
2419 * ```ts
2420 * export const reducer = createReducer(
2421 * initialState,
2422 * on(
2423 * featureActions.actionOne,
2424 * featureActions.actionTwo,
2425 * (state, { updatedValue }) => ({ ...state, prop: updatedValue })
2426 * ),
2427 * on(featureActions.actionThree, () => initialState);
2428 * );
2429 * ```
2430 *
2431 * **Declaring a reducer creator using a wrapper function (Only needed if using View Engine AOT)**
2432 *
2433 * ```ts
2434 * const featureReducer = createReducer(
2435 * initialState,
2436 * on(
2437 * featureActions.actionOne,
2438 * featureActions.actionTwo,
2439 * (state, { updatedValue }) => ({ ...state, prop: updatedValue })
2440 * ),
2441 * on(featureActions.actionThree, () => initialState);
2442 * );
2443 *
2444 * export function reducer(state: State | undefined, action: Action) {
2445 * return featureReducer(state, action);
2446 * }
2447 * ```
2448 * @template S, A
2449 * @param {?} initialState Provides a state value if the current state is `undefined`, as it is initially.
2450 * @param {...?} ons Associations between actions and state changes.
2451 * @return {?} A reducer function.
2452 *
2453 */
2454 function createReducer(initialState) {
2455 var e_1, _a;
2456 var ons = [];
2457 for (var _i = 1; _i < arguments.length; _i++) {
2458 ons[_i - 1] = arguments[_i];
2459 }
2460 /** @type {?} */
2461 var map = new Map();
2462 var _loop_1 = function (on_1) {
2463 var e_2, _a;
2464 var _loop_2 = function (type) {
2465 /** @type {?} */
2466 var existingReducer = map.get(type);
2467 if (existingReducer) {
2468 /** @type {?} */
2469 var newReducer = ( /**
2470 * @param {?} state
2471 * @param {?} action
2472 * @return {?}
2473 */function (state, action) { return on_1.reducer(existingReducer(state, action), action); });
2474 map.set(type, newReducer);
2475 }
2476 else {
2477 map.set(type, on_1.reducer);
2478 }
2479 };
2480 try {
2481 for (var _b = (e_2 = void 0, __values(on_1.types)), _c = _b.next(); !_c.done; _c = _b.next()) {
2482 var type = _c.value;
2483 _loop_2(type);
2484 }
2485 }
2486 catch (e_2_1) { e_2 = { error: e_2_1 }; }
2487 finally {
2488 try {
2489 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2490 }
2491 finally { if (e_2) throw e_2.error; }
2492 }
2493 };
2494 try {
2495 for (var ons_1 = __values(ons), ons_1_1 = ons_1.next(); !ons_1_1.done; ons_1_1 = ons_1.next()) {
2496 var on_1 = ons_1_1.value;
2497 _loop_1(on_1);
2498 }
2499 }
2500 catch (e_1_1) { e_1 = { error: e_1_1 }; }
2501 finally {
2502 try {
2503 if (ons_1_1 && !ons_1_1.done && (_a = ons_1.return)) _a.call(ons_1);
2504 }
2505 finally { if (e_1) throw e_1.error; }
2506 }
2507 return ( /**
2508 * @param {?=} state
2509 * @param {?=} action
2510 * @return {?}
2511 */function (state, action) {
2512 if (state === void 0) { state = initialState; }
2513 /** @type {?} */
2514 var reducer = map.get(action.type);
2515 return reducer ? reducer(state, action) : state;
2516 });
2517 }
2518
2519 /**
2520 * @fileoverview added by tsickle
2521 * Generated from: src/index.ts
2522 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2523 */
2524
2525 /**
2526 * @fileoverview added by tsickle
2527 * Generated from: public_api.ts
2528 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2529 */
2530
2531 /**
2532 * @fileoverview added by tsickle
2533 * Generated from: index.ts
2534 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2535 */
2536
2537 /**
2538 * @fileoverview added by tsickle
2539 * Generated from: ngrx-store.ts
2540 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2541 */
2542
2543 exports.ActionsSubject = ActionsSubject;
2544 exports.FEATURE_REDUCERS = FEATURE_REDUCERS;
2545 exports.INIT = INIT;
2546 exports.INITIAL_REDUCERS = INITIAL_REDUCERS;
2547 exports.INITIAL_STATE = INITIAL_STATE;
2548 exports.META_REDUCERS = META_REDUCERS;
2549 exports.REDUCER_FACTORY = REDUCER_FACTORY;
2550 exports.ReducerManager = ReducerManager;
2551 exports.ReducerManagerDispatcher = ReducerManagerDispatcher;
2552 exports.ReducerObservable = ReducerObservable;
2553 exports.STORE_FEATURES = STORE_FEATURES;
2554 exports.ScannedActionsSubject = ScannedActionsSubject;
2555 exports.State = State;
2556 exports.StateObservable = StateObservable;
2557 exports.Store = Store;
2558 exports.StoreFeatureModule = StoreFeatureModule;
2559 exports.StoreModule = StoreModule;
2560 exports.StoreRootModule = StoreRootModule;
2561 exports.UPDATE = UPDATE;
2562 exports.USER_PROVIDED_META_REDUCERS = USER_PROVIDED_META_REDUCERS;
2563 exports.USER_RUNTIME_CHECKS = USER_RUNTIME_CHECKS;
2564 exports.combineReducers = combineReducers;
2565 exports.compose = compose;
2566 exports.createAction = createAction;
2567 exports.createFeatureSelector = createFeatureSelector;
2568 exports.createReducer = createReducer;
2569 exports.createReducerFactory = createReducerFactory;
2570 exports.createSelector = createSelector;
2571 exports.createSelectorFactory = createSelectorFactory;
2572 exports.defaultMemoize = defaultMemoize;
2573 exports.defaultStateFn = defaultStateFn;
2574 exports.isNgrxMockEnvironment = isNgrxMockEnvironment;
2575 exports.on = on;
2576 exports.props = props;
2577 exports.reduceState = reduceState;
2578 exports.resultMemoize = resultMemoize;
2579 exports.select = select;
2580 exports.setNgrxMockEnvironment = setNgrxMockEnvironment;
2581 exports.union = union;
2582 exports.ɵb = STORE_PROVIDERS;
2583 exports.ɵba = createActiveRuntimeChecks;
2584 exports.ɵbb = createSerializationCheckMetaReducer;
2585 exports.ɵbc = createImmutabilityCheckMetaReducer;
2586 exports.ɵbd = createInNgZoneCheckMetaReducer;
2587 exports.ɵbe = provideRuntimeChecks;
2588 exports.ɵbf = checkForActionTypeUniqueness;
2589 exports.ɵbg = _runtimeChecksFactory;
2590 exports.ɵbh = _actionTypeUniquenessCheck;
2591 exports.ɵc = ACTIONS_SUBJECT_PROVIDERS;
2592 exports.ɵd = REDUCER_MANAGER_PROVIDERS;
2593 exports.ɵe = SCANNED_ACTIONS_SUBJECT_PROVIDERS;
2594 exports.ɵf = isEqualCheck;
2595 exports.ɵg = STATE_PROVIDERS;
2596 exports.ɵh = _ROOT_STORE_GUARD;
2597 exports.ɵi = _INITIAL_STATE;
2598 exports.ɵj = _REDUCER_FACTORY;
2599 exports.ɵk = _INITIAL_REDUCERS;
2600 exports.ɵl = _STORE_REDUCERS;
2601 exports.ɵm = _FEATURE_REDUCERS;
2602 exports.ɵn = _FEATURE_CONFIGS;
2603 exports.ɵo = _STORE_FEATURES;
2604 exports.ɵp = _FEATURE_REDUCERS_TOKEN;
2605 exports.ɵq = _RESOLVED_META_REDUCERS;
2606 exports.ɵr = _USER_RUNTIME_CHECKS;
2607 exports.ɵs = _ACTIVE_RUNTIME_CHECKS;
2608 exports.ɵt = _ACTION_TYPE_UNIQUENESS_CHECK;
2609 exports.ɵu = _createStoreReducers;
2610 exports.ɵv = _createFeatureStore;
2611 exports.ɵw = _createFeatureReducers;
2612 exports.ɵx = _initialStateFactory;
2613 exports.ɵy = _concatMetaReducers;
2614 exports.ɵz = _provideForRootGuard;
2615
2616 Object.defineProperty(exports, '__esModule', { value: true });
2617
2618})));
2619//# sourceMappingURL=ngrx-store.umd.js.map