(()=>{"use strict";var a={n:e=>{var d=e&&e.__esModule?()=>e.default:()=>e;return a.d(d,{a:d}),d},d:(e,d)=>{for(var n in d)a.o(d,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:d[n]})},o:(a,e)=>Object.prototype.hasOwnProperty.call(a,e)};const e=window.jQuery;var d=a.n(e);const n=d()("#advanced-ad-type"),t=d()("#advanced-ads-ad-parameters"),o=d()("#advanced-ads-tinymce-wrapper");d()(function(){(function(){const a=d()("#advanced-ad-type input"),e=d()("#ad-types-box h2"),r=e.text();a.on("change",()=>{AdvancedAdsAdmin.AdImporter.onChangedAdType();const s=a.filter(":checked"),i=s.next("label").text();e.html(r+": "+i),function(a){n.addClass("is-list-disabled"),t.html('<span class="spinner advads-ad-parameters-spinner advads-spinner"></span>'),o.hide();let e=!0;d().ajax({type:"POST",url:advancedAds.endpoints.ajaxUrl,data:{action:"load_ad_parameters_metabox",ad_type:a,ad_id:d()("#post_ID").val(),nonce:advadsglobal.ajax_nonce}}).done(d=>{d&&(t.html(d).trigger("paramloaded"),advads_maybe_textarea_to_tinymce(a),e&&(e=!1,setTimeout(()=>{advancedAds.termination.resetInitialValues()},500)))}).fail((a,e,d)=>{t.html(d)}).always(()=>{n.removeClass("is-list-disabled")})}(s.val())}),a.eq(0).trigger("change"),d()('input[name="advanced_ad[type]"]').on("change",function(){const a="adsense"===d()(this).val();d()(".advads-notice-adsense").toggleClass("block-important",a).toggleClass("!hidden",!a)})})(),function(){const a=d()("#advads-ad-injection-box"),e=d()("#post_ID").val();d()(document).on("click",".advads-ad-injection-button",function(){const n=d()(this).data("placement-type"),t=d()(this).data("placement-id");let o={};(n||t)&&(o=function(a,e){if("post_content"===a){const a=prompt(advadstxt.after_paragraph_promt,1);if(null!==a)return{...e,index:parseInt(a,10)}}return e}(n,o),function(a,e,n,t){const o=d()("#advads-ad-injection-box");d().ajax({type:"POST",url:ajaxurl,data:{action:"advads-ad-injection-content",placement_type:a,placement_id:e,ad_id:n,options:t,nonce:advadsglobal.ajax_nonce},success(e){e?(d()("#advads-ad-injection-box *").hide(),d()("#advads-ad-injection-message-placement-created, #advads-ad-injection-message-placement-created *").show(),"server"===a&&d()(".hide-server-placement").hide()):o.html("an error occured")},error(a,e,d){o.html(d)}})}(n,t,e,o),a.find(".advads-loader").show(),a.find(".advads-ad-injection-box-placements").hide(),d()("body").animate({scrollTop:a.offset().top-40},1,"linear"))})}(),function(){let a=null;const e=()=>{const e=a?a.codemirror.getValue():jQuery("#advads-ad-content-plain").val(),d=jQuery("#advads-parameters-php-warning"),n=jQuery("#advads-allow-php-warning");d.hide(),n.hide(),jQuery("#advads-parameters-php").prop("checked")&&(/<\?(?:php|=)/.test(e)?n.show():d.show()),jQuery("#advads-parameters-shortcodes-warning").toggle(jQuery("#advads-parameters-shortcodes").prop("checked")&&!/\[[^\]]+\]/.test(e))};jQuery(document).on("keyup","#advads-ad-content-plain",e),jQuery(document).on("click","#advads-parameters-php,#advads-parameters-shortcodes",e),jQuery(document).on("paramloaded","#advanced-ads-ad-parameters",()=>{let d;try{d=window.advancedAds.admin.codeMirror.settings}catch(e){return void(a=null)}if("plain"!==jQuery('input[name="advanced_ad[type]"]:checked').val())return void(a=null);const n=jQuery("#advads-ad-content-plain");n.length?(a=wp.codeEditor.initialize(n,d),a.codemirror.on("keyup",e),window.advancedAds.admin.codeMirror=a.codemirror,window.advancedAds=window.advancedAds||{},window.advancedAds.admin.getSourceCode=()=>a?a.codemirror.getValue():jQuery("#advads-ad-content-plain").val(),window.advancedAds.admin.setSourceCode=e=>{a?a.codemirror.setValue(e):jQuery("#advads-ad-content-plain").val(e)}):a=null})}()})})();