function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,a,r,s,o=[],c=!0,l=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;c=!1}else for(;!(c=(n=r.call(i)).done)&&(o.push(n.value),o.length!==t);c=!0);}catch(e){l=!0,a=e}finally{try{if(!c&&null!=i.return&&(s=i.return(),Object(s)!==s))return}finally{if(l)throw a}}return o}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _createForOfIteratorHelper(e,t){var i,n,a,r,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return a=!(n=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return n=e.done,e},e:function(e){a=!0,i=e},f:function(){try{n||null==s.return||s.return()}finally{if(a)throw i}}};if(Array.isArray(e)||(s=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),r=0,{s:t=function(){},n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var i;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(i="Object"===(i={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i{e(document).ready(function(e){new CountDownTimer(e)})})(jQuery,window);var defaultStyles={classic:{labelsColor:"",digitsColor:"#444444",digitsBackground:"",borderColor:"",fontSizeDigits:16,fontSizeLabels:16},progress:{labelsColor:"",digitsColor:"#3858E9",digitsBackground:"#3858E9",borderColor:"",progressColor:"#3858E9",fontSizeDigits:16,fontSizeLabels:16},circles:{labelsColor:"#7C7C7C",digitsColor:"#000",digitsBackground:"#fff",borderColor:"#444444",progressColor:"#3858E9",fontSizeDigits:22,fontSizeLabels:10,width:80,height:80},squares:{labelsColor:"#180B40",digitsColor:"#000",digitsBackground:"#fff",borderColor:"#000000",fontSizeDigits:28,fontSizeLabels:12,width:65,height:65},minimalist:{labelsColor:"#7C7C7C",digitsColor:"#000000",digitsBackground:"#F6F7F7",borderColor:"",fontSizeDigits:40,fontSizeLabels:12,width:80,height:80},cards:{labelsColor:"#3858E9",digitsColor:"#3858E9",digitsBackground:"#E0E2EC",borderColor:"#000000",fontSizeDigits:40,fontSizeLabels:12,width:80,height:80},modern:{labelsColor:"#180B40",digitsColor:"#fff",digitsBackground:"#180B40",borderColor:"",fontSizeDigits:36,fontSizeLabels:12,width:80,height:95}},CountDownTimer=(()=>_createClass(function e(t){_classCallCheck(this,e),this.countDownWrapper=t(".merchant-countdown-timer"),this.countDownTimer=this.countDownWrapper.find(".merchant-countdown-timer-countdown"),this.countDownTimer.length&&(this.total,this.days,this.hours,this.minutes,this.seconds,this.currentTimeInitial=this.getCurrentTime(),this.theme=this.countDownWrapper.attr("data-theme"),this.timerType=this.countDownWrapper.attr("data-countdown-type"),this.startDate=new Date(this.countDownWrapper.attr("data-start-date")||null),this.endDate=new Date(this.countDownWrapper.attr("data-end-date")||null),this.startTime=this.startDate.getTime(),this.endTime=this.endDate.getTime(),this.minExpiration=parseInt(this.countDownWrapper.attr("data-min-expiration")),this.maxExpiration=parseInt(this.countDownWrapper.attr("data-max-expiration")),this.offPeriod=parseInt(this.countDownWrapper.attr("data-off-period")),this.timerCookie="merchant_countdown_timer",this.timerOffPeriodCookie="merchant_countdown_timer_off_period",this.variationsDates=this.countDownWrapper.attr("data-variations-dates"),this.variationsDates=this.variationsDates?JSON.parse(this.variationsDates):[],this.flipTimerKeys={days:{value:"",currentValue:""},hours:{value:"",currentValue:""},minutes:{value:"",currentValue:""},seconds:{value:"",currentValue:""}},null!=(t=merchant)&&t.is_admin&&(this.deleteCookie(this.timerCookie),this.deleteCookie(this.timerOffPeriodCookie)),this.init())},[{key:"init",value:function(){this.buildTimerMarkup(),this.setTimerData(),this.startTimer(),this.events()}},{key:"events",value:function(){this.updateVariationTimer(),this.updateAdminPreview()}},{key:"buildTimerMarkup",value:function(){var e=["classic","progress"].includes(this.theme)?"":"circles"===this.theme?'\n
\n \n \n \n \n
\n 00\n Days\n
\n
\n
\n \n \n \n \n
\n 00\n Hours\n
\n
\n
\n \n \n \n \n
\n 00\n Minutes\n
\n
\n
\n \n \n \n \n
\n 00\n Seconds\n
\n
\n ':"modern"===this.theme?'\n
\n
\n
\n
\n 00\n \n \n \n
\n
\n Days\n
\n\n
\n
\n
\n 00\n \n \n \n
\n
\n Hours\n
\n\n
\n
\n
\n 00\n \n \n \n
\n
\n Minutes\n
\n \n
\n
\n
\n 00\n \n \n \n
\n
\n Seconds\n
\n\n
\n ':'\n
\n 00\n Days\n
\n
\n 00\n Hours\n
\n
\n 00\n Minutes\n
\n
\n 00\n Seconds\n
\n ';this.countDownWrapper.find(".cd-progress").remove(),this.countDownTimer.html(e),"progress"===this.theme&&jQuery('').insertBefore(this.countDownTimer)}},{key:"setTimerData",value:function(){var e,t,i,n,a;"sale-dates"===this.timerType?this.endTime=this.endDate.getTime():"evergreen"===this.timerType&&(e=this.getCookie(this.timerCookie),t=this.getCookie(this.timerOffPeriodCookie),i=1e3*this.getRandomValueForCountDown(this.minExpiration,this.maxExpiration),i=this.getCurrentTime()+i,n=new Date(i),a=i+1e3*this.offPeriod,!(!e&&t)?e?(this.endTime=new Date(e).getTime(),t||this.setCookie(this.timerOffPeriodCookie,this.offPeriod,a)):(this.setCookie(this.timerCookie,n,i),this.setCookie(this.timerOffPeriodCookie,this.offPeriod,a),this.endTime=n.getTime()):(this.endTime=0,this.displayTimer(0)))}},{key:"startTimer",value:function(){var e=this.getRemainingTime();e?this.displayTimer(e,this.timerEnd):this.timerEnd(),"circles"===this.theme?this.progressCircles():"progress"===this.theme&&this.progressBar()}},{key:"displayTimer",value:function(e,t){t=t||function(){};var i=["classic","progress"].includes(this.theme);this.days=Math.floor(e/864e5),this.days=i?this.days:this.days.toString().padStart(2,"0"),this.hours=Math.floor(e%864e5/36e5).toString().padStart(2,"0"),this.minutes=Math.floor(e%36e5/6e4).toString().padStart(2,"0"),this.seconds=Math.floor(e%6e4/1e3).toString().padStart(2,"0"),i?this.countDownTimer.find("span").html("".concat(this.days," days ").concat("progress"===this.theme?" : ":""," ").concat(this.hours,":").concat(this.minutes,":").concat(this.seconds)):"modern"===this.theme?this.flipTimer():(this.countDownTimer.find(".cd-days .cd-value").html(this.days).attr("data-time",this.days),this.countDownTimer.find(".cd-hours .cd-value").html(this.hours).attr("data-time",this.hours),this.countDownTimer.find(".cd-minutes .cd-value").html(this.minutes).attr("data-time",this.minutes),this.countDownTimer.find(".cd-seconds .cd-value").html(this.seconds).attr("data-time",this.seconds)),e<=0?t.call(this):(this.countDownWrapper.show(),setTimeout(this.startTimer.bind(this),1e3))}},{key:"timerEnd",value:function(){var e;null!=(e=merchant)&&e.is_admin?this.countDownWrapper.show():this.countDownWrapper.hide(),this.displayTimer(0),this.deleteCookie(this.timerCookie)}},{key:"updateVariationTimer",value:function(){var n,a;"sale-dates"===this.timerType&&(n=jQuery,a=this,n('input[name="variation_id"]').on("change",function(){var e,t,i=parseInt(n(this).val());i&&a.variationsDates.length&&(e=(t=a.variationsDates.find(function(e){return parseInt(null==e?void 0:e.id)===i})||{}).start,t=t.end,e="object"===_typeof(e)?null==e?void 0:e.date:e,t="object"===_typeof(t)?null==t?void 0:t.date:t,a.startTime=e?new Date(e).getTime():0,a.endTime=t?new Date(t).getTime():0,a.displayTimer(0),a.startTimer())}))}},{key:"flipTimer",value:function(){var o=this;this.countDownTimer.find(".cd-flip-card").each(function(){var e,t,i,n=jQuery(this),a="",r=(Object.keys(o.flipTimerKeys).forEach(function(e){if(n.hasClass("cd-"+e))return a=e,!1}),o.flipTimerKeys[a].currentValue),s=o[a];s!==r&&(e=n.find(".cd-flip-card-top"),t=n.find(".cd-flip-card-back"),i=n.find(".cd-flip-card-back .cd-flip-card-bottom"),0<=r&&t.attr("data-time",r),o.flipTimerKeys[a].currentValue=s,e.html(s),i.attr("data-time",s),n.removeClass("cd-flipped"),n[0].offsetWidth,n.addClass("cd-flipped"))})}},{key:"getCurrentTime",value:function(){var e=!(0e||this.endTime