timely.define(["jquery_timely","external_libs/bootstrap/collapse","external_libs/bootstrap/modal"],function(e){var t=function(t){!e(this).is(":checked")&&e("#ai1ec-facebook-export-modal").length?e("#ai1ec-facebook-export-modal").modal({show:!0,backdrop:"static"}):e("#ai1ec-remove-fb-event-hidden").remove()},n=function(){e("#ai1ec-facebook-export-modal").modal("hide");if(e(this).hasClass("remove")){var t=e("<input />",{type:"hidden",name:"ai1ec-remove-event",value:1,id:"ai1ec-remove-fb-event-hidden"});e("#ai1ec-facebook-publish").append(t)}else e("#ai1ec-remove-fb-event-hidden").remove()},r=function(t){t.preventDefault();var n=e(t.target).closest("#ai1ec-facebook-publish"),r=n.find(".ai1ec-fa-refresh"),i={action:"ai1ec_refresh_tokens"};r.addClass("ai1ec-fa-spin"),e.post(ajaxurl,i,function(e){var t=n.find(".ai1ec-page-choices");r.removeClass("ai1ec-fa-spin"),t.length?t.replaceWith(e):n.find(".ai1ec-refresh-fb-pages").before(e)},"json")},i=function(t){var n=e("#ai1ec-fb-collapse");n.length&&n.collapse(this.checked?"show":"hide")};return{open_modal_on_unpublish:t,add_hidden_field_when_user_click_remove_in_modal:n,show_page_choices_when_present:i,refresh_list_of_pages:r}});