vanilla-breeze 0.4.1 → 0.5.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 (238) hide show
  1. package/custom-elements.json +13966 -11505
  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 +9 -6
  5. package/dist/cdn/components/ai-summary.js +4 -2
  6. package/dist/cdn/components/analytics-panel.js +19 -21
  7. package/dist/cdn/components/audio-player.js +17 -7
  8. package/dist/cdn/components/audio-visualizer.js +3 -3
  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 -11
  16. package/dist/cdn/components/chart-wc.js +32 -32
  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 +49 -49
  23. package/dist/cdn/components/comment-thread.js +32 -32
  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 +4 -4
  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 +2 -2
  45. package/dist/cdn/components/image-gallery.js +1 -1
  46. package/dist/cdn/components/image-map.js +1 -1
  47. package/dist/cdn/components/include-file.js +1 -1
  48. package/dist/cdn/components/manifest.json +100 -100
  49. package/dist/cdn/components/markdown-editor.js +1 -1
  50. package/dist/cdn/components/markdown-viewer.js +11 -11
  51. package/dist/cdn/components/nav-bar.js +1 -1
  52. package/dist/cdn/components/note-wc.js +2 -2
  53. package/dist/cdn/components/notification-wc.js +4 -4
  54. package/dist/cdn/components/page-info.js +2 -2
  55. package/dist/cdn/components/page-stats.js +1 -1
  56. package/dist/cdn/components/page-toc.js +1 -1
  57. package/dist/cdn/components/page-tools.js +1 -1
  58. package/dist/cdn/components/page-tour.js +5 -5
  59. package/dist/cdn/components/pager-wc.js +1 -1
  60. package/dist/cdn/components/poll-wc.js +1 -1
  61. package/dist/cdn/components/pop-over.js +1 -1
  62. package/dist/cdn/components/popularity-index.js +4 -4
  63. package/dist/cdn/components/print-page.js +1 -1
  64. package/dist/cdn/components/progress-tracker.js +1 -1
  65. package/dist/cdn/components/qr-code.js +1 -1
  66. package/dist/cdn/components/reaction-bar.js +1 -1
  67. package/dist/cdn/components/reader-view.js +3 -3
  68. package/dist/cdn/components/reading-progress.js +1 -1
  69. package/dist/cdn/components/recently-visited.js +7 -7
  70. package/dist/cdn/components/score-card.js +2 -2
  71. package/dist/cdn/components/selection-menu.js +1 -1
  72. package/dist/cdn/components/settings-panel.js +4 -4
  73. package/dist/cdn/components/share-wc.js +2 -2
  74. package/dist/cdn/components/short-cuts.js +1 -1
  75. package/dist/cdn/components/site-index.js +6 -6
  76. package/dist/cdn/components/site-map.js +1 -1
  77. package/dist/cdn/components/site-search.js +3 -3
  78. package/dist/cdn/components/slide-accept.js +1 -1
  79. package/dist/cdn/components/social-embed.js +1 -1
  80. package/dist/cdn/components/split-surface.js +1 -1
  81. package/dist/cdn/components/star-rating.js +1 -1
  82. package/dist/cdn/components/status-wc.js +1 -1
  83. package/dist/cdn/components/stepper-wc.js +1 -1
  84. package/dist/cdn/components/tab-set.js +1 -1
  85. package/dist/cdn/components/text-reader.js +2 -2
  86. package/dist/cdn/components/theme-picker.js +44 -44
  87. package/dist/cdn/components/time-index.js +2 -2
  88. package/dist/cdn/components/time-picker.js +1 -1
  89. package/dist/cdn/components/toast-msg.js +1 -1
  90. package/dist/cdn/components/tool-tip.js +1 -1
  91. package/dist/cdn/components/topic-map.js +3 -3
  92. package/dist/cdn/components/trust-filter.js +3 -3
  93. package/dist/cdn/components/version-switcher.js +3 -13
  94. package/dist/cdn/components/video-player.js +1 -1
  95. package/dist/cdn/components/watch-wc.js +2 -2
  96. package/dist/cdn/components/week-view.js +1 -1
  97. package/dist/cdn/components/youtube-player.js +1 -1
  98. package/dist/cdn/packs/effects.full.js +1 -1
  99. package/dist/cdn/packs/kawaii.effects.css +1 -1
  100. package/dist/cdn/packs/kawaii.full.css +1 -1
  101. package/dist/cdn/packs/kawaii.full.js +4 -4
  102. package/dist/cdn/packs/manifest.json +7 -7
  103. package/dist/cdn/packs/memphis.full.css +1 -1
  104. package/dist/cdn/packs/memphis.theme.css +1 -1
  105. package/dist/cdn/packs/ui.full.js +46 -46
  106. package/dist/cdn/themes/8bit.css +1 -1
  107. package/dist/cdn/themes/8bit.tokens.json +1 -1
  108. package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
  109. package/dist/cdn/themes/alpha1999.tokens.json +1 -1
  110. package/dist/cdn/themes/art-deco-dark.tokens.json +33 -1
  111. package/dist/cdn/themes/art-deco.css +1 -1
  112. package/dist/cdn/themes/art-deco.tokens.json +23 -1
  113. package/dist/cdn/themes/bauhaus-dark.tokens.json +23 -1
  114. package/dist/cdn/themes/bauhaus.css +1 -1
  115. package/dist/cdn/themes/bauhaus.tokens.json +1 -1
  116. package/dist/cdn/themes/brutalist-dark.tokens.json +33 -1
  117. package/dist/cdn/themes/brutalist.css +1 -1
  118. package/dist/cdn/themes/brutalist.tokens.json +23 -1
  119. package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
  120. package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
  121. package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
  122. package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
  123. package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
  124. package/dist/cdn/themes/classic-dark.tokens.json +1 -1
  125. package/dist/cdn/themes/classic.tokens.json +1 -1
  126. package/dist/cdn/themes/claymorphism-dark.tokens.json +33 -1
  127. package/dist/cdn/themes/claymorphism.css +1 -1
  128. package/dist/cdn/themes/claymorphism.tokens.json +23 -1
  129. package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
  130. package/dist/cdn/themes/clinical.tokens.json +1 -1
  131. package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
  132. package/dist/cdn/themes/cottagecore.css +1 -1
  133. package/dist/cdn/themes/cottagecore.tokens.json +1 -1
  134. package/dist/cdn/themes/cyber.css +1 -1
  135. package/dist/cdn/themes/cyber.tokens.json +1 -1
  136. package/dist/cdn/themes/dawn-dark.tokens.json +33 -1
  137. package/dist/cdn/themes/dawn.css +1 -1
  138. package/dist/cdn/themes/dawn.tokens.json +23 -1
  139. package/dist/cdn/themes/dracula.tokens.json +1 -1
  140. package/dist/cdn/themes/dusk.css +1 -1
  141. package/dist/cdn/themes/dusk.tokens.json +1 -1
  142. package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
  143. package/dist/cdn/themes/editorial.css +1 -1
  144. package/dist/cdn/themes/editorial.tokens.json +1 -1
  145. package/dist/cdn/themes/financial-dark.tokens.json +1 -1
  146. package/dist/cdn/themes/financial.tokens.json +1 -1
  147. package/dist/cdn/themes/genai.css +1 -1
  148. package/dist/cdn/themes/genai.tokens.json +1 -1
  149. package/dist/cdn/themes/glassmorphism-dark.tokens.json +1 -1
  150. package/dist/cdn/themes/glassmorphism.tokens.json +1 -1
  151. package/dist/cdn/themes/government-dark.tokens.json +1 -1
  152. package/dist/cdn/themes/government.tokens.json +1 -1
  153. package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
  154. package/dist/cdn/themes/gruvbox.tokens.json +1 -1
  155. package/dist/cdn/themes/high-noon-dark.tokens.json +23 -1
  156. package/dist/cdn/themes/high-noon.css +1 -1
  157. package/dist/cdn/themes/high-noon.tokens.json +1 -1
  158. package/dist/cdn/themes/journal-dark.tokens.json +33 -1
  159. package/dist/cdn/themes/journal.css +1 -1
  160. package/dist/cdn/themes/journal.tokens.json +23 -1
  161. package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
  162. package/dist/cdn/themes/kawaii.css +1 -1
  163. package/dist/cdn/themes/kawaii.tokens.json +1 -1
  164. package/dist/cdn/themes/magna-dark.tokens.json +1 -1
  165. package/dist/cdn/themes/magna.tokens.json +1 -1
  166. package/dist/cdn/themes/manifest.json +26 -50
  167. package/dist/cdn/themes/midnight.tokens.json +1 -1
  168. package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
  169. package/dist/cdn/themes/minimal.tokens.json +1 -1
  170. package/dist/cdn/themes/modern-dark.tokens.json +1 -1
  171. package/dist/cdn/themes/modern.tokens.json +1 -1
  172. package/dist/cdn/themes/nes-dark.tokens.json +1 -1
  173. package/dist/cdn/themes/nes.css +1 -1
  174. package/dist/cdn/themes/nes.tokens.json +1 -1
  175. package/dist/cdn/themes/neumorphism-dark.tokens.json +1 -1
  176. package/dist/cdn/themes/neumorphism.css +1 -1
  177. package/dist/cdn/themes/neumorphism.tokens.json +1 -1
  178. package/dist/cdn/themes/nord-dark.tokens.json +33 -1
  179. package/dist/cdn/themes/nord.css +1 -1
  180. package/dist/cdn/themes/nord.tokens.json +23 -1
  181. package/dist/cdn/themes/organic-dark.tokens.json +1 -1
  182. package/dist/cdn/themes/organic.css +1 -1
  183. package/dist/cdn/themes/organic.tokens.json +1 -1
  184. package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
  185. package/dist/cdn/themes/rose-pine.tokens.json +1 -1
  186. package/dist/cdn/themes/rough-dark.tokens.json +1 -1
  187. package/dist/cdn/themes/rough.css +1 -1
  188. package/dist/cdn/themes/rough.tokens.json +1 -1
  189. package/dist/cdn/themes/solarized-dark.tokens.json +23 -1
  190. package/dist/cdn/themes/solarized.css +1 -1
  191. package/dist/cdn/themes/solarized.tokens.json +23 -1
  192. package/dist/cdn/themes/startup-dark.tokens.json +1 -1
  193. package/dist/cdn/themes/startup.tokens.json +1 -1
  194. package/dist/cdn/themes/super2026-dark.tokens.json +33 -1
  195. package/dist/cdn/themes/super2026.css +1 -1
  196. package/dist/cdn/themes/super2026.tokens.json +23 -1
  197. package/dist/cdn/themes/swiss-dark.tokens.json +1 -1
  198. package/dist/cdn/themes/swiss.css +1 -1
  199. package/dist/cdn/themes/swiss.tokens.json +1 -1
  200. package/dist/cdn/themes/terminal.css +1 -1
  201. package/dist/cdn/themes/terminal.tokens.json +1 -1
  202. package/dist/cdn/themes/tokyo-night-dark.tokens.json +33 -1
  203. package/dist/cdn/themes/tokyo-night.css +1 -1
  204. package/dist/cdn/themes/tokyo-night.tokens.json +23 -1
  205. package/dist/cdn/themes/vaporwave-dark.tokens.json +33 -1
  206. package/dist/cdn/themes/vaporwave.css +1 -1
  207. package/dist/cdn/themes/vaporwave.tokens.json +23 -1
  208. package/dist/cdn/themes/win9x-dark.tokens.json +15 -4
  209. package/dist/cdn/themes/win9x.css +1 -1
  210. package/dist/cdn/themes/win9x.tokens.json +1 -1
  211. package/dist/cdn/vanilla-breeze-autoload.js +663 -0
  212. package/dist/cdn/vanilla-breeze-charts.css +1 -1
  213. package/dist/cdn/vanilla-breeze-charts.js +32 -32
  214. package/dist/cdn/vanilla-breeze-core.css +1 -1
  215. package/dist/cdn/vanilla-breeze-core.js +78 -80
  216. package/dist/cdn/vanilla-breeze-dev.css +1 -1
  217. package/dist/cdn/vanilla-breeze-extras.js +47 -37
  218. package/dist/cdn/vanilla-breeze.css +1 -1
  219. package/dist/cdn/vanilla-breeze.js +180 -177
  220. package/package.json +3 -3
  221. package/dist/cdn/themes/amber.css +0 -2
  222. package/dist/cdn/themes/anthropic.css +0 -2
  223. package/dist/cdn/themes/anthropic.tokens.json +0 -564
  224. package/dist/cdn/themes/coral.css +0 -2
  225. package/dist/cdn/themes/emerald.css +0 -2
  226. package/dist/cdn/themes/forest.css +0 -2
  227. package/dist/cdn/themes/ibm.css +0 -2
  228. package/dist/cdn/themes/ibm.tokens.json +0 -568
  229. package/dist/cdn/themes/indigo.css +0 -2
  230. package/dist/cdn/themes/lavender.css +0 -2
  231. package/dist/cdn/themes/mcdonalds.css +0 -2
  232. package/dist/cdn/themes/mcdonalds.tokens.json +0 -533
  233. package/dist/cdn/themes/ocean.css +0 -2
  234. package/dist/cdn/themes/rose.css +0 -2
  235. package/dist/cdn/themes/slate.css +0 -2
  236. package/dist/cdn/themes/starbucks.css +0 -2
  237. package/dist/cdn/themes/starbucks.tokens.json +0 -593
  238. package/dist/cdn/themes/sunset.css +0 -2
