/*
    Google Maps
    Version: 2.4.2
    Release date: Fri Mar 26 2021

    https://elfsight.com

    Copyright (c) 2021 Elfsight, LLC. ALL RIGHTS RESERVED
*/

"use strict";!function(e,t){var i,a,n,s,o,d,r,g,c,l=t.pluginParams.slug,p=t.pluginParams.domainId,f=JSON.parse(t.pluginParams.user),h="true"===t.pluginParams.widgetsClogged,m=!1,u=t.pluginParams.restApiUrl,v=t.wpApiSettings.nonce;function w(){this.pages=[]}w.prototype={constructor:w,add:function(t,i){if(!t||!i||!e.isFunction(i))return!1;this.pages[t]=i()||{}},get:function(e){return this.pages[e]||!1},show:function(t,i){var d,c=this,l=this.get(t);return!!l&&("init"in l&&e.isFunction(l.init)&&(d=l.init(i)),e.when(d).then(function(){r.hasClass("elfsight-admin-other-products-hidden-permanently")||r.toggleClass("elfsight-admin-other-products-hidden","widgets"!==t),a.removeClass("elfsight-admin-loading"),s.removeClass("active"),s.filter("[data-elfsight-admin-page="+t+"]").addClass("active"),g.length&&g.removeClass("elfsight-admin-page-active"),g=n.filter("[data-elfsight-admin-page-id="+t+"]"),o.css("min-height",g.outerHeight()),g.addClass("elfsight-admin-page-animation elfsight-admin-page-active"),setTimeout(function(){g.removeClass("elfsight-admin-page-animation"),"function"==typeof c.onPageChanged&&c.onPageChanged(t)},200)}),l)}};var C=new w;function S(){this.popups=[]}t.elfsightAdminPagesController=C,S.prototype={constructor:S,add:function(t,i){if(!t||!i||!e.isFunction(i))return!1;this.popups[t]=i()||{}},get:function(e){return this.popups[e]||!1},hide:function(e){(c=d.filter("[data-elfsight-admin-popup-id="+e+"]")).removeClass("elfsight-admin-popup-active")},show:function(t,i){var a,n=this.get(t);return!!n&&("init"in n&&e.isFunction(n.init)&&(a=n.init(i)),e.when(a).then(function(){c.length&&c.removeClass("elfsight-admin-popup-active"),(c=d.filter("[data-elfsight-admin-popup-id="+t+"]")).addClass("elfsight-admin-popup-animation elfsight-admin-popup-active"),setTimeout(function(){c.removeClass("elfsight-admin-popup-animation")},200)}),n)}};var b=new S;e(function(){i=e(".elfsight-admin"),a=e(".elfsight-admin-main"),n=e("[data-elfsight-admin-page-id]"),s=e("[data-elfsight-admin-page]"),o=e(".elfsight-admin-pages-container"),d=e("[data-elfsight-admin-popup-id]"),r=e(".elfsight-admin-other-products"),g=e(),c=e(),C.add("welcome",e.noop),C.add("widgets",function(){var t=[],i=e(".elfsight-admin-page-widgets"),a=e(".elfsight-admin-page-widgets-list",i),n=e(".elfsight-admin-template-widgets-list-item",i),s=e(".elfsight-admin-template-widgets-list-empty",i);a.on("click",".elfsight-admin-page-widgets-list-item-actions-remove",function(t){var i=e(this),a=i.attr("data-widget-id");i.closest(".elfsight-admin-page-widgets-list-item").addClass("elfsight-admin-page-widgets-list-item-removed"),S("widgets/remove",{id:a},"post",!0),t.preventDefault()}),a.on("click",".elfsight-admin-page-widgets-list-item-actions-restore a",function(t){var i=e(this),a=i.attr("data-widget-id");i.closest(".elfsight-admin-page-widgets-list-item").removeClass("elfsight-admin-page-widgets-list-item-removed"),S("widgets/restore",{id:a},"post",!0),t.preventDefault()}),a.tablesorter({cssAsc:"elfsight-admin-page-widgets-list-sort-asc",cssDesc:"elfsight-admin-page-widgets-list-sort-desc",cssHeader:"elfsight-admin-page-widgets-list-sort",headers:{0:{},1:{},2:{},3:{sorter:!1}}});var o=function(){var i=e("tbody",a).empty();e.isArray(t)&&t.length?(e.each(t,function(t,a){var s=e(n.html()),o="["+l.split("-").join("_")+' id="'+a.id+'"]';s.find(".elfsight-admin-page-widgets-list-item-name a").attr("href","#/edit-widget/"+a.id+"/").text(a.name);var d=new Date(1e3*(a.time_updated||a.time_created));s.find(".elfsight-admin-page-widgets-list-item-date").text(function(e){e instanceof Date||(e=new Date(Date.parse(e)));return["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()]+" "+e.getDate()+", "+e.getFullYear()}(d)),s.find(".elfsight-admin-page-widgets-list-item-shortcode-hidden").text(o);var r=s.find(".elfsight-admin-page-widgets-list-item-shortcode-input").val(o),g=s.find(".elfsight-admin-page-widgets-list-item-shortcode-copy-trigger").attr("data-clipboard-text",o),c=new ClipboardJS(g.get(0));c.on("success",function(){g.addClass("elfsight-admin-page-widgets-list-item-shortcode-copy-trigger-copied").find("span").text("Copied"),setTimeout(function(){g.removeClass("elfsight-admin-page-widgets-list-item-shortcode-copy-trigger-copied").find("span").text("Copy")},5e3)}),c.on("error",function(){var e=s.find(".elfsight-admin-page-widgets-list-item-shortcode-copy-error").show();r.select(),setTimeout(function(){e.hide()},5e3)}),s.find(".elfsight-admin-page-widgets-list-item-shortcode-value").text(o),s.find(".elfsight-admin-page-widgets-list-item-actions-edit").attr("href","#/edit-widget/"+a.id+"/"),s.find(".elfsight-admin-page-widgets-list-item-actions-duplicate").attr("href","#/edit-widget/"+a.id+"/duplicate/"),s.find(".elfsight-admin-page-widgets-list-item-actions-remove, .elfsight-admin-page-widgets-list-item-actions-restore a").attr("data-widget-id",a.id),s.appendTo(i)}),a.trigger("update")):e(s.html()).appendTo(i)};return{init:function(i,a){return S("widgets/list").then(function(i){if(i.status){if(t=i.data,!(h||e.isArray(t)&&t.length))return C.show("welcome"),e.Deferred().reject(i).promise();o(),m=!0}})}}}),C.add("edit-widget",function(){var i,a,n,s="add",o=e(".elfsight-admin-page-edit-widget"),d=e(".elfsight-admin-page-edit-widget-form-submit",o),r=e(".elfsight-admin-page-edit-widget-form-apply",o),g=e(".elfsight-admin-page-edit-widget-unsaved",o),c=e(".elfsight-admin-page-edit-widget-form-cancel",o),l=e(".elfsight-admin-page-edit-widget-name-input",o),h="elfsight-admin-page-edit-widget-form-editor",u=h+"-clone",v=e("."+u,o).parent(),w=e("."+u,o),y=!1,x=JSON.parse(w.attr("data-elfsight-admin-editor-settings")),_=JSON.parse(w.attr("data-elfsight-admin-editor-preferences")),P=JSON.parse(w.attr("data-elfsight-admin-editor-preview-url")),T=w.attr("data-elfsight-admin-editor-observer-url")||null;T&&(T=JSON.parse(T));var D=function(e){e,g.toggleClass("elfsight-admin-page-edit-widget-unsaved-visible",e),e?t.addEventListener("beforeunload",k):t.removeEventListener("beforeunload",k)},k=function(e){e.preventDefault(),e.returnValue="Widget has unsaved changed"},j=function(t){var n,o=l.val(),d={};a.getData()?d=a.getData():i&&(d=i.options),"update"===s&&(n="widgets/update"),"add"===s&&(n="widgets/add");var r={name:o||"Untitled",options:encodeURIComponent(JSON.stringify(d))};i&&(r.id=i.id),S(n,r,"post").done(function(a){a.status&&(a.id&&(i={id:a.id},m=!0,b.popups.rating.open(!0,3e4)),e.isFunction(t)&&t())})};return d.on("click",function(){e("html, body").animate({scrollTop:0}),j(function(){D(!1),hasher.setHash("widgets/")})}),r.on("click",function(){j(),D(!1)}),c.on("click",function(){hasher.setHash("widgets/"),D(!1)}),{init:function(t,d){var r=function(){l.val(i?i.name:""),n&&n.remove(),(n=w.clone().removeClass(u).addClass(h)).appendTo(v);var t=angular.module("elfsightEditor",["elfsightAppsEditor"]),s=i.public_id||i.id;t.controller("AppController",["$elfsightAppsEditor","$scope","$rootScope","$timeout",function(t,o,d,r){a=t,d.user=f,y=!1;var g={parent:n,previewUrl:P,observerUrl:T||void 0,settings:e.extend(!0,{},x),preferences:_,widget:{data:i.options,public_id:p+"-"+s},enableCustomCSS:!1,enableCloudProperties:!1,onChange:function(e){y?D(!0):y=!0}};t.init(g)}]),n.attr("ng-controller","AppController as app"),angular.bootstrap(n,["elfsightEditor"])};return t&&t.id?S("widgets/list",{id:t.id}).then(function(a){if(a.status){if(!a.data.length)return C.show("error",{message:"There is no widget with id "+t.id+"."}),e.Deferred().reject(a).promise();i=a.data[0],m=!0,r(),D(!1),o.toggleClass("elfsight-admin-page-edit-widget-new",!!t.duplicate),t.duplicate?S("widgets/prepare").then(function(e){i.public_id=e.data.widget_id,r(),s="add"}):s="update"}},function(){i=null}):S("widgets/prepare").then(function(e){s="add",i={public_id:e.data.widget_id},r(),o.addClass("elfsight-admin-page-edit-widget-new")})}}}),C.add("preferences",function(){var t=e(".elfsight-admin-page-preferences-form"),i=function(t,i){var a=i.find(".elfsight-admin-page-preferences-option-save");a.addClass("elfsight-admin-page-preferences-option-save-loading"),e.ajax({type:"POST",url:u+"/update-preferences/",data:t,dataType:"json",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",v)}}).done(function(e){var t=i.find(".elfsight-admin-page-preferences-option-save-success"),n=i.find(".elfsight-admin-page-preferences-option-save-error");a.removeClass("elfsight-admin-page-preferences-option-save-loading"),e.success?(n.text(""),t.addClass("elfsight-admin-page-preferences-option-save-success-visible"),setTimeout(function(){t.removeClass("elfsight-admin-page-preferences-option-save-success-visible")},2e3)):e.error&&n.text(e.error)})},a=function(e,t){var i=e.getSession().getScreenLength()*e.renderer.lineHeight+e.renderer.scrollBar.getWidth();t.height(i.toString()+"px"),e.resize()},n=ace.edit("elfsightPreferencesSnippetCSS");n.setOption("useWorker",!1),n.setTheme("ace/theme/monokai"),n.getSession().setMode("ace/mode/css"),n.commands.addCommand({name:"save",bindKey:{win:"Ctrl-S",mac:"Command-S"},exec:function(){var t=e(".elfsight-admin-page-preferences-option-css");i({preferences_custom_css:n.getSession().doc.getValue()},t)}}),a(n,e("#elfsightPreferencesSnippetCSS")),n.getSession().on("change",function(){a(n,e("#elfsightPreferencesSnippetCSS"))});var s=ace.edit("elfsightPreferencesSnippetJS");s.setOption("useWorker",!1),s.setTheme("ace/theme/monokai"),s.getSession().setMode("ace/mode/javascript"),s.commands.addCommand({name:"save",bindKey:{win:"Ctrl-S",mac:"Command-S"},exec:function(){var t=e(".elfsight-admin-page-preferences-option-js");i({preferences_custom_js:s.getSession().doc.getValue()},t)}}),a(s,e("#elfsightPreferencesSnippetJS")),s.getSession().on("change",function(){a(s,e("#elfsightPreferencesSnippetJS"))}),t.find(".elfsight-admin-page-preferences-option-save").click(function(t){t.preventDefault();var a=e(this),o=a.closest(".elfsight-admin-page-preferences-option"),d=a.closest(".elfsight-admin-page-preferences-option-input-container").find('input[type="text"]'),r={};d.each(function(t,i){r[e(i).attr("name")]=e(i).val()}),o.is(".elfsight-admin-page-preferences-option-css")&&(r.preferences_custom_css=n.getSession().doc.getValue()),o.is(".elfsight-admin-page-preferences-option-js")&&(r.preferences_custom_js=s.getSession().doc.getValue()),i(r,o)}),t.find('[name="preferences_force_script_add"]').change(function(){var t=e(this),a=t.closest(".elfsight-admin-page-preferences-option");i({option:{name:"force_script_add",value:t.is(":checked")?"on":"off"}},a)}),t.find('[name="preferences_access_role"]').change(function(){var t=e(this),a=t.closest(".elfsight-admin-page-preferences-option");i({option:{name:"access_role",value:t.val()}},a)}),t.find('[name="preferences_auto_upgrade"]').change(function(){var t=e(this),a=t.closest(".elfsight-admin-page-preferences-option");i({option:{name:"auto_upgrade",value:t.is(":checked")?"on":"off"}},a)})}),C.add("activation",function(){var t=e(".elfsight-admin-page-activation-form"),a=e(".elfsight-admin-page-activation-form-purchase-code-input",t),n=e(".elfsight-admin-page-activation-form-activated-input",t),s=e(".elfsight-admin-page-activation-form-host-input",t),o=e(".elfsight-admin-page-activation-form-activation-button",t),d=e(".elfsight-admin-page-activation-form-activation",t),r=e(".elfsight-admin-page-activation-form-activation-confirm-no",t),g=e(".elfsight-admin-page-activation-form-activation-confirm-yes",t),c=(e(".elfsight-admin-page-activation-form-deactivation",t),e(".elfsight-admin-page-activation-form-deactivation-button",t)),p=e(".elfsight-admin-page-activation-form-deactivation-confirm-no",t),f=e(".elfsight-admin-page-activation-form-deactivation-confirm-yes",t),h=e(".elfsight-admin-page-activation-form-message-success",t),m=e(".elfsight-admin-page-activation-form-message-error",t),w=e(".elfsight-admin-page-activation-form-message-fail",t),C=e(".elfsight-admin-page-activation-faq"),S=e(".elfsight-admin-page-activation-faq-list-item",C),b=null,y=t.attr("data-activation-url"),x=t.attr("data-activation-version"),_=function(t,i){e.ajax({type:"POST",url:u+"/update-activation-data/",data:{purchase_code:t,activated:i},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",v)}}),a.prop("readonly",i)};o.click(function(e){e.preventDefault(),e.stopPropagation(),P({purchaseCode:a.val(),host:s.val()})});var P=function(a){var s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.ajax({url:y,dataType:"jsonp",data:{action:"purchase_code",slug:l+"-cc",host:a.host,purchase_code:a.purchaseCode,version:x,force_update:s}}).done(function(e){if(e.verification){b=e.verification;var s=!!e.verification.valid;n.val(s),b.valid?(i.removeClass("elfsight-admin-activation-invalid").addClass("elfsight-admin-activation-activated"),m.text("").hide(),w.hide(),h.show(),_(a.purchaseCode,s)):(i.removeClass("elfsight-admin-activation-activated").toggleClass("elfsight-admin-activation-invalid",!!a.purchaseCode),h.hide(),w.hide(),m.text(b.error).show()),b.exception&&"PC_REGISTERED_TO_ANOTHER"===b.exception&&(m.text("").hide(),d.find(".elfsight-admin-page-activation-form-activation-confirm-caption-message").html(b.error),t.addClass("elfsight-admin-page-activation-form-activation-confirm-visible"))}}).fail(function(){i.removeClass("elfsight-admin-activation-activated").addClass("elfsight-admin-activation-invalid"),n.val(!1),h.hide(),m.hide(),w.show(),_(a.purchaseCode,!1)})};c.click(function(e){e.preventDefault(),e.stopPropagation(),t.addClass("elfsight-admin-page-activation-form-deactivation-confirm-visible")}),p.click(function(e){e.preventDefault(),e.stopPropagation(),t.removeClass("elfsight-admin-page-activation-form-deactivation-confirm-visible")}),f.click(function(o){o.preventDefault(),o.stopPropagation(),t.removeClass("elfsight-admin-page-activation-form-deactivation-confirm-visible");var d=a.val(),r=s.val();e.ajax({url:y,dataType:"jsonp",data:{action:"deactivate",slug:l+"-cc",host:r,purchase_code:d,version:x}}).done(function(e){a.val(""),n.val("false"),i.removeClass("elfsight-admin-activation-activated"),h.hide(),w.hide(),m.hide(),_("",!1)})}),r.click(function(e){e.preventDefault(),e.stopPropagation(),t.removeClass("elfsight-admin-page-activation-form-activation-confirm-visible")}),g.click(function(e){e.preventDefault(),e.stopPropagation(),P({purchaseCode:a.val(),host:s.val()},!0)}),C.find(".elfsight-admin-page-activation-faq-list-item-question").click(function(){var t=e(this).closest(".elfsight-admin-page-activation-faq-list-item");S.not(t).removeClass("elfsight-admin-page-activation-faq-list-item-active"),t.toggleClass("elfsight-admin-page-activation-faq-list-item-active")})}),C.add("error",function(){var t=e(".elfsight-admin-page-error");return{init:function(i){i&&i.message&&e(".elfsight-admin-page-error-message",t).text(i.message)}}}),b.add("rating",function(){var t=e(".elfsight-admin-header-rating"),i=t.find("input[name=rating-header]"),a=e(".elfsight-admin-popup-rating"),n=a.find("form"),s=a.find("input[name=rating-popup]"),o=a.find(".elfsight-admin-popup-textarea"),d=a.find(".elfsight-admin-popup-text"),r=a.find(".elfsight-admin-popup-footer-button-ok"),g=a.find(".elfsight-admin-popup-footer-button-close"),c=localStorage.getItem("popupRatingShowed")?localStorage.getItem("popupRatingShowed"):Math.floor(Date.now()/1e3),l=parseInt(c)+86400<Math.floor(Date.now()/1e3),p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;setTimeout(function(){if(a.length&&!a.hasClass("elfsight-admin-popup-sent")){var t=!~hasher.getHash().indexOf("edit-widget")&&!~hasher.getHash().indexOf("add-widget");(!e||e&&l&&t&&m)&&b.show("rating"),localStorage.setItem("popupRatingShowed",Math.floor(Date.now()/1e3))}},t)};setTimeout(function(){m&&t&&(p(!0,3e4),t.slideDown())},5e3),i.on("change",function(){var t=parseInt(e(this).val());p(!1,0),setTimeout(function(){s.filter('[value="'+t+'"]').prop("checked",!0),f(t)},400),e(this).prop("checked",!1)});var f=function(e){r.removeClass("elfsight-admin-popup-footer-button-hide"),o.toggleClass("elfsight-admin-popup-textarea-hide",5===e),d.toggleClass("elfsight-admin-popup-text-hide",e<5)};return s.on("change",function(){f(parseInt(e(this).val()))}),r.on("click",function(i){i.preventDefault();var s=parseInt(n.find('input[name="rating-popup"]:checked').val()),d=n.find("textarea").val();5===s&&w(e(i.target).attr("href")),s<5&&""===d?o.toggleClass("elfsight-admin-popup-textarea-error",!0):(o.toggleClass("elfsight-admin-popup-textarea-error",!1),e.ajax({type:"POST",url:u+"/rating-send/",data:{value:s,comment:d},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",v)}}).then(function(){a.addClass("elfsight-admin-popup-sent"),g.text("OK"),r.addClass("elfsight-admin-popup-footer-button-hide"),t.slideUp(),localStorage.removeItem("popupRatingShowed")}))}),g.on("click",function(){b.hide("rating"),r.addClass("elfsight-admin-popup-footer-button-hide"),o.addClass("elfsight-admin-popup-textarea-hide"),d.addClass("elfsight-admin-popup-text-hide"),s.prop("checked",!1)}),{init:function(e,t){return!0},open:p}});var w=function(e,i){var a=940,n=700,s=["width="+a,"height="+n,"menubar=no","toolbar=no","resizable=yes","scrollbars=yes","left="+(t.screen.availLeft+t.screen.availWidth/2-a/2),"top="+(t.screen.availTop+t.screen.availHeight/2-n/2)];t.open(e,i,s.join(","))},S=function(t,i,n,s){return i="post"===(n="post"===n?"post":"get")?JSON.stringify(i):i,e.ajax({url:u+"/"+t+"/",dataType:"json",data:i,contentType:"application/json",type:n,beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",v),e.setRequestHeader("X-HTTP-Method-Override",n),s||a.addClass("elfsight-admin-loading")}}).always(function(){s||a.removeClass("elfsight-admin-loading")}).then(function(t){return t.status?t:(C.show("error",{message:"An error occurred during your request process. Please, try again."}),e.Deferred().reject(t).promise())},function(e){return C.show("error",{message:"An error occurred during your request process. Please, try again."}),e})};if(t.crossroads&&t.hasher){crossroads.addRoute("/add-widget/",function(){C.show("edit-widget")}),crossroads.addRoute("/edit-widget/{id}/",function(e){C.show("edit-widget",{id:e})}),crossroads.addRoute("/edit-widget/{id}/duplicate/",function(e){C.show("edit-widget",{id:e,duplicate:!0})}),crossroads.addRoute("/{page}/",function(e){e&&-1===e.indexOf("!")&&(C.show(e)||C.show("error",{message:"The requested page was not found."}))});var y=function(e,t){crossroads.parse(e)};hasher.initialized.add(y),hasher.changed.add(y),hasher.init(),hasher.getHash()||hasher.setHash("widgets/")}})}(jQuery,window);