@internetarchive/collection-browser 0.4.9 → 0.4.10-alpha.1

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 (243) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +9 -9
  11. package/dist/src/app-root.d.ts +50 -50
  12. package/dist/src/app-root.js +278 -278
  13. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  14. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  15. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  16. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  17. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  18. package/dist/src/assets/img/icons/chevron.js +2 -2
  19. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  20. package/dist/src/assets/img/icons/empty-query.js +2 -2
  21. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  22. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  23. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  24. package/dist/src/assets/img/icons/eye.js +2 -2
  25. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  26. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  27. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  28. package/dist/src/assets/img/icons/login-required.js +2 -2
  29. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  30. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  31. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  32. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  33. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  34. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  35. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  36. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  37. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  38. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  39. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  40. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  41. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  42. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  43. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  44. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  45. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  46. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  47. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  48. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  49. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  50. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  51. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  52. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  53. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  54. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  55. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  56. package/dist/src/assets/img/icons/null-result.js +2 -2
  57. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  58. package/dist/src/assets/img/icons/restricted.js +2 -2
  59. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  60. package/dist/src/assets/img/icons/reviews.js +2 -2
  61. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  62. package/dist/src/assets/img/icons/upload.js +2 -2
  63. package/dist/src/assets/img/icons/views.d.ts +1 -1
  64. package/dist/src/assets/img/icons/views.js +2 -2
  65. package/dist/src/circular-activity-indicator.d.ts +5 -5
  66. package/dist/src/circular-activity-indicator.js +17 -17
  67. package/dist/src/collection-browser.d.ts +280 -281
  68. package/dist/src/collection-browser.js +1173 -1202
  69. package/dist/src/collection-browser.js.map +1 -1
  70. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  71. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  72. package/dist/src/collection-facets/facets-template.d.ts +16 -16
  73. package/dist/src/collection-facets/facets-template.js +125 -125
  74. package/dist/src/collection-facets/more-facets-content.d.ts +75 -77
  75. package/dist/src/collection-facets/more-facets-content.js +340 -357
  76. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  77. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  78. package/dist/src/collection-facets/more-facets-pagination.js +192 -192
  79. package/dist/src/collection-facets.d.ts +81 -83
  80. package/dist/src/collection-facets.js +375 -393
  81. package/dist/src/collection-facets.js.map +1 -1
  82. package/dist/src/empty-placeholder.d.ts +11 -11
  83. package/dist/src/empty-placeholder.js +42 -42
  84. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  85. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  86. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  87. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  88. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  89. package/dist/src/mediatype/mediatype-config.js +85 -85
  90. package/dist/src/models.d.ts +115 -115
  91. package/dist/src/models.js +125 -125
  92. package/dist/src/models.js.map +1 -1
  93. package/dist/src/restoration-state-handler.d.ts +45 -45
  94. package/dist/src/restoration-state-handler.js +230 -230
  95. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
  96. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
  97. package/dist/src/sort-filter-bar/alpha-bar.d.ts +20 -20
  98. package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
  99. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  100. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  101. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  102. package/dist/src/sort-filter-bar/img/list.js +2 -2
  103. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  104. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  105. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  106. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  107. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +113 -108
  108. package/dist/src/sort-filter-bar/sort-filter-bar.js +614 -548
  109. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  110. package/dist/src/styles/item-image-styles.d.ts +8 -8
  111. package/dist/src/styles/item-image-styles.js +9 -9
  112. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  113. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  114. package/dist/src/tiles/grid/account-tile.d.ts +20 -20
  115. package/dist/src/tiles/grid/account-tile.js +64 -64
  116. package/dist/src/tiles/grid/collection-tile.d.ts +17 -17
  117. package/dist/src/tiles/grid/collection-tile.js +71 -71
  118. package/dist/src/tiles/grid/item-tile.d.ts +32 -32
  119. package/dist/src/tiles/grid/item-tile.js +129 -126
  120. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  121. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  122. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +7 -7
  123. package/dist/src/tiles/grid/tile-stats.d.ts +10 -10
  124. package/dist/src/tiles/grid/tile-stats.js +40 -40
  125. package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
  126. package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
  127. package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
  128. package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
  129. package/dist/src/tiles/image-block.d.ts +17 -17
  130. package/dist/src/tiles/image-block.js +72 -72
  131. package/dist/src/tiles/item-image.d.ts +35 -35
  132. package/dist/src/tiles/item-image.js +117 -117
  133. package/dist/src/tiles/list/account-label.d.ts +1 -1
  134. package/dist/src/tiles/list/account-label.js +6 -6
  135. package/dist/src/tiles/list/date-label.d.ts +1 -1
  136. package/dist/src/tiles/list/date-label.js +12 -12
  137. package/dist/src/tiles/list/tile-list-compact-header.d.ts +12 -12
  138. package/dist/src/tiles/list/tile-list-compact-header.js +41 -41
  139. package/dist/src/tiles/list/tile-list-compact.d.ts +21 -21
  140. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  141. package/dist/src/tiles/list/tile-list.d.ts +55 -55
  142. package/dist/src/tiles/list/tile-list.js +301 -301
  143. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  144. package/dist/src/tiles/mediatype-icon.js +47 -47
  145. package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
  146. package/dist/src/tiles/overlay/icon-overlay.js +40 -40
  147. package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
  148. package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
  149. package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
  150. package/dist/src/tiles/overlay/text-overlay.js +42 -42
  151. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  152. package/dist/src/tiles/text-snippet-block.js +73 -73
  153. package/dist/src/tiles/tile-dispatcher.d.ts +58 -58
  154. package/dist/src/tiles/tile-dispatcher.js +194 -194
  155. package/dist/src/utils/analytics-events.d.ts +22 -22
  156. package/dist/src/utils/analytics-events.js +24 -24
  157. package/dist/src/utils/format-count.d.ts +7 -7
  158. package/dist/src/utils/format-count.js +76 -76
  159. package/dist/src/utils/format-date.d.ts +2 -2
  160. package/dist/src/utils/format-date.js +23 -23
  161. package/dist/src/utils/format-unit-size.d.ts +2 -2
  162. package/dist/src/utils/format-unit-size.js +33 -33
  163. package/dist/test/collection-browser.test.d.ts +1 -1
  164. package/dist/test/collection-browser.test.js +584 -584
  165. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  166. package/dist/test/collection-facets/facets-template.test.js +62 -62
  167. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  168. package/dist/test/collection-facets/more-facets-content.test.js +114 -114
  169. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  170. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  171. package/dist/test/collection-facets.test.d.ts +2 -2
  172. package/dist/test/collection-facets.test.js +460 -508
  173. package/dist/test/collection-facets.test.js.map +1 -1
  174. package/dist/test/empty-placeholder.test.d.ts +1 -1
  175. package/dist/test/empty-placeholder.test.js +33 -33
  176. package/dist/test/icon-overlay.test.d.ts +1 -1
  177. package/dist/test/icon-overlay.test.js +24 -24
  178. package/dist/test/image-block.test.d.ts +1 -1
  179. package/dist/test/image-block.test.js +48 -48
  180. package/dist/test/item-image.test.d.ts +1 -1
  181. package/dist/test/item-image.test.js +84 -84
  182. package/dist/test/mediatype-config.test.d.ts +1 -1
  183. package/dist/test/mediatype-config.test.js +16 -16
  184. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  185. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  186. package/dist/test/mocks/mock-collection-name-cache.d.ts +7 -7
  187. package/dist/test/mocks/mock-collection-name-cache.js +13 -13
  188. package/dist/test/mocks/mock-search-responses.d.ts +12 -12
  189. package/dist/test/mocks/mock-search-responses.js +341 -341
  190. package/dist/test/mocks/mock-search-service.d.ts +13 -13
  191. package/dist/test/mocks/mock-search-service.js +40 -40
  192. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  193. package/dist/test/restoration-state-handler.test.js +125 -125
  194. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
  195. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
  196. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  197. package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
  198. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  199. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +208 -197
  200. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  201. package/dist/test/text-overlay.test.d.ts +1 -1
  202. package/dist/test/text-overlay.test.js +48 -48
  203. package/dist/test/text-snippet-block.test.d.ts +1 -1
  204. package/dist/test/text-snippet-block.test.js +57 -57
  205. package/dist/test/tile-stats.test.d.ts +1 -1
  206. package/dist/test/tile-stats.test.js +33 -33
  207. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  208. package/dist/test/tiles/grid/account-tile.test.js +76 -76
  209. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  210. package/dist/test/tiles/grid/collection-tile.test.js +73 -73
  211. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  212. package/dist/test/tiles/grid/item-tile.test.js +158 -158
  213. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  214. package/dist/test/tiles/hover/hover-pane-controller.test.js +257 -257
  215. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  216. package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
  217. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  218. package/dist/test/tiles/list/tile-list-compact.test.js +92 -92
  219. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  220. package/dist/test/tiles/list/tile-list.test.js +163 -163
  221. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
  222. package/dist/test/tiles/tile-dispatcher.test.js +67 -67
  223. package/dist/test/utils/format-count.test.d.ts +1 -1
  224. package/dist/test/utils/format-count.test.js +23 -23
  225. package/dist/test/utils/format-date.test.d.ts +1 -1
  226. package/dist/test/utils/format-date.test.js +17 -17
  227. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  228. package/dist/test/utils/format-unit-size.test.js +17 -17
  229. package/local.archive.org.cert +86 -86
  230. package/local.archive.org.key +27 -27
  231. package/package.json +4 -3
  232. package/renovate.json +6 -6
  233. package/src/collection-browser.ts +1 -34
  234. package/src/collection-facets/more-facets-content.ts +2 -22
  235. package/src/collection-facets.ts +1 -24
  236. package/src/models.ts +6 -6
  237. package/src/sort-filter-bar/sort-filter-bar.ts +283 -197
  238. package/src/tiles/grid/item-tile.ts +5 -1
  239. package/test/collection-facets.test.ts +0 -67
  240. package/test/sort-filter-bar/sort-filter-bar.test.ts +56 -39
  241. package/tsconfig.json +21 -21
  242. package/web-dev-server.config.mjs +30 -30
  243. package/web-test-runner.config.mjs +41 -41
