@zengenti/contensis-react-base 3.0.0-beta.7 → 3.0.0-beta.72

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 (167) hide show
  1. package/README.md +1 -1
  2. package/cjs/{App-3324f784.js → App-80a696bc.js} +210 -179
  3. package/cjs/App-80a696bc.js.map +1 -0
  4. package/cjs/{RouteLoader-c7957b14.js → RouteLoader-2675e1c9.js} +31 -23
  5. package/cjs/RouteLoader-2675e1c9.js.map +1 -0
  6. package/cjs/ToJs-a9a8522b.js +129 -0
  7. package/cjs/ToJs-a9a8522b.js.map +1 -0
  8. package/cjs/VersionInfo-4c9dfa6a.js +181 -0
  9. package/cjs/VersionInfo-4c9dfa6a.js.map +1 -0
  10. package/cjs/{actions-a24bf46e.js → actions-8dc9e8de.js} +5 -4
  11. package/cjs/actions-8dc9e8de.js.map +1 -0
  12. package/cjs/client.js +17 -22
  13. package/cjs/client.js.map +1 -1
  14. package/cjs/contensis-react-base.js +3761 -156
  15. package/cjs/contensis-react-base.js.map +1 -1
  16. package/cjs/forms.js +181 -100
  17. package/cjs/forms.js.map +1 -1
  18. package/cjs/{fromJSLeaveImmer-c00d597f.js → fromJSLeaveImmer-e74c673c.js} +2 -16
  19. package/cjs/fromJSLeaveImmer-e74c673c.js.map +1 -0
  20. package/cjs/{login-c810cc4c.js → login-6b9de6a1.js} +92 -55
  21. package/cjs/login-6b9de6a1.js.map +1 -0
  22. package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
  23. package/cjs/reducers-3a4f8971.js.map +1 -0
  24. package/cjs/redux.js +6 -5
  25. package/cjs/redux.js.map +1 -1
  26. package/cjs/routing.js +5 -4
  27. package/cjs/routing.js.map +1 -1
  28. package/cjs/sagas-24f5607f.js +2052 -0
  29. package/cjs/sagas-24f5607f.js.map +1 -0
  30. package/cjs/search.js +283 -1909
  31. package/cjs/search.js.map +1 -1
  32. package/cjs/{selectors-0ec95076.js → selectors-656da4b7.js} +8 -3
  33. package/cjs/selectors-656da4b7.js.map +1 -0
  34. package/cjs/user.js +21 -12
  35. package/cjs/user.js.map +1 -1
  36. package/cjs/util.js +55 -212
  37. package/cjs/util.js.map +1 -1
  38. package/cjs/{version-4f0f5fa6.js → version-330551f5.js} +34 -22
  39. package/cjs/version-330551f5.js.map +1 -0
  40. package/cjs/{version-085d203d.js → version-eba6d09b.js} +5 -5
  41. package/cjs/version-eba6d09b.js.map +1 -0
  42. package/esm/{App-1b05ab11.js → App-af0670fa.js} +210 -180
  43. package/esm/App-af0670fa.js.map +1 -0
  44. package/esm/{RouteLoader-e5f0e8cb.js → RouteLoader-f96a61c1.js} +31 -23
  45. package/esm/RouteLoader-f96a61c1.js.map +1 -0
  46. package/esm/ToJs-affd73f1.js +99 -0
  47. package/esm/ToJs-affd73f1.js.map +1 -0
  48. package/esm/VersionInfo-f5403b09.js +172 -0
  49. package/esm/VersionInfo-f5403b09.js.map +1 -0
  50. package/esm/{actions-927d9698.js → actions-fcfc8704.js} +5 -4
  51. package/esm/actions-fcfc8704.js.map +1 -0
  52. package/esm/client.js +18 -23
  53. package/esm/client.js.map +1 -1
  54. package/esm/contensis-react-base.js +3759 -155
  55. package/esm/contensis-react-base.js.map +1 -1
  56. package/esm/forms.js +182 -102
  57. package/esm/forms.js.map +1 -1
  58. package/esm/{fromJSLeaveImmer-392af4e3.js → fromJSLeaveImmer-0114ffcf.js} +2 -16
  59. package/esm/fromJSLeaveImmer-0114ffcf.js.map +1 -0
  60. package/esm/{login-f8ba3aeb.js → login-ca2dc2f7.js} +92 -55
  61. package/esm/login-ca2dc2f7.js.map +1 -0
  62. package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
  63. package/esm/reducers-8e5d6232.js.map +1 -0
  64. package/esm/redux.js +8 -7
  65. package/esm/redux.js.map +1 -1
  66. package/esm/routing.js +5 -4
  67. package/esm/routing.js.map +1 -1
  68. package/esm/sagas-489c29ca.js +1966 -0
  69. package/esm/sagas-489c29ca.js.map +1 -0
  70. package/esm/search.js +243 -1850
  71. package/esm/search.js.map +1 -1
  72. package/esm/{selectors-b98d5c76.js → selectors-337be432.js} +7 -4
  73. package/esm/selectors-337be432.js.map +1 -0
  74. package/esm/user.js +23 -14
  75. package/esm/user.js.map +1 -1
  76. package/esm/util.js +54 -209
  77. package/esm/util.js.map +1 -1
  78. package/esm/version-6dd7b2cd.js +15 -0
  79. package/esm/version-6dd7b2cd.js.map +1 -0
  80. package/esm/{version-16aa83eb.js → version-c7268214.js} +33 -22
  81. package/esm/version-c7268214.js.map +1 -0
  82. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  83. package/models/forms/index.d.ts +3 -1
  84. package/models/index.d.ts +1 -0
  85. package/models/redux/appstate.d.ts +5 -10
  86. package/models/redux/selectors/navigation.d.ts +2 -1
  87. package/models/routing/components/RouteLoader.d.ts +2 -19
  88. package/models/routing/redux/actions.d.ts +1 -1
  89. package/models/routing/redux/selectors.d.ts +1 -1
  90. package/models/routing/routes.d.ts +9 -3
  91. package/models/routing/util/expressions.d.ts +3 -2
  92. package/models/routing/util/queries.d.ts +1 -1
  93. package/models/search/containers/withListing.d.ts +1 -1
  94. package/models/search/containers/withSearch.d.ts +1 -1
  95. package/models/search/hooks/useFacets.hook.d.ts +3 -0
  96. package/models/search/hooks/useListing.hook.d.ts +3 -0
  97. package/models/search/hooks/useMinilist.hook.d.ts +2 -9
  98. package/models/search/index.d.ts +4 -1
  99. package/models/search/models/Queries.d.ts +8 -5
  100. package/models/search/models/Search.d.ts +60 -28
  101. package/models/search/models/SearchActions.d.ts +4 -3
  102. package/models/search/models/SearchProps.d.ts +52 -7
  103. package/models/search/models/SearchState.d.ts +5 -1
  104. package/models/search/models/index.d.ts +3 -1
  105. package/models/search/redux/actions.d.ts +2 -1
  106. package/models/search/redux/reducers.d.ts +230 -314
  107. package/models/search/redux/sagas.d.ts +5 -5
  108. package/models/search/redux/selectors.d.ts +19 -22
  109. package/models/search/search/ContensisDeliveryApi.d.ts +1 -0
  110. package/models/search/search/expressions.d.ts +3 -6
  111. package/models/search/{redux → search}/queries.d.ts +0 -0
  112. package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -1
  113. package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
  114. package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
  115. package/models/search/transformations/index.d.ts +3 -0
  116. package/models/search/transformations/queryParams-to-customapi.mapper.d.ts +3 -0
  117. package/models/search/transformations/state-to-searchuri.d.ts +2 -13
  118. package/models/server/features/linkdepth-api/api.d.ts +12 -0
  119. package/models/server/features/linkdepth-api/events-api.config.d.ts +37 -0
  120. package/models/server/middleware/bundleManipulation.d.ts +2 -1
  121. package/models/server/util/bundles.d.ts +17 -21
  122. package/models/server/util/getVersionInfo.d.ts +1 -0
  123. package/models/server/util/headers.d.ts +3 -2
  124. package/models/user/components/Login.d.ts +1 -2
  125. package/models/user/components/LoginForm.d.ts +1 -2
  126. package/models/user/hocs/withLogin.d.ts +4 -2
  127. package/models/user/hocs/withRegistration.d.ts +4 -2
  128. package/models/user/hooks/useChangePassword.d.ts +5 -5
  129. package/models/user/hooks/useForgotPassword.d.ts +6 -6
  130. package/models/user/hooks/useLogin.d.ts +9 -45
  131. package/models/user/hooks/useRegistration.d.ts +4 -4
  132. package/models/user/redux/reducers.d.ts +4 -5
  133. package/models/user/redux/sagas/login.d.ts +11 -8
  134. package/models/user/redux/selectors.d.ts +33 -71
  135. package/models/user/util/LoginHelper.class.d.ts +4 -3
  136. package/models/util/ContensisDeliveryApi.d.ts +1 -3
  137. package/models/util/json-mapper.d.ts +9 -3
  138. package/models/util/merge.d.ts +1 -0
  139. package/package.json +60 -55
  140. package/CHANGELOG.md +0 -293
  141. package/cjs/App-3324f784.js.map +0 -1
  142. package/cjs/RouteLoader-c7957b14.js.map +0 -1
  143. package/cjs/ToJs-a38fa20e.js +0 -230
  144. package/cjs/ToJs-a38fa20e.js.map +0 -1
  145. package/cjs/actions-a24bf46e.js.map +0 -1
  146. package/cjs/fromJSLeaveImmer-c00d597f.js.map +0 -1
  147. package/cjs/login-c810cc4c.js.map +0 -1
  148. package/cjs/reducers-fde41d6b.js.map +0 -1
  149. package/cjs/selectors-0ec95076.js.map +0 -1
  150. package/cjs/version-085d203d.js.map +0 -1
  151. package/cjs/version-4f0f5fa6.js.map +0 -1
  152. package/esm/App-1b05ab11.js.map +0 -1
  153. package/esm/RouteLoader-e5f0e8cb.js.map +0 -1
  154. package/esm/ToJs-879a5a85.js +0 -199
  155. package/esm/ToJs-879a5a85.js.map +0 -1
  156. package/esm/actions-927d9698.js.map +0 -1
  157. package/esm/fromJSLeaveImmer-392af4e3.js.map +0 -1
  158. package/esm/login-f8ba3aeb.js.map +0 -1
  159. package/esm/reducers-d6c0edb1.js.map +0 -1
  160. package/esm/selectors-b98d5c76.js.map +0 -1
  161. package/esm/version-16aa83eb.js.map +0 -1
  162. package/esm/version-3833e8b5.js +0 -15
  163. package/esm/version-3833e8b5.js.map +0 -1
  164. package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
  165. package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
  166. package/models/server/features/caching/cacheHashing.d.ts +0 -1
  167. package/package-lock.json +0 -14093
