var ToggleEvent=class extends Event{oldState;newState;constructor(type,{oldState="",newState="",...init}={}){super(type,init),this.oldState=String(oldState||""),this.newState=String(newState||"")}},popoverToggleTaskQueue=new WeakMap;function queuePopoverToggleEventTask(element,oldState,newState){popoverToggleTaskQueue.set(element,setTimeout(()=>{popoverToggleTaskQueue.has(element)&&element.dispatchEvent(new ToggleEvent("toggle",{cancelable:!1,oldState,newState}))},0))}var ShadowRoot=globalThis.ShadowRoot||function(){},HTMLDialogElement=globalThis.HTMLDialogElement||function(){},topLayerElements=new WeakMap,autoPopoverList=new WeakMap,hintPopoverList=new WeakMap,visibilityState=new WeakMap;function getPopoverVisibilityState(popover){return visibilityState.get(popover)||"hidden"}var popoverInvoker=new WeakMap;function lastSetElement(set){return[...set].pop()}function popoverTargetAttributeActivationBehavior(element){const popover=element.popoverTargetElement;if(!(popover instanceof HTMLElement))return;const visibility=getPopoverVisibilityState(popover);element.popoverTargetAction==="show"&&visibility==="showing"||element.popoverTargetAction==="hide"&&visibility==="hidden"||(visibility==="showing"?hidePopover(popover,!0,!0):checkPopoverValidity(popover,!1)&&(popoverInvoker.set(popover,element),showPopover(popover)))}function checkPopoverValidity(element,expectedToBeShowing){return!(element.popover!=="auto"&&element.popover!=="manual"&&element.popover!=="hint"||!element.isConnected||expectedToBeShowing&&getPopoverVisibilityState(element)!=="showing"||!expectedToBeShowing&&getPopoverVisibilityState(element)!=="hidden"||element instanceof HTMLDialogElement&&element.hasAttribute("open")||document.fullscreenElement===element)}function getStackPosition(popover){if(!popover)return 0;const autoPopovers=autoPopoverList.get(document)||new Set,hintPopovers=hintPopoverList.get(document)||new Set;return hintPopovers.has(popover)?[...hintPopovers].indexOf(popover)+autoPopovers.size+1:autoPopovers.has(popover)?[...autoPopovers].indexOf(popover)+1:0}function topMostClickedPopover(target){const clickedPopover=nearestInclusiveOpenPopover(target),invokerPopover=nearestInclusiveTargetPopoverForInvoker(target);return getStackPosition(clickedPopover)>getStackPosition(invokerPopover)?clickedPopover:invokerPopover}function topmostAutoOrHintPopover(document2){let topmostPopover;const hintPopovers=hintPopoverList.get(document2)||new Set,autoPopovers=autoPopoverList.get(document2)||new Set,usedStack=hintPopovers.size>0?hintPopovers:autoPopovers.size>0?autoPopovers:null;return usedStack?(topmostPopover=lastSetElement(usedStack),topmostPopover.isConnected?topmostPopover:(usedStack.delete(topmostPopover),topmostAutoOrHintPopover(document2))):null}function topMostPopoverInList(list){for(const popover of list||[])if(!popover.isConnected)list.delete(popover);else return popover;return null}function getRootNode(node){return typeof node.getRootNode=="function"?node.getRootNode():node.parentNode?getRootNode(node.parentNode):node}function nearestInclusiveOpenPopover(node){for(;node;){if(node instanceof HTMLElement&&node.popover==="auto"&&visibilityState.get(node)==="showing")return node;if(node=node instanceof Element&&node.assignedSlot||node.parentElement||getRootNode(node),node instanceof ShadowRoot&&(node=node.host),node instanceof Document)return}}function nearestInclusiveTargetPopoverForInvoker(node){for(;node;){const nodePopover=node.popoverTargetElement;if(nodePopover instanceof HTMLElement)return nodePopover;if(node=node.parentElement||getRootNode(node),node instanceof ShadowRoot&&(node=node.host),node instanceof Document)return}}function topMostPopoverAncestor(newPopover,list){const popoverPositions=new Map;let i=0;for(const popover of list||[])popoverPositions.set(popover,i),i+=1;popoverPositions.set(newPopover,i),i+=1;let topMostPopoverAncestor2=null;function checkAncestor(candidate){if(!candidate)return;let okNesting=!1,candidateAncestor=null,candidatePosition=null;for(;!okNesting;){if(candidateAncestor=nearestInclusiveOpenPopover(candidate)||null,candidateAncestor===null||!popoverPositions.has(candidateAncestor))return;(newPopover.popover==="hint"||candidateAncestor.popover==="auto")&&(okNesting=!0),okNesting||(candidate=candidateAncestor.parentElement)}candidatePosition=popoverPositions.get(candidateAncestor),(topMostPopoverAncestor2===null||popoverPositions.get(topMostPopoverAncestor2)"u")return;window.ToggleEvent=window.ToggleEvent||ToggleEvent;function rewriteSelector(selector){return selector?.includes(":popover-open")&&(selector=selector.replace(nonEscapedPopoverSelector,"$1.\\:popover-open")),selector}patchSelectorFn(Document.prototype,"querySelector",rewriteSelector),patchSelectorFn(Document.prototype,"querySelectorAll",rewriteSelector),patchSelectorFn(Element.prototype,"querySelector",rewriteSelector),patchSelectorFn(Element.prototype,"querySelectorAll",rewriteSelector),patchSelectorFn(Element.prototype,"matches",rewriteSelector),patchSelectorFn(Element.prototype,"closest",rewriteSelector),patchSelectorFn(DocumentFragment.prototype,"querySelectorAll",rewriteSelector),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){if(!this.hasAttribute("popover"))return null;const value=(this.getAttribute("popover")||"").toLowerCase();return value===""||value=="auto"?"auto":value=="hint"?"hint":"manual"},set(value){value===null?this.removeAttribute("popover"):this.setAttribute("popover",value)}},showPopover:{enumerable:!0,configurable:!0,value(options={}){showPopover(this)}},hidePopover:{enumerable:!0,configurable:!0,value(){hidePopover(this,!0,!0)}},togglePopover:{enumerable:!0,configurable:!0,value(options={}){return typeof options=="boolean"&&(options={force:options}),visibilityState.get(this)==="showing"&&options.force===void 0||options.force===!1?hidePopover(this,!0,!0):(options.force===void 0||options.force===!0)&&showPopover(this),visibilityState.get(this)==="showing"}}});const originalAttachShadow=Element.prototype.attachShadow;originalAttachShadow&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(options){const shadowRoot=originalAttachShadow.call(this,options);return injectStyles(shadowRoot),shadowRoot}}});const originalAttachInternals=HTMLElement.prototype.attachInternals;originalAttachInternals&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){const internals=originalAttachInternals.call(this);return internals.shadowRoot&&injectStyles(internals.shadowRoot),internals}}});const popoverTargetAssociatedElements=new WeakMap;function applyPopoverInvokerElementMixin(ElementClass){Object.defineProperties(ElementClass.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(targetElement){if(targetElement===null)this.removeAttribute("popovertarget"),popoverTargetAssociatedElements.delete(this);else if(targetElement instanceof Element)this.setAttribute("popovertarget",""),popoverTargetAssociatedElements.set(this,targetElement);else throw new TypeError("popoverTargetElement must be an element or null")},get(){if(this.localName!=="button"&&this.localName!=="input"||this.localName==="input"&&this.type!=="reset"&&this.type!=="image"&&this.type!=="button"||this.disabled||this.form&&this.type==="submit")return null;const targetElement=popoverTargetAssociatedElements.get(this);if(targetElement&&targetElement.isConnected)return targetElement;if(targetElement&&!targetElement.isConnected)return popoverTargetAssociatedElements.delete(this),null;const root=getRootNode(this),idref=this.getAttribute("popovertarget");return(root instanceof Document||root instanceof ShadowRoot2)&&idref&&root.getElementById(idref)||null}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){const value=(this.getAttribute("popovertargetaction")||"").toLowerCase();return value==="show"||value==="hide"?value:"toggle"},set(value){this.setAttribute("popovertargetaction",value)}}})}applyPopoverInvokerElementMixin(HTMLButtonElement),applyPopoverInvokerElementMixin(HTMLInputElement);const handleInvokerActivation=event=>{if(event.defaultPrevented)return;const composedPath=event.composedPath(),target=composedPath[0];if(!(target instanceof Element)||target?.shadowRoot)return;const root=getRootNode(target);if(!(root instanceof ShadowRoot2||root instanceof Document))return;const invoker=composedPath.find(el=>{var _a;return(_a=el.matches)==null?void 0:_a.call(el,"[popovertargetaction],[popovertarget]")});if(invoker){popoverTargetAttributeActivationBehavior(invoker),event.preventDefault();return}},onKeydown=event=>{const key=event.key,target=event.target;!event.defaultPrevented&&target&&(key==="Escape"||key==="Esc")&&hideAllPopoversUntil(target.ownerDocument,!0,!0)};(root=>{root.addEventListener("click",handleInvokerActivation),root.addEventListener("keydown",onKeydown),root.addEventListener("pointerdown",lightDismissOpenPopovers),root.addEventListener("pointerup",lightDismissOpenPopovers)})(document),injectStyles(document)}isSupported()||apply(); //# sourceMappingURL=/cdn/shop/t/47/assets/popover-polyfill.js.map?v=119029313658895111201757451905