@abtasty/google-form-modal 1.6.8 → 1.6.10
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 +3 -3
- package/README.md +0 -1
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="undefined"!=typeof globalThis?globalThis:e||self).widgetForm=o()}(this,function(){"use strict";const e="style",o="layout",t="content",l="conditions",i="short-separator",a="select",n="colorpicker",r="number",_="selectelement",c="radio",p="switch",d="slider",m="group",g="inlinenotification",u="https://widgets-images.abtasty.com/",s="week",y="month",b=[{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:s},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:y},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],v={category:l,type:d,min:1},w=[{...v,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...v,propName:s,label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...v,propName:y,label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],h={category:l,type:a,options:b,value:"everytime"},f={...h,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},N={...h,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},k={...h,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},x=w.map(({type:e,min:o,propName:t,label:i,value:a,max:n})=>({category:l,type:e,min:o,max:n,label:i,value:a,propName:`${f.propName}_${t}`,conditions:[{field:f.propName,value:t}]})),B=w.map(({type:e,min:o,propName:t,label:i,value:a,max:n})=>({category:l,type:e,min:o,max:n,label:i,value:a,propName:`${N.propName}_${t}`,conditions:[{field:N.propName,value:t}]})),I=w.map(({type:e,min:o,propName:t,label:i,value:a,max:n})=>({category:l,type:e,min:o,max:n,label:i,value:a,propName:`${k.propName}_${t}`,conditions:[{field:k.propName,value:t}]})),P={category:l,type:i};N.condition=({closeButton:e,layout:o,overlay:t,overlayClickable:l,linkType:i})=>!("string"!=typeof i||!i.includes("Close"))||("popin"!==o||!1!==e||!1!==t&&!1!==l)&&(void 0===o||"popin"===o||!1!==e);const U={category:l,type:m,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[f,...x,{...P,condition:N.condition},N,...B,{...P},k,...I]},C="triggerEvent",T={category:l,type:d,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0},S={...T,propName:"triggerEventReengageDelay",value:10,max:180},z={category:l,type:_,propName:"triggerEventClick",value:"body"},R={...z,propName:"triggerEventElementVisible"},O={category:l,type:"codeeditor",label:"widget_common_conditions_triggering_label_customTriggerJSCode",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15},W={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"}},D={category:l,type:p,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce"},E={category:l,type:a,label:"widget_common_conditions_triggering_label",options:[W.pageLoad,W.direct,W.exitIntent,W.reengage,W.click,W.elementVisible,W.customScript],propName:C,value:"pageLoad"};z.conditions=[{field:C,value:"click"}],S.conditions=[{field:C,value:"reengage"}],R.conditions=[{field:C,value:"elementVisible"}],O.conditions=[{field:C,value:"script"}],T.conditions=[{field:C,value:e=>"reengage"!==e}],D.conditions=[{field:C,value:e=>"click"===e||"script"===e}];const H={category:l,type:m,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[E,z,R,O,D,S,T]},$={category:o,type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${u}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${u}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${u}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${u}layout/icon-layout-freePlacement.png`}]},V={category:o,type:_,propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},L={category:o,type:c,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"}]},A={category:o,type:"positioninput",propName:"popinPosition",label:"widget_common_layout_blockTitle_layout",value:[{x:1,y:1}],condition:({layout:e})=>"popin"===e},X=[{field:"layout",value:"free"}];V.conditions=X,L.conditions=X;const M={category:o,type:m,label:"widget_common_layout_blockTitle_layout",collapsible:!0,children:[$,V,A,L]},j={category:o,type:p,label:"widget_common_layout_toggler_widgetDimensionsBasedOnContent",propName:"autoWidth",value:!0},F=[{label:"px",value:"px"},{label:"%",value:"%"},{label:"em",value:"em"},{label:"vw (% of viewport width)",value:"vw"},{label:"vh (% of viewport height)",value:"vh"},{label:"vmin (% of viewport minimum size)",value:"vmin"},{label:"vmax (% of viewport maximum size)",value:"vmax"}],J={category:o,type:p,propName:"autoHeight",label:"widget_common_layout_toggler_label_keepHeightAuto",value:!0},q={category:o,type:a,propName:"widthUnit",value:"vw",options:F},G={category:o,type:a,propName:"heightUnit",value:"vh",condition:({autoHeight:e})=>!e,options:F},K={category:o,type:r,label:"widget_common_layout_popinDimensions_label_width",propName:"popinPercentWidth",value:50,max:100,condition:({widthUnit:e,layout:o})=>"px"!==e&&"popin"===o},Q={category:o,type:r,label:"widget_common_layout_popinDimensions_label_width",propName:"popinPixelsWidth",value:parseInt(window.innerWidth/2.5,10),max:window.innerWidth,condition:({widthUnit:e,layout:o})=>"px"===e&&"popin"===o},Y={category:o,type:r,label:"widget_common_layout_popinDimensions_label_height",propName:"popinPercentHeight",value:50,max:100,condition:({autoHeight:e,heightUnit:o,layout:t})=>!e&&"px"!==o&&"popin"===t},Z={category:o,type:r,label:"widget_common_layout_popinDimensions_label_height",propName:"popinPixelsHeight",value:parseInt(window.innerHeight/2.5,10),max:window.innerHeight,condition:({autoHeight:e,heightUnit:o,layout:t})=>!e&&"px"===o&&"popin"===t},ee=({autoWidth:e})=>!e;q.condition=ee,J.condition=ee;const oe=K.condition;K.condition=e=>oe(e)&&ee(e);const te=Q.condition;Q.condition=e=>te(e)&&ee(e);const le=Y.condition;Y.condition=e=>le(e)&&ee(e);const ie=Z.condition;Z.condition=e=>ie(e)&&ee(e);const ae=G.condition;G.condition=e=>ae(e)&&ee(e);const ne={category:o,type:m,collapsible:!0,label:"widget_common_layout_blockTitle_dimensions",children:[j,K,Q,q,J,Y,Z,G],conditions:[{field:"layout",value:"popin"}]},re={category:o,type:g,label:"widget_common_layout_zindex_alert_text",hrefUrl:"widget_common_layout_zindex_alert_link"},_e={category:o,type:m,label:"widget_common_layout_blockTitle_layering",collapsible:!0,children:[{category:o,type:c,propName:"zindex",value:"9999",label:"widget_common_layout_zIndex_label",options:[{label:"widget_common_layout_zIndex_radio_option_above",value:"2147483647"},{label:"widget_common_layout_zIndex_radio_option_default",value:"9999"},{label:"widget_common_layout_zIndex_radio_option_auto",value:"auto"},{label:"widget_common_layout_zIndex_radio_option_under",value:"-1"},{label:"widget_common_layout_zIndex_radio_option_custom",value:"custom"}]},{category:o,type:r,propName:"zindexCustom",label:"widget_common_layout_zIndex_custom_numberInput_label",value:1,min:-2147483647,max:2147483647,conditions:[{field:"zindex",value:"custom"}]}],conditions:[{field:"layout",value:e=>"free"!==e}]},ce={field:"isBackgroundImage",value:!0},pe={field:"backgroundSize",value:e=>"100% 100%"!==e},de={category:e,type:n,label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},me={category:e,type:p,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},ge={category:e,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:"",conditions:[ce]},ue={category:e,type:c,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"}],conditions:[ce]},se={category:e,type:a,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"}],conditions:[ce,pe]},ye={category:e,type:p,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1,conditions:[ce,pe,{field:"backgroundSize",value:e=>"cover"!==e}]},be={category:e,type:n,label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},ve={category:e,type:d,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},we={category:e,type:d,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},he={category:e,type:"areainput"},fe={...he,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},Ne={...he,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},ke={category:e,type:p,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},xe={category:e,type:n,label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},Be={category:e,type:d,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},Ie={category:e,type:p,label:"widget_common_style_closeButton_label_displayCloseButton",propName:"closeButton",value:!0},Pe={category:e,type:c,label:"widget_common_style_closeButton_radio_closeButtonPosition",propName:"closeButtonPosition",value:"in",options:[{label:"widget_common_style_closeButton_radio_closeButtonPosition_option_inside",value:"in"},{label:"widget_common_style_closeButton_radio_closeButtonPosition_option_outside",value:"out"}]},Ue={category:e,type:d,label:"widget_common_style_closeButton_label_closeButtonSize",propName:"closeButtonSize",value:16,min:10,max:50},Ce={category:e,type:n,label:"widget_common_style_closeButton_label_closeButtonColor",propName:"closeButtonColor",value:"rgba(119, 119, 119, 1)"},Te={category:e,type:n,label:"widget_common_style_closeButton_label_closeButtonBackgroundColor",propName:"closeButtonBackgroundColor",value:"rgba(255, 255, 255, 0)"},Se={category:e,type:d,label:"widget_common_style_closeButton_label_closeButtonBorderRadius",propName:"closeButtonBorderRadius",value:0,min:0,max:50},ze={category:e,type:d,label:"widget_common_style_closeButton_label_closeButtonBorderThickness",propName:"closeButtonBorderWidth",value:0,min:0,max:50},Re={category:e,type:n,label:"widget_common_style_closeButton_label_closeButtonBorderColor",propName:"closeButtonBorderColor",value:"rgba(57, 57, 57, 1)",condition:({closeButtonBorderWidth:e})=>e>0},Oe={category:e,type:p,propName:"overlay",label:"widget_common_style_blockTitle_overlay",value:!0},We={category:e,type:n,label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},De={category:e,type:p,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},Ee=[de,me,ge,ue,se,ye],He=[{field:we.propName,value:e=>e>0}];be.conditions=He;const $e={category:e,type:m,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[we,be,ve]},Ve={category:e,type:i},Le=[{field:"dropShadow",value:!0}];xe.conditions=Le,Be.conditions=Le;const Ae={category:e,type:m,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[fe,Ne,{...Ve},...Ee,{...Ve},ke,xe,Be]},Xe=[{field:"overlay"}];We.conditions=Xe,De.conditions=Xe;const Me={category:e,type:m,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[Oe,We,De],conditions:[{field:"layout",value:"popin"}]},je=({closeButton:e})=>e,Fe={category:e,type:i,condition:je},Je=Re.condition;Pe.condition=je,Ue.condition=je,Ce.condition=je,Te.condition=je,Se.condition=je,ze.condition=je,Re.condition=e=>Je(e)&&je(e);const qe={category:e,type:m,label:"widget_common_style_blockTitle_closeButton",collapsible:!0,children:[Ie,Pe,{...Fe},Ue,Ce,Te,{...Fe},Se,ze,Re]};Ae.collapsed=!1,M.collapsed=!1,H.collapsed=!1,Ae.children.find(function(e){return"containerPadding"===e.propName}).value=[{top:0,left:0,bottom:0,right:0}];var Ge=M.children.find(function(e){return"layout"===e.propName});Ge.options=Ge.options.filter(function(e){return!e.value.includes("banner")}),U.children=U.children.filter(function(e,o){return!e.propName&&"validationRecurrence"!==U.children[o+1].propName||e.propName&&!e.propName.includes("validationRecurrence")});var Ke=ne.children.find(function(e){return"autoWidth"===e.propName}),Qe=ne.children.find(function(e){return"autoHeight"===e.propName});return Ke.value=!1,Qe.value=!1,[M,ne,re,_e,{type:g,category:t,label:"widget_iframe_closable_alert_text",hrefUrl:"widget_iframe_closable_alert_link"},{propName:"iframeUrl",type:"url",category:t,label:"widget_iframe_content_label_iframeUrl",value:"widget_iframe_content_defaultUrl"},Ae,$e,Me,qe,H,U]});
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).widgetForm=o()}(this,function(){"use strict";const e="style",o="layout",t="content",l="conditions",i="short-separator",n="select",a="colorpicker",r="number",c="selectelement",_="radio",d="switch",p="slider",m="group",g="inlinenotification",u="https://widgets-images.abtasty.com/",s=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","audio","canvas","iframe","optgroup","option","progress","select","svg","textarea","video"],y="week",b="month",v=[{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:y},{label:"widget_common_conditions_recurrence_option_everyXMonths",value:b},{label:"widget_common_conditions_recurrence_option_once",value:"once"}],w={category:l,type:p,min:1},f=[{...w,propName:"day",label:"widget_common_conditions_recurrence_ifOptionVariable_labelDays",value:5,max:395},{...w,propName:y,label:"widget_common_conditions_recurrence_ifOptionVariable_labelWeeks",value:2,max:56},{...w,propName:b,label:"widget_common_conditions_recurrence_ifOptionVariable_labelMonths",value:1,max:13}],h={category:l,type:n,options:v,value:"everytime",render:!1},N={...h,label:"widget_common_conditions_recurrence_label_widgetDisplayed",propName:"displayRecurrence"},k={...h,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterClosure",propName:"closingRecurrence"},x={...h,label:"widget_common_conditions_recurrence_label_widgetDisplayedAfterSubmission",propName:"validationRecurrence"},B=f.map(({type:e,min:o,propName:t,label:i,value:n,max:a})=>({category:l,type:e,min:o,max:a,label:i,value:n,render:!1,propName:`${N.propName}_${t}`,conditions:[{field:N.propName,value:t}]})),I=f.map(({type:e,min:o,propName:t,label:i,value:n,max:a})=>({category:l,type:e,min:o,max:a,label:i,value:n,render:!1,propName:`${k.propName}_${t}`,conditions:[{field:k.propName,value:t}]})),T=f.map(({type:e,min:o,propName:t,label:i,value:n,max:a})=>({category:l,type:e,min:o,max:a,label:i,value:n,render:!1,propName:`${x.propName}_${t}`,conditions:[{field:x.propName,value:t}]})),C={category:l,type:i};k.condition=({closeButton:e,layout:o,overlay:t,overlayClickable:l,linkType:i})=>!("string"!=typeof i||!i.includes("Close"))||("popin"!==o||!1!==e||!1!==t&&!1!==l)&&(void 0===o||"popin"===o||!1!==e);const P={category:l,type:m,label:"widget_common_conditions_recurrence_blockTitle",collapsible:!0,children:[N,...B,{...C,condition:k.condition},k,...I,{...C},x,...T]},U="triggerEvent",S={category:l,type:p,propName:"triggerEventDelay",label:"widget_common_conditions_triggering_delay_label",min:0,max:60,value:0,render:!1},z={...S,propName:"triggerEventReengageDelay",value:10,max:180,render:!1},R={category:l,type:c,propName:"triggerEventClick",value:"body",render:!1},D={...R,propName:"triggerEventElementVisible",render:!1},O={category:l,type:"codeeditor",label:"widget_common_conditions_triggering_label_customTriggerJSCode",propName:"triggerEventCustomScript",value:"/* In this example snippet, the widget will be triggered as soon as any scroll is detected.\nCreate your own by resolving resolve() with true (which does trigger) or false (which doesn't trigger) */\n\nfunction launchIfScroll() {\n\treturn new Promise(resolve => {\n\t\tdocument.addEventListener('scroll', () => resolve(true), {once: true});\n\t});\n}\n\nconst result = await launchIfScroll();\nreturn resolve(result);",rows:15,render:!1},W={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"}},E={category:l,type:d,propName:"isOncePerPageTrigger",value:!0,label:"widget_common_conditions_triggering_label_triggerOnlyOnce",render:!1},A={category:l,type:n,label:"widget_common_conditions_triggering_label",options:[W.pageLoad,W.direct,W.exitIntent,W.reengage,W.click,W.elementVisible,W.customScript],propName:U,value:"pageLoad",render:!1};R.conditions=[{field:U,value:"click"}],z.conditions=[{field:U,value:"reengage"}],D.conditions=[{field:U,value:"elementVisible"}],O.conditions=[{field:U,value:"script"}],S.conditions=[{field:U,value:e=>"reengage"!==e}],E.conditions=[{field:U,value:e=>"click"===e||"script"===e}];const H={category:l,type:m,label:"widget_common_conditions_triggering_blockTitle",collapsible:!0,children:[A,R,D,O,E,z,S]},L={category:o,type:"radioImage",propName:"layout",label:"widget_common_layout_label_selectALayout",value:"popin",style:"big",options:[{label:"widget_common_layout_option_modal",value:"popin",src:`${u}layout/icon-layout-modal.png`},{label:"widget_common_layout_option_topBanner",value:"bannerTop",src:`${u}layout/icon-layout-topBanner.png`},{label:"widget_common_layout_option_bottomBanner",value:"bannerBottom",src:`${u}layout/icon-layout-bottomBanner.png`},{label:"widget_common_layout_option_freePlacement",value:"free",src:`${u}layout/icon-layout-freePlacement.png`}]},$={category:o,type:c,propName:"elementReferrer",label:"widget_common_layout_label_selectElementContainWidget",value:"body"},V=({elementReferrer:e})=>{try{const o=window.ABTASTY_S&&window.ABTASTY_S.CLIENT_MANAGER.getDocument();return!s.includes(o.querySelector(e).tagName.toLowerCase())}catch(e){return!0}},M={category:o,type:_,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",condition:V,fallback:"beforebegin"},{label:"widget_common_layout_positioning_option_atTheEnd",value:"beforeend",condition:V,fallback:"afterend"},{label:"widget_common_layout_positioning_option_after",value:"afterend"}]},X={category:o,type:"positioninput",propName:"popinPosition",label:"widget_common_layout_blockTitle_layout",value:[{x:1,y:1}],condition:({layout:e})=>"popin"===e},Y=[{field:"layout",value:"free"}];$.conditions=Y,M.conditions=Y;const j={category:o,type:m,label:"widget_common_layout_blockTitle_layout",collapsible:!0,children:[L,$,X,M]},q={category:o,type:d,label:"widget_common_layout_toggler_widgetDimensionsBasedOnContent",propName:"autoWidth",value:!0},F=[{label:"px",value:"px"},{label:"%",value:"%"},{label:"em",value:"em"},{label:"vw (% of viewport width)",value:"vw"},{label:"vh (% of viewport height)",value:"vh"},{label:"vmin (% of viewport minimum size)",value:"vmin"},{label:"vmax (% of viewport maximum size)",value:"vmax"}],G={category:o,type:d,propName:"autoHeight",label:"widget_common_layout_toggler_label_keepHeightAuto",value:!0},J={category:o,type:n,propName:"widthUnit",value:"vw",options:F},K={category:o,type:n,propName:"heightUnit",value:"vh",condition:({autoHeight:e})=>!e,options:F},Q={category:o,type:r,label:"widget_common_layout_popinDimensions_label_width",propName:"popinPercentWidth",value:50,max:100,condition:({widthUnit:e,layout:o})=>"px"!==e&&"popin"===o},Z={category:o,type:r,label:"widget_common_layout_popinDimensions_label_width",propName:"popinPixelsWidth",value:parseInt(window.innerWidth/2.5,10),max:window.innerWidth,condition:({widthUnit:e,layout:o})=>"px"===e&&"popin"===o},ee={category:o,type:r,label:"widget_common_layout_popinDimensions_label_height",propName:"popinPercentHeight",value:50,max:100,condition:({autoHeight:e,heightUnit:o,layout:t})=>!e&&"px"!==o&&"popin"===t},oe={category:o,type:r,label:"widget_common_layout_popinDimensions_label_height",propName:"popinPixelsHeight",value:parseInt(window.innerHeight/2.5,10),max:window.innerHeight,condition:({autoHeight:e,heightUnit:o,layout:t})=>!e&&"px"===o&&"popin"===t},te=({autoWidth:e})=>!e;J.condition=te,G.condition=te;const le=Q.condition;Q.condition=e=>le(e)&&te(e);const ie=Z.condition;Z.condition=e=>ie(e)&&te(e);const ne=ee.condition;ee.condition=e=>ne(e)&&te(e);const ae=oe.condition;oe.condition=e=>ae(e)&&te(e);const re=K.condition;K.condition=e=>re(e)&&te(e);const ce={category:o,type:m,collapsible:!0,label:"widget_common_layout_blockTitle_dimensions",children:[q,Q,Z,J,G,ee,oe,K],conditions:[{field:"layout",value:"popin"}]},_e={category:o,type:g,label:"widget_common_layout_zindex_alert_text",hrefUrl:"widget_common_layout_zindex_alert_link"},de={category:o,type:m,label:"widget_common_layout_blockTitle_layering",collapsible:!0,children:[{category:o,type:_,propName:"zindex",value:"9999",label:"widget_common_layout_zIndex_label",options:[{label:"widget_common_layout_zIndex_radio_option_above",value:"2147483647"},{label:"widget_common_layout_zIndex_radio_option_default",value:"9999"},{label:"widget_common_layout_zIndex_radio_option_auto",value:"auto"},{label:"widget_common_layout_zIndex_radio_option_under",value:"-1"},{label:"widget_common_layout_zIndex_radio_option_custom",value:"custom"}]},{category:o,type:r,propName:"zindexCustom",label:"widget_common_layout_zIndex_custom_numberInput_label",value:1,min:-2147483647,max:2147483647,conditions:[{field:"zindex",value:"custom"}]}],conditions:[{field:"layout",value:e=>"free"!==e}]},pe={field:"isBackgroundImage",value:!0},me={field:"backgroundSize",value:e=>"100% 100%"!==e},ge={category:e,type:a,label:"widget_common_style_container_label_backgroundColor",propName:"backgroundColor",value:"rgba(247, 247, 247, 1)"},ue={category:e,type:d,label:"widget_common_style_toggler_label_backgroundImage",propName:"isBackgroundImage",value:!1},se={category:e,type:"mediaupload",label:"widget_common_style_toggler_label_backgroundImage",propName:"backgroundImage",value:"",conditions:[pe]},ye={category:e,type:_,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"}],conditions:[pe]},be={category:e,type:n,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"}],conditions:[pe,me]},ve={category:e,type:d,label:"widget_common_style_backgroundImageUploader_toggler_repeatBackgroundImage",propName:"backgroundRepeat",value:!1,conditions:[pe,me,{field:"backgroundSize",value:e=>"cover"!==e}]},we={category:e,type:a,label:"widget_common_style_border_label_borderColor",propName:"borderColor",value:"rgba(0, 127, 145, 1)"},fe={category:e,type:p,label:"widget_common_style_border_label_borderRadius",propName:"borderRadius",value:4,unit:"px"},he={category:e,type:p,label:"widget_common_style_border_label_borderThickness",propName:"borderWidth",value:2,min:0,max:50,unit:"px"},Ne={category:e,type:"areainput"},ke={...Ne,label:"widget_common_style_container_label_margin",propName:"containerMargin",value:[{top:0,left:0,bottom:0,right:0}]},xe={...Ne,label:"widget_common_style_container_label_padding",propName:"containerPadding",value:[{top:35,left:60,bottom:35,right:60}]},Be={category:e,type:d,label:"widget_common_style_container_dropShadow_blockTitle",propName:"dropShadow",value:!1},Ie={category:e,type:a,label:"widget_common_style_container_dropShadow_label_color",propName:"dropShadowColor",value:"rgba(57, 57, 57, 0.25);"},Te={category:e,type:p,label:"widget_common_style_container_dropShadow_label_blurRadius",propName:"dropShadowBlur",value:10,unit:"px"},Ce={category:e,type:d,label:"widget_common_style_closeButton_label_displayCloseButton",propName:"closeButton",value:!0},Pe={category:e,type:_,label:"widget_common_style_closeButton_radio_closeButtonPosition",propName:"closeButtonPosition",value:"in",options:[{label:"widget_common_style_closeButton_radio_closeButtonPosition_option_inside",value:"in"},{label:"widget_common_style_closeButton_radio_closeButtonPosition_option_outside",value:"out"}]},Ue={category:e,type:p,label:"widget_common_style_closeButton_label_closeButtonSize",propName:"closeButtonSize",value:16,min:10,max:50},Se={category:e,type:a,label:"widget_common_style_closeButton_label_closeButtonColor",propName:"closeButtonColor",value:"rgba(119, 119, 119, 1)"},ze={category:e,type:a,label:"widget_common_style_closeButton_label_closeButtonBackgroundColor",propName:"closeButtonBackgroundColor",value:"rgba(255, 255, 255, 0)"},Re={category:e,type:p,label:"widget_common_style_closeButton_label_closeButtonBorderRadius",propName:"closeButtonBorderRadius",value:0,min:0,max:50},De={category:e,type:p,label:"widget_common_style_closeButton_label_closeButtonBorderThickness",propName:"closeButtonBorderWidth",value:0,min:0,max:50},Oe={category:e,type:a,label:"widget_common_style_closeButton_label_closeButtonBorderColor",propName:"closeButtonBorderColor",value:"rgba(57, 57, 57, 1)",condition:({closeButtonBorderWidth:e})=>e>0},We={category:e,type:d,propName:"overlay",label:"widget_common_style_blockTitle_overlay",value:!0},Ee={category:e,type:a,label:"widget_common_style_overlay_label_overlayColor",propName:"overlayColor",value:"rgba(0, 0, 0, 0.6)"},Ae={category:e,type:d,label:"widget_common_style_overlay_label_overlayClickable",propName:"overlayClickable",value:!0},He=[ge,ue,se,ye,be,ve],Le=[{field:he.propName,value:e=>e>0}];we.conditions=Le;const $e={category:e,type:m,label:"widget_common_style_blockTitle_border",collapsible:!0,children:[he,we,fe]},Ve={category:e,type:i},Me=[{field:"dropShadow",value:!0}];Ie.conditions=Me,Te.conditions=Me;const Xe={category:e,type:m,label:"widget_common_style_blockTitle_container",collapsible:!0,children:[ke,xe,{...Ve},...He,{...Ve},Be,Ie,Te]},Ye=[{field:"overlay"}];Ee.conditions=Ye,Ae.conditions=Ye;const je={category:e,type:m,label:"widget_common_style_blockTitle_overlay",collapsible:!0,children:[We,Ee,Ae],conditions:[{field:"layout",value:"popin"}]},qe=({closeButton:e})=>e,Fe={category:e,type:i,condition:qe},Ge=Oe.condition;Pe.condition=qe,Ue.condition=qe,Se.condition=qe,ze.condition=qe,Re.condition=qe,De.condition=qe,Oe.condition=e=>Ge(e)&&qe(e);const Je={category:e,type:m,label:"widget_common_style_blockTitle_closeButton",collapsible:!0,children:[Ce,Pe,{...Fe},Ue,Se,ze,{...Fe},Re,De,Oe]};Xe.collapsed=!1,j.collapsed=!1,H.collapsed=!1,Xe.children.find(function(e){return"containerPadding"===e.propName}).value=[{top:0,left:0,bottom:0,right:0}];var Ke=j.children.find(function(e){return"layout"===e.propName});Ke.options=Ke.options.filter(function(e){return!e.value.includes("banner")}),P.children=P.children.filter(function(e,o){return!e.propName&&"validationRecurrence"!==P.children[o+1].propName||e.propName&&!e.propName.includes("validationRecurrence")});var Qe=ce.children.find(function(e){return"autoWidth"===e.propName}),Ze=ce.children.find(function(e){return"autoHeight"===e.propName});return Qe.value=!1,Ze.value=!1,[j,ce,_e,de,{type:g,category:t,label:"widget_iframe_closable_alert_text",hrefUrl:"widget_iframe_closable_alert_link"},{propName:"iframeUrl",type:"url",category:t,label:"widget_iframe_content_label_iframeUrl",value:"widget_iframe_content_defaultUrl"},Xe,$e,je,Je,H,P]});
|
package/dist/main.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),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=()=>!e()&&(s()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),r=()=>window.ABTasty&&!0===window.ABTasty.consentReady,n="remove",o="rebuild",a="https://api-social-proof.abtasty.com/clients/",c=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},h=()=>{const e=c();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},l=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,d=t=>{if((()=>{if(e()||s())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0})()){const e=h();window.console.log(`%c${e} - QA Mode for campaign ${TEST_ID}\n${t}`,"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)=>{let s=document.querySelector(e);const i=[document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],r=()=>o.disconnect(),n=()=>o.observe(...i),o=new MutationObserver(()=>(s=document.querySelector(e),s&&!r()&&t(s)));return s?setTimeout(()=>t(s),0):n(),{selector:e,clear:r,observe:n}};function m(e,t){return t(e)||!e.parentElement?e:m(e.parentElement,t)}class p{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"===m(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)||(t&&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));const s=document.querySelector(e);s&&this.visibilityObserver.unobserve(s),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class v{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 async function(){let e;return e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||new Promise((e,t)=>{const s=window.document.getElementsByTagName("script")[0],i=window.document.createElement("script");i.src="https://polyfill.io/v3/polyfill.min.js?flags=gated&features=IntersectionObserver",s.parentNode.insertBefore(i,s),i.onload=e,i.onerror=t})),e}(),n=new p;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",({isTrusted:e})=>e&&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",({isTrusted:e,target:s})=>e&&i(s)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e}onExitIntent({promise:e,resolve:t}){const s=["mouseleave",({isTrusted:e,clientY:s})=>{e&&s<=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=[({isTrusted:e})=>{e&&(i=s)},{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:o,spNoTrim:c}=DATA;return i||(d("Not able to find ABTastyProductKey, impossible to call the API."),s(!1)),i&&r?fetch(`${a}${r}/metrics/i?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===o)return!1;const t=void 0!==e[n]&&e[n]>=o;return t||d(`Widget will not be shown, product has been purchased ${e[n]} times while ${o} are required`),t})(e)&&s(`${e[n]}`)).catch(()=>d("Failed to fetch datas from server.")):s(!1),e}getSocialProofPageViews({promise:e,resolve:s}){const{viewInterval:i,triggerSocialProofMinPageViews:r,spNoTrim:n}=DATA,o=encodeURIComponent(n?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),c=t();return o&&c?fetch(`${a}${c}/metrics/pv?key=${o}${n?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===i||void 0===r)return!1;const t=void 0!==e[i]&&e[i]>=r;return t||d(`Widget will not be shown, page has been seen ${e[i]} times while ${r} are required`),t})(e)&&s(`${e[i]}`)).catch(()=>d("Failed to fetch datas from server.")):s(!1),e}onConsent({promise:e,resolve:t}){if(!r()){const s=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(s),window.addEventListener(...s),e}return t(!0),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...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={consent:()=>this.onConsent(e),direct:()=>!0,pageLoad:()=>this.onPageLoad(e),click:()=>this.onClick(e),exitIntent:()=>this.onExitIntent(e),reengage:()=>this.onReengage(e),elementVisible:()=>this.onElementVisible(e),script:()=>this.onCustomTrigger(e),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},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}}const y="closing",w="validation",b="ABTastyWidgets",f="ABTastyWidgetsTemporary";class ${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=c(),this.uniqueId=l(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(f),s=sessionStorage.getItem(b);"ABTastyData"===e&&!t&&s&&localStorage.setItem(f,s)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(b);return JSON.parse(t)}catch(t){return e.removeItem(b),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:s,...i}=t;return Object.entries(i).length?(e.setItem(b,JSON.stringify(i)),i):(e.removeItem(b),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=localStorage.getItem(f),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(b,e),localStorage.removeItem(f));const s=this.getLocalRecurrence(),i=(s?parseFloat(s.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&i&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const i=this.getTypeOfStorage(e);if(s()||!i&&"object"!=typeof i)return!1;const{storageString:n,storageMethod:o}=i,a=this.getStamp(e),c={type:t,stamp:a},{type:h}=this.getCurrentRecurrence(),l=async()=>{if(!r()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new v({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===n?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===n&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const i=s?{[this.recurrenceKey]:c,...s}:{[this.recurrenceKey]:c};o.setItem(b,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(h&&t!==w)if(t===y&&h!==w)l();else{if("display"!==t||h===w||h===y)return!1;l()}else l();return a}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 S{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};let r;const a=this.isWidgetApplied(),c=(()=>{const t=this.recurrenceIsDone();return e&&"display"===s||t})();return!a&&t&&c?r=o:(a&&(!t||!c)||!a&&!t)&&(r=n),"string"==typeof r&&(this.clearWatcher(),this.callback(r,e),this.watch()),this}eventHandler(){let e=i();return[250,500].forEach(t=>{setTimeout(()=>{const s=i();return 500===t&&s===e?this:(e=s,this.decisionHandler(!1))},t)}),this}observerHandler(e){return e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler(!0):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=()=>{const e=[document.body,{childList:!0,subtree:!0}];this.observer.observe(...e)};return document.body?t():(()=>{const e=g("body",()=>{t(),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});this.elementsWaiters.push(e)})(),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const T=/.+\/([^.]+)\.(otf|ttf)$/;class C{constructor(){this.children=void 0,this.uniqueId=l(),this.widgetName=c(),this.prettyName=h(),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",h="reengage"===t?i:o;return r&&(t=1===r?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:h}})(),this.recurrence=!!this.recurrenceParams&&new $(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new v(this.triggerParams),this.pageWatcher=new S(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(e=>e===t)})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=new Promise(e=>{const t=g("head",t=>{this.elementsWaiters=this.elementsWaiters.filter(({selector:e})=>"head"!==e),e(t.appendChild(this.styleElement))});this.elementsWaiters.push(t)}),t=new Promise(e=>{const{elementReferrer:t="body",referrerInsertType:s="beforeend"}=DATA,i=g(t,i=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==t),this.removeOldDomElement(),e(i.insertAdjacentElement(s,this.domElement))});this.elementsWaiters.push(i)});return Promise.all([t,e]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(e=>e&&e.isConnected&&e.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return!e()&&this.hasBeenShown&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){const s=e(),r=i(),n=this.trigger&&this.trigger.promises.length,o=!this.recurrence||this.recurrence.isOver();if(!s&&!r||n||!o)return!1;this.pageWatcher.watch();const a=s||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!a&&(await this.insert(),this.addCloseEvent(),s||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),{container:this,response:a})}onPageChange(e,t){const s=()=>this.init().then(({response:e})=>e&&this.show());t||(this.hasBeenShown=!1);const i=this.isWidgetApplied(),r={[n]:()=>{i?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch())},[o]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():i||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):s()}};"function"==typeof r[e]&&r[e]()}addCloseEvent(...t){const{closeButton:s,overlay:i,overlayClickable:r,layout:n}=DATA,o=[];if(void 0!==i&&!0!==i||!0!==r||"popin"!==n||o.push(`.${this.overlayClassName}`),void 0!==s&&s&&o.push(`.${this.closeButtonClassName}`),!o.length)return this;const a=this.domElement.querySelectorAll(o.join(", "));return a.length?(t.push(...a),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",t=>{(t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())})(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{once:!0,capture:!0})}),this):this}getDom(){const{closeButton:e,layout:t,overlay:s=!0}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.innerHTML=`\n\t\t\t${"popin"===t&&!0===s?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,i}loadFont(e,t){if(!e||"inherit"===e)return;const s=document.createElement("style"),i=t.match(T)?t.match(T)[1]:"";s.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}');}`,document.head.appendChild(s)}getStyleTag(t=""){const{noStyles:s,layout:i}=DATA,{backgroundColor:r,isBackgroundImage:n,backgroundImage:o,backgroundSize:a,backgroundPosition:c,backgroundRepeat:h,borderColor:l,borderRadius:d,borderWidth:u,textColor:g,textAlign:m,fontName:p,fontStyle:v,fontSize:y,isTitle:w,titleTextAlign:b,titleTextColor:f,titleFontName:$,titleFontStyle:S,titleFontSize:C,overlay:E,overlayColor:A,dropShadow:I,dropShadowColor:x,dropShadowBlur:P,containerMargin:R,containerPadding:N,closeButton:B,closeButtonPosition:L,closeButtonSize:O,closeButtonBorderRadius:k,closeButtonBorderWidth:W,closeButtonBorderColor:D,closeButtonColor:_,closeButtonBackgroundColor:q,buttonsBorderWidth:V,buttonsBorderColor:j,buttonsBorderRadius:M,buttonsBackgroundColor:H,buttonsTextColor:F,buttonsFontName:z,buttonsFontStyle:U,buttonsFontSize:G}=s?{}:DATA,K=document.createElement("style");K.type="text/css",e()&&K.setAttribute("abtasty-script-added","true"),this.loadFont(p,v),this.loadFont($,S),this.loadFont(z,U);const Y=`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&&h&&!["cover","100% 100%"].includes(a)?"repeat":"no-repeat"].join(" ").trim()};`,J="number"==typeof u&&u>0,Q=`border: ${[J?`${u}px`:"unset",J?"solid":"",J&&"string"==typeof l&&l.length?l:""].join(" ").trim()};`,X=void 0!==d?`border-radius: ${d}px;`:"",Z=void 0!==g?`color: ${g}; fill: ${g}; -webkit-text-fill-color: ${g};`:"",ee=void 0!==m?`text-align: ${m};`:"",te=p&&"inherit"!==p?`font-family:${p}_${v.match(T)?v.match(T)[1]:""};`:v||"",se=y?`font-size: ${y}px;`:"",ie=void 0!==I&&I?`box-shadow: 0 5px ${P}px 0 ${x};`:"",re=R instanceof Array&&1===R.length&&R[0],ne=re?`margin: ${re.top}px ${re.right}px ${re.bottom}px ${re.left}px;`:"",oe=re?`margin: calc(${re.top}px * 0.5) calc(${re.right}px * 0.5) calc(${re.bottom}px * 0.5) calc(${re.left}px * 0.5);`:"",ae=N instanceof Array&&1===N.length&&N[0],ce=ae?`padding: ${ae.top}px ${ae.right}px ${ae.bottom}px ${ae.left}px;`:"",he=ae?`padding: calc(${ae.top}px * 0.5) calc(${ae.right}px * 0.5) calc(${ae.bottom}px * 0.5) calc(${ae.left}px * 0.5);`:"",le=void 0!==V&&V?`border-width: ${V}px; border-style: solid;`:"",de=[j,V].every(e=>void 0!==e)&&V?`border-color: ${j};`:"",ue=void 0!==M?`border-radius: ${M}px;`:"",ge=void 0!==H?`background-color: ${H};`:"",me=void 0!==F?`color: ${F}; fill: ${F}; -webkit-text-fill-color: ${F};`:"",pe=z&&"inherit"!==z?`font-family:${z}_${U.match(T)?U.match(T)[1]:""};`:U||"",ve=G?`font-size: ${G}px;`:"",ye="popin"!==i||void 0!==E&&!0!==E?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==A?A:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),we="number"==typeof O?O:16,be=we/2,fe=s||void 0!==B&&B?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===L?`bottom: calc(100% + ${be}px)`:`top: ${be}px`)+";",`right: ${be}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof k?`border-radius: ${k}px;`:"","number"==typeof W&&W>0?`border: ${W}px solid ${void 0!==D?D:"rgba(57, 57, 57, 1)"};`:"","string"==typeof q?`background-color: ${q};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${we}px;`,`height: ${we}px;`,"string"==typeof _?`fill: ${_};`:"","}"].join(""):"",$e=w&&"string"==typeof f?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${f}; fill: ${f}; -webkit-text-fill-color: ${f};`,void 0!==b?`text-align: ${b};`:"",$&&"inherit"!==$?`font-family:${$}_${S.match(T)?S.match(T)[1]:""};`:S||"",C?`font-size: ${C}px;`:"","}"].join(""):"";return K.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,Y,X,Q,Z,ee,ie,ne,te,se,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,Z,ee,te,se,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",ce,te,se,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,"box-sizing: border-box;","display: inline-block;",le,de,ue,ge,me,pe,ve,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button * {`,me,pe,ve,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,oe,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,he,"}","}",ye,fe,$e,`${t}`].join(""),K}}const E=["top: 0;","top: 50%;","bottom: 0;"],A=["left: 0;","left: 50%;","right: 0;"],I=e=>1===e?"-50%":0,x=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,s=`translate(${I(t)}, ${I(e)});`;return`${E[e]}${A[t]}transform: ${s}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},P=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,R=()=>{if(P())return"width: auto;height: auto;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:s,autoHeight:i,popinPercentHeight:r,popinPixelsHeight:n,heightUnit:o}=DATA;return`width: ${"px"===s?t:e}${s};height: ${i?"auto":`${"px"===o?n:r}${o}`};`};class N extends C{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t,overlay:s}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"opacity: 1;","transition: opacity 0.25s ease;","background: none;","pointer-events: "+(!1===s?"none":"all"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",x(),R(),"pointer-events: all","}",`${P()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class B extends C{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}var L;"string"==typeof(L=DATA.iframeUrl)&&L.length&&function(){var e,t=DATA,s=t.layout,i=t.frameReferrerInsertType,r=t.frameElementReferrer;switch(s){case"popin":e=new N;break;default:e=new B(i,r)}var n,o,a,c=e.domElement.querySelector(".".concat(e.contentClassName)),h=function(e){var t=DATA.iframeUrl,s=document.createElement("iframe");return s.id="tasty_frame_".concat(e),s.src=t,s}(e.uniqueId);n=e.styleElement,o=e.uniqueId,a="\n #tasty_frame_".concat(o," {\n box-sizing: border-box;\n border: none;\n width: 100%;\n height: 100%;\n }"),n.insertAdjacentHTML("beforeend",a),c.appendChild(h),e.init().then(function(t){return t&&e.show()})}()}();
|
1
|
+
!function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),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=()=>!e()&&(s()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),r=()=>window.ABTasty&&!0===window.ABTasty.consentReady,n="remove",o="rebuild",a="https://api-social-proof.abtasty.com/clients/",c=()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`},h=()=>{const e=c();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")},l=()=>`${PLUGIN_ID.split("-")[0]}_${TEST_ID}`,d=t=>{if((()=>{if(e()||s())return!1;const t=ABTasty.getTestsOnPage()[TEST_ID];return!!t&&Object.keys(t.targetings.qaParameters).length>0})()){const e=h();window.console.log(`%c${e} - QA Mode for campaign ${TEST_ID}\n${t}`,"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)=>{const s=()=>{try{return document.querySelector(e)}catch(e){return null}};let i=s();const r=[document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],n=()=>a.disconnect(),o=()=>a.observe(...r),a=new MutationObserver(()=>(i=s(),i&&!n()&&t(i)));return i?setTimeout(()=>t(i),0):o(),{selector:e,clear:n,observe:o}};function m(e,t){return t(e)||!e.parentElement?e:m(e.parentElement,t)}class p{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"===m(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)||(t&&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));const s=document.querySelector(e);s&&this.visibilityObserver.unobserve(s),0===this.targets.length&&this.mutationObserver.disconnect(),0===this.inViewportTargets.length&&this.mouseOverEvent.clear()}}class v{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 async function(){let e;return e=await("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype||new Promise((e,t)=>{const s=window.document.getElementsByTagName("script")[0],i=window.document.createElement("script");i.src="",s.parentNode.insertBefore(i,s),i.onload=e,i.onerror=t})),e}(),n=new p;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",({isTrusted:e})=>e&&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",({isTrusted:e,target:s})=>e&&i(s)&&t(!0),{passive:!0,capture:!0}];return this.eventsListeners.push(r),document.addEventListener(...r),e}onExitIntent({promise:e,resolve:t}){const s=["mouseleave",({isTrusted:e,clientY:s})=>{e&&s<=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=[({isTrusted:e})=>{e&&(i=s)},{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:o,spNoTrim:c}=DATA;return i||(d("Not able to find ABTastyProductKey, impossible to call the API."),s(!1)),i&&r?fetch(`${a}${r}/metrics/i?key=${i}${c?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===n||void 0===o)return!1;const t=void 0!==e[n]&&e[n]>=o;return t||d(`Widget will not be shown, product has been purchased ${e[n]} times while ${o} are required`),t})(e)&&s(`${e[n]}`)).catch(()=>d("Failed to fetch datas from server.")):s(!1),e}getSocialProofPageViews({promise:e,resolve:s}){const{viewInterval:i,triggerSocialProofMinPageViews:r,spNoTrim:n}=DATA,o=encodeURIComponent(n?window.location.href.replace(window.location.origin,""):`${window.location.pathname}`),c=t();return o&&c?fetch(`${a}${c}/metrics/pv?key=${o}${n?"&noTrim=true":""}`).then(e=>e.ok&&e.json()).then(e=>(e=>{if(void 0===i||void 0===r)return!1;const t=void 0!==e[i]&&e[i]>=r;return t||d(`Widget will not be shown, page has been seen ${e[i]} times while ${r} are required`),t})(e)&&s(`${e[i]}`)).catch(()=>d("Failed to fetch datas from server.")):s(!1),e}onConsent({promise:e,resolve:t}){if(!r()){const s=["abtasty_consentValid",()=>t(!0)];return this.eventsListeners.push(s),window.addEventListener(...s),e}return t(!0),e}clear(){if(this.elementsSelectors.length&&(this.elementsSelectors.forEach(e=>{document.querySelector(e)&&document.querySelector(e).remove()}),this.elementsSelectors=[]),this.eventsListeners.length&&(this.eventsListeners.forEach(e=>{const[t,...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={consent:()=>this.onConsent(e),direct:()=>!0,pageLoad:()=>this.onPageLoad(e),click:()=>this.onClick(e),exitIntent:()=>this.onExitIntent(e),reengage:()=>this.onReengage(e),elementVisible:()=>this.onElementVisible(e),script:()=>this.onCustomTrigger(e),socialProofPurchases:()=>this.getSocialProofPurchases(e),socialProofPageViews:()=>this.getSocialProofPageViews(e)},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}}const y="closing",w="validation",b="ABTastyWidgets",f="ABTastyWidgetsTemporary";class ${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=c(),this.uniqueId=l(),this.recurrenceKey=`${this.widgetName}_${this.uniqueId}`,this.isListeningStorageEvent=this.listenStorageEvent(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}onStorage({key:e}){const t=localStorage.getItem(f),s=sessionStorage.getItem(b);"ABTastyData"===e&&!t&&s&&localStorage.setItem(f,s)}listenStorageEvent(){return this.isListeningStorageEvent||window.addEventListener("storage",this.onStorage.bind(this)),!0}getGivenRecurrenceStorageParsed(e){try{const t=e.getItem(b);return JSON.parse(t)}catch(t){return e.removeItem(b),!1}}getSessionRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.sessionStorage)}getLocalRecurrenceStorageParsed(){return this.getGivenRecurrenceStorageParsed(window.localStorage)}removeGivenStorage(e,t){const{[this.recurrenceKey]:s,...i}=t;return Object.entries(i).length?(e.setItem(b,JSON.stringify(i)),i):(e.removeItem(b),!1)}removeSessionRecurrenceStorage(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.sessionStorage,e)}removeLocalRecurrenceStorage(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&this.removeGivenStorage(window.localStorage,e)}getSessionRecurrence(){const e=this.getSessionRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getLocalRecurrence(){const e=this.getLocalRecurrenceStorageParsed();return!!e&&e[this.recurrenceKey]}getCurrentRecurrence(){if(this.pendingRecurrence)return this.pendingRecurrenceValue;const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();return e||t||{type:!1}}isOver(){const e=localStorage.getItem(f),t=!(!e||!e.includes(this.recurrenceKey))||this.getSessionRecurrence();e&&(sessionStorage.setItem(b,e),localStorage.removeItem(f));const s=this.getLocalRecurrence(),i=(s?parseFloat(s.stamp):0)<(new Date).getTime();return i&&this.removeLocalRecurrenceStorage(),!this.pendingRecurrence&&i&&!this.getLocalRecurrence()&&!t}setRecurrence(e,t){0!==e&&(window.removeEventListener("storage",this.onStorage.bind(this)),this.isListeningStorageEvent=!1);const i=this.getTypeOfStorage(e);if(s()||!i&&"object"!=typeof i)return!1;const{storageString:n,storageMethod:o}=i,a=this.getStamp(e),c={type:t,stamp:a},{type:h}=this.getCurrentRecurrence(),l=async()=>{if(!r()){this.pendingRecurrence=!0,this.pendingRecurrenceValue=c;const e=new v({triggerEvent:"consent"});await e.isTriggered(),this.pendingRecurrence=!1,this.pendingRecurrenceValue={}}const e=this.getSessionRecurrence(),t=this.getLocalRecurrence();let s;"session"===n?e?s=this.removeSessionRecurrenceStorage():(this.removeLocalRecurrenceStorage(),s=this.getSessionRecurrenceStorageParsed()):"local"===n&&(t?s=this.removeLocalRecurrenceStorage():(this.removeSessionRecurrenceStorage(),s=this.getLocalRecurrenceStorageParsed()));const i=s?{[this.recurrenceKey]:c,...s}:{[this.recurrenceKey]:c};o.setItem(b,JSON.stringify(i)),this.onSetCallback&&"function"==typeof this.onSetCallback&&this.onSetCallback()};if(!o)return!1;if(h&&t!==w)if(t===y&&h!==w)l();else{if("display"!==t||h===w||h===y)return!1;l()}else l();return a}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 S{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};let r;const a=this.isWidgetApplied(),c=(()=>{const t=this.recurrenceIsDone();return e&&"display"===s||t})();return!a&&t&&c?r=o:(a&&(!t||!c)||!a&&!t)&&(r=n),"string"==typeof r&&(this.clearWatcher(),this.callback(r,e),this.watch()),this}eventHandler(){let e=i();return[250,500].forEach(t=>{setTimeout(()=>{const s=i();return 500===t&&s===e?this:(e=s,this.decisionHandler(!1))},t)}),this}observerHandler(e){return e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler(!0):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=()=>{const e=[document.body,{childList:!0,subtree:!0}];this.observer.observe(...e)};return document.body?t():(()=>{const e=g("body",()=>{t(),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});this.elementsWaiters.push(e)})(),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}const T=/.+\/([^.]+)\.(otf|ttf)$/;class C{constructor(){this.children=void 0,this.uniqueId=l(),this.widgetName=c(),this.prettyName=h(),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",h="reengage"===t?i:o;return r&&(t=1===r?"socialProofPurchases":"socialProofPageViews"),{triggerEvent:t,triggerSelector:c,triggerDelay:h}})(),this.recurrence=!!this.recurrenceParams&&new $(this.recurrenceParams,this.clearGivenClearables.bind(this)),this.trigger=!!this.triggerParams&&new v(this.triggerParams),this.pageWatcher=new S(this.recurrence,this.isWidgetApplied.bind(this),this.onPageChange.bind(this)),this.hasOncePerPageTrigger=(()=>{const{isOncePerPageTrigger:e,triggerEvent:t}=DATA;return!t||!(!e||!["click","script"].includes(t))||["pageLoad","direct","reengage","socialProofPurchases","socialProofPageViews","elementVisible"].some(e=>e===t)})(),this.basicClassName=`ab_widget_container_${this.widgetName}`,this.widgetContainerId=`${this.basicClassName}_${this.uniqueId}`,this.contentClassName=`${this.basicClassName}_content`,this.overlayClassName=`${this.basicClassName}_overlay`,this.closeButtonClassName=`${this.basicClassName}_close_button`,this.hideClassName=`ab_hide_${this.uniqueId}`,this.domElement=this.getDom(),this.hasBeenShown=!1,this.closedByUser=!1,this.eventsListeners=[],this.timeouts=[],this.intervals=[],this.observers=[],this.promises=[],this.elementsWaiters=[]}clearGivenClearables(){this.eventsListeners.length&&(this.eventsListeners.forEach(e=>document.removeEventListener(...e)),this.eventsListeners=[]),this.timeouts.length&&(this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts=[]),this.intervals.length&&(this.intervals.forEach(e=>clearInterval(e)),this.intervals=[]),this.observers.length&&(this.observers.forEach(e=>e.disconnect()),this.observers=[]),this.promises.length&&(this.promises.forEach(e=>e.resolve(!1)),this.promises=[]),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[])}isWidgetApplied(){return this.domElement&&this.domElement.isConnected}removeOldDomElement(){const e=document.getElementById(this.widgetContainerId);return e&&e.remove(),this}async insert(){if(this.isWidgetApplied())return!1;const e=new Promise(e=>{const t=g("head",t=>{this.elementsWaiters=this.elementsWaiters.filter(({selector:e})=>"head"!==e),e(t.appendChild(this.styleElement))});this.elementsWaiters.push(t)}),t=new Promise(e=>{const{elementReferrer:t="body",referrerInsertType:s="beforeend"}="free"===DATA.layout?DATA:{},i=g(t,i=>{this.elementsWaiters=this.elementsWaiters.filter(e=>e.selector!==t),this.removeOldDomElement(),e(i.insertAdjacentElement(s,this.domElement))});this.elementsWaiters.push(i)});return Promise.all([t,e]).then(()=>this)}remove(){return this.pageWatcher.clearWatcher(),[this.domElement,this.styleElement].forEach(e=>e&&e.isConnected&&e.remove()),this.hasOncePerPageTrigger?this.pageWatcher.watch():e()||this.init().then(({response:e})=>e?this.show():this),this}show(){return e()||this.hasBeenShown&&this.hasOncePerPageTrigger||window.ABTastyEvent(`${this.prettyName} displayed`,null,TEST_ID),this.closedByUser=!1,this.domElement.classList.remove(this.hideClassName),this.recurrence&&this.recurrence.setDisplayRecurrence(),this.hasBeenShown=!0,this.pageWatcher.watch(),this}hide(){return!e()&&this.hasBeenShown&&window.ABTastyEvent(`${this.prettyName} closed`,null,TEST_ID),this.closedByUser=!0,this.domElement.classList.add(this.hideClassName),this}async init(t){const s=e(),r=i(),n=this.trigger&&this.trigger.promises.length,o=!this.recurrence||this.recurrence.isOver();if(!s&&!r||n||!o)return!1;this.pageWatcher.watch();const a=s||!this.trigger||this.trigger&&await this.trigger.isTriggered();return!!a&&(await this.insert(),this.addCloseEvent(),s||t||this.hasBeenShown||void 0===this.children||"function"!=typeof this.children.refreshContent||this.children.refreshContent(a),{container:this,response:a})}onPageChange(e,t){const s=()=>this.init().then(({response:e})=>e&&this.show());t||(this.hasBeenShown=!1);const i=this.isWidgetApplied(),r={[n]:()=>{i?this.remove():(this.trigger&&this.trigger.clear(),this.pageWatcher.watch())},[o]:()=>{this.hasBeenShown?this.closedByUser?this.pageWatcher.watch():i||this.insert().then(e=>e.show()).catch(this.pageWatcher.watch):s()}};"function"==typeof r[e]&&r[e]()}addCloseEvent(...t){const{closeButton:s,overlay:i,overlayClickable:r,layout:n}=DATA,o=[];if(void 0!==i&&!0!==i||!0!==r||"popin"!==n||o.push(`.${this.overlayClassName}`),void 0!==s&&s&&o.push(`.${this.closeButtonClassName}`),!o.length)return this;const a=this.domElement.querySelectorAll(o.join(", "));return a.length?(t.push(...a),t.forEach(t=>{e()&&(t.dataset.abtastyActionnable="true"),t.addEventListener("click",t=>{(t=>{e()||(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation())})(t),this.recurrence&&this.recurrence.setClosingRecurrence(),this.hide(),setTimeout(()=>this.remove(),1e3)},{once:!0,capture:!0})}),this):this}getDom(){const{closeButton:e,layout:t,overlay:s=!0}=DATA,i=document.createElement("div");return i.className=`${this.basicClassName} ${this.hideClassName}`,i.id=this.widgetContainerId,i.innerHTML=`\n\t\t\t${"popin"===t&&!0===s?`<div class="${this.overlayClassName}"></div>`:""}\n\t\t\t<div class="${this.contentClassName}">\n\t\t\t${e?`<button class="${this.closeButtonClassName}"><svg viewBox="0 0 16 16">\n\t<defs><path id="prefix__a" d="M12 4.991L11.009 4 8 7.009 4.991 4 4 4.991 7.009 8 4 11.009 4.991 12 8 8.991 11.009 12 12 11.009 8.991 8z"></path></defs>\n\t<g><use xlink:href="#prefix__a"></use></g>\n</svg></button>`:""}\n\t\t\t</div>`,i}loadFont(e,t){if(!e||"inherit"===e)return;const s=document.createElement("style"),i=t.match(T)?t.match(T)[1]:"";s.innerHTML=`@font-face { font-family: '${e}_${i}'; src: url('${t}');}`,document.head.appendChild(s)}getStyleTag(t="",s=DATA){const{noStyles:i,layout:r}=s,{backgroundColor:n,isBackgroundImage:o,backgroundImage:a,backgroundSize:c,backgroundPosition:h,backgroundRepeat:l,borderColor:d,borderRadius:u,borderWidth:g,textColor:m,textAlign:p,fontName:v,fontStyle:y,fontSize:w,isTitle:b,titleTextAlign:f,titleTextColor:$,titleFontName:S,titleFontStyle:C,titleFontSize:E,overlay:A,overlayColor:I,dropShadow:x,dropShadowColor:P,dropShadowBlur:R,containerMargin:N,containerPadding:B,closeButton:L,closeButtonPosition:O,closeButtonSize:k,closeButtonBorderRadius:W,closeButtonBorderWidth:D,closeButtonBorderColor:_,closeButtonColor:V,closeButtonBackgroundColor:q,buttonsBorderWidth:j,buttonsBorderColor:M,buttonsBorderRadius:H,buttonsBackgroundColor:F,buttonsTextColor:z,buttonsFontName:U,buttonsFontStyle:G,buttonsFontSize:K}=i?{}:s,Y=document.createElement("style");Y.type="text/css",e()&&Y.setAttribute("abtasty-script-added","true"),this.loadFont(v,y),this.loadFont(S,C),this.loadFont(U,G);const J=`background: ${["string"==typeof n?n:"rgba(255, 255, 255, 1)",o&&"string"==typeof a&&a.length?`url(${a})`:"",o&&"string"==typeof h&&"100% 100%"!==c?h:"0 0",o&&"string"==typeof c?`/ ${c}`:"/ auto",o&&l&&!["cover","100% 100%"].includes(c)?"repeat":"no-repeat"].join(" ").trim()};`,Q="number"==typeof g&&g>0,X=`border: ${[Q?`${g}px`:"unset",Q?"solid":"",Q&&"string"==typeof d&&d.length?d:""].join(" ").trim()};`,Z=void 0!==u?`border-radius: ${u}px;`:"",ee=void 0!==m?`color: ${m}; fill: ${m}; -webkit-text-fill-color: ${m};`:"",te=void 0!==p?`text-align: ${p};`:"",se=v&&"inherit"!==v?`font-family:${v}_${y.match(T)?y.match(T)[1]:""};`:y||"",ie=w?`font-size: ${w}px;`:"",re=void 0!==x&&x?`box-shadow: 0 5px ${R}px 0 ${P};`:"",ne=N instanceof Array&&1===N.length&&N[0],oe=ne?`margin: ${ne.top}px ${ne.right}px ${ne.bottom}px ${ne.left}px;`:"",ae=ne?`margin: calc(${ne.top}px * 0.5) calc(${ne.right}px * 0.5) calc(${ne.bottom}px * 0.5) calc(${ne.left}px * 0.5);`:"",ce=B instanceof Array&&1===B.length&&B[0],he=ce?`padding: ${ce.top}px ${ce.right}px ${ce.bottom}px ${ce.left}px;`:"",le=ce?`padding: calc(${ce.top}px * 0.5) calc(${ce.right}px * 0.5) calc(${ce.bottom}px * 0.5) calc(${ce.left}px * 0.5);`:"",de=void 0!==j&&j?`border-width: ${j}px; border-style: solid;`:"",ue=[M,j].every(e=>void 0!==e)&&j?`border-color: ${M};`:"",ge=void 0!==H?`border-radius: ${H}px;`:"",me=void 0!==F?`background-color: ${F};`:"",pe=void 0!==z?`color: ${z}; fill: ${z}; -webkit-text-fill-color: ${z};`:"",ve=U&&"inherit"!==U?`font-family:${U}_${G.match(T)?G.match(T)[1]:""};`:G||"",ye=K?`font-size: ${K}px;`:"",we="popin"!==r||void 0!==A&&!0!==A?"":[`#${this.widgetContainerId} .${this.overlayClassName} {`,`background-color: ${void 0!==I?I:"rgba(0, 0, 0, 0.6)"};`,"}"].join(""),be="number"==typeof k?k:16,fe=be/2,$e=i||void 0!==L&&L?[`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} {`,"position: absolute;",("out"===O?`bottom: calc(100% + ${fe}px)`:`top: ${fe}px`)+";",`right: ${fe}px;`,"width: auto;","height: auto;","background: none;","border: none;","cursor: pointer;","outline: none;","padding: 0;","margin: 0;","line-height: 0;","z-index: 9;","number"==typeof W?`border-radius: ${W}px;`:"","number"==typeof D&&D>0?`border: ${D}px solid ${void 0!==_?_:"rgba(57, 57, 57, 1)"};`:"","string"==typeof q?`background-color: ${q};`:"","}",`#${this.widgetContainerId} .${this.contentClassName} .${this.closeButtonClassName} svg {`,"pointer-events: none;",`width: ${be}px;`,`height: ${be}px;`,"string"==typeof V?`fill: ${V};`:"","}"].join(""):"",Se=b&&"string"==typeof $?[`#${this.widgetContainerId} .${this.contentClassName} > * h1, `,`#${this.widgetContainerId} .${this.contentClassName} > * h2, `,`#${this.widgetContainerId} .${this.contentClassName} > * h3, `,`#${this.widgetContainerId} .${this.contentClassName} > * h4, `,`#${this.widgetContainerId} .${this.contentClassName} > * h5, `,`#${this.widgetContainerId} .${this.contentClassName} > * h6 {`,`color: ${$}; fill: ${$}; -webkit-text-fill-color: ${$};`,void 0!==f?`text-align: ${f};`:"",S&&"inherit"!==S?`font-family:${S}_${C.match(T)?C.match(T)[1]:""};`:C||"",E?`font-size: ${E}px;`:"","}"].join(""):"";return Y.textContent=[`.${this.hideClassName} {`,"opacity: 0 !important;","pointer-events: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,J,Z,X,ee,te,re,oe,se,ie,"}",`#${this.widgetContainerId} .${this.contentClassName} p {`,ee,te,se,ie,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,"display: block;","line-height: 1;","text-indent: unset;",he,se,ie,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a, `,`#${this.widgetContainerId} .${this.contentClassName} > * button {`,"box-sizing: border-box;","display: inline-block;",de,ue,ge,me,pe,ve,ye,"}",`#${this.widgetContainerId} .${this.contentClassName} > * a *, `,`#${this.widgetContainerId} .${this.contentClassName} > * button * {`,pe,ve,ye,"}","@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,ae,"}",`#${this.widgetContainerId} .${this.contentClassName} > * {`,le,"}","}",we,$e,Se,`${t}`].join(""),Y}}const E=["top: 0;","top: 50%;","bottom: 0;"],A=["left: 0;","left: 50%;","right: 0;"],I=e=>1===e?"-50%":0,x=()=>{if(Array.isArray(DATA.popinPosition)){const{popinPosition:[{x:e,y:t}]}=DATA,s=`translate(${I(t)}, ${I(e)});`;return`${E[e]}${A[t]}transform: ${s}`}return"left: 50%;top: 50%;transform: translate(-50%, -50%);"},P=()=>"autoWidth"in DATA&&!0===DATA.autoWidth,R=()=>{if(P())return"width: auto;height: auto;";const{popinPercentWidth:e,popinPixelsWidth:t,widthUnit:s,autoHeight:i,popinPercentHeight:r,popinPixelsHeight:n,heightUnit:o}=DATA;return`width: ${"px"===s?t:e}${s};height: ${i?"auto":`${"px"===o?n:r}${o}`};`};class N extends C{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){const{zindex:e,zindexCustom:t,overlay:s}=DATA;return[`#${this.widgetContainerId} {`,"position: fixed;","top: 0;","left: 0;","width: 100%;","height: 100%;",`z-index: ${"custom"===e?t:e};`,"opacity: 1;","transition: opacity 0.25s ease;","background: none;","pointer-events: "+(!1===s?"none":"all"),"}",`#${this.widgetContainerId} .${this.overlayClassName} {`,"position: absolute;","z-index: -1;","top: 0;","left: 0;","width: 100%;","height: 100%;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: absolute;",x(),R(),"pointer-events: all","}",`${P()?"":[`#${this.widgetContainerId} .${this.contentClassName} > div {`,"height: 100%;","overflow: auto;","box-sizing: border-box;","}"].join("")}`,"@media screen and (max-width: 579px) {",`#${this.widgetContainerId} .${this.contentClassName} {`,"max-width: 94vw;","}","}"].join("")}}class B extends C{constructor(){super(),this.stringStyles=this.getStyles(),this.styleElement=this.getStyleTag(this.stringStyles)}getStyles(){return[`#${this.widgetContainerId} {`,"width: auto;","height: auto;","margin: 0;","padding: 0;","background: none;","}",`#${this.widgetContainerId} .${this.contentClassName} {`,"position: relative;","}"].join("")}}var L;"string"==typeof(L=DATA.iframeUrl)&&L.length&&function(){var e,t=DATA,s=t.layout,i=t.frameReferrerInsertType,r=t.frameElementReferrer;switch(s){case"popin":e=new N;break;default:e=new B(i,r)}var n,o,a,c=e.domElement.querySelector(".".concat(e.contentClassName)),h=function(e){var t=DATA.iframeUrl,s=document.createElement("iframe");return s.id="tasty_frame_".concat(e),s.src=t,s}(e.uniqueId);n=e.styleElement,o=e.uniqueId,a="\n #tasty_frame_".concat(o," {\n box-sizing: border-box;\n border: none;\n width: 100%;\n height: 100%;\n }"),n.insertAdjacentHTML("beforeend",a),c.appendChild(h),e.init().then(function(t){return t&&e.show()})}()}();
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@abtasty/google-form-modal",
|
3
3
|
"description": "Widget for AB Tasty",
|
4
|
-
"version": "1.6.
|
4
|
+
"version": "1.6.10",
|
5
5
|
"form": "dist/form.js",
|
6
6
|
"main": "dist/main.js",
|
7
7
|
"files": [
|
@@ -34,6 +34,6 @@
|
|
34
34
|
"rollup-plugin-terser": "^7.0.0"
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@abtasty/widget-utils": "^1.18.
|
37
|
+
"@abtasty/widget-utils": "^1.18.19"
|
38
38
|
}
|
39
|
-
}
|
39
|
+
}
|
package/README.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Engage Plugin Base
|