(($,t,i)=>{"use strict";!function(t,i,e){t.fn.tb_backstretch=function(s,r){return void 0!==r&&(void 0===r.mode&&(void 0!==i.themifyScript&&i.themifyScript.backgroundMode?r.mode=themifyScript.backgroundMode:void 0!==i.themifyVars&&i.themifyVars.backgroundMode&&(r.mode=themifyVars.backgroundMode)),void 0===r.position&&(void 0!==i.themifyScript&&i.themifyScript.backgroundPosition&&i.themifyScript.backgroundPosition?r.position=i.themifyScript.backgroundPosition:void 0!==i.themifyVars&&i.themifyVars.backgroundPosition&&i.themifyVars.backgroundPosition&&(r.position=i.themifyVars.backgroundPosition)),void 0===r.is_first&&(r.is_first=!0)),(s===e||0===s.length)&&t.error("No images were supplied for Backstretch"),0===t(i).scrollTop()&&i.scrollTo(0,0),this.each((function(){var i=t(this),e=i.data("tb_backstretch");if(e){if("string"==typeof s&&"function"==typeof e[s])return void e[s](r);r=t.extend(e.options,r),e.destroy(!0)}e=new h(this,s,r),i.data("tb_backstretch",e)}))},t.tb_backstretch=(i,e)=>t("body").tb_backstretch(i,e).data("tb_backstretch"),t.expr.pseudos.tb_backstretch=i=>t(i).data("tb_backstretch")!==e,t.fn.tb_backstretch.defaults={centeredX:!0,centeredY:!0,duration:5e3,fade:0,mode:"",position:""};var s={left:0,top:0,overflow:"hidden",margin:0,padding:0,height:"100%",width:"100%",zIndex:-999999},r={position:"absolute",display:"none",margin:0,padding:0,border:"none",width:"auto",height:"auto",maxHeight:"none",maxWidth:"none",zIndex:-999999},h=function(e,r,h){for(var o in this.options=t.extend({},t.fn.tb_backstretch.defaults,h||{}),this.images=t.isArray(r)?r:[r],this.images)t("<img />")[0].src=void 0===this.images[o].url?this.images[o]:this.images[o].url;this.isBody=e===document.body,this.$container=t(e),this.$root=this.isBody?t(i):this.$container,e=this.$container.children(".tb_backstretch").first(),this.$wrap=e.length?e:t('<span class="tb_backstretch"></span>').css(s).appendTo(this.$container),this.isBody||(e=this.$container.css("position"),r=this.$container.css("zIndex"),this.$container.css({position:"static"===e?"relative":e,zIndex:"auto"===r?0:r,backgroundImage:"none"}),this.$wrap.css({zIndex:-999998})),this.$wrap.css({position:this.isBody?"fixed":"absolute"}),this.index=0,this.show(this.index,this.options.is_first),t(i).on("resize.tb_backstretch",t.proxy(this.resize,this)).on("orientationchange.tb_backstretch",t.proxy((function(){this.isBody&&0===i.pageYOffset&&(i.scrollTo(0,1),this.resize())}),this))};h.prototype={resize(){try{var t,e={left:0,top:0},s=this.isBody?this.$root.width():this.$root.innerWidth(),r=s,h=this.isBody?i.innerHeight?i.innerHeight:this.$root.height():this.$root.innerHeight(),o=r/this.$img.data("ratio");"best-fit"===this.options.mode&&(r/h>parseFloat(this.$img.data("ratio"))?this.$img.addClass("best-fit-vertical").removeClass("best-fit-horizontal"):this.$img.addClass("best-fit-horizontal").removeClass("best-fit-vertical")),o>=h?(t=(o-h)/2,this.options.centeredY&&(e.top="-"+t+"px")):(t=((r=(o=h)*this.$img.data("ratio"))-s)/2,this.options.centeredX&&(e.left="-"+t+"px")),this.$wrap.css({width:s,height:h}).find("img:not(.deleteable)").css({width:r,height:o}).css(e)}catch(t){}return this},show(i,e){if(!(Math.abs(i)>this.images.length-1)){var s,h=this,o=h.$wrap.find("img").addClass("deleteable"),n={relatedTarget:h.$container[0]};return h.$container.trigger(t.Event("tb_backstretch.before",n),[h,i]),this.index=i,clearInterval(h.interval),h.$img=t("<img />").css(r).bind("load",(function(s){var r=this.width||t(s.target).width();if(s=this.height||t(s.target).height(),t(this).data("ratio",r/s),void 0!==h){if("best-fit"===h.options.mode){t(this).parent().addClass("best-fit-wrap");var a=r/s;h.$wrap.width()/h.$wrap.height()>a?t(this).addClass("best-fit best-fit-vertical"):t(this).addClass("best-fit best-fit-horizontal")}else"fullcover"===h.options.mode&&h.options.position?t(this).addClass("fullcover-"+h.options.position):"kenburns-effect"===h.options.mode&&t(this).parent().addClass("kenburns-effect");e&&t(this).show()}t(this).fadeIn(h.options.speed||h.options.fade,(function(){o.remove(),h.paused||h.cycle(),t(["after","show"]).each((function(){h.$container.trigger(t.Event("tb_backstretch."+this,n),[h,i])}))})),h.resize()})).appendTo(h.$wrap),void 0===h.images[i].url?s=h.images[i]:(s=h.images[i].url,h.images[i].alt&&h.$img.attr("alt",h.images[i].alt)),h.$img.attr("src",s),h}},next(){return this.show(this.index<this.images.length-1?this.index+1:0,!1)},prev(){return this.show(0===this.index?this.images.length-1:this.index-1,!1)},pause(){return this.paused=!0,this},resume(){return this.paused=!1,this.next(),this},cycle(){return 1<this.images.length&&(clearInterval(this.interval),this.interval=setInterval(t.proxy((function(){this.paused||this.next()}),this),this.options.duration)),this},destroy(e){t(i).off("resize.tb_backstretch orientationchange.tb_backstretch"),clearInterval(this.interval),e||this.$wrap.remove(),this.$container.removeData("tb_backstretch")}}}(jQuery,window),i.autoplay=i.backgroundSlider?.autoplay?~~i.backgroundSlider.autoplay:5e3;const e=e=>{i.autoplay<=10&&(i.autoplay*=1e3);for(let r=e.length-1;r>-1;--r){let h=e[r],o=$(h),n=o.parent(),a=h.firstElementChild.children,c=[];for(var s=a.length-1;s>-1;--s)c.push({url:a[s].dataset.bg,alt:a[s].dataset.bgAlt});n.tb_backstretch(c,{speed:~~h.dataset.sliderspeed,duration:i.autoplay,mode:h.dataset.bgmode});let d=n.data("tb_backstretch"),l=o.find(".row-slider-slides > span"),b="row-slider-dot-active";for(a=h.querySelectorAll(".row-slider-prev,.row-slider-next,.row-slider-dot"),s=a.length-1;s>-1;--s)a[s].tfOn("click",(function(t){this.classList.contains("row-slider-dot")?d.show($(this).data("index")):(t.preventDefault(),this.classList.contains("row-slider-prev")?d.prev():d.next())}),{passive:a[s].classList.contains("row-slider-dot")});if(l[0]&&(l[0].classList.add(b),n.on("tb_backstretch.show",((t,i)=>{const e=l.eq(d.index);e[0]&&(l.removeClass(b),e.addClass(b))}))),"kenburns-effect"===h.dataset.bgmode){let i,e=0,s=c.length>4?4:c.length,r=()=>e+1>s?e=1:++e;n.on("tb_backstretch.before",((t,e)=>{setTimeout((()=>{if(i!=e.index){e.$wrap.find("img").last().addClass("kenburns-effect"+r()),i=e.index}}),50)})).on("tb_backstretch.after",((t,e)=>{const s=e.$wrap.find("img").last();/kenburns-effect\d/.test(s.attr("class"))||(s.addClass("kenburns-effect"+r()),i=e.index)})),t.is_builder_active&&n.on("backstretch.show",((t,i,e)=>{n.css("zIndex",0)}))}}};t.on("builder_load_module_partial",((i,s)=>{let r;if(!0===s){if("DIV"!==i.tagName||i.classList.contains("module"))return;const t=i.querySelector(":scope>.tb_slider");if(null===t)return;r=[t]}else r=t.selectWithParent("tb_slider",i);r.length>0&&t.loadCss(ThemifyBuilderModuleJs.cssUrl+"background-slider").then((()=>{e(r)}))}))})(jQuery,Themify,tbLocalScript);