@abtasty/drawer 0.0.35 → 0.0.36

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/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},i=e=>new Function(`try {\n\t\t${e}\n\t} catch (error) {\n\t\treturn null;\n\t}`)(),n=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),s=()=>!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=i=>{const n=(()=>{if(e()||t())return!1;const i=ABTasty.getTestsOnPage()[TEST_ID];return!!i&&Object.keys(i.targetings.qaParameters).length>0})(),s=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(n||s){const e=a();window.console.log(`%c${e} - ${n?"QA":"Debug"} Mode for campaign ${TEST_ID} %c ${i}`,"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,i)=>{t.resolve=e,t.reject=i}),t},d=(e,t)=>{const i=t?[]:null;if("string"!=typeof e||!e.trim().length)return i;const[n,s,r]=e.split("[]").map(e=>e.trim()),o=Boolean(r)?r:e,a=s?document.querySelector(n)?.[s]:document;return a?t?[...a.querySelectorAll(o)]:a.querySelector(o):i},u=e=>d(e,!1),g=e=>d(e,!0),m=(e,t)=>{const i={childList:!0,subtree:!0,attributes:!0},n=()=>s.disconnect(),s=new MutationObserver(()=>{const i=u(t);return i&&!n()&&e(i)});return{clear:n,observe:e=>{const t=document.querySelector("body")||document.documentElement,n=e??t;s.observe(n,i)}}},p=()=>{},v=(t,i)=>{const n=u(t),s={selector:t,clear:p,observe:p};if(n)return setTimeout(()=>i(n),0),s;if(e())return setTimeout(()=>v(t,i),1e3),s;if(t.includes("[]"))return((e,t)=>{const[i,n]=t.split("[]").map(e=>e.trim()),s=u(i),r=s?.[n],{clear:o,observe:a}=m(e,t),c=()=>{const i=u(t);return i&&!l()&&e(i)},l=()=>{o(),s?.removeEventListener("load",c)},h=()=>{a(r),"iframe"===s?.localName&&s.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(i,t);const{clear:r,observe:o}=m(i,t);return o(),{selector:t,clear:r,observe:o}};function y(e,t){const i=e.parentElement||e.getRootNode().host;return t(e)||!i?e:y(i,t)}const f=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},w=(e,t)=>[...g(t)].some(i=>{const[n,,s]=t.split("[]"),r=s??n;return i===e||!!e.closest(r)});let b=!1;class E{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:.01};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 i=this.inViewportTargets.find(({element:i,selector:n})=>{if(i.isSameNode(e))return!0;const[s,,r]=n.split("[]"),o=r??s,a=[...e.querySelectorAll(o)];if(a.length&&a.includes(i))return!0;if(t.includes(i))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(i))return!0;if(h.some(e=>[...e.querySelectorAll(o)].includes(i)))return!0}return!1});if(i&&this.isElementVisible(i.element)){const{selector:e,element:t,uniqueId:n}=i,s=this.targets.find(t=>t.selector===e&&t.uniqueId===n);s&&s.resolve(t),this.clear(e,n)}}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:i}=e;setTimeout(()=>this.onMouseOver({target:i,path:t}),50)},!0];return this.getEvents(...t)}scrollEventHandler(e){const t=[e,"scroll",(i=this.checkElements.bind(this),()=>{b||(b=!0,setTimeout(()=>{i(),b=!1},100))}),{passive:!0}];var i;return this.getEvents(...t)}isElementVisible(e){return this.isElementOpaque(e)&&this.isElementTopmost(e)}isElementOpaque(e){return"HTML"===y(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),i=[[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 n=!1,s=0;for(;!n&&s<i.length;){const t=e.getRootNode()?.elementFromPoint(...i[s]);n=e===t||t?.contains(e)||e.contains(t),s+=1}return n}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const i=u(e),[n,,s]=e.split("[]"),r=s??n;i&&!this.existingTargets.find(e=>e.element.matches(r)&&e.uniqueId===t)&&(this.existingTargets.push({element:i,selector:e,uniqueId:t}),this.visibilityObserver.observe(i))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!(!u(e)||!t.isConnected)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:i})=>{const[n,,s]=e.split("[]"),r=s??n;if(t.matches(r)&&this.isElementVisible(t)){const n=this.targets.find(t=>t.selector===e&&t.uniqueId===i);return n&&n.resolve(t),this.clear(e,i),!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,i){this.targets.push({selector:e,resolve:t,uniqueId:i});const{clear:n}=v(e,e=>{n();const t=e.getRootNode({composed:!0}),i="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(t),this.startMutationObserver(i),this.checkElements()})}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(i=>i.filter(({selector:i,uniqueId:n})=>i!==e&&n!==t));const i=u(e);i&&this.visibilityObserver?.unobserve(i),0===this.targets.length&&(this.mutationObserver?.disconnect(),this.onIframeLoad?.clear()),0===this.inViewportTargets.length&&(this.mouseOverEvent?.clear(),this.scrollEvent?.clear(),this.onTransitionEnd?.clear())}}const T="remove",C="rebuild",S="update",x="ABTastyData";class k{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:i,triggerTarget:n}){this.event=e,this.selector=Boolean(t)?t:"body",this.target="string"==typeof n?u(t):n,this.delay=1e3*i,this.triggerElements=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={},this.elementWaiters=[]}async onElementVisible({promise:e,resolve:t}){const i=h(`${this.event}DomReady`);this.promises.push(i);const{clear:n}=v(this.selector,()=>{const e=new E;this.visibilityObservers.push(e),e.watch(this.selector,t,c())});return this.elementWaiters.push(n),e}onPageLoad({promise:e,resolve:t}){const i=()=>"complete"===document.readyState;if(!i()){const n=["readystatechange",()=>i()&&t(!0),{passive:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}return t(!0),e}onClick({promise:e,resolve:t}){const i=({isTrusted:e,target:i})=>{if(e)return(i.isEqualNode(this.target)||w(i,this.selector))&&t(!0)},{clear:n}=v(this.selector,e=>{n();const t=document.createElement("style");t.id=`Click_${c()}`;const[s,,r]=this.selector.split("[]"),o=r??s;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",i,{passive:!0,capture:!0}];this.eventsListeners.push([a,...l]),a.addEventListener(...l)});return this.elementWaiters.push(n),e}onHover({promise:e,resolve:t}){const i=({isTrusted:e,target:i})=>{if(e)return(this.target?i.isEqualNode(this.target):w(i,this.selector))&&t(!0)},{clear:n}=v(this.selector,e=>{const t=e.getRootNode(),n="body"in t?t.body:[...t.childNodes].find(t=>t.contains(e)),s=["mouseenter",i,{passive:!0,capture:!0}];this.eventsListeners.push([n,...s]),n.addEventListener(...s)});return this.elementWaiters.push(n),e}onExitIntent({promise:e,resolve:t}){const i=["mouseleave",({isTrusted:e,clientY:i})=>{e&&i<=0&&t(!0)},{passive:!0}],{clear:n}=v("html",e=>{n(),this.eventsListeners.push([e,...i]),e.addEventListener(...i)});return e}onReengage({promise:e,resolve:t}){const i=this.delay;let n=i;const s=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),r=[({isTrusted:e})=>{e&&(n=i)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...s].forEach(t=>{this.eventsListeners.push([t,e,...r]),t.addEventListener(e,...r)})});const o=setInterval(()=>{n<=0?t(!0):n-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:i,tagIsSafeEval:n}=DATA,s=n&&DATA_JS?.triggerEventCustomScript,r="function"==typeof s?()=>new Promise(e=>s(e)):new Function(`return new Promise(async resolve => {${i}})`);return r().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let i=0;const n=["scroll",({isTrusted:e})=>{e&&(window.scrollY<i?t(!0):i=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}onScrollPercentReached({promise:e,resolve:t}){const{triggerEventScrollPercent:i}=DATA,n=["scroll",({isTrusted:e})=>{if(!e)return;const n=(()=>{const{documentElement:e,body:t}=document,i=e.scrollTop||t.scrollTop,n=e.scrollHeight||t.scrollHeight;return Math.trunc(i/(n-e.clientHeight)*100,10)})();i<n&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}checkSocialProofConditions(e,t,i,n){const s=(()=>{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))i(this.socialProofStore[e])?n(`${this.socialProofStore[e][r]}`):n(!1);else if(e&&s){const a=t=>(this.socialProofStore[e]=t,n(!!i(t)&&`${t[r]}`));fetch(`https://api-social-proof.abtasty.com/clients/${s}/metrics/${t}?key=${e}${o?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>l("Failed to fetch datas from server."))}else n(!1)}getSocialProofDatas({promise:e,resolve:t},s,r=!1){const{productKey:o,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:s,customJSProductKey:r,productSKU:o,tagIsSafeEval:a}=DATA,{pathToProductKey:c,customJSProductKey:l}=a&&DATA_JS||{};if(2===e)return{productKey:n(),keyType:"url"};{let a=null,h="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a="function"==typeof c?c():i(`return ${s};`);break;case"customJSProductKey":a="function"==typeof l?l():i(r);break;case"productSKU":a=o}return a||3!==e||(a=n(),h="url"),{productKey:a,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:u}=DATA,g={pv:u,i:d,"v-pv":h}[s];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"===s&&"sku"===a?"v-i":s,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 i=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(i),window.addEventListener(...i),e}return t(!0),e}onTrackingSent({promise:e,resolve:t}){const{triggerEventTrackingSent:i}=DATA;let n=localStorage.getItem(x);const s=()=>JSON.parse(n)?.ActionTracking?.some(({name:e})=>e===i),r=["storage",({key:e,newValue:i})=>{e===x&&(n=i,s()&&t(!0))},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:i}=DATA;let n=localStorage.getItem(x);const s=()=>i<=(n?JSON.parse(n)?.VisitedPages?.length:0),r=["storage",({key:e,newValue:i})=>{e===x&&(n=i,s()&&t(!0))},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...r]),window.addEventListener(...r)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:i,triggerEventRageClickDelay:n}=DATA;let s=0,r=!1;const o=["click",({isTrusted:e})=>{if(e&&(s+=1,s>=i&&t(!0),!r)){r=!0;const e=setTimeout(()=>{s=0,r=!1},n);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,...i]=e;return t&&i.length>1&&t.removeEventListener(...i),!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")},i=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return i&&this.clear(),"reengage"!==this.event&&this.delay?i&&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})():i}}const A="display",I="closing",B="validation",P="ABTastyWidgets",L=`${P}Temporary`;class N{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:i},n){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(i),this.onSetCallback=n,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(L),i=sessionStorage.getItem(P);"ABTastyData"===e&&!t&&i&&localStorage.setItem(L,i)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(P);return JSON.parse(t)}catch(t){return e.removeItem(P),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:i,...n}=t;return Object.entries(n).length?(e.setItem(P,JSON.stringify(n)),n):(e.removeItem(P),!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(P,e),localStorage.removeItem(L));const i=this.getLocalRecurrence(),n=(i?parseFloat(i.stamp):0)<(new Date).getTime();return n&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&n&&!this.getLocalRecurrence()&&!t}setRecurrence(e,i){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(e);if(t()||!n&&"object"!=typeof n)return!1;const{storageString:s,storageMethod:o}=n,a=this.getStamp(e),c={type:i,stamp:a},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!r()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new k({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let i;"session"===s?e?i=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),i=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?i=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),i=this.getLocalRecurrenceStorageParsed()));const n=i?{[this.recurrenceKey]:c,...i}:{[this.recurrenceKey]:c};o.setItem(P,JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(l&&i!==B)if(i===I&&l!==B)h();else{if(i!==A||l===B||l===I)return!1;h()}else h();return a}setDisplayRecurrence(){const e=A;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=I;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=B;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,i){this.isWidgetApplied=e,this.callback=t,this.shouldUpdate=i,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(),i=t?this.shouldUpdate&&S:C;return i?(this.clearWatcher(),this.callback(i,!e,t),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(C,!1),this.watch())}onTagRollback({target:e}){return this.clearWatcher(e),this.callback(T,!1,!0),window.addEventListener(...this.onCampaignLaunchedEventParams),this}observerHandler(e){return s()?e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler():this:this.callback(T,!1)}watch(t,i){if(e())return this;if(this.clearWatcher(t),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),i?.includes("[]contentDocument[]")){const e=i.split("[]")[0].trim(),{clear:t}=v(e,e=>{t(),this.triggerIframeTarget=e,e.addEventListener("load",this.decisionHandler.bind(this))})}const n=t?.defaultView?.frameElement;n&&this.triggerIframeTarget!==n&&n.addEventListener("load",this.decisionHandler.bind(this));const{clear:s}=v("body",e=>{s();const i=t?.body||t||e;this.observer.observe(i,{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)$/,_=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class O{constructor(t,i){this.children=void 0,this.uniqueId=`${c()}${i?`_${i}`:""}`,this.widgetName=o(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:i,validationRecurrence:n}=DATA,s=!t&&!i&&!n;if(e()||s)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")),i&&(o.closingRecurrence=r[i]("closingRecurrence")),n&&(o.validationRecurrence=r[n]("validationRecurrence")),o})(),this.triggerParams=(t=>{let{triggerEvent:i}=DATA;const{triggerEventClick:n,triggerEventHover:s,triggerEventReengageDelay:r,socialProofContentType:o,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!i&&!o)return!1;const l={click:()=>n,hover:()=>s,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,i)?l[i]():"body",d="reengage"===i?r:c;return o&&(i=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][o]),{triggerEvent:i,triggerSelector:h,triggerDelay:d,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new N(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new k(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&_.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.websiteFocusedElement=null,this.elementsWaiters=[]}clearGivenClearables(){for(const e of this.elementsWaiters)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:i="body",referrerInsertType:n="beforeend"}=t?DATA:{},s=v(i,t=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==i),this.rootElement=t.getRootNode(),this.removeOldDomElement(),this.domElement.appendChild(this.styleElement),e(t.insertAdjacentElement(n,this.domElement))});this.elementsWaiters.push(s)}).then(()=>this)}remove(){this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement);for(const e of this.elementsWaiters)[DATA.elementReferrer,"body"].includes(e.selector)&&e.clear();return 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,this.websiteFocusedElement=document.activeElement,setTimeout(()=>{this.domElement.classList.remove(this.hideClassName),e()||this.domElement.querySelector('input[type="text"], textarea, a, button')?.focus()},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),!e()&&this.websiteFocusedElement?.isConnected&&this.websiteFocusedElement.focus(),this}async init(t){const i=e(),n=s(),r=this.trigger?.promises?.length,o=!this.recurrence||this.recurrence.isOver();if(!i&&!n||r||!o)return{container:this,response:!1};this.pageWatcher.watch(this.rootElement||document,this.triggerParams.triggerSelector);const a=i||!this.trigger||this.trigger&&await this.trigger.isTriggered();this.pageWatcher.clearTriggerElementWatcher();const c={container:this,response:a};return a?(await this.insert(),this.addCloseEvent(),i||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),c):c}onPageChange(e,t,i){const n=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,i&&this.domElement.remove(),this.trigger&&this.trigger.clear());const s={[T]:()=>i?this.remove():this.pageWatcher.watch(this.rootElement),[C]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch(this.rootElement):i||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):n()},[S]:()=>{this.hasBeenShown?this.pageWatcher.watch():n()}};"function"==typeof s[e]&&s[e]()}addCloseEvent(...t){const{closeButton:i,overlay:n,overlayClickable:s,layout:r,animationDuration:o=1e3}=DATA,a=[];if(void 0!==n&&!0!==n||!0!==s||"popin"!==r||a.push(`.${this.overlayClassName}`),void 0!==i&&i&&a.push(`.${this.closeButtonClassName}`),!a.length)return this;const c=this.domElement.querySelectorAll(a.join(", "));if(!c.length)return this;const l=e=>{const t="click"===e.type,i="keyup"===e.type&&"Escape"===e.code&&e.isTrusted;(t||i)&&(f(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*o))},h=["click",l,{once:!0,capture:!0}];t.push(...c);for(const i of t)e()&&(i.dataset.abtastyActionnable="true"),i.removeEventListener(...h),i.addEventListener(...h);return window.removeEventListener("keyup",l,{once:!0}),window.addEventListener("keyup",l,{once:!0}),this}getDom(){const{closeButton:e,layout:t,overlayClickable:i,overlay:n=!0}=DATA,s=document.createElement("div");return s.className=`${this.basicClassName} ${this.hideClassName}`,s.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(s.role="dialog","popin"===t&&!0===n&&(s.ariaModal="true")),s.innerHTML=`\n\t\t\t${"popin"===t&&!0===n?`<div ${i?'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>`,s}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const i=document.createElement("style"),n=t.match(D)?t.match(D)[1]:"";i.innerHTML=`@font-face { font-family: '${e}_${n}'; src: url('${t}'); font-display: swap; }`;const s=this.rootElement?.head||document.head;s?.appendChild(i)}getStyleTag(t="",i=DATA){const{noStyles:n,layout:s}=i,{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:y,fontSize:f,isTitle:w,titleTextAlign:b,titleTextColor:E,titleFontName:T,titleFontStyle:C,titleFontSize:S,overlay:x,overlayColor:k,dropShadow:A,dropShadowColor:I,dropShadowBlur:B,containerMargin:P,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:_,closeButtonBorderRadius:O,closeButtonBorderWidth:W,closeButtonBorderColor:V,closeButtonColor:j,closeButtonBackgroundColor:H,buttonsAlign:F,buttonsBorderWidth:M,buttonsBorderColor:q,buttonsBorderRadius:K,buttonsBackgroundColor:U,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:G,buttonsFontSize:J,secondLink:X,secondLinkBorderWidth:Q,secondLinkBorderColor:Z,secondLinkBorderRadius:ee,secondLinkBackgroundColor:te,secondLinkTextColor:ie,secondLinkFontName:ne,secondLinkFontStyle:se,secondLinkFontSize:re,animation:oe,animationDuration:ae,animationBehaviour:ce,animationSlideDirection:le}=n?{}:i,he=document.createElement("style");e()&&he.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(T,C),this.loadFont(Y,G),this.loadFont(ne,se);const de=`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()};`,ue="number"==typeof g&&g>0,ge=`border: ${[ue?`${g}px`:"unset",ue?"solid":"",ue&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,me=void 0!==u?`border-radius: ${u}px;`:"",pe=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",ve=void 0!==p?`text-align: ${p};`:"",ye=v&&"inherit"!==v?`font-family:${v}_${y.match(D)?y.match(D)[1]:""};`:y||"",fe=f?`font-size: ${f}px;`:"",we=void 0!==A&&A?`box-shadow: 0 5px ${B}px 0 ${I};`:"",$e=P instanceof Array&&1===P.length&&P[0],be=$e?`margin: ${$e.top}px ${$e.right}px ${$e.bottom}px ${$e.left}px;`:"",Ee=$e?`margin: calc(${$e.top}px * 0.5) calc(${$e.right}px * 0.5) calc(${$e.bottom}px * 0.5) calc(${$e.left}px * 0.5);`:"",Te=L instanceof Array&&1===L.length&&L[0],Ce=Te?`padding: ${Te.top}px ${Te.right}px ${Te.bottom}px ${Te.left}px;`:"",Se=Te?`padding: calc(${Te.top}px * 0.5) calc(${Te.right}px * 0.5) calc(${Te.bottom}px * 0.5) calc(${Te.left}px * 0.5);`:"",xe=void 0!==M&&M?`border-width: ${M}px; border-style: solid;`:"",ke=[q,M].every(e=>void 0!==e)&&M?`border-color: ${q};`:"",Ae=void 0!==K?`border-radius: ${K}px;`:"",Ie=void 0!==U?`background-color: ${U};`:"",Be=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Pe=Y&&"inherit"!==Y?`font-family:${Y}_${G.match(D)?G.match(D)[1]:""};`:G||"",Le=J?`font-size: ${J}px;`:"",Ne="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Re=[Z,Q].every(e=>void 0!==e)&&Q?`border-color: ${Z};`:"",De=void 0!==ee?`border-radius: ${ee}px;`:"",_e=void 0!==te?`background-color: ${te};`:"",Oe=void 0!==ie?`color: ${ie}; fill: ${ie}; -webkit-text-fill-color: ${ie};`:"",We=ne&&"inherit"!==ne?`font-family:${ne}_${se.match(D)?se.match(D)[1]:""};`:se||"",Ve=re?`font-size: ${re}px;`:"",je="popin"!==s||void 0!==x&&!0!==x?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==k?k:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),He="number"==typeof _?_:16,Fe=He/2,Me=n||void 0!==N&&N?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${Fe}px)`:`top: ${Fe}px`)+";",`right: ${Fe}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 H?`background-color: ${H};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${He}px;`,`height: ${He}px;`,"string"==typeof j?`fill: ${j};`:"","}"].join(""):"",qe=w&&"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!==b?`text-align: ${b};`:"",T&&"inherit"!==T?`font-family:${T}_${C.match(D)?C.match(D)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Ke="";if("string"==typeof oe){const t=(ae/1e3).toFixed(2),i=["top","bottom"].includes(le),n=Number(i),s=[(["top","left"].includes(le)?"-":"")+"100vmax",this.translateValues?this.translateValues[n]:"0"];i&&s.reverse(),Ke={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} {`,"transition: unset;","}","}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ce};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} .${this.overlayClassName},`,`.${this.hideClassName} .${this.contentClassName},`,`#${this.widgetContainerId} .${this.contentClassName} {`,"transition: unset;","}","}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":oe].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===F?"top":"left"}: 8px;`,Ne,Re,De,_e,Oe,We,Ve,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Oe,We,Ve,"}"];return he.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,me,ge,pe,ve,we,be,ye,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pe,ve,ye,fe,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,ye,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;",xe,ke,Ae,Ie,Be,Pe,Le,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *:not(.second_link span), `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"], [class*="csatEmojiButton"]) * {`,Be,Pe,Le,"}",...X?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Ee,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",je,Me,qe,Ke,`${t}`].join(""),he}}const W={top:{top:0,left:50,translateX:-50,translateY:-100,translateOpenX:-50,translateOpenY:0},bottom:{top:100,left:50,translateX:-50,translateY:0,translateOpenX:-50,translateOpenY:-100},left:{top:50,left:0,translateX:-100,translateY:-50,translateOpenX:0,translateOpenY:-50},right:{top:50,right:0,translateX:100,translateY:-50,translateOpenX:0,translateOpenY:-50}},V={top:[!1,!1,!0,!0],bottom:[!0,!0,!1,!1],left:[!1,!0,!0,!1],right:[!0,!1,!1,!0]};class j extends O{constructor(){super(),this.button=this.setButton(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles),this.open=!1}toggleDrawer(){this.open=this.domElement.classList.toggle("drawer_open")}setButton(){const{mainButtonText:t,hasMainButtonIcon:i,mainButtonIcon:n,mainButtonIconAlt:s}=DATA,r=document.createElement("button");return r.className=`drawer_button_${this.uniqueId}`,e()&&(r.dataset.abtastyActionnable="true"),r.innerHTML=`<span>${t}</span>${i?`<img src="${n}" alt="${s}">`:""}`,e()&&top.document.documentElement.classList.contains("widget-react-form-opened")&&this.domElement.classList.add("drawer_open"),r.addEventListener("click",this.toggleDrawer.bind(this),!0),this.domElement.insertAdjacentElement("beforeend",r),r}getStyles(){const{buttonLayout:e,customTarget:t,elementReferrer:i,zindex:n,zindexCustom:s,styckyButtonBackgroundColor:r,styckyButtonIsBackgroundImage:o,styckyButtonBackgroundImage:a,styckyButtonBackgroundPosition:c,styckyButtonBackgroundRepeat:l,styckyButtonBackgroundSize:h,styckyButtonButtonsAlign:d,styckyButtonContainerMargin:u,styckyButtonContainerPadding:g,styckyButtonButtonsBorderWidth:m,styckyButtonButtonsBorderColor:p,styckyButtonButtonsBorderRadius:v,styckyButtonDropShadow:y,styckyButtonDropShadowBlur:f,styckyButtonDropShadowColor:w,styckyButtonTitleFontName:b,styckyButtonTitleFontStyle:E,styckyButtonTitleFontSize:T,styckyButtonTitleTextAlign:C,styckyButtonTitleTextColor:S,autoWidth:x,drawerLayout:k,hasMainButtonIcon:A,animationDuration:I,animationBehaviour:B}=DATA,{top:P,left:L,right:N,translateX:R,translateY:D,translateOpenX:_,translateOpenY:O}=W[e],j=["left","right"].includes(e),[{top:H,bottom:F,left:M,right:q}]=u,[{top:K,bottom:U,left:z,right:Y}]=g,G=V[e].map(e=>e?`${v}px`:"0").join(" "),J=`background: ${[r,o&&a.length?`url(${a})`:"",o&&"100% 100%"!==h?c:"0 0",o&&"string"==typeof h?`/ ${h}`:"/ auto",o&&l&&!["cover","100% 100%"].includes(h)?"repeat":"no-repeat"].join(" ").trim()} !important;`,X=y?`box-shadow: 0 5px ${f}px 0 ${w};`:"",Q=`border: ${m>0?`${m}px solid ${p}`:"unset"};`,Z=/.+\/([^.]+)\.(otf|ttf)$/;this.loadFont(b,E);const ee=[`color: ${S}; fill: ${S}; -webkit-text-fill-color: ${S};`,`text-align: ${C};`,"inherit"!==b?`font-family:${b}_${E.match(Z)?E.match(Z)[1]:""};`:E||"",T?`font-size: ${T}px;`:""].join(""),te={left:"start",center:"center",right:"end"}[C],ie=t?i:"body",[ne,se,re]=ie.split("[]"),oe=re??ne,ae="shadowRoot"===se?":host":`${oe.trimEnd()}:not(:has(.fixed-drawer))`;return[`${oe} {`,"position: relative;","}",t?[`${ae} {`,`overflow-${j?"x":"y"}: hidden;`,"}"].join(""):"",`#${this.widgetContainerId} {`,"position: absolute;",`top: ${P}%;`,"number"==typeof L?`left: ${L}%;`:"","number"==typeof N?`right: ${N}%;`:"",`transform: translate(${R}%, ${D}%);`,`transition: transform ${(I/1e3).toFixed(2)}s ${B};`,"margin: 0;","padding: 0;","background: none;",`z-index: ${"custom"===n?s:n};`,(()=>{if(x)return t?`width: auto; height: auto; max-width: calc(100% - ${j?`${z+Y+1.5*T}px`:`${K+U+1.5*T}px`});`:`width: auto; height: auto; min-width: 30vw; max-width: ${["left","right"].includes(k)?"80vw":"40vw"};`;const{popinPercentWidth:e,popinPixelsWidth:i,widthUnit:n,autoHeight:s,popinPercentHeight:r,popinPixelsHeight:o,heightUnit:a}=DATA;return`width: ${"px"===n?i:e}${n};height: ${s?"auto":`${"px"===a?o:r}${a}`};`})(),"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} {`,"transition: unset;","}","}",`#${this.widgetContainerId}.fixed-drawer {`,"position: fixed;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","width: 100%;","height: 100%;","box-sizing: border-box;","}",`#${this.widgetContainerId}.drawer_open {`,`transform: translate(${_}%, ${O}%);`,"}",`.${this.button.className} {`,"position: absolute;",`${e}: 100%;`,["top","bottom"].includes(e)?[`${"right"===d?"right":"left"}: ${["left","right"].includes(d)?"0":"50%"};`,`transform: translate(${["left","right"].includes(d)?"0":"-50%"}, 0);`,`width: ${"fill"===d?"100%":"auto"};`].join(""):"",j?[`${"right"===d?"bottom":"top"}: ${["center","fill"].includes(d)?"50%":"0"};`,`transform: translate(0, ${["left","right"].includes(d)?"0":"-50%"});`,`height: ${"fill"===d?"100%":"auto"};`].join(""):"",`margin: ${H}px ${q}px ${F}px ${M}px;`,`padding: ${K}px ${Y}px ${U}px ${z}px;`,"text-wrap: nowrap;",J,Q,`border-radius: ${G};`,"display: flex;",`flex-direction: ${j?"column":"row"};`,"align-items: center;",`justify-content: ${te};`,X,"}",`.${this.button.className} span {`,j?["writing-mode: vertical-rl;","text-orientation: sideways;"].join(""):"","right"===e?"transform: rotate(180deg);":"","width: auto;",ee,"}",A?[`.${this.button.className} img {`,j?`transform: rotate(${e.includes("right")?"-":""}90deg);`:"",`min-width: ${2*T}px;`,`max-height: ${2*T}px;`,`margin-${j?"top":"left"}: ${T}px`,"}"].join(""):"","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,x?"min-width: 40vw; max-width: 60vw;":"","}","}"].join("")}}class H{constructor(e){let{parentContainer:t}=e;this.parentContainer=t,this.className=`drawer_container_${t.uniqueId}`,this.domElement=this.getElement()}insertIn(e,t){this.setStyles(),e.insertAdjacentElement(t,this.domElement)}addRedirectionEvent(t){!e()&&t&&t.addEventListener("click",()=>{const{autoHide:t,timeHide:i}=DATA;t&&setTimeout(()=>{this.parentContainer.hide(),this.remove()},1e3*i),e()||this.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}addCloseEvent(t){t&&t.addEventListener("click",t=>{f(t),e()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),setTimeout(()=>this.parentContainer.remove(),1e3)},{capture:!0,passive:!1})}buttonBuilder(e,t,i,n){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=document.createElement("a");return r.ariaLabel=e,r.innerHTML=`<span>${e}</span>`,r.href="button"===t?i:"#",s&&(r.className="second_link"),"button"===t?(r.target=n?"_blank":"_self",this.addRedirectionEvent(r)):(r.dataset.abtastyActionnable="true",this.addCloseEvent(r)),r}getButtons(){const{linkType:e,buttonText:t,redirectionUrl:i,openInNewTab:n,secondLink:s,secondLinkText:r,secondLinkType:o,secondLinkURL:a,secondLinkOpenInNewTab:c}=DATA,l=[this.buttonBuilder(t,e,i,n)];if(s){const e=this.buttonBuilder(r,o,a,c,s);l.push(e)}return l}getElement(){const{linkType:e,buttonText:t,redirectionUrl:i,isTitle:n,title:s,textContent:r,openInNewTab:o,drawerLayout:a,drawerImage:c,altDesc:l}=DATA,h=document.createElement(e&&e.includes("widget")?"a":"div");h.className=this.className,"widget"===e?(h.href=i,h.target=o?"_blank":"_self",this.addRedirectionEvent(h)):"widgetClose"===e&&(h.href="#",h.dataset.abtastyActionnable="true",this.addCloseEvent(h)),h.innerHTML="textOnly"!==a?`<img src="${c}" ${"string"==typeof l?`alt="${l}"`:""}>`:"";const d=document.createElement("div");if(d.className="drawer_text_container","imageOnly"!==a&&(d.innerHTML=`\n\t\t\t${n?`<h2 class="drawer_title">${s}</h2>`:""}\n\t\t\t<p class="drawer_text">${r}</p>`),[e,t].every(e=>"string"==typeof e)&&e.includes("button")&&t.length){const e=this.getButtons(),t=document.createElement("div");t.className="buttons_container",e.forEach(e=>t.appendChild(e)),d.appendChild(t)}return h.appendChild(d),h}setStyles(){const{styleElement:e,widgetContainerId:t,contentClassName:i}=this.parentContainer,{linkType:n,buttonsAlign:s,drawerLayout:r}=DATA,o=`#${t} .${i}`,a=`${["left","right"].includes(r)?"row":"column"}${["right","bottom"].includes(r)?"-reverse":""}`,c=[`${o} .buttons_container {`,"display: inline-block;","width: 100%;",void 0!==s&&"fill"!==s?`text-align: ${s};`:"","}",`${o} .buttons_container a {`,"margin: 25px 0 0 0;","padding: 10px 22px;","line-height: 1;","max-width: 100%;",`width: ${"fill"===s?"100%":"auto"};`,"text-align: center;","}"].join(""),l=[`${o} .${this.className} {`,"display: flex;",`flex-direction: ${a};`,"justify-content: space-around;","align-items: center;","}",`.${this.className} > img {`,"max-width: 100%;","width: 100%;","height: auto;","}",["left","right"].includes(r)?[`${o} .${this.className} > * {`,"max-width: 46%;","}"].join(""):"",`${o} .drawer_title {`,"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}",`${o} .drawer_text_container {`,"line-height: 0;","white-space: pre-line;","display: inline-block;","vertical-align: middle;","width: 100%;","margin: 2vh 0;","}",`${o} .drawer_text_container * {`,"line-height: 1;","}",`${o} .drawer_text_container p {`,"margin: 0;","}"];n&&n.includes("button")&&l.push(c);const h=l.join("");return e.insertAdjacentText("beforeend",h),e}}!function(){l("Widget launch");const e=new j,t=e.domElement.querySelector(`.${e.contentClassName}`),i=new H({parentContainer:e});e.children=i,i.insertIn(t,"beforeend"),e.init(!0).then(t=>{let{response:i}=t;i&&(e.show(),(!0!==DATA.customTarget||u(DATA.elementReferrer).matches("body"))&&e.domElement.classList.add("fixed-drawer"))})}()}();
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}`)(),i=()=>encodeURIComponent(DATA.spNoTrim?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),r=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),o=()=>window.ABTasty&&!0===window.ABTasty.consentReady,s=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},a=()=>{const e=s();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},c=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,l=n=>{const i=(()=>{if(e()||t())return!1;const n=ABTasty.getTestsOnPage()[TEST_ID];return!!n&&Object.keys(n.targetings.qaParameters).length>0})(),r=window.document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(i||r){const e=a();window.console.log(`%c${e} - ${i?"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[i,r,o]=e.split("[]").map(e=>e.trim()),s=Boolean(o)?o:e,a=r?document.querySelector(i)?.[r]:document;return a?t?[...a.querySelectorAll(s)]:a.querySelector(s):n},u=e=>d(e,!1),g=e=>d(e,!0),m=(e,t)=>{const n={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=>{const t=document.querySelector("body")||document.documentElement,i=e??t;r.observe(i,n)}}},p=()=>{},v=(t,n)=>{const i=u(t),r={selector:t,clear:p,observe:p};if(i)return setTimeout(()=>n(i),0),r;if(e())return setTimeout(()=>v(t,n),1e3),r;if(t.includes("[]"))return((e,t)=>{const[n,i]=t.split("[]").map(e=>e.trim()),r=u(n),o=r?.[i],{clear:s,observe:a}=m(e,t),c=()=>{const n=u(t);return n&&!l()&&e(n)},l=()=>{s(),r?.removeEventListener("load",c)},h=()=>{a(o),"iframe"===r?.localName&&r.addEventListener("load",c)};return h(),{selector:t,clear:l,observe:h}})(n,t);const{clear:o,observe:s}=m(n,t);return s(),{selector:t,clear:o,observe:s}};function f(e,t){const n=e.parentElement||e.getRootNode().host;return t(e)||!n?e:f(n,t)}const y=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},b=(e,t)=>[...g(t)].some(n=>{const[i,,r]=t.split("[]"),o=r??i;return n===e||!!e.closest(o)});let w=!1;class E{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:.01};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:i})=>{if(n.isSameNode(e))return!0;const[r,,o]=i.split("[]"),s=o??r,a=[...e.querySelectorAll(s)];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(s)].includes(n)))return!0}return!1});if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:i}=n,r=this.targets.find(t=>t.selector===e&&t.uniqueId===i);r&&r.resolve(t),this.clear(e,i)}}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"===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 i=!1,r=0;for(;!i&&r<n.length;){const t=e.getRootNode()?.elementFromPoint(...n[r]);i=e===t||t?.contains(e)||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const n=u(e),[i,,r]=e.split("[]"),o=r??i;n&&!this.existingTargets.find(e=>e.element.matches(o)&&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.isConnected)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:n})=>{const[i,,r]=e.split("[]"),o=r??i;if(t.matches(o)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===n);return i&&i.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:i}=v(e,e=>{i();const t=e.getRootNode({composed:!0}),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(t),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:i})=>n!==e&&i!==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 T="remove",S="rebuild",C="update",x="ABTastyData";class k{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n,triggerTarget:i}){this.event=e,this.selector=Boolean(t)?t:"body",this.target="string"==typeof i?u(t):i,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:i}=v(this.selector,()=>{const e=new E;this.visibilityObservers.push(e),e.watch(this.selector,t,c())});return this.elementWaiters.push(i),e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const i=["readystatechange",()=>n()&&t(!0),{passive:!0}];return this.eventsListeners.push([document,...i]),document.addEventListener(...i),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:i}=v(this.selector,e=>{i();const t=document.createElement("style");t.id=`Click_${c()}`;const[r,,o]=this.selector.split("[]"),s=o??r;t.innerHTML=`${s} {\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(i),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:i}=v(this.selector,e=>{const t=e.getRootNode(),i="body"in t?t.body:[...t.childNodes].find(t=>t.contains(e)),r=["mouseenter",n,{passive:!0,capture:!0}];this.eventsListeners.push([i,...r]),i.addEventListener(...r)});return this.elementWaiters.push(i),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",({isTrusted:e,clientY:n})=>{e&&n<=0&&t(!0)},{passive:!0}],{clear:i}=v("html",e=>{i(),this.eventsListeners.push([e,...n]),e.addEventListener(...n)});return e}onReengage({promise:e,resolve:t}){const n=this.delay;let i=n;const r=[...document.querySelectorAll("*:empty")].map(e=>e.contentDocument||e.shadowRoot).filter(e=>e),o=[({isTrusted:e})=>{e&&(i=n)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{[document,...r].forEach(t=>{this.eventsListeners.push([t,e,...o]),t.addEventListener(e,...o)})});const s=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(s),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n,tagIsSafeEval:i}=DATA,r=i&&DATA_JS?.triggerEventCustomScript,o="function"==typeof r?()=>new Promise(e=>r(e)):new Function(`return new Promise(async resolve => {${n}})`);return o().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let n=0;const i=["scroll",({isTrusted:e})=>{e&&(window.scrollY<n?t(!0):n=window.scrollY)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...i]),document.addEventListener(...i),e}onScrollPercentReached({promise:e,resolve:t}){const{triggerEventScrollPercent:n}=DATA,i=["scroll",({isTrusted:e})=>{if(!e)return;const i=(()=>{const{documentElement:e,body:t}=document,n=e.scrollTop||t.scrollTop,i=e.scrollHeight||t.scrollHeight;return Math.trunc(n/(i-e.clientHeight)*100,10)})();n<i&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...i]),document.addEventListener(...i),e}checkSocialProofConditions(e,t,n,i){const r=(()=>{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:o,spNoTrim:s}=DATA;if(this.socialProofStore.hasOwnProperty(e))n(this.socialProofStore[e])?i(`${this.socialProofStore[e][o]}`):i(!1);else if(e&&r){const a=t=>(this.socialProofStore[e]=t,i(!!n(t)&&`${t[o]}`));fetch(`https://api-social-proof.abtasty.com/clients/${r}/metrics/${t}?key=${e}${s?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>l("Failed to fetch datas from server."))}else i(!1)}getSocialProofDatas({promise:e,resolve:t},r,o=!1){const{productKey:s,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:r,customJSProductKey:o,productSKU:s,tagIsSafeEval:a}=DATA,{pathToProductKey:c,customJSProductKey:l}=a&&DATA_JS||{};if(2===e)return{productKey:i(),keyType:"url"};{let a=null,h="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a="function"==typeof c?c():n(`return ${r};`);break;case"customJSProductKey":a="function"==typeof l?l():n(o);break;case"productSKU":a=s}return a||3!==e||(a=i(),h="url"),{productKey:a,keyType:h}}})(),{viewInterval:c,triggerSocialProofMinVisitors:h,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:u}=DATA,g={pv:u,i:d,"v-pv":h}[r];return[typeof c,typeof g].includes("undefined")&&t(!1),o&&!s&&(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(s,"v-pv"===r&&"sku"===a?"v-i":r,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(!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 i=localStorage.getItem(x);const r=()=>JSON.parse(i)?.ActionTracking?.some(({name:e})=>e===n),o=["storage",({key:e,newValue:n})=>{e===x&&(i=n,r()&&t(!0))},{passive:!0,capture:!0}];return i&&r()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:n}=DATA;let i=localStorage.getItem(x);const r=()=>n<=(i?JSON.parse(i)?.VisitedPages?.length:0),o=["storage",({key:e,newValue:n})=>{e===x&&(i=n,r()&&t(!0))},{passive:!0,capture:!0}];return i&&r()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:n,triggerEventRageClickDelay:i}=DATA;let r=0,o=!1;const s=["click",({isTrusted:e})=>{if(e&&(r+=1,r>=n&&t(!0),!o)){o=!0;const e=setTimeout(()=>{r=0,o=!1},i);this.timeouts.push(e)}},{passive:!0,capture:!0}],a=e=>{this.eventsListeners.push([e,...s]),e.addEventListener(...s)},{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 A="display",P="closing",I="validation",B="ABTastyWidgets",L=`${B}Temporary`;class N{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:n},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(n),this.onSetCallback=i,this.widgetName=s(),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(L),n=sessionStorage.getItem(B);"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(B);return JSON.parse(t)}catch(t){return e.removeItem(B),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:n,...i}=t;return Object.entries(i).length?(e.setItem(B,JSON.stringify(i)),i):(e.removeItem(B),!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(B,e),localStorage.removeItem(L));const n=this.getLocalRecurrence(),i=(n?parseFloat(n.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&i&&!this.getLocalRecurrence()&&!t}setRecurrence(e,n){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const i=this.getTypeOfStorage(e);if(t()||!i&&"object"!=typeof i)return!1;const{storageString:r,storageMethod:s}=i,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 k({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===r?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===r&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const i=n?{[this.recurrenceKey]:c,...n}:{[this.recurrenceKey]:c};s.setItem(B,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&n!==I)if(n===P&&l!==I)h();else{if(n!==A||l===I||l===P)return!1;h()}else h();return a}setDisplayRecurrence(){const e=A;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=P;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=I;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&&C: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(T,!1,!0),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(T,!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 i=t?.defaultView?.frameElement;i&&this.triggerIframeTarget!==i&&i.addEventListener("load",this.decisionHandler.bind(this));const{clear:r}=v("body",e=>{r();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 O=/.+\/([^.]+)\.(otf|ttf)$/,D=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class _{constructor(t,n){this.children=void 0,this.uniqueId=`${c()}${n?`_${n}`:""}`,this.widgetName=s(),this.prettyName=a(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:n,validationRecurrence:i}=DATA,r=!t&&!n&&!i;if(e()||r)return!1;const o={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},s={};return t&&(s.displayRecurrence=o[t]("displayRecurrence")),n&&(s.closingRecurrence=o[n]("closingRecurrence")),i&&(s.validationRecurrence=o[i]("validationRecurrence")),s})(),this.triggerParams=(t=>{let{triggerEvent:n}=DATA;const{triggerEventClick:i,triggerEventHover:r,triggerEventReengageDelay:o,socialProofContentType:s,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!n&&!s)return!1;const l={click:()=>i,hover:()=>r,elementVisible:()=>a},h=Object.prototype.hasOwnProperty.call(l,n)?l[n]():"body",d="reengage"===n?o:c;return s&&(n=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][s]),{triggerEvent:n,triggerSelector:h,triggerDelay:d,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new N(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new k(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&D.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.websiteFocusedElement=null,this.elementsWaiters=[]}clearGivenClearables(){for(const e of this.elementsWaiters)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:i="beforeend"}=t?DATA:{},r=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(i,this.domElement))});this.elementsWaiters.push(r)}).then(()=>this)}remove(){this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(this.rootElement);for(const e of this.elementsWaiters)[DATA.elementReferrer,"body"].includes(e.selector)&&e.clear();return 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(){const{layout:t,overlay:n=!0}=DATA;return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.websiteFocusedElement=document.activeElement,setTimeout(()=>{this.domElement.classList.remove(this.hideClassName),e()||"popin"!==t||!0!==n||this.domElement.querySelector('input[type="text"], textarea, a, button')?.focus()},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),!e()&&this.websiteFocusedElement?.isConnected&&this.websiteFocusedElement.focus(),this}async init(t){const n=e(),i=r(),o=this.trigger?.promises?.length,s=!this.recurrence||this.recurrence.isOver();if(!n&&!i||o||!s)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 i=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,n&&this.domElement.remove(),this.trigger&&this.trigger.clear());const r={[T]:()=>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):i()},[C]:()=>{this.hasBeenShown?this.pageWatcher.watch():i()}};"function"==typeof r[e]&&r[e]()}addCloseEvent(...t){const{closeButton:n,overlay:i,overlayClickable:r,layout:o,animationDuration:s=1e3}=DATA,a=[];if(void 0!==i&&!0!==i||!0!==r||"popin"!==o||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=e=>{const t="click"===e.type,n="keyup"===e.type&&"Escape"===e.code&&e.isTrusted;(t||n)&&(y(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*s))},h=["click",l,{once:!0,capture:!0}];t.push(...c);for(const n of t)e()&&(n.dataset.abtastyActionnable="true"),n.removeEventListener(...h),n.addEventListener(...h);return window.removeEventListener("keyup",l,{once:!0}),window.addEventListener("keyup",l,{once:!0}),this}getDom(){const{closeButton:e,layout:t,overlayClickable:n,overlay:i=!0}=DATA,r=document.createElement("div");return r.className=`${this.basicClassName} ${this.hideClassName}`,r.id=this.widgetContainerId,["popin","bannerTop","bannerBottom"].includes(t)&&(r.role="dialog","popin"===t&&!0===i&&(r.ariaModal="true")),r.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<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>`,r}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const n=document.createElement("style"),i=t.match(O)?t.match(O)[1]:"";n.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}'); font-display: swap; }`;const r=this.rootElement?.head||document.head;r?.appendChild(n)}getStyleTag(t="",n=DATA){const{noStyles:i,layout:r}=n,{backgroundColor:o,isBackgroundImage:s,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:h,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:f,fontSize:y,isTitle:b,titleTextAlign:w,titleTextColor:E,titleFontName:T,titleFontStyle:S,titleFontSize:C,overlay:x,overlayColor:k,dropShadow:A,dropShadowColor:P,dropShadowBlur:I,containerMargin:B,containerPadding:L,closeButton:N,closeButtonPosition:R,closeButtonSize:D,closeButtonBorderRadius:_,closeButtonBorderWidth:j,closeButtonBorderColor:W,closeButtonColor:V,closeButtonBackgroundColor:H,buttonsAlign:M,buttonsBorderWidth:F,buttonsBorderColor:q,buttonsBorderRadius:U,buttonsBackgroundColor:K,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:G,buttonsFontSize:J,secondLink:X,secondLinkBorderWidth:Q,secondLinkBorderColor:Z,secondLinkBorderRadius:ee,secondLinkBackgroundColor:te,secondLinkTextColor:ne,secondLinkFontName:ie,secondLinkFontStyle:re,secondLinkFontSize:oe,animation:se,animationDuration:ae,animationBehaviour:ce,animationSlideDirection:le}=i?{}:n,he=document.createElement("style");e()&&he.setAttribute("abtasty-script-added","true"),this.loadFont(v,f),this.loadFont(T,S),this.loadFont(Y,G),this.loadFont(ie,re);const de=`background: ${["string"==typeof o?o:"rgba(255, 255, 255, 1)",s&&"string"==typeof a&&a.length?`url(${a})`:"",s&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",s&&"string"==typeof c?`/ ${c}`:"/ auto",s&&h&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,ue="number"==typeof g&&g>0,ge=`border: ${[ue?`${g}px`:"unset",ue?"solid":"",ue&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,me=void 0!==u?`border-radius: ${u}px;`:"",pe=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",ve=void 0!==p?`text-align: ${p};`:"",fe=v&&"inherit"!==v?`font-family:${v}_${f.match(O)?f.match(O)[1]:""};`:f||"",ye=y?`font-size: ${y}px;`:"",be=void 0!==A&&A?`box-shadow: 0 5px ${I}px 0 ${P};`:"",we=B instanceof Array&&1===B.length&&B[0],Ee=we?`margin: ${we.top}px ${we.right}px ${we.bottom}px ${we.left}px;`:"",Te=we?`margin: calc(${we.top}px * 0.5) calc(${we.right}px * 0.5) calc(${we.bottom}px * 0.5) calc(${we.left}px * 0.5);`:"",$e=L instanceof Array&&1===L.length&&L[0],Se=$e?`padding: ${$e.top}px ${$e.right}px ${$e.bottom}px ${$e.left}px;`:"",Ce=$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);`:"",xe=void 0!==F&&F?`border-width: ${F}px; border-style: solid;`:"",ke=[q,F].every(e=>void 0!==e)&&F?`border-color: ${q};`:"",Ae=void 0!==U?`border-radius: ${U}px;`:"",Pe=void 0!==K?`background-color: ${K};`:"",Ie=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",Be=Y&&"inherit"!==Y?`font-family:${Y}_${G.match(O)?G.match(O)[1]:""};`:G||"",Le=J?`font-size: ${J}px;`:"",Ne="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Re=[Z,Q].every(e=>void 0!==e)&&Q?`border-color: ${Z};`:"",Oe=void 0!==ee?`border-radius: ${ee}px;`:"",De=void 0!==te?`background-color: ${te};`:"",_e=void 0!==ne?`color: ${ne}; fill: ${ne}; -webkit-text-fill-color: ${ne};`:"",je=ie&&"inherit"!==ie?`font-family:${ie}_${re.match(O)?re.match(O)[1]:""};`:re||"",We=oe?`font-size: ${oe}px;`:"",Ve="popin"!==r||void 0!==x&&!0!==x?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==k?k:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),He="number"==typeof D?D:16,Me=He/2,Fe=i||void 0!==N&&N?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${Me}px)`:`top: ${Me}px`)+";",`right: ${Me}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 j&&j>0?`border: ${j}px solid ${void 0!==W?W:"rgba(57, 57, 57, 1)"};`:"","string"==typeof H?`background-color: ${H};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${He}px;`,`height: ${He}px;`,"string"==typeof V?`fill: ${V};`:"","}"].join(""):"",qe=b&&"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};`:"",T&&"inherit"!==T?`font-family:${T}_${S.match(O)?S.match(O)[1]:""};`:S||"",C?`font-size: ${C}px;`:"","}"].join(""):"";let Ue="";if("string"==typeof se){const t=(ae/1e3).toFixed(2),n=["top","bottom"].includes(le),i=Number(n),r=[(["top","left"].includes(le)?"-":"")+"100vmax",this.translateValues?this.translateValues[i]:"0"];n&&r.reverse(),Ue={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} {`,"transition: unset;","}","}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ce};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${r.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ce};`,"}","@media (prefers-reduced-motion: reduce) {",`#${this.widgetContainerId} .${this.overlayClassName},`,`.${this.hideClassName} .${this.contentClassName},`,`#${this.widgetContainerId} .${this.contentClassName} {`,"transition: unset;","}","}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":se].join("")}const Ke=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===M?"top":"left"}: 8px;`,Ne,Re,Oe,De,_e,je,We,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,_e,je,We,"}"];return he.textContent=[`#${this.widgetContainerId} style { display: none; }`,`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,me,ge,pe,ve,be,Ee,fe,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,pe,ve,fe,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Se,fe,ye,"}",`#${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;",xe,ke,Ae,Pe,Ie,Be,Le,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *:not(.second_link span), `,`#${this.widgetContainerId} .${this.contentClassName} button:not([class*="close_button"], [class*="csatEmojiButton"]) * {`,Ie,Be,Le,"}",...X?Ke:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,Te,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Ce,"}","}",Ve,Fe,qe,Ue,`${t}`].join(""),he}}function j(e){return j="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},j(e)}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return V(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?V(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function H(e){var t=function(e){if("object"!=j(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==j(t)?t:t+""}function M(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(M=function(){return!!e})()}function F(e){return F=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},F(e)}function q(e,t){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},q(e,t)}var U={top:{top:0,left:50,translateX:-50,translateY:-100,translateOpenX:-50,translateOpenY:0},bottom:{top:100,left:50,translateX:-50,translateY:0,translateOpenX:-50,translateOpenY:-100},left:{top:50,left:0,translateX:-100,translateY:-50,translateOpenX:0,translateOpenY:-50},right:{top:50,right:0,translateX:100,translateY:-50,translateOpenX:0,translateOpenY:-50}},K={top:[!1,!1,!0,!0],bottom:[!0,!0,!1,!1],left:[!1,!0,!0,!1],right:[!0,!1,!1,!0]},z=function(t){function n(){var e,t,i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(t=this,i=n,i=F(i),e=function(e,t){if(t&&("object"==j(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,M()?Reflect.construct(i,[],F(t).constructor):i.apply(t,undefined))).button=e.setButton(),e.stringStyles=e.getStyles(),e.styleElement=e.getStyleTag(e.stringStyles),e.open=!1,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&q(e,t)}(n,t),i=n,r=[{key:"toggleDrawer",value:function(){this.open=this.domElement.classList.toggle("drawer_open")}},{key:"setButton",value:function(){var t=DATA,n=t.mainButtonText,i=t.hasMainButtonIcon,r=t.mainButtonIcon,o=t.mainButtonIconAlt,s=document.createElement("button");return s.className="drawer_button_".concat(this.uniqueId),e()&&(s.dataset.abtastyActionnable="true"),s.innerHTML="<span>".concat(n,"</span>").concat(i?'<img src="'.concat(r,'" alt="').concat(o,'">'):""),e()&&top.document.documentElement.classList.contains("widget-react-form-opened")&&this.domElement.classList.add("drawer_open"),s.addEventListener("click",this.toggleDrawer.bind(this),!0),this.domElement.insertAdjacentElement("beforeend",s),s}},{key:"getStyles",value:function(){var e=DATA,t=e.buttonLayout,n=e.customTarget,i=e.elementReferrer,r=e.zindex,o=e.zindexCustom,s=e.styckyButtonBackgroundColor,a=e.styckyButtonIsBackgroundImage,c=e.styckyButtonBackgroundImage,l=e.styckyButtonBackgroundPosition,h=e.styckyButtonBackgroundRepeat,d=e.styckyButtonBackgroundSize,u=e.styckyButtonButtonsAlign,g=e.styckyButtonContainerMargin,m=e.styckyButtonContainerPadding,p=e.styckyButtonButtonsBorderWidth,v=e.styckyButtonButtonsBorderColor,f=e.styckyButtonButtonsBorderRadius,y=e.styckyButtonDropShadow,b=e.styckyButtonDropShadowBlur,w=e.styckyButtonDropShadowColor,E=e.styckyButtonTitleFontName,T=e.styckyButtonTitleFontStyle,S=e.styckyButtonTitleFontSize,C=e.styckyButtonTitleTextAlign,x=e.styckyButtonTitleTextColor,k=e.autoWidth,A=e.drawerLayout,P=e.hasMainButtonIcon,I=e.animationDuration,B=e.animationBehaviour,L=U[t],N=L.top,R=L.left,O=L.right,D=L.translateX,_=L.translateY,j=L.translateOpenX,V=L.translateOpenY,H=["left","right"].includes(t),M=W(g,1)[0],F=M.top,q=M.bottom,z=M.left,Y=M.right,G=W(m,1)[0],J=G.top,X=G.bottom,Q=G.left,Z=G.right,ee=K[t].map(function(e){return e?"".concat(f,"px"):"0"}).join(" "),te=[s,a&&c.length?"url(".concat(c,")"):"",a&&"100% 100%"!==d?l:"0 0",a&&"string"==typeof d?"/ ".concat(d):"/ auto",a&&h&&!["cover","100% 100%"].includes(d)?"repeat":"no-repeat"],ne="background: ".concat(te.join(" ").trim()," !important;"),ie=y?"box-shadow: 0 5px ".concat(b,"px 0 ").concat(w,";"):"",re="border: ".concat(p>0?"".concat(p,"px solid ").concat(v):"unset",";"),oe=/.+\/([^.]+)\.(otf|ttf)$/;this.loadFont(E,T);var se=["color: ".concat(x,"; fill: ").concat(x,"; -webkit-text-fill-color: ").concat(x,";"),"text-align: ".concat(C,";"),"inherit"!==E?"font-family:".concat(E,"_").concat(T.match(oe)?T.match(oe)[1]:"",";"):T||"",S?"font-size: ".concat(S,"px;"):""].join(""),ae={left:"start",center:"center",right:"end"}[C],ce=W((n?i:"body").split("[]"),3),le=ce[0],he=ce[1],de=ce[2],ue=null!=de?de:le,ge="shadowRoot"===he?":host":"".concat(ue.trimEnd(),":not(:has(.fixed-drawer))"),me=n?["".concat(ge," {"),"overflow-".concat(H?"x":"y",": hidden;"),"}"].join(""):"";return["".concat(ue," {"),"position: relative;","}",me,"#".concat(this.widgetContainerId," {"),"position: absolute;","top: ".concat(N,"%;"),"number"==typeof R?"left: ".concat(R,"%;"):"","number"==typeof O?"right: ".concat(O,"%;"):"","transform: translate(".concat(D,"%, ").concat(_,"%);"),"transition: transform ".concat((I/1e3).toFixed(2),"s ").concat(B,";"),"margin: 0;","padding: 0;","background: none;","z-index: ".concat("custom"===r?o:r,";"),function(){if(k)return n?"width: auto; height: auto; max-width: calc(100% - ".concat("".concat(H?Q+Z+1.5*S:J+X+1.5*S,"px"),");"):"width: auto; height: auto; min-width: 30vw; max-width: ".concat(["left","right"].includes(A)?"80vw":"40vw",";");var e=DATA,t=e.popinPercentWidth,i=e.popinPixelsWidth,r=e.widthUnit,o=e.autoHeight,s=e.popinPercentHeight,a=e.popinPixelsHeight,c=e.heightUnit,l="px"===c?a:s;return"width: ".concat("px"===r?i:t).concat(r,";height: ").concat(o?"auto":"".concat(l).concat(c),";")}(),"}","@media (prefers-reduced-motion: reduce) {","#".concat(this.widgetContainerId," {"),"transition: unset;","}","}","#".concat(this.widgetContainerId,".fixed-drawer {"),"position: fixed;","}","#".concat(this.widgetContainerId," .").concat(this.contentClassName," {"),"position: relative;","width: 100%;","height: 100%;","box-sizing: border-box;","}","#".concat(this.widgetContainerId,".drawer_open {"),"transform: translate(".concat(j,"%, ").concat(V,"%);"),"}",".".concat(this.button.className," {"),"position: absolute;","".concat(t,": 100%;"),["top","bottom"].includes(t)?["".concat("right"===u?"right":"left",": ").concat(["left","right"].includes(u)?"0":"50%",";"),"transform: translate(".concat(["left","right"].includes(u)?"0":"-50%",", 0);"),"width: ".concat("fill"===u?"100%":"auto",";")].join(""):"",H?["".concat("right"===u?"bottom":"top",": ").concat(["center","fill"].includes(u)?"50%":"0",";"),"transform: translate(0, ".concat(["left","right"].includes(u)?"0":"-50%",");"),"height: ".concat("fill"===u?"100%":"auto",";")].join(""):"","margin: ".concat(F,"px ").concat(Y,"px ").concat(q,"px ").concat(z,"px;"),"padding: ".concat(J,"px ").concat(Z,"px ").concat(X,"px ").concat(Q,"px;"),"text-wrap: nowrap;",ne,re,"border-radius: ".concat(ee,";"),"display: flex;","flex-direction: ".concat(H?"column":"row",";"),"align-items: center;","justify-content: ".concat(ae,";"),ie,"}",".".concat(this.button.className," span {"),H?["writing-mode: vertical-rl;","text-orientation: sideways;"].join(""):"","right"===t?"transform: rotate(180deg);":"","width: auto;",se,"}",P?[".".concat(this.button.className," img {"),H?"transform: rotate(".concat(t.includes("right")?"-":"","90deg);"):"","min-width: ".concat(2*S,"px;"),"max-height: ".concat(2*S,"px;"),"margin-".concat(H?"top":"left",": ").concat(S,"px"),"}"].join(""):"","@media screen and (max-width: 579px) {","#".concat(this.widgetContainerId," .").concat(this.contentClassName," {"),k?"min-width: 40vw; max-width: 60vw;":"","}","}"].join("")}}],r&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,H(i.key),i)}}(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,r}(_);function Y(e){return Y="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},Y(e)}function G(e){var t=function(e){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Y(t)?t:t+""}var J=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.className="drawer_container_".concat(n.uniqueId),this.domElement=this.getElement()},n=[{key:"insertIn",value:function(e,t){this.setStyles(),e.insertAdjacentElement(t,this.domElement)}},{key:"addRedirectionEvent",value:function(t){var n=this;!e()&&t&&t.addEventListener("click",function(){var t=DATA,i=t.autoHide,r=t.timeHide;i&&setTimeout(function(){n.parentContainer.hide(),n.remove()},1e3*r),e()||n.parentContainer.recurrence.setValidationRecurrence()},{capture:!0,passive:!0})}},{key:"addCloseEvent",value:function(t){var n=this;t&&t.addEventListener("click",function(t){y(t),e()||n.parentContainer.recurrence.setClosingRecurrence(),n.parentContainer.hide(),setTimeout(function(){return n.parentContainer.remove()},1e3)},{capture:!0,passive:!1})}},{key:"buttonBuilder",value:function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=document.createElement("a");return o.ariaLabel=e,o.innerHTML="<span>".concat(e,"</span>"),o.href="button"===t?n:"#",r&&(o.className="second_link"),"button"===t?(o.target=i?"_blank":"_self",this.addRedirectionEvent(o)):(o.dataset.abtastyActionnable="true",this.addCloseEvent(o)),o}},{key:"getButtons",value:function(){var e=DATA,t=e.linkType,n=e.buttonText,i=e.redirectionUrl,r=e.openInNewTab,o=e.secondLink,s=e.secondLinkText,a=e.secondLinkType,c=e.secondLinkURL,l=e.secondLinkOpenInNewTab,h=[this.buttonBuilder(n,t,i,r)];if(o){var d=this.buttonBuilder(s,a,c,l,o);h.push(d)}return h}},{key:"getElement",value:function(){var e=DATA,t=e.linkType,n=e.buttonText,i=e.redirectionUrl,r=e.isTitle,o=e.title,s=e.textContent,a=e.openInNewTab,c=e.drawerLayout,l=e.drawerImage,h=e.altDesc,d=document.createElement(t&&t.includes("widget")?"a":"div");d.className=this.className,"widget"===t?(d.href=i,d.target=a?"_blank":"_self",this.addRedirectionEvent(d)):"widgetClose"===t&&(d.href="#",d.dataset.abtastyActionnable="true",this.addCloseEvent(d)),d.innerHTML="".concat("textOnly"!==c?'<img src="'.concat(l,'" ').concat("string"==typeof h?'alt="'.concat(h,'"'):"",">"):"");var u=document.createElement("div");if(u.className="drawer_text_container","imageOnly"!==c&&(u.innerHTML="\n\t\t\t".concat(r?'<h2 class="drawer_title">'.concat(o,"</h2>"):"",'\n\t\t\t<p class="drawer_text">').concat(s,"</p>")),[t,n].every(function(e){return"string"==typeof e})&&t.includes("button")&&n.length){var g=this.getButtons(),m=document.createElement("div");m.className="buttons_container",g.forEach(function(e){return m.appendChild(e)}),u.appendChild(m)}return d.appendChild(u),d}},{key:"setStyles",value:function(){var e=this.parentContainer,t=e.styleElement,n=e.widgetContainerId,i=e.contentClassName,r=DATA,o=r.linkType,s=r.buttonsAlign,a=r.drawerLayout,c="#".concat(n," .").concat(i),l="".concat(["left","right"].includes(a)?"row":"column").concat(["right","bottom"].includes(a)?"-reverse":""),h=void 0!==s&&"fill"!==s?"text-align: ".concat(s,";"):"",d=["".concat(c," .buttons_container {"),"display: inline-block;","width: 100%;",h,"}","".concat(c," .buttons_container a {"),"margin: 25px 0 0 0;","padding: 10px 22px;","line-height: 1;","max-width: 100%;","width: ".concat("fill"===s?"100%":"auto",";"),"text-align: center;","}"].join(""),u=["".concat(c," .").concat(this.className," {"),"display: flex;","flex-direction: ".concat(l,";"),"justify-content: space-around;","align-items: center;","}",".".concat(this.className," > img {"),"max-width: 100%;","width: 100%;","height: auto;","}",["left","right"].includes(a)?["".concat(c," .").concat(this.className," > * {"),"max-width: 46%;","}"].join(""):"","".concat(c," .drawer_title {"),"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}","".concat(c," .drawer_text_container {"),"line-height: 0;","white-space: pre-line;","display: inline-block;","vertical-align: middle;","width: 100%;","margin: 2vh 0;","}","".concat(c," .drawer_text_container * {"),"line-height: 1;","}","".concat(c," .drawer_text_container p {"),"margin: 0;","}"];o&&o.includes("button")&&u.push(d);var g=u.join("");return t.insertAdjacentText("beforeend",g),t}}],n&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,G(i.key),i)}}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n}();!function(){l("Widget launch");var e=new z,t=e.domElement.querySelector(".".concat(e.contentClassName)),n=new J({parentContainer:e});e.children=n,n.insertIn(t,"beforeend"),e.init(!0).then(function(t){t.response&&(e.show(),(!0!==DATA.customTarget||u(DATA.elementReferrer).matches("body"))&&e.domElement.classList.add("fixed-drawer"))})}()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/drawer",
3
3
  "description": "Drawer widget",
4
- "version": "0.0.35",
4
+ "version": "0.0.36",
5
5
  "form": "dist/form.js",
6
6
  "main": "dist/main.js",
7
7
  "type": "module",