@internetarchive/collection-browser 2.1.8 → 2.1.9-alpha1

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 (293) hide show
  1. package/.editorconfig +29 -29
  2. package/.husky/pre-commit +4 -4
  3. package/LICENSE +661 -661
  4. package/README.md +83 -83
  5. package/dist/index.d.ts +12 -12
  6. package/dist/index.js +12 -12
  7. package/dist/src/app-root.d.ts +88 -88
  8. package/dist/src/app-root.js +475 -475
  9. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  10. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  11. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  12. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  13. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  14. package/dist/src/assets/img/icons/chevron.js +2 -2
  15. package/dist/src/assets/img/icons/contract.d.ts +2 -2
  16. package/dist/src/assets/img/icons/contract.js +2 -2
  17. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  18. package/dist/src/assets/img/icons/empty-query.js +2 -2
  19. package/dist/src/assets/img/icons/expand.d.ts +2 -2
  20. package/dist/src/assets/img/icons/expand.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/favorite-unfilled.d.ts +1 -1
  28. package/dist/src/assets/img/icons/favorite-unfilled.js +2 -2
  29. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  30. package/dist/src/assets/img/icons/login-required.js +2 -2
  31. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  32. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  33. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  34. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  35. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  36. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  37. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  38. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  39. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  40. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  41. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  42. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  43. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  44. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  45. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  46. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  47. package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -1
  48. package/dist/src/assets/img/icons/mediatype/search.js +2 -2
  49. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  50. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  51. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  52. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  53. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  54. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  55. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  56. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  57. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  58. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  59. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  60. package/dist/src/assets/img/icons/null-result.js +2 -2
  61. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  62. package/dist/src/assets/img/icons/restricted.js +2 -2
  63. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  64. package/dist/src/assets/img/icons/reviews.js +2 -2
  65. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  66. package/dist/src/assets/img/icons/upload.js +2 -2
  67. package/dist/src/assets/img/icons/views.d.ts +1 -1
  68. package/dist/src/assets/img/icons/views.js +2 -2
  69. package/dist/src/circular-activity-indicator.d.ts +5 -5
  70. package/dist/src/circular-activity-indicator.js +17 -17
  71. package/dist/src/collection-browser.d.ts +446 -446
  72. package/dist/src/collection-browser.js +1408 -1408
  73. package/dist/src/collection-browser.js.map +1 -1
  74. package/dist/src/collection-facets/facet-row.d.ts +30 -30
  75. package/dist/src/collection-facets/facet-row.js +114 -114
  76. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  77. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  78. package/dist/src/collection-facets/facets-template.d.ts +17 -17
  79. package/dist/src/collection-facets/facets-template.js +114 -114
  80. package/dist/src/collection-facets/more-facets-content.d.ts +74 -74
  81. package/dist/src/collection-facets/more-facets-content.js +360 -360
  82. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  83. package/dist/src/collection-facets/more-facets-pagination.js +196 -196
  84. package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
  85. package/dist/src/collection-facets/toggle-switch.js +94 -94
  86. package/dist/src/collection-facets.d.ts +103 -103
  87. package/dist/src/collection-facets.js +510 -510
  88. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +236 -236
  89. package/dist/src/data-source/collection-browser-data-source-interface.js +1 -1
  90. package/dist/src/data-source/collection-browser-data-source.d.ts +364 -364
  91. package/dist/src/data-source/collection-browser-data-source.js +946 -946
  92. package/dist/src/data-source/collection-browser-query-state.d.ts +43 -43
  93. package/dist/src/data-source/collection-browser-query-state.js +1 -1
  94. package/dist/src/data-source/models.d.ts +28 -28
  95. package/dist/src/data-source/models.js +8 -8
  96. package/dist/src/empty-placeholder.d.ts +23 -23
  97. package/dist/src/empty-placeholder.js +74 -74
  98. package/dist/src/expanded-date-picker.d.ts +43 -43
  99. package/dist/src/expanded-date-picker.js +109 -109
  100. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  101. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  102. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  103. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  104. package/dist/src/manage/manage-bar.d.ts +30 -30
  105. package/dist/src/manage/manage-bar.js +61 -61
  106. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  107. package/dist/src/mediatype/mediatype-config.js +91 -91
  108. package/dist/src/models.d.ts +198 -198
  109. package/dist/src/models.js +381 -381
  110. package/dist/src/restoration-state-handler.d.ts +70 -70
  111. package/dist/src/restoration-state-handler.js +357 -357
  112. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
  113. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
  114. package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -21
  115. package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
  116. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  117. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  118. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  119. package/dist/src/sort-filter-bar/img/list.js +2 -2
  120. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
  121. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
  122. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
  123. package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
  124. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
  125. package/dist/src/sort-filter-bar/img/sort-toggle-up.js +2 -2
  126. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  127. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  128. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  129. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  130. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +221 -221
  131. package/dist/src/sort-filter-bar/sort-filter-bar.js +691 -691
  132. package/dist/src/styles/ia-button.d.ts +2 -2
  133. package/dist/src/styles/ia-button.js +16 -16
  134. package/dist/src/styles/item-image-styles.d.ts +8 -8
  135. package/dist/src/styles/item-image-styles.js +9 -9
  136. package/dist/src/styles/sr-only.d.ts +1 -1
  137. package/dist/src/styles/sr-only.js +2 -2
  138. package/dist/src/tiles/base-tile-component.d.ts +19 -19
  139. package/dist/src/tiles/base-tile-component.js +63 -63
  140. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  141. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  142. package/dist/src/tiles/grid/account-tile.d.ts +18 -18
  143. package/dist/src/tiles/grid/account-tile.js +72 -72
  144. package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
  145. package/dist/src/tiles/grid/collection-tile.js +80 -80
  146. package/dist/src/tiles/grid/item-tile.d.ts +30 -30
  147. package/dist/src/tiles/grid/item-tile.js +149 -149
  148. package/dist/src/tiles/grid/search-tile.d.ts +10 -10
  149. package/dist/src/tiles/grid/search-tile.js +51 -51
  150. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  151. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +8 -8
  152. package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
  153. package/dist/src/tiles/grid/tile-stats.js +53 -53
  154. package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
  155. package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
  156. package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
  157. package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
  158. package/dist/src/tiles/image-block.d.ts +17 -17
  159. package/dist/src/tiles/image-block.js +73 -73
  160. package/dist/src/tiles/item-image.d.ts +39 -39
  161. package/dist/src/tiles/item-image.js +154 -154
  162. package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
  163. package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
  164. package/dist/src/tiles/list/tile-list-compact.d.ts +15 -15
  165. package/dist/src/tiles/list/tile-list-compact.js +114 -114
  166. package/dist/src/tiles/list/tile-list.d.ts +50 -50
  167. package/dist/src/tiles/list/tile-list.js +315 -315
  168. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  169. package/dist/src/tiles/mediatype-icon.js +47 -47
  170. package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
  171. package/dist/src/tiles/overlay/icon-overlay.js +40 -40
  172. package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
  173. package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
  174. package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
  175. package/dist/src/tiles/overlay/text-overlay.js +42 -42
  176. package/dist/src/tiles/review-block.d.ts +12 -12
  177. package/dist/src/tiles/review-block.js +56 -56
  178. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  179. package/dist/src/tiles/text-snippet-block.js +73 -73
  180. package/dist/src/tiles/tile-dispatcher.d.ts +64 -64
  181. package/dist/src/tiles/tile-dispatcher.js +229 -229
  182. package/dist/src/tiles/tile-display-value-provider.d.ts +47 -47
  183. package/dist/src/tiles/tile-display-value-provider.js +94 -94
  184. package/dist/src/utils/analytics-events.d.ts +26 -26
  185. package/dist/src/utils/analytics-events.js +28 -28
  186. package/dist/src/utils/array-equals.d.ts +4 -4
  187. package/dist/src/utils/array-equals.js +10 -10
  188. package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -11
  189. package/dist/src/utils/collapse-repeated-quotes.js +13 -13
  190. package/dist/src/utils/format-count.d.ts +7 -7
  191. package/dist/src/utils/format-count.js +76 -76
  192. package/dist/src/utils/format-date.d.ts +2 -2
  193. package/dist/src/utils/format-date.js +25 -25
  194. package/dist/src/utils/format-unit-size.d.ts +2 -2
  195. package/dist/src/utils/format-unit-size.js +33 -33
  196. package/dist/src/utils/local-date-from-utc.d.ts +9 -9
  197. package/dist/src/utils/local-date-from-utc.js +15 -15
  198. package/dist/src/utils/log.d.ts +7 -7
  199. package/dist/src/utils/log.js +15 -15
  200. package/dist/src/utils/resolve-mediatype.d.ts +8 -8
  201. package/dist/src/utils/resolve-mediatype.js +23 -23
  202. package/dist/src/utils/sha1.d.ts +2 -2
  203. package/dist/src/utils/sha1.js +8 -8
  204. package/dist/test/collection-browser.test.d.ts +1 -1
  205. package/dist/test/collection-browser.test.js +1283 -1283
  206. package/dist/test/collection-facets/facet-row.test.d.ts +1 -1
  207. package/dist/test/collection-facets/facet-row.test.js +203 -203
  208. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  209. package/dist/test/collection-facets/facets-template.test.js +105 -105
  210. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  211. package/dist/test/collection-facets/more-facets-content.test.js +139 -139
  212. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  213. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  214. package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -1
  215. package/dist/test/collection-facets/toggle-switch.test.js +73 -73
  216. package/dist/test/collection-facets.test.d.ts +2 -2
  217. package/dist/test/collection-facets.test.js +652 -652
  218. package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -1
  219. package/dist/test/data-source/collection-browser-data-source.test.js +89 -89
  220. package/dist/test/empty-placeholder.test.d.ts +1 -1
  221. package/dist/test/empty-placeholder.test.js +63 -63
  222. package/dist/test/expanded-date-picker.test.d.ts +1 -1
  223. package/dist/test/expanded-date-picker.test.js +95 -95
  224. package/dist/test/icon-overlay.test.d.ts +1 -1
  225. package/dist/test/icon-overlay.test.js +24 -24
  226. package/dist/test/image-block.test.d.ts +1 -1
  227. package/dist/test/image-block.test.js +48 -48
  228. package/dist/test/item-image.test.d.ts +1 -1
  229. package/dist/test/item-image.test.js +85 -85
  230. package/dist/test/manage/manage-bar.test.d.ts +1 -1
  231. package/dist/test/manage/manage-bar.test.js +81 -81
  232. package/dist/test/mediatype-config.test.d.ts +1 -1
  233. package/dist/test/mediatype-config.test.js +16 -16
  234. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  235. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  236. package/dist/test/mocks/mock-search-responses.d.ts +24 -24
  237. package/dist/test/mocks/mock-search-responses.js +860 -860
  238. package/dist/test/mocks/mock-search-service.d.ts +15 -15
  239. package/dist/test/mocks/mock-search-service.js +53 -53
  240. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  241. package/dist/test/restoration-state-handler.test.js +270 -270
  242. package/dist/test/review-block.test.d.ts +1 -1
  243. package/dist/test/review-block.test.js +44 -44
  244. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
  245. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
  246. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  247. package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
  248. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  249. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +426 -426
  250. package/dist/test/text-overlay.test.d.ts +1 -1
  251. package/dist/test/text-overlay.test.js +48 -48
  252. package/dist/test/text-snippet-block.test.d.ts +1 -1
  253. package/dist/test/text-snippet-block.test.js +57 -57
  254. package/dist/test/tile-stats.test.d.ts +1 -1
  255. package/dist/test/tile-stats.test.js +81 -81
  256. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  257. package/dist/test/tiles/grid/account-tile.test.js +76 -76
  258. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  259. package/dist/test/tiles/grid/collection-tile.test.js +73 -73
  260. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  261. package/dist/test/tiles/grid/item-tile.test.js +312 -312
  262. package/dist/test/tiles/grid/search-tile.test.d.ts +1 -1
  263. package/dist/test/tiles/grid/search-tile.test.js +51 -51
  264. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  265. package/dist/test/tiles/hover/hover-pane-controller.test.js +259 -259
  266. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  267. package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
  268. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  269. package/dist/test/tiles/list/tile-list-compact.test.js +143 -143
  270. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  271. package/dist/test/tiles/list/tile-list.test.js +297 -297
  272. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
  273. package/dist/test/tiles/tile-dispatcher.test.js +100 -100
  274. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
  275. package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
  276. package/dist/test/utils/array-equals.test.d.ts +1 -1
  277. package/dist/test/utils/array-equals.test.js +26 -26
  278. package/dist/test/utils/format-count.test.d.ts +1 -1
  279. package/dist/test/utils/format-count.test.js +23 -23
  280. package/dist/test/utils/format-date.test.d.ts +1 -1
  281. package/dist/test/utils/format-date.test.js +17 -17
  282. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  283. package/dist/test/utils/format-unit-size.test.js +17 -17
  284. package/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
  285. package/dist/test/utils/local-date-from-utc.test.js +26 -26
  286. package/local.archive.org.cert +86 -86
  287. package/local.archive.org.key +27 -27
  288. package/package.json +1 -1
  289. package/renovate.json +6 -6
  290. package/src/collection-browser.ts +1 -1
  291. package/tsconfig.json +21 -21
  292. package/web-dev-server.config.mjs +30 -30
  293. package/web-test-runner.config.mjs +41 -41
