@abtasty/countdown 3.11.1-1 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +2 -3
package/dist/main.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(){"use strict";const t=()=>Object.prototype.hasOwnProperty.call(top,"ABTastyEditor"),e=()=>{const t=!!document.getElementById("ABTastyPreviewBar"),e=location.href.includes("ab_project=preview");return t||e},n=t=>new Function(`try {\n\t\t${t}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),o=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),s=()=>!t()&&(e()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),i=()=>window.ABTasty&&!0===window.ABTasty.consentReady,a=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?`_${t}`:""}`},r=()=>{const t=a();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=n=>{const o=(()=>{if(t()||e())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),s=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(o||s){const t=r();window.console.log(`%c${t} - ${o?"QA":"Debug"} Mode for campaign ${TEST_ID} %c ${n}`,"background-color: #D6FF01; color: #3100be; padding: 3px 0 3px 10px; border-radius: 5px 0 0 5px; font-weight: bold;","background-color: #3100be; color: white; padding: 3px 10px 3px 0; border-radius: 0 5px 5px 0;")}},d=t=>{const e={promise:null,resolve:null,reject:null,name:t};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e},u=(t,e)=>{const n=e?[]:null;if("string"!=typeof t||!t.trim().length)return n;const[o,s,i]=t.split("[]").map(t=>t.trim()),a=Boolean(i)?i:t,r=s?document.querySelector(o)?.[s]:document;return r?e?[...r.querySelectorAll(a)]:r.querySelector(a):n},h=t=>u(t,!1),m=t=>u(t,!0),g=(t,e)=>{const n={childList:!0,subtree:!0,attributes:!0},o=()=>s.disconnect(),s=new MutationObserver(()=>{const n=h(e);return n&&!o()&&t(n)});return{clear:o,observe:t=>{const e=document.querySelector("body")||document.documentElement,o=t??e;s.observe(o,n)}}},b=()=>{},p=(e,n)=>{const o=h(e),s={selector:e,clear:b,observe:b};if(o)return setTimeout(()=>n(o),0),s;if(t())return setTimeout(()=>p(e,n),1e3),s;if(e.includes("[]"))return((t,e)=>{const[n,o]=e.split("[]").map(t=>t.trim()),s=h(n),i=s?.[o],{clear:a,observe:r}=g(t,e),c=()=>{const n=h(e);return n&&!l()&&t(n)},l=()=>{a(),s?.removeEventListener("load",c)},d=()=>{r(i),"iframe"===s?.localName&&s.addEventListener("load",c)};return d(),{selector:e,clear:l,observe:d}})(n,e);const{clear:i,observe:a}=g(n,e);return a(),{selector:e,clear:i,observe:a}};function y(t,e){const n=t.parentElement||t.getRootNode().host;return e(t)||!n?t:y(n,e)}const w=e=>{t()||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())},v=(t,e)=>[...m(e)].some(n=>{const[o,,s]=e.split("[]"),i=s??o;return n===t||!!t.closest(i)});let f=!1;class T{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=null,this.mutationObserver=null,this.mouseOverEvent=null,this.scrollEvent=null,this.onTransitionEnd=null,this.onIframeLoad=null}transitionOverHandler(t){const e=[t,"transitionend",this.checkElements.bind(this),!0];return this.getEvents(...e)}intersectionHandler(t){t.forEach(t=>{t.isIntersecting?(this.existingTargets.forEach(e=>{e.element.isSameNode(t.target)&&(this.inViewportTargets.push(e),this.mouseOverEvent.start(),this.scrollEvent.start(),this.onTransitionEnd.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(e=>!e.element.isSameNode(t.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear(),!1))})}startVisibilityObserver(t){const e={root:t,rootMargin:"0px",threshold:0};return this.visibilityObserver??=new IntersectionObserver(this.intersectionHandler.bind(this),e),this.visibilityObserver}startMutationObserver(t){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(t,{attributes:!0,childList:!0,subtree:!0}),this.mutationObserver}onMouseOver({target:t,path:e}){const n=this.inViewportTargets.find(({element:n,selector:o})=>{if(n.isSameNode(t))return!0;const[s,,i]=o.split("[]"),a=i??s,r=[...t.querySelectorAll(a)];if(r.length&&r.includes(n))return!0;if(e.includes(n))return!0;if(!t.parentElement?.children?.length)return;const c=[...t.parentElement.children],l=c.findIndex(e=>e.isSameNode(t)),d=c.filter((t,e)=>e>l);if(d.length){if(d.includes(n))return!0;if(d.some(t=>[...t.querySelectorAll(a)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:t,element:e,uniqueId:o}=n,s=this.targets.find(e=>e.selector===t&&e.uniqueId===o);s&&s.resolve(e),this.clear(t,o)}}getEvents(t,...e){return{start:()=>t?.addEventListener(...e),clear:()=>t?.removeEventListener(...e)}}mouseOverHandler(t){const e=[t,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?"touchmove":"mouseover",t=>{const e=t.composedPath(),{target:n}=t;setTimeout(()=>this.onMouseOver({target:n,path:e}),50)},!0];return this.getEvents(...e)}scrollEventHandler(t){const e=[t,"scroll",(n=this.checkElements.bind(this),()=>{f||(f=!0,setTimeout(()=>{n(),f=!1},100))}),{passive:!0}];var n;return this.getEvents(...e)}isElementVisible(t){return this.isElementOpaque(t)&&this.isElementTopmost(t)}isElementOpaque(t){return"HTML"===y(t,t=>"0"===window.getComputedStyle(t).opacity).nodeName}isElementTopmost(t){const e=t.getBoundingClientRect(),n=[[e.left,e.top],[e.right,e.top],[e.left,e.bottom],[e.right,e.bottom],[e.left+e.width/2,e.top],[e.left+e.width/2,e.bottom],[e.left,e.height/2],[e.right,e.height/2],[e.left+e.left/2,e.height/2]];let o=!1,s=0;for(;!o&&s<n.length;){const e=t.getRootNode()?.elementFromPoint(...n[s]);o=t===e||e?.contains(t)||t.contains(e),s+=1}return o}checkElements(){this.targets.forEach(({selector:t,uniqueId:e})=>{const n=h(t),[o,,s]=t.split("[]"),i=s??o;n&&!this.existingTargets.find(t=>t.element.matches(i)&&t.uniqueId===e)&&(this.existingTargets.push({element:n,selector:t,uniqueId:e}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:t,element:e})=>!(!h(t)||!e.isConnected)||(e&&this.visibilityObserver.unobserve(e),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:t,element:e,uniqueId:n})=>{const[o,,s]=t.split("[]"),i=s??o;if(e.matches(i)&&this.isElementVisible(e)){const o=this.targets.find(e=>e.selector===t&&e.uniqueId===n);return o&&o.resolve(e),this.clear(t,n),!1}return!0})}onLoadIframe(t){const e=[t.defaultView.frameElement,"load",()=>this.watch(selector,resolve,uniqueId).bind(this),{passive:!0}];return this.getEvents(...e)}watch(t,e,n){this.targets.push({selector:t,resolve:e,uniqueId:n});const{clear:o}=p(t,t=>{o();const e=t.getRootNode({composed:!0}),n="body"in e?e.body:document;this.mouseOverEvent=this.mouseOverHandler(e),this.scrollEvent=this.scrollEventHandler(e),this.onTransitionEnd=this.transitionOverHandler(e),e.defaultView?.frameElement&&(this.onIframeLoad=this.onLoadIframe(e),this.onIframeLoad.start()),this.startVisibilityObserver(e),this.startMutationObserver(n),this.checkElements()})}clear(t,e){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:o})=>n!==t&&o!==e));const n=h(t);n&&this.visibilityObserver?.unobserve(n),0===this.targets.length&&(this.mutationObserver?.disconnect(),this.onIframeLoad?.clear()),0===this.inViewportTargets.length&&(this.mouseOverEvent?.clear(),this.scrollEvent?.clear(),this.onTransitionEnd?.clear())}}const x="remove",$="rebuild",A="update",C="ABTastyData";class S{constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n,triggerTarget:o}){this.event=t,this.selector=Boolean(e)?e:"body",this.target="string"==typeof o?h(e):o,this.delay=1e3*n,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:t,resolve:e}){const n=d(`${this.event}DomReady`);this.promises.push(n);const{clear:o}=p(this.selector,()=>{const t=new T;this.visibilityObservers.push(t),t.watch(this.selector,e,c())});return this.elementWaiters.push(o),t}onPageLoad({promise:t,resolve:e}){const n=()=>"complete"===document.readyState;if(!n()){const o=["readystatechange",()=>n()&&e(!0),{passive:!0}];return this.eventsListeners.push([document,...o]),document.addEventListener(...o),t}return e(!0),t}onClick({promise:t,resolve:e}){const n=({isTrusted:t,target:n})=>{if(t)return(n.isEqualNode(this.target)||v(n,this.selector))&&e(!0)},{clear:o}=p(this.selector,t=>{o();const e=document.createElement("style");e.id=`Click_${c()}`;const[s,,i]=this.selector.split("[]"),a=i??s;e.innerHTML=`${a} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const r=t.getRootNode();("head"in r?r.head:r).appendChild(e),this.triggerElements.push(e);const l=["click",n,{passive:!0,capture:!0}];this.eventsListeners.push([r,...l]),r.addEventListener(...l)});return this.elementWaiters.push(o),t}onHover({promise:t,resolve:e}){const n=({isTrusted:t,target:n})=>{if(t)return(this.target?n.isEqualNode(this.target):v(n,this.selector))&&e(!0)},{clear:o}=p(this.selector,t=>{const e=t.getRootNode(),o="body"in e?e.body:[...e.childNodes].find(e=>e.contains(t)),s=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([o,...s]),o.addEventListener(...s)});return this.elementWaiters.push(o),t}onExitIntent({promise:t,resolve:e}){const n=["mouseleave",({isTrusted:t,clientY:n})=>{t&&n<=0&&e(!0)},{passive:!0}],{clear:o}=p("html",t=>{o(),this.eventsListeners.push([t,...n]),t.addEventListener(...n)});return t}onReengage({promise:t,resolve:e}){const n=this.delay;let o=n;const s=[...document.querySelectorAll("*:empty")].map(t=>t.contentDocument||t.shadowRoot).filter(t=>t),i=[({isTrusted:t})=>{t&&(o=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{[document,...s].forEach(e=>{this.eventsListeners.push([e,t,...i]),e.addEventListener(t,...i)})});const a=setInterval(()=>{o<=0?e(!0):o-=100},100);return this.intervals.push(a),t}onCustomTrigger({promise:t,resolve:e}){const{triggerEventCustomScript:n,tagIsSafeEval:o}=DATA,s=o&&DATA_JS?.triggerEventCustomScript,i="function"==typeof s?()=>new Promise(t=>s(t)):new Function(`return new Promise(async resolve => {${n}})`);return i().then(t=>t&&e(!0)),t}onScrollUp({promise:t,resolve:e}){let n=0;const o=["scroll",({isTrusted:t})=>{t&&(window.scrollY<n?e(!0):n=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...o]),document.addEventListener(...o),t}onScrollPercentReached({promise:t,resolve:e}){const{triggerEventScrollPercent:n}=DATA,o=["scroll",({isTrusted:t})=>{if(!t)return;const o=(()=>{const{documentElement:t,body:e}=document,n=t.scrollTop||e.scrollTop,o=t.scrollHeight||e.scrollHeight;return Math.trunc(n/(o-t.clientHeight)*100,10)})();n<o&&e(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...o]),document.addEventListener(...o),t}checkSocialProofConditions(t,e,n,o){const s=(()=>{let t;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?t=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?t=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(t=window.ABTasty.accountSettings.identifier),t):t})(),{viewInterval:i,spNoTrim:a}=DATA;if(this.socialProofStore.hasOwnProperty(t))n(this.socialProofStore[t])?o(`${this.socialProofStore[t][i]}`):o(!1);else if(t&&s){const r=e=>(this.socialProofStore[t]=e,o(!!n(e)&&`${e[i]}`));fetch(`https://api-social-proof.abtasty.com/clients/${s}/metrics/${e}?key=${t}${a?"&noTrim=true":""}`).then(t=>t.ok&&t.json()).then(r).catch(()=>l("Failed to fetch datas from server."))}else o(!1)}getSocialProofDatas({promise:t,resolve:e},s,i=!1){const{productKey:a,keyType:r}=(()=>{const{socialProofContentType:t,productKeyProvider:e,pathToProductKey:s,customJSProductKey:i,productSKU:a,tagIsSafeEval:r}=DATA,{pathToProductKey:c,customJSProductKey:l}=r&&DATA_JS||{};if(2===t)return{productKey:o(),keyType:"url"};{let r=null,d="sku";switch(e){case"ABTastyProductKey":r=window.ABTastyProductKey;break;case"pathToProductKey":r="function"==typeof c?c():n(`return ${s};`);break;case"customJSProductKey":r="function"==typeof l?l():n(i);break;case"productSKU":r=a}return r||3!==t||(r=o(),d="url"),{productKey:r,keyType:d}}})(),{viewInterval:c,triggerSocialProofMinVisitors:d,triggerSocialProofMinPurchases:u,triggerSocialProofMinPageViews:h}=DATA,m={pv:h,i:u,"v-pv":d}[s];return[typeof c,typeof m].includes("undefined")&&e(!1),i&&!a&&(l("Not able to find ABTastyProductKey, impossible to call the API, read documentation for more informations:\n\t\t\t\thttps://support.abtasty.com/hc/en-us/articles/4710919241628-Widgets-List#h_84c04344-c655-4e5e-b9ab-d26a798ad9b0"),e(!1)),this.checkSocialProofConditions(a,"v-pv"===s&&"sku"===r?"v-i":s,t=>{const e=void 0!==t[c]&&t[c]>=m;return e||l(`Widget will not be shown, Social Proof API returned ${t[c]} while ${m} are required`),e},e),t}onConsent({promise:t,resolve:e}){if(!i()){const n=["abtasty_consentValid",()=>e(!0)];return this.eventsListeners.push(n),window.addEventListener(...n),t}return e(!0),t}onTrackingSent({promise:t,resolve:e}){const{triggerEventTrackingSent:n}=DATA;let o=localStorage.getItem(C);const s=()=>JSON.parse(o)?.ActionTracking?.some(({name:t})=>t===n),i=["storage",({key:t,newValue:n})=>{t===C&&(o=n,s()&&e(!0))},{passive:!0,capture:!0}];return o&&s()?e(!0):(()=>{this.eventsListeners.push([window,...i]),window.addEventListener(...i)})(),t}onMinPagesViewed({promise:t,resolve:e}){const{triggerEventMinPagesViewed:n}=DATA;let o=localStorage.getItem(C);const s=()=>n<=(o?JSON.parse(o)?.VisitedPages?.length:0),i=["storage",({key:t,newValue:n})=>{t===C&&(o=n,s()&&e(!0))},{passive:!0,capture:!0}];return o&&s()?e(!0):(()=>{this.eventsListeners.push([window,...i]),window.addEventListener(...i)})(),t}onRageClick({promise:t,resolve:e}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:o}=DATA;let s=0,i=!1;const a=["click",({isTrusted:t})=>{if(t&&(s+=1,s>=n&&e(!0),!i)){i=!0;const t=setTimeout(()=>{s=0,i=!1},o);this.timeouts.push(t)}},{passive:!0,capture:!0}],r=t=>{this.eventsListeners.push([t,...a]),t.addEventListener(...a)},{clear:c}=p("iframe []contentDocument[] body > *",()=>{const t=document.getElementsByTagName("iframe");for(const e of t){"contentDocument"in e&&"body"in e.contentDocument&&r(e.contentDocument);const t=()=>r(e.contentDocument);e.addEventListener("load",t),this.eventsListeners.push([e,"onIframeLoad",t])}});return this.elementWaiters.push(c),r(document),t}clear(){this.triggerElements=this.triggerElements.filter(t=>(t.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(t=>{const[e,...n]=t;return e&&n.length>1&&e.removeEventListener(...n),!1}),this.timeouts=this.timeouts.filter(t=>(clearTimeout(t),!1)),this.intervals=this.intervals.filter(t=>(clearInterval(t),!1));const t=c();return this.visibilityObservers=this.visibilityObservers.filter(e=>(e.clear(this.selector,t),!1)),this.promises=this.promises.filter(t=>(t.resolve(!1),!1)),this.elementWaiters=this.elementWaiters.filter(t=>(t(),!1)),this}async isTriggered(){this.clear();const t=d(this.event);this.promises.push(t);const e={consent:()=>this.onConsent(t),direct:()=>!0,pageLoad:()=>this.onPageLoad(t),click:()=>this.onClick(t),exitIntent:()=>this.onExitIntent(t),reengage:()=>this.onReengage(t),elementVisible:()=>this.onElementVisible(t),script:()=>this.onCustomTrigger(t),hover:()=>this.onHover(t),scrollUp:()=>this.onScrollUp(t),scrollPercent:()=>this.onScrollPercentReached(t),rageClick:()=>this.onRageClick(t),minPagesViewed:()=>this.onMinPagesViewed(t),trackingSent:()=>this.onTrackingSent(t),socialProofPurchases:()=>this.getSocialProofDatas(t,"i",!0),socialProofPageViews:()=>this.getSocialProofDatas(t,"pv"),socialProofVisitors:()=>this.getSocialProofDatas(t,"v-pv")},n=!Object.prototype.hasOwnProperty.call(e,this.event)||await e[this.event]();return n&&this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const t=d(`${this.event}Delay`);this.promises.push(t);const e=setTimeout(()=>{t.resolve(!0),this.clear()},this.delay);return this.timeouts.push(e),t.promise})():n}}const E="display",k="closing",L="validation",D="ABTastyWidgets",B=`${D}Temporary`;class P{constructor({displayRecurrence:t,closingRecurrence:e,validationRecurrence:n},o){this.displayRecurrence=parseFloat(t),this.closingRecurrence=parseFloat(e),this.validationRecurrence=parseFloat(n),this.onSetCallback=o,this.widgetName=a(),this.uniqueId=c(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:t}){const e=localStorage.getItem(B),n=sessionStorage.getItem(D);"ABTastyData"===t&&!e&&n&&localStorage.setItem(B,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem(D);return JSON.parse(e)}catch(e){return t.removeItem(D),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(t,e){const{[this.recurrenceKey]:n,...o}=e;return Object.entries(o).length?(t.setItem(D,JSON.stringify(o)),o):(t.removeItem(D),!1)}removeSessionRecurrenceStorage(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.sessionStorage,t)}removeLocalRecurrenceStorage(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.localStorage,t)}getSessionRecurrence(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getLocalRecurrence(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();return t||e||{type:!1}}isOver(){const t=localStorage.getItem(B),e=!(!t||!t.includes(this.recurrenceKey))||this.getSessionRecurrence();t&&(sessionStorage.setItem(D,t),localStorage.removeItem(B));const n=this.getLocalRecurrence(),o=(n?parseFloat(n.stamp):0)<(new Date).getTime();return o&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&o&&!this.getLocalRecurrence()&&!e}setRecurrence(t,n){0!==t&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const o=this.getTypeOfStorage(t);if(e()||!o&&"object"!=typeof o)return!1;const{storageString:s,storageMethod:a}=o,r=this.getStamp(t),c={type:n,stamp:r},{type:l}=this.getCurrentRecurrence(),d=async()=>{if(!i()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const t=new S({triggerEvent:"consent"});await t.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();let n;"session"===s?t?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(e?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const o=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};a.setItem(D,JSON.stringify(o)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!a)return!1;if(l&&n!==L)if(n===k&&l!==L)d();else{if(n!==E||l===L||l===k)return!1;d()}else d();return r}setDisplayRecurrence(){const t=E;this.setRecurrence(this.displayRecurrence,t)}setClosingRecurrence(){const t=k;this.setRecurrence(this.closingRecurrence,t)}setValidationRecurrence(){const t=L;this.setRecurrence(this.validationRecurrence,t)}getStamp(t){return(new Date).getTime()+864e5*t}getTypeOfStorage(t){return!(isNaN(t)||t<0||0!==t&&!t)&&(t>0?{storageString:"local",storageMethod:window.localStorage}:0===t&&{storageString:"session",storageMethod:window.sessionStorage})}}class I{constructor(t,e,n){this.isWidgetApplied=t,this.callback=e,this.shouldUpdate=n,this.triggerIframeTarget=null,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.tagRollbackEventParams=["abtasty_resetActionTracking",this.onTagRollback.bind(this)],this.onCampaignLaunchedEventParams=["abtasty_executedCampaign",this.onCampaignLaunched.bind(this)]}decisionHandler(t){const e=!t&&this.isWidgetApplied(),n=e?this.shouldUpdate&&A:$;return n?(this.clearWatcher(),this.callback(n,!t,e),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:t}}){t===TEST_ID&&(this.callback($,!1),this.watch())}onTagRollback({target:t}){return this.clearWatcher(t),this.callback(x,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(t){return s()?t.some(t=>["removedNodes","addedNodes"].some(e=>t[e]&&t[e].length))?this.decisionHandler():this:this.callback(x,!1)}watch(e,n){if(t())return this;if(this.clearWatcher(e),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),n?.includes("[]contentDocument[]")){const t=n.split("[]")[0].trim(),{clear:e}=p(t,t=>{e(),this.triggerIframeTarget=t,t.addEventListener("load",this.decisionHandler.bind(this))})}const o=e?.defaultView?.frameElement;o&&this.triggerIframeTarget!==o&&o.addEventListener("load",this.decisionHandler.bind(this));const{clear:s}=p("body",t=>{s();const n=e?.body||e||t;this.observer.observe(n,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(t){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),t?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const N=/.+\/([^.]+)\.(otf|ttf)$/,R=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class _{constructor(e,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=a(),this.prettyName=r(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:n,validationRecurrence:o}=DATA,s=!e&&!n&&!o;if(t()||s)return!1;const i={everytime:()=>-1,session:()=>0,once:()=>395,day:t=>DATA[`${t}_day`],week:t=>7*DATA[`${t}_week`],month:t=>30.5*DATA[`${t}_month`]},a={};return e&&(a.displayRecurrence=i[e]("displayRecurrence")),n&&(a.closingRecurrence=i[n]("closingRecurrence")),o&&(a.validationRecurrence=i[o]("validationRecurrence")),a})(),this.triggerParams=(e=>{let{triggerEvent:n}=DATA;const{triggerEventClick:o,triggerEventHover:s,triggerEventReengageDelay:i,socialProofContentType:a,triggerEventElementVisible:r,triggerEventDelay:c}=DATA;if(t()||!n&&!a)return!1;const l={click:()=>o,hover:()=>s,elementVisible:()=>r},d=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",u="reengage"===n?i:c;return a&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][a]),{triggerEvent:n,triggerSelector:d,triggerDelay:u,triggerTarget:e}})(e),this.recurrence=!!this.recurrenceParams&&new P(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new S(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&R.includes(this.triggerParams.triggerEvent),this.pageWatcher=new I(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:t,triggerEvent:e}=DATA;return!e||!["click","hover","scrollUp","script"].includes(e)||t})(),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.rootElement=null,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.elementsWaiters=[]}clearGivenClearables(){for(const t of this.elementsWaiters)t.clear();this.elementsWaiters=[]}isWidgetApplied(){return this.domElement?.isConnected&&this.domElement.ownerDocument?.defaultView}removeOldDomElement(){const t=this.rootElement?.getElementById(this.widgetContainerId);return t?.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const t=["free"];"drawer"===DATA.layout&&DATA.customTarget&&t.push("drawer");const e=t.includes(DATA.layout);return new Promise(t=>{const{elementReferrer:n="body",referrerInsertType:o="beforeend"}=e?DATA:{},s=p(n,e=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t.selector!==n),this.rootElement=e.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),t(e.insertAdjacentElement(o,this.domElement))});this.elementsWaiters.push(s)}).then(()=>this)}remove(){this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement);for(const t of this.elementsWaiters)[DATA.elementReferrer,"body"].includes(t.selector)&&t.clear();return this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):t()||this.init().then(({response:t})=>t?this.show():this),this}show(){return t()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(this.rootElement),this}hide(e=!0){return!t()&&this.hasBeenShown&&e&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),e&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(e){const n=t(),o=s(),i=this.trigger?.promises?.length,a=!this.recurrence||this.recurrence.isOver();if(!n&&!o||i||!a)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const r=n||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:r};return r?(await this.insert(),this.addCloseEvent(),n||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(r),c):c}onPageChange(t,e,n){const o=()=>this.init().then(({response:t})=>{t?this.show():this.hide(!1)});e||(this.hasBeenShown=!1,n&&this.domElement.remove(),this.trigger&&this.trigger.clear());const s={[x]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[$]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(t=>t.show()).catch(this.pageWatcher.watch):o()},[A]:()=>{this.hasBeenShown?this.pageWatcher.watch():o()}};"function"==typeof s[t]&&s[t]()}addCloseEvent(...e){const{closeButton:n,overlay:o,overlayClickable:s,layout:i,animationDuration:a=1e3}=DATA,r=[];if(void 0!==o&&!0!==o||!0!==s||"popin"!==i||r.push(`.${this.overlayClassName}`),void 0!==n&&n&&r.push(`.${this.closeButtonClassName}`),!r.length)return this;const c=this.domElement.querySelectorAll(r.join(", "));if(!c.length)return this;const l=["click",t=>{w(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*a)},{once:!0,capture:!0}];e.push(...c);for(const n of e)t()&&(n.dataset.abtastyActionnable="true"),n.removeEventListener(...l),n.addEventListener(...l);return this}getDom(){const{closeButton:t,layout:e,overlayClickable:n,overlay:o=!0}=DATA,s=document.createElement("div");return s.className=`${this.basicClassName} ${this.hideClassName}`,s.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(e)&&(s.role="dialog"),s.innerHTML=`\n\t\t\t${"popin"===e&&!0===o?`<div ${n?'aria-label="Close dialog"':""} class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${t?`<button class="${this.closeButtonClassName}" aria-label="Close dialog"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,s}loadFont(t,e){if(!t||"inherit"===t||!/otf|ttf/g.test(e))return;const n=document.createElement("style"),o=e.match(N)?e.match(N)[1]:"";n.innerHTML=`@font-face { font-family: '${t}_${o}'; src: url('${e}'); font-display: swap; }`;const s=this.rootElement?.head||document.head;s?.appendChild(n)}getStyleTag(e="",n=DATA){const{noStyles:o,layout:s}=n,{backgroundColor:i,isBackgroundImage:a,backgroundImage:r,backgroundSize:c,backgroundPosition:l,backgroundRepeat:d,borderColor:u,borderRadius:h,borderWidth:m,textColor:g,textAlign:b,fontName:p,fontStyle:y,fontSize:w,isTitle:v,titleTextAlign:f,titleTextColor:T,titleFontName:x,titleFontStyle:$,titleFontSize:A,overlay:C,overlayColor:S,dropShadow:E,dropShadowColor:k,dropShadowBlur:L,containerMargin:D,containerPadding:B,closeButton:P,closeButtonPosition:I,closeButtonSize:R,closeButtonBorderRadius:_,closeButtonBorderWidth:O,closeButtonBorderColor:W,closeButtonColor:V,closeButtonBackgroundColor:q,buttonsAlign:M,buttonsBorderWidth:H,buttonsBorderColor:j,buttonsBorderRadius:z,buttonsBackgroundColor:F,buttonsTextColor:U,buttonsFontName:K,buttonsFontStyle:G,buttonsFontSize:J,secondLink:Y,secondLinkBorderWidth:Q,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:tt,secondLinkTextColor:et,secondLinkFontName:nt,secondLinkFontStyle:ot,secondLinkFontSize:st,animation:it,animationDuration:at,animationBehaviour:rt,animationSlideDirection:ct}=o?{}:n,lt=document.createElement("style");t()&<.setAttribute("abtasty-script-added","true"),this.loadFont(p,y),this.loadFont(x,$),this.loadFont(K,G),this.loadFont(nt,ot);const dt=`background: ${["string"==typeof i?i:"rgba(255, 255, 255, 1)",a&&"string"==typeof r&&r.length?`url(${r})`:"",a&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",a&&"string"==typeof c?`/ ${c}`:"/ auto",a&&d&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,ut="number"==typeof m&&m>0,ht=`border: ${[ut?`${m}px`:"unset",ut?"solid":"",ut&&"string"==typeof u&&u.length?u:""].join(" ").trim()};`,mt=void 0!==h?`border-radius: ${h}px;`:"",gt=void 0!==g?`color: ${g}; fill: ${g}; -webkit-text-fill-color: ${g};`:"",bt=void 0!==b?`text-align: ${b};`:"",pt=p&&"inherit"!==p?`font-family:${p}_${y.match(N)?y.match(N)[1]:""};`:y||"",yt=w?`font-size: ${w}px;`:"",wt=void 0!==E&&E?`box-shadow: 0 5px ${L}px 0 ${k};`:"",vt=D instanceof Array&&1===D.length&&D[0],ft=vt?`margin: ${vt.top}px ${vt.right}px ${vt.bottom}px ${vt.left}px;`:"",Tt=vt?`margin: calc(${vt.top}px * 0.5) calc(${vt.right}px * 0.5) calc(${vt.bottom}px * 0.5) calc(${vt.left}px * 0.5);`:"",xt=B instanceof Array&&1===B.length&&B[0],$t=xt?`padding: ${xt.top}px ${xt.right}px ${xt.bottom}px ${xt.left}px;`:"",At=xt?`padding: calc(${xt.top}px * 0.5) calc(${xt.right}px * 0.5) calc(${xt.bottom}px * 0.5) calc(${xt.left}px * 0.5);`:"",Ct=void 0!==H&&H?`border-width: ${H}px; border-style: solid;`:"",St=[j,H].every(t=>void 0!==t)&&H?`border-color: ${j};`:"",Et=void 0!==z?`border-radius: ${z}px;`:"",kt=void 0!==F?`background-color: ${F};`:"",Lt=void 0!==U?`color: ${U}; fill: ${U}; -webkit-text-fill-color: ${U};`:"",Dt=K&&"inherit"!==K?`font-family:${K}_${G.match(N)?G.match(N)[1]:""};`:G||"",Bt=J?`font-size: ${J}px;`:"",Pt="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",It=[X,Q].every(t=>void 0!==t)&&Q?`border-color: ${X};`:"",Nt=void 0!==Z?`border-radius: ${Z}px;`:"",Rt=void 0!==tt?`background-color: ${tt};`:"",_t=void 0!==et?`color: ${et}; fill: ${et}; -webkit-text-fill-color: ${et};`:"",Ot=nt&&"inherit"!==nt?`font-family:${nt}_${ot.match(N)?ot.match(N)[1]:""};`:ot||"",Wt=st?`font-size: ${st}px;`:"",Vt="popin"!==s||void 0!==C&&!0!==C?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==S?S:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),qt="number"==typeof R?R:16,Mt=qt/2,Ht=o||void 0!==P&&P?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===I?`bottom: calc(100% + ${Mt}px)`:`top: ${Mt}px`)+";",`right: ${Mt}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof _?`border-radius: ${_}px;`:"","number"==typeof O&&O>0?`border: ${O}px solid ${void 0!==W?W:"rgba(57, 57, 57, 1)"};`:"","string"==typeof q?`background-color: ${q};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${qt}px;`,`height: ${qt}px;`,"string"==typeof V?`fill: ${V};`:"","}"].join(""):"",jt=v&&"string"==typeof T?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${T}; fill: ${T}; -webkit-text-fill-color: ${T};`,void 0!==f?`text-align: ${f};`:"",x&&"inherit"!==x?`font-family:${x}_${$.match(N)?$.match(N)[1]:""};`:$||"",A?`font-size: ${A}px;`:"","}"].join(""):"";let zt="";if("string"==typeof it){const e=(at/1e3).toFixed(2),n=["top","bottom"].includes(ct),o=Number(n),s=[(["top","left"].includes(ct)?"-":"")+"100vmax",this.translateValues?this.translateValues[o]:"0"];n&&s.reverse(),zt={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${e}s ${rt};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${e}s ${rt};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${e}s ${rt};`,"}"]}[t()&&!ABTASTY_S.WIDGETS.animationChanged?"none":it].join("")}const Ft=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Pt,It,Nt,Rt,_t,Ot,Wt,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,_t,Ot,Wt,"}"];return lt.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,dt,mt,ht,gt,bt,wt,ft,pt,yt,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,gt,bt,pt,yt,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",$t,pt,yt,"}",`#${this.widgetContainerId} .${this.contentClassName} a {`,"text-decoration: underline;","}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a, `,`#${this.widgetContainerId} .${this.contentClassName} button {`,"text-decoration: none;","box-sizing: border-box;","display: inline-block;",Ct,St,Et,kt,Lt,Dt,Bt,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"]) * {`,Lt,Dt,Bt,"}",...Y?Ft:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Tt,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,At,"}","}",Vt,Ht,jt,zt,`${e}`].join(""),lt}}const O=["top: 0;","top: 50%;","bottom: 0;"],W=["left: 0;","left: 50%;","right: 0;"],V=t=>1===t?"-50%":0,q=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:t,y:e}]}=DATA,n=`translate(${V(e)}, ${V(t)});`;return`${O[t]}${W[e]}transform: ${n}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},M=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,H=()=>{if(M())return"width: auto; height: auto; min-width: fit-content;";const{popinPercentWidth:t,popinPixelsWidth:e,widthUnit:n,autoHeight:o,popinPercentHeight:s,popinPixelsHeight:i,heightUnit:a}=DATA;return`width: ${"px"===n?e:t}${n};height: ${o?"auto":`${"px"===a?i:s}${a}`};`};class j extends _{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(t=>V(t)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:t,zindexCustom:e,widthUnit:n}=DATA,o="string"!=typeof DATA.overlay&&DATA.overlay;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===t?e:t};`,"background: none;","pointer-events: "+(o?"all":"none"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",q(),H(),"pointer-events: all","}",`${M()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!M()&&["px","em"].includes(n)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}class z extends _{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:t,zindexCustom:e}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;",`z-index: ${"custom"===t?e:t};`,"background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class F extends _{constructor(t,e){super(t,e),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const U=/.+\/([^.]+)\.(otf|ttf)$/,K=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"popin";const{layout:n,inlineLayoutContent:o}=DATA,{image:s}=DATA;return t&&"https://widgets-images.abtasty.com/widgets-default-image.png"!==s?`<div class="countdown_${e}_img_container">\n\t\t\t\t<img src="${s}" class="abtasty-countdown-image ${"popin"===n||"free"===n&&!o?"abtasty-countdown-image-popin-layout":""}">\n\t\t\t</div>`:""},G=["day","hour","minute","second"],J="line",Y=window.ABTASTY_S?.USER?.lang?ABTASTY_S.USER.lang.split("_")[0]:navigator.language.substring(0,2)||"en",Q=["fr","en","de","es","ja"].indexOf(Y)>-1?Y:"en",X=DATA.contentChosenLanguage,Z="default"===X?Q:X,tt=(t,e,n="long")=>{const o={style:"unit",unit:t,unitDisplay:n};return new Intl.NumberFormat(Z,o).format(e)};class et{constructor(t){let{parentContainer:e}=t;this.parentContainer=e,this.testId=TEST_ID,this.container=this.createContainer(),this.digitElements={},this.textElements={},this.timerElements={},this.timeLoop=null,this.maxWidth=0,this.previewTime=172799,this.fonts=[]}remove(){const{animationDuration:t}=DATA;setTimeout(()=>this.parentContainer.remove(),1.05*t)}addCloseEvent(e){e&&e.addEventListener("click",e=>{w(e),t()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),this.remove()},{capture:!0,passive:!1})}addRedirectionEvent(e){!t()&&e&&e.addEventListener("click",()=>{const{autoHide:t,timeHide:e}=DATA;t&&setTimeout(()=>{this.parentContainer.hide(),this.remove()},1e3*e),this.parentContainer.recurrence.setValidationRecurrence()},{useCapture:!0,once:!0})}createContainer(){const{linkType:t,redirectionUrl:e,openInNewTab:n}=DATA,o=document.createElement(t&&t.includes("widget")?"a":"div");switch(o.classList.add("abtasty-countdown"),t){case"widget":o.href=e,o.target=n?"_blank":"_self",this.addRedirectionEvent(o);break;case"widgetClose":o.href="#",o.dataset.abtastyActionnable="true",this.addCloseEvent(o)}return o}insert(t,e){return t.insertAdjacentElement(e,this.container),this}setText(t){const{layoutType:e,displayElapsedElements:n,layout:o,endSettings:s}=DATA,i={day:DATA.customDaysLabel,hour:DATA.customHoursLabel,minute:DATA.customMinutesLabel,second:DATA.customSecondsLabel},a=DATA.timeUnitLengthFormat;for(const o of G){const s=this.timerElements[o],r=String(t[o]).padStart(2,"0"),c=tt(o,r,a).match(/([\d,.]+)\s*(.+)/),l=c?c[1]:r;let d=c?c[2]:o;if(DATA.customTexts&&o in i&&(d=i[o]),n||(s.dataset.timeEnd=0===t[o]?"true":"false"),"textDigits"===e)s.textContent=`${l} ${d}`;else{const t=this.digitElements[o],e=this.textElements[o];t.textContent=l,e.textContent=d,this.maxWidth<t.offsetWidth&&(this.maxWidth=t.offsetWidth,t.style.minWidth=`${this.maxWidth}px`),t.style.minWidth=`${this.maxWidth}px`}}[null,"",s].includes(this.parentContainer.domElement.ariaLabel)&&["popin","bannerTop","bannerBottom"].includes(o)&&(this.parentContainer.domElement.ariaLabel=[...this.parentContainer.domElement.querySelectorAll(".abtasty-countdown-clock, .abtasty-countdown-top-message")].map(t=>t.textContent.replace(/\s+/g," "),"").join("").trim())}onTimeEnd(){const{endSettings:t,layout:e}=DATA;clearInterval(this.timeLoop);const n=this.container.querySelector("abtasty-countdown-clock");if(n&&(n.ariaLive="off"),"hideWidget"===t)return this.parentContainer.hide(),void(this.parentContainer.domElement.style.display="none");const o=this.container.querySelectorAll(".abtasty-countdown-elm-time");for(const t of o)t.removeAttribute("data-time-end");["popin","bannerTop","bannerBottom"].includes(e)&&(this.parentContainer.domElement.ariaLabel=DATA.endMessage);const s={endText:!0,endCountdown:["showText","showTextAndButton"].includes(t),endButton:["hideCountdownAndShowTextAndButton","showTextAndButton"].includes(t)},i=[`abtasty-countdown-${t}`,"abtasty-countdown-finish"];for(const t of Object.keys(s)){const e=s[t]?"show":"hide";i.push(`abtasty-countdown-${t}-${e}`)}this.container.classList.add(...i)}setCountdown(){const e=new Date;let n=function(e,n){switch(e.type){case"global":return e.timestamp-n.getTime();case"local":if(t())return e.previewTimestamp-n.getTime();const{year:o,month:s,day:i,hour:a,minute:r}=e.timecomponents;return new Date(o,s-1,i,a,r).getTime()-n.getTime();default:return 0}}(DATA.dateTime,e)/1e3;if(top.ABTastyEditor&&("ifEnded"===DATA.previewBlock&&(n=-1),this.previewTime-=1),n<=0)return this.setText({day:0,hour:0,minute:0,second:0}),void this.onTimeEnd();const o=Math.floor(n/86400);n-=86400*o;const s=Math.floor(n/3600);n-=3600*s;const i=Math.floor(n/60);n-=60*i;const a=Math.floor(n);this.setText({day:o,hour:s,minute:i,second:a})}setButton(){var t=this;const e=function(e,n,o,s){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const a=document.createElement("a");return a.ariaLabel=e,i&&(a.className="second_link"),a.innerHTML=`<span>${e}</span>`,a.href="button"===n?o:"#","button"===n?(a.target=s?"_blank":"_self",t.addRedirectionEvent(a)):(a.dataset.abtastyActionnable="true",t.addCloseEvent(a)),a},{linkType:n,buttonText:o,redirectionUrl:s,openInNewTab:i,secondLink:a,secondLinkText:r,secondLinkType:c,secondLinkURL:l,secondLinkOpenInNewTab:d,endBtnTargetBlank:u,endBtnLabel:h,endBtnLink:m}=DATA,g=this.container.querySelector(".abtasty-countdown-bottom-button"),b=[];if(n&&n.includes("button")){const t=e(o,n,s,i);if(b.push(t),a){const t=e(r,c,l,d,a);b.push(t)}}for(const t of b)g.appendChild(t);const p=this.container.querySelector(".abtasty-countdown-finish-button"),y=document.createElement("a");y.href=m,y.target=u?"_blank":"_self",y.innerHTML=h,y.ariaLabel=h,p.appendChild(y)}setContent(){const t=this.container.querySelector(".abtasty-countdown-finish-text"),e=document.createElement("div");if(e.innerHTML=DATA.endMessage,t.appendChild(e),"textDigits"===DATA.layoutType)return;const n=this.container.querySelector(".abtasty-countdown-top-message"),o=document.createElement("p");o.innerHTML=DATA.message,n.appendChild(o)}init(){const{layout:t,inlineLayoutContent:e,hideResponsiveImage:n,hideResponsiveText:o}=DATA;try{const s=["free","popin"].includes(t);(e=>{if(this.container.classList.add(`abtasty-countdown-layout-${e}`),s||(n&&this.container.classList.add("abtasty-countdown-hide-responsive-image"),o&&this.container.classList.add("abtasty-countdown-hide-responsive-text")),e===J){s&&(this.parentContainer.domElement.querySelector(`.${this.parentContainer.contentClassName}`).classList.add(`abtasty-countdown-content-${t}-inline`),this.container.classList.add(`abtasty-countdown-layout-${t}-inline`));const e=this.parentContainer.domElement.querySelectorAll(`.${this.parentContainer.closeButtonClassName}`);for(const t of e)t.classList.add("abtasty-countdown-close-inline")}})(s&&!e?"free":J),this.container.innerHTML=(()=>{const{layout:t,inlineLayoutContent:e,imagePosition:n,layoutType:o}=DATA,s="popin"===t||"free"===t&&!e,i=`\n ${K(s&&!("popin"===t&&e),"popin")}\n <div class="abtasty-countdown-layout-${t} abtasty-countdown-mini">\n ${K(!s&&"before"===n,"banner")}\n <div class="abtasty-countdown-top-message">\n ${DATA.messageMinimalistMode.split(/!countdown!/gm).map(t=>`<p>${t.trim()}</p>`).join('\n <span class="abtasty-countdown-days abtasty-countdown-elm-time"></span>\n <span class="abtasty-countdown-hours abtasty-countdown-elm-time"></span>\n <span class="abtasty-countdown-minutes abtasty-countdown-elm-time"></span>\n <span class="abtasty-countdown-seconds abtasty-countdown-elm-time"></span>\n').replace("<p></p>","")}\n </div>\n ${K(!s&&"after"===n,"banner")}\n <div class="abtasty-countdown-finish-text"></div>\n <div class="abtasty-countdown-finish-button"></div>\n <div class="abtasty-countdown-bottom-button buttons_container"></div>\n </div>\n `,a=`\n ${K(s&&!("popin"===t&&e),"popin")}\n <div class="abtasty-countdown-layout-${t} abtasty-countdown-standard">\n ${K(!s&&"before"===n,"banner")}\n <div class="abtasty-countdown-clock" role="timer" aria-live="polite">\n <div class="abtasty-countdown-days abtasty-countdown-elm-time">\n <div class="abtasty-countdown-days__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-days__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-hours abtasty-countdown-elm-time">\n <div class="abtasty-countdown-hours__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-hours__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-minutes abtasty-countdown-elm-time">\n <div class="abtasty-countdown-minutes__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-minutes__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-seconds abtasty-countdown-elm-time">\n <div class="abtasty-countdown-seconds__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-seconds__text abtasty-countdown-elm-text"></div>\n </div>\n </div>\n ${K(!s&&"after"===n,"banner")}\n <div class="abtasty-countdown-top-message"></div>\n <div class="abtasty-countdown-finish-text"></div>\n <div class="abtasty-countdown-finish-button"></div>\n <div class="abtasty-countdown-bottom-button buttons_container"></div>\n </div>\n `;return"textDigits"===o?i:a})(),this.container.insertAdjacentElement("afterbegin",(t=>{const e=document.createElement("style");return e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t)),e})(`@media (min-width:741px){.abtasty-countdown-layout-line .abtasty-countdown-elm-time{margin:0}}@media (max-width:740px){.abtasty-countdown-layout-line>div:not(.abtasty-countdown-layout-popin){-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.abtasty-countdown-layout-line div.abtasty-countdown-finish-text,.abtasty-countdown-layout-line div.abtasty-countdown-top-message{margin-bottom:20px}.abtasty-countdown-layout-line div.abtasty-countdown-bottom-button a{margin-left:0}}@media (max-width:579px){.ab_widget_container_countdown_content{max-width:100%;width:100vw}.abtasty-countdown-layout-free,.abtasty-countdown-layout-popin{-webkit-box-orient:vertical!important;-webkit-box-direction:normal!important;-ms-flex-direction:column!important;flex-direction:column!important;margin:10px 0!important}.abtasty-countdown-hide-responsive-image .countdown_banner_img_container,.abtasty-countdown-hide-responsive-text .abtasty-countdown-top-message{display:none}}.abtasty-countdown,.abtasty-countdown>div{display:inline-block;text-align:center}.abtasty-countdown>div{margin:10px;overflow:auto;white-space:normal;width:100%}.abtasty-countdown .countdown_popin_img_container{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:center;max-width:100%}.abtasty-countdown .countdown_popin_img_container:empty{display:none}.abtasty-countdown .abtasty-countdown-finish-text,.abtasty-countdown .abtasty-countdown-top-message{margin-bottom:15px}.abtasty-countdown .abtasty-countdown-elm-time{display:inline-block;margin:6px 6px 15px;padding:6px}.abtasty-countdown .abtasty-countdown-elm-number,.abtasty-countdown .abtasty-countdown-elm-text{font-stretch:normal;font-style:normal;font-weight:700;letter-spacing:normal;line-height:normal;text-align:center}.abtasty-countdown .abtasty-countdown-bottom-button a,.abtasty-countdown .abtasty-countdown-finish-button a{cursor:pointer;display:block;display:inline-block;padding:6px 10px;text-align:center;text-decoration:none}.abtasty-countdown-layout-line>div{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:stretch;-ms-flex-pack:stretch;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:stretch}.abtasty-countdown-layout-line>div>div{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}.abtasty-countdown-layout-free{display:block;text-align:center}.abtasty-countdown-layout-line>div{margin:0}.abtasty-countdown-layout-line .abtasty-countdown-finish-text,.abtasty-countdown-layout-line .abtasty-countdown-top-message{-webkit-box-sizing:border-box;box-sizing:border-box;margin-bottom:0;padding:0 5px 0 15px}.abtasty-countdown-layout-line .abtasty-countdown-top-message p{margin-bottom:0}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button a{margin-left:30px}.abtasty-countdown-layout-line{-webkit-box-sizing:border-box;box-sizing:border-box}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button,.abtasty-countdown-layout-line .abtasty-countdown-clock,.abtasty-countdown-layout-line .abtasty-countdown-finish-button{-ms-flex-negative:0;flex-shrink:0}.abtasty-countdown-finish-button,.abtasty-countdown-finish-text{display:none}.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-show.abtasty-countdown-clock,.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:block}.abtasty-countdown-layout-line.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-layout-line.abtasty-countdown-endCountdown-show .abtasty-countdown-clock,.abtasty-countdown-layout-line.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:table-cell}.abtasty-countdown-endButton-hide .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-hide .abtasty-countdown-clock,.abtasty-countdown-endText-hide .abtasty-countdown-finish-text,.abtasty-countdown-finish .abtasty-countdown-bottom-button,.abtasty-countdown-finish .abtasty-countdown-top-message{display:none!important}.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-text,.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-text{width:55%!important}.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-button,.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-button{width:45%!important}.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-text,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-text{width:30%!important}.abtasty-countdown-showText .abtasty-countdown-layout-bannerBottom .abtasty-countdown-clock,.abtasty-countdown-showText .abtasty-countdown-layout-bannerTop .abtasty-countdown-clock,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-clock,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-button,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-clock,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-button{width:35%!important}.abtasty-countdown-showText .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-text,.abtasty-countdown-showText .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-text{width:65%}.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerBottom,.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerTop,.abtasty-countdown-showText .abtasty-countdown-layout-bannerBottom,.abtasty-countdown-showText .abtasty-countdown-layout-bannerTop,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop{width:100%}.abtasty-countdown-standard .abtasty-countdown-clock>.abtasty-countdown-elm-time[data-time-end=true]+.abtasty-countdown-elm-time[data-time-end=true],.abtasty-countdown-standard .abtasty-countdown-clock>.abtasty-countdown-elm-time[data-time-end=true]:first-child{display:none}.abtasty-countdown-content-popin-inline,.abtasty-countdown-content-popin-inline .abtasty-countdown-layout-popin{max-width:inherit;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content}.abtasty-countdown-content-free-inline{max-width:100%}.abtasty-countdown-image-popin-layout{margin-bottom:20px}.abtasty-countdown-layout-popin{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.countdown_banner_img_container{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:center;padding:0 15px}.countdown_banner_img_container img{max-height:67px;max-width:200px}.abtasty-countdown .abtasty-countdown-mini .abtasty-countdown-elm-time{border:none;margin:0;padding:0}.abtasty-countdown .abtasty-countdown-mini .abtasty-countdown-top-message{display:inline-block;white-space:unset;width:100%}.abtasty-countdown .abtasty-countdown-mini .abtasty-countdown-top-message>*{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex}.abtasty-countdown-mini .abtasty-countdown-top-message>.abtasty-countdown-elm-time[data-time-end=true]+.abtasty-countdown-elm-time[data-time-end=true],:not(.abtasty-countdown-showTextAndButton) :not(.abtasty-countdown-showText) .abtasty-countdown-mini .abtasty-countdown-top-message>.abtasty-countdown-elm-time[data-time-end=true]:first-child{display:none} ${(t=>{const e=[{fontName:DATA.messageFontName,fontStyle:DATA.messageFontStyle},{fontName:DATA.numbersfontName,fontStyle:DATA.numbersfontStyle},{fontName:DATA.legendfontName,fontStyle:DATA.legendfontStyle}];for(const{fontName:n,fontStyle:o}of e)t(n,o);const{buttonsAlign:n,messageAlign:o,textColor:s,messageFontSize:i,messageFontName:a,messageFontStyle:r,numbersfontSize:c,numberstextColor:l,numbersfontName:d,numbersfontStyle:u,legendfontName:h,legendfontStyle:m,legendfontSize:g,legendtextColor:b,countdownBorderRadius:p,countdownBorderWidth:y,countdownBorderColor:w,numbersBackgroundColor:v}=DATA,f=void 0!==n&&"fill"!==n?`text-align: ${n};`:"",T=(t,e)=>t&&"inherit"!==t?`font-family:${t}_${e.match(U)?e.match(U)[1]:""};`:e||"",x=T(a,r),$=T(d,u);return`\n .abtasty-countdown-bottom-button,\n .abtasty-countdown-finish-button {\n ${f};\n }\n .abtasty-countdown-bottom-button a,\n .abtasty-countdown-finish-button a {\n width: ${"fill"===n?"100%":"auto"};\n }\n\n .abtasty-countdown .abtasty-countdown-finish-text,\n .abtasty-countdown .abtasty-countdown-top-message,\n .abtasty-countdown .abtasty-countdown-finish-text *,\n .abtasty-countdown .abtasty-countdown-top-message * {\n white-space: pre-line;\n text-align: ${o} !important;\n color: ${s};\n font-size: ${i}px;\n ${x};\n }\n\n .abtasty-countdown .abtasty-countdown-elm-number,\n .abtasty-countdown .abtasty-countdown-elm-number * {\n font-size: ${c}px;\n color: ${l};\n fill: ${l};\n -webkit-text-fill-color: ${l};\n font-weight: initial;\n ${$};\n }\n\n .abtasty-countdown .abtasty-countdown-elm-text,\n .abtasty-countdown .abtasty-countdown-elm-text * {\n ${T(h,m)};\n font-size: ${g}px;\n color: ${b};\n -webkit-text-fill-color: ${b};\n }\n\n .abtasty-countdown > div:not(.abtasty-countdown-mini) .abtasty-countdown-elm-time {\n border-radius: ${p}px;\n border: ${y}px solid ${w};\n background-color: ${v};\n }\n\n .abtasty-countdown > .abtasty-countdown-mini .abtasty-countdown-elm-time {\n font-size: ${c}px;\n color: ${l};\n fill: ${l};\n -webkit-text-fill-color: ${l};\n font-weight: initial;\n ${$};\n }`})(this.parentContainer.loadFont)}`));for(const t of G){const e=this.container.querySelector(`.abtasty-countdown-${t}s`);this.timerElements[t]=e,this.digitElements[t]=e.querySelector(".abtasty-countdown-elm-number"),this.textElements[t]=e.querySelector(".abtasty-countdown-elm-text")}this.setContent(),this.setButton(),this.timeLoop=setInterval(this.setCountdown.bind(this),1e3),this.setCountdown()}catch(t){console.warn("Countdown error occurred during widget rendering:",t)}}}!async function(){l("Widget launch");const t=(()=>{const{layout:t}=DATA;let e;switch(t){case"popin":e=new j;break;case"bannerTop":case"bannerBottom":e=new z;break;case"free":e=new F;break;default:e=new _}return e})(),{response:e}=await t.init(!0),n=t.domElement.querySelector(`.${t.contentClassName}`),o=new et({parentContainer:t});o.init(),o.insert(n,"beforeend"),e&&t.show()}()}();
|
1
|
+
!function(){"use strict";const t=()=>Object.prototype.hasOwnProperty.call(top,"ABTastyEditor"),e=()=>{const t=!!document.getElementById("ABTastyPreviewBar"),e=location.href.includes("ab_project=preview");return t||e},n=t=>new Function(`try {\n\t\t${t}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),o=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),s=()=>!t()&&(e()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),i=()=>window.ABTasty&&!0===window.ABTasty.consentReady,a=()=>{const{type:t}=DATA;return`${PACKAGE.replace("@abtasty/","")}${t?`_${t}`:""}`},r=()=>{const t=a();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=n=>{const o=(()=>{if(t()||e())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),s=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(o||s){const t=r();window.console.log(`%c${t} - ${o?"QA":"Debug"} Mode for campaign ${TEST_ID} %c ${n}`,"background-color: #D6FF01; color: #3100be; padding: 3px 0 3px 10px; border-radius: 5px 0 0 5px; font-weight: bold;","background-color: #3100be; color: white; padding: 3px 10px 3px 0; border-radius: 0 5px 5px 0;")}},d=t=>{const e={promise:null,resolve:null,reject:null,name:t};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e},u=(t,e)=>{const n=e?[]:null;if("string"!=typeof t||!t.trim().length)return n;const[o,s,i]=t.split("[]").map(t=>t.trim()),a=Boolean(i)?i:t,r=s?document.querySelector(o)?.[s]:document;return r?e?[...r.querySelectorAll(a)]:r.querySelector(a):n},h=t=>u(t,!1),m=t=>u(t,!0),g=(t,e)=>{const n={childList:!0,subtree:!0,attributes:!0},o=()=>s.disconnect(),s=new MutationObserver(()=>{const n=h(e);return n&&!o()&&t(n)});return{clear:o,observe:t=>{const e=document.querySelector("body")||document.documentElement,o=t??e;s.observe(o,n)}}},b=()=>{},p=(e,n)=>{const o=h(e),s={selector:e,clear:b,observe:b};if(o)return setTimeout(()=>n(o),0),s;if(t())return setTimeout(()=>p(e,n),1e3),s;if(e.includes("[]"))return((t,e)=>{const[n,o]=e.split("[]").map(t=>t.trim()),s=h(n),i=s?.[o],{clear:a,observe:r}=g(t,e),c=()=>{const n=h(e);return n&&!l()&&t(n)},l=()=>{a(),s?.removeEventListener("load",c)},d=()=>{r(i),"iframe"===s?.localName&&s.addEventListener("load",c)};return d(),{selector:e,clear:l,observe:d}})(n,e);const{clear:i,observe:a}=g(n,e);return a(),{selector:e,clear:i,observe:a}};function y(t,e){const n=t.parentElement||t.getRootNode().host;return e(t)||!n?t:y(n,e)}const w=e=>{t()||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())},v=(t,e)=>[...m(e)].some(n=>{const[o,,s]=e.split("[]"),i=s??o;return n===t||!!t.closest(i)});let f=!1;class T{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=null,this.mutationObserver=null,this.mouseOverEvent=null,this.scrollEvent=null,this.onTransitionEnd=null,this.onIframeLoad=null}transitionOverHandler(t){const e=[t,"transitionend",this.checkElements.bind(this),!0];return this.getEvents(...e)}intersectionHandler(t){t.forEach(t=>{t.isIntersecting?(this.existingTargets.forEach(e=>{e.element.isSameNode(t.target)&&(this.inViewportTargets.push(e),this.mouseOverEvent.start(),this.scrollEvent.start(),this.onTransitionEnd.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(e=>!e.element.isSameNode(t.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear(),!1))})}startVisibilityObserver(t){const e={root:t,rootMargin:"0px",threshold:.01};return this.visibilityObserver??=new IntersectionObserver(this.intersectionHandler.bind(this),e),this.visibilityObserver}startMutationObserver(t){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(t,{attributes:!0,childList:!0,subtree:!0}),this.mutationObserver}onMouseOver({target:t,path:e}){const n=this.inViewportTargets.find(({element:n,selector:o})=>{if(n.isSameNode(t))return!0;const[s,,i]=o.split("[]"),a=i??s,r=[...t.querySelectorAll(a)];if(r.length&&r.includes(n))return!0;if(e.includes(n))return!0;if(!t.parentElement?.children?.length)return;const c=[...t.parentElement.children],l=c.findIndex(e=>e.isSameNode(t)),d=c.filter((t,e)=>e>l);if(d.length){if(d.includes(n))return!0;if(d.some(t=>[...t.querySelectorAll(a)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:t,element:e,uniqueId:o}=n,s=this.targets.find(e=>e.selector===t&&e.uniqueId===o);s&&s.resolve(e),this.clear(t,o)}}getEvents(t,...e){return{start:()=>t?.addEventListener(...e),clear:()=>t?.removeEventListener(...e)}}mouseOverHandler(t){const e=[t,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?"touchmove":"mouseover",t=>{const e=t.composedPath(),{target:n}=t;setTimeout(()=>this.onMouseOver({target:n,path:e}),50)},!0];return this.getEvents(...e)}scrollEventHandler(t){const e=[t,"scroll",(n=this.checkElements.bind(this),()=>{f||(f=!0,setTimeout(()=>{n(),f=!1},100))}),{passive:!0}];var n;return this.getEvents(...e)}isElementVisible(t){return this.isElementOpaque(t)&&this.isElementTopmost(t)}isElementOpaque(t){return"HTML"===y(t,t=>"0"===window.getComputedStyle(t).opacity).nodeName}isElementTopmost(t){const e=t.getBoundingClientRect(),n=[[e.left,e.top],[e.right,e.top],[e.left,e.bottom],[e.right,e.bottom],[e.left+e.width/2,e.top],[e.left+e.width/2,e.bottom],[e.left,e.height/2],[e.right,e.height/2],[e.left+e.left/2,e.height/2]];let o=!1,s=0;for(;!o&&s<n.length;){const e=t.getRootNode()?.elementFromPoint(...n[s]);o=t===e||e?.contains(t)||t.contains(e),s+=1}return o}checkElements(){this.targets.forEach(({selector:t,uniqueId:e})=>{const n=h(t),[o,,s]=t.split("[]"),i=s??o;n&&!this.existingTargets.find(t=>t.element.matches(i)&&t.uniqueId===e)&&(this.existingTargets.push({element:n,selector:t,uniqueId:e}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:t,element:e})=>!(!h(t)||!e.isConnected)||(e&&this.visibilityObserver.unobserve(e),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:t,element:e,uniqueId:n})=>{const[o,,s]=t.split("[]"),i=s??o;if(e.matches(i)&&this.isElementVisible(e)){const o=this.targets.find(e=>e.selector===t&&e.uniqueId===n);return o&&o.resolve(e),this.clear(t,n),!1}return!0})}onLoadIframe(t){const e=[t.defaultView.frameElement,"load",()=>this.watch(selector,resolve,uniqueId).bind(this),{passive:!0}];return this.getEvents(...e)}watch(t,e,n){this.targets.push({selector:t,resolve:e,uniqueId:n});const{clear:o}=p(t,t=>{o();const e=t.getRootNode({composed:!0}),n="body"in e?e.body:document;this.mouseOverEvent=this.mouseOverHandler(e),this.scrollEvent=this.scrollEventHandler(e),this.onTransitionEnd=this.transitionOverHandler(e),e.defaultView?.frameElement&&(this.onIframeLoad=this.onLoadIframe(e),this.onIframeLoad.start()),this.startVisibilityObserver(e),this.startMutationObserver(n),this.checkElements()})}clear(t,e){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:o})=>n!==t&&o!==e));const n=h(t);n&&this.visibilityObserver?.unobserve(n),0===this.targets.length&&(this.mutationObserver?.disconnect(),this.onIframeLoad?.clear()),0===this.inViewportTargets.length&&(this.mouseOverEvent?.clear(),this.scrollEvent?.clear(),this.onTransitionEnd?.clear())}}const x="remove",C="rebuild",A="update",S="ABTastyData";class E{constructor({triggerEvent:t,triggerSelector:e,triggerDelay:n,triggerTarget:o}){this.event=t,this.selector=Boolean(e)?e:"body",this.target="string"==typeof o?h(e):o,this.delay=1e3*n,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:t,resolve:e}){const n=d(`${this.event}DomReady`);this.promises.push(n);const{clear:o}=p(this.selector,()=>{const t=new T;this.visibilityObservers.push(t),t.watch(this.selector,e,c())});return this.elementWaiters.push(o),t}onPageLoad({promise:t,resolve:e}){const n=()=>"complete"===document.readyState;if(!n()){const o=["readystatechange",()=>n()&&e(!0),{passive:!0}];return this.eventsListeners.push([document,...o]),document.addEventListener(...o),t}return e(!0),t}onClick({promise:t,resolve:e}){const n=({isTrusted:t,target:n})=>{if(t)return(n.isEqualNode(this.target)||v(n,this.selector))&&e(!0)},{clear:o}=p(this.selector,t=>{o();const e=document.createElement("style");e.id=`Click_${c()}`;const[s,,i]=this.selector.split("[]"),a=i??s;e.innerHTML=`${a} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const r=t.getRootNode();("head"in r?r.head:r).appendChild(e),this.triggerElements.push(e);const l=["click",n,{passive:!0,capture:!0}];this.eventsListeners.push([r,...l]),r.addEventListener(...l)});return this.elementWaiters.push(o),t}onHover({promise:t,resolve:e}){const n=({isTrusted:t,target:n})=>{if(t)return(this.target?n.isEqualNode(this.target):v(n,this.selector))&&e(!0)},{clear:o}=p(this.selector,t=>{const e=t.getRootNode(),o="body"in e?e.body:[...e.childNodes].find(e=>e.contains(t)),s=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([o,...s]),o.addEventListener(...s)});return this.elementWaiters.push(o),t}onExitIntent({promise:t,resolve:e}){const n=["mouseleave",({isTrusted:t,clientY:n})=>{t&&n<=0&&e(!0)},{passive:!0}],{clear:o}=p("html",t=>{o(),this.eventsListeners.push([t,...n]),t.addEventListener(...n)});return t}onReengage({promise:t,resolve:e}){const n=this.delay;let o=n;const s=[...document.querySelectorAll("*:empty")].map(t=>t.contentDocument||t.shadowRoot).filter(t=>t),i=[({isTrusted:t})=>{t&&(o=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(t=>{[document,...s].forEach(e=>{this.eventsListeners.push([e,t,...i]),e.addEventListener(t,...i)})});const a=setInterval(()=>{o<=0?e(!0):o-=100},100);return this.intervals.push(a),t}onCustomTrigger({promise:t,resolve:e}){const{triggerEventCustomScript:n,tagIsSafeEval:o}=DATA,s=o&&DATA_JS?.triggerEventCustomScript,i="function"==typeof s?()=>new Promise(t=>s(t)):new Function(`return new Promise(async resolve => {${n}})`);return i().then(t=>t&&e(!0)),t}onScrollUp({promise:t,resolve:e}){let n=0;const o=["scroll",({isTrusted:t})=>{t&&(window.scrollY<n?e(!0):n=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...o]),document.addEventListener(...o),t}onScrollPercentReached({promise:t,resolve:e}){const{triggerEventScrollPercent:n}=DATA,o=["scroll",({isTrusted:t})=>{if(!t)return;const o=(()=>{const{documentElement:t,body:e}=document,n=t.scrollTop||e.scrollTop,o=t.scrollHeight||e.scrollHeight;return Math.trunc(n/(o-t.clientHeight)*100,10)})();n<o&&e(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...o]),document.addEventListener(...o),t}checkSocialProofConditions(t,e,n,o){const s=(()=>{let t;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?t=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?t=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(t=window.ABTasty.accountSettings.identifier),t):t})(),{viewInterval:i,spNoTrim:a}=DATA;if(this.socialProofStore.hasOwnProperty(t))n(this.socialProofStore[t])?o(`${this.socialProofStore[t][i]}`):o(!1);else if(t&&s){const r=e=>(this.socialProofStore[t]=e,o(!!n(e)&&`${e[i]}`));fetch(`https://api-social-proof.abtasty.com/clients/${s}/metrics/${e}?key=${t}${a?"&noTrim=true":""}`).then(t=>t.ok&&t.json()).then(r).catch(()=>l("Failed to fetch datas from server."))}else o(!1)}getSocialProofDatas({promise:t,resolve:e},s,i=!1){const{productKey:a,keyType:r}=(()=>{const{socialProofContentType:t,productKeyProvider:e,pathToProductKey:s,customJSProductKey:i,productSKU:a,tagIsSafeEval:r}=DATA,{pathToProductKey:c,customJSProductKey:l}=r&&DATA_JS||{};if(2===t)return{productKey:o(),keyType:"url"};{let r=null,d="sku";switch(e){case"ABTastyProductKey":r=window.ABTastyProductKey;break;case"pathToProductKey":r="function"==typeof c?c():n(`return ${s};`);break;case"customJSProductKey":r="function"==typeof l?l():n(i);break;case"productSKU":r=a}return r||3!==t||(r=o(),d="url"),{productKey:r,keyType:d}}})(),{viewInterval:c,triggerSocialProofMinVisitors:d,triggerSocialProofMinPurchases:u,triggerSocialProofMinPageViews:h}=DATA,m={pv:h,i:u,"v-pv":d}[s];return[typeof c,typeof m].includes("undefined")&&e(!1),i&&!a&&(l("Not able to find ABTastyProductKey, impossible to call the API, read documentation for more informations:\n\t\t\t\thttps://support.abtasty.com/hc/en-us/articles/4710919241628-Widgets-List#h_84c04344-c655-4e5e-b9ab-d26a798ad9b0"),e(!1)),this.checkSocialProofConditions(a,"v-pv"===s&&"sku"===r?"v-i":s,t=>{const e=void 0!==t[c]&&t[c]>=m;return e||l(`Widget will not be shown, Social Proof API returned ${t[c]} while ${m} are required`),e},e),t}onConsent({promise:t,resolve:e}){if(!i()){const n=["abtasty_consentValid",()=>e(!0)];return this.eventsListeners.push(n),window.addEventListener(...n),t}return e(!0),t}onTrackingSent({promise:t,resolve:e}){const{triggerEventTrackingSent:n}=DATA;let o=localStorage.getItem(S);const s=()=>JSON.parse(o)?.ActionTracking?.some(({name:t})=>t===n),i=["storage",({key:t,newValue:n})=>{t===S&&(o=n,s()&&e(!0))},{passive:!0,capture:!0}];return o&&s()?e(!0):(()=>{this.eventsListeners.push([window,...i]),window.addEventListener(...i)})(),t}onMinPagesViewed({promise:t,resolve:e}){const{triggerEventMinPagesViewed:n}=DATA;let o=localStorage.getItem(S);const s=()=>n<=(o?JSON.parse(o)?.VisitedPages?.length:0),i=["storage",({key:t,newValue:n})=>{t===S&&(o=n,s()&&e(!0))},{passive:!0,capture:!0}];return o&&s()?e(!0):(()=>{this.eventsListeners.push([window,...i]),window.addEventListener(...i)})(),t}onRageClick({promise:t,resolve:e}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:o}=DATA;let s=0,i=!1;const a=["click",({isTrusted:t})=>{if(t&&(s+=1,s>=n&&e(!0),!i)){i=!0;const t=setTimeout(()=>{s=0,i=!1},o);this.timeouts.push(t)}},{passive:!0,capture:!0}],r=t=>{this.eventsListeners.push([t,...a]),t.addEventListener(...a)},{clear:c}=p("iframe []contentDocument[] body > *",()=>{const t=document.getElementsByTagName("iframe");for(const e of t){"contentDocument"in e&&"body"in e.contentDocument&&r(e.contentDocument);const t=()=>r(e.contentDocument);e.addEventListener("load",t),this.eventsListeners.push([e,"onIframeLoad",t])}});return this.elementWaiters.push(c),r(document),t}clear(){this.triggerElements=this.triggerElements.filter(t=>(t.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(t=>{const[e,...n]=t;return e&&n.length>1&&e.removeEventListener(...n),!1}),this.timeouts=this.timeouts.filter(t=>(clearTimeout(t),!1)),this.intervals=this.intervals.filter(t=>(clearInterval(t),!1));const t=c();return this.visibilityObservers=this.visibilityObservers.filter(e=>(e.clear(this.selector,t),!1)),this.promises=this.promises.filter(t=>(t.resolve(!1),!1)),this.elementWaiters=this.elementWaiters.filter(t=>(t(),!1)),this}async isTriggered(){this.clear();const t=d(this.event);this.promises.push(t);const e={consent:()=>this.onConsent(t),direct:()=>!0,pageLoad:()=>this.onPageLoad(t),click:()=>this.onClick(t),exitIntent:()=>this.onExitIntent(t),reengage:()=>this.onReengage(t),elementVisible:()=>this.onElementVisible(t),script:()=>this.onCustomTrigger(t),hover:()=>this.onHover(t),scrollUp:()=>this.onScrollUp(t),scrollPercent:()=>this.onScrollPercentReached(t),rageClick:()=>this.onRageClick(t),minPagesViewed:()=>this.onMinPagesViewed(t),trackingSent:()=>this.onTrackingSent(t),socialProofPurchases:()=>this.getSocialProofDatas(t,"i",!0),socialProofPageViews:()=>this.getSocialProofDatas(t,"pv"),socialProofVisitors:()=>this.getSocialProofDatas(t,"v-pv")},n=!Object.prototype.hasOwnProperty.call(e,this.event)||await e[this.event]();return n&&this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const t=d(`${this.event}Delay`);this.promises.push(t);const e=setTimeout(()=>{t.resolve(!0),this.clear()},this.delay);return this.timeouts.push(e),t.promise})():n}}const k="display",L="closing",B="validation",D="ABTastyWidgets",P=`${D}Temporary`;class I{constructor({displayRecurrence:t,closingRecurrence:e,validationRecurrence:n},o){this.displayRecurrence=parseFloat(t),this.closingRecurrence=parseFloat(e),this.validationRecurrence=parseFloat(n),this.onSetCallback=o,this.widgetName=a(),this.uniqueId=c(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:t}){const e=localStorage.getItem(P),n=sessionStorage.getItem(D);"ABTastyData"===t&&!e&&n&&localStorage.setItem(P,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(t){try{const e=t.getItem(D);return JSON.parse(e)}catch(e){return t.removeItem(D),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(t,e){const{[this.recurrenceKey]:n,...o}=e;return Object.entries(o).length?(t.setItem(D,JSON.stringify(o)),o):(t.removeItem(D),!1)}removeSessionRecurrenceStorage(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.sessionStorage,t)}removeLocalRecurrenceStorage(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&this.removeGivenStorage(window.localStorage,t)}getSessionRecurrence(){const t=this.getSessionRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getLocalRecurrence(){const t=this.getLocalRecurrenceStorageParsed();return!!t&&t[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();return t||e||{type:!1}}isOver(){const t=localStorage.getItem(P),e=!(!t||!t.includes(this.recurrenceKey))||this.getSessionRecurrence();t&&(sessionStorage.setItem(D,t),localStorage.removeItem(P));const n=this.getLocalRecurrence(),o=(n?parseFloat(n.stamp):0)<(new Date).getTime();return o&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&o&&!this.getLocalRecurrence()&&!e}setRecurrence(t,n){0!==t&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const o=this.getTypeOfStorage(t);if(e()||!o&&"object"!=typeof o)return!1;const{storageString:s,storageMethod:a}=o,r=this.getStamp(t),c={type:n,stamp:r},{type:l}=this.getCurrentRecurrence(),d=async()=>{if(!i()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const t=new E({triggerEvent:"consent"});await t.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const t=this.getSessionRecurrence(),e=this.getLocalRecurrence();let n;"session"===s?t?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(e?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const o=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};a.setItem(D,JSON.stringify(o)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!a)return!1;if(l&&n!==B)if(n===L&&l!==B)d();else{if(n!==k||l===B||l===L)return!1;d()}else d();return r}setDisplayRecurrence(){const t=k;this.setRecurrence(this.displayRecurrence,t)}setClosingRecurrence(){const t=L;this.setRecurrence(this.closingRecurrence,t)}setValidationRecurrence(){const t=B;this.setRecurrence(this.validationRecurrence,t)}getStamp(t){return(new Date).getTime()+864e5*t}getTypeOfStorage(t){return!(isNaN(t)||t<0||0!==t&&!t)&&(t>0?{storageString:"local",storageMethod:window.localStorage}:0===t&&{storageString:"session",storageMethod:window.sessionStorage})}}class N{constructor(t,e,n){this.isWidgetApplied=t,this.callback=e,this.shouldUpdate=n,this.triggerIframeTarget=null,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.tagRollbackEventParams=["abtasty_resetActionTracking",this.onTagRollback.bind(this)],this.onCampaignLaunchedEventParams=["abtasty_executedCampaign",this.onCampaignLaunched.bind(this)]}decisionHandler(t){const e=!t&&this.isWidgetApplied(),n=e?this.shouldUpdate&&A:C;return n?(this.clearWatcher(),this.callback(n,!t,e),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:t}}){t===TEST_ID&&(this.callback(C,!1),this.watch())}onTagRollback({target:t}){return this.clearWatcher(t),this.callback(x,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(t){return s()?t.some(t=>["removedNodes","addedNodes"].some(e=>t[e]&&t[e].length))?this.decisionHandler():this:this.callback(x,!1)}watch(e,n){if(t())return this;if(this.clearWatcher(e),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),n?.includes("[]contentDocument[]")){const t=n.split("[]")[0].trim(),{clear:e}=p(t,t=>{e(),this.triggerIframeTarget=t,t.addEventListener("load",this.decisionHandler.bind(this))})}const o=e?.defaultView?.frameElement;o&&this.triggerIframeTarget!==o&&o.addEventListener("load",this.decisionHandler.bind(this));const{clear:s}=p("body",t=>{s();const n=e?.body||e||t;this.observer.observe(n,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(t){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),t?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const R=/.+\/([^.]+)\.(otf|ttf)$/,_=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class O{constructor(e,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=a(),this.prettyName=r(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:n,validationRecurrence:o}=DATA,s=!e&&!n&&!o;if(t()||s)return!1;const i={everytime:()=>-1,session:()=>0,once:()=>395,day:t=>DATA[`${t}_day`],week:t=>7*DATA[`${t}_week`],month:t=>30.5*DATA[`${t}_month`]},a={};return e&&(a.displayRecurrence=i[e]("displayRecurrence")),n&&(a.closingRecurrence=i[n]("closingRecurrence")),o&&(a.validationRecurrence=i[o]("validationRecurrence")),a})(),this.triggerParams=(e=>{let{triggerEvent:n}=DATA;const{triggerEventClick:o,triggerEventHover:s,triggerEventReengageDelay:i,socialProofContentType:a,triggerEventElementVisible:r,triggerEventDelay:c}=DATA;if(t()||!n&&!a)return!1;const l={click:()=>o,hover:()=>s,elementVisible:()=>r},d=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",u="reengage"===n?i:c;return a&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][a]),{triggerEvent:n,triggerSelector:d,triggerDelay:u,triggerTarget:e}})(e),this.recurrence=!!this.recurrenceParams&&new I(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new E(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&_.includes(this.triggerParams.triggerEvent),this.pageWatcher=new N(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:t,triggerEvent:e}=DATA;return!e||!["click","hover","scrollUp","script"].includes(e)||t})(),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.rootElement=null,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.elementsWaiters=[]}clearGivenClearables(){for(const t of this.elementsWaiters)t.clear();this.elementsWaiters=[]}isWidgetApplied(){return this.domElement?.isConnected&&this.domElement.ownerDocument?.defaultView}removeOldDomElement(){const t=this.rootElement?.getElementById(this.widgetContainerId);return t?.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const t=["free"];"drawer"===DATA.layout&&DATA.customTarget&&t.push("drawer");const e=t.includes(DATA.layout);return new Promise(t=>{const{elementReferrer:n="body",referrerInsertType:o="beforeend"}=e?DATA:{},s=p(n,e=>{this.elementsWaiters=this.elementsWaiters.filter(t=>t.selector!==n),this.rootElement=e.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),t(e.insertAdjacentElement(o,this.domElement))});this.elementsWaiters.push(s)}).then(()=>this)}remove(){this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement);for(const t of this.elementsWaiters)[DATA.elementReferrer,"body"].includes(t.selector)&&t.clear();return this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):t()||this.init().then(({response:t})=>t?this.show():this),this}show(){return t()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(this.rootElement),this}hide(e=!0){return!t()&&this.hasBeenShown&&e&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),e&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(e){const n=t(),o=s(),i=this.trigger?.promises?.length,a=!this.recurrence||this.recurrence.isOver();if(!n&&!o||i||!a)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const r=n||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:r};return r?(await this.insert(),this.addCloseEvent(),n||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(r),c):c}onPageChange(t,e,n){const o=()=>this.init().then(({response:t})=>{t?this.show():this.hide(!1)});e||(this.hasBeenShown=!1,n&&this.domElement.remove(),this.trigger&&this.trigger.clear());const s={[x]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[C]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(t=>t.show()).catch(this.pageWatcher.watch):o()},[A]:()=>{this.hasBeenShown?this.pageWatcher.watch():o()}};"function"==typeof s[t]&&s[t]()}addCloseEvent(...e){const{closeButton:n,overlay:o,overlayClickable:s,layout:i,animationDuration:a=1e3}=DATA,r=[];if(void 0!==o&&!0!==o||!0!==s||"popin"!==i||r.push(`.${this.overlayClassName}`),void 0!==n&&n&&r.push(`.${this.closeButtonClassName}`),!r.length)return this;const c=this.domElement.querySelectorAll(r.join(", "));if(!c.length)return this;const l=["click",t=>{w(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*a)},{once:!0,capture:!0}];e.push(...c);for(const n of e)t()&&(n.dataset.abtastyActionnable="true"),n.removeEventListener(...l),n.addEventListener(...l);return this}getDom(){const{closeButton:t,layout:e,overlayClickable:n,overlay:o=!0}=DATA,s=document.createElement("div");return s.className=`${this.basicClassName} ${this.hideClassName}`,s.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(e)&&(s.role="dialog"),s.innerHTML=`\n\t\t\t${"popin"===e&&!0===o?`<div ${n?'aria-label="Close dialog"':""} class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${t?`<button class="${this.closeButtonClassName}" aria-label="Close dialog"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,s}loadFont(t,e){if(!t||"inherit"===t||!/otf|ttf/g.test(e))return;const n=document.createElement("style"),o=e.match(R)?e.match(R)[1]:"";n.innerHTML=`@font-face { font-family: '${t}_${o}'; src: url('${e}'); font-display: swap; }`;const s=this.rootElement?.head||document.head;s?.appendChild(n)}getStyleTag(e="",n=DATA){const{noStyles:o,layout:s}=n,{backgroundColor:i,isBackgroundImage:a,backgroundImage:r,backgroundSize:c,backgroundPosition:l,backgroundRepeat:d,borderColor:u,borderRadius:h,borderWidth:m,textColor:g,textAlign:b,fontName:p,fontStyle:y,fontSize:w,isTitle:v,titleTextAlign:f,titleTextColor:T,titleFontName:x,titleFontStyle:C,titleFontSize:A,overlay:S,overlayColor:E,dropShadow:k,dropShadowColor:L,dropShadowBlur:B,containerMargin:D,containerPadding:P,closeButton:I,closeButtonPosition:N,closeButtonSize:_,closeButtonBorderRadius:O,closeButtonBorderWidth:W,closeButtonBorderColor:V,closeButtonColor:M,closeButtonBackgroundColor:q,buttonsAlign:H,buttonsBorderWidth:j,buttonsBorderColor:F,buttonsBorderRadius:z,buttonsBackgroundColor:U,buttonsTextColor:K,buttonsFontName:G,buttonsFontStyle:J,buttonsFontSize:Y,secondLink:Q,secondLinkBorderWidth:X,secondLinkBorderColor:Z,secondLinkBorderRadius:tt,secondLinkBackgroundColor:et,secondLinkTextColor:nt,secondLinkFontName:ot,secondLinkFontStyle:st,secondLinkFontSize:it,animation:at,animationDuration:rt,animationBehaviour:ct,animationSlideDirection:lt}=o?{}:n,dt=document.createElement("style");t()&&dt.setAttribute("abtasty-script-added","true"),this.loadFont(p,y),this.loadFont(x,C),this.loadFont(G,J),this.loadFont(ot,st);const ut=`background: ${["string"==typeof i?i:"rgba(255, 255, 255, 1)",a&&"string"==typeof r&&r.length?`url(${r})`:"",a&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",a&&"string"==typeof c?`/ ${c}`:"/ auto",a&&d&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,ht="number"==typeof m&&m>0,mt=`border: ${[ht?`${m}px`:"unset",ht?"solid":"",ht&&"string"==typeof u&&u.length?u:""].join(" ").trim()};`,gt=void 0!==h?`border-radius: ${h}px;`:"",bt=void 0!==g?`color: ${g}; fill: ${g}; -webkit-text-fill-color: ${g};`:"",pt=void 0!==b?`text-align: ${b};`:"",yt=p&&"inherit"!==p?`font-family:${p}_${y.match(R)?y.match(R)[1]:""};`:y||"",wt=w?`font-size: ${w}px;`:"",vt=void 0!==k&&k?`box-shadow: 0 5px ${B}px 0 ${L};`:"",ft=D instanceof Array&&1===D.length&&D[0],Tt=ft?`margin: ${ft.top}px ${ft.right}px ${ft.bottom}px ${ft.left}px;`:"",xt=ft?`margin: calc(${ft.top}px * 0.5) calc(${ft.right}px * 0.5) calc(${ft.bottom}px * 0.5) calc(${ft.left}px * 0.5);`:"",$t=P instanceof Array&&1===P.length&&P[0],Ct=$t?`padding: ${$t.top}px ${$t.right}px ${$t.bottom}px ${$t.left}px;`:"",At=$t?`padding: calc(${$t.top}px * 0.5) calc(${$t.right}px * 0.5) calc(${$t.bottom}px * 0.5) calc(${$t.left}px * 0.5);`:"",St=void 0!==j&&j?`border-width: ${j}px; border-style: solid;`:"",Et=[F,j].every(t=>void 0!==t)&&j?`border-color: ${F};`:"",kt=void 0!==z?`border-radius: ${z}px;`:"",Lt=void 0!==U?`background-color: ${U};`:"",Bt=void 0!==K?`color: ${K}; fill: ${K}; -webkit-text-fill-color: ${K};`:"",Dt=G&&"inherit"!==G?`font-family:${G}_${J.match(R)?J.match(R)[1]:""};`:J||"",Pt=Y?`font-size: ${Y}px;`:"",It="number"==typeof X?`border-width: ${X}px; border-style: solid;`:"",Nt=[Z,X].every(t=>void 0!==t)&&X?`border-color: ${Z};`:"",Rt=void 0!==tt?`border-radius: ${tt}px;`:"",_t=void 0!==et?`background-color: ${et};`:"",Ot=void 0!==nt?`color: ${nt}; fill: ${nt}; -webkit-text-fill-color: ${nt};`:"",Wt=ot&&"inherit"!==ot?`font-family:${ot}_${st.match(R)?st.match(R)[1]:""};`:st||"",Vt=it?`font-size: ${it}px;`:"",Mt="popin"!==s||void 0!==S&&!0!==S?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==E?E:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),qt="number"==typeof _?_:16,Ht=qt/2,jt=o||void 0!==I&&I?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===N?`bottom: calc(100% + ${Ht}px)`:`top: ${Ht}px`)+";",`right: ${Ht}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof O?`border-radius: ${O}px;`:"","number"==typeof W&&W>0?`border: ${W}px solid ${void 0!==V?V:"rgba(57, 57, 57, 1)"};`:"","string"==typeof q?`background-color: ${q};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${qt}px;`,`height: ${qt}px;`,"string"==typeof M?`fill: ${M};`:"","}"].join(""):"",Ft=v&&"string"==typeof T?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${T}; fill: ${T}; -webkit-text-fill-color: ${T};`,void 0!==f?`text-align: ${f};`:"",x&&"inherit"!==x?`font-family:${x}_${C.match(R)?C.match(R)[1]:""};`:C||"",A?`font-size: ${A}px;`:"","}"].join(""):"";let zt="";if("string"==typeof at){const e=(rt/1e3).toFixed(2),n=["top","bottom"].includes(lt),o=Number(n),s=[(["top","left"].includes(lt)?"-":"")+"100vmax",this.translateValues?this.translateValues[o]:"0"];n&&s.reverse(),zt={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${e}s ${ct};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${e}s ${ct};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${e}s ${ct};`,"}"]}[t()&&!ABTASTY_S.WIDGETS.animationChanged?"none":at].join("")}const Ut=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===H?"top":"left"}: 8px;`,It,Nt,Rt,_t,Ot,Wt,Vt,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Ot,Wt,Vt,"}"];return dt.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,ut,gt,mt,bt,pt,vt,Tt,yt,wt,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,bt,pt,yt,wt,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ct,yt,wt,"}",`#${this.widgetContainerId} .${this.contentClassName} a {`,"text-decoration: underline;","}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a, `,`#${this.widgetContainerId} .${this.contentClassName} button {`,"text-decoration: none;","box-sizing: border-box;","display: inline-block;",St,Et,kt,Lt,Bt,Dt,Pt,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"]) * {`,Bt,Dt,Pt,"}",...Q?Ut:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,xt,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,At,"}","}",Mt,jt,Ft,zt,`${e}`].join(""),dt}}const W=["top: 0;","top: 50%;","bottom: 0;"],V=["left: 0;","left: 50%;","right: 0;"],M=t=>1===t?"-50%":0,q=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:t,y:e}]}=DATA,n=`translate(${M(e)}, ${M(t)});`;return`${W[t]}${V[e]}transform: ${n}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},H=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,j=()=>{if(H())return"width: auto; height: auto; min-width: fit-content;";const{popinPercentWidth:t,popinPixelsWidth:e,widthUnit:n,autoHeight:o,popinPercentHeight:s,popinPixelsHeight:i,heightUnit:a}=DATA;return`width: ${"px"===n?e:t}${n};height: ${o?"auto":`${"px"===a?i:s}${a}`};`};class F extends O{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(t=>M(t)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:t,zindexCustom:e,widthUnit:n}=DATA,o="string"!=typeof DATA.overlay&&DATA.overlay;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===t?e:t};`,"background: none;","pointer-events: "+(o?"all":"none"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",q(),j(),"pointer-events: all","}",`${H()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!H()&&["px","em"].includes(n)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}class z extends O{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:t,zindexCustom:e}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;",`z-index: ${"custom"===t?e:t};`,"background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class U extends O{constructor(t,e){super(t,e),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const K=/.+\/([^.]+)\.(otf|ttf)$/,G=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"popin";const{layout:n,inlineLayoutContent:o}=DATA,{image:s}=DATA;return t&&"https://widgets-images.abtasty.com/widgets-default-image.png"!==s?`<div class="countdown_${e}_img_container">\n\t\t\t\t<img src="${s}" class="abtasty-countdown-image ${"popin"===n||"free"===n&&!o?"abtasty-countdown-image-popin-layout":""}">\n\t\t\t</div>`:""},J=["day","hour","minute","second"],Y="line",Q=window.ABTASTY_S?.USER?.lang?ABTASTY_S.USER.lang.split("_")[0]:navigator.language.substring(0,2)||"en",X=["fr","en","de","es","ja"].indexOf(Q)>-1?Q:"en",Z=DATA.contentChosenLanguage,tt="default"===Z?X:Z,et=(t,e,n="long")=>{const o={style:"unit",unit:t,unitDisplay:n};return new Intl.NumberFormat(tt,o).format(e)};class nt{constructor(t){let{parentContainer:e}=t;this.parentContainer=e,this.testId=TEST_ID,this.container=this.createContainer(),this.digitElements={},this.textElements={},this.timerElements={},this.timeLoop=null,this.maxWidth=0,this.previewTime=172799,this.fonts=[]}remove(){const{animationDuration:t}=DATA;setTimeout(()=>this.parentContainer.remove(),1.05*t)}getCountdownClock(){return this.container.querySelector(".abtasty-countdown-clock")}onBlurOrMouseLeave(t){let{type:e}=t;const n=this.getCountdownClock();n&&(n.ariaLive="off");const o="mouseleave"===e?"mouseenter":"focus";this.container.addEventListener(o,this.onFocusOrMouseEnter.bind(this),{passive:!0,once:!0})}onFocusOrMouseEnter(t){let{type:e}=t;const n=this.getCountdownClock();n&&(n.ariaLive="polite");const o="mouseenter"===e?"mouseleave":"blur";this.container.addEventListener(o,this.onBlurOrMouseLeave.bind(this),{passive:!0,once:!0})}addAriaEvents(t){const e=["mouseenter","focus"];for(const n of e)t.addEventListener(n,this.onFocusOrMouseEnter.bind(this),{passive:!0,once:!0})}addCloseEvent(e){e&&e.addEventListener("click",e=>{w(e),t()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),this.remove()},{capture:!0,passive:!1})}addRedirectionEvent(e){!t()&&e&&e.addEventListener("click",()=>{const{autoHide:t,timeHide:e}=DATA;t&&setTimeout(()=>{this.parentContainer.hide(),this.remove()},1e3*e),this.parentContainer.recurrence.setValidationRecurrence()},{useCapture:!0,once:!0})}createContainer(){const{linkType:t,redirectionUrl:e,openInNewTab:n}=DATA,o=document.createElement(t&&t.includes("widget")?"a":"div");switch(o.classList.add("abtasty-countdown"),t){case"widget":o.href=e,o.target=n?"_blank":"_self",this.addRedirectionEvent(o);break;case"widgetClose":o.href="#",o.dataset.abtastyActionnable="true",this.addCloseEvent(o)}return this.addAriaEvents(o),o}insert(t,e){return t.insertAdjacentElement(e,this.container),this}setText(t){const{layoutType:e,displayElapsedElements:n,layout:o,endSettings:s}=DATA,i={day:DATA.customDaysLabel,hour:DATA.customHoursLabel,minute:DATA.customMinutesLabel,second:DATA.customSecondsLabel},a=DATA.timeUnitLengthFormat;for(const o of J){const s=this.timerElements[o],r=String(t[o]).padStart(2,"0"),c=et(o,r,a).match(/([\d,.]+)\s*(.+)/),l=c?c[1]:r;let d=c?c[2]:o;if(DATA.customTexts&&o in i&&(d=i[o]),n||(s.dataset.timeEnd=0===t[o]?"true":"false"),"textDigits"===e)s.textContent=`${l} ${d}`;else{const t=this.digitElements[o],e=this.textElements[o];t.textContent=l,e.textContent=d,this.maxWidth<t.offsetWidth&&(this.maxWidth=t.offsetWidth,t.style.minWidth=`${this.maxWidth}px`),t.style.minWidth=`${this.maxWidth}px`}}[null,"",s].includes(this.parentContainer.domElement.ariaLabel)&&["popin","bannerTop","bannerBottom"].includes(o)&&(this.parentContainer.domElement.ariaLabel=[...this.parentContainer.domElement.querySelectorAll(".abtasty-countdown-clock, .abtasty-countdown-top-message")].map(t=>t.textContent.replace(/\s+/g," "),"").join("").trim())}onTimeEnd(){const{endSettings:t,layout:e}=DATA;clearInterval(this.timeLoop);const n=this.getCountdownClock();if(n&&(n.ariaLive="off"),"hideWidget"===t)return this.parentContainer.hide(),void(this.parentContainer.domElement.style.display="none");const o=this.container.querySelectorAll(".abtasty-countdown-elm-time");for(const t of o)t.removeAttribute("data-time-end");["popin","bannerTop","bannerBottom"].includes(e)&&(this.parentContainer.domElement.ariaLabel=DATA.endMessage);const s={endText:!0,endCountdown:["showText","showTextAndButton"].includes(t),endButton:["hideCountdownAndShowTextAndButton","showTextAndButton"].includes(t)},i=[`abtasty-countdown-${t}`,"abtasty-countdown-finish"];for(const t of Object.keys(s)){const e=s[t]?"show":"hide";i.push(`abtasty-countdown-${t}-${e}`)}this.container.classList.add(...i)}setCountdown(){const e=new Date;let n=function(e,n){switch(e.type){case"global":return e.timestamp-n.getTime();case"local":if(t())return e.previewTimestamp-n.getTime();const{year:o,month:s,day:i,hour:a,minute:r}=e.timecomponents;return new Date(o,s-1,i,a,r).getTime()-n.getTime();default:return 0}}(DATA.dateTime,e)/1e3;if(top.ABTastyEditor&&("ifEnded"===DATA.previewBlock&&(n=-1),this.previewTime-=1),n<=0)return this.setText({day:0,hour:0,minute:0,second:0}),void this.onTimeEnd();const o=Math.floor(n/86400);n-=86400*o;const s=Math.floor(n/3600);n-=3600*s;const i=Math.floor(n/60);n-=60*i;const a=Math.floor(n);this.setText({day:o,hour:s,minute:i,second:a})}setButton(){var t=this;const e=function(e,n,o,s){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const a=document.createElement("a");return a.ariaLabel=e,i&&(a.className="second_link"),a.innerHTML=`<span>${e}</span>`,a.href="button"===n?o:"#","button"===n?(a.target=s?"_blank":"_self",t.addRedirectionEvent(a)):(a.dataset.abtastyActionnable="true",t.addCloseEvent(a)),a},{linkType:n,buttonText:o,redirectionUrl:s,openInNewTab:i,secondLink:a,secondLinkText:r,secondLinkType:c,secondLinkURL:l,secondLinkOpenInNewTab:d,endBtnTargetBlank:u,endBtnLabel:h,endBtnLink:m}=DATA,g=this.container.querySelector(".abtasty-countdown-bottom-button"),b=[];if(n&&n.includes("button")){const t=e(o,n,s,i);if(b.push(t),a){const t=e(r,c,l,d,a);b.push(t)}}for(const t of b)g.appendChild(t);const p=this.container.querySelector(".abtasty-countdown-finish-button"),y=document.createElement("a");y.href=m,y.target=u?"_blank":"_self",y.innerHTML=h,y.ariaLabel=h,p.appendChild(y)}setContent(){const t=this.container.querySelector(".abtasty-countdown-finish-text"),e=document.createElement("div");if(e.innerHTML=DATA.endMessage,t.appendChild(e),"textDigits"===DATA.layoutType)return;const n=this.container.querySelector(".abtasty-countdown-top-message"),o=document.createElement("p");o.innerHTML=DATA.message,n.appendChild(o)}init(){const{layout:t,inlineLayoutContent:e,hideResponsiveImage:n,hideResponsiveText:o}=DATA;try{const s=["free","popin"].includes(t);(e=>{if(this.container.classList.add(`abtasty-countdown-layout-${e}`),s||(n&&this.container.classList.add("abtasty-countdown-hide-responsive-image"),o&&this.container.classList.add("abtasty-countdown-hide-responsive-text")),e===Y){s&&(this.parentContainer.domElement.querySelector(`.${this.parentContainer.contentClassName}`).classList.add(`abtasty-countdown-content-${t}-inline`),this.container.classList.add(`abtasty-countdown-layout-${t}-inline`));const e=this.parentContainer.domElement.querySelectorAll(`.${this.parentContainer.closeButtonClassName}`);for(const t of e)t.classList.add("abtasty-countdown-close-inline")}})(s&&!e?"free":Y),this.container.innerHTML=(()=>{const{layout:t,inlineLayoutContent:e,imagePosition:n,layoutType:o}=DATA,s="popin"===t||"free"===t&&!e,i=`\n ${G(s&&!("popin"===t&&e),"popin")}\n <div class="abtasty-countdown-layout-${t} abtasty-countdown-mini">\n ${G(!s&&"before"===n,"banner")}\n <div class="abtasty-countdown-top-message">\n ${DATA.messageMinimalistMode.split(/!countdown!/gm).map(t=>`<p>${t.trim()}</p>`).join('\n <span class="abtasty-countdown-days abtasty-countdown-elm-time"></span>\n <span class="abtasty-countdown-hours abtasty-countdown-elm-time"></span>\n <span class="abtasty-countdown-minutes abtasty-countdown-elm-time"></span>\n <span class="abtasty-countdown-seconds abtasty-countdown-elm-time"></span>\n').replace("<p></p>","")}\n </div>\n ${G(!s&&"after"===n,"banner")}\n <div class="abtasty-countdown-finish-text"></div>\n <div class="abtasty-countdown-finish-button"></div>\n <div class="abtasty-countdown-bottom-button buttons_container"></div>\n </div>\n `,a=`\n ${G(s&&!("popin"===t&&e),"popin")}\n <div class="abtasty-countdown-layout-${t} abtasty-countdown-standard">\n ${G(!s&&"before"===n,"banner")}\n <div class="abtasty-countdown-clock" role="timer" aria-live="off">\n <div class="abtasty-countdown-days abtasty-countdown-elm-time">\n <div class="abtasty-countdown-days__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-days__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-hours abtasty-countdown-elm-time">\n <div class="abtasty-countdown-hours__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-hours__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-minutes abtasty-countdown-elm-time">\n <div class="abtasty-countdown-minutes__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-minutes__text abtasty-countdown-elm-text"></div>\n </div>\n <div class="abtasty-countdown-seconds abtasty-countdown-elm-time">\n <div class="abtasty-countdown-seconds__digit abtasty-countdown-elm-number"></div>\n <div class="abtasty-countdown-seconds__text abtasty-countdown-elm-text"></div>\n </div>\n </div>\n ${G(!s&&"after"===n,"banner")}\n <div class="abtasty-countdown-top-message"></div>\n <div class="abtasty-countdown-finish-text"></div>\n <div class="abtasty-countdown-finish-button"></div>\n <div class="abtasty-countdown-bottom-button buttons_container"></div>\n </div>\n `;return"textDigits"===o?i:a})(),this.container.insertAdjacentElement("afterbegin",(t=>{const e=document.createElement("style");return e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t)),e})(`@media (min-width:741px){.abtasty-countdown-layout-line .abtasty-countdown-elm-time{margin:0}}@media (max-width:740px){.abtasty-countdown-layout-line>div:not(.abtasty-countdown-layout-popin){-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.abtasty-countdown-layout-line div.abtasty-countdown-finish-text,.abtasty-countdown-layout-line div.abtasty-countdown-top-message{margin-bottom:20px}.abtasty-countdown-layout-line div.abtasty-countdown-bottom-button a{margin-left:0}}@media (max-width:579px){.ab_widget_container_countdown_content{max-width:100%;width:100vw}.abtasty-countdown-layout-free,.abtasty-countdown-layout-popin{-webkit-box-orient:vertical!important;-webkit-box-direction:normal!important;-ms-flex-direction:column!important;flex-direction:column!important;margin:10px 0!important}.abtasty-countdown-hide-responsive-image .countdown_banner_img_container,.abtasty-countdown-hide-responsive-text .abtasty-countdown-top-message{display:none}}.abtasty-countdown,.abtasty-countdown>div{display:inline-block;text-align:center}.abtasty-countdown>div{margin:10px;overflow:auto;white-space:normal;width:100%}.abtasty-countdown .countdown_popin_img_container{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:center;max-width:100%}.abtasty-countdown .countdown_popin_img_container:empty{display:none}.abtasty-countdown .abtasty-countdown-finish-text,.abtasty-countdown .abtasty-countdown-top-message{margin-bottom:15px}.abtasty-countdown .abtasty-countdown-elm-time{display:inline-block;margin:6px 6px 15px;padding:6px}.abtasty-countdown .abtasty-countdown-elm-number,.abtasty-countdown .abtasty-countdown-elm-text{font-stretch:normal;font-style:normal;font-weight:700;letter-spacing:normal;line-height:normal;text-align:center}.abtasty-countdown .abtasty-countdown-bottom-button a,.abtasty-countdown .abtasty-countdown-finish-button a{cursor:pointer;display:block;display:inline-block;padding:6px 10px;text-align:center;text-decoration:none}.abtasty-countdown-layout-line>div{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:stretch;-ms-flex-pack:stretch;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:stretch}.abtasty-countdown-layout-line>div>div{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}.abtasty-countdown-layout-free{display:block;text-align:center}.abtasty-countdown-layout-line>div{margin:0}.abtasty-countdown-layout-line .abtasty-countdown-finish-text,.abtasty-countdown-layout-line .abtasty-countdown-top-message{-webkit-box-sizing:border-box;box-sizing:border-box;margin-bottom:0;padding:0 5px 0 15px}.abtasty-countdown-layout-line .abtasty-countdown-top-message p{margin-bottom:0}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button a{margin-left:30px}.abtasty-countdown-layout-line{-webkit-box-sizing:border-box;box-sizing:border-box}.abtasty-countdown-layout-line .abtasty-countdown-bottom-button,.abtasty-countdown-layout-line .abtasty-countdown-clock,.abtasty-countdown-layout-line .abtasty-countdown-finish-button{-ms-flex-negative:0;flex-shrink:0}.abtasty-countdown-finish-button,.abtasty-countdown-finish-text{display:none}.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-show.abtasty-countdown-clock,.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:block}.abtasty-countdown-layout-line.abtasty-countdown-endButton-show .abtasty-countdown-finish-button,.abtasty-countdown-layout-line.abtasty-countdown-endCountdown-show .abtasty-countdown-clock,.abtasty-countdown-layout-line.abtasty-countdown-endText-show .abtasty-countdown-finish-text{display:table-cell}.abtasty-countdown-endButton-hide .abtasty-countdown-finish-button,.abtasty-countdown-endCountdown-hide .abtasty-countdown-clock,.abtasty-countdown-endText-hide .abtasty-countdown-finish-text,.abtasty-countdown-finish .abtasty-countdown-bottom-button,.abtasty-countdown-finish .abtasty-countdown-top-message{display:none!important}.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-text,.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-text{width:55%!important}.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-button,.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-button{width:45%!important}.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-text,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-text{width:30%!important}.abtasty-countdown-showText .abtasty-countdown-layout-bannerBottom .abtasty-countdown-clock,.abtasty-countdown-showText .abtasty-countdown-layout-bannerTop .abtasty-countdown-clock,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-clock,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-button,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-clock,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-button{width:35%!important}.abtasty-countdown-showText .abtasty-countdown-layout-bannerBottom .abtasty-countdown-finish-text,.abtasty-countdown-showText .abtasty-countdown-layout-bannerTop .abtasty-countdown-finish-text{width:65%}.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerBottom,.abtasty-countdown-hideCountdownAndShowTextAndButton .abtasty-countdown-layout-bannerTop,.abtasty-countdown-showText .abtasty-countdown-layout-bannerBottom,.abtasty-countdown-showText .abtasty-countdown-layout-bannerTop,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerBottom,.abtasty-countdown-showTextAndButton .abtasty-countdown-layout-bannerTop{width:100%}.abtasty-countdown-standard .abtasty-countdown-clock>.abtasty-countdown-elm-time[data-time-end=true]+.abtasty-countdown-elm-time[data-time-end=true],.abtasty-countdown-standard .abtasty-countdown-clock>.abtasty-countdown-elm-time[data-time-end=true]:first-child{display:none}.abtasty-countdown-content-popin-inline,.abtasty-countdown-content-popin-inline .abtasty-countdown-layout-popin{max-width:inherit;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content}.abtasty-countdown-content-free-inline{max-width:100%}.abtasty-countdown-image-popin-layout{margin-bottom:20px}.abtasty-countdown-layout-popin{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.countdown_banner_img_container{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;justify-content:center;padding:0 15px}.countdown_banner_img_container img{max-height:67px;max-width:200px}.abtasty-countdown .abtasty-countdown-mini .abtasty-countdown-elm-time{border:none;margin:0;padding:0}.abtasty-countdown .abtasty-countdown-mini .abtasty-countdown-top-message{display:inline-block;white-space:unset;width:100%}.abtasty-countdown .abtasty-countdown-mini .abtasty-countdown-top-message>*{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex}.abtasty-countdown-mini .abtasty-countdown-top-message>.abtasty-countdown-elm-time[data-time-end=true]+.abtasty-countdown-elm-time[data-time-end=true],:not(.abtasty-countdown-showTextAndButton) :not(.abtasty-countdown-showText) .abtasty-countdown-mini .abtasty-countdown-top-message>.abtasty-countdown-elm-time[data-time-end=true]:first-child{display:none} ${(t=>{const e=[{fontName:DATA.messageFontName,fontStyle:DATA.messageFontStyle},{fontName:DATA.numbersfontName,fontStyle:DATA.numbersfontStyle},{fontName:DATA.legendfontName,fontStyle:DATA.legendfontStyle}];for(const{fontName:n,fontStyle:o}of e)t(n,o);const{buttonsAlign:n,messageAlign:o,textColor:s,messageFontSize:i,messageFontName:a,messageFontStyle:r,numbersfontSize:c,numberstextColor:l,numbersfontName:d,numbersfontStyle:u,legendfontName:h,legendfontStyle:m,legendfontSize:g,legendtextColor:b,countdownBorderRadius:p,countdownBorderWidth:y,countdownBorderColor:w,numbersBackgroundColor:v}=DATA,f=void 0!==n&&"fill"!==n?`text-align: ${n};`:"",T=(t,e)=>t&&"inherit"!==t?`font-family:${t}_${e.match(K)?e.match(K)[1]:""};`:e||"",x=T(a,r),C=T(d,u);return`\n .abtasty-countdown-bottom-button,\n .abtasty-countdown-finish-button {\n ${f};\n }\n .abtasty-countdown-bottom-button a,\n .abtasty-countdown-finish-button a {\n width: ${"fill"===n?"100%":"auto"};\n }\n\n .abtasty-countdown .abtasty-countdown-finish-text,\n .abtasty-countdown .abtasty-countdown-top-message,\n .abtasty-countdown .abtasty-countdown-finish-text *,\n .abtasty-countdown .abtasty-countdown-top-message * {\n white-space: pre-line;\n text-align: ${o} !important;\n color: ${s};\n font-size: ${i}px;\n ${x};\n }\n\n .abtasty-countdown .abtasty-countdown-elm-number,\n .abtasty-countdown .abtasty-countdown-elm-number * {\n font-size: ${c}px;\n color: ${l};\n fill: ${l};\n -webkit-text-fill-color: ${l};\n font-weight: initial;\n ${C};\n }\n\n .abtasty-countdown .abtasty-countdown-elm-text,\n .abtasty-countdown .abtasty-countdown-elm-text * {\n ${T(h,m)};\n font-size: ${g}px;\n color: ${b};\n -webkit-text-fill-color: ${b};\n }\n\n .abtasty-countdown > div:not(.abtasty-countdown-mini) .abtasty-countdown-elm-time {\n border-radius: ${p}px;\n border: ${y}px solid ${w};\n background-color: ${v};\n }\n\n .abtasty-countdown > .abtasty-countdown-mini .abtasty-countdown-elm-time {\n font-size: ${c}px;\n color: ${l};\n fill: ${l};\n -webkit-text-fill-color: ${l};\n font-weight: initial;\n ${C};\n }`})(this.parentContainer.loadFont.bind(this.parentContainer))}`));for(const t of J){const e=this.container.querySelector(`.abtasty-countdown-${t}s`);this.timerElements[t]=e,this.digitElements[t]=e.querySelector(".abtasty-countdown-elm-number"),this.textElements[t]=e.querySelector(".abtasty-countdown-elm-text")}this.setContent(),this.setButton(),this.timeLoop=setInterval(this.setCountdown.bind(this),1e3),this.setCountdown()}catch(t){console.warn("Countdown error occurred during widget rendering:",t)}}}!async function(){l("Widget launch");const t=(()=>{const{layout:t}=DATA;let e;switch(t){case"popin":e=new F;break;case"bannerTop":case"bannerBottom":e=new z;break;case"free":e=new U;break;default:e=new O}return e})(),{response:e}=await t.init(!0),n=t.domElement.querySelector(`.${t.contentClassName}`),o=new nt({parentContainer:t});o.init(),o.insert(n,"beforeend"),e&&t.show()}()}();
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@abtasty/countdown",
|
3
3
|
"description": "Widget for AB Tasty",
|
4
|
-
"version": "3.
|
4
|
+
"version": "3.12.0",
|
5
5
|
"form": "dist/form.js",
|
6
6
|
"main": "dist/main.js",
|
7
7
|
"type": "module",
|
@@ -43,6 +43,5 @@
|
|
43
43
|
"postcss-cssnext": "^3.1.1",
|
44
44
|
"rollup": "^4.12.0",
|
45
45
|
"rollup-plugin-postcss": "^4.0.2"
|
46
|
-
}
|
47
|
-
"stableVersion": "3.11.1-0"
|
46
|
+
}
|
48
47
|
}
|