vanilla-breeze 0.6.2 → 0.7.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/dist/cdn/components/accordion-wc.js +1 -1
- package/dist/cdn/components/activity-feed.js +1 -1
- package/dist/cdn/components/ai-chat.js +6 -6
- package/dist/cdn/components/ai-summary.js +2 -2
- package/dist/cdn/components/analytics-panel.js +2 -2
- package/dist/cdn/components/audio-player.js +4 -4
- package/dist/cdn/components/audio-visualizer.js +2 -2
- 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 -1
- package/dist/cdn/components/chart-wc.js +13 -13
- 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 +35 -35
- package/dist/cdn/components/comment-thread.js +38 -38
- 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 +3 -3
- 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 +2 -2
- package/dist/cdn/components/icon-wc.js +2 -2
- 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 +58 -54
- package/dist/cdn/components/markdown-editor.js +25 -25
- package/dist/cdn/components/markdown-viewer.js +27 -27
- package/dist/cdn/components/nav-bar.js +1 -1
- package/dist/cdn/components/note-wc.js +2 -2
- package/dist/cdn/components/notification-wc.js +23 -23
- package/dist/cdn/components/page-info.js +6 -6
- 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 -1
- 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 -1
- 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/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +1 -1
- package/dist/cdn/components/score-card.js +2 -2
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/settings-panel.js +6 -6
- 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 -1
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +1 -1
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/social-links.js +2 -0
- 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 +20 -20
- package/dist/cdn/components/time-index.js +1 -1
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +2 -2
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +4 -4
- package/dist/cdn/components/trust-filter.js +1 -1
- package/dist/cdn/components/version-switcher.js +6 -6
- package/dist/cdn/components/video-player.js +4 -4
- package/dist/cdn/components/watch-wc.js +2 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/fonts/barlow-condensed-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/barlow-condensed-latin-ext-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/dm-serif-display-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/exo-2-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/inter-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/jetbrains-mono-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/josefin-sans-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/lora-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/merriweather-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-ext-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii/fonts/nunito-latin-wght-italic.woff2 +0 -0
- package/dist/cdn/packs/kawaii.full.css +1 -1
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +4 -4
- package/dist/cdn/packs/prototype.full.js +1 -1
- package/dist/cdn/packs/ui.full.js +19 -19
- package/dist/cdn/themes/8bit.tokens.json +8 -37
- 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 +3 -6
- package/dist/cdn/themes/art-deco-dark.tokens.json +3 -27
- package/dist/cdn/themes/art-deco.css +1 -1
- package/dist/cdn/themes/art-deco.tokens.json +5 -11
- package/dist/cdn/themes/bauhaus-dark.tokens.json +1 -1
- package/dist/cdn/themes/bauhaus.css +1 -1
- package/dist/cdn/themes/bauhaus.tokens.json +13 -7
- package/dist/cdn/themes/brutalist-dark.tokens.json +3 -27
- package/dist/cdn/themes/brutalist.tokens.json +5 -11
- 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 +41 -41
- package/dist/cdn/themes/classic.tokens.json +25 -31
- package/dist/cdn/themes/claymorphism-dark.tokens.json +533 -161
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/claymorphism.tokens.json +531 -135
- package/dist/cdn/themes/clinical-dark.tokens.json +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 +5 -11
- package/dist/cdn/themes/dawn-dark.tokens.json +3 -27
- package/dist/cdn/themes/dawn.css +1 -1
- package/dist/cdn/themes/dawn.tokens.json +1 -1
- package/dist/cdn/themes/dracula.tokens.json +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.tokens.json +19 -16
- 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 +233 -116
- package/dist/cdn/themes/glassmorphism.css +1 -1
- package/dist/cdn/themes/glassmorphism.tokens.json +233 -116
- package/dist/cdn/themes/government-dark.tokens.json +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 +1 -1
- package/dist/cdn/themes/high-noon.tokens.json +1 -1
- package/dist/cdn/themes/journal-dark.tokens.json +3 -27
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +21 -21
- 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 +2 -14
- package/dist/cdn/themes/manifest.json +25 -25
- package/dist/cdn/themes/midnight.tokens.json +1 -1
- package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
- package/dist/cdn/themes/minimal.tokens.json +25 -27
- package/dist/cdn/themes/modern-dark.tokens.json +41 -41
- package/dist/cdn/themes/modern.css +1 -1
- package/dist/cdn/themes/modern.tokens.json +21 -21
- package/dist/cdn/themes/nes-dark.tokens.json +3 -27
- package/dist/cdn/themes/nes.tokens.json +10 -39
- package/dist/cdn/themes/neumorphism-dark.tokens.json +266 -134
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/neumorphism.tokens.json +266 -134
- package/dist/cdn/themes/nord-dark.tokens.json +3 -27
- package/dist/cdn/themes/nord.css +1 -1
- package/dist/cdn/themes/nord.tokens.json +1 -1
- package/dist/cdn/themes/organic-dark.tokens.json +1 -1
- package/dist/cdn/themes/organic.tokens.json +5 -14
- 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.tokens.json +1 -1
- package/dist/cdn/themes/solarized-dark.tokens.json +1 -1
- package/dist/cdn/themes/solarized.tokens.json +1 -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 +6 -30
- package/dist/cdn/themes/super2026.css +1 -1
- package/dist/cdn/themes/super2026.tokens.json +1 -1
- package/dist/cdn/themes/swiss-dark.tokens.json +4 -40
- package/dist/cdn/themes/swiss.tokens.json +34 -68
- package/dist/cdn/themes/terminal.tokens.json +286 -120
- package/dist/cdn/themes/tokyo-night-dark.tokens.json +3 -27
- package/dist/cdn/themes/tokyo-night.css +1 -1
- package/dist/cdn/themes/tokyo-night.tokens.json +1 -1
- package/dist/cdn/themes/vaporwave-dark.tokens.json +3 -27
- package/dist/cdn/themes/vaporwave.tokens.json +1 -1
- package/dist/cdn/themes/win9x-dark.tokens.json +5 -29
- package/dist/cdn/themes/win9x.tokens.json +9 -9
- package/dist/cdn/vanilla-breeze-autoload.js +113 -108
- package/dist/cdn/vanilla-breeze-charts.js +13 -13
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +80 -75
- package/dist/cdn/vanilla-breeze-extras.js +31 -31
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +133 -133
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(o){return document.startViewTransition?document.startViewTransition(o):o()}var E=window.matchMedia("(prefers-reduced-motion: reduce)");var h=new Map;function f(o,e,r={}){let s=r.priority??10,t={impl:e,bundle:r.bundle,contract:r.contract,priority:s},n=h.get(o);if(customElements.get(o)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==e&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${r.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${r.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}". Skipping "${r.bundle}" (first wins at equal priority).`);return}h.set(o,t),customElements.define(o,e)}var d=class extends HTMLElement{#e=[];#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 e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,r,s,t){e.addEventListener(r,s,t),this.#e.push(()=>e.removeEventListener(r,s,t))}_reinit(){for(let e of this.#e)e();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,r){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{r?s.add(e):s.delete(e)}catch{let t=`--${e}`;r?s.add(t):s.delete(t)}}_adoptInternals(e){this.#t||(this.#t=e)}#r(){return this.constructor.formAssociated&&this.#t?this.#t: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}};var p=0,m=6,l=class extends d{#e=[];#t=[];#r=[];#n=!1;#s=new WeakSet;setup(){return this.#e=[...this.querySelectorAll(":scope > details")],this.#t=this.#e.map(e=>e.querySelector("summary")),this.#e.length===0?!1:(this.#o(),this.#c(),this.#a(),!0)}teardown(){this.#e=[],this.#t=[],this.#r=[],this.#n=!1}get panels(){return this.#e.map((e,r)=>({id:e.id||void 0,summary:e.querySelector("summary")?.textContent?.trim()||`Panel ${r+1}`,content:this.#r[r]?.innerHTML||"",open:e.hasAttribute("open")}))}set panels(e){let r=Array.isArray(e)?e:[],t=this.hasAttribute("single")?`acc-${++p}`:null;for(;this.firstChild;)this.firstChild.remove();for(let n of r){let i=document.createElement("details");n.id&&(i.id=n.id),n.open&&i.setAttribute("open",""),t&&i.setAttribute("name",t);let a=document.createElement("summary");a.textContent=n.summary||"",i.appendChild(a);let u=document.createElement("div");u.innerHTML=n.content||"",i.appendChild(u),this.appendChild(i)}this._reinit(),this.dispatchEvent(new CustomEvent("accordion-wc:panels-changed",{detail:{panels:r,source:"property"},bubbles:!0}))}#o(){this.#r=this.#e.map(e=>{let r=e.querySelector("summary");if(!r)return null;let s=[...e.children].filter(t=>t!==r);if(s.length===1&&s[0].localName==="div")return s[0];if(s.length>=1){let t=document.createElement("div");for(let n of s)t.appendChild(n);return e.appendChild(t),t}return null})}#a(){if(!this.hasAttribute("transition")||!document.startViewTransition)return;this.#n=!0;let e=++p,r=this.getAttribute("transition")||"fade",s=r==="slide"?"vt-accordion-slide":r==="scale"?"vt-accordion-scale":"vt-accordion";this.#r.forEach((t,n)=>{t&&(t.style.viewTransitionName=`accordion-${e}-${n}`,t.style.viewTransitionClass=s)})}#i(e){c(()=>{e.open=!e.open})}#c(){let e=this.#e.length<=m;this.#e.forEach((r,s)=>{let t=this.#t[s],n=this.#r[s];if(t){if(n){let i=t.id||`accordion-heading-${crypto.randomUUID().slice(0,8)}`,a=n.id||`accordion-panel-${crypto.randomUUID().slice(0,8)}`;t.id=i,n.id=a,t.setAttribute("aria-expanded",r.open?"true":"false"),t.setAttribute("aria-controls",a),e?(n.setAttribute("aria-labelledby",i),n.setAttribute("role","region"),this.#s.add(n)):this.#s.has(n)&&(n.removeAttribute("role"),n.removeAttribute("aria-labelledby"),this.#s.delete(n))}else t.setAttribute("aria-expanded",r.open?"true":"false");this.listen(t,"click",i=>{this.#n&&(i.preventDefault(),this.#i(r))}),this.listen(t,"keydown",i=>this.#l(i,s)),this.listen(r,"toggle",()=>this.#d(r,s))}})}#d(e,r){this.#t[r].setAttribute("aria-expanded",e.open?"true":"false"),this.hasAttribute("single")&&e.open&&this.#e.forEach((t,n)=>{n!==r&&t.open&&(t.open=!1,this.#t[n].setAttribute("aria-expanded","false"))}),this.dispatchEvent(new CustomEvent("accordion-wc:toggle",{detail:{index:r,open:e.open},bubbles:!0}))}#l(e,r){let{key:s}=e,t;switch(s){case"ArrowDown":t=(r+1)%this.#e.length;break;case"ArrowUp":t=(r-1+this.#e.length)%this.#e.length;break;case"Home":t=0;break;case"End":t=this.#e.length-1;break;default:return}e.preventDefault(),this.#t[t].focus()}open(e){e<0||e>=this.#e.length||(this.#n&&!this.#e[e].open?c(()=>{this.#e[e].open=!0}):this.#e[e].open=!0)}close(e){e<0||e>=this.#e.length||(this.#n&&this.#e[e].open?c(()=>{this.#e[e].open=!1}):this.#e[e].open=!1)}toggle(e){e<0||e>=this.#e.length||(this.#n?this.#i(this.#e[e]):this.#e[e].open=!this.#e[e].open)}openAll(){this.hasAttribute("single")||this.#e.forEach(e=>{e.open=!0})}closeAll(){this.#e.forEach(e=>{e.open=!1})}};f("accordion-wc",l);export{l as AccordionWc};
|
|
2
2
|
//# sourceMappingURL=accordion-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var 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};
|
|
1
|
+
var O=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 f=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 v(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 h=typeof document<"u"?document.documentElement:null,g;function E(){v(),g||(g=setInterval(()=>v(),6e4))}h&&!h.hasAttribute("data-vb-time-relative-init")&&(h.setAttribute("data-vb-time-relative-init",""),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E,{once:!0}):E());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 S(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 $(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 A(s){return s.nodeType===1&&s.matches("article[data-activity]")}function M(s){return`Week of ${s.replace("-W",", week ")}`}var C='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"])',T=0,b=class extends f{static observedAttributes=["data-infinite"];#i=null;#t=null;#e=null;#a=null;#s=null;#d=`activity-feed-${++T}`;#g=0;#r=!1;#l=0;#u=!0;setup(){let t=this.getAttribute("role");return this.#u=t===null||t==="feed"||t==="group",!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label","Recent activity"),this.#r=!1,this.setAttribute("aria-busy","false"),this.#n().forEach(i=>this.#f(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)A(o)&&(this.#f(o),e=!0,r=!0);for(let o of n.removedNodes)A(o)&&(e=!0)}e&&(this.#o(),this.#p()),r&&this.#r&&this.#c()}),this.#i.observe(this,{childList:!0}),this.#a=setInterval(()=>this.#E(),6e4),this.listen(this,"keydown",this.#$),this.listen(this,"focusin",this.#S),!0}teardown(){this.#a!==null&&clearInterval(this.#a),this.#a=null,this.#i?.disconnect(),this.#i=null,this.#v(),this.#r=!1,this.setAttribute("aria-busy","false")}attributeChangedCallback(t,i,e){!this.hasAttribute("data-upgraded")||i===null==(e===null)||t==="data-infinite"&&(e!==null?this.#y():(this.#v(),this.#r&&this.#c()),this.#o())}#n(){return[...this.querySelectorAll(":scope > article[data-activity]")]}#f(t){if(t.dataset.decorated==="")return;t.dataset.decorated="",t.setAttribute("tabindex","-1");let i=`${this.#d}-e${++this.#g}`,e=t.querySelector(":scope > time[datetime]");e?.remove();let 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,d=t.dataset.activityIcon;if(o||d){let a=document.createElement("div");if(a.className="activity-rail",a.setAttribute("aria-hidden","true"),o){let c=document.createElement("user-avatar"),l=document.createElement("img");l.src=o,l.alt="",l.loading="lazy",l.decoding="async",c.appendChild(l),a.appendChild(c)}else{let c=document.createElement("icon-wc");c.setAttribute("name",d||""),a.appendChild(c)}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.#A(r)),a.textContent=u(new Date(r))||a.textContent||r,t.appendChild(a)}}#E(){for(let t of this.querySelectorAll(":scope > article[data-activity] > time.activity-time")){let i=t.getAttribute("datetime");if(!i)continue;let e=u(new Date(i));e&&(t.textContent=e)}}#A(t){try{return new Date(t).toLocaleString()}catch{return t}}#o(){this.querySelectorAll(":scope > [data-activity-heading]").forEach(n=>n.remove());let t=this.#n(),i=this.#t?"-1":String(t.length),e=this.getAttribute("data-group")||"none",r=null;t.forEach((n,o)=>{n.setAttribute("aria-posinset",String(o+1)),n.setAttribute("aria-setsize",i);let d=[];if(e!=="none"&&n.dataset.time){let c=e==="week"?S(n.dataset.time):m(n.dataset.time);if(c!==r){let l=document.createElement("h3");l.setAttribute("data-activity-heading",""),l.setAttribute("aria-hidden","true"),l.id=`${this.#d}-g-${c}`,l.className="activity-heading",l.textContent=e==="week"?M(c):$(c),this.insertBefore(l,n),d.push(l.id),r=c}}let a=n.querySelector(":scope > time.activity-time");a?.id&&d.push(a.id),d.length?n.setAttribute("aria-describedby",d.join(" ")):n.removeAttribute("aria-describedby")}),this.#w(),this.#h()}#h(){let t=this.#t;t&&t.parentNode===this&&this.lastElementChild!==t&&this.appendChild(t)}#w(){let t=this.#n(),i=t.find(e=>e.getAttribute("tabindex")==="0")||t[0];for(let e of t)e.setAttribute("tabindex",e===i?"0":"-1")}#m(t){for(let i of this.#n())i.setAttribute("tabindex",i===t?"0":"-1")}#b(t){let e=(t instanceof Element?t:null)?.closest("article[data-activity]")??null;return e&&e.parentElement===this?e:null}#S=t=>{let i=this.#b(t.target);i&&i.getAttribute("tabindex")!=="0"&&this.#m(i)};#p(){let t=this.#n().length;t===0?this.#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.#h()):(this.#s?.remove(),this.#s=null),this.#u&&this.setAttribute("role",t===0?"group":"feed")}#$=t=>{let i=t.target;if(i.isContentEditable||i.matches?.("input, textarea, select"))return;let e=this.#n(),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 c=this.#M(t.key==="Home"?"before":"after");c&&(t.preventDefault(),c.focus());return}if(t.altKey||t.ctrlKey||t.metaKey)return;let d=n;switch(t.key){case"PageDown":d=Math.min(e.length-1,n+1);break;case"PageUp":d=Math.max(0,n-1);break;case"Home":if(!o)return;d=0;break;case"End":if(!o)return;d=e.length-1;break;default:return}t.preventDefault();let a=e[d];a&&(this.#m(a),a.focus())};#M(t){let i=[...document.querySelectorAll(C)].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.#C()},{rootMargin:"200px"}),this.#e.observe(this.#t))}#v(){this.#e?.disconnect(),this.#e=null,this.#t?.remove(),this.#t=null}#C(){if(this.#r)return;this.#r=!0,this.setAttribute("aria-busy","true");let t=++this.#l,i=()=>{this.#r&&t===this.#l&&this.#c()};this.dispatchEvent(new CustomEvent("activity-feed:load-more",{bubbles:!0,detail:{done:i}}))}#c(){this.#r=!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.#n()[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.#n().forEach(t=>t.remove())}get entries(){return this.#n()}get loading(){return this.#r}};y("activity-feed",b);export{b as ActivityFeed};
|
|
2
2
|
//# sourceMappingURL=activity-feed.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
1
|
+
var F=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function w(r,t,e={}){let n=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:n},s=v.get(r);if(customElements.get(r)){if(!s||s.priority>=n){s&&s.priority===n&&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>=n){s.priority===n&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}v.set(r,i),customElements.define(r,t)}var u=class extends HTMLElement{#n=[];#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.#n)t();this.#n=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,i){t.addEventListener(e,n,i),this.#n.push(()=>t.removeEventListener(e,n,i))}_reinit(){for(let t of this.#n)t();this.#n=[],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 n=this.#t.states;try{e?n.add(t):n.delete(t)}catch{let i=`--${t}`;e?n.add(i):n.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}#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 g(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 n=await e.availability();return n==="available"||n==="downloadable"||n==="downloading"||n==="unavailable"?{state:n}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}var k="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function S(r,{stripSelectors:t=k}={}){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 n=e.cloneNode(!0);return t&&typeof n.querySelectorAll=="function"&&n.querySelectorAll(t).forEach(i=>i.remove()),(n.textContent||"").trim().replace(/\s+/g," ")}var $=/\{(prompt|url|title|content)\}/g;function M(r,t=1500){let e=String(r??"");if(e.length<=t)return e;let n=e.slice(0,Math.max(0,t-1)),i=n.lastIndexOf(" ");return`${i>t*.8?n.slice(0,i):n}\u2026`}function E(r){return typeof r=="string"&&r.includes("{content}")}function x(r,t={},{contentLimit:e=1500}={}){if(!r)return"";let n={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:M(t.content,e)};return String(r).replace($,(i,s)=>encodeURIComponent(n[s]))}async function*A(r,{prompt:t="",content:e,mode:n,messages:i,signal:s}={}){let o={prompt:t};e!==void 0&&(o.content=e),n!==void 0&&(o.mode=n),Array.isArray(i)&&(o.messages=i);let a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:s});if(!a.ok)throw new Error(`AI endpoint ${r} returned ${a.status} ${a.statusText}`);if((a.headers.get("content-type")||"").toLowerCase().includes("application/json")){let c=await a.json(),d=typeof c?.text=="string"?c.text:"";d&&(yield d);return}if(!a.body||typeof a.body.getReader!="function"){let c=await a.text();c&&(yield c);return}let b=a.body.getReader(),m=new TextDecoder;try{for(;;){let{value:d,done:T}=await b.read();if(T)break;if(d){let y=m.decode(d,{stream:!0});y&&(yield y)}}let c=m.decode();c&&(yield c)}finally{try{b.releaseLock()}catch{}}}function C(r){return r?Math.ceil(String(r).length/4):0}var _=12e3,L=20;function f(r,{maxChars:t=_,maxMessages:e=L}={}){if(!Array.isArray(r)||r.length===0)return[];let n=[],i=0;for(let s=r.length-1;s>=0;s--){let o=r[s],a=String(o?.content??"").length;if(n.length>=e||i+a>t)break;n.unshift(o),i+=a}for(;n.length&&n[0].role==="assistant";)n.shift();return n}var P="Help me explore this article: {title} ({url})",O={user:{name:"You",role:"user"},assistant:{name:"Assistant",role:"agent"}},h={local:"Gemini Nano (on-device)",endpoint:"Server endpoint","deep-link":"Open in external tool"},p=class extends u{#n=null;#t=null;#e=null;#a=null;#l=null;#m=null;#c=null;#d=[];#s=null;#i=null;#u="unsupported";#r="unavailable";static get observedAttributes(){return["placeholder"]}setup(){this.#C()||this.#T(),this.#k(),this.#$(),this.#f(),this.#L()}teardown(){this.#i?.abort(),this.#i=null,this.#s?.destroy?.(),this.#s=null,this.#p()}attributeChangedCallback(t,e,n){if(t==="placeholder"){let i=this.querySelector("chat-input textarea");i&&(i.placeholder=n??"")}}async reset(){this.#i?.abort(),this.#i=null,this.#s?.destroy?.(),this.#s=null,this.#d=[],this.#p(),this.#n?.clearThread?.(),this.#f(),this.#o("ready")}stop(){this.#i?.abort()}#C(){let t=this.querySelector(":scope > chat-window");return t?(this.#n=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.#w(),!0):!1}#w(){this.#m=this.querySelector("chat-input [data-send]"),this.#c=this.querySelector("chat-input [data-stop]")}#T(){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
|
-
<p class="ai-chat-notice" hidden></p>
|
|
3
|
+
<p class="ai-chat-notice" role="status" 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
6
|
<script type="application/json" data-participants>${JSON.stringify(O)}<\/script>
|
|
@@ -20,12 +20,12 @@ var R=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;functi
|
|
|
20
20
|
</footer>
|
|
21
21
|
</chat-input>
|
|
22
22
|
</chat-window>
|
|
23
|
-
`,this.appendChild(e.content.cloneNode(!0)),this.#
|
|
24
|
-
`).map(
|
|
23
|
+
`,this.appendChild(e.content.cloneNode(!0)),this.#n=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.#w();let n=this.querySelector("chat-input textarea");n&&(n.placeholder=t)}#k(){if(!this.#l)return;let t=this.querySelector(':scope > template[data-role="starters"]'),e=(t&&t.content?.textContent||"").split(`
|
|
24
|
+
`).map(n=>n.trim()).filter(Boolean);if(this.#l.replaceChildren(),!e.length){this.#l.hidden=!0;return}this.#l.hidden=!1;for(let n of e){let i=document.createElement("button");i.type="button",i.className="ai-chat-starter small",i.textContent=n,this.listen(i,"click",()=>this.#M(n)),this.#l.appendChild(i)}}#$(){this.#n&&(this.listen(this,"chat-input:send",t=>{if(!this.#i)return;t.stopImmediatePropagation();let e=t.target,n=t.detail?.message??"";queueMicrotask(()=>{e&&"value"in e&&(e.value=n)})},{capture:!0}),this.listen(this.#n,"chat-window:send",t=>{t.stopPropagation(),this.#O(t.detail.message,t.detail.typingElement)}),this.listen(this.#n,"chat-window:model-change",t=>{let e=t.detail.model;e&&e!==this.#r&&(this.#r=e,this.#s?.destroy?.(),this.#s=null,this.#S())}),this.listen(this,"keydown",t=>{t.key!=="Escape"||!this.#i||t.isComposing||t.keyCode===229||(t.preventDefault(),t.stopPropagation(),this.#i.abort())},{capture:!0}),this.#c&&this.listen(this.#c,"click",()=>{this.#i?.abort(),this.querySelector("chat-input textarea")?.focus()}),this.listen(this,"focusin",t=>{let e=t.relatedTarget;e&&this.contains(e)||this.#f()}))}#M(t){let e=this.querySelector("chat-input");if(!e)return;e.value=t;let n=e.querySelector("textarea");n&&n.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))}#g(){return this.getAttribute("context")?.trim()||""}#h(){let t=this.#g();return t?S(t,{stripSelectors:"ai-chat, ai-summary, .ais-ui"}):""}#f(){if(!this.#e)return;let t=this.#g();if(!t){this.#e.hidden=!0;return}let e=this.#h();if(!e){this.#e.hidden=!1,this.#e.textContent=`Context selector "${t}" matched no readable content.`,this.setAttribute("data-context-state","missing");return}let n=e.length,i=C(e),s=n>6e3,o=this.getAttribute("context-label")||t;this.#e.hidden=!1,this.#e.replaceChildren();let a=document.createElement("span");if(a.className="ai-chat-ribbon-lead",a.textContent=`Page context: ${o} \xB7 ${n.toLocaleString()} chars (~${i.toLocaleString()} tokens)`,this.#e.appendChild(a),s){let l=document.createElement("span");l.className="ai-chat-ribbon-warn",l.textContent="large \u2014 may crowd the conversation",this.#e.appendChild(l)}this.setAttribute("data-context-state",s?"large":"ok")}#_(){let t=this.getAttribute("system")?.trim()||this.querySelector(':scope > template[data-role="system"]')?.content?.textContent?.trim()||"",e=this.#h();if(!e)return t||void 0;let i=`
|
|
25
25
|
|
|
26
26
|
[PAGE CONTENT \u2014 ${this.getAttribute("context-label")||"page"}]
|
|
27
27
|
${e}
|
|
28
|
-
[END PAGE CONTENT]`;return t?t+
|
|
28
|
+
[END PAGE CONTENT]`;return t?t+i:`Use the following page content to answer the user.${i}`}async#L(){this.#o("checking");let{state:t}=await g("LanguageModel");this.#u=t;let e=[];t==="available"||t==="downloadable"||t==="downloading"?e.push({value:"local",label:h.local}):e.push({value:"local",label:`${h.local} \u2014 unavailable`,disabled:!0}),this.getAttribute("endpoint")&&e.push({value:"endpoint",label:h.endpoint}),this.getAttribute("fallback-url")&&e.push({value:"deep-link",label:this.getAttribute("fallback-label")||h["deep-link"]}),this.#q(e);let n=e.find(i=>!i.disabled&&i.value===this.#r)??e.find(i=>!i.disabled);this.#r=n?.value??"unavailable",this.#t&&n&&(this.#t.value=n.value),this.#n&&(this.#n.model=this.#r),this.#S(),this.#o(this.#r==="unavailable"?"unavailable":"ready")}#q(t){if(this.#t){if(this.#t.replaceChildren(),t.length===0){let e=document.createElement("option");e.textContent="Unavailable",e.disabled=!0,this.#t.appendChild(e),this.#t.disabled=!0;return}for(let e of t){let n=document.createElement("option");n.value=e.value,n.textContent=e.label,e.disabled&&(n.disabled=!0),this.#t.appendChild(n)}this.#t.disabled=t.every(e=>e.disabled)}}#S(){this.#m?.setAttribute("aria-label",this.#r==="deep-link"?"Send (opens in new tab)":"Send"),this.#r==="unavailable"?this.#b("On-device AI unavailable and no fallback configured. Set endpoint= or fallback-url= to enable a fallback."):this.#r==="deep-link"?this.#b("Send opens the external tool in a new tab. Choose another provider above to chat in-page."):this.#u==="downloadable"&&this.#r==="local"?this.#b("First message will download the on-device model (~1.6 GB)."):this.#v()}async#P(t){if(this.#s)return this.#s;let e=this.#_(),n=[...e?[{role:"system",content:e}]:[],...f(this.#d)],i=n.length?n:void 0;return this.#s=await LanguageModel.create({initialPrompts:i,signal:t,expectedInputs:[{type:"text",languages:["en"]}],expectedOutputs:[{type:"text",languages:["en"]}],monitor:s=>{s.addEventListener("downloadprogress",o=>{if(o.loaded>=1){this.#u="available",this.#v();return}this.#o("downloading"),this.#b(`Downloading on-device model: ${Math.round(o.loaded*100)}%`)})}}),this.#u="available",this.#v(),this.#s.addEventListener?.("contextoverflow",()=>{this.dispatchEvent(new CustomEvent("ai-chat:context-overflow",{bubbles:!0}))}),this.#s}async#O(t,e){if(this.#i){e.remove();return}if(this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"user",text:t},bubbles:!0})),this.#r==="deep-link"){e.remove(),window.open(this.#R(t),"_blank","noopener,noreferrer");return}if(this.#r==="unavailable"){this.#x(e,"Chat is unavailable in this browser.",{error:!0});return}let n=e.querySelector("chat-bubble");if(!n)return;let i=new AbortController;this.#i=i,this.#o("streaming"),this.#p();let s=this.querySelector("chat-thread");s?.setAttribute("aria-busy","true"),this.#f();let o="";try{let a=this.#r==="local"?await this.#B(t,i.signal):A(this.getAttribute("endpoint")||"",{prompt:t,content:this.#h()||void 0,mode:"chat",messages:f(this.#d),signal:i.signal});this.getAttribute("data-state")!=="streaming"&&this.#o("streaming");for await(let l of a)o+=l,n.textContent=o,this.#A();this.#y(e,o||" "),this.#A(),this.#E(t,o),this.dispatchEvent(new CustomEvent("ai-chat:message",{detail:{role:"assistant",text:o},bubbles:!0})),this.#o("ready")}catch(a){let l=a;if(l?.name==="AbortError"){o&&this.#E(t,o),this.#y(e,o?`${o} (stopped)`:"(stopped)"),this.#o("ready");return}this.#x(e,l?.message||"Generation failed",{error:!0}),this.#o("error"),this.dispatchEvent(new CustomEvent("ai-chat:error",{detail:{error:a},bubbles:!0}))}finally{s?.removeAttribute("aria-busy"),this.#i===i&&(this.#i=null),this.#p()}}#E(t,e){this.#d.push({role:"user",content:t},{role:"assistant",content:e})}#p(){let t=!!this.#i,e=this.#m,n=this.#c;if(!e||!n||n.hidden===!t)return;let i=document.activeElement;e.hidden=t,n.hidden=!t,t&&i===e?n.focus():!t&&i===n&&this.querySelector("chat-input textarea")?.focus()}async#B(t,e){let i=(await this.#P(e)).promptStreaming(t,{signal:e});return(async function*(){for await(let s of i)yield s})()}#y(t,e){let n=t.querySelector("chat-bubble");n&&(n.textContent=e),t.removeAttribute("data-status")}#x(t,e,n={}){this.#y(t,e),n.error&&t.setAttribute("data-status","error")}#A(){this.#n?.scrollToBottom?.()}#o(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-chat:state",{detail:{state:t,provider:this.#r},bubbles:!0}))}#b(t){this.#a&&(this.#a.hidden=!1,this.#a.textContent=t)}#v(){this.#a&&(this.#a.hidden=!0,this.#a.textContent="")}#R(t){let n=(this.getAttribute("fallback-prompt")||P).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title),i=t?`${n}
|
|
29
29
|
|
|
30
|
-
User: ${t}`:
|
|
30
|
+
User: ${t}`:n,s=this.getAttribute("fallback-url"),o=E(s)?this.#h():"";return x(s,{prompt:i,content:o})}};w("ai-chat",p);export{p as AIChat};
|
|
31
31
|
//# sourceMappingURL=ai-chat.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var B=window.matchMedia("(prefers-reduced-motion: reduce)");var b=new Map;function m(r,t,e={}){let n=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:n},i=b.get(r);if(customElements.get(r)){if(!i||i.priority>=n){i&&i.priority===n&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=n){i.priority===n&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}b.set(r,s),customElements.define(r,t)}var d=class extends HTMLElement{#t=[];#n;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,n,s){t.addEventListener(e,n,s),this.#t.push(()=>t.removeEventListener(e,n,s))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#n||(this.#n=this.attachInternals());let n=this.#n.states;try{e?n.add(t):n.delete(t)}catch{let s=`--${t}`;e?n.add(s):n.delete(s)}}_adoptInternals(t){this.#n||(this.#n=t)}#e(){return this.constructor.formAssociated&&this.#n?this.#n: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(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 n=await e.availability();return n==="available"||n==="downloadable"||n==="downloading"||n==="unavailable"?{state:n}:{state:"unsupported"}}catch(e){return{state:"unsupported",error:e}}}function g({availability:r,endpoint:t,fallbackURL:e}){return T.includes(r)?"local":t?"endpoint":e?"deep-link":"unavailable"}var $="ai-chat, ai-summary, .ai-chat-shell, .ais-ui";function v(r,{stripSelectors: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 n=e.cloneNode(!0);return t&&typeof n.querySelectorAll=="function"&&n.querySelectorAll(t).forEach(s=>s.remove()),(n.textContent||"").trim().replace(/\s+/g," ")}var M=/\{(prompt|url|title|content)\}/g;function _(r,t=1500){let e=String(r??"");if(e.length<=t)return e;let n=e.slice(0,Math.max(0,t-1)),s=n.lastIndexOf(" ");return`${s>t*.8?n.slice(0,s):n}\u2026`}function w(r){return typeof r=="string"&&r.includes("{content}")}function E(r,t={},{contentLimit:e=1500}={}){if(!r)return"";let n={prompt:t.prompt??"",url:t.url??(typeof location<"u"?location.href:""),title:t.title??(typeof document<"u"?document.title:""),content:_(t.content,e)};return String(r).replace(M,(s,i)=>encodeURIComponent(n[i]))}async function*A(r,{prompt:t="",content:e,mode:n,messages:s,signal:i}={}){let o={prompt:t};e!==void 0&&(o.content=e),n!==void 0&&(o.mode=n),Array.isArray(s)&&(o.messages=s);let a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:i});if(!a.ok)throw new Error(`AI endpoint ${r} 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:k}=await h.read();if(k)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 S=16e3;function C(r,t,e){let n=String(r??"");if(!(t>0)||!(e>0)||!Number.isFinite(e)||t<=e)return n;let s=Math.floor(n.length*(e/t)*.95);return n.slice(0,Math.max(0,s))}var L="Summarize this article: {url}",u=class extends d{#t=null;#n=null;#e=null;#o=null;#a=null;#s=null;#i="unavailable";setup(){this.#p(),this.#b()}teardown(){this.#s?.abort(),this.#s=null}stop(){this.#s?.abort()}#p(){let t=this.querySelector(":scope > .ais-ui");if(t){this.#l(t);return}let e=document.createElement("div");e.className="ais-ui",e.innerHTML=`
|
|
2
2
|
<div class="ais-controls">
|
|
3
3
|
<button type="button" class="ais-trigger small" disabled>
|
|
4
4
|
<span class="ais-label">Summarize</span>
|
|
@@ -8,5 +8,5 @@ var R=window.matchMedia("(prefers-reduced-motion: reduce)");var m=new Map;functi
|
|
|
8
8
|
</div>
|
|
9
9
|
<p class="ais-notice" role="status" hidden></p>
|
|
10
10
|
<div class="ais-output" hidden aria-live="polite"></div>
|
|
11
|
-
`,this.prepend(e),this.#l(e)}#l(t){this.#t=t.querySelector(".ais-trigger"),this.#
|
|
11
|
+
`,this.prepend(e),this.#l(e)}#l(t){this.#t=t.querySelector(".ais-trigger"),this.#n=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#b(){this.#r("checking");let{state:t}=await y("Summarizer");this.#i=g({availability:t,endpoint:this.getAttribute("endpoint")||void 0,fallbackURL:this.getAttribute("fallback-url")||void 0}),this.#m(t)}#m(t){if(!(!this.#t||!this.#n)){if(this.#C(this.#i==="deep-link"),this.#i==="local"){this.#n.dataset.state=t,this.#n.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.#r("ready");return}if(this.#i==="endpoint"){this.#n.dataset.state="available",this.#n.textContent="Ready (remote)",this.#t.disabled=!1,this.#t.dataset.provider="endpoint",this.#r("ready");return}if(this.#i==="deep-link"){this.#n.dataset.state="unavailable",this.#n.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.#S(e),this.#r("deep-link");return}this.#n.dataset.state="unavailable",this.#n.textContent="Summarization not available on this device",this.#t.disabled=!0,this.#t.dataset.provider="unavailable",this.#r("unavailable")}}async#y(){if(!this.#t||!this.#e)return;if(this.#i==="deep-link"){window.open(this.#h(),"_blank","noopener,noreferrer");return}if(this.#i==="unavailable")return;this.#e.hidden=!1,this.#e.textContent="",this.#x(),this.#e.setAttribute("aria-busy","true"),this.#r("streaming");let t=new AbortController;this.#s=t,this.#c(!0);let e="";try{let n=this.#d(),s=this.#i==="local"?await this.#g(n,t.signal):A(this.getAttribute("endpoint")||"",{prompt:this.#u(),content:n,mode:"summarize",signal:t.signal});this.getAttribute("data-state")!=="streaming"&&this.#r("streaming");for await(let i of s)e+=i,this.#e.textContent=e;this.#w(e),this.#r("complete"),this.dispatchEvent(new CustomEvent("ai-summary:result",{detail:{text:e,provider:this.#i},bubbles:!0}))}catch(n){if(n&&n.name==="AbortError"){this.#e.textContent=e?`${e} (stopped)`:"(stopped)",this.#r("ready");return}this.#A(n),this.#r("error"),this.dispatchEvent(new CustomEvent("ai-summary:error",{detail:{error:n},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 n=await Summarizer.create({signal:e,type:this.getAttribute("type")||"key-points",format:this.getAttribute("format")||"markdown",length:this.getAttribute("length")||"medium",sharedContext:this.getAttribute("shared-context")||void 0,expectedInputLanguages:["en"],outputLanguage:"en",monitor:o=>{o.addEventListener("downloadprogress",a=>{this.#r("downloading"),this.#n&&(this.#n.textContent=`Downloading model: ${Math.round(a.loaded*100)}%`)})}}),s=t;try{s=await this.#v(n,t,e)}catch(o){throw n.destroy?.(),o}let i=typeof n.summarizeStreaming=="function"?n.summarizeStreaming(s,{signal:e}):(async function*(){yield await n.summarize(s,{signal:e})})();return(async function*(){try{for await(let o of i)yield o}finally{n.destroy?.()}})()}async#v(t,e,n){let s=t?.inputQuota;if(typeof t?.measureInputUsage=="function"&&typeof s=="number"){let i;try{i=await t.measureInputUsage(e,{signal:n})}catch(o){if(o?.name==="AbortError")throw o;i=void 0}if(typeof i=="number"&&i>s){let o=C(e,i,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>S&&this.#f(`This content is long (${e.length.toLocaleString()} characters) and may exceed the on-device model's limit.`),e}#d(){return v(this,{stripSelectors:".ais-ui"})}#u(){return(this.getAttribute("fallback-prompt")||L).replace(/\{url\}/g,location.href).replace(/\{title\}/g,document.title)}#h(){let t=this.getAttribute("fallback-url");return E(t,{prompt:this.#u(),content:w(t)?this.#d():""})}#w(t){if(this.#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 n=document.createElement("pre");n.textContent=t,e.appendChild(n),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 i=document.createElement("a");i.href=this.#h(),i.target="_blank",i.rel="noopener noreferrer",i.textContent=this.getAttribute("fallback-label")||"Continue elsewhere",i.append(x()),s.append("You can ",i," instead."),this.#e.appendChild(s)}}#r(t){this.setAttribute("data-state",t),this.dispatchEvent(new CustomEvent("ai-summary:state",{detail:{state:t,provider:this.#i},bubbles:!0}))}#S(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 r=document.createElement("span");return r.className="visually-hidden ais-newtab",r.textContent=" (opens in new tab)",r}m("ai-summary",u);export{u as AISummary};
|
|
12
12
|
//# sourceMappingURL=ai-summary.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
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=`
|
|
1
|
+
var N=window.matchMedia("(prefers-reduced-motion: reduce)");var k=new Map;function x(e,t,n={}){let r=n.priority??10,s={impl:t,bundle:n.bundle,contract:n.contract,priority:r},o=k.get(e);if(customElements.get(e)){if(!o||o.priority>=r){o&&o.priority===r&&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>=r){o.priority===r&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${o.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}k.set(e,s),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,r,s){t.addEventListener(n,r,s),this.#t.push(()=>t.removeEventListener(n,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,n){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{n?r.add(t):r.delete(t)}catch{let s=`--${t}`;n?r.add(s):r.delete(s)}}_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 _(e){let t=T(e);return t.user?"user":t.gpc?"gpc":t.dnt?"dnt":t.consent?"consent":null}function l(e){return _(e)!==null}function L(e){return e?.closest?.("[data-vb-no-track]")!=null}function P(){let{dataset:e}=document.documentElement,t={};for(let n of Object.keys(e)){let r=e[n];r!=null&&r!==""&&(t[n]=r)}return t}var q=new Set(["track-history","track-history-params","no-track-history"]);function B(){let e={};for(let n of document.querySelectorAll('meta[name^="vb:"]')){let r=n.getAttribute("name")?.slice(3),s=n.getAttribute("content")?.trim();r&&q.has(r)||r&&s&&(e[r]=s)}let t=[];for(let n of document.querySelectorAll('meta[name="concept"]')){let r=n.getAttribute("content")?.trim();r&&t.push(r)}return t.length&&(e.concepts=t),e}function D(e,t){if(!t?.length)return e;for(let{pattern:n,replace:r}of t)if(n.test(e))return e.replace(n,r);return e}function R(e,t){let n=JSON.stringify(t);if(typeof navigator.sendBeacon=="function"){let r=new Blob([n],{type:"application/json"});if(navigator.sendBeacon(e,r))return!0}try{return fetch(e,{method:"POST",body:n,keepalive:!0,headers:{"content-type":"application/json"}}),!0}catch{return!1}}var i={config:null,queue:[]},u={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`${(i.config?.endpoint??"/api/analytics").replace(/\/+$/,"")}/${e}`}function g(e,t){let n=i.config;if(!n)throw new Error("analytics: buildEnvelope called before init");let r=D(location.pathname+location.search,n.urlMasks),s=typeof n.context=="function"?n.context()??{}:{};return{name:e,ts:Date.now(),site:n.siteId,path:r,referrer:document.referrer||"",context:{...P(),...B(),...s},props:t??{}}}function b(e,t){let n=i.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),u.logged++,p(),!0;let r=R(E(e),t);return r&&(u.sent++,p()),r}function M(){let e=i.config?.sampleRate??1;return e>=1?!0:Math.random()<e}var $=null;function O(){if(!i.config||l(i.config)||document.documentElement.hasAttribute("data-vb-no-track")||!M())return;let e=location.pathname+location.search;e!==$&&($=e,b("hit",g("page.view",{})))}function j(){let e,t=()=>{clearTimeout(e),e=setTimeout(O,100)},n=history.pushState.bind(history);history.pushState=function(...s){n(...s),t()};let r=history.replaceState.bind(history);history.replaceState=function(...s){r(...s),t()},window.addEventListener("popstate",t)}function V(e){let t={};for(let[n,r]of Object.entries(e.dataset)){if(n==="vbEvent"||!n.startsWith("vbEvent"))continue;let s=n.slice(7).replace(/^./,o=>o.toLowerCase());t[s]=r}return t}function H(e){if(!i.config||l(i.config))return;let n=e.target?.closest?.("[data-vb-event]");if(!n||L(n))return;let r=n.dataset.vbEvent;r&&w.track(r,V(n))}function C(){let e=document.querySelectorAll('a[href^="http"]');for(let t of e){if(t.hostname===location.hostname||L(t)||t.hasAttribute("data-vb-analytics-wired"))continue;let n=encodeURIComponent(i.config?.siteId??"default"),r=`${E("click")}?site=${n}&from=${encodeURIComponent(location.pathname)}`,s=!t.hasAttribute("ping"),o=()=>{s&&(l(i.config)?t.removeAttribute("ping"):t.setAttribute("ping",r))};t.addEventListener("click",o,{capture:!0}),t.addEventListener("auxclick",o,{capture:!0}),t.addEventListener("click",()=>{if(l(i.config))return;let a=navigator.userAgent;/Firefox|Brave/.test(a)&&b("click",g("link.outbound",{to:t.hostname,href:t.href}))}),t.setAttribute("data-vb-analytics-wired","")}}function y(){if(!i.queue.length)return;let e=i.queue.splice(0);b("events",{site:i.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 z(){try{return window.top!==window.self}catch{return!0}}var w={init(e={}){if(i.config)return;let t={...U,...e};if(i.config=t,globalThis[m]||(globalThis[m]=w),queueMicrotask(p),z()&&!t.allowInIframe){u.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",H,{capture:!0}),t.autoOutboundLinks&&(C(),new MutationObserver(()=>C()).observe(document.body,{childList:!0,subtree:!0})),t.autoPageView&&(O(),j()),document.addEventListener("visibilitychange",F),window.addEventListener("pagehide",y)},track(e,t={}){i.config&&(l(i.config)||M()&&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=i.config,t=T(e),n=_(e),r=null;if(e)try{r=g("page.view",{})}catch{r=null}let s=e?.transport??null;return{initialized:e!=null,active:e!=null&&s!=="disabled"&&n===null,optedOut:n!==null,reason:n,signals:t,transport:s,inIframe:u.iframeDisabled,endpoint:e?E("hit"):null,siteId:e?.siteId??null,sampleRate:e?.sampleRate??null,outboundLinks:e?.autoOutboundLinks??!1,queued:i.queue.length,sent:u.sent,logged:u.logged,collects:r?Object.keys(r):[],contextKeys:r?Object.keys(r.context):[],preview:r}},get config(){return i.config?{...i.config}:null}};function A(){return globalThis[m]??w}var K="Analytics on this page",G=2;function W(e){let t=Number.parseInt(e??"",10);return Number.isInteger(t)&&t>=1&&t<=6?t:G}var I={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 Y(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=I[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 J(e){return e?.signals?["gpc","dnt","consent"].filter(t=>e.signals[t]):[]}var S=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.#r())}get#e(){return this.getAttribute("heading")||K}get status(){let t=A();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 r=n.dataset.analyticsAction;r==="toggle"&&this.#s(),r==="refresh"&&this.refresh()};#s(){let t=!this.status?.signals?.user;A().setConsent(!t),this.dispatchEvent(new CustomEvent(t?"analytics-panel:optout":"analytics-panel:optin",{bubbles:!0,composed:!0})),this.refresh()}#o(){let t=`analytics-panel-${Math.random().toString(36).slice(2,8)}`;this.innerHTML=`
|
|
2
2
|
<header class="analytics-panel__header">
|
|
3
3
|
<h2 data-part="heading"></h2>
|
|
4
4
|
<p class="analytics-panel__status" role="status">
|
|
@@ -28,5 +28,5 @@ var J=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;functi
|
|
|
28
28
|
server records your country from the request; your IP address is not
|
|
29
29
|
stored.
|
|
30
30
|
</p>
|
|
31
|
-
`;for(let n of this.querySelectorAll("[data-part]"))this.#t[n.dataset.part??""]=n;this.#t.heading.textContent=this.#e,this.#
|
|
31
|
+
`;for(let n of this.querySelectorAll("[data-part]"))this.#t[n.dataset.part??""]=n;this.#t.heading.textContent=this.#e,this.#r()}#r(){let t=W(this.getAttribute("heading-level")),n={heading:t,"fields-heading":Math.min(t+1,6)};for(let[r,s]of Object.entries(n)){let o=this.#t[r];if(!o||o.localName===`h${s}`)continue;let a=document.createElement(`h${s}`);for(let{name:d,value:c}of o.attributes)a.setAttribute(d,c);a.textContent=o.textContent,o.replaceWith(a),this.#t[r]=a}}refresh(){if(!this.#t.status)return;let t=this.status,n=Y(t),r=this.#t;this.setAttribute("data-state",n.state),n.reason?this.setAttribute("data-reason",n.reason):this.removeAttribute("data-reason"),r.status.textContent!==n.text&&(r.status.textContent=n.text),this.#i(t);let s=!!t?.signals?.user,o=J(t),a=s?"Resume analytics":"Pause analytics";if(r.toggle.textContent!==a&&(r.toggle.textContent=a),r.toggle.setAttribute("aria-pressed",String(s)),s&&o.length>0?r.toggle.setAttribute("aria-disabled","true"):r.toggle.removeAttribute("aria-disabled"),o.length){let c=o.map(f=>I[f]).join(" and ");r.hint.textContent=s?`Resume is unavailable because ${c}.`:`Analytics stays off because ${c}; pausing as well changes nothing.`,r.hint.hidden=!1,r.toggle.setAttribute("aria-describedby",r.hint.id)}else r.hint.textContent="",r.hint.hidden=!0,r.toggle.removeAttribute("aria-describedby")}#i(t){let{data:n,empty:r}=this.#t;if(!t?.initialized||!t.preview){n.hidden=!0,n.replaceChildren(),r.hidden=!1,r.textContent="Nothing to show: the analytics runtime has not started on this page.";return}r.hidden=!0,n.hidden=!1;let s=[["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"?(s.push(["Sent to",t.endpoint]),s.push(["Sent from this page",String(t.sent)])):t.transport==="console"&&s.push(["Logged on this page",String(t.logged)]),t.queued>0&&s.push(["Waiting to send",String(t.queued)]),t.outboundLinks&&s.push(["Outbound link clicks","Reported (site, page path, destination)"]);let o=document.createDocumentFragment();for(let[a,d]of s){let c=document.createElement("dt");c.textContent=a;let f=document.createElement("dd");f.textContent=d,o.append(c,f)}n.replaceChildren(o)}};x("analytics-panel",S);export{Y as describeStatus,W as headingLevel};
|
|
32
32
|
//# sourceMappingURL=analytics-panel.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
<style>${this
|
|
1
|
+
var k=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(i,t,e={}){let r=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:r},a=c.get(i);if(customElements.get(i)){if(!a||a.priority>=r){a&&a.priority===r&&a.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${a.bundle}" (priority ${a.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${a.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(a&&a.priority>=r){a.priority===r&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${a.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}c.set(i,s),customElements.define(i,t)}var o=class extends HTMLElement{#t=[];#e;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)}#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 f(i,t,e){let r=e.querySelector("a[href]");return r?(t.querySelectorAll("li[data-audio-active]").forEach(s=>{s!==e&&s.removeAttribute("data-audio-active")}),e.setAttribute("data-audio-active",""),i.src=r.href,i.play()?.catch(()=>{}),{src:r.href,title:r.textContent?.trim()??""}):null}function p(i){let t=h(i);return t?.setAttribute("data-audio-played",""),t}function v(i,{loop:t=!1}={}){let e=l(i);if(!e.length)return null;let r=h(i),s=r?e.indexOf(r):-1;return s+1<e.length?e[s+1]:t?e[0]:null}var m='input:not([type="range"]), select, textarea, audio, [contenteditable]:not([contenteditable="false"])',b='button, summary, [role="button"]',y='input[type="range"], [role="slider"]',u=class extends o{static get observedAttributes(){return["loop","shuffle"]}#t=null;#e=null;#r=!1;#T=null;#a=null;#i=null;#v=null;#n=null;#x=null;#w=null;#s=null;#c=null;#o=null;#d=!1;#l=new Set;#k=null;#m=!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.#C(),this.#M(),this.#z()),this.#g(),this.#E(),this.#u();let e=this.#t;return(e.error||e.networkState===HTMLMediaElement.NETWORK_NO_SOURCE&&(e.hasAttribute("src")||e.querySelector("source")))&&this.#A(),e.readyState>=HTMLMediaElement.HAVE_METADATA&&(this.#y(),this.#h()),this.hasAttribute("autoplay")&&this.#t.play().catch(()=>{}),this.#k=()=>{let r=this.shadowRoot?.querySelector(".player");r&&(r.style.display="none",r.offsetHeight,r.style.display="")},this.listen(window,"vb:theme-change",this.#k),!0}teardown(){this.#t&&this.#t.setAttribute("controls","")}attributeChangedCallback(t){t==="loop"?this.#E():t==="shuffle"&&this.#l.clear()}#E(){this.#t&&(this.hasAttribute("loop")&&!this.#e?(this.#t.loop=!0,this.#m=!0):this.#m&&(this.#t.loop=!1,this.#m=!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.#P(),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.#$()}</style>
|
|
3
3
|
<div part="player" class="player">
|
|
4
4
|
<div part="controls" class="controls">
|
|
5
5
|
<button part="play-button" class="play-btn" type="button" aria-label="Play">
|
|
@@ -43,7 +43,7 @@ var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;functi
|
|
|
43
43
|
<p part="error" class="error" role="status" hidden></p>
|
|
44
44
|
<slot></slot>
|
|
45
45
|
</div>
|
|
46
|
-
`,this.#T=t.querySelector(".controls"),this.#
|
|
46
|
+
`,this.#T=t.querySelector(".controls"),this.#a=t.querySelector(".play-btn"),this.#i=t.querySelector(".timeline"),this.#v=t.querySelector(".timeline-fill"),this.#n=t.querySelector(".volume"),this.#x=t.querySelector(".current-time"),this.#w=t.querySelector(".duration"),this.#s=t.querySelector(".track-title"),this.#c=t.querySelector(".mute-btn"),this.#o=t.querySelector(".error")}#$(){return`
|
|
47
47
|
:host {
|
|
48
48
|
display: block;
|
|
49
49
|
--_accent: var(--audio-player-accent, var(--color-primary, oklch(55% 0.2 260)));
|
|
@@ -346,5 +346,5 @@ var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;functi
|
|
|
346
346
|
transform: none;
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
-
`}#
|
|
349
|
+
`}#C(){this.#t.addEventListener("timeupdate",()=>this.#h()),this.#t.addEventListener("loadedmetadata",()=>{this.#L(),this.#y(),this.#h()}),this.#t.addEventListener("emptied",()=>{this.#y(),this.#h()}),this.#t.addEventListener("volumechange",()=>this.#u()),this.#t.addEventListener("error",t=>{let e=t.target;if(e!==this.#t){if(e.localName!=="source"||this.#t.hasAttribute("src"))return;let r=e.nextElementSibling;for(;r&&r.localName!=="source";)r=r.nextElementSibling;if(r)return}this.#A()},!0),this.#t.addEventListener("play",()=>{this.#r=!0,this.setAttribute("state","playing"),this.#a.setAttribute("aria-label","Pause"),this.#p("audio-player:play",{currentTime:this.#t.currentTime,src:this.#t.currentSrc})}),this.#t.addEventListener("pause",()=>{this.#r=!1,this.setAttribute("state","paused"),this.#a.setAttribute("aria-label","Play"),this.#p("audio-player:pause",{currentTime:this.#t.currentTime})}),this.#t.addEventListener("ended",()=>{this.#r=!1,this.setAttribute("state","ended"),this.#a.setAttribute("aria-label","Play"),this.#e&&(p(this.#e),this.#B()),this.#p("audio-player:ended",{src:this.#t.currentSrc})})}#A(){this.setAttribute("data-state","error"),this.#o.textContent=`Audio could not be loaded${this.#s.textContent?`: ${this.#s.textContent}`:""}.`,this.#o.hidden=!1}#L(){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)}#M(){this.#a.addEventListener("click",()=>{this.#r?this.#t.pause():this.#t.play().catch(()=>{})}),this.#i.addEventListener("input",()=>{let e=Number(this.#i.value);this.#v.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.#q(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("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")}#q(t){let e=t.key==="ArrowLeft"||t.key==="ArrowRight";for(let r of t.composedPath()){if(r===this)return!1;if(r instanceof Element&&(r.matches(m)||t.key===" "&&r.matches(b)||e&&r.matches(y)))return!0}return!1}#z(){this.#e&&this.#e.addEventListener("click",t=>{let r=t.target?.closest("a[href]"),s=r?.closest("li");!r||!s||(t.preventDefault(),this.#b(s))})}#b(t){if(!this.#e)return;let e=f(this.#t,this.#e,t);e&&(this.#l.add(t),this.#g(),this.#p("audio-player:track-change",e))}#P(){if(!this.#e)return;let t=this.#t.src,e=l(this.#e).find(r=>r.querySelector("a[href]").href===t);this.#e.querySelectorAll("li[data-audio-active]").forEach(r=>{r!==e&&r.removeAttribute("data-audio-active")}),e?.setAttribute("data-audio-active","")}#B(){if(!this.#e)return;let t=this.hasAttribute("loop");if(!this.hasAttribute("shuffle")){let n=v(this.#e,{loop:t});n&&this.#b(n);return}let e=l(this.#e),r=this.#e.querySelector("li[data-audio-active]");r&&this.#l.add(r);let s=e.filter(n=>!this.#l.has(n));if(!s.length){if(this.#l.clear(),!t)return;s=e.length>1?e.filter(n=>n!==r):e}let a=s[Math.floor(Math.random()*s.length)];a&&this.#b(a)}#h(){let t=this.#t.currentTime,e=this.#t.duration||0,r=e?t/e*100:0;this.#x.textContent=this.#f(t),this.#S(t,e),!this.#d&&(this.#i.value=String(r),this.#v.style.width=`${r}%`)}#S(t,e){this.#i.setAttribute("aria-valuetext",`${this.#f(t)} of ${this.#f(e)}`)}#y(){let t=this.#t.duration||0;this.#w.textContent=this.#f(t)}#g(){if(!this.#s)return;if(this.#e){let r=this.#e.querySelector("li[data-audio-active] a");if(r){this.#s.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.#s.textContent=e.replace(/\.[^.]+$/,"").replace(/[-_]/g," ")}#f(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}`}#p(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}};d("audio-player",u);export{u as AudioPlayerElement};
|
|
350
350
|
//# sourceMappingURL=audio-player.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;function E(s,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=w.get(s);if(customElements.get(s)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> 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 <${s}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}w.set(s,n),customElements.define(s,t)}var l=class extends HTMLElement{#t=[];#s;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.#s||(this.#s=this.attachInternals());let i=this.#s.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#s||(this.#s=t)}#r(){return this.constructor.formAssociated&&this.#s?this.#s: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}};var m=new Map;function $(){if(!m.has("default"))try{m.set("default",new AudioContext)}catch{return null}return m.get("default")}var f=new WeakMap;function k(s,t){if(f.has(s))return f.get(s);let e=t.createMediaElementSource(s);return e.connect(t.destination),f.set(s,e),e}function A(s){let t=Number.parseInt(s??"",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 T(s){if(s.crossOrigin!=null)return!1;let t=s.currentSrc||s.src||s.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 S=new WeakSet,L=new Set(["bars","waveform","circle"]);function M(s){return s&&L.has(s)?s:"bars"}var b="oklch(55% 0.2 260)",P=new Uint8Array(256).fill(128),x=new Uint8Array(128),p=class extends l{#t=null;#s=null;#r=null;#e=null;#c=null;#u=new Uint8Array(0);#l=new Uint8Array(0);#f=b;#m="";#y="bars";#i=null;#v=null;#g=null;#b=!0;#o=!1;#d=!1;#n=null;#h=()=>this.#M();static get observedAttributes(){return["for","data-mode","data-fft-size"]}setup(){if(this.#d=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.#y=M(this.getAttribute("data-mode")),this.#$(),this.#E(),this.#A(),this.#x(),this.#_(),this.#B(),this.#o&&this.#c&&this.#e){try{this.#c.connect(this.#e)}catch{}this.#p()}let t=()=>requestAnimationFrame(()=>{this.#E(),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.#v?.disconnect(),this.#g?.disconnect(),this.#n?.removeEventListener("play",this.#h),this.#n=null,this.#S()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="data-mode"){this.#y=M(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.#C(),this.#i||this.#a()))}}#$(){if(this.shadowRoot)return;let t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
display: block;
|
|
@@ -16,5 +16,5 @@ var T=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;functi
|
|
|
16
16
|
}
|
|
17
17
|
</style>
|
|
18
18
|
<canvas aria-hidden="true"></canvas>
|
|
19
|
-
`,this.#t=t.querySelector("canvas"),this.#
|
|
19
|
+
`,this.#t=t.querySelector("canvas"),this.#s=this.#t.getContext("2d")}#E(){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.#r&&this.#r!==i&&(this.#w(),this.#S(),this.#e=null,this.#c=null,this.#o=!1,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#a()),this.#r=i,!i){this.#n?.removeEventListener("play",this.#h),this.#n=null;return}this.#o||(this.#n!==i&&(this.#n?.removeEventListener("play",this.#h),i.addEventListener("play",this.#h),this.#n=i),i.paused||this.#M())}#S(){if(this.#c&&this.#e)try{this.#c.disconnect(this.#e)}catch{}}#M(){if(this.#o||!this.#r)return;let t=this.#r;if(!f.has(t)&&T(t)){this.setAttribute("data-state","cross-origin"),S.has(t)||(S.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=$();if(!e)return;let i,n;try{i=e.createAnalyser(),i.fftSize=A(this.getAttribute("data-fft-size")),i.smoothingTimeConstant=.8,n=k(t,e),n.connect(i)}catch(r){this.setAttribute("data-state","error"),console.warn("<audio-visualizer>: could not connect to the audio element.",r);return}this.#e=i,this.#c=n,this.#C(),this.#o=!0,this.getAttribute("data-state")!==null&&this.removeAttribute("data-state"),this.#n?.removeEventListener("play",this.#h),this.#n=null,e.state==="suspended"&&e.resume().catch(()=>{}),this.#p()}#C(){this.#e&&(this.#u.length!==this.#e.frequencyBinCount&&(this.#u=new Uint8Array(this.#e.frequencyBinCount)),this.#l.length!==this.#e.fftSize&&(this.#l=new Uint8Array(this.#e.fftSize)))}#p(){if(this.#i)return;if(this.#d){this.#a();return}let t=()=>{if(!this.#b||this.#d){this.#i=null;return}this.#i=requestAnimationFrame(t),this.#a()};this.#i=requestAnimationFrame(t)}#w(){this.#i&&(cancelAnimationFrame(this.#i),this.#i=null)}#k(){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.#s;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,r=this.#y;if(r==="waveform"){n&&n.getByteTimeDomainData(this.#l),this.#L(t,e,i,this.#f,n?this.#l:P);return}n&&n.getByteFrequencyData(this.#u);let c=n?this.#u:x;r==="circle"?this.#P(t,e,i,this.#f,c):this.#T(t,e,i,this.#f,c)}#T(t,e,i,n,r){let c=Math.min(r.length,64),o=e/c,d=Math.max(1,o-1),u=Math.max(1,Math.round(i*.03));t.fillStyle=n;for(let a=0;a<c;a++){let h=Math.max(u,r[a]/255*i);t.fillRect(a*o,i-h,d,h)}}#L(t,e,i,n,r){let c=e/Math.max(1,r.length-1);t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let o=0;o<r.length;o++){let d=r[o]/255*i;o===0?t.moveTo(0,d):t.lineTo(o*c,d)}t.stroke()}#P(t,e,i,n,r){let c=e/2,o=i/2,d=Math.min(e,i)*.25,u=r.length;t.strokeStyle=n,t.lineWidth=2*(window.devicePixelRatio||1),t.beginPath();for(let a=0;a<u;a++){let h=a/u*Math.PI*2,C=r[a]/255*(d*.8),y=d+C,v=c+y*Math.cos(h),g=o+y*Math.sin(h);a===0?t.moveTo(v,g):t.lineTo(v,g)}t.closePath(),t.stroke()}#x(){this.#v??=new IntersectionObserver(([t])=>{this.#b=t.isIntersecting,this.#b&&this.#o&&!this.#i&&!this.#d&&this.#p()}),this.#v.observe(this)}#_(){this.#g??=new ResizeObserver(()=>{this.#k(),this.#i||this.#a()}),this.#g.observe(this.#t)}#B(){let t=window.matchMedia("(prefers-reduced-motion: reduce)");this.listen(t,"change",e=>{this.#d=e.matches,this.#d?(this.#w(),this.#a()):this.#o&&this.#b&&!this.#i&&this.#p()})}};E("audio-visualizer",p);export{p as AudioVisualizerElement};
|
|
20
20
|
//# sourceMappingURL=audio-visualizer.js.map
|