@internetarchive/collection-browser 4.5.1 → 4.6.0

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 (520) hide show
  1. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.editorconfig +29 -0
  2. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/ci.yml +27 -0
  3. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/gh-pages-main.yml +39 -0
  4. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/npm-publish.yml +39 -0
  5. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.github/workflows/pr-preview.yml +38 -0
  6. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.husky/pre-commit +1 -0
  7. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/.prettierignore +1 -0
  8. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/LICENSE +661 -0
  9. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/README.md +84 -0
  10. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/eslint.config.mjs +53 -0
  11. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/index.html +24 -0
  12. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/index.ts +29 -0
  13. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/local.archive.org.cert +86 -0
  14. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/local.archive.org.key +27 -0
  15. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/package.json +120 -0
  16. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/renovate.json +6 -0
  17. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/app-root.ts +1284 -0
  18. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/arrow-left.ts +10 -0
  19. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/arrow-right.ts +10 -0
  20. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/chevron.ts +4 -0
  21. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/close-circle-dark.ts +5 -0
  22. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/contract.ts +9 -0
  23. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/empty-query.ts +5 -0
  24. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/expand.ts +9 -0
  25. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/eye-closed.ts +5 -0
  26. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/eye.ts +5 -0
  27. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/favorite-filled.ts +10 -0
  28. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/favorite-unfilled.ts +9 -0
  29. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/filter.ts +10 -0
  30. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/login-required.ts +18 -0
  31. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/account.ts +14 -0
  32. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/audio.ts +14 -0
  33. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/collection.ts +12 -0
  34. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/data.ts +15 -0
  35. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/etree.ts +14 -0
  36. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/film.ts +14 -0
  37. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/images.ts +13 -0
  38. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/radio.ts +15 -0
  39. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/search.ts +14 -0
  40. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/software.ts +13 -0
  41. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/texts.ts +13 -0
  42. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv-commercial.ts +12 -0
  43. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv-fact-check.ts +12 -0
  44. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv-quote.ts +12 -0
  45. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/tv.ts +14 -0
  46. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/video.ts +14 -0
  47. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/mediatype/web.ts +13 -0
  48. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/null-result.ts +5 -0
  49. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/quote.ts +7 -0
  50. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/restricted.ts +13 -0
  51. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/reviews.ts +11 -0
  52. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/upload.ts +12 -0
  53. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/assets/img/icons/views.ts +11 -0
  54. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/circular-activity-indicator.ts +64 -0
  55. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-browser.ts +3165 -0
  56. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/facet-row.ts +309 -0
  57. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/facet-tombstone-row.ts +40 -0
  58. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/facets-template.ts +85 -0
  59. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/models.ts +10 -0
  60. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/more-facets-content.ts +644 -0
  61. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/more-facets-pagination.ts +294 -0
  62. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/dedupe.ts +44 -0
  63. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.ts +27 -0
  64. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/index.ts +3 -0
  65. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.ts +17 -0
  66. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.ts +70 -0
  67. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.ts +79 -0
  68. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts +93 -0
  69. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/models.ts +36 -0
  70. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -0
  71. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-button.ts +145 -0
  72. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -0
  73. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-equals.ts +16 -0
  74. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/smart-facets/smart-facet-heuristics.ts +26 -0
  75. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets/toggle-switch.ts +174 -0
  76. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/collection-facets.ts +1013 -0
  77. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/collection-browser-data-source-interface.ts +351 -0
  78. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/collection-browser-data-source.ts +1474 -0
  79. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/collection-browser-query-state.ts +60 -0
  80. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/data-source/models.ts +56 -0
  81. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/empty-placeholder.ts +192 -0
  82. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/expanded-date-picker.ts +191 -0
  83. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/language-code-handler/language-code-handler.ts +64 -0
  84. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/language-code-handler/language-code-mapping.ts +564 -0
  85. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/manage/manage-bar.ts +276 -0
  86. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/manage/remove-items-modal-content.ts +102 -0
  87. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/mediatype/mediatype-config.ts +146 -0
  88. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/models.ts +895 -0
  89. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/restoration-state-handler.ts +550 -0
  90. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/alpha-bar-tooltip.ts +53 -0
  91. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/alpha-bar.ts +252 -0
  92. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/compact.ts +5 -0
  93. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/list.ts +5 -0
  94. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-toggle-disabled.ts +15 -0
  95. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-toggle-down.ts +17 -0
  96. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-toggle-up.ts +17 -0
  97. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/sort-triangle.ts +5 -0
  98. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/img/tile.ts +5 -0
  99. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/sort-filter-bar/sort-filter-bar.ts +733 -0
  100. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/ia-button.ts +139 -0
  101. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/item-image-styles.ts +124 -0
  102. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/sr-only.ts +18 -0
  103. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/styles/tile-action-styles.ts +59 -0
  104. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/base-tile-component.ts +124 -0
  105. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/collection-browser-loading-tile.ts +26 -0
  106. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/account-tile.ts +113 -0
  107. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/collection-tile.ts +184 -0
  108. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/item-tile.ts +347 -0
  109. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/search-tile.ts +90 -0
  110. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -0
  111. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/grid/tile-stats.ts +211 -0
  112. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/hover/hover-pane-controller.ts +638 -0
  113. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/hover/tile-hover-pane.ts +184 -0
  114. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/image-block.ts +162 -0
  115. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/item-image.ts +214 -0
  116. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/list/tile-list-compact-header.ts +112 -0
  117. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/list/tile-list-compact.ts +278 -0
  118. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/list/tile-list.ts +718 -0
  119. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/models.ts +21 -0
  120. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/overlay/icon-overlay.ts +57 -0
  121. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/overlay/text-overlay.ts +79 -0
  122. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/review-block.ts +130 -0
  123. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/text-snippet-block.ts +132 -0
  124. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/tile-dispatcher.ts +637 -0
  125. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/tile-display-value-provider.ts +133 -0
  126. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/tiles/tile-mediatype-icon.ts +133 -0
  127. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/analytics-events.ts +29 -0
  128. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/array-equals.ts +8 -0
  129. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/collapse-repeated-quotes.ts +13 -0
  130. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/date-filter-field.ts +11 -0
  131. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/facet-utils.ts +183 -0
  132. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/format-count.ts +95 -0
  133. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/format-date.ts +62 -0
  134. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/format-unit-size.ts +43 -0
  135. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/local-date-from-utc.ts +15 -0
  136. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/log.ts +14 -0
  137. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/resolve-mediatype.ts +26 -0
  138. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/src/utils/sha1.ts +9 -0
  139. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-browser.test.ts +2639 -0
  140. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/facet-row.test.ts +421 -0
  141. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/facets-template.test.ts +139 -0
  142. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/more-facets-content.test.ts +231 -0
  143. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/more-facets-pagination.test.ts +201 -0
  144. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets/toggle-switch.test.ts +164 -0
  145. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/collection-facets.test.ts +928 -0
  146. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/data-source/collection-browser-data-source.test.ts +193 -0
  147. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/empty-placeholder.test.ts +88 -0
  148. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/expanded-date-picker.test.ts +201 -0
  149. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/icon-overlay.test.ts +38 -0
  150. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/image-block.test.ts +247 -0
  151. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/item-image.test.ts +220 -0
  152. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/manage/manage-bar.test.ts +347 -0
  153. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/manage/remove-items-modal-content.test.ts +81 -0
  154. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mediatype-config.test.ts +11 -0
  155. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mocks/mock-analytics-handler.ts +30 -0
  156. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mocks/mock-search-responses.ts +1364 -0
  157. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/mocks/mock-search-service.ts +134 -0
  158. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/restoration-state-handler.test.ts +480 -0
  159. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/review-block.test.ts +62 -0
  160. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/sort-filter-bar/alpha-bar-tooltip.test.ts +17 -0
  161. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/sort-filter-bar/alpha-bar.test.ts +101 -0
  162. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/sort-filter-bar/sort-filter-bar.test.ts +443 -0
  163. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/text-overlay.test.ts +55 -0
  164. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/text-snippet-block.test.ts +85 -0
  165. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tile-stats.test.ts +191 -0
  166. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/account-tile.test.ts +121 -0
  167. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/collection-tile.test.ts +114 -0
  168. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/item-tile.test.ts +520 -0
  169. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/grid/search-tile.test.ts +75 -0
  170. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/hover/hover-pane-controller.test.ts +482 -0
  171. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/hover/tile-hover-pane.test.ts +80 -0
  172. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/list/tile-list-compact-header.test.ts +43 -0
  173. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/list/tile-list-compact.test.ts +282 -0
  174. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/list/tile-list.test.ts +576 -0
  175. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/tile-dispatcher.test.ts +320 -0
  176. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/tile-display-value-provider.test.ts +172 -0
  177. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/tiles/tile-mediatype-icon.test.ts +160 -0
  178. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/array-equals.test.ts +31 -0
  179. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/format-count.test.ts +32 -0
  180. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/format-date.test.ts +89 -0
  181. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/format-unit-size.test.ts +21 -0
  182. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/test/utils/local-date-from-utc.test.ts +37 -0
  183. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/tsconfig.json +25 -0
  184. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/types/dompurify.d.ts +1 -0
  185. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/vite.config.ts +29 -0
  186. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/web-dev-server.config.mjs +30 -0
  187. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/web-test-runner.config.mjs +52 -0
  188. package/.claude/worktrees/WEBDEV-8677-bump-field-parsers/yarn.lock +5965 -0
  189. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/.editorconfig +29 -0
  190. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/.github/workflows/ci.yml +29 -0
  191. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/.github/workflows/gh-pages-main.yml +41 -0
  192. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/.github/workflows/npm-publish.yml +42 -0
  193. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/.github/workflows/pr-preview.yml +40 -0
  194. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/.husky/pre-commit +1 -0
  195. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/.prettierignore +1 -0
  196. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/LICENSE +661 -0
  197. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/README.md +68 -0
  198. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/eslint.config.mjs +53 -0
  199. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/index.html +24 -0
  200. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/index.ts +29 -0
  201. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/local.archive.org.cert +86 -0
  202. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/local.archive.org.key +27 -0
  203. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/package.json +129 -0
  204. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/pnpm-lock.yaml +7366 -0
  205. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/pnpm-workspace.yaml +46 -0
  206. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/renovate.json +6 -0
  207. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/app-root.ts +1284 -0
  208. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/arrow-left.ts +10 -0
  209. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/arrow-right.ts +10 -0
  210. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/chevron.ts +4 -0
  211. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/close-circle-dark.ts +5 -0
  212. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/contract.ts +9 -0
  213. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/empty-query.ts +5 -0
  214. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/expand.ts +9 -0
  215. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/eye-closed.ts +5 -0
  216. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/eye.ts +5 -0
  217. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/favorite-filled.ts +10 -0
  218. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/favorite-unfilled.ts +9 -0
  219. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/filter.ts +10 -0
  220. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/login-required.ts +18 -0
  221. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/account.ts +14 -0
  222. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/audio.ts +14 -0
  223. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/collection.ts +12 -0
  224. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/data.ts +15 -0
  225. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/etree.ts +14 -0
  226. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/film.ts +14 -0
  227. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/images.ts +13 -0
  228. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/radio.ts +15 -0
  229. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/search.ts +14 -0
  230. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/software.ts +13 -0
  231. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/texts.ts +13 -0
  232. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/tv-commercial.ts +12 -0
  233. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/tv-fact-check.ts +12 -0
  234. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/tv-quote.ts +12 -0
  235. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/tv.ts +14 -0
  236. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/video.ts +14 -0
  237. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/mediatype/web.ts +13 -0
  238. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/null-result.ts +5 -0
  239. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/quote.ts +7 -0
  240. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/restricted.ts +13 -0
  241. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/reviews.ts +11 -0
  242. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/upload.ts +12 -0
  243. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/assets/img/icons/views.ts +11 -0
  244. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/circular-activity-indicator.ts +64 -0
  245. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-browser.ts +3165 -0
  246. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/facet-row.ts +309 -0
  247. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/facet-tombstone-row.ts +40 -0
  248. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/facets-template.ts +85 -0
  249. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/models.ts +10 -0
  250. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/more-facets-content.ts +644 -0
  251. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/more-facets-pagination.ts +294 -0
  252. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/dedupe.ts +44 -0
  253. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.ts +27 -0
  254. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/heuristics/index.ts +3 -0
  255. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.ts +17 -0
  256. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.ts +70 -0
  257. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.ts +79 -0
  258. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts +93 -0
  259. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/models.ts +36 -0
  260. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -0
  261. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/smart-facet-button.ts +145 -0
  262. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -0
  263. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/smart-facet-equals.ts +16 -0
  264. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/smart-facets/smart-facet-heuristics.ts +26 -0
  265. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets/toggle-switch.ts +174 -0
  266. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/collection-facets.ts +1013 -0
  267. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/data-source/collection-browser-data-source-interface.ts +351 -0
  268. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/data-source/collection-browser-data-source.ts +1474 -0
  269. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/data-source/collection-browser-query-state.ts +60 -0
  270. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/data-source/models.ts +56 -0
  271. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/empty-placeholder.ts +192 -0
  272. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/expanded-date-picker.ts +191 -0
  273. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/language-code-handler/language-code-handler.ts +64 -0
  274. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/language-code-handler/language-code-mapping.ts +564 -0
  275. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/manage/manage-bar.ts +276 -0
  276. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/manage/remove-items-modal-content.ts +102 -0
  277. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/mediatype/mediatype-config.ts +146 -0
  278. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/models.ts +895 -0
  279. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/restoration-state-handler.ts +550 -0
  280. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/alpha-bar-tooltip.ts +53 -0
  281. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/alpha-bar.ts +252 -0
  282. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/img/compact.ts +5 -0
  283. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/img/list.ts +5 -0
  284. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/img/sort-toggle-disabled.ts +15 -0
  285. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/img/sort-toggle-down.ts +17 -0
  286. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/img/sort-toggle-up.ts +17 -0
  287. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/img/sort-triangle.ts +5 -0
  288. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/img/tile.ts +5 -0
  289. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/sort-filter-bar/sort-filter-bar.ts +733 -0
  290. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/styles/ia-button.ts +139 -0
  291. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/styles/item-image-styles.ts +124 -0
  292. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/styles/sr-only.ts +18 -0
  293. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/styles/tile-action-styles.ts +59 -0
  294. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/base-tile-component.ts +124 -0
  295. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/collection-browser-loading-tile.ts +26 -0
  296. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/grid/account-tile.ts +113 -0
  297. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/grid/collection-tile.ts +184 -0
  298. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/grid/item-tile.ts +347 -0
  299. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/grid/search-tile.ts +90 -0
  300. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -0
  301. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/grid/tile-stats.ts +211 -0
  302. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/hover/hover-pane-controller.ts +638 -0
  303. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/hover/tile-hover-pane.ts +184 -0
  304. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/image-block.ts +162 -0
  305. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/item-image.ts +214 -0
  306. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/list/tile-list-compact-header.ts +112 -0
  307. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/list/tile-list-compact.ts +278 -0
  308. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/list/tile-list.ts +718 -0
  309. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/models.ts +21 -0
  310. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/overlay/icon-overlay.ts +57 -0
  311. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/overlay/text-overlay.ts +79 -0
  312. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/review-block.ts +130 -0
  313. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/text-snippet-block.ts +132 -0
  314. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/tile-dispatcher.ts +637 -0
  315. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/tile-display-value-provider.ts +133 -0
  316. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/tiles/tile-mediatype-icon.ts +133 -0
  317. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/analytics-events.ts +29 -0
  318. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/array-equals.ts +8 -0
  319. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/collapse-repeated-quotes.ts +13 -0
  320. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/date-filter-field.ts +11 -0
  321. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/facet-utils.ts +183 -0
  322. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/format-count.ts +95 -0
  323. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/format-date.ts +62 -0
  324. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/format-unit-size.ts +43 -0
  325. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/local-date-from-utc.ts +15 -0
  326. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/log.ts +14 -0
  327. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/resolve-mediatype.ts +26 -0
  328. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/src/utils/sha1.ts +9 -0
  329. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/collection-browser.test.ts +2639 -0
  330. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/collection-facets/facet-row.test.ts +421 -0
  331. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/collection-facets/facets-template.test.ts +139 -0
  332. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/collection-facets/more-facets-content.test.ts +231 -0
  333. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/collection-facets/more-facets-pagination.test.ts +201 -0
  334. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/collection-facets/toggle-switch.test.ts +164 -0
  335. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/collection-facets.test.ts +928 -0
  336. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/data-source/collection-browser-data-source.test.ts +193 -0
  337. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/empty-placeholder.test.ts +88 -0
  338. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/expanded-date-picker.test.ts +201 -0
  339. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/icon-overlay.test.ts +38 -0
  340. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/image-block.test.ts +247 -0
  341. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/item-image.test.ts +220 -0
  342. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/manage/manage-bar.test.ts +347 -0
  343. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/manage/remove-items-modal-content.test.ts +81 -0
  344. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/mediatype-config.test.ts +11 -0
  345. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/mocks/mock-analytics-handler.ts +30 -0
  346. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/mocks/mock-search-responses.ts +1364 -0
  347. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/mocks/mock-search-service.ts +134 -0
  348. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/restoration-state-handler.test.ts +480 -0
  349. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/review-block.test.ts +62 -0
  350. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/sort-filter-bar/alpha-bar-tooltip.test.ts +17 -0
  351. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/sort-filter-bar/alpha-bar.test.ts +101 -0
  352. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/sort-filter-bar/sort-filter-bar.test.ts +443 -0
  353. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/text-overlay.test.ts +55 -0
  354. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/text-snippet-block.test.ts +85 -0
  355. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tile-stats.test.ts +191 -0
  356. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/grid/account-tile.test.ts +121 -0
  357. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/grid/collection-tile.test.ts +114 -0
  358. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/grid/item-tile.test.ts +520 -0
  359. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/grid/search-tile.test.ts +75 -0
  360. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/hover/hover-pane-controller.test.ts +482 -0
  361. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/hover/tile-hover-pane.test.ts +80 -0
  362. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/list/tile-list-compact-header.test.ts +43 -0
  363. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/list/tile-list-compact.test.ts +282 -0
  364. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/list/tile-list.test.ts +576 -0
  365. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/tile-dispatcher.test.ts +320 -0
  366. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/tile-display-value-provider.test.ts +172 -0
  367. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/tiles/tile-mediatype-icon.test.ts +160 -0
  368. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/utils/array-equals.test.ts +31 -0
  369. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/utils/format-count.test.ts +32 -0
  370. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/utils/format-date.test.ts +89 -0
  371. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/utils/format-unit-size.test.ts +21 -0
  372. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/test/utils/local-date-from-utc.test.ts +37 -0
  373. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/tsconfig.json +25 -0
  374. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/types/dompurify.d.ts +1 -0
  375. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/vite.config.ts +29 -0
  376. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/web-dev-server.config.mjs +30 -0
  377. package/.claude/worktrees/WEBDEV-9119-migrate-to-pnpm/web-test-runner.config.mjs +52 -0
  378. package/.editorconfig +29 -29
  379. package/.github/workflows/ci.yml +27 -27
  380. package/.github/workflows/gh-pages-main.yml +39 -39
  381. package/.github/workflows/npm-publish.yml +39 -39
  382. package/.github/workflows/pr-preview.yml +38 -38
  383. package/.husky/pre-commit +1 -1
  384. package/.prettierignore +1 -1
  385. package/LICENSE +661 -661
  386. package/README.md +83 -83
  387. package/dist/index.js.map +1 -1
  388. package/dist/src/app-root.d.ts +1 -1
  389. package/dist/src/app-root.js +683 -683
  390. package/dist/src/app-root.js.map +1 -1
  391. package/dist/src/assets/img/icons/arrow-left.d.ts +1 -1
  392. package/dist/src/assets/img/icons/arrow-right.d.ts +1 -1
  393. package/dist/src/assets/img/icons/chevron.d.ts +1 -1
  394. package/dist/src/assets/img/icons/close-circle-dark.d.ts +1 -1
  395. package/dist/src/assets/img/icons/contract.d.ts +1 -1
  396. package/dist/src/assets/img/icons/empty-query.d.ts +1 -1
  397. package/dist/src/assets/img/icons/expand.d.ts +1 -1
  398. package/dist/src/assets/img/icons/eye-closed.d.ts +1 -1
  399. package/dist/src/assets/img/icons/eye.d.ts +1 -1
  400. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  401. package/dist/src/assets/img/icons/favorite-unfilled.d.ts +1 -1
  402. package/dist/src/assets/img/icons/filter.d.ts +1 -1
  403. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  404. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  405. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  406. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  407. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  408. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  409. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  410. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  411. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  412. package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -1
  413. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  414. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  415. package/dist/src/assets/img/icons/mediatype/tv-commercial.d.ts +1 -1
  416. package/dist/src/assets/img/icons/mediatype/tv-fact-check.d.ts +1 -1
  417. package/dist/src/assets/img/icons/mediatype/tv-quote.d.ts +1 -1
  418. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  419. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  420. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  421. package/dist/src/assets/img/icons/null-result.d.ts +1 -1
  422. package/dist/src/assets/img/icons/quote.d.ts +1 -1
  423. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  424. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  425. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  426. package/dist/src/assets/img/icons/views.d.ts +1 -1
  427. package/dist/src/circular-activity-indicator.d.ts +1 -1
  428. package/dist/src/collection-browser.js +766 -766
  429. package/dist/src/collection-browser.js.map +1 -1
  430. package/dist/src/collection-facets/facet-row.js +143 -143
  431. package/dist/src/collection-facets/facet-row.js.map +1 -1
  432. package/dist/src/collection-facets/facet-tombstone-row.d.ts +1 -1
  433. package/dist/src/collection-facets/facets-template.js +24 -24
  434. package/dist/src/collection-facets/facets-template.js.map +1 -1
  435. package/dist/src/collection-facets/smart-facets/smart-facet-button.d.ts +1 -1
  436. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +1 -1
  437. package/dist/src/collection-facets/toggle-switch.d.ts +1 -1
  438. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  439. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  440. package/dist/src/restoration-state-handler.js.map +1 -1
  441. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +1 -1
  442. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  443. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  444. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
  445. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
  446. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
  447. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  448. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  449. package/dist/src/styles/tile-action-styles.js +43 -43
  450. package/dist/src/styles/tile-action-styles.js.map +1 -1
  451. package/dist/src/tiles/base-tile-component.js +11 -11
  452. package/dist/src/tiles/base-tile-component.js.map +1 -1
  453. package/dist/src/tiles/collection-browser-loading-tile.d.ts +1 -1
  454. package/dist/src/tiles/grid/item-tile.js +138 -138
  455. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  456. package/dist/src/tiles/hover/hover-pane-controller.js +15 -5
  457. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  458. package/dist/src/tiles/image-block.d.ts +1 -1
  459. package/dist/src/tiles/item-image.d.ts +1 -1
  460. package/dist/src/tiles/list/tile-list-compact-header.d.ts +1 -1
  461. package/dist/src/tiles/list/tile-list-compact-header.js +62 -62
  462. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  463. package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
  464. package/dist/src/tiles/list/tile-list-compact.js +123 -123
  465. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  466. package/dist/src/tiles/list/tile-list.js +310 -310
  467. package/dist/src/tiles/list/tile-list.js.map +1 -1
  468. package/dist/src/tiles/models.js.map +1 -1
  469. package/dist/src/tiles/tile-dispatcher.d.ts +1 -1
  470. package/dist/src/tiles/tile-dispatcher.js +286 -286
  471. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  472. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  473. package/dist/src/tiles/tile-mediatype-icon.d.ts +1 -1
  474. package/dist/src/utils/date-filter-field.js.map +1 -1
  475. package/dist/test/collection-browser.test.js +203 -203
  476. package/dist/test/collection-browser.test.js.map +1 -1
  477. package/dist/test/collection-facets/facet-row.test.js +31 -31
  478. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  479. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  480. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  481. package/dist/test/tiles/hover/hover-pane-controller.test.js +55 -21
  482. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  483. package/dist/test/tiles/list/tile-list.test.js +134 -134
  484. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  485. package/dist/test/tiles/tile-dispatcher.test.js +92 -92
  486. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  487. package/eslint.config.mjs +53 -53
  488. package/index.html +24 -24
  489. package/index.ts +29 -29
  490. package/local.archive.org.cert +86 -86
  491. package/local.archive.org.key +27 -27
  492. package/package.json +120 -120
  493. package/renovate.json +6 -6
  494. package/src/app-root.ts +1284 -1284
  495. package/src/collection-browser.ts +3165 -3165
  496. package/src/collection-facets/facet-row.ts +309 -309
  497. package/src/collection-facets/facets-template.ts +85 -85
  498. package/src/data-source/collection-browser-data-source-interface.ts +351 -351
  499. package/src/data-source/collection-browser-data-source.ts +1474 -1474
  500. package/src/restoration-state-handler.ts +550 -550
  501. package/src/styles/tile-action-styles.ts +59 -59
  502. package/src/tiles/base-tile-component.ts +124 -124
  503. package/src/tiles/grid/item-tile.ts +347 -347
  504. package/src/tiles/hover/hover-pane-controller.ts +15 -5
  505. package/src/tiles/list/tile-list-compact-header.ts +112 -112
  506. package/src/tiles/list/tile-list-compact.ts +278 -278
  507. package/src/tiles/list/tile-list.ts +718 -718
  508. package/src/tiles/models.ts +21 -21
  509. package/src/tiles/tile-dispatcher.ts +637 -637
  510. package/src/tiles/tile-display-value-provider.ts +133 -133
  511. package/src/utils/date-filter-field.ts +11 -11
  512. package/test/collection-browser.test.ts +2639 -2639
  513. package/test/collection-facets/facet-row.test.ts +421 -421
  514. package/test/tiles/grid/item-tile.test.ts +520 -520
  515. package/test/tiles/hover/hover-pane-controller.test.ts +87 -23
  516. package/test/tiles/list/tile-list.test.ts +576 -576
  517. package/test/tiles/tile-dispatcher.test.ts +320 -320
  518. package/tsconfig.json +25 -25
  519. package/web-dev-server.config.mjs +30 -30
  520. package/web-test-runner.config.mjs +52 -52
