@internetarchive/collection-browser 2.7.5-alpha.4 → 2.7.5-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 (328) 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 +13 -13
  6. package/dist/index.js +13 -13
  7. package/dist/src/app-root.d.ts +99 -95
  8. package/dist/src/app-root.js +514 -494
  9. package/dist/src/app-root.js.map +1 -1
  10. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  11. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  12. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  13. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  14. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  15. package/dist/src/assets/img/icons/chevron.js +2 -2
  16. package/dist/src/assets/img/icons/contract.d.ts +2 -2
  17. package/dist/src/assets/img/icons/contract.js +2 -2
  18. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  19. package/dist/src/assets/img/icons/empty-query.js +2 -2
  20. package/dist/src/assets/img/icons/expand.d.ts +2 -2
  21. package/dist/src/assets/img/icons/expand.js +2 -2
  22. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  23. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  24. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  25. package/dist/src/assets/img/icons/eye.js +2 -2
  26. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  27. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  28. package/dist/src/assets/img/icons/favorite-unfilled.d.ts +1 -1
  29. package/dist/src/assets/img/icons/favorite-unfilled.js +2 -2
  30. package/dist/src/assets/img/icons/filter.d.ts +2 -2
  31. package/dist/src/assets/img/icons/filter.js +2 -2
  32. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  33. package/dist/src/assets/img/icons/login-required.js +2 -2
  34. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  35. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  36. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  37. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  38. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  39. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  40. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  41. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  42. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  43. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  44. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  45. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  46. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  47. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  48. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  49. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  50. package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -1
  51. package/dist/src/assets/img/icons/mediatype/search.js +2 -2
  52. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  53. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  54. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  55. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  56. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  57. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  58. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  59. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  60. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  61. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  62. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  63. package/dist/src/assets/img/icons/null-result.js +2 -2
  64. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  65. package/dist/src/assets/img/icons/restricted.js +2 -2
  66. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  67. package/dist/src/assets/img/icons/reviews.js +2 -2
  68. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  69. package/dist/src/assets/img/icons/upload.js +2 -2
  70. package/dist/src/assets/img/icons/views.d.ts +1 -1
  71. package/dist/src/assets/img/icons/views.js +2 -2
  72. package/dist/src/circular-activity-indicator.d.ts +5 -5
  73. package/dist/src/circular-activity-indicator.js +17 -17
  74. package/dist/src/collection-browser.d.ts +582 -578
  75. package/dist/src/collection-browser.js +1629 -1614
  76. package/dist/src/collection-browser.js.map +1 -1
  77. package/dist/src/collection-facets/facet-row.d.ts +30 -30
  78. package/dist/src/collection-facets/facet-row.js +118 -118
  79. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  80. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  81. package/dist/src/collection-facets/facets-template.d.ts +13 -13
  82. package/dist/src/collection-facets/facets-template.js +44 -44
  83. package/dist/src/collection-facets/more-facets-content.d.ts +106 -106
  84. package/dist/src/collection-facets/more-facets-content.js +407 -407
  85. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  86. package/dist/src/collection-facets/more-facets-pagination.js +196 -196
  87. package/dist/src/collection-facets/smart-facets/dedupe.d.ts +10 -10
  88. package/dist/src/collection-facets/smart-facets/dedupe.js +33 -33
  89. package/dist/src/collection-facets/smart-facets/heuristics/browser-language-heuristic.d.ts +5 -5
  90. package/dist/src/collection-facets/smart-facets/heuristics/browser-language-heuristic.js +23 -23
  91. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.d.ts +5 -5
  92. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.js +44 -44
  93. package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.d.ts +5 -5
  94. package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.js +172 -172
  95. package/dist/src/collection-facets/smart-facets/models.d.ts +26 -26
  96. package/dist/src/collection-facets/smart-facets/models.js +1 -1
  97. package/dist/src/collection-facets/smart-facets/smart-facet-bar.d.ts +31 -31
  98. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +240 -240
  99. package/dist/src/collection-facets/smart-facets/smart-facet-button.d.ts +11 -11
  100. package/dist/src/collection-facets/smart-facets/smart-facet-button.js +86 -86
  101. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +16 -16
  102. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +100 -100
  103. package/dist/src/collection-facets/smart-facets/smart-facet-equals.d.ts +2 -2
  104. package/dist/src/collection-facets/smart-facets/smart-facet-equals.js +12 -12
  105. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.d.ts +5 -5
  106. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +15 -15
  107. package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
  108. package/dist/src/collection-facets/toggle-switch.js +94 -94
  109. package/dist/src/collection-facets.d.ts +103 -103
  110. package/dist/src/collection-facets.js +522 -522
  111. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +241 -241
  112. package/dist/src/data-source/collection-browser-data-source-interface.js +1 -1
  113. package/dist/src/data-source/collection-browser-data-source.d.ts +373 -378
  114. package/dist/src/data-source/collection-browser-data-source.js +982 -1013
  115. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  116. package/dist/src/data-source/collection-browser-query-state.d.ts +43 -43
  117. package/dist/src/data-source/collection-browser-query-state.js +1 -1
  118. package/dist/src/data-source/models.d.ts +28 -28
  119. package/dist/src/data-source/models.js +8 -8
  120. package/dist/src/empty-placeholder.d.ts +23 -23
  121. package/dist/src/empty-placeholder.js +79 -79
  122. package/dist/src/expanded-date-picker.d.ts +43 -43
  123. package/dist/src/expanded-date-picker.js +109 -109
  124. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  125. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  126. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  127. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  128. package/dist/src/manage/manage-bar.d.ts +35 -30
  129. package/dist/src/manage/manage-bar.js +86 -82
  130. package/dist/src/manage/manage-bar.js.map +1 -1
  131. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  132. package/dist/src/mediatype/mediatype-config.js +91 -91
  133. package/dist/src/models.d.ts +219 -219
  134. package/dist/src/models.js +401 -401
  135. package/dist/src/models.js.map +1 -1
  136. package/dist/src/restoration-state-handler.d.ts +70 -70
  137. package/dist/src/restoration-state-handler.js +363 -363
  138. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
  139. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
  140. package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -21
  141. package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
  142. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  143. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  144. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  145. package/dist/src/sort-filter-bar/img/list.js +2 -2
  146. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
  147. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
  148. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
  149. package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
  150. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
  151. package/dist/src/sort-filter-bar/img/sort-toggle-up.js +2 -2
  152. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  153. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  154. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  155. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  156. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +223 -223
  157. package/dist/src/sort-filter-bar/sort-filter-bar.js +697 -697
  158. package/dist/src/styles/ia-button.d.ts +2 -2
  159. package/dist/src/styles/ia-button.js +51 -19
  160. package/dist/src/styles/ia-button.js.map +1 -1
  161. package/dist/src/styles/item-image-styles.d.ts +8 -8
  162. package/dist/src/styles/item-image-styles.js +9 -9
  163. package/dist/src/styles/sr-only.d.ts +1 -1
  164. package/dist/src/styles/sr-only.js +2 -2
  165. package/dist/src/tiles/base-tile-component.d.ts +19 -19
  166. package/dist/src/tiles/base-tile-component.js +64 -64
  167. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  168. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  169. package/dist/src/tiles/grid/account-tile.d.ts +18 -18
  170. package/dist/src/tiles/grid/account-tile.js +72 -72
  171. package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
  172. package/dist/src/tiles/grid/collection-tile.js +80 -80
  173. package/dist/src/tiles/grid/item-tile.d.ts +34 -34
  174. package/dist/src/tiles/grid/item-tile.js +158 -158
  175. package/dist/src/tiles/grid/search-tile.d.ts +10 -10
  176. package/dist/src/tiles/grid/search-tile.js +51 -51
  177. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  178. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +8 -8
  179. package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
  180. package/dist/src/tiles/grid/tile-stats.js +53 -53
  181. package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
  182. package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
  183. package/dist/src/tiles/hover/tile-hover-pane.d.ts +18 -18
  184. package/dist/src/tiles/hover/tile-hover-pane.js +69 -69
  185. package/dist/src/tiles/image-block.d.ts +18 -18
  186. package/dist/src/tiles/image-block.js +89 -89
  187. package/dist/src/tiles/item-image.d.ts +39 -39
  188. package/dist/src/tiles/item-image.js +154 -154
  189. package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
  190. package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
  191. package/dist/src/tiles/list/tile-list-compact.d.ts +19 -19
  192. package/dist/src/tiles/list/tile-list-compact.js +122 -122
  193. package/dist/src/tiles/list/tile-list.d.ts +54 -54
  194. package/dist/src/tiles/list/tile-list.js +323 -323
  195. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  196. package/dist/src/tiles/mediatype-icon.js +47 -47
  197. package/dist/src/tiles/overlay/icon-overlay.d.ts +8 -8
  198. package/dist/src/tiles/overlay/icon-overlay.js +25 -25
  199. package/dist/src/tiles/overlay/text-overlay.d.ts +9 -9
  200. package/dist/src/tiles/overlay/text-overlay.js +31 -31
  201. package/dist/src/tiles/review-block.d.ts +12 -12
  202. package/dist/src/tiles/review-block.js +56 -56
  203. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  204. package/dist/src/tiles/text-snippet-block.js +73 -73
  205. package/dist/src/tiles/tile-dispatcher.d.ts +64 -64
  206. package/dist/src/tiles/tile-dispatcher.js +230 -230
  207. package/dist/src/tiles/tile-display-value-provider.d.ts +47 -47
  208. package/dist/src/tiles/tile-display-value-provider.js +94 -94
  209. package/dist/src/utils/analytics-events.d.ts +28 -28
  210. package/dist/src/utils/analytics-events.js +30 -30
  211. package/dist/src/utils/array-equals.d.ts +4 -4
  212. package/dist/src/utils/array-equals.js +10 -10
  213. package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -11
  214. package/dist/src/utils/collapse-repeated-quotes.js +13 -13
  215. package/dist/src/utils/facet-utils.d.ts +83 -83
  216. package/dist/src/utils/facet-utils.js +145 -145
  217. package/dist/src/utils/format-count.d.ts +7 -7
  218. package/dist/src/utils/format-count.js +76 -76
  219. package/dist/src/utils/format-date.d.ts +2 -2
  220. package/dist/src/utils/format-date.js +25 -25
  221. package/dist/src/utils/format-unit-size.d.ts +2 -2
  222. package/dist/src/utils/format-unit-size.js +33 -33
  223. package/dist/src/utils/local-date-from-utc.d.ts +9 -9
  224. package/dist/src/utils/local-date-from-utc.js +15 -15
  225. package/dist/src/utils/log.d.ts +7 -7
  226. package/dist/src/utils/log.js +15 -15
  227. package/dist/src/utils/resolve-mediatype.d.ts +8 -8
  228. package/dist/src/utils/resolve-mediatype.js +23 -23
  229. package/dist/src/utils/sha1.d.ts +2 -2
  230. package/dist/src/utils/sha1.js +8 -8
  231. package/dist/test/collection-browser.test.d.ts +1 -1
  232. package/dist/test/collection-browser.test.js +1294 -1294
  233. package/dist/test/collection-browser.test.js.map +1 -1
  234. package/dist/test/collection-facets/facet-row.test.d.ts +1 -1
  235. package/dist/test/collection-facets/facet-row.test.js +227 -227
  236. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  237. package/dist/test/collection-facets/facets-template.test.js +91 -91
  238. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  239. package/dist/test/collection-facets/more-facets-content.test.js +141 -141
  240. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  241. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  242. package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -1
  243. package/dist/test/collection-facets/toggle-switch.test.js +73 -73
  244. package/dist/test/collection-facets.test.d.ts +2 -2
  245. package/dist/test/collection-facets.test.js +690 -690
  246. package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -1
  247. package/dist/test/data-source/collection-browser-data-source.test.js +89 -89
  248. package/dist/test/empty-placeholder.test.d.ts +1 -1
  249. package/dist/test/empty-placeholder.test.js +63 -63
  250. package/dist/test/expanded-date-picker.test.d.ts +1 -1
  251. package/dist/test/expanded-date-picker.test.js +95 -95
  252. package/dist/test/icon-overlay.test.d.ts +1 -1
  253. package/dist/test/icon-overlay.test.js +24 -24
  254. package/dist/test/image-block.test.d.ts +1 -1
  255. package/dist/test/image-block.test.js +107 -107
  256. package/dist/test/item-image.test.d.ts +1 -1
  257. package/dist/test/item-image.test.js +85 -85
  258. package/dist/test/manage/manage-bar.test.d.ts +1 -1
  259. package/dist/test/manage/manage-bar.test.js +91 -81
  260. package/dist/test/manage/manage-bar.test.js.map +1 -1
  261. package/dist/test/mediatype-config.test.d.ts +1 -1
  262. package/dist/test/mediatype-config.test.js +16 -16
  263. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  264. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  265. package/dist/test/mocks/mock-search-responses.d.ts +25 -25
  266. package/dist/test/mocks/mock-search-responses.js +942 -942
  267. package/dist/test/mocks/mock-search-service.d.ts +15 -15
  268. package/dist/test/mocks/mock-search-service.js +54 -54
  269. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  270. package/dist/test/restoration-state-handler.test.js +270 -270
  271. package/dist/test/review-block.test.d.ts +1 -1
  272. package/dist/test/review-block.test.js +44 -44
  273. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
  274. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
  275. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  276. package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
  277. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  278. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +426 -426
  279. package/dist/test/text-overlay.test.d.ts +1 -1
  280. package/dist/test/text-overlay.test.js +38 -38
  281. package/dist/test/text-snippet-block.test.d.ts +1 -1
  282. package/dist/test/text-snippet-block.test.js +57 -57
  283. package/dist/test/tile-stats.test.d.ts +1 -1
  284. package/dist/test/tile-stats.test.js +81 -81
  285. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  286. package/dist/test/tiles/grid/account-tile.test.js +76 -76
  287. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  288. package/dist/test/tiles/grid/collection-tile.test.js +73 -73
  289. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  290. package/dist/test/tiles/grid/item-tile.test.js +312 -312
  291. package/dist/test/tiles/grid/search-tile.test.d.ts +1 -1
  292. package/dist/test/tiles/grid/search-tile.test.js +51 -51
  293. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  294. package/dist/test/tiles/hover/hover-pane-controller.test.js +259 -259
  295. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  296. package/dist/test/tiles/hover/tile-hover-pane.test.js +56 -56
  297. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  298. package/dist/test/tiles/list/tile-list-compact.test.js +143 -143
  299. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  300. package/dist/test/tiles/list/tile-list.test.js +297 -297
  301. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
  302. package/dist/test/tiles/tile-dispatcher.test.js +100 -100
  303. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
  304. package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
  305. package/dist/test/utils/array-equals.test.d.ts +1 -1
  306. package/dist/test/utils/array-equals.test.js +26 -26
  307. package/dist/test/utils/format-count.test.d.ts +1 -1
  308. package/dist/test/utils/format-count.test.js +23 -23
  309. package/dist/test/utils/format-date.test.d.ts +1 -1
  310. package/dist/test/utils/format-date.test.js +17 -17
  311. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  312. package/dist/test/utils/format-unit-size.test.js +17 -17
  313. package/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
  314. package/dist/test/utils/local-date-from-utc.test.js +26 -26
  315. package/local.archive.org.cert +86 -86
  316. package/local.archive.org.key +27 -27
  317. package/package.json +1 -1
  318. package/renovate.json +6 -6
  319. package/src/app-root.ts +23 -0
  320. package/src/collection-browser.ts +18 -0
  321. package/src/data-source/collection-browser-data-source.ts +8 -45
  322. package/src/manage/manage-bar.ts +28 -21
  323. package/src/models.ts +2 -2
  324. package/src/styles/ia-button.ts +37 -5
  325. package/test/collection-browser.test.ts +1 -1
  326. package/test/manage/manage-bar.test.ts +12 -0
  327. package/web-dev-server.config.mjs +30 -30
  328. package/web-test-runner.config.mjs +41 -41
