@abtasty/social-proof 1.1.0-6 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/form.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +4 -6
- package/README.md +0 -52
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,a=new Array(o);t<o;t++)a[t]=e[t];return a};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 a=function(o,t){if(o){if("string"==typeof o)return e(o,t);var a=Object.prototype.toString.call(o).slice(8,-1);return"Object"===a&&o.constructor&&(a=o.constructor.name),"Map"===a||"Set"===a?Array.from(a):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(o,t):void 0}};var l=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 n=function(e){return o(e)||t(e)||a(e)||l()};const i="style",r="content",c="conditions",_="hidden",s="select",p="switch",d="slider",m="group",g="https://widgets-images.abtasty.com/",u={category:c,type:d,min:1},b=[{...u,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...u,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...u,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],y={category:c,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"},v={...y,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},f=b.map(e=>({...e,propName:`${v.propName}_${e.propName}`,conditions:[{field:v.propName,value:e.propName}]})),w={...y,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},h=b.map(e=>({...e,propName:`${w.propName}_${e.propName}`,conditions:[{field:w.propName,value:e.propName}]})),N={...y,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},k=b.map(e=>({...e,propName:`${N.propName}_${e.propName}`,conditions:[{field:N.propName,value:e.propName}]}));w.condition=({closeButton:e,layout:o,overlayClickable:t})=>!("popin"===o&&!1===e&&!1===t||void 0!==o&&"popin"!==o&&!1===e);const I={category:c,type:m,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[v,...f,w,...h,N,...k]},P={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}},x=(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:`${g}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${g}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${g}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${g}layout/icon-layout-freePlacement.png`}]}),S={category:"layout",type:"selectelement",propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},O={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"}]},T=[{field:"layout",value:"free"}];S.conditions=T,O.conditions=T;const C={category:"layout",type:m,label:"widget_common_tabName_layout",collapsible:!0,children:[x,S,O]},A={category:i,type:"colorpicker",label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},j={category:i,type:p,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},U={category:i,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:""},z={category:i,type:"radio",label:"widget_common_style_backgroundImageUploader_imageOptions_label",propName:"backgroundSize",value:"cover",options:[{label:"widget_common_style_backgroundImageUploader_imageOptions_option_cover",value:"cover"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_contain",value:"contain"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_fill",value:"100% 100%"},{label:"widget_common_style_backgroundImageUploader_imageOptions_option_none",value:"auto"}]},D={category:i,type:"select",label:"widget_common_style_backgroundImageUploader_imagePosition_select_label",propName:"backgroundPosition",value:"center",options:[{label:"widget_common_style_backgroundImageUploader_imagePosition_option_top",value:"top"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottom",value:"bottom"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_center",value:"center"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_left",value:"left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_right",value:"right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topLeft",value:"top left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_topRight",value:"top right"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomLeft",value:"bottom left"},{label:"widget_common_style_backgroundImageUploader_imagePosition_option_bottomRight",value:"bottom right"}]},E={category:i,type:p,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1},$={category:i,type:"colorpicker",label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},B={category:i,type:d,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},R={category:i,type:d,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},V={category:i,type:"colorpicker",label:"widget_common_style_text_label_textColor",propName:"textColor",value:"rgba(57, 57, 57, 1)"},W={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:`${g}style/icon-text-alignLeft.png`},{label:"widget_common_style_text_textAlignment_option_center",value:"center",src:`${g}style/icon-text-alignCenter.png`},{label:"widget_common_style_text_textAlignment_option_right",value:"right",src:`${g}style/icon-text-alignRight.png`}]},L={category:i,type:"areainput"},M={...L,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},X={...L,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},H={category:i,type:p,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);"},K={category:i,type:d,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},F={category:i,type:p,label:"widget_common_style_container_label_displayCloseButton",propName:"closeButton",value:!0},G={category:i,type:"colorpicker",label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},Q={category:i,type:p,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},Z={field:j.propName,value:!0},J={field:z.propName,value:e=>"cover"!==e},Y={field:z.propName,value:e=>"100% 100%"!==e};U.conditions=[Z],z.conditions=[Z],D.conditions=[Z,Y],E.conditions=[Z,Y,J];const ee=[A,j,U,z,D,E],oe=[{field:R.propName,value:e=>e>0}];$.conditions=oe;const te={category:i,type:m,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[R,$,B]},ae={category:i,type:m,label:"widget_common_style_blockTitle_text",collapsible:!0,children:[W,V]},le=[{field:"dropShadow",value:!0}];q.conditions=le,K.conditions=le;const ne={category:i,type:m,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[M,X,...ee,H,q,K,F]},ie={category:i,type:m,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[G,Q],conditions:[{field:"layout",value:"popin"}]};var re=n(C.children);var ce=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 _e(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);o&&(a=a.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,a)}return t}function se(e){for(var o=1;o<arguments.length;o++){var t=null!=arguments[o]?arguments[o]:{};o%2?_e(Object(t),!0).forEach((function(o){ce(e,o,t[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):_e(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}var pe={category:r,propName:"socialProofContentType",type:s,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}]},de={category:r,type:"variablesinput"},me=[{category:"content",propName:"socialProofInfo",type:"inlinenotification",label:"widget_socialProof_content_alert_transactionTag",hrefUrl:"https://abtasty.zendesk.com/hc/en-us/articles/360034533374"},{category:r,propName:"daysTranslations",type:_,value:{en:"days",fr:"jours",es:"días",de:"Tagen"}},{category:r,propName:"hoursTranslations",type:_,value:{en:"hours",fr:"heures",es:"horas",de:"Stunden"}},pe,{category:r,propName:"viewInterval",type:s,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"}]},se({},de,{label:"widget_socialProof_content_messageTextarea_purchases_label",propName:"socialProofContentPurchase",value:"widget_socialProof_content_messageTextarea_purchases_default",conditions:[{field:pe.propName,value:1}],vars:["purchaseQty","period","unit"]}),se({},de,{label:"widget_socialProof_content_messageTextarea_views_label",propName:"socialProofContentView",value:"widget_socialProof_content_messageTextarea_views_default",conditions:[{field:pe.propName,value:2}],vars:["views","period","unit"]})];ae.collapsed=!1;var ge=[ae,ne,te,ie],ue={category:c,type:m,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,collapsed:!1,children:[{category:c,type:d,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:d,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:d,propName:"timeHide",min:5,max:120,value:10,label:"widget_common_conditions_triggering_delay_label",conditions:[{field:"autoHide",value:!0}]}]},be={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"}]};I.children=I.children.filter((function(e){return e.propName.indexOf("validationRecurrence")<0}));var ye=[ue,I,be];return[].concat(n(re),n(me),n(ge),n(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]},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))}));
|
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=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},i=()=>s()||!!window.ABTasty.getTestsOnPage()[TEST_ID],r=()=>{if(e()||s())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0},n="conditions",o="https://social-proof-api.abtasty.com/clients/",a=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},c=()=>{const e=a();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},l=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,h=(...e)=>{e.unshift(`[AB Tasty Widget] ${PACKAGE}:`),console.log(...e)},d=e=>{if(r()){const t=c();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)")}},u=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},g=(e,t,s)=>{let i=0,r=0;try{document.querySelector(e)}catch(t){const i=`Selector «${e}» not valid.`;return h(i),"function"==typeof s&&s(i)}function n(){clearInterval(r),clearTimeout(i)}return i=setTimeout(()=>{n();const t=`Can't find element «${e}».`;return h(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 m(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 p{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=a(),this.uniqueId=l(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent()}onStorage({key:e}){const t=localStorage.getItem("ABTastyWidgetsTemporary"),s=sessionStorage.getItem("ABTastyWidgets");"ABTastyData"===e&&!t&&s&&localStorage.setItem("ABTastyWidgetsTemporary",s)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}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=localStorage.getItem("ABTastyWidgetsTemporary"),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem("ABTastyWidgets",e),localStorage.removeItem("ABTastyWidgetsTemporary"));const s=this.getLocalRecurrence(),i=(s?parseFloat(s.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),i&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const i=this.getTypeOfStorage(e);if(s()||!i&&"object"!=typeof i)return!1;const{storageString:r,storageMethod:n}=i,o=this.getStamp(e),a={type:t,stamp:o},{type:c}=this.getCurrentRecurrence(),l=()=>{const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===r?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===r&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const i=s?{[this.recurrenceKey]:a,...s}:{[this.recurrenceKey]:a};n.setItem("ABTastyWidgets",JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!n)return!1;if(c&&"validation"!==t)if("closing"===t&&"validation"!==c)l();else{if("display"!==t||"validation"===c||"closing"===c)return!1;l()}else l();return o}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 v{constructor(){this.targets=[],this.existingTargets=[],this.inViewportTargets=[],this.visibilityObserver=this.startVisibilityObserver(),this.mutationObserver=this.startMutationObserver(),this.mouseOverEvent=this.mouseOverHandler()}intersectionHandler(e){e.forEach(e=>{e.isIntersecting?(this.existingTargets.forEach(t=>{t.element.isSameNode(e.target)&&(this.inViewportTargets.push(t),this.mouseOverEvent.start())}),this.checkElements()):this.inViewportTargets=this.inViewportTargets.filter(t=>!t.element.isSameNode(e.target)||(this.mouseOverEvent.clear(),!1))})}startVisibilityObserver(){return new IntersectionObserver(this.intersectionHandler.bind(this),{root:null,rootMargin:"0px",threshold:0})}startMutationObserver(){const e=this.mutationObserver||new MutationObserver(this.checkElements.bind(this));return document.body&&e.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),e}onMouseOver({target:e,path:t}){const 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(s=>s.element.matches(e)&&s.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});const i=()=>{this.startMutationObserver(),this.checkElements()};document.body?i():g("body",i)}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 y{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=u(`${this.event}DomReady`);this.promises.push(s);const i=await this.onPageLoad(s),r=await m("IntersectionObserver"),n=function(e,t){return ABTasty.widgetUtils||(ABTasty.widgetUtils={}),ABTasty.widgetUtils[e]||Object.assign(ABTasty.widgetUtils,{[e]:new t}),ABTasty.widgetUtils[e]}("VisibilityObserver",v);if(this.visibilityObservers.push(n),r&&i){const e=l();n.watch(this.selector,t,e)}return e}onPageLoad({promise:e,resolve:t}){const s=()=>"complete"===document.readyState;if(!s()){const i=["readystatechange",()=>s()&&t(!0),{passive:!0}];return this.eventsListeners.push(i),document.addEventListener(...i),e}return t(!0),e}onClick({promise:e,resolve:t}){const s=document.createElement("style");s.type="text/css",s.id=`Click_${l()}`,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=g("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,r=t(),{viewInterval:n,triggerSocialProofMinPurchases:a,spNoTrim:c}=DATA;return i||(d("Not able to find ABTastyProductKey, impossible to call the API."),s(!1)),i&&r?fetch(`${o}${r}/metrics/i?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===a)return!1;const t=e[n]&&e[n]>=a;return t||d(`Widget will not be shown, product has been purchased ${e[n]} times while ${a} are required`),t})(e)&&s(e[n])).catch(()=>d("Failed to fetch datas from server.")):s(!1),e}getSocialProofPageViews({promise:e,resolve:s}){const i=encodeURIComponent(`${window.location.pathname}`),r=t(),{viewInterval:n,triggerSocialProofMinPageViews:a}=DATA;return i&&r?fetch(`${o}${r}/metrics/pv?key=${i}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===a)return!1;const t=e[n]&&e[n]>=a;return t||d(`Widget will not be shown, page has been seen ${e[n]} times while ${a} are required`),t})(e)&&s(e[n])).catch(()=>d("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=l();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=u(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=u(`${this.event}Delay`);return this.promises.push(e),setTimeout(()=>{e.resolve(!0),this.clear()},this.delay),e.promise})():s}}class w{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=i(),{type:s}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1},r=()=>e&&"display"===s||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=i();return[250,500].forEach(t=>setTimeout(()=>500===t&&i()===e?this:(e=i(),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=g("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 b{constructor(){this.children=void 0,this.uniqueId=l(),this.widgetName=a(),this.prettyName=c(),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 p(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new y(this.triggerParams),this.pageWatcher=new w(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),d(e),s(e)},t=new Promise((t,s)=>{const i=g("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=g(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()&&!i())return!1;if(this.trigger&&this.trigger.promises.length)return!1;const s=this.recurrence&&this.recurrence.isOver();if(this.recurrence&&!s)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(...t){const{closeButton:s,overlayClickable:i,layout:r}=DATA,n=[];if(void 0!==i&&i&&void 0!==r&&"popin"===r&&n.push(`.${this.overlayClassName}`),void 0!==s&&s&&n.push(`.${this.closeButtonClassName}`),!n.length)return this;const o=this.domElement.querySelectorAll(n.join(", "));return o.length?(t.push(...o),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",()=>{this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{passive:!0,once:!0})}),this):this}getDom(){const{closeButton:e,layout:t}=DATA,s=document.createElement("div");return s.className=`${this.basicClassName} ${this.hideClassName}`,s.id=this.widgetContainerId,s.innerHTML=`\n\t\t\t${void 0!==t&&"popin"===t?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,s}getStyleTag(t=""){const{noStyles:s,layout:i}=DATA,{backgroundColor:r,isBackgroundImage:n,backgroundImage:o,backgroundSize:a,backgroundPosition:c,backgroundRepeat:l,borderColor:h,borderRadius:d,borderWidth:u,textColor:g,textAlign:m,overlayColor:p,dropShadow:v,dropShadowColor:y,dropShadowBlur:w,containerMargin:b,containerPadding:f,closeButton:S,buttonsBorderWidth:T,buttonsBorderColor:_,buttonsBorderRadius:E,buttonsBackgroundColor:$,buttonsTextColor:A}=s?{}:DATA,C=document.createElement("style");C.type="text/css",e()&&C.setAttribute("abtasty-script-added","true");const I=`background: ${["string"==typeof r?r:"rgba(255, 255, 255, 1)",n&&"string"==typeof o&&o.length?`url(${o})`:"",n&&"string"==typeof c&&"100% 100%"!==a?c:"0 0",n&&"string"==typeof a?`/ ${a}`:"/ auto",n&&l&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,N="number"==typeof u&&u>0,P=`border: ${[N?`${u}px`:"unset",N?"solid":"",N&&"string"==typeof h&&h.length?h:""].join(" ").trim()};`,x=void 0!==d?`border-radius: ${d}px;`:"",R=void 0!==g?`color: ${g}; fill: ${g};`:"",B=void 0!==m?`text-align: ${m};`:"",k=void 0!==v&&v?`box-shadow: 0 5px ${w}px 0 ${y};`:"",O=b instanceof Array&&1===b.length&&b[0],W=O?`margin: ${O.top}px ${O.right}px ${O.bottom}px ${O.left}px;`:"",L=O?`margin: calc(${O.top}px * 0.5) calc(${O.right}px * 0.5) calc(${O.bottom}px * 0.5) calc(${O.left}px * 0.5);`:"",D=f instanceof Array&&1===f.length&&f[0],V=D?`padding: ${D.top}px ${D.right}px ${D.bottom}px ${D.left}px;`:"",q=D?`padding: calc(${D.top}px * 0.5) calc(${D.right}px * 0.5) calc(${D.bottom}px * 0.5) calc(${D.left}px * 0.5);`:"",j=void 0!==T&&T?`border-width: ${T}px; border-style: solid;`:"",M=[_,T].every(e=>void 0!==e)&&T?`border-color: ${_};`:"",H=void 0!==E?`border-radius: ${E}px;`:"",U=void 0!==$?`background-color: ${$};`:"",G=void 0!==A?`color: ${A};`:"",K=void 0!==i&&"popin"===i?[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==p?p:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""):"",F=s||void 0!==S&&S?[`#${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;",R,"}"].join(""):"";return C.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,I,x,P,R,B,k,W,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",V,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,j,M,H,U,G,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,L,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,q,"}","}",K,F,`${t}`].join(""),C}}class f extends b{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: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class S extends b{constructor(){super(),this.position="string"==typeof DATA.layout&&"bannerTop"===DATA.layout?"top":"bottom",this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){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 T extends b{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 _={category:n,type:"slider",min:1},E=[{..._,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{..._,propName:"week",label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{..._,propName:"month",label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],$={category:n,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"},A={...$,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},C=(E.map(e=>({...e,propName:`${A.propName}_${e.propName}`,conditions:[{field:A.propName,value:e.propName}]})),{...$,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"}),I=(E.map(e=>({...e,propName:`${C.propName}_${e.propName}`,conditions:[{field:C.propName,value:e.propName}]})),{...$,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"});E.map(e=>({...e,propName:`${I.propName}_${e.propName}`,conditions:[{field:I.propName,value:e.propName}]}));C.condition=({closeButton:e,layout:t,overlayClickable:s})=>!("popin"===t&&!1===e&&!1===s||void 0!==t&&"popin"!==t&&!1===e);const N={pageLoad:{label:"widget_common_conditions_triggering_option_pageload",value:"pageLoad"},direct:{label:"widget_common_conditions_triggering_option_asap",value:"direct"},exitIntent:{label:"widget_common_conditions_triggering_option_exitIntent",value:"exitIntent"},reengage:{label:"widget_common_conditions_triggering_option_afterXSecondsOfInactivity",value:"reengage"},click:{label:"widget_common_conditions_triggering_option_click",value:"click"},elementVisible:{label:"widget_common_conditions_triggering_option_elementVisible",value:"elementVisible"},customScript:{label:"widget_common_conditions_triggering_option_customTrigger",value:"script"}};Object.keys(N).map(e=>N[e]);var P=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function x(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 R=function(e,t,s){return t&&x(e.prototype,t),s&&x(e,s),e},B=["count_72hours","count_168hours"],k=function(){function t(e){var s=e.parentContainer,i=e.response;P(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 R(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]/(B.includes(e)?24:1)}},{key:"getUnits",value:function(e){var t=DATA,s=t.daysTranslations,i=t.hoursTranslations;return B.includes(e)?s:i}}]),t}();!function(){d("Widget launch");var t=DATA,s=t.autoHide,i=t.timeHide,r=(()=>{const{layout:e}=DATA;let t;switch(e){case"popin":t=new f;break;case"bannerTop":case"bannerBottom":t=new S;break;case"free":t=new T;break;default:t=new b}return t})(),n=r.domElement.querySelector(".".concat(r.contentClassName)),o=new k({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})}(""));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.
|
4
|
+
"version": "1.1.1",
|
5
5
|
"main": "dist/main.js",
|
6
6
|
"form": "dist/form.js",
|
7
7
|
"icon": "icon.png",
|
@@ -16,9 +16,7 @@
|
|
16
16
|
"buildtestdeps": "rollup -c rolluptests.config.js",
|
17
17
|
"watch": "rollup -c --watch",
|
18
18
|
"build": "rollup -c",
|
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'"
|
19
|
+
"serve": "widget serve"
|
22
20
|
},
|
23
21
|
"devDependencies": {
|
24
22
|
"@babel/core": "^7.8.4",
|
@@ -37,11 +35,11 @@
|
|
37
35
|
"rollup-plugin-eslint": "^7.0.0"
|
38
36
|
},
|
39
37
|
"dependencies": {
|
40
|
-
"@abtasty/widget-utils": "
|
38
|
+
"@abtasty/widget-utils": "1.16.4-0",
|
41
39
|
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
|
42
40
|
"@rollup/plugin-commonjs": "^11.0.1",
|
43
41
|
"@rollup/plugin-node-resolve": "^7.0.0",
|
44
42
|
"babel-eslint": "^10.0.3",
|
45
43
|
"rollup-plugin-terser": "^5.2.0"
|
46
44
|
}
|
47
|
-
}
|
45
|
+
}
|
package/README.md
DELETED
@@ -1,52 +0,0 @@
|
|
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.
|