@@ -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))}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.teardown(),this.removeAttribute("data-upgraded"),this.setup(),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)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(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};
2
2
  //# sourceMappingURL=accordion-wc.js.map
@@ -1,2 +1,2 @@
1
- var A=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function p(r,t,i={}){let e=i.priority??10,a={impl:t,bundle:i.bundle,contract:i.contract,priority:e},n=m.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}m.set(r,a),customElements.define(r,t)}var d=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,a){t.addEventListener(i,e,a),this.#e.push(()=>t.removeEventListener(i,e,a))}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 a=`--${t}`;i?e.add(a):e.delete(a)}}_adoptInternals(t){this.#t||(this.#t=t)}};function l(r){let t=(Date.now()-r.getTime())/1e3;if(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 b(r=document){for(let t of r.querySelectorAll("time[data-relative]")){let i=t.getAttribute("datetime");if(!i)continue;let e=l(new Date(i));e&&(t.textContent=e)}}var u=typeof document<"u"?document.documentElement:null,v;function y(){b(),v||(v=setInterval(()=>b(),6e4))}u&&!u.hasAttribute("data-vb-time-relative-init")&&(u.setAttribute("data-vb-time-relative-init",""),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y,{once:!0}):y());function h(r){let t=new Date(r);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function g(r){let t=new Date(r),i=(t.getDay()+6)%7,e=new Date(t);e.setDate(t.getDate()-i);let a=new Date(e);a.setDate(e.getDate()+3);let n=new Date(a.getFullYear(),0,1),s=Math.ceil(((a.getTime()-n.getTime())/864e5+1)/7);return`${a.getFullYear()}-W${String(s).padStart(2,"0")}`}function E(r){let t=h(new Date),i=h(new Date(Date.now()-864e5));if(r===t)return"Today";if(r===i)return"Yesterday";let[e,a,n]=r.split("-").map(Number);return new Date(e,a-1,n).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}function w(r){return`Week of ${r.replace("-W",", week ")}`}var f=class extends d{#e=null;#t=null;#a=null;#r=null;#i=null;setup(){return this.hasAttribute("role")||this.setAttribute("role","feed"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Recent activity"),this.setAttribute("aria-busy","false"),this.#n().forEach(t=>this.#s(t)),this.#o(),this.#c(),this.#e=new MutationObserver(t=>{let i=!1;for(let e of t){for(let a of e.addedNodes){let n=a;a.nodeType===1&&n.matches?.("article[data-activity]")&&(this.#s(n),i=!0)}e.removedNodes.length&&(i=!0)}i&&(this.#o(),this.#c())}),this.#e.observe(this,{childList:!0}),this.#r=setInterval(()=>this.#d(),6e4),this.hasAttribute("data-infinite")&&this.#h(),this.listen(this,"keydown",this.#u),!0}teardown(){this.#r!==null&&clearInterval(this.#r),this.#e?.disconnect(),this.#a?.disconnect()}#n(){return[...this.querySelectorAll(":scope > article[data-activity]")]}#s(t){if(t.dataset.decorated==="")return;t.dataset.decorated="",t.setAttribute("tabindex","-1");let i=document.createElement("div");for(i.className="activity-body";t.firstChild;)i.appendChild(t.firstChild);t.appendChild(i);let e=t.dataset.activityAvatar,a=t.dataset.activityIcon;if(e||a){let s=document.createElement("div");if(s.className="activity-rail",s.setAttribute("aria-hidden","true"),e){let o=document.createElement("user-avatar");o.setAttribute("src",e);let c=i.querySelector("[data-activity-actor]")?.textContent||"";c&&o.setAttribute("name",c),s.appendChild(o)}else{let o=document.createElement("icon-wc");o.setAttribute("name",a),s.appendChild(o)}t.prepend(s)}let n=t.dataset.time;if(n){let s=document.createElement("time");s.className="activity-time",s.setAttribute("datetime",n),s.setAttribute("title",this.#l(n)),s.textContent=l(new Date(n))||n,t.appendChild(s)}}#d(){for(let t of this.querySelectorAll(":scope > article[data-activity] > time.activity-time")){let i=t.getAttribute("datetime");if(!i)continue;let e=l(new Date(i));e&&(t.textContent=e)}}#l(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=t.length,e=this.getAttribute("data-group")||"none",a=null;t.forEach((n,s)=>{if(n.setAttribute("aria-posinset",String(s+1)),n.setAttribute("aria-setsize",String(i)),e!=="none"&&n.dataset.time){let o=e==="week"?g(n.dataset.time):h(n.dataset.time);if(o!==a){let c=document.createElement("h3");c.setAttribute("data-activity-heading",""),c.setAttribute("role","heading"),c.setAttribute("aria-level","3"),c.className="activity-heading",c.textContent=e==="week"?w(o):E(o),this.insertBefore(c,n),a=o}}})}#c(){this.#n().length===0?this.#i||(this.#i=document.createElement("p"),this.#i.className="activity-empty",this.#i.textContent=this.getAttribute("data-empty-text")||"No recent activity",this.appendChild(this.#i)):(this.#i?.remove(),this.#i=null)}#u=t=>{let i=this.#n(),e=document.activeElement,a=e?i.indexOf(e):-1;if(a===-1)return;let n=a;switch(t.key){case"ArrowDown":t.preventDefault(),n=Math.min(i.length-1,a+1);break;case"ArrowUp":t.preventDefault(),n=Math.max(0,a-1);break;case"PageDown":t.preventDefault(),n=Math.min(i.length-1,a+5);break;case"PageUp":t.preventDefault(),n=Math.max(0,a-5);break;case"Home":t.preventDefault(),n=0;break;case"End":t.preventDefault(),n=i.length-1;break;default:return}i[n]?.focus()};#h(){"IntersectionObserver"in window&&(this.#t=document.createElement("div"),this.#t.className="activity-sentinel",this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t),this.#a=new IntersectionObserver(t=>{for(let i of t)i.isIntersecting&&this.dispatchEvent(new CustomEvent("activity-feed:load-more",{bubbles:!0}))},{rootMargin:"200px"}),this.#a.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 a=this.#n()[0];a?this.insertBefore(e,a):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()}};p("activity-feed",f);export{f as ActivityFeed};
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};
2
2
  //# sourceMappingURL=activity-feed.js.map
