1import{bo as g,by as d,aw as m,S as f,C as v}from"./storefrontApp.5Jl33SLO.min.js";import{S as b}from"./chunk-storefront_base_lit_element.BngXaMu.js";import{b as r,f as l,$ as a,d as c}from"./chunk-vendor-lit.NvY0u02.js";import{t as h}from"./chunk-vendor-lodash.CWHFt7Z.js";import{S}from"./chunk-storefront_settings_constants.DIF02Gz.js";import{S as B}from"./chunk-search_constants.BTyTVBH.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-vendor-rxjs.Dp7kflo.js";import"./chunk-vendor-phoenix.cdKS79L.js";class o{static async show(e,t,i){const s=o._calculateTranstionDuration(e);return new Promise(n=>{e.hidden=!1,e.classList.add(`${t}-transition-end`),requestAnimationFrame(()=>{e.classList.remove(`${t}-transition-start`),typeof i=="function"&&i(),setTimeout(()=>{e.hidden=!1,n()},s)})})}static async hide(e,t,i){const s=o._calculateTranstionDuration(e);return new Promise(n=>{requestAnimationFrame(()=>{typeof i=="function"&&i(),e.classList.add(`${t}-transition-start`),e.classList.remove(`${t}-transition-end`),setTimeout(()=>{e.hidden=!0,n()},s)})})}static _calculateTranstionDuration(e){try{return parseFloat(getComputedStyle(e).transitionDuration)*1e3+parseFloat(getComputedStyle(e).transitionDelay)*1e3}catch(t){return console.error(t),0}}}class p extends b{constructor(){super(),this._buyButtonRef=r(),this._navRef=r(),this._totalAndPayRef=r(),this._isNavScrolledDown=!1,this._throttledBadgeOffsetUpdate=h(()=>this._updateGlobalBadgeOffset(),100),this._lastScrollTop=0,this._hideMenuWhenScrollingDownWhileStickyBuyButtonVisible=h(()=>{const t=window.scrollY||document.documentElement.scrollTop,i=window.innerHeight,s=document.documentElement.scrollHeight,n=t+i>=s,_=t>this._lastScrollTop,y=this._buyButtonRef.value;_&&y?this._hideStickyNav():this._showStickyNav(),n&&this._showStickyNav(),this._lastScrollTop=t<=0?0:t},100),this._showStickyNav=()=>{this.style.transform="translate3d(0, 0, 0)",this._isGoogleReviewsStickyBarsFixFlagEnabled&&(this._isNavScrolledDown=!1,this._updateGlobalBadgeOffset())},this._hideStickyNav=()=>{this.style.transform=`translate3d(0, ${this._getStickyNavHeight()}px, 0)`,this._isGoogleReviewsStickyBarsFixFlagEnabled&&(this._isNavScrolledDown=!0,this._updateGlobalBadgeOffset())},this._updateGlobalBadgeOffset=()=>{let t=this.getBoundingClientRect().height;this._isNavScrolledDown&&(t-=this._getStickyNavHeight());const i=t>0?t:0;document.dispatchEvent(new CustomEvent(g.mobileMenuHeightChanged,{detail:i}))},this._getStickyNavHeight=()=>this._navRef.value?this._navRef.value.getBoundingClientRect().height:0,this._getStickyMobileBarsHeight=()=>this.getBoundingClientRect().height,this._toggleStickyBuyButton=t=>{t.forEach(i=>{if(this._buyButtonRef.value){const s="fade";i.isIntersecting?o.hide(this._buyButtonRef.value,s):o.show(this._buyButtonRef.value,s)}})},this._toggleStickyTotalAndPay=t=>{t.forEach(i=>{if(this._totalAndPayRef.value){const s="sticky-total-and-pay";i.isIntersecting?o.hide(this._totalAndPayRef.value,s):o.show(this._totalAndPayRef.value,s)}})},this._addMarginBottomToBody=()=>{const t=this._getStickyMobileBarsHeight()+document.body.style.marginBottom;document.body.style.marginBottom=`${t}px`},this._settingsApi=this.getApiSync(S.api),this._isGoogleReviewsStickyBarsFixFlagEnabled=this._settingsApi.isFeatureEnabled("dev_google_reviews_sticky_bars_fix");const e={root:null,rootMargin:"0px",threshold:.1};this._mainButButtonObserver=new IntersectionObserver(this._toggleStickyBuyButton,e),this._mainTotalAndPayObserver=new IntersectionObserver(this._toggleStickyTotalAndPay,e),this._isGoogleReviewsStickyBarsFixFlagEnabled&&(this._resizeObserver=new ResizeObserver(this._throttledBadgeOffsetUpdate))}static{this.moduleName=d.component}connectedCallback(){super.connectedCallback(),this._isGoogleReviewsStickyBarsFixFlagEnabled&&this._resizeObserver?.observe(this),this._addMarginBottomToBody(),this.classList.add("sticky-mobile-bars_active"),this.addEventListener("searchFocusIn",()=>{this.style.position="inherit"}),this.addEventListener(B.close,()=>{this.style.position="fixed"}),m.nextTick(()=>{document.querySelectorAll('main [data-module-name="product_actions"] buy-button').forEach(e
1=>{this._mainButButtonObserver.observe(e)}),document.querySelectorAll("main total-and-pay").forEach(e=>{this._mainTotalAndPayObserver.observe(e)})}),document.addEventListener("scroll",this._hideMenuWhenScrollingDownWhileStickyBuyButtonVisible)}disconnectedCallback(){super.disconnectedCallback(),this._isGoogleReviewsStickyBarsFixFlagEnabled&&(this._resizeObserver?.disconnect(),this._throttledBadgeOffsetUpdate.cancel()),this.classList.remove("sticky-mobile-bars_active"),this._mainButButtonObserver.disconnect(),this._mainTotalAndPayObserver.disconnect(),document.removeEventListener("scroll",this._hideMenuWhenScrollingDownWhileStickyBuyButtonVisible)}render(){const e=this.getSlot("total-and-pay"),t=this.getSlot("buy-button"),i=this.getSlot("nav");return a` 2 ${l(t,()=>a`<div 3 class="sticky-mobile-bars__buy-button-container" 4 ${c(this._buyButtonRef)} 5 > 6 ${t} 7 </div>`)} 8 ${l(i,()=>a`<div 9 ${c(this._navRef)} 10 class="sticky-mobile-bars__menu-container" 11 > 12 ${this.getSlot("nav")} 13 </div>`)} 14 ${l(e,()=>a`<div 15 class="sticky-mobile-bars__total-and-pay-container" 16 ${c(this._totalAndPayRef)} 17 > 18 ${e} 19 </div>`)} 20 `}}class M extends f{static{this.featureName=d.feature}init(){return{cores:[{type:v,instance:p}]}}}export{M as StickyMobileBarsInitializer};
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.