@internetarchive/collection-browser 2.7.7 → 2.7.8

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