vanilla-breeze 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +23012 -11383
- package/dist/cdn/components/accordion-wc.js +1 -1
- package/dist/cdn/components/activity-feed.js +1 -1
- package/dist/cdn/components/ai-chat.js +9 -6
- package/dist/cdn/components/ai-summary.js +4 -2
- package/dist/cdn/components/analytics-panel.js +19 -21
- package/dist/cdn/components/audio-player.js +17 -7
- package/dist/cdn/components/audio-visualizer.js +3 -3
- package/dist/cdn/components/author-index.js +2 -2
- package/dist/cdn/components/brand-mark.js +1 -1
- package/dist/cdn/components/bread-crumb.js +1 -1
- package/dist/cdn/components/calendar-wc.js +2 -2
- package/dist/cdn/components/card-list.js +1 -1
- package/dist/cdn/components/carousel-wc.js +1 -1
- package/dist/cdn/components/change-set.js +1 -11
- package/dist/cdn/components/chart-wc.js +32 -32
- package/dist/cdn/components/chat-input.js +1 -1
- package/dist/cdn/components/chat-window.js +1 -1
- package/dist/cdn/components/color-picker.js +1 -1
- package/dist/cdn/components/combo-box.js +1 -1
- package/dist/cdn/components/command-palette.js +1 -1
- package/dist/cdn/components/comment-box.js +50 -49
- package/dist/cdn/components/comment-thread.js +50 -49
- package/dist/cdn/components/comment-wc.js +1 -1
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/consent-banner.js +1 -1
- package/dist/cdn/components/content-lens.js +1 -1
- package/dist/cdn/components/content-swap.js +1 -1
- package/dist/cdn/components/context-menu.js +1 -1
- package/dist/cdn/components/data-table.js +1 -1
- package/dist/cdn/components/date-picker.js +1 -1
- package/dist/cdn/components/day-view.js +1 -1
- package/dist/cdn/components/diagram-wc.js +2 -2
- package/dist/cdn/components/drag-surface.js +1 -1
- package/dist/cdn/components/drop-down.js +1 -1
- package/dist/cdn/components/emoji-picker.js +1 -1
- package/dist/cdn/components/flow-diagram.js +1 -1
- package/dist/cdn/components/foot-notes.js +1 -1
- package/dist/cdn/components/form-field.js +1 -1
- package/dist/cdn/components/geo-map.js +170 -54
- package/dist/cdn/components/glossary-index.js +1 -1
- package/dist/cdn/components/glossary-wc.js +1 -1
- package/dist/cdn/components/heading-links.js +1 -1
- package/dist/cdn/components/highlight-wc.js +6 -2
- package/dist/cdn/components/icon-wc.js +11 -10
- package/dist/cdn/components/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/manifest.json +101 -101
- package/dist/cdn/components/markdown-editor.js +60 -1
- package/dist/cdn/components/markdown-viewer.js +50 -49
- package/dist/cdn/components/nav-bar.js +1 -1
- package/dist/cdn/components/note-wc.js +6 -2
- package/dist/cdn/components/notification-wc.js +33 -32
- package/dist/cdn/components/page-info.js +6 -72
- package/dist/cdn/components/page-stats.js +1 -1
- package/dist/cdn/components/page-toc.js +1 -1
- package/dist/cdn/components/page-tools.js +1 -1
- package/dist/cdn/components/page-tour.js +1 -38
- package/dist/cdn/components/pager-wc.js +1 -1
- package/dist/cdn/components/poll-wc.js +1 -1
- package/dist/cdn/components/pop-over.js +1 -1
- package/dist/cdn/components/popularity-index.js +1 -8
- package/dist/cdn/components/print-page.js +1 -1
- package/dist/cdn/components/progress-tracker.js +1 -1
- package/dist/cdn/components/qr-code.js +1 -1
- package/dist/cdn/components/reaction-bar.js +1 -1
- package/dist/cdn/components/reader-view.js +25 -25
- package/dist/cdn/components/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +1 -26
- package/dist/cdn/components/score-card.js +21 -5
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/settings-panel.js +88 -142
- package/dist/cdn/components/share-wc.js +2 -2
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -10
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +1 -51
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/status-wc.js +1 -1
- package/dist/cdn/components/stepper-wc.js +1 -1
- package/dist/cdn/components/tab-set.js +1 -1
- package/dist/cdn/components/text-reader.js +2 -2
- package/dist/cdn/components/theme-picker.js +84 -81
- package/dist/cdn/components/time-index.js +1 -11
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +6 -6
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +6 -3
- package/dist/cdn/components/trust-filter.js +1 -3
- package/dist/cdn/components/version-switcher.js +5 -15
- package/dist/cdn/components/video-player.js +67 -9
- package/dist/cdn/components/watch-wc.js +6 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/emoji-extended.js +2 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-OFL.txt +93 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2 +0 -0
- package/dist/cdn/fonts/latinmodern-math-GUST-LICENSE.txt +30 -0
- package/dist/cdn/fonts/latinmodern-math.woff2 +0 -0
- package/dist/cdn/fonts/math-fonts.css +14 -0
- package/dist/cdn/packs/effects.full.css +1 -1
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/fonts-display.full.css +1 -1
- package/dist/cdn/packs/fonts-display.theme.css +1 -1
- package/dist/cdn/packs/icons.bundle.js +1 -1
- package/dist/cdn/packs/icons.full.css +1 -1
- package/dist/cdn/packs/icons.theme.css +1 -1
- package/dist/cdn/packs/journal.effects.css +1 -1
- package/dist/cdn/packs/journal.full.css +1 -1
- package/dist/cdn/packs/kawaii.effects.css +1 -1
- package/dist/cdn/packs/kawaii.full.css +2 -2
- package/dist/cdn/packs/kawaii.full.js +6 -6
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +17 -17
- package/dist/cdn/packs/memphis.full.css +1 -1
- package/dist/cdn/packs/memphis.theme.css +1 -1
- package/dist/cdn/packs/ui.full.css +1 -1
- package/dist/cdn/packs/ui.full.js +88 -85
- package/dist/cdn/themes/8bit.css +1 -1
- package/dist/cdn/themes/8bit.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999.css +1 -1
- package/dist/cdn/themes/alpha1999.tokens.json +1 -1
- package/dist/cdn/themes/art-deco-dark.tokens.json +33 -1
- package/dist/cdn/themes/art-deco.css +1 -1
- package/dist/cdn/themes/art-deco.tokens.json +23 -1
- package/dist/cdn/themes/bauhaus-dark.tokens.json +23 -1
- package/dist/cdn/themes/bauhaus.css +1 -1
- package/dist/cdn/themes/bauhaus.tokens.json +1 -1
- package/dist/cdn/themes/brutalist-dark.tokens.json +33 -1
- package/dist/cdn/themes/brutalist.css +1 -1
- package/dist/cdn/themes/brutalist.tokens.json +23 -1
- package/dist/cdn/themes/catppuccin-frappe.css +1 -1
- package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte.css +1 -1
- package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-mocha.css +1 -1
- package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
- package/dist/cdn/themes/classic-dark.tokens.json +1 -1
- package/dist/cdn/themes/classic.css +1 -1
- package/dist/cdn/themes/classic.tokens.json +1 -1
- package/dist/cdn/themes/claymorphism-dark.tokens.json +33 -1
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/claymorphism.tokens.json +24 -1
- package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
- package/dist/cdn/themes/clinical.css +1 -1
- package/dist/cdn/themes/clinical.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore.css +1 -1
- package/dist/cdn/themes/cottagecore.tokens.json +1 -1
- package/dist/cdn/themes/cyber.css +1 -1
- package/dist/cdn/themes/cyber.tokens.json +1 -1
- package/dist/cdn/themes/dawn-dark.tokens.json +33 -1
- package/dist/cdn/themes/dawn.css +1 -1
- package/dist/cdn/themes/dawn.tokens.json +23 -1
- package/dist/cdn/themes/dracula.css +1 -1
- package/dist/cdn/themes/dracula.tokens.json +1 -1
- package/dist/cdn/themes/dusk.css +1 -1
- package/dist/cdn/themes/dusk.tokens.json +1 -1
- package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
- package/dist/cdn/themes/editorial.css +1 -1
- package/dist/cdn/themes/editorial.tokens.json +1 -1
- package/dist/cdn/themes/financial-dark.tokens.json +1 -1
- package/dist/cdn/themes/financial.css +1 -1
- package/dist/cdn/themes/financial.tokens.json +1 -1
- package/dist/cdn/themes/genai.css +1 -1
- package/dist/cdn/themes/genai.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism-dark.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism.css +1 -1
- package/dist/cdn/themes/glassmorphism.tokens.json +1 -1
- package/dist/cdn/themes/government-dark.tokens.json +1 -1
- package/dist/cdn/themes/government.css +1 -1
- package/dist/cdn/themes/government.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox.css +1 -1
- package/dist/cdn/themes/gruvbox.tokens.json +1 -1
- package/dist/cdn/themes/high-noon-dark.tokens.json +23 -1
- package/dist/cdn/themes/high-noon.css +1 -1
- package/dist/cdn/themes/high-noon.tokens.json +1 -1
- package/dist/cdn/themes/journal-dark.tokens.json +36 -2
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +26 -2
- package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
- package/dist/cdn/themes/kawaii.css +1 -1
- package/dist/cdn/themes/kawaii.tokens.json +1 -1
- package/dist/cdn/themes/magna-dark.tokens.json +1 -1
- package/dist/cdn/themes/magna.css +1 -1
- package/dist/cdn/themes/magna.tokens.json +1 -1
- package/dist/cdn/themes/manifest.json +44 -68
- package/dist/cdn/themes/midnight.css +1 -1
- package/dist/cdn/themes/midnight.tokens.json +1 -1
- package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
- package/dist/cdn/themes/minimal.css +1 -1
- package/dist/cdn/themes/minimal.tokens.json +1 -1
- package/dist/cdn/themes/modern-dark.tokens.json +1 -1
- package/dist/cdn/themes/modern.css +1 -1
- package/dist/cdn/themes/modern.tokens.json +1 -1
- package/dist/cdn/themes/nes-dark.tokens.json +7 -2
- package/dist/cdn/themes/nes.css +1 -1
- package/dist/cdn/themes/nes.tokens.json +1 -1
- package/dist/cdn/themes/neumorphism-dark.tokens.json +1 -1
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/neumorphism.tokens.json +1 -1
- package/dist/cdn/themes/nord-dark.tokens.json +33 -1
- package/dist/cdn/themes/nord.css +1 -1
- package/dist/cdn/themes/nord.tokens.json +23 -1
- package/dist/cdn/themes/organic-dark.tokens.json +1 -1
- package/dist/cdn/themes/organic.css +1 -1
- package/dist/cdn/themes/organic.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine.css +1 -1
- package/dist/cdn/themes/rose-pine.tokens.json +1 -1
- package/dist/cdn/themes/rough-dark.tokens.json +1 -1
- package/dist/cdn/themes/rough.css +1 -1
- package/dist/cdn/themes/rough.tokens.json +1 -1
- package/dist/cdn/themes/solarized-dark.tokens.json +23 -1
- package/dist/cdn/themes/solarized.css +1 -1
- package/dist/cdn/themes/solarized.tokens.json +23 -1
- package/dist/cdn/themes/startup-dark.tokens.json +1 -1
- package/dist/cdn/themes/startup.css +1 -1
- package/dist/cdn/themes/startup.tokens.json +1 -1
- package/dist/cdn/themes/super2026-dark.tokens.json +33 -1
- package/dist/cdn/themes/super2026.css +1 -1
- package/dist/cdn/themes/super2026.tokens.json +23 -1
- package/dist/cdn/themes/swiss-dark.tokens.json +1 -1
- package/dist/cdn/themes/swiss.css +1 -1
- package/dist/cdn/themes/swiss.tokens.json +1 -1
- package/dist/cdn/themes/terminal.css +1 -1
- package/dist/cdn/themes/terminal.tokens.json +1 -1
- package/dist/cdn/themes/tokyo-night-dark.tokens.json +33 -1
- package/dist/cdn/themes/tokyo-night.css +1 -1
- package/dist/cdn/themes/tokyo-night.tokens.json +23 -1
- package/dist/cdn/themes/vaporwave-dark.tokens.json +33 -1
- package/dist/cdn/themes/vaporwave.css +1 -1
- package/dist/cdn/themes/vaporwave.tokens.json +23 -1
- package/dist/cdn/themes/win9x-dark.tokens.json +20 -5
- package/dist/cdn/themes/win9x.css +1 -1
- package/dist/cdn/themes/win9x.tokens.json +3 -1
- package/dist/cdn/vanilla-breeze-autoload.js +553 -0
- package/dist/cdn/vanilla-breeze-charts.css +1 -1
- package/dist/cdn/vanilla-breeze-charts.js +32 -32
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +183 -281
- package/dist/cdn/vanilla-breeze-dev.css +1 -1
- package/dist/cdn/vanilla-breeze-dev.js +1 -1
- package/dist/cdn/vanilla-breeze-extras.js +286 -134
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +574 -656
- package/dist/cdn/view-transitions.css +2 -0
- package/package.json +17 -9
- package/dist/cdn/themes/amber.css +0 -2
- package/dist/cdn/themes/anthropic.css +0 -2
- package/dist/cdn/themes/anthropic.tokens.json +0 -564
- package/dist/cdn/themes/coral.css +0 -2
- package/dist/cdn/themes/emerald.css +0 -2
- package/dist/cdn/themes/forest.css +0 -2
- package/dist/cdn/themes/ibm.css +0 -2
- package/dist/cdn/themes/ibm.tokens.json +0 -568
- package/dist/cdn/themes/indigo.css +0 -2
- package/dist/cdn/themes/lavender.css +0 -2
- package/dist/cdn/themes/mcdonalds.css +0 -2
- package/dist/cdn/themes/mcdonalds.tokens.json +0 -533
- package/dist/cdn/themes/ocean.css +0 -2
- package/dist/cdn/themes/rose.css +0 -2
- package/dist/cdn/themes/slate.css +0 -2
- package/dist/cdn/themes/starbucks.css +0 -2
- package/dist/cdn/themes/starbucks.tokens.json +0 -593
- package/dist/cdn/themes/sunset.css +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function a(
|
|
1
|
+
function a(n){return document.startViewTransition?document.startViewTransition(n):n()}var b=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function f(n,t,e={}){let r=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:r},i=h.get(n);if(customElements.get(n)){if(!i||i.priority>=r){i&&i.priority===r&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=r){i.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}h.set(n,s),customElements.define(n,t)}var c=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,s){t.addEventListener(e,r,s),this.#t.push(()=>t.removeEventListener(e,r,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let s=`--${t}`;e?r.add(s):r.delete(s)}}_adoptInternals(t){this.#e||(this.#e=t)}#s(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var p=0,l=class extends c{#t=[];#e=[];#s=[];#r=!1;setup(){return this.#t=[...this.querySelectorAll(":scope > details")],this.#e=this.#t.map(t=>t.querySelector("summary")),this.#t.length===0?!1:(this.#n(),this.#a(),this.#o(),!0)}teardown(){this.#t=[],this.#e=[],this.#s=[],this.#r=!1}get panels(){return this.#t.map((t,e)=>({id:t.id||void 0,summary:t.querySelector("summary")?.textContent?.trim()||`Panel ${e+1}`,content:this.#s[e]?.innerHTML||"",open:t.hasAttribute("open")}))}set panels(t){let e=Array.isArray(t)?t:[],s=this.hasAttribute("single")?`acc-${++p}`:null;for(;this.firstChild;)this.firstChild.remove();for(let i of e){let o=document.createElement("details");i.id&&(o.id=i.id),i.open&&o.setAttribute("open",""),s&&o.setAttribute("name",s);let u=document.createElement("summary");u.textContent=i.summary||"",o.appendChild(u);let d=document.createElement("div");d.innerHTML=i.content||"",o.appendChild(d),this.appendChild(o)}this._reinit(),this.dispatchEvent(new CustomEvent("accordion-wc:panels-changed",{detail:{panels:e,source:"property"},bubbles:!0}))}#n(){this.#s=this.#t.map(t=>{let e=t.querySelector("summary");if(!e)return null;let r=[...t.children].filter(s=>s!==e);if(r.length===1&&r[0].localName==="div")return r[0];if(r.length>=1){let s=document.createElement("div");for(let i of r)s.appendChild(i);return t.appendChild(s),s}return null})}#o(){if(!this.hasAttribute("transition")||!document.startViewTransition)return;this.#r=!0;let t=++p,e=this.getAttribute("transition")||"fade",r=e==="slide"?"vt-accordion-slide":e==="scale"?"vt-accordion-scale":"vt-accordion";this.#s.forEach((s,i)=>{s&&(s.style.viewTransitionName=`accordion-${t}-${i}`,s.style.viewTransitionClass=r)})}#i(t){a(()=>{t.open=!t.open})}#a(){this.#t.forEach((t,e)=>{let r=this.#e[e],s=this.#s[e];if(r){if(s){let i=r.id||`accordion-heading-${crypto.randomUUID().slice(0,8)}`,o=s.id||`accordion-panel-${crypto.randomUUID().slice(0,8)}`;r.id=i,s.id=o,r.setAttribute("aria-expanded",t.open?"true":"false"),r.setAttribute("aria-controls",o),s.setAttribute("aria-labelledby",i),s.setAttribute("role","region")}else r.setAttribute("aria-expanded",t.open?"true":"false");this.listen(r,"click",i=>{this.#r&&(i.preventDefault(),this.#i(t))}),this.listen(r,"keydown",i=>this.#l(i,e)),this.listen(t,"toggle",()=>this.#c(t,e))}})}#c(t,e){this.#e[e].setAttribute("aria-expanded",t.open?"true":"false"),this.hasAttribute("single")&&t.open&&this.#t.forEach((s,i)=>{i!==e&&s.open&&(s.open=!1,this.#e[i].setAttribute("aria-expanded","false"))}),this.dispatchEvent(new CustomEvent("accordion-wc:toggle",{detail:{index:e,open:t.open},bubbles:!0}))}#l(t,e){let{key:r}=t,s;switch(r){case"ArrowDown":s=(e+1)%this.#t.length;break;case"ArrowUp":s=(e-1+this.#t.length)%this.#t.length;break;case"Home":s=0;break;case"End":s=this.#t.length-1;break;default:return}t.preventDefault(),this.#e[s].focus()}open(t){t<0||t>=this.#t.length||(this.#r&&!this.#t[t].open?a(()=>{this.#t[t].open=!0}):this.#t[t].open=!0)}close(t){t<0||t>=this.#t.length||(this.#r&&this.#t[t].open?a(()=>{this.#t[t].open=!1}):this.#t[t].open=!1)}toggle(t){t<0||t>=this.#t.length||(this.#r?this.#i(this.#t[t]):this.#t[t].open=!this.#t[t].open)}openAll(){this.hasAttribute("single")||this.#t.forEach(t=>{t.open=!0})}closeAll(){this.#t.forEach(t=>{t.open=!1})}};f("accordion-wc",l);export{l as AccordionWc};
|
|
2
2
|
//# sourceMappingURL=accordion-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var 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 C=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function y(s,t,i={}){let e=i.priority??10,r={impl:t,bundle:i.bundle,contract:i.contract,priority:e},n=p.get(s);if(customElements.get(s)){if(!n||n.priority>=e){n&&n.priority===e&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=e){n.priority===e&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}p.set(s,r),customElements.define(s,t)}var h=class extends HTMLElement{#i=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#i)t();this.#i=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,i,e,r){t.addEventListener(i,e,r),this.#i.push(()=>t.removeEventListener(i,e,r))}_reinit(){for(let t of this.#i)t();this.#i=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,i){this.#t||(this.#t=this.attachInternals());let e=this.#t.states;try{i?e.add(t):e.delete(t)}catch{let r=`--${t}`;i?e.add(r):e.delete(r)}}_adoptInternals(t){this.#t||(this.#t=t)}#e(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};function u(s){let t=(Date.now()-s.getTime())/1e3;if(Number.isNaN(t)||t<0)return null;if(t<60)return"just now";if(t<3600){let e=Math.floor(t/60);return`${e} minute${e!==1?"s":""} ago`}if(t<86400){let e=Math.floor(t/3600);return`${e} hour${e!==1?"s":""} ago`}if(t<2592e3){let e=Math.floor(t/86400);return`${e} day${e!==1?"s":""} ago`}if(t<31536e3){let e=Math.floor(t/2592e3);return`${e} month${e!==1?"s":""} ago`}let i=Math.floor(t/31536e3);return`${i} year${i!==1?"s":""} ago`}function g(s=document){for(let t of s.querySelectorAll("time[data-relative]")){if(t.closest("page-info"))continue;let i=t.getAttribute("datetime");if(!i)continue;let e=new Date(i),r=t.closest("[lang]")?.getAttribute("lang")||"",n=r&&!/^en\b/i.test(r)?w(e,r):u(e);n&&(t.textContent=n)}}function w(s,t){let i=(Date.now()-s.getTime())/1e3;if(Number.isNaN(i)||i<0)return null;let e;try{e=new Intl.RelativeTimeFormat(t,{numeric:"auto"})}catch{return u(s)}return i<60?e.format(0,"second"):i<3600?e.format(-Math.floor(i/60),"minute"):i<86400?e.format(-Math.floor(i/3600),"hour"):i<2592e3?e.format(-Math.floor(i/86400),"day"):i<31536e3?e.format(-Math.floor(i/2592e3),"month"):e.format(-Math.floor(i/31536e3),"year")}var f=typeof document<"u"?document.documentElement:null,v;function A(){g(),v||(v=setInterval(()=>g(),6e4))}f&&!f.hasAttribute("data-vb-time-relative-init")&&(f.setAttribute("data-vb-time-relative-init",""),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A,{once:!0}):A());function m(s){let t=new Date(s);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function M(s){let t=new Date(s),i=(t.getDay()+6)%7,e=new Date(t);e.setDate(t.getDate()-i);let r=new Date(e);r.setDate(e.getDate()+3);let n=new Date(r.getFullYear(),0,1),o=Math.ceil(((r.getTime()-n.getTime())/864e5+1)/7);return`${r.getFullYear()}-W${String(o).padStart(2,"0")}`}function N(s){let t=m(new Date),i=m(new Date(Date.now()-864e5));if(s===t)return"Today";if(s===i)return"Yesterday";let[e,r,n]=s.split("-").map(Number);return new Date(e,r-1,n).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}function E(s){return s.nodeType===1&&s.matches("article[data-activity]")}function S(s){return`Week of ${s.replace("-W",", week ")}`}var $='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, iframe, [contenteditable=""], [contenteditable="true"], [tabindex]:not([tabindex="-1"])',D=0,b=class extends h{static observedAttributes=["data-infinite"];#i=null;#t=null;#e=null;#a=null;#s=null;#l=`activity-feed-${++D}`;#v=0;#n=!1;#d=0;#u=!0;setup(){let t=this.getAttribute("role");return this.#u=t===null||t==="feed"||t==="group",!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Recent activity"),this.#n=!1,this.setAttribute("aria-busy","false"),this.#r().forEach(i=>this.#h(i)),this.hasAttribute("data-infinite")&&this.#y(),this.#o(),this.#p(),this.#i=new MutationObserver(i=>{let e=!1,r=!1;for(let n of i){for(let o of n.addedNodes)E(o)&&(this.#h(o),e=!0,r=!0);for(let o of n.removedNodes)E(o)&&(e=!0)}e&&(this.#o(),this.#p()),r&&this.#n&&this.#c()}),this.#i.observe(this,{childList:!0}),this.#a=setInterval(()=>this.#A(),6e4),this.listen(this,"keydown",this.#N),this.listen(this,"focusin",this.#M),!0}teardown(){this.#a!==null&&clearInterval(this.#a),this.#a=null,this.#i?.disconnect(),this.#i=null,this.#g(),this.#n=!1,this.setAttribute("aria-busy","false")}attributeChangedCallback(t,i,e){!this.hasAttribute("data-upgraded")||i===null==(e===null)||t==="data-infinite"&&(e!==null?this.#y():(this.#g(),this.#n&&this.#c()),this.#o())}#r(){return[...this.querySelectorAll(":scope > article[data-activity]")]}#h(t){if(t.dataset.decorated==="")return;t.dataset.decorated="",t.setAttribute("tabindex","-1");let i=`${this.#l}-e${++this.#v}`,e=t.querySelector(":scope > time[datetime]");e?.remove();let r=t.dataset.time||e?.getAttribute("datetime")||"";r&&!t.dataset.time&&(t.dataset.time=r);let n=document.createElement("div");for(n.className="activity-body",n.id=`${i}-body`;t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n),!t.hasAttribute("aria-label")&&!t.hasAttribute("aria-labelledby")&&t.setAttribute("aria-labelledby",n.id);let o=t.dataset.activityAvatar,c=t.dataset.activityIcon;if(o||c){let a=document.createElement("div");if(a.className="activity-rail",a.setAttribute("aria-hidden","true"),o){let l=document.createElement("user-avatar"),d=document.createElement("img");d.src=o,d.alt="",d.loading="lazy",d.decoding="async",l.appendChild(d),a.appendChild(l)}else{let l=document.createElement("icon-wc");l.setAttribute("name",c||""),a.appendChild(l)}t.prepend(a)}if(r){let a=e||document.createElement("time");a.classList.add("activity-time"),a.setAttribute("datetime",r),a.id||(a.id=`${i}-time`),a.setAttribute("title",this.#E(r)),a.textContent=u(new Date(r))||a.textContent||r,t.appendChild(a)}}#A(){for(let t of this.querySelectorAll(":scope > article[data-activity] > time.activity-time")){let i=t.getAttribute("datetime");if(!i)continue;let e=u(new Date(i));e&&(t.textContent=e)}}#E(t){try{return new Date(t).toLocaleString()}catch{return t}}#o(){this.querySelectorAll(":scope > [data-activity-heading]").forEach(n=>n.remove());let t=this.#r(),i=this.#t?"-1":String(t.length),e=this.getAttribute("data-group")||"none",r=null;t.forEach((n,o)=>{n.setAttribute("aria-posinset",String(o+1)),n.setAttribute("aria-setsize",i);let c=[];if(e!=="none"&&n.dataset.time){let l=e==="week"?M(n.dataset.time):m(n.dataset.time);if(l!==r){let d=document.createElement("h3");d.setAttribute("data-activity-heading",""),d.setAttribute("aria-hidden","true"),d.id=`${this.#l}-g-${l}`,d.className="activity-heading",d.textContent=e==="week"?S(l):N(l),this.insertBefore(d,n),c.push(d.id),r=l}}let a=n.querySelector(":scope > time.activity-time");a?.id&&c.push(a.id),c.length?n.setAttribute("aria-describedby",c.join(" ")):n.removeAttribute("aria-describedby")}),this.#w(),this.#f()}#f(){let t=this.#t;t&&t.parentNode===this&&this.lastElementChild!==t&&this.appendChild(t)}#w(){let t=this.#r(),i=t.find(e=>e.getAttribute("tabindex")==="0")||t[0];for(let e of t)e.setAttribute("tabindex",e===i?"0":"-1")}#m(t){for(let i of this.#r())i.setAttribute("tabindex",i===t?"0":"-1")}#b(t){let e=(t instanceof Element?t:null)?.closest("article[data-activity]")??null;return e&&e.parentElement===this?e:null}#M=t=>{let i=this.#b(t.target);i&&i.getAttribute("tabindex")!=="0"&&this.#m(i)};#p(){let t=this.#r().length;t===0?this.#s||(this.#s=document.createElement("p"),this.#s.className="activity-empty",this.#s.textContent=this.getAttribute("data-empty-text")||"No recent activity",this.appendChild(this.#s),this.#f()):(this.#s?.remove(),this.#s=null),this.#u&&this.setAttribute("role",t===0?"group":"feed")}#N=t=>{let i=t.target;if(i.isContentEditable||i.matches?.("input, textarea, select"))return;let e=this.#r(),r=this.#b(t.target),n=r?e.indexOf(r):-1;if(n===-1)return;let o=i===r;if(t.ctrlKey&&(t.key==="Home"||t.key==="End")){let l=this.#S(t.key==="Home"?"before":"after");l&&(t.preventDefault(),l.focus());return}if(t.altKey||t.ctrlKey||t.metaKey)return;let c=n;switch(t.key){case"PageDown":c=Math.min(e.length-1,n+1);break;case"PageUp":c=Math.max(0,n-1);break;case"ArrowDown":if(!o)return;c=Math.min(e.length-1,n+1);break;case"ArrowUp":if(!o)return;c=Math.max(0,n-1);break;case"Home":if(!o)return;c=0;break;case"End":if(!o)return;c=e.length-1;break;default:return}t.preventDefault();let a=e[c];a&&(this.#m(a),a.focus())};#S(t){let i=[...document.querySelectorAll($)].filter(r=>!this.contains(r)&&(r.checkVisibility?.()??!0));return t==="after"?i.find(r=>this.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING)||null:i.filter(r=>this.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_PRECEDING).at(-1)||null}#y(){this.#t||!("IntersectionObserver"in window)||(this.querySelectorAll(":scope > .activity-sentinel").forEach(t=>t.remove()),this.#t=document.createElement("div"),this.#t.className="activity-sentinel",this.#t.setAttribute("aria-hidden","true"),this.appendChild(this.#t),this.#e=new IntersectionObserver(t=>{t.some(i=>i.isIntersecting)&&this.#$()},{rootMargin:"200px"}),this.#e.observe(this.#t))}#g(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null}#$(){if(this.#n)return;this.#n=!0,this.setAttribute("aria-busy","true");let t=++this.#d,i=()=>{this.#n&&t===this.#d&&this.#c()};this.dispatchEvent(new CustomEvent("activity-feed:load-more",{bubbles:!0,detail:{done:i}}))}#c(){this.#n=!1,this.setAttribute("aria-busy","false"),this.#e&&this.#t&&(this.#e.unobserve(this.#t),this.#e.observe(this.#t))}addEntry(t,i={}){let e=document.createElement("article");if(e.setAttribute("data-activity",""),e.dataset.time=t.time,t.avatar&&(e.dataset.activityAvatar=t.avatar),t.icon&&(e.dataset.activityIcon=t.icon),e.innerHTML=t.html,i.prepend){let r=this.#r()[0];r?this.insertBefore(e,r):this.appendChild(e)}else this.#t?this.insertBefore(e,this.#t):this.appendChild(e);return e}removeEntry(t){t?.matches?.("article[data-activity]")&&t.remove()}clear(){this.#r().forEach(t=>t.remove())}get entries(){return this.#r()}get loading(){return this.#n}};y("activity-feed",b);export{b as ActivityFeed};
|
|
2
2
|
//# sourceMappingURL=activity-feed.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
1
|
+
var R=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function g(r,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=v.get(r);if(customElements.get(r)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}v.set(r,n),customElements.define(r,t)}var h=class extends HTMLElement{#i=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#i)t();this.#i=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#i.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#i)t();this.#i=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#t||(this.#t=t)}#e(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};async function w(r){let t=typeof globalThis<"u"?globalThis:null;if(!t||!(r in t))return{state:"unsupported"};try{let e=t[r];if(!e||typeof e.availability!="function")return{state:"unsupported"};let i=await e.availability();return i==="available"||i==="downloadable"||i==="downloading"||i==="unavailable"?{state:i}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}var T="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function x(r,{stripSelectors:t=T}={}){if(r==null)return"";let e;if(typeof r=="string"){if(typeof document>"u")return"";try{e=document.querySelector(r)}catch{return""}}else typeof r=="object"&&typeof r.cloneNode=="function"&&(e=r);if(!e)return"";let i=e.cloneNode(!0);return t&&typeof i.querySelectorAll=="function"&&i.querySelectorAll(t).forEach(n=>n.remove()),(i.textContent||"").trim().replace(/\s+/g," ")}var N=/\{(prompt|url|title|content)\}/g;function $(r,t=1500){let e=String(r??"");if(e.length<=t)return e;let i=e.slice(0,Math.max(0,t-1)),n=i.lastIndexOf(" ");return`${n>t*.8?i.slice(0,n):i}\u2026`}function S(r){return typeof r=="string"&&r.includes("{content}")}function A(r,t={},{contentLimit:e=1500}={}){if(!r)return"";let i={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:$(t.content,e)};return String(r).replace(N,(n,s)=>encodeURIComponent(i[s]))}async function*C(r,{prompt:t="",content:e,mode:i,messages:n,signal:s}={}){let a={prompt:t};e!==void 0&&(a.content=e),i!==void 0&&(a.mode=i),Array.isArray(n)&&(a.messages=n);let o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:s});if(!o.ok)throw new Error(`AI endpoint ${r} returned ${o.status} ${o.statusText}`);if((o.headers.get("content-type")||"").toLowerCase().includes("application/json")){let l=await o.json(),c=typeof l?.text=="string"?l.text:"";c&&(yield c);return}if(!o.body||typeof o.body.getReader!="function"){let l=await o.text();l&&(yield l);return}let b=o.body.getReader(),m=new TextDecoder;try{for(;;){let{value:c,done:k}=await b.read();if(k)break;if(c){let y=m.decode(c,{stream:!0});y&&(yield y)}}let l=m.decode();l&&(yield l)}finally{try{b.releaseLock()}catch{}}}function E(r){return r?Math.ceil(String(r).length/4):0}var M=12e3,q=20;function p(r,{maxChars:t=M,maxMessages:e=q}={}){if(!Array.isArray(r)||r.length===0)return[];let i=[],n=0;for(let s=r.length-1;s>=0;s--){let a=r[s],o=String(a?.content??"").length;if(i.length>=e||n+o>t)break;i.unshift(a),n+=o}for(;i.length&&i[0].role==="assistant";)i.shift();return i}var _="Help me explore this article: {title} ({url})",O={user:{name:"You",role:"user"},assistant:{name:"Assistant",role:"agent"}},u={local:"Gemini Nano (on-device)",endpoint:"Server endpoint","deep-link":"Open in external tool"},f=class extends h{#i=null;#t=null;#e=null;#a=null;#l=null;#m=null;#c=null;#d=[];#r=null;#n=null;#h="unsupported";#s="unavailable";static get observedAttributes(){return["placeholder"]}setup(){this.#E()||this.#k(),this.#T(),this.#N(),this.#p(),this.#q()}teardown(){this.#n?.abort(),this.#n=null,this.#r?.destroy?.(),this.#r=null,this.#f()}attributeChangedCallback(t,e,i){if(t==="placeholder"){let n=this.querySelector("chat-input textarea");n&&(n.placeholder=i??"")}}async reset(){this.#n?.abort(),this.#n=null,this.#r?.destroy?.(),this.#r=null,this.#d=[],this.#f(),this.#i?.clearThread?.(),this.#p(),this.#o("ready")}stop(){this.#n?.abort()}#E(){let t=this.querySelector(":scope > chat-window");return t?(this.#i=t,this.#t=t.querySelector(".ai-chat-provider"),this.#e=this.querySelector(":scope > .ai-chat-ribbon"),this.#a=this.querySelector(":scope > .ai-chat-notice"),this.#l=this.querySelector(":scope > .ai-chat-starters"),this.#g(),!0):!1}#g(){this.#m=this.querySelector("chat-input [data-send]"),this.#c=this.querySelector("chat-input [data-stop]")}#k(){let t=this.getAttribute("placeholder")||"Type a message\u2026",e=document.createElement("template");e.innerHTML=`
|
|
2
2
|
<p class="ai-chat-ribbon" hidden></p>
|
|
3
3
|
<p class="ai-chat-notice" hidden></p>
|
|
4
4
|
<div class="ai-chat-starters" role="group" aria-label="Starter prompts" hidden></div>
|
|
5
5
|
<chat-window empty-message="Send a message to start a session.">
|
|
6
|
-
<script type="application/json" data-participants>${JSON.stringify(
|
|
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.#
|
|
21
|
-
`).map(
|
|
23
|
+
`,this.appendChild(e.content.cloneNode(!0)),this.#i=this.querySelector(":scope > chat-window"),this.#t=this.querySelector(".ai-chat-provider"),this.#e=this.querySelector(":scope > .ai-chat-ribbon"),this.#a=this.querySelector(":scope > .ai-chat-notice"),this.#l=this.querySelector(":scope > .ai-chat-starters"),this.#g();let i=this.querySelector("chat-input textarea");i&&(i.placeholder=t)}#T(){if(!this.#l)return;let t=this.querySelector(':scope > template[data-role="starters"]'),e=(t&&t.content?.textContent||"").split(`
|
|
24
|
+
`).map(i=>i.trim()).filter(Boolean);if(this.#l.replaceChildren(),!e.length){this.#l.hidden=!0;return}this.#l.hidden=!1;for(let i of e){let n=document.createElement("button");n.type="button",n.className="ai-chat-starter small",n.textContent=i,this.listen(n,"click",()=>this.#$(i)),this.#l.appendChild(n)}}#N(){this.#i&&(this.listen(this,"chat-input:send",t=>{if(!this.#n)return;t.stopImmediatePropagation();let e=t.target,i=t.detail?.message??"";queueMicrotask(()=>{e&&"value"in e&&(e.value=i)})},{capture:!0}),this.listen(this.#i,"chat-window:send",t=>{t.stopPropagation(),this.#O(t.detail.message,t.detail.typingElement)}),this.listen(this.#i,"chat-window:model-change",t=>{let e=t.detail.model;e&&e!==this.#s&&(this.#s=e,this.#r?.destroy?.(),this.#r=null,this.#x())}),this.listen(this,"keydown",t=>{t.key==="Escape"&&this.#n&&(t.preventDefault(),this.#n.abort())}),this.#c&&this.listen(this.#c,"click",()=>{this.#n?.abort(),this.querySelector("chat-input textarea")?.focus()}),this.listen(this,"focusin",t=>{let e=t.relatedTarget;e&&this.contains(e)||this.#p()}))}#$(t){let e=this.querySelector("chat-input");if(!e)return;e.value=t;let i=e.querySelector("textarea");i&&i.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))}#w(){return this.getAttribute("context")?.trim()||""}#u(){let t=this.#w();return t?x(t,{stripSelectors:"ai-chat, ai-summary, .ais-ui"}):""}#p(){if(!this.#e)return;let t=this.#w();if(!t){this.#e.hidden=!0;return}let e=this.#u();if(!e){this.#e.hidden=!1,this.#e.textContent=`Context selector "${t}" matched no readable content.`,this.setAttribute("data-context-state","missing");return}let i=e.length,n=E(e),s=i>6e3,a=this.getAttribute("context-label")||t;this.#e.hidden=!1,this.#e.replaceChildren();let o=document.createElement("span");if(o.className="ai-chat-ribbon-lead",o.textContent=`Page context: ${a} \xB7 ${i.toLocaleString()} chars (~${n.toLocaleString()} tokens)`,this.#e.appendChild(o),s){let d=document.createElement("span");d.className="ai-chat-ribbon-warn",d.textContent="large \u2014 may crowd the conversation",this.#e.appendChild(d)}this.setAttribute("data-context-state",s?"large":"ok")}#M(){let t=this.getAttribute("system")?.trim()||this.querySelector(':scope > template[data-role="system"]')?.content?.textContent?.trim()||"",e=this.#u();if(!e)return t||void 0;let n=`
|
|
22
25
|
|
|
23
26
|
[PAGE CONTENT \u2014 ${this.getAttribute("context-label")||"page"}]
|
|
24
27
|
${e}
|
|
25
|
-
[END PAGE CONTENT]`;return t?t+
|
|
28
|
+
[END PAGE CONTENT]`;return t?t+n:`Use the following page content to answer the user.${n}`}async#q(){this.#o("checking");let{state:t}=await w("LanguageModel");this.#h=t;let e=[];t==="available"||t==="downloadable"||t==="downloading"?e.push({value:"local",label:u.local}):e.push({value:"local",label:`${u.local} \u2014 unavailable`,disabled:!0}),this.getAttribute("endpoint")&&e.push({value:"endpoint",label:u.endpoint}),this.getAttribute("fallback-url")&&e.push({value:"deep-link",label:this.getAttribute("fallback-label")||u["deep-link"]}),this.#L(e);let i=e.find(n=>!n.disabled&&n.value===this.#s)??e.find(n=>!n.disabled);this.#s=i?.value??"unavailable",this.#t&&i&&(this.#t.value=i.value),this.#i&&(this.#i.model=this.#s),this.#x(),this.#o(this.#s==="unavailable"?"unavailable":"ready")}#L(t){if(this.#t){if(this.#t.replaceChildren(),t.length===0){let e=document.createElement("option");e.textContent="Unavailable",e.disabled=!0,this.#t.appendChild(e),this.#t.disabled=!0;return}for(let e of t){let i=document.createElement("option");i.value=e.value,i.textContent=e.label,e.disabled&&(i.disabled=!0),this.#t.appendChild(i)}this.#t.disabled=t.every(e=>e.disabled)}}#x(){this.#m?.setAttribute("aria-label",this.#s==="deep-link"?"Send (opens in new tab)":"Send"),this.#s==="unavailable"?this.#b("On-device AI unavailable and no fallback configured. Set endpoint= or fallback-url= to enable a fallback."):this.#s==="deep-link"?this.#b("Send opens the external tool in a new tab. Choose another provider above to chat in-page."):this.#h==="downloadable"&&this.#s==="local"?this.#b("First message will download the on-device model (~1.6 GB)."):this.#v()}async#_(t){if(this.#r)return this.#r;let e=this.#M(),i=[...e?[{role:"system",content:e}]:[],...p(this.#d)],n=i.length?i:void 0;return this.#r=await LanguageModel.create({initialPrompts:n,signal:t,expectedInputs:[{type:"text",languages:["en"]}],expectedOutputs:[{type:"text",languages:["en"]}],monitor:s=>{s.addEventListener("downloadprogress",a=>{if(a.loaded>=1){this.#h="available",this.#v();return}this.#o("downloading"),this.#b(`Downloading on-device model: ${Math.round(a.loaded*100)}%`)})}}),this.#h="available",this.#v(),this.#r.addEventListener?.("contextoverflow",()=>{this.dispatchEvent(new CustomEvent("ai-chat:context-overflow",{bubbles:!0}))}),this.#r}async#O(t,e){if(this.#n){e.remove();return}if(this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"user",text:t},bubbles:!0})),this.#s==="deep-link"){e.remove(),window.open(this.#B(t),"_blank","noopener,noreferrer");return}if(this.#s==="unavailable"){this.#A(e,"Chat is unavailable in this browser.",{error:!0});return}let i=e.querySelector("chat-bubble");if(!i)return;let n=new AbortController;this.#n=n,this.#o("streaming"),this.#f(),e.setAttribute("aria-busy","true"),this.#p();let s="";try{let a=this.#s==="local"?await this.#R(t,n.signal):C(this.getAttribute("endpoint")||"",{prompt:t,content:this.#u()||void 0,mode:"chat",messages:p(this.#d),signal:n.signal});this.getAttribute("data-state")!=="streaming"&&this.#o("streaming");for await(let o of a)s+=o,i.textContent=s,this.#C();this.#y(e,s||" "),this.#C(),this.#S(t,s),this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"assistant",text:s},bubbles:!0})),this.#o("ready")}catch(a){let o=a;if(o?.name==="AbortError"){s&&this.#S(t,s),this.#y(e,s?`${s} (stopped)`:"(stopped)"),this.#o("ready");return}this.#A(e,o?.message||"Generation failed",{error:!0}),this.#o("error"),this.dispatchEvent(new CustomEvent("ai-chat:error",{detail:{error:a},bubbles:!0}))}finally{e.removeAttribute("aria-busy"),this.#n===n&&(this.#n=null),this.#f()}}#S(t,e){this.#d.push({role:"user",content:t},{role:"assistant",content:e})}#f(){let t=!!this.#n,e=this.#m,i=this.#c;if(!e||!i||i.hidden===!t)return;let n=document.activeElement;e.hidden=t,i.hidden=!t,t&&n===e?i.focus():!t&&n===i&&this.querySelector("chat-input textarea")?.focus()}async#R(t,e){let n=(await this.#_(e)).promptStreaming(t,{signal:e});return(async function*(){for await(let s of n)yield s})()}#y(t,e){let i=t.querySelector("chat-bubble");i&&(i.textContent=e),t.removeAttribute("data-status"),t.removeAttribute("aria-label")}#A(t,e,i={}){this.#y(t,e),i.error&&t.setAttribute("data-status","error")}#C(){this.#i?.scrollToBottom?.()}#o(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-chat:state",{detail:{state:t,provider:this.#s},bubbles:!0}))}#b(t){this.#a&&(this.#a.hidden=!1,this.#a.textContent=t)}#v(){this.#a&&(this.#a.hidden=!0,this.#a.textContent="")}#B(t){let i=(this.getAttribute("fallback-prompt")||_).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title),n=t?`${i}
|
|
26
29
|
|
|
27
|
-
User: ${t}`:
|
|
30
|
+
User: ${t}`:i,s=this.getAttribute("fallback-url"),a=S(s)?this.#u():"";return A(s,{prompt:n,content:a})}};g("ai-chat",f);export{f as AIChat};
|
|
28
31
|
//# sourceMappingURL=ai-chat.js.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
var
|
|
1
|
+
var R=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;function b(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=m.get(n);if(customElements.get(n)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=i){r.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}m.set(n,s),customElements.define(n,t)}var u=class extends HTMLElement{#t=[];#i;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#t.push(()=>t.removeEventListener(e,i,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#i||(this.#i=this.attachInternals());let i=this.#i.states;try{e?i.add(t):i.delete(t)}catch{let s=`--${t}`;e?i.add(s):i.delete(s)}}_adoptInternals(t){this.#i||(this.#i=t)}#e(){return this.constructor.formAssociated&&this.#i?this.#i:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};var T=["available","downloadable","downloading"];async function y(n){let t=typeof globalThis<"u"?globalThis:null;if(!t||!(n in t))return{state:"unsupported"};try{let e=t[n];if(!e||typeof e.availability!="function")return{state:"unsupported"};let i=await e.availability();return i==="available"||i==="downloadable"||i==="downloading"||i==="unavailable"?{state:i}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}function g({availability:n,endpoint:t,fallbackURL:e}){return T.includes(n)?"local":t?"endpoint":e?"deep-link":"unavailable"}var M="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function v(n,{stripSelectors:t=M}={}){if(n==null)return"";let e;if(typeof n=="string"){if(typeof document>"u")return"";try{e=document.querySelector(n)}catch{return""}}else typeof n=="object"&&typeof n.cloneNode=="function"&&(e=n);if(!e)return"";let i=e.cloneNode(!0);return t&&typeof i.querySelectorAll=="function"&&i.querySelectorAll(t).forEach(s=>s.remove()),(i.textContent||"").trim().replace(/\s+/g," ")}var N=/\{(prompt|url|title|content)\}/g;function _(n,t=1500){let e=String(n??"");if(e.length<=t)return e;let i=e.slice(0,Math.max(0,t-1)),s=i.lastIndexOf(" ");return`${s>t*.8?i.slice(0,s):i}\u2026`}function w(n){return typeof n=="string"&&n.includes("{content}")}function E(n,t={},{contentLimit:e=1500}={}){if(!n)return"";let i={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:_(t.content,e)};return String(n).replace(N,(s,r)=>encodeURIComponent(i[r]))}async function*A(n,{prompt:t="",content:e,mode:i,messages:s,signal:r}={}){let o={prompt:t};e!==void 0&&(o.content=e),i!==void 0&&(o.mode=i),Array.isArray(s)&&(o.messages=s);let a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:r});if(!a.ok)throw new Error(`AI endpoint ${n} returned ${a.status} ${a.statusText}`);if((a.headers.get("content-type")||"").toLowerCase().includes("application/json")){let l=await a.json(),c=typeof l?.text=="string"?l.text:"";c&&(yield c);return}if(!a.body||typeof a.body.getReader!="function"){let l=await a.text();l&&(yield l);return}let h=a.body.getReader(),f=new TextDecoder;try{for(;;){let{value:c,done:S}=await h.read();if(S)break;if(c){let p=f.decode(c,{stream:!0});p&&(yield p)}}let l=f.decode();l&&(yield l)}finally{try{h.releaseLock()}catch{}}}var k=16e3;function C(n,t,e){let i=String(n??"");if(!(t>0)||!(e>0)||!Number.isFinite(e)||t<=e)return i;let s=Math.floor(i.length*(e/t)*.95);return i.slice(0,Math.max(0,s))}var L="Summarize this article: {url}",d=class extends u{#t=null;#i=null;#e=null;#o=null;#a=null;#s=null;#r="unavailable";setup(){this.#p(),this.#m()}teardown(){this.#s?.abort(),this.#s=null}stop(){this.#s?.abort()}#p(){let t=this.querySelector(":scope > .ais-ui");if(t){this.#l(t);return}let e=document.createElement("div");e.className="ais-ui",e.innerHTML=`
|
|
2
2
|
<div class="ais-controls">
|
|
3
3
|
<button type="button" class="ais-trigger small" disabled>
|
|
4
4
|
<span class="ais-label">Summarize</span>
|
|
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(
|
|
11
|
+
`,this.prepend(e),this.#l(e)}#l(t){this.#t=t.querySelector(".ais-trigger"),this.#i=t.querySelector(".ais-status"),this.#e=t.querySelector(".ais-output"),this.#o=t.querySelector(".ais-stop"),this.#a=t.querySelector(".ais-notice"),this.listen(this.#t,"click",()=>this.#y()),this.#o&&this.listen(this.#o,"click",()=>this.#s?.abort()),this.listen(this,"keydown",e=>{e.key==="Escape"&&this.#s&&(e.preventDefault(),this.#s.abort())})}async#m(){this.#n("checking");let{state:t}=await y("Summarizer");this.#r=g({availability:t,endpoint:this.getAttribute("endpoint")||void 0,fallbackURL:this.getAttribute("fallback-url")||void 0}),this.#b(t)}#b(t){if(!(!this.#t||!this.#i)){if(this.#C(this.#r==="deep-link"),this.#r==="local"){this.#i.dataset.state=t,this.#i.textContent={available:"Ready (on-device)",downloadable:"Model available \u2014 first run will download",downloading:"Model downloading\u2026"}[t]??t,this.#t.disabled=!1,this.#t.dataset.provider="local",this.#n("ready");return}if(this.#r==="endpoint"){this.#i.dataset.state="available",this.#i.textContent="Ready (remote)",this.#t.disabled=!1,this.#t.dataset.provider="endpoint",this.#n("ready");return}if(this.#r==="deep-link"){this.#i.dataset.state="unavailable",this.#i.textContent="On-device AI unavailable \u2014 using deep-link",this.#t.disabled=!1,this.#t.dataset.provider="deep-link";let e=this.getAttribute("fallback-label")||"Read elsewhere";this.#k(e),this.#n("deep-link");return}this.#i.dataset.state="unavailable",this.#i.textContent="Summarization not available on this device",this.#t.disabled=!0,this.#t.dataset.provider="unavailable",this.#n("unavailable")}}async#y(){if(!this.#t||!this.#e)return;if(this.#r==="deep-link"){window.open(this.#h(),"_blank","noopener,noreferrer");return}if(this.#r==="unavailable")return;this.#e.hidden=!1,this.#e.textContent="",this.#x(),this.#e.setAttribute("aria-busy","true"),this.#n("streaming");let t=new AbortController;this.#s=t,this.#c(!0);let e="";try{let i=this.#u(),s=this.#r==="local"?await this.#g(i,t.signal):A(this.getAttribute("endpoint")||"",{prompt:this.#d(),content:i,mode:"summarize",signal:t.signal});this.getAttribute("data-state")!=="streaming"&&this.#n("streaming");for await(let r of s)e+=r,this.#e.textContent=e;this.#w(e),this.#n("complete"),this.dispatchEvent(new CustomEvent("ai-summary:result",{detail:{text:e,provider:this.#r},bubbles:!0}))}catch(i){if(i&&i.name==="AbortError"){this.#e.textContent=e?`${e} (stopped)`:"(stopped)",this.#n("ready");return}this.#A(i),this.#n("error"),this.dispatchEvent(new CustomEvent("ai-summary:error",{detail:{error:i},bubbles:!0}))}finally{this.#e.removeAttribute("aria-busy"),this.#s===t&&(this.#s=null),this.#c(!1)}}#c(t){if(!this.#t)return;let e=document.activeElement;this.#t.disabled=t,this.#o&&(this.#o.hidden=!t,t&&e===this.#t?this.#o.focus():!t&&e===this.#o&&this.#t.focus())}async#g(t,e){let i=await Summarizer.create({signal:e,type:this.getAttribute("type")||"key-points",format:this.getAttribute("format")||"markdown",length:this.getAttribute("length")||"medium",sharedContext:this.getAttribute("shared-context")||void 0,expectedInputLanguages:["en"],outputLanguage:"en",monitor:o=>{o.addEventListener("downloadprogress",a=>{this.#n("downloading"),this.#i&&(this.#i.textContent=`Downloading model: ${Math.round(a.loaded*100)}%`)})}}),s=t;try{s=await this.#v(i,t,e)}catch(o){throw i.destroy?.(),o}let r=typeof i.summarizeStreaming=="function"?i.summarizeStreaming(s,{signal:e}):(async function*(){yield await i.summarize(s,{signal:e})})();return(async function*(){try{for await(let o of r)yield o}finally{i.destroy?.()}})()}async#v(t,e,i){let s=t?.inputQuota;if(typeof t?.measureInputUsage=="function"&&typeof s=="number"){let r;try{r=await t.measureInputUsage(e,{signal:i})}catch(o){if(o?.name==="AbortError")throw o;r=void 0}if(typeof r=="number"&&r>s){let o=C(e,r,s),a=Math.max(1,Math.round(o.length/e.length*100));return this.#f(`This content is longer than the on-device model accepts; summarizing the first ${a}%.`),o}return e}return e.length>k&&this.#f(`This content is long (${e.length.toLocaleString()} characters) and may exceed the on-device model's limit.`),e}#u(){return v(this,{stripSelectors:".ais-ui"})}#d(){return(this.getAttribute("fallback-prompt")||L).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title)}#h(){let t=this.getAttribute("fallback-url");return E(t,{prompt:this.#d(),content:w(t)?this.#u():""})}#w(t){if(this.#e){if((this.getAttribute("format")||"markdown")==="plain-text"){this.#e.textContent=t;return}this.#E(t)}}#E(t){if(!this.#e)return;if(!t){this.#e.textContent="";return}let e=document.createElement("markdown-viewer");e.setAttribute("sanitize","");let i=document.createElement("pre");i.textContent=t,e.appendChild(i),this.#e.replaceChildren(e)}#A(t){if(!this.#e)return;let e=document.createElement("p");if(e.className="ais-error",e.textContent=`Summarization failed: ${t?.message||t}`,this.#e.replaceChildren(e),this.getAttribute("fallback-url")){let s=document.createElement("p");s.className="ais-fallback";let r=document.createElement("a");r.href=this.#h(),r.target="_blank",r.rel="noopener noreferrer",r.textContent=this.getAttribute("fallback-label")||"Continue elsewhere",r.append(x()),s.append("You can ",r," instead."),this.#e.appendChild(s)}}#n(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-summary:state",{detail:{state:t,provider:this.#r},bubbles:!0}))}#k(t){let e=this.#t?.querySelector(".ais-label");e&&(e.textContent=t)}#C(t){let e=this.#t?.querySelector(".ais-newtab");t&&!e?this.#t?.append(x()):t||e?.remove()}#f(t){this.#a&&(this.#a.textContent=t,this.#a.hidden=!1)}#x(){this.#a&&(this.#a.hidden=!0,this.#a.textContent="")}};function x(){let n=document.createElement("span");return n.className="visually-hidden ais-newtab",n.textContent=" (opens in new tab)",n}b("ai-summary",d);export{d as AISummary};
|
|
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=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[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 J=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function S(e,t,n={}){let s=n.priority??10,i={impl:t,bundle:n.bundle,contract:n.contract,priority:s},o=x.get(e);if(customElements.get(e)){if(!o||o.priority>=s){o&&o.priority===s&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${e}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=s){o.priority===s&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${o.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}x.set(e,i),customElements.define(e,t)}var h=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,n,s,i){t.addEventListener(n,s,i),this.#t.push(()=>t.removeEventListener(n,s,i))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,n){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{n?s.add(t):s.delete(t)}catch{let i=`--${t}`;n?s.add(i):s.delete(i)}}_adoptInternals(t){this.#e||(this.#e=t)}#n(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#n()?.validity}get validationMessage(){return this.#n()?.validationMessage??""}get willValidate(){return this.#n()?.willValidate??!1}get form(){return this.#n()?.form??null}checkValidity(){return this.#n()?.checkValidity()??!0}reportValidity(){return this.#n()?.reportValidity()??!0}};function T(e){let t=!1;try{t=sessionStorage.getItem("vb_optout")==="1"}catch{}let n=!1;if(typeof e?.consent=="function")try{n=e.consent()===!1}catch{n=!0}return{user:t,gpc:navigator.globalPrivacyControl===!0,dnt:navigator.doNotTrack==="1",consent:n}}function L(e){let t=T(e);return t.user?"user":t.gpc?"gpc":t.dnt?"dnt":t.consent?"consent":null}function u(e){return L(e)!==null}function $(e){return e?.closest?.("[data-vb-no-track]")!=null}function M(){let{dataset:e}=document.documentElement,t={};for(let n of Object.keys(e)){let s=e[n];s!=null&&s!==""&&(t[n]=s)}return t}var D=new Set(["track-history","track-history-params","no-track-history"]);function q(){let e={};for(let n of document.querySelectorAll('meta[name^="vb:"]')){let s=n.getAttribute("name")?.slice(3),i=n.getAttribute("content")?.trim();s&&D.has(s)||s&&i&&(e[s]=i)}let t=[];for(let n of document.querySelectorAll('meta[name="concept"]')){let s=n.getAttribute("content")?.trim();s&&t.push(s)}return t.length&&(e.concepts=t),e}function P(e,t){if(!t?.length)return e;for(let{pattern:n,replace:s}of t)if(n.test(e))return e.replace(n,s);return e}function R(e,t){let n=JSON.stringify(t);if(typeof navigator.sendBeacon=="function"){let s=new Blob([n],{type:"application/json"});if(navigator.sendBeacon(e,s))return!0}try{return fetch(e,{method:"POST",body:n,keepalive:!0,headers:{"content-type":"application/json"}}),!0}catch{return!1}}var a={config:null,queue:[]},l={sent:0,logged:0,iframeDisabled:!1},m=Symbol.for("vanilla-breeze.analytics"),v="vb:analytics-status";function p(){try{document.dispatchEvent(new CustomEvent(v))}catch{}}function E(e){return`${(a.config?.endpoint??"/api/analytics").replace(/\/+$/,"")}/${e}`}function g(e,t){let n=a.config;if(!n)throw new Error("analytics: buildEnvelope called before init");let s=P(location.pathname+location.search,n.urlMasks),i=typeof n.context=="function"?n.context()??{}:{};return{name:e,ts:Date.now(),site:n.siteId,path:s,referrer:document.referrer||"",context:{...M(),...q(),...i},props:t??{}}}function b(e,t){let n=a.config;if(!n||n.transport==="disabled")return!1;if(n.transport==="console")return console.log("%c[vb:analytics]","color:#0aa;font-weight:600",e,t),l.logged++,p(),!0;let s=R(E(e),t);return s&&(l.sent++,p()),s}function I(){let e=a.config?.sampleRate??1;return e>=1?!0:Math.random()<e}var _=null;function O(){if(!a.config||u(a.config)||document.documentElement.hasAttribute("data-vb-no-track")||!I())return;let e=location.pathname+location.search;e!==_&&(_=e,b("hit",g("page.view",{})))}function B(){let e,t=()=>{clearTimeout(e),e=setTimeout(O,100)},n=history.pushState.bind(history);history.pushState=function(...i){n(...i),t()};let s=history.replaceState.bind(history);history.replaceState=function(...i){s(...i),t()},window.addEventListener("popstate",t)}function V(e){let t={};for(let[n,s]of Object.entries(e.dataset)){if(n==="vbEvent"||!n.startsWith("vbEvent"))continue;let i=n.slice(7).replace(/^./,o=>o.toLowerCase());t[i]=s}return t}function j(e){if(!a.config||u(a.config))return;let n=e.target?.closest?.("[data-vb-event]");if(!n||$(n))return;let s=n.dataset.vbEvent;s&&w.track(s,V(n))}function C(){let e=document.querySelectorAll('a[href^="http"]');for(let t of e){if(t.hostname===location.hostname||$(t)||t.hasAttribute("data-vb-analytics-wired"))continue;let n=encodeURIComponent(a.config?.siteId??"default"),s=`${E("click")}?site=${n}&from=${encodeURIComponent(location.pathname)}`,i=!t.hasAttribute("ping"),o=()=>{i&&(u(a.config)?t.removeAttribute("ping"):t.setAttribute("ping",s))};t.addEventListener("click",o,{capture:!0}),t.addEventListener("auxclick",o,{capture:!0}),t.addEventListener("click",()=>{if(u(a.config))return;let r=navigator.userAgent;/Firefox|Brave/.test(r)&&b("click",g("link.outbound",{to:t.hostname,href:t.href}))}),t.setAttribute("data-vb-analytics-wired","")}}function y(){if(!a.queue.length)return;let e=a.queue.splice(0);b("events",{site:a.config?.siteId,events:e})}function F(){document.visibilityState==="hidden"&&y()}var U={endpoint:"/api/analytics",siteId:"default",transport:"disabled",sampleRate:1,consent:null,context:null,urlMasks:null,autoPageView:!0,autoOutboundLinks:!0,autoDeclarative:!0,allowInIframe:!1};function H(){try{return window.top!==window.self}catch{return!0}}var w={init(e={}){if(a.config)return;let t={...U,...e};if(a.config=t,globalThis[m]||(globalThis[m]=w),queueMicrotask(p),H()&&!t.allowInIframe){l.iframeDisabled=!0,t.transport="disabled",t.autoPageView=!1,t.autoOutboundLinks=!1,t.autoDeclarative=!1;return}t.transport==="disabled"&&(t.autoOutboundLinks=!1),t.autoDeclarative&&document.addEventListener("click",j,{capture:!0}),t.autoOutboundLinks&&(C(),new MutationObserver(()=>C()).observe(document.body,{childList:!0,subtree:!0})),t.autoPageView&&(O(),B()),document.addEventListener("visibilitychange",F),window.addEventListener("pagehide",y)},track(e,t={}){a.config&&(u(a.config)||I()&&b("hit",g(e,t)))},flush:y,setConsent(e){try{e?sessionStorage.removeItem("vb_optout"):sessionStorage.setItem("vb_optout","1")}catch{}p()},getStatus(){let e=a.config,t=T(e),n=L(e),s=null;if(e)try{s=g("page.view",{})}catch{s=null}let i=e?.transport??null;return{initialized:e!=null,active:e!=null&&i!=="disabled"&&n===null,optedOut:n!==null,reason:n,signals:t,transport:i,inIframe:l.iframeDisabled,endpoint:e?E("hit"):null,siteId:e?.siteId??null,sampleRate:e?.sampleRate??null,outboundLinks:e?.autoOutboundLinks??!1,queued:a.queue.length,sent:l.sent,logged:l.logged,collects:s?Object.keys(s):[],contextKeys:s?Object.keys(s.context):[],preview:s}},get config(){return a.config?{...a.config}:null}};function k(){return globalThis[m]??w}var z="Analytics on this page",G=2;function K(e){let t=Number.parseInt(e??"",10);return Number.isInteger(t)&&t>=1&&t<=6?t:G}var N={gpc:"your browser sends a Global Privacy Control signal",dnt:"your browser sends Do Not Track",consent:"this site has not been given consent to collect analytics"};function W(e){if(!e||!e.initialized)return{state:"off",reason:"uninitialized",text:"Off. The analytics runtime is not running on this page, so nothing is sent."};if(e.inIframe)return{state:"off",reason:"iframe",text:"Off. Analytics does not run inside embedded frames, so nothing is sent."};if(e.reason==="user")return{state:"paused",reason:"user",text:"Paused for this tab. Nothing is being sent."};if(e.reason){let n=N[e.reason];return{state:"off",reason:e.reason,text:`Off because ${n}. Nothing is sent.`}}if(e.transport==="disabled")return{state:"off",reason:"disabled",text:"Off. This site has analytics switched off, so nothing is sent."};if(e.transport==="console")return{state:"debug",reason:null,text:"Debug mode. Events are written to this browser\u2019s console, not sent anywhere."};let t=typeof e.sampleRate=="number"&&e.sampleRate<1?` (a ${Math.round(e.sampleRate*100)}% sample)`:"";return{state:"active",reason:null,text:`Active. Events from this page are sent to ${e.endpoint}${t}.`}}function Y(e){return e?.signals?["gpc","dnt","consent"].filter(t=>e.signals[t]):[]}var A=class extends h{static get observedAttributes(){return["heading","heading-level"]}#t={};setup(){(!this.#t.status||!this.contains(this.#t.status))&&this.#o(),this.listen(this,"click",this.#n),this.listen(document,v,()=>this.refresh()),this.refresh()}attributeChangedCallback(t){this.#t.heading&&(t==="heading"&&(this.#t.heading.textContent=this.#e),t==="heading-level"&&this.#s())}get#e(){return this.getAttribute("heading")||z}get status(){let t=k();return typeof t?.getStatus=="function"?t.getStatus():null}#n=t=>{let n=t.target?.closest?.("[data-analytics-action]");if(!n||!this.contains(n)||n.getAttribute("aria-disabled")==="true")return;let s=n.dataset.analyticsAction;s==="toggle"&&this.#i(),s==="refresh"&&this.refresh()};#i(){let t=!this.status?.signals?.user;k().setConsent(!t),this.dispatchEvent(new CustomEvent(t?"analytics-panel:optout":"analytics-panel:optin",{bubbles:!0,composed:!0})),this.refresh()}#o(){let t=`analytics-panel-${Math.random().toString(36).slice(2,8)}`;this.innerHTML=`
|
|
2
2
|
<header class="analytics-panel__header">
|
|
3
|
-
<
|
|
3
|
+
<h2 data-part="heading"></h2>
|
|
4
4
|
<p class="analytics-panel__status" role="status">
|
|
5
|
-
<span class="analytics-panel__dot
|
|
6
|
-
|
|
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
|
-
<
|
|
12
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
31
|
-
|
|
24
|
+
No cookies and no visitor ID. The only thing stored on this device is
|
|
25
|
+
the pause setting, kept in this tab’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
|
-
|
|
31
|
+
`;for(let n of this.querySelectorAll("[data-part]"))this.#t[n.dataset.part??""]=n;this.#t.heading.textContent=this.#e,this.#s()}#s(){let t=K(this.getAttribute("heading-level")),n={heading:t,"fields-heading":Math.min(t+1,6)};for(let[s,i]of Object.entries(n)){let o=this.#t[s];if(!o||o.localName===`h${i}`)continue;let r=document.createElement(`h${i}`);for(let{name:d,value:c}of o.attributes)r.setAttribute(d,c);r.textContent=o.textContent,o.replaceWith(r),this.#t[s]=r}}refresh(){if(!this.#t.status)return;let t=this.status,n=W(t),s=this.#t;this.setAttribute("data-state",n.state),n.reason?this.setAttribute("data-reason",n.reason):this.removeAttribute("data-reason"),s.status.textContent!==n.text&&(s.status.textContent=n.text),this.#a(t);let i=!!t?.signals?.user,o=Y(t),r=i?"Resume analytics":"Pause analytics";if(s.toggle.textContent!==r&&(s.toggle.textContent=r),s.toggle.setAttribute("aria-pressed",String(i)),i&&o.length>0?s.toggle.setAttribute("aria-disabled","true"):s.toggle.removeAttribute("aria-disabled"),o.length){let c=o.map(f=>N[f]).join(" and ");s.hint.textContent=i?`Resume is unavailable because ${c}.`:`Analytics stays off because ${c}; pausing as well changes nothing.`,s.hint.hidden=!1,s.toggle.setAttribute("aria-describedby",s.hint.id)}else s.hint.textContent="",s.hint.hidden=!0,s.toggle.removeAttribute("aria-describedby")}#a(t){let{data:n,empty:s}=this.#t;if(!t?.initialized||!t.preview){n.hidden=!0,n.replaceChildren(),s.hidden=!1,s.textContent="Nothing to show: the analytics runtime has not started on this page.";return}s.hidden=!0,n.hidden=!1;let i=[["Fields",t.collects.join(", ")],["Page path",t.preview.path],["Referrer",t.preview.referrer||"(none)"],["Page context",t.contextKeys.length?t.contextKeys.join(", "):"(none)"]];t.transport==="beacon"?(i.push(["Sent to",t.endpoint]),i.push(["Sent from this page",String(t.sent)])):t.transport==="console"&&i.push(["Logged on this page",String(t.logged)]),t.queued>0&&i.push(["Waiting to send",String(t.queued)]),t.outboundLinks&&i.push(["Outbound link clicks","Reported (site, page path, destination)"]);let o=document.createDocumentFragment();for(let[r,d]of i){let c=document.createElement("dt");c.textContent=r;let f=document.createElement("dd");f.textContent=d,o.append(c,f)}n.replaceChildren(o)}};S("analytics-panel",A);export{W as describeStatus,K as headingLevel};
|
|
34
32
|
//# sourceMappingURL=analytics-panel.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
<style>${this.#
|
|
1
|
+
var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(i,t,e={}){let r=e.priority??10,a={impl:t,bundle:e.bundle,contract:e.contract,priority:r},s=c.get(i);if(customElements.get(i)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}c.set(i,a),customElements.define(i,t)}var o=class extends HTMLElement{#t=[];#e;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,a){t.addEventListener(e,r,a),this.#t.push(()=>t.removeEventListener(e,r,a))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let a=`--${t}`;e?r.add(a):r.delete(a)}}_adoptInternals(t){this.#e||(this.#e=t)}#r(){return this.constructor.formAssociated&&this.#e?this.#e:null}get validity(){return this.#r()?.validity}get validationMessage(){return this.#r()?.validationMessage??""}get willValidate(){return this.#r()?.willValidate??!1}get form(){return this.#r()?.form??null}checkValidity(){return this.#r()?.checkValidity()??!0}reportValidity(){return this.#r()?.reportValidity()??!0}};function l(i){return[...i.querySelectorAll("li")].filter(t=>t.querySelector("a[href]"))}function h(i){return i.querySelector("li[data-audio-active]")}function p(i,t,e){let r=e.querySelector("a[href]");return r?(t.querySelectorAll("li[data-audio-active]").forEach(a=>{a!==e&&a.removeAttribute("data-audio-active")}),e.setAttribute("data-audio-active",""),i.src=r.href,i.play()?.catch(()=>{}),{src:r.href,title:r.textContent?.trim()??""}):null}function f(i){let t=h(i);return t?.setAttribute("data-audio-played",""),t}function m(i,{loop:t=!1}={}){let e=l(i);if(!e.length)return null;let r=h(i),a=r?e.indexOf(r):-1;return a+1<e.length?e[a+1]:t?e[0]:null}var v='input, button, a[href], summary, select, textarea, audio, [contenteditable]:not([contenteditable="false"])',u=class extends o{static get observedAttributes(){return["loop","shuffle"]}#t=null;#e=null;#r=!1;#T=null;#s=null;#i=null;#m=null;#n=null;#x=null;#w=null;#a=null;#c=null;#o=null;#d=!1;#l=new Set;#k=null;#v=!1;setup(){if(this.#t=this.querySelector("audio"),!this.#t)return!1;this.#e=this.querySelector(".track-list"),this.#t.removeAttribute("controls");let t=!this.shadowRoot;this.#_(),t&&(this.#L(),this.#q(),this.#$()),this.#g(),this.#A(),this.#u();let e=this.#t;return(e.error||e.networkState===HTMLMediaElement.NETWORK_NO_SOURCE&&(e.hasAttribute("src")||e.querySelector("source")))&&this.#E(),e.readyState>=HTMLMediaElement.HAVE_METADATA&&(this.#y(),this.#h()),this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{}),this.#k=()=>{let r=this.shadowRoot?.querySelector(".player");r&&(r.style.display="none",r.offsetHeight,r.style.display="")},this.listen(window,"vb:theme-change",this.#k),!0}teardown(){this.#t&&this.#t.setAttribute("controls","")}attributeChangedCallback(t){t==="loop"?this.#A():t==="shuffle"&&this.#l.clear()}#A(){this.#t&&(this.hasAttribute("loop")&&!this.#e?(this.#t.loop=!0,this.#v=!0):this.#v&&(this.#t.loop=!1,this.#v=!1))}get src(){return this.#t?.getAttribute("src")||this.#t?.currentSrc||""}set src(t){if(!this.#t)return;let e=t==null?"":String(t);this.#t.getAttribute("src")!==e&&(this.#t.setAttribute("src",e),this.#t.load?.(),this.#N(),this.#g(),this.dispatchEvent(new CustomEvent("audio-player:src-changed",{detail:{src:e,source:"property"},bubbles:!0})))}get currentTime(){return this.#t?.currentTime??0}set currentTime(t){this.#t&&(this.#t.currentTime=Number(t)||0)}#_(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
2
|
+
<style>${this.#M()}</style>
|
|
3
3
|
<div part="player" class="player">
|
|
4
|
-
<div part="controls" class="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.#
|
|
46
|
+
`,this.#T=t.querySelector(".controls"),this.#s=t.querySelector(".play-btn"),this.#i=t.querySelector(".timeline"),this.#m=t.querySelector(".timeline-fill"),this.#n=t.querySelector(".volume"),this.#x=t.querySelector(".current-time"),this.#w=t.querySelector(".duration"),this.#a=t.querySelector(".track-title"),this.#c=t.querySelector(".mute-btn"),this.#o=t.querySelector(".error")}#M(){return`
|
|
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
|
-
`}#
|
|
349
|
+
`}#L(){this.#t.addEventListener("timeupdate",()=>this.#h()),this.#t.addEventListener("loadedmetadata",()=>{this.#C(),this.#y(),this.#h()}),this.#t.addEventListener("emptied",()=>{this.#y(),this.#h()}),this.#t.addEventListener("volumechange",()=>this.#u()),this.#t.addEventListener("error",t=>{let e=t.target;if(e!==this.#t){if(e.localName!=="source"||this.#t.hasAttribute("src"))return;let r=e.nextElementSibling;for(;r&&r.localName!=="source";)r=r.nextElementSibling;if(r)return}this.#E()},!0),this.#t.addEventListener("play",()=>{this.#r=!0,this.setAttribute("state","playing"),this.#s.setAttribute("aria-label","Pause"),this.#f("audio-player:play",{currentTime:this.#t.currentTime,src:this.#t.currentSrc})}),this.#t.addEventListener("pause",()=>{this.#r=!1,this.setAttribute("state","paused"),this.#s.setAttribute("aria-label","Play"),this.#f("audio-player:pause",{currentTime:this.#t.currentTime})}),this.#t.addEventListener("ended",()=>{this.#r=!1,this.setAttribute("state","ended"),this.#s.setAttribute("aria-label","Play"),this.#e&&(f(this.#e),this.#V()),this.#f("audio-player:ended",{src:this.#t.currentSrc})})}#E(){this.setAttribute("data-state","error"),this.#o.textContent=`Audio could not be loaded${this.#a.textContent?`: ${this.#a.textContent}`:""}.`,this.#o.hidden=!1}#C(){this.getAttribute("data-state")==="error"&&this.removeAttribute("data-state"),this.#o.hidden=!0,this.#o.textContent=""}#u(){if(!this.#t||!this.#c)return;let t=this.#t.muted;t?this.setAttribute("muted",""):this.removeAttribute("muted"),this.#c.setAttribute("aria-pressed",String(t)),this.#n.style.setProperty("--_vol",t?"0":this.#n.value)}#q(){this.#s.addEventListener("click",()=>{this.#r?this.#t.pause():this.#t.play().catch(()=>{})}),this.#i.addEventListener("input",()=>{let e=Number(this.#i.value);this.#m.style.width=`${e}%`,this.#t.duration&&(this.#t.currentTime=e/100*this.#t.duration,this.#S(this.#t.currentTime,this.#t.duration))}),this.#i.addEventListener("pointerdown",()=>{this.#d=!0,this.setState("scrub-active",!0)});let t=()=>{this.#d&&(this.#d=!1,this.setState("scrub-active",!1))};this.#i.addEventListener("pointerup",t),this.#i.addEventListener("pointercancel",t),this.#i.addEventListener("change",t),this.#n.addEventListener("input",()=>{this.#t.volume=Number(this.#n.value),this.#t.muted=!1,this.#u()}),this.#c.addEventListener("click",()=>{this.#t.muted=!this.#t.muted,this.#u()}),this.addEventListener("keydown",e=>{if(!(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey)&&!this.#z(e))switch(e.key){case" ":e.preventDefault(),this.#r?this.#t.pause():this.#t.play().catch(()=>{});break;case"ArrowLeft":e.preventDefault(),this.#t.currentTime=Math.max(0,this.#t.currentTime-10);break;case"ArrowRight":e.preventDefault(),this.#t.currentTime=Math.min(this.#t.duration||0,this.#t.currentTime+10);break;case"m":case"M":this.#t.muted=!this.#t.muted,this.#u();break}}),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Audio player"),this.hasAttribute("aria-keyshortcuts")||this.setAttribute("aria-keyshortcuts","Space ArrowLeft ArrowRight M")}#z(t){for(let e of t.composedPath()){if(e===this)return!1;if(e instanceof Element&&e.matches(v))return!0}return!1}#$(){this.#e&&this.#e.addEventListener("click",t=>{let r=t.target?.closest("a[href]"),a=r?.closest("li");!r||!a||(t.preventDefault(),this.#b(a))})}#b(t){if(!this.#e)return;let e=p(this.#t,this.#e,t);e&&(this.#l.add(t),this.#g(),this.#f("audio-player:track-change",e))}#N(){if(!this.#e)return;let t=this.#t.src,e=l(this.#e).find(r=>r.querySelector("a[href]").href===t);this.#e.querySelectorAll("li[data-audio-active]").forEach(r=>{r!==e&&r.removeAttribute("data-audio-active")}),e?.setAttribute("data-audio-active","")}#V(){if(!this.#e)return;let t=this.hasAttribute("loop");if(!this.hasAttribute("shuffle")){let n=m(this.#e,{loop:t});n&&this.#b(n);return}let e=l(this.#e),r=this.#e.querySelector("li[data-audio-active]");r&&this.#l.add(r);let a=e.filter(n=>!this.#l.has(n));if(!a.length){if(this.#l.clear(),!t)return;a=e.length>1?e.filter(n=>n!==r):e}let s=a[Math.floor(Math.random()*a.length)];s&&this.#b(s)}#h(){let t=this.#t.currentTime,e=this.#t.duration||0,r=e?t/e*100:0;this.#x.textContent=this.#p(t),this.#S(t,e),!this.#d&&(this.#i.value=String(r),this.#m.style.width=`${r}%`)}#S(t,e){this.#i.setAttribute("aria-valuetext",`${this.#p(t)} of ${this.#p(e)}`)}#y(){let t=this.#t.duration||0;this.#w.textContent=this.#p(t)}#g(){if(!this.#a)return;if(this.#e){let r=this.#e.querySelector("li[data-audio-active] a");if(r){this.#a.textContent=r.textContent;return}}let t=this.#t.src||this.#t.currentSrc||this.#t.querySelector("source")?.src||"",e=t?t.split("/").pop().split(/[?#]/)[0]:"";this.#a.textContent=e.replace(/\.[^.]+$/,"").replace(/[-_]/g," ")}#p(t){if(!Number.isFinite(t))return"0:00";let e=Math.floor(t/60),r=Math.floor(t%60).toString().padStart(2,"0");return`${e}:${r}`}#f(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}};d("audio-player",u);export{u as AudioPlayerElement};
|
|
340
350
|
//# sourceMappingURL=audio-player.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
1
|
+
var T=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;function M(r,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=w.get(r);if(customElements.get(r)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}w.set(r,n),customElements.define(r,t)}var d=class extends HTMLElement{#t=[];#r;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,n){t.addEventListener(e,i,n),this.#t.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#r||(this.#r=this.attachInternals());let i=this.#r.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#r||(this.#r=t)}#s(){return this.constructor.formAssociated&&this.#r?this.#r:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var m=new Map;function C(){if(!m.has("default"))try{m.set("default",new AudioContext)}catch{return null}return m.get("default")}var f=new WeakMap;function z(r,t){if(f.has(r))return f.get(r);let e=t.createMediaElementSource(r);return e.connect(t.destination),f.set(r,e),e}function A(r){let t=Number.parseInt(r??"",10);if(!Number.isFinite(t)||t<=0)return 256;let e=2**Math.round(Math.log2(t));return Math.min(32768,Math.max(32,e))}function L(r){if(r.crossOrigin!=null)return!1;let t=r.currentSrc||r.src||r.querySelector("source[src]")?.src||"";if(!t)return!1;try{let e=new URL(t,location.href);return e.protocol==="data:"||e.protocol==="blob:"?!1:e.origin!==location.origin}catch{return!1}}var E=new WeakSet,O=new Set(["bars","waveform","circle"]);function S(r){return r&&O.has(r)?r:"bars"}var b="oklch(55% 0.2 260)",$=new Uint8Array(256).fill(128),q=new Uint8Array(128),y=class extends d{#t=null;#r=null;#s=null;#e=null;#h=null;#u=new Uint8Array(0);#d=new Uint8Array(0);#f=b;#m="";#g="bars";#i=null;#p=null;#v=null;#b=!0;#o=!1;#c=!1;#n=null;#l=()=>this.#S();static get observedAttributes(){return["for","data-mode","data-fft-size"]}setup(){if(this.#c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.#g=S(this.getAttribute("data-mode")),this.#C(),this.#M(),this.#A(),this.#q(),this.#T(),this.#_(),this.#o&&this.#h&&this.#e){try{this.#h.connect(this.#e)}catch{}this.#y()}let t=()=>requestAnimationFrame(()=>{this.#M(),this.#i||this.#a()});this.listen(window,"vb:theme-change",t),this.listen(window.matchMedia("(prefers-color-scheme: dark)"),"change",t)}teardown(){this.#w(),this.#p?.disconnect(),this.#v?.disconnect(),this.#n?.removeEventListener("play",this.#l),this.#n=null,this.#E()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="data-mode"){this.#g=S(i),this.isConnected&&!this.#i&&this.#a();return}this.isConnected&&(t==="for"?this.#A():t==="data-fft-size"&&this.#e&&(this.#e.fftSize=A(i),this.#k(),this.#i||this.#a()))}}#C(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
display: block;
|
|
5
|
-
--_color: var(--audio-visualizer-color, var(--color-primary,
|
|
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.#
|
|
19
|
+
`,this.#t=t.querySelector("canvas"),this.#r=this.#t.getContext("2d")}#M(){let t=getComputedStyle(this);this.#f=t.getPropertyValue("--_color").trim()||b,this.#m=t.getPropertyValue("--_bg").trim()}#A(){let t=this.getAttribute("for"),e=t?document.getElementById(t):null,i=e?.tagName==="AUDIO"?e:null;if(this.#s&&this.#s!==i&&(this.#w(),this.#E(),this.#e=null,this.#h=null,this.#o=!1,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#a()),this.#s=i,!i){this.#n?.removeEventListener("play",this.#l),this.#n=null;return}this.#o||(this.#n!==i&&(this.#n?.removeEventListener("play",this.#l),i.addEventListener("play",this.#l),this.#n=i),i.paused||this.#S())}#E(){if(this.#h&&this.#e)try{this.#h.disconnect(this.#e)}catch{}}#S(){if(this.#o||!this.#s)return;let t=this.#s;if(!f.has(t)&&L(t)){this.setAttribute("data-state","cross-origin"),E.has(t)||(E.add(t),console.warn('<audio-visualizer>: not visualising a cross-origin <audio> without crossorigin="anonymous" and CORS headers \u2014 hooking it would mute playback.',t));return}let e=C();if(!e)return;let i,n;try{i=e.createAnalyser(),i.fftSize=A(this.getAttribute("data-fft-size")),i.smoothingTimeConstant=.8,n=z(t,e),n.connect(i)}catch(s){this.setAttribute("data-state","error"),console.warn("<audio-visualizer>: could not connect to the audio element.",s);return}this.#e=i,this.#h=n,this.#k(),this.#o=!0,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#n?.removeEventListener("play",this.#l),this.#n=null,e.state==="suspended"&&e.resume().catch(()=>{}),this.#y()}#k(){this.#e&&(this.#u.length!==this.#e.frequencyBinCount&&(this.#u=new Uint8Array(this.#e.frequencyBinCount)),this.#d.length!==this.#e.fftSize&&(this.#d=new Uint8Array(this.#e.fftSize)))}#y(){if(this.#i)return;if(this.#c){this.#a();return}let t=()=>{if(!this.#b||this.#c){this.#i=null;return}this.#i=requestAnimationFrame(t),this.#a()};this.#i=requestAnimationFrame(t)}#w(){this.#i&&(cancelAnimationFrame(this.#i),this.#i=null)}#z(){let t=window.devicePixelRatio||1,e=Math.round(this.#t.clientWidth*t),i=Math.round(this.#t.clientHeight*t);this.#t.width!==e&&(this.#t.width=e),this.#t.height!==i&&(this.#t.height=i)}#a(){let t=this.#r;if(!t)return;let e=this.#t.width,i=this.#t.height;if(!e||!i)return;t.clearRect(0,0,e,i),this.#m&&this.#m!=="transparent"&&(t.fillStyle=this.#m,t.fillRect(0,0,e,i));let n=this.#o?this.#e:null,s=this.#g;if(s==="waveform"){n&&n.getByteTimeDomainData(this.#d),this.#O(t,e,i,this.#f,n?this.#d:$);return}n&&n.getByteFrequencyData(this.#u);let h=n?this.#u:q;s==="circle"?this.#$(t,e,i,this.#f,h):this.#L(t,e,i,this.#f,h)}#L(t,e,i,n,s){let h=Math.min(s.length,64),o=e/h,c=Math.max(1,o-1),u=Math.max(1,Math.round(i*.03));t.fillStyle=n;for(let a=0;a<h;a++){let l=Math.max(u,s[a]/255*i);t.fillRect(a*o,i-l,c,l)}}#O(t,e,i,n,s){let h=e/Math.max(1,s.length-1);t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let o=0;o<s.length;o++){let c=s[o]/255*i;o===0?t.moveTo(0,c):t.lineTo(o*h,c)}t.stroke()}#$(t,e,i,n,s){let h=e/2,o=i/2,c=Math.min(e,i)*.25,u=s.length;t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let a=0;a<u;a++){let l=a/u*Math.PI*2,k=s[a]/255*(c*.8),g=c+k,p=h+g*Math.cos(l),v=o+g*Math.sin(l);a===0?t.moveTo(p,v):t.lineTo(p,v)}t.closePath(),t.stroke()}#q(){this.#p??=new IntersectionObserver(([t])=>{this.#b=t.isIntersecting,this.#b&&this.#o&&!this.#i&&!this.#c&&this.#y()}),this.#p.observe(this)}#T(){this.#v??=new ResizeObserver(()=>{this.#z(),this.#i||this.#a()}),this.#v.observe(this.#t)}#_(){let t=window.matchMedia("(prefers-reduced-motion: reduce)");this.listen(t,"change",e=>{this.#c=e.matches,this.#c?(this.#w(),this.#a()):this.#o&&this.#b&&!this.#i&&this.#y()})}};M("audio-visualizer",y);export{y as AudioVisualizerElement};
|
|
20
20
|
//# sourceMappingURL=audio-visualizer.js.map
|