@ngxs/store 3.8.2-dev.master-0fd1fe5 → 3.8.2

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 (273) hide show
  1. package/bundles/ngxs-store-internals-testing.umd.js +684 -0
  2. package/bundles/ngxs-store-internals-testing.umd.js.map +1 -0
  3. package/bundles/ngxs-store-internals.umd.js +141 -0
  4. package/bundles/ngxs-store-internals.umd.js.map +1 -0
  5. package/bundles/ngxs-store-operators.umd.js +224 -0
  6. package/bundles/ngxs-store-operators.umd.js.map +1 -0
  7. package/bundles/ngxs-store.umd.js +3076 -0
  8. package/bundles/ngxs-store.umd.js.map +1 -0
  9. package/esm2015/internals/index.js +5 -0
  10. package/esm2015/internals/initial-state.js +17 -0
  11. package/esm2015/internals/internal-tokens.js +5 -0
  12. package/{esm2020/internals/ngxs-bootstrapper.mjs → esm2015/internals/ngxs-bootstrapper.js} +4 -4
  13. package/esm2015/internals/src/symbols.js +2 -0
  14. package/esm2015/internals/symbols.js +2 -0
  15. package/esm2015/internals/testing/fresh-platform.js +70 -0
  16. package/{esm2020/internals/testing/helpers/ngxs-test.component.mjs → esm2015/internals/testing/helpers/ngxs-test.component.js} +4 -4
  17. package/esm2015/internals/testing/helpers/ngxs-test.module.js +21 -0
  18. package/{esm2020/internals/testing/ngxs.setup.mjs → esm2015/internals/testing/ngxs.setup.js} +2 -4
  19. package/esm2015/internals/testing/symbol.js +2 -0
  20. package/esm2015/operators/patch.js +21 -0
  21. package/{esm2020/src/actions-stream.mjs → esm2015/src/actions-stream.js} +7 -7
  22. package/esm2015/src/configs/messages.config.js +36 -0
  23. package/{esm2020/src/decorators/select/select-factory.mjs → esm2015/src/decorators/select/select-factory.js} +4 -4
  24. package/esm2015/src/decorators/selector/selector.js +32 -0
  25. package/esm2015/src/decorators/state.js +36 -0
  26. package/{esm2020/src/dev-features/ngxs-development.module.mjs → esm2015/src/dev-features/ngxs-development.module.js} +5 -5
  27. package/{esm2020/src/dev-features/ngxs-unhandled-actions-logger.mjs → esm2015/src/dev-features/ngxs-unhandled-actions-logger.js} +4 -4
  28. package/{esm2020/src/execution/dispatch-outside-zone-ngxs-execution-strategy.mjs → esm2015/src/execution/dispatch-outside-zone-ngxs-execution-strategy.js} +4 -4
  29. package/{esm2020/src/execution/internal-ngxs-execution-strategy.mjs → esm2015/src/execution/internal-ngxs-execution-strategy.js} +4 -4
  30. package/{esm2020/src/execution/noop-ngxs-execution-strategy.mjs → esm2015/src/execution/noop-ngxs-execution-strategy.js} +4 -4
  31. package/esm2015/src/execution/symbols.js +23 -0
  32. package/{esm2020/src/internal/dispatcher.mjs → esm2015/src/internal/dispatcher.js} +11 -11
  33. package/{esm2020/src/internal/error-handler.mjs → esm2015/src/internal/error-handler.js} +5 -5
  34. package/esm2015/src/internal/internals.js +248 -0
  35. package/esm2015/src/internal/lifecycle-state-manager.js +79 -0
  36. package/{esm2020/src/internal/state-context-factory.mjs → esm2015/src/internal/state-context-factory.js} +4 -4
  37. package/esm2015/src/internal/state-factory.js +288 -0
  38. package/{esm2020/src/internal/state-operations.mjs → esm2015/src/internal/state-operations.js} +5 -5
  39. package/esm2015/src/internal/state-operators.js +20 -0
  40. package/esm2015/src/internal/state-stream.js +25 -0
  41. package/{esm2020/src/ivy/ivy-enabled-in-dev-mode.mjs → esm2015/src/ivy/ivy-enabled-in-dev-mode.js} +2 -2
  42. package/esm2015/src/module.js +88 -0
  43. package/esm2015/src/modules/ngxs-feature.module.js +45 -0
  44. package/esm2015/src/modules/ngxs-root.module.js +41 -0
  45. package/{esm2020/src/operators/of-action.mjs → esm2015/src/operators/of-action.js} +10 -10
  46. package/{esm2020/src/plugin-manager.mjs → esm2015/src/plugin-manager.js} +4 -4
  47. package/esm2015/src/public_api.js +27 -0
  48. package/esm2015/src/selectors/create-property-selectors.js +20 -0
  49. package/esm2015/src/selectors/selector-metadata.js +30 -0
  50. package/esm2015/src/selectors/selector-types.util.js +2 -0
  51. package/{esm2020/src/store.mjs → esm2015/src/store.js} +5 -6
  52. package/esm2015/src/symbols.js +58 -0
  53. package/esm2015/src/utils/utils.js +92 -0
  54. package/fesm2015/{ngxs-store-internals-testing.mjs → ngxs-store-internals-testing.js} +13 -19
  55. package/fesm2015/ngxs-store-internals-testing.js.map +1 -0
  56. package/{fesm2020/ngxs-store-internals.mjs → fesm2015/ngxs-store-internals.js} +8 -21
  57. package/fesm2015/ngxs-store-internals.js.map +1 -0
  58. package/fesm2015/{ngxs-store-operators.mjs → ngxs-store-operators.js} +1 -1
  59. package/fesm2015/ngxs-store-operators.js.map +1 -0
  60. package/{fesm2020/ngxs-store.mjs → fesm2015/ngxs-store.js} +1029 -1192
  61. package/fesm2015/ngxs-store.js.map +1 -0
  62. package/internals/index.d.ts +1 -1
  63. package/internals/initial-state.d.ts +1 -1
  64. package/internals/ngxs-store-internals.d.ts +5 -0
  65. package/internals/package.json +10 -0
  66. package/internals/src/symbols.d.ts +1 -4
  67. package/internals/symbols.d.ts +1 -4
  68. package/internals/testing/helpers/ngxs-test.component.d.ts +1 -1
  69. package/internals/testing/ngxs-store-internals-testing.d.ts +5 -0
  70. package/internals/testing/package.json +10 -0
  71. package/internals/testing/symbol.d.ts +2 -2
  72. package/ngxs-store.d.ts +5 -0
  73. package/operators/ngxs-store-operators.d.ts +5 -0
  74. package/operators/package.json +10 -0
  75. package/package.json +11 -48
  76. package/src/configs/messages.config.d.ts +0 -2
  77. package/src/decorators/state.d.ts +2 -2
  78. package/src/execution/symbols.d.ts +2 -8
  79. package/src/internal/internals.d.ts +5 -5
  80. package/src/internal/lifecycle-state-manager.d.ts +1 -3
  81. package/src/module.d.ts +14 -3
  82. package/src/modules/ngxs-feature.module.d.ts +9 -2
  83. package/src/modules/ngxs-root.module.d.ts +9 -2
  84. package/src/public_api.d.ts +4 -5
  85. package/src/selectors/selector-types.util.d.ts +3 -3
  86. package/src/symbols.d.ts +8 -5
  87. package/esm2020/internals/index.mjs +0 -6
  88. package/esm2020/internals/initial-state.mjs +0 -18
  89. package/esm2020/internals/internal-tokens.mjs +0 -6
  90. package/esm2020/internals/src/symbols.mjs +0 -11
  91. package/esm2020/internals/symbols.mjs +0 -11
  92. package/esm2020/internals/testing/fresh-platform.mjs +0 -72
  93. package/esm2020/internals/testing/helpers/ngxs-test.module.mjs +0 -20
  94. package/esm2020/internals/testing/symbol.mjs +0 -2
  95. package/esm2020/operators/patch.mjs +0 -21
  96. package/esm2020/src/configs/messages.config.mjs +0 -48
  97. package/esm2020/src/decorators/selector/selector.mjs +0 -32
  98. package/esm2020/src/decorators/state.mjs +0 -36
  99. package/esm2020/src/execution/symbols.mjs +0 -27
  100. package/esm2020/src/internal/internals.mjs +0 -248
  101. package/esm2020/src/internal/lifecycle-state-manager.mjs +0 -97
  102. package/esm2020/src/internal/state-factory.mjs +0 -292
  103. package/esm2020/src/internal/state-operators.mjs +0 -20
  104. package/esm2020/src/internal/state-stream.mjs +0 -27
  105. package/esm2020/src/module.mjs +0 -27
  106. package/esm2020/src/modules/ngxs-feature.module.mjs +0 -18
  107. package/esm2020/src/modules/ngxs-root.module.mjs +0 -18
  108. package/esm2020/src/public_api.mjs +0 -28
  109. package/esm2020/src/selectors/create-property-selectors.mjs +0 -20
  110. package/esm2020/src/selectors/selector-metadata.mjs +0 -35
  111. package/esm2020/src/selectors/selector-types.util.mjs +0 -2
  112. package/esm2020/src/standalone-features/feature-providers.mjs +0 -20
  113. package/esm2020/src/standalone-features/index.mjs +0 -4
  114. package/esm2020/src/standalone-features/initializers.mjs +0 -86
  115. package/esm2020/src/standalone-features/plugin.mjs +0 -20
  116. package/esm2020/src/standalone-features/provide-states.mjs +0 -26
  117. package/esm2020/src/standalone-features/provide-store.mjs +0 -26
  118. package/esm2020/src/standalone-features/root-providers.mjs +0 -47
  119. package/esm2020/src/symbols.mjs +0 -65
  120. package/esm2020/src/utils/utils.mjs +0 -92
  121. package/fesm2015/ngxs-store-internals-testing.mjs.map +0 -1
  122. package/fesm2015/ngxs-store-internals.mjs +0 -114
  123. package/fesm2015/ngxs-store-internals.mjs.map +0 -1
  124. package/fesm2015/ngxs-store-operators.mjs.map +0 -1
  125. package/fesm2015/ngxs-store.mjs +0 -2454
  126. package/fesm2015/ngxs-store.mjs.map +0 -1
  127. package/fesm2020/ngxs-store-internals-testing.mjs +0 -180
  128. package/fesm2020/ngxs-store-internals-testing.mjs.map +0 -1
  129. package/fesm2020/ngxs-store-internals.mjs.map +0 -1
  130. package/fesm2020/ngxs-store-operators.mjs +0 -202
  131. package/fesm2020/ngxs-store-operators.mjs.map +0 -1
  132. package/fesm2020/ngxs-store.mjs.map +0 -1
  133. package/schematics/collection.json +0 -36
  134. package/schematics/src/actions/actions.factory.d.ts +0 -3
  135. package/schematics/src/actions/actions.factory.js +0 -22
  136. package/schematics/src/actions/actions.factory.js.map +0 -1
  137. package/schematics/src/actions/files/__name__.actions.ts__template__ +0 -4
  138. package/schematics/src/actions/schema.json +0 -28
  139. package/schematics/src/ng-add/add-declaration.d.ts +0 -4
  140. package/schematics/src/ng-add/add-declaration.js +0 -109
  141. package/schematics/src/ng-add/add-declaration.js.map +0 -1
  142. package/schematics/src/ng-add/ng-add.factory.d.ts +0 -9
  143. package/schematics/src/ng-add/ng-add.factory.js +0 -86
  144. package/schematics/src/ng-add/ng-add.factory.js.map +0 -1
  145. package/schematics/src/ng-add/schema.json +0 -72
  146. package/schematics/src/starter-kit/files/store/auth/auth.actions.ts__template__ +0 -7
  147. package/schematics/src/starter-kit/files/store/auth/auth.state.spec.ts__template__ +0 -46
  148. package/schematics/src/starter-kit/files/store/auth/auth.state.ts__template__ +0 -45
  149. package/schematics/src/starter-kit/files/store/dashboard/index.ts__template__ +0 -11
  150. package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.actions.ts__template__ +0 -13
  151. package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.spec.ts__template__ +0 -77
  152. package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.ts__template__ +0 -60
  153. package/schematics/src/starter-kit/files/store/dashboard/states/user/user.actions.ts__template__ +0 -6
  154. package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.spec.ts__template__ +0 -54
  155. package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.ts__template__ +0 -40
  156. package/schematics/src/starter-kit/files/store/store.config.ts__template__ +0 -38
  157. package/schematics/src/starter-kit/files/store/store.module.ts__template__ +0 -22
  158. package/schematics/src/starter-kit/schema.json +0 -18
  159. package/schematics/src/starter-kit/starter-kit.factory.d.ts +0 -3
  160. package/schematics/src/starter-kit/starter-kit.factory.js +0 -12
  161. package/schematics/src/starter-kit/starter-kit.factory.js.map +0 -1
  162. package/schematics/src/state/files/__name__.state.spec.ts__template__ +0 -22
  163. package/schematics/src/state/files/__name__.state.ts__template__ +0 -20
  164. package/schematics/src/state/schema.json +0 -33
  165. package/schematics/src/state/state.factory.d.ts +0 -3
  166. package/schematics/src/state/state.factory.js +0 -20
  167. package/schematics/src/state/state.factory.js.map +0 -1
  168. package/schematics/src/store/files/__name__.actions.ts__template__ +0 -4
  169. package/schematics/src/store/files/__name__.state.spec.ts__template__ +0 -24
  170. package/schematics/src/store/files/__name__.state.ts__template__ +0 -27
  171. package/schematics/src/store/schema.json +0 -33
  172. package/schematics/src/store/store.factory.d.ts +0 -3
  173. package/schematics/src/store/store.factory.js +0 -20
  174. package/schematics/src/store/store.factory.js.map +0 -1
  175. package/schematics/src/utils/common/lib.config.d.ts +0 -10
  176. package/schematics/src/utils/common/lib.config.js +0 -15
  177. package/schematics/src/utils/common/lib.config.js.map +0 -1
  178. package/schematics/src/utils/common/project-files.config.d.ts +0 -3
  179. package/schematics/src/utils/common/project-files.config.js +0 -7
  180. package/schematics/src/utils/common/project-files.config.js.map +0 -1
  181. package/schematics/src/utils/common/properties.d.ts +0 -1
  182. package/schematics/src/utils/common/properties.js +0 -8
  183. package/schematics/src/utils/common/properties.js.map +0 -1
  184. package/schematics/src/utils/config.d.ts +0 -119
  185. package/schematics/src/utils/config.js +0 -21
  186. package/schematics/src/utils/config.js.map +0 -1
  187. package/schematics/src/utils/generate-utils.d.ts +0 -4
  188. package/schematics/src/utils/generate-utils.js +0 -14
  189. package/schematics/src/utils/generate-utils.js.map +0 -1
  190. package/schematics/src/utils/interfaces/package.interface.d.ts +0 -7
  191. package/schematics/src/utils/interfaces/package.interface.js +0 -3
  192. package/schematics/src/utils/interfaces/package.interface.js.map +0 -1
  193. package/schematics/src/utils/ng-utils/README.md +0 -1
  194. package/schematics/src/utils/ng-utils/ast-utils.d.ts +0 -99
  195. package/schematics/src/utils/ng-utils/ast-utils.js +0 -517
  196. package/schematics/src/utils/ng-utils/ast-utils.js.map +0 -1
  197. package/schematics/src/utils/ng-utils/ng-ast-utils.d.ts +0 -5
  198. package/schematics/src/utils/ng-utils/ng-ast-utils.js +0 -67
  199. package/schematics/src/utils/ng-utils/ng-ast-utils.js.map +0 -1
  200. package/schematics/src/utils/ng-utils/project.d.ts +0 -2
  201. package/schematics/src/utils/ng-utils/project.js +0 -21
  202. package/schematics/src/utils/ng-utils/project.js.map +0 -1
  203. package/schematics/src/utils/ng-utils/standalone/app_config.d.ts +0 -16
  204. package/schematics/src/utils/ng-utils/standalone/app_config.js +0 -84
  205. package/schematics/src/utils/ng-utils/standalone/app_config.js.map +0 -1
  206. package/schematics/src/utils/ng-utils/standalone/code_block.d.ts +0 -46
  207. package/schematics/src/utils/ng-utils/standalone/code_block.js +0 -73
  208. package/schematics/src/utils/ng-utils/standalone/code_block.js.map +0 -1
  209. package/schematics/src/utils/ng-utils/standalone/index.d.ts +0 -1
  210. package/schematics/src/utils/ng-utils/standalone/index.js +0 -7
  211. package/schematics/src/utils/ng-utils/standalone/index.js.map +0 -1
  212. package/schematics/src/utils/ng-utils/standalone/rules.d.ts +0 -38
  213. package/schematics/src/utils/ng-utils/standalone/rules.js +0 -195
  214. package/schematics/src/utils/ng-utils/standalone/rules.js.map +0 -1
  215. package/schematics/src/utils/ng-utils/standalone/util.d.ts +0 -28
  216. package/schematics/src/utils/ng-utils/standalone/util.js +0 -138
  217. package/schematics/src/utils/ng-utils/standalone/util.js.map +0 -1
  218. package/schematics/src/utils/normalize-options.d.ts +0 -9
  219. package/schematics/src/utils/normalize-options.js +0 -24
  220. package/schematics/src/utils/normalize-options.js.map +0 -1
  221. package/schematics/src/utils/project.d.ts +0 -16
  222. package/schematics/src/utils/project.js +0 -40
  223. package/schematics/src/utils/project.js.map +0 -1
  224. package/schematics/src/utils/versions.json +0 -3
  225. package/src/standalone-features/feature-providers.d.ts +0 -7
  226. package/src/standalone-features/index.d.ts +0 -3
  227. package/src/standalone-features/initializers.d.ts +0 -29
  228. package/src/standalone-features/plugin.d.ts +0 -17
  229. package/src/standalone-features/provide-states.d.ts +0 -18
  230. package/src/standalone-features/provide-store.d.ts +0 -22
  231. package/src/standalone-features/root-providers.d.ts +0 -8
  232. /package/{esm2020/index.mjs → esm2015/index.js} +0 -0
  233. /package/{esm2020/internals/memoize.mjs → esm2015/internals/memoize.js} +0 -0
  234. /package/{esm2020/internals/ngxs-store-internals.mjs → esm2015/internals/ngxs-store-internals.js} +0 -0
  235. /package/{esm2020/internals/testing/index.mjs → esm2015/internals/testing/index.js} +0 -0
  236. /package/{esm2020/internals/testing/ngxs-store-internals-testing.mjs → esm2015/internals/testing/ngxs-store-internals-testing.js} +0 -0
  237. /package/{esm2020/internals/testing/skip-console-logging.mjs → esm2015/internals/testing/skip-console-logging.js} +0 -0
  238. /package/{esm2020/ngxs-store.mjs → esm2015/ngxs-store.js} +0 -0
  239. /package/{esm2020/operators/append.mjs → esm2015/operators/append.js} +0 -0
  240. /package/{esm2020/operators/compose.mjs → esm2015/operators/compose.js} +0 -0
  241. /package/{esm2020/operators/iif.mjs → esm2015/operators/iif.js} +0 -0
  242. /package/{esm2020/operators/index.mjs → esm2015/operators/index.js} +0 -0
  243. /package/{esm2020/operators/insert-item.mjs → esm2015/operators/insert-item.js} +0 -0
  244. /package/{esm2020/operators/ngxs-store-operators.mjs → esm2015/operators/ngxs-store-operators.js} +0 -0
  245. /package/{esm2020/operators/remove-item.mjs → esm2015/operators/remove-item.js} +0 -0
  246. /package/{esm2020/operators/types.mjs → esm2015/operators/types.js} +0 -0
  247. /package/{esm2020/operators/update-item.mjs → esm2015/operators/update-item.js} +0 -0
  248. /package/{esm2020/operators/utils.mjs → esm2015/operators/utils.js} +0 -0
  249. /package/{esm2020/src/actions/actions.mjs → esm2015/src/actions/actions.js} +0 -0
  250. /package/{esm2020/src/actions/symbols.mjs → esm2015/src/actions/symbols.js} +0 -0
  251. /package/{esm2020/src/decorators/action.mjs → esm2015/src/decorators/action.js} +0 -0
  252. /package/{esm2020/src/decorators/select/select.mjs → esm2015/src/decorators/select/select.js} +0 -0
  253. /package/{esm2020/src/decorators/select/symbols.mjs → esm2015/src/decorators/select/symbols.js} +0 -0
  254. /package/{esm2020/src/decorators/selector/symbols.mjs → esm2015/src/decorators/selector/symbols.js} +0 -0
  255. /package/{esm2020/src/decorators/selector-options.mjs → esm2015/src/decorators/selector-options.js} +0 -0
  256. /package/{esm2020/src/dev-features/symbols.mjs → esm2015/src/dev-features/symbols.js} +0 -0
  257. /package/{esm2020/src/internal/custom-rxjs-subjects.mjs → esm2015/src/internal/custom-rxjs-subjects.js} +0 -0
  258. /package/{esm2020/src/operators/leave-ngxs.mjs → esm2015/src/operators/leave-ngxs.js} +0 -0
  259. /package/{esm2020/src/plugin_api.mjs → esm2015/src/plugin_api.js} +0 -0
  260. /package/{esm2020/src/private_api.mjs → esm2015/src/private_api.js} +0 -0
  261. /package/{esm2020/src/public_to_deprecate.mjs → esm2015/src/public_to_deprecate.js} +0 -0
  262. /package/{esm2020/src/selectors/create-model-selector.mjs → esm2015/src/selectors/create-model-selector.js} +0 -0
  263. /package/{esm2020/src/selectors/create-pick-selector.mjs → esm2015/src/selectors/create-pick-selector.js} +0 -0
  264. /package/{esm2020/src/selectors/create-selector.mjs → esm2015/src/selectors/create-selector.js} +0 -0
  265. /package/{esm2020/src/selectors/index.mjs → esm2015/src/selectors/index.js} +0 -0
  266. /package/{esm2020/src/selectors/selector-checks.util.mjs → esm2015/src/selectors/selector-checks.util.js} +0 -0
  267. /package/{esm2020/src/selectors/selector-models.mjs → esm2015/src/selectors/selector-models.js} +0 -0
  268. /package/{esm2020/src/selectors/selector-utils.mjs → esm2015/src/selectors/selector-utils.js} +0 -0
  269. /package/{esm2020/src/state-token/state-token.mjs → esm2015/src/state-token/state-token.js} +0 -0
  270. /package/{esm2020/src/state-token/symbols.mjs → esm2015/src/state-token/symbols.js} +0 -0
  271. /package/{esm2020/src/utils/compose.mjs → esm2015/src/utils/compose.js} +0 -0
  272. /package/{esm2020/src/utils/freeze.mjs → esm2015/src/utils/freeze.js} +0 -0
  273. /package/{esm2020/src/utils/store-validators.mjs → esm2015/src/utils/store-validators.js} +0 -0
