@abtasty/spotlight 1.1.15-1 → 1.1.16
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.js +1 -1
- package/package.json +2 -3
package/dist/main.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(top,"ABTastyEditor"),t=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},n=e=>new Function(`try {\n\t\t${e}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),s=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),i=()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:i,customJSProductKey:r,productSKU:o}=DATA,{pathToProductKey:a,customJSProductKey:c}="DATA_JS"in arguments?DATA_JS:{};if(2===e)return{productKey:s(),keyType:"url"};{let l=null,h="sku";switch(t){case"ABTastyProductKey":l=window.ABTastyProductKey;break;case"pathToProductKey":l="function"==typeof a?a():n(`return ${i};`);break;case"customJSProductKey":l="function"==typeof c?c():n(r);break;case"productSKU":l=o}return l||3!==e||(l=s(),h="url"),{productKey:l,keyType:h}}},r=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),o=()=>window.ABTasty&&!0===window.ABTasty.consentReady,a=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},c=()=>{const e=a();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},l=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,h=n=>{const s=(()=>{if(e()||t())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),i=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(s||i){const e=c();window.console.log(`%c${e} - ${s?"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=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t},u=(e,t)=>{const n=t?[]:null;if("string"!=typeof e||!e.trim().length)return n;const[s,i,r]=e.split("[]").map(e=>e.trim()),o=Boolean(r)?r:e,a=i?document.querySelector(s)?.[i]:document;return a?t?[...a.querySelectorAll(o)]:a.querySelector(o):n},g=e=>u(e,!1),m=e=>u(e,!0),p=(e,t)=>{const n=document.querySelector("body")||document.documentElement,s={childList:!0,subtree:!0,attributes:!0},i=()=>r.disconnect(),r=new MutationObserver(()=>{const n=g(t);return n&&!i()&&e(n)});return{clear:i,observe:(e=n)=>r.observe(e,s)}},v=()=>{},f=(t,n)=>{const s=g(t),i={selector:t,clear:v,observe:v};if(s)return setTimeout(()=>n(s),0),i;if(e())return setTimeout(()=>f(t,n),1e3),i;if(t.includes("[]"))return((e,t)=>{const[n,s]=t.split("[]").map(e=>e.trim()),i=g(n),r=i?.[s],{clear:o,observe:a}=p(e,t),c=()=>{const n=g(t);return n&&!l()&&e(n)},l=()=>{o(),i?.removeEventListener("load",c)},h=()=>{a(r),"iframe"===i?.localName&&i.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(n,t);const{clear:r,observe:o}=p(n,t);return o(),{selector:t,clear:r,observe:o}};function b(e,t){const n=e.parentElement||e.getRootNode().host;return t(e)||!n?e:b(n,t)}const y=(e,t)=>[...m(t)].some(n=>{const[s,,i]=t.split("[]"),r=i??s;return n===e||!!e.closest(r)});let w=!1;class ${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(e){const t=[e,"transitionend",this.checkElements.bind(this),!0];return this.getEvents(...t)}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start(),this.scrollEvent.start(),this.onTransitionEnd.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear(),!1))})}startVisibilityObserver(e){const t={root:e,rootMargin:"0px",threshold:0};return this.visibilityObserver??=new IntersectionObserver(this.intersectionHandler.bind(this),t),this.visibilityObserver}startMutationObserver(e){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}),this.mutationObserver}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find(({element:n,selector:s})=>{if(n.isSameNode(e))return!0;const[i,,r]=s.split("[]"),o=r??i,a=[...e.querySelectorAll(o)];if(a.length&&a.includes(n))return!0;if(t.includes(n))return!0;if(!e.parentElement?.children?.length)return;const c=[...e.parentElement.children],l=c.findIndex(t=>t.isSameNode(e)),h=c.filter((e,t)=>t>l);if(h.length){if(h.includes(n))return!0;if(h.some(e=>[...e.querySelectorAll(o)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:s}=n,i=this.targets.find(t=>t.selector===e&&t.uniqueId===s);i&&i.resolve(t),this.clear(e,s)}}getEvents(e,...t){return{start:()=>e?.addEventListener(...t),clear:()=>e?.removeEventListener(...t)}}mouseOverHandler(e){const t=[e,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?"touchmove":"mouseover",e=>{const t=e.composedPath(),{target:n}=e;setTimeout(()=>this.onMouseOver({target:n,path:t}),50)},!0];return this.getEvents(...t)}scrollEventHandler(e){const t=[e,"scroll",(n=this.checkElements.bind(this),()=>{w||(w=!0,setTimeout(()=>{n(),w=!1},100))}),{passive:!0}];var n;return this.getEvents(...t)}isElementVisible(e){return this.isElementOpaque(e)&&this.isElementTopmost(e)}isElementOpaque(e){return"HTML"===b(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),n=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let s=!1,i=0;for(;!s&&i<n.length;){const t=e.getRootNode()?.elementFromPoint(...n[i]);s=e===t||t?.contains(e)||e.contains(t),i+=1}return s}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=g(e),[s,,i]=e.split("[]"),r=i??s;n&&!this.existingTargets.find(e=>e.element.matches(r)&&e.uniqueId===t)&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!g(e)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:n})=>{const[s,,i]=e.split("[]"),r=i??s;if(t.matches(r)&&this.isElementVisible(t)){const s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);return s&&s.resolve(t),this.clear(e,n),!1}return!0})}onLoadIframe(e){const t=[e.defaultView.frameElement,"load",()=>this.watch(selector,resolve,uniqueId).bind(this),{passive:!0}];return this.getEvents(...t)}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const{clear:s}=f(e,e=>{s();const t=e.getRootNode(),n="body"in t?t.body:document;this.mouseOverEvent=this.mouseOverHandler(t),this.scrollEvent=this.scrollEventHandler(t),this.onTransitionEnd=this.transitionOverHandler(t),t.defaultView?.frameElement&&(this.onIframeLoad=this.onLoadIframe(t),this.onIframeLoad.start()),this.startVisibilityObserver(n),this.startMutationObserver(n),this.checkElements()})}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:s})=>n!==e&&s!==t));const n=g(e);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 E="remove",S="rebuild",T="update",C="ABTastyData";class A{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n,triggerTarget:s}){this.event=e,this.selector=Boolean(t)?t:"body",this.target="string"==typeof s?g(t):s,this.delay=1e3*n,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=d(`${this.event}DomReady`);this.promises.push(n);const{clear:s}=f(this.selector,()=>{const e=new $;this.visibilityObservers.push(e),e.watch(this.selector,t,l())});return this.elementWaiters.push(s),e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const s=["readystatechange",()=>n()&&t(!0),{passive:!0}];return this.eventsListeners.push([document,...s]),document.addEventListener(...s),e}return t(!0),e}onClick({promise:e,resolve:t}){const n=({isTrusted:e,target:n})=>{if(e)return(n.isEqualNode(this.target)||y(n,this.selector))&&t(!0)},{clear:s}=f(this.selector,e=>{s();const t=document.createElement("style");t.id=`Click_${l()}`;const[i,,r]=this.selector.split("[]"),o=r??i;t.innerHTML=`${o} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const a=e.getRootNode();("head"in a?a.head:a).appendChild(t),this.triggerElements.push(t);const c=["click",n,{passive:!0,capture:!0}];this.eventsListeners.push([a,...c]),a.addEventListener(...c)});return this.elementWaiters.push(s),e}onHover({promise:e,resolve:t}){const n=({isTrusted:e,target:n})=>{if(e)return(this.target?n.isEqualNode(this.target):y(n,this.selector))&&t(!0)},{clear:s}=f(this.selector,e=>{const t=e.getRootNode(),s="body"in t?t.body:[...t.childNodes].find(t=>t.contains(e)),i=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([s,...i]),s.addEventListener(...i)});return this.elementWaiters.push(s),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",({isTrusted:e,clientY:n})=>{e&&n<=0&&t(!0)},{passive:!0}],{clear:s}=f("html",e=>{s(),this.eventsListeners.push([e,...n]),e.addEventListener(...n)});return e}onReengage({promise:e,resolve:t}){const n=this.delay;let s=n;const i=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),r=[({isTrusted:e})=>{e&&(s=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...i].forEach(t=>{this.eventsListeners.push([t,e,...r]),t.addEventListener(e,...r)})});const o=setInterval(()=>{s<=0?t(!0):s-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n}=DATA,s="DATA_JS"in arguments&&DATA_JS?.triggerEventCustomScript,i="function"==typeof s?new Promise(async e=>s(e)):new Function(`return new Promise(async resolve => {${n}})`);return i().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let n=0;const s=["scroll",({isTrusted:e})=>{e&&(window.scrollY<n?t(!0):n=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...s]),document.addEventListener(...s),e}onScrollPercentReached({promise:e,resolve:t}){const{triggerEventScrollPercent:n}=DATA,s=["scroll",({isTrusted:e})=>{if(!e)return;const s=(()=>{const{documentElement:e,body:t}=document,n=e.scrollTop||t.scrollTop,s=e.scrollHeight||t.scrollHeight;return Math.trunc(n/(s-e.clientHeight)*100,10)})();n<s&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...s]),document.addEventListener(...s),e}checkSocialProofConditions(e,t,n,s){const i=(()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?e=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:r,spNoTrim:o}=DATA;if(this.socialProofStore.hasOwnProperty(e))n(this.socialProofStore[e])?s(`${this.socialProofStore[e][r]}`):s(!1);else if(e&&i){const a=t=>(this.socialProofStore[e]=t,s(!!n(t)&&`${t[r]}`));fetch(`https://api-social-proof.abtasty.com/clients/${i}/metrics/${t}?key=${e}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>h("Failed to fetch datas from server."))}else s(!1)}getSocialProofDatas({promise:e,resolve:t},n,s=!1){const{productKey:r,keyType:o}=i(),{viewInterval:a,triggerSocialProofMinVisitors:c,triggerSocialProofMinPurchases:l,triggerSocialProofMinPageViews:d}=DATA,u={pv:d,i:l,"v-pv":c}[n];return[typeof a,typeof u].includes("undefined")&&t(!1),s&&!r&&(h("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"),t(!1)),this.checkSocialProofConditions(r,"v-pv"===n&&"sku"===o?"v-i":n,e=>{const t=void 0!==e[a]&&e[a]>=u;return t||h(`Widget will not be shown, Social Proof API returned ${e[a]} while ${u} are required`),t},t),e}onConsent({promise:e,resolve:t}){if(!o()){const n=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(n),window.addEventListener(...n),e}return t(!0),e}onTrackingSent({promise:e,resolve:t}){const{triggerEventTrackingSent:n}=DATA;let s=localStorage.getItem(C);const i=()=>JSON.parse(s)?.ActionTracking?.some(({name:e})=>e===n),r=["storage",({key:e,newValue:n})=>{e===C&&(s=n,i()&&t(!0))},{passive:!0,capture:!0}];return s&&i()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:n}=DATA;let s=localStorage.getItem(C);const i=()=>n<=(s?JSON.parse(s)?.VisitedPages?.length:0),r=["storage",({key:e,newValue:n})=>{e===C&&(s=n,i()&&t(!0))},{passive:!0,capture:!0}];return s&&i()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:s}=DATA;let i=0,r=!1;const o=["click",({isTrusted:e})=>{if(e&&(i+=1,i>=n&&t(!0),!r)){r=!0;const e=setTimeout(()=>{i=0,r=!1},s);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...o]),e.addEventListener(...o)},{clear:c}=f("iframe []contentDocument[] body > *",()=>{const e=document.getElementsByTagName("iframe");for(const t of e){"contentDocument"in t&&"body"in t.contentDocument&&a(t.contentDocument);const e=()=>a(t.contentDocument);t.addEventListener("load",e),this.eventsListeners.push([t,"onIframeLoad",e])}});return this.elementWaiters.push(c),a(document),e}clear(){this.triggerElements=this.triggerElements.filter(e=>(e.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(e=>{const[t,...n]=e;return t&&n.length>1&&t.removeEventListener(...n),!1}),this.timeouts=this.timeouts.filter(e=>(clearTimeout(e),!1)),this.intervals=this.intervals.filter(e=>(clearInterval(e),!1));const e=l();return this.visibilityObservers=this.visibilityObservers.filter(t=>(t.clear(this.selector,e),!1)),this.promises=this.promises.filter(e=>(e.resolve(!1),!1)),this.elementWaiters=this.elementWaiters.filter(e=>(e(),!1)),this}async isTriggered(){this.clear();const e=d(this.event);this.promises.push(e);const t={consent:()=>this.onConsent(e),direct:()=>!0,pageLoad:()=>this.onPageLoad(e),click:()=>this.onClick(e),exitIntent:()=>this.onExitIntent(e),reengage:()=>this.onReengage(e),elementVisible:()=>this.onElementVisible(e),script:()=>this.onCustomTrigger(e),hover:()=>this.onHover(e),scrollUp:()=>this.onScrollUp(e),scrollPercent:()=>this.onScrollPercentReached(e),rageClick:()=>this.onRageClick(e),minPagesViewed:()=>this.onMinPagesViewed(e),trackingSent:()=>this.onTrackingSent(e),socialProofPurchases:()=>this.getSocialProofDatas(e,"i",!0),socialProofPageViews:()=>this.getSocialProofDatas(e,"pv"),socialProofVisitors:()=>this.getSocialProofDatas(e,"v-pv")},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return n&&this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=d(`${this.event}Delay`);this.promises.push(e);const t=setTimeout(()=>{e.resolve(!0),this.clear()},this.delay);return this.timeouts.push(t),e.promise})():n}}const P="display",x="closing",k="validation",N="ABTastyWidgets",L=`${N}Temporary`;class I{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:n},s){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(n),this.onSetCallback=s,this.widgetName=a(),this.uniqueId=l(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(L),n=sessionStorage.getItem(N);"ABTastyData"===e&&!t&&n&&localStorage.setItem(L,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(N);return JSON.parse(t)}catch(t){return e.removeItem(N),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:n,...s}=t;return Object.entries(s).length?(e.setItem(N,JSON.stringify(s)),s):(e.removeItem(N),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=localStorage.getItem(L),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(N,e),localStorage.removeItem(L));const n=this.getLocalRecurrence(),s=(n?parseFloat(n.stamp):0)<(new Date).getTime();return s&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&s&&!this.getLocalRecurrence()&&!t}setRecurrence(e,n){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const s=this.getTypeOfStorage(e);if(t()||!s&&"object"!=typeof s)return!1;const{storageString:i,storageMethod:r}=s,a=this.getStamp(e),c={type:n,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!o()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new A({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===i?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const s=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};r.setItem(N,JSON.stringify(s)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(l&&n!==k)if(n===x&&l!==k)h();else{if(n!==P||l===k||l===x)return!1;h()}else h();return a}setDisplayRecurrence(){const e=P;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=x;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=k;this.setRecurrence(this.validationRecurrence,e)}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class R{constructor(e,t,n){this.isWidgetApplied=e,this.callback=t,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(e){const t=!e&&this.isWidgetApplied(),n=t?this.shouldUpdate&&T:S;return n?(this.clearWatcher(),this.callback(n,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(S,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback(E,!1),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return r()?e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler():this:this.callback(E,!1)}watch(t,n){if(e())return this;if(this.clearWatcher(t),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),n?.includes("[]contentDocument[]")){const e=n.split("[]")[0].trim(),{clear:t}=f(e,e=>{t(),this.triggerIframeTarget=e,e.addEventListener("load",this.decisionHandler.bind(this))})}const s=t?.defaultView?.frameElement;s&&this.triggerIframeTarget!==s&&s.addEventListener("load",this.decisionHandler.bind(this));const{clear:i}=f("body",e=>{i();const n=t?.body||t||e;this.observer.observe(n,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(e){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),e?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const D=/.+\/([^.]+)\.(otf|ttf)$/,B=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class O{constructor(t,n){this.children=void 0,this.uniqueId=`${l()}${n?`_${n}`:""}`,this.widgetName=a(),this.prettyName=c(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:n,validationRecurrence:s}=DATA,i=!t&&!n&&!s;if(e()||i)return!1;const r={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},o={};return t&&(o.displayRecurrence=r[t]("displayRecurrence")),n&&(o.closingRecurrence=r[n]("closingRecurrence")),s&&(o.validationRecurrence=r[s]("validationRecurrence")),o})(),this.triggerParams=(t=>{let{triggerEvent:n}=DATA;const{triggerEventClick:s,triggerEventHover:i,triggerEventReengageDelay:r,socialProofContentType:o,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!n&&!o)return!1;const l={click:()=>s,hover:()=>i,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",d="reengage"===n?r:c;return o&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][o]),{triggerEvent:n,triggerSelector:h,triggerDelay:d,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new I(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new A(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&B.includes(this.triggerParams.triggerEvent),this.pageWatcher=new R(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!["click","hover","scrollUp","script"].includes(t)||e})(),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(){this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]}isWidgetApplied(){return this.domElement?.isConnected&&this.domElement.ownerDocument?.defaultView}removeOldDomElement(){const e=this.rootElement?.getElementById(this.widgetContainerId);return e?.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=["free"];"drawer"===DATA.layout&&DATA.customTarget&&e.push("drawer");const t=e.includes(DATA.layout);return new Promise(e=>{const{elementReferrer:n="body",referrerInsertType:s="beforeend"}=t?DATA:{},i=f(n,t=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==n),this.rootElement=t.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),e(t.insertAdjacentElement(s,this.domElement))});this.elementsWaiters.push(i)}).then(()=>this)}remove(){return this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement),this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||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(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const n=e(),s=r(),i=this.trigger?.promises?.length,o=!this.recurrence||this.recurrence.isOver();if(!n&&!s||i||!o)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const a=n||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:a};return a?(await this.insert(),this.addCloseEvent(),n||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),c):c}onPageChange(e,t,n){const s=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,this.trigger&&this.trigger.clear());const i={[E]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[S]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):s()},[T]:()=>{this.hasBeenShown?this.pageWatcher.watch():s()}};"function"==typeof i[e]&&i[e]()}addCloseEvent(...t){const{closeButton:n,overlay:s,overlayClickable:i,layout:r,animationDuration:o=1e3}=DATA,a=[];if(void 0!==s&&!0!==s||!0!==i||"popin"!==r||a.push(`.${this.overlayClassName}`),void 0!==n&&n&&a.push(`.${this.closeButtonClassName}`),!a.length)return this;const c=this.domElement.querySelectorAll(a.join(", "));if(!c.length)return this;const l=["click",t=>{(t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())})(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*o)},{once:!0,capture:!0}];return t.push(...c),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.removeEventListener(...l),t.addEventListener(...l)}),this}getDom(){const{closeButton:e,layout:t,overlayClickable:n,overlay:s=!0}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(i.role="dialog"),i.innerHTML=`\n\t\t\t${"popin"===t&&!0===s?`<div ${n?'aria-label="Close dialog"':""} class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<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>`,i}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const n=document.createElement("style"),s=t.match(D)?t.match(D)[1]:"";n.innerHTML=`@font-face { font-family: '${e}_${s}'; src: url('${t}'); font-display: swap; }`;const i=this.rootElement?.head||document.head;i?.appendChild(n)}getStyleTag(t="",n=DATA){const{noStyles:s,layout:i}=n,{backgroundColor:r,isBackgroundImage:o,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:f,fontSize:b,isTitle:y,titleTextAlign:w,titleTextColor:$,titleFontName:E,titleFontStyle:S,titleFontSize:T,overlay:C,overlayColor:A,dropShadow:P,dropShadowColor:x,dropShadowBlur:k,containerMargin:N,containerPadding:L,closeButton:I,closeButtonPosition:R,closeButtonSize:B,closeButtonBorderRadius:O,closeButtonBorderWidth:_,closeButtonBorderColor:W,closeButtonColor:V,closeButtonBackgroundColor:j,buttonsAlign:q,buttonsBorderWidth:H,buttonsBorderColor:F,buttonsBorderRadius:M,buttonsBackgroundColor:z,buttonsTextColor:K,buttonsFontName:U,buttonsFontStyle:J,buttonsFontSize:G,secondLink:Y,secondLinkBorderWidth:Q,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:ee,secondLinkTextColor:te,secondLinkFontName:ne,secondLinkFontStyle:se,secondLinkFontSize:ie,animation:re,animationDuration:oe,animationBehaviour:ae,animationSlideDirection:ce}=s?{}:n,le=document.createElement("style");e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,f),this.loadFont(E,S),this.loadFont(U,J),this.loadFont(ne,se);const he=`background: ${["string"==typeof r?r:"rgba(255, 255, 255, 1)",o&&"string"==typeof a&&a.length?`url(${a})`:"",o&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",o&&"string"==typeof c?`/ ${c}`:"/ auto",o&&h&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,de="number"==typeof g&&g>0,ue=`border: ${[de?`${g}px`:"unset",de?"solid":"",de&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,ge=void 0!==u?`border-radius: ${u}px;`:"",me=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",pe=void 0!==p?`text-align: ${p};`:"",ve=v&&"inherit"!==v?`font-family:${v}_${f.match(D)?f.match(D)[1]:""};`:f||"",fe=b?`font-size: ${b}px;`:"",be=void 0!==P&&P?`box-shadow: 0 5px ${k}px 0 ${x};`:"",ye=N instanceof Array&&1===N.length&&N[0],we=ye?`margin: ${ye.top}px ${ye.right}px ${ye.bottom}px ${ye.left}px;`:"",$e=ye?`margin: calc(${ye.top}px * 0.5) calc(${ye.right}px * 0.5) calc(${ye.bottom}px * 0.5) calc(${ye.left}px * 0.5);`:"",Ee=L instanceof Array&&1===L.length&&L[0],Se=Ee?`padding: ${Ee.top}px ${Ee.right}px ${Ee.bottom}px ${Ee.left}px;`:"",Te=Ee?`padding: calc(${Ee.top}px * 0.5) calc(${Ee.right}px * 0.5) calc(${Ee.bottom}px * 0.5) calc(${Ee.left}px * 0.5);`:"",Ce=void 0!==H&&H?`border-width: ${H}px; border-style: solid;`:"",Ae=[F,H].every(e=>void 0!==e)&&H?`border-color: ${F};`:"",Pe=void 0!==M?`border-radius: ${M}px;`:"",xe=void 0!==z?`background-color: ${z};`:"",ke=void 0!==K?`color: ${K}; fill: ${K}; -webkit-text-fill-color: ${K};`:"",Ne=U&&"inherit"!==U?`font-family:${U}_${J.match(D)?J.match(D)[1]:""};`:J||"",Le=G?`font-size: ${G}px;`:"",Ie="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Re=[X,Q].every(e=>void 0!==e)&&Q?`border-color: ${X};`:"",De=void 0!==Z?`border-radius: ${Z}px;`:"",Be=void 0!==ee?`background-color: ${ee};`:"",Oe=void 0!==te?`color: ${te}; fill: ${te}; -webkit-text-fill-color: ${te};`:"",_e=ne&&"inherit"!==ne?`font-family:${ne}_${se.match(D)?se.match(D)[1]:""};`:se||"",We=ie?`font-size: ${ie}px;`:"",Ve="popin"!==i||void 0!==C&&!0!==C?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==A?A:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),je="number"==typeof B?B:16,qe=je/2,He=s||void 0!==I&&I?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${qe}px)`:`top: ${qe}px`)+";",`right: ${qe}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 _&&_>0?`border: ${_}px solid ${void 0!==W?W:"rgba(57, 57, 57, 1)"};`:"","string"==typeof j?`background-color: ${j};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${je}px;`,`height: ${je}px;`,"string"==typeof V?`fill: ${V};`:"","}"].join(""):"",Fe=y&&"string"==typeof $?[`#${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: ${$}; fill: ${$}; -webkit-text-fill-color: ${$};`,void 0!==w?`text-align: ${w};`:"",E&&"inherit"!==E?`font-family:${E}_${S.match(D)?S.match(D)[1]:""};`:S||"",T?`font-size: ${T}px;`:"","}"].join(""):"";let Me="";if("string"==typeof re){const t=(oe/1e3).toFixed(2),n=["top","bottom"].includes(ce),s=Number(n),i=[(["top","left"].includes(ce)?"-":"")+"100vmax",this.translateValues?this.translateValues[s]:"0"];n&&i.reverse(),Me={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ae};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ae};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${i.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ae};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":re].join("")}const ze=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===q?"top":"left"}: 8px;`,Ie,Re,De,Be,Oe,_e,We,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Oe,_e,We,"}"];return le.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,he,ge,ue,me,pe,be,we,ve,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,me,pe,ve,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Se,ve,fe,"}",`#${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;",Ce,Ae,Pe,xe,ke,Ne,Le,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,ke,Ne,Le,"}",...Y?ze:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,$e,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Te,"}","}",Ve,He,Fe,Me,`${t}`].join(""),le}}class _ 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:e,zindexCustom:t}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;",`z-index: ${"custom"===e?t:e};`,"background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class W extends O{constructor(e,t){super(e,t),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("")}}function V(e){return V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},V(e)}function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach(function(t){H(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function H(e,t,n){return(t=F(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e){var t=function(e){if("object"!=V(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=V(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==V(t)?t:t+""}var M=function(){return t=function e(t){var n=t.parentContainer;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentContainer=n,this.baseClassName="spotlight_container",this.className="".concat(this.baseClassName,"_").concat(n.uniqueId),this.contentElement=this.getContentElement()},n=[{key:"insertIn",value:function(t,n){return this.setStyles(),t.insertAdjacentElement(n,this.contentElement),e()||(setTimeout(this.setHorizontalScroll.bind(this),500),window.addEventListener("resize",this.setHorizontalScroll.bind(this))),this}},{key:"remove",value:function(){var e=this,t=DATA.animationDuration;setTimeout(function(){return e.parentContainer.remove()},1.05*(void 0===t?1e3:t))}},{key:"onRedirect",value:function(e){window.ABTastyEvent(e,null,TEST_ID),h('Tracking "'.concat(e,'" sent to campaign ').concat(TEST_ID)),this.parentContainer.recurrence.setValidationRecurrence()}},{key:"setHorizontalScroll",value:function(){var e=this,t=ABTasty.getParsedUserAgent().type,n=this.contentElement,s=n.scrollWidth,i=n.clientWidth,r=!1,o=!1,a=0,c=0,l=function(){return n.classList.remove("".concat(e.baseClassName,"_draggable_active"))},h=function(){o?setTimeout(l,50):l(),r=!1,o=!1},d=function(e){r=!0,a=e.pageX-n.offsetLeft,c=n.scrollLeft,n.addEventListener("mouseup",h,{capture:!0,once:!0,passive:!0})},u=function(t){if(r){t.preventDefault(),n.classList.add("".concat(e.baseClassName,"_draggable_active")),o=!0;var s=t.pageX-n.offsetLeft-a;n.scrollLeft=c-s}};"Desktop"===t&&s>i?(n.classList.add("".concat(this.baseClassName,"_draggable")),n.addEventListener("mousedown",d,{capture:!0,passive:!0}),n.addEventListener("mousemove",u,{capture:!0,passive:!1})):(n.classList.remove("".concat(this.baseClassName,"_draggable")),n.removeEventListener("mousedown",d,{capture:!0,passive:!0}),n.removeEventListener("mousemove",u,{capture:!0,passive:!1}))}},{key:"getContentElement",value:function(){var t=this,n=DATA,s=n.spotlightContent,i=n.layout,r=document.createElement("div");return r.className="".concat(this.className," buttons_container"),["bannerTop","bannerBottom"].includes(i)&&this.parentContainer.domElement.removeAttribute("role"),1===s.length&&e()&&(s.length=4,s.fill(q(q({},s[0]),{},{text:"Example",fake:!0}),1)),s.forEach(function(n,s){var i=n.text,o=n.link,a=n.fake,c=n.tracking,l=document.createElement("figure");a&&(l.className="spotlightExample"),l.innerHTML="<a href='".concat(o,"' aria-label=\"").concat(i,'"></a><legend>').concat(i,"</legend>");var h=c.replace(/!name!/gm,i).replace(/!number!/gm,s+1);e()||l.querySelector("a").addEventListener("click",function(){return t.onRedirect(h)},{capture:!0}),r.appendChild(l)}),r}},{key:"setStyles",value:function(){var e=this,t=this.parentContainer,n=t.styleElement,s=t.widgetContainerId,i=DATA,r=i.buttonsBorderRadius,o=i.buttonsTextColor,a=i.buttonsFontName,c=i.buttonsFontStyle,l=i.buttonsFontSize,h=i.insideBorderWidth,d=i.insideBorderColor,u=i.buttonsAlign,g=i.spotlightContent,m=i.buttonsSize,p=i.buttonsSpace,v=i.scrollSnapBehaviour,f=i.scrollBarDisplay,b=i.textAlign,y=i.textWrap,w=/.+\/([^.]+)\.(otf|ttf)$/,$=void 0!==o?"color: ".concat(o,"; fill: ").concat(o,"; -webkit-text-fill-color: ").concat(o,";"):"",E=a&&"inherit"!==a?"font-family:".concat(a,"_").concat(c.match(w)?c.match(w)[1]:"",";"):c||"",S=["#".concat(s," .").concat(this.className," {"),"display: flex;","flex-direction: row;","flex-wrap: nowrap;","justify-content: ".concat(u,";"),"align-items: flex-start;","overflow-x: auto;","overscroll-behavior-x: contain;",v?"scroll-snap-type: x mandatory;":"",f?"scrollbar-width: none;":"","overflow-y: hidden;","}",f?["#".concat(s," .").concat(this.className,"::-webkit-scrollbar {"),"display: none;","}"].join(""):"",".".concat(this.baseClassName,"_draggable {"),"cursor: grab;","}","#".concat(s," .").concat(this.baseClassName,"_draggable_active {"),"cursor: grabbing;","}","#".concat(s," .").concat(this.baseClassName,"_draggable_active * {"),"pointer-events: none;","}",".".concat(this.className," .spotlightExample {"),"opacity: 0.5;","}",".".concat(this.className," figure {"),"display: flex;","flex-direction: column;","font-size: 0;","text-align: center;","margin: 0 ".concat(p,"vw;"),"width: ".concat(m,"vh;"),"min-width: ".concat(m,"vh;"),"scroll-snap-align: start;","scroll-margin-left: ".concat(p,"vw;"),"}",".".concat(this.className," figure a {"),"line-height: 0;","width: 100%;","background-size: cover;","background-position: center;","background-repeat: no-repeat;","border-radius: ".concat(r,"% !important;"),"position: relative;","}",".".concat(this.className," figure legend {"),"display: inline-block;","margin-top: ".concat(10,"px;"),"white-space: ".concat(y?"pre-wrap":"nowrap",";"),"overflow: hidden;","text-overflow: ellipsis;","line-height: 1.5;","font-size: ".concat(l,"px;"),"text-align: ".concat(b,";"),$,E,"}",g.map(function(t,n){var s=t.image;return[".".concat(e.className," figure:nth-of-type(").concat(n+1,") a {"),'background-image: url("'.concat("widget_common_defaultImgUrl"===s?"https://widgets-images.abtasty.com/widgets-default-image.png":s,'");'),"}"].join("")}).join(""),".".concat(this.className," figure a::before {"),'content: "";',"display: block;","border-radius: ".concat(r,"% !important;"),"padding-bottom: calc(100% - ".concat(2*h,"px);"),h>0?"border: ".concat(h,"px solid ").concat(d,";"):"","}",".".concat(this.className," figure a::after {"),'content: "";',"display: block;","position: absolute;","top: calc(100% + ".concat(r,"px);"),"left: -".concat(r,"px;"),"z-index: 1;","width: calc(100% + ".concat(2*r,"px);"),"height: ".concat(1.1*(10+l),"px;"),"}"].join("");return n.insertAdjacentText("beforeend",S),n}}],n&&function(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,F(s.key),s)}}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();!function(){h("Widget launch");var e=DATA.layout.includes("banner")?new _:new W,t=e.domElement.querySelector(".".concat(e.contentClassName)),n=new M({parentContainer:e});e.children=n,n.insertIn(t,"beforeend"),e.init(!0).then(function(t){t.response&&e.show()})}()}();
|
1
|
+
!function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(top,"ABTastyEditor"),t=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},n=e=>new Function(`try {\n\t\t${e}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),s=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),i=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),r=()=>window.ABTasty&&!0===window.ABTasty.consentReady,o=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},a=()=>{const e=o();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=n=>{const s=(()=>{if(e()||t())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),i=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(s||i){const e=a();window.console.log(`%c${e} - ${s?"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;")}},h=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t},d=(e,t)=>{const n=t?[]:null;if("string"!=typeof e||!e.trim().length)return n;const[s,i,r]=e.split("[]").map(e=>e.trim()),o=Boolean(r)?r:e,a=i?document.querySelector(s)?.[i]:document;return a?t?[...a.querySelectorAll(o)]:a.querySelector(o):n},u=e=>d(e,!1),g=e=>d(e,!0),m=(e,t)=>{const n=document.querySelector("body")||document.documentElement,s={childList:!0,subtree:!0,attributes:!0},i=()=>r.disconnect(),r=new MutationObserver(()=>{const n=u(t);return n&&!i()&&e(n)});return{clear:i,observe:(e=n)=>r.observe(e,s)}},p=()=>{},v=(t,n)=>{const s=u(t),i={selector:t,clear:p,observe:p};if(s)return setTimeout(()=>n(s),0),i;if(e())return setTimeout(()=>v(t,n),1e3),i;if(t.includes("[]"))return((e,t)=>{const[n,s]=t.split("[]").map(e=>e.trim()),i=u(n),r=i?.[s],{clear:o,observe:a}=m(e,t),c=()=>{const n=u(t);return n&&!l()&&e(n)},l=()=>{o(),i?.removeEventListener("load",c)},h=()=>{a(r),"iframe"===i?.localName&&i.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(n,t);const{clear:r,observe:o}=m(n,t);return o(),{selector:t,clear:r,observe:o}};function f(e,t){const n=e.parentElement||e.getRootNode().host;return t(e)||!n?e:f(n,t)}const b=(e,t)=>[...g(t)].some(n=>{const[s,,i]=t.split("[]"),r=i??s;return n===e||!!e.closest(r)});let y=!1;class w{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(e){const t=[e,"transitionend",this.checkElements.bind(this),!0];return this.getEvents(...t)}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start(),this.scrollEvent.start(),this.onTransitionEnd.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),this.onTransitionEnd.clear(),!1))})}startVisibilityObserver(e){const t={root:e,rootMargin:"0px",threshold:0};return this.visibilityObserver??=new IntersectionObserver(this.intersectionHandler.bind(this),t),this.visibilityObserver}startMutationObserver(e){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(e,{attributes:!0,childList:!0,subtree:!0}),this.mutationObserver}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find(({element:n,selector:s})=>{if(n.isSameNode(e))return!0;const[i,,r]=s.split("[]"),o=r??i,a=[...e.querySelectorAll(o)];if(a.length&&a.includes(n))return!0;if(t.includes(n))return!0;if(!e.parentElement?.children?.length)return;const c=[...e.parentElement.children],l=c.findIndex(t=>t.isSameNode(e)),h=c.filter((e,t)=>t>l);if(h.length){if(h.includes(n))return!0;if(h.some(e=>[...e.querySelectorAll(o)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:s}=n,i=this.targets.find(t=>t.selector===e&&t.uniqueId===s);i&&i.resolve(t),this.clear(e,s)}}getEvents(e,...t){return{start:()=>e?.addEventListener(...t),clear:()=>e?.removeEventListener(...t)}}mouseOverHandler(e){const t=[e,"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0?"touchmove":"mouseover",e=>{const t=e.composedPath(),{target:n}=e;setTimeout(()=>this.onMouseOver({target:n,path:t}),50)},!0];return this.getEvents(...t)}scrollEventHandler(e){const t=[e,"scroll",(n=this.checkElements.bind(this),()=>{y||(y=!0,setTimeout(()=>{n(),y=!1},100))}),{passive:!0}];var n;return this.getEvents(...t)}isElementVisible(e){return this.isElementOpaque(e)&&this.isElementTopmost(e)}isElementOpaque(e){return"HTML"===f(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),n=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let s=!1,i=0;for(;!s&&i<n.length;){const t=e.getRootNode()?.elementFromPoint(...n[i]);s=e===t||t?.contains(e)||e.contains(t),i+=1}return s}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=u(e),[s,,i]=e.split("[]"),r=i??s;n&&!this.existingTargets.find(e=>e.element.matches(r)&&e.uniqueId===t)&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!u(e)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:n})=>{const[s,,i]=e.split("[]"),r=i??s;if(t.matches(r)&&this.isElementVisible(t)){const s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);return s&&s.resolve(t),this.clear(e,n),!1}return!0})}onLoadIframe(e){const t=[e.defaultView.frameElement,"load",()=>this.watch(selector,resolve,uniqueId).bind(this),{passive:!0}];return this.getEvents(...t)}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const{clear:s}=v(e,e=>{s();const t=e.getRootNode(),n="body"in t?t.body:document;this.mouseOverEvent=this.mouseOverHandler(t),this.scrollEvent=this.scrollEventHandler(t),this.onTransitionEnd=this.transitionOverHandler(t),t.defaultView?.frameElement&&(this.onIframeLoad=this.onLoadIframe(t),this.onIframeLoad.start()),this.startVisibilityObserver(n),this.startMutationObserver(n),this.checkElements()})}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(n=>n.filter(({selector:n,uniqueId:s})=>n!==e&&s!==t));const n=u(e);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 E="remove",$="rebuild",S="update",T="ABTastyData";class C{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n,triggerTarget:s}){this.event=e,this.selector=Boolean(t)?t:"body",this.target="string"==typeof s?u(t):s,this.delay=1e3*n,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=h(`${this.event}DomReady`);this.promises.push(n);const{clear:s}=v(this.selector,()=>{const e=new w;this.visibilityObservers.push(e),e.watch(this.selector,t,c())});return this.elementWaiters.push(s),e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const s=["readystatechange",()=>n()&&t(!0),{passive:!0}];return this.eventsListeners.push([document,...s]),document.addEventListener(...s),e}return t(!0),e}onClick({promise:e,resolve:t}){const n=({isTrusted:e,target:n})=>{if(e)return(n.isEqualNode(this.target)||b(n,this.selector))&&t(!0)},{clear:s}=v(this.selector,e=>{s();const t=document.createElement("style");t.id=`Click_${c()}`;const[i,,r]=this.selector.split("[]"),o=r??i;t.innerHTML=`${o} {\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tpointer-events: all !important;\n\t\t\t}`;const a=e.getRootNode();("head"in a?a.head:a).appendChild(t),this.triggerElements.push(t);const l=["click",n,{passive:!0,capture:!0}];this.eventsListeners.push([a,...l]),a.addEventListener(...l)});return this.elementWaiters.push(s),e}onHover({promise:e,resolve:t}){const n=({isTrusted:e,target:n})=>{if(e)return(this.target?n.isEqualNode(this.target):b(n,this.selector))&&t(!0)},{clear:s}=v(this.selector,e=>{const t=e.getRootNode(),s="body"in t?t.body:[...t.childNodes].find(t=>t.contains(e)),i=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([s,...i]),s.addEventListener(...i)});return this.elementWaiters.push(s),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",({isTrusted:e,clientY:n})=>{e&&n<=0&&t(!0)},{passive:!0}],{clear:s}=v("html",e=>{s(),this.eventsListeners.push([e,...n]),e.addEventListener(...n)});return e}onReengage({promise:e,resolve:t}){const n=this.delay;let s=n;const i=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),r=[({isTrusted:e})=>{e&&(s=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...i].forEach(t=>{this.eventsListeners.push([t,e,...r]),t.addEventListener(e,...r)})});const o=setInterval(()=>{s<=0?t(!0):s-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n,tagIsSafeEval:s}=DATA,i=s&&DATA_JS?.triggerEventCustomScript,r="function"==typeof i?()=>new Promise(e=>i(e)):new Function(`return new Promise(async resolve => {${n}})`);return r().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let n=0;const s=["scroll",({isTrusted:e})=>{e&&(window.scrollY<n?t(!0):n=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...s]),document.addEventListener(...s),e}onScrollPercentReached({promise:e,resolve:t}){const{triggerEventScrollPercent:n}=DATA,s=["scroll",({isTrusted:e})=>{if(!e)return;const s=(()=>{const{documentElement:e,body:t}=document,n=e.scrollTop||t.scrollTop,s=e.scrollHeight||t.scrollHeight;return Math.trunc(n/(s-e.clientHeight)*100,10)})();n<s&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...s]),document.addEventListener(...s),e}checkSocialProofConditions(e,t,n,s){const i=(()=>{let e;return window.ABTasty||window.ABTASTY_S?(window.ABTASTY_S?.USER?.accountIdentifier?.length?e=window.ABTASTY_S.USER.accountIdentifier:"function"==typeof window.ABTasty?.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty?.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:r,spNoTrim:o}=DATA;if(this.socialProofStore.hasOwnProperty(e))n(this.socialProofStore[e])?s(`${this.socialProofStore[e][r]}`):s(!1);else if(e&&i){const a=t=>(this.socialProofStore[e]=t,s(!!n(t)&&`${t[r]}`));fetch(`https://api-social-proof.abtasty.com/clients/${i}/metrics/${t}?key=${e}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>l("Failed to fetch datas from server."))}else s(!1)}getSocialProofDatas({promise:e,resolve:t},i,r=!1){const{productKey:o,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:i,customJSProductKey:r,productSKU:o,tagIsSafeEval:a}=DATA,{pathToProductKey:c,customJSProductKey:l}=a?DATA_JS:{};if(2===e)return{productKey:s(),keyType:"url"};{let a=null,h="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a="function"==typeof c?c():n(`return ${i};`);break;case"customJSProductKey":a="function"==typeof l?l():n(r);break;case"productSKU":a=o}return a||3!==e||(a=s(),h="url"),{productKey:a,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:u}=DATA,g={pv:u,i:d,"v-pv":h}[i];return[typeof c,typeof g].includes("undefined")&&t(!1),r&&!o&&(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"),t(!1)),this.checkSocialProofConditions(o,"v-pv"===i&&"sku"===a?"v-i":i,e=>{const t=void 0!==e[c]&&e[c]>=g;return t||l(`Widget will not be shown, Social Proof API returned ${e[c]} while ${g} are required`),t},t),e}onConsent({promise:e,resolve:t}){if(!r()){const n=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(n),window.addEventListener(...n),e}return t(!0),e}onTrackingSent({promise:e,resolve:t}){const{triggerEventTrackingSent:n}=DATA;let s=localStorage.getItem(T);const i=()=>JSON.parse(s)?.ActionTracking?.some(({name:e})=>e===n),r=["storage",({key:e,newValue:n})=>{e===T&&(s=n,i()&&t(!0))},{passive:!0,capture:!0}];return s&&i()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:n}=DATA;let s=localStorage.getItem(T);const i=()=>n<=(s?JSON.parse(s)?.VisitedPages?.length:0),r=["storage",({key:e,newValue:n})=>{e===T&&(s=n,i()&&t(!0))},{passive:!0,capture:!0}];return s&&i()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:s}=DATA;let i=0,r=!1;const o=["click",({isTrusted:e})=>{if(e&&(i+=1,i>=n&&t(!0),!r)){r=!0;const e=setTimeout(()=>{i=0,r=!1},s);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...o]),e.addEventListener(...o)},{clear:c}=v("iframe []contentDocument[] body > *",()=>{const e=document.getElementsByTagName("iframe");for(const t of e){"contentDocument"in t&&"body"in t.contentDocument&&a(t.contentDocument);const e=()=>a(t.contentDocument);t.addEventListener("load",e),this.eventsListeners.push([t,"onIframeLoad",e])}});return this.elementWaiters.push(c),a(document),e}clear(){this.triggerElements=this.triggerElements.filter(e=>(e.remove(),!1)),this.eventsListeners=this.eventsListeners.filter(e=>{const[t,...n]=e;return t&&n.length>1&&t.removeEventListener(...n),!1}),this.timeouts=this.timeouts.filter(e=>(clearTimeout(e),!1)),this.intervals=this.intervals.filter(e=>(clearInterval(e),!1));const e=c();return this.visibilityObservers=this.visibilityObservers.filter(t=>(t.clear(this.selector,e),!1)),this.promises=this.promises.filter(e=>(e.resolve(!1),!1)),this.elementWaiters=this.elementWaiters.filter(e=>(e(),!1)),this}async isTriggered(){this.clear();const e=h(this.event);this.promises.push(e);const t={consent:()=>this.onConsent(e),direct:()=>!0,pageLoad:()=>this.onPageLoad(e),click:()=>this.onClick(e),exitIntent:()=>this.onExitIntent(e),reengage:()=>this.onReengage(e),elementVisible:()=>this.onElementVisible(e),script:()=>this.onCustomTrigger(e),hover:()=>this.onHover(e),scrollUp:()=>this.onScrollUp(e),scrollPercent:()=>this.onScrollPercentReached(e),rageClick:()=>this.onRageClick(e),minPagesViewed:()=>this.onMinPagesViewed(e),trackingSent:()=>this.onTrackingSent(e),socialProofPurchases:()=>this.getSocialProofDatas(e,"i",!0),socialProofPageViews:()=>this.getSocialProofDatas(e,"pv"),socialProofVisitors:()=>this.getSocialProofDatas(e,"v-pv")},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return n&&this.clear(),"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=h(`${this.event}Delay`);this.promises.push(e);const t=setTimeout(()=>{e.resolve(!0),this.clear()},this.delay);return this.timeouts.push(t),e.promise})():n}}const P="display",A="closing",x="validation",k="ABTastyWidgets",N=`${k}Temporary`;class I{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:n},s){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(n),this.onSetCallback=s,this.widgetName=o(),this.uniqueId=c(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(N),n=sessionStorage.getItem(k);"ABTastyData"===e&&!t&&n&&localStorage.setItem(N,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(k);return JSON.parse(t)}catch(t){return e.removeItem(k),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:n,...s}=t;return Object.entries(s).length?(e.setItem(k,JSON.stringify(s)),s):(e.removeItem(k),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=localStorage.getItem(N),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(k,e),localStorage.removeItem(N));const n=this.getLocalRecurrence(),s=(n?parseFloat(n.stamp):0)<(new Date).getTime();return s&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&s&&!this.getLocalRecurrence()&&!t}setRecurrence(e,n){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const s=this.getTypeOfStorage(e);if(t()||!s&&"object"!=typeof s)return!1;const{storageString:i,storageMethod:o}=s,a=this.getStamp(e),c={type:n,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!r()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new C({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===i?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const s=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};o.setItem(k,JSON.stringify(s)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(l&&n!==x)if(n===A&&l!==x)h();else{if(n!==P||l===x||l===A)return!1;h()}else h();return a}setDisplayRecurrence(){const e=P;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=A;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=x;this.setRecurrence(this.validationRecurrence,e)}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class L{constructor(e,t,n){this.isWidgetApplied=e,this.callback=t,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(e){const t=!e&&this.isWidgetApplied(),n=t?this.shouldUpdate&&S:$;return n?(this.clearWatcher(),this.callback(n,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback($,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback(E,!1),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return i()?e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler():this:this.callback(E,!1)}watch(t,n){if(e())return this;if(this.clearWatcher(t),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),n?.includes("[]contentDocument[]")){const e=n.split("[]")[0].trim(),{clear:t}=v(e,e=>{t(),this.triggerIframeTarget=e,e.addEventListener("load",this.decisionHandler.bind(this))})}const s=t?.defaultView?.frameElement;s&&this.triggerIframeTarget!==s&&s.addEventListener("load",this.decisionHandler.bind(this));const{clear:i}=v("body",e=>{i();const n=t?.body||t||e;this.observer.observe(n,{childList:!0,subtree:!0})});return this}clearTriggerElementWatcher(){this.triggerIframeTarget?.removeEventListener("load",this.decisionHandler.bind(this))}clearWatcher(e){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this.clearTriggerElementWatcher(),e?.defaultView?.frameElement?.removeEventListener("load",this.decisionHandler.bind(this)),this}}const R=/.+\/([^.]+)\.(otf|ttf)$/,D=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class B{constructor(t,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=o(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:n,validationRecurrence:s}=DATA,i=!t&&!n&&!s;if(e()||i)return!1;const r={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},o={};return t&&(o.displayRecurrence=r[t]("displayRecurrence")),n&&(o.closingRecurrence=r[n]("closingRecurrence")),s&&(o.validationRecurrence=r[s]("validationRecurrence")),o})(),this.triggerParams=(t=>{let{triggerEvent:n}=DATA;const{triggerEventClick:s,triggerEventHover:i,triggerEventReengageDelay:r,socialProofContentType:o,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!n&&!o)return!1;const l={click:()=>s,hover:()=>i,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",d="reengage"===n?r:c;return o&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][o]),{triggerEvent:n,triggerSelector:h,triggerDelay:d,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new I(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new C(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&D.includes(this.triggerParams.triggerEvent),this.pageWatcher=new L(this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!["click","hover","scrollUp","script"].includes(t)||e})(),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(){this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]}isWidgetApplied(){return this.domElement?.isConnected&&this.domElement.ownerDocument?.defaultView}removeOldDomElement(){const e=this.rootElement?.getElementById(this.widgetContainerId);return e?.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=["free"];"drawer"===DATA.layout&&DATA.customTarget&&e.push("drawer");const t=e.includes(DATA.layout);return new Promise(e=>{const{elementReferrer:n="body",referrerInsertType:s="beforeend"}=t?DATA:{},i=v(n,t=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==n),this.rootElement=t.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),e(t.insertAdjacentElement(s,this.domElement))});this.elementsWaiters.push(i)}).then(()=>this)}remove(){return this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement),this.domElement?.isConnected&&this.domElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch(this.rootElement):e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||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(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(this.rootElement),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const n=e(),s=i(),r=this.trigger?.promises?.length,o=!this.recurrence||this.recurrence.isOver();if(!n&&!s||r||!o)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const a=n||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:a};return a?(await this.insert(),this.addCloseEvent(),n||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),c):c}onPageChange(e,t,n){const s=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,this.trigger&&this.trigger.clear());const i={[E]:()=>n?this.remove():this.pageWatcher.watch(this.rootElement),[$]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):s()},[S]:()=>{this.hasBeenShown?this.pageWatcher.watch():s()}};"function"==typeof i[e]&&i[e]()}addCloseEvent(...t){const{closeButton:n,overlay:s,overlayClickable:i,layout:r,animationDuration:o=1e3}=DATA,a=[];if(void 0!==s&&!0!==s||!0!==i||"popin"!==r||a.push(`.${this.overlayClassName}`),void 0!==n&&n&&a.push(`.${this.closeButtonClassName}`),!a.length)return this;const c=this.domElement.querySelectorAll(a.join(", "));if(!c.length)return this;const l=["click",t=>{(t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())})(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*o)},{once:!0,capture:!0}];return t.push(...c),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.removeEventListener(...l),t.addEventListener(...l)}),this}getDom(){const{closeButton:e,layout:t,overlayClickable:n,overlay:s=!0}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(i.role="dialog"),i.innerHTML=`\n\t\t\t${"popin"===t&&!0===s?`<div ${n?'aria-label="Close dialog"':""} class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<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>`,i}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const n=document.createElement("style"),s=t.match(R)?t.match(R)[1]:"";n.innerHTML=`@font-face { font-family: '${e}_${s}'; src: url('${t}'); font-display: swap; }`;const i=this.rootElement?.head||document.head;i?.appendChild(n)}getStyleTag(t="",n=DATA){const{noStyles:s,layout:i}=n,{backgroundColor:r,isBackgroundImage:o,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:f,fontSize:b,isTitle:y,titleTextAlign:w,titleTextColor:E,titleFontName:$,titleFontStyle:S,titleFontSize:T,overlay:C,overlayColor:P,dropShadow:A,dropShadowColor:x,dropShadowBlur:k,containerMargin:N,containerPadding:I,closeButton:L,closeButtonPosition:D,closeButtonSize:B,closeButtonBorderRadius:O,closeButtonBorderWidth:_,closeButtonBorderColor:W,closeButtonColor:V,closeButtonBackgroundColor:j,buttonsAlign:q,buttonsBorderWidth:H,buttonsBorderColor:F,buttonsBorderRadius:M,buttonsBackgroundColor:z,buttonsTextColor:K,buttonsFontName:U,buttonsFontStyle:G,buttonsFontSize:J,secondLink:Y,secondLinkBorderWidth:Q,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:ee,secondLinkTextColor:te,secondLinkFontName:ne,secondLinkFontStyle:se,secondLinkFontSize:ie,animation:re,animationDuration:oe,animationBehaviour:ae,animationSlideDirection:ce}=s?{}:n,le=document.createElement("style");e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,f),this.loadFont($,S),this.loadFont(U,G),this.loadFont(ne,se);const he=`background: ${["string"==typeof r?r:"rgba(255, 255, 255, 1)",o&&"string"==typeof a&&a.length?`url(${a})`:"",o&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",o&&"string"==typeof c?`/ ${c}`:"/ auto",o&&h&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,de="number"==typeof g&&g>0,ue=`border: ${[de?`${g}px`:"unset",de?"solid":"",de&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,ge=void 0!==u?`border-radius: ${u}px;`:"",me=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",pe=void 0!==p?`text-align: ${p};`:"",ve=v&&"inherit"!==v?`font-family:${v}_${f.match(R)?f.match(R)[1]:""};`:f||"",fe=b?`font-size: ${b}px;`:"",be=void 0!==A&&A?`box-shadow: 0 5px ${k}px 0 ${x};`:"",ye=N instanceof Array&&1===N.length&&N[0],we=ye?`margin: ${ye.top}px ${ye.right}px ${ye.bottom}px ${ye.left}px;`:"",Ee=ye?`margin: calc(${ye.top}px * 0.5) calc(${ye.right}px * 0.5) calc(${ye.bottom}px * 0.5) calc(${ye.left}px * 0.5);`:"",$e=I instanceof Array&&1===I.length&&I[0],Se=$e?`padding: ${$e.top}px ${$e.right}px ${$e.bottom}px ${$e.left}px;`:"",Te=$e?`padding: calc(${$e.top}px * 0.5) calc(${$e.right}px * 0.5) calc(${$e.bottom}px * 0.5) calc(${$e.left}px * 0.5);`:"",Ce=void 0!==H&&H?`border-width: ${H}px; border-style: solid;`:"",Pe=[F,H].every(e=>void 0!==e)&&H?`border-color: ${F};`:"",Ae=void 0!==M?`border-radius: ${M}px;`:"",xe=void 0!==z?`background-color: ${z};`:"",ke=void 0!==K?`color: ${K}; fill: ${K}; -webkit-text-fill-color: ${K};`:"",Ne=U&&"inherit"!==U?`font-family:${U}_${G.match(R)?G.match(R)[1]:""};`:G||"",Ie=J?`font-size: ${J}px;`:"",Le="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Re=[X,Q].every(e=>void 0!==e)&&Q?`border-color: ${X};`:"",De=void 0!==Z?`border-radius: ${Z}px;`:"",Be=void 0!==ee?`background-color: ${ee};`:"",Oe=void 0!==te?`color: ${te}; fill: ${te}; -webkit-text-fill-color: ${te};`:"",_e=ne&&"inherit"!==ne?`font-family:${ne}_${se.match(R)?se.match(R)[1]:""};`:se||"",We=ie?`font-size: ${ie}px;`:"",Ve="popin"!==i||void 0!==C&&!0!==C?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==P?P:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),je="number"==typeof B?B:16,qe=je/2,He=s||void 0!==L&&L?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===D?`bottom: calc(100% + ${qe}px)`:`top: ${qe}px`)+";",`right: ${qe}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 _&&_>0?`border: ${_}px solid ${void 0!==W?W:"rgba(57, 57, 57, 1)"};`:"","string"==typeof j?`background-color: ${j};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${je}px;`,`height: ${je}px;`,"string"==typeof V?`fill: ${V};`:"","}"].join(""):"",Fe=y&&"string"==typeof E?[`#${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: ${E}; fill: ${E}; -webkit-text-fill-color: ${E};`,void 0!==w?`text-align: ${w};`:"",$&&"inherit"!==$?`font-family:${$}_${S.match(R)?S.match(R)[1]:""};`:S||"",T?`font-size: ${T}px;`:"","}"].join(""):"";let Me="";if("string"==typeof re){const t=(oe/1e3).toFixed(2),n=["top","bottom"].includes(ce),s=Number(n),i=[(["top","left"].includes(ce)?"-":"")+"100vmax",this.translateValues?this.translateValues[s]:"0"];n&&i.reverse(),Me={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ae};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ae};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${i.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ae};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":re].join("")}const ze=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===q?"top":"left"}: 8px;`,Le,Re,De,Be,Oe,_e,We,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Oe,_e,We,"}"];return le.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,he,ge,ue,me,pe,be,we,ve,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,me,pe,ve,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Se,ve,fe,"}",`#${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;",Ce,Pe,Ae,xe,ke,Ne,Ie,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,ke,Ne,Ie,"}",...Y?ze:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Ee,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Te,"}","}",Ve,He,Fe,Me,`${t}`].join(""),le}}class O extends B{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:e,zindexCustom:t}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;",`z-index: ${"custom"===e?t:e};`,"background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class _ extends B{constructor(e,t){super(e,t),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("")}}function W(e){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},W(e)}function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V(Object(n),!0).forEach(function(t){q(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function q(e,t,n){return(t=H(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function H(e){var t=function(e){if("object"!=W(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=W(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==W(t)?t:t+""}var F=function(){return t=function e(t){var n=t.parentContainer;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentContainer=n,this.baseClassName="spotlight_container",this.className="".concat(this.baseClassName,"_").concat(n.uniqueId),this.contentElement=this.getContentElement()},n=[{key:"insertIn",value:function(t,n){return this.setStyles(),t.insertAdjacentElement(n,this.contentElement),e()||(setTimeout(this.setHorizontalScroll.bind(this),500),window.addEventListener("resize",this.setHorizontalScroll.bind(this))),this}},{key:"remove",value:function(){var e=this,t=DATA.animationDuration;setTimeout(function(){return e.parentContainer.remove()},1.05*(void 0===t?1e3:t))}},{key:"onRedirect",value:function(e){window.ABTastyEvent(e,null,TEST_ID),l('Tracking "'.concat(e,'" sent to campaign ').concat(TEST_ID)),this.parentContainer.recurrence.setValidationRecurrence()}},{key:"setHorizontalScroll",value:function(){var e=this,t=ABTasty.getParsedUserAgent().type,n=this.contentElement,s=n.scrollWidth,i=n.clientWidth,r=!1,o=!1,a=0,c=0,l=function(){return n.classList.remove("".concat(e.baseClassName,"_draggable_active"))},h=function(){o?setTimeout(l,50):l(),r=!1,o=!1},d=function(e){r=!0,a=e.pageX-n.offsetLeft,c=n.scrollLeft,n.addEventListener("mouseup",h,{capture:!0,once:!0,passive:!0})},u=function(t){if(r){t.preventDefault(),n.classList.add("".concat(e.baseClassName,"_draggable_active")),o=!0;var s=t.pageX-n.offsetLeft-a;n.scrollLeft=c-s}};"Desktop"===t&&s>i?(n.classList.add("".concat(this.baseClassName,"_draggable")),n.addEventListener("mousedown",d,{capture:!0,passive:!0}),n.addEventListener("mousemove",u,{capture:!0,passive:!1})):(n.classList.remove("".concat(this.baseClassName,"_draggable")),n.removeEventListener("mousedown",d,{capture:!0,passive:!0}),n.removeEventListener("mousemove",u,{capture:!0,passive:!1}))}},{key:"getContentElement",value:function(){var t=this,n=DATA,s=n.spotlightContent,i=n.layout,r=document.createElement("div");return r.className="".concat(this.className," buttons_container"),["bannerTop","bannerBottom"].includes(i)&&this.parentContainer.domElement.removeAttribute("role"),1===s.length&&e()&&(s.length=4,s.fill(j(j({},s[0]),{},{text:"Example",fake:!0}),1)),s.forEach(function(n,s){var i=n.text,o=n.link,a=n.fake,c=n.tracking,l=document.createElement("figure");a&&(l.className="spotlightExample"),l.innerHTML="<a href='".concat(o,"' aria-label=\"").concat(i,'"></a><legend>').concat(i,"</legend>");var h=c.replace(/!name!/gm,i).replace(/!number!/gm,s+1);e()||l.querySelector("a").addEventListener("click",function(){return t.onRedirect(h)},{capture:!0}),r.appendChild(l)}),r}},{key:"setStyles",value:function(){var e=this,t=this.parentContainer,n=t.styleElement,s=t.widgetContainerId,i=DATA,r=i.buttonsBorderRadius,o=i.buttonsTextColor,a=i.buttonsFontName,c=i.buttonsFontStyle,l=i.buttonsFontSize,h=i.insideBorderWidth,d=i.insideBorderColor,u=i.buttonsAlign,g=i.spotlightContent,m=i.buttonsSize,p=i.buttonsSpace,v=i.scrollSnapBehaviour,f=i.scrollBarDisplay,b=i.textAlign,y=i.textWrap,w=/.+\/([^.]+)\.(otf|ttf)$/,E=void 0!==o?"color: ".concat(o,"; fill: ").concat(o,"; -webkit-text-fill-color: ").concat(o,";"):"",$=a&&"inherit"!==a?"font-family:".concat(a,"_").concat(c.match(w)?c.match(w)[1]:"",";"):c||"",S=["#".concat(s," .").concat(this.className," {"),"display: flex;","flex-direction: row;","flex-wrap: nowrap;","justify-content: ".concat(u,";"),"align-items: flex-start;","overflow-x: auto;","overscroll-behavior-x: contain;",v?"scroll-snap-type: x mandatory;":"",f?"scrollbar-width: none;":"","overflow-y: hidden;","}",f?["#".concat(s," .").concat(this.className,"::-webkit-scrollbar {"),"display: none;","}"].join(""):"",".".concat(this.baseClassName,"_draggable {"),"cursor: grab;","}","#".concat(s," .").concat(this.baseClassName,"_draggable_active {"),"cursor: grabbing;","}","#".concat(s," .").concat(this.baseClassName,"_draggable_active * {"),"pointer-events: none;","}",".".concat(this.className," .spotlightExample {"),"opacity: 0.5;","}",".".concat(this.className," figure {"),"display: flex;","flex-direction: column;","font-size: 0;","text-align: center;","margin: 0 ".concat(p,"vw;"),"width: ".concat(m,"vh;"),"min-width: ".concat(m,"vh;"),"scroll-snap-align: start;","scroll-margin-left: ".concat(p,"vw;"),"}",".".concat(this.className," figure a {"),"line-height: 0;","width: 100%;","background-size: cover;","background-position: center;","background-repeat: no-repeat;","border-radius: ".concat(r,"% !important;"),"position: relative;","}",".".concat(this.className," figure legend {"),"display: inline-block;","margin-top: ".concat(10,"px;"),"white-space: ".concat(y?"pre-wrap":"nowrap",";"),"overflow: hidden;","text-overflow: ellipsis;","line-height: 1.5;","font-size: ".concat(l,"px;"),"text-align: ".concat(b,";"),E,$,"}",g.map(function(t,n){var s=t.image;return[".".concat(e.className," figure:nth-of-type(").concat(n+1,") a {"),'background-image: url("'.concat("widget_common_defaultImgUrl"===s?"https://widgets-images.abtasty.com/widgets-default-image.png":s,'");'),"}"].join("")}).join(""),".".concat(this.className," figure a::before {"),'content: "";',"display: block;","border-radius: ".concat(r,"% !important;"),"padding-bottom: calc(100% - ".concat(2*h,"px);"),h>0?"border: ".concat(h,"px solid ").concat(d,";"):"","}",".".concat(this.className," figure a::after {"),'content: "";',"display: block;","position: absolute;","top: calc(100% + ".concat(r,"px);"),"left: -".concat(r,"px;"),"z-index: 1;","width: calc(100% + ".concat(2*r,"px);"),"height: ".concat(1.1*(10+l),"px;"),"}"].join("");return n.insertAdjacentText("beforeend",S),n}}],n&&function(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,H(s.key),s)}}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();!function(){l("Widget launch");var e=DATA.layout.includes("banner")?new O:new _,t=e.domElement.querySelector(".".concat(e.contentClassName)),n=new F({parentContainer:e});e.children=n,n.insertIn(t,"beforeend"),e.init(!0).then(function(t){t.response&&e.show()})}()}();
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@abtasty/spotlight",
|
3
3
|
"description": "Allow you to add a spotlight section on your website",
|
4
|
-
"version": "1.1.
|
4
|
+
"version": "1.1.16",
|
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": "1.1.14"
|
46
|
+
}
|
48
47
|
}
|