@@ -1,9 +1,9 @@
1
- var N=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function y(o,t,e={}){let n=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:n},a=m.get(o);if(customElements.get(o)){if(!a||a.priority>=n){a&&a.priority===n&&a.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${a.bundle}" (priority ${a.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${a.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(a&&a.priority>=n){a.priority===n&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${a.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}m.set(o,i),customElements.define(o,t)}var u=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,n,i){t.addEventListener(e,n,i),this.#e.push(()=>t.removeEventListener(e,n,i))}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{e?n.add(t):n.delete(t)}catch{let i=`--${t}`;e?n.add(i):n.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}};async function v(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 n=await e.availability();return n==="available"||n==="downloadable"||n==="downloading"||n==="unavailable"?{state:n}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}var C="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function w(o,{stripSelectors:t=C}={}){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 n=e.cloneNode(!0);return t&&typeof n.querySelectorAll=="function"&&n.querySelectorAll(t).forEach(i=>i.remove()),(n.textContent||"").trim().replace(/\s+/g," ")}var k=/\{(prompt|url|title|content)\}/g;function g(o,t={}){if(!o)return"";let e={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:t.content??""};return String(o).replace(k,(n,i)=>encodeURIComponent(e[i]))}async function*x(o,{prompt:t="",content:e,mode:n,signal:i}={}){let a={prompt:t};e!==void 0&&(a.content=e),n!==void 0&&(a.mode=n);let r=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:i});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 s=await r.json(),c=typeof s?.text=="string"?s.text:"";c&&(yield c);return}if(!r.body||typeof r.body.getReader!="function"){let s=await r.text();s&&(yield s);return}let l=r.body.getReader(),f=new TextDecoder;try{for(;;){let{value:c,done:S}=await l.read();if(S)break;if(c){let b=f.decode(c,{stream:!0});b&&(yield b)}}let s=f.decode();s&&(yield s)}finally{try{l.releaseLock()}catch{}}}function E(o){return o?Math.ceil(String(o).length/4):0}var T="Help me explore this article: {title} ({url})",$={user:{name:"You",role:"user"},assistant:{name:"Assistant",role:"agent"}},h={local:"Gemini Nano (on-device)",endpoint:"Server endpoint","deep-link":"Open in external tool"},p=class extends u{#e=null;#t=null;#o=null;#s=null;#l=null;#i=null;#a=null;#c="unsupported";#n="unavailable";static get observedAttributes(){return["placeholder"]}setup(){this.#w(),this.#g(),this.#x(),this.#b(),this.#C()}teardown(){this.#a?.abort(),this.#i?.destroy?.(),this.#i=null}attributeChangedCallback(t,e,n){if(t==="placeholder"){let i=this.querySelector("chat-input textarea");i&&(i.placeholder=n??"")}}async reset(){this.#a?.abort(),this.#i?.destroy?.(),this.#i=null,this.#e?.clearThread?.(),this.#b(),this.#r("ready")}#w(){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 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=`
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>
5
5
  <chat-window empty-message="Send a message to start a session.">
6
- <script type="application/json" data-participants>${JSON.stringify($)}<\/script>
6
+ <script type="application/json" data-participants>${JSON.stringify(O)}<\/script>
7
7
  <header>
8
8
  <select class="ai-chat-provider small" data-model-select aria-label="AI provider"></select>
9
9
  </header>
@@ -14,15 +14,18 @@ var N=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;functi
14
14
  <button type="submit" class="small" data-send aria-label="Send">
15
15
  <icon-wc name="send"></icon-wc>
16
16
  </button>
17
+ <button type="button" class="small" data-stop aria-label="Stop generating" hidden>
18
+ <icon-wc name="square"></icon-wc>
19
+ </button>
17
20
  </footer>
18
21
  </chat-input>
19
22
  </chat-window>
20
- `,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.#s=this.querySelector(":scope > .ai-chat-notice"),this.#l=this.querySelector(":scope > .ai-chat-starters");let n=this.querySelector("chat-input textarea");n&&(n.placeholder=t)}#g(){if(!this.#l)return;let t=this.querySelector(':scope > template[data-role="starters"]'),e=(t&&t.content?.textContent||"").split(`
21
- `).map(n=>n.trim()).filter(Boolean);if(this.#l.replaceChildren(),!e.length){this.#l.hidden=!0;return}this.#l.hidden=!1;for(let n of e){let i=document.createElement("button");i.type="button",i.className="ai-chat-starter small",i.textContent=n,this.listen(i,"click",()=>this.#E(n)),this.#l.appendChild(i)}}#x(){this.#e&&(this.listen(this.#e,"chat-window:send",t=>{t.stopPropagation(),this.#T(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.#i?.destroy?.(),this.#i=null,this.#m())}),this.listen(this,"keydown",t=>{t.key==="Escape"&&this.#a&&(t.preventDefault(),this.#a.abort())}))}#E(t){let e=this.querySelector("chat-input");if(!e)return;e.value=t;let n=e.querySelector("textarea");n&&n.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))}#f(){return this.getAttribute("context")?.trim()||""}#u(){let t=this.#f();return t?w(t,{stripSelectors:"ai-chat, ai-summary, .ais-ui"}):""}#b(){if(!this.#o)return;let t=this.#f();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 n=e.length,i=E(e),a=n>6e3,r=this.getAttribute("context-label")||t;this.#o.hidden=!1,this.#o.replaceChildren();let d=document.createElement("span");if(d.className="ai-chat-ribbon-lead",d.textContent=`Page context: ${r} \xB7 ${n.toLocaleString()} chars (~${i.toLocaleString()} tokens)`,this.#o.appendChild(d),a){let l=document.createElement("span");l.className="ai-chat-ribbon-warn",l.textContent="large \u2014 may crowd the conversation",this.#o.appendChild(l)}this.setAttribute("data-context-state",a?"large":"ok")}#S(){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 i=`
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=`
22
25
 
23
26
  [PAGE CONTENT \u2014 ${this.getAttribute("context-label")||"page"}]
24
27
  ${e}
25
- [END PAGE CONTENT]`;return t?t+i:`Use the following page content to answer the user.${i}`}async#C(){this.#r("checking");let{state:t}=await v("LanguageModel");this.#c=t;let e=[];t==="available"||t==="downloadable"||t==="downloading"?e.push({value:"local",label:h.local}):e.push({value:"local",label:`${h.local} \u2014 unavailable`,disabled:!0}),this.getAttribute("endpoint")&&e.push({value:"endpoint",label:h.endpoint}),this.getAttribute("fallback-url")&&e.push({value:"deep-link",label:this.getAttribute("fallback-label")||h["deep-link"]}),this.#k(e);let n=e.find(i=>!i.disabled);this.#n=n?.value??"unavailable",this.#t&&n&&(this.#t.value=n.value),this.#e&&(this.#e.model=this.#n),this.#m(),this.#r(this.#n==="unavailable"?"unavailable":"ready")}#k(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 n=document.createElement("option");n.value=e.value,n.textContent=e.label,e.disabled&&(n.disabled=!0),this.#t.appendChild(n)}this.#t.disabled=t.every(e=>e.disabled)}}#m(){this.#n==="unavailable"?this.#d("On-device AI unavailable and no fallback configured. Set endpoint= or fallback-url= to enable a fallback."):this.#n==="deep-link"?this.#d("Send opens the external tool in a new tab. Choose another provider above to chat in-page."):this.#c==="downloadable"&&this.#n==="local"?this.#d("First message will download the on-device model (~1.6 GB)."):this.#p()}async#A(){if(this.#i)return this.#i;let t=this.#S(),e=t?[{role:"system",content:t}]:void 0;return this.#i=await LanguageModel.create({initialPrompts:e,expectedInputs:[{type:"text",languages:["en"]}],expectedOutputs:[{type:"text",languages:["en"]}],monitor:n=>{n.addEventListener("downloadprogress",i=>{if(i.loaded>=1){this.#c="available",this.#p();return}this.#r("downloading"),this.#d(`Downloading on-device model: ${Math.round(i.loaded*100)}%`)})}}),this.#c="available",this.#p(),this.#i.addEventListener?.("contextoverflow",()=>{this.dispatchEvent(new CustomEvent("ai-chat:context-overflow",{bubbles:!0}))}),this.#i}async#T(t,e){if(this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"user",text:t},bubbles:!0})),this.#n==="deep-link"){e.remove(),window.open(this.#N(t),"_blank","noopener,noreferrer");return}if(this.#n==="unavailable"){this.#y(e,"Chat is unavailable in this browser.",{error:!0});return}this.#r("streaming"),this.#a=new AbortController;let n=e.querySelector("chat-bubble");if(!n)return;let i="";try{let a=this.#n==="local"?await this.#$(t):x(this.getAttribute("endpoint")||"",{prompt:t,content:this.#u()||void 0,mode:"chat",signal:this.#a.signal});for await(let r of a)i+=r,n.textContent=i,this.#v();this.#h(e,i||" "),this.#v(),this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"assistant",text:i},bubbles:!0})),this.#r("ready")}catch(a){let r=a;if(r?.name==="AbortError"){this.#h(e,i?`${i} (stopped)`:"(stopped)"),this.#r("ready");return}this.#y(e,r?.message||"Generation failed",{error:!0}),this.#r("error"),this.dispatchEvent(new CustomEvent("ai-chat:error",{detail:{error:a},bubbles:!0}))}finally{this.#a=null}}async#$(t){let e=await this.#A(),n=this.#a?.signal,i=e.promptStreaming(t,{signal:n});return(async function*(){for await(let a of i)yield a})()}#h(t,e){let n=t.querySelector("chat-bubble");n&&(n.textContent=e),t.removeAttribute("data-status"),t.removeAttribute("aria-label")}#y(t,e,n={}){this.#h(t,e),n.error&&t.setAttribute("data-status","error")}#v(){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}))}#d(t){this.#s&&(this.#s.hidden=!1,this.#s.textContent=t)}#p(){this.#s&&(this.#s.hidden=!0,this.#s.textContent="")}#N(t){let n=(this.getAttribute("fallback-prompt")||T).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title),i=t?`${n}
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}
26
29
 
