@abtasty/popin-video 1.4.18 → 1.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/main.js +1 -1
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"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]),o=()=>window.ABTasty&&!0===window.ABTasty.consentReady;function r(e,t){return t(e)||!e.parentElement?e:r(e.parentElement,t)}const a=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},c=(e,t)=>[...document.querySelectorAll(t)].some(i=>i===e||!!e.closest(t)),l=(e,t)=>{let i=Date.now();return()=>{i+t-Date.now()<=0&&(e(),i=Date.now())}},d=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},h=()=>{const e=d();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},u=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,p=i=>{const n=(()=>{if(e()||t())return!1;const i=ABTasty.getTestsOnPage()[TEST_ID];return!!i&&Object.keys(i.targetings.qaParameters).length>0})(),s=document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(n||s){const e=h();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;")}},m=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};class g{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=null,this.mouseOverEvent=this.mouseOverHandler(),this.scrollEvent=this.scrollEventHandler()}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.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){return this.mutationObserver??=new MutationObserver(this.checkElements.bind(this)),this.mutationObserver.observe(document.querySelector("body"),{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=[...e.querySelectorAll(n)];if(s.length&&s.includes(i))return!0;if(t.includes(i))return!0;const o=[...e.parentElement.children],r=o.findIndex(t=>t.isSameNode(e)),a=o.filter((e,t)=>t>r);if(a.length){if(a.includes(i))return!0;if(a.some(e=>[...e.querySelectorAll(n)].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){return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}mouseOverHandler(){const 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(e)}scrollEventHandler(){const e=["scroll",l(this.checkElements.bind(this),50),{passive:!0}];return this.getEvents(e)}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===r(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=document.elementFromPoint(...i[s]);n=e===t||e.contains(t),s+=1}return n}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const i=document.querySelector(e);i&&!this.existingTargets.find(i=>i.element.matches(e)&&i.uniqueId===t)&&(this.existingTargets.push({element:i,selector:e,uniqueId:t}),this.visibilityObserver.observe(i))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:i})=>{if(t.matches(e)&&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})}watch(e,t,i){this.targets.push({selector:e,resolve:t,uniqueId:i}),this.startMutationObserver(),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=document.querySelector(e);i&&this.visibilityObserver.unobserve(i),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&(this.mouseOverEvent.clear(),this.scrollEvent.clear())}}const v="remove",y="rebuild",b="update";class w{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:i,triggerTarget:n}){this.event=e,this.selector=t&&t.length?t:"body",this.target=n,this.delay=1e3*i,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={}}async onElementVisible({promise:e,resolve:t}){const i=m(`${this.event}DomReady`);this.promises.push(i);const n=await this.onPageLoad(i),s=await async function(){let e;return e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||new Promise((e,t)=>{const i=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");n.src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver",i.parentNode.insertBefore(n,i),n.onload=e,n.onerror=t})),e}(),o=new g;if(this.visibilityObservers.push(o),s&&n){const e=u();o.watch(this.selector,t,e)}return 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=document.createElement("style");i.type="text/css",i.id=`Click_${u()}`,i.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(i),this.elementsSelectors.push(`#${i.id}`);const n=["click",({isTrusted:e,target:i})=>{const n=i.isEqualNode(this.target)||c(i,this.selector);return e&&n&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}onHover({promise:e,resolve:t}){const i=["mouseenter",({isTrusted:e,target:i})=>{const n=this.target?i.isEqualNode(this.target):c(i,this.selector);return e&&n&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document.documentElement,...i]),document.documentElement.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const i=document.body,n=["mouseleave",({isTrusted:e,clientY:i})=>{e&&i<=0&&t(!0)},{passive:!0}];return this.eventsListeners.push([i,...n]),i.addEventListener(...n),e}onReengage({promise:e,resolve:t}){const i=this.delay;let n=i;const s=[({isTrusted:e})=>{e&&(n=i)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{this.eventsListeners.push([document,e,...s]),document.addEventListener(e,...s)});const o=setInterval(()=>{n<=0?t(!0):n-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:i}=DATA;return new Function(`return new Promise(async resolve => {${i}})`)().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let i=0;const n=["scroll",({isTrusted:e})=>{e&&(window.pageYOffset<i?t(!0):i=window.pageYOffset)},{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&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:o,spNoTrim:r}=DATA;if(this.socialProofStore.hasOwnProperty(e))i(this.socialProofStore[e])?n(`${this.socialProofStore[e][o]}`):n(!1);else if(e&&s){const a=t=>(this.socialProofStore[e]=t,n(!!i(t)&&`${t[o]}`));fetch(`https://api-social-proof.abtasty.com/clients/${s}/metrics/${t}?key=${e}${r?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>p("Failed to fetch datas from server."))}else n(!1)}getSocialProofDatas({promise:e,resolve:t},s,o=!1){const{productKey:r,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:s,customJSProductKey:o,productSKU:r}=DATA;if(2===e)return{productKey:n(),keyType:"url"};{let a=null,c="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a=i(`return ${s};`);break;case"customJSProductKey":a=i(o);break;case"productSKU":a=r}return a||3!==e||(a=n(),c="url"),{productKey:a,keyType:c}}})(),{viewInterval:c,triggerSocialProofMinVisitors:l,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:h}=DATA,u={pv:h,i:d,"v-pv":l}[s];return[typeof c,typeof u].includes("undefined")&&t(!1),o&&!r&&(p("Not able to find ABTastyProductKey, impossible to call the API, read documentation for more informations:\n\t\t\t\thttps://support.abtasty.com/hc/en-us/articles/4710919241628-Widgets-List#h_84c04344-c655-4e5e-b9ab-d26a798ad9b0"),t(!1)),this.checkSocialProofConditions(r,"v-pv"===s&&"sku"===a?"v-i":s,e=>{const t=void 0!==e[c]&&e[c]>=u;return t||p(`Widget will not be shown, Social Proof API returned ${e[c]} while ${u} are required`),t},t),e}onConsent({promise:e,resolve:t}){if(!o()){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("ABTastyData");const s=()=>JSON.parse(n).ActionTracking.find(({name:e})=>e===i),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:i}=DATA;let n=localStorage.getItem("ABTastyData");const s=()=>i<=(n?JSON.parse(n).VisitedPages.length:0),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:i,triggerEventRageClickDelay:n}=DATA;let s=0,o=!1;const r=["click",({isTrusted:e})=>{if(e&&(s+=1,s>=i&&t(!0),!o)){o=!0;const e=setTimeout(()=>{s=0,o=!1},n);this.timeouts.push(e)}},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...i]=e;t&&i.length>1&&t.removeEventListener(...i)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.visibilityObservers.length){const e=u();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this}async isTriggered(){this.clear();const e=m(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=m(`${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 f="display",$="closing",T="validation",C="ABTastyWidgets",S=`${C}Temporary`;class A{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=d(),this.uniqueId=u(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(S),i=sessionStorage.getItem(C);"ABTastyData"===e&&!t&&i&&localStorage.setItem(S,i)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(C);return JSON.parse(t)}catch(t){return e.removeItem(C),!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(C,JSON.stringify(n)),n):(e.removeItem(C),!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(S),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(C,e),localStorage.removeItem(S));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:r}=n,a=this.getStamp(e),c={type:i,stamp:a},{type:l}=this.getCurrentRecurrence(),d=async()=>{if(!o()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new w({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};r.setItem(C,JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(l&&i!==T)if(i===$&&l!==T)d();else{if(i!==f||l===T||l===$)return!1;d()}else d();return a}setDisplayRecurrence(){const e=f;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=$;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=T;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 E{constructor(e,t,i){this.isWidgetApplied=e,this.callback=t,this.shouldUpdate=i,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(){const e=this.isWidgetApplied()?this.shouldUpdate&&b:y;return e?(this.clearWatcher(),this.callback(e,!0),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(y,!1),this.watch())}onTagRollback(){return this.clearWatcher(),this.callback(v,!1),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(v,!1)}watch(){return e()||(this.clearWatcher(),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams),this.observer.observe(document.querySelector("body"),{childList:!0,subtree:!0})),this}clearWatcher(){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this}}const _=/.+\/([^.]+)\.(otf|ttf)$/,x=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class P{constructor(t,i){this.children=void 0,this.uniqueId=`${u()}${i?`_${i}`:""}`,this.widgetName=d(),this.prettyName=h(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:i,validationRecurrence:n}=DATA,s=!t&&!i&&!n;if(e()||s)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`]},r={};return t&&(r.displayRecurrence=o[t]("displayRecurrence")),i&&(r.closingRecurrence=o[i]("closingRecurrence")),n&&(r.validationRecurrence=o[n]("validationRecurrence")),r})(),this.triggerParams=(t=>{let{triggerEvent:i}=DATA;const{triggerEventClick:n,triggerEventHover:s,triggerEventReengageDelay:o,socialProofContentType:r,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!i&&!r)return!1;const l={click:()=>n,hover:()=>s,elementVisible:()=>a},d=Object.prototype.hasOwnProperty.call(l,i)?l[i]():"body",h="reengage"===i?o:c;return r&&(i=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][r]),{triggerEvent:i,triggerSelector:d,triggerDelay:h,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new A(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new w(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&x.includes(this.triggerParams.triggerEvent),this.pageWatcher=new E(this.isWidgetApplied.bind(this),this.onPageChange.bind(this),this.shouldUpdate),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.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[],this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[],this.intervals.forEach(e=>clearInterval(e)),this.intervals=[],this.observers.forEach(e=>e.disconnect()),this.observers=[],this.promises.forEach(e=>e.resolve(!1)),this.promises=[],this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){if(this.isWidgetApplied())return!1;document.head.appendChild(this.styleElement);const e=["free"];return"drawer"===DATA.layout&&DATA.customTarget&&e.push("drawer"),new Promise(t=>{const{elementReferrer:i="body",referrerInsertType:n="beforeend"}=e.includes(DATA.layout)?DATA:{},s=((e,t)=>{const i=()=>{try{return document.querySelector(e)}catch(e){return null}};let n=i();const s=[document.querySelector("body")||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],o=()=>a.disconnect(),r=()=>a.observe(...s),a=new MutationObserver(()=>(n=i(),n&&!o()&&t(n)));return n?setTimeout(()=>t(n),0):r(),{selector:e,clear:o,observe:r}})(i,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==i),this.removeOldDomElement(),t(e.insertAdjacentElement(n,this.domElement))});this.elementsWaiters.push(s)}).then(()=>this)}remove(){return this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(e=>e&&e.isConnected&&e.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const i=e(),n=s(),o=this.trigger&&this.trigger.promises.length,r=!this.recurrence||this.recurrence.isOver();if(!i&&!n||o||!r)return{container:this,response:!1};this.pageWatcher.watch();const a=i||!this.trigger||this.trigger&&await this.trigger.isTriggered(),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){const i=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,this.trigger&&this.trigger.clear());const n=this.isWidgetApplied(),s={[v]:()=>n?this.remove():this.pageWatcher.watch(),[y]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[b]:i};"function"==typeof s[e]&&s[e]()}addCloseEvent(...t){const{closeButton:i,overlay:n,overlayClickable:s,layout:o,animationDuration:r=1e3}=DATA,c=[];if(void 0!==n&&!0!==n||!0!==s||"popin"!==o||c.push(`.${this.overlayClassName}`),void 0!==i&&i&&c.push(`.${this.closeButtonClassName}`),!c.length)return this;const l=this.domElement.querySelectorAll(c.join(", "));if(!l.length)return this;const d=["click",e=>{a(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*r)},{once:!0,capture:!0}];return t.push(...l),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.removeEventListener(...d),t.addEventListener(...d)}),this}getDom(){const{closeButton:e,layout:t,overlay:i=!0}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.role="dialog",n.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}" aria-label="Dialog content">\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>`,n}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const i=document.createElement("style"),n=t.match(_)?t.match(_)[1]:"";i.innerHTML=`@font-face { font-family: '${e}_${n}'; src: url('${t}'); font-display: swap; }`,document.head.appendChild(i)}getStyleTag(t="",i=DATA){const{noStyles:n,layout:s}=i,{backgroundColor:o,isBackgroundImage:r,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:d,borderColor:h,borderRadius:u,borderWidth:p,textColor:m,textAlign:g,fontName:v,fontStyle:y,fontSize:b,isTitle:w,titleTextAlign:f,titleTextColor:$,titleFontName:T,titleFontStyle:C,titleFontSize:S,overlay:A,overlayColor:E,dropShadow:x,dropShadowColor:P,dropShadowBlur:k,containerMargin:I,containerPadding:D,closeButton:L,closeButtonPosition:R,closeButtonSize:N,closeButtonBorderRadius:O,closeButtonBorderWidth:B,closeButtonBorderColor:V,closeButtonColor:j,closeButtonBackgroundColor:q,buttonsAlign:W,buttonsBorderWidth:M,buttonsBorderColor:H,buttonsBorderRadius:F,buttonsBackgroundColor:U,buttonsTextColor:K,buttonsFontName:z,buttonsFontStyle:Y,buttonsFontSize:G,secondLink:J,secondLinkBorderWidth:Q,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:ee,secondLinkTextColor:te,secondLinkFontName:ie,secondLinkFontStyle:ne,secondLinkFontSize:se,animation:oe,animationDuration:re,animationBehaviour:ae,animationSlideDirection:ce}=n?{}:i,le=document.createElement("style");le.type="text/css",e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(T,C),this.loadFont(z,Y),this.loadFont(ie,ne);const de=`background: ${["string"==typeof o?o:"rgba(255, 255, 255, 1)",r&&"string"==typeof a&&a.length?`url(${a})`:"",r&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",r&&"string"==typeof c?`/ ${c}`:"/ auto",r&&d&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,he="number"==typeof p&&p>0,ue=`border: ${[he?`${p}px`:"unset",he?"solid":"",he&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,pe=void 0!==u?`border-radius: ${u}px;`:"",me=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",ge=void 0!==g?`text-align: ${g};`:"",ve=v&&"inherit"!==v?`font-family:${v}_${y.match(_)?y.match(_)[1]:""};`:y||"",ye=b?`font-size: ${b}px;`:"",be=void 0!==x&&x?`box-shadow: 0 5px ${k}px 0 ${P};`:"",we=I instanceof Array&&1===I.length&&I[0],fe=we?`margin: ${we.top}px ${we.right}px ${we.bottom}px ${we.left}px;`:"",$e=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);`:"",Te=D instanceof Array&&1===D.length&&D[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);`:"",Ae=void 0!==M&&M?`border-width: ${M}px; border-style: solid;`:"",Ee=[H,M].every(e=>void 0!==e)&&M?`border-color: ${H};`:"",_e=void 0!==F?`border-radius: ${F}px;`:"",xe=void 0!==U?`background-color: ${U};`:"",Pe=void 0!==K?`color: ${K}; fill: ${K}; -webkit-text-fill-color: ${K};`:"",ke=z&&"inherit"!==z?`font-family:${z}_${Y.match(_)?Y.match(_)[1]:""};`:Y||"",Ie=G?`font-size: ${G}px;`:"",De="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Le=[X,Q].every(e=>void 0!==e)&&Q?`border-color: ${X};`:"",Re=void 0!==Z?`border-radius: ${Z}px;`:"",Ne=void 0!==ee?`background-color: ${ee};`:"",Oe=void 0!==te?`color: ${te}; fill: ${te}; -webkit-text-fill-color: ${te};`:"",Be=ie&&"inherit"!==ie?`font-family:${ie}_${ne.match(_)?ne.match(_)[1]:""};`:ne||"",Ve=se?`font-size: ${se}px;`:"",je="popin"!==s||void 0!==A&&!0!==A?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==E?E:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),qe="number"==typeof N?N:16,We=qe/2,Me=n||void 0!==L&&L?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===R?`bottom: calc(100% + ${We}px)`:`top: ${We}px`)+";",`right: ${We}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 B&&B>0?`border: ${B}px solid ${void 0!==V?V:"rgba(57, 57, 57, 1)"};`:"","string"==typeof q?`background-color: ${q};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${qe}px;`,`height: ${qe}px;`,"string"==typeof j?`fill: ${j};`:"","}"].join(""):"",He=w&&"string"==typeof $?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${$}; fill: ${$}; -webkit-text-fill-color: ${$};`,void 0!==f?`text-align: ${f};`:"",T&&"inherit"!==T?`font-family:${T}_${C.match(_)?C.match(_)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Fe="";if("string"==typeof oe){const t=(re/1e3).toFixed(2),i=["top","bottom"].includes(ce),n=Number(i),s=[(["top","left"].includes(ce)?"-":"")+"100vmax",this.translateValues?this.translateValues[n]:"0"];i&&s.reverse(),Fe={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ae};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ae};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ae};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":oe].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===W?"top":"left"}: 8px;`,De,Le,Re,Ne,Oe,Be,Ve,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Oe,Be,Ve,"}"];return le.textContent=[`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,pe,ue,me,ge,be,fe,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,me,ge,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,ve,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;",Ae,Ee,_e,xe,Pe,ke,Ie,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,Pe,ke,Ie,"}",...J?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,$e,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",je,Me,He,Fe,`${t}`].join(""),le}}const k=["top: 0;","top: 50%;","bottom: 0;"],I=["left: 0;","left: 50%;","right: 0;"],D=e=>1===e?"-50%":0,L=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,i=`translate(${D(t)}, ${D(e)});`;return`${k[e]}${I[t]}transform: ${i}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},R=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,N=()=>{if(R())return"width: auto; height: auto; min-width: fit-content;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:i,autoHeight:n,popinPercentHeight:s,popinPixelsHeight:o,heightUnit:r}=DATA;return`width: ${"px"===i?t:e}${i};height: ${n?"auto":`${"px"===r?o:s}${r}`};`};class O extends P{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(e=>D(e)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t,widthUnit:i}=DATA,n="string"!=typeof DATA.overlay&&DATA.overlay;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"background: none;","pointer-events: "+(n?"all":"none"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",L(),N(),"pointer-events: all","}",`${R()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!R()&&["px","em"].includes(i)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}const B=["mp4","webm","ogg"],V=()=>B.some(e=>DATA.video.includes(e)),j=e=>e.replace("/","__").replace("?","__").replace("#","__").replace("&","__"),q=e=>(256|e).toString(16).slice(1);function W(e){const t=e.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i);return`${q(t[1])}${q(t[2])}${q(t[3])}`}const M="C71YkqN0pEA",H=["youtube.com","youtu.be"],F=()=>H.some(e=>DATA.video.includes(e)||""===DATA.video),U=(e,t)=>{if(window.YT&&"function"==typeof YT.Player){const i=(()=>{const{video:e}=DATA;if(""===e)return M;const t=["youtube.com/embed/","youtube.com/watch?v=","youtu.be/"].filter(t=>e.includes(t))[0],i=t?j(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]})(),n=(()=>{const{youtubeCCLoadPolicy:e,youtubeColor:t,youtubeControls:i,youtubeDisableKeyboard:n,youtubeEndTime:s,youtubeFullScreen:o,youtubeStartTime:r}=DATA,a={origin:location.origin,rel:0,color:t,controls:i?1:0,disablekb:n?0:1,fs:o?1:0};return e&&(a.cc_load_policy=1),s&&(a.end=s),r&&(a.start=r),a})(),s=(()=>{const{youtubeAutoPlay:e,youtubeLoop:t,youtubeMuted:i,youtubeStartTime:n}=DATA,s={};return(e||i)&&(s.onReady=t=>{i&&t.target.mute(),e&&t.target.playVideo()}),t&&(s.onStateChange=e=>{0===e.data&&(n&&e.target.seekTo(n),e.target.playVideo())}),s})(),o=new YT.Player(`popin_video_iframe_${e}`,{videoId:i,playerVars:n,events:s});return t(o)}return setTimeout(()=>U(e,t),100)};function K(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}const z=()=>DATA.video.includes("vimeo.com"),Y=(e,t)=>{if(window.Vimeo&&"function"==typeof Vimeo.Player){const{vimeoStartTime:i}=DATA,n=(()=>{const{video:e,vimeoAutoPlay:t,vimeoColor:i,vimeoLoop:n,vimeoMuted:s,vimeoInfos:o}=DATA;return{url:e,autoplay:t,byline:o,color:W(i),loop:n,muted:s,portrait:o,title:o}})(),s=new Vimeo.Player(`popin_video_iframe_${e}`,function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?K(Object(i),!0).forEach(function(t){var n,s,o,r;n=e,s=t,o=i[t],(s="symbol"==typeof(r=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(s))?r:String(r))in n?Object.defineProperty(n,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[s]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):K(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}({},n));return i&&s.setCurrentTime(i),t(s)}return setTimeout(()=>Y(e,t),100)},G=["dailymotion.com","dai.ly"],J=()=>G.some(e=>DATA.video.includes(e)),Q=()=>{const{video:e}=DATA,t=["/video/","dai.ly/"].filter(t=>e.includes(t))[0],i=t?j(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]},X=(e,t,i,n)=>{if(window.DM&&"function"==typeof DM.player){const s=(()=>{const{dailymotionAutoPlay:e,dailymotionMuted:t,dailymotionColor:i,dailymotionLogo:n}=DATA;return{autoplay:e,mute:t,logo:n,"ui-highlight":W(i)}})(),o=DM.player(t.querySelector(`#popin_video_iframe_${e}`),{video:Q(),params:s});return i(o),n(o)}return setTimeout(()=>X(e,t,n,i),100)},Z=()=>DATA.video.includes("tiktok.com"),ee=()=>{return e=`https://www.tiktok.com/oembed?url=${DATA.video}`,new Promise((t,i)=>{const n=new XMLHttpRequest;n.open("GET",e,!0),n.onload=function(){this.status>=200&&this.status<300?t(n.response):i({status:this.status,statusText:n.statusText})},n.onerror=function(){i({status:this.status,statusText:n.statusText})},n.send()});var e},te=()=>{const{linkType:e,buttonText:t}=DATA;return!!([e,t].every(e=>"string"==typeof e)&&e.includes("button")&&t.length)};class ie{constructor(e){let{parentContainer:t}=e;this.parentContainer=t,this.className=`popinvideo_container_${t.uniqueId}`,this.videoSource=DATA.video||`https://www.youtube.com/embed/${M}`,this.contentElement=this.getContentElement(),this.styleElement=this.getStyleElement()}remove(){const{animationDuration:e=1e3}=DATA;setTimeout(()=>this.parentContainer.remove(),1.05*e)}addCloseEvent(t){t&&t.addEventListener("click",t=>{a(t),e()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),this.remove()},{capture:!0,passive:!1})}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})}insertButtonsInContainer(e){const t=this.getButtons(),i=document.createElement("div");i.className="buttons_container",t.forEach(e=>i.appendChild(e)),e.appendChild(i)}getButtons(){var e=this;const t=function(t,i,n,s){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=document.createElement("a");return r.ariaLabel=t,o&&(r.className="second_link"),r.innerHTML=`<span>${t}</span>`,r.href="button"===i?n:"#","button"===i?(r.target=s?"_blank":"_self",e.addRedirectionEvent(r)):(r.dataset.abtastyActionnable="true",e.addCloseEvent(r)),r},{linkType:i,buttonText:n,redirectionUrl:s,openInNewTab:o,secondLink:r,secondLinkText:a,secondLinkType:c,secondLinkURL:l,secondLinkOpenInNewTab:d}=DATA,h=[t(n,i,s,o)];if(r){const e=t(a,c,l,d,r);h.push(e)}return h}getVideoContainer(){const e="popin_video_iframe",t=`${e}_${this.parentContainer.uniqueId}`,i=document.createElement("div");if(i.className="popin_video_container",V()){const{htmlPlayerAutoPlay:e,htmlPlayerMuted:t,htmlPlayerLoop:n,htmlPlayerControls:s}=DATA,o=B.filter(e=>this.videoSource.includes(`.${e}`))[0],r=document.createElement("video");r.innerHTML=`<source src="${this.videoSource}" type="video/${o}">`,e&&(r.setAttribute("playsinline",""),r.autoplay=!0),t&&(r.setAttribute("muted",""),r.muted=!0),n&&(r.loop=!0),s&&(r.controls=!0),i.appendChild(r)}else{DATA.video.includes("facebook.com")&&(this.videoSource=(()=>{const{video:e}=DATA;return e.includes("plugins/video.php")?e:`https://www.facebook.com/plugins/video.php?href=${e}&show_text=0`})());const n=`<iframe id="${t}" class="${e}" src="${this.videoSource}"></iframe>`;i.innerHTML=[F(),z(),J(),Z()].some(e=>e)?`<div id="${t}" class="${e}"></div>`:n}return i}setVideoOnlyContent(e,t){const i=this.getVideoContainer();return e.appendChild(i),e.classList.add(t),te()&&this.insertButtonsInContainer(e),e}setVideoAndTextContent(e,t){const{isTitle:i,title:n,textContent:s}=DATA,o=this.getVideoContainer(),r=document.createElement("div");return r.className="popin_text_container",r.innerHTML=`${i?`<h2 class="popin_video_title">${n}</h2>`:""}<p class="popin_video_text">${s}</p>`,e.classList.add(t),["leftVideo","topVideo"].some(e=>e===t)&&e.appendChild(o),e.appendChild(r),["rightVideo","bottomVideo"].some(e=>e===t)&&e.appendChild(o),te()&&this.insertButtonsInContainer(r),e}insertIn(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.contentElement),e}getContentElement(){const{contentLayout:e}=DATA,t=document.createElement("div");return t.className=this.className,{videoOnly:()=>this.setVideoOnlyContent(t,"onlyVideo"),left:()=>this.setVideoAndTextContent(t,"leftVideo"),right:()=>this.setVideoAndTextContent(t,"rightVideo"),top:()=>this.setVideoAndTextContent(t,"topVideo"),bottom:()=>this.setVideoAndTextContent(t,"bottomVideo")}[e](),t}getStyleElement(){const t=document.createElement("style");t.type="text/css",e()&&t.setAttribute("abtasty-script-added","true");const{textVideoRatio:i,borderRadius:n,borderWidth:s,containerPadding:o,contentLayout:r,linkType:a,buttonsAlign:c}=DATA,l=`#${this.parentContainer.widgetContainerId} .${this.parentContainer.contentClassName}`,d=o[0],h=parseInt(n-s,10),u=h-d.top>0?h-d.top:0,p=h-d.bottom>0?h-d.bottom:0,m=void 0!==c&&"fill"!==c?`text-align: ${c};`:"",g=[`${l} .onlyVideo .popin_video_container {`,`border-radius: ${u}px ${u}px ${p}px ${p}px;`,"}"].join(""),v=[`${l} .leftVideo .popin_video_container {`,`width: calc(${i}% - 2.5%);`,"}",`${l} .leftVideo .popin_text_container {`,`width: calc(100% - ${i}% - 2.5%);`,"position: relative;","margin: 0 2.5%;","}",`${l} .leftVideo .popin_video_container {`,`border-radius: ${u}px 0 0 ${p}px;`,"}"].join(""),y=[`${l} .rightVideo .popin_video_container {`,`width: calc(${i}% - 2.5%);`,"}",`${l} .rightVideo .popin_text_container {`,`width: calc(100% - ${i}% - 2.5%);`,"position: relative;","margin: 0 2.5%;","}",`${l} .rightVideo .popin_video_container {`,`border-radius: 0 ${u}px ${p}px 0;`,"}"].join(""),b=[`${l} .topVideo .popin_video_container {`,`border-radius: ${u}px ${u}px 0 0;`,"margin-bottom: 15px","}"].join(""),w=[`${l} .bottomVideo .popin_video_container {`,`border-radius: 0 0 ${p}px ${p}px;`,"margin-top: 15px;","}"].join(""),f=[`${l} .buttons_container {`,"display: inline-block;","width: 100%;",m,"}",`${l} .buttons_container a {`,"display: inline-block;","margin: 25px 0 0 0;","padding: 10px 22px;","max-width: 100%;",`width: ${"fill"===c?"100%":"auto"};`,"text-align: center;","}"].join(""),$=[`${l} .popin_video_container {`,"line-height: 0;","overflow: hidden;","width: 100%;","max-width: 100%;","}",`${l} .popin_video_title {`,"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}",`${l} .popin_video_container video,`,`${l} .popin_video_container .popin_video_iframe {`,"display: inline-block;","width: 100%;","height: 100%;","}",`${l} .popin_video_container .popin_video_iframe iframe {`,"display: inline-block;","width: 100%;","}",`${l} .popin_text_container {`,"line-height: 1;","white-space: pre-line;","}",`${l} .popin_text_container p {`,"margin: 0;","}",`${l} .popin_video_container,`,`${l} .popin_text_container {`,"display: inline-block;","vertical-align: middle;","}"];return(0,{videoOnly:()=>$.push(g),top:()=>$.push(b),bottom:()=>$.push(w),left:()=>$.push(v),right:()=>$.push(y)}[r])(),a&&$.push(f),t.textContent=$.join(""),t}}function ne(e){const t=e.querySelector(".popin_video_iframe"),i=parseInt(t.clientWidth/16*9,10)+1;t.style.height=`${i}px`}!function(){p("Widget launch");const e=u(),t=F(),i=z(),n=J(),s=Z();t&&(e=>{if(window.YT)return!1;const t=document.createElement("script");t.src="https://www.youtube.com/iframe_api",t.id=`video_popin_ytapi_${e}`,document.head.appendChild(t)})(e),i&&(e=>{if(window.Vimeo)return!1;const t=document.createElement("script");t.src="https://player.vimeo.com/api/player.js",t.id=`video_popin_vimeoapi_${e}`,document.head.appendChild(t)})(e),n&&(e=>{if(window.DM)return!1;const t=document.createElement("script");t.src="https://api.dmcdn.net/all.js",t.id=`video_popin_dailymotionapi_${e}`,document.head.appendChild(t)})(e);const o=new O,r=new ie({parentContainer:o}),a=r.contentElement.querySelector(".popin_video_container");s&&ee().then(t=>{const i=JSON.parse(t),n=a.querySelector(`#popin_video_iframe_${e}`);n.innerHTML=i.html,r.player=n,a.appendChild(r.player),(e=>{window.tiktokEmbed&&(window.tiktokEmbed=void 0);const t=document.createElement("script");t.src="https://www.tiktok.com/embed.js",t.id=`video_popin_tiktokapi_${e}`,t.async=!0,document.head.appendChild(t)})(e)});const c=o.domElement.querySelector(`.${o.contentClassName}`);o.children=r,r.insertIn(c,"beforeend"),o.init(!0).then(c=>{let{response:l}=c;if(l){const c=e=>{r.player=e,i||s||V()||(ne(r.contentElement),window.addEventListener("resize",()=>ne(r.contentElement),{capture:!0,passive:!0}))};t&&U(e,c),i&&Y(e,c),n&&X(e,r.contentElement,e=>{a.innerHTML="",a.appendChild(e)},c),r.player||c(a),o.show()}})}()}();
1
+ !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"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]),o=()=>window.ABTasty&&!0===window.ABTasty.consentReady,r=(e,t)=>{const i=()=>{try{return document.querySelector(e)}catch(e){return null}};let n=i();const s=[document.querySelector("body")||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],o=()=>a.disconnect(),r=()=>a.observe(...s),a=new MutationObserver(()=>(n=i(),n&&!o()&&t(n)));return n?setTimeout(()=>t(n),0):r(),{selector:e,clear:o,observe:r}};function a(e,t){return t(e)||!e.parentElement?e:a(e.parentElement,t)}const c=t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())},l=(e,t)=>[...document.querySelectorAll(t)].some(i=>i===e||!!e.closest(t)),d=(e,t)=>{let i=Date.now();return()=>{i+t-Date.now()<=0&&(e(),i=Date.now())}},h=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},u=()=>{const e=h();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},p=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,g=i=>{const n=(()=>{if(e()||t())return!1;const i=ABTasty.getTestsOnPage()[TEST_ID];return!!i&&Object.keys(i.targetings.qaParameters).length>0})(),s=document.cookie.includes("abTastyDebug=")||!0===window.abTastyDebug;if(n||s){const e=u();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;")}},m=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};class v{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=null,this.mouseOverEvent=this.mouseOverHandler(),this.scrollEvent=this.scrollEventHandler()}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.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),this.scrollEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){this.mutationObserver??=new MutationObserver(this.checkElements.bind(this));const{clear:e}=r("body",t=>{e(),this.mutationObserver.observe(t,{attributes:!0,childList:!0,subtree:!0})});return this.mutationObserver}onMouseOver({target:e,path:t}){const i=this.inViewportTargets.find(({element:i,selector:n})=>{if(i.isSameNode(e))return!0;const s=[...e.querySelectorAll(n)];if(s.length&&s.includes(i))return!0;if(t.includes(i))return!0;const o=[...e.parentElement.children],r=o.findIndex(t=>t.isSameNode(e)),a=o.filter((e,t)=>t>r);if(a.length){if(a.includes(i))return!0;if(a.some(e=>[...e.querySelectorAll(n)].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){return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}mouseOverHandler(){const 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(e)}scrollEventHandler(){const e=["scroll",d(this.checkElements.bind(this),50),{passive:!0}];return this.getEvents(e)}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===a(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=document.elementFromPoint(...i[s]);n=e===t||e.contains(t),s+=1}return n}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const i=document.querySelector(e);i&&!this.existingTargets.find(i=>i.element.matches(e)&&i.uniqueId===t)&&(this.existingTargets.push({element:i,selector:e,uniqueId:t}),this.visibilityObserver.observe(i))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(t&&this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:i})=>{if(t.matches(e)&&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})}watch(e,t,i){this.targets.push({selector:e,resolve:t,uniqueId:i}),this.startMutationObserver(),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=document.querySelector(e);i&&this.visibilityObserver.unobserve(i),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&(this.mouseOverEvent.clear(),this.scrollEvent.clear())}}const y="remove",b="rebuild",w="update";class f{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:i,triggerTarget:n}){this.event=e,this.selector=t&&t.length?t:"body",this.target=n,this.delay=1e3*i,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.promises=[],this.visibilityObservers=[],this.socialProofStore={}}async onElementVisible({promise:e,resolve:t}){const i=m(`${this.event}DomReady`);this.promises.push(i);const n=await this.onPageLoad(i),s=await async function(){let e;return e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||new Promise((e,t)=>{const i=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");n.src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver",i.parentNode.insertBefore(n,i),n.onload=e,n.onerror=t})),e}(),o=new v;if(this.visibilityObservers.push(o),s&&n){const e=p();o.watch(this.selector,t,e)}return 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=document.createElement("style");i.type="text/css",i.id=`Click_${p()}`,i.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(i),this.elementsSelectors.push(`#${i.id}`);const n=["click",({isTrusted:e,target:i})=>{const n=i.isEqualNode(this.target)||l(i,this.selector);return e&&n&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...n]),document.addEventListener(...n),e}onHover({promise:e,resolve:t}){const i=["mouseenter",({isTrusted:e,target:i})=>{const n=this.target?i.isEqualNode(this.target):l(i,this.selector);return e&&n&&t(!0)},{passive:!0,capture:!0}];return this.eventsListeners.push([document.documentElement,...i]),document.documentElement.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const i=["mouseleave",({isTrusted:e,clientY:i})=>{e&&i<=0&&t(!0)},{passive:!0}],{clear:n}=r("body",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=[({isTrusted:e})=>{e&&(n=i)},{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{this.eventsListeners.push([document,e,...s]),document.addEventListener(e,...s)});const o=setInterval(()=>{n<=0?t(!0):n-=100},100);return this.intervals.push(o),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:i}=DATA;return new Function(`return new Promise(async resolve => {${i}})`)().then(e=>e&&t(!0)),e}onScrollUp({promise:e,resolve:t}){let i=0;const n=["scroll",({isTrusted:e})=>{e&&(window.pageYOffset<i?t(!0):i=window.pageYOffset)},{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&&window.ABTASTY_S.USER&&window.ABTASTY_S.USER.accountIdentifier&&window.ABTASTY_S.USER.accountIdentifier.length?e=window.ABTASTY_S.USER.accountIdentifier:window.ABTasty&&window.ABTasty.getAccountSettings&&"function"==typeof window.ABTasty.getAccountSettings?e=window.ABTasty.getAccountSettings().identifier:window.ABTasty&&window.ABTasty.accountSettings&&(e=window.ABTasty.accountSettings.identifier),e):e})(),{viewInterval:o,spNoTrim:r}=DATA;if(this.socialProofStore.hasOwnProperty(e))i(this.socialProofStore[e])?n(`${this.socialProofStore[e][o]}`):n(!1);else if(e&&s){const a=t=>(this.socialProofStore[e]=t,n(!!i(t)&&`${t[o]}`));fetch(`https://api-social-proof.abtasty.com/clients/${s}/metrics/${t}?key=${e}${r?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(a).catch(()=>g("Failed to fetch datas from server."))}else n(!1)}getSocialProofDatas({promise:e,resolve:t},s,o=!1){const{productKey:r,keyType:a}=(()=>{const{socialProofContentType:e,productKeyProvider:t,pathToProductKey:s,customJSProductKey:o,productSKU:r}=DATA;if(2===e)return{productKey:n(),keyType:"url"};{let a=null,c="sku";switch(t){case"ABTastyProductKey":a=window.ABTastyProductKey;break;case"pathToProductKey":a=i(`return ${s};`);break;case"customJSProductKey":a=i(o);break;case"productSKU":a=r}return a||3!==e||(a=n(),c="url"),{productKey:a,keyType:c}}})(),{viewInterval:c,triggerSocialProofMinVisitors:l,triggerSocialProofMinPurchases:d,triggerSocialProofMinPageViews:h}=DATA,u={pv:h,i:d,"v-pv":l}[s];return[typeof c,typeof u].includes("undefined")&&t(!1),o&&!r&&(g("Not able to find ABTastyProductKey, impossible to call the API, read documentation for more informations:\n\t\t\t\thttps://support.abtasty.com/hc/en-us/articles/4710919241628-Widgets-List#h_84c04344-c655-4e5e-b9ab-d26a798ad9b0"),t(!1)),this.checkSocialProofConditions(r,"v-pv"===s&&"sku"===a?"v-i":s,e=>{const t=void 0!==e[c]&&e[c]>=u;return t||g(`Widget will not be shown, Social Proof API returned ${e[c]} while ${u} are required`),t},t),e}onConsent({promise:e,resolve:t}){if(!o()){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("ABTastyData");const s=()=>JSON.parse(n).ActionTracking.find(({name:e})=>e===i),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onMinPagesViewed({promise:e,resolve:t}){const{triggerEventMinPagesViewed:i}=DATA;let n=localStorage.getItem("ABTastyData");const s=()=>i<=(n?JSON.parse(n).VisitedPages.length:0),o=["storage",()=>{n=localStorage.getItem("ABTastyData"),s()&&t(!0)},{passive:!0,capture:!0}];return n&&s()?t(!0):(()=>{this.eventsListeners.push([window,...o]),window.addEventListener(...o)})(),e}onRageClick({promise:e,resolve:t}){const{triggerEventRageClickQuantity:i,triggerEventRageClickDelay:n}=DATA;let s=0,o=!1;const r=["click",({isTrusted:e})=>{if(e&&(s+=1,s>=i&&t(!0),!o)){o=!0;const e=setTimeout(()=>{s=0,o=!1},n);this.timeouts.push(e)}},{passive:!0,capture:!0}];return this.eventsListeners.push([document,...r]),document.addEventListener(...r),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...i]=e;t&&i.length>1&&t.removeEventListener(...i)}),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.visibilityObservers.length){const e=p();this.visibilityObservers.forEach(t=>t.clear(this.selector,e)),this.visibilityObservers=[]}return this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this}async isTriggered(){this.clear();const e=m(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=m(`${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 $="display",T="closing",C="validation",S="ABTastyWidgets",A=`${S}Temporary`;class E{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=h(),this.uniqueId=p(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(A),i=sessionStorage.getItem(S);"ABTastyData"===e&&!t&&i&&localStorage.setItem(A,i)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(S);return JSON.parse(t)}catch(t){return e.removeItem(S),!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(S,JSON.stringify(n)),n):(e.removeItem(S),!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(A),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(S,e),localStorage.removeItem(A));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:r}=n,a=this.getStamp(e),c={type:i,stamp:a},{type:l}=this.getCurrentRecurrence(),d=async()=>{if(!o()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new f({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};r.setItem(S,JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(l&&i!==C)if(i===T&&l!==C)d();else{if(i!==$||l===C||l===T)return!1;d()}else d();return a}setDisplayRecurrence(){const e=$;this.setRecurrence(this.displayRecurrence,e)}setClosingRecurrence(){const e=T;this.setRecurrence(this.closingRecurrence,e)}setValidationRecurrence(){const e=C;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 _{constructor(e,t,i){this.isWidgetApplied=e,this.callback=t,this.shouldUpdate=i,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(){const e=this.isWidgetApplied()?this.shouldUpdate&&w:b;return e?(this.clearWatcher(),this.callback(e,!0),this.watch(),this):this}onCampaignLaunched({detail:{campaignId:e}}){e===TEST_ID&&(this.callback(b,!1),this.watch())}onTagRollback(){return this.clearWatcher(),this.callback(y,!1),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(y,!1)}watch(){if(e())return this;this.clearWatcher(),window.removeEventListener(...this.onCampaignLaunchedEventParams),document.addEventListener(...this.tagRollbackEventParams);const{clear:t}=r("body",e=>{t(),this.observer.observe(e,{childList:!0,subtree:!0})});return this}clearWatcher(){return document.removeEventListener(...this.tagRollbackEventParams),this.observer.disconnect(),this}}const x=/.+\/([^.]+)\.(otf|ttf)$/,P=["socialProofPurchases","socialProofPageViews","socialProofVisitors"];class k{constructor(t,i){this.children=void 0,this.uniqueId=`${p()}${i?`_${i}`:""}`,this.widgetName=h(),this.prettyName=u(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:i,validationRecurrence:n}=DATA,s=!t&&!i&&!n;if(e()||s)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`]},r={};return t&&(r.displayRecurrence=o[t]("displayRecurrence")),i&&(r.closingRecurrence=o[i]("closingRecurrence")),n&&(r.validationRecurrence=o[n]("validationRecurrence")),r})(),this.triggerParams=(t=>{let{triggerEvent:i}=DATA;const{triggerEventClick:n,triggerEventHover:s,triggerEventReengageDelay:o,socialProofContentType:r,triggerEventElementVisible:a,triggerEventDelay:c}=DATA;if(e()||!i&&!r)return!1;const l={click:()=>n,hover:()=>s,elementVisible:()=>a},d=Object.prototype.hasOwnProperty.call(l,i)?l[i]():"body",h="reengage"===i?o:c;return r&&(i=[,"socialProofPurchases","socialProofPageViews","socialProofVisitors"][r]),{triggerEvent:i,triggerSelector:d,triggerDelay:h,triggerTarget:t}})(t),this.recurrence=!!this.recurrenceParams&&new E(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new f(this.triggerParams),this.shouldUpdate=!!this.triggerParams&&P.includes(this.triggerParams.triggerEvent),this.pageWatcher=new _(this.isWidgetApplied.bind(this),this.onPageChange.bind(this),this.shouldUpdate),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.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[],this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[],this.intervals.forEach(e=>clearInterval(e)),this.intervals=[],this.observers.forEach(e=>e.disconnect()),this.observers=[],this.promises.forEach(e=>e.resolve(!1)),this.promises=[],this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){if(this.isWidgetApplied())return!1;document.head.appendChild(this.styleElement);const e=["free"];return"drawer"===DATA.layout&&DATA.customTarget&&e.push("drawer"),new Promise(t=>{const{elementReferrer:i="body",referrerInsertType:n="beforeend"}=e.includes(DATA.layout)?DATA:{},s=r(i,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==i),this.removeOldDomElement(),t(e.insertAdjacentElement(n,this.domElement))});this.elementsWaiters.push(s)}).then(()=>this)}remove(){return this.trigger&&this.trigger.clear(),this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(e=>e&&e.isConnected&&e.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,setTimeout(()=>this.domElement.classList.remove(this.hideClassName),50),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(t=!0){return!e()&&this.hasBeenShown&&t&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),t&&(this.pageWatcher.clearWatcher(),this.closedByUser=!0),this.domElement.classList.add(this.hideClassName),this}async init(t){const i=e(),n=s(),o=this.trigger&&this.trigger.promises.length,r=!this.recurrence||this.recurrence.isOver();if(!i&&!n||o||!r)return{container:this,response:!1};this.pageWatcher.watch();const a=i||!this.trigger||this.trigger&&await this.trigger.isTriggered(),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){const i=()=>this.init().then(({response:e})=>{e?this.show():this.hide(!1)});t||(this.hasBeenShown=!1,this.trigger&&this.trigger.clear());const n=this.isWidgetApplied(),s={[y]:()=>n?this.remove():this.pageWatcher.watch(),[b]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():n||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):i()},[w]:i};"function"==typeof s[e]&&s[e]()}addCloseEvent(...t){const{closeButton:i,overlay:n,overlayClickable:s,layout:o,animationDuration:r=1e3}=DATA,a=[];if(void 0!==n&&!0!==n||!0!==s||"popin"!==o||a.push(`.${this.overlayClassName}`),void 0!==i&&i&&a.push(`.${this.closeButtonClassName}`),!a.length)return this;const l=this.domElement.querySelectorAll(a.join(", "));if(!l.length)return this;const d=["click",e=>{c(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(!0),setTimeout(()=>this.remove(),1.05*r)},{once:!0,capture:!0}];return t.push(...l),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.removeEventListener(...d),t.addEventListener(...d)}),this}getDom(){const{closeButton:e,layout:t,overlay:i=!0}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.role="dialog",n.innerHTML=`\n\t\t\t${"popin"===t&&!0===i?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}" aria-label="Dialog content">\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>`,n}loadFont(e,t){if(!e||"inherit"===e||!/otf|ttf/g.test(t))return;const i=document.createElement("style"),n=t.match(x)?t.match(x)[1]:"";i.innerHTML=`@font-face { font-family: '${e}_${n}'; src: url('${t}'); font-display: swap; }`,document.head.appendChild(i)}getStyleTag(t="",i=DATA){const{noStyles:n,layout:s}=i,{backgroundColor:o,isBackgroundImage:r,backgroundImage:a,backgroundSize:c,backgroundPosition:l,backgroundRepeat:d,borderColor:h,borderRadius:u,borderWidth:p,textColor:g,textAlign:m,fontName:v,fontStyle:y,fontSize:b,isTitle:w,titleTextAlign:f,titleTextColor:$,titleFontName:T,titleFontStyle:C,titleFontSize:S,overlay:A,overlayColor:E,dropShadow:_,dropShadowColor:P,dropShadowBlur:k,containerMargin:I,containerPadding:D,closeButton:L,closeButtonPosition:R,closeButtonSize:N,closeButtonBorderRadius:O,closeButtonBorderWidth:B,closeButtonBorderColor:V,closeButtonColor:j,closeButtonBackgroundColor:W,buttonsAlign:M,buttonsBorderWidth:q,buttonsBorderColor:H,buttonsBorderRadius:F,buttonsBackgroundColor:U,buttonsTextColor:K,buttonsFontName:z,buttonsFontStyle:Y,buttonsFontSize:G,secondLink:J,secondLinkBorderWidth:Q,secondLinkBorderColor:X,secondLinkBorderRadius:Z,secondLinkBackgroundColor:ee,secondLinkTextColor:te,secondLinkFontName:ie,secondLinkFontStyle:ne,secondLinkFontSize:se,animation:oe,animationDuration:re,animationBehaviour:ae,animationSlideDirection:ce}=n?{}:i,le=document.createElement("style");le.type="text/css",e()&&le.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(T,C),this.loadFont(z,Y),this.loadFont(ie,ne);const de=`background: ${["string"==typeof o?o:"rgba(255, 255, 255, 1)",r&&"string"==typeof a&&a.length?`url(${a})`:"",r&&"string"==typeof l&&"100% 100%"!==c?l:"0 0",r&&"string"==typeof c?`/ ${c}`:"/ auto",r&&d&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,he="number"==typeof p&&p>0,ue=`border: ${[he?`${p}px`:"unset",he?"solid":"",he&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,pe=void 0!==u?`border-radius: ${u}px;`:"",ge=void 0!==g?`color: ${g}; fill: ${g}; -webkit-text-fill-color: ${g};`:"",me=void 0!==m?`text-align: ${m};`:"",ve=v&&"inherit"!==v?`font-family:${v}_${y.match(x)?y.match(x)[1]:""};`:y||"",ye=b?`font-size: ${b}px;`:"",be=void 0!==_&&_?`box-shadow: 0 5px ${k}px 0 ${P};`:"",we=I instanceof Array&&1===I.length&&I[0],fe=we?`margin: ${we.top}px ${we.right}px ${we.bottom}px ${we.left}px;`:"",$e=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);`:"",Te=D instanceof Array&&1===D.length&&D[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);`:"",Ae=void 0!==q&&q?`border-width: ${q}px; border-style: solid;`:"",Ee=[H,q].every(e=>void 0!==e)&&q?`border-color: ${H};`:"",_e=void 0!==F?`border-radius: ${F}px;`:"",xe=void 0!==U?`background-color: ${U};`:"",Pe=void 0!==K?`color: ${K}; fill: ${K}; -webkit-text-fill-color: ${K};`:"",ke=z&&"inherit"!==z?`font-family:${z}_${Y.match(x)?Y.match(x)[1]:""};`:Y||"",Ie=G?`font-size: ${G}px;`:"",De="number"==typeof Q?`border-width: ${Q}px; border-style: solid;`:"",Le=[X,Q].every(e=>void 0!==e)&&Q?`border-color: ${X};`:"",Re=void 0!==Z?`border-radius: ${Z}px;`:"",Ne=void 0!==ee?`background-color: ${ee};`:"",Oe=void 0!==te?`color: ${te}; fill: ${te}; -webkit-text-fill-color: ${te};`:"",Be=ie&&"inherit"!==ie?`font-family:${ie}_${ne.match(x)?ne.match(x)[1]:""};`:ne||"",Ve=se?`font-size: ${se}px;`:"",je="popin"!==s||void 0!==A&&!0!==A?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==E?E:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),We="number"==typeof N?N:16,Me=We/2,qe=n||void 0!==L&&L?[`#${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 O?`border-radius: ${O}px;`:"","number"==typeof B&&B>0?`border: ${B}px solid ${void 0!==V?V:"rgba(57, 57, 57, 1)"};`:"","string"==typeof W?`background-color: ${W};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${We}px;`,`height: ${We}px;`,"string"==typeof j?`fill: ${j};`:"","}"].join(""):"",He=w&&"string"==typeof $?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${$}; fill: ${$}; -webkit-text-fill-color: ${$};`,void 0!==f?`text-align: ${f};`:"",T&&"inherit"!==T?`font-family:${T}_${C.match(x)?C.match(x)[1]:""};`:C||"",S?`font-size: ${S}px;`:"","}"].join(""):"";let Fe="";if("string"==typeof oe){const t=(re/1e3).toFixed(2),i=["top","bottom"].includes(ce),n=Number(i),s=[(["top","left"].includes(ce)?"-":"")+"100vmax",this.translateValues?this.translateValues[n]:"0"];i&&s.reverse(),Fe={none:[`.${this.hideClassName} {`,"opacity: 0 !important;","}"],fade:[`.${this.hideClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} {`,`transition: opacity ${t}s ${ae};`,"}"],slide:[`.${this.hideClassName} .${this.overlayClassName} {`,"opacity: 0 !important;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,`transition: opacity ${t}s ${ae};`,"}",`.${this.hideClassName} .${this.contentClassName} {`,`transform: translate(${s.join(", ")}) !important;`,"}",`#${this.widgetContainerId} .${this.contentClassName} {`,`transition: transform ${t}s ${ae};`,"}"]}[e()&&!ABTASTY_S.WIDGETS.animationChanged?"none":oe].join("")}const Ue=[`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,`margin-${"fill"===M?"top":"left"}: 8px;`,De,Le,Re,Ne,Oe,Be,Ve,"}",`#${this.widgetContainerId} .${this.contentClassName} .buttons_container .second_link {`,Oe,Be,Ve,"}"];return le.textContent=[`.${this.hideClassName} {`,"pointer-events: none;","}",`#${this.widgetContainerId} {`,"opacity: 1;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,de,pe,ue,ge,me,be,fe,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,ge,me,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",Ce,ve,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;",Ae,Ee,_e,xe,Pe,ke,Ie,"}",`#${this.widgetContainerId} .${this.contentClassName} div.buttons_container a *, `,`#${this.widgetContainerId} .${this.contentClassName} button:not(class*="close_button") * {`,Pe,ke,Ie,"}",...J?Ue:[],"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,$e,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,Se,"}","}",je,qe,He,Fe,`${t}`].join(""),le}}const I=["top: 0;","top: 50%;","bottom: 0;"],D=["left: 0;","left: 50%;","right: 0;"],L=e=>1===e?"-50%":0,R=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,i=`translate(${L(t)}, ${L(e)});`;return`${I[e]}${D[t]}transform: ${i}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},N=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,O=()=>{if(N())return"width: auto; height: auto; min-width: fit-content;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:i,autoHeight:n,popinPercentHeight:s,popinPixelsHeight:o,heightUnit:r}=DATA;return`width: ${"px"===i?t:e}${i};height: ${n?"auto":`${"px"===r?o:s}${r}`};`};class B extends k{constructor(){super(),this.translateValues=Object.values(DATA.popinPosition[0]).map(e=>L(e)),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t,widthUnit:i}=DATA,n="string"!=typeof DATA.overlay&&DATA.overlay;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"background: none;","pointer-events: "+(n?"all":"none"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",R(),O(),"pointer-events: all","}",`${N()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,`${!N()&&["px","em"].includes(i)?["@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join(""):""}`].join("")}}const V=["mp4","webm","ogg"],j=()=>V.some(e=>DATA.video.includes(e)),W=e=>e.replace("/","__").replace("?","__").replace("#","__").replace("&","__"),M=e=>(256|e).toString(16).slice(1);function q(e){const t=e.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i);return`${M(t[1])}${M(t[2])}${M(t[3])}`}const H="C71YkqN0pEA",F=["youtube.com","youtu.be"],U=()=>F.some(e=>DATA.video.includes(e)||""===DATA.video),K=(e,t)=>{if(window.YT&&"function"==typeof YT.Player){const i=(()=>{const{video:e}=DATA;if(""===e)return H;const t=["youtube.com/embed/","youtube.com/watch?v=","youtu.be/"].filter(t=>e.includes(t))[0],i=t?W(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]})(),n=(()=>{const{youtubeCCLoadPolicy:e,youtubeColor:t,youtubeControls:i,youtubeDisableKeyboard:n,youtubeEndTime:s,youtubeFullScreen:o,youtubeStartTime:r}=DATA,a={origin:location.origin,rel:0,color:t,controls:i?1:0,disablekb:n?0:1,fs:o?1:0};return e&&(a.cc_load_policy=1),s&&(a.end=s),r&&(a.start=r),a})(),s=(()=>{const{youtubeAutoPlay:e,youtubeLoop:t,youtubeMuted:i,youtubeStartTime:n}=DATA,s={};return(e||i)&&(s.onReady=t=>{i&&t.target.mute(),e&&t.target.playVideo()}),t&&(s.onStateChange=e=>{0===e.data&&(n&&e.target.seekTo(n),e.target.playVideo())}),s})(),o=new YT.Player(`popin_video_iframe_${e}`,{videoId:i,playerVars:n,events:s});return t(o)}return setTimeout(()=>K(e,t),100)};function z(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}const Y=()=>DATA.video.includes("vimeo.com"),G=(e,t)=>{if(window.Vimeo&&"function"==typeof Vimeo.Player){const{vimeoStartTime:i}=DATA,n=(()=>{const{video:e,vimeoAutoPlay:t,vimeoColor:i,vimeoLoop:n,vimeoMuted:s,vimeoInfos:o}=DATA;return{url:e,autoplay:t,byline:o,color:q(i),loop:n,muted:s,portrait:o,title:o}})(),s=new Vimeo.Player(`popin_video_iframe_${e}`,function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?z(Object(i),!0).forEach(function(t){var n,s,o,r;n=e,s=t,o=i[t],(s="symbol"==typeof(r=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(s))?r:String(r))in n?Object.defineProperty(n,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[s]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):z(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}({},n));return i&&s.setCurrentTime(i),t(s)}return setTimeout(()=>G(e,t),100)},J=["dailymotion.com","dai.ly"],Q=()=>J.some(e=>DATA.video.includes(e)),X=()=>{const{video:e}=DATA,t=["/video/","dai.ly/"].filter(t=>e.includes(t))[0],i=t?W(e.split(t)[1]):"";return!!i.length&&i.split("__")[0]},Z=(e,t,i,n)=>{if(window.DM&&"function"==typeof DM.player){const s=(()=>{const{dailymotionAutoPlay:e,dailymotionMuted:t,dailymotionColor:i,dailymotionLogo:n}=DATA;return{autoplay:e,mute:t,logo:n,"ui-highlight":q(i)}})(),o=DM.player(t.querySelector(`#popin_video_iframe_${e}`),{video:X(),params:s});return i(o),n(o)}return setTimeout(()=>Z(e,t,n,i),100)},ee=()=>DATA.video.includes("tiktok.com"),te=()=>{return e=`https://www.tiktok.com/oembed?url=${DATA.video}`,new Promise((t,i)=>{const n=new XMLHttpRequest;n.open("GET",e,!0),n.onload=function(){this.status>=200&&this.status<300?t(n.response):i({status:this.status,statusText:n.statusText})},n.onerror=function(){i({status:this.status,statusText:n.statusText})},n.send()});var e},ie=()=>{const{linkType:e,buttonText:t}=DATA;return!!([e,t].every(e=>"string"==typeof e)&&e.includes("button")&&t.length)};class ne{constructor(e){let{parentContainer:t}=e;this.parentContainer=t,this.className=`popinvideo_container_${t.uniqueId}`,this.videoSource=DATA.video||`https://www.youtube.com/embed/${H}`,this.contentElement=this.getContentElement(),this.styleElement=this.getStyleElement()}remove(){const{animationDuration:e=1e3}=DATA;setTimeout(()=>this.parentContainer.remove(),1.05*e)}addCloseEvent(t){t&&t.addEventListener("click",t=>{c(t),e()||this.parentContainer.recurrence.setClosingRecurrence(),this.parentContainer.hide(),this.remove()},{capture:!0,passive:!1})}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})}insertButtonsInContainer(e){const t=this.getButtons(),i=document.createElement("div");i.className="buttons_container",t.forEach(e=>i.appendChild(e)),e.appendChild(i)}getButtons(){var e=this;const t=function(t,i,n,s){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=document.createElement("a");return r.ariaLabel=t,o&&(r.className="second_link"),r.innerHTML=`<span>${t}</span>`,r.href="button"===i?n:"#","button"===i?(r.target=s?"_blank":"_self",e.addRedirectionEvent(r)):(r.dataset.abtastyActionnable="true",e.addCloseEvent(r)),r},{linkType:i,buttonText:n,redirectionUrl:s,openInNewTab:o,secondLink:r,secondLinkText:a,secondLinkType:c,secondLinkURL:l,secondLinkOpenInNewTab:d}=DATA,h=[t(n,i,s,o)];if(r){const e=t(a,c,l,d,r);h.push(e)}return h}getVideoContainer(){const e="popin_video_iframe",t=`${e}_${this.parentContainer.uniqueId}`,i=document.createElement("div");if(i.className="popin_video_container",j()){const{htmlPlayerAutoPlay:e,htmlPlayerMuted:t,htmlPlayerLoop:n,htmlPlayerControls:s}=DATA,o=V.filter(e=>this.videoSource.includes(`.${e}`))[0],r=document.createElement("video");r.innerHTML=`<source src="${this.videoSource}" type="video/${o}">`,e&&(r.setAttribute("playsinline",""),r.autoplay=!0),t&&(r.setAttribute("muted",""),r.muted=!0),n&&(r.loop=!0),s&&(r.controls=!0),i.appendChild(r)}else{DATA.video.includes("facebook.com")&&(this.videoSource=(()=>{const{video:e}=DATA;return e.includes("plugins/video.php")?e:`https://www.facebook.com/plugins/video.php?href=${e}&show_text=0`})());const n=`<iframe id="${t}" class="${e}" src="${this.videoSource}"></iframe>`;i.innerHTML=[U(),Y(),Q(),ee()].some(e=>e)?`<div id="${t}" class="${e}"></div>`:n}return i}setVideoOnlyContent(e,t){const i=this.getVideoContainer();return e.appendChild(i),e.classList.add(t),ie()&&this.insertButtonsInContainer(e),e}setVideoAndTextContent(e,t){const{isTitle:i,title:n,textContent:s}=DATA,o=this.getVideoContainer(),r=document.createElement("div");return r.className="popin_text_container",r.innerHTML=`${i?`<h2 class="popin_video_title">${n}</h2>`:""}<p class="popin_video_text">${s}</p>`,e.classList.add(t),["leftVideo","topVideo"].some(e=>e===t)&&e.appendChild(o),e.appendChild(r),["rightVideo","bottomVideo"].some(e=>e===t)&&e.appendChild(o),ie()&&this.insertButtonsInContainer(r),e}insertIn(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.contentElement),e}getContentElement(){const{contentLayout:e}=DATA,t=document.createElement("div");return t.className=this.className,{videoOnly:()=>this.setVideoOnlyContent(t,"onlyVideo"),left:()=>this.setVideoAndTextContent(t,"leftVideo"),right:()=>this.setVideoAndTextContent(t,"rightVideo"),top:()=>this.setVideoAndTextContent(t,"topVideo"),bottom:()=>this.setVideoAndTextContent(t,"bottomVideo")}[e](),t}getStyleElement(){const t=document.createElement("style");t.type="text/css",e()&&t.setAttribute("abtasty-script-added","true");const{textVideoRatio:i,borderRadius:n,borderWidth:s,containerPadding:o,contentLayout:r,linkType:a,buttonsAlign:c}=DATA,l=`#${this.parentContainer.widgetContainerId} .${this.parentContainer.contentClassName}`,d=o[0],h=parseInt(n-s,10),u=h-d.top>0?h-d.top:0,p=h-d.bottom>0?h-d.bottom:0,g=void 0!==c&&"fill"!==c?`text-align: ${c};`:"",m=[`${l} .onlyVideo .popin_video_container {`,`border-radius: ${u}px ${u}px ${p}px ${p}px;`,"}"].join(""),v=[`${l} .leftVideo .popin_video_container {`,`width: calc(${i}% - 2.5%);`,"}",`${l} .leftVideo .popin_text_container {`,`width: calc(100% - ${i}% - 2.5%);`,"position: relative;","margin: 0 2.5%;","}",`${l} .leftVideo .popin_video_container {`,`border-radius: ${u}px 0 0 ${p}px;`,"}"].join(""),y=[`${l} .rightVideo .popin_video_container {`,`width: calc(${i}% - 2.5%);`,"}",`${l} .rightVideo .popin_text_container {`,`width: calc(100% - ${i}% - 2.5%);`,"position: relative;","margin: 0 2.5%;","}",`${l} .rightVideo .popin_video_container {`,`border-radius: 0 ${u}px ${p}px 0;`,"}"].join(""),b=[`${l} .topVideo .popin_video_container {`,`border-radius: ${u}px ${u}px 0 0;`,"margin-bottom: 15px","}"].join(""),w=[`${l} .bottomVideo .popin_video_container {`,`border-radius: 0 0 ${p}px ${p}px;`,"margin-top: 15px;","}"].join(""),f=[`${l} .buttons_container {`,"display: inline-block;","width: 100%;",g,"}",`${l} .buttons_container a {`,"display: inline-block;","margin: 25px 0 0 0;","padding: 10px 22px;","max-width: 100%;",`width: ${"fill"===c?"100%":"auto"};`,"text-align: center;","}"].join(""),$=[`${l} .popin_video_container {`,"line-height: 0;","overflow: hidden;","width: 100%;","max-width: 100%;","}",`${l} .popin_video_title {`,"margin: 0 0 25px 0;","display: inline-block;","width: 100%;","}",`${l} .popin_video_container video,`,`${l} .popin_video_container .popin_video_iframe {`,"display: inline-block;","width: 100%;","height: 100%;","}",`${l} .popin_video_container .popin_video_iframe iframe {`,"display: inline-block;","width: 100%;","}",`${l} .popin_text_container {`,"line-height: 1;","white-space: pre-line;","}",`${l} .popin_text_container p {`,"margin: 0;","}",`${l} .popin_video_container,`,`${l} .popin_text_container {`,"display: inline-block;","vertical-align: middle;","}"];return(0,{videoOnly:()=>$.push(m),top:()=>$.push(b),bottom:()=>$.push(w),left:()=>$.push(v),right:()=>$.push(y)}[r])(),a&&$.push(f),t.textContent=$.join(""),t}}function se(e){const t=e.querySelector(".popin_video_iframe"),i=parseInt(t.clientWidth/16*9,10)+1;t.style.height=`${i}px`}!function(){g("Widget launch");const e=p(),t=U(),i=Y(),n=Q(),s=ee();t&&(e=>{if(window.YT)return!1;const t=document.createElement("script");t.src="https://www.youtube.com/iframe_api",t.id=`video_popin_ytapi_${e}`,document.head.appendChild(t)})(e),i&&(e=>{if(window.Vimeo)return!1;const t=document.createElement("script");t.src="https://player.vimeo.com/api/player.js",t.id=`video_popin_vimeoapi_${e}`,document.head.appendChild(t)})(e),n&&(e=>{if(window.DM)return!1;const t=document.createElement("script");t.src="https://api.dmcdn.net/all.js",t.id=`video_popin_dailymotionapi_${e}`,document.head.appendChild(t)})(e);const o=new B,r=new ne({parentContainer:o}),a=r.contentElement.querySelector(".popin_video_container");s&&te().then(t=>{const i=JSON.parse(t),n=a.querySelector(`#popin_video_iframe_${e}`);n.innerHTML=i.html,r.player=n,a.appendChild(r.player),(e=>{window.tiktokEmbed&&(window.tiktokEmbed=void 0);const t=document.createElement("script");t.src="https://www.tiktok.com/embed.js",t.id=`video_popin_tiktokapi_${e}`,t.async=!0,document.head.appendChild(t)})(e)});const c=o.domElement.querySelector(`.${o.contentClassName}`);o.children=r,r.insertIn(c,"beforeend"),o.init(!0).then(c=>{let{response:l}=c;if(l){const c=e=>{r.player=e,i||s||j()||(se(r.contentElement),window.addEventListener("resize",()=>se(r.contentElement),{capture:!0,passive:!0}))};t&&K(e,c),i&&G(e,c),n&&Z(e,r.contentElement,e=>{a.innerHTML="",a.appendChild(e)},c),r.player||c(a),o.show()}})}()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/popin-video",
3
3
  "description": "A simple way to create a modal with an video in it",
4
- "version": "1.4.18",
4
+ "version": "1.4.19",
5
5
  "main": "dist/main.js",
6
6
  "form": "dist/form.js",
7
7
  "type": "module",