@@ -0,0 +1,3076 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store/internals'), require('@angular/common'), require('rxjs'), require('rxjs/operators'), require('@ngxs/store/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@ngxs/store', ['exports', '@angular/core', '@ngxs/store/internals', '@angular/common', 'rxjs', 'rxjs/operators', '@ngxs/store/operators'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs.store = {}), global.ng.core, global.ngxs.store.internals, global.ng.common, global.rxjs, global.rxjs.operators, global.ngxs.store.operators));
5
+ })(this, (function (exports, i0, i5, common, rxjs, operators, operators$1) { 'use strict';
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
+ var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
27
+
28
+ /******************************************************************************
29
+ Copyright (c) Microsoft Corporation.
30
+
31
+ Permission to use, copy, modify, and/or distribute this software for any
32
+ purpose with or without fee is hereby granted.
33
+
34
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
35
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
37
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
38
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40
+ PERFORMANCE OF THIS SOFTWARE.
41
+ ***************************************************************************** */
42
+ /* global Reflect, Promise, SuppressedError, Symbol */
43
+ var extendStatics = function (d, b) {
44
+ extendStatics = Object.setPrototypeOf ||
45
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
46
+ function (d, b) { for (var p in b)
47
+ if (Object.prototype.hasOwnProperty.call(b, p))
48
+ d[p] = b[p]; };
49
+ return extendStatics(d, b);
50
+ };
51
+ function __extends(d, b) {
52
+ if (typeof b !== "function" && b !== null)
53
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
54
+ extendStatics(d, b);
55
+ function __() { this.constructor = d; }
56
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
57
+ }
58
+ var __assign = function () {
59
+ __assign = Object.assign || function __assign(t) {
60
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
61
+ s = arguments[i];
62
+ for (var p in s)
63
+ if (Object.prototype.hasOwnProperty.call(s, p))
64
+ t[p] = s[p];
65
+ }
66
+ return t;
67
+ };
68
+ return __assign.apply(this, arguments);
69
+ };
70
+ function __rest(s, e) {
71
+ var t = {};
72
+ for (var p in s)
73
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
74
+ t[p] = s[p];
75
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
76
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
77
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
78
+ t[p[i]] = s[p[i]];
79
+ }
80
+ return t;
81
+ }
82
+ function __decorate(decorators, target, key, desc) {
83
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
84
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
85
+ r = Reflect.decorate(decorators, target, key, desc);
86
+ else
87
+ for (var i = decorators.length - 1; i >= 0; i--)
88
+ if (d = decorators[i])
89
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
90
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
91
+ }
92
+ function __param(paramIndex, decorator) {
93
+ return function (target, key) { decorator(target, key, paramIndex); };
94
+ }
95
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
96
+ function accept(f) { if (f !== void 0 && typeof f !== "function")
97
+ throw new TypeError("Function expected"); return f; }
98
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
99
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
100
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
101
+ var _, done = false;
102
+ for (var i = decorators.length - 1; i >= 0; i--) {
103
+ var context = {};
104
+ for (var p in contextIn)
105
+ context[p] = p === "access" ? {} : contextIn[p];
106
+ for (var p in contextIn.access)
107
+ context.access[p] = contextIn.access[p];
108
+ context.addInitializer = function (f) { if (done)
109
+ throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
110
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
111
+ if (kind === "accessor") {
112
+ if (result === void 0)
113
+ continue;
114
+ if (result === null || typeof result !== "object")
115
+ throw new TypeError("Object expected");
116
+ if (_ = accept(result.get))
117
+ descriptor.get = _;
118
+ if (_ = accept(result.set))
119
+ descriptor.set = _;
120
+ if (_ = accept(result.init))
121
+ initializers.unshift(_);
122
+ }
123
+ else if (_ = accept(result)) {
124
+ if (kind === "field")
125
+ initializers.unshift(_);
126
+ else
127
+ descriptor[key] = _;
128
+ }
129
+ }
130
+ if (target)
131
+ Object.defineProperty(target, contextIn.name, descriptor);
132
+ done = true;
133
+ }
134
+ ;
135
+ function __runInitializers(thisArg, initializers, value) {
136
+ var useValue = arguments.length > 2;
137
+ for (var i = 0; i < initializers.length; i++) {
138
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
139
+ }
140
+ return useValue ? value : void 0;
141
+ }
142
+ ;
143
+ function __propKey(x) {
144
+ return typeof x === "symbol" ? x : "".concat(x);
145
+ }
146
+ ;
147
+ function __setFunctionName(f, name, prefix) {
148
+ if (typeof name === "symbol")
149
+ name = name.description ? "[".concat(name.description, "]") : "";
150
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
151
+ }
152
+ ;
153
+ function __metadata(metadataKey, metadataValue) {
154
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
155
+ return Reflect.metadata(metadataKey, metadataValue);
156
+ }
157
+ function __awaiter(thisArg, _arguments, P, generator) {
158
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
159
+ return new (P || (P = Promise))(function (resolve, reject) {
160
+ function fulfilled(value) { try {
161
+ step(generator.next(value));
162
+ }
163
+ catch (e) {
164
+ reject(e);
165
+ } }
166
+ function rejected(value) { try {
167
+ step(generator["throw"](value));
168
+ }
169
+ catch (e) {
170
+ reject(e);
171
+ } }
172
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
173
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
174
+ });
175
+ }
176
+ function __generator(thisArg, body) {
177
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
178
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
179
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
180
+ function verb(n) { return function (v) { return step([n, v]); }; }
181
+ function step(op) {
182
+ if (f)
183
+ throw new TypeError("Generator is already executing.");
184
+ while (g && (g = 0, op[0] && (_ = 0)), _)
185
+ try {
186
+ 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)
187
+ return t;
188
+ if (y = 0, t)
189
+ op = [op[0] & 2, t.value];
190
+ switch (op[0]) {
191
+ case 0:
192
+ case 1:
193
+ t = op;
194
+ break;
195
+ case 4:
196
+ _.label++;
197
+ return { value: op[1], done: false };
198
+ case 5:
199
+ _.label++;
200
+ y = op[1];
201
+ op = [0];
202
+ continue;
203
+ case 7:
204
+ op = _.ops.pop();
205
+ _.trys.pop();
206
+ continue;
207
+ default:
208
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
209
+ _ = 0;
210
+ continue;
211
+ }
212
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
213
+ _.label = op[1];
214
+ break;
215
+ }
216
+ if (op[0] === 6 && _.label < t[1]) {
217
+ _.label = t[1];
218
+ t = op;
219
+ break;
220
+ }
221
+ if (t && _.label < t[2]) {
222
+ _.label = t[2];
223
+ _.ops.push(op);
224
+ break;
225
+ }
226
+ if (t[2])
227
+ _.ops.pop();
228
+ _.trys.pop();
229
+ continue;
230
+ }
231
+ op = body.call(thisArg, _);
232
+ }
233
+ catch (e) {
234
+ op = [6, e];
235
+ y = 0;
236
+ }
237
+ finally {
238
+ f = t = 0;
239
+ }
240
+ if (op[0] & 5)
241
+ throw op[1];
242
+ return { value: op[0] ? op[1] : void 0, done: true };
243
+ }
244
+ }
245
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
246
+ if (k2 === undefined)
247
+ k2 = k;
248
+ var desc = Object.getOwnPropertyDescriptor(m, k);
249
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
250
+ desc = { enumerable: true, get: function () { return m[k]; } };
251
+ }
252
+ Object.defineProperty(o, k2, desc);
253
+ }) : (function (o, m, k, k2) {
254
+ if (k2 === undefined)
255
+ k2 = k;
256
+ o[k2] = m[k];
257
+ });
258
+ function __exportStar(m, o) {
259
+ for (var p in m)
260
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
261
+ __createBinding(o, m, p);
262
+ }
263
+ function __values(o) {
264
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
265
+ if (m)
266
+ return m.call(o);
267
+ if (o && typeof o.length === "number")
268
+ return {
269
+ next: function () {
270
+ if (o && i >= o.length)
271
+ o = void 0;
272
+ return { value: o && o[i++], done: !o };
273
+ }
274
+ };
275
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
276
+ }
277
+ function __read(o, n) {
278
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
279
+ if (!m)
280
+ return o;
281
+ var i = m.call(o), r, ar = [], e;
282
+ try {
283
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
284
+ ar.push(r.value);
285
+ }
286
+ catch (error) {
287
+ e = { error: error };
288
+ }
289
+ finally {
290
+ try {
291
+ if (r && !r.done && (m = i["return"]))
292
+ m.call(i);
293
+ }
294
+ finally {
295
+ if (e)
296
+ throw e.error;
297
+ }
298
+ }
299
+ return ar;
300
+ }
301
+ /** @deprecated */
302
+ function __spread() {
303
+ for (var ar = [], i = 0; i < arguments.length; i++)
304
+ ar = ar.concat(__read(arguments[i]));
305
+ return ar;
306
+ }
307
+ /** @deprecated */
308
+ function __spreadArrays() {
309
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
310
+ s += arguments[i].length;
311
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
312
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
313
+ r[k] = a[j];
314
+ return r;
315
+ }
316
+ function __spreadArray(to, from, pack) {
317
+ if (pack || arguments.length === 2)
318
+ for (var i = 0, l = from.length, ar; i < l; i++) {
319
+ if (ar || !(i in from)) {
320
+ if (!ar)
321
+ ar = Array.prototype.slice.call(from, 0, i);
322
+ ar[i] = from[i];
323
+ }
324
+ }
325
+ return to.concat(ar || Array.prototype.slice.call(from));
326
+ }
327
+ function __await(v) {
328
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
329
+ }
330
+ function __asyncGenerator(thisArg, _arguments, generator) {
331
+ if (!Symbol.asyncIterator)
332
+ throw new TypeError("Symbol.asyncIterator is not defined.");
333
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
334
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
335
+ function verb(n) { if (g[n])
336
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
337
+ function resume(n, v) { try {
338
+ step(g[n](v));
339
+ }
340
+ catch (e) {
341
+ settle(q[0][3], e);
342
+ } }
343
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
344
+ function fulfill(value) { resume("next", value); }
345
+ function reject(value) { resume("throw", value); }
346
+ function settle(f, v) { if (f(v), q.shift(), q.length)
347
+ resume(q[0][0], q[0][1]); }
348
+ }
349
+ function __asyncDelegator(o) {
350
+ var i, p;
351
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
352
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
353
+ }
354
+ function __asyncValues(o) {
355
+ if (!Symbol.asyncIterator)
356
+ throw new TypeError("Symbol.asyncIterator is not defined.");
357
+ var m = o[Symbol.asyncIterator], i;
358
+ 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);
359
+ 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); }); }; }
360
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
361
+ }
362
+ function __makeTemplateObject(cooked, raw) {
363
+ if (Object.defineProperty) {
364
+ Object.defineProperty(cooked, "raw", { value: raw });
365
+ }
366
+ else {
367
+ cooked.raw = raw;
368
+ }
369
+ return cooked;
370
+ }
371
+ ;
372
+ var __setModuleDefault = Object.create ? (function (o, v) {
373
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
374
+ }) : function (o, v) {
375
+ o["default"] = v;
376
+ };
377
+ function __importStar(mod) {
378
+ if (mod && mod.__esModule)
379
+ return mod;
380
+ var result = {};
381
+ if (mod != null)
382
+ for (var k in mod)
383
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
384
+ __createBinding(result, mod, k);
385
+ __setModuleDefault(result, mod);
386
+ return result;
387
+ }
388
+ function __importDefault(mod) {
389
+ return (mod && mod.__esModule) ? mod : { default: mod };
390
+ }
391
+ function __classPrivateFieldGet(receiver, state, kind, f) {
392
+ if (kind === "a" && !f)
393
+ throw new TypeError("Private accessor was defined without a getter");
394
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
395
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
396
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
397
+ }
398
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
399
+ if (kind === "m")
400
+ throw new TypeError("Private method is not writable");
401
+ if (kind === "a" && !f)
402
+ throw new TypeError("Private accessor was defined without a setter");
403
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
404
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
405
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
406
+ }
407
+ function __classPrivateFieldIn(state, receiver) {
408
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
409
+ throw new TypeError("Cannot use 'in' operator on non-object");
410
+ return typeof state === "function" ? receiver === state : state.has(receiver);
411
+ }
412
+ function __addDisposableResource(env, value, async) {
413
+ if (value !== null && value !== void 0) {
414
+ if (typeof value !== "object" && typeof value !== "function")
415
+ throw new TypeError("Object expected.");
416
+ var dispose;
417
+ if (async) {
418
+ if (!Symbol.asyncDispose)
419
+ throw new TypeError("Symbol.asyncDispose is not defined.");
420
+ dispose = value[Symbol.asyncDispose];
421
+ }
422
+ if (dispose === void 0) {
423
+ if (!Symbol.dispose)
424
+ throw new TypeError("Symbol.dispose is not defined.");
425
+ dispose = value[Symbol.dispose];
426
+ }
427
+ if (typeof dispose !== "function")
428
+ throw new TypeError("Object not disposable.");
429
+ env.stack.push({ value: value, dispose: dispose, async: async });
430
+ }
431
+ else if (async) {
432
+ env.stack.push({ async: true });
433
+ }
434
+ return value;
435
+ }
436
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
437
+ var e = new Error(message);
438
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
439
+ };
440
+ function __disposeResources(env) {
441
+ function fail(e) {
442
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
443
+ env.hasError = true;
444
+ }
445
+ function next() {
446
+ while (env.stack.length) {
447
+ var rec = env.stack.pop();
448
+ try {
449
+ var result = rec.dispose && rec.dispose.call(rec.value);
450
+ if (rec.async)
451
+ return Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
452
+ }
453
+ catch (e) {
454
+ fail(e);
455
+ }
456
+ }
457
+ if (env.hasError)
458
+ throw env.error;
459
+ }
460
+ return next();
461
+ }
462
+ var tslib_es6 = {
463
+ __extends: __extends,
464
+ __assign: __assign,
465
+ __rest: __rest,
466
+ __decorate: __decorate,
467
+ __param: __param,
468
+ __metadata: __metadata,
469
+ __awaiter: __awaiter,
470
+ __generator: __generator,
471
+ __createBinding: __createBinding,
472
+ __exportStar: __exportStar,
473
+ __values: __values,
474
+ __read: __read,
475
+ __spread: __spread,
476
+ __spreadArrays: __spreadArrays,
477
+ __spreadArray: __spreadArray,
478
+ __await: __await,
479
+ __asyncGenerator: __asyncGenerator,
480
+ __asyncDelegator: __asyncDelegator,
481
+ __asyncValues: __asyncValues,
482
+ __makeTemplateObject: __makeTemplateObject,
483
+ __importStar: __importStar,
484
+ __importDefault: __importDefault,
485
+ __classPrivateFieldGet: __classPrivateFieldGet,
486
+ __classPrivateFieldSet: __classPrivateFieldSet,
487
+ __classPrivateFieldIn: __classPrivateFieldIn,
488
+ __addDisposableResource: __addDisposableResource,
489
+ __disposeResources: __disposeResources,
490
+ };
491
+
492
+ /**
493
+ * Returns the type from an action instance/class.
494
+ * @ignore
495
+ */
496
+ function getActionTypeFromInstance(action) {
497
+ if (action.constructor && action.constructor.type) {
498
+ return action.constructor.type;
499
+ }
500
+ else {
501
+ return action.type;
502
+ }
503
+ }
504
+ /**
505
+ * Matches a action
506
+ * @ignore
507
+ */
508
+ function actionMatcher(action1) {
509
+ var type1 = getActionTypeFromInstance(action1);
510
+ return function (action2) {
511
+ return type1 === getActionTypeFromInstance(action2);
512
+ };
513
+ }
514
+ /**
515
+ * Set a deeply nested value. Example:
516
+ *
517
+ * setValue({ foo: { bar: { eat: false } } },
518
+ * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
519
+ *
520
+ * While it traverses it also creates new objects from top down.
521
+ *
522
+ * @ignore
523
+ */
524
+ var setValue = function (obj, prop, val) {
525
+ obj = Object.assign({}, obj);
526
+ var split = prop.split('.');
527
+ var lastIndex = split.length - 1;
528
+ split.reduce(function (acc, part, index) {
529
+ if (index === lastIndex) {
530
+ acc[part] = val;
531
+ }
532
+ else {
533
+ acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
534
+ }
535
+ return acc && acc[part];
536
+ }, obj);
537
+ return obj;
538
+ };
539
+ /**
540
+ * Get a deeply nested value. Example:
541
+ *
542
+ * getValue({ foo: bar: [] }, 'foo.bar') //=> []
543
+ *
544
+ * @ignore
545
+ */
546
+ var getValue = function (obj, prop) { return prop.split('.').reduce(function (acc, part) { return acc && acc[part]; }, obj); };
547
+ /**
548
+ * Simple object check.
549
+ *
550
+ * isObject({a:1}) //=> true
551
+ * isObject(1) //=> false
552
+ *
553
+ * @ignore
554
+ */
555
+ var isObject$1 = function (item) {
556
+ return item && typeof item === 'object' && !Array.isArray(item);
557
+ };
558
+ /**
559
+ * Deep merge two objects.
560
+ *
561
+ * mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
562
+ *
563
+ * @param base base object onto which `sources` will be applied
564
+ */
565
+ var mergeDeep = function (base) {
566
+ var _a, _b;
567
+ var sources = [];
568
+ for (var _i = 1; _i < arguments.length; _i++) {
569
+ sources[_i - 1] = arguments[_i];
570
+ }
571
+ if (!sources.length)
572
+ return base;
573
+ var source = sources.shift();
574
+ if (isObject$1(base) && isObject$1(source)) {
575
+ for (var key in source) {
576
+ if (isObject$1(source[key])) {
577
+ if (!base[key])
578
+ Object.assign(base, (_a = {}, _a[key] = {}, _a));
579
+ mergeDeep(base[key], source[key]);
580
+ }
581
+ else {
582
+ Object.assign(base, (_b = {}, _b[key] = source[key], _b));
583
+ }
584
+ }
585
+ }
586
+ return mergeDeep.apply(void 0, __spreadArray([base], __read(sources)));
587
+ };
588
+
589
+ function throwStateNameError(name) {
590
+ throw new Error(name + " is not a valid state name. It needs to be a valid object property name.");
591
+ }
592
+ function throwStateNamePropertyError() {
593
+ throw new Error("States must register a 'name' property.");
594
+ }
595
+ function throwStateUniqueError(current, newName, oldName) {
596
+ throw new Error("State name '" + current + "' from " + newName + " already exists in " + oldName + ".");
597
+ }
598
+ function throwStateDecoratorError(name) {
599
+ throw new Error("States must be decorated with @State() decorator, but \"" + name + "\" isn't.");
600
+ }
601
+ function throwActionDecoratorError() {
602
+ throw new Error('@Action() decorator cannot be used with static methods.');
603
+ }
604
+ function throwSelectorDecoratorError() {
605
+ throw new Error('Selectors only work on methods.');
606
+ }
607
+ function getZoneWarningMessage() {
608
+ return ('Your application was bootstrapped with nooped zone and your execution strategy requires an actual NgZone!\n' +
609
+ 'Please set the value of the executionStrategy property to NoopNgxsExecutionStrategy.\n' +
610
+ 'NgxsModule.forRoot(states, { executionStrategy: NoopNgxsExecutionStrategy })');
611
+ }
612
+ function getUndecoratedStateInIvyWarningMessage(name) {
613
+ return "'" + name + "' class should be decorated with @Injectable() right after the @State() decorator";
614
+ }
615
+ function throwSelectFactoryNotConnectedError() {
616
+ throw new Error('You have forgotten to import the NGXS module!');
617
+ }
618
+ function throwPatchingArrayError() {
619
+ throw new Error('Patching arrays is not supported.');
620
+ }
621
+ function throwPatchingPrimitiveError() {
622
+ throw new Error('Patching primitives is not supported.');
623
+ }
624
+
625
+ var DispatchOutsideZoneNgxsExecutionStrategy = /** @class */ (function () {
626
+ function DispatchOutsideZoneNgxsExecutionStrategy(_ngZone, _platformId) {
627
+ this._ngZone = _ngZone;
628
+ this._platformId = _platformId;
629
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
630
+ // creating a breaking change for projects that still use the View Engine.
631
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
632
+ verifyZoneIsNotNooped(_ngZone);
633
+ }
634
+ }
635
+ DispatchOutsideZoneNgxsExecutionStrategy.prototype.enter = function (func) {
636
+ if (common.isPlatformServer(this._platformId)) {
637
+ return this.runInsideAngular(func);
638
+ }
639
+ return this.runOutsideAngular(func);
640
+ };
641
+ DispatchOutsideZoneNgxsExecutionStrategy.prototype.leave = function (func) {
642
+ return this.runInsideAngular(func);
643
+ };
644
+ DispatchOutsideZoneNgxsExecutionStrategy.prototype.runInsideAngular = function (func) {
645
+ if (i0.NgZone.isInAngularZone()) {
646
+ return func();
647
+ }
648
+ return this._ngZone.run(func);
649
+ };
650
+ DispatchOutsideZoneNgxsExecutionStrategy.prototype.runOutsideAngular = function (func) {
651
+ if (i0.NgZone.isInAngularZone()) {
652
+ return this._ngZone.runOutsideAngular(func);
653
+ }
654
+ return func();
655
+ };
656
+ return DispatchOutsideZoneNgxsExecutionStrategy;
657
+ }());
658
+ /** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DispatchOutsideZoneNgxsExecutionStrategy, deps: [{ token: i0__namespace.NgZone }, { token: i0.PLATFORM_ID }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
659
+ /** @nocollapse */ DispatchOutsideZoneNgxsExecutionStrategy.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DispatchOutsideZoneNgxsExecutionStrategy, providedIn: 'root' });
660
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: DispatchOutsideZoneNgxsExecutionStrategy, decorators: [{
661
+ type: i0.Injectable,
662
+ args: [{ providedIn: 'root' }]
663
+ }], ctorParameters: function () {
664
+ return [{ type: i0__namespace.NgZone }, { type: undefined, decorators: [{
665
+ type: i0.Inject,
666
+ args: [i0.PLATFORM_ID]
667
+ }] }];
668
+ } });
669
+ // Caretaker note: this should exist as a separate function and not a class method,
670
+ // since class methods are not tree-shakable.
671
+ function verifyZoneIsNotNooped(ngZone) {
672
+ // `NoopNgZone` is not exposed publicly as it doesn't expect
673
+ // to be used outside of the core Angular code, thus we just have
674
+ // to check if the zone doesn't extend or instanceof `NgZone`.
675
+ if (ngZone instanceof i0.NgZone) {
676
+ return;
677
+ }
678
+ console.warn(getZoneWarningMessage());
679
+ }
680
+
681
+ var ROOT_OPTIONS = new i0.InjectionToken('ROOT_OPTIONS');
682
+ var ROOT_STATE_TOKEN = new i0.InjectionToken('ROOT_STATE_TOKEN');
683
+ var FEATURE_STATE_TOKEN = new i0.InjectionToken('FEATURE_STATE_TOKEN');
684
+ var NGXS_PLUGINS = new i0.InjectionToken('NGXS_PLUGINS');
685
+ var META_KEY = 'NGXS_META';
686
+ var META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
687
+ var SELECTOR_META_KEY = 'NGXS_SELECTOR_META';
688
+ /**
689
+ * The NGXS config settings.
690
+ */
691
+ var NgxsConfig = /** @class */ (function () {
692
+ function NgxsConfig() {
693
+ /**
694
+ * Defining the default state before module initialization
695
+ * This is convenient if we need to create a define our own set of states.
696
+ * @deprecated will be removed after v4
697
+ * (default: {})
698
+ */
699
+ this.defaultsState = {};
700
+ /**
701
+ * Defining shared selector options
702
+ */
703
+ this.selectorOptions = {
704
+ injectContainerState: true,
705
+ suppressErrors: true // TODO: default is true in v3, will change in v4
706
+ };
707
+ this.compatibility = {
708
+ strictContentSecurityPolicy: false
709
+ };
710
+ this.executionStrategy = DispatchOutsideZoneNgxsExecutionStrategy;
711
+ }
712
+ return NgxsConfig;
713
+ }());
714
+ /** @nocollapse */ NgxsConfig.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsConfig, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
715
+ /** @nocollapse */ NgxsConfig.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsConfig, providedIn: 'root', useFactory: function (options) { return mergeDeep(new NgxsConfig(), options); }, deps: [{ token: ROOT_OPTIONS }] });
716
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsConfig, decorators: [{
717
+ type: i0.Injectable,
718
+ args: [{
719
+ providedIn: 'root',
720
+ useFactory: function (options) { return mergeDeep(new NgxsConfig(), options); },
721
+ deps: [ROOT_OPTIONS]
722
+ }]
723
+ }], ctorParameters: function () { return []; } });
724
+ /**
725
+ * Represents a basic change from a previous to a new value for a single state instance.
726
+ * Passed as a value in a NgxsSimpleChanges object to the ngxsOnChanges hook.
727
+ */
728
+ var NgxsSimpleChange = /** @class */ (function () {
729
+ function NgxsSimpleChange(previousValue, currentValue, firstChange) {
730
+ this.previousValue = previousValue;
731
+ this.currentValue = currentValue;
732
+ this.firstChange = firstChange;
733
+ }
734
+ return NgxsSimpleChange;
735
+ }());
736
+
737
+ var NoopNgxsExecutionStrategy = /** @class */ (function () {
738
+ function NoopNgxsExecutionStrategy() {
739
+ }
740
+ NoopNgxsExecutionStrategy.prototype.enter = function (func) {
741
+ return func();
742
+ };
743
+ NoopNgxsExecutionStrategy.prototype.leave = function (func) {
744
+ return func();
745
+ };
746
+ return NoopNgxsExecutionStrategy;
747
+ }());
748
+ /** @nocollapse */ NoopNgxsExecutionStrategy.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NoopNgxsExecutionStrategy, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
749
+ /** @nocollapse */ NoopNgxsExecutionStrategy.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NoopNgxsExecutionStrategy, providedIn: 'root' });
750
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NoopNgxsExecutionStrategy, decorators: [{
751
+ type: i0.Injectable,
752
+ args: [{ providedIn: 'root' }]
753
+ }] });
754
+
755
+ /**
756
+ * The strategy that might be provided by users through `options.executionStrategy`.
757
+ */
758
+ var USER_PROVIDED_NGXS_EXECUTION_STRATEGY = new i0.InjectionToken('USER_PROVIDED_NGXS_EXECUTION_STRATEGY');
759
+ /*
760
+ * Internal execution strategy injection token
761
+ */
762
+ var NGXS_EXECUTION_STRATEGY = new i0.InjectionToken('NGXS_EXECUTION_STRATEGY', {
763
+ providedIn: 'root',
764
+ factory: function () {
765
+ var injector = i0.inject(i0.INJECTOR);
766
+ var executionStrategy = injector.get(USER_PROVIDED_NGXS_EXECUTION_STRATEGY);
767
+ return executionStrategy
768
+ ? injector.get(executionStrategy)
769
+ : injector.get(typeof i0["ɵglobal"].Zone !== 'undefined'
770
+ ? DispatchOutsideZoneNgxsExecutionStrategy
771
+ : NoopNgxsExecutionStrategy);
772
+ }
773
+ });
774
+
775
+ /**
776
+ * Ensures metadata is attached to the class and returns it.
777
+ *
778
+ * @ignore
779
+ */
780
+ function ensureStoreMetadata$1(target) {
781
+ if (!target.hasOwnProperty(META_KEY)) {
782
+ var defaultMetadata_1 = {
783
+ name: null,
784
+ actions: {},
785
+ defaults: {},
786
+ path: null,
787
+ makeRootSelector: function (context) {
788
+ return context.getStateGetter(defaultMetadata_1.name);
789
+ },
790
+ children: []
791
+ };
792
+ Object.defineProperty(target, META_KEY, { value: defaultMetadata_1 });
793
+ }
794
+ return getStoreMetadata$1(target);
795
+ }
796
+ /**
797
+ * Get the metadata attached to the state class if it exists.
798
+ *
799
+ * @ignore
800
+ */
801
+ function getStoreMetadata$1(target) {
802
+ return target[META_KEY];
803
+ }
804
+ /**
805
+ * Ensures metadata is attached to the selector and returns it.
806
+ *
807
+ * @ignore
808
+ */
809
+ function ensureSelectorMetadata$1(target) {
810
+ if (!target.hasOwnProperty(SELECTOR_META_KEY)) {
811
+ var defaultMetadata = {
812
+ makeRootSelector: null,
813
+ originalFn: null,
814
+ containerClass: null,
815
+ selectorName: null,
816
+ getSelectorOptions: function () { return ({}); }
817
+ };
818
+ Object.defineProperty(target, SELECTOR_META_KEY, { value: defaultMetadata });
819
+ }
820
+ return getSelectorMetadata$1(target);
821
+ }
822
+ /**
823
+ * Get the metadata attached to the selector if it exists.
824
+ *
825
+ * @ignore
826
+ */
827
+ function getSelectorMetadata$1(target) {
828
+ return target[SELECTOR_META_KEY];
829
+ }
830
+ /**
831
+ * Get a deeply nested value. Example:
832
+ *
833
+ * getValue({ foo: bar: [] }, 'foo.bar') //=> []
834
+ *
835
+ * Note: This is not as fast as the `fastPropGetter` but is strict Content Security Policy compliant.
836
+ * See perf hit: https://jsperf.com/fast-value-getter-given-path/1
837
+ *
838
+ * @ignore
839
+ */
840
+ function compliantPropGetter(paths) {
841
+ var copyOfPaths = paths.slice();
842
+ return function (obj) { return copyOfPaths.reduce(function (acc, part) { return acc && acc[part]; }, obj); };
843
+ }
844
+ /**
845
+ * The generated function is faster than:
846
+ * - pluck (Observable operator)
847
+ * - memoize
848
+ *
849
+ * @ignore
850
+ */
851
+ function fastPropGetter(paths) {
852
+ var segments = paths;
853
+ var seg = 'store.' + segments[0];
854
+ var i = 0;
855
+ var l = segments.length;
856
+ var expr = seg;
857
+ while (++i < l) {
858
+ expr = expr + ' && ' + (seg = seg + '.' + segments[i]);
859
+ }
860
+ var fn = new Function('store', 'return ' + expr + ';');
861
+ return fn;
862
+ }
863
+ /**
864
+ * Get a deeply nested value. Example:
865
+ *
866
+ * getValue({ foo: bar: [] }, 'foo.bar') //=> []
867
+ *
868
+ * @ignore
869
+ */
870
+ function propGetter(paths, config) {
871
+ if (config && config.compatibility && config.compatibility.strictContentSecurityPolicy) {
872
+ return compliantPropGetter(paths);
873
+ }
874
+ else {
875
+ return fastPropGetter(paths);
876
+ }
877
+ }
878
+ /**
879
+ * Given an array of states, it will return a object graph. Example:
880
+ * const states = [
881
+ * Cart,
882
+ * CartSaved,
883
+ * CartSavedItems
884
+ * ]
885
+ *
886
+ * would return:
887
+ *
888
+ * const graph = {
889
+ * cart: ['saved'],
890
+ * saved: ['items'],
891
+ * items: []
892
+ * };
893
+ *
894
+ * @ignore
895
+ */
896
+ function buildGraph(stateClasses) {
897
+ var findName = function (stateClass) {
898
+ var meta = stateClasses.find(function (g) { return g === stateClass; });
899
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
900
+ // creating a breaking change for projects that still use the View Engine.
901
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && !meta) {
902
+ throw new Error("Child state not found: " + stateClass + ". \r\nYou may have forgotten to add states to module");
903
+ }
904
+ return meta[META_KEY].name;
905
+ };
906
+ return stateClasses.reduce(function (result, stateClass) {
907
+ var _a = stateClass[META_KEY], name = _a.name, children = _a.children;
908
+ result[name] = (children || []).map(findName);
909
+ return result;
910
+ }, {});
911
+ }
912
+ /**
913
+ * Given a states array, returns object graph
914
+ * returning the name and state metadata. Example:
915
+ *
916
+ * const graph = {
917
+ * cart: { metadata }
918
+ * };
919
+ *
920
+ * @ignore
921
+ */
922
+ function nameToState(states) {
923
+ return states.reduce(function (result, stateClass) {
924
+ var meta = stateClass[META_KEY];
925
+ result[meta.name] = stateClass;
926
+ return result;
927
+ }, {});
928
+ }
929
+ /**
930
+ * Given a object relationship graph will return the full path
931
+ * for the child items. Example:
932
+ *
933
+ * const graph = {
934
+ * cart: ['saved'],
935
+ * saved: ['items'],
936
+ * items: []
937
+ * };
938
+ *
939
+ * would return:
940
+ *
941
+ * const r = {
942
+ * cart: 'cart',
943
+ * saved: 'cart.saved',
944
+ * items: 'cart.saved.items'
945
+ * };
946
+ *
947
+ * @ignore
948
+ */
949
+ function findFullParentPath(obj, newObj) {
950
+ if (newObj === void 0) { newObj = {}; }
951
+ var visit = function (child, keyToFind) {
952
+ for (var key in child) {
953
+ if (child.hasOwnProperty(key) && child[key].indexOf(keyToFind) >= 0) {
954
+ var parent = visit(child, key);
955
+ return parent !== null ? parent + "." + key : key;
956
+ }
957
+ }
958
+ return null;
959
+ };
960
+ for (var key in obj) {
961
+ if (obj.hasOwnProperty(key)) {
962
+ var parent = visit(obj, key);
963
+ newObj[key] = parent ? parent + "." + key : key;
964
+ }
965
+ }
966
+ return newObj;
967
+ }
968
+ /**
969
+ * Given a object graph, it will return the items topologically sorted Example:
970
+ *
971
+ * const graph = {
972
+ * cart: ['saved'],
973
+ * saved: ['items'],
974
+ * items: []
975
+ * };
976
+ *
977
+ * would return:
978
+ *
979
+ * const results = [
980
+ * 'items',
981
+ * 'saved',
982
+ * 'cart'
983
+ * ];
984
+ *
985
+ * @ignore
986
+ */
987
+ function topologicalSort(graph) {
988
+ var sorted = [];
989
+ var visited = {};
990
+ var visit = function (name, ancestors) {
991
+ if (ancestors === void 0) { ancestors = []; }
992
+ if (!Array.isArray(ancestors)) {
993
+ ancestors = [];
994
+ }
995
+ ancestors.push(name);
996
+ visited[name] = true;
997
+ graph[name].forEach(function (dep) {
998
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
999
+ // creating a breaking change for projects that still use the View Engine.
1000
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && ancestors.indexOf(dep) >= 0) {
1001
+ throw new Error("Circular dependency '" + dep + "' is required by '" + name + "': " + ancestors.join(' -> '));
1002
+ }
1003
+ if (visited[dep]) {
1004
+ return;
1005
+ }
1006
+ visit(dep, ancestors.slice(0));
1007
+ });
1008
+ if (sorted.indexOf(name) < 0) {
1009
+ sorted.push(name);
1010
+ }
1011
+ };
1012
+ Object.keys(graph).forEach(function (k) { return visit(k); });
1013
+ return sorted.reverse();
1014
+ }
1015
+ /**
1016
+ * Returns if the parameter is a object or not.
1017
+ *
1018
+ * @ignore
1019
+ */
1020
+ function isObject(obj) {
1021
+ return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
1022
+ }
1023
+
1024
+ /**
1025
+ * RxJS operator for selecting out specific actions.
1026
+ *
1027
+ * This will grab actions that have just been dispatched as well as actions that have completed
1028
+ */
1029
+ function ofAction() {
1030
+ var allowedTypes = [];
1031
+ for (var _i = 0; _i < arguments.length; _i++) {
1032
+ allowedTypes[_i] = arguments[_i];
1033
+ }
1034
+ return ofActionOperator(allowedTypes);
1035
+ }
1036
+ /**
1037
+ * RxJS operator for selecting out specific actions.
1038
+ *
1039
+ * This will ONLY grab actions that have just been dispatched
1040
+ */
1041
+ function ofActionDispatched() {
1042
+ var allowedTypes = [];
1043
+ for (var _i = 0; _i < arguments.length; _i++) {
1044
+ allowedTypes[_i] = arguments[_i];
1045
+ }
1046
+ return ofActionOperator(allowedTypes, ["DISPATCHED" /* Dispatched */]);
1047
+ }
1048
+ /**
1049
+ * RxJS operator for selecting out specific actions.
1050
+ *
1051
+ * This will ONLY grab actions that have just been successfully completed
1052
+ */
1053
+ function ofActionSuccessful() {
1054
+ var allowedTypes = [];
1055
+ for (var _i = 0; _i < arguments.length; _i++) {
1056
+ allowedTypes[_i] = arguments[_i];
1057
+ }
1058
+ return ofActionOperator(allowedTypes, ["SUCCESSFUL" /* Successful */]);
1059
+ }
1060
+ /**
1061
+ * RxJS operator for selecting out specific actions.
1062
+ *
1063
+ * This will ONLY grab actions that have just been canceled
1064
+ */
1065
+ function ofActionCanceled() {
1066
+ var allowedTypes = [];
1067
+ for (var _i = 0; _i < arguments.length; _i++) {
1068
+ allowedTypes[_i] = arguments[_i];
1069
+ }
1070
+ return ofActionOperator(allowedTypes, ["CANCELED" /* Canceled */]);
1071
+ }
1072
+ /**
1073
+ * RxJS operator for selecting out specific actions.
1074
+ *
1075
+ * This will ONLY grab actions that have just been completed
1076
+ */
1077
+ function ofActionCompleted() {
1078
+ var allowedTypes = [];
1079
+ for (var _i = 0; _i < arguments.length; _i++) {
1080
+ allowedTypes[_i] = arguments[_i];
1081
+ }
1082
+ var allowedStatuses = [
1083
+ "SUCCESSFUL" /* Successful */,
1084
+ "CANCELED" /* Canceled */,
1085
+ "ERRORED" /* Errored */
1086
+ ];
1087
+ return ofActionOperator(allowedTypes, allowedStatuses, mapActionResult);
1088
+ }
1089
+ /**
1090
+ * RxJS operator for selecting out specific actions.
1091
+ *
1092
+ * This will ONLY grab actions that have just thrown an error
1093
+ */
1094
+ function ofActionErrored() {
1095
+ var allowedTypes = [];
1096
+ for (var _i = 0; _i < arguments.length; _i++) {
1097
+ allowedTypes[_i] = arguments[_i];
1098
+ }
1099
+ return ofActionOperator(allowedTypes, ["ERRORED" /* Errored */]);
1100
+ }
1101
+ function ofActionOperator(allowedTypes, statuses,
1102
+ // This actually could've been `OperatorFunction<ActionContext, ActionCompletion | any>`,
1103
+ // since it maps either to `ctx.action` OR to `ActionCompletion`. But `ActionCompleteion | any`
1104
+ // defaults to `any`, thus there is no sense from union type.
1105
+ mapOperator) {
1106
+ if (mapOperator === void 0) { mapOperator = mapAction; }
1107
+ var allowedMap = createAllowedActionTypesMap(allowedTypes);
1108
+ var allowedStatusMap = statuses && createAllowedStatusesMap(statuses);
1109
+ return function (o) {
1110
+ return o.pipe(filterStatus(allowedMap, allowedStatusMap), mapOperator());
1111
+ };
1112
+ }
1113
+ function filterStatus(allowedTypes, allowedStatuses) {
1114
+ return operators.filter(function (ctx) {
1115
+ var actionType = getActionTypeFromInstance(ctx.action);
1116
+ var typeMatch = allowedTypes[actionType];
1117
+ var statusMatch = allowedStatuses ? allowedStatuses[ctx.status] : true;
1118
+ return typeMatch && statusMatch;
1119
+ });
1120
+ }
1121
+ function mapActionResult() {
1122
+ return operators.map(function (_a) {
1123
+ var action = _a.action, status = _a.status, error = _a.error;
1124
+ return {
1125
+ action: action,
1126
+ result: {
1127
+ successful: "SUCCESSFUL" /* Successful */ === status,
1128
+ canceled: "CANCELED" /* Canceled */ === status,
1129
+ error: error
1130
+ }
1131
+ };
1132
+ });
1133
+ }
1134
+ function mapAction() {
1135
+ return operators.map(function (ctx) { return ctx.action; });
1136
+ }
1137
+ function createAllowedActionTypesMap(types) {
1138
+ return types.reduce(function (filterMap, klass) {
1139
+ filterMap[getActionTypeFromInstance(klass)] = true;
1140
+ return filterMap;
1141
+ }, {});
1142
+ }
1143
+ function createAllowedStatusesMap(statuses) {
1144
+ return statuses.reduce(function (filterMap, status) {
1145
+ filterMap[status] = true;
1146
+ return filterMap;
1147
+ }, {});
1148
+ }
1149
+
1150
+ var stateNameRegex = new RegExp('^[a-zA-Z0-9_]+$');
1151
+ function ensureStateNameIsValid(name) {
1152
+ if (!name) {
1153
+ throwStateNamePropertyError();
1154
+ }
1155
+ else if (!stateNameRegex.test(name)) {
1156
+ throwStateNameError(name);
1157
+ }
1158
+ }
1159
+ function ensureStateNameIsUnique(stateName, state, statesByName) {
1160
+ var existingState = statesByName[stateName];
1161
+ if (existingState && existingState !== state) {
1162
+ throwStateUniqueError(stateName, state.name, existingState.name);
1163
+ }
1164
+ }
1165
+ function ensureStatesAreDecorated(stateClasses) {
1166
+ stateClasses.forEach(function (stateClass) {
1167
+ if (!getStoreMetadata$1(stateClass)) {
1168
+ throwStateDecoratorError(stateClass.name);
1169
+ }
1170
+ });
1171
+ }
1172
+
1173
+ /**
1174
+ * All provided or injected tokens must have `@Injectable` decorator
1175
+ * (previously, injected tokens without `@Injectable` were allowed
1176
+ * if another decorator was used, e.g. pipes).
1177
+ */
1178
+ function ensureStateClassIsInjectable(stateClass) {
1179
+ if (jit_hasInjectableAnnotation(stateClass) || aot_hasNgInjectableDef(stateClass)) {
1180
+ return;
1181
+ }
1182
+ console.warn(getUndecoratedStateInIvyWarningMessage(stateClass.name));
1183
+ }
1184
+ function aot_hasNgInjectableDef(stateClass) {
1185
+ // `ɵprov` is a static property added by the NGCC compiler. It always exists in
1186
+ // AOT mode because this property is added before runtime. If an application is running in
1187
+ // JIT mode then this property can be added by the `@Injectable()` decorator. The `@Injectable()`
1188
+ // decorator has to go after the `@State()` decorator, thus we prevent users from unwanted DI errors.
1189
+ return !!stateClass.ɵprov;
1190
+ }
1191
+ function jit_hasInjectableAnnotation(stateClass) {
1192
+ // `ɵprov` doesn't exist in JIT mode (for instance when running unit tests with Jest).
1193
+ var annotations = stateClass.__annotations__ || [];
1194
+ return annotations.some(function (annotation) { return (annotation === null || annotation === void 0 ? void 0 : annotation.ngMetadataName) === 'Injectable'; });
1195
+ }
1196
+
1197
+ /**
1198
+ * Init action
1199
+ */
1200
+ var InitState = /** @class */ (function () {
1201
+ function InitState() {
1202
+ }
1203
+ return InitState;
1204
+ }());
1205
+ InitState.type = '@@INIT';
1206
+ /**
1207
+ * Update action
1208
+ */
1209
+ var UpdateState = /** @class */ (function () {
1210
+ function UpdateState(addedStates) {
1211
+ this.addedStates = addedStates;
1212
+ }
1213
+ return UpdateState;
1214
+ }());
1215
+ UpdateState.type = '@@UPDATE_STATE';
1216
+
1217
+ var NGXS_DEVELOPMENT_OPTIONS = new i0.InjectionToken('NGXS_DEVELOPMENT_OPTIONS', {
1218
+ providedIn: 'root',
1219
+ factory: function () { return ({ warnOnUnhandledActions: true }); }
1220
+ });
1221
+
1222
+ var NgxsUnhandledActionsLogger = /** @class */ (function () {
1223
+ function NgxsUnhandledActionsLogger(options) {
1224
+ /**
1225
+ * These actions should be ignored by default; the user can increase this
1226
+ * list in the future via the `ignoreActions` method.
1227
+ */
1228
+ this._ignoredActions = new Set([InitState.type, UpdateState.type]);
1229
+ if (typeof options.warnOnUnhandledActions === 'object') {
1230
+ this.ignoreActions.apply(this, __spreadArray([], __read(options.warnOnUnhandledActions.ignore)));
1231
+ }
1232
+ }
1233
+ /**
1234
+ * Adds actions to the internal list of actions that should be ignored.
1235
+ */
1236
+ NgxsUnhandledActionsLogger.prototype.ignoreActions = function () {
1237
+ var e_1, _a;
1238
+ var actions = [];
1239
+ for (var _i = 0; _i < arguments.length; _i++) {
1240
+ actions[_i] = arguments[_i];
1241
+ }
1242
+ try {
1243
+ for (var actions_1 = __values(actions), actions_1_1 = actions_1.next(); !actions_1_1.done; actions_1_1 = actions_1.next()) {
1244
+ var action = actions_1_1.value;
1245
+ this._ignoredActions.add(action.type);
1246
+ }
1247
+ }
1248
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1249
+ finally {
1250
+ try {
1251
+ if (actions_1_1 && !actions_1_1.done && (_a = actions_1.return)) _a.call(actions_1);
1252
+ }
1253
+ finally { if (e_1) throw e_1.error; }
1254
+ }
1255
+ };
1256
+ /** @internal */
1257
+ NgxsUnhandledActionsLogger.prototype.warn = function (action) {
1258
+ var actionShouldBeIgnored = Array.from(this._ignoredActions).some(function (type) { return type === getActionTypeFromInstance(action); });
1259
+ if (actionShouldBeIgnored) {
1260
+ return;
1261
+ }
1262
+ action =
1263
+ action.constructor && action.constructor.name !== 'Object'
1264
+ ? action.constructor.name
1265
+ : action.type;
1266
+ console.warn("The " + action + " action has been dispatched but hasn't been handled. This may happen if the state with an action handler for this action is not registered.");
1267
+ };
1268
+ return NgxsUnhandledActionsLogger;
1269
+ }());
1270
+ /** @nocollapse */ NgxsUnhandledActionsLogger.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsUnhandledActionsLogger, deps: [{ token: NGXS_DEVELOPMENT_OPTIONS }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1271
+ /** @nocollapse */ NgxsUnhandledActionsLogger.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsUnhandledActionsLogger });
1272
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsUnhandledActionsLogger, decorators: [{
1273
+ type: i0.Injectable
1274
+ }], ctorParameters: function () {
1275
+ return [{ type: undefined, decorators: [{
1276
+ type: i0.Inject,
1277
+ args: [NGXS_DEVELOPMENT_OPTIONS]
1278
+ }] }];
1279
+ } });
1280
+
1281
+ /**
1282
+ * Returns operator that will run
1283
+ * `subscribe` outside of the ngxs execution context
1284
+ */
1285
+ function leaveNgxs(ngxsExecutionStrategy) {
1286
+ return function (source) {
1287
+ return new rxjs.Observable(function (sink) {
1288
+ return source.subscribe({
1289
+ next: function (value) {
1290
+ ngxsExecutionStrategy.leave(function () { return sink.next(value); });
1291
+ },
1292
+ error: function (error) {
1293
+ ngxsExecutionStrategy.leave(function () { return sink.error(error); });
1294
+ },
1295
+ complete: function () {
1296
+ ngxsExecutionStrategy.leave(function () { return sink.complete(); });
1297
+ }
1298
+ });
1299
+ });
1300
+ };
1301
+ }
1302
+
1303
+ /**
1304
+ * This wraps the provided function, and will enforce the following:
1305
+ * - The calls will execute in the order that they are made
1306
+ * - A call will only be initiated when the previous call has completed
1307
+ * - If there is a call currently executing then the new call will be added
1308
+ * to the queue and the function will return immediately
1309
+ *
1310
+ * NOTE: The following assumptions about the operation must hold true:
1311
+ * - The operation is synchronous in nature
1312
+ * - If any asynchronous side effects of the call exist, it should not
1313
+ * have any bearing on the correctness of the next call in the queue
1314
+ * - The operation has a void return
1315
+ * - The caller should not assume that the call has completed upon
1316
+ * return of the function
1317
+ * - The caller can assume that all the queued calls will complete
1318
+ * within the current microtask
1319
+ * - The only way that a call will encounter another call in the queue
1320
+ * would be if the call at the front of the queue initiated this call
1321
+ * as part of its synchronous execution
1322
+ */
1323
+ function orderedQueueOperation(operation) {
1324
+ var callsQueue = [];
1325
+ var busyPushingNext = false;
1326
+ return function callOperation() {
1327
+ var args = [];
1328
+ for (var _i = 0; _i < arguments.length; _i++) {
1329
+ args[_i] = arguments[_i];
1330
+ }
1331
+ if (busyPushingNext) {
1332
+ callsQueue.unshift(args);
1333
+ return;
1334
+ }
1335
+ busyPushingNext = true;
1336
+ operation.apply(void 0, __spreadArray([], __read(args)));
1337
+ while (callsQueue.length > 0) {
1338
+ var nextCallArgs = callsQueue.pop();
1339
+ nextCallArgs && operation.apply(void 0, __spreadArray([], __read(nextCallArgs)));
1340
+ }
1341
+ busyPushingNext = false;
1342
+ };
1343
+ }
1344
+ /**
1345
+ * Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
1346
+ * A standard Subject does not have this guarantee.
1347
+ * For example, given the following code:
1348
+ * ```typescript
1349
+ * const subject = new Subject<string>();
1350
+ subject.subscribe(value => {
1351
+ if (value === 'start') subject.next('end');
1352
+ });
1353
+ subject.subscribe(value => { });
1354
+ subject.next('start');
1355
+ * ```
1356
+ * When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
1357
+ * When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
1358
+ */
1359
+ var OrderedSubject = /** @class */ (function (_super) {
1360
+ __extends(OrderedSubject, _super);
1361
+ function OrderedSubject() {
1362
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1363
+ _this._orderedNext = orderedQueueOperation(function (value) { return _super.prototype.next.call(_this, value); });
1364
+ return _this;
1365
+ }
1366
+ OrderedSubject.prototype.next = function (value) {
1367
+ this._orderedNext(value);
1368
+ };
1369
+ return OrderedSubject;
1370
+ }(rxjs.Subject));
1371
+ /**
1372
+ * Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
1373
+ * A standard BehaviorSubject does not have this guarantee.
1374
+ * For example, given the following code:
1375
+ * ```typescript
1376
+ * const subject = new BehaviorSubject<string>();
1377
+ subject.subscribe(value => {
1378
+ if (value === 'start') subject.next('end');
1379
+ });
1380
+ subject.subscribe(value => { });
1381
+ subject.next('start');
1382
+ * ```
1383
+ * When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
1384
+ * When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
1385
+ */
1386
+ var OrderedBehaviorSubject = /** @class */ (function (_super) {
1387
+ __extends(OrderedBehaviorSubject, _super);
1388
+ function OrderedBehaviorSubject(value) {
1389
+ var _this = _super.call(this, value) || this;
1390
+ _this._orderedNext = orderedQueueOperation(function (value) { return _super.prototype.next.call(_this, value); });
1391
+ _this._currentValue = value;
1392
+ return _this;
1393
+ }
1394
+ OrderedBehaviorSubject.prototype.getValue = function () {
1395
+ return this._currentValue;
1396
+ };
1397
+ OrderedBehaviorSubject.prototype.next = function (value) {
1398
+ this._currentValue = value;
1399
+ this._orderedNext(value);
1400
+ };
1401
+ return OrderedBehaviorSubject;
1402
+ }(rxjs.BehaviorSubject));
1403
+
1404
+ var InternalNgxsExecutionStrategy = /** @class */ (function () {
1405
+ function InternalNgxsExecutionStrategy(_executionStrategy) {
1406
+ this._executionStrategy = _executionStrategy;
1407
+ }
1408
+ InternalNgxsExecutionStrategy.prototype.enter = function (func) {
1409
+ return this._executionStrategy.enter(func);
1410
+ };
1411
+ InternalNgxsExecutionStrategy.prototype.leave = function (func) {
1412
+ return this._executionStrategy.leave(func);
1413
+ };
1414
+ return InternalNgxsExecutionStrategy;
1415
+ }());
1416
+ /** @nocollapse */ InternalNgxsExecutionStrategy.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy, deps: [{ token: NGXS_EXECUTION_STRATEGY }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1417
+ /** @nocollapse */ InternalNgxsExecutionStrategy.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy, providedIn: 'root' });
1418
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalNgxsExecutionStrategy, decorators: [{
1419
+ type: i0.Injectable,
1420
+ args: [{ providedIn: 'root' }]
1421
+ }], ctorParameters: function () {
1422
+ return [{ type: undefined, decorators: [{
1423
+ type: i0.Inject,
1424
+ args: [NGXS_EXECUTION_STRATEGY]
1425
+ }] }];
1426
+ } });
1427
+
1428
+ /**
1429
+ * Internal Action stream that is emitted anytime an action is dispatched.
1430
+ */
1431
+ var InternalActions = /** @class */ (function (_super) {
1432
+ __extends(InternalActions, _super);
1433
+ function InternalActions() {
1434
+ return _super !== null && _super.apply(this, arguments) || this;
1435
+ }
1436
+ InternalActions.prototype.ngOnDestroy = function () {
1437
+ this.complete();
1438
+ };
1439
+ return InternalActions;
1440
+ }(OrderedSubject));
1441
+ /** @nocollapse */ InternalActions.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalActions, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
1442
+ /** @nocollapse */ InternalActions.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalActions, providedIn: 'root' });
1443
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalActions, decorators: [{
1444
+ type: i0.Injectable,
1445
+ args: [{ providedIn: 'root' }]
1446
+ }] });
1447
+ /**
1448
+ * Action stream that is emitted anytime an action is dispatched.
1449
+ *
1450
+ * You can listen to this in services to react without stores.
1451
+ */
1452
+ var Actions = /** @class */ (function (_super) {
1453
+ __extends(Actions, _super);
1454
+ function Actions(internalActions$, internalExecutionStrategy) {
1455
+ var _this = this;
1456
+ var sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
1457
+ // The `InternalActions` subject emits outside of the Angular zone.
1458
+ // We have to re-enter the Angular zone for any incoming consumer.
1459
+ // The `share()` operator reduces the number of change detections.
1460
+ // This would call leave only once for any stream emission across all active subscribers.
1461
+ operators.share());
1462
+ _this = _super.call(this, function (observer) {
1463
+ var childSubscription = sharedInternalActions$.subscribe({
1464
+ next: function (ctx) { return observer.next(ctx); },
1465
+ error: function (error) { return observer.error(error); },
1466
+ complete: function () { return observer.complete(); }
1467
+ });
1468
+ observer.add(childSubscription);
1469
+ }) || this;
1470
+ return _this;
1471
+ }
1472
+ return Actions;
1473
+ }(rxjs.Observable));
1474
+ /** @nocollapse */ Actions.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: Actions, deps: [{ token: InternalActions }, { token: InternalNgxsExecutionStrategy }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1475
+ /** @nocollapse */ Actions.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: Actions, providedIn: 'root' });
1476
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: Actions, decorators: [{
1477
+ type: i0.Injectable,
1478
+ args: [{ providedIn: 'root' }]
1479
+ }], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalNgxsExecutionStrategy }]; } });
1480
+
1481
+ /**
1482
+ * Composes a array of functions from left to right. Example:
1483
+ *
1484
+ * compose([fn, final])(state, action);
1485
+ *
1486
+ * then the funcs have a signature like:
1487
+ *
1488
+ * function fn (state, action, next) {
1489
+ * console.log('here', state, action, next);
1490
+ * return next(state, action);
1491
+ * }
1492
+ *
1493
+ * function final (state, action) {
1494
+ * console.log('here', state, action);
1495
+ * return state;
1496
+ * }
1497
+ *
1498
+ * the last function should not call `next`.
1499
+ *
1500
+ * @ignore
1501
+ */
1502
+ var compose = function (funcs) { return function () {
1503
+ var args = [];
1504
+ for (var _i = 0; _i < arguments.length; _i++) {
1505
+ args[_i] = arguments[_i];
1506
+ }
1507
+ var curr = funcs.shift();
1508
+ return curr.apply(void 0, __spreadArray(__spreadArray([], __read(args)), [function () {
1509
+ var nextArgs = [];
1510
+ for (var _i = 0; _i < arguments.length; _i++) {
1511
+ nextArgs[_i] = arguments[_i];
1512
+ }
1513
+ return compose(funcs).apply(void 0, __spreadArray([], __read(nextArgs)));
1514
+ }]));
1515
+ }; };
1516
+
1517
+ /**
1518
+ * This operator is used for piping the observable result
1519
+ * from the `dispatch()`. It has a "smart" error handling
1520
+ * strategy that allows us to decide whether we propagate
1521
+ * errors to Angular's `ErrorHandler` or enable users to
1522
+ * handle them manually. We consider following cases:
1523
+ * 1) `store.dispatch()` (no subscribe) -> call `handleError()`
1524
+ * 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
1525
+ * 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
1526
+ * 4) `toPromise()` without `catch` -> do `handleError()`
1527
+ * 5) `toPromise()` with `catch` -> don't `handleError()`
1528
+ */
1529
+ function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
1530
+ return function (source) {
1531
+ var subscribed = false;
1532
+ source.subscribe({
1533
+ error: function (error) {
1534
+ // Do not trigger change detection for a microtask. This depends on the execution
1535
+ // strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
1536
+ // leaves the Angular zone.
1537
+ ngxsExecutionStrategy.enter(function () { return Promise.resolve().then(function () {
1538
+ if (!subscribed) {
1539
+ ngxsExecutionStrategy.leave(function () { return internalErrorReporter.reportErrorSafely(error); });
1540
+ }
1541
+ }); });
1542
+ }
1543
+ });
1544
+ return new rxjs.Observable(function (subscriber) {
1545
+ subscribed = true;
1546
+ return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
1547
+ });
1548
+ };
1549
+ }
1550
+ var InternalErrorReporter = /** @class */ (function () {
1551
+ function InternalErrorReporter(_injector) {
1552
+ this._injector = _injector;
1553
+ /** Will be set lazily to be backward compatible. */
1554
+ this._errorHandler = null;
1555
+ }
1556
+ InternalErrorReporter.prototype.reportErrorSafely = function (error) {
1557
+ if (this._errorHandler === null) {
1558
+ this._errorHandler = this._injector.get(i0.ErrorHandler);
1559
+ }
1560
+ // The `try-catch` is used to avoid handling the error twice. Suppose we call
1561
+ // `handleError` which re-throws the error internally. The re-thrown error will
1562
+ // be caught by zone.js which will then get to the `zone.onError.emit()` and the
1563
+ // `onError` subscriber will call `handleError` again.
1564
+ try {
1565
+ this._errorHandler.handleError(error);
1566
+ }
1567
+ catch (_a) { }
1568
+ };
1569
+ return InternalErrorReporter;
1570
+ }());
1571
+ /** @nocollapse */ InternalErrorReporter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalErrorReporter, deps: [{ token: i0__namespace.Injector }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1572
+ /** @nocollapse */ InternalErrorReporter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalErrorReporter, providedIn: 'root' });
1573
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalErrorReporter, decorators: [{
1574
+ type: i0.Injectable,
1575
+ args: [{ providedIn: 'root' }]
1576
+ }], ctorParameters: function () { return [{ type: i0__namespace.Injector }]; } });
1577
+
1578
+ var PluginManager = /** @class */ (function () {
1579
+ function PluginManager(_parentManager, _pluginHandlers) {
1580
+ this._parentManager = _parentManager;
1581
+ this._pluginHandlers = _pluginHandlers;
1582
+ this.plugins = [];
1583
+ this.registerHandlers();
1584
+ }
1585
+ Object.defineProperty(PluginManager.prototype, "rootPlugins", {
1586
+ get: function () {
1587
+ return (this._parentManager && this._parentManager.plugins) || this.plugins;
1588
+ },
1589
+ enumerable: false,
1590
+ configurable: true
1591
+ });
1592
+ PluginManager.prototype.registerHandlers = function () {
1593
+ var _a;
1594
+ var pluginHandlers = this.getPluginHandlers();
1595
+ (_a = this.rootPlugins).push.apply(_a, __spreadArray([], __read(pluginHandlers)));
1596
+ };
1597
+ PluginManager.prototype.getPluginHandlers = function () {
1598
+ var handlers = this._pluginHandlers || [];
1599
+ return handlers.map(function (plugin) { return (plugin.handle ? plugin.handle.bind(plugin) : plugin); });
1600
+ };
1601
+ return PluginManager;
1602
+ }());
1603
+ /** @nocollapse */ PluginManager.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PluginManager, deps: [{ token: PluginManager, optional: true, skipSelf: true }, { token: NGXS_PLUGINS, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1604
+ /** @nocollapse */ PluginManager.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PluginManager });
1605
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PluginManager, decorators: [{
1606
+ type: i0.Injectable
1607
+ }], ctorParameters: function () {
1608
+ return [{ type: PluginManager, decorators: [{
1609
+ type: i0.Optional
1610
+ }, {
1611
+ type: i0.SkipSelf
1612
+ }] }, { type: undefined, decorators: [{
1613
+ type: i0.Inject,
1614
+ args: [NGXS_PLUGINS]
1615
+ }, {
1616
+ type: i0.Optional
1617
+ }] }];
1618
+ } });
1619
+
1620
+ /**
1621
+ * BehaviorSubject of the entire state.
1622
+ * @ignore
1623
+ */
1624
+ var StateStream = /** @class */ (function (_super) {
1625
+ __extends(StateStream, _super);
1626
+ function StateStream() {
1627
+ return _super.call(this, {}) || this;
1628
+ }
1629
+ StateStream.prototype.ngOnDestroy = function () {
1630
+ // The `StateStream` should never emit values once the root view is removed, e.g. when the `NgModuleRef.destroy()` is called.
1631
+ // This will eliminate memory leaks in server-side rendered apps where the `StateStream` is created per each HTTP request, users
1632
+ // might forget to unsubscribe from `store.select` or `store.subscribe`, thus this will lead to huge memory leaks in SSR apps.
1633
+ this.complete();
1634
+ };
1635
+ return StateStream;
1636
+ }(OrderedBehaviorSubject));
1637
+ /** @nocollapse */ StateStream.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateStream, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1638
+ /** @nocollapse */ StateStream.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateStream, providedIn: 'root' });
1639
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateStream, decorators: [{
1640
+ type: i0.Injectable,
1641
+ args: [{ providedIn: 'root' }]
1642
+ }], ctorParameters: function () { return []; } });
1643
+
1644
+ /**
1645
+ * Internal Action result stream that is emitted when an action is completed.
1646
+ * This is used as a method of returning the action result to the dispatcher
1647
+ * for the observable returned by the dispatch(...) call.
1648
+ * The dispatcher then asynchronously pushes the result from this stream onto the main action stream as a result.
1649
+ */
1650
+ var InternalDispatchedActionResults = /** @class */ (function (_super) {
1651
+ __extends(InternalDispatchedActionResults, _super);
1652
+ function InternalDispatchedActionResults() {
1653
+ return _super !== null && _super.apply(this, arguments) || this;
1654
+ }
1655
+ return InternalDispatchedActionResults;
1656
+ }(rxjs.Subject));
1657
+ /** @nocollapse */ InternalDispatchedActionResults.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalDispatchedActionResults, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
1658
+ /** @nocollapse */ InternalDispatchedActionResults.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalDispatchedActionResults, providedIn: 'root' });
1659
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalDispatchedActionResults, decorators: [{
1660
+ type: i0.Injectable,
1661
+ args: [{ providedIn: 'root' }]
1662
+ }] });
1663
+ var InternalDispatcher = /** @class */ (function () {
1664
+ function InternalDispatcher(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
1665
+ this._actions = _actions;
1666
+ this._actionResults = _actionResults;
1667
+ this._pluginManager = _pluginManager;
1668
+ this._stateStream = _stateStream;
1669
+ this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
1670
+ this._internalErrorReporter = _internalErrorReporter;
1671
+ }
1672
+ /**
1673
+ * Dispatches event(s).
1674
+ */
1675
+ InternalDispatcher.prototype.dispatch = function (actionOrActions) {
1676
+ var _this = this;
1677
+ var result = this._ngxsExecutionStrategy.enter(function () { return _this.dispatchByEvents(actionOrActions); });
1678
+ return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
1679
+ };
1680
+ InternalDispatcher.prototype.dispatchByEvents = function (actionOrActions) {
1681
+ var _this = this;
1682
+ if (Array.isArray(actionOrActions)) {
1683
+ if (actionOrActions.length === 0)
1684
+ return rxjs.of(this._stateStream.getValue());
1685
+ return rxjs.forkJoin(actionOrActions.map(function (action) { return _this.dispatchSingle(action); }));
1686
+ }
1687
+ else {
1688
+ return this.dispatchSingle(actionOrActions);
1689
+ }
1690
+ };
1691
+ InternalDispatcher.prototype.dispatchSingle = function (action) {
1692
+ var _this = this;
1693
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
1694
+ var type = getActionTypeFromInstance(action);
1695
+ if (!type) {
1696
+ var error = new Error("This action doesn't have a type property: " + action.constructor.name);
1697
+ return rxjs.throwError(error);
1698
+ }
1699
+ }
1700
+ var prevState = this._stateStream.getValue();
1701
+ var plugins = this._pluginManager.plugins;
1702
+ return compose(__spreadArray(__spreadArray([], __read(plugins)), [
1703
+ function (nextState, nextAction) {
1704
+ if (nextState !== prevState) {
1705
+ _this._stateStream.next(nextState);
1706
+ }
1707
+ var actionResult$ = _this.getActionResultStream(nextAction);
1708
+ actionResult$.subscribe(function (ctx) { return _this._actions.next(ctx); });
1709
+ _this._actions.next({ action: nextAction, status: "DISPATCHED" /* Dispatched */ });
1710
+ return _this.createDispatchObservable(actionResult$);
1711
+ }
1712
+ ]))(prevState, action).pipe(operators.shareReplay());
1713
+ };
1714
+ InternalDispatcher.prototype.getActionResultStream = function (action) {
1715
+ return this._actionResults.pipe(operators.filter(function (ctx) { return ctx.action === action && ctx.status !== "DISPATCHED"; } /* Dispatched */), operators.take(1), operators.shareReplay());
1716
+ };
1717
+ InternalDispatcher.prototype.createDispatchObservable = function (actionResult$) {
1718
+ var _this = this;
1719
+ return actionResult$
1720
+ .pipe(operators.exhaustMap(function (ctx) {
1721
+ switch (ctx.status) {
1722
+ case "SUCCESSFUL" /* Successful */:
1723
+ return rxjs.of(_this._stateStream.getValue());
1724
+ case "ERRORED" /* Errored */:
1725
+ return rxjs.throwError(ctx.error);
1726
+ default:
1727
+ return rxjs.EMPTY;
1728
+ }
1729
+ }))
1730
+ .pipe(operators.shareReplay());
1731
+ };
1732
+ return InternalDispatcher;
1733
+ }());
1734
+ /** @nocollapse */ InternalDispatcher.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalDispatcher, deps: [{ token: InternalActions }, { token: InternalDispatchedActionResults }, { token: PluginManager }, { token: StateStream }, { token: InternalNgxsExecutionStrategy }, { token: InternalErrorReporter }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1735
+ /** @nocollapse */ InternalDispatcher.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalDispatcher, providedIn: 'root' });
1736
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalDispatcher, decorators: [{
1737
+ type: i0.Injectable,
1738
+ args: [{ providedIn: 'root' }]
1739
+ }], ctorParameters: function () { return [{ type: InternalActions }, { type: InternalDispatchedActionResults }, { type: PluginManager }, { type: StateStream }, { type: InternalNgxsExecutionStrategy }, { type: InternalErrorReporter }]; } });
1740
+
1741
+ function simplePatch(value) {
1742
+ return function (existingState) {
1743
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
1744
+ if (Array.isArray(value)) {
1745
+ throwPatchingArrayError();
1746
+ }
1747
+ else if (typeof value !== 'object') {
1748
+ throwPatchingPrimitiveError();
1749
+ }
1750
+ }
1751
+ var newState = Object.assign({}, existingState);
1752
+ for (var key in value) {
1753
+ // deep clone for patch compatibility
1754
+ newState[key] = value[key];
1755
+ }
1756
+ return newState;
1757
+ };
1758
+ }
1759
+
1760
+ /**
1761
+ * Object freeze code
1762
+ * https://github.com/jsdf/deep-freeze
1763
+ */
1764
+ var deepFreeze = function (o) {
1765
+ Object.freeze(o);
1766
+ var oIsFunction = typeof o === 'function';
1767
+ var hasOwnProp = Object.prototype.hasOwnProperty;
1768
+ Object.getOwnPropertyNames(o).forEach(function (prop) {
1769
+ if (hasOwnProp.call(o, prop) &&
1770
+ (oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) &&
1771
+ o[prop] !== null &&
1772
+ (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
1773
+ !Object.isFrozen(o[prop])) {
1774
+ deepFreeze(o[prop]);
1775
+ }
1776
+ });
1777
+ return o;
1778
+ };
1779
+
1780
+ /**
1781
+ * @ignore
1782
+ */
1783
+ var InternalStateOperations = /** @class */ (function () {
1784
+ function InternalStateOperations(_stateStream, _dispatcher, _config) {
1785
+ this._stateStream = _stateStream;
1786
+ this._dispatcher = _dispatcher;
1787
+ this._config = _config;
1788
+ }
1789
+ /**
1790
+ * Returns the root state operators.
1791
+ */
1792
+ InternalStateOperations.prototype.getRootStateOperations = function () {
1793
+ var _this = this;
1794
+ var rootStateOperations = {
1795
+ getState: function () { return _this._stateStream.getValue(); },
1796
+ setState: function (newState) { return _this._stateStream.next(newState); },
1797
+ dispatch: function (actionOrActions) { return _this._dispatcher.dispatch(actionOrActions); }
1798
+ };
1799
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
1800
+ return this._config.developmentMode
1801
+ ? ensureStateAndActionsAreImmutable(rootStateOperations)
1802
+ : rootStateOperations;
1803
+ }
1804
+ else {
1805
+ return rootStateOperations;
1806
+ }
1807
+ };
1808
+ InternalStateOperations.prototype.setStateToTheCurrentWithNew = function (results) {
1809
+ var stateOperations = this.getRootStateOperations();
1810
+ // Get our current stream
1811
+ var currentState = stateOperations.getState();
1812
+ // Set the state to the current + new
1813
+ stateOperations.setState(Object.assign(Object.assign({}, currentState), results.defaults));
1814
+ };
1815
+ return InternalStateOperations;
1816
+ }());
1817
+ /** @nocollapse */ InternalStateOperations.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalStateOperations, deps: [{ token: StateStream }, { token: InternalDispatcher }, { token: NgxsConfig }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1818
+ /** @nocollapse */ InternalStateOperations.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalStateOperations, providedIn: 'root' });
1819
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: InternalStateOperations, decorators: [{
1820
+ type: i0.Injectable,
1821
+ args: [{ providedIn: 'root' }]
1822
+ }], ctorParameters: function () { return [{ type: StateStream }, { type: InternalDispatcher }, { type: NgxsConfig }]; } });
1823
+ function ensureStateAndActionsAreImmutable(root) {
1824
+ return {
1825
+ getState: function () { return root.getState(); },
1826
+ setState: function (value) {
1827
+ var frozenValue = deepFreeze(value);
1828
+ return root.setState(frozenValue);
1829
+ },
1830
+ dispatch: function (actions) {
1831
+ return root.dispatch(actions);
1832
+ }
1833
+ };
1834
+ }
1835
+
1836
+ /**
1837
+ * State Context factory class
1838
+ * @ignore
1839
+ */
1840
+ var StateContextFactory = /** @class */ (function () {
1841
+ function StateContextFactory(_internalStateOperations) {
1842
+ this._internalStateOperations = _internalStateOperations;
1843
+ }
1844
+ /**
1845
+ * Create the state context
1846
+ */
1847
+ StateContextFactory.prototype.createStateContext = function (mappedStore) {
1848
+ var root = this._internalStateOperations.getRootStateOperations();
1849
+ return {
1850
+ getState: function () {
1851
+ var currentAppState = root.getState();
1852
+ return getState(currentAppState, mappedStore.path);
1853
+ },
1854
+ patchState: function (val) {
1855
+ var currentAppState = root.getState();
1856
+ var patchOperator = simplePatch(val);
1857
+ return setStateFromOperator(root, currentAppState, patchOperator, mappedStore.path);
1858
+ },
1859
+ setState: function (val) {
1860
+ var currentAppState = root.getState();
1861
+ return operators$1.isStateOperator(val)
1862
+ ? setStateFromOperator(root, currentAppState, val, mappedStore.path)
1863
+ : setStateValue(root, currentAppState, val, mappedStore.path);
1864
+ },
1865
+ dispatch: function (actions) {
1866
+ return root.dispatch(actions);
1867
+ }
1868
+ };
1869
+ };
1870
+ return StateContextFactory;
1871
+ }());
1872
+ /** @nocollapse */ StateContextFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateContextFactory, deps: [{ token: InternalStateOperations }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1873
+ /** @nocollapse */ StateContextFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateContextFactory, providedIn: 'root' });
1874
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateContextFactory, decorators: [{
1875
+ type: i0.Injectable,
1876
+ args: [{ providedIn: 'root' }]
1877
+ }], ctorParameters: function () { return [{ type: InternalStateOperations }]; } });
1878
+ function setStateValue(root, currentAppState, newValue, path) {
1879
+ var newAppState = setValue(currentAppState, path, newValue);
1880
+ root.setState(newAppState);
1881
+ return newAppState;
1882
+ // In doing this refactoring I noticed that there is a 'bug' where the
1883
+ // application state is returned instead of this state slice.
1884
+ // This has worked this way since the beginning see:
1885
+ // https://github.com/ngxs/store/blame/324c667b4b7debd8eb979006c67ca0ae347d88cd/src/state-factory.ts
1886
+ // This needs to be fixed, but is a 'breaking' change.
1887
+ // I will do this fix in a subsequent PR and we can decide how to handle it.
1888
+ }
1889
+ function setStateFromOperator(root, currentAppState, stateOperator, path) {
1890
+ var local = getState(currentAppState, path);
1891
+ var newValue = stateOperator(local);
1892
+ return setStateValue(root, currentAppState, newValue, path);
1893
+ }
1894
+ function getState(currentAppState, path) {
1895
+ return getValue(currentAppState, path);
1896
+ }
1897
+
1898
+ var NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
1899
+ /**
1900
+ * The `StateFactory` class adds root and feature states to the graph.
1901
+ * This extracts state names from state classes, checks if they already
1902
+ * exist in the global graph, throws errors if their names are invalid, etc.
1903
+ * See its constructor, state factories inject state factories that are
1904
+ * parent-level providers. This is required to get feature states from the
1905
+ * injector on the same level.
1906
+ *
1907
+ * The `NgxsModule.forFeature(...)` returns `providers: [StateFactory, ...states]`.
1908
+ * The `StateFactory` is initialized on the feature level and goes through `...states`
1909
+ * to get them from the injector through `injector.get(state)`.
1910
+ * @ignore
1911
+ */
1912
+ var StateFactory = /** @class */ (function () {
1913
+ function StateFactory(_injector, _config, _parentFactory, _actions, _actionResults, _stateContextFactory, _initialState) {
1914
+ var _this = this;
1915
+ this._injector = _injector;
1916
+ this._config = _config;
1917
+ this._parentFactory = _parentFactory;
1918
+ this._actions = _actions;
1919
+ this._actionResults = _actionResults;
1920
+ this._stateContextFactory = _stateContextFactory;
1921
+ this._initialState = _initialState;
1922
+ this._actionsSubscription = null;
1923
+ this._states = [];
1924
+ this._statesByName = {};
1925
+ this._statePaths = {};
1926
+ this.getRuntimeSelectorContext = i5.memoize(function () {
1927
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1928
+ var stateFactory = _this;
1929
+ function resolveGetter(key) {
1930
+ var path = stateFactory.statePaths[key];
1931
+ return path ? propGetter(path.split('.'), stateFactory._config) : null;
1932
+ }
1933
+ var context = _this._parentFactory
1934
+ ? _this._parentFactory.getRuntimeSelectorContext()
1935
+ : {
1936
+ getStateGetter: function (key) {
1937
+ var getter = resolveGetter(key);
1938
+ if (getter) {
1939
+ return getter;
1940
+ }
1941
+ return function () {
1942
+ var args = [];
1943
+ for (var _i = 0; _i < arguments.length; _i++) {
1944
+ args[_i] = arguments[_i];
1945
+ }
1946
+ // Late loaded getter
1947
+ if (!getter) {
1948
+ getter = resolveGetter(key);
1949
+ }
1950
+ return getter ? getter.apply(void 0, __spreadArray([], __read(args))) : undefined;
1951
+ };
1952
+ },
1953
+ getSelectorOptions: function (localOptions) {
1954
+ var globalSelectorOptions = stateFactory._config.selectorOptions;
1955
+ return Object.assign(Object.assign({}, globalSelectorOptions), (localOptions || {}));
1956
+ }
1957
+ };
1958
+ return context;
1959
+ });
1960
+ }
1961
+ Object.defineProperty(StateFactory.prototype, "states", {
1962
+ get: function () {
1963
+ return this._parentFactory ? this._parentFactory.states : this._states;
1964
+ },
1965
+ enumerable: false,
1966
+ configurable: true
1967
+ });
1968
+ Object.defineProperty(StateFactory.prototype, "statesByName", {
1969
+ get: function () {
1970
+ return this._parentFactory ? this._parentFactory.statesByName : this._statesByName;
1971
+ },
1972
+ enumerable: false,
1973
+ configurable: true
1974
+ });
1975
+ Object.defineProperty(StateFactory.prototype, "statePaths", {
1976
+ get: function () {
1977
+ return this._parentFactory ? this._parentFactory.statePaths : this._statePaths;
1978
+ },
1979
+ enumerable: false,
1980
+ configurable: true
1981
+ });
1982
+ StateFactory._cloneDefaults = function (defaults) {
1983
+ var value = defaults;
1984
+ if (Array.isArray(defaults)) {
1985
+ value = defaults.slice();
1986
+ }
1987
+ else if (isObject(defaults)) {
1988
+ value = Object.assign({}, defaults);
1989
+ }
1990
+ else if (defaults === undefined) {
1991
+ value = {};
1992
+ }
1993
+ return value;
1994
+ };
1995
+ StateFactory.prototype.ngOnDestroy = function () {
1996
+ var _a;
1997
+ (_a = this._actionsSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
1998
+ };
1999
+ /**
2000
+ * Add a new state to the global defs.
2001
+ */
2002
+ StateFactory.prototype.add = function (stateClasses) {
2003
+ var e_1, _b;
2004
+ if (NG_DEV_MODE) {
2005
+ ensureStatesAreDecorated(stateClasses);
2006
+ }
2007
+ var newStates = this.addToStatesMap(stateClasses).newStates;
2008
+ if (!newStates.length)
2009
+ return [];
2010
+ var stateGraph = buildGraph(newStates);
2011
+ var sortedStates = topologicalSort(stateGraph);
2012
+ var paths = findFullParentPath(stateGraph);
2013
+ var nameGraph = nameToState(newStates);
2014
+ var bootstrappedStores = [];
2015
+ try {
2016
+ for (var sortedStates_1 = __values(sortedStates), sortedStates_1_1 = sortedStates_1.next(); !sortedStates_1_1.done; sortedStates_1_1 = sortedStates_1.next()) {
2017
+ var name = sortedStates_1_1.value;
2018
+ var stateClass = nameGraph[name];
2019
+ var path = paths[name];
2020
+ var meta = stateClass[META_KEY];
2021
+ this.addRuntimeInfoToMeta(meta, path);
2022
+ // Note: previously we called `ensureStateClassIsInjectable` within the
2023
+ // `State` decorator. This check is moved here because the `ɵprov` property
2024
+ // will not exist on the class in JIT mode (because it's set asynchronously
2025
+ // during JIT compilation through `Object.defineProperty`).
2026
+ if (NG_DEV_MODE) {
2027
+ ensureStateClassIsInjectable(stateClass);
2028
+ }
2029
+ var stateMap = {
2030
+ name: name,
2031
+ path: path,
2032
+ isInitialised: false,
2033
+ actions: meta.actions,
2034
+ instance: this._injector.get(stateClass),
2035
+ defaults: StateFactory._cloneDefaults(meta.defaults)
2036
+ };
2037
+ // ensure our store hasn't already been added
2038
+ // but don't throw since it could be lazy
2039
+ // loaded from different paths
2040
+ if (!this.hasBeenMountedAndBootstrapped(name, path)) {
2041
+ bootstrappedStores.push(stateMap);
2042
+ }
2043
+ this.states.push(stateMap);
2044
+ }
2045
+ }
2046
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2047
+ finally {
2048
+ try {
2049
+ if (sortedStates_1_1 && !sortedStates_1_1.done && (_b = sortedStates_1.return)) _b.call(sortedStates_1);
2050
+ }
2051
+ finally { if (e_1) throw e_1.error; }
2052
+ }
2053
+ return bootstrappedStores;
2054
+ };
2055
+ /**
2056
+ * Add a set of states to the store and return the defaults
2057
+ */
2058
+ StateFactory.prototype.addAndReturnDefaults = function (stateClasses) {
2059
+ var classes = stateClasses || [];
2060
+ var mappedStores = this.add(classes);
2061
+ var defaults = mappedStores.reduce(function (result, mappedStore) { return setValue(result, mappedStore.path, mappedStore.defaults); }, {});
2062
+ return { defaults: defaults, states: mappedStores };
2063
+ };
2064
+ StateFactory.prototype.connectActionHandlers = function () {
2065
+ var _this = this;
2066
+ // Note: We have to connect actions only once when the `StateFactory`
2067
+ // is being created for the first time. This checks if we're in
2068
+ // a child state factory and the parent state factory already exists.
2069
+ if (this._parentFactory || this._actionsSubscription !== null) {
2070
+ return;
2071
+ }
2072
+ var dispatched$ = new rxjs.Subject();
2073
+ this._actionsSubscription = this._actions
2074
+ .pipe(operators.filter(function (ctx) { return ctx.status === "DISPATCHED"; } /* Dispatched */), operators.mergeMap(function (ctx) {
2075
+ dispatched$.next(ctx);
2076
+ var action = ctx.action;
2077
+ return _this.invokeActions(dispatched$, action).pipe(operators.map(function () { return ({ action: action, status: "SUCCESSFUL" /* Successful */ }); }), operators.defaultIfEmpty({ action: action, status: "CANCELED" /* Canceled */ }), operators.catchError(function (error) { return rxjs.of({ action: action, status: "ERRORED" /* Errored */, error: error }); }));
2078
+ }))
2079
+ .subscribe(function (ctx) { return _this._actionResults.next(ctx); });
2080
+ };
2081
+ /**
2082
+ * Invoke actions on the states.
2083
+ */
2084
+ StateFactory.prototype.invokeActions = function (dispatched$, action) {
2085
+ var e_2, _b, e_3, _c;
2086
+ var type = getActionTypeFromInstance(action);
2087
+ var results = [];
2088
+ // Determines whether the dispatched action has been handled, this is assigned
2089
+ // to `true` within the below `for` loop if any `actionMetas` has been found.
2090
+ var actionHasBeenHandled = false;
2091
+ try {
2092
+ for (var _d = __values(this.states), _e = _d.next(); !_e.done; _e = _d.next()) {
2093
+ var metadata = _e.value;
2094
+ var actionMetas = metadata.actions[type];
2095
+ if (actionMetas) {
2096
+ try {
2097
+ for (var actionMetas_1 = (e_3 = void 0, __values(actionMetas)), actionMetas_1_1 = actionMetas_1.next(); !actionMetas_1_1.done; actionMetas_1_1 = actionMetas_1.next()) {
2098
+ var actionMeta = actionMetas_1_1.value;
2099
+ var stateContext = this._stateContextFactory.createStateContext(metadata);
2100
+ try {
2101
+ var result = metadata.instance[actionMeta.fn](stateContext, action);
2102
+ if (result instanceof Promise) {
2103
+ result = rxjs.from(result);
2104
+ }
2105
+ if (rxjs.isObservable(result)) {
2106
+ // If this observable has been completed w/o emitting
2107
+ // any value then we wouldn't want to complete the whole chain
2108
+ // of actions. Since if any observable completes then
2109
+ // action will be canceled.
2110
+ // For instance if any action handler would've had such statement:
2111
+ // `handler(ctx) { return EMPTY; }`
2112
+ // then the action will be canceled.
2113
+ // See https://github.com/ngxs/store/issues/1568
2114
+ result = result.pipe(operators.mergeMap(function (value) {
2115
+ if (value instanceof Promise) {
2116
+ return rxjs.from(value);
2117
+ }
2118
+ if (rxjs.isObservable(value)) {
2119
+ return value;
2120
+ }
2121
+ return rxjs.of(value);
2122
+ }), operators.defaultIfEmpty({}));
2123
+ if (actionMeta.options.cancelUncompleted) {
2124
+ // todo: ofActionDispatched should be used with action class
2125
+ result = result.pipe(operators.takeUntil(dispatched$.pipe(ofActionDispatched(action))));
2126
+ }
2127
+ }
2128
+ else {
2129
+ result = rxjs.of({}).pipe(operators.shareReplay());
2130
+ }
2131
+ results.push(result);
2132
+ }
2133
+ catch (e) {
2134
+ results.push(rxjs.throwError(e));
2135
+ }
2136
+ actionHasBeenHandled = true;
2137
+ }
2138
+ }
2139
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2140
+ finally {
2141
+ try {
2142
+ if (actionMetas_1_1 && !actionMetas_1_1.done && (_c = actionMetas_1.return)) _c.call(actionMetas_1);
2143
+ }
2144
+ finally { if (e_3) throw e_3.error; }
2145
+ }
2146
+ }
2147
+ }
2148
+ }
2149
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2150
+ finally {
2151
+ try {
2152
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
2153
+ }
2154
+ finally { if (e_2) throw e_2.error; }
2155
+ }
2156
+ // The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
2157
+ // only during development.
2158
+ if (NG_DEV_MODE && !actionHasBeenHandled) {
2159
+ var unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
2160
+ // The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
2161
+ // `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
2162
+ // didn't return `null` so we may ensure the module has been imported.
2163
+ if (unhandledActionsLogger) {
2164
+ unhandledActionsLogger.warn(action);
2165
+ }
2166
+ }
2167
+ if (!results.length) {
2168
+ results.push(rxjs.of({}));
2169
+ }
2170
+ return rxjs.forkJoin(results);
2171
+ };
2172
+ StateFactory.prototype.addToStatesMap = function (stateClasses) {
2173
+ var e_4, _b;
2174
+ var newStates = [];
2175
+ var statesMap = this.statesByName;
2176
+ try {
2177
+ for (var stateClasses_1 = __values(stateClasses), stateClasses_1_1 = stateClasses_1.next(); !stateClasses_1_1.done; stateClasses_1_1 = stateClasses_1.next()) {
2178
+ var stateClass = stateClasses_1_1.value;
2179
+ var stateName = getStoreMetadata$1(stateClass).name;
2180
+ if (NG_DEV_MODE) {
2181
+ ensureStateNameIsUnique(stateName, stateClass, statesMap);
2182
+ }
2183
+ var unmountedState = !statesMap[stateName];
2184
+ if (unmountedState) {
2185
+ newStates.push(stateClass);
2186
+ statesMap[stateName] = stateClass;
2187
+ }
2188
+ }
2189
+ }
2190
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
2191
+ finally {
2192
+ try {
2193
+ if (stateClasses_1_1 && !stateClasses_1_1.done && (_b = stateClasses_1.return)) _b.call(stateClasses_1);
2194
+ }
2195
+ finally { if (e_4) throw e_4.error; }
2196
+ }
2197
+ return { newStates: newStates };
2198
+ };
2199
+ StateFactory.prototype.addRuntimeInfoToMeta = function (meta, path) {
2200
+ this.statePaths[meta.name] = path;
2201
+ // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
2202
+ // we can do this when we get rid of the incorrectly exposed getStoreMetadata
2203
+ // We will need to come up with an alternative in v4 because this is used by many plugins
2204
+ meta.path = path;
2205
+ };
2206
+ StateFactory.prototype.hasBeenMountedAndBootstrapped = function (name, path) {
2207
+ var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
2208
+ // This checks whether a state has been already added to the global graph and
2209
+ // its lifecycle is in 'bootstrapped' state.
2210
+ return this.statesByName[name] && valueIsBootstrappedInInitialState;
2211
+ };
2212
+ return StateFactory;
2213
+ }());
2214
+ /** @nocollapse */ StateFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateFactory, deps: [{ token: i0__namespace.Injector }, { token: NgxsConfig }, { token: StateFactory, optional: true, skipSelf: true }, { token: InternalActions }, { token: InternalDispatchedActionResults }, { token: StateContextFactory }, { token: i5.INITIAL_STATE_TOKEN, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2215
+ /** @nocollapse */ StateFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateFactory });
2216
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: StateFactory, decorators: [{
2217
+ type: i0.Injectable
2218
+ }], ctorParameters: function () {
2219
+ return [{ type: i0__namespace.Injector }, { type: NgxsConfig }, { type: StateFactory, decorators: [{
2220
+ type: i0.Optional
2221
+ }, {
2222
+ type: i0.SkipSelf
2223
+ }] }, { type: InternalActions }, { type: InternalDispatchedActionResults }, { type: StateContextFactory }, { type: undefined, decorators: [{
2224
+ type: i0.Optional
2225
+ }, {
2226
+ type: i0.Inject,
2227
+ args: [i5.INITIAL_STATE_TOKEN]
2228
+ }] }];
2229
+ } });
2230
+
2231
+ function createRootSelectorFactory(selectorMetaData, selectors, memoizedSelectorFn) {
2232
+ return function (context) {
2233
+ var _a = getRuntimeSelectorInfo(context, selectorMetaData, selectors), argumentSelectorFunctions = _a.argumentSelectorFunctions, selectorOptions = _a.selectorOptions;
2234
+ return function selectFromRoot(rootState) {
2235
+ // Determine arguments from the app state using the selectors
2236
+ var results = argumentSelectorFunctions.map(function (argFn) { return argFn(rootState); });
2237
+ // if the lambda tries to access a something on the
2238
+ // state that doesn't exist, it will throw a TypeError.
2239
+ // since this is quite usual behaviour, we simply return undefined if so.
2240
+ try {
2241
+ return memoizedSelectorFn.apply(void 0, __spreadArray([], __read(results)));
2242
+ }
2243
+ catch (ex) {
2244
+ if (ex instanceof TypeError && selectorOptions.suppressErrors) {
2245
+ return undefined;
2246
+ }
2247
+ throw ex;
2248
+ }
2249
+ };
2250
+ };
2251
+ }
2252
+ function createMemoizedSelectorFn(originalFn, creationMetadata) {
2253
+ var containerClass = creationMetadata && creationMetadata.containerClass;
2254
+ var wrappedFn = function wrappedSelectorFn() {
2255
+ var args = [];
2256
+ for (var _i = 0; _i < arguments.length; _i++) {
2257
+ args[_i] = arguments[_i];
2258
+ }
2259
+ var returnValue = originalFn.apply(containerClass, args);
2260
+ if (returnValue instanceof Function) {
2261
+ var innerMemoizedFn = i5.memoize.apply(null, [returnValue]);
2262
+ return innerMemoizedFn;
2263
+ }
2264
+ return returnValue;
2265
+ };
2266
+ var memoizedFn = i5.memoize(wrappedFn);
2267
+ Object.setPrototypeOf(memoizedFn, originalFn);
2268
+ return memoizedFn;
2269
+ }
2270
+ function getRuntimeSelectorInfo(context, selectorMetaData, selectors) {
2271
+ if (selectors === void 0) { selectors = []; }
2272
+ var localSelectorOptions = selectorMetaData.getSelectorOptions();
2273
+ var selectorOptions = context.getSelectorOptions(localSelectorOptions);
2274
+ var selectorsToApply = getSelectorsToApply(selectors, selectorOptions, selectorMetaData.containerClass);
2275
+ var argumentSelectorFunctions = selectorsToApply.map(function (selector) {
2276
+ var factory = getRootSelectorFactory(selector);
2277
+ return factory(context);
2278
+ });
2279
+ return {
2280
+ selectorOptions: selectorOptions,
2281
+ argumentSelectorFunctions: argumentSelectorFunctions,
2282
+ };
2283
+ }
2284
+ function getSelectorsToApply(selectors, selectorOptions, containerClass) {
2285
+ if (selectors === void 0) { selectors = []; }
2286
+ var selectorsToApply = [];
2287
+ var canInjectContainerState = selectors.length === 0 || selectorOptions.injectContainerState;
2288
+ if (containerClass && canInjectContainerState) {
2289
+ // If we are on a state class, add it as the first selector parameter
2290
+ var metadata = getStoreMetadata$1(containerClass);
2291
+ if (metadata) {
2292
+ selectorsToApply.push(containerClass);
2293
+ }
2294
+ }
2295
+ if (selectors) {
2296
+ selectorsToApply.push.apply(selectorsToApply, __spreadArray([], __read(selectors)));
2297
+ }
2298
+ return selectorsToApply;
2299
+ }
2300
+ /**
2301
+ * This function gets the factory function to create the selector to get the selected slice from the app state
2302
+ * @ignore
2303
+ */
2304
+ function getRootSelectorFactory(selector) {
2305
+ var metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
2306
+ return (metadata && metadata.makeRootSelector) || (function () { return selector; });
2307
+ }
2308
+
2309
+ // tslint:disable:unified-signatures
2310
+ var Store = /** @class */ (function () {
2311
+ function Store(_stateStream, _internalStateOperations, _config, _internalExecutionStrategy, _stateFactory, initialStateValue) {
2312
+ this._stateStream = _stateStream;
2313
+ this._internalStateOperations = _internalStateOperations;
2314
+ this._config = _config;
2315
+ this._internalExecutionStrategy = _internalExecutionStrategy;
2316
+ this._stateFactory = _stateFactory;
2317
+ /**
2318
+ * This is a derived state stream that leaves NGXS execution strategy to emit state changes within the Angular zone,
2319
+ * because state is being changed actually within the `<root>` zone, see `InternalDispatcher#dispatchSingle`.
2320
+ * All selects would use this stream, and it would call leave only once for any state change across all active selectors.
2321
+ */
2322
+ this._selectableStateStream = this._stateStream.pipe(leaveNgxs(this._internalExecutionStrategy), operators.shareReplay({ bufferSize: 1, refCount: true }));
2323
+ this.initStateStream(initialStateValue);
2324
+ }
2325
+ /**
2326
+ * Dispatches event(s).
2327
+ */
2328
+ Store.prototype.dispatch = function (actionOrActions) {
2329
+ return this._internalStateOperations.getRootStateOperations().dispatch(actionOrActions);
2330
+ };
2331
+ Store.prototype.select = function (selector) {
2332
+ var _this = this;
2333
+ var selectorFn = this.getStoreBoundSelectorFn(selector);
2334
+ return this._selectableStateStream.pipe(operators.map(selectorFn), operators.catchError(function (err) {
2335
+ // if error is TypeError we swallow it to prevent usual errors with property access
2336
+ var suppressErrors = _this._config.selectorOptions.suppressErrors;
2337
+ if (err instanceof TypeError && suppressErrors) {
2338
+ return rxjs.of(undefined);
2339
+ }
2340
+ // rethrow other errors
2341
+ return rxjs.throwError(err);
2342
+ }), operators.distinctUntilChanged(), leaveNgxs(this._internalExecutionStrategy));
2343
+ };
2344
+ Store.prototype.selectOnce = function (selector) {
2345
+ return this.select(selector).pipe(operators.take(1));
2346
+ };
2347
+ Store.prototype.selectSnapshot = function (selector) {
2348
+ var selectorFn = this.getStoreBoundSelectorFn(selector);
2349
+ return selectorFn(this._stateStream.getValue());
2350
+ };
2351
+ /**
2352
+ * Allow the user to subscribe to the root of the state
2353
+ */
2354
+ Store.prototype.subscribe = function (fn) {
2355
+ return this._selectableStateStream
2356
+ .pipe(leaveNgxs(this._internalExecutionStrategy))
2357
+ .subscribe(fn);
2358
+ };
2359
+ /**
2360
+ * Return the raw value of the state.
2361
+ */
2362
+ Store.prototype.snapshot = function () {
2363
+ return this._internalStateOperations.getRootStateOperations().getState();
2364
+ };
2365
+ /**
2366
+ * Reset the state to a specific point in time. This method is useful
2367
+ * for plugin's who need to modify the state directly or unit testing.
2368
+ */
2369
+ Store.prototype.reset = function (state) {
2370
+ return this._internalStateOperations.getRootStateOperations().setState(state);
2371
+ };
2372
+ Store.prototype.getStoreBoundSelectorFn = function (selector) {
2373
+ var makeSelectorFn = getRootSelectorFactory(selector);
2374
+ var runtimeContext = this._stateFactory.getRuntimeSelectorContext();
2375
+ return makeSelectorFn(runtimeContext);
2376
+ };
2377
+ Store.prototype.initStateStream = function (initialStateValue) {
2378
+ var value = this._stateStream.value;
2379
+ var storeIsEmpty = !value || Object.keys(value).length === 0;
2380
+ if (storeIsEmpty) {
2381
+ var defaultStateNotEmpty = Object.keys(this._config.defaultsState).length > 0;
2382
+ var storeValues = defaultStateNotEmpty
2383
+ ? Object.assign(Object.assign({}, this._config.defaultsState), initialStateValue) : initialStateValue;
2384
+ this._stateStream.next(storeValues);
2385
+ }
2386
+ };
2387
+ return Store;
2388
+ }());
2389
+ /** @nocollapse */ Store.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: Store, deps: [{ token: StateStream }, { token: InternalStateOperations }, { token: NgxsConfig }, { token: InternalNgxsExecutionStrategy }, { token: StateFactory }, { token: i5.INITIAL_STATE_TOKEN, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2390
+ /** @nocollapse */ Store.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: Store, providedIn: 'root' });
2391
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: Store, decorators: [{
2392
+ type: i0.Injectable,
2393
+ args: [{ providedIn: 'root' }]
2394
+ }], ctorParameters: function () {
2395
+ return [{ type: StateStream }, { type: InternalStateOperations }, { type: NgxsConfig }, { type: InternalNgxsExecutionStrategy }, { type: StateFactory }, { type: undefined, decorators: [{
2396
+ type: i0.Optional
2397
+ }, {
2398
+ type: i0.Inject,
2399
+ args: [i5.INITIAL_STATE_TOKEN]
2400
+ }] }];
2401
+ } });
2402
+
2403
+ /**
2404
+ * Allows the select decorator to get access to the DI store, this is used internally
2405
+ * in `@Select` decorator.
2406
+ */
2407
+ var SelectFactory = /** @class */ (function () {
2408
+ function SelectFactory(store, config) {
2409
+ SelectFactory.store = store;
2410
+ SelectFactory.config = config;
2411
+ }
2412
+ SelectFactory.prototype.ngOnDestroy = function () {
2413
+ SelectFactory.store = null;
2414
+ SelectFactory.config = null;
2415
+ };
2416
+ return SelectFactory;
2417
+ }());
2418
+ SelectFactory.store = null;
2419
+ SelectFactory.config = null;
2420
+ /** @nocollapse */ SelectFactory.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SelectFactory, deps: [{ token: Store }, { token: NgxsConfig }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2421
+ /** @nocollapse */ SelectFactory.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SelectFactory, providedIn: 'root' });
2422
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SelectFactory, decorators: [{
2423
+ type: i0.Injectable,
2424
+ args: [{ providedIn: 'root' }]
2425
+ }], ctorParameters: function () { return [{ type: Store }, { type: NgxsConfig }]; } });
2426
+
2427
+ var LifecycleStateManager = /** @class */ (function () {
2428
+ function LifecycleStateManager(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
2429
+ this._store = _store;
2430
+ this._internalErrorReporter = _internalErrorReporter;
2431
+ this._internalStateOperations = _internalStateOperations;
2432
+ this._stateContextFactory = _stateContextFactory;
2433
+ this._bootstrapper = _bootstrapper;
2434
+ this._destroy$ = new rxjs.Subject();
2435
+ }
2436
+ LifecycleStateManager.prototype.ngOnDestroy = function () {
2437
+ this._destroy$.next();
2438
+ };
2439
+ LifecycleStateManager.prototype.ngxsBootstrap = function (action, results) {
2440
+ var _this = this;
2441
+ this._internalStateOperations
2442
+ .getRootStateOperations()
2443
+ .dispatch(action)
2444
+ .pipe(operators.filter(function () { return !!results; }), operators.tap(function () { return _this._invokeInitOnStates(results.states); }), operators.mergeMap(function () { return _this._bootstrapper.appBootstrapped$; }), operators.filter(function (appBootstrapped) { return !!appBootstrapped; }), operators.catchError(function (error) {
2445
+ // The `SafeSubscriber` (which is used by most RxJS operators) re-throws
2446
+ // errors asynchronously (`setTimeout(() => { throw error })`). This might
2447
+ // break existing user's code or unit tests. We catch the error manually to
2448
+ // be backward compatible with the old behavior.
2449
+ _this._internalErrorReporter.reportErrorSafely(error);
2450
+ return rxjs.EMPTY;
2451
+ }), operators.takeUntil(this._destroy$))
2452
+ .subscribe(function () { return _this._invokeBootstrapOnStates(results.states); });
2453
+ };
2454
+ LifecycleStateManager.prototype._invokeInitOnStates = function (mappedStores) {
2455
+ var e_1, _a;
2456
+ var _loop_1 = function (mappedStore) {
2457
+ var instance = mappedStore.instance;
2458
+ if (instance.ngxsOnChanges) {
2459
+ this_1._store
2460
+ .select(function (state) { return getValue(state, mappedStore.path); })
2461
+ .pipe(operators.startWith(undefined), operators.pairwise(), operators.takeUntil(this_1._destroy$))
2462
+ .subscribe(function (_a) {
2463
+ var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
2464
+ var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
2465
+ instance.ngxsOnChanges(change);
2466
+ });
2467
+ }
2468
+ if (instance.ngxsOnInit) {
2469
+ instance.ngxsOnInit(this_1._getStateContext(mappedStore));
2470
+ }
2471
+ mappedStore.isInitialised = true;
2472
+ };
2473
+ var this_1 = this;
2474
+ try {
2475
+ for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
2476
+ var mappedStore = mappedStores_1_1.value;
2477
+ _loop_1(mappedStore);
2478
+ }
2479
+ }
2480
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2481
+ finally {
2482
+ try {
2483
+ if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
2484
+ }
2485
+ finally { if (e_1) throw e_1.error; }
2486
+ }
2487
+ };
2488
+ LifecycleStateManager.prototype._invokeBootstrapOnStates = function (mappedStores) {
2489
+ var e_2, _a;
2490
+ try {
2491
+ for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
2492
+ var mappedStore = mappedStores_2_1.value;
2493
+ var instance = mappedStore.instance;
2494
+ if (instance.ngxsAfterBootstrap) {
2495
+ instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
2496
+ }
2497
+ }
2498
+ }
2499
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2500
+ finally {
2501
+ try {
2502
+ if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
2503
+ }
2504
+ finally { if (e_2) throw e_2.error; }
2505
+ }
2506
+ };
2507
+ LifecycleStateManager.prototype._getStateContext = function (mappedStore) {
2508
+ return this._stateContextFactory.createStateContext(mappedStore);
2509
+ };
2510
+ return LifecycleStateManager;
2511
+ }());
2512
+ /** @nocollapse */ LifecycleStateManager.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LifecycleStateManager, deps: [{ token: Store }, { token: InternalErrorReporter }, { token: InternalStateOperations }, { token: StateContextFactory }, { token: i5__namespace.NgxsBootstrapper }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2513
+ /** @nocollapse */ LifecycleStateManager.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LifecycleStateManager, providedIn: 'root' });
2514
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LifecycleStateManager, decorators: [{
2515
+ type: i0.Injectable,
2516
+ args: [{ providedIn: 'root' }]
2517
+ }], ctorParameters: function () { return [{ type: Store }, { type: InternalErrorReporter }, { type: InternalStateOperations }, { type: StateContextFactory }, { type: i5__namespace.NgxsBootstrapper }]; } });
2518
+
2519
+ /**
2520
+ * Root module
2521
+ * @ignore
2522
+ */
2523
+ var NgxsRootModule = /** @class */ (function () {
2524
+ function NgxsRootModule(factory, internalStateOperations, _store, _select, states, lifecycleStateManager) {
2525
+ if (states === void 0) { states = []; }
2526
+ // Add stores to the state graph and return their defaults
2527
+ var results = factory.addAndReturnDefaults(states);
2528
+ internalStateOperations.setStateToTheCurrentWithNew(results);
2529
+ // Connect our actions stream
2530
+ factory.connectActionHandlers();
2531
+ // Dispatch the init action and invoke init and bootstrap functions after
2532
+ lifecycleStateManager.ngxsBootstrap(new InitState(), results);
2533
+ }
2534
+ return NgxsRootModule;
2535
+ }());
2536
+ /** @nocollapse */ NgxsRootModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRootModule, deps: [{ token: StateFactory }, { token: InternalStateOperations }, { token: Store }, { token: SelectFactory }, { token: ROOT_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2537
+ /** @nocollapse */ NgxsRootModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRootModule });
2538
+ /** @nocollapse */ NgxsRootModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRootModule });
2539
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRootModule, decorators: [{
2540
+ type: i0.NgModule
2541
+ }], ctorParameters: function () {
2542
+ return [{ type: StateFactory }, { type: InternalStateOperations }, { type: Store }, { type: SelectFactory }, { type: undefined, decorators: [{
2543
+ type: i0.Optional
2544
+ }, {
2545
+ type: i0.Inject,
2546
+ args: [ROOT_STATE_TOKEN]
2547
+ }] }, { type: LifecycleStateManager }];
2548
+ } });
2549
+
2550
+ /**
2551
+ * Feature module
2552
+ * @ignore
2553
+ */
2554
+ var NgxsFeatureModule = /** @class */ (function () {
2555
+ function NgxsFeatureModule(_store, internalStateOperations, factory, states, lifecycleStateManager) {
2556
+ if (states === void 0) { states = []; }
2557
+ // Since FEATURE_STATE_TOKEN is a multi token, we need to
2558
+ // flatten it [[Feature1State, Feature2State], [Feature3State]]
2559
+ var flattenedStates = NgxsFeatureModule.flattenStates(states);
2560
+ // add stores to the state graph and return their defaults
2561
+ var results = factory.addAndReturnDefaults(flattenedStates);
2562
+ if (results.states.length) {
2563
+ internalStateOperations.setStateToTheCurrentWithNew(results);
2564
+ // dispatch the update action and invoke init and bootstrap functions after
2565
+ lifecycleStateManager.ngxsBootstrap(new UpdateState(results.defaults), results);
2566
+ }
2567
+ }
2568
+ NgxsFeatureModule.flattenStates = function (states) {
2569
+ if (states === void 0) { states = []; }
2570
+ return states.reduce(function (total, values) { return total.concat(values); }, []);
2571
+ };
2572
+ return NgxsFeatureModule;
2573
+ }());
2574
+ /** @nocollapse */ NgxsFeatureModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFeatureModule, deps: [{ token: Store }, { token: InternalStateOperations }, { token: StateFactory }, { token: FEATURE_STATE_TOKEN, optional: true }, { token: LifecycleStateManager }], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2575
+ /** @nocollapse */ NgxsFeatureModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFeatureModule });
2576
+ /** @nocollapse */ NgxsFeatureModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFeatureModule });
2577
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFeatureModule, decorators: [{
2578
+ type: i0.NgModule
2579
+ }], ctorParameters: function () {
2580
+ return [{ type: Store }, { type: InternalStateOperations }, { type: StateFactory }, { type: undefined, decorators: [{
2581
+ type: i0.Optional
2582
+ }, {
2583
+ type: i0.Inject,
2584
+ args: [FEATURE_STATE_TOKEN]
2585
+ }] }, { type: LifecycleStateManager }];
2586
+ } });
2587
+
2588
+ /**
2589
+ * Ngxs Module
2590
+ */
2591
+ var NgxsModule = /** @class */ (function () {
2592
+ function NgxsModule() {
2593
+ }
2594
+ /**
2595
+ * Root module factory
2596
+ */
2597
+ NgxsModule.forRoot = function (states, options) {
2598
+ if (states === void 0) { states = []; }
2599
+ if (options === void 0) { options = {}; }
2600
+ return {
2601
+ ngModule: NgxsRootModule,
2602
+ providers: __spreadArray(__spreadArray([
2603
+ StateFactory,
2604
+ PluginManager
2605
+ ], __read(states)), __read(NgxsModule.ngxsTokenProviders(states, options)))
2606
+ };
2607
+ };
2608
+ /**
2609
+ * Feature module factory
2610
+ */
2611
+ NgxsModule.forFeature = function (states) {
2612
+ if (states === void 0) { states = []; }
2613
+ return {
2614
+ ngModule: NgxsFeatureModule,
2615
+ providers: __spreadArray(__spreadArray([
2616
+ // This is required on the feature level, see comments in `state-factory.ts`.
2617
+ StateFactory,
2618
+ PluginManager
2619
+ ], __read(states)), [
2620
+ {
2621
+ provide: FEATURE_STATE_TOKEN,
2622
+ multi: true,
2623
+ useValue: states
2624
+ }
2625
+ ])
2626
+ };
2627
+ };
2628
+ NgxsModule.ngxsTokenProviders = function (states, options) {
2629
+ return [
2630
+ {
2631
+ provide: USER_PROVIDED_NGXS_EXECUTION_STRATEGY,
2632
+ useValue: options.executionStrategy
2633
+ },
2634
+ {
2635
+ provide: ROOT_STATE_TOKEN,
2636
+ useValue: states
2637
+ },
2638
+ {
2639
+ provide: ROOT_OPTIONS,
2640
+ useValue: options
2641
+ },
2642
+ {
2643
+ provide: i0.APP_BOOTSTRAP_LISTENER,
2644
+ useFactory: NgxsModule.appBootstrapListenerFactory,
2645
+ multi: true,
2646
+ deps: [i5.NgxsBootstrapper]
2647
+ },
2648
+ {
2649
+ provide: i5["ɵNGXS_STATE_CONTEXT_FACTORY"],
2650
+ useExisting: StateContextFactory
2651
+ },
2652
+ {
2653
+ provide: i5["ɵNGXS_STATE_FACTORY"],
2654
+ useExisting: StateFactory
2655
+ }
2656
+ ];
2657
+ };
2658
+ NgxsModule.appBootstrapListenerFactory = function (bootstrapper) {
2659
+ return function () { return bootstrapper.bootstrap(); };
2660
+ };
2661
+ return NgxsModule;
2662
+ }());
2663
+ /** @nocollapse */ NgxsModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2664
+ /** @nocollapse */ NgxsModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsModule });
2665
+ /** @nocollapse */ NgxsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsModule });
2666
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsModule, decorators: [{
2667
+ type: i0.NgModule
2668
+ }] });
2669
+
2670
+ /**
2671
+ * Decorates a method with a action information.
2672
+ */
2673
+ function Action(actions, options) {
2674
+ return function (target, name) {
2675
+ var e_1, _a;
2676
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
2677
+ // creating a breaking change for projects that still use the View Engine.
2678
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2679
+ var isStaticMethod = target.hasOwnProperty('prototype');
2680
+ if (isStaticMethod) {
2681
+ throwActionDecoratorError();
2682
+ }
2683
+ }
2684
+ var meta = ensureStoreMetadata$1(target.constructor);
2685
+ if (!Array.isArray(actions)) {
2686
+ actions = [actions];
2687
+ }
2688
+ try {
2689
+ for (var actions_1 = __values(actions), actions_1_1 = actions_1.next(); !actions_1_1.done; actions_1_1 = actions_1.next()) {
2690
+ var action = actions_1_1.value;
2691
+ var type = action.type;
2692
+ if (!meta.actions[type]) {
2693
+ meta.actions[type] = [];
2694
+ }
2695
+ meta.actions[type].push({
2696
+ fn: name,
2697
+ options: options || {},
2698
+ type: type
2699
+ });
2700
+ }
2701
+ }
2702
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2703
+ finally {
2704
+ try {
2705
+ if (actions_1_1 && !actions_1_1.done && (_a = actions_1.return)) _a.call(actions_1);
2706
+ }
2707
+ finally { if (e_1) throw e_1.error; }
2708
+ }
2709
+ };
2710
+ }
2711
+
2712
+ /**
2713
+ * Decorates a class with ngxs state information.
2714
+ */
2715
+ function State(options) {
2716
+ return function (target) {
2717
+ var stateClass = target;
2718
+ var meta = ensureStoreMetadata$1(stateClass);
2719
+ var inheritedStateClass = Object.getPrototypeOf(stateClass);
2720
+ var optionsWithInheritance = getStateOptions(inheritedStateClass, options);
2721
+ mutateMetaData({ meta: meta, inheritedStateClass: inheritedStateClass, optionsWithInheritance: optionsWithInheritance });
2722
+ stateClass[META_OPTIONS_KEY] = optionsWithInheritance;
2723
+ };
2724
+ }
2725
+ function getStateOptions(inheritedStateClass, options) {
2726
+ var inheritanceOptions = inheritedStateClass[META_OPTIONS_KEY] || {};
2727
+ return Object.assign(Object.assign({}, inheritanceOptions), options);
2728
+ }
2729
+ function mutateMetaData(params) {
2730
+ var meta = params.meta, inheritedStateClass = params.inheritedStateClass, optionsWithInheritance = params.optionsWithInheritance;
2731
+ var children = optionsWithInheritance.children, defaults = optionsWithInheritance.defaults, name = optionsWithInheritance.name;
2732
+ var stateName = typeof name === 'string' ? name : (name && name.getName()) || null;
2733
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2734
+ ensureStateNameIsValid(stateName);
2735
+ }
2736
+ if (inheritedStateClass.hasOwnProperty(META_KEY)) {
2737
+ var inheritedMeta = inheritedStateClass[META_KEY] || {};
2738
+ meta.actions = Object.assign(Object.assign({}, meta.actions), inheritedMeta.actions);
2739
+ }
2740
+ meta.children = children;
2741
+ meta.defaults = defaults;
2742
+ meta.name = stateName;
2743
+ }
2744
+
2745
+ var DOLLAR_CHAR_CODE = 36;
2746
+ function createSelectObservable(selector) {
2747
+ if (!SelectFactory.store) {
2748
+ throwSelectFactoryNotConnectedError();
2749
+ }
2750
+ return SelectFactory.store.select(selector);
2751
+ }
2752
+ function createSelectorFn(name, rawSelector, paths) {
2753
+ if (paths === void 0) { paths = []; }
2754
+ rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
2755
+ if (typeof rawSelector === 'string') {
2756
+ var propsArray = paths.length
2757
+ ? __spreadArray([rawSelector], __read(paths)) : rawSelector.split('.');
2758
+ return propGetter(propsArray, SelectFactory.config);
2759
+ }
2760
+ return rawSelector;
2761
+ }
2762
+ /**
2763
+ * @example If `foo$` => make it just `foo`
2764
+ */
2765
+ function removeDollarAtTheEnd(name) {
2766
+ var lastCharIndex = name.length - 1;
2767
+ var dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
2768
+ return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
2769
+ }
2770
+
2771
+ /**
2772
+ * Decorator for selecting a slice of state from the store.
2773
+ */
2774
+ function Select(rawSelector) {
2775
+ var paths = [];
2776
+ for (var _i = 1; _i < arguments.length; _i++) {
2777
+ paths[_i - 1] = arguments[_i];
2778
+ }
2779
+ return function (target, key) {
2780
+ var _a;
2781
+ var name = key.toString();
2782
+ var selectorId = "__" + name + "__selector";
2783
+ var selector = createSelectorFn(name, rawSelector, paths);
2784
+ Object.defineProperties(target, (_a = {},
2785
+ _a[selectorId] = {
2786
+ writable: true,
2787
+ enumerable: false,
2788
+ configurable: true
2789
+ },
2790
+ _a[name] = {
2791
+ enumerable: true,
2792
+ configurable: true,
2793
+ get: function () {
2794
+ return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
2795
+ }
2796
+ },
2797
+ _a));
2798
+ };
2799
+ }
2800
+
2801
+ var SELECTOR_OPTIONS_META_KEY = 'NGXS_SELECTOR_OPTIONS_META';
2802
+ var selectorOptionsMetaAccessor = {
2803
+ getOptions: function (target) {
2804
+ return (target && target[SELECTOR_OPTIONS_META_KEY]) || {};
2805
+ },
2806
+ defineOptions: function (target, options) {
2807
+ if (!target)
2808
+ return;
2809
+ target[SELECTOR_OPTIONS_META_KEY] = options;
2810
+ },
2811
+ };
2812
+ function setupSelectorMetadata(originalFn, creationMetadata) {
2813
+ var selectorMetaData = ensureSelectorMetadata$1(originalFn);
2814
+ selectorMetaData.originalFn = originalFn;
2815
+ var getExplicitSelectorOptions = function () { return ({}); };
2816
+ if (creationMetadata) {
2817
+ selectorMetaData.containerClass = creationMetadata.containerClass;
2818
+ selectorMetaData.selectorName = creationMetadata.selectorName || null;
2819
+ getExplicitSelectorOptions =
2820
+ creationMetadata.getSelectorOptions || getExplicitSelectorOptions;
2821
+ }
2822
+ var selectorMetaDataClone = Object.assign({}, selectorMetaData);
2823
+ selectorMetaData.getSelectorOptions = function () { return getLocalSelectorOptions(selectorMetaDataClone, getExplicitSelectorOptions()); };
2824
+ return selectorMetaData;
2825
+ }
2826
+ function getLocalSelectorOptions(selectorMetaData, explicitOptions) {
2827
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (selectorOptionsMetaAccessor.getOptions(selectorMetaData.containerClass) || {})), (selectorOptionsMetaAccessor.getOptions(selectorMetaData.originalFn) || {})), (selectorMetaData.getSelectorOptions() || {})), explicitOptions);
2828
+ }
2829
+
2830
+ /**
2831
+ * Decorator for setting selector options at a method or class level.
2832
+ */
2833
+ function SelectorOptions(options) {
2834
+ return (function decorate(target, methodName, descriptor) {
2835
+ if (methodName) {
2836
+ descriptor || (descriptor = Object.getOwnPropertyDescriptor(target, methodName));
2837
+ // Method Decorator
2838
+ var originalFn = descriptor.value || descriptor.originalFn;
2839
+ if (originalFn) {
2840
+ selectorOptionsMetaAccessor.defineOptions(originalFn, options);
2841
+ }
2842
+ }
2843
+ else {
2844
+ // Class Decorator
2845
+ selectorOptionsMetaAccessor.defineOptions(target, options);
2846
+ }
2847
+ });
2848
+ }
2849
+
2850
+ function ensureStoreMetadata(target) {
2851
+ return ensureStoreMetadata$1(target);
2852
+ }
2853
+ function getStoreMetadata(target) {
2854
+ return getStoreMetadata$1(target);
2855
+ }
2856
+ function ensureSelectorMetadata(target) {
2857
+ return ensureSelectorMetadata$1(target);
2858
+ }
2859
+ function getSelectorMetadata(target) {
2860
+ return getSelectorMetadata$1(target);
2861
+ }
2862
+
2863
+ function createSelector(selectors, projector, creationMetadata) {
2864
+ var memoizedFn = createMemoizedSelectorFn(projector, creationMetadata);
2865
+ var selectorMetaData = setupSelectorMetadata(projector, creationMetadata);
2866
+ selectorMetaData.makeRootSelector = createRootSelectorFactory(selectorMetaData, selectors, memoizedFn);
2867
+ return memoizedFn;
2868
+ }
2869
+
2870
+ function Selector(selectors) {
2871
+ return function (target, key, descriptor) {
2872
+ descriptor || (descriptor = Object.getOwnPropertyDescriptor(target, key));
2873
+ var originalFn = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value;
2874
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
2875
+ // creating a breaking change for projects that still use the View Engine.
2876
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2877
+ if (originalFn && typeof originalFn !== 'function') {
2878
+ throwSelectorDecoratorError();
2879
+ }
2880
+ }
2881
+ var memoizedFn = createSelector(selectors, originalFn, {
2882
+ containerClass: target,
2883
+ selectorName: key.toString(),
2884
+ getSelectorOptions: function () {
2885
+ return {};
2886
+ },
2887
+ });
2888
+ var newDescriptor = {
2889
+ configurable: true,
2890
+ get: function () {
2891
+ return memoizedFn;
2892
+ },
2893
+ };
2894
+ // Add hidden property to descriptor
2895
+ newDescriptor['originalFn'] = originalFn;
2896
+ return newDescriptor;
2897
+ };
2898
+ }
2899
+
2900
+ var StateToken = /** @class */ (function () {
2901
+ function StateToken(name) {
2902
+ var _this = this;
2903
+ this.name = name;
2904
+ var selectorMetadata = ensureSelectorMetadata$1(this);
2905
+ selectorMetadata.makeRootSelector = function (runtimeContext) {
2906
+ return runtimeContext.getStateGetter(_this.name);
2907
+ };
2908
+ }
2909
+ StateToken.prototype.getName = function () {
2910
+ return this.name;
2911
+ };
2912
+ StateToken.prototype.toString = function () {
2913
+ return "StateToken[" + this.name + "]";
2914
+ };
2915
+ return StateToken;
2916
+ }());
2917
+
2918
+ var NgxsDevelopmentModule = /** @class */ (function () {
2919
+ function NgxsDevelopmentModule() {
2920
+ }
2921
+ NgxsDevelopmentModule.forRoot = function (options) {
2922
+ return {
2923
+ ngModule: NgxsDevelopmentModule,
2924
+ providers: [
2925
+ NgxsUnhandledActionsLogger,
2926
+ { provide: NGXS_DEVELOPMENT_OPTIONS, useValue: options }
2927
+ ]
2928
+ };
2929
+ };
2930
+ return NgxsDevelopmentModule;
2931
+ }());
2932
+ /** @nocollapse */ NgxsDevelopmentModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsDevelopmentModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2933
+ /** @nocollapse */ NgxsDevelopmentModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsDevelopmentModule });
2934
+ /** @nocollapse */ NgxsDevelopmentModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsDevelopmentModule });
2935
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsDevelopmentModule, decorators: [{
2936
+ type: i0.NgModule
2937
+ }] });
2938
+
2939
+ function ensureValidSelector(selector, context) {
2940
+ if (context === void 0) { context = {}; }
2941
+ var noun = context.noun || 'selector';
2942
+ var prefix = context.prefix ? context.prefix + ': ' : '';
2943
+ ensureValueProvided(selector, { noun: noun, prefix: context.prefix });
2944
+ var metadata = getSelectorMetadata$1(selector) || getStoreMetadata$1(selector);
2945
+ if (!metadata) {
2946
+ throw new Error(prefix + "The value provided as the " + noun + " is not a valid selector.");
2947
+ }
2948
+ }
2949
+ function ensureValueProvided(value, context) {
2950
+ if (context === void 0) { context = {}; }
2951
+ var noun = context.noun || 'value';
2952
+ var prefix = context.prefix ? context.prefix + ': ' : '';
2953
+ if (!value) {
2954
+ throw new Error(prefix + "A " + noun + " must be provided.");
2955
+ }
2956
+ }
2957
+
2958
+ function createModelSelector(selectorMap) {
2959
+ var selectorKeys = Object.keys(selectorMap);
2960
+ var selectors = Object.values(selectorMap);
2961
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2962
+ ensureValidSelectorMap({
2963
+ prefix: '[createModelSelector]',
2964
+ selectorMap: selectorMap,
2965
+ selectorKeys: selectorKeys,
2966
+ selectors: selectors
2967
+ });
2968
+ }
2969
+ return createSelector(selectors, function () {
2970
+ var args = [];
2971
+ for (var _i = 0; _i < arguments.length; _i++) {
2972
+ args[_i] = arguments[_i];
2973
+ }
2974
+ return selectorKeys.reduce(function (obj, key, index) {
2975
+ obj[key] = args[index];
2976
+ return obj;
2977
+ }, {});
2978
+ });
2979
+ }
2980
+ function ensureValidSelectorMap(_a) {
2981
+ var prefix = _a.prefix, selectorMap = _a.selectorMap, selectorKeys = _a.selectorKeys, selectors = _a.selectors;
2982
+ ensureValueProvided(selectorMap, { prefix: prefix, noun: 'selector map' });
2983
+ ensureValueProvided(typeof selectorMap === 'object', { prefix: prefix, noun: 'valid selector map' });
2984
+ ensureValueProvided(selectorKeys.length, { prefix: prefix, noun: 'non-empty selector map' });
2985
+ selectors.forEach(function (selector, index) { return ensureValidSelector(selector, {
2986
+ prefix: prefix,
2987
+ noun: "selector for the '" + selectorKeys[index] + "' property"
2988
+ }); });
2989
+ }
2990
+
2991
+ function createPickSelector(selector, keys) {
2992
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2993
+ ensureValidSelector(selector, { prefix: '[createPickSelector]' });
2994
+ }
2995
+ var validKeys = keys.filter(Boolean);
2996
+ var selectors = validKeys.map(function (key) { return createSelector([selector], function (s) { return s[key]; }); });
2997
+ return createSelector(__spreadArray([], __read(selectors)), function () {
2998
+ var props = [];
2999
+ for (var _i = 0; _i < arguments.length; _i++) {
3000
+ props[_i] = arguments[_i];
3001
+ }
3002
+ return validKeys.reduce(function (acc, key, index) {
3003
+ acc[key] = props[index];
3004
+ return acc;
3005
+ }, {});
3006
+ });
3007
+ }
3008
+
3009
+ function createPropertySelectors(parentSelector) {
3010
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
3011
+ ensureValidSelector(parentSelector, {
3012
+ prefix: '[createPropertySelectors]',
3013
+ noun: 'parent selector'
3014
+ });
3015
+ }
3016
+ var cache = {};
3017
+ return new Proxy({}, {
3018
+ get: function (_target, prop) {
3019
+ var selector = cache[prop] ||
3020
+ createSelector([parentSelector], function (s) { return s === null || s === void 0 ? void 0 : s[prop]; });
3021
+ cache[prop] = selector;
3022
+ return selector;
3023
+ }
3024
+ });
3025
+ }
3026
+
3027
+ /**
3028
+ * The public api for consumers of @ngxs/store
3029
+ */
3030
+
3031
+ /**
3032
+ * Generated bundle index. Do not edit.
3033
+ */
3034
+
3035
+ exports.Action = Action;
3036
+ exports.Actions = Actions;
3037
+ exports.InitState = InitState;
3038
+ exports.NGXS_PLUGINS = NGXS_PLUGINS;
3039
+ exports.NgxsDevelopmentModule = NgxsDevelopmentModule;
3040
+ exports.NgxsModule = NgxsModule;
3041
+ exports.NgxsSimpleChange = NgxsSimpleChange;
3042
+ exports.NgxsUnhandledActionsLogger = NgxsUnhandledActionsLogger;
3043
+ exports.NoopNgxsExecutionStrategy = NoopNgxsExecutionStrategy;
3044
+ exports.Select = Select;
3045
+ exports.Selector = Selector;
3046
+ exports.SelectorOptions = SelectorOptions;
3047
+ exports.State = State;
3048
+ exports.StateStream = StateStream;
3049
+ exports.StateToken = StateToken;
3050
+ exports.Store = Store;
3051
+ exports.UpdateState = UpdateState;
3052
+ exports.actionMatcher = actionMatcher;
3053
+ exports.createModelSelector = createModelSelector;
3054
+ exports.createPickSelector = createPickSelector;
3055
+ exports.createPropertySelectors = createPropertySelectors;
3056
+ exports.createSelector = createSelector;
3057
+ exports.ensureSelectorMetadata = ensureSelectorMetadata;
3058
+ exports.ensureStoreMetadata = ensureStoreMetadata;
3059
+ exports.getActionTypeFromInstance = getActionTypeFromInstance;
3060
+ exports.getSelectorMetadata = getSelectorMetadata;
3061
+ exports.getStoreMetadata = getStoreMetadata;
3062
+ exports.getValue = getValue;
3063
+ exports.ofAction = ofAction;
3064
+ exports.ofActionCanceled = ofActionCanceled;
3065
+ exports.ofActionCompleted = ofActionCompleted;
3066
+ exports.ofActionDispatched = ofActionDispatched;
3067
+ exports.ofActionErrored = ofActionErrored;
3068
+ exports.ofActionSuccessful = ofActionSuccessful;
3069
+ exports.setValue = setValue;
3070
+ exports["ɵNgxsFeatureModule"] = NgxsFeatureModule;
3071
+ exports["ɵNgxsRootModule"] = NgxsRootModule;
3072
+
3073
+ Object.defineProperty(exports, '__esModule', { value: true });
3074
+
3075
+ }));
3076
+ //# sourceMappingURL=ngxs-store.umd.js.map