@@ -0,0 +1,1966 @@
1
+ import * as log from 'loglevel';
2
+ import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
3
+ import { Client } from 'contensis-delivery-api';
4
+ import { stringify, parse } from 'query-string';
5
+ import mapJson, { jpath } from 'jsonpath-mapper';
6
+ import { Op, OrderBy, Query } from 'contensis-core-api';
7
+ import merge from 'deepmerge';
8
+
9
+ const ACTION_PREFIX = '@SEARCH/';
10
+ const APPLY_CONFIG = `${ACTION_PREFIX}APPLY_CONFIG`;
11
+ const CLEAR_FILTERS = `${ACTION_PREFIX}CLEAR_FILTERS`;
12
+ const DO_SEARCH = `${ACTION_PREFIX}DO_SEARCH`;
13
+ const EXECUTE_SEARCH = `${ACTION_PREFIX}EXECUTE_SEARCH`;
14
+ const EXECUTE_SEARCH_ERROR = `${ACTION_PREFIX}EXECUTE_SEARCH_ERROR`;
15
+ const EXECUTE_SEARCH_PRELOAD = `${ACTION_PREFIX}EXECUTE_SEARCH_PRELOAD`;
16
+ const LOAD_FILTERS = `${ACTION_PREFIX}LOAD_FILTERS`;
17
+ const LOAD_FILTERS_COMPLETE = `${ACTION_PREFIX}LOAD_FILTERS_COMPLETE`;
18
+ const LOAD_FILTERS_ERROR = `${ACTION_PREFIX}LOAD_FILTERS_ERROR`;
19
+ const SET_FEATURED_ENTRIES = `${ACTION_PREFIX}SET_FEATURED_ENTRIES`;
20
+ const SET_ROUTE_FILTERS = `${ACTION_PREFIX}SET_ROUTE_FILTERS`;
21
+ const SET_SEARCH_FILTERS = `${ACTION_PREFIX}SET_SEARCH_FILTERS`;
22
+ const SET_SEARCH_ENTRIES = `${ACTION_PREFIX}SET_SEARCH_ENTRIES`;
23
+ const SET_SELECTED_FILTER = `${ACTION_PREFIX}SET_SELECTED_FILTER`;
24
+ const UPDATE_CURRENT_FACET = `${ACTION_PREFIX}UPDATE_CURRENT_FACET`;
25
+ const UPDATE_CURRENT_TAB = `${ACTION_PREFIX}UPDATE_CURRENT_TAB`;
26
+ const UPDATE_SORT_ORDER = `${ACTION_PREFIX}UPDATE_SORT_ORDER`;
27
+ const UPDATE_PAGE_INDEX = `${ACTION_PREFIX}UPDATE_PAGE_INDEX`;
28
+ const UPDATE_SEARCH_TERM = `${ACTION_PREFIX}UPDATE_SEARCH_TERM`;
29
+ const UPDATE_SELECTED_FILTERS = `${ACTION_PREFIX}UPDATE_SELECTED_FILTERS`;
30
+
31
+ var types = /*#__PURE__*/Object.freeze({
32
+ __proto__: null,
33
+ APPLY_CONFIG: APPLY_CONFIG,
34
+ CLEAR_FILTERS: CLEAR_FILTERS,
35
+ DO_SEARCH: DO_SEARCH,
36
+ EXECUTE_SEARCH: EXECUTE_SEARCH,
37
+ EXECUTE_SEARCH_ERROR: EXECUTE_SEARCH_ERROR,
38
+ EXECUTE_SEARCH_PRELOAD: EXECUTE_SEARCH_PRELOAD,
39
+ LOAD_FILTERS: LOAD_FILTERS,
40
+ LOAD_FILTERS_COMPLETE: LOAD_FILTERS_COMPLETE,
41
+ LOAD_FILTERS_ERROR: LOAD_FILTERS_ERROR,
42
+ SET_FEATURED_ENTRIES: SET_FEATURED_ENTRIES,
43
+ SET_ROUTE_FILTERS: SET_ROUTE_FILTERS,
44
+ SET_SEARCH_FILTERS: SET_SEARCH_FILTERS,
45
+ SET_SEARCH_ENTRIES: SET_SEARCH_ENTRIES,
46
+ SET_SELECTED_FILTER: SET_SELECTED_FILTER,
47
+ UPDATE_CURRENT_FACET: UPDATE_CURRENT_FACET,
48
+ UPDATE_CURRENT_TAB: UPDATE_CURRENT_TAB,
49
+ UPDATE_SORT_ORDER: UPDATE_SORT_ORDER,
50
+ UPDATE_PAGE_INDEX: UPDATE_PAGE_INDEX,
51
+ UPDATE_SEARCH_TERM: UPDATE_SEARCH_TERM,
52
+ UPDATE_SELECTED_FILTERS: UPDATE_SELECTED_FILTERS
53
+ });
54
+
55
+ const withMappers = (action, mappers) => {
56
+ return { ...action,
57
+ mappers
58
+ };
59
+ };
60
+ const triggerSearch = ({
61
+ config,
62
+ context,
63
+ debug,
64
+ defaultLang,
65
+ excludeIds,
66
+ facet,
67
+ mapper,
68
+ mappers,
69
+ params
70
+ }) => {
71
+ return {
72
+ type: DO_SEARCH,
73
+ config,
74
+ context,
75
+ debug,
76
+ defaultLang,
77
+ excludeIds,
78
+ facet,
79
+ mapper,
80
+ mappers,
81
+ params
82
+ };
83
+ };
84
+ const initListing = ({
85
+ context,
86
+ facet,
87
+ mapper,
88
+ params
89
+ }) => {
90
+ return {
91
+ type: SET_ROUTE_FILTERS,
92
+ context,
93
+ facet,
94
+ mapper,
95
+ params
96
+ };
97
+ };
98
+ const navigate = (path, state) => {
99
+ return {
100
+ type: '@ROUTING/_SET_ROUTE',
101
+ path,
102
+ state
103
+ };
104
+ };
105
+ const clearFilters$1 = () => {
106
+ return {
107
+ type: CLEAR_FILTERS
108
+ };
109
+ };
110
+ const updatePageIndex$1 = (pageIndex, scrollYPos) => {
111
+ return {
112
+ type: UPDATE_PAGE_INDEX,
113
+ pageIndex,
114
+ scrollYPos
115
+ };
116
+ };
117
+ const updateCurrentFacet$1 = facet => {
118
+ return {
119
+ type: UPDATE_CURRENT_FACET,
120
+ facet
121
+ };
122
+ };
123
+ const updateCurrentTab$1 = id => {
124
+ return {
125
+ type: UPDATE_CURRENT_TAB,
126
+ id
127
+ };
128
+ };
129
+ const updateSearchTerm$1 = term => {
130
+ return {
131
+ type: UPDATE_SEARCH_TERM,
132
+ term
133
+ };
134
+ };
135
+ const updateSelectedFilters = (filter, key, isUnknownItem = false, scrollYPos) => {
136
+ return {
137
+ type: UPDATE_SELECTED_FILTERS,
138
+ filter,
139
+ key,
140
+ isUnknownItem,
141
+ scrollYPos
142
+ };
143
+ };
144
+ const updateSortOrder$1 = (orderBy, facet) => {
145
+ return {
146
+ type: UPDATE_SORT_ORDER,
147
+ orderBy,
148
+ facet
149
+ };
150
+ };
151
+
152
+ var actions = /*#__PURE__*/Object.freeze({
153
+ __proto__: null,
154
+ withMappers: withMappers,
155
+ triggerSearch: triggerSearch,
156
+ initListing: initListing,
157
+ navigate: navigate,
158
+ clearFilters: clearFilters$1,
159
+ updatePageIndex: updatePageIndex$1,
160
+ updateCurrentFacet: updateCurrentFacet$1,
161
+ updateCurrentTab: updateCurrentTab$1,
162
+ updateSearchTerm: updateSearchTerm$1,
163
+ updateSelectedFilters: updateSelectedFilters,
164
+ updateSortOrder: updateSortOrder$1
165
+ });
166
+
167
+ let Context; // export type Context = 'facets' | 'listings' | 'minilist';
168
+
169
+ (function (Context) {
170
+ Context["facets"] = "facets";
171
+ Context["listings"] = "listings";
172
+ Context["minilist"] = "minilist";
173
+ })(Context || (Context = {}));
174
+
175
+ // or replace with a stub function for non-immutable gets
176
+
177
+ const makeFromJS = (returnType = globalThis.STATE_TYPE || 'immutable') => {
178
+ var _immutable, _immutable2;
179
+
180
+ return returnType === 'immutable' ? ((_immutable = globalThis.immutable) === null || _immutable === void 0 ? void 0 : _immutable.fromJSOrdered) || ((_immutable2 = globalThis.immutable) === null || _immutable2 === void 0 ? void 0 : _immutable2.fromJS) || (v => v) : v => v;
181
+ };
182
+
183
+ const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThis.STATE_TYPE || 'immutable') => {
184
+ // Find a fromJS function from global that is dynamically loaded in createStore
185
+ // or replace with a stub function for non-immutable gets
186
+ const fromJS = makeFromJS(returnType);
187
+
188
+ if (state && 'get' in state && typeof state.get === 'function' && 'getIn' in state && typeof state.getIn === 'function' && 'toJS' in state && typeof state.toJS === 'function') {
189
+ if (Array.isArray(stateKey)) return fromJS(state.getIn(stateKey, fallbackValue));
190
+ return fromJS(state.get(stateKey, fallbackValue));
191
+ }
192
+
193
+ if (Array.isArray(stateKey) && state && typeof state === 'object') {
194
+ const result = jpath(stateKey.join('.'), state);
195
+ if (typeof result === 'undefined') return fallbackValue;
196
+ return result;
197
+ }
198
+
199
+ const result = state && typeof state === 'object' ? state[stateKey] : undefined;
200
+ if (typeof result === 'undefined') return fallbackValue;
201
+ return result;
202
+ };
203
+
204
+ const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context.facets);
205
+ const getCurrent = (state, context = Context.facets) => context === Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
206
+ const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
207
+ const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
208
+ const getCurrentTab = state => getImmutableOrJS(state, ['search', Context.facets, getCurrentFacet(state), 'tabId'], 0);
209
+ const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context.facets], {}, returnType);
210
+ const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
211
+ const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
212
+ var _facet$pagingInfo;
213
+
214
+ return {
215
+ isSelected: getCurrentFacet(state) === key,
216
+ key,
217
+ title: facet.title,
218
+ totalCount: (_facet$pagingInfo = facet.pagingInfo) === null || _facet$pagingInfo === void 0 ? void 0 : _facet$pagingInfo.totalCount
219
+ };
220
+ });
221
+ const getFacet = (state, facetName = '', context = Context.facets, returnType) => {
222
+ const currentFacet = facetName || getCurrentFacet(state);
223
+ return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
224
+ };
225
+ const getListing = (state, listing = '') => {
226
+ const currentListing = listing || getCurrentListing(state);
227
+ return getImmutableOrJS(state, ['search', Context.listings, currentListing], {});
228
+ };
229
+ const getFilters = (state, facet, context = Context.facets, returnType) => {
230
+ return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
231
+ };
232
+ const getRenderableFilters = (state, facet = '', context = Context.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
233
+ const getFiltersToLoad = (state, facet, context = Context.facets, returnType) => {
234
+ const filters = getFilters(state, facet, context, returnType);
235
+ const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
236
+ const title = i === null || i === void 0 ? void 0 : i.title;
237
+ return typeof title !== 'undefined' && !!title;
238
+ }).length > 0 && (f.isError || false) === false]);
239
+ return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
240
+ }; // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
241
+
242
+ const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
243
+ const filters = getFilters(state, facet, context, 'js');
244
+ const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
245
+ const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
246
+ const key = (item === null || item === void 0 ? void 0 : item.key) || '';
247
+ const isIsoDate = isoDateRegex.test(key);
248
+ return isIsoDate ? key : typeof key.toLowerCase !== 'undefined' ? key.toLowerCase() : key;
249
+ })]));
250
+ const fromJS = makeFromJS(returnType);
251
+ return fromJS(selectedFilters);
252
+ };
253
+ const getResults = (state, current = '', context = Context.facets, returnType) => {
254
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
255
+ };
256
+ const getIsInternalPaging = (state, current, context = Context.facets) => {
257
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
258
+ };
259
+ const getIsLoaded = (state, context = Context.facets, facet) => {
260
+ return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
261
+ };
262
+ const getIsLoading = (state, context = Context.facets, facet) => {
263
+ return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
264
+ };
265
+ const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
266
+ const getFeaturedResults = (state, current = '', context = Context.facets, returnType) => {
267
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], [], returnType);
268
+ };
269
+ const getPaging = (state, current = '', context = Context.facets, returnType) => {
270
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
271
+ };
272
+ const getPageIndex = (state, current = '', context = Context.facets) => {
273
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
274
+ };
275
+ const getPrevPageIndex = (state, current = '', context = Context.facets) => {
276
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
277
+ };
278
+ const getPageIsLoading = (state, current = '', context = Context.facets) => {
279
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
280
+ };
281
+ const getPagesLoaded = (state, current = '', context = Context.facets) => {
282
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
283
+ };
284
+ const getTotalCount = (state, current = '', context = Context.facets) => {
285
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
286
+ };
287
+ const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
288
+ const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
289
+ const getQueryParams = (state, current = '', context = Context.facets) => {
290
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
291
+ };
292
+ const getQueryParameter = ({
293
+ state,
294
+ facet,
295
+ context = Context.facets
296
+ }, key, ifnull = null) => {
297
+ return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
298
+ };
299
+ const getCustomApi = (state, current, context = Context.facets, returnType) => {
300
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
301
+ };
302
+ const getCustomEnv = (state, current, context = Context.facets) => {
303
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
304
+ };
305
+ const getTabsAndFacets = (state, returnType) => {
306
+ const tabs = getSearchTabs(state, 'js');
307
+ const facets = getFacets(state, 'js');
308
+ const tabsAndFacets = (tabs || []).map((tab = {}) => {
309
+ const fieldsToCount = tab.totalCount;
310
+ let countFields;
311
+ if (typeof fieldsToCount === 'string') countFields = [[fieldsToCount]];
312
+ const thisTabFacets = Object.entries(facets).filter(([key]) => getImmutableOrJS(facets, [key, 'tabId'], 0) === tab.id);
313
+ const thisTabTotal = thisTabFacets.map(([facetName, facet = {}]) => {
314
+ if (!countFields || countFields.find((f = []) => (f === null || f === void 0 ? void 0 : f[0]) === facetName)) return getImmutableOrJS(facet, ['pagingInfo', 'totalCount']);
315
+ return 0;
316
+ }).reduce((a, b) => a + b, 0);
317
+ return { ...tab,
318
+ [Context.facets]: Object.fromEntries(thisTabFacets),
319
+ totalCount: thisTabTotal
320
+ };
321
+ });
322
+ const fromJS = makeFromJS(returnType);
323
+ return fromJS(tabsAndFacets);
324
+ };
325
+ const getSearchTotalCount = state => {
326
+ const tabsAndFacets = getTabsAndFacets(state, 'js');
327
+ const wholeSearchTotal = tabsAndFacets.map((t = {}) => t.totalCount).reduce((a, b) => a + b, 0);
328
+ return wholeSearchTotal;
329
+ };
330
+ const getFacetsTotalCount = state => {
331
+ const facets = getFacets(state);
332
+ const wholeSearchTotal = Object.entries(facets).map(([, t = {}]) => {
333
+ var _t$pagingInfo;
334
+
335
+ return ((_t$pagingInfo = t.pagingInfo) === null || _t$pagingInfo === void 0 ? void 0 : _t$pagingInfo.totalCount) || 0;
336
+ }).reduce((a, b) => a + b, 0);
337
+ return wholeSearchTotal;
338
+ }; // An exported copy of the relevant selectors scoped by default to a facets context
339
+
340
+ const selectFacets = {
341
+ getCurrent: getCurrentFacet,
342
+ getCurrentTab,
343
+ getCustomApi,
344
+ getCustomEnv,
345
+ getFacet,
346
+ getFacetTitles,
347
+ getFacets,
348
+ getFacetsTotalCount,
349
+ getFeaturedResults,
350
+ getFilters,
351
+ getFiltersToLoad,
352
+ getIsLoaded,
353
+ getIsLoading,
354
+ getPageIndex,
355
+ getPageIsLoading,
356
+ getPagesLoaded,
357
+ getPaging,
358
+ getQueryParams: (state, facet) => getQueryParams(state, facet, Context.facets),
359
+ getQueryParameter: ({
360
+ state,
361
+ facet
362
+ }, key, ifnull) => getQueryParameter({
363
+ state,
364
+ facet,
365
+ context: Context.facets
366
+ }, key, ifnull),
367
+ getRenderableFilters,
368
+ getResults,
369
+ getTabFacets,
370
+ getTabsAndFacets,
371
+ getTotalCount,
372
+ getSearchTabs,
373
+ getSearchTerm,
374
+ getSearchTotalCount,
375
+ getSelectedFilters
376
+ }; // An exported copy of the relevant selectors pre-scoped to a listing context
377
+
378
+ const selectListing = {
379
+ getCurrent: getCurrentListing,
380
+ getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context.listings, 'js'),
381
+ getFilters: (state, listing = '') => getFilters(state, listing, Context.listings, 'js'),
382
+ getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context.listings),
383
+ getListing,
384
+ getIsLoaded: state => getIsLoaded(state, Context.listings),
385
+ getIsLoading: state => getIsLoading(state, Context.listings),
386
+ getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context.listings),
387
+ getPaging: (state, listing = '') => getPaging(state, listing, Context.listings, 'js'),
388
+ getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context.listings),
389
+ getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context.listings),
390
+ getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context.listings),
391
+ getQueryParameter: ({
392
+ state,
393
+ facet
394
+ }, key, ifnull) => getQueryParameter({
395
+ state,
396
+ facet,
397
+ context: Context.listings
398
+ }, key, ifnull),
399
+ getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context.listings),
400
+ getResults: (state, listing = '') => getResults(state, listing, Context.listings, 'js'),
401
+ getSearchTerm,
402
+ getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context.listings),
403
+ getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context.listings, 'js')
404
+ };
405
+ const selectCurrentPath = state => getImmutableOrJS(state, ['routing', 'currentPath']);
406
+ const selectCurrentProject = state => getImmutableOrJS(state, ['routing', 'currentProject']);
407
+ const selectVersionStatus = state => getImmutableOrJS(state, ['version', 'contensisVersionStatus']);
408
+
409
+ var selectors = /*#__PURE__*/Object.freeze({
410
+ __proto__: null,
411
+ getSearchContext: getSearchContext,
412
+ getCurrent: getCurrent,
413
+ getCurrentFacet: getCurrentFacet,
414
+ getCurrentListing: getCurrentListing,
415
+ getCurrentTab: getCurrentTab,
416
+ getFacets: getFacets,
417
+ getTabFacets: getTabFacets,
418
+ getFacetTitles: getFacetTitles,
419
+ getFacet: getFacet,
420
+ getListing: getListing,
421
+ getFilters: getFilters,
422
+ getRenderableFilters: getRenderableFilters,
423
+ getFiltersToLoad: getFiltersToLoad,
424
+ getSelectedFilters: getSelectedFilters,
425
+ getResults: getResults,
426
+ getIsInternalPaging: getIsInternalPaging,
427
+ getIsLoaded: getIsLoaded,
428
+ getIsLoading: getIsLoading,
429
+ getIsSsr: getIsSsr,
430
+ getFeaturedResults: getFeaturedResults,
431
+ getPaging: getPaging,
432
+ getPageIndex: getPageIndex,
433
+ getPrevPageIndex: getPrevPageIndex,
434
+ getPageIsLoading: getPageIsLoading,
435
+ getPagesLoaded: getPagesLoaded,
436
+ getTotalCount: getTotalCount,
437
+ getSearchTerm: getSearchTerm,
438
+ getSearchTabs: getSearchTabs,
439
+ getQueryParams: getQueryParams,
440
+ getQueryParameter: getQueryParameter,
441
+ getCustomApi: getCustomApi,
442
+ getCustomEnv: getCustomEnv,
443
+ getTabsAndFacets: getTabsAndFacets,
444
+ getSearchTotalCount: getSearchTotalCount,
445
+ getFacetsTotalCount: getFacetsTotalCount,
446
+ selectFacets: selectFacets,
447
+ selectListing: selectListing,
448
+ selectCurrentPath: selectCurrentPath,
449
+ selectCurrentProject: selectCurrentProject,
450
+ selectVersionStatus: selectVersionStatus
451
+ });
452
+
453
+ const getClientConfig = (project, env) => {
454
+ let config = DELIVERY_API_CONFIG;
455
+ /* global DELIVERY_API_CONFIG */
456
+
457
+ if (project) {
458
+ config.projectId = project;
459
+ }
460
+
461
+ if (typeof window != 'undefined' && PROXY_DELIVERY_API
462
+ /* global PROXY_DELIVERY_API */
463
+ ) {
464
+ // ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
465
+ config.rootUrl = env || '';
466
+ config.responseHandler = {
467
+ 404: () => null
468
+ };
469
+ }
470
+
471
+ return config;
472
+ };
473
+
474
+ class CacheNode {
475
+ constructor(key, value) {
476
+ this.key = key;
477
+ this.value = value;
478
+ this.next = null;
479
+ this.prev = null;
480
+ }
481
+
482
+ }
483
+
484
+ class LruCache {
485
+ constructor(limit = 100) {
486
+ this.map = {};
487
+ this.head = null;
488
+ this.tail = null;
489
+ this.limit = limit || 100;
490
+ this.size = 0;
491
+ }
492
+
493
+ get(key) {
494
+ if (this.map[key]) {
495
+ let value = this.map[key].value;
496
+ let node = new CacheNode(key, value);
497
+ this.remove(key);
498
+ this.setHead(node);
499
+ return value;
500
+ }
501
+ }
502
+
503
+ set(key, value) {
504
+ let node = new CacheNode(key, value);
505
+
506
+ if (this.map[key]) {
507
+ this.remove(key);
508
+ } else {
509
+ if (this.size >= this.limit) {
510
+ delete this.map[this.tail.key];
511
+ this.size--;
512
+ this.tail = this.tail.prev;
513
+ this.tail.next = null;
514
+ }
515
+ }
516
+
517
+ this.setHead(node);
518
+ }
519
+
520
+ setHead(node) {
521
+ node.next = this.head;
522
+ node.prev = null;
523
+
524
+ if (this.head) {
525
+ this.head.prev = node;
526
+ }
527
+
528
+ this.head = node;
529
+
530
+ if (!this.tail) {
531
+ this.tail = node;
532
+ }
533
+
534
+ this.size++;
535
+ this.map[node.key] = node;
536
+ }
537
+
538
+ remove(key) {
539
+ let node = this.map[key];
540
+
541
+ if (node.prev) {
542
+ node.prev.next = node.next;
543
+ } else {
544
+ this.head = node.next;
545
+ }
546
+
547
+ if (node.next) {
548
+ node.next.prev = node.prev;
549
+ } else {
550
+ this.tail = node.prev;
551
+ }
552
+
553
+ delete this.map[key];
554
+ this.size--;
555
+ }
556
+
557
+ }
558
+
559
+ class CachedSearch {
560
+ constructor() {
561
+ this.cache = new LruCache();
562
+ this.taxonomyLookup = {};
563
+ }
564
+
565
+ search(query, linkDepth, project, env) {
566
+ const client = Client.create(getClientConfig(project, env));
567
+ return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
568
+ }
569
+
570
+ getTaxonomyNodeByPath(path, project, env) {
571
+ const client = Client.create(getClientConfig(project, env));
572
+ return this.request(`[TAXONOMY NODE] ${path}`, () => client.taxonomy.getNodeByPath({
573
+ path: path,
574
+ order: 'defined',
575
+ childDepth: 2
576
+ }).then(node => this.extendTaxonomyNode(node)));
577
+ }
578
+
579
+ request(key, execute) {
580
+ if (!this.cache.get(key) || typeof window == 'undefined') {
581
+ let promise = execute();
582
+ this.cache.set(key, promise);
583
+ promise.catch(() => {
584
+ this.cache.remove(key);
585
+ });
586
+ }
587
+
588
+ return this.cache.get(key);
589
+ }
590
+
591
+ extendTaxonomyNode(node) {
592
+ let id = this.getTaxonomyId(node);
593
+ this.taxonomyLookup[id] = node.key;
594
+ return { ...node,
595
+ id,
596
+ children: node.children ? node.children.map(n => this.extendTaxonomyNode(n)) : null
597
+ };
598
+ }
599
+
600
+ getTaxonomyId(node) {
601
+ if (node.key) {
602
+ let parts = node.key.split('/');
603
+ return parts[parts.length - 1];
604
+ }
605
+
606
+ return '';
607
+ }
608
+
609
+ fetch(uri, opts = {}) {
610
+ return this.request(`[FETCH] ${uri} ${JSON.stringify(opts)}`, () => fetch(uri, opts));
611
+ }
612
+
613
+ }
614
+
615
+ const cachedSearch = new CachedSearch();
616
+
617
+ const now = () => {
618
+ if (typeof window == 'undefined') {
619
+ return Date.now();
620
+ }
621
+
622
+ return window.performance.now();
623
+ };
624
+
625
+ // eslint-disable-next-line import/default
626
+ function fixFreeTextForElastic(s) {
627
+ const illegalChars = ['>', '<', '=', '|', '!', '{', '}', '[', ']', '^', '~', '*', '?', ':', '\\', '/'];
628
+ const illegalRegEx = new RegExp(illegalChars.map(c => '\\' + c).join('|'), 'g');
629
+ s = s.replace(illegalRegEx, ''); // s = s.replace(encodedRegEx, ''); // (m) => '\\\\' + m);
630
+
631
+ return s;
632
+ }
633
+ const timedSearch = async (query, linkDepth = 0, projectId, env) => {
634
+ if (!query) return null;
635
+ let duration = 0;
636
+ const start = now();
637
+ const payload = await cachedSearch.search(query, linkDepth, projectId, env);
638
+ const end = now();
639
+ duration = end - start;
640
+ return {
641
+ duration,
642
+ payload
643
+ };
644
+ };
645
+ const getItemsFromResult = result => {
646
+ const {
647
+ payload
648
+ } = result || {};
649
+
650
+ if (payload) {
651
+ if (Array.isArray(payload)) return payload;
652
+ if (Array.isArray(payload.items)) return payload.items;
653
+ return payload;
654
+ }
655
+
656
+ return [];
657
+ };
658
+ const extractQuotedPhrases = searchTerm => {
659
+ const pattern = new RegExp(/(?=["'])(?:"[^"\\]*(?:\\[\s\S][^"\\]*)*"|'[^'\\]*(?:\\[\s\S][^'\\]*)*')/gm);
660
+ return (searchTerm.match(pattern) || []).map(match => match.replace(/"/g, ''));
661
+ };
662
+ const buildUrl = (route, params) => {
663
+ const qs = stringify(params);
664
+ const path = qs ? `${route}${route.includes('?') ? '&' : '?'}${qs}` : route;
665
+ return path;
666
+ };
667
+ const callCustomApi = async (customApi, filters) => {
668
+ const apiUri = customApi.uri || '';
669
+ let uri = buildUrl(apiUri, filters);
670
+ if (!uri) throw new Error('uri is required to use customApi');
671
+ if (typeof window == 'undefined' && uri.startsWith('/')) uri = `http://localhost:3001${uri}`;
672
+ const response = await cachedSearch.fetch(uri);
673
+ return await response.clone().json();
674
+ };
675
+ const removeEmptyAttributes = obj => {
676
+ Object.entries(obj).forEach(([key, val]) => val && typeof val === 'object' && removeEmptyAttributes(val) || (typeof val === 'undefined' || val === null || val === '') && delete obj[key]);
677
+ return obj;
678
+ };
679
+ const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator); // assumes array elements are primitive types
680
+
681
+ const areArraysEqualSets = (a1, a2) => {
682
+ const superSet = {};
683
+
684
+ for (const ai of a1) {
685
+ const e = ai + typeof ai;
686
+ superSet[e] = 1;
687
+ }
688
+
689
+ for (const ai of a2) {
690
+ const e = ai + typeof ai;
691
+
692
+ if (!superSet[e]) {
693
+ return false;
694
+ }
695
+
696
+ superSet[e] = 2;
697
+ }
698
+
699
+ for (const e in superSet) {
700
+ if (superSet[e] === 1) {
701
+ return false;
702
+ }
703
+ }
704
+
705
+ return true;
706
+ };
707
+
708
+ const DataFormats = {
709
+ asset: 'asset',
710
+ entry: 'entry',
711
+ webpage: 'webpage'
712
+ };
713
+ const FilterExpressionTypes = {
714
+ contentType: 'contentType',
715
+ field: 'field'
716
+ };
717
+ const sys = {
718
+ allUris: 'sys.allUris',
719
+ contentTypeId: 'sys.contentTypeId',
720
+ dataFormat: 'sys.dataFormat',
721
+ filename: 'sys.properties.filename',
722
+ id: 'sys.id',
723
+ includeInSearch: 'sys.metadata.includeInSearch',
724
+ language: 'sys.language',
725
+ uri: 'sys.uri',
726
+ versionStatus: 'sys.versionStatus'
727
+ };
728
+ const Fields = {
729
+ entryDescription: 'entryDescription',
730
+ entryTitle: 'entryTitle',
731
+ keywords: 'keywords',
732
+ searchContent: 'searchContent',
733
+ sys,
734
+ contentTypeId: 'sys.contentTypeId',
735
+ wildcard: '*'
736
+ };
737
+
738
+ const fieldExpression = (field, value, operator = 'equalTo', weight) => {
739
+ if (!field || !value || Array.isArray(value) && value.length === 0) return [];
740
+ if (Array.isArray(field)) // If an array of fieldIds have been provided, call self for each fieldId
741
+ // to generate expressions that are combined with an 'or' operator
742
+ return [Op.or(...field.map(fieldId => fieldExpression(fieldId, value, operator, weight)).flat())];
743
+ if (operator === 'between') return between(field, value);
744
+ if (Array.isArray(value)) return equalToOrIn(field, value, operator);else return !weight ? equalToOrIn(field, value, operator) : [equalToOrIn(field, value, operator)[0].weight(weight)];
745
+ };
746
+ const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) => {
747
+ const expressions = [];
748
+ if (!contentTypeIds && !webpageTemplates && !assetTypes) return expressions;
749
+
750
+ if (contentTypeIds && contentTypeIds.length > 0) {
751
+ expressions.push(...dataFormatExpression(contentTypeIds, DataFormats.entry));
752
+ }
753
+
754
+ if (webpageTemplates && webpageTemplates.length > 0) {
755
+ expressions.push(...dataFormatExpression(webpageTemplates, DataFormats.webpage));
756
+ }
757
+
758
+ if (assetTypes && assetTypes.length > 0) {
759
+ expressions.push(...dataFormatExpression(assetTypes, DataFormats.asset));
760
+ }
761
+
762
+ if (expressions.length > 1) return [Op.or(...expressions)];
763
+ return expressions;
764
+ };
765
+ const filterExpressions = (filters, isOptional = false) => {
766
+ if (!filters) return [];
767
+ const expressions = [];
768
+ filters.map(selectedFilter => {
769
+ if (selectedFilter.logicOperator === 'and') // using 'and' logic operator we loop through each filter
770
+ // and loop through all values to add an expression for each filter value
771
+ selectedFilter.values.forEach(value => expressions.push(...fieldExpression(selectedFilter.key, value, selectedFilter.fieldOperator || 'equalTo')));else if (selectedFilter.logicOperator === 'not') {
772
+ const fieldExpressions = fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in');
773
+ fieldExpressions.forEach(expr => {
774
+ expressions.push(Op.not(expr));
775
+ });
776
+ } // using 'or' logic operator we loop over each filter
777
+ // and simply add the array of values to an expression with an 'in' operator
778
+ else expressions.push(...fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in'));
779
+ if (isOptional) expressions.push(Op.not(fieldExpression(selectedFilter.key, true, 'exists')[0]));
780
+ });
781
+ return expressions;
782
+ };
783
+ const dataFormatExpression = (contentTypeIds, dataFormat = DataFormats.entry) => {
784
+ if (contentTypeIds && contentTypeIds.length > 0) {
785
+ /**
786
+ * We have an array of contentTypeIds some may be prefixed with a "!"
787
+ * to indicate this is a "not" expression
788
+ */
789
+ const withContentTypeIds = contentTypeIds.filter(c => !c.startsWith('!'));
790
+ const notContentTypeIds = contentTypeIds.filter(c => c.startsWith('!')).map(id => id.substring(1));
791
+ const andExpr = Op.and();
792
+ const dataFormatExpr = fieldExpression(Fields.sys.dataFormat, dataFormat)[0];
793
+ const withExpr = fieldExpression(Fields.sys.contentTypeId, withContentTypeIds)[0];
794
+ const notExpr = Op.not(fieldExpression(Fields.sys.contentTypeId, notContentTypeIds)[0]);
795
+ andExpr.add(dataFormatExpr);
796
+ if (withContentTypeIds.length > 0 && withExpr) andExpr.add(withExpr);
797
+ if (notContentTypeIds.length > 0 && notExpr) andExpr.add(notExpr);
798
+ return [andExpr];
799
+ }
800
+
801
+ return [];
802
+ };
803
+ const featuredResultsExpression = ({
804
+ contentTypeId,
805
+ fieldId,
806
+ fieldValue = true
807
+ } = {}) => {
808
+ const expressions = [];
809
+
810
+ if (contentTypeId) {
811
+ expressions.push(...contentTypeIdExpression(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId]));
812
+ }
813
+
814
+ if (fieldId && fieldValue) {
815
+ expressions.push(...fieldExpression(fieldId, fieldValue));
816
+ }
817
+
818
+ return expressions;
819
+ };
820
+ const languagesExpression = languages => fieldExpression(Fields.sys.language, languages);
821
+ const includeInSearchExpressions = (webpageTemplates, includeInSearchFields) => {
822
+ const expressions = []; // Or include this expression if we have explicity specified non-default includeInSearch fields
823
+
824
+ if (Array.isArray(includeInSearchFields)) expressions.push(...includeInSearchFields.map(includeInSearchField => Op.or(Op.and(Op.exists(includeInSearchField, true), Op.equalTo(includeInSearchField, true)), Op.exists(includeInSearchField, false)))); // If webpageTemplates have been specified, include this expression
825
+ // with the default includeInSearch field from classic Contensis.
826
+
827
+ if (Array.isArray(webpageTemplates) && webpageTemplates.length > 0) expressions.push(Op.or(Op.and(Op.exists(Fields.sys.includeInSearch, true), Op.equalTo(Fields.sys.includeInSearch, true)), Op.exists(Fields.sys.includeInSearch, false)));
828
+ return expressions;
829
+ };
830
+ const defaultExpressions = versionStatus => {
831
+ return [Op.equalTo(Fields.sys.versionStatus, versionStatus)];
832
+ };
833
+ const includeIdsExpression = includeIds => {
834
+ if (Array.isArray(includeIds) && includeIds.length > 0) {
835
+ return fieldExpression(Fields.sys.id, includeIds);
836
+ } else return [];
837
+ };
838
+ const excludeIdsExpression = excludeIds => {
839
+ if (Array.isArray(excludeIds) && excludeIds.length > 0) {
840
+ const [expr] = fieldExpression(Fields.sys.id, excludeIds);
841
+ return [Op.not(expr)];
842
+ } else return [];
843
+ };
844
+ const orderByExpression = orderBy => {
845
+ let expression;
846
+
847
+ if (orderBy && orderBy.length > 0) {
848
+ expression = OrderBy;
849
+
850
+ for (const ob of orderBy) {
851
+ var _expression, _expression2;
852
+
853
+ expression = ob.startsWith('-') ? (_expression = expression) === null || _expression === void 0 ? void 0 : _expression.desc(ob.substring(1)) : (_expression2 = expression) === null || _expression2 === void 0 ? void 0 : _expression2.asc(ob);
854
+ }
855
+ }
856
+
857
+ return expression;
858
+ };
859
+
860
+ const equalToOrIn = (field, value, operator = 'equalTo') => {
861
+ if (value.length === 0) return [];
862
+
863
+ if (Array.isArray(value)) {
864
+ if (operator === 'equalTo' || operator === 'in') return [Op.in(field, ...value)];
865
+ const expressions = value.map(innerValue => {
866
+ var _between, _distanceWithin;
867
+
868
+ switch (operator) {
869
+ case 'between':
870
+ return (_between = between(field, innerValue)) === null || _between === void 0 ? void 0 : _between[0];
871
+
872
+ case 'distanceWithin':
873
+ return (_distanceWithin = distanceWithin(field, innerValue)) === null || _distanceWithin === void 0 ? void 0 : _distanceWithin[0];
874
+
875
+ case 'exists':
876
+ return Op.exists(field, innerValue);
877
+
878
+ case 'freeText':
879
+ // TODO: Potentially needs further implementation of new options
880
+ return Op[operator](field, innerValue, false, undefined);
881
+
882
+ default:
883
+ return Op[operator](field, innerValue);
884
+ }
885
+ });
886
+ return (expressions === null || expressions === void 0 ? void 0 : expressions.length) > 1 ? [Op.or(...expressions)] : expressions || [];
887
+ }
888
+
889
+ switch (operator) {
890
+ case 'between':
891
+ return between(field, value);
892
+
893
+ case 'distanceWithin':
894
+ return distanceWithin(field, value);
895
+
896
+ case 'freeText':
897
+ // TODO: Potentially needs further implementation of new options
898
+ return [Op.freeText(field, value, false, undefined)];
899
+
900
+ default:
901
+ return [Op[operator](field, value)];
902
+ }
903
+ };
904
+
905
+ const between = (field, value) => {
906
+ const handle = betweenValue => {
907
+ const valArr = betweenValue.split('--');
908
+
909
+ if (valArr.length > 1) {
910
+ const [minimum, maximum] = valArr;
911
+ return Op.between(field, minimum, maximum);
912
+ } else {
913
+ // eslint-disable-next-line no-console
914
+ console.log(`[search] You have supplied only one value to a "between" operator which must have two values. Your supplied value "${valArr.length && valArr[0]}" has been discarded.`);
915
+ return false;
916
+ }
917
+ };
918
+
919
+ if (value.length === 0) return [];
920
+ if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
921
+ const op = handle(value);
922
+ return op ? [op] : [];
923
+ };
924
+
925
+ const distanceWithin = (field, value) => {
926
+ const handle = distanceValue => {
927
+ const valArr = distanceValue.split(' ');
928
+
929
+ if (valArr.length > 1) {
930
+ const [lat, lon] = valArr;
931
+ return Op.distanceWithin(field, Number(lat), Number(lon), (valArr === null || valArr === void 0 ? void 0 : valArr[2]) || '10mi');
932
+ } else {
933
+ // eslint-disable-next-line no-console
934
+ console.log(`[search] You have supplied only one value to a "distanceWithin" operator which must be made up of "lat,lon,distance". Your supplied value "${valArr.length && valArr[0]}" has been discarded.`);
935
+ return false;
936
+ }
937
+ };
938
+
939
+ if (value.length === 0) return [];
940
+ if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
941
+ const op = handle(value);
942
+ return op ? [op] : [];
943
+ };
944
+ /**
945
+ * Accept HTTP style objects and map them to
946
+ * their equivalent JS client "Op" expressions
947
+ * @param {array} where the where array as you'd provide it to the HTTP API
948
+ * @returns {array} array of constructed Delivery API Operators
949
+ */
950
+
951
+
952
+ const customWhereExpressions = where => {
953
+ if (!where || !Array.isArray(where)) return []; // Map each clause inside the where array
954
+
955
+ return where.map(clause => {
956
+ let expression; // Map through each property in the clause so we can
957
+ // capture the values required and reconstruct them as
958
+ // a Delivery API expression
959
+
960
+ let operator;
961
+ Object.keys(clause).map((key, idx) => {
962
+ // The clause may contain only one key
963
+ if (idx === 0) operator = key;
964
+ const field = clause.field;
965
+ const value = clause[Object.keys(clause).find(k => !['field', 'weight'].includes(k)) || ''];
966
+ const weight = clause.weight;
967
+
968
+ if (idx === 0) {
969
+ if (operator === 'and' || operator === 'or') {
970
+ // These are array expressions so we can call ourself recursively
971
+ // to map these inner values to expressions
972
+ const recurseExpr = customWhereExpressions(clause[operator]);
973
+ expression = Op[operator](...recurseExpr);
974
+ }
975
+
976
+ if (['not'].includes(operator)) {
977
+ // A 'not' expression is an object with only one inner field and inner operator
978
+ Object.keys(value).map((notKey, notIdx) => {
979
+ const innerOperator = notKey;
980
+ const innerValue = value[notKey];
981
+ const innerField = value.field; // Map the expression when we've looped and scoped to
982
+ // the second property inside the clause
983
+
984
+ if (notIdx === 1) expression = Op.not(makeJsExpression(innerOperator, innerField, innerValue));
985
+ });
986
+ }
987
+ } // Map the expression when we've looped and scoped to
988
+ // the second property inside the clause
989
+
990
+
991
+ operator = Object.keys(clause).find(clauseKey => !['field', 'weight'].includes(clauseKey));
992
+
993
+ if (idx === 1) {
994
+ expression = makeJsExpression(operator, field, value);
995
+ if (typeof weight === 'number') expression = expression.weight(weight);
996
+ }
997
+ });
998
+ return expression;
999
+ });
1000
+ };
1001
+
1002
+ const makeJsExpression = (operator, field, value) => operator === 'freeText' || operator === 'contains' ? Op[operator](field, value) : operator === 'in' ? Op[operator](field, ...value) : operator === 'exists' ? Op[operator](field, value) : operator === 'between' ? Op[operator](field, value[0], value[1]) : operator === 'distanceWithin' ? Op[operator](field, value === null || value === void 0 ? void 0 : value.lat, value === null || value === void 0 ? void 0 : value.lon, value === null || value === void 0 ? void 0 : value.distance) : Op[operator](field, value);
1003
+
1004
+ const termExpressions = (searchTerm, weightedSearchFields) => {
1005
+ if (searchTerm && weightedSearchFields && weightedSearchFields.length > 0) {
1006
+ // Extract any phrases in quotes to array
1007
+ const quotedPhrases = extractQuotedPhrases(searchTerm); // Modify the search term to remove any quoted phrases to leave any remaining terms
1008
+
1009
+ let modifiedSearchTerm = searchTerm;
1010
+ quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim()); // Push to the operators array to include in the query
1011
+
1012
+ const operators = []; // Helper functions to generate Op expressions
1013
+
1014
+ const containsOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'contains', f.weight);
1015
+
1016
+ const freeTextOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'freeText', f.weight); // For each weighted search field
1017
+
1018
+
1019
+ weightedSearchFields.forEach(wsf => {
1020
+ // Push to field operators
1021
+ const fieldOperators = []; // Add operator expressions for modified search term
1022
+
1023
+ if (modifiedSearchTerm) {
1024
+ if ([Fields.keywords, Fields.sys.filename, Fields.sys.uri].includes(wsf.fieldId)) {
1025
+ fieldOperators.push(...containsOp(wsf, modifiedSearchTerm));
1026
+ } else {
1027
+ if ([Fields.entryTitle].includes(wsf.fieldId)) {
1028
+ fieldOperators.push(Op.or(...containsOp(wsf, modifiedSearchTerm), ...freeTextOp(wsf, modifiedSearchTerm)));
1029
+ } else {
1030
+ fieldOperators.push(...freeTextOp(wsf, modifiedSearchTerm));
1031
+ }
1032
+ }
1033
+ } // Add operator expressions for any quoted phrases
1034
+
1035
+
1036
+ quotedPhrases.forEach(qp => fieldOperators.push(...containsOp(wsf, qp))); // If we are using multiple operators for a field we will
1037
+ // wrap each field inside an And operator so we will match
1038
+ // all terms/phrases rather than any terms/phrases
1039
+
1040
+ if (fieldOperators.length > 1) {
1041
+ operators.push(Op.and(...fieldOperators));
1042
+ } else {
1043
+ operators.push(...fieldOperators);
1044
+ }
1045
+ }); // Wrap operators in an Or operator
1046
+
1047
+ return [Op.or().addRange(operators).add(Op.freeText(Fields.searchContent, searchTerm))];
1048
+ } else if (searchTerm) {
1049
+ // Searching without weightedSearchFields defined will fall back
1050
+ // to a default set of search fields with arbritary weights set.
1051
+ return [Op.or(Op.equalTo(Fields.entryTitle, searchTerm).weight(10), Op.freeText(Fields.entryTitle, searchTerm).weight(2), Op.freeText(Fields.entryDescription, searchTerm).weight(2), Op.contains(Fields.keywords, searchTerm).weight(2), Op.contains(Fields.sys.uri, searchTerm).weight(2), Op.contains(Fields.sys.allUris, searchTerm), Op.freeText(Fields.searchContent, searchTerm))];
1052
+ } else {
1053
+ return [];
1054
+ }
1055
+ };
1056
+
1057
+ var expressions = /*#__PURE__*/Object.freeze({
1058
+ __proto__: null,
1059
+ fieldExpression: fieldExpression,
1060
+ contentTypeIdExpression: contentTypeIdExpression,
1061
+ filterExpressions: filterExpressions,
1062
+ dataFormatExpression: dataFormatExpression,
1063
+ featuredResultsExpression: featuredResultsExpression,
1064
+ languagesExpression: languagesExpression,
1065
+ includeInSearchExpressions: includeInSearchExpressions,
1066
+ defaultExpressions: defaultExpressions,
1067
+ includeIdsExpression: includeIdsExpression,
1068
+ excludeIdsExpression: excludeIdsExpression,
1069
+ orderByExpression: orderByExpression,
1070
+ customWhereExpressions: customWhereExpressions,
1071
+ termExpressions: termExpressions
1072
+ });
1073
+
1074
+ const filterQuery = (contentTypeIds, versionStatus, customWhere) => {
1075
+ const query = new Query(...[...contentTypeIdExpression(contentTypeIds), ...defaultExpressions(versionStatus), ...customWhereExpressions(customWhere)]);
1076
+ query.orderBy = OrderBy.asc(Fields.entryTitle);
1077
+ query.pageSize = 100;
1078
+ return query;
1079
+ };
1080
+ const searchQuery = ({
1081
+ assetTypes,
1082
+ contentTypeIds,
1083
+ customWhere,
1084
+ dynamicOrderBy,
1085
+ excludeIds,
1086
+ featuredResults,
1087
+ fields,
1088
+ filters,
1089
+ includeInSearchFields,
1090
+ languages,
1091
+ pageSize,
1092
+ pageIndex,
1093
+ orderBy,
1094
+ searchTerm,
1095
+ versionStatus,
1096
+ webpageTemplates,
1097
+ weightedSearchFields
1098
+ }, isFeatured = false) => {
1099
+ let expressions = [...termExpressions(searchTerm, weightedSearchFields), ...defaultExpressions(versionStatus), ...includeInSearchExpressions(webpageTemplates, includeInSearchFields), ...languagesExpression(languages), ...customWhereExpressions(customWhere), ...excludeIdsExpression(excludeIds)];
1100
+ if (isFeatured) expressions = [...expressions, ...featuredResultsExpression(featuredResults)];
1101
+ if (!isFeatured || featuredResults && !featuredResults.contentTypeId) expressions = [...expressions, ...filterExpressions(filters), ...contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes)];
1102
+ const query = new Query(...expressions);
1103
+ if (!searchTerm) query.orderBy = orderByExpression(orderBy);
1104
+ if (dynamicOrderBy && dynamicOrderBy.length) query.orderBy = orderByExpression(dynamicOrderBy);
1105
+
1106
+ if (fields && fields.length > 0 && !isFeatured) {
1107
+ query.fields = fields;
1108
+ }
1109
+
1110
+ query.pageIndex = isFeatured ? 0 : pageIndex;
1111
+ query.pageSize = isFeatured && typeof featuredResults.count === 'number' ? featuredResults.count : pageSize;
1112
+ return query;
1113
+ };
1114
+
1115
+ var queries = /*#__PURE__*/Object.freeze({
1116
+ __proto__: null,
1117
+ filterQuery: filterQuery,
1118
+ searchQuery: searchQuery
1119
+ });
1120
+
1121
+ const searchUriTemplate = {
1122
+ path: ({
1123
+ state,
1124
+ facet,
1125
+ pageIndex
1126
+ }) => {
1127
+ const currentFacet = getSearchContext(state) !== Context.listings && (facet || getCurrentFacet(state));
1128
+ const currentPath = selectCurrentPath(state) || '/search';
1129
+ const newPath = currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
1130
+ if (pageIndex) return `${newPath}/${pageIndex + 1}`;
1131
+ return newPath;
1132
+ },
1133
+ search: ({
1134
+ state,
1135
+ facet,
1136
+ orderBy,
1137
+ term
1138
+ }) => {
1139
+ const searchContext = getSearchContext(state); // Lose stateFilters and currentSearch if a new
1140
+ // term is passed via an argument
1141
+
1142
+ const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')]));
1143
+ const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
1144
+ const currentQs = removeEmptyAttributes(parse(currentSearch));
1145
+ if (orderBy) currentQs.orderBy = orderBy;
1146
+ const searchTerm = getSearchTerm(state); // Merge the stateFilters with any current qs to build the new qs
1147
+
1148
+ const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
1149
+ term: searchTerm
1150
+ });
1151
+ return stringify(mergedSearch);
1152
+ },
1153
+ hash: state => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
1154
+ };
1155
+
1156
+ const mapStateToSearchUri = params => mapJson(params, searchUriTemplate);
1157
+
1158
+ const mapEntriesToSearchResults = ({
1159
+ mappers,
1160
+ mapper,
1161
+ context,
1162
+ facet
1163
+ }, items, state) => {
1164
+ const mapperFunc = mapper || mappers && mappers.results;
1165
+ return items && typeof mapperFunc === 'function' ? mapperFunc(items, facet, context, state) : [];
1166
+ };
1167
+
1168
+ const facetTemplate = {
1169
+ type: () => SET_SEARCH_ENTRIES,
1170
+ context: 'action.context',
1171
+ facet: 'action.facet',
1172
+ mappers: 'action.mappers',
1173
+ nextFacet: {
1174
+ entries: {
1175
+ isLoading: () => false,
1176
+ isError: () => false
1177
+ },
1178
+ featuredEntries: {
1179
+ isLoading: () => false,
1180
+ isError: () => false
1181
+ },
1182
+ featuredResults: ({
1183
+ action,
1184
+ featuredResult,
1185
+ state
1186
+ }) => mapEntriesToSearchResults(action, getItemsFromResult(featuredResult), state),
1187
+ queryDuration: 'result.duration',
1188
+ pagingInfo: {
1189
+ isLoading: () => false,
1190
+ pageCount: {
1191
+ $path: 'result.payload.pageCount',
1192
+ $default: 0
1193
+ },
1194
+ totalCount: {
1195
+ $path: 'result.payload.totalCount',
1196
+ $default: 0
1197
+ },
1198
+ pageSize: {
1199
+ $path: 'result.payload.pageSize',
1200
+ $default: 0
1201
+ },
1202
+ pageIndex: 'pageIndex',
1203
+ pagesLoaded: {
1204
+ $path: 'action.queryParams',
1205
+ $formatting: ({
1206
+ pageIndex,
1207
+ pagesLoaded
1208
+ }) => {
1209
+ const loaded = [...(pagesLoaded || [])];
1210
+
1211
+ if (isNaN(loaded.find(l => l === pageIndex))) {
1212
+ loaded.push(pageIndex);
1213
+ }
1214
+
1215
+ return loaded.sort((a, b) => a - b);
1216
+ }
1217
+ },
1218
+ prevPageIndex: 'action.queryParams.prevPageIndex'
1219
+ },
1220
+ preloaded: {
1221
+ $path: 'preload',
1222
+ $default: false
1223
+ },
1224
+ results: ({
1225
+ action,
1226
+ pageIndex,
1227
+ result,
1228
+ prevResults,
1229
+ state
1230
+ }) => {
1231
+ const {
1232
+ loadMorePaging,
1233
+ pagesLoaded,
1234
+ prevPageIndex
1235
+ } = action.queryParams;
1236
+ const results = mapEntriesToSearchResults(action, getItemsFromResult(result), state);
1237
+ if (!loadMorePaging) return results; // add a _pageIndex property to the returned results to help us later
1238
+
1239
+ const nextResults = results.map((r, idx) => ({
1240
+ _pageIndex: pageIndex,
1241
+ _pagePosition: idx,
1242
+ ...r
1243
+ }));
1244
+ const loadedPages = pagesLoaded || []; // if pageIndex is found in loadedPages, we have already loaded this page
1245
+
1246
+ if (!isNaN(loadedPages.find(l => l === pageIndex))) return prevResults; // Determine where we put the results depending on if we
1247
+ // are paging forwards, backwards, or doing a new search
1248
+
1249
+ const firstResultSet = pageIndex > prevPageIndex ? prevResults || [] : nextResults;
1250
+ const secondResultSet = pageIndex > prevPageIndex ? nextResults : prevResults || [];
1251
+ const onlyResultSet = loadedPages.length === 0 ? nextResults : false;
1252
+ return onlyResultSet || [...firstResultSet, ...secondResultSet];
1253
+ }
1254
+ },
1255
+ preload: 'action.preload',
1256
+ ogState: 'action.ogState',
1257
+ debug: 'action.debug'
1258
+ };
1259
+ const filterTemplate = {
1260
+ type: ({
1261
+ type
1262
+ }) => type || LOAD_FILTERS_COMPLETE,
1263
+ context: 'context',
1264
+ facetKey: 'facetKey',
1265
+ filterKey: 'filterKey',
1266
+ nextFilter: {
1267
+ isLoading: () => false,
1268
+ isError: ({
1269
+ type
1270
+ }) => type === LOAD_FILTERS_ERROR,
1271
+ items: ({
1272
+ payload,
1273
+ selectedKeys,
1274
+ mapper
1275
+ }) => {
1276
+ if (payload && (payload.items || payload.children)) {
1277
+ const items = (payload.items || payload.children).map(item => {
1278
+ var _item$sys;
1279
+
1280
+ item.isSelected = selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.includes((item === null || item === void 0 ? void 0 : (_item$sys = item.sys) === null || _item$sys === void 0 ? void 0 : _item$sys.id) || item.key);
1281
+ return item;
1282
+ });
1283
+ return mapper(items);
1284
+ }
1285
+
1286
+ return [];
1287
+ }
1288
+ },
1289
+ error: {
1290
+ $path: 'error',
1291
+ $disable: e => !e
1292
+ }
1293
+ };
1294
+
1295
+ const filterExpressionMapper = {
1296
+ // Expression type: so we can identify how to build the query
1297
+ expressionType: ({
1298
+ contentTypeId
1299
+ }) => contentTypeId ? FilterExpressionTypes.contentType : FilterExpressionTypes.field,
1300
+ // Key: so we can target the query to a specific field
1301
+ key: 'fieldId',
1302
+ // Value: so we can filter a specific field by an array of values
1303
+ // e.g. taxonomy key or contentTypeId array
1304
+ values: 'selectedValues',
1305
+ fieldOperator: 'fieldOperator',
1306
+ logicOperator: 'logicOperator'
1307
+ };
1308
+
1309
+ const mapFilterToFilterExpression = filter => mapJson(filter, filterExpressionMapper);
1310
+
1311
+ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
1312
+ if (!selectedFilters || Object.keys(selectedFilters).length === 0) return [];
1313
+ const filterExpressions = []; // Iterate through the keys in selectedFilters and locate
1314
+ // the items that are selected and queryable
1315
+
1316
+ Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
1317
+ const filter = filters[fkey];
1318
+
1319
+ if (selectedValues && filter) {
1320
+ // Where we have a value for a selectedFilter
1321
+ // and a filter is found for the current key
1322
+ // map the filter to a filterExpression object
1323
+ const expr = mapFilterToFilterExpression({ ...filter,
1324
+ selectedValues
1325
+ });
1326
+ filterExpressions.push(expr);
1327
+ }
1328
+ });
1329
+ return filterExpressions;
1330
+ };
1331
+
1332
+ const queryParamsTemplate = {
1333
+ assetTypes: root => getQueryParameter(root, 'assetTypes', []),
1334
+ contentTypeIds: root => getQueryParameter(root, 'contentTypeIds', []),
1335
+ customWhere: root => getQueryParameter(root, 'customWhere', []),
1336
+ dynamicOrderBy: root => getQueryParameter(root, 'dynamicOrderBy', []),
1337
+ env: ({
1338
+ state,
1339
+ facet,
1340
+ context
1341
+ }) => getCustomEnv(state, facet, context),
1342
+ excludeIds: ({
1343
+ action: {
1344
+ excludeIds
1345
+ }
1346
+ }) => {
1347
+ // Exclude current route entry id from minilist searches or any supplied ids
1348
+ if (excludeIds) return Array.isArray(excludeIds) ? excludeIds : excludeIds.split(',').map(id => id.trim());
1349
+ return null;
1350
+ },
1351
+ featuredResults: root => getQueryParameter(root, 'featuredResults', null),
1352
+ fields: root => getQueryParameter(root, 'fields', []),
1353
+ filters: ({
1354
+ state,
1355
+ facet,
1356
+ context
1357
+ }) => {
1358
+ const stateFilters = getFilters(state, facet, context, 'js');
1359
+ const selectedFilters = getSelectedFilters(state, facet, context, 'js'); // Use another mapping function to map the filter parameters for the query
1360
+
1361
+ const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
1362
+ return filterParams;
1363
+ },
1364
+ includeInSearchFields: root => getQueryParameter(root, 'includeInSearch', []),
1365
+ internalPageIndex: ({
1366
+ action,
1367
+ state
1368
+ }) => getPageIndex(state, '', action.context),
1369
+ internalPaging: root => getQueryParameter(root, 'internalPaging', false),
1370
+ languages: ({
1371
+ action
1372
+ }) => action.defaultLang ? [action.defaultLang] : [],
1373
+ linkDepth: root => getQueryParameter(root, 'linkDepth', 0),
1374
+ loadMorePaging: root => getQueryParameter(root, 'loadMorePaging', false),
1375
+ orderBy: root => getQueryParameter(root, 'orderBy', []),
1376
+ pageIndex: root => {
1377
+ const {
1378
+ action,
1379
+ state
1380
+ } = root;
1381
+ if (getQueryParameter(root, 'internalPaging', false)) return 0;
1382
+ if (action.type === UPDATE_PAGE_INDEX) return action.params.pageIndex;
1383
+ return !action.preload ? getPageIndex(state, action.facet, action.context) : 0;
1384
+ },
1385
+ pageSize: root => getQueryParameter(root, 'pageSize'),
1386
+ pagesLoaded: ({
1387
+ state,
1388
+ facet,
1389
+ context
1390
+ }) => getPagesLoaded(state, facet, context),
1391
+ prevPageIndex: ({
1392
+ state,
1393
+ facet,
1394
+ context
1395
+ }) => getPrevPageIndex(state, facet, context),
1396
+ projectId: ({
1397
+ state,
1398
+ facet,
1399
+ context
1400
+ }) => {
1401
+ var _getFacet;
1402
+
1403
+ return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
1404
+ },
1405
+ searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
1406
+ selectedFilters: ({
1407
+ state,
1408
+ facet,
1409
+ context
1410
+ }) => Object.fromEntries(Object.entries(getSelectedFilters(state, facet, context, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')])),
1411
+ versionStatus: ({
1412
+ state
1413
+ }) => selectVersionStatus(state),
1414
+ weightedSearchFields: root => {
1415
+ const wsf = getQueryParameter(root, 'weightedSearchFields', []);
1416
+ const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
1417
+ return deduped; // return wsf;
1418
+ },
1419
+ webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
1420
+ };
1421
+
1422
+ const mapStateToQueryParams = sourceJson => mapJson(sourceJson, queryParamsTemplate);
1423
+
1424
+ /**
1425
+ * 1, Generates all the parameters required to run the search query.
1426
+ * 2, Tells us if we should run the search.
1427
+ * @param {object} action
1428
+ * @param {AppState} state
1429
+ * @returns [queryParams, runSearch]
1430
+ */
1431
+ const generateQueryParams = (action, state) => {
1432
+ const {
1433
+ context,
1434
+ facet
1435
+ } = action; // Map parameters using state and some additional
1436
+ // inputs from the action
1437
+
1438
+ const queryParams = mapStateToQueryParams({
1439
+ context,
1440
+ facet,
1441
+ action,
1442
+ state
1443
+ });
1444
+ return [queryParams, runSearch(action, state, queryParams)];
1445
+ };
1446
+ /**
1447
+ * Checks if we have already loaded everything we're asking for and tells us to run the search or not
1448
+ * @param action
1449
+ * @param state
1450
+ */
1451
+
1452
+ const runSearch = (action, state, queryParams) => {
1453
+ const {
1454
+ context,
1455
+ defaultLang,
1456
+ facet,
1457
+ ogState = state,
1458
+ preload,
1459
+ ssr
1460
+ } = action;
1461
+ let willRun = false;
1462
+ const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
1463
+ const stateParams = { ...getQueryParams(ogState, facet, context)
1464
+ };
1465
+ stateParams.pageIndex = getPageIndex(ogState, facet, context);
1466
+ stateParams.searchTerm = getSearchTerm(ogState);
1467
+
1468
+ if (context === Context.facets && ssr || // context === Context.minilist ||
1469
+ preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
1470
+ willRun = true;
1471
+ } else {
1472
+ // Don't execute the search if the inbound query params
1473
+ // are the same as what we already have in state
1474
+ Object.entries(stateParams).forEach(([param, value]) => {
1475
+ const queryParam = queryParams[param];
1476
+
1477
+ if (JSON.stringify(value) !== JSON.stringify(queryParam)) {
1478
+ willRun = true;
1479
+ }
1480
+ });
1481
+ }
1482
+
1483
+ const internalPaging = getIsInternalPaging(ogState, facet, context);
1484
+
1485
+ if (internalPaging && facetIsLoaded) {
1486
+ willRun = false;
1487
+ }
1488
+
1489
+ return willRun;
1490
+ };
1491
+ /**
1492
+ * This will tell us if filter parameters have been
1493
+ * changed by some external event such as a route change
1494
+ * @param action
1495
+ * @returns true or false
1496
+ */
1497
+
1498
+ const filterParamsChanged = (action, state) => {
1499
+ const {
1500
+ context,
1501
+ facet,
1502
+ params,
1503
+ ogState = state
1504
+ } = action;
1505
+ const selectedFilters = getSelectedFilters(ogState, facet, context, 'js');
1506
+ const paramsChanged = Object.entries(selectedFilters).map(([filterKey, selectedValues]) => {
1507
+ const inboundValues = params && params[filterKey] && params[filterKey].split(',') || [];
1508
+ if (!areArraysEqualSets(selectedValues, inboundValues)) return true;
1509
+ });
1510
+ return paramsChanged.filter(f => f === true).length > 0;
1511
+ };
1512
+ /* eslint-disable no-console */
1513
+
1514
+ const debugExecuteSearch = (action, state) => {
1515
+ const [queryParams, runSearch] = generateQueryParams(action, state);
1516
+ console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
1517
+ const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
1518
+ pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
1519
+ searchTerm: getSearchTerm(action.ogState || state)
1520
+ };
1521
+ console.log(stateParams, queryParams);
1522
+ console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
1523
+ };
1524
+ const scrollTop = scrollYPos => {
1525
+ if (typeof window !== 'undefined') window.scrollTo(0, scrollYPos);
1526
+ };
1527
+
1528
+ // Base mapping, fields that are the same across all mappings
1529
+ // to save repeating these elements in every mapper, spread this
1530
+ // into your discrete mappings
1531
+
1532
+ const base = {
1533
+ contentTypeId: Fields.sys.contentTypeId,
1534
+ title: 'entryTitle',
1535
+ key: 'sys.id',
1536
+ path: 'sys.slug',
1537
+ isSelected: 'isSelected'
1538
+ };
1539
+
1540
+ const mapEntriesToFilterItems = entries => {
1541
+ if (!entries) return [];
1542
+ return entries.map(entry => {
1543
+ const template = base;
1544
+
1545
+ if (template) {
1546
+ return mapJson(entry, template);
1547
+ }
1548
+
1549
+ return entry;
1550
+ });
1551
+ };
1552
+
1553
+ const mapQueryParamsToCustomApi = queryParams => {
1554
+ const customApiMapping = {
1555
+ fields: ({
1556
+ fields
1557
+ }) => JSON.stringify(fields),
1558
+ orderBy: 'orderBy',
1559
+ linkDepth: 'linkDepth',
1560
+ pageSize: 'pageSize',
1561
+ pageIndex: 'pageIndex',
1562
+ term: {
1563
+ $path: 'searchTerm',
1564
+ $disable: t => !t
1565
+ },
1566
+ versionStatus: 'versionStatus'
1567
+ };
1568
+ Object.keys(queryParams.selectedFilters).forEach(k => {
1569
+ customApiMapping[k] = {
1570
+ $path: `selectedFilters.${k}`,
1571
+ $disable: f => !f
1572
+ };
1573
+ });
1574
+ return mapJson(queryParams, customApiMapping);
1575
+ };
1576
+
1577
+ const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters), takeEvery(DO_SEARCH, doSearch), takeEvery(SET_ROUTE_FILTERS, loadFilters), takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), takeEvery(UPDATE_SORT_ORDER, updateSortOrder), takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
1578
+
1579
+ const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
1580
+
1581
+ function* setRouteFilters(action) {
1582
+ const {
1583
+ mappers,
1584
+ params,
1585
+ listingType,
1586
+ defaultLang,
1587
+ debug
1588
+ } = action;
1589
+ const context = listingType ? Context.listings : Context.facets;
1590
+ const state = toJS(yield select());
1591
+ const ssr = getIsSsr(state); // Get current facet from params or state
1592
+
1593
+ let currentFacet = params && params.facet || listingType; // Pick the default facet from initialState
1594
+
1595
+ if (!currentFacet) {
1596
+ var _Object$keys;
1597
+
1598
+ const tabs = getSearchTabs(state, 'js');
1599
+ currentFacet = (tabs === null || tabs === void 0 ? void 0 : tabs[0].defaultFacet) || ((_Object$keys = Object.keys(getFacets(state, 'js'))) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0]) || '';
1600
+ }
1601
+
1602
+ const nextAction = {
1603
+ type: SET_ROUTE_FILTERS,
1604
+ context,
1605
+ facet: currentFacet,
1606
+ mappers,
1607
+ params,
1608
+ defaultLang,
1609
+ ssr,
1610
+ debug
1611
+ };
1612
+ yield put(nextAction); // keep track of this state ref for comparing changes to params later
1613
+
1614
+ const ogState = {
1615
+ search: state.search
1616
+ }; // Using call instead of triggering from the put
1617
+ // to allow this exported saga to continue during SSR
1618
+
1619
+ yield call(ensureSearch, { ...nextAction,
1620
+ ogState
1621
+ });
1622
+ }
1623
+ function* doSearch(action) {
1624
+ var _action$params;
1625
+
1626
+ const state = toJS(yield select());
1627
+
1628
+ if (action.config) {
1629
+ // If the action contains a config object, we can add this to the
1630
+ // state at runtime
1631
+ yield put({ ...action,
1632
+ type: APPLY_CONFIG
1633
+ });
1634
+ }
1635
+
1636
+ const nextAction = { ...action,
1637
+ type: SET_SEARCH_FILTERS,
1638
+ ssr: getIsSsr(state),
1639
+ facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
1640
+ };
1641
+
1642
+ if (nextAction.facet && (action.config || Object.keys(getFacet(state, nextAction.facet, action.context, 'js')).length > 0)) {
1643
+ yield put(nextAction); // keep track of this state ref for comparing changes to params later
1644
+
1645
+ const ogState = {
1646
+ search: state.search
1647
+ };
1648
+ yield call(ensureSearch, { ...nextAction,
1649
+ ogState
1650
+ });
1651
+ }
1652
+ }
1653
+
1654
+ function* loadFilters(action) {
1655
+ const {
1656
+ facet: facetKey,
1657
+ context,
1658
+ mappers = {}
1659
+ } = action;
1660
+ const filtersToLoad = yield select(getFiltersToLoad, facetKey, context, 'js');
1661
+
1662
+ if (filtersToLoad.length > 0) {
1663
+ yield put({
1664
+ type: LOAD_FILTERS,
1665
+ filtersToLoad,
1666
+ facetKey,
1667
+ context
1668
+ });
1669
+ const selectedKeys = yield select(getSelectedFilters, facetKey, context, 'js');
1670
+ const facet = yield select(getFacet, facetKey, context, 'js');
1671
+ const filters = facet.filters || {};
1672
+ const projectId = facet.projectId;
1673
+ const filtersToLoadSagas = filters && filtersToLoad.map((filterKey = '') => {
1674
+ return call(loadFilter, {
1675
+ facetKey,
1676
+ filterKey,
1677
+ filter: filters[filterKey],
1678
+ projectId,
1679
+ selectedKeys: selectedKeys[filterKey],
1680
+ context,
1681
+ mapper: 'filterItems' in mappers && mappers.filterItems || mapEntriesToFilterItems
1682
+ });
1683
+ });
1684
+ if (filtersToLoadSagas) yield all(filtersToLoadSagas);
1685
+ }
1686
+ }
1687
+
1688
+ function* loadFilter(action) {
1689
+ const {
1690
+ facetKey,
1691
+ filterKey,
1692
+ filter,
1693
+ projectId,
1694
+ selectedKeys,
1695
+ context,
1696
+ mapper
1697
+ } = action;
1698
+ const {
1699
+ contentTypeId,
1700
+ customWhere,
1701
+ path
1702
+ } = filter;
1703
+ const createStateFrom = {
1704
+ type: LOAD_FILTERS_COMPLETE,
1705
+ context,
1706
+ error: undefined,
1707
+ facetKey,
1708
+ filterKey,
1709
+ payload: {},
1710
+ selectedKeys,
1711
+ mapper
1712
+ };
1713
+
1714
+ try {
1715
+ if (contentTypeId) {
1716
+ const versionStatus = yield select(selectVersionStatus);
1717
+ const query = filterQuery(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId], versionStatus, customWhere);
1718
+ const payload = yield cachedSearch.search(query, 0, projectId);
1719
+ if (!payload) throw new Error('No payload returned by search');
1720
+ if (payload.type === 'error') throw payload;
1721
+ createStateFrom.payload = payload;
1722
+ }
1723
+
1724
+ if (path) {
1725
+ const payload = yield cachedSearch.getTaxonomyNodeByPath(path, projectId);
1726
+ if (!payload) throw new Error(`No payload returned for taxonomy path: '${path}'`);
1727
+ if (payload.type === 'error') throw payload;
1728
+ createStateFrom.payload = payload;
1729
+ }
1730
+ } catch (error) {
1731
+ createStateFrom.type = LOAD_FILTERS_ERROR;
1732
+ createStateFrom.error = error;
1733
+ }
1734
+
1735
+ const nextAction = mapJson(createStateFrom, filterTemplate);
1736
+ yield put(nextAction);
1737
+ }
1738
+
1739
+ function* ensureSearch(action) {
1740
+ const {
1741
+ context,
1742
+ facet,
1743
+ debug
1744
+ } = action;
1745
+
1746
+ try {
1747
+ const state = yield select();
1748
+ const nextAction = { ...action,
1749
+ ogState: action.ogState || {
1750
+ search: state.search
1751
+ }
1752
+ };
1753
+ const [queryParams, runSearch] = generateQueryParams(nextAction, state);
1754
+ if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
1755
+
1756
+ if (runSearch) {
1757
+ yield put({
1758
+ type: EXECUTE_SEARCH,
1759
+ facet,
1760
+ context
1761
+ });
1762
+ yield call(executeSearch, { ...nextAction,
1763
+ context,
1764
+ facet,
1765
+ queryParams,
1766
+ debug
1767
+ });
1768
+ }
1769
+ } catch (error) {
1770
+ // eslint-disable-next-line import/namespace
1771
+ log.error(...['Error running search saga:', error, error.stack]);
1772
+ }
1773
+ }
1774
+
1775
+ function* executeSearch(action) {
1776
+ const {
1777
+ context,
1778
+ facet,
1779
+ queryParams,
1780
+ mappers
1781
+ } = action;
1782
+
1783
+ try {
1784
+ const state = yield select();
1785
+ let result = {};
1786
+ let featuredResult;
1787
+ let featuredQuery;
1788
+ const customApi = getCustomApi(state, facet, context, 'js');
1789
+
1790
+ if (customApi) {
1791
+ const apiParams = typeof mappers === 'object' && typeof mappers.customApi === 'function' && mappers.customApi(queryParams) || mapQueryParamsToCustomApi(queryParams);
1792
+ result.payload = yield callCustomApi(customApi, apiParams);
1793
+ result.duration = 1;
1794
+ } else {
1795
+ if (queryParams.featuredResults) {
1796
+ featuredQuery = searchQuery(queryParams, true);
1797
+ featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env); // eslint-disable-next-line require-atomic-updates
1798
+
1799
+ queryParams.excludeIds = getItemsFromResult(featuredResult).map(fi => {
1800
+ var _fi$sys;
1801
+
1802
+ return fi === null || fi === void 0 ? void 0 : (_fi$sys = fi.sys) === null || _fi$sys === void 0 ? void 0 : _fi$sys.id;
1803
+ }).filter(fi => typeof fi === 'string');
1804
+ }
1805
+
1806
+ const query = searchQuery(queryParams);
1807
+ result = yield timedSearch(query, queryParams.linkDepth, queryParams.projectId, queryParams.env);
1808
+ }
1809
+
1810
+ const createStateFrom = {
1811
+ action,
1812
+ featuredResult,
1813
+ pageIndex: queryParams.internalPaging && queryParams.internalPageIndex || queryParams.pageIndex,
1814
+ prevResults: getResults(state, facet, action.context, 'js'),
1815
+ result,
1816
+ state
1817
+ };
1818
+ const nextAction = mapJson(createStateFrom, facetTemplate);
1819
+ yield put(nextAction);
1820
+ } catch (error) {
1821
+ // eslint-disable-next-line import/namespace
1822
+ log.error(...['Error running search saga:', error, error.stack]);
1823
+ }
1824
+ }
1825
+
1826
+ function* preloadOtherFacets(action) {
1827
+ const {
1828
+ preload,
1829
+ context,
1830
+ facet,
1831
+ debug
1832
+ } = action;
1833
+ const state = yield select();
1834
+ const currentFacet = getCurrentFacet(state);
1835
+
1836
+ if (!preload && facet === currentFacet && context !== Context.listings) {
1837
+ const allFacets = getFacets(state, 'js');
1838
+ const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
1839
+ yield all(otherFacets.map((preloadFacet = '') => {
1840
+ const preloadAction = { ...action,
1841
+ facet: preloadFacet,
1842
+ preload: true
1843
+ };
1844
+ const [queryParams, runSearch] = generateQueryParams(preloadAction, state);
1845
+ if (debug && (debug === true || debug.preloadOtherFacets)) debugExecuteSearch(preloadAction, state);
1846
+ return runSearch && call(executeSearch, { ...action,
1847
+ type: EXECUTE_SEARCH_PRELOAD,
1848
+ preload: true,
1849
+ facet: preloadFacet,
1850
+ queryParams
1851
+ });
1852
+ }));
1853
+ }
1854
+ }
1855
+
1856
+ function* updateCurrentTab(action) {
1857
+ const {
1858
+ id,
1859
+ mappers
1860
+ } = action;
1861
+ const state = yield select();
1862
+ const facets = getFacets(state, 'js');
1863
+ const tabs = getSearchTabs(state, 'js');
1864
+ let nextFacet = tabs === null || tabs === void 0 ? void 0 : tabs[id].currentFacet;
1865
+
1866
+ if (!nextFacet) {
1867
+ Object.entries(facets).map(([facetName, facet]) => {
1868
+ if (facet.tabId === id && (tabs === null || tabs === void 0 ? void 0 : tabs[id].defaultFacet) === facetName) nextFacet = facetName;
1869
+ });
1870
+ } // If the next Tab does not have a defaultFacet,
1871
+ // take the first facet for that tab
1872
+
1873
+
1874
+ if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
1875
+ yield put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
1876
+ }
1877
+
1878
+ function* clearFilters(action) {
1879
+ const {
1880
+ mappers
1881
+ } = action;
1882
+ const uri = yield buildUri({}, mappers);
1883
+ yield put(navigate(uri));
1884
+ }
1885
+
1886
+ function* updateCurrentFacet(action) {
1887
+ const {
1888
+ facet,
1889
+ mappers
1890
+ } = action;
1891
+ const pageIndex = yield select(getPageIndex, facet);
1892
+ const uri = yield buildUri({
1893
+ facet,
1894
+ pageIndex
1895
+ }, mappers);
1896
+ yield put(navigate(uri));
1897
+ }
1898
+
1899
+ function* updateSearchTerm(action) {
1900
+ const {
1901
+ term,
1902
+ mappers
1903
+ } = action;
1904
+ const uri = yield buildUri({
1905
+ term
1906
+ }, mappers);
1907
+ yield put(navigate(uri));
1908
+ }
1909
+
1910
+ function* updateSortOrder(action) {
1911
+ const {
1912
+ orderBy,
1913
+ facet,
1914
+ mappers
1915
+ } = action;
1916
+ const uri = yield buildUri({
1917
+ orderBy,
1918
+ facet
1919
+ }, mappers);
1920
+ yield put(navigate(uri));
1921
+ }
1922
+
1923
+ function* updatePageIndex(action) {
1924
+ const {
1925
+ pageIndex,
1926
+ mappers,
1927
+ scrollYPos
1928
+ } = action;
1929
+ const uri = yield buildUri({
1930
+ pageIndex
1931
+ }, mappers);
1932
+ yield put(navigate(uri));
1933
+ if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1934
+ }
1935
+
1936
+ function* applySearchFilter(action) {
1937
+ const {
1938
+ mappers,
1939
+ scrollYPos
1940
+ } = action;
1941
+ const uri = yield buildUri({}, mappers);
1942
+ yield put(navigate(uri));
1943
+ if (typeof scrollYPos !== 'undefined') scrollTop(scrollYPos);
1944
+ }
1945
+
1946
+ function* buildUri({
1947
+ facet,
1948
+ orderBy,
1949
+ pageIndex = 0,
1950
+ term
1951
+ }, mappers) {
1952
+ const state = yield select();
1953
+ const mapUri = (mappers === null || mappers === void 0 ? void 0 : mappers.navigate) || mapStateToSearchUri;
1954
+ const uri = mapUri({
1955
+ state,
1956
+ facet,
1957
+ orderBy,
1958
+ pageIndex,
1959
+ term
1960
+ }); // return uri;
1961
+
1962
+ return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
1963
+ }
1964
+
1965
+ export { APPLY_CONFIG as $, clearFilters$1 as A, updateCurrentFacet$1 as B, updateCurrentTab$1 as C, updatePageIndex$1 as D, updateSearchTerm$1 as E, updateSelectedFilters as F, updateSortOrder$1 as G, selectListing as H, mapStateToSearchUri as I, Context as J, selectFacets as K, triggerSearch as L, getFilters as M, toArray as N, UPDATE_SELECTED_FILTERS as O, UPDATE_SEARCH_TERM as P, UPDATE_PAGE_INDEX as Q, SET_SEARCH_ENTRIES as R, SET_SEARCH_FILTERS as S, SET_ROUTE_FILTERS as T, UPDATE_SORT_ORDER as U, LOAD_FILTERS_COMPLETE as V, LOAD_FILTERS_ERROR as W, LOAD_FILTERS as X, EXECUTE_SEARCH_ERROR as Y, EXECUTE_SEARCH as Z, CLEAR_FILTERS as _, customWhereExpressions as a, actions as a0, expressions as a1, queries as a2, selectors as a3, types as a4, doSearch as a5, setRouteFilters as a6, searchSagas as a7, getPageIndex as b, contentTypeIdExpression as c, defaultExpressions as d, getCurrentTab as e, filterExpressions as f, getCurrentFacet as g, getFacet as h, getTabFacets as i, getFacetsTotalCount as j, getFacetTitles as k, getFeaturedResults as l, getRenderableFilters as m, getIsLoading as n, orderByExpression as o, getPaging as p, getPageIsLoading as q, getResults as r, getSearchTerm as s, termExpressions as t, getSearchTotalCount as u, getSelectedFilters as v, getQueryParameter as w, getTabsAndFacets as x, getTotalCount as y, withMappers as z };
1966
+ //# sourceMappingURL=sagas-489c29ca.js.map