(function($){var wrap,tempHidden,tempHiddenTimeout;function show(){var parent=$('#wp-auth-check'),form=$('#wp-auth-check-form'),noframe=wrap.find('.wp-auth-fallback-expired'),frame,loaded=false;if(form.length){$(window).on('beforeunload.wp-auth-check',function(event){event.originalEvent.returnValue=window.wp.i18n.__('Your session has expired. You can log in again from this page or go to the login page.');});frame=$('<iframe id="wp-auth-check-frame" frameborder="0">').attr('title',noframe.text());frame.on('load',function(){var height,body;loaded=true;form.removeClass('loading');try{body=$(this).contents().find('body');height=body.height();}catch(er){wrap.addClass('fallback');parent.css('max-height','');form.remove();noframe.focus();return;}
if(height){if(body&&body.hasClass('interim-login-success')){hide();}else{parent.css('max-height',height+40+'px');}}else if(!body||!body.length){wrap.addClass('fallback');parent.css('max-height','');form.remove();noframe.focus();}}).attr('src',form.data('src'));form.append(frame);}
$('body').addClass('modal-open');wrap.removeClass('hidden');if(frame){frame.focus();setTimeout(function(){if(!loaded){wrap.addClass('fallback');form.remove();noframe.focus();}},10000);}else{noframe.focus();}}
function hide(){var adminpage=window.adminpage,wp=window.wp;$(window).off('beforeunload.wp-auth-check');if((adminpage==='post-php'||adminpage==='post-new-php')&&wp&&wp.heartbeat){wp.heartbeat.connectNow();}
wrap.fadeOut(200,function(){wrap.addClass('hidden').css('display','');$('#wp-auth-check-frame').remove();$('body').removeClass('modal-open');});}
function setShowTimeout(){tempHidden=true;window.clearTimeout(tempHiddenTimeout);tempHiddenTimeout=window.setTimeout(function(){tempHidden=false;},300000);}
$(function(){wrap=$('#wp-auth-check-wrap');wrap.find('.wp-auth-check-close').on('click',function(){hide();setShowTimeout();});}).on('heartbeat-tick.wp-auth-check',function(e,data){if(!('wp-auth-check'in data)){return;}
var showOrHide=function(){if(!data['wp-auth-check']&&wrap.hasClass('hidden')&&!tempHidden){show();}else if(data['wp-auth-check']&&!wrap.hasClass('hidden')){hide();}};if(wrap){showOrHide();}else{$(showOrHide);}});}(jQuery));