(e=>{function t(){return e.matchMedia?.("(pointer: coarse)").matches}function o(e,t){let o;return function(...r){clearTimeout(o),o=setTimeout(()=>e.apply(this,r),t)}}const r=new WeakMap;let s=0;class i{constructor(e){if(this.popoverShown=!1,this.triggerEl=e,this.popoverEl=e.nextElementSibling,!this.popoverEl||!this.popoverEl.hasAttribute("popover"))return void console.error("Popover trigger has no adjacent popover element.",e);this.placement=this.triggerEl.dataset.popover||"bottom",this.placementFallback=this.triggerEl.dataset.popoverPlacementFallback?n(this.triggerEl.dataset.popoverPlacementFallback):l(this.placement),this.trigger=this.triggerEl.dataset.popoverTrigger||"click","hover"===this.trigger&&t()&&(this.trigger="click"),this.hoverDelay=Number.parseInt(this.triggerEl.dataset.popoverHoverDelay||"150"),this.hoverOutDelay=Number.parseInt(this.triggerEl.dataset.popoverHoverOutDelay||"150"),this.offset=this.getDefaultOffset(),this.hoverTimeout=null,this.triggerHovered=!1,this.popoverHovered=!1,this.popoverEl.id||(this.popoverEl.id="data-popover-"+ ++s),"hover"!==this.trigger&&null===this.triggerEl.getAttribute("popovertarget")&&this.triggerEl.setAttribute("popovertarget",this.popoverEl.id),this.popoverEl.addEventListener("toggle",e=>{this.popoverShown="open"===e.newState,this.popoverShown?(this.positionPopover(),this.popoverEl.dispatchEvent(new CustomEvent("data-popover:show")),this.popoverEl.addEventListener("animationend",()=>{this.popoverEl.dataset.popoverAnimated="true"},{once:!0})):delete this.popoverEl.dataset.popoverAnimated}),"hover"===this.trigger&&this.setupHoverHandlers();new ResizeObserver(()=>{this.popoverEl.matches(":popover-open")&&this.positionPopover()}).observe(this.popoverEl),r.set(e,this)}setupHoverHandlers(){this.triggerEl.addEventListener("mouseenter",()=>{this.triggerHovered=!0,clearTimeout(this.hoverTimeout),this.popoverEl.matches(":popover-open")||(this.hoverTimeout=setTimeout(()=>{(this.triggerHovered||this.popoverHovered)&&this.popoverEl.showPopover()},this.hoverDelay))}),this.triggerEl.addEventListener("mouseleave",()=>{this.triggerHovered=!1,this.scheduleHide()}),this.popoverEl.addEventListener("mouseenter",()=>{this.popoverHovered=!0,clearTimeout(this.hoverTimeout)}),this.popoverEl.addEventListener("mouseleave",()=>{this.popoverHovered=!1,this.scheduleHide()})}scheduleHide(){clearTimeout(this.hoverTimeout),this.hoverTimeout=setTimeout(()=>{this.triggerHovered||this.popoverHovered||this.popoverEl.hidePopover()},this.hoverOutDelay)}getDefaultOffset(){const e=getComputedStyle(this.popoverEl);return Number.parseFloat(e.getPropertyValue("--data-popover-arrow-width"))||8}calculateCoords(e,t,o){let r,s;switch(e){case"right":r=t.right+this.offset,s=t.top+t.height/2-o.height/2;break;case"right-start":r=t.right+this.offset,s=t.top;break;case"right-end":r=t.right+this.offset,s=t.bottom-o.height;break;case"left":r=t.left-o.width-this.offset,s=t.top+t.height/2-o.height/2;break;case"left-start":r=t.left-o.width-this.offset,s=t.top;break;case"left-end":r=t.left-o.width-this.offset,s=t.bottom-o.height;break;case"top":r=t.left+t.width/2-o.width/2,s=t.top-o.height-this.offset;break;case"top-start":r=t.left,s=t.top-o.height-this.offset;break;case"top-end":r=t.right-o.width,s=t.top-o.height-this.offset;break;case"bottom-start":r=t.left,s=t.bottom+this.offset;break;case"bottom-end":r=t.right-o.width,s=t.bottom+this.offset;break;default:"bottom"!==e&&console.error(`Invalid popover placement: "${e}"`),r=t.left+t.width/2-o.width/2,s=t.bottom+this.offset}return{left:r,top:s}}isOutOfBounds(t){return t.top<0||t.left<0||t.bottom>e.innerHeight||t.right>e.innerWidth}positionPopover(){requestAnimationFrame(()=>{const t=this.triggerEl.getBoundingClientRect(),o=this.popoverEl.getBoundingClientRect(),r=[this.placement,...this.placementFallback];let s=this.placement;for(const e of r){const r=this.calculateCoords(e,t,o),i={top:r.top,left:r.left,bottom:r.top+o.height,right:r.left+o.width};if(!this.isOutOfBounds(i)){s=e;break}}let{left:i,top:p}=this.calculateCoords(s,t,o);i+=e.scrollX,p+=e.scrollY;const h=Math.round(Number.parseFloat(this.popoverEl.style.left))!==Math.round(i),l=Math.round(Number.parseFloat(this.popoverEl.style.top))!==Math.round(p);if(h&&(this.popoverEl.style.left=`${i}px`),l&&(this.popoverEl.style.top=`${p}px`),h||l){const e=a(s);this.popoverEl.dataset.popoverLoc!==e&&(this.popoverEl.dataset.popoverLoc=e)}})}}function p(){for(const e of document.querySelectorAll("[popover]:popover-open")){const t=e.previousElementSibling;if(t){const e=r.get(t);e&&e.positionPopover()}}}document.addEventListener("click",e=>{const o=e.target.closest?.("[data-popover]");if(!o)return;if("hover"===o.dataset.popoverTrigger&&!t())return;r.has(o)||new i(o);const s=o.tagName.toUpperCase();if(!("BUTTON"===s||"INPUT"===s&&o.type&&"button"===o.type.toLowerCase())){o.hasAttribute("href")&&e.preventDefault();const t=r.get(o);t.popoverShown?t.popoverEl.hidePopover():t.popoverEl.showPopover()}}),document.addEventListener("mouseover",e=>{const o=e.target.closest?.("[data-popover]");o&&!r.has(o)&&("hover"!==o.dataset.popoverTrigger||t()||new i(o))}),e.addEventListener("scroll",function(e,t){let o=0,r=null;return function(...s){const i=Date.now(),p=t-(i-o);p<=0?(r&&(clearTimeout(r),r=null),o=i,e.apply(this,s)):r||(r=setTimeout(()=>{o=Date.now(),r=null,e.apply(this,s)},p))}}(p,15)),e.addEventListener("resize",o(p,15)),document.addEventListener("DOMContentLoaded",()=>{new MutationObserver(o(p,15)).observe(document.body,{childList:!0,subtree:!0,attributes:!0})});const h={t:"b r l",b:"t r l",l:"r t b",r:"l t b",ts:"te bs be rs ls",te:"ts be bs re le",bs:"be ts te rs ls",be:"bs te ts re le",ls:"le rs re ts bs",le:"ls re rs te be",rs:"re ls le ts bs",re:"rs le ls te be"};function l(e){return n(h[a(e)])}function a(e){const t=e.split("-");let o=t[0].charAt(0);if(2===t.length&&(o+=t[1].charAt(0)),!(o in h))throw new Error(`Invalid placement name: "${e}"`);return o}function n(e){try{return e.split(" ").map(e=>function(e){if(!(e in h))throw new Error(`Invalid short placement name: "${e}"`);const t={t:"top",b:"bottom",l:"left",r:"right"}[e.charAt(0)];if(1===e.length)return t;const o={s:"start",e:"end"}[e.charAt(1)];return`${t}-${o}`}(e))}catch(t){throw new Error(`Failed to decode placement fallback: "${e}"`,{cause:t})}}e.d=l})(window);