function essentialCountdownCloseAnnouncementBar(e,t){let n=document.querySelector(`.countdown_annoucement_bar_wrapper_${e}`);if(n){n.parentNode.removeChild(n);try{window.localStorage.setItem("countdownTimerAnnoucementBarClosed",JSON.stringify({value:!0,id:e,updatedAt:t}))}catch(o){console.log(o)}}}function essentialCountdownCloseAnnouncementBarOnClick(e,t){!e.target.closest("button")&&t&&(window.location.href=t)}async function getCartEssentialApps(){let e=await fetch(window?.Shopify?.routes?.root+"cart.js",{headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>e).catch(e=>{console.error("Error:",e)});return e}function clearCartEssentialApps(e){fetch(window?.Shopify?.routes?.root+"cart/clear.js",{method:"POST",headers:{"Content-Type":"application/json"}}).then(()=>{try{window.localStorage.removeItem(`essentialCountdownTimer-${e.id}`)}catch(t){console.log(t)}let n=window.location&&window.location.pathname.includes("/cart");(n||window.cartTimerObserver)&&location.reload()}).catch(e=>{console.error("Error:",e)})}!function(){let e=null,t=window.essentialCountdownTimerMeta,n=window.essentialCountdownTimerPageTemplate||"";async function o(){let t=window.Shopify?window.Shopify.shop:window.location.origin,n=window.essentialCountdownTimerConfigs,o=`https://cache-essential-apps.cc/config/${t}`;if(n){let i=n.find(e=>e.locationType&&"on-countries"===e.locationType);return i&&await fetch("https://cache-essential-apps.cc/config/geolocation").then(t=>{t.headers.has("country")&&(e=t.headers.get("country"))}),new Promise(e=>{e(n)})}return t?fetch(o).then(t=>(t.headers.has("country")&&(e=t.headers.get("country")),t.json())):new Promise(e=>{e([])})}function i(e){let t=document.getElementsByTagName("head")[0],n=document.createElement("style");n.setAttribute("type","text/css"),n.setAttribute("id","countdown_timer"),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),t.appendChild(n)}function r(e){return"imageBackground"===e.backgroundType?"":"gradientBackground"===e.backgroundType?`background: linear-gradient(${e.gradientTurn}deg, ${e.gradientStart}, ${e.gradientEnd});`:"singleBackground"===e.backgroundType&&(e.singleColorAlpha||0===parseFloat(e.singleColorAlpha))&&1>parseFloat(e.singleColorAlpha)?`background: ${e.singleColorRgba};`:`background: ${e.singleColor};`}function a(){if(window.essentialViewCounted||Shopify?.shop==="rationalacoustics.myshopify.com")return;window.essentialViewCounted=!0;let e=window.Shopify?window.Shopify.shop:window.location.origin,t=document.querySelectorAll(".essential_countdown_timer"),n=t&&t.length>0?t.length:0;e&&0!==n&&fetch("https://essential-apps-analytics.herokuapp.com/post_event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({shop:e,views:n})})}function l(e){return""!==e.font&&e.font?`font-family: ${e.font}; `:""}function d(e,t){let n=e.style;return` .countdown_wrapper_${e.id} { display: grid; ${C(e)?"grid-template-columns: 1fr 10px 1fr 10px 1fr;":"grid-template-columns: 1fr 10px 1fr 10px 1fr 10px 1fr;"} ${"top-bar"===t?"row-gap: 0;":"row-gap: 6px;"} justify-items: center; align-items: center; column-gap: 5px; direction: ltr; ${"top-bar"===t?"column-gap: 2px;":"padding-top: 4px;"} ${"top-bar"!==t&&!e.subheading&&!e.title&&"padding-top: 0;"} } .countdown_time_${e.id} { ${l(n)}color: ${n.timerColor}; font-weight: bold; font-size: ${n.timerSize}px; line-height: 1; font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums; ${"top-bar"!==t&&(e.subheading||e.title)&&"padding-top: 4px;"} } .countdown_legend_${e.id} { ${l(n)}color: ${n.legendColor}; font-size: ${n.legendSize}px; padding-right: 10px; grid-column: 2 span; line-height: 1; } .countdown_legend_${e.id}.last { grid-column: auto; padding-right: 0; } ${"df8f6b-2.myshopify.com"===Shopify.shop?`.essential_countdown_annoucement_bar_wrapper > div:nth-of-type(2) .essential_countdown_timer {display: none;} .essential_countdown_annoucement_bar_wrapper > div:nth-of-type(2) .essential_countdown_timer:last-of-type {display: grid;}`:""}`}function s(e){let t=e.style,n=` .countdown_timer_wrapper_${e.id} { display: flex; flex-flow: column; ${l(t)} ${r(t)} ${void 0!==t.insideTopSpacing?`margin-top: ${t.outsideTopSpacing}px; margin-bottom: ${t.outsideBottomSpacing}px; padding-top: ${t.insideTopSpacing}px; padding-bottom: ${t.insideBottomSpacing}px; `:`margin: 20px 0; padding: 30px;`} border-radius: ${t.borderRadius}px; border: ${t.borderColor} solid ${t.borderSize}px; text-align: center; flex:auto; align-items: center; position: relative; overflow: hidden; } .countdown_timer_wrapper_${e.id}.clickable { cursor: pointer; } .countdown_timer_wrapper_${e.id} h2 { ${l(t)}font-weight: bold; font-size: ${t.titleSize}px; color: ${t.titleColor}; margin: 0; padding: 0; line-height: 1.2; letter-spacing: normal; text-transform: none; } .countdown_timer_subheading_${e.id} { ${l(t)}font-size: ${t.subheadingSize}px; color: ${t.subheadingColor}; line-height: 1.2; letter-spacing: normal; padding: 0; padding-top: 2px; margin: 0; } .countdown_timer_bar_cta_${e.id}, .countdown_timer_bar_cta_${e.id}:visited { display: block; cursor: pointer; text-decoration: none; background: ${t.buttonBackgroundColor}; border: 0; white-space: nowrap; padding: 8px 16px; line-height: 1.5; border-radius: ${t.buttonBorderRadius}px; font-size: ${t.buttonFontSize}px; color: ${t.buttonFontColor}; margin-top: 16px; } ${d(e,"product-page")} `;i(n)}function c(e){return 1===e.toString().length?`0${e}`:e}function p(e,t,n,o=null){let i,r=new Date(e+6e4*n.fixedMinutes),a=new Date().getTime();if("toDate"===n.timerType)i=new Date(n.endDate)-a;else if("recurring"===n.timerType){let l=new Date(n.endDate)-a;if("never"!==n.endType&&l<0)i=l;else{let d=S(n.startDate),s=S(n.endDate);i=da?s-a:d.getTime()>a?0:s.getTime()+864e5-a}}else{i=t?r-(6e4*n.fixedMinutes-t)-a:r-a;try{"cart-page"===n.type&&o.item_count>0&&window.localStorage.setItem(`essentialCountdownTimer-${n.id}`,JSON.stringify({id:n.id,userDistance:i,sessionCurrentDate:new Date().getTime(),updatedAt:n.updatedAt})),"cart-page"!==n.type&&window.localStorage.setItem(`essentialCountdownTimer-${n.id}`,`${i}, ${new Date().getTime()}, ${n.timerType}-${n.fixedMinutes}-${n.id}`)}catch(p){console.log(p)}}if(i<0){if("custom-title"===n.onceItEnds){var u;let m,g;"product-page"===(u=n).type||"landing-page"===u.type?(m=document.querySelector(`.countdown_timer_wrapper_${u.id} h2`),g=document.querySelector(`.countdown_timer_subheading_${u.id}`)):(m=document.querySelector(`.countdown_annoucement_bar_title_${u.id}`),g=document.querySelector(`.countdown_annoucement_bar_subheading_${u.id}`)),g&&g.remove(),m&&(m.textContent=u.customTitle)}if("hide"===n.onceItEnds||""===n.onceItEnds||"delete-items"===n.onceItEnds){let h;"product-page"===n.type||"landing-page"===n.type?h=document.querySelector(`.countdown_timer_wrapper_${n.id}`):"cart-page"===n.type?(window.cartTimerObserver&&window.cartTimerObserver.disconnect(),h=document.querySelector(`.countdown_cart_page_timer_wrapper_${n.id}`)):h=document.querySelector(`.countdown_annoucement_bar_wrapper_${n.id}`),h&&h.remove()}"delete-items"===n.onceItEnds&&"cart-page"===n.type&&o.item_count>0&&clearCartEssentialApps(n);return}let f=Math.floor(i/864e5);f=c(f);let $=Math.floor(i%864e5/36e5);$=c($);let w=Math.floor(i%36e5/6e4);w=c(w);let y=Math.floor(i%6e4/1e3);return y=c(y),C(n)?{hours:$,minutes:w,seconds:y}:{days:f,hours:$,minutes:w,seconds:y}}function u(e,t){if("imageBackground"!==t.style.backgroundType)return;let n=t.style.imageOverlayColor;(t.style.imageOverlayColorAlpha||0===parseFloat(t.style.imageOverlayColorAlpha))&&1>parseFloat(t.style.imageOverlayColorAlpha)&&(n=`linear-gradient(${t.style.imageOverlayColorRgba}, ${t.style.imageOverlayColorRgba})`),[...e.children].forEach(e=>{e.style.position="relative"});let o=document.createElement("div");o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.width="100%",o.style.height="100%",o.style.background=n,e.insertBefore(o,e.firstChild);let i=document.createElement("img");i.src=t.style.image,i.classList.add("essential-countdown-timer-img-reset"),i.fetchpriority="high",i.style.width="100%",i.style.height="100%",i.style.objectFit="cover",i.style.zIndex="-1",i.style.position="relative",o.append(i)}function m(e,t){let n=Number(new Date().getTime()),o,i,r,l;try{r=window.localStorage.getItem(`essentialCountdownTimer-${t.id}`)}catch(d){console.log(d)}r&&([o,i,l]=r&&r.split(","),-1===l.indexOf(`${t.timerType}-${t.fixedMinutes}-${t.id}`)&&(r=null,o=null)),r&&parseInt(i)+6e4*t.fixedMinutes>n&&(n=parseInt(i)),g(p(n,o,t),e,t),setTimeout(()=>{a()},700);let s=setInterval(()=>{let i=p(n,o,t);(t.repeat||"repeat"===t.onceItEnds)&&"fixedMinutes"===t.timerType&&!i?(o=0,n=Number(new Date().getTime())):i||clearInterval(s),g(p(n,o,t),e,t)},1e3)}function g(e,t,n){let o=document.createElement("div");o.className=`countdown_wrapper_${n.id} essential_countdown_timer notranslate`,Shopify?.shop==="sculpdus.myshopify.com"&&o.setAttribute("aria-live","polite"),e||(e=C(n)?{hours:"00",minutes:"00",seconds:"00"}:{days:"00",hours:"00",minutes:"00",seconds:"00"}),Object.values(e).forEach((e,t)=>{let i=document.createElement("span");i.className=`countdown_time_${n.id}`,i.textContent=e,Shopify?.shop==="sculpdus.myshopify.com"&&i.setAttribute("tabindex","-1");let r=i.cloneNode(!0);r.textContent=":",Shopify?.shop==="sculpdus.myshopify.com"&&(r.setAttribute("aria-hidden","true"),r.setAttribute("tabindex","-1")),o.append(i);let a=C(n)?2:3;t!==a&&o.append(r)}),t.innerHTML="",function e(t,n,o){let i=C(o)?[o.legendCopyHours,o.legendCopyMins,o.legendCopySecs]:[o.legendCopyDays,o.legendCopyHours,o.legendCopyMins,o.legendCopySecs,];i.forEach((e,n)=>{let i=document.createElement("div");i.className=`countdown_legend_${o.id}`,Shopify?.shop==="sculpdus.myshopify.com"&&i.setAttribute("tabindex","-1");let r=C(o)?2:3;n===r&&(i.className=`countdown_legend_${o.id} last`),i.textContent=e,t.append(i)}),n.append(t)}(o,t,n),t.append(o)}function h(e,t,n){let o=document.createElement("div");o.className="cart-page-inline-timer h2";let i=document.createElement("span");var r,a,l="{timer}";e||(e={days:"00",hours:"00",minutes:"00",seconds:"00"}),Object.values(e).forEach((e,t)=>{if(0===t&&"00"===e||1===t&&"00"===e)return;let o=document.createElement("span");o.className=`countdown_time_${n.id}`,o.textContent=e;let r=o.cloneNode(!0);r.textContent=":",i.append(o),3!==t&&i.append(r)}),t.innerHTML="",o.innerHTML+=(r=n.title,a=i,r.replace(l,a.outerHTML)),t.append(o)}function f(e,t=null){let o=document.querySelector(".essential_countdown_annoucement_bar_wrapper");if(o&&!t)return;try{let a=window.localStorage.getItem("countdownTimerAnnoucementBarClosed");if((a=JSON.parse(a))&&a.id===e.id&&a.updatedAt===e.updatedAt&&a.value)return}catch(s){console.log(s)}if(e.timerPlacement){let c=window.location.pathname,p=window?.Shopify?.routes?.root||"/",g=p;if(p.length>1&&(p=p.slice(0,p.length-1)),"home-page"===e.timerPlacement&&c!==p&&c!==g||"all-products"===e.timerPlacement&&!window.location.pathname.includes("/products/"))return;if("all-products"===e.timerPlacement&&window.location.pathname.includes("/products/")){let h=e.excludeOnProducts?.find(e=>Number(e.id.split("/").pop())===window.essentialProductId);if(h)return}if("all-collections"===e.timerPlacement&&(!window.location.pathname.includes("/collections/")||window.location.pathname.includes("/products/")))return}else{let f=n.startsWith("index")&&e.excludeOnPages?.includes("home-page")||n.startsWith("collection")&&e.excludeOnPages?.includes("all-collections")||n.startsWith("product")&&e.excludeOnPages?.includes("all-products")||n.startsWith("blog")&&e.excludeOnPages?.includes("blogs")||n.startsWith("article")&&e.excludeOnPages?.includes("posts")||n.startsWith("cart")&&e.excludeOnPages?.includes("cart")||n.startsWith("search")&&e.excludeOnPages?.includes("search")||n.startsWith("404")&&e.excludeOnPages?.includes("404"),$=e.excludeOnSpecificUrls?.some(e=>window.location.href.includes(e)),w=window.location.pathname.split(/[/\-]/),y=!!e.excludeOnKeywordsInUrl?.find(e=>w.includes(e));if(f||$||y)return}!function e(t){let n=t.style,o=` .countdown_annoucement_bar_wrapper_${t.id} { position: relative; ${l(n)} ${r(n)} z-index: ${!t.createdAt||1697704508e3>new Date(t.createdAt).getTime()?100:1}; display: flex !important; width: 100%; flex-wrap: wrap; ${"seperate-centered"===n.announcementBarStyle?`flex-flow: column; justify-items: center;`:""} align-items: center; justify-content: center; padding: 10px; column-gap: 26px; row-gap: 10px; border-bottom: ${n.borderColor} solid ${n.borderSize}px; } .countdown_annoucement_bar_wrapper_${t.id}.top_page { position: sticky; top: 0; } .countdown_annoucement_bar_wrapper_${t.id}.bottom_page { bottom: 0; left: 0; position: fixed; width: 100%; border-bottom: none; border-top: ${n.borderColor} solid ${n.borderSize}px; } .countdown_annoucement_bar_wrapper_${t.id}.clickable { cursor: pointer; } .countdown_annoucement_bar_title_${t.id}.h2 { ${l(n)}font-weight: bold; font-size: ${n.titleSize}px; color: ${n.titleColor}; margin: 0; padding: 0; line-height: 1.2; letter-spacing: normal; text-transform: none; text-align: left; } .countdown_annoucement_bar_subheading_${t.id} { ${l(n)}font-size: ${n.subheadingSize}px; color: ${n.subheadingColor}; line-height: 1.2; letter-spacing: normal; padding: 0; margin: 0; } .countdown_annoucement_bar_cta_${t.id}, .countdown_annoucement_bar_cta_${t.id}:visited { display: block; cursor: pointer; text-decoration: none; background: ${n.buttonBackgroundColor}; border: 0; white-space: nowrap; padding: 8px 16px; line-height: 1.5; border-radius: ${n.buttonBorderRadius}px; font-size: ${n.buttonFontSize}px; color: ${n.buttonFontColor}; } .countdown_annoucement_bar_close_button_${t.id} { position: absolute; display: block; border: none; background: none; padding: 6px; cursor: pointer; top: 50%; right: 10px; transform: translate(0, -50%); } .countdown_annoucement_bar_close_button_${t.id} svg { width: 12px; height: 12px; display: block; } .countdown_annoucement_bar_close_button_${t.id}.top_right { position: absolute; top: 20px; right: 20px; } ${(e=>{if(!e.createdAt||1697704508e3>new Date(e.createdAt).getTime())return"";let t=!e.legendCopyDays&&!e.legendCopyHours&&!e.legendCopyMins&&!e.legendCopySecs;return` @media (max-width: 620px) { .countdown_annoucement_bar_wrapper_${e.id} { padding: 7px; column-gap: 10px; row-gap: 7px; } span.countdown_time_${e.id} { font-size: ${Math.floor(.8*n.timerSize)}px; padding-top: ${t?0:"2px"}; } div.countdown_legend_${e.id} { font-size: ${Math.floor(.8*n.legendSize)}px; } .countdown_annoucement_bar_title_${e.id}.h2 { font-size: ${Math.floor(.8*n.titleSize)}px; } .countdown_annoucement_bar_subheading_${e.id} { font-size: ${Math.floor(.8*n.subheadingSize)}px; } .countdown_annoucement_bar_cta_${e.id}, .countdown_annoucement_bar_cta_${e.id}:visited { padding: 6px 14px; line-height: 1.5; font-size: ${Math.floor(.9*n.buttonFontSize)}px; } }`})(t)} @media (max-width: 430px) { .countdown_annoucement_bar_wrapper_${t.id} { justify-items: center; text-align: center; padding: 10px 15px; } .countdown_annoucement_bar_close_button_${t.id} { position: absolute; padding: 0; transform: none; top: 5px; right: 5px; } .countdown_annoucement_bar_title_${t.id}.h2 { text-align: center; } } ${d(t,"top-bar")} `;i(o)}(e);let b=document.createElement("div");b.className=`essential_countdown_annoucement_bar_wrapper countdown_annoucement_bar_wrapper_${e.id}`,Shopify?.shop==="sculpdus.myshopify.com"&&(b.setAttribute("role","region"),b.setAttribute("aria-labelledby","timer-title")),"top-page"===e.style.position&&e.style.stickyBar&&(b.className+=" top_page"),"bottom-page"===e.style.position&&(b.className+=" bottom_page"),"clickable"===e.CTAType&&e.CTALink&&(b.className+=" clickable",b.setAttribute("onclick",`essentialCountdownCloseAnnouncementBarOnClick(event, "${e.CTALink}")`));let x=document.createElement("p");x.className+=`countdown_annoucement_bar_title_${e.id} h2`,x.textContent+=e.title,Shopify?.shop==="sculpdus.myshopify.com"&&(x.setAttribute("id","timer-title"),x.setAttribute("role","heading"),x.setAttribute("aria-level","2"));let C=document.createElement("p");C.className=`countdown_annoucement_bar_subheading_${e.id}`,C.textContent+=e.subheading;let T=document.createElement("div");T.append(x),T.append(C);let _=document.createElement("div"),S=document.createElement("a");S.className=`countdown_annoucement_bar_cta_${e.id}`,Shopify?.shop==="homonaturals-test.myshopify.com"||Shopify?.shop==="glapru-amsterdam.myshopify.com"?S.setAttribute("href",(e=>{if(e.includes("http://")||e.includes("https://"));else if(e.startsWith("/"))return e.replace("/",Shopify?.routes?.root||"/");return e})(e.CTALink)):S.setAttribute("href",e.CTALink),S.textContent+=e.buttonText;let A=document.createElement("button");A.className=`countdown_annoucement_bar_close_button_${e.id}`,A.setAttribute("onclick",`essentialCountdownCloseAnnouncementBar("${e.id}", "${e.updatedAt}")`),A.setAttribute("aria-label","Close timer bar"),A.append(function e(t){let n=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("width",12),n.setAttribute("height",12),n.setAttribute("fill","none"),o.setAttribute("d","m7.414 6 4.293-4.293A.999.999 0 1 0 10.293.293L6 4.586 1.707.293A.999.999 0 1 0 .293 1.707L4.586 6 .293 10.293a.999.999 0 1 0 1.414 1.414L6 7.414l4.293 4.293a.997.997 0 0 0 1.414 0 .999.999 0 0 0 0-1.414L7.414 6Z"),o.setAttribute("fill",t),n.append(o),n}(e.style.closeIconColor)),b.append(T),b.append(_),"button"===e.CTAType&&b.append(S),e.closeButton&&b.append(A);let N=document.querySelector(".essential-countdown-top-bar");N?N.append(b):t?t.append(b):document.querySelector("body").prepend(b),m(_,e),u(b,e)}async function $(e,t,n){if(n&&e.productTags&&e.productTags.length>0){let o=window.essentialProductTags||[],i=o.map(e=>e.toLowerCase()),r=e.productTags.some(e=>i.includes(e.toLowerCase()));if(!r)return!1}let a=e.excludeOnProducts?.find(e=>Number(e.id.split("/").pop())===window.essentialProductId);if(a)return!1;let l=document.querySelector(`.countdown_timer_wrapper_${e.id}`);if(l)return;let d=document.createElement("div");d.className=`countdown_timer_wrapper_${e.id}`;let c=document.createElement("h2");c.textContent+=e.title;let p=document.createElement("p");p.className=`countdown_timer_subheading_${e.id}`,p.textContent+=e.subheading;let g=document.createElement("div");d.append(c),e.subheading&&d.append(p),d.append(g),s(e),t.append(d),m(g,e),u(d,e)}function w(e,t,n=!0){let o=document.createElement("div");o.className=`countdown_timer_wrapper_${e.id}`;let i=document.createElement("h2");i.textContent+=e.title;let r=document.createElement("p");r.className=`countdown_timer_subheading_${e.id}`,r.textContent+=e.subheading;let a=document.createElement("div");"clickable"===e.CTAType&&e.CTALink&&(o.className+=" clickable",o.setAttribute("onclick",`essentialCountdownCloseAnnouncementBarOnClick(event, "${e.CTALink}")`));let l=document.createElement("a");l.className=`countdown_timer_bar_cta_${e.id}`,l.setAttribute("href",e.CTALink),l.textContent+=e.buttonText,o.append(i),o.append(r),o.append(a),"button"===e.CTAType&&o.append(l),s(e),n?t.append(o):t.prepend(o),m(a,e),u(o,e)}async function y(e,t,n){let o=await getCartEssentialApps();if(o&&o.item_count<1){try{window.localStorage.removeItem(`essentialCountdownTimer-${e.id}`)}catch(d){console.log(d)}return}let s=document.querySelector(".essential_countdown_cart_page_timer");if(s)return;let c=document.createElement("div");c.className=`essential_countdown_cart_page_timer countdown_cart_page_timer_wrapper_${e.id} essential_countdown_timer`;let m=document.createElement("div");c.append(m),t&&t.prepend(c),function e(t){let n=t.style,o=` .countdown_cart_page_timer_wrapper_${t.id} { ${l(n)} ${r(n)} margin-top: ${n.outsideTopSpacing}px; margin-bottom: ${n.outsideBottomSpacing}px; padding-top: ${n.insideTopSpacing}px; padding-bottom: ${n.insideBottomSpacing}px; padding-left: 10px; padding-right: 10px; border-radius: ${n.borderRadius}px; border: ${n.borderColor} solid ${n.borderSize}px; text-align: center; flex:auto; align-items: center; position: relative; overflow: hidden; } .countdown_cart_page_timer_wrapper_${t.id} .h2 { ${l(n)}font-weight: bold; font-size: ${n.titleSize}px; color: ${n.titleColor}; margin: 0; padding: 0; line-height: 1.2; letter-spacing: normal; text-transform: none; white-space: break-spaces; } .countdown_wrapper_${t.id} { white-space: nowrap; } .countdown_time_${t.id} { ${l(n)}color: ${n.timerColor}; font-weight: bold; font-size: ${n.timerSize}px; line-height: 1; font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums; }`;i(o)}(e),function e(t,n,o){let i=Number(new Date().getTime()),r,a={};try{r=window.localStorage.getItem(`essentialCountdownTimer-${n.id}`)}catch(l){console.log(l)}if(r){try{let d=JSON.parse(r);a={...a,...d}}catch(s){console.log(s)}a&&a.id===n.id&&a.updatedAt!==n.updatedAt&&(window.localStorage.removeItem(`essentialCountdownTimer-${n.id}`),r=null,a={...a,userDistance:null})}r&&parseInt(a.sessionCurrentDate)+6e4*n.fixedMinutes>i&&(i=parseInt(a.sessionCurrentDate)),h(p(i,a.userDistance,n,o),t,n);let c=setInterval(()=>{let e=p(i,a.userDistance,n,o);(n.repeat||"repeat"===n.onceItEnds)&&"fixedMinutes"===n.timerType&&!e?(a={...a,userDistance:0},i=Number(new Date().getTime())):e||clearInterval(c),h(p(i,a.userDistance,n,o),t,n)},1e3)}(m,e,o),u(c,e),n||setTimeout(()=>{a()},700)}function b(){let e,t=window?.Shopify?.routes?.root||"/",n=document.querySelector(`form[action="${t}cart"]`),o=document.querySelectorAll(".side-cart"),i=document.querySelector(".countdown-timer-side-cart");return n&&"cart-notification-form"===n.getAttribute("id")&&(n=null),i?e=i:n?e=n:o.length>0&&(e=o[o.length-1]),e}function x(e){if(e.startDate&&"fixedMinutes"!==e.timerType){let t=Number(new Date().getTime()),n=Number(S(e.startDate).getTime()),o=Number(S(e.endDate).getTime()),i=C(e)&&"today"===e.startType?n:Number(new Date(e.startDate).getTime());return(!C(e)||"today"!==e.startType||!(n>o))&&!(t>=i)}return!1}function C(e){return"recurring"===e.timerType}function T(e){if("do-nothing"===e.onceItEnds||"custom-title"===e.onceItEnds)return!0;let t=Number(new Date().getTime()),n=Number(S(e.startDate).getTime()),o=Number(S(e.endDate).getTime());return n1735570161e3?n0)||e.recurringDays.includes(t)}function S(e){let t=new Date,n=new Date(e).getHours(),o=new Date(e).getMinutes(),i=new Date(e).getSeconds();return t.setHours(n),t.setMinutes(o),t.setSeconds(i),t}!function n(){let i,r=window.location&&window.location.pathname.includes("/products/"),a=window.location&&window.location.pathname.includes("/collections/"),l=window.location&&window.location.pathname.includes("/password"),d=window.location&&window.location.pathname.includes("/cart"),s=document.querySelectorAll('form[action="/cart/add"]'),c=document.querySelector("#MainContent"),p=document.querySelector("main"),u=document.querySelector("form#contact_form"),m=document.querySelector(".essential-countdown-timer-placement"),g=c||p;if(s&&0===s.length){let h=document.querySelectorAll("form[action]");s=Array.from(h).filter(e=>e.getAttribute("action").includes("/cart/add"))}if(d){let S=window?.Shopify?.routes?.root||"/",A=document.querySelectorAll(`form[action="${S}cart"]`),N=A[A.length-1];N&&(i=N.parentNode)}let v=document.querySelectorAll("div.countdown-timer-block"),E=[],k=(e,n,o,i)=>{if(e.type!==n||o&&"custom"===e.timerPlacement||i&&e.productTags&&e.productTags.length>0)return!1;if(e.showOnProducts&&0!==e.showOnProducts.length){let r=decodeURI(window.location.pathname),a=window.meta&&window.meta.product,l=e.showOnProducts.find(e=>a&&a.gid?a.gid===e.id:"function"==typeof r.endsWith?r.endsWith(`products/${e.handle}`):r.includes(`products/${e.handle}`));if(!l)return!1}if(e.showOnProductsInCollections&&0!==e.showOnProductsInCollections.length){let d=t.productCollections||[],s=e.showOnProductsInCollections.find(e=>{let t=Number(e.id.split("/").pop());return d.some(e=>e.id===t)});if(!s)return!1}return!(x(e)||C(e)&&!_(e)||C(e)&&!T(e))},O=(e,t,n)=>{if(e.type!==t||n&&"custom"===e.timerPlacement||n&&"password-page"===e.timerPlacement)return!1;if(e.showOnCollections&&0!==e.showOnCollections.length){let o=decodeURI(window.location.pathname),i;if(!(i="american-uncle-alpha.myshopify.com"===Shopify.shop||"89be57-2.myshopify.com"===Shopify.shop||"anbernicbrazil.myshopify.com"===Shopify.shop||"playr-fit-teamwear.myshopify.com"===Shopify.shop||new Date(e.createdAt).getTime()>1730369064e3?essentialCollectionId&&e.showOnCollections.find(e=>e.id.includes(essentialCollectionId)):e.showOnCollections.find(e=>o.includes(`collections/${e.handle}`))))return!1}if(x(e)||C(e)&&!_(e)||C(e)&&!T(e))return!1;let r=e.excludeOnCollections?.find(e=>{let t=Number(e.id.split("/").pop());return window.essentialCollectionId===t});return!r},z=(e,t,n)=>!(e.type!==t||n&&""===e.timerPlacement||e.timerPlacement&&"password-page"!==e.timerPlacement||x(e)||C(e)&&!_(e)||C(e)&&!T(e)),P=(e,t,n)=>e.type===t&&(!n||"custom"!==e.timerPlacement);v&&v.length>0&&(E=Array.from(v).filter(e=>e&&""!==e.getAttribute("countdown-timer-id"))),o().then(async t=>{if(t&&!Array.isArray(t)&&0===t.length)return null;let n=t.reduce((e,t)=>t.showInCountries&&t.showInCountries.length?[...e,...t.showInCountries]:e,[]),o=t.find(e=>e.locationType&&"on-countries"===e.locationType),c=t.filter(t=>{if(!o||!(n.length>0))return t;if("on-countries"===t.locationType){if(!e)return;return t.showInCountries.includes(e)}if(!n.includes(e))return t});c.forEach(e=>{if(e.translations&&e.translations.length>0){let t=e.translations.find(e=>e.locale===Shopify?.locale);t&&Object.assign(e,t)}});let p=c.filter(e=>"top-bar"===e.type),h=c.find(e=>"cart-page"===e.type);if(p.forEach(e=>{e&&"custom"!==e.timerPlacement&&k(e,"top-bar")&&O(e,"top-bar")&&f(e)}),E.forEach(e=>{let t=e.getAttribute("countdown-timer-id"),n=c.find(e=>e.id===t&&"top-bar"===e.type);n&&k(n,"top-bar")&&O(n,"top-bar")&&f(n,e)}),(E=E.filter(e=>{let t=e.getAttribute("countdown-timer-id"),n=c.find(e=>e.id===t);return!n||!!n&&n?.type!=="top-bar"})).forEach(e=>{let t=e.getAttribute("countdown-timer-id"),n=c.find(e=>e.id===t);n&&k(n,"product-page")&&$(n,e,!0),n&&O(n,"landing-page")&&w(n,e),n&&"cart-page"===n.type&&y(n,e)}),0===E.length&&r&&(s&&s.length>0||m)){let x,C;C=m||s[s.length-1];let T=c.find(e=>e.productTags&&e.productTags.length>0),_;if(T){let S=window.essentialProductTags||[],A=S.map(e=>e.toLowerCase());_=c.filter(e=>e.productTags.some(e=>A.includes(e.toLowerCase())))}if(x=_&&_.length>0?_.find(e=>k(e,"product-page",!0)):c.find(e=>k(e,"product-page",!0,!0))){if(Shopify?.theme?.name&&Shopify.theme.name.toLowerCase().includes("debutify")&&x.createdAt&&new Date(x.createdAt).getTime()>1698142755e3&&!m){let N=document.querySelector("form.product-single__form"),v=document.querySelector('product-form form[action="/cart/add"]');N?C=N:v&&(C=v)}$(x,C)}}if(0===E.length&&a&&g){let I;(I=c.find(e=>O(e,"landing-page",!0)))&&w(I,g,!1)}if(0===E.length&&l&&u){let D;(D=c.find(e=>z(e,"landing-page",!0)))&&w(D,u)}if(0===E.length&&d){let q=c.find(e=>P(e,"cart-page",!0));i&&q&&y(q,i)}if(b()&&h&&!d){let B=b();if(B&&"custom"!==h.timerPlacement){y(h,B);let L=new MutationObserver(()=>{let e=document.querySelector(`.countdown_cart_page_timer_wrapper_${h.id}`);!e&&b()&&y(h,b(),!0)});if(!window.sideCartObserver&&B){let M;M=B.parentNode.parentNode.parentNode.parentNode&&"BODY"!==B.parentNode.parentNode.parentNode.parentNode.tagName&&"HTML"!==B.parentNode.parentNode.parentNode.parentNode.tagName?B.parentNode.parentNode.parentNode.parentNode:B.parentNode.parentNode.parentNode&&"BODY"!==B.parentNode.parentNode.parentNode.tagName&&"HTML"!==B.parentNode.parentNode.parentNode.tagName?B.parentNode.parentNode.parentNode:B.parentNode.parentNode&&"BODY"!==B.parentNode.parentNode.tagName&&"HTML"!==B.parentNode.parentNode.tagName?B.parentNode.parentNode:B.parentNode,window.cartTimerObserver=L,L.observe(M,{childList:!0,subtree:!0}),window.sideCartObserver=!0}}}if(!b()&&!d&&h)try{(timerSession=window.localStorage.getItem(`essentialCountdownTimer-${h.id}`))&&y(h,!1)}catch(j){console.log(j)}})}()}();