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