define(["core","jquery"],function(a,b){return a.create_module("timeLeft",function(g){var d,e,c,f; return{el:{clock:b("[data-timerclock]",c)},options:{desktopPosition:"#timeLeftDesktop",lessThanDesktopPosition:"#timeLeftlessThanDesktop"},currentView:false,init:function(j){d=this; e=j;c=g.getContainer();var l=d.getTimerDuration(),k,h=g.now(),i;d.currentView=g.getCurrentView(); g.listen({"disable-timer":d.disable,"view-resized":d.view.viewResized});d.initLibraryFunctions(); d.view.viewResized();d.view.displayTimer(l);k=setInterval(function(){i=g.now();l-=Math.round((i-h)/1000); h=i;if(l<1&&!f){clearInterval(k);d.notify_disableSubmit();d.notify_timeOutLightBox(); }else{d.view.displayTimer(l);}},1000);},disable:function(){f=true;},initLibraryFunctions:function(){g.library({name:["moveModule"]},g); d.library.moveModule.init();},getTimerDuration:function(){if(typeof e.secondsUntilCartExpires==="number"){return e.secondsUntilCartExpires; }},addLeadingZero:function(h){return("0"+h).slice(-2);},notify_disableSubmit:function(){g.notify({type:"submit-disable"}); },notify_timeOutLightBox:function(){g.notify({type:"show-timeOutLightBox"});},view:{displayTimer:function(j){var h=d.addLeadingZero(parseInt(j/60)),i=d.addLeadingZero(parseInt(j%60)); d.el.clock.html(h+":"+i);},viewResized:function(){d.currentView=g.checkMatchMedia("lessThanDesktop")?"notDesktop":"desktop"; if(d.currentView==="desktop"){d.library.moveModule.to(d.options.desktopPosition); }else{d.library.moveModule.to(d.options.lessThanDesktopPosition);}}},destroy:function(){d=null; }};});});