@@ -1,351 +1,351 @@
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 { msg } from '@lit/localize';
7
- import { SearchType, } from '@internetarchive/search-service';
8
- import '@internetarchive/infinite-scroller';
9
- import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
10
- import { RestorationStateHandler, } from './restoration-state-handler';
11
- import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
12
- import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
13
- import chevronIcon from './assets/img/icons/chevron';
14
- import { srOnlyStyle } from './styles/sr-only';
15
- import { sha1 } from './utils/sha1';
16
- import { formatDate } from './utils/format-date';
17
- import { log } from './utils/log';
18
- import './empty-placeholder';
19
- import './tiles/tile-dispatcher';
20
- import './tiles/collection-browser-loading-tile';
21
- import './sort-filter-bar/sort-filter-bar';
22
- import './manage/manage-bar';
23
- import './collection-facets';
24
- import './circular-activity-indicator';
25
- let CollectionBrowser = class CollectionBrowser extends LitElement {
26
- constructor() {
27
- super();
28
- this.baseImageUrl = 'https://archive.org';
29
- /**
30
- * Which backend should be targeted by searches (e.g., metadata or FTS)
31
- */
32
- this.searchType = SearchType.METADATA;
33
- this.defaultSortParam = null;
34
- this.selectedSort = SortField.default;
35
- this.selectedTitleFilter = null;
36
- this.selectedCreatorFilter = null;
37
- this.sortDirection = null;
38
- this.pageSize = 50;
39
- /**
40
- * Whether to show the date picker (above the facets)
41
- */
42
- this.showHistogramDatePicker = false;
43
- /**
44
- * Whether placeholder views should be suppressed. If true, searches that produce an
45
- * error or empty result set will simply show a blank results view instead of a placeholder.
46
- */
47
- this.suppressPlaceholders = false;
48
- /**
49
- * Whether the result count text should be suppressed.
50
- * If true, no "X Results" message will be shown.
51
- */
52
- this.suppressResultCount = false;
53
- /**
54
- * Whether the scrolling result view should be suppressed entirely.
55
- * If true, no infinite scroller (and thus no result tiles) will be rendered.
56
- */
57
- this.suppressResultTiles = false;
58
- /**
59
- * Whether to suppress persistence of the query to the URL.
60
- * If true, the `query` param will not be added to the URL or updated on query changes.
61
- */
62
- this.suppressURLQuery = false;
63
- /**
64
- * Whether to suppress the display of facets.
65
- * If true, the facet sidebar content will be replaced by a message that facets are
66
- * temporarily unavailable.
67
- */
68
- this.suppressFacets = false;
69
- /**
70
- * Whether to suppress display of the sort bar.
71
- * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
72
- */
73
- this.suppressSortBar = false;
74
- /**
75
- * Whether to suppress showing the display mode options in the sort bar.
76
- * If true, those options will be omitted (though the rest of the sort bar may still render).
77
- */
78
- this.suppressDisplayModes = false;
79
- this.clearResultsOnEmptyQuery = false;
80
- this.collectionPagePath = '/details/';
81
- /** describes where this component is being used */
82
- this.searchContext = analyticsCategories.default;
83
- this.pageContext = 'search';
84
- this.restorationStateHandler = new RestorationStateHandler({
85
- context: this.pageContext,
86
- });
87
- this.mobileBreakpoint = 600;
88
- this.loggedIn = false;
89
- this.modalManager = undefined;
90
- /**
91
- * If item management UI active
92
- */
93
- this.isManageView = false;
94
- this.manageViewLabel = 'Select items to remove';
95
- /** Whether to replace the default sort options with a slot for customization (default: false) */
96
- this.enableSortOptionsSlot = false;
97
- /**
98
- * The results per page so we can paginate.
99
- *
100
- * This allows us to start in the middle of the search results and
101
- * fetch data before or after the current page. If we don't have a key
102
- * for the previous/next page, we'll fetch the next/previous page to populate it
103
- */
104
- this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
105
- /**
106
- * The page that the consumer wants to load.
107
- */
108
- this.initialPageNumber = 1;
109
- /**
110
- * This the the number of pages that we want to show.
111
- *
112
- * The data isn't necessarily loaded for all of the pages, but this lets us
113
- * know how many cells we should render.
114
- */
115
- this.pagesToRender = this.initialPageNumber;
116
- /**
117
- * Whether the initial page fetch for a new query is currently in progress.
118
- */
119
- this.searchResultsLoading = false;
120
- this.facetsLoading = false;
121
- this.mobileView = false;
122
- this.mobileFacetsVisible = false;
123
- this.defaultSortField = SortField.relevance;
124
- this.defaultSortDirection = null;
125
- this.placeholderType = null;
126
- /**
127
- * When we're animated scrolling to the page, we don't want to fetch
128
- * all of the pages as it scrolls so this lets us know if we're scrolling
129
- */
130
- this.isScrollingToCell = false;
131
- /**
132
- * When page width resizes from desktop to mobile, set true to
133
- * disable expand/collapse transition when loading.
134
- */
135
- this.isResizeToMobile = false;
136
- /**
137
- * Flag indicating that a new data source is currently being installed.
138
- * During the install, any URL persistence operation should replace the current entry
139
- * instead of creating a new one.
140
- */
141
- this.dataSourceInstallInProgress = false;
142
- this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
143
- /**
144
- * How many tiles to offset the data source by, to account for any removed tiles.
145
- */
146
- this.tileModelOffset = 0;
147
- /**
148
- * Updates the height of the left column according to its position on the page.
149
- * Arrow function ensures proper `this` binding.
150
- */
151
- this.updateLeftColumnHeight = () => {
152
- var _a, _b, _c, _d, _e;
153
- if (this.mobileView) {
154
- (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
155
- }
156
- else {
157
- const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
158
- (_e = (_d = this.leftColumn) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.setProperty('height', `${window.innerHeight - (clientTop !== null && clientTop !== void 0 ? clientTop : 0) - 3}px`);
159
- }
160
- };
161
- /**
162
- * Toggles whether the fade-out is visible at the bottom of the facets.
163
- * It should only be visible if the facets are not scrolled to the bottom.
164
- * Arrow function ensures proper `this` binding.
165
- */
166
- this.updateFacetFadeOut = (entries) => {
167
- var _a, _b;
168
- const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
169
- fadeElmt === null || fadeElmt === void 0 ? void 0 : fadeElmt.classList.toggle('hidden', (_b = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _b === void 0 ? void 0 : _b.isIntersecting);
170
- };
171
- // we only want to scroll on the very first query change
172
- // so this keeps track of whether we've already set the initial query
173
- this.initialQueryChangeHappened = false;
174
- this.historyPopOccurred = false;
175
- this.addController(this.dataSource);
176
- }
177
- tileModelAtCellIndex(index) {
178
- const model = this.dataSource.getTileModelAt(index);
179
- /**
180
- * If we encounter a model we don't have yet and we're not in the middle of an
181
- * automated scroll, fetch the page and just return undefined.
182
- * The datasource will be updated once the page is loaded and the cell will be rendered.
183
- *
184
- * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
185
- * user may never see.
186
- */
187
- if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
188
- const pageNumber = Math.floor(index / this.pageSize) + 1;
189
- this.dataSource.fetchPage(pageNumber);
190
- }
191
- return model;
192
- }
193
- // this is the total number of tiles we expect if
194
- // the data returned is a full page worth
195
- // this is useful for putting in placeholders for the expected number of tiles
196
- get estimatedTileCount() {
197
- return this.pagesToRender * this.pageSize;
198
- }
199
- /**
200
- * Returns a promise resolving to a unique string that persists for the current browser session.
201
- * Used in generating unique IDs for search requests, so that multiple requests coming from the
202
- * same browser session can be identified.
203
- */
204
- async getSessionId() {
205
- try {
206
- const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
207
- if (storedSessionId) {
208
- return storedSessionId;
209
- }
210
- // If we enter this method a second time while a first session ID is already being generated,
211
- // ensure we produce the same ID from both calls instead of generating another one.
212
- if (this.sessionIdGenPromise) {
213
- return this.sessionIdGenPromise;
214
- }
215
- this.sessionIdGenPromise = sha1(Math.random().toString());
216
- const newSessionId = await this.sessionIdGenPromise;
217
- sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
218
- return newSessionId;
219
- }
220
- catch (err) {
221
- // Either we can't generate the hash or we're restricted from accessing sessionStorage
222
- return '';
223
- }
224
- }
225
- /**
226
- * Go to the given page of results
227
- *
228
- * @param pageNumber
229
- */
230
- goToPage(pageNumber) {
231
- this.initialPageNumber = pageNumber;
232
- this.pagesToRender = pageNumber;
233
- return this.scrollToPage(pageNumber);
234
- }
235
- /**
236
- * Sets the state for whether the initial set of search results is loading in.
237
- */
238
- setSearchResultsLoading(loading) {
239
- this.searchResultsLoading = loading;
240
- }
241
- /**
242
- * Sets the state for whether facet data is loading in
243
- */
244
- setFacetsLoading(loading) {
245
- this.facetsLoading = loading;
246
- }
247
- /**
248
- * Sets the total number of results to be displayed for the current search
249
- */
250
- setTotalResultCount(totalResults) {
251
- this.totalResults = totalResults;
252
- }
253
- /**
254
- * Clears all selected/negated facets, date ranges, and letter filters.
255
- *
256
- * By default, the current sort field/direction are not cleared,
257
- * but this can be overridden by setting the `sort` option to `true`.
258
- *
259
- * Similarly, it is possible to finely control what is cleared by
260
- * setting any of the `facets`, `dateRange`, or `letterFilters` flags
261
- * in the options object.
262
- */
263
- clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
264
- // Don't bother clearing facets if none are checked, so that we don't
265
- // trigger unnecessary update cycles.
266
- if (facets && this.hasCheckedFacets) {
267
- this.selectedFacets = getDefaultSelectedFacets();
268
- }
269
- if (dateRange) {
270
- this.minSelectedDate = undefined;
271
- this.maxSelectedDate = undefined;
272
- }
273
- if (letterFilters) {
274
- this.selectedTitleFilter = null;
275
- this.selectedCreatorFilter = null;
276
- }
277
- if (sort) {
278
- this.sortDirection = null;
279
- this.selectedSort = SortField.default;
280
- }
281
- }
282
- /**
283
- * Returns true if the current value of `this.selectedFacets` contains
284
- * any facet buckets than have been selected or negated, or false otherwise.
285
- */
286
- get hasCheckedFacets() {
287
- if (!this.selectedFacets)
288
- return false;
289
- for (const facetGroup of Object.values(this.selectedFacets)) {
290
- for (const bucket of Object.values(facetGroup)) {
291
- if (bucket.state !== 'none')
292
- return true;
293
- }
294
- }
295
- return false;
296
- }
297
- /**
298
- * Returns true if there are any currently selected/negated facet buckets,
299
- * any selected date range, or any selected letter filters. False otherwise.
300
- *
301
- * Ignores sorting options.
302
- */
303
- get hasActiveFilters() {
304
- return !!(this.hasCheckedFacets ||
305
- this.minSelectedDate ||
306
- this.maxSelectedDate ||
307
- this.selectedTitleFilter ||
308
- this.selectedCreatorFilter);
309
- }
310
- render() {
311
- 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 { msg } from '@lit/localize';
7
+ import { SearchType, } from '@internetarchive/search-service';
8
+ import '@internetarchive/infinite-scroller';
9
+ import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
10
+ import { RestorationStateHandler, } from './restoration-state-handler';
11
+ import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
12
+ import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
13
+ import chevronIcon from './assets/img/icons/chevron';
14
+ import { srOnlyStyle } from './styles/sr-only';
15
+ import { sha1 } from './utils/sha1';
16
+ import { formatDate } from './utils/format-date';
17
+ import { log } from './utils/log';
18
+ import './empty-placeholder';
19
+ import './tiles/tile-dispatcher';
20
+ import './tiles/collection-browser-loading-tile';
21
+ import './sort-filter-bar/sort-filter-bar';
22
+ import './manage/manage-bar';
23
+ import './collection-facets';
24
+ import './circular-activity-indicator';
25
+ let CollectionBrowser = class CollectionBrowser extends LitElement {
26
+ constructor() {
27
+ super();
28
+ this.baseImageUrl = 'https://archive.org';
29
+ /**
30
+ * Which backend should be targeted by searches (e.g., metadata or FTS)
31
+ */
32
+ this.searchType = SearchType.METADATA;
33
+ this.defaultSortParam = null;
34
+ this.selectedSort = SortField.default;
35
+ this.selectedTitleFilter = null;
36
+ this.selectedCreatorFilter = null;
37
+ this.sortDirection = null;
38
+ this.pageSize = 50;
39
+ /**
40
+ * Whether to show the date picker (above the facets)
41
+ */
42
+ this.showHistogramDatePicker = false;
43
+ /**
44
+ * Whether placeholder views should be suppressed. If true, searches that produce an
45
+ * error or empty result set will simply show a blank results view instead of a placeholder.
46
+ */
47
+ this.suppressPlaceholders = false;
48
+ /**
49
+ * Whether the result count text should be suppressed.
50
+ * If true, no "X Results" message will be shown.
51
+ */
52
+ this.suppressResultCount = false;
53
+ /**
54
+ * Whether the scrolling result view should be suppressed entirely.
55
+ * If true, no infinite scroller (and thus no result tiles) will be rendered.
56
+ */
57
+ this.suppressResultTiles = false;
58
+ /**
59
+ * Whether to suppress persistence of the query to the URL.
60
+ * If true, the `query` param will not be added to the URL or updated on query changes.
61
+ */
62
+ this.suppressURLQuery = false;
63
+ /**
64
+ * Whether to suppress the display of facets.
65
+ * If true, the facet sidebar content will be replaced by a message that facets are
66
+ * temporarily unavailable.
67
+ */
68
+ this.suppressFacets = false;
69
+ /**
70
+ * Whether to suppress display of the sort bar.
71
+ * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
72
+ */
73
+ this.suppressSortBar = false;
74
+ /**
75
+ * Whether to suppress showing the display mode options in the sort bar.
76
+ * If true, those options will be omitted (though the rest of the sort bar may still render).
77
+ */
78
+ this.suppressDisplayModes = false;
79
+ this.clearResultsOnEmptyQuery = false;
80
+ this.collectionPagePath = '/details/';
81
+ /** describes where this component is being used */
82
+ this.searchContext = analyticsCategories.default;
83
+ this.pageContext = 'search';
84
+ this.restorationStateHandler = new RestorationStateHandler({
85
+ context: this.pageContext,
86
+ });
87
+ this.mobileBreakpoint = 600;
88
+ this.loggedIn = false;
89
+ this.modalManager = undefined;
90
+ /**
91
+ * If item management UI active
92
+ */
93
+ this.isManageView = false;
94
+ this.manageViewLabel = 'Select items to remove';
95
+ /** Whether to replace the default sort options with a slot for customization (default: false) */
96
+ this.enableSortOptionsSlot = false;
97
+ /**
98
+ * The results per page so we can paginate.
99
+ *
100
+ * This allows us to start in the middle of the search results and
101
+ * fetch data before or after the current page. If we don't have a key
102
+ * for the previous/next page, we'll fetch the next/previous page to populate it
103
+ */
104
+ this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
105
+ /**
106
+ * The page that the consumer wants to load.
107
+ */
108
+ this.initialPageNumber = 1;
109
+ /**
110
+ * This the the number of pages that we want to show.
111
+ *
112
+ * The data isn't necessarily loaded for all of the pages, but this lets us
113
+ * know how many cells we should render.
114
+ */
115
+ this.pagesToRender = this.initialPageNumber;
116
+ /**
117
+ * Whether the initial page fetch for a new query is currently in progress.
118
+ */
119
+ this.searchResultsLoading = false;
120
+ this.facetsLoading = false;
121
+ this.mobileView = false;
122
+ this.mobileFacetsVisible = false;
123
+ this.defaultSortField = SortField.relevance;
124
+ this.defaultSortDirection = null;
125
+ this.placeholderType = null;
126
+ /**
127
+ * When we're animated scrolling to the page, we don't want to fetch
128
+ * all of the pages as it scrolls so this lets us know if we're scrolling
129
+ */
130
+ this.isScrollingToCell = false;
131
+ /**
132
+ * When page width resizes from desktop to mobile, set true to
133
+ * disable expand/collapse transition when loading.
134
+ */
135
+ this.isResizeToMobile = false;
136
+ /**
137
+ * Flag indicating that a new data source is currently being installed.
138
+ * During the install, any URL persistence operation should replace the current entry
139
+ * instead of creating a new one.
140
+ */
141
+ this.dataSourceInstallInProgress = false;
142
+ this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
143
+ /**
144
+ * How many tiles to offset the data source by, to account for any removed tiles.
145
+ */
146
+ this.tileModelOffset = 0;
147
+ /**
148
+ * Updates the height of the left column according to its position on the page.
149
+ * Arrow function ensures proper `this` binding.
150
+ */
151
+ this.updateLeftColumnHeight = () => {
152
+ var _a, _b, _c, _d, _e;
153
+ if (this.mobileView) {
154
+ (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
155
+ }
156
+ else {
157
+ const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
158
+ (_e = (_d = this.leftColumn) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.setProperty('height', `${window.innerHeight - (clientTop !== null && clientTop !== void 0 ? clientTop : 0) - 3}px`);
159
+ }
160
+ };
161
+ /**
162
+ * Toggles whether the fade-out is visible at the bottom of the facets.
163
+ * It should only be visible if the facets are not scrolled to the bottom.
164
+ * Arrow function ensures proper `this` binding.
165
+ */
166
+ this.updateFacetFadeOut = (entries) => {
167
+ var _a, _b;
168
+ const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
169
+ fadeElmt === null || fadeElmt === void 0 ? void 0 : fadeElmt.classList.toggle('hidden', (_b = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _b === void 0 ? void 0 : _b.isIntersecting);
170
+ };
171
+ // we only want to scroll on the very first query change
172
+ // so this keeps track of whether we've already set the initial query
173
+ this.initialQueryChangeHappened = false;
174
+ this.historyPopOccurred = false;
175
+ this.addController(this.dataSource);
176
+ }
177
+ tileModelAtCellIndex(index) {
178
+ const model = this.dataSource.getTileModelAt(index);
179
+ /**
180
+ * If we encounter a model we don't have yet and we're not in the middle of an
181
+ * automated scroll, fetch the page and just return undefined.
182
+ * The datasource will be updated once the page is loaded and the cell will be rendered.
183
+ *
184
+ * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
185
+ * user may never see.
186
+ */
187
+ if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
188
+ const pageNumber = Math.floor(index / this.pageSize) + 1;
189
+ this.dataSource.fetchPage(pageNumber);
190
+ }
191
+ return model;
192
+ }
193
+ // this is the total number of tiles we expect if
194
+ // the data returned is a full page worth
195
+ // this is useful for putting in placeholders for the expected number of tiles
196
+ get estimatedTileCount() {
197
+ return this.pagesToRender * this.pageSize;
198
+ }
199
+ /**
200
+ * Returns a promise resolving to a unique string that persists for the current browser session.
201
+ * Used in generating unique IDs for search requests, so that multiple requests coming from the
202
+ * same browser session can be identified.
203
+ */
204
+ async getSessionId() {
205
+ try {
206
+ const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
207
+ if (storedSessionId) {
208
+ return storedSessionId;
209
+ }
210
+ // If we enter this method a second time while a first session ID is already being generated,
211
+ // ensure we produce the same ID from both calls instead of generating another one.
212
+ if (this.sessionIdGenPromise) {
213
+ return this.sessionIdGenPromise;
214
+ }
215
+ this.sessionIdGenPromise = sha1(Math.random().toString());
216
+ const newSessionId = await this.sessionIdGenPromise;
217
+ sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
218
+ return newSessionId;
219
+ }
220
+ catch (err) {
221
+ // Either we can't generate the hash or we're restricted from accessing sessionStorage
222
+ return '';
223
+ }
224
+ }
225
+ /**
226
+ * Go to the given page of results
227
+ *
228
+ * @param pageNumber
229
+ */
230
+ goToPage(pageNumber) {
231
+ this.initialPageNumber = pageNumber;
232
+ this.pagesToRender = pageNumber;
233
+ return this.scrollToPage(pageNumber);
234
+ }
235
+ /**
236
+ * Sets the state for whether the initial set of search results is loading in.
237
+ */
238
+ setSearchResultsLoading(loading) {
239
+ this.searchResultsLoading = loading;
240
+ }
241
+ /**
242
+ * Sets the state for whether facet data is loading in
243
+ */
244
+ setFacetsLoading(loading) {
245
+ this.facetsLoading = loading;
246
+ }
247
+ /**
248
+ * Sets the total number of results to be displayed for the current search
249
+ */
250
+ setTotalResultCount(totalResults) {
251
+ this.totalResults = totalResults;
252
+ }
253
+ /**
254
+ * Clears all selected/negated facets, date ranges, and letter filters.
255
+ *
256
+ * By default, the current sort field/direction are not cleared,
257
+ * but this can be overridden by setting the `sort` option to `true`.
258
+ *
259
+ * Similarly, it is possible to finely control what is cleared by
260
+ * setting any of the `facets`, `dateRange`, or `letterFilters` flags
261
+ * in the options object.
262
+ */
263
+ clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
264
+ // Don't bother clearing facets if none are checked, so that we don't
265
+ // trigger unnecessary update cycles.
266
+ if (facets && this.hasCheckedFacets) {
267
+ this.selectedFacets = getDefaultSelectedFacets();
268
+ }
269
+ if (dateRange) {
270
+ this.minSelectedDate = undefined;
271
+ this.maxSelectedDate = undefined;
272
+ }
273
+ if (letterFilters) {
274
+ this.selectedTitleFilter = null;
275
+ this.selectedCreatorFilter = null;
276
+ }
277
+ if (sort) {
278
+ this.sortDirection = null;
279
+ this.selectedSort = SortField.default;
280
+ }
281
+ }
282
+ /**
283
+ * Returns true if the current value of `this.selectedFacets` contains
284
+ * any facet buckets than have been selected or negated, or false otherwise.
285
+ */
286
+ get hasCheckedFacets() {
287
+ if (!this.selectedFacets)
288
+ return false;
289
+ for (const facetGroup of Object.values(this.selectedFacets)) {
290
+ for (const bucket of Object.values(facetGroup)) {
291
+ if (bucket.state !== 'none')
292
+ return true;
293
+ }
294
+ }
295
+ return false;
296
+ }
297
+ /**
298
+ * Returns true if there are any currently selected/negated facet buckets,
299
+ * any selected date range, or any selected letter filters. False otherwise.
300
+ *
301
+ * Ignores sorting options.
302
+ */
303
+ get hasActiveFilters() {
304
+ return !!(this.hasCheckedFacets ||
305
+ this.minSelectedDate ||
306
+ this.maxSelectedDate ||
307
+ this.selectedTitleFilter ||
308
+ this.selectedCreatorFilter);
309
+ }
310
+ render() {
311
+ this.setPlaceholderType();
312
312
  return html `
313
313
  <div
314
314
  id="content-container"
315
315
  class=${this.mobileView ? 'mobile' : 'desktop'}
316
316
  >
317
- ${this.placeholderType
318
- ? this.emptyPlaceholderTemplate
317
+ ${this.placeholderType
318
+ ? this.emptyPlaceholderTemplate
319
319
  : this.collectionBrowserTemplate}
320
320
  </div>
321
- `;
322
- }
323
- setPlaceholderType() {
324
- var _a;
325
- const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
326
- const isCollection = !!this.withinCollection;
327
- const isProfile = !!this.withinProfile;
328
- const noResults = !this.searchResultsLoading &&
329
- (this.dataSource.size === 0 || !this.searchService);
330
- this.placeholderType = null;
331
- if (this.suppressPlaceholders)
332
- return;
333
- if (!hasQuery && !isCollection && !isProfile) {
334
- this.placeholderType = 'empty-query';
335
- }
336
- else if (noResults) {
337
- // Within a collection, no query + no results means the collection simply has no viewable items.
338
- // Otherwise, we must have a user query that produced 0 results.
339
- this.placeholderType =
340
- !hasQuery && isCollection ? 'empty-collection' : 'no-results';
341
- }
342
- if (this.dataSource.queryErrorMessage) {
343
- this.placeholderType =
344
- !hasQuery && isCollection ? 'collection-error' : 'query-error';
345
- }
346
- }
347
- get emptyPlaceholderTemplate() {
348
- var _a;
321
+ `;
322
+ }
323
+ setPlaceholderType() {
324
+ var _a;
325
+ const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
326
+ const isCollection = !!this.withinCollection;
327
+ const isProfile = !!this.withinProfile;
328
+ const noResults = !this.searchResultsLoading &&
329
+ (this.dataSource.size === 0 || !this.searchService);
330
+ this.placeholderType = null;
331
+ if (this.suppressPlaceholders)
332
+ return;
333
+ if (!hasQuery && !isCollection && !isProfile) {
334
+ this.placeholderType = 'empty-query';
335
+ }
336
+ else if (noResults) {
337
+ // Within a collection, no query + no results means the collection simply has no viewable items.
338
+ // Otherwise, we must have a user query that produced 0 results.
339
+ this.placeholderType =
340
+ !hasQuery && isCollection ? 'empty-collection' : 'no-results';
341
+ }
342
+ if (this.dataSource.queryErrorMessage) {
343
+ this.placeholderType =
344
+ !hasQuery && isCollection ? 'collection-error' : 'query-error';
345
+ }
346
+ }
347
+ get emptyPlaceholderTemplate() {
348
+ var _a;
349
349
  return html `
350
350
  <empty-placeholder
351
351
  .placeholderType=${this.placeholderType}
@@ -354,33 +354,33 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
354
354
  .detailMessage=${(_a = this.dataSource.queryErrorMessage) !== null && _a !== void 0 ? _a : ''}
355
355
  .baseNavigationUrl=${this.baseNavigationUrl}
356
356
  ></empty-placeholder>
357
- `;
358
- }
359
- /**
360
- * Top-level template for rendering the left (facets) and right (results) columns.
361
- */
362
- get collectionBrowserTemplate() {
357
+ `;
358
+ }
359
+ /**
360
+ * Top-level template for rendering the left (facets) and right (results) columns.
361
+ */
362
+ get collectionBrowserTemplate() {
363
363
  return html `
364
364
  <div id="left-column-scroll-sentinel"></div>
365
365
  ${this.leftColumnTemplate} ${this.rightColumnTemplate}
366
- `;
367
- }
368
- /**
369
- * Template for either the mobile or desktop version of the left column, depending
370
- * on current component state.
371
- */
372
- get leftColumnTemplate() {
373
- if (this.mobileView) {
374
- return this.mobileLeftColumnTemplate;
375
- }
376
- return this.desktopLeftColumnTemplate;
377
- }
378
- /**
379
- * Template for the mobile version of the "left column" (which in this case, appears
380
- * *above* the search results rather than beside them), for rendering the
381
- * accordion-style facets.
382
- */
383
- get mobileLeftColumnTemplate() {
366
+ `;
367
+ }
368
+ /**
369
+ * Template for either the mobile or desktop version of the left column, depending
370
+ * on current component state.
371
+ */
372
+ get leftColumnTemplate() {
373
+ if (this.mobileView) {
374
+ return this.mobileLeftColumnTemplate;
375
+ }
376
+ return this.desktopLeftColumnTemplate;
377
+ }
378
+ /**
379
+ * Template for the mobile version of the "left column" (which in this case, appears
380
+ * *above* the search results rather than beside them), for rendering the
381
+ * accordion-style facets.
382
+ */
383
+ get mobileLeftColumnTemplate() {
384
384
  return html `
385
385
  <div
386
386
  id="left-column"
@@ -389,12 +389,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
389
389
  ${this.facetTopViewSlot} ${this.resultsCountTemplate}
390
390
  <div id="facets-header-container">${this.mobileFacetsTemplate}</div>
391
391
  </div>
392
- `;
393
- }
394
- /**
395
- * Template for the desktop version of the left column, displaying the facets sidebar.
396
- */
397
- get desktopLeftColumnTemplate() {
392
+ `;
393
+ }
394
+ /**
395
+ * Template for the desktop version of the left column, displaying the facets sidebar.
396
+ */
397
+ get desktopLeftColumnTemplate() {
398
398
  return html `
399
399
  <div id="left-column" class="column">
400
400
  ${this.facetTopViewSlot}
@@ -408,28 +408,28 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
408
408
  </div>
409
409
  <div id="facets-bottom-fade"></div>
410
410
  </div>
411
- `;
412
- }
413
- /**
414
- * Slot which is placed at top of the facets area for user-profile page
415
- * - mainly used to render userlists
416
- */
417
- get facetTopViewSlot() {
411
+ `;
412
+ }
413
+ /**
414
+ * Slot which is placed at top of the facets area for user-profile page
415
+ * - mainly used to render userlists
416
+ */
417
+ get facetTopViewSlot() {
418
418
  return html `<div id="facet-top-view">
419
419
  <slot name="facet-top-slot"></slot>
420
- </div>`;
421
- }
422
- /**
423
- * Template for the "X Results" count at the top of the search results.
424
- * Changes to the "Searching..." label if the search results are still loading.
425
- */
426
- get resultsCountTemplate() {
427
- var _a;
428
- if (this.suppressResultCount)
429
- return nothing;
430
- const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
431
- const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
432
- const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
420
+ </div>`;
421
+ }
422
+ /**
423
+ * Template for the "X Results" count at the top of the search results.
424
+ * Changes to the "Searching..." label if the search results are still loading.
425
+ */
426
+ get resultsCountTemplate() {
427
+ var _a;
428
+ if (this.suppressResultCount)
429
+ return nothing;
430
+ const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
431
+ const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
432
+ const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
433
433
  return html `
434
434
  <div id="results-total">
435
435
  <span id="big-results-count">
@@ -439,30 +439,30 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
439
439
  ${shouldShowSearching ? nothing : resultsLabel}
440
440
  </span>
441
441
  </div>
442
- `;
443
- }
444
- /**
445
- * Template for the right column of the collection browser, where the result
446
- * tiles and sort/filter bar are shown.
447
- */
448
- get rightColumnTemplate() {
442
+ `;
443
+ }
444
+ /**
445
+ * Template for the right column of the collection browser, where the result
446
+ * tiles and sort/filter bar are shown.
447
+ */
448
+ get rightColumnTemplate() {
449
449
  return html `
450
450
  <div id="right-column" class="column">
451
451
  <div id="cb-top-view">
452
452
  <slot name="cb-top-slot"></slot>
453
453
  </div>
454
- ${this.isManageView
455
- ? this.manageBarTemplate
454
+ ${this.isManageView
455
+ ? this.manageBarTemplate
456
456
  : this.sortFilterBarTemplate}
457
457
  <slot name="cb-results"></slot>
458
- ${this.displayMode === `list-compact`
459
- ? this.listHeaderTemplate
458
+ ${this.displayMode === `list-compact` && this.totalResults
459
+ ? this.listHeaderTemplate
460
460
  : nothing}
461
461
  ${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
462
462
  </div>
463
- `;
464
- }
465
- get infiniteScrollerTemplate() {
463
+ `;
464
+ }
465
+ get infiniteScrollerTemplate() {
466
466
  return html `<infinite-scroller
467
467
  class=${this.infiniteScrollerClasses}
468
468
  itemCount=${this.placeholderType ? 0 : nothing}
@@ -471,22 +471,22 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
471
471
  .placeholderCellTemplate=${this.placeholderCellTemplate}
472
472
  @scrollThresholdReached=${this.scrollThresholdReached}
473
473
  @visibleCellsChanged=${this.visibleCellsChanged}
474
- >${this.displayMode === 'grid'
475
- ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
474
+ >${this.displayMode === 'grid'
475
+ ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
476
476
  : nothing}
477
- </infinite-scroller>`;
478
- }
479
- get infiniteScrollerClasses() {
480
- var _a;
481
- return classMap({
482
- [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
483
- hidden: !!this.placeholderType,
484
- });
485
- }
486
- get sortFilterBarTemplate() {
487
- var _a;
488
- if (this.suppressSortBar)
489
- return nothing;
477
+ </infinite-scroller>`;
478
+ }
479
+ get infiniteScrollerClasses() {
480
+ var _a;
481
+ return classMap({
482
+ [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
483
+ hidden: !!this.placeholderType,
484
+ });
485
+ }
486
+ get sortFilterBarTemplate() {
487
+ var _a;
488
+ if (this.suppressSortBar)
489
+ return nothing;
490
490
  return html `
491
491
  <sort-filter-bar
492
492
  .defaultSortField=${this.defaultSortField}
@@ -511,9 +511,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
511
511
  <slot name="sort-options" slot="sort-options"></slot>
512
512
  <slot name="sort-options-right" slot="sort-options-right"></slot>
513
513
  </sort-filter-bar>
514
- `;
515
- }
516
- get manageBarTemplate() {
514
+ `;
515
+ }
516
+ get manageBarTemplate() {
517
517
  return html `
518
518
  <manage-bar
519
519
  .label=${this.manageViewLabel}
@@ -523,170 +523,170 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
523
523
  @removeItems=${this.handleRemoveItems}
524
524
  @selectAll=${() => this.dataSource.checkAllTiles()}
525
525
  @unselectAll=${() => this.dataSource.uncheckAllTiles()}
526
- @cancel=${() => {
527
- this.isManageView = false;
528
- this.dataSource.uncheckAllTiles();
526
+ @cancel=${() => {
527
+ this.isManageView = false;
528
+ this.dataSource.uncheckAllTiles();
529
529
  }}
530
530
  ></manage-bar>
531
- `;
532
- }
533
- /**
534
- * Handler for when the user requests to remove all checked items via the manage bar.
535
- * Emits an `itemRemovalRequested` event with all checked tile models.
536
- */
537
- handleRemoveItems() {
538
- this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
539
- detail: {
540
- items: this.dataSource.checkedTileModels.map(model => {
541
- const cloned = model.clone();
542
- cloned.dateStr = formatDate(model.datePublished, 'long');
543
- return cloned;
544
- }),
545
- },
546
- }));
547
- }
548
- /**
549
- * Removes all tile models that are currently checked & adjusts the paging
550
- * of the data source to account for any new gaps in the data.
551
- */
552
- removeCheckedTiles() {
553
- this.dataSource.removeCheckedTiles();
554
- }
555
- userChangedSort(e) {
556
- var _a;
557
- const { selectedSort, sortDirection } = e.detail;
558
- this.selectedSort = selectedSort;
559
- this.sortDirection = sortDirection;
560
- if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
561
- this.goToPage(1);
562
- }
563
- this.currentPage = 1;
564
- }
565
- sendSortByAnalytics(prevSortDirection) {
566
- var _a;
567
- const directionCleared = prevSortDirection && !this.sortDirection;
568
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
569
- category: this.searchContext,
570
- action: analyticsActions.sortBy,
571
- label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
572
- });
573
- }
574
- selectedSortChanged() {
575
- // Lazy-load the alphabet counts for title/creator sort bar as needed
576
- this.dataSource.updatePrefixFiltersForCurrentSort();
577
- }
578
- get sortParam() {
579
- var _a;
580
- const sortOption = SORT_OPTIONS[this.selectedSort];
581
- if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
582
- return null;
583
- }
584
- // If the sort option specified in the URL is unrecognized, we just use it as-is
585
- const urlSortParam = new URL(window.location.href).searchParams.get('sort');
586
- const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
587
- // If the sort direction is still null at this point, then we assume ascending
588
- // (i.e., it was unrecognized and had no directional flag)
589
- if (!this.sortDirection)
590
- this.sortDirection = 'asc';
591
- if (!sortField)
592
- return null;
593
- return { field: sortField, direction: this.sortDirection };
594
- }
595
- displayModeChanged(e) {
596
- var _a;
597
- this.displayMode = e.detail.displayMode;
598
- if (this.displayMode) {
599
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
600
- category: this.searchContext,
601
- action: analyticsActions.displayMode,
602
- label: this.displayMode,
603
- });
604
- }
605
- }
606
- /**
607
- * Returns a query clause identifying the currently selected title filter,
608
- * e.g., `firstTitle:X`.
609
- */
610
- get titleQuery() {
611
- return this.selectedTitleFilter
612
- ? `firstTitle:${this.selectedTitleFilter}`
613
- : undefined;
614
- }
615
- /**
616
- * Returns a query clause identifying the currently selected creator filter,
617
- * e.g., `firstCreator:X`.
618
- */
619
- get creatorQuery() {
620
- return this.selectedCreatorFilter
621
- ? `firstCreator:${this.selectedCreatorFilter}`
622
- : undefined;
623
- }
624
- /**
625
- * Send Analytics when sorting by title's first letter
626
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
627
- */
628
- sendFilterByTitleAnalytics(prevSelectedLetter) {
629
- var _a;
630
- if (!prevSelectedLetter && !this.selectedTitleFilter) {
631
- return;
632
- }
633
- const cleared = prevSelectedLetter && !this.selectedTitleFilter;
634
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
635
- category: this.searchContext,
636
- action: analyticsActions.filterByTitle,
637
- label: cleared
638
- ? `clear-${prevSelectedLetter}`
639
- : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
640
- });
641
- }
642
- /**
643
- * Send Analytics when filtering by creator's first letter
644
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
645
- */
646
- sendFilterByCreatorAnalytics(prevSelectedLetter) {
647
- var _a;
648
- if (!prevSelectedLetter && !this.selectedCreatorFilter) {
649
- return;
650
- }
651
- const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
652
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
653
- category: this.searchContext,
654
- action: analyticsActions.filterByCreator,
655
- label: cleared
656
- ? `clear-${prevSelectedLetter}`
657
- : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
658
- });
659
- }
660
- /**
661
- * Handler for changes to which letter is selected in the title alphabet bar.
662
- */
663
- titleLetterSelected(e) {
664
- this.selectedCreatorFilter = null;
665
- this.selectedTitleFilter = e.detail.selectedLetter;
666
- }
667
- /**
668
- * Handler for changes to which letter is selected in the creator alphabet bar.
669
- */
670
- creatorLetterSelected(e) {
671
- this.selectedTitleFilter = null;
672
- this.selectedCreatorFilter = e.detail.selectedLetter;
673
- }
674
- /**
675
- * The full template for how the facets should be structured in mobile view,
676
- * including the collapsible container (with header) and the facets themselves.
677
- */
678
- get mobileFacetsTemplate() {
679
- const toggleFacetsVisible = (e) => {
680
- var _a;
681
- this.isResizeToMobile = false;
682
- this.mobileFacetsVisible = !this.mobileFacetsVisible;
683
- const target = e.target;
684
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
685
- category: this.searchContext,
686
- action: analyticsActions.mobileFacetsToggled,
687
- label: target.open ? 'open' : 'closed',
688
- });
689
- };
531
+ `;
532
+ }
533
+ /**
534
+ * Handler for when the user requests to remove all checked items via the manage bar.
535
+ * Emits an `itemRemovalRequested` event with all checked tile models.
536
+ */
537
+ handleRemoveItems() {
538
+ this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
539
+ detail: {
540
+ items: this.dataSource.checkedTileModels.map(model => {
541
+ const cloned = model.clone();
542
+ cloned.dateStr = formatDate(model.datePublished, 'long');
543
+ return cloned;
544
+ }),
545
+ },
546
+ }));
547
+ }
548
+ /**
549
+ * Removes all tile models that are currently checked & adjusts the paging
550
+ * of the data source to account for any new gaps in the data.
551
+ */
552
+ removeCheckedTiles() {
553
+ this.dataSource.removeCheckedTiles();
554
+ }
555
+ userChangedSort(e) {
556
+ var _a;
557
+ const { selectedSort, sortDirection } = e.detail;
558
+ this.selectedSort = selectedSort;
559
+ this.sortDirection = sortDirection;
560
+ if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
561
+ this.goToPage(1);
562
+ }
563
+ this.currentPage = 1;
564
+ }
565
+ sendSortByAnalytics(prevSortDirection) {
566
+ var _a;
567
+ const directionCleared = prevSortDirection && !this.sortDirection;
568
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
569
+ category: this.searchContext,
570
+ action: analyticsActions.sortBy,
571
+ label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
572
+ });
573
+ }
574
+ selectedSortChanged() {
575
+ // Lazy-load the alphabet counts for title/creator sort bar as needed
576
+ this.dataSource.updatePrefixFiltersForCurrentSort();
577
+ }
578
+ get sortParam() {
579
+ var _a;
580
+ const sortOption = SORT_OPTIONS[this.selectedSort];
581
+ if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
582
+ return null;
583
+ }
584
+ // If the sort option specified in the URL is unrecognized, we just use it as-is
585
+ const urlSortParam = new URL(window.location.href).searchParams.get('sort');
586
+ const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
587
+ // If the sort direction is still null at this point, then we assume ascending
588
+ // (i.e., it was unrecognized and had no directional flag)
589
+ if (!this.sortDirection)
590
+ this.sortDirection = 'asc';
591
+ if (!sortField)
592
+ return null;
593
+ return { field: sortField, direction: this.sortDirection };
594
+ }
595
+ displayModeChanged(e) {
596
+ var _a;
597
+ this.displayMode = e.detail.displayMode;
598
+ if (this.displayMode) {
599
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
600
+ category: this.searchContext,
601
+ action: analyticsActions.displayMode,
602
+ label: this.displayMode,
603
+ });
604
+ }
605
+ }
606
+ /**
607
+ * Returns a query clause identifying the currently selected title filter,
608
+ * e.g., `firstTitle:X`.
609
+ */
610
+ get titleQuery() {
611
+ return this.selectedTitleFilter
612
+ ? `firstTitle:${this.selectedTitleFilter}`
613
+ : undefined;
614
+ }
615
+ /**
616
+ * Returns a query clause identifying the currently selected creator filter,
617
+ * e.g., `firstCreator:X`.
618
+ */
619
+ get creatorQuery() {
620
+ return this.selectedCreatorFilter
621
+ ? `firstCreator:${this.selectedCreatorFilter}`
622
+ : undefined;
623
+ }
624
+ /**
625
+ * Send Analytics when sorting by title's first letter
626
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
627
+ */
628
+ sendFilterByTitleAnalytics(prevSelectedLetter) {
629
+ var _a;
630
+ if (!prevSelectedLetter && !this.selectedTitleFilter) {
631
+ return;
632
+ }
633
+ const cleared = prevSelectedLetter && !this.selectedTitleFilter;
634
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
635
+ category: this.searchContext,
636
+ action: analyticsActions.filterByTitle,
637
+ label: cleared
638
+ ? `clear-${prevSelectedLetter}`
639
+ : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
640
+ });
641
+ }
642
+ /**
643
+ * Send Analytics when filtering by creator's first letter
644
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
645
+ */
646
+ sendFilterByCreatorAnalytics(prevSelectedLetter) {
647
+ var _a;
648
+ if (!prevSelectedLetter && !this.selectedCreatorFilter) {
649
+ return;
650
+ }
651
+ const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
652
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
653
+ category: this.searchContext,
654
+ action: analyticsActions.filterByCreator,
655
+ label: cleared
656
+ ? `clear-${prevSelectedLetter}`
657
+ : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
658
+ });
659
+ }
660
+ /**
661
+ * Handler for changes to which letter is selected in the title alphabet bar.
662
+ */
663
+ titleLetterSelected(e) {
664
+ this.selectedCreatorFilter = null;
665
+ this.selectedTitleFilter = e.detail.selectedLetter;
666
+ }
667
+ /**
668
+ * Handler for changes to which letter is selected in the creator alphabet bar.
669
+ */
670
+ creatorLetterSelected(e) {
671
+ this.selectedTitleFilter = null;
672
+ this.selectedCreatorFilter = e.detail.selectedLetter;
673
+ }
674
+ /**
675
+ * The full template for how the facets should be structured in mobile view,
676
+ * including the collapsible container (with header) and the facets themselves.
677
+ */
678
+ get mobileFacetsTemplate() {
679
+ const toggleFacetsVisible = (e) => {
680
+ var _a;
681
+ this.isResizeToMobile = false;
682
+ this.mobileFacetsVisible = !this.mobileFacetsVisible;
683
+ const target = e.target;
684
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
685
+ category: this.searchContext,
686
+ action: analyticsActions.mobileFacetsToggled,
687
+ label: target.open ? 'open' : 'closed',
688
+ });
689
+ };
690
690
  return html `
