@internetarchive/collection-browser 3.3.1 → 3.3.2

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 (492) hide show
  1. package/package.json +1 -1
  2. package/dist/index.d.ts +0 -16
  3. package/dist/index.js.map +0 -1
  4. package/dist/src/app-root.d.ts +0 -105
  5. package/dist/src/app-root.js +0 -1076
  6. package/dist/src/app-root.js.map +0 -1
  7. package/dist/src/assets/img/icons/arrow-left.d.ts +0 -2
  8. package/dist/src/assets/img/icons/arrow-left.js +0 -10
  9. package/dist/src/assets/img/icons/arrow-left.js.map +0 -1
  10. package/dist/src/assets/img/icons/arrow-right.d.ts +0 -2
  11. package/dist/src/assets/img/icons/arrow-right.js +0 -10
  12. package/dist/src/assets/img/icons/arrow-right.js.map +0 -1
  13. package/dist/src/assets/img/icons/chevron.d.ts +0 -2
  14. package/dist/src/assets/img/icons/chevron.js +0 -4
  15. package/dist/src/assets/img/icons/chevron.js.map +0 -1
  16. package/dist/src/assets/img/icons/close-circle-dark.d.ts +0 -2
  17. package/dist/src/assets/img/icons/close-circle-dark.js +0 -5
  18. package/dist/src/assets/img/icons/close-circle-dark.js.map +0 -1
  19. package/dist/src/assets/img/icons/contract.d.ts +0 -2
  20. package/dist/src/assets/img/icons/contract.js +0 -9
  21. package/dist/src/assets/img/icons/contract.js.map +0 -1
  22. package/dist/src/assets/img/icons/empty-query.d.ts +0 -2
  23. package/dist/src/assets/img/icons/empty-query.js +0 -5
  24. package/dist/src/assets/img/icons/empty-query.js.map +0 -1
  25. package/dist/src/assets/img/icons/expand.d.ts +0 -2
  26. package/dist/src/assets/img/icons/expand.js +0 -9
  27. package/dist/src/assets/img/icons/expand.js.map +0 -1
  28. package/dist/src/assets/img/icons/eye-closed.d.ts +0 -2
  29. package/dist/src/assets/img/icons/eye-closed.js +0 -5
  30. package/dist/src/assets/img/icons/eye-closed.js.map +0 -1
  31. package/dist/src/assets/img/icons/eye.d.ts +0 -2
  32. package/dist/src/assets/img/icons/eye.js +0 -5
  33. package/dist/src/assets/img/icons/eye.js.map +0 -1
  34. package/dist/src/assets/img/icons/favorite-filled.d.ts +0 -1
  35. package/dist/src/assets/img/icons/favorite-filled.js +0 -10
  36. package/dist/src/assets/img/icons/favorite-filled.js.map +0 -1
  37. package/dist/src/assets/img/icons/favorite-unfilled.d.ts +0 -1
  38. package/dist/src/assets/img/icons/favorite-unfilled.js +0 -9
  39. package/dist/src/assets/img/icons/favorite-unfilled.js.map +0 -1
  40. package/dist/src/assets/img/icons/filter.d.ts +0 -2
  41. package/dist/src/assets/img/icons/filter.js +0 -10
  42. package/dist/src/assets/img/icons/filter.js.map +0 -1
  43. package/dist/src/assets/img/icons/login-required.d.ts +0 -1
  44. package/dist/src/assets/img/icons/login-required.js +0 -18
  45. package/dist/src/assets/img/icons/login-required.js.map +0 -1
  46. package/dist/src/assets/img/icons/mediatype/account.d.ts +0 -1
  47. package/dist/src/assets/img/icons/mediatype/account.js +0 -14
  48. package/dist/src/assets/img/icons/mediatype/account.js.map +0 -1
  49. package/dist/src/assets/img/icons/mediatype/audio.d.ts +0 -1
  50. package/dist/src/assets/img/icons/mediatype/audio.js +0 -14
  51. package/dist/src/assets/img/icons/mediatype/audio.js.map +0 -1
  52. package/dist/src/assets/img/icons/mediatype/collection.d.ts +0 -1
  53. package/dist/src/assets/img/icons/mediatype/collection.js +0 -12
  54. package/dist/src/assets/img/icons/mediatype/collection.js.map +0 -1
  55. package/dist/src/assets/img/icons/mediatype/data.d.ts +0 -1
  56. package/dist/src/assets/img/icons/mediatype/data.js +0 -15
  57. package/dist/src/assets/img/icons/mediatype/data.js.map +0 -1
  58. package/dist/src/assets/img/icons/mediatype/etree.d.ts +0 -1
  59. package/dist/src/assets/img/icons/mediatype/etree.js +0 -14
  60. package/dist/src/assets/img/icons/mediatype/etree.js.map +0 -1
  61. package/dist/src/assets/img/icons/mediatype/film.d.ts +0 -1
  62. package/dist/src/assets/img/icons/mediatype/film.js +0 -14
  63. package/dist/src/assets/img/icons/mediatype/film.js.map +0 -1
  64. package/dist/src/assets/img/icons/mediatype/images.d.ts +0 -1
  65. package/dist/src/assets/img/icons/mediatype/images.js +0 -13
  66. package/dist/src/assets/img/icons/mediatype/images.js.map +0 -1
  67. package/dist/src/assets/img/icons/mediatype/radio.d.ts +0 -1
  68. package/dist/src/assets/img/icons/mediatype/radio.js +0 -15
  69. package/dist/src/assets/img/icons/mediatype/radio.js.map +0 -1
  70. package/dist/src/assets/img/icons/mediatype/search.d.ts +0 -1
  71. package/dist/src/assets/img/icons/mediatype/search.js +0 -14
  72. package/dist/src/assets/img/icons/mediatype/search.js.map +0 -1
  73. package/dist/src/assets/img/icons/mediatype/software.d.ts +0 -1
  74. package/dist/src/assets/img/icons/mediatype/software.js +0 -13
  75. package/dist/src/assets/img/icons/mediatype/software.js.map +0 -1
  76. package/dist/src/assets/img/icons/mediatype/texts.d.ts +0 -1
  77. package/dist/src/assets/img/icons/mediatype/texts.js +0 -13
  78. package/dist/src/assets/img/icons/mediatype/texts.js.map +0 -1
  79. package/dist/src/assets/img/icons/mediatype/tv-commercial.d.ts +0 -1
  80. package/dist/src/assets/img/icons/mediatype/tv-commercial.js +0 -12
  81. package/dist/src/assets/img/icons/mediatype/tv-commercial.js.map +0 -1
  82. package/dist/src/assets/img/icons/mediatype/tv-fact-check.d.ts +0 -1
  83. package/dist/src/assets/img/icons/mediatype/tv-fact-check.js +0 -12
  84. package/dist/src/assets/img/icons/mediatype/tv-fact-check.js.map +0 -1
  85. package/dist/src/assets/img/icons/mediatype/tv-quote.d.ts +0 -1
  86. package/dist/src/assets/img/icons/mediatype/tv-quote.js +0 -12
  87. package/dist/src/assets/img/icons/mediatype/tv-quote.js.map +0 -1
  88. package/dist/src/assets/img/icons/mediatype/tv.d.ts +0 -1
  89. package/dist/src/assets/img/icons/mediatype/tv.js +0 -14
  90. package/dist/src/assets/img/icons/mediatype/tv.js.map +0 -1
  91. package/dist/src/assets/img/icons/mediatype/video.d.ts +0 -1
  92. package/dist/src/assets/img/icons/mediatype/video.js +0 -14
  93. package/dist/src/assets/img/icons/mediatype/video.js.map +0 -1
  94. package/dist/src/assets/img/icons/mediatype/web.d.ts +0 -1
  95. package/dist/src/assets/img/icons/mediatype/web.js +0 -13
  96. package/dist/src/assets/img/icons/mediatype/web.js.map +0 -1
  97. package/dist/src/assets/img/icons/null-result.d.ts +0 -2
  98. package/dist/src/assets/img/icons/null-result.js +0 -5
  99. package/dist/src/assets/img/icons/null-result.js.map +0 -1
  100. package/dist/src/assets/img/icons/quote.d.ts +0 -1
  101. package/dist/src/assets/img/icons/quote.js +0 -7
  102. package/dist/src/assets/img/icons/quote.js.map +0 -1
  103. package/dist/src/assets/img/icons/restricted.d.ts +0 -1
  104. package/dist/src/assets/img/icons/restricted.js +0 -13
  105. package/dist/src/assets/img/icons/restricted.js.map +0 -1
  106. package/dist/src/assets/img/icons/reviews.d.ts +0 -1
  107. package/dist/src/assets/img/icons/reviews.js +0 -11
  108. package/dist/src/assets/img/icons/reviews.js.map +0 -1
  109. package/dist/src/assets/img/icons/upload.d.ts +0 -1
  110. package/dist/src/assets/img/icons/upload.js +0 -12
  111. package/dist/src/assets/img/icons/upload.js.map +0 -1
  112. package/dist/src/assets/img/icons/views.d.ts +0 -1
  113. package/dist/src/assets/img/icons/views.js +0 -11
  114. package/dist/src/assets/img/icons/views.js.map +0 -1
  115. package/dist/src/circular-activity-indicator.d.ts +0 -5
  116. package/dist/src/circular-activity-indicator.js +0 -66
  117. package/dist/src/circular-activity-indicator.js.map +0 -1
  118. package/dist/src/collection-browser.d.ts +0 -684
  119. package/dist/src/collection-browser.js +0 -2567
  120. package/dist/src/collection-browser.js.map +0 -1
  121. package/dist/src/collection-facets/facet-row.d.ts +0 -30
  122. package/dist/src/collection-facets/facet-row.js +0 -265
  123. package/dist/src/collection-facets/facet-row.js.map +0 -1
  124. package/dist/src/collection-facets/facet-tombstone-row.d.ts +0 -5
  125. package/dist/src/collection-facets/facet-tombstone-row.js +0 -43
  126. package/dist/src/collection-facets/facet-tombstone-row.js.map +0 -1
  127. package/dist/src/collection-facets/facets-template.d.ts +0 -13
  128. package/dist/src/collection-facets/facets-template.js +0 -68
  129. package/dist/src/collection-facets/facets-template.js.map +0 -1
  130. package/dist/src/collection-facets/models.d.ts +0 -9
  131. package/dist/src/collection-facets/models.js +0 -10
  132. package/dist/src/collection-facets/models.js.map +0 -1
  133. package/dist/src/collection-facets/more-facets-content.d.ts +0 -109
  134. package/dist/src/collection-facets/more-facets-content.js +0 -547
  135. package/dist/src/collection-facets/more-facets-content.js.map +0 -1
  136. package/dist/src/collection-facets/more-facets-pagination.d.ts +0 -36
  137. package/dist/src/collection-facets/more-facets-pagination.js +0 -264
  138. package/dist/src/collection-facets/more-facets-pagination.js.map +0 -1
  139. package/dist/src/collection-facets/smart-facets/dedupe.d.ts +0 -10
  140. package/dist/src/collection-facets/smart-facets/dedupe.js +0 -35
  141. package/dist/src/collection-facets/smart-facets/dedupe.js.map +0 -1
  142. package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.d.ts +0 -5
  143. package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.js +0 -24
  144. package/dist/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.js.map +0 -1
  145. package/dist/src/collection-facets/smart-facets/heuristics/index.d.ts +0 -3
  146. package/dist/src/collection-facets/smart-facets/heuristics/index.js +0 -4
  147. package/dist/src/collection-facets/smart-facets/heuristics/index.js.map +0 -1
  148. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.d.ts +0 -4
  149. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.js +0 -14
  150. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.js.map +0 -1
  151. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.d.ts +0 -6
  152. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.js +0 -68
  153. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.js.map +0 -1
  154. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.d.ts +0 -9
  155. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js +0 -69
  156. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js.map +0 -1
  157. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.d.ts +0 -21
  158. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js +0 -76
  159. package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.js.map +0 -1
  160. package/dist/src/collection-facets/smart-facets/models.d.ts +0 -30
  161. package/dist/src/collection-facets/smart-facets/models.js +0 -2
  162. package/dist/src/collection-facets/smart-facets/models.js.map +0 -1
  163. package/dist/src/collection-facets/smart-facets/smart-facet-bar.d.ts +0 -54
  164. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +0 -383
  165. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +0 -1
  166. package/dist/src/collection-facets/smart-facets/smart-facet-button.d.ts +0 -11
  167. package/dist/src/collection-facets/smart-facets/smart-facet-button.js +0 -133
  168. package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +0 -1
  169. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +0 -28
  170. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +0 -172
  171. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +0 -1
  172. package/dist/src/collection-facets/smart-facets/smart-facet-equals.d.ts +0 -2
  173. package/dist/src/collection-facets/smart-facets/smart-facet-equals.js +0 -13
  174. package/dist/src/collection-facets/smart-facets/smart-facet-equals.js.map +0 -1
  175. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.d.ts +0 -5
  176. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +0 -18
  177. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +0 -1
  178. package/dist/src/collection-facets/toggle-switch.d.ts +0 -41
  179. package/dist/src/collection-facets/toggle-switch.js +0 -174
  180. package/dist/src/collection-facets/toggle-switch.js.map +0 -1
  181. package/dist/src/collection-facets.d.ts +0 -113
  182. package/dist/src/collection-facets.js +0 -873
  183. package/dist/src/collection-facets.js.map +0 -1
  184. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +0 -261
  185. package/dist/src/data-source/collection-browser-data-source-interface.js +0 -2
  186. package/dist/src/data-source/collection-browser-data-source-interface.js.map +0 -1
  187. package/dist/src/data-source/collection-browser-data-source.d.ts +0 -400
  188. package/dist/src/data-source/collection-browser-data-source.js +0 -1103
  189. package/dist/src/data-source/collection-browser-data-source.js.map +0 -1
  190. package/dist/src/data-source/collection-browser-query-state.d.ts +0 -49
  191. package/dist/src/data-source/collection-browser-query-state.js +0 -2
  192. package/dist/src/data-source/collection-browser-query-state.js.map +0 -1
  193. package/dist/src/data-source/models.d.ts +0 -32
  194. package/dist/src/data-source/models.js +0 -9
  195. package/dist/src/data-source/models.js.map +0 -1
  196. package/dist/src/empty-placeholder.d.ts +0 -23
  197. package/dist/src/empty-placeholder.js +0 -165
  198. package/dist/src/empty-placeholder.js.map +0 -1
  199. package/dist/src/expanded-date-picker.d.ts +0 -50
  200. package/dist/src/expanded-date-picker.js +0 -182
  201. package/dist/src/expanded-date-picker.js.map +0 -1
  202. package/dist/src/language-code-handler/language-code-handler.d.ts +0 -37
  203. package/dist/src/language-code-handler/language-code-handler.js +0 -27
  204. package/dist/src/language-code-handler/language-code-handler.js.map +0 -1
  205. package/dist/src/language-code-handler/language-code-mapping.d.ts +0 -1
  206. package/dist/src/language-code-handler/language-code-mapping.js +0 -563
  207. package/dist/src/language-code-handler/language-code-mapping.js.map +0 -1
  208. package/dist/src/manage/manage-bar.d.ts +0 -58
  209. package/dist/src/manage/manage-bar.js +0 -237
  210. package/dist/src/manage/manage-bar.js.map +0 -1
  211. package/dist/src/manage/remove-items-modal-content.d.ts +0 -9
  212. package/dist/src/manage/remove-items-modal-content.js +0 -104
  213. package/dist/src/manage/remove-items-modal-content.js.map +0 -1
  214. package/dist/src/mediatype/mediatype-config.d.ts +0 -11
  215. package/dist/src/mediatype/mediatype-config.js +0 -116
  216. package/dist/src/mediatype/mediatype-config.js.map +0 -1
  217. package/dist/src/models.d.ts +0 -302
  218. package/dist/src/models.js +0 -511
  219. package/dist/src/models.js.map +0 -1
  220. package/dist/src/restoration-state-handler.d.ts +0 -75
  221. package/dist/src/restoration-state-handler.js +0 -403
  222. package/dist/src/restoration-state-handler.js.map +0 -1
  223. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +0 -6
  224. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +0 -60
  225. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js.map +0 -1
  226. package/dist/src/sort-filter-bar/alpha-bar.d.ts +0 -21
  227. package/dist/src/sort-filter-bar/alpha-bar.js +0 -241
  228. package/dist/src/sort-filter-bar/alpha-bar.js.map +0 -1
  229. package/dist/src/sort-filter-bar/img/compact.d.ts +0 -1
  230. package/dist/src/sort-filter-bar/img/compact.js +0 -5
  231. package/dist/src/sort-filter-bar/img/compact.js.map +0 -1
  232. package/dist/src/sort-filter-bar/img/list.d.ts +0 -1
  233. package/dist/src/sort-filter-bar/img/list.js +0 -5
  234. package/dist/src/sort-filter-bar/img/list.js.map +0 -1
  235. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +0 -1
  236. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +0 -15
  237. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js.map +0 -1
  238. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +0 -1
  239. package/dist/src/sort-filter-bar/img/sort-toggle-down.js +0 -17
  240. package/dist/src/sort-filter-bar/img/sort-toggle-down.js.map +0 -1
  241. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +0 -1
  242. package/dist/src/sort-filter-bar/img/sort-toggle-up.js +0 -17
  243. package/dist/src/sort-filter-bar/img/sort-toggle-up.js.map +0 -1
  244. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +0 -1
  245. package/dist/src/sort-filter-bar/img/sort-triangle.js +0 -5
  246. package/dist/src/sort-filter-bar/img/sort-triangle.js.map +0 -1
  247. package/dist/src/sort-filter-bar/img/tile.d.ts +0 -1
  248. package/dist/src/sort-filter-bar/img/tile.js +0 -5
  249. package/dist/src/sort-filter-bar/img/tile.js.map +0 -1
  250. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +0 -278
  251. package/dist/src/sort-filter-bar/sort-filter-bar.js +0 -1161
  252. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +0 -1
  253. package/dist/src/styles/ia-button.d.ts +0 -2
  254. package/dist/src/styles/ia-button.js +0 -134
  255. package/dist/src/styles/ia-button.js.map +0 -1
  256. package/dist/src/styles/item-image-styles.d.ts +0 -8
  257. package/dist/src/styles/item-image-styles.js +0 -123
  258. package/dist/src/styles/item-image-styles.js.map +0 -1
  259. package/dist/src/styles/sr-only.d.ts +0 -1
  260. package/dist/src/styles/sr-only.js +0 -18
  261. package/dist/src/styles/sr-only.js.map +0 -1
  262. package/dist/src/tiles/base-tile-component.d.ts +0 -27
  263. package/dist/src/tiles/base-tile-component.js +0 -82
  264. package/dist/src/tiles/base-tile-component.js.map +0 -1
  265. package/dist/src/tiles/collection-browser-loading-tile.d.ts +0 -5
  266. package/dist/src/tiles/collection-browser-loading-tile.js +0 -29
  267. package/dist/src/tiles/collection-browser-loading-tile.js.map +0 -1
  268. package/dist/src/tiles/grid/account-tile.d.ts +0 -18
  269. package/dist/src/tiles/grid/account-tile.js +0 -111
  270. package/dist/src/tiles/grid/account-tile.js.map +0 -1
  271. package/dist/src/tiles/grid/collection-tile.d.ts +0 -15
  272. package/dist/src/tiles/grid/collection-tile.js +0 -160
  273. package/dist/src/tiles/grid/collection-tile.js.map +0 -1
  274. package/dist/src/tiles/grid/item-tile.d.ts +0 -41
  275. package/dist/src/tiles/grid/item-tile.js +0 -321
  276. package/dist/src/tiles/grid/item-tile.js.map +0 -1
  277. package/dist/src/tiles/grid/search-tile.d.ts +0 -10
  278. package/dist/src/tiles/grid/search-tile.js +0 -95
  279. package/dist/src/tiles/grid/search-tile.js.map +0 -1
  280. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +0 -1
  281. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +0 -128
  282. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +0 -1
  283. package/dist/src/tiles/grid/tile-stats.d.ts +0 -58
  284. package/dist/src/tiles/grid/tile-stats.js +0 -204
  285. package/dist/src/tiles/grid/tile-stats.js.map +0 -1
  286. package/dist/src/tiles/hover/hover-pane-controller.d.ts +0 -220
  287. package/dist/src/tiles/hover/hover-pane-controller.js +0 -378
  288. package/dist/src/tiles/hover/hover-pane-controller.js.map +0 -1
  289. package/dist/src/tiles/hover/tile-hover-pane.d.ts +0 -19
  290. package/dist/src/tiles/hover/tile-hover-pane.js +0 -182
  291. package/dist/src/tiles/hover/tile-hover-pane.js.map +0 -1
  292. package/dist/src/tiles/image-block.d.ts +0 -19
  293. package/dist/src/tiles/image-block.js +0 -175
  294. package/dist/src/tiles/image-block.js.map +0 -1
  295. package/dist/src/tiles/item-image.d.ts +0 -40
  296. package/dist/src/tiles/item-image.js +0 -191
  297. package/dist/src/tiles/item-image.js.map +0 -1
  298. package/dist/src/tiles/list/tile-list-compact-header.d.ts +0 -6
  299. package/dist/src/tiles/list/tile-list-compact-header.js +0 -85
  300. package/dist/src/tiles/list/tile-list-compact-header.js.map +0 -1
  301. package/dist/src/tiles/list/tile-list-compact.d.ts +0 -19
  302. package/dist/src/tiles/list/tile-list-compact.js +0 -223
  303. package/dist/src/tiles/list/tile-list-compact.js.map +0 -1
  304. package/dist/src/tiles/list/tile-list.d.ts +0 -54
  305. package/dist/src/tiles/list/tile-list.js +0 -621
  306. package/dist/src/tiles/list/tile-list.js.map +0 -1
  307. package/dist/src/tiles/models.d.ts +0 -1
  308. package/dist/src/tiles/models.js +0 -2
  309. package/dist/src/tiles/models.js.map +0 -1
  310. package/dist/src/tiles/overlay/icon-overlay.d.ts +0 -8
  311. package/dist/src/tiles/overlay/icon-overlay.js +0 -55
  312. package/dist/src/tiles/overlay/icon-overlay.js.map +0 -1
  313. package/dist/src/tiles/overlay/text-overlay.d.ts +0 -9
  314. package/dist/src/tiles/overlay/text-overlay.js +0 -74
  315. package/dist/src/tiles/overlay/text-overlay.js.map +0 -1
  316. package/dist/src/tiles/review-block.d.ts +0 -12
  317. package/dist/src/tiles/review-block.js +0 -134
  318. package/dist/src/tiles/review-block.js.map +0 -1
  319. package/dist/src/tiles/text-snippet-block.d.ts +0 -27
  320. package/dist/src/tiles/text-snippet-block.js +0 -132
  321. package/dist/src/tiles/text-snippet-block.js.map +0 -1
  322. package/dist/src/tiles/tile-dispatcher.d.ts +0 -68
  323. package/dist/src/tiles/tile-dispatcher.js +0 -445
  324. package/dist/src/tiles/tile-dispatcher.js.map +0 -1
  325. package/dist/src/tiles/tile-display-value-provider.d.ts +0 -47
  326. package/dist/src/tiles/tile-display-value-provider.js +0 -95
  327. package/dist/src/tiles/tile-display-value-provider.js.map +0 -1
  328. package/dist/src/tiles/tile-mediatype-icon.d.ts +0 -27
  329. package/dist/src/tiles/tile-mediatype-icon.js +0 -130
  330. package/dist/src/tiles/tile-mediatype-icon.js.map +0 -1
  331. package/dist/src/utils/analytics-events.d.ts +0 -28
  332. package/dist/src/utils/analytics-events.js +0 -31
  333. package/dist/src/utils/analytics-events.js.map +0 -1
  334. package/dist/src/utils/array-equals.d.ts +0 -4
  335. package/dist/src/utils/array-equals.js +0 -11
  336. package/dist/src/utils/array-equals.js.map +0 -1
  337. package/dist/src/utils/collapse-repeated-quotes.d.ts +0 -11
  338. package/dist/src/utils/collapse-repeated-quotes.js +0 -14
  339. package/dist/src/utils/collapse-repeated-quotes.js.map +0 -1
  340. package/dist/src/utils/facet-utils.d.ts +0 -83
  341. package/dist/src/utils/facet-utils.js +0 -152
  342. package/dist/src/utils/facet-utils.js.map +0 -1
  343. package/dist/src/utils/format-count.d.ts +0 -7
  344. package/dist/src/utils/format-count.js +0 -76
  345. package/dist/src/utils/format-count.js.map +0 -1
  346. package/dist/src/utils/format-date.d.ts +0 -16
  347. package/dist/src/utils/format-date.js +0 -33
  348. package/dist/src/utils/format-date.js.map +0 -1
  349. package/dist/src/utils/format-unit-size.d.ts +0 -2
  350. package/dist/src/utils/format-unit-size.js +0 -34
  351. package/dist/src/utils/format-unit-size.js.map +0 -1
  352. package/dist/src/utils/local-date-from-utc.d.ts +0 -9
  353. package/dist/src/utils/local-date-from-utc.js +0 -16
  354. package/dist/src/utils/local-date-from-utc.js.map +0 -1
  355. package/dist/src/utils/log.d.ts +0 -7
  356. package/dist/src/utils/log.js +0 -14
  357. package/dist/src/utils/log.js.map +0 -1
  358. package/dist/src/utils/resolve-mediatype.d.ts +0 -8
  359. package/dist/src/utils/resolve-mediatype.js +0 -24
  360. package/dist/src/utils/resolve-mediatype.js.map +0 -1
  361. package/dist/src/utils/sha1.d.ts +0 -2
  362. package/dist/src/utils/sha1.js +0 -9
  363. package/dist/src/utils/sha1.js.map +0 -1
  364. package/dist/test/collection-browser.test.d.ts +0 -1
  365. package/dist/test/collection-browser.test.js +0 -1711
  366. package/dist/test/collection-browser.test.js.map +0 -1
  367. package/dist/test/collection-facets/facet-row.test.d.ts +0 -1
  368. package/dist/test/collection-facets/facet-row.test.js +0 -274
  369. package/dist/test/collection-facets/facet-row.test.js.map +0 -1
  370. package/dist/test/collection-facets/facets-template.test.d.ts +0 -1
  371. package/dist/test/collection-facets/facets-template.test.js +0 -101
  372. package/dist/test/collection-facets/facets-template.test.js.map +0 -1
  373. package/dist/test/collection-facets/more-facets-content.test.d.ts +0 -1
  374. package/dist/test/collection-facets/more-facets-content.test.js +0 -169
  375. package/dist/test/collection-facets/more-facets-content.test.js.map +0 -1
  376. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +0 -1
  377. package/dist/test/collection-facets/more-facets-pagination.test.js +0 -132
  378. package/dist/test/collection-facets/more-facets-pagination.test.js.map +0 -1
  379. package/dist/test/collection-facets/toggle-switch.test.d.ts +0 -1
  380. package/dist/test/collection-facets/toggle-switch.test.js +0 -96
  381. package/dist/test/collection-facets/toggle-switch.test.js.map +0 -1
  382. package/dist/test/collection-facets.test.d.ts +0 -2
  383. package/dist/test/collection-facets.test.js +0 -745
  384. package/dist/test/collection-facets.test.js.map +0 -1
  385. package/dist/test/data-source/collection-browser-data-source.test.d.ts +0 -1
  386. package/dist/test/data-source/collection-browser-data-source.test.js +0 -102
  387. package/dist/test/data-source/collection-browser-data-source.test.js.map +0 -1
  388. package/dist/test/empty-placeholder.test.d.ts +0 -1
  389. package/dist/test/empty-placeholder.test.js +0 -63
  390. package/dist/test/empty-placeholder.test.js.map +0 -1
  391. package/dist/test/expanded-date-picker.test.d.ts +0 -1
  392. package/dist/test/expanded-date-picker.test.js +0 -130
  393. package/dist/test/expanded-date-picker.test.js.map +0 -1
  394. package/dist/test/icon-overlay.test.d.ts +0 -1
  395. package/dist/test/icon-overlay.test.js +0 -30
  396. package/dist/test/icon-overlay.test.js.map +0 -1
  397. package/dist/test/image-block.test.d.ts +0 -1
  398. package/dist/test/image-block.test.js +0 -218
  399. package/dist/test/image-block.test.js.map +0 -1
  400. package/dist/test/item-image.test.d.ts +0 -1
  401. package/dist/test/item-image.test.js +0 -196
  402. package/dist/test/item-image.test.js.map +0 -1
  403. package/dist/test/manage/manage-bar.test.d.ts +0 -2
  404. package/dist/test/manage/manage-bar.test.js +0 -106
  405. package/dist/test/manage/manage-bar.test.js.map +0 -1
  406. package/dist/test/manage/remove-items-modal-content.test.d.ts +0 -1
  407. package/dist/test/manage/remove-items-modal-content.test.js +0 -65
  408. package/dist/test/manage/remove-items-modal-content.test.js.map +0 -1
  409. package/dist/test/mediatype-config.test.d.ts +0 -1
  410. package/dist/test/mediatype-config.test.js +0 -11
  411. package/dist/test/mediatype-config.test.js.map +0 -1
  412. package/dist/test/mocks/mock-analytics-handler.d.ts +0 -10
  413. package/dist/test/mocks/mock-analytics-handler.js +0 -16
  414. package/dist/test/mocks/mock-analytics-handler.js.map +0 -1
  415. package/dist/test/mocks/mock-search-responses.d.ts +0 -31
  416. package/dist/test/mocks/mock-search-responses.js +0 -1241
  417. package/dist/test/mocks/mock-search-responses.js.map +0 -1
  418. package/dist/test/mocks/mock-search-service.d.ts +0 -16
  419. package/dist/test/mocks/mock-search-service.js +0 -65
  420. package/dist/test/mocks/mock-search-service.js.map +0 -1
  421. package/dist/test/restoration-state-handler.test.d.ts +0 -1
  422. package/dist/test/restoration-state-handler.test.js +0 -375
  423. package/dist/test/restoration-state-handler.test.js.map +0 -1
  424. package/dist/test/review-block.test.d.ts +0 -1
  425. package/dist/test/review-block.test.js +0 -48
  426. package/dist/test/review-block.test.js.map +0 -1
  427. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +0 -1
  428. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +0 -13
  429. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +0 -1
  430. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +0 -1
  431. package/dist/test/sort-filter-bar/alpha-bar.test.js +0 -74
  432. package/dist/test/sort-filter-bar/alpha-bar.test.js.map +0 -1
  433. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +0 -1
  434. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +0 -609
  435. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +0 -1
  436. package/dist/test/text-overlay.test.d.ts +0 -1
  437. package/dist/test/text-overlay.test.js +0 -42
  438. package/dist/test/text-overlay.test.js.map +0 -1
  439. package/dist/test/text-snippet-block.test.d.ts +0 -1
  440. package/dist/test/text-snippet-block.test.js +0 -63
  441. package/dist/test/text-snippet-block.test.js.map +0 -1
  442. package/dist/test/tile-stats.test.d.ts +0 -1
  443. package/dist/test/tile-stats.test.js +0 -128
  444. package/dist/test/tile-stats.test.js.map +0 -1
  445. package/dist/test/tiles/grid/account-tile.test.d.ts +0 -1
  446. package/dist/test/tiles/grid/account-tile.test.js +0 -96
  447. package/dist/test/tiles/grid/account-tile.test.js.map +0 -1
  448. package/dist/test/tiles/grid/collection-tile.test.d.ts +0 -1
  449. package/dist/test/tiles/grid/collection-tile.test.js +0 -96
  450. package/dist/test/tiles/grid/collection-tile.test.js.map +0 -1
  451. package/dist/test/tiles/grid/item-tile.test.d.ts +0 -1
  452. package/dist/test/tiles/grid/item-tile.test.js +0 -427
  453. package/dist/test/tiles/grid/item-tile.test.js.map +0 -1
  454. package/dist/test/tiles/grid/search-tile.test.d.ts +0 -1
  455. package/dist/test/tiles/grid/search-tile.test.js +0 -66
  456. package/dist/test/tiles/grid/search-tile.test.js.map +0 -1
  457. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +0 -1
  458. package/dist/test/tiles/hover/hover-pane-controller.test.js +0 -282
  459. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +0 -1
  460. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +0 -1
  461. package/dist/test/tiles/hover/tile-hover-pane.test.js +0 -57
  462. package/dist/test/tiles/hover/tile-hover-pane.test.js.map +0 -1
  463. package/dist/test/tiles/list/tile-list-compact.test.d.ts +0 -1
  464. package/dist/test/tiles/list/tile-list-compact.test.js +0 -251
  465. package/dist/test/tiles/list/tile-list-compact.test.js.map +0 -1
  466. package/dist/test/tiles/list/tile-list.test.d.ts +0 -1
  467. package/dist/test/tiles/list/tile-list.test.js +0 -469
  468. package/dist/test/tiles/list/tile-list.test.js.map +0 -1
  469. package/dist/test/tiles/tile-dispatcher.test.d.ts +0 -1
  470. package/dist/test/tiles/tile-dispatcher.test.js +0 -153
  471. package/dist/test/tiles/tile-dispatcher.test.js.map +0 -1
  472. package/dist/test/tiles/tile-display-value-provider.test.d.ts +0 -1
  473. package/dist/test/tiles/tile-display-value-provider.test.js +0 -142
  474. package/dist/test/tiles/tile-display-value-provider.test.js.map +0 -1
  475. package/dist/test/tiles/tile-mediatype-icon.test.d.ts +0 -1
  476. package/dist/test/tiles/tile-mediatype-icon.test.js +0 -145
  477. package/dist/test/tiles/tile-mediatype-icon.test.js.map +0 -1
  478. package/dist/test/utils/array-equals.test.d.ts +0 -1
  479. package/dist/test/utils/array-equals.test.js +0 -27
  480. package/dist/test/utils/array-equals.test.js.map +0 -1
  481. package/dist/test/utils/format-count.test.d.ts +0 -1
  482. package/dist/test/utils/format-count.test.js +0 -24
  483. package/dist/test/utils/format-count.test.js.map +0 -1
  484. package/dist/test/utils/format-date.test.d.ts +0 -1
  485. package/dist/test/utils/format-date.test.js +0 -61
  486. package/dist/test/utils/format-date.test.js.map +0 -1
  487. package/dist/test/utils/format-unit-size.test.d.ts +0 -1
  488. package/dist/test/utils/format-unit-size.test.js +0 -18
  489. package/dist/test/utils/format-unit-size.test.js.map +0 -1
  490. package/dist/test/utils/local-date-from-utc.test.d.ts +0 -1
  491. package/dist/test/utils/local-date-from-utc.test.js +0 -27
  492. package/dist/test/utils/local-date-from-utc.test.js.map +0 -1