@@ -0,0 +1,3165 @@
1
+ import {
2
+ html,
3
+ css,
4
+ LitElement,
5
+ PropertyValues,
6
+ TemplateResult,
7
+ HTMLTemplateResult,
8
+ nothing,
9
+ } from 'lit';
10
+ import { customElement, property, query, state } from 'lit/decorators.js';
11
+ import { classMap } from 'lit/directives/class-map.js';
12
+ import { msg } from '@lit/localize';
13
+
14
+ import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
15
+ import type {
16
+ InfiniteScroller,
17
+ InfiniteScrollerCellProviderInterface,
18
+ } from '@internetarchive/infinite-scroller';
19
+ import {
20
+ CollectionExtraInfo,
21
+ PageElementName,
22
+ SearchServiceInterface,
23
+ SearchType,
24
+ SortDirection,
25
+ SortParam,
26
+ } from '@internetarchive/search-service';
27
+ import type {
28
+ SharedResizeObserverInterface,
29
+ SharedResizeObserverResizeHandlerInterface,
30
+ } from '@internetarchive/shared-resize-observer';
31
+ import '@internetarchive/infinite-scroller';
32
+ import type { ModalManagerInterface } from '@internetarchive/modal-manager';
33
+ import type { FeatureFeedbackServiceInterface } from '@internetarchive/feature-feedback';
34
+ import type { RecaptchaManagerInterface } from '@internetarchive/recaptcha-manager';
35
+ import type { IAComboBox } from '@internetarchive/elements/ia-combo-box/ia-combo-box';
36
+ import {
37
+ SelectedFacets,
38
+ SortField,
39
+ CollectionBrowserContext,
40
+ getDefaultSelectedFacets,
41
+ TileModel,
42
+ CollectionDisplayMode,
43
+ FacetEventDetails,
44
+ sortOptionFromAPIString,
45
+ SORT_OPTIONS,
46
+ defaultProfileElementSorts,
47
+ FacetLoadStrategy,
48
+ defaultFacetDisplayOrder,
49
+ tvFacetDisplayOrder,
50
+ TileBlurOverrideState,
51
+ defaultSortAvailability,
52
+ favoritesSortAvailability,
53
+ tvSortAvailability,
54
+ FacetBucket,
55
+ } from './models';
56
+ import {
57
+ RestorationStateHandlerInterface,
58
+ RestorationStateHandler,
59
+ RestorationState,
60
+ RestorationStatePersistOptions,
61
+ } from './restoration-state-handler';
62
+ import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
63
+ import type {
64
+ CollectionBrowserQueryState,
65
+ CollectionBrowserSearchInterface,
66
+ } from './data-source/collection-browser-query-state';
67
+ import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
68
+ import type { CollectionFacets } from './collection-facets';
69
+ import type { CollectionBrowserDataSourceInterface } from './data-source/collection-browser-data-source-interface';
70
+ import {
71
+ analyticsActions,
72
+ analyticsCategories,
73
+ } from './utils/analytics-events';
74
+ import { updateSelectedFacetBucket } from './utils/facet-utils';
75
+ import chevronIcon from './assets/img/icons/chevron';
76
+ import { srOnlyStyle } from './styles/sr-only';
77
+ import { sha1 } from './utils/sha1';
78
+ import type { PlaceholderType } from './empty-placeholder';
79
+ import type { ManageBar } from './manage/manage-bar';
80
+ import type { SmartFacetBar } from './collection-facets/smart-facets/smart-facet-bar';
81
+ import type { LayoutType, TileAction } from './tiles/models';
82
+
83
+ import '@internetarchive/elements/ia-combo-box/ia-combo-box';
84
+ import './empty-placeholder';
85
+ import './tiles/tile-dispatcher';
86
+ import './tiles/collection-browser-loading-tile';
87
+ import './sort-filter-bar/sort-filter-bar';
88
+ import './manage/manage-bar';
89
+ import './collection-facets';
90
+ import './circular-activity-indicator';
91
+ import './collection-facets/smart-facets/smart-facet-bar';
92
+
93
+ @customElement('collection-browser')
94
+ export class CollectionBrowser
95
+ extends LitElement
96
+ implements
97
+ InfiniteScrollerCellProviderInterface,
98
+ SharedResizeObserverResizeHandlerInterface,
99
+ CollectionBrowserSearchInterface
100
+ {
101
+ @property({ type: String }) baseNavigationUrl?: string;
102
+
103
+ @property({ type: String }) baseImageUrl: string = 'https://archive.org';
104
+
105
+ @property({ type: Object }) searchService?: SearchServiceInterface;
106
+
107
+ /**
108
+ * Which backend should be targeted by searches (e.g., metadata or FTS)
109
+ */
110
+ @property({ type: Number }) searchType: SearchType = SearchType.DEFAULT;
111
+
112
+ /**
113
+ * The identifier of the collection that searches should be performed within
114
+ */
115
+ @property({ type: String }) withinCollection?: string;
116
+
117
+ /**
118
+ * The identifier (e.g., @person) of the user whose profile is being searched within
119
+ */
120
+ @property({ type: String }) withinProfile?: string;
121
+
122
+ /**
123
+ * Which section of the profile page searches are for (e.g., uploads, reviews, ...)
124
+ */
125
+ @property({ type: String }) profileElement?: PageElementName;
126
+
127
+ /**
128
+ * The base query to use for all searches, updated to match the current user query.
129
+ */
130
+ @property({ type: String }) baseQuery?: string;
131
+
132
+ /**
133
+ * The base list of identifiers to fetch, if using the client_document_fetch feature
134
+ * of the search service.
135
+ *
136
+ * This approach allows many more identifiers to be retrieved than a query like
137
+ * `identifier:(foo OR bar OR ...)` would, but still may be more limited in what
138
+ * content is returned by the backend
139
+ */
140
+ @property({ type: Array }) identifiers?: string[];
141
+
142
+ /**
143
+ * Which mode to display result tiles in (grid, extended list, or compact list)
144
+ */
145
+ @property({ type: String }) displayMode?: CollectionDisplayMode;
146
+
147
+ @property({ type: String }) selectedSort: SortField = SortField.default;
148
+
149
+ @property({ type: String }) selectedTitleFilter: string | null = null;
150
+
151
+ @property({ type: String }) selectedCreatorFilter: string | null = null;
152
+
153
+ @property({ type: String }) sortDirection: SortDirection | null = null;
154
+
155
+ @property({ type: String }) defaultSortField: Exclude<
156
+ SortField,
157
+ SortField.default
158
+ > = SortField.relevance;
159
+
160
+ @property({ type: String }) defaultSortDirection: SortDirection | null = null;
161
+
162
+ @property({ type: Number }) pageSize = 50;
163
+
164
+ @property({ type: Number }) currentPage?: number;
165
+
166
+ @property({ type: String }) minSelectedDate?: string;
167
+
168
+ @property({ type: String }) maxSelectedDate?: string;
169
+
170
+ @property({ type: Object }) selectedFacets?: SelectedFacets;
171
+
172
+ /**
173
+ * Set of filters to be applied internally to searches, but not included in URL params or
174
+ * visibly selected facets. Use when this instance of collection browser is being shown
175
+ * in a filtered context, such as a single-mediatype tab, but the corresponding filters
176
+ * should not be exposed/changeable within that context.
177
+ */
178
+ @property({ type: Object }) internalFilters?: SelectedFacets;
179
+
180
+ /**
181
+ * Whether to show smart facets (bubbles) along the top of the component
182
+ */
183
+ @property({ type: Boolean }) showSmartFacetBar = false;
184
+
185
+ /**
186
+ * Sets the label that is shown in front of the smart facets, if present.
187
+ */
188
+ @property({ type: String }) smartFacetBarLabel?: string;
189
+
190
+ /**
191
+ * Whether to show the date picker (above the facets)
192
+ */
193
+ @property({ type: Boolean }) showHistogramDatePicker = false;
194
+
195
+ /**
196
+ * Whether placeholder views should be suppressed. If true, searches that produce an
197
+ * error or empty result set will simply show a blank results view instead of a placeholder.
198
+ */
199
+ @property({ type: Boolean }) suppressPlaceholders = false;
200
+
201
+ /**
202
+ * Whether the result count text should be suppressed.
203
+ * If true, no "X Results" message will be shown.
204
+ */
205
+ @property({ type: Boolean }) suppressResultCount = false;
206
+
207
+ /**
208
+ * Whether the scrolling result view should be suppressed entirely.
209
+ * If true, no infinite scroller (and thus no result tiles) will be rendered.
210
+ */
211
+ @property({ type: Boolean }) suppressResultTiles = false;
212
+
213
+ /**
214
+ * Whether to suppress persistence of the query to the URL.
215
+ * If true, the `query` param will not be added to the URL or updated on query changes.
216
+ */
217
+ @property({ type: Boolean }) suppressURLQuery = false;
218
+
219
+ /**
220
+ * Whether to suppress persistence of the `sin` search type param to the URL.
221
+ * If true, the `sin` param will not be added to the URL or updated on query changes.
222
+ */
223
+ @property({ type: Boolean }) suppressURLSinParam = false;
224
+
225
+ /**
226
+ * Whether to suppress display of the sort bar.
227
+ * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
228
+ */
229
+ @property({ type: Boolean }) suppressSortBar = false;
230
+
231
+ /**
232
+ * Whether to suppress showing the display mode options in the sort bar.
233
+ * If true, those options will be omitted (though the rest of the sort bar may still render).
234
+ */
235
+ @property({ type: Boolean }) suppressDisplayModes = false;
236
+
237
+ /**
238
+ * Whether to suppress the display of the `mediatype` facet group, e.g., because this instance
239
+ * of collection browser is being shown in a filtered single-mediatype context.
240
+ */
241
+ @property({ type: Boolean }) suppressMediatypeFacets = false;
242
+
243
+ /**
244
+ * What strategy to use for when/whether to load facet data for a search.
245
+ *
246
+ * Defaults to `eager`, always loading facets immediately alongside search results.
247
+ *
248
+ * To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
249
+ * will delay loading facets in the mobile view until the "Filters" accordion is opened.
250
+ * Facets are still loaded eagerly when viewing the desktop layout.
251
+ *
252
+ * To further reduce facet requests for patrons who do not need to use them, this can be
253
+ * again reduced to `opt-in`, which will also require desktop users to explicitly request
254
+ * that they be loaded (in addition to the lazy mobile behavior described above).
255
+ *
256
+ * To entirely suppress facets from being loaded, this may be set to `off`.
257
+ */
258
+ @property({ type: String }) facetLoadStrategy: FacetLoadStrategy = 'eager';
259
+
260
+ @property({ type: Boolean, reflect: true }) facetPaneVisible = false;
261
+
262
+ @property({ type: Boolean }) clearResultsOnEmptyQuery = false;
263
+
264
+ @property({ type: String }) collectionPagePath: string = '/details/';
265
+
266
+ /** describes where this component is being used */
267
+ @property({ type: String, reflect: true }) searchContext: string =
268
+ analyticsCategories.default;
269
+
270
+ @property({ type: String }) pageContext: CollectionBrowserContext = 'search';
271
+
272
+ @property({ type: Object })
273
+ restorationStateHandler: RestorationStateHandlerInterface =
274
+ new RestorationStateHandler({
275
+ context: this.pageContext,
276
+ });
277
+
278
+ @property({ type: Number }) mobileBreakpoint = 600;
279
+
280
+ @property({ type: Boolean }) loggedIn = false;
281
+
282
+ @property({ type: Object }) resizeObserver?: SharedResizeObserverInterface;
283
+
284
+ @property({ type: Object }) modalManager?: ModalManagerInterface = undefined;
285
+
286
+ @property({ type: Object })
287
+ featureFeedbackService?: FeatureFeedbackServiceInterface;
288
+
289
+ @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;
290
+
291
+ /**
292
+ * Whether we are representing a TV collection, needing slightly different tile handling.
293
+ */
294
+ @property({ type: Boolean }) isTVCollection = false;
295
+
296
+ /**
297
+ * If item management UI active
298
+ */
299
+ @property({ type: Boolean }) isManageView = false;
300
+
301
+ /** Action buttons to display on each tile */
302
+ @property({ type: Array }) tileActions: TileAction[] = [];
303
+
304
+ /**
305
+ * The simplified layout to apply to grid-mode tiles, if any. See
306
+ * `LayoutType` for available options. Has no effect on list display modes.
307
+ */
308
+ @property({ type: String }) tileLayoutType: LayoutType = 'default';
309
+
310
+ @property({ type: String }) manageViewLabel = 'Select items to remove';
311
+
312
+ /** Whether to replace the default sort options with a slot for customization (default: false) */
313
+ @property({ type: Boolean }) enableSortOptionsSlot = false;
314
+
315
+ /** Whether to expose a slot for a smart results carousel above the full results */
316
+ @property({ type: Boolean, reflect: true }) showSmartResults = false;
317
+
318
+ /**
319
+ * The maximum number of pages we will load when a privileged user clicks
320
+ * the "Manage" button on the search page. Limited to 15 pages.
321
+ */
322
+ @property({ type: Number }) maxPagesToManage = 15;
323
+
324
+ /**
325
+ * The results per page so we can paginate.
326
+ *
327
+ * This allows us to start in the middle of the search results and
328
+ * fetch data before or after the current page. If we don't have a key
329
+ * for the previous/next page, we'll fetch the next/previous page to populate it
330
+ */
331
+ @property({ type: Object }) dataSource: CollectionBrowserDataSourceInterface =
332
+ new CollectionBrowserDataSource(this, this.pageSize);
333
+
334
+ /**
335
+ * The page that the consumer wants to load.
336
+ */
337
+ initialPageNumber = 1;
338
+
339
+ /**
340
+ * This the the number of pages that we want to show.
341
+ *
342
+ * The data isn't necessarily loaded for all of the pages, but this lets us
343
+ * know how many cells we should render.
344
+ */
345
+ @state() private pagesToRender = this.initialPageNumber;
346
+
347
+ /**
348
+ * Whether the initial page fetch for a new query is currently in progress.
349
+ */
350
+ @state() private searchResultsLoading = false;
351
+
352
+ @state() private facetsLoading = false;
353
+
354
+ @state() private totalResults?: number;
355
+
356
+ @state() private mobileView = false;
357
+
358
+ /**
359
+ * Any temporarily overridden `on`/`off` state for the user's tile blurring preference if they
360
+ * have chosen to override it, or `no-override` if they have not.
361
+ */
362
+ @state() private tileBlurOverrideState: TileBlurOverrideState = 'no-override';
363
+
364
+ @state() private collapsibleFacetsVisible = false;
365
+
366
+ @state() private contentWidth?: number;
367
+
368
+ @state() private placeholderType: PlaceholderType = null;
369
+
370
+ @state() private selectedTVNetwork?: string = undefined;
371
+
372
+ @state() private selectedTVShow?: string = undefined;
373
+
374
+ @state() private tvMapsPopulated: boolean = false;
375
+
376
+ @state() private tvMapsLoading: boolean = false;
377
+
378
+ @state() private tvMapsErrored: boolean = false;
379
+
380
+ @query('#content-container') private contentContainer!: HTMLDivElement;
381
+
382
+ @query('#left-column') private leftColumn?: HTMLDivElement;
383
+
384
+ @query('collection-facets') private collectionFacets?: CollectionFacets;
385
+
386
+ @query('manage-bar') private manageBar?: ManageBar;
387
+
388
+ @query('smart-facet-bar') private smartFacetBar?: SmartFacetBar;
389
+
390
+ @query('#tv-networks') private tvNetworksDropdown?: IAComboBox;
391
+
392
+ @query('#tv-shows') private tvShowsDropdown?: IAComboBox;
393
+
394
+ @property({ type: Object, attribute: false })
395
+ analyticsHandler?: AnalyticsManagerInterface;
396
+
397
+ /** Whether layout size analytics have been sent already. */
398
+ private layoutSizeAnalyticsSent = false;
399
+
400
+ /**
401
+ * When we're animated scrolling to the page, we don't want to fetch
402
+ * all of the pages as it scrolls so this lets us know if we're scrolling
403
+ */
404
+ private isScrollingToCell = false;
405
+
406
+ /**
407
+ * When page width resizes from desktop to mobile, set true to
408
+ * disable expand/collapse transition when loading.
409
+ */
410
+ private isResizeToMobile = false;
411
+
412
+ /**
413
+ * Flag indicating that a new data source is currently being installed.
414
+ * During the install, any URL persistence operation should replace the current entry
415
+ * instead of creating a new one.
416
+ */
417
+ private dataSourceInstallInProgress = false;
418
+
419
+ private leftColIntersectionObserver?: IntersectionObserver;
420
+
421
+ private facetsIntersectionObserver?: IntersectionObserver;
422
+
423
+ private placeholderCellTemplate = html`<collection-browser-loading-tile></collection-browser-loading-tile>`;
424
+
425
+ constructor() {
426
+ super();
427
+ this.addController(this.dataSource);
428
+ }
429
+
430
+ private tileModelAtCellIndex(index: number): TileModel | undefined {
431
+ const model = this.dataSource.getTileModelAt(index);
432
+ /**
433
+ * If we encounter a model we don't have yet and we're not in the middle of an
434
+ * automated scroll, schedule a fetch for the missing page and return undefined.
435
+ * The datasource will be updated once the page is loaded and the cell will be rendered.
436
+ *
437
+ * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
438
+ * user may never see.
439
+ */
440
+ if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
441
+ const pageNumber = Math.floor(index / this.pageSize) + 1;
442
+ this.scheduleDeferredPageFetch(pageNumber);
443
+ }
444
+ return model;
445
+ }
446
+
447
+ /**
448
+ * Debounce delay for page fetches initiated by new cells becoming visible.
449
+ * Tuned so quick scrolling through unloaded regions doesn't send rapid-fire
450
+ * search requests for every page we pass through, but to still feel responsive
451
+ * when the scroll ends.
452
+ */
453
+ private static readonly DEFERRED_FETCH_DELAY_MS = 150;
454
+
455
+ private deferredFetchTimer = 0;
456
+
457
+ /**
458
+ * Schedules a fetch for the given page, debounced to ensure we don't
459
+ * rapid-fire fetches while scrolling through pages quickly.
460
+ *
461
+ * If there's no pending fetch timer yet, it will fire a fetch immediately.
462
+ * Otherwise, it will reset any existing timer. In either case, a deferred
463
+ * fetch for the visible pages is scheduled after a brief delay to account
464
+ * for whatever pages we land on after scrolling.
465
+ */
466
+ private scheduleDeferredPageFetch(pageNumber: number): void {
467
+ if (!this.deferredFetchTimer) {
468
+ this.dataSource.fetchPage(pageNumber);
469
+ } else {
470
+ window.clearTimeout(this.deferredFetchTimer);
471
+ }
472
+
473
+ this.deferredFetchTimer = window.setTimeout(() => {
474
+ this.deferredFetchTimer = 0;
475
+ this.fetchVisiblePages();
476
+ }, CollectionBrowser.DEFERRED_FETCH_DELAY_MS);
477
+ }
478
+
479
+ /**
480
+ * Fetch each currently-visible page whose first cell still has no
481
+ * loaded model.
482
+ */
483
+ private fetchVisiblePages(): void {
484
+ const visibleIndices = this.infiniteScroller?.getVisibleCellIndices() ?? [];
485
+ const visiblePages = new Set(
486
+ visibleIndices.map(i => Math.floor(i / this.pageSize) + 1),
487
+ );
488
+
489
+ for (const page of visiblePages) {
490
+ const firstCellOfPage = (page - 1) * this.pageSize;
491
+ if (!this.dataSource.getTileModelAt(firstCellOfPage)) {
492
+ this.dataSource.fetchPage(page);
493
+ }
494
+ }
495
+ }
496
+
497
+ // this is the total number of tiles we expect if
498
+ // the data returned is a full page worth
499
+ // this is useful for putting in placeholders for the expected number of tiles
500
+ private get estimatedTileCount(): number {
501
+ return this.pagesToRender * this.pageSize;
502
+ }
503
+
504
+ @query('infinite-scroller')
505
+ private infiniteScroller?: InfiniteScroller;
506
+
507
+ private sessionIdGenPromise?: Promise<string>;
508
+
509
+ /**
510
+ * Returns a promise resolving to a unique string that persists for the current browser session.
511
+ * Used in generating unique IDs for search requests, so that multiple requests coming from the
512
+ * same browser session can be identified.
513
+ */
514
+ async getSessionId(): Promise<string> {
515
+ try {
516
+ const storedSessionId = sessionStorage?.getItem('cb-session');
517
+ if (storedSessionId) {
518
+ return storedSessionId;
519
+ }
520
+
521
+ // If we enter this method a second time while a first session ID is already being generated,
522
+ // ensure we produce the same ID from both calls instead of generating another one.
523
+ if (this.sessionIdGenPromise) {
524
+ return this.sessionIdGenPromise;
525
+ }
526
+
527
+ this.sessionIdGenPromise = sha1(Math.random().toString());
528
+ const newSessionId = await this.sessionIdGenPromise;
529
+
530
+ sessionStorage?.setItem('cb-session', newSessionId);
531
+ return newSessionId;
532
+ } catch {
533
+ // Either we can't generate the hash or we're restricted from accessing sessionStorage
534
+ return '';
535
+ }
536
+ }
537
+
538
+ /**
539
+ * Go to the given page of results
540
+ *
541
+ * @param pageNumber
542
+ */
543
+ goToPage(pageNumber: number) {
544
+ this.initialPageNumber = pageNumber;
545
+ this.pagesToRender = pageNumber;
546
+ return this.scrollToPage(pageNumber);
547
+ }
548
+
549
+ /**
550
+ * Sets the state for whether the initial set of search results is loading in.
551
+ */
552
+ setSearchResultsLoading(loading: boolean): void {
553
+ this.searchResultsLoading = loading;
554
+ }
555
+
556
+ /**
557
+ * Sets the state for whether facet data is loading in
558
+ */
559
+ setFacetsLoading(loading: boolean): void {
560
+ this.facetsLoading = loading;
561
+ }
562
+
563
+ /**
564
+ * Sets the total number of results to be displayed for the current search
565
+ */
566
+ setTotalResultCount(totalResults: number): void {
567
+ this.totalResults = totalResults;
568
+ }
569
+
570
+ /**
571
+ * Clears all selected/negated facets, date ranges, and letter filters.
572
+ *
573
+ * By default, the current sort field/direction are not cleared,
574
+ * but this can be overridden by setting the `sort` option to `true`.
575
+ *
576
+ * Similarly, it is possible to finely control what is cleared by
577
+ * setting any of the `facets`, `dateRange`, or `letterFilters` flags
578
+ * in the options object.
579
+ */
580
+ clearFilters({
581
+ facets = true,
582
+ dateRange = true,
583
+ letterFilters = true,
584
+ sort = false,
585
+ } = {}): void {
586
+ // Don't bother clearing facets if none are checked, so that we don't
587
+ // trigger unnecessary update cycles.
588
+ if (facets && this.hasCheckedFacets) {
589
+ this.selectedFacets = getDefaultSelectedFacets();
590
+ }
591
+
592
+ if (dateRange) {
593
+ this.minSelectedDate = undefined;
594
+ this.maxSelectedDate = undefined;
595
+ }
596
+
597
+ if (letterFilters) {
598
+ this.selectedTitleFilter = null;
599
+ this.selectedCreatorFilter = null;
600
+ }
601
+
602
+ if (sort) {
603
+ this.sortDirection = null;
604
+ this.selectedSort = SortField.default;
605
+ }
606
+
607
+ this.clearTVDropdowns();
608
+
609
+ if (this.smartFacetBar) {
610
+ this.smartFacetBar.deselectAll();
611
+ }
612
+ }
613
+
614
+ /**
615
+ * Resets any selected TV network/show dropdowns to their default state
616
+ */
617
+ private clearTVDropdowns(): void {
618
+ this.selectedTVNetwork = undefined;
619
+ this.selectedTVShow = undefined;
620
+
621
+ if (this.tvNetworksDropdown) {
622
+ this.tvNetworksDropdown.clearSelectedOption();
623
+ }
624
+
625
+ if (this.tvShowsDropdown) {
626
+ this.tvShowsDropdown.clearSelectedOption();
627
+ }
628
+ }
629
+
630
+ /**
631
+ * Returns true if the current value of `this.selectedFacets` contains
632
+ * any facet buckets than have been selected or negated, or false otherwise.
633
+ */
634
+ private get hasCheckedFacets(): boolean {
635
+ if (!this.selectedFacets) return false;
636
+
637
+ for (const facetGroup of Object.values(this.selectedFacets)) {
638
+ for (const bucket of Object.values(facetGroup)) {
639
+ if (bucket.state !== 'none') return true;
640
+ }
641
+ }
642
+
643
+ return false;
644
+ }
645
+
646
+ /**
647
+ * Returns true if there are any currently selected/negated facet buckets,
648
+ * any selected date range, or any selected letter filters. False otherwise.
649
+ *
650
+ * Ignores sorting options.
651
+ */
652
+ private get hasActiveFilters(): boolean {
653
+ return !!(
654
+ this.hasCheckedFacets ||
655
+ this.minSelectedDate ||
656
+ this.maxSelectedDate ||
657
+ this.selectedTitleFilter ||
658
+ this.selectedCreatorFilter
659
+ );
660
+ }
661
+
662
+ willUpdate(changed: PropertyValues): void {
663
+ this.setPlaceholderType();
664
+
665
+ if (changed.has('searchType') && this.searchType === SearchType.TV) {
666
+ this.applyDefaultTVSearchSort();
667
+ }
668
+
669
+ // If we need to clear filters due to a query change or other reset, we do so *before* any
670
+ // updates happen, to prevent unnecessary update cycles and ensure there's a clean slate
671
+ // for any search requests that fire.
672
+ if (
673
+ changed.has('baseQuery') ||
674
+ changed.has('identifiers') ||
675
+ changed.has('searchType') ||
676
+ changed.has('withinCollection')
677
+ ) {
678
+ // Unless this query/search type update is from the initial page load or the
679
+ // result of hitting the back button,
680
+ // we need to clear any existing filters since they may no longer be valid for
681
+ // the new set of search results.
682
+ if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
683
+ // Ordinarily, we leave the sort param unchanged between searches.
684
+ // However, if we are changing the target collection itself, we want the sort cleared too,
685
+ // since different collections may have different sorting options available.
686
+ const shouldClearSort =
687
+ changed.has('withinCollection') &&
688
+ !changed.has('selectedSort') &&
689
+ !changed.has('sortDirection');
690
+
691
+ // Otherwise, only clear filters that haven't been simultaneously applied in this update
692
+ this.clearFilters({
693
+ sort: shouldClearSort,
694
+ facets: !changed.has('selectedFacets'),
695
+ dateRange: !(
696
+ changed.has('minSelectedDate') || changed.has('maxSelectedDate')
697
+ ),
698
+ letterFilters: !(
699
+ changed.has('selectedTitleFilter') ||
700
+ changed.has('selectedCreatorFilter')
701
+ ),
702
+ });
703
+ }
704
+ }
705
+ }
706
+
707
+ render() {
708
+ return html`
709
+ ${this.showSmartFacetBar && this.placeholderType === null
710
+ ? html`<smart-facet-bar
711
+ .query=${this.baseQuery}
712
+ .aggregations=${this.dataSource.aggregations}
713
+ .selectedFacets=${this.selectedFacets}
714
+ .collectionTitles=${this.dataSource.collectionTitles}
715
+ .filterToggleShown=${!this.mobileView}
716
+ .filterToggleActive=${this.facetPaneVisible}
717
+ .label=${this.smartFacetBarLabel}
718
+ @facetsChanged=${this.facetsChanged}
719
+ @filtersToggled=${() => {
720
+ this.facetPaneVisible = !this.facetPaneVisible;
721
+ this.emitFacetPaneVisibilityChanged();
722
+ }}
723
+ ></smart-facet-bar>`
724
+ : nothing}
725
+
726
+ <div
727
+ id="content-container"
728
+ class=${this.mobileView ? 'mobile' : 'desktop'}
729
+ >
730
+ ${this.placeholderType
731
+ ? this.emptyPlaceholderTemplate
732
+ : this.collectionBrowserTemplate}
733
+ </div>
734
+ `;
735
+ }
736
+
737
+ /**
738
+ * Determines what type of placeholder content should be shown instead of result tiles, if applicable.
739
+ * The placeholders indicate states where we have no results to show, which could be the result of:
740
+ * - No query is set (on the search page)
741
+ * - No results were returned for the most recent search
742
+ * - The collection being searched within has no viewable items
743
+ * - An error occurred on the most recent search attempt
744
+ */
745
+ private setPlaceholderType() {
746
+ const isInitialized = this.dataSource.queryInitialized;
747
+ const hasQuery = !!this.baseQuery?.trim();
748
+ const hasIdentifiers = !!this.identifiers?.length;
749
+ const isCollection = !!this.withinCollection;
750
+ const isProfile = !!this.withinProfile;
751
+ const isSearchResults = !isCollection && !isProfile;
752
+ const noResults =
753
+ !this.searchResultsLoading &&
754
+ (this.dataSource.size === 0 || !this.searchService);
755
+
756
+ this.placeholderType = null;
757
+ if (this.suppressPlaceholders) return;
758
+
759
+ if (!isInitialized) {
760
+ this.placeholderType = 'empty-query';
761
+ } else if (isSearchResults && !hasQuery && !hasIdentifiers) {
762
+ this.placeholderType = 'empty-query';
763
+ } else if (noResults) {
764
+ // Within a collection, no query + no results means the collection simply has no viewable items.
765
+ // Otherwise, we must have a user query that produced 0 results.
766
+ this.placeholderType =
767
+ !hasQuery && isCollection ? 'empty-collection' : 'no-results';
768
+ }
769
+
770
+ if (this.dataSource.queryErrorMessage) {
771
+ this.placeholderType =
772
+ !hasQuery && isCollection ? 'collection-error' : 'query-error';
773
+ }
774
+ }
775
+
776
+ /**
777
+ * Template for the placeholder content to show when no results are available.
778
+ */
779
+ private get emptyPlaceholderTemplate() {
780
+ return html`
781
+ <empty-placeholder
782
+ .placeholderType=${this.placeholderType}
783
+ ?isMobileView=${this.mobileView}
784
+ ?isCollection=${!!this.withinCollection}
785
+ .detailMessage=${this.dataSource.queryErrorMessage ?? ''}
786
+ .baseNavigationUrl=${this.baseNavigationUrl}
787
+ ></empty-placeholder>
788
+ `;
789
+ }
790
+
791
+ /**
792
+ * Top-level template for rendering the left (facets) and right (results) columns.
793
+ */
794
+ private get collectionBrowserTemplate() {
795
+ return html`
796
+ <div id="left-column-scroll-sentinel"></div>
797
+ ${this.leftColumnTemplate} ${this.rightColumnTemplate}
798
+ `;
799
+ }
800
+
801
+ /**
802
+ * Template for either the mobile or desktop version of the left column, depending
803
+ * on current component state.
804
+ */
805
+ private get leftColumnTemplate(): TemplateResult {
806
+ if (this.mobileView) {
807
+ return this.mobileLeftColumnTemplate;
808
+ }
809
+ return this.desktopLeftColumnTemplate;
810
+ }
811
+
812
+ /**
813
+ * Template for the mobile version of the "left column" (which in this case, appears
814
+ * *above* the search results rather than beside them), for rendering the
815
+ * accordion-style facets.
816
+ */
817
+ private get mobileLeftColumnTemplate(): TemplateResult {
818
+ return html`
819
+ <div
820
+ id="left-column"
821
+ class="column${this.isResizeToMobile ? ' preload' : ''}"
822
+ >
823
+ ${this.facetTopViewSlot} ${this.resultsCountTemplate}
824
+ <div id="facets-header-container">${this.mobileFacetsTemplate}</div>
825
+ </div>
826
+ `;
827
+ }
828
+
829
+ /**
830
+ * Template for the desktop version of the left column, displaying the facets sidebar.
831
+ */
832
+ private get desktopLeftColumnTemplate(): TemplateResult {
833
+ return html`
834
+ <div id="left-column" class="column" ?hidden=${!this.facetPaneVisible}>
835
+ ${this.facetTopViewSlot}
836
+ <div id="facets-header-container">
837
+ <h2 id="facets-header" class="sr-only">${msg('Filters')}</h2>
838
+ ${this.resultsCountTemplate} ${this.clearFiltersBtnTemplate(false)}
839
+ </div>
840
+ <div id="facets-container" aria-labelledby="facets-header">
841
+ ${this.facetsTemplate}
842
+ <div id="facets-scroll-sentinel"></div>
843
+ </div>
844
+ <div id="facets-bottom-fade"></div>
845
+ </div>
846
+ `;
847
+ }
848
+
849
+ /**
850
+ * Slot which is placed at top of the facets area for user-profile page
851
+ * - mainly used to render userlists
852
+ */
853
+ private get facetTopViewSlot(): TemplateResult {
854
+ return html`<div id="facet-top-view">
855
+ <slot name="facet-top-slot"></slot>
856
+ </div>`;
857
+ }
858
+
859
+ /**
860
+ * Template for the "X Results" count at the top of the search results.
861
+ * Changes to the "Searching..." label if the search results are still loading.
862
+ */
863
+ private get resultsCountTemplate(): TemplateResult | typeof nothing {
864
+ if (this.suppressResultCount) return nothing;
865
+
866
+ const shouldShowSearching =
867
+ this.searchResultsLoading || this.totalResults === undefined;
868
+ const classes = classMap({ filtered: this.hasActiveFilters });
869
+ const resultsCount = this.totalResults?.toLocaleString();
870
+ const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
871
+
872
+ // Added data-testid for Playwright testing
873
+ return html`
874
+ <div id="results-total" class=${classes} data-testid="results-total">
875
+ <span id="big-results-count">
876
+ ${shouldShowSearching ? html`Searching&hellip;` : resultsCount}
877
+ </span>
878
+ <span id="big-results-label">
879
+ ${shouldShowSearching ? nothing : resultsLabel}
880
+ </span>
881
+ </div>
882
+ `;
883
+ }
884
+
885
+ /**
886
+ * Template for the right column of the collection browser, where the result
887
+ * tiles and sort/filter bar are shown.
888
+ */
889
+ private get rightColumnTemplate(): TemplateResult {
890
+ const rightColumnClasses = classMap({
891
+ column: true,
892
+ 'full-width': !this.facetPaneVisible,
893
+ 'smart-results-spacing': !!this.showSmartResults,
894
+ });
895
+
896
+ return html`
897
+ <div id="right-column" class=${rightColumnClasses}>
898
+ ${this.showSmartResults
899
+ ? html`<slot name="smart-results"></slot>`
900
+ : nothing}
901
+ <section id="results">
902
+ <h2 class="results-section-heading">
903
+ <slot name="results-heading"></slot>
904
+ </h2>
905
+ <div id="cb-top-view">
906
+ <slot name="cb-top-slot"></slot>
907
+ </div>
908
+ ${this.isManageView
909
+ ? this.manageBarTemplate
910
+ : this.sortFilterBarTemplate}
911
+ <slot name="cb-results"></slot>
912
+ ${this.displayMode === `list-compact` && this.totalResults
913
+ ? this.listHeaderTemplate
914
+ : nothing}
915
+ ${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
916
+ </section>
917
+ </div>
918
+ `;
919
+ }
920
+
921
+ /**
922
+ * Template for the infinite scroller widget that contains the result tiles.
923
+ */
924
+ private get infiniteScrollerTemplate() {
925
+ return html`<infinite-scroller
926
+ class=${this.infiniteScrollerClasses}
927
+ itemCount=${this.placeholderType ? 0 : nothing}
928
+ ariaLandmarkLabel="Search results"
929
+ .estimatedCellHeight=${this.estimatedTileHeight}
930
+ .minBufferMarginCells=${this.pageSize}
931
+ .cellProvider=${this}
932
+ .placeholderCellTemplate=${this.placeholderCellTemplate}
933
+ @scrollThresholdReached=${this.scrollThresholdReached}
934
+ @visibleCellsChanged=${this.visibleCellsChanged}
935
+ >${this.displayMode === 'grid'
936
+ ? html`<slot name="result-last-tile" slot="result-last-tile"></slot>`
937
+ : nothing}
938
+ </infinite-scroller>`;
939
+ }
940
+
941
+ /**
942
+ * Produces a `classMap` indicating which classes the infinite scroller should have
943
+ * given the current display mode & placeholder case.
944
+ */
945
+ private get infiniteScrollerClasses() {
946
+ return classMap({
947
+ [this.displayMode ?? '']: !!this.displayMode,
948
+ hidden: !!this.placeholderType,
949
+ });
950
+ }
951
+
952
+ /**
953
+ * Best-effort hint of how tall a single rendered tile is, by display mode.
954
+ * The scroller uses this to better estimate the size its initial scroll
955
+ * spacer and buffer position before real cell heights are measured.
956
+ * Should roughly match the placeholder heights since the initial render
957
+ * of a new page generally shows placeholders only anyway.
958
+ */
959
+ private get estimatedTileHeight(): number {
960
+ switch (this.displayMode) {
961
+ case 'list-detail':
962
+ return 80;
963
+ case 'list-compact':
964
+ return 45;
965
+ case 'grid':
966
+ default:
967
+ return 225;
968
+ }
969
+ }
970
+
971
+ /**
972
+ * Template for the sort & filtering bar that appears atop the search results.
973
+ */
974
+ private get sortFilterBarTemplate(): TemplateResult | typeof nothing {
975
+ if (this.suppressSortBar) return nothing;
976
+
977
+ // Determine the set of sortable fields that should be shown in the sort bar
978
+ let sortFieldAvailability = defaultSortAvailability;
979
+
980
+ // We adjust the available sort options for a couple of special cases...
981
+ if (
982
+ this.withinCollection?.startsWith('fav-') ||
983
+ this.profileElement === 'favorites'
984
+ ) {
985
+ // When viewing a fav- collection or the favorites profile tab,
986
+ // we include the Date Favorited option as the default
987
+ sortFieldAvailability = favoritesSortAvailability;
988
+ } else if (!this.withinCollection && this.searchType === SearchType.TV) {
989
+ // When viewing TV search results, we exclude several of the usual date sort options.
990
+ sortFieldAvailability = tvSortAvailability;
991
+ }
992
+
993
+ // We only show relevance sort if a search query is currently defined
994
+ sortFieldAvailability.relevance = this.isRelevanceSortAvailable;
995
+
996
+ return html`
997
+ <sort-filter-bar
998
+ .defaultSortField=${this.defaultSortField}
999
+ .defaultSortDirection=${this.defaultSortDirection}
1000
+ .selectedSort=${this.selectedSort}
1001
+ .sortDirection=${this.sortDirection}
1002
+ .sortFieldAvailability=${sortFieldAvailability}
1003
+ .displayMode=${this.displayMode}
1004
+ .selectedTitleFilter=${this.selectedTitleFilter}
1005
+ .selectedCreatorFilter=${this.selectedCreatorFilter}
1006
+ .prefixFilterCountMap=${this.dataSource.prefixFilterCountMap}
1007
+ .enableSortOptionsSlot=${this.enableSortOptionsSlot}
1008
+ .suppressDisplayModes=${this.suppressDisplayModes}
1009
+ @sortChanged=${this.userChangedSort}
1010
+ @displayModeChanged=${this.displayModeChanged}
1011
+ @titleLetterChanged=${this.titleLetterSelected}
1012
+ @creatorLetterChanged=${this.creatorLetterSelected}
1013
+ >
1014
+ ${this.tileBlurCheckboxTemplate}
1015
+ <slot name="sort-options-left" slot="sort-options-left"></slot>
1016
+ <slot name="sort-options" slot="sort-options"></slot>
1017
+ <slot name="sort-options-right" slot="sort-options-right"></slot>
1018
+ </sort-filter-bar>
1019
+ `;
1020
+ }
1021
+
1022
+ /**
1023
+ * Template for the Blurring toggle for admins to enable/disable blurring of
1024
+ * sensitive content in result tiles.
1025
+ */
1026
+ private get tileBlurCheckboxTemplate(): TemplateResult | typeof nothing {
1027
+ // Only show the checkbox for @archive.org users
1028
+ if (!this.dataSource.sessionContext?.is_archive_user) return nothing;
1029
+
1030
+ return html`
1031
+ <label
1032
+ id="tile-blur-label"
1033
+ for="tile-blur-check"
1034
+ slot="sort-options-right"
1035
+ >
1036
+ ${msg('Blurring')}
1037
+ <input
1038
+ id="tile-blur-check"
1039
+ type="checkbox"
1040
+ ?checked=${!this.shouldSuppressTileBlurring}
1041
+ @change=${this.tileBlurCheckboxChanged}
1042
+ />
1043
+ </label>
1044
+ `;
1045
+ }
1046
+
1047
+ /**
1048
+ * Template for the manage bar UI that appears atop the search results when we are
1049
+ * showing the management view. This generally replaces the sort bar when present.
1050
+ */
1051
+ private get manageBarTemplate(): TemplateResult {
1052
+ return html`
1053
+ <manage-bar
1054
+ .label=${this.manageViewLabel}
1055
+ .modalManager=${this.modalManager}
1056
+ .selectedItems=${this.dataSource.checkedTileModels}
1057
+ .profileElement=${this.profileElement}
1058
+ showSelectAll
1059
+ showUnselectAll
1060
+ ?showItemManageButton=${this.pageContext === 'search'}
1061
+ ?removeAllowed=${this.dataSource.checkedTileModels.length !== 0}
1062
+ @removeItems=${this.handleRemoveItems}
1063
+ @manageItems=${this.handleManageItems}
1064
+ @selectAll=${() => this.dataSource.checkAllTiles()}
1065
+ @unselectAll=${() => this.dataSource.uncheckAllTiles()}
1066
+ @cancel=${() => {
1067
+ this.isManageView = false;
1068
+ this.dataSource.uncheckAllTiles();
1069
+ if (this.searchResultsLoading) this.dataSource.resetPages();
1070
+ }}
1071
+ ></manage-bar>
1072
+ `;
1073
+ }
1074
+
1075
+ /**
1076
+ * Handler for when the user requests to remove all checked items via the manage bar.
1077
+ * Emits an `itemRemovalRequested` event with all checked tile models.
1078
+ */
1079
+ private handleRemoveItems(): void {
1080
+ this.dispatchEvent(
1081
+ new CustomEvent<{ items: string[] }>('itemRemovalRequested', {
1082
+ detail: {
1083
+ items: this.dataSource.checkedTileModels.map(model => {
1084
+ // For favorited searches, we attach a search: prefix to differentiate it from an item
1085
+ const searchPrefix = model?.mediatype === 'search' ? 'search:' : '';
1086
+ const identifier = model?.identifier ?? '';
1087
+ return `${searchPrefix}${identifier}`;
1088
+ }),
1089
+ },
1090
+ }),
1091
+ );
1092
+ }
1093
+
1094
+ /**
1095
+ * Handler when user request to bulk edit from /search/ page
1096
+ */
1097
+ private handleManageItems(): void {
1098
+ this.dispatchEvent(
1099
+ new CustomEvent<{ items: string[] }>('itemManagerRequested', {
1100
+ detail: {
1101
+ items: this.dataSource.checkedTileModels.map(model =>
1102
+ model?.identifier ? model.identifier : '',
1103
+ ),
1104
+ },
1105
+ }),
1106
+ );
1107
+ }
1108
+
1109
+ refreshSmartFacets(): void {
1110
+ this.smartFacetBar?.refresh();
1111
+ }
1112
+
1113
+ /**
1114
+ * Handler to show processing modal while removing item
1115
+ */
1116
+ showRemoveItemsProcessingModal(): void {
1117
+ this.manageBar?.showRemoveItemsProcessingModal();
1118
+ }
1119
+
1120
+ /**
1121
+ * Handler to show error modal when item removal failed
1122
+ */
1123
+ showRemoveItemsErrorModal(): void {
1124
+ this.manageBar?.showRemoveItemsErrorModal();
1125
+ }
1126
+
1127
+ /**
1128
+ * Removes all tile models that are currently checked & adjusts the paging
1129
+ * of the data source to account for any new gaps in the data.
1130
+ */
1131
+ removeCheckedTiles(): void {
1132
+ this.dataSource.removeCheckedTiles();
1133
+ }
1134
+
1135
+ /**
1136
+ * Handler for when the tile blurring checkbox state is toggled
1137
+ */
1138
+ private tileBlurCheckboxChanged(e: Event): void {
1139
+ const { checked } = e.target as HTMLInputElement;
1140
+ this.tileBlurOverrideState = checked ? 'on' : 'off';
1141
+ this.infiniteScroller?.refreshAllVisibleCells();
1142
+ }
1143
+
1144
+ /**
1145
+ * Whether result tiles should have the default blurring of sensitive content suppressed.
1146
+ * First considers any override specified by the user, falling back to the setting in
1147
+ * user preferences if not overridden.
1148
+ */
1149
+ private get shouldSuppressTileBlurring(): boolean {
1150
+ if (this.tileBlurOverrideState !== 'no-override') {
1151
+ // User wants to override their preference.
1152
+ // Return true if they want blurring turned off, or false otherwise.
1153
+ return this.tileBlurOverrideState === 'off';
1154
+ }
1155
+
1156
+ // Not overriding, so use the preference from session context
1157
+ const { sessionContext } = this.dataSource;
1158
+ const userPrefs = sessionContext?.pps_relevant_user_preferences;
1159
+ const blurringPref = userPrefs?.display__blur_moderated_content;
1160
+
1161
+ // Only suppress blurring if the preference is disabled.
1162
+ // If enabled or missing, tile blurring remains on.
1163
+ return blurringPref === 'off';
1164
+ }
1165
+
1166
+ /**
1167
+ * Handler for when the user changes the selected sort option or direction.
1168
+ */
1169
+ private userChangedSort(
1170
+ e: CustomEvent<{
1171
+ selectedSort: SortField;
1172
+ sortDirection: SortDirection | null;
1173
+ }>,
1174
+ ) {
1175
+ const { selectedSort, sortDirection } = e.detail;
1176
+ this.selectedSort = selectedSort;
1177
+ this.sortDirection = sortDirection;
1178
+
1179
+ if ((this.currentPage ?? 1) > 1) {
1180
+ this.goToPage(1);
1181
+ }
1182
+ this.setCurrentPage(1);
1183
+ }
1184
+
1185
+ /**
1186
+ * Fires an analytics event for sorting changes.
1187
+ * @param prevSortDirection Which sort direction was previously set.
1188
+ */
1189
+ private sendSortByAnalytics(prevSortDirection: SortDirection | null): void {
1190
+ const directionCleared = prevSortDirection && !this.sortDirection;
1191
+
1192
+ this.analyticsHandler?.sendEvent({
1193
+ category: this.searchContext,
1194
+ action: analyticsActions.sortBy,
1195
+ label: `${this.selectedSort}${
1196
+ this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''
1197
+ }`,
1198
+ });
1199
+ }
1200
+
1201
+ /**
1202
+ * Handler for when the selected sort option is updated, whether by the user
1203
+ * themselves or programmatically.
1204
+ */
1205
+ private selectedSortChanged(): void {
1206
+ // Lazy-load the alphabet counts for title/creator sort bar as needed
1207
+ this.dataSource.updatePrefixFiltersForCurrentSort();
1208
+ }
1209
+
1210
+ /**
1211
+ * An object representing the current sort field & direction.
1212
+ */
1213
+ get sortParam(): SortParam | null {
1214
+ const sortOption = SORT_OPTIONS[this.selectedSort];
1215
+ if (!sortOption?.handledBySearchService) {
1216
+ return null;
1217
+ }
1218
+
1219
+ // If the sort option specified in the URL is unrecognized, we just use it as-is
1220
+ const urlSortParam = new URL(window.location.href).searchParams.get('sort');
1221
+ const sortField =
1222
+ sortOption.searchServiceKey ?? urlSortParam?.replace(/^-/, '');
1223
+
1224
+ // If the sort direction is still null at this point, then we assume ascending
1225
+ // (i.e., it was unrecognized and had no directional flag)
1226
+ if (!this.sortDirection) this.sortDirection = 'asc';
1227
+
1228
+ if (!sortField) return null;
1229
+ return { field: sortField, direction: this.sortDirection };
1230
+ }
1231
+
1232
+ /**
1233
+ * An object representing the default sort field & direction, if none are explicitly set.
1234
+ */
1235
+ get defaultSortParam(): SortParam | null {
1236
+ const direction = this.defaultSortDirection ?? 'asc';
1237
+ const field = SORT_OPTIONS[this.defaultSortField].searchServiceKey;
1238
+ if (!field) return null;
1239
+
1240
+ return { field, direction };
1241
+ }
1242
+
1243
+ /**
1244
+ * Handler for when the display mode option is changed (grid/list/compact-list views).
1245
+ */
1246
+ private displayModeChanged(
1247
+ e: CustomEvent<{ displayMode?: CollectionDisplayMode }>,
1248
+ ): void {
1249
+ this.displayMode = e.detail.displayMode;
1250
+
1251
+ if (this.displayMode) {
1252
+ this.analyticsHandler?.sendEvent({
1253
+ category: this.searchContext,
1254
+ action: analyticsActions.displayMode,
1255
+ label: this.displayMode,
1256
+ });
1257
+ }
1258
+ }
1259
+
1260
+ /**
1261
+ * Returns a query clause identifying the currently selected title filter,
1262
+ * e.g., `firstTitle:X`.
1263
+ */
1264
+ private get titleQuery(): string | undefined {
1265
+ return this.selectedTitleFilter
1266
+ ? `firstTitle:${this.selectedTitleFilter}`
1267
+ : undefined;
1268
+ }
1269
+
1270
+ /**
1271
+ * Returns a query clause identifying the currently selected creator filter,
1272
+ * e.g., `firstCreator:X`.
1273
+ */
1274
+ private get creatorQuery(): string | undefined {
1275
+ return this.selectedCreatorFilter
1276
+ ? `firstCreator:${this.selectedCreatorFilter}`
1277
+ : undefined;
1278
+ }
1279
+
1280
+ /**
1281
+ * Send Analytics when sorting by title's first letter
1282
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
1283
+ */
1284
+ private sendFilterByTitleAnalytics(prevSelectedLetter: string | null): void {
1285
+ if (!prevSelectedLetter && !this.selectedTitleFilter) {
1286
+ return;
1287
+ }
1288
+ const cleared = prevSelectedLetter && !this.selectedTitleFilter;
1289
+
1290
+ this.analyticsHandler?.sendEvent({
1291
+ category: this.searchContext,
1292
+ action: analyticsActions.filterByTitle,
1293
+ label: cleared
1294
+ ? `clear-${prevSelectedLetter}`
1295
+ : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
1296
+ });
1297
+ }
1298
+
1299
+ /**
1300
+ * Send Analytics when filtering by creator's first letter
1301
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
1302
+ */
1303
+ private sendFilterByCreatorAnalytics(
1304
+ prevSelectedLetter: string | null,
1305
+ ): void {
1306
+ if (!prevSelectedLetter && !this.selectedCreatorFilter) {
1307
+ return;
1308
+ }
1309
+ const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
1310
+
1311
+ this.analyticsHandler?.sendEvent({
1312
+ category: this.searchContext,
1313
+ action: analyticsActions.filterByCreator,
1314
+ label: cleared
1315
+ ? `clear-${prevSelectedLetter}`
1316
+ : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
1317
+ });
1318
+ }
1319
+
1320
+ /**
1321
+ * Handler for changes to which letter is selected in the title alphabet bar.
1322
+ */
1323
+ private titleLetterSelected(
1324
+ e: CustomEvent<{ selectedLetter: string | null }>,
1325
+ ): void {
1326
+ this.selectedCreatorFilter = null;
1327
+ this.selectedTitleFilter = e.detail.selectedLetter;
1328
+ }
1329
+
1330
+ /**
1331
+ * Handler for changes to which letter is selected in the creator alphabet bar.
1332
+ */
1333
+ private creatorLetterSelected(
1334
+ e: CustomEvent<{ selectedLetter: string | null }>,
1335
+ ): void {
1336
+ this.selectedTitleFilter = null;
1337
+ this.selectedCreatorFilter = e.detail.selectedLetter;
1338
+ }
1339
+
1340
+ /**
1341
+ * The full template for how the facets should be structured in mobile view,
1342
+ * including the collapsible container (with header) and the facets themselves.
1343
+ */
1344
+ private get mobileFacetsTemplate(): TemplateResult | typeof nothing {
1345
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement!)) return nothing;
1346
+
1347
+ const toggleFacetsVisible = (e: Event) => {
1348
+ const target = e.target as HTMLDetailsElement;
1349
+ this.isResizeToMobile = false;
1350
+ this.collapsibleFacetsVisible = target.open;
1351
+
1352
+ this.analyticsHandler?.sendEvent({
1353
+ category: this.searchContext,
1354
+ action: analyticsActions.mobileFacetsToggled,
1355
+ label: target.open ? 'open' : 'closed',
1356
+ });
1357
+ };
1358
+
1359
+ return html`
1360
+ <details id="mobile-filter-collapse" @toggle=${toggleFacetsVisible}>
1361
+ <summary>
1362
+ <span class="collapser-icon">${chevronIcon}</span>
1363
+ <h2>${msg('Filters')}</h2>
1364
+ ${this.clearFiltersBtnTemplate(true)}
1365
+ </summary>
1366
+ ${this.facetsTemplate}
1367
+ </details>
1368
+ `;
1369
+ }
1370
+
1371
+ /**
1372
+ * Handler for when either of the TV dropdown filters are toggled, loading their
1373
+ * contents if necessary.
1374
+ */
1375
+ private async tvDropdownToggled(e: CustomEvent<boolean>): Promise<void> {
1376
+ if (!e.detail) return; // Only run when toggled open
1377
+ if (this.tvMapsPopulated) return;
1378
+
1379
+ this.tvMapsLoading = true;
1380
+ this.tvMapsErrored = false;
1381
+ try {
1382
+ await this.dataSource.populateTVChannelMaps();
1383
+ this.tvMapsPopulated = true;
1384
+ } catch (err) {
1385
+ this.tvMapsErrored = true;
1386
+ }
1387
+
1388
+ this.tvMapsLoading = false;
1389
+ }
1390
+
1391
+ private async networksDropdownChanged(): Promise<void> {
1392
+ const previousNetwork = this.selectedTVNetwork;
1393
+ const newNetwork = this.tvNetworksDropdown!.selectedOption?.text;
1394
+ this.selectedTVNetwork = newNetwork ?? undefined;
1395
+
1396
+ const entries = this.dataSource.tvChannelMaps.channelToNetwork!.entries();
1397
+ for (const [channel, network] of entries) {
1398
+ if (network === previousNetwork) {
1399
+ // Remove any previously-applied network filter
1400
+ const removedBucket: FacetBucket = {
1401
+ key: channel.toLowerCase(),
1402
+ count: 0,
1403
+ state: 'none',
1404
+ };
1405
+ this.selectedFacets = updateSelectedFacetBucket(
1406
+ this.selectedFacets,
1407
+ 'creator',
1408
+ removedBucket,
1409
+ true,
1410
+ );
1411
+ } else if (network === this.selectedTVNetwork) {
1412
+ const newBucket: FacetBucket = {
1413
+ key: channel.toLowerCase(),
1414
+ count: 0,
1415
+ state: 'selected',
1416
+ };
1417
+ this.selectedFacets = updateSelectedFacetBucket(
1418
+ this.selectedFacets,
1419
+ 'creator',
1420
+ newBucket,
1421
+ );
1422
+ }
1423
+ }
1424
+ }
1425
+
1426
+ private async showsDropdownChanged(): Promise<void> {
1427
+ const previousShow = this.selectedTVShow;
1428
+ const newShow = this.tvShowsDropdown!.selectedOption?.text;
1429
+ this.selectedTVShow = newShow ?? undefined;
1430
+
1431
+ // Remove any previously-applied shows filter
1432
+ if (previousShow !== undefined) {
1433
+ const removedBucket: FacetBucket = {
1434
+ key: previousShow,
1435
+ count: 0,
1436
+ state: 'none',
1437
+ };
1438
+ this.selectedFacets = updateSelectedFacetBucket(
1439
+ this.selectedFacets,
1440
+ 'program',
1441
+ removedBucket,
1442
+ true,
1443
+ );
1444
+ }
1445
+
1446
+ if (this.selectedTVShow) {
1447
+ const newBucket: FacetBucket = {
1448
+ key: this.selectedTVShow,
1449
+ count: 0,
1450
+ state: 'selected',
1451
+ };
1452
+ this.selectedFacets = updateSelectedFacetBucket(
1453
+ this.selectedFacets,
1454
+ 'program',
1455
+ newBucket,
1456
+ );
1457
+ }
1458
+ }
1459
+
1460
+ private get tvDropdownFiltersTemplate(): TemplateResult | typeof nothing {
1461
+ if (this.searchType !== SearchType.TV) return nothing;
1462
+
1463
+ const { channelToNetwork, programToChannels } =
1464
+ this.dataSource.tvChannelMaps;
1465
+ const networks = channelToNetwork
1466
+ ? [...new Set(channelToNetwork.values())]
1467
+ : [];
1468
+
1469
+ let showEntries = programToChannels ? [...programToChannels.entries()] : [];
1470
+
1471
+ if (channelToNetwork && this.selectedTVNetwork) {
1472
+ showEntries = showEntries.filter(([, channels]) =>
1473
+ Object.keys(channels).some(
1474
+ c => channelToNetwork.get(c) === this.selectedTVNetwork,
1475
+ ),
1476
+ );
1477
+ }
1478
+
1479
+ const filterByNetworkLabel = msg('Filter by Network');
1480
+ const filterByShowLabel = msg('Filter by Show');
1481
+ const shows = showEntries.map(([show]) => show);
1482
+ const loadingIndicator = html`
1483
+ <span slot="empty-options">
1484
+ <img src="https://archive.org/images/loading.gif" />
1485
+ </span>
1486
+ `;
1487
+ const errorMessage = html`
1488
+ <span slot="empty-options">
1489
+ ${msg('Unable to fetch options, try again later')}
1490
+ </span>
1491
+ `;
1492
+
1493
+ return html`
1494
+ <div id="tv-filters" slot="facets-top">
1495
+ <ia-combo-box
1496
+ id="tv-networks"
1497
+ class="tv-filter-dropdown"
1498
+ placeholder=${filterByNetworkLabel}
1499
+ clearable
1500
+ wrap-arrow-keys
1501
+ sort
1502
+ .options=${networks.map((n, i) => ({ id: `network-${i}`, text: n }))}
1503
+ @toggle=${this.tvDropdownToggled}
1504
+ @change=${this.networksDropdownChanged}
1505
+ >
1506
+ <span slot="label" class="sr-only">${filterByNetworkLabel}</span>
1507
+ ${this.tvMapsLoading ? loadingIndicator : nothing}
1508
+ ${this.tvMapsErrored ? errorMessage : nothing}
1509
+ </ia-combo-box>
1510
+ <ia-combo-box
1511
+ id="tv-shows"
1512
+ class="tv-filter-dropdown"
1513
+ placeholder=${filterByShowLabel}
1514
+ max-autocomplete-entries="500"
1515
+ clearable
1516
+ wrap-arrow-keys
1517
+ sort
1518
+ .options=${shows.map((s, i) => ({ id: `show-${i}`, text: s }))}
1519
+ @toggle=${this.tvDropdownToggled}
1520
+ @change=${this.showsDropdownChanged}
1521
+ >
1522
+ <span slot="label" class="sr-only">${filterByShowLabel}</span>
1523
+ ${this.tvMapsLoading ? loadingIndicator : nothing}
1524
+ ${this.tvMapsErrored ? errorMessage : nothing}
1525
+ </ia-combo-box>
1526
+ </div>
1527
+ `;
1528
+ }
1529
+
1530
+ /**
1531
+ * The template for the facets component alone, without any surrounding wrappers.
1532
+ */
1533
+ private get facetsTemplate() {
1534
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement!)) return nothing;
1535
+ if (this.facetLoadStrategy === 'off') {
1536
+ return html`
1537
+ <p class="facets-message">
1538
+ ${msg('Facets are temporarily unavailable.')}
1539
+ </p>
1540
+ `;
1541
+ }
1542
+
1543
+ // We switch to TV facet ordering & date picker if we are in a TV collection or showing TV search results
1544
+ const shouldUseTvInterface =
1545
+ this.isTVCollection ||
1546
+ (!this.withinCollection && this.searchType === SearchType.TV);
1547
+ const facetDisplayOrder = shouldUseTvInterface
1548
+ ? tvFacetDisplayOrder
1549
+ : defaultFacetDisplayOrder;
1550
+
1551
+ const facets = html`
1552
+ <collection-facets
1553
+ .collectionPagePath=${this.collectionPagePath}
1554
+ .parentCollections=${this.dataSource.parentCollections}
1555
+ .pageSpecifierParams=${this.dataSource.pageSpecifierParams}
1556
+ .searchService=${this.searchService}
1557
+ .featureFeedbackService=${this.featureFeedbackService}
1558
+ .recaptchaManager=${this.recaptchaManager}
1559
+ .resizeObserver=${this.resizeObserver}
1560
+ .searchType=${this.searchType}
1561
+ .aggregations=${this.dataSource.aggregations}
1562
+ .histogramAggregation=${this.dataSource.histogramAggregation}
1563
+ .minSelectedDate=${this.minSelectedDate}
1564
+ .maxSelectedDate=${this.maxSelectedDate}
1565
+ .selectedFacets=${this.selectedFacets}
1566
+ .baseNavigationUrl=${this.baseNavigationUrl}
1567
+ .collectionTitles=${this.dataSource.collectionTitles}
1568
+ .tvChannelAliases=${this.dataSource.tvChannelAliases}
1569
+ .showHistogramDatePicker=${this.showHistogramDatePicker}
1570
+ .allowExpandingDatePicker=${!this.mobileView}
1571
+ .allowDatePickerMonths=${shouldUseTvInterface}
1572
+ .contentWidth=${this.contentWidth}
1573
+ .query=${this.baseQuery}
1574
+ .identifiers=${this.identifiers}
1575
+ .filterMap=${this.dataSource.filterMap}
1576
+ .isManageView=${this.isManageView}
1577
+ .modalManager=${this.modalManager}
1578
+ .analyticsHandler=${this.analyticsHandler}
1579
+ .facetDisplayOrder=${facetDisplayOrder}
1580
+ .isTvSearch=${shouldUseTvInterface}
1581
+ ?collapsableFacets=${this.mobileView}
1582
+ ?facetsLoading=${this.facetsLoading}
1583
+ ?histogramAggregationLoading=${this.facetsLoading}
1584
+ ?suppressMediatypeFacets=${this.suppressMediatypeFacets}
1585
+ @facetClick=${this.facetClickHandler}
1586
+ @facetsChanged=${this.facetsChanged}
1587
+ @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
1588
+ >
1589
+ ${this.tvDropdownFiltersTemplate}
1590
+ </collection-facets>
1591
+ `;
1592
+
1593
+ // If we are using one of the opt-in facet load strategies, we may need to wrap the
1594
+ // desktop view facets in a <details> widget so that patrons can opt into loading them.
1595
+ // In the `opt-in-or-login` case, we only do this if they are not logged in.
1596
+ const showDesktopOptInWidget =
1597
+ this.facetLoadStrategy === 'opt-in' ||
1598
+ (this.facetLoadStrategy === 'opt-in-or-login' && !this.loggedIn);
1599
+
1600
+ if (showDesktopOptInWidget && !this.mobileView) {
1601
+ return html`
1602
+ <details
1603
+ class="desktop-facets-dropdown"
1604
+ @toggle=${(e: Event) => {
1605
+ const target = e.target as HTMLDetailsElement;
1606
+ this.collapsibleFacetsVisible = target.open;
1607
+ }}
1608
+ >
1609
+ <summary>
1610
+ <span class="collapser-icon">${chevronIcon}</span>
1611
+ <h2>${msg('Filters')}</h2>
1612
+ </summary>
1613
+ ${facets}
1614
+ </details>
1615
+ `;
1616
+ }
1617
+ // Otherwise, just render the facets component bare
1618
+ return facets;
1619
+ }
1620
+
1621
+ /**
1622
+ * The HTML template for the "Clear all filters" button, or `nothing` if no
1623
+ * filters are currently active.
1624
+ *
1625
+ * @param mobile Whether to style/shorten the button for mobile view
1626
+ */
1627
+ private clearFiltersBtnTemplate(
1628
+ mobile: boolean,
1629
+ ): TemplateResult | typeof nothing {
1630
+ if (!this.hasActiveFilters) return nothing;
1631
+
1632
+ const buttonClasses = classMap({
1633
+ 'clear-filters-btn': true,
1634
+ mobile,
1635
+ });
1636
+
1637
+ const buttonText = mobile ? 'Clear all' : 'Clear all filters';
1638
+
1639
+ return html`
1640
+ <div class="clear-filters-btn-row">
1641
+ ${mobile
1642
+ ? html`<span class="clear-filters-btn-separator">&nbsp;</span>`
1643
+ : nothing}
1644
+ <button class=${buttonClasses} @click=${this.clearFilters}>
1645
+ ${buttonText}
1646
+ </button>
1647
+ </div>
1648
+ `;
1649
+ }
1650
+
1651
+ /**
1652
+ * Template for the table header content that appears atop the compact list view.
1653
+ */
1654
+ private get listHeaderTemplate() {
1655
+ return html`
1656
+ <div id="list-header">
1657
+ <tile-dispatcher
1658
+ .tileDisplayMode=${'list-header'}
1659
+ .resizeObserver=${this.resizeObserver}
1660
+ .sortParam=${this.sortParam}
1661
+ .defaultSortParam=${this.defaultSortParam}
1662
+ .mobileBreakpoint=${this.mobileBreakpoint}
1663
+ .loggedIn=${this.loggedIn}
1664
+ .suppressBlurring=${this.shouldSuppressTileBlurring}
1665
+ .tileActions=${this.tileActions}
1666
+ >
1667
+ </tile-dispatcher>
1668
+ </div>
1669
+ `;
1670
+ }
1671
+
1672
+ /**
1673
+ * Handler for when the date picker's date range is changed.
1674
+ */
1675
+ private histogramDateRangeUpdated(
1676
+ e: CustomEvent<{
1677
+ minDate: string;
1678
+ maxDate: string;
1679
+ }>,
1680
+ ) {
1681
+ const { minDate, maxDate } = e.detail;
1682
+ [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
1683
+
1684
+ this.analyticsHandler?.sendEvent({
1685
+ category: this.searchContext,
1686
+ action: analyticsActions.histogramChanged,
1687
+ label: this.dataSource.dateRangeQueryClause,
1688
+ });
1689
+ }
1690
+
1691
+ /**
1692
+ * Emits an event indicating a change in whether the manage mode is shown.
1693
+ */
1694
+ private emitManageModeChangedEvent(): void {
1695
+ this.dispatchEvent(
1696
+ new CustomEvent<boolean>('manageModeChanged', {
1697
+ detail: this.isManageView,
1698
+ }),
1699
+ );
1700
+ }
1701
+
1702
+ /**
1703
+ * Installs a new data source component and associated query state parameters into
1704
+ * this component, causing it to efficiently update its views to represent the
1705
+ * newly-provided data. In this way, one can reuse a single instance of
1706
+ * <collection-browser> to handle multiple different sets of search results on
1707
+ * a single page, each set of results being loaded & updated by its own data
1708
+ * source.
1709
+ *
1710
+ * @param dataSource The data source component containing (or prepared to fetch)
1711
+ * the tile data to be displayed.
1712
+ * @param queryState The new query-related state that this component should
1713
+ * represent, such as the search query, sort option, and any filters applied.
1714
+ */
1715
+ async installDataSourceAndQueryState(
1716
+ dataSource: CollectionBrowserDataSourceInterface,
1717
+ queryState: CollectionBrowserQueryState,
1718
+ ): Promise<void> {
1719
+ if (this.dataSource) this.removeController(this.dataSource);
1720
+ this.dataSource = dataSource;
1721
+ this.addController(this.dataSource);
1722
+
1723
+ this.baseQuery = queryState.baseQuery;
1724
+ this.profileElement = queryState.profileElement;
1725
+ this.searchType = queryState.searchType;
1726
+ this.selectedFacets =
1727
+ queryState.selectedFacets ?? getDefaultSelectedFacets();
1728
+ this.internalFilters = queryState.internalFilters;
1729
+ this.minSelectedDate = queryState.minSelectedDate;
1730
+ this.maxSelectedDate = queryState.maxSelectedDate;
1731
+ this.selectedSort = queryState.selectedSort ?? SortField.default;
1732
+ this.sortDirection = queryState.sortDirection;
1733
+ this.selectedTitleFilter = queryState.selectedTitleFilter;
1734
+ this.selectedCreatorFilter = queryState.selectedCreatorFilter;
1735
+
1736
+ this.pagesToRender = this.initialPageNumber;
1737
+
1738
+ // We set this flag during the update to prevent the URL state persistence
1739
+ // from creating an unwanted extra history entry.
1740
+ this.dataSourceInstallInProgress = true;
1741
+ this.requestUpdate();
1742
+ await this.updateComplete;
1743
+ this.dataSourceInstallInProgress = false;
1744
+
1745
+ if (!this.searchResultsLoading) {
1746
+ this.setTotalResultCount(this.dataSource.totalResults);
1747
+ this.setTileCount(this.dataSource.size);
1748
+ }
1749
+
1750
+ this.refreshVisibleResults();
1751
+ }
1752
+
1753
+ firstUpdated(): void {
1754
+ this.restoreState();
1755
+ this.setInitialSize();
1756
+ }
1757
+
1758
+ /**
1759
+ * Determines the initial size of the content container and whether or not
1760
+ * the mobile layout should be used.
1761
+ */
1762
+ setInitialSize(): void {
1763
+ this.contentWidth = this.contentContainer.getBoundingClientRect().width;
1764
+ this.mobileView =
1765
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1766
+ this.sendLayoutSizeAnalytics();
1767
+ }
1768
+
1769
+ /**
1770
+ * Fires an analytics event indicating which type of layout was rendered:
1771
+ * mobile or desktop.
1772
+ */
1773
+ private sendLayoutSizeAnalytics(): void {
1774
+ if (this.analyticsHandler) {
1775
+ this.layoutSizeAnalyticsSent = true;
1776
+ this.analyticsHandler.sendEvent({
1777
+ category: this.searchContext,
1778
+ action: this.mobileView
1779
+ ? analyticsActions.loadMobileView
1780
+ : analyticsActions.loadDesktopView,
1781
+ });
1782
+ }
1783
+ }
1784
+
1785
+ updated(changed: PropertyValues) {
1786
+ if (changed.has('placeholderType') && this.placeholderType === null) {
1787
+ if (!this.leftColIntersectionObserver) {
1788
+ this.setupLeftColumnScrollListeners();
1789
+ }
1790
+ if (!this.facetsIntersectionObserver) {
1791
+ this.setupFacetsScrollListeners();
1792
+ }
1793
+ this.updateLeftColumnHeight();
1794
+ }
1795
+
1796
+ if (changed.has('analyticsHandler') && !this.layoutSizeAnalyticsSent) {
1797
+ this.sendLayoutSizeAnalytics();
1798
+ }
1799
+
1800
+ if (
1801
+ changed.has('displayMode') ||
1802
+ changed.has('baseNavigationUrl') ||
1803
+ changed.has('baseImageUrl') ||
1804
+ changed.has('loggedIn') ||
1805
+ changed.has('tileActions') ||
1806
+ changed.has('tileLayoutType')
1807
+ ) {
1808
+ this.infiniteScroller?.reload();
1809
+ }
1810
+
1811
+ if (changed.has('profileElement')) {
1812
+ this.applyDefaultProfileSort();
1813
+ }
1814
+
1815
+ if (changed.has('withinCollection') && this.withinCollection) {
1816
+ // Set a sensible default collection sort while we load results, which we will later
1817
+ // adjust based on any sort-by metadata once the response arrives.
1818
+ if (!this.baseQuery) {
1819
+ this.defaultSortField = this.withinCollection.startsWith('fav-')
1820
+ ? SortField.datefavorited
1821
+ : SortField.weeklyview;
1822
+ this.defaultSortDirection = 'desc';
1823
+ }
1824
+ }
1825
+
1826
+ if (changed.has('baseQuery')) {
1827
+ this.emitBaseQueryChanged();
1828
+ }
1829
+ if (changed.has('searchType')) {
1830
+ this.emitSearchTypeChanged();
1831
+ }
1832
+
1833
+ if (changed.has('currentPage') || changed.has('displayMode')) {
1834
+ this.persistState();
1835
+ }
1836
+
1837
+ if (
1838
+ changed.has('baseQuery') ||
1839
+ changed.has('identifiers') ||
1840
+ changed.has('minSelectedDate') ||
1841
+ changed.has('maxSelectedDate') ||
1842
+ changed.has('selectedFacets') ||
1843
+ changed.has('searchService') ||
1844
+ changed.has('withinCollection') ||
1845
+ changed.has('withinProfile') ||
1846
+ changed.has('profileElement')
1847
+ ) {
1848
+ this.dataSource.refreshLetterCounts();
1849
+ }
1850
+
1851
+ if (changed.has('selectedSort') || changed.has('sortDirection')) {
1852
+ const prevSortDirection = changed.get('sortDirection') as SortDirection;
1853
+ this.sendSortByAnalytics(prevSortDirection);
1854
+ this.selectedSortChanged();
1855
+ }
1856
+
1857
+ if (changed.has('selectedTitleFilter')) {
1858
+ this.sendFilterByTitleAnalytics(
1859
+ changed.get('selectedTitleFilter') as string,
1860
+ );
1861
+ }
1862
+ if (changed.has('selectedCreatorFilter')) {
1863
+ this.sendFilterByCreatorAnalytics(
1864
+ changed.get('selectedCreatorFilter') as string,
1865
+ );
1866
+ }
1867
+
1868
+ this.updateFacetReadiness();
1869
+
1870
+ if (
1871
+ changed.has('baseQuery') ||
1872
+ changed.has('identifiers') ||
1873
+ changed.has('searchType') ||
1874
+ changed.has('selectedTitleFilter') ||
1875
+ changed.has('selectedCreatorFilter') ||
1876
+ changed.has('minSelectedDate') ||
1877
+ changed.has('maxSelectedDate') ||
1878
+ changed.has('selectedSort') ||
1879
+ changed.has('sortDirection') ||
1880
+ changed.has('selectedFacets') ||
1881
+ changed.has('searchService') ||
1882
+ changed.has('withinCollection') ||
1883
+ changed.has('withinProfile') ||
1884
+ changed.has('profileElement')
1885
+ ) {
1886
+ this.handleQueryChange();
1887
+ }
1888
+
1889
+ if (changed.has('searchResultsLoading')) {
1890
+ this.emitSearchResultsLoadingChanged();
1891
+ }
1892
+
1893
+ if (
1894
+ changed.has('facetsLoading') &&
1895
+ this.facetsLoading &&
1896
+ this.collectionFacets
1897
+ ) {
1898
+ this.collectionFacets.moreLinksVisible =
1899
+ this.searchType !== SearchType.FULLTEXT;
1900
+ }
1901
+
1902
+ if (changed.has('pagesToRender')) {
1903
+ if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1904
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1905
+ }
1906
+ }
1907
+
1908
+ if (changed.has('isManageView')) {
1909
+ if (this.isManageView) {
1910
+ this.displayMode = 'grid';
1911
+ this.fetchManageableSearchResults();
1912
+ } else if (this.pageContext === 'search') this.infiniteScroller?.reload();
1913
+
1914
+ this.infiniteScroller?.refreshAllVisibleCells();
1915
+
1916
+ // Only emit change event if changing b/w true & false, not on initial value set.
1917
+ if (changed.get('isManageView') !== undefined) {
1918
+ this.emitManageModeChangedEvent();
1919
+ }
1920
+ }
1921
+
1922
+ if (changed.has('resizeObserver')) {
1923
+ const oldObserver = changed.get(
1924
+ 'resizeObserver',
1925
+ ) as SharedResizeObserverInterface;
1926
+ if (oldObserver) this.disconnectResizeObserver(oldObserver);
1927
+ this.setupResizeObserver();
1928
+ }
1929
+
1930
+ this.ensureAvailableTilesDisplayed();
1931
+ }
1932
+
1933
+ connectedCallback(): void {
1934
+ super.connectedCallback?.();
1935
+ this.setupStateRestorationObserver();
1936
+ this.setupResizeObserver();
1937
+ }
1938
+
1939
+ disconnectedCallback(): void {
1940
+ if (this.resizeObserver) {
1941
+ this.disconnectResizeObserver(this.resizeObserver);
1942
+ }
1943
+ if (this.boundNavigationHandler) {
1944
+ window.removeEventListener('popstate', this.boundNavigationHandler);
1945
+ }
1946
+
1947
+ if (this.deferredFetchTimer) {
1948
+ window.clearTimeout(this.deferredFetchTimer);
1949
+ this.deferredFetchTimer = 0;
1950
+ }
1951
+
1952
+ this.leftColIntersectionObserver?.disconnect();
1953
+ this.facetsIntersectionObserver?.disconnect();
1954
+ window.removeEventListener('resize', this.updateLeftColumnHeight);
1955
+ }
1956
+
1957
+ handleResize(entry: ResizeObserverEntry): void {
1958
+ const previousView = this.mobileView;
1959
+ if (entry.target === this.contentContainer) {
1960
+ this.contentWidth = entry.contentRect.width;
1961
+ this.mobileView =
1962
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1963
+ // If changing from desktop to mobile disable transition
1964
+ if (this.mobileView && !previousView) {
1965
+ this.isResizeToMobile = true;
1966
+ }
1967
+ }
1968
+
1969
+ // Ensure the facet sidebar remains sized correctly
1970
+ this.updateLeftColumnHeight();
1971
+ }
1972
+
1973
+ /**
1974
+ * Ensures that if we have new results from the data source that are not yet
1975
+ * displayed in the infinite scroller, that they are immediately reflected
1976
+ * in the tile count.
1977
+ */
1978
+ private ensureAvailableTilesDisplayed(): void {
1979
+ if (
1980
+ this.infiniteScroller &&
1981
+ this.infiniteScroller.itemCount < this.dataSource.size
1982
+ ) {
1983
+ this.setTileCount(
1984
+ this.dataSource.endOfDataReached
1985
+ ? this.dataSource.size
1986
+ : this.estimatedTileCount,
1987
+ );
1988
+ }
1989
+ }
1990
+
1991
+ /**
1992
+ * Updates the data source with the current state of facet readiness for loading,
1993
+ * so that they will begin to load in at the appropriate time according to the
1994
+ * current facet loading strategy.
1995
+ */
1996
+ private updateFacetReadiness(): void {
1997
+ // There are two ways to opt into facet production:
1998
+ // (1) have the facets dropdown open, or
1999
+ // (2) if using the `opt-in-or-login` strategy, be logged into an account
2000
+ const optedIn =
2001
+ this.collapsibleFacetsVisible ||
2002
+ (this.facetLoadStrategy === 'opt-in-or-login' && this.loggedIn);
2003
+
2004
+ // In desktop view, we are always ready to load facets *unless* we are using one of the
2005
+ // `opt-in` strategies and have not opted in (whether by login or UI interaction).
2006
+ const usingOptInStrategy = ['opt-in', 'opt-in-or-login'].includes(
2007
+ this.facetLoadStrategy,
2008
+ );
2009
+ const desktopFacetsReady =
2010
+ !this.mobileView && (!usingOptInStrategy || optedIn);
2011
+
2012
+ // In the mobile view, facets are considered ready provided we have opted in (whether by
2013
+ // login or UI interaction).
2014
+ const mobileFacetsReady = this.mobileView && optedIn;
2015
+
2016
+ this.dataSource.handleFacetReadinessChange(
2017
+ desktopFacetsReady || mobileFacetsReady,
2018
+ );
2019
+ }
2020
+
2021
+ /**
2022
+ * Sets up listeners for events that may require updating the left column height.
2023
+ */
2024
+ private setupLeftColumnScrollListeners(): void {
2025
+ // We observe intersections between the left column's scroll sentinel and
2026
+ // the viewport, so that we can ensure the left column is always sized to
2027
+ // match the _available_ viewport height. This should generally be more
2028
+ // performant than listening to scroll events on the page or column.
2029
+ const leftColumnSentinel = this.shadowRoot?.querySelector(
2030
+ '#left-column-scroll-sentinel',
2031
+ );
2032
+ if (leftColumnSentinel) {
2033
+ this.leftColIntersectionObserver = new IntersectionObserver(
2034
+ this.updateLeftColumnHeight,
2035
+ {
2036
+ threshold: [...Array(201).keys()].map(n => n / 200), // Threshold every 0.5%
2037
+ },
2038
+ );
2039
+ this.leftColIntersectionObserver.observe(leftColumnSentinel);
2040
+ }
2041
+
2042
+ // We also listen for window resize events, as they are not always captured
2043
+ // by the resize observer and can affect the desired height of the left column.
2044
+ window.addEventListener('resize', this.updateLeftColumnHeight);
2045
+ }
2046
+
2047
+ /**
2048
+ * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
2049
+ * Note this uses a separate IntersectionObserver from the left column, because we
2050
+ * don't need granular intersection thresholds for this.
2051
+ */
2052
+ private setupFacetsScrollListeners(): void {
2053
+ const facetsSentinel = this.shadowRoot?.querySelector(
2054
+ '#facets-scroll-sentinel',
2055
+ );
2056
+ if (facetsSentinel) {
2057
+ this.facetsIntersectionObserver = new IntersectionObserver(
2058
+ this.updateFacetFadeOut,
2059
+ );
2060
+ this.facetsIntersectionObserver.observe(facetsSentinel);
2061
+ }
2062
+ }
2063
+
2064
+ /**
2065
+ * Updates the height of the left column according to its position on the page.
2066
+ * Arrow function ensures proper `this` binding.
2067
+ */
2068
+ private updateLeftColumnHeight = (): void => {
2069
+ if (this.mobileView) {
2070
+ this.leftColumn?.style?.removeProperty('height');
2071
+ } else {
2072
+ const clientTop = this.leftColumn?.getBoundingClientRect().top;
2073
+ const columnHeight = window.innerHeight - (clientTop ?? 0);
2074
+ const cssHeightValue =
2075
+ clientTop === 0
2076
+ ? null
2077
+ : // Subtract off the column's top padding so that it doesn't overflow
2078
+ `calc(${columnHeight}px - var(--leftColumnPaddingTop, 2rem))`;
2079
+
2080
+ this.leftColumn?.style?.setProperty('height', cssHeightValue);
2081
+ }
2082
+ };
2083
+
2084
+ /**
2085
+ * Toggles whether the fade-out is visible at the bottom of the facets.
2086
+ * It should only be visible if the facets are not scrolled to the bottom.
2087
+ * Arrow function ensures proper `this` binding.
2088
+ */
2089
+ private updateFacetFadeOut = (entries: IntersectionObserverEntry[]): void => {
2090
+ const fadeElmt = this.shadowRoot?.getElementById('facets-bottom-fade');
2091
+ fadeElmt?.classList.toggle('hidden', entries?.[0]?.isIntersecting);
2092
+ };
2093
+
2094
+ /**
2095
+ * Emits a `baseQueryChanged` event indicating an update to the search query.
2096
+ */
2097
+ private emitBaseQueryChanged() {
2098
+ this.dispatchEvent(
2099
+ new CustomEvent<{ baseQuery?: string }>('baseQueryChanged', {
2100
+ detail: {
2101
+ baseQuery: this.baseQuery,
2102
+ },
2103
+ }),
2104
+ );
2105
+ }
2106
+
2107
+ /**
2108
+ * Emits a `searchTypeChanged` event indicating an update to the search type
2109
+ * (e.g., metadata vs. full-text).
2110
+ */
2111
+ private emitSearchTypeChanged() {
2112
+ this.dispatchEvent(
2113
+ new CustomEvent<SearchType>('searchTypeChanged', {
2114
+ detail: this.searchType,
2115
+ }),
2116
+ );
2117
+ }
2118
+
2119
+ /**
2120
+ * Emits a `facetPaneVisibilityChanged` event indicating that the facet pane has
2121
+ * been toggled open or closed.
2122
+ */
2123
+ private emitFacetPaneVisibilityChanged(): void {
2124
+ this.dispatchEvent(
2125
+ new CustomEvent<boolean>('facetPaneVisibilityChanged', {
2126
+ detail: this.facetPaneVisible,
2127
+ }),
2128
+ );
2129
+ }
2130
+
2131
+ /**
2132
+ * Emits a `searchError` event indicating that the most recent search has encountered
2133
+ * an error from the backend.
2134
+ */
2135
+ emitSearchError(): void {
2136
+ this.dispatchEvent(
2137
+ new CustomEvent<string>('searchError', {
2138
+ detail: this.dataSource.queryErrorMessage,
2139
+ }),
2140
+ );
2141
+ }
2142
+
2143
+ /**
2144
+ * Emits a `queryStateChanged` event indicating that one or more of this component's
2145
+ * properties have changed in a way that could affect the set of search results.
2146
+ */
2147
+ emitQueryStateChanged() {
2148
+ this.dispatchEvent(
2149
+ new CustomEvent<CollectionBrowserQueryState>('queryStateChanged', {
2150
+ detail: {
2151
+ baseQuery: this.baseQuery,
2152
+ withinCollection: this.withinCollection,
2153
+ withinProfile: this.withinProfile,
2154
+ profileElement: this.profileElement,
2155
+ searchType: this.searchType,
2156
+ selectedFacets: this.selectedFacets,
2157
+ internalFilters: this.internalFilters,
2158
+ minSelectedDate: this.minSelectedDate,
2159
+ maxSelectedDate: this.maxSelectedDate,
2160
+ selectedSort: this.selectedSort,
2161
+ sortDirection: this.sortDirection,
2162
+ selectedTitleFilter: this.selectedTitleFilter,
2163
+ selectedCreatorFilter: this.selectedCreatorFilter,
2164
+ },
2165
+ }),
2166
+ );
2167
+ }
2168
+
2169
+ /**
2170
+ * Emits an `emptyResults` event indicating that we have received an empty result set
2171
+ * for the most recent query.
2172
+ */
2173
+ emitEmptyResults() {
2174
+ this.dispatchEvent(new Event('emptyResults'));
2175
+ }
2176
+
2177
+ private disconnectResizeObserver(
2178
+ resizeObserver: SharedResizeObserverInterface,
2179
+ ) {
2180
+ resizeObserver.removeObserver({
2181
+ target: this.contentContainer,
2182
+ handler: this,
2183
+ });
2184
+ }
2185
+
2186
+ private setupResizeObserver() {
2187
+ if (!this.resizeObserver || !this.contentContainer) return;
2188
+ this.resizeObserver.addObserver({
2189
+ target: this.contentContainer,
2190
+ handler: this,
2191
+ });
2192
+ }
2193
+
2194
+ /**
2195
+ * When the visible cells change from the infinite scroller, we want to emit
2196
+ * which page is currently visible so the consumer can update its UI or the URL
2197
+ *
2198
+ * @param e
2199
+ * @returns
2200
+ */
2201
+ private visibleCellsChanged(
2202
+ e: CustomEvent<{ visibleCellIndices: number[] }>,
2203
+ ) {
2204
+ this.updateVisiblePage(e.detail.visibleCellIndices);
2205
+ }
2206
+
2207
+ /**
2208
+ * Recomputes the current page from the given set of visible cell indices
2209
+ * and emits `visiblePageChanged` if the page actually changed.
2210
+ */
2211
+ private updateVisiblePage(visibleCellIndices: number[]): void {
2212
+ if (this.isScrollingToCell) return;
2213
+ if (visibleCellIndices.length === 0) return;
2214
+
2215
+ // The indices aren't necessarily sorted, so sort them here to ensure our
2216
+ // calculations below find the right cell/page.
2217
+ const sorted = [...visibleCellIndices].sort((a, b) => a - b);
2218
+
2219
+ // For page determination, do not count more than a single page of visible cells,
2220
+ // since otherwise patrons using very tall screens will be treated as one page
2221
+ // further than they actually are.
2222
+ const lastIndexWithinCurrentPage =
2223
+ Math.min(this.pageSize, sorted.length) - 1;
2224
+ const lastVisibleCellIndex = sorted[lastIndexWithinCurrentPage];
2225
+ const lastVisibleCellPage =
2226
+ Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
2227
+
2228
+ this.setCurrentPage(lastVisibleCellPage);
2229
+ }
2230
+
2231
+ /**
2232
+ * Sets the current page number and emits a `visiblePageChanged`
2233
+ * event if the new page differs from the previous one.
2234
+ */
2235
+ private setCurrentPage(pageNumber: number): void {
2236
+ if (this.currentPage === pageNumber) return;
2237
+ this.currentPage = pageNumber;
2238
+ this.dispatchEvent(
2239
+ new CustomEvent('visiblePageChanged', {
2240
+ detail: { pageNumber },
2241
+ }),
2242
+ );
2243
+ }
2244
+
2245
+ // we only want to scroll on the very first query change
2246
+ // so this keeps track of whether we've already set the initial query
2247
+ private initialQueryChangeHappened = false;
2248
+
2249
+ private historyPopOccurred = false;
2250
+
2251
+ // this lets us store the query key so we know if it's actually changed or not
2252
+ private previousQueryKey?: string;
2253
+
2254
+ /**
2255
+ * A Promise which, after each query change, resolves once the fetches for the initial
2256
+ * search have completed. Waits for *both* the hits and aggregations fetches to finish.
2257
+ *
2258
+ * Ensure you await this component's `updateComplete` promise before awaiting this
2259
+ * one, to ensure you do not await an obsolete promise from the previous update.
2260
+ */
2261
+ get initialSearchComplete(): Promise<boolean> {
2262
+ return this.dataSource.initialSearchComplete;
2263
+ }
2264
+
2265
+ /**
2266
+ * Handler for whenever the component's properties change in a way that may require
2267
+ * fetching new results.
2268
+ */
2269
+ private async handleQueryChange() {
2270
+ // only reset if the query has actually changed
2271
+ if (
2272
+ !this.searchService ||
2273
+ this.dataSource.pageFetchQueryKey === this.previousQueryKey
2274
+ ) {
2275
+ return;
2276
+ }
2277
+
2278
+ // If the new state prevents us from updating the search results, don't reset
2279
+ if (this.baseQuery && !this.dataSource.canPerformSearch) {
2280
+ return;
2281
+ }
2282
+
2283
+ this.previousQueryKey = this.dataSource.pageFetchQueryKey;
2284
+
2285
+ this.totalResults = undefined;
2286
+ this.pagesToRender =
2287
+ this.initialPageNumber === 1
2288
+ ? 2 // First two pages are batched into one request when starting from page 1
2289
+ : this.initialPageNumber;
2290
+
2291
+ // Reset the infinite scroller's item count, so that it
2292
+ // shows tile placeholders until the new query's results load in
2293
+ if (this.infiniteScroller) {
2294
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
2295
+ this.infiniteScroller.reload();
2296
+ }
2297
+
2298
+ if (this.withinCollection && this.baseQuery?.trim()) {
2299
+ this.defaultSortField = SortField.relevance;
2300
+ this.defaultSortDirection = null;
2301
+ }
2302
+
2303
+ if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
2304
+ this.scrollToPage(this.initialPageNumber);
2305
+ }
2306
+ this.initialQueryChangeHappened = true;
2307
+
2308
+ // if the query changed as part of a window.history pop event, we don't want to
2309
+ // persist the state because it overwrites the forward history
2310
+ if (!this.historyPopOccurred) {
2311
+ this.persistState();
2312
+ }
2313
+ this.historyPopOccurred = false;
2314
+ }
2315
+
2316
+ private setupStateRestorationObserver() {
2317
+ if (!this.boundNavigationHandler) {
2318
+ this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
2319
+ }
2320
+ // when the user navigates back, we want to update the UI to match the URL
2321
+ window.addEventListener('popstate', this.boundNavigationHandler);
2322
+ }
2323
+
2324
+ private boundNavigationHandler?: () => void;
2325
+
2326
+ private historyNavigationHandler() {
2327
+ this.historyPopOccurred = true;
2328
+ this.restoreState();
2329
+ }
2330
+
2331
+ private restoreState() {
2332
+ const restorationState = this.restorationStateHandler.getRestorationState();
2333
+ this.displayMode = restorationState.displayMode;
2334
+ if (!this.suppressURLSinParam && restorationState.searchType != null)
2335
+ this.searchType = restorationState.searchType;
2336
+ this.selectedSort = restorationState.selectedSort ?? SortField.default;
2337
+ this.sortDirection = restorationState.sortDirection ?? null;
2338
+ this.selectedTitleFilter = restorationState.selectedTitleFilter ?? null;
2339
+ this.selectedCreatorFilter = restorationState.selectedCreatorFilter ?? null;
2340
+ this.selectedFacets = restorationState.selectedFacets;
2341
+ if (!this.suppressURLQuery) this.baseQuery = restorationState.baseQuery;
2342
+ this.setCurrentPage(restorationState.currentPage ?? 1);
2343
+ this.minSelectedDate = restorationState.minSelectedDate;
2344
+ this.maxSelectedDate = restorationState.maxSelectedDate;
2345
+ if (this.currentPage && this.currentPage > 1) {
2346
+ this.goToPage(this.currentPage);
2347
+ }
2348
+ }
2349
+
2350
+ private persistState() {
2351
+ const isDefaultSort = this.selectedSort === this.defaultSortField;
2352
+ const restorationState: RestorationState = {
2353
+ displayMode: this.displayMode,
2354
+ searchType: this.suppressURLSinParam ? undefined : this.searchType,
2355
+ selectedSort: isDefaultSort ? SortField.default : this.selectedSort,
2356
+ sortDirection: this.sortDirection ?? undefined,
2357
+ selectedFacets: this.selectedFacets ?? getDefaultSelectedFacets(),
2358
+ baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
2359
+ currentPage: this.currentPage,
2360
+ titleQuery: this.titleQuery,
2361
+ creatorQuery: this.creatorQuery,
2362
+ minSelectedDate: this.minSelectedDate,
2363
+ maxSelectedDate: this.maxSelectedDate,
2364
+ selectedTitleFilter: this.selectedTitleFilter ?? undefined,
2365
+ selectedCreatorFilter: this.selectedCreatorFilter ?? undefined,
2366
+ };
2367
+ const persistOptions: RestorationStatePersistOptions = {
2368
+ forceReplace: this.dataSourceInstallInProgress,
2369
+ persistMetadataSearchType: this.isTVCollection,
2370
+ };
2371
+ this.restorationStateHandler.persistState(restorationState, persistOptions);
2372
+ }
2373
+
2374
+ /**
2375
+ * Emits a `searchResultsLoadingChanged` event indicating that our loading state has
2376
+ * changed (either we have started loading new results, or we have finished loading them).
2377
+ */
2378
+ private emitSearchResultsLoadingChanged(): void {
2379
+ this.dispatchEvent(
2380
+ new CustomEvent<{ loading: boolean }>('searchResultsLoadingChanged', {
2381
+ detail: {
2382
+ loading: this.searchResultsLoading,
2383
+ },
2384
+ }),
2385
+ );
2386
+ }
2387
+
2388
+ /**
2389
+ * Handler for when the set of selected facets changes.
2390
+ */
2391
+ facetsChanged(e: CustomEvent<SelectedFacets>) {
2392
+ this.selectedFacets = e.detail;
2393
+ }
2394
+
2395
+ /**
2396
+ * Handler for when any facet is selected/unselected/hidden/unhidden.
2397
+ * Fires analytics indicating the type of facet event that took place.
2398
+ */
2399
+ facetClickHandler({
2400
+ detail: { facetType, bucket, negative },
2401
+ }: CustomEvent<FacetEventDetails>): void {
2402
+ let action: analyticsActions;
2403
+ if (negative) {
2404
+ action =
2405
+ bucket.state !== 'none'
2406
+ ? analyticsActions.facetNegativeSelected
2407
+ : analyticsActions.facetNegativeDeselected;
2408
+ } else {
2409
+ action =
2410
+ bucket.state !== 'none'
2411
+ ? analyticsActions.facetSelected
2412
+ : analyticsActions.facetDeselected;
2413
+ }
2414
+
2415
+ this.analyticsHandler?.sendEvent({
2416
+ category: this.searchContext,
2417
+ action,
2418
+ label: facetType,
2419
+ });
2420
+ }
2421
+
2422
+ private async scrollToPage(pageNumber: number): Promise<void> {
2423
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
2424
+
2425
+ // Wait for the infinite scroller be rendered before proceeding
2426
+ let waitAttempts = 0;
2427
+ while (!this.infiniteScroller && waitAttempts < 20) {
2428
+ await this.updateComplete;
2429
+ waitAttempts++;
2430
+ }
2431
+ if (!this.infiniteScroller) return;
2432
+
2433
+ // The scroller have its default `itemCount=0`, so propagate our estimated
2434
+ // tile count before jumping to the desired page.
2435
+ if (this.infiniteScroller.itemCount < this.estimatedTileCount) {
2436
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
2437
+ await this.updateComplete;
2438
+ }
2439
+
2440
+ // Without this setTimeout(0), Safari just pauses until the `fetchPage`
2441
+ // is complete then scrolls to the cell.
2442
+ await new Promise<void>(resolve => {
2443
+ setTimeout(resolve, 0);
2444
+ });
2445
+
2446
+ this.isScrollingToCell = true;
2447
+ const scrolled = await this.infiniteScroller.scrollToCell(
2448
+ cellIndexToScrollTo,
2449
+ true,
2450
+ );
2451
+ this.isScrollingToCell = false;
2452
+ this.infiniteScroller.refreshAllVisibleCells();
2453
+
2454
+ // After we finish scrolling, recompute the visible page from the new state
2455
+ // so that it doesn't fall out of sync.
2456
+ if (scrolled) {
2457
+ this.updateVisiblePage(this.infiniteScroller.getVisibleCellIndices());
2458
+ }
2459
+ }
2460
+
2461
+ /**
2462
+ * Whether sorting by relevance makes sense for the current state.
2463
+ * Currently equivalent to having a non-empty query.
2464
+ */
2465
+ private get isRelevanceSortAvailable(): boolean {
2466
+ return !!this.baseQuery?.trim();
2467
+ }
2468
+
2469
+ /**
2470
+ * Sets the total number of tiles displayed in the infinite scroller.
2471
+ */
2472
+ setTileCount(count: number): void {
2473
+ if (this.infiniteScroller) {
2474
+ this.infiniteScroller.itemCount = count;
2475
+ }
2476
+ }
2477
+
2478
+ /**
2479
+ * Applies the default sort options for the TV search results page
2480
+ */
2481
+ applyDefaultTVSearchSort(): void {
2482
+ this.defaultSortField = SortField.datearchived;
2483
+ this.defaultSortDirection = 'desc';
2484
+ }
2485
+
2486
+ /**
2487
+ * Applies any default sort option for the current collection, by checking
2488
+ * for one in the collection's metadata. If none is found, defaults to sorting
2489
+ * descending by:
2490
+ * - Date Favorited for fav-* collections
2491
+ * - Weekly views for all other collections
2492
+ */
2493
+ applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo): void {
2494
+ if (this.baseQuery) {
2495
+ // If there's a query set, then we default to relevance sorting regardless of
2496
+ // the collection metadata-specified sort.
2497
+ this.defaultSortField = SortField.relevance;
2498
+ this.defaultSortDirection = null;
2499
+ return;
2500
+ }
2501
+
2502
+ // Favorite collections sort on Date Favorited by default.
2503
+ // Other collections fall back to sorting on weekly views.
2504
+ const baseDefaultSort: string =
2505
+ collectionInfo?.public_metadata?.identifier?.startsWith('fav-')
2506
+ ? '-favoritedate'
2507
+ : '-week';
2508
+
2509
+ // The collection metadata may override the default sorting with something else
2510
+ const metadataSort: string | undefined =
2511
+ collectionInfo?.public_metadata?.['sort-by'];
2512
+
2513
+ // Prefer the metadata-specified sort if one exists
2514
+ const defaultSortToApply = metadataSort ?? baseDefaultSort;
2515
+
2516
+ // Account for both -field and field:dir formats
2517
+ let [field, dir] = defaultSortToApply.split(':');
2518
+ if (field.startsWith('-')) {
2519
+ field = field.slice(1);
2520
+ dir = 'desc';
2521
+ } else if (!['asc', 'desc'].includes(dir)) {
2522
+ dir = 'asc';
2523
+ }
2524
+
2525
+ const sortOption = sortOptionFromAPIString(field);
2526
+ const sortField = sortOption.field;
2527
+ if (sortField && sortField !== SortField.default) {
2528
+ this.defaultSortField = sortField;
2529
+ this.defaultSortDirection = dir as SortDirection;
2530
+ }
2531
+ }
2532
+
2533
+ /**
2534
+ * Applies the default sort option for the current profile element
2535
+ */
2536
+ applyDefaultProfileSort(): void {
2537
+ if (this.profileElement) {
2538
+ const defaultSortField = defaultProfileElementSorts[this.profileElement];
2539
+ this.defaultSortField = defaultSortField ?? SortField.weeklyview;
2540
+ } else {
2541
+ this.defaultSortField = SortField.weeklyview;
2542
+ }
2543
+
2544
+ this.defaultSortDirection = 'desc';
2545
+ }
2546
+
2547
+ /**
2548
+ * This is useful for determining whether we need to reload the scroller.
2549
+ *
2550
+ * When the fetch completes, we need to reload the scroller if the cells for that
2551
+ * page are visible, but if the page is not currenlty visible, we don't need to reload
2552
+ */
2553
+ get currentVisiblePageNumbers(): number[] {
2554
+ const visibleCells = this.infiniteScroller?.getVisibleCellIndices() ?? [];
2555
+ const visiblePages = new Set<number>();
2556
+ visibleCells.forEach(cellIndex => {
2557
+ const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
2558
+ visiblePages.add(visiblePage);
2559
+ });
2560
+ return Array.from(visiblePages);
2561
+ }
2562
+
2563
+ /**
2564
+ * Whether we are currently displaying results for a radio collection
2565
+ */
2566
+ private get isRadioCollection(): boolean {
2567
+ const { withinCollection } = this;
2568
+ const topCollections = ['radio'];
2569
+ const isTopCollection = topCollections.includes(withinCollection as string);
2570
+ const isSubCollection = topCollections.some(topCollxn =>
2571
+ this.dataSource.parentCollections?.includes(topCollxn),
2572
+ );
2573
+ return isTopCollection || isSubCollection;
2574
+ }
2575
+
2576
+ /**
2577
+ * Refreshes all visible result cells in the infinite scroller.
2578
+ */
2579
+ refreshVisibleResults(): void {
2580
+ this.infiniteScroller?.refreshAllVisibleCells();
2581
+ }
2582
+
2583
+ /**
2584
+ * Callback when a result is selected
2585
+ */
2586
+ resultSelected(event: CustomEvent<TileModel>): void {
2587
+ if (this.isManageView) {
2588
+ // Checked/unchecked state change -- rerender to ensure it propagates
2589
+ // this.mapDataSource(model => ({ ...model }));
2590
+ const cellIndex = this.dataSource.indexOf(event.detail);
2591
+ if (cellIndex >= 0) this.infiniteScroller?.refreshCell(cellIndex);
2592
+
2593
+ this.requestUpdate();
2594
+ }
2595
+
2596
+ this.analyticsHandler?.sendEvent({
2597
+ category: this.searchContext,
2598
+ action: analyticsActions.resultSelected,
2599
+ label: event.detail.mediatype,
2600
+ });
2601
+
2602
+ this.analyticsHandler?.sendEvent({
2603
+ category: this.searchContext,
2604
+ action: analyticsActions.resultSelected,
2605
+ label: `page-${this.currentPage}`,
2606
+ });
2607
+ }
2608
+
2609
+ cellForIndex(index: number): HTMLTemplateResult | undefined {
2610
+ const model = this.tileModelAtCellIndex(index);
2611
+ if (!model) return undefined;
2612
+
2613
+ // Tiles show dates in UTC by default.
2614
+ // But for certain types of time-based media, we want them to use local time instead.
2615
+ // Those local-time cases are:
2616
+ // - TV or Radio search results
2617
+ // - TV or Radio collection results
2618
+ const isTVSearch = this.searchType === SearchType.TV;
2619
+ const isRadioSearch = this.searchType === SearchType.RADIO;
2620
+ const { isTVCollection, isRadioCollection } = this;
2621
+ const shouldUseLocalTime =
2622
+ isTVSearch || isRadioSearch || isTVCollection || isRadioCollection;
2623
+
2624
+ return html`
2625
+ <tile-dispatcher
2626
+ .collectionPagePath=${this.collectionPagePath}
2627
+ .baseNavigationUrl=${this.baseNavigationUrl}
2628
+ .baseImageUrl=${this.baseImageUrl}
2629
+ .model=${model}
2630
+ .tileDisplayMode=${this.displayMode}
2631
+ .resizeObserver=${this.resizeObserver}
2632
+ .collectionTitles=${this.dataSource.collectionTitles}
2633
+ .sortParam=${this.sortParam}
2634
+ .defaultSortParam=${this.defaultSortParam}
2635
+ .creatorFilter=${this.selectedCreatorFilter}
2636
+ .mobileBreakpoint=${this.mobileBreakpoint}
2637
+ .loggedIn=${this.loggedIn}
2638
+ .suppressBlurring=${this.shouldSuppressTileBlurring}
2639
+ .isManageView=${this.isManageView}
2640
+ .tileActions=${this.tileActions}
2641
+ .layoutType=${this.tileLayoutType}
2642
+ ?showTvClips=${isTVSearch || isTVCollection}
2643
+ ?enableHoverPane=${true}
2644
+ ?useLocalTime=${shouldUseLocalTime}
2645
+ @resultSelected=${(e: CustomEvent) => this.resultSelected(e)}
2646
+ >
2647
+ </tile-dispatcher>
2648
+ `;
2649
+ }
2650
+
2651
+ /**
2652
+ * When the user scrolls near to the bottom of the page, fetch the next page
2653
+ * increase the number of pages to render and start fetching data for the new page
2654
+ */
2655
+ private scrollThresholdReached() {
2656
+ if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
2657
+ this.pagesToRender += 1;
2658
+ this.dataSource.fetchPage(this.pagesToRender);
2659
+ }
2660
+ }
2661
+
2662
+ /**
2663
+ * Fetches search results for privileged users when in manage view.
2664
+ *
2665
+ * This method:
2666
+ * 1. Checks if we're in search context and either haven't loaded results yet, or have already finished loading with > 100 total results
2667
+ * 2. Resets the datasource pagination state
2668
+ * 3. Fetches first page with limit based on maxPagesToManage threshold
2669
+ * 4. Reloads the infinite scroller to display new results
2670
+ */
2671
+ private fetchManageableSearchResults(): void {
2672
+ const hasNotLoadedInitialResults = !this.dataSource.totalResults;
2673
+ const hasLoadedWithMoreResultsAvailable =
2674
+ !this.searchResultsLoading && this.dataSource.totalResults > 100;
2675
+
2676
+ if (
2677
+ this.pageContext === 'search' &&
2678
+ (hasNotLoadedInitialResults || hasLoadedWithMoreResultsAvailable)
2679
+ ) {
2680
+ this.dataSource.resetPages();
2681
+ this.dataSource.fetchPage(1, this.maxPagesToManage);
2682
+ this.infiniteScroller?.reload();
2683
+ }
2684
+ }
2685
+
2686
+ static get styles() {
2687
+ return [
2688
+ srOnlyStyle,
2689
+ css`
2690
+ :host {
2691
+ display: block;
2692
+ --leftColumnWidth: 18rem;
2693
+ --leftColumnPaddingTop: 2rem;
2694
+ --leftColumnPaddingRight: 2.5rem;
2695
+ }
2696
+
2697
+ #facet-top-view {
2698
+ display: flex;
2699
+ }
2700
+
2701
+ /**
2702
+ * When page width resizes from desktop to mobile, use this class to
2703
+ * disable expand/collapse transition when loading.
2704
+ */
2705
+ .preload * {
2706
+ transition: none !important;
2707
+ -webkit-transition: none !important;
2708
+ -moz-transition: none !important;
2709
+ -ms-transition: none !important;
2710
+ -o-transition: none !important;
2711
+ }
2712
+
2713
+ #content-container {
2714
+ display: flex;
2715
+ }
2716
+
2717
+ empty-placeholder {
2718
+ margin-top: var(--placeholderMarginTop, 0);
2719
+ }
2720
+
2721
+ .collapser-icon {
2722
+ display: inline-block;
2723
+ }
2724
+
2725
+ .collapser-icon svg {
2726
+ display: inline-block;
2727
+ width: 12px;
2728
+ height: 12px;
2729
+ transition: transform 0.2s ease-out;
2730
+ }
2731
+
2732
+ #mobile-filter-collapse {
2733
+ width: 100%;
2734
+ }
2735
+
2736
+ #mobile-filter-collapse > summary {
2737
+ cursor: pointer;
2738
+ list-style: none;
2739
+ }
2740
+
2741
+ #mobile-filter-collapse[open] > summary {
2742
+ margin-bottom: 10px;
2743
+ }
2744
+
2745
+ #mobile-filter-collapse h2 {
2746
+ display: inline-block;
2747
+ margin: 0;
2748
+ font-size: 2rem;
2749
+ }
2750
+
2751
+ #mobile-filter-collapse[open] svg {
2752
+ transform: rotate(90deg);
2753
+ }
2754
+
2755
+ #content-container.mobile {
2756
+ display: block;
2757
+ }
2758
+
2759
+ #right-column {
2760
+ flex: 1;
2761
+ position: relative;
2762
+ min-height: 90vh;
2763
+ border-right: 1px solid rgb(232, 232, 232);
2764
+ margin-top: var(--rightColumnMarginTop, 0);
2765
+ padding-top: var(--rightColumnPaddingTop, 2rem);
2766
+ background: #fff;
2767
+ }
2768
+
2769
+ #left-column:not([hidden]) + #right-column {
2770
+ border-left: 1px solid rgb(232, 232, 232);
2771
+ }
2772
+
2773
+ #right-column.smart-results-spacing {
2774
+ padding-top: 0.5rem;
2775
+ border-right: none;
2776
+ background: transparent;
2777
+ min-width: 0;
2778
+ }
2779
+
2780
+ #results {
2781
+ background: #fff;
2782
+ padding-left: 1rem;
2783
+ padding-right: 1rem;
2784
+ }
2785
+
2786
+ #right-column.smart-results-spacing #results {
2787
+ border-radius: 10px 10px 0px 0px;
2788
+ padding-top: 0.5rem;
2789
+ margin-top: 1rem;
2790
+ }
2791
+
2792
+ .mobile #right-column {
2793
+ border-left: none;
2794
+ }
2795
+
2796
+ .mobile #results {
2797
+ padding: 5px 5px 0;
2798
+ }
2799
+
2800
+ #left-column {
2801
+ width: var(--leftColumnWidth, 18rem);
2802
+ /* Prevents Safari from shrinking col at first draw */
2803
+ min-width: var(--leftColumnWidth, 18rem);
2804
+ padding-top: var(--leftColumnPaddingTop, 2rem);
2805
+ /* Reduced padding by 0.2rem to add the invisible border in the rule below */
2806
+ padding-right: calc(var(--leftColumnPaddingRight, 2.5rem) - 0.2rem);
2807
+ border-right: 0.2rem solid transparent; /* Pads to the right of the scrollbar a bit */
2808
+ z-index: 1;
2809
+ }
2810
+
2811
+ .desktop #left-column {
2812
+ top: 0;
2813
+ position: sticky;
2814
+ height: calc(100vh - 2rem);
2815
+ max-height: calc(100vh - 2rem);
2816
+ overflow-x: hidden;
2817
+ overflow-y: scroll;
2818
+
2819
+ /*
2820
+ * Firefox doesn't support any of the -webkit-scrollbar stuff below, but
2821
+ * does at least give us a tiny bit of control over width & color.
2822
+ */
2823
+ scrollbar-width: thin;
2824
+ scrollbar-color: transparent transparent;
2825
+ }
2826
+ .desktop #left-column:hover {
2827
+ scrollbar-color: auto;
2828
+ }
2829
+ .desktop #left-column::-webkit-scrollbar {
2830
+ appearance: none;
2831
+ width: 6px;
2832
+ }
2833
+ .desktop #left-column::-webkit-scrollbar-button {
2834
+ height: 3px;
2835
+ background: transparent;
2836
+ }
2837
+ .desktop #left-column::-webkit-scrollbar-corner {
2838
+ background: transparent;
2839
+ }
2840
+ .desktop #left-column::-webkit-scrollbar-thumb {
2841
+ border-radius: 4px;
2842
+ }
2843
+ .desktop #left-column:hover::-webkit-scrollbar-thumb {
2844
+ background: rgba(0, 0, 0, 0.15);
2845
+ }
2846
+ .desktop #left-column:hover::-webkit-scrollbar-thumb:hover {
2847
+ background: rgba(0, 0, 0, 0.2);
2848
+ }
2849
+ .desktop #left-column:hover::-webkit-scrollbar-thumb:active {
2850
+ background: rgba(0, 0, 0, 0.3);
2851
+ }
2852
+
2853
+ #facets-bottom-fade {
2854
+ background: linear-gradient(
2855
+ to bottom,
2856
+ #fbfbfd00 0%,
2857
+ #fbfbfdc0 50%,
2858
+ #fbfbfd 80%,
2859
+ #fbfbfd 100%
2860
+ );
2861
+ position: fixed;
2862
+ bottom: 0;
2863
+ height: 50px;
2864
+ /* Wide enough to cover the content, but leave the scrollbar uncovered */
2865
+ width: calc(
2866
+ var(--leftColumnWidth) + var(--leftColumnPaddingRight) - 10px
2867
+ );
2868
+ z-index: 2;
2869
+ pointer-events: none;
2870
+ transition: height 0.1s ease;
2871
+ }
2872
+ #facets-bottom-fade.hidden {
2873
+ height: 0;
2874
+ }
2875
+
2876
+ .facets-message {
2877
+ font-size: 1.4rem;
2878
+ }
2879
+
2880
+ .desktop-facets-dropdown > summary {
2881
+ cursor: pointer;
2882
+ list-style: none;
2883
+ }
2884
+
2885
+ .desktop-facets-dropdown h2 {
2886
+ display: inline-block;
2887
+ margin: 0;
2888
+ font-size: 1.6rem;
2889
+ }
2890
+
2891
+ .desktop-facets-dropdown[open] > summary {
2892
+ margin-bottom: 10px;
2893
+ }
2894
+
2895
+ .desktop-facets-dropdown[open] svg {
2896
+ transform: rotate(90deg);
2897
+ }
2898
+
2899
+ .desktop #left-column-scroll-sentinel {
2900
+ width: 1px;
2901
+ height: 100vh;
2902
+ background: transparent;
2903
+ }
2904
+
2905
+ .desktop #facets-scroll-sentinel {
2906
+ width: 1px;
2907
+ height: 1px;
2908
+ background: transparent;
2909
+ }
2910
+
2911
+ #facets-header-container {
2912
+ display: flex;
2913
+ justify-content: space-between;
2914
+ align-items: flex-start;
2915
+ clear: both;
2916
+ }
2917
+
2918
+ .desktop #facets-header-container {
2919
+ flex-wrap: wrap;
2920
+ }
2921
+
2922
+ .mobile #left-column {
2923
+ width: 100%;
2924
+ min-width: 0;
2925
+ padding: 5px 0;
2926
+ border: 0;
2927
+ }
2928
+
2929
+ .clear-filters-btn-row {
2930
+ display: inline-block;
2931
+ }
2932
+
2933
+ .desktop .clear-filters-btn-row {
2934
+ width: 100%;
2935
+ }
2936
+
2937
+ .clear-filters-btn {
2938
+ display: inline-block;
2939
+ appearance: none;
2940
+ margin: 0;
2941
+ padding: 0;
2942
+ border: 0;
2943
+ background: none;
2944
+ color: var(--ia-theme-link-color);
2945
+ font-size: 1.4rem;
2946
+ font-family: inherit;
2947
+ cursor: pointer;
2948
+ }
2949
+
2950
+ .clear-filters-btn:hover {
2951
+ text-decoration: underline;
2952
+ }
2953
+
2954
+ .clear-filters-btn-separator {
2955
+ display: inline-block;
2956
+ margin-left: 5px;
2957
+ border-left: 1px solid #2c2c2c;
2958
+ font-size: 1.4rem;
2959
+ line-height: 1.3rem;
2960
+ }
2961
+
2962
+ #tv-filters {
2963
+ margin-bottom: 15px;
2964
+ }
2965
+
2966
+ #tv-shows {
2967
+ --comboBoxListWidth: 300px;
2968
+ }
2969
+
2970
+ .tv-filter-dropdown {
2971
+ display: block;
2972
+ font-size: 14px;
2973
+ margin-left: 1px;
2974
+ margin-bottom: 5px;
2975
+ }
2976
+
2977
+ .tv-filter-dropdown::part(combo-box) {
2978
+ outline-offset: 1px;
2979
+ }
2980
+
2981
+ .tv-filter-dropdown::part(option) {
2982
+ line-height: 1.1;
2983
+ padding: 7px;
2984
+ }
2985
+
2986
+ .tv-filter-dropdown::part(clear-button) {
2987
+ flex: 0 0 26px;
2988
+ --combo-box-clear-icon-size: 14px;
2989
+ }
2990
+
2991
+ .tv-filter-dropdown::part(icon) {
2992
+ width: 1.4rem;
2993
+ height: 1.4rem;
2994
+ }
2995
+
2996
+ #facets-container {
2997
+ position: relative;
2998
+ max-height: 0;
2999
+ transition: max-height 0.2s ease-in-out;
3000
+ z-index: 1;
3001
+ margin-top: var(--facetsContainerMarginTop, 3rem);
3002
+ padding-bottom: 2rem;
3003
+ }
3004
+
3005
+ .desktop #facets-container {
3006
+ width: 18rem;
3007
+ }
3008
+
3009
+ .mobile #facets-container {
3010
+ overflow: hidden;
3011
+ padding-bottom: 0;
3012
+ padding-left: 10px;
3013
+ padding-right: 10px;
3014
+ }
3015
+
3016
+ #facets-container.expanded {
3017
+ max-height: 2000px;
3018
+ }
3019
+
3020
+ .results-section-heading {
3021
+ margin: 0.5rem 0.3rem;
3022
+ font-size: 2rem;
3023
+ line-height: 25px;
3024
+ }
3025
+
3026
+ #results-total {
3027
+ display: flex;
3028
+ align-items: baseline;
3029
+ }
3030
+
3031
+ #results-total:not(.filtered) {
3032
+ padding-bottom: 2rem;
3033
+ }
3034
+
3035
+ .mobile #results-total {
3036
+ position: absolute;
3037
+ right: 10px;
3038
+ }
3039
+
3040
+ #big-results-count {
3041
+ font-size: 2.4rem;
3042
+ font-weight: 500;
3043
+ margin-right: 5px;
3044
+ }
3045
+
3046
+ .mobile #big-results-count {
3047
+ font-size: 2rem;
3048
+ }
3049
+
3050
+ #big-results-label {
3051
+ font-size: 1.4rem;
3052
+ font-weight: 200;
3053
+ }
3054
+
3055
+ #list-header {
3056
+ max-height: 4.2rem;
3057
+ }
3058
+
3059
+ .loading-cover {
3060
+ position: absolute;
3061
+ top: 0;
3062
+ left: 0;
3063
+ width: 100%;
3064
+ height: 100%;
3065
+ display: flex;
3066
+ justify-content: center;
3067
+ z-index: 1;
3068
+ padding-top: 50px;
3069
+ }
3070
+
3071
+ #tile-blur-label {
3072
+ display: flex;
3073
+ align-items: center;
3074
+ column-gap: 5px;
3075
+ }
3076
+
3077
+ #tile-blur-check {
3078
+ margin: 0 5px 0 0;
3079
+ width: 15px;
3080
+ }
3081
+
3082
+ circular-activity-indicator {
3083
+ width: 30px;
3084
+ height: 30px;
3085
+ }
3086
+
3087
+ sort-filter-bar {
3088
+ display: block;
3089
+ margin-bottom: 4rem;
3090
+ }
3091
+
3092
+ infinite-scroller {
3093
+ display: block;
3094
+ --infiniteScrollerRowGap: var(--collectionBrowserRowGap, 1.7rem);
3095
+ --infiniteScrollerColGap: var(--collectionBrowserColGap, 1.7rem);
3096
+ }
3097
+
3098
+ infinite-scroller.list-compact {
3099
+ --infiniteScrollerCellMinWidth: var(
3100
+ --collectionBrowserCellMinWidth,
3101
+ 100%
3102
+ );
3103
+ --infiniteScrollerCellMinHeight: 45px; /* override infinite scroller component */
3104
+ --infiniteScrollerCellMaxHeight: 56px;
3105
+ --infiniteScrollerRowGap: 10px;
3106
+ }
3107
+
3108
+ infinite-scroller.list-detail {
3109
+ --infiniteScrollerCellMinWidth: var(
3110
+ --collectionBrowserCellMinWidth,
3111
+ 100%
3112
+ );
3113
+ --infiniteScrollerCellMinHeight: var(
3114
+ --collectionBrowserCellMinHeight,
3115
+ 5rem
3116
+ );
3117
+ /*
3118
+ 30px in spec, compensating for a -4px margin
3119
+ to align title with top of item image
3120
+ src/tiles/list/tile-list.ts
3121
+ */
3122
+ --infiniteScrollerRowGap: 34px;
3123
+ }
3124
+
3125
+ .mobile infinite-scroller.list-detail {
3126
+ --infiniteScrollerRowGap: 24px;
3127
+ }
3128
+
3129
+ infinite-scroller.grid {
3130
+ --infiniteScrollerCellMinWidth: var(
3131
+ --collectionBrowserCellMinWidth,
3132
+ 17rem
3133
+ );
3134
+ --infiniteScrollerCellMaxWidth: var(
3135
+ --collectionBrowserCellMaxWidth,
3136
+ 1fr
3137
+ );
3138
+ }
3139
+
3140
+ /* Allow tiles to shrink a bit further at smaller viewport widths */
3141
+ @media screen and (max-width: 880px) {
3142
+ infinite-scroller.grid {
3143
+ --infiniteScrollerCellMinWidth: var(
3144
+ --collectionBrowserCellMinWidth,
3145
+ 15rem
3146
+ );
3147
+ }
3148
+ }
3149
+ /* At very small widths, maintain a 2-tile layout as far as it can reasonably go */
3150
+ @media screen and (max-width: 360px) {
3151
+ infinite-scroller.grid {
3152
+ --infiniteScrollerCellMinWidth: var(
3153
+ --collectionBrowserCellMinWidth,
3154
+ 12rem
3155
+ );
3156
+ }
3157
+ }
3158
+
3159
+ infinite-scroller.hidden {
3160
+ display: none;
3161
+ }
3162
+ `,
3163
+ ];
3164
+ }
3165
+ }