vanilla-breeze 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/components/accordion-wc.js +1 -1
- package/dist/cdn/components/analytics-panel.js +1 -1
- package/dist/cdn/components/audio-player.js +1 -1
- package/dist/cdn/components/audio-visualizer.js +2 -2
- package/dist/cdn/components/author-index.js +1 -1
- package/dist/cdn/components/brand-mark.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 +11 -11
- package/dist/cdn/components/chat-input.js +1 -1
- package/dist/cdn/components/chat-window.js +1 -1
- package/dist/cdn/components/color-palette.js +4 -4
- 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-wc.js +1 -1
- package/dist/cdn/components/compare-surface.js +1 -1
- package/dist/cdn/components/component-sampler.js +4 -4
- 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/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/font-pairer.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/gantt-chart.js +1 -1
- package/dist/cdn/components/geo-map.js +3 -3
- package/dist/cdn/components/glossary-index.js +1 -1
- package/dist/cdn/components/glossary-wc.js +1 -1
- package/dist/cdn/components/gradient-builder.js +1 -1
- package/dist/cdn/components/heading-links.js +1 -1
- package/dist/cdn/components/highlight-wc.js +2 -2
- package/dist/cdn/components/image-gallery.js +1 -1
- package/dist/cdn/components/image-map.js +1 -1
- package/dist/cdn/components/impact-effort.js +1 -1
- package/dist/cdn/components/include-file.js +1 -1
- package/dist/cdn/components/kanban-board.js +1 -1
- package/dist/cdn/components/manifest.json +95 -95
- package/dist/cdn/components/markdown-editor.js +1 -1
- package/dist/cdn/components/markdown-viewer.js +1 -1
- package/dist/cdn/components/motion-specimen.js +3 -3
- package/dist/cdn/components/note-wc.js +1 -1
- package/dist/cdn/components/notification-wc.js +4 -4
- package/dist/cdn/components/page-info.js +20 -20
- 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 +2 -2
- package/dist/cdn/components/palette-generator.js +1 -1
- package/dist/cdn/components/popularity-index.js +1 -1
- package/dist/cdn/components/print-page.js +1 -1
- package/dist/cdn/components/qr-code.js +1 -1
- package/dist/cdn/components/reader-view.js +2 -2
- package/dist/cdn/components/recently-visited.js +26 -2
- package/dist/cdn/components/selection-menu.js +1 -1
- package/dist/cdn/components/semantic-palette.js +1 -1
- package/dist/cdn/components/settings-panel.js +2 -2
- package/dist/cdn/components/share-wc.js +1 -1
- package/dist/cdn/components/short-cuts.js +1 -1
- package/dist/cdn/components/site-index.js +1 -1
- package/dist/cdn/components/site-map-wc.js +1 -1
- package/dist/cdn/components/site-map.js +1 -1
- package/dist/cdn/components/site-search.js +3 -3
- package/dist/cdn/components/slide-accept.js +1 -1
- package/dist/cdn/components/social-embed.js +1 -1
- package/dist/cdn/components/spacing-specimen.js +2 -2
- package/dist/cdn/components/split-surface.js +1 -1
- package/dist/cdn/components/star-rating.js +1 -1
- package/dist/cdn/components/story-map.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-export.js +1 -1
- package/dist/cdn/components/theme-picker.js +3 -3
- package/dist/cdn/components/time-index.js +1 -1
- package/dist/cdn/components/time-picker.js +1 -1
- package/dist/cdn/components/toast-msg.js +1 -1
- package/dist/cdn/components/token-specimen.js +6 -6
- package/dist/cdn/components/tool-tip.js +1 -1
- package/dist/cdn/components/topic-map.js +3 -2
- package/dist/cdn/components/trust-filter.js +3 -3
- package/dist/cdn/components/type-specimen.js +1 -1
- package/dist/cdn/components/user-story.js +8 -8
- package/dist/cdn/components/video-player.js +4 -4
- package/dist/cdn/components/watch-wc.js +2 -2
- package/dist/cdn/components/week-view.js +1 -1
- package/dist/cdn/components/work-item.js +14 -14
- package/dist/cdn/components/youtube-player.js +1 -1
- package/dist/cdn/packs/design-system.full.js +15 -15
- package/dist/cdn/packs/effects.full.js +1 -1
- package/dist/cdn/packs/manifest.json +5 -5
- package/dist/cdn/packs/ui.full.css +1 -1
- package/dist/cdn/packs/ui.full.js +5 -5
- package/dist/cdn/packs/ux-planning.full.js +119 -119
- package/dist/cdn/vanilla-breeze-charts.css +1 -1
- package/dist/cdn/vanilla-breeze-charts.js +11 -11
- package/dist/cdn/vanilla-breeze-core.css +1 -1
- package/dist/cdn/vanilla-breeze-core.js +21 -21
- package/dist/cdn/vanilla-breeze-extras.js +3 -3
- package/dist/cdn/vanilla-breeze.css +1 -1
- package/dist/cdn/vanilla-breeze.js +210 -185
- package/package.json +5 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var m=window.matchMedia("(prefers-reduced-motion: reduce)");var f=new Map;function h(s,n,e={}){let t=e.priority??10,o={impl:n,bundle:e.bundle,contract:e.contract,priority:t},r=f.get(s);if(customElements.get(s)){if(!r||r.priority>=t){r&&r.priority===t&&r.impl!==n&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=t){r.priority===t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}f.set(s,o),customElements.define(s,n)}var l=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let n of this.#e)n();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(n,e,t,o){n.addEventListener(e,t,o),this.#e.push(()=>n.removeEventListener(e,t,o))}setup(){}teardown(){}};var d=class extends l{#e=null;#t=null;setup(){this.#n(),this.#o()}teardown(){this.#t?.disconnect()}#n(){let n=this.getAttribute("placeholder")||"Filter terms\u2026",e=document.createElement("input");e.type="search",e.placeholder=n,e.setAttribute("aria-label",n),e.setAttribute("data-glossary-search",""),e.addEventListener("input",()=>this.#r(e.value));let t=this.querySelector("main");t?t.prepend(e):this.prepend(e),this.#e=e}#r(n){let e=n.toLowerCase().trim(),t=this.querySelectorAll('.glossary-section, section[id^="glossary-"]');for(let o of t){let r=o.querySelectorAll("dt"),i=!1;for(let c of r){let p=c.textContent?.toLowerCase()||"",a=!e||p.includes(e),u=c.nextElementSibling;c.hidden=!a,u?.tagName==="DD"&&(u.hidden=!a),a&&(i=!0)}o.hidden=!i}}#o(){let n=this.querySelectorAll(".glossary-jump a");if(!n.length)return;let e=this.querySelectorAll('.glossary-section, section[id^="glossary-"]');if(e.length){this.#t=new IntersectionObserver(t=>{for(let o of t)if(o.isIntersecting){let r=o.target.id;for(let i of n){let c=i.getAttribute("href")===`#${r}`;i.setAttribute("aria-current",c?"true":"false")}}},{rootMargin:"-20% 0px -60% 0px"});for(let t of e)this.#t.observe(t)}}};h("glossary-index",d);export{d as GlossaryIndex};
|
|
1
|
+
var m=window.matchMedia("(prefers-reduced-motion: reduce)");var f=new Map;function h(s,n,e={}){let t=e.priority??10,o={impl:n,bundle:e.bundle,contract:e.contract,priority:t},r=f.get(s);if(customElements.get(s)){if(!r||r.priority>=t){r&&r.priority===t&&r.impl!==n&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=t){r.priority===t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}f.set(s,o),customElements.define(s,n)}var l=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let n of this.#e)n();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(n,e,t,o){n.addEventListener(e,t,o),this.#e.push(()=>n.removeEventListener(e,t,o))}setup(){}teardown(){}};var d=class extends l{#e=null;#t=null;setup(){this.#n(),this.#o()}teardown(){this.#t?.disconnect()}#n(){let n=this.getAttribute("placeholder")||"Filter terms\u2026",e=document.createElement("input");e.type="search",e.placeholder=n,e.setAttribute("aria-label",n),e.setAttribute("data-glossary-search",""),e.addEventListener("input",()=>this.#r(e.value));let t=this.querySelector("main");t?t.prepend(e):this.prepend(e),this.#e=e}#r(n){let e=n.toLowerCase().trim(),t=this.querySelectorAll('.glossary-section, section[id^="glossary-"]');for(let o of t){let r=o.querySelectorAll("dt"),i=!1;for(let c of r){let p=c.textContent?.toLowerCase()||"",a=!e||p.includes(e),u=c.nextElementSibling;c.hidden=!a,u?.tagName==="DD"&&(u.hidden=!a),a&&(i=!0)}o.hidden=!i}}#o(){let n=this.querySelectorAll(".glossary-jump a");if(!n.length)return;let e=this.querySelectorAll('.glossary-section, section[id^="glossary-"]');if(e.length){this.#t=new IntersectionObserver(t=>{for(let o of t)if(o.isIntersecting){let r=o.target.id;for(let i of n){let c=i.getAttribute("href")===`#${r}`;i.setAttribute("aria-current",c?"true":"false")}}},{rootMargin:"-20% 0px -60% 0px"});for(let t of e)this.#t.observe(t)}}};h("glossary-index",d);export{d as GlossaryIndex};
|
|
2
2
|
//# sourceMappingURL=glossary-index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var y=window.matchMedia("(prefers-reduced-motion: reduce)");var b=new Map;function C(a,i,t={}){let e=t.priority??10,r={impl:i,bundle:t.bundle,contract:t.contract,priority:e},s=b.get(a);if(customElements.get(a)){if(!s||s.priority>=e){s&&s.priority===e&&s.impl!==i&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=e){s.priority===e&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}b.set(a,r),customElements.define(a,i)}var u=class extends HTMLElement{#n=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let i of this.#n)i();this.#n=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(i,t,e,r){i.addEventListener(t,e,r),this.#n.push(()=>i.removeEventListener(t,e,r))}setup(){}teardown(){}};function m(a){return String(a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var p={user:'<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',pencil:'<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>',check:'<path d="M20 6 9 17l-5-5"/>',target:'<circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/>',alertTriangle:'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',messageCircle:'<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/>',lightbulb:'<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/>',wrench:'<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"/>',heart:'<path d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"/>',mapPin:'<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>',checkCircle:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m9 11 3 3L22 4"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',send:'<path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"/><path d="m21.854 2.147-10.94 10.939"/>'},v={says:{label:"Says",icon:p.messageCircle,color:"#3b82f6"},thinks:{label:"Thinks",icon:p.lightbulb,color:"#8b5cf6"},does:{label:"Does",icon:p.wrench,color:"#f59e0b"},feels:{label:"Feels",icon:p.heart,color:"#ef4444"}};var g=class a extends u{static get observedAttributes(){return["src","compact","title","searchable"]}static#n=0;#c=null;#i=null;#r=null;#t=null;#s=null;#l="";#a=null;#e=[];#o=[];#h=new Map;#d=new Map;setup(){this.#l=`gloss-${++a.#n}`;let i=this.querySelector(":scope > dl");if(!i)return!1;let t=[...i.querySelectorAll(":scope > div[data-term-id]")];if(t.length===0)return!1;this.#e=t.map(s=>{let o=s.getAttribute("data-term-id")||"",d=s.getAttribute("data-category")||"Uncategorized",c=s.querySelector("dt"),h=s.querySelector("dd"),n=c?c.textContent.trim():"",l=h?h.textContent.trim():"";return s.id=o,{id:o,term:n,definition:l,category:d,el:s}});let e=new Set;this.#o=[];for(let s of this.#e)e.has(s.category)||(e.add(s.category),this.#o.push(s.category));i.remove(),this.#u();let r=this.getAttribute("src");if(r){this._loadSrc(r);return}this.dispatchEvent(new CustomEvent("glossary-wc:ready",{bubbles:!0,detail:{termCount:this.#e.length,categories:[...this.#o]}}))}teardown(){this.#a&&clearTimeout(this.#a);let i=this.querySelector(".gloss-title");i&&i.remove(),this.#c?.parentElement&&this.#c.parentElement.remove(),this.#i&&this.#i.remove(),this.#s&&this.#s.remove(),this.#t&&this.#t.remove(),this.#c=null,this.#i=null,this.#r=null,this.#t=null,this.#s=null,this.#e=[],this.#o=[],this.#h=new Map,this.#d=new Map}#u(){let i=this.getAttribute("title");if(i){let t=document.createElement("h2");t.className="gloss-title",t.textContent=i,this.#r=document.createElement("output"),this.#r.className="gloss-count",this.#r.textContent=String(this.#e.length),t.appendChild(this.#r),this.appendChild(t)}if(this.hasAttribute("searchable")){let t=document.createElement("div");t.className="gloss-search";let e=document.createElement("input");e.type="search",e.className="gloss-search-input",e.setAttribute("placeholder","Search terms\u2026"),e.setAttribute("aria-label","Search glossary terms"),t.appendChild(e),this.appendChild(t),this.#c=e,this.listen(e,"input",this.#f)}this.#p(),this.#s=document.createElement("div"),this.#s.className="gloss-categories",this.#s.setAttribute("role","region"),this.#s.setAttribute("aria-label","Glossary terms"),this.appendChild(this.#s);for(let t of this.#o){let e=this.#e.filter(r=>r.category===t);this.#m(t,e)}this.#t=document.createElement("div"),this.#t.className="gloss-live-region",this.#t.setAttribute("role","status"),this.#t.setAttribute("aria-live","polite"),this.#t.setAttribute("aria-atomic","true"),this.appendChild(this.#t)}#p(){this.#i=document.createElement("nav"),this.#i.className="gloss-jump-bar",this.#i.setAttribute("aria-label","Alphabet navigation");let i=new Set;for(let t of this.#e){let e=t.term.charAt(0).toUpperCase();/[A-Z]/.test(e)&&i.add(e)}for(let t=65;t<=90;t++){let e=String.fromCharCode(t),r=document.createElement("a");r.textContent=e,r.className="gloss-jump-letter",i.has(e)?(r.href=`#${this.#l}-letter-${e}`,r.setAttribute("data-active","")):(r.setAttribute("aria-disabled","true"),r.setAttribute("tabindex","-1")),this.#i.appendChild(r)}this.appendChild(this.#i)}#m(i,t){let e=document.createElement("section");e.className="gloss-category",e.setAttribute("data-category",i);let r=document.createElement("header");r.className="gloss-category-header";let s=document.createElement("button");s.type="button",s.className="gloss-category-toggle",s.setAttribute("aria-expanded","true"),s.innerHTML=`<span class="gloss-category-label">${m(i)}</span><output class="gloss-category-count">${t.length}</output><span class="gloss-chevron" aria-hidden="true"></span>`,r.appendChild(s),e.appendChild(r),this.#h.set(i,s);let o=document.createElement("dl");o.className="gloss-term-list";let d=[...t].sort((n,l)=>n.term.localeCompare(l.term)),c=[],h="";for(let n of d){let l=n.term.charAt(0).toUpperCase();if(/[A-Z]/.test(l)&&l!==h){h=l;let f=document.createElement("span");f.id=`${this.#l}-letter-${l}`,f.className="gloss-letter-anchor",o.appendChild(f)}n.el.className="gloss-term",n.el.id=n.id,o.appendChild(n.el),c.push(n.el)}this.#d.set(i,c),e.appendChild(o),this.#s.appendChild(e),this.listen(s,"click",()=>{let n=s.getAttribute("aria-expanded")==="true";s.setAttribute("aria-expanded",String(!n)),o.hidden=n})}#f=i=>{this.#a&&clearTimeout(this.#a),this.#a=setTimeout(()=>{let t=i.target.value.toLowerCase().trim();this.#g(t)},150)};#g(i){let t=0;for(let e of this.#e)i===""||e.term.toLowerCase().includes(i)||e.definition.toLowerCase().includes(i)?(e.el.removeAttribute("hidden"),t++):e.el.setAttribute("hidden","");for(let e of this.#o){let r=this.#d.get(e)||[],s=r[0]?.closest(".gloss-category");if(!s)continue;if(r.some(d=>!d.hasAttribute("hidden"))){s.removeAttribute("hidden");let d=r.filter(h=>!h.hasAttribute("hidden")).length,c=s.querySelector(".gloss-category-count");c&&(c.textContent=String(d))}else s.setAttribute("hidden","")}this.#r&&(this.#r.textContent=i===""?String(this.#e.length):`${t} / ${this.#e.length}`),i!==""&&this.#t&&(this.#t.textContent="",requestAnimationFrame(()=>{this.#t&&(this.#t.textContent=`${t} term${t!==1?"s":""} found`)})),this.dispatchEvent(new CustomEvent("glossary-wc:search",{bubbles:!0,detail:{query:i,matchCount:t}}))}attributeChangedCallback(i,t,e){t===e||!this.isConnected||i==="src"&&this._loadSrc(e)}async _loadSrc(i){if(i)try{let t=await fetch(i);if(!t.ok)throw new Error(`HTTP ${t.status}`);let e=await t.json();for(;this.firstChild;)this.firstChild.remove();let r=document.createElement("dl");for(let s of e.terms||[]){let o=document.createElement("div");o.setAttribute("data-term-id",s.id||""),o.setAttribute("data-category",s.category||"Uncategorized");let d=document.createElement("dt");d.textContent=s.term||"";let c=document.createElement("dd"),h=s.definition||"";if(s.seeAlso&&s.seeAlso.length>0){let n=s.seeAlso.map(l=>`<a href="#${m(l)}">${m(this.#b(l))}</a>`).join(", ");h+=` See also: ${n}.`}c.innerHTML=h,o.appendChild(d),o.appendChild(c),r.appendChild(o)}this.appendChild(r),e.title&&!this.getAttribute("title")&&this.setAttribute("title",e.title),this.teardown(),this.removeAttribute("data-upgraded"),this.setup()}catch(t){console.warn(`[glossary-wc] Failed to load src="${i}":`,t)}}#b(i){return i.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}};C("glossary-wc",g);export{g as GlossaryWc};
|
|
1
|
+
var y=window.matchMedia("(prefers-reduced-motion: reduce)");var b=new Map;function C(a,i,t={}){let e=t.priority??10,r={impl:i,bundle:t.bundle,contract:t.contract,priority:e},s=b.get(a);if(customElements.get(a)){if(!s||s.priority>=e){s&&s.priority===e&&s.impl!==i&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=e){s.priority===e&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}b.set(a,r),customElements.define(a,i)}var u=class extends HTMLElement{#n=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let i of this.#n)i();this.#n=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(i,t,e,r){i.addEventListener(t,e,r),this.#n.push(()=>i.removeEventListener(t,e,r))}setup(){}teardown(){}};function m(a){return String(a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var p={user:'<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',pencil:'<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>',check:'<path d="M20 6 9 17l-5-5"/>',target:'<circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/>',alertTriangle:'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',messageCircle:'<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/>',lightbulb:'<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/>',wrench:'<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"/>',heart:'<path d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"/>',mapPin:'<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"/><circle cx="12" cy="10" r="3"/>',checkCircle:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="m9 11 3 3L22 4"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',send:'<path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"/><path d="m21.854 2.147-10.94 10.939"/>'},v={says:{label:"Says",icon:p.messageCircle,color:"#3b82f6"},thinks:{label:"Thinks",icon:p.lightbulb,color:"#8b5cf6"},does:{label:"Does",icon:p.wrench,color:"#f59e0b"},feels:{label:"Feels",icon:p.heart,color:"#ef4444"}};var g=class a extends u{static get observedAttributes(){return["src","compact","title","searchable"]}static#n=0;#c=null;#i=null;#r=null;#t=null;#s=null;#l="";#a=null;#e=[];#o=[];#h=new Map;#d=new Map;setup(){this.#l=`gloss-${++a.#n}`;let i=this.querySelector(":scope > dl");if(!i)return!1;let t=[...i.querySelectorAll(":scope > div[data-term-id]")];if(t.length===0)return!1;this.#e=t.map(s=>{let o=s.getAttribute("data-term-id")||"",d=s.getAttribute("data-category")||"Uncategorized",c=s.querySelector("dt"),h=s.querySelector("dd"),n=c?c.textContent.trim():"",l=h?h.textContent.trim():"";return s.id=o,{id:o,term:n,definition:l,category:d,el:s}});let e=new Set;this.#o=[];for(let s of this.#e)e.has(s.category)||(e.add(s.category),this.#o.push(s.category));i.remove(),this.#u();let r=this.getAttribute("src");if(r){this._loadSrc(r);return}this.dispatchEvent(new CustomEvent("glossary-wc:ready",{bubbles:!0,detail:{termCount:this.#e.length,categories:[...this.#o]}}))}teardown(){this.#a&&clearTimeout(this.#a);let i=this.querySelector(".gloss-title");i&&i.remove(),this.#c?.parentElement&&this.#c.parentElement.remove(),this.#i&&this.#i.remove(),this.#s&&this.#s.remove(),this.#t&&this.#t.remove(),this.#c=null,this.#i=null,this.#r=null,this.#t=null,this.#s=null,this.#e=[],this.#o=[],this.#h=new Map,this.#d=new Map}#u(){let i=this.getAttribute("title");if(i){let t=document.createElement("h2");t.className="gloss-title",t.textContent=i,this.#r=document.createElement("output"),this.#r.className="gloss-count",this.#r.textContent=String(this.#e.length),t.appendChild(this.#r),this.appendChild(t)}if(this.hasAttribute("searchable")){let t=document.createElement("div");t.className="gloss-search";let e=document.createElement("input");e.type="search",e.className="gloss-search-input",e.setAttribute("placeholder","Search terms\u2026"),e.setAttribute("aria-label","Search glossary terms"),t.appendChild(e),this.appendChild(t),this.#c=e,this.listen(e,"input",this.#f)}this.#p(),this.#s=document.createElement("div"),this.#s.className="gloss-categories",this.#s.setAttribute("role","region"),this.#s.setAttribute("aria-label","Glossary terms"),this.appendChild(this.#s);for(let t of this.#o){let e=this.#e.filter(r=>r.category===t);this.#m(t,e)}this.#t=document.createElement("div"),this.#t.className="gloss-live-region",this.#t.setAttribute("role","status"),this.#t.setAttribute("aria-live","polite"),this.#t.setAttribute("aria-atomic","true"),this.appendChild(this.#t)}#p(){this.#i=document.createElement("nav"),this.#i.className="gloss-jump-bar",this.#i.setAttribute("aria-label","Alphabet navigation");let i=new Set;for(let t of this.#e){let e=t.term.charAt(0).toUpperCase();/[A-Z]/.test(e)&&i.add(e)}for(let t=65;t<=90;t++){let e=String.fromCharCode(t),r=document.createElement("a");r.textContent=e,r.className="gloss-jump-letter",i.has(e)?(r.href=`#${this.#l}-letter-${e}`,r.setAttribute("data-active","")):(r.setAttribute("aria-disabled","true"),r.setAttribute("tabindex","-1")),this.#i.appendChild(r)}this.appendChild(this.#i)}#m(i,t){let e=document.createElement("section");e.className="gloss-category",e.setAttribute("data-category",i);let r=document.createElement("header");r.className="gloss-category-header";let s=document.createElement("button");s.type="button",s.className="gloss-category-toggle",s.setAttribute("aria-expanded","true"),s.innerHTML=`<span class="gloss-category-label">${m(i)}</span><output class="gloss-category-count">${t.length}</output><span class="gloss-chevron" aria-hidden="true"></span>`,r.appendChild(s),e.appendChild(r),this.#h.set(i,s);let o=document.createElement("dl");o.className="gloss-term-list";let d=[...t].sort((n,l)=>n.term.localeCompare(l.term)),c=[],h="";for(let n of d){let l=n.term.charAt(0).toUpperCase();if(/[A-Z]/.test(l)&&l!==h){h=l;let f=document.createElement("span");f.id=`${this.#l}-letter-${l}`,f.className="gloss-letter-anchor",o.appendChild(f)}n.el.className="gloss-term",n.el.id=n.id,o.appendChild(n.el),c.push(n.el)}this.#d.set(i,c),e.appendChild(o),this.#s.appendChild(e),this.listen(s,"click",()=>{let n=s.getAttribute("aria-expanded")==="true";s.setAttribute("aria-expanded",String(!n)),o.hidden=n})}#f=i=>{this.#a&&clearTimeout(this.#a),this.#a=setTimeout(()=>{let t=i.target.value.toLowerCase().trim();this.#g(t)},150)};#g(i){let t=0;for(let e of this.#e)i===""||e.term.toLowerCase().includes(i)||e.definition.toLowerCase().includes(i)?(e.el.removeAttribute("hidden"),t++):e.el.setAttribute("hidden","");for(let e of this.#o){let r=this.#d.get(e)||[],s=r[0]?.closest(".gloss-category");if(!s)continue;if(r.some(d=>!d.hasAttribute("hidden"))){s.removeAttribute("hidden");let d=r.filter(h=>!h.hasAttribute("hidden")).length,c=s.querySelector(".gloss-category-count");c&&(c.textContent=String(d))}else s.setAttribute("hidden","")}this.#r&&(this.#r.textContent=i===""?String(this.#e.length):`${t} / ${this.#e.length}`),i!==""&&this.#t&&(this.#t.textContent="",requestAnimationFrame(()=>{this.#t&&(this.#t.textContent=`${t} term${t!==1?"s":""} found`)})),this.dispatchEvent(new CustomEvent("glossary-wc:search",{bubbles:!0,detail:{query:i,matchCount:t}}))}attributeChangedCallback(i,t,e){t===e||!this.isConnected||i==="src"&&this._loadSrc(e)}async _loadSrc(i){if(i)try{let t=await fetch(i);if(!t.ok)throw new Error(`HTTP ${t.status}`);let e=await t.json();for(;this.firstChild;)this.firstChild.remove();let r=document.createElement("dl");for(let s of e.terms||[]){let o=document.createElement("div");o.setAttribute("data-term-id",s.id||""),o.setAttribute("data-category",s.category||"Uncategorized");let d=document.createElement("dt");d.textContent=s.term||"";let c=document.createElement("dd"),h=s.definition||"";if(s.seeAlso&&s.seeAlso.length>0){let n=s.seeAlso.map(l=>`<a href="#${m(l)}">${m(this.#b(l))}</a>`).join(", ");h+=` See also: ${n}.`}c.innerHTML=h,o.appendChild(d),o.appendChild(c),r.appendChild(o)}this.appendChild(r),e.title&&!this.getAttribute("title")&&this.setAttribute("title",e.title),this.teardown(),this.removeAttribute("data-upgraded"),this.setup()}catch(t){console.warn(`[glossary-wc] Failed to load src="${i}":`,t)}}#b(i){return i.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}};C("glossary-wc",g);export{g as GlossaryWc};
|
|
2
2
|
//# sourceMappingURL=glossary-wc.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var A=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function w(r,o,s={}){let t=s.priority??10,i={impl:o,bundle:s.bundle,contract:s.contract,priority:t},e=x.get(r);if(customElements.get(r)){if(!e||e.priority>=t){e&&e.priority===t&&e.impl!==o&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${e.bundle}" (priority ${e.priority}). Skipping "${s.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${e.bundle}" cannot be replaced (customElements.define is permanent). "${s.bundle}" has higher priority but arrived late.`);return}if(e&&e.priority>=t){e.priority===t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${e.bundle}". Skipping "${s.bundle}" (first wins at equal priority).`);return}x.set(r,i),customElements.define(r,o)}var u=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let o of this.#t)o();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(o,s,t,i){o.addEventListener(s,t,i),this.#t.push(()=>o.removeEventListener(s,t,i))}setup(){}teardown(){}};function
|
|
1
|
+
var A=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function w(r,o,s={}){let t=s.priority??10,i={impl:o,bundle:s.bundle,contract:s.contract,priority:t},e=x.get(r);if(customElements.get(r)){if(!e||e.priority>=t){e&&e.priority===t&&e.impl!==o&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${e.bundle}" (priority ${e.priority}). Skipping "${s.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${e.bundle}" cannot be replaced (customElements.define is permanent). "${s.bundle}" has higher priority but arrived late.`);return}if(e&&e.priority>=t){e.priority===t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${e.bundle}". Skipping "${s.bundle}" (first wins at equal priority).`);return}x.set(r,i),customElements.define(r,o)}var u=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let o of this.#t)o();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(o,s,t,i){o.addEventListener(s,t,i),this.#t.push(()=>o.removeEventListener(s,t,i))}setup(){}teardown(){}};function k(r,{type:o="linear",angle:s=90,interpolation:t="oklab"}={}){if(r.length<2)return"transparent";let e=[...r].sort((a,d)=>a.position-d.position).map(a=>`${a.color} ${a.position}%`).join(", "),n=t!=="srgb"?` in ${t}`:"";return o==="radial"?`radial-gradient(circle${n}, ${e})`:`linear-gradient(${s}deg${n}, ${e})`}function g(r){if(!r)return E();let o=r.split(",").map(s=>s.trim()).filter(Boolean);return o.length<2?E():o.map((s,t)=>({color:s,position:Math.round(t/(o.length-1)*100)}))}function E(){return[{color:"#6366f1",position:0},{color:"#ec4899",position:100}]}var m=class extends u{static observedAttributes=["colors","type","angle","interpolation","show-export","show-controls"];#t=[];#e="linear";#o=90;#s="oklab";setup(){this.#t=g(this.getAttribute("colors")),this.#e=this.getAttribute("type")||"linear",this.#o=Number(this.getAttribute("angle"))||90,this.#s=this.getAttribute("interpolation")||"oklab",this.#r()}attributeChangedCallback(o,s,t){s===t||!this.isConnected||(o==="colors"&&(this.#t=g(t)),o==="type"&&(this.#e=t||"linear"),o==="angle"&&(this.#o=Number(t)||90),o==="interpolation"&&(this.#s=t||"oklab"),this.#r())}get css(){return k(this.#t,{type:this.#e,angle:this.#o,interpolation:this.#s})}#r(){let o=this.hasAttribute("show-export"),s=this.getAttribute("show-controls")!=="false",t=this.css,i="var(--size-m, 1rem)",e="var(--size-s, 0.75rem)",n="var(--size-xs, 0.5rem)",a="var(--radius-m, 0.5rem)",d="var(--color-border, #ddd)",y="var(--color-surface, #fff)",h="var(--color-text-muted, #666)",f="var(--font-mono, monospace)",b="var(--font-size-sm, 0.875rem)",p="var(--font-size-xs, 0.75rem)",S=`<div class="gb-preview" style="height:4rem;border-radius:${a};background:${t};border:1px solid ${d}"></div>`,$=`font:inherit;font-size:${b};padding:0.25rem 0.5rem;border:1px solid ${d};border-radius:4px;background:${y}`,v="";s&&(v=`<div style="display:flex;flex-direction:column;gap:${e};font-size:${b}">
|
|
2
2
|
<div style="display:flex;flex-wrap:wrap;gap:${i};align-items:center">
|
|
3
3
|
<label style="display:flex;align-items:center;gap:${n}">
|
|
4
4
|
Type
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var d=window.matchMedia("(prefers-reduced-motion: reduce)");var a=new Map;function l(
|
|
1
|
+
var d=window.matchMedia("(prefers-reduced-motion: reduce)");var a=new Map;function l(r,t,e={}){let n=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:n},i=a.get(r);if(customElements.get(r)){if(!i||i.priority>=n){i&&i.priority===n&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=n){i.priority===n&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}a.set(r,o),customElements.define(r,t)}var s=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,o){t.addEventListener(e,n,o),this.#e.push(()=>t.removeEventListener(e,n,o))}setup(){}teardown(){}};var c=class extends s{#e;#t=new WeakSet;setup(){this.#n(),this.#e=new MutationObserver(t=>{for(let e of t)e.type==="childList"&&this.#n()}),this.#e.observe(this,{childList:!0,subtree:!0})}teardown(){this.#e?.disconnect()}#n(){let e=(this.getAttribute("levels")||"h2,h3").split(",").map(o=>o.trim()).join(","),n=this.querySelectorAll(e);for(let o of n)this.#t.has(o)||(this.#o(o),this.#t.add(o))}#o(t){if(t.closest("dialog, [data-toc-ignore]")||t.hasAttribute("data-toc-ignore")||(t.id||(t.id=this.#i(t.textContent)),t.querySelector(".heading-anchor")))return;let e=document.createElement("a");e.className="heading-anchor",e.href=`#${t.id}`,e.setAttribute("aria-label",`Link to ${t.textContent.trim()}`),e.innerHTML='<icon-wc name="link" size="sm"></icon-wc>',e.addEventListener("click",n=>{n.preventDefault(),this.#r(t,e)}),t.appendChild(e),t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1")}#i(t){let e=t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").substring(0,50),n=e,o=1;for(;document.getElementById(n);)n=`${e}-${o}`,o++;return n}async#r(t,e){let n=new URL(window.location.href);n.hash=t.id,window.history.pushState(null,"",n),t.scrollIntoView({behavior:"smooth",block:"start"}),t.focus();try{await navigator.clipboard.writeText(n.href);let o=e.innerHTML;e.innerHTML='<icon-wc name="check" size="sm"></icon-wc>',e.classList.add("copied"),setTimeout(()=>{e.innerHTML=o,e.classList.remove("copied")},1500),this.#s("Link copied to clipboard")}catch{}this.dispatchEvent(new CustomEvent("heading-links:navigate",{bubbles:!0,detail:{id:t.id,url:n.href}}))}#s(t){let e=document.createElement("div");e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.className="visually-hidden",e.textContent=t,this.appendChild(e),setTimeout(()=>e.remove(),1e3)}};l("heading-links",c);export{c as HeadingLinks};
|
|
2
2
|
//# sourceMappingURL=heading-links.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var C=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,i){t.addEventListener(e,n,i),this.#t.push(()=>t.removeEventListener(e,n,i))}setup(){}teardown(){}};var
|
|
2
|
-
`);v.replaceSync(t),document.adoptedStyleSheets=[...document.adoptedStyleSheets,v],w=1}function Q(){w--,w<=0&&v&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(o=>o!==v),v=null,w=0)}var d=null,x=null;function Z(){return d||(d=document.createElement("div"),d.className="hn-toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Highlight tools"),d.setAttribute("popover","auto"),d.hidden=!0,document.body.appendChild(d),d.addEventListener("toggle",o=>{o.newState==="closed"&&(d.hidden=!0,x=null)}),d)}function L(o,t,e){let n=Z();n.innerHTML="",x=t;let i=t.colors,s=t.element,r=e?.color,h=document.createElement("div");if(h.className="hn-swatches",h.setAttribute("role","group"),h.setAttribute("aria-label","Highlight colors"),i.forEach((a,l)=>{let c=document.createElement("button");c.type="button",c.className="hn-swatch",c.dataset.color=a,c.setAttribute("aria-label",`Highlight ${a}${r===a?" (current)":""}`),c.setAttribute("tabindex",l===0?"0":"-1");let f=W(s,a);f&&(c.style.backgroundColor=f),r===a&&c.setAttribute("aria-pressed","true"),c.addEventListener("click",()=>{e?t._changeColor(e.id,a):t._createFromSelection(a),E()}),h.appendChild(c)}),n.appendChild(h),e){let a=document.createElement("span");a.className="hn-separator",a.setAttribute("aria-hidden","true"),n.appendChild(a);let l=document.createElement("button");l.type="button",l.className="hn-action",l.textContent=e.note?"Edit Note":"Add Note",l.addEventListener("click",()=>{X(t,e),E()}),n.appendChild(l);let c=document.createElement("button");c.type="button",c.className="hn-action hn-action-remove",c.textContent="Remove",c.addEventListener("click",()=>{t.removeHighlight(e.id),E()}),n.appendChild(c)}h.addEventListener("keydown",a=>{let l=[...h.querySelectorAll("button")],c=l.indexOf(document.activeElement);if(c<0)return;let f=-1;if(a.key==="ArrowRight"||a.key==="ArrowDown")a.preventDefault(),f=(c+1)%l.length;else if(a.key==="ArrowLeft"||a.key==="ArrowUp")a.preventDefault(),f=(c-1+l.length)%l.length;else if(a.key==="Escape"){E();return}f>=0&&(l[c].setAttribute("tabindex","-1"),l[f].setAttribute("tabindex","0"),l[f].focus())}),n.hidden=!1;try{n.showPopover()}catch{}tt(o),requestAnimationFrame(()=>{let a=n.querySelector(".hn-swatch");a&&a.focus()})}var u=null;function X(o,t){y();let e=o.element,n=b(e,t.startOffset,t.endOffset);if(!n)return;u=document.createElement("div"),u.className="hn-note-panel",u.setAttribute("role","dialog"),u.setAttribute("aria-label","Private note");let i=document.createElement("header");i.className="hn-note-header",i.innerHTML="<small>PRIVATE NOTE</small>",u.appendChild(i);let s=document.createElement("blockquote");s.className="hn-note-quote",s.textContent=t.text.length>80?t.text.slice(0,80)+"\u2026":t.text,u.appendChild(s);let r=document.createElement("textarea");r.className="hn-note-textarea",r.placeholder="Add a note\u2026",r.value=t.note||"",r.rows=3,r.setAttribute("aria-label","Note for highlighted text"),u.appendChild(r);let h=document.createElement("footer");h.className="hn-note-actions";let a=document.createElement("button");a.type="button",a.className="hn-action hn-action-save",a.textContent="Save",a.addEventListener("click",()=>{o._updateNote(t.id,r.value.trim()),y()});let l=document.createElement("button");l.type="button",l.className="hn-action",l.textContent="Cancel",l.addEventListener("click",()=>y()),h.append(a,l),u.appendChild(h),r.addEventListener("keydown",m=>{m.key==="Escape"&&(m.preventDefault(),y()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),o._updateNote(t.id,r.value.trim()),y())}),e.style.position="relative",e.appendChild(u);let c=n.getClientRects()[0],f=e.getBoundingClientRect();if(c){let m=c.top-f.top;u.style.top=`${m}px`}requestAnimationFrame(()=>{r.focus(),document.addEventListener("pointerdown",K)})}function K(o){u&&!u.contains(o.target)&&y()}function y(){u&&(document.removeEventListener("pointerdown",K),u.remove(),u=null)}function tt(o){d&&requestAnimationFrame(()=>{let t=d.getBoundingClientRect(),e=t.width||200,n=t.height||40,i=o.top-n-D,s=o.left+o.width/2-e/2;i<O&&(i=o.bottom+D);let r=window.innerWidth-e-O;s=Math.max(O,Math.min(s,r)),d.style.top=`${i}px`,d.style.left=`${s}px`})}function E(){if(d){try{d.hidePopover()}catch{}d.hidden=!0,x=null}}var p=null;function R(o){p||(p=document.createElement("div"),p.setAttribute("aria-live","polite"),p.setAttribute("aria-atomic","true"),p.className="hn-sr-only",document.body.appendChild(p)),p.textContent="",requestAnimationFrame(()=>{p.textContent=o})}function V(o,t,e){let n=document.createTreeWalker(o,NodeFilter.SHOW_TEXT),i=0;for(;n.nextNode();){if(n.currentNode===t)return i+e;i+=(n.currentNode.textContent??"").length}return-1}function b(o,t,e){let n=document.createTreeWalker(o,NodeFilter.SHOW_TEXT),i=0,s=null,r=0,h=null,a=0;for(;n.nextNode();){let l=n.currentNode,c=(l.textContent??"").length;if(!s&&i+c>t&&(s=l,r=t-i),i+c>=e){h=l,a=e-i;break}i+=c}if(!s||!h)return null;try{let l=document.createRange();return l.setStart(s,Math.min(r,(s.textContent??"").length)),l.setEnd(h,Math.min(a,(h.textContent??"").length)),l}catch{return null}}var B=class{#t;#o;#i;#n;#e=[];#a=!J;#l;#c;#h=!1;#d=[];constructor(t){this.#t=t,this.#n=t.hasAttribute("data-highlights-readonly");let e=t.dataset.highlights;this.#o=e&&e!==""?e:location.pathname;let n=t.dataset.highlightsColors;this.#i=n?n.split(",").map(i=>i.trim()).filter(Boolean):[...j],this.#a||Y(this.#i),this.#r(),this.#n||(this.#l=this.#m.bind(this),this.#c=this.#p.bind(this),t.addEventListener("pointerup",this.#l),t.addEventListener("click",this.#c)),t.setAttribute("data-highlights-init",""),this.#y().then(()=>{this.#h||this.#r()})}get colors(){return[...this.#i]}get element(){return this.#t}getHighlights(){return this.#e.map(t=>({...t}))}removeHighlight(t){let e=this.#e.findIndex(n=>n.id===t);e<0||(this.#e.splice(e,1),this.#s(),this.#r(),this.#u("highlights:removed",{id:t}),R("Highlight removed"))}clearAll(){this.#e=[],this.#s(),this.#r()}exportHighlights(){return JSON.stringify({version:1,highlights:this.#e})}importHighlights(t){try{let e=typeof t=="string"?JSON.parse(t):t;if(!e.highlights||!Array.isArray(e.highlights))return;this.#e=e.highlights,this.#s(),this.#r()}catch{}}destroy(){if(!this.#h){if(this.#h=!0,this.#l&&this.#t.removeEventListener("pointerup",this.#l),this.#c&&this.#t.removeEventListener("click",this.#c),this.#a)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()});else{for(let t of this.#i)CSS.highlights.delete(`hn-${t}`);Q()}this.#f(),this.#t.removeAttribute("data-highlights-init"),x===this&&E(),y()}}#m(){requestAnimationFrame(()=>{if(this.#h||this.#t.hasAttribute("data-selection-menu"))return;let t=window.getSelection();if(!t||t.isCollapsed||!t.toString().trim())return;let e=t.getRangeAt(0);if(!this.#t.contains(e.commonAncestorContainer))return;let n=e.getBoundingClientRect();L(n,this,null)})}#p(t){if(this.#t.hasAttribute("data-selection-menu"))return;let e=t.target.closest?.(".hn-margin-annotation");if(e){let i=e.dataset.hnId,s=this.#e.find(r=>r.id===i);if(s){X(this,s);return}}let n=t.target.closest?.("mark[data-hn-id]");if(n){let i=n.dataset.hnId,s=this.#e.find(r=>r.id===i);if(s){this.#u("highlights:clicked",{id:i});let r=n.getBoundingClientRect();L(r,this,s);return}}if(!this.#a){let i=this.#b(t.clientX,t.clientY);if(i){this.#u("highlights:clicked",{id:i.id});let s=b(this.#t,i.startOffset,i.endOffset);s&&L(s.getBoundingClientRect(),this,i)}}}#b(t,e){for(let n of this.#e){let i=b(this.#t,n.startOffset,n.endOffset);if(!i)continue;let s=i.getClientRects();for(let r of s)if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom)return n}return null}_createFromSelection(t){let e=window.getSelection();if(!e||e.isCollapsed)return;let n=e.getRangeAt(0);if(!this.#t.contains(n.commonAncestorContainer))return;let i=V(this.#t,n.startContainer,n.startOffset),s=V(this.#t,n.endContainer,n.endOffset);if(i<0||s<0||i>=s)return;let r=e.toString().trim(),h={id:z(),startOffset:i,endOffset:s,text:r,color:t,note:"",created:Date.now()};this.#e.push(h),this.#s(),this.#r(),e.removeAllRanges(),this.#u("highlights:added",{id:h.id,text:r,color:t,note:""}),R("Highlight added")}_changeColor(t,e){let n=this.#e.find(i=>i.id===t);n&&(n.color=e,this.#s(),this.#r())}_updateNote(t,e){let n=this.#e.find(i=>i.id===t);n&&(n.note=e,this.#s(),this.#g(),this.#u("highlights:note-changed",{id:t,note:e}),R("Note saved"))}async#y(){let t=await k.get(q,this.#o);if(!t||!Array.isArray(t.highlights))return;let e=_(this.#t.textContent);t.contentHash&&t.contentHash!==e?(this.#e=t.highlights.filter(n=>{let i=b(this.#t,n.startOffset,n.endOffset);return i?i.toString().trim()===n.text:!1}),this.#s()):this.#e=t.highlights}#s(){let t={version:1,contentHash:_(this.#t.textContent),highlights:this.#e};k.set(q,this.#o,t).catch(()=>{})}#r(){this.#a?this.#A():this.#v(),this.#g()}#v(){let t=new Map;for(let e of this.#i)t.set(e,[]);for(let e of this.#e){let n=b(this.#t,e.startOffset,e.endOffset);n&&t.has(e.color)&&t.get(e.color).push(n)}for(let[e,n]of t){let i=`hn-${e}`;n.length===0?CSS.highlights.delete(i):CSS.highlights.set(i,new Highlight(...n))}}#A(){this.#t.querySelectorAll("mark[data-hn-id]").forEach(e=>{let n=e.parentNode;for(;e.firstChild;)n.insertBefore(e.firstChild,e);n.removeChild(e)}),this.#t.normalize();let t=[...this.#e].sort((e,n)=>n.startOffset-e.startOffset);for(let e of t){let n=b(this.#t,e.startOffset,e.endOffset);if(!n)continue;let i=W(this.#t,e.color),s=document.createElement("mark");s.dataset.hnId=e.id,s.dataset.hnColor=e.color,i&&(s.style.backgroundColor=i,s.style.textDecorationColor=i);try{n.surroundContents(s)}catch{let r=n.extractContents();s.appendChild(r),n.insertNode(s)}}}#f(){for(let t of this.#d)t.remove();this.#d=[]}#g(){if(this.#f(),this.#e.length===0)return;getComputedStyle(this.#t).position==="static"&&(this.#t.style.position="relative");for(let e of this.#e){let n=b(this.#t,e.startOffset,e.endOffset);if(!n)continue;let i=n.getClientRects();if(i.length===0)continue;let s=i[0],r=this.#t.getBoundingClientRect(),h=s.top-r.top,a=document.createElement("span");a.className="hn-margin-annotation",a.dataset.hnId=e.id,a.setAttribute("aria-hidden","true"),a.style.top=`${h}px`,e.note?(a.innerHTML='<span class="hn-note-indicator">*</span> You highlighted',a.classList.add("hn-has-note")):a.textContent="You highlighted",this.#t.appendChild(a),this.#d.push(a)}}#u(t,e={}){this.#t.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}},T=new WeakMap;function A(o){if(T.has(o))return T.get(o);let t=new B(o);return T.set(o,t),t}function U(o=document){o.querySelectorAll($).forEach(t=>{t.hasAttribute("data-highlights-init")||A(t)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>U()):U();var et=new MutationObserver(o=>{for(let t of o)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let n=e;n.matches($)&&A(n),n.querySelectorAll($).forEach(i=>{i.hasAttribute("data-highlights-init")||A(i)})}});et.observe(document.documentElement,{childList:!0,subtree:!0});var nt=["yellow","green","blue","pink"],H=class extends C{#t=null;#o="yellow";#i=!1;#n=null;setup(){this.#i=!!this.closest("selection-menu"),this.#i?this.#e():this.#c()}teardown(){this.#t?.destroy(),this.#t=null,this.#n?.remove(),this.#n=null}#e(){let t=this.#d(),e=document.createElement("button");e.type="button",e.setAttribute("aria-label","Highlight selection");let n=document.createElement("icon-wc");n.setAttribute("name","highlighter"),n.setAttribute("size","sm"),n.setAttribute("aria-hidden","true"),e.appendChild(n),e.addEventListener("click",i=>{i.stopPropagation(),this.#a()}),this.appendChild(e),this.#n=document.createElement("div"),this.#n.className="highlight-color-dropdown",this.#n.setAttribute("role","group"),this.#n.setAttribute("aria-label","Highlight color"),this.#n.hidden=!0,t.forEach(i=>{let s=document.createElement("button");s.type="button",s.className="highlight-color-swatch",s.dataset.color=i,s.setAttribute("aria-label",`${i}`),s.setAttribute("aria-pressed",i===this.#o?"true":"false"),s.style.backgroundColor=`var(--highlight-${i})`,s.addEventListener("click",r=>{r.stopPropagation(),this.#o=i,this.#n.querySelectorAll(".highlight-color-swatch").forEach(h=>h.setAttribute("aria-pressed",h.dataset.color===i?"true":"false")),this.#n.hidden=!0,this.#l()}),this.#n.appendChild(s)}),this.appendChild(this.#n)}#a(){this.#n&&(this.#n.hidden=!this.#n.hidden)}#l(){let t=this.closest("selection-menu");if(!t)return;let e=t.getSelection();if(!e)return;let n=e.target;if(n.hasAttribute("data-highlights-init"))this.#t||(this.#t=A(n));else{let i=this.getAttribute("storage-key")||"";n.setAttribute("data-highlights",i),this.hasAttribute("colors")&&n.setAttribute("data-highlights-colors",this.getAttribute("colors")),this.#t=A(n)}this.#t._createFromSelection(this.#o),t.dismiss()}#c(){let t=this.#h();if(!t)return!1;let e=this.getAttribute("storage-key")||"";t.setAttribute("data-highlights",e),this.hasAttribute("colors")&&t.setAttribute("data-highlights-colors",this.getAttribute("colors")),this.hasAttribute("readonly")&&t.setAttribute("data-highlights-readonly",""),this.#t=A(t)}#h(){let t=this.getAttribute("for");return t?document.getElementById(t):this.firstElementChild}#d(){let t=this.getAttribute("colors");return t?t.split(",").map(e=>e.trim()).filter(Boolean):[...nt]}getHighlights(){return this.#t?.getHighlights()??[]}removeHighlight(t){this.#t?.removeHighlight(t)}clearAll(){this.#t?.clearAll()}exportHighlights(){return this.#t?.exportHighlights()??'{"version":1,"highlights":[]}'}importHighlights(t){this.#t?.importHighlights(t)}};P("highlight-wc",H);
|
|
1
|
+
var C=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,i){t.addEventListener(e,n,i),this.#t.push(()=>t.removeEventListener(e,n,i))}setup(){}teardown(){}};var st=window.matchMedia("(prefers-reduced-motion: reduce)");var M=new Map;function P(s,t,e={}){let n=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:n},o=M.get(s);if(customElements.get(s)){if(!o||o.priority>=n){o&&o.priority===n&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=n){o.priority===n&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${o.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}M.set(s,i),customElements.define(s,t)}function G(){let s=globalThis.localStorage;if(!s)throw new Error("VBStore: localStorage is not available in this environment");return{async getRaw(t){return s.getItem(t)},async setRaw(t,e){s.setItem(t,e)},async removeRaw(t){s.removeItem(t)},async keys(t){let e=[];for(let n=0;n<s.length;n++){let i=s.key(n);i&&i.startsWith(t)&&e.push(i)}return e}}}var S=null;function g(){return S||(S=G()),S}function N(s,t){if(typeof s!="string"||!s)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:${s}:${t}`}function F(s){if(typeof s!="string"||!s)throw new TypeError("VBStore: namespace must be a non-empty string");return`vb:${s}:`}function I(s){try{let t=JSON.parse(s);if(t&&typeof t=="object"&&typeof t.timestamp=="number")return t}catch{}return null}var k={configure(s={}){S=s.backend??null},async set(s,t,e){let n={data:e,timestamp:Date.now()};await g().setRaw(N(s,t),JSON.stringify(n))},async get(s,t,e){let n=await g().getRaw(N(s,t));if(n==null)return null;let i=I(n);return!i||e?.maxAge!=null&&Date.now()-i.timestamp>e.maxAge?null:i.data},async remove(s,t){await g().removeRaw(N(s,t))},async list(s){let t=F(s),e=await g().keys(t),n=[];for(let i of e){let o=await g().getRaw(i);if(o==null)continue;let r=I(o);r&&n.push({key:i.slice(t.length),data:r.data,timestamp:r.timestamp})}return n},async clear(s){let t=F(s),e=await g().keys(t);for(let n of e)await g().removeRaw(n)},async clearAll(){let s=await g().keys("vb:");for(let t of s)await g().removeRaw(t)},async setMany(s,t){for(let[e,n]of t)await k.set(s,e,n)}};var $="[data-highlights]",q="highlights",j=["yellow","green","blue","pink"],D=8,O=8,J=typeof CSS<"u"&&"highlights"in CSS;function _(s){let t=2166136261;for(let e=0;e<s.length;e++)t^=s.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function z(){return"hn-"+crypto.randomUUID().slice(0,8)}function W(s,t){return getComputedStyle(s).getPropertyValue(`--highlight-${t}`).trim()}var v=null,w=0;function Y(s){if(v){w++;return}v=new CSSStyleSheet;let t=s.map(e=>`::highlight(hn-${e}) { background-color: var(--highlight-${e}); text-decoration-line: underline; text-decoration-color: var(--highlight-${e}); text-underline-offset: 2px; }`).join(`
|
|
2
|
+
`);v.replaceSync(t),document.adoptedStyleSheets=[...document.adoptedStyleSheets,v],w=1}function Q(){w--,w<=0&&v&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(s=>s!==v),v=null,w=0)}var d=null,x=null;function Z(){return d||(d=document.createElement("div"),d.className="hn-toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Highlight tools"),d.setAttribute("popover","auto"),d.hidden=!0,document.body.appendChild(d),d.addEventListener("toggle",s=>{s.newState==="closed"&&(d.hidden=!0,x=null)}),d)}function L(s,t,e){let n=Z();n.innerHTML="",x=t;let i=t.colors,o=t.element,r=e?.color,h=document.createElement("div");if(h.className="hn-swatches",h.setAttribute("role","group"),h.setAttribute("aria-label","Highlight colors"),i.forEach((a,l)=>{let c=document.createElement("button");c.type="button",c.className="hn-swatch",c.dataset.color=a,c.setAttribute("aria-label",`Highlight ${a}${r===a?" (current)":""}`),c.setAttribute("tabindex",l===0?"0":"-1");let f=W(o,a);f&&(c.style.backgroundColor=f),r===a&&c.setAttribute("aria-pressed","true"),c.addEventListener("click",()=>{e?t._changeColor(e.id,a):t._createFromSelection(a),A()}),h.appendChild(c)}),n.appendChild(h),e){let a=document.createElement("span");a.className="hn-separator",a.setAttribute("aria-hidden","true"),n.appendChild(a);let l=document.createElement("button");l.type="button",l.className="hn-action",l.textContent=e.note?"Edit Note":"Add Note",l.addEventListener("click",()=>{X(t,e),A()}),n.appendChild(l);let c=document.createElement("button");c.type="button",c.className="hn-action hn-action-remove",c.textContent="Remove",c.addEventListener("click",()=>{t.removeHighlight(e.id),A()}),n.appendChild(c)}h.addEventListener("keydown",a=>{let l=[...h.querySelectorAll("button")],c=l.indexOf(document.activeElement);if(c<0)return;let f=-1;if(a.key==="ArrowRight"||a.key==="ArrowDown")a.preventDefault(),f=(c+1)%l.length;else if(a.key==="ArrowLeft"||a.key==="ArrowUp")a.preventDefault(),f=(c-1+l.length)%l.length;else if(a.key==="Escape"){A();return}f>=0&&(l[c].setAttribute("tabindex","-1"),l[f].setAttribute("tabindex","0"),l[f].focus())}),n.hidden=!1;try{n.showPopover()}catch{}tt(s),requestAnimationFrame(()=>{let a=n.querySelector(".hn-swatch");a&&a.focus()})}var u=null;function X(s,t){y();let e=s.element,n=b(e,t.startOffset,t.endOffset);if(!n)return;u=document.createElement("div"),u.className="hn-note-panel",u.setAttribute("role","dialog"),u.setAttribute("aria-label","Private note");let i=document.createElement("header");i.className="hn-note-header",i.innerHTML="<small>PRIVATE NOTE</small>",u.appendChild(i);let o=document.createElement("blockquote");o.className="hn-note-quote",o.textContent=t.text.length>80?t.text.slice(0,80)+"\u2026":t.text,u.appendChild(o);let r=document.createElement("textarea");r.className="hn-note-textarea",r.placeholder="Add a note\u2026",r.value=t.note||"",r.rows=3,r.setAttribute("aria-label","Note for highlighted text"),u.appendChild(r);let h=document.createElement("footer");h.className="hn-note-actions";let a=document.createElement("button");a.type="button",a.className="hn-action hn-action-save",a.textContent="Save",a.addEventListener("click",()=>{s._updateNote(t.id,r.value.trim()),y()});let l=document.createElement("button");l.type="button",l.className="hn-action",l.textContent="Cancel",l.addEventListener("click",()=>y()),h.append(a,l),u.appendChild(h),r.addEventListener("keydown",m=>{m.key==="Escape"&&(m.preventDefault(),y()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),s._updateNote(t.id,r.value.trim()),y())}),e.style.position="relative",e.appendChild(u);let c=n.getClientRects()[0],f=e.getBoundingClientRect();if(c){let m=c.top-f.top;u.style.top=`${m}px`}requestAnimationFrame(()=>{r.focus(),document.addEventListener("pointerdown",K)})}function K(s){u&&!u.contains(s.target)&&y()}function y(){u&&(document.removeEventListener("pointerdown",K),u.remove(),u=null)}function tt(s){d&&requestAnimationFrame(()=>{let t=d.getBoundingClientRect(),e=t.width||200,n=t.height||40,i=s.top-n-D,o=s.left+s.width/2-e/2;i<O&&(i=s.bottom+D);let r=window.innerWidth-e-O;o=Math.max(O,Math.min(o,r)),d.style.top=`${i}px`,d.style.left=`${o}px`})}function A(){if(d){try{d.hidePopover()}catch{}d.hidden=!0,x=null}}var p=null;function R(s){p||(p=document.createElement("div"),p.setAttribute("aria-live","polite"),p.setAttribute("aria-atomic","true"),p.className="hn-sr-only",document.body.appendChild(p)),p.textContent="",requestAnimationFrame(()=>{p.textContent=s})}function V(s,t,e){let n=document.createTreeWalker(s,NodeFilter.SHOW_TEXT),i=0;for(;n.nextNode();){if(n.currentNode===t)return i+e;i+=(n.currentNode.textContent??"").length}return-1}function b(s,t,e){let n=document.createTreeWalker(s,NodeFilter.SHOW_TEXT),i=0,o=null,r=0,h=null,a=0;for(;n.nextNode();){let l=n.currentNode,c=(l.textContent??"").length;if(!o&&i+c>t&&(o=l,r=t-i),i+c>=e){h=l,a=e-i;break}i+=c}if(!o||!h)return null;try{let l=document.createRange();return l.setStart(o,Math.min(r,(o.textContent??"").length)),l.setEnd(h,Math.min(a,(h.textContent??"").length)),l}catch{return null}}var B=class{#t;#s;#i;#n;#e=[];#a=!J;#l;#c;#h=!1;#d=[];constructor(t){this.#t=t,this.#n=t.hasAttribute("data-highlights-readonly");let e=t.dataset.highlights;this.#s=e&&e!==""?e:location.pathname;let n=t.dataset.highlightsColors;this.#i=n?n.split(",").map(i=>i.trim()).filter(Boolean):[...j],this.#a||Y(this.#i),this.#r(),this.#n||(this.#l=this.#m.bind(this),this.#c=this.#p.bind(this),t.addEventListener("pointerup",this.#l),t.addEventListener("click",this.#c)),t.setAttribute("data-highlights-init",""),this.#y().then(()=>{this.#h||this.#r()})}get colors(){return[...this.#i]}get element(){return this.#t}getHighlights(){return this.#e.map(t=>({...t}))}removeHighlight(t){let e=this.#e.findIndex(n=>n.id===t);e<0||(this.#e.splice(e,1),this.#o(),this.#r(),this.#u("highlights:removed",{id:t}),R("Highlight removed"))}clearAll(){this.#e=[],this.#o(),this.#r()}exportHighlights(){return JSON.stringify({version:1,highlights:this.#e})}importHighlights(t){try{let e=typeof t=="string"?JSON.parse(t):t;if(!e.highlights||!Array.isArray(e.highlights))return;this.#e=e.highlights,this.#o(),this.#r()}catch{}}destroy(){if(!this.#h){if(this.#h=!0,this.#l&&this.#t.removeEventListener("pointerup",this.#l),this.#c&&this.#t.removeEventListener("click",this.#c),this.#a)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()});else{for(let t of this.#i)CSS.highlights.delete(`hn-${t}`);Q()}this.#f(),this.#t.removeAttribute("data-highlights-init"),x===this&&A(),y()}}#m(){requestAnimationFrame(()=>{if(this.#h||this.#t.hasAttribute("data-selection-menu"))return;let t=window.getSelection();if(!t||t.isCollapsed||!t.toString().trim())return;let e=t.getRangeAt(0);if(!this.#t.contains(e.commonAncestorContainer))return;let n=e.getBoundingClientRect();L(n,this,null)})}#p(t){if(this.#t.hasAttribute("data-selection-menu"))return;let e=t.target.closest?.(".hn-margin-annotation");if(e){let i=e.dataset.hnId,o=this.#e.find(r=>r.id===i);if(o){X(this,o);return}}let n=t.target.closest?.("mark[data-hn-id]");if(n){let i=n.dataset.hnId,o=this.#e.find(r=>r.id===i);if(o){this.#u("highlights:clicked",{id:i});let r=n.getBoundingClientRect();L(r,this,o);return}}if(!this.#a){let i=this.#b(t.clientX,t.clientY);if(i){this.#u("highlights:clicked",{id:i.id});let o=b(this.#t,i.startOffset,i.endOffset);o&&L(o.getBoundingClientRect(),this,i)}}}#b(t,e){for(let n of this.#e){let i=b(this.#t,n.startOffset,n.endOffset);if(!i)continue;let o=i.getClientRects();for(let r of o)if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom)return n}return null}_createFromSelection(t){let e=window.getSelection();if(!e||e.isCollapsed)return;let n=e.getRangeAt(0);if(!this.#t.contains(n.commonAncestorContainer))return;let i=V(this.#t,n.startContainer,n.startOffset),o=V(this.#t,n.endContainer,n.endOffset);if(i<0||o<0||i>=o)return;let r=e.toString().trim(),h={id:z(),startOffset:i,endOffset:o,text:r,color:t,note:"",created:Date.now()};this.#e.push(h),this.#o(),this.#r(),e.removeAllRanges(),this.#u("highlights:added",{id:h.id,text:r,color:t,note:""}),R("Highlight added")}_changeColor(t,e){let n=this.#e.find(i=>i.id===t);n&&(n.color=e,this.#o(),this.#r())}_updateNote(t,e){let n=this.#e.find(i=>i.id===t);n&&(n.note=e,this.#o(),this.#g(),this.#u("highlights:note-changed",{id:t,note:e}),R("Note saved"))}async#y(){let t=await k.get(q,this.#s);if(!t||!Array.isArray(t.highlights))return;let e=_(this.#t.textContent);t.contentHash&&t.contentHash!==e?(this.#e=t.highlights.filter(n=>{let i=b(this.#t,n.startOffset,n.endOffset);return i?i.toString().trim()===n.text:!1}),this.#o()):this.#e=t.highlights}#o(){let t={version:1,contentHash:_(this.#t.textContent),highlights:this.#e};k.set(q,this.#s,t).catch(()=>{})}#r(){this.#a?this.#E():this.#v(),this.#g()}#v(){let t=new Map;for(let e of this.#i)t.set(e,[]);for(let e of this.#e){let n=b(this.#t,e.startOffset,e.endOffset);n&&t.has(e.color)&&t.get(e.color).push(n)}for(let[e,n]of t){let i=`hn-${e}`;n.length===0?CSS.highlights.delete(i):CSS.highlights.set(i,new Highlight(...n))}}#E(){this.#t.querySelectorAll("mark[data-hn-id]").forEach(e=>{let n=e.parentNode;for(;e.firstChild;)n.insertBefore(e.firstChild,e);n.removeChild(e)}),this.#t.normalize();let t=[...this.#e].sort((e,n)=>n.startOffset-e.startOffset);for(let e of t){let n=b(this.#t,e.startOffset,e.endOffset);if(!n)continue;let i=W(this.#t,e.color),o=document.createElement("mark");o.dataset.hnId=e.id,o.dataset.hnColor=e.color,i&&(o.style.backgroundColor=i,o.style.textDecorationColor=i);try{n.surroundContents(o)}catch{let r=n.extractContents();o.appendChild(r),n.insertNode(o)}}}#f(){for(let t of this.#d)t.remove();this.#d=[]}#g(){if(this.#f(),this.#e.length===0)return;getComputedStyle(this.#t).position==="static"&&(this.#t.style.position="relative");for(let e of this.#e){let n=b(this.#t,e.startOffset,e.endOffset);if(!n)continue;let i=n.getClientRects();if(i.length===0)continue;let o=i[0],r=this.#t.getBoundingClientRect(),h=o.top-r.top,a=document.createElement("span");a.className="hn-margin-annotation",a.dataset.hnId=e.id,a.setAttribute("aria-hidden","true"),a.style.top=`${h}px`,e.note?(a.innerHTML='<span class="hn-note-indicator">*</span> You highlighted',a.classList.add("hn-has-note")):a.textContent="You highlighted",this.#t.appendChild(a),this.#d.push(a)}}#u(t,e={}){this.#t.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0}))}},T=new WeakMap;function E(s){if(T.has(s))return T.get(s);let t=new B(s);return T.set(s,t),t}function U(s=document){s.querySelectorAll($).forEach(t=>{t.hasAttribute("data-highlights-init")||E(t)})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>U()):U();var et=new MutationObserver(s=>{for(let t of s)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let n=e;n.matches($)&&E(n),n.querySelectorAll($).forEach(i=>{i.hasAttribute("data-highlights-init")||E(i)})}});et.observe(document.documentElement,{childList:!0,subtree:!0});var nt=["yellow","green","blue","pink"],H=class extends C{#t=null;#s="yellow";#i=!1;#n=null;setup(){this.#i=!!this.closest("selection-menu"),this.#i?this.#e():this.#c()}teardown(){this.#t?.destroy(),this.#t=null,this.#n?.remove(),this.#n=null}#e(){let t=this.#d(),e=document.createElement("button");e.type="button",e.setAttribute("aria-label","Highlight selection");let n=document.createElement("icon-wc");n.setAttribute("name","highlighter"),n.setAttribute("size","sm"),n.setAttribute("aria-hidden","true"),e.appendChild(n),e.addEventListener("click",i=>{i.stopPropagation(),this.#a()}),this.appendChild(e),this.#n=document.createElement("div"),this.#n.className="highlight-color-dropdown",this.#n.setAttribute("role","group"),this.#n.setAttribute("aria-label","Highlight color"),this.#n.hidden=!0,t.forEach(i=>{let o=document.createElement("button");o.type="button",o.className="highlight-color-swatch",o.dataset.color=i,o.setAttribute("aria-label",`${i}`),o.setAttribute("aria-pressed",i===this.#s?"true":"false"),o.style.backgroundColor=`var(--highlight-${i})`,o.addEventListener("click",r=>{r.stopPropagation(),this.#s=i,this.#n.querySelectorAll(".highlight-color-swatch").forEach(h=>h.setAttribute("aria-pressed",h.dataset.color===i?"true":"false")),this.#n.hidden=!0,this.#l()}),this.#n.appendChild(o)}),this.appendChild(this.#n)}#a(){this.#n&&(this.#n.hidden=!this.#n.hidden)}#l(){let t=this.closest("selection-menu");if(!t)return;let e=t.getSelection();if(!e)return;let n=e.target;if(n.hasAttribute("data-highlights-init"))this.#t||(this.#t=E(n));else{let i=this.getAttribute("storage-key")||"";n.setAttribute("data-highlights",i),this.hasAttribute("colors")&&n.setAttribute("data-highlights-colors",this.getAttribute("colors")),this.#t=E(n)}this.#t._createFromSelection(this.#s),t.dismiss()}#c(){let t=this.#h();if(!t)return!1;let e=this.getAttribute("storage-key")||"";t.setAttribute("data-highlights",e),this.hasAttribute("colors")&&t.setAttribute("data-highlights-colors",this.getAttribute("colors")),this.hasAttribute("readonly")&&t.setAttribute("data-highlights-readonly",""),this.#t=E(t)}#h(){let t=this.getAttribute("for");return t?document.getElementById(t):this.firstElementChild}#d(){let t=this.getAttribute("colors");return t?t.split(",").map(e=>e.trim()).filter(Boolean):[...nt]}getHighlights(){return this.#t?.getHighlights()??[]}removeHighlight(t){this.#t?.removeHighlight(t)}clearAll(){this.#t?.clearAll()}exportHighlights(){return this.#t?.exportHighlights()??'{"version":1,"highlights":[]}'}importHighlights(t){this.#t?.importHighlights(t)}};P("highlight-wc",H);
|
|
3
3
|
//# sourceMappingURL=highlight-wc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var C=Object.defineProperty;var q=(t,e)=>()=>(t&&(e=t(t=0)),e);var Y=(t,e)=>{for(var i in e)C(t,i,{get:e[i],enumerable:!0})};var $={};Y($,{addDialogDismiss:()=>N,addLongPress:()=>k,addPullToRefresh:()=>B,addSwipeListener:()=>T,haptic:()=>E,initGestures:()=>P,makeSwipeable:()=>S});function T(t,e={}){let i=e.threshold??50,s=e.restraint??100,r=e.timeout??300,n,f,c;function a(l){l.isPrimary&&(n=l.clientX,f=l.clientY,c=Date.now())}function p(l){if(!l.isPrimary)return;let d=l.clientX-n,o=l.clientY-f,m=Date.now()-c;if(m>r)return;let v=Math.abs(d),u=Math.abs(o),h;if(v>=i&&u<=s?h=d<0?"left":"right":u>=i&&v<=s&&(h=o<0?"up":"down"),h){let y=h==="left"||h==="right"?v:u;t.dispatchEvent(new CustomEvent(`swipe-${h}`,{bubbles:!0,detail:{distance:y,duration:m}}))}}return t.addEventListener("pointerdown",a,{passive:!0}),t.addEventListener("pointerup",p,{passive:!0}),()=>{t.removeEventListener("pointerdown",a),t.removeEventListener("pointerup",p)}}function S(t,e={}){let i=e.threshold??100,s=e.direction??"horizontal",r=e.removeOnDismiss??!0,n=s==="horizontal",f=0,c=0,a=!1;function p(u){!u.isPrimary||t.hasAttribute("data-dismissed")||(u.preventDefault(),a=!0,f=n?u.clientX:u.clientY,c=0,t.setPointerCapture(u.pointerId),t.setAttribute("data-swiping",""))}function l(u){if(!a||!u.isPrimary)return;c=(n?u.clientX:u.clientY)-f;let y=1-Math.min(Math.abs(c)/i,1)*.5;n?t.style.transform=`translateX(${c}px)`:t.style.transform=`translateY(${c}px)`,t.style.opacity=String(y)}function d(u){!a||!u.isPrimary||(a=!1,t.releasePointerCapture(u.pointerId),t.removeAttribute("data-swiping"),Math.abs(c)>=i?m(c>0?"right":"left"):v())}function o(u){!a||!u.isPrimary||(a=!1,t.releasePointerCapture(u.pointerId),t.removeAttribute("data-swiping"),v())}function m(u){let h=u==="right"?"100%":"-100%";t.style.transition="transform 0.2s ease-out, opacity 0.2s ease-out",t.style.transform=n?`translateX(${h})`:`translateY(${h})`,t.style.opacity="0",t.setAttribute("data-dismissed",""),E.dismiss(),t.dispatchEvent(new CustomEvent("swipe-dismiss",{bubbles:!0,detail:{direction:u,distance:Math.abs(c)}})),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",p),t.addEventListener("pointermove",l),t.addEventListener("pointerup",d),t.addEventListener("pointercancel",o),()=>{t.removeEventListener("pointerdown",p),t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",d),t.removeEventListener("pointercancel",o)}}function B(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 f=document.createElement("div");f.setAttribute("data-pull-spinner",""),n.appendChild(f),t.prepend(n);let c=0,a=!1,p=!1;function l(h){!h.isPrimary||p||t.scrollTop<=0&&(c=h.clientY,a=!0)}function d(h){if(!a||!h.isPrimary||p)return;let y=h.clientY-c;if(y<=0){n.style.transform="",n.style.opacity="";return}let L=Math.min(y,r),A=L/s;n.style.transform=`translateY(${L}px)`,n.style.opacity=String(Math.min(A,1)),A>=1?n.setAttribute("data-pull-ready",""):n.removeAttribute("data-pull-ready")}function o(h){!a||!h.isPrimary||(a=!1,n.hasAttribute("data-pull-ready")&&!p?v():u())}function m(h){!a||!h.isPrimary||(a=!1,u())}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 e()}finally{p=!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",l,{passive:!0}),t.addEventListener("pointermove",d,{passive:!0}),t.addEventListener("pointerup",o,{passive:!0}),t.addEventListener("pointercancel",m,{passive:!0}),()=>{t.removeEventListener("pointerdown",l),t.removeEventListener("pointermove",d),t.removeEventListener("pointerup",o),t.removeEventListener("pointercancel",m),n.remove()}}function k(t,e,i={}){let s=i.duration??500,r=i.hapticFeedback??!0,n=i.blockContextMenu??!0,f=null;function c(l){l.isPrimary&&(f=setTimeout(()=>{r&&E.tap(),e(l),f=null},s))}function a(){f&&(clearTimeout(f),f=null)}function p(l){n&&l.preventDefault()}return t.addEventListener("pointerdown",c,{passive:!0}),t.addEventListener("pointermove",a,{passive:!0}),t.addEventListener("pointerup",a,{passive:!0}),t.addEventListener("pointercancel",a,{passive:!0}),t.addEventListener("contextmenu",p),()=>{a(),t.removeEventListener("pointerdown",c),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",a),t.removeEventListener("pointercancel",a),t.removeEventListener("contextmenu",p)}}function N(t,e={}){let i=e.threshold??80,s=0,r=0,n=!1;function f(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 c(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 a(o){!n||!o.isPrimary||(n=!1,t.releasePointerCapture(o.pointerId),r>=i?l():d())}function p(o){!n||!o.isPrimary||(n=!1,t.releasePointerCapture(o.pointerId),d())}function l(){t.style.transition="transform 0.2s ease-out, opacity 0.2s ease-out",t.style.transform="translateY(100%)",t.style.opacity="0",E.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",f),t.addEventListener("pointermove",c),t.addEventListener("pointerup",a),t.addEventListener("pointercancel",p),()=>{t.removeEventListener("pointerdown",f),t.removeEventListener("pointermove",c),t.removeEventListener("pointerup",a),t.removeEventListener("pointercancel",p)}}function P(t=document){let e=[];for(let i of t.querySelectorAll('[data-gesture="swipe"]'))e.push(T(i));for(let i of t.querySelectorAll('[data-gesture="dismiss"]'))e.push(S(i));for(let i of t.querySelectorAll('[data-gesture="long-press"]'))e.push(k(i,()=>{i.dispatchEvent(new CustomEvent("long-press",{bubbles:!0}))}));for(let i of t.querySelectorAll('dialog[data-gesture="dismiss-down"]'))e.push(N(i));return()=>e.forEach(i=>i())}var E,D=q(()=>{E={tap:()=>navigator.vibrate?.(8),confirm:()=>navigator.vibrate?.([8,40,8]),error:()=>navigator.vibrate?.([30,60,30]),dismiss:()=>navigator.vibrate?.(15)};P()});var F=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function M(t,e,i={}){let s=i.priority??10,r={impl:e,bundle:i.bundle,contract:i.contract,priority:s},n=x.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}x.set(t,r),customElements.define(t,e)}var b=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}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))}setup(){}teardown(){}};function g(t){return document.startViewTransition?document.startViewTransition(t):t()}var H=0,w=class extends b{#t=[];#e=0;#n=null;#m=null;#i=null;#u=null;#d=null;#p=null;#a=null;#s=null;#c=null;#o="";#l=!1;setup(){if(this.#o=`gallery-lb-${++H}`,this.#l=!!document.startViewTransition,this.#v(),this.#t.length===0)return!1;this.listen(this,"click",this.#y)}teardown(){this.#c&&(this.#c(),this.#c=null),this.#n&&(this.#n.remove(),this.#n=null),this.#t=[]}open(e){if(e<0||e>=this.#t.length)return;this.#n||this.#b(),this.#h(e);let i=this.#t[e],s=this.getAttribute("transition")||"morph";if(this.#l&&s==="morph"){let r=`gallery-morph-${this.#o}`;i.thumbEl.style.viewTransitionName=r,g(()=>{i.thumbEl.style.viewTransitionName="";let n=this.#i.querySelector("img");n&&(n.style.viewTransitionName=r),this.#n.showModal()}).finished?.then(()=>{let n=this.#i.querySelector("img");n&&(n.style.viewTransitionName="")})}else this.#n.showModal();this.#f(e)}close(){if(!this.#n?.open)return;let e=this.#t[this.#e],i=this.getAttribute("transition")||"morph";if(this.#l&&i==="morph"){let s=`gallery-morph-${this.#o}`,r=this.#i.querySelector("img");r&&(r.style.viewTransitionName=s),g(()=>{r&&(r.style.viewTransitionName=""),e.thumbEl.style.viewTransitionName=s,this.#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)}#v(){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 i=e.target.closest("a[href]");if(!i||!this.contains(i))return;let s=i.querySelector("img"),r=this.#t.findIndex(n=>n.thumbEl===s);r!==-1&&(e.preventDefault(),this.open(r))};#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 f=this.getAttribute("captions")||"auto";s.append(n);let c=document.createElement("section");c.className="gallery-stage",this.#m=c;let a=document.createElement("button");a.type="button",a.className="gallery-prev",a.setAttribute("aria-label","Previous image"),a.innerHTML='<icon-wc name="chevron-left" size="sm"></icon-wc>',this.#d=a;let p=document.createElement("figure");p.className="gallery-frame",this.#i=p;let l=document.createElement("button");if(l.type="button",l.className="gallery-next",l.setAttribute("aria-label","Next image"),l.innerHTML='<icon-wc name="chevron-right" size="sm"></icon-wc>',this.#p=l,c.append(a,p,l),f==="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,c,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,c);this.append(e),this.#n=e,this.listen(a,"click",()=>this.prev()),this.listen(l,"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(()=>(D(),$)).then(({addSwipeListener:d})=>{this.#c=d(c,{threshold:40}),this.listen(c,"swipe-left",()=>this.next()),this.listen(c,"swipe-right",()=>this.prev())})}#h(e){let i=this.#t[e];this.#e=e;let s=document.createElement("img");s.src=i.href,s.alt=i.alt,this.#i.innerHTML="",this.#i.append(s);let r=this.getAttribute("captions")||"auto";if(r==="overlay"&&i.caption){let n=document.createElement("figcaption");n.innerHTML=i.caption,this.#i.append(n)}else if(r==="auto"){let n=this.#s?.parentElement;this.#s&&this.#a&&n&&(i.caption?(this.#s.innerHTML=i.caption,n.hidden=!1,this.#s.hidden=!0,this.#a.setAttribute("aria-expanded","false"),this.#a.setAttribute("aria-label","Show image details")):(this.#s.innerHTML="",n.hidden=!0))}this.#g()}#r(e){let i=this.getAttribute("transition")||"morph";this.#l&&i!=="none"?g(()=>{this.#h(e)}):this.#h(e),this.#f(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.#p&&(this.#p.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}};#f(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)}};M("image-gallery",w);export{w as ImageGallery};
|
|
1
|
+
var C=Object.defineProperty;var q=(t,e)=>()=>(t&&(e=t(t=0)),e);var Y=(t,e)=>{for(var i in e)C(t,i,{get:e[i],enumerable:!0})};var $={};Y($,{addDialogDismiss:()=>k,addLongPress:()=>N,addPullToRefresh:()=>B,addSwipeListener:()=>T,haptic:()=>g,initGestures:()=>P,makeSwipeable:()=>S});function T(t,e={}){let i=e.threshold??50,s=e.restraint??100,r=e.timeout??300,n,f,c;function a(l){l.isPrimary&&(n=l.clientX,f=l.clientY,c=Date.now())}function h(l){if(!l.isPrimary)return;let d=l.clientX-n,o=l.clientY-f,m=Date.now()-c;if(m>r)return;let v=Math.abs(d),u=Math.abs(o),p;if(v>=i&&u<=s?p=d<0?"left":"right":u>=i&&v<=s&&(p=o<0?"up":"down"),p){let y=p==="left"||p==="right"?v:u;t.dispatchEvent(new CustomEvent(`swipe-${p}`,{bubbles:!0,detail:{distance:y,duration:m}}))}}return t.addEventListener("pointerdown",a,{passive:!0}),t.addEventListener("pointerup",h,{passive:!0}),()=>{t.removeEventListener("pointerdown",a),t.removeEventListener("pointerup",h)}}function S(t,e={}){let i=e.threshold??100,s=e.direction??"horizontal",r=e.removeOnDismiss??!0,n=s==="horizontal",f=0,c=0,a=!1;function h(u){!u.isPrimary||t.hasAttribute("data-dismissed")||(u.preventDefault(),a=!0,f=n?u.clientX:u.clientY,c=0,t.setPointerCapture(u.pointerId),t.setAttribute("data-swiping",""))}function l(u){if(!a||!u.isPrimary)return;c=(n?u.clientX:u.clientY)-f;let y=1-Math.min(Math.abs(c)/i,1)*.5;n?t.style.transform=`translateX(${c}px)`:t.style.transform=`translateY(${c}px)`,t.style.opacity=String(y)}function d(u){!a||!u.isPrimary||(a=!1,t.releasePointerCapture(u.pointerId),t.removeAttribute("data-swiping"),Math.abs(c)>=i?m(c>0?"right":"left"):v())}function o(u){!a||!u.isPrimary||(a=!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",""),g.dismiss(),t.dispatchEvent(new CustomEvent("swipe-dismiss",{bubbles:!0,detail:{direction:u,distance:Math.abs(c)}})),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",h),t.addEventListener("pointermove",l),t.addEventListener("pointerup",d),t.addEventListener("pointercancel",o),()=>{t.removeEventListener("pointerdown",h),t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",d),t.removeEventListener("pointercancel",o)}}function B(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 f=document.createElement("div");f.setAttribute("data-pull-spinner",""),n.appendChild(f),t.prepend(n);let c=0,a=!1,h=!1;function l(p){!p.isPrimary||h||t.scrollTop<=0&&(c=p.clientY,a=!0)}function d(p){if(!a||!p.isPrimary||h)return;let y=p.clientY-c;if(y<=0){n.style.transform="",n.style.opacity="";return}let L=Math.min(y,r),A=L/s;n.style.transform=`translateY(${L}px)`,n.style.opacity=String(Math.min(A,1)),A>=1?n.setAttribute("data-pull-ready",""):n.removeAttribute("data-pull-ready")}function o(p){!a||!p.isPrimary||(a=!1,n.hasAttribute("data-pull-ready")&&!h?v():u())}function m(p){!a||!p.isPrimary||(a=!1,u())}async function v(){h=!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{h=!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",l,{passive:!0}),t.addEventListener("pointermove",d,{passive:!0}),t.addEventListener("pointerup",o,{passive:!0}),t.addEventListener("pointercancel",m,{passive:!0}),()=>{t.removeEventListener("pointerdown",l),t.removeEventListener("pointermove",d),t.removeEventListener("pointerup",o),t.removeEventListener("pointercancel",m),n.remove()}}function N(t,e,i={}){let s=i.duration??500,r=i.hapticFeedback??!0,n=i.blockContextMenu??!0,f=null;function c(l){l.isPrimary&&(f=setTimeout(()=>{r&&g.tap(),e(l),f=null},s))}function a(){f&&(clearTimeout(f),f=null)}function h(l){n&&l.preventDefault()}return t.addEventListener("pointerdown",c,{passive:!0}),t.addEventListener("pointermove",a,{passive:!0}),t.addEventListener("pointerup",a,{passive:!0}),t.addEventListener("pointercancel",a,{passive:!0}),t.addEventListener("contextmenu",h),()=>{a(),t.removeEventListener("pointerdown",c),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",a),t.removeEventListener("pointercancel",a),t.removeEventListener("contextmenu",h)}}function k(t,e={}){let i=e.threshold??80,s=0,r=0,n=!1;function f(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 c(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 a(o){!n||!o.isPrimary||(n=!1,t.releasePointerCapture(o.pointerId),r>=i?l():d())}function h(o){!n||!o.isPrimary||(n=!1,t.releasePointerCapture(o.pointerId),d())}function l(){t.style.transition="transform 0.2s ease-out, opacity 0.2s ease-out",t.style.transform="translateY(100%)",t.style.opacity="0",g.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",f),t.addEventListener("pointermove",c),t.addEventListener("pointerup",a),t.addEventListener("pointercancel",h),()=>{t.removeEventListener("pointerdown",f),t.removeEventListener("pointermove",c),t.removeEventListener("pointerup",a),t.removeEventListener("pointercancel",h)}}function P(t=document){let e=[];for(let i of t.querySelectorAll('[data-gesture="swipe"]'))e.push(T(i));for(let i of t.querySelectorAll('[data-gesture="dismiss"]'))e.push(S(i));for(let i of t.querySelectorAll('[data-gesture="long-press"]'))e.push(N(i,()=>{i.dispatchEvent(new CustomEvent("long-press",{bubbles:!0}))}));for(let i of t.querySelectorAll('dialog[data-gesture="dismiss-down"]'))e.push(k(i));return()=>e.forEach(i=>i())}var g,D=q(()=>{g={tap:()=>navigator.vibrate?.(8),confirm:()=>navigator.vibrate?.([8,40,8]),error:()=>navigator.vibrate?.([30,60,30]),dismiss:()=>navigator.vibrate?.(15)};P()});var F=window.matchMedia("(prefers-reduced-motion: reduce)");var x=new Map;function M(t,e,i={}){let s=i.priority??10,r={impl:e,bundle:i.bundle,contract:i.contract,priority:s},n=x.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}x.set(t,r),customElements.define(t,e)}var b=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),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))}setup(){}teardown(){}};function E(t){return document.startViewTransition?document.startViewTransition(t):t()}var H=0,w=class extends b{#t=[];#e=0;#n=null;#m=null;#i=null;#u=null;#d=null;#h=null;#a=null;#s=null;#c=null;#o="";#l=!1;setup(){if(this.#o=`gallery-lb-${++H}`,this.#l=!!document.startViewTransition,this.#v(),this.#t.length===0)return!1;this.listen(this,"click",this.#y)}teardown(){this.#c&&(this.#c(),this.#c=null),this.#n&&(this.#n.remove(),this.#n=null),this.#t=[]}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"){let r=`gallery-morph-${this.#o}`;i.thumbEl.style.viewTransitionName=r,E(()=>{i.thumbEl.style.viewTransitionName="";let n=this.#i.querySelector("img");n&&(n.style.viewTransitionName=r),this.#n.showModal()}).finished?.then(()=>{let n=this.#i.querySelector("img");n&&(n.style.viewTransitionName="")})}else this.#n.showModal();this.#f(e)}close(){if(!this.#n?.open)return;let e=this.#t[this.#e],i=this.getAttribute("transition")||"morph";if(this.#l&&i==="morph"){let s=`gallery-morph-${this.#o}`,r=this.#i.querySelector("img");r&&(r.style.viewTransitionName=s),E(()=>{r&&(r.style.viewTransitionName=""),e.thumbEl.style.viewTransitionName=s,this.#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)}#v(){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 i=e.target.closest("a[href]");if(!i||!this.contains(i))return;let s=i.querySelector("img"),r=this.#t.findIndex(n=>n.thumbEl===s);r!==-1&&(e.preventDefault(),this.open(r))};#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 f=this.getAttribute("captions")||"auto";s.append(n);let c=document.createElement("section");c.className="gallery-stage",this.#m=c;let a=document.createElement("button");a.type="button",a.className="gallery-prev",a.setAttribute("aria-label","Previous image"),a.innerHTML='<icon-wc name="chevron-left" size="sm"></icon-wc>',this.#d=a;let h=document.createElement("figure");h.className="gallery-frame",this.#i=h;let l=document.createElement("button");if(l.type="button",l.className="gallery-next",l.setAttribute("aria-label","Next image"),l.innerHTML='<icon-wc name="chevron-right" size="sm"></icon-wc>',this.#h=l,c.append(a,h,l),f==="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,c,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,c);this.append(e),this.#n=e,this.listen(a,"click",()=>this.prev()),this.listen(l,"click",()=>this.next()),this.listen(e,"keydown",this.#g),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(()=>(D(),$)).then(({addSwipeListener:d})=>{this.#c=d(c,{threshold:40}),this.listen(c,"swipe-left",()=>this.next()),this.listen(c,"swipe-right",()=>this.prev())})}#p(e){let i=this.#t[e];this.#e=e;let s=document.createElement("img");s.src=i.href,s.alt=i.alt,this.#i.innerHTML="",this.#i.append(s);let r=this.getAttribute("captions")||"auto";if(r==="overlay"&&i.caption){let n=document.createElement("figcaption");n.innerHTML=i.caption,this.#i.append(n)}else if(r==="auto"){let n=this.#s?.parentElement;this.#s&&this.#a&&n&&(i.caption?(this.#s.innerHTML=i.caption,n.hidden=!1,this.#s.hidden=!0,this.#a.setAttribute("aria-expanded","false"),this.#a.setAttribute("aria-label","Show image details")):(this.#s.innerHTML="",n.hidden=!0))}this.#E()}#r(e){let i=this.getAttribute("transition")||"morph";this.#l&&i!=="none"?E(()=>{this.#p(e)}):this.#p(e),this.#f(e)}#E(){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}`)}#g=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}};#f(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)}};M("image-gallery",w);export{w 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(
|
|
1
|
+
var S=window.matchMedia("(prefers-reduced-motion: reduce)");var y=new Map;function b(s,i,e={}){let t=e.priority??10,r={impl:i,bundle:e.bundle,contract:e.contract,priority:t},n=y.get(s);if(customElements.get(s)){if(!n||n.priority>=t){n&&n.priority===t&&n.impl!==i&&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>=t){n.priority===t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}y.set(s,r),customElements.define(s,i)}var f=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let i of this.#e)i();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(i,e,t,r){i.addEventListener(e,t,r),this.#e.push(()=>i.removeEventListener(e,t,r))}setup(){}teardown(){}};var p="http://www.w3.org/2000/svg";function v(s){return s.trim().split(/[\s,]+/).map(Number)}function A(s,i){let e=v(i);switch(s){case"rect":{let[t,r,n,c]=e;return{type:"rect",x:t,y:r,width:n-t,height:c-r}}case"circle":{let[t,r,n]=e;return{type:"circle",cx:t,cy:r,r:n}}case"poly":{let t=[];for(let r=0;r<e.length;r+=2)t.push([e[r],e[r+1]]);return{type:"poly",points:t}}default:return null}}function x(s){if(!s)return null;switch(s.type){case"rect":{let i=document.createElementNS(p,"rect");return i.setAttribute("x",String(s.x)),i.setAttribute("y",String(s.y)),i.setAttribute("width",String(s.width)),i.setAttribute("height",String(s.height)),i}case"circle":{let i=document.createElementNS(p,"circle");return i.setAttribute("cx",String(s.cx)),i.setAttribute("cy",String(s.cy)),i.setAttribute("r",String(s.r)),i}case"poly":{let i=document.createElementNS(p,"polygon");return i.setAttribute("points",s.points.map(e=>e.join(",")).join(" ")),i}default:return null}}function E(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 i=100,e=100,t=0,r=0;for(let[n,c]of s.points)n<i&&(i=n),c<e&&(e=c),n>t&&(t=n),c>r&&(r=c);return{x:i,y:e,width:t-i,height:r-e}}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{#e=null;#i=null;#t=null;#n=[];#c=[];#s=null;#h=null;#o=null;setup(){if(this.#e=this.querySelector(":scope > img"),!this.#e){let i=this.getAttribute("src"),e=this.getAttribute("alt");if(i)this.#e=document.createElement("img"),this.#e.src=i,this.#e.alt=e||"",this.prepend(this.#e);else return!1}this.#e.classList.add("image-map-img"),this.#e.complete?this.#u():this.#e.addEventListener("load",()=>this.#u(),{once:!0})}teardown(){this.#h?.disconnect(),this.#r(),this.#i?.remove(),this.#t?.remove();for(let i of this.#c)i.anchor?.remove();this.#c=[],this.#n=[]}#u(){let i=[...this.querySelectorAll(":scope > map-area")];if(i.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.#t=document.createElement("div"),this.#t.className="image-map-tooltip",this.#t.setAttribute("role","tooltip"),this.#t.setAttribute("aria-live","polite"),this.#t.id=`imap-tip-${crypto.randomUUID().slice(0,8)}`;for(let e of i){let t=e,r=t.shape,n=t.coords,c=A(r,n),a=x(c);if(!a)continue;let h=E(c),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.#t.id),o.textContent=t.label,o.style.left=`${h.x}%`,o.style.top=`${h.y}%`,o.style.width=`${h.width}%`,o.style.height=`${h.height}%`,t.disabled&&(a.setAttribute("data-disabled",""),o.setAttribute("tabindex","-1"),o.setAttribute("aria-disabled","true"));let d=e.innerHTML,l={area:e,parsed:c,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.#r(),a.removeAttribute("data-hover"),this.#l("image-map:area-leave",t)}),this.listen(a,"click",()=>{u==="click"&&(this.#s===l?this.#r():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",w=>{u==="hover"&&(this.#o!==l?(w.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.#r(),a.removeAttribute("data-hover")})}this.#i.appendChild(a),this.#c.push(l),this.#n.push(o)}this.appendChild(this.#i);for(let e of this.#n)this.appendChild(e);this.appendChild(this.#t),this.listen(this,"keydown",this.#f),this.#h=new ResizeObserver(()=>{this.#s&&this.#d(this.#s.svgShape)}),this.#h.observe(this.#e),this.setAttribute("role","group"),this.hasAttribute("aria-label")||this.setAttribute("aria-label",this.#e.alt||"Image map"),this.setAttribute("data-upgraded","")}#a(i){this.#t&&(this.#s=i,this.#t.innerHTML=i.contentHTML,this.#t.setAttribute("data-visible",""),this.#d(i.svgShape))}#r(){this.#t&&(this.#s=null,this.#t.removeAttribute("data-visible"))}#d(i){if(!this.#t||!i)return;let e=i.getBoundingClientRect(),t=this.#t.getBoundingClientRect(),r=8,n=8,c=window.innerWidth,a=window.innerHeight,h,o,d=e.top-t.height-r;d>=n?(h=d,o=e.left+(e.width-t.width)/2):e.bottom+r+t.height<=a-n?(h=e.bottom+r,o=e.left+(e.width-t.width)/2):e.right+r+t.width<=c-n?(h=e.top+(e.height-t.height)/2,o=e.right+r):(h=e.top+(e.height-t.height)/2,o=e.left-t.width-r),o=Math.max(n,Math.min(o,c-t.width-n)),h=Math.max(n,Math.min(h,a-t.height-n)),this.#t.style.top=`${h}px`,this.#t.style.left=`${o}px`}#f=i=>{let e=this.#n.filter(r=>!r.hasAttribute("aria-disabled")),t=e.indexOf(document.activeElement);switch(i.key){case"ArrowDown":case"ArrowRight":{i.preventDefault();let r=t<e.length-1?t+1:0;e[r]?.focus();break}case"ArrowUp":case"ArrowLeft":{i.preventDefault();let r=t>0?t-1:e.length-1;e[r]?.focus();break}case"Escape":this.#r(),this.#o=null;break}};#l(i,e){this.dispatchEvent(new CustomEvent(i,{detail:{area:e},bubbles:!0}))}};b("map-area",m);b("image-map",g);export{g as ImageMapWc,m as MapAreaWc};
|
|
2
2
|
//# sourceMappingURL=image-map.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var w=window.matchMedia("(prefers-reduced-motion: reduce)");var A=new Map;function E(a,i,e={}){let r=e.priority??10,t={impl:i,bundle:e.bundle,contract:e.contract,priority:r},s=A.get(a);if(customElements.get(a)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==i&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> 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 <${a}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}A.set(a,t),customElements.define(a,i)}var
|
|
1
|
+
var w=window.matchMedia("(prefers-reduced-motion: reduce)");var A=new Map;function E(a,i,e={}){let r=e.priority??10,t={impl:i,bundle:e.bundle,contract:e.contract,priority:r},s=A.get(a);if(customElements.get(a)){if(!s||s.priority>=r){s&&s.priority===r&&s.impl!==i&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> 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 <${a}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}A.set(a,t),customElements.define(a,i)}var h=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let i of this.#e)i();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(i,e,r,t){i.addEventListener(e,r,t),this.#e.push(()=>i.removeEventListener(e,r,t))}setup(){}teardown(){}};var b=class a extends h{static QUADRANTS=["quick-wins","big-bets","fill-ins","money-pit"];static LABELS={"quick-wins":"Quick Wins","big-bets":"Big Bets","fill-ins":"Fill-Ins","money-pit":"Money Pit"};static DESCRIPTIONS={"quick-wins":"High impact \xB7 Low effort","big-bets":"High impact \xB7 High effort","fill-ins":"Low impact \xB7 Low effort","money-pit":"Low impact \xB7 High effort"};static#e=0;static get observedAttributes(){return["src","compact","title"]}#s=null;#t={};#i=null;#n="";#r=null;setup(){this.#n=`ie-${++a.#e}`;let i=[...this.querySelectorAll(":scope > [data-quadrant], :scope > [draggable]")],e=document.createElement("div");e.className="ie-wrapper";let r=document.createElement("div");r.className="ie-y-label",r.setAttribute("aria-hidden","true"),r.textContent="Impact \u2191";let t=document.createElement("div");t.style.cssText="display:flex;flex-direction:column;flex:1;min-width:0;";let s=document.createElement("div");s.className="ie-grid",s.setAttribute("role","region"),s.setAttribute("aria-label","Impact-Effort prioritization matrix");let u=document.createElement("div");u.className="ie-x-label",u.setAttribute("aria-hidden","true"),u.textContent="Effort \u2192";for(let n of a.QUADRANTS){let c=document.createElement("section");c.className="ie-quadrant",c.dataset.quadrantZone=n,c.setAttribute("aria-label",`${a.LABELS[n]}: ${a.DESCRIPTIONS[n]}`);let f=document.createElement("header");f.className="ie-quadrant-label",f.innerHTML=`${a.LABELS[n]}<br><span class="ie-quadrant-desc">${a.DESCRIPTIONS[n]}</span>`;let d=document.createElement("drag-surface");d.setAttribute("group",this.#n),d.setAttribute("aria-label",a.LABELS[n]),d.setAttribute("data-layout","stack"),d.setAttribute("data-layout-gap","xs"),c.appendChild(f),c.appendChild(d),s.appendChild(c),this.#t[n]=d}i.forEach((n,c)=>{let f=n.getAttribute("data-quadrant")||"quick-wins",d=this.#t[f]||this.#t["quick-wins"];n.hasAttribute("draggable")||n.setAttribute("draggable","true"),n.hasAttribute("data-id")||(n.dataset.id=`ie-item-${c}`),d.appendChild(n)});let l=document.createElement("div");l.className="ie-live-region",l.setAttribute("role","status"),l.setAttribute("aria-live","polite"),l.setAttribute("aria-atomic","true");let o=this.getAttribute("title");if(o){let n=document.createElement("h3");n.className="ie-title",n.textContent=o,this.prepend(n)}t.appendChild(s),t.appendChild(u),e.appendChild(r),e.appendChild(t),this.appendChild(e),this.appendChild(l),this.#s=s,this.#i=l,this.#r=e,this.listen(this,"drag-surface:transfer",n=>{let{item:c,fromSurface:f,toSurface:d}=n.detail,g=this.#o(f),m=this.#o(d);!g||!m||(c.setAttribute("data-quadrant",m),this.#d(`Moved ${this.#u(c)} to ${a.LABELS[m]}`),this.dispatchEvent(new CustomEvent("impact-effort:move",{bubbles:!0,detail:{itemId:c.dataset.id,from:g,to:m,item:c}})))});let p=this.getAttribute("src");p&&this.#a(p),this.#c()}teardown(){this.#r&&(this.#r.remove(),this.#r=null),this.#i&&(this.#i.remove(),this.#i=null),this.#s=null,this.#t={}}attributeChangedCallback(i,e,r){this.hasAttribute("data-upgraded")&&i==="src"&&r&&r!==e&&this.#a(r)}async#a(i){try{let e=await fetch(i);if(!e.ok)throw new Error(`HTTP ${e.status}`);let r=await e.json();if(!Array.isArray(r))return;for(let t of a.QUADRANTS){let s=this.#t[t];if(s)for(let u of[...s.querySelectorAll("[draggable]")])u.remove()}r.forEach((t,s)=>{let u=t.quadrant||"quick-wins",l=t.id||`ie-item-${s}`,o;t.persona||t.action||t.storyId?(o=document.createElement("user-story"),o.setAttribute("detail","minimal"),t.storyId&&o.setAttribute("story-id",t.storyId),t.persona&&o.setAttribute("persona",t.persona),t.action&&o.setAttribute("action",t.action),t.benefit&&o.setAttribute("benefit",t.benefit),t.priority&&o.setAttribute("priority",t.priority),t.status&&o.setAttribute("status",t.status),t.points&&o.setAttribute("points",String(t.points))):(o=document.createElement("article"),o.textContent=t.label||t.text||""),o.setAttribute("draggable","true"),o.dataset.id=l,o.dataset.quadrant=u,(this.#t[u]||this.#t["quick-wins"]).appendChild(o)}),this.#c()}catch(e){console.warn(`[impact-effort] Failed to load src="${i}":`,e)}}#o(i){for(let[e,r]of Object.entries(this.#t))if(r===i)return e;return null}#d(i){let e=this.#i;e&&(e.textContent="",requestAnimationFrame(()=>{e.textContent=i}))}#u(i){return i.dataset.id||i.textContent.trim().slice(0,40)}#c(){let i={};for(let e of a.QUADRANTS){let r=this.#t[e];i[e]=r?r.querySelectorAll('[draggable="true"]').length:0}this.dispatchEvent(new CustomEvent("impact-effort:ready",{bubbles:!0,detail:{quadrantCounts:i}}))}};E("impact-effort",b);export{b as ImpactEffort};
|
|
2
2
|
//# sourceMappingURL=impact-effort.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var h=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function u(s,e,t={}){let r=t.priority??10,n={impl:e,bundle:t.bundle,contract:t.contract,priority:r},i=l.get(s);if(customElements.get(s)){if(!i||i.priority>=r){i&&i.priority===r&&i.impl!==e&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=r){i.priority===r&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${i.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}l.set(s,n),customElements.define(s,e)}var o=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,r,n){e.addEventListener(t,r,n),this.#e.push(()=>e.removeEventListener(t,r,n))}setup(){}teardown(){}};var a=class extends o{#e;#t;#r=null;#s=!1;setup(){if(this.#s)return;let e=this.getAttribute("src");if(!e)return!1;this.#r===null&&(this.#r=this.innerHTML),this.hasAttribute("lazy")?this.#n():this.#i(e)}teardown(){this.#e?.disconnect(),this.#t?.abort()}static get observedAttributes(){return["src"]}attributeChangedCallback(e,t,r){e==="src"&&r&&t!==r&&this.isConnected&&(this.hasAttribute("lazy")&&!this.#o()?this.#n():this.#i(r))}#o(){let e=this.getBoundingClientRect();return e.top<window.innerHeight+200&&e.bottom>-200}#n(){this.#e?.disconnect(),this.#e=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){this.#e.disconnect();let r=this.getAttribute("src");r&&this.#i(r)}},{rootMargin:"200px"}),this.#e.observe(this)}async#i(e){this.#t?.abort(),this.#t=new AbortController,this.setAttribute("data-loading",""),this.removeAttribute("data-loaded"),this.removeAttribute("data-error");try{let t=await fetch(e,{signal:this.#t.signal});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let r=await t.text(),n=this.getAttribute("mode")||"replace";n==="replace"?this.innerHTML=r:n==="append"?this.insertAdjacentHTML("beforeend",r):n==="prepend"&&this.insertAdjacentHTML("afterbegin",r),this.hasAttribute("allow-scripts")?this.querySelectorAll("script").forEach(i=>{let c=document.createElement("script");for(let d of i.attributes)c.setAttribute(d.name,d.value);c.textContent=i.textContent,i.replaceWith(c)}):this.querySelectorAll("script").forEach(i=>i.remove()),this.removeAttribute("data-loading"),this.setAttribute("data-loaded",""),this.#s=!0,this.dispatchEvent(new CustomEvent("include-file:loaded",{bubbles:!0,detail:{src:e,html:r}}))}catch(t){if(t.name==="AbortError")return;this.removeAttribute("data-loading"),this.setAttribute("data-error",""),(this.getAttribute("mode")||"replace")==="replace"&&this.#r!==null&&!this.#s&&(this.innerHTML=this.#r),this.dispatchEvent(new CustomEvent("include-file:error",{bubbles:!0,detail:{src:e,error:t.message}}))}}reload(){let e=this.getAttribute("src");e&&this.#i(e)}};u("include-file",a);export{a as IncludeFile};
|
|
1
|
+
var h=window.matchMedia("(prefers-reduced-motion: reduce)");var l=new Map;function u(s,e,t={}){let r=t.priority??10,n={impl:e,bundle:t.bundle,contract:t.contract,priority:r},i=l.get(s);if(customElements.get(s)){if(!i||i.priority>=r){i&&i.priority===r&&i.impl!==e&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=r){i.priority===r&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${i.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}l.set(s,n),customElements.define(s,e)}var o=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),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,r,n){e.addEventListener(t,r,n),this.#e.push(()=>e.removeEventListener(t,r,n))}setup(){}teardown(){}};var a=class extends o{#e;#t;#r=null;#s=!1;setup(){if(this.#s)return;let e=this.getAttribute("src");if(!e)return!1;this.#r===null&&(this.#r=this.innerHTML),this.hasAttribute("lazy")?this.#n():this.#i(e)}teardown(){this.#e?.disconnect(),this.#t?.abort()}static get observedAttributes(){return["src"]}attributeChangedCallback(e,t,r){e==="src"&&r&&t!==r&&this.isConnected&&(this.hasAttribute("lazy")&&!this.#o()?this.#n():this.#i(r))}#o(){let e=this.getBoundingClientRect();return e.top<window.innerHeight+200&&e.bottom>-200}#n(){this.#e?.disconnect(),this.#e=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){this.#e.disconnect();let r=this.getAttribute("src");r&&this.#i(r)}},{rootMargin:"200px"}),this.#e.observe(this)}async#i(e){this.#t?.abort(),this.#t=new AbortController,this.setAttribute("data-loading",""),this.removeAttribute("data-loaded"),this.removeAttribute("data-error");try{let t=await fetch(e,{signal:this.#t.signal});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let r=await t.text(),n=this.getAttribute("mode")||"replace";n==="replace"?this.innerHTML=r:n==="append"?this.insertAdjacentHTML("beforeend",r):n==="prepend"&&this.insertAdjacentHTML("afterbegin",r),this.hasAttribute("allow-scripts")?this.querySelectorAll("script").forEach(i=>{let c=document.createElement("script");for(let d of i.attributes)c.setAttribute(d.name,d.value);c.textContent=i.textContent,i.replaceWith(c)}):this.querySelectorAll("script").forEach(i=>i.remove()),this.removeAttribute("data-loading"),this.setAttribute("data-loaded",""),this.#s=!0,this.dispatchEvent(new CustomEvent("include-file:loaded",{bubbles:!0,detail:{src:e,html:r}}))}catch(t){if(t.name==="AbortError")return;this.removeAttribute("data-loading"),this.setAttribute("data-error",""),(this.getAttribute("mode")||"replace")==="replace"&&this.#r!==null&&!this.#s&&(this.innerHTML=this.#r),this.dispatchEvent(new CustomEvent("include-file:error",{bubbles:!0,detail:{src:e,error:t.message}}))}}reload(){let e=this.getAttribute("src");e&&this.#i(e)}};u("include-file",a);export{a as IncludeFile};
|
|
2
2
|
//# sourceMappingURL=include-file.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var k=window.matchMedia("(prefers-reduced-motion: reduce)");var w=new Map;function y(u,i,n={}){let o=n.priority??10,s={impl:i,bundle:n.bundle,contract:n.contract,priority:o},t=w.get(u);if(customElements.get(u)){if(!t||t.priority>=o){t&&t.priority===o&&t.impl!==i&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${t.bundle}" (priority ${t.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${u}> defined by "${t.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(t&&t.priority>=o){t.priority===o&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${t.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}w.set(u,s),customElements.define(u,i)}var m=class extends HTMLElement{#n=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&this.setAttribute("data-upgraded","")}disconnectedCallback(){for(let i of this.#n)i();this.#n=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(i,n,o,s){i.addEventListener(n,o,s),this.#n.push(()=>i.removeEventListener(n,o,s))}setup(){}teardown(){}};var f=class u extends m{static get observedAttributes(){return["src","compact","title"]}static#n=0;#e=null;#r={};#o={};#t=null;#l="";#i=[];setup(){this.#l=`kb-${++u.#n}`;let i=[...this.querySelectorAll(":scope > section[data-column]")];this.#i=i.map(t=>{let e=t.getAttribute("data-column")||"",c=t.getAttribute("data-column-label")||""||this.#d(e),d=t.getAttribute("data-wip"),l=d?parseInt(d,10):null,a=t.getAttribute("data-column-color")||null,p=[...t.children];return{id:e,label:c,wip:l,color:a,children:p}});for(let t of i)t.remove();this.#e=document.createElement("div"),this.#e.className="kb-columns",this.#e.setAttribute("role","region"),this.#e.setAttribute("aria-label","Kanban board");let n=0;for(let t of this.#i){let e=document.createElement("section");e.className="kb-column",e.setAttribute("data-column-id",t.id),t.color&&e.setAttribute("data-column-tint",t.color);let r=document.createElement("header");r.className="kb-column-header";let c=document.createElement("h3");c.textContent=t.label;let d=document.createElement("output");if(d.className="kb-count",d.textContent=String(t.children.length),c.appendChild(d),t.wip!==null&&!isNaN(t.wip)){let a=document.createElement("span");a.className="kb-wip",a.textContent=`/ ${t.wip}`,a.setAttribute("aria-label",`WIP limit ${t.wip}`),c.appendChild(a)}r.appendChild(c),e.appendChild(r);let l=document.createElement("drag-surface");if(l.setAttribute("group",this.#l),l.setAttribute("aria-label",`${t.label} items`),l.setAttribute("data-layout","stack"),l.setAttribute("data-layout-gap","xs"),t.children.length>0){for(let a of t.children)a.hasAttribute("draggable")||a.setAttribute("draggable","true"),a.hasAttribute("data-id")||(a.dataset.id=`kb-item-${n}`),l.appendChild(a);n+=t.children.length}else{let a=document.createElement("p");a.className="kb-empty",a.textContent="No items",l.appendChild(a)}e.appendChild(l),this.#e.appendChild(e),this.#r[t.id]=l,this.#o[t.id]=e,t.wip!==null&&t.children.length>t.wip&&e.setAttribute("data-wip-exceeded","")}let o=this.getAttribute("title");if(o){let t=document.createElement("h2");t.className="kb-title",t.textContent=o,this.appendChild(t)}this.appendChild(this.#e),this.#t=document.createElement("div"),this.#t.className="kb-live-region",this.#t.setAttribute("role","status"),this.#t.setAttribute("aria-live","polite"),this.#t.setAttribute("aria-atomic","true"),this.appendChild(this.#t),this.listen(this,"drag-surface:reorder",t=>{let e=t.detail,r=t.target.closest("drag-surface"),c=this.#s(r);c&&(this.#a(c),this.dispatchEvent(new CustomEvent("kanban-board:reorder",{bubbles:!0,detail:{itemId:e.itemId,column:c,oldIndex:e.oldIndex,newIndex:e.newIndex}})))}),this.listen(this,"drag-surface:transfer",t=>{let e=t.detail,r=e.fromSurface,c=e.toSurface,d=this.#s(r),l=this.#s(c);if(!d||!l)return;e.item&&e.item.setAttribute("data-column",l),this.#a(d),this.#a(l);let a=c.querySelector(".kb-empty");if(a&&a.remove(),r.querySelectorAll(':scope > [draggable="true"]').length===0&&!r.querySelector(".kb-empty")){let h=document.createElement("p");h.className="kb-empty",h.textContent="No items",r.appendChild(h)}let A=this.#h(e.item),C=this.#c(d),E=this.#c(l);this.#u(`${A} moved from ${C} to ${E}`),this.dispatchEvent(new CustomEvent("kanban-board:transfer",{bubbles:!0,detail:{itemId:e.itemId,fromColumn:d,toColumn:l,newIndex:e.newIndex,item:e.item}}));let g=c.querySelectorAll(':scope > [draggable="true"]').length,b=this.#i.find(h=>h.id===l);b?.wip!==null&&b?.wip!==void 0&&g>b.wip&&this.dispatchEvent(new CustomEvent("kanban-board:wip-exceeded",{bubbles:!0,detail:{column:l,limit:b.wip,count:g}}))});let s=this.getAttribute("src");if(s){this._loadSrc(s);return}this.dispatchEvent(new CustomEvent("kanban-board:ready",{bubbles:!0,detail:{columnCount:this.#i.length,itemCount:n}}))}teardown(){let i=this.querySelector(".kb-title");i&&i.remove(),this.#e&&(this.#e.remove(),this.#e=null),this.#t&&(this.#t.remove(),this.#t=null),this.#r={},this.#o={},this.#i=[]}attributeChangedCallback(i,n,o){n===o||!this.isConnected||i==="src"&&this._loadSrc(o)}async _loadSrc(i){if(i)try{let n=await fetch(i);if(!n.ok)throw new Error(`HTTP ${n.status}`);let o=await n.json();for(;this.firstChild;)this.firstChild.remove();for(let s of o.columns||[]){let t=document.createElement("section");t.setAttribute("data-column",s.id),s.label&&t.setAttribute("data-column-label",s.label),s.wip!=null&&t.setAttribute("data-wip",String(s.wip)),s.color&&t.setAttribute("data-column-color",s.color);for(let e of s.items||[]){let r;e.persona||e.action||e.storyId?(r=document.createElement("user-story"),r.setAttribute("detail",e.detail||"minimal"),e.storyId&&r.setAttribute("story-id",e.storyId),e.persona&&r.setAttribute("persona",e.persona),e.action&&r.setAttribute("action",e.action),e.benefit&&r.setAttribute("benefit",e.benefit),e.priority&&r.setAttribute("priority",e.priority),e.status&&r.setAttribute("status",e.status),e.points&&r.setAttribute("points",String(e.points))):(r=document.createElement("article"),r.className="kb-card",r.textContent=e.text||e.label||""),r.setAttribute("draggable","true"),r.dataset.id=e.id||e.storyId||"",t.appendChild(r)}this.appendChild(t)}this.teardown(),this.removeAttribute("data-upgraded"),this.setup()}catch(n){console.warn(`[kanban-board] Failed to load src="${i}":`,n)}}#s(i){if(!i)return null;for(let[n,o]of Object.entries(this.#r))if(o===i)return n;return null}#a(i){let n=this.#r[i],o=this.#o[i];if(!n||!o)return;let s=n.querySelectorAll(':scope > [draggable="true"]').length,t=o.querySelector(".kb-count");t&&(t.textContent=String(s));let e=this.#i.find(r=>r.id===i);e?.wip!==null&&e?.wip!==void 0&&(s>e.wip?o.setAttribute("data-wip-exceeded",""):o.removeAttribute("data-wip-exceeded"))}#c(i){return this.#i.find(o=>o.id===i)?.label||this.#d(i)}#u(i){this.#t&&(this.#t.textContent="",requestAnimationFrame(()=>{this.#t&&(this.#t.textContent=i)}))}#h(i){return i.getAttribute("story-id")||i.getAttribute("data-id")||i.textContent?.trim().slice(0,40)||"item"}#d(i){return i.replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())}};y("kanban-board",f);export{f as KanbanBoard};
|
|
1
|
+
var v=window.matchMedia("(prefers-reduced-motion: reduce)");var A=new Map;function E(u,t,n={}){let s=n.priority??10,o={impl:t,bundle:n.bundle,contract:n.contract,priority:s},e=A.get(u);if(customElements.get(u)){if(!e||e.priority>=s){e&&e.priority===s&&e.impl!==t&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${e.bundle}" (priority ${e.priority}). Skipping "${n.bundle}".`);return}console.warn(`[VB Bundle] Tag <${u}> defined by "${e.bundle}" cannot be replaced (customElements.define is permanent). "${n.bundle}" has higher priority but arrived late.`);return}if(e&&e.priority>=s){e.priority===s&&console.warn(`[VB Bundle] Tag <${u}> already registered by "${e.bundle}". Skipping "${n.bundle}" (first wins at equal priority).`);return}A.set(u,o),customElements.define(u,t)}var y=class extends HTMLElement{#i=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#i)t();this.#i=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,n,s,o){t.addEventListener(n,s,o),this.#i.push(()=>t.removeEventListener(n,s,o))}setup(){}teardown(){}};function k({newItems:u,nodes:t,keyOf:n,renderItem:s,containerFor:o}){let e=[],i=[],r=[],c=new Set;for(let a of u)c.add(n(a));for(let[a,l]of[...t])c.has(a)||(l.remove(),t.delete(a),r.push(a));let d=new Map;for(let a of u){let l=n(a),h=t.get(l)||null,f=o(a,h);d.has(f)||d.set(f,[]),d.get(f).push({item:a,key:l,existing:h})}for(let[a,l]of d)for(let h=0;h<l.length;h++){let{item:f,key:b,existing:w}=l[h],m=w;m?(m.parentElement!==a||a.children[h]!==m)&&i.push(b):(m=s(f),t.set(b,m),e.push(b));let p=a.children[h];p!==m&&a.insertBefore(m,p||null)}return{added:e,moved:i,removed:r}}function x(u){return class extends u{static keyOf(t){return t.id}#i=[];#t=new Map;get items(){return this.#i}set items(t){let n=t||[],s=k({newItems:n,nodes:this.#t,keyOf:this.constructor.keyOf,renderItem:o=>this._renderItem(o),containerFor:(o,e)=>this._containerFor(o,e)});this.#i=n,this._postRender({...s,items:n}),this._emit("items-changed",{items:n},"api")}_renderItem(t){throw new Error(`${this.constructor.name}: must implement _renderItem(item)`)}_containerFor(t,n){return this}_postRender(t){}_emit(t,n,s="api"){this.dispatchEvent(new CustomEvent(`${this.localName}:${t}`,{detail:{...n,source:s},bubbles:!0}))}_nodeFor(t){return this.#t.get(t)||null}_seedCollection(t,n){this.#i=t,this.#t.clear();for(let[s,o]of n)this.#t.set(s,o)}_setItemsSilently(t){this.#i=t}}}var C=class u extends x(y){static get observedAttributes(){return["src","compact","title"]}static keyOf(t){return t.id??t.storyId}static#i=0;#t=null;#n={};#o={};#e=null;#l="";#s=[];#r=null;setup(){this.#l=`kb-${++u.#i}`;let t=[...this.querySelectorAll(":scope > section[data-column]")];this.#s=t.map(e=>{let i=e.getAttribute("data-column")||"",c=e.getAttribute("data-column-label")||""||this.#d(i),d=e.getAttribute("data-wip"),a=d?parseInt(d,10):null,l=e.getAttribute("data-column-color")||null,h=[...e.children];return{id:i,label:c,wip:a,color:l,children:h}});for(let e of t)e.remove();this.#t=document.createElement("div"),this.#t.className="kb-columns",this.#t.setAttribute("role","region"),this.#t.setAttribute("aria-label","Kanban board");let n=0;for(let e of this.#s){let i=document.createElement("section");i.className="kb-column",i.setAttribute("data-column-id",e.id),e.color&&i.setAttribute("data-column-tint",e.color);let r=document.createElement("header");r.className="kb-column-header";let c=document.createElement("h3");c.textContent=e.label;let d=document.createElement("output");if(d.className="kb-count",d.textContent=String(e.children.length),c.appendChild(d),e.wip!==null&&!isNaN(e.wip)){let l=document.createElement("span");l.className="kb-wip",l.textContent=`/ ${e.wip}`,l.setAttribute("aria-label",`WIP limit ${e.wip}`),c.appendChild(l)}r.appendChild(c),i.appendChild(r);let a=document.createElement("drag-surface");if(a.setAttribute("group",this.#l),a.setAttribute("aria-label",`${e.label} items`),a.setAttribute("data-layout","stack"),a.setAttribute("data-layout-gap","xs"),e.children.length>0){for(let l of e.children)l.hasAttribute("draggable")||l.setAttribute("draggable","true"),l.hasAttribute("data-id")||(l.dataset.id=`kb-item-${n}`),a.appendChild(l);n+=e.children.length}else{let l=document.createElement("p");l.className="kb-empty",l.textContent="No items",a.appendChild(l)}i.appendChild(a),this.#t.appendChild(i),this.#n[e.id]=a,this.#o[e.id]=i,e.wip!==null&&e.children.length>e.wip&&i.setAttribute("data-wip-exceeded","")}let s=this.getAttribute("title");if(s){let e=document.createElement("h2");e.className="kb-title",e.textContent=s,this.appendChild(e)}this.appendChild(this.#t),this.#e=document.createElement("div"),this.#e.className="kb-live-region",this.#e.setAttribute("role","status"),this.#e.setAttribute("aria-live","polite"),this.#e.setAttribute("aria-atomic","true"),this.appendChild(this.#e),this.listen(this,"drag-surface:reorder",e=>{let i=e.detail,r=e.target.closest("drag-surface"),c=this.#c(r);c&&(this.#a(c),this.#u("drag"),this.dispatchEvent(new CustomEvent("kanban-board:reorder",{bubbles:!0,detail:{itemId:i.itemId,column:c,oldIndex:i.oldIndex,newIndex:i.newIndex}})))}),this.listen(this,"drag-surface:transfer",e=>{let i=e.detail,r=i.fromSurface,c=i.toSurface,d=this.#c(r),a=this.#c(c);if(!d||!a)return;i.item&&i.item.setAttribute("data-column",a),this.#a(d),this.#a(a);let l=c.querySelector(".kb-empty");if(l&&l.remove(),r.querySelectorAll(':scope > [draggable="true"]').length===0&&!r.querySelector(".kb-empty")){let g=document.createElement("p");g.className="kb-empty",g.textContent="No items",r.appendChild(g)}let f=this.#g(i.item),b=this.#h(d),w=this.#h(a);this.#b(`${f} moved from ${b} to ${w}`),this.#u("drag"),this.dispatchEvent(new CustomEvent("kanban-board:transfer",{bubbles:!0,detail:{itemId:i.itemId,fromColumn:d,toColumn:a,newIndex:i.newIndex,item:i.item}}));let m=c.querySelectorAll(':scope > [draggable="true"]').length,p=this.#s.find(g=>g.id===a);p?.wip!==null&&p?.wip!==void 0&&m>p.wip&&this.dispatchEvent(new CustomEvent("kanban-board:wip-exceeded",{bubbles:!0,detail:{column:a,limit:p.wip,count:m}}))}),this.#m();let o=this.getAttribute("src");if(o){this._loadSrc(o);return}this.dispatchEvent(new CustomEvent("kanban-board:ready",{bubbles:!0,detail:{columnCount:this.#s.length,itemCount:n}}))}#m(){let t=[],n=new Map;for(let[s,o]of Object.entries(this.#n)){let e=o.querySelectorAll(':scope > [draggable="true"]');for(let i of e){let r=i.getAttribute("data-id");r&&(t.push({id:r,column:s}),n.set(r,i))}}this._seedCollection(t,n)}#u(t){let n=[],s=new Map;for(let o of this.items){let e=String(o.id??o.storyId??"");e&&s.set(e,o)}for(let[o,e]of Object.entries(this.#n)){let i=e.querySelectorAll(':scope > [draggable="true"]');for(let r of i){let c=r.getAttribute("data-id");if(!c)continue;let d=s.get(c);n.push(d?{...d,column:o}:{id:c,column:o})}}this._setItemsSilently(n),this._emit("items-changed",{items:n},t)}teardown(){let t=this.querySelector(".kb-title");t&&t.remove(),this.#t&&(this.#t.remove(),this.#t=null),this.#e&&(this.#e.remove(),this.#e=null),this.#n={},this.#o={},this.#s=[]}get columns(){return this.#s.map(t=>({id:t.id,label:t.label,wip:t.wip??void 0,color:t.color??void 0}))}set columns(t){let n=(t||[]).map(s=>({id:s.id,label:s.label||this.#d(s.id),wip:s.wip??null,color:s.color??null,children:[]}));this.#t&&(this.#t.remove(),this.#t=null),this.#n={},this.#o={},this.#s=n,this.#p()}get renderItem(){return this.#r}set renderItem(t){this.#r=typeof t=="function"?t:null}_renderItem(t){let n;if(this.#r){let s=this.#r(t);if(!(s instanceof Element))throw new Error("kanban-board: renderItem must return an Element");n=s}else n=this.#f(t);return n.hasAttribute("draggable")||n.setAttribute("draggable","true"),n.hasAttribute("data-id")||n.setAttribute("data-id",String(u.keyOf(t))),n}_containerFor(t,n){let s=this.#n[t.column];if(!s)throw new Error(`kanban-board: no column "${t.column}" \u2014 set .columns first or include item.column matching an existing column id`);let o=s.querySelector(":scope > .kb-empty");return o&&o.remove(),s}_postRender(){for(let t of Object.keys(this.#n)){this.#a(t);let n=this.#n[t],s=n.querySelectorAll(':scope > [draggable="true"]'),o=n.querySelector(":scope > .kb-empty");if(s.length===0&&!o){let e=document.createElement("p");e.className="kb-empty",e.textContent="No items",n.appendChild(e)}else s.length>0&&o&&o.remove()}}#f(t){let n=customElements.get("work-item")?"work-item":"article",s=document.createElement(n);return n==="work-item"?s.data={itemId:t.id??t.storyId,type:t.type,priority:t.priority,status:t.status,estimate:t.estimate!=null?String(t.estimate):void 0,assignee:t.assignee,title:t.title,description:t.description,checklist:t.checklist,notes:t.notes,detail:t.detail}:(s.className="kb-card",s.textContent=t.title||t.label||t.id),s}#p(){this.#t=document.createElement("div"),this.#t.className="kb-columns",this.#t.setAttribute("role","region"),this.#t.setAttribute("aria-label","Kanban board");for(let t of this.#s){let n=document.createElement("section");n.className="kb-column",n.setAttribute("data-column-id",t.id),t.color&&n.setAttribute("data-column-tint",t.color);let s=document.createElement("header");s.className="kb-column-header";let o=document.createElement("h3");o.textContent=t.label;let e=document.createElement("output");if(e.className="kb-count",e.textContent="0",o.appendChild(e),t.wip!=null&&!isNaN(t.wip)){let c=document.createElement("span");c.className="kb-wip",c.textContent=`/ ${t.wip}`,c.setAttribute("aria-label",`WIP limit ${t.wip}`),o.appendChild(c)}s.appendChild(o),n.appendChild(s);let i=document.createElement("drag-surface");i.setAttribute("group",this.#l),i.setAttribute("aria-label",`${t.label} items`),i.setAttribute("data-layout","stack"),i.setAttribute("data-layout-gap","xs");let r=document.createElement("p");r.className="kb-empty",r.textContent="No items",i.appendChild(r),n.appendChild(i),this.#t.appendChild(n),this.#n[t.id]=i,this.#o[t.id]=n}this.appendChild(this.#t)}attributeChangedCallback(t,n,s){n===s||!this.isConnected||t==="src"&&this._loadSrc(s)}async _loadSrc(t){if(t)try{let n=await fetch(t);if(!n.ok)throw new Error(`HTTP ${n.status}`);let s=await n.json();for(;this.firstChild;)this.firstChild.remove();for(let o of s.columns||[]){let e=document.createElement("section");e.setAttribute("data-column",o.id),o.label&&e.setAttribute("data-column-label",o.label),o.wip!=null&&e.setAttribute("data-wip",String(o.wip)),o.color&&e.setAttribute("data-column-color",o.color);for(let i of o.items||[]){let r;i.persona||i.action||i.storyId?(r=document.createElement("user-story"),r.setAttribute("detail",i.detail||"minimal"),i.storyId&&r.setAttribute("story-id",i.storyId),i.persona&&r.setAttribute("persona",i.persona),i.action&&r.setAttribute("action",i.action),i.benefit&&r.setAttribute("benefit",i.benefit),i.priority&&r.setAttribute("priority",i.priority),i.status&&r.setAttribute("status",i.status),i.points&&r.setAttribute("points",String(i.points))):(r=document.createElement("article"),r.className="kb-card",r.textContent=i.text||i.label||""),r.setAttribute("draggable","true"),r.dataset.id=i.id||i.storyId||"",e.appendChild(r)}this.appendChild(e)}this.teardown(),this.removeAttribute("data-upgraded"),this.setup()}catch(n){console.warn(`[kanban-board] Failed to load src="${t}":`,n)}}#c(t){if(!t)return null;for(let[n,s]of Object.entries(this.#n))if(s===t)return n;return null}#a(t){let n=this.#n[t],s=this.#o[t];if(!n||!s)return;let o=n.querySelectorAll(':scope > [draggable="true"]').length,e=s.querySelector(".kb-count");e&&(e.textContent=String(o));let i=this.#s.find(r=>r.id===t);i?.wip!==null&&i?.wip!==void 0&&(o>i.wip?s.setAttribute("data-wip-exceeded",""):s.removeAttribute("data-wip-exceeded"))}#h(t){return this.#s.find(s=>s.id===t)?.label||this.#d(t)}#b(t){this.#e&&(this.#e.textContent="",requestAnimationFrame(()=>{this.#e&&(this.#e.textContent=t)}))}#g(t){return t.getAttribute("story-id")||t.getAttribute("data-id")||t.textContent?.trim().slice(0,40)||"item"}#d(t){return t.replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())}};E("kanban-board",C);export{C as KanbanBoard};
|
|
2
2
|
//# sourceMappingURL=kanban-board.js.map
|