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,SACxBV,EAAOI,MAAMI,OAAS,EACtBR,EAAOI,MAAMO,WAAa,EAC1BX,EAAOI,MAAMQ,cAAgB,EAC7BZ,EAAOI,MAAMS,UAAY,EACzBb,EAAOI,MAAMU,aAAe,EAC5BC,OAAOC,YAAW,WACjBhB,EAAOI,MAAMa,QAAU,OACvBjB,EAAOI,MAAMc,eAAe,UAC5BlB,EAAOI,MAAMc,eAAe,eAC5BlB,EAAOI,MAAMc,eAAe,kBAC5BlB,EAAOI,MAAMc,eAAe,cAC5BlB,EAAOI,MAAMc,eAAe,iBAC5BlB,EAAOI,MAAMc,eAAe,YAC5BlB,EAAOI,MAAMc,eAAe,uBAC5BlB,EAAOI,MAAMc,eAAe,sBAC7B,GAAGjB,EACJ,CAeGkB,CAAQ/B,EAAS,KAEbQ,EACHwB,aAAaC,QAAQ,YAAa/B,KAAKgC,UAAU,CAAEC,QAAQ,KAE3DH,aAAaI,WAAW,YAE1B,IAEI5B,EAAgB,CACnB,IAAM6B,EAAgBnC,KAAK7B,MAAM2D,aAAaM,QAAQ,cAEjDD,SAAAA,EAAeF,SACnBnC,EAAQgB,MAAMa,QAAU,QAE1B,CAG+C,MAA3BxB,GAEnBkC,EAAUvC,EAAQjC,cAAc,cAAe,CAC9CJ,KAAM,GAAF6E,OAAKlC,EAAgB,KAAAkC,OAAIjC,KAM/BP,EAAQyC,gBAAgB,eACzB,CACD,G","sources":["webpack://header-promo/external var [\"wp\",\"i18n\"]","webpack://header-promo/./src/downCount.js","webpack://header-promo/./src/script.js"],"sourcesContent":["const __WEBPACK_NAMESPACE_OBJECT__ = wp.i18n;","import { __ } from '@wordpress/i18n';\r\n\r\nimport './downCount.scss';\r\n\r\nconst downCount = (container, options, callback) => {\r\n\tconst settings = Object.assign({ date: null, offset: null }, options);\r\n\r\n\tconst getText = (sl) => container.querySelector(sl).textContent;\r\n\tconst setText = (sl, val) => {\r\n\t\tcontainer.querySelector(sl).textContent = val;\r\n\t}\r\n\r\n\tif (!settings.date) {\r\n\t\tthrow new Error('Date is not defined.');\r\n\t}\r\n\r\n\tif (!Date.parse(settings.date)) {\r\n\t\tthrow new Error('Incorrect date format, it should look like this, 12/24/2012 12:00:00.');\r\n\t}\r\n\r\n\tconst currentDate = () => {\r\n\t\t// get the client's current date\r\n\t\tconst date = new Date();\r\n\r\n\t\t// turn the date to UTC\r\n\t\tconst utc = date.getTime() + (date.getTimezoneOffset() * 60000);\r\n\r\n\t\treturn new Date(utc + (3600000 * settings.offset)); // return a new Date object\r\n\t}\r\n\r\n\tfunction countdown() {\r\n\t\t// difference of dates\r\n\t\tconst difference = new Date(settings.date) - currentDate();\r\n\r\n\t\t// if the difference is negative, then it's past the target date\r\n\t\tif (difference < 0) {\r\n\t\t\t// stop the timer\r\n\t\t\tclearInterval(interval);\r\n\r\n\t\t\tif (callback && typeof callback === 'function') {\r\n\t\t\t\tcallback();\r\n\t\t\t}\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// basic math variables\r\n\t\tconst _second = 1000;\r\n\t\tconst _minute = _second * 60;\r\n\t\tconst _hour = _minute * 60;\r\n\t\tconst _day = _hour * 24;\r\n\r\n\t\t// calculate dates\r\n\t\tvar days = Math.floor(difference / _day);\r\n\t\tvar hours = Math.floor((difference % _day) / _hour);\r\n\t\tvar minutes = Math.floor((difference % _hour) / _minute);\r\n\t\tvar seconds = Math.floor((difference % _minute) / _second);\r\n\r\n\t\t// fix dates so that they will show two digits\r\n\t\tdays = (String(days).length >= 2) ? days : '0' + days;\r\n\t\thours = (String(hours).length >= 2) ? hours : '0' + hours;\r\n\t\tminutes = (String(minutes).length >= 2) ? minutes : '0' + minutes;\r\n\t\tseconds = (String(seconds).length >= 2) ? seconds : '0' + seconds;\r\n\r\n\t\t// based on the date change the reference wording\r\n\t\tvar refDays = days === '01' ? __('day', 'header-promo') : __('days', 'header-promo');\r\n\t\tvar refHours = hours === '01' ? __('hour', 'header-promo') : __('hours', 'header-promo');\r\n\t\tvar refMinutes = minutes === '01' ? __('minute', 'header-promo') : __('minutes', 'header-promo');\r\n\t\tvar refSeconds = seconds === '01' ? __('second', 'header-promo') : __('seconds', 'header-promo');\r\n\r\n\t\t// set the values to the DOM\r\n\t\tsetText('.days', days);\r\n\t\tsetText('.hours', hours);\r\n\t\tsetText('.minutes', minutes);\r\n\t\tsetText('.seconds', seconds);\r\n\r\n\t\tgetText('.days_ref') === 'days' && setText('.days_ref', refDays);\r\n\t\tgetText('.hours_ref') === 'hours' && setText('.hours_ref', refHours);\r\n\t\tgetText('.minutes_ref') === 'minutes' && setText('.minutes_ref', refMinutes);\r\n\t\tgetText('.seconds_ref') === 'seconds' && setText('.seconds_ref', refSeconds);\r\n\t}\r\n\r\n\t// start\r\n\tvar interval = setInterval(countdown, 1000);\r\n\r\n\t// Return the interval for later use or stopping the countdown if needed\r\n\treturn interval;\r\n}\r\nexport default downCount;\r\n\r\n// Example of usage:\r\n// var countdownContainer = document.querySelector('.countdown-container');\r\n// var options = {\r\n// \tdate: '12/24/2023 12:00:00', // Specify your target date here\r\n// \toffset: 0, // Set your desired offset\r\n// };\r\n\r\n// var interval = downCount(countdownContainer, options, function () {\r\n// \t// Callback function when the countdown is complete\r\n// \tconsole.log('Countdown is complete!');\r\n// });","import downCount from './downCount';\r\nimport './style.scss';\r\n\r\nconst slideUp = (target, duration = 500) => {\r\n\ttarget.style.transitionProperty = 'height, margin, padding';\r\n\ttarget.style.transitionDuration = duration + 'ms';\r\n\ttarget.style.boxSizing = 'border-box';\r\n\ttarget.style.height = target.offsetHeight + 'px';\r\n\ttarget.offsetHeight;\r\n\ttarget.style.overflow = 'hidden';\r\n\ttarget.style.height = 0;\r\n\ttarget.style.paddingTop = 0;\r\n\ttarget.style.paddingBottom = 0;\r\n\ttarget.style.marginTop = 0;\r\n\ttarget.style.marginBottom = 0;\r\n\twindow.setTimeout(() => {\r\n\t\ttarget.style.display = 'none';\r\n\t\ttarget.style.removeProperty('height');\r\n\t\ttarget.style.removeProperty('padding-top');\r\n\t\ttarget.style.removeProperty('padding-bottom');\r\n\t\ttarget.style.removeProperty('margin-top');\r\n\t\ttarget.style.removeProperty('margin-bottom');\r\n\t\ttarget.style.removeProperty('overflow');\r\n\t\ttarget.style.removeProperty('transition-duration');\r\n\t\ttarget.style.removeProperty('transition-property');\r\n\t}, duration);\r\n}\r\n\r\n\r\ndocument.addEventListener('DOMContentLoaded', () => {\r\n\tconst promoEl = document.getElementById('promo-outer');\r\n\tif (promoEl) {\r\n\t\tconst options = JSON.parse(promoEl.dataset.options);\r\n\t\tconst { promoStopReappear, promo_countdown_off_on, promo_count_date, promo_count_time } = options;\r\n\r\n\t\tconst isStopReappear = promoStopReappear === '1'; // Is Stop Reappear enabled\r\n\r\n\t\tconst closeEl = promoEl.querySelector('#close');\r\n\t\tcloseEl.addEventListener('click', () => {\r\n\t\t\tpromoEl.classList.remove('promoOpened');\r\n\t\t\tpromoEl.classList.add('promoClosed');\r\n\t\t\tslideUp(promoEl, 400);\r\n\r\n\t\t\tif (isStopReappear) {\r\n\t\t\t\tlocalStorage.setItem('bphpPromo', JSON.stringify({ closed: true }));\r\n\t\t\t} else {\r\n\t\t\t\tlocalStorage.removeItem('bphpPromo');\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif (isStopReappear) {\r\n\t\t\tconst bphpPromoData = JSON.parse(localStorage.getItem('bphpPromo'));\r\n\r\n\t\t\tif (!bphpPromoData?.closed) {\r\n\t\t\t\tpromoEl.style.display = 'block';\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Countdown\r\n\t\tconst isCountdown = promo_countdown_off_on === '1';\r\n\t\tif (isCountdown) {\r\n\t\t\tdownCount(promoEl.querySelector('.countdown'), {\r\n\t\t\t\tdate: `${promo_count_date} ${promo_count_time}`,\r\n\t\t\t\t// offset: +6\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t// Remove options\r\n\t\tpromoEl.removeAttribute('data-options');\r\n\t}\r\n});"],"names":["wp","i18n","container","options","callback","settings","Object","assign","date","offset","getText","sl","querySelector","textContent","setText","val","Error","Date","parse","interval","setInterval","utc","difference","getTime","getTimezoneOffset","clearInterval","_minute","_second","_hour","_day","days","Math","floor","hours","minutes","seconds","String","length","refDays","__","refHours","refMinutes","refSeconds","document","addEventListener","promoEl","getElementById","JSON","dataset","promoStopReappear","promo_countdown_off_on","promo_count_date","promo_count_time","isStopReappear","classList","remove","add","target","duration","arguments","undefined","style","transitionProperty","transitionDuration","boxSizing","height","offsetHeight","overflow","paddingTop","paddingBottom","marginTop","marginBottom","window","setTimeout","display","removeProperty","slideUp","localStorage","setItem","stringify","closed","removeItem","bphpPromoData","getItem","downCount","concat","removeAttribute"],"sourceRoot":""}