(()=>{var a;a=jQuery,tinymce.PluginManager.add("aawp",(function(a,n){a.addButton("aawp",{classes:"aawp-insert-button",image:aawp_classic_editor_data.icon_url,tooltip:"AAWP"})})),a((function(){function n(){var n=(0!==a("#advanced-ads-ad-parameters .display-variant-items").length?a(".display-variant-items input[type=radio]:checked"):a("#aawp-modal-display-variant")).val();void 0!==n&&a("#aawp-modal-template-select-container").css("display","block"),["box","link","fields"].includes(n)?(a("#aawp-modal-asin-input-container").css("display","block"),a(".aawp-products-search-container").css("display","block"),a("#aawp-modal-keywords-input-container, #aawp-modal-value-select-container, #aawp-modal-items-input-container, #aawp-modal-comparison-table-container").css("display","none"),"fields"===n&&a("#aawp-modal-value-select-container").css("display","block")):"bestseller"===n||"new"===n?(a("#aawp-modal-keywords-input-container").css("display","block"),a("#aawp-modal-items-input-container").css("display","block"),a("#aawp-modal-asin-input-container, .aawp-products-search-container, #aawp-modal-value-select-container, #aawp-modal-comparison-table-container").css("display","none")):"table"===n?(a("#aawp-modal-comparison-table-container").css("display","block"),a("#aawp-modal-asin-input-container, .aawp-products-search-container, #aawp-modal-value-select-container, #aawp-modal-keywords-input-container, #aawp-modal-value-select-container").css("display","none")):a("#aawp-modal-asin-input-container, .aawp-products-search-container, #aawp-modal-keywords-input-container, #aawp-modal-value-select-container, #aawp-modal-value-select-container, #aawp-modal-comparison-table-container, #aawp-modal-template-select-container").css("display","none")}n();var e=function(){a("#aawp-modal-display-variant").length&&(a("#aawp-modal-display-variant").get(0).selectedIndex=0,a("#aawp-modal-asin-input, #aawp-modal-keywords-input").val(""),a("#aawp-modal-asin-input-container, #aawp-modal-keywords-input-container, #aawp-modal-value-select-container, #aawp-modal-items-input-container, #aawp-modal-comparison-table-container").css("display","none")),a("#aawp-modal-backdrop, #aawp-modal-wrap").css("display","none"),a(document.body).removeClass("modal-open")};a(document).on("click",".mce-aawp-insert-button",(function(n){n.preventDefault(),a("#aawp-modal-backdrop, #aawp-modal-wrap").css("display","block"),a(document.body).addClass("modal-open")})),a(document).on("click","#aawp-modal-close, #aawp-modal-cancel a",(function(a){a.preventDefault(),e()})),a(document).on("change","#aawp-modal-display-variant",(function(a){a.preventDefault(),n()})),a(document).on("change",".display-variant-items input[type=radio]",(function(a){a.preventDefault(),n()})),a(document).on("click","#aawp-modal-submit",(function(n){var o;n.preventDefault();var l,t=a("#aawp-modal-display-variant").val();"box"===t||"link"===t||"fields"===t?l=a("#aawp-modal-asin-input").val():"bestseller"===t||"new"===t?l=a("#aawp-modal-keywords-input").val():"table"===t&&(l=a("#aawp-modal-comparison-table").val()),""!==t&&"undefined"!==l&&(o="["+aawp_classic_editor_data.shortcode+" "+t+' ="'+l+'"',"bestseller"===t||"new"===t?o=o+' items="'+a("#aawp-modal-items-input").val()+'"':"fields"===t&&(o=o+' value="'+a("#aawp-modal-value-select").val()+'"'),o+="]",wp.media.editor.insert(o),e())}))}))})();