1import{Component}from"@theme/component";import{prefersReducedMotion}from"@theme/utilities";class AnnouncementBar extends Component{requiredRefs=["viewport","track"];#timer=null;#mobileTimer=null;#resizeObserver=null;#frame=null;#paused=!1;#columnWidth=0;#mobileQuery=window.matchMedia("(max-width: 749px)");#originalOrder=[];#transitionHandler=null;connectedCallback(){super.connectedCallback(),this.#resizeObserver=new ResizeObserver(this.#schedule),this.#resizeObserver.observe(this),this.addEventListener("pointerenter",this.#pause),this.addEventListener("pointerleave",this.#resume),this.addEventListener("focusin",this.#pause),this.addEventListener("focusout",this.#resume),this.#mobileQuery.addEventListener("change",this.#schedule),this.#originalOrder=[...this.refs.track.children],this.#layout(),document.fonts?.ready.then(this.#schedule)}disconnectedCallback(){super.disconnectedCallback(),this.#stop(),this.#stopMobile(),this.#clearTransition(),this.#frame&&cancelAnimationFrame(this.#frame),this.#frame=null,this.#resizeObserver?.disconnect(),this.#resizeObserver=null,this.#mobileQuery.removeEventListener("change",this.#schedule)}updatedCallback(){this.#schedule()}#schedule=()=>{this.#frame&&cancelAnimationFrame(this.#frame),this.#frame=requestAnimationFrame(()=>{this.#frame=null,this.#layout()})};#layout(){const{track}=this.refs;if(this.#mobileQuery.matches){this.#stop(),this.#clearTransition(),this.#restoreOrder(),this.removeAttribute("data-scrolling"),this.removeAttribute("data-animating"),track.style.transform="",this.style.removeProperty("--announcement-bar-column"),this.#layoutMobile();return}this.#stopMobile();const items=[...track.children].filter(el=>el instanceof HTMLElement);if(items.length===0)return;this.#stop(),this.removeAttribute("data-scrolling"),track.style.transform="",this.style.removeProperty("--announcement-bar-column");const available=this.#availableWidth();if(available<=0)return;const gap=parseFloat(getComputedStyle(track).columnGap)||0,widths=items.map(item=>item.getBoundingClientRect().width);if(widths.reduce((sum,width)=>sum+width,0)+gap*(items.length-1)<=Math.ceil(available))return;const widest=Math.max(...widths),columns=Math.max(1,Math.min(items.length-1,Math.floor((available+gap)/(widest+gap))));this.#columnWidth=(available-gap*(columns-1))/columns,this.style.setProperty("--announcement-bar-column",`${this.#columnWidth}px`),this.setAttribute("data-scrolling",""),!prefersReducedMotion()&&this.#start()}#availableWidth(){const styles=getComputedStyle(this),padding=parseFloat(styles.paddingInlineStart)+parseFloat(styles.paddingInlineEnd);return this.getBoundingClientRect().width-padding}#start(){this.#timer=setInterval(()=>this.#advance(),this.#intervalMs)}#stop(){this.#timer&&clearInterval(this.#timer),this.#timer=null}get#intervalMs(){return(Number(this.getAttribute("interval"))||4)*1e3}#layoutMobile(){const items=[...this.refs.track.children].filter(el=>el instanceof HTMLElement);if(items.length!==0){if(!items.some(item=>item.hasAttribute("data-mobile-active")))for(const[index,item]of items.entries())item.toggleAttribute("data-mobile-active",index===0);this.#stopMobile(),!(items.length<=1||prefersReducedMotion())&&(this.#mobileTimer=setInterval(()=>this.#advanceMobile(),this.#intervalMs))}}#advanceMobile(){if(this.#paused)return;const items=[...this.refs.track.children].filter(el=>el instanceof HTMLElement);if(items.length===0)return;const currentIndex=items.findIndex(item=>item.hasAttribute("data-mobile-active")),nextIndex=(currentIndex+1)%items.length;currentIndex>=0&&items[currentIndex]?.removeAttribute("data-mobile-active"),items[nextIndex]?.setAttribute("data-mobile-active","")}#stopMobile(){this.#mobileTimer&&clearInterval(this.#mobileTimer),this.#mobileTimer=null}#pause=()=>{this.#paused=!0};#resume=()=>{this.#paused=!1};#advance(){if(this.#paused)return;const{track}=this.refs,first=track.firstElementChild;if(!(first instanceof HTMLElement))return;const gap=parseFloat(getComputedStyle(track).columnGap)||0;this.setAttribute("data-animating",""),track.style.transform=`translateX(-${this.#columnWidth+gap}px)`,this.#transitionHandler=()=>{this.#transitionHandler=null,this.removeAttribute("data-animating"),track.style.transform="",track.appendChild(first)},track.addEventListener("transitionend",this.#transitionHandler,{once:!0})}#clearTransition(){this.#transitionHandler&&(this.refs.track.removeEventListener("transitionend",this.#transitionHandler),this.#transitionHandler=null)}#restoreOrder(){const{track}=this.refs;for(const item of this.#originalOrder)track.appendChild(item)}}customElements.get("announcement-bar")||customElements.define("announcement-bar",AnnouncementBar); 2//# sourceMappingURL=/cdn/shop/t/4/assets/announcement-bar.js.map?v=78692092591156698271790150665
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.