@abtasty/social-proof 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # AB-tasty stress-test
2
+
3
+ This widget was generated using AB Tasty Widget CLI. You can find more infomation and documentation about widgets at https://abtasty.gitbooks.io/widget/.
4
+
5
+ ## Preview your widget
6
+
7
+ Launch your widget in a new window and watch for changes.
8
+ ```bash
9
+ npm start
10
+ ```
11
+
12
+ ## Main files
13
+
14
+ * `main.js`
15
+ Main source code of your widget
16
+ * `form.js`
17
+ Configuration form for your widget
18
+ * `icon.png`
19
+ Icon for your widget (recommended size: 200x200px)
20
+
21
+ You can specify each file location in the `package.json` like this:
22
+ ```json
23
+ "main": "dist/main.js",
24
+ "form": "dist/form.js",
25
+ "icon": "icon.png",
26
+ ```
27
+
28
+ ## Included
29
+
30
+ * [Rollup.js](https://rollupjs.org/) module bundler (like Webpack but smaller and faster).
31
+ * ES6 support using [Babel](https://babeljs.io/).
32
+ * JavaScript Linting with [ESLint](http://eslint.org/) and [Airbnb style](https://github.com/airbnb/javascript).
33
+ * JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
34
+ * [Prettier](https://prettier.io/) to format code.
35
+
36
+
37
+
38
+ **We heard your widget have an UI, so we allowed ourselves to include some extra:**
39
+ * [Pug](https://github.com/aMarCruz/rollup-plugin-pug) (aka Jade) to transforms html files into JS template.
40
+ * [PostCSS](https://github.com/egoist/rollup-plugin-postcss) to automatically append your CSS to head just using `import 'yourstyle.css'` and also use CSS plugins including:
41
+ * [CSSnext](http://cssnext.io/) to use the latest CSS syntax today.
42
+ * [cssnano](http://cssnano.co/) to minify CSS.
43
+
44
+
45
+
46
+ ## Add your widget to AB Tasty
47
+
48
+ 1. First, you'll need to have your widget on NPM:
49
+ * Create a minified bundle with `npm run build`
50
+ * Bump the version of your widget ([using semver](http://semver.org/)) with `npm version [patch|minor|major]`
51
+ * Publish it to NPM: `npm publish`
52
+ 2. Once your widget is on NPM, you can now add it on AB Tasty at https://marketplace.abtasty.com/publish.
package/dist/form.js CHANGED
@@ -1 +1 @@
1
- !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e=e||self).widgetForm=o()}(this,(function(){"use strict";var e=function(e,o){(null==o||o>e.length)&&(o=e.length);for(var t=0,n=new Array(o);t<o;t++)n[t]=e[t];return n};var o=function(o){if(Array.isArray(o))return e(o)};var t=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)};var n=function(o,t){if(o){if("string"==typeof o)return e(o,t);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(o,t):void 0}};var a=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var r=function(e){return o(e)||t(e)||n(e)||a()};const i="style",l="content",c="conditions",s="hidden",d="select",p="switch",u="slider",m="group",_="https://widgets-images.abtasty.com/",g={category:"conditions",type:"slider",min:1},y=[{...g,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...g,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...g,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],b={category:"conditions",type:"select",options:[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],value:"everytime"},f={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},v=y.map(e=>({...e,propName:`${f.propName}_${e.propName}`,conditions:[{field:f.propName,value:e.propName}]})),h={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},w=y.map(e=>({...e,propName:`${h.propName}_${e.propName}`,conditions:[{field:h.propName,value:e.propName}]})),N={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},S=y.map(e=>({...e,propName:`${N.propName}_${e.propName}`,conditions:[{field:N.propName,value:e.propName}]})),x={category:"conditions",type:m,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[f,...v,h,...w,N,...S]},k={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},P=(Object.keys(k).map(e=>k[e]),{category:"layout",type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${_}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${_}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${_}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${_}layout/icon-layout-freePlacement.png`}]}),T={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},C={category:"layout",type:"radio",propName:"referrerInsertType",value:"afterbegin",label:"widget_common_layout_positioning_label_selectPosition",options:[{label:"widget_common_layout_positioning_option_before",value:"beforebegin"},{label:"widget_common_layout_positioning_option_atTheBeginning",value:"afterbegin"},{label:"widget_common_layout_positioning_option_atTheEnd",value:"beforeend"},{label:"widget_common_layout_positioning_option_after",value:"afterend"}]},z=[{field:"layout",value:"free"}];T.conditions=z,C.conditions=z;const I={category:"layout",type:m,label:"widget_common_tabName_layout",collapsible:!0,children:[P,T,C]},O={category:i,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},A={category:i,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},j={category:i,type:"slider",label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},E={category:i,type:"slider",label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},D={category:i,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},$={category:i,type:"radioImage",label:"widget_common_style_text_label_textAlignment",propName:"textAlign",value:"center",style:"little",options:[{label:"widget_common_style_text_textAlignment_option_left",value:"left",src:`${_}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${_}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${_}style/icon-text-alignRight.png`}]},U={category:i,type:"areainput"},V={...U,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},B={...U,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},R={category:i,type:"switch",label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Q={category:i,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},W={category:i,type:"slider",label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},M={category:i,type:"switch",label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},X={category:i,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},H={category:i,type:"switch",label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},L=[{field:E.propName,value:e=>e>0}];A.conditions=L;const q={category:i,type:m,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[E,A,j]},K={category:i,type:m,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[$,D]},Z=[{field:"dropShadow",value:!0}];Q.conditions=Z,W.conditions=Z;const F={category:i,type:m,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[V,B,O,R,Q,W,M]},G={category:i,type:m,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[X,H],conditions:[{field:"layout",value:"popin"}]};var J=r(I.children);var Y=function(e,o,t){return o in e?Object.defineProperty(e,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[o]=t,e};function ee(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o&&(n=n.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,n)}return t}function oe(e){for(var o=1;o<arguments.length;o++){var t=null!=arguments[o]?arguments[o]:{};o%2?ee(Object(t),!0).forEach((function(o){Y(e,o,t[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ee(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}var te={category:l,propName:"socialProofContentType",type:d,value:1,label:{en:"Select the type of content you want to display",fr:"Choisissez le type de contenu à afficher",es:"Selecciona el tipo de contenido que quieres mostrar",de:"Wählen Sie die Art des Inhalts, den Sie anzeigen wollen"},options:[{label:{en:"Number of purchases",fr:"Nombre d'achats",es:"Número de compras",de:"Anzahl der Käufe"},value:1},{label:{en:"Number of views",fr:"Nombre de vues",es:"Número de visualizaciones",de:"Anzahl der Aufrufe"},value:2}]},ne={category:l,type:"textarea"},ae="Create your own content with the dynamic tags.",re="Créez votre propre contenu avec les variables.",ie="Crea tu propio contenido con las variables.",le="Erstellen Sie Ihren eigenen Inhalt mit den dynamischen Tags.",ce="Use !period! and !unit! to display the period duration selected and its unit (hours or days).",se="Utilisez !period! et !unit! pour afficher la durée de la période sélectionnée et son unité (heures ou jours).",de="Usa !period! y !unit! para mostrar la duración del período seleccionado y su unidad (horas o días).",pe="Verwenden Sie! Zeitraum !period! und !unit! um die ausgewählte Periodendauer und ihre Einheit (Stunden oder Tage) anzuzeigen.",ue=[{category:"content",propName:"socialProofInfo",type:"inlinenotification",label:"widget_socialProof_content_alert_transactionTag",hrefUrl:"https://abtasty.zendesk.com/hc/en-us/articles/360034533374"},{category:l,propName:"daysTranslations",type:s,value:{en:"days",fr:"jours",es:"días",de:"Tagen"}},{category:l,propName:"hoursTranslations",type:s,value:{en:"hours",fr:"heures",es:"horas",de:"Stunden"}},te,{category:l,propName:"viewInterval",type:d,value:"count_72hours",label:{en:"Select a period to display",fr:"Choisissez une période à afficher",es:"Seleccione un período para mostrar",de:"Wählen Sie einen Zeitraum für die Anzeige aus"},options:[{label:{en:"In the last 3 hours",fr:"Dans les 3 dernières heures",de:"In den letzen 3 Stunden",es:"En las últimas 3 horas"},value:"count_3hours"},{label:{en:"In the last 12 hours",fr:"Dans les 12 dernières heures",de:"In den letzen 12 Stunden",es:"En las últimas 12 horas"},value:"count_12hours"},{label:{en:"In the last 24 hours",fr:"Dans les 24 dernières heures",de:"In den letzten 24 Stunden",es:"En las últimas 24 horas"},value:"count_24hours"},{label:{en:"In the last 3 days",fr:"Dans les 3 derniers jours",de:"In den letzen 3 Tagen",es:"En los últimos 3 días"},value:"count_72hours"},{label:{en:"In the last 7 days",fr:"Dans les 7 derniers jours",de:"In den letzen 7 Tagen",es:"En los últmos 7 días"},value:"count_168hours"}]},oe({},ne,{label:{en:"".concat(ae,"\n\nUse !purchaseQty! for the number of purchased products.\n\n").concat(ce),fr:"".concat(re,"\n\nUtilisez !purchaseQty! pour afficher le nombre de produits achetés.\n\n").concat(se),es:"".concat(ie,"\n\nUsa !purchaseQty! por la cantidad de productos comprados.\n\n").concat(de),de:"".concat(le,"\n\nVerwenden Sie !purchaseQty! für die Anzahl der gekauften Produkte.\n\n").concat(pe)},propName:"socialProofContentPurchase",value:{en:"This item has been purchased !purchaseQty! times in the last !period! !unit!",fr:"Ce produit a été acheté !purchaseQty! fois depuis !period! !unit!",es:"Este producto se ha comprado !purchaseQty! veces en las últimas !period! !unit!",de:"Dieses Produkt wurde in den letzten !period! !unit! !purchaseQty! mal aufgerufen"},conditions:[{field:te.propName,value:1}]}),oe({},ne,{label:{en:"".concat(ae,"\n\nUse !views! for the number of pages seen.\n\n").concat(ce),fr:"".concat(re,"\n\nUtilisez !views! pour afficher le nombre de pages vues.\n\n").concat(se),es:"".concat(ie,"\n\nUsa !views! por el número de páginas vistas.\n\n").concat(de),de:"".concat(le,"\n\nVerwenden Sie !views! für die Anzahl der gesehenen Seiten.\n\n").concat(pe)},propName:"socialProofContentView",value:{en:"This page has been viewed !views! times in the last !period! !unit!",fr:"Cette page a été vue !views! fois depuis !period! !unit!",es:"Esta página se ha visto !views! veces en las últimas !period! !unit!",de:"Diese Seite wurde in den letzten !period! !unit! !views! mal gekauft"},conditions:[{field:te.propName,value:2}]})];K.collapsed=!1;var me=[K,F,q,G],_e={category:c,type:m,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,collapsed:!1,children:[{category:c,type:u,propName:"triggerSocialProofMinPurchases",label:{en:"Enter the minimum number of purchases to display the widget.",fr:"Entrez le minimum de produits achetés afin d'afficher le widget.",es:"Introduce el número de compras mínimo para mostrar el widget.",de:"Geben Sie die minimale Anzahl von gesehenen Seiten oder Käufen an, nach der das Widget angezeigt werden soll."},min:1,max:1e3,value:50,conditions:[{field:"socialProofContentType",value:1}]},{category:c,type:u,propName:"triggerSocialProofMinPageViews",label:{en:"Enter the minimum number of page views to display the widget.",fr:"Entrez le minimum de pages vues afin d'afficher le widget.",es:"Introduce el número de visitas mínimo para mostrar el widget."},min:1,max:1e3,value:200,conditions:[{field:"socialProofContentType",value:2}]},{category:c,type:p,propName:"autoHide",value:!1,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds"},{category:c,type:u,propName:"timeHide",min:5,max:120,value:10,label:"widget_common_conditions_triggering_delay_label",conditions:[{field:"autoHide",value:!0}]}]},ge={category:c,type:m,label:"widget_socialProof_conditions_noTrimParamUrl_blockTitle",collapsible:!0,collapsed:!0,children:[{category:c,type:p,propName:"spNoTrim",value:!1,label:"widget_socialProof_conditions_noTrimParamUrl_toggler_label"}]};x.children=x.children.filter((function(e){return e.propName.indexOf("validationRecurrence")<0}));var ye=[_e,x,ge];return[].concat(r(J),r(ue),r(me),r(ye))}));
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e=e||self).widgetForm=o()}(this,(function(){"use strict";var e=function(e,o){(null==o||o>e.length)&&(o=e.length);for(var t=0,n=new Array(o);t<o;t++)n[t]=e[t];return n};var o=function(o){if(Array.isArray(o))return e(o)};var t=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)};var n=function(o,t){if(o){if("string"==typeof o)return e(o,t);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(o,t):void 0}};var a=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var r=function(e){return o(e)||t(e)||n(e)||a()};const i="style",l="content",c="conditions",s="hidden",d="select",p="switch",u="slider",m="group",_="https://widgets-images.abtasty.com/",g={category:"conditions",type:"slider",min:1},y=[{...g,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...g,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...g,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],b={category:"conditions",type:"select",options:[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],value:"everytime"},f={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},v=y.map(e=>({...e,propName:`${f.propName}_${e.propName}`,conditions:[{field:f.propName,value:e.propName}]})),h={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},w=y.map(e=>({...e,propName:`${h.propName}_${e.propName}`,conditions:[{field:h.propName,value:e.propName}]})),N={...b,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},S=y.map(e=>({...e,propName:`${N.propName}_${e.propName}`,conditions:[{field:N.propName,value:e.propName}]})),x={category:"conditions",type:m,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[f,...v,h,...w,N,...S]},P={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},k=(Object.keys(P).map(e=>P[e]),{category:"layout",type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${_}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${_}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${_}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${_}layout/icon-layout-freePlacement.png`}]}),T={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},C={category:"layout",type:"radio",propName:"referrerInsertType",value:"afterbegin",label:"widget_common_layout_positioning_label_selectPosition",options:[{label:"widget_common_layout_positioning_option_before",value:"beforebegin"},{label:"widget_common_layout_positioning_option_atTheBeginning",value:"afterbegin"},{label:"widget_common_layout_positioning_option_atTheEnd",value:"beforeend"},{label:"widget_common_layout_positioning_option_after",value:"afterend"}]},O=[{field:"layout",value:"free"}];T.conditions=O,C.conditions=O;const I={category:"layout",type:m,label:"widget_common_tabName_layout",collapsible:!0,children:[k,T,C]},z={category:i,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},A={category:i,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},j={category:i,type:"slider",label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},E={category:i,type:"slider",label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},D={category:i,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},$={category:i,type:"radioImage",label:"widget_common_style_text_label_textAlignment",propName:"textAlign",value:"center",style:"little",options:[{label:"widget_common_style_text_textAlignment_option_left",value:"left",src:`${_}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${_}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${_}style/icon-text-alignRight.png`}]},U={category:i,type:"areainput"},V={...U,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},B={...U,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},R={category:i,type:"switch",label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Q={category:i,type:"colorpicker",label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},M={category:i,type:"slider",label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},W={category:i,type:"switch",label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},X={category:i,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},H={category:i,type:"switch",label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},L=[{field:E.propName,value:e=>e>0}];A.conditions=L;const K={category:i,type:m,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[E,A,j]},Z={category:i,type:m,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[$,D]},F=[{field:"dropShadow",value:!0}];Q.conditions=F,M.conditions=F;const G={category:i,type:m,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[V,B,z,R,Q,M,W]},q={category:i,type:m,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[X,H],conditions:[{field:"layout",value:"popin"}]};var J=r(I.children);var Y=function(e,o,t){return o in e?Object.defineProperty(e,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[o]=t,e};function ee(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o&&(n=n.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,n)}return t}function oe(e){for(var o=1;o<arguments.length;o++){var t=null!=arguments[o]?arguments[o]:{};o%2?ee(Object(t),!0).forEach((function(o){Y(e,o,t[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ee(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}var te={category:l,propName:"socialProofContentType",type:d,value:1,label:"widget_socialProof_content_variableSelect_label",options:[{label:{en:"Number of purchases",fr:"Nombre d'achats",es:"Número de compras",de:"Anzahl der Käufe"},value:1},{label:{en:"Number of views",fr:"Nombre de vues",es:"Número de visualizaciones",de:"Anzahl der Aufrufe"},value:2}]},ne={category:l,type:"textarea"},ae="Create your own content with the dynamic tags.",re="Créez votre propre contenu avec les variables.",ie="Crea tu propio contenido con las variables.",le="Erstellen Sie Ihren eigenen Inhalt mit den dynamischen Tags.",ce="Use !period! and !unit! to display the period duration selected and its unit (hours or days).",se="Utilisez !period! et !unit! pour afficher la durée de la période sélectionnée et son unité (heures ou jours).",de="Usa !period! y !unit! para mostrar la duración del período seleccionado y su unidad (horas o días).",pe="Verwenden Sie! Zeitraum !period! und !unit! um die ausgewählte Periodendauer und ihre Einheit (Stunden oder Tage) anzuzeigen.",ue=[{category:"content",propName:"socialProofInfo",type:"inlinenotification",label:"widget_socialProof_content_alert_transactionTag",hrefUrl:"https://abtasty.zendesk.com/hc/en-us/articles/360034533374"},{category:l,propName:"daysTranslations",type:s,value:{en:"days",fr:"jours",es:"días",de:"Tagen"}},{category:l,propName:"hoursTranslations",type:s,value:{en:"hours",fr:"heures",es:"horas",de:"Stunden"}},te,{category:l,propName:"viewInterval",type:d,value:"count_72hours",label:{en:"Select a period to display",fr:"Choisissez une période à afficher",es:"Seleccione un período para mostrar",de:"Wählen Sie einen Zeitraum für die Anzeige aus"},options:[{label:{en:"In the last 3 hours",fr:"Dans les 3 dernières heures",de:"In den letzen 3 Stunden",es:"En las últimas 3 horas"},value:"count_3hours"},{label:{en:"In the last 12 hours",fr:"Dans les 12 dernières heures",de:"In den letzen 12 Stunden",es:"En las últimas 12 horas"},value:"count_12hours"},{label:{en:"In the last 24 hours",fr:"Dans les 24 dernières heures",de:"In den letzten 24 Stunden",es:"En las últimas 24 horas"},value:"count_24hours"},{label:{en:"In the last 3 days",fr:"Dans les 3 derniers jours",de:"In den letzen 3 Tagen",es:"En los últimos 3 días"},value:"count_72hours"},{label:{en:"In the last 7 days",fr:"Dans les 7 derniers jours",de:"In den letzen 7 Tagen",es:"En los últmos 7 días"},value:"count_168hours"}]},oe({},ne,{label:{en:"".concat(ae,"\n\nUse !purchaseQty! for the number of purchased products.\n\n").concat(ce),fr:"".concat(re,"\n\nUtilisez !purchaseQty! pour afficher le nombre de produits achetés.\n\n").concat(se),es:"".concat(ie,"\n\nUsa !purchaseQty! por la cantidad de productos comprados.\n\n").concat(de),de:"".concat(le,"\n\nVerwenden Sie !purchaseQty! für die Anzahl der gekauften Produkte.\n\n").concat(pe)},propName:"socialProofContentPurchase",value:{en:"This item has been purchased !purchaseQty! times in the last !period! !unit!",fr:"Ce produit a été acheté !purchaseQty! fois depuis !period! !unit!",es:"Este producto se ha comprado !purchaseQty! veces en las últimas !period! !unit!",de:"Dieses Produkt wurde in den letzten !period! !unit! !purchaseQty! mal aufgerufen"},conditions:[{field:te.propName,value:1}]}),oe({},ne,{label:{en:"".concat(ae,"\n\nUse !views! for the number of pages seen.\n\n").concat(ce),fr:"".concat(re,"\n\nUtilisez !views! pour afficher le nombre de pages vues.\n\n").concat(se),es:"".concat(ie,"\n\nUsa !views! por el número de páginas vistas.\n\n").concat(de),de:"".concat(le,"\n\nVerwenden Sie !views! für die Anzahl der gesehenen Seiten.\n\n").concat(pe)},propName:"socialProofContentView",value:{en:"This page has been viewed !views! times in the last !period! !unit!",fr:"Cette page a été vue !views! fois depuis !period! !unit!",es:"Esta página se ha visto !views! veces en las últimas !period! !unit!",de:"Diese Seite wurde in den letzten !period! !unit! !views! mal gekauft"},conditions:[{field:te.propName,value:2}]})];Z.collapsed=!1;var me=[Z,G,K,q],_e={category:c,type:m,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,collapsed:!1,children:[{category:c,type:u,propName:"triggerSocialProofMinPurchases",label:{en:"Enter the minimum number of purchases to display the widget.",fr:"Entrez le minimum de produits achetés afin d'afficher le widget.",es:"Introduce el número de compras mínimo para mostrar el widget.",de:"Geben Sie die minimale Anzahl von gesehenen Seiten oder Käufen an, nach der das Widget angezeigt werden soll."},min:1,max:1e3,value:50,conditions:[{field:"socialProofContentType",value:1}]},{category:c,type:u,propName:"triggerSocialProofMinPageViews",label:{en:"Enter the minimum number of page views to display the widget.",fr:"Entrez le minimum de pages vues afin d'afficher le widget.",es:"Introduce el número de visitas mínimo para mostrar el widget."},min:1,max:1e3,value:200,conditions:[{field:"socialProofContentType",value:2}]},{category:c,type:p,propName:"autoHide",value:!1,label:"widget_common_conditions_triggering_autohide_toggler_label_autoHideAfterXSeconds"},{category:c,type:u,propName:"timeHide",min:5,max:120,value:10,label:"widget_common_conditions_triggering_delay_label",conditions:[{field:"autoHide",value:!0}]}]},ge={category:c,type:m,label:"widget_socialProof_conditions_noTrimParamUrl_blockTitle",collapsible:!0,collapsed:!0,children:[{category:c,type:p,propName:"spNoTrim",value:!1,label:"widget_socialProof_conditions_noTrimParamUrl_toggler_label"}]};x.children=x.children.filter((function(e){return e.propName.indexOf("validationRecurrence")<0}));var ye=[_e,x,ge];return[].concat(r(J),r(ue),r(me),r(ye))}));
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const t=()=>{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},s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||(()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t})(),i=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},r="https://social-proof-api.abtasty.com/clients/",n=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},o=()=>{const e=n();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},a=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,c=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},l=e=>{if(i()){const t=o();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)")}},h=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,s)=>{t.resolve=e,t.reject=s}),t},d=(e,t,s)=>{let i=0,r=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return c(i),"function"==typeof s&&s(i)}function n(){clearInterval(r),clearTimeout(i)}return i=setTimeout(()=>{n();const t=`Can't find element «${e}».`;return c(t),"function"==typeof s&&s(t)},1e4),r=setInterval(()=>{const s=document.querySelector(e);return null!==s?(n(),"function"==typeof t&&t(s)):s},200),{clear:n}};async function u(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(e){return new Promise((t,s)=>{const i=window.document.getElementsByTagName("script")[0],r=window.document.createElement("script");r.src=e,i.parentNode.insertBefore(r,i),r.onload=t,r.onerror=s})}(""));break;default:t=!0}return t}class g{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:s},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(s),this.onSetCallback=i,this.widgetName=n(),this.uniqueId=a(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:s,...i}=t;return Object.entries(i).length?(e.setItem("ABTastyWidgets",JSON.stringify(i)),i):(e.removeItem("ABTastyWidgets"),!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(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const s=this.getTypeOfStorage(e);if(!s&&"object"!=typeof s)return!1;const{storageString:i,storageMethod:r}=s,n=this.getStamp(e),o={type:t,stamp:n},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===i?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const n=s?{[this.recurrenceKey]:o,...s}:{[this.recurrenceKey]:o};r.setItem("ABTastyWidgets",JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(a&&"validation"!==t)if("closing"===t&&"validation"!==a)c();else{if("display"!==t||"validation"===a||"closing"===a)return!1;c()}else c();return n}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 m{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 e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const s=this.inViewportTargets.find(({element:s,selector:i})=>{if(s.isSameNode(e))return!0;const r=[...e.querySelectorAll(i)];if(r.length&&r.includes(s))return!0;if(t.includes(s))return!0;const n=[...e.parentElement.children],o=n.findIndex(t=>t.isSameNode(e)),a=n.filter((e,t)=>t>o);if(a.length){if(a.includes(s))return!0;if(a.some(e=>[...e.querySelectorAll(i)].includes(s)))return!0}return!1});if(s&&this.isElementVisible(s.element)){const{selector:e,element:t,uniqueId:i}=s,r=this.targets.find(t=>t.selector===e&&t.uniqueId===i);r&&r.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"===function e(t,s){return s(t)||!t.parentElement?t:e(t.parentElement,s)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),s=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let i=!1,r=0;for(;!i&&r<s.length;){const t=document.elementFromPoint(...s[r]);i=e===t||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const s=document.querySelector(e);s&&!this.existingTargets.find(e=>e.element===s&&e.uniqueId===t)&&(this.existingTargets.push({element:s,selector:e,uniqueId:t}),this.visibilityObserver.observe(s))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:s})=>{if(t.matches(e)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===s);return i&&i.resolve(t),this.clear(e,s),!1}return!0})}watch(e,t,s){this.targets.push({selector:e,resolve:t,uniqueId:s}),this.startMutationObserver()}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(s=>s.filter(({selector:s,uniqueId:i})=>s!==e&&i!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class p{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:s}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*s,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const s=h(`${this.event}DomReady`);this.promises.push(s);const i=await this.onPageLoad(s),r=await u("IntersectionObserver"),n=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",m);if(this.visibilityObservers.push(n),r&&i){const e=a();n.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const s=()=>"complete"===document.readyState;if(!s()){const e=["readystatechange",()=>s()&&t(!0),{passive:!0}];this.eventsListeners.push(e),document.addEventListener(...e)}return t(!0),e}onClick({promise:e,resolve:t}){const s=document.createElement("style");s.type="text/css",s.id=`Click_${a()}`,s.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(s),this.elementsSelectors.push(`#${s.id}`);const i=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),r=["click",({target:e})=>i(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e}onExitIntent({promise:e,resolve:t}){const s=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],i=d("body",e=>{e.addEventListener(...s),this.eventsListeners.push([e,...s]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i)});return this.elementsWaiters.push(i),e}onReengage({promise:e,resolve:t}){const s=this.delay;let i=s;const r=[()=>(i=s,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...r),this.eventsListeners.push([e,...r])});const n=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(n),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:s}=DATA;return new Function(`return new Promise(async resolve => {${s}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:s}){const i=window.ABTastyProductKey,n=t(),{viewInterval:o,triggerSocialProofMinPurchases:a,spNoTrim:c}=DATA;return i||(l("Not able to find ABTastyProductKey, impossible to call the API."),s(!1)),i&&n?fetch(`${r}${n}/metrics/i?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||l(`Widget will not be shown, product has been purchased ${e[o]} times while ${a} are required`),t})(e)&&s(e[o])).catch(()=>l("Failed to fetch datas from server.")):s(!1),e}getSocialProofPageViews({promise:e,resolve:s}){const i=encodeURIComponent(`${window.location.pathname}`),n=t(),{viewInterval:o,triggerSocialProofMinPageViews:a,spNoTrim:c}=DATA;return i&&n?fetch(`${r}${n}/metrics/pv?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||l(`Widget will not be shown, page has been seen ${e[o]} times while ${a} are required`),t})(e)&&s(e[o])).catch(()=>l("Failed to fetch datas from server.")):s(!1),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,...s]="string"==typeof e[0]?[document,...e]:e;t&&s.length>1&&t.removeEventListener(...s)}),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=a();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=h(this.event);this.promises.push(e);const t={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)},s=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?s&&await(async()=>{const e=h(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():s}}class v{constructor(e,t,s){this.recurrence=e,this.isWidgetApplied=t,this.callback=s,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=s(),{type:i}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},r=()=>e&&"display"===i||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&r()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&r())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=s();return[250,500].forEach(t=>setTimeout(()=>500===t&&s()===e?this:(e=s(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),s=e.some(({addedNodes:e})=>e&&e.length);return t||s?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=d("body",e=>{const s=[e,{childList:!0,subtree:!0}];this.observer.observe(...s),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class y{constructor(){this.children=void 0,this.uniqueId=a(),this.widgetName=n(),this.prettyName=o(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:s,validationRecurrence:i}=DATA;if(e()||!t&&!s&&!i)return!1;const r={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},n={};return t&&(n.displayRecurrence=r[t]("displayRecurrence")),s&&(n.closingRecurrence=r[s]("closingRecurrence")),i&&(n.validationRecurrence=r[i]("validationRecurrence")),n})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:s,triggerEventReengageDelay:i,socialProofContentType:r,triggerEventElementVisible:n,triggerEventDelay:o}=DATA;if(e()||!t&&!r)return!1;const a={click:()=>s,elementVisible:()=>n},c=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",l="reengage"===t?i:o;return r&&(t=1===r?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new g(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new p(this.triggerParams),this.pageWatcher=new v(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!(!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,s)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),l(e),s(e)},t=new Promise((t,s)=>{const i=d("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i),t(e.appendChild(this.styleElement))},t=>e(t,i,s));this.elementsWaiters.push(i)}),s=new Promise((t,s)=>{const{layout:i,elementReferrer:r,referrerInsertType:n}=DATA,{selector:o,position:a}="string"==typeof i&&"free"===i&&"string"==typeof r&&"string"==typeof n?{selector:r,position:n}:{selector:"body",position:"beforeend"},c=d(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,s));this.elementsWaiters.push(c)});return Promise.all([s,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():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||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&&!e()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!s())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const i=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!i)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const r=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!r&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(r),{container:this,response:r})}onPageChange(e,t){const s=()=>this.init().then(({response:e})=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(e=>e.show()):s()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:s,layout:i}=DATA,r=[];if(void 0!==s&&s&&void 0!==i&&"popin"===i&&r.push(`.${this.overlayClassName}`),void 0!==t&&t&&r.push(`.${this.closeButtonClassName}`),!r.length)return this;const n=this.domElement.querySelectorAll(r.join(", "));return n.length?(e.push(...n),e.forEach(e=>{e.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:t,layout:s}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.innerHTML=`\n\t\t\t${void 0!==s&&"popin"===s?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${t?`<button class="${this.closeButtonClassName}" ${e()?"data-abtasty-actionnable":""}><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}getStyleTag(t=""){const{noStyles:s,layout:i}=DATA,{backgroundColor:r,backgroundImage:n,borderColor:o,borderRadius:a,borderWidth:c,textColor:l,textAlign:h,overlayColor:d,dropShadow:u,dropShadowColor:g,dropShadowBlur:m,containerMargin:p,containerPadding:v,closeButton:y,buttonsBorderWidth:w,buttonsBorderColor:b,buttonsBorderRadius:f,buttonsBackgroundColor:S,buttonsTextColor:T}=s?{}:DATA,_=document.createElement("style");_.type="text/css",e()&&_.setAttribute("abtasty-script-added","true");const $=`background-color: ${void 0!==r?r:"rgba(255, 255, 255, 1)"};`,E=void 0!==n?`background-image: url(${n});`:"",C=void 0!==a?`border-radius: ${a}px;`:"",A=void 0!==c&&c?`border-width: ${c}px; border-style: solid;`:"",N=[o,c].every(e=>void 0!==e)&&c?`border-color: ${o};`:"",P=void 0!==l?`color: ${l}; fill: ${l};`:"",I=void 0!==h?`text-align: ${h};`:"",x=void 0!==u&&u?`box-shadow: 0 5px ${m}px 0 ${g};`:"",R=p instanceof Array&&1===p.length&&p[0],O=R?`margin: ${R.top}px ${R.right}px ${R.bottom}px ${R.left}px;`:"",B=R?`margin: calc(${R.top}px * 0.5) calc(${R.right}px * 0.5) calc(${R.bottom}px * 0.5) calc(${R.left}px * 0.5);`:"",k=v instanceof Array&&1===v.length&&v[0],W=k?`padding: ${k.top}px ${k.right}px ${k.bottom}px ${k.left}px;`:"",D=k?`padding: calc(${k.top}px * 0.5) calc(${k.right}px * 0.5) calc(${k.bottom}px * 0.5) calc(${k.left}px * 0.5);`:"",L=void 0!==w&&w?`border-width: ${w}px; border-style: solid;`:"",V=[b,w].every(e=>void 0!==e)&&w?`border-color: ${b};`:"",q=void 0!==f?`border-radius: ${f}px;`:"",j=void 0!==S?`background-color: ${S};`:"",M=void 0!==T?`color: ${T};`:"",H=void 0!==i&&"popin"===i?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==d?d:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",U=s||void 0!==y&&y?[`#${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;",P,"}"].join(""):"";return _.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,$,E,C,A,N,P,I,x,O,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;",W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,L,V,q,j,M,"}","@media screen and (max-width: 549px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,B,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,D,"}","}",H,U,`${t}`].join(""),_}}class w extends y{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;","}",`#${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: 549px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class b extends y{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;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class f extends y{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const S={category:"conditions",type:"slider",min:1},T=[{...S,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...S,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...S,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],_={category:"conditions",type:"select",options:[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],value:"everytime"},$={..._,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},E=(T.map(e=>({...e,propName:`${$.propName}_${e.propName}`,conditions:[{field:$.propName,value:e.propName}]})),{..._,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),C=(T.map(e=>({...e,propName:`${E.propName}_${e.propName}`,conditions:[{field:E.propName,value:e.propName}]})),{..._,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"}),A=(T.map(e=>({...e,propName:`${C.propName}_${e.propName}`,conditions:[{field:C.propName,value:e.propName}]})),{pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}});Object.keys(A).map(e=>A[e]);var N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function P(e,t){for(var s=0;s<t.length;s++){var i=t[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var I=function(e,t,s){return t&&P(e.prototype,t),s&&P(e,s),e},x=["count_72hours","count_168hours"],R=function(){function t(e){var s=e.parentContainer,i=e.response;N(this,t),this.parentContainer=s,this.spDatas=i,this.baseClassName="socialproof_container",this.spClassName="".concat(this.baseClassName,"_").concat(s.uniqueId),this.spElement=this.getSPElement(),this.styleElement=this.getStyleElement()}return I(t,[{key:"getSPText",value:function(){var e=DATA,s=e.socialProofContentType,i=e.socialProofContentPurchase,r=e.socialProofContentView,n=e.viewInterval;return(1===s?i:r).replace("!purchaseQty!",this.spDatas?'<span class="purchase_quantity">'.concat(this.spDatas,"</span>"):'<span class="purchase_quantity">0 (example)</span>').replace("!views!",this.spDatas?'<span class="pageview_number">'.concat(this.spDatas,"</span>"):'<span class="pageview_number">0 (example)</span>').replace("!period!",'<span class="period">'.concat(t.getPeriod(n),"</span>")).replace("!unit!",'<span class="unit">'.concat(t.getUnits(n),"</span>"))}},{key:"refreshContent",value:function(e){this.spDatas=e;var t=this.getSPText();return this.spElement.innerHTML=t,this}},{key:"getSPElement",value:function(){var e=document.createElement("div"),t=this.getSPText();return e.className=this.spClassName,e.innerHTML=t,e}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.spElement),this}},{key:"getStyleElement",value:function(){var t=DATA,s=t.textColor,i=t.textAlign,r=document.createElement("style");r.type="text/css",e()&&r.setAttribute("abtasty-script-added","true");var n=void 0!==s?"color: ".concat(s,";"):"",o=void 0!==i?"text-align: ".concat(i,";"):"";return r.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," p {"),"margin: 0;","white-space: pre-line;",n,o,"}",n&&n.length?["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," span {"),n,"}"].join(""):""].join(""),r}}],[{key:"getPeriod",value:function(e){return e.split(/(?:count_|hours)+/)[1]/(x.includes(e)?24:1)}},{key:"getUnits",value:function(e){var t=DATA,s=t.daysTranslations,i=t.hoursTranslations;return x.includes(e)?s:i}}]),t}();!function(){l("Widget launch");var t=DATA,s=t.autoHide,i=t.timeHide,r=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new w;break;case"bannerTop":case"bannerBottom":t=new b;break;case"free":t=new f;break;default:t=new y}return t})(),n=r.domElement.querySelector(".".concat(r.contentClassName)),o=new R({parentContainer:r});r.children=o,o.insertIn(n,"beforeend"),r.init(!0).then((function(t){var n=t.response;e()||"number"!=typeof n||o.refreshContent(n),n&&(r.show(),!e()&&"boolean"==typeof s&&"number"==typeof i&&s&&setTimeout((function(){r.hide()}),1e3*i))}))}()}();
1
+ !function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor");const t=()=>{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},s=()=>!!window.ABTasty.getTestsOnPage()[TEST_ID]||(()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t})(),i=()=>{if(e())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},r="https://social-proof-api.abtasty.com/clients/",n=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},o=()=>{const e=n();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},a=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,c=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},l=e=>{if(i()){const t=o();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)")}},h=e=>{const t={promise:null,resolve:null,reject:null,name:e};return t.promise=new Promise((e,s)=>{t.resolve=e,t.reject=s}),t},d=(e,t,s)=>{let i=0,r=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return c(i),"function"==typeof s&&s(i)}function n(){clearInterval(r),clearTimeout(i)}return i=setTimeout(()=>{n();const t=`Can't find element «${e}».`;return c(t),"function"==typeof s&&s(t)},1e4),r=setInterval(()=>{const s=document.querySelector(e);return null!==s?(n(),"function"==typeof t&&t(s)):s},200),{clear:n}};async function u(e){let t;switch(e){case"IntersectionObserver":t=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||function(e){return new Promise((t,s)=>{const i=window.document.getElementsByTagName("script")[0],r=window.document.createElement("script");r.src=e,i.parentNode.insertBefore(r,i),r.onload=t,r.onerror=s})}("https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver"));break;default:t=!0}return t}class g{constructor({displayRecurrence:e,closingRecurrence:t,validationRecurrence:s},i){this.displayRecurrence=parseFloat(e),this.closingRecurrence=parseFloat(t),this.validationRecurrence=parseFloat(s),this.onSetCallback=i,this.widgetName=n(),this.uniqueId=a(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem("ABTastyWidgets");return JSON.parse(t)}catch(t){return e.removeItem("ABTastyWidgets"),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:s,...i}=t;return Object.entries(i).length?(e.setItem("ABTastyWidgets",JSON.stringify(i)),i):(e.removeItem("ABTastyWidgets"),!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(){const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=this.getLocalRecurrence(),t=(e?parseFloat(e.stamp):0)<(new Date).getTime();return t&&this.removeLocalRecurrenceStorage(),t&&!this.getLocalRecurrence()&&!this.getSessionRecurrence()}setRecurrence(e,t){const s=this.getTypeOfStorage(e);if(!s&&"object"!=typeof s)return!1;const{storageString:i,storageMethod:r}=s,n=this.getStamp(e),o={type:t,stamp:n},{type:a}=this.getCurrentRecurrence(),c=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===i?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===i&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const n=s?{[this.recurrenceKey]:o,...s}:{[this.recurrenceKey]:o};r.setItem("ABTastyWidgets",JSON.stringify(n)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!r)return!1;if(a&&"validation"!==t)if("closing"===t&&"validation"!==a)c();else{if("display"!==t||"validation"===a||"closing"===a)return!1;c()}else c();return n}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 m{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 e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const s=this.inViewportTargets.find(({element:s,selector:i})=>{if(s.isSameNode(e))return!0;const r=[...e.querySelectorAll(i)];if(r.length&&r.includes(s))return!0;if(t.includes(s))return!0;const n=[...e.parentElement.children],o=n.findIndex(t=>t.isSameNode(e)),a=n.filter((e,t)=>t>o);if(a.length){if(a.includes(s))return!0;if(a.some(e=>[...e.querySelectorAll(i)].includes(s)))return!0}return!1});if(s&&this.isElementVisible(s.element)){const{selector:e,element:t,uniqueId:i}=s,r=this.targets.find(t=>t.selector===e&&t.uniqueId===i);r&&r.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"===function e(t,s){return s(t)||!t.parentElement?t:e(t.parentElement,s)}(e,e=>"0"===window.getComputedStyle(e).opacity).nodeName}isElementTopmost(e){const t=e.getBoundingClientRect(),s=[[t.left,t.top],[t.right,t.top],[t.left,t.bottom],[t.right,t.bottom],[t.left+t.width/2,t.top],[t.left+t.width/2,t.bottom],[t.left,t.height/2],[t.right,t.height/2],[t.left+t.left/2,t.height/2]];let i=!1,r=0;for(;!i&&r<s.length;){const t=document.elementFromPoint(...s[r]);i=e===t||e.contains(t),r+=1}return i}checkElements(){this.targets.forEach(({selector:e,uniqueId:t})=>{const s=document.querySelector(e);s&&!this.existingTargets.find(e=>e.element===s&&e.uniqueId===t)&&(this.existingTargets.push({element:s,selector:e,uniqueId:t}),this.visibilityObserver.observe(s))}),this.existingTargets=this.existingTargets.filter(({selector:e,element:t})=>!!document.querySelector(e)||(this.visibilityObserver.unobserve(t),!1)),this.inViewportTargets=this.inViewportTargets.filter(({selector:e,element:t,uniqueId:s})=>{if(t.matches(e)&&this.isElementVisible(t)){const i=this.targets.find(t=>t.selector===e&&t.uniqueId===s);return i&&i.resolve(t),this.clear(e,s),!1}return!0})}watch(e,t,s){this.targets.push({selector:e,resolve:t,uniqueId:s}),this.startMutationObserver()}clear(e,t){[this.targets,this.existingTargets,this.inViewportTargets]=[this.targets,this.existingTargets,this.inViewportTargets].map(s=>s.filter(({selector:s,uniqueId:i})=>s!==e&&i!==t)),this.visibilityObserver.unobserve(document.querySelector(e)),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class p{constructor({triggerEvent:e,triggerSelector:t,triggerDelay:s}){this.event=e,this.selector=t&&t.length?t:"body",this.delay=1e3*s,this.elementsSelectors=[],this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.visibilityObservers=[],this.elementsWaiters=[]}async onElementVisible({promise:e,resolve:t}){const s=h(`${this.event}DomReady`);this.promises.push(s);const i=await this.onPageLoad(s),r=await u("IntersectionObserver"),n=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",m);if(this.visibilityObservers.push(n),r&&i){const e=a();n.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const s=()=>"complete"===document.readyState;if(!s()){const e=["readystatechange",()=>s()&&t(!0),{passive:!0}];this.eventsListeners.push(e),document.addEventListener(...e)}return t(!0),e}onClick({promise:e,resolve:t}){const s=document.createElement("style");s.type="text/css",s.id=`Click_${a()}`,s.innerHTML=`${this.selector} {\n\t\t\tcursor: pointer !important;\n\t\t\tpointer-events: all !important;\n\t\t}`,document.head.appendChild(s),this.elementsSelectors.push(`#${s.id}`);const i=e=>[...document.querySelectorAll(this.selector)].some(t=>t.isSameNode(e)||!!e.closest(this.selector)),r=["click",({target:e})=>i(e)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e}onExitIntent({promise:e,resolve:t}){const s=["mouseleave",async({clientY:e})=>{e<=0&&t(!0)},{passive:!0}],i=d("body",e=>{e.addEventListener(...s),this.eventsListeners.push([e,...s]),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i)});return this.elementsWaiters.push(i),e}onReengage({promise:e,resolve:t}){const s=this.delay;let i=s;const r=[()=>(i=s,i),{passive:!0}];["click","mousemove","scroll","keypress"].forEach(e=>{document.addEventListener(e,...r),this.eventsListeners.push([e,...r])});const n=setInterval(()=>{i<=0?t(!0):i-=100},100);return this.intervals.push(n),e}onCustomTrigger({promise:e,resolve:t}){const{triggerEventCustomScript:s}=DATA;return new Function(`return new Promise(async resolve => {${s}})`)().then(e=>e&&t(!0)),e}getSocialProofPurchases({promise:e,resolve:s}){const i=window.ABTastyProductKey,n=t(),{viewInterval:o,triggerSocialProofMinPurchases:a,spNoTrim:c}=DATA;return i||(l("Not able to find ABTastyProductKey, impossible to call the API."),s(!1)),i&&n?fetch(`${r}${n}/metrics/i?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||l(`Widget will not be shown, product has been purchased ${e[o]} times while ${a} are required`),t})(e)&&s(e[o])).catch(()=>l("Failed to fetch datas from server.")):s(!1),e}getSocialProofPageViews({promise:e,resolve:s}){const i=encodeURIComponent(`${window.location.pathname}`),n=t(),{viewInterval:o,triggerSocialProofMinPageViews:a,spNoTrim:c}=DATA;return i&&n?fetch(`${r}${n}/metrics/pv?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===o||void 0===a)return!1;const t=e[o]&&e[o]>=a;return t||l(`Widget will not be shown, page has been seen ${e[o]} times while ${a} are required`),t})(e)&&s(e[o])).catch(()=>l("Failed to fetch datas from server.")):s(!1),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,...s]="string"==typeof e[0]?[document,...e]:e;t&&s.length>1&&t.removeEventListener(...s)}),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=a();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=h(this.event);this.promises.push(e);const t={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)},s=!Object.prototype.hasOwnProperty.call(t,this.event)||await t[this.event]();return this.clear(),"reengage"!==this.event&&this.delay?s&&await(async()=>{const e=h(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():s}}class v{constructor(e,t,s){this.recurrence=e,this.isWidgetApplied=t,this.callback=s,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=s(),{type:i}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},r=()=>e&&"display"===i||this.recurrenceIsDone();return!this.isWidgetApplied()&&t&&r()?(this.clearWatcher(),this.callback("rebuild",e)):(!this.isWidgetApplied()||t&&r())&&(this.isWidgetApplied()||t)||(this.clearWatcher(),this.callback("remove",e),this.watch()),this}eventHandler(){let e=s();return[250,500].forEach(t=>setTimeout(()=>500===t&&s()===e?this:(e=s(),this.decisionHandler(!1)),t)),this}observerHandler(e){const t=e.some(({removedNodes:e})=>e&&e.length),s=e.some(({addedNodes:e})=>e&&e.length);return t||s?(this.decisionHandler(!0),this):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=d("body",e=>{const s=[e,{childList:!0,subtree:!0}];this.observer.observe(...s),this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t)});return this.elementsWaiters.push(t),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}class y{constructor(){this.children=void 0,this.uniqueId=a(),this.widgetName=n(),this.prettyName=o(),this.recurrenceParams=(()=>{const{displayRecurrence:t,closingRecurrence:s,validationRecurrence:i}=DATA;if(e()||!t&&!s&&!i)return!1;const r={everytime:()=>-1,session:()=>0,once:()=>395,day:e=>DATA[`${e}_day`],week:e=>7*DATA[`${e}_week`],month:e=>30.5*DATA[`${e}_month`]},n={};return t&&(n.displayRecurrence=r[t]("displayRecurrence")),s&&(n.closingRecurrence=r[s]("closingRecurrence")),i&&(n.validationRecurrence=r[i]("validationRecurrence")),n})(),this.triggerParams=(()=>{let{triggerEvent:t}=DATA;const{triggerEventClick:s,triggerEventReengageDelay:i,socialProofContentType:r,triggerEventElementVisible:n,triggerEventDelay:o}=DATA;if(e()||!t&&!r)return!1;const a={click:()=>s,elementVisible:()=>n},c=Object.prototype.hasOwnProperty.call(a,t)?a[t]():"body",l="reengage"===t?i:o;return r&&(t=1===r?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:l}})(),this.recurrence=!!this.recurrenceParams&&new g(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new p(this.triggerParams),this.pageWatcher=new v(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!(!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,s)=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==t),l(e),s(e)},t=new Promise((t,s)=>{const i=d("head",e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==i),t(e.appendChild(this.styleElement))},t=>e(t,i,s));this.elementsWaiters.push(i)}),s=new Promise((t,s)=>{const{layout:i,elementReferrer:r,referrerInsertType:n}=DATA,{selector:o,position:a}="string"==typeof i&&"free"===i&&"string"==typeof r&&"string"==typeof n?{selector:r,position:n}:{selector:"body",position:"beforeend"},c=d(o,e=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e!==c),this.removeOldDomElement(),t(e.insertAdjacentElement(a,this.domElement))},t=>e(t,c,s));this.elementsWaiters.push(c)});return Promise.all([s,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():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return this.hasBeenShown||e()||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&&!e()&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){if(!e()&&!s())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const i=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!i)return this.pageWatcher.watch(),!1;this.pageWatcher.watch();const r=e()||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!r&&(await this.insert(),this.addCloseEvent(),e()||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(r),{container:this,response:r})}onPageChange(e,t){const s=()=>this.init().then(({response:e})=>e&&this.show());switch(t||(this.hasBeenShown=!1),e){case"remove":this.isWidgetApplied()?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch());break;case"rebuild":this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():this.insert().then(e=>e.show()):s()}}addCloseEvent(...e){const{closeButton:t,overlayClickable:s,layout:i}=DATA,r=[];if(void 0!==s&&s&&void 0!==i&&"popin"===i&&r.push(`.${this.overlayClassName}`),void 0!==t&&t&&r.push(`.${this.closeButtonClassName}`),!r.length)return this;const n=this.domElement.querySelectorAll(r.join(", "));return n.length?(e.push(...n),e.forEach(e=>{e.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:t,layout:s}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.innerHTML=`\n\t\t\t${void 0!==s&&"popin"===s?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${t?`<button class="${this.closeButtonClassName}" ${e()?"data-abtasty-actionnable":""}><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}getStyleTag(t=""){const{noStyles:s,layout:i}=DATA,{backgroundColor:r,backgroundImage:n,borderColor:o,borderRadius:a,borderWidth:c,textColor:l,textAlign:h,overlayColor:d,dropShadow:u,dropShadowColor:g,dropShadowBlur:m,containerMargin:p,containerPadding:v,closeButton:y,buttonsBorderWidth:w,buttonsBorderColor:b,buttonsBorderRadius:f,buttonsBackgroundColor:S,buttonsTextColor:T}=s?{}:DATA,_=document.createElement("style");_.type="text/css",e()&&_.setAttribute("abtasty-script-added","true");const $=`background-color: ${void 0!==r?r:"rgba(255, 255, 255, 1)"};`,E=void 0!==n?`background-image: url(${n});`:"",C=void 0!==a?`border-radius: ${a}px;`:"",A=void 0!==c&&c?`border-width: ${c}px; border-style: solid;`:"",N=[o,c].every(e=>void 0!==e)&&c?`border-color: ${o};`:"",P=void 0!==l?`color: ${l}; fill: ${l};`:"",I=void 0!==h?`text-align: ${h};`:"",x=void 0!==u&&u?`box-shadow: 0 5px ${m}px 0 ${g};`:"",R=p instanceof Array&&1===p.length&&p[0],O=R?`margin: ${R.top}px ${R.right}px ${R.bottom}px ${R.left}px;`:"",B=R?`margin: calc(${R.top}px * 0.5) calc(${R.right}px * 0.5) calc(${R.bottom}px * 0.5) calc(${R.left}px * 0.5);`:"",k=v instanceof Array&&1===v.length&&v[0],W=k?`padding: ${k.top}px ${k.right}px ${k.bottom}px ${k.left}px;`:"",D=k?`padding: calc(${k.top}px * 0.5) calc(${k.right}px * 0.5) calc(${k.bottom}px * 0.5) calc(${k.left}px * 0.5);`:"",L=void 0!==w&&w?`border-width: ${w}px; border-style: solid;`:"",V=[b,w].every(e=>void 0!==e)&&w?`border-color: ${b};`:"",q=void 0!==f?`border-radius: ${f}px;`:"",j=void 0!==S?`background-color: ${S};`:"",M=void 0!==T?`color: ${T};`:"",H=void 0!==i&&"popin"===i?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==d?d:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",U=s||void 0!==y&&y?[`#${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;",P,"}"].join(""):"";return _.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,$,E,C,A,N,P,I,x,O,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;",W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,L,V,q,j,M,"}","@media screen and (max-width: 549px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,B,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,D,"}","}",H,U,`${t}`].join(""),_}}class w extends y{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;","}",`#${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: 549px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class b extends y{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;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}class f extends y{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}const S={category:"conditions",type:"slider",min:1},T=[{...S,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...S,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...S,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],_={category:"conditions",type:"select",options:[{label:"widget_common_conditions_recurrence_option_everyTime",value:"everytime"},{label:"widget_common_conditions_recurrence_option_everySession",value:"session"},{label:"widget_common_conditions_recurrence_option_everyXDays",value:"day"},{label:"widget_common_conditions_recurrence_option_everyXWeeks",value:"week"},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:"month"},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],value:"everytime"},$={..._,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},E=(T.map(e=>({...e,propName:`${$.propName}_${e.propName}`,conditions:[{field:$.propName,value:e.propName}]})),{..._,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),C=(T.map(e=>({...e,propName:`${E.propName}_${e.propName}`,conditions:[{field:E.propName,value:e.propName}]})),{..._,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"}),A=(T.map(e=>({...e,propName:`${C.propName}_${e.propName}`,conditions:[{field:C.propName,value:e.propName}]})),{pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}});Object.keys(A).map(e=>A[e]);var N=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function P(e,t){for(var s=0;s<t.length;s++){var i=t[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var I=function(e,t,s){return t&&P(e.prototype,t),s&&P(e,s),e},x=["count_72hours","count_168hours"],R=function(){function t(e){var s=e.parentContainer,i=e.response;N(this,t),this.parentContainer=s,this.spDatas=i,this.baseClassName="socialproof_container",this.spClassName="".concat(this.baseClassName,"_").concat(s.uniqueId),this.spElement=this.getSPElement(),this.styleElement=this.getStyleElement()}return I(t,[{key:"getSPText",value:function(){var e=DATA,s=e.socialProofContentType,i=e.socialProofContentPurchase,r=e.socialProofContentView,n=e.viewInterval;return(1===s?i:r).replace("!purchaseQty!",this.spDatas?'<span class="purchase_quantity">'.concat(this.spDatas,"</span>"):'<span class="purchase_quantity">0 (example)</span>').replace("!views!",this.spDatas?'<span class="pageview_number">'.concat(this.spDatas,"</span>"):'<span class="pageview_number">0 (example)</span>').replace("!period!",'<span class="period">'.concat(t.getPeriod(n),"</span>")).replace("!unit!",'<span class="unit">'.concat(t.getUnits(n),"</span>"))}},{key:"refreshContent",value:function(e){this.spDatas=e;var t=this.getSPText();return this.spElement.innerHTML=t,this}},{key:"getSPElement",value:function(){var e=document.createElement("div"),t=this.getSPText();return e.className=this.spClassName,e.innerHTML=t,e}},{key:"insertIn",value:function(e,t){return document.head.insertAdjacentElement("beforeend",this.styleElement),e.insertAdjacentElement(t,this.spElement),this}},{key:"getStyleElement",value:function(){var t=DATA,s=t.textColor,i=t.textAlign,r=document.createElement("style");r.type="text/css",e()&&r.setAttribute("abtasty-script-added","true");var n=void 0!==s?"color: ".concat(s,";"):"",o=void 0!==i?"text-align: ".concat(i,";"):"";return r.textContent=["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," p {"),"margin: 0;","white-space: pre-line;",n,o,"}",n&&n.length?["#".concat(this.parentContainer.widgetContainerId," .").concat(this.spClassName," span {"),n,"}"].join(""):""].join(""),r}}],[{key:"getPeriod",value:function(e){return e.split(/(?:count_|hours)+/)[1]/(x.includes(e)?24:1)}},{key:"getUnits",value:function(e){var t=DATA,s=t.daysTranslations,i=t.hoursTranslations;return x.includes(e)?s:i}}]),t}();!function(){l("Widget launch");var t=DATA,s=t.autoHide,i=t.timeHide,r=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new w;break;case"bannerTop":case"bannerBottom":t=new b;break;case"free":t=new f;break;default:t=new y}return t})(),n=r.domElement.querySelector(".".concat(r.contentClassName)),o=new R({parentContainer:r});r.children=o,o.insertIn(n,"beforeend"),r.init(!0).then((function(t){var n=t.response;e()||"number"!=typeof n||o.refreshContent(n),n&&(r.show(),!e()&&"boolean"==typeof s&&"number"==typeof i&&s&&setTimeout((function(){r.hide()}),1e3*i))}))}()}();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abtasty/social-proof",
3
3
  "description": "simple",
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "main": "dist/main.js",
6
6
  "form": "dist/form.js",
7
7
  "icon": "icon.png",
@@ -16,7 +16,9 @@
16
16
  "buildtestdeps": "rollup -c rolluptests.config.js",
17
17
  "watch": "rollup -c --watch",
18
18
  "build": "rollup -c",
19
- "serve": "widget serve"
19
+ "serve": "widget serve",
20
+ "prepare": "npm run build",
21
+ "postpublish": "echo 'Your widget is on NPM. You can now add your widget to AB Tasty Marketplace at https://marketplace.abtasty.com/add'"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@babel/core": "^7.8.4",
@@ -35,11 +37,11 @@
35
37
  "rollup-plugin-eslint": "^7.0.0"
36
38
  },
37
39
  "dependencies": {
38
- "@abtasty/widget-utils": "1.16.4-0",
40
+ "@abtasty/widget-utils": "1.16.8",
39
41
  "@babel/plugin-proposal-object-rest-spread": "^7.8.3",
40
42
  "@rollup/plugin-commonjs": "^11.0.1",
41
43
  "@rollup/plugin-node-resolve": "^7.0.0",
42
44
  "babel-eslint": "^10.0.3",
43
45
  "rollup-plugin-terser": "^5.2.0"
44
46
  }
45
- }
47
+ }