jQuery(document).ready(function(a){a(".kad-panel-left .nav-tab-link").click(function(b){b.preventDefault();const c=a(this).closest(".kad-panel-left"),d=c.find(".nav-tab-wrapper"),e=d.find(".nav-tab-active"),f=a(this).closest(".kad-panel-contain").find(".nav-tab-content.panel_open"),g=a(this).data("tab-id"),h=d.find("a[data-tab-id=\""+g+"\"]");return e.data("tab-id")==g||(h.addClass("nav-tab-active"),e.removeClass("nav-tab-active"),f.removeClass("panel_open"),a("#"+g).addClass("panel_open")),!1}),a(".kt-blocks-config-settings").on("click",function(b){b.preventDefault();const c=a(this).val(),d=a(this).data("name"),e=a("#js-settings-modal-content");let f="";if(kt_blocks_params.blockConfigSettings[c])for(var g in kt_blocks_params.blockConfigSettings[c]){if(!kt_blocks_params.blockConfigSettings[c].hasOwnProperty(g))continue;const a=kt_blocks_params.blockConfigSettings[c][g],b=kt_blocks_params.blockConfig[c]&&"undefined"!=typeof kt_blocks_params.blockConfig[c][g]?kt_blocks_params.blockConfig[c][g]:a.default;switch(a.type){case"boolean":f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"\">"+a.name+"</label><input id=\""+g+"\" class=\"kt-block-config-input\" name=\""+g+"\" type=\"checkbox\" "+(!1===b?"":"checked")+"></div>";break;case"info":f+="<div class=\"kt-modal-settings-field\"><p>"+a.name+"</p></div>";break;case"number":f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"\">"+a.name+"</label><input id=\""+g+"\" class=\"kt-block-config-input\" name=\""+g+"\" type=\"number\" step=\""+a.options.step+"\" max=\""+a.options.max+"\" min=\""+a.options.min+"\" value=\""+b+"\"></div>";break;case"typoNumber":f+=a.units&&"em"===kt_blocks_params.blockConfig[c][a.units]?"<div class=\"kt-modal-settings-field\"><label for=\""+g+"\">"+a.name+"</label><input id=\""+g+"\" class=\"kt-block-config-input\" name=\""+g+"\" type=\"number\" step=\"0.1\" max=\"12\" min=\"0.1\" value=\""+b+"\"></div>":"<div class=\"kt-modal-settings-field\"><label for=\""+g+"\">"+a.name+"</label><input id=\""+g+"\" class=\"kt-block-config-input\" name=\""+g+"\" type=\"number\" step=\""+a.options.step+"\" max=\""+a.options.max+"\" min=\""+a.options.min+"\" value=\""+b+"\"></div>";break;case"select":for(const c in f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"\">"+a.name+"</label><select id=\""+g+"\" class=\"kt-block-config-input\" name=\""+g+"\">",a.options){if(!a.options.hasOwnProperty(c))continue;const d=b==a.options[c].value?"selected":"";f+="<option value=\""+a.options[c].value+"\" "+d+">"+a.options[c].name+"</option>"}f+="</select></div>";break;case"numberArray":f+="<div class=\"kt-modal-settings-number-array\" data-array-key=\""+g+"\"><h4>"+a.name+"</h4>",f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"[0]\"><i class=\"dashicons dashicons-arrow-up-alt\"></i></label><input id=\""+g+"[0]\" class=\"kt-block-config-input-number-array\" name=\""+g+"[0]\" data-array-key=\""+g+"\" type=\"number\" step=\""+a.options.step+"\" max=\""+a.options.max+"\" min=\""+a.options.min+"\" value=\""+(b?b[0]:"")+"\"></div>",f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"[1]\"><i class=\"dashicons dashicons-arrow-right-alt\"></i></label><input id=\""+g+"[1]\" class=\"kt-block-config-input-number-array\" name=\""+g+"[1]\" data-array-key=\""+g+"\" type=\"number\" step=\""+a.options.step+"\" max=\""+a.options.max+"\" min=\""+a.options.min+"\" value=\""+(b?b[1]:"")+"\"></div>",f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"[2]\"><i class=\"dashicons dashicons-arrow-down-alt\"></i></label><input id=\""+g+"[2]\" class=\"kt-block-config-input-number-array\" name=\""+g+"[2]\" data-array-key=\""+g+"\" type=\"number\" step=\""+a.options.step+"\" max=\""+a.options.max+"\" min=\""+a.options.min+"\" value=\""+(b?b[2]:"")+"\"></div>",f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"[3]\"><i class=\"dashicons dashicons-arrow-left-alt\"></i></label><input id=\""+g+"[3]\" class=\"kt-block-config-input-number-array\" name=\""+g+"[3]\" data-array-key=\""+g+"\" type=\"number\" step=\""+a.options.step+"\" max=\""+a.options.max+"\" min=\""+a.options.min+"\" value=\""+(b?b[3]:"")+"\"></div>",f+="</div>";break;case"color":f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"\">"+a.name+"</label><input class=\"kt-block-config-input kt-init-color\" id=\""+g+"\" name=\""+g+"\" type=\"text\" value=\""+b+"\"></div>";break;case"array":for(const d in f+="<div class=\"kt-modal-settings-array\"><h4>"+a.name+"</h4>",a.options){if(!a.options.hasOwnProperty(d))continue;const e=kt_blocks_params.blockConfigSettings[c][g].options[d];switch(e.type){case"number":f+="<div class=\"kt-modal-settings-field\"><label for=\""+d+"\">"+e.name+"</label><input id=\""+d+"\" class=\"kt-block-config-input-array\" data-array-key=\""+g+"\" name=\""+d+"\" type=\"number\" step=\""+e.options.step+"\" max=\""+e.options.max+"\" min=\""+e.options.min+"\" value=\""+b[0][d]+"\"></div>";break;case"color":f+="<div class=\"kt-modal-settings-field\"><label for=\""+d+"\">"+e.name+"</label><input class=\"kt-block-config-input-array kt-init-color\" data-array-key=\""+g+"\" id=\""+d+"\" name=\""+d+"\" type=\"text\" value=\""+b[0][d]+"\"></div>";break;default:f+="<div class=\"kt-modal-settings-field\"><label for=\""+d+"\">"+e.name+"</label><input class=\"kt-block-config-input-array\" data-array-key=\""+g+"\" id=\""+d+"\" name=\""+d+"\" type=\"text\" value=\""+b[0][d]+"\"></div>";}}f+="</div>";break;default:f+="<div class=\"kt-modal-settings-field\"><label for=\""+g+"\">"+a.name+"</label><input class=\"kt-block-config-input\" id=\""+g+"\" name=\""+g+"\" type=\"text\" value=\""+b+"\"></div>";}}else f+="<div class=\"kt-modal-settings-content\">No Settings, Yet. Try again Soon!</div>";const h=a.extend({dialogClass:"wp-dialog",resizable:!1,height:"auto",modal:!0,width:400,buttons:[{text:kt_blocks_params.texts.close,click:function(){a(this).dialog("close")}},{text:kt_blocks_params.texts.save,class:"button  button-primary kt-modal-save-button",click:function(b){function d(a){g.addClass("updating-message").removeClass("button-disabled").text(a)}function e(a){g.removeClass("updating-message").addClass("button-disabled").text(a)}function f(a){g.removeClass("updating-message").addClass("button-disabled").text(a),setTimeout(function(){location.reload()},500)}const g=a(b.currentTarget);if(g.hasClass("updating-message")||g.hasClass("button-disabled"))return;const h={};h[c]={},a("#js-settings-modal-content .kt-block-config-input").each(function(){const b=a(this).attr("name");let d=a(this).val().trim();"checkbox"===a(this).attr("type")&&(this.checked?d=!0:d=!1),""!==d&&(h[c][b]=d)}),a("#js-settings-modal-content .kt-block-config-input-array").each(function(){const b=a(this).attr("name"),d=a(this).attr("data-array-key");let e=a(this).val().trim();"checkbox"===a(this).attr("type")&&(this.checked?e=!0:e=!1),""!==e&&(h[c][d]===void 0?(h[c][d]={},h[c][d][0]={},h[c][d][0][b]=e):h[c][d][0][b]=e)}),a("#js-settings-modal-content .kt-modal-settings-number-array").each(function(){var b=[];const d=a(this).attr("data-array-key");a(this).find(".kt-block-config-input-number-array").each(function(){const c=a(this).val().trim();""!==c&&b.push(c)}),Array.isArray(b)&&b.length&&4===b.length&&(h[c][d]===void 0?(h[c][d]={},h[c][d]=b):h[c][d]=b)}),function(){d(kt_blocks_params.texts.updating),jQuery.ajax({type:"POST",url:kt_blocks_params.ajaxurl,data:{action:"kadence_blocks_save_config",wpnonce:kt_blocks_params.wpnonce,kt_block:c,config:h},success:function(){f(kt_blocks_params.texts.updated)},error:function(a,b,c){console.log(c),e("Error")}})}()}}]});e.prop("title",kt_blocks_params.texts.config+" "+d),e.html("<p class=\"kt-modal-item-title\">"+d+" "+kt_blocks_params.texts.settings+"</p>"+f),e.dialog(h),a(".kt-init-color").wpColorPicker()})}),function(a){"use strict";a(function(){a(".kt_block_button").on("click",function(b){function c(a){"undefined"!=typeof a.success&&a.success?g.hasClass("kt-block-active")?f(g.data("deactivated-label")):f(g.data("activated-label")):e("Error")}function d(a){g.addClass("updating-message").removeClass("button-disabled").text(a)}function e(a){g.removeClass("updating-message").addClass("button-disabled").text(a)}function f(a){g.hasClass("kt-block-active")?(g.removeClass("updating-message kt-block-active").addClass("button-disabled").text(a),g.closest(".kt_plugin_box").addClass("kt-block-inactive").removeClass("kt-block-active"),setTimeout(function(){g.addClass("kt-block-inactive").removeClass("button-disabled").text(g.data("inactive-label"))},2e3)):(g.removeClass("updating-message kt-block-inactive").addClass("button-disabled").text(a),g.closest(".kt_plugin_box").addClass("kt-block-active").removeClass("kt-block-inactive"),setTimeout(function(){g.addClass("kt-block-active").removeClass("button-disabled").text(g.data("active-label"))},2e3))}const g=a(b.target);b.preventDefault();g.hasClass("updating-message")||g.hasClass("button-disabled")||function(){g.hasClass("kt-block-active")?d(g.data("deactivating-label")):d(g.data("activating-label")),jQuery.post(kt_blocks_params.ajaxurl,{action:"kadence_blocks_activate_deactivate",wpnonce:kt_blocks_params.wpnonce,kt_block:g.data("block-slug")},c)}()})})}(jQuery,window,document);