(function(){"use strict";u8.rest=function(e){if(typeof e=="string"){e={url:e,type:"GET"}}e.headers=e.headers||{};e.headers["x-redirect"]="client";var r=e.type!=="GET";if(r){if(u8._csrfToken){e.headers["x-csrf-token"]=u8._csrfToken}else{var t=u8.tools.getCookie("csrf-token");if(t){u8._csrfToken=t;e.headers["x-csrf-token"]=t}}}if(u8.debug.level>=400){var s="";var n=typeof e.data;if(n=="string"){s="json:"+e.data}else if(n=="object"){s="html:"+u8.Base.Json.stringify(e.data,"html")}u8.log.debug("request",(e.type||"GET")+": "+e.url+(s?" +\n"+s:""))}var o=$.Deferred();if(typeof e.url=="string"&&e.url.startsWith("~")){e.url=e.url.replace("~",mobileBaseUrl)}var a=$.ajax(e);var i=u8.rest.slow;if(i){var u=(i.min||0)+Math.floor(Math.random()*Math.max(0,i.max-i.min||0));setTimeout(f,u)}else{f()}function f(){a.done(function(r,t,s){if(u8.debug.level>=400){var n;if(r){var a=s.getResponseHeader("content-type")||"",i=a.indexOf("json")>-1;if(i){n=u8.Base.Json.stringify(r,"html")}else{n=u8.Base.Html.escape(r.length>255?r.substr(0,255)+"\n...":r)}}u8.log.debug("response",(e.type||"GET")+": "+e.url+(n?" =\nhtml:"+n:""))}var u=s.getResponseHeader("x-redirect");if(u){window.location.href=u}o.resolve(r)}).fail(function(r,t,s){u8.log.error("response",(e.type||"GET")+": "+e.url+" HTTP Status '"+t+"', Error:"+s);var n=r.responseJSON||r.responseData||r.responseText||r.responseXML;o.reject({status:t,statusDescription:s,data:n})})}return o.promise({abort:function(){if(this.state()=="pending"){a.abort()}}})};u8.rest.slow={min:0,max:300}})();