691
691
  <details id="mobile-filter-collapse" @toggle=${toggleFacetsVisible}>
692
692
  <summary>
@@ -696,19 +696,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
696
696
  </summary>
697
697
  ${this.facetsTemplate}
698
698
  </details>
699
- `;
700
- }
701
- /**
702
- * The template for the facets component alone, without any surrounding wrappers.
703
- */
704
- get facetsTemplate() {
705
- if (this.suppressFacets) {
699
+ `;
700
+ }
701
+ /**
702
+ * The template for the facets component alone, without any surrounding wrappers.
703
+ */
704
+ get facetsTemplate() {
705
+ if (this.suppressFacets) {
706
706
  return html `
707
707
  <p class="facets-message">
708
708
  ${msg('Facets are temporarily unavailable.')}
709
709
  </p>
710
- `;
711
- }
710
+ `;
711
+ }
712
712
  return html `
713
713
  <collection-facets
714
714
  @facetsChanged=${this.facetsChanged}
@@ -722,7 +722,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
722
722
  .resizeObserver=${this.resizeObserver}
723
723
  .searchType=${this.searchType}
724
724
  .aggregations=${this.dataSource.aggregations}
725
- .fullYearsHistogramAggregation=${this.dataSource
725
+ .fullYearsHistogramAggregation=${this.dataSource
726
726
  .yearHistogramAggregation}
727
727
  .minSelectedDate=${this.minSelectedDate}
728
728
  .maxSelectedDate=${this.maxSelectedDate}
@@ -743,41 +743,41 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
743
743
  .analyticsHandler=${this.analyticsHandler}
744
744
  >
745
745
  </collection-facets>
746
- `;
747
- }
748
- /**
749
- * The HTML template for the "Clear all filters" button, or `nothing` if no
750
- * filters are currently active.
751
- *
752
- * @param mobile Whether to style/shorten the button for mobile view
753
- */
754
- clearFiltersBtnTemplate(mobile) {
755
- if (!this.hasActiveFilters)
756
- return nothing;
757
- const buttonClasses = classMap({
758
- 'clear-filters-btn': true,
759
- mobile,
760
- });
761
- const buttonText = mobile ? 'Clear all' : 'Clear all filters';
746
+ `;
747
+ }
748
+ /**
749
+ * The HTML template for the "Clear all filters" button, or `nothing` if no
750
+ * filters are currently active.
751
+ *
752
+ * @param mobile Whether to style/shorten the button for mobile view
753
+ */
754
+ clearFiltersBtnTemplate(mobile) {
755
+ if (!this.hasActiveFilters)
756
+ return nothing;
757
+ const buttonClasses = classMap({
758
+ 'clear-filters-btn': true,
759
+ mobile,
760
+ });
761
+ const buttonText = mobile ? 'Clear all' : 'Clear all filters';
762
762
  return html `
763
763
  <div class="clear-filters-btn-row">
764
- ${mobile
765
- ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
764
+ ${mobile
765
+ ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
766
766
  : nothing}
767
767
  <button class=${buttonClasses} @click=${this.clearFilters}>
768
768
  ${buttonText}
769
769
  </button>
770
770
  </div>
771
- `;
772
- }
773
- get loadingTemplate() {
771
+ `;
772
+ }
773
+ get loadingTemplate() {
774
774
  return html `
775
775
  <div class="loading-cover">
776
776
  <circular-activity-indicator></circular-activity-indicator>
777
777
  </div>
778
- `;
779
- }
780
- get listHeaderTemplate() {
778
+ `;
779
+ }
780
+ get listHeaderTemplate() {
781
781
  return html `
782
782
  <div id="list-header">
783
783
  <tile-dispatcher
@@ -790,601 +790,601 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
790
790
  >
791
791
  </tile-dispatcher>
792
792
  </div>
793
- `;
794
- }
795
- histogramDateRangeUpdated(e) {
796
- var _a;
797
- const { minDate, maxDate } = e.detail;
798
- [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
799
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
800
- category: this.searchContext,
801
- action: analyticsActions.histogramChanged,
802
- label: this.dateRangeQueryClause,
803
- });
804
- }
805
- get dateRangeQueryClause() {
806
- if (!this.minSelectedDate || !this.maxSelectedDate) {
807
- return undefined;
808
- }
809
- return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
810
- }
811
- /**
812
- * Emits an event indicating a change in whether the manage mode is shown.
813
- */
814
- emitManageModeChangedEvent() {
815
- this.dispatchEvent(new CustomEvent('manageModeChanged', {
816
- detail: this.isManageView,
817
- }));
818
- }
819
- async installDataSourceAndQueryState(dataSource, queryState) {
820
- var _a, _b;
821
- log('Installing data source & query state in CB:', dataSource, queryState);
822
- if (this.dataSource)
823
- this.removeController(this.dataSource);
824
- this.dataSource = dataSource;
825
- this.addController(this.dataSource);
826
- this.baseQuery = queryState.baseQuery;
827
- this.profileElement = queryState.profileElement;
828
- this.searchType = queryState.searchType;
829
- this.selectedFacets =
830
- (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
831
- this.minSelectedDate = queryState.minSelectedDate;
832
- this.maxSelectedDate = queryState.maxSelectedDate;
833
- this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
834
- this.sortDirection = queryState.sortDirection;
835
- this.selectedTitleFilter = queryState.selectedTitleFilter;
836
- this.selectedCreatorFilter = queryState.selectedCreatorFilter;
837
- // We set this flag during the update to prevent the URL state persistence
838
- // from creating an unwanted extra history entry.
839
- this.dataSourceInstallInProgress = true;
840
- this.requestUpdate();
841
- await this.updateComplete;
842
- this.dataSourceInstallInProgress = false;
843
- if (!this.searchResultsLoading) {
844
- this.setTotalResultCount(this.dataSource.totalResults);
845
- this.setTileCount(this.dataSource.size);
846
- }
847
- this.refreshVisibleResults();
848
- }
849
- firstUpdated() {
850
- this.restoreState();
851
- }
852
- updated(changed) {
853
- var _a, _b;
854
- if (changed.has('placeholderType') && this.placeholderType === null) {
855
- if (!this.leftColIntersectionObserver) {
856
- this.setupLeftColumnScrollListeners();
857
- }
858
- if (!this.facetsIntersectionObserver) {
859
- this.setupFacetsScrollListeners();
860
- }
861
- this.updateLeftColumnHeight();
862
- }
863
- if (changed.has('displayMode') ||
864
- changed.has('baseNavigationUrl') ||
865
- changed.has('baseImageUrl') ||
866
- changed.has('loggedIn')) {
867
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
868
- }
869
- if (changed.has('baseQuery') ||
870
- changed.has('searchType') ||
871
- changed.has('withinCollection')) {
872
- // Unless this query/search type update is from the initial page load or the
873
- // result of hitting the back button,
874
- // we need to clear any existing filters since they may no longer be valid for
875
- // the new set of search results.
876
- if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
877
- // Ordinarily, we leave the sort param unchanged between searches.
878
- // However, if we are changing the target collection itself, we want the sort cleared too,
879
- // since different collections may have different sorting options available.
880
- const shouldClearSort = changed.has('withinCollection') &&
881
- !changed.has('selectedSort') &&
882
- !changed.has('sortDirection');
883
- // Otherwise, only clear filters that haven't been simultaneously applied in this update
884
- this.clearFilters({
885
- sort: shouldClearSort,
886
- facets: !changed.has('selectedFacets'),
887
- dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
888
- letterFilters: !(changed.has('selectedTitleFilter') ||
889
- changed.has('selectedCreatorFilter')),
890
- });
891
- }
892
- }
893
- if (changed.has('profileElement')) {
894
- this.applyDefaultProfileSort();
895
- }
896
- if (changed.has('baseQuery')) {
897
- this.emitBaseQueryChanged();
898
- }
899
- if (changed.has('searchType')) {
900
- this.emitSearchTypeChanged();
901
- }
902
- if (changed.has('currentPage') || changed.has('displayMode')) {
903
- this.persistState();
904
- }
905
- if (changed.has('baseQuery') ||
906
- changed.has('minSelectedDate') ||
907
- changed.has('maxSelectedDate') ||
908
- changed.has('selectedFacets') ||
909
- changed.has('searchService') ||
910
- changed.has('withinCollection') ||
911
- changed.has('withinProfile') ||
912
- changed.has('profileElement')) {
913
- this.dataSource.refreshLetterCounts();
914
- }
915
- if (changed.has('selectedSort') || changed.has('sortDirection')) {
916
- const prevSortDirection = changed.get('sortDirection');
917
- this.sendSortByAnalytics(prevSortDirection);
918
- this.selectedSortChanged();
919
- }
920
- if (changed.has('selectedTitleFilter')) {
921
- this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
922
- }
923
- if (changed.has('selectedCreatorFilter')) {
924
- this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
925
- }
926
- if (changed.has('baseQuery') ||
927
- changed.has('searchType') ||
928
- changed.has('selectedTitleFilter') ||
929
- changed.has('selectedCreatorFilter') ||
930
- changed.has('minSelectedDate') ||
931
- changed.has('maxSelectedDate') ||
932
- changed.has('selectedSort') ||
933
- changed.has('sortDirection') ||
934
- changed.has('selectedFacets') ||
935
- changed.has('searchService') ||
936
- changed.has('withinCollection') ||
937
- changed.has('withinProfile') ||
938
- changed.has('profileElement')) {
939
- this.handleQueryChange();
940
- }
941
- if (changed.has('searchResultsLoading')) {
942
- this.emitSearchResultsLoadingChanged();
943
- }
944
- if (changed.has('facetsLoading') &&
945
- this.facetsLoading &&
946
- this.collectionFacets) {
947
- this.collectionFacets.moreLinksVisible =
948
- this.searchType !== SearchType.FULLTEXT;
949
- }
950
- if (changed.has('pagesToRender')) {
951
- if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
952
- this.infiniteScroller.itemCount = this.estimatedTileCount;
953
- }
954
- }
955
- if (changed.has('isManageView')) {
956
- if (this.isManageView)
957
- this.displayMode = 'grid';
958
- (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.refreshAllVisibleCells();
959
- this.emitManageModeChangedEvent();
960
- }
961
- if (changed.has('resizeObserver')) {
962
- const oldObserver = changed.get('resizeObserver');
963
- if (oldObserver)
964
- this.disconnectResizeObserver(oldObserver);
965
- this.setupResizeObserver();
966
- }
967
- }
968
- connectedCallback() {
969
- var _a;
970
- (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
971
- this.setupStateRestorationObserver();
972
- this.setupResizeObserver();
973
- }
974
- disconnectedCallback() {
975
- var _a, _b;
976
- if (this.resizeObserver) {
977
- this.disconnectResizeObserver(this.resizeObserver);
978
- }
979
- if (this.boundNavigationHandler) {
980
- window.removeEventListener('popstate', this.boundNavigationHandler);
981
- }
982
- (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
983
- (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
984
- window.removeEventListener('resize', this.updateLeftColumnHeight);
985
- }
986
- handleResize(entry) {
987
- const previousView = this.mobileView;
988
- if (entry.target === this.contentContainer) {
989
- this.contentWidth = entry.contentRect.width;
990
- this.mobileView =
991
- this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
992
- // If changing from desktop to mobile disable transition
993
- if (this.mobileView && !previousView) {
994
- this.isResizeToMobile = true;
995
- }
996
- }
997
- // Ensure the facet sidebar remains sized correctly
998
- this.updateLeftColumnHeight();
999
- }
1000
- /**
1001
- * Sets up listeners for events that may require updating the left column height.
1002
- */
1003
- setupLeftColumnScrollListeners() {
1004
- var _a;
1005
- // We observe intersections between the left column's scroll sentinel and
1006
- // the viewport, so that we can ensure the left column is always sized to
1007
- // match the _available_ viewport height. This should generally be more
1008
- // performant than listening to scroll events on the page or column.
1009
- const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1010
- if (leftColumnSentinel) {
1011
- this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1012
- threshold: [...Array(101).keys()].map(n => n / 100), // Threshold every 1%
1013
- });
1014
- this.leftColIntersectionObserver.observe(leftColumnSentinel);
1015
- }
1016
- // We also listen for window resize events, as they are not always captured
1017
- // by the resize observer and can affect the desired height of the left column.
1018
- window.addEventListener('resize', this.updateLeftColumnHeight);
1019
- }
1020
- /**
1021
- * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1022
- * Note this uses a separate IntersectionObserver from the left column, because we
1023
- * don't need granular intersection thresholds for this.
1024
- */
1025
- setupFacetsScrollListeners() {
1026
- var _a;
1027
- const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1028
- if (facetsSentinel) {
1029
- this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1030
- this.facetsIntersectionObserver.observe(facetsSentinel);
1031
- }
1032
- }
1033
- emitBaseQueryChanged() {
1034
- this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1035
- detail: {
1036
- baseQuery: this.baseQuery,
1037
- },
1038
- }));
1039
- }
1040
- emitSearchTypeChanged() {
1041
- this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1042
- detail: this.searchType,
1043
- }));
1044
- }
1045
- emitQueryStateChanged() {
1046
- this.dispatchEvent(new CustomEvent('queryStateChanged', {
1047
- detail: {
1048
- baseQuery: this.baseQuery,
1049
- withinCollection: this.withinCollection,
1050
- withinProfile: this.withinProfile,
1051
- profileElement: this.profileElement,
1052
- searchType: this.searchType,
1053
- selectedFacets: this.selectedFacets,
1054
- minSelectedDate: this.minSelectedDate,
1055
- maxSelectedDate: this.maxSelectedDate,
1056
- selectedSort: this.selectedSort,
1057
- sortDirection: this.sortDirection,
1058
- selectedTitleFilter: this.selectedTitleFilter,
1059
- selectedCreatorFilter: this.selectedCreatorFilter,
1060
- },
1061
- }));
1062
- }
1063
- emitEmptyResults() {
1064
- this.dispatchEvent(new Event('emptyResults'));
1065
- }
1066
- disconnectResizeObserver(resizeObserver) {
1067
- resizeObserver.removeObserver({
1068
- target: this.contentContainer,
1069
- handler: this,
1070
- });
1071
- }
1072
- setupResizeObserver() {
1073
- if (!this.resizeObserver || !this.contentContainer)
1074
- return;
1075
- this.resizeObserver.addObserver({
1076
- target: this.contentContainer,
1077
- handler: this,
1078
- });
1079
- }
1080
- /**
1081
- * When the visible cells change from the infinite scroller, we want to emit
1082
- * which page is currently visible so the consumer can update its UI or the URL
1083
- *
1084
- * @param e
1085
- * @returns
1086
- */
1087
- visibleCellsChanged(e) {
1088
- if (this.isScrollingToCell)
1089
- return;
1090
- const { visibleCellIndices } = e.detail;
1091
- if (visibleCellIndices.length === 0)
1092
- return;
1093
- const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
1094
- const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1095
- if (this.currentPage !== lastVisibleCellPage) {
1096
- this.currentPage = lastVisibleCellPage;
1097
- }
1098
- const event = new CustomEvent('visiblePageChanged', {
1099
- detail: {
1100
- pageNumber: lastVisibleCellPage,
1101
- },
1102
- });
1103
- this.dispatchEvent(event);
1104
- }
1105
- /**
1106
- * A Promise which, after each query change, resolves once the fetches for the initial
1107
- * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1108
- *
1109
- * Ensure you await this component's `updateComplete` promise before awaiting this
1110
- * one, to ensure you do not await an obsolete promise from the previous update.
1111
- */
1112
- get initialSearchComplete() {
1113
- return this.dataSource.initialSearchComplete;
1114
- }
1115
- async handleQueryChange() {
1116
- var _a;
1117
- // only reset if the query has actually changed
1118
- if (!this.searchService ||
1119
- this.dataSource.pageFetchQueryKey === this.previousQueryKey)
1120
- return;
1121
- // If the new state prevents us from updating the search results, don't reset
1122
- if (!this.dataSource.canPerformSearch &&
1123
- !(this.clearResultsOnEmptyQuery && this.baseQuery === ''))
1124
- return;
1125
- this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1126
- // this.emitQueryStateChanged();
1127
- this.tileModelOffset = 0;
1128
- this.totalResults = undefined;
1129
- this.pagesToRender =
1130
- this.initialPageNumber === 1
1131
- ? 2 // First two pages are batched into one request when starting from page 1
1132
- : this.initialPageNumber;
1133
- // Reset the infinite scroller's item count, so that it
1134
- // shows tile placeholders until the new query's results load in
1135
- if (this.infiniteScroller) {
1136
- this.infiniteScroller.itemCount = this.estimatedTileCount;
1137
- this.infiniteScroller.reload();
1138
- }
1139
- if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1140
- this.defaultSortField = SortField.relevance;
1141
- this.defaultSortDirection = null;
1142
- }
1143
- if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1144
- this.scrollToPage(this.initialPageNumber);
1145
- }
1146
- this.initialQueryChangeHappened = true;
1147
- // if the query changed as part of a window.history pop event, we don't want to
1148
- // persist the state because it overwrites the forward history
1149
- if (!this.historyPopOccurred) {
1150
- this.persistState();
1151
- }
1152
- this.historyPopOccurred = false;
1153
- // Fire the initial page and facets requests
1154
- // await this.dataSource.handleQueryChange();
1155
- }
1156
- setupStateRestorationObserver() {
1157
- if (!this.boundNavigationHandler) {
1158
- this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1159
- }
1160
- // when the user navigates back, we want to update the UI to match the URL
1161
- window.addEventListener('popstate', this.boundNavigationHandler);
1162
- }
1163
- historyNavigationHandler() {
1164
- this.historyPopOccurred = true;
1165
- this.restoreState();
1166
- }
1167
- restoreState() {
1168
- var _a, _b, _c, _d, _e;
1169
- const restorationState = this.restorationStateHandler.getRestorationState();
1170
- this.displayMode = restorationState.displayMode;
1171
- if (restorationState.searchType != null)
1172
- this.searchType = restorationState.searchType;
1173
- this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1174
- this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1175
- this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1176
- this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1177
- this.selectedFacets = restorationState.selectedFacets;
1178
- if (!this.suppressURLQuery)
1179
- this.baseQuery = restorationState.baseQuery;
1180
- this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1181
- this.minSelectedDate = restorationState.minSelectedDate;
1182
- this.maxSelectedDate = restorationState.maxSelectedDate;
1183
- if (this.currentPage > 1) {
1184
- this.goToPage(this.currentPage);
1185
- }
1186
- }
1187
- persistState() {
1188
- var _a, _b, _c, _d;
1189
- const restorationState = {
1190
- displayMode: this.displayMode,
1191
- searchType: this.searchType,
1192
- selectedSort: this.selectedSort,
1193
- sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1194
- selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1195
- baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1196
- currentPage: this.currentPage,
1197
- titleQuery: this.titleQuery,
1198
- creatorQuery: this.creatorQuery,
1199
- minSelectedDate: this.minSelectedDate,
1200
- maxSelectedDate: this.maxSelectedDate,
1201
- selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1202
- selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1203
- };
1204
- this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1205
- }
1206
- emitSearchResultsLoadingChanged() {
1207
- this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1208
- detail: {
1209
- loading: this.searchResultsLoading,
1210
- },
1211
- }));
1212
- }
1213
- facetsChanged(e) {
1214
- this.selectedFacets = e.detail;
1215
- }
1216
- facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1217
- var _a;
1218
- let action;
1219
- if (negative) {
1220
- action =
1221
- bucket.state !== 'none'
1222
- ? analyticsActions.facetNegativeSelected
1223
- : analyticsActions.facetNegativeDeselected;
1224
- }
1225
- else {
1226
- action =
1227
- bucket.state !== 'none'
1228
- ? analyticsActions.facetSelected
1229
- : analyticsActions.facetDeselected;
1230
- }
1231
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1232
- category: this.searchContext,
1233
- action,
1234
- label: facetType,
1235
- });
1236
- }
1237
- scrollToPage(pageNumber) {
1238
- return new Promise(resolve => {
1239
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1240
- // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1241
- // then scrolls to the cell
1242
- setTimeout(() => {
1243
- var _a;
1244
- this.isScrollingToCell = true;
1245
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1246
- // This timeout is to give the scroll animation time to finish
1247
- // then updating the infinite scroller once we're done scrolling
1248
- // There's no scroll animation completion callback so we're
1249
- // giving it 0.5s to finish.
1250
- setTimeout(() => {
1251
- var _a;
1252
- this.isScrollingToCell = false;
1253
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1254
- resolve();
1255
- }, 500);
1256
- }, 0);
1257
- });
1258
- }
1259
- /**
1260
- * Whether sorting by relevance makes sense for the current state.
1261
- * Currently equivalent to having a non-empty query.
1262
- */
1263
- get isRelevanceSortAvailable() {
1264
- var _a;
1265
- return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1266
- }
1267
- /**
1268
- * Sets the total number of tiles displayed in the infinite scroller.
1269
- */
1270
- setTileCount(count) {
1271
- if (this.infiniteScroller) {
1272
- this.infiniteScroller.itemCount = count;
1273
- }
1274
- }
1275
- /**
1276
- * Applies any default sort option for the current collection, by checking
1277
- * for one in the collection's metadata. If none is found, defaults to sorting
1278
- * descending by:
1279
- * - Date Favorited for fav-* collections
1280
- * - Weekly views for all other collections
1281
- */
1282
- applyDefaultCollectionSort(collectionInfo) {
1283
- var _a, _b, _c;
1284
- if (this.baseQuery) {
1285
- // If there's a query set, then we default to relevance sorting regardless of
1286
- // the collection metadata-specified sort.
1287
- this.defaultSortField = SortField.relevance;
1288
- this.defaultSortDirection = null;
1289
- return;
1290
- }
1291
- // Favorite collections sort on Date Favorited by default.
1292
- // Other collections fall back to sorting on weekly views.
1293
- const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
1294
- ? '-favoritedate'
1295
- : '-week';
1296
- // The collection metadata may override the default sorting with something else
1297
- const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1298
- // Prefer the metadata-specified sort if one exists
1299
- const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1300
- // Account for both -field and field:dir formats
1301
- let [field, dir] = defaultSortToApply.split(':');
1302
- if (field.startsWith('-')) {
1303
- field = field.slice(1);
1304
- dir = 'desc';
1305
- }
1306
- else if (!['asc', 'desc'].includes(dir)) {
1307
- dir = 'asc';
1308
- }
1309
- const sortOption = sortOptionFromAPIString(field);
1310
- const sortField = sortOption.field;
1311
- if (sortField && sortField !== SortField.default) {
1312
- this.defaultSortField = sortField;
1313
- this.defaultSortDirection = dir;
1314
- this.defaultSortParam = {
1315
- field: this.defaultSortField,
1316
- direction: this.defaultSortDirection,
1317
- };
1318
- }
1319
- }
1320
- /**
1321
- * Applies the default sort option for the current profile element
1322
- */
1323
- applyDefaultProfileSort() {
1324
- if (this.profileElement) {
1325
- const defaultSortField = defaultProfileElementSorts[this.profileElement];
1326
- this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1327
- }
1328
- else {
1329
- this.defaultSortField = SortField.weeklyview;
1330
- }
1331
- this.defaultSortDirection = 'desc';
1332
- this.defaultSortParam = {
1333
- field: this.defaultSortField,
1334
- direction: this.defaultSortDirection,
1335
- };
1336
- }
1337
- /**
1338
- * This is useful for determining whether we need to reload the scroller.
1339
- *
1340
- * When the fetch completes, we need to reload the scroller if the cells for that
1341
- * page are visible, but if the page is not currenlty visible, we don't need to reload
1342
- */
1343
- get currentVisiblePageNumbers() {
1344
- var _a, _b;
1345
- const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1346
- const visiblePages = new Set();
1347
- visibleCells.forEach(cellIndex => {
1348
- const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1349
- visiblePages.add(visiblePage);
1350
- });
1351
- return Array.from(visiblePages);
1352
- }
1353
- /**
1354
- * Refreshes all visible result cells in the infinite scroller.
1355
- */
1356
- refreshVisibleResults() {
1357
- var _a;
1358
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1359
- }
1360
- /**
1361
- * Callback when a result is selected
1362
- */
1363
- resultSelected(event) {
1364
- var _a, _b, _c;
1365
- if (this.isManageView) {
1366
- // Checked/unchecked state change -- rerender to ensure it propagates
1367
- // this.mapDataSource(model => ({ ...model }));
1368
- const cellIndex = this.dataSource.indexOf(event.detail);
1369
- if (cellIndex >= 0)
1370
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1371
- this.requestUpdate();
1372
- }
1373
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1374
- category: this.searchContext,
1375
- action: analyticsActions.resultSelected,
1376
- label: event.detail.mediatype,
1377
- });
1378
- (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1379
- category: this.searchContext,
1380
- action: analyticsActions.resultSelected,
1381
- label: `page-${this.currentPage}`,
1382
- });
1383
- }
1384
- cellForIndex(index) {
1385
- const model = this.tileModelAtCellIndex(index);
1386
- if (!model)
1387
- return undefined;
793
+ `;
794
+ }
795
+ histogramDateRangeUpdated(e) {
796
+ var _a;
797
+ const { minDate, maxDate } = e.detail;
798
+ [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
799
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
800
+ category: this.searchContext,
801
+ action: analyticsActions.histogramChanged,
802
+ label: this.dateRangeQueryClause,
803
+ });
804
+ }
805
+ get dateRangeQueryClause() {
806
+ if (!this.minSelectedDate || !this.maxSelectedDate) {
807
+ return undefined;
808
+ }
809
+ return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
810
+ }
811
+ /**
812
+ * Emits an event indicating a change in whether the manage mode is shown.
813
+ */
814
+ emitManageModeChangedEvent() {
815
+ this.dispatchEvent(new CustomEvent('manageModeChanged', {
816
+ detail: this.isManageView,
817
+ }));
818
+ }
819
+ async installDataSourceAndQueryState(dataSource, queryState) {
820
+ var _a, _b;
821
+ log('Installing data source & query state in CB:', dataSource, queryState);
822
+ if (this.dataSource)
823
+ this.removeController(this.dataSource);
824
+ this.dataSource = dataSource;
825
+ this.addController(this.dataSource);
826
+ this.baseQuery = queryState.baseQuery;
827
+ this.profileElement = queryState.profileElement;
828
+ this.searchType = queryState.searchType;
829
+ this.selectedFacets =
830
+ (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
831
+ this.minSelectedDate = queryState.minSelectedDate;
832
+ this.maxSelectedDate = queryState.maxSelectedDate;
833
+ this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
834
+ this.sortDirection = queryState.sortDirection;
835
+ this.selectedTitleFilter = queryState.selectedTitleFilter;
836
+ this.selectedCreatorFilter = queryState.selectedCreatorFilter;
837
+ // We set this flag during the update to prevent the URL state persistence
838
+ // from creating an unwanted extra history entry.
839
+ this.dataSourceInstallInProgress = true;
840
+ this.requestUpdate();
841
+ await this.updateComplete;
842
+ this.dataSourceInstallInProgress = false;
843
+ if (!this.searchResultsLoading) {
844
+ this.setTotalResultCount(this.dataSource.totalResults);
845
+ this.setTileCount(this.dataSource.size);
846
+ }
847
+ this.refreshVisibleResults();
848
+ }
849
+ firstUpdated() {
850
+ this.restoreState();
851
+ }
852
+ updated(changed) {
853
+ var _a, _b;
854
+ if (changed.has('placeholderType') && this.placeholderType === null) {
855
+ if (!this.leftColIntersectionObserver) {
856
+ this.setupLeftColumnScrollListeners();
857
+ }
858
+ if (!this.facetsIntersectionObserver) {
859
+ this.setupFacetsScrollListeners();
860
+ }
861
+ this.updateLeftColumnHeight();
862
+ }
863
+ if (changed.has('displayMode') ||
864
+ changed.has('baseNavigationUrl') ||
865
+ changed.has('baseImageUrl') ||
866
+ changed.has('loggedIn')) {
867
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
868
+ }
869
+ if (changed.has('baseQuery') ||
870
+ changed.has('searchType') ||
871
+ changed.has('withinCollection')) {
872
+ // Unless this query/search type update is from the initial page load or the
873
+ // result of hitting the back button,
874
+ // we need to clear any existing filters since they may no longer be valid for
875
+ // the new set of search results.
876
+ if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
877
+ // Ordinarily, we leave the sort param unchanged between searches.
878
+ // However, if we are changing the target collection itself, we want the sort cleared too,
879
+ // since different collections may have different sorting options available.
880
+ const shouldClearSort = changed.has('withinCollection') &&
881
+ !changed.has('selectedSort') &&
882
+ !changed.has('sortDirection');
883
+ // Otherwise, only clear filters that haven't been simultaneously applied in this update
884
+ this.clearFilters({
885
+ sort: shouldClearSort,
886
+ facets: !changed.has('selectedFacets'),
887
+ dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
888
+ letterFilters: !(changed.has('selectedTitleFilter') ||
889
+ changed.has('selectedCreatorFilter')),
890
+ });
891
+ }
892
+ }
893
+ if (changed.has('profileElement')) {
894
+ this.applyDefaultProfileSort();
895
+ }
896
+ if (changed.has('baseQuery')) {
897
+ this.emitBaseQueryChanged();
898
+ }
899
+ if (changed.has('searchType')) {
900
+ this.emitSearchTypeChanged();
901
+ }
902
+ if (changed.has('currentPage') || changed.has('displayMode')) {
903
+ this.persistState();
904
+ }
905
+ if (changed.has('baseQuery') ||
906
+ changed.has('minSelectedDate') ||
907
+ changed.has('maxSelectedDate') ||
908
+ changed.has('selectedFacets') ||
909
+ changed.has('searchService') ||
910
+ changed.has('withinCollection') ||
911
+ changed.has('withinProfile') ||
912
+ changed.has('profileElement')) {
913
+ this.dataSource.refreshLetterCounts();
914
+ }
915
+ if (changed.has('selectedSort') || changed.has('sortDirection')) {
916
+ const prevSortDirection = changed.get('sortDirection');
917
+ this.sendSortByAnalytics(prevSortDirection);
918
+ this.selectedSortChanged();
919
+ }
920
+ if (changed.has('selectedTitleFilter')) {
921
+ this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
922
+ }
923
+ if (changed.has('selectedCreatorFilter')) {
924
+ this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
925
+ }
926
+ if (changed.has('baseQuery') ||
927
+ changed.has('searchType') ||
928
+ changed.has('selectedTitleFilter') ||
929
+ changed.has('selectedCreatorFilter') ||
930
+ changed.has('minSelectedDate') ||
931
+ changed.has('maxSelectedDate') ||
932
+ changed.has('selectedSort') ||
933
+ changed.has('sortDirection') ||
934
+ changed.has('selectedFacets') ||
935
+ changed.has('searchService') ||
936
+ changed.has('withinCollection') ||
937
+ changed.has('withinProfile') ||
938
+ changed.has('profileElement')) {
939
+ this.handleQueryChange();
940
+ }
941
+ if (changed.has('searchResultsLoading')) {
942
+ this.emitSearchResultsLoadingChanged();
943
+ }
944
+ if (changed.has('facetsLoading') &&
945
+ this.facetsLoading &&
946
+ this.collectionFacets) {
947
+ this.collectionFacets.moreLinksVisible =
948
+ this.searchType !== SearchType.FULLTEXT;
949
+ }
950
+ if (changed.has('pagesToRender')) {
951
+ if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
952
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
953
+ }
954
+ }
955
+ if (changed.has('isManageView')) {
956
+ if (this.isManageView)
957
+ this.displayMode = 'grid';
958
+ (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.refreshAllVisibleCells();
959
+ this.emitManageModeChangedEvent();
960
+ }
961
+ if (changed.has('resizeObserver')) {
962
+ const oldObserver = changed.get('resizeObserver');
963
+ if (oldObserver)
964
+ this.disconnectResizeObserver(oldObserver);
965
+ this.setupResizeObserver();
966
+ }
967
+ }
968
+ connectedCallback() {
969
+ var _a;
970
+ (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
971
+ this.setupStateRestorationObserver();
972
+ this.setupResizeObserver();
973
+ }
974
+ disconnectedCallback() {
975
+ var _a, _b;
976
+ if (this.resizeObserver) {
977
+ this.disconnectResizeObserver(this.resizeObserver);
978
+ }
979
+ if (this.boundNavigationHandler) {
980
+ window.removeEventListener('popstate', this.boundNavigationHandler);
981
+ }
982
+ (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
983
+ (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
984
+ window.removeEventListener('resize', this.updateLeftColumnHeight);
985
+ }
986
+ handleResize(entry) {
987
+ const previousView = this.mobileView;
988
+ if (entry.target === this.contentContainer) {
989
+ this.contentWidth = entry.contentRect.width;
990
+ this.mobileView =
991
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
992
+ // If changing from desktop to mobile disable transition
993
+ if (this.mobileView && !previousView) {
994
+ this.isResizeToMobile = true;
995
+ }
996
+ }
997
+ // Ensure the facet sidebar remains sized correctly
998
+ this.updateLeftColumnHeight();
999
+ }
1000
+ /**
1001
+ * Sets up listeners for events that may require updating the left column height.
1002
+ */
1003
+ setupLeftColumnScrollListeners() {
1004
+ var _a;
1005
+ // We observe intersections between the left column's scroll sentinel and
1006
+ // the viewport, so that we can ensure the left column is always sized to
1007
+ // match the _available_ viewport height. This should generally be more
1008
+ // performant than listening to scroll events on the page or column.
1009
+ const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1010
+ if (leftColumnSentinel) {
1011
+ this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1012
+ threshold: [...Array(101).keys()].map(n => n / 100), // Threshold every 1%
1013
+ });
1014
+ this.leftColIntersectionObserver.observe(leftColumnSentinel);
1015
+ }
1016
+ // We also listen for window resize events, as they are not always captured
1017
+ // by the resize observer and can affect the desired height of the left column.
1018
+ window.addEventListener('resize', this.updateLeftColumnHeight);
1019
+ }
1020
+ /**
1021
+ * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1022
+ * Note this uses a separate IntersectionObserver from the left column, because we
1023
+ * don't need granular intersection thresholds for this.
1024
+ */
1025
+ setupFacetsScrollListeners() {
1026
+ var _a;
1027
+ const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1028
+ if (facetsSentinel) {
1029
+ this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1030
+ this.facetsIntersectionObserver.observe(facetsSentinel);
1031
+ }
1032
+ }
1033
+ emitBaseQueryChanged() {
1034
+ this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1035
+ detail: {
1036
+ baseQuery: this.baseQuery,
1037
+ },
1038
+ }));
1039
+ }
1040
+ emitSearchTypeChanged() {
1041
+ this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1042
+ detail: this.searchType,
1043
+ }));
1044
+ }
1045
+ emitQueryStateChanged() {
1046
+ this.dispatchEvent(new CustomEvent('queryStateChanged', {
1047
+ detail: {
1048
+ baseQuery: this.baseQuery,
1049
+ withinCollection: this.withinCollection,
1050
+ withinProfile: this.withinProfile,
1051
+ profileElement: this.profileElement,
1052
+ searchType: this.searchType,
1053
+ selectedFacets: this.selectedFacets,
1054
+ minSelectedDate: this.minSelectedDate,
1055
+ maxSelectedDate: this.maxSelectedDate,
1056
+ selectedSort: this.selectedSort,
1057
+ sortDirection: this.sortDirection,
1058
+ selectedTitleFilter: this.selectedTitleFilter,
1059
+ selectedCreatorFilter: this.selectedCreatorFilter,
1060
+ },
1061
+ }));
1062
+ }
1063
+ emitEmptyResults() {
1064
+ this.dispatchEvent(new Event('emptyResults'));
1065
+ }
1066
+ disconnectResizeObserver(resizeObserver) {
1067
+ resizeObserver.removeObserver({
1068
+ target: this.contentContainer,
1069
+ handler: this,
1070
+ });
1071
+ }
1072
+ setupResizeObserver() {
1073
+ if (!this.resizeObserver || !this.contentContainer)
1074
+ return;
1075
+ this.resizeObserver.addObserver({
1076
+ target: this.contentContainer,
1077
+ handler: this,
1078
+ });
1079
+ }
1080
+ /**
1081
+ * When the visible cells change from the infinite scroller, we want to emit
1082
+ * which page is currently visible so the consumer can update its UI or the URL
1083
+ *
1084
+ * @param e
1085
+ * @returns
1086
+ */
1087
+ visibleCellsChanged(e) {
1088
+ if (this.isScrollingToCell)
1089
+ return;
1090
+ const { visibleCellIndices } = e.detail;
1091
+ if (visibleCellIndices.length === 0)
1092
+ return;
1093
+ const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
1094
+ const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1095
+ if (this.currentPage !== lastVisibleCellPage) {
1096
+ this.currentPage = lastVisibleCellPage;
1097
+ }
1098
+ const event = new CustomEvent('visiblePageChanged', {
1099
+ detail: {
1100
+ pageNumber: lastVisibleCellPage,
1101
+ },
1102
+ });
1103
+ this.dispatchEvent(event);
1104
+ }
1105
+ /**
1106
+ * A Promise which, after each query change, resolves once the fetches for the initial
1107
+ * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1108
+ *
1109
+ * Ensure you await this component's `updateComplete` promise before awaiting this
1110
+ * one, to ensure you do not await an obsolete promise from the previous update.
1111
+ */
1112
+ get initialSearchComplete() {
1113
+ return this.dataSource.initialSearchComplete;
1114
+ }
1115
+ async handleQueryChange() {
1116
+ var _a;
1117
+ // only reset if the query has actually changed
1118
+ if (!this.searchService ||
1119
+ this.dataSource.pageFetchQueryKey === this.previousQueryKey)
1120
+ return;
1121
+ // If the new state prevents us from updating the search results, don't reset
1122
+ if (!this.dataSource.canPerformSearch &&
1123
+ !(this.clearResultsOnEmptyQuery && this.baseQuery === ''))
1124
+ return;
1125
+ this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1126
+ // this.emitQueryStateChanged();
1127
+ this.tileModelOffset = 0;
1128
+ this.totalResults = undefined;
1129
+ this.pagesToRender =
1130
+ this.initialPageNumber === 1
1131
+ ? 2 // First two pages are batched into one request when starting from page 1
1132
+ : this.initialPageNumber;
1133
+ // Reset the infinite scroller's item count, so that it
1134
+ // shows tile placeholders until the new query's results load in
1135
+ if (this.infiniteScroller) {
1136
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1137
+ this.infiniteScroller.reload();
1138
+ }
1139
+ if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1140
+ this.defaultSortField = SortField.relevance;
1141
+ this.defaultSortDirection = null;
1142
+ }
1143
+ if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1144
+ this.scrollToPage(this.initialPageNumber);
1145
+ }
1146
+ this.initialQueryChangeHappened = true;
1147
+ // if the query changed as part of a window.history pop event, we don't want to
1148
+ // persist the state because it overwrites the forward history
1149
+ if (!this.historyPopOccurred) {
1150
+ this.persistState();
1151
+ }
1152
+ this.historyPopOccurred = false;
1153
+ // Fire the initial page and facets requests
1154
+ // await this.dataSource.handleQueryChange();
1155
+ }
1156
+ setupStateRestorationObserver() {
1157
+ if (!this.boundNavigationHandler) {
1158
+ this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1159
+ }
1160
+ // when the user navigates back, we want to update the UI to match the URL
1161
+ window.addEventListener('popstate', this.boundNavigationHandler);
1162
+ }
1163
+ historyNavigationHandler() {
1164
+ this.historyPopOccurred = true;
1165
+ this.restoreState();
1166
+ }
1167
+ restoreState() {
1168
+ var _a, _b, _c, _d, _e;
1169
+ const restorationState = this.restorationStateHandler.getRestorationState();
1170
+ this.displayMode = restorationState.displayMode;
1171
+ if (restorationState.searchType != null)
1172
+ this.searchType = restorationState.searchType;
1173
+ this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1174
+ this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1175
+ this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1176
+ this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1177
+ this.selectedFacets = restorationState.selectedFacets;
1178
+ if (!this.suppressURLQuery)
1179
+ this.baseQuery = restorationState.baseQuery;
1180
+ this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1181
+ this.minSelectedDate = restorationState.minSelectedDate;
1182
+ this.maxSelectedDate = restorationState.maxSelectedDate;
1183
+ if (this.currentPage > 1) {
1184
+ this.goToPage(this.currentPage);
1185
+ }
1186
+ }
1187
+ persistState() {
1188
+ var _a, _b, _c, _d;
1189
+ const restorationState = {
1190
+ displayMode: this.displayMode,
1191
+ searchType: this.searchType,
1192
+ selectedSort: this.selectedSort,
1193
+ sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1194
+ selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1195
+ baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1196
+ currentPage: this.currentPage,
1197
+ titleQuery: this.titleQuery,
1198
+ creatorQuery: this.creatorQuery,
1199
+ minSelectedDate: this.minSelectedDate,
1200
+ maxSelectedDate: this.maxSelectedDate,
1201
+ selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1202
+ selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1203
+ };
1204
+ this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1205
+ }
1206
+ emitSearchResultsLoadingChanged() {
1207
+ this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1208
+ detail: {
1209
+ loading: this.searchResultsLoading,
1210
+ },
1211
+ }));
1212
+ }
1213
+ facetsChanged(e) {
1214
+ this.selectedFacets = e.detail;
1215
+ }
1216
+ facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1217
+ var _a;
1218
+ let action;
1219
+ if (negative) {
1220
+ action =
1221
+ bucket.state !== 'none'
1222
+ ? analyticsActions.facetNegativeSelected
1223
+ : analyticsActions.facetNegativeDeselected;
1224
+ }
1225
+ else {
1226
+ action =
1227
+ bucket.state !== 'none'
1228
+ ? analyticsActions.facetSelected
1229
+ : analyticsActions.facetDeselected;
1230
+ }
1231
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1232
+ category: this.searchContext,
1233
+ action,
1234
+ label: facetType,
1235
+ });
1236
+ }
1237
+ scrollToPage(pageNumber) {
1238
+ return new Promise(resolve => {
1239
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1240
+ // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1241
+ // then scrolls to the cell
1242
+ setTimeout(() => {
1243
+ var _a;
1244
+ this.isScrollingToCell = true;
1245
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1246
+ // This timeout is to give the scroll animation time to finish
1247
+ // then updating the infinite scroller once we're done scrolling
1248
+ // There's no scroll animation completion callback so we're
1249
+ // giving it 0.5s to finish.
1250
+ setTimeout(() => {
1251
+ var _a;
1252
+ this.isScrollingToCell = false;
1253
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1254
+ resolve();
1255
+ }, 500);
1256
+ }, 0);
1257
+ });
1258
+ }
1259
+ /**
1260
+ * Whether sorting by relevance makes sense for the current state.
1261
+ * Currently equivalent to having a non-empty query.
1262
+ */
1263
+ get isRelevanceSortAvailable() {
1264
+ var _a;
1265
+ return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1266
+ }
1267
+ /**
1268
+ * Sets the total number of tiles displayed in the infinite scroller.
1269
+ */
1270
+ setTileCount(count) {
1271
+ if (this.infiniteScroller) {
1272
+ this.infiniteScroller.itemCount = count;
1273
+ }
1274
+ }
1275
+ /**
1276
+ * Applies any default sort option for the current collection, by checking
1277
+ * for one in the collection's metadata. If none is found, defaults to sorting
1278
+ * descending by:
1279
+ * - Date Favorited for fav-* collections
1280
+ * - Weekly views for all other collections
1281
+ */
1282
+ applyDefaultCollectionSort(collectionInfo) {
1283
+ var _a, _b, _c;
1284
+ if (this.baseQuery) {
1285
+ // If there's a query set, then we default to relevance sorting regardless of
1286
+ // the collection metadata-specified sort.
1287
+ this.defaultSortField = SortField.relevance;
1288
+ this.defaultSortDirection = null;
1289
+ return;
1290
+ }
1291
+ // Favorite collections sort on Date Favorited by default.
1292
+ // Other collections fall back to sorting on weekly views.
1293
+ const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
1294
+ ? '-favoritedate'
1295
+ : '-week';
1296
+ // The collection metadata may override the default sorting with something else
1297
+ const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1298
+ // Prefer the metadata-specified sort if one exists
1299
+ const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1300
+ // Account for both -field and field:dir formats
1301
+ let [field, dir] = defaultSortToApply.split(':');
1302
+ if (field.startsWith('-')) {
1303
+ field = field.slice(1);
1304
+ dir = 'desc';
1305
+ }
1306
+ else if (!['asc', 'desc'].includes(dir)) {
1307
+ dir = 'asc';
1308
+ }
1309
+ const sortOption = sortOptionFromAPIString(field);
1310
+ const sortField = sortOption.field;
1311
+ if (sortField && sortField !== SortField.default) {
1312
+ this.defaultSortField = sortField;
1313
+ this.defaultSortDirection = dir;
1314
+ this.defaultSortParam = {
1315
+ field: this.defaultSortField,
1316
+ direction: this.defaultSortDirection,
1317
+ };
1318
+ }
1319
+ }
1320
+ /**
1321
+ * Applies the default sort option for the current profile element
1322
+ */
1323
+ applyDefaultProfileSort() {
1324
+ if (this.profileElement) {
1325
+ const defaultSortField = defaultProfileElementSorts[this.profileElement];
1326
+ this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1327
+ }
1328
+ else {
1329
+ this.defaultSortField = SortField.weeklyview;
1330
+ }
1331
+ this.defaultSortDirection = 'desc';
1332
+ this.defaultSortParam = {
1333
+ field: this.defaultSortField,
1334
+ direction: this.defaultSortDirection,
1335
+ };
1336
+ }
1337
+ /**
1338
+ * This is useful for determining whether we need to reload the scroller.
1339
+ *
1340
+ * When the fetch completes, we need to reload the scroller if the cells for that
1341
+ * page are visible, but if the page is not currenlty visible, we don't need to reload
1342
+ */
1343
+ get currentVisiblePageNumbers() {
1344
+ var _a, _b;
1345
+ const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1346
+ const visiblePages = new Set();
1347
+ visibleCells.forEach(cellIndex => {
1348
+ const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1349
+ visiblePages.add(visiblePage);
1350
+ });
1351
+ return Array.from(visiblePages);
1352
+ }
1353
+ /**
1354
+ * Refreshes all visible result cells in the infinite scroller.
1355
+ */
1356
+ refreshVisibleResults() {
1357
+ var _a;
1358
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1359
+ }
1360
+ /**
1361
+ * Callback when a result is selected
1362
+ */
1363
+ resultSelected(event) {
1364
+ var _a, _b, _c;
1365
+ if (this.isManageView) {
1366
+ // Checked/unchecked state change -- rerender to ensure it propagates
1367
+ // this.mapDataSource(model => ({ ...model }));
1368
+ const cellIndex = this.dataSource.indexOf(event.detail);
1369
+ if (cellIndex >= 0)
1370
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1371
+ this.requestUpdate();
1372
+ }
1373
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1374
+ category: this.searchContext,
1375
+ action: analyticsActions.resultSelected,
1376
+ label: event.detail.mediatype,
1377
+ });
1378
+ (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1379
+ category: this.searchContext,
1380
+ action: analyticsActions.resultSelected,
1381
+ label: `page-${this.currentPage}`,
1382
+ });
1383
+ }
1384
+ cellForIndex(index) {
1385
+ const model = this.tileModelAtCellIndex(index);
1386
+ if (!model)
1387
+ return undefined;
1388
1388
  return html `
1389
1389
  <tile-dispatcher
1390
1390
  .collectionPagePath=${this.collectionPagePath}
@@ -1404,21 +1404,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1404
1404
  @resultSelected=${(e) => this.resultSelected(e)}
1405
1405
  >
1406
1406
  </tile-dispatcher>
1407
- `;
1408
- }
1409
- /**
1410
- * When the user scrolls near to the bottom of the page, fetch the next page
1411
- * increase the number of pages to render and start fetching data for the new page
1412
- */
1413
- scrollThresholdReached() {
1414
- if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1415
- this.pagesToRender += 1;
1416
- this.dataSource.fetchPage(this.pagesToRender);
1417
- }
1418
- }
1419
- static get styles() {
1420
- return [
1421
- srOnlyStyle,
1407
+ `;
1408
+ }
1409
+ /**
1410
+ * When the user scrolls near to the bottom of the page, fetch the next page
1411
+ * increase the number of pages to render and start fetching data for the new page
1412
+ */
1413
+ scrollThresholdReached() {
1414
+ if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1415
+ this.pagesToRender += 1;
1416
+ this.dataSource.fetchPage(this.pagesToRender);
1417
+ }
1418
+ }
1419
+ static get styles() {
1420
+ return [
1421
+ srOnlyStyle,
1422
1422
  css `
1423
1423
  :host {
1424
1424
  display: block;
@@ -1796,183 +1796,183 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1796
1796
  infinite-scroller.hidden {
1797
1797
  display: none;
1798
1798
  }
1799
- `,
1800
- ];
1801
- }
1802
- };
1803
- __decorate([
1804
- property({ type: String })
1805
- ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1806
- __decorate([
1807
- property({ type: String })
1808
- ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1809
- __decorate([
1810
- property({ type: Object })
1811
- ], CollectionBrowser.prototype, "searchService", void 0);
1812
- __decorate([
1813
- property({ type: String })
1814
- ], CollectionBrowser.prototype, "searchType", void 0);
1815
- __decorate([
1816
- property({ type: String })
1817
- ], CollectionBrowser.prototype, "withinCollection", void 0);
1818
- __decorate([
1819
- property({ type: String })
1820
- ], CollectionBrowser.prototype, "withinProfile", void 0);
1821
- __decorate([
1822
- property({ type: String })
1823
- ], CollectionBrowser.prototype, "profileElement", void 0);
1824
- __decorate([
1825
- property({ type: String })
1826
- ], CollectionBrowser.prototype, "baseQuery", void 0);
1827
- __decorate([
1828
- property({ type: String })
1829
- ], CollectionBrowser.prototype, "displayMode", void 0);
1830
- __decorate([
1831
- property({ type: Object })
1832
- ], CollectionBrowser.prototype, "defaultSortParam", void 0);
1833
- __decorate([
1834
- property({ type: String })
1835
- ], CollectionBrowser.prototype, "selectedSort", void 0);
1836
- __decorate([
1837
- property({ type: String })
1838
- ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1839
- __decorate([
1840
- property({ type: String })
1841
- ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1842
- __decorate([
1843
- property({ type: String })
1844
- ], CollectionBrowser.prototype, "sortDirection", void 0);
1845
- __decorate([
1846
- property({ type: Number })
1847
- ], CollectionBrowser.prototype, "pageSize", void 0);
1848
- __decorate([
1849
- property({ type: Number })
1850
- ], CollectionBrowser.prototype, "currentPage", void 0);
1851
- __decorate([
1852
- property({ type: String })
1853
- ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1854
- __decorate([
1855
- property({ type: String })
1856
- ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1857
- __decorate([
1858
- property({ type: Object })
1859
- ], CollectionBrowser.prototype, "selectedFacets", void 0);
1860
- __decorate([
1861
- property({ type: Boolean })
1862
- ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1863
- __decorate([
1864
- property({ type: Boolean })
1865
- ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
1866
- __decorate([
1867
- property({ type: Boolean })
1868
- ], CollectionBrowser.prototype, "suppressResultCount", void 0);
1869
- __decorate([
1870
- property({ type: Boolean })
1871
- ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
1872
- __decorate([
1873
- property({ type: Boolean })
1874
- ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
1875
- __decorate([
1876
- property({ type: Boolean })
1877
- ], CollectionBrowser.prototype, "suppressFacets", void 0);
1878
- __decorate([
1879
- property({ type: Boolean })
1880
- ], CollectionBrowser.prototype, "suppressSortBar", void 0);
1881
- __decorate([
1882
- property({ type: Boolean })
1883
- ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
1884
- __decorate([
1885
- property({ type: Boolean })
1886
- ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
1887
- __decorate([
1888
- property({ type: String })
1889
- ], CollectionBrowser.prototype, "collectionPagePath", void 0);
1890
- __decorate([
1891
- property({ type: String, reflect: true })
1892
- ], CollectionBrowser.prototype, "searchContext", void 0);
1893
- __decorate([
1894
- property({ type: String })
1895
- ], CollectionBrowser.prototype, "pageContext", void 0);
1896
- __decorate([
1897
- property({ type: Object })
1898
- ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1899
- __decorate([
1900
- property({ type: Number })
1901
- ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
1902
- __decorate([
1903
- property({ type: Boolean })
1904
- ], CollectionBrowser.prototype, "loggedIn", void 0);
1905
- __decorate([
1906
- property({ type: Object })
1907
- ], CollectionBrowser.prototype, "resizeObserver", void 0);
1908
- __decorate([
1909
- property({ type: Object })
1910
- ], CollectionBrowser.prototype, "modalManager", void 0);
1911
- __decorate([
1912
- property({ type: Object })
1913
- ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
1914
- __decorate([
1915
- property({ type: Object })
1916
- ], CollectionBrowser.prototype, "recaptchaManager", void 0);
1917
- __decorate([
1918
- property({ type: Boolean })
1919
- ], CollectionBrowser.prototype, "isManageView", void 0);
1920
- __decorate([
1921
- property({ type: String })
1922
- ], CollectionBrowser.prototype, "manageViewLabel", void 0);
1923
- __decorate([
1924
- property({ type: Boolean })
1925
- ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
1926
- __decorate([
1927
- property({ type: Object })
1928
- ], CollectionBrowser.prototype, "dataSource", void 0);
1929
- __decorate([
1930
- state()
1931
- ], CollectionBrowser.prototype, "pagesToRender", void 0);
1932
- __decorate([
1933
- state()
1934
- ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
1935
- __decorate([
1936
- state()
1937
- ], CollectionBrowser.prototype, "facetsLoading", void 0);
1938
- __decorate([
1939
- state()
1940
- ], CollectionBrowser.prototype, "totalResults", void 0);
1941
- __decorate([
1942
- state()
1943
- ], CollectionBrowser.prototype, "mobileView", void 0);
1944
- __decorate([
1945
- state()
1946
- ], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
1947
- __decorate([
1948
- state()
1949
- ], CollectionBrowser.prototype, "contentWidth", void 0);
1950
- __decorate([
1951
- state()
1952
- ], CollectionBrowser.prototype, "defaultSortField", void 0);
1953
- __decorate([
1954
- state()
1955
- ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
1956
- __decorate([
1957
- state()
1958
- ], CollectionBrowser.prototype, "placeholderType", void 0);
1959
- __decorate([
1960
- query('#content-container')
1961
- ], CollectionBrowser.prototype, "contentContainer", void 0);
1962
- __decorate([
1963
- query('#left-column')
1964
- ], CollectionBrowser.prototype, "leftColumn", void 0);
1965
- __decorate([
1966
- query('collection-facets')
1967
- ], CollectionBrowser.prototype, "collectionFacets", void 0);
1968
- __decorate([
1969
- property({ type: Object, attribute: false })
1970
- ], CollectionBrowser.prototype, "analyticsHandler", void 0);
1971
- __decorate([
1972
- query('infinite-scroller')
1973
- ], CollectionBrowser.prototype, "infiniteScroller", void 0);
1974
- CollectionBrowser = __decorate([
1975
- customElement('collection-browser')
1976
- ], CollectionBrowser);
1977
- export { CollectionBrowser };
1799
+ `,
1800
+ ];
1801
+ }
1802
+ };
1803
+ __decorate([
1804
+ property({ type: String })
1805
+ ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1806
+ __decorate([
1807
+ property({ type: String })
1808
+ ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1809
+ __decorate([
1810
+ property({ type: Object })
1811
+ ], CollectionBrowser.prototype, "searchService", void 0);
1812
+ __decorate([
1813
+ property({ type: String })
1814
+ ], CollectionBrowser.prototype, "searchType", void 0);
1815
+ __decorate([
1816
+ property({ type: String })
1817
+ ], CollectionBrowser.prototype, "withinCollection", void 0);
1818
+ __decorate([
1819
+ property({ type: String })
1820
+ ], CollectionBrowser.prototype, "withinProfile", void 0);
1821
+ __decorate([
1822
+ property({ type: String })
1823
+ ], CollectionBrowser.prototype, "profileElement", void 0);
1824
+ __decorate([
1825
+ property({ type: String })
1826
+ ], CollectionBrowser.prototype, "baseQuery", void 0);
1827
+ __decorate([
1828
+ property({ type: String })
1829
+ ], CollectionBrowser.prototype, "displayMode", void 0);
1830
+ __decorate([
1831
+ property({ type: Object })
1832
+ ], CollectionBrowser.prototype, "defaultSortParam", void 0);
1833
+ __decorate([
1834
+ property({ type: String })
1835
+ ], CollectionBrowser.prototype, "selectedSort", void 0);
1836
+ __decorate([
1837
+ property({ type: String })
1838
+ ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1839
+ __decorate([
1840
+ property({ type: String })
1841
+ ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1842
+ __decorate([
1843
+ property({ type: String })
1844
+ ], CollectionBrowser.prototype, "sortDirection", void 0);
1845
+ __decorate([
1846
+ property({ type: Number })
1847
+ ], CollectionBrowser.prototype, "pageSize", void 0);
1848
+ __decorate([
1849
+ property({ type: Number })
1850
+ ], CollectionBrowser.prototype, "currentPage", void 0);
1851
+ __decorate([
1852
+ property({ type: String })
1853
+ ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1854
+ __decorate([
1855
+ property({ type: String })
1856
+ ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1857
+ __decorate([
1858
+ property({ type: Object })
1859
+ ], CollectionBrowser.prototype, "selectedFacets", void 0);
1860
+ __decorate([
1861
+ property({ type: Boolean })
1862
+ ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1863
+ __decorate([
1864
+ property({ type: Boolean })
1865
+ ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
1866
+ __decorate([
1867
+ property({ type: Boolean })
1868
+ ], CollectionBrowser.prototype, "suppressResultCount", void 0);
1869
+ __decorate([
1870
+ property({ type: Boolean })
1871
+ ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
1872
+ __decorate([
1873
+ property({ type: Boolean })
1874
+ ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
1875
+ __decorate([
1876
+ property({ type: Boolean })
1877
+ ], CollectionBrowser.prototype, "suppressFacets", void 0);
1878
+ __decorate([
1879
+ property({ type: Boolean })
1880
+ ], CollectionBrowser.prototype, "suppressSortBar", void 0);
1881
+ __decorate([
1882
+ property({ type: Boolean })
1883
+ ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
1884
+ __decorate([
1885
+ property({ type: Boolean })
1886
+ ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
1887
+ __decorate([
1888
+ property({ type: String })
1889
+ ], CollectionBrowser.prototype, "collectionPagePath", void 0);
1890
+ __decorate([
1891
+ property({ type: String, reflect: true })
1892
+ ], CollectionBrowser.prototype, "searchContext", void 0);
1893
+ __decorate([
1894
+ property({ type: String })
1895
+ ], CollectionBrowser.prototype, "pageContext", void 0);
1896
+ __decorate([
1897
+ property({ type: Object })
1898
+ ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1899
+ __decorate([
1900
+ property({ type: Number })
1901
+ ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
1902
+ __decorate([
1903
+ property({ type: Boolean })
1904
+ ], CollectionBrowser.prototype, "loggedIn", void 0);
1905
+ __decorate([
1906
+ property({ type: Object })
1907
+ ], CollectionBrowser.prototype, "resizeObserver", void 0);
1908
+ __decorate([
1909
+ property({ type: Object })
1910
+ ], CollectionBrowser.prototype, "modalManager", void 0);
1911
+ __decorate([
1912
+ property({ type: Object })
1913
+ ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
1914
+ __decorate([
1915
+ property({ type: Object })
1916
+ ], CollectionBrowser.prototype, "recaptchaManager", void 0);
1917
+ __decorate([
1918
+ property({ type: Boolean })
1919
+ ], CollectionBrowser.prototype, "isManageView", void 0);
1920
+ __decorate([
1921
+ property({ type: String })
1922
+ ], CollectionBrowser.prototype, "manageViewLabel", void 0);
1923
+ __decorate([
1924
+ property({ type: Boolean })
1925
+ ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
1926
+ __decorate([
1927
+ property({ type: Object })
1928
+ ], CollectionBrowser.prototype, "dataSource", void 0);
1929
+ __decorate([
1930
+ state()
1931
+ ], CollectionBrowser.prototype, "pagesToRender", void 0);
1932
+ __decorate([
1933
+ state()
1934
+ ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
1935
+ __decorate([
1936
+ state()
1937
+ ], CollectionBrowser.prototype, "facetsLoading", void 0);
1938
+ __decorate([
1939
+ state()
1940
+ ], CollectionBrowser.prototype, "totalResults", void 0);
1941
+ __decorate([
1942
+ state()
1943
+ ], CollectionBrowser.prototype, "mobileView", void 0);
1944
+ __decorate([
1945
+ state()
1946
+ ], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
1947
+ __decorate([
1948
+ state()
1949
+ ], CollectionBrowser.prototype, "contentWidth", void 0);
1950
+ __decorate([
1951
+ state()
1952
+ ], CollectionBrowser.prototype, "defaultSortField", void 0);
1953
+ __decorate([
1954
+ state()
1955
+ ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
1956
+ __decorate([
1957
+ state()
1958
+ ], CollectionBrowser.prototype, "placeholderType", void 0);
1959
+ __decorate([
1960
+ query('#content-container')
1961
+ ], CollectionBrowser.prototype, "contentContainer", void 0);
1962
+ __decorate([
1963
+ query('#left-column')
1964
+ ], CollectionBrowser.prototype, "leftColumn", void 0);
1965
+ __decorate([
1966
+ query('collection-facets')
1967
+ ], CollectionBrowser.prototype, "collectionFacets", void 0);
1968
+ __decorate([
1969
+ property({ type: Object, attribute: false })
1970
+ ], CollectionBrowser.prototype, "analyticsHandler", void 0);
1971
+ __decorate([
1972
+ query('infinite-scroller')
1973
+ ], CollectionBrowser.prototype, "infiniteScroller", void 0);
1974
+ CollectionBrowser = __decorate([
1975
+ customElement('collection-browser')
1976
+ ], CollectionBrowser);
1977
+ export { CollectionBrowser };
1978
1978
  //# sourceMappingURL=collection-browser.js.map