@@ -1,1103 +0,0 @@
1
- import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
2
- import { prefixFilterAggregationKeys, TileModel, SortField, SORT_OPTIONS, } from '../models';
3
- import { FACETLESS_PAGE_ELEMENTS } from './models';
4
- import { sha1 } from '../utils/sha1';
5
- import { log } from '../utils/log';
6
- import { mergeSelectedFacets } from '../utils/facet-utils';
7
- export class CollectionBrowserDataSource {
8
- /**
9
- * @inheritdoc
10
- */
11
- get initialSearchComplete() {
12
- return this._initialSearchCompletePromise;
13
- }
14
- constructor(
15
- /** The host element to which this controller should attach listeners */
16
- host,
17
- /** Default size of result pages */
18
- pageSize = 50) {
19
- this.host = host;
20
- this.pageSize = pageSize;
21
- /**
22
- * All pages of tile models that have been fetched so far, indexed by their page
23
- * number (with the first being page 1).
24
- */
25
- this.pages = {};
26
- /**
27
- * Tile offset to apply when looking up tiles in the pages, in order to maintain
28
- * page alignment after tiles are removed.
29
- */
30
- this.offset = 0;
31
- /**
32
- * Total number of tile models stored in this data source's pages
33
- */
34
- this.numTileModels = 0;
35
- /**
36
- * How many consecutive pages should be batched together on the initial page fetch.
37
- * Defaults to 2 pages.
38
- */
39
- this.numInitialPages = 2;
40
- /**
41
- * A set of fetch IDs that are valid for the current query state
42
- */
43
- this.fetchesInProgress = new Set();
44
- /**
45
- * A record of the query key used for the last search.
46
- * If this changes, we need to load new results.
47
- */
48
- this.previousQueryKey = '';
49
- /**
50
- * Whether the initial page of search results for the current query state
51
- * is presently being fetched.
52
- */
53
- this.searchResultsLoading = false;
54
- /**
55
- * Whether the facets (aggregations) for the current query state are
56
- * presently being fetched.
57
- */
58
- this.facetsLoading = false;
59
- /**
60
- * Whether the facets are actually visible -- if not, then we can delay any facet
61
- * fetches until they become visible.
62
- */
63
- this.facetsReadyToLoad = false;
64
- /**
65
- * Whether further query changes should be ignored and not trigger fetches
66
- */
67
- this.suppressFetches = false;
68
- /**
69
- * @inheritdoc
70
- */
71
- this.totalResults = 0;
72
- /**
73
- * @inheritdoc
74
- */
75
- this.endOfDataReached = false;
76
- /**
77
- * @inheritdoc
78
- */
79
- this.queryInitialized = false;
80
- /**
81
- * @inheritdoc
82
- */
83
- this.collectionTitles = new Map();
84
- /**
85
- * @inheritdoc
86
- */
87
- this.tvChannelAliases = new Map();
88
- /**
89
- * @inheritdoc
90
- */
91
- this.parentCollections = [];
92
- /**
93
- * @inheritdoc
94
- */
95
- this.prefixFilterCountMap = {};
96
- /**
97
- * Internal property to store the private value backing the `initialSearchComplete` getter.
98
- */
99
- this._initialSearchCompletePromise = Promise.resolve(true);
100
- /**
101
- * @inheritdoc
102
- */
103
- this.checkAllTiles = () => {
104
- this.map(model => {
105
- const cloned = model.clone();
106
- cloned.checked = true;
107
- return cloned;
108
- });
109
- };
110
- /**
111
- * @inheritdoc
112
- */
113
- this.uncheckAllTiles = () => {
114
- this.map(model => {
115
- const cloned = model.clone();
116
- cloned.checked = false;
117
- return cloned;
118
- });
119
- };
120
- /**
121
- * @inheritdoc
122
- */
123
- this.removeCheckedTiles = () => {
124
- // To make sure our data source remains page-aligned, we will offset our data source by
125
- // the number of removed tiles, so that we can just add the offset when the infinite
126
- // scroller queries for cell contents.
127
- // This only matters while we're still viewing the same set of results. If the user changes
128
- // their query/filters/sort, then the data source is overwritten and the offset cleared.
129
- const { checkedTileModels, uncheckedTileModels } = this;
130
- const numChecked = checkedTileModels.length;
131
- if (numChecked === 0)
132
- return;
133
- this.offset += numChecked;
134
- const newPages = {};
135
- // Which page the remaining tile models start on, post-offset
136
- let offsetPageNumber = Math.floor(this.offset / this.pageSize) + 1;
137
- let indexOnPage = this.offset % this.pageSize;
138
- // Fill the pages up to that point with empty models
139
- for (let page = 1; page <= offsetPageNumber; page += 1) {
140
- const remainingHidden = this.offset - this.pageSize * (page - 1);
141
- const offsetCellsOnPage = Math.min(this.pageSize, remainingHidden);
142
- newPages[page] = Array(offsetCellsOnPage).fill(undefined);
143
- }
144
- // Shift all the remaining tiles into their new positions in the data source
145
- for (const model of uncheckedTileModels) {
146
- if (!newPages[offsetPageNumber])
147
- newPages[offsetPageNumber] = [];
148
- newPages[offsetPageNumber].push(model);
149
- indexOnPage += 1;
150
- if (indexOnPage >= this.pageSize) {
151
- offsetPageNumber += 1;
152
- indexOnPage = 0;
153
- }
154
- }
155
- // Swap in the new pages
156
- this.pages = newPages;
157
- this.numTileModels -= numChecked;
158
- this.totalResults -= numChecked;
159
- this.host.setTileCount(this.size);
160
- this.host.setTotalResultCount(this.totalResults);
161
- this.requestHostUpdate();
162
- this.refreshVisibleResults();
163
- };
164
- // Just setting some property values
165
- }
166
- hostConnected() {
167
- this.setSearchResultsLoading(this.searchResultsLoading);
168
- this.setFacetsLoading(this.facetsLoading);
169
- }
170
- hostUpdate() {
171
- // This reactive controller hook is run whenever the host component (collection-browser) performs an update.
172
- // We check whether the host's state has changed in a way which should trigger a reset & new results fetch.
173
- // Only the currently-installed data source should react to the update
174
- if (!this.activeOnHost)
175
- return;
176
- // Copy loading states onto the host
177
- this.setSearchResultsLoading(this.searchResultsLoading);
178
- this.setFacetsLoading(this.facetsLoading);
179
- // Can't perform searches without a search service
180
- if (!this.host.searchService)
181
- return;
182
- // We should only reset if part of the full query state has changed
183
- const queryKeyChanged = this.pageFetchQueryKey !== this.previousQueryKey;
184
- if (!queryKeyChanged)
185
- return;
186
- // We should only reset if either:
187
- // (a) our state permits a valid search, or
188
- // (b) we have a blank query that we're showing a placeholder/message for
189
- const queryIsEmpty = !this.host.baseQuery;
190
- if (!(this.canPerformSearch || queryIsEmpty))
191
- return;
192
- if (this.activeOnHost)
193
- this.host.emitQueryStateChanged();
194
- this.handleQueryChange();
195
- }
196
- /**
197
- * Returns whether this data source is the one currently installed on the host component.
198
- */
199
- get activeOnHost() {
200
- return this.host.dataSource === this;
201
- }
202
- /**
203
- * @inheritdoc
204
- */
205
- get size() {
206
- return this.numTileModels;
207
- }
208
- /**
209
- * @inheritdoc
210
- */
211
- reset() {
212
- log('Resetting CB data source');
213
- this.pages = {};
214
- this.aggregations = {};
215
- this.histogramAggregation = undefined;
216
- this.pageElements = undefined;
217
- this.parentCollections = [];
218
- this.previousQueryKey = '';
219
- this.queryErrorMessage = undefined;
220
- this.offset = 0;
221
- this.numTileModels = 0;
222
- this.endOfDataReached = false;
223
- this.queryInitialized = false;
224
- this.facetsLoading = false;
225
- // Invalidate any fetches in progress
226
- this.fetchesInProgress.clear();
227
- this.setTotalResultCount(0);
228
- this.requestHostUpdate();
229
- }
230
- /**
231
- * @inheritdoc
232
- */
233
- resetPages() {
234
- if (Object.keys(this.pages).length < this.host.maxPagesToManage) {
235
- this.pages = {};
236
- // Invalidate any page fetches in progress (keep facet fetches)
237
- this.fetchesInProgress.forEach(key => {
238
- if (!key.startsWith('facets-'))
239
- this.fetchesInProgress.delete(key);
240
- });
241
- this.requestHostUpdate();
242
- }
243
- }
244
- /**
245
- * @inheritdoc
246
- */
247
- addPage(pageNum, pageTiles) {
248
- this.pages[pageNum] = pageTiles;
249
- this.numTileModels += pageTiles.length;
250
- this.requestHostUpdate();
251
- }
252
- /**
253
- * @inheritdoc
254
- */
255
- addMultiplePages(firstPageNum, tiles) {
256
- const numPages = Math.ceil(tiles.length / this.pageSize);
257
- for (let i = 0; i < numPages; i += 1) {
258
- const pageStartIndex = this.pageSize * i;
259
- this.addPage(firstPageNum + i, tiles.slice(pageStartIndex, pageStartIndex + this.pageSize));
260
- }
261
- const visiblePages = this.host.currentVisiblePageNumbers;
262
- const needsReload = visiblePages.some(page => page >= firstPageNum && page <= firstPageNum + numPages);
263
- if (needsReload) {
264
- this.refreshVisibleResults();
265
- }
266
- }
267
- /**
268
- * @inheritdoc
269
- */
270
- getPage(pageNum) {
271
- return this.pages[pageNum];
272
- }
273
- /**
274
- * @inheritdoc
275
- */
276
- getAllPages() {
277
- return this.pages;
278
- }
279
- /**
280
- * @inheritdoc
281
- */
282
- hasPage(pageNum) {
283
- return !!this.pages[pageNum];
284
- }
285
- /**
286
- * @inheritdoc
287
- */
288
- getTileModelAt(index) {
289
- var _a, _b;
290
- const offsetIndex = index + this.offset;
291
- const expectedPageNum = Math.floor(offsetIndex / this.pageSize) + 1;
292
- const expectedIndexOnPage = offsetIndex % this.pageSize;
293
- let page = 1;
294
- let tilesSeen = 0;
295
- while (tilesSeen <= offsetIndex) {
296
- if (!this.pages[page]) {
297
- // If we encounter a missing page, either we're past all the results or the page data is sparse.
298
- // So just return the tile at the expected position if it exists.
299
- return (_a = this.pages[expectedPageNum]) === null || _a === void 0 ? void 0 : _a[expectedIndexOnPage];
300
- }
301
- if (tilesSeen + this.pages[page].length > offsetIndex) {
302
- return this.pages[page][offsetIndex - tilesSeen];
303
- }
304
- tilesSeen += this.pages[page].length;
305
- page += 1;
306
- }
307
- return (_b = this.pages[expectedPageNum]) === null || _b === void 0 ? void 0 : _b[expectedIndexOnPage];
308
- }
309
- /**
310
- * @inheritdoc
311
- */
312
- indexOf(tile) {
313
- return Object.values(this.pages).flat().indexOf(tile) - this.offset;
314
- }
315
- /**
316
- * @inheritdoc
317
- */
318
- getPageSize() {
319
- return this.pageSize;
320
- }
321
- /**
322
- * @inheritdoc
323
- */
324
- setPageSize(pageSize) {
325
- this.reset();
326
- this.pageSize = pageSize;
327
- }
328
- /**
329
- * @inheritdoc
330
- */
331
- setNumInitialPages(numPages) {
332
- this.numInitialPages = numPages;
333
- }
334
- /**
335
- * @inheritdoc
336
- */
337
- setTotalResultCount(count) {
338
- this.totalResults = count;
339
- if (this.activeOnHost) {
340
- this.host.setTotalResultCount(count);
341
- }
342
- }
343
- /**
344
- * @inheritdoc
345
- */
346
- setFetchesSuppressed(suppressed) {
347
- this.suppressFetches = suppressed;
348
- }
349
- /**
350
- * @inheritdoc
351
- */
352
- setEndOfDataReached(reached) {
353
- this.endOfDataReached = reached;
354
- }
355
- /**
356
- * @inheritdoc
357
- */
358
- async handleQueryChange() {
359
- // Don't react to the change if fetches are suppressed for this data source
360
- if (this.suppressFetches)
361
- return;
362
- this.reset();
363
- // Reset the `initialSearchComplete` promise with a new value for the imminent search
364
- let initialSearchCompleteResolver;
365
- this._initialSearchCompletePromise = new Promise(res => {
366
- initialSearchCompleteResolver = res;
367
- });
368
- // Fire the initial page & facet requests
369
- this.queryInitialized = true;
370
- await Promise.all([
371
- this.doInitialPageFetch(),
372
- this.canFetchFacets ? this.fetchFacets() : null,
373
- ]);
374
- // Resolve the `initialSearchComplete` promise for this search
375
- initialSearchCompleteResolver(true);
376
- }
377
- /**
378
- * @inheritdoc
379
- */
380
- async handleFacetReadinessChange(ready) {
381
- const facetsBecameReady = !this.facetsReadyToLoad && ready;
382
- this.facetsReadyToLoad = ready;
383
- const needsFetch = facetsBecameReady && this.canFetchFacets;
384
- if (needsFetch) {
385
- this.fetchFacets();
386
- }
387
- }
388
- /**
389
- * Whether the data source & its host are in a state where a facet request should be fired.
390
- * (i.e., they aren't suppressed or already loading, etc.)
391
- */
392
- get canFetchFacets() {
393
- var _a;
394
- // Don't fetch facets if they are suppressed entirely or not required for the current profile page element
395
- if (this.host.facetLoadStrategy === 'off')
396
- return false;
397
- if (FACETLESS_PAGE_ELEMENTS.includes(this.host.profileElement))
398
- return false;
399
- // If facets are to be lazy-loaded, don't fetch them if they are not going to be visible anyway
400
- // (wait until they become visible instead)
401
- if (this.host.facetLoadStrategy !== 'eager' && !this.facetsReadyToLoad)
402
- return false;
403
- // Don't fetch facets again if they are already fetched or pending
404
- const facetsAlreadyFetched = Object.keys((_a = this.aggregations) !== null && _a !== void 0 ? _a : {}).length > 0;
405
- if (this.facetsLoading || facetsAlreadyFetched)
406
- return false;
407
- return true;
408
- }
409
- /**
410
- * @inheritdoc
411
- */
412
- map(callback) {
413
- if (!Object.keys(this.pages).length)
414
- return;
415
- this.pages = Object.fromEntries(Object.entries(this.pages).map(([page, tileModels]) => [
416
- page,
417
- tileModels.map((model, index, array) => model ? callback(model, index, array) : model),
418
- ]));
419
- this.requestHostUpdate();
420
- this.refreshVisibleResults();
421
- }
422
- /**
423
- * @inheritdoc
424
- */
425
- get checkedTileModels() {
426
- return this.getFilteredTileModels(model => model.checked);
427
- }
428
- /**
429
- * @inheritdoc
430
- */
431
- get uncheckedTileModels() {
432
- return this.getFilteredTileModels(model => !model.checked);
433
- }
434
- /**
435
- * Returns a flattened, filtered array of all the tile models in the data source
436
- * for which the given predicate returns a truthy value.
437
- *
438
- * @param predicate A callback function to apply on each tile model, as with Array.filter
439
- * @returns A filtered array of tile models satisfying the predicate
440
- */
441
- getFilteredTileModels(predicate) {
442
- return Object.values(this.pages)
443
- .flat()
444
- .filter((model, index, array) => model ? predicate(model, index, array) : false);
445
- }
446
- /**
447
- * @inheritdoc
448
- */
449
- get canPerformSearch() {
450
- var _a, _b;
451
- if (!this.host.searchService)
452
- return false;
453
- const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
454
- const hasNonEmptyQuery = !!trimmedQuery;
455
- const hasIdentifiers = !!((_b = this.host.identifiers) === null || _b === void 0 ? void 0 : _b.length);
456
- const isCollectionSearch = !!this.host.withinCollection;
457
- const isProfileSearch = !!this.host.withinProfile;
458
- const hasProfileElement = !!this.host.profileElement;
459
- const isDefaultedSearch = this.host.searchType === SearchType.DEFAULT;
460
- const isMetadataSearch = this.host.searchType === SearchType.METADATA;
461
- const isTvSearch = this.host.searchType === SearchType.TV;
462
- // Metadata/tv searches within a collection are allowed to have no query.
463
- const isValidForCollectionSearch = isDefaultedSearch || isMetadataSearch || isTvSearch;
464
- // Searches within a profile page may also be performed without a query, provided the profile element is set.
465
- const isValidForProfileSearch = hasProfileElement && (isDefaultedSearch || isMetadataSearch);
466
- // Otherwise, a non-empty query must be set.
467
- return (hasNonEmptyQuery ||
468
- hasIdentifiers ||
469
- (isCollectionSearch && isValidForCollectionSearch) ||
470
- (isProfileSearch && isValidForProfileSearch));
471
- }
472
- /**
473
- * Sets the state for whether the initial set of search results for the
474
- * current query is loading
475
- */
476
- setSearchResultsLoading(loading) {
477
- this.searchResultsLoading = loading;
478
- if (this.activeOnHost) {
479
- this.host.setSearchResultsLoading(loading);
480
- }
481
- }
482
- /**
483
- * Sets the state for whether the facets for a query is loading
484
- */
485
- setFacetsLoading(loading) {
486
- this.facetsLoading = loading;
487
- if (this.activeOnHost) {
488
- this.host.setFacetsLoading(loading);
489
- }
490
- }
491
- /**
492
- * Requests that the host perform an update, provided this data
493
- * source is actively installed on it.
494
- */
495
- requestHostUpdate() {
496
- if (this.activeOnHost) {
497
- this.host.requestUpdate();
498
- }
499
- }
500
- /**
501
- * Requests that the host refresh its visible tiles, provided this
502
- * data source is actively installed on it.
503
- */
504
- refreshVisibleResults() {
505
- if (this.activeOnHost) {
506
- this.host.refreshVisibleResults();
507
- }
508
- }
509
- /**
510
- * The query key is a string that uniquely identifies the current search.
511
- * It consists of:
512
- * - The current base query
513
- * - The current collection/profile target & page element
514
- * - The current search type
515
- * - Any currently-applied facets
516
- * - Any currently-applied date range
517
- * - Any currently-applied prefix filters
518
- * - The current sort options
519
- *
520
- * This lets us internally keep track of queries so we don't persist data that's
521
- * no longer relevant. Not meant to be human-readable.
522
- */
523
- get pageFetchQueryKey() {
524
- var _a, _b, _c;
525
- const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
526
- const pageTarget = (_a = this.host.withinCollection) !== null && _a !== void 0 ? _a : profileKey;
527
- const sortField = (_b = this.host.selectedSort) !== null && _b !== void 0 ? _b : 'none';
528
- const sortDirection = (_c = this.host.sortDirection) !== null && _c !== void 0 ? _c : 'none';
529
- return `fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}-sf:${sortField}-sd:${sortDirection}`;
530
- }
531
- /**
532
- * Similar to `pageFetchQueryKey` above, but excludes sort fields since they
533
- * are not relevant in determining aggregation queries.
534
- */
535
- get facetFetchQueryKey() {
536
- var _a;
537
- const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
538
- const pageTarget = (_a = this.host.withinCollection) !== null && _a !== void 0 ? _a : profileKey;
539
- return `facets-fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}`;
540
- }
541
- /**
542
- * Constructs a search service FilterMap object from the combination of
543
- * all the currently-applied filters. This includes any facets, letter
544
- * filters, and date range.
545
- */
546
- get filterMap() {
547
- const builder = new FilterMapBuilder();
548
- const { minSelectedDate, maxSelectedDate, selectedFacets, internalFilters, selectedTitleFilter, selectedCreatorFilter, } = this.host;
549
- const dateField = this.host.searchType === SearchType.TV ? 'date' : 'year';
550
- if (minSelectedDate) {
551
- builder.addFilter(dateField, minSelectedDate, FilterConstraint.GREATER_OR_EQUAL);
552
- }
553
- if (maxSelectedDate) {
554
- builder.addFilter(dateField, maxSelectedDate, FilterConstraint.LESS_OR_EQUAL);
555
- }
556
- // Add any selected facets and internal filters
557
- const combinedFilters = mergeSelectedFacets(internalFilters, selectedFacets);
558
- if (combinedFilters) {
559
- for (const [facetName, facetValues] of Object.entries(combinedFilters)) {
560
- const { name, values } = this.prepareFacetForFetch(facetName, facetValues);
561
- for (const [value, bucket] of Object.entries(values)) {
562
- let constraint;
563
- if (bucket.state === 'selected') {
564
- constraint = FilterConstraint.INCLUDE;
565
- }
566
- else if (bucket.state === 'hidden') {
567
- constraint = FilterConstraint.EXCLUDE;
568
- }
569
- if (constraint) {
570
- builder.addFilter(name, value, constraint);
571
- }
572
- }
573
- }
574
- }
575
- // Add any letter filters
576
- if (selectedTitleFilter) {
577
- builder.addFilter('firstTitle', selectedTitleFilter, FilterConstraint.INCLUDE);
578
- }
579
- if (selectedCreatorFilter) {
580
- builder.addFilter('firstCreator', selectedCreatorFilter, FilterConstraint.INCLUDE);
581
- }
582
- // Add any TV clip type filter, if applicable
583
- if (this.host.searchType === SearchType.TV) {
584
- switch (this.host.tvClipFilter) {
585
- case 'commercials':
586
- builder.addFilter('ad_id', '*', FilterConstraint.INCLUDE);
587
- break;
588
- case 'factchecks':
589
- builder.addFilter('factcheck', '*', FilterConstraint.INCLUDE);
590
- break;
591
- case 'quotes':
592
- builder.addFilter('clip', '1', FilterConstraint.INCLUDE);
593
- break;
594
- case 'all':
595
- default:
596
- break;
597
- }
598
- }
599
- const filterMap = builder.build();
600
- return filterMap;
601
- }
602
- /**
603
- * Produces a compact unique ID for a search request that can help with debugging
604
- * on the backend by making related requests easier to trace through different services.
605
- * (e.g., tying the hits/aggregations requests for the same page back to a single hash).
606
- *
607
- * @param params The search service parameters for the request
608
- * @param kind The kind of request (hits-only, aggregations-only, or both)
609
- * @returns A Promise resolving to the uid to apply to the request
610
- */
611
- async requestUID(params, kind) {
612
- var _a;
613
- const paramsToHash = JSON.stringify({
614
- pageType: params.pageType,
615
- pageTarget: params.pageTarget,
616
- query: params.query,
617
- fields: params.fields,
618
- filters: params.filters,
619
- sort: params.sort,
620
- searchType: this.host.searchType,
621
- });
622
- const fullQueryHash = (await sha1(paramsToHash)).slice(0, 20); // First 80 bits of SHA-1 are plenty for this
623
- const sessionId = (await this.host.getSessionId()).slice(0, 20); // Likewise
624
- const page = (_a = params.page) !== null && _a !== void 0 ? _a : 0;
625
- const kindPrefix = kind.charAt(0); // f = full, h = hits, a = aggregations
626
- const currentTime = Date.now();
627
- return `R:${fullQueryHash}-S:${sessionId}-P:${page}-K:${kindPrefix}-T:${currentTime}`;
628
- }
629
- /**
630
- * @inheritdoc
631
- */
632
- get pageSpecifierParams() {
633
- var _a;
634
- if ((_a = this.host.identifiers) === null || _a === void 0 ? void 0 : _a.length) {
635
- return {
636
- pageType: 'client_document_fetch',
637
- };
638
- }
639
- if (this.host.withinCollection) {
640
- return {
641
- pageType: 'collection_details',
642
- pageTarget: this.host.withinCollection,
643
- };
644
- }
645
- if (this.host.withinProfile) {
646
- return {
647
- pageType: 'account_details',
648
- pageTarget: this.host.withinProfile,
649
- pageElements: this.host.profileElement
650
- ? [this.host.profileElement]
651
- : [],
652
- };
653
- }
654
- return null;
655
- }
656
- /**
657
- * The full query, including year facets and date range clauses
658
- */
659
- get fullQuery() {
660
- var _a;
661
- const parts = [];
662
- const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
663
- if (trimmedQuery)
664
- parts.push(trimmedQuery);
665
- if (this.host.identifiers) {
666
- parts.push(`identifier:(${this.host.identifiers.join(' OR ')})`);
667
- }
668
- const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
669
- if (facetQuery)
670
- parts.push(facetQuery);
671
- if (dateRangeQueryClause)
672
- parts.push(dateRangeQueryClause);
673
- if (sortFilterQueries)
674
- parts.push(sortFilterQueries);
675
- return parts.join(' AND ').trim();
676
- }
677
- /**
678
- * Generates a query string representing the current set of applied facets
679
- *
680
- * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
681
- */
682
- get facetQuery() {
683
- var _a;
684
- if (!this.host.selectedFacets)
685
- return undefined;
686
- const facetClauses = [];
687
- for (const [facetName, facetValues] of Object.entries(this.host.selectedFacets)) {
688
- facetClauses.push(this.buildFacetClause(facetName, facetValues));
689
- }
690
- return (_a = this.joinFacetClauses(facetClauses)) === null || _a === void 0 ? void 0 : _a.trim();
691
- }
692
- get dateRangeQueryClause() {
693
- if (!this.host.minSelectedDate || !this.host.maxSelectedDate) {
694
- return undefined;
695
- }
696
- return `year:[${this.host.minSelectedDate} TO ${this.host.maxSelectedDate}]`;
697
- }
698
- get sortFilterQueries() {
699
- const queries = [this.titleQuery, this.creatorQuery];
700
- return queries.filter(q => q).join(' AND ');
701
- }
702
- /**
703
- * Returns a query clause identifying the currently selected title filter,
704
- * e.g., `firstTitle:X`.
705
- */
706
- get titleQuery() {
707
- return this.host.selectedTitleFilter
708
- ? `firstTitle:${this.host.selectedTitleFilter}`
709
- : undefined;
710
- }
711
- /**
712
- * Returns a query clause identifying the currently selected creator filter,
713
- * e.g., `firstCreator:X`.
714
- */
715
- get creatorQuery() {
716
- return this.host.selectedCreatorFilter
717
- ? `firstCreator:${this.host.selectedCreatorFilter}`
718
- : undefined;
719
- }
720
- /**
721
- * Builds an OR-joined facet clause for the given facet name and values.
722
- *
723
- * E.g., for name `subject` and values
724
- * `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
725
- * this will produce the clause
726
- * `subject:("foo" OR -"bar")`.
727
- *
728
- * @param facetName The facet type (e.g., 'collection')
729
- * @param facetValues The facet buckets, mapped by their keys
730
- */
731
- buildFacetClause(facetName, facetValues) {
732
- const { name: facetQueryName, values } = this.prepareFacetForFetch(facetName, facetValues);
733
- const facetEntries = Object.entries(values);
734
- if (facetEntries.length === 0)
735
- return '';
736
- const facetValuesArray = [];
737
- for (const [key, facetData] of facetEntries) {
738
- const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
739
- facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
740
- }
741
- const valueQuery = facetValuesArray.join(` OR `);
742
- return `${facetQueryName}:(${valueQuery})`;
743
- }
744
- /**
745
- * Handles some special pre-request normalization steps for certain facet types
746
- * that require them.
747
- *
748
- * @param facetName The name of the facet type (e.g., 'language')
749
- * @param facetValues An array of values for that facet type
750
- */
751
- prepareFacetForFetch(facetName, facetValues) {
752
- // eslint-disable-next-line prefer-const
753
- let [normalizedName, normalizedValues] = [facetName, facetValues];
754
- // The full "search engine" name of the lending field is "lending___status"
755
- if (facetName === 'lending') {
756
- normalizedName = 'lending___status';
757
- }
758
- return {
759
- name: normalizedName,
760
- values: normalizedValues,
761
- };
762
- }
763
- /**
764
- * Takes an array of facet clauses, and combines them into a
765
- * full AND-joined facet query string. Empty clauses are ignored.
766
- */
767
- joinFacetClauses(facetClauses) {
768
- const nonEmptyFacetClauses = facetClauses.filter(clause => clause.length > 0);
769
- return nonEmptyFacetClauses.length > 0
770
- ? `(${nonEmptyFacetClauses.join(' AND ')})`
771
- : undefined;
772
- }
773
- /**
774
- * Fires a backend request to fetch a set of aggregations (representing UI facets) for
775
- * the current search state.
776
- */
777
- async fetchFacets() {
778
- var _a, _b, _c, _d, _e, _f, _g;
779
- const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
780
- if (!this.canPerformSearch)
781
- return;
782
- const { facetFetchQueryKey } = this;
783
- if (this.fetchesInProgress.has(facetFetchQueryKey))
784
- return;
785
- this.fetchesInProgress.add(facetFetchQueryKey);
786
- this.setFacetsLoading(true);
787
- const sortParams = this.host.sortParam ? [this.host.sortParam] : [];
788
- const params = {
789
- ...this.pageSpecifierParams,
790
- query: trimmedQuery || '',
791
- identifiers: this.host.identifiers,
792
- rows: 0,
793
- filters: this.filterMap,
794
- // Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
795
- aggregationsSize: 10,
796
- // Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
797
- // The default aggregations for the search_results page type should be what we need here.
798
- };
799
- params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
800
- const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
801
- const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
802
- // This is checking to see if the query has changed since the data was fetched.
803
- // If so, we just want to discard this set of aggregations because they are
804
- // likely no longer valid for the newer query.
805
- const queryChangedSinceFetch = !this.fetchesInProgress.has(facetFetchQueryKey);
806
- this.fetchesInProgress.delete(facetFetchQueryKey);
807
- if (queryChangedSinceFetch)
808
- return;
809
- if (!success) {
810
- const errorMsg = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _c === void 0 ? void 0 : _c.message;
811
- const detailMsg = (_e = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.details) === null || _e === void 0 ? void 0 : _e.message;
812
- if (!errorMsg && !detailMsg) {
813
- // @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
814
- (_g = (_f = window === null || window === void 0 ? void 0 : window.Sentry) === null || _f === void 0 ? void 0 : _f.captureMessage) === null || _g === void 0 ? void 0 : _g.call(_f, 'Missing or malformed facet response from backend', 'error');
815
- }
816
- this.setFacetsLoading(false);
817
- return;
818
- }
819
- const { aggregations, collectionTitles, tvChannelAliases } = success.response;
820
- this.aggregations = aggregations;
821
- this.histogramAggregation =
822
- this.host.searchType === SearchType.TV
823
- ? aggregations === null || aggregations === void 0 ? void 0 : aggregations.date_histogram
824
- : aggregations === null || aggregations === void 0 ? void 0 : aggregations.year_histogram;
825
- if (collectionTitles) {
826
- for (const [id, title] of Object.entries(collectionTitles)) {
827
- this.collectionTitles.set(id, title);
828
- }
829
- }
830
- if (tvChannelAliases) {
831
- for (const [channel, network] of Object.entries(tvChannelAliases)) {
832
- this.tvChannelAliases.set(channel, network);
833
- }
834
- }
835
- this.setFacetsLoading(false);
836
- this.requestHostUpdate();
837
- }
838
- /**
839
- * Performs the initial page fetch(es) for the current search state.
840
- */
841
- async doInitialPageFetch() {
842
- this.setSearchResultsLoading(true);
843
- // Try to batch 2 initial page requests when possible
844
- await this.fetchPage(this.host.initialPageNumber, this.numInitialPages);
845
- }
846
- /**
847
- * Fetches one or more pages of results and updates the data source.
848
- *
849
- * @param pageNumber The page number to fetch
850
- * @param numInitialPages If this is an initial page fetch (`pageNumber = 1`),
851
- * specifies how many pages to batch together in one request. Ignored
852
- * if `pageNumber != 1`, defaulting to a single page.
853
- */
854
- async fetchPage(pageNumber, numInitialPages = 1) {
855
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
856
- const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
857
- // reset loading status
858
- if (!this.canPerformSearch) {
859
- this.setSearchResultsLoading(false);
860
- return;
861
- }
862
- // if we already have data, don't fetch again
863
- if (this.hasPage(pageNumber))
864
- return;
865
- if (this.endOfDataReached)
866
- return;
867
- // Batch multiple initial page requests together if needed (e.g., can request
868
- // pages 1 and 2 together in a single request).
869
- let numPages = pageNumber === 1 ? numInitialPages : 1;
870
- const numRows = this.pageSize * numPages;
871
- // if a fetch is already in progress for this query and page, don't fetch again
872
- const { pageFetchQueryKey } = this;
873
- const currentPageKey = `${pageFetchQueryKey}-p:${pageNumber}`;
874
- if (this.fetchesInProgress.has(currentPageKey))
875
- return;
876
- for (let i = 0; i < numPages; i += 1) {
877
- this.fetchesInProgress.add(`${pageFetchQueryKey}-p:${pageNumber + i}`);
878
- }
879
- this.previousQueryKey = pageFetchQueryKey;
880
- const { withinCollection, withinProfile } = this.host;
881
- let sortParams = this.host.sortParam ? [this.host.sortParam] : [];
882
- // TODO eventually the PPS should handle these defaults natively
883
- const isDefaultProfileSort = withinProfile && this.host.selectedSort === SortField.default;
884
- if (isDefaultProfileSort && this.host.defaultSortField) {
885
- const sortOption = SORT_OPTIONS[this.host.defaultSortField];
886
- if (sortOption.searchServiceKey) {
887
- sortParams = [
888
- {
889
- field: sortOption.searchServiceKey,
890
- direction: 'desc',
891
- },
892
- ];
893
- }
894
- }
895
- const params = {
896
- ...this.pageSpecifierParams,
897
- query: trimmedQuery || '',
898
- identifiers: this.host.identifiers,
899
- page: pageNumber,
900
- rows: numRows,
901
- sort: sortParams,
902
- filters: this.filterMap,
903
- aggregations: { omit: true },
904
- };
905
- params.uid = await this.requestUID(params, 'hits');
906
- // log('=== FIRING PAGE REQUEST ===', params);
907
- const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
908
- // log('=== RECEIVED PAGE RESPONSE IN CB ===', searchResponse);
909
- const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
910
- // This is checking to see if the fetch has been invalidated since it was fired off.
911
- // If so, we just want to discard the response since it is for an obsolete query state.
912
- if (!this.fetchesInProgress.has(currentPageKey))
913
- return;
914
- for (let i = 0; i < numPages; i += 1) {
915
- this.fetchesInProgress.delete(`${pageFetchQueryKey}-p:${pageNumber + i}`);
916
- }
917
- if (!success) {
918
- const errorMsg = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _c === void 0 ? void 0 : _c.message;
919
- const detailMsg = (_e = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.details) === null || _e === void 0 ? void 0 : _e.message;
920
- this.queryErrorMessage = `${errorMsg !== null && errorMsg !== void 0 ? errorMsg : ''}${detailMsg ? `; ${detailMsg}` : ''}`;
921
- if (!this.queryErrorMessage) {
922
- this.queryErrorMessage = 'Missing or malformed response from backend';
923
- // @ts-expect-error: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
924
- (_g = (_f = window === null || window === void 0 ? void 0 : window.Sentry) === null || _f === void 0 ? void 0 : _f.captureMessage) === null || _g === void 0 ? void 0 : _g.call(_f, this.queryErrorMessage, 'error');
925
- }
926
- this.setSearchResultsLoading(false);
927
- this.requestHostUpdate();
928
- this.host.emitSearchError();
929
- return;
930
- }
931
- this.setTotalResultCount(success.response.totalResults - this.offset);
932
- if (this.activeOnHost && this.totalResults === 0) {
933
- // display event to offshoot when result count is zero.
934
- this.host.emitEmptyResults();
935
- }
936
- this.sessionContext = success.sessionContext;
937
- if (withinCollection) {
938
- this.collectionExtraInfo = success.response.collectionExtraInfo;
939
- // For collections, we want the UI to respect the default sort option
940
- // which can be specified in metadata, or otherwise assumed to be week:desc
941
- if (this.activeOnHost) {
942
- this.host.applyDefaultCollectionSort(this.collectionExtraInfo);
943
- }
944
- if (this.collectionExtraInfo) {
945
- this.parentCollections = [].concat((_j = (_h = this.collectionExtraInfo.public_metadata) === null || _h === void 0 ? void 0 : _h.collection) !== null && _j !== void 0 ? _j : []);
946
- // Update the TV collection status now that we know the parent collections
947
- this.host.isTVCollection =
948
- ((_k = this.host.withinCollection) === null || _k === void 0 ? void 0 : _k.startsWith('TV-')) ||
949
- this.host.withinCollection === 'tvnews' ||
950
- this.host.withinCollection === 'tvarchive' ||
951
- this.parentCollections.includes('tvnews') ||
952
- this.parentCollections.includes('tvarchive');
953
- }
954
- }
955
- else if (withinProfile) {
956
- this.accountExtraInfo = success.response.accountExtraInfo;
957
- this.pageElements = success.response.pageElements;
958
- }
959
- const { results, collectionTitles, tvChannelAliases } = success.response;
960
- if (results && results.length > 0) {
961
- // Load any collection titles present on the response into the cache,
962
- // or queue up preload fetches for them if none were present.
963
- if (collectionTitles) {
964
- for (const [id, title] of Object.entries(collectionTitles)) {
965
- this.collectionTitles.set(id, title);
966
- }
967
- // Also add the target collection's title if available
968
- const targetTitle = (_m = (_l = this.collectionExtraInfo) === null || _l === void 0 ? void 0 : _l.public_metadata) === null || _m === void 0 ? void 0 : _m.title;
969
- if (withinCollection && targetTitle) {
970
- this.collectionTitles.set(withinCollection, targetTitle);
971
- }
972
- }
973
- if (tvChannelAliases) {
974
- for (const [channel, network] of Object.entries(tvChannelAliases)) {
975
- this.tvChannelAliases.set(channel, network);
976
- }
977
- }
978
- // Update the data source for each returned page.
979
- // For loans and web archives, we must account for receiving more pages than we asked for.
980
- const isUnpagedElement = ['lending', 'web_archives'].includes(this.host.profileElement);
981
- if (isUnpagedElement) {
982
- numPages = Math.ceil(results.length / this.pageSize);
983
- this.endOfDataReached = true;
984
- if (this.activeOnHost)
985
- this.host.setTileCount(this.totalResults);
986
- }
987
- for (let i = 0; i < numPages; i += 1) {
988
- const pageStartIndex = this.pageSize * i;
989
- this.addFetchedResultsToDataSource(pageNumber + i, results.slice(pageStartIndex, pageStartIndex + this.pageSize), !isUnpagedElement || i === numPages - 1);
990
- }
991
- }
992
- // When we reach the end of the data, we can set the infinite scroller's
993
- // item count to the real total number of results (rather than the
994
- // temporary estimates based on pages rendered so far).
995
- if (this.size >= this.totalResults || results.length === 0) {
996
- this.endOfDataReached = true;
997
- if (this.activeOnHost)
998
- this.host.setTileCount(this.size);
999
- }
1000
- this.setSearchResultsLoading(false);
1001
- this.requestHostUpdate();
1002
- }
1003
- /**
1004
- * Returns the type of request that produced the current set of hits,
1005
- * based on the presence of a search query or profile/collection target
1006
- * on the host.
1007
- */
1008
- get hitRequestSource() {
1009
- const { host } = this;
1010
- if (host.baseQuery)
1011
- return 'search_query';
1012
- if (host.withinProfile)
1013
- return 'profile_tab';
1014
- if (host.withinCollection)
1015
- return 'collection_members';
1016
- return 'unknown';
1017
- }
1018
- /**
1019
- * Update the datasource from the fetch response
1020
- *
1021
- * @param pageNumber
1022
- * @param results
1023
- */
1024
- addFetchedResultsToDataSource(pageNumber, results, needsReload = true) {
1025
- const tiles = [];
1026
- const requestSource = this.hitRequestSource;
1027
- results === null || results === void 0 ? void 0 : results.forEach(result => {
1028
- if (!result.identifier)
1029
- return;
1030
- tiles.push(new TileModel(result, requestSource));
1031
- });
1032
- this.addPage(pageNumber, tiles);
1033
- if (needsReload) {
1034
- this.refreshVisibleResults();
1035
- }
1036
- }
1037
- /**
1038
- * Fetches the aggregation buckets for the given prefix filter type.
1039
- */
1040
- async fetchPrefixFilterBuckets(filterType) {
1041
- var _a, _b, _c, _d, _e, _f, _g;
1042
- const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
1043
- if (!this.canPerformSearch)
1044
- return [];
1045
- const filterAggregationKey = prefixFilterAggregationKeys[filterType];
1046
- const sortParams = this.host.sortParam ? [this.host.sortParam] : [];
1047
- const params = {
1048
- ...this.pageSpecifierParams,
1049
- query: trimmedQuery || '',
1050
- identifiers: this.host.identifiers,
1051
- rows: 0,
1052
- filters: this.filterMap,
1053
- // Only fetch the firstTitle or firstCreator aggregation
1054
- aggregations: { simpleParams: [filterAggregationKey] },
1055
- // Fetch all 26 letter buckets
1056
- aggregationsSize: 26,
1057
- };
1058
- params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
1059
- const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
1060
- return ((_g = (_f = (_e = (_d = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e[filterAggregationKey]) === null || _f === void 0 ? void 0 : _f.buckets) !== null && _g !== void 0 ? _g : []);
1061
- }
1062
- /**
1063
- * Fetches and caches the prefix filter counts for the given filter type.
1064
- */
1065
- async updatePrefixFilterCounts(filterType) {
1066
- const { facetFetchQueryKey } = this;
1067
- const buckets = await this.fetchPrefixFilterBuckets(filterType);
1068
- // Don't update the filter counts for an outdated query (if it has been changed
1069
- // since we sent the request)
1070
- const queryChangedSinceFetch = facetFetchQueryKey !== this.facetFetchQueryKey;
1071
- if (queryChangedSinceFetch)
1072
- return;
1073
- // Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
1074
- this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
1075
- this.prefixFilterCountMap[filterType] = buckets.reduce((acc, bucket) => {
1076
- acc[bucket.key.toUpperCase()] = bucket.doc_count;
1077
- return acc;
1078
- }, {});
1079
- this.requestHostUpdate();
1080
- }
1081
- /**
1082
- * @inheritdoc
1083
- */
1084
- async updatePrefixFiltersForCurrentSort() {
1085
- if (['title', 'creator'].includes(this.host.selectedSort)) {
1086
- const filterType = this.host.selectedSort;
1087
- if (!this.prefixFilterCountMap[filterType]) {
1088
- this.updatePrefixFilterCounts(filterType);
1089
- }
1090
- }
1091
- }
1092
- /**
1093
- * @inheritdoc
1094
- */
1095
- refreshLetterCounts() {
1096
- if (Object.keys(this.prefixFilterCountMap).length > 0) {
1097
- this.prefixFilterCountMap = {};
1098
- }
1099
- this.updatePrefixFiltersForCurrentSort();
1100
- this.requestHostUpdate();
1101
- }
1102
- }
1103
- //# sourceMappingURL=collection-browser-data-source.js.map