!function(i){(i.isEpicFailing=function(){return"undefined"==typeof $},i.isEpicFailing())&&(document.getElementById("epicfail").style.display="block")}(window.AoPS||{}); ;$(document).on("ready",(function(){if(jQuery.support.cors=!0,document.getElementById("side-column")&&($("#breadcrumbs-wrapper").addClass("clickable-breadcrumb"),$("#breadcrumbs-wrapper").click((function(){window.innerWidth<840&&($("#side-column-wrapper").toggleClass("active"),$("#submenu-icon").toggleClass("open"))})),$("#side-column .dropdown-box > .title").click((function(e){$(e.currentTarget).parent().toggleClass("open")})),$("#side-column .menu").click((function(e){$("#side-column .submenu-wrapper").removeClass("open"),$(e.currentTarget).find(".submenu-wrapper").addClass("open")}))),$(".infobar").click((function(e){e.target.className.indexOf("infobar-hide")>=0&&($(this).hide(),AoPS.fixFooter(),$("#main-content").trigger($.Event("resize")),$.ajax({url:"/ajax.php",timeout:5e3,type:"post",data:{a:"infobar-hide",key:$(this).data("key")},success:function(e){}}))})),$("#menu-myaops-toggle").click((function(e){$("#menu-myaops").toggle(),e.preventDefault(),e.stopPropagation()})),!document.getElementById("side-column")){var e=document.getElementById("submenu-icon");e&&e.parentNode.removeChild(e)}AoPS.fixFooter(),$(window).on("resize.fix_footer",(function(){AoPS.fixFooter()})),AoPS.login.initialize(),AoPS.inputPlaceholders.initialize(),document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect?$("html").addClass("svg"):$("html").addClass("no-svg");var o=$("body"),n=$("#top-bar"),t=$("#main-logo"),i=!1,a=!1,r=!1,s=!1;n.on("mousemove.start_loc",(function(){i=!0})),t.on("mousemove.start_loc",(function(){s=!0})),o.on("mousemove.start_loc",(function(){n.off("mousemove.start_loc"),o.off("mousemove.start_loc"),t.off("mousemove.start_loc"),setTimeout((function(){i=!1,s=!1}),350)})),n.on("mouseenter",(function(){a=!0,setTimeout((function(){!i&&a&&$("#header-popin").animate({opacity:1},150)}),350)})),t.on("mouseenter",(function(){r=!0,setTimeout((function(){!s&&r&&$("#header-popin").animate({opacity:1},150)}),350)})),n.on("mouseleave",(function(){a=!1})),t.on("mouseleave",(function(){r=!1})),$("#header").on("mouseleave",(function(){$("#header-popin").animate({opacity:0},150)})),n.find(".site").hover((function(){var e=$(this);e.addClass("dropdown-visible");var o=e.find(".site-dropdown-wrapper");if(o.length){var n=$(window).width(),t=o.outerWidth(),i=o.offset().left+t+10-n;i>0&&o.css("left",-100-i+"px")}}),(function(){$(this).removeClass("dropdown-visible").find(".site-dropdown-wrapper").css("left","")})),AoPS.checkPrivacy()})),$(window).on("load",(function(){AoPS.fixFooter()})),AoPS.checkPrivacy=function(){if(document.URL.indexOf("/privacy")<0&&AoPS.session&&AoPS.session.show_privacy){var e=["

We've made a few updates to our privacy policy. These updates went into effect on Friday, February 4, 2022.

","

Click ",'here ',"to learn more about the new ",'artofproblemsolving.com policy.

'],o=1,n=document.location.href;(n.indexOf("community")>0||n.indexOf("alcumus")>0||n.indexOf("baeditor")>0||n.indexOf("class/")>0)&&(o=1e3),setTimeout((function(){alert(e.join(""),{onButtonClick:function(){$.post("/ajax.php",{action:"update-accepted"})},max_width:"600px",closeX:!1,force_response:!0})}),o)}},window.classicAlert=window.alert,window.alert=function(e,o){AoPS.hasOwnProperty("Ui")?(AoPS.Ui.Modal.closeTopModal(),void 0===o?AoPS.Ui.Modal.showAlertQuick(e):AoPS.Ui.Modal.showAlertQuick(e,o)):window.classicAlert(e)},AoPS.setBreadcrumbs=function(e){for(var o,n=[],t=0;t'+o+""),n.push(''+o+"");$(".crumb-wrapper").html(n.join(' '))},AoPS.fixFooter=function(){var e=$(window).height(),o=$("body").hasClass("small-footer");e-=$("#header-wrapper").outerHeight(),e-=$("#top-bar").outerHeight(),$("#breadcrumbs-wrapper:visible").length||(e-=26),e-=o?$("#small-footer-wrapper").outerHeight():$("#main-footer").outerHeight(),$("#main-content").css("min-height",e),o&&$("#small-footer-wrapper").show();var n=document.getElementById("side-column-wrapper");n&&$(n).css("min-height",e),AoPS.fixSidebarOnce()},AoPS.makeSidebarAdjustment=function(e,o,n){if(e&&o&&n){var t=0;o.children().each((function(){t+=$(this).outerHeight(!0)})),e.height()!==Math.max(n.outerHeight(!0),t)&&e.css("height",Math.max(n.outerHeight(!0),t))}},AoPS.fixSidebarOnce=function(){var e=$("#side-column-wrapper"),o=$("#side-column"),n=$("#main-column");AoPS.makeSidebarAdjustment(e,o,n)},AoPS.fixSidebarAnimatedOnce=function(e){AoPS.fixSidebarAnimatedOnceOnElement(e,"main-column")},AoPS.fixSidebarAnimatedOnceOnElement=function(e,o){var n=$("#side-column-wrapper"),t=$("#side-column"),i=2+e?e/15:0,a=0;!function e(){a>i||(a++,AoPS.makeSidebarAdjustment(n,t,$("#"+o)),setTimeout(e,15))}()},AoPS.fixSidebarClassObserver=function(e){var o,n=$("#side-column-wrapper"),t=$("#side-column"),i=$("#main-column");e||(e=[]),o=e.attributeFilter?{attributeFilter:e.attributeFilter,attributes:!0,childList:!0,subtree:!0}:{attributeFilter:["class"],attributes:!0,childList:!0,subtree:!0};new MutationObserver((function(){if(e.animation_length){var o=2+e.animation_length/15,a=0;!function e(){a>o||(a++,AoPS.makeSidebarAdjustment(n,t,i),setTimeout(e,15))}()}else AoPS.makeSidebarAdjustment(n,t,i)})).observe(document.getElementById("main-column"),o),e.animation_length?AoPS.fixSidebarAnimatedOnce(e.animation_length/15):AoPS.makeSidebarAdjustment(n,t,i)},AoPS.login={ajaxing:!1,$login_form:$("#login-form"),logout_url:AoPS.bootstrap_data&&AoPS.bootstrap_data.logout_url,user_clicked_logout:!1,user_clicked_login:!1,modal:null,initialize:function(){$(document).on("click",".online-login-button",AoPS.login.display),$("#header-logout, #small-header-logout").on("click",AoPS.login.logout),$("#register-button").on("click",(function(e){e.preventDefault(),AoPS.login.register()})),$("#login-cancel-button").on("click",AoPS.login.close),$("#login-button").on("click",AoPS.login.login),$("#login-password").on("keypress",(function(e){13===e.keyCode&&AoPS.login.login()})),$("#login-username").on("keypress",(function(e){if(13===e.keyCode){var o=document.getElementById("login-username").value;document.getElementById("login-password").value.length?AoPS.login.login():o.length&&document.getElementById("login-password").focus()}}))},logout:function(e){if(!AoPS.login.ajaxing){e.preventDefault(),e.stopPropagation(),AoPS.login.user_clicked_logout=!0,AoPS.login.ajaxing=!0;var o=AoPS.protected_url+"ajax.php",n=location.protocol;void 0!==n&&n.indexOf("https")<0&&(o=o.replace("https","http")),$.ajax({url:o,timeout:1e4,type:"post",crossDomain:!0,xhrFields:{withCredentials:!0},data:{a:"logout"},success:function(e){AoPS.login.ajaxing=!1,AoPS.login.logout_url?window.location=AoPS.login.logout_url:window.location.hash?window.location.reload(!0):window.location.href=window.location.href}})}},register:function(){var e=document.getElementById("login-username").value||"",o=document.getElementById("login-password").value||"";if("function"==typeof(AoPS.Register||{}).display)AoPS.login.close(),AoPS.Register.display({username:e,password:o});else{var n=document.getElementById("registration-form");n.username.value=e,n.password.value=o,n.submit()}},loggedin:function(){},login:function(e){if(!AoPS.login.ajaxing){AoPS.login.user_clicked_login=!0,AoPS.login.ajaxing=!0;var o=AoPS.protected_url+"ajax.php";if(void 0!==e&&!0===e){var n=location.protocol;void 0!==n&&n.indexOf("https")<0&&(o=o.replace("https","http"))}$.ajax({url:o,timeout:1e4,type:"post",data:{a:"login",username:$("#login-username").val(),password:$("#login-password").val(),stay:$("#login-stay-logged-in").is(":checked")},crossDomain:!0,xhrFields:{withCredentials:!0},success:function(e){setTimeout((function(){AoPS.login.ajaxing=!1}),1e3),e.error_msg?($("#login-form > .error").show().html(e.error_msg),e.error_msg.toLowerCase().indexOf("account deactivated")>=0&&$.ajax({url:o,timeout:1e4,type:"post",data:{a:"user-get-registration-disabled",username:$("#login-username").val()},crossDomain:!0,xhrFields:{withCredentials:!0},success:function(e){$("#register-button").hide(),window.location.href.includes("register.php")&&window.location.reload(!0)}})):e.error_code?$("#login-from > .error").show().html(e.error_code):document.location.href.indexOf("com/online?login")>0?document.location="/online":window.location.hash?window.location.reload(!0):window.location.href=window.location.href},error:function(o){void 0!==e&&!0===e?(AoPS.login.user_clicked_login=!1,setTimeout((function(){AoPS.login.ajaxing=!1}),1e3),$("#login-form > .error").show().html("There was an error communicating with the server. Please try again.")):(AoPS.login.ajaxing=!1,AoPS.login.login(!0))}})}},close:function(){AoPS.login.modal&&(AoPS.Ui.Modal.removeModal(AoPS.login.modal),AoPS.login.modal=null),$(document).off("keyup",AoPS.login.checkKeyPress)},display:function(e){e=!1!==e,0===AoPS.login.$login_form.length&&(window.location.href="/user/login.php?redirect="+encodeURIComponent(window.location.href)),$("#login-cancel-button").toggle(e),$.ajax({url:"/ajax.php",timeout:5e3,type:"get",data:{a:"check-invalid-registration-cookie"},success:function(e){e.response&&$("#register-button").hide()}}),$("#login-password").attr("type","password"),AoPS.login.modal&&AoPS.Ui.Modal.removeModal(AoPS.login.modal),AoPS.login.modal=AoPS.login.$login_form.showPlainModal({max_width:"500px",closeX:e,force_response:!e,scrollable:!0}),setTimeout((function(){$("#login-username").focus()}),1),e&&$(document).on("keyup",AoPS.login.checkKeyPress)},checkKeyPress:function(e){27===e.keyCode&&AoPS.login.close()},onUserAjaxLogout:function(){AoPS.session.logged_in||($("#header .myaops").remove(),$("#header-login").show())},onUserAjaxLogin:function(){document.location.reload(!0)}},$((function(){var e=$(".menubar-label, .login-dropdown"),o=!1;e.on("click",(function(e){o&&(e.preventDefault(),e.stopPropagation())})).on("mouseover",(function(e){if(o)e.preventDefault();else{var n=$(this);n.prop("hoverTimeout")&&n.prop("hoverTimeout",clearTimeout(n.prop("hoverTimeout"))),n.prop("hoverIntent",setTimeout((function(){n.addClass("open")}),50))}})).on("mouseleave",(function(e){if(o)e.preventDefault();else{var n=$(this);n.prop("hoverIntent")&&n.prop("hoverIntent",clearTimeout(n.prop("hoverIntent"))),n.prop("hoverTimeout",setTimeout((function(){n.removeClass("open")}),50))}}));var n=window.navigator.msPointerEnabled?"MSPointerDown":"touchstart";("ontouchstart"in document.documentElement||"MSPointerDown"===n)&&e.each((function(){var t=$(this);this.addEventListener(n,(function(i){if(("MSPointerDown"===n||1===i.touches.length)&&(window.innerWidth>700||t.hasClass("login-dropdown")))if(i.stopPropagation(),t.hasClass("open"))o=!1;else{o=!0,i.target!==this&&i.target.parentNode!==this||i.preventDefault(),e.removeClass("open"),t.addClass("open");document.addEventListener(n,(function e(n){n.stopPropagation(),t.removeClass("open"),document.removeEventListener("touchstart",e),o=!1}))}}),!1)}))})),AoPS.updateLayout=function(){},"undefined"!=typeof Backbone&&(AoPS.Model=Backbone.Model.extend({}),AoPS.Collection=Backbone.Collection.extend({debug:function(){console.log(this),console.log(this.length),console.log(this.models)}}),AoPS.View=Backbone.View.extend({getTemplate:function(e,o){var n=AoPS.View.compileTemplate(e);return $.parseHTML($.trim(n&&n(o)))},compile:function(e){return AoPS.View.compileTemplate(e)},display:function(e,o){this.$el.html($.parseHTML($.trim(e(o))))},debug:function(){console.log("View.model:",this.model),console.log("View.tagName:",this.tagName),console.log("View.className:",this.className),console.log("View.el:",this.el),console.log("View.$el:",this.$el)},hide:function(){this.$el.hide()},show:function(){this.$el.show()},close:function(){this.remove(),this.unbind(),"function"==typeof this.onClose&&this.onClose()},showLoadingModal:function(){this.loadingModal=AoPS.Ui.Modal.showMessage('',{closeX:!1,force_response:!0,frame_class:"loading-modal-frame"})},closeLoadingModal:function(){AoPS.Ui.Modal.closeParticularModal(this.loadingModal)}}),AoPS.View.template_cache={},AoPS.View.compileTemplate=function(e){var o=AoPS.View.template_cache;if(!o.hasOwnProperty(e)){var n=$(e),t=Handlebars.templates&&Handlebars.templates[e.slice(1)];n.length?o[e]=Handlebars.compile(n.html()):t&&(o[e]=t)}return o[e]}),AoPS.inputPlaceholders={initialize:function(){"placeholder"in document.createElement("input")||($("[placeholder]").focus((function(){var e=$(this);e.val()===e.attr("placeholder")&&(e.val(""),e.removeClass("placeholder"))})).blur((function(){var e=$(this);""!==e.val()&&e.val()!==e.attr("placeholder")||(e.addClass("placeholder"),e.val(e.attr("placeholder")))})).blur(),$(["placeholder"]).parents("form").submit(AoPS.inputPlaceholders.clear),AoPS.inputPlaceholders.clear=function(){$("[placeholder]").each((function(){var e=$(this);e.val()===e.attr("placeholder")&&e.val("")}))})},clear:function(){}},AoPS.doFastMathJax=function(e){AoPS.FastMathJax.push(e)},AoPS.FastMathJax={_elements:[],_isProcessing:!1,_process:function(){if(!this._isProcessing)if(this._elements.length){this._isProcessing=!0;var e=$("
").css({position:"fixed",top:"-100vh",left:"-100vw",opacity:0,"z-index":-9999,"pointer-events":"none"}).appendTo($(document.body)),o=this,n=this._elements.splice(0,250);_.each(n,(function(o){o.$hidden=o.$el.clone().removeClass().appendTo(e)})),MathJax.Hub.Queue(["Typeset",MathJax.Hub,e.get(0)]),MathJax.Hub.Queue([function(){_.each(n,(function(e){e.$el.html("").append(e.$hidden.clone()),e.$hidden.remove()})),e.remove(),o._isProcessing=!1,o._process()}])}else this._isProcessing=!1},push:function(e){window.MathJax&&(e instanceof jQuery||_.isArray(e)?_.each(e,_.bind((function(e){this._elements.push({$el:$(e)})}),this)):this._elements.push({$el:$(e)}),setTimeout(_.bind((function(){this._process()}),this),50))}},AoPS.importJavaScript=function(e){var o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(o)},window.number_format=function(e,o,n,t){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var i,a,r,s=isFinite(+e)?+e:0,l=isFinite(+o)?Math.abs(o):0,c=void 0===t?",":t,u=void 0===n?".":n,d="";return(d=(l?(i=s,a=l,r=Math.pow(10,a),""+(Math.round(i*r)/r).toFixed(a)):""+Math.round(s)).split("."))[0].length>3&&(d[0]=d[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,c)),(d[1]||"").length-1)&&(parseInt(o)||!1)}(t=t||"init_time");if(!1!==i){var a=function(e){if(!document||_.isUndefined(document.cookie)||!navigator||!navigator.cookieEnabled)return!1;for(var o,n=new RegExp("^\\s*"+e+"_init_time\\s*=\\s*(.*?)\\s*$"),t=document.cookie.split(";"),i=0;i=i?function(){if(!e){e=!0;var o=document.createElement("STYLE"),n=document.createTextNode("body {display: none;}");o.appendChild(n),document.head.appendChild(o),console.log("About to refresh the page due to back button use."),setTimeout((function(){window.location.reload(!0)}),2e3)}}():setTimeout((function(){e||(document.cookie=n+"_init_time="+i+"; path=/")}),3e3)}}}}(),AoPS.isUserLimited=function(){return AoPS.user_is_limited},AoPS.user_is_limited=AoPS.hasOwnProperty("session")&&AoPS.session.hasOwnProperty("role")&&-1!==AoPS.session.role.indexOf("limited_user"),AoPS.isUserNew=function(){return AoPS.user_is_new},AoPS.user_is_new=AoPS.hasOwnProperty("session")&&AoPS.session.hasOwnProperty("role")&&-1!==AoPS.session.role.indexOf("new_user"),AoPS.in_academy=AoPS.bootstrap_data&&AoPS.bootstrap_data.hasOwnProperty("in_academy")&&1===parseInt(AoPS.bootstrap_data.in_academy),AoPS.convertSmartQuotes=function(e){return e.replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/[\u2013\u2014]/g,"-").replace(/[\u2026]/g,"...")};var gOldOnError=window.onerror;window.onerror=function(e,o,n,t,i){return!!gOldOnError&&gOldOnError(e,o,n)},window.onImageLoad=function(){},window.handlebars=function(e,o){var n="";if(o||(o={}),e instanceof Element)n=e.innerHTML;else if("undefined"!=typeof jQuery&&e instanceof jQuery)n=e.html();else{if("string"!=typeof e)return!1;try{var t=document.querySelector(e);n=null===t?e:t.innerHTML}catch(r){n=e}}if("undefined"!=typeof Handlebars)return Handlebars.compile(n)(o);for(var i in o){var a=new RegExp("{{"+i+"}}","g");n=n.replace(a,o[i])}return n},AoPS.handleLocationHash=function(e){var o=function(e){var o=e.offset().top,n=$("#main-menubar").outerHeight();return Math.min(Math.floor(o-n),Math.max($("html").prop("scrollHeight")-$(window).height(),$("body").prop("scrollHeight")-$(window).height()))},n={};function t(e){if(!n.animating){n.animating=!0;var i=o(e);$("html, body").animate({scrollTop:i},{duration:0,step:function(n,t){t.end=o(e)},always:function(){n.animating=!1,Math.abs($(window).scrollTop()-o(e))>n.threshold&&t(e)}})}}setTimeout((function(){if(location.hash){var e=$(document).find(location.hash);e.length&&t(e)}}),0)},AoPS.handleLocationHash2=function(e,o){o||(o={});var n=function(e){var o=$("#header"),n=$("#main-menubar"),t=n.outerHeight();t=$(window).width()<=700?0:"fixed"===o.css("position")?n.outerHeight():n.outerHeight()+70;var i=e.offset().top;return Math.min(Math.floor(i-t),Math.max($("html").prop("scrollHeight")-$(window).height(),$("body").prop("scrollHeight")-$(window).height()))},t={};function i(e){if(!t.animating){t.animating=!0;var a=n(e);$("html, body").animate({scrollTop:a},{duration:o&&o.duration?o.duration:0,step:function(o,t){t.end=n(e)},always:function(){t.animating=!1,Math.abs($(window).scrollTop()-n(e))>5&&(o.duration=0,i(e))}})}}setTimeout((function(){if(e)e.length&&i(e);else if(location.hash){var o=$(document).find(location.hash);o.length&&i(o)}}),0)}; ;AoPS.hasOwnProperty("Ui")&&AoPS.hasOwnProperty("ui_main_loaded")||(AoPS.Ui=function(e){var t;t=$(window).height(),setInterval((function(){var e=$(window).height();e!=t&&(t=e,$(window).trigger("resize"))}),100),$(window).on("resize",(function(){t=$(window).height()})),e.buildTableRow=function(e){var t=$(""),o=(e=_.defaults(e,{is_header:!1})).is_header?"th":"td";return _.each(e.data,(function(e){t.append($.parseHTML("<"+o+">"+e+""))})),e.is_header&&t.addClass("aops-no-sort"),t},e.buildTable=function(t){var o,s,a=0,i=!1,n=!1;return t=_.defaults(t,{sortable:!1,table_id:"",sort_on_build:!1,table_class:"",sort_col:0,sort_order:"asc",repeating_header:0}),o=$("",{id:t.table_id,class:t.table_class}),s=$("").appendTo(o),t.hasOwnProperty("footer")&&$("").prependTo(o).append(e.buildTableRow({data:t.footer,is_header:!0})),t.hasOwnProperty("header")&&$("").prependTo(o).append(e.buildTableRow({data:t.header,is_header:!0})),t.hasOwnProperty("rows")&&_.each(t.rows,(function(o){s.append(e.buildTableRow({data:o})),a++,t.repeating_header>0&&a%t.repeating_header==0&&s.append(e.buildTableRow({data:t.header,is_header:!0}))})),t.sortable&&(o.tablesorter(t.sort_on_build?{sortList:t.hasOwnProperty("sortList")?t.sortList:[[t.sort_col,"asc"===t.sort_order?0:1]]}:{}),t.repeating_header>0&&(o.bind("sortStart",(function(){i?(i=!1,n=!0):(i=!0,s.find(".aops-no-sort").remove(),o.trigger("update"))})),o.bind("sortEnd",(function(){n?n=!1:s.find("tr:nth-child("+t.repeating_header+"n)").after(e.buildTableRow({data:t.header,is_header:!0}))})))),o},e.Flyout=function(){var e,t={},o=[],s={width:300,height:150,class:"",time:5e3,animation_time:1e3,close_function:"close"};function a(){if(o.length&&document.body){var e=document.getElementById("flyout");if(!e||!e.parentNode){var t=o.shift();i(t.html,t.opts)}}}function i(o,a){a=$.extend({},s,a),e=a;var i=document.createElement("div");i.id="flyout",i.style.width=a.width+"px",i.style.height=a.height+"px",i.style.right=-a.width+"px",i.className=a.class,i.innerHTML='
'+o,document.body.appendChild(i),$("#flyout").animate({right:0},a.animation_time,(function(){t.timeout=setTimeout((function(){n()}),a.time)}))}function n(){$("#flyout").animate({right:-e.width},e.animation_time,(function(){t.timeout=0;var e=document.getElementById("flyout");e&&(e.parentNode.removeChild(e),a())}))}return t.display=function(e,s){document.body?(t.close(),o=[],i(e,s)):(AoPS.ErrorUtil.log("E_EARLY_FLYOUT"),t.queue(e,s))},t.queue=function(e,t){o.push({html:e,opts:t}),a()},t.close=function(){if(document.body){t.timeout&&clearTimeout(t.timeout),o=[];var e=document.getElementById("flyout");e&&e.parentNode&&e.parentNode.removeChild(e)}},t.closeWithoutClearingQueue=function(){document.body&&(t.timeout&&clearTimeout(t.timeout),n())},$(a),t}(),$.fn.extend({showUnstyledModal:function(e){var t=_.defaults({$obj:this},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.show$Object(t)},showPlainModal:function(e){var t=_.defaults({body:this},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.show(t)},showPlainBodyModal:function(e){var t=_.defaults({body:this},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.showPlainBody(t)},showModal:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showMessage(this,t)},showModalQuick:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showMessageQuick(this,t)},showPlainAlert:function(e){var t=_.defaults({body:this,type:"alert"},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.show(t)},showAlertQuick:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showAlertQuick(this,t)},showAlert:function(e){var t=arguments.length>0?arguments[0]:{};return this.show(),AoPS.Ui.Modal.showAlert(this,t)},cloneToPlainModal:function(e){var t=this.clone(!0),o=_.defaults({body:t,type:"message"},arguments.length>0?arguments[0]:{});return t.show(),AoPS.Ui.Modal.showPlain(o)},cloneToUnstyledModal:function(e){var t=this.clone(!0),o=_.defaults({$obj:t},arguments.length>0?arguments[0]:{});return this.show(),AoPS.Ui.Modal.show$Object(o)},cloneToModal:function(e){var t=this.clone(!0),o=_.extend({},arguments.length>0?arguments[0]:{});return t.show(),AoPS.Ui.Modal.showMessage(t,o)},replaceTopModalPlain:function(e){var t=_.defaults({body:this,frame_class:"",type:"message"},arguments.length>0?arguments[0]:{}),o=AoPS.Ui.Modal.replace(t);return this.show(),o},replaceTopModalUnstyled:function(e){var t=_.defaults({$obj:this,type:"$"},arguments.length>0?arguments[0]:{}),o=AoPS.Ui.Modal.replace(t);return this.show(),o},replaceTopModal:function(e){var t=_.extend({type:"message",frame_class:"aops-modal-standard",body:this},arguments.length>0?arguments[0]:{}),o=AoPS.Ui.Modal.replace(t);return this.show(),o}});var o=1e5;return e.Modal={active_modals:[],fitMasks:function(){function e(){var e={height:$(window).outerHeight(),width:$(window).outerWidth()};function t(t,o){var s=t.options["max_"+o];return"%"===s.substr(s.length-1,1)?Math.min(parseFloat(s)/100*e[o],t.options.overall_max_width):Math.min(parseFloat(s),t.options.overall_max_width)}_.each(this.active_modals,(function(e){var o={height:t(e,"height"),width:t(e,"width")};e.$obj.css({"max-height":"","max-width":""}),e.$obj.css({height:e.options.height,width:e.options.width}),_.each(["width","height"],(function(t){var s=Math.round(o[t]);("height"===t?e.$obj.outerHeight():e.$obj.outerWidth())>=s&&e.$obj[t](s)}));var s=Math.min(1e3,window.innerWidth-12)+"px";e.$obj.css({"max-height":e.options.max_height,"max-width":s})}))}function t(){$("body").toggleClass("modal-page-overflow",$("body").height()>$(window).height()),_.each(this.active_modals,(function(e){e.$wrapper.css({overflow:"hidden"}),e.$obj.css({position:"absolute"}),e.$obj.css({top:parseInt(Math.max(0,($(window).height()-e.$obj.outerHeight())/2*.8)),left:parseInt(Math.max(0,($(window).width()-e.$obj.outerWidth())/2))})}))}e.apply(this),e.apply(this),setTimeout(_.bind((function(){e.apply(this),t.apply(this)}),this),5),t.apply(this)},show$Object:function(e){var t={$wrapper:$("
",{class:"aops-modal-wrapper"}),$mask:$("
",{class:"aops-modal-mask"}),$obj:e.$obj,options:this.appendDefaults(e)};return $("body").addClass("aops-modal-open"),t.$wrapper.append(t.$obj),this.setZIndices(t),$("body").append(t.$mask),$("body").append(t.$wrapper),t.options.hasOwnProperty("onShow")&&setTimeout((function(){t.options.onShow()}),100),this.active_modals.push(t),this.setZIndices(t),t.$mask.fadeTo(e.mask_fade_in_speed,t.options.mask_alpha),t.$wrapper.fadeIn(e.mask_fade_in_speed,(function(){"alert"===e.type&&e.focus_on_alert&&t.$obj.find("button").first().focus()})),t.options.draggable&&t.$obj.draggable&&t.$obj.draggable(t.options.draggable_options),this.parseForceResponse(t),this.fitMasks(),!("activeElement"in document)||_.isUndefined(document.activeElement)||_.isNull(document.activeElement)||document.activeElement.blur(),t.options.mathjax&&window.MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub,t.$obj[0]]),t.$obj.trigger("modal_shown"),t},show:function(e){var t;switch((t=this.prepareOptions.apply(this,arguments)).type){case"$":return this.show$Object(t);case"unframed_html":return $($.parseHTML(t.body));case"ignore-loading":break;default:return this.show$Object(_.extend({$obj:this.makeFramed$Object(t)},t))}},extFrameClass:function(e,t){return e+(t.hasOwnProperty("frame_class")?" "+t.frame_class:"")},showPlain:function(e){return this.show(e)},showQuick:function(e){return this.show(_.defaults({frame_class:this.extFrameClass("aops-modal-standard aops-modal-quick",e)},e))},showPlainBody:function(e){return this.show(_.defaults({frame_class:this.extFrameClass("aops-modal-plain-body",e)},e))},showMessage:function(e){var t,o=arguments.length>1?arguments[1]:{};return t=o.hasOwnProperty("buttons")?"buttons":"message",this.show(_.extend({type:t,body:e,frame_class:this.extFrameClass("aops-modal-standard",o)},o))},showMessageQuick:function(e){return this.showQuick(_.extend({type:"message",body:e},arguments.length>1?arguments[1]:{}))},showAlert:function(e){var t=arguments.length>1?arguments[1]:{};return this.show(_.extend({type:"alert",body:e,frame_class:this.extFrameClass("aops-modal-standard",t)},t))},showAlertQuick:function(e){return this.showQuick(_.extend({type:"alert",body:e},arguments.length>1?arguments[1]:{}))},showConfirm:function(e,t){var o=arguments.length>2?arguments[2]:{},s=this.show(_.extend({type:"confirm",body:e,onButtonClick:t,frame_class:this.extFrameClass("aops-modal-standard",o)},o));return s.$obj.find(".aops-modal-btn").first().focus(),s},showConfirmQuick:function(e,t){var o=this.showQuick(_.extend({type:"confirm",body:e,onButtonClick:t},arguments.length>2?arguments[2]:{}));return o.$obj.find(".aops-modal-btn").first().focus(),o},showButtons:function(e,t,o){var s=arguments.length>3?arguments[3]:{};return this.show(_.extend({type:"buttons",buttons:t,body:e,onButtonClick:o,frame_class:this.extFrameClass("aops-modal-standard",s)},s))},showButtonsQuick:function(e,t,o,s){return s=s||{},this.showQuick(_.extend({type:"buttons",buttons:t,body:e,onButtonClick:o},s))},makeFramed$Object:function(e){var t,o,s=null,a=null,i=this,n=$("
",{class:e.scrollable?"aops-scroll-content":"aops-modal-noscroll"});function r(e){var t="";return e.removeDefaultBtnCss||(t=" btn-primary"),e.btnClass&&(t=" "+e.btnClass),$("