vanilla-breeze 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +22381 -13213
- 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 +5 -5
- 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 +6 -6
- 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 +51 -50
- package/dist/cdn/components/comment-thread.js +50 -49
- package/dist/cdn/components/comment-wc.js +1 -1
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/consent-banner.js +1 -1
- package/dist/cdn/components/content-lens.js +1 -1
- package/dist/cdn/components/content-swap.js +1 -1
- package/dist/cdn/components/context-menu.js +1 -1
- package/dist/cdn/components/data-table.js +1 -1
- package/dist/cdn/components/date-picker.js +1 -1
- package/dist/cdn/components/day-view.js +1 -1
- package/dist/cdn/components/diagram-wc.js +2 -2
- package/dist/cdn/components/drag-surface.js +1 -1
- package/dist/cdn/components/drop-down.js +1 -1
- package/dist/cdn/components/emoji-picker.js +1 -1
- package/dist/cdn/components/flow-diagram.js +1 -1
- package/dist/cdn/components/foot-notes.js +1 -1
- package/dist/cdn/components/form-field.js +1 -1
- package/dist/cdn/components/geo-map.js +170 -54
- package/dist/cdn/components/glossary-index.js +1 -1
- package/dist/cdn/components/glossary-wc.js +1 -1
- package/dist/cdn/components/heading-links.js +1 -1
- package/dist/cdn/components/highlight-wc.js +6 -2
- package/dist/cdn/components/icon-wc.js +11 -10
- package/dist/cdn/components/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/manifest.json +101 -101
- package/dist/cdn/components/markdown-editor.js +60 -1
- package/dist/cdn/components/markdown-viewer.js +50 -49
- package/dist/cdn/components/nav-bar.js +1 -1
- package/dist/cdn/components/note-wc.js +6 -2
- package/dist/cdn/components/notification-wc.js +33 -32
- package/dist/cdn/components/page-info.js +6 -72
- package/dist/cdn/components/page-stats.js +1 -1
- package/dist/cdn/components/page-toc.js +1 -1
- package/dist/cdn/components/page-tools.js +1 -1
- package/dist/cdn/components/page-tour.js +1 -38
- package/dist/cdn/components/pager-wc.js +1 -1
- package/dist/cdn/components/poll-wc.js +1 -1
- package/dist/cdn/components/pop-over.js +1 -1
- package/dist/cdn/components/popularity-index.js +1 -8
- package/dist/cdn/components/print-page.js +1 -1
- package/dist/cdn/components/progress-tracker.js +1 -1
- package/dist/cdn/components/qr-code.js +1 -1
- package/dist/cdn/components/reaction-bar.js +1 -1
- package/dist/cdn/components/reader-view.js +25 -25
- package/dist/cdn/components/reading-progress.js +1 -1
- package/dist/cdn/components/recently-visited.js +1 -26
- package/dist/cdn/components/score-card.js +21 -5
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/settings-panel.js +88 -142
- package/dist/cdn/components/share-wc.js +2 -2
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -10
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +1 -51
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/status-wc.js +1 -1
- package/dist/cdn/components/stepper-wc.js +1 -1
- package/dist/cdn/components/tab-set.js +1 -1
- package/dist/cdn/components/text-reader.js +2 -2
- package/dist/cdn/components/theme-picker.js +86 -83
- package/dist/cdn/components/time-index.js +1 -11
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +6 -6
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +6 -3
- package/dist/cdn/components/trust-filter.js +1 -3
- package/dist/cdn/components/version-switcher.js +5 -5
- package/dist/cdn/components/video-player.js +67 -9
- package/dist/cdn/components/watch-wc.js +6 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/emoji-extended.js +2 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-OFL.txt +93 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-italic.woff2 +0 -0
- package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2 +0 -0
- package/dist/cdn/fonts/latinmodern-math-GUST-LICENSE.txt +30 -0
- package/dist/cdn/fonts/latinmodern-math.woff2 +0 -0
- package/dist/cdn/fonts/math-fonts.css +14 -0
- package/dist/cdn/packs/effects.full.css +1 -1
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/fonts-display.full.css +1 -1
- package/dist/cdn/packs/fonts-display.theme.css +1 -1
- package/dist/cdn/packs/icons.bundle.js +1 -1
- package/dist/cdn/packs/icons.full.css +1 -1
- package/dist/cdn/packs/icons.theme.css +1 -1
- package/dist/cdn/packs/journal.effects.css +1 -1
- package/dist/cdn/packs/journal.full.css +1 -1
- package/dist/cdn/packs/kawaii.effects.css +1 -1
- package/dist/cdn/packs/kawaii.full.css +2 -2
- package/dist/cdn/packs/kawaii.full.js +4 -4
- package/dist/cdn/packs/kawaii.theme.css +1 -1
- package/dist/cdn/packs/manifest.json +17 -17
- package/dist/cdn/packs/memphis.full.css +1 -1
- package/dist/cdn/packs/memphis.theme.css +1 -1
- package/dist/cdn/packs/ui.full.css +1 -1
- package/dist/cdn/packs/ui.full.js +89 -86
- package/dist/cdn/themes/8bit.css +1 -1
- package/dist/cdn/themes/8bit.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
- package/dist/cdn/themes/alpha1999.css +1 -1
- package/dist/cdn/themes/alpha1999.tokens.json +1 -1
- package/dist/cdn/themes/art-deco-dark.tokens.json +1 -1
- package/dist/cdn/themes/art-deco.css +1 -1
- package/dist/cdn/themes/art-deco.tokens.json +1 -1
- 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 +1 -1
- package/dist/cdn/themes/brutalist-dark.tokens.json +1 -1
- package/dist/cdn/themes/brutalist.css +1 -1
- package/dist/cdn/themes/brutalist.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-frappe.css +1 -1
- package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-latte.css +1 -1
- package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
- package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
- package/dist/cdn/themes/catppuccin-mocha.css +1 -1
- package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
- package/dist/cdn/themes/classic-dark.tokens.json +1 -1
- package/dist/cdn/themes/classic.css +1 -1
- package/dist/cdn/themes/classic.tokens.json +1 -1
- package/dist/cdn/themes/claymorphism-dark.tokens.json +1 -1
- package/dist/cdn/themes/claymorphism.css +1 -1
- package/dist/cdn/themes/claymorphism.tokens.json +2 -1
- package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
- package/dist/cdn/themes/clinical.css +1 -1
- package/dist/cdn/themes/clinical.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
- package/dist/cdn/themes/cottagecore.css +1 -1
- package/dist/cdn/themes/cottagecore.tokens.json +1 -1
- package/dist/cdn/themes/cyber.css +1 -1
- package/dist/cdn/themes/cyber.tokens.json +1 -1
- package/dist/cdn/themes/dawn-dark.tokens.json +1 -1
- package/dist/cdn/themes/dawn.css +1 -1
- package/dist/cdn/themes/dawn.tokens.json +1 -1
- package/dist/cdn/themes/dracula.css +1 -1
- package/dist/cdn/themes/dracula.tokens.json +1 -1
- package/dist/cdn/themes/dusk.css +1 -1
- package/dist/cdn/themes/dusk.tokens.json +1 -1
- package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
- package/dist/cdn/themes/editorial.css +1 -1
- package/dist/cdn/themes/editorial.tokens.json +1 -1
- package/dist/cdn/themes/financial-dark.tokens.json +1 -1
- package/dist/cdn/themes/financial.css +1 -1
- package/dist/cdn/themes/financial.tokens.json +1 -1
- package/dist/cdn/themes/genai.css +1 -1
- package/dist/cdn/themes/genai.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism-dark.tokens.json +1 -1
- package/dist/cdn/themes/glassmorphism.css +1 -1
- package/dist/cdn/themes/glassmorphism.tokens.json +1 -1
- package/dist/cdn/themes/government-dark.tokens.json +1 -1
- package/dist/cdn/themes/government.css +1 -1
- package/dist/cdn/themes/government.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
- package/dist/cdn/themes/gruvbox.css +1 -1
- package/dist/cdn/themes/gruvbox.tokens.json +1 -1
- package/dist/cdn/themes/high-noon-dark.tokens.json +1 -1
- package/dist/cdn/themes/high-noon.css +1 -1
- package/dist/cdn/themes/high-noon.tokens.json +1 -1
- package/dist/cdn/themes/journal-dark.tokens.json +4 -2
- package/dist/cdn/themes/journal.css +1 -1
- package/dist/cdn/themes/journal.tokens.json +4 -2
- package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
- package/dist/cdn/themes/kawaii.css +1 -1
- package/dist/cdn/themes/kawaii.tokens.json +1 -1
- package/dist/cdn/themes/magna-dark.tokens.json +1 -1
- package/dist/cdn/themes/magna.css +1 -1
- package/dist/cdn/themes/magna.tokens.json +1 -1
- package/dist/cdn/themes/manifest.json +44 -44
- package/dist/cdn/themes/midnight.css +1 -1
- package/dist/cdn/themes/midnight.tokens.json +1 -1
- package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
- package/dist/cdn/themes/minimal.css +1 -1
- package/dist/cdn/themes/minimal.tokens.json +1 -1
- package/dist/cdn/themes/modern-dark.tokens.json +1 -1
- package/dist/cdn/themes/modern.css +1 -1
- package/dist/cdn/themes/modern.tokens.json +1 -1
- package/dist/cdn/themes/nes-dark.tokens.json +7 -2
- package/dist/cdn/themes/nes.css +1 -1
- package/dist/cdn/themes/nes.tokens.json +1 -1
- package/dist/cdn/themes/neumorphism-dark.tokens.json +1 -1
- package/dist/cdn/themes/neumorphism.css +1 -1
- package/dist/cdn/themes/neumorphism.tokens.json +1 -1
- package/dist/cdn/themes/nord-dark.tokens.json +1 -1
- 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.css +1 -1
- package/dist/cdn/themes/organic.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
- package/dist/cdn/themes/rose-pine.css +1 -1
- package/dist/cdn/themes/rose-pine.tokens.json +1 -1
- package/dist/cdn/themes/rough-dark.tokens.json +1 -1
- package/dist/cdn/themes/rough.css +1 -1
- package/dist/cdn/themes/rough.tokens.json +1 -1
- package/dist/cdn/themes/solarized-dark.tokens.json +1 -1
- package/dist/cdn/themes/solarized.css +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 +1 -1
- 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 +1 -1
- package/dist/cdn/themes/swiss.css +1 -1
- package/dist/cdn/themes/swiss.tokens.json +1 -1
- package/dist/cdn/themes/terminal.css +1 -1
- package/dist/cdn/themes/terminal.tokens.json +1 -1
- package/dist/cdn/themes/tokyo-night-dark.tokens.json +1 -1
- 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 +1 -1
- package/dist/cdn/themes/vaporwave.css +1 -1
- package/dist/cdn/themes/vaporwave.tokens.json +1 -1
- package/dist/cdn/themes/win9x-dark.tokens.json +6 -2
- package/dist/cdn/themes/win9x.css +1 -1
- package/dist/cdn/themes/win9x.tokens.json +3 -1
- package/dist/cdn/vanilla-breeze-autoload.js +187 -297
- package/dist/cdn/vanilla-breeze-charts.css +1 -1
- package/dist/cdn/vanilla-breeze-charts.js +6 -6
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +166 -262
- package/dist/cdn/vanilla-breeze-dev.js +1 -1
- package/dist/cdn/vanilla-breeze-extras.js +272 -130
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +536 -621
- package/dist/cdn/view-transitions.css +2 -0
- package/package.json +15 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var C=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function h(n,e,t={}){let i=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:i},o=p.get(n);if(customElements.get(n)){if(!o||o.priority>=i){o&&o.priority===i&&o.impl!==e&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=i){o.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${o.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}p.set(n,r),customElements.define(n,e)}var s=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,i,r){e.addEventListener(t,i,r),this.#e.push(()=>e.removeEventListener(t,i,r))}_reinit(){for(let e of this.#e)e();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,t){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{t?i.add(e):i.delete(e)}catch{let r=`--${e}`;t?i.add(r):i.delete(r)}}_adoptInternals(e){this.#t||(this.#t=e)}};var c="[data-copy], [data-copy-target], [data-paste-target]",y="Copied to clipboard",E="Pasted from clipboard",a=new WeakMap;async function l(n,e={}){if(n==null||n==="")return!1;let{button:t,announceMessage:i=y,duration:r=1500}=e;try{await navigator.clipboard.writeText(n)}catch{return!1}return b({button:t,duration:r,announceMessage:i,eventDetail:{text:n}}),!0}function b({button:n,duration:e,announceMessage:t,eventDetail:i,state:r="copied",eventName:o="copy"}){if(n){n.dataset.state=r;let f=a.get(n);f&&clearTimeout(f),a.set(n,setTimeout(()=>{delete n.dataset.state,a.delete(n)},e)),n.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:i}))}T(t,n??document.body)}async function v(n,e={}){let{button:t,announceMessage:i=E,duration:r=1500}=e,o;try{o=await navigator.clipboard.readText()}catch{return null}return n&&("value"in n&&(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement)?n.value=o:n.textContent=o,n.dispatchEvent(new Event("input",{bubbles:!0}))),b({button:t,duration:r,announceMessage:i,eventDetail:{text:o},state:"pasted",eventName:"paste"}),o}function m(n=document){n.querySelectorAll(c).forEach(d)}function d(n){n.hasAttribute("data-copy-init")||(n.setAttribute("data-copy-init",""),n.addEventListener("click",()=>{if(n.dataset.pasteTarget){let t=document.querySelector(n.dataset.pasteTarget);if(!t)return;v(t,{button:n});return}let e=w(n);e&&l(e,{button:n})}))}function w(n){if(n.dataset.copy)return n.dataset.copy;if(n.dataset.copyTarget){let e=document.querySelector(n.dataset.copyTarget);if(!e)return"";let t=n.dataset.copyAttr;return t?e.getAttribute(t)??"":e.textContent??""}return""}function T(n,e){let t=document.createElement("div");t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.className="visually-hidden",t.textContent=n,e.appendChild(t),setTimeout(()=>t.remove(),1e3)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>m()):m();var A=new MutationObserver(n=>{for(let e of n)for(let t of e.addedNodes){if(t.nodeType!==Node.ELEMENT_NODE)continue;let i=t;i.matches(c)&&d(i),i.querySelectorAll(c).forEach(r=>d(r))}});A.observe(document.documentElement,{childList:!0,subtree:!0});var u=class extends s{#e;#t=new WeakSet;setup(){this.#n(),this.#e=new MutationObserver(e=>{for(let t of e)t.type==="childList"&&this.#n()}),this.#e.observe(this,{childList:!0,subtree:!0})}teardown(){this.#e?.disconnect()}#n(){let t=(this.getAttribute("levels")||"h2,h3").split(",").map(r=>r.trim()).join(","),i=this.querySelectorAll(t);for(let r of i)this.#t.has(r)||(this.#i(r),this.#t.add(r))}#i(e){if(e.closest("dialog, [data-toc-ignore]")||e.hasAttribute("data-toc-ignore")||(e.id||(e.id=this.#r(e.textContent)),e.querySelector(".heading-anchor")))return;let t=document.createElement("a");t.className="heading-anchor",t.href=`#${e.id}`,t.setAttribute("aria-label",`Link to ${e.textContent.trim()}`),t.innerHTML='<icon-wc name="link" size="sm"></icon-wc>',t.addEventListener("click",i=>{i.preventDefault(),this.#o(e,t)}),e.appendChild(t),e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1")}#r(e){let t=e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").substring(0,50),i=t,r=1;for(;document.getElementById(i);)i=`${t}-${r}`,r++;return i}async#o(e,t){let i=new URL(window.location.href);if(i.hash=e.id,window.history.pushState(null,"",i),e.scrollIntoView({behavior:"smooth",block:"start"}),e.focus(),await l(i.href,{button:t,announceMessage:"Link copied to clipboard"})){let o=t.innerHTML;t.innerHTML='<icon-wc name="check" size="sm"></icon-wc>',t.classList.add("copied"),setTimeout(()=>{t.innerHTML=o,t.classList.remove("copied")},1500)}this.dispatchEvent(new CustomEvent("heading-links:navigate",{bubbles:!0,detail:{id:e.id,url:i.href}}))}};h("heading-links",u);export{u as HeadingLinks};
|
|
1
|
+
var B=window.matchMedia("(prefers-reduced-motion: reduce)");var b=new Map;function y(n,e,t={}){let r=t.priority??10,i={impl:e,bundle:t.bundle,contract:t.contract,priority:r},a=b.get(n);if(customElements.get(n)){if(!a||a.priority>=r){a&&a.priority===r&&a.impl!==e&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${a.bundle}" (priority ${a.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${a.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(a&&a.priority>=r){a.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${a.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}b.set(n,i),customElements.define(n,e)}var l=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 e of this.#t)e();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,r,i){e.addEventListener(t,r,i),this.#t.push(()=>e.removeEventListener(t,r,i))}_reinit(){for(let e of this.#t)e();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,t){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{t?r.add(e):r.delete(e)}catch{let i=`--${e}`;t?r.add(i):r.delete(i)}}_adoptInternals(e){this.#e||(this.#e=e)}#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}};var k=["position:absolute","inline-size:1px","block-size:1px","padding:0","margin:-1px","overflow:hidden","clip-path:inset(50%)","white-space:nowrap","border:0"].join(";"),g=new WeakMap;function C(n,e){let t=g.get(e);t||g.set(e,t=new Map);let r=t.get(n);if(!r||!r.region.isConnected){let a=(e.ownerDocument||document).createElement("span");a.setAttribute("data-vb-announcer",n),a.setAttribute("role",n==="assertive"?"alert":"status"),a.setAttribute("aria-live",n),a.setAttribute("aria-atomic","true"),a.style.cssText=k,e.appendChild(a),r={region:a},t.set(n,r)}return r}function v(n,{politeness:e="polite",root:t}={}){let r=String(n??"").trim();if(!r||typeof document>"u")return null;let i=t||document.body;if(!i)return null;let o=C(e==="assertive"?"assertive":"polite",i);return clearTimeout(o.write),clearTimeout(o.clear),o.region.textContent="",o.write=setTimeout(()=>{o.region.textContent=r,o.clear=setTimeout(()=>{o.region.textContent=""},7e3)},50),o.region}function s(n,e,t,r){let i=`data-label-${e}`,o=n?.closest?.(`[${i}]`)?.getAttribute(i)||t;return r?o.replace(/\{(\w+)\}/g,(u,m)=>m in r?String(r[m]):u):o}var E=1500,T="[data-copy], [data-copy-target], [data-paste-target]",c={copied:"Copied to clipboard",pasted:"Pasted from clipboard","copy-failed":"Copy failed","copy-failed-selected":"Copy failed. Text selected, press Ctrl+C to copy","paste-failed":"Paste failed"},f=new WeakMap;function M(n){if(typeof document.execCommand!="function"||!document.body)return!1;let e=document.activeElement,t=document.createElement("textarea");t.value=n,t.setAttribute("readonly",""),t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none",document.body.appendChild(t),t.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}return t.remove(),e?.focus?.({preventScroll:!0}),r}function L(n){if(!n)return!1;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n.focus(),n.select(),!0;let e=window.getSelection?.();if(!e)return!1;let t=document.createRange();return t.selectNodeContents(n),e.removeAllRanges(),e.addRange(t),!e.isCollapsed}async function p(n,e={}){if(n==null||n==="")return!1;let{button:t,duration:r=E}=e,i=!1,a=null;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(n),i=!0}catch(u){a=u,i=M(n)}if(i)return d({button:t,duration:r,state:"copied",eventName:"copy:done",eventDetail:{text:n},message:e.announceMessage??s(t,"copied",c.copied)}),!0;let o=L(e.source);return d({button:t,duration:r,state:"failed",eventName:"copy:error",eventDetail:{text:n,error:a},message:e.failureMessage??s(t,"copy-failed",o?c["copy-failed-selected"]:c["copy-failed"])}),!1}function d({button:n,duration:e,message:t,eventDetail:r,state:i,eventName:a}){if(n){n.dataset.state=i;let o=f.get(n);o&&clearTimeout(o),f.set(n,setTimeout(()=>{n.dataset.state===i&&delete n.dataset.state,f.delete(n)},e)),n.dispatchEvent(new CustomEvent(a,{bubbles:!0,detail:r}))}v(t,{politeness:i==="failed"?"assertive":"polite"})}async function S(n,e={}){let{button:t,duration:r=E}=e,i;try{if(!navigator.clipboard?.readText)throw new Error("Clipboard API unavailable");i=await navigator.clipboard.readText()}catch(a){return d({button:t,duration:r,state:"failed",eventName:"paste:error",eventDetail:{target:n,error:a},message:e.failureMessage??s(t,"paste-failed",c["paste-failed"])}),null}return n&&(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement?n.value=i:n.textContent=i,n.dispatchEvent(new Event("input",{bubbles:!0}))),d({button:t,duration:r,state:"pasted",eventName:"paste:done",eventDetail:{text:i,target:n},message:e.announceMessage??s(t,"pasted",c.pasted)}),i}function w(n){let e=n.dataset.copyTarget;if(!e)return null;try{return document.querySelector(e)}catch{return null}}function $(n){if(n.dataset.copy)return n.dataset.copy;let e=w(n);if(!e)return"";let t=n.dataset.copyAttr;return t?e.getAttribute(t)??"":e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.textContent??""}function N(n){let e=n.target?.closest?.(T);if(!e||e.matches(':disabled, [aria-disabled="true"]'))return;if(e.dataset.pasteTarget){let r=null;try{r=document.querySelector(e.dataset.pasteTarget)}catch{}if(!r)return;S(r,{button:e});return}let t=$(e);t&&p(t,{button:e,source:w(e)??void 0})}typeof document<"u"&&!document.__vbCopyDelegated&&(document.__vbCopyDelegated=!0,document.addEventListener("click",N));var D=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;function A(n,e){let r=(()=>{try{return decodeURIComponent(location.hash.slice(1))}catch{return location.hash.slice(1)}})()===e;r||(location.hash=e);let i=n;typeof i.focus=="function"&&(i.tabIndex<0&&!i.hasAttribute("tabindex")&&i.setAttribute("tabindex","-1"),i.focus({preventScroll:!0})),(r||!i.matches?.(":target"))&&i.scrollIntoView({behavior:D()?"auto":"smooth",block:"start"})}var I="dialog, [data-toc-ignore], browser-window";function x(n){return!!n.closest(I)}var _=["h2","h3"],R=1500,q=0;function F(n){let e=String(n).normalize("NFC").toLowerCase().trim().replace(/[^\p{L}\p{M}\p{N}\s_-]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");return Array.from(e).slice(0,50).join("").replace(/-$/,"")||"section"}function V(n,e){let t=n,r=1;for(;e(t);)t=`${n}-${r++}`;return t}function H(n){let e=(n??"").split(",").map(t=>t.trim().toLowerCase()).filter(t=>/^h[1-6]$/.test(t));return e.length?[...new Set(e)]:_}var h=class extends l{static get observedAttributes(){return["levels","data-label-anchor"]}#t;#e=new WeakMap;setup(){this.#r(),this.listen(this,"click",this.#s),this.#t=new MutationObserver(e=>{e.some(t=>t.type==="childList")&&this.#r()}),this.#t.observe(this,{childList:!0,subtree:!0})}teardown(){this.#t?.disconnect(),this.#t=void 0}attributeChangedCallback(e,t,r){t===r||!this.hasAttribute("data-upgraded")||this.#r()}get#n(){return this.getAttribute("data-label-anchor")||"Copy link to"}#i(e){return e.closest("heading-links")!==this?!1:!x(e)}#r(){let e=H(this.getAttribute("levels")).join(","),t=this.#n;for(let r of this.querySelectorAll(".heading-anchor[data-heading-links]")){if(r.closest("heading-links")!==this)continue;let i=r.parentElement;!i||!i.matches(e)||!this.#i(i)?this.#o(i,r):r.getAttribute("aria-label")!==t&&r.setAttribute("aria-label",t)}for(let r of this.querySelectorAll(e))this.#i(r)&&this.#a(r)}#a(e){if(e.id||(e.id=V(F(e.textContent??""),o=>!!document.getElementById(o))),e.querySelector(":scope > .heading-anchor"))return;let t=++q,r=document.createElement("span");r.className="heading-text",r.id=`heading-links-text-${t}`,r.append(...e.childNodes),e.append(r),!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&(e.setAttribute("aria-labelledby",r.id),e.setAttribute("data-heading-links-labelled",""));let i=document.createElement("a");i.className="heading-anchor",i.id=`heading-links-anchor-${t}`,i.dataset.headingLinks="",i.href=`#${e.id}`,i.setAttribute("aria-label",this.#n),i.setAttribute("aria-labelledby",`${i.id} ${r.id}`);let a=document.createElement("icon-wc");a.setAttribute("name","link"),a.setAttribute("size","sm"),i.append(a),e.append(i),e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1")}#o(e,t){if(t.remove(),!e)return;let r=e.querySelector(":scope > .heading-text");r&&r.replaceWith(...r.childNodes),e.hasAttribute("data-heading-links-labelled")&&(e.removeAttribute("aria-labelledby"),e.removeAttribute("data-heading-links-labelled"))}#s=e=>{let t=e,i=(t.target instanceof Element?t.target:null)?.closest("a.heading-anchor[data-heading-links]");if(!i||i.closest("heading-links")!==this||t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let a=i.parentElement;a?.id&&(t.preventDefault(),this.#c(a,i))};async#c(e,t){A(e,e.id);let r=new URL(document.URL);if(r.hash=e.id,this.dispatchEvent(new CustomEvent("heading-links:navigate",{bubbles:!0,detail:{id:e.id,url:r.href,heading:e}})),!await p(r.href,{announceMessage:this.getAttribute("data-label-copied")||"Link copied to clipboard"}))return;let a=t.querySelector("icon-wc");t.dataset.state="copied",a?.setAttribute("name","check"),clearTimeout(this.#e.get(t)),this.#e.set(t,setTimeout(()=>{delete t.dataset.state,a?.setAttribute("name","link"),this.#e.delete(t)},R))}};y("heading-links",h);export{h as HeadingLinks,F as headingSlug,H as parseLevels,V as uniqueSlug};
|
|
2
2
|
//# sourceMappingURL=heading-links.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)
|
|
1
|
+
var m=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,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.#n||(this.#n=this.attachInternals());let i=this.#n.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#n||(this.#n=t)}#i(){return this.constructor.formAssociated&&this.#n?this.#n:null}get validity(){return this.#i()?.validity}get validationMessage(){return this.#i()?.validationMessage??""}get willValidate(){return this.#i()?.willValidate??!1}get form(){return this.#i()?.form??null}checkValidity(){return this.#i()?.checkValidity()??!0}reportValidity(){return this.#i()?.reportValidity()??!0}};var rt=window.matchMedia("(prefers-reduced-motion: reduce)");var T=new Map;function $(r,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=T.get(r);if(customElements.get(r)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}T.set(r,n),customElements.define(r,t)}function q(){let r=globalThis.localStorage;if(!r)throw new Error("VBStore: localStorage is not available in this environment");return{async getRaw(t){return r.getItem(t)},async setRaw(t,e){r.setItem(t,e)},async removeRaw(t){r.removeItem(t)},async keys(t){let e=[];for(let i=0;i<r.length;i++){let n=r.key(i);n&&n.startsWith(t)&&e.push(n)}return e}}}var y="__vbStoreBackend",b=globalThis;function c(){return b[y]||(b[y]=q()),b[y]}function C(r,t){if(typeof r!="string"||!r)throw new TypeError("VBStore: namespace must be a non-empty string");if(typeof t!="string"||!t)throw new TypeError("VBStore: key must be a non-empty string");return`vb:${r}:${t}`}function N(r){if(typeof r!="string"||!r)throw new TypeError("VBStore: namespace must be a non-empty string");return`vb:${r}:`}function M(r){try{let t=JSON.parse(r);if(t&&typeof t=="object"&&typeof t.timestamp=="number")return t}catch{}return null}var g={configure(r={}){b[y]=r.backend??null},async set(r,t,e){let i={data:e,timestamp:Date.now()};await c().setRaw(C(r,t),JSON.stringify(i))},async get(r,t,e){let i=await c().getRaw(C(r,t));if(i==null)return null;let n=M(i);return!n||e?.maxAge!=null&&Date.now()-n.timestamp>e.maxAge?null:n.data},async remove(r,t){await c().removeRaw(C(r,t))},async list(r){let t=N(r),e=await c().keys(t),i=[];for(let n of e){let s=await c().getRaw(n);if(s==null)continue;let o=M(s);o&&i.push({key:n.slice(t.length),data:o.data,timestamp:o.timestamp})}return i},async clear(r){let t=N(r),e=await c().keys(t);for(let i of e)await c().removeRaw(i)},async clearAll(){let r=await c().keys("vb:");for(let t of r)await c().removeRaw(t)},async setMany(r,t){for(let[e,i]of t)await g.set(r,e,i)}};if(typeof window<"u"){let r=window.VB??(window.VB={});r.store??=g}var W=["position:absolute","inline-size:1px","block-size:1px","padding:0","margin:-1px","overflow:hidden","clip-path:inset(50%)","white-space:nowrap","border:0"].join(";"),L=new WeakMap;function j(r,t){let e=L.get(t);e||L.set(t,e=new Map);let i=e.get(r);if(!i||!i.region.isConnected){let s=(t.ownerDocument||document).createElement("span");s.setAttribute("data-vb-announcer",r),s.setAttribute("role",r==="assertive"?"alert":"status"),s.setAttribute("aria-live",r),s.setAttribute("aria-atomic","true"),s.style.cssText=W,t.appendChild(s),i={region:s},e.set(r,i)}return i}function w(r,{politeness:t="polite",root:e}={}){let i=String(r??"").trim();if(!i||typeof document>"u")return null;let n=e||document.body;if(!n)return null;let o=j(t==="assertive"?"assertive":"polite",n);return clearTimeout(o.write),clearTimeout(o.clear),o.region.textContent="",o.write=setTimeout(()=>{o.region.textContent=i,o.clear=setTimeout(()=>{o.region.textContent=""},7e3)},50),o.region}var x="[data-highlights]",_="highlights",z=["yellow","green","blue","pink"];var U=typeof CSS<"u"&&"highlights"in CSS,E=new WeakMap;function B(r){let t=2166136261;for(let e=0;e<r.length;e++)t^=r.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function D(){return"hn-"+crypto.randomUUID().slice(0,8)}var X=/^[a-z0-9_-]+$/i,I=["solid","double","dotted","dashed","wavy"],Y={annotation:"You highlighted",added:"Highlight added",removed:"Highlight removed",noteSaved:"Note saved"};function A(r,t){let e="highlightsLabel"+t[0].toUpperCase()+t.slice(1);return r.dataset[e]||Y[t]}function G(r,{textLength:t,colors:e}){if(!r||typeof r!="object")return null;let i=r,{startOffset:n,endOffset:s,color:o}=i;if(!Number.isInteger(n)||!Number.isInteger(s))return null;let h=n,a=s;return h<0||a<=h||a>t||!k(o)||!e.includes(o)||i.id!=null&&(typeof i.id!="string"||!/^[\w-]{1,64}$/.test(i.id))||i.text!=null&&typeof i.text!="string"||i.note!=null&&typeof i.note!="string"?null:{id:i.id||D(),startOffset:h,endOffset:a,text:i.text??"",color:o,note:i.note??"",created:Number.isFinite(i.created)?i.created:Date.now()}}function k(r){return typeof r=="string"&&X.test(r)}var d=null,u=new Map,p=new Map;function V(){if(u.size===0){d&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(i=>i!==d),d=null);return}d||(d=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,d]);let r=[...u.keys()],t=r.map(i=>`::highlight(hn-${i}) { background-color: var(--highlight-${i}); color: var(--highlight-${i}-ink, var(--highlight-ink, CanvasText)); text-decoration-line: underline; text-decoration-color: var(--highlight-${i}); text-underline-offset: 2px; }`),e=r.map((i,n)=>`::highlight(hn-${i}) { background-color: Mark; color: MarkText; text-decoration-line: underline; text-decoration-color: MarkText; text-decoration-style: ${I[n%I.length]}; text-decoration-thickness: 2px; }`);d.replaceSync(`${t.join(`
|
|
2
|
+
`)}
|
|
3
|
+
@media (forced-colors: active) {
|
|
4
|
+
${e.join(`
|
|
5
|
+
`)}
|
|
6
|
+
}`)}function J(r){for(let t of r)u.set(t,(u.get(t)??0)+1);V()}function K(r){for(let t of r){let e=(u.get(t)??0)-1;e>0?u.set(t,e):u.delete(t)}V()}function Q(r){let t=p.get(r),e=t?[...t.values()].flat():[];e.length===0?(CSS.highlights.delete(`hn-${r}`),p.delete(r)):CSS.highlights.set(`hn-${r}`,new Highlight(...e))}function H(r,t){let e=new Set(t.keys());for(let[i,n]of p)n.has(r)&&e.add(i);for(let i of e){let n=t.get(i)??[],s=p.get(i);n.length?(s||p.set(i,s=new Map),s.set(r,n)):s?.delete(r),Q(i)}}function P(r,t,e){let i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),n=0;for(;i.nextNode();){if(i.currentNode===t)return n+e;n+=(i.currentNode.textContent??"").length}return-1}function S(r,t,e){let i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),n=0,s=null,o=0,h=null,a=0;for(;i.nextNode();){let l=i.currentNode,v=(l.textContent??"").length;if(!s&&n+v>t&&(s=l,o=t-n),n+v>=e){h=l,a=e-n;break}n+=v}if(!s||!h)return null;try{let l=document.createRange();return l.setStart(s,Math.min(o,(s.textContent??"").length)),l.setEnd(h,Math.min(a,(h.textContent??"").length)),l}catch{return null}}var O=class{#t;#n;#i;#o;#e=[];#h=!U;#s;#f;#r=!1;#p=[];#a=new Map;constructor(t){this.#t=t,this.#o=t.hasAttribute("data-highlights-readonly");let e=t.dataset.highlights;this.#n=e&&e!==""?e:location.pathname;let i=t.dataset.highlightsColors,n=i?i.split(",").map(s=>s.trim()).filter(k):[...z];this.#i=[...new Set(n)],this.#h||J(this.#i),this.#u(),this.#o||(this.#s=this.#b.bind(this),this.#f=this.#g.bind(this),t.addEventListener("pointerup",this.#s),t.addEventListener("click",this.#f)),t.setAttribute("data-highlights-init",""),this.#c().then(()=>{this.#r||this.#u()})}get colors(){return[...this.#i]}get destroyed(){return this.#r}get element(){return this.#t}getHighlights(){return this.#e.map(t=>({...t}))}removeHighlight(t){let e=this.#e.findIndex(i=>i.id===t);e<0||(this.#e.splice(e,1),this.#d(),this.#u(),this.#l("highlights:removed",{id:t}),w(A(this.#t,"removed")))}clearAll(){this.#e=[],this.#d(),this.#u()}exportHighlights(){return JSON.stringify({version:1,highlights:this.#e})}importHighlights(t){let e;try{e=typeof t=="string"?JSON.parse(t):t}catch{return{imported:0,rejected:0}}if(!e||!Array.isArray(e.highlights))return{imported:0,rejected:0};let i=this.#m(e.highlights);return this.#e=i,this.#d(),this.#u(),{imported:i.length,rejected:e.highlights.length-i.length}}#m(t){let e={textLength:(this.#t.textContent??"").length,colors:this.#i},i=new Set,n=[];for(let s of t){let o=G(s,e);!o||i.has(o.id)||(i.add(o.id),n.push(o))}return n}destroy(){this.#r||(this.#r=!0,this.#s&&this.#t.removeEventListener("pointerup",this.#s),this.#f&&this.#t.removeEventListener("click",this.#f),this.#h?this.#t.querySelectorAll("mark[data-hn-id]").forEach(t=>{let e=t.parentNode;for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t),e.normalize()}):(H(this,new Map),K(this.#i)),this.#S(),this.#a.clear(),this.#t.removeAttribute("data-highlights-init"),E.get(this.#t)===this&&E.delete(this.#t))}#b(){requestAnimationFrame(()=>{if(this.#r)return;let t=window.getSelection();if(!t||t.isCollapsed||!t.toString().trim())return;let e=t.getRangeAt(0);this.#t.contains(e.commonAncestorContainer)&&this.#l("highlights:selected",{text:t.toString().trim(),rect:e.getBoundingClientRect()})})}#g(t){let e=t.target.closest?.(".hn-margin-annotation");if(e){let n=e.dataset.hnId,s=this.#e.find(o=>o.id===n);if(s){this.#l("highlights:clicked",{id:n,highlight:{...s}}),this.#l("highlights:request-note",{id:n,highlight:{...s},controller:this});return}}let i=t.target.closest?.("mark[data-hn-id]");if(i){let n=i.dataset.hnId,s=this.#e.find(o=>o.id===n);if(s){this.#l("highlights:clicked",{id:n,highlight:{...s}});return}}if(!this.#h){let n=this.#y(t.clientX,t.clientY);n&&this.#l("highlights:clicked",{id:n.id,highlight:{...n}})}}findHighlightRect(t){let e=this.#e.find(s=>s.id===t);if(!e)return null;let i=this.#A(e);if(!i)return null;let n=i.getClientRects();return n.length?n[0]:null}#A(t){return this.#a.get(t.id)??S(this.#t,t.startOffset,t.endOffset)}#w(){this.#a.clear();for(let t of this.#e){let e=S(this.#t,t.startOffset,t.endOffset);e&&this.#a.set(t.id,e)}}#y(t,e){for(let i of this.#e){let n=this.#a.get(i.id);if(!n)continue;let s=n.getClientRects();for(let o of s)if(t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom)return i}return null}_createFromSelection(t){let e=window.getSelection();if(!e||e.isCollapsed)return;let i=e.getRangeAt(0);if(!this.#t.contains(i.commonAncestorContainer))return;let n=P(this.#t,i.startContainer,i.startOffset),s=P(this.#t,i.endContainer,i.endOffset);if(n<0||s<0||n>=s)return;let o=e.toString().trim(),h={id:D(),startOffset:n,endOffset:s,text:o,color:t,note:"",created:Date.now()};this.#e.push(h),this.#d(),this.#u(),e.removeAllRanges(),this.#l("highlights:added",{id:h.id,text:o,color:t,note:""}),w(A(this.#t,"added"))}_changeColor(t,e){let i=this.#e.find(n=>n.id===t);i&&(i.color=e,this.#d(),this.#u())}_updateNote(t,e){let i=this.#e.find(n=>n.id===t);i&&(i.note=e,this.#d(),this.#E(),this.#l("highlights:note-changed",{id:t,note:e}),w(A(this.#t,"noteSaved")))}async#c(){let t=await g.get(_,this.#n);if(!t||!Array.isArray(t.highlights)||this.#r)return;let e=this.#m(t.highlights),i=B(this.#t.textContent);t.contentHash&&t.contentHash!==i?(this.#e=e.filter(n=>{let s=S(this.#t,n.startOffset,n.endOffset);return s?s.toString().trim()===n.text:!1}),this.#d()):this.#e=e}#d(){let t={version:1,contentHash:B(this.#t.textContent),highlights:this.#e};g.set(_,this.#n,t).catch(()=>{})}#u(){this.#h?(this.#C(),this.#w()):(this.#w(),this.#v()),this.#E()}#v(){let t=new Map;for(let e of this.#i)t.set(e,[]);for(let e of this.#e){let i=this.#a.get(e.id);i&&t.has(e.color)&&t.get(e.color).push(i)}H(this,t)}#C(){this.#t.querySelectorAll("mark[data-hn-id]").forEach(e=>{let i=e.parentNode;for(;e.firstChild;)i.insertBefore(e.firstChild,e);i.removeChild(e)}),this.#t.normalize();let t=[...this.#e].sort((e,i)=>i.startOffset-e.startOffset);for(let e of t){let i=S(this.#t,e.startOffset,e.endOffset);if(!i)continue;let n=document.createElement("mark");n.dataset.hnId=e.id,k(e.color)&&(n.dataset.hnColor=e.color,n.style.setProperty("--_hn-color",`var(--highlight-${e.color})`),n.style.setProperty("--_hn-ink",`var(--highlight-${e.color}-ink, var(--highlight-ink))`));try{i.surroundContents(n)}catch{let s=i.extractContents();n.appendChild(s),i.insertNode(n)}}}#S(){for(let t of this.#p)t.remove();this.#p=[]}#E(){if(this.#S(),this.#e.length===0)return;getComputedStyle(this.#t).position==="static"&&(this.#t.style.position="relative");let e=this.#t.getBoundingClientRect(),i=A(this.#t,"annotation");for(let n of this.#e){let s=this.#a.get(n.id);if(!s)continue;let o=s.getClientRects();if(o.length===0)continue;let h=o[0].top-e.top,a=document.createElement("span");if(a.className="hn-margin-annotation",a.dataset.hnId=n.id,a.setAttribute("aria-hidden","true"),a.style.insetBlockStart=`${h}px`,n.note){let l=document.createElement("span");l.className="hn-note-indicator",l.textContent="*",a.append(l,` ${i}`),a.classList.add("hn-has-note")}else a.textContent=i;this.#t.appendChild(a),this.#p.push(a)}}#l(t,e={}){this.#t.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}};function f(r){let t=E.get(r);if(t&&!t.destroyed)return t;let e=new O(r);return E.set(r,e),e}function F(r=document){r.querySelectorAll(x).forEach(t=>{t.hasAttribute("data-highlights-init")||f(t)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>F()):F();var Z=new MutationObserver(r=>{for(let t of r)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let i=e;i.matches(x)&&f(i),i.querySelectorAll(x).forEach(n=>{n.hasAttribute("data-highlights-init")||f(n)})}});Z.observe(document.documentElement,{childList:!0,subtree:!0});var tt=["yellow","green","blue","pink"],et=/^[a-z0-9_-]+$/i,it=["annotation","added","removed"],nt=0,R=class extends m{#t=null;#n=null;#i="yellow";#o=null;#e=null;#h=!1;#s=null;setup(){this.#o=this.closest("selection-menu");let t=this.#y();t.includes(this.#i)||(this.#i=t[0]??"yellow"),this.#o?this.#f():this.#A()}teardown(){this.#t?.destroy(),this.#t=null,this.#s?.remove(),this.#s=null,this.#h?this.#e?.remove():this.#e?.removeAttribute("aria-expanded"),this.#e=null,this.#h=!1,this.#o=null}#f(){let t=this.hasAttribute("readonly");for(let s of this.#b())this.#g(s);if(t)return;let e=this.#y(),i=this.querySelector(":scope > button");if(this.#h=!i,!i){i=document.createElement("button"),i.type="button",i.setAttribute("aria-label",this.dataset.labelButton||"Highlight selection");let s=document.createElement("icon-wc");s.setAttribute("name","highlighter"),s.setAttribute("size","sm"),s.setAttribute("aria-hidden","true"),i.appendChild(s),this.appendChild(i)}this.#e=i;let n=document.createElement("div");n.className="highlight-color-dropdown",n.id=`highlight-palette-${++nt}`,n.setAttribute("role","group"),n.setAttribute("aria-label",this.dataset.labelPalette||"Highlight color"),n.hidden=!0;for(let s of e){let o=document.createElement("button");o.type="button",o.className="highlight-color-swatch",o.dataset.color=s,o.title=s,o.setAttribute("aria-label",s),o.setAttribute("aria-pressed",String(s===this.#i)),o.style.setProperty("--_swatch",`var(--highlight-${s})`),n.appendChild(o)}this.appendChild(n),this.#s=n,i.setAttribute("aria-expanded","false"),i.setAttribute("aria-controls",n.id),this.listen(i,"click",s=>{s.stopPropagation(),this.#r(n.hidden)}),this.listen(n,"click",s=>{let o=s.target.closest?.(".highlight-color-swatch");o&&(s.stopPropagation(),this.#a(o.dataset.color??this.#i),this.#r(!1),this.#m(this.#i))}),this.listen(this,"keydown",s=>{let o=s;o.key!=="Escape"||n.hidden||(o.stopPropagation(),this.#r(!1),i.focus())}),this.listen(document,"pointerdown",s=>{!n.hidden&&!this.contains(s.target)&&this.#r(!1)}),this.listen(this.#o,"selection-menu:dismiss",()=>this.#r(!1))}#r(t){!this.#s||!this.#e||(this.#s.hidden=!t,this.#e.setAttribute("aria-expanded",String(t)),t&&(this.#p(),(this.#s.querySelector('[aria-pressed="true"]')??this.#s.firstElementChild)?.focus({preventScroll:!0})))}#p(){let t=this.#s;if(!t)return;t.style.removeProperty("--_hn-shift");let{left:e,right:i}=t.getBoundingClientRect(),n=8,s=e<n?n-e:i>window.innerWidth-n?window.innerWidth-n-i:0;s&&t.style.setProperty("--_hn-shift",`${s}px`)}#a(t){this.#i=t,this.#s?.querySelectorAll(".highlight-color-swatch").forEach(e=>e.setAttribute("aria-pressed",String(e.dataset.color===t)))}#m(t){let e=this.#o,i=e?.getSelection?.();if(!i?.target)return;let n=this.#g(i.target);if(!n)return;let s=window.getSelection();s&&(s.isCollapsed||!s.rangeCount)&&i.range&&(s.removeAllRanges(),s.addRange(i.range)),n._createFromSelection(t),this.#n=i.target,e.dismiss?.()}#b(){let t=this.#o;if(!t)return[];let e=new Set,i=t.getAttribute("for"),n=i&&document.getElementById(i);return n&&e.add(n),t.id&&document.querySelectorAll(`[data-selection-menu="${CSS.escape(t.id)}"]`).forEach(s=>e.add(s)),[...e]}#g(t){t.hasAttribute("data-highlights-init")||(t.setAttribute("data-highlights",this.getAttribute("storage-key")||""),this.hasAttribute("colors")&&t.setAttribute("data-highlights-colors",this.getAttribute("colors")??""));for(let i of it){let n=this.getAttribute(`data-label-${i}`);n&&t.setAttribute(`data-highlights-label-${i}`,n)}let e=f(t);return this.hasAttribute("readonly")&&!t.hasAttribute("data-highlights-readonly")&&(t.setAttribute("data-highlights-readonly",""),e.destroy(),e=f(t)),e}#A(){let t=this.#w();t&&(this.#t=this.#g(t))}#w(){let t=this.getAttribute("for");return t?document.getElementById(t):this.firstElementChild}#y(){let t=this.getAttribute("colors"),e=t?t.split(",").map(i=>i.trim()).filter(i=>et.test(i)):[];return e.length?[...new Set(e)]:[...tt]}#c(){if(this.#t&&!this.#t.destroyed)return this.#t;let t=this.#n?.isConnected?this.#n:this.#b()[0];return t?this.#g(t):null}highlightSelection(t=this.#i){this.hasAttribute("readonly")||!this.#y().includes(t)||(this.#a(t),this.#o?this.#m(t):this.#t?._createFromSelection(t))}getHighlights(){return this.#c()?.getHighlights()??[]}removeHighlight(t){this.#c()?.removeHighlight(t)}clearAll(){this.#c()?.clearAll()}exportHighlights(){return this.#c()?.exportHighlights()??'{"version":1,"highlights":[]}'}importHighlights(t){return this.#c()?.importHighlights(t)??{imported:0,rejected:0}}};$("highlight-wc",R);
|
|
3
7
|
//# sourceMappingURL=highlight-wc.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l({basePath:t,set:n,name:e}){return`${t}/${n}/${e}.svg`}function u(t,n=document){let e=t.getAttribute("data-icon-set");if(e)return e;let r=t.closest("[data-icon-set]")?.getAttribute("data-icon-set");return r||n.documentElement.dataset.iconSet||"lucide"}function f(t=document){return t.documentElement.dataset.iconPath||"/cdn/icons"}function m(t){let n=t.getAttribute("data-icon");if(!n){t.style.removeProperty("--vb-icon");return}let e=l({basePath:f(document),set:u(t,document),name:n});t.style.setProperty("--vb-icon",`url("${e}")`)}function d(t=document){for(let n of t.querySelectorAll("[data-icon]"))m(n)}var A=!1;function C(){if(A)return;A=!0,d(),new MutationObserver(n=>{for(let e of n)if(e.type==="attributes"){let r=e.target;r.hasAttribute&&r.hasAttribute("data-icon")&&m(r),e.attributeName==="data-icon-set"&&d(r)}else for(let r of e.addedNodes){if(r.nodeType!==1)continue;let o=r;o.hasAttribute("data-icon")&&m(o),d(o)}}).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-icon","data-icon-set"]})}typeof document<"u"&&C();var S=`
|
|
2
2
|
:host {
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
align-items: center;
|
|
@@ -40,14 +40,18 @@ function u({basePath:o,set:n,name:e}){return`${o}/${n}/${e}.svg`}function h(o,n=
|
|
|
40
40
|
block-size: 3em;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/* Sizing only. Paint (fill/stroke/stroke-width) comes from each file's own
|
|
44
|
+
presentation attributes: Lucide/Tabler/Mage are stroked, Phosphor/Bold are
|
|
45
|
+
filled. Any author rule here, even :where(), would beat those attributes. */
|
|
43
46
|
svg {
|
|
47
|
+
display: block;
|
|
44
48
|
inline-size: 100%;
|
|
45
49
|
block-size: 100%;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Opt-in RTL mirroring for directional glyphs (arrows, chevrons, undo\u2026) */
|
|
53
|
+
:host([data-flip-rtl]:dir(rtl)) svg {
|
|
54
|
+
transform: scaleX(-1);
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
/* Error state */
|
|
@@ -59,8 +63,5 @@ svg {
|
|
|
59
63
|
:host([hidden]) {
|
|
60
64
|
display: none;
|
|
61
65
|
}
|
|
62
|
-
`;var
|
|
63
|
-
<style>${b}</style>
|
|
64
|
-
<slot></slot>
|
|
65
|
-
`}async loadIcon(){if(!this.name){this.setError("No icon name specified");return}let n=`${this.set}/${this.name}`;if(s.has(n)){this.displayIcon(s.get(n));return}try{let e=await this.#n(this.set,n);this.displayIcon(e)}catch(e){let t="lucide";if(this.set!==t){let i=`${t}/${this.name}`;if(s.has(i)){this.displayIcon(s.get(i));return}try{let r=await this.#n(t,i);this.displayIcon(r);return}catch{}}this.setError(e.message)}}async#n(n,e){return c.has(e)||c.set(e,this.#i(n).then(t=>(s.set(e,t),c.delete(e),t)).catch(t=>{throw c.delete(e),t})),c.get(e)}async#i(n){let e=`${this.basePath}/${n}/${this.name}.svg`,t=await fetch(e);if(!t.ok)throw new Error(`Icon not found: ${this.name}`);let i=await t.text();if(!i.includes("<svg"))throw new Error(`Invalid SVG: ${this.name}`);return i}displayIcon(n){let i=new DOMParser().parseFromString(n,"image/svg+xml").querySelector("svg");if(!i){this.setError("Invalid SVG content");return}i.removeAttribute("width"),i.removeAttribute("height"),this.label?(i.setAttribute("role","img"),i.setAttribute("aria-label",this.label)):i.setAttribute("aria-hidden","true"),this.removeAttribute("data-error");let r=this.shadowRoot?.querySelector("slot");r&&r.replaceWith(i)}setError(n){this.setAttribute("data-error","true"),console.warn(`icon-wc: ${n}`);let e=this.shadowRoot?.querySelector("slot");e&&(e.textContent="")}connectedCallback(){o.#e.add(this),o.#o(),this.render(),this.loadIcon(),this._onThemeChange=()=>{let n=this.shadowRoot?.querySelector("svg");n&&(n.style.stroke="none",requestAnimationFrame(()=>{n.style.stroke=""}))},window.addEventListener("vb:theme-change",this._onThemeChange),this.setAttribute("data-upgraded","")}disconnectedCallback(){this.removeAttribute("data-upgraded"),o.#e.delete(this),this._onThemeChange&&window.removeEventListener("vb:theme-change",this._onThemeChange)}attributeChangedCallback(n,e,t){if(e!==t&&this.isConnected){if(n==="name"||n==="set")this.render(),this.loadIcon();else if(n==="label"){let i=this.shadowRoot?.querySelector("svg");i&&(t?(i.setAttribute("role","img"),i.setAttribute("aria-label",t)):(i.removeAttribute("role"),i.setAttribute("aria-hidden","true")))}}}};p("icon-wc",d);export{d as IconWc};
|
|
66
|
+
`;var de=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function T(t,n,e={}){let r=e.priority??10,o={impl:n,bundle:e.bundle,contract:e.contract,priority:r},s=E.get(t);if(customElements.get(t)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==n&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${t}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(t,o),customElements.define(t,n)}var O="http://www.w3.org/1999/xhtml",h="http://www.w3.org/2000/svg",P="http://www.w3.org/1998/Math/MathML",_=new Set([O,h,P]),b="user-content-",D=new Set(["script","iframe","frame","frameset","object","embed","applet","portal","fencedframe","form","base","link","meta","noscript","foreignobject","style","xmp","noembed","noframes","plaintext","mglyph","malignmark","annotation-xml"]),M=new Set(["title","desc"]),F=new Set(["animate","set","animatemotion","animatetransform"]),B=new Set(["href","xlink:href","action","formaction","data","codebase","cite","background","longdesc","manifest","to","from","values","by"]),U=new Set(["src","poster","srcset"]),j=new Set(["srcdoc","form","formaction","formmethod","formtarget","formenctype","formnovalidate","action","method","ping"]),q=new Set(["popovertarget","popovertargetaction","commandfor","command","interestfor","autofocus"]),H=new Set(["for","headers","list","aria-labelledby","aria-describedby","aria-controls","aria-owns","aria-flowto","aria-details","aria-errormessage","aria-activedescendant"]),W={"include-file":["trusted","allow-scripts","allow-cross-origin"],"markdown-viewer":["src","sanitize","ping","allow-cross-origin"]},V=new Set(["social-embed","youtube-player","geo-map"]),G=["src","src-dark","data-src","url","endpoint","tile-url","data-versions"],K=new Set(["audio-player","video-player","image-map","brand-mark"]);function X(t){return String(t).replace(/[\u0000- \u007f-\u009f]/g,"").toLowerCase()}function k(t,n=!1){let e=X(t);return n?/(^|,)(javascript|vbscript|livescript):/.test(e)?!0:/(^|,)data:/.test(e)?e.split(/(?=data:)/).filter(o=>o.startsWith("data:")).some(o=>!/^data:(image|audio|video|font)\//.test(o)):!1:/^(javascript|vbscript|livescript|data):/.test(e)}function $(t){let n=String(t).replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\/g,"").replace(/\s+/g,"").toLowerCase();return/expression\(|javascript:|vbscript:|-moz-binding|behavior:|@import|position:fixed/.test(n)}var Y=t=>String(t.localName||t.tagName||"").toLowerCase(),J=t=>t.startsWith(b)?t:b+t;function Q(t,n){if(D.has(n))return!0;let e=t.namespaceURI;return!!(e&&!_.has(e)||n==="title"&&e!==h||M.has(n)&&e===h&&t.children?.length||F.has(n)&&(t.getAttribute("attributeName")||t.getAttribute("attributename")||"").toLowerCase().includes("href"))}function Z(t,n){for(let e of[...t.attributes]){let r=e.name.toLowerCase();if(r.startsWith("on")||j.has(r)||!n.keepIds&&q.has(r)){t.removeAttribute(e.name);continue}if(r==="style"){(!n.keepStyle||$(e.value))&&t.removeAttribute(e.name);continue}if((r==="id"||r==="name")&&!n.keepIds){let o=J(e.value);r==="id"?n.ids.set(e.value,o):n.ids.set(`name:${e.value}`,o),t.setAttribute(e.name,o);continue}if(B.has(r)||r.endsWith(":href")){k(e.value,!1)&&t.removeAttribute(e.name);continue}U.has(r)&&k(e.value,!0)&&t.removeAttribute(e.name)}}function ee(t,n){let e=(t.getAttribute("type")||"").toLowerCase();n==="button"&&e!=="button"&&t.setAttribute("type","button"),n==="input"&&/^(submit|reset|image)$/.test(e)&&t.setAttribute("type","button")}function te(t,n){for(let e of t)for(let r of[...e.attributes]){let o=r.name.toLowerCase(),s=r.value;if((o==="href"||o.endsWith(":href"))&&s.startsWith("#")){let i=ne(s.slice(1));n.has(i)&&e.setAttribute(r.name,`#${n.get(i)}`)}else if(o==="usemap"&&s.startsWith("#")){let i=n.get(`name:${s.slice(1)}`);i?e.setAttribute(r.name,`#${i}`):e.removeAttribute(r.name)}else if(H.has(o)){let i=s.split(/\s+/).filter(Boolean).map(a=>n.get(a)||(a.startsWith(b)?a:null)).filter(Boolean);i.length?e.setAttribute(r.name,i.join(" ")):e.removeAttribute(r.name)}else s.includes("url(#")&&e.setAttribute(r.name,s.replace(/url\(#([^)]+)\)/g,(i,a)=>n.has(a)?`url(#${n.get(a)})`:i))}}function ne(t){try{return decodeURIComponent(t)}catch{return t}}function N(t){let n=t.childNodes;if(n)for(let e of[...n])e.nodeType===8?e.remove():(e.nodeType===1||e.nodeType===11)&&N(e)}function L(t,n){N(t);let e=[...t.querySelectorAll("*")];n.includeRoot&&e.unshift(t);let r=new Map,o=[],s={...n,ids:r};for(let i of e){if(!oe(i,t))continue;let a=Y(i);if(n.svgOnly&&(M.has(a)||a==="style")){if(a==="style"&&$(i.textContent||"")){i.remove();continue}}else if(Q(i,a)){i.remove();continue}if(!n.keepIds&&!n.svgOnly&&V.has(a)){re(i);continue}if(a==="template"){let c=i.content;c&&L(c,{...n,includeRoot:!1})}Z(i,s),n.keepIds||ee(i,a);let w=W[a];if(w)for(let c of w)i.removeAttribute(c);if(a==="include-file"&&!n.allowIncludeFile&&i.removeAttribute("src"),!n.keepIds&&!n.svgOnly&&a.includes("-")&&a!=="include-file"&&!K.has(a))for(let c of G)i.removeAttribute(c);o.push(i)}!n.keepIds&&r.size&&te(o,r)}function re(t){let n=t.parentNode;if(n){for(let e of[...t.childNodes])n.insertBefore(e,t);t.remove()}}function oe(t,n){let e=t;for(;e;){if(e===n)return!0;e=e.parentNode??e.parent??null}return!1}function x(t){return!t||typeof t!="object"||!("attributes"in t)||L(t,{includeRoot:!0,keepIds:!0,keepStyle:!0,svgOnly:!0}),t}var y="lucide",ie=new Set([y,"custom"]),I=new Map,p=new Set,g=new Map,z=new Map;function se(t,n){let e=`${t}/${n}`,r=z.get(e);return r||(r=fetch(`${e}.json`).then(o=>o.ok?o.json():null).then(o=>Array.isArray(o)?new Set(o.map(String)):null).catch(()=>null),z.set(e,r)),r}function ae(t){if(!t.includes("<svg"))return null;let n=new DOMParser().parseFromString(t,"image/svg+xml"),e=n.documentElement;return!e||e.localName!=="svg"||n.querySelector("parsererror")?null:(x(e),e.removeAttribute("width"),e.removeAttribute("height"),document.importNode(e,!0))}function R(t){let n=I.get(t);if(n)return Promise.resolve(n);if(p.has(t))return Promise.reject(new Error(`Icon not found: ${t}`));let e=g.get(t);return e||(e=fetch(t).then(async r=>{if(!r.ok)throw p.add(t),new Error(`Icon not found: ${t}`);let o=ae(await r.text());if(!o)throw p.add(t),new Error(`Invalid SVG: ${t}`);return I.set(t,o),o}).finally(()=>g.delete(t)),g.set(t,e)),e}async function ce(t,n,e){if(n!==y){let r=ie.has(n)?null:await se(t,n);if(!r||r.has(e))try{return await R(l({basePath:t,set:n,name:e}))}catch{}}return R(l({basePath:t,set:y,name:e}))}var v=class t extends HTMLElement{static#r=new Set;static#o=null;static#f(){t.#o||(t.#o=new MutationObserver(n=>{let e=document.documentElement;for(let r of n){let o=r.target;for(let s of t.#r)(o===e||o.contains(s))&&s.#c()}}),t.#o.observe(document.documentElement,{subtree:!0,attributes:!0,attributeFilter:["data-icon-set","data-icon-path"]}))}static get observedAttributes(){return["name","set","label","base-path"]}#i=0;#s="";#e="";#a="";#t=null;constructor(){super();let n=this.attachShadow({mode:"open"});n.innerHTML=`<style>${S}</style><slot></slot>`}get name(){return this.getAttribute("name")||""}get set(){return this.getAttribute("set")||u(this)}get size(){return this.getAttribute("size")||"md"}get label(){return this.getAttribute("label")}get basePath(){return this.getAttribute("base-path")||f()}get iconPath(){return l({basePath:this.basePath,set:this.set,name:this.name})}connectedCallback(){t.#r.add(this),t.#f(),this.#c(),this.#t=()=>{let n=this.#n();n&&(n.style.stroke="none",requestAnimationFrame(()=>{n.style.stroke=""}))},window.addEventListener("vb:theme-change",this.#t),this.setAttribute("data-upgraded","")}disconnectedCallback(){this.removeAttribute("data-upgraded"),t.#r.delete(this),this.#t&&(window.removeEventListener("vb:theme-change",this.#t),this.#t=null)}attributeChangedCallback(n,e,r){e===r||!this.isConnected||(n==="label"?this.#l():this.#c())}#n(){return this.shadowRoot?.querySelector("svg")??null}#c(){let n=this.name,e=`${this.basePath}|${this.set}|${n}`;if(e===this.#s){this.#l();return}if(e===this.#e||e===this.#a)return;let r=++this.#i;if(this.#e=e,this.#a="",!n){this.#e="",this.#u("No icon name specified",e);return}let o=this.basePath,s=this.set;ce(o,s,n).then(i=>{r===this.#i&&(this.#e="",this.#d(i.cloneNode(!0),e))},i=>{r===this.#i&&(this.#e="",this.#u(i.message,e))})}#d(n,e){let r=this.shadowRoot,o=this.#n()||r.querySelector("slot");o?o.replaceWith(n):r.append(n),this.#s=e,this.removeAttribute("data-error"),this.#l()}#l(){let n=this.#n();if(!n)return;let e=this.label;e?(n.setAttribute("role","img"),n.setAttribute("aria-label",e),n.removeAttribute("aria-hidden")):(n.removeAttribute("role"),n.removeAttribute("aria-label"),n.setAttribute("aria-hidden","true"))}#u(n,e){this.#a=e,this.setAttribute("data-error","true"),console.warn(`icon-wc: ${n}`);let r=this.#n();r&&r.replaceWith(document.createElement("slot")),this.#s=""}};T("icon-wc",v);export{v as IconWc};
|
|
66
67
|
//# sourceMappingURL=icon-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var B=Object.defineProperty;var H=(t,e)=>()=>(t&&(e=t(t=0)),e);var X=(t,e)=>{for(var i in e)B(t,i,{get:e[i],enumerable:!0})};var Y={};X(Y,{addDialogDismiss:()=>C,addFlickListener:()=>N,addLongPress:()=>$,addPullToRefresh:()=>z,addSwipeListener:()=>D,haptic:()=>x,initGestures:()=>q,makeSwipeable:()=>P});function D(t,e={}){let i=e.threshold??50,s=e.restraint??100,r=e.timeout??300,n=e.velocity??.5,l=e.minFlickDistance??10,a,c,f;function h(o){o.isPrimary&&(a=o.clientX,c=o.clientY,f=Date.now())}function d(o){if(!o.isPrimary)return;let m=o.clientX-a,v=o.clientY-c,u=Date.now()-f;if(u>r)return;let p=Math.abs(m),y=Math.abs(v),g=Math.max(p,y),b=u>0?g/u:0,w=b>=n&&g>=l,E;if((p>=i||w&&p>y)&&y<=s?E=m<0?"left":"right":(y>=i||w&&y>p)&&p<=s&&(E=v<0?"up":"down"),E){let I=E==="left"||E==="right"?p:y;t.dispatchEvent(new CustomEvent(`swipe-${E}`,{bubbles:!0,detail:{distance:I,duration:u,velocity:b,flick:w}}))}}return t.addEventListener("pointerdown",h,{passive:!0}),t.addEventListener("pointerup",d,{passive:!0}),()=>{t.removeEventListener("pointerdown",h),t.removeEventListener("pointerup",d)}}function N(t,e={}){let i=e.minDistance??10,s=e.velocity??.6,r=e.timeout??250,n=e.restraint??80,l,a,c;function f(d){d.isPrimary&&(l=d.clientX,a=d.clientY,c=Date.now())}function h(d){if(!d.isPrimary)return;let o=d.clientX-l,m=d.clientY-a,v=Date.now()-c;if(v===0||v>r)return;let u=Math.abs(o),p=Math.abs(m),y=Math.max(u,p);if(y<i)return;let g=y/v;if(g<s)return;let b;if(u>p&&p<=n?b=o<0?"left":"right":p>u&&u<=n&&(b=m<0?"up":"down"),b){let w=b==="left"||b==="right"?u:p;t.dispatchEvent(new CustomEvent(`swipe-${b}`,{bubbles:!0,detail:{distance:w,duration:v,velocity:g,flick:!0}}))}}return t.addEventListener("pointerdown",f,{passive:!0}),t.addEventListener("pointerup",h,{passive:!0}),()=>{t.removeEventListener("pointerdown",f),t.removeEventListener("pointerup",h)}}function P(t,e={}){let i=e.threshold??100,s=e.direction??"horizontal",r=e.removeOnDismiss??!0,n=s==="horizontal",l=0,a=0,c=!1;function f(u){!u.isPrimary||t.hasAttribute("data-dismissed")||(u.preventDefault(),c=!0,l=n?u.clientX:u.clientY,a=0,t.setPointerCapture(u.pointerId),t.setAttribute("data-swiping",""))}function h(u){if(!c||!u.isPrimary)return;a=(n?u.clientX:u.clientY)-l;let y=1-Math.min(Math.abs(a)/i,1)*.5;n?t.style.transform=`translateX(${a}px)`:t.style.transform=`translateY(${a}px)`,t.style.opacity=String(y)}function d(u){!c||!u.isPrimary||(c=!1,t.releasePointerCapture(u.pointerId),t.removeAttribute("data-swiping"),Math.abs(a)>=i?m(a>0?"right":"left"):v())}function o(u){!c||!u.isPrimary||(c=!1,t.releasePointerCapture(u.pointerId),t.removeAttribute("data-swiping"),v())}function m(u){let p=u==="right"?"100%":"-100%";t.style.transition="transform 0.2s ease-out, opacity 0.2s ease-out",t.style.transform=n?`translateX(${p})`:`translateY(${p})`,t.style.opacity="0",t.setAttribute("data-dismissed",""),x.dismiss(),t.dispatchEvent(new CustomEvent("swipe-dismiss",{bubbles:!0,detail:{direction:u,distance:Math.abs(a)}})),r&&t.addEventListener("transitionend",()=>t.remove(),{once:!0})}function v(){t.style.transition="transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease",t.style.transform="",t.style.opacity="",t.addEventListener("transitionend",()=>{t.style.transition=""},{once:!0})}return t.addEventListener("pointerdown",f),t.addEventListener("pointermove",h),t.addEventListener("pointerup",d),t.addEventListener("pointercancel",o),()=>{t.removeEventListener("pointerdown",f),t.removeEventListener("pointermove",h),t.removeEventListener("pointerup",d),t.removeEventListener("pointercancel",o)}}function z(t,e,i={}){let s=i.threshold??70,r=i.maxPull??120,n=document.createElement("div");n.setAttribute("data-pull-indicator",""),n.setAttribute("aria-hidden","true");let l=document.createElement("div");l.setAttribute("data-pull-spinner",""),n.appendChild(l),t.prepend(n);let a=0,c=!1,f=!1;function h(p){!p.isPrimary||f||t.scrollTop<=0&&(a=p.clientY,c=!0)}function d(p){if(!c||!p.isPrimary||f)return;let y=p.clientY-a;if(y<=0){n.style.transform="",n.style.opacity="";return}let g=Math.min(y,r),b=g/s;n.style.transform=`translateY(${g}px)`,n.style.opacity=String(Math.min(b,1)),b>=1?n.setAttribute("data-pull-ready",""):n.removeAttribute("data-pull-ready")}function o(p){!c||!p.isPrimary||(c=!1,n.hasAttribute("data-pull-ready")&&!f?v():u())}function m(p){!c||!p.isPrimary||(c=!1,u())}async function v(){f=!0,n.removeAttribute("data-pull-ready"),n.setAttribute("data-pull-loading",""),n.style.transform=`translateY(${s}px)`,n.style.opacity="1";try{await e()}finally{f=!1,n.removeAttribute("data-pull-loading"),u()}}function u(){n.style.transition="transform 0.3s ease, opacity 0.3s ease",n.style.transform="",n.style.opacity="",n.removeAttribute("data-pull-ready"),n.addEventListener("transitionend",()=>{n.style.transition=""},{once:!0})}return t.addEventListener("pointerdown",h,{passive:!0}),t.addEventListener("pointermove",d,{passive:!0}),t.addEventListener("pointerup",o,{passive:!0}),t.addEventListener("pointercancel",m,{passive:!0}),()=>{t.removeEventListener("pointerdown",h),t.removeEventListener("pointermove",d),t.removeEventListener("pointerup",o),t.removeEventListener("pointercancel",m),n.remove()}}function $(t,e,i={}){let s=i.duration??500,r=i.hapticFeedback??!0,n=i.blockContextMenu??!0,l=null;function a(h){h.isPrimary&&(l=setTimeout(()=>{r&&x.tap(),e(h),l=null},s))}function c(){l&&(clearTimeout(l),l=null)}function f(h){n&&h.preventDefault()}return t.addEventListener("pointerdown",a,{passive:!0}),t.addEventListener("pointermove",c,{passive:!0}),t.addEventListener("pointerup",c,{passive:!0}),t.addEventListener("pointercancel",c,{passive:!0}),t.addEventListener("contextmenu",f),()=>{c(),t.removeEventListener("pointerdown",a),t.removeEventListener("pointermove",c),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),t.removeEventListener("contextmenu",f)}}function C(t,e={}){let i=e.threshold??80,s=0,r=0,n=!1;function l(o){if(!o.isPrimary||!t.open)return;let m=o.target;m.closest("a, button, input, select, textarea, [contenteditable]")&&!m.closest("header")||(n=!0,s=o.clientY,r=0,t.setPointerCapture(o.pointerId),t.style.transition="none")}function a(o){if(!n||!o.isPrimary)return;if(r=o.clientY-s,r<=0){t.style.transform="",t.style.opacity="";return}let v=1-Math.min(r/i,1)*.4;t.style.transform=`translateY(${r}px)`,t.style.opacity=String(v)}function c(o){!n||!o.isPrimary||(n=!1,t.releasePointerCapture(o.pointerId),r>=i?h():d())}function f(o){!n||!o.isPrimary||(n=!1,t.releasePointerCapture(o.pointerId),d())}function h(){t.style.transition="transform 0.2s ease-out, opacity 0.2s ease-out",t.style.transform="translateY(100%)",t.style.opacity="0",x.dismiss(),t.addEventListener("transitionend",()=>{t.style.transition="",t.style.transform="",t.style.opacity="",t.close("dismiss")},{once:!0})}function d(){t.style.transition="transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease",t.style.transform="",t.style.opacity="",t.addEventListener("transitionend",()=>{t.style.transition=""},{once:!0})}return t.addEventListener("pointerdown",l),t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",f),()=>{t.removeEventListener("pointerdown",l),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",f)}}function q(t=document){let e=[];for(let i of t.querySelectorAll('[data-gesture="swipe"]'))e.push(D(i));for(let i of t.querySelectorAll('[data-gesture="flick"]'))e.push(N(i));for(let i of t.querySelectorAll('[data-gesture="dismiss"]'))e.push(P(i));for(let i of t.querySelectorAll('[data-gesture="long-press"]'))e.push($(i,()=>{i.dispatchEvent(new CustomEvent("long-press",{bubbles:!0}))}));for(let i of t.querySelectorAll('dialog[data-gesture="dismiss-down"]'))e.push(C(i));return()=>e.forEach(i=>i())}var x,M,F=H(()=>{x={tap:()=>navigator.vibrate?.(8),confirm:()=>navigator.vibrate?.([8,40,8]),error:()=>navigator.vibrate?.([30,60,30]),dismiss:()=>navigator.vibrate?.(15)};M=typeof document<"u"?document.documentElement:null;(!M||!M.hasAttribute("data-vb-gestures-init"))&&(M?.setAttribute("data-vb-gestures-init",""),q())});var R=window.matchMedia("(prefers-reduced-motion: reduce)");var T=new Map;function k(t,e,i={}){let s=i.priority??10,r={impl:e,bundle:i.bundle,contract:i.contract,priority:s},n=T.get(t);if(customElements.get(t)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==e&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${t}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${t}> already registered by "${n.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}T.set(t,r),customElements.define(t,e)}var L=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#t)e();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,i,s,r){e.addEventListener(i,s,r),this.#t.push(()=>e.removeEventListener(i,s,r))}_reinit(){for(let e of this.#t)e();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,i){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{i?s.add(e):s.delete(e)}catch{let r=`--${e}`;i?s.add(r):s.delete(r)}}_adoptInternals(e){this.#e||(this.#e=e)}};function A(t){return document.startViewTransition?document.startViewTransition(t):t()}var U=0,S=class extends L{#t=[];#e=0;#n=null;#v=null;#i=null;#u=null;#d=null;#h=null;#a=null;#s=null;#c=null;#o="";#l=!1;setup(){return this.#o=`gallery-lb-${++U}`,this.#l=!!document.startViewTransition,this.#f(),this.#t.length===0?!1:(this.listen(this,"click",this.#y),!0)}teardown(){this.#c&&(this.#c(),this.#c=null),this.#n&&(this.#n.remove(),this.#n=null),this.#t=[]}get images(){return this.#t.map(e=>({href:e.href,thumbSrc:e.thumbSrc,alt:e.alt,caption:e.caption}))}set images(e){let i=Array.isArray(e)?e:[];for(let s of[...this.children])(s.tagName==="FIGURE"||s.tagName==="A")&&s.remove();for(let s of i){if(!s?.href||!s?.thumbSrc)continue;let r=s.caption?document.createElement("figure"):document.createElement("a"),n=r.tagName==="FIGURE"?document.createElement("a"):r;n.href=s.href;let l=document.createElement("img");if(l.src=s.thumbSrc,l.alt=s.alt||"",n.appendChild(l),r.tagName==="FIGURE"){r.appendChild(n);let a=document.createElement("figcaption");a.innerHTML=s.caption??"",r.appendChild(a)}this.appendChild(r)}this.#f(),this.dispatchEvent(new CustomEvent("image-gallery:images-changed",{detail:{images:this.images,source:"property"},bubbles:!0}))}open(e){if(e<0||e>=this.#t.length)return;this.#n||this.#b(),this.#p(e);let i=this.#t[e],s=this.getAttribute("transition")||"morph";if(this.#l&&s==="morph"&&this.#i&&this.#n){let r=`gallery-morph-${this.#o}`;i.thumbEl.style.viewTransitionName=r;let n=this.#i,l=this.#n;A(()=>{i.thumbEl.style.viewTransitionName="";let a=n.querySelector("img");a&&(a.style.viewTransitionName=r),l.showModal()}).finished?.then(()=>{let a=n.querySelector("img");a&&(a.style.viewTransitionName="")})}else this.#n?.showModal();this.#m(e)}close(){if(!this.#n?.open)return;let e=this.#t[this.#e],i=this.getAttribute("transition")||"morph";if(this.#l&&i==="morph"&&this.#i&&this.#n){let s=`gallery-morph-${this.#o}`,r=this.#i.querySelector("img");r&&(r.style.viewTransitionName=s);let n=this.#n;A(()=>{r&&(r.style.viewTransitionName=""),e.thumbEl.style.viewTransitionName=s,n.close()}).finished?.then(()=>{e.thumbEl.style.viewTransitionName=""})}else this.#n?.close()}next(){let e=this.hasAttribute("loop");this.#e<this.#t.length-1?this.#r(this.#e+1):e&&this.#r(0)}prev(){let e=this.hasAttribute("loop");this.#e>0?this.#r(this.#e-1):e&&this.#r(this.#t.length-1)}#f(){this.#t=[];for(let e of this.children){let i=e.tagName==="FIGURE",s=i?e.querySelector("a[href]"):e.matches("a[href]")?e:null;if(!s)continue;let r=s.querySelector("img");if(!r)continue;let n=i?e.querySelector("figcaption")?.innerHTML??null:null;this.#t.push({href:s.href,thumbSrc:r.src,alt:r.alt||"",caption:n,thumbEl:r})}}#y=e=>{let s=e.target?.closest("a[href]");if(!s||!this.contains(s))return;let r=s.querySelector("img"),n=this.#t.findIndex(l=>l.thumbEl===r);n!==-1&&(e.preventDefault(),this.open(n))};#b(){let e=document.createElement("dialog");e.id=this.#o,e.className="gallery-lightbox",e.dataset.size="full";let i=this.getAttribute("controls")||"edge";e.dataset.controls=i;let s=document.createElement("header"),r=document.createElement("span");r.className="gallery-counter",r.setAttribute("aria-live","polite"),r.setAttribute("aria-atomic","true"),this.#u=r;let n=document.createElement("button");n.type="button",n.className="gallery-close",n.setAttribute("commandfor",this.#o),n.setAttribute("command","close"),n.setAttribute("aria-label","Close gallery"),n.innerHTML='<icon-wc name="x" size="sm"></icon-wc>',this.listen(n,"click",()=>this.close()),s.append(r);let l=this.getAttribute("captions")||"auto";s.append(n);let a=document.createElement("section");a.className="gallery-stage",this.#v=a;let c=document.createElement("button");c.type="button",c.className="gallery-prev",c.setAttribute("aria-label","Previous image"),c.innerHTML='<icon-wc name="chevron-left" size="sm"></icon-wc>',this.#d=c;let f=document.createElement("figure");f.className="gallery-frame",this.#i=f;let h=document.createElement("button");if(h.type="button",h.className="gallery-next",h.setAttribute("aria-label","Next image"),h.innerHTML='<icon-wc name="chevron-right" size="sm"></icon-wc>',this.#h=h,a.append(c,f,h),l==="auto"){let d=document.createElement("footer");d.className="gallery-caption",d.hidden=!0;let o=document.createElement("button");o.type="button",o.className="gallery-info-btn",o.setAttribute("aria-label","Show image details"),o.setAttribute("aria-expanded","false"),o.innerHTML='<icon-wc name="info" size="sm"></icon-wc>',this.#a=o;let m=document.createElement("div");m.className="gallery-caption-text",m.hidden=!0,d.append(o,m),this.#s=m,e.append(s,a,d),this.listen(o,"click",()=>{let v=!m.hidden;m.hidden=v,o.setAttribute("aria-expanded",String(!v)),o.setAttribute("aria-label",v?"Show image details":"Hide image details")})}else e.append(s,a);this.append(e),this.#n=e,this.listen(c,"click",()=>this.prev()),this.listen(h,"click",()=>this.next()),this.listen(e,"keydown",this.#E),this.listen(e,"click",d=>{d.target===e&&this.close()}),this.listen(e,"close",()=>{let d=this.#t[this.#e];d&&(d.thumbEl.style.viewTransitionName="");let o=this.#i?.querySelector("img");o&&(o.style.viewTransitionName="")}),Promise.resolve().then(()=>(F(),Y)).then(({addSwipeListener:d})=>{this.#c=d(a,{threshold:40}),this.listen(a,"swipe-left",()=>this.next()),this.listen(a,"swipe-right",()=>this.prev())})}#p(e){let i=this.#t[e];this.#e=e;let s=document.createElement("img");if(s.src=i.href,s.alt=i.alt,!this.#i)return;let r=this.#i;r.innerHTML="",r.append(s);let n=this.getAttribute("captions")||"auto";if(n==="overlay"&&i.caption){let l=document.createElement("figcaption");l.innerHTML=i.caption,r.append(l)}else if(n==="auto"){let l=this.#s?.parentElement;this.#s&&this.#a&&l&&(i.caption?(this.#s.innerHTML=i.caption,l.hidden=!1,this.#s.hidden=!0,this.#a.setAttribute("aria-expanded","false"),this.#a.setAttribute("aria-label","Show image details")):(this.#s.innerHTML="",l.hidden=!0))}this.#g()}#r(e){let i=this.getAttribute("transition")||"morph";this.#l&&i!=="none"?A(()=>{this.#p(e)}):this.#p(e),this.#m(e)}#g(){let e=this.hasAttribute("loop"),i=this.#e===0,s=this.#e===this.#t.length-1;this.#d&&(this.#d.disabled=!e&&i),this.#h&&(this.#h.disabled=!e&&s),this.#u&&(this.#u.textContent=`${this.#e+1} of ${this.#t.length}`)}#E=e=>{switch(e.key){case"ArrowLeft":e.preventDefault(),this.prev();break;case"ArrowRight":e.preventDefault(),this.next();break;case"Home":e.preventDefault(),this.#r(0);break;case"End":e.preventDefault(),this.#r(this.#t.length-1);break}};#m(e){let i=s=>{if(s>=0&&s<this.#t.length){let r=new Image;r.src=this.#t[s].href}};i(e-1),i(e+1)}};k("image-gallery",S);export{S as ImageGallery};
|
|
1
|
+
var X=Object.defineProperty;var U=(e,t)=>()=>(e&&(t=e(e=0)),t);var z=(e,t)=>{for(var i in t)X(e,i,{get:t[i],enumerable:!0})};var q={};z(q,{addDialogDismiss:()=>$,addFlickListener:()=>M,addLongPress:()=>P,addPullToRefresh:()=>H,addSwipeListener:()=>N,haptic:()=>L,initGestures:()=>I,makeSwipeable:()=>T});function N(e,t={}){let i=t.threshold??50,s=t.restraint??100,r=t.timeout??300,n=t.velocity??.5,l=t.minFlickDistance??10,a,o,p;function u(c){c.isPrimary&&(a=c.clientX,o=c.clientY,p=Date.now())}function h(c){if(!c.isPrimary)return;let m=c.clientX-a,v=c.clientY-o,d=Date.now()-p;if(d>r)return;let f=Math.abs(m),y=Math.abs(v),g=Math.max(f,y),b=d>0?g/d:0,w=b>=n&&g>=l,E;if((f>=i||w&&f>y)&&y<=s?E=m<0?"left":"right":(y>=i||w&&y>f)&&f<=s&&(E=v<0?"up":"down"),E){let V=E==="left"||E==="right"?f:y;e.dispatchEvent(new CustomEvent(`swipe-${E}`,{bubbles:!0,detail:{distance:V,duration:d,velocity:b,flick:w}}))}}return e.addEventListener("pointerdown",u,{passive:!0}),e.addEventListener("pointerup",h,{passive:!0}),()=>{e.removeEventListener("pointerdown",u),e.removeEventListener("pointerup",h)}}function M(e,t={}){let i=t.minDistance??10,s=t.velocity??.6,r=t.timeout??250,n=t.restraint??80,l,a,o;function p(h){h.isPrimary&&(l=h.clientX,a=h.clientY,o=Date.now())}function u(h){if(!h.isPrimary)return;let c=h.clientX-l,m=h.clientY-a,v=Date.now()-o;if(v===0||v>r)return;let d=Math.abs(c),f=Math.abs(m),y=Math.max(d,f);if(y<i)return;let g=y/v;if(g<s)return;let b;if(d>f&&f<=n?b=c<0?"left":"right":f>d&&d<=n&&(b=m<0?"up":"down"),b){let w=b==="left"||b==="right"?d:f;e.dispatchEvent(new CustomEvent(`swipe-${b}`,{bubbles:!0,detail:{distance:w,duration:v,velocity:g,flick:!0}}))}}return e.addEventListener("pointerdown",p,{passive:!0}),e.addEventListener("pointerup",u,{passive:!0}),()=>{e.removeEventListener("pointerdown",p),e.removeEventListener("pointerup",u)}}function T(e,t={}){let i=t.threshold??100,s=t.direction??"horizontal",r=t.removeOnDismiss??!0,n=s==="horizontal",l=0,a=0,o=!1;function p(d){!d.isPrimary||e.hasAttribute("data-dismissed")||(d.preventDefault(),o=!0,l=n?d.clientX:d.clientY,a=0,e.setPointerCapture(d.pointerId),e.setAttribute("data-swiping",""))}function u(d){if(!o||!d.isPrimary)return;a=(n?d.clientX:d.clientY)-l;let y=1-Math.min(Math.abs(a)/i,1)*.5;n?e.style.transform=`translateX(${a}px)`:e.style.transform=`translateY(${a}px)`,e.style.opacity=String(y)}function h(d){!o||!d.isPrimary||(o=!1,e.releasePointerCapture(d.pointerId),e.removeAttribute("data-swiping"),Math.abs(a)>=i?m(a>0?"right":"left"):v())}function c(d){!o||!d.isPrimary||(o=!1,e.releasePointerCapture(d.pointerId),e.removeAttribute("data-swiping"),v())}function m(d){let f=d==="right"?"100%":"-100%";e.style.transition="transform 0.2s ease-out, opacity 0.2s ease-out",e.style.transform=n?`translateX(${f})`:`translateY(${f})`,e.style.opacity="0",e.setAttribute("data-dismissed",""),L.dismiss(),e.dispatchEvent(new CustomEvent("swipe-dismiss",{bubbles:!0,detail:{direction:d,distance:Math.abs(a)}})),r&&e.addEventListener("transitionend",()=>e.remove(),{once:!0})}function v(){e.style.transition="transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease",e.style.transform="",e.style.opacity="",e.addEventListener("transitionend",()=>{e.style.transition=""},{once:!0})}return e.addEventListener("pointerdown",p),e.addEventListener("pointermove",u),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",c),()=>{e.removeEventListener("pointerdown",p),e.removeEventListener("pointermove",u),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",c)}}function H(e,t,i={}){let s=i.threshold??70,r=i.maxPull??120,n=document.createElement("div");n.setAttribute("data-pull-indicator",""),n.setAttribute("aria-hidden","true");let l=document.createElement("div");l.setAttribute("data-pull-spinner",""),n.appendChild(l),e.prepend(n);let a=0,o=!1,p=!1;function u(f){!f.isPrimary||p||e.scrollTop<=0&&(a=f.clientY,o=!0)}function h(f){if(!o||!f.isPrimary||p)return;let y=f.clientY-a;if(y<=0){n.style.transform="",n.style.opacity="";return}let g=Math.min(y,r),b=g/s;n.style.transform=`translateY(${g}px)`,n.style.opacity=String(Math.min(b,1)),b>=1?n.setAttribute("data-pull-ready",""):n.removeAttribute("data-pull-ready")}function c(f){!o||!f.isPrimary||(o=!1,n.hasAttribute("data-pull-ready")&&!p?v():d())}function m(f){!o||!f.isPrimary||(o=!1,d())}async function v(){p=!0,n.removeAttribute("data-pull-ready"),n.setAttribute("data-pull-loading",""),n.style.transform=`translateY(${s}px)`,n.style.opacity="1";try{await t()}finally{p=!1,n.removeAttribute("data-pull-loading"),d()}}function d(){n.style.transition="transform 0.3s ease, opacity 0.3s ease",n.style.transform="",n.style.opacity="",n.removeAttribute("data-pull-ready"),n.addEventListener("transitionend",()=>{n.style.transition=""},{once:!0})}return e.addEventListener("pointerdown",u,{passive:!0}),e.addEventListener("pointermove",h,{passive:!0}),e.addEventListener("pointerup",c,{passive:!0}),e.addEventListener("pointercancel",m,{passive:!0}),()=>{e.removeEventListener("pointerdown",u),e.removeEventListener("pointermove",h),e.removeEventListener("pointerup",c),e.removeEventListener("pointercancel",m),n.remove()}}function P(e,t,i={}){let s=i.duration??500,r=i.hapticFeedback??!0,n=i.blockContextMenu??!0,l=null;function a(u){u.isPrimary&&(l=setTimeout(()=>{r&&L.tap(),t(u),l=null},s))}function o(){l&&(clearTimeout(l),l=null)}function p(u){n&&u.preventDefault()}return e.addEventListener("pointerdown",a,{passive:!0}),e.addEventListener("pointermove",o,{passive:!0}),e.addEventListener("pointerup",o,{passive:!0}),e.addEventListener("pointercancel",o,{passive:!0}),e.addEventListener("contextmenu",p),()=>{o(),e.removeEventListener("pointerdown",a),e.removeEventListener("pointermove",o),e.removeEventListener("pointerup",o),e.removeEventListener("pointercancel",o),e.removeEventListener("contextmenu",p)}}function $(e,t={}){let i=t.threshold??80,s=0,r=0,n=!1;function l(c){if(!c.isPrimary||!e.open)return;let m=c.target;m.closest("a, button, input, select, textarea, [contenteditable]")&&!m.closest("header")||(n=!0,s=c.clientY,r=0,e.setPointerCapture(c.pointerId),e.style.transition="none")}function a(c){if(!n||!c.isPrimary)return;if(r=c.clientY-s,r<=0){e.style.transform="",e.style.opacity="";return}let v=1-Math.min(r/i,1)*.4;e.style.transform=`translateY(${r}px)`,e.style.opacity=String(v)}function o(c){!n||!c.isPrimary||(n=!1,e.releasePointerCapture(c.pointerId),r>=i?u():h())}function p(c){!n||!c.isPrimary||(n=!1,e.releasePointerCapture(c.pointerId),h())}function u(){e.style.transition="transform 0.2s ease-out, opacity 0.2s ease-out",e.style.transform="translateY(100%)",e.style.opacity="0",L.dismiss(),e.addEventListener("transitionend",()=>{e.style.transition="",e.style.transform="",e.style.opacity="",e.close("dismiss")},{once:!0})}function h(){e.style.transition="transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease",e.style.transform="",e.style.opacity="",e.addEventListener("transitionend",()=>{e.style.transition=""},{once:!0})}return e.addEventListener("pointerdown",l),e.addEventListener("pointermove",a),e.addEventListener("pointerup",o),e.addEventListener("pointercancel",p),()=>{e.removeEventListener("pointerdown",l),e.removeEventListener("pointermove",a),e.removeEventListener("pointerup",o),e.removeEventListener("pointercancel",p)}}function I(e=document){let t=[];for(let i of e.querySelectorAll('[data-gesture="swipe"]'))t.push(N(i));for(let i of e.querySelectorAll('[data-gesture="flick"]'))t.push(M(i));for(let i of e.querySelectorAll('[data-gesture="dismiss"]'))t.push(T(i));for(let i of e.querySelectorAll('[data-gesture="long-press"]'))t.push(P(i,()=>{i.dispatchEvent(new CustomEvent("long-press",{bubbles:!0}))}));for(let i of e.querySelectorAll('dialog[data-gesture="dismiss-down"]'))t.push($(i));return()=>t.forEach(i=>i())}var L,S,F=U(()=>{L={tap:()=>navigator.vibrate?.(8),confirm:()=>navigator.vibrate?.([8,40,8]),error:()=>navigator.vibrate?.([30,60,30]),dismiss:()=>navigator.vibrate?.(15)};S=typeof document<"u"?document.documentElement:null;(!S||!S.hasAttribute("data-vb-gestures-init"))&&(S?.setAttribute("data-vb-gestures-init",""),I())});var G=window.matchMedia("(prefers-reduced-motion: reduce)");var C=new Map;function k(e,t,i={}){let s=i.priority??10,r={impl:t,bundle:i.bundle,contract:i.contract,priority:s},n=C.get(e);if(customElements.get(e)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${e}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${e}> already registered by "${n.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}C.set(e,r),customElements.define(e,t)}var A=class extends HTMLElement{#t=[];#i;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,i,s,r){t.addEventListener(i,s,r),this.#t.push(()=>t.removeEventListener(i,s,r))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,i){this.#i||(this.#i=this.attachInternals());let s=this.#i.states;try{i?s.add(t):s.delete(t)}catch{let r=`--${t}`;i?s.add(r):s.delete(r)}}_adoptInternals(t){this.#i||(this.#i=t)}#e(){return this.constructor.formAssociated&&this.#i?this.#i:null}get validity(){return this.#e()?.validity}get validationMessage(){return this.#e()?.validationMessage??""}get willValidate(){return this.#e()?.willValidate??!1}get form(){return this.#e()?.form??null}checkValidity(){return this.#e()?.checkValidity()??!0}reportValidity(){return this.#e()?.reportValidity()??!0}};function x(e){return document.startViewTransition?document.startViewTransition(e):e()}var R=0,Y=!1,O={Dialog:"Image viewer",Close:"Close gallery",Prev:"Previous image",Next:"Next image",ShowDetails:"Show image details",HideDetails:"Hide image details",Counter:"Image {n} of {total}"};function _(e){return e==null||e===""?[]:e instanceof HTMLTemplateElement?[e.content.cloneNode(!0)]:e instanceof Node?[e.cloneNode(!0)]:[document.createTextNode(String(e))]}function B(e){return e?[...e.childNodes].map(t=>t.cloneNode(!0)):[]}var D=class extends A{static get observedAttributes(){return["captions","controls"]}#t=[];#i=0;#e=null;#n=null;#l=null;#u=null;#d=null;#c=null;#r=null;#h=null;#o="";#p=!1;setup(){return this.#o||(this.#o=`gallery-lb-${++R}`),this.#p=!!document.startViewTransition,this.#v(),this.listen(this,"click",this.#w),!0}teardown(){this.#E();for(let t of this.#t)t.thumbEl.style.viewTransitionName="";this.#t=[]}attributeChangedCallback(t,i,s){i!==s&&this.#e&&this.#E()}get images(){return this.#t.map(t=>{let i=null;if(t.captionEl)if(t.captionEl.children.length){let s=document.createDocumentFragment();s.append(...B(t.captionEl)),i=s}else i=t.captionEl.textContent;return{href:t.href,thumbSrc:t.thumbSrc,alt:t.alt,caption:i}})}set images(t){let i=Array.isArray(t)?t:[];for(let r of[...this.children])(r.tagName==="FIGURE"||r.tagName==="A")&&r.remove();let s=i.filter(r=>r?.href&&r?.thumbSrc);s.forEach((r,n)=>{let l=_(r.caption),a=l.length?document.createElement("figure"):document.createElement("a"),o=a.tagName==="FIGURE"?document.createElement("a"):a;o.href=r.href;let p=document.createElement("img");if(p.src=r.thumbSrc,p.alt=r.alt||"",p.loading="lazy",!r.alt){Y||(Y=!0,console.warn("[image-gallery] .images entries should include alt text; falling back to a generic link name."));let u=typeof r.caption=="string"?r.caption.trim():"";o.setAttribute("aria-label",u||this.#g(n+1,s.length))}if(o.appendChild(p),a.tagName==="FIGURE"){a.appendChild(o);let u=document.createElement("figcaption");u.append(...l),a.appendChild(u)}this.appendChild(a)}),this._reinit(),this.dispatchEvent(new CustomEvent("image-gallery:images-changed",{detail:{images:this.images,source:"property"},bubbles:!0}))}open(t){if(this.#t.length||this.#v(),!(t>=0&&t<this.#t.length))return;this.#e||this.#A(),this.#y(t);let i=this.#t[t],s=this.getAttribute("transition")||"morph";if(this.#e?.open){this.#b(t);return}if(this.#p&&s==="morph"&&this.#n&&this.#e){let r=`gallery-morph-${this.#o}`;i.thumbEl.style.viewTransitionName=r;let n=this.#n,l=this.#e;x(()=>{i.thumbEl.style.viewTransitionName="";let a=n.querySelector("img");a&&(a.style.viewTransitionName=r),l.isConnected&&!l.open&&l.showModal()}).finished?.then(()=>{let a=n.querySelector("img");a&&(a.style.viewTransitionName="")})}else this.#e?.showModal();this.#b(t)}close(){if(!this.#e?.open)return;let t=this.#t[this.#i],i=this.getAttribute("transition")||"morph";if(t&&this.#p&&i==="morph"&&this.#n&&this.#e){let s=`gallery-morph-${this.#o}`,r=this.#n.querySelector("img");r&&(r.style.viewTransitionName=s);let n=this.#e;x(()=>{r&&(r.style.viewTransitionName=""),t.thumbEl.style.viewTransitionName=s,n.close()}).finished?.then(()=>{t.thumbEl.style.viewTransitionName=""})}else this.#e?.close()}next(){let t=this.hasAttribute("loop");this.#i<this.#t.length-1?this.#a(this.#i+1):t&&this.#a(0)}prev(){let t=this.hasAttribute("loop");this.#i>0?this.#a(this.#i-1):t&&this.#a(this.#t.length-1)}#s(t){return this.dataset[`label${t}`]||O[t]}#g(t,i){return this.#s("Counter").replace("{n}",String(t)).replace("{total}",String(i))}#m(){return getComputedStyle(this).direction==="rtl"}#v(){this.#t=[];for(let t of this.children){let i=t.tagName==="FIGURE",s=i?t.querySelector("a[href]"):t.matches("a[href]")?t:null;if(!s)continue;let r=s.querySelector("img");r&&this.#t.push({href:s.href,thumbSrc:r.src,alt:r.alt||"",captionEl:i?t.querySelector(":scope > figcaption"):null,thumbEl:r})}}#w=t=>{let s=t.target?.closest("a[href]");if(!s||!this.contains(s)||this.#e?.contains(s))return;let r=s.querySelector("img"),n=this.#t.findIndex(l=>l.thumbEl===r);n===-1&&(this.#v(),n=this.#t.findIndex(l=>l.thumbEl===r)),n!==-1&&(t.preventDefault(),this.open(n))};#f(t,i,s){let r=document.createElement("button");r.type="button",r.className=t,r.setAttribute("aria-label",i);let n=document.createElement("icon-wc");return n.setAttribute("name",s),n.setAttribute("size","sm"),r.append(n),r}#A(){let t=document.createElement("dialog");t.id=this.#o,t.className="gallery-lightbox",t.dataset.size="full",t.setAttribute("aria-label",this.#s("Dialog")),t.dataset.controls=this.getAttribute("controls")||"edge";let i=document.createElement("header"),s=document.createElement("span");s.className="gallery-counter",s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),this.#l=s;let r=this.#f("gallery-close",this.#s("Close"),"x");this.listen(r,"click",()=>this.close()),i.append(s,r);let n=document.createElement("section");n.className="gallery-stage";let l=this.#f("gallery-prev",this.#s("Prev"),"chevron-left");this.#u=l;let a=document.createElement("figure");a.className="gallery-frame",this.#n=a;let o=this.#f("gallery-next",this.#s("Next"),"chevron-right");if(this.#d=o,n.append(l,a,o),(this.getAttribute("captions")||"auto")==="auto"){let u=document.createElement("footer");u.className="gallery-caption",u.hidden=!0;let h=this.#f("gallery-info-btn",this.#s("ShowDetails"),"info");h.setAttribute("aria-expanded","false"),this.#c=h;let c=document.createElement("div");c.className="gallery-caption-text",c.id=`${this.#o}-caption`,c.hidden=!0,h.setAttribute("aria-controls",c.id),this.#r=c,u.append(h,c),t.append(i,n,u),this.listen(h,"click",()=>{let m=!c.hidden;c.hidden=m,h.setAttribute("aria-expanded",String(!m)),h.setAttribute("aria-label",this.#s(m?"ShowDetails":"HideDetails"))})}else t.append(i,n);this.append(t),this.#e=t,this.listen(l,"click",()=>this.prev()),this.listen(o,"click",()=>this.next()),this.listen(t,"keydown",this.#L),this.listen(t,"click",u=>{u.target===t&&this.close()}),this.listen(t,"close",()=>{let u=this.#t[this.#i];u&&(u.thumbEl.style.viewTransitionName="");let h=this.#n?.querySelector("img");h&&(h.style.viewTransitionName="")}),Promise.resolve().then(()=>(F(),q)).then(({addSwipeListener:u})=>{!this.isConnected||this.#e!==t||(this.#h=u(n,{threshold:40}),this.listen(n,"swipe-left",()=>this.#m()?this.prev():this.next()),this.listen(n,"swipe-right",()=>this.#m()?this.next():this.prev()))})}#E(){this.#h&&(this.#h(),this.#h=null),this.#e&&(this.#e.open&&this.#e.close(),this.#e.remove()),this.#e=null,this.#n=null,this.#l=null,this.#u=null,this.#d=null,this.#c=null,this.#r=null}#y(t){let i=this.#t[t];if(!i||!this.#n)return;this.#i=t;let s=document.createElement("img");s.src=i.href,s.alt=i.alt;let r=this.#n;r.replaceChildren(s);let n=this.getAttribute("captions")||"auto",l=B(i.captionEl),a=!!i.captionEl?.textContent?.trim()||l.some(o=>o.nodeType===1);if(n==="overlay"&&a){let o=document.createElement("figcaption");o.append(...l),r.append(o)}else if(n==="auto"){let o=this.#r?.parentElement;this.#r&&this.#c&&o&&(a?(this.#r.replaceChildren(...l),o.hidden=!1,this.#r.hidden=!0,this.#c.setAttribute("aria-expanded","false"),this.#c.setAttribute("aria-label",this.#s("ShowDetails"))):(this.#r.replaceChildren(),o.hidden=!0))}this.#x()}#a(t){let i=this.getAttribute("transition")||"morph";this.#p&&i!=="none"?x(()=>{this.#y(t)}):this.#y(t),this.#b(t)}#x(){let t=this.hasAttribute("loop"),i=this.#i===0,s=this.#i===this.#t.length-1;this.#u&&(this.#u.disabled=!t&&i),this.#d&&(this.#d.disabled=!t&&s),this.#l&&(this.#l.textContent=this.#g(this.#i+1,this.#t.length))}#L=t=>{if(t.target instanceof Element&&t.target.closest(".gallery-caption-text, figcaption"))return;let i=this.#m();switch(t.key){case"ArrowLeft":t.preventDefault(),i?this.next():this.prev();break;case"ArrowRight":t.preventDefault(),i?this.prev():this.next();break;case"Home":t.preventDefault(),this.#a(0);break;case"End":t.preventDefault(),this.#a(this.#t.length-1);break}};#b(t){let i=s=>{if(s>=0&&s<this.#t.length){let r=new Image;r.src=this.#t[s].href}};i(t-1),i(t+1)}};k("image-gallery",D);export{D as ImageGallery};
|
|
2
2
|
//# sourceMappingURL=image-gallery.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var S=window.matchMedia("(prefers-reduced-motion: reduce)");var y=new Map;function b(s,e,i={}){let t=i.priority??10,r={impl:e,bundle:i.bundle,contract:i.contract,priority:t},n=y.get(s);if(customElements.get(s)){if(!n||n.priority>=t){n&&n.priority===t&&n.impl!==e&&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>=t){n.priority===t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}y.set(s,r),customElements.define(s,e)}var f=class extends HTMLElement{#t=[];#i;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.#t)e();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,i,t,r){e.addEventListener(i,t,r),this.#t.push(()=>e.removeEventListener(i,t,r))}_reinit(){for(let e of this.#t)e();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(e,i){this.#i||(this.#i=this.attachInternals());let t=this.#i.states;try{i?t.add(e):t.delete(e)}catch{let r=`--${e}`;i?t.add(r):t.delete(r)}}_adoptInternals(e){this.#i||(this.#i=e)}};var p="http://www.w3.org/2000/svg";function w(s){return s.trim().split(/[\s,]+/).map(Number)}function v(s,e){let i=w(e);switch(s){case"rect":{let[t,r,n,h]=i;return{type:"rect",x:t,y:r,width:n-t,height:h-r}}case"circle":{let[t,r,n]=i;return{type:"circle",cx:t,cy:r,r:n}}case"poly":{let t=[];for(let r=0;r<i.length;r+=2)t.push([i[r],i[r+1]]);return{type:"poly",points:t}}default:return null}}function E(s){if(!s)return null;switch(s.type){case"rect":{let e=document.createElementNS(p,"rect");return e.setAttribute("x",String(s.x)),e.setAttribute("y",String(s.y)),e.setAttribute("width",String(s.width)),e.setAttribute("height",String(s.height)),e}case"circle":{let e=document.createElementNS(p,"circle");return e.setAttribute("cx",String(s.cx)),e.setAttribute("cy",String(s.cy)),e.setAttribute("r",String(s.r)),e}case"poly":{let e=document.createElementNS(p,"polygon");return e.setAttribute("points",s.points.map(i=>i.join(",")).join(" ")),e}default:return null}}function x(s){if(!s)return{x:0,y:0,width:0,height:0};switch(s.type){case"rect":return{x:s.x,y:s.y,width:s.width,height:s.height};case"circle":return{x:s.cx-s.r,y:s.cy-s.r,width:s.r*2,height:s.r*2};case"poly":{let e=100,i=100,t=0,r=0;for(let[n,h]of s.points)n<e&&(e=n),h<i&&(i=h),n>t&&(t=n),h>r&&(r=h);return{x:e,y:i,width:t-e,height:r-i}}default:return{x:0,y:0,width:0,height:0}}}var m=class extends HTMLElement{get shape(){return this.getAttribute("shape")||"rect"}get coords(){return this.getAttribute("coords")||""}get label(){return this.getAttribute("label")||""}get href(){return this.getAttribute("href")}get target(){return this.getAttribute("target")||""}get tooltipMode(){return this.getAttribute("tooltip")||"hover"}get disabled(){return this.hasAttribute("disabled")}connectedCallback(){this.setAttribute("data-upgraded","")}disconnectedCallback(){this.removeAttribute("data-upgraded")}},g=class extends f{#t=null;#i=null;#e=null;#n=[];#h=[];#r=null;#c=null;#o=null;setup(){if(this.#t=this.querySelector(":scope > img"),!this.#t){let e=this.getAttribute("src"),i=this.getAttribute("alt");if(e)this.#t=document.createElement("img"),this.#t.src=e,this.#t.alt=i||"",this.prepend(this.#t);else return!1}return this.#t.classList.add("image-map-img"),this.#t.complete?this.#u():this.#t.addEventListener("load",()=>this.#u(),{once:!0}),!0}teardown(){this.#c?.disconnect(),this.#s(),this.#i?.remove(),this.#e?.remove();for(let e of this.#h)e.anchor?.remove();this.#h=[],this.#n=[]}get regions(){return[...this.querySelectorAll(":scope > map-area")].map(e=>({shape:e.getAttribute("shape")||void 0,coords:e.getAttribute("coords")||void 0,label:e.getAttribute("label")||e.textContent?.trim()||void 0,href:e.getAttribute("href")||void 0,target:e.getAttribute("target")||void 0}))}set regions(e){let i=Array.isArray(e)?e:[];for(let t of[...this.querySelectorAll(":scope > map-area")])t.remove();for(let t of i){let r=document.createElement("map-area");t.shape&&r.setAttribute("shape",t.shape),t.coords&&r.setAttribute("coords",t.coords),t.label&&r.setAttribute("label",t.label),t.href&&r.setAttribute("href",t.href),t.target&&r.setAttribute("target",t.target),this.appendChild(r)}this.teardown(),this.removeAttribute("data-upgraded"),this.setup(),this.dispatchEvent(new CustomEvent("image-map:regions-changed",{detail:{regions:i,source:"property"},bubbles:!0}))}#u(){let e=[...this.querySelectorAll(":scope > map-area")];if(e.length===0){this.setAttribute("data-upgraded","");return}this.#i=document.createElementNS(p,"svg"),this.#i.setAttribute("viewBox","0 0 100 100"),this.#i.setAttribute("preserveAspectRatio","none"),this.#i.setAttribute("aria-hidden","true"),this.#i.classList.add("image-map-overlay"),this.#e=document.createElement("div"),this.#e.className="image-map-tooltip",this.#e.setAttribute("role","tooltip"),this.#e.setAttribute("aria-live","polite"),this.#e.id=`imap-tip-${crypto.randomUUID().slice(0,8)}`;for(let i of e){let t=i,r=t.shape,n=t.coords,h=v(r,n),a=E(h);if(!a)continue;let c=x(h),o=t.href?document.createElement("a"):document.createElement("button");t.href&&(o.href=t.href,t.target&&(o.target=t.target)),o.className="image-map-anchor",o.setAttribute("aria-label",t.label),o.setAttribute("aria-describedby",this.#e.id),o.textContent=t.label,o.style.left=`${c.x}%`,o.style.top=`${c.y}%`,o.style.width=`${c.width}%`,o.style.height=`${c.height}%`,t.disabled&&(a.setAttribute("data-disabled",""),o.setAttribute("tabindex","-1"),o.setAttribute("aria-disabled","true"));let d=i.innerHTML,l={area:i,parsed:h,svgShape:a,anchor:o,contentHTML:d};if(!t.disabled){let u=t.tooltipMode;this.listen(a,"pointerenter",()=>{u==="hover"&&this.#a(l),a.setAttribute("data-hover",""),this.#l("image-map:area-enter",t)}),this.listen(a,"pointerleave",()=>{u==="hover"&&this.#s(),a.removeAttribute("data-hover"),this.#l("image-map:area-leave",t)}),this.listen(a,"click",()=>{u==="click"&&(this.#r===l?this.#s():this.#a(l)),this.#l("image-map:area-activate",t),t.href&&u!=="click"&&(t.target==="_blank"?window.open(t.href,"_blank","noopener"):window.location.href=t.href)}),this.listen(a,"touchstart",A=>{u==="hover"&&(this.#o!==l?(A.preventDefault(),this.#o=l,this.#a(l)):this.#o=null)},{passive:!1}),this.listen(o,"focus",()=>{this.#a(l),a.setAttribute("data-hover","")}),this.listen(o,"blur",()=>{this.#s(),a.removeAttribute("data-hover")})}this.#i.appendChild(a),this.#h.push(l),this.#n.push(o)}this.appendChild(this.#i);for(let i of this.#n)this.appendChild(i);this.appendChild(this.#e),this.listen(this,"keydown",this.#f),this.#c=new ResizeObserver(()=>{this.#r&&this.#d(this.#r.svgShape)}),this.#c.observe(this.#t),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.#t.alt||"Image map"),this.setAttribute("data-upgraded","")}#a(e){this.#e&&(this.#r=e,this.#e.innerHTML=e.contentHTML,this.#e.setAttribute("data-visible",""),this.#d(e.svgShape))}#s(){this.#e&&(this.#r=null,this.#e.removeAttribute("data-visible"))}#d(e){if(!this.#e||!e)return;let i=e.getBoundingClientRect(),t=this.#e.getBoundingClientRect(),r=8,n=8,h=window.innerWidth,a=window.innerHeight,c,o,d=i.top-t.height-r;d>=n?(c=d,o=i.left+(i.width-t.width)/2):i.bottom+r+t.height<=a-n?(c=i.bottom+r,o=i.left+(i.width-t.width)/2):i.right+r+t.width<=h-n?(c=i.top+(i.height-t.height)/2,o=i.right+r):(c=i.top+(i.height-t.height)/2,o=i.left-t.width-r),o=Math.max(n,Math.min(o,h-t.width-n)),c=Math.max(n,Math.min(c,a-t.height-n)),this.#e.style.top=`${c}px`,this.#e.style.left=`${o}px`}#f=e=>{let i=this.#n.filter(r=>!r.hasAttribute("aria-disabled")),t=i.indexOf(document.activeElement);switch(e.key){case"ArrowDown":case"ArrowRight":{e.preventDefault();let r=t<i.length-1?t+1:0;i[r]?.focus();break}case"ArrowUp":case"ArrowLeft":{e.preventDefault();let r=t>0?t-1:i.length-1;i[r]?.focus();break}case"Escape":this.#s(),this.#o=null;break}};#l(e,i){this.dispatchEvent(new CustomEvent(e,{detail:{area:i},bubbles:!0}))}};b("map-area",m);b("image-map",g);export{g as ImageMapWc,m as MapAreaWc};
|
|
1
|
+
var L=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function m(s,t,e={}){let i=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:i},n=E.get(s);if(customElements.get(s)){if(!n||n.priority>=i){n&&n.priority===i&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=i){n.priority===i&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(s,r),customElements.define(s,t)}var d=class extends HTMLElement{#e=[];#r;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,r){t.addEventListener(e,i,r),this.#e.push(()=>t.removeEventListener(e,i,r))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#r||(this.#r=this.attachInternals());let i=this.#r.states;try{e?i.add(t):i.delete(t)}catch{let r=`--${t}`;e?i.add(r):i.delete(r)}}_adoptInternals(t){this.#r||(this.#r=t)}#t(){return this.constructor.formAssociated&&this.#r?this.#r:null}get validity(){return this.#t()?.validity}get validationMessage(){return this.#t()?.validationMessage??""}get willValidate(){return this.#t()?.willValidate??!1}get form(){return this.#t()?.form??null}checkValidity(){return this.#t()?.checkValidity()??!0}reportValidity(){return this.#t()?.reportValidity()??!0}};var f="http://www.w3.org/2000/svg";function S(s){return s.trim().split(/[\s,]+/).map(Number)}function C(s,t){let e=S(t);switch(s){case"rect":{let[i,r,n,o]=e;return{type:"rect",x:i,y:r,width:n-i,height:o-r}}case"circle":{let[i,r,n]=e;return{type:"circle",cx:i,cy:r,r:n}}case"poly":{let i=[];for(let r=0;r<e.length;r+=2)i.push([e[r],e[r+1]]);return{type:"poly",points:i}}default:return null}}function T(s){if(!s)return null;switch(s.type){case"rect":{let t=document.createElementNS(f,"rect");return t.setAttribute("x",String(s.x)),t.setAttribute("y",String(s.y)),t.setAttribute("width",String(s.width)),t.setAttribute("height",String(s.height)),t}case"circle":{let t=document.createElementNS(f,"circle");return t.setAttribute("cx",String(s.cx)),t.setAttribute("cy",String(s.cy)),t.setAttribute("r",String(s.r)),t}case"poly":{let t=document.createElementNS(f,"polygon");return t.setAttribute("points",s.points.map(e=>e.join(",")).join(" ")),t}default:return null}}function N(s){if(!s)return{x:0,y:0,width:0,height:0};switch(s.type){case"rect":return{x:s.x,y:s.y,width:s.width,height:s.height};case"circle":return{x:s.cx-s.r,y:s.cy-s.r,width:s.r*2,height:s.r*2};case"poly":{let t=100,e=100,i=0,r=0;for(let[n,o]of s.points)n<t&&(t=n),o<e&&(e=o),n>i&&(i=n),o>r&&(r=o);return{x:t,y:e,width:i-t,height:r-e}}default:return{x:0,y:0,width:0,height:0}}}var k=0,$=300,M='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function D(s){return s==null||s===""?[]:s instanceof HTMLTemplateElement?[s.content.cloneNode(!0)]:s instanceof Node?[s.cloneNode(!0)]:[document.createTextNode(String(s))]}var g=class extends HTMLElement{get shape(){return this.getAttribute("shape")||"rect"}get coords(){return this.getAttribute("coords")||""}get label(){return this.getAttribute("label")||""}get href(){return this.getAttribute("href")}get target(){return this.getAttribute("target")||""}get tooltipMode(){return this.getAttribute("tooltip")||"hover"}get disabled(){return this.hasAttribute("disabled")}connectedCallback(){this.setAttribute("data-upgraded","")}disconnectedCallback(){this.removeAttribute("data-upgraded")}},A=class extends d{#e=null;#r=null;#t=null;#l=[];#d=[];#i=null;#c=null;#o=null;#s=0;#h=0;#f=[];setup(){if(this.#e=this.querySelector(":scope > img"),!this.#e){let t=this.getAttribute("src"),e=this.getAttribute("alt");if(t)this.#e=document.createElement("img"),this.#e.src=t,this.#e.alt=e||"",this.prepend(this.#e);else return!1}return this.#e.classList.add("image-map-img"),this.#e.complete?this.#b():this.listen(this.#e,"load",()=>this.#b(),{once:!0}),!0}teardown(){this.#c?.disconnect(),this.#c=null,this.#n(),clearTimeout(this.#s),cancelAnimationFrame(this.#h),this.#r?.remove(),this.#t?.remove();for(let t of this.#d)t.anchor?.remove();for(let t of this.#f)t.removeAttribute("id");this.#r=null,this.#t=null,this.#d=[],this.#l=[],this.#f=[],this.#o=null}get regions(){return[...this.querySelectorAll(":scope > map-area")].map(t=>{let e;if(t.children.length){let i=document.createDocumentFragment();i.append(...[...t.childNodes].map(r=>r.cloneNode(!0))),e=i}else e=t.textContent?.trim()||void 0;return{shape:t.getAttribute("shape")||void 0,coords:t.getAttribute("coords")||void 0,label:t.getAttribute("label")||t.textContent?.trim().replace(/\s+/g," ")||void 0,href:t.getAttribute("href")||void 0,target:t.getAttribute("target")||void 0,tooltip:t.getAttribute("tooltip")||void 0,disabled:t.hasAttribute("disabled")||void 0,content:e}})}set regions(t){let e=Array.isArray(t)?t:[];for(let i of[...this.querySelectorAll(":scope > map-area")])i.remove();for(let i of e){if(!i)continue;let r=document.createElement("map-area");i.shape&&r.setAttribute("shape",i.shape),i.coords&&r.setAttribute("coords",i.coords),i.label&&r.setAttribute("label",i.label),i.href&&r.setAttribute("href",i.href),i.target&&r.setAttribute("target",i.target),i.tooltip&&r.setAttribute("tooltip",i.tooltip),i.disabled&&r.setAttribute("disabled",""),r.append(...D(i.content)),this.appendChild(r)}this._reinit(),this.dispatchEvent(new CustomEvent("image-map:regions-changed",{detail:{regions:this.regions,source:"property"},bubbles:!0}))}#b(){if(!this.isConnected||this.#r)return;let t=[...this.querySelectorAll(":scope > map-area")];if(t.length===0)return;let e=document.createElementNS(f,"svg");e.setAttribute("viewBox","0 0 100 100"),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("aria-hidden","true"),e.classList.add("image-map-overlay"),this.#r=e;let i=document.createElement("div");i.className="image-map-tooltip",i.id=`imap-tip-${++k}`,i.hidden=!0,this.#t=i;for(let r of t){let n=r,o=C(n.shape,n.coords),c=T(o);if(!c)continue;let l=N(o),h=r.getAttribute("href"),u=r.getAttribute("target")||"",p=r.getAttribute("tooltip")||"hover",y=r.hasAttribute("disabled"),b=r.textContent?.trim().replace(/\s+/g," ")||"",v=r.getAttribute("label")||b,a=h?document.createElement("a"):document.createElement("button");h?(a.href=h,u&&(a.target=u)):a.type="button",a.className="image-map-anchor",a.textContent=v;let w=p!=="none"&&(r.children.length>0||b&&b!==v);w&&(r.id||(r.id=`imap-area-${++k}`,this.#f.push(r)),p==="click"?(a.setAttribute("aria-expanded","false"),a.setAttribute("aria-controls",i.id)):a.setAttribute("aria-describedby",r.id)),a.style.left=`${l.x}%`,a.style.top=`${l.y}%`,a.style.width=`${l.width}%`,a.style.height=`${l.height}%`,y&&(c.setAttribute("data-disabled",""),a.setAttribute("tabindex","-1"),a.setAttribute("aria-disabled","true"));let x={area:r,parsed:o,svgShape:c,anchor:a,href:h,target:u,mode:p,hasContent:w,keyboardOpen:!1};y||this.#v(x),e.appendChild(c),this.#d.push(x),this.#l.push(a)}this.appendChild(e);for(let r of this.#l)this.appendChild(r);this.appendChild(i),this.listen(i,"pointerenter",()=>clearTimeout(this.#s)),this.listen(i,"pointerleave",()=>{this.#i?.mode==="hover"&&!this.#p()&&this.#g()}),this.listen(i,"focusout",r=>{let n=r.relatedTarget;n&&(i.contains(n)||n===this.#i?.anchor)||this.#n()}),this.listen(this,"keydown",this.#w),this.listen(document,"keydown",this.#x),this.listen(document,"pointerdown",this.#E),this.listen(window,"scroll",this.#A,{passive:!0,capture:!0}),this.#c=new ResizeObserver(this.#A),this.#c.observe(this.#e),this.setAttribute("role","group"),!this.hasAttribute("aria-label")&&!this.hasAttribute("aria-labelledby")&&this.setAttribute("aria-label",this.#e.alt||this.dataset.labelMap||"Image map")}#v(t){let{svgShape:e,anchor:i,area:r,mode:n}=t;this.listen(e,"pointerenter",()=>{clearTimeout(this.#s),n==="hover"&&this.#u(t),e.setAttribute("data-hover",""),this.#a("image-map:area-enter",r)}),this.listen(e,"pointerleave",()=>{n==="hover"&&this.#i===t&&!this.#p()&&this.#g(),document.activeElement!==i&&e.removeAttribute("data-hover"),this.#a("image-map:area-leave",r)}),this.listen(e,"click",()=>{let o=this.#m(t,!1);t.href&&n!=="click"&&!o.defaultPrevented&&(t.target==="_blank"?window.open(t.href,"_blank","noopener"):window.location.href=t.href)}),this.listen(e,"touchstart",o=>{n==="hover"&&(this.#o!==t?(o.preventDefault(),this.#o=t,this.#u(t)):this.#o=null)},{passive:!1}),this.listen(i,"click",o=>{let c=o.detail===0,l=this.#m(t,c);(n==="click"||l.defaultPrevented)&&o.preventDefault()}),t.href&&this.listen(i,"keydown",o=>{o.key===" "&&(o.preventDefault(),i.click())}),this.listen(i,"focus",()=>{clearTimeout(this.#s),n==="hover"&&this.#u(t),e.setAttribute("data-hover",""),this.#a("image-map:area-enter",r)}),this.listen(i,"blur",o=>{e.removeAttribute("data-hover"),this.#a("image-map:area-leave",r);let c=o.relatedTarget;this.#i===t&&!(c&&this.#t?.contains(c))&&this.#n()})}#m(t,e){if(t.mode==="click"&&t.hasContent){if(this.#i===t)this.#n();else if(this.#u(t),e){t.keyboardOpen=!0;let i=this.#t?.querySelector(M);i&&i.focus()}}return this.#a("image-map:area-activate",t.area,!0)}#p(){let t=document.activeElement;return!!(t&&this.#t?.contains(t))}#g(){clearTimeout(this.#s),this.#s=setTimeout(()=>this.#n(),$)}#u(t){let e=this.#t;!e||t.mode==="none"||!t.hasContent||(clearTimeout(this.#s),this.#i&&this.#i!==t&&this.#n(),this.#i=t,e.replaceChildren(...[...t.area.childNodes].map(i=>i.cloneNode(!0))),t.mode==="click"?(e.removeAttribute("role"),e.setAttribute("role","group"),e.setAttribute("aria-label",t.anchor.textContent||""),t.anchor.setAttribute("aria-expanded","true")):(e.setAttribute("role","tooltip"),e.removeAttribute("aria-label")),t.anchor.nextSibling!==e&&t.anchor.after(e),e.hidden=!1,e.setAttribute("data-state-visible",""),this.#y(t.svgShape))}#n({restoreFocus:t=!1}={}){clearTimeout(this.#s);let e=this.#i,i=this.#t;if(!i||!e)return;let r=this.#p();this.#i=null,e.keyboardOpen=!1,e.mode==="click"&&e.anchor.hasAttribute("aria-expanded")&&e.anchor.setAttribute("aria-expanded","false"),i.removeAttribute("data-state-visible"),i.hidden=!0,i.replaceChildren(),(t||r)&&e.anchor.focus()}#A=()=>{!this.#i||this.#h||(this.#h=requestAnimationFrame(()=>{this.#h=0,this.#i&&this.#y(this.#i.svgShape)}))};#y(t){if(!this.#t||!t)return;let e=t.getBoundingClientRect(),i=this.#t.getBoundingClientRect(),r=8,n=8,o=window.innerWidth,c=window.innerHeight,l,h,u=e.top-i.height-r;u>=n?(l=u,h=e.left+(e.width-i.width)/2):e.bottom+r+i.height<=c-n?(l=e.bottom+r,h=e.left+(e.width-i.width)/2):e.right+r+i.width<=o-n?(l=e.top+(e.height-i.height)/2,h=e.right+r):(l=e.top+(e.height-i.height)/2,h=e.left-i.width-r),h=Math.max(n,Math.min(h,o-i.width-n)),l=Math.max(n,Math.min(l,c-i.height-n)),this.#t.style.top=`${l}px`,this.#t.style.left=`${h}px`}#w=t=>{if(this.#t?.contains(t.target))return;let e=this.#l.filter(r=>!r.hasAttribute("aria-disabled")),i=e.indexOf(document.activeElement);if(i!==-1)switch(t.key){case"ArrowDown":case"ArrowRight":{t.preventDefault(),e[i<e.length-1?i+1:0]?.focus();break}case"ArrowUp":case"ArrowLeft":{t.preventDefault(),e[i>0?i-1:e.length-1]?.focus();break}}};#x=t=>{t.key==="Escape"&&(this.#o=null,this.#i&&(t.preventDefault(),this.#n()))};#E=t=>{if(!this.#i)return;let e=t.target;this.#t?.contains(e)||this.contains(e)&&e!==this&&e!==this.#e||(this.#o=null,this.#n())};#a(t,e,i=!1){let r=new CustomEvent(t,{detail:{area:e},bubbles:!0,cancelable:i});return this.dispatchEvent(r),r}};m("map-area",g);m("image-map",A);export{A as ImageMapWc,g as MapAreaWc};
|
|
2
2
|
//# sourceMappingURL=image-map.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var h=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function u(n,t,e={}){let r=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:r},s=l.get(n);if(customElements.get(n)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=r){s.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}l.set(n,i),customElements.define(n,t)}var o=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,r,i){t.addEventListener(e,r,i),this.#t.push(()=>t.removeEventListener(e,r,i))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let i=`--${t}`;e?r.add(i):r.delete(i)}}_adoptInternals(t){this.#e||(this.#e=t)}};var a=class extends o{#t;#e;#r=null;#i=!1;setup(){if(this.#i)return;let t=this.getAttribute("src");return t?(this.#r===null&&(this.#r=this.innerHTML),this.hasAttribute("lazy")?this.#n():this.#s(t),!0):!1}teardown(){this.#t?.disconnect(),this.#e?.abort()}get src(){return this.getAttribute("src")||""}set src(t){let e=t==null?"":String(t);this.src!==e&&(e?this.setAttribute("src",e):this.removeAttribute("src"),this.dispatchEvent(new CustomEvent("include-file:src-changed",{detail:{src:e,source:"property"},bubbles:!0})))}static get observedAttributes(){return["src"]}attributeChangedCallback(t,e,r){t==="src"&&r&&e!==r&&this.isConnected&&(this.hasAttribute("lazy")&&!this.#o()?this.#n():this.#s(r))}#o(){let t=this.getBoundingClientRect();return t.top<window.innerHeight+200&&t.bottom>-200}#n(){this.#t?.disconnect(),this.#t=new IntersectionObserver(t=>{for(let e of t)if(e.isIntersecting){this.#t.disconnect();let r=this.getAttribute("src");r&&this.#s(r)}},{rootMargin:"200px"}),this.#t.observe(this)}async#s(t){this.#e?.abort(),this.#e=new AbortController,this.setAttribute("data-loading",""),this.removeAttribute("data-loaded"),this.removeAttribute("data-error");try{let e=await fetch(t,{signal:this.#e.signal});if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);let r=await e.text(),i=this.getAttribute("mode")||"replace";i==="replace"?this.innerHTML=r:i==="append"?this.insertAdjacentHTML("beforeend",r):i==="prepend"&&this.insertAdjacentHTML("afterbegin",r),this.hasAttribute("allow-scripts")?this.querySelectorAll("script").forEach(s=>{let c=document.createElement("script");for(let d of s.attributes)c.setAttribute(d.name,d.value);c.textContent=s.textContent,s.replaceWith(c)}):this.querySelectorAll("script").forEach(s=>s.remove()),this.removeAttribute("data-loading"),this.setAttribute("data-loaded",""),this.#i=!0,this.dispatchEvent(new CustomEvent("include-file:loaded",{bubbles:!0,detail:{src:t,html:r}}))}catch(e){if(e.name==="AbortError")return;this.removeAttribute("data-loading"),this.setAttribute("data-error",""),(this.getAttribute("mode")||"replace")==="replace"&&this.#r!==null&&!this.#i&&(this.innerHTML=this.#r),this.dispatchEvent(new CustomEvent("include-file:error",{bubbles:!0,detail:{src:t,error:e.message}}))}}reload(){let t=this.getAttribute("src");t&&this.#s(t)}};u("include-file",a);export{a as IncludeFile};
|
|
1
|
+
var et=window.matchMedia("(prefers-reduced-motion: reduce)");var y=new Map;function A(n,t,e={}){let r=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:r},o=y.get(n);if(customElements.get(n)){if(!o||o.priority>=r){o&&o.priority===r&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=r){o.priority===r&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${o.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}y.set(n,i),customElements.define(n,t)}var d=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,i){t.addEventListener(e,r,i),this.#t.push(()=>t.removeEventListener(e,r,i))}_reinit(){for(let t of this.#t)t();this.#t=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let r=this.#e.states;try{e?r.add(t):r.delete(t)}catch{let i=`--${t}`;e?r.add(i):r.delete(i)}}_adoptInternals(t){this.#e||(this.#e=t)}#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}};var x="http://www.w3.org/1999/xhtml",h="http://www.w3.org/2000/svg",C="http://www.w3.org/1998/Math/MathML",N=new Set([x,h,C]),m="user-content-",$=new Set(["script","iframe","frame","frameset","object","embed","applet","portal","fencedframe","form","base","link","meta","noscript","foreignobject","style","xmp","noembed","noframes","plaintext","mglyph","malignmark","annotation-xml"]),E=new Set(["title","desc"]),I=new Set(["animate","set","animatemotion","animatetransform"]),_=new Set(["href","xlink:href","action","formaction","data","codebase","cite","background","longdesc","manifest","to","from","values","by"]),O=new Set(["src","poster","srcset"]),U=new Set(["srcdoc","form","formaction","formmethod","formtarget","formenctype","formnovalidate","action","method","ping"]),D=new Set(["popovertarget","popovertargetaction","commandfor","command","interestfor","autofocus"]),H=new Set(["for","headers","list","aria-labelledby","aria-describedby","aria-controls","aria-owns","aria-flowto","aria-details","aria-errormessage","aria-activedescendant"]),F={"include-file":["trusted","allow-scripts","allow-cross-origin"],"markdown-viewer":["src","sanitize","ping","allow-cross-origin"]},B=new Set(["social-embed","youtube-player","geo-map"]),q=["src","src-dark","data-src","url","endpoint","tile-url","data-versions"],z=new Set(["audio-player","video-player","image-map","brand-mark"]);function V(n){return String(n).replace(/[\u0000- \u007f-\u009f]/g,"").toLowerCase()}function v(n,t=!1){let e=V(n);return t?/(^|,)(javascript|vbscript|livescript):/.test(e)?!0:/(^|,)data:/.test(e)?e.split(/(?=data:)/).filter(i=>i.startsWith("data:")).some(i=>!/^data:(image|audio|video|font)\//.test(i)):!1:/^(javascript|vbscript|livescript|data):/.test(e)}function S(n){let t=String(n).replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\/g,"").replace(/\s+/g,"").toLowerCase();return/expression\(|javascript:|vbscript:|-moz-binding|behavior:|@import|position:fixed/.test(t)}var W=n=>String(n.localName||n.tagName||"").toLowerCase(),j=n=>n.startsWith(m)?n:m+n;function P(n,t){if($.has(t))return!0;let e=n.namespaceURI;return!!(e&&!N.has(e)||t==="title"&&e!==h||E.has(t)&&e===h&&n.children?.length||I.has(t)&&(n.getAttribute("attributeName")||n.getAttribute("attributename")||"").toLowerCase().includes("href"))}function G(n,t){for(let e of[...n.attributes]){let r=e.name.toLowerCase();if(r.startsWith("on")||U.has(r)||!t.keepIds&&D.has(r)){n.removeAttribute(e.name);continue}if(r==="style"){(!t.keepStyle||S(e.value))&&n.removeAttribute(e.name);continue}if((r==="id"||r==="name")&&!t.keepIds){let i=j(e.value);r==="id"?t.ids.set(e.value,i):t.ids.set(`name:${e.value}`,i),n.setAttribute(e.name,i);continue}if(_.has(r)||r.endsWith(":href")){v(e.value,!1)&&n.removeAttribute(e.name);continue}O.has(r)&&v(e.value,!0)&&n.removeAttribute(e.name)}}function X(n,t){let e=(n.getAttribute("type")||"").toLowerCase();t==="button"&&e!=="button"&&n.setAttribute("type","button"),t==="input"&&/^(submit|reset|image)$/.test(e)&&n.setAttribute("type","button")}function Y(n,t){for(let e of n)for(let r of[...e.attributes]){let i=r.name.toLowerCase(),o=r.value;if((i==="href"||i.endsWith(":href"))&&o.startsWith("#")){let s=K(o.slice(1));t.has(s)&&e.setAttribute(r.name,`#${t.get(s)}`)}else if(i==="usemap"&&o.startsWith("#")){let s=t.get(`name:${o.slice(1)}`);s?e.setAttribute(r.name,`#${s}`):e.removeAttribute(r.name)}else if(H.has(i)){let s=o.split(/\s+/).filter(Boolean).map(a=>t.get(a)||(a.startsWith(m)?a:null)).filter(Boolean);s.length?e.setAttribute(r.name,s.join(" ")):e.removeAttribute(r.name)}else o.includes("url(#")&&e.setAttribute(r.name,o.replace(/url\(#([^)]+)\)/g,(s,a)=>t.has(a)?`url(#${t.get(a)})`:s))}}function K(n){try{return decodeURIComponent(n)}catch{return n}}function T(n){let t=n.childNodes;if(t)for(let e of[...t])e.nodeType===8?e.remove():(e.nodeType===1||e.nodeType===11)&&T(e)}function M(n,t){T(n);let e=[...n.querySelectorAll("*")];t.includeRoot&&e.unshift(n);let r=new Map,i=[],o={...t,ids:r};for(let s of e){if(!Q(s,n))continue;let a=W(s);if(t.svgOnly&&(E.has(a)||a==="style")){if(a==="style"&&S(s.textContent||"")){s.remove();continue}}else if(P(s,a)){s.remove();continue}if(!t.keepIds&&!t.svgOnly&&B.has(a)){J(s);continue}if(a==="template"){let l=s.content;l&&M(l,{...t,includeRoot:!1})}G(s,o),t.keepIds||X(s,a);let c=F[a];if(c)for(let l of c)s.removeAttribute(l);if(a==="include-file"&&!t.allowIncludeFile&&s.removeAttribute("src"),!t.keepIds&&!t.svgOnly&&a.includes("-")&&a!=="include-file"&&!z.has(a))for(let l of q)s.removeAttribute(l);i.push(s)}!t.keepIds&&r.size&&Y(i,r)}function J(n){let t=n.parentNode;if(t){for(let e of[...n.childNodes])t.insertBefore(e,n);n.remove()}}function Q(n,t){let e=n;for(;e;){if(e===t)return!0;e=e.parentNode??e.parent??null}return!1}function L(n,t={}){let e=document.createElement("template");return n&&typeof n=="string"&&(e.innerHTML=n,M(e.content,{allowIncludeFile:!!t.allowIncludeFile,keepIds:!!t.keepIds,keepStyle:!!t.keepStyle})),e.content}var k=10,Z=new Set(["replace","append","prepend"]),tt="Failed to load content",p=class extends d{#t;#e;#r=null;#s=!1;#c=null;#o="";#n=!1;#i=null;setup(){let t=this.getAttribute("src");return t?(this.#n=!0,this.#r===null&&(this.#r=this.innerHTML),this.#s&&this.#c===t||this.#l(t),!0):!1}teardown(){this.#n=!1,this.#t?.disconnect(),this.hasAttribute("data-loading")&&(this.#e?.abort(),this.removeAttribute("data-loading"),this.removeAttribute("aria-busy"))}get src(){return this.getAttribute("src")||""}set src(t){let e=t==null?"":String(t);this.src!==e&&(e?this.setAttribute("src",e):this.removeAttribute("src"),this.dispatchEvent(new CustomEvent("include-file:src-changed",{detail:{src:e,source:"property"},bubbles:!0})))}static get observedAttributes(){return["src"]}attributeChangedCallback(t,e,r){if(!(t!=="src"||!r||e===r)){if(!this.#n){queueMicrotask(()=>{!this.#n&&this.isConnected&&this.getAttribute("src")&&this._reinit()});return}this.#l(r)}}#l(t){this.hasAttribute("lazy")&&!this.#f()?this.#h():this.#a(t)}#f(){let t=this.getBoundingClientRect();return t.top<window.innerHeight+200&&t.bottom>-200}#h(){this.#t?.disconnect(),this.#t=new IntersectionObserver(t=>{for(let e of t)if(e.isIntersecting){this.#t.disconnect();let r=this.getAttribute("src");r&&this.#a(r)}},{rootMargin:"200px"}),this.#t.observe(this)}#m(t){let e;try{e=new URL(t,document.baseURI)}catch{throw new Error(`Invalid URL: ${t}`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error(`Refused ${e.protocol} URL: only http(s) is allowed`);return this.#u(e.href),e.href}#u(t){if(!this.hasAttribute("allow-cross-origin")&&new URL(t).origin!==location.origin)throw new Error(`Refused cross-origin URL ${t} (add allow-cross-origin to permit)`)}#p(t){let e=0,r=this.parentElement?.closest("include-file");for(;r;){if(#o in r&&(e++,r.#o===t))throw new Error(`Refused include cycle: ${t} is already included by an ancestor`);r=r.parentElement?.closest("include-file")}if(e>=k)throw new Error(`Refused include: nesting deeper than ${k}`)}#d(){let t=this.getAttribute("mode")||"replace";return Z.has(t)?t:(console.warn(`<include-file>: unknown mode "${t}", using "replace"`),"replace")}async#a(t){this.#e?.abort();let e=new AbortController;this.#e=e,this.#g(),this.setAttribute("data-loading",""),this.setAttribute("aria-busy","true"),this.removeAttribute("data-loaded"),this.removeAttribute("data-error");try{let r=this.#m(t);this.#p(r),this.#o=r;let i=await fetch(r,{signal:e.signal});if(i.url&&this.#u(i.url),!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);let o=await i.text();if(e.signal.aborted)return;let s=this.hasAttribute("trusted");this.hasAttribute("allow-scripts")&&!s&&console.warn("<include-file>: allow-scripts is ignored without trusted");let a=s&&this.hasAttribute("allow-scripts"),c;if(s){let u=document.createElement("template");u.innerHTML=o,c=u.content}else c=L(o,{allowIncludeFile:!0,keepIds:!0,keepStyle:!0});let l=document.createElement("template");l.content.append(c.cloneNode(!0));let R=l.innerHTML,b=[...c.querySelectorAll("script")];a||b.forEach(u=>u.remove());let g=this.#d();g==="replace"?this.replaceChildren(c):g==="append"?this.append(c):this.prepend(c);for(let u of a?b:[]){let f=document.createElement("script");for(let w of u.attributes)f.setAttribute(w.name,w.value);f.textContent=u.textContent,u.replaceWith(f)}this.removeAttribute("data-loading"),this.removeAttribute("aria-busy"),this.setAttribute("data-loaded",""),this.#s=!0,this.#c=t,this.dispatchEvent(new CustomEvent("include-file:loaded",{bubbles:!0,detail:{src:t,url:r,html:R}}))}catch(r){if(r.name==="AbortError"||e.signal.aborted)return;this.#b(t,r)}}#b(t,e){if(this.removeAttribute("data-loading"),this.removeAttribute("aria-busy"),this.setAttribute("data-error",""),this.#d()==="replace"&&this.#r!==null&&!this.#s&&(this.innerHTML=this.#r),!this.textContent.trim()&&!this.children.length){let r=document.createElement("p");r.setAttribute("role","alert"),r.setAttribute("data-include-error",""),r.textContent=this.getAttribute("data-label-error")||tt,this.append(r),this.#i=r}this.dispatchEvent(new CustomEvent("include-file:error",{bubbles:!0,detail:{src:t,error:e.message}}))}#g(){this.#i?.parentNode===this&&this.#i.remove(),this.#i=null}reload(){let t=this.getAttribute("src");t&&this.#a(t)}};A("include-file",p);export{p as IncludeFile};
|
|
2
2
|
//# sourceMappingURL=include-file.js.map
|