@@ -1,331 +1,331 @@
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 { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
13
- import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
14
- import chevronIcon from './assets/img/icons/chevron';
15
- import { srOnlyStyle } from './styles/sr-only';
16
- import { sha1 } from './utils/sha1';
17
- import { formatDate } from './utils/format-date';
18
- import { log } from './utils/log';
19
- import './empty-placeholder';
20
- import './tiles/tile-dispatcher';
21
- import './tiles/collection-browser-loading-tile';
22
- import './sort-filter-bar/sort-filter-bar';
23
- import './manage/manage-bar';
24
- import './collection-facets';
25
- import './circular-activity-indicator';
26
- import './collection-facets/smart-facets/smart-facet-bar';
27
- let CollectionBrowser = class CollectionBrowser extends LitElement {
28
- constructor() {
29
- super();
30
- this.baseImageUrl = 'https://archive.org';
31
- /**
32
- * Which backend should be targeted by searches (e.g., metadata or FTS)
33
- */
34
- this.searchType = SearchType.METADATA;
35
- this.selectedSort = SortField.default;
36
- this.selectedTitleFilter = null;
37
- this.selectedCreatorFilter = null;
38
- this.sortDirection = null;
39
- this.defaultSortField = SortField.relevance;
40
- this.defaultSortDirection = null;
41
- this.pageSize = 50;
42
- this.showSmartFacetBar = false;
43
- /**
44
- * Whether to show the date picker (above the facets)
45
- */
46
- this.showHistogramDatePicker = false;
47
- /**
48
- * Whether placeholder views should be suppressed. If true, searches that produce an
49
- * error or empty result set will simply show a blank results view instead of a placeholder.
50
- */
51
- this.suppressPlaceholders = false;
52
- /**
53
- * Whether the result count text should be suppressed.
54
- * If true, no "X Results" message will be shown.
55
- */
56
- this.suppressResultCount = false;
57
- /**
58
- * Whether the scrolling result view should be suppressed entirely.
59
- * If true, no infinite scroller (and thus no result tiles) will be rendered.
60
- */
61
- this.suppressResultTiles = false;
62
- /**
63
- * Whether to suppress persistence of the query to the URL.
64
- * If true, the `query` param will not be added to the URL or updated on query changes.
65
- */
66
- this.suppressURLQuery = false;
67
- /**
68
- * Whether to suppress display of the sort bar.
69
- * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
70
- */
71
- this.suppressSortBar = false;
72
- /**
73
- * Whether to suppress showing the display mode options in the sort bar.
74
- * If true, those options will be omitted (though the rest of the sort bar may still render).
75
- */
76
- this.suppressDisplayModes = false;
77
- /**
78
- * What strategy to use for when/whether to load facet data for a search.
79
- *
80
- * Defaults to `eager`, always loading facets immediately alongside search results.
81
- *
82
- * To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
83
- * will delay loading facets in the mobile view until the "Filters" accordion is opened.
84
- * Facets are still loaded eagerly when viewing the desktop layout.
85
- *
86
- * To further reduce facet requests for patrons who do not need to use them, this can be
87
- * again reduced to `opt-in`, which will also require desktop users to explicitly request
88
- * that they be loaded (in addition to the lazy mobile behavior described above).
89
- *
90
- * To entirely suppress facets from being loaded, this may be set to `off`.
91
- */
92
- this.facetLoadStrategy = 'eager';
93
- this.facetPaneVisible = false;
94
- this.clearResultsOnEmptyQuery = false;
95
- this.collectionPagePath = '/details/';
96
- /** describes where this component is being used */
97
- this.searchContext = analyticsCategories.default;
98
- this.pageContext = 'search';
99
- this.restorationStateHandler = new RestorationStateHandler({
100
- context: this.pageContext,
101
- });
102
- this.mobileBreakpoint = 600;
103
- this.loggedIn = false;
104
- this.modalManager = undefined;
105
- /**
106
- * If item management UI active
107
- */
108
- this.isManageView = false;
109
- this.manageViewLabel = 'Select items to remove';
110
- /** Whether to replace the default sort options with a slot for customization (default: false) */
111
- this.enableSortOptionsSlot = false;
112
- /** Whether to display a smart results carousel above the full results */
113
- this.showSmartResults = false;
114
- /**
115
- * The results per page so we can paginate.
116
- *
117
- * This allows us to start in the middle of the search results and
118
- * fetch data before or after the current page. If we don't have a key
119
- * for the previous/next page, we'll fetch the next/previous page to populate it
120
- */
121
- this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
122
- /**
123
- * The page that the consumer wants to load.
124
- */
125
- this.initialPageNumber = 1;
126
- /**
127
- * This the the number of pages that we want to show.
128
- *
129
- * The data isn't necessarily loaded for all of the pages, but this lets us
130
- * know how many cells we should render.
131
- */
132
- this.pagesToRender = this.initialPageNumber;
133
- /**
134
- * Whether the initial page fetch for a new query is currently in progress.
135
- */
136
- this.searchResultsLoading = false;
137
- this.facetsLoading = false;
138
- this.mobileView = false;
139
- this.collapsibleFacetsVisible = false;
140
- this.placeholderType = null;
141
- /** Whether layout size analytics have been sent already. */
142
- this.layoutSizeAnalyticsSent = false;
143
- /**
144
- * When we're animated scrolling to the page, we don't want to fetch
145
- * all of the pages as it scrolls so this lets us know if we're scrolling
146
- */
147
- this.isScrollingToCell = false;
148
- /**
149
- * When page width resizes from desktop to mobile, set true to
150
- * disable expand/collapse transition when loading.
151
- */
152
- this.isResizeToMobile = false;
153
- /**
154
- * Flag indicating that a new data source is currently being installed.
155
- * During the install, any URL persistence operation should replace the current entry
156
- * instead of creating a new one.
157
- */
158
- this.dataSourceInstallInProgress = false;
159
- this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
160
- /**
161
- * Updates the height of the left column according to its position on the page.
162
- * Arrow function ensures proper `this` binding.
163
- */
164
- this.updateLeftColumnHeight = () => {
165
- var _a, _b, _c, _d, _e;
166
- if (this.mobileView) {
167
- (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
168
- }
169
- else {
170
- const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
171
- (_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`);
172
- }
173
- };
174
- /**
175
- * Toggles whether the fade-out is visible at the bottom of the facets.
176
- * It should only be visible if the facets are not scrolled to the bottom.
177
- * Arrow function ensures proper `this` binding.
178
- */
179
- this.updateFacetFadeOut = (entries) => {
180
- var _a, _b;
181
- const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
182
- 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);
183
- };
184
- // we only want to scroll on the very first query change
185
- // so this keeps track of whether we've already set the initial query
186
- this.initialQueryChangeHappened = false;
187
- this.historyPopOccurred = false;
188
- this.addController(this.dataSource);
189
- }
190
- tileModelAtCellIndex(index) {
191
- const model = this.dataSource.getTileModelAt(index);
192
- /**
193
- * If we encounter a model we don't have yet and we're not in the middle of an
194
- * automated scroll, fetch the page and just return undefined.
195
- * The datasource will be updated once the page is loaded and the cell will be rendered.
196
- *
197
- * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
198
- * user may never see.
199
- */
200
- if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
201
- const pageNumber = Math.floor(index / this.pageSize) + 1;
202
- this.dataSource.fetchPage(pageNumber);
203
- }
204
- return model;
205
- }
206
- // this is the total number of tiles we expect if
207
- // the data returned is a full page worth
208
- // this is useful for putting in placeholders for the expected number of tiles
209
- get estimatedTileCount() {
210
- return this.pagesToRender * this.pageSize;
211
- }
212
- /**
213
- * Returns a promise resolving to a unique string that persists for the current browser session.
214
- * Used in generating unique IDs for search requests, so that multiple requests coming from the
215
- * same browser session can be identified.
216
- */
217
- async getSessionId() {
218
- try {
219
- const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
220
- if (storedSessionId) {
221
- return storedSessionId;
222
- }
223
- // If we enter this method a second time while a first session ID is already being generated,
224
- // ensure we produce the same ID from both calls instead of generating another one.
225
- if (this.sessionIdGenPromise) {
226
- return this.sessionIdGenPromise;
227
- }
228
- this.sessionIdGenPromise = sha1(Math.random().toString());
229
- const newSessionId = await this.sessionIdGenPromise;
230
- sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
231
- return newSessionId;
232
- }
233
- catch (err) {
234
- // Either we can't generate the hash or we're restricted from accessing sessionStorage
235
- return '';
236
- }
237
- }
238
- /**
239
- * Go to the given page of results
240
- *
241
- * @param pageNumber
242
- */
243
- goToPage(pageNumber) {
244
- this.initialPageNumber = pageNumber;
245
- this.pagesToRender = pageNumber;
246
- return this.scrollToPage(pageNumber);
247
- }
248
- /**
249
- * Sets the state for whether the initial set of search results is loading in.
250
- */
251
- setSearchResultsLoading(loading) {
252
- this.searchResultsLoading = loading;
253
- }
254
- /**
255
- * Sets the state for whether facet data is loading in
256
- */
257
- setFacetsLoading(loading) {
258
- this.facetsLoading = loading;
259
- }
260
- /**
261
- * Sets the total number of results to be displayed for the current search
262
- */
263
- setTotalResultCount(totalResults) {
264
- this.totalResults = totalResults;
265
- }
266
- /**
267
- * Clears all selected/negated facets, date ranges, and letter filters.
268
- *
269
- * By default, the current sort field/direction are not cleared,
270
- * but this can be overridden by setting the `sort` option to `true`.
271
- *
272
- * Similarly, it is possible to finely control what is cleared by
273
- * setting any of the `facets`, `dateRange`, or `letterFilters` flags
274
- * in the options object.
275
- */
276
- clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
277
- // Don't bother clearing facets if none are checked, so that we don't
278
- // trigger unnecessary update cycles.
279
- if (facets && this.hasCheckedFacets) {
280
- this.selectedFacets = getDefaultSelectedFacets();
281
- }
282
- if (dateRange) {
283
- this.minSelectedDate = undefined;
284
- this.maxSelectedDate = undefined;
285
- }
286
- if (letterFilters) {
287
- this.selectedTitleFilter = null;
288
- this.selectedCreatorFilter = null;
289
- }
290
- if (sort) {
291
- this.sortDirection = null;
292
- this.selectedSort = SortField.default;
293
- }
294
- }
295
- /**
296
- * Returns true if the current value of `this.selectedFacets` contains
297
- * any facet buckets than have been selected or negated, or false otherwise.
298
- */
299
- get hasCheckedFacets() {
300
- if (!this.selectedFacets)
301
- return false;
302
- for (const facetGroup of Object.values(this.selectedFacets)) {
303
- for (const bucket of Object.values(facetGroup)) {
304
- if (bucket.state !== 'none')
305
- return true;
306
- }
307
- }
308
- return false;
309
- }
310
- /**
311
- * Returns true if there are any currently selected/negated facet buckets,
312
- * any selected date range, or any selected letter filters. False otherwise.
313
- *
314
- * Ignores sorting options.
315
- */
316
- get hasActiveFilters() {
317
- return !!(this.hasCheckedFacets ||
318
- this.minSelectedDate ||
319
- this.maxSelectedDate ||
320
- this.selectedTitleFilter ||
321
- this.selectedCreatorFilter);
322
- }
323
- willUpdate() {
324
- this.setPlaceholderType();
325
- }
326
- render() {
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 { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
13
+ import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
14
+ import chevronIcon from './assets/img/icons/chevron';
15
+ import { srOnlyStyle } from './styles/sr-only';
16
+ import { sha1 } from './utils/sha1';
17
+ import { formatDate } from './utils/format-date';
18
+ import { log } from './utils/log';
19
+ import './empty-placeholder';
20
+ import './tiles/tile-dispatcher';
21
+ import './tiles/collection-browser-loading-tile';
22
+ import './sort-filter-bar/sort-filter-bar';
23
+ import './manage/manage-bar';
24
+ import './collection-facets';
25
+ import './circular-activity-indicator';
26
+ import './collection-facets/smart-facets/smart-facet-bar';
27
+ let CollectionBrowser = class CollectionBrowser extends LitElement {
28
+ constructor() {
29
+ super();
30
+ this.baseImageUrl = 'https://archive.org';
31
+ /**
32
+ * Which backend should be targeted by searches (e.g., metadata or FTS)
33
+ */
34
+ this.searchType = SearchType.METADATA;
35
+ this.selectedSort = SortField.default;
36
+ this.selectedTitleFilter = null;
37
+ this.selectedCreatorFilter = null;
38
+ this.sortDirection = null;
39
+ this.defaultSortField = SortField.relevance;
40
+ this.defaultSortDirection = null;
41
+ this.pageSize = 50;
42
+ this.showSmartFacetBar = false;
43
+ /**
44
+ * Whether to show the date picker (above the facets)
45
+ */
46
+ this.showHistogramDatePicker = false;
47
+ /**
48
+ * Whether placeholder views should be suppressed. If true, searches that produce an
49
+ * error or empty result set will simply show a blank results view instead of a placeholder.
50
+ */
51
+ this.suppressPlaceholders = false;
52
+ /**
53
+ * Whether the result count text should be suppressed.
54
+ * If true, no "X Results" message will be shown.
55
+ */
56
+ this.suppressResultCount = false;
57
+ /**
58
+ * Whether the scrolling result view should be suppressed entirely.
59
+ * If true, no infinite scroller (and thus no result tiles) will be rendered.
60
+ */
61
+ this.suppressResultTiles = false;
62
+ /**
63
+ * Whether to suppress persistence of the query to the URL.
64
+ * If true, the `query` param will not be added to the URL or updated on query changes.
65
+ */
66
+ this.suppressURLQuery = false;
67
+ /**
68
+ * Whether to suppress display of the sort bar.
69
+ * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
70
+ */
71
+ this.suppressSortBar = false;
72
+ /**
73
+ * Whether to suppress showing the display mode options in the sort bar.
74
+ * If true, those options will be omitted (though the rest of the sort bar may still render).
75
+ */
76
+ this.suppressDisplayModes = false;
77
+ /**
78
+ * What strategy to use for when/whether to load facet data for a search.
79
+ *
80
+ * Defaults to `eager`, always loading facets immediately alongside search results.
81
+ *
82
+ * To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
83
+ * will delay loading facets in the mobile view until the "Filters" accordion is opened.
84
+ * Facets are still loaded eagerly when viewing the desktop layout.
85
+ *
86
+ * To further reduce facet requests for patrons who do not need to use them, this can be
87
+ * again reduced to `opt-in`, which will also require desktop users to explicitly request
88
+ * that they be loaded (in addition to the lazy mobile behavior described above).
89
+ *
90
+ * To entirely suppress facets from being loaded, this may be set to `off`.
91
+ */
92
+ this.facetLoadStrategy = 'eager';
93
+ this.facetPaneVisible = false;
94
+ this.clearResultsOnEmptyQuery = false;
95
+ this.collectionPagePath = '/details/';
96
+ /** describes where this component is being used */
97
+ this.searchContext = analyticsCategories.default;
98
+ this.pageContext = 'search';
99
+ this.restorationStateHandler = new RestorationStateHandler({
100
+ context: this.pageContext,
101
+ });
102
+ this.mobileBreakpoint = 600;
103
+ this.loggedIn = false;
104
+ this.modalManager = undefined;
105
+ /**
106
+ * If item management UI active
107
+ */
108
+ this.isManageView = false;
109
+ this.manageViewLabel = 'Select items to remove';
110
+ /** Whether to replace the default sort options with a slot for customization (default: false) */
111
+ this.enableSortOptionsSlot = false;
112
+ /** Whether to display a smart results carousel above the full results */
113
+ this.showSmartResults = false;
114
+ /**
115
+ * The results per page so we can paginate.
116
+ *
117
+ * This allows us to start in the middle of the search results and
118
+ * fetch data before or after the current page. If we don't have a key
119
+ * for the previous/next page, we'll fetch the next/previous page to populate it
120
+ */
121
+ this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
122
+ /**
123
+ * The page that the consumer wants to load.
124
+ */
125
+ this.initialPageNumber = 1;
126
+ /**
127
+ * This the the number of pages that we want to show.
128
+ *
129
+ * The data isn't necessarily loaded for all of the pages, but this lets us
130
+ * know how many cells we should render.
131
+ */
132
+ this.pagesToRender = this.initialPageNumber;
133
+ /**
134
+ * Whether the initial page fetch for a new query is currently in progress.
135
+ */
136
+ this.searchResultsLoading = false;
137
+ this.facetsLoading = false;
138
+ this.mobileView = false;
139
+ this.collapsibleFacetsVisible = false;
140
+ this.placeholderType = null;
141
+ /** Whether layout size analytics have been sent already. */
142
+ this.layoutSizeAnalyticsSent = false;
143
+ /**
144
+ * When we're animated scrolling to the page, we don't want to fetch
145
+ * all of the pages as it scrolls so this lets us know if we're scrolling
146
+ */
147
+ this.isScrollingToCell = false;
148
+ /**
149
+ * When page width resizes from desktop to mobile, set true to
150
+ * disable expand/collapse transition when loading.
151
+ */
152
+ this.isResizeToMobile = false;
153
+ /**
154
+ * Flag indicating that a new data source is currently being installed.
155
+ * During the install, any URL persistence operation should replace the current entry
156
+ * instead of creating a new one.
157
+ */
158
+ this.dataSourceInstallInProgress = false;
159
+ this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
160
+ /**
161
+ * Updates the height of the left column according to its position on the page.
162
+ * Arrow function ensures proper `this` binding.
163
+ */
164
+ this.updateLeftColumnHeight = () => {
165
+ var _a, _b, _c, _d, _e;
166
+ if (this.mobileView) {
167
+ (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
168
+ }
169
+ else {
170
+ const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
171
+ (_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`);
172
+ }
173
+ };
174
+ /**
175
+ * Toggles whether the fade-out is visible at the bottom of the facets.
176
+ * It should only be visible if the facets are not scrolled to the bottom.
177
+ * Arrow function ensures proper `this` binding.
178
+ */
179
+ this.updateFacetFadeOut = (entries) => {
180
+ var _a, _b;
181
+ const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
182
+ 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);
183
+ };
184
+ // we only want to scroll on the very first query change
185
+ // so this keeps track of whether we've already set the initial query
186
+ this.initialQueryChangeHappened = false;
187
+ this.historyPopOccurred = false;
188
+ this.addController(this.dataSource);
189
+ }
190
+ tileModelAtCellIndex(index) {
191
+ const model = this.dataSource.getTileModelAt(index);
192
+ /**
193
+ * If we encounter a model we don't have yet and we're not in the middle of an
194
+ * automated scroll, fetch the page and just return undefined.
195
+ * The datasource will be updated once the page is loaded and the cell will be rendered.
196
+ *
197
+ * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
198
+ * user may never see.
199
+ */
200
+ if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
201
+ const pageNumber = Math.floor(index / this.pageSize) + 1;
202
+ this.dataSource.fetchPage(pageNumber);
203
+ }
204
+ return model;
205
+ }
206
+ // this is the total number of tiles we expect if
207
+ // the data returned is a full page worth
208
+ // this is useful for putting in placeholders for the expected number of tiles
209
+ get estimatedTileCount() {
210
+ return this.pagesToRender * this.pageSize;
211
+ }
212
+ /**
213
+ * Returns a promise resolving to a unique string that persists for the current browser session.
214
+ * Used in generating unique IDs for search requests, so that multiple requests coming from the
215
+ * same browser session can be identified.
216
+ */
217
+ async getSessionId() {
218
+ try {
219
+ const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
220
+ if (storedSessionId) {
221
+ return storedSessionId;
222
+ }
223
+ // If we enter this method a second time while a first session ID is already being generated,
224
+ // ensure we produce the same ID from both calls instead of generating another one.
225
+ if (this.sessionIdGenPromise) {
226
+ return this.sessionIdGenPromise;
227
+ }
228
+ this.sessionIdGenPromise = sha1(Math.random().toString());
229
+ const newSessionId = await this.sessionIdGenPromise;
230
+ sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
231
+ return newSessionId;
232
+ }
233
+ catch (err) {
234
+ // Either we can't generate the hash or we're restricted from accessing sessionStorage
235
+ return '';
236
+ }
237
+ }
238
+ /**
239
+ * Go to the given page of results
240
+ *
241
+ * @param pageNumber
242
+ */
243
+ goToPage(pageNumber) {
244
+ this.initialPageNumber = pageNumber;
245
+ this.pagesToRender = pageNumber;
246
+ return this.scrollToPage(pageNumber);
247
+ }
248
+ /**
249
+ * Sets the state for whether the initial set of search results is loading in.
250
+ */
251
+ setSearchResultsLoading(loading) {
252
+ this.searchResultsLoading = loading;
253
+ }
254
+ /**
255
+ * Sets the state for whether facet data is loading in
256
+ */
257
+ setFacetsLoading(loading) {
258
+ this.facetsLoading = loading;
259
+ }
260
+ /**
261
+ * Sets the total number of results to be displayed for the current search
262
+ */
263
+ setTotalResultCount(totalResults) {
264
+ this.totalResults = totalResults;
265
+ }
266
+ /**
267
+ * Clears all selected/negated facets, date ranges, and letter filters.
268
+ *
269
+ * By default, the current sort field/direction are not cleared,
270
+ * but this can be overridden by setting the `sort` option to `true`.
271
+ *
272
+ * Similarly, it is possible to finely control what is cleared by
273
+ * setting any of the `facets`, `dateRange`, or `letterFilters` flags
274
+ * in the options object.
275
+ */
276
+ clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
277
+ // Don't bother clearing facets if none are checked, so that we don't
278
+ // trigger unnecessary update cycles.
279
+ if (facets && this.hasCheckedFacets) {
280
+ this.selectedFacets = getDefaultSelectedFacets();
281
+ }
282
+ if (dateRange) {
283
+ this.minSelectedDate = undefined;
284
+ this.maxSelectedDate = undefined;
285
+ }
286
+ if (letterFilters) {
287
+ this.selectedTitleFilter = null;
288
+ this.selectedCreatorFilter = null;
289
+ }
290
+ if (sort) {
291
+ this.sortDirection = null;
292
+ this.selectedSort = SortField.default;
293
+ }
294
+ }
295
+ /**
296
+ * Returns true if the current value of `this.selectedFacets` contains
297
+ * any facet buckets than have been selected or negated, or false otherwise.
298
+ */
299
+ get hasCheckedFacets() {
300
+ if (!this.selectedFacets)
301
+ return false;
302
+ for (const facetGroup of Object.values(this.selectedFacets)) {
303
+ for (const bucket of Object.values(facetGroup)) {
304
+ if (bucket.state !== 'none')
305
+ return true;
306
+ }
307
+ }
308
+ return false;
309
+ }
310
+ /**
311
+ * Returns true if there are any currently selected/negated facet buckets,
312
+ * any selected date range, or any selected letter filters. False otherwise.
313
+ *
314
+ * Ignores sorting options.
315
+ */
316
+ get hasActiveFilters() {
317
+ return !!(this.hasCheckedFacets ||
318
+ this.minSelectedDate ||
319
+ this.maxSelectedDate ||
320
+ this.selectedTitleFilter ||
321
+ this.selectedCreatorFilter);
322
+ }
323
+ willUpdate() {
324
+ this.setPlaceholderType();
325
+ }
326
+ render() {
327
327
  return html `
328
- ${this.showSmartFacetBar
328
+ ${this.showSmartFacetBar
329
329
  ? html ` <smart-facet-bar
330
330
  .query=${this.baseQuery}
331
331
  .aggregations=${this.dataSource.aggregations}
@@ -333,59 +333,59 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
333
333
  .collectionTitles=${this.dataSource.collectionTitles}
334
334
  .filterToggleActive=${this.facetPaneVisible}
335
335
  @facetsChanged=${this.facetsChanged}
336
- @filtersToggled=${() => {
337
- this.facetPaneVisible = !this.facetPaneVisible;
336
+ @filtersToggled=${() => {
337
+ this.facetPaneVisible = !this.facetPaneVisible;
338
338
  }}
339
- ></smart-facet-bar>`
339
+ ></smart-facet-bar>`
340
340
  : nothing}
341
341
 
342
342
  <div
343
343
  id="content-container"
344
344
  class=${this.mobileView ? 'mobile' : 'desktop'}
345
345
  >
346
- ${this.placeholderType
347
- ? this.emptyPlaceholderTemplate
346
+ ${this.placeholderType
347
+ ? this.emptyPlaceholderTemplate
348
348
  : this.collectionBrowserTemplate}
349
349
  </div>
350
- `;
351
- }
352
- /**
353
- * Determines what type of placeholder content should be shown instead of result tiles, if applicable.
354
- * The placeholders indicate states where we have no results to show, which could be the result of:
355
- * - No query is set (on the search page)
356
- * - No results were returned for the most recent search
357
- * - The collection being searched within has no viewable items
358
- * - An error occurred on the most recent search attempt
359
- */
360
- setPlaceholderType() {
361
- var _a;
362
- const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
363
- const isCollection = !!this.withinCollection;
364
- const isProfile = !!this.withinProfile;
365
- const noResults = !this.searchResultsLoading &&
366
- (this.dataSource.size === 0 || !this.searchService);
367
- this.placeholderType = null;
368
- if (this.suppressPlaceholders)
369
- return;
370
- if (!hasQuery && !isCollection && !isProfile) {
371
- this.placeholderType = 'empty-query';
372
- }
373
- else if (noResults) {
374
- // Within a collection, no query + no results means the collection simply has no viewable items.
375
- // Otherwise, we must have a user query that produced 0 results.
376
- this.placeholderType =
377
- !hasQuery && isCollection ? 'empty-collection' : 'no-results';
378
- }
379
- if (this.dataSource.queryErrorMessage) {
380
- this.placeholderType =
381
- !hasQuery && isCollection ? 'collection-error' : 'query-error';
382
- }
383
- }
384
- /**
385
- * Template for the placeholder content to show when no results are available.
386
- */
387
- get emptyPlaceholderTemplate() {
388
- var _a;
350
+ `;
351
+ }
352
+ /**
353
+ * Determines what type of placeholder content should be shown instead of result tiles, if applicable.
354
+ * The placeholders indicate states where we have no results to show, which could be the result of:
355
+ * - No query is set (on the search page)
356
+ * - No results were returned for the most recent search
357
+ * - The collection being searched within has no viewable items
358
+ * - An error occurred on the most recent search attempt
359
+ */
360
+ setPlaceholderType() {
361
+ var _a;
362
+ const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
363
+ const isCollection = !!this.withinCollection;
364
+ const isProfile = !!this.withinProfile;
365
+ const noResults = !this.searchResultsLoading &&
366
+ (this.dataSource.size === 0 || !this.searchService);
367
+ this.placeholderType = null;
368
+ if (this.suppressPlaceholders)
369
+ return;
370
+ if (!hasQuery && !isCollection && !isProfile) {
371
+ this.placeholderType = 'empty-query';
372
+ }
373
+ else if (noResults) {
374
+ // Within a collection, no query + no results means the collection simply has no viewable items.
375
+ // Otherwise, we must have a user query that produced 0 results.
376
+ this.placeholderType =
377
+ !hasQuery && isCollection ? 'empty-collection' : 'no-results';
378
+ }
379
+ if (this.dataSource.queryErrorMessage) {
380
+ this.placeholderType =
381
+ !hasQuery && isCollection ? 'collection-error' : 'query-error';
382
+ }
383
+ }
384
+ /**
385
+ * Template for the placeholder content to show when no results are available.
386
+ */
387
+ get emptyPlaceholderTemplate() {
388
+ var _a;
389
389
  return html `
390
390
  <empty-placeholder
391
391
  .placeholderType=${this.placeholderType}
@@ -394,33 +394,33 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
394
394
  .detailMessage=${(_a = this.dataSource.queryErrorMessage) !== null && _a !== void 0 ? _a : ''}
395
395
  .baseNavigationUrl=${this.baseNavigationUrl}
396
396
  ></empty-placeholder>
397
- `;
398
- }
399
- /**
400
- * Top-level template for rendering the left (facets) and right (results) columns.
401
- */
402
- get collectionBrowserTemplate() {
397
+ `;
398
+ }
399
+ /**
400
+ * Top-level template for rendering the left (facets) and right (results) columns.
401
+ */
402
+ get collectionBrowserTemplate() {
403
403
  return html `
404
404
  <div id="left-column-scroll-sentinel"></div>
405
405
  ${this.leftColumnTemplate} ${this.rightColumnTemplate}
406
- `;
407
- }
408
- /**
409
- * Template for either the mobile or desktop version of the left column, depending
410
- * on current component state.
411
- */
412
- get leftColumnTemplate() {
413
- if (this.mobileView) {
414
- return this.mobileLeftColumnTemplate;
415
- }
416
- return this.desktopLeftColumnTemplate;
417
- }
418
- /**
419
- * Template for the mobile version of the "left column" (which in this case, appears
420
- * *above* the search results rather than beside them), for rendering the
421
- * accordion-style facets.
422
- */
423
- get mobileLeftColumnTemplate() {
406
+ `;
407
+ }
408
+ /**
409
+ * Template for either the mobile or desktop version of the left column, depending
410
+ * on current component state.
411
+ */
412
+ get leftColumnTemplate() {
413
+ if (this.mobileView) {
414
+ return this.mobileLeftColumnTemplate;
415
+ }
416
+ return this.desktopLeftColumnTemplate;
417
+ }
418
+ /**
419
+ * Template for the mobile version of the "left column" (which in this case, appears
420
+ * *above* the search results rather than beside them), for rendering the
421
+ * accordion-style facets.
422
+ */
423
+ get mobileLeftColumnTemplate() {
424
424
  return html `
425
425
  <div
426
426
  id="left-column"
@@ -429,12 +429,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
429
429
  ${this.facetTopViewSlot} ${this.resultsCountTemplate}
430
430
  <div id="facets-header-container">${this.mobileFacetsTemplate}</div>
431
431
  </div>
432
- `;
433
- }
434
- /**
435
- * Template for the desktop version of the left column, displaying the facets sidebar.
436
- */
437
- get desktopLeftColumnTemplate() {
432
+ `;
433
+ }
434
+ /**
435
+ * Template for the desktop version of the left column, displaying the facets sidebar.
436
+ */
437
+ get desktopLeftColumnTemplate() {
438
438
  return html `
439
439
  <div
440
440
  id="left-column"
@@ -452,29 +452,29 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
452
452
  </div>
453
453
  <div id="facets-bottom-fade"></div>
454
454
  </div>
455
- `;
456
- }
457
- /**
458
- * Slot which is placed at top of the facets area for user-profile page
459
- * - mainly used to render userlists
460
- */
461
- get facetTopViewSlot() {
455
+ `;
456
+ }
457
+ /**
458
+ * Slot which is placed at top of the facets area for user-profile page
459
+ * - mainly used to render userlists
460
+ */
461
+ get facetTopViewSlot() {
462
462
  return html `<div id="facet-top-view">
463
463
  <slot name="facet-top-slot"></slot>
464
- </div>`;
465
- }
466
- /**
467
- * Template for the "X Results" count at the top of the search results.
468
- * Changes to the "Searching..." label if the search results are still loading.
469
- */
470
- get resultsCountTemplate() {
471
- var _a;
472
- if (this.suppressResultCount)
473
- return nothing;
474
- const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
475
- const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
476
- const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
477
- // Added data-testid for Playwright testing
464
+ </div>`;
465
+ }
466
+ /**
467
+ * Template for the "X Results" count at the top of the search results.
468
+ * Changes to the "Searching..." label if the search results are still loading.
469
+ */
470
+ get resultsCountTemplate() {
471
+ var _a;
472
+ if (this.suppressResultCount)
473
+ return nothing;
474
+ const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
475
+ const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
476
+ const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
477
+ // Added data-testid for Playwright testing
478
478
  return html `
479
479
  <div id="results-total" data-testid="results-total">
480
480
  <span id="big-results-count">
@@ -484,46 +484,46 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
484
484
  ${shouldShowSearching ? nothing : resultsLabel}
485
485
  </span>
486
486
  </div>
487
- `;
488
- }
489
- /**
490
- * Template for the right column of the collection browser, where the result
491
- * tiles and sort/filter bar are shown.
492
- */
493
- get rightColumnTemplate() {
487
+ `;
488
+ }
489
+ /**
490
+ * Template for the right column of the collection browser, where the result
491
+ * tiles and sort/filter bar are shown.
492
+ */
493
+ get rightColumnTemplate() {
494
494
  return html `
495
495
  <div
496
496
  id="right-column"
497
497
  class="column ${this.showSmartResults ? 'smart-results-spacing' : ''}"
498
498
  >
499
- ${this.showSmartResults
500
- ? html `<slot name="smart-results"></slot>`
499
+ ${this.showSmartResults
500
+ ? html `<slot name="smart-results"></slot>`
501
501
  : nothing}
502
502
  <section id="results">
503
- ${this.showSmartResults
503
+ ${this.showSmartResults
504
504
  ? html `<h2 class="results-section-heading">
505
505
  ${msg('All results')}
506
- </h2>`
506
+ </h2>`
507
507
  : nothing}
508
508
  <div id="cb-top-view">
509
509
  <slot name="cb-top-slot"></slot>
510
510
  </div>
511
- ${this.isManageView
512
- ? this.manageBarTemplate
511
+ ${this.isManageView
512
+ ? this.manageBarTemplate
513
513
  : this.sortFilterBarTemplate}
514
514
  <slot name="cb-results"></slot>
515
- ${this.displayMode === `list-compact` && this.totalResults
516
- ? this.listHeaderTemplate
515
+ ${this.displayMode === `list-compact` && this.totalResults
516
+ ? this.listHeaderTemplate
517
517
  : nothing}
518
518
  ${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
519
519
  </section>
520
520
  </div>
521
- `;
522
- }
523
- /**
524
- * Template for the infinite scroller widget that contains the result tiles.
525
- */
526
- get infiniteScrollerTemplate() {
521
+ `;
522
+ }
523
+ /**
524
+ * Template for the infinite scroller widget that contains the result tiles.
525
+ */
526
+ get infiniteScrollerTemplate() {
527
527
  return html `<infinite-scroller
528
528
  class=${this.infiniteScrollerClasses}
529
529
  itemCount=${this.placeholderType ? 0 : nothing}
@@ -532,29 +532,29 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
532
532
  .placeholderCellTemplate=${this.placeholderCellTemplate}
533
533
  @scrollThresholdReached=${this.scrollThresholdReached}
534
534
  @visibleCellsChanged=${this.visibleCellsChanged}
535
- >${this.displayMode === 'grid'
536
- ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
535
+ >${this.displayMode === 'grid'
536
+ ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
537
537
  : nothing}
538
- </infinite-scroller>`;
539
- }
540
- /**
541
- * Produces a `classMap` indicating which classes the infinite scroller should have
542
- * given the current display mode & placeholder case.
543
- */
544
- get infiniteScrollerClasses() {
545
- var _a;
546
- return classMap({
547
- [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
548
- hidden: !!this.placeholderType,
549
- });
550
- }
551
- /**
552
- * Template for the sort & filtering bar that appears atop the search results.
553
- */
554
- get sortFilterBarTemplate() {
555
- var _a;
556
- if (this.suppressSortBar)
557
- return nothing;
538
+ </infinite-scroller>`;
539
+ }
540
+ /**
541
+ * Produces a `classMap` indicating which classes the infinite scroller should have
542
+ * given the current display mode & placeholder case.
543
+ */
544
+ get infiniteScrollerClasses() {
545
+ var _a;
546
+ return classMap({
547
+ [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
548
+ hidden: !!this.placeholderType,
549
+ });
550
+ }
551
+ /**
552
+ * Template for the sort & filtering bar that appears atop the search results.
553
+ */
554
+ get sortFilterBarTemplate() {
555
+ var _a;
556
+ if (this.suppressSortBar)
557
+ return nothing;
558
558
  return html `
559
559
  <sort-filter-bar
560
560
  .defaultSortField=${this.defaultSortField}
@@ -579,216 +579,231 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
579
579
  <slot name="sort-options" slot="sort-options"></slot>
580
580
  <slot name="sort-options-right" slot="sort-options-right"></slot>
581
581
  </sort-filter-bar>
582
- `;
583
- }
584
- /**
585
- * Template for the manage bar UI that appears atop the search results when we are
586
- * showing the management view. This generally replaces the sort bar when present.
587
- */
588
- get manageBarTemplate() {
582
+ `;
583
+ }
584
+ /**
585
+ * Template for the manage bar UI that appears atop the search results when we are
586
+ * showing the management view. This generally replaces the sort bar when present.
587
+ */
588
+ get manageBarTemplate() {
589
589
  return html `
590
590
  <manage-bar
591
591
  .label=${this.manageViewLabel}
592
+ .pageContext=${this.pageContext}
592
593
  showSelectAll
593
594
  showUnselectAll
594
595
  ?removeAllowed=${this.dataSource.checkedTileModels.length !== 0}
595
596
  @removeItems=${this.handleRemoveItems}
597
+ @itemsManager=${this.handleItemsManager}
596
598
  @selectAll=${() => this.dataSource.checkAllTiles()}
597
599
  @unselectAll=${() => this.dataSource.uncheckAllTiles()}
598
- @cancel=${() => {
599
- this.isManageView = false;
600
- this.dataSource.uncheckAllTiles();
600
+ @cancel=${() => {
601
+ this.isManageView = false;
602
+ this.dataSource.uncheckAllTiles();
601
603
  }}
602
604
  ></manage-bar>
603
- `;
604
- }
605
- /**
606
- * Handler for when the user requests to remove all checked items via the manage bar.
607
- * Emits an `itemRemovalRequested` event with all checked tile models.
608
- */
609
- handleRemoveItems() {
610
- this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
611
- detail: {
612
- items: this.dataSource.checkedTileModels.map(model => {
613
- const cloned = model.clone();
614
- cloned.dateStr = formatDate(model.datePublished, 'long');
615
- return cloned;
616
- }),
617
- },
618
- }));
619
- }
620
- /**
621
- * Removes all tile models that are currently checked & adjusts the paging
622
- * of the data source to account for any new gaps in the data.
623
- */
624
- removeCheckedTiles() {
625
- this.dataSource.removeCheckedTiles();
626
- }
627
- /**
628
- * Handler for when the user changes the selected sort option or direction.
629
- */
630
- userChangedSort(e) {
631
- var _a;
632
- const { selectedSort, sortDirection } = e.detail;
633
- this.selectedSort = selectedSort;
634
- this.sortDirection = sortDirection;
635
- if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
636
- this.goToPage(1);
637
- }
638
- this.currentPage = 1;
639
- }
640
- /**
641
- * Fires an analytics event for sorting changes.
642
- * @param prevSortDirection Which sort direction was previously set.
643
- */
644
- sendSortByAnalytics(prevSortDirection) {
645
- var _a;
646
- const directionCleared = prevSortDirection && !this.sortDirection;
647
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
648
- category: this.searchContext,
649
- action: analyticsActions.sortBy,
650
- label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
651
- });
652
- }
653
- /**
654
- * Handler for when the selected sort option is updated, whether by the user
655
- * themselves or programmatically.
656
- */
657
- selectedSortChanged() {
658
- // Lazy-load the alphabet counts for title/creator sort bar as needed
659
- this.dataSource.updatePrefixFiltersForCurrentSort();
660
- }
661
- /**
662
- * An object representing the current sort field & direction.
663
- */
664
- get sortParam() {
665
- var _a;
666
- const sortOption = SORT_OPTIONS[this.selectedSort];
667
- if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
668
- return null;
669
- }
670
- // If the sort option specified in the URL is unrecognized, we just use it as-is
671
- const urlSortParam = new URL(window.location.href).searchParams.get('sort');
672
- const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
673
- // If the sort direction is still null at this point, then we assume ascending
674
- // (i.e., it was unrecognized and had no directional flag)
675
- if (!this.sortDirection)
676
- this.sortDirection = 'asc';
677
- if (!sortField)
678
- return null;
679
- return { field: sortField, direction: this.sortDirection };
680
- }
681
- /**
682
- * An object representing the default sort field & direction, if none are explicitly set.
683
- */
684
- get defaultSortParam() {
685
- var _a;
686
- const direction = (_a = this.defaultSortDirection) !== null && _a !== void 0 ? _a : 'asc';
687
- const field = SORT_OPTIONS[this.defaultSortField].searchServiceKey;
688
- if (!field)
689
- return null;
690
- return { field, direction };
691
- }
692
- /**
693
- * Handler for when the display mode option is changed (grid/list/compact-list views).
694
- */
695
- displayModeChanged(e) {
696
- var _a;
697
- this.displayMode = e.detail.displayMode;
698
- if (this.displayMode) {
699
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
700
- category: this.searchContext,
701
- action: analyticsActions.displayMode,
702
- label: this.displayMode,
703
- });
704
- }
705
- }
706
- /**
707
- * Returns a query clause identifying the currently selected title filter,
708
- * e.g., `firstTitle:X`.
709
- */
710
- get titleQuery() {
711
- return this.selectedTitleFilter
712
- ? `firstTitle:${this.selectedTitleFilter}`
713
- : undefined;
714
- }
715
- /**
716
- * Returns a query clause identifying the currently selected creator filter,
717
- * e.g., `firstCreator:X`.
718
- */
719
- get creatorQuery() {
720
- return this.selectedCreatorFilter
721
- ? `firstCreator:${this.selectedCreatorFilter}`
722
- : undefined;
723
- }
724
- /**
725
- * Send Analytics when sorting by title's first letter
726
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
727
- */
728
- sendFilterByTitleAnalytics(prevSelectedLetter) {
729
- var _a;
730
- if (!prevSelectedLetter && !this.selectedTitleFilter) {
731
- return;
732
- }
733
- const cleared = prevSelectedLetter && !this.selectedTitleFilter;
734
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
735
- category: this.searchContext,
736
- action: analyticsActions.filterByTitle,
737
- label: cleared
738
- ? `clear-${prevSelectedLetter}`
739
- : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
740
- });
741
- }
742
- /**
743
- * Send Analytics when filtering by creator's first letter
744
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
745
- */
746
- sendFilterByCreatorAnalytics(prevSelectedLetter) {
747
- var _a;
748
- if (!prevSelectedLetter && !this.selectedCreatorFilter) {
749
- return;
750
- }
751
- const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
752
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
753
- category: this.searchContext,
754
- action: analyticsActions.filterByCreator,
755
- label: cleared
756
- ? `clear-${prevSelectedLetter}`
757
- : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
758
- });
759
- }
760
- /**
761
- * Handler for changes to which letter is selected in the title alphabet bar.
762
- */
763
- titleLetterSelected(e) {
764
- this.selectedCreatorFilter = null;
765
- this.selectedTitleFilter = e.detail.selectedLetter;
766
- }
767
- /**
768
- * Handler for changes to which letter is selected in the creator alphabet bar.
769
- */
770
- creatorLetterSelected(e) {
771
- this.selectedTitleFilter = null;
772
- this.selectedCreatorFilter = e.detail.selectedLetter;
773
- }
774
- /**
775
- * The full template for how the facets should be structured in mobile view,
776
- * including the collapsible container (with header) and the facets themselves.
777
- */
778
- get mobileFacetsTemplate() {
779
- if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
780
- return nothing;
781
- const toggleFacetsVisible = (e) => {
782
- var _a;
783
- const target = e.target;
784
- this.isResizeToMobile = false;
785
- this.collapsibleFacetsVisible = target.open;
786
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
787
- category: this.searchContext,
788
- action: analyticsActions.mobileFacetsToggled,
789
- label: target.open ? 'open' : 'closed',
790
- });
791
- };
605
+ `;
606
+ }
607
+ /**
608
+ * Handler for when the user requests to remove all checked items via the manage bar.
609
+ * Emits an `itemRemovalRequested` event with all checked tile models.
610
+ */
611
+ handleRemoveItems() {
612
+ this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
613
+ detail: {
614
+ items: this.dataSource.checkedTileModels.map(model => {
615
+ const cloned = model.clone();
616
+ cloned.dateStr = formatDate(model.datePublished, 'long');
617
+ return cloned;
618
+ }),
619
+ },
620
+ }));
621
+ }
622
+ /**
623
+ * Handler when user request to bulk edit from /search/ page
624
+ */
625
+ handleItemsManager() {
626
+ this.dispatchEvent(new CustomEvent('itemsManagerRequested', {
627
+ detail: {
628
+ items: this.dataSource.checkedTileModels
629
+ .map(item => item.identifier)
630
+ .filter(Boolean)
631
+ .join(','),
632
+ },
633
+ }));
634
+ }
635
+ /**
636
+ * Removes all tile models that are currently checked & adjusts the paging
637
+ * of the data source to account for any new gaps in the data.
638
+ */
639
+ removeCheckedTiles() {
640
+ this.dataSource.removeCheckedTiles();
641
+ }
642
+ /**
643
+ * Handler for when the user changes the selected sort option or direction.
644
+ */
645
+ userChangedSort(e) {
646
+ var _a;
647
+ const { selectedSort, sortDirection } = e.detail;
648
+ this.selectedSort = selectedSort;
649
+ this.sortDirection = sortDirection;
650
+ if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
651
+ this.goToPage(1);
652
+ }
653
+ this.currentPage = 1;
654
+ }
655
+ /**
656
+ * Fires an analytics event for sorting changes.
657
+ * @param prevSortDirection Which sort direction was previously set.
658
+ */
659
+ sendSortByAnalytics(prevSortDirection) {
660
+ var _a;
661
+ const directionCleared = prevSortDirection && !this.sortDirection;
662
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
663
+ category: this.searchContext,
664
+ action: analyticsActions.sortBy,
665
+ label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
666
+ });
667
+ }
668
+ /**
669
+ * Handler for when the selected sort option is updated, whether by the user
670
+ * themselves or programmatically.
671
+ */
672
+ selectedSortChanged() {
673
+ // Lazy-load the alphabet counts for title/creator sort bar as needed
674
+ this.dataSource.updatePrefixFiltersForCurrentSort();
675
+ }
676
+ /**
677
+ * An object representing the current sort field & direction.
678
+ */
679
+ get sortParam() {
680
+ var _a;
681
+ const sortOption = SORT_OPTIONS[this.selectedSort];
682
+ if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
683
+ return null;
684
+ }
685
+ // If the sort option specified in the URL is unrecognized, we just use it as-is
686
+ const urlSortParam = new URL(window.location.href).searchParams.get('sort');
687
+ const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
688
+ // If the sort direction is still null at this point, then we assume ascending
689
+ // (i.e., it was unrecognized and had no directional flag)
690
+ if (!this.sortDirection)
691
+ this.sortDirection = 'asc';
692
+ if (!sortField)
693
+ return null;
694
+ return { field: sortField, direction: this.sortDirection };
695
+ }
696
+ /**
697
+ * An object representing the default sort field & direction, if none are explicitly set.
698
+ */
699
+ get defaultSortParam() {
700
+ var _a;
701
+ const direction = (_a = this.defaultSortDirection) !== null && _a !== void 0 ? _a : 'asc';
702
+ const field = SORT_OPTIONS[this.defaultSortField].searchServiceKey;
703
+ if (!field)
704
+ return null;
705
+ return { field, direction };
706
+ }
707
+ /**
708
+ * Handler for when the display mode option is changed (grid/list/compact-list views).
709
+ */
710
+ displayModeChanged(e) {
711
+ var _a;
712
+ this.displayMode = e.detail.displayMode;
713
+ if (this.displayMode) {
714
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
715
+ category: this.searchContext,
716
+ action: analyticsActions.displayMode,
717
+ label: this.displayMode,
718
+ });
719
+ }
720
+ }
721
+ /**
722
+ * Returns a query clause identifying the currently selected title filter,
723
+ * e.g., `firstTitle:X`.
724
+ */
725
+ get titleQuery() {
726
+ return this.selectedTitleFilter
727
+ ? `firstTitle:${this.selectedTitleFilter}`
728
+ : undefined;
729
+ }
730
+ /**
731
+ * Returns a query clause identifying the currently selected creator filter,
732
+ * e.g., `firstCreator:X`.
733
+ */
734
+ get creatorQuery() {
735
+ return this.selectedCreatorFilter
736
+ ? `firstCreator:${this.selectedCreatorFilter}`
737
+ : undefined;
738
+ }
739
+ /**
740
+ * Send Analytics when sorting by title's first letter
741
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
742
+ */
743
+ sendFilterByTitleAnalytics(prevSelectedLetter) {
744
+ var _a;
745
+ if (!prevSelectedLetter && !this.selectedTitleFilter) {
746
+ return;
747
+ }
748
+ const cleared = prevSelectedLetter && !this.selectedTitleFilter;
749
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
750
+ category: this.searchContext,
751
+ action: analyticsActions.filterByTitle,
752
+ label: cleared
753
+ ? `clear-${prevSelectedLetter}`
754
+ : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
755
+ });
756
+ }
757
+ /**
758
+ * Send Analytics when filtering by creator's first letter
759
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
760
+ */
761
+ sendFilterByCreatorAnalytics(prevSelectedLetter) {
762
+ var _a;
763
+ if (!prevSelectedLetter && !this.selectedCreatorFilter) {
764
+ return;
765
+ }
766
+ const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
767
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
768
+ category: this.searchContext,
769
+ action: analyticsActions.filterByCreator,
770
+ label: cleared
771
+ ? `clear-${prevSelectedLetter}`
772
+ : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
773
+ });
774
+ }
775
+ /**
776
+ * Handler for changes to which letter is selected in the title alphabet bar.
777
+ */
778
+ titleLetterSelected(e) {
779
+ this.selectedCreatorFilter = null;
780
+ this.selectedTitleFilter = e.detail.selectedLetter;
781
+ }
782
+ /**
783
+ * Handler for changes to which letter is selected in the creator alphabet bar.
784
+ */
785
+ creatorLetterSelected(e) {
786
+ this.selectedTitleFilter = null;
787
+ this.selectedCreatorFilter = e.detail.selectedLetter;
788
+ }
789
+ /**
790
+ * The full template for how the facets should be structured in mobile view,
791
+ * including the collapsible container (with header) and the facets themselves.
792
+ */
793
+ get mobileFacetsTemplate() {
794
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
795
+ return nothing;
796
+ const toggleFacetsVisible = (e) => {
797
+ var _a;
798
+ const target = e.target;
799
+ this.isResizeToMobile = false;
800
+ this.collapsibleFacetsVisible = target.open;
801
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
802
+ category: this.searchContext,
803
+ action: analyticsActions.mobileFacetsToggled,
804
+ label: target.open ? 'open' : 'closed',
805
+ });
806
+ };
792
807
  return html `
