jQuery(document).ready(function($){InitSmoothScrollToAnchor();initBlogCTA();initUTMs();initPassUTMsToCalendy();initHSForms();initFixIframeVideoAspectRatio();initShareLinkPopups();initToolTips();initBILinkClickEvent();initUserLeftTitle();initLottieAnimations();function InitSmoothScrollToAnchor(){const headerOffset=getComputedStyle(document.body).getPropertyValue('--header-height')
const extraOffset=parseFloat(getComputedStyle(document.body).getPropertyValue('--sticky-height'))||0
$('a[href*="#"]:not([href="#"])').click(function(){if(location.pathname.replace(/^\//,'')===this.pathname.replace(/^\//,'')&&location.hostname===this.hostname){var target=$(this.hash);target=target.length?target:$('[name='+this.hash.slice(1)+']');if(target.length){$('html,body').animate({scrollTop:target.offset().top-headerOffset-extraOffset},1000);return false;}}});}
function initBlogCTA(){if($('.blog-ctaWithSlider__slider').length){$('.blog-ctaWithSlider__slider').slick({infinite:true,slidesToShow:1,slidesToScroll:1,dots:false,arrows:true,fade:true,autoplay:false,});}
$('.js-blog-ctaWithVideo-play').click(function(){$(this).siblings('img').addClass('hide-img');$(this).addClass('hide-img');var videoEl=$(this).siblings('.blog-ctaWithVideo__video');var videoElIframe=videoEl.find('iframe');videoElIframe.addClass('firameeee');videoEl.addClass('show-video');videoElIframe.attr('src',videoElIframe.attr('data-src'))});}
function initUTMs(){window.Utms_Manager={utms:['utm_source','utm_medium','utm_campaign','utm_term','utm_content','couponCode',]};Utms_Manager.getUTMsFromStorage=function(){var utms_in_cookies={};Utms_Manager.utms.forEach(utm=>{const item=localStorage.getItem(utm)
if(item){utms_in_cookies[utm]=item}})
return utms_in_cookies;}
Utms_Manager.getUTMsFromCookies=function(){var utms_in_cookies={};Utms_Manager.utms.forEach(function(utm_key){var utm_val=Cookies.get(utm_key);if(utm_val){utms_in_cookies[utm_key]=utm_val;}});return utms_in_cookies;}
Utms_Manager.ifUserCameWithUTMs=function(){var exists=false;Utms_Manager.utms.forEach(function(utm){var url_param_value=getUrlParam(utm);if(url_param_value){exists=true;}});return exists;}
Utms_Manager.initSaveUTMsToStorage=function(){const userCameWithUTMs=Utms_Manager.ifUserCameWithUTMs();Utms_Manager.utms.forEach(utm=>{const url_param_value=getUrlParam(utm);if(url_param_value){localStorage.setItem(utm,url_param_value);}else if(!url_param_value&&userCameWithUTMs){localStorage.removeItem(utm);}})}
Utms_Manager.initSaveUTMsToCookies=function(){var UserCameWithUTMs=Utms_Manager.ifUserCameWithUTMs();Utms_Manager.utms.forEach(function(utm){var url_param_value=getUrlParam(utm);if(url_param_value){Cookies.set(utm,url_param_value,{expires:365,domain:window.location.host,path:'/'});}else if(!url_param_value&&UserCameWithUTMs){Cookies.remove(utm,{domain:window.location.host,path:'/'});}});}
Utms_Manager.populateUTMs=function(){var utms_in_cookies=Utms_Manager.getUTMsFromStorage();if(utms_in_cookies){for(var utm_key in utms_in_cookies){if(Object.prototype.hasOwnProperty.call(utms_in_cookies,utm_key)){var utm_val=utms_in_cookies[utm_key];$('[name="'+utm_key+'"]').val(utm_val);}}
$('.js-add-utms').each(function(item){var currentURL=$(this).attr('href');var newURL=addParamsToUrl(currentURL,utms_in_cookies);$(this).attr('href',newURL);});}}
Utms_Manager.init=function(){Utms_Manager.initSaveUTMsToStorage();Utms_Manager.populateUTMs();}
Utms_Manager.init();}
function initPassUTMsToCalendy(){var utms_in_cookies=Utms_Manager.getUTMsFromStorage();$('a[href*="/calendly"]').each(function(){var currentURL=$(this).attr('href');var newURL=addParamsToUrl(currentURL,utms_in_cookies);$(this).attr('href',newURL);});}
function initHSForms(){window.addEventListener('message',event=>{if(event.data.type==='hsFormCallback'&&event.data.eventName==='onFormReady'){$(document).trigger('hubspot_forms_loaded');}
if(event.data.type==='hsFormCallback'&&event.data.eventName==='onFormSubmit'){$(document).trigger('hubspot_form_submit',{status:'success',formId:event.data.id,formName:'hubspot_form',formData:event.data});}});$(document).on('hubspot_forms_loaded',function(e,eventInfo){setTimeout(function(){addUTMsToHSForms();},500);});function addUTMsToHSForms(){tg.globals.utms.forEach(function(utm_key){var utm_val=Cookies.get(utm_key);if(utm_val){$('[name="'+utm_key+'"]').val(utm_val);}});}}
function initCookiesPopup(){var cookies_popup=$('.cookies-popup');var cookie_key='agree_to_use_cookies2';var cookie_val=getCookie(cookie_key);if((!$('body').hasClass('rtl'))&&(!cookie_val)){cookies_popup.css("display","flex");$('body').addClass('cookies-popup-is-open');setCookie(cookie_key,'agree',365);}
$(document).on('click','.cookies-popup__agree',function(e){e.preventDefault();cookies_popup.slideUp();$('body').removeClass('cookies-popup-is-open');});function setCookie(name,value,expiry_days){var d=new Date();d.setTime(d.getTime()+(expiry_days*24*60*60*1000));var expires="expires="+d.toUTCString();document.cookie=name+"="+value+";"+expires+";path=/";return getCookie(name);};function getCookie(name){var cookie_name=name+"=";var decodedCookie=decodeURIComponent(document.cookie);var ca=decodedCookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1);}
if(c.indexOf(cookie_name)===0){return c.substring(cookie_name.length,c.length);}}
return false;};}
function initFixIframeVideoAspectRatio(){var $allVideos=$(".js-iframe-fix-aspectRatio iframe[src*='//www.youtube.com'], .js-iframe-fix-aspectRatio iframe[src*='//player.vimeo.com']"),$fluidEl=$(".js-iframe-fix-aspectRatio");$allVideos.each(function(){$(this).data('aspectRatio',this.height/this.width).removeAttr('height').removeAttr('width');});$(window).resize(function(){var newWidth=$fluidEl.width();$allVideos.each(function(){var $el=$(this);$el.width(newWidth).height(newWidth*$el.data('aspectRatio'));});}).resize();}
function initShareLinkPopups(){const $popupLinks=document.querySelectorAll('[data-share-popup]')
if(!$popupLinks)return
function popupCenter(url){const title='share'
const w=800
const h=600
const dualScreenLeft=window.screenLeft!=undefined?window.screenLeft:screen.left;const dualScreenTop=window.screenTop!=undefined?window.screenTop:screen.top;const width=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width;const height=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;const left=((width/2)-(w/2))+dualScreenLeft;const top=((height/2)-(h/2))+dualScreenTop;const newWindow=window.open(url,title,`scrollbars=yes, width=${w}, height=${h}, top=${top}, left=${left}`);if(window.focus){newWindow.focus();}}
$popupLinks.forEach($link=>{$link.addEventListener('click',event=>{if(!$link.href)return
event.preventDefault()
popupCenter($link.href)})})}
function initToolTips(){if(!window.tippy)return
window.tippy('[data-tippy-content]',{theme:'main',interactive:true,placement:'top',hideOnClick:false,allowHTML:true,})}
function initBILinkClickEvent(){function handler(){if(!window.cta)return
const $element=$(this)
const label=$element.text().replace(/\n/gmi,'').replace(/<svg>(.*)<\/svg>/gmi,'').replace(/ +(?= )/gmi,'').trim()
const $section=$element.closest('section[class^=section], header[class^=section], footer[class^=section]')
const sectionLoopIndex=$('.sections-loop').children('section').index($section)
const extra={element_type:$element[0].nodeName==='A'?'link':`button:${$element.data('bi-click')}`,link_label:label,link_href:$element.attr('href'),link_classname:$element.attr('class')||$element.closest('[class]').attr('class'),link_id:$element.attr('id'),section:$section&&($section.attr('class')||'').split(' ')[0],section_id:$section&&$section.attr('id'),section_loop_index:sectionLoopIndex>-1&&sectionLoopIndex,clean_url:window.location.href.split('?')[0],}
const data={label:'cta_button:clicked',feature:'website',context:window.document.title,value:'',extra:extra,}
window.cta.reportHit('actionHit',data)}
$('a[href], [data-bi-click]').on('click',handler)}
function initUserLeftTitle(){var initialTitle=$(document).attr('title');var titleShouldChange=false;if(!window.userLeftTitle||!window.userLeftTitle.length){return;}
setInterval(rotateTitle,1200);$(window).blur(function(e){titleShouldChange=true;});$(window).focus(function(e){titleShouldChange=false;document.title=initialTitle;});function rotateTitle(){if(!titleShouldChange){return;}
if(document.title===initialTitle){document.title=window.userLeftTitle;}else{document.title=initialTitle;}}}
function initLottieAnimations(){if(!window.lottie)return
if(!'IntersectionObserver'in window)return
const lottie=window.lottie
$('[data-lottie]').each(function(){const $container=$(this)
const path=$container.attr('data-lottie')
const start=$container.attr('data-lottie-start')
const playbackMode=$container.attr('data-lottie-playback')
const iterations=parseInt($container.attr('data-lottie-iterations')||0)
const loop=playbackMode==='loop'?true:Math.round(iterations)-1
const animation=lottie.loadAnimation({container:$container[0],renderer:/iPhone|iPad|iPod/.test(navigator.userAgent)?'canvas':'svg',loop:loop,autoplay:false,path:path,name:path,})
let segments=false
function playAnimation({alreadyStarted}={alreadyStarted:false}){if(segments){if(!alreadyStarted){animation.playSegments(segments,true)}else{animation.playSegments(segments[1])}}else{animation.play()}}
animation.addEventListener('data_ready',function(){const markers=animation.animationData?.markers
if(markers&&markers[0]&&markers[1]&&markers[2]){segments=[[markers[0].tm,markers[1].tm],[markers[1].tm,markers[2].tm],]}
if(start==='visible'){const initObserver=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){playAnimation()
initObserver.unobserve($container[0])}})
initObserver.observe($container[0])}else if(start==='click'){$container.one('click',function(){playAnimation()
$container.one('mouseleave',function(){$container.attr('data-lottie-start','clicked')})})}else{playAnimation()}
const playPauseObserver=new IntersectionObserver(([entry])=>{if($container.attr('data-lottie-start')==='click'){return}
if(entry.isIntersecting&&animation.isPaused){playAnimation({alreadyStarted:true})}
if(!entry.isIntersecting){animation.pause()}})
playPauseObserver.observe($container[0])})})}
function getUrlParam(name,url){if(!url)url=window.location.href;name=name.replace(/[\[\]]/g,"\\$&");var regex=new RegExp("[?&]"+name+"(=([^&#]*)|&|#|$)"),results=regex.exec(url);if(!results)return null;if(!results[2])return '';return decodeURIComponent(results[2].replace(/\+/g," "));}
function addParamsToUrl(href,params){if(href&&validURL(href)&&params){var url=new URL(href);for(var param in params){if(Object.prototype.hasOwnProperty.call(params,param)){url.searchParams.set(param,params[param]);}}
return url.href;}
return href;}
function validURL(str){var pattern=new RegExp('^(https?:\\/\\/)?'+
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+
'((\\d{1,3}\\.){3}\\d{1,3}))'+
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+
'(\\?[;&a-z\\d%_.~+=-]*)?'+
'(\\#[-a-z\\d_]*)?$','i');return!!pattern.test(str);}
const scrollHeight=({identifier='data-scroll-height',variable='--scroll-height',variableIdentifier='data-scroll-height-variable',whichChild=false,whichChildSelector='data-scroll-height-which-child',}={})=>{const setScrollHeights=()=>{document.querySelectorAll(`[${identifier}]`).forEach($el=>{const childSelector=$el.getAttribute(identifier)
const _whichChild=whichChild||$el.getAttribute(whichChildSelector)||false
let height
let $sources=false
if(childSelector){if(_whichChild){$sources=$el.querySelectorAll(childSelector)
$sources.forEach($source=>{$source.style.setProperty('min-height',0)})
$sources.forEach($source=>{$source.style.setProperty('align-self','start')})
const heights=[...$sources].map($source=>$source.scrollHeight)
$sources.forEach($source=>{$source.style.removeProperty('min-height')})
$sources.forEach($source=>{$source.style.removeProperty('align-self')})
switch(_whichChild){case 'tallest':height=Math.max(...heights);break
case 'shortest':height=Math.min(...heights);break}}else{const $element=$el.querySelector(childSelector)
if($element)
height=$element.scrollHeight}}else{height=$el.scrollHeight}
if(height){const customProperty=(variableIdentifier&&$el.getAttribute(variableIdentifier))?`--${$el.getAttribute(variableIdentifier)}`:variable
$el.style.setProperty(customProperty,height+'px')}})}
window.addEventListener('load',()=>{setScrollHeights()})
window.addEventListener('resize',setScrollHeights,{passive:true})}
scrollHeight();});