@abtasty/nps 1.1.11 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +52 -0
- package/dist/form.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +39 -39
package/dist/main.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(){"use strict";var e,t=(function(e){var t=function(e){var t,n=Object.prototype,s=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,s){var i=t&&t.prototype instanceof f?t:f,r=Object.create(i.prototype),o=new k(s||[]);return r._invoke=function(e,t,n){var s=u;return function(i,r){if(s===m)throw new Error("Generator is already running");if(s===g){if("throw"===i)throw r;return L()}for(n.method=i,n.arg=r;;){var o=n.delegate;if(o){var a=$(o,n);if(a){if(a===p)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(s===u)throw s=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);s=m;var c=h(e,t,n);if("normal"===c.type){if(s=n.done?g:d,c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(s=g,n.method="throw",n.arg=c.arg)}}}(e,n,o),r}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var u="suspendedStart",d="suspendedYield",m="executing",g="completed",p={};function f(){}function v(){}function y(){}var b={};b[r]=function(){return this};var w=Object.getPrototypeOf,C=w&&w(w(A([])));C&&C!==n&&s.call(C,r)&&(b=C);var E=y.prototype=f.prototype=Object.create(b);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function N(e,t){function n(i,r,o,a){var c=h(e[i],e,r);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==typeof u&&s.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,o,a)}),(function(e){n("throw",e,o,a)})):t.resolve(u).then((function(e){l.value=e,o(l)}),(function(e){return n("throw",e,o,a)}))}a(c.arg)}var i;this._invoke=function(e,s){function r(){return new t((function(t,i){n(e,s,t,i)}))}return i=i?i.then(r,r):r()}}function $(e,n){var s=e.iterator[n.method];if(s===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,$(e,n),"throw"===n.method))return p;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var i=h(s,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,p;var r=i.arg;return r?r.done?(n[e.resultName]=r.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,p):r:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,p)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function A(e){if(e){var n=e[r];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(s.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}return{next:L}}function L(){return{value:t,done:!0}}return v.prototype=E.constructor=y,y.constructor=v,v.displayName=c(y,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,c(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},S(N.prototype),N.prototype[o]=function(){return this},e.AsyncIterator=N,e.async=function(t,n,s,i,r){void 0===r&&(r=Promise);var o=new N(l(t,n,s,i),r);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(E),c(E,a,"Generator"),E[r]=function(){return this},E.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var s=t.pop();if(s in e)return n.value=s,n.done=!1,n}return n.done=!0,n}},e.values=A,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(x),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(s,i){return a.type="throw",a.arg=e,n.next=s,i&&(n.method="next",n.arg=t),!!i}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),l=s.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,p):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var s=n.completion;if("throw"===s.type){var i=s.arg;x(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,s){return this.delegate={iterator:A(e),resultName:n,nextLoc:s},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(e={exports:{}},e.exports),e.exports);function n(e,t,n,s,i,r,o){try{var a=e[r](o),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(s,i)}var s=function(e){return function(){var t=this,s=arguments;return new Promise((function(i,r){var o=e.apply(t,s);function a(e){n(o,i,r,a,c,"next",e)}function c(e){n(o,i,r,a,c,"throw",e)}a(void 0)}))}};const i=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),r=()=>{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},o=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},a=()=>o()||!!window.ABTasty.getTestsOnPage()[TEST_ID],c=()=>["consentReady","cnilReady"].some((e=>window.ABTasty&&Object.prototype.hasOwnProperty.call(window.ABTasty,e)&&!0===window.ABTasty[e])),l="remove",h="rebuild",u="https://social-proof-api.abtasty.com/clients/",d=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},m=()=>{const e=d();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},g=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,p=e=>{if((()=>{if(i()||o())return!1;const e=ABTasty.getTestsOnPage()[TEST_ID];return!!e&&Object.keys(e.targetings.qaParameters).length>0})()){const t=m();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}},f=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise(((e,n)=>{t.resolve=e,t.reject=n})),t},v=(e,t,n)=>{let s=0,i=0;try{document.querySelector(e)}catch(t){const s=`Selector «${e}» not valid.`;return p(s),"function"==typeof n&&n(s)}function r(){clearInterval(i),clearTimeout(s)}return s=setTimeout((()=>{r();const t=`Can't find element «${e}».`;return p(t),"function"==typeof n&&n(t)}),1e4),i=setInterval((()=>{const n=document.querySelector(e);return null!==n?(r(),"function"==typeof t&&t(n)):n}),200),{clear:r}};function y(e,t){return t(e)||!e.parentElement?e:y(e.parentElement,t)}const b=e=>{i()||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};function w(){return"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||(e="",new Promise(((t,n)=>{const s=window.document.getElementsByTagName("script")[0],i=window.document.createElement("script");i.src=e,s.parentNode.insertBefore(i,s),i.onload=t,i.onerror=n})));var e}class C{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach((e=>{e.isIntersecting?(this.existingTargets.forEach((t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())})),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter((t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1)))}))}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find((({element:n,selector:s})=>{if(n.isSameNode(e))return!0;const i=[...e.querySelectorAll(s)];if(i.length){if(i.includes(n))return!0}if(t.includes(n))return!0;const r=[...e.parentElement.children],o=r.findIndex((t=>t.isSameNode(e))),a=r.filter(((e,t)=>t>o));if(a.length){if(a.includes(n))return!0;if(a.some((e=>[...e.querySelectorAll(s)].includes(n))))return!0}return!1}));if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:s}=n,i=this.targets.find((t=>t.selector===e&&t.uniqueId===s));i&&i.resolve(t),this.clear(e,s)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout((()=>this.onMouseOver(e)),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===y(e,(e=>"0"===window.getComputedStyle(e).opacity)).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),n=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let s=!1,i=0;for(;!s&&i<n.length;){const t=document.elementFromPoint(...n[i]);s=e===t||e.contains(t),i+=1}return s}checkElements(){this.targets.forEach((({selector:e,uniqueId:t})=>{const n=document.querySelector(e);n&&!this.existingTargets.find((n=>n.element.matches(e)&&n.uniqueId===t))&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))})),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:n})=>{if(t.matches(e)&&this.isElementVisible(t)){const s=this.targets.find((t=>t.selector===e&&t.uniqueId===n));return s&&s.resolve(t),this.clear(e,n),!1}return!0}))}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const s=()=>{this.startMutationObserver(),this.checkElements()};document.body?s():v("body",s)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map((n=>n.filter((({selector:n,uniqueId:s})=>n!==e&&s!==t))));const n=document.querySelector(e);n&&this.visibilityObserver.unobserve(n),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class E{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=f(`${this.event}DomReady`);this.promises.push(n);const s=await this.onPageLoad(n),i=await async function(e){let t;switch(e){case"IntersectionObserver":t=await w();break;default:t=!0}return t}("IntersectionObserver"),r=new C;if(this.visibilityObservers.push(r),i&&s){const e=g();r.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const s=["readystatechange",()=>n()&&t(!0),{passive:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),e}return t(!0),e}onClick({promise:e,resolve:t}){const n=document.createElement("style");n.type="text/css",n.id=`Click_${g()}`,n.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(n),this.elementsSelectors.push(`#${n.id}`);const s=e=>[...document.querySelectorAll(this.selector)].some((t=>t.isSameNode(e)||!!e.closest(this.selector))),i=["click",({target:e})=>s(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],s=v("body",(e=>{e.addEventListener(...n),this.eventsListeners.push([e,...n]),this.elementsWaiters=this.elementsWaiters.filter((e=>e!==s))}));return this.elementsWaiters.push(s),e}onReengage({promise:e,resolve:t}){const n=this.delay;let s=n;const i=[()=>(s=n,s),{passive:!0}];["click","mousemove","scroll","keypress"].forEach((e=>{document.addEventListener(e,...i),this.eventsListeners.push([e,...i])}));const r=setInterval((()=>{s<=0?t(!0):s-=100}),100);return this.intervals.push(r),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n}=DATA;return new Function(`return new Promise(async resolve => {${n}})`)().then((e=>e&&t(!0))),e}getSocialProofPurchases({promise:e,resolve:t}){const n=window.ABTastyProductKey,s=r(),{viewInterval:i,triggerSocialProofMinPurchases:o,spNoTrim:a}=DATA;if(n||(p("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),n&&s){fetch(`${u}${s}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then((e=>e.ok&&e.json())).then((e=>(e=>{if(void 0===i||void 0===o)return!1;const t=void 0!==e[i]&&e[i]>=o;return t||p(`Widget will not be shown, product has been purchased ${e[i]} times while ${o} are required`),t})(e)&&t(`${e[i]}`))).catch((()=>p("Failed to fetch datas from server.")))}else t(!1);return e}getSocialProofPageViews({promise:e,resolve:t}){const{viewInterval:n,triggerSocialProofMinPageViews:s,spNoTrim:i}=DATA,o=encodeURIComponent(i?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),a=r();if(o&&a){fetch(`${u}${a}/metrics/pv?key=${o}${i?"&noTrim=true":""}`).then((e=>e.ok&&e.json())).then((e=>(e=>{if(void 0===n||void 0===s)return!1;const t=void 0!==e[n]&&e[n]>=s;return t||p(`Widget will not be shown, page has been seen ${e[n]} times while ${s} are required`),t})(e)&&t(`${e[n]}`))).catch((()=>p("Failed to fetch datas from server.")))}else t(!1);return e}onConsent({promise:e,resolve:t}){if(!c()){const n=["consentValid",()=>t(!0)];return this.eventsListeners.push(n),document.addEventListener(...n),e}return t(!0),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,...n]="string"==typeof e[0]?[document,...e]:e;t&&n.length>1&&t.removeEventListener(...n)})),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach((e=>clearInterval(e))),this.intervals=[]),this.observers.length&&(this.observers.forEach((e=>e.disconnect())),this.observers=[]),this.visibilityObservers.length){const e=g();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.elementsWaiters.length&&(this.elementsWaiters.forEach((e=>e.clear())),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=f(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),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();this.clear();return"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=f(`${this.event}Delay`);return this.promises.push(e),setTimeout((()=>{e.resolve(!0),this.clear()}),this.delay),e.promise})():n}}const S="display",N="closing",$="validation",T="ABTastyWidgets",x="ABTastyWidgetsTemporary";class k{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:n},s){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(n),this.onSetCallback=s,this.widgetName=d(),this.uniqueId=g(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(x),n=sessionStorage.getItem(T);"ABTastyData"===e&&!t&&n&&localStorage.setItem(x,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(T);return JSON.parse(t)}catch(t){return e.removeItem(T),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:n,...s}=t;return Object.entries(s).length?(e.setItem(T,JSON.stringify(s)),s):(e.removeItem(T),!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(x),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(T,e),localStorage.removeItem(x));const n=this.getLocalRecurrence(),s=(n?parseFloat(n.stamp):0)<(new Date).getTime();return s&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&s&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(e);if(o()||!n&&"object"!=typeof n)return!1;const{storageString:s,storageMethod:i}=n,r=this.getStamp(e),a={type:t,stamp:r},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!c()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=a;const e=new E({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===s?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===s&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const r=n?{[this.recurrenceKey]:a,...n}:{[this.recurrenceKey]:a};i.setItem(T,JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!i)return!1;if(l&&t!==$)if(t===N&&l!==$)h();else{if(t!==S||l===$||l===N)return!1;h()}else h();return r}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class A{constructor(e,t,n){this.recurrence=e,this.isWidgetApplied=t,this.callback=n,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=a(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},s=()=>{const t=this.recurrenceIsDone();return e&&"display"===n||t};return!this.isWidgetApplied()&&t&&s()?(this.clearWatcher(),this.callback(h,e)):(!this.isWidgetApplied()||t&&s())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback(l,e),this.watch()),this}eventHandler(){let e=a();return[250,500].forEach((t=>setTimeout((()=>500===t&&a()===e?this:(e=a(),this.decisionHandler(!1))),t))),this}observerHandler(e){const t=e.some((({removedNodes:e})=>e&&e.length)),n=e.some((({addedNodes:e})=>e&&e.length));return t||n?(this.decisionHandler(!0),this):this}watch(){if(i())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const e=v("body",(t=>{const n=[t,{childList:!0,subtree:!0}];this.observer.observe(...n),this.elementsWaiters=this.elementsWaiters.filter((t=>t!==e))}));return this.elementsWaiters.push(e),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach((e=>e.clear())),this.elementsWaiters=[]),this.observer.disconnect(),this}}const L=/.+\/([^.]+)\.(otf|ttf)$/;class I{constructor(){this.children=void 0,this.uniqueId=g(),this.widgetName=d(),this.prettyName=m(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:t,validationRecurrence:n}=DATA;if(i()||!e&&!t&&!n)return!1;const s={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 e&&(r.displayRecurrence=s[e]("displayRecurrence")),t&&(r.closingRecurrence=s[t]("closingRecurrence")),n&&(r.validationRecurrence=s[n]("validationRecurrence")),r})(),this.triggerParams=(()=>{let{triggerEvent:e}=DATA;const{triggerEventClick:t,triggerEventReengageDelay:n,socialProofContentType:s,triggerEventElementVisible:r,triggerEventDelay:o}=DATA;if(i()||!e&&!s)return!1;const a={click:()=>t,elementVisible:()=>r},c=Object.prototype.hasOwnProperty.call(a,e)?a[e]():"body",l="reengage"===e?n:o;return s&&(e=1===s?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:e,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new k(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new E(this.triggerParams),this.pageWatcher=new A(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||(!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some((e=>e===t)))})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach((e=>document.removeEventListener(...e))),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach((e=>clearInterval(e))),this.intervals=[]),this.observers.length&&(this.observers.forEach((e=>e.disconnect())),this.observers=[]),this.promises.length&&(this.promises.forEach((e=>e.resolve(!1))),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach((e=>e.clear())),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){const e=(e,t,n)=>{this.elementsWaiters=this.elementsWaiters.filter((e=>e!==t)),n(e)},t=new Promise(((t,n)=>{const s=v("head",(e=>{this.elementsWaiters=this.elementsWaiters.filter((e=>e!==s)),t(e.appendChild(this.styleElement))}),(t=>e(t,s,n)));this.elementsWaiters.push(s)})),n=new Promise(((t,n)=>{const{layout:s,elementReferrer:i,referrerInsertType:r}=DATA,{selector:o,position:a}="string"==typeof s&&"free"===s&&"string"==typeof i&&"string"==typeof r?{selector:i,position:r}:{selector:"body",position:"beforeend"},c=v(o,(e=>{this.elementsWaiters=this.elementsWaiters.filter((e=>e!==c)),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))}),(t=>e(t,c,n)));this.elementsWaiters.push(c)}));return Promise.all([n,t]).then((()=>this))}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():i()||this.init().then((({response:e})=>e?this.show():this)),this}show(){return this.hasBeenShown||i()||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!i()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(e){if(!i()&&!a())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const t=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!t)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const n=i()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!n&&(await this.insert(),this.addCloseEvent(),i()||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(n),{container:this,response:n})}onPageChange(e,t){const n=()=>this.init().then((({response:e})=>e&&this.show()));switch(t||(this.hasBeenShown=!1),e){case l:this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case h:this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then((e=>e.show())):n()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:n,layout:s}=DATA,r=[];if(void 0!==n&&n&&void 0!==s&&"popin"===s&&r.push(`.${this.overlayClassName}`),void 0!==t&&t&&r.push(`.${this.closeButtonClassName}`),!r.length)return this;const o=this.domElement.querySelectorAll(r.join(", "));return o.length?(e.push(...o),e.forEach((e=>{i()&&(e.dataset.abtastyActionnable="true"),e.addEventListener("click",(e=>{b(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout((()=>this.remove()),1e3)}),{once:!0,capture:!0})})),this):this}getDom(){const{closeButton:e,layout:t}=DATA,n=document.createElement("div");return n.className=`${this.basicClassName} ${this.hideClassName}`,n.id=this.widgetContainerId,n.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<button class="${this.closeButtonClassName}"><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)return;const n=document.createElement("style"),s=t.match(L)?t.match(L)[1]:"";n.appendChild(document.createTextNode(`\t\t\t@font-face { \t\tfont-family: '${e}_${s}'; src: url('${t}');\t\t\t}\t\t`)),document.head.appendChild(n)}getStyleTag(e=""){const{noStyles:t,layout:n}=DATA,{backgroundColor:s,isBackgroundImage:r,backgroundImage:o,backgroundSize:a,backgroundPosition:c,backgroundRepeat:l,borderColor:h,borderRadius:u,borderWidth:d,textColor:m,textAlign:g,fontName:p,fontStyle:f,fontSize:v,isTitle:y,titleTextAlign:b,titleTextColor:w,titleFontName:C,titleFontStyle:E,titleFontSize:S,overlayColor:N,dropShadow:$,dropShadowColor:T,dropShadowBlur:x,containerMargin:k,containerPadding:A,closeButton:I,buttonsBorderWidth:P,buttonsBorderColor:O,buttonsBorderRadius:R,buttonsBackgroundColor:_,buttonsTextColor:B,buttonsFontName:j,buttonsFontStyle:W,buttonsFontSize:D}=t?{}:DATA,q=document.createElement("style");q.type="text/css",i()&&q.setAttribute("abtasty-script-added","true"),this.loadFont(p,f),this.loadFont(C,E),this.loadFont(j,W);const F=`background: ${["string"==typeof s?s:"rgba(255, 255, 255, 1)",r&&"string"==typeof o&&o.length?`url(${o})`:"",r&&"string"==typeof c&&"100% 100%"!==a?c:"0 0",r&&"string"==typeof a?`/ ${a}`:"/ auto",r&&l&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,V="number"==typeof d&&d>0,M=`border: ${[V?`${d}px`:"unset",V?"solid":"",V&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,H=void 0!==u?`border-radius: ${u}px;`:"",Y=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",z=void 0!==g?`text-align: ${g};`:"",G=p&&"inherit"!==p?`font-family:${p}_${f.match(L)?f.match(L)[1]:""};`:f||"",U=v?`font-size: ${v}px;`:"",K=void 0!==$&&$?`box-shadow: 0 5px ${x}px 0 ${T};`:"",Q=k instanceof Array&&1===k.length&&k[0],J=Q?`margin: ${Q.top}px ${Q.right}px ${Q.bottom}px ${Q.left}px;`:"",X=Q?`margin: calc(${Q.top}px * 0.5) calc(${Q.right}px * 0.5) calc(${Q.bottom}px * 0.5) calc(${Q.left}px * 0.5);`:"",Z=A instanceof Array&&1===A.length&&A[0],ee=Z?`padding: ${Z.top}px ${Z.right}px ${Z.bottom}px ${Z.left}px;`:"",te=Z?`padding: calc(${Z.top}px * 0.5) calc(${Z.right}px * 0.5) calc(${Z.bottom}px * 0.5) calc(${Z.left}px * 0.5);`:"",ne=void 0!==P&&P?`border-width: ${P}px; border-style: solid;`:"",se=[O,P].every((e=>void 0!==e))&&P?`border-color: ${O};`:"",ie=void 0!==R?`border-radius: ${R}px;`:"",re=void 0!==_?`background-color: ${_};`:"",oe=void 0!==B?`color: ${B}; fill: ${B}; -webkit-text-fill-color: ${B};`:"",ae=j&&"inherit"!==j?`font-family:${j}_${W.match(L)?W.match(L)[1]:""};`:W||"",ce=D?`font-size: ${D}px;`:"",le=void 0!==n&&"popin"===n?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==N?N:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",he=t||void 0!==I&&I?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;","top: 8px;","right: 8px;","width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;","width: 16px;","height: 16px;",Y,G,U,"}"].join(""):"",ue=y&&"string"==typeof w?[`#${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: ${w}; fill: ${w}; -webkit-text-fill-color: ${w};`,void 0!==b?`text-align: ${b};`:"",C&&"inherit"!==C?`font-family:${C}_${E.match(L)?E.match(L)[1]:""};`:E||"",S?`font-size: ${S}px;`:"","}"].join(""):"";return q.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,F,H,M,Y,z,K,J,G,U,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,Y,z,G,U,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",ee,G,U,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,ne,se,ie,re,oe,ae,ce,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button * {`,oe,ae,ce,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,X,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,te,"}","}",le,he,ue,`${e}`].join(""),q}}class P extends I{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","background: none;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;","left: 50%;","top: 50%;","transform: translate(-50%, -50%);","width: auto;","height: auto;","}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class O extends I{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;","z-index: 9999;","opacity: 1;","transition: opacity 0.25s ease;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class R extends I{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const _=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new P;break;case"bannerTop":case"bannerBottom":t=new O;break;case"free":t=new R;break;default:t=new I}return t};var B=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};var j=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function W(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var D=function(e,t,n){return t&&W(e.prototype,t),n&&W(e,n),e};function q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function F(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?q(Object(n),!0).forEach((function(t){B(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var V=DATA,M=V.isFeedBackQuestion,H=V.isThankYouMessage,Y=V.autoHide,z=V.timeHide,G=V.stepToShow,U=V.question,K=V.feedbackQuestion,Q=V.buttonText,J=V.thankYouMessage,X=V.isLegend,Z=V.minLegend,ee=V.maxLegend,te=V.noStyles,ne={capture:!0,passive:!1},se=function(){function e(t){var n=t.parentContainer;j(this,e),this.parentContainer=n,this.baseClassName="nps_container",this.className="".concat(this.baseClassName,"_").concat(n.uniqueId),this.questionClassName="".concat(this.baseClassName,"_question"),this.notesClassName="".concat(this.baseClassName,"_notes"),this.feedbackQuestionClassName="".concat(this.questionClassName,"_feedback"),this.feedbackFormClassName="".concat(this.questionClassName,"_feedback_form"),this.notesButtonsClassName="".concat(this.notesClassName,"_button"),this.thankYouClassName="".concat(this.baseClassName,"_thanks"),this.hideClassName="nps_".concat(n.uniqueId,"_display_none"),this.currentNote=NaN,this.userFeedback="",this.npsContainer=this.getContainer(),this.questionElement=this.getQuestionElement(),this.notesContainer=this.getNotesElement(),this.feedbackElements=this.getFeedBackElements(),this.thankYouElement=this.getThankYouElement(),this.npsElement=this.getNPSElement(),this.styleElement=this.getStyleElement()}return D(e,[{key:"sendNote",value:function(){if(!i()&&!isNaN(this.currentNote))try{window.abtasty.send("nps",{ns:this.currentNote,nf:this.userFeedback})}catch(e){p("Not able to send NPS hit due to old tag version (< 3.0)")}return this}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.npsElement),this}},{key:"complete",value:function(){var e=this;return this.sendNote(),Y?(setTimeout((function(){e.parentContainer.hide(),setTimeout((function(){e.parentContainer.recurrence.setValidationRecurrence(),e.parentContainer.remove(),e.showNotes(),e.currentNote=NaN,e.userFeedback="",e.feedbackElements.feedbackFormElement.querySelector("textarea").value=""}),1e3)}),1e3*z),this):this}},{key:"onClickNote",value:function(e){this.currentNote=Number(e.target.dataset.note),M&&K&&K.length?this.showFeedBack():H&&J&&J.length?this.showThankYouMessage():this.complete()}},{key:"onFeedbackSend",value:function(){H&&J&&J.length?this.showThankYouMessage():this.complete()}},{key:"showNotes",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),[this.questionElement,this.notesContainer].forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showFeedBack",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),Object.values(this.feedbackElements).forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showThankYouMessage",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),this.thankYouElement.classList.remove(this.hideClassName),this.complete(),this}},{key:"getThankYouElement",value:function(){var e=document.createElement("p");return e.className="".concat(this.thankYouClassName," ").concat(this.hideClassName),e.innerHTML=J,i()&&"displayThanksStep"===G&&e.classList.remove(this.hideClassName),e}},{key:"getFeedBackElements",value:function(){var e=this,t=document.createElement("p");t.className="".concat(this.feedbackQuestionClassName," ").concat(this.hideClassName),t.innerHTML=K;var n=document.createElement("form");n.className="".concat(this.feedbackFormClassName," ").concat(this.hideClassName),n.addEventListener("submit",b,F({},ne));var s=document.createElement("textarea");s.className="".concat(this.feedbackQuestionClassName,"_textarea");var r=document.createElement("button");return r.className="".concat(this.feedbackQuestionClassName,"_button"),r.innerHTML="<span>".concat(Q,"</span>"),r.addEventListener("click",(function(t){return b(t),e.userFeedback=s.value,e.onFeedbackSend()}),F({},ne)),i()&&"displayFeedbackStep"===G&&[t,n].forEach((function(t){return t.classList.remove(e.hideClassName)})),n.appendChild(s),n.appendChild(r),{feedbackQuestionElement:t,feedbackFormElement:n}}},{key:"getNotesElement",value:function(){var e=this,t=document.createElement("div");t.className=this.notesClassName,i()&&"displayNoteStep"!==G&&t.classList.add(this.hideClassName);for(var n=10;n>=0;){var s=document.createElement("button");s.className=this.notesButtonsClassName,s.dataset.note=n,i()&&s.setAttribute("data-abtasty-actionnable",""),s.innerHTML+="<span>".concat(n,"</span>"),s.addEventListener("click",(function(t){b(t),e.onClickNote(t)}),F({},ne)),t.insertAdjacentElement("afterbegin",s),5===n&&s.insertAdjacentHTML("afterend","<br>"),n-=1}return X&&(t.insertAdjacentHTML("afterbegin","<legend>".concat(Z,"</legend>")),t.insertAdjacentHTML("beforeend","<legend>".concat(ee,"</legend>"))),t}},{key:"getQuestionElement",value:function(){var e=document.createElement("p");return e.className=this.questionClassName,e.innerHTML=U,i()&&"displayNoteStep"!==G&&e.classList.add(this.hideClassName),e}},{key:"getContainer",value:function(){var e=document.createElement("div");return e.className="".concat(this.baseClassName," ").concat(this.className),e}},{key:"getNPSElement",value:function(){var e=this;return this.npsContainer.appendChild(this.questionElement),this.npsContainer.appendChild(this.notesContainer),M&&Object.values(this.feedbackElements).forEach((function(t){e.npsContainer.appendChild(t)})),H&&this.npsContainer.appendChild(this.thankYouElement),this.npsContainer}},{key:"getStyleElement",value:function(){var e=document.createElement("style");if(e.type="text/css",i()&&e.setAttribute("abtasty-script-added","true"),te)e.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.className," .").concat(this.hideClassName," {"),"display: none !important;","}"].join("");else{var t=DATA.containerPadding,n=t instanceof Array&&1===t.length&&t[0],s="#".concat(this.parentContainer.widgetContainerId," .").concat(this.className);e.textContent=["".concat(s," .").concat(this.hideClassName," {"),"display: none !important;","}","".concat(s,","),"".concat(s," * {"),"all: unset;","box-sizing: border-box;","font-size: 10px;","line-height: 1;","font-family: sans-serif;","}","".concat(s," > * {"),"display: block;","width: 100%;","}","".concat(s," .").concat(this.notesClassName," {"),"position: relative;","display: inline-block;","width: auto;","}","".concat(s," p {"),"margin-bottom: 15px;","font-size: 1.4em;","}","".concat(s," button {"),"vertical-align: middle;","cursor: pointer;","text-align: center;","}","".concat(s," button span {"),"font-size: 1.4em;","pointer-events: none;","}","".concat(s," .").concat(this.notesClassName," button {"),"margin: 0 5px;","width: 30px;","height: 30px;","}","".concat(s," .").concat(this.feedbackFormClassName," span {"),"display: block;","padding: 6px 24px;","}",X?["".concat(s," legend {"),"position: absolute;","text-decoration: none;","border: none;","font-size: 1em;","}","".concat(s," legend:nth-of-type(2) {"),"left: auto;","right: 0;","}"].join(""):"","".concat(s," textarea {"),"display: block;","width: 100%;","min-width: 310px;","min-height: 60px;","font-size: 1.4em;","border: 1px solid grey;","border-radius: 4px;","resize: vertical;","margin-bottom: 10px;","text-align: left;","padding: 5px;","}","".concat(s," .").concat(this.thankYouClassName," {"),"margin-bottom: 0;","}","@media screen and (min-width: 580px) {","".concat(s," {"),"min-width: 560px;","}",X?["".concat(s," .").concat(this.notesClassName," {"),"padding-top: 22px","}","".concat(s," legend {"),"top: 0;","left: 0;","display: inline-block;","width: auto;","}"].join(""):"","".concat(s," br {"),"display: none","}","}","@media screen and (max-width: 579px) {","".concat(s," {"),"min-width: ".concat(240+(n.left+n.right/2),"px;"),"}","".concat(s," .").concat(this.notesClassName," button {"),"margin-bottom: 5px;","}","".concat(s," br {"),"display: block","}",X?["".concat(s," .").concat(this.notesClassName," {"),"padding-bottom: 35px;","}","".concat(s," legend {"),"bottom: 0;","left: 50%;","transform: translateX(-50%)","}","".concat(s," legend:nth-of-type(1) {"),"bottom: 15px;","}","".concat(s," legend:nth-of-type(2) {"),"left: 50%;","right: unset;","}","".concat(s," legend:nth-of-type(1)::before {"),'content: "0: ";',"}","".concat(s," legend:nth-of-type(2)::before{"),'content: "10: ";',"}"].join(""):"","".concat(s," textarea {"),"min-width: auto;","}","}"].join("")}return e}}]),e}();function ie(){return(ie=s(t.mark((function e(){var n,s,i;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=_(),s=n.domElement.querySelector(".".concat(n.contentClassName)),i=new se({parentContainer:n}),n.children=i,i.insertIn(s,"beforeend"),n.init().then((function(e){return e.response&&n.show()})),e.abrupt("return",{parentContainer:n,NPS:i});case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){ie.apply(this,arguments)}()}();
|
1
|
+
!function(){"use strict";var e,t=(function(e){var t=function(e){var t,n=Object.prototype,i=n.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},r=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",a=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,i){var s=t&&t.prototype instanceof f?t:f,r=Object.create(s.prototype),o=new k(i||[]);return r._invoke=function(e,t,n){var i=u;return function(s,r){if(i===m)throw new Error("Generator is already running");if(i===g){if("throw"===s)throw r;return A()}for(n.method=s,n.arg=r;;){var o=n.delegate;if(o){var a=S(o,n);if(a){if(a===p)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===u)throw i=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=m;var c=h(e,t,n);if("normal"===c.type){if(i=n.done?g:d,c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=g,n.method="throw",n.arg=c.arg)}}}(e,n,o),r}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var u="suspendedStart",d="suspendedYield",m="executing",g="completed",p={};function f(){}function v(){}function y(){}var b={};b[r]=function(){return this};var w=Object.getPrototypeOf,C=w&&w(w(_([])));C&&C!==n&&i.call(C,r)&&(b=C);var E=y.prototype=f.prototype=Object.create(b);function N(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function $(e,t){function n(s,r,o,a){var c=h(e[s],e,r);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==typeof u&&i.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,o,a)}),(function(e){n("throw",e,o,a)})):t.resolve(u).then((function(e){l.value=e,o(l)}),(function(e){return n("throw",e,o,a)}))}a(c.arg)}var s;this._invoke=function(e,i){function r(){return new t((function(t,s){n(e,i,t,s)}))}return s=s?s.then(r,r):r()}}function S(e,n){var i=e.iterator[n.method];if(i===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,S(e,n),"throw"===n.method))return p;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var s=h(i,e.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,p;var r=s.arg;return r?r.done?(n[e.resultName]=r.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,p):r:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,p)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function _(e){if(e){var n=e[r];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var s=-1,o=function n(){for(;++s<e.length;)if(i.call(e,s))return n.value=e[s],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}return{next:A}}function A(){return{value:t,done:!0}}return v.prototype=E.constructor=y,y.constructor=v,v.displayName=c(y,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,c(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},N($.prototype),$.prototype[o]=function(){return this},e.AsyncIterator=$,e.async=function(t,n,i,s,r){void 0===r&&(r=Promise);var o=new $(l(t,n,i,s),r);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},N(E),c(E,a,"Generator"),E[r]=function(){return this},E.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var i=t.pop();if(i in e)return n.value=i,n.done=!1,n}return n.done=!0,n}},e.values=_,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function s(i,s){return a.type="throw",a.arg=e,n.next=i,s&&(n.method="next",n.arg=t),!!s}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return s("end");if(o.tryLoc<=this.prev){var c=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return s(o.catchLoc,!0);if(this.prev<o.finallyLoc)return s(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return s(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return s(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc<=this.prev&&i.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var r=s;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,p):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var s=i.arg;T(n)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:_(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(e={exports:{}},e.exports),e.exports);function n(e,t,n,i,s,r,o){try{var a=e[r](o),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,s)}var i=function(e){return function(){var t=this,i=arguments;return new Promise((function(s,r){var o=e.apply(t,i);function a(e){n(o,s,r,a,c,"next",e)}function c(e){n(o,s,r,a,c,"throw",e)}a(void 0)}))}};const s=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),r=()=>{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},o=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},a=()=>o()||!!window.ABTasty.getTestsOnPage()[TEST_ID],c=()=>["consentReady","cnilReady"].some((e=>window.ABTasty&&Object.prototype.hasOwnProperty.call(window.ABTasty,e)&&!0===window.ABTasty[e])),l="style",h="layout",u="colorpicker",d="number",m="switch",g="remove",p="rebuild",f="rgba(57, 57, 57, 1)",v="https://social-proof-api.abtasty.com/clients/",y=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},b=()=>{const e=y();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},w=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,C=e=>{if((()=>{if(s()||o())return!1;const e=ABTasty.getTestsOnPage()[TEST_ID];return!!e&&Object.keys(e.targetings.qaParameters).length>0})()){const t=b();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}},E=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise(((e,n)=>{t.resolve=e,t.reject=n})),t},N=(e,t,n)=>{let i=0,s=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return C(i),"function"==typeof n&&n(i)}function r(){clearInterval(s),clearTimeout(i)}return i=setTimeout((()=>{r();const t=`Can't find element «${e}».`;return C(t),"function"==typeof n&&n(t)}),1e4),s=setInterval((()=>{const n=document.querySelector(e);return null!==n?(r(),"function"==typeof t&&t(n)):n}),200),{clear:r}};function $(e,t){return t(e)||!e.parentElement?e:$(e.parentElement,t)}const S=e=>{s()||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};function x(){return"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||(e="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver",new Promise(((t,n)=>{const i=window.document.getElementsByTagName("script")[0],s=window.document.createElement("script");s.src=e,i.parentNode.insertBefore(s,i),s.onload=t,s.onerror=n})));var e}class T{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach((e=>{e.isIntersecting?(this.existingTargets.forEach((t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())})),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter((t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1)))}))}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const n=this.inViewportTargets.find((({element:n,selector:i})=>{if(n.isSameNode(e))return!0;const s=[...e.querySelectorAll(i)];if(s.length){if(s.includes(n))return!0}if(t.includes(n))return!0;const r=[...e.parentElement.children],o=r.findIndex((t=>t.isSameNode(e))),a=r.filter(((e,t)=>t>o));if(a.length){if(a.includes(n))return!0;if(a.some((e=>[...e.querySelectorAll(i)].includes(n))))return!0}return!1}));if(n&&this.isElementVisible(n.element)){const{selector:e,element:t,uniqueId:i}=n,s=this.targets.find((t=>t.selector===e&&t.uniqueId===i));s&&s.resolve(t),this.clear(e,i)}}mouseOverHandler(){const e=["mouseover",e=>setTimeout((()=>this.onMouseOver(e)),50),!0];return{start:()=>document.addEventListener(...e),clear:()=>document.removeEventListener(...e)}}isElementVisible(e){return this.isElementTopmost(e)&&this.isElementOpaque(e)}isElementOpaque(e){return"HTML"===$(e,(e=>"0"===window.getComputedStyle(e).opacity)).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),n=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let i=!1,s=0;for(;!i&&s<n.length;){const t=document.elementFromPoint(...n[s]);i=e===t||e.contains(t),s+=1}return i}checkElements(){this.targets.forEach((({selector:e,uniqueId:t})=>{const n=document.querySelector(e);n&&!this.existingTargets.find((n=>n.element.matches(e)&&n.uniqueId===t))&&(this.existingTargets.push({element:n,selector:e,uniqueId:t}),this.visibilityObserver.observe(n))})),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:n})=>{if(t.matches(e)&&this.isElementVisible(t)){const i=this.targets.find((t=>t.selector===e&&t.uniqueId===n));return i&&i.resolve(t),this.clear(e,n),!1}return!0}))}watch(e,t,n){this.targets.push({selector:e,resolve:t,uniqueId:n});const i=()=>{this.startMutationObserver(),this.checkElements()};document.body?i():N("body",i)}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map((n=>n.filter((({selector:n,uniqueId:i})=>n!==e&&i!==t))));const n=document.querySelector(e);n&&this.visibilityObserver.unobserve(n),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class k{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:n}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*n,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const n=E(`${this.event}DomReady`);this.promises.push(n);const i=await this.onPageLoad(n),s=await async function(e){let t;switch(e){case"IntersectionObserver":t=await x();break;default:t=!0}return t}("IntersectionObserver"),r=new T;if(this.visibilityObservers.push(r),s&&i){const e=w();r.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const n=()=>"complete"===document.readyState;if(!n()){const i=["readystatechange",()=>n()&&t(!0),{passive:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),e}return t(!0),e}onClick({promise:e,resolve:t}){const n=document.createElement("style");n.type="text/css",n.id=`Click_${w()}`,n.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(n),this.elementsSelectors.push(`#${n.id}`);const i=e=>[...document.querySelectorAll(this.selector)].some((t=>t.isSameNode(e)||!!e.closest(this.selector))),s=["click",({target:e})=>i(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(s),document.addEventListener(...s),e}onExitIntent({promise:e,resolve:t}){const n=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],i=N("body",(e=>{e.addEventListener(...n),this.eventsListeners.push([e,...n]),this.elementsWaiters=this.elementsWaiters.filter((e=>e!==i))}));return this.elementsWaiters.push(i),e}onReengage({promise:e,resolve:t}){const n=this.delay;let i=n;const s=[()=>(i=n,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach((e=>{document.addEventListener(e,...s),this.eventsListeners.push([e,...s])}));const r=setInterval((()=>{i<=0?t(!0):i-=100}),100);return this.intervals.push(r),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:n}=DATA;return new Function(`return new Promise(async resolve => {${n}})`)().then((e=>e&&t(!0))),e}getSocialProofPurchases({promise:e,resolve:t}){const n=window.ABTastyProductKey,i=r(),{viewInterval:s,triggerSocialProofMinPurchases:o,spNoTrim:a}=DATA;if(n||(C("Not able to find ABTastyProductKey, impossible to call the API."),t(!1)),n&&i){fetch(`${v}${i}/metrics/i?key=${n}${a?"&noTrim=true":""}`).then((e=>e.ok&&e.json())).then((e=>(e=>{if(void 0===s||void 0===o)return!1;const t=void 0!==e[s]&&e[s]>=o;return t||C(`Widget will not be shown, product has been purchased ${e[s]} times while ${o} are required`),t})(e)&&t(`${e[s]}`))).catch((()=>C("Failed to fetch datas from server.")))}else t(!1);return e}getSocialProofPageViews({promise:e,resolve:t}){const{viewInterval:n,triggerSocialProofMinPageViews:i,spNoTrim:s}=DATA,o=encodeURIComponent(s?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),a=r();if(o&&a){fetch(`${v}${a}/metrics/pv?key=${o}${s?"&noTrim=true":""}`).then((e=>e.ok&&e.json())).then((e=>(e=>{if(void 0===n||void 0===i)return!1;const t=void 0!==e[n]&&e[n]>=i;return t||C(`Widget will not be shown, page has been seen ${e[n]} times while ${i} are required`),t})(e)&&t(`${e[n]}`))).catch((()=>C("Failed to fetch datas from server.")))}else t(!1);return e}onConsent({promise:e,resolve:t}){if(!c()){const n=["consentValid",()=>t(!0)];return this.eventsListeners.push(n),document.addEventListener(...n),e}return t(!0),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,...n]="string"==typeof e[0]?[document,...e]:e;t&&n.length>1&&t.removeEventListener(...n)})),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach((e=>clearInterval(e))),this.intervals=[]),this.observers.length&&(this.observers.forEach((e=>e.disconnect())),this.observers=[]),this.visibilityObservers.length){const e=w();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.elementsWaiters.length&&(this.elementsWaiters.forEach((e=>e.clear())),this.elementsWaiters=[]),this}async isTriggered(){this.clear();const e=E(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),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},n=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();this.clear();return"reengage"!==this.event&&this.delay?n&&await(async()=>{const e=E(`${this.event}Delay`);return this.promises.push(e),setTimeout((()=>{e.resolve(!0),this.clear()}),this.delay),e.promise})():n}}const _="display",A="closing",P="validation",B="ABTastyWidgets",L="ABTastyWidgetsTemporary";class I{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:n},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(n),this.onSetCallback=i,this.widgetName=y(),this.uniqueId=w(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(L),n=sessionStorage.getItem(B);"ABTastyData"===e&&!t&&n&&localStorage.setItem(L,n)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(B);return JSON.parse(t)}catch(t){return e.removeItem(B),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:n,...i}=t;return Object.entries(i).length?(e.setItem(B,JSON.stringify(i)),i):(e.removeItem(B),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=localStorage.getItem(L),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(B,e),localStorage.removeItem(L));const n=this.getLocalRecurrence(),i=(n?parseFloat(n.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&i&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const n=this.getTypeOfStorage(e);if(o()||!n&&"object"!=typeof n)return!1;const{storageString:i,storageMethod:s}=n,r=this.getStamp(e),a={type:t,stamp:r},{type:l}=this.getCurrentRecurrence(),h=async()=>{if(!c()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=a;const e=new k({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let n;"session"===i?e?n=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),n=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?n=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),n=this.getLocalRecurrenceStorageParsed()));const r=n?{[this.recurrenceKey]:a,...n}:{[this.recurrenceKey]:a};s.setItem(B,JSON.stringify(r)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!s)return!1;if(l&&t!==P)if(t===A&&l!==P)h();else{if(t!==_||l===P||l===A)return!1;h()}else h();return r}setDisplayRecurrence(){this.setRecurrence(this.displayRecurrence,"display")}setClosingRecurrence(){this.setRecurrence(this.closingRecurrence,"closing")}setValidationRecurrence(){this.setRecurrence(this.validationRecurrence,"validation")}getStamp(e){return(new Date).getTime()+864e5*e}getTypeOfStorage(e){return!(isNaN(e)||e<0||0!==e&&!e)&&(e>0?{storageString:"local",storageMethod:window.localStorage}:0===e&&{storageString:"session",storageMethod:window.sessionStorage})}}class O{constructor(e,t,n){this.recurrence=e,this.isWidgetApplied=t,this.callback=n,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=["abtasty_resetActionTracking",this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=a(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},i=()=>{const t=this.recurrenceIsDone();return e&&"display"===n||t};return!this.isWidgetApplied()&&t&&i()?(this.clearWatcher(),this.callback(p,e)):(!this.isWidgetApplied()||t&&i())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback(g,e),this.watch()),this}eventHandler(){let e=a();return[250,500].forEach((t=>setTimeout((()=>500===t&&a()===e?this:(e=a(),this.decisionHandler(!1))),t))),this}observerHandler(e){const t=e.some((({removedNodes:e})=>e&&e.length)),n=e.some((({addedNodes:e})=>e&&e.length));return t||n?(this.decisionHandler(!0),this):this}watch(){if(s())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const e=N("body",(t=>{const n=[t,{childList:!0,subtree:!0}];this.observer.observe(...n),this.elementsWaiters=this.elementsWaiters.filter((t=>t!==e))}));return this.elementsWaiters.push(e),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach((e=>e.clear())),this.elementsWaiters=[]),this.observer.disconnect(),this}}const R=/.+\/([^.]+)\.(otf|ttf)$/;class j{constructor(){this.children=void 0,this.uniqueId=w(),this.widgetName=y(),this.prettyName=b(),this.recurrenceParams=(()=>{const{displayRecurrence:e,closingRecurrence:t,validationRecurrence:n}=DATA;if(s()||!e&&!t&&!n)return!1;const i={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 e&&(r.displayRecurrence=i[e]("displayRecurrence")),t&&(r.closingRecurrence=i[t]("closingRecurrence")),n&&(r.validationRecurrence=i[n]("validationRecurrence")),r})(),this.triggerParams=(()=>{let{triggerEvent:e}=DATA;const{triggerEventClick:t,triggerEventReengageDelay:n,socialProofContentType:i,triggerEventElementVisible:r,triggerEventDelay:o}=DATA;if(s()||!e&&!i)return!1;const a={click:()=>t,elementVisible:()=>r},c=Object.prototype.hasOwnProperty.call(a,e)?a[e]():"body",l="reengage"===e?n:o;return i&&(e=1===i?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:e,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new I(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new k(this.triggerParams),this.pageWatcher=new O(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||(!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some((e=>e===t)))})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach((e=>document.removeEventListener(...e))),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach((e=>clearInterval(e))),this.intervals=[]),this.observers.length&&(this.observers.forEach((e=>e.disconnect())),this.observers=[]),this.promises.length&&(this.promises.forEach((e=>e.resolve(!1))),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach((e=>e.clear())),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&!!this.domElement.closest("html")}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){const e=(e,t,n)=>{this.elementsWaiters=this.elementsWaiters.filter((e=>e!==t)),n(e)},t=new Promise(((t,n)=>{const i=N("head",(e=>{this.elementsWaiters=this.elementsWaiters.filter((e=>e!==i)),t(e.appendChild(this.styleElement))}),(t=>e(t,i,n)));this.elementsWaiters.push(i)})),n=new Promise(((t,n)=>{const{layout:i,elementReferrer:s,referrerInsertType:r}=DATA,{selector:o,position:a}="string"==typeof i&&"free"===i&&"string"==typeof s&&"string"==typeof r?{selector:s,position:r}:{selector:"body",position:"beforeend"},c=N(o,(e=>{this.elementsWaiters=this.elementsWaiters.filter((e=>e!==c)),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))}),(t=>e(t,c,n)));this.elementsWaiters.push(c)}));return Promise.all([n,t]).then((()=>this))}remove(){return this.pageWatcher.clearWatcher(),this.domElement&&this.domElement.closest("html")&&this.domElement.remove(),this.styleElement&&this.styleElement.closest("html")&&this.styleElement.remove(),this.hasOncePerPageTrigger?this.pageWatcher.watch():s()||this.init().then((({response:e})=>e?this.show():this)),this}show(){return this.hasBeenShown||s()||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return this.hasBeenShown&&!s()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(e){if(!s()&&!a())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const t=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!t)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const n=s()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!n&&(await this.insert(),this.addCloseEvent(),s()||e||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(n),{container:this,response:n})}onPageChange(e,t){const n=()=>this.init().then((({response:e})=>e&&this.show()));switch(t||(this.hasBeenShown=!1),e){case g:this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case p:this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then((e=>e.show())):n()}}addCloseEvent(...e){const{closeButton:t,overlay:n,overlayClickable:i,layout:r}=DATA,o=[];if(void 0!==n&&!0!==n||!0!==i||"popin"!==r||o.push(`.${this.overlayClassName}`),void 0!==t&&t&&o.push(`.${this.closeButtonClassName}`),!o.length)return this;const a=this.domElement.querySelectorAll(o.join(", "));return a.length?(e.push(...a),e.forEach((e=>{s()&&(e.dataset.abtastyActionnable="true"),e.addEventListener("click",(e=>{S(e),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout((()=>this.remove()),1e3)}),{once:!0,capture:!0})})),this):this}getDom(){const{closeButton:e,layout:t,overlay:n=!0}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.innerHTML=`\n\t\t\t${"popin"===t&&!0===n?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,i}loadFont(e,t){if(!e||"inherit"===e)return;const n=document.createElement("style"),i=t.match(R)?t.match(R)[1]:"";n.appendChild(document.createTextNode(`\t\t\t@font-face { \t\tfont-family: '${e}_${i}'; src: url('${t}');\t\t\t}\t\t`)),document.head.appendChild(n)}getStyleTag(e=""){const{noStyles:t,layout:n}=DATA,{backgroundColor:i,isBackgroundImage:r,backgroundImage:o,backgroundSize:a,backgroundPosition:c,backgroundRepeat:l,borderColor:h,borderRadius:u,borderWidth:d,textColor:m,textAlign:g,fontName:p,fontStyle:v,fontSize:y,isTitle:b,titleTextAlign:w,titleTextColor:C,titleFontName:E,titleFontStyle:N,titleFontSize:$,overlay:S,overlayColor:x,dropShadow:T,dropShadowColor:k,dropShadowBlur:_,containerMargin:A,containerPadding:P,closeButton:B,closeButtonPosition:L,closeButtonSize:I,closeButtonBorderRadius:O,closeButtonBorderWidth:j,closeButtonBorderColor:W,closeButtonColor:D,closeButtonBackgroundColor:q,buttonsBorderWidth:F,buttonsBorderColor:H,buttonsBorderRadius:V,buttonsBackgroundColor:M,buttonsTextColor:z,buttonsFontName:Y,buttonsFontStyle:U,buttonsFontSize:G}=t?{}:DATA,K=document.createElement("style");K.type="text/css",s()&&K.setAttribute("abtasty-script-added","true"),this.loadFont(p,v),this.loadFont(E,N),this.loadFont(Y,U);const Q=`background: ${["string"==typeof i?i:"rgba(255, 255, 255, 1)",r&&"string"==typeof o&&o.length?`url(${o})`:"",r&&"string"==typeof c&&"100% 100%"!==a?c:"0 0",r&&"string"==typeof a?`/ ${a}`:"/ auto",r&&l&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,J="number"==typeof d&&d>0,X=`border: ${[J?`${d}px`:"unset",J?"solid":"",J&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,Z=void 0!==u?`border-radius: ${u}px;`:"",ee=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",te=void 0!==g?`text-align: ${g};`:"",ne=p&&"inherit"!==p?`font-family:${p}_${v.match(R)?v.match(R)[1]:""};`:v||"",ie=y?`font-size: ${y}px;`:"",se=void 0!==T&&T?`box-shadow: 0 5px ${_}px 0 ${k};`:"",re=A instanceof Array&&1===A.length&&A[0],oe=re?`margin: ${re.top}px ${re.right}px ${re.bottom}px ${re.left}px;`:"",ae=re?`margin: calc(${re.top}px * 0.5) calc(${re.right}px * 0.5) calc(${re.bottom}px * 0.5) calc(${re.left}px * 0.5);`:"",ce=P instanceof Array&&1===P.length&&P[0],le=ce?`padding: ${ce.top}px ${ce.right}px ${ce.bottom}px ${ce.left}px;`:"",he=ce?`padding: calc(${ce.top}px * 0.5) calc(${ce.right}px * 0.5) calc(${ce.bottom}px * 0.5) calc(${ce.left}px * 0.5);`:"",ue=void 0!==F&&F?`border-width: ${F}px; border-style: solid;`:"",de=[H,F].every((e=>void 0!==e))&&F?`border-color: ${H};`:"",me=void 0!==V?`border-radius: ${V}px;`:"",ge=void 0!==M?`background-color: ${M};`:"",pe=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",fe=Y&&"inherit"!==Y?`font-family:${Y}_${U.match(R)?U.match(R)[1]:""};`:U||"",ve=G?`font-size: ${G}px;`:"",ye="popin"!==n||void 0!==S&&!0!==S?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==x?x:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),be="number"==typeof I?I:16,we=be/2,Ce=t||void 0!==B&&B?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===L?`bottom: calc(100% + ${we}px)`:`top: ${we}px`)+";",`right: ${we}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","line-height: 0;",""+("number"==typeof O?`border-radius: ${O}px;`:""),""+("number"==typeof j&&j>0?`border: ${j}px solid ${void 0!==W?W:f};`:""),""+("string"==typeof q?`background-color: ${q};`:""),"}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${be}px;`,`height: ${be}px;`,""+("string"==typeof D?`fill: ${D};`:""),"}"].join(""):"",Ee=b&&"string"==typeof C?[`#${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: ${C}; fill: ${C}; -webkit-text-fill-color: ${C};`,void 0!==w?`text-align: ${w};`:"",E&&"inherit"!==E?`font-family:${E}_${N.match(R)?N.match(R)[1]:""};`:N||"",$?`font-size: ${$}px;`:"","}"].join(""):"";return K.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,Q,Z,X,ee,te,se,oe,ne,ie,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,ee,te,ne,ie,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",le,ne,ie,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,"box-sizing: border-box;","display: inline-block;",ue,de,me,ge,pe,fe,ve,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button * {`,pe,fe,ve,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,ae,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,he,"}","}",ye,Ce,Ee,`${e}`].join(""),K}}const W=["top: 0;","top: 50%;","bottom: 0;"],D=["left: 0;","left: 50%;","right: 0;"],q=e=>1===e?"-50%":0,F=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,n=`translate(${q(t)}, ${q(e)});`;return`${W[e]}${D[t]}transform: ${n}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},H=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,V=()=>{if(H())return"width: auto;height: auto;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:n,autoHeight:i,popinPercentHeight:s,popinPixelsHeight:r,heightUnit:o}=DATA;return`width: ${"px"===n?t:e}${n};height: ${i?"auto":`${"px"===o?r:s}${o}`};`};class M extends j{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"opacity: 1;","transition: opacity 0.25s ease;","background: none;","}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",F(),V(),"}",`${H()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","}"].join("")}`,"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class z extends j{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;",`${this.position}: 0;`,"left: 0;","width: 100%;","height: auto;",`z-index: ${"custom"===e?t:e};`,"opacity: 1;","transition: opacity 0.25s ease;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class Y extends j{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const U=()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new M;break;case"bannerTop":case"bannerBottom":t=new z;break;case"free":t=new Y;break;default:t=new j}return t},G={category:h,type:"select",options:[{label:"px",value:"px"},{label:"%",value:"%"},{label:"em",value:"em"},{label:"vw (% of viewport width)",value:"vw"},{label:"vh (% of viewport height)",value:"vh"},{label:"vmin (% of viewport minimum size)",value:"vmin"},{label:"vmax (% of viewport maximum size)",value:"vmax"}]},K={category:h,type:m,propName:"autoHeight",label:"widget_common_layout_toggler_label_keepHeightAuto",value:!0},Q={category:h,propName:"widthUnit",value:"vw",...G},J={category:h,propName:"heightUnit",value:"vh",condition:({autoHeight:e})=>!e,...G},X={category:h,type:d,label:"widget_common_layout_popinDimensions_label_width"},Z={...X,propName:"popinPercentWidth",value:50,max:100,condition:({widthUnit:e,layout:t})=>"px"!==e&&"popin"===t},ee={...X,propName:"popinPixelsWidth",value:parseInt(window.innerWidth/2.5,10),max:window.innerWidth,condition:({widthUnit:e,layout:t})=>"px"===e&&"popin"===t},te={category:h,type:d,label:"widget_common_layout_popinDimensions_label_height",condition:({autoHeight:e})=>!e},ne={...te,propName:"popinPercentHeight",value:50,max:100,condition:({autoHeight:e,heightUnit:t,layout:n})=>!e&&"px"!==t&&"popin"===n},ie={...te,propName:"popinPixelsHeight",value:parseInt(window.innerHeight/2.5,10),max:window.innerHeight,condition:({autoHeight:e,heightUnit:t,layout:n})=>!e&&"px"===t&&"popin"===n},se=({autoWidth:e})=>!e;[Z,ee,Q,K,ne,ie,J].map((e=>{if("condition"in e){const t=e.condition,n=e=>t(e)&&se(e);return{...e,condition:n}}return{...e,condition:se}}));const re="closeButton",oe={category:l,type:"radio",label:"widget_common_style_closeButton_radio_closeButtonPosition",propName:"closeButtonPosition",value:"in",options:[{label:"widget_common_style_closeButton_radio_closeButtonPosition_option_inside",value:"in"},{label:"widget_common_style_closeButton_radio_closeButtonPosition_option_outside",value:"out"}]},ae={category:l,type:d,label:"widget_common_style_closeButton_label_closeButtonSize",propName:"closeButtonSize",value:16,min:10,max:50},ce={category:l,type:u,label:"widget_common_style_closeButton_label_closeButtonColor",propName:"closeButtonColor",value:"rgba(119, 119, 119, 1)"},le={category:l,type:u,label:"widget_common_style_closeButton_label_closeButtonBackgroundColor",propName:"closeButtonBackgroundColor",value:"rgba(255, 255, 255, 0)"},he={category:l,type:"slider",label:"widget_common_style_closeButton_label_closeButtonBorderRadius",propName:"closeButtonBorderRadius",value:0,min:0,max:50},ue={...he,label:"widget_common_style_closeButton_label_closeButtonBorderThickness",propName:"closeButtonBorderWidth"},de={category:l,type:u,label:"widget_common_style_closeButton_label_closeButtonBorderColor",propName:"closeButtonBorderColor",value:f},me=[{field:re}];de.conditions=[{field:ue.propName,value:e=>e>0}],[oe,ae,ce,le,he,ue,de].map((e=>{const t=e.conditions||[];return t.push(me[0]),{...e,conditions:t}}));var ge=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e};var pe=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function fe(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var ve=function(e,t,n){return t&&fe(e.prototype,t),n&&fe(e,n),e};function ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(n),!0).forEach((function(t){ge(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ye(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var we=DATA,Ce=we.isFeedBackQuestion,Ee=we.isThankYouMessage,Ne=we.autoHide,$e=we.timeHide,Se=we.stepToShow,xe=we.question,Te=we.feedbackQuestion,ke=we.buttonText,_e=we.thankYouMessage,Ae=we.isLegend,Pe=we.minLegend,Be=we.maxLegend,Le=we.noStyles,Ie={capture:!0,passive:!1},Oe=function(){function e(t){var n=t.parentContainer;pe(this,e),this.parentContainer=n,this.baseClassName="nps_container",this.className="".concat(this.baseClassName,"_").concat(n.uniqueId),this.questionClassName="".concat(this.baseClassName,"_question"),this.notesClassName="".concat(this.baseClassName,"_notes"),this.feedbackQuestionClassName="".concat(this.questionClassName,"_feedback"),this.feedbackFormClassName="".concat(this.questionClassName,"_feedback_form"),this.notesButtonsClassName="".concat(this.notesClassName,"_button"),this.thankYouClassName="".concat(this.baseClassName,"_thanks"),this.hideClassName="nps_".concat(n.uniqueId,"_display_none"),this.currentNote=NaN,this.userFeedback="",this.npsContainer=this.getContainer(),this.questionElement=this.getQuestionElement(),this.notesContainer=this.getNotesElement(),this.feedbackElements=this.getFeedBackElements(),this.thankYouElement=this.getThankYouElement(),this.npsElement=this.getNPSElement(),this.styleElement=this.getStyleElement()}return ve(e,[{key:"sendNote",value:function(){if(!s()&&!isNaN(this.currentNote))try{window.abtasty.send("nps",{ns:this.currentNote,nf:this.userFeedback})}catch(e){C("Not able to send NPS hit due to old tag version (< 3.0)")}return this}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.npsElement),this}},{key:"complete",value:function(){var e=this;return this.sendNote(),Ne?(setTimeout((function(){e.parentContainer.hide(),setTimeout((function(){e.parentContainer.recurrence.setValidationRecurrence(),e.parentContainer.remove(),e.showNotes(),e.currentNote=NaN,e.userFeedback="",e.feedbackElements.feedbackFormElement.querySelector("textarea").value=""}),1e3)}),1e3*$e),this):this}},{key:"onClickNote",value:function(e){this.currentNote=Number(e.target.dataset.note),Ce&&Te&&Te.length?this.showFeedBack():Ee&&_e&&_e.length?this.showThankYouMessage():this.complete()}},{key:"onFeedbackSend",value:function(){Ee&&_e&&_e.length?this.showThankYouMessage():this.complete()}},{key:"showNotes",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),[this.questionElement,this.notesContainer].forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showFeedBack",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),Object.values(this.feedbackElements).forEach((function(t){return t.classList.remove(e.hideClassName)})),this}},{key:"showThankYouMessage",value:function(){var e=this;return this.npsContainer.childNodes.forEach((function(t){return t.classList.add(e.hideClassName)})),this.thankYouElement.classList.remove(this.hideClassName),this.complete(),this}},{key:"getThankYouElement",value:function(){var e=document.createElement("p");return e.className="".concat(this.thankYouClassName," ").concat(this.hideClassName),e.innerHTML=_e,s()&&"displayThanksStep"===Se&&e.classList.remove(this.hideClassName),e}},{key:"getFeedBackElements",value:function(){var e=this,t=document.createElement("p");t.className="".concat(this.feedbackQuestionClassName," ").concat(this.hideClassName),t.innerHTML=Te;var n=document.createElement("form");n.className="".concat(this.feedbackFormClassName," ").concat(this.hideClassName),n.addEventListener("submit",S,be({},Ie));var i=document.createElement("textarea");i.className="".concat(this.feedbackQuestionClassName,"_textarea");var r=document.createElement("button");return r.className="".concat(this.feedbackQuestionClassName,"_button"),r.innerHTML="<span>".concat(ke,"</span>"),r.addEventListener("click",(function(t){return S(t),e.userFeedback=i.value,e.onFeedbackSend()}),be({},Ie)),s()&&"displayFeedbackStep"===Se&&[t,n].forEach((function(t){return t.classList.remove(e.hideClassName)})),n.appendChild(i),n.appendChild(r),{feedbackQuestionElement:t,feedbackFormElement:n}}},{key:"getNotesElement",value:function(){var e=this,t=document.createElement("div");t.className=this.notesClassName,s()&&"displayNoteStep"!==Se&&t.classList.add(this.hideClassName);for(var n=10;n>=0;){var i=document.createElement("button");i.className=this.notesButtonsClassName,i.dataset.note=n,s()&&i.setAttribute("data-abtasty-actionnable",""),i.innerHTML+="<span>".concat(n,"</span>"),i.addEventListener("click",(function(t){S(t),e.onClickNote(t)}),be({},Ie)),t.insertAdjacentElement("afterbegin",i),5===n&&i.insertAdjacentHTML("afterend","<br>"),n-=1}return Ae&&(t.insertAdjacentHTML("afterbegin","<legend>".concat(Pe,"</legend>")),t.insertAdjacentHTML("beforeend","<legend>".concat(Be,"</legend>"))),t}},{key:"getQuestionElement",value:function(){var e=document.createElement("p");return e.className=this.questionClassName,e.innerHTML=xe,s()&&"displayNoteStep"!==Se&&e.classList.add(this.hideClassName),e}},{key:"getContainer",value:function(){var e=document.createElement("div");return e.className="".concat(this.baseClassName," ").concat(this.className),e}},{key:"getNPSElement",value:function(){var e=this;return this.npsContainer.appendChild(this.questionElement),this.npsContainer.appendChild(this.notesContainer),Ce&&Object.values(this.feedbackElements).forEach((function(t){e.npsContainer.appendChild(t)})),Ee&&this.npsContainer.appendChild(this.thankYouElement),this.npsContainer}},{key:"getStyleElement",value:function(){var e=document.createElement("style");if(e.type="text/css",s()&&e.setAttribute("abtasty-script-added","true"),Le)e.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.className," .").concat(this.hideClassName," {"),"display: none !important;","}"].join("");else{var t=DATA.containerPadding,n=t instanceof Array&&1===t.length&&t[0],i="#".concat(this.parentContainer.widgetContainerId," .").concat(this.className);e.textContent=["".concat(i," .").concat(this.hideClassName," {"),"display: none !important;","}","".concat(i,","),"".concat(i," * {"),"all: unset;","box-sizing: border-box;","font-size: 10px;","line-height: 1;","font-family: sans-serif;","}","".concat(i," > * {"),"display: block;","width: 100%;","}","".concat(i," .").concat(this.notesClassName," {"),"position: relative;","display: inline-block;","width: auto;","}","".concat(i," p {"),"margin-bottom: 15px;","font-size: 1.4em;","}","".concat(i," button {"),"vertical-align: middle;","cursor: pointer;","text-align: center;","}","".concat(i," button span {"),"font-size: 1.4em;","pointer-events: none;","}","".concat(i," .").concat(this.notesClassName," button {"),"margin: 0 5px;","width: 30px;","height: 30px;","}","".concat(i," .").concat(this.feedbackFormClassName," span {"),"display: block;","padding: 6px 24px;","}",Ae?["".concat(i," legend {"),"position: absolute;","text-decoration: none;","border: none;","font-size: 1em;","}","".concat(i," legend:nth-of-type(2) {"),"left: auto;","right: 0;","}"].join(""):"","".concat(i," textarea {"),"display: block;","width: 100%;","min-width: 310px;","min-height: 60px;","font-size: 1.4em;","border: 1px solid grey;","border-radius: 4px;","resize: vertical;","margin-bottom: 10px;","text-align: left;","padding: 5px;","}","".concat(i," .").concat(this.thankYouClassName," {"),"margin-bottom: 0;","}","@media screen and (min-width: 580px) {","".concat(i," {"),"min-width: 560px;","}",Ae?["".concat(i," .").concat(this.notesClassName," {"),"padding-top: 22px","}","".concat(i," legend {"),"top: 0;","left: 0;","display: inline-block;","width: auto;","}"].join(""):"","".concat(i," br {"),"display: none","}","}","@media screen and (max-width: 579px) {","".concat(i," {"),"min-width: ".concat(240+(n.left+n.right/2),"px;"),"}","".concat(i," .").concat(this.notesClassName," button {"),"margin-bottom: 5px;","}","".concat(i," br {"),"display: block","}",Ae?["".concat(i," .").concat(this.notesClassName," {"),"padding-bottom: 35px;","}","".concat(i," legend {"),"bottom: 0;","left: 50%;","transform: translateX(-50%)","}","".concat(i," legend:nth-of-type(1) {"),"bottom: 15px;","}","".concat(i," legend:nth-of-type(2) {"),"left: 50%;","right: unset;","}","".concat(i," legend:nth-of-type(1)::before {"),'content: "0: ";',"}","".concat(i," legend:nth-of-type(2)::before{"),'content: "10: ";',"}"].join(""):"","".concat(i," textarea {"),"min-width: auto;","}","}"].join("")}return e}}]),e}();function Re(){return(Re=i(t.mark((function e(){var n,i,s;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=U(),i=n.domElement.querySelector(".".concat(n.contentClassName)),s=new Oe({parentContainer:n}),n.children=s,s.insertIn(i,"beforeend"),n.init().then((function(e){return e.response&&n.show()})),e.abrupt("return",{parentContainer:n,NPS:s});case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){Re.apply(this,arguments)}()}();
|
package/package.json
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
{
|
2
|
-
"name": "@abtasty/nps",
|
3
|
-
"description": "Allow you to add a custom NPS on your website",
|
4
|
-
"version": "1.
|
5
|
-
"form": "dist/form.js",
|
6
|
-
"main": "dist/main.js",
|
7
|
-
"files": [
|
8
|
-
"dist"
|
9
|
-
],
|
10
|
-
"repository": "abtasty/widget",
|
11
|
-
"author": "Jonathan Granger",
|
12
|
-
"license": "MIT",
|
13
|
-
"scripts": {
|
14
|
-
"watch": "rollup -c --watch",
|
15
|
-
"build": "rollup -c"
|
16
|
-
},
|
17
|
-
"devDependencies": {
|
18
|
-
"@babel/core": "^7.12.8",
|
19
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
|
20
|
-
"@babel/plugin-transform-classes": "^7.12.1",
|
21
|
-
"@babel/plugin-transform-runtime": "^7.12.1",
|
22
|
-
"@babel/preset-env": "^7.12.11",
|
23
|
-
"@rollup/plugin-babel": "^5.2.2",
|
24
|
-
"@rollup/plugin-node-resolve": "^11.1.0",
|
25
|
-
"babel-eslint": "^10.0.3",
|
26
|
-
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
|
27
|
-
"eslint": "^7.18.0",
|
28
|
-
"eslint-config-airbnb-base": "^14.2.1",
|
29
|
-
"eslint-config-prettier": "^7.2.0",
|
30
|
-
"eslint-plugin-import": "^2.22.1",
|
31
|
-
"rollup": "^2.38.0",
|
32
|
-
"rollup-plugin-commonjs": "^10.1.0",
|
33
|
-
"rollup-plugin-eslint": "^7.0.0",
|
34
|
-
"rollup-plugin-terser": "^7.0.0"
|
35
|
-
},
|
36
|
-
"dependencies": {
|
37
|
-
"@abtasty/widget-utils": "^1.
|
38
|
-
}
|
39
|
-
}
|
1
|
+
{
|
2
|
+
"name": "@abtasty/nps",
|
3
|
+
"description": "Allow you to add a custom NPS on your website",
|
4
|
+
"version": "1.2.0",
|
5
|
+
"form": "dist/form.js",
|
6
|
+
"main": "dist/main.js",
|
7
|
+
"files": [
|
8
|
+
"dist"
|
9
|
+
],
|
10
|
+
"repository": "abtasty/widget",
|
11
|
+
"author": "Jonathan Granger",
|
12
|
+
"license": "MIT",
|
13
|
+
"scripts": {
|
14
|
+
"watch": "rollup -c --watch",
|
15
|
+
"build": "rollup -c"
|
16
|
+
},
|
17
|
+
"devDependencies": {
|
18
|
+
"@babel/core": "^7.12.8",
|
19
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
|
20
|
+
"@babel/plugin-transform-classes": "^7.12.1",
|
21
|
+
"@babel/plugin-transform-runtime": "^7.12.1",
|
22
|
+
"@babel/preset-env": "^7.12.11",
|
23
|
+
"@rollup/plugin-babel": "^5.2.2",
|
24
|
+
"@rollup/plugin-node-resolve": "^11.1.0",
|
25
|
+
"babel-eslint": "^10.0.3",
|
26
|
+
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
|
27
|
+
"eslint": "^7.18.0",
|
28
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
29
|
+
"eslint-config-prettier": "^7.2.0",
|
30
|
+
"eslint-plugin-import": "^2.22.1",
|
31
|
+
"rollup": "^2.38.0",
|
32
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
33
|
+
"rollup-plugin-eslint": "^7.0.0",
|
34
|
+
"rollup-plugin-terser": "^7.0.0"
|
35
|
+
},
|
36
|
+
"dependencies": {
|
37
|
+
"@abtasty/widget-utils": "^1.18.0"
|
38
|
+
}
|
39
|
+
}
|