
function setActiveCarouselItem(a){$(a).find(".carousel-item:first").addClass("active")}function initTestimonialsCarousel(a){a=$(a);var b=a.attr("ID")+"-carousel";a.find(".carousel").attr("id",b);a.find(".carousel-controls a").attr("href","#"+b);a.find(".carousel-indicators li").attr("data-target","#"+b);setActiveCarouselItem(a)}
function initClientCarousel(a){a=$(a);var b=a.find(".carousel-item").length,c=a.find(".carousel-inner").attr("data-visible");b<c&&(c=b);a.find(".carousel-inner").attr("class","carousel-inner slides"+c);a.find(".clonedCol").remove();a.find(".carousel-item .col-md-12").each(function(){2>c?$(this).attr("class","col-md-12"):"5"==c?$(this).attr("class","col-md-12 col-lg-15"):$(this).attr("class","col-md-12 col-lg-"+12/c)});a.find(".carousel-item").each(function(){for(var a=$(this),b=1;b<c;b++){a=a.next();
a.length||(a=$(this).siblings(":first"));var d=a.index();a.find(".col-md-12:first").clone().addClass("cloneditem-"+b).addClass("clonedCol").attr("data-cloned-index",d).appendTo($(this).children().eq(0))}})}
function updateClientCarousel(a){a=$(a);var b=a.find(".carousel-item").length,c=a.find(".carousel-inner").attr("data-visible");b<c&&(c=b);a.find(".clonedCol").remove();a.find(".carousel-item").each(function(){for(var a=$(this),b=1;b<c;b++){a=a.next();a.length||(a=$(this).siblings(":first"));var d=a.index();a.find(".col-md-12:first").clone().addClass("cloneditem-"+b).addClass("clonedCol").attr("data-cloned-index",d).appendTo($(this).children().eq(0))}})}
function clickHandler(a){a.stopPropagation();a.preventDefault();a=$(a.target);var b;a.closest(".clonedCol").length?(b=a.closest(".clonedCol"),b=b.attr("data-cloned-index")):(b=a.closest(".carousel-item"),b=b.index());b=$(a.closest(".carousel-inner").find(".carousel-item")[b]).find("img")[0];0<a.parents(".clonedCol").length&&b.click()}var isBuilder=$("html").hasClass("is-builder");
if(isBuilder)$(document).on("add.cards",function(a){if($(a.target).hasClass("clients")){initTestimonialsCarousel(a.target);initClientCarousel(a.target);if("add"===a.type)$(a.target).on("slide.bs.carousel",function(){updateClientCarousel(a.target)});$(a.target).find(".carousel-item [mbr-media]").on("click",function(a){clickHandler(a)});$(a.target).on("slide.bs.carousel",function(){$(a.target).find(".carousel-item .clonedCol [mbr-media]").off("click").on("click",function(a){clickHandler(a)})})}}).on("changeParameter.cards",
function(a,b,c){"slidesCount"==b&&0==$(a.target).find(".carousel-item.active").length&&setActiveCarouselItem(a.target);initClientCarousel(a.target);updateClientCarousel(a.target);$(a.target).find(".carousel-item [mbr-media]").on("click",function(a){clickHandler(a)});$(a.target).on("slide.bs.carousel",function(){$(a.target).find(".carousel-item .clonedCol [mbr-media]").off("click").on("click",function(a){clickHandler(a)})})}).on("changeContent.cards",function(a,b){updateClientCarousel(a.target);try{$(a.target).closest(".carousel").carousel("next")}catch(c){}});
else"undefined"===typeof window.initClientPlugin&&(window.initClientPlugin=!0,$(document.body).find(".clients").each(function(a,b){$(this).attr("data-isinit")||(initTestimonialsCarousel($(this)),initClientCarousel($(this)))}));
