var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};var tdPopupModal={};jQuery().ready(function(){tdPopupModal.init()});
(function(){tdPopupModal={ui_events:"mouseover click keydown wheel touchmove touchstart".split(" "),items:[],itemsQueue:[],item:function(){this.blockUid=this.uid="";this.modalObj=this.triggerBtnObj=void 0;this.closeModals=[];this._modal_trigger_types=[];this._modal_content_load_data=this._modal_content_load=this._modal_open_position="";this._site_scroll=!0;this._is_initialized=this._show_modal_in_composer=this._in_composer=this._is_modal_open=!1},init:function(){tdPopupModal.items=[];this._is_running=
!1},_initialize_item:function(a){if(!0!==a._is_initialized){a._is_initialized=!0;if(a._in_composer){var b=document.getElementsByClassName(a.blockUid)[0];b.classList.contains("tdc-element-selected")&&!0===a._show_modal_in_composer&&tdPopupModal.modalOpen(a);(new MutationObserver(function(b,c){b.forEach(function(b){"class"===b.attributeName&&(b=b.target.classList,b.contains("tdc-element-selected")&&!b.contains("tdc-dragged")?!0===a._show_modal_in_composer?tdPopupModal.modalOpen(a):tdPopupModal.modalClose(a):
tdPopupModal.modalClose(a))})})).observe(b,{attributes:!0})}else if(tdPopupModal.modalManageOpenState(a),tdPopupModal.modalManageCloseState(a),"ui_delayed"===a._modal_content_load)a.modalObj.on("ui_delayed_load",function(){tdPopupModal.modalLoadContent(a)});tdPopupModal.modalOpenPosition(a)}},addItem:function(a){if("undefined"===typeof a.uid)throw"item.uid is not defined";tdPopupModal.items.push(a);tdPopupModal._initialize_item(a)},getItem:function(a){for(var b=0;b<tdPopupModal.items.length;b++)if(tdPopupModal.items[b].uid===
a)return tdPopupModal.items[b];return!1},modalManageOpenState:function(a){for(var b={},d=$jscomp.makeIterator(Object.entries(a._modal_trigger_types)),c=d.next();!c.done;b={$jscomp$loop$prop$trigger_options$8:b.$jscomp$loop$prop$trigger_options$8},c=d.next()){c=$jscomp.makeIterator(c.value);var e=c.next().value;b.$jscomp$loop$prop$trigger_options$8=c.next().value;switch(e){case "button":a.triggerBtnObj.click(function(b){b.preventDefault();tdPopupModal.modalOpen(a)});break;case "page_load":c=b.$jscomp$loop$prop$trigger_options$8.modal_open_delay;
var f=b.$jscomp$loop$prop$trigger_options$8.modal_close_after,g=b.$jscomp$loop$prop$trigger_options$8.modal_prevent_open;e=a.uid;0==g&&tdPopupModal.setCookie(e,"",g);""!=tdPopupModal.getCookie(e)||a._is_modal_open||setTimeout(function(){tdPopupModal.modalOpen(a);0<f&&a._is_modal_open&&setTimeout(function(){tdPopupModal.modalClose(a);var b=a.uid;0<g&&""==tdPopupModal.getCookie(b)&&tdPopupModal.setCookie(b,"set",g)},f)},c);break;case "cursor_area":c=function(b){return function(c){""===tdPopupModal.getCookie(a.uid)&&
b.$jscomp$loop$prop$trigger_options$8.area_vertical_space.trim()>=c.y&&tdPopupModal.modalOpen(a)}}(b);document.addEventListener("mousemove",tdPopupModal._checkModal(c,300));break;case "scroll":c=function(b){return function(c){if(""===tdPopupModal.getCookie(a.uid)){var d=b.$jscomp$loop$prop$trigger_options$8.scroll_distance.trim();0<d.indexOf("%")?(d=parseInt(d.replace(/%/gi,""),10),100*window.scrollY/document.body.clientHeight>d&&tdPopupModal.modalOpen(a)):(0<d.indexOf("px")&&(d=parseInt(d.replace(/px/gi,
""),10)),c.target.scrollingElement.scrollTop>d&&tdPopupModal.modalOpen(a))}}}(b),document.addEventListener("scroll",tdPopupModal._checkModal(c,10))}}},_checkModal:function(a,b){var d=Date.now()-b;return function(c){for(var e=[],f=0;f<arguments.length;++f)e[f-0]=arguments[f];Date.now()-d>=b&&(d=Date.now(),a.apply(null,e))}},modalManageCloseState:function(a){var b=["tdm-pmh-close"];"over-screen"===a._modal_open_position&&b.push("tdm-popup-modal-bg");jQuery("#tdm-popup-modal-"+a.uid+" .tdm-pmh-close,#tdm-popup-modal-"+
a.uid+" .tdm-popup-modal-bg").click(function(){if(!0===a._is_modal_open){tdPopupModal.modalClose(a);for(var b=$jscomp.makeIterator(Object.entries(a._modal_trigger_types)),c=b.next();!c.done;c=b.next()){var e=$jscomp.makeIterator(c.value);c=e.next().value;e=e.next().value;switch(c){case "page_load":c=e.modal_prevent_open;e=a.uid;0<c&&""==tdPopupModal.getCookie(e)&&tdPopupModal.setCookie(e,"set",c);break;case "cursor_area":c=e.modal_area_prevent_open;0<c&&""===tdPopupModal.getCookie(a.uid)&&tdPopupModal.setCookie(a.uid,
"set",c);break;case "scroll":c=e.modal_scroll_prevent_open,0<c&&""===tdPopupModal.getCookie(a.uid)&&tdPopupModal.setCookie(a.uid,"set",c)}}}})},modalOpenPosition:function(a){switch(a._modal_open_position){case "over-screen":a.modalObj.detach().prependTo("body"),a.modalObj.attr("style","")}},modalOpen:function(a){if(!a._is_modal_open){for(var b=!1,d=0;d<tdPopupModal.items.length;d++)if(tdPopupModal.items[d].uid!==a.uid&&tdPopupModal.items[d]._is_modal_open){b=!0;break}d=!1;for(var c=$jscomp.makeIterator(Object.entries(a._modal_trigger_types)),
e=c.next();!e.done;e=c.next()){var f=$jscomp.makeIterator(e.value);e=f.next().value;f=f.next().value;if("page_load"===e&&f.modal_open_when_others_close){d=!0;break}}if(b&&d){b=!1;for(d=0;d<tdPopupModal.itemsQueue.length;d++)tdPopupModal.itemsQueue[d].uid===a.uid&&(b=!0);b||tdPopupModal.itemsQueue.push(a)}else for(a.modalObj.addClass("tdm-popup-modal-open"),a._is_modal_open=!0,a._site_scroll||jQuery("body").addClass("tdm-popup-modal-prevent-scroll"),a.modalObj.trigger("tdPopupModal.show"),b=$jscomp.makeIterator(Object.entries(a.closeModals)),
d=b.next();!d.done;d=b.next())d=$jscomp.makeIterator(d.value),d.next(),d=d.next().value,tdPopupModal.getItem(d)&&jQuery("#tdm-popup-modal-"+a.closeModals+" .tdm-pmh-close").click()}},modalClose:function(a){a._is_modal_open&&(a.modalObj.removeClass("tdm-popup-modal-open"),a._is_modal_open=!1,a._site_scroll||jQuery("body").removeClass("tdm-popup-modal-prevent-scroll"),a.modalObj.trigger("tdPopupModal.close"),tdShowVideo._pauseModalPlayers(),tdPopupModal.itemsQueue.length&&tdPopupModal.modalOpen(tdPopupModal.itemsQueue.shift()))},
setCookie:function(a,b,d){var c=new Date;c.setTime(c.getTime()+d);d="expires="+c.toUTCString();document.cookie=a+"="+b+";"+d+";path=/"},getCookie:function(a){a+="=";for(var b=decodeURIComponent(document.cookie).split(";"),d=0;d<b.length;d++){for(var c=b[d];" "==c.charAt(0);)c=c.substring(1);if(0==c.indexOf(a))return c.substring(a.length,c.length)}return""},deleteItem:function(a){for(var b=0;b<tdPopupModal.items.length;b++)if(tdPopupModal.items[b].blockUid===a)return a=jQuery("body"),!tdPopupModal.items[b]._site_scroll&&
a.hasClass("tdm-popup-modal-prevent-scroll")&&a.removeClass("tdm-popup-modal-prevent-scroll"),jQuery("#tdm-popup-modal-"+tdPopupModal.items[b].uid).remove(),tdPopupModal.items.splice(b,1),!0;return!1},resetItems:function(){tdPopupModal.items=[]},loadDelayed:function(a){for(a=0;a<tdPopupModal.items.length;a++){var b=tdPopupModal.items[a];"ui_delayed"!==b._modal_content_load||b._in_composer||b.modalObj.trigger("ui_delayed_load")}tdPopupModal.ui_events.forEach(function(a){window.removeEventListener(a,
tdPopupModal.loadDelayed)})},modalLoadContent:function(a){var b=jQuery.parseJSON(a._modal_content_load_data),d=b.content_source,c=a.modalObj.find(".tdm-pm-body");"custom_code"===d&&c.append(b.content);if("page"===d){var e=b.page_id;jQuery.ajax({type:"POST",url:td_ajax_url,data:{action:"tdb_get_modal_page",pageId:e,td_res_context_registered_atts:td_res_context_registered_atts},success:function(a,b,d){a=jQuery.parseJSON(a);"undefined"!==typeof a.content&&(jQuery(a.content).appendTo(c),"undefined"!==
typeof window.tdAnimationStack&&!0===window.tdAnimationStack.activated&&window.tdAnimationStack.reinit())},error:function(a,b,c){console.group("%c tdPopupModal.modalLoadContent/tdb_get_modal_page: error","color: orangered;");console.log("Post: ",{pageId:e});console.log("Error data: ",{errorThrown:c,textStatus:b,status:void 0!==a.status?a.status:"",MLHttpRequest:a});console.groupEnd()}})}}}})();
jQuery(document).ready(function(){tdPopupModal.ui_events.forEach(function(a){window.addEventListener(a,tdPopupModal.loadDelayed,{passive:!0})})});
