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