@internetarchive/collection-browser 2.7.5 → 2.7.6-alpha1

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