@abtasty/countdown 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Engage Plugin Base
package/dist/form.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).widgetForm=t()}(this,(function(){"use strict";return[{type:"selectelement",propName:"selector",label:{en:"Select the element that will host the widget",fr:"Veuillez sélectionner l'élément de la page qui accueillera le widget",es:"Selecciona el elemento donde incluir el widget",de:"Wählen Sie das Element aus, dass das Widget enthalten soll"},value:"nav"},{type:"group",label:{en:"Date & Time",fr:"Date et heure de fin",es:"Fecha y hora",de:"Datum & Zeit"},children:[{propName:"dateStart",type:"datepicker",value:new Date},{propName:"timeStart",type:"timepicker",value:new Date},{propName:"timezoneOffset",type:"hidden",value:(new Date).getTimezoneOffset()},{propName:"timezoneName",type:"hidden",value:Intl.DateTimeFormat().resolvedOptions().timeZone}]}]}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).widgetForm=t()}(this,(function(){"use strict";return[{type:"selectelement",propName:"selector",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},{type:"group",label:{en:"Date & Time",fr:"Date et heure de fin",es:"Fecha y hora",de:"Datum & Zeit"},children:[{propName:"dateStart",type:"datepicker",value:new Date},{propName:"timeStart",type:"timepicker",value:new Date},{propName:"timezoneOffset",type:"hidden",value:(new Date).getTimezoneOffset()},{propName:"timezoneName",type:"hidden",value:Intl.DateTimeFormat().resolvedOptions().timeZone}]}]}));
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var e=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},n=s.iterator||"@@iterator",i=s.asyncIterator||"@@asyncIterator",o=s.toStringTag||"@@toStringTag";function a(e,t,r,s){var n=t&&t.prototype instanceof l?t:l,i=Object.create(n.prototype),o=new S(s||[]);return i._invoke=function(e,t,r){var s="suspendedStart";return function(n,i){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===n)throw i;return L()}for(r.method=n,r.arg=i;;){var o=r.delegate;if(o){var a=b(o,r);if(a){if(a===h)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===s)throw s="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);s="executing";var l=c(e,t,r);if("normal"===l.type){if(s=r.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(s="completed",r.method="throw",r.arg=l.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=a;var h={};function l(){}function u(){}function d(){}var g={};g[n]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(T([])));v&&v!==t&&r.call(v,n)&&(g=v);var f=d.prototype=l.prototype=Object.create(g);function p(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function y(e){var t;this._invoke=function(s,n){function i(){return new Promise((function(t,i){!function t(s,n,i,o){var a=c(e[s],e,n);if("throw"!==a.type){var h=a.arg,l=h.value;return l&&"object"==typeof l&&r.call(l,"__await")?Promise.resolve(l.__await).then((function(e){t("next",e,i,o)}),(function(e){t("throw",e,i,o)})):Promise.resolve(l).then((function(e){h.value=e,i(h)}),(function(e){return t("throw",e,i,o)}))}o(a.arg)}(s,n,t,i)}))}return t=t?t.then(i,i):i()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var s=c(r,e.iterator,t.arg);if("throw"===s.type)return t.method="throw",t.arg=s.arg,t.delegate=null,h;var n=s.arg;return n?n.done?(t[e.resultName]=n.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):n:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function T(e){if(e){var t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var s=-1,i=function t(){for(;++s<e.length;)if(r.call(e,s))return t.value=e[s],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return u.prototype=f.constructor=d,d.constructor=u,d[o]=u.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===u||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(f),e},e.awrap=function(e){return{__await:e}},p(y.prototype),y.prototype[i]=function(){return this},e.AsyncIterator=y,e.async=function(t,r,s,n){var i=new y(a(t,r,s,n));return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},p(f),f[o]="Generator",f[n]=function(){return this},f.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var s=t.pop();if(s in e)return r.value=s,r.done=!1,r}return r.done=!0,r}},e.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function s(r,s){return o.type="throw",o.arg=e,t.next=r,s&&(t.method="next",t.arg=void 0),!!s}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return s("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return s(i.catchLoc,!0);if(this.prev<i.finallyLoc)return s(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return s(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return s(i.finallyLoc)}}}},abrupt:function(e,t){for(var s=this.tryEntries.length-1;s>=0;--s){var n=this.tryEntries[s];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var s=r.completion;if("throw"===s.type){var n=s.arg;E(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function t(e,t,r,s,n,i,o){try{var a=e[i](o),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(s,n)}var r=function(e){return function(){var r=this,s=arguments;return new Promise((function(n,i){var o=e.apply(r,s);function a(e){t(o,n,i,a,c,"next",e)}function c(e){t(o,n,i,a,c,"throw",e)}a(void 0)}))}};const s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID],n=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const i=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},o=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,a=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},c=(e,t,r)=>{let s=0,n=0;try{document.querySelector(e)}catch(t){const s=`Selector «${e}» not valid.`;return a(s),"function"==typeof r&&r(s)}function i(){clearInterval(n),clearTimeout(s)}return s=setTimeout(()=>{i();const t=`Can't find element «${e}».`;return a(t),"function"==typeof r&&r(t)},1e4),n=setInterval(()=>{const r=document.querySelector(e);return null!==r?(i(),"function"==typeof t&&t(r)):r},200),{clear:i}};async function h(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(e){return new Promise((t,r)=>{const s=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");n.src=e,s.parentNode.insertBefore(n,s),n.onload=t,n.onerror=r})}(""));break;default:t=!0}return t}class l{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:r},s){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(r),this.onSetCallback=s,this.widgetName=i(),this.uniqueId=o(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:r,...s}=t;return Object.entries(s).length?(e.setItem("ABTastyWidgets",JSON.stringify(s)),s):(e.removeItem("ABTastyWidgets"),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const r=this.getTypeOfStorage(e);if(!r&&"object"!=typeof r)return!1;const{storageString:s,storageMethod:n}=this.getTypeOfStorage(e),i=this.getStamp(e),o={type:t,stamp:i},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let r;"session"===s?e?r=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),r=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?r=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),r=this.getLocalRecurrenceStorageParsed()));const i=r?{[this.recurrenceKey]:o,...r}:{[this.recurrenceKey]:o};n.setItem("ABTastyWidgets",JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!n)return!1;if(a&&"validation"!==t)if("closing"===t&&"validation"!==a)c();else{if("display"!==t||"validation"===a||"closing"===a)return!1;c()}else c();return i}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class u{constructor(){this.targets=[],this.existingTargets=[],this.inViewPortTargets=[],this.visibilityobserver=this.startVisibilityObserver(),this.mutationobserver=this.startMutationObserver()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets=this.existingTargets.filter(t=>t.element!==e.target||(this.inViewPortTargets.push(t),!1)),this.checkElements()):this.inViewPortTargets=this.inViewPortTargets.filter(t=>t.element!==e.target||(this.existingTargets.push(t),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=new MutationObserver(this.checkElements.bind(this));return e.observe(document,{attributes:!0,childList:!0,subtree:!0}),e}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===function e(t,r){return r(t)||!t.parentElement?t:e(t.parentElement,r)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),r=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let s=!1,n=0;for(;!s&&n<r.length;){const t=document.elementFromPoint(...r[n]);s=e===t||e.contains(t),n+=1}return s}checkElements(){this.targets=this.targets.filter(e=>{const t=document.querySelector(e.selector);return!t||(this.existingTargets.push(Object.assign(e,{element:t})),this.visibilityobserver.observe(t),!1)}),this.existingTargets=this.existingTargets.filter(e=>!!document.querySelector(e.selector)||(this.visibilityobserver.unobserve(e.element),this.targets.push(e),!1)),this.inViewPortTargets=this.inViewPortTargets.filter(({element:e,resolve:t})=>!this.isElementVisible(e)||(this.visibilityobserver.unobserve(e),t(e),!1))}watch(e,t){this.targets.push({selector:e,resolve:t})}clear(e){const t=this.targets.filter(t=>t.selector!==e);0===t.length&&(this.existingTargets=[],this.inViewPortTargets=[],this.mutationobserver.disconnect(),this.visibilityobserver.unobserve(e)),this.targets.length>t&&(this.targets=t,this.visibilityobserver.unobserve(e))}}class d{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:r}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=r,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}static promiseDeferrer(e){const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}async onElementVisible(){const e=d.promiseDeferrer("onElementVisible");this.promises.push(e);const t=await this.onPageLoad(),r=await h("IntersectionObserver"),s=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",u);return this.visibilityObservers.push(s),r&&t&&s.watch(this.selector,e.resolve),e.promise}onPageLoad(){const e=d.promiseDeferrer("onPageLoad");this.promises.push(e);const t=()=>"complete"===document.readyState;if(t())e.resolve(!0);else{const r=()=>t()&&!clearTimeout(s)&&!e.resolve(!0),s=setTimeout(()=>e.resolve(!1),2e4),n=["readystatechange",r,{passive:!0}];this.timeouts.push(s),this.eventsListeners.push(n),document.addEventListener(...n)}return e.promise}onClick(){const e=document.createElement("style");e.type="text/css",e.id=`Click_${o()}`,e.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(e),this.elementsSelectors.push(`#${e.id}`);const t=d.promiseDeferrer("onClick");this.promises.push(t);const r=()=>[...document.querySelectorAll(this.selector)],s=e=>r().some(t=>t.isSameNode(e)||!!e.closest(this.selector)),n=["click",({target:e})=>!!s(e)&&(t.resolve(!0),this.clear()),{passive:!0,capture:!0}];return this.eventsListeners.push(n),document.addEventListener(...n),t.promise}onExitIntent(){const e=d.promiseDeferrer("onExitIntent");this.promises.push(e);const t=["mouseleave",async()=>{if(this.delay){const t=1e3*this.delay,r=setTimeout(()=>{e.resolve(!0)},t);this.timeouts.push(r)}else e.resolve(!0)},{passive:!0,once:!0}],r=c("body",e=>{e.addEventListener(...t),this.eventsListeners.push([e,...t]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==r)});return this.elementsWaiters.push(r),e.promise}onDelay(){const e=d.promiseDeferrer("onDelay");this.promises.push(e);const t=1e3*this.delay,r=setTimeout(()=>{e.resolve(!0)},t);return this.timeouts.push(r),e.promise}onReengage(){const e=d.promiseDeferrer("onReengage");this.promises.push(e);const t=1e3*this.delay;let r=t;const s=[()=>(r=t,r),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...s),this.eventsListeners.push([e,...s])});const n=setInterval(()=>{r<=0?e.resolve(!0):r-=100},100);return this.intervals.push(n),e.promise}clear(){return this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...r]="string"==typeof e[0]?[document,...e]:e;t&&r.length>1&&t.removeEventListener(...r)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length&&(this.visibilityObservers.forEach(e=>e.clear(this.selector)),this.visibilityObservers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){let e;switch(this.clear(),this.event){case"pageLoad":e=await this.onPageLoad(),this.clear();break;case"click":e=await this.onClick(),this.clear();break;case"exitIntent":e=await this.onExitIntent(),this.clear();break;case"delay":e=await this.onDelay(),this.clear();break;case"reengage":e=await this.onReengage(),this.clear();break;case"elementVisible":e=await this.onElementVisible(),this.clear();break;default:e=!1}return e}}class g{constructor(e,t,r){this.recurrence=e,this.isWidgetApplied=t,this.callback=r,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=s(),{type:r}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},n=()=>e&&"display"===r||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&n()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&n())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=s();return[250,500].forEach(t=>setTimeout(()=>500===t&&s()===e?this:(e=s(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),r=e.some(({addedNodes:e})=>e&&e.length);return t||r?(this.decisionHandler(!0),this):this}watch(){if(n())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const e=c("body",t=>{const r=[t,{childList:!0,subtree:!0}];this.observer.observe(...r),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});return this.elementsWaiters.push(e),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const m=["pageLoad","delay","reengage"];class v extends class{constructor(){this.uniqueId=o(),this.widgetName=i(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:t,validationRecurrence:r}=DATA;return!(n()||!(e||t||r))&&{displayRecurrence:e,closingRecurrence:t,validationRecurrence:r}})(),this.triggerParams=(()=>{const{triggerEvent:e,triggerEventClick:t,triggerEventExitDelay:r,triggerEventDelay:s,triggerEventReengageDelay:i}=DATA;if(n()||!e)return!1;const o=t;let a;switch(e){case"exitIntent":a=r;break;case"delay":a=s;break;case"reengage":a=i;break;default:a=0}return{triggerEvent:e,triggerSelector:o,triggerDelay:a}})(),this.recurrence=!!this.recurrenceParams&&new l(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new d(this.triggerParams),this.pageWatcher=new g(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=!!this.trigger&&m.some(e=>e===this.trigger.event),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(e){const t=document.getElementById(e);t&&t.remove()}insert(){const e=c("head",t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),t.appendChild(this.styleElement)),t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),a(t))),t=c("body",e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),this.removeOldDomElement(this.domElement.id),e.appendChild(this.domElement)),e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),a(e)));return this.elementsWaiters.push(e,t),this}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():n()||this.init().then(e=>e?this.show():this),this}show(){return this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(){if(!n()&&!s())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const e=this.recurrence&&this.recurrence.isOver();return this.recurrence&&!e?(this.pageWatcher.watch(),!1):(this.pageWatcher.watch(),!!(n()||!this.trigger||this.trigger&&await this.trigger.isTriggered())&&(this.insert(),this.addCloseEvent(),this))}onPageChange(e,t){const r=()=>this.init().then(e=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().show():r()}}addCloseEvent(...e){const t=this.domElement.querySelectorAll(`\n\t\t\t.${this.overlayClassName},\n\t\t\t.${this.closeButtonClassName}\n\t\t`);return e.push(...t),e.forEach(e=>{e.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this}getDom(){const e=document.createElement("div");return e.className=`${this.basicClassName} ${this.hideClassName}`,e.id=this.widgetContainerId,e.innerHTML=`\n\t\t\t<div class="${this.overlayClassName}"></div>\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t<button class="${this.closeButtonClassName}" ${n()?"data-abtasty-actionnable":""}>+</button>\n\t\t\t</div>`,e}getStyleTag(e=""){const t=document.createElement("style");return t.type="text/css",n()&&t.setAttribute("abtasty-script-added","true"),t.textContent=`\n\t\t\t.${this.hideClassName} {opacity: 0 !important; pointer-events: none;}\n\t\t\t${e}`,t}}{constructor(e,t){super(),this.position=e,this.referrerElement=t,this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}insert(){const e=c("head",t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),t.appendChild(this.styleElement)),t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),a(t))),t=c(this.referrerElement,e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),this.removeOldDomElement(this.domElement.id),e.insertAdjacentElement(this.position,this.domElement)),e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),a(e)));return this.elementsWaiters.push(e,t),this}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tposition: relative;\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}`}}var f=function(e){if(Array.isArray(e))return e};var p=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],s=!0,n=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(s=(o=a.next()).done)&&(r.push(o.value),!t||r.length!==t);s=!0);}catch(e){n=!0,i=e}finally{try{s||null==a.return||a.return()}finally{if(n)throw i}}return r}};var y=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var b=function(e,t){return f(e)||p(e,t)||y()};var w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function E(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var S=function(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e},T=function(e){var t=Object.prototype.hasOwnProperty;function r(e,s){return Array.isArray(e)?function(e,t){for(var s,n="",i="",a=Array.isArray(t),c=0;c<e.length;c++)(s=r(e[c]))&&(a&&t[c]&&(s=o(s)),n=n+i+s,i=" ");return n}(e,s):e&&"object"==typeof e?function(e){var r="",s="";for(var n in e)n&&e[n]&&t.call(e,n)&&(r=r+s+n,s=" ");return r}(e):e||""}function s(e){if(!e)return"";if("object"==typeof e){var r="";for(var s in e)t.call(e,s)&&(r=r+s+":"+e[s]+";");return r}return e+""}function n(e,t,r,s){if(!1===t||null==t||!t&&("class"===e||"style"===e))return"";if(!0===t)return" "+(s?e:e+'="'+e+'"');var n=typeof t;return"object"!==n&&"function"!==n||"function"!=typeof t.toJSON||(t=t.toJSON()),"string"==typeof t||(t=JSON.stringify(t),r||-1===t.indexOf('"'))?(r&&(t=o(t))," "+e+'="'+t+'"'):" "+e+"='"+t.replace(/'/g,"&#39;")+"'"}e.merge=function e(t,r){if(1===arguments.length){for(var n=t[0],i=1;i<t.length;i++)n=e(n,t[i]);return n}for(var o in r)if("class"===o){var a=t[o]||[];t[o]=(Array.isArray(a)?a:[a]).concat(r[o]||[])}else if("style"===o){a=(a=s(t[o]))&&";"!==a[a.length-1]?a+";":a;var c=s(r[o]);c=c&&";"!==c[c.length-1]?c+";":c,t[o]=a+c}else t[o]=r[o];return t},e.classes=r,e.style=s,e.attr=n,e.attrs=function(e,i){var o="";for(var a in e)if(t.call(e,a)){var c=e[a];if("class"===a){c=r(c),o=n(a,c,!1,i)+o;continue}"style"===a&&(c=s(c)),o+=n(a,c,!1,i)}return o};var i=/["&<>]/;function o(e){var t=""+e,r=i.exec(t);if(!r)return e;var s,n,o,a="";for(s=r.index,n=0;s<t.length;s++){switch(t.charCodeAt(s)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;case 62:o="&gt;";break;default:continue}n!==s&&(a+=t.substring(n,s)),n=s+1,a+=o}return n!==s?a+t.substring(n,s):a}return e.escape=o,e.rethrow=function e(t,r,s,n){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&r||n))throw t.message+=" on line "+s,t;try{n=n||require("fs").readFileSync(r,"utf8")}catch(r){e(t,null,s)}var i=3,o=n.split("\n"),a=Math.max(s-i,0),c=Math.min(o.length,s+i);i=o.slice(a,c).map((function(e,t){var r=t+a+1;return(r==s?" > ":" ")+r+"| "+e})).join("\n");throw t.path=r,t.message=(r||"Pug")+":"+s+"\n"+i+"\n\n"+t.message,t},e}({});var L=["fr","en","de","es"],x=["day","hour","minute","second"],R={day:{en:"Day",fr:"Jour",es:"Dia",de:"Tag"},days:{en:"Days",fr:"Jours",es:"Dias",de:"Tage"},hour:{en:"Hour",fr:"Heure",es:"Hora",de:"Zeit"},hours:{en:"Hours",fr:"Heures",es:"Horas",de:"Stunden"},minute:"Min",second:{en:"Sec",fr:"Sec",es:"Seg",de:"Sek"}},C={"01":"Jan","02":"Feb","03":"Mar","04":"Apr","05":"May","06":"Jun","07":"Jul","08":"Aug","09":"Sep",10:"Oct",11:"Nov",12:"Dec"},A=window.ABTASTY_S&&ABTASTY_S.USER&&ABTASTY_S.USER.lang?ABTASTY_S.USER.lang.split("_")[0]:navigator.language.substr(0,2)||"en",O=function(e){return L.indexOf(e)>-1}(A)?A:"en",W={day:R.day[O],days:R.days[O],hour:R.hour[O],hours:R.hours[O],minute:R.minute,minutes:R.minute,second:R.second[O],seconds:R.second[O]},P=function(e,t){return new Date(e).toLocaleString("fr-FR",{timezone:t}).replace(/[^ -~]/g,"")},k=function(e){var t=function(e,t){return P(e,t)}(e).split(" ")[0].split("/"),r=b(t,3),s=r[0],n=r[1],i=r[2];return"".concat(s," ").concat(C[n]," ").concat(i)},_=function(e,t){return function(e,t){return P(e,t)}(e,t).split(" ")},N=function(e,t){return function(e,t){return _(e,t)[_(e,t).length-1]}(e,t)},I=function(e){return function(e){var t=function(e,t){var r="".concat(e);return r.length<t?"0".concat(r):"".concat(e)};return"".concat(e<0?"+":"-").concat(t(parseInt(Math.abs(e/60),10),2)).concat(t(Math.abs(e%60),2))}(e)},D=function(e){var t=e.dateStart,r=e.timeStart,s=e.timezoneOffset;return new Date("".concat(function(e,t){return k(e)}(t)," ").concat(N(r)," GMT").concat(I(s))).getTime()};var $=function(){function e(t,r){w(this,e),this.testId=t,this.data=r,this.targetselector=r.selector,this.container=document.createElement("abtasty-countdown"),this.digitElements={},this.textElements={},this.timeLoop=null}return S(e,[{key:"insert",value:function(e,t){return e.insertAdjacentElement(t,this.container),this}},{key:"setText",value:function(e){var t=this;x.forEach((function(r){var s=e[r];t.digitElements[r].textContent=s,t.textElements[r].textContent=1===s?W[r]:W["".concat(r,"s")]}))}},{key:"setCountdown",value:function(){var e=(new Date).getTime(),t=(D(this.data)-e)/1e3;if(t<=0)return this.setText({day:0,hour:0,minute:0,second:0}),void clearInterval(this.timeLoop);var r=Math.floor(t/86400);t-=86400*r;var s=Math.floor(t/3600);t-=3600*s;var n=Math.floor(t/60);t-=60*n;var i=Math.floor(t);this.setText({day:r,hour:s,minute:n,second:i})}},{key:"init",value:function(){var e=this,t=function(e){var t="";try{var r={};t+='<div class="abtasty-countdown-days">',t+='<div class="abtasty-countdown-days__digit"></div>',t+='<div class="abtasty-countdown-days__text"></div></div>',t+='<div class="abtasty-countdown-hours">',t+='<div class="abtasty-countdown-hours__digit"></div>',t+='<div class="abtasty-countdown-hours__text"></div></div>',t+='<div class="abtasty-countdown-minutes">',t+='<div class="abtasty-countdown-minutes__digit"></div>',t+='<div class="abtasty-countdown-minutes__text"></div></div>',t+='<div class="abtasty-countdown-seconds">',t+='<div class="abtasty-countdown-seconds__digit"></div>',t+='<div class="abtasty-countdown-seconds__text"></div></div>'}catch(e){T.rethrow(e,void 0,void 0,r[void 0])}return t}();this.container.innerHTML=t,this.container.insertAdjacentElement("afterbegin",function(e){var t=document.createElement("style");return t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),t}("abtasty-countdown{display:inline-block}abtasty-countdown>div{display:inline-block;text-align:center;margin:10px}")),x.forEach((function(t){var r=b(e.container.querySelector(".abtasty-countdown-".concat(t,"s")).children,2),s=r[0],n=r[1];e.digitElements[t]=s,e.textElements[t]=n})),this.timeLoop=setInterval(this.setCountdown.bind(this),1e3)}}]),e}();function B(){return j.apply(this,arguments)}function j(){return(j=r(e.mark((function t(){var r,s,n;return e.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new v("beforeend",DATA.selector),e.next=3,r.init();case 3:if(e.sent){e.next=6;break}return e.abrupt("return",!1);case 6:s=r.domElement.querySelector(".".concat(r.contentClassName)),r.domElement.querySelectorAll(".".concat(r.closeButtonClassName)).forEach((function(e){e.remove()})),(n=new $(TEST_ID,DATA)).init(),n.insert(s,"beforeend"),r.show();case 12:case"end":return e.stop()}}),t)})))).apply(this,arguments)}B()}();
1
+ !function(){"use strict";var e=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},n=s.iterator||"@@iterator",i=s.asyncIterator||"@@asyncIterator",o=s.toStringTag||"@@toStringTag";function a(e,t,r,s){var n=t&&t.prototype instanceof l?t:l,i=Object.create(n.prototype),o=new S(s||[]);return i._invoke=function(e,t,r){var s="suspendedStart";return function(n,i){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===n)throw i;return L()}for(r.method=n,r.arg=i;;){var o=r.delegate;if(o){var a=b(o,r);if(a){if(a===h)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===s)throw s="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);s="executing";var l=c(e,t,r);if("normal"===l.type){if(s=r.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(s="completed",r.method="throw",r.arg=l.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=a;var h={};function l(){}function u(){}function d(){}var g={};g[n]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(T([])));v&&v!==t&&r.call(v,n)&&(g=v);var f=d.prototype=l.prototype=Object.create(g);function p(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function y(e){var t;this._invoke=function(s,n){function i(){return new Promise((function(t,i){!function t(s,n,i,o){var a=c(e[s],e,n);if("throw"!==a.type){var h=a.arg,l=h.value;return l&&"object"==typeof l&&r.call(l,"__await")?Promise.resolve(l.__await).then((function(e){t("next",e,i,o)}),(function(e){t("throw",e,i,o)})):Promise.resolve(l).then((function(e){h.value=e,i(h)}),(function(e){return t("throw",e,i,o)}))}o(a.arg)}(s,n,t,i)}))}return t=t?t.then(i,i):i()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var s=c(r,e.iterator,t.arg);if("throw"===s.type)return t.method="throw",t.arg=s.arg,t.delegate=null,h;var n=s.arg;return n?n.done?(t[e.resultName]=n.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):n:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function T(e){if(e){var t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var s=-1,i=function t(){for(;++s<e.length;)if(r.call(e,s))return t.value=e[s],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return u.prototype=f.constructor=d,d.constructor=u,d[o]=u.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===u||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(f),e},e.awrap=function(e){return{__await:e}},p(y.prototype),y.prototype[i]=function(){return this},e.AsyncIterator=y,e.async=function(t,r,s,n){var i=new y(a(t,r,s,n));return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},p(f),f[o]="Generator",f[n]=function(){return this},f.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var s=t.pop();if(s in e)return r.value=s,r.done=!1,r}return r.done=!0,r}},e.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function s(r,s){return o.type="throw",o.arg=e,t.next=r,s&&(t.method="next",t.arg=void 0),!!s}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return s("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return s(i.catchLoc,!0);if(this.prev<i.finallyLoc)return s(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return s(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return s(i.finallyLoc)}}}},abrupt:function(e,t){for(var s=this.tryEntries.length-1;s>=0;--s){var n=this.tryEntries[s];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var s=r.completion;if("throw"===s.type){var n=s.arg;E(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function t(e,t,r,s,n,i,o){try{var a=e[i](o),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(s,n)}var r=function(e){return function(){var r=this,s=arguments;return new Promise((function(n,i){var o=e.apply(r,s);function a(e){t(o,n,i,a,c,"next",e)}function c(e){t(o,n,i,a,c,"throw",e)}a(void 0)}))}};const s=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const n=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID],i=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},o=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,a=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},c=(e,t,r)=>{let s=0,n=0;try{document.querySelector(e)}catch(t){const s=`Selector «${e}» not valid.`;return a(s),"function"==typeof r&&r(s)}function i(){clearInterval(n),clearTimeout(s)}return s=setTimeout(()=>{i();const t=`Can't find element «${e}».`;return a(t),"function"==typeof r&&r(t)},1e4),n=setInterval(()=>{const r=document.querySelector(e);return null!==r?(i(),"function"==typeof t&&t(r)):r},200),{clear:i}};async function h(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(e){return new Promise((t,r)=>{const s=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");n.src=e,s.parentNode.insertBefore(n,s),n.onload=t,n.onerror=r})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}class l{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:r},s){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(r),this.onSetCallback=s,this.widgetName=i(),this.uniqueId=o(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:r,...s}=t;return Object.entries(s).length?(e.setItem("ABTastyWidgets",JSON.stringify(s)),s):(e.removeItem("ABTastyWidgets"),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const r=this.getTypeOfStorage(e);if(!r&&"object"!=typeof r)return!1;const{storageString:s,storageMethod:n}=this.getTypeOfStorage(e),i=this.getStamp(e),o={type:t,stamp:i},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let r;"session"===s?e?r=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),r=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?r=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),r=this.getLocalRecurrenceStorageParsed()));const i=r?{[this.recurrenceKey]:o,...r}:{[this.recurrenceKey]:o};n.setItem("ABTastyWidgets",JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!n)return!1;if(a&&"validation"!==t)if("closing"===t&&"validation"!==a)c();else{if("display"!==t||"validation"===a||"closing"===a)return!1;c()}else c();return i}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class u{constructor(){this.targets=[],this.existingTargets=[],this.inViewPortTargets=[],this.visibilityobserver=this.startVisibilityObserver(),this.mutationobserver=this.startMutationObserver()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets=this.existingTargets.filter(t=>t.element!==e.target||(this.inViewPortTargets.push(t),!1)),this.checkElements()):this.inViewPortTargets=this.inViewPortTargets.filter(t=>t.element!==e.target||(this.existingTargets.push(t),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=new MutationObserver(this.checkElements.bind(this));return e.observe(document,{attributes:!0,childList:!0,subtree:!0}),e}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===function e(t,r){return r(t)||!t.parentElement?t:e(t.parentElement,r)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),r=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let s=!1,n=0;for(;!s&&n<r.length;){const t=document.elementFromPoint(...r[n]);s=e===t||e.contains(t),n+=1}return s}checkElements(){this.targets=this.targets.filter(e=>{const t=document.querySelector(e.selector);return!t||(this.existingTargets.push(Object.assign(e,{element:t})),this.visibilityobserver.observe(t),!1)}),this.existingTargets=this.existingTargets.filter(e=>!!document.querySelector(e.selector)||(this.visibilityobserver.unobserve(e.element),this.targets.push(e),!1)),this.inViewPortTargets=this.inViewPortTargets.filter(({element:e,resolve:t})=>!this.isElementVisible(e)||(this.visibilityobserver.unobserve(e),t(e),!1))}watch(e,t){this.targets.push({selector:e,resolve:t})}clear(e){const t=this.targets.filter(t=>t.selector!==e);0===t.length&&(this.existingTargets=[],this.inViewPortTargets=[],this.mutationobserver.disconnect(),this.visibilityobserver.unobserve(document.querySelector(e))),this.targets.length>t&&(this.targets=t,this.visibilityobserver.unobserve(document.querySelector(e)))}}class d{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:r}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=r,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}static promiseDeferrer(e){const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}async onElementVisible(){const e=d.promiseDeferrer("onElementVisible");this.promises.push(e);const t=await this.onPageLoad(),r=await h("IntersectionObserver"),s=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",u);return this.visibilityObservers.push(s),r&&t&&s.watch(this.selector,e.resolve),e.promise}onPageLoad(){const e=d.promiseDeferrer("onPageLoad");this.promises.push(e);const t=()=>"complete"===document.readyState;if(t())e.resolve(!0);else{const r=()=>t()&&!clearTimeout(s)&&!e.resolve(!0),s=setTimeout(()=>e.resolve(!1),2e4),n=["readystatechange",r,{passive:!0}];this.timeouts.push(s),this.eventsListeners.push(n),document.addEventListener(...n)}return e.promise}onClick(){const e=document.createElement("style");e.type="text/css",e.id=`Click_${o()}`,e.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(e),this.elementsSelectors.push(`#${e.id}`);const t=d.promiseDeferrer("onClick");this.promises.push(t);const r=()=>[...document.querySelectorAll(this.selector)],s=e=>r().some(t=>t.isSameNode(e)||!!e.closest(this.selector)),n=["click",({target:e})=>!!s(e)&&(t.resolve(!0),this.clear()),{passive:!0,capture:!0}];return this.eventsListeners.push(n),document.addEventListener(...n),t.promise}onExitIntent(){const e=d.promiseDeferrer("onExitIntent");this.promises.push(e);const t=["mouseleave",async({clientY:t})=>{if(!(t>0))if(this.delay){const t=1e3*this.delay,r=setTimeout(()=>{e.resolve(!0)},t);this.timeouts.push(r)}else e.resolve(!0)},{passive:!0}],r=c("body",e=>{e.addEventListener(...t),this.eventsListeners.push([e,...t]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==r)});return this.elementsWaiters.push(r),e.promise}onDelay(){const e=d.promiseDeferrer("onDelay");this.promises.push(e);const t=1e3*this.delay,r=setTimeout(()=>{e.resolve(!0)},t);return this.timeouts.push(r),e.promise}onReengage(){const e=d.promiseDeferrer("onReengage");this.promises.push(e);const t=1e3*this.delay;let r=t;const s=[()=>(r=t,r),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...s),this.eventsListeners.push([e,...s])});const n=setInterval(()=>{r<=0?e.resolve(!0):r-=100},100);return this.intervals.push(n),e.promise}clear(){return this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...r]="string"==typeof e[0]?[document,...e]:e;t&&r.length>1&&t.removeEventListener(...r)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.visibilityObservers.length&&(this.visibilityObservers.forEach(e=>e.clear(this.selector)),this.visibilityObservers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this}async isTriggered(){let e;switch(this.clear(),this.event){case"pageLoad":e=await this.onPageLoad(),this.clear();break;case"click":e=await this.onClick(),this.clear();break;case"exitIntent":e=await this.onExitIntent(),this.clear();break;case"delay":e=await this.onDelay(),this.clear();break;case"reengage":e=await this.onReengage(),this.clear();break;case"elementVisible":e=await this.onElementVisible(),this.clear();break;default:e=!1}return e}}class g{constructor(e,t,r){this.recurrence=e,this.isWidgetApplied=t,this.callback=r,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=n(),{type:r}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},s=()=>e&&"display"===r||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&s()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&s())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=n();return[250,500].forEach(t=>setTimeout(()=>500===t&&n()===e?this:(e=n(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),r=e.some(({addedNodes:e})=>e&&e.length);return t||r?(this.decisionHandler(!0),this):this}watch(){if(s())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const e=c("body",t=>{const r=[t,{childList:!0,subtree:!0}];this.observer.observe(...r),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});return this.elementsWaiters.push(e),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const m=["pageLoad","delay","reengage"];class v extends class{constructor(){this.uniqueId=o(),this.widgetName=i(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:t,validationRecurrence:r}=DATA;return!(s()||!(e||t||r))&&{displayRecurrence:e,closingRecurrence:t,validationRecurrence:r}})(),this.triggerParams=(()=>{const{triggerEvent:e,triggerEventClick:t,triggerEventExitDelay:r,triggerEventDelay:n,triggerEventReengageDelay:i}=DATA;if(s()||!e)return!1;const o=t;let a;switch(e){case"exitIntent":a=r;break;case"delay":a=n;break;case"reengage":a=i;break;default:a=0}return{triggerEvent:e,triggerSelector:o,triggerDelay:a}})(),this.recurrence=!!this.recurrenceParams&&new l(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new d(this.triggerParams),this.pageWatcher=new g(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=!!this.trigger&&m.some(e=>e===this.trigger.event),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}insert(){const e=new Promise((t,r)=>{c("body",r=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),this.removeOldDomElement(),t(r.appendChild(this.domElement))},t=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),a(t),r(t)})}),t=new Promise((e,r)=>{c("head",r=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),e(r.appendChild(this.styleElement))},e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),a(e),r(e)})});return Promise.all([e,t]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():s()||this.init().then(e=>e?this.show():this),this}show(){return this.hasBeenShown||s()||window.ABTastyEvent(`${this.widgetName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!s()&&window.ABTastyEvent(`${this.widgetName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(){if(!s()&&!n())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const e=this.recurrence&&this.recurrence.isOver();return this.recurrence&&!e?(this.pageWatcher.watch(),!1):(this.pageWatcher.watch(),!!(s()||!this.trigger||this.trigger&&await this.trigger.isTriggered())&&(await this.insert(),this.addCloseEvent(),this))}onPageChange(e,t){const r=()=>this.init().then(e=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(e=>e.show()):r()}}addCloseEvent(...e){const t=this.domElement.querySelectorAll(`\n\t\t\t.${this.overlayClassName},\n\t\t\t.${this.closeButtonClassName}\n\t\t`);return e.push(...t),e.forEach(e=>{e.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this}getDom(){const e=document.createElement("div");return e.className=`${this.basicClassName} ${this.hideClassName}`,e.id=this.widgetContainerId,e.innerHTML=`\n\t\t\t<div class="${this.overlayClassName}"></div>\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t<button class="${this.closeButtonClassName}" ${s()?"data-abtasty-actionnable":""}>+</button>\n\t\t\t</div>`,e}getStyleTag(e=""){const t=document.createElement("style");return t.type="text/css",s()&&t.setAttribute("abtasty-script-added","true"),t.textContent=`\n\t\t\t.${this.hideClassName} {opacity: 0 !important; pointer-events: none;}\n\t\t\t${e}`,t}}{constructor(e,t){super(),this.position=e,this.referrerElement=t,this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}async insert(){const e=c("head",t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),t.appendChild(this.styleElement)),t=>(this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e),a(t))),t=c(this.referrerElement,e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),this.removeOldDomElement(this.domElement.id),e.insertAdjacentElement(this.position,this.domElement)),e=>(this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),a(e)));return this.elementsWaiters.push(e,t),this}getStyles(){return`\n\t\t#${this.widgetContainerId} {\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tposition: relative;\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.overlayClassName} {\n\t\t\tdisplay: none;\n\t\t}\n\t\t#${this.widgetContainerId} .${this.closeButtonClassName} {\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: 0;\n\t\t\twidth: auto;\n\t\t\theight: auto;\n\t\t\tcolor: black;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\ttransform: rotate(45deg);\n\t\t\tcursor: pointer;\n\t\t\toutline: none;\n\t\t\tfont-size: 1.8em;\n\t\t}`}}var f=function(e){if(Array.isArray(e))return e};var p=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],s=!0,n=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(s=(o=a.next()).done)&&(r.push(o.value),!t||r.length!==t);s=!0);}catch(e){n=!0,i=e}finally{try{s||null==a.return||a.return()}finally{if(n)throw i}}return r}};var y=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var b=function(e,t){return f(e)||p(e,t)||y()};var w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function E(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var S=function(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e},T=function(e){var t=Object.prototype.hasOwnProperty;function r(e,s){return Array.isArray(e)?function(e,t){for(var s,n="",i="",a=Array.isArray(t),c=0;c<e.length;c++)(s=r(e[c]))&&(a&&t[c]&&(s=o(s)),n=n+i+s,i=" ");return n}(e,s):e&&"object"==typeof e?function(e){var r="",s="";for(var n in e)n&&e[n]&&t.call(e,n)&&(r=r+s+n,s=" ");return r}(e):e||""}function s(e){if(!e)return"";if("object"==typeof e){var r="";for(var s in e)t.call(e,s)&&(r=r+s+":"+e[s]+";");return r}return e+""}function n(e,t,r,s){if(!1===t||null==t||!t&&("class"===e||"style"===e))return"";if(!0===t)return" "+(s?e:e+'="'+e+'"');var n=typeof t;return"object"!==n&&"function"!==n||"function"!=typeof t.toJSON||(t=t.toJSON()),"string"==typeof t||(t=JSON.stringify(t),r||-1===t.indexOf('"'))?(r&&(t=o(t))," "+e+'="'+t+'"'):" "+e+"='"+t.replace(/'/g,"&#39;")+"'"}e.merge=function e(t,r){if(1===arguments.length){for(var n=t[0],i=1;i<t.length;i++)n=e(n,t[i]);return n}for(var o in r)if("class"===o){var a=t[o]||[];t[o]=(Array.isArray(a)?a:[a]).concat(r[o]||[])}else if("style"===o){a=(a=s(t[o]))&&";"!==a[a.length-1]?a+";":a;var c=s(r[o]);c=c&&";"!==c[c.length-1]?c+";":c,t[o]=a+c}else t[o]=r[o];return t},e.classes=r,e.style=s,e.attr=n,e.attrs=function(e,i){var o="";for(var a in e)if(t.call(e,a)){var c=e[a];if("class"===a){c=r(c),o=n(a,c,!1,i)+o;continue}"style"===a&&(c=s(c)),o+=n(a,c,!1,i)}return o};var i=/["&<>]/;function o(e){var t=""+e,r=i.exec(t);if(!r)return e;var s,n,o,a="";for(s=r.index,n=0;s<t.length;s++){switch(t.charCodeAt(s)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;case 62:o="&gt;";break;default:continue}n!==s&&(a+=t.substring(n,s)),n=s+1,a+=o}return n!==s?a+t.substring(n,s):a}return e.escape=o,e.rethrow=function e(t,r,s,n){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&r||n))throw t.message+=" on line "+s,t;try{n=n||require("fs").readFileSync(r,"utf8")}catch(r){e(t,null,s)}var i=3,o=n.split("\n"),a=Math.max(s-i,0),c=Math.min(o.length,s+i);i=o.slice(a,c).map((function(e,t){var r=t+a+1;return(r==s?" > ":" ")+r+"| "+e})).join("\n");throw t.path=r,t.message=(r||"Pug")+":"+s+"\n"+i+"\n\n"+t.message,t},e}({});var L=["fr","en","de","es"],x=["day","hour","minute","second"],A={day:{en:"Day",fr:"Jour",es:"Dia",de:"Tag"},days:{en:"Days",fr:"Jours",es:"Dias",de:"Tage"},hour:{en:"Hour",fr:"Heure",es:"Hora",de:"Zeit"},hours:{en:"Hours",fr:"Heures",es:"Horas",de:"Stunden"},minute:"Min",second:{en:"Sec",fr:"Sec",es:"Seg",de:"Sek"}},C={"01":"Jan","02":"Feb","03":"Mar","04":"Apr","05":"May","06":"Jun","07":"Jul","08":"Aug","09":"Sep",10:"Oct",11:"Nov",12:"Dec"},R=window.ABTASTY_S&&ABTASTY_S.USER&&ABTASTY_S.USER.lang?ABTASTY_S.USER.lang.split("_")[0]:navigator.language.substr(0,2)||"en",O=function(e){return L.indexOf(e)>-1}(R)?R:"en",W={day:A.day[O],days:A.days[O],hour:A.hour[O],hours:A.hours[O],minute:A.minute,minutes:A.minute,second:A.second[O],seconds:A.second[O]},P=function(e,t){return new Date(e).toLocaleString("fr-FR",{timezone:t}).replace(/[^ -~]/g,"")},_=function(e){var t=function(e,t){return P(e,t)}(e).split(" ")[0].split("/"),r=b(t,3),s=r[0],n=r[1],i=r[2];return"".concat(s," ").concat(C[n]," ").concat(i)},k=function(e,t){return function(e,t){return P(e,t)}(e,t).split(" ")},N=function(e,t){return function(e,t){return k(e,t)[k(e,t).length-1]}(e,t)},I=function(e){return function(e){var t=function(e,t){var r="".concat(e);return r.length<t?"0".concat(r):"".concat(e)};return"".concat(e<0?"+":"-").concat(t(parseInt(Math.abs(e/60),10),2)).concat(t(Math.abs(e%60),2))}(e)},D=function(e){var t=e.dateStart,r=e.timeStart,s=e.timezoneOffset;return new Date("".concat(function(e,t){return _(e)}(t)," ").concat(N(r)," GMT").concat(I(s))).getTime()};var B=function(){function e(t,r){w(this,e),this.testId=t,this.data=r,this.targetselector=r.selector,this.container=document.createElement("abtasty-countdown"),this.digitElements={},this.textElements={},this.timeLoop=null}return S(e,[{key:"insert",value:function(e,t){return e.insertAdjacentElement(t,this.container),this}},{key:"setText",value:function(e){var t=this;x.forEach((function(r){var s=e[r];t.digitElements[r].textContent=s,t.textElements[r].textContent=1===s?W[r]:W["".concat(r,"s")]}))}},{key:"setCountdown",value:function(){var e=(new Date).getTime(),t=(D(this.data)-e)/1e3;if(t<=0)return this.setText({day:0,hour:0,minute:0,second:0}),void clearInterval(this.timeLoop);var r=Math.floor(t/86400);t-=86400*r;var s=Math.floor(t/3600);t-=3600*s;var n=Math.floor(t/60);t-=60*n;var i=Math.floor(t);this.setText({day:r,hour:s,minute:n,second:i})}},{key:"init",value:function(){var e=this,t=function(e){var t="";try{var r={};t+='<div class="abtasty-countdown-days">',t+='<div class="abtasty-countdown-days__digit"></div>',t+='<div class="abtasty-countdown-days__text"></div></div>',t+='<div class="abtasty-countdown-hours">',t+='<div class="abtasty-countdown-hours__digit"></div>',t+='<div class="abtasty-countdown-hours__text"></div></div>',t+='<div class="abtasty-countdown-minutes">',t+='<div class="abtasty-countdown-minutes__digit"></div>',t+='<div class="abtasty-countdown-minutes__text"></div></div>',t+='<div class="abtasty-countdown-seconds">',t+='<div class="abtasty-countdown-seconds__digit"></div>',t+='<div class="abtasty-countdown-seconds__text"></div></div>'}catch(e){T.rethrow(e,void 0,void 0,r[void 0])}return t}();this.container.innerHTML=t,this.container.insertAdjacentElement("afterbegin",function(e){var t=document.createElement("style");return t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),t}("abtasty-countdown{display:inline-block}abtasty-countdown>div{display:inline-block;text-align:center;margin:10px}")),x.forEach((function(t){var r=b(e.container.querySelector(".abtasty-countdown-".concat(t,"s")).children,2),s=r[0],n=r[1];e.digitElements[t]=s,e.textElements[t]=n})),this.timeLoop=setInterval(this.setCountdown.bind(this),1e3)}}]),e}();function $(){return j.apply(this,arguments)}function j(){return(j=r(e.mark((function t(){var r,s,n;return e.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new v("beforeend",DATA.selector),e.next=3,r.init();case 3:if(e.sent){e.next=6;break}return e.abrupt("return",!1);case 6:s=r.domElement.querySelector(".".concat(r.contentClassName)),r.domElement.querySelectorAll(".".concat(r.closeButtonClassName)).forEach((function(e){e.remove()})),(n=new B(TEST_ID,DATA)).init(),n.insert(s,"beforeend"),r.show();case 12:case"end":return e.stop()}}),t)})))).apply(this,arguments)}$()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/countdown",
3
3
  "description": "Widget for AB Tasty",
4
- "version": "1.3.5",
4
+ "version": "1.4.0",
5
5
  "form": "dist/form.js",
6
6
  "main": "dist/main.js",
7
7
  "files": [
@@ -15,7 +15,9 @@
15
15
  "start": "concurrently --kill-others \"npm run watch\" \"npm run serve\"",
16
16
  "watch": "rollup -c --watch",
17
17
  "build": "rollup -c",
18
- "serve": "widget serve"
18
+ "serve": "widget serve",
19
+ "prepare": "npm run build",
20
+ "postpublish": "echo 'Your widget is on NPM. You can now add your widget to AB Tasty at https://app2.abtasty.com/'"
19
21
  },
20
22
  "devDependencies": {
21
23
  "@babel/core": "^7.8.4",
@@ -52,4 +54,4 @@
52
54
  "@abtasty/widget-utils"
53
55
  ]
54
56
  }
55
- }
57
+ }