27
- User: ${t}`:n;return g(this.getAttribute("fallback-url"),{prompt:i})}};y("ai-chat",p);export{p as AIChat};
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};
28
31
  //# sourceMappingURL=ai-chat.js.map
@@ -1,10 +1,12 @@
1
- var L=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function m(i,t,e={}){let n=e.priority??10,a={impl:t,bundle:e.bundle,contract:e.contract,priority:n},r=p.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}p.set(i,a),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,a){t.addEventListener(e,n,a),this.#t.push(()=>t.removeEventListener(e,n,a))}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 a=`--${t}`;e?n.add(a):n.delete(a)}}_adoptInternals(t){this.#e||(this.#e=t)}};var k=["available","downloadable","downloading"];async function b(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 y({availability:i,endpoint:t,fallbackURL:e}){return k.includes(i)?"local":t?"endpoint":e?"deep-link":"unavailable"}var x="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function g(i,{stripSelectors:t=x}={}){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(a=>a.remove()),(n.textContent||"").trim().replace(/\s+/g," ")}var C=/\{(prompt|url|title|content)\}/g;function v(i,t={}){if(!i)return"";let e={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:t.content??""};return String(i).replace(C,(n,a)=>encodeURIComponent(e[a]))}async function*w(i,{prompt:t="",content:e,mode:n,signal:a}={}){let r={prompt:t};e!==void 0&&(r.content=e),n!==void 0&&(r.mode=n);let o=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:a});if(!o.ok)throw new Error(`AI endpoint ${i} returned ${o.status} ${o.statusText}`);if((o.headers.get("content-type")||"").toLowerCase().includes("application/json")){let s=await o.json(),l=typeof s?.text=="string"?s.text:"";l&&(yield l);return}if(!o.body||typeof o.body.getReader!="function"){let s=await o.text();s&&(yield s);return}let u=o.body.getReader(),h=new TextDecoder;try{for(;;){let{value:l,done:E}=await u.read();if(E)break;if(l){let f=h.decode(l,{stream:!0});f&&(yield f)}}let s=h.decode();s&&(yield s)}finally{try{u.releaseLock()}catch{}}}var A="Summarize this article: {url}",c=class extends d{#t=null;#e=null;#n=null;#a=null;#r="unavailable";setup(){this.#l(),this.#d()}teardown(){this.#a?.abort(),this.#a=null}#l(){let t=document.createElement("div");t.className="ais-ui",t.innerHTML=`
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=`
2
2
  <div class="ais-controls">
3
3
  <button type="button" class="ais-trigger small" disabled>
4
4
  <span class="ais-label">Summarize</span>
5
5
  </button>
6
+ <button type="button" class="ais-stop small" hidden>Stop</button>
6
7
  <span class="ais-status" data-state="checking" role="status">Checking availability\u2026</span>
7
8
  </div>
9
+ <p class="ais-notice" role="status" hidden></p>
8
10
  <div class="ais-output" hidden aria-live="polite"></div>
9
- `,this.prepend(t),this.#t=t.querySelector(".ais-trigger"),this.#e=t.querySelector(".ais-status"),this.#n=t.querySelector(".ais-output"),this.listen(this.#t,"click",()=>this.#u())}async#d(){this.#i("checking");let{state:t}=await b("Summarizer");this.#r=y({availability:t,endpoint:this.getAttribute("endpoint")||void 0,fallbackURL:this.getAttribute("fallback-url")||void 0}),this.#c(t)}#c(t){if(!(!this.#t||!this.#e)){if(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.#b(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#u(){if(!(!this.#t||!this.#n)){if(this.#r==="deep-link"){window.open(this.#s(),"_blank","noopener,noreferrer");return}if(this.#r!=="unavailable"){this.#n.hidden=!1,this.#n.textContent="",this.#t.disabled=!0,this.#i("streaming"),this.#a=new AbortController;try{let t=this.#f(),e="",n=this.#r==="local"?await this.#h(t):w(this.getAttribute("endpoint")||"",{prompt:this.#o(),content:t,mode:"summarize",signal:this.#a.signal});for await(let a of n)e+=a,this.#n.textContent=e;this.#p(e),this.#i("complete"),this.dispatchEvent(new CustomEvent("ai-summary:result",{detail:{text:e,provider:this.#r},bubbles:!0}))}catch(t){if(t&&t.name==="AbortError"){this.#i("ready");return}this.#m(t),this.#i("error"),this.dispatchEvent(new CustomEvent("ai-summary:error",{detail:{error:t},bubbles:!0}))}finally{this.#a=null,this.#t.disabled=!1}}}}async#h(t){let e=await Summarizer.create({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:r=>{r.addEventListener("downloadprogress",o=>{this.#i("downloading"),this.#e&&(this.#e.textContent=`Downloading model: ${Math.round(o.loaded*100)}%`)})}}),n=this.#a?.signal,a=typeof e.summarizeStreaming=="function"?e.summarizeStreaming(t,{signal:n}):(async function*(){yield await e.summarize(t,{signal:n})})();return(async function*(){try{for await(let r of a)yield r}finally{e.destroy?.()}})()}#f(){return g(this,{stripSelectors:".ais-ui"})}#o(){return(this.getAttribute("fallback-prompt")||A).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title)}#s(){return v(this.getAttribute("fallback-url"),{prompt:this.#o()})}#p(t){if(!this.#n)return;if(!t){this.#n.textContent="";return}let e=document.createElement("markdown-viewer"),n=document.createElement("pre");n.textContent=t,e.appendChild(n),this.#n.replaceChildren(e)}#m(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 a=document.createElement("p");a.className="ais-fallback";let r=document.createElement("a");r.href=this.#s(),r.target="_blank",r.rel="noopener noreferrer",r.textContent=this.getAttribute("fallback-label")||"Continue elsewhere",a.append("You can ",r," instead."),this.#n.appendChild(a)}}#i(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-summary:state",{detail:{state:t,provider:this.#r},bubbles:!0}))}#b(t){let e=this.#t?.querySelector(".ais-label");e&&(e.textContent=t)}};m("ai-summary",c);export{c as AISummary};
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};
10
12
  //# sourceMappingURL=ai-summary.js.map