793
808
  <details id="mobile-filter-collapse" @toggle=${toggleFacetsVisible}>
794
809
  <summary>
@@ -798,21 +813,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
798
813
  </summary>
799
814
  ${this.facetsTemplate}
800
815
  </details>
801
- `;
802
- }
803
- /**
804
- * The template for the facets component alone, without any surrounding wrappers.
805
- */
806
- get facetsTemplate() {
807
- if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
808
- return nothing;
809
- if (this.facetLoadStrategy === 'off') {
816
+ `;
817
+ }
818
+ /**
819
+ * The template for the facets component alone, without any surrounding wrappers.
820
+ */
821
+ get facetsTemplate() {
822
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
823
+ return nothing;
824
+ if (this.facetLoadStrategy === 'off') {
810
825
  return html `
811
826
  <p class="facets-message">
812
827
  ${msg('Facets are temporarily unavailable.')}
813
828
  </p>
814
- `;
815
- }
829
+ `;
830
+ }
816
831
  const facets = html `
817
832
  <collection-facets
818
833
  @facetsChanged=${this.facetsChanged}
@@ -826,7 +841,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
826
841
  .resizeObserver=${this.resizeObserver}
827
842
  .searchType=${this.searchType}
828
843
  .aggregations=${this.dataSource.aggregations}
829
- .fullYearsHistogramAggregation=${this.dataSource
844
+ .fullYearsHistogramAggregation=${this.dataSource
830
845
  .yearHistogramAggregation}
831
846
  .minSelectedDate=${this.minSelectedDate}
832
847
  .maxSelectedDate=${this.maxSelectedDate}
@@ -847,19 +862,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
847
862
  .analyticsHandler=${this.analyticsHandler}
848
863
  >
849
864
  </collection-facets>
850
- `;
851
- // If we are using one of the opt-in facet load strategies, we may need to wrap the
852
- // desktop view facets in a <details> widget so that patrons can opt into loading them.
853
- // In the `opt-in-or-login` case, we only do this if they are not logged in.
854
- const showDesktopOptInWidget = this.facetLoadStrategy === 'opt-in' ||
855
- (this.facetLoadStrategy === 'opt-in-or-login' && !this.loggedIn);
856
- if (showDesktopOptInWidget && !this.mobileView) {
865
+ `;
866
+ // If we are using one of the opt-in facet load strategies, we may need to wrap the
867
+ // desktop view facets in a <details> widget so that patrons can opt into loading them.
868
+ // In the `opt-in-or-login` case, we only do this if they are not logged in.
869
+ const showDesktopOptInWidget = this.facetLoadStrategy === 'opt-in' ||
870
+ (this.facetLoadStrategy === 'opt-in-or-login' && !this.loggedIn);
871
+ if (showDesktopOptInWidget && !this.mobileView) {
857
872
  return html `
858
873
  <details
859
874
  class="desktop-facets-dropdown"
860
- @toggle=${(e) => {
861
- const target = e.target;
862
- this.collapsibleFacetsVisible = target.open;
875
+ @toggle=${(e) => {
876
+ const target = e.target;
877
+ this.collapsibleFacetsVisible = target.open;
863
878
  }}
864
879
  >
865
880
  <summary>
@@ -868,40 +883,40 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
868
883
  </summary>
869
884
  ${facets}
870
885
  </button>
871
- `;
872
- }
873
- // Otherwise, just render the facets component bare
874
- return facets;
875
- }
876
- /**
877
- * The HTML template for the "Clear all filters" button, or `nothing` if no
878
- * filters are currently active.
879
- *
880
- * @param mobile Whether to style/shorten the button for mobile view
881
- */
882
- clearFiltersBtnTemplate(mobile) {
883
- if (!this.hasActiveFilters)
884
- return nothing;
885
- const buttonClasses = classMap({
886
- 'clear-filters-btn': true,
887
- mobile,
888
- });
889
- const buttonText = mobile ? 'Clear all' : 'Clear all filters';
886
+ `;
887
+ }
888
+ // Otherwise, just render the facets component bare
889
+ return facets;
890
+ }
891
+ /**
892
+ * The HTML template for the "Clear all filters" button, or `nothing` if no
893
+ * filters are currently active.
894
+ *
895
+ * @param mobile Whether to style/shorten the button for mobile view
896
+ */
897
+ clearFiltersBtnTemplate(mobile) {
898
+ if (!this.hasActiveFilters)
899
+ return nothing;
900
+ const buttonClasses = classMap({
901
+ 'clear-filters-btn': true,
902
+ mobile,
903
+ });
904
+ const buttonText = mobile ? 'Clear all' : 'Clear all filters';
890
905
  return html `
891
906
  <div class="clear-filters-btn-row">
892
- ${mobile
893
- ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
907
+ ${mobile
908
+ ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
894
909
  : nothing}
895
910
  <button class=${buttonClasses} @click=${this.clearFilters}>
896
911
  ${buttonText}
897
912
  </button>
898
913
  </div>
899
- `;
900
- }
901
- /**
902
- * Template for the table header content that appears atop the compact list view.
903
- */
904
- get listHeaderTemplate() {
914
+ `;
915
+ }
916
+ /**
917
+ * Template for the table header content that appears atop the compact list view.
918
+ */
919
+ get listHeaderTemplate() {
905
920
  return html `
906
921
  <div id="list-header">
907
922
  <tile-dispatcher
@@ -914,707 +929,707 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
914
929
  >
915
930
  </tile-dispatcher>
916
931
  </div>
917
- `;
918
- }
919
- /**
920
- * Handler for when the date picker's date range is changed.
921
- */
922
- histogramDateRangeUpdated(e) {
923
- var _a;
924
- const { minDate, maxDate } = e.detail;
925
- [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
926
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
927
- category: this.searchContext,
928
- action: analyticsActions.histogramChanged,
929
- label: this.dateRangeQueryClause,
930
- });
931
- }
932
- /**
933
- * The Lucene query corresponding to the current date range.
934
- */
935
- get dateRangeQueryClause() {
936
- if (!this.minSelectedDate || !this.maxSelectedDate) {
937
- return undefined;
938
- }
939
- return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
940
- }
941
- /**
942
- * Emits an event indicating a change in whether the manage mode is shown.
943
- */
944
- emitManageModeChangedEvent() {
945
- this.dispatchEvent(new CustomEvent('manageModeChanged', {
946
- detail: this.isManageView,
947
- }));
948
- }
949
- /**
950
- * Installs a new data source component and associated query state parameters into
951
- * this component, causing it to efficiently update its views to represent the
952
- * newly-provided data. In this way, one can reuse a single instance of
953
- * <collection-browser> to handle multiple different sets of search results on
954
- * a single page, each set of results being loaded & updated by its own data
955
- * source.
956
- *
957
- * @param dataSource The data source component containing (or prepared to fetch)
958
- * the tile data to be displayed.
959
- * @param queryState The new query-related state that this component should
960
- * represent, such as the search query, sort option, and any filters applied.
961
- */
962
- async installDataSourceAndQueryState(dataSource, queryState) {
963
- var _a, _b;
964
- log('Installing data source & query state in CB:', dataSource, queryState);
965
- if (this.dataSource)
966
- this.removeController(this.dataSource);
967
- this.dataSource = dataSource;
968
- this.addController(this.dataSource);
969
- this.baseQuery = queryState.baseQuery;
970
- this.profileElement = queryState.profileElement;
971
- this.searchType = queryState.searchType;
972
- this.selectedFacets =
973
- (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
974
- this.minSelectedDate = queryState.minSelectedDate;
975
- this.maxSelectedDate = queryState.maxSelectedDate;
976
- this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
977
- this.sortDirection = queryState.sortDirection;
978
- this.selectedTitleFilter = queryState.selectedTitleFilter;
979
- this.selectedCreatorFilter = queryState.selectedCreatorFilter;
980
- // We set this flag during the update to prevent the URL state persistence
981
- // from creating an unwanted extra history entry.
982
- this.dataSourceInstallInProgress = true;
983
- this.requestUpdate();
984
- await this.updateComplete;
985
- this.dataSourceInstallInProgress = false;
986
- if (!this.searchResultsLoading) {
987
- this.setTotalResultCount(this.dataSource.totalResults);
988
- this.setTileCount(this.dataSource.size);
989
- }
990
- this.refreshVisibleResults();
991
- }
992
- firstUpdated() {
993
- this.restoreState();
994
- this.setInitialSize();
995
- }
996
- /**
997
- * Determines the initial size of the content container and whether or not
998
- * the mobile layout should be used.
999
- */
1000
- setInitialSize() {
1001
- this.contentWidth = this.contentContainer.getBoundingClientRect().width;
1002
- this.mobileView =
1003
- this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1004
- this.sendLayoutSizeAnalytics();
1005
- }
1006
- /**
1007
- * Fires an analytics event indicating which type of layout was rendered:
1008
- * mobile or desktop.
1009
- */
1010
- sendLayoutSizeAnalytics() {
1011
- if (this.analyticsHandler) {
1012
- this.layoutSizeAnalyticsSent = true;
1013
- this.analyticsHandler.sendEvent({
1014
- category: this.searchContext,
1015
- action: this.mobileView
1016
- ? analyticsActions.loadMobileView
1017
- : analyticsActions.loadDesktopView,
1018
- });
1019
- }
1020
- }
1021
- updated(changed) {
1022
- var _a, _b;
1023
- if (changed.has('placeholderType') && this.placeholderType === null) {
1024
- if (!this.leftColIntersectionObserver) {
1025
- this.setupLeftColumnScrollListeners();
1026
- }
1027
- if (!this.facetsIntersectionObserver) {
1028
- this.setupFacetsScrollListeners();
1029
- }
1030
- this.updateLeftColumnHeight();
1031
- }
1032
- if (changed.has('analyticsHandler') && !this.layoutSizeAnalyticsSent) {
1033
- this.sendLayoutSizeAnalytics();
1034
- }
1035
- if (changed.has('displayMode') ||
1036
- changed.has('baseNavigationUrl') ||
1037
- changed.has('baseImageUrl') ||
1038
- changed.has('loggedIn')) {
1039
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1040
- }
1041
- if (changed.has('baseQuery') ||
1042
- changed.has('searchType') ||
1043
- changed.has('withinCollection')) {
1044
- // Unless this query/search type update is from the initial page load or the
1045
- // result of hitting the back button,
1046
- // we need to clear any existing filters since they may no longer be valid for
1047
- // the new set of search results.
1048
- if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
1049
- // Ordinarily, we leave the sort param unchanged between searches.
1050
- // However, if we are changing the target collection itself, we want the sort cleared too,
1051
- // since different collections may have different sorting options available.
1052
- const shouldClearSort = changed.has('withinCollection') &&
1053
- !changed.has('selectedSort') &&
1054
- !changed.has('sortDirection');
1055
- // Otherwise, only clear filters that haven't been simultaneously applied in this update
1056
- this.clearFilters({
1057
- sort: shouldClearSort,
1058
- facets: !changed.has('selectedFacets'),
1059
- dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
1060
- letterFilters: !(changed.has('selectedTitleFilter') ||
1061
- changed.has('selectedCreatorFilter')),
1062
- });
1063
- }
1064
- }
1065
- if (changed.has('profileElement')) {
1066
- this.applyDefaultProfileSort();
1067
- }
1068
- if (changed.has('baseQuery')) {
1069
- this.emitBaseQueryChanged();
1070
- }
1071
- if (changed.has('searchType')) {
1072
- this.emitSearchTypeChanged();
1073
- }
1074
- if (changed.has('currentPage') || changed.has('displayMode')) {
1075
- this.persistState();
1076
- }
1077
- if (changed.has('baseQuery') ||
1078
- changed.has('minSelectedDate') ||
1079
- changed.has('maxSelectedDate') ||
1080
- changed.has('selectedFacets') ||
1081
- changed.has('searchService') ||
1082
- changed.has('withinCollection') ||
1083
- changed.has('withinProfile') ||
1084
- changed.has('profileElement')) {
1085
- this.dataSource.refreshLetterCounts();
1086
- }
1087
- if (changed.has('selectedSort') || changed.has('sortDirection')) {
1088
- const prevSortDirection = changed.get('sortDirection');
1089
- this.sendSortByAnalytics(prevSortDirection);
1090
- this.selectedSortChanged();
1091
- }
1092
- if (changed.has('selectedTitleFilter')) {
1093
- this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
1094
- }
1095
- if (changed.has('selectedCreatorFilter')) {
1096
- this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
1097
- }
1098
- this.updateFacetReadiness();
1099
- if (changed.has('baseQuery') ||
1100
- changed.has('searchType') ||
1101
- changed.has('selectedTitleFilter') ||
1102
- changed.has('selectedCreatorFilter') ||
1103
- changed.has('minSelectedDate') ||
1104
- changed.has('maxSelectedDate') ||
1105
- changed.has('selectedSort') ||
1106
- changed.has('sortDirection') ||
1107
- changed.has('selectedFacets') ||
1108
- changed.has('searchService') ||
1109
- changed.has('withinCollection') ||
1110
- changed.has('withinProfile') ||
1111
- changed.has('profileElement')) {
1112
- this.handleQueryChange();
1113
- }
1114
- if (changed.has('searchResultsLoading')) {
1115
- this.emitSearchResultsLoadingChanged();
1116
- }
1117
- if (changed.has('facetsLoading') &&
1118
- this.facetsLoading &&
1119
- this.collectionFacets) {
1120
- this.collectionFacets.moreLinksVisible =
1121
- this.searchType !== SearchType.FULLTEXT;
1122
- }
1123
- if (changed.has('pagesToRender')) {
1124
- if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1125
- this.infiniteScroller.itemCount = this.estimatedTileCount;
1126
- }
1127
- }
1128
- if (changed.has('isManageView')) {
1129
- if (this.isManageView)
1130
- this.displayMode = 'grid';
1131
- (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.refreshAllVisibleCells();
1132
- this.emitManageModeChangedEvent();
1133
- }
1134
- if (changed.has('resizeObserver')) {
1135
- const oldObserver = changed.get('resizeObserver');
1136
- if (oldObserver)
1137
- this.disconnectResizeObserver(oldObserver);
1138
- this.setupResizeObserver();
1139
- }
1140
- this.ensureAvailableTilesDisplayed();
1141
- }
1142
- connectedCallback() {
1143
- var _a;
1144
- (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
1145
- this.setupStateRestorationObserver();
1146
- this.setupResizeObserver();
1147
- }
1148
- disconnectedCallback() {
1149
- var _a, _b;
1150
- if (this.resizeObserver) {
1151
- this.disconnectResizeObserver(this.resizeObserver);
1152
- }
1153
- if (this.boundNavigationHandler) {
1154
- window.removeEventListener('popstate', this.boundNavigationHandler);
1155
- }
1156
- (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1157
- (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
1158
- window.removeEventListener('resize', this.updateLeftColumnHeight);
1159
- }
1160
- handleResize(entry) {
1161
- const previousView = this.mobileView;
1162
- if (entry.target === this.contentContainer) {
1163
- this.contentWidth = entry.contentRect.width;
1164
- this.mobileView =
1165
- this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1166
- // If changing from desktop to mobile disable transition
1167
- if (this.mobileView && !previousView) {
1168
- this.isResizeToMobile = true;
1169
- }
1170
- }
1171
- // Ensure the facet sidebar remains sized correctly
1172
- this.updateLeftColumnHeight();
1173
- }
1174
- /**
1175
- * Ensures that if we have new results from the data source that are not yet
1176
- * displayed in the infinite scroller, that they are immediately reflected
1177
- * in the tile count.
1178
- */
1179
- ensureAvailableTilesDisplayed() {
1180
- if (this.infiniteScroller &&
1181
- this.infiniteScroller.itemCount < this.dataSource.size) {
1182
- this.setTileCount(this.dataSource.endOfDataReached
1183
- ? this.dataSource.size
1184
- : this.estimatedTileCount);
1185
- }
1186
- }
1187
- /**
1188
- * Updates the data source with the current state of facet readiness for loading,
1189
- * so that they will begin to load in at the appropriate time according to the
1190
- * current facet loading strategy.
1191
- */
1192
- updateFacetReadiness() {
1193
- // There are two ways to opt into facet production:
1194
- // (1) have the facets dropdown open, or
1195
- // (2) if using the `opt-in-or-login` strategy, be logged into an account
1196
- const optedIn = this.collapsibleFacetsVisible ||
1197
- (this.facetLoadStrategy === 'opt-in-or-login' && this.loggedIn);
1198
- // In desktop view, we are always ready to load facets *unless* we are using one of the
1199
- // `opt-in` strategies and have not opted in (whether by login or UI interaction).
1200
- const usingOptInStrategy = ['opt-in', 'opt-in-or-login'].includes(this.facetLoadStrategy);
1201
- const desktopFacetsReady = !this.mobileView && (!usingOptInStrategy || optedIn);
1202
- // In the mobile view, facets are considered ready provided we have opted in (whether by
1203
- // login or UI interaction).
1204
- const mobileFacetsReady = this.mobileView && optedIn;
1205
- this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
1206
- }
1207
- /**
1208
- * Sets up listeners for events that may require updating the left column height.
1209
- */
1210
- setupLeftColumnScrollListeners() {
1211
- var _a;
1212
- // We observe intersections between the left column's scroll sentinel and
1213
- // the viewport, so that we can ensure the left column is always sized to
1214
- // match the _available_ viewport height. This should generally be more
1215
- // performant than listening to scroll events on the page or column.
1216
- const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1217
- if (leftColumnSentinel) {
1218
- this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1219
- threshold: [...Array(101).keys()].map(n => n / 100), // Threshold every 1%
1220
- });
1221
- this.leftColIntersectionObserver.observe(leftColumnSentinel);
1222
- }
1223
- // We also listen for window resize events, as they are not always captured
1224
- // by the resize observer and can affect the desired height of the left column.
1225
- window.addEventListener('resize', this.updateLeftColumnHeight);
1226
- }
1227
- /**
1228
- * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1229
- * Note this uses a separate IntersectionObserver from the left column, because we
1230
- * don't need granular intersection thresholds for this.
1231
- */
1232
- setupFacetsScrollListeners() {
1233
- var _a;
1234
- const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1235
- if (facetsSentinel) {
1236
- this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1237
- this.facetsIntersectionObserver.observe(facetsSentinel);
1238
- }
1239
- }
1240
- /**
1241
- * Emits a `baseQueryChanged` event indicating an update to the search query.
1242
- */
1243
- emitBaseQueryChanged() {
1244
- this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1245
- detail: {
1246
- baseQuery: this.baseQuery,
1247
- },
1248
- }));
1249
- }
1250
- /**
1251
- * Emits a `searchTypeChanged` event indicating an update to the search type
1252
- * (e.g., metadata vs. full-text).
1253
- */
1254
- emitSearchTypeChanged() {
1255
- this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1256
- detail: this.searchType,
1257
- }));
1258
- }
1259
- /**
1260
- * Emits a `queryStateChanged` event indicating that one or more of this component's
1261
- * properties have changed in a way that could affect the set of search results.
1262
- */
1263
- emitQueryStateChanged() {
1264
- this.dispatchEvent(new CustomEvent('queryStateChanged', {
1265
- detail: {
1266
- baseQuery: this.baseQuery,
1267
- withinCollection: this.withinCollection,
1268
- withinProfile: this.withinProfile,
1269
- profileElement: this.profileElement,
1270
- searchType: this.searchType,
1271
- selectedFacets: this.selectedFacets,
1272
- minSelectedDate: this.minSelectedDate,
1273
- maxSelectedDate: this.maxSelectedDate,
1274
- selectedSort: this.selectedSort,
1275
- sortDirection: this.sortDirection,
1276
- selectedTitleFilter: this.selectedTitleFilter,
1277
- selectedCreatorFilter: this.selectedCreatorFilter,
1278
- },
1279
- }));
1280
- }
1281
- /**
1282
- * Emits an `emptyResults` event indicating that we have received an empty result set
1283
- * for the most recent query.
1284
- */
1285
- emitEmptyResults() {
1286
- this.dispatchEvent(new Event('emptyResults'));
1287
- }
1288
- disconnectResizeObserver(resizeObserver) {
1289
- resizeObserver.removeObserver({
1290
- target: this.contentContainer,
1291
- handler: this,
1292
- });
1293
- }
1294
- setupResizeObserver() {
1295
- if (!this.resizeObserver || !this.contentContainer)
1296
- return;
1297
- this.resizeObserver.addObserver({
1298
- target: this.contentContainer,
1299
- handler: this,
1300
- });
1301
- }
1302
- /**
1303
- * When the visible cells change from the infinite scroller, we want to emit
1304
- * which page is currently visible so the consumer can update its UI or the URL
1305
- *
1306
- * @param e
1307
- * @returns
1308
- */
1309
- visibleCellsChanged(e) {
1310
- if (this.isScrollingToCell)
1311
- return;
1312
- const { visibleCellIndices } = e.detail;
1313
- if (visibleCellIndices.length === 0)
1314
- return;
1315
- // For page determination, do not count more than a single page of visible cells,
1316
- // since otherwise patrons using very tall screens will be treated as one page
1317
- // further than they actually are.
1318
- const lastIndexWithinCurrentPage = Math.min(this.pageSize, visibleCellIndices.length) - 1;
1319
- const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
1320
- const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1321
- if (this.currentPage !== lastVisibleCellPage) {
1322
- this.currentPage = lastVisibleCellPage;
1323
- }
1324
- const event = new CustomEvent('visiblePageChanged', {
1325
- detail: {
1326
- pageNumber: lastVisibleCellPage,
1327
- },
1328
- });
1329
- this.dispatchEvent(event);
1330
- }
1331
- /**
1332
- * A Promise which, after each query change, resolves once the fetches for the initial
1333
- * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1334
- *
1335
- * Ensure you await this component's `updateComplete` promise before awaiting this
1336
- * one, to ensure you do not await an obsolete promise from the previous update.
1337
- */
1338
- get initialSearchComplete() {
1339
- return this.dataSource.initialSearchComplete;
1340
- }
1341
- /**
1342
- * Handler for whenever the component's properties change in a way that may require
1343
- * fetching new results.
1344
- */
1345
- async handleQueryChange() {
1346
- var _a;
1347
- // only reset if the query has actually changed
1348
- if (!this.searchService ||
1349
- this.dataSource.pageFetchQueryKey === this.previousQueryKey) {
1350
- return;
1351
- }
1352
- // If the new state prevents us from updating the search results, don't reset
1353
- if (this.baseQuery && !this.dataSource.canPerformSearch) {
1354
- return;
1355
- }
1356
- this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1357
- this.totalResults = undefined;
1358
- this.pagesToRender =
1359
- this.initialPageNumber === 1
1360
- ? 2 // First two pages are batched into one request when starting from page 1
1361
- : this.initialPageNumber;
1362
- // Reset the infinite scroller's item count, so that it
1363
- // shows tile placeholders until the new query's results load in
1364
- if (this.infiniteScroller) {
1365
- this.infiniteScroller.itemCount = this.estimatedTileCount;
1366
- this.infiniteScroller.reload();
1367
- }
1368
- if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1369
- this.defaultSortField = SortField.relevance;
1370
- this.defaultSortDirection = null;
1371
- }
1372
- if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1373
- this.scrollToPage(this.initialPageNumber);
1374
- }
1375
- this.initialQueryChangeHappened = true;
1376
- // if the query changed as part of a window.history pop event, we don't want to
1377
- // persist the state because it overwrites the forward history
1378
- if (!this.historyPopOccurred) {
1379
- this.persistState();
1380
- }
1381
- this.historyPopOccurred = false;
1382
- }
1383
- setupStateRestorationObserver() {
1384
- if (!this.boundNavigationHandler) {
1385
- this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1386
- }
1387
- // when the user navigates back, we want to update the UI to match the URL
1388
- window.addEventListener('popstate', this.boundNavigationHandler);
1389
- }
1390
- historyNavigationHandler() {
1391
- this.historyPopOccurred = true;
1392
- this.restoreState();
1393
- }
1394
- restoreState() {
1395
- var _a, _b, _c, _d, _e;
1396
- const restorationState = this.restorationStateHandler.getRestorationState();
1397
- this.displayMode = restorationState.displayMode;
1398
- if (restorationState.searchType != null)
1399
- this.searchType = restorationState.searchType;
1400
- this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1401
- this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1402
- this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1403
- this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1404
- this.selectedFacets = restorationState.selectedFacets;
1405
- if (!this.suppressURLQuery)
1406
- this.baseQuery = restorationState.baseQuery;
1407
- this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1408
- this.minSelectedDate = restorationState.minSelectedDate;
1409
- this.maxSelectedDate = restorationState.maxSelectedDate;
1410
- if (this.currentPage > 1) {
1411
- this.goToPage(this.currentPage);
1412
- }
1413
- }
1414
- persistState() {
1415
- var _a, _b, _c, _d;
1416
- const restorationState = {
1417
- displayMode: this.displayMode,
1418
- searchType: this.searchType,
1419
- selectedSort: this.selectedSort,
1420
- sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1421
- selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1422
- baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1423
- currentPage: this.currentPage,
1424
- titleQuery: this.titleQuery,
1425
- creatorQuery: this.creatorQuery,
1426
- minSelectedDate: this.minSelectedDate,
1427
- maxSelectedDate: this.maxSelectedDate,
1428
- selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1429
- selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1430
- };
1431
- this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1432
- }
1433
- /**
1434
- * Emits a `searchResultsLoadingChanged` event indicating that our loading state has
1435
- * changed (either we have started loading new results, or we have finished loading them).
1436
- */
1437
- emitSearchResultsLoadingChanged() {
1438
- this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1439
- detail: {
1440
- loading: this.searchResultsLoading,
1441
- },
1442
- }));
1443
- }
1444
- /**
1445
- * Handler for when the set of selected facets changes.
1446
- */
1447
- facetsChanged(e) {
1448
- this.selectedFacets = e.detail;
1449
- }
1450
- /**
1451
- * Handler for when any facet is selected/unselected/hidden/unhidden.
1452
- * Fires analytics indicating the type of facet event that took place.
1453
- */
1454
- facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1455
- var _a;
1456
- let action;
1457
- if (negative) {
1458
- action =
1459
- bucket.state !== 'none'
1460
- ? analyticsActions.facetNegativeSelected
1461
- : analyticsActions.facetNegativeDeselected;
1462
- }
1463
- else {
1464
- action =
1465
- bucket.state !== 'none'
1466
- ? analyticsActions.facetSelected
1467
- : analyticsActions.facetDeselected;
1468
- }
1469
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1470
- category: this.searchContext,
1471
- action,
1472
- label: facetType,
1473
- });
1474
- }
1475
- scrollToPage(pageNumber) {
1476
- return new Promise(resolve => {
1477
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1478
- // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1479
- // then scrolls to the cell
1480
- setTimeout(() => {
1481
- var _a;
1482
- this.isScrollingToCell = true;
1483
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1484
- // This timeout is to give the scroll animation time to finish
1485
- // then updating the infinite scroller once we're done scrolling
1486
- // There's no scroll animation completion callback so we're
1487
- // giving it 0.5s to finish.
1488
- setTimeout(() => {
1489
- var _a;
1490
- this.isScrollingToCell = false;
1491
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1492
- resolve();
1493
- }, 500);
1494
- }, 0);
1495
- });
1496
- }
1497
- /**
1498
- * Whether sorting by relevance makes sense for the current state.
1499
- * Currently equivalent to having a non-empty query.
1500
- */
1501
- get isRelevanceSortAvailable() {
1502
- var _a;
1503
- return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1504
- }
1505
- /**
1506
- * Sets the total number of tiles displayed in the infinite scroller.
1507
- */
1508
- setTileCount(count) {
1509
- if (this.infiniteScroller) {
1510
- this.infiniteScroller.itemCount = count;
1511
- }
1512
- }
1513
- /**
1514
- * Applies any default sort option for the current collection, by checking
1515
- * for one in the collection's metadata. If none is found, defaults to sorting
1516
- * descending by:
1517
- * - Date Favorited for fav-* collections
1518
- * - Weekly views for all other collections
1519
- */
1520
- applyDefaultCollectionSort(collectionInfo) {
1521
- var _a, _b, _c;
1522
- if (this.baseQuery) {
1523
- // If there's a query set, then we default to relevance sorting regardless of
1524
- // the collection metadata-specified sort.
1525
- this.defaultSortField = SortField.relevance;
1526
- this.defaultSortDirection = null;
1527
- return;
1528
- }
1529
- // Favorite collections sort on Date Favorited by default.
1530
- // Other collections fall back to sorting on weekly views.
1531
- 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-'))
1532
- ? '-favoritedate'
1533
- : '-week';
1534
- // The collection metadata may override the default sorting with something else
1535
- const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1536
- // Prefer the metadata-specified sort if one exists
1537
- const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1538
- // Account for both -field and field:dir formats
1539
- let [field, dir] = defaultSortToApply.split(':');
1540
- if (field.startsWith('-')) {
1541
- field = field.slice(1);
1542
- dir = 'desc';
1543
- }
1544
- else if (!['asc', 'desc'].includes(dir)) {
1545
- dir = 'asc';
1546
- }
1547
- const sortOption = sortOptionFromAPIString(field);
1548
- const sortField = sortOption.field;
1549
- if (sortField && sortField !== SortField.default) {
1550
- this.defaultSortField = sortField;
1551
- this.defaultSortDirection = dir;
1552
- }
1553
- }
1554
- /**
1555
- * Applies the default sort option for the current profile element
1556
- */
1557
- applyDefaultProfileSort() {
1558
- if (this.profileElement) {
1559
- const defaultSortField = defaultProfileElementSorts[this.profileElement];
1560
- this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1561
- }
1562
- else {
1563
- this.defaultSortField = SortField.weeklyview;
1564
- }
1565
- this.defaultSortDirection = 'desc';
1566
- }
1567
- /**
1568
- * This is useful for determining whether we need to reload the scroller.
1569
- *
1570
- * When the fetch completes, we need to reload the scroller if the cells for that
1571
- * page are visible, but if the page is not currenlty visible, we don't need to reload
1572
- */
1573
- get currentVisiblePageNumbers() {
1574
- var _a, _b;
1575
- const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1576
- const visiblePages = new Set();
1577
- visibleCells.forEach(cellIndex => {
1578
- const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1579
- visiblePages.add(visiblePage);
1580
- });
1581
- return Array.from(visiblePages);
1582
- }
1583
- /**
1584
- * Refreshes all visible result cells in the infinite scroller.
1585
- */
1586
- refreshVisibleResults() {
1587
- var _a;
1588
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1589
- }
1590
- /**
1591
- * Callback when a result is selected
1592
- */
1593
- resultSelected(event) {
1594
- var _a, _b, _c;
1595
- if (this.isManageView) {
1596
- // Checked/unchecked state change -- rerender to ensure it propagates
1597
- // this.mapDataSource(model => ({ ...model }));
1598
- const cellIndex = this.dataSource.indexOf(event.detail);
1599
- if (cellIndex >= 0)
1600
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1601
- this.requestUpdate();
1602
- }
1603
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1604
- category: this.searchContext,
1605
- action: analyticsActions.resultSelected,
1606
- label: event.detail.mediatype,
1607
- });
1608
- (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1609
- category: this.searchContext,
1610
- action: analyticsActions.resultSelected,
1611
- label: `page-${this.currentPage}`,
1612
- });
1613
- }
1614
- cellForIndex(index) {
1615
- const model = this.tileModelAtCellIndex(index);
1616
- if (!model)
1617
- return undefined;
932
+ `;
933
+ }
934
+ /**
935
+ * Handler for when the date picker's date range is changed.
936
+ */
937
+ histogramDateRangeUpdated(e) {
938
+ var _a;
939
+ const { minDate, maxDate } = e.detail;
940
+ [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
941
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
942
+ category: this.searchContext,
943
+ action: analyticsActions.histogramChanged,
944
+ label: this.dateRangeQueryClause,
945
+ });
946
+ }
947
+ /**
948
+ * The Lucene query corresponding to the current date range.
949
+ */
950
+ get dateRangeQueryClause() {
951
+ if (!this.minSelectedDate || !this.maxSelectedDate) {
952
+ return undefined;
953
+ }
954
+ return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
955
+ }
956
+ /**
957
+ * Emits an event indicating a change in whether the manage mode is shown.
958
+ */
959
+ emitManageModeChangedEvent() {
960
+ this.dispatchEvent(new CustomEvent('manageModeChanged', {
961
+ detail: this.isManageView,
962
+ }));
963
+ }
964
+ /**
965
+ * Installs a new data source component and associated query state parameters into
966
+ * this component, causing it to efficiently update its views to represent the
967
+ * newly-provided data. In this way, one can reuse a single instance of
968
+ * <collection-browser> to handle multiple different sets of search results on
969
+ * a single page, each set of results being loaded & updated by its own data
970
+ * source.
971
+ *
972
+ * @param dataSource The data source component containing (or prepared to fetch)
973
+ * the tile data to be displayed.
974
+ * @param queryState The new query-related state that this component should
975
+ * represent, such as the search query, sort option, and any filters applied.
976
+ */
977
+ async installDataSourceAndQueryState(dataSource, queryState) {
978
+ var _a, _b;
979
+ log('Installing data source & query state in CB:', dataSource, queryState);
980
+ if (this.dataSource)
981
+ this.removeController(this.dataSource);
982
+ this.dataSource = dataSource;
983
+ this.addController(this.dataSource);
984
+ this.baseQuery = queryState.baseQuery;
985
+ this.profileElement = queryState.profileElement;
986
+ this.searchType = queryState.searchType;
987
+ this.selectedFacets =
988
+ (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
989
+ this.minSelectedDate = queryState.minSelectedDate;
990
+ this.maxSelectedDate = queryState.maxSelectedDate;
991
+ this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
992
+ this.sortDirection = queryState.sortDirection;
993
+ this.selectedTitleFilter = queryState.selectedTitleFilter;
994
+ this.selectedCreatorFilter = queryState.selectedCreatorFilter;
995
+ // We set this flag during the update to prevent the URL state persistence
996
+ // from creating an unwanted extra history entry.
997
+ this.dataSourceInstallInProgress = true;
998
+ this.requestUpdate();
999
+ await this.updateComplete;
1000
+ this.dataSourceInstallInProgress = false;
1001
+ if (!this.searchResultsLoading) {
1002
+ this.setTotalResultCount(this.dataSource.totalResults);
1003
+ this.setTileCount(this.dataSource.size);
1004
+ }
1005
+ this.refreshVisibleResults();
1006
+ }
1007
+ firstUpdated() {
1008
+ this.restoreState();
1009
+ this.setInitialSize();
1010
+ }
1011
+ /**
1012
+ * Determines the initial size of the content container and whether or not
1013
+ * the mobile layout should be used.
1014
+ */
1015
+ setInitialSize() {
1016
+ this.contentWidth = this.contentContainer.getBoundingClientRect().width;
1017
+ this.mobileView =
1018
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1019
+ this.sendLayoutSizeAnalytics();
1020
+ }
1021
+ /**
1022
+ * Fires an analytics event indicating which type of layout was rendered:
1023
+ * mobile or desktop.
1024
+ */
1025
+ sendLayoutSizeAnalytics() {
1026
+ if (this.analyticsHandler) {
1027
+ this.layoutSizeAnalyticsSent = true;
1028
+ this.analyticsHandler.sendEvent({
1029
+ category: this.searchContext,
1030
+ action: this.mobileView
1031
+ ? analyticsActions.loadMobileView
1032
+ : analyticsActions.loadDesktopView,
1033
+ });
1034
+ }
1035
+ }
1036
+ updated(changed) {
1037
+ var _a, _b;
1038
+ if (changed.has('placeholderType') && this.placeholderType === null) {
1039
+ if (!this.leftColIntersectionObserver) {
1040
+ this.setupLeftColumnScrollListeners();
1041
+ }
1042
+ if (!this.facetsIntersectionObserver) {
1043
+ this.setupFacetsScrollListeners();
1044
+ }
1045
+ this.updateLeftColumnHeight();
1046
+ }
1047
+ if (changed.has('analyticsHandler') && !this.layoutSizeAnalyticsSent) {
1048
+ this.sendLayoutSizeAnalytics();
1049
+ }
1050
+ if (changed.has('displayMode') ||
1051
+ changed.has('baseNavigationUrl') ||
1052
+ changed.has('baseImageUrl') ||
1053
+ changed.has('loggedIn')) {
1054
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1055
+ }
1056
+ if (changed.has('baseQuery') ||
1057
+ changed.has('searchType') ||
1058
+ changed.has('withinCollection')) {
1059
+ // Unless this query/search type update is from the initial page load or the
1060
+ // result of hitting the back button,
1061
+ // we need to clear any existing filters since they may no longer be valid for
1062
+ // the new set of search results.
1063
+ if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
1064
+ // Ordinarily, we leave the sort param unchanged between searches.
1065
+ // However, if we are changing the target collection itself, we want the sort cleared too,
1066
+ // since different collections may have different sorting options available.
1067
+ const shouldClearSort = changed.has('withinCollection') &&
1068
+ !changed.has('selectedSort') &&
1069
+ !changed.has('sortDirection');
1070
+ // Otherwise, only clear filters that haven't been simultaneously applied in this update
1071
+ this.clearFilters({
1072
+ sort: shouldClearSort,
1073
+ facets: !changed.has('selectedFacets'),
1074
+ dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
1075
+ letterFilters: !(changed.has('selectedTitleFilter') ||
1076
+ changed.has('selectedCreatorFilter')),
1077
+ });
1078
+ }
1079
+ }
1080
+ if (changed.has('profileElement')) {
1081
+ this.applyDefaultProfileSort();
1082
+ }
1083
+ if (changed.has('baseQuery')) {
1084
+ this.emitBaseQueryChanged();
1085
+ }
1086
+ if (changed.has('searchType')) {
1087
+ this.emitSearchTypeChanged();
1088
+ }
1089
+ if (changed.has('currentPage') || changed.has('displayMode')) {
1090
+ this.persistState();
1091
+ }
1092
+ if (changed.has('baseQuery') ||
1093
+ changed.has('minSelectedDate') ||
1094
+ changed.has('maxSelectedDate') ||
1095
+ changed.has('selectedFacets') ||
1096
+ changed.has('searchService') ||
1097
+ changed.has('withinCollection') ||
1098
+ changed.has('withinProfile') ||
1099
+ changed.has('profileElement')) {
1100
+ this.dataSource.refreshLetterCounts();
1101
+ }
1102
+ if (changed.has('selectedSort') || changed.has('sortDirection')) {
1103
+ const prevSortDirection = changed.get('sortDirection');
1104
+ this.sendSortByAnalytics(prevSortDirection);
1105
+ this.selectedSortChanged();
1106
+ }
1107
+ if (changed.has('selectedTitleFilter')) {
1108
+ this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
1109
+ }
1110
+ if (changed.has('selectedCreatorFilter')) {
1111
+ this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
1112
+ }
1113
+ this.updateFacetReadiness();
1114
+ if (changed.has('baseQuery') ||
1115
+ changed.has('searchType') ||
1116
+ changed.has('selectedTitleFilter') ||
1117
+ changed.has('selectedCreatorFilter') ||
1118
+ changed.has('minSelectedDate') ||
1119
+ changed.has('maxSelectedDate') ||
1120
+ changed.has('selectedSort') ||
1121
+ changed.has('sortDirection') ||
1122
+ changed.has('selectedFacets') ||
1123
+ changed.has('searchService') ||
1124
+ changed.has('withinCollection') ||
1125
+ changed.has('withinProfile') ||
1126
+ changed.has('profileElement')) {
1127
+ this.handleQueryChange();
1128
+ }
1129
+ if (changed.has('searchResultsLoading')) {
1130
+ this.emitSearchResultsLoadingChanged();
1131
+ }
1132
+ if (changed.has('facetsLoading') &&
1133
+ this.facetsLoading &&
1134
+ this.collectionFacets) {
1135
+ this.collectionFacets.moreLinksVisible =
1136
+ this.searchType !== SearchType.FULLTEXT;
1137
+ }
1138
+ if (changed.has('pagesToRender')) {
1139
+ if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1140
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1141
+ }
1142
+ }
1143
+ if (changed.has('isManageView')) {
1144
+ if (this.isManageView)
1145
+ this.displayMode = 'grid';
1146
+ (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.refreshAllVisibleCells();
1147
+ this.emitManageModeChangedEvent();
1148
+ }
1149
+ if (changed.has('resizeObserver')) {
1150
+ const oldObserver = changed.get('resizeObserver');
1151
+ if (oldObserver)
1152
+ this.disconnectResizeObserver(oldObserver);
1153
+ this.setupResizeObserver();
1154
+ }
1155
+ this.ensureAvailableTilesDisplayed();
1156
+ }
1157
+ connectedCallback() {
1158
+ var _a;
1159
+ (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
1160
+ this.setupStateRestorationObserver();
1161
+ this.setupResizeObserver();
1162
+ }
1163
+ disconnectedCallback() {
1164
+ var _a, _b;
1165
+ if (this.resizeObserver) {
1166
+ this.disconnectResizeObserver(this.resizeObserver);
1167
+ }
1168
+ if (this.boundNavigationHandler) {
1169
+ window.removeEventListener('popstate', this.boundNavigationHandler);
1170
+ }
1171
+ (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1172
+ (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
1173
+ window.removeEventListener('resize', this.updateLeftColumnHeight);
1174
+ }
1175
+ handleResize(entry) {
1176
+ const previousView = this.mobileView;
1177
+ if (entry.target === this.contentContainer) {
1178
+ this.contentWidth = entry.contentRect.width;
1179
+ this.mobileView =
1180
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1181
+ // If changing from desktop to mobile disable transition
1182
+ if (this.mobileView && !previousView) {
1183
+ this.isResizeToMobile = true;
1184
+ }
1185
+ }
1186
+ // Ensure the facet sidebar remains sized correctly
1187
+ this.updateLeftColumnHeight();
1188
+ }
1189
+ /**
1190
+ * Ensures that if we have new results from the data source that are not yet
1191
+ * displayed in the infinite scroller, that they are immediately reflected
1192
+ * in the tile count.
1193
+ */
1194
+ ensureAvailableTilesDisplayed() {
1195
+ if (this.infiniteScroller &&
1196
+ this.infiniteScroller.itemCount < this.dataSource.size) {
1197
+ this.setTileCount(this.dataSource.endOfDataReached
1198
+ ? this.dataSource.size
1199
+ : this.estimatedTileCount);
1200
+ }
1201
+ }
1202
+ /**
1203
+ * Updates the data source with the current state of facet readiness for loading,
1204
+ * so that they will begin to load in at the appropriate time according to the
1205
+ * current facet loading strategy.
1206
+ */
1207
+ updateFacetReadiness() {
1208
+ // There are two ways to opt into facet production:
1209
+ // (1) have the facets dropdown open, or
1210
+ // (2) if using the `opt-in-or-login` strategy, be logged into an account
1211
+ const optedIn = this.collapsibleFacetsVisible ||
1212
+ (this.facetLoadStrategy === 'opt-in-or-login' && this.loggedIn);
1213
+ // In desktop view, we are always ready to load facets *unless* we are using one of the
1214
+ // `opt-in` strategies and have not opted in (whether by login or UI interaction).
1215
+ const usingOptInStrategy = ['opt-in', 'opt-in-or-login'].includes(this.facetLoadStrategy);
1216
+ const desktopFacetsReady = !this.mobileView && (!usingOptInStrategy || optedIn);
1217
+ // In the mobile view, facets are considered ready provided we have opted in (whether by
1218
+ // login or UI interaction).
1219
+ const mobileFacetsReady = this.mobileView && optedIn;
1220
+ this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
1221
+ }
1222
+ /**
1223
+ * Sets up listeners for events that may require updating the left column height.
1224
+ */
1225
+ setupLeftColumnScrollListeners() {
1226
+ var _a;
1227
+ // We observe intersections between the left column's scroll sentinel and
1228
+ // the viewport, so that we can ensure the left column is always sized to
1229
+ // match the _available_ viewport height. This should generally be more
1230
+ // performant than listening to scroll events on the page or column.
1231
+ const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1232
+ if (leftColumnSentinel) {
1233
+ this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1234
+ threshold: [...Array(101).keys()].map(n => n / 100), // Threshold every 1%
1235
+ });
1236
+ this.leftColIntersectionObserver.observe(leftColumnSentinel);
1237
+ }
1238
+ // We also listen for window resize events, as they are not always captured
1239
+ // by the resize observer and can affect the desired height of the left column.
1240
+ window.addEventListener('resize', this.updateLeftColumnHeight);
1241
+ }
1242
+ /**
1243
+ * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1244
+ * Note this uses a separate IntersectionObserver from the left column, because we
1245
+ * don't need granular intersection thresholds for this.
1246
+ */
1247
+ setupFacetsScrollListeners() {
1248
+ var _a;
1249
+ const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1250
+ if (facetsSentinel) {
1251
+ this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1252
+ this.facetsIntersectionObserver.observe(facetsSentinel);
1253
+ }
1254
+ }
1255
+ /**
1256
+ * Emits a `baseQueryChanged` event indicating an update to the search query.
1257
+ */
1258
+ emitBaseQueryChanged() {
1259
+ this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1260
+ detail: {
1261
+ baseQuery: this.baseQuery,
1262
+ },
1263
+ }));
1264
+ }
1265
+ /**
1266
+ * Emits a `searchTypeChanged` event indicating an update to the search type
1267
+ * (e.g., metadata vs. full-text).
1268
+ */
1269
+ emitSearchTypeChanged() {
1270
+ this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1271
+ detail: this.searchType,
1272
+ }));
1273
+ }
1274
+ /**
1275
+ * Emits a `queryStateChanged` event indicating that one or more of this component's
1276
+ * properties have changed in a way that could affect the set of search results.
1277
+ */
1278
+ emitQueryStateChanged() {
1279
+ this.dispatchEvent(new CustomEvent('queryStateChanged', {
1280
+ detail: {
1281
+ baseQuery: this.baseQuery,
1282
+ withinCollection: this.withinCollection,
1283
+ withinProfile: this.withinProfile,
1284
+ profileElement: this.profileElement,
1285
+ searchType: this.searchType,
1286
+ selectedFacets: this.selectedFacets,
1287
+ minSelectedDate: this.minSelectedDate,
1288
+ maxSelectedDate: this.maxSelectedDate,
1289
+ selectedSort: this.selectedSort,
1290
+ sortDirection: this.sortDirection,
1291
+ selectedTitleFilter: this.selectedTitleFilter,
1292
+ selectedCreatorFilter: this.selectedCreatorFilter,
1293
+ },
1294
+ }));
1295
+ }
1296
+ /**
1297
+ * Emits an `emptyResults` event indicating that we have received an empty result set
1298
+ * for the most recent query.
1299
+ */
1300
+ emitEmptyResults() {
1301
+ this.dispatchEvent(new Event('emptyResults'));
1302
+ }
1303
+ disconnectResizeObserver(resizeObserver) {
1304
+ resizeObserver.removeObserver({
1305
+ target: this.contentContainer,
1306
+ handler: this,
1307
+ });
1308
+ }
1309
+ setupResizeObserver() {
1310
+ if (!this.resizeObserver || !this.contentContainer)
1311
+ return;
1312
+ this.resizeObserver.addObserver({
1313
+ target: this.contentContainer,
1314
+ handler: this,
1315
+ });
1316
+ }
1317
+ /**
1318
+ * When the visible cells change from the infinite scroller, we want to emit
1319
+ * which page is currently visible so the consumer can update its UI or the URL
1320
+ *
1321
+ * @param e
1322
+ * @returns
1323
+ */
1324
+ visibleCellsChanged(e) {
1325
+ if (this.isScrollingToCell)
1326
+ return;
1327
+ const { visibleCellIndices } = e.detail;
1328
+ if (visibleCellIndices.length === 0)
1329
+ return;
1330
+ // For page determination, do not count more than a single page of visible cells,
1331
+ // since otherwise patrons using very tall screens will be treated as one page
1332
+ // further than they actually are.
1333
+ const lastIndexWithinCurrentPage = Math.min(this.pageSize, visibleCellIndices.length) - 1;
1334
+ const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
1335
+ const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1336
+ if (this.currentPage !== lastVisibleCellPage) {
1337
+ this.currentPage = lastVisibleCellPage;
1338
+ }
1339
+ const event = new CustomEvent('visiblePageChanged', {
1340
+ detail: {
1341
+ pageNumber: lastVisibleCellPage,
1342
+ },
1343
+ });
1344
+ this.dispatchEvent(event);
1345
+ }
1346
+ /**
1347
+ * A Promise which, after each query change, resolves once the fetches for the initial
1348
+ * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1349
+ *
1350
+ * Ensure you await this component's `updateComplete` promise before awaiting this
1351
+ * one, to ensure you do not await an obsolete promise from the previous update.
1352
+ */
1353
+ get initialSearchComplete() {
1354
+ return this.dataSource.initialSearchComplete;
1355
+ }
1356
+ /**
1357
+ * Handler for whenever the component's properties change in a way that may require
1358
+ * fetching new results.
1359
+ */
1360
+ async handleQueryChange() {
1361
+ var _a;
1362
+ // only reset if the query has actually changed
1363
+ if (!this.searchService ||
1364
+ this.dataSource.pageFetchQueryKey === this.previousQueryKey) {
1365
+ return;
1366
+ }
1367
+ // If the new state prevents us from updating the search results, don't reset
1368
+ if (this.baseQuery && !this.dataSource.canPerformSearch) {
1369
+ return;
1370
+ }
1371
+ this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1372
+ this.totalResults = undefined;
1373
+ this.pagesToRender =
1374
+ this.initialPageNumber === 1
1375
+ ? 2 // First two pages are batched into one request when starting from page 1
1376
+ : this.initialPageNumber;
1377
+ // Reset the infinite scroller's item count, so that it
1378
+ // shows tile placeholders until the new query's results load in
1379
+ if (this.infiniteScroller) {
1380
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1381
+ this.infiniteScroller.reload();
1382
+ }
1383
+ if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1384
+ this.defaultSortField = SortField.relevance;
1385
+ this.defaultSortDirection = null;
1386
+ }
1387
+ if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1388
+ this.scrollToPage(this.initialPageNumber);
1389
+ }
1390
+ this.initialQueryChangeHappened = true;
1391
+ // if the query changed as part of a window.history pop event, we don't want to
1392
+ // persist the state because it overwrites the forward history
1393
+ if (!this.historyPopOccurred) {
1394
+ this.persistState();
1395
+ }
1396
+ this.historyPopOccurred = false;
1397
+ }
1398
+ setupStateRestorationObserver() {
1399
+ if (!this.boundNavigationHandler) {
1400
+ this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1401
+ }
1402
+ // when the user navigates back, we want to update the UI to match the URL
1403
+ window.addEventListener('popstate', this.boundNavigationHandler);
1404
+ }
1405
+ historyNavigationHandler() {
1406
+ this.historyPopOccurred = true;
1407
+ this.restoreState();
1408
+ }
1409
+ restoreState() {
1410
+ var _a, _b, _c, _d, _e;
1411
+ const restorationState = this.restorationStateHandler.getRestorationState();
1412
+ this.displayMode = restorationState.displayMode;
1413
+ if (restorationState.searchType != null)
1414
+ this.searchType = restorationState.searchType;
1415
+ this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1416
+ this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1417
+ this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1418
+ this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1419
+ this.selectedFacets = restorationState.selectedFacets;
1420
+ if (!this.suppressURLQuery)
1421
+ this.baseQuery = restorationState.baseQuery;
1422
+ this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1423
+ this.minSelectedDate = restorationState.minSelectedDate;
1424
+ this.maxSelectedDate = restorationState.maxSelectedDate;
1425
+ if (this.currentPage > 1) {
1426
+ this.goToPage(this.currentPage);
1427
+ }
1428
+ }
1429
+ persistState() {
1430
+ var _a, _b, _c, _d;
1431
+ const restorationState = {
1432
+ displayMode: this.displayMode,
1433
+ searchType: this.searchType,
1434
+ selectedSort: this.selectedSort,
1435
+ sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1436
+ selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1437
+ baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1438
+ currentPage: this.currentPage,
1439
+ titleQuery: this.titleQuery,
1440
+ creatorQuery: this.creatorQuery,
1441
+ minSelectedDate: this.minSelectedDate,
1442
+ maxSelectedDate: this.maxSelectedDate,
1443
+ selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1444
+ selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1445
+ };
1446
+ this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1447
+ }
1448
+ /**
1449
+ * Emits a `searchResultsLoadingChanged` event indicating that our loading state has
1450
+ * changed (either we have started loading new results, or we have finished loading them).
1451
+ */
1452
+ emitSearchResultsLoadingChanged() {
1453
+ this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1454
+ detail: {
1455
+ loading: this.searchResultsLoading,
1456
+ },
1457
+ }));
1458
+ }
1459
+ /**
1460
+ * Handler for when the set of selected facets changes.
1461
+ */
1462
+ facetsChanged(e) {
1463
+ this.selectedFacets = e.detail;
1464
+ }
1465
+ /**
1466
+ * Handler for when any facet is selected/unselected/hidden/unhidden.
1467
+ * Fires analytics indicating the type of facet event that took place.
1468
+ */
1469
+ facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1470
+ var _a;
1471
+ let action;
1472
+ if (negative) {
1473
+ action =
1474
+ bucket.state !== 'none'
1475
+ ? analyticsActions.facetNegativeSelected
1476
+ : analyticsActions.facetNegativeDeselected;
1477
+ }
1478
+ else {
1479
+ action =
1480
+ bucket.state !== 'none'
1481
+ ? analyticsActions.facetSelected
1482
+ : analyticsActions.facetDeselected;
1483
+ }
1484
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1485
+ category: this.searchContext,
1486
+ action,
1487
+ label: facetType,
1488
+ });
1489
+ }
1490
+ scrollToPage(pageNumber) {
1491
+ return new Promise(resolve => {
1492
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1493
+ // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1494
+ // then scrolls to the cell
1495
+ setTimeout(() => {
1496
+ var _a;
1497
+ this.isScrollingToCell = true;
1498
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1499
+ // This timeout is to give the scroll animation time to finish
1500
+ // then updating the infinite scroller once we're done scrolling
1501
+ // There's no scroll animation completion callback so we're
1502
+ // giving it 0.5s to finish.
1503
+ setTimeout(() => {
1504
+ var _a;
1505
+ this.isScrollingToCell = false;
1506
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1507
+ resolve();
1508
+ }, 500);
1509
+ }, 0);
1510
+ });
1511
+ }
1512
+ /**
1513
+ * Whether sorting by relevance makes sense for the current state.
1514
+ * Currently equivalent to having a non-empty query.
1515
+ */
1516
+ get isRelevanceSortAvailable() {
1517
+ var _a;
1518
+ return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1519
+ }
1520
+ /**
1521
+ * Sets the total number of tiles displayed in the infinite scroller.
1522
+ */
1523
+ setTileCount(count) {
1524
+ if (this.infiniteScroller) {
1525
+ this.infiniteScroller.itemCount = count;
1526
+ }
1527
+ }
1528
+ /**
1529
+ * Applies any default sort option for the current collection, by checking
1530
+ * for one in the collection's metadata. If none is found, defaults to sorting
1531
+ * descending by:
1532
+ * - Date Favorited for fav-* collections
1533
+ * - Weekly views for all other collections
1534
+ */
1535
+ applyDefaultCollectionSort(collectionInfo) {
1536
+ var _a, _b, _c;
1537
+ if (this.baseQuery) {
1538
+ // If there's a query set, then we default to relevance sorting regardless of
1539
+ // the collection metadata-specified sort.
1540
+ this.defaultSortField = SortField.relevance;
1541
+ this.defaultSortDirection = null;
1542
+ return;
1543
+ }
1544
+ // Favorite collections sort on Date Favorited by default.
1545
+ // Other collections fall back to sorting on weekly views.
1546
+ 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-'))
1547
+ ? '-favoritedate'
1548
+ : '-week';
1549
+ // The collection metadata may override the default sorting with something else
1550
+ const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1551
+ // Prefer the metadata-specified sort if one exists
1552
+ const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1553
+ // Account for both -field and field:dir formats
1554
+ let [field, dir] = defaultSortToApply.split(':');
1555
+ if (field.startsWith('-')) {
1556
+ field = field.slice(1);
1557
+ dir = 'desc';
1558
+ }
1559
+ else if (!['asc', 'desc'].includes(dir)) {
1560
+ dir = 'asc';
1561
+ }
1562
+ const sortOption = sortOptionFromAPIString(field);
1563
+ const sortField = sortOption.field;
1564
+ if (sortField && sortField !== SortField.default) {
1565
+ this.defaultSortField = sortField;
1566
+ this.defaultSortDirection = dir;
1567
+ }
1568
+ }
1569
+ /**
1570
+ * Applies the default sort option for the current profile element
1571
+ */
1572
+ applyDefaultProfileSort() {
1573
+ if (this.profileElement) {
1574
+ const defaultSortField = defaultProfileElementSorts[this.profileElement];
1575
+ this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1576
+ }
1577
+ else {
1578
+ this.defaultSortField = SortField.weeklyview;
1579
+ }
1580
+ this.defaultSortDirection = 'desc';
1581
+ }
1582
+ /**
1583
+ * This is useful for determining whether we need to reload the scroller.
1584
+ *
1585
+ * When the fetch completes, we need to reload the scroller if the cells for that
1586
+ * page are visible, but if the page is not currenlty visible, we don't need to reload
1587
+ */
1588
+ get currentVisiblePageNumbers() {
1589
+ var _a, _b;
1590
+ const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1591
+ const visiblePages = new Set();
1592
+ visibleCells.forEach(cellIndex => {
1593
+ const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1594
+ visiblePages.add(visiblePage);
1595
+ });
1596
+ return Array.from(visiblePages);
1597
+ }
1598
+ /**
1599
+ * Refreshes all visible result cells in the infinite scroller.
1600
+ */
1601
+ refreshVisibleResults() {
1602
+ var _a;
1603
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1604
+ }
1605
+ /**
1606
+ * Callback when a result is selected
1607
+ */
1608
+ resultSelected(event) {
1609
+ var _a, _b, _c;
1610
+ if (this.isManageView) {
1611
+ // Checked/unchecked state change -- rerender to ensure it propagates
1612
+ // this.mapDataSource(model => ({ ...model }));
1613
+ const cellIndex = this.dataSource.indexOf(event.detail);
1614
+ if (cellIndex >= 0)
1615
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1616
+ this.requestUpdate();
1617
+ }
1618
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1619
+ category: this.searchContext,
1620
+ action: analyticsActions.resultSelected,
1621
+ label: event.detail.mediatype,
1622
+ });
1623
+ (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1624
+ category: this.searchContext,
1625
+ action: analyticsActions.resultSelected,
1626
+ label: `page-${this.currentPage}`,
1627
+ });
1628
+ }
1629
+ cellForIndex(index) {
1630
+ const model = this.tileModelAtCellIndex(index);
1631
+ if (!model)
1632
+ return undefined;
1618
1633
  return html `
1619
1634
  <tile-dispatcher
1620
1635
  .collectionPagePath=${this.collectionPagePath}
@@ -1634,21 +1649,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1634
1649
  @resultSelected=${(e) => this.resultSelected(e)}
1635
1650
  >
1636
1651
  </tile-dispatcher>
1637
- `;
1638
- }
1639
- /**
1640
- * When the user scrolls near to the bottom of the page, fetch the next page
1641
- * increase the number of pages to render and start fetching data for the new page
1642
- */
1643
- scrollThresholdReached() {
1644
- if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1645
- this.pagesToRender += 1;
1646
- this.dataSource.fetchPage(this.pagesToRender);
1647
- }
1648
- }
1649
- static get styles() {
1650
- return [
1651
- srOnlyStyle,
1652
+ `;
1653
+ }
1654
+ /**
1655
+ * When the user scrolls near to the bottom of the page, fetch the next page
1656
+ * increase the number of pages to render and start fetching data for the new page
1657
+ */
1658
+ scrollThresholdReached() {
1659
+ if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1660
+ this.pagesToRender += 1;
1661
+ this.dataSource.fetchPage(this.pagesToRender);
1662
+ }
1663
+ }
1664
+ static get styles() {
1665
+ return [
1666
+ srOnlyStyle,
1652
1667
  css `
1653
1668
  :host {
1654
1669
  display: block;
@@ -2072,189 +2087,189 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
2072
2087
  infinite-scroller.hidden {
2073
2088
  display: none;
2074
2089
  }
2075
- `,
2076
- ];
2077
- }
2078
- };
2079
- __decorate([
2080
- property({ type: String })
2081
- ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
2082
- __decorate([
2083
- property({ type: String })
2084
- ], CollectionBrowser.prototype, "baseImageUrl", void 0);
2085
- __decorate([
2086
- property({ type: Object })
2087
- ], CollectionBrowser.prototype, "searchService", void 0);
2088
- __decorate([
2089
- property({ type: Number })
2090
- ], CollectionBrowser.prototype, "searchType", void 0);
2091
- __decorate([
2092
- property({ type: String })
2093
- ], CollectionBrowser.prototype, "withinCollection", void 0);
2094
- __decorate([
2095
- property({ type: String })
2096
- ], CollectionBrowser.prototype, "withinProfile", void 0);
2097
- __decorate([
2098
- property({ type: String })
2099
- ], CollectionBrowser.prototype, "profileElement", void 0);
2100
- __decorate([
2101
- property({ type: String })
2102
- ], CollectionBrowser.prototype, "baseQuery", void 0);
2103
- __decorate([
2104
- property({ type: String })
2105
- ], CollectionBrowser.prototype, "displayMode", void 0);
2106
- __decorate([
2107
- property({ type: String })
2108
- ], CollectionBrowser.prototype, "selectedSort", void 0);
2109
- __decorate([
2110
- property({ type: String })
2111
- ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
2112
- __decorate([
2113
- property({ type: String })
2114
- ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
2115
- __decorate([
2116
- property({ type: String })
2117
- ], CollectionBrowser.prototype, "sortDirection", void 0);
2118
- __decorate([
2119
- property({ type: String })
2120
- ], CollectionBrowser.prototype, "defaultSortField", void 0);
2121
- __decorate([
2122
- property({ type: String })
2123
- ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2124
- __decorate([
2125
- property({ type: Number })
2126
- ], CollectionBrowser.prototype, "pageSize", void 0);
2127
- __decorate([
2128
- property({ type: Number })
2129
- ], CollectionBrowser.prototype, "currentPage", void 0);
2130
- __decorate([
2131
- property({ type: String })
2132
- ], CollectionBrowser.prototype, "minSelectedDate", void 0);
2133
- __decorate([
2134
- property({ type: String })
2135
- ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
2136
- __decorate([
2137
- property({ type: Object })
2138
- ], CollectionBrowser.prototype, "selectedFacets", void 0);
2139
- __decorate([
2140
- property({ type: Boolean })
2141
- ], CollectionBrowser.prototype, "showSmartFacetBar", void 0);
2142
- __decorate([
2143
- property({ type: Boolean })
2144
- ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
2145
- __decorate([
2146
- property({ type: Boolean })
2147
- ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
2148
- __decorate([
2149
- property({ type: Boolean })
2150
- ], CollectionBrowser.prototype, "suppressResultCount", void 0);
2151
- __decorate([
2152
- property({ type: Boolean })
2153
- ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
2154
- __decorate([
2155
- property({ type: Boolean })
2156
- ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
2157
- __decorate([
2158
- property({ type: Boolean })
2159
- ], CollectionBrowser.prototype, "suppressSortBar", void 0);
2160
- __decorate([
2161
- property({ type: Boolean })
2162
- ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
2163
- __decorate([
2164
- property({ type: String })
2165
- ], CollectionBrowser.prototype, "facetLoadStrategy", void 0);
2166
- __decorate([
2167
- property({ type: Boolean })
2168
- ], CollectionBrowser.prototype, "facetPaneVisible", void 0);
2169
- __decorate([
2170
- property({ type: Boolean })
2171
- ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
2172
- __decorate([
2173
- property({ type: String })
2174
- ], CollectionBrowser.prototype, "collectionPagePath", void 0);
2175
- __decorate([
2176
- property({ type: String, reflect: true })
2177
- ], CollectionBrowser.prototype, "searchContext", void 0);
2178
- __decorate([
2179
- property({ type: String })
2180
- ], CollectionBrowser.prototype, "pageContext", void 0);
2181
- __decorate([
2182
- property({ type: Object })
2183
- ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
2184
- __decorate([
2185
- property({ type: Number })
2186
- ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
2187
- __decorate([
2188
- property({ type: Boolean })
2189
- ], CollectionBrowser.prototype, "loggedIn", void 0);
2190
- __decorate([
2191
- property({ type: Object })
2192
- ], CollectionBrowser.prototype, "resizeObserver", void 0);
2193
- __decorate([
2194
- property({ type: Object })
2195
- ], CollectionBrowser.prototype, "modalManager", void 0);
2196
- __decorate([
2197
- property({ type: Object })
2198
- ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
2199
- __decorate([
2200
- property({ type: Object })
2201
- ], CollectionBrowser.prototype, "recaptchaManager", void 0);
2202
- __decorate([
2203
- property({ type: Boolean })
2204
- ], CollectionBrowser.prototype, "isManageView", void 0);
2205
- __decorate([
2206
- property({ type: String })
2207
- ], CollectionBrowser.prototype, "manageViewLabel", void 0);
2208
- __decorate([
2209
- property({ type: Boolean })
2210
- ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
2211
- __decorate([
2212
- property({ type: Boolean, reflect: true })
2213
- ], CollectionBrowser.prototype, "showSmartResults", void 0);
2214
- __decorate([
2215
- property({ type: Object })
2216
- ], CollectionBrowser.prototype, "dataSource", void 0);
2217
- __decorate([
2218
- state()
2219
- ], CollectionBrowser.prototype, "pagesToRender", void 0);
2220
- __decorate([
2221
- state()
2222
- ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
2223
- __decorate([
2224
- state()
2225
- ], CollectionBrowser.prototype, "facetsLoading", void 0);
2226
- __decorate([
2227
- state()
2228
- ], CollectionBrowser.prototype, "totalResults", void 0);
2229
- __decorate([
2230
- state()
2231
- ], CollectionBrowser.prototype, "mobileView", void 0);
2232
- __decorate([
2233
- state()
2234
- ], CollectionBrowser.prototype, "collapsibleFacetsVisible", void 0);
2235
- __decorate([
2236
- state()
2237
- ], CollectionBrowser.prototype, "contentWidth", void 0);
2238
- __decorate([
2239
- state()
2240
- ], CollectionBrowser.prototype, "placeholderType", void 0);
2241
- __decorate([
2242
- query('#content-container')
2243
- ], CollectionBrowser.prototype, "contentContainer", void 0);
2244
- __decorate([
2245
- query('#left-column')
2246
- ], CollectionBrowser.prototype, "leftColumn", void 0);
2247
- __decorate([
2248
- query('collection-facets')
2249
- ], CollectionBrowser.prototype, "collectionFacets", void 0);
2250
- __decorate([
2251
- property({ type: Object, attribute: false })
2252
- ], CollectionBrowser.prototype, "analyticsHandler", void 0);
2253
- __decorate([
2254
- query('infinite-scroller')
2255
- ], CollectionBrowser.prototype, "infiniteScroller", void 0);
2256
- CollectionBrowser = __decorate([
2257
- customElement('collection-browser')
2258
- ], CollectionBrowser);
2259
- export { CollectionBrowser };
2090
+ `,
2091
+ ];
2092
+ }
2093
+ };
2094
+ __decorate([
2095
+ property({ type: String })
2096
+ ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
2097
+ __decorate([
2098
+ property({ type: String })
2099
+ ], CollectionBrowser.prototype, "baseImageUrl", void 0);
2100
+ __decorate([
2101
+ property({ type: Object })
2102
+ ], CollectionBrowser.prototype, "searchService", void 0);
2103
+ __decorate([
2104
+ property({ type: Number })
2105
+ ], CollectionBrowser.prototype, "searchType", void 0);
2106
+ __decorate([
2107
+ property({ type: String })
2108
+ ], CollectionBrowser.prototype, "withinCollection", void 0);
2109
+ __decorate([
2110
+ property({ type: String })
2111
+ ], CollectionBrowser.prototype, "withinProfile", void 0);
2112
+ __decorate([
2113
+ property({ type: String })
2114
+ ], CollectionBrowser.prototype, "profileElement", void 0);
2115
+ __decorate([
2116
+ property({ type: String })
2117
+ ], CollectionBrowser.prototype, "baseQuery", void 0);
2118
+ __decorate([
2119
+ property({ type: String })
2120
+ ], CollectionBrowser.prototype, "displayMode", void 0);
2121
+ __decorate([
2122
+ property({ type: String })
2123
+ ], CollectionBrowser.prototype, "selectedSort", void 0);
2124
+ __decorate([
2125
+ property({ type: String })
2126
+ ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
2127
+ __decorate([
2128
+ property({ type: String })
2129
+ ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
2130
+ __decorate([
2131
+ property({ type: String })
2132
+ ], CollectionBrowser.prototype, "sortDirection", void 0);
2133
+ __decorate([
2134
+ property({ type: String })
2135
+ ], CollectionBrowser.prototype, "defaultSortField", void 0);
2136
+ __decorate([
2137
+ property({ type: String })
2138
+ ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2139
+ __decorate([
2140
+ property({ type: Number })
2141
+ ], CollectionBrowser.prototype, "pageSize", void 0);
2142
+ __decorate([
2143
+ property({ type: Number })
2144
+ ], CollectionBrowser.prototype, "currentPage", void 0);
2145
+ __decorate([
2146
+ property({ type: String })
2147
+ ], CollectionBrowser.prototype, "minSelectedDate", void 0);
2148
+ __decorate([
2149
+ property({ type: String })
2150
+ ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
2151
+ __decorate([
2152
+ property({ type: Object })
2153
+ ], CollectionBrowser.prototype, "selectedFacets", void 0);
2154
+ __decorate([
2155
+ property({ type: Boolean })
2156
+ ], CollectionBrowser.prototype, "showSmartFacetBar", void 0);
2157
+ __decorate([
2158
+ property({ type: Boolean })
2159
+ ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
2160
+ __decorate([
2161
+ property({ type: Boolean })
2162
+ ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
2163
+ __decorate([
2164
+ property({ type: Boolean })
2165
+ ], CollectionBrowser.prototype, "suppressResultCount", void 0);
2166
+ __decorate([
2167
+ property({ type: Boolean })
2168
+ ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
2169
+ __decorate([
2170
+ property({ type: Boolean })
2171
+ ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
2172
+ __decorate([
2173
+ property({ type: Boolean })
2174
+ ], CollectionBrowser.prototype, "suppressSortBar", void 0);
2175
+ __decorate([
2176
+ property({ type: Boolean })
2177
+ ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
2178
+ __decorate([
2179
+ property({ type: String })
2180
+ ], CollectionBrowser.prototype, "facetLoadStrategy", void 0);
2181
+ __decorate([
2182
+ property({ type: Boolean })
2183
+ ], CollectionBrowser.prototype, "facetPaneVisible", void 0);
2184
+ __decorate([
2185
+ property({ type: Boolean })
2186
+ ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
2187
+ __decorate([
2188
+ property({ type: String })
2189
+ ], CollectionBrowser.prototype, "collectionPagePath", void 0);
2190
+ __decorate([
2191
+ property({ type: String, reflect: true })
2192
+ ], CollectionBrowser.prototype, "searchContext", void 0);
2193
+ __decorate([
2194
+ property({ type: String })
2195
+ ], CollectionBrowser.prototype, "pageContext", void 0);
2196
+ __decorate([
2197
+ property({ type: Object })
2198
+ ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
2199
+ __decorate([
2200
+ property({ type: Number })
2201
+ ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
2202
+ __decorate([
2203
+ property({ type: Boolean })
2204
+ ], CollectionBrowser.prototype, "loggedIn", void 0);
2205
+ __decorate([
2206
+ property({ type: Object })
2207
+ ], CollectionBrowser.prototype, "resizeObserver", void 0);
2208
+ __decorate([
2209
+ property({ type: Object })
2210
+ ], CollectionBrowser.prototype, "modalManager", void 0);
2211
+ __decorate([
2212
+ property({ type: Object })
2213
+ ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
2214
+ __decorate([
2215
+ property({ type: Object })
2216
+ ], CollectionBrowser.prototype, "recaptchaManager", void 0);
2217
+ __decorate([
2218
+ property({ type: Boolean })
2219
+ ], CollectionBrowser.prototype, "isManageView", void 0);
2220
+ __decorate([
2221
+ property({ type: String })
2222
+ ], CollectionBrowser.prototype, "manageViewLabel", void 0);
2223
+ __decorate([
2224
+ property({ type: Boolean })
2225
+ ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
2226
+ __decorate([
2227
+ property({ type: Boolean, reflect: true })
2228
+ ], CollectionBrowser.prototype, "showSmartResults", void 0);
2229
+ __decorate([
2230
+ property({ type: Object })
2231
+ ], CollectionBrowser.prototype, "dataSource", void 0);
2232
+ __decorate([
2233
+ state()
2234
+ ], CollectionBrowser.prototype, "pagesToRender", void 0);
2235
+ __decorate([
2236
+ state()
2237
+ ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
2238
+ __decorate([
2239
+ state()
2240
+ ], CollectionBrowser.prototype, "facetsLoading", void 0);
2241
+ __decorate([
2242
+ state()
2243
+ ], CollectionBrowser.prototype, "totalResults", void 0);
2244
+ __decorate([
2245
+ state()
2246
+ ], CollectionBrowser.prototype, "mobileView", void 0);
2247
+ __decorate([
2248
+ state()
2249
+ ], CollectionBrowser.prototype, "collapsibleFacetsVisible", void 0);
2250
+ __decorate([
2251
+ state()
2252
+ ], CollectionBrowser.prototype, "contentWidth", void 0);
2253
+ __decorate([
2254
+ state()
2255
+ ], CollectionBrowser.prototype, "placeholderType", void 0);
2256
+ __decorate([
2257
+ query('#content-container')
2258
+ ], CollectionBrowser.prototype, "contentContainer", void 0);
2259
+ __decorate([
2260
+ query('#left-column')
2261
+ ], CollectionBrowser.prototype, "leftColumn", void 0);
2262
+ __decorate([
2263
+ query('collection-facets')
2264
+ ], CollectionBrowser.prototype, "collectionFacets", void 0);
2265
+ __decorate([
2266
+ property({ type: Object, attribute: false })
2267
+ ], CollectionBrowser.prototype, "analyticsHandler", void 0);
2268
+ __decorate([
2269
+ query('infinite-scroller')
2270
+ ], CollectionBrowser.prototype, "infiniteScroller", void 0);
2271
+ CollectionBrowser = __decorate([
2272
+ customElement('collection-browser')
2273
+ ], CollectionBrowser);
2274
+ export { CollectionBrowser };
2260
2275
  //# sourceMappingURL=collection-browser.js.map