PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
← All changes | assets/js/admin/admin.min.js +1 -1 1.72.3.2 View file →
@@ -1 +1 @@
1 -"use strict";!function(d,c,o){var s={};d(o).ready(function(){var e=d(".merchant-module-page-ajax-form"),a=d(".merchant-module-page-ajax-header");d(".merchant-module-save-button");d(".merchant-module-page-content").on("change keypress change.merchant",":input:not(.merchant-module-question-answer-textarea):not(.merchant-license-code-input)",function(){s.show_save||(a.addClass("merchant-show"),a.removeClass("merchant-saving"),s.show_save=!0)}),e.ajaxForm({beforeSubmit:function(){a.addClass("merchant-saving")},success:function(){var t;a.removeClass("merchant-show"),s.show_save=!1,d(".merchant-module-action").hasClass("merchant-enabled")||((t=d(".merchant-module-alert")).addClass("merchant-show"),d(o).off("click.merchant-alert-close"),d(o).on("click.merchant-alert-close",function(e){d(e.target).closest(".merchant-module-alert-wrapper").length||(t.removeClass("merchant-show"),d(o).off("click.merchant-alert-close"))}))}}),d(".merchant-module-question-answer-button").on("click",function(e){e.preventDefault();var e=d(this),t=d(".merchant-module-question-answer-textarea");d(".merchant-module-question-answer-dropdown").removeClass("merchant-show"),d(".merchant-module-question-thank-you-dropdown").addClass("merchant-show"),c.wp.ajax.post("merchant_module_feedback",{subject:t.data("subject"),message:t.val(),module:e.closest(".merchant-module-action").find(".merchant-module-page-button-action-activate").data("module"),nonce:c.merchant.nonce})}),d(".merchant-module-page-button-action-activate").on("click",function(e){e.preventDefault(),d(".merchant-module-question-list-dropdown").removeClass("merchant-show"),d(".merchant-module-question-answer-dropdown").removeClass("merchant-show"),d(".merchant-module-question-answer-form").removeClass("merchant-show"),d(".merchant-module-question-answer-title").removeClass("merchant-show"),d(".merchant-module-question-thank-you-dropdown").removeClass("merchant-show"),d(".merchant-module-question-answer-textarea").val(""),c.wp.ajax.post("merchant_module_activate",{module:d(this).data("module"),nonce:c.merchant.nonce}).done(function(){d("body").removeClass("merchant-module-disabled").addClass("merchant-module-enabled"),d(".merchant-module-action").addClass("merchant-enabled")})}),d(".merchant-module-page-button-action-deactivate").on("click",function(e){e.preventDefault(),c.wp.ajax.post("merchant_module_deactivate",{module:d(this).data("module"),nonce:c.merchant.nonce}).done(function(){d("body").removeClass("merchant-module-enabled").addClass("merchant-module-disabled"),d(".merchant-module-action").removeClass("merchant-enabled"),d(".merchant-module-question-list-dropdown").addClass("merchant-show")})}),d(".merchant-module-question-list-dropdown li").on("click",function(e){var t=d(this),a=t.data("answer-target"),a=d('[data-answer-title="'+a+'"]');a.length?(a.addClass("merchant-show").siblings().removeClass("merchant-show"),d(".merchant-module-question-answer-dropdown").addClass("merchant-show"),d(".merchant-module-question-answer-textarea").attr("data-subject",t.text().trim())):(d(".merchant-module-question-thank-you-dropdown").addClass("merchant-show"),d(".merchant-module-question-answer-dropdown").removeClass("merchant-show")),d(".merchant-module-question-answer-textarea").val(""),d(".merchant-module-question-list-dropdown").removeClass("merchant-show")}),d(".merchant-module-dropdown-close").on("click",function(e){e.preventDefault(),d(this).closest(".merchant-module-dropdown").removeClass("merchant-show")}),d(".merchant-module-page-button-deactivate").on("click",function(e){e.preventDefault();d(this);var t=d(".merchant-module-deactivate-dropdown");t.toggleClass("merchant-show"),d(o).off("click.merchant-close"),d(o).on("click.merchant-close",function(e){d(e.target).closest(".merchant-module-deactivate").length||(t.removeClass("merchant-show"),d(o).off("click.merchant-close"))})}),d(".merchant-range").each(function(){var e=d(this),n=e.find(".merchant-range-input"),i=e.find(".merchant-range-number-input");n.on("change input merchant.range merchant-init.range",function(e){var t=d(this),e=("merchant"===e.type?i:t).val()||0,a=t.attr("min")||0,a=(e-a)/((t.attr("max")||1)-a)*100;t.css({background:"linear-gradient(to right, #3858E9 0%, #3858E9 "+a+"%, #ddd "+a+"%, #ddd 100%)"}),n.val(e),i.val(e)}).trigger("merchant-init.range"),i.on("change input blur",function(){n.hasClass("merchant-range-input")&&n.val(d(this).val()).trigger("merchant.range")})}),{init:function(e){this.events()},events:function(){var a=this;d(".merchant-sortable").each(function(){var e=d(this),t=e.find(".merchant-sortable-input");d(e.find("ul.merchant-sortable-list").first()).sortable({update:function(){t.val(a.sortableGetNewVal(e)).trigger("change.merchant")}}).disableSelection().find("li").each(function(){d(this).find("i.visibility").click(function(){d(this).toggleClass("dashicons-visibility-faint").parents("li:eq(0)").toggleClass("invisible")})}).click(function(){d(event.target).hasClass("dashicons-visibility")&&t.val(a.sortableGetNewVal(e)).trigger("change.merchant")})})},sortableGetNewVal:function(e){var e=d(e.find("li")),t=[];return _.each(e,function(e){d(e).hasClass("invisible")||t.push(d(e).data("value"))}),JSON.stringify(t)}}.init(),{init:function(e){var n=this;d(".merchant-sortable-repeater-control").each(function(){var e=JSON.parse(d(this).find(".merchant-sortable-repeater-input").val()),t=e.length;if(0<t&&(d(this).find(".repeater-input").val(e[0]),1<t))for(var a=1;a<t;++a)n.appendRow(d(this),e[a]);d(this).hasClass("disable-sorting")||d(this).find(".merchant-sortable-repeater.sortable").sortable({update:function(e,t){n.getAllInputs(d(this).parent())}})}),this.events()},events:function(){var t=this;d(".merchant-sortable-repeater.sortable").on("click",".customize-control-sortable-repeater-delete",function(e){e.preventDefault(),1<d(this).parent().parent().find(".repeater").length?d(this).parent().slideUp("fast",function(){var e=d(this).parent().parent();d(this).remove(),t.getAllInputs(e)}):t.getAllInputs(d(this).parent().parent().parent())}),d(".customize-control-sortable-repeater-add").click(function(e){e.preventDefault(),t.appendRow(d(this).parent()),t.getAllInputs(d(this).parent())}),d(".merchant-sortable-repeater.sortable").change(function(){t.getAllInputs(d(this).parent())}),d(".merchant-sortable-repeater.sortable").on("focusout",".repeater-input",function(){t.getAllInputs(d(this).parent())})},appendRow:function(e){var t='<div class="repeater" style="display:none"><input type="text" value="'+(1<arguments.length&&void 0!==arguments[1]?arguments[1]:"")+'" class="repeater-input" /><span class="dashicons dashicons-menu"></span><a class="customize-control-sortable-repeater-delete" href="#"><span class="dashicons dashicons-no-alt"></span></a></div>';e.find(".sortable").append(t),e.find(".sortable").find(".repeater:last").slideDown("slow",function(){d(this).find("input").focus()})},getAllInputs:function(e){var t=e.find(".repeater-input").map(function(){return d(this).val()}).toArray();e.find(".merchant-sortable-repeater-input").val(JSON.stringify(t)),e.find(".merchant-sortable-repeater-input").trigger("change")}}.init(),{init:function(e){var n=this;d(".merchant-flexible-content-control").each(function(){var a=d(this).find(".merchant-flexible-content");a.sortable({axis:"y",cursor:"move",helper:"original",handle:".customize-control-flexible-content-move",stop:function(e,t){a.trigger("merchant.sorted"),n.refreshNumbers(a)}})}),this.events()},events:function(){var a=this;d(".customize-control-flexible-content-add-button").click(function(e){e.preventDefault(),e.stopImmediatePropagation(),d(this).parent().find(".customize-control-flexible-content-add-list").toggleClass("active")}),d(".customize-control-flexible-content-add").click(function(e){e.preventDefault(),e.stopImmediatePropagation();var e=d(".merchant-flexible-content-control[data-id="+d(this).data("id")+"]"),t=e.find(".layouts"),a=d(this).data("layout"),t=t.find(".layout[data-type="+a+"]").clone(!0),a=e.find(".merchant-flexible-content"),n=a.find(".layout");t.find("input, select").each(function(){d(this).data("name")&&d(this).attr("name",d(this).data("name").replace("0",n.length))}),t.find(".layout-count").text(n.length+1),a.append(t),a.removeClass("empty"),d(this).parent().removeClass("active"),t.find(".merchant-module-page-setting-field-upload").length&&i(t.find(".merchant-module-page-setting-field-upload")),t.find(".merchant-module-page-setting-field-select_ajax").length&&r(t.find(".merchant-module-page-setting-field-select_ajax")),d(o).trigger("merchant-flexible-content-added",[t])}),d(".customize-control-flexible-content-delete").click(function(e){e.preventDefault();var e=d(this).closest(".layout"),t=e.parent();e.remove(),0===t.find(".layout").length&&t.addClass("empty"),a.refreshNumbers(t),d(o).trigger("merchant-flexible-content-deleted",[e])})},refreshNumbers:function(e){e.find(".layout").each(function(e){var t=d(this).find(".layout-count").text(),a=parseInt(t)-1;d(this).find(".layout-count").text(e+1),d(this).find("input, select").each(function(){d(this).attr("name")&&d(this).attr("name",d(this).attr("name").replace("["+a+"]","[*refreshed*"+e+"]"))})}),e.find(".layout").each(function(e){d(this).find("input, select").each(function(){d(this).attr("name",d(this).attr("name").replace("*refreshed*",""))})}),e.parent().find("input").trigger("change.merchant")}}.init(),d(o).on("merchant-admin-check-fields merchant-flexible-content-added",function(){d(".merchant-module-page-setting-field").each(function(){var e=d(this);if(e.data("condition")&&e.data("condition").length){var t=e.data("condition"),a=d(this).closest(".layout-body").find('input[name*="'+t[0]+'"],select[name*="'+t[0]+'"]');if((a=a.length?a:d('input[name="merchant['+t[0]+']"],select[name="merchant['+t[0]+']"]')).length){var n=!1;switch(t[1]){case"==":"radio"!==a.attr("type")&&"checkbox"!==a.attr("type")||a.is(":checked")&&a.val()==t[2]&&(n=!0),a.is("select")&&a.val()==t[2]&&(n=!0);break;case"any":"radio"!==a.attr("type")&&"checkbox"!==a.attr("type")||a.is(":checked")&&t[2].split("|").includes(a.val())&&(n=!0),a.is("select")&&t[2].split("|").includes(a.val())&&(n=!0)}n?e.removeClass("merchant-hide").addClass("merchant-show"):e.removeClass("merchant-show").addClass("merchant-hide")}}})}).trigger("merchant.change"),d(o).on("change",".merchant-module-page-setting-field",function(){d(o).trigger("merchant-admin-check-fields")}).trigger("merchant.change"),d(o).trigger("merchant-admin-check-fields"),d(o).on("merchant-admin-check-color-fields merchant-flexible-content-added",function(){d(".merchant-color").each(function(){var a,e=d(this),n=e.find(".merchant-color-picker"),i=e.find(".merchant-color-input"),r=!1;n.off("click").on("click",function(e){e.preventDefault(),e.stopPropagation();var t=d("body,html");t.addClass("merchant-height-auto"),r?a.setColor(i.val()):((a=new Pickr({el:n.get(0),container:"body",theme:"merchant",appClass:"merchant-pcr-app",default:i.val()||n.data("default-color")||"#212121",swatches:["#000000","#F44336","#E91E63","#673AB7","#03A9F4","#8BC34A","#FFEB3B","#FFC107","#FFFFFF"],sliders:"h",useAsButton:!0,components:{hue:!0,preview:!0,opacity:!0,interaction:{input:!0,clear:!0}},i18n:{"btn:clear":"Default"}})).on("change",function(e){e=(1===e.a?(a.setColorRepresentation("HEX"),e.toHEXA()):(a.setColorRepresentation("RGBA"),e.toRGBA())).toString(0);n.css({"background-color":e}),i.val()!==e&&i.val(e).trigger("change.merchant")}),a.on("clear",function(){var e=n.data("default-color");e?a.setColor(e):(n.css({"background-color":"white"}),i.val(""))}),a.on("hide",function(){t.removeClass("merchant-height-auto")}),n.data("pickr",a),setTimeout(function(){a.show()},200),r=!0)}),i.on("change keyup",function(){var e=d(this).val();n.css({"background-color":e})})})}),d(o).trigger("merchant-admin-check-color-fields");({init:function(){this.events()},events:function(){var l=this;d(o).on("click",".merchant-create-page-control-button",function(e){e.preventDefault();var t=d(this),a=t.parent().find(".merchant-create-page-control-create-message"),n=t.parent().find(".merchant-create-page-control-success-message"),e=(t.text(),t.data("creating-text")),i=(t.data("created-text"),t.data("page-title")),r=t.data("page-meta-key"),o=t.data("page-meta-value"),c=t.data("option-name"),s=t.data("nonce");if(!i)return!1;d(this).text(e),d(this).attr("disabled",!0),d.ajax({type:"post",url:ajaxurl,data:{action:"merchant_create_page_control",page_title:i,page_meta_key:r,page_meta_value:o,option_name:c,nonce:s},success:function(e){l.ajaxResponseHandler(e,t,n,a)}})})},ajaxResponseHandler:function(e,t,a,n){"success"===e.status&&(e=a.find("a").attr("href").replace("?post=&","?post="+e.page_id+"&"),a.find("a").attr("href",e),a.css("display","block"),n.remove(),t.remove())}}).init(),d(".merchant-module-page-setting-field-gallery").each(function(){var n,i=d(this),e=i.find(".merchant-gallery-button"),r=i.find(".merchant-gallery-input"),o=i.find(".merchant-gallery-images"),t=i.find(".merchant-gallery-remove");o.sortable({helper:"original",update:function(e,t){var a=[];o.find(".merchant-gallery-image").each(function(){a.push(d(this).data("item-id"))}),r.val(a.join(",")).trigger("change")}});t.on("click",function(e){e.preventDefault(),d(this).parent().remove();var t=[];o.find(".merchant-gallery-image").each(function(){t.push(d(this).data("item-id"))}),r.val(t.join(",")).trigger("change")}),e.on("click",function(e){d(this);var t=r.val(),a=t?"edit":"add";e.preventDefault(),void 0!==c.wp&&c.wp.media&&c.wp.media.gallery&&("add"==a?(n=c.wp.media({library:{type:"image"},frame:"post",state:"gallery",multiple:!0})).open():n=c.wp.media.gallery.edit('[gallery ids="'+t+'"]'),n.on("update",function(e){o.empty();e=e.models.map(function(e){var e=e.toJSON(),t=(e.sizes&&e.sizes.thumbnail&&e.sizes.thumbnail.url?e.sizes.thumbnail:e).url;return o.append('<div class="merchant-gallery-image" data-item-id="'+e.id+'"><i class="merchant-gallery-remove dashicons dashicons-no-alt"></i><img src="'+t+'" /></div>'),e.id});r.val(e.join(",")).trigger("change"),i.find(".merchant-gallery-remove").on("click",function(e){e.preventDefault(),d(this).parent().remove();var t=[];o.find(".merchant-gallery-image").each(function(){t.push(d(this).data("item-id"))}),r.val(t.join(",")).trigger("change")})}))})});var i=function(e){var a,n=e,e=n.find(".merchant-upload-button"),i=n.find(".merchant-upload-input"),r=n.find(".merchant-upload-wrapper");n.find(".merchant-upload-remove").on("click",function(e){e.preventDefault(),d(this).parent().remove(),i.val("").trigger("change")}),e.on("click",function(e){e.preventDefault(),void 0!==c.wp&&c.wp.media&&((a=a||c.wp.media({library:{type:"image"}})).open(),a.on("select",function(){r.empty();var e=a.state().get("selection").first().attributes,t=(e.sizes&&e.sizes.thumbnail&&e.sizes.thumbnail.url?e.sizes.thumbnail:e).url;r.append('<div class="merchant-upload-image"><i class="merchant-upload-remove dashicons dashicons-no-alt"></i><img src="'+t+'" /></div>'),i.val(e.id).trigger("change"),n.find(".merchant-upload-remove").on("click",function(e){e.preventDefault(),d(this).parent().remove(),i.val("").trigger("change")})}))})},r=(d(".merchant-module-page-setting-field-upload:not(.template)").each(function(){i(d(this))}),function(e){var t=e.find("select"),a=t.data("source"),n=c.merchant_admin_options,i={width:"100%"};"post"!==a&&"product"!==a||(i.minimumInputLength=1,i.ajax={url:n.ajaxurl,dataType:"json",delay:250,cache:!0,data:function(e){return{action:"merchant_admin_options_select_ajax",nonce:n.ajaxnonce,term:e.term,source:a}},processResults:function(e,t){return e.success?{results:e.data}:{}}}),t.select2(i),e.find(".select2-selection--multiple").append('<span class="merchant-select2-clear"></span>')}),n=(d(".merchant-module-page-setting-field-select_ajax:not(.template)").each(function(){r(d(this))}),d(".merchant-module-page-settings-responsive").each(function(){var e=d(this),a=e.find(".merchant-module-page-settings-devices button"),n=e.find(".merchant-module-page-settings-device-container");a.on("click",function(e){e.preventDefault();var t=d(this).data("device");a.removeClass("active"),n.removeClass("active"),d(this).addClass("active"),n.each(function(){d(this).data("device")===t&&d(this).addClass("active")})})}),d(".merchant-animated-buttons").each(function(){var e,t,a=d(this).find("label"),n=d(".merchant-animation-demo");a.on("click",function(){n.removeClass("merchant-animation-"+e),n.removeClass("merchant-animation-"+t),e=d(this).find("input").attr("value"),setTimeout(function(){n.addClass("merchant-animation-"+e)},100),setTimeout(function(){n.removeClass("merchant-animation-"+e)},1e3)}),a.mouseover(function(){n.removeClass("merchant-animation-"+e),t=d(this).find("input").attr("value"),n.addClass("merchant-animation-"+t)}).mouseout(function(){n.removeClass("merchant-animation-"+t)})}),d(".merchant-notifications-sidebar")),e=(n.length&&(d(".merchant-notifications").on("click",function(e){e.preventDefault();var t=d(this),e=n.find(".merchant-notification:first-child .merchant-notification-date").data("raw-date");n.toggleClass("opened"),t.hasClass("read")||d.post(c.merchant.ajax_url,{action:"merchant_notifications_read",nonce:c.merchant.nonce,latest_notification_date:e},function(e){e.success&&setTimeout(function(){t.addClass("read")},2e3)})}),d(c).on("scroll",function(){60<c.pageYOffset&&(n.addClass("closing"),setTimeout(function(){n.removeClass("opened"),n.removeClass("closing")},300))}),d(".merchant-notifications-sidebar-close").on("click",function(e){e.preventDefault(),n.addClass("closing"),setTimeout(function(){n.removeClass("opened"),n.removeClass("closing")},300)})),d(".merchant-tabs-nav")),t=(e.length&&e.each(function(){var a=d(this).data("tab-wrapper-id");d(this).find(".merchant-tabs-nav-link").on("click",function(e){e.preventDefault();var e=d(this).closest(".merchant-tabs-nav").find(".merchant-tabs-nav-link"),t=d(this).data("tab-to"),e=(e.each(function(){d(this).closest(".merchant-tabs-nav-item").removeClass("active")}),d(this).closest(".merchant-tabs-nav-item").addClass("active"),d('.merchant-tab-content-wrapper[data-tab-wrapper-id="'+a+'"]'));e.find("> .merchant-tab-content").removeClass("active"),e.find('> .merchant-tab-content[data-tab-content-id="'+t+'"]').addClass("active")})}),d(".merchant-module-alert"));t.length&&t.find(".merchant-module-alert-close").on("click",function(e){e.preventDefault(),t.removeClass("merchant-show"),d(o).off("click.merchant-alert-close")})})}(jQuery,window,document);
1 +function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var a;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(a="Object"===(a={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:a)||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}function _iterableToArrayLimit(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,i,r,o,c=[],s=!0,l=!1;try{if(r=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;s=!1}else for(;!(s=(n=r.call(a)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){l=!0,i=e}finally{try{if(!s&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(l)throw i}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}((w,x,k,C)=>{var S={},j=new URLSearchParams(x.location.search),O=j.get("module");function A(e){return"string"==typeof e&&!isNaN(e)&&!isNaN(parseFloat(e))}w(k).ready(function(){var e=w(".merchant-module-page-ajax-form"),a=w(".merchant-module-page-ajax-header"),n=(w(".merchant-module-save-button"),w(".merchant-module-page-content").on("change keypress change.merchant",function(e){w(e.target).hasClass("merchant-backup-file")||w(e.target).hasClass("merchant-search-field")||w(e.target).closest(".merchant-module-page-preview").length||(w(e.target).is(".merchant-module-question-answer-textarea, .merchant-license-code-input")||S.show_save||(a.addClass("merchant-show"),a.removeClass("merchant-saving"),S.show_save=!0),d.initFlag())}),x.addEventListener("beforeunload",function(e){S.show_save&&e.preventDefault()}),e.ajaxForm({beforeSubmit:function(t){a.addClass("merchant-saving");var h={},u=[],e=(t.forEach(function(e,t){if("merchant-search-field"===e.name)u.push(t);else if(e.name&&0===e.name.indexOf("merchant[")){var a=e.name.match(/\[([^\]]*)\]/g);if(a){for(var n=h,i=0;i<a.length-1;i++){var r,o=a[i].slice(1,-1);n[o]===C&&(r=a[i+1]?a[i+1].slice(1,-1):"",n[o]=/^\d+$/.test(r)?[]:{}),n=n[o]}var c=a[a.length-1].slice(1,-1);if(""===c){for(var s=a[a.length-2].slice(1,-1),l=h,d=0;d<a.length-2;d++)l=l[a[d].slice(1,-1)];Array.isArray(l[s])||(l[s]=[]),l[s].push(e.value)}else n[c]=e.value}}else u.push(t)}),w(".merchant-flexible-content .layout:not([data-deferred])").each(function(){w(this).find('.layout-body input[type="checkbox"]:not(:checked)').each(function(){var e=w(this).attr("name")||"";if(0===e.indexOf("merchant[")&&!/\[\]$/.test(e)){var t=e.match(/\[([^\]]*)\]/g);if(t){for(var a=h,n=0;n<t.length-1;n++){var i=t[n].slice(1,-1);a[i]===C&&(a[i]={}),a=a[i]}e=t[t.length-1].slice(1,-1);a[e]===C&&(a[e]=0)}}})}),w('.merchant-flexible-content .layout[data-deferred="1"]').each(function(){var e=w(this).attr("data-fields-json");if(e){try{a=JSON.parse(e)}catch(e){return}var e=w(this).closest(".merchant-flexible-content-control").attr("data-id"),t=parseInt(w(this).find(".layout-count").text(),10)-1,a=(h[e]||(h[e]={}),w.extend({},a.values||{}));a.layout=w(this).attr("data-type")||"",a.flexible_id=w(this).find(".flexible-id").val()||"",h[e][t]=a}}),u.map(function(e){return t[e]}));e.push({name:"merchant_json_payload",value:JSON.stringify(h)}),t.length=0,e.forEach(function(e){t.push(e)})},success:function(){var t;a.removeClass("merchant-show"),S.show_save=!1,w(".merchant-module-action").hasClass("merchant-enabled")||((t=w(".merchant-module-alert")).addClass("merchant-show"),w(k).off("click.merchant-alert-close"),w(k).on("click.merchant-alert-close",function(e){w(e.target).closest(".merchant-module-alert-wrapper").length||(t.removeClass("merchant-show"),w(k).off("click.merchant-alert-close"))})),w(k).trigger("save.merchant",[O])}}),w(".merchant-module-question-answer-button")),i=w(".merchant-module-question-answer-textarea");function l(){var e=w(k).find(".merchant-range");0!==e.length&&e.each(function(){var e=w(this),n=e.find(".merchant-range-input"),i=e.find(".merchant-range-number-input");n.on("change input merchant.range merchant-init.range",function(e){var t=w(this),e=("merchant"===e.type?i:t).val()||0,a=t.attr("min")||0,a=(e-a)/((t.attr("max")||1)-a)*100;w("body").hasClass("rtl")?t.css({background:"linear-gradient(to left, #3858E9 0%, #3858E9 "+a+"%, #ddd "+a+"%, #ddd 100%)"}):t.css({background:"linear-gradient(to right, #3858E9 0%, #3858E9 "+a+"%, #ddd "+a+"%, #ddd 100%)"}),n.val(e),i.val(e)}).trigger("merchant-init.range"),i.on("change input blur",function(){n.hasClass("merchant-range-input")&&n.val(w(this).val()).trigger("merchant.range")})})}i.on("input",function(){n.prop("disabled",""===w(this).val().trim())}),n.on("click",function(e){e.preventDefault();var t,e=i.val();e.trim()?(t=w(this),w(".merchant-module-question-answer-dropdown").removeClass("merchant-show"),w(".merchant-module-question-thank-you-dropdown").addClass("merchant-show"),x.wp.ajax.post("merchant_module_feedback",{subject:i.attr("data-subject"),message:e,module:t.closest(".merchant-module-action").find(".merchant-module-page-button-action-activate").data("module"),nonce:x.merchant.nonce})):alert("Please provide the required information.")}),w(".merchant-module-page-button-action-activate").on("click",function(e){if(e.preventDefault(),w(this).hasClass("merchant-module-deactivated-by-bp"))return!1;w(".merchant-module-question-list-dropdown").removeClass("merchant-show"),w(".merchant-module-question-answer-dropdown").removeClass("merchant-show"),w(".merchant-module-question-answer-form").removeClass("merchant-show"),w(".merchant-module-question-answer-title").removeClass("merchant-show"),w(".merchant-module-question-thank-you-dropdown").removeClass("merchant-show"),w(".merchant-module-question-answer-textarea").val(""),x.wp.ajax.post("merchant_module_activate",{module:w(this).data("module"),nonce:x.merchant.nonce}).done(function(){w("body").removeClass("merchant-module-disabled").addClass("merchant-module-enabled"),w(".merchant-module-action").addClass("merchant-enabled")})}),w(".merchant-module-page-button-action-deactivate").on("click",function(e){e.preventDefault(),x.wp.ajax.post("merchant_module_deactivate",{module:w(this).data("module"),nonce:x.merchant.nonce}).done(function(){w("body").removeClass("merchant-module-enabled").addClass("merchant-module-disabled"),w(".merchant-module-action").removeClass("merchant-enabled"),w(".merchant-module-question-list-dropdown").addClass("merchant-show")})}),w(".merchant-module-question-list-dropdown li").on("click",function(e){n.prop("disabled",""===i.val().trim());var t=w(this),a=t.data("answer-target"),a=w('[data-answer-title="'+a+'"]');a.length?(a.addClass("merchant-show").siblings().removeClass("merchant-show"),w(".merchant-module-question-answer-dropdown").addClass("merchant-show"),w(".merchant-module-question-answer-textarea").attr("data-subject",t.text().trim())):(w(".merchant-module-question-thank-you-dropdown").addClass("merchant-show"),w(".merchant-module-question-answer-dropdown").removeClass("merchant-show")),w(".merchant-module-question-answer-textarea").val(""),w(".merchant-module-question-list-dropdown").removeClass("merchant-show")}),w(".merchant-module-dropdown-close").on("click",function(e){e.preventDefault(),w(this).closest(".merchant-module-dropdown").removeClass("merchant-show")}),w(".merchant-module-page-button-deactivate").on("click",function(e){e.preventDefault();w(this);var t=w(".merchant-module-deactivate-dropdown");t.toggleClass("merchant-show"),w(k).off("click.merchant-close"),w(k).on("click.merchant-close",function(e){w(e.target).closest(".merchant-module-deactivate").length||(t.removeClass("merchant-show"),w(k).off("click.merchant-close"))})}),l(),w(k).on("click",".merchant-module-page-setting-field-hidden-desc-trigger",function(){var e=w(this),t=(e.toggleClass("expanded"),e.attr("data-show-text")),a=e.attr("data-hidden-text");w(this).find("span:first").text(e.text()===t?a:t),w(this).closest(".merchant-module-page-setting-field").find(".merchant-module-page-setting-field-hidden-desc").stop(!0,!0).slideToggle("fast")});({init:function(){this.events()},events:function(){var t=this,e=(w(k).on("click","#download-backup-button",this.download.bind(this)),w(k).on("click",".merchant-dropzone__browse",function(e){e.preventDefault(),e.stopPropagation(),w(this).closest(".merchant-dropzone").find(".merchant-backup-file").trigger("click")}),w(k).on("change","#merchant-backup-file",function(){var e=this.files[0];e&&t.restoreFile(e)}),w("#merchant-restore-dropzone"));e.on("dragover dragenter",function(e){e.preventDefault(),e.stopPropagation(),w(this).addClass("drag-over")}),e.on("dragleave drop",function(e){e.preventDefault(),e.stopPropagation(),w(this).removeClass("drag-over")}),e.on("drop",function(e){e=e.originalEvent.dataTransfer.files[0];e&&t.restoreFile(e)})},download:function(e){var n=this,i=(e.preventDefault(),w(".merchant-module-page-setting-fields .backup-section")),r=i.find(".merchant-backup-status"),o=(r.removeAttr("class").addClass("merchant-backup-status").text(""),w(e.target).attr("data-module-id"));w.ajax({url:merchant_admin_options.ajaxurl,type:"GET",data:{action:"merchant_get_module_settings",nonce:merchant_admin_options.ajaxnonce,module_id:o},beforeSend:function(){n.showLoadingIndicator(i)},success:function(e){var t,a;n.hideLoadingIndicator(i),e.success?(t=e.data,a="merchant-"+o+"-backup-"+(new Date).toISOString().slice(0,10)+"-"+(new Date).getHours()+"-"+(new Date).getMinutes()+"-"+(new Date).getSeconds()+".json",n.downloadJson(t,a),r.addClass("is-success").text(merchant_admin_options.backup_success||"Downloaded!")):r.addClass("is-error").text(e.data.message),setTimeout(function(){r.removeAttr("class").addClass("merchant-backup-status").text("")},3e3)},error:function(e,t,a){n.hideLoadingIndicator(i),r.addClass("is-error").text(a),setTimeout(function(){r.removeAttr("class").addClass("merchant-backup-status").text("")},3e3)}})},restoreFile:function(e){var t,n=this,a=w(".merchant-module-page-setting-fields .restore-section"),i=w("#merchant-restore-dropzone").data("module-id");n.hideError(),e&&"application/json"===e.type?((t=new FileReader).onload=function(e){e=e.target.result;w.ajax({url:merchant_admin_options.ajaxurl,type:"POST",data:{action:"merchant_restore_module_settings",nonce:merchant_admin_options.ajaxnonce,module_id:i,module_settings:e},beforeSend:function(){w("#merchant-restore-dropzone").addClass("is-loading"),n.showLoadingIndicator(a)},success:function(e){e.success?(S.show_save=!1,w("#merchant-restore-dropzone").removeClass("is-loading").addClass("is-success"),n.hideLoadingIndicator(a),setTimeout(function(){x.location.href=e.data.redirect_url},1500)):n.displayError(e.data.message)},error:function(e,t,a){n.displayError(a)}})},t.readAsText(e)):n.displayError(merchant_admin_options.invalid_file)},downloadJson:function(e,t){"object"===_typeof(e)&&(e=JSON.stringify(e));var e=new Blob([e],{type:"application/json"}),e=URL.createObjectURL(e),a=k.createElement("a");a.href=e,a.download=t,a.click(),URL.revokeObjectURL(e)},displayError:function(e){var t=w("#merchant-restore-dropzone");t.find(".merchant-dropzone__error p").text(e),t.removeClass("is-loading").addClass("is-error"),this.hideLoadingIndicator(w(".merchant-module-page-setting-fields .restore-section")),setTimeout(function(){t.removeClass("is-error"),t.find(".merchant-backup-file").val("")},3e3)},hideError:function(){w("#merchant-restore-dropzone").removeClass("is-error")},showLoadingIndicator:function(e){e.find(".merchant-loading-spinner").addClass("show")},hideLoadingIndicator:function(e){e.find(".merchant-loading-spinner").removeClass("show")}}).init();e={init:function(e){this.events()},events:function(){w(k).on("click",".merchant-flexible-content .merchant-toggle-switch .toggle-switch-label span",function(){var e=w(this).closest(".merchant-toggle-switch").find(".toggle-switch-checkbox");e.prop("checked",!e.prop("checked"))}).trigger("merchant.change")}};({init:function(){this.initiate_datepicker(),this.events()},parseInitialDate:function(e,t){var a;return e?t.onlyTimepicker&&/^\d{1,2}:\d{2}$/.test(e)?(a=(t=_slicedToArray(e.split(":"),2))[0],t=t[1],[new Date((new Date).setHours(Number(a),Number(t),0,0))]):(a=new Date(e),isNaN(a)?[]:[a]):[]},initiate_datepicker:function(){var t=this,e=w(".merchant-module-page-setting-field .merchant-datetime-field");0!==e.length&&e.each(function(a){var n=w(this).find("input"),e=w(this).data("options")||{},i={locale:JSON.parse(merchant_datepicker_locale),selectedDates:t.parseInitialDate(n.val(),e),onSelect:function(e){e.date;var t=e.formattedDate;void 0===t&&(e.datepicker.$el.value=""),n.trigger("change.merchant"),n.trigger("change.merchant-datepicker",[t,n,i,a])}},e=(e.buttons=["clear"],e.minDate!==C&&"today"===e.minDate&&(e.minDate=new Date,e.timeZone!==C)&&""!==e.timeZone&&(e.minDate=new Date(e.minDate.toLocaleString("en-US",{timeZone:e.timeZone}))),i=Object.assign(i,e),new AirDatepicker(n.getPath(),i));n.attr("readonly",!0),w(k).trigger("initiated.merchant-datepicker",[e,n,i,a])})},events:function(){var e=this;w(k).on("merchant-flexible-content-added",function(){e.initiate_datepicker()})}}).init();({init:function(e){this.events()},events:function(){var a=this;w(".merchant-sortable").each(function(){var e=w(this),t=e.find(".merchant-sortable-input");w(e.find("ul.merchant-sortable-list").first()).sortable({update:function(){t.val(a.sortableGetNewVal(e)).trigger("change.merchant")}}).disableSelection().find("li").each(function(){w(this).find("i.visibility").click(function(){w(this).toggleClass("dashicons-visibility-faint").parents("li:eq(0)").toggleClass("invisible")})}).click(function(){w(event.target).hasClass("dashicons-visibility")&&t.val(a.sortableGetNewVal(e)).trigger("change.merchant")})})},sortableGetNewVal:function(e){var e=w(e.find("li")),t=[];return _.each(e,function(e){w(e).hasClass("invisible")||t.push(w(e).data("value"))}),JSON.stringify(t)}}).init(),e.init(),w(k).on("merchant-flexible-content-added",function(e,t){t=t.find(".merchant-sortable-repeater-control").find(".merchant-sortable-repeater.sortable");o.makeFieldsSortable(t)});var r,o={init:function(e){var n=this;w(".merchant-sortable-repeater-control").each(function(){var e=JSON.parse(w(this).find(".merchant-sortable-repeater-input").val()),t=e.length;if(0<t&&(w(this).find(".repeater-input").val(e[0]),1<t))for(var a=1;a<t;++a)n.appendRow(w(this),e[a])}),this.events()},events:function(){var t=this;w(k).on("click",".merchant-sortable-repeater.sortable .customize-control-sortable-repeater-delete",function(e){e.preventDefault(),w(this).parent().slideUp("fast",function(){var e=w(this).parent().parent();w(this).remove(),t.getAllInputs(e)}),w(k).trigger("merchant-sortable-repeater-item-deleted")}),w(k).on("click",".customize-control-sortable-repeater-add",function(e){e.preventDefault(),t.appendRow(w(this).parent()),t.getAllInputs(w(this).parent())}),w(k).on("change",".merchant-sortable-repeater.sortable",function(){t.getAllInputs(w(this).parent())}),w(k).on("focusout",".merchant-sortable-repeater.sortable .repeater-input",function(){t.getAllInputs(w(this).parent())})},appendRow:function(e){var t='<div class="repeater" style="display:none"><input type="text" value="'+(1<arguments.length&&arguments[1]!==C?arguments[1]:"")+'" class="repeater-input" /><span class="dashicons dashicons-menu"></span><a class="customize-control-sortable-repeater-delete" href="#"><span class="dashicons dashicons-no-alt"></span></a></div>',t=(e.find(".sortable").append(t),e.find(".sortable").find(".repeater:last"));t.slideDown("slow",function(){w(this).find("input").focus()}),this.makeFieldsSortable(e.find(".sortable")),w(k).trigger("merchant-sortable-repeater-item-added",[t,e.find(".sortable")])},makeFieldsSortable:function(a){a.hasClass("disable-sorting")||a.sortable({update:function(e,t){o.getAllInputs(a.parent())}})},getAllInputs:function(e){var t=e.find(".repeater-input").map(function(){return w(this).val()}).toArray();t.length||t.push(""),e.find(".merchant-sortable-repeater-input").val(JSON.stringify(t)),e.find(".merchant-sortable-repeater-input").trigger("change"),e.find(".merchant-sortable-repeater-input").trigger("sortable.repeater.change")}},c=(o.init(),{CONTROL:".merchant-sortable-repeater-icons-control",init:function(){var e=this;w(e.CONTROL).each(function(){e.populate(w(this))}),this.events()},populate:function(e){var t=[];try{t=JSON.parse(e.find(".merchant-sortable-repeater-input").val())}catch(e){t=[]}if(Array.isArray(t)&&0!==t.length){var a=e.find(".repeater").first(),n=this.normalizeItem(t[0]);a.find(".repeater-input").val(n.text),this.setRowIcon(a,n.icon);for(var i=1;i<t.length;i++){var r=this.normalizeItem(t[i]);this.appendRow(e,r.text,r.icon,!0)}}},events:function(){var a=this;w(k).on("click",a.CONTROL+" .merchant-icon-picker-toggle",function(e){e.preventDefault(),e.stopPropagation();e=w(this).siblings(".merchant-icon-picker-dropdown");w(a.CONTROL+" .merchant-icon-picker-dropdown").not(e).hide(),e.toggle()}),w(k).on("click",a.CONTROL+" .merchant-icon-option",function(e){e.preventDefault(),e.stopPropagation();var e=w(this).closest(".repeater"),t=w(this).data("icon")||"";a.setRowIcon(e,t),w(this).closest(".merchant-icon-picker-dropdown").hide(),a.syncHiddenInput(w(this).closest(a.CONTROL))}),w(k).on("click",function(){w(c.CONTROL+" .merchant-icon-picker-dropdown").hide()}),w(k).on("click",a.CONTROL+" .merchant-icon-picker-dropdown",function(e){e.stopPropagation()}),w(k).on("click",a.CONTROL+" .merchant-sortable-repeater-icons.sortable .customize-control-sortable-repeater-delete",function(e){e.preventDefault();var t=w(this).closest(a.CONTROL);w(this).parent().slideUp("fast",function(){w(this).remove(),a.syncHiddenInput(t)}),w(k).trigger("merchant-sortable-repeater-item-deleted")}),w(k).on("click",a.CONTROL+" .customize-control-sortable-repeater-icons-add",function(e){e.preventDefault();e=w(this).closest(a.CONTROL);a.appendRow(e,"",""),a.syncHiddenInput(e)}),w(k).on("focusout",a.CONTROL+" .merchant-sortable-repeater-icons.sortable .repeater-input",function(){a.syncHiddenInput(w(this).closest(a.CONTROL))}),w(k).on("change",a.CONTROL+" .merchant-sortable-repeater-icons.sortable",function(){a.syncHiddenInput(w(this).closest(a.CONTROL))}),w(k).on("merchant-flexible-content-added",function(e,t){t=t.find(a.CONTROL);t.length&&(a.populate(t),a.makeFieldsSortable(t.find(".sortable")))})},appendRow:function(e,t,a,n){var i=this.getIconLibrary(e),r='<div class="merchant-icon-picker-dropdown" style="display:none;">',t=(r+='<button type="button" class="merchant-icon-option" data-icon="" title="Use campaign icon"><span class="dashicons dashicons-no-alt"></span></button>',Object.keys(i).forEach(function(e){r+='<button type="button" class="merchant-icon-option" data-icon="'+e+'" title="'+e+'">'+i[e]+"</button>"}),r+="</div>",w("<div>").text(t).html()),t=w('<div class="repeater" style="display:none"><button type="button" class="merchant-icon-picker-toggle" data-icon="" title="Select icon"><span class="dashicons dashicons-plus-alt2"></span></button>'+r+'<input type="text" value="'+t+'" class="repeater-input" /><span class="dashicons dashicons-menu"></span><a class="customize-control-sortable-repeater-delete" href="#"><span class="dashicons dashicons-no-alt"></span></a></div>');e.find(".sortable").append(t),n?t.show():t.slideDown("slow",function(){w(this).find("input").focus()}),a&&this.setRowIcon(t,a),this.makeFieldsSortable(e.find(".sortable")),w(k).trigger("merchant-sortable-repeater-item-added",[t,e.find(".sortable")])},setRowIcon:function(e,t){var a,n=e.find(".merchant-icon-picker-toggle");n.attr("data-icon",t),t&&(a=e.closest(c.CONTROL),a=this.getIconLibrary(a)[t]||"")?n.html(a).addClass("has-icon"):n.html('<span class="dashicons dashicons-plus-alt2"></span>').removeClass("has-icon"),e.find(".merchant-icon-option").removeClass("selected"),e.find('.merchant-icon-option[data-icon="'+t+'"]').addClass("selected")},syncHiddenInput:function(e){var a=[];e.find(".merchant-sortable-repeater-icons .repeater").each(function(){var e=w(this).find(".repeater-input").val(),t=w(this).find(".merchant-icon-picker-toggle").attr("data-icon")||"";a.push({text:e,icon:t})}),a.length||a.push({text:"",icon:""}),e.find(".merchant-sortable-repeater-input").val(JSON.stringify(a)),e.find(".merchant-sortable-repeater-input").trigger("change"),e.find(".merchant-sortable-repeater-input").trigger("sortable.repeater.change")},makeFieldsSortable:function(e){var t=this;e.hasClass("disable-sorting")||e.sortable({handle:".dashicons-menu",update:function(){t.syncHiddenInput(e.closest(t.CONTROL))}})},getIconLibrary:function(t){if(!t.data("_iconLibrary"))try{t.data("_iconLibrary",JSON.parse(t.attr("data-icons"))||{})}catch(e){t.data("_iconLibrary",{})}return t.data("_iconLibrary")},normalizeItem:function(e){return"string"==typeof e?{text:e,icon:""}:{text:e.text||"",icon:e.icon||""}}}),d=(c.init(),{init:function(){this.initAccordion(),this.initFlag()},initAccordion:function(){w(".merchant-group-field.has-accordion").each(function(){var e=w(this);e.accordion({collapsible:!0,header:"> .title-area",heightStyle:"content",active:!!e.hasClass("open")&&0})})},initFlag:function(){w(".merchant-group-field.has-flag").each(function(){var e=w(this),t=e.data("id"),t=e.find(".merchant-field-".concat(t,"_status select")),a=t.val(),t=t.find("option:selected").text();e.find(".field-status").removeClass("hidden active inactive").text(t).addClass(a)})}}),e={accordion:null,activePopupContainer:null,init:function(){this.initAccordion(),this.events(),this.makeSelectedReviewsSortable(w(".merchant-reviews-selector").not(".layouts .merchant-reviews-selector"))},events:function(){var a=this;w(k).on("input",".merchant-reviews-selector .products-search",a.ajaxSearch.bind(a)),w(k).on("change",'.merchant-reviews-selector .product-review input[type="checkbox"]',a.toggleReview.bind(a)),w(k).on("click",".merchant-reviews-selector .review-photo img",a.requestReviewImages.bind(a)),w(k).on("click",".review-photos-popup .overlay",a.dismissImagesGallery.bind(a)),w(k).on("click",".merchant-reviews-selector .product-reviews-load-more button",a.loadMoreReviews.bind(a)),w(k).on("click",".merchant-reviews-selector .popup-trigger",a.initPopUp.bind(a)),w(k).on("click",".merchant-reviews-selector .popup-header .close, .merchant-reviews-selector > .overlay",a.dismissPopUp.bind(a)),w(k).on("click",".merchant-reviews-selector .product-review-delete",a.deleteSelectedReview.bind(a)),w(k).on("keyup",function(e){"Escape"!==e.key||a.dismissImagesGallery()||a.dismissPopUp(a)}),w(k).on("merchant-flexible-content-added",function(e,t){a.makeSelectedReviewsSortable(),a.initAccordion()})},makeSelectedReviewsSortable:function(){var e=0<arguments.length&&arguments[0]!==C?arguments[0]:w(k).find(".merchant-reviews-selector").not(".layouts .merchant-reviews-selector"),a=this;e.find(".selected-reviews .product-reviews").sortable({axis:"y",cursor:"move",helper:"original",handle:".product-review-move",cancel:"",placeholder:"placeholder",update:function(e,t){t=t.item.closest(".merchant-reviews-selector");a.saveModifications(t)},start:function(e,t){t.placeholder.height(t.item.height())}})},deleteSelectedReview:function(e){var e=w(e.target).closest(".product-review"),t=e.closest(".merchant-reviews-selector");e.remove(),this.saveModifications(t),this.updateSelectedReviewsCheckboxState(t),this.countSelectedReviewsInProduct(t)},ajaxSearch:function(e){var t=this,e=w(e.target),a=e.closest(".merchant-reviews-selector"),n=a.find(".popup-header");(0===e.val().length||3<=e.val().length)&&w.ajax({url:merchant_admin_options.ajaxurl,type:"POST",data:{action:"merchant_search_reviews",search:e.val(),nonce:merchant_admin_options.ajaxnonce},beforeSend:function(){n.addClass("loading"),t.destroyAccordion(a)},success:function(e){e.success?(n.removeClass("popup-error"),a.find(".products-search-results").html(e.data),t.initAccordion(a)):n.addClass("popup-error")},complete:function(){n.removeClass("loading")},error:function(){n.addClass("popup-error")}})},loadMoreReviews:function(e){var t=this,a=w(e.target).closest(".product-item"),e=a.find(".product-review").length;w.ajax({url:merchant_admin_options.ajaxurl,type:"POST",data:{action:"merchant_load_more_reviews",product_id:a.attr("data-id"),offset:e,nonce:merchant_admin_options.ajaxnonce},beforeSend:function(){a.addClass("loading")},success:function(e){e.success&&(a.find(".product-reviews .reviews-wrapper").append(e.data.reviews),""===e.data.load_more&&t.hideLoadMoreButton(a),t.updateSelectedReviewsCheckboxState(a.closest(".merchant-reviews-selector")),t.countSelectedReviewsInProduct(a.closest(".merchant-reviews-selector")))},complete:function(){a.removeClass("loading")}})},hideLoadMoreButton:function(e){e.find(".product-reviews-load-more").remove()},initPopUp:function(e){var e=w(e.target).closest(".merchant-reviews-selector"),t=e.find(".selector-popup"),a=e.find(".overlay");t.addClass("active"),a.addClass("active"),this.activePopupContainer=e},dismissPopUp:function(){var e,t=this.activePopupContainer;null!==t&&(e=t.find(".selector-popup"),t=t.find(".overlay"),e.removeClass("active"),t.removeClass("active"),this.activePopupContainer=null)},initAccordion:function(){var e=0<arguments.length&&arguments[0]!==C?arguments[0]:w(k).find(".merchant-reviews-selector"),t=this;e.each(function(){var a=w(this).find(".popup-content .product-item.product-item-has-reviews");a.each(function(){a.accordion({collapsible:!0,heightStyle:"content",icons:!1,active:!!a.hasClass("opened")&&0,activate:function(e,t){t.newPanel.length?t.newPanel.parent().addClass("opened"):a.removeClass("opened")}})}),a.find("a").on("click",function(e){e.stopPropagation()}),t.updateSelectedReviewsCheckboxState(w(this)),t.countSelectedReviewsInProduct(w(this))})},destroyAccordion:function(e){e.find(".selector-popup .product-item.product-item-has-reviews").each(function(){w(this).hasClass("ui-accordion")&&w(this).accordion("destroy")})},toggleReview:function(e){var t=this,a=w(e.target).prop("checked"),n=w(e.target).closest(".merchant-reviews-selector"),e=w(e.target).closest(".product-review"),i=e.attr("data-id"),r=n.find(".selected-reviews .product-reviews"),i=r.find('.product-review[data-id="'.concat(i,'"]'));a?0===i.length&&(a=e.clone(),r.append(a),t.makeSelectedReviewsSortable()):i.remove(),setTimeout(function(){t.saveModifications(n)},150)},saveModifications:function(e){var t=e.find(".review-saved-ids"),a=e.find(".selected-reviews .product-reviews").find(".product-review"),n=[];a.each(function(){var e=w(this).attr("data-id");n.push(e)}),t.val(n.join(",")),t.trigger("change"),this.updateSelectedReviewsCheckboxState(e),this.countSelectedReviewsInProduct(e)},updateSelectedReviewsCheckboxState:function(a){var e=a.find(".selector-popup"),t=a.find(".review-saved-ids"),e=e.find(".product-review"),n=t.val().split(",");e.each(function(){var e=w(this).attr("data-id"),t=a.find('.product-review[data-id="'.concat(e,'"] input[type="checkbox"]'));n.includes(e)?t.prop("checked",!0):t.prop("checked",!1)})},countSelectedReviewsInProduct:function(e){var t=e.find(".selector-popup .product-item"),a=e.find(".review-saved-ids").val().split(",");t.each(function(){var t=0,e=w(this);e.find(".product-review").each(function(){var e=w(this).attr("data-id");a.includes(e)&&t++}),e.find(".selected-reviews-count .counter").text(t)})},requestReviewImages:function(e){var t=w(e.target).closest(".product-review"),a=w(e.target),e=t.attr("data-id");w.ajax({url:merchant_admin_options.ajaxurl,type:"POST",data:{action:"merchant_get_review_images",review_id:e,nonce:merchant_admin_options.ajaxnonce},beforeSend:function(){a.addClass("loading")},success:function(e){e.success&&(w("body").append(e.data),setTimeout(function(){w("body").find(".review-photos-popup").addClass("active")},300))},complete:function(){a.removeClass("loading")}})},dismissImagesGallery:function(){var e=w("body").find(".review-photos-popup");return!!e.length&&(e.removeClass("active"),setTimeout(function(){e.remove()},300),!0)}};({init:function(e){var i=this;w(".merchant-flexible-content-control").each(function(){var e=w(this).hasClass("has-accordion"),a=w(this).find(".merchant-flexible-content"),t=j.get("campaign_id"),n=0;t&&a.find("input.flexible-id").each(function(e){if(w(this).val()===t)return n=e,!1}),e?a.accordion({active:n,collapsible:!0,header:function(e){return e.find(".layout__inner > .layout-header")},heightStyle:"content",beforeActivate:function(e,t){e.originalEvent&&w(e.originalEvent.target).hasClass("layout-status")?e.preventDefault():t.newPanel.length&&"1"===(e=t.newPanel.closest(".layout")).attr("data-deferred")&&i.hydrateLayout(e)}}).sortable({axis:"y",cursor:"move",helper:"original",handle:".customize-control-flexible-content-move",stop:function(e,t){a.trigger("merchant.sorted"),i.refreshNumbers(a),a.accordion("refresh")}}):a.sortable({axis:"y",cursor:"move",helper:"original",handle:".customize-control-flexible-content-move",stop:function(e,t){a.trigger("merchant.sorted"),i.refreshNumbers(a),a.accordion("refresh")}})}),this.updateLayoutTitle(),this.updateLayoutStatus(),this.updateDiscountPercentMaxVal(),this.events()},updateLayoutTitle:function(){w(".merchant-flexible-content .layout").each(function(){var e,t=w(this).find(".layout-title[data-title-field]");t.length&&((e=w(this).find(".layout-body .merchant-field-"+t.data("title-field")+" input")).on("change keyup",function(){t.text(w(this).val())}),t.text(e.val()))})},resolveStatusField:function(e,t){var a,n,i,r=e.find(".layout-body .merchant-field-"+t);return r.length?(a=r.find("select"),n=r.find('input[type="radio"]'),i=r.find('input[type="checkbox"]'),a.length?{getValue:function(){return a.val()||"active"},getLabel:function(){return a.find("option:selected").text()||this.getValue()},getOptions:function(){return a.find("option").map(function(){return w(this).val()}).get()},setNext:function(){var e=a.find("option"),t=(e.index(e.filter(":selected"))+1)%e.length;a.val(e.eq(t).val()).trigger("change")},onChange:function(e){a.off("change.statusBadge").on("change.statusBadge",e)}}:n.length?{getValue:function(){return n.filter(":checked").val()||"active"},getLabel:function(){var e=n.filter(":checked"),e=r.find('label[for="'+e.attr("id")+'"]');return e.length?e.text():this.getValue()},getOptions:function(){return n.map(function(){return w(this).val()}).get()},setNext:function(){var e=this.getOptions(),t=(e.indexOf(this.getValue())+1)%e.length;n.filter('[value="'+e[t]+'"]').prop("checked",!0).trigger("change")},onChange:function(e){n.off("change.statusBadge").on("change.statusBadge",e)}}:i.length?{getValue:function(){return i.is(":checked")?"active":"inactive"},getLabel:function(){return i.is(":checked")?"Active":"Inactive"},getOptions:function(){return["active","inactive"]},setNext:function(){i.prop("checked",!i.is(":checked")).trigger("change")},onChange:function(e){i.off("change.statusBadge").on("change.statusBadge",e)}}:null):null},updateLayoutStatus:function(){var c=this;w(".merchant-flexible-content .layout").each(function(){var e,a,n=w(this).find(".layout-header .layout-status[data-status-field]");function t(){var e=a.getValue(),t=a.getLabel();n.removeClass(function(e,t){return(t.match(/layout-status--\S+/g)||[]).join(" ")}).addClass("layout-status--"+e).text(t.trim())}n.length&&(e=n.data("status-field"),a=c.resolveStatusField(w(this),e))&&(a.onChange(t),t())}),w(k).off("click.statusToggle").on("click.statusToggle",".layout-status[data-status-field]",function(e){e.stopPropagation(),e.preventDefault();var e=w(this),t=e.data("status-field"),a=e.closest(".layout"),n=c.resolveStatusField(a,t);if(n)n.setNext();else{var n=e.attr("data-status-options"),n=n?n.split(","):["active","inactive"],i=(i=e.attr("class").match(/layout-status--(\S+)/))?i[1]:n[0],r=n.indexOf(i),r=n[(r+1)%n.length],n=r.charAt(0).toUpperCase()+r.slice(1),e=(e.removeClass("layout-status--"+i).addClass("layout-status--"+r).text(n),a.attr("data-fields-json"));if(e)try{var o=JSON.parse(e);o.values||(o.values={}),o.values[t]=r,a.attr("data-fields-json",JSON.stringify(o))}catch(e){}w(".merchant-module-page-content").trigger("change.merchant")}})},updateDiscountPercentMaxVal:function(){w(".merchant-flexible-content .layout").each(function(){var e=w(this),t=e.find('.merchant-module-page-setting-field[data-id="discount_type"]'),a=e.find('.merchant-module-page-setting-field[data-id="discount_value"]'),e=(a=(a=a.length?a:e.find('.merchant-module-page-setting-field[data-id="discount"]')).length?a:e.find('.merchant-module-page-setting-field[data-id="discount_amount"]'),t.find("input:checked").val());"percentage_discount"===e||"percentage"===e?a.find("input").attr("max",100):a.find("input").removeAttr("max")}),w(".merchant-module-page-setting-fields")},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},events:function(){var o=this;function a(e){e&&e.length&&e.siblings().find(".layout-actions__inner").slideUp(300)}w(k).on("change",'.merchant-module-page-setting-field[data-id="discount_type"] input',function(){o.updateDiscountPercentMaxVal()}),w(k).on("change","select",function(){var t=w(this).val(),a=w(this).prop("multiple");w(this).find("option").each(function(){var e=w(this).val(),e=a?t.includes(e):e===t;w(this).attr("selected",e)})}),w(".customize-control-flexible-content-add-button").on("click",function(e){e.preventDefault(),e.stopImmediatePropagation(),1===w(this).parent().find(".customize-control-flexible-content-add-list a").length?w(this).parent().find(".customize-control-flexible-content-add-list a").trigger("click"):w(this).parent().find(".customize-control-flexible-content-add-list").toggleClass("active")}),w(k).on("click",".customize-control-flexible-content-add",function(e){e.preventDefault(),e.stopImmediatePropagation();var e=w(".merchant-flexible-content-control[data-id="+w(this).data("id")+"]"),t=e.find(".layouts"),a=w(this).data("layout"),t=t.find(".layout[data-type="+a+"]").clone(!0),a=e.find(".merchant-flexible-content"),n=a.find(".layout"),e=o.generateUUID(),e=(t.find("input, select, textarea").each(function(){w(this).data("name")&&w(this).attr("name",w(this).data("name").replace("0",n.length)),w(this).is(":checkbox, :radio")&&w(this).attr("checked")&&w(this).prop("checked",!0)}),t.attr("data-layout-id",e),t.find(".layout-count").text(n.length+1),t.find(".flexible-id").val(e),a.append(t),a.removeClass("empty"),w(this).parent().removeClass("active"),t.find(".merchant-module-page-setting-field-upload").length&&m(t.find(".merchant-module-page-setting-field-upload")),t.find(".merchant-module-page-setting-field-select_ajax").length&&f(t.find(".merchant-module-page-setting-field-select_ajax")),w(this).closest(".merchant-flexible-content-control"));e.hasClass("has-accordion")&&(e.find(".merchant-flexible-content").accordion("refresh"),e.find(".merchant-flexible-content").accordion("option","active",-1)),d.init(),w(k).trigger("merchant-flexible-content-added",[t]),l(),o.updateLayoutTitle(),o.updateLayoutStatus(),o.updateDiscountPercentMaxVal(),w(".merchant-module-page-content").trigger("change.merchant")}),w(k).on("click",".customize-control-flexible-content-duplicate",function(e){e.preventDefault(),e.stopImmediatePropagation();var t,n,a,e=w(this),i=e.closest(".merchant-flexible-content-control[data-id="+e.data("id")+"]"),r=null==i?void 0:i.find(".merchant-flexible-content");i.length&&r.length&&(e=e.closest(".layout")).length&&(e.find(".layout-actions__inner").hide(),t=e.clone(),r.find(".layout"),n=e.find(".layout-count").text(),a=o.generateUUID(),t.attr("data-layout-id",a),t.find(".flexible-id").val(a),t.find("input, select, textarea").each(function(){var e,t=w(this),a=t.attr("name");a&&(e=a.split("[")[0],a=a.match(/\[(.*?)\]/g))&&1<a.length&&(a[1]="["+n+"]",e="".concat(e).concat(a.join("")),t.attr("name",e))}),t.find("select").each(function(){w(this).hasClass("select2-hidden-accessible")&&(w(this).removeClass("select2-hidden-accessible").removeAttr("data-live-search").removeAttr("data-select2-id").removeAttr("aria-hidden").removeAttr("tabindex"),w(this).nextAll(".select2-container").remove(),w(this).select2())}),t.find(".layout-body").removeAttr("style"),t.hide(),t.insertAfter(e),t.fadeIn(),t.find(".merchant-module-page-setting-field-upload").length&&m(t.find(".merchant-module-page-setting-field-upload")),t.find(".merchant-module-page-setting-field-select_ajax").length&&f(t.find(".merchant-module-page-setting-field-select_ajax")),o.refreshNumbers(r),w(k).trigger("merchant-flexible-content-added",[t]),i.hasClass("has-accordion")&&r.accordion("refresh"),o.updateLayoutTitle(),o.updateLayoutStatus(),d.init(),w(".merchant-module-page-content").trigger("change.merchant"))}),w(k).on("click",".customize-control-flexible-content-delete",function(e){e.preventDefault();var e=w(this).closest(".layout"),t=e.parent(),t=(e.remove(),0===t.find(".layout").length&&t.addClass("empty"),o.refreshNumbers(t),w(k).trigger("merchant-flexible-content-deleted",[e]),w(this).closest(".merchant-flexible-content-control"));t.hasClass("has-accordion")&&t.find(".merchant-flexible-content").accordion("refresh"),w(".merchant-module-page-content").trigger("change.merchant")}),w(k).on("click",".layout-actions__toggle",function(e){e.preventDefault(),a(w(this).closest(".layout")),w(this).closest(".layout-actions").find(".layout-actions__inner").stop().slideToggle(300)}),w(k).on("click",".layout-header",function(){a(w(this).closest(".layout"))}),w(k).on("merchant-flexible-content-added",function(e,t){a(t)}),w(k).on("click",function(e){w(e.target).closest(".layout-actions").length||w(".layout-actions__inner").slideUp(300)}),w(k).on("keydown",function(e){"Escape"===e.key&&w(".layout-actions__inner").slideUp(300)})},hydrateLayout:function(e){var t=e.attr("data-fields-json");if(t){try{o=JSON.parse(t)}catch(e){return}var a,n,i,r,o,c,t=e.attr("data-type"),s=e.closest(".merchant-flexible-content-control"),t=s.find('.layouts .layout[data-type="'+t+'"]');t.length&&(t=t.find(".layout-body").clone(),a=parseInt(e.find(".layout-count").text(),10)-1,c=s.attr("data-id"),t.find("input, select, textarea").each(function(){var e=w(this).attr("data-name");e&&(w(this).attr("name",e.replace("[0]","["+a+"]")),w(this).removeAttr("data-name"))}),this.populateFieldValues(t,o,c,a),t.find(".merchant-color").each(function(){var e=w(this).find(".merchant-color-input").val();e&&w(this).find(".merchant-color-picker").css("background-color",e)}),t.find(".merchant-range").each(function(){var e=w(this).find(".merchant-range-number-input").val();e!==C&&""!==e&&w(this).find(".merchant-range-input").val(e)}),(o=e.find(".layout-body")).empty().append(t.children()),o.find(".merchant-module-page-setting-field-upload").length&&m(o.find(".merchant-module-page-setting-field-upload")),o.find(".merchant-module-page-setting-field-select_ajax").length&&f(o.find(".merchant-module-page-setting-field-select_ajax")),w(k).trigger("merchant-flexible-content-added",[e]),d.init(),l(),(n=e.find(".layout-title[data-title-field]")).length&&(c=n.attr("data-title-field"),e.find(".layout-body .merchant-field-"+c+" input").on("change keyup",function(){n.text(w(this).val())})),(i=e.find(".layout-header .layout-status[data-status-field]")).length&&(t=i.data("status-field"),r=this.resolveStatusField(e,t))&&(r.onChange(o=function(){var e=r.getValue(),t=r.getLabel();i.removeClass(function(e,t){return(t.match(/layout-status--\S+/g)||[]).join(" ")}).addClass("layout-status--"+e).text(t.trim())}),o()),this.updateDiscountPercentMaxVal(),e.removeAttr("data-deferred"),e.removeAttr("data-fields-json"),(c=s.find(".merchant-flexible-content")).data("ui-accordion")&&c.accordion("refresh"),w(k).trigger("merchant-admin-check-fields"),w(k).trigger("merchant-admin-check-color-fields"))}},populateFieldValues:function(c,e,a,n){function i(e,n){w.each(e,function(e,t){var a;"object"!==_typeof(t)||null===t||Array.isArray(t)?Array.isArray(t)?c.find('[name="'+n+"["+e+'][]"]').each(function(){w(this).is(":checkbox")&&w(this).prop("checked",-1!==t.indexOf(w(this).val()))}):(a=c.find('[name="'+n+"["+e+']"]')).length&&(a.is(":checkbox")&&!a.is(":radio")?a.prop("checked",!!parseInt(t,10)):a.is(":radio")?a.prop("checked",a.val()===String(t)):a.val(t)):i(t,n+"["+e+"]")})}var r=e.values||{},t=e.select_options||{},o=e.product_options||{},e=e.review_options||{};c.find("input, select, textarea").each(function(){var e=w(this),t=e.attr("name")||"",a=t.match(/\[([^\]]+)\]\[\]$/);a?(a=a[1],a=r[a],Array.isArray(a)&&e.is(":checkbox")&&e.prop("checked",-1!==a.indexOf(e.val()))):(a=t.match(/\[([^\]]+)\]$/))&&(t=a[1],(a=r[t])!==C)&&null!==a&&(e.is(":checkbox")&&!e.is(":radio")?e.prop("checked",!!parseInt(a,10)):e.is(":radio")?e.prop("checked",e.val()===String(a)):e.is("select")?e.val(a):e.val("object"===_typeof(a)&&null!==a?JSON.stringify(a):a))}),w.each(t,function(e,t){var a=c.find('[data-id="'+e+'"] select');a.length&&(a.empty(),w.each(t,function(e,t){a.append(w("<option>").val(t.id).text(t.text).prop("selected",!0))}))}),w.each(o,function(e,t){var r,o,e=c.find('[data-id="'+e+'"] .merchant-products-search-container');e.length&&(r=e.find(".merchant-selected-products-preview ul"),o=[],r.empty(),w.each(t,function(e,t){o.push(t.id);var a,n,i=w("<li>").addClass("product-item").attr("data-id",t.id).attr("data-name",t.title);t.image&&i.append(w("<span>").addClass("img").append(w("<img>").attr("src",t.image).attr("alt",t.title).attr("width",30).attr("height",30))),i.append(w("<span>").addClass("data").append(w("<span>").addClass("name").text(t.title),w("<span>").addClass("info").html(t.price))),(t.type||t.id)&&(a=(t.type||"")+"<br>#"+t.id,n=w("<span>").addClass("type"),t.edit_url?n.append(w("<a>").attr("href",t.edit_url).attr("target","_blank").html(a)):n.html(a),i.append(n)),i.append(w("<span>").addClass("remove hint--left").attr("aria-label","Remove").html("&times;")),r.append(i)}),e.find(".merchant-selected-products").val(o.join(",")))}),w.each(e,function(e,t){var n,i,e=c.find('[data-id="'+e+'"] .merchant-reviews-selector');e.length&&(n=e.find(".selected-reviews .product-reviews"),i=[],n.empty(),w.each(t,function(e,t){i.push(t.id);var a=w("<div>").addClass("product-review").attr("data-review-id",t.id);a.append(w("<span>").addClass("review-author").text(t.author)),a.append(w("<span>").addClass("review-content").text(t.content)),a.append(w("<span>").addClass("review-rating").text("★".repeat(parseInt(t.rating)||0))),a.append(w("<span>").addClass("review-product").text(t.product_name)),a.append(w("<span>").addClass("product-review-delete").html("&times;")),a.append(w("<span>").addClass("product-review-move").html("⋮⋮")),n.append(a)}),e.find(".merchant-selected-reviews").val(i.join(",")))});w.each(r,function(e,t){"object"!==_typeof(t)||null===t||Array.isArray(t)||i(t,"merchant["+a+"]["+n+"]["+e+"]")})},refreshNumbers:function(e){e.find(".layout").each(function(e){var t=w(this).find(".layout-count").text(),a=parseInt(t)-1;w(this).find(".layout-count").text(e+1),w(this).find("input, select, textarea").each(function(){w(this).attr("name")&&w(this).attr("name",w(this).attr("name").replace("["+a+"]","[*refreshed*"+e+"]"))})}),e.find(".layout").each(function(e){w(this).find("input, select, textarea").each(function(){var e=w(this).attr("name");e&&w(this).attr("name",e.replace("*refreshed*",""))})}),e.parent().find("input").trigger("change.merchant")}}).init(),d.init(),e.init(),w(k).on("keyup",".merchant-module-page-setting-field-products_selector .merchant-search-field",function(){clearTimeout(r);var e,t,a,n=[],i=(!w(this).closest('[data-id="excluded_products"]').length||"categories"!==(t=(e=w(this).closest(".layout")).find(".merchant-field-rules_to_apply select").val()||e.find(".merchant-field-rules_to_display select").val()||e.find(".merchant-field-display_rules select").val())&&"by_category"!==t||(n=e.find(".merchant-field-category_slugs select").val()||e.find(".merchant-field-product_cats select").val()),w(this).closest(".merchant-products-search-container"));""!==w(this).val()?(i.find(".merchant-searching").addClass("active"),a={action:"merchant_admin_products_search",nonce:merchant_admin_options.ajaxnonce,keyword:w(this).val(),product_types:w(this).data("allowed-types"),ids:i.find(".merchant-selected-products").val(),categories:n},r=setTimeout(function(){w.post(merchant_admin_options.ajaxurl,a,function(e){var t=i.find(".merchant-selections-products-preview");t.show(),t.html(e),i.find(".merchant-searching").removeClass("active")})},250)):i.find(".merchant-selections-products-preview").html("").hide()}),w(k).on("click touch",function(e){w(e.target).closest(".merchant-products-search-container").length||(w(".merchant-selections-products-preview").html("").hide(),w(".merchant-search-field").val(""))}),w(k).on("keydown",".merchant-search-field",function(e){"Escape"===e.key&&(w(this).closest(".merchant-products-search-container").find(".merchant-selections-products-preview").html("").hide(),w(this).val("").blur())}),w(k).on("click touch",".merchant-module-page-setting-field-products_selector .merchant-selections-products-preview li",function(){var e=w(this).closest(".merchant-products-search-container"),t=e.find(".merchant-selected-products"),a=t.val(),n="multiple"===e.data("multiple");0<e.find(".merchant-selected-products-preview ul li").length&&!n&&(e.find(".merchant-selected-products-preview ul li").remove(),t.val("").change()),w(this).children(".remove").attr("aria-label","Remove").html("×"),e.find(".merchant-selected-products-preview ul").append(w(this)),e.find(".merchant-selections-products-preview").html("").hide(),e.find(".merchant-search-field").val("").change(),(""!==a&&n?((e=a.split(",")).push(w(this).data("id")),t.val(e.join(","))):t.val(w(this).data("id"))).change()}),w(k).on("click touch",".merchant-selected-products-preview .remove",function(){var e=w(this),t=e.closest(".merchant-products-search-container").find(".merchant-selected-products"),a=e.parent().data("id"),n=(e.parent().remove(),t.val().split(","));if(0<n.length)for(var i in n)parseInt(n[i])===parseInt(a)&&n.splice(i,1);t.val(n.join(",")).change(),t.trigger("change.merchant")}),w(k).on("merchant-admin-check-fields merchant-flexible-content-added",function(){w(".merchant-module-page-setting-field").each(function(){var e=w(this);if(e.data("condition")&&e.data("condition").length){var t=e.data("condition"),a=w(this).closest(".layout-body").find('input[name*="'+t[0]+'"],select[name*="'+t[0]+'"]');if((a=a.length?a:w('input[name="merchant['+t[0]+']"],select[name="merchant['+t[0]+']"]')).length){var n,i=!1;switch(t[1]){case"==":"radio"!==a.attr("type")&&"checkbox"!==a.attr("type")||(n=a.parent().find("input:checked")).length&&n.val()===t[2]&&(i=!0),a.is("select")&&a.val()==t[2]&&(i=!0);break;case"any":"radio"!==a.attr("type")&&"checkbox"!==a.attr("type")||(n=a.parent().find("input:checked")).length&&t[2].split("|").includes(n.val())&&(i=!0),a.is("select")&&t[2].split("|").includes(a.val())&&(i=!0)}i?e.removeClass("merchant-hide").addClass("merchant-show"):e.removeClass("merchant-show").addClass("merchant-hide")}}})}).trigger("merchant.change"),w(k).on("merchant-admin-check-fields merchant-flexible-content-added change keyup",function(){w(k).find(".merchant-module-page-setting-field").each(function(){var e=w(this);e.data("conditions")&&(function e(t){var a=1<arguments.length&&arguments[1]!==C&&arguments[1];var n=!1;if("relation"in t){var i=t.relation.toUpperCase();if("OR"===i)for(var r=0;r<t.terms.length;r++){var o=t.terms[r];if(n=e(o,a))return!0}else if("AND"===i){for(var c=0,s=0;s<t.terms.length;s++){var l=t.terms[s];e(l,a)&&c++}c===t.terms.length&&(n=!0)}}else{var d,i="",h=(i="terms"in t?t.terms[0]:t,w('input[name="merchant['+i.field+']"],select[name="merchant['+i.field+']"]')),u=(h.length||0<(d=a.closest(".layout-body")).length&&(h=d.find(".merchant-field-"+i.field).find("input, select")),(h=(h=h.length?h:w('input[name="merchant['+i.field+'][]"],select[name="merchant['+i.field+'][]"]')).length?h:w(".merchant-group-fields-container").find(".merchant-field-"+i.field+' input[name*="'+i.field+'"],.merchant-field-'+i.field+' select[name*="'+i.field+'"]')).val());"checkbox"===h.attr("type")&&(u=h.is(":checked")),"radio"===h.attr("type")&&(u=h.filter(":checked").val()),"checkbox"===h.attr("type")&&1<h.length&&(u=[],h.each(function(){w(this).is(":checked")&&u.push(w(this).val())})),A(u)&&(u=Number(u)),Array.isArray(i.value)&&(i.value=i.value.map(function(e){return A(e)?Number(e):e})),("==="===i.operator&&u===i.value||"!=="===i.operator&&u!==i.value||">"===i.operator&&u>i.value||"<"===i.operator&&u<i.value||">="===i.operator&&u>=i.value||"<="===i.operator&&u<=i.value||"in"===i.operator&&i.value.includes(u)||"!in"===i.operator&&!i.value.includes(u)||"contains"===i.operator&&Array.isArray(u)&&u.includes(i.value)||"!contains"===i.operator&&Array.isArray(u)&&!u.includes(i.value))&&(n=!0)}return n}(e.data("conditions"),e)?e.removeClass("merchant-hide").addClass("merchant-show"):e.removeClass("merchant-show").addClass("merchant-hide"))})}).trigger("merchant.change"),w(k).on("change",".merchant-module-page-setting-field",function(){w(k).trigger("merchant-admin-check-fields")}).trigger("merchant.change"),w(k).trigger("merchant-admin-check-fields"),w(k).on("merchant-admin-check-color-fields merchant-flexible-content-added",function(){w(".merchant-color").each(function(){var a,e=w(this),n=e.find(".merchant-color-picker"),i=e.find(".merchant-color-input"),r=!1;n.off("click").on("click",function(e){e.preventDefault(),e.stopPropagation();var t=w("body,html");t.addClass("merchant-height-auto"),r?a.setColor(i.val()):((a=new Pickr({el:n.get(0),container:"body",theme:"merchant",appClass:"merchant-pcr-app",default:i.val()||n.data("default-color")||"#212121",swatches:["#000000","#F44336","#E91E63","#673AB7","#03A9F4","#8BC34A","#FFEB3B","#FFC107","#FFFFFF"],sliders:"h",useAsButton:!0,components:{hue:!0,preview:!0,opacity:!0,interaction:{input:!0,clear:!0}},i18n:{"btn:clear":"Default"}})).on("change",function(e){e=(1===e.a?(a.setColorRepresentation("HEX"),e.toHEXA()):(a.setColorRepresentation("RGBA"),e.toRGBA())).toString(0);n.css({"background-color":e}),i.val()!==e&&i.val(e).trigger("change.merchant"),w(k).trigger("merchant-color-picker-updated",[e,i])}),a.on("clear",function(){var e=n.data("default-color");e?a.setColor(e):(n.css({"background-color":"white"}),i.val(""))}),a.on("hide",function(){t.removeClass("merchant-height-auto")}),n.data("pickr",a),setTimeout(function(){a.show()},200),r=!0)}),i.on("change keyup",function(){var e=w(this).val();n.css({"background-color":e})})})}),w(k).trigger("merchant-admin-check-color-fields");({init:function(){this.events()},events:function(){var l=this;w(k).on("click",".merchant-create-page-control-button",function(e){e.preventDefault();var t=w(this),a=t.parent().find(".merchant-create-page-control-create-message"),n=t.parent().find(".merchant-create-page-control-success-message"),e=(t.text(),t.data("creating-text")),i=(t.data("created-text"),t.data("page-title")),r=t.data("page-meta-key"),o=t.data("page-meta-value"),c=t.data("option-name"),s=t.data("nonce");if(!i)return!1;w(this).text(e),w(this).attr("disabled",!0),w.ajax({type:"post",url:ajaxurl,data:{action:"merchant_create_page_control",page_title:i,page_meta_key:r,page_meta_value:o,option_name:c,nonce:s},success:function(e){l.ajaxResponseHandler(e,t,n,a)}})})},ajaxResponseHandler:function(e,t,a,n){var i,r;"success"===e.status&&((r=(i=a.find("a").first()).attr("href"))&&i.attr("href",r.replace("?post=&","?post="+e.page_id+"&")),a.css("display","block"),n.remove(),t.remove())}}).init(),w(".merchant-module-page-setting-field-gallery").each(function(){var n,i=w(this),e=i.find(".merchant-gallery-button"),r=i.find(".merchant-gallery-input"),o=i.find(".merchant-gallery-images"),t=i.find(".merchant-gallery-remove");o.sortable({helper:"original",update:function(e,t){var a=[];o.find(".merchant-gallery-image").each(function(){a.push(w(this).data("item-id"))}),r.val(a.join(",")).trigger("change")}});t.on("click",function(e){e.preventDefault(),w(this).parent().remove();var t=[];o.find(".merchant-gallery-image").each(function(){t.push(w(this).data("item-id"))}),r.val(t.join(",")).trigger("change")}),e.on("click",function(e){w(this);var t=r.val(),a=t?"edit":"add";e.preventDefault(),void 0!==x.wp&&x.wp.media&&x.wp.media.gallery&&("add"==a?(n=x.wp.media({library:{type:"image"},frame:"post",state:"gallery",multiple:!0})).open():n=x.wp.media.gallery.edit('[gallery ids="'+t+'"]'),n.on("update",function(e){o.empty();e=e.models.map(function(e){var e=e.toJSON(),t=(e.sizes&&e.sizes.thumbnail&&e.sizes.thumbnail.url?e.sizes.thumbnail:e).url;return o.append('<div class="merchant-gallery-image" data-item-id="'+e.id+'"><i class="merchant-gallery-remove dashicons dashicons-no-alt"></i><img src="'+t+'" /></div>'),e.id});r.val(e.join(",")).trigger("change"),i.find(".merchant-gallery-remove").on("click",function(e){e.preventDefault(),w(this).parent().remove();var t=[];o.find(".merchant-gallery-image").each(function(){t.push(w(this).data("item-id"))}),r.val(t.join(",")).trigger("change")})}))})});var s,h,u,p,t,m=function(e){var n,i=e,e=i.find(".merchant-upload-button"),r=i.find(".merchant-upload-input"),o=i.find(".merchant-upload-wrapper");i.find(".merchant-upload-remove").on("click",function(e){e.preventDefault(),w(this).parent().remove(),r.val("").trigger("change")}),e.on("click",function(e){e.preventDefault(),void 0!==x.wp&&x.wp.media&&((n=n||x.wp.media({library:{type:"image"}})).open(),n.on("select",function(){o.empty();var e=n.state().get("selection").first().attributes,t=(e.sizes&&e.sizes.thumbnail&&e.sizes.thumbnail.url?e.sizes.thumbnail:e).url,a=e.sizes?JSON.stringify(e.sizes):"";o.append('<div class="merchant-upload-image" data-sizes=\''+a+'\'><i class="merchant-upload-remove dashicons dashicons-no-alt"></i><img src="'+t+'" /></div>'),r.val(e.id).trigger("change"),i.find(".merchant-upload-button-drag-drop").hide(),i.find(".merchant-upload-remove").on("click",function(e){e.preventDefault(),w(this).parent().remove(),r.val("").trigger("change"),i.find(".merchant-upload-button-drag-drop").show()})}))})},f=(w(".merchant-module-page-setting-field-upload:not(.template)").each(function(){m(w(this))}),jQuery.each(["dragenter","dragover","dragleave","drop"],function(e,t){w(k).on(t,".merchant-upload-button-drag-drop",function(e){e.preventDefault(),e.stopPropagation()})}),w(k).on("dragenter",".merchant-upload-button-drag-drop",function(e){w(this).closest(".merchant-module-page-setting-field-upload").find(".merchant-upload-button").click()}),function(e){e.each(function(){v(w(this))})}),v=function(e){var t=e.find("select"),a=t.data("source"),n=x.merchant_admin_options,i={width:"100%",templateSelection:function(e){return e.text.replace(/&nbsp;-*\s*/g,"").trim()}};"post"!==a&&"product"!==a&&"user"!==a||(i.minimumInputLength=1,i.ajax={url:n.ajaxurl,dataType:"json",delay:250,cache:!0,data:function(e){return{action:"merchant_admin_options_select_ajax",nonce:n.ajaxnonce,term:e.term,source:a}},processResults:function(e,t){return e.success?{results:e.data}:{}}}),t.select2(i),e.find(".select2-selection--multiple").append('<span class="merchant-select2-clear"></span>')},g=(w(".merchant-module-page-setting-field-select_ajax:not(.template)").each(function(){f(w(this))}),w(".merchant-module-page-settings-responsive").each(function(){var e=w(this),a=e.find(".merchant-module-page-settings-devices button"),n=e.find(".merchant-module-page-settings-device-container");a.on("click",function(e){e.preventDefault();var t=w(this).data("device");a.removeClass("active"),n.removeClass("active"),w(this).addClass("active"),n.each(function(){w(this).data("device")===t&&w(this).addClass("active")})})}),w(".merchant-animated-buttons").each(function(){var e,t,a=w(this).find("label"),n=w(".merchant-animation-demo");a.on("click",function(){n.removeClass("merchant-animation-"+e),n.removeClass("merchant-animation-"+t),e=w(this).find("input").attr("value"),setTimeout(function(){n.addClass("merchant-animation-"+e)},100),setTimeout(function(){n.removeClass("merchant-animation-"+e)},1e3)}),a.mouseover(function(){n.removeClass("merchant-animation-"+e),t=w(this).find("input").attr("value"),n.addClass("merchant-animation-"+t)}).mouseout(function(){n.removeClass("merchant-animation-"+t)})}),w(".merchant-notifications-sidebar")),e=(g.length&&(w(".merchant-notifications").on("click",function(e){e.preventDefault();var t=w(this),e=g.find(".merchant-notification:first-child .merchant-notification-date").data("raw-date");g.toggleClass("opened"),t.hasClass("read")||w.post(x.merchant.ajax_url,{action:"merchant_notifications_read",nonce:x.merchant.nonce,latest_notification_date:e},function(e){e.success&&setTimeout(function(){t.addClass("read")},2e3)})}),w(".merchant-notification-content").each(function(){var e=w(this),t=(e.find("span.changelog-fixed").each(function(){w(this).closest("li").remove()}),e.find("li")),a=e.find("li.hidden");t.length===a.length&&e.closest(".merchant-notification").remove()}),w(x).on("scroll",function(){60<x.pageYOffset&&(g.addClass("closing"),setTimeout(function(){g.removeClass("opened"),g.removeClass("closing")},300))}),w(".merchant-notifications-sidebar-close").on("click",function(e){e.preventDefault(),g.addClass("closing"),setTimeout(function(){g.removeClass("opened"),g.removeClass("closing")},300)})),w(".merchant-tabs-nav")),b=(e.length&&e.each(function(){var a=w(this).data("tab-wrapper-id");w(this).find(".merchant-tabs-nav-link").on("click",function(e){e.preventDefault();var e=w(this).closest(".merchant-tabs-nav").find(".merchant-tabs-nav-link"),t=w(this).data("tab-to"),e=(e.each(function(){w(this).closest(".merchant-tabs-nav-item").removeClass("active")}),w(this).closest(".merchant-tabs-nav-item").addClass("active"),w('.merchant-tab-content-wrapper[data-tab-wrapper-id="'+a+'"]'));e.find("> .merchant-tab-content").removeClass("active"),e.find('> .merchant-tab-content[data-tab-content-id="'+t+'"]').addClass("active")})}),w(".merchant-module-alert")),y=(b.length&&b.find(".merchant-module-alert-close").on("click",function(e){e.preventDefault(),b.removeClass("merchant-show"),w(k).off("click.merchant-alert-close")}),w("#merchant-ai-prompts-modal"));y.length&&(s=y.find(".merchant-ai-prompts-modal-list"),h=x.merchant.ai_prompt_copy_hint||"Click to copy",u=x.merchant.ai_prompt_copied_label||"Copied!",p='<svg width="14" height="14" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="5" y="5" width="8" height="8" rx="1.5" stroke="currentColor" stroke-width="1.3"/><path d="M3 10V3.5C3 2.67157 3.67157 2 4.5 2H10.5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',w(k).on("click",".merchant-ai-badge",function(e){e.preventDefault(),e.stopPropagation();e=w(this).data("aiPrompts"),y.find(".merchant-ai-prompts-modal-title-text").text(w(this).data("aiTitle")||""),y.find(".merchant-ai-prompts-modal-blurb").text(w(this).data("aiBlurb")||""),s.empty(),Array.isArray(e)&&e.forEach(function(e){var t=w('<button type="button" class="merchant-ai-prompt-row"></button>').attr("data-prompt",e);t.append(w('<span class="merchant-ai-prompt-text"></span>').text(e)),t.append(w('<span class="merchant-ai-prompt-icon"></span>').html(p)),t.attr("aria-label",h),s.append(t)}),y.addClass("merchant-show"),e=y.find(".merchant-ai-prompts-modal-badge svg");e.removeClass("merchant-ai-badge-spin"),e[0].offsetWidth,e.addClass("merchant-ai-badge-spin")}),w(k).on("keydown",".merchant-ai-badge",function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),w(this).trigger("click"))}),s.on("click",".merchant-ai-prompt-row",function(){var e,t,a=w(this);a.hasClass("is-copied")||(e=a.attr("data-prompt"),t=function(){a.addClass("is-copied").attr("aria-label",u),a.find(".merchant-ai-prompt-icon").html('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.5 4.5L6 12L2.5 8.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'),setTimeout(function(){a.removeClass("is-copied").attr("aria-label",h),a.find(".merchant-ai-prompt-icon").html(p)},1600)},navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(t):(e=w("<textarea readonly></textarea>").val(e).css({position:"fixed",top:"-1000px"}),w("body").append(e),e[0].select(),k.execCommand("copy"),e.remove(),t()))}),t=function(){y.removeClass("merchant-show"),y.find(".merchant-ai-prompts-modal-badge svg").removeClass("merchant-ai-badge-spin")},w(k).on("click",".merchant-ai-prompts-modal-close",function(){t()}),y.on("click",function(e){w(e.target).is(y)&&t()}),w(k).on("keydown",function(e){"Escape"===e.key&&y.hasClass("merchant-show")&&t()}))})})(jQuery,window,document),jQuery.fn.extend({getPath:function(){var c=[];return this.each(function(e,t){for(var a,n=jQuery(t);n.length;){var i=n.get(0);if(!(r=i.localName))break;var r=r.toLowerCase(),o=n.parent();1<o.children(r).length&&0<(e=o.children().index(i)+1)&&(r+=":nth-child("+e+")"),a=r+(a?" > "+a:""),n=o}c.push(a)}),c.join(",")}});