@@ -1,194 +1,192 @@
1
- import { __decorate } from "tslib";
2
- /* eslint-disable import/no-duplicates */
3
- import { html, css, LitElement, nothing, } from 'lit';
4
- import { customElement, property, query, state } from 'lit/decorators.js';
5
- import { classMap } from 'lit/directives/class-map.js';
6
- import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
7
- import '@internetarchive/infinite-scroller';
8
- import './tiles/tile-dispatcher';
9
- import './tiles/collection-browser-loading-tile';
10
- import './sort-filter-bar/sort-filter-bar';
11
- import './collection-facets';
12
- import './circular-activity-indicator';
13
- import './sort-filter-bar/sort-filter-bar';
14
- import { SortField, SortFieldToMetadataField, defaultSelectedFacets, prefixFilterAggregationKeys, } from './models';
15
- import { RestorationStateHandler, } from './restoration-state-handler';
16
- import chevronIcon from './assets/img/icons/chevron';
17
- import { LanguageCodeHandler } from './language-code-handler/language-code-handler';
18
- import './empty-placeholder';
19
- import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
20
- let CollectionBrowser = class CollectionBrowser extends LitElement {
21
- constructor() {
22
- super(...arguments);
23
- this.baseImageUrl = 'https://archive.org';
24
- this.searchType = SearchType.METADATA;
25
- this.sortParam = null;
26
- this.selectedSort = SortField.relevance;
27
- this.selectedTitleFilter = null;
28
- this.selectedCreatorFilter = null;
29
- this.sortDirection = null;
30
- this.pageSize = 50;
31
- this.showHistogramDatePicker = false;
32
- /** describes where this component is being used */
33
- this.searchContext = analyticsCategories.default;
34
- this.pageContext = 'search';
35
- this.restorationStateHandler = new RestorationStateHandler({
36
- context: this.pageContext,
37
- });
38
- this.mobileBreakpoint = 600;
39
- this.loggedIn = false;
40
- this.modalManager = undefined;
41
- /**
42
- * If item management UI active
43
- */
44
- this.isManageView = false;
45
- /**
46
- * The page that the consumer wants to load.
47
- */
48
- this.initialPageNumber = 1;
49
- /**
50
- * This the the number of pages that we want to show.
51
- *
52
- * The data isn't necessarily loaded for all of the pages, but this lets us
53
- * know how many cells we should render.
54
- */
55
- this.pagesToRender = this.initialPageNumber;
56
- this.searchResultsLoading = false;
57
- this.facetsLoading = false;
58
- this.fullYearAggregationLoading = false;
59
- this.mobileView = false;
60
- this.mobileFacetsVisible = false;
61
- this.placeholderType = null;
62
- this.prefixFilterCountMap = {};
63
- this.languageCodeHandler = new LanguageCodeHandler();
64
- /**
65
- * When we're animated scrolling to the page, we don't want to fetch
66
- * all of the pages as it scrolls so this lets us know if we're scrolling
67
- */
68
- this.isScrollingToCell = false;
69
- /**
70
- * When we've reached the end of the data, stop trying to fetch more
71
- */
72
- this.endOfDataReached = false;
73
- /**
74
- * When page width resizes from desktop to mobile, set true to
75
- * disable expand/collapse transition when loading.
76
- */
77
- this.isResizeToMobile = false;
78
- this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
79
- /**
80
- * The results per page so we can paginate.
81
- *
82
- * This allows us to start in the middle of the search results and
83
- * fetch data before or after the current page. If we don't have a key
84
- * for the previous/next page, we'll fetch the next/previous page to populate it
85
- */
86
- this.dataSource = {};
87
- // we only want to scroll on the very first query change
88
- // so this keeps track of whether we've already set the initial query
89
- this.initialQueryChangeHappened = false;
90
- this.historyPopOccurred = false;
91
- // this maps the query to the pages being fetched for that query
92
- this.pageFetchesInProgress = {};
93
- }
94
- tileModelAtCellIndex(index) {
95
- var _a;
96
- const pageNumber = Math.floor(index / this.pageSize) + 1;
97
- const itemIndex = index % this.pageSize;
98
- const model = (_a = this.dataSource[pageNumber]) === null || _a === void 0 ? void 0 : _a[itemIndex];
99
- /**
100
- * If we encounter a model we don't have yet and we're not in the middle of an
101
- * automated scroll, fetch the page and just return undefined.
102
- * The datasource will be updated once the page is loaded and the cell will be rendered.
103
- *
104
- * We disable it during the automated scroll since we may fetch pages for cells the
105
- * user may never see.
106
- */
107
- if (!model && !this.isScrollingToCell) {
108
- this.fetchPage(pageNumber);
109
- }
110
- return model;
111
- }
112
- get sortFilterQueries() {
113
- const queries = [this.titleQuery, this.creatorQuery];
114
- return queries.filter(q => q).join(' AND ');
115
- }
116
- // this is the total number of tiles we expect if
117
- // the data returned is a full page worth
118
- // this is useful for putting in placeholders for the expected number of tiles
119
- get estimatedTileCount() {
120
- return this.pagesToRender * this.pageSize;
121
- }
122
- // this is the actual number of tiles in the datasource,
123
- // which is useful for removing excess placeholder tiles
124
- // once we reached the end of the data
125
- get actualTileCount() {
126
- return Object.keys(this.dataSource).reduce((acc, page) => acc + this.dataSource[page].length, 0);
127
- }
128
- /**
129
- * Go to the given page of results
130
- *
131
- * @param pageNumber
132
- */
133
- goToPage(pageNumber) {
134
- this.initialPageNumber = pageNumber;
135
- this.pagesToRender = pageNumber;
136
- return this.scrollToPage(pageNumber);
137
- }
138
- clearFilters() {
139
- this.selectedFacets = defaultSelectedFacets;
140
- this.sortParam = null;
141
- this.selectedTitleFilter = null;
142
- this.selectedCreatorFilter = null;
143
- this.titleQuery = undefined;
144
- this.creatorQuery = undefined;
145
- this.selectedSort = SortField.relevance;
146
- this.sortDirection = null;
147
- }
148
- /**
149
- * Manually requests to perform a search, which will only be executed if one of
150
- * the query, the search type, or the sort has changed.
151
- */
152
- requestSearch() {
153
- this.handleQueryChange();
154
- }
155
- render() {
156
- this.setPlaceholderType();
1
+ import { __decorate } from "tslib";
2
+ /* eslint-disable import/no-duplicates */
3
+ import { html, css, LitElement, nothing, } from 'lit';
4
+ import { customElement, property, query, state } from 'lit/decorators.js';
5
+ import { classMap } from 'lit/directives/class-map.js';
6
+ import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
7
+ import '@internetarchive/infinite-scroller';
8
+ import './tiles/tile-dispatcher';
9
+ import './tiles/collection-browser-loading-tile';
10
+ import './sort-filter-bar/sort-filter-bar';
11
+ import './collection-facets';
12
+ import './circular-activity-indicator';
13
+ import './sort-filter-bar/sort-filter-bar';
14
+ import { SortField, SortFieldToMetadataField, defaultSelectedFacets, prefixFilterAggregationKeys, } from './models';
15
+ import { RestorationStateHandler, } from './restoration-state-handler';
16
+ import chevronIcon from './assets/img/icons/chevron';
17
+ import './empty-placeholder';
18
+ import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
19
+ let CollectionBrowser = class CollectionBrowser extends LitElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.baseImageUrl = 'https://archive.org';
23
+ this.searchType = SearchType.METADATA;
24
+ this.sortParam = null;
25
+ this.selectedSort = SortField.relevance;
26
+ this.selectedTitleFilter = null;
27
+ this.selectedCreatorFilter = null;
28
+ this.sortDirection = null;
29
+ this.pageSize = 50;
30
+ this.showHistogramDatePicker = false;
31
+ /** describes where this component is being used */
32
+ this.searchContext = analyticsCategories.default;
33
+ this.pageContext = 'search';
34
+ this.restorationStateHandler = new RestorationStateHandler({
35
+ context: this.pageContext,
36
+ });
37
+ this.mobileBreakpoint = 600;
38
+ this.loggedIn = false;
39
+ this.modalManager = undefined;
40
+ /**
41
+ * If item management UI active
42
+ */
43
+ this.isManageView = false;
44
+ /**
45
+ * The page that the consumer wants to load.
46
+ */
47
+ this.initialPageNumber = 1;
48
+ /**
49
+ * This the the number of pages that we want to show.
50
+ *
51
+ * The data isn't necessarily loaded for all of the pages, but this lets us
52
+ * know how many cells we should render.
53
+ */
54
+ this.pagesToRender = this.initialPageNumber;
55
+ this.searchResultsLoading = false;
56
+ this.facetsLoading = false;
57
+ this.fullYearAggregationLoading = false;
58
+ this.mobileView = false;
59
+ this.mobileFacetsVisible = false;
60
+ this.placeholderType = null;
61
+ this.prefixFilterCountMap = {};
62
+ /**
63
+ * When we're animated scrolling to the page, we don't want to fetch
64
+ * all of the pages as it scrolls so this lets us know if we're scrolling
65
+ */
66
+ this.isScrollingToCell = false;
67
+ /**
68
+ * When we've reached the end of the data, stop trying to fetch more
69
+ */
70
+ this.endOfDataReached = false;
71
+ /**
72
+ * When page width resizes from desktop to mobile, set true to
73
+ * disable expand/collapse transition when loading.
74
+ */
75
+ this.isResizeToMobile = false;
76
+ this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
77
+ /**
78
+ * The results per page so we can paginate.
79
+ *
80
+ * This allows us to start in the middle of the search results and
81
+ * fetch data before or after the current page. If we don't have a key
82
+ * for the previous/next page, we'll fetch the next/previous page to populate it
83
+ */
84
+ this.dataSource = {};
85
+ // we only want to scroll on the very first query change
86
+ // so this keeps track of whether we've already set the initial query
87
+ this.initialQueryChangeHappened = false;
88
+ this.historyPopOccurred = false;
89
+ // this maps the query to the pages being fetched for that query
90
+ this.pageFetchesInProgress = {};
91
+ }
92
+ tileModelAtCellIndex(index) {
93
+ var _a;
94
+ const pageNumber = Math.floor(index / this.pageSize) + 1;
95
+ const itemIndex = index % this.pageSize;
96
+ const model = (_a = this.dataSource[pageNumber]) === null || _a === void 0 ? void 0 : _a[itemIndex];
97
+ /**
98
+ * If we encounter a model we don't have yet and we're not in the middle of an
99
+ * automated scroll, fetch the page and just return undefined.
100
+ * The datasource will be updated once the page is loaded and the cell will be rendered.
101
+ *
102
+ * We disable it during the automated scroll since we may fetch pages for cells the
103
+ * user may never see.
104
+ */
105
+ if (!model && !this.isScrollingToCell) {
106
+ this.fetchPage(pageNumber);
107
+ }
108
+ return model;
109
+ }
110
+ get sortFilterQueries() {
111
+ const queries = [this.titleQuery, this.creatorQuery];
112
+ return queries.filter(q => q).join(' AND ');
113
+ }
114
+ // this is the total number of tiles we expect if
115
+ // the data returned is a full page worth
116
+ // this is useful for putting in placeholders for the expected number of tiles
117
+ get estimatedTileCount() {
118
+ return this.pagesToRender * this.pageSize;
119
+ }
120
+ // this is the actual number of tiles in the datasource,
121
+ // which is useful for removing excess placeholder tiles
122
+ // once we reached the end of the data
123
+ get actualTileCount() {
124
+ return Object.keys(this.dataSource).reduce((acc, page) => acc + this.dataSource[page].length, 0);
125
+ }
126
+ /**
127
+ * Go to the given page of results
128
+ *
129
+ * @param pageNumber
130
+ */
131
+ goToPage(pageNumber) {
132
+ this.initialPageNumber = pageNumber;
133
+ this.pagesToRender = pageNumber;
134
+ return this.scrollToPage(pageNumber);
135
+ }
136
+ clearFilters() {
137
+ this.selectedFacets = defaultSelectedFacets;
138
+ this.sortParam = null;
139
+ this.selectedTitleFilter = null;
140
+ this.selectedCreatorFilter = null;
141
+ this.titleQuery = undefined;
142
+ this.creatorQuery = undefined;
143
+ this.selectedSort = SortField.relevance;
144
+ this.sortDirection = null;
145
+ }
146
+ /**
147
+ * Manually requests to perform a search, which will only be executed if one of
148
+ * the query, the search type, or the sort has changed.
149
+ */
150
+ requestSearch() {
151
+ this.handleQueryChange();
152
+ }
153
+ render() {
154
+ this.setPlaceholderType();
157
155
  return html `
158
156
  <div
159
157
  id="content-container"
160
158
  class=${this.mobileView ? 'mobile' : 'desktop'}
161
159
  >
162
- ${this.placeholderType
163
- ? this.emptyPlaceholderTemplate
160
+ ${this.placeholderType
161
+ ? this.emptyPlaceholderTemplate
164
162
  : this.collectionBrowserTemplate}
165
163
  </div>
166
- `;
167
- }
168
- setPlaceholderType() {
169
- this.placeholderType = null;
170
- if (!this.baseQuery) {
171
- this.placeholderType = 'empty-query';
172
- }
173
- if ((!this.searchResultsLoading && this.totalResults === 0) ||
174
- !this.searchService) {
175
- this.placeholderType = 'null-result';
176
- }
177
- }
178
- get emptyPlaceholderTemplate() {
164
+ `;
165
+ }
166
+ setPlaceholderType() {
167
+ this.placeholderType = null;
168
+ if (!this.baseQuery) {
169
+ this.placeholderType = 'empty-query';
170
+ }
171
+ if ((!this.searchResultsLoading && this.totalResults === 0) ||
172
+ !this.searchService) {
173
+ this.placeholderType = 'null-result';
174
+ }
175
+ }
176
+ get emptyPlaceholderTemplate() {
179
177
  return html `
180
178
  <empty-placeholder
181
179
  .placeholderType=${this.placeholderType}
182
180
  ?isMobileView=${this.mobileView}
183
181
  ></empty-placeholder>
184
182
  ${this.infiniteScrollerTemplate}
185
- `;
186
- }
187
- get collectionBrowserTemplate() {
188
- var _a;
189
- const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
190
- const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
191
- const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
183
+ `;
184
+ }
185
+ get collectionBrowserTemplate() {
186
+ var _a;
187
+ const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
188
+ const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
189
+ const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
192
190
  return html `<div
193
191
  id="left-column"
194
192
  class="column${this.isResizeToMobile ? ' preload' : ''}"
@@ -206,8 +204,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
206
204
  </div>
207
205
  <div
208
206
  id="facets-container"
209
- class=${!this.mobileView || this.mobileFacetsVisible
210
- ? 'expanded'
207
+ class=${!this.mobileView || this.mobileFacetsVisible
208
+ ? 'expanded'
211
209
  : ''}
212
210
  >
213
211
  ${this.facetsTemplate}
@@ -215,13 +213,13 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
215
213
  </div>
216
214
  <div id="right-column" class="column">
217
215
  ${this.sortFilterBarTemplate}
218
- ${this.displayMode === `list-compact`
219
- ? this.listHeaderTemplate
216
+ ${this.displayMode === `list-compact`
217
+ ? this.listHeaderTemplate
220
218
  : nothing}
221
219
  ${this.infiniteScrollerTemplate}
222
- </div>`;
223
- }
224
- get infiniteScrollerTemplate() {
220
+ </div>`;
221
+ }
222
+ get infiniteScrollerTemplate() {
225
223
  return html `<infinite-scroller
226
224
  class=${this.infiniteScrollerClasses}
227
225
  itemCount=${this.placeholderType ? 0 : nothing}
@@ -229,16 +227,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
229
227
  .placeholderCellTemplate=${this.placeholderCellTemplate}
230
228
  @scrollThresholdReached=${this.scrollThresholdReached}
231
229
  @visibleCellsChanged=${this.visibleCellsChanged}
232
- ></infinite-scroller>`;
233
- }
234
- get infiniteScrollerClasses() {
235
- var _a;
236
- return classMap({
237
- [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
238
- hidden: !!this.placeholderType,
239
- });
240
- }
241
- get sortFilterBarTemplate() {
230
+ ></infinite-scroller>`;
231
+ }
232
+ get infiniteScrollerClasses() {
233
+ var _a;
234
+ return classMap({
235
+ [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
236
+ hidden: !!this.placeholderType,
237
+ });
238
+ }
239
+ get sortFilterBarTemplate() {
242
240
  return html `
243
241
  <sort-filter-bar
244
242
  .selectedSort=${this.selectedSort}
@@ -254,113 +252,113 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
254
252
  @creatorLetterChanged=${this.creatorLetterSelected}
255
253
  >
256
254
  </sort-filter-bar>
257
- `;
258
- }
259
- userChangedSort(e) {
260
- var _a;
261
- const { selectedSort, sortDirection } = e.detail;
262
- this.selectedSort = selectedSort;
263
- this.sortDirection = sortDirection;
264
- if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
265
- this.goToPage(1);
266
- }
267
- this.currentPage = 1;
268
- }
269
- sendSortByAnalytics(prevSortDirection) {
270
- var _a;
271
- const directionCleared = prevSortDirection && !this.sortDirection;
272
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
273
- category: this.searchContext,
274
- action: analyticsActions.sortBy,
275
- label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
276
- });
277
- }
278
- selectedSortChanged() {
279
- if (this.selectedSort === 'relevance' || this.sortDirection === null) {
280
- this.sortParam = null;
281
- return;
282
- }
283
- const sortField = SortFieldToMetadataField[this.selectedSort];
284
- if (!sortField)
285
- return;
286
- this.sortParam = { field: sortField, direction: this.sortDirection };
287
- // Lazy-load the alphabet counts for title/creator sort bar as needed
288
- this.updatePrefixFiltersForCurrentSort();
289
- }
290
- displayModeChanged(e) {
291
- var _a;
292
- this.displayMode = e.detail.displayMode;
293
- if (this.displayMode) {
294
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
295
- category: this.searchContext,
296
- action: analyticsActions.displayMode,
297
- label: this.displayMode,
298
- });
299
- }
300
- }
301
- /** Send Analytics when sorting by title's first letter
302
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
303
- * */
304
- sendFilterByTitleAnalytics(prevSelectedLetter) {
305
- var _a;
306
- if (!prevSelectedLetter && !this.selectedTitleFilter) {
307
- return;
308
- }
309
- const cleared = prevSelectedLetter && this.selectedTitleFilter === null;
310
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
311
- category: this.searchContext,
312
- action: analyticsActions.filterByTitle,
313
- label: cleared
314
- ? `clear-${prevSelectedLetter}`
315
- : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
316
- });
317
- }
318
- selectedTitleLetterChanged() {
319
- this.titleQuery = this.selectedTitleFilter
320
- ? `firstTitle:${this.selectedTitleFilter}`
321
- : undefined;
322
- }
323
- /** Send Analytics when filtering by creator's first letter
324
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
325
- * */
326
- sendFilterByCreatorAnalytics(prevSelectedLetter) {
327
- var _a;
328
- if (!prevSelectedLetter && !this.selectedCreatorFilter) {
329
- return;
330
- }
331
- const cleared = prevSelectedLetter && this.selectedCreatorFilter === null;
332
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
333
- category: this.searchContext,
334
- action: analyticsActions.filterByCreator,
335
- label: cleared
336
- ? `clear-${prevSelectedLetter}`
337
- : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
338
- });
339
- }
340
- selectedCreatorLetterChanged() {
341
- this.creatorQuery = this.selectedCreatorFilter
342
- ? `firstCreator:${this.selectedCreatorFilter}`
343
- : undefined;
344
- }
345
- titleLetterSelected(e) {
346
- this.selectedCreatorFilter = null;
347
- this.selectedTitleFilter = e.detail.selectedLetter;
348
- }
349
- creatorLetterSelected(e) {
350
- this.selectedTitleFilter = null;
351
- this.selectedCreatorFilter = e.detail.selectedLetter;
352
- }
353
- get mobileFacetsTemplate() {
255
+ `;
256
+ }
257
+ userChangedSort(e) {
258
+ var _a;
259
+ const { selectedSort, sortDirection } = e.detail;
260
+ this.selectedSort = selectedSort;
261
+ this.sortDirection = sortDirection;
262
+ if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
263
+ this.goToPage(1);
264
+ }
265
+ this.currentPage = 1;
266
+ }
267
+ sendSortByAnalytics(prevSortDirection) {
268
+ var _a;
269
+ const directionCleared = prevSortDirection && !this.sortDirection;
270
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
271
+ category: this.searchContext,
272
+ action: analyticsActions.sortBy,
273
+ label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
274
+ });
275
+ }
276
+ selectedSortChanged() {
277
+ if (this.selectedSort === 'relevance' || this.sortDirection === null) {
278
+ this.sortParam = null;
279
+ return;
280
+ }
281
+ const sortField = SortFieldToMetadataField[this.selectedSort];
282
+ if (!sortField)
283
+ return;
284
+ this.sortParam = { field: sortField, direction: this.sortDirection };
285
+ // Lazy-load the alphabet counts for title/creator sort bar as needed
286
+ this.updatePrefixFiltersForCurrentSort();
287
+ }
288
+ displayModeChanged(e) {
289
+ var _a;
290
+ this.displayMode = e.detail.displayMode;
291
+ if (this.displayMode) {
292
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
293
+ category: this.searchContext,
294
+ action: analyticsActions.displayMode,
295
+ label: this.displayMode,
296
+ });
297
+ }
298
+ }
299
+ /** Send Analytics when sorting by title's first letter
300
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
301
+ * */
302
+ sendFilterByTitleAnalytics(prevSelectedLetter) {
303
+ var _a;
304
+ if (!prevSelectedLetter && !this.selectedTitleFilter) {
305
+ return;
306
+ }
307
+ const cleared = prevSelectedLetter && this.selectedTitleFilter === null;
308
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
309
+ category: this.searchContext,
310
+ action: analyticsActions.filterByTitle,
311
+ label: cleared
312
+ ? `clear-${prevSelectedLetter}`
313
+ : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
314
+ });
315
+ }
316
+ selectedTitleLetterChanged() {
317
+ this.titleQuery = this.selectedTitleFilter
318
+ ? `firstTitle:${this.selectedTitleFilter}`
319
+ : undefined;
320
+ }
321
+ /** Send Analytics when filtering by creator's first letter
322
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
323
+ * */
324
+ sendFilterByCreatorAnalytics(prevSelectedLetter) {
325
+ var _a;
326
+ if (!prevSelectedLetter && !this.selectedCreatorFilter) {
327
+ return;
328
+ }
329
+ const cleared = prevSelectedLetter && this.selectedCreatorFilter === null;
330
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
331
+ category: this.searchContext,
332
+ action: analyticsActions.filterByCreator,
333
+ label: cleared
334
+ ? `clear-${prevSelectedLetter}`
335
+ : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
336
+ });
337
+ }
338
+ selectedCreatorLetterChanged() {
339
+ this.creatorQuery = this.selectedCreatorFilter
340
+ ? `firstCreator:${this.selectedCreatorFilter}`
341
+ : undefined;
342
+ }
343
+ titleLetterSelected(e) {
344
+ this.selectedCreatorFilter = null;
345
+ this.selectedTitleFilter = e.detail.selectedLetter;
346
+ }
347
+ creatorLetterSelected(e) {
348
+ this.selectedTitleFilter = null;
349
+ this.selectedCreatorFilter = e.detail.selectedLetter;
350
+ }
351
+ get mobileFacetsTemplate() {
354
352
  return html `
355
353
  <div id="mobile-filter-collapse">
356
354
  <h1
357
- @click=${() => {
358
- this.isResizeToMobile = false;
359
- this.mobileFacetsVisible = !this.mobileFacetsVisible;
355
+ @click=${() => {
356
+ this.isResizeToMobile = false;
357
+ this.mobileFacetsVisible = !this.mobileFacetsVisible;
360
358
  }}
361
- @keyup=${() => {
362
- this.isResizeToMobile = false;
363
- this.mobileFacetsVisible = !this.mobileFacetsVisible;
359
+ @keyup=${() => {
360
+ this.isResizeToMobile = false;
361
+ this.mobileFacetsVisible = !this.mobileFacetsVisible;
364
362
  }}
365
363
  >
366
364
  <span class="collapser ${this.mobileFacetsVisible ? 'open' : ''}">
@@ -369,9 +367,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
369
367
  Filters
370
368
  </h1>
371
369
  </div>
372
- `;
373
- }
374
- get facetsTemplate() {
370
+ `;
371
+ }
372
+ get facetsTemplate() {
375
373
  return html `
376
374
  <collection-facets
377
375
  @facetsChanged=${this.facetsChanged}
@@ -388,7 +386,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
388
386
  .maxSelectedDate=${this.maxSelectedDate}
389
387
  .selectedFacets=${this.selectedFacets}
390
388
  .collectionNameCache=${this.collectionNameCache}
391
- .languageCodeHandler=${this.languageCodeHandler}
392
389
  .showHistogramDatePicker=${this.showHistogramDatePicker}
393
390
  .query=${this.filteredQuery}
394
391
  .filterMap=${this.filterMap}
@@ -400,16 +397,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
400
397
  .analyticsHandler=${this.analyticsHandler}
401
398
  >
402
399
  </collection-facets>
403
- `;
404
- }
405
- get loadingTemplate() {
400
+ `;
401
+ }
402
+ get loadingTemplate() {
406
403
  return html `
407
404
  <div class="loading-cover">
408
405
  <circular-activity-indicator></circular-activity-indicator>
409
406
  </div>
410
- `;
411
- }
412
- get listHeaderTemplate() {
407
+ `;
408
+ }
409
+ get listHeaderTemplate() {
413
410
  return html `
414
411
  <div id="list-header">
415
412
  <tile-dispatcher
@@ -421,747 +418,721 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
421
418
  >
422
419
  </tile-dispatcher>
423
420
  </div>
424
- `;
425
- }
426
- histogramDateRangeUpdated(e) {
427
- var _a;
428
- const { minDate, maxDate } = e.detail;
429
- [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
430
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
431
- category: this.searchContext,
432
- action: analyticsActions.histogramChanged,
433
- label: this.dateRangeQueryClause,
434
- });
435
- }
436
- get dateRangeQueryClause() {
437
- if (!this.minSelectedDate || !this.maxSelectedDate) {
438
- return undefined;
439
- }
440
- return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
441
- }
442
- firstUpdated() {
443
- this.setupStateRestorationObserver();
444
- this.restoreState();
445
- }
446
- updated(changed) {
447
- var _a;
448
- if (changed.has('displayMode') ||
449
- changed.has('baseNavigationUrl') ||
450
- changed.has('baseImageUrl') ||
451
- changed.has('loggedIn')) {
452
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
453
- }
454
- if (changed.has('baseQuery')) {
455
- this.emitBaseQueryChanged();
456
- }
457
- if (changed.has('searchType')) {
458
- this.emitSearchTypeChanged();
459
- }
460
- if (changed.has('currentPage') || changed.has('displayMode')) {
461
- this.persistState();
462
- }
463
- if (changed.has('baseQuery') ||
464
- changed.has('titleQuery') ||
465
- changed.has('creatorQuery') ||
466
- changed.has('minSelectedDate') ||
467
- changed.has('maxSelectedDate') ||
468
- changed.has('sortParam') ||
469
- changed.has('selectedFacets') ||
470
- changed.has('searchService')) {
471
- this.handleQueryChange();
472
- }
473
- if (changed.has('baseQuery') ||
474
- changed.has('minSelectedDate') ||
475
- changed.has('maxSelectedDate') ||
476
- changed.has('selectedFacets')) {
477
- this.refreshLetterCounts();
478
- }
479
- if (changed.has('selectedSort') || changed.has('sortDirection')) {
480
- const prevSortDirection = changed.get('sortDirection');
481
- this.sendSortByAnalytics(prevSortDirection);
482
- this.selectedSortChanged();
483
- }
484
- if (changed.has('selectedTitleFilter')) {
485
- this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
486
- this.selectedTitleLetterChanged();
487
- }
488
- if (changed.has('selectedCreatorFilter')) {
489
- this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
490
- this.selectedCreatorLetterChanged();
491
- }
492
- if (changed.has('pagesToRender')) {
493
- if (!this.endOfDataReached && this.infiniteScroller) {
494
- this.infiniteScroller.itemCount = this.estimatedTileCount;
495
- }
496
- }
497
- if (changed.has('resizeObserver')) {
498
- const oldObserver = changed.get('resizeObserver');
499
- if (oldObserver)
500
- this.disconnectResizeObserver(oldObserver);
501
- this.setupResizeObserver();
502
- }
503
- }
504
- disconnectedCallback() {
505
- if (this.resizeObserver) {
506
- this.disconnectResizeObserver(this.resizeObserver);
507
- }
508
- if (this.boundNavigationHandler) {
509
- window.removeEventListener('popstate', this.boundNavigationHandler);
510
- }
511
- }
512
- handleResize(entry) {
513
- const previousView = this.mobileView;
514
- if (entry.target === this.contentContainer) {
515
- this.mobileView = entry.contentRect.width < this.mobileBreakpoint;
516
- // If changing from desktop to mobile disable transition
517
- if (this.mobileView && !previousView) {
518
- this.isResizeToMobile = true;
519
- }
520
- }
521
- }
522
- emitBaseQueryChanged() {
523
- this.dispatchEvent(new CustomEvent('baseQueryChanged', {
524
- detail: {
525
- baseQuery: this.baseQuery,
526
- },
527
- }));
528
- }
529
- emitSearchTypeChanged() {
530
- this.dispatchEvent(new CustomEvent('searchTypeChanged', {
531
- detail: this.searchType,
532
- }));
533
- }
534
- disconnectResizeObserver(resizeObserver) {
535
- resizeObserver.removeObserver({
536
- target: this.contentContainer,
537
- handler: this,
538
- });
539
- }
540
- setupResizeObserver() {
541
- if (!this.resizeObserver)
542
- return;
543
- this.resizeObserver.addObserver({
544
- target: this.contentContainer,
545
- handler: this,
546
- });
547
- }
548
- /**
549
- * When the visible cells change from the infinite scroller, we want to emit
550
- * which page is currently visible so the consumer can update its UI or the URL
551
- *
552
- * @param e
553
- * @returns
554
- */
555
- visibleCellsChanged(e) {
556
- if (this.isScrollingToCell)
557
- return;
558
- const { visibleCellIndices } = e.detail;
559
- if (visibleCellIndices.length === 0)
560
- return;
561
- const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
562
- const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
563
- if (this.currentPage !== lastVisibleCellPage) {
564
- this.currentPage = lastVisibleCellPage;
565
- }
566
- const event = new CustomEvent('visiblePageChanged', {
567
- detail: {
568
- pageNumber: lastVisibleCellPage,
569
- },
570
- });
571
- this.dispatchEvent(event);
572
- }
573
- async handleQueryChange() {
574
- var _a;
575
- // only reset if the query has actually changed
576
- if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
577
- return;
578
- this.previousQueryKey = this.pageFetchQueryKey;
579
- this.dataSource = {};
580
- this.totalResults = undefined;
581
- this.aggregations = undefined;
582
- this.fullYearsHistogramAggregation = undefined;
583
- this.pageFetchesInProgress = {};
584
- this.endOfDataReached = false;
585
- this.pagesToRender = this.initialPageNumber;
586
- // Reset the infinite scroller's item count, so that it
587
- // shows tile placeholders until the new query's results load in
588
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
589
- if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
590
- this.scrollToPage(this.initialPageNumber);
591
- }
592
- this.initialQueryChangeHappened = true;
593
- // if the query changed as part of a window.history pop event, we don't want to
594
- // persist the state because it overwrites the forward history
595
- if (!this.historyPopOccurred) {
596
- this.persistState();
597
- this.historyPopOccurred = false;
598
- }
599
- await Promise.all([this.doInitialPageFetch(), this.fetchFacets()]);
600
- }
601
- setupStateRestorationObserver() {
602
- if (this.boundNavigationHandler)
603
- return;
604
- this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
605
- // when the user navigates back, we want to update the UI to match the URL
606
- window.addEventListener('popstate', this.boundNavigationHandler);
607
- }
608
- historyNavigationHandler() {
609
- this.historyPopOccurred = true;
610
- this.restoreState();
611
- }
612
- restoreState() {
613
- var _a, _b, _c, _d, _e, _f;
614
- const restorationState = this.restorationStateHandler.getRestorationState();
615
- this.displayMode = restorationState.displayMode;
616
- if (restorationState.searchType != null)
617
- this.searchType = restorationState.searchType;
618
- this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
619
- this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
620
- this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
621
- this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
622
- this.selectedFacets = restorationState.selectedFacets;
623
- this.baseQuery = restorationState.baseQuery;
624
- this.titleQuery = restorationState.titleQuery;
625
- this.creatorQuery = restorationState.creatorQuery;
626
- this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
627
- this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
628
- this.minSelectedDate = restorationState.minSelectedDate;
629
- this.maxSelectedDate = restorationState.maxSelectedDate;
630
- if (this.currentPage > 1) {
631
- this.goToPage(this.currentPage);
632
- }
633
- }
634
- persistState() {
635
- var _a, _b, _c, _d, _e;
636
- const restorationState = {
637
- displayMode: this.displayMode,
638
- searchType: this.searchType,
639
- sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
640
- selectedSort: this.selectedSort,
641
- sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
642
- selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : defaultSelectedFacets,
643
- baseQuery: this.baseQuery,
644
- currentPage: this.currentPage,
645
- titleQuery: this.titleQuery,
646
- creatorQuery: this.creatorQuery,
647
- minSelectedDate: this.minSelectedDate,
648
- maxSelectedDate: this.maxSelectedDate,
649
- selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
650
- selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
651
- };
652
- this.restorationStateHandler.persistState(restorationState);
653
- }
654
- async doInitialPageFetch() {
655
- this.searchResultsLoading = true;
656
- await this.fetchPage(this.initialPageNumber);
657
- this.searchResultsLoading = false;
658
- }
659
- get filterMap() {
660
- const builder = new FilterMapBuilder();
661
- // Add the date range, if applicable
662
- if (this.minSelectedDate) {
663
- builder.addFilter('year', this.minSelectedDate, FilterConstraint.GREATER_OR_EQUAL);
664
- }
665
- if (this.maxSelectedDate) {
666
- builder.addFilter('year', this.maxSelectedDate, FilterConstraint.LESS_OR_EQUAL);
667
- }
668
- // Add any selected facets
669
- if (this.selectedFacets) {
670
- for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
671
- const { name, values } = this.prepareFacetForFetch(facetName, facetValues);
672
- for (const [value, bucket] of Object.entries(values)) {
673
- let constraint;
674
- if (bucket.state === 'selected') {
675
- constraint = FilterConstraint.INCLUDE;
676
- }
677
- else if (bucket.state === 'hidden') {
678
- constraint = FilterConstraint.EXCLUDE;
679
- }
680
- if (constraint) {
681
- builder.addFilter(name, value, constraint);
682
- }
683
- }
684
- }
685
- }
686
- const filterMap = builder.build();
687
- // TEMP: At present, the backend search engine incorrectly returns 0 results if
688
- // the _first_ language filter contains a space, so let's try to avoid that if possible.
689
- if (filterMap.language) {
690
- for (const [value, constraint] of Object.entries(filterMap.language)) {
691
- if (value.includes(' ')) {
692
- // Delete and re-add this filter to make it the last one on the parent object
693
- // (Technically this isn't in the standard, but most browser impls output
694
- // object keys in the order they were added.)
695
- delete filterMap.language[value];
696
- filterMap.language[value] = constraint;
697
- }
698
- else {
699
- // As soon as we reach one without a space, we're done
700
- break;
701
- }
702
- }
703
- }
704
- return filterMap;
705
- }
706
- /** The base query joined with any title/creator letter filters */
707
- get filteredQuery() {
708
- if (!this.baseQuery)
709
- return undefined;
710
- let filteredQuery = this.baseQuery;
711
- const { sortFilterQueries } = this;
712
- if (sortFilterQueries) {
713
- filteredQuery += ` AND ${sortFilterQueries}`;
714
- }
715
- return filteredQuery;
716
- }
717
- /** The full query, including year facets and date range clauses */
718
- get fullQuery() {
719
- if (!this.baseQuery)
720
- return undefined;
721
- let fullQuery = this.baseQuery;
722
- const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
723
- if (facetQuery) {
724
- fullQuery += ` AND ${facetQuery}`;
725
- }
726
- if (dateRangeQueryClause) {
727
- fullQuery += ` AND ${dateRangeQueryClause}`;
728
- }
729
- if (sortFilterQueries) {
730
- fullQuery += ` AND ${sortFilterQueries}`;
731
- }
732
- return fullQuery;
733
- }
734
- /** The full query without any title/creator letter filters */
735
- get fullQueryWithoutAlphaFilters() {
736
- if (!this.baseQuery)
737
- return undefined;
738
- let fullQuery = this.baseQuery;
739
- const { facetQuery, dateRangeQueryClause } = this;
740
- if (facetQuery) {
741
- fullQuery += ` AND ${facetQuery}`;
742
- }
743
- if (dateRangeQueryClause) {
744
- fullQuery += ` AND ${dateRangeQueryClause}`;
745
- }
746
- return fullQuery;
747
- }
748
- /**
749
- * Generates a query string for the given facets
750
- *
751
- * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
752
- */
753
- get facetQuery() {
754
- if (!this.selectedFacets)
755
- return undefined;
756
- const facetClauses = [];
757
- for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
758
- facetClauses.push(this.buildFacetClause(facetName, facetValues));
759
- }
760
- return this.joinFacetClauses(facetClauses);
761
- }
762
- /**
763
- * Builds an OR-joined facet clause for the given facet name and values.
764
- *
765
- * E.g., for name `subject` and values
766
- * `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
767
- * this will produce the clause
768
- * `subject:("foo" OR -"bar")`.
769
- *
770
- * @param facetName The facet type (e.g., 'collection')
771
- * @param facetValues The facet buckets, mapped by their keys
772
- */
773
- buildFacetClause(facetName, facetValues) {
774
- const { name: facetQueryName, values } = this.prepareFacetForFetch(facetName, facetValues);
775
- const facetEntries = Object.entries(values);
776
- if (facetEntries.length === 0)
777
- return '';
778
- const facetValuesArray = [];
779
- for (const [key, facetData] of facetEntries) {
780
- const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
781
- facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
782
- }
783
- const valueQuery = facetValuesArray.join(` OR `);
784
- return `${facetQueryName}:(${valueQuery})`;
785
- }
786
- /**
787
- * Handles some special pre-request normalization steps for certain facet types
788
- * that require them.
789
- *
790
- * @param facetName The name of the facet type (e.g., 'language')
791
- * @param facetValues An array of values for that facet type
792
- */
793
- prepareFacetForFetch(facetName, facetValues) {
794
- let [normalizedName, normalizedValues] = [facetName, facetValues];
795
- // The full "search engine" name of the lending field is "lending___status"
796
- if (facetName === 'lending') {
797
- normalizedName = 'lending___status';
798
- }
799
- // Language codes like "en-US|en-GB|en" need to be broken apart into individual values
800
- if (facetName === 'language') {
801
- normalizedValues = {};
802
- for (const [facetValue, facetData] of Object.entries(facetValues)) {
803
- const languages = this.languageCodeHandler.getCodeArrayFromCodeString(facetValue);
804
- for (const lang of languages) {
805
- normalizedValues[lang] = { ...facetData };
806
- }
807
- }
808
- }
809
- return {
810
- name: normalizedName,
811
- values: normalizedValues,
812
- };
813
- }
814
- /**
815
- * Takes an array of facet clauses, and combines them into a
816
- * full AND-joined facet query string. Empty clauses are ignored.
817
- */
818
- joinFacetClauses(facetClauses) {
819
- const nonEmptyFacetClauses = facetClauses.filter(clause => clause.length > 0);
820
- return nonEmptyFacetClauses.length > 0
821
- ? `(${nonEmptyFacetClauses.join(' AND ')})`
822
- : undefined;
823
- }
824
- facetsChanged(e) {
825
- this.selectedFacets = e.detail;
826
- }
827
- facetClickHandler(name, facetSelected, negative) {
828
- var _a, _b;
829
- if (negative) {
830
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
831
- category: this.searchContext,
832
- action: facetSelected
833
- ? analyticsActions.facetNegativeSelected
834
- : analyticsActions.facetNegativeDeselected,
835
- label: name,
836
- });
837
- }
838
- else {
839
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
840
- category: this.searchContext,
841
- action: facetSelected
842
- ? analyticsActions.facetSelected
843
- : analyticsActions.facetDeselected,
844
- label: name,
845
- });
846
- }
847
- }
848
- async fetchFacets() {
849
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
850
- if (!this.filteredQuery)
851
- return;
852
- const params = {
853
- query: this.filteredQuery,
854
- rows: 0,
855
- filters: this.filterMap,
856
- // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
857
- aggregationsSize: 10,
858
- // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
859
- // The default aggregations for the search_results page type should be what we need here.
860
- };
861
- this.facetsLoading = true;
862
- this.previousSearchType = this.searchType;
863
- const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
864
- this.facetsLoading = false;
865
- this.aggregations = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response.aggregations;
866
- this.fullYearsHistogramAggregation =
867
- (_f = (_e = (_d = (_c = results === null || results === void 0 ? void 0 : results.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e.year_histogram) !== null && _f !== void 0 ? _f : (_j = (_h = (_g = results === null || results === void 0 ? void 0 : results.success) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.aggregations) === null || _j === void 0 ? void 0 : _j['year-histogram']; // Temp fix until PPS FTS key is fixed to use underscore
868
- }
869
- scrollToPage(pageNumber) {
870
- return new Promise(resolve => {
871
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
872
- // without this setTimeout, Safari just pauses until the `fetchPage` is complete
873
- // then scrolls to the cell
874
- setTimeout(() => {
875
- var _a;
876
- this.isScrollingToCell = true;
877
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
878
- // This timeout is to give the scroll animation time to finish
879
- // then updating the infinite scroller once we're done scrolling
880
- // There's no scroll animation completion callback so we're
881
- // giving it 0.5s to finish.
882
- setTimeout(() => {
883
- var _a;
884
- this.isScrollingToCell = false;
885
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
886
- resolve();
887
- }, 500);
888
- }, 0);
889
- });
890
- }
891
- /**
892
- * The query key is a string that uniquely identifies the current search.
893
- * It consists of:
894
- * - The current base query
895
- * - The current search type
896
- * - Any currently-applied facets
897
- * - Any currently-applied date range
898
- * - Any currently-applied prefix filters
899
- * - The current sort options
900
- *
901
- * This lets us keep track of queries so we don't persist data that's
902
- * no longer relevant.
903
- */
904
- get pageFetchQueryKey() {
905
- var _a, _b;
906
- return `${this.fullQuery}-${this.searchType}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
907
- }
908
- async fetchPage(pageNumber) {
909
- var _a, _b, _c, _d, _e;
910
- if (!this.filteredQuery)
911
- return;
912
- // if we already have data, don't fetch again
913
- if (this.dataSource[pageNumber])
914
- return;
915
- if (this.endOfDataReached)
916
- return;
917
- // if a fetch is already in progress for this query and page, don't fetch again
918
- const { pageFetchQueryKey } = this;
919
- const pageFetches = (_a = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _a !== void 0 ? _a : new Set();
920
- if (pageFetches.has(pageNumber))
921
- return;
922
- pageFetches.add(pageNumber);
923
- this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
924
- const sortParams = this.sortParam ? [this.sortParam] : [];
925
- const params = {
926
- query: this.filteredQuery,
927
- page: pageNumber,
928
- rows: this.pageSize,
929
- sort: sortParams,
930
- filters: this.filterMap,
931
- aggregations: { omit: true },
932
- };
933
- const searchResponse = await ((_b = this.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.searchType));
934
- const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
935
- if (!success)
936
- return;
937
- this.totalResults = success.response.totalResults;
938
- // this is checking to see if the query has changed since the data was fetched
939
- // if so, we just want to discard the data since there should be a new query
940
- // right behind it
941
- const searchQuery = success.request.clientParameters.user_query;
942
- const searchSort = success.request.clientParameters.sort;
943
- let sortChanged = false;
944
- if (!searchSort || searchSort.length === 0) {
945
- // if we went from no sort to sort, the sort has changed
946
- if (this.sortParam) {
947
- sortChanged = true;
948
- }
949
- }
950
- else {
951
- // check if the sort has changed
952
- for (const sortType of searchSort) {
953
- const [field, direction] = sortType.split(':');
954
- if (field !== ((_c = this.sortParam) === null || _c === void 0 ? void 0 : _c.field) ||
955
- direction !== ((_d = this.sortParam) === null || _d === void 0 ? void 0 : _d.direction)) {
956
- sortChanged = true;
957
- break;
958
- }
959
- }
960
- }
961
- const queryChangedSinceFetch = searchQuery !== this.filteredQuery || sortChanged;
962
- if (queryChangedSinceFetch)
963
- return;
964
- const { results } = success.response;
965
- if (results && results.length > 0) {
966
- this.preloadCollectionNames(results);
967
- this.updateDataSource(pageNumber, results);
968
- }
969
- // When we reach the end of the data, we can set the infinite scroller's
970
- // item count to the real total number of results (rather than the
971
- // temporary estimates based on pages rendered so far).
972
- if (results.length < this.pageSize) {
973
- this.endOfDataReached = true;
974
- if (this.infiniteScroller) {
975
- this.infiniteScroller.itemCount = this.totalResults;
976
- }
977
- }
978
- (_e = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _e === void 0 ? void 0 : _e.delete(pageNumber);
979
- this.searchResultsLoading = false;
980
- }
981
- preloadCollectionNames(results) {
982
- var _a;
983
- const collectionIds = results
984
- .map(result => { var _a; return (_a = result.collection) === null || _a === void 0 ? void 0 : _a.values; })
985
- .flat();
986
- const collectionIdsArray = Array.from(new Set(collectionIds));
987
- (_a = this.collectionNameCache) === null || _a === void 0 ? void 0 : _a.preloadIdentifiers(collectionIdsArray);
988
- }
989
- /**
990
- * This is useful for determining whether we need to reload the scroller.
991
- *
992
- * When the fetch completes, we need to reload the scroller if the cells for that
993
- * page are visible, but if the page is not currenlty visible, we don't need to reload
994
- */
995
- get currentVisiblePageNumbers() {
996
- var _a, _b;
997
- const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
998
- const visiblePages = new Set();
999
- visibleCells.forEach(cellIndex => {
1000
- const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1001
- visiblePages.add(visiblePage);
1002
- });
1003
- return Array.from(visiblePages);
1004
- }
1005
- /**
1006
- * Update the datasource from the fetch response
1007
- *
1008
- * @param pageNumber
1009
- * @param results
1010
- */
1011
- updateDataSource(pageNumber, results) {
1012
- var _a;
1013
- // copy our existing datasource so when we set it below, it gets set
1014
- // instead of modifying the existing dataSource since object changes
1015
- // don't trigger a re-render
1016
- const datasource = { ...this.dataSource };
1017
- const tiles = [];
1018
- results === null || results === void 0 ? void 0 : results.forEach(result => {
1019
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
1020
- if (!result.identifier)
1021
- return;
1022
- let loginRequired = false;
1023
- let contentWarning = false;
1024
- // Check if item and item in "modifying" collection, setting above flags
1025
- if (((_a = result.collection) === null || _a === void 0 ? void 0 : _a.values.length) &&
1026
- ((_b = result.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== 'collection') {
1027
- for (const collection of (_d = (_c = result.collection) === null || _c === void 0 ? void 0 : _c.values) !== null && _d !== void 0 ? _d : []) {
1028
- if (collection === 'loggedin') {
1029
- loginRequired = true;
1030
- if (contentWarning)
1031
- break;
1032
- }
1033
- if (collection === 'no-preview') {
1034
- contentWarning = true;
1035
- if (loginRequired)
1036
- break;
1037
- }
1038
- }
1039
- }
1040
- tiles.push({
1041
- averageRating: (_e = result.avg_rating) === null || _e === void 0 ? void 0 : _e.value,
1042
- collections: (_g = (_f = result.collection) === null || _f === void 0 ? void 0 : _f.values) !== null && _g !== void 0 ? _g : [],
1043
- collectionFilesCount: (_j = (_h = result.collection_files_count) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : 0,
1044
- collectionSize: (_l = (_k = result.collection_size) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 0,
1045
- commentCount: (_o = (_m = result.num_reviews) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 0,
1046
- creator: (_p = result.creator) === null || _p === void 0 ? void 0 : _p.value,
1047
- creators: (_r = (_q = result.creator) === null || _q === void 0 ? void 0 : _q.values) !== null && _r !== void 0 ? _r : [],
1048
- dateAdded: (_s = result.addeddate) === null || _s === void 0 ? void 0 : _s.value,
1049
- dateArchived: (_t = result.publicdate) === null || _t === void 0 ? void 0 : _t.value,
1050
- datePublished: (_u = result.date) === null || _u === void 0 ? void 0 : _u.value,
1051
- dateReviewed: (_v = result.reviewdate) === null || _v === void 0 ? void 0 : _v.value,
1052
- description: (_w = result.description) === null || _w === void 0 ? void 0 : _w.values.join('\n'),
1053
- favCount: (_y = (_x = result.num_favorites) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 0,
1054
- href: (_z = result.__href__) === null || _z === void 0 ? void 0 : _z.value,
1055
- identifier: result.identifier,
1056
- issue: (_0 = result.issue) === null || _0 === void 0 ? void 0 : _0.value,
1057
- itemCount: (_2 = (_1 = result.item_count) === null || _1 === void 0 ? void 0 : _1.value) !== null && _2 !== void 0 ? _2 : 0,
1058
- mediatype: (_4 = (_3 = result.mediatype) === null || _3 === void 0 ? void 0 : _3.value) !== null && _4 !== void 0 ? _4 : 'data',
1059
- snippets: (_6 = (_5 = result.highlight) === null || _5 === void 0 ? void 0 : _5.values) !== null && _6 !== void 0 ? _6 : [],
1060
- source: (_7 = result.source) === null || _7 === void 0 ? void 0 : _7.value,
1061
- subjects: (_9 = (_8 = result.subject) === null || _8 === void 0 ? void 0 : _8.values) !== null && _9 !== void 0 ? _9 : [],
1062
- title: this.etreeTitle((_10 = result.title) === null || _10 === void 0 ? void 0 : _10.value, (_11 = result.mediatype) === null || _11 === void 0 ? void 0 : _11.value, (_12 = result.collection) === null || _12 === void 0 ? void 0 : _12.values),
1063
- volume: (_13 = result.volume) === null || _13 === void 0 ? void 0 : _13.value,
1064
- viewCount: (_15 = (_14 = result.downloads) === null || _14 === void 0 ? void 0 : _14.value) !== null && _15 !== void 0 ? _15 : 0,
1065
- weeklyViewCount: (_16 = result.week) === null || _16 === void 0 ? void 0 : _16.value,
1066
- loginRequired,
1067
- contentWarning,
1068
- });
1069
- });
1070
- datasource[pageNumber] = tiles;
1071
- this.dataSource = datasource;
1072
- const visiblePages = this.currentVisiblePageNumbers;
1073
- const needsReload = visiblePages.includes(pageNumber);
1074
- if (needsReload) {
1075
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1076
- }
1077
- }
1078
- /** Fetches the aggregation buckets for the given prefix filter type. */
1079
- async fetchPrefixFilterBuckets(filterType) {
1080
- var _a, _b, _c, _d, _e, _f;
1081
- if (!this.fullQueryWithoutAlphaFilters)
1082
- return [];
1083
- const filterAggregationKey = prefixFilterAggregationKeys[filterType];
1084
- const params = {
1085
- query: this.fullQueryWithoutAlphaFilters,
1086
- rows: 0,
1087
- // Only fetch the firstTitle or firstCreator aggregation
1088
- aggregations: { simpleParams: [filterAggregationKey] },
1089
- // Fetch all 26 letter buckets
1090
- aggregationsSize: 26,
1091
- };
1092
- const searchResponse = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
1093
- return ((_f = (_e = (_d = (_c = (_b = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.aggregations) === null || _d === void 0 ? void 0 : _d[filterAggregationKey]) === null || _e === void 0 ? void 0 : _e.buckets) !== null && _f !== void 0 ? _f : []);
1094
- }
1095
- /** Fetches and caches the prefix filter counts for the given filter type. */
1096
- async updatePrefixFilterCounts(filterType) {
1097
- const buckets = await this.fetchPrefixFilterBuckets(filterType);
1098
- // Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
1099
- this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
1100
- this.prefixFilterCountMap[filterType] = buckets.reduce((acc, bucket) => {
1101
- acc[bucket.key.toUpperCase()] = bucket.doc_count;
1102
- return acc;
1103
- }, {});
1104
- }
1105
- /**
1106
- * Fetches and caches the prefix filter counts for the current sort type,
1107
- * provided it is one that permits prefix filtering. (If not, this does nothing).
1108
- */
1109
- async updatePrefixFiltersForCurrentSort() {
1110
- if (['title', 'creator'].includes(this.selectedSort)) {
1111
- const filterType = this.selectedSort;
1112
- if (!this.prefixFilterCountMap[filterType]) {
1113
- this.updatePrefixFilterCounts(filterType);
1114
- }
1115
- }
1116
- }
1117
- /**
1118
- * Clears the cached letter counts for both title and creator, and
1119
- * fetches a new set of counts for whichever of them is the currently
1120
- * selected sort option (which may be neither).
1121
- *
1122
- * Call this whenever the counts are invalidated (e.g., by a query change).
1123
- */
1124
- refreshLetterCounts() {
1125
- this.prefixFilterCountMap = {};
1126
- this.updatePrefixFiltersForCurrentSort();
1127
- }
1128
- /*
1129
- * Convert etree titles
1130
- * "[Creator] Live at [Place] on [Date]" => "[Date]: [Place]"
1131
- *
1132
- * Todo: Check collection(s) for etree, need to get as array.
1133
- * Current search-service only returns first collection as string.
1134
- */
1135
- etreeTitle(title, mediatype, collections) {
1136
- if (mediatype === 'etree' || (collections === null || collections === void 0 ? void 0 : collections.includes('etree'))) {
1137
- const regex = /^(.*) Live at (.*) on (\d\d\d\d-\d\d-\d\d)$/;
1138
- const newTitle = title === null || title === void 0 ? void 0 : title.replace(regex, '$3: $2');
1139
- if (newTitle) {
1140
- return `${newTitle}`;
1141
- }
1142
- }
1143
- return title !== null && title !== void 0 ? title : '';
1144
- }
1145
- /**
1146
- * Callback when a result is selected
1147
- */
1148
- resultSelected(event) {
1149
- var _a, _b;
1150
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1151
- category: this.searchContext,
1152
- action: analyticsActions.resultSelected,
1153
- label: event.detail.mediatype,
1154
- });
1155
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1156
- category: this.searchContext,
1157
- action: analyticsActions.resultSelected,
1158
- label: `page-${this.currentPage}`,
1159
- });
1160
- }
1161
- cellForIndex(index) {
1162
- const model = this.tileModelAtCellIndex(index);
1163
- if (!model)
1164
- return undefined;
421
+ `;
422
+ }
423
+ histogramDateRangeUpdated(e) {
424
+ var _a;
425
+ const { minDate, maxDate } = e.detail;
426
+ [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
427
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
428
+ category: this.searchContext,
429
+ action: analyticsActions.histogramChanged,
430
+ label: this.dateRangeQueryClause,
431
+ });
432
+ }
433
+ get dateRangeQueryClause() {
434
+ if (!this.minSelectedDate || !this.maxSelectedDate) {
435
+ return undefined;
436
+ }
437
+ return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
438
+ }
439
+ firstUpdated() {
440
+ this.setupStateRestorationObserver();
441
+ this.restoreState();
442
+ }
443
+ updated(changed) {
444
+ var _a;
445
+ if (changed.has('displayMode') ||
446
+ changed.has('baseNavigationUrl') ||
447
+ changed.has('baseImageUrl') ||
448
+ changed.has('loggedIn')) {
449
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
450
+ }
451
+ if (changed.has('baseQuery')) {
452
+ this.emitBaseQueryChanged();
453
+ }
454
+ if (changed.has('searchType')) {
455
+ this.emitSearchTypeChanged();
456
+ }
457
+ if (changed.has('currentPage') || changed.has('displayMode')) {
458
+ this.persistState();
459
+ }
460
+ if (changed.has('baseQuery') ||
461
+ changed.has('titleQuery') ||
462
+ changed.has('creatorQuery') ||
463
+ changed.has('minSelectedDate') ||
464
+ changed.has('maxSelectedDate') ||
465
+ changed.has('sortParam') ||
466
+ changed.has('selectedFacets') ||
467
+ changed.has('searchService')) {
468
+ this.handleQueryChange();
469
+ }
470
+ if (changed.has('baseQuery') ||
471
+ changed.has('minSelectedDate') ||
472
+ changed.has('maxSelectedDate') ||
473
+ changed.has('selectedFacets')) {
474
+ this.refreshLetterCounts();
475
+ }
476
+ if (changed.has('selectedSort') || changed.has('sortDirection')) {
477
+ const prevSortDirection = changed.get('sortDirection');
478
+ this.sendSortByAnalytics(prevSortDirection);
479
+ this.selectedSortChanged();
480
+ }
481
+ if (changed.has('selectedTitleFilter')) {
482
+ this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
483
+ this.selectedTitleLetterChanged();
484
+ }
485
+ if (changed.has('selectedCreatorFilter')) {
486
+ this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
487
+ this.selectedCreatorLetterChanged();
488
+ }
489
+ if (changed.has('pagesToRender')) {
490
+ if (!this.endOfDataReached && this.infiniteScroller) {
491
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
492
+ }
493
+ }
494
+ if (changed.has('resizeObserver')) {
495
+ const oldObserver = changed.get('resizeObserver');
496
+ if (oldObserver)
497
+ this.disconnectResizeObserver(oldObserver);
498
+ this.setupResizeObserver();
499
+ }
500
+ }
501
+ disconnectedCallback() {
502
+ if (this.resizeObserver) {
503
+ this.disconnectResizeObserver(this.resizeObserver);
504
+ }
505
+ if (this.boundNavigationHandler) {
506
+ window.removeEventListener('popstate', this.boundNavigationHandler);
507
+ }
508
+ }
509
+ handleResize(entry) {
510
+ const previousView = this.mobileView;
511
+ if (entry.target === this.contentContainer) {
512
+ this.mobileView = entry.contentRect.width < this.mobileBreakpoint;
513
+ // If changing from desktop to mobile disable transition
514
+ if (this.mobileView && !previousView) {
515
+ this.isResizeToMobile = true;
516
+ }
517
+ }
518
+ }
519
+ emitBaseQueryChanged() {
520
+ this.dispatchEvent(new CustomEvent('baseQueryChanged', {
521
+ detail: {
522
+ baseQuery: this.baseQuery,
523
+ },
524
+ }));
525
+ }
526
+ emitSearchTypeChanged() {
527
+ this.dispatchEvent(new CustomEvent('searchTypeChanged', {
528
+ detail: this.searchType,
529
+ }));
530
+ }
531
+ disconnectResizeObserver(resizeObserver) {
532
+ resizeObserver.removeObserver({
533
+ target: this.contentContainer,
534
+ handler: this,
535
+ });
536
+ }
537
+ setupResizeObserver() {
538
+ if (!this.resizeObserver)
539
+ return;
540
+ this.resizeObserver.addObserver({
541
+ target: this.contentContainer,
542
+ handler: this,
543
+ });
544
+ }
545
+ /**
546
+ * When the visible cells change from the infinite scroller, we want to emit
547
+ * which page is currently visible so the consumer can update its UI or the URL
548
+ *
549
+ * @param e
550
+ * @returns
551
+ */
552
+ visibleCellsChanged(e) {
553
+ if (this.isScrollingToCell)
554
+ return;
555
+ const { visibleCellIndices } = e.detail;
556
+ if (visibleCellIndices.length === 0)
557
+ return;
558
+ const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
559
+ const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
560
+ if (this.currentPage !== lastVisibleCellPage) {
561
+ this.currentPage = lastVisibleCellPage;
562
+ }
563
+ const event = new CustomEvent('visiblePageChanged', {
564
+ detail: {
565
+ pageNumber: lastVisibleCellPage,
566
+ },
567
+ });
568
+ this.dispatchEvent(event);
569
+ }
570
+ async handleQueryChange() {
571
+ var _a;
572
+ // only reset if the query has actually changed
573
+ if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
574
+ return;
575
+ this.previousQueryKey = this.pageFetchQueryKey;
576
+ this.dataSource = {};
577
+ this.totalResults = undefined;
578
+ this.aggregations = undefined;
579
+ this.fullYearsHistogramAggregation = undefined;
580
+ this.pageFetchesInProgress = {};
581
+ this.endOfDataReached = false;
582
+ this.pagesToRender = this.initialPageNumber;
583
+ // Reset the infinite scroller's item count, so that it
584
+ // shows tile placeholders until the new query's results load in
585
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
586
+ if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
587
+ this.scrollToPage(this.initialPageNumber);
588
+ }
589
+ this.initialQueryChangeHappened = true;
590
+ // if the query changed as part of a window.history pop event, we don't want to
591
+ // persist the state because it overwrites the forward history
592
+ if (!this.historyPopOccurred) {
593
+ this.persistState();
594
+ this.historyPopOccurred = false;
595
+ }
596
+ await Promise.all([this.doInitialPageFetch(), this.fetchFacets()]);
597
+ }
598
+ setupStateRestorationObserver() {
599
+ if (this.boundNavigationHandler)
600
+ return;
601
+ this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
602
+ // when the user navigates back, we want to update the UI to match the URL
603
+ window.addEventListener('popstate', this.boundNavigationHandler);
604
+ }
605
+ historyNavigationHandler() {
606
+ this.historyPopOccurred = true;
607
+ this.restoreState();
608
+ }
609
+ restoreState() {
610
+ var _a, _b, _c, _d, _e, _f;
611
+ const restorationState = this.restorationStateHandler.getRestorationState();
612
+ this.displayMode = restorationState.displayMode;
613
+ if (restorationState.searchType != null)
614
+ this.searchType = restorationState.searchType;
615
+ this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
616
+ this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
617
+ this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
618
+ this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
619
+ this.selectedFacets = restorationState.selectedFacets;
620
+ this.baseQuery = restorationState.baseQuery;
621
+ this.titleQuery = restorationState.titleQuery;
622
+ this.creatorQuery = restorationState.creatorQuery;
623
+ this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
624
+ this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
625
+ this.minSelectedDate = restorationState.minSelectedDate;
626
+ this.maxSelectedDate = restorationState.maxSelectedDate;
627
+ if (this.currentPage > 1) {
628
+ this.goToPage(this.currentPage);
629
+ }
630
+ }
631
+ persistState() {
632
+ var _a, _b, _c, _d, _e;
633
+ const restorationState = {
634
+ displayMode: this.displayMode,
635
+ searchType: this.searchType,
636
+ sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
637
+ selectedSort: this.selectedSort,
638
+ sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
639
+ selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : defaultSelectedFacets,
640
+ baseQuery: this.baseQuery,
641
+ currentPage: this.currentPage,
642
+ titleQuery: this.titleQuery,
643
+ creatorQuery: this.creatorQuery,
644
+ minSelectedDate: this.minSelectedDate,
645
+ maxSelectedDate: this.maxSelectedDate,
646
+ selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
647
+ selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
648
+ };
649
+ this.restorationStateHandler.persistState(restorationState);
650
+ }
651
+ async doInitialPageFetch() {
652
+ this.searchResultsLoading = true;
653
+ await this.fetchPage(this.initialPageNumber);
654
+ this.searchResultsLoading = false;
655
+ }
656
+ get filterMap() {
657
+ const builder = new FilterMapBuilder();
658
+ // Add the date range, if applicable
659
+ if (this.minSelectedDate) {
660
+ builder.addFilter('year', this.minSelectedDate, FilterConstraint.GREATER_OR_EQUAL);
661
+ }
662
+ if (this.maxSelectedDate) {
663
+ builder.addFilter('year', this.maxSelectedDate, FilterConstraint.LESS_OR_EQUAL);
664
+ }
665
+ // Add any selected facets
666
+ if (this.selectedFacets) {
667
+ for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
668
+ const { name, values } = this.prepareFacetForFetch(facetName, facetValues);
669
+ for (const [value, bucket] of Object.entries(values)) {
670
+ let constraint;
671
+ if (bucket.state === 'selected') {
672
+ constraint = FilterConstraint.INCLUDE;
673
+ }
674
+ else if (bucket.state === 'hidden') {
675
+ constraint = FilterConstraint.EXCLUDE;
676
+ }
677
+ if (constraint) {
678
+ builder.addFilter(name, value, constraint);
679
+ }
680
+ }
681
+ }
682
+ }
683
+ const filterMap = builder.build();
684
+ return filterMap;
685
+ }
686
+ /** The base query joined with any title/creator letter filters */
687
+ get filteredQuery() {
688
+ if (!this.baseQuery)
689
+ return undefined;
690
+ let filteredQuery = this.baseQuery;
691
+ const { sortFilterQueries } = this;
692
+ if (sortFilterQueries) {
693
+ filteredQuery += ` AND ${sortFilterQueries}`;
694
+ }
695
+ return filteredQuery;
696
+ }
697
+ /** The full query, including year facets and date range clauses */
698
+ get fullQuery() {
699
+ if (!this.baseQuery)
700
+ return undefined;
701
+ let fullQuery = this.baseQuery;
702
+ const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
703
+ if (facetQuery) {
704
+ fullQuery += ` AND ${facetQuery}`;
705
+ }
706
+ if (dateRangeQueryClause) {
707
+ fullQuery += ` AND ${dateRangeQueryClause}`;
708
+ }
709
+ if (sortFilterQueries) {
710
+ fullQuery += ` AND ${sortFilterQueries}`;
711
+ }
712
+ return fullQuery;
713
+ }
714
+ /** The full query without any title/creator letter filters */
715
+ get fullQueryWithoutAlphaFilters() {
716
+ if (!this.baseQuery)
717
+ return undefined;
718
+ let fullQuery = this.baseQuery;
719
+ const { facetQuery, dateRangeQueryClause } = this;
720
+ if (facetQuery) {
721
+ fullQuery += ` AND ${facetQuery}`;
722
+ }
723
+ if (dateRangeQueryClause) {
724
+ fullQuery += ` AND ${dateRangeQueryClause}`;
725
+ }
726
+ return fullQuery;
727
+ }
728
+ /**
729
+ * Generates a query string for the given facets
730
+ *
731
+ * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
732
+ */
733
+ get facetQuery() {
734
+ if (!this.selectedFacets)
735
+ return undefined;
736
+ const facetClauses = [];
737
+ for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
738
+ facetClauses.push(this.buildFacetClause(facetName, facetValues));
739
+ }
740
+ return this.joinFacetClauses(facetClauses);
741
+ }
742
+ /**
743
+ * Builds an OR-joined facet clause for the given facet name and values.
744
+ *
745
+ * E.g., for name `subject` and values
746
+ * `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
747
+ * this will produce the clause
748
+ * `subject:("foo" OR -"bar")`.
749
+ *
750
+ * @param facetName The facet type (e.g., 'collection')
751
+ * @param facetValues The facet buckets, mapped by their keys
752
+ */
753
+ buildFacetClause(facetName, facetValues) {
754
+ const { name: facetQueryName, values } = this.prepareFacetForFetch(facetName, facetValues);
755
+ const facetEntries = Object.entries(values);
756
+ if (facetEntries.length === 0)
757
+ return '';
758
+ const facetValuesArray = [];
759
+ for (const [key, facetData] of facetEntries) {
760
+ const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
761
+ facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
762
+ }
763
+ const valueQuery = facetValuesArray.join(` OR `);
764
+ return `${facetQueryName}:(${valueQuery})`;
765
+ }
766
+ /**
767
+ * Handles some special pre-request normalization steps for certain facet types
768
+ * that require them.
769
+ *
770
+ * @param facetName The name of the facet type (e.g., 'language')
771
+ * @param facetValues An array of values for that facet type
772
+ */
773
+ prepareFacetForFetch(facetName, facetValues) {
774
+ // eslint-disable-next-line prefer-const
775
+ let [normalizedName, normalizedValues] = [facetName, facetValues];
776
+ // The full "search engine" name of the lending field is "lending___status"
777
+ if (facetName === 'lending') {
778
+ normalizedName = 'lending___status';
779
+ }
780
+ return {
781
+ name: normalizedName,
782
+ values: normalizedValues,
783
+ };
784
+ }
785
+ /**
786
+ * Takes an array of facet clauses, and combines them into a
787
+ * full AND-joined facet query string. Empty clauses are ignored.
788
+ */
789
+ joinFacetClauses(facetClauses) {
790
+ const nonEmptyFacetClauses = facetClauses.filter(clause => clause.length > 0);
791
+ return nonEmptyFacetClauses.length > 0
792
+ ? `(${nonEmptyFacetClauses.join(' AND ')})`
793
+ : undefined;
794
+ }
795
+ facetsChanged(e) {
796
+ this.selectedFacets = e.detail;
797
+ }
798
+ facetClickHandler(name, facetSelected, negative) {
799
+ var _a, _b;
800
+ if (negative) {
801
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
802
+ category: this.searchContext,
803
+ action: facetSelected
804
+ ? analyticsActions.facetNegativeSelected
805
+ : analyticsActions.facetNegativeDeselected,
806
+ label: name,
807
+ });
808
+ }
809
+ else {
810
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
811
+ category: this.searchContext,
812
+ action: facetSelected
813
+ ? analyticsActions.facetSelected
814
+ : analyticsActions.facetDeselected,
815
+ label: name,
816
+ });
817
+ }
818
+ }
819
+ async fetchFacets() {
820
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
821
+ if (!this.filteredQuery)
822
+ return;
823
+ const params = {
824
+ query: this.filteredQuery,
825
+ rows: 0,
826
+ filters: this.filterMap,
827
+ // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
828
+ aggregationsSize: 10,
829
+ // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
830
+ // The default aggregations for the search_results page type should be what we need here.
831
+ };
832
+ this.facetsLoading = true;
833
+ this.previousSearchType = this.searchType;
834
+ const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
835
+ this.facetsLoading = false;
836
+ this.aggregations = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response.aggregations;
837
+ this.fullYearsHistogramAggregation =
838
+ (_f = (_e = (_d = (_c = results === null || results === void 0 ? void 0 : results.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e.year_histogram) !== null && _f !== void 0 ? _f : (_j = (_h = (_g = results === null || results === void 0 ? void 0 : results.success) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.aggregations) === null || _j === void 0 ? void 0 : _j['year-histogram']; // Temp fix until PPS FTS key is fixed to use underscore
839
+ }
840
+ scrollToPage(pageNumber) {
841
+ return new Promise(resolve => {
842
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
843
+ // without this setTimeout, Safari just pauses until the `fetchPage` is complete
844
+ // then scrolls to the cell
845
+ setTimeout(() => {
846
+ var _a;
847
+ this.isScrollingToCell = true;
848
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
849
+ // This timeout is to give the scroll animation time to finish
850
+ // then updating the infinite scroller once we're done scrolling
851
+ // There's no scroll animation completion callback so we're
852
+ // giving it 0.5s to finish.
853
+ setTimeout(() => {
854
+ var _a;
855
+ this.isScrollingToCell = false;
856
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
857
+ resolve();
858
+ }, 500);
859
+ }, 0);
860
+ });
861
+ }
862
+ /**
863
+ * The query key is a string that uniquely identifies the current search.
864
+ * It consists of:
865
+ * - The current base query
866
+ * - The current search type
867
+ * - Any currently-applied facets
868
+ * - Any currently-applied date range
869
+ * - Any currently-applied prefix filters
870
+ * - The current sort options
871
+ *
872
+ * This lets us keep track of queries so we don't persist data that's
873
+ * no longer relevant.
874
+ */
875
+ get pageFetchQueryKey() {
876
+ var _a, _b;
877
+ return `${this.fullQuery}-${this.searchType}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
878
+ }
879
+ async fetchPage(pageNumber) {
880
+ var _a, _b, _c, _d, _e;
881
+ if (!this.filteredQuery)
882
+ return;
883
+ // if we already have data, don't fetch again
884
+ if (this.dataSource[pageNumber])
885
+ return;
886
+ if (this.endOfDataReached)
887
+ return;
888
+ // if a fetch is already in progress for this query and page, don't fetch again
889
+ const { pageFetchQueryKey } = this;
890
+ const pageFetches = (_a = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _a !== void 0 ? _a : new Set();
891
+ if (pageFetches.has(pageNumber))
892
+ return;
893
+ pageFetches.add(pageNumber);
894
+ this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
895
+ const sortParams = this.sortParam ? [this.sortParam] : [];
896
+ const params = {
897
+ query: this.filteredQuery,
898
+ page: pageNumber,
899
+ rows: this.pageSize,
900
+ sort: sortParams,
901
+ filters: this.filterMap,
902
+ aggregations: { omit: true },
903
+ };
904
+ const searchResponse = await ((_b = this.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.searchType));
905
+ const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
906
+ if (!success)
907
+ return;
908
+ this.totalResults = success.response.totalResults;
909
+ // this is checking to see if the query has changed since the data was fetched
910
+ // if so, we just want to discard the data since there should be a new query
911
+ // right behind it
912
+ const searchQuery = success.request.clientParameters.user_query;
913
+ const searchSort = success.request.clientParameters.sort;
914
+ let sortChanged = false;
915
+ if (!searchSort || searchSort.length === 0) {
916
+ // if we went from no sort to sort, the sort has changed
917
+ if (this.sortParam) {
918
+ sortChanged = true;
919
+ }
920
+ }
921
+ else {
922
+ // check if the sort has changed
923
+ for (const sortType of searchSort) {
924
+ const [field, direction] = sortType.split(':');
925
+ if (field !== ((_c = this.sortParam) === null || _c === void 0 ? void 0 : _c.field) ||
926
+ direction !== ((_d = this.sortParam) === null || _d === void 0 ? void 0 : _d.direction)) {
927
+ sortChanged = true;
928
+ break;
929
+ }
930
+ }
931
+ }
932
+ const queryChangedSinceFetch = searchQuery !== this.filteredQuery || sortChanged;
933
+ if (queryChangedSinceFetch)
934
+ return;
935
+ const { results } = success.response;
936
+ if (results && results.length > 0) {
937
+ this.preloadCollectionNames(results);
938
+ this.updateDataSource(pageNumber, results);
939
+ }
940
+ // When we reach the end of the data, we can set the infinite scroller's
941
+ // item count to the real total number of results (rather than the
942
+ // temporary estimates based on pages rendered so far).
943
+ if (results.length < this.pageSize) {
944
+ this.endOfDataReached = true;
945
+ if (this.infiniteScroller) {
946
+ this.infiniteScroller.itemCount = this.totalResults;
947
+ }
948
+ }
949
+ (_e = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _e === void 0 ? void 0 : _e.delete(pageNumber);
950
+ this.searchResultsLoading = false;
951
+ }
952
+ preloadCollectionNames(results) {
953
+ var _a;
954
+ const collectionIds = results
955
+ .map(result => { var _a; return (_a = result.collection) === null || _a === void 0 ? void 0 : _a.values; })
956
+ .flat();
957
+ const collectionIdsArray = Array.from(new Set(collectionIds));
958
+ (_a = this.collectionNameCache) === null || _a === void 0 ? void 0 : _a.preloadIdentifiers(collectionIdsArray);
959
+ }
960
+ /**
961
+ * This is useful for determining whether we need to reload the scroller.
962
+ *
963
+ * When the fetch completes, we need to reload the scroller if the cells for that
964
+ * page are visible, but if the page is not currenlty visible, we don't need to reload
965
+ */
966
+ get currentVisiblePageNumbers() {
967
+ var _a, _b;
968
+ const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
969
+ const visiblePages = new Set();
970
+ visibleCells.forEach(cellIndex => {
971
+ const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
972
+ visiblePages.add(visiblePage);
973
+ });
974
+ return Array.from(visiblePages);
975
+ }
976
+ /**
977
+ * Update the datasource from the fetch response
978
+ *
979
+ * @param pageNumber
980
+ * @param results
981
+ */
982
+ updateDataSource(pageNumber, results) {
983
+ var _a;
984
+ // copy our existing datasource so when we set it below, it gets set
985
+ // instead of modifying the existing dataSource since object changes
986
+ // don't trigger a re-render
987
+ const datasource = { ...this.dataSource };
988
+ const tiles = [];
989
+ results === null || results === void 0 ? void 0 : results.forEach(result => {
990
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
991
+ if (!result.identifier)
992
+ return;
993
+ let loginRequired = false;
994
+ let contentWarning = false;
995
+ // Check if item and item in "modifying" collection, setting above flags
996
+ if (((_a = result.collection) === null || _a === void 0 ? void 0 : _a.values.length) &&
997
+ ((_b = result.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== 'collection') {
998
+ for (const collection of (_d = (_c = result.collection) === null || _c === void 0 ? void 0 : _c.values) !== null && _d !== void 0 ? _d : []) {
999
+ if (collection === 'loggedin') {
1000
+ loginRequired = true;
1001
+ if (contentWarning)
1002
+ break;
1003
+ }
1004
+ if (collection === 'no-preview') {
1005
+ contentWarning = true;
1006
+ if (loginRequired)
1007
+ break;
1008
+ }
1009
+ }
1010
+ }
1011
+ tiles.push({
1012
+ averageRating: (_e = result.avg_rating) === null || _e === void 0 ? void 0 : _e.value,
1013
+ collections: (_g = (_f = result.collection) === null || _f === void 0 ? void 0 : _f.values) !== null && _g !== void 0 ? _g : [],
1014
+ collectionFilesCount: (_j = (_h = result.collection_files_count) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : 0,
1015
+ collectionSize: (_l = (_k = result.collection_size) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 0,
1016
+ commentCount: (_o = (_m = result.num_reviews) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 0,
1017
+ creator: (_p = result.creator) === null || _p === void 0 ? void 0 : _p.value,
1018
+ creators: (_r = (_q = result.creator) === null || _q === void 0 ? void 0 : _q.values) !== null && _r !== void 0 ? _r : [],
1019
+ dateAdded: (_s = result.addeddate) === null || _s === void 0 ? void 0 : _s.value,
1020
+ dateArchived: (_t = result.publicdate) === null || _t === void 0 ? void 0 : _t.value,
1021
+ datePublished: (_u = result.date) === null || _u === void 0 ? void 0 : _u.value,
1022
+ dateReviewed: (_v = result.reviewdate) === null || _v === void 0 ? void 0 : _v.value,
1023
+ description: (_w = result.description) === null || _w === void 0 ? void 0 : _w.values.join('\n'),
1024
+ favCount: (_y = (_x = result.num_favorites) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 0,
1025
+ href: (_z = result.__href__) === null || _z === void 0 ? void 0 : _z.value,
1026
+ identifier: result.identifier,
1027
+ issue: (_0 = result.issue) === null || _0 === void 0 ? void 0 : _0.value,
1028
+ itemCount: (_2 = (_1 = result.item_count) === null || _1 === void 0 ? void 0 : _1.value) !== null && _2 !== void 0 ? _2 : 0,
1029
+ mediatype: (_4 = (_3 = result.mediatype) === null || _3 === void 0 ? void 0 : _3.value) !== null && _4 !== void 0 ? _4 : 'data',
1030
+ snippets: (_6 = (_5 = result.highlight) === null || _5 === void 0 ? void 0 : _5.values) !== null && _6 !== void 0 ? _6 : [],
1031
+ source: (_7 = result.source) === null || _7 === void 0 ? void 0 : _7.value,
1032
+ subjects: (_9 = (_8 = result.subject) === null || _8 === void 0 ? void 0 : _8.values) !== null && _9 !== void 0 ? _9 : [],
1033
+ title: this.etreeTitle((_10 = result.title) === null || _10 === void 0 ? void 0 : _10.value, (_11 = result.mediatype) === null || _11 === void 0 ? void 0 : _11.value, (_12 = result.collection) === null || _12 === void 0 ? void 0 : _12.values),
1034
+ volume: (_13 = result.volume) === null || _13 === void 0 ? void 0 : _13.value,
1035
+ viewCount: (_15 = (_14 = result.downloads) === null || _14 === void 0 ? void 0 : _14.value) !== null && _15 !== void 0 ? _15 : 0,
1036
+ weeklyViewCount: (_16 = result.week) === null || _16 === void 0 ? void 0 : _16.value,
1037
+ loginRequired,
1038
+ contentWarning,
1039
+ });
1040
+ });
1041
+ datasource[pageNumber] = tiles;
1042
+ this.dataSource = datasource;
1043
+ const visiblePages = this.currentVisiblePageNumbers;
1044
+ const needsReload = visiblePages.includes(pageNumber);
1045
+ if (needsReload) {
1046
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1047
+ }
1048
+ }
1049
+ /** Fetches the aggregation buckets for the given prefix filter type. */
1050
+ async fetchPrefixFilterBuckets(filterType) {
1051
+ var _a, _b, _c, _d, _e, _f;
1052
+ if (!this.fullQueryWithoutAlphaFilters)
1053
+ return [];
1054
+ const filterAggregationKey = prefixFilterAggregationKeys[filterType];
1055
+ const params = {
1056
+ query: this.fullQueryWithoutAlphaFilters,
1057
+ rows: 0,
1058
+ // Only fetch the firstTitle or firstCreator aggregation
1059
+ aggregations: { simpleParams: [filterAggregationKey] },
1060
+ // Fetch all 26 letter buckets
1061
+ aggregationsSize: 26,
1062
+ };
1063
+ const searchResponse = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
1064
+ return ((_f = (_e = (_d = (_c = (_b = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.aggregations) === null || _d === void 0 ? void 0 : _d[filterAggregationKey]) === null || _e === void 0 ? void 0 : _e.buckets) !== null && _f !== void 0 ? _f : []);
1065
+ }
1066
+ /** Fetches and caches the prefix filter counts for the given filter type. */
1067
+ async updatePrefixFilterCounts(filterType) {
1068
+ const buckets = await this.fetchPrefixFilterBuckets(filterType);
1069
+ // Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
1070
+ this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
1071
+ this.prefixFilterCountMap[filterType] = buckets.reduce((acc, bucket) => {
1072
+ acc[bucket.key.toUpperCase()] = bucket.doc_count;
1073
+ return acc;
1074
+ }, {});
1075
+ }
1076
+ /**
1077
+ * Fetches and caches the prefix filter counts for the current sort type,
1078
+ * provided it is one that permits prefix filtering. (If not, this does nothing).
1079
+ */
1080
+ async updatePrefixFiltersForCurrentSort() {
1081
+ if (['title', 'creator'].includes(this.selectedSort)) {
1082
+ const filterType = this.selectedSort;
1083
+ if (!this.prefixFilterCountMap[filterType]) {
1084
+ this.updatePrefixFilterCounts(filterType);
1085
+ }
1086
+ }
1087
+ }
1088
+ /**
1089
+ * Clears the cached letter counts for both title and creator, and
1090
+ * fetches a new set of counts for whichever of them is the currently
1091
+ * selected sort option (which may be neither).
1092
+ *
1093
+ * Call this whenever the counts are invalidated (e.g., by a query change).
1094
+ */
1095
+ refreshLetterCounts() {
1096
+ this.prefixFilterCountMap = {};
1097
+ this.updatePrefixFiltersForCurrentSort();
1098
+ }
1099
+ /*
1100
+ * Convert etree titles
1101
+ * "[Creator] Live at [Place] on [Date]" => "[Date]: [Place]"
1102
+ *
1103
+ * Todo: Check collection(s) for etree, need to get as array.
1104
+ * Current search-service only returns first collection as string.
1105
+ */
1106
+ etreeTitle(title, mediatype, collections) {
1107
+ if (mediatype === 'etree' || (collections === null || collections === void 0 ? void 0 : collections.includes('etree'))) {
1108
+ const regex = /^(.*) Live at (.*) on (\d\d\d\d-\d\d-\d\d)$/;
1109
+ const newTitle = title === null || title === void 0 ? void 0 : title.replace(regex, '$3: $2');
1110
+ if (newTitle) {
1111
+ return `${newTitle}`;
1112
+ }
1113
+ }
1114
+ return title !== null && title !== void 0 ? title : '';
1115
+ }
1116
+ /**
1117
+ * Callback when a result is selected
1118
+ */
1119
+ resultSelected(event) {
1120
+ var _a, _b;
1121
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1122
+ category: this.searchContext,
1123
+ action: analyticsActions.resultSelected,
1124
+ label: event.detail.mediatype,
1125
+ });
1126
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1127
+ category: this.searchContext,
1128
+ action: analyticsActions.resultSelected,
1129
+ label: `page-${this.currentPage}`,
1130
+ });
1131
+ }
1132
+ cellForIndex(index) {
1133
+ const model = this.tileModelAtCellIndex(index);
1134
+ if (!model)
1135
+ return undefined;
1165
1136
  return html `
1166
1137
  <tile-dispatcher
1167
1138
  .baseNavigationUrl=${this.baseNavigationUrl}
@@ -1177,19 +1148,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1177
1148
  @resultSelected=${(e) => this.resultSelected(e)}
1178
1149
  >
1179
1150
  </tile-dispatcher>
1180
- `;
1181
- }
1182
- /**
1183
- * When the user scrolls near to the bottom of the page, fetch the next page
1184
- * increase the number of pages to render and start fetching data for the new page
1185
- */
1186
- scrollThresholdReached() {
1187
- if (!this.endOfDataReached) {
1188
- this.pagesToRender += 1;
1189
- this.fetchPage(this.pagesToRender);
1190
- }
1191
- }
1192
- };
1151
+ `;
1152
+ }
1153
+ /**
1154
+ * When the user scrolls near to the bottom of the page, fetch the next page
1155
+ * increase the number of pages to render and start fetching data for the new page
1156
+ */
1157
+ scrollThresholdReached() {
1158
+ if (!this.endOfDataReached) {
1159
+ this.pagesToRender += 1;
1160
+ this.fetchPage(this.pagesToRender);
1161
+ }
1162
+ }
1163
+ };
1193
1164
  CollectionBrowser.styles = css `
1194
1165
  :host {
1195
1166
  display: block;
@@ -1413,144 +1384,144 @@ CollectionBrowser.styles = css `
1413
1384
  infinite-scroller.hidden {
1414
1385
  display: none;
1415
1386
  }
1416
- `;
1417
- __decorate([
1418
- property({ type: String })
1419
- ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1420
- __decorate([
1421
- property({ type: String })
1422
- ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1423
- __decorate([
1424
- property({ type: Object })
1425
- ], CollectionBrowser.prototype, "searchService", void 0);
1426
- __decorate([
1427
- property({ type: String })
1428
- ], CollectionBrowser.prototype, "searchType", void 0);
1429
- __decorate([
1430
- property({ type: String })
1431
- ], CollectionBrowser.prototype, "baseQuery", void 0);
1432
- __decorate([
1433
- property({ type: String })
1434
- ], CollectionBrowser.prototype, "displayMode", void 0);
1435
- __decorate([
1436
- property({ type: Object })
1437
- ], CollectionBrowser.prototype, "sortParam", void 0);
1438
- __decorate([
1439
- property({ type: String })
1440
- ], CollectionBrowser.prototype, "selectedSort", void 0);
1441
- __decorate([
1442
- property({ type: String })
1443
- ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1444
- __decorate([
1445
- property({ type: String })
1446
- ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1447
- __decorate([
1448
- property({ type: String })
1449
- ], CollectionBrowser.prototype, "sortDirection", void 0);
1450
- __decorate([
1451
- property({ type: Number })
1452
- ], CollectionBrowser.prototype, "pageSize", void 0);
1453
- __decorate([
1454
- property({ type: Object })
1455
- ], CollectionBrowser.prototype, "resizeObserver", void 0);
1456
- __decorate([
1457
- property({ type: String })
1458
- ], CollectionBrowser.prototype, "titleQuery", void 0);
1459
- __decorate([
1460
- property({ type: String })
1461
- ], CollectionBrowser.prototype, "creatorQuery", void 0);
1462
- __decorate([
1463
- property({ type: Number })
1464
- ], CollectionBrowser.prototype, "currentPage", void 0);
1465
- __decorate([
1466
- property({ type: String })
1467
- ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1468
- __decorate([
1469
- property({ type: String })
1470
- ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1471
- __decorate([
1472
- property({ type: Object })
1473
- ], CollectionBrowser.prototype, "selectedFacets", void 0);
1474
- __decorate([
1475
- property({ type: Boolean })
1476
- ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1477
- __decorate([
1478
- property({ type: String, reflect: true })
1479
- ], CollectionBrowser.prototype, "searchContext", void 0);
1480
- __decorate([
1481
- property({ type: Object })
1482
- ], CollectionBrowser.prototype, "collectionNameCache", void 0);
1483
- __decorate([
1484
- property({ type: String })
1485
- ], CollectionBrowser.prototype, "pageContext", void 0);
1486
- __decorate([
1487
- property({ type: Object })
1488
- ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1489
- __decorate([
1490
- property({ type: Number })
1491
- ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
1492
- __decorate([
1493
- property({ type: Boolean })
1494
- ], CollectionBrowser.prototype, "loggedIn", void 0);
1495
- __decorate([
1496
- property({ type: Object })
1497
- ], CollectionBrowser.prototype, "modalManager", void 0);
1498
- __decorate([
1499
- property({ type: Object })
1500
- ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
1501
- __decorate([
1502
- property({ type: Object })
1503
- ], CollectionBrowser.prototype, "recaptchaManager", void 0);
1504
- __decorate([
1505
- property({ type: Boolean })
1506
- ], CollectionBrowser.prototype, "isManageView", void 0);
1507
- __decorate([
1508
- state()
1509
- ], CollectionBrowser.prototype, "pagesToRender", void 0);
1510
- __decorate([
1511
- state()
1512
- ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
1513
- __decorate([
1514
- state()
1515
- ], CollectionBrowser.prototype, "facetsLoading", void 0);
1516
- __decorate([
1517
- state()
1518
- ], CollectionBrowser.prototype, "fullYearAggregationLoading", void 0);
1519
- __decorate([
1520
- state()
1521
- ], CollectionBrowser.prototype, "aggregations", void 0);
1522
- __decorate([
1523
- state()
1524
- ], CollectionBrowser.prototype, "fullYearsHistogramAggregation", void 0);
1525
- __decorate([
1526
- state()
1527
- ], CollectionBrowser.prototype, "previousSearchType", void 0);
1528
- __decorate([
1529
- state()
1530
- ], CollectionBrowser.prototype, "totalResults", void 0);
1531
- __decorate([
1532
- state()
1533
- ], CollectionBrowser.prototype, "mobileView", void 0);
1534
- __decorate([
1535
- state()
1536
- ], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
1537
- __decorate([
1538
- state()
1539
- ], CollectionBrowser.prototype, "placeholderType", void 0);
1540
- __decorate([
1541
- state()
1542
- ], CollectionBrowser.prototype, "prefixFilterCountMap", void 0);
1543
- __decorate([
1544
- query('#content-container')
1545
- ], CollectionBrowser.prototype, "contentContainer", void 0);
1546
- __decorate([
1547
- property({ type: Object, attribute: false })
1548
- ], CollectionBrowser.prototype, "analyticsHandler", void 0);
1549
- __decorate([
1550
- query('infinite-scroller')
1551
- ], CollectionBrowser.prototype, "infiniteScroller", void 0);
1552
- CollectionBrowser = __decorate([
1553
- customElement('collection-browser')
1554
- ], CollectionBrowser);
1555
- export { CollectionBrowser };
1387
+ `;
1388
+ __decorate([
1389
+ property({ type: String })
1390
+ ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1391
+ __decorate([
1392
+ property({ type: String })
1393
+ ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1394
+ __decorate([
1395
+ property({ type: Object })
1396
+ ], CollectionBrowser.prototype, "searchService", void 0);
1397
+ __decorate([
1398
+ property({ type: String })
1399
+ ], CollectionBrowser.prototype, "searchType", void 0);
1400
+ __decorate([
1401
+ property({ type: String })
1402
+ ], CollectionBrowser.prototype, "baseQuery", void 0);
1403
+ __decorate([
1404
+ property({ type: String })
1405
+ ], CollectionBrowser.prototype, "displayMode", void 0);
1406
+ __decorate([
1407
+ property({ type: Object })
1408
+ ], CollectionBrowser.prototype, "sortParam", void 0);
1409
+ __decorate([
1410
+ property({ type: String })
1411
+ ], CollectionBrowser.prototype, "selectedSort", void 0);
1412
+ __decorate([
1413
+ property({ type: String })
1414
+ ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1415
+ __decorate([
1416
+ property({ type: String })
1417
+ ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1418
+ __decorate([
1419
+ property({ type: String })
1420
+ ], CollectionBrowser.prototype, "sortDirection", void 0);
1421
+ __decorate([
1422
+ property({ type: Number })
1423
+ ], CollectionBrowser.prototype, "pageSize", void 0);
1424
+ __decorate([
1425
+ property({ type: Object })
1426
+ ], CollectionBrowser.prototype, "resizeObserver", void 0);
1427
+ __decorate([
1428
+ property({ type: String })
1429
+ ], CollectionBrowser.prototype, "titleQuery", void 0);
1430
+ __decorate([
1431
+ property({ type: String })
1432
+ ], CollectionBrowser.prototype, "creatorQuery", void 0);
1433
+ __decorate([
1434
+ property({ type: Number })
1435
+ ], CollectionBrowser.prototype, "currentPage", void 0);
1436
+ __decorate([
1437
+ property({ type: String })
1438
+ ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1439
+ __decorate([
1440
+ property({ type: String })
1441
+ ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1442
+ __decorate([
1443
+ property({ type: Object })
1444
+ ], CollectionBrowser.prototype, "selectedFacets", void 0);
1445
+ __decorate([
1446
+ property({ type: Boolean })
1447
+ ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1448
+ __decorate([
1449
+ property({ type: String, reflect: true })
1450
+ ], CollectionBrowser.prototype, "searchContext", void 0);
1451
+ __decorate([
1452
+ property({ type: Object })
1453
+ ], CollectionBrowser.prototype, "collectionNameCache", void 0);
1454
+ __decorate([
1455
+ property({ type: String })
1456
+ ], CollectionBrowser.prototype, "pageContext", void 0);
1457
+ __decorate([
1458
+ property({ type: Object })
1459
+ ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1460
+ __decorate([
1461
+ property({ type: Number })
1462
+ ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
1463
+ __decorate([
1464
+ property({ type: Boolean })
1465
+ ], CollectionBrowser.prototype, "loggedIn", void 0);
1466
+ __decorate([
1467
+ property({ type: Object })
1468
+ ], CollectionBrowser.prototype, "modalManager", void 0);
1469
+ __decorate([
1470
+ property({ type: Object })
1471
+ ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
1472
+ __decorate([
1473
+ property({ type: Object })
1474
+ ], CollectionBrowser.prototype, "recaptchaManager", void 0);
1475
+ __decorate([
1476
+ property({ type: Boolean })
1477
+ ], CollectionBrowser.prototype, "isManageView", void 0);
1478
+ __decorate([
1479
+ state()
1480
+ ], CollectionBrowser.prototype, "pagesToRender", void 0);
1481
+ __decorate([
1482
+ state()
1483
+ ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
1484
+ __decorate([
1485
+ state()
1486
+ ], CollectionBrowser.prototype, "facetsLoading", void 0);
1487
+ __decorate([
1488
+ state()
1489
+ ], CollectionBrowser.prototype, "fullYearAggregationLoading", void 0);
1490
+ __decorate([
1491
+ state()
1492
+ ], CollectionBrowser.prototype, "aggregations", void 0);
1493
+ __decorate([
1494
+ state()
1495
+ ], CollectionBrowser.prototype, "fullYearsHistogramAggregation", void 0);
1496
+ __decorate([
1497
+ state()
1498
+ ], CollectionBrowser.prototype, "previousSearchType", void 0);
1499
+ __decorate([
1500
+ state()
1501
+ ], CollectionBrowser.prototype, "totalResults", void 0);
1502
+ __decorate([
1503
+ state()
1504
+ ], CollectionBrowser.prototype, "mobileView", void 0);
1505
+ __decorate([
1506
+ state()
1507
+ ], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
1508
+ __decorate([
1509
+ state()
1510
+ ], CollectionBrowser.prototype, "placeholderType", void 0);
1511
+ __decorate([
1512
+ state()
1513
+ ], CollectionBrowser.prototype, "prefixFilterCountMap", void 0);
1514
+ __decorate([
1515
+ query('#content-container')
1516
+ ], CollectionBrowser.prototype, "contentContainer", void 0);
1517
+ __decorate([
1518
+ property({ type: Object, attribute: false })
1519
+ ], CollectionBrowser.prototype, "analyticsHandler", void 0);
1520
+ __decorate([
1521
+ query('infinite-scroller')
1522
+ ], CollectionBrowser.prototype, "infiniteScroller", void 0);
1523
+ CollectionBrowser = __decorate([
1524
+ customElement('collection-browser')
1525
+ ], CollectionBrowser);
1526
+ export { CollectionBrowser };
1556
1527
  //# sourceMappingURL=collection-browser.js.map