@@ -1,34 +1,32 @@
1
- var y=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function h(n,t,e={}){let s=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:s},a=u.get(n);if(customElements.get(n)){if(!a||a.priority>=s){a&&a.priority===s&&a.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${a.bundle}" (priority ${a.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${a.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(a&&a.priority>=s){a.priority===s&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${a.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}u.set(n,o),customElements.define(n,t)}var l=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,s,o){t.addEventListener(e,s,o),this.#e.push(()=>t.removeEventListener(e,s,o))}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{e?s.add(t):s.delete(t)}catch{let o=`--${t}`;e?s.add(o):s.delete(o)}}_adoptInternals(t){this.#t||(this.#t=t)}};var i={optout:"vb_optout",sessionCount:"vb_sc",eventQueue:"vb_q"};function p(n){return String(n).replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function f(n){return typeof n!="number"||n<=0?"\u2014":n<6e4?`${Math.round(n/1e3)}s`:`${Math.floor(n/6e4)}m ${Math.round(n%6e4/1e3)}s`}var d=class extends l{setup(){this.#s(),this.listen(this,"click",this.#e)}get isOptedOut(){try{return sessionStorage.getItem(i.optout)==="1"}catch{return!1}}get sessionCounter(){try{let t=sessionStorage.getItem(i.sessionCount);return t?JSON.parse(t):null}catch{return null}}get queuedEvents(){try{let t=sessionStorage.getItem(i.eventQueue);return t?JSON.parse(t):[]}catch{return[]}}get hasSessionData(){return this.sessionCounter!=null||this.queuedEvents.length>0}#e=t=>{let e=t.target?.closest?.("[data-analytics-action]");if(!e||!this.contains(e))return;let s=e.dataset.analyticsAction;s==="clear"&&this.#t(),s==="optout"&&this.#n(),s==="refresh"&&this.#s()};#t(){try{sessionStorage.removeItem(i.sessionCount),sessionStorage.removeItem(i.eventQueue)}catch{}this.dispatchEvent(new CustomEvent("analytics-panel:cleared",{bubbles:!0,composed:!0})),this.#s()}#n(){let t=!this.isOptedOut;try{t?sessionStorage.setItem(i.optout,"1"):sessionStorage.removeItem(i.optout)}catch{}this.dispatchEvent(new CustomEvent(t?"analytics-panel:optout":"analytics-panel:optin",{bubbles:!0,composed:!0})),t?this.#t():this.#s()}#s(){let t=this.getAttribute("title")||"Analytics data",e=this.isOptedOut,s=this.hasSessionData;this.innerHTML=`
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=`
2
2
  <header class="analytics-panel__header">
3
- <h3>${p(t)}</h3>
3
+ <h2 data-part="heading"></h2>
4
4
  <p class="analytics-panel__status" role="status">
5
- <span class="analytics-panel__dot analytics-panel__dot--${e?"paused":"active"}" aria-hidden="true"></span>
6
- ${e?"Analytics paused for this tab. No data is being collected.":"Analytics active. Only aggregate, device-scoped data is collected."}
5
+ <span class="analytics-panel__dot" aria-hidden="true"></span>
6
+ <span data-part="status"></span>
7
7
  </p>
8
8
  </header>
9
9
 
10
- <section class="analytics-panel__body">
11
- <h4>Stored on this device (this session only)</h4>
12
- ${this.#a()}
10
+ <section class="analytics-panel__body" aria-labelledby="${t}-fields">
11
+ <h3 id="${t}-fields" data-part="fields-heading">What an event from this page contains</h3>
12
+ <dl class="analytics-panel__data" data-part="data"></dl>
13
+ <p class="analytics-panel__empty" data-part="empty" hidden></p>
13
14
  </section>
14
15
 
15
16
  <footer class="analytics-panel__actions">
16
- ${s?`
17
- <button type="button" data-analytics-action="clear" class="analytics-panel__action analytics-panel__action--danger">
18
- Clear my data
19
- </button>
20
- `:""}
21
- <button type="button" data-analytics-action="optout" class="analytics-panel__action analytics-panel__action--toggle">
22
- ${e?"Resume analytics":"Pause analytics"}
23
- </button>
24
- <button type="button" data-analytics-action="refresh" class="analytics-panel__action">
25
- Refresh
26
- </button>
17
+ <button type="button" data-analytics-action="toggle" data-part="toggle"
18
+ class="analytics-panel__action analytics-panel__action--toggle"></button>
19
+ <button type="button" data-analytics-action="refresh" class="analytics-panel__action">Refresh</button>
20
+ <p class="analytics-panel__hint" id="${t}-hint" data-part="hint" hidden></p>
27
21
  </footer>
28
22
 
29
23
  <p class="analytics-panel__note">
30
- No cookies, no cross-site identifiers, no IP address stored.
31
- Data is cleared automatically when you close this tab.
24
+ No cookies and no visitor ID. The only thing stored on this device is
25
+ the pause setting, kept in this tab&rsquo;s session storage until you
26
+ close it. Events already sent are stored on the server without an
27
+ identifier, so they cannot be looked up or deleted from here. The
28
+ server records your country from the request; your IP address is not
29
+ stored.
32
30
  </p>
33
- `}#a(){if(!this.hasSessionData)return'<p class="analytics-panel__empty">No data stored on this device in this session.</p>';let t=this.sessionCounter,e=this.queuedEvents,s=e.find(c=>c?.id==="__scroll"),o=e.find(c=>c?.id==="__attention"),a=e.filter(c=>!c?.id?.startsWith?.("__")).length,r=[];return t?.v!=null&&r.push(`<dt>Pages this session</dt><dd>${t.v}</dd>`),s&&r.push(`<dt>Max scroll depth</dt><dd>${s.params?.depth??"?"}%</dd>`),o&&r.push(`<dt>Active reading time</dt><dd>${f(o.params?.ms)}</dd>`),a>0&&r.push(`<dt>Queued events</dt><dd>${a}</dd>`),`<dl class="analytics-panel__data">${r.join("")}</dl>`}};h("analytics-panel",d);
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};
34
32
  //# sourceMappingURL=analytics-panel.js.map
