var DiscoveryGTM=function(){"use strict";function t(){f(),g(),u()}function e(t,e,a,n,o){this.id=t,this.name=e,this.creative=a,this.pos=n,this.servicePlatformCampaign=o}function a(t){"undefined"!=typeof dataLayer&&dataLayer.push({ecommerce:{promoView:{promotions:[t]}}})}function n(t){"undefined"!=typeof dataLayer&&dataLayer.push({ecommerce:{promoClick:{promotions:[t]}},event:"promotionClick",eventCallback:function(){}})}var o=function(t,a,n,o,i){return new e(t,a,n,o,i)},i=function(t,e,a,n,o){dataLayer.push({event:"analyticsEvent",eventCategory:t,eventAction:e,eventLabel:a,eventValue:n,eventNonInt:o})},m=function(t,e,a,n){dataLayer.push({event:t,event_parameters:{form_name:e,form_action:a,form_step:n}})},r=function(t,e){dataLayer.push({customDimensionName:e})},d=function(t){dataLayer.push({LeadsId:t})},s=function(t,e,a,n){dataLayer.push({event:"social",socialNetwork:t,socialAction:e,socialTarget:a,socialPagePath:n})},c=function(t){var e="";e="/"==t.substring(0,1)?"/vpv"+t:"/vpv/"+t,$(".form-group.has-error",$("form")).length<1&&dataLayer.push({event:"analyticsVPV",vpvName:e})},v=function(t,e,a){var n=t,o=e.name||e.id||e.type,m="form",r="field_completed",d=a+"_"+o+":"+e.type+"_"+n;i(m,r,d)},f=function(){$(".custom-gtm-event").off().on("click",function(){var t=$(this);if(void 0!==t.data("gtm-category")&&void 0!==t.data("gtm-action")){var e,a,n,o,m;e=void 0!==t.data("gtm-category")?t.data("gtm-category"):"category-undefined",a=void 0!==t.data("gtm-action")?t.data("gtm-action"):"action-undefined",n=void 0!==t.data("gtm-label")?t.data("gtm-label"):"",o=void 0!==t.data("gtm-value")?t.data("gtm-value"):"",m=void 0!==t.data("gtm-noninteractive")?t.data("gtm-noninteractive"):"",i(e,a,n,o,m)}})},u=function(){$(document).on("submit","form.ga4-form",function(){var t=$(this);if(void 0!==t.data("gtm-event")&&void 0!==t.data("gtm-form-name")&&void 0!==t.data("gtm-form-step")&&void 0!==t.data("gtm-action")){var e,a,n,o;a=void 0!==t.data("gtm-event")?t.data("gtm-event"):"event-type-undefined",e=void 0!==t.data("gtm-form-name")?t.data("gtm-form-name"):"form-name-undefined",n=void 0!==t.data("gtm-action")?t.data("gtm-action"):"action-undefined",o=void 0!==t.data("gtm-form-step")?t.data("gtm-form-step"):"form-step-undefined",m(a,e,n,o)}})},g=function(){if($(".gtm-promotion-impression").length){var t=$(".gtm-promotion-impression"),e=t.data("gtm-impression-id"),n=t.data("gtm-impression-name"),i=t.data("gtm-impression-creative"),m=t.data("gtm-impression-position");void 0==e&&(e="promotion-id-undefined"),void 0==n&&(n="promotion-name-undefined"),void 0==i&&(i="promotion-creative-undefined"),void 0==m&&(m="promotion-position-undefined"),a(o(e,n,i,m,null))}},p=function(t,e){var a={event:t,event_parameters:e};window.postMessage(a,"iframe")};return{init:t,onPromoView:a,onPromoClick:n,analyticsEvent:i,ga4LeadsFormEvent:m,analyticsSocial:s,analyticsVPV:c,analyticsForm:v,promotion:o,registerCustomEventClicks:f,registerPromotionImpressions:g,customDimension:r,customLeadsDimension:d,logDiscoveryGA4Service:p}}();$(function(){DiscoveryGTM.init()});