vanilla-breeze 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/custom-elements.json +22381 -13213
  2. package/dist/cdn/components/accordion-wc.js +1 -1
  3. package/dist/cdn/components/activity-feed.js +1 -1
  4. package/dist/cdn/components/ai-chat.js +5 -5
  5. package/dist/cdn/components/ai-summary.js +2 -2
  6. package/dist/cdn/components/analytics-panel.js +2 -2
  7. package/dist/cdn/components/audio-player.js +4 -4
  8. package/dist/cdn/components/audio-visualizer.js +2 -2
  9. package/dist/cdn/components/author-index.js +2 -2
  10. package/dist/cdn/components/brand-mark.js +1 -1
  11. package/dist/cdn/components/bread-crumb.js +1 -1
  12. package/dist/cdn/components/calendar-wc.js +2 -2
  13. package/dist/cdn/components/card-list.js +1 -1
  14. package/dist/cdn/components/carousel-wc.js +1 -1
  15. package/dist/cdn/components/change-set.js +1 -1
  16. package/dist/cdn/components/chart-wc.js +6 -6
  17. package/dist/cdn/components/chat-input.js +1 -1
  18. package/dist/cdn/components/chat-window.js +1 -1
  19. package/dist/cdn/components/color-picker.js +1 -1
  20. package/dist/cdn/components/combo-box.js +1 -1
  21. package/dist/cdn/components/command-palette.js +1 -1
  22. package/dist/cdn/components/comment-box.js +51 -50
  23. package/dist/cdn/components/comment-thread.js +50 -49
  24. package/dist/cdn/components/comment-wc.js +1 -1
  25. package/dist/cdn/components/compare-surface.js +1 -1
  26. package/dist/cdn/components/consent-banner.js +1 -1
  27. package/dist/cdn/components/content-lens.js +1 -1
  28. package/dist/cdn/components/content-swap.js +1 -1
  29. package/dist/cdn/components/context-menu.js +1 -1
  30. package/dist/cdn/components/data-table.js +1 -1
  31. package/dist/cdn/components/date-picker.js +1 -1
  32. package/dist/cdn/components/day-view.js +1 -1
  33. package/dist/cdn/components/diagram-wc.js +2 -2
  34. package/dist/cdn/components/drag-surface.js +1 -1
  35. package/dist/cdn/components/drop-down.js +1 -1
  36. package/dist/cdn/components/emoji-picker.js +1 -1
  37. package/dist/cdn/components/flow-diagram.js +1 -1
  38. package/dist/cdn/components/foot-notes.js +1 -1
  39. package/dist/cdn/components/form-field.js +1 -1
  40. package/dist/cdn/components/geo-map.js +170 -54
  41. package/dist/cdn/components/glossary-index.js +1 -1
  42. package/dist/cdn/components/glossary-wc.js +1 -1
  43. package/dist/cdn/components/heading-links.js +1 -1
  44. package/dist/cdn/components/highlight-wc.js +6 -2
  45. package/dist/cdn/components/icon-wc.js +11 -10
  46. package/dist/cdn/components/image-gallery.js +1 -1
  47. package/dist/cdn/components/image-map.js +1 -1
  48. package/dist/cdn/components/include-file.js +1 -1
  49. package/dist/cdn/components/manifest.json +101 -101
  50. package/dist/cdn/components/markdown-editor.js +60 -1
  51. package/dist/cdn/components/markdown-viewer.js +50 -49
  52. package/dist/cdn/components/nav-bar.js +1 -1
  53. package/dist/cdn/components/note-wc.js +6 -2
  54. package/dist/cdn/components/notification-wc.js +33 -32
  55. package/dist/cdn/components/page-info.js +6 -72
  56. package/dist/cdn/components/page-stats.js +1 -1
  57. package/dist/cdn/components/page-toc.js +1 -1
  58. package/dist/cdn/components/page-tools.js +1 -1
  59. package/dist/cdn/components/page-tour.js +1 -38
  60. package/dist/cdn/components/pager-wc.js +1 -1
  61. package/dist/cdn/components/poll-wc.js +1 -1
  62. package/dist/cdn/components/pop-over.js +1 -1
  63. package/dist/cdn/components/popularity-index.js +1 -8
  64. package/dist/cdn/components/print-page.js +1 -1
  65. package/dist/cdn/components/progress-tracker.js +1 -1
  66. package/dist/cdn/components/qr-code.js +1 -1
  67. package/dist/cdn/components/reaction-bar.js +1 -1
  68. package/dist/cdn/components/reader-view.js +25 -25
  69. package/dist/cdn/components/reading-progress.js +1 -1
  70. package/dist/cdn/components/recently-visited.js +1 -26
  71. package/dist/cdn/components/score-card.js +21 -5
  72. package/dist/cdn/components/selection-menu.js +1 -1
  73. package/dist/cdn/components/settings-panel.js +88 -142
  74. package/dist/cdn/components/share-wc.js +2 -2
  75. package/dist/cdn/components/short-cuts.js +1 -1
  76. package/dist/cdn/components/site-index.js +1 -10
  77. package/dist/cdn/components/site-map.js +1 -1
  78. package/dist/cdn/components/site-search.js +1 -51
  79. package/dist/cdn/components/slide-accept.js +1 -1
  80. package/dist/cdn/components/social-embed.js +1 -1
  81. package/dist/cdn/components/split-surface.js +1 -1
  82. package/dist/cdn/components/star-rating.js +1 -1
  83. package/dist/cdn/components/status-wc.js +1 -1
  84. package/dist/cdn/components/stepper-wc.js +1 -1
  85. package/dist/cdn/components/tab-set.js +1 -1
  86. package/dist/cdn/components/text-reader.js +2 -2
  87. package/dist/cdn/components/theme-picker.js +86 -83
  88. package/dist/cdn/components/time-index.js +1 -11
  89. package/dist/cdn/components/time-picker.js +1 -1
  90. package/dist/cdn/components/toast-msg.js +6 -6
  91. package/dist/cdn/components/tool-tip.js +1 -1
  92. package/dist/cdn/components/topic-map.js +6 -3
  93. package/dist/cdn/components/trust-filter.js +1 -3
  94. package/dist/cdn/components/version-switcher.js +5 -5
  95. package/dist/cdn/components/video-player.js +67 -9
  96. package/dist/cdn/components/watch-wc.js +6 -2
  97. package/dist/cdn/components/week-view.js +1 -1
  98. package/dist/cdn/components/youtube-player.js +1 -1
  99. package/dist/cdn/emoji-extended.js +2 -0
  100. package/dist/cdn/fonts/atkinson-hyperlegible-OFL.txt +93 -0
  101. package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-italic.woff2 +0 -0
  102. package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
  103. package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-italic.woff2 +0 -0
  104. package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
  105. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-italic.woff2 +0 -0
  106. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2 +0 -0
  107. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-italic.woff2 +0 -0
  108. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2 +0 -0
  109. package/dist/cdn/fonts/latinmodern-math-GUST-LICENSE.txt +30 -0
  110. package/dist/cdn/fonts/latinmodern-math.woff2 +0 -0
  111. package/dist/cdn/fonts/math-fonts.css +14 -0
  112. package/dist/cdn/packs/effects.full.css +1 -1
  113. package/dist/cdn/packs/effects.full.js +1 -1
  114. package/dist/cdn/packs/fonts-display.full.css +1 -1
  115. package/dist/cdn/packs/fonts-display.theme.css +1 -1
  116. package/dist/cdn/packs/icons.bundle.js +1 -1
  117. package/dist/cdn/packs/icons.full.css +1 -1
  118. package/dist/cdn/packs/icons.theme.css +1 -1
  119. package/dist/cdn/packs/journal.effects.css +1 -1
  120. package/dist/cdn/packs/journal.full.css +1 -1
  121. package/dist/cdn/packs/kawaii.effects.css +1 -1
  122. package/dist/cdn/packs/kawaii.full.css +2 -2
  123. package/dist/cdn/packs/kawaii.full.js +4 -4
  124. package/dist/cdn/packs/kawaii.theme.css +1 -1
  125. package/dist/cdn/packs/manifest.json +17 -17
  126. package/dist/cdn/packs/memphis.full.css +1 -1
  127. package/dist/cdn/packs/memphis.theme.css +1 -1
  128. package/dist/cdn/packs/ui.full.css +1 -1
  129. package/dist/cdn/packs/ui.full.js +89 -86
  130. package/dist/cdn/themes/8bit.css +1 -1
  131. package/dist/cdn/themes/8bit.tokens.json +1 -1
  132. package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
  133. package/dist/cdn/themes/alpha1999.css +1 -1
  134. package/dist/cdn/themes/alpha1999.tokens.json +1 -1
  135. package/dist/cdn/themes/art-deco-dark.tokens.json +1 -1
  136. package/dist/cdn/themes/art-deco.css +1 -1
  137. package/dist/cdn/themes/art-deco.tokens.json +1 -1
  138. package/dist/cdn/themes/bauhaus-dark.tokens.json +1 -1
  139. package/dist/cdn/themes/bauhaus.css +1 -1
  140. package/dist/cdn/themes/bauhaus.tokens.json +1 -1
  141. package/dist/cdn/themes/brutalist-dark.tokens.json +1 -1
  142. package/dist/cdn/themes/brutalist.css +1 -1
  143. package/dist/cdn/themes/brutalist.tokens.json +1 -1
  144. package/dist/cdn/themes/catppuccin-frappe.css +1 -1
  145. package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
  146. package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
  147. package/dist/cdn/themes/catppuccin-latte.css +1 -1
  148. package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
  149. package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
  150. package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
  151. package/dist/cdn/themes/catppuccin-mocha.css +1 -1
  152. package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
  153. package/dist/cdn/themes/classic-dark.tokens.json +1 -1
  154. package/dist/cdn/themes/classic.css +1 -1
  155. package/dist/cdn/themes/classic.tokens.json +1 -1
  156. package/dist/cdn/themes/claymorphism-dark.tokens.json +1 -1
  157. package/dist/cdn/themes/claymorphism.css +1 -1
  158. package/dist/cdn/themes/claymorphism.tokens.json +2 -1
  159. package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
  160. package/dist/cdn/themes/clinical.css +1 -1
  161. package/dist/cdn/themes/clinical.tokens.json +1 -1
  162. package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
  163. package/dist/cdn/themes/cottagecore.css +1 -1
  164. package/dist/cdn/themes/cottagecore.tokens.json +1 -1
  165. package/dist/cdn/themes/cyber.css +1 -1
  166. package/dist/cdn/themes/cyber.tokens.json +1 -1
  167. package/dist/cdn/themes/dawn-dark.tokens.json +1 -1
  168. package/dist/cdn/themes/dawn.css +1 -1
  169. package/dist/cdn/themes/dawn.tokens.json +1 -1
  170. package/dist/cdn/themes/dracula.css +1 -1
  171. package/dist/cdn/themes/dracula.tokens.json +1 -1
  172. package/dist/cdn/themes/dusk.css +1 -1
  173. package/dist/cdn/themes/dusk.tokens.json +1 -1
  174. package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
  175. package/dist/cdn/themes/editorial.css +1 -1
  176. package/dist/cdn/themes/editorial.tokens.json +1 -1
  177. package/dist/cdn/themes/financial-dark.tokens.json +1 -1
  178. package/dist/cdn/themes/financial.css +1 -1
  179. package/dist/cdn/themes/financial.tokens.json +1 -1
  180. package/dist/cdn/themes/genai.css +1 -1
  181. package/dist/cdn/themes/genai.tokens.json +1 -1
  182. package/dist/cdn/themes/glassmorphism-dark.tokens.json +1 -1
  183. package/dist/cdn/themes/glassmorphism.css +1 -1
  184. package/dist/cdn/themes/glassmorphism.tokens.json +1 -1
  185. package/dist/cdn/themes/government-dark.tokens.json +1 -1
  186. package/dist/cdn/themes/government.css +1 -1
  187. package/dist/cdn/themes/government.tokens.json +1 -1
  188. package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
  189. package/dist/cdn/themes/gruvbox.css +1 -1
  190. package/dist/cdn/themes/gruvbox.tokens.json +1 -1
  191. package/dist/cdn/themes/high-noon-dark.tokens.json +1 -1
  192. package/dist/cdn/themes/high-noon.css +1 -1
  193. package/dist/cdn/themes/high-noon.tokens.json +1 -1
  194. package/dist/cdn/themes/journal-dark.tokens.json +4 -2
  195. package/dist/cdn/themes/journal.css +1 -1
  196. package/dist/cdn/themes/journal.tokens.json +4 -2
  197. package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
  198. package/dist/cdn/themes/kawaii.css +1 -1
  199. package/dist/cdn/themes/kawaii.tokens.json +1 -1
  200. package/dist/cdn/themes/magna-dark.tokens.json +1 -1
  201. package/dist/cdn/themes/magna.css +1 -1
  202. package/dist/cdn/themes/magna.tokens.json +1 -1
  203. package/dist/cdn/themes/manifest.json +44 -44
  204. package/dist/cdn/themes/midnight.css +1 -1
  205. package/dist/cdn/themes/midnight.tokens.json +1 -1
  206. package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
  207. package/dist/cdn/themes/minimal.css +1 -1
  208. package/dist/cdn/themes/minimal.tokens.json +1 -1
  209. package/dist/cdn/themes/modern-dark.tokens.json +1 -1
  210. package/dist/cdn/themes/modern.css +1 -1
  211. package/dist/cdn/themes/modern.tokens.json +1 -1
  212. package/dist/cdn/themes/nes-dark.tokens.json +7 -2
  213. package/dist/cdn/themes/nes.css +1 -1
  214. package/dist/cdn/themes/nes.tokens.json +1 -1
  215. package/dist/cdn/themes/neumorphism-dark.tokens.json +1 -1
  216. package/dist/cdn/themes/neumorphism.css +1 -1
  217. package/dist/cdn/themes/neumorphism.tokens.json +1 -1
  218. package/dist/cdn/themes/nord-dark.tokens.json +1 -1
  219. package/dist/cdn/themes/nord.css +1 -1
  220. package/dist/cdn/themes/nord.tokens.json +1 -1
  221. package/dist/cdn/themes/organic-dark.tokens.json +1 -1
  222. package/dist/cdn/themes/organic.css +1 -1
  223. package/dist/cdn/themes/organic.tokens.json +1 -1
  224. package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
  225. package/dist/cdn/themes/rose-pine.css +1 -1
  226. package/dist/cdn/themes/rose-pine.tokens.json +1 -1
  227. package/dist/cdn/themes/rough-dark.tokens.json +1 -1
  228. package/dist/cdn/themes/rough.css +1 -1
  229. package/dist/cdn/themes/rough.tokens.json +1 -1
  230. package/dist/cdn/themes/solarized-dark.tokens.json +1 -1
  231. package/dist/cdn/themes/solarized.css +1 -1
  232. package/dist/cdn/themes/solarized.tokens.json +1 -1
  233. package/dist/cdn/themes/startup-dark.tokens.json +1 -1
  234. package/dist/cdn/themes/startup.css +1 -1
  235. package/dist/cdn/themes/startup.tokens.json +1 -1
  236. package/dist/cdn/themes/super2026-dark.tokens.json +1 -1
  237. package/dist/cdn/themes/super2026.css +1 -1
  238. package/dist/cdn/themes/super2026.tokens.json +1 -1
  239. package/dist/cdn/themes/swiss-dark.tokens.json +1 -1
  240. package/dist/cdn/themes/swiss.css +1 -1
  241. package/dist/cdn/themes/swiss.tokens.json +1 -1
  242. package/dist/cdn/themes/terminal.css +1 -1
  243. package/dist/cdn/themes/terminal.tokens.json +1 -1
  244. package/dist/cdn/themes/tokyo-night-dark.tokens.json +1 -1
  245. package/dist/cdn/themes/tokyo-night.css +1 -1
  246. package/dist/cdn/themes/tokyo-night.tokens.json +1 -1
  247. package/dist/cdn/themes/vaporwave-dark.tokens.json +1 -1
  248. package/dist/cdn/themes/vaporwave.css +1 -1
  249. package/dist/cdn/themes/vaporwave.tokens.json +1 -1
  250. package/dist/cdn/themes/win9x-dark.tokens.json +6 -2
  251. package/dist/cdn/themes/win9x.css +1 -1
  252. package/dist/cdn/themes/win9x.tokens.json +3 -1
  253. package/dist/cdn/vanilla-breeze-autoload.js +187 -297
  254. package/dist/cdn/vanilla-breeze-charts.css +1 -1
  255. package/dist/cdn/vanilla-breeze-charts.js +6 -6
  256. package/dist/cdn/vanilla-breeze-core.css +1 -1
  257. package/dist/cdn/vanilla-breeze-core.js +166 -262
  258. package/dist/cdn/vanilla-breeze-dev.js +1 -1
  259. package/dist/cdn/vanilla-breeze-extras.js +272 -130
  260. package/dist/cdn/vanilla-breeze.css +1 -1
  261. package/dist/cdn/vanilla-breeze.js +536 -621
  262. package/dist/cdn/view-transitions.css +2 -0
  263. package/package.json +15 -7
