(function($){
'use strict';
window.JetPopupFrontend={
addedScripts: {},
addedStyles: {},
addedAssetsPromises: [],
init: function(){
let $popup_list=$('.jet-popup.jet-popup--front-mode');
$popup_list.each(function(index){
let $target=$(this),
instance=null,
settings=$target.data('settings');
instance=new window.jetPopup($target, settings);
instance.init();
});
JetPopupFrontend.initAttachedPopups();
JetPopupFrontend.initBlocks();
$(window).on('jet-popup/ajax/frontend-init',(event, payload)=> {
switch(payload.contentType){
case 'elementor':
JetPopupFrontend.maybeElementorFrontendInit(payload.$container);
break;
case 'default':
JetPopupFrontend.maybeDefaultFrontendInit(payload);
break
}});
},
initAttachedPopups: function($scope){
$scope=$scope||$('body');
$scope.find('[data-popup-instance]').each(( index, el)=> {
let $this=$(el),
popupId=$this.data('popup-instance')||'none',
triggerType=$this.data('popup-trigger-type')||'none',
clickedCustomClass=$this.data('popup-custom-selector')||'',
popupData={
popupId: `jet-popup-${ popupId }`,
};
if($this.hasClass('jet-popup-attach-event-inited') ){
return;
}
$this.addClass('jet-popup-attach-event-inited');
switch(triggerType){
case 'click-self':
$this.addClass('jet-popup-cursor-pointer');
$this.on('click.JetPopup', function(event){
event.preventDefault();
$(window).trigger({
type: 'jet-popup-open-trigger',
popupData: popupData,
triggeredBy: $this,
});
return false;
});
break;
case 'click-selector':
if(''!==clickedCustomClass){
$this.find(clickedCustomClass).addClass('jet-popup-cursor-pointer');
$this.on('click.JetPopup', clickedCustomClass, function(event){
event.preventDefault();
$(window).trigger({
type: 'jet-popup-open-trigger',
popupData: popupData,
triggeredBy: $this,
});
return false;
});
}
break;
case 'hover':
$this.on('mouseenter.JetPopup', function(event){
$(window).trigger({
type: 'jet-popup-open-trigger',
popupData: popupData,
triggeredBy: $this,
});
});
break;
case 'scroll-to':
const observer=new IntersectionObserver((entries)=> {
entries.forEach((entry)=> {
if(entry.isIntersecting){
$(window).trigger({
type: 'jet-popup-open-trigger',
popupData: popupData,
triggeredBy: $this,
});
}})
},
{
threshold: 0.5
});
for(let i=0; i < $($this).length; i++){
const elements=$($this)[i];
observer.observe(elements);
}
break;
}});
},
initBlocks: function($scope){
$scope=$scope||$('body');
window.JetPlugins.init($scope, [
{
block: 'jet-popup/action-button',
callback:($scope)=> {
let $button=$('.jet-popup-action-button__instance', $scope),
actionType=$scope.data('action-type');
JetPopupFrontend.actionButtonHandle($button, actionType);
}}
]);
},
actionButtonBlock: function($scope){
var $button=$('.jet-popup-action-button__instance', $scope),
actionType=$scope.data('action-type');
JetPopupFrontend.actionButtonHandle($button, actionType);
},
actionButtonHandle: function($button, actionType='link'){
switch(actionType){
case 'link':
$button.on('click.JetPopup', function(event){
event.preventDefault();
var $currentPopup=$button.closest('.jet-popup'),
link=$(this).attr('href'),
target=$(this).attr('target'),
popupId=$currentPopup.attr('id');
$(window).trigger({
type: 'jet-popup-close-trigger',
popupData: {
popupId: popupId,
constantly: false
}});
if('_blank'===target){
window.open(link, '_blank');
}else{
window.open(link, '_self');
}
return false;
});
break;
case 'leave':
$button.on('click.JetPopup', function(event){
event.preventDefault();
window.history.back();
});
break;
case 'close-popup':
$button.on('click.JetPopup', function(event){
event.preventDefault();
var $currentPopup=$button.closest('.jet-popup'),
popupId=$currentPopup.attr('id');
$(window).trigger({
type: 'jet-popup-close-trigger',
popupData: {
popupId: popupId,
constantly: false
}});
});
break;
case 'close-all-popups':
$button.on('click.JetPopup', function(event){
event.preventDefault();
var $popups=$('.jet-popup');
if($popups[0]){
$popups.each(function(index){
var $popup=$(this),
popupId=$popup.attr('id');
$(window).trigger({
type: 'jet-popup-close-trigger',
popupData: {
popupId: popupId,
constantly: false
}});
});
}});
break;
case 'close-constantly':
$button.on('click.JetPopup', function(event){
event.preventDefault();
var $currentPopup=$button.closest('.jet-popup'),
popupId=$currentPopup.attr('id');
$(window).trigger({
type: 'jet-popup-close-trigger',
popupData: {
popupId: popupId,
constantly: true
}});
});
break;
case 'close-all-constantly':
$button.on('click.JetPopup', function(event){
event.preventDefault();
var $popups=$('.jet-popup');
if($popups[0]){
$popups.each(function(index){
var $popup=$(this),
popupId=$popup.attr('id');
$(window).trigger({
type: 'jet-popup-close-trigger',
popupData: {
popupId: popupId,
constantly: true
}});
});
}});
break;
}},
loadScriptAsync: function(script, uri){
if(JetPopupFrontend.addedScripts.hasOwnProperty(script) ){
return script;
}
JetPopupFrontend.addedScripts[ script ]=uri;
const asset=document.getElementById(script + '-js');
if(asset){
return script;
}
return new Promise(function(resolve, reject){
var tag=document.createElement('script');
tag.src=uri;
tag.async=false;
tag.onload=function(){
resolve(script);
};
document.head.appendChild(tag);
});
},
loadStyle: function(style, uri){
if(JetPopupFrontend.addedStyles.hasOwnProperty(style)&&JetPopupFrontend.addedStyles[ style ]===uri){
return style;
}
JetPopupFrontend.addedStyles[ style ]=uri;
return new Promise(function(resolve, reject){
var tag=document.createElement('link');
tag.id=style;
tag.rel='stylesheet';
tag.href=uri;
tag.type='text/css';
tag.media='all';
tag.onload=function(){
resolve(style);
};
document.head.appendChild(tag);
});
},
assetsLoaderPromise: function(){
return Promise.all(JetPopupFrontend.addedAssetsPromises);
},
maybeElementorFrontendInit: function($popupContainer){
$popupContainer.find('div[data-element_type]').each(function(){
var $this=$(this),
elementType=$this.data('element_type');
if(! elementType){
return;
}
try {
if('widget'===elementType){
elementType=$this.data('widget_type');
if(window.elementorFrontend&&window.elementorFrontend.hooks){
window.elementorFrontend.hooks.doAction('frontend/element_ready/widget', $this, $);
}}
if(window.elementorFrontend&&window.elementorFrontend.hooks){
window.elementorFrontend.hooks.doAction('frontend/element_ready/global', $this, $);
window.elementorFrontend.hooks.doAction('frontend/element_ready/' + elementType, $this, $);
}} catch(err){
console.log(err);
$this.remove();
return false;
}});
},
maybeDefaultFrontendInit: function(payload){
const contentElements=payload.contentElements||[],
$container=payload.$container;
$container.find('[data-is-block*="/"]').each(( index, el)=> {
window.JetPlugins.hooks.doAction(window.JetPlugins.hookNameFromBlock(el.dataset.isBlock), jQuery(el) );
});
}};
window.jetPopup=function($popup, settings){
var self=this,
$window=$(window),
$document=$(document),
popupSettings=settings,
id=popupSettings['id'],
popupId=popupSettings['jet-popup-id'],
popupsLocalStorageData={},
isAnimation=false,
isOpen=false,
ajaxGetContentHanler=null,
ajaxContentLoaded=false;
self.init=function(){
var popupAvailable=self.popupAvailableCheck();
if(! popupAvailable){
return false;
}
self.setLocalStorageData(popupId, 'enable');
self.initCompatibilityHandler();
self.initOpenEvent();
self.initCloseEvent();
$window.trigger('jet-popup/init/after', {
self: self,
settings: popupSettings
});
};
self.popupAvailableCheck=function(){
var storageData=self.getLocalStorageData()||{};
if(! storageData.hasOwnProperty(popupId) ){
return true;
}
var popupData=storageData[ popupId ],
status='enable',
showAgainDate='none';
if('disable'===popupData){
return false;
}
if('enable'===popupData){
return true;
}
if(popupData.hasOwnProperty('status') ){
status=popupData['status'];
}
if('enable'===status){
return true;
}
if(popupData.hasOwnProperty('show-again-date') ){
showAgainDate=popupData['show-again-date'];
}
if('none'===showAgainDate&&'disable'===status){
return false;
}
if(showAgainDate < Date.now()){
return true;
}else{
return false;
}};
self.initOpenEvent=function(){
$window.trigger('jet-popup/init-events/before', {
self: self,
settings: popupSettings
});
switch(popupSettings['open-trigger']){
case 'page-load':
self.pageLoadEvent(popupSettings['page-load-delay']);
break;
case 'user-inactive':
self.userInactiveEvent(popupSettings['user-inactivity-time']);
break;
case 'scroll-trigger':
self.scrollPageEvent(popupSettings['scrolled-to']);
break;
case 'try-exit-trigger':
self.tryExitEvent();
break;
case 'on-date':
self.onDateEvent(popupSettings['on-date']);
break;
case 'on-time':
self.onTimeEvent(popupSettings['on-time-start'], popupSettings['on-time-end']);
break;
case 'on-date-and-time':
self.onTimeAndDateEvent(popupSettings['start-date-and-time'], popupSettings['end-date-and-time']);
break;
case 'custom-selector':
self.onCustomSelector(popupSettings['custom-selector']);
break;$scope
}
$window.on('jet-popup-open-trigger', function(event){
var popupData=event.popupData||{},
triggeredBy=event.triggeredBy||false,
popupUniqId=popupData.popupId||false,
constantly=popupData.constantly;
if(popupUniqId==popupId){
if($popup.hasClass('jet-popup--hide-state')){
self.showPopup(popupData, triggeredBy);
}else{
self.hidePopup({
constantly: constantly,
popupId: popupUniqId,
});
}}
});
$window.on('jet-popup-close-trigger', function(event){
var popupData=event.popupData||{},
popupUniqId=popupData.popupId,
constantly=popupData.constantly;
if(popupUniqId==popupId){
self.hidePopup({
popupId: popupUniqId,
constantly: constantly,
});
}});
$window.trigger('jet-popup/init-events/after', {
self: self,
settings: popupSettings
});
};
self.initOnCloseEvent=function(){
var $htmlBody=$('html, body');
if('scroll-to-top'===popupSettings['close-event']){
$htmlBody.animate({ scrollTop: 0 }, 'slow');
}
if('scroll-to-anchor'===popupSettings['close-event']){
var anchor=$('#' + popupSettings['сlose-event-anchor']);
if(anchor.length){
$htmlBody.animate({ scrollTop: anchor.offset().top }, 'slow');
}}
}
self.initCloseEvent=function(){
$popup.on('click', '.jet-popup__close-button', function(event){
var target=event.currentTarget;
self.hidePopup({
constantly: popupSettings['show-once'],
popupId: popupSettings['jet-popup-id']
});
self.initOnCloseEvent();
});
if(popupSettings['close-on-overlay-click']){
$popup.on('click', '.jet-popup__overlay', function(event){
var target=event.currentTarget;
self.hidePopup({
constantly: popupSettings['show-once'],
popupId: popupSettings['jet-popup-id']
});
self.initOnCloseEvent();
});
}
$document.on('keyup.jetPopup', function(event){
var key=event.keyCode;
if(27===key&&isOpen){
self.hidePopup({
constantly: popupSettings['show-once'],
popupId: popupSettings['jet-popup-id']
});
}});
};
self.initCompatibilityHandler=function(){
var $elementorProFormWidget=$('.elementor-widget-form', $popup);
if($elementorProFormWidget[0]){
$elementorProFormWidget.each(function(){
var $this=$(this),
$form=$('.elementor-form', $this);
$form.on('submit_success', function(data){
setTimeout(function(){
$window.trigger({
type: 'jet-popup-close-trigger',
popupData: {
popupId: popupId,
constantly: false
}});
}, 3000);
});
});
}};
self.pageLoadEvent=function(openDelay){
var delay=+openDelay||0;
delay=delay * 1000;
$(function(){
setTimeout(function(){
self.showPopup();
}, delay);
});
};
self.userInactiveEvent=function(inactiveDelay){
var delay=+inactiveDelay||0,
isInactive=true;
delay=delay * 1000;
setTimeout(function(){
if(isInactive){
self.showPopup();
}}, delay);
$(document).on('click focus resize keyup scroll', function(){
isInactive=false;
});
};
self.scrollPageEvent=function(scrollingValue){
var scrolledValue=+scrollingValue||0;
$window.on('scroll.cherryJetScrollEvent resize.cherryJetResizeEvent', function(){
var $window=$(window),
windowHeight=$window.height(),
documentHeight=$(document).height(),
scrolledHeight=documentHeight - windowHeight,
scrolledProgress=Math.max(0, Math.min(1, $window.scrollTop() / scrolledHeight) ) * 100;
if(scrolledProgress >=scrolledValue){
$window.off('scroll.cherryJetScrollEvent resize.cherryJetResizeEvent');
self.showPopup();
}}).trigger('scroll.cherryJetResizeEvent');
};
self.tryExitEvent=function(){
var pageY=0;
$(document).on('mouseleave', 'body', function(event){
pageY=event.pageY - $window.scrollTop();
if(0 > pageY&&$popup.hasClass('jet-popup--hide-state') ){
self.showPopup();
}});
};
self.onDateEvent=function(date){
var nowDate=Date.now(),
startDate=Date.parse(date);
if(startDate < nowDate){
setTimeout(function(){
self.showPopup();
}, 500);
}}
self.onTimeEvent=function(startTime='00:00', endTime='23:59'){
var startTime=''!==startTime ? startTime:'00:00',
endTime=''!==endTime ? endTime:'23:59',
nowTimeStamp=Date.now(),
dateTimeFormat=new Intl.DateTimeFormat('en', { year: 'numeric', month: 'short', day: '2-digit' }),
[ { value: month },,{ value: day },,{ value: year } ]=dateTimeFormat.formatToParts(nowTimeStamp),
startTime=`${ month }. ${ day }, ${ year } ${ startTime }`,
endTime=`${ month }. ${ day }, ${ year } ${ endTime }`,
startTimeStamp=Date.parse(startTime),
endTimeStamp=Date.parse(endTime);
if(( startTimeStamp < nowTimeStamp)&&(nowTimeStamp < endTimeStamp) ){
setTimeout(function(){
self.showPopup();
}, 500);
}}
self.onTimeAndDateEvent=function(start, end){
var nowDateStamp=Date.now(),
startDateStamp=Date.parse(start),
endDateStamp=Date.parse(end);
if(( startDateStamp < nowDateStamp)&&(nowDateStamp < endDateStamp) ){
setTimeout(function(){
self.showPopup();
}, 500);
}}
self.checkLoadedSelector=function(selector){
$(document).on('jet-engine/listing-grid/after-lazy-load', function(){
self.onCustomSelector(selector);
});
$('.jet-mobile-menu__toggle').closest('.jet-mobile-menu__instance--slide-out-layout').on('click', function(){
self.onCustomSelector(selector);
});
}
self.onCustomSelector=function(selector){
let $selector=$(selector);
if($selector[0]){
$('body').off('click.jetPopup', selector).on('click.jetPopup', selector, function(event){
event.preventDefault();
let $this=$(this);
let popupId=$this.data('popup');
let $popup=$('#jet-popup-' + popupId);
if($popup.length&&$popup.hasClass('jet-popup--show-state') ){
self.hidePopup(popupId, false);
}else{
self.showPopup(popupId, $this);
}});
}else{
self.checkLoadedSelector(selector);
}}
self.showPopup=function(data, $trigger){
var popupData=data||{},
animeOverlay=null,
animeContainer=null,
animeOverlaySettings=jQuery.extend({
targets: $('.jet-popup__overlay', $popup)[0]
},
self.avaliableEffects[ 'fade' ][ 'show' ]
);
$trigger=$trigger||false;
if(! self.popupAvailableCheck()){
return false;
}
animeOverlay=anime(animeOverlaySettings);
$popup.toggleClass('jet-popup--hide-state jet-popup--show-state');
if(popupSettings['prevent-scrolling']){
$('body').addClass('jet-popup-prevent-scroll');
}
popupData=window.JetPlugins.hooks.applyFilters('jet-popup.show-popup.data', popupData, $popup, $trigger);
self.showContainer(popupData);
};
self.showContainer=function(data){
var popupData=data||{},
popupDefaultData={
forceLoad: popupSettings['force-ajax']||false,
customContent: ''
},
animeContainerInstance=null,
$popupContainer=$('.jet-popup__container', $popup),
$content=$('.jet-popup__container-content', $popup),
animeContainer=jQuery.extend({
targets: $('.jet-popup__container', $popup)[0],
begin: function(anime){
isAnimation=true;
$window.trigger('jet-popup/show-event/before-show', {
self: self,
data: popupData,
anime: anime
});
},
complete: function(anime){
isAnimation=false;
isOpen=true;
$window.trigger('jet-popup/show-event/after-show', {
self: self,
data: popupData,
anime: anime
});
}},
self.avaliableEffects[ popupSettings['animation'] ][ 'show' ]
);
popupData=jQuery.extend(popupDefaultData, popupData);
if(''!==popupData.customContent){
$content.html(popupData.customContent);
self.elementorFrontendInit();
animeContainerInstance=anime(animeContainer);
$window.trigger('jet-popup/render-content/render-custom-content', {
self: self,
popup_id: id,
data: popupData,
});
return false;
}
if(! popupSettings['use-ajax']){
animeContainerInstance=anime(animeContainer);
$window.trigger('jet-popup/render-content/render-custom-content', {
self: self,
popup_id: id,
data: popupData,
});
return false;
}
if(popupData.forceLoad){
ajaxContentLoaded=false;
}
if(ajaxContentLoaded){
animeContainerInstance=anime(animeContainer);
$window.trigger('jet-popup/render-content/show-content', {
self: self,
popup_id: id,
data: popupData,
});
return false;
}
popupData=jQuery.extend(popupData, {
'popup_id': id,
'page_url': window.location.href
});
ajaxGetContentHanler=jQuery.ajax({
type: 'POST',
url: window.jetPopupData.ajax_url,
data: {
'action': 'jet_popup_get_content',
'data': popupData
},
beforeSend: function(jqXHR, ajaxSettings){
if(null!==ajaxGetContentHanler){
ajaxGetContentHanler.abort();
}
$window.trigger('jet-popup/render-content/ajax/before-send', {
self: self,
popup_id: id,
data: popupData
});
$popup.addClass('jet-popup--loading-state');
},
error: function(jqXHR, ajaxSettings){},
success: function(data, textStatus, jqXHR){
var successType=data.type,
contentData=data.content||false,
$popupContainer=$('.jet-popup__container-content', $popup);
$popup.removeClass('jet-popup--loading-state');
if('error'===successType){
var message=data.message;
$content.html('<h3>' + message + '</h3>');
animeContainerInstance=anime(animeContainer);
}
if('success'===successType){
let popupContent=contentData['content'],
popupContentElements=contentData['contentElements'],
popupScripts=contentData['scripts'],
popupStyles=contentData['styles'],
popupAfterScripts=contentData['afterScripts'];
for(let { handle: scriptHandler, src: scriptSrc } of popupScripts){
JetPopupFrontend.addedAssetsPromises.push(JetPopupFrontend.loadScriptAsync(scriptHandler, scriptSrc) );
}
if(popupStyles&&Object.keys(popupStyles).length > 0){
for(let styleHandler in popupStyles){
JetPopupFrontend.addedAssetsPromises.push(JetPopupFrontend.loadStyle(styleHandler, popupStyles[ styleHandler ]) );
}}
JetPopupFrontend.assetsLoaderPromise().then(async function(value){
ajaxContentLoaded=true;
$window.trigger('jet-popup/render-content/ajax/success', {
self: self,
popup_id: id,
data: popupData,
request: data
});
if(popupContent){
$popupContainer.html(popupContent);
}
if(popupAfterScripts.length){
await Promise.all(popupAfterScripts.map(( { handle, src })=> JetPopupFrontend.loadScriptAsync(handle, src)
));
}
$(window).trigger('jet-popup/ajax/frontend-init/before', {
$container: $popupContainer,
content: popupContent,
contentElements: popupContentElements,
contentType: popupSettings['content-type'],
});
$(window).trigger('jet-popup/ajax/frontend-init', {
$container: $popupContainer,
content: popupContent,
contentElements: popupContentElements,
contentType: popupSettings['content-type'],
});
$(window).trigger('jet-popup/ajax/frontend-init/after', {
$container: $popupContainer,
content: popupContent,
contentElements: popupContentElements,
contentType: popupSettings['content-type'],
});
animeContainerInstance=anime(animeContainer);
}, function(reason){
console.log('Assets Loaded Error');
});
}}
});
};
self.hidePopup=function(data){
var popupData=data||{},
$content=$('.jet-popup__container-content', $popup),
constantly=popupData.constantly||false,
animeOverlay=null,
animeContainer=null,
animeOverlaySettings=jQuery.extend({ targets: $('.jet-popup__overlay', $popup)[0] }, self.avaliableEffects[ 'fade' ][ 'hide' ]),
animeContainerSettings=jQuery.extend({
targets: $('.jet-popup__container', $popup)[0],
begin: function(anime){
isAnimation=true;
$window.trigger('jet-popup/hide-event/before-hide', {
self: self,
data: popupData,
anime: anime
});
},
complete: function(anime){
isAnimation=false;
isOpen=false;
$popup.toggleClass('jet-popup--show-state jet-popup--hide-state');
if(popupSettings['use-ajax']&&popupSettings['force-ajax']){
$content.html('');
}
if(popupSettings['prevent-scrolling']&&!$('.jet-popup--show-state')[0]){
$('body').removeClass('jet-popup-prevent-scroll');
}
$window.trigger('jet-popup/hide-event/after-hide', {
self: self,
data: popupData,
anime: anime
});
}},
self.avaliableEffects[ popupSettings['animation'] ][ 'hide' ]
);
if(constantly){
self.setLocalStorageData(popupId, 'disable');
}
if(isAnimation){
return false;
}
if($popup.hasClass('jet-popup--show-state')){
animeOverlay=anime(animeOverlaySettings);
animeContainer=anime(animeContainerSettings);
}
self.onHidePopupAction();
$window.trigger('jet-popup/close-hide-event/before-hide', {
self: self,
data: popupData
});
};
self.elementorFrontendInit=function(){
var $content=$('.jet-popup__container-content', $popup);
$content.find('div[data-element_type]').each(function(){
var $this=$(this),
elementType=$this.data('element_type');
if(!elementType){
return;
}
try {
if('widget'===elementType){
elementType=$this.data('widget_type');
window.elementorFrontend.hooks.doAction('frontend/element_ready/widget', $this, $);
}
window.elementorFrontend.hooks.doAction('frontend/element_ready/' + elementType, $this, $);
} catch(err){
console.log(err);
$this.remove();
return false;
}});
self.onShowPopupAction();
}
self.onShowPopupAction=function(){};
self.onHidePopupAction=function(){};
self.avaliableEffects={
'none': {
'show': {
duration: 0,
opacity: {
value: [ 1, 1 ],
}},
'hide': {
duration: 0,
opacity: {
value: [ 1, 1 ],
}}
},
'fade':{
'show': {
opacity: {
value: [ 0, 1 ],
duration: 600,
easing: 'easeOutQuart',
},
},
'hide': {
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
easing: 'easeOutQuart',
duration: 400,
},
}},
'zoom-in':{
'show': {
duration: 500,
easing: 'easeOutQuart',
opacity: {
value: [ 0, 1 ],
},
scale: {
value: [ 0.75, 1 ],
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
},
scale: {
value: [ 1, 0.75 ],
}}
},
'zoom-out':{
'show': {
duration: 500,
easing: 'easeOutQuart',
opacity: {
value: [ 0, 1 ],
},
scale: {
value: [ 1.25, 1 ],
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
},
scale: {
value: [ 1, 1.25 ],
}}
},
'rotate':{
'show': {
duration: 500,
easing: 'easeOutQuart',
opacity: {
value: [ 0, 1 ],
},
scale: {
value: [ 0.75, 1 ],
},
rotate: {
value: [ -65, 0 ],
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
},
scale: {
value: [ 1, 0.9 ],
},
}},
'move-up':{
'show': {
duration: 500,
easing: 'easeOutExpo',
opacity: {
value: [ 0, 1 ],
},
translateY: {
value: [ 50, 1 ],
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
},
translateY: {
value: [ 1, 50 ],
}}
},
'flip-x':{
'show': {
duration: 500,
easing: 'easeOutExpo',
opacity: {
value: [ 0, 1 ],
},
rotateX: {
value: [ 65, 0 ],
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
}}
},
'flip-y':{
'show': {
duration: 500,
easing: 'easeOutExpo',
opacity: {
value: [ 0, 1 ],
},
rotateY: {
value: [ 65, 0 ],
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
}}
},
'bounce-in':{
'show': {
opacity: {
value: [ 0, 1 ],
duration: 500,
easing: 'easeOutQuart',
},
scale: {
value: [ 0.2, 1 ],
duration: 800,
elasticity: function(el, i, l){
return (400 + i * 200);
},
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
},
scale: {
value: [ 1, 0.8 ],
}}
},
'bounce-out':{
'show': {
opacity: {
value: [ 0, 1 ],
duration: 500,
easing: 'easeOutQuart',
},
scale: {
value: [ 1.8, 1 ],
duration: 800,
elasticity: function(el, i, l){
return (400 + i * 200);
},
}},
'hide': {
duration: 400,
easing: 'easeOutQuart',
opacity: {
value: [ 1, 0 ],
},
scale: {
value: [ 1, 1.5 ],
}}
},
'slide-in-up':{
'show': {
opacity: {
value: [ 0, 1 ],
duration: 400,
easing: 'easeOutQuart',
},
translateY: {
value: ['100vh', 0],
duration: 750,
easing: 'easeOutQuart',
}},
'hide': {
duration: 400,
easing: 'easeInQuart',
opacity: {
value: [ 1, 0 ],
},
translateY: {
value: [0,'100vh'],
}}
},
'slide-in-right':{
'show': {
opacity: {
value: [ 0, 1 ],
duration: 400,
easing: 'easeOutQuart',
},
translateX: {
value: ['100vw', 0],
duration: 750,
easing: 'easeOutQuart',
}},
'hide': {
duration: 400,
easing: 'easeInQuart',
opacity: {
value: [ 1, 0 ],
},
translateX: {
value: [0,'100vw'],
}}
},
'slide-in-down':{
'show': {
opacity: {
value: [ 0, 1 ],
duration: 400,
easing: 'easeOutQuart',
},
translateY: {
value: ['-100vh', 0],
duration: 750,
easing: 'easeOutQuart',
}},
'hide': {
duration: 400,
easing: 'easeInQuart',
opacity: {
value: [ 1, 0 ],
},
translateY: {
value: [0,'-100vh'],
}}
},
'slide-in-left':{
'show': {
opacity: {
value: [ 0, 1 ],
duration: 400,
easing: 'easeOutQuart',
},
translateX: {
value: ['-100vw', 0],
duration: 750,
easing: 'easeOutQuart',
}},
'hide': {
duration: 400,
easing: 'easeInQuart',
opacity: {
value: [ 1, 0 ],
},
translateX: {
value: [0,'-100vw'],
}}
}};
self.getLocalStorageData=function(){
try {
return JSON.parse(localStorage.getItem('jetPopupData') );
} catch(e){
return false;
}};
self.setLocalStorageData=function(id, status){
var jetPopupData=self.getLocalStorageData()||{},
newData={};
newData['status']=status;
if('disable'===status){
var nowDate=Date.now(),
showAgainDelay=popupSettings['show-again-delay'],
showAgainDate='none'!==showAgainDelay ?(nowDate + showAgainDelay):'none';
newData['show-again-date']=showAgainDate;
}
jetPopupData[ id ]=newData;
localStorage.setItem('jetPopupData', JSON.stringify(jetPopupData) );
}}
window.JetPopupFrontend.init();
}(jQuery) );
((c,r,l)=>{l={$div:null,settings:null,store:null,chatbox:!1,showed_at:0,is_ready:!1,is_mobile:/Mobile|Android|iPhone|iPad/i.test(navigator.userAgent),can_qr:c.QrCreator&&"function"==typeof QrCreator.render,...l},(c.joinchat_obj=l).$=function(t){return this.$div.querySelector(t)},l.$$=function(t){return this.$div.querySelectorAll(t)},l.send_event=function(o){if((o={event_category:"JoinChat",event_label:"",event_action:"",chat_channel:"whatsapp",chat_id:"--",is_mobile:this.is_mobile?"yes":"no",page_location:location.href,page_title:r.title||"no title",...o}).event_label=o.event_label||o.link||"",o.event_action=o.event_action||o.chat_channel+": "+o.chat_id,delete o.link,r.dispatchEvent(new CustomEvent("joinchat:event",{detail:o,cancelable:!0}))){let t=c[this.settings.data_layer]||c[c.gtm4wp_datalayer_name]||c.dataLayer;if("object"==typeof t){let i=c.gtag||function(){t.push(arguments)},n=void 0!==this.settings.ga_event?this.settings.ga_event:"generate_lead";if(n){let e={transport_type:"beacon",...o},s=(Object.keys(e).forEach(t=>{"page_location"===t?e[t]=e[t].substring(0,1e3):"page_referrer"===t?e[t]=e[t].substring(0,420):"page_title"===t?e[t]=e[t].substring(0,300):"string"==typeof e[t]&&(e[t]=e[t].substring(0,100))}),[]),a=t=>{s.includes(t)||(t.startsWith("G-")||t.startsWith("GT-"))&&(s.push(t),i("event",n,{send_to:t,...e}))};if(c.google_tag_data&&google_tag_data.tidr&&google_tag_data.tidr.destination)for(var h in google_tag_data.tidr.destination)a(h);t.forEach(t=>{"config"===t[0]&&t[1]&&a(t[1])})}this.settings.gads&&i("event","conversion",{send_to:this.settings.gads})}var e,s,a=o.event_category;delete o.event_category,"object"==typeof t&&t.push({event:a,...o}),"function"==typeof fbq&&("whatsapp"===o.chat_channel&&(s=""+(e=o.chat_id).substring(0,3)+"X".repeat(e.length-5)+e.substring(e.length-2),o.chat_id=s,o.event_label=o.event_label.replace(e,s),o.event_action=o.event_action.replace(e,s)),fbq("trackCustom",a,o))}},l.get_wa_link=function(t,e,s){e=void 0!==e?e:this.settings.message_send||"",s=void 0!==s?s:this.settings.whatsapp_web&&!this.is_mobile;s=new URL((s?"https://web.whatsapp.com/send?phone=":"https://wa.me/")+(t||this.settings.telephone));return e&&s.searchParams.set("text",e),s.toString()},l.show=function(t){this.$div.removeAttribute("hidden"),this.$div.classList.add("joinchat--show"),t&&this.$div.classList.add("joinchat--tooltip")},l.hide=function(){this.$div.classList.remove("joinchat--show")},l.chatbox_show=function(){this.chatbox||(this.chatbox=!0,this.showed_at=Date.now(),this.$div.classList.add("joinchat--chatbox"),this.settings.message_badge&&this.$(".joinchat__badge").classList.replace("joinchat__badge--in","joinchat__badge--out"),r.dispatchEvent(new Event("joinchat:show")))},l.chatbox_hide=function(){this.chatbox&&(this.chatbox=!1,this.$div.classList.remove("joinchat--chatbox","joinchat--tooltip"),this.settings.message_badge&&this.$(".joinchat__badge").classList.remove("joinchat__badge--out"),r.dispatchEvent(new Event("joinchat:hide")))},l.save_hash=function(){var t;!this.settings.message_hash||this.settings.message_delay<0||(t=(this.store.getItem("joinchat_hashes")||"").split(",").filter(Boolean)).includes(this.settings.message_hash)||(t.push(this.settings.message_hash),this.store.setItem("joinchat_hashes",t.join(",")))},l.open_whatsapp=function(t,e){t=t||this.settings.telephone,e=void 0!==e?e:this.settings.message_send||"";t={link:this.get_wa_link(t,e),chat_channel:"whatsapp",chat_id:t,chat_message:e};r.dispatchEvent(new CustomEvent("joinchat:open",{detail:t,cancelable:!0}))&&(this.send_event(t),c.open(t.link,"joinchat","noopener"))},l.need_optin=function(){return this.$div.classList.contains("joinchat--optout")},l.use_qr=function(){return!!this.settings.qr&&this.can_qr&&!this.is_mobile},l.open=function(t,e,s){t&&!this.need_optin()||!l.$(".joinchat__chatbox")?Date.now()<l.showed_at+600||(this.save_hash(),this.open_whatsapp(e,s)):this.chatbox_show()},l.close=function(){this.save_hash(),this.chatbox_hide()},l.rand_text=function(t){t.querySelectorAll("jc-rand").forEach(t=>{var e=t.children;t.replaceWith(e[Math.floor(Math.random()*e.length)].innerHTML)})},l.qr=function(t,e){var s=r.createElement("CANVAS");return QrCreator.render(Object.assign({text:t,radius:.4,background:"#FFF",size:200*(c.devicePixelRatio||1)},this.settings.qr||{},e||{}),s),s};var t=()=>{if(l.$div=r.querySelector(".joinchat"),l.$div){l.settings=JSON.parse(l.$div.dataset.settings);try{localStorage.test=2,l.store=localStorage}catch(t){l.store={_data:{},setItem:function(t,e){this._data[t]=String(e)},getItem:function(t){return this._data.hasOwnProperty(t)?this._data[t]:null}}}if(l.settings&&l.settings.telephone){if(l.is_mobile||!l.settings.mobile_only){r.dispatchEvent(new Event("joinchat:starting"));var i=1e3*l.settings.button_delay,n=Math.max(0,1e3*l.settings.message_delay);let t=!!l.settings.message_hash;var o=parseInt(l.store.getItem("joinchat_views")||1)>=l.settings.message_views,h=(l.store.getItem("joinchat_hashes")||"").split(",").filter(Boolean);let s=void 0!==l.settings.cta_viewed?l.settings.cta_viewed:-1!==h.indexOf(l.settings.message_hash||"none"),e=!s&&(l.settings.message_badge||!t||!n||!o),a=(setTimeout(()=>l.show(e),i),()=>l.open());if(t&&!s&&n){let t;l.settings.message_badge?t=setTimeout(()=>l.$(".joinchat__badge").classList.add("joinchat__badge--in"),i+n):o&&(t=setTimeout(a,i+n)),r.addEventListener("joinchat:show",()=>clearTimeout(t),{once:!0})}if(h=l.$(".joinchat__button"),!l.is_mobile){let t;h.addEventListener("mouseenter",()=>{l.$(".joinchat__chatbox")&&(t=setTimeout(a,1500))}),h.addEventListener("mouseleave",()=>{clearTimeout(t)})}if(h.addEventListener("click",a),l.$(".joinchat__open")?.addEventListener("click",()=>l.open(!0)),l.$(".joinchat__close")?.addEventListener("click",()=>l.close()),l.$("#joinchat_optin")?.addEventListener("change",t=>l.$div.classList.toggle("joinchat--optout",!t.target.checked)),l.$(".joinchat__scroll")?.addEventListener("wheel",function(t){t.preventDefault(),this.scrollTop+=t.deltaY},{passive:!1}),l.is_mobile){let e,t,s=()=>{var t=(r.activeElement.type||"").toLowerCase();["date","datetime","email","month","number","password","search","tel","text","textarea","time","url","week"].includes(t)?l.chatbox?(l.chatbox_hide(),setTimeout(()=>l.hide(),400)):l.hide():l.show()};["focusin","focusout"].forEach(t=>r.addEventListener(t,t=>{t.target.matches("input, textarea")&&!l.$div.contains(t.target)&&(clearTimeout(e),e=setTimeout(s,200))})),c.addEventListener("resize",()=>{clearTimeout(t),t=setTimeout(()=>{l.$div.style.setProperty("--vh",c.innerHeight+"px")},200)}),c.dispatchEvent(new Event("resize"))}if(l.use_qr()?l.$(".joinchat__qr").appendChild(l.qr(l.get_wa_link(void 0,void 0,!1))):l.$(".joinchat__qr")?.remove(),n&&!o&&l.store.setItem("joinchat_views",parseInt(l.store.getItem("joinchat_views")||0)+1),r.addEventListener("joinchat:show",()=>{let s=l.$(".joinchat__scroll"),e=l.$(".joinchat__chat"),a=l.$$(".joinchat__bubble");if(!e)return;if(t&&l.rand_text(e),a.length<=1||c.matchMedia("(prefers-reduced-motion)").matches)return void setTimeout(()=>e.dispatchEvent(new Event("joinchat:bubbles")),1);a.forEach(t=>t.classList.add("joinchat--hidden")),l.$(".joinchat__optin")?.classList.add("joinchat--hidden");let i=0,n=(t,e)=>Math.round(Math.random()*(e-t)+t),o=(t,e)=>{l.$(".joinchat__bubble--loading")?.remove(),t.classList.remove("joinchat--hidden"),s.scrollTop=s.scrollHeight,setTimeout(h,e)},h=()=>{if(i>=a.length)l.$(".joinchat__optin")?.classList.remove("joinchat--hidden"),e.dispatchEvent(new Event("joinchat:bubbles"));else{let t=a[i++];t.classList.contains("joinchat__bubble--note")?o(t,100):(e.insertAdjacentHTML("beforeend",'<div class="joinchat__bubble joinchat__bubble--loading"></div>'),s.scrollTop=s.scrollHeight,setTimeout(()=>o(t,n(400,600)),60*t.textContent.split(/\s+/).length+n(100,200)))}};h()},{once:!0}),"#joinchat"!==(i=new URL(c.location)).hash&&!i.searchParams.has("joinchat")||(h=1e3*(parseInt(i.searchParams.get("joinchat"))||0),setTimeout(()=>l.show(),h),setTimeout(()=>l.chatbox_show(),700+h)),r.addEventListener("click",t=>{var e;t.target.closest('.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]')&&(t.preventDefault(),e=!!t.target.closest('.joinchat_app, a[href="#whatsapp"]'),l.open(e,t.target.dataset.phone,t.target.dataset.message))}),r.addEventListener("click",t=>{t.target.closest(".joinchat_close")&&(t.preventDefault(),l.close())}),n=r.querySelectorAll(".joinchat_show, .joinchat_force_show"),t&&n&&"IntersectionObserver"in c){let e=new IntersectionObserver(t=>{t.forEach(t=>{t.intersectionRatio<=0||s&&!t.target.classList.contains("joinchat_force_show")||(e.disconnect(),a())})});n.forEach(t=>e.observe(t))}l.is_ready=!0,r.dispatchEvent(new Event("joinchat:start"))}else l.hide(),r.addEventListener("click",t=>{t.target.closest('.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]')&&(t.preventDefault(),l.open_whatsapp(t.target.dataset.phone,t.target.dataset.message))});if(l.can_qr&&!l.is_mobile?r.querySelectorAll(".joinchat-button__qr").forEach(t=>t.appendChild(l.qr(l.get_wa_link(t.dataset.phone,t.dataset.message,!1)))):r.querySelectorAll(".wp-block-joinchat-button figure").forEach(t=>t.remove()),void 0!==l.settings.sku&&"function"==typeof jQuery){let a=l.settings.message_send;jQuery("form.variations_form").on("found_variation reset_data",function(t,e){let s=e&&e.sku||l.settings.sku;l.$$(".joinchat__chat jc-sku").forEach(t=>t.textContent=s),l.settings.message_send=a.replace(/<jc-sku>.*<\/jc-sku>/g,s)})}}}};"loading"!==r.readyState?t():r.addEventListener("DOMContentLoaded",t)})(window,document,window.joinchat_obj||{});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function a(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var r=t[s][1][e];return a(r||e)},p,p.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(e,t,r){"use strict";var n=e("./init"),a={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=a},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),a=e("./helpers/utils"),i={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",id:"id",platform:"plt",format:"fmt",tactic:"tct"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return i.aliases.main.type+"="+e.type+i.delimiter+i.aliases.main.source+"="+e.source+i.delimiter+i.aliases.main.medium+"="+e.medium+i.delimiter+i.aliases.main.campaign+"="+e.campaign+i.delimiter+i.aliases.main.content+"="+e.content+i.delimiter+i.aliases.main.term+"="+e.term+i.delimiter+i.aliases.main.id+"="+e.id+i.delimiter+i.aliases.main.platform+"="+e.platform+i.delimiter+i.aliases.main.format+"="+e.format+i.delimiter+i.aliases.main.tactic+"="+e.tactic},extra:function(e){return i.aliases.extra.fire_date+"="+a.setDate(new Date,e)+i.delimiter+i.aliases.extra.entrance_point+"="+document.location.href+i.delimiter+i.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return i.aliases.udata.visits+"="+e+i.delimiter+i.aliases.udata.ip+"="+t+i.delimiter+i.aliases.udata.agent+"="+navigator.userAgent},session:function(e){return i.aliases.session.pages_seen+"="+e+i.delimiter+i.aliases.session.current_page+"="+document.location.href},promo:function(e){return i.aliases.promo+"="+a.setLeadingZeroToInt(a.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=i},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={useBase64:!1,setBase64Flag:function(e){this.useBase64=e},encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,a){var i,s;if(r){var o=new Date;o.setTime(o.getTime()+60*r*1e3),i="; expires="+o.toGMTString()}else i="";s=n&&!a?";domain=."+n:"";var c=this.encodeData(t);this.useBase64&&(c=btoa(c).replace(/=+$/,"")),document.cookie=this.encodeData(e)+"="+c+i+s+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var a=r[n];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t)){var i=a.substring(t.length,a.length);if(/^[A-Za-z0-9+/]+$/.test(i))try{i=atob(i.padEnd(4*Math.ceil(i.length/4),"="))}catch(s){}return this.decodeData(i)}}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var a in e)e.hasOwnProperty(a)&&t.push(e[a]);for(var i=0;i<t.length;i++){var s;r[this.unsbjs(t[i])]={},s=this.get(t[i])?this.get(t[i]).split(n):[];for(var o=0;o<s.length;o++){var c=s[o].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[i])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},a=14;a--;)n[t.key[a]]=r[a]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,a){r&&(n[t.q.name][r]=a)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=(e||window.location.search.substring(1)).split("&"),n=0;n<r.length;n++){var a=r[n].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var i=[t[a[0]],a[1]];t[a[0]]=i}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),a=t||0===t?t:-r;return e.setHours(n+r+a),e.getFullYear()+"-"+this.setLeadingZeroToInt(e.getMonth()+1,2)+"-"+this.setLeadingZeroToInt(e.getDate(),2)+" "+this.setLeadingZeroToInt(e.getHours(),2)+":"+this.setLeadingZeroToInt(e.getMinutes(),2)+":"+this.setLeadingZeroToInt(e.getSeconds(),2)},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),a=e("./terms"),i=e("./helpers/cookies"),s=e("./helpers/uri"),o=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){var t,r,p,f,m,d,l,g,h,y,_,v,b,x=c.fetch(e),k=s.getParam(),w=x.domain.host,q=x.domain.isolate,I=x.lifetime;function j(e){switch(e){case a.traffic.utm:t=a.traffic.utm,r="undefined"!=typeof k.utm_source?k.utm_source:"undefined"!=typeof k.gclid?"google":"undefined"!=typeof k.yclid?"yandex":a.none,p="undefined"!=typeof k.utm_medium?k.utm_medium:"undefined"!=typeof k.gclid?"cpc":"undefined"!=typeof k.yclid?"cpc":a.none,f="undefined"!=typeof k.utm_campaign?k.utm_campaign:"undefined"!=typeof k[x.campaign_param]?k[x.campaign_param]:"undefined"!=typeof k.gclid?"google_cpc":"undefined"!=typeof k.yclid?"yandex_cpc":a.none,m="undefined"!=typeof k.utm_content?k.utm_content:"undefined"!=typeof k[x.content_param]?k[x.content_param]:a.none,l=k.utm_id||a.none,g=k.utm_source_platform||a.none,h=k.utm_creative_format||a.none,y=k.utm_marketing_tactic||a.none,d="undefined"!=typeof k.utm_term?k.utm_term:"undefined"!=typeof k[x.term_param]?k[x.term_param]:function(){var e=document.referrer;if(k.utm_term)return k.utm_term;if(!(e&&s.parse(e).host&&s.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return s.getParam(s.parse(document.referrer).query).text}catch(t){return!1}}()||a.none;break;case a.traffic.organic:t=a.traffic.organic,r=r||s.getHost(document.referrer),p=a.referer.organic,f=a.none,m=a.none,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;case a.traffic.referral:t=a.traffic.referral,r=r||s.getHost(document.referrer),p=p||a.referer.referral,f=a.none,m=s.parse(document.referrer).path,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;case a.traffic.typein:t=a.traffic.typein,r=x.typein_attributes.source,p=x.typein_attributes.medium,f=a.none,m=a.none,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;default:t=a.oops,r=a.oops,p=a.oops,f=a.oops,m=a.oops,d=a.oops,l=a.oops,g=a.oops,h=a.oops,y=a.oops}var i={type:t,source:r,medium:p,campaign:f,content:m,term:d,id:l,platform:g,format:h,tactic:y};return n.pack.main(i)}function R(e){var t=document.referrer;switch(e){case a.traffic.organic:return!!t&&H(t)&&function(e){var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp("yandex")+"\\..{2,9}$"),n=new RegExp(".*"+o.escapeRegexp("text")+"=.*"),a=new RegExp("^(?:www\\.)?"+o.escapeRegexp("google")+"\\..{2,9}$");if(s.parse(e).query&&s.parse(e).host.match(t)&&s.parse(e).query.match(n))return r="yandex",!0;if(s.parse(e).host.match(a))return r="google",!0;if(!s.parse(e).query)return!1;for(var i=0;i<x.organics.length;i++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(x.organics[i].host)+"$","i"))&&s.parse(e).query.match(new RegExp(".*"+o.escapeRegexp(x.organics[i].param)+"=.*","i")))return r=x.organics[i].display||x.organics[i].host,!0;if(i+1===x.organics.length)return!1}}(t);case a.traffic.referral:return!!t&&H(t)&&function(e){if(!(x.referrals.length>0))return r=s.getHost(e),!0;for(var t=0;t<x.referrals.length;t++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(x.referrals[t].host)+"$","i")))return r=x.referrals[t].display||x.referrals[t].host,p=x.referrals[t].medium||a.referer.referral,!0;if(t+1===x.referrals.length)return r=s.getHost(e),!0}}(t);default:return!1}}function H(e){if(x.domain){if(q)return s.getHost(e)!==s.getHost(w);var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp(w)+"$","i");return!s.getHost(e).match(t)}return s.getHost(e)!==s.getHost(document.location.href)}function D(){i.set(n.containers.current_extra,n.pack.extra(x.timezone_offset),I,w,q),i.get(n.containers.first_extra)||i.set(n.containers.first_extra,n.pack.extra(x.timezone_offset),I,w,q)}return i.setBase64Flag(x.base64),u.go(I,w,q),i.set(n.containers.current,function(){var e;if("undefined"!=typeof k.utm_source||"undefined"!=typeof k.utm_medium||"undefined"!=typeof k.utm_campaign||"undefined"!=typeof k.utm_content||"undefined"!=typeof k.utm_term||"undefined"!=typeof k.utm_id||"undefined"!=typeof k.utm_source_platform||"undefined"!=typeof k.utm_creative_format||"undefined"!=typeof k.utm_marketing_tactic||"undefined"!=typeof k.gclid||"undefined"!=typeof k.yclid||"undefined"!=typeof k[x.campaign_param]||"undefined"!=typeof k[x.term_param]||"undefined"!=typeof k[x.content_param])D(),e=j(a.traffic.utm);else if(R(a.traffic.organic))D(),e=j(a.traffic.organic);else if(!i.get(n.containers.session)&&R(a.traffic.referral))D(),e=j(a.traffic.referral);else{if(i.get(n.containers.first)||i.get(n.containers.current))return i.get(n.containers.current);D(),e=j(a.traffic.typein)}return e}(),I,w,q),i.get(n.containers.first)||i.set(n.containers.first,i.get(n.containers.current),I,w,q),i.get(n.containers.udata)?(_=parseInt(i.parse(n.containers.udata)[i.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,_=i.get(n.containers.session)?_:_+1,v=n.pack.user(_,x.user_ip)):(_=1,v=n.pack.user(_,x.user_ip)),i.set(n.containers.udata,v,I,w,q),i.get(n.containers.session)?(b=parseInt(i.parse(n.containers.session)[i.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,b+=1):b=1,i.set(n.containers.session,n.pack.session(b),x.session_length,w,q),x.promocode&&!i.get(n.containers.promocode)&&i.set(n.containers.promocode,n.pack.promo(x.promocode),I,w,q),i.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),a=e("./helpers/cookies");t.exports={go:function(e,t,r){var i,s=this.migrations,o={l:e,d:t,i:r};if(a.get(n.containers.first)||a.get(n.service.migrations)){if(!a.get(n.service.migrations))for(i=0;i<s.length;i++)s[i].go(s[i].id,o)}else{var c=[];for(i=0;i<s.length;i++)c.push(s[i].id);var u="";for(i=0;i<c.length;i++)u+=c[i]+"=1",i<c.length-1&&(u+=n.delimiter);a.set(n.service.migrations,u,o.l,o.d,o.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",i=e+"=0",s=function(e,t,r){return t||r?e:n.delimiter};try{var o=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&o.push(n.containers[c]);for(var u=0;u<o.length;u++)if(a.get(o[u])){var p=a.get(o[u]).replace(/(\|)?\|(\|)?/g,s);a.destroy(o[u],t.d,t.i),a.destroy(o[u],t.d,!t.i),a.set(o[u],p,t.l,t.d,t.i)}a.get(n.containers.session)&&a.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),a.set(n.service.migrations,r,t.l,t.d,t.i)}catch(f){a.set(n.service.migrations,i,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),a=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.base64=t.base64||!1,r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:a.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var i=0;i<t.referrals.length;i++)t.referrals[i].host&&r.referrals.push(t.referrals[i]);if(r.organics=[],t.organics&&t.organics.length>0)for(var s=0;s<t.organics.length;s++)t.organics[s].host&&t.organics[s].param&&r.organics.push(t.organics[s]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});