var $=jQuery.noConflict();$(document).ready(function(t){t("body").tooltip({selector:".cfmsync-tooltip"});var e=new ClipboardJS(".clipboard");e.on("success",function(e){var o=t(e.trigger).data("clipboard-response");cfmsync_toaster("success",o),e.clearSelection()}),e.on("error",function(t){cfmsync_toaster("error","Clipboard error."),t.clearSelection()}),t(".dropdown-menu").on("click",".dropdown-item",function(){t(this).closest(".dropdown-sort").find(".dropdown-toggle").text(t(this).text()+" "),t(this).closest(".dropdown-menu").prev().dropdown("toggle")}),t(".dropdown-search input[type=search]").on("input",function(){var e=t(this).val().toLowerCase();t(this).closest(".dropdown-menu").find(".dropdown-item").filter(function(){t(this).toggle(t(this).text().toLowerCase().indexOf(e)>-1)})}),t(".dropdown-checkbox, .dropdown-search").on("click",function(t){t.stopPropagation()}),t(document).on("click","#cfm-save-settings",function(e){e.preventDefault();var o=t(this),n=o.closest("form").serializeArray();t.ajax({url:cfmsync.ajaxurl,type:"post",data:{action:"save-settings",form_data:n,_nonce:cfmsync.ajaxnonce},beforeSend:function(t){o.prop("disabled",!0),o.html('<i class="fas fa-spinner fa-spin me-2"></i> Saving settings...')},success:function(t){"success"==t?cfmsync_toaster("success","Settings saved successfully."):cfmsync_toaster("error",t),o.prop("disabled",!1),o.html('Save Settings <i class="fal fa-cog ms-2"></i>')}}),e.preventDefault()}),t(document).on("keyup","input[name=archive_slug], input[name=single_slug], input[name=category_archive_slug], input[name=tag_archive_slug]",function(e){t(this).val(cfm_convert_to_slug(t(this).val()))}),t("#confirmation-modal").on("show.bs.modal",function(e){var o=t(e.relatedTarget),n=o.data("confirmation-title"),a=o.data("confirmation-content"),s=o.data("confirmation-button"),c=o.data("confirmation-button-text"),i=o.data("confirmation-reference"),r=o.data("confirmation-nonce"),d=t(this);d.find(".modal-title").text(n),d.find(".modal-body p").text(a),d.find(".modal-footer .modal-confirm").prop("id",s),d.find(".modal-footer .modal-confirm").text(c),d.find(".modal-footer .modal-confirm").attr("data-reference",i),d.find(".modal-footer .modal-confirm").attr("data-nonce",r)}),t("#confirmation-modal").on("hidden.bs.modal",function(e){var o=t(this);o.find(".modal-title").text(""),o.find(".modal-body p").text(""),o.find(".modal-footer .modal-confirm").removeAttr("id"),o.find(".modal-footer .modal-confirm").text("Confirm"),o.find(".modal-footer .modal-confirm").removeAttr("data-reference"),o.find(".modal-footer .modal-confirm").removeAttr("data-nonce")}),t(document).on("click",".cfm-display-show-settings",function(e){e.preventDefault();var o=t(this).attr("data-reference");t("#cfm-save-show-settings").attr("data-reference",o),t.ajax({url:cfmsync.ajaxurl,type:"post",data:{action:"load-show-settings",show_id:o,_nonce:cfmsync.ajaxnonce},beforeSend:function(){t("#cfm-show-settings").html(cfm_content_spinner)},success:function(e){t("#cfm-show-settings").html(e)}}),e.preventDefault()}),t(document).on("click","#cfm-save-show-settings",function(e){e.preventDefault();var o=t(this),n=o.attr("data-reference"),a=t("input[name=use_artwork]:checked").val(),s=t("input[name=se_num]:checked").val(),c=t("input[name=se_num_text]").val(),i=t("input[name=bonus_trailer_text]").val(),r=t("input[name=episode_video]:checked").val();t.ajax({url:cfmsync.ajaxurl,type:"post",data:{action:"save-show-settings",show_id:n,use_artwork:a,se_num:s,se_num_text:c,bonus_trailer_text:i,episode_video:r,_nonce:cfmsync.ajaxnonce},beforeSend:function(){o.prop("disabled",!0),o.html('<i class="fas fa-spinner fa-spin me-2"></i> Saving podcast settings...')},success:function(e){"success"==e?cfmsync_toaster("success","Podcasts settings saved successfully."):cfmsync_toaster("error",e),o.html("Save Podcast Settings"),o.prop("disabled",!1),t("#cfm-show-settings-modal").modal("hide")}}),e.preventDefault()})});