@@ -1,2 +1,2 @@
1
- function a(i){return document.startViewTransition?document.startViewTransition(i):i()}var b=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function f(i,e,t={}){let n=t.priority??10,s={impl:e,bundle:t.bundle,contract:t.contract,priority:n},r=h.get(i);if(customElements.get(i)){if(!r||r.priority>=n){r&&r.priority===n&&r.impl!==e&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=n){r.priority===n&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}h.set(i,s),customElements.define(i,e)}var c=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,n,s){e.addEventListener(t,n,s),this.#e.push(()=>e.removeEventListener(t,n,s))}_reinit(){for(let e of this.#e)e();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,t){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{t?n.add(e):n.delete(e)}catch{let s=`--${e}`;t?n.add(s):n.delete(s)}}_adoptInternals(e){this.#t||(this.#t=e)}};var p=0,l=class extends c{#e=[];#t=[];#n=[];#s=!1;setup(){return this.#e=[...this.querySelectorAll(":scope > details")],this.#t=this.#e.map(e=>e.querySelector("summary")),this.#e.length===0?!1:(this.#i(),this.#a(),this.#o(),!0)}teardown(){this.#e=[],this.#t=[],this.#n=[],this.#s=!1}get panels(){return this.#e.map((e,t)=>({id:e.id||void 0,summary:e.querySelector("summary")?.textContent?.trim()||`Panel ${t+1}`,content:this.#n[t]?.innerHTML||"",open:e.hasAttribute("open")}))}set panels(e){let t=Array.isArray(e)?e:[],s=this.hasAttribute("single")?`acc-${++p}`:null;for(;this.firstChild;)this.firstChild.remove();for(let r of t){let o=document.createElement("details");r.id&&(o.id=r.id),r.open&&o.setAttribute("open",""),s&&o.setAttribute("name",s);let u=document.createElement("summary");u.textContent=r.summary||"",o.appendChild(u);let d=document.createElement("div");d.innerHTML=r.content||"",o.appendChild(d),this.appendChild(o)}this._reinit(),this.dispatchEvent(new CustomEvent("accordion-wc:panels-changed",{detail:{panels:t,source:"property"},bubbles:!0}))}#i(){this.#n=this.#e.map(e=>{let t=e.querySelector("summary");if(!t)return null;let n=[...e.children].filter(s=>s!==t);if(n.length===1&&n[0].localName==="div")return n[0];if(n.length>=1){let s=document.createElement("div");for(let r of n)s.appendChild(r);return e.appendChild(s),s}return null})}#o(){if(!this.hasAttribute("transition")||!document.startViewTransition)return;this.#s=!0;let e=++p,t=this.getAttribute("transition")||"fade",n=t==="slide"?"vt-accordion-slide":t==="scale"?"vt-accordion-scale":"vt-accordion";this.#n.forEach((s,r)=>{s&&(s.style.viewTransitionName=`accordion-${e}-${r}`,s.style.viewTransitionClass=n)})}#r(e){a(()=>{e.open=!e.open})}#a(){this.#e.forEach((e,t)=>{let n=this.#t[t],s=this.#n[t];if(n){if(s){let r=n.id||`accordion-heading-${crypto.randomUUID().slice(0,8)}`,o=s.id||`accordion-panel-${crypto.randomUUID().slice(0,8)}`;n.id=r,s.id=o,n.setAttribute("aria-expanded",e.open?"true":"false"),n.setAttribute("aria-controls",o),s.setAttribute("aria-labelledby",r),s.setAttribute("role","region")}else n.setAttribute("aria-expanded",e.open?"true":"false");this.listen(n,"click",r=>{this.#s&&(r.preventDefault(),this.#r(e))}),this.listen(n,"keydown",r=>this.#l(r,t)),this.listen(e,"toggle",()=>this.#c(e,t))}})}#c(e,t){this.#t[t].setAttribute("aria-expanded",e.open?"true":"false"),this.hasAttribute("single")&&e.open&&this.#e.forEach((s,r)=>{r!==t&&s.open&&(s.open=!1,this.#t[r].setAttribute("aria-expanded","false"))}),this.dispatchEvent(new CustomEvent("accordion-wc:toggle",{detail:{index:t,open:e.open},bubbles:!0}))}#l(e,t){let{key:n}=e,s;switch(n){case"ArrowDown":s=(t+1)%this.#e.length;break;case"ArrowUp":s=(t-1+this.#e.length)%this.#e.length;break;case"Home":s=0;break;case"End":s=this.#e.length-1;break;default:return}e.preventDefault(),this.#t[s].focus()}open(e){e<0||e>=this.#e.length||(this.#s&&!this.#e[e].open?a(()=>{this.#e[e].open=!0}):this.#e[e].open=!0)}close(e){e<0||e>=this.#e.length||(this.#s&&this.#e[e].open?a(()=>{this.#e[e].open=!1}):this.#e[e].open=!1)}toggle(e){e<0||e>=this.#e.length||(this.#s?this.#r(this.#e[e]):this.#e[e].open=!this.#e[e].open)}openAll(){this.hasAttribute("single")||this.#e.forEach(e=>{e.open=!0})}closeAll(){this.#e.forEach(e=>{e.open=!1})}};f("accordion-wc",l);export{l as AccordionWc};
1
+ function a(n){return document.startViewTransition?document.startViewTransition(n):n()}var b=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function f(n,t,e={}){let r=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:r},i=h.get(n);if(customElements.get(n)){if(!i||i.priority>=r){i&&i.priority===r&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=r){i.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}h.set(n,s),customElements.define(n,t)}var c=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,s){t.addEventListener(e,r,s),this.#t.push(()=>t.removeEventListener(e,r,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let s=`--${t}`;e?r.add(s):r.delete(s)}}_adoptInternals(t){this.#e||(this.#e=t)}#s(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var p=0,l=class extends c{#t=[];#e=[];#s=[];#r=!1;setup(){return this.#t=[...this.querySelectorAll(":scope > details")],this.#e=this.#t.map(t=>t.querySelector("summary")),this.#t.length===0?!1:(this.#n(),this.#a(),this.#o(),!0)}teardown(){this.#t=[],this.#e=[],this.#s=[],this.#r=!1}get panels(){return this.#t.map((t,e)=>({id:t.id||void 0,summary:t.querySelector("summary")?.textContent?.trim()||`Panel ${e+1}`,content:this.#s[e]?.innerHTML||"",open:t.hasAttribute("open")}))}set panels(t){let e=Array.isArray(t)?t:[],s=this.hasAttribute("single")?`acc-${++p}`:null;for(;this.firstChild;)this.firstChild.remove();for(let i of e){let o=document.createElement("details");i.id&&(o.id=i.id),i.open&&o.setAttribute("open",""),s&&o.setAttribute("name",s);let u=document.createElement("summary");u.textContent=i.summary||"",o.appendChild(u);let d=document.createElement("div");d.innerHTML=i.content||"",o.appendChild(d),this.appendChild(o)}this._reinit(),this.dispatchEvent(new CustomEvent("accordion-wc:panels-changed",{detail:{panels:e,source:"property"},bubbles:!0}))}#n(){this.#s=this.#t.map(t=>{let e=t.querySelector("summary");if(!e)return null;let r=[...t.children].filter(s=>s!==e);if(r.length===1&&r[0].localName==="div")return r[0];if(r.length>=1){let s=document.createElement("div");for(let i of r)s.appendChild(i);return t.appendChild(s),s}return null})}#o(){if(!this.hasAttribute("transition")||!document.startViewTransition)return;this.#r=!0;let t=++p,e=this.getAttribute("transition")||"fade",r=e==="slide"?"vt-accordion-slide":e==="scale"?"vt-accordion-scale":"vt-accordion";this.#s.forEach((s,i)=>{s&&(s.style.viewTransitionName=`accordion-${t}-${i}`,s.style.viewTransitionClass=r)})}#i(t){a(()=>{t.open=!t.open})}#a(){this.#t.forEach((t,e)=>{let r=this.#e[e],s=this.#s[e];if(r){if(s){let i=r.id||`accordion-heading-${crypto.randomUUID().slice(0,8)}`,o=s.id||`accordion-panel-${crypto.randomUUID().slice(0,8)}`;r.id=i,s.id=o,r.setAttribute("aria-expanded",t.open?"true":"false"),r.setAttribute("aria-controls",o),s.setAttribute("aria-labelledby",i),s.setAttribute("role","region")}else r.setAttribute("aria-expanded",t.open?"true":"false");this.listen(r,"click",i=>{this.#r&&(i.preventDefault(),this.#i(t))}),this.listen(r,"keydown",i=>this.#l(i,e)),this.listen(t,"toggle",()=>this.#c(t,e))}})}#c(t,e){this.#e[e].setAttribute("aria-expanded",t.open?"true":"false"),this.hasAttribute("single")&&t.open&&this.#t.forEach((s,i)=>{i!==e&&s.open&&(s.open=!1,this.#e[i].setAttribute("aria-expanded","false"))}),this.dispatchEvent(new CustomEvent("accordion-wc:toggle",{detail:{index:e,open:t.open},bubbles:!0}))}#l(t,e){let{key:r}=t,s;switch(r){case"ArrowDown":s=(e+1)%this.#t.length;break;case"ArrowUp":s=(e-1+this.#t.length)%this.#t.length;break;case"Home":s=0;break;case"End":s=this.#t.length-1;break;default:return}t.preventDefault(),this.#e[s].focus()}open(t){t<0||t>=this.#t.length||(this.#r&&!this.#t[t].open?a(()=>{this.#t[t].open=!0}):this.#t[t].open=!0)}close(t){t<0||t>=this.#t.length||(this.#r&&this.#t[t].open?a(()=>{this.#t[t].open=!1}):this.#t[t].open=!1)}toggle(t){t<0||t>=this.#t.length||(this.#r?this.#i(this.#t[t]):this.#t[t].open=!this.#t[t].open)}openAll(){this.hasAttribute("single")||this.#t.forEach(t=>{t.open=!0})}closeAll(){this.#t.forEach(t=>{t.open=!1})}};f("accordion-wc",l);export{l as AccordionWc};
2
2
  //# sourceMappingURL=accordion-wc.js.map
@@ -1,2 +1,2 @@
1
- var N=window.matchMedia("(prefers-reduced-motion: reduce)");var y=new Map;function v(r,t,i={}){let e=i.priority??10,s={impl:t,bundle:i.bundle,contract:i.contract,priority:e},n=y.get(r);if(customElements.get(r)){if(!n||n.priority>=e){n&&n.priority===e&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=e){n.priority===e&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}y.set(r,s),customElements.define(r,t)}var h=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,i,e,s){t.addEventListener(i,e,s),this.#e.push(()=>t.removeEventListener(i,e,s))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,i){this.#t||(this.#t=this.attachInternals());let e=this.#t.states;try{i?e.add(t):e.delete(t)}catch{let s=`--${t}`;i?e.add(s):e.delete(s)}}_adoptInternals(t){this.#t||(this.#t=t)}};function f(r){let t=(Date.now()-r.getTime())/1e3;if(Number.isNaN(t)||t<0)return null;if(t<60)return"just now";if(t<3600){let e=Math.floor(t/60);return`${e} minute${e!==1?"s":""} ago`}if(t<86400){let e=Math.floor(t/3600);return`${e} hour${e!==1?"s":""} ago`}if(t<2592e3){let e=Math.floor(t/86400);return`${e} day${e!==1?"s":""} ago`}if(t<31536e3){let e=Math.floor(t/2592e3);return`${e} month${e!==1?"s":""} ago`}let i=Math.floor(t/31536e3);return`${i} year${i!==1?"s":""} ago`}function g(r=document){for(let t of r.querySelectorAll("time[data-relative]")){let i=t.getAttribute("datetime");if(!i)continue;let e=f(new Date(i));e&&(t.textContent=e)}}var m=typeof document<"u"?document.documentElement:null,E;function A(){g(),E||(E=setInterval(()=>g(),6e4))}m&&!m.hasAttribute("data-vb-time-relative-init")&&(m.setAttribute("data-vb-time-relative-init",""),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A,{once:!0}):A());function b(r){let t=new Date(r);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function S(r){let t=new Date(r),i=(t.getDay()+6)%7,e=new Date(t);e.setDate(t.getDate()-i);let s=new Date(e);s.setDate(e.getDate()+3);let n=new Date(s.getFullYear(),0,1),o=Math.ceil(((s.getTime()-n.getTime())/864e5+1)/7);return`${s.getFullYear()}-W${String(o).padStart(2,"0")}`}function $(r){let t=b(new Date),i=b(new Date(Date.now()-864e5));if(r===t)return"Today";if(r===i)return"Yesterday";let[e,s,n]=r.split("-").map(Number);return new Date(e,s-1,n).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}function w(r){return r.nodeType===1&&r.matches("article[data-activity]")}function C(r){return`Week of ${r.replace("-W",", week ")}`}var M='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, iframe, [contenteditable=""], [contenteditable="true"], [tabindex]:not([tabindex="-1"])',D=0,p=class extends h{static observedAttributes=["data-infinite"];#e=null;#t=null;#s=null;#a=null;#r=null;#d=`activity-feed-${++D}`;#g=0;#i=!1;#l=0;#u=!0;setup(){let t=this.getAttribute("role");return this.#u=t===null||t==="feed"||t==="group",!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Recent activity"),this.#i=!1,this.setAttribute("aria-busy","false"),this.#n().forEach(i=>this.#h(i)),this.hasAttribute("data-infinite")&&this.#y(),this.#o(),this.#p(),this.#e=new MutationObserver(i=>{let e=!1,s=!1;for(let n of i){for(let o of n.addedNodes)w(o)&&(this.#h(o),e=!0,s=!0);for(let o of n.removedNodes)w(o)&&(e=!0)}e&&(this.#o(),this.#p()),s&&this.#i&&this.#c()}),this.#e.observe(this,{childList:!0}),this.#a=setInterval(()=>this.#E(),6e4),this.listen(this,"keydown",this.#$),this.listen(this,"focusin",this.#S),!0}teardown(){this.#a!==null&&clearInterval(this.#a),this.#a=null,this.#e?.disconnect(),this.#e=null,this.#v(),this.#i=!1,this.setAttribute("aria-busy","false")}attributeChangedCallback(t,i,e){!this.hasAttribute("data-upgraded")||i===null==(e===null)||t==="data-infinite"&&(e!==null?this.#y():(this.#v(),this.#i&&this.#c()),this.#o())}#n(){return[...this.querySelectorAll(":scope > article[data-activity]")]}#h(t){if(t.dataset.decorated==="")return;t.dataset.decorated="",t.setAttribute("tabindex","-1");let i=`${this.#d}-e${++this.#g}`,e=t.querySelector(":scope > time[datetime]");e?.remove();let s=t.dataset.time||e?.getAttribute("datetime")||"";s&&!t.dataset.time&&(t.dataset.time=s);let n=document.createElement("div");for(n.className="activity-body",n.id=`${i}-body`;t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n),!t.hasAttribute("aria-label")&&!t.hasAttribute("aria-labelledby")&&t.setAttribute("aria-labelledby",n.id);let o=t.dataset.activityAvatar,c=t.dataset.activityIcon;if(o||c){let a=document.createElement("div");if(a.className="activity-rail",a.setAttribute("aria-hidden","true"),o){let d=document.createElement("user-avatar"),l=n.querySelector("[data-activity-actor]")?.textContent?.trim()||"";l&&d.setAttribute("name",l);let u=document.createElement("img");u.src=o,u.alt="",u.loading="lazy",u.decoding="async",d.appendChild(u),a.appendChild(d)}else{let d=document.createElement("icon-wc");d.setAttribute("name",c||""),a.appendChild(d)}t.prepend(a)}if(s){let a=e||document.createElement("time");a.classList.add("activity-time"),a.setAttribute("datetime",s),a.id||(a.id=`${i}-time`),a.setAttribute("title",this.#A(s)),a.textContent=f(new Date(s))||a.textContent||s,t.appendChild(a)}}#E(){for(let t of this.querySelectorAll(":scope > article[data-activity] > time.activity-time")){let i=t.getAttribute("datetime");if(!i)continue;let e=f(new Date(i));e&&(t.textContent=e)}}#A(t){try{return new Date(t).toLocaleString()}catch{return t}}#o(){this.querySelectorAll(":scope > [data-activity-heading]").forEach(n=>n.remove());let t=this.#n(),i=this.#t?"-1":String(t.length),e=this.getAttribute("data-group")||"none",s=null;t.forEach((n,o)=>{n.setAttribute("aria-posinset",String(o+1)),n.setAttribute("aria-setsize",i);let c=[];if(e!=="none"&&n.dataset.time){let d=e==="week"?S(n.dataset.time):b(n.dataset.time);if(d!==s){let l=document.createElement("h3");l.setAttribute("data-activity-heading",""),l.setAttribute("aria-hidden","true"),l.id=`${this.#d}-g-${d}`,l.className="activity-heading",l.textContent=e==="week"?C(d):$(d),this.insertBefore(l,n),c.push(l.id),s=d}}let a=n.querySelector(":scope > time.activity-time");a?.id&&c.push(a.id),c.length?n.setAttribute("aria-describedby",c.join(" ")):n.removeAttribute("aria-describedby")}),this.#w(),this.#f()}#f(){let t=this.#t;t&&t.parentNode===this&&this.lastElementChild!==t&&this.appendChild(t)}#w(){let t=this.#n(),i=t.find(e=>e.getAttribute("tabindex")==="0")||t[0];for(let e of t)e.setAttribute("tabindex",e===i?"0":"-1")}#m(t){for(let i of this.#n())i.setAttribute("tabindex",i===t?"0":"-1")}#b(t){let e=(t instanceof Element?t:null)?.closest("article[data-activity]")??null;return e&&e.parentElement===this?e:null}#S=t=>{let i=this.#b(t.target);i&&i.getAttribute("tabindex")!=="0"&&this.#m(i)};#p(){let t=this.#n().length;t===0?this.#r||(this.#r=document.createElement("p"),this.#r.className="activity-empty",this.#r.textContent=this.getAttribute("data-empty-text")||"No recent activity",this.appendChild(this.#r),this.#f()):(this.#r?.remove(),this.#r=null),this.#u&&this.setAttribute("role",t===0?"group":"feed")}#$=t=>{let i=t.target;if(i.isContentEditable||i.matches?.("input, textarea, select"))return;let e=this.#n(),s=this.#b(t.target),n=s?e.indexOf(s):-1;if(n===-1)return;let o=i===s;if(t.ctrlKey&&(t.key==="Home"||t.key==="End")){let d=this.#C(t.key==="Home"?"before":"after");d&&(t.preventDefault(),d.focus());return}if(t.altKey||t.ctrlKey||t.metaKey)return;let c=n;switch(t.key){case"PageDown":c=Math.min(e.length-1,n+1);break;case"PageUp":c=Math.max(0,n-1);break;case"ArrowDown":if(!o)return;c=Math.min(e.length-1,n+1);break;case"ArrowUp":if(!o)return;c=Math.max(0,n-1);break;case"Home":if(!o)return;c=0;break;case"End":if(!o)return;c=e.length-1;break;default:return}t.preventDefault();let a=e[c];a&&(this.#m(a),a.focus())};#C(t){let i=[...document.querySelectorAll(M)].filter(s=>!this.contains(s)&&(s.checkVisibility?.()??!0));return t==="after"?i.find(s=>this.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING)||null:i.filter(s=>this.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_PRECEDING).at(-1)||null}#y(){this.#t||!("IntersectionObserver"in window)||(this.querySelectorAll(":scope > .activity-sentinel").forEach(t=>t.remove()),this.#t=document.createElement("div"),this.#t.className="activity-sentinel",this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t),this.#s=new IntersectionObserver(t=>{t.some(i=>i.isIntersecting)&&this.#M()},{rootMargin:"200px"}),this.#s.observe(this.#t))}#v(){this.#s?.disconnect(),this.#s=null,this.#t?.remove(),this.#t=null}#M(){if(this.#i)return;this.#i=!0,this.setAttribute("aria-busy","true");let t=++this.#l,i=()=>{this.#i&&t===this.#l&&this.#c()};this.dispatchEvent(new CustomEvent("activity-feed:load-more",{bubbles:!0,detail:{done:i}}))}#c(){this.#i=!1,this.setAttribute("aria-busy","false"),this.#s&&this.#t&&(this.#s.unobserve(this.#t),this.#s.observe(this.#t))}addEntry(t,i={}){let e=document.createElement("article");if(e.setAttribute("data-activity",""),e.dataset.time=t.time,t.avatar&&(e.dataset.activityAvatar=t.avatar),t.icon&&(e.dataset.activityIcon=t.icon),e.innerHTML=t.html,i.prepend){let s=this.#n()[0];s?this.insertBefore(e,s):this.appendChild(e)}else this.#t?this.insertBefore(e,this.#t):this.appendChild(e);return e}removeEntry(t){t?.matches?.("article[data-activity]")&&t.remove()}clear(){this.#n().forEach(t=>t.remove())}get entries(){return this.#n()}get loading(){return this.#i}};v("activity-feed",p);export{p as ActivityFeed};
1
+ var C=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function y(s,t,i={}){let e=i.priority??10,r={impl:t,bundle:i.bundle,contract:i.contract,priority:e},n=p.get(s);if(customElements.get(s)){if(!n||n.priority>=e){n&&n.priority===e&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=e){n.priority===e&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}p.set(s,r),customElements.define(s,t)}var h=class extends HTMLElement{#i=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#i)t();this.#i=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,i,e,r){t.addEventListener(i,e,r),this.#i.push(()=>t.removeEventListener(i,e,r))}_reinit(){for(let t of this.#i)t();this.#i=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,i){this.#t||(this.#t=this.attachInternals());let e=this.#t.states;try{i?e.add(t):e.delete(t)}catch{let r=`--${t}`;i?e.add(r):e.delete(r)}}_adoptInternals(t){this.#t||(this.#t=t)}#e(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};function u(s){let t=(Date.now()-s.getTime())/1e3;if(Number.isNaN(t)||t<0)return null;if(t<60)return"just now";if(t<3600){let e=Math.floor(t/60);return`${e} minute${e!==1?"s":""} ago`}if(t<86400){let e=Math.floor(t/3600);return`${e} hour${e!==1?"s":""} ago`}if(t<2592e3){let e=Math.floor(t/86400);return`${e} day${e!==1?"s":""} ago`}if(t<31536e3){let e=Math.floor(t/2592e3);return`${e} month${e!==1?"s":""} ago`}let i=Math.floor(t/31536e3);return`${i} year${i!==1?"s":""} ago`}function g(s=document){for(let t of s.querySelectorAll("time[data-relative]")){if(t.closest("page-info"))continue;let i=t.getAttribute("datetime");if(!i)continue;let e=new Date(i),r=t.closest("[lang]")?.getAttribute("lang")||"",n=r&&!/^en\b/i.test(r)?w(e,r):u(e);n&&(t.textContent=n)}}function w(s,t){let i=(Date.now()-s.getTime())/1e3;if(Number.isNaN(i)||i<0)return null;let e;try{e=new Intl.RelativeTimeFormat(t,{numeric:"auto"})}catch{return u(s)}return i<60?e.format(0,"second"):i<3600?e.format(-Math.floor(i/60),"minute"):i<86400?e.format(-Math.floor(i/3600),"hour"):i<2592e3?e.format(-Math.floor(i/86400),"day"):i<31536e3?e.format(-Math.floor(i/2592e3),"month"):e.format(-Math.floor(i/31536e3),"year")}var f=typeof document<"u"?document.documentElement:null,v;function A(){g(),v||(v=setInterval(()=>g(),6e4))}f&&!f.hasAttribute("data-vb-time-relative-init")&&(f.setAttribute("data-vb-time-relative-init",""),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A,{once:!0}):A());function m(s){let t=new Date(s);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function M(s){let t=new Date(s),i=(t.getDay()+6)%7,e=new Date(t);e.setDate(t.getDate()-i);let r=new Date(e);r.setDate(e.getDate()+3);let n=new Date(r.getFullYear(),0,1),o=Math.ceil(((r.getTime()-n.getTime())/864e5+1)/7);return`${r.getFullYear()}-W${String(o).padStart(2,"0")}`}function N(s){let t=m(new Date),i=m(new Date(Date.now()-864e5));if(s===t)return"Today";if(s===i)return"Yesterday";let[e,r,n]=s.split("-").map(Number);return new Date(e,r-1,n).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}function E(s){return s.nodeType===1&&s.matches("article[data-activity]")}function S(s){return`Week of ${s.replace("-W",", week ")}`}var $='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, iframe, [contenteditable=""], [contenteditable="true"], [tabindex]:not([tabindex="-1"])',D=0,b=class extends h{static observedAttributes=["data-infinite"];#i=null;#t=null;#e=null;#a=null;#s=null;#l=`activity-feed-${++D}`;#v=0;#n=!1;#d=0;#u=!0;setup(){let t=this.getAttribute("role");return this.#u=t===null||t==="feed"||t==="group",!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Recent activity"),this.#n=!1,this.setAttribute("aria-busy","false"),this.#r().forEach(i=>this.#h(i)),this.hasAttribute("data-infinite")&&this.#y(),this.#o(),this.#p(),this.#i=new MutationObserver(i=>{let e=!1,r=!1;for(let n of i){for(let o of n.addedNodes)E(o)&&(this.#h(o),e=!0,r=!0);for(let o of n.removedNodes)E(o)&&(e=!0)}e&&(this.#o(),this.#p()),r&&this.#n&&this.#c()}),this.#i.observe(this,{childList:!0}),this.#a=setInterval(()=>this.#A(),6e4),this.listen(this,"keydown",this.#N),this.listen(this,"focusin",this.#M),!0}teardown(){this.#a!==null&&clearInterval(this.#a),this.#a=null,this.#i?.disconnect(),this.#i=null,this.#g(),this.#n=!1,this.setAttribute("aria-busy","false")}attributeChangedCallback(t,i,e){!this.hasAttribute("data-upgraded")||i===null==(e===null)||t==="data-infinite"&&(e!==null?this.#y():(this.#g(),this.#n&&this.#c()),this.#o())}#r(){return[...this.querySelectorAll(":scope > article[data-activity]")]}#h(t){if(t.dataset.decorated==="")return;t.dataset.decorated="",t.setAttribute("tabindex","-1");let i=`${this.#l}-e${++this.#v}`,e=t.querySelector(":scope > time[datetime]");e?.remove();let r=t.dataset.time||e?.getAttribute("datetime")||"";r&&!t.dataset.time&&(t.dataset.time=r);let n=document.createElement("div");for(n.className="activity-body",n.id=`${i}-body`;t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n),!t.hasAttribute("aria-label")&&!t.hasAttribute("aria-labelledby")&&t.setAttribute("aria-labelledby",n.id);let o=t.dataset.activityAvatar,c=t.dataset.activityIcon;if(o||c){let a=document.createElement("div");if(a.className="activity-rail",a.setAttribute("aria-hidden","true"),o){let l=document.createElement("user-avatar"),d=document.createElement("img");d.src=o,d.alt="",d.loading="lazy",d.decoding="async",l.appendChild(d),a.appendChild(l)}else{let l=document.createElement("icon-wc");l.setAttribute("name",c||""),a.appendChild(l)}t.prepend(a)}if(r){let a=e||document.createElement("time");a.classList.add("activity-time"),a.setAttribute("datetime",r),a.id||(a.id=`${i}-time`),a.setAttribute("title",this.#E(r)),a.textContent=u(new Date(r))||a.textContent||r,t.appendChild(a)}}#A(){for(let t of this.querySelectorAll(":scope > article[data-activity] > time.activity-time")){let i=t.getAttribute("datetime");if(!i)continue;let e=u(new Date(i));e&&(t.textContent=e)}}#E(t){try{return new Date(t).toLocaleString()}catch{return t}}#o(){this.querySelectorAll(":scope > [data-activity-heading]").forEach(n=>n.remove());let t=this.#r(),i=this.#t?"-1":String(t.length),e=this.getAttribute("data-group")||"none",r=null;t.forEach((n,o)=>{n.setAttribute("aria-posinset",String(o+1)),n.setAttribute("aria-setsize",i);let c=[];if(e!=="none"&&n.dataset.time){let l=e==="week"?M(n.dataset.time):m(n.dataset.time);if(l!==r){let d=document.createElement("h3");d.setAttribute("data-activity-heading",""),d.setAttribute("aria-hidden","true"),d.id=`${this.#l}-g-${l}`,d.className="activity-heading",d.textContent=e==="week"?S(l):N(l),this.insertBefore(d,n),c.push(d.id),r=l}}let a=n.querySelector(":scope > time.activity-time");a?.id&&c.push(a.id),c.length?n.setAttribute("aria-describedby",c.join(" ")):n.removeAttribute("aria-describedby")}),this.#w(),this.#f()}#f(){let t=this.#t;t&&t.parentNode===this&&this.lastElementChild!==t&&this.appendChild(t)}#w(){let t=this.#r(),i=t.find(e=>e.getAttribute("tabindex")==="0")||t[0];for(let e of t)e.setAttribute("tabindex",e===i?"0":"-1")}#m(t){for(let i of this.#r())i.setAttribute("tabindex",i===t?"0":"-1")}#b(t){let e=(t instanceof Element?t:null)?.closest("article[data-activity]")??null;return e&&e.parentElement===this?e:null}#M=t=>{let i=this.#b(t.target);i&&i.getAttribute("tabindex")!=="0"&&this.#m(i)};#p(){let t=this.#r().length;t===0?this.#s||(this.#s=document.createElement("p"),this.#s.className="activity-empty",this.#s.textContent=this.getAttribute("data-empty-text")||"No recent activity",this.appendChild(this.#s),this.#f()):(this.#s?.remove(),this.#s=null),this.#u&&this.setAttribute("role",t===0?"group":"feed")}#N=t=>{let i=t.target;if(i.isContentEditable||i.matches?.("input, textarea, select"))return;let e=this.#r(),r=this.#b(t.target),n=r?e.indexOf(r):-1;if(n===-1)return;let o=i===r;if(t.ctrlKey&&(t.key==="Home"||t.key==="End")){let l=this.#S(t.key==="Home"?"before":"after");l&&(t.preventDefault(),l.focus());return}if(t.altKey||t.ctrlKey||t.metaKey)return;let c=n;switch(t.key){case"PageDown":c=Math.min(e.length-1,n+1);break;case"PageUp":c=Math.max(0,n-1);break;case"ArrowDown":if(!o)return;c=Math.min(e.length-1,n+1);break;case"ArrowUp":if(!o)return;c=Math.max(0,n-1);break;case"Home":if(!o)return;c=0;break;case"End":if(!o)return;c=e.length-1;break;default:return}t.preventDefault();let a=e[c];a&&(this.#m(a),a.focus())};#S(t){let i=[...document.querySelectorAll($)].filter(r=>!this.contains(r)&&(r.checkVisibility?.()??!0));return t==="after"?i.find(r=>this.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING)||null:i.filter(r=>this.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_PRECEDING).at(-1)||null}#y(){this.#t||!("IntersectionObserver"in window)||(this.querySelectorAll(":scope > .activity-sentinel").forEach(t=>t.remove()),this.#t=document.createElement("div"),this.#t.className="activity-sentinel",this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t),this.#e=new IntersectionObserver(t=>{t.some(i=>i.isIntersecting)&&this.#$()},{rootMargin:"200px"}),this.#e.observe(this.#t))}#g(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null}#$(){if(this.#n)return;this.#n=!0,this.setAttribute("aria-busy","true");let t=++this.#d,i=()=>{this.#n&&t===this.#d&&this.#c()};this.dispatchEvent(new CustomEvent("activity-feed:load-more",{bubbles:!0,detail:{done:i}}))}#c(){this.#n=!1,this.setAttribute("aria-busy","false"),this.#e&&this.#t&&(this.#e.unobserve(this.#t),this.#e.observe(this.#t))}addEntry(t,i={}){let e=document.createElement("article");if(e.setAttribute("data-activity",""),e.dataset.time=t.time,t.avatar&&(e.dataset.activityAvatar=t.avatar),t.icon&&(e.dataset.activityIcon=t.icon),e.innerHTML=t.html,i.prepend){let r=this.#r()[0];r?this.insertBefore(e,r):this.appendChild(e)}else this.#t?this.insertBefore(e,this.#t):this.appendChild(e);return e}removeEntry(t){t?.matches?.("article[data-activity]")&&t.remove()}clear(){this.#r().forEach(t=>t.remove())}get entries(){return this.#r()}get loading(){return this.#n}};y("activity-feed",b);export{b as ActivityFeed};
2
2
  //# sourceMappingURL=activity-feed.js.map
@@ -1,4 +1,4 @@
1
- var R=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function w(o,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=v.get(o);if(customElements.get(o)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}v.set(o,n),customElements.define(o,t)}var h=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#e.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#t||(this.#t=t)}};async function g(o){let t=typeof globalThis<"u"?globalThis:null;if(!t||!(o in t))return{state:"unsupported"};try{let e=t[o];if(!e||typeof e.availability!="function")return{state:"unsupported"};let i=await e.availability();return i==="available"||i==="downloadable"||i==="downloading"||i==="unavailable"?{state:i}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}var T="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function x(o,{stripSelectors:t=T}={}){if(o==null)return"";let e;if(typeof o=="string"){if(typeof document>"u")return"";try{e=document.querySelector(o)}catch{return""}}else typeof o=="object"&&typeof o.cloneNode=="function"&&(e=o);if(!e)return"";let i=e.cloneNode(!0);return t&&typeof i.querySelectorAll=="function"&&i.querySelectorAll(t).forEach(n=>n.remove()),(i.textContent||"").trim().replace(/\s+/g," ")}var N=/\{(prompt|url|title|content)\}/g;function $(o,t=1500){let e=String(o??"");if(e.length<=t)return e;let i=e.slice(0,Math.max(0,t-1)),n=i.lastIndexOf(" ");return`${n>t*.8?i.slice(0,n):i}\u2026`}function S(o){return typeof o=="string"&&o.includes("{content}")}function C(o,t={},{contentLimit:e=1500}={}){if(!o)return"";let i={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:$(t.content,e)};return String(o).replace(N,(n,s)=>encodeURIComponent(i[s]))}async function*A(o,{prompt:t="",content:e,mode:i,messages:n,signal:s}={}){let a={prompt:t};e!==void 0&&(a.content=e),i!==void 0&&(a.mode=i),Array.isArray(n)&&(a.messages=n);let r=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:s});if(!r.ok)throw new Error(`AI endpoint ${o} returned ${r.status} ${r.statusText}`);if((r.headers.get("content-type")||"").toLowerCase().includes("application/json")){let l=await r.json(),c=typeof l?.text=="string"?l.text:"";c&&(yield c);return}if(!r.body||typeof r.body.getReader!="function"){let l=await r.text();l&&(yield l);return}let b=r.body.getReader(),m=new TextDecoder;try{for(;;){let{value:c,done:k}=await b.read();if(k)break;if(c){let y=m.decode(c,{stream:!0});y&&(yield y)}}let l=m.decode();l&&(yield l)}finally{try{b.releaseLock()}catch{}}}function E(o){return o?Math.ceil(String(o).length/4):0}var q=12e3,M=20;function p(o,{maxChars:t=q,maxMessages:e=M}={}){if(!Array.isArray(o)||o.length===0)return[];let i=[],n=0;for(let s=o.length-1;s>=0;s--){let a=o[s],r=String(a?.content??"").length;if(i.length>=e||n+r>t)break;i.unshift(a),n+=r}for(;i.length&&i[0].role==="assistant";)i.shift();return i}var _="Help me explore this article: {title} ({url})",O={user:{name:"You",role:"user"},assistant:{name:"Assistant",role:"agent"}},u={local:"Gemini Nano (on-device)",endpoint:"Server endpoint","deep-link":"Open in external tool"},f=class extends h{#e=null;#t=null;#o=null;#a=null;#l=null;#m=null;#c=null;#d=[];#s=null;#i=null;#h="unsupported";#n="unavailable";static get observedAttributes(){return["placeholder"]}setup(){this.#E()||this.#k(),this.#T(),this.#N(),this.#p(),this.#M()}teardown(){this.#i?.abort(),this.#i=null,this.#s?.destroy?.(),this.#s=null,this.#f()}attributeChangedCallback(t,e,i){if(t==="placeholder"){let n=this.querySelector("chat-input textarea");n&&(n.placeholder=i??"")}}async reset(){this.#i?.abort(),this.#i=null,this.#s?.destroy?.(),this.#s=null,this.#d=[],this.#f(),this.#e?.clearThread?.(),this.#p(),this.#r("ready")}stop(){this.#i?.abort()}#E(){let t=this.querySelector(":scope > chat-window");return t?(this.#e=t,this.#t=t.querySelector(".ai-chat-provider"),this.#o=this.querySelector(":scope > .ai-chat-ribbon"),this.#a=this.querySelector(":scope > .ai-chat-notice"),this.#l=this.querySelector(":scope > .ai-chat-starters"),this.#w(),!0):!1}#w(){this.#m=this.querySelector("chat-input [data-send]"),this.#c=this.querySelector("chat-input [data-stop]")}#k(){let t=this.getAttribute("placeholder")||"Type a message\u2026",e=document.createElement("template");e.innerHTML=`
1
+ var R=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function g(r,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=v.get(r);if(customElements.get(r)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}v.set(r,n),customElements.define(r,t)}var h=class extends HTMLElement{#i=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#i)t();this.#i=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#i.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#i)t();this.#i=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#t||(this.#t=t)}#e(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};async function w(r){let t=typeof globalThis<"u"?globalThis:null;if(!t||!(r in t))return{state:"unsupported"};try{let e=t[r];if(!e||typeof e.availability!="function")return{state:"unsupported"};let i=await e.availability();return i==="available"||i==="downloadable"||i==="downloading"||i==="unavailable"?{state:i}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}var T="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function x(r,{stripSelectors:t=T}={}){if(r==null)return"";let e;if(typeof r=="string"){if(typeof document>"u")return"";try{e=document.querySelector(r)}catch{return""}}else typeof r=="object"&&typeof r.cloneNode=="function"&&(e=r);if(!e)return"";let i=e.cloneNode(!0);return t&&typeof i.querySelectorAll=="function"&&i.querySelectorAll(t).forEach(n=>n.remove()),(i.textContent||"").trim().replace(/\s+/g," ")}var N=/\{(prompt|url|title|content)\}/g;function $(r,t=1500){let e=String(r??"");if(e.length<=t)return e;let i=e.slice(0,Math.max(0,t-1)),n=i.lastIndexOf(" ");return`${n>t*.8?i.slice(0,n):i}\u2026`}function S(r){return typeof r=="string"&&r.includes("{content}")}function A(r,t={},{contentLimit:e=1500}={}){if(!r)return"";let i={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:$(t.content,e)};return String(r).replace(N,(n,s)=>encodeURIComponent(i[s]))}async function*C(r,{prompt:t="",content:e,mode:i,messages:n,signal:s}={}){let a={prompt:t};e!==void 0&&(a.content=e),i!==void 0&&(a.mode=i),Array.isArray(n)&&(a.messages=n);let o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:s});if(!o.ok)throw new Error(`AI endpoint ${r} returned ${o.status} ${o.statusText}`);if((o.headers.get("content-type")||"").toLowerCase().includes("application/json")){let l=await o.json(),c=typeof l?.text=="string"?l.text:"";c&&(yield c);return}if(!o.body||typeof o.body.getReader!="function"){let l=await o.text();l&&(yield l);return}let b=o.body.getReader(),m=new TextDecoder;try{for(;;){let{value:c,done:k}=await b.read();if(k)break;if(c){let y=m.decode(c,{stream:!0});y&&(yield y)}}let l=m.decode();l&&(yield l)}finally{try{b.releaseLock()}catch{}}}function E(r){return r?Math.ceil(String(r).length/4):0}var M=12e3,q=20;function p(r,{maxChars:t=M,maxMessages:e=q}={}){if(!Array.isArray(r)||r.length===0)return[];let i=[],n=0;for(let s=r.length-1;s>=0;s--){let a=r[s],o=String(a?.content??"").length;if(i.length>=e||n+o>t)break;i.unshift(a),n+=o}for(;i.length&&i[0].role==="assistant";)i.shift();return i}var _="Help me explore this article: {title} ({url})",O={user:{name:"You",role:"user"},assistant:{name:"Assistant",role:"agent"}},u={local:"Gemini Nano (on-device)",endpoint:"Server endpoint","deep-link":"Open in external tool"},f=class extends h{#i=null;#t=null;#e=null;#a=null;#l=null;#m=null;#c=null;#d=[];#r=null;#n=null;#h="unsupported";#s="unavailable";static get observedAttributes(){return["placeholder"]}setup(){this.#E()||this.#k(),this.#T(),this.#N(),this.#p(),this.#q()}teardown(){this.#n?.abort(),this.#n=null,this.#r?.destroy?.(),this.#r=null,this.#f()}attributeChangedCallback(t,e,i){if(t==="placeholder"){let n=this.querySelector("chat-input textarea");n&&(n.placeholder=i??"")}}async reset(){this.#n?.abort(),this.#n=null,this.#r?.destroy?.(),this.#r=null,this.#d=[],this.#f(),this.#i?.clearThread?.(),this.#p(),this.#o("ready")}stop(){this.#n?.abort()}#E(){let t=this.querySelector(":scope > chat-window");return t?(this.#i=t,this.#t=t.querySelector(".ai-chat-provider"),this.#e=this.querySelector(":scope > .ai-chat-ribbon"),this.#a=this.querySelector(":scope > .ai-chat-notice"),this.#l=this.querySelector(":scope > .ai-chat-starters"),this.#g(),!0):!1}#g(){this.#m=this.querySelector("chat-input [data-send]"),this.#c=this.querySelector("chat-input [data-stop]")}#k(){let t=this.getAttribute("placeholder")||"Type a message\u2026",e=document.createElement("template");e.innerHTML=`
2
2
  <p class="ai-chat-ribbon" hidden></p>
3
3
  <p class="ai-chat-notice" hidden></p>
4
4
  <div class="ai-chat-starters" role="group" aria-label="Starter prompts" hidden></div>
@@ -20,12 +20,12 @@ var R=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;functi
20
20
  </footer>
21
21
  </chat-input>
22
22
  </chat-window>
23
- `,this.appendChild(e.content.cloneNode(!0)),this.#e=this.querySelector(":scope > chat-window"),this.#t=this.querySelector(".ai-chat-provider"),this.#o=this.querySelector(":scope > .ai-chat-ribbon"),this.#a=this.querySelector(":scope > .ai-chat-notice"),this.#l=this.querySelector(":scope > .ai-chat-starters"),this.#w();let i=this.querySelector("chat-input textarea");i&&(i.placeholder=t)}#T(){if(!this.#l)return;let t=this.querySelector(':scope > template[data-role="starters"]'),e=(t&&t.content?.textContent||"").split(`
24
- `).map(i=>i.trim()).filter(Boolean);if(this.#l.replaceChildren(),!e.length){this.#l.hidden=!0;return}this.#l.hidden=!1;for(let i of e){let n=document.createElement("button");n.type="button",n.className="ai-chat-starter small",n.textContent=i,this.listen(n,"click",()=>this.#$(i)),this.#l.appendChild(n)}}#N(){this.#e&&(this.listen(this,"chat-input:send",t=>{if(!this.#i)return;t.stopImmediatePropagation();let e=t.target,i=t.detail?.message??"";queueMicrotask(()=>{e&&"value"in e&&(e.value=i)})},{capture:!0}),this.listen(this.#e,"chat-window:send",t=>{t.stopPropagation(),this.#O(t.detail.message,t.detail.typingElement)}),this.listen(this.#e,"chat-window:model-change",t=>{let e=t.detail.model;e&&e!==this.#n&&(this.#n=e,this.#s?.destroy?.(),this.#s=null,this.#x())}),this.listen(this,"keydown",t=>{t.key==="Escape"&&this.#i&&(t.preventDefault(),this.#i.abort())}),this.#c&&this.listen(this.#c,"click",()=>{this.#i?.abort(),this.querySelector("chat-input textarea")?.focus()}),this.listen(this,"focusin",t=>{let e=t.relatedTarget;e&&this.contains(e)||this.#p()}))}#$(t){let e=this.querySelector("chat-input");if(!e)return;e.value=t;let i=e.querySelector("textarea");i&&i.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))}#g(){return this.getAttribute("context")?.trim()||""}#u(){let t=this.#g();return t?x(t,{stripSelectors:"ai-chat, ai-summary, .ais-ui"}):""}#p(){if(!this.#o)return;let t=this.#g();if(!t){this.#o.hidden=!0;return}let e=this.#u();if(!e){this.#o.hidden=!1,this.#o.textContent=`Context selector "${t}" matched no readable content.`,this.setAttribute("data-context-state","missing");return}let i=e.length,n=E(e),s=i>6e3,a=this.getAttribute("context-label")||t;this.#o.hidden=!1,this.#o.replaceChildren();let r=document.createElement("span");if(r.className="ai-chat-ribbon-lead",r.textContent=`Page context: ${a} \xB7 ${i.toLocaleString()} chars (~${n.toLocaleString()} tokens)`,this.#o.appendChild(r),s){let d=document.createElement("span");d.className="ai-chat-ribbon-warn",d.textContent="large \u2014 may crowd the conversation",this.#o.appendChild(d)}this.setAttribute("data-context-state",s?"large":"ok")}#q(){let t=this.getAttribute("system")?.trim()||this.querySelector(':scope > template[data-role="system"]')?.content?.textContent?.trim()||"",e=this.#u();if(!e)return t||void 0;let n=`
23
+ `,this.appendChild(e.content.cloneNode(!0)),this.#i=this.querySelector(":scope > chat-window"),this.#t=this.querySelector(".ai-chat-provider"),this.#e=this.querySelector(":scope > .ai-chat-ribbon"),this.#a=this.querySelector(":scope > .ai-chat-notice"),this.#l=this.querySelector(":scope > .ai-chat-starters"),this.#g();let i=this.querySelector("chat-input textarea");i&&(i.placeholder=t)}#T(){if(!this.#l)return;let t=this.querySelector(':scope > template[data-role="starters"]'),e=(t&&t.content?.textContent||"").split(`
24
+ `).map(i=>i.trim()).filter(Boolean);if(this.#l.replaceChildren(),!e.length){this.#l.hidden=!0;return}this.#l.hidden=!1;for(let i of e){let n=document.createElement("button");n.type="button",n.className="ai-chat-starter small",n.textContent=i,this.listen(n,"click",()=>this.#$(i)),this.#l.appendChild(n)}}#N(){this.#i&&(this.listen(this,"chat-input:send",t=>{if(!this.#n)return;t.stopImmediatePropagation();let e=t.target,i=t.detail?.message??"";queueMicrotask(()=>{e&&"value"in e&&(e.value=i)})},{capture:!0}),this.listen(this.#i,"chat-window:send",t=>{t.stopPropagation(),this.#O(t.detail.message,t.detail.typingElement)}),this.listen(this.#i,"chat-window:model-change",t=>{let e=t.detail.model;e&&e!==this.#s&&(this.#s=e,this.#r?.destroy?.(),this.#r=null,this.#x())}),this.listen(this,"keydown",t=>{t.key==="Escape"&&this.#n&&(t.preventDefault(),this.#n.abort())}),this.#c&&this.listen(this.#c,"click",()=>{this.#n?.abort(),this.querySelector("chat-input textarea")?.focus()}),this.listen(this,"focusin",t=>{let e=t.relatedTarget;e&&this.contains(e)||this.#p()}))}#$(t){let e=this.querySelector("chat-input");if(!e)return;e.value=t;let i=e.querySelector("textarea");i&&i.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))}#w(){return this.getAttribute("context")?.trim()||""}#u(){let t=this.#w();return t?x(t,{stripSelectors:"ai-chat, ai-summary, .ais-ui"}):""}#p(){if(!this.#e)return;let t=this.#w();if(!t){this.#e.hidden=!0;return}let e=this.#u();if(!e){this.#e.hidden=!1,this.#e.textContent=`Context selector "${t}" matched no readable content.`,this.setAttribute("data-context-state","missing");return}let i=e.length,n=E(e),s=i>6e3,a=this.getAttribute("context-label")||t;this.#e.hidden=!1,this.#e.replaceChildren();let o=document.createElement("span");if(o.className="ai-chat-ribbon-lead",o.textContent=`Page context: ${a} \xB7 ${i.toLocaleString()} chars (~${n.toLocaleString()} tokens)`,this.#e.appendChild(o),s){let d=document.createElement("span");d.className="ai-chat-ribbon-warn",d.textContent="large \u2014 may crowd the conversation",this.#e.appendChild(d)}this.setAttribute("data-context-state",s?"large":"ok")}#M(){let t=this.getAttribute("system")?.trim()||this.querySelector(':scope > template[data-role="system"]')?.content?.textContent?.trim()||"",e=this.#u();if(!e)return t||void 0;let n=`
25
25
 
26
26
  [PAGE CONTENT \u2014 ${this.getAttribute("context-label")||"page"}]
27
27
  ${e}
28
- [END PAGE CONTENT]`;return t?t+n:`Use the following page content to answer the user.${n}`}async#M(){this.#r("checking");let{state:t}=await g("LanguageModel");this.#h=t;let e=[];t==="available"||t==="downloadable"||t==="downloading"?e.push({value:"local",label:u.local}):e.push({value:"local",label:`${u.local} \u2014 unavailable`,disabled:!0}),this.getAttribute("endpoint")&&e.push({value:"endpoint",label:u.endpoint}),this.getAttribute("fallback-url")&&e.push({value:"deep-link",label:this.getAttribute("fallback-label")||u["deep-link"]}),this.#L(e);let i=e.find(n=>!n.disabled&&n.value===this.#n)??e.find(n=>!n.disabled);this.#n=i?.value??"unavailable",this.#t&&i&&(this.#t.value=i.value),this.#e&&(this.#e.model=this.#n),this.#x(),this.#r(this.#n==="unavailable"?"unavailable":"ready")}#L(t){if(this.#t){if(this.#t.replaceChildren(),t.length===0){let e=document.createElement("option");e.textContent="Unavailable",e.disabled=!0,this.#t.appendChild(e),this.#t.disabled=!0;return}for(let e of t){let i=document.createElement("option");i.value=e.value,i.textContent=e.label,e.disabled&&(i.disabled=!0),this.#t.appendChild(i)}this.#t.disabled=t.every(e=>e.disabled)}}#x(){this.#m?.setAttribute("aria-label",this.#n==="deep-link"?"Send (opens in new tab)":"Send"),this.#n==="unavailable"?this.#b("On-device AI unavailable and no fallback configured. Set endpoint= or fallback-url= to enable a fallback."):this.#n==="deep-link"?this.#b("Send opens the external tool in a new tab. Choose another provider above to chat in-page."):this.#h==="downloadable"&&this.#n==="local"?this.#b("First message will download the on-device model (~1.6 GB)."):this.#v()}async#_(t){if(this.#s)return this.#s;let e=this.#q(),i=[...e?[{role:"system",content:e}]:[],...p(this.#d)],n=i.length?i:void 0;return this.#s=await LanguageModel.create({initialPrompts:n,signal:t,expectedInputs:[{type:"text",languages:["en"]}],expectedOutputs:[{type:"text",languages:["en"]}],monitor:s=>{s.addEventListener("downloadprogress",a=>{if(a.loaded>=1){this.#h="available",this.#v();return}this.#r("downloading"),this.#b(`Downloading on-device model: ${Math.round(a.loaded*100)}%`)})}}),this.#h="available",this.#v(),this.#s.addEventListener?.("contextoverflow",()=>{this.dispatchEvent(new CustomEvent("ai-chat:context-overflow",{bubbles:!0}))}),this.#s}async#O(t,e){if(this.#i){e.remove();return}if(this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"user",text:t},bubbles:!0})),this.#n==="deep-link"){e.remove(),window.open(this.#B(t),"_blank","noopener,noreferrer");return}if(this.#n==="unavailable"){this.#C(e,"Chat is unavailable in this browser.",{error:!0});return}let i=e.querySelector("chat-bubble");if(!i)return;let n=new AbortController;this.#i=n,this.#r("streaming"),this.#f(),e.setAttribute("aria-busy","true"),this.#p();let s="";try{let a=this.#n==="local"?await this.#R(t,n.signal):A(this.getAttribute("endpoint")||"",{prompt:t,content:this.#u()||void 0,mode:"chat",messages:p(this.#d),signal:n.signal});this.getAttribute("data-state")!=="streaming"&&this.#r("streaming");for await(let r of a)s+=r,i.textContent=s,this.#A();this.#y(e,s||" "),this.#A(),this.#S(t,s),this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"assistant",text:s},bubbles:!0})),this.#r("ready")}catch(a){let r=a;if(r?.name==="AbortError"){s&&this.#S(t,s),this.#y(e,s?`${s} (stopped)`:"(stopped)"),this.#r("ready");return}this.#C(e,r?.message||"Generation failed",{error:!0}),this.#r("error"),this.dispatchEvent(new CustomEvent("ai-chat:error",{detail:{error:a},bubbles:!0}))}finally{e.removeAttribute("aria-busy"),this.#i===n&&(this.#i=null),this.#f()}}#S(t,e){this.#d.push({role:"user",content:t},{role:"assistant",content:e})}#f(){let t=!!this.#i,e=this.#m,i=this.#c;if(!e||!i||i.hidden===!t)return;let n=document.activeElement;e.hidden=t,i.hidden=!t,t&&n===e?i.focus():!t&&n===i&&this.querySelector("chat-input textarea")?.focus()}async#R(t,e){let n=(await this.#_(e)).promptStreaming(t,{signal:e});return(async function*(){for await(let s of n)yield s})()}#y(t,e){let i=t.querySelector("chat-bubble");i&&(i.textContent=e),t.removeAttribute("data-status"),t.removeAttribute("aria-label")}#C(t,e,i={}){this.#y(t,e),i.error&&t.setAttribute("data-status","error")}#A(){this.#e?.scrollToBottom?.()}#r(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-chat:state",{detail:{state:t,provider:this.#n},bubbles:!0}))}#b(t){this.#a&&(this.#a.hidden=!1,this.#a.textContent=t)}#v(){this.#a&&(this.#a.hidden=!0,this.#a.textContent="")}#B(t){let i=(this.getAttribute("fallback-prompt")||_).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title),n=t?`${i}
28
+ [END PAGE CONTENT]`;return t?t+n:`Use the following page content to answer the user.${n}`}async#q(){this.#o("checking");let{state:t}=await w("LanguageModel");this.#h=t;let e=[];t==="available"||t==="downloadable"||t==="downloading"?e.push({value:"local",label:u.local}):e.push({value:"local",label:`${u.local} \u2014 unavailable`,disabled:!0}),this.getAttribute("endpoint")&&e.push({value:"endpoint",label:u.endpoint}),this.getAttribute("fallback-url")&&e.push({value:"deep-link",label:this.getAttribute("fallback-label")||u["deep-link"]}),this.#L(e);let i=e.find(n=>!n.disabled&&n.value===this.#s)??e.find(n=>!n.disabled);this.#s=i?.value??"unavailable",this.#t&&i&&(this.#t.value=i.value),this.#i&&(this.#i.model=this.#s),this.#x(),this.#o(this.#s==="unavailable"?"unavailable":"ready")}#L(t){if(this.#t){if(this.#t.replaceChildren(),t.length===0){let e=document.createElement("option");e.textContent="Unavailable",e.disabled=!0,this.#t.appendChild(e),this.#t.disabled=!0;return}for(let e of t){let i=document.createElement("option");i.value=e.value,i.textContent=e.label,e.disabled&&(i.disabled=!0),this.#t.appendChild(i)}this.#t.disabled=t.every(e=>e.disabled)}}#x(){this.#m?.setAttribute("aria-label",this.#s==="deep-link"?"Send (opens in new tab)":"Send"),this.#s==="unavailable"?this.#b("On-device AI unavailable and no fallback configured. Set endpoint= or fallback-url= to enable a fallback."):this.#s==="deep-link"?this.#b("Send opens the external tool in a new tab. Choose another provider above to chat in-page."):this.#h==="downloadable"&&this.#s==="local"?this.#b("First message will download the on-device model (~1.6 GB)."):this.#v()}async#_(t){if(this.#r)return this.#r;let e=this.#M(),i=[...e?[{role:"system",content:e}]:[],...p(this.#d)],n=i.length?i:void 0;return this.#r=await LanguageModel.create({initialPrompts:n,signal:t,expectedInputs:[{type:"text",languages:["en"]}],expectedOutputs:[{type:"text",languages:["en"]}],monitor:s=>{s.addEventListener("downloadprogress",a=>{if(a.loaded>=1){this.#h="available",this.#v();return}this.#o("downloading"),this.#b(`Downloading on-device model: ${Math.round(a.loaded*100)}%`)})}}),this.#h="available",this.#v(),this.#r.addEventListener?.("contextoverflow",()=>{this.dispatchEvent(new CustomEvent("ai-chat:context-overflow",{bubbles:!0}))}),this.#r}async#O(t,e){if(this.#n){e.remove();return}if(this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"user",text:t},bubbles:!0})),this.#s==="deep-link"){e.remove(),window.open(this.#B(t),"_blank","noopener,noreferrer");return}if(this.#s==="unavailable"){this.#A(e,"Chat is unavailable in this browser.",{error:!0});return}let i=e.querySelector("chat-bubble");if(!i)return;let n=new AbortController;this.#n=n,this.#o("streaming"),this.#f(),e.setAttribute("aria-busy","true"),this.#p();let s="";try{let a=this.#s==="local"?await this.#R(t,n.signal):C(this.getAttribute("endpoint")||"",{prompt:t,content:this.#u()||void 0,mode:"chat",messages:p(this.#d),signal:n.signal});this.getAttribute("data-state")!=="streaming"&&this.#o("streaming");for await(let o of a)s+=o,i.textContent=s,this.#C();this.#y(e,s||" "),this.#C(),this.#S(t,s),this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"assistant",text:s},bubbles:!0})),this.#o("ready")}catch(a){let o=a;if(o?.name==="AbortError"){s&&this.#S(t,s),this.#y(e,s?`${s} (stopped)`:"(stopped)"),this.#o("ready");return}this.#A(e,o?.message||"Generation failed",{error:!0}),this.#o("error"),this.dispatchEvent(new CustomEvent("ai-chat:error",{detail:{error:a},bubbles:!0}))}finally{e.removeAttribute("aria-busy"),this.#n===n&&(this.#n=null),this.#f()}}#S(t,e){this.#d.push({role:"user",content:t},{role:"assistant",content:e})}#f(){let t=!!this.#n,e=this.#m,i=this.#c;if(!e||!i||i.hidden===!t)return;let n=document.activeElement;e.hidden=t,i.hidden=!t,t&&n===e?i.focus():!t&&n===i&&this.querySelector("chat-input textarea")?.focus()}async#R(t,e){let n=(await this.#_(e)).promptStreaming(t,{signal:e});return(async function*(){for await(let s of n)yield s})()}#y(t,e){let i=t.querySelector("chat-bubble");i&&(i.textContent=e),t.removeAttribute("data-status"),t.removeAttribute("aria-label")}#A(t,e,i={}){this.#y(t,e),i.error&&t.setAttribute("data-status","error")}#C(){this.#i?.scrollToBottom?.()}#o(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-chat:state",{detail:{state:t,provider:this.#s},bubbles:!0}))}#b(t){this.#a&&(this.#a.hidden=!1,this.#a.textContent=t)}#v(){this.#a&&(this.#a.hidden=!0,this.#a.textContent="")}#B(t){let i=(this.getAttribute("fallback-prompt")||_).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title),n=t?`${i}
29
29
 
30
- User: ${t}`:i,s=this.getAttribute("fallback-url"),a=S(s)?this.#u():"";return C(s,{prompt:n,content:a})}};w("ai-chat",f);export{f as AIChat};
30
+ User: ${t}`:i,s=this.getAttribute("fallback-url"),a=S(s)?this.#u():"";return A(s,{prompt:n,content:a})}};g("ai-chat",f);export{f as AIChat};
31
31
  //# sourceMappingURL=ai-chat.js.map
@@ -1,4 +1,4 @@
1
- var R=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function b(i,t,e={}){let n=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:n},r=m.get(i);if(customElements.get(i)){if(!r||r.priority>=n){r&&r.priority===n&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=n){r.priority===n&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}m.set(i,s),customElements.define(i,t)}var d=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,s){t.addEventListener(e,n,s),this.#t.push(()=>t.removeEventListener(e,n,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let n=this.#e.states;try{e?n.add(t):n.delete(t)}catch{let s=`--${t}`;e?n.add(s):n.delete(s)}}_adoptInternals(t){this.#e||(this.#e=t)}};var T=["available","downloadable","downloading"];async function y(i){let t=typeof globalThis<"u"?globalThis:null;if(!t||!(i in t))return{state:"unsupported"};try{let e=t[i];if(!e||typeof e.availability!="function")return{state:"unsupported"};let n=await e.availability();return n==="available"||n==="downloadable"||n==="downloading"||n==="unavailable"?{state:n}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}function g({availability:i,endpoint:t,fallbackURL:e}){return T.includes(i)?"local":t?"endpoint":e?"deep-link":"unavailable"}var M="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function v(i,{stripSelectors:t=M}={}){if(i==null)return"";let e;if(typeof i=="string"){if(typeof document>"u")return"";try{e=document.querySelector(i)}catch{return""}}else typeof i=="object"&&typeof i.cloneNode=="function"&&(e=i);if(!e)return"";let n=e.cloneNode(!0);return t&&typeof n.querySelectorAll=="function"&&n.querySelectorAll(t).forEach(s=>s.remove()),(n.textContent||"").trim().replace(/\s+/g," ")}var N=/\{(prompt|url|title|content)\}/g;function _(i,t=1500){let e=String(i??"");if(e.length<=t)return e;let n=e.slice(0,Math.max(0,t-1)),s=n.lastIndexOf(" ");return`${s>t*.8?n.slice(0,s):n}\u2026`}function w(i){return typeof i=="string"&&i.includes("{content}")}function E(i,t={},{contentLimit:e=1500}={}){if(!i)return"";let n={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:_(t.content,e)};return String(i).replace(N,(s,r)=>encodeURIComponent(n[r]))}async function*C(i,{prompt:t="",content:e,mode:n,messages:s,signal:r}={}){let o={prompt:t};e!==void 0&&(o.content=e),n!==void 0&&(o.mode=n),Array.isArray(s)&&(o.messages=s);let a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:r});if(!a.ok)throw new Error(`AI endpoint ${i} returned ${a.status} ${a.statusText}`);if((a.headers.get("content-type")||"").toLowerCase().includes("application/json")){let l=await a.json(),c=typeof l?.text=="string"?l.text:"";c&&(yield c);return}if(!a.body||typeof a.body.getReader!="function"){let l=await a.text();l&&(yield l);return}let h=a.body.getReader(),f=new TextDecoder;try{for(;;){let{value:c,done:S}=await h.read();if(S)break;if(c){let p=f.decode(c,{stream:!0});p&&(yield p)}}let l=f.decode();l&&(yield l)}finally{try{h.releaseLock()}catch{}}}var x=16e3;function A(i,t,e){let n=String(i??"");if(!(t>0)||!(e>0)||!Number.isFinite(e)||t<=e)return n;let s=Math.floor(n.length*(e/t)*.95);return n.slice(0,Math.max(0,s))}var L="Summarize this article: {url}",u=class extends d{#t=null;#e=null;#n=null;#o=null;#a=null;#s=null;#r="unavailable";setup(){this.#p(),this.#m()}teardown(){this.#s?.abort(),this.#s=null}stop(){this.#s?.abort()}#p(){let t=this.querySelector(":scope > .ais-ui");if(t){this.#l(t);return}let e=document.createElement("div");e.className="ais-ui",e.innerHTML=`
1
+ var R=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function b(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=m.get(n);if(customElements.get(n)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=i){r.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}m.set(n,s),customElements.define(n,t)}var u=class extends HTMLElement{#t=[];#i;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#t.push(()=>t.removeEventListener(e,i,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#i||(this.#i=this.attachInternals());let i=this.#i.states;try{e?i.add(t):i.delete(t)}catch{let s=`--${t}`;e?i.add(s):i.delete(s)}}_adoptInternals(t){this.#i||(this.#i=t)}#e(){return this.constructor.formAssociated&&this.#i?this.#i:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};var T=["available","downloadable","downloading"];async function y(n){let t=typeof globalThis<"u"?globalThis:null;if(!t||!(n in t))return{state:"unsupported"};try{let e=t[n];if(!e||typeof e.availability!="function")return{state:"unsupported"};let i=await e.availability();return i==="available"||i==="downloadable"||i==="downloading"||i==="unavailable"?{state:i}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}function g({availability:n,endpoint:t,fallbackURL:e}){return T.includes(n)?"local":t?"endpoint":e?"deep-link":"unavailable"}var M="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function v(n,{stripSelectors:t=M}={}){if(n==null)return"";let e;if(typeof n=="string"){if(typeof document>"u")return"";try{e=document.querySelector(n)}catch{return""}}else typeof n=="object"&&typeof n.cloneNode=="function"&&(e=n);if(!e)return"";let i=e.cloneNode(!0);return t&&typeof i.querySelectorAll=="function"&&i.querySelectorAll(t).forEach(s=>s.remove()),(i.textContent||"").trim().replace(/\s+/g," ")}var N=/\{(prompt|url|title|content)\}/g;function _(n,t=1500){let e=String(n??"");if(e.length<=t)return e;let i=e.slice(0,Math.max(0,t-1)),s=i.lastIndexOf(" ");return`${s>t*.8?i.slice(0,s):i}\u2026`}function w(n){return typeof n=="string"&&n.includes("{content}")}function E(n,t={},{contentLimit:e=1500}={}){if(!n)return"";let i={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:_(t.content,e)};return String(n).replace(N,(s,r)=>encodeURIComponent(i[r]))}async function*A(n,{prompt:t="",content:e,mode:i,messages:s,signal:r}={}){let o={prompt:t};e!==void 0&&(o.content=e),i!==void 0&&(o.mode=i),Array.isArray(s)&&(o.messages=s);let a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:r});if(!a.ok)throw new Error(`AI endpoint ${n} returned ${a.status} ${a.statusText}`);if((a.headers.get("content-type")||"").toLowerCase().includes("application/json")){let l=await a.json(),c=typeof l?.text=="string"?l.text:"";c&&(yield c);return}if(!a.body||typeof a.body.getReader!="function"){let l=await a.text();l&&(yield l);return}let h=a.body.getReader(),f=new TextDecoder;try{for(;;){let{value:c,done:S}=await h.read();if(S)break;if(c){let p=f.decode(c,{stream:!0});p&&(yield p)}}let l=f.decode();l&&(yield l)}finally{try{h.releaseLock()}catch{}}}var k=16e3;function C(n,t,e){let i=String(n??"");if(!(t>0)||!(e>0)||!Number.isFinite(e)||t<=e)return i;let s=Math.floor(i.length*(e/t)*.95);return i.slice(0,Math.max(0,s))}var L="Summarize this article: {url}",d=class extends u{#t=null;#i=null;#e=null;#o=null;#a=null;#s=null;#r="unavailable";setup(){this.#p(),this.#m()}teardown(){this.#s?.abort(),this.#s=null}stop(){this.#s?.abort()}#p(){let t=this.querySelector(":scope > .ais-ui");if(t){this.#l(t);return}let e=document.createElement("div");e.className="ais-ui",e.innerHTML=`
2
2
  <div class="ais-controls">
3
3
  <button type="button" class="ais-trigger small" disabled>
4
4
  <span class="ais-label">Summarize</span>
@@ -8,5 +8,5 @@ var R=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;functi
8
8
  </div>
9
9
  <p class="ais-notice" role="status" hidden></p>
10
10
  <div class="ais-output" hidden aria-live="polite"></div>
11
- `,this.prepend(e),this.#l(e)}#l(t){this.#t=t.querySelector(".ais-trigger"),this.#e=t.querySelector(".ais-status"),this.#n=t.querySelector(".ais-output"),this.#o=t.querySelector(".ais-stop"),this.#a=t.querySelector(".ais-notice"),this.listen(this.#t,"click",()=>this.#y()),this.#o&&this.listen(this.#o,"click",()=>this.#s?.abort()),this.listen(this,"keydown",e=>{e.key==="Escape"&&this.#s&&(e.preventDefault(),this.#s.abort())})}async#m(){this.#i("checking");let{state:t}=await y("Summarizer");this.#r=g({availability:t,endpoint:this.getAttribute("endpoint")||void 0,fallbackURL:this.getAttribute("fallback-url")||void 0}),this.#b(t)}#b(t){if(!(!this.#t||!this.#e)){if(this.#A(this.#r==="deep-link"),this.#r==="local"){this.#e.dataset.state=t,this.#e.textContent={available:"Ready (on-device)",downloadable:"Model available \u2014 first run will download",downloading:"Model downloading\u2026"}[t]??t,this.#t.disabled=!1,this.#t.dataset.provider="local",this.#i("ready");return}if(this.#r==="endpoint"){this.#e.dataset.state="available",this.#e.textContent="Ready (remote)",this.#t.disabled=!1,this.#t.dataset.provider="endpoint",this.#i("ready");return}if(this.#r==="deep-link"){this.#e.dataset.state="unavailable",this.#e.textContent="On-device AI unavailable \u2014 using deep-link",this.#t.disabled=!1,this.#t.dataset.provider="deep-link";let e=this.getAttribute("fallback-label")||"Read elsewhere";this.#x(e),this.#i("deep-link");return}this.#e.dataset.state="unavailable",this.#e.textContent="Summarization not available on this device",this.#t.disabled=!0,this.#t.dataset.provider="unavailable",this.#i("unavailable")}}async#y(){if(!this.#t||!this.#n)return;if(this.#r==="deep-link"){window.open(this.#h(),"_blank","noopener,noreferrer");return}if(this.#r==="unavailable")return;this.#n.hidden=!1,this.#n.textContent="",this.#k(),this.#n.setAttribute("aria-busy","true"),this.#i("streaming");let t=new AbortController;this.#s=t,this.#c(!0);let e="";try{let n=this.#d(),s=this.#r==="local"?await this.#g(n,t.signal):C(this.getAttribute("endpoint")||"",{prompt:this.#u(),content:n,mode:"summarize",signal:t.signal});this.getAttribute("data-state")!=="streaming"&&this.#i("streaming");for await(let r of s)e+=r,this.#n.textContent=e;this.#w(e),this.#i("complete"),this.dispatchEvent(new CustomEvent("ai-summary:result",{detail:{text:e,provider:this.#r},bubbles:!0}))}catch(n){if(n&&n.name==="AbortError"){this.#n.textContent=e?`${e} (stopped)`:"(stopped)",this.#i("ready");return}this.#C(n),this.#i("error"),this.dispatchEvent(new CustomEvent("ai-summary:error",{detail:{error:n},bubbles:!0}))}finally{this.#n.removeAttribute("aria-busy"),this.#s===t&&(this.#s=null),this.#c(!1)}}#c(t){if(!this.#t)return;let e=document.activeElement;this.#t.disabled=t,this.#o&&(this.#o.hidden=!t,t&&e===this.#t?this.#o.focus():!t&&e===this.#o&&this.#t.focus())}async#g(t,e){let n=await Summarizer.create({signal:e,type:this.getAttribute("type")||"key-points",format:this.getAttribute("format")||"markdown",length:this.getAttribute("length")||"medium",sharedContext:this.getAttribute("shared-context")||void 0,expectedInputLanguages:["en"],outputLanguage:"en",monitor:o=>{o.addEventListener("downloadprogress",a=>{this.#i("downloading"),this.#e&&(this.#e.textContent=`Downloading model: ${Math.round(a.loaded*100)}%`)})}}),s=t;try{s=await this.#v(n,t,e)}catch(o){throw n.destroy?.(),o}let r=typeof n.summarizeStreaming=="function"?n.summarizeStreaming(s,{signal:e}):(async function*(){yield await n.summarize(s,{signal:e})})();return(async function*(){try{for await(let o of r)yield o}finally{n.destroy?.()}})()}async#v(t,e,n){let s=t?.inputQuota;if(typeof t?.measureInputUsage=="function"&&typeof s=="number"){let r;try{r=await t.measureInputUsage(e,{signal:n})}catch(o){if(o?.name==="AbortError")throw o;r=void 0}if(typeof r=="number"&&r>s){let o=A(e,r,s),a=Math.max(1,Math.round(o.length/e.length*100));return this.#f(`This content is longer than the on-device model accepts; summarizing the first ${a}%.`),o}return e}return e.length>x&&this.#f(`This content is long (${e.length.toLocaleString()} characters) and may exceed the on-device model's limit.`),e}#d(){return v(this,{stripSelectors:".ais-ui"})}#u(){return(this.getAttribute("fallback-prompt")||L).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title)}#h(){let t=this.getAttribute("fallback-url");return E(t,{prompt:this.#u(),content:w(t)?this.#d():""})}#w(t){if(this.#n){if((this.getAttribute("format")||"markdown")==="plain-text"){this.#n.textContent=t;return}this.#E(t)}}#E(t){if(!this.#n)return;if(!t){this.#n.textContent="";return}let e=document.createElement("markdown-viewer");e.setAttribute("sanitize","");let n=document.createElement("pre");n.textContent=t,e.appendChild(n),this.#n.replaceChildren(e)}#C(t){if(!this.#n)return;let e=document.createElement("p");if(e.className="ais-error",e.textContent=`Summarization failed: ${t?.message||t}`,this.#n.replaceChildren(e),this.getAttribute("fallback-url")){let s=document.createElement("p");s.className="ais-fallback";let r=document.createElement("a");r.href=this.#h(),r.target="_blank",r.rel="noopener noreferrer",r.textContent=this.getAttribute("fallback-label")||"Continue elsewhere",r.append(k()),s.append("You can ",r," instead."),this.#n.appendChild(s)}}#i(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-summary:state",{detail:{state:t,provider:this.#r},bubbles:!0}))}#x(t){let e=this.#t?.querySelector(".ais-label");e&&(e.textContent=t)}#A(t){let e=this.#t?.querySelector(".ais-newtab");t&&!e?this.#t?.append(k()):t||e?.remove()}#f(t){this.#a&&(this.#a.textContent=t,this.#a.hidden=!1)}#k(){this.#a&&(this.#a.hidden=!0,this.#a.textContent="")}};function k(){let i=document.createElement("span");return i.className="visually-hidden ais-newtab",i.textContent=" (opens in new tab)",i}b("ai-summary",u);export{u as AISummary};
11
+ `,this.prepend(e),this.#l(e)}#l(t){this.#t=t.querySelector(".ais-trigger"),this.#i=t.querySelector(".ais-status"),this.#e=t.querySelector(".ais-output"),this.#o=t.querySelector(".ais-stop"),this.#a=t.querySelector(".ais-notice"),this.listen(this.#t,"click",()=>this.#y()),this.#o&&this.listen(this.#o,"click",()=>this.#s?.abort()),this.listen(this,"keydown",e=>{e.key==="Escape"&&this.#s&&(e.preventDefault(),this.#s.abort())})}async#m(){this.#n("checking");let{state:t}=await y("Summarizer");this.#r=g({availability:t,endpoint:this.getAttribute("endpoint")||void 0,fallbackURL:this.getAttribute("fallback-url")||void 0}),this.#b(t)}#b(t){if(!(!this.#t||!this.#i)){if(this.#C(this.#r==="deep-link"),this.#r==="local"){this.#i.dataset.state=t,this.#i.textContent={available:"Ready (on-device)",downloadable:"Model available \u2014 first run will download",downloading:"Model downloading\u2026"}[t]??t,this.#t.disabled=!1,this.#t.dataset.provider="local",this.#n("ready");return}if(this.#r==="endpoint"){this.#i.dataset.state="available",this.#i.textContent="Ready (remote)",this.#t.disabled=!1,this.#t.dataset.provider="endpoint",this.#n("ready");return}if(this.#r==="deep-link"){this.#i.dataset.state="unavailable",this.#i.textContent="On-device AI unavailable \u2014 using deep-link",this.#t.disabled=!1,this.#t.dataset.provider="deep-link";let e=this.getAttribute("fallback-label")||"Read elsewhere";this.#k(e),this.#n("deep-link");return}this.#i.dataset.state="unavailable",this.#i.textContent="Summarization not available on this device",this.#t.disabled=!0,this.#t.dataset.provider="unavailable",this.#n("unavailable")}}async#y(){if(!this.#t||!this.#e)return;if(this.#r==="deep-link"){window.open(this.#h(),"_blank","noopener,noreferrer");return}if(this.#r==="unavailable")return;this.#e.hidden=!1,this.#e.textContent="",this.#x(),this.#e.setAttribute("aria-busy","true"),this.#n("streaming");let t=new AbortController;this.#s=t,this.#c(!0);let e="";try{let i=this.#u(),s=this.#r==="local"?await this.#g(i,t.signal):A(this.getAttribute("endpoint")||"",{prompt:this.#d(),content:i,mode:"summarize",signal:t.signal});this.getAttribute("data-state")!=="streaming"&&this.#n("streaming");for await(let r of s)e+=r,this.#e.textContent=e;this.#w(e),this.#n("complete"),this.dispatchEvent(new CustomEvent("ai-summary:result",{detail:{text:e,provider:this.#r},bubbles:!0}))}catch(i){if(i&&i.name==="AbortError"){this.#e.textContent=e?`${e} (stopped)`:"(stopped)",this.#n("ready");return}this.#A(i),this.#n("error"),this.dispatchEvent(new CustomEvent("ai-summary:error",{detail:{error:i},bubbles:!0}))}finally{this.#e.removeAttribute("aria-busy"),this.#s===t&&(this.#s=null),this.#c(!1)}}#c(t){if(!this.#t)return;let e=document.activeElement;this.#t.disabled=t,this.#o&&(this.#o.hidden=!t,t&&e===this.#t?this.#o.focus():!t&&e===this.#o&&this.#t.focus())}async#g(t,e){let i=await Summarizer.create({signal:e,type:this.getAttribute("type")||"key-points",format:this.getAttribute("format")||"markdown",length:this.getAttribute("length")||"medium",sharedContext:this.getAttribute("shared-context")||void 0,expectedInputLanguages:["en"],outputLanguage:"en",monitor:o=>{o.addEventListener("downloadprogress",a=>{this.#n("downloading"),this.#i&&(this.#i.textContent=`Downloading model: ${Math.round(a.loaded*100)}%`)})}}),s=t;try{s=await this.#v(i,t,e)}catch(o){throw i.destroy?.(),o}let r=typeof i.summarizeStreaming=="function"?i.summarizeStreaming(s,{signal:e}):(async function*(){yield await i.summarize(s,{signal:e})})();return(async function*(){try{for await(let o of r)yield o}finally{i.destroy?.()}})()}async#v(t,e,i){let s=t?.inputQuota;if(typeof t?.measureInputUsage=="function"&&typeof s=="number"){let r;try{r=await t.measureInputUsage(e,{signal:i})}catch(o){if(o?.name==="AbortError")throw o;r=void 0}if(typeof r=="number"&&r>s){let o=C(e,r,s),a=Math.max(1,Math.round(o.length/e.length*100));return this.#f(`This content is longer than the on-device model accepts; summarizing the first ${a}%.`),o}return e}return e.length>k&&this.#f(`This content is long (${e.length.toLocaleString()} characters) and may exceed the on-device model's limit.`),e}#u(){return v(this,{stripSelectors:".ais-ui"})}#d(){return(this.getAttribute("fallback-prompt")||L).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title)}#h(){let t=this.getAttribute("fallback-url");return E(t,{prompt:this.#d(),content:w(t)?this.#u():""})}#w(t){if(this.#e){if((this.getAttribute("format")||"markdown")==="plain-text"){this.#e.textContent=t;return}this.#E(t)}}#E(t){if(!this.#e)return;if(!t){this.#e.textContent="";return}let e=document.createElement("markdown-viewer");e.setAttribute("sanitize","");let i=document.createElement("pre");i.textContent=t,e.appendChild(i),this.#e.replaceChildren(e)}#A(t){if(!this.#e)return;let e=document.createElement("p");if(e.className="ais-error",e.textContent=`Summarization failed: ${t?.message||t}`,this.#e.replaceChildren(e),this.getAttribute("fallback-url")){let s=document.createElement("p");s.className="ais-fallback";let r=document.createElement("a");r.href=this.#h(),r.target="_blank",r.rel="noopener noreferrer",r.textContent=this.getAttribute("fallback-label")||"Continue elsewhere",r.append(x()),s.append("You can ",r," instead."),this.#e.appendChild(s)}}#n(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-summary:state",{detail:{state:t,provider:this.#r},bubbles:!0}))}#k(t){let e=this.#t?.querySelector(".ais-label");e&&(e.textContent=t)}#C(t){let e=this.#t?.querySelector(".ais-newtab");t&&!e?this.#t?.append(x()):t||e?.remove()}#f(t){this.#a&&(this.#a.textContent=t,this.#a.hidden=!1)}#x(){this.#a&&(this.#a.hidden=!0,this.#a.textContent="")}};function x(){let n=document.createElement("span");return n.className="visually-hidden ais-newtab",n.textContent=" (opens in new tab)",n}b("ai-summary",d);export{d as AISummary};
12
12
  //# sourceMappingURL=ai-summary.js.map
@@ -1,4 +1,4 @@
1
- var Y=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function S(e,t,n={}){let s=n.priority??10,o={impl:t,bundle:n.bundle,contract:n.contract,priority:s},i=x.get(e);if(customElements.get(e)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${e}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${i.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}x.set(e,o),customElements.define(e,t)}var f=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,n,s,o){t.addEventListener(n,s,o),this.#t.push(()=>t.removeEventListener(n,s,o))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,n){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{n?s.add(t):s.delete(t)}catch{let o=`--${t}`;n?s.add(o):s.delete(o)}}_adoptInternals(t){this.#e||(this.#e=t)}};function T(e){let t=!1;try{t=sessionStorage.getItem("vb_optout")==="1"}catch{}let n=!1;if(typeof e?.consent=="function")try{n=e.consent()===!1}catch{n=!0}return{user:t,gpc:navigator.globalPrivacyControl===!0,dnt:navigator.doNotTrack==="1",consent:n}}function $(e){let t=T(e);return t.user?"user":t.gpc?"gpc":t.dnt?"dnt":t.consent?"consent":null}function g(e){return $(e)!==null}function L(e){return e?.closest?.("[data-vb-no-track]")!=null}function M(){let{dataset:e}=document.documentElement,t={};for(let n of Object.keys(e)){let s=e[n];s!=null&&s!==""&&(t[n]=s)}return t}function D(){let e={};for(let n of document.querySelectorAll('meta[name^="vb:"]')){let s=n.getAttribute("name")?.slice(3),o=n.getAttribute("content")?.trim();s&&o&&(e[s]=o)}let t=[];for(let n of document.querySelectorAll('meta[name="concept"]')){let s=n.getAttribute("content")?.trim();s&&t.push(s)}return t.length&&(e.concepts=t),e}function q(e,t){if(!t?.length)return e;for(let{pattern:n,replace:s}of t)if(n.test(e))return e.replace(n,s);return e}function R(e,t){let n=JSON.stringify(t);if(typeof navigator.sendBeacon=="function"){let s=new Blob([n],{type:"application/json"});if(navigator.sendBeacon(e,s))return!0}try{return fetch(e,{method:"POST",body:n,keepalive:!0,headers:{"content-type":"application/json"}}),!0}catch{return!1}}var a={config:null,queue:[]},l={sent:0,logged:0,iframeDisabled:!1},m=Symbol.for("vanilla-breeze.analytics"),v="vb:analytics-status";function h(){try{document.dispatchEvent(new CustomEvent(v))}catch{}}function E(e){return`${(a.config?.endpoint??"/api/analytics").replace(/\/+$/,"")}/${e}`}function p(e,t){let n=a.config;if(!n)throw new Error("analytics: buildEnvelope called before init");let s=q(location.pathname+location.search,n.urlMasks),o=typeof n.context=="function"?n.context()??{}:{};return{name:e,ts:Date.now(),site:n.siteId,path:s,referrer:document.referrer||"",context:{...M(),...D(),...o},props:t??{}}}function b(e,t){let n=a.config;if(!n||n.transport==="disabled")return!1;if(n.transport==="console")return console.log("%c[vb:analytics]","color:#0aa;font-weight:600",e,t),l.logged++,h(),!0;let s=R(E(e),t);return s&&(l.sent++,h()),s}function I(){let e=a.config?.sampleRate??1;return e>=1?!0:Math.random()<e}var _=null;function O(){if(!a.config||g(a.config)||document.documentElement.hasAttribute("data-vb-no-track")||!I())return;let e=location.pathname+location.search;e!==_&&(_=e,b("hit",p("page.view",{})))}function P(){let e,t=()=>{clearTimeout(e),e=setTimeout(O,100)},n=history.pushState.bind(history);history.pushState=function(...o){n(...o),t()};let s=history.replaceState.bind(history);history.replaceState=function(...o){s(...o),t()},window.addEventListener("popstate",t)}function B(e){let t={};for(let[n,s]of Object.entries(e.dataset)){if(n==="vbEvent"||!n.startsWith("vbEvent"))continue;let o=n.slice(7).replace(/^./,i=>i.toLowerCase());t[o]=s}return t}function j(e){if(!a.config||g(a.config))return;let n=e.target?.closest?.("[data-vb-event]");if(!n||L(n))return;let s=n.dataset.vbEvent;s&&w.track(s,B(n))}function C(){let e=document.querySelectorAll('a[href^="http"]');for(let t of e){if(t.hostname===location.hostname||L(t)||t.hasAttribute("data-vb-analytics-wired"))continue;let n=encodeURIComponent(a.config?.siteId??"default"),s=`${E("click")}?site=${n}&from=${encodeURIComponent(location.pathname)}`;t.hasAttribute("ping")||t.setAttribute("ping",s),t.addEventListener("click",()=>{if(g(a.config))return;let o=navigator.userAgent;/Firefox|Brave/.test(o)&&b("click",p("link.outbound",{to:t.hostname,href:t.href}))}),t.setAttribute("data-vb-analytics-wired","")}}function y(){if(!a.queue.length)return;let e=a.queue.splice(0);b("events",{site:a.config?.siteId,events:e})}function F(){document.visibilityState==="hidden"&&y()}var V={endpoint:"/api/analytics",siteId:"default",transport:"disabled",sampleRate:1,consent:null,context:null,urlMasks:null,autoPageView:!0,autoOutboundLinks:!0,autoDeclarative:!0,allowInIframe:!1};function U(){try{return window.top!==window.self}catch{return!0}}var w={init(e={}){if(a.config)return;let t={...V,...e};if(a.config=t,globalThis[m]||(globalThis[m]=w),queueMicrotask(h),U()&&!t.allowInIframe){l.iframeDisabled=!0,t.transport="disabled",t.autoPageView=!1,t.autoOutboundLinks=!1,t.autoDeclarative=!1;return}t.transport==="disabled"&&(t.autoOutboundLinks=!1),t.autoDeclarative&&document.addEventListener("click",j,{capture:!0}),t.autoOutboundLinks&&(C(),new MutationObserver(()=>C()).observe(document.body,{childList:!0,subtree:!0})),t.autoPageView&&(O(),P()),document.addEventListener("visibilitychange",F),window.addEventListener("pagehide",y)},track(e,t={}){a.config&&(g(a.config)||I()&&b("hit",p(e,t)))},flush:y,setConsent(e){try{e?sessionStorage.removeItem("vb_optout"):sessionStorage.setItem("vb_optout","1")}catch{}h()},getStatus(){let e=a.config,t=T(e),n=$(e),s=null;if(e)try{s=p("page.view",{})}catch{s=null}let o=e?.transport??null;return{initialized:e!=null,active:e!=null&&o!=="disabled"&&n===null,optedOut:n!==null,reason:n,signals:t,transport:o,inIframe:l.iframeDisabled,endpoint:e?E("hit"):null,siteId:e?.siteId??null,sampleRate:e?.sampleRate??null,outboundLinks:e?.autoOutboundLinks??!1,queued:a.queue.length,sent:l.sent,logged:l.logged,collects:s?Object.keys(s):[],contextKeys:s?Object.keys(s.context):[],preview:s}},get config(){return a.config?{...a.config}:null}};function k(){return globalThis[m]??w}var H="Analytics on this page",z=2;function G(e){let t=Number.parseInt(e??"",10);return Number.isInteger(t)&&t>=1&&t<=6?t:z}var N={gpc:"your browser sends a Global Privacy Control signal",dnt:"your browser sends Do Not Track",consent:"this site has not been given consent to collect analytics"};function K(e){if(!e||!e.initialized)return{state:"off",reason:"uninitialized",text:"Off. The analytics runtime is not running on this page, so nothing is sent."};if(e.inIframe)return{state:"off",reason:"iframe",text:"Off. Analytics does not run inside embedded frames, so nothing is sent."};if(e.reason==="user")return{state:"paused",reason:"user",text:"Paused for this tab. Nothing is being sent."};if(e.reason){let n=N[e.reason];return{state:"off",reason:e.reason,text:`Off because ${n}. Nothing is sent.`}}if(e.transport==="disabled")return{state:"off",reason:"disabled",text:"Off. This site has analytics switched off, so nothing is sent."};if(e.transport==="console")return{state:"debug",reason:null,text:"Debug mode. Events are written to this browser\u2019s console, not sent anywhere."};let t=typeof e.sampleRate=="number"&&e.sampleRate<1?` (a ${Math.round(e.sampleRate*100)}% sample)`:"";return{state:"active",reason:null,text:`Active. Events from this page are sent to ${e.endpoint}${t}.`}}function W(e){return e?.signals?["gpc","dnt","consent"].filter(t=>e.signals[t]):[]}var A=class extends f{static get observedAttributes(){return["heading","heading-level"]}#t={};setup(){(!this.#t.status||!this.contains(this.#t.status))&&this.#i(),this.listen(this,"click",this.#s),this.listen(document,v,()=>this.refresh()),this.refresh()}attributeChangedCallback(t){this.#t.heading&&(t==="heading"&&(this.#t.heading.textContent=this.#e),t==="heading-level"&&this.#n())}get#e(){return this.getAttribute("heading")||H}get status(){let t=k();return typeof t?.getStatus=="function"?t.getStatus():null}#s=t=>{let n=t.target?.closest?.("[data-analytics-action]");if(!n||!this.contains(n)||n.getAttribute("aria-disabled")==="true")return;let s=n.dataset.analyticsAction;s==="toggle"&&this.#o(),s==="refresh"&&this.refresh()};#o(){let t=!this.status?.signals?.user;k().setConsent(!t),this.dispatchEvent(new CustomEvent(t?"analytics-panel:optout":"analytics-panel:optin",{bubbles:!0,composed:!0})),this.refresh()}#i(){let t=`analytics-panel-${Math.random().toString(36).slice(2,8)}`;this.innerHTML=`
1
+ var J=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function S(e,t,n={}){let s=n.priority??10,i={impl:t,bundle:n.bundle,contract:n.contract,priority:s},o=x.get(e);if(customElements.get(e)){if(!o||o.priority>=s){o&&o.priority===s&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${e}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=s){o.priority===s&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${o.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}x.set(e,i),customElements.define(e,t)}var h=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,n,s,i){t.addEventListener(n,s,i),this.#t.push(()=>t.removeEventListener(n,s,i))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,n){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{n?s.add(t):s.delete(t)}catch{let i=`--${t}`;n?s.add(i):s.delete(i)}}_adoptInternals(t){this.#e||(this.#e=t)}#n(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};function T(e){let t=!1;try{t=sessionStorage.getItem("vb_optout")==="1"}catch{}let n=!1;if(typeof e?.consent=="function")try{n=e.consent()===!1}catch{n=!0}return{user:t,gpc:navigator.globalPrivacyControl===!0,dnt:navigator.doNotTrack==="1",consent:n}}function L(e){let t=T(e);return t.user?"user":t.gpc?"gpc":t.dnt?"dnt":t.consent?"consent":null}function u(e){return L(e)!==null}function $(e){return e?.closest?.("[data-vb-no-track]")!=null}function M(){let{dataset:e}=document.documentElement,t={};for(let n of Object.keys(e)){let s=e[n];s!=null&&s!==""&&(t[n]=s)}return t}var D=new Set(["track-history","track-history-params","no-track-history"]);function q(){let e={};for(let n of document.querySelectorAll('meta[name^="vb:"]')){let s=n.getAttribute("name")?.slice(3),i=n.getAttribute("content")?.trim();s&&D.has(s)||s&&i&&(e[s]=i)}let t=[];for(let n of document.querySelectorAll('meta[name="concept"]')){let s=n.getAttribute("content")?.trim();s&&t.push(s)}return t.length&&(e.concepts=t),e}function P(e,t){if(!t?.length)return e;for(let{pattern:n,replace:s}of t)if(n.test(e))return e.replace(n,s);return e}function R(e,t){let n=JSON.stringify(t);if(typeof navigator.sendBeacon=="function"){let s=new Blob([n],{type:"application/json"});if(navigator.sendBeacon(e,s))return!0}try{return fetch(e,{method:"POST",body:n,keepalive:!0,headers:{"content-type":"application/json"}}),!0}catch{return!1}}var a={config:null,queue:[]},l={sent:0,logged:0,iframeDisabled:!1},m=Symbol.for("vanilla-breeze.analytics"),v="vb:analytics-status";function p(){try{document.dispatchEvent(new CustomEvent(v))}catch{}}function E(e){return`${(a.config?.endpoint??"/api/analytics").replace(/\/+$/,"")}/${e}`}function g(e,t){let n=a.config;if(!n)throw new Error("analytics: buildEnvelope called before init");let s=P(location.pathname+location.search,n.urlMasks),i=typeof n.context=="function"?n.context()??{}:{};return{name:e,ts:Date.now(),site:n.siteId,path:s,referrer:document.referrer||"",context:{...M(),...q(),...i},props:t??{}}}function b(e,t){let n=a.config;if(!n||n.transport==="disabled")return!1;if(n.transport==="console")return console.log("%c[vb:analytics]","color:#0aa;font-weight:600",e,t),l.logged++,p(),!0;let s=R(E(e),t);return s&&(l.sent++,p()),s}function I(){let e=a.config?.sampleRate??1;return e>=1?!0:Math.random()<e}var _=null;function O(){if(!a.config||u(a.config)||document.documentElement.hasAttribute("data-vb-no-track")||!I())return;let e=location.pathname+location.search;e!==_&&(_=e,b("hit",g("page.view",{})))}function B(){let e,t=()=>{clearTimeout(e),e=setTimeout(O,100)},n=history.pushState.bind(history);history.pushState=function(...i){n(...i),t()};let s=history.replaceState.bind(history);history.replaceState=function(...i){s(...i),t()},window.addEventListener("popstate",t)}function V(e){let t={};for(let[n,s]of Object.entries(e.dataset)){if(n==="vbEvent"||!n.startsWith("vbEvent"))continue;let i=n.slice(7).replace(/^./,o=>o.toLowerCase());t[i]=s}return t}function j(e){if(!a.config||u(a.config))return;let n=e.target?.closest?.("[data-vb-event]");if(!n||$(n))return;let s=n.dataset.vbEvent;s&&w.track(s,V(n))}function C(){let e=document.querySelectorAll('a[href^="http"]');for(let t of e){if(t.hostname===location.hostname||$(t)||t.hasAttribute("data-vb-analytics-wired"))continue;let n=encodeURIComponent(a.config?.siteId??"default"),s=`${E("click")}?site=${n}&from=${encodeURIComponent(location.pathname)}`,i=!t.hasAttribute("ping"),o=()=>{i&&(u(a.config)?t.removeAttribute("ping"):t.setAttribute("ping",s))};t.addEventListener("click",o,{capture:!0}),t.addEventListener("auxclick",o,{capture:!0}),t.addEventListener("click",()=>{if(u(a.config))return;let r=navigator.userAgent;/Firefox|Brave/.test(r)&&b("click",g("link.outbound",{to:t.hostname,href:t.href}))}),t.setAttribute("data-vb-analytics-wired","")}}function y(){if(!a.queue.length)return;let e=a.queue.splice(0);b("events",{site:a.config?.siteId,events:e})}function F(){document.visibilityState==="hidden"&&y()}var U={endpoint:"/api/analytics",siteId:"default",transport:"disabled",sampleRate:1,consent:null,context:null,urlMasks:null,autoPageView:!0,autoOutboundLinks:!0,autoDeclarative:!0,allowInIframe:!1};function H(){try{return window.top!==window.self}catch{return!0}}var w={init(e={}){if(a.config)return;let t={...U,...e};if(a.config=t,globalThis[m]||(globalThis[m]=w),queueMicrotask(p),H()&&!t.allowInIframe){l.iframeDisabled=!0,t.transport="disabled",t.autoPageView=!1,t.autoOutboundLinks=!1,t.autoDeclarative=!1;return}t.transport==="disabled"&&(t.autoOutboundLinks=!1),t.autoDeclarative&&document.addEventListener("click",j,{capture:!0}),t.autoOutboundLinks&&(C(),new MutationObserver(()=>C()).observe(document.body,{childList:!0,subtree:!0})),t.autoPageView&&(O(),B()),document.addEventListener("visibilitychange",F),window.addEventListener("pagehide",y)},track(e,t={}){a.config&&(u(a.config)||I()&&b("hit",g(e,t)))},flush:y,setConsent(e){try{e?sessionStorage.removeItem("vb_optout"):sessionStorage.setItem("vb_optout","1")}catch{}p()},getStatus(){let e=a.config,t=T(e),n=L(e),s=null;if(e)try{s=g("page.view",{})}catch{s=null}let i=e?.transport??null;return{initialized:e!=null,active:e!=null&&i!=="disabled"&&n===null,optedOut:n!==null,reason:n,signals:t,transport:i,inIframe:l.iframeDisabled,endpoint:e?E("hit"):null,siteId:e?.siteId??null,sampleRate:e?.sampleRate??null,outboundLinks:e?.autoOutboundLinks??!1,queued:a.queue.length,sent:l.sent,logged:l.logged,collects:s?Object.keys(s):[],contextKeys:s?Object.keys(s.context):[],preview:s}},get config(){return a.config?{...a.config}:null}};function k(){return globalThis[m]??w}var z="Analytics on this page",G=2;function K(e){let t=Number.parseInt(e??"",10);return Number.isInteger(t)&&t>=1&&t<=6?t:G}var N={gpc:"your browser sends a Global Privacy Control signal",dnt:"your browser sends Do Not Track",consent:"this site has not been given consent to collect analytics"};function W(e){if(!e||!e.initialized)return{state:"off",reason:"uninitialized",text:"Off. The analytics runtime is not running on this page, so nothing is sent."};if(e.inIframe)return{state:"off",reason:"iframe",text:"Off. Analytics does not run inside embedded frames, so nothing is sent."};if(e.reason==="user")return{state:"paused",reason:"user",text:"Paused for this tab. Nothing is being sent."};if(e.reason){let n=N[e.reason];return{state:"off",reason:e.reason,text:`Off because ${n}. Nothing is sent.`}}if(e.transport==="disabled")return{state:"off",reason:"disabled",text:"Off. This site has analytics switched off, so nothing is sent."};if(e.transport==="console")return{state:"debug",reason:null,text:"Debug mode. Events are written to this browser\u2019s console, not sent anywhere."};let t=typeof e.sampleRate=="number"&&e.sampleRate<1?` (a ${Math.round(e.sampleRate*100)}% sample)`:"";return{state:"active",reason:null,text:`Active. Events from this page are sent to ${e.endpoint}${t}.`}}function Y(e){return e?.signals?["gpc","dnt","consent"].filter(t=>e.signals[t]):[]}var A=class extends h{static get observedAttributes(){return["heading","heading-level"]}#t={};setup(){(!this.#t.status||!this.contains(this.#t.status))&&this.#o(),this.listen(this,"click",this.#n),this.listen(document,v,()=>this.refresh()),this.refresh()}attributeChangedCallback(t){this.#t.heading&&(t==="heading"&&(this.#t.heading.textContent=this.#e),t==="heading-level"&&this.#s())}get#e(){return this.getAttribute("heading")||z}get status(){let t=k();return typeof t?.getStatus=="function"?t.getStatus():null}#n=t=>{let n=t.target?.closest?.("[data-analytics-action]");if(!n||!this.contains(n)||n.getAttribute("aria-disabled")==="true")return;let s=n.dataset.analyticsAction;s==="toggle"&&this.#i(),s==="refresh"&&this.refresh()};#i(){let t=!this.status?.signals?.user;k().setConsent(!t),this.dispatchEvent(new CustomEvent(t?"analytics-panel:optout":"analytics-panel:optin",{bubbles:!0,composed:!0})),this.refresh()}#o(){let t=`analytics-panel-${Math.random().toString(36).slice(2,8)}`;this.innerHTML=`
2
2
  <header class="analytics-panel__header">
3
3
  <h2 data-part="heading"></h2>
4
4
  <p class="analytics-panel__status" role="status">
@@ -28,5 +28,5 @@ var Y=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;functi
28
28
  server records your country from the request; your IP address is not
29
29
  stored.
30
30
  </p>
31
- `;for(let n of this.querySelectorAll("[data-part]"))this.#t[n.dataset.part??""]=n;this.#t.heading.textContent=this.#e,this.#n()}#n(){let t=G(this.getAttribute("heading-level")),n={heading:t,"fields-heading":Math.min(t+1,6)};for(let[s,o]of Object.entries(n)){let i=this.#t[s];if(!i||i.localName===`h${o}`)continue;let r=document.createElement(`h${o}`);for(let{name:u,value:c}of i.attributes)r.setAttribute(u,c);r.textContent=i.textContent,i.replaceWith(r),this.#t[s]=r}}refresh(){if(!this.#t.status)return;let t=this.status,n=K(t),s=this.#t;this.setAttribute("data-state",n.state),n.reason?this.setAttribute("data-reason",n.reason):this.removeAttribute("data-reason"),s.status.textContent!==n.text&&(s.status.textContent=n.text),this.#a(t);let o=!!t?.signals?.user,i=W(t),r=o?"Resume analytics":"Pause analytics";if(s.toggle.textContent!==r&&(s.toggle.textContent=r),s.toggle.setAttribute("aria-pressed",String(o)),o&&i.length>0?s.toggle.setAttribute("aria-disabled","true"):s.toggle.removeAttribute("aria-disabled"),i.length){let c=i.map(d=>N[d]).join(" and ");s.hint.textContent=o?`Resume is unavailable because ${c}.`:`Analytics stays off because ${c}; pausing as well changes nothing.`,s.hint.hidden=!1,s.toggle.setAttribute("aria-describedby",s.hint.id)}else s.hint.textContent="",s.hint.hidden=!0,s.toggle.removeAttribute("aria-describedby")}#a(t){let{data:n,empty:s}=this.#t;if(!t?.initialized||!t.preview){n.hidden=!0,n.replaceChildren(),s.hidden=!1,s.textContent="Nothing to show: the analytics runtime has not started on this page.";return}s.hidden=!0,n.hidden=!1;let o=[["Fields",t.collects.join(", ")],["Page path",t.preview.path],["Referrer",t.preview.referrer||"(none)"],["Page context",t.contextKeys.length?t.contextKeys.join(", "):"(none)"]];t.transport==="beacon"?(o.push(["Sent to",t.endpoint]),o.push(["Sent from this page",String(t.sent)])):t.transport==="console"&&o.push(["Logged on this page",String(t.logged)]),t.queued>0&&o.push(["Waiting to send",String(t.queued)]),t.outboundLinks&&o.push(["Outbound link clicks","Reported (site, page path, destination)"]);let i=document.createDocumentFragment();for(let[r,u]of o){let c=document.createElement("dt");c.textContent=r;let d=document.createElement("dd");d.textContent=u,i.append(c,d)}n.replaceChildren(i)}};S("analytics-panel",A);export{K as describeStatus,G as headingLevel};
31
+ `;for(let n of this.querySelectorAll("[data-part]"))this.#t[n.dataset.part??""]=n;this.#t.heading.textContent=this.#e,this.#s()}#s(){let t=K(this.getAttribute("heading-level")),n={heading:t,"fields-heading":Math.min(t+1,6)};for(let[s,i]of Object.entries(n)){let o=this.#t[s];if(!o||o.localName===`h${i}`)continue;let r=document.createElement(`h${i}`);for(let{name:d,value:c}of o.attributes)r.setAttribute(d,c);r.textContent=o.textContent,o.replaceWith(r),this.#t[s]=r}}refresh(){if(!this.#t.status)return;let t=this.status,n=W(t),s=this.#t;this.setAttribute("data-state",n.state),n.reason?this.setAttribute("data-reason",n.reason):this.removeAttribute("data-reason"),s.status.textContent!==n.text&&(s.status.textContent=n.text),this.#a(t);let i=!!t?.signals?.user,o=Y(t),r=i?"Resume analytics":"Pause analytics";if(s.toggle.textContent!==r&&(s.toggle.textContent=r),s.toggle.setAttribute("aria-pressed",String(i)),i&&o.length>0?s.toggle.setAttribute("aria-disabled","true"):s.toggle.removeAttribute("aria-disabled"),o.length){let c=o.map(f=>N[f]).join(" and ");s.hint.textContent=i?`Resume is unavailable because ${c}.`:`Analytics stays off because ${c}; pausing as well changes nothing.`,s.hint.hidden=!1,s.toggle.setAttribute("aria-describedby",s.hint.id)}else s.hint.textContent="",s.hint.hidden=!0,s.toggle.removeAttribute("aria-describedby")}#a(t){let{data:n,empty:s}=this.#t;if(!t?.initialized||!t.preview){n.hidden=!0,n.replaceChildren(),s.hidden=!1,s.textContent="Nothing to show: the analytics runtime has not started on this page.";return}s.hidden=!0,n.hidden=!1;let i=[["Fields",t.collects.join(", ")],["Page path",t.preview.path],["Referrer",t.preview.referrer||"(none)"],["Page context",t.contextKeys.length?t.contextKeys.join(", "):"(none)"]];t.transport==="beacon"?(i.push(["Sent to",t.endpoint]),i.push(["Sent from this page",String(t.sent)])):t.transport==="console"&&i.push(["Logged on this page",String(t.logged)]),t.queued>0&&i.push(["Waiting to send",String(t.queued)]),t.outboundLinks&&i.push(["Outbound link clicks","Reported (site, page path, destination)"]);let o=document.createDocumentFragment();for(let[r,d]of i){let c=document.createElement("dt");c.textContent=r;let f=document.createElement("dd");f.textContent=d,o.append(c,f)}n.replaceChildren(o)}};S("analytics-panel",A);export{W as describeStatus,K as headingLevel};
32
32
  //# sourceMappingURL=analytics-panel.js.map
@@ -1,5 +1,5 @@
1
- var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(i,t,e={}){let r=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:r},a=c.get(i);if(customElements.get(i)){if(!a||a.priority>=r){a&&a.priority===r&&a.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${a.bundle}" (priority ${a.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${a.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(a&&a.priority>=r){a.priority===r&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${a.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}c.set(i,s),customElements.define(i,t)}var o=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,s){t.addEventListener(e,r,s),this.#t.push(()=>t.removeEventListener(e,r,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let s=`--${t}`;e?r.add(s):r.delete(s)}}_adoptInternals(t){this.#e||(this.#e=t)}};function l(i){return[...i.querySelectorAll("li")].filter(t=>t.querySelector("a[href]"))}function h(i){return i.querySelector("li[data-audio-active]")}function p(i,t,e){let r=e.querySelector("a[href]");return r?(t.querySelectorAll("li[data-audio-active]").forEach(s=>{s!==e&&s.removeAttribute("data-audio-active")}),e.setAttribute("data-audio-active",""),i.src=r.href,i.play()?.catch(()=>{}),{src:r.href,title:r.textContent?.trim()??""}):null}function f(i){let t=h(i);return t?.setAttribute("data-audio-played",""),t}function m(i,{loop:t=!1}={}){let e=l(i);if(!e.length)return null;let r=h(i),s=r?e.indexOf(r):-1;return s+1<e.length?e[s+1]:t?e[0]:null}var v='input, button, a[href], summary, select, textarea, audio, [contenteditable]:not([contenteditable="false"])',u=class extends o{static get observedAttributes(){return["loop","shuffle"]}#t=null;#e=null;#s=!1;#T=null;#a=null;#r=null;#m=null;#n=null;#x=null;#w=null;#i=null;#c=null;#o=null;#d=!1;#l=new Set;#k=null;#v=!1;setup(){if(this.#t=this.querySelector("audio"),!this.#t)return!1;this.#e=this.querySelector(".track-list"),this.#t.removeAttribute("controls");let t=!this.shadowRoot;this.#_(),t&&(this.#M(),this.#q(),this.#$()),this.#g(),this.#E(),this.#u();let e=this.#t;return(e.error||e.networkState===HTMLMediaElement.NETWORK_NO_SOURCE&&(e.hasAttribute("src")||e.querySelector("source")))&&this.#A(),e.readyState>=HTMLMediaElement.HAVE_METADATA&&(this.#y(),this.#h()),this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{}),this.#k=()=>{let r=this.shadowRoot?.querySelector(".player");r&&(r.style.display="none",r.offsetHeight,r.style.display="")},this.listen(window,"vb:theme-change",this.#k),!0}teardown(){this.#t&&this.#t.setAttribute("controls","")}attributeChangedCallback(t){t==="loop"?this.#E():t==="shuffle"&&this.#l.clear()}#E(){this.#t&&(this.hasAttribute("loop")&&!this.#e?(this.#t.loop=!0,this.#v=!0):this.#v&&(this.#t.loop=!1,this.#v=!1))}get src(){return this.#t?.getAttribute("src")||this.#t?.currentSrc||""}set src(t){if(!this.#t)return;let e=t==null?"":String(t);this.#t.getAttribute("src")!==e&&(this.#t.setAttribute("src",e),this.#t.load?.(),this.#N(),this.#g(),this.dispatchEvent(new CustomEvent("audio-player:src-changed",{detail:{src:e,source:"property"},bubbles:!0})))}get currentTime(){return this.#t?.currentTime??0}set currentTime(t){this.#t&&(this.#t.currentTime=Number(t)||0)}#_(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
2
- <style>${this.#L()}</style>
1
+ var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(i,t,e={}){let r=e.priority??10,a={impl:t,bundle:e.bundle,contract:e.contract,priority:r},s=c.get(i);if(customElements.get(i)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}c.set(i,a),customElements.define(i,t)}var o=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,a){t.addEventListener(e,r,a),this.#t.push(()=>t.removeEventListener(e,r,a))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let a=`--${t}`;e?r.add(a):r.delete(a)}}_adoptInternals(t){this.#e||(this.#e=t)}#r(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};function l(i){return[...i.querySelectorAll("li")].filter(t=>t.querySelector("a[href]"))}function h(i){return i.querySelector("li[data-audio-active]")}function p(i,t,e){let r=e.querySelector("a[href]");return r?(t.querySelectorAll("li[data-audio-active]").forEach(a=>{a!==e&&a.removeAttribute("data-audio-active")}),e.setAttribute("data-audio-active",""),i.src=r.href,i.play()?.catch(()=>{}),{src:r.href,title:r.textContent?.trim()??""}):null}function f(i){let t=h(i);return t?.setAttribute("data-audio-played",""),t}function m(i,{loop:t=!1}={}){let e=l(i);if(!e.length)return null;let r=h(i),a=r?e.indexOf(r):-1;return a+1<e.length?e[a+1]:t?e[0]:null}var v='input, button, a[href], summary, select, textarea, audio, [contenteditable]:not([contenteditable="false"])',u=class extends o{static get observedAttributes(){return["loop","shuffle"]}#t=null;#e=null;#r=!1;#T=null;#s=null;#i=null;#m=null;#n=null;#x=null;#w=null;#a=null;#c=null;#o=null;#d=!1;#l=new Set;#k=null;#v=!1;setup(){if(this.#t=this.querySelector("audio"),!this.#t)return!1;this.#e=this.querySelector(".track-list"),this.#t.removeAttribute("controls");let t=!this.shadowRoot;this.#_(),t&&(this.#L(),this.#q(),this.#$()),this.#g(),this.#A(),this.#u();let e=this.#t;return(e.error||e.networkState===HTMLMediaElement.NETWORK_NO_SOURCE&&(e.hasAttribute("src")||e.querySelector("source")))&&this.#E(),e.readyState>=HTMLMediaElement.HAVE_METADATA&&(this.#y(),this.#h()),this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{}),this.#k=()=>{let r=this.shadowRoot?.querySelector(".player");r&&(r.style.display="none",r.offsetHeight,r.style.display="")},this.listen(window,"vb:theme-change",this.#k),!0}teardown(){this.#t&&this.#t.setAttribute("controls","")}attributeChangedCallback(t){t==="loop"?this.#A():t==="shuffle"&&this.#l.clear()}#A(){this.#t&&(this.hasAttribute("loop")&&!this.#e?(this.#t.loop=!0,this.#v=!0):this.#v&&(this.#t.loop=!1,this.#v=!1))}get src(){return this.#t?.getAttribute("src")||this.#t?.currentSrc||""}set src(t){if(!this.#t)return;let e=t==null?"":String(t);this.#t.getAttribute("src")!==e&&(this.#t.setAttribute("src",e),this.#t.load?.(),this.#N(),this.#g(),this.dispatchEvent(new CustomEvent("audio-player:src-changed",{detail:{src:e,source:"property"},bubbles:!0})))}get currentTime(){return this.#t?.currentTime??0}set currentTime(t){this.#t&&(this.#t.currentTime=Number(t)||0)}#_(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
2
+ <style>${this.#M()}</style>
3
3
  <div part="player" class="player">
4
4
  <div part="controls" class="controls">
5
5
  <button part="play-button" class="play-btn" type="button" aria-label="Play">
@@ -43,7 +43,7 @@ var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;functi
43
43
  <p part="error" class="error" role="status" hidden></p>
44
44
  <slot></slot>
45
45
  </div>
46
- `,this.#T=t.querySelector(".controls"),this.#a=t.querySelector(".play-btn"),this.#r=t.querySelector(".timeline"),this.#m=t.querySelector(".timeline-fill"),this.#n=t.querySelector(".volume"),this.#x=t.querySelector(".current-time"),this.#w=t.querySelector(".duration"),this.#i=t.querySelector(".track-title"),this.#c=t.querySelector(".mute-btn"),this.#o=t.querySelector(".error")}#L(){return`
46
+ `,this.#T=t.querySelector(".controls"),this.#s=t.querySelector(".play-btn"),this.#i=t.querySelector(".timeline"),this.#m=t.querySelector(".timeline-fill"),this.#n=t.querySelector(".volume"),this.#x=t.querySelector(".current-time"),this.#w=t.querySelector(".duration"),this.#a=t.querySelector(".track-title"),this.#c=t.querySelector(".mute-btn"),this.#o=t.querySelector(".error")}#M(){return`
47
47
  :host {
48
48
  display: block;
49
49
  --_accent: var(--audio-player-accent, var(--color-primary, oklch(55% 0.2 260)));
@@ -346,5 +346,5 @@ var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;functi
346
346
  transform: none;
347
347
  }
348
348
  }
349
- `}#M(){this.#t.addEventListener("timeupdate",()=>this.#h()),this.#t.addEventListener("loadedmetadata",()=>{this.#C(),this.#y(),this.#h()}),this.#t.addEventListener("emptied",()=>{this.#y(),this.#h()}),this.#t.addEventListener("volumechange",()=>this.#u()),this.#t.addEventListener("error",t=>{let e=t.target;if(e!==this.#t){if(e.localName!=="source"||this.#t.hasAttribute("src"))return;let r=e.nextElementSibling;for(;r&&r.localName!=="source";)r=r.nextElementSibling;if(r)return}this.#A()},!0),this.#t.addEventListener("play",()=>{this.#s=!0,this.setAttribute("state","playing"),this.#a.setAttribute("aria-label","Pause"),this.#f("audio-player:play",{currentTime:this.#t.currentTime,src:this.#t.currentSrc})}),this.#t.addEventListener("pause",()=>{this.#s=!1,this.setAttribute("state","paused"),this.#a.setAttribute("aria-label","Play"),this.#f("audio-player:pause",{currentTime:this.#t.currentTime})}),this.#t.addEventListener("ended",()=>{this.#s=!1,this.setAttribute("state","ended"),this.#a.setAttribute("aria-label","Play"),this.#e&&(f(this.#e),this.#B()),this.#f("audio-player:ended",{src:this.#t.currentSrc})})}#A(){this.setAttribute("data-state","error"),this.#o.textContent=`Audio could not be loaded${this.#i.textContent?`: ${this.#i.textContent}`:""}.`,this.#o.hidden=!1}#C(){this.getAttribute("data-state")==="error"&&this.removeAttribute("data-state"),this.#o.hidden=!0,this.#o.textContent=""}#u(){if(!this.#t||!this.#c)return;let t=this.#t.muted;t?this.setAttribute("muted",""):this.removeAttribute("muted"),this.#c.setAttribute("aria-pressed",String(t)),this.#n.style.setProperty("--_vol",t?"0":this.#n.value)}#q(){this.#a.addEventListener("click",()=>{this.#s?this.#t.pause():this.#t.play().catch(()=>{})}),this.#r.addEventListener("input",()=>{let e=Number(this.#r.value);this.#m.style.width=`${e}%`,this.#t.duration&&(this.#t.currentTime=e/100*this.#t.duration,this.#S(this.#t.currentTime,this.#t.duration))}),this.#r.addEventListener("pointerdown",()=>{this.#d=!0,this.setState("scrub-active",!0)});let t=()=>{this.#d&&(this.#d=!1,this.setState("scrub-active",!1))};this.#r.addEventListener("pointerup",t),this.#r.addEventListener("pointercancel",t),this.#r.addEventListener("change",t),this.#n.addEventListener("input",()=>{this.#t.volume=Number(this.#n.value),this.#t.muted=!1,this.#u()}),this.#c.addEventListener("click",()=>{this.#t.muted=!this.#t.muted,this.#u()}),this.addEventListener("keydown",e=>{if(!(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey)&&!this.#z(e))switch(e.key){case" ":e.preventDefault(),this.#s?this.#t.pause():this.#t.play().catch(()=>{});break;case"ArrowLeft":e.preventDefault(),this.#t.currentTime=Math.max(0,this.#t.currentTime-10);break;case"ArrowRight":e.preventDefault(),this.#t.currentTime=Math.min(this.#t.duration||0,this.#t.currentTime+10);break;case"m":case"M":this.#t.muted=!this.#t.muted,this.#u();break}}),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Audio player"),this.hasAttribute("aria-keyshortcuts")||this.setAttribute("aria-keyshortcuts","Space ArrowLeft ArrowRight M")}#z(t){for(let e of t.composedPath()){if(e===this)return!1;if(e instanceof Element&&e.matches(v))return!0}return!1}#$(){this.#e&&this.#e.addEventListener("click",t=>{let r=t.target?.closest("a[href]"),s=r?.closest("li");!r||!s||(t.preventDefault(),this.#b(s))})}#b(t){if(!this.#e)return;let e=p(this.#t,this.#e,t);e&&(this.#l.add(t),this.#g(),this.#f("audio-player:track-change",e))}#N(){if(!this.#e)return;let t=this.#t.src,e=l(this.#e).find(r=>r.querySelector("a[href]").href===t);this.#e.querySelectorAll("li[data-audio-active]").forEach(r=>{r!==e&&r.removeAttribute("data-audio-active")}),e?.setAttribute("data-audio-active","")}#B(){if(!this.#e)return;let t=this.hasAttribute("loop");if(!this.hasAttribute("shuffle")){let n=m(this.#e,{loop:t});n&&this.#b(n);return}let e=l(this.#e),r=this.#e.querySelector("li[data-audio-active]");r&&this.#l.add(r);let s=e.filter(n=>!this.#l.has(n));if(!s.length){if(this.#l.clear(),!t)return;s=e.length>1?e.filter(n=>n!==r):e}let a=s[Math.floor(Math.random()*s.length)];a&&this.#b(a)}#h(){let t=this.#t.currentTime,e=this.#t.duration||0,r=e?t/e*100:0;this.#x.textContent=this.#p(t),this.#S(t,e),!this.#d&&(this.#r.value=String(r),this.#m.style.width=`${r}%`)}#S(t,e){this.#r.setAttribute("aria-valuetext",`${this.#p(t)} of ${this.#p(e)}`)}#y(){let t=this.#t.duration||0;this.#w.textContent=this.#p(t)}#g(){if(!this.#i)return;if(this.#e){let r=this.#e.querySelector("li[data-audio-active] a");if(r){this.#i.textContent=r.textContent;return}}let t=this.#t.src||this.#t.currentSrc||this.#t.querySelector("source")?.src||"",e=t?t.split("/").pop().split(/[?#]/)[0]:"";this.#i.textContent=e.replace(/\.[^.]+$/,"").replace(/[-_]/g," ")}#p(t){if(!Number.isFinite(t))return"0:00";let e=Math.floor(t/60),r=Math.floor(t%60).toString().padStart(2,"0");return`${e}:${r}`}#f(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}};d("audio-player",u);export{u as AudioPlayerElement};
349
+ `}#L(){this.#t.addEventListener("timeupdate",()=>this.#h()),this.#t.addEventListener("loadedmetadata",()=>{this.#C(),this.#y(),this.#h()}),this.#t.addEventListener("emptied",()=>{this.#y(),this.#h()}),this.#t.addEventListener("volumechange",()=>this.#u()),this.#t.addEventListener("error",t=>{let e=t.target;if(e!==this.#t){if(e.localName!=="source"||this.#t.hasAttribute("src"))return;let r=e.nextElementSibling;for(;r&&r.localName!=="source";)r=r.nextElementSibling;if(r)return}this.#E()},!0),this.#t.addEventListener("play",()=>{this.#r=!0,this.setAttribute("state","playing"),this.#s.setAttribute("aria-label","Pause"),this.#f("audio-player:play",{currentTime:this.#t.currentTime,src:this.#t.currentSrc})}),this.#t.addEventListener("pause",()=>{this.#r=!1,this.setAttribute("state","paused"),this.#s.setAttribute("aria-label","Play"),this.#f("audio-player:pause",{currentTime:this.#t.currentTime})}),this.#t.addEventListener("ended",()=>{this.#r=!1,this.setAttribute("state","ended"),this.#s.setAttribute("aria-label","Play"),this.#e&&(f(this.#e),this.#V()),this.#f("audio-player:ended",{src:this.#t.currentSrc})})}#E(){this.setAttribute("data-state","error"),this.#o.textContent=`Audio could not be loaded${this.#a.textContent?`: ${this.#a.textContent}`:""}.`,this.#o.hidden=!1}#C(){this.getAttribute("data-state")==="error"&&this.removeAttribute("data-state"),this.#o.hidden=!0,this.#o.textContent=""}#u(){if(!this.#t||!this.#c)return;let t=this.#t.muted;t?this.setAttribute("muted",""):this.removeAttribute("muted"),this.#c.setAttribute("aria-pressed",String(t)),this.#n.style.setProperty("--_vol",t?"0":this.#n.value)}#q(){this.#s.addEventListener("click",()=>{this.#r?this.#t.pause():this.#t.play().catch(()=>{})}),this.#i.addEventListener("input",()=>{let e=Number(this.#i.value);this.#m.style.width=`${e}%`,this.#t.duration&&(this.#t.currentTime=e/100*this.#t.duration,this.#S(this.#t.currentTime,this.#t.duration))}),this.#i.addEventListener("pointerdown",()=>{this.#d=!0,this.setState("scrub-active",!0)});let t=()=>{this.#d&&(this.#d=!1,this.setState("scrub-active",!1))};this.#i.addEventListener("pointerup",t),this.#i.addEventListener("pointercancel",t),this.#i.addEventListener("change",t),this.#n.addEventListener("input",()=>{this.#t.volume=Number(this.#n.value),this.#t.muted=!1,this.#u()}),this.#c.addEventListener("click",()=>{this.#t.muted=!this.#t.muted,this.#u()}),this.addEventListener("keydown",e=>{if(!(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey)&&!this.#z(e))switch(e.key){case" ":e.preventDefault(),this.#r?this.#t.pause():this.#t.play().catch(()=>{});break;case"ArrowLeft":e.preventDefault(),this.#t.currentTime=Math.max(0,this.#t.currentTime-10);break;case"ArrowRight":e.preventDefault(),this.#t.currentTime=Math.min(this.#t.duration||0,this.#t.currentTime+10);break;case"m":case"M":this.#t.muted=!this.#t.muted,this.#u();break}}),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Audio player"),this.hasAttribute("aria-keyshortcuts")||this.setAttribute("aria-keyshortcuts","Space ArrowLeft ArrowRight M")}#z(t){for(let e of t.composedPath()){if(e===this)return!1;if(e instanceof Element&&e.matches(v))return!0}return!1}#$(){this.#e&&this.#e.addEventListener("click",t=>{let r=t.target?.closest("a[href]"),a=r?.closest("li");!r||!a||(t.preventDefault(),this.#b(a))})}#b(t){if(!this.#e)return;let e=p(this.#t,this.#e,t);e&&(this.#l.add(t),this.#g(),this.#f("audio-player:track-change",e))}#N(){if(!this.#e)return;let t=this.#t.src,e=l(this.#e).find(r=>r.querySelector("a[href]").href===t);this.#e.querySelectorAll("li[data-audio-active]").forEach(r=>{r!==e&&r.removeAttribute("data-audio-active")}),e?.setAttribute("data-audio-active","")}#V(){if(!this.#e)return;let t=this.hasAttribute("loop");if(!this.hasAttribute("shuffle")){let n=m(this.#e,{loop:t});n&&this.#b(n);return}let e=l(this.#e),r=this.#e.querySelector("li[data-audio-active]");r&&this.#l.add(r);let a=e.filter(n=>!this.#l.has(n));if(!a.length){if(this.#l.clear(),!t)return;a=e.length>1?e.filter(n=>n!==r):e}let s=a[Math.floor(Math.random()*a.length)];s&&this.#b(s)}#h(){let t=this.#t.currentTime,e=this.#t.duration||0,r=e?t/e*100:0;this.#x.textContent=this.#p(t),this.#S(t,e),!this.#d&&(this.#i.value=String(r),this.#m.style.width=`${r}%`)}#S(t,e){this.#i.setAttribute("aria-valuetext",`${this.#p(t)} of ${this.#p(e)}`)}#y(){let t=this.#t.duration||0;this.#w.textContent=this.#p(t)}#g(){if(!this.#a)return;if(this.#e){let r=this.#e.querySelector("li[data-audio-active] a");if(r){this.#a.textContent=r.textContent;return}}let t=this.#t.src||this.#t.currentSrc||this.#t.querySelector("source")?.src||"",e=t?t.split("/").pop().split(/[?#]/)[0]:"";this.#a.textContent=e.replace(/\.[^.]+$/,"").replace(/[-_]/g," ")}#p(t){if(!Number.isFinite(t))return"0:00";let e=Math.floor(t/60),r=Math.floor(t%60).toString().padStart(2,"0");return`${e}:${r}`}#f(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}};d("audio-player",u);export{u as AudioPlayerElement};
350
350
  //# sourceMappingURL=audio-player.js.map
@@ -1,4 +1,4 @@
1
- var T=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;function M(r,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=w.get(r);if(customElements.get(r)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}w.set(r,n),customElements.define(r,t)}var d=class extends HTMLElement{#t=[];#r;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#t.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#r||(this.#r=this.attachInternals());let i=this.#r.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#r||(this.#r=t)}};var m=new Map;function C(){if(!m.has("default"))try{m.set("default",new AudioContext)}catch{return null}return m.get("default")}var f=new WeakMap;function z(r,t){if(f.has(r))return f.get(r);let e=t.createMediaElementSource(r);return e.connect(t.destination),f.set(r,e),e}function A(r){let t=Number.parseInt(r??"",10);if(!Number.isFinite(t)||t<=0)return 256;let e=2**Math.round(Math.log2(t));return Math.min(32768,Math.max(32,e))}function L(r){if(r.crossOrigin!=null)return!1;let t=r.currentSrc||r.src||r.querySelector("source[src]")?.src||"";if(!t)return!1;try{let e=new URL(t,location.href);return e.protocol==="data:"||e.protocol==="blob:"?!1:e.origin!==location.origin}catch{return!1}}var E=new WeakSet,O=new Set(["bars","waveform","circle"]);function S(r){return r&&O.has(r)?r:"bars"}var b="oklch(55% 0.2 260)",$=new Uint8Array(256).fill(128),q=new Uint8Array(128),y=class extends d{#t=null;#r=null;#c=null;#e=null;#a=null;#u=new Uint8Array(0);#d=new Uint8Array(0);#f=b;#m="";#p="bars";#i=null;#g=null;#v=null;#b=!0;#n=!1;#h=!1;#s=null;#l=()=>this.#S();static get observedAttributes(){return["for","data-mode","data-fft-size"]}setup(){if(this.#h=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.#p=S(this.getAttribute("data-mode")),this.#C(),this.#M(),this.#A(),this.#q(),this.#T(),this.#_(),this.#n&&this.#a&&this.#e){try{this.#a.connect(this.#e)}catch{}this.#y()}let t=()=>requestAnimationFrame(()=>{this.#M(),this.#i||this.#o()});this.listen(window,"vb:theme-change",t),this.listen(window.matchMedia("(prefers-color-scheme: dark)"),"change",t)}teardown(){this.#w(),this.#g?.disconnect(),this.#v?.disconnect(),this.#s?.removeEventListener("play",this.#l),this.#s=null,this.#E()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="data-mode"){this.#p=S(i),this.isConnected&&!this.#i&&this.#o();return}this.isConnected&&(t==="for"?this.#A():t==="data-fft-size"&&this.#e&&(this.#e.fftSize=A(i),this.#k(),this.#i||this.#o()))}}#C(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
1
+ var T=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;function M(r,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=w.get(r);if(customElements.get(r)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}w.set(r,n),customElements.define(r,t)}var d=class extends HTMLElement{#t=[];#r;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#t.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#r||(this.#r=this.attachInternals());let i=this.#r.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#r||(this.#r=t)}#s(){return this.constructor.formAssociated&&this.#r?this.#r:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var m=new Map;function C(){if(!m.has("default"))try{m.set("default",new AudioContext)}catch{return null}return m.get("default")}var f=new WeakMap;function z(r,t){if(f.has(r))return f.get(r);let e=t.createMediaElementSource(r);return e.connect(t.destination),f.set(r,e),e}function A(r){let t=Number.parseInt(r??"",10);if(!Number.isFinite(t)||t<=0)return 256;let e=2**Math.round(Math.log2(t));return Math.min(32768,Math.max(32,e))}function L(r){if(r.crossOrigin!=null)return!1;let t=r.currentSrc||r.src||r.querySelector("source[src]")?.src||"";if(!t)return!1;try{let e=new URL(t,location.href);return e.protocol==="data:"||e.protocol==="blob:"?!1:e.origin!==location.origin}catch{return!1}}var E=new WeakSet,O=new Set(["bars","waveform","circle"]);function S(r){return r&&O.has(r)?r:"bars"}var b="oklch(55% 0.2 260)",$=new Uint8Array(256).fill(128),q=new Uint8Array(128),y=class extends d{#t=null;#r=null;#s=null;#e=null;#h=null;#u=new Uint8Array(0);#d=new Uint8Array(0);#f=b;#m="";#g="bars";#i=null;#p=null;#v=null;#b=!0;#o=!1;#c=!1;#n=null;#l=()=>this.#S();static get observedAttributes(){return["for","data-mode","data-fft-size"]}setup(){if(this.#c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.#g=S(this.getAttribute("data-mode")),this.#C(),this.#M(),this.#A(),this.#q(),this.#T(),this.#_(),this.#o&&this.#h&&this.#e){try{this.#h.connect(this.#e)}catch{}this.#y()}let t=()=>requestAnimationFrame(()=>{this.#M(),this.#i||this.#a()});this.listen(window,"vb:theme-change",t),this.listen(window.matchMedia("(prefers-color-scheme: dark)"),"change",t)}teardown(){this.#w(),this.#p?.disconnect(),this.#v?.disconnect(),this.#n?.removeEventListener("play",this.#l),this.#n=null,this.#E()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="data-mode"){this.#g=S(i),this.isConnected&&!this.#i&&this.#a();return}this.isConnected&&(t==="for"?this.#A():t==="data-fft-size"&&this.#e&&(this.#e.fftSize=A(i),this.#k(),this.#i||this.#a()))}}#C(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
2
2
  <style>
3
3
  :host {
4
4
  display: block;
@@ -16,5 +16,5 @@ var T=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;functi
16
16
  }
17
17
  </style>
18
18
  <canvas aria-hidden="true"></canvas>
19
- `,this.#t=t.querySelector("canvas"),this.#r=this.#t.getContext("2d")}#M(){let t=getComputedStyle(this);this.#f=t.getPropertyValue("--_color").trim()||b,this.#m=t.getPropertyValue("--_bg").trim()}#A(){let t=this.getAttribute("for"),e=t?document.getElementById(t):null,i=e?.tagName==="AUDIO"?e:null;if(this.#c&&this.#c!==i&&(this.#w(),this.#E(),this.#e=null,this.#a=null,this.#n=!1,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#o()),this.#c=i,!i){this.#s?.removeEventListener("play",this.#l),this.#s=null;return}this.#n||(this.#s!==i&&(this.#s?.removeEventListener("play",this.#l),i.addEventListener("play",this.#l),this.#s=i),i.paused||this.#S())}#E(){if(this.#a&&this.#e)try{this.#a.disconnect(this.#e)}catch{}}#S(){if(this.#n||!this.#c)return;let t=this.#c;if(!f.has(t)&&L(t)){this.setAttribute("data-state","cross-origin"),E.has(t)||(E.add(t),console.warn('<audio-visualizer>: not visualising a cross-origin <audio> without crossorigin="anonymous" and CORS headers \u2014 hooking it would mute playback.',t));return}let e=C();if(!e)return;let i,n;try{i=e.createAnalyser(),i.fftSize=A(this.getAttribute("data-fft-size")),i.smoothingTimeConstant=.8,n=z(t,e),n.connect(i)}catch(s){this.setAttribute("data-state","error"),console.warn("<audio-visualizer>: could not connect to the audio element.",s);return}this.#e=i,this.#a=n,this.#k(),this.#n=!0,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#s?.removeEventListener("play",this.#l),this.#s=null,e.state==="suspended"&&e.resume().catch(()=>{}),this.#y()}#k(){this.#e&&(this.#u.length!==this.#e.frequencyBinCount&&(this.#u=new Uint8Array(this.#e.frequencyBinCount)),this.#d.length!==this.#e.fftSize&&(this.#d=new Uint8Array(this.#e.fftSize)))}#y(){if(this.#i)return;if(this.#h){this.#o();return}let t=()=>{if(!this.#b||this.#h){this.#i=null;return}this.#i=requestAnimationFrame(t),this.#o()};this.#i=requestAnimationFrame(t)}#w(){this.#i&&(cancelAnimationFrame(this.#i),this.#i=null)}#z(){let t=window.devicePixelRatio||1,e=Math.round(this.#t.clientWidth*t),i=Math.round(this.#t.clientHeight*t);this.#t.width!==e&&(this.#t.width=e),this.#t.height!==i&&(this.#t.height=i)}#o(){let t=this.#r;if(!t)return;let e=this.#t.width,i=this.#t.height;if(!e||!i)return;t.clearRect(0,0,e,i),this.#m&&this.#m!=="transparent"&&(t.fillStyle=this.#m,t.fillRect(0,0,e,i));let n=this.#n?this.#e:null,s=this.#p;if(s==="waveform"){n&&n.getByteTimeDomainData(this.#d),this.#O(t,e,i,this.#f,n?this.#d:$);return}n&&n.getByteFrequencyData(this.#u);let h=n?this.#u:q;s==="circle"?this.#$(t,e,i,this.#f,h):this.#L(t,e,i,this.#f,h)}#L(t,e,i,n,s){let h=Math.min(s.length,64),o=e/h,c=Math.max(1,o-1),u=Math.max(1,Math.round(i*.03));t.fillStyle=n;for(let a=0;a<h;a++){let l=Math.max(u,s[a]/255*i);t.fillRect(a*o,i-l,c,l)}}#O(t,e,i,n,s){let h=e/Math.max(1,s.length-1);t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let o=0;o<s.length;o++){let c=s[o]/255*i;o===0?t.moveTo(0,c):t.lineTo(o*h,c)}t.stroke()}#$(t,e,i,n,s){let h=e/2,o=i/2,c=Math.min(e,i)*.25,u=s.length;t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let a=0;a<u;a++){let l=a/u*Math.PI*2,k=s[a]/255*(c*.8),p=c+k,g=h+p*Math.cos(l),v=o+p*Math.sin(l);a===0?t.moveTo(g,v):t.lineTo(g,v)}t.closePath(),t.stroke()}#q(){this.#g??=new IntersectionObserver(([t])=>{this.#b=t.isIntersecting,this.#b&&this.#n&&!this.#i&&!this.#h&&this.#y()}),this.#g.observe(this)}#T(){this.#v??=new ResizeObserver(()=>{this.#z(),this.#i||this.#o()}),this.#v.observe(this.#t)}#_(){let t=window.matchMedia("(prefers-reduced-motion: reduce)");this.listen(t,"change",e=>{this.#h=e.matches,this.#h?(this.#w(),this.#o()):this.#n&&this.#b&&!this.#i&&this.#y()})}};M("audio-visualizer",y);export{y as AudioVisualizerElement};
19
+ `,this.#t=t.querySelector("canvas"),this.#r=this.#t.getContext("2d")}#M(){let t=getComputedStyle(this);this.#f=t.getPropertyValue("--_color").trim()||b,this.#m=t.getPropertyValue("--_bg").trim()}#A(){let t=this.getAttribute("for"),e=t?document.getElementById(t):null,i=e?.tagName==="AUDIO"?e:null;if(this.#s&&this.#s!==i&&(this.#w(),this.#E(),this.#e=null,this.#h=null,this.#o=!1,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#a()),this.#s=i,!i){this.#n?.removeEventListener("play",this.#l),this.#n=null;return}this.#o||(this.#n!==i&&(this.#n?.removeEventListener("play",this.#l),i.addEventListener("play",this.#l),this.#n=i),i.paused||this.#S())}#E(){if(this.#h&&this.#e)try{this.#h.disconnect(this.#e)}catch{}}#S(){if(this.#o||!this.#s)return;let t=this.#s;if(!f.has(t)&&L(t)){this.setAttribute("data-state","cross-origin"),E.has(t)||(E.add(t),console.warn('<audio-visualizer>: not visualising a cross-origin <audio> without crossorigin="anonymous" and CORS headers \u2014 hooking it would mute playback.',t));return}let e=C();if(!e)return;let i,n;try{i=e.createAnalyser(),i.fftSize=A(this.getAttribute("data-fft-size")),i.smoothingTimeConstant=.8,n=z(t,e),n.connect(i)}catch(s){this.setAttribute("data-state","error"),console.warn("<audio-visualizer>: could not connect to the audio element.",s);return}this.#e=i,this.#h=n,this.#k(),this.#o=!0,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#n?.removeEventListener("play",this.#l),this.#n=null,e.state==="suspended"&&e.resume().catch(()=>{}),this.#y()}#k(){this.#e&&(this.#u.length!==this.#e.frequencyBinCount&&(this.#u=new Uint8Array(this.#e.frequencyBinCount)),this.#d.length!==this.#e.fftSize&&(this.#d=new Uint8Array(this.#e.fftSize)))}#y(){if(this.#i)return;if(this.#c){this.#a();return}let t=()=>{if(!this.#b||this.#c){this.#i=null;return}this.#i=requestAnimationFrame(t),this.#a()};this.#i=requestAnimationFrame(t)}#w(){this.#i&&(cancelAnimationFrame(this.#i),this.#i=null)}#z(){let t=window.devicePixelRatio||1,e=Math.round(this.#t.clientWidth*t),i=Math.round(this.#t.clientHeight*t);this.#t.width!==e&&(this.#t.width=e),this.#t.height!==i&&(this.#t.height=i)}#a(){let t=this.#r;if(!t)return;let e=this.#t.width,i=this.#t.height;if(!e||!i)return;t.clearRect(0,0,e,i),this.#m&&this.#m!=="transparent"&&(t.fillStyle=this.#m,t.fillRect(0,0,e,i));let n=this.#o?this.#e:null,s=this.#g;if(s==="waveform"){n&&n.getByteTimeDomainData(this.#d),this.#O(t,e,i,this.#f,n?this.#d:$);return}n&&n.getByteFrequencyData(this.#u);let h=n?this.#u:q;s==="circle"?this.#$(t,e,i,this.#f,h):this.#L(t,e,i,this.#f,h)}#L(t,e,i,n,s){let h=Math.min(s.length,64),o=e/h,c=Math.max(1,o-1),u=Math.max(1,Math.round(i*.03));t.fillStyle=n;for(let a=0;a<h;a++){let l=Math.max(u,s[a]/255*i);t.fillRect(a*o,i-l,c,l)}}#O(t,e,i,n,s){let h=e/Math.max(1,s.length-1);t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let o=0;o<s.length;o++){let c=s[o]/255*i;o===0?t.moveTo(0,c):t.lineTo(o*h,c)}t.stroke()}#$(t,e,i,n,s){let h=e/2,o=i/2,c=Math.min(e,i)*.25,u=s.length;t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let a=0;a<u;a++){let l=a/u*Math.PI*2,k=s[a]/255*(c*.8),g=c+k,p=h+g*Math.cos(l),v=o+g*Math.sin(l);a===0?t.moveTo(p,v):t.lineTo(p,v)}t.closePath(),t.stroke()}#q(){this.#p??=new IntersectionObserver(([t])=>{this.#b=t.isIntersecting,this.#b&&this.#o&&!this.#i&&!this.#c&&this.#y()}),this.#p.observe(this)}#T(){this.#v??=new ResizeObserver(()=>{this.#z(),this.#i||this.#a()}),this.#v.observe(this.#t)}#_(){let t=window.matchMedia("(prefers-reduced-motion: reduce)");this.listen(t,"change",e=>{this.#c=e.matches,this.#c?(this.#w(),this.#a()):this.#o&&this.#b&&!this.#i&&this.#y()})}};M("audio-visualizer",y);export{y as AudioVisualizerElement};
20
20
  //# sourceMappingURL=audio-visualizer.js.map
@@ -1,3 +1,3 @@
1
- var T=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function A(o,t,e={}){let s=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=x.get(o);if(customElements.get(o)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}x.set(o,r),customElements.define(o,t)}var m=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,r){t.addEventListener(e,s,r),this.#t.push(()=>t.removeEventListener(e,s,r))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let r=`--${t}`;e?s.add(r):s.delete(r)}}_adoptInternals(t){this.#e||(this.#e=t)}};function y(o){return String(o??"").normalize("NFKD").replace(/\p{M}+/gu,"").toLowerCase()}function k(o){return y(o).replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"author"}function N(o,t,e=()=>!1){let s=k(o),r=s;for(let n=2;t.has(r)||e(r);n++)r=`${s}-${n}`;return t.add(r),r}function S(o){let t=String(o??"").trim();if(!t)return null;try{let{protocol:e}=new URL(t,"https://author-index.invalid/");return e==="http:"||e==="https:"?t:null}catch{return null}}function q(o){let t=Number.parseInt(o??"",10);return Number.isInteger(t)?Math.min(6,Math.max(1,t)):2}function L(o){let t=o.cloneNode(!0);return t.querySelectorAll('.visually-hidden, [aria-hidden="true"]').forEach(e=>e.remove()),y(t.textContent||"")}var b=class extends m{#t=null;setup(){if(this.querySelector(":scope > [data-author-index-search]")){this.#r();return}let t=this.getAttribute("data-lens-src")||this.getAttribute("src");t?(this.#t=new AbortController,this.#e(t,this.#t.signal)):this.#r()}teardown(){this.#t?.abort(),this.#t=null}async#e(t,e){let s;try{let r=await fetch(t,{signal:e});if(!r.ok)throw new Error(`status ${r.status}`);let n=await r.json();if(s=Array.isArray(n)?n:n?.pages||[],!Array.isArray(s))throw new Error("no pages array")}catch(r){if(e.aborted)return;this.children.length>0?this.#r():this.#s(`Could not load ${t}: ${r instanceof Error?r.message:r}`);return}e.aborted||(this.#n(s),this.#r())}#n(t){let e=new Map;for(let l of t){if(!l||typeof l!="object")continue;let a=typeof l.author=="string"&&l.author.trim()||"Unknown";e.has(a)||e.set(a,[]),e.get(a).push(l)}let s=this.getAttribute("sort")==="count"?"count":"alpha",r=[...e.entries()].sort(([l,a],[g,f])=>s==="count"&&f.length!==a.length?f.length-a.length:l.localeCompare(g)),n=q(this.getAttribute("heading-level")),u=new Set,p=l=>{let a=document.getElementById(`author-${l}`);return!!a&&!this.contains(a)},i=[`<h${n} class="author-index-heading">Authors <small>(${r.length})</small></h${n}>`];for(let[l,a]of r){let g=a[0],f=N(l,u,p),M=`${a.length} ${a.length===1?"page":"pages"}`;i.push(`<details data-author-group id="author-${h(f)}">`),i.push(`<summary><span class="author-name">${d(l)}</span><span class="author-count"><span aria-hidden="true">(${a.length})</span><span class="visually-hidden">, ${M}</span></span></summary>`);let $=S(g.authorUrl);$&&i.push(`<p class="author-link"><a href="${h($)}" rel="author">View ${d(l)}'s profile</a></p>`),i.push('<ul class="author-pages">');for(let c of a){let E=[c.modified?`<time datetime="${h(c.modified)}">${d(c.modified)}</time>`:"",c.provenance?`<span class="author-prov" data-provenance="${h(c.provenance)}">${d(c.provenance)}</span>`:"",c.signed?'<span class="author-signed" title="Cryptographically signed">signed</span>':""].filter(Boolean).join(" \xB7 "),w=S(c.url),v=d(c.title||c.url||"Untitled"),C=w?`<a href="${h(w)}">${v}</a>`:`<span>${v}</span>`;i.push(`<li>${C}${E?`<small>${E}</small>`:""}</li>`)}i.push("</ul></details>")}this.innerHTML=i.join(`
2
- `)}#s(t){let e=document.createElement("p");e.setAttribute("data-author-index-error",""),e.textContent=t,this.append(e)}#r(){let t=this.querySelector(":scope > [data-author-index-search]");if(!t){let r=this.getAttribute("placeholder")||"Filter authors\u2026";t=document.createElement("input"),t.type="search",t.placeholder=r,t.setAttribute("data-author-index-search",""),t.setAttribute("aria-label",r),this.prepend(t)}let e=this.querySelector(":scope > [data-author-index-status]");e||(e=document.createElement("p"),e.setAttribute("data-author-index-status",""),e.setAttribute("role","status"),e.className="visually-hidden",t.after(e));let s=t;this.listen(s,"input",()=>this.#o(s.value))}#o(t){let e=y(t.trim()),s=[...this.querySelectorAll("[data-author-group]")],r=0;for(let i of s)i.hidden=!!e&&!L(i).includes(e),i.hidden||r++;let n=this.querySelector(":scope > [data-author-index-status]");if(!n)return;let u=s.length,p=i=>i===1?"author":"authors";e?r===0?n.textContent=`No authors match \u201C${t.trim()}\u201D`:n.textContent=`${r} of ${u} ${p(u)} match \u201C${t.trim()}\u201D`:n.textContent=`Showing all ${u} ${p(u)}`,n.classList.toggle("visually-hidden",!(e&&r===0)),n.toggleAttribute("data-empty",!!e&&r===0)}};function d(o){return String(o??"").replace(/[&<>]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[t])}function h(o){return String(o??"").replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}A("author-index",b);export{b as AuthorIndex,S as safeHref,k as slugify,N as uniqueSlug};
1
+ var T=window.matchMedia("(prefers-reduced-motion: reduce)");var A=new Map;function x(o,t,e={}){let s=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=A.get(o);if(customElements.get(o)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}A.set(o,r),customElements.define(o,t)}var m=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,r){t.addEventListener(e,s,r),this.#t.push(()=>t.removeEventListener(e,s,r))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let r=`--${t}`;e?s.add(r):s.delete(r)}}_adoptInternals(t){this.#e||(this.#e=t)}#r(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};function b(o){return String(o??"").normalize("NFKD").replace(/\p{M}+/gu,"").toLowerCase()}function C(o){return b(o).replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"author"}function N(o,t,e=()=>!1){let s=C(o),r=s;for(let n=2;t.has(r)||e(r);n++)r=`${s}-${n}`;return t.add(r),r}function S(o){let t=String(o??"").trim();if(!t)return null;try{let{protocol:e}=new URL(t,"https://author-index.invalid/");return e==="http:"||e==="https:"?t:null}catch{return null}}function q(o){let t=Number.parseInt(o??"",10);return Number.isInteger(t)?Math.min(6,Math.max(1,t)):2}function L(o){let t=o.cloneNode(!0);return t.querySelectorAll('.visually-hidden, [aria-hidden="true"]').forEach(e=>e.remove()),b(t.textContent||"")}var y=class extends m{#t=null;setup(){if(this.querySelector(":scope > [data-author-index-search]")){this.#n();return}let t=this.getAttribute("data-lens-src")||this.getAttribute("src");t?(this.#t=new AbortController,this.#e(t,this.#t.signal)):this.#n()}teardown(){this.#t?.abort(),this.#t=null}async#e(t,e){let s;try{let r=await fetch(t,{signal:e});if(!r.ok)throw new Error(`status ${r.status}`);let n=await r.json();if(s=Array.isArray(n)?n:n?.pages||[],!Array.isArray(s))throw new Error("no pages array")}catch(r){if(e.aborted)return;this.children.length>0?this.#n():this.#s(`Could not load ${t}: ${r instanceof Error?r.message:r}`);return}e.aborted||(this.#r(s),this.#n())}#r(t){let e=new Map;for(let l of t){if(!l||typeof l!="object")continue;let i=typeof l.author=="string"&&l.author.trim()||"Unknown";e.has(i)||e.set(i,[]),e.get(i).push(l)}let s=this.getAttribute("sort")==="count"?"count":"alpha",r=[...e.entries()].sort(([l,i],[g,f])=>s==="count"&&f.length!==i.length?f.length-i.length:l.localeCompare(g)),n=q(this.getAttribute("heading-level")),u=new Set,p=l=>{let i=document.getElementById(`author-${l}`);return!!i&&!this.contains(i)},a=[`<h${n} class="author-index-heading">Authors <small>(${r.length})</small></h${n}>`];for(let[l,i]of r){let g=i[0],f=N(l,u,p),M=`${i.length} ${i.length===1?"page":"pages"}`;a.push(`<details data-author-group id="author-${h(f)}">`),a.push(`<summary><span class="author-name">${d(l)}</span><span class="author-count"><span aria-hidden="true">(${i.length})</span><span class="visually-hidden">, ${M}</span></span></summary>`);let $=S(g.authorUrl);$&&a.push(`<p class="author-link"><a href="${h($)}" rel="author">View ${d(l)}'s profile</a></p>`),a.push('<ul class="author-pages">');for(let c of i){let w=[c.modified?`<time datetime="${h(c.modified)}">${d(c.modified)}</time>`:"",c.provenance?`<span class="author-prov" data-provenance="${h(c.provenance)}">${d(c.provenance)}</span>`:"",c.signed?'<span class="author-signed" title="Cryptographically signed">signed</span>':""].filter(Boolean).join(" \xB7 "),v=S(c.url),E=d(c.title||c.url||"Untitled"),k=v?`<a href="${h(v)}">${E}</a>`:`<span>${E}</span>`;a.push(`<li>${k}${w?`<small>${w}</small>`:""}</li>`)}a.push("</ul></details>")}this.innerHTML=a.join(`
2
+ `)}#s(t){let e=document.createElement("p");e.setAttribute("data-author-index-error",""),e.textContent=t,this.append(e)}#n(){let t=this.querySelector(":scope > [data-author-index-search]");if(!t){let r=this.getAttribute("placeholder")||"Filter authors\u2026";t=document.createElement("input"),t.type="search",t.placeholder=r,t.setAttribute("data-author-index-search",""),t.setAttribute("aria-label",r),this.prepend(t)}let e=this.querySelector(":scope > [data-author-index-status]");e||(e=document.createElement("p"),e.setAttribute("data-author-index-status",""),e.setAttribute("role","status"),e.className="visually-hidden",t.after(e));let s=t;this.listen(s,"input",()=>this.#o(s.value))}#o(t){let e=b(t.trim()),s=[...this.querySelectorAll("[data-author-group]")],r=0;for(let a of s)a.hidden=!!e&&!L(a).includes(e),a.hidden||r++;let n=this.querySelector(":scope > [data-author-index-status]");if(!n)return;let u=s.length,p=a=>a===1?"author":"authors";e?r===0?n.textContent=`No authors match \u201C${t.trim()}\u201D`:n.textContent=`${r} of ${u} ${p(u)} match \u201C${t.trim()}\u201D`:n.textContent=`Showing all ${u} ${p(u)}`,n.classList.toggle("visually-hidden",!(e&&r===0)),n.toggleAttribute("data-empty",!!e&&r===0)}};function d(o){return String(o??"").replace(/[&<>]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[t])}function h(o){return String(o??"").replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}x("author-index",y);export{y as AuthorIndex,S as safeHref,C as slugify,N as uniqueSlug};
3
3
  //# sourceMappingURL=author-index.js.map
@@ -1,2 +1,2 @@
1
- var a=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,i){t.addEventListener(e,r,i),this.#t.push(()=>t.removeEventListener(e,r,i))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let i=`--${t}`;e?r.add(i):r.delete(i)}}_adoptInternals(t){this.#e||(this.#e=t)}};var p=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function f(n,t,e={}){let r=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:r},s=h.get(n);if(customElements.get(n)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}h.set(n,i),customElements.define(n,t)}var u="data-brand-mark-img",m="(width < 48rem)",l=class extends a{static observedAttributes=["src","src-dark","src-compact","compact-media","alt","wordmark","height"];#t=null;#e=null;#r=null;#i=!1;setup(){this.#c(),this.hasAttribute("src-dark")&&this.#o(),this.#n(),this.#e=new MutationObserver(()=>this.#d()),this.#e.observe(this,{childList:!0,characterData:!0,subtree:!0})}teardown(){this.#t?.disconnect(),this.#t=null,this.#e?.disconnect(),this.#e=null,this.#r=null,this.#i=!1}attributeChangedCallback(t,e,r){if(e!==r&&!(!this.isConnected||!this.hasAttribute("data-upgraded"))){if(t==="height"){this.#c();return}t==="src-dark"&&r!==null&&this.#o(),this.#n()}}#u(){let t=document.documentElement.getAttribute("data-mode");if(t==="dark")return!0;if(t==="light")return!1;let e=getComputedStyle(this).colorScheme||"";return/\bdark\b/.test(e)&&!/\blight\b/.test(e)?!0:/\blight\b/.test(e)&&!/\bdark\b/.test(e)?!1:(this.#r??matchMedia("(prefers-color-scheme: dark)")).matches}#o(){this.#i||(this.#i=!0,this.#r=matchMedia("(prefers-color-scheme: dark)"),this.listen(this.#r,"change",this.#s),this.listen(window,"vb:theme-change",this.#s),this.#t=new MutationObserver(this.#s),this.#t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-mode","data-theme"]}))}#s=()=>{this.isConnected&&this.#n()};#c(){let t=this.getAttribute("height")?.trim();if(!t){this.style.removeProperty("--brand-mark-height"),this.getAttribute("style")||this.removeAttribute("style");return}this.style.setProperty("--brand-mark-height",/^\d+(\.\d+)?$/.test(t)?`${t}px`:t)}#a(){return this.querySelector(`:scope > [${u}]`)}#n(){let t=this.getAttribute("src"),e=this.#a();if(!t){e?.remove();return}let r=this.getAttribute("src-dark"),i=r&&this.#u()?r:t;if(!(e instanceof HTMLPictureElement)||!e.querySelector(":scope > img")){e?.remove(),e=document.createElement("picture"),e.setAttribute(u,"");let c=document.createElement("img");c.decoding="async",e.append(c),this.prepend(e)}let s=e.querySelector(":scope > img");s.getAttribute("src")!==i&&s.setAttribute("src",i);let d=this.getAttribute("src-compact"),o=e.querySelector(":scope > source");if(d){o||(o=document.createElement("source"),e.prepend(o));let c=this.getAttribute("compact-media")||m;o.getAttribute("media")!==c&&o.setAttribute("media",c),o.getAttribute("srcset")!==d&&o.setAttribute("srcset",d)}else o?.remove();this.#d()}#d(){let t=this.#a()?.querySelector(":scope > img");if(!t)return;let e=this.getAttribute("alt"),r=!this.hasAttribute("wordmark"),i;r&&e?i=e:this.#l()?i="":i=e??"",t.getAttribute("alt")!==i&&t.setAttribute("alt",i)}#l(){for(let t of this.childNodes)if(!(t instanceof Element&&t.hasAttribute(u))&&t.textContent?.trim())return!0;return!1}};f("brand-mark",l);
1
+ var a=class extends HTMLElement{#r=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#r)t();this.#r=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,i){t.addEventListener(e,r,i),this.#r.push(()=>t.removeEventListener(e,r,i))}_reinit(){for(let t of this.#r)t();this.#r=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let r=this.#t.states;try{e?r.add(t):r.delete(t)}catch{let i=`--${t}`;e?r.add(i):r.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}#e(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};var p=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function f(n,t,e={}){let r=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:r},s=h.get(n);if(customElements.get(n)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}h.set(n,i),customElements.define(n,t)}var u="data-brand-mark-img",m="(width < 48rem)",l=class extends a{static observedAttributes=["src","src-dark","src-compact","compact-media","alt","wordmark","height"];#r=null;#t=null;#e=null;#i=!1;setup(){this.#c(),this.hasAttribute("src-dark")&&this.#o(),this.#n(),this.#t=new MutationObserver(()=>this.#d()),this.#t.observe(this,{childList:!0,characterData:!0,subtree:!0})}teardown(){this.#r?.disconnect(),this.#r=null,this.#t?.disconnect(),this.#t=null,this.#e=null,this.#i=!1}attributeChangedCallback(t,e,r){if(e!==r&&!(!this.isConnected||!this.hasAttribute("data-upgraded"))){if(t==="height"){this.#c();return}t==="src-dark"&&r!==null&&this.#o(),this.#n()}}#u(){let t=document.documentElement.getAttribute("data-mode");if(t==="dark")return!0;if(t==="light")return!1;let e=getComputedStyle(this).colorScheme||"";return/\bdark\b/.test(e)&&!/\blight\b/.test(e)?!0:/\blight\b/.test(e)&&!/\bdark\b/.test(e)?!1:(this.#e??matchMedia("(prefers-color-scheme: dark)")).matches}#o(){this.#i||(this.#i=!0,this.#e=matchMedia("(prefers-color-scheme: dark)"),this.listen(this.#e,"change",this.#s),this.listen(window,"vb:theme-change",this.#s),this.#r=new MutationObserver(this.#s),this.#r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-mode","data-theme"]}))}#s=()=>{this.isConnected&&this.#n()};#c(){let t=this.getAttribute("height")?.trim();if(!t){this.style.removeProperty("--brand-mark-height"),this.getAttribute("style")||this.removeAttribute("style");return}this.style.setProperty("--brand-mark-height",/^\d+(\.\d+)?$/.test(t)?`${t}px`:t)}#a(){return this.querySelector(`:scope > [${u}]`)}#n(){let t=this.getAttribute("src"),e=this.#a();if(!t){e?.remove();return}let r=this.getAttribute("src-dark"),i=r&&this.#u()?r:t;if(!(e instanceof HTMLPictureElement)||!e.querySelector(":scope > img")){e?.remove(),e=document.createElement("picture"),e.setAttribute(u,"");let c=document.createElement("img");c.decoding="async",e.append(c),this.prepend(e)}let s=e.querySelector(":scope > img");s.getAttribute("src")!==i&&s.setAttribute("src",i);let d=this.getAttribute("src-compact"),o=e.querySelector(":scope > source");if(d){o||(o=document.createElement("source"),e.prepend(o));let c=this.getAttribute("compact-media")||m;o.getAttribute("media")!==c&&o.setAttribute("media",c),o.getAttribute("srcset")!==d&&o.setAttribute("srcset",d)}else o?.remove();this.#d()}#d(){let t=this.#a()?.querySelector(":scope > img");if(!t)return;let e=this.getAttribute("alt"),r=!this.hasAttribute("wordmark"),i;r&&e?i=e:this.#l()?i="":i=e??"",t.getAttribute("alt")!==i&&t.setAttribute("alt",i)}#l(){for(let t of this.childNodes)if(!(t instanceof Element&&t.hasAttribute(u))&&t.textContent?.trim())return!0;return!1}};f("brand-mark",l);
2
2
  //# sourceMappingURL=brand-mark.js.map