@@ -1,7 +1,7 @@
1
- var c=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function d(s,t,e={}){let r=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:r},a=u.get(s);if(customElements.get(s)){if(!a||a.priority>=r){a&&a.priority===r&&a.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${a.bundle}" (priority ${a.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> 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 <${s}> already registered by "${a.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}u.set(s,i),customElements.define(s,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,i){t.addEventListener(e,r,i),this.#t.push(()=>t.removeEventListener(e,r,i))}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 l=class extends o{#t=null;#e=null;#a=!1;#v=null;#s=null;#i=null;#u=null;#r=null;#d=null;#c=null;#n=null;#h=null;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;return this.#f(),t&&(this.#y(),this.#g(),this.#x()),this.#p(),this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{}),this.#h=()=>{let e=this.shadowRoot?.querySelector(".player");e&&(e.style.display="none",e.offsetHeight,e.style.display="")},this.listen(window,"vb:theme-change",this.#h),!0}teardown(){this.#t&&this.#t.setAttribute("controls","")}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.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)}#f(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
2
- <style>${this.#b()}</style>
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>
3
3
  <div part="player" class="player">
4
- <div part="controls" class="controls" role="group" aria-label="Audio controls">
4
+ <div part="controls" class="controls">
5
5
  <button part="play-button" class="play-btn" type="button" aria-label="Play">
6
6
  <svg class="icon-play" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" width="20" height="20">
7
7
  <path d="M8 5v14l11-7z"/>
@@ -22,12 +22,12 @@ var c=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
22
22
  <div class="timeline-wrap">
23
23
  <input part="timeline" type="range" class="timeline"
24
24
  min="0" max="100" value="0" step="0.1"
25
- aria-label="Seek">
25
+ aria-label="Seek" aria-valuetext="0:00 of 0:00">
26
26
  <div class="timeline-fill"></div>
27
27
  </div>
28
28
  </div>
29
29
  <div class="volume-wrap">
30
- <button class="mute-btn" type="button" aria-label="Mute">
30
+ <button class="mute-btn" type="button" aria-label="Mute" aria-pressed="false">
31
31
  <svg class="icon-vol" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" width="16" height="16">
32
32
  <path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/>
33
33
  </svg>
@@ -40,9 +40,10 @@ var c=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
40
40
  aria-label="Volume">
41
41
  </div>
42
42
  </div>
43
+ <p part="error" class="error" role="status" hidden></p>
43
44
  <slot></slot>
44
45
  </div>
45
- `,this.#v=t.querySelector(".controls"),this.#s=t.querySelector(".play-btn"),this.#i=t.querySelector(".timeline"),this.#u=t.querySelector(".timeline-fill"),this.#r=t.querySelector(".volume"),this.#d=t.querySelector(".current-time"),this.#c=t.querySelector(".duration"),this.#n=t.querySelector(".track-title")}#b(){return`
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
47
  :host {
47
48
  display: block;
48
49
  --_accent: var(--audio-player-accent, var(--color-primary, oklch(55% 0.2 260)));
@@ -315,6 +316,15 @@ var c=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
315
316
  border-radius: var(--radius-s, 2px);
316
317
  }
317
318
 
319
+ /* \u2500\u2500 Load error message \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
320
+ .error {
321
+ margin: 0;
322
+ padding: var(--size-2xs, 4px) var(--size-s, 0.75rem) var(--size-xs, 0.5rem);
323
+ font-size: var(--font-size-xs, 0.75rem);
324
+ color: var(--color-error-text, var(--color-error, #b00020));
325
+ }
326
+ .error[hidden] { display: none; }
327
+
318
328
  /* \u2500\u2500 Slot: hide native audio controls \u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
319
329
  ::slotted(audio) {
320
330
  display: none !important;
@@ -336,5 +346,5 @@ var c=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;functi
336
346
  transform: none;
337
347
  }
338
348
  }
339
- `}#y(){this.#t.addEventListener("timeupdate",()=>this.#k()),this.#t.addEventListener("loadedmetadata",()=>this.#E()),this.#t.addEventListener("play",()=>{this.#a=!0,this.setAttribute("state","playing"),this.#s.setAttribute("aria-label","Pause"),this.#l("audio-player:play",{currentTime:this.#t.currentTime,src:this.#t.currentSrc})}),this.#t.addEventListener("pause",()=>{this.#a=!1,this.setAttribute("state","paused"),this.#s.setAttribute("aria-label","Play"),this.#l("audio-player:pause",{currentTime:this.#t.currentTime})}),this.#t.addEventListener("ended",()=>{this.#a=!1,this.setAttribute("state","ended"),this.#s.setAttribute("aria-label","Play");let t=this.#e?.querySelector("li[data-audio-active]");t&&t.setAttribute("data-audio-played",""),this.#e&&this.#w(),this.#l("audio-player:ended",{src:this.#t.currentSrc})})}#g(){this.#s.addEventListener("click",()=>{this.#a?this.#t.pause():this.#t.play().catch(()=>{})}),this.#i.addEventListener("input",()=>{this.#t.duration&&(this.#t.currentTime=Number(this.#i.value)/100*this.#t.duration)}),this.#i.addEventListener("pointerdown",()=>this.setState("scrub-active",!0));let t=()=>this.setState("scrub-active",!1);this.#i.addEventListener("pointerup",t),this.#i.addEventListener("pointercancel",t),this.#r.addEventListener("input",()=>{this.#t.volume=Number(this.#r.value),this.#t.muted=!1,this.removeAttribute("muted"),this.#r.style.setProperty("--_vol",this.#r.value)});let e=this.shadowRoot?.querySelector(".mute-btn");e&&(e.addEventListener("click",()=>{this.#t.muted=!this.#t.muted,this.toggleAttribute("muted",this.#t.muted),this.#r.style.setProperty("--_vol",this.#t.muted?"0":this.#r.value)}),this.addEventListener("keydown",r=>{let i=r.target;if(!(i?.tagName==="INPUT"||i?.tagName==="TEXTAREA"))switch(r.key){case" ":r.preventDefault(),this.#a?this.#t.pause():this.#t.play().catch(()=>{});break;case"ArrowLeft":r.preventDefault(),this.#t.currentTime=Math.max(0,this.#t.currentTime-10);break;case"ArrowRight":r.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.toggleAttribute("muted",this.#t.muted),this.#r.style.setProperty("--_vol",this.#t.muted?"0":this.#r.value);break}}),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"))}#x(){this.#e&&this.#e.addEventListener("click",t=>{let r=t.target?.closest("a[href]");r&&(t.preventDefault(),this.#o(r.href,r.closest("li")))})}#o(t,e){if(!this.#e)return;this.#e.querySelectorAll("li").forEach(i=>i.removeAttribute("data-audio-active")),e&&e.setAttribute("data-audio-active",""),this.#t.src=t,this.#t.play().catch(()=>{}),this.#p(),this.#l("audio-player:track-change",{src:t,title:e?.querySelector("a")?.textContent??""})}#w(){if(!this.#e)return;let t=[...this.#e.querySelectorAll("li")],e=t.findIndex(i=>i.hasAttribute("data-audio-active"));if(this.hasAttribute("shuffle")){let i=t.filter((a,n)=>n!==e);if(i.length){let a=i[Math.floor(Math.random()*i.length)],n=a.querySelector("a[href]");n&&this.#o(n.href,a)}return}let r=e+1;if(r<t.length){let i=t[r].querySelector("a[href]");i&&this.#o(i.href,t[r])}else if(this.hasAttribute("loop")){let i=t[0]?.querySelector("a[href]");i&&this.#o(i.href,t[0])}}#k(){let t=this.#t.currentTime,e=this.#t.duration||0,r=e?t/e*100:0;this.#d.textContent=this.#m(t),this.#i.value=String(r),this.#u.style.width=`${r}%`}#E(){let t=this.#t.duration||0;this.#c.textContent=this.#m(t)}#p(){if(!this.#n)return;if(this.#e){let e=this.#e.querySelector("li[data-audio-active] a");if(e){this.#n.textContent=e.textContent;return}}let t=this.#t.currentSrc||this.#t.querySelector("source")?.src||"";if(t){let e=t.split("/").pop().split("?")[0];this.#n.textContent=e.replace(/\.[^.]+$/,"").replace(/[-_]/g," ")}}#m(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}`}#l(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}};d("audio-player",l);export{l as AudioPlayerElement};
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};
340
350
  //# sourceMappingURL=audio-player.js.map
@@ -1,8 +1,8 @@
1
- var S=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 u=class extends HTMLElement{#s=[];#n;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.#s)t();this.#s=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#s.push(()=>t.removeEventListener(e,i,n))}setup(){}teardown(){}setState(t,e){this.#n||(this.#n=this.attachInternals());let i=this.#n.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#n||(this.#n=t)}};var f=new Map;function E(){if(!f.has("default"))try{f.set("default",new AudioContext)}catch{return null}return f.get("default")}var m=new WeakMap;function k(o,t){if(m.has(o))return m.get(o);let e=t.createMediaElementSource(o);return m.set(o,e),e}var y=class extends u{#s=null;#n=null;#r=null;#e=null;#t=null;#h=null;#i=null;#l=null;#c=!0;#o=!1;#a=!1;#u=null;static get observedAttributes(){return["for","data-mode","data-fft-size"]}setup(){this.#a=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let t=!this.shadowRoot;this.#y(),this.#f(),t&&(this.#M(),this.#E()),this.#u=()=>{let e=this.shadowRoot?.querySelector("canvas");e&&(e.style.display="none",e.offsetHeight,e.style.display="")},this.listen(window,"vb:theme-change",this.#u)}teardown(){this.#m(),this.#l?.disconnect()}attributeChangedCallback(t){t==="for"&&this.#f()}#y(){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;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=`
2
2
  <style>
3
3
  :host {
4
4
  display: block;
5
- --_color: var(--audio-visualizer-color, var(--color-primary, oklch(55% 0.2 260)));
5
+ --_color: var(--audio-visualizer-color, var(--color-primary, ${b}));
6
6
  --_bg: var(--audio-visualizer-bg, var(--color-surface-sunken, transparent));
7
7
  --_height: var(--audio-visualizer-height, 80px);
8
8
  --_radius: var(--audio-visualizer-radius, var(--radius-m, 0.5rem));
@@ -16,5 +16,5 @@ var S=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;functi
16
16
  }
17
17
  </style>
18
18
  <canvas aria-hidden="true"></canvas>
19
- `,this.#s=t.querySelector("canvas")}#f(){let t=this.getAttribute("for");t&&(this.#r=document.getElementById(t),!(!this.#r||this.#r.tagName!=="AUDIO")&&(this.#o||this.#r.addEventListener("play",()=>this.#b(),{once:!0})))}#b(){if(this.#o||(this.#o=!0,this.#e=E(),!this.#e))return;this.#e.state==="suspended"&&this.#e.resume();let t=parseInt(this.getAttribute("data-fft-size")||"256",10);this.#t=this.#e.createAnalyser(),this.#t.fftSize=t,this.#t.smoothingTimeConstant=.8,this.#h=k(this.#r,this.#e),this.#h.connect(this.#t),this.#t.connect(this.#e.destination),this.#d()}#d(){if(this.#a)return;let t=()=>{if(!this.#c||this.#a){this.#i=null;return}this.#i=requestAnimationFrame(t),this.#p()};this.#i=requestAnimationFrame(t)}#m(){this.#i&&(cancelAnimationFrame(this.#i),this.#i=null)}#p(){let t=this.#s,e=t.getContext("2d");if(!e)return;let i=t.width=t.offsetWidth*(window.devicePixelRatio||1),n=t.height=t.offsetHeight*(window.devicePixelRatio||1),s=getComputedStyle(this),c=s.getPropertyValue("--_color").trim()||"oklch(55% 0.2 260)",a=s.getPropertyValue("--_bg").trim();if(e.clearRect(0,0,i,n),a&&a!=="transparent"&&(e.fillStyle=a,e.fillRect(0,0,i,n)),!this.#t)return;let l=this.getAttribute("data-mode")||"bars",d=this.#t.frequencyBinCount,r=new Uint8Array(d);l==="waveform"?(this.#t.getByteTimeDomainData(r),this.#v(e,i,n,c,r)):l==="circle"?(this.#t.getByteFrequencyData(r),this.#w(e,i,n,c,r)):(this.#t.getByteFrequencyData(r),this.#g(e,i,n,c,r))}#g(t,e,i,n,s){let c=Math.min(s.length,64),a=e/c-1;t.fillStyle=n;for(let l=0;l<c;l++){let r=s[l]/255*i,h=l*(e/c);t.fillRect(h,i-r,a,r)}}#v(t,e,i,n,s){let c=e/s.length;t.strokeStyle=n,t.lineWidth=2,t.beginPath();for(let a=0;a<s.length;a++){let d=s[a]/128*i/2;a===0?t.moveTo(0,d):t.lineTo(a*c,d)}t.stroke()}#w(t,e,i,n,s){let c=e/2,a=i/2,l=Math.min(e,i)*.25,d=s.length;t.strokeStyle=n,t.lineWidth=2,t.beginPath();for(let r=0;r<d;r++){let h=r/d*Math.PI*2,M=s[r]/255*(l*.8),b=l+M,p=c+b*Math.cos(h),g=a+b*Math.sin(h);r===0?t.moveTo(p,g):t.lineTo(p,g)}t.closePath(),t.stroke()}#M(){this.#l=new IntersectionObserver(([t])=>{this.#c=t.isIntersecting,this.#c&&this.#o&&!this.#i&&!this.#a&&this.#d()}),this.#l.observe(this)}#E(){window.matchMedia("(prefers-reduced-motion: reduce)").addEventListener("change",t=>{this.#a=t.matches,t.matches?this.#m():this.#o&&this.#c&&this.#d()})}};w("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.#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};
20
20
  //# sourceMappingURL=audio-visualizer.js.map