@uvalib/web-components 1.1.1 → 1.3.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 (252) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/README.md +1310 -80
  3. package/dist/analytics.d.ts +10 -0
  4. package/dist/analytics.js +9 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/base/UvalibElement.js +8 -5
  7. package/dist/base/UvalibElement.js.map +1 -1
  8. package/dist/base/analytics-state.d.ts +7 -0
  9. package/dist/base/analytics-state.js.map +1 -1
  10. package/dist/base/light-dom-styles.d.ts +13 -0
  11. package/dist/base/light-dom-styles.js +26 -0
  12. package/dist/base/light-dom-styles.js.map +1 -1
  13. package/dist/base/search-tracker.d.ts +57 -0
  14. package/dist/base/search-tracker.js +51 -0
  15. package/dist/base/search-tracker.js.map +1 -0
  16. package/dist/base/url-param.d.ts +23 -0
  17. package/dist/base/url-param.js +49 -0
  18. package/dist/base/url-param.js.map +1 -0
  19. package/dist/base.css +562 -2
  20. package/dist/base.d.ts +2 -0
  21. package/dist/base.js +1 -0
  22. package/dist/base.js.map +1 -1
  23. package/dist/components/site-analytics/SiteAnalytics.d.ts +20 -1
  24. package/dist/components/site-analytics/SiteAnalytics.js +93 -12
  25. package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
  26. package/dist/components/site-page/SitePage.d.ts +23 -0
  27. package/dist/components/site-page/SitePage.js +77 -0
  28. package/dist/components/site-page/SitePage.js.map +1 -1
  29. package/dist/components/uvalib-back-to-top/UvalibBackToTop.d.ts +58 -0
  30. package/dist/components/uvalib-back-to-top/UvalibBackToTop.js +250 -0
  31. package/dist/components/uvalib-back-to-top/UvalibBackToTop.js.map +1 -0
  32. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.d.ts +1 -0
  33. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js +4 -0
  34. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js.map +1 -0
  35. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +14 -0
  36. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +56 -4
  37. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -1
  38. package/dist/components/uvalib-card/UvalibCard.d.ts +19 -5
  39. package/dist/components/uvalib-card/UvalibCard.js +112 -9
  40. package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
  41. package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +178 -0
  42. package/dist/components/uvalib-chip-group/UvalibChipGroup.js +817 -0
  43. package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -0
  44. package/dist/components/uvalib-chip-group/uvalib-chip-group.d.ts +1 -0
  45. package/dist/components/uvalib-chip-group/uvalib-chip-group.js +4 -0
  46. package/dist/components/uvalib-chip-group/uvalib-chip-group.js.map +1 -0
  47. package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +212 -0
  48. package/dist/components/uvalib-combobox/UvalibCombobox.js +1088 -0
  49. package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -0
  50. package/dist/components/uvalib-combobox/uvalib-combobox.d.ts +1 -0
  51. package/dist/components/uvalib-combobox/uvalib-combobox.js +4 -0
  52. package/dist/components/uvalib-combobox/uvalib-combobox.js.map +1 -0
  53. package/dist/components/uvalib-contents/UvalibContents.d.ts +53 -0
  54. package/dist/components/uvalib-contents/UvalibContents.js +202 -3
  55. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  56. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +187 -0
  57. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1452 -0
  58. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -0
  59. package/dist/components/uvalib-date-histogram/uvalib-date-histogram.d.ts +1 -0
  60. package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js +4 -0
  61. package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js.map +1 -0
  62. package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +6 -0
  63. package/dist/components/uvalib-date-range/UvalibDateRange.js +23 -0
  64. package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
  65. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +113 -0
  66. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +589 -0
  67. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -0
  68. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.d.ts +1 -0
  69. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js +4 -0
  70. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js.map +1 -0
  71. package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +130 -0
  72. package/dist/components/uvalib-image-regions/UvalibImageRegions.js +658 -0
  73. package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -0
  74. package/dist/components/uvalib-image-regions/regions.d.ts +57 -0
  75. package/dist/components/uvalib-image-regions/regions.js +117 -0
  76. package/dist/components/uvalib-image-regions/regions.js.map +1 -0
  77. package/dist/components/uvalib-image-regions/uvalib-image-regions.d.ts +1 -0
  78. package/dist/components/uvalib-image-regions/uvalib-image-regions.js +4 -0
  79. package/dist/components/uvalib-image-regions/uvalib-image-regions.js.map +1 -0
  80. package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +40 -0
  81. package/dist/components/uvalib-lightbox/UvalibLightbox.js +152 -17
  82. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
  83. package/dist/components/uvalib-lightbox/media.d.ts +1 -18
  84. package/dist/components/uvalib-lightbox/media.js +1 -42
  85. package/dist/components/uvalib-lightbox/media.js.map +1 -1
  86. package/dist/components/uvalib-map/UvalibMap.d.ts +182 -0
  87. package/dist/components/uvalib-map/UvalibMap.js +1001 -0
  88. package/dist/components/uvalib-map/UvalibMap.js.map +1 -0
  89. package/dist/components/uvalib-map/uvalib-map.d.ts +1 -0
  90. package/dist/components/uvalib-map/uvalib-map.js +4 -0
  91. package/dist/components/uvalib-map/uvalib-map.js.map +1 -0
  92. package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +39 -2
  93. package/dist/components/uvalib-metadata/UvalibMetadata.js +214 -8
  94. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  95. package/dist/components/uvalib-pager/UvalibPager.d.ts +77 -4
  96. package/dist/components/uvalib-pager/UvalibPager.js +270 -8
  97. package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
  98. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +27 -1
  99. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +192 -26
  100. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
  101. package/dist/components/uvalib-results-count/UvalibResultsCount.d.ts +62 -0
  102. package/dist/components/uvalib-results-count/UvalibResultsCount.js +208 -0
  103. package/dist/components/uvalib-results-count/UvalibResultsCount.js.map +1 -0
  104. package/dist/components/uvalib-results-count/uvalib-results-count.d.ts +1 -0
  105. package/dist/components/uvalib-results-count/uvalib-results-count.js +4 -0
  106. package/dist/components/uvalib-results-count/uvalib-results-count.js.map +1 -0
  107. package/dist/components/uvalib-tabs/UvalibTabs.d.ts +127 -0
  108. package/dist/components/uvalib-tabs/UvalibTabs.js +821 -0
  109. package/dist/components/uvalib-tabs/UvalibTabs.js.map +1 -0
  110. package/dist/components/uvalib-tabs/uvalib-tabs.d.ts +1 -0
  111. package/dist/components/uvalib-tabs/uvalib-tabs.js +4 -0
  112. package/dist/components/uvalib-tabs/uvalib-tabs.js.map +1 -0
  113. package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +89 -0
  114. package/dist/components/uvalib-tag-list/UvalibTagList.js +411 -0
  115. package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -0
  116. package/dist/components/uvalib-tag-list/uvalib-tag-list.d.ts +1 -0
  117. package/dist/components/uvalib-tag-list/uvalib-tag-list.js +4 -0
  118. package/dist/components/uvalib-tag-list/uvalib-tag-list.js.map +1 -0
  119. package/dist/custom-elements.json +14007 -3497
  120. package/dist/index.d.ts +16 -0
  121. package/dist/index.js +10 -0
  122. package/dist/index.js.map +1 -1
  123. package/dist/pagefind.css +4 -0
  124. package/dist/styles/base.js +154 -1
  125. package/dist/styles/base.js.map +1 -1
  126. package/dist/styles/color-scheme.js +9 -0
  127. package/dist/styles/color-scheme.js.map +1 -1
  128. package/dist/styles/controls.js +8 -0
  129. package/dist/styles/controls.js.map +1 -1
  130. package/dist/styles/hidden.d.ts +2 -0
  131. package/dist/styles/hidden.js +51 -0
  132. package/dist/styles/hidden.js.map +1 -0
  133. package/dist/styles/message.d.ts +1 -0
  134. package/dist/styles/message.js +82 -0
  135. package/dist/styles/message.js.map +1 -0
  136. package/dist/styles/pagefind.js +4 -0
  137. package/dist/styles/pagefind.js.map +1 -1
  138. package/dist/styles/result-list.d.ts +1 -0
  139. package/dist/styles/result-list.js +111 -0
  140. package/dist/styles/result-list.js.map +1 -0
  141. package/dist/styles/results.d.ts +1 -0
  142. package/dist/styles/results.js +242 -0
  143. package/dist/styles/results.js.map +1 -0
  144. package/dist/testing/index.d.ts +110 -0
  145. package/dist/testing/index.js +100 -0
  146. package/dist/testing/index.js.map +1 -0
  147. package/dist/testing/lighthouse-rules.d.ts +10 -0
  148. package/dist/testing/lighthouse-rules.js +44 -0
  149. package/dist/testing/lighthouse-rules.js.map +1 -0
  150. package/dist/tokens.css +9 -0
  151. package/dist-cdn/analytics.js +32 -0
  152. package/dist-cdn/analytics.js.map +1 -0
  153. package/dist-cdn/base.css +562 -2
  154. package/dist-cdn/bento-box.js +3 -3
  155. package/dist-cdn/chunks/{SiteAnalytics-Cm-FyhYS.js → SiteAnalytics-B9gu5aGO.js} +59 -30
  156. package/dist-cdn/chunks/SiteAnalytics-B9gu5aGO.js.map +1 -0
  157. package/dist-cdn/chunks/{UvalibElement-BnI-eRRR.js → UvalibElement-pGONDAwB.js} +108 -101
  158. package/dist-cdn/chunks/UvalibElement-pGONDAwB.js.map +1 -0
  159. package/dist-cdn/chunks/{accessible-GqhVn5_H.js → accessible-DJv7YOtS.js} +2 -2
  160. package/dist-cdn/chunks/{accessible-GqhVn5_H.js.map → accessible-DJv7YOtS.js.map} +1 -1
  161. package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -1
  162. package/dist-cdn/chunks/base-BI8h0Gf3.js +281 -0
  163. package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
  164. package/dist-cdn/chunks/inline-copy-BANQSMIR.js +69 -0
  165. package/dist-cdn/chunks/inline-copy-BANQSMIR.js.map +1 -0
  166. package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js → library-weekly-hours-CrV3TlP5.js} +3 -3
  167. package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js.map → library-weekly-hours-CrV3TlP5.js.map} +1 -1
  168. package/dist-cdn/chunks/regions-B8ExwUGP.js +86 -0
  169. package/dist-cdn/chunks/regions-B8ExwUGP.js.map +1 -0
  170. package/dist-cdn/chunks/{repeat-CIFUYkyh.js → repeat-m5Zd_QeP.js} +2 -2
  171. package/dist-cdn/chunks/{repeat-CIFUYkyh.js.map → repeat-m5Zd_QeP.js.map} +1 -1
  172. package/dist-cdn/chunks/{site-header-C9V7Wuw2.js → site-header-DYRMpdBj.js} +13 -4
  173. package/dist-cdn/chunks/site-header-DYRMpdBj.js.map +1 -0
  174. package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js → site-main-nav-DURrQMal.js} +3 -3
  175. package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js.map → site-main-nav-DURrQMal.js.map} +1 -1
  176. package/dist-cdn/chunks/source-children-BHsDwCvL.js +53 -0
  177. package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
  178. package/dist-cdn/chunks/{static-html-1mTAG6nS.js → static-html-C1rhtCHu.js} +2 -2
  179. package/dist-cdn/chunks/{static-html-1mTAG6nS.js.map → static-html-C1rhtCHu.js.map} +1 -1
  180. package/dist-cdn/chunks/url-param-C1sk_F1d.js +28 -0
  181. package/dist-cdn/chunks/url-param-C1sk_F1d.js.map +1 -0
  182. package/dist-cdn/custom-elements.json +14007 -3497
  183. package/dist-cdn/events-section.js +3 -3
  184. package/dist-cdn/library-hours-setup.js +2 -2
  185. package/dist-cdn/library-weekly-hours.js +1 -1
  186. package/dist-cdn/manifest.json +15 -2
  187. package/dist-cdn/pagefind.css +4 -0
  188. package/dist-cdn/site-alerts.js +4 -4
  189. package/dist-cdn/site-analytics.js +2 -2
  190. package/dist-cdn/site-footer.js +2 -2
  191. package/dist-cdn/site-header.js +1 -1
  192. package/dist-cdn/site-hours-section.js +4 -4
  193. package/dist-cdn/site-main-nav.js +1 -1
  194. package/dist-cdn/site-page.js +56 -11
  195. package/dist-cdn/site-page.js.map +1 -1
  196. package/dist-cdn/site-style.js +2 -2
  197. package/dist-cdn/skills/uvalib-web-components/SKILL.md +269 -24
  198. package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
  199. package/dist-cdn/skills/uvalib-web-components/reference/components.md +514 -13
  200. package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
  201. package/dist-cdn/tokens.css +9 -0
  202. package/dist-cdn/uvalib-analytics.js +2 -2
  203. package/dist-cdn/uvalib-back-to-top.js +156 -0
  204. package/dist-cdn/uvalib-back-to-top.js.map +1 -0
  205. package/dist-cdn/uvalib-breadcrumbs.js +31 -11
  206. package/dist-cdn/uvalib-breadcrumbs.js.map +1 -1
  207. package/dist-cdn/uvalib-card-grid.js +1 -1
  208. package/dist-cdn/uvalib-card.js +97 -23
  209. package/dist-cdn/uvalib-card.js.map +1 -1
  210. package/dist-cdn/uvalib-chip-group.js +535 -0
  211. package/dist-cdn/uvalib-chip-group.js.map +1 -0
  212. package/dist-cdn/uvalib-combobox.js +667 -0
  213. package/dist-cdn/uvalib-combobox.js.map +1 -0
  214. package/dist-cdn/uvalib-contents.js +102 -23
  215. package/dist-cdn/uvalib-contents.js.map +1 -1
  216. package/dist-cdn/uvalib-date-histogram.js +960 -0
  217. package/dist-cdn/uvalib-date-histogram.js.map +1 -0
  218. package/dist-cdn/uvalib-date-range.js +14 -2
  219. package/dist-cdn/uvalib-date-range.js.map +1 -1
  220. package/dist-cdn/uvalib-filter-drawer.js +355 -0
  221. package/dist-cdn/uvalib-filter-drawer.js.map +1 -0
  222. package/dist-cdn/uvalib-filter.js +3 -3
  223. package/dist-cdn/uvalib-image-regions.js +447 -0
  224. package/dist-cdn/uvalib-image-regions.js.map +1 -0
  225. package/dist-cdn/uvalib-lightbox.js +145 -78
  226. package/dist-cdn/uvalib-lightbox.js.map +1 -1
  227. package/dist-cdn/uvalib-map.js +471 -0
  228. package/dist-cdn/uvalib-map.js.map +1 -0
  229. package/dist-cdn/uvalib-metadata.js +152 -25
  230. package/dist-cdn/uvalib-metadata.js.map +1 -1
  231. package/dist-cdn/uvalib-pager.js +164 -18
  232. package/dist-cdn/uvalib-pager.js.map +1 -1
  233. package/dist-cdn/uvalib-photo-grid.js +123 -21
  234. package/dist-cdn/uvalib-photo-grid.js.map +1 -1
  235. package/dist-cdn/uvalib-results-count.js +101 -0
  236. package/dist-cdn/uvalib-results-count.js.map +1 -0
  237. package/dist-cdn/uvalib-tabs.js +436 -0
  238. package/dist-cdn/uvalib-tabs.js.map +1 -0
  239. package/dist-cdn/uvalib-tag-list.js +267 -0
  240. package/dist-cdn/uvalib-tag-list.js.map +1 -0
  241. package/package.json +66 -3
  242. package/skills/uvalib-web-components/SKILL.md +269 -24
  243. package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
  244. package/skills/uvalib-web-components/reference/components.md +514 -13
  245. package/skills/uvalib-web-components/reference/snippets.md +1 -1
  246. package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +0 -1
  247. package/dist-cdn/chunks/UvalibElement-BnI-eRRR.js.map +0 -1
  248. package/dist-cdn/chunks/base-CAFQWnZG.js +0 -128
  249. package/dist-cdn/chunks/base-CAFQWnZG.js.map +0 -1
  250. package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +0 -1
  251. package/dist-cdn/chunks/source-children-RuAec527.js +0 -119
  252. package/dist-cdn/chunks/source-children-RuAec527.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uvalib-combobox.js","names":["unsafeCSS","nothing","_decorate","property","state","n","w","i","r$1","b","define","__decorate","A","r","installLightDomStyles","UvalibElement","trackEvent","trackError","normalize","SourceChildren","accessible","comboboxTiming","TAG","CLEAR_MS","CACHE_SIZE","uid","MARKS","fold","s","foldMap","text","map","ch","label","f","k","WORD","toEntry","raw","e","d","toEntries","list","count","structuralRules","host","shadowStructure","BORDER","ACCENT","MUTED","TEXT","RAISED","CLEAR_ICON","UvalibCombobox","nodes","root","sheet","node","disabled","state","input","options","v","kind","message","entries","o","item","key","m","all","max","q","buckets","total","cached","ctrl","url","res","data","err","value","type","hits","selected","at","from","dir","index","keep","button","form","el","li","now","changed","field","popup","opt","top","bottom","parts","last","end","id","off","expanded","note"],"sources":["../src/components/uvalib-combobox/UvalibCombobox.ts","../src/components/uvalib-combobox/uvalib-combobox.ts"],"sourcesContent":["import { css, html, nothing, svg, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackError, trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/**\n * One suggestion: the value submitted with the form and reported in events, the text shown\n * (default: the value), an optional second line, and whether it can be chosen. Other fields\n * are kept: `select` and `change` hand back the object you gave.\n */\nexport interface ComboboxItem {\n value: string;\n label?: string;\n description?: string;\n disabled?: boolean;\n [key: string]: unknown;\n}\n\n/** Turns a `src` response into suggestions (default: the response is already an array). */\nexport type ComboboxTransform = (data: unknown, query: string) => (ComboboxItem | string)[];\n\n/**\n * `debounce`: milliseconds after the last keystroke before `src` is fetched. `announce`:\n * milliseconds the suggestion count must stay put before it is announced. Tests may shorten them.\n */\nexport const comboboxTiming = { debounce: 250, announce: 500 };\n\nconst TAG = 'uvalib-combobox';\n/** How long an announcement stays in the live region before it is cleared. */\nconst CLEAR_MS = 5000;\n/** Responses kept per `src`, so Backspace does not fetch again. */\nconst CACHE_SIZE = 30;\nlet uid = 0;\n\n/** A suggestion as shown: its display text, folded for matching, and what was given. */\ninterface Entry {\n value: string;\n label: string;\n description?: string;\n disabled: boolean;\n fold: string;\n /** What events and `selected` hand back: the given object, or `{ value, label }` for a string. */\n raw: ComboboxItem;\n}\n\nconst MARKS = /\\p{M}/gu;\n/** Case- and accent-insensitive form: “Ébène” and “ebene” match. */\nexport const fold = (s: string): string => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\n/** `label` folded, with the index in `label` that each folded character came from. */\nfunction foldMap(label: string): { text: string; map: number[] } {\n let text = '';\n const map: number[] = [];\n let i = 0;\n for (const ch of label) {\n const f = fold(ch);\n for (let k = 0; k < f.length; k++) map.push(i);\n text += f;\n i += ch.length;\n }\n map.push(i);\n return { text, map };\n}\n\nconst WORD = /[\\p{L}\\p{N}]/u;\n\nfunction toEntry(raw: unknown): Entry | null {\n if (typeof raw === 'string' || typeof raw === 'number') {\n const s = normalize(raw);\n return s\n ? { value: s, label: s, disabled: false, fold: fold(s), raw: { value: s, label: s } }\n : null;\n }\n if (!raw || typeof raw !== 'object') return null;\n const r = raw as ComboboxItem;\n const label = normalize(r.label ?? r.value);\n if (!label) return null;\n const e: Entry = {\n value: String(r.value ?? label),\n label,\n disabled: !!r.disabled,\n fold: fold(label),\n raw: r,\n };\n const d = normalize(r.description);\n if (d) e.description = d;\n return e;\n}\n\nconst toEntries = (list: unknown): Entry[] =>\n Array.isArray(list) ? list.map(toEntry).filter((e): e is Entry => e !== null) : [];\n\nconst count = (n: number) => n.toLocaleString('en-US');\n\n/**\n * Kept with `no-style`: the popup under the field, 44px options and clear button, and the\n * hidden live region. `host` is `:host` or the tag.\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; max-width: 100%; line-height: 1.5; }\n ${host} .label { display: block; margin-block-end: 0.25rem; }\n ${host} .field { position: relative; }\n ${host} .input {\n display: block;\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: 44px;\n margin: 0;\n padding-inline-end: 44px;\n font: inherit;\n line-height: 1.2;\n }\n ${host} .clear {\n position: absolute;\n inset-block-start: 0;\n inset-inline-end: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n inline-size: 44px;\n block-size: 44px;\n margin: 0;\n padding: 0;\n cursor: pointer;\n }\n ${host} .popup {\n position: absolute;\n inset-inline: 0;\n inset-block-start: calc(100% + 2px);\n z-index: 20;\n box-sizing: border-box;\n max-block-size: min(18rem, 60vh);\n margin: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n }\n ${host} .listbox { margin: 0; padding: 0; list-style: none; }\n ${host} .option {\n display: flex;\n flex-direction: column;\n justify-content: center;\n box-sizing: border-box;\n min-block-size: 44px;\n overflow-wrap: anywhere;\n cursor: pointer;\n }\n ${host} .option[aria-disabled='true'] { cursor: not-allowed; }\n ${host} .message { box-sizing: border-box; min-block-size: 44px; margin: 0; }\n ${host} .description { margin: 0.25rem 0 0; }\n ${host} .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\nconst BORDER = unsafeCSS('var(--uva-color-control-border, var(--uva-grey, #808080))');\nconst ACCENT = unsafeCSS('var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))');\nconst MUTED = unsafeCSS('var(--uva-color-text-muted, var(--uva-grey-A, #4f4f4f))');\nconst TEXT = unsafeCSS('var(--uva-color-input-text, var(--uva-grey-darkest, #2b2b2b))');\nconst RAISED = unsafeCSS('var(--uva-color-surface-raised, #ffffff)');\n\nconst CLEAR_ICON = svg`<svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M4 4l8 8M12 4l-8 8\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>`;\n\n/**\n * An editable text field that suggests values as you type, from a local list or a URL: a\n * person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List\n * Autocomplete”: a real `<input role=\"combobox\">` and a `role=\"listbox\"` popup under it.\n *\n * Suggestions come from the `items` property (`{ value, label?, description?, disabled? }`\n * objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the\n * `label` attribute or text is the label, `data-description` the second line), or from `src`,\n * a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has\n * `min-length` characters, default 1; a newer keystroke aborts the older request; the\n * response is a JSON array of the same shape, or anything `transform(data, query)` turns\n * into one). `items` wins over the children while set. Local suggestions match anywhere in\n * the label, ignoring case and accents, those starting with the text first, then those with\n * a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which\n * keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`.\n *\n * Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the\n * last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion\n * (and then does not submit the form; with none active, Enter submits as in any field),\n * Escape closes the list and a second Escape clears the field, Home, End, Left and Right move\n * the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px,\n * shown only with text) empties the field and returns focus to it.\n *\n * Free text is allowed: `value` is whatever is in the field, and `selected` the chosen\n * suggestion (or null); typing after choosing clears it, and leaving the field with text that\n * is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid\n * (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits\n * the chosen suggestion's value, or else the text, and a form reset restores the `value`\n * attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input.\n *\n * A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”,\n * “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles\n * (never on the first render); the popup shows the same notes visibly. A failed load never\n * throws.\n *\n * Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's\n * height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its\n * text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.\n *\n * @tagname uvalib-combobox\n * @fires input - The text changed by typing (the native event of the field, composed). Not fired when an option is chosen.\n * @fires select - A suggestion was chosen (click or Enter). `detail` is `{ item }`, the object given. Bubbles and is composed.\n * @fires change - The value was committed: a suggestion chosen, the field cleared, or the field left with changed text. `detail` is `{ value, item }` (`item` is the chosen suggestion or null). Not fired when the app sets `value` or `selected`. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-combobox', 'select', '<label>', <position from 1>]` when a suggestion is chosen, `['uvalib-combobox', 'clear', '<label>']` when the clear button or Escape empties the field, and `['uvalib-combobox', 'error', 'load']` once when `src` fails. Never the typed text or a suggestion's text or value. Bubbles and is composed.\n * @csspart label - The visible label.\n * @csspart input - The text field.\n * @csspart clear - The clear button.\n * @csspart popup - The popup under the field.\n * @csspart option - Each suggestion.\n * @csspart description - The hint under the field.\n * @cssprop --uva-color-surface-raised - Dark-mode role token: field and popup background (else #fff).\n * @cssprop --uva-color-control-border - Dark-mode role token: field and popup border (else `--uva-grey`, #808080).\n * @cssprop --uva-color-input-text - Dark-mode role token: field and suggestion text (else #2b2b2b).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions, notes and the clear icon (else #4f4f4f).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: active suggestion background (else #dadada).\n * @cssprop --uva-color-track - Dark-mode role token: hovered suggestion background (else #f1f1f1).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: the active suggestion's bar and outline (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-shadow - Dark-mode role token: popup shadow.\n */\nexport class UvalibCombobox extends UvalibElement {\n static formAssociated = true;\n static override shadowRootOptions: ShadowRootInit = {\n ...UvalibElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static styles = [\n accessible,\n shadowStructure,\n css`\n .label {\n font-weight: 600;\n }\n .input {\n padding-block: 0.5rem;\n padding-inline-start: 0.75rem;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n }\n .input::placeholder {\n color: ${MUTED};\n opacity: 1;\n }\n .input:disabled {\n background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));\n color: ${MUTED};\n cursor: not-allowed;\n }\n .input[aria-invalid='true'] {\n border-width: 2px;\n }\n .clear {\n border: 0;\n border-radius: 5px;\n background: none;\n color: ${MUTED};\n }\n .clear:hover {\n color: ${TEXT};\n }\n .clear:focus-visible {\n outline-offset: -4px;\n }\n .popup {\n padding-block: 0.25rem;\n border: 1px solid ${BORDER};\n border-radius: 5px;\n background: ${RAISED};\n color: ${TEXT};\n box-shadow: 0 4px 12px var(--uva-color-shadow, rgba(0, 0, 0, 0.2));\n }\n .option {\n padding: 0.375rem 0.75rem;\n border-inline-start: 4px solid transparent;\n }\n .option:hover {\n background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));\n }\n /* The active suggestion: a fill, a bar at the start and an outline, never colour alone. */\n .option[aria-selected='true'] {\n border-inline-start-color: ${ACCENT};\n background: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));\n outline: 2px solid ${ACCENT};\n outline-offset: -2px;\n }\n .option[aria-disabled='true'] {\n color: ${MUTED};\n font-style: italic;\n }\n .option-description {\n color: ${MUTED};\n font-size: 0.875em;\n }\n mark {\n background: none;\n color: inherit;\n font-weight: 700;\n text-decoration: underline;\n text-underline-offset: 0.15em;\n }\n .message {\n padding: 0.625rem 0.75rem;\n color: ${MUTED};\n }\n .description {\n color: ${MUTED};\n }\n @media (forced-colors: active) {\n .input,\n .popup {\n border-color: CanvasText;\n }\n .clear {\n color: ButtonText;\n }\n .option[aria-selected='true'] {\n forced-color-adjust: none;\n border-inline-start-color: HighlightText;\n background: Highlight;\n color: HighlightText;\n outline-color: HighlightText;\n }\n .option[aria-selected='true'] .option-description {\n color: HighlightText;\n }\n .option[aria-disabled='true'] {\n color: GrayText;\n }\n }\n `,\n ];\n\n /** The field's visible label (required); also the analytics name. */\n @property({ type: String }) label = '';\n\n /** A hint under the field, read with it (aria-describedby). */\n @property({ type: String }) description = '';\n\n @property({ type: String }) placeholder = '';\n\n /** The form field name. */\n @property({ type: String, reflect: true }) name = '';\n\n /**\n * The text in the field. The attribute is the starting text, and what a form reset\n * restores. Setting it does not fire `change`.\n */\n @property({ type: String }) value = '';\n\n /**\n * The chosen suggestion, or null. Set it (an item or a string) to show a choice: the field\n * shows its label. Setting it does not fire `change`.\n */\n @property({ attribute: false }) selected: ComboboxItem | null = null;\n\n /** Suggestions as data: `{ value, label?, description?, disabled? }` or strings. Wins over the children. */\n @property({ attribute: false }) items?: (ComboboxItem | string)[];\n\n /** A URL template with `{q}` (the trimmed text, URL-encoded) that returns suggestions as JSON. */\n @property({ type: String }) src = '';\n\n /** Maps a `src` response to suggestions, e.g. `(data) => data.results`. */\n @property({ attribute: false }) transform?: ComboboxTransform;\n\n /** Characters typed before suggestions appear (and `src` is fetched). */\n @property({ type: Number, attribute: 'min-length' }) minLength = 1;\n\n /** The most suggestions shown at once; 0 for all. */\n @property({ type: Number, attribute: 'max-results' }) maxResults = 50;\n\n /** Text that is not one of the suggestions is invalid. */\n @property({ type: Boolean, attribute: 'must-choose' }) mustChoose = false;\n\n @property({ type: Boolean, reflect: true }) required = false;\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n @state() private open = false;\n @state() private active = -1;\n @state() private shown: Entry[] = [];\n @state() private total = 0;\n @state() private loading: 'idle' | 'loading' | 'error' = 'idle';\n @state() private announcement = '';\n @state() private formDisabled = false;\n @state() private invalidShown = false;\n @state() private childEntries: Entry[] = [];\n\n private internals: ElementInternals;\n private readonly uid = `${TAG}-${++uid}`;\n private warned = new Set<string>();\n /** The last committed state: `change` fires when it differs. */\n private committed: { value: string; item: ComboboxItem | null } = { value: '', item: null };\n /** Values this element set itself (any other change is the app's). */\n private ownValue?: string;\n private ownSelected?: ComboboxItem | null;\n private itemEntries?: Entry[];\n private itemsSource?: unknown;\n private remote: Entry[] = [];\n private remoteQuery?: string;\n private cache = new Map<string, Entry[]>();\n private abort?: AbortController;\n private fetchTimer?: ReturnType<typeof setTimeout>;\n private announceTimer?: ReturnType<typeof setTimeout>;\n private clearTimer?: ReturnType<typeof setTimeout>;\n private lastAnnounced = '';\n private adopted = new WeakSet<HTMLInputElement>();\n private started = false;\n\n constructor() {\n super();\n this.internals = this.attachInternals();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.cancelFetch();\n clearTimeout(this.announceTimer);\n clearTimeout(this.clearTimer);\n this.open = false;\n }\n\n /* ---------- form association ---------- */\n\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n get validity(): ValidityState {\n return this.internals.validity;\n }\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n get willValidate(): boolean {\n return this.internals.willValidate;\n }\n checkValidity(): boolean {\n return this.internals.checkValidity();\n }\n reportValidity(): boolean {\n return this.internals.reportValidity();\n }\n\n formResetCallback(): void {\n this.cancelFetch();\n this.open = false;\n this.active = -1;\n this.invalidShown = false;\n this.setOwn(this.getAttribute('value') ?? '', null);\n this.committed = { value: this.value, item: null };\n }\n\n formDisabledCallback(disabled: boolean): void {\n this.formDisabled = disabled;\n }\n\n formStateRestoreCallback(state: string | File | FormData | null): void {\n if (typeof state === 'string') {\n this.setOwn(state, null);\n this.committed = { value: state, item: null };\n }\n }\n\n private get input(): HTMLInputElement | null {\n return this.renderRoot.querySelector<HTMLInputElement>(`#${this.uid}-input`);\n }\n\n override focus(options?: FocusOptions): void {\n const input = this.input;\n if (input) input.focus(options);\n else super.focus(options);\n }\n\n private updateForm(): void {\n const v = this.selected ? String(this.selected.value) : this.value;\n this.internals.setFormValue(v, this.value);\n const input = this.input ?? undefined;\n if (this.required && !this.value.trim())\n this.internals.setValidity({ valueMissing: true }, 'Fill in this field.', input);\n else if (this.mustChoose && this.value.trim() && !this.selected)\n this.internals.setValidity({ customError: true }, 'Choose one of the suggestions.', input);\n else this.internals.setValidity({});\n }\n\n /* ---------- data ---------- */\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read `<option>`s (direct or in a `<datalist>`) and adopt a fallback `<input>`. */\n private read(nodes: Node[]): void {\n const options: HTMLOptionElement[] = [];\n for (const n of nodes) {\n if (n instanceof HTMLOptionElement) options.push(n);\n else if (n instanceof HTMLDataListElement) options.push(...n.options);\n else if (n instanceof HTMLInputElement) {\n this.adopt(n);\n if (n.list && !nodes.includes(n.list)) options.push(...n.list.options);\n }\n }\n const entries = toEntries(\n options.map((o) => {\n const label = normalize(o.getAttribute('label') ?? o.textContent) || o.value;\n const item: ComboboxItem = { value: o.value || label, label };\n const d = o.getAttribute('data-description');\n if (d) item.description = d;\n if (o.disabled) item.disabled = true;\n return item;\n }),\n );\n const key = (list: Entry[]) =>\n list\n .map((e) => `${e.value}\\u0001${e.label}\\u0001${e.description ?? ''}\\u0001${+e.disabled}`)\n .join('\\u0000');\n if (key(entries) !== key(this.childEntries)) this.childEntries = entries;\n }\n\n /** The no-JavaScript field: its text, name and placeholder carry over, then it is disabled. */\n private adopt(input: HTMLInputElement): void {\n if (this.adopted.has(input)) return;\n this.adopted.add(input);\n if (!this.name && input.name) this.name = input.name;\n if (!this.placeholder && input.placeholder) this.placeholder = input.placeholder;\n if (!this.value && input.value) this.setOwn(input.value, null);\n input.disabled = true;\n }\n\n /** Local suggestions: `items` while set, else the children. */\n private get local(): Entry[] {\n if (this.items) {\n if (this.items !== this.itemsSource) {\n this.itemsSource = this.items;\n this.itemEntries = toEntries(this.items);\n }\n return this.itemEntries!;\n }\n return this.childEntries;\n }\n\n /** The trimmed text, and folded for matching. */\n private get query(): { text: string; folded: string } {\n const text = normalize(this.value);\n return { text, folded: fold(text) };\n }\n\n private get max(): number {\n const m = Math.trunc(Number(this.maxResults));\n return Number.isFinite(m) && m > 0 ? m : Infinity;\n }\n\n /** Prefix matches, then word-start matches, then the rest, each in the given order. */\n private filter(q: string): void {\n const all = this.local;\n const max = this.max;\n if (!q) {\n this.shown = all.slice(0, max);\n this.total = all.length;\n return;\n }\n const buckets: Entry[][] = [[], [], []];\n let total = 0;\n for (const e of all) {\n const i = e.fold.indexOf(q);\n if (i < 0) continue;\n total++;\n const b = i === 0 ? 0 : WORD.test(e.fold[i - 1]!) ? 2 : 1;\n if (buckets[b]!.length < max) buckets[b]!.push(e);\n }\n this.shown = buckets.flat().slice(0, max);\n this.total = total;\n }\n\n private cancelFetch(): void {\n clearTimeout(this.fetchTimer);\n this.fetchTimer = undefined;\n this.abort?.abort();\n this.abort = undefined;\n }\n\n private showRemote(q: string, entries: Entry[]): void {\n this.remote = entries;\n this.remoteQuery = q;\n this.loading = 'idle';\n this.shown = entries.slice(0, this.max);\n this.total = entries.length;\n }\n\n /** `src`: the cached response, or a fetch once typing pauses. */\n private request(q: string): void {\n this.cancelFetch();\n const cached = this.cache.get(q);\n if (cached) {\n this.showRemote(q, cached);\n return;\n }\n this.loading = 'loading';\n this.fetchTimer = setTimeout(() => void this.load(q), comboboxTiming.debounce);\n }\n\n private async load(q: string): Promise<void> {\n const ctrl = new AbortController();\n this.abort = ctrl;\n const url = this.src.replaceAll('{q}', encodeURIComponent(q));\n try {\n const res = await fetch(new URL(url, this.ownerDocument.baseURI), {\n signal: ctrl.signal,\n headers: { Accept: 'application/json' },\n });\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n const data: unknown = await res.json();\n const list = this.transform ? this.transform(data, q) : data;\n if (!Array.isArray(list)) throw new Error('the response is not an array');\n if (ctrl.signal.aborted) return;\n const entries = toEntries(list);\n this.cache.set(q, entries);\n if (this.cache.size > CACHE_SIZE) this.cache.delete(this.cache.keys().next().value!);\n if (this.query.text !== q) return;\n this.showRemote(q, entries);\n this.active = -1;\n } catch (err) {\n if (ctrl.signal.aborted) return;\n this.loading = 'error';\n this.shown = [];\n this.total = 0;\n this.remoteQuery = undefined;\n this.warnOnce('load', `couldn't load suggestions (${(err as Error).message}).`);\n trackError(this, TAG, 'load');\n } finally {\n if (this.abort === ctrl) this.abort = undefined;\n }\n }\n\n /** Recompute the suggestions for the current text. */\n private refresh(): void {\n const q = this.query;\n if (this.src) {\n if (q.text.length < this.minLength) {\n this.cancelFetch();\n this.loading = 'idle';\n this.shown = [];\n this.total = 0;\n return;\n }\n if (q.text === this.remoteQuery && this.loading !== 'error') {\n this.shown = this.remote.slice(0, this.max);\n this.total = this.remote.length;\n return;\n }\n this.request(q.text);\n return;\n }\n this.filter(q.folded);\n }\n\n /* ---------- state changes ---------- */\n\n private setOwn(value: string, item: ComboboxItem | null): void {\n this.value = this.ownValue = value;\n this.selected = this.ownSelected = item;\n }\n\n private emit(type: string, detail: object): void {\n this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));\n }\n\n /** The suggestion whose label is exactly the text (ignoring case and accents), if one. */\n private exact(): Entry | undefined {\n const q = this.query.folded;\n if (!q) return undefined;\n const pool = this.src ? this.remote : this.local;\n const hits = pool.filter((e) => !e.disabled && e.fold === q);\n return hits.length === 1 ? hits[0] : undefined;\n }\n\n private commit(): void {\n if (!this.selected) {\n const m = this.exact();\n if (m) this.setOwn(m.label, m.raw);\n }\n const { value, selected } = this;\n this.invalidShown = this.mustChoose && !!value.trim() && !selected;\n if (value === this.committed.value && selected === this.committed.item) return;\n this.committed = { value, item: selected };\n this.emit('change', { value, item: selected });\n }\n\n private close(): void {\n this.open = false;\n this.active = -1;\n }\n\n private openList(at: 'none' | 'first' | 'last'): void {\n if (this.src && this.query.text.length < this.minLength) return;\n this.refresh();\n this.open = true;\n this.active =\n at === 'none'\n ? -1\n : this.step(at === 'first' ? -1 : this.shown.length, at === 'first' ? 1 : -1);\n }\n\n /** The next choosable index from `from` in `dir`, wrapping; -1 when there is none. */\n private step(from: number, dir: 1 | -1): number {\n const n = this.shown.length;\n for (let k = 1; k <= n; k++) {\n const i = (((from + dir * k) % n) + n) % n;\n if (!this.shown[i]!.disabled) return i;\n }\n return -1;\n }\n\n private choose(index: number): void {\n const e = this.shown[index];\n if (!e || e.disabled) return;\n this.cancelFetch();\n this.setOwn(e.label, e.raw);\n this.close();\n this.invalidShown = false;\n this.emit('select', { item: e.raw });\n trackEvent(this, [TAG, 'select', this.label.trim(), index + 1]);\n this.commit();\n }\n\n private clear(): void {\n this.cancelFetch();\n this.loading = 'idle';\n this.setOwn('', null);\n this.close();\n trackEvent(this, [TAG, 'clear', this.label.trim()]);\n this.commit();\n this.focus();\n }\n\n /* ---------- handlers ---------- */\n\n private onInput(e: Event): void {\n const text = (e.target as HTMLInputElement).value;\n const keep = this.selected && text === normalize(this.selected.label ?? this.selected.value);\n this.setOwn(text, keep ? this.selected : null);\n this.invalidShown = false;\n this.active = -1;\n if (this.query.text.length < this.minLength) {\n this.cancelFetch();\n this.loading = 'idle';\n this.close();\n return;\n }\n this.refresh();\n this.open = true;\n }\n\n private onKeydown(e: KeyboardEvent): void {\n if (e.isComposing) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (e.altKey) {\n if (!this.open) this.openList('none');\n } else if (!this.open) this.openList('first');\n else this.active = this.step(this.active, 1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (e.altKey) this.close();\n else if (!this.open) this.openList('last');\n else this.active = this.step(this.active < 0 ? this.shown.length : this.active, -1);\n return;\n case 'Enter':\n if (this.open && this.active >= 0) {\n e.preventDefault();\n this.choose(this.active);\n return;\n }\n this.close();\n this.commit();\n this.updateForm();\n if (!this.lightDom && this.form) {\n // A shadow field is not the form's own: submit as a native field would.\n e.preventDefault();\n this.submit(this.form);\n }\n return;\n case 'Escape':\n if (this.open) {\n e.preventDefault();\n e.stopPropagation();\n this.cancelFetch();\n if (this.loading === 'loading') this.loading = 'idle';\n this.close();\n } else if (this.value) {\n e.preventDefault();\n e.stopPropagation();\n this.clear();\n }\n return;\n case 'Home':\n case 'End':\n case 'ArrowLeft':\n case 'ArrowRight':\n this.active = -1;\n return;\n }\n }\n\n /** Implicit submission: click the default button, or submit when there is none. */\n private submit(form: HTMLFormElement): void {\n const button = [...form.elements].find(\n (el): el is HTMLButtonElement | HTMLInputElement =>\n (el instanceof HTMLButtonElement || el instanceof HTMLInputElement) &&\n (el.type === 'submit' || el.type === 'image'),\n );\n if (button) {\n if (!button.disabled) button.click();\n return;\n }\n form.requestSubmit();\n }\n\n private onBlur(): void {\n this.cancelFetch();\n if (this.loading === 'loading') this.loading = 'idle';\n this.close();\n this.commit();\n }\n\n private onOptionClick(e: MouseEvent): void {\n const li = (e.target as Element).closest<HTMLElement>('[role=\"option\"]');\n if (!li) return;\n this.choose(Number(li.dataset.index));\n }\n\n /* ---------- status ---------- */\n\n /** The visible note in the popup, and what the live region says. */\n private get note(): { visible: string; spoken: string } {\n if (this.loading === 'loading' && !this.shown.length)\n return { visible: 'Loading suggestions…', spoken: 'Loading suggestions' };\n if (this.loading === 'error')\n return { visible: \"Couldn't load suggestions\", spoken: \"Couldn't load suggestions\" };\n const n = this.shown.length;\n if (!n) return { visible: 'No suggestions', spoken: 'No suggestions' };\n if (this.total > n)\n return {\n visible: `Showing ${count(n)} of ${count(this.total)}. Type more to narrow them.`,\n spoken: `${count(n)} of ${count(this.total)} suggestions`,\n };\n return { visible: '', spoken: `${count(n)} suggestion${n === 1 ? '' : 's'}` };\n }\n\n private scheduleAnnouncement(): void {\n clearTimeout(this.announceTimer);\n const text = this.open ? this.note.spoken : '';\n if (!text) {\n this.lastAnnounced = '';\n return;\n }\n if (text === this.lastAnnounced) return;\n this.announceTimer = setTimeout(() => {\n const now = this.open ? this.note.spoken : '';\n if (!now || now === this.lastAnnounced) return;\n this.lastAnnounced = now;\n this.announcement = now;\n clearTimeout(this.clearTimer);\n this.clearTimer = setTimeout(() => (this.announcement = ''), CLEAR_MS);\n }, comboboxTiming.announce);\n }\n\n /* ---------- lifecycle ---------- */\n\n protected override willUpdate(changed: PropertyValues): void {\n if (!this.label.trim()) this.warnOnce('label', 'set label: the field needs a visible label.');\n if (changed.has('selected') && this.selected !== this.ownSelected) {\n // Set by the app: show it.\n const s = this.selected as ComboboxItem | string | null;\n const e = s === null || s === undefined ? null : toEntry(s);\n this.selected = this.ownSelected = e ? e.raw : null;\n if (e) this.value = this.ownValue = e.label;\n this.committed = { value: this.value, item: this.selected };\n } else if (changed.has('value') && this.value !== this.ownValue) {\n this.value = this.ownValue = String(this.value ?? '');\n if (this.selected && this.value !== normalize(this.selected.label ?? this.selected.value))\n this.selected = this.ownSelected = null;\n this.committed = { value: this.value, item: this.selected };\n }\n if (changed.has('src') || changed.has('transform')) {\n this.cache.clear();\n this.remoteQuery = undefined;\n }\n if (\n this.open &&\n (changed.has('items') || changed.has('childEntries') || changed.has('maxResults'))\n )\n this.refresh();\n if (this.open && this.active >= this.shown.length) this.active = -1;\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n // The field may hold typed text the last render did not know about.\n const field = this.input;\n if (field && field.value !== this.value) field.value = this.value;\n if (!this.started) {\n this.started = true;\n this.updateForm();\n return;\n }\n if (\n changed.has('value') ||\n changed.has('selected') ||\n changed.has('required') ||\n changed.has('mustChoose')\n )\n this.updateForm();\n if (\n changed.has('open') ||\n changed.has('shown') ||\n changed.has('total') ||\n changed.has('loading')\n )\n this.scheduleAnnouncement();\n if (changed.has('active') && this.active >= 0) this.reveal();\n }\n\n /** Scroll the active suggestion into view inside the popup (not the page). */\n private reveal(): void {\n const popup = this.renderRoot.querySelector<HTMLElement>('.popup');\n const opt = this.renderRoot.querySelector<HTMLElement>(`#${this.uid}-opt-${this.active}`);\n if (!popup || !opt) return;\n const top = opt.offsetTop;\n const bottom = top + opt.offsetHeight;\n if (top < popup.scrollTop) popup.scrollTop = top;\n else if (bottom > popup.scrollTop + popup.clientHeight)\n popup.scrollTop = bottom - popup.clientHeight;\n }\n\n /* ---------- render ---------- */\n\n private marked(label: string, q: string) {\n if (!q) return label;\n const { text, map } = foldMap(label);\n const parts: unknown[] = [];\n let last = 0;\n let from = 0;\n for (let i = text.indexOf(q); i !== -1; i = text.indexOf(q, from)) {\n const s = map[i]!;\n const end = map[i + q.length]!;\n if (s > last) parts.push(label.slice(last, s));\n parts.push(html`<mark>${label.slice(s, end)}</mark>`);\n last = end;\n from = i + q.length;\n }\n parts.push(label.slice(last));\n return parts;\n }\n\n protected override render() {\n const id = this.uid;\n const label = this.label.trim();\n const off = this.disabled || this.formDisabled;\n const expanded = this.open && this.shown.length > 0;\n const note = this.open ? this.note.visible : '';\n const q = this.query.folded;\n return html`<label class=\"label\" part=\"label\" id=\"${id}-label\" for=\"${id}-input\"\n >${label}</label\n >\n <div class=\"field\">\n <input\n id=\"${id}-input\"\n class=\"input\"\n part=\"input\"\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${expanded ? 'true' : 'false'}\n aria-controls=\"${id}-listbox\"\n aria-activedescendant=${expanded && this.active >= 0 ? `${id}-opt-${this.active}` : nothing}\n aria-describedby=${this.description ? `${id}-description` : nothing}\n aria-required=${this.required ? 'true' : nothing}\n aria-invalid=${this.invalidShown ? 'true' : nothing}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n placeholder=${this.placeholder || nothing}\n .value=${this.value}\n ?disabled=${off}\n @input=${this.onInput}\n @keydown=${this.onKeydown}\n @blur=${this.onBlur}\n @change=${(e: Event) => e.stopPropagation()}\n @select=${(e: Event) => e.stopPropagation()}\n /><button\n type=\"button\"\n class=\"clear\"\n part=\"clear\"\n aria-label=\"Clear ${label}\"\n ?hidden=${!this.value || off}\n @mousedown=${(e: MouseEvent) => e.preventDefault()}\n @click=${this.clear}\n >\n ${CLEAR_ICON}\n </button>\n <div\n class=\"popup\"\n part=\"popup\"\n ?hidden=${!this.open || (!this.shown.length && !note)}\n @mousedown=${(e: MouseEvent) => e.preventDefault()}\n >\n <ul\n id=\"${id}-listbox\"\n class=\"listbox\"\n role=\"listbox\"\n aria-labelledby=\"${id}-label\"\n tabindex=\"-1\"\n ?hidden=${!expanded}\n @click=${this.onOptionClick}\n >\n ${\n expanded\n ? this.shown.map(\n (e, i) =>\n html`<li\n id=\"${id}-opt-${i}\"\n class=\"option\"\n part=\"option\"\n role=\"option\"\n data-index=${i}\n aria-selected=${i === this.active ? 'true' : 'false'}\n aria-disabled=${e.disabled ? 'true' : nothing}\n >\n <span class=\"option-label\">${this.marked(e.label, q)}</span>${\n e.description\n ? html`<span class=\"option-description\">${e.description}</span>`\n : nothing\n }\n </li>`,\n )\n : nothing\n }\n </ul>\n <p class=\"message\" ?hidden=${!note}>${note}</p>\n </div>\n </div>\n <p class=\"description\" part=\"description\" id=\"${id}-description\" ?hidden=${!this.description}>\n ${this.description}\n </p>\n <span class=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n >${this.announcement}</span\n >`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibCombobox } from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D,EAAA,WAAA,SAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,SAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,WAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GACNnD,EAAA,CAAAE,EAAM,CAAA,GAAAiD,EAAA,WAAA,gBAAA,KAAA,CAAA,GChZT3C,EAAO,mBAAmB2C,CAAc"}
@@ -1,25 +1,35 @@
1
- import { a as e, f as t, i as n, m as r, n as i, o as a, p as o, r as s, t as c } from "./chunks/UvalibElement-BnI-eRRR.js";
2
- import { n as l, t as u } from "./chunks/static-html-1mTAG6nS.js";
1
+ import { a as e, f as t, i as n, m as r, n as i, o as a, p as o, r as s, t as c } from "./chunks/UvalibElement-pGONDAwB.js";
2
+ import { n as l, t as u } from "./chunks/static-html-C1rhtCHu.js";
3
3
  import { a as d } from "./chunks/analytics-DTTihuBD.js";
4
- import { a as f, i as p, n as m, r as h, t as g } from "./chunks/source-children-RuAec527.js";
5
- import { t as _ } from "./chunks/accessible-GqhVn5_H.js";
4
+ import { n as f, t as p } from "./chunks/inline-copy-BANQSMIR.js";
5
+ import { n as m, r as h, t as g } from "./chunks/source-children-BHsDwCvL.js";
6
+ import { t as _ } from "./chunks/accessible-DJv7YOtS.js";
6
7
  // src/components/uvalib-contents/UvalibContents.ts
7
8
  var v = (e) => {
8
9
  let t = e?.trim().toLowerCase();
9
10
  return t === "page" || t === "true" ? "page" : t === "location" ? "location" : void 0;
10
- }, y = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), b = "Contents", x = "64rem", S = 2, C = 0, w = (e) => `
11
+ }, y = (e) => JSON.stringify(e, (e, t) => e === "nodes" ? void 0 : t), b = "Contents", x = "64rem", S = 2, C = "2-3", w = 2, T = 0, E = {
12
+ childList: !0,
13
+ characterData: !0,
14
+ subtree: !0
15
+ }, D = (e) => e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "section", O = (e) => {
16
+ let t = "", n = (e) => {
17
+ e instanceof Element && e.getAttribute("aria-hidden") === "true" || (e.nodeType === Node.TEXT_NODE ? t += e.textContent : e.childNodes.forEach(n));
18
+ };
19
+ return n(e), m(t);
20
+ }, k = (e) => `
11
21
  ${e} { display: block; }
12
22
  ${e} :is(ol, ul) { list-style: none; margin: 0; padding: 0; }
13
23
  ${e} li :is(ol, ul) { padding-inline-start: 1rem; }
14
24
  ${e}[hidden], ${e} [hidden] { display: none !important; }
15
- `, T = o(w(":host")), E = (e) => e.origin + (e.pathname.replace(/\/index\.html?$/i, "/").replace(/(.)\/$/, "$1") || "/"), D = (e) => {
25
+ `, A = o(k(":host")), j = (e) => e.origin + (e.pathname.replace(/\/index\.html?$/i, "/").replace(/(.)\/$/, "$1") || "/"), M = (e) => {
16
26
  let t = new URLSearchParams(e.search);
17
27
  return t.sort(), t.toString();
18
- }, O = class extends c {
28
+ }, N = class extends c {
19
29
  static {
20
30
  this.styles = [
21
31
  _,
22
- T,
32
+ A,
23
33
  t`
24
34
  :host {
25
35
  font-size: 1rem;
@@ -134,7 +144,7 @@ var v = (e) => {
134
144
  ];
135
145
  }
136
146
  constructor() {
137
- super(), this.label = b, this.headingLevel = S, this.collapseBelow = x, this.open = !1, this.sticky = !1, this.childItems = [], this.ordered = !1, this.narrow = !1, this.here = "", this.warned = /* @__PURE__ */ new Set(), this.panelId = `uvalib-contents-${++C}`, this.onLocation = () => {
147
+ super(), this.label = b, this.headingLevel = S, this.collapseBelow = x, this.open = !1, this.sticky = !1, this.levels = C, this.min = w, this.headingItems = [], this.headingsQueued = !1, this.scrolledToHash = !1, this.childItems = [], this.ordered = !1, this.narrow = !1, this.here = "", this.warned = /* @__PURE__ */ new Set(), this.panelId = `uvalib-contents-${++T}`, this.onLocation = () => {
138
148
  this.here = this.ownerDocument.defaultView?.location.href ?? "";
139
149
  }, this.listening = !1, this.onWidth = () => {
140
150
  this.narrow = !!this.mql?.matches;
@@ -143,7 +153,7 @@ var v = (e) => {
143
153
  createRenderRoot() {
144
154
  let e = super.createRenderRoot();
145
155
  if (e instanceof ShadowRoot && this.noStyle) {
146
- let t = T.styleSheet;
156
+ let t = A.styleSheet;
147
157
  t && (e.adoptedStyleSheets = [t]);
148
158
  }
149
159
  return e;
@@ -151,15 +161,15 @@ var v = (e) => {
151
161
  connectedCallback() {
152
162
  if (super.connectedCallback(), this.lightDom && this.noStyle) {
153
163
  let e = this.getRootNode();
154
- s(`${this.localName}::structure`, o(w(this.localName)), {
164
+ s(`${this.localName}::structure`, o(k(this.localName)), {
155
165
  root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
156
166
  scope: !1
157
167
  });
158
168
  }
159
- this.here = this.ownerDocument.defaultView?.location.href ?? "", this.listenLocation(!0), this.watchWidth();
169
+ this.here = this.ownerDocument.defaultView?.location.href ?? "", this.listenLocation(!0), this.watchWidth(), this.hasUpdated && this.refresh();
160
170
  }
161
171
  disconnectedCallback() {
162
- super.disconnectedCallback(), this.listenLocation(!1), this.mql?.removeEventListener("change", this.onWidth), this.mql = void 0;
172
+ super.disconnectedCallback(), this.headingsObserver?.disconnect(), this.headingsScope = void 0, this.listenLocation(!1), this.mql?.removeEventListener("change", this.onWidth), this.mql = void 0;
163
173
  }
164
174
  listenLocation(e) {
165
175
  let t = this.ownerDocument.defaultView;
@@ -180,6 +190,69 @@ var v = (e) => {
180
190
  warnOnce(e, t) {
181
191
  this.warned.has(e) || (this.warned.add(e), console.warn(`${this.localName}: ${t}`));
182
192
  }
193
+ refresh() {
194
+ let e = m(this.headingsFrom), t = null;
195
+ if (e) {
196
+ let n = this.getRootNode(), r = n instanceof Document || n instanceof ShadowRoot ? n : this.ownerDocument;
197
+ try {
198
+ t = r.querySelector(e);
199
+ } catch {
200
+ t = null;
201
+ }
202
+ !t && this.ownerDocument.readyState === "loading" ? this.ownerDocument.addEventListener("DOMContentLoaded", () => this.refresh(), { once: !0 }) : t || this.warnOnce("headings-from", `no element matches headings-from="${e}".`);
203
+ }
204
+ t !== this.headingsScope && (this.headingsScope = t, this.headingsObserver?.disconnect(), t && (this.headingsObserver ??= new MutationObserver(() => this.queueHeadings()), this.headingsObserver.observe(t, E)));
205
+ let n = t ? this.fromHeadings(t) : [];
206
+ y(n) !== y(this.headingItems) && (this.headingItems = n);
207
+ }
208
+ queueHeadings() {
209
+ this.headingsQueued || (this.headingsQueued = !0, queueMicrotask(() => {
210
+ this.headingsQueued = !1, this.isConnected && this.refresh();
211
+ }));
212
+ }
213
+ get headingRange() {
214
+ let e = /^\s*([1-6])\s*(?:-\s*([1-6]))?\s*$/.exec(String(this.levels ?? ""));
215
+ if (!e) return this.warnOnce("levels", `ignoring levels="${this.levels}" (use a level, 2, or a range, 2-3).`), [2, 3];
216
+ let t = Number(e[1]), n = e[2] ? Number(e[2]) : t;
217
+ return [Math.min(t, n), Math.max(t, n)];
218
+ }
219
+ fromHeadings(e) {
220
+ let [t, n] = this.headingRange, r = Array.from({ length: n - t + 1 }, (e, n) => `h${t + n}`).join(", "), i = e.getRootNode(), a = [], o = [], s = [];
221
+ for (let t of e.querySelectorAll(r)) {
222
+ if (this.contains(t) || t.closest("[aria-hidden=\"true\"]")) continue;
223
+ let e = O(t);
224
+ if (!e) continue;
225
+ if (!t.id) {
226
+ let n = D(e), r = n;
227
+ for (let e = 2; i.getElementById(r); e++) r = `${n}-${e}`;
228
+ t.id = r, s.push(t);
229
+ }
230
+ let n = Number(t.localName.slice(1)), r = {
231
+ label: e,
232
+ href: `#${t.id}`,
233
+ children: []
234
+ };
235
+ for (; o.length && o[o.length - 1].level >= n;) o.pop();
236
+ (o.length ? o[o.length - 1].entry.children : a).push(r), o.push({
237
+ level: n,
238
+ entry: r
239
+ });
240
+ }
241
+ this.scrollToAdded(s);
242
+ let c = Number.isFinite(Number(this.min)) ? Math.trunc(Number(this.min)) : w;
243
+ return a.length >= c ? a : [];
244
+ }
245
+ scrollToAdded(e) {
246
+ if (this.scrolledToHash || !e.length) return;
247
+ let t = this.ownerDocument.defaultView?.location.hash.slice(1);
248
+ if (!t) return;
249
+ let n = t;
250
+ try {
251
+ n = decodeURIComponent(t);
252
+ } catch {}
253
+ let r = e.find((e) => e.id === n);
254
+ r && (this.scrolledToHash = !0, requestAnimationFrame(() => r.scrollIntoView()));
255
+ }
183
256
  read(e) {
184
257
  let t = null;
185
258
  for (let n of e) if (n instanceof Element && (t = n.matches("ol, ul") ? n : n.querySelector("ol, ul"), t)) break;
@@ -241,7 +314,10 @@ var v = (e) => {
241
314
  };
242
315
  return delete i.href, delete i.mark, i;
243
316
  });
244
- return t(this.items ? this.fromItems(this.items) : this.childItems);
317
+ return t(this.items ? this.fromItems(this.items) : this.fromHeadingsNow ? this.headingItems : this.childItems);
318
+ }
319
+ get fromHeadingsNow() {
320
+ return !this.items && !this.childItems.length && !!this.headingItems.length;
245
321
  }
246
322
  currentOf(e) {
247
323
  let t = [], n = (e) => e.forEach((e) => (t.push(e), n(e.children)));
@@ -261,11 +337,11 @@ var v = (e) => {
261
337
  } catch {
262
338
  return r;
263
339
  }
264
- let c = (e) => new URL(e, e.startsWith("#") ? s.href : a), l = E(s), u = D(s), d = t.flatMap((e) => {
340
+ let c = (e) => new URL(e, e.startsWith("#") ? s.href : a), l = j(s), u = M(s), d = t.flatMap((e) => {
265
341
  if (e.href === void 0) return [];
266
342
  try {
267
343
  let t = c(e.href);
268
- return E(t) !== l || t.search && D(t) !== u ? [] : [{
344
+ return j(t) !== l || t.search && M(t) !== u ? [] : [{
269
345
  e,
270
346
  hash: t.hash
271
347
  }];
@@ -310,7 +386,7 @@ var v = (e) => {
310
386
  this.dispatchEvent(r) || e.preventDefault();
311
387
  }
312
388
  willUpdate(e) {
313
- e.has("collapseBelow") && this.isConnected && this.watchWidth();
389
+ e.has("collapseBelow") && this.isConnected && this.watchWidth(), (e.has("headingsFrom") || e.has("levels") || e.has("min")) && this.isConnected && this.refresh();
314
390
  }
315
391
  updated(e) {
316
392
  super.updated(e), this.toggleAttribute("data-narrow", this.narrow), this.toggleAttribute("data-empty", !this.entries.length), this.reveal();
@@ -339,7 +415,7 @@ var v = (e) => {
339
415
  ${o}${e.children.length ? this.renderList(e.children, t, n + 1) : a}
340
416
  </li>`;
341
417
  });
342
- return this.ordered ? l`<ol role="list">
418
+ return this.ordered || this.fromHeadingsNow ? l`<ol role="list">
343
419
  ${r}
344
420
  </ol>` : l`<ul role="list">
345
421
  ${r}
@@ -364,18 +440,21 @@ var v = (e) => {
364
440
  }
365
441
  };
366
442
  // src/components/uvalib-contents/uvalib-contents.ts
367
- i([e({ type: String })], O.prototype, "label", void 0), i([e({
443
+ i([e({ type: String })], N.prototype, "label", void 0), i([e({
368
444
  type: Number,
369
445
  attribute: "heading-level"
370
- })], O.prototype, "headingLevel", void 0), i([e({ type: String })], O.prototype, "current", void 0), i([e({
446
+ })], N.prototype, "headingLevel", void 0), i([e({ type: String })], N.prototype, "current", void 0), i([e({
371
447
  type: String,
372
448
  attribute: "collapse-below"
373
- })], O.prototype, "collapseBelow", void 0), i([e({
449
+ })], N.prototype, "collapseBelow", void 0), i([e({
374
450
  type: Boolean,
375
451
  reflect: !0
376
- })], O.prototype, "open", void 0), i([e({
452
+ })], N.prototype, "open", void 0), i([e({
377
453
  type: Boolean,
378
454
  reflect: !0
379
- })], O.prototype, "sticky", void 0), i([e({ attribute: !1 })], O.prototype, "items", void 0), i([n()], O.prototype, "childItems", void 0), i([n()], O.prototype, "ordered", void 0), i([n()], O.prototype, "narrow", void 0), i([n()], O.prototype, "here", void 0), r("uvalib-contents", O);
455
+ })], N.prototype, "sticky", void 0), i([e({ attribute: !1 })], N.prototype, "items", void 0), i([e({
456
+ type: String,
457
+ attribute: "headings-from"
458
+ })], N.prototype, "headingsFrom", void 0), i([e({ type: String })], N.prototype, "levels", void 0), i([e({ type: Number })], N.prototype, "min", void 0), i([n()], N.prototype, "headingItems", void 0), i([n()], N.prototype, "childItems", void 0), i([n()], N.prototype, "ordered", void 0), i([n()], N.prototype, "narrow", void 0), i([n()], N.prototype, "here", void 0), r("uvalib-contents", N);
380
459
 
381
460
  //# sourceMappingURL=uvalib-contents.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uvalib-contents.js","names":["unsafeCSS","nothing","unsafeStatic","_decorate","property","state","n","i","r$1","define","__decorate","A","r","installLightDomStyles","UvalibElement","u","s","trackEvent","langDir","inlineCopy","normalize","safeHref","SourceChildren","accessible","markOf","v","entriesKey","items","k","DEFAULT_LABEL","DEFAULT_COLLAPSE","DEFAULT_LEVEL","uid","structuralRules","host","shadowStructure","pageKey","queryKey","q","UvalibContents","nodes","root","sheet","node","win","on","nav","targets","type","below","kind","message","list","ordered","out","li","sub","c","a","x","label","children","entry","mark","own","item","copy","base","clean","e","rest","flat","walk","l","entries","found","marked","m","here","target","resolve","h","key","query","same","page","section","level","go","changed","panel","links","p","current","text","collapsed","headline"],"sources":["../src/components/uvalib-contents/UvalibContents.ts","../src/components/uvalib-contents/uvalib-contents.ts"],"sourcesContent":["import { css, nothing, unsafeCSS, type PropertyValues, type TemplateResult } from 'lit';\nimport { html, unsafeStatic } from 'lit/static-html.js';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { inlineCopy, langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One entry of the contents: its text, a link (optional for a group label) and sub-entries. */\nexport interface ContentsItem {\n label: string;\n href?: string;\n children?: ContentsItem[];\n}\n\n/**\n * An entry as drawn: `mark` is a valid `aria-current` the author gave its source link;\n * `lang`/`dir` come from the link and `itemLang`/`itemDir` from the `<li>`. `nodes` is a safe inline copy of the label (`em`, `cite`, `code`, `abbr`…),\n * cloned for each render; `rich` describes it, so two reads can be compared.\n */\ninterface Entry {\n label: string;\n href?: string;\n children: Entry[];\n mark?: Current;\n lang?: string;\n dir?: string;\n itemLang?: string;\n itemDir?: string;\n rich?: string;\n nodes?: Node[];\n}\n\n/** An `aria-current` value an author may give: `page`, `location`, or `true` (a page). */\nconst markOf = (v: string | null | undefined): Current | undefined => {\n const t = v?.trim().toLowerCase();\n return t === 'page' || t === 'true' ? 'page' : t === 'location' ? 'location' : undefined;\n};\n\n/** Compare two reads, leaving out the copied nodes (their `rich` key stands for them). */\nconst entriesKey = (items: Entry[]) =>\n JSON.stringify(items, (k, v: unknown) => (k === 'nodes' ? undefined : v));\n\ntype Current = 'page' | 'location';\n\nconst DEFAULT_LABEL = 'Contents';\nconst DEFAULT_COLLAPSE = '64rem';\nconst DEFAULT_LEVEL = 2;\nlet uid = 0;\n\n/**\n * The rules kept with `no-style`: unmarked lists, the disclosure's closed panel hidden, and\n * `[hidden]` hides. `host` is `:host` (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} :is(ol, ul) { list-style: none; margin: 0; padding: 0; }\n ${host} li :is(ol, ul) { padding-inline-start: 1rem; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** A comparable form of a URL: origin and path, without a trailing slash or index.html. */\nconst pageKey = (u: URL) =>\n u.origin + (u.pathname.replace(/\\/index\\.html?$/i, '/').replace(/(.)\\/$/, '$1') || '/');\n\n/** The query string as a sorted, comparable form (`?b=2&a=1` is `?a=1&b=2`). */\nconst queryKey = (u: URL) => {\n const q = new URLSearchParams(u.search);\n q.sort();\n return q.toString();\n};\n\n/**\n * Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a\n * `<nav>` landmark (named by `label`, \"Contents\" by default) with the label as a visible\n * headline, and a nested list of links with dividers between the top-level entries and a bar\n * beside each nested level.\n *\n * Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>`\n * (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any\n * depth. Other children (a heading) are ignored. The list follows changes to the children.\n * Apps set the `items` property instead (`{ label, href?, children? }`, winning over the\n * children while set).\n *\n * The current entry gets `aria-current`: `page` for the link to this page, `location` for the\n * link to the section of it in the URL's hash. It is found from the page URL (path, and hash\n * for in-page sections), followed through same-document navigations (`hashchange`,\n * `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like\n * the links). An entry whose href has a query string matches only that query (`?part=2`); one\n * without matches the page whatever its query. Hash-only hrefs are places on that page. With\n * `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is\n * used instead, the first of each kind. `lang` and `dir` on the source links and items, and\n * inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element,\n * never as HTML), are kept.\n *\n * On narrow screens the list collapses into a disclosure: the headline becomes a button with\n * `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents\n * does on phones, so the text comes first) until the reader opens it, or while the `open`\n * attribute is set; opening it shows the current entry. Narrow means the viewport\n * (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is\n * always far narrower than 64rem, so a container query could not tell a phone from a\n * desktop. `sticky` keeps it in view in a sidebar on wide\n * screens; a list longer than the window then scrolls, and the current entry is scrolled\n * into view inside it (never the page).\n *\n * Single-page apps: the list is drawn from copies of the children, so a router's own click\n * handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in\n * place; hash links need nothing.\n *\n * @tagname uvalib-contents\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), and opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' | 'close']`; never the label or URL. Bubbles and is composed.\n * @fires uvalib-contents-navigate - A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssprop [--uvalib-contents-sticky-top=1rem] - With `sticky`: the gap kept above it.\n * @cssprop [--uvalib-contents-max-height=none] - The list's maximum height on wide screens (it scrolls beyond it); with `sticky`, the window's height less twice the sticky gap.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-brand-blue=#232d4b] - The current entry's bar.\n * @cssprop [--uva-brand-orange=#e57200] - The nested levels' bar.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Text and current entry colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: text and current entry (else `--uva-grey-darkest`).\n * @cssprop --uva-color-link - Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`).\n * @cssprop --uva-color-current - Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`).\n * @cssprop --uva-color-border - Dark-mode role token: dividers (else #dadada).\n * @cssprop --uva-color-control-border - Dark-mode role token: the button's border (else #808080).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibContents extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n :host([sticky]:not([data-narrow])) {\n position: sticky;\n top: var(--uvalib-contents-sticky-top, 1rem);\n align-self: start;\n }\n .headline {\n margin: 0 0 0.5rem;\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .panel {\n max-height: var(--uvalib-contents-max-height, none);\n overflow-y: auto;\n overscroll-behavior: contain;\n }\n :host([sticky]:not([data-narrow])) .panel {\n max-height: var(\n --uvalib-contents-max-height,\n calc(100dvh - 2 * var(--uvalib-contents-sticky-top, 1rem) - 3rem)\n );\n }\n :host([data-narrow]) .panel {\n max-height: none;\n overflow: visible;\n }\n .panel > :is(ol, ul) {\n border-block: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n .panel > :is(ol, ul) > li + li {\n border-top: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n li :is(ol, ul) {\n margin: 0 0 0.5rem 0.75rem;\n padding: 0;\n border-inline-start: 2px solid var(--uva-color-current, var(--uva-brand-orange, #e57200));\n }\n a,\n .group {\n display: block;\n padding: 0.5rem 0.75rem 0.5rem calc(0.75rem + 4px);\n }\n li li > :is(a, .group) {\n padding-block: 0.25rem;\n }\n .group {\n font-weight: 700;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n a[aria-current] {\n padding-inline-start: 0.75rem;\n border-inline-start: 4px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n color: inherit;\n font-weight: 700;\n }\n .panel a:focus-visible {\n outline-offset: -3px;\n }\n .toggle {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.75rem;\n box-sizing: border-box;\n width: 100%;\n min-height: 44px;\n margin: 0;\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-weight: 700;\n text-align: start;\n cursor: pointer;\n }\n .toggle::after {\n content: '';\n flex: none;\n width: 0.5em;\n height: 0.5em;\n margin-block-end: 0.25em;\n border-inline-end: 2px solid currentColor;\n border-block-end: 2px solid currentColor;\n transform: rotate(45deg);\n }\n .toggle[aria-expanded='true']::after {\n margin-block: 0.25em 0;\n transform: rotate(225deg);\n }\n :host([data-narrow]) .headline {\n margin-bottom: 0;\n }\n :host([data-narrow]) .panel {\n margin-top: 0.5rem;\n }\n `,\n ];\n\n /** Accessible name of the navigation landmark, and its visible headline. */\n @property({ type: String }) label = DEFAULT_LABEL;\n\n /** The headline's level (2 to 6), for the page's outline. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel = DEFAULT_LEVEL;\n\n /**\n * The URL of the current entry (resolved like the links), for apps whose route is not the\n * page URL. Unset: the page URL, followed through same-document navigations.\n */\n @property({ type: String }) current?: string;\n\n /**\n * The viewport width at and below which the list collapses into a disclosure: a CSS length\n * (`64rem`, `800px`). `0` or `none` never collapses.\n */\n @property({ type: String, attribute: 'collapse-below' }) collapseBelow = DEFAULT_COLLAPSE;\n\n /** Whether the collapsed disclosure is open (no effect on wide screens). Toggled by its button. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Keep it in view while the page scrolls (a sidebar), on wide screens. */\n @property({ type: Boolean, reflect: true }) sticky = false;\n\n /**\n * The entries as data, for apps that build them in JavaScript: `{ label, href?, children? }`.\n * Wins over the children while set; `undefined` goes back to them. Entries without a label\n * are skipped (with their children) with one console warning.\n */\n @property({ attribute: false }) items?: ContentsItem[];\n\n /** The entries read from the children. */\n @state() private childItems: Entry[] = [];\n /** The root list's element in the source (`ol` or `ul`). */\n @state() private ordered = false;\n @state() private narrow = false;\n /** The page URL, updated on same-document navigations. */\n @state() private here = '';\n\n private warned = new Set<string>();\n private readonly panelId = `uvalib-contents-${++uid}`;\n private mql?: MediaQueryList;\n /** What was last scrolled into view, so the list is not scrolled again on every update. */\n private scrolledTo?: string;\n\n constructor() {\n super();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n this.listenLocation(true);\n this.watchWidth();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.listenLocation(false);\n this.mql?.removeEventListener('change', this.onWidth);\n this.mql = undefined;\n }\n\n private onLocation = (): void => {\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n };\n\n private listening = false;\n private listenLocation(on: boolean): void {\n const win = this.ownerDocument.defaultView;\n if (!win || on === this.listening) return;\n this.listening = on;\n const nav = (win as Window & { navigation?: EventTarget }).navigation;\n const targets: [EventTarget, string][] = [\n [win, 'popstate'],\n [win, 'hashchange'],\n ...(nav ? [[nav, 'currententrychange'] as [EventTarget, string]] : []),\n ];\n for (const [t, type] of targets) {\n if (on) t.addEventListener(type, this.onLocation);\n else t.removeEventListener(type, this.onLocation);\n }\n }\n\n private onWidth = (): void => {\n this.narrow = !!this.mql?.matches;\n };\n\n /** Follow the viewport against `collapse-below`. */\n private watchWidth(): void {\n this.mql?.removeEventListener('change', this.onWidth);\n const win = this.ownerDocument.defaultView;\n const below = normalize(this.collapseBelow) || DEFAULT_COLLAPSE;\n this.mql =\n win && !/^(none|0+(\\.0*)?[a-z%]*)$/i.test(below)\n ? win.matchMedia(`(max-width: ${below})`)\n : undefined;\n if (this.mql?.media === 'not all') {\n this.warnOnce('collapse', `ignoring collapse-below=\"${below}\" (not a CSS length).`);\n this.mql = win?.matchMedia(`(max-width: ${DEFAULT_COLLAPSE})`);\n }\n this.mql?.addEventListener('change', this.onWidth);\n this.onWidth();\n }\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /** Read the entries from the first list among the children. */\n private read(nodes: Node[]): void {\n let list: Element | null = null;\n for (const n of nodes) {\n if (!(n instanceof Element)) continue;\n list = n.matches('ol, ul') ? n : n.querySelector('ol, ul');\n if (list) break;\n }\n const items = list ? this.parse(list) : [];\n const ordered = list?.localName === 'ol';\n if (ordered !== this.ordered) this.ordered = ordered;\n // Only a real change re-renders.\n if (entriesKey(items) !== entriesKey(this.childItems)) this.childItems = items;\n }\n\n private parse(list: Element): Entry[] {\n const out: Entry[] = [];\n for (const li of list.children) {\n if (li.localName !== 'li') continue;\n const sub = [...li.children].find((c) => c.matches('ol, ul'));\n const a = [...li.querySelectorAll('a[href]')].find((x) => x.closest('li') === li);\n // The entry's own text: the link's, or the item's without its sub-list.\n const label = normalize(\n a\n ? a.textContent\n : [...li.childNodes]\n .filter((c) => c !== sub)\n .map((c) => c.textContent)\n .join(' '),\n );\n const children = sub ? this.parse(sub) : [];\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children };\n if (a) entry.href = a.getAttribute('href')!;\n const mark = markOf(a?.getAttribute('aria-current'));\n if (mark) entry.mark = mark;\n const own = langDir(a);\n if (own.lang !== undefined) entry.lang = own.lang;\n if (own.dir) entry.dir = own.dir;\n const item = langDir(li);\n if (item.lang !== undefined) entry.itemLang = item.lang;\n if (item.dir) entry.itemDir = item.dir;\n const copy = inlineCopy(\n a ? a.childNodes : [...li.childNodes].filter((c) => c !== sub),\n this.ownerDocument,\n );\n if (copy.rich) {\n entry.rich = copy.key;\n entry.nodes = copy.nodes;\n }\n out.push(entry);\n }\n return out;\n }\n\n private fromItems(items: readonly ContentsItem[]): Entry[] {\n const out: Entry[] = [];\n for (const i of items) {\n const label = normalize(i?.label);\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children: this.fromItems(i.children ?? []) };\n if (i.href != null) entry.href = String(i.href);\n out.push(entry);\n }\n return out;\n }\n\n /** What is shown: `items` while set, else the children; unsafe hrefs made plain text. */\n private get entries(): Entry[] {\n const base = this.ownerDocument.baseURI;\n const clean = (list: Entry[]): Entry[] =>\n list.map((e) => {\n const children = clean(e.children);\n if (e.href === undefined || safeHref(e.href, base)) return { ...e, children };\n this.warnOnce(\n 'href',\n 'showing an entry as text: its href is not http(s), mailto, tel or relative.',\n );\n const rest: Entry = { ...e, children };\n delete rest.href;\n delete rest.mark;\n return rest;\n });\n return clean(this.items ? this.fromItems(this.items) : this.childItems);\n }\n\n /** The current entries: the page's and its section's. */\n private currentOf(entries: Entry[]): Map<Entry, Current> {\n const flat: Entry[] = [];\n const walk = (l: Entry[]) => l.forEach((e) => (flat.push(e), walk(e.children)));\n walk(entries);\n const found = new Map<Entry, Current>();\n // The author's marks, on links only (a group or an unsafe link has none): the first\n // `page` and the first `location`.\n const marked = flat.filter((e) => e.mark && e.href !== undefined);\n if (!this.current && marked.length) {\n for (const kind of ['page', 'location'] as const) {\n const e = marked.find((m) => m.mark === kind);\n if (e) found.set(e, kind);\n }\n return found;\n }\n const base = this.ownerDocument.baseURI;\n const here = this.here || base;\n let target: URL;\n try {\n // A hash-only href is a place on this page, whatever the base URL (about:srcdoc frames).\n const c = this.current || here;\n target = new URL(c, c.startsWith('#') ? here : base);\n } catch {\n return found;\n }\n // Entries' hash-only hrefs are places on the target page (the current URL, or `current`).\n const resolve = (h: string) => new URL(h, h.startsWith('#') ? target.href : base);\n const key = pageKey(target);\n const query = queryKey(target);\n const same = flat.flatMap((e) => {\n if (e.href === undefined) return [];\n try {\n const u = resolve(e.href);\n // An entry with a query names that query (?part=2); one without matches the page\n // whatever its query (tracking parameters).\n if (pageKey(u) !== key || (u.search && queryKey(u) !== query)) return [];\n return [{ e, hash: u.hash }];\n } catch {\n return [];\n }\n });\n const page = same.find((s) => !s.hash);\n if (page) found.set(page.e, 'page');\n const section = target.hash && same.find((s) => s.hash === target.hash);\n if (section) found.set(section.e, 'location');\n return found;\n }\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : DEFAULT_LEVEL;\n }\n\n private toggle(): void {\n this.open = !this.open;\n trackEvent(this, ['uvalib-contents', 'toggle', this.open ? 'open' : 'close']);\n }\n\n /**\n * A plain click on an entry fires a cancelable `uvalib-contents-navigate`; a router that\n * cancels it navigates itself (the click's default is prevented too).\n */\n private onClick(e: MouseEvent): void {\n const a = (e.target as Element | null)?.closest?.('a[href]');\n if (!a || !this.renderRoot.contains(a)) return;\n // Analytics: the entry's level (1 is the top), never its label or URL.\n const level = Number(a.getAttribute('data-level'));\n trackEvent(this, ['uvalib-contents', 'link-click', `level ${level}`, level]);\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)\n return;\n const go = new CustomEvent('uvalib-contents-navigate', {\n detail: { href: a.getAttribute('href'), level },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('collapseBelow') && this.isConnected) this.watchWidth();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.toggleAttribute('data-narrow', this.narrow);\n this.toggleAttribute('data-empty', !this.entries.length);\n this.reveal();\n }\n\n /** Scroll the list (never the page) so the current entry shows, once per entry and opening. */\n private reveal(): void {\n const panel = this.renderRoot.querySelector<HTMLElement>(`#${this.panelId}`);\n const links = panel ? [...panel.querySelectorAll<HTMLElement>('a[aria-current]')] : [];\n const a = links.find((l) => l.getAttribute('aria-current') === 'location') ?? links[0];\n if (!panel || !a || panel.hidden) return;\n const key = `${a.getAttribute('href')}|${this.narrow}|${this.open}`;\n if (key === this.scrolledTo) return;\n this.scrolledTo = key;\n if (panel.scrollHeight <= panel.clientHeight) return;\n const p = panel.getBoundingClientRect();\n const r = a.getBoundingClientRect();\n if (r.top >= p.top && r.bottom <= p.bottom) return;\n panel.scrollTop += r.top - p.top - (p.height - r.height) / 2;\n }\n\n private renderList(\n entries: Entry[],\n current: Map<Entry, Current>,\n level: number,\n ): TemplateResult {\n const items = entries.map((e) => {\n const mark = current.get(e);\n // Fresh copies of the label's inline markup each render (a node can be in one place).\n const text = e.nodes ? e.nodes.map((n) => n.cloneNode(true)) : e.label;\n const own =\n e.href !== undefined\n ? html`<a\n href=${e.href}\n data-level=${level}\n aria-current=${mark ?? nothing}\n lang=${e.lang ?? nothing}\n dir=${e.dir ?? nothing}\n >${text}</a\n >`\n : html`<span class=\"group\" lang=${e.lang ?? nothing} dir=${e.dir ?? nothing}\n >${text}</span\n >`;\n return html`<li role=\"listitem\" lang=${e.itemLang ?? nothing} dir=${e.itemDir ?? nothing}>\n ${own}${e.children.length ? this.renderList(e.children, current, level + 1) : nothing}\n </li>`;\n });\n // role=\"list\": Safari drops the list semantics of a list styled without markers.\n return this.ordered\n ? html`<ol role=\"list\">\n ${items}\n </ol>`\n : html`<ul role=\"list\">\n ${items}\n </ul>`;\n }\n\n protected override render() {\n const entries = this.entries;\n const label = normalize(this.label) || DEFAULT_LABEL;\n const h = unsafeStatic(`h${this.level}`);\n const collapsed = this.narrow && !this.open;\n const headline = this.narrow\n ? html`<button\n type=\"button\"\n class=\"toggle\"\n aria-expanded=${this.open ? 'true' : 'false'}\n aria-controls=${this.panelId}\n @click=${this.toggle}\n >\n ${label}\n </button>`\n : label;\n // The heading's tag changes the inner template only: the <nav> (in light DOM, a child\n // of the element) is never replaced.\n return html`<nav aria-label=${label} ?hidden=${!entries.length} @click=${this.onClick}>\n ${html`<${h} class=\"headline\">${headline}</${h}>`}\n <div class=\"panel\" id=${this.panelId} ?hidden=${collapsed}>\n ${this.renderList(entries, this.currentOf(entries), 1)}\n </div>\n </nav>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibContents } from './UvalibContents.js';\n\ndefine('uvalib-contents', UvalibContents);\n"],"mappings":";;;;;;AAoCA,IAAMwB,KAAU,MAAsD;CACpE,IAAM,IAA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decorate","A","r","installLightDomStyles","UvalibElement","u","s","trackEvent","langDir","inlineCopy","normalize","safeHref","SourceChildren","accessible","markOf","v","entriesKey","items","k","DEFAULT_LABEL","DEFAULT_COLLAPSE","DEFAULT_LEVEL","DEFAULT_LEVELS","DEFAULT_MIN","uid","HEADINGS","slugify","text","headingText","walk","h","structuralRules","host","shadowStructure","pageKey","queryKey","q","UvalibContents","nodes","root","sheet","node","win","on","nav","targets","type","below","kind","message","sel","scope","finder","m","a","b","lo","hi","selector","top","open","added","label","base","id","level","entry","min","hash","list","ordered","out","li","sub","c","x","children","mark","own","item","copy","clean","e","rest","flat","l","entries","found","marked","here","target","resolve","key","query","same","page","section","go","changed","panel","links","p","current","collapsed","headline"],"sources":["../src/components/uvalib-contents/UvalibContents.ts","../src/components/uvalib-contents/uvalib-contents.ts"],"sourcesContent":["import { css, nothing, unsafeCSS, type PropertyValues, type TemplateResult } from 'lit';\nimport { html, unsafeStatic } from 'lit/static-html.js';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { inlineCopy, langDir } from '../../base/inline-copy.js';\nimport { normalize, safeHref, SourceChildren } from '../../base/source-children.js';\nimport { accessible } from '../../styles/accessible.js';\n\n/** One entry of the contents: its text, a link (optional for a group label) and sub-entries. */\nexport interface ContentsItem {\n label: string;\n href?: string;\n children?: ContentsItem[];\n}\n\n/**\n * An entry as drawn: `mark` is a valid `aria-current` the author gave its source link;\n * `lang`/`dir` come from the link and `itemLang`/`itemDir` from the `<li>`. `nodes` is a safe inline copy of the label (`em`, `cite`, `code`, `abbr`…),\n * cloned for each render; `rich` describes it, so two reads can be compared.\n */\ninterface Entry {\n label: string;\n href?: string;\n children: Entry[];\n mark?: Current;\n lang?: string;\n dir?: string;\n itemLang?: string;\n itemDir?: string;\n rich?: string;\n nodes?: Node[];\n}\n\n/** An `aria-current` value an author may give: `page`, `location`, or `true` (a page). */\nconst markOf = (v: string | null | undefined): Current | undefined => {\n const t = v?.trim().toLowerCase();\n return t === 'page' || t === 'true' ? 'page' : t === 'location' ? 'location' : undefined;\n};\n\n/** Compare two reads, leaving out the copied nodes (their `rich` key stands for them). */\nconst entriesKey = (items: Entry[]) =>\n JSON.stringify(items, (k, v: unknown) => (k === 'nodes' ? undefined : v));\n\ntype Current = 'page' | 'location';\n\nconst DEFAULT_LABEL = 'Contents';\nconst DEFAULT_COLLAPSE = '64rem';\nconst DEFAULT_LEVEL = 2;\nconst DEFAULT_LEVELS = '2-3';\nconst DEFAULT_MIN = 2;\nlet uid = 0;\n\n/** What is watched in the `headings-from` element: headings added, removed or retitled. */\nconst HEADINGS: MutationObserverInit = { childList: true, characterData: true, subtree: true };\n\n/**\n * An id from a heading's text: lowercase ASCII (accents dropped), runs of anything else as\n * one `-`, none at either end; `section` when nothing is left.\n */\nconst slugify = (text: string): string =>\n text\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'section';\n\n/** A heading's text, leaving out what is hidden from assistive technology (a `#` permalink). */\nconst headingText = (h: Element): string => {\n let text = '';\n const walk = (n: Node) => {\n if (n instanceof Element && n.getAttribute('aria-hidden') === 'true') return;\n if (n.nodeType === Node.TEXT_NODE) text += n.textContent;\n else n.childNodes.forEach(walk);\n };\n walk(h);\n return normalize(text);\n};\n\n/**\n * The rules kept with `no-style`: unmarked lists, the disclosure's closed panel hidden, and\n * `[hidden]` hides. `host` is `:host` (shadow) or the tag name (light DOM, so they stay scoped).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} :is(ol, ul) { list-style: none; margin: 0; padding: 0; }\n ${host} li :is(ol, ul) { padding-inline-start: 1rem; }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/** A comparable form of a URL: origin and path, without a trailing slash or index.html. */\nconst pageKey = (u: URL) =>\n u.origin + (u.pathname.replace(/\\/index\\.html?$/i, '/').replace(/(.)\\/$/, '$1') || '/');\n\n/** The query string as a sorted, comparable form (`?b=2&a=1` is `?a=1&b=2`). */\nconst queryKey = (u: URL) => {\n const q = new URLSearchParams(u.search);\n q.sort();\n return q.toString();\n};\n\n/**\n * Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a\n * `<nav>` landmark (named by `label`, \"Contents\" by default) with the label as a visible\n * headline, and a nested list of links with dividers between the top-level entries and a bar\n * beside each nested level.\n *\n * Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>`\n * (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any\n * depth. Other children (a heading) are ignored. The list follows changes to the children.\n * Apps set the `items` property instead (`{ label, href?, children? }`, winning over the\n * children while set).\n *\n * The current entry gets `aria-current`: `page` for the link to this page, `location` for the\n * link to the section of it in the URL's hash. It is found from the page URL (path, and hash\n * for in-page sections), followed through same-document navigations (`hashchange`,\n * `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like\n * the links). An entry whose href has a query string matches only that query (`?part=2`); one\n * without matches the page whatever its query. Hash-only hrefs are places on that page. With\n * `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is\n * used instead, the first of each kind. `lang` and `dir` on the source links and items, and\n * inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element,\n * never as HTML), are kept.\n *\n * On narrow screens the list collapses into a disclosure: the headline becomes a button with\n * `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents\n * does on phones, so the text comes first) until the reader opens it, or while the `open`\n * attribute is set; opening it shows the current entry. Narrow means the viewport\n * (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is\n * always far narrower than 64rem, so a container query could not tell a phone from a\n * desktop. `sticky` keeps it in view in a sidebar on wide\n * screens; a list longer than the window then scrolls, and the current entry is scrolled\n * into view inside it (never the page).\n *\n * A table of contents for a long document: `headings-from=\"#article\"` builds the list from the\n * headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level\n * entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped;\n * one without an id gets one from its text (`budget-report`, then `budget-report-2`), and\n * existing ids are kept, so links to sections keep working. It follows headings added,\n * removed or retitled; `refresh()` reads them again after other changes. The children and\n * `items` win while they give a list. Without JavaScript there is no list: a list rendered\n * at build time, as children, works everywhere.\n *\n * Single-page apps: the list is drawn from copies of the children, so a router's own click\n * handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in\n * place; hash links need nothing.\n *\n * @tagname uvalib-contents\n * @fires uvalib-analytics-event - For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), and opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' | 'close']`; never the label or URL. Bubbles and is composed.\n * @fires uvalib-contents-navigate - A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed.\n * @cssprop [--uvalib-contents-sticky-top=1rem] - With `sticky`: the gap kept above it.\n * @cssprop [--uvalib-contents-max-height=none] - The list's maximum height on wide screens (it scrolls beyond it); with `sticky`, the window's height less twice the sticky gap.\n * @cssprop [--uva-blue-alt-dark=#005679] - Link colour.\n * @cssprop [--uva-brand-blue=#232d4b] - The current entry's bar.\n * @cssprop [--uva-brand-orange=#e57200] - The nested levels' bar.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Text and current entry colour.\n * @cssprop --uva-color-utility-link - Dark-mode role token: link colour (else `--uva-blue-alt-dark`).\n * @cssprop --uva-color-text - Dark-mode role token: text and current entry (else `--uva-grey-darkest`).\n * @cssprop --uva-color-link - Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`).\n * @cssprop --uva-color-current - Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`).\n * @cssprop --uva-color-border - Dark-mode role token: dividers (else #dadada).\n * @cssprop --uva-color-control-border - Dark-mode role token: the button's border (else #808080).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: the button's background (else #fff).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n */\nexport class UvalibContents extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n css`\n :host {\n font-size: 1rem;\n line-height: 1.5;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n overflow-wrap: anywhere;\n }\n :host([sticky]:not([data-narrow])) {\n position: sticky;\n top: var(--uvalib-contents-sticky-top, 1rem);\n align-self: start;\n }\n .headline {\n margin: 0 0 0.5rem;\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .panel {\n max-height: var(--uvalib-contents-max-height, none);\n overflow-y: auto;\n overscroll-behavior: contain;\n }\n :host([sticky]:not([data-narrow])) .panel {\n max-height: var(\n --uvalib-contents-max-height,\n calc(100dvh - 2 * var(--uvalib-contents-sticky-top, 1rem) - 3rem)\n );\n }\n :host([data-narrow]) .panel {\n max-height: none;\n overflow: visible;\n }\n .panel > :is(ol, ul) {\n border-block: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n .panel > :is(ol, ul) > li + li {\n border-top: 1px solid var(--uva-color-border, var(--uva-grey-100, #dadada));\n }\n li :is(ol, ul) {\n margin: 0 0 0.5rem 0.75rem;\n padding: 0;\n border-inline-start: 2px solid var(--uva-color-current, var(--uva-brand-orange, #e57200));\n }\n a,\n .group {\n display: block;\n padding: 0.5rem 0.75rem 0.5rem calc(0.75rem + 4px);\n }\n li li > :is(a, .group) {\n padding-block: 0.25rem;\n }\n .group {\n font-weight: 700;\n }\n a {\n color: var(--uva-color-utility-link, var(--uva-blue-alt-dark, #005679));\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n a[aria-current] {\n padding-inline-start: 0.75rem;\n border-inline-start: 4px solid var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n color: inherit;\n font-weight: 700;\n }\n .panel a:focus-visible {\n outline-offset: -3px;\n }\n .toggle {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.75rem;\n box-sizing: border-box;\n width: 100%;\n min-height: 44px;\n margin: 0;\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n border-radius: 0.3rem;\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font: inherit;\n font-weight: 700;\n text-align: start;\n cursor: pointer;\n }\n .toggle::after {\n content: '';\n flex: none;\n width: 0.5em;\n height: 0.5em;\n margin-block-end: 0.25em;\n border-inline-end: 2px solid currentColor;\n border-block-end: 2px solid currentColor;\n transform: rotate(45deg);\n }\n .toggle[aria-expanded='true']::after {\n margin-block: 0.25em 0;\n transform: rotate(225deg);\n }\n :host([data-narrow]) .headline {\n margin-bottom: 0;\n }\n :host([data-narrow]) .panel {\n margin-top: 0.5rem;\n }\n `,\n ];\n\n /** Accessible name of the navigation landmark, and its visible headline. */\n @property({ type: String }) label = DEFAULT_LABEL;\n\n /** The headline's level (2 to 6), for the page's outline. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel = DEFAULT_LEVEL;\n\n /**\n * The URL of the current entry (resolved like the links), for apps whose route is not the\n * page URL. Unset: the page URL, followed through same-document navigations.\n */\n @property({ type: String }) current?: string;\n\n /**\n * The viewport width at and below which the list collapses into a disclosure: a CSS length\n * (`64rem`, `800px`). `0` or `none` never collapses.\n */\n @property({ type: String, attribute: 'collapse-below' }) collapseBelow = DEFAULT_COLLAPSE;\n\n /** Whether the collapsed disclosure is open (no effect on wide screens). Toggled by its button. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Keep it in view while the page scrolls (a sidebar), on wide screens. */\n @property({ type: Boolean, reflect: true }) sticky = false;\n\n /**\n * The entries as data, for apps that build them in JavaScript: `{ label, href?, children? }`.\n * Wins over the children while set; `undefined` goes back to them. Entries without a label\n * are skipped (with their children) with one console warning.\n */\n @property({ attribute: false }) items?: ContentsItem[];\n\n /**\n * Build the list from the headings in the element this selector names (`#article`): each\n * heading at `levels` gets an entry linking to it (an id is added when it has none), the\n * lower levels nested under the heading before them. The children and `items` win while\n * they give a list.\n */\n @property({ type: String, attribute: 'headings-from' }) headingsFrom?: string;\n\n /** With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. */\n @property({ type: String }) levels = DEFAULT_LEVELS;\n\n /**\n * With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer,\n * nothing is shown.\n */\n @property({ type: Number }) min = DEFAULT_MIN;\n\n /** The entries built from the headings (`headings-from`). */\n @state() private headingItems: Entry[] = [];\n private headingsObserver?: MutationObserver;\n private headingsScope?: Element | null;\n private headingsQueued = false;\n private scrolledToHash = false;\n\n /** The entries read from the children. */\n @state() private childItems: Entry[] = [];\n /** The root list's element in the source (`ol` or `ul`). */\n @state() private ordered = false;\n @state() private narrow = false;\n /** The page URL, updated on same-document navigations. */\n @state() private here = '';\n\n private warned = new Set<string>();\n private readonly panelId = `uvalib-contents-${++uid}`;\n private mql?: MediaQueryList;\n /** What was last scrolled into view, so the list is not scrolled again on every update. */\n private scrolledTo?: string;\n\n constructor() {\n super();\n new SourceChildren(\n this,\n () => this.lightDom,\n (nodes) => this.read(nodes),\n );\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (root instanceof ShadowRoot && this.noStyle) {\n const sheet = shadowStructure.styleSheet;\n if (sheet) root.adoptedStyleSheets = [sheet];\n }\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.lightDom && this.noStyle) {\n const node = this.getRootNode();\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n {\n root: node instanceof ShadowRoot || node instanceof Document ? node : undefined,\n scope: false,\n },\n );\n }\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n this.listenLocation(true);\n this.watchWidth();\n // Reconnected: the headings may have changed meanwhile (the first time, willUpdate reads).\n if (this.hasUpdated) this.refresh();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.headingsObserver?.disconnect();\n this.headingsScope = undefined;\n this.listenLocation(false);\n this.mql?.removeEventListener('change', this.onWidth);\n this.mql = undefined;\n }\n\n private onLocation = (): void => {\n this.here = this.ownerDocument.defaultView?.location.href ?? '';\n };\n\n private listening = false;\n private listenLocation(on: boolean): void {\n const win = this.ownerDocument.defaultView;\n if (!win || on === this.listening) return;\n this.listening = on;\n const nav = (win as Window & { navigation?: EventTarget }).navigation;\n const targets: [EventTarget, string][] = [\n [win, 'popstate'],\n [win, 'hashchange'],\n ...(nav ? [[nav, 'currententrychange'] as [EventTarget, string]] : []),\n ];\n for (const [t, type] of targets) {\n if (on) t.addEventListener(type, this.onLocation);\n else t.removeEventListener(type, this.onLocation);\n }\n }\n\n private onWidth = (): void => {\n this.narrow = !!this.mql?.matches;\n };\n\n /** Follow the viewport against `collapse-below`. */\n private watchWidth(): void {\n this.mql?.removeEventListener('change', this.onWidth);\n const win = this.ownerDocument.defaultView;\n const below = normalize(this.collapseBelow) || DEFAULT_COLLAPSE;\n this.mql =\n win && !/^(none|0+(\\.0*)?[a-z%]*)$/i.test(below)\n ? win.matchMedia(`(max-width: ${below})`)\n : undefined;\n if (this.mql?.media === 'not all') {\n this.warnOnce('collapse', `ignoring collapse-below=\"${below}\" (not a CSS length).`);\n this.mql = win?.matchMedia(`(max-width: ${DEFAULT_COLLAPSE})`);\n }\n this.mql?.addEventListener('change', this.onWidth);\n this.onWidth();\n }\n\n private warnOnce(kind: string, message: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(`${this.localName}: ${message}`);\n }\n\n /**\n * With `headings-from`: read the headings again, adding ids to new ones. Headings added,\n * removed or retitled are followed by themselves; call this after other changes (an\n * `aria-hidden` set or a heading's level changed).\n */\n refresh(): void {\n const sel = normalize(this.headingsFrom);\n let scope: Element | null = null;\n if (sel) {\n const root = this.getRootNode();\n const finder =\n root instanceof Document || root instanceof ShadowRoot ? root : this.ownerDocument;\n try {\n scope = finder.querySelector(sel);\n } catch {\n scope = null;\n }\n if (!scope && this.ownerDocument.readyState === 'loading') {\n // Still parsing: try again once the document is read.\n this.ownerDocument.addEventListener('DOMContentLoaded', () => this.refresh(), {\n once: true,\n });\n } else if (!scope) {\n this.warnOnce('headings-from', `no element matches headings-from=\"${sel}\".`);\n }\n }\n if (scope !== this.headingsScope) {\n this.headingsScope = scope;\n this.headingsObserver?.disconnect();\n if (scope) {\n this.headingsObserver ??= new MutationObserver(() => this.queueHeadings());\n this.headingsObserver.observe(scope, HEADINGS);\n }\n }\n const items = scope ? this.fromHeadings(scope) : [];\n if (entriesKey(items) !== entriesKey(this.headingItems)) this.headingItems = items;\n }\n\n /** Several changes at once read the headings once. */\n private queueHeadings(): void {\n if (this.headingsQueued) return;\n this.headingsQueued = true;\n queueMicrotask(() => {\n this.headingsQueued = false;\n if (this.isConnected) this.refresh();\n });\n }\n\n /** The heading levels to list, from `levels`. */\n private get headingRange(): [number, number] {\n const m = /^\\s*([1-6])\\s*(?:-\\s*([1-6]))?\\s*$/.exec(String(this.levels ?? ''));\n if (!m) {\n this.warnOnce(\n 'levels',\n `ignoring levels=\"${this.levels}\" (use a level, 2, or a range, 2-3).`,\n );\n return [2, 3];\n }\n const a = Number(m[1]);\n const b = m[2] ? Number(m[2]) : a;\n return [Math.min(a, b), Math.max(a, b)];\n }\n\n /**\n * The entries for the headings in `scope`, in document order: empty and `aria-hidden` ones\n * and those inside this element skipped; an id added to each without one (a slug of its\n * text, unique with `-2`, `-3`…); each nested under the previous higher-level heading.\n * Fewer than `min` top-level entries: none.\n */\n private fromHeadings(scope: Element): Entry[] {\n const [lo, hi] = this.headingRange;\n const selector = Array.from({ length: hi - lo + 1 }, (_, i) => `h${lo + i}`).join(', ');\n const root = scope.getRootNode() as Document | ShadowRoot;\n const top: Entry[] = [];\n const open: { level: number; entry: Entry }[] = [];\n const added: Element[] = [];\n for (const h of scope.querySelectorAll(selector)) {\n if (this.contains(h) || h.closest('[aria-hidden=\"true\"]')) continue;\n const label = headingText(h);\n if (!label) continue;\n if (!h.id) {\n const base = slugify(label);\n let id = base;\n for (let n = 2; root.getElementById(id); n++) id = `${base}-${n}`;\n h.id = id;\n added.push(h);\n }\n const level = Number(h.localName.slice(1));\n const entry: Entry = { label, href: `#${h.id}`, children: [] };\n while (open.length && open[open.length - 1]!.level >= level) open.pop();\n (open.length ? open[open.length - 1]!.entry.children : top).push(entry);\n open.push({ level, entry });\n }\n this.scrollToAdded(added);\n const min = Number.isFinite(Number(this.min)) ? Math.trunc(Number(this.min)) : DEFAULT_MIN;\n return top.length >= min ? top : [];\n }\n\n /**\n * The page was opened at a section whose heading had no id until now: go there, as the\n * browser would have (once).\n */\n private scrollToAdded(added: Element[]): void {\n if (this.scrolledToHash || !added.length) return;\n const hash = this.ownerDocument.defaultView?.location.hash.slice(1);\n if (!hash) return;\n let id = hash;\n try {\n id = decodeURIComponent(hash);\n } catch {\n /* keep it as written */\n }\n const h = added.find((a) => a.id === id);\n if (!h) return;\n this.scrolledToHash = true;\n requestAnimationFrame(() => h.scrollIntoView());\n }\n\n /** Read the entries from the first list among the children. */\n private read(nodes: Node[]): void {\n let list: Element | null = null;\n for (const n of nodes) {\n if (!(n instanceof Element)) continue;\n list = n.matches('ol, ul') ? n : n.querySelector('ol, ul');\n if (list) break;\n }\n const items = list ? this.parse(list) : [];\n const ordered = list?.localName === 'ol';\n if (ordered !== this.ordered) this.ordered = ordered;\n // Only a real change re-renders.\n if (entriesKey(items) !== entriesKey(this.childItems)) this.childItems = items;\n }\n\n private parse(list: Element): Entry[] {\n const out: Entry[] = [];\n for (const li of list.children) {\n if (li.localName !== 'li') continue;\n const sub = [...li.children].find((c) => c.matches('ol, ul'));\n const a = [...li.querySelectorAll('a[href]')].find((x) => x.closest('li') === li);\n // The entry's own text: the link's, or the item's without its sub-list.\n const label = normalize(\n a\n ? a.textContent\n : [...li.childNodes]\n .filter((c) => c !== sub)\n .map((c) => c.textContent)\n .join(' '),\n );\n const children = sub ? this.parse(sub) : [];\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children };\n if (a) entry.href = a.getAttribute('href')!;\n const mark = markOf(a?.getAttribute('aria-current'));\n if (mark) entry.mark = mark;\n const own = langDir(a);\n if (own.lang !== undefined) entry.lang = own.lang;\n if (own.dir) entry.dir = own.dir;\n const item = langDir(li);\n if (item.lang !== undefined) entry.itemLang = item.lang;\n if (item.dir) entry.itemDir = item.dir;\n const copy = inlineCopy(\n a ? a.childNodes : [...li.childNodes].filter((c) => c !== sub),\n this.ownerDocument,\n );\n if (copy.rich) {\n entry.rich = copy.key;\n entry.nodes = copy.nodes;\n }\n out.push(entry);\n }\n return out;\n }\n\n private fromItems(items: readonly ContentsItem[]): Entry[] {\n const out: Entry[] = [];\n for (const i of items) {\n const label = normalize(i?.label);\n if (!label) {\n this.warnOnce('label', 'ignoring entries with no text (each needs a label).');\n continue;\n }\n const entry: Entry = { label, children: this.fromItems(i.children ?? []) };\n if (i.href != null) entry.href = String(i.href);\n out.push(entry);\n }\n return out;\n }\n\n /** What is shown: `items` while set, else the children; unsafe hrefs made plain text. */\n private get entries(): Entry[] {\n const base = this.ownerDocument.baseURI;\n const clean = (list: Entry[]): Entry[] =>\n list.map((e) => {\n const children = clean(e.children);\n if (e.href === undefined || safeHref(e.href, base)) return { ...e, children };\n this.warnOnce(\n 'href',\n 'showing an entry as text: its href is not http(s), mailto, tel or relative.',\n );\n const rest: Entry = { ...e, children };\n delete rest.href;\n delete rest.mark;\n return rest;\n });\n return clean(\n this.items\n ? this.fromItems(this.items)\n : this.fromHeadingsNow\n ? this.headingItems\n : this.childItems,\n );\n }\n\n /** Whether the list shown is the one built from the headings (no items, no child list). */\n private get fromHeadingsNow(): boolean {\n return !this.items && !this.childItems.length && !!this.headingItems.length;\n }\n\n /** The current entries: the page's and its section's. */\n private currentOf(entries: Entry[]): Map<Entry, Current> {\n const flat: Entry[] = [];\n const walk = (l: Entry[]) => l.forEach((e) => (flat.push(e), walk(e.children)));\n walk(entries);\n const found = new Map<Entry, Current>();\n // The author's marks, on links only (a group or an unsafe link has none): the first\n // `page` and the first `location`.\n const marked = flat.filter((e) => e.mark && e.href !== undefined);\n if (!this.current && marked.length) {\n for (const kind of ['page', 'location'] as const) {\n const e = marked.find((m) => m.mark === kind);\n if (e) found.set(e, kind);\n }\n return found;\n }\n const base = this.ownerDocument.baseURI;\n const here = this.here || base;\n let target: URL;\n try {\n // A hash-only href is a place on this page, whatever the base URL (about:srcdoc frames).\n const c = this.current || here;\n target = new URL(c, c.startsWith('#') ? here : base);\n } catch {\n return found;\n }\n // Entries' hash-only hrefs are places on the target page (the current URL, or `current`).\n const resolve = (h: string) => new URL(h, h.startsWith('#') ? target.href : base);\n const key = pageKey(target);\n const query = queryKey(target);\n const same = flat.flatMap((e) => {\n if (e.href === undefined) return [];\n try {\n const u = resolve(e.href);\n // An entry with a query names that query (?part=2); one without matches the page\n // whatever its query (tracking parameters).\n if (pageKey(u) !== key || (u.search && queryKey(u) !== query)) return [];\n return [{ e, hash: u.hash }];\n } catch {\n return [];\n }\n });\n const page = same.find((s) => !s.hash);\n if (page) found.set(page.e, 'page');\n const section = target.hash && same.find((s) => s.hash === target.hash);\n if (section) found.set(section.e, 'location');\n return found;\n }\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : DEFAULT_LEVEL;\n }\n\n private toggle(): void {\n this.open = !this.open;\n trackEvent(this, ['uvalib-contents', 'toggle', this.open ? 'open' : 'close']);\n }\n\n /**\n * A plain click on an entry fires a cancelable `uvalib-contents-navigate`; a router that\n * cancels it navigates itself (the click's default is prevented too).\n */\n private onClick(e: MouseEvent): void {\n const a = (e.target as Element | null)?.closest?.('a[href]');\n if (!a || !this.renderRoot.contains(a)) return;\n // Analytics: the entry's level (1 is the top), never its label or URL.\n const level = Number(a.getAttribute('data-level'));\n trackEvent(this, ['uvalib-contents', 'link-click', `level ${level}`, level]);\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)\n return;\n const go = new CustomEvent('uvalib-contents-navigate', {\n detail: { href: a.getAttribute('href'), level },\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n if (!this.dispatchEvent(go)) e.preventDefault();\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('collapseBelow') && this.isConnected) this.watchWidth();\n if (\n (changed.has('headingsFrom') || changed.has('levels') || changed.has('min')) &&\n this.isConnected\n )\n this.refresh();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.toggleAttribute('data-narrow', this.narrow);\n this.toggleAttribute('data-empty', !this.entries.length);\n this.reveal();\n }\n\n /** Scroll the list (never the page) so the current entry shows, once per entry and opening. */\n private reveal(): void {\n const panel = this.renderRoot.querySelector<HTMLElement>(`#${this.panelId}`);\n const links = panel ? [...panel.querySelectorAll<HTMLElement>('a[aria-current]')] : [];\n const a = links.find((l) => l.getAttribute('aria-current') === 'location') ?? links[0];\n if (!panel || !a || panel.hidden) return;\n const key = `${a.getAttribute('href')}|${this.narrow}|${this.open}`;\n if (key === this.scrolledTo) return;\n this.scrolledTo = key;\n if (panel.scrollHeight <= panel.clientHeight) return;\n const p = panel.getBoundingClientRect();\n const r = a.getBoundingClientRect();\n if (r.top >= p.top && r.bottom <= p.bottom) return;\n panel.scrollTop += r.top - p.top - (p.height - r.height) / 2;\n }\n\n private renderList(\n entries: Entry[],\n current: Map<Entry, Current>,\n level: number,\n ): TemplateResult {\n const items = entries.map((e) => {\n const mark = current.get(e);\n // Fresh copies of the label's inline markup each render (a node can be in one place).\n const text = e.nodes ? e.nodes.map((n) => n.cloneNode(true)) : e.label;\n const own =\n e.href !== undefined\n ? html`<a\n href=${e.href}\n data-level=${level}\n aria-current=${mark ?? nothing}\n lang=${e.lang ?? nothing}\n dir=${e.dir ?? nothing}\n >${text}</a\n >`\n : html`<span class=\"group\" lang=${e.lang ?? nothing} dir=${e.dir ?? nothing}\n >${text}</span\n >`;\n return html`<li role=\"listitem\" lang=${e.itemLang ?? nothing} dir=${e.itemDir ?? nothing}>\n ${own}${e.children.length ? this.renderList(e.children, current, level + 1) : nothing}\n </li>`;\n });\n // role=\"list\": Safari drops the list semantics of a list styled without markers. A list\n // built from headings is an <ol>: the document's order.\n return this.ordered || this.fromHeadingsNow\n ? html`<ol role=\"list\">\n ${items}\n </ol>`\n : html`<ul role=\"list\">\n ${items}\n </ul>`;\n }\n\n protected override render() {\n const entries = this.entries;\n const label = normalize(this.label) || DEFAULT_LABEL;\n const h = unsafeStatic(`h${this.level}`);\n const collapsed = this.narrow && !this.open;\n const headline = this.narrow\n ? html`<button\n type=\"button\"\n class=\"toggle\"\n aria-expanded=${this.open ? 'true' : 'false'}\n aria-controls=${this.panelId}\n @click=${this.toggle}\n >\n ${label}\n </button>`\n : label;\n // The heading's tag changes the inner template only: the <nav> (in light DOM, a child\n // of the element) is never replaced.\n return html`<nav aria-label=${label} ?hidden=${!entries.length} @click=${this.onClick}>\n ${html`<${h} class=\"headline\">${headline}</${h}>`}\n <div class=\"panel\" id=${this.panelId} ?hidden=${collapsed}>\n ${this.renderList(entries, this.currentOf(entries), 1)}\n </div>\n </nav>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibContents } from './UvalibContents.js';\n\ndefine('uvalib-contents', UvalibContents);\n"],"mappings":";;;;;;;AAoCA,IAAMwB,KAAU,MAAsD;CACpE,IAAM,IAAIC,GAAG,KAAK,CAAC,CAAC,YAAY;CAChC,OAAO,MAAM,UAAU,MAAM,SAAS,SAAS,MAAM,aAAa,aAAa,KAAA;AACjF,GAGMC,KAAc,MAClB,KAAK,UAAUC,IAAQ,GAAG,MAAgBC,MAAM,UAAU,KAAA,IAAYH,CAAE,GAIpEI,IAAgB,YAChBC,IAAmB,SACnBC,IAAgB,GAChBC,IAAiB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