text: // jQuery REST Client - v0.0.7 - https://github.com/jpillora/jquery.rest
  // Jaime Pillora <dev@jpillora.com> - MIT Copyright 2013
  !function(a,b,c,d){"use strict";var e,f,g,h,i,j,k,l,m,n,o,p;k=function(a){throw"ERROR: jquery.rest: "+a},m=function(a){var b;for(b="";a-->0;)b+="  ";return b},j=function(b){return a.btoa||k("You need a polyfill for 'btoa' to use basic auth."),a.btoa(b)},n=function(b){return a.JSON||k("You need a polyfill for 'JSON' to use stringify."),a.JSON.stringify(b)},l=function(a,b){var d;return d=function(){},d.prototype=a,c.extend(!0,new d,b)},o=function(a){return a&&c.isPlainObject(a)?(c.each(a,function(a){return h[a]===d?k("Unknown option: '"+a+"'"):void 0}),null):!1},p=function(a,b){return"string"!==c.type(b)?k("'"+a+"' must be a string"):void 0},i=function(){return alert('"delete()" has been deprecated. Please use "destroy()" or "del()" instead.')},h={url:"",cache:0,request:function(a,b){return c.ajax(b)},cachableMethods:["GET"],methodOverride:!1,stringifyData:!1,stripTrailingSlash:!1,password:null,username:null,verbs:{create:"POST",read:"GET",update:"PUT",destroy:"DELETE"},ajax:{dataType:"json"}},e=function(){function a(a){this.parent=a,this.c={}}return a.prototype.valid=function(a){var b;return b=(new Date).getTime()-a.getTime(),b<=1e3*this.parent.opts.cache},a.prototype.key=function(a){var b,d=this;return b="",c.each(a,function(a,e){return b+=a+"="+(c.isPlainObject(e)?"{"+d.key(e)+"}":e)+"|"}),b},a.prototype.get=function(a){var b;return(b=this.c[a])?this.valid(b.created)?b.data:void 0:void 0},a.prototype.put=function(a,b){return this.c[a]={created:new Date,data:b}},a.prototype.clear=function(a){var b=this;return a?c.each(this.c,function(c){return c.match(a)?delete b.c[c]:void 0}):this.c={}},a}(),g=function(){function a(a,b,d,e){this.name=a,this.method=b,null==d&&(d={}),this.parent=e,p("name",this.name),p("method",this.method),o(d),this.parent[this.name]&&k("Cannot add Verb: '"+a+"' already exists"),this.method=b.toUpperCase(),d.url||(d.url=""),this.opts=l(this.parent.opts,d),this.root=this.parent.root,this.custom=!h.verbs[this.name],this.call=c.proxy(this.call,this),this.call.instance=this}return a.prototype.call=function(){var a,b,c;return c=this.parent.extractUrlData(this.method,arguments),b=c.url,a=c.data,this.custom&&(b+=this.opts.url||this.name),this.parent.ajax.call(this,this.method,b,a)},a.prototype.show=function(a){return console.log(m(a)+this.name+": "+this.method)},a}(),f=function(){function a(b,c,d){null==c&&(c={}),o(c),d&&d instanceof a?(this.name=b,p("name",this.name),this.constructChild(d,c)):(this.url=b||"",p("url",this.url),this.constructRoot(c))}return a.prototype.constructRoot=function(a){return this.opts=l(h,a),this.root=this,this.numParents=0,this.urlNoId=this.url,this.cache=new e(this),this.parent=null,this.name=this.opts.name||"ROOT"},a.prototype.constructChild=function(b,d){return this.parent=b,p("name",this.name),this.parent instanceof a||this.error("Invalid parent"),this.parent[this.name]&&this.error("'"+name+"' already exists"),d.url||(d.url=""),this.opts=l(this.parent.opts,d),this.root=this.parent.root,this.numParents=this.parent.numParents+1,this.urlNoId=this.parent.url+(""+(this.opts.url||this.name)+"/"),this.url=this.urlNoId+(":ID_"+this.numParents+"/"),c.each(this.opts.verbs,c.proxy(this.addVerb,this)),this.destroy?(this.del=this.destroy,this["delete"]=i):void 0},a.prototype.error=function(a){return k("Cannot add Resource: "+a)},a.prototype.add=function(b,c){return this[b]=new a(b,c,this)},a.prototype.addVerb=function(a,b,c){return this[a]=new g(a,b,c,this).call},a.prototype.show=function(b){return null==b&&(b=0),b>25&&k("Plugin Bug! Recursion Fail"),this.name&&console.log(m(b)+this.name+": "+this.url),c.each(this,function(a,d){return"function"===c.type(d)&&d.instance instanceof g&&"del"!==a?d.instance.show(b+1):void 0}),c.each(this,function(c,d){return"parent"!==c&&"root"!==c&&d instanceof a?d.show(b+1):void 0}),null},a.prototype.toString=function(){return this.name},a.prototype.extractUrlData=function(a,b){var d,e,f,g,h,i,j,l,m,n,o,p,q,r,s,t;for(j=[],g=null,n=null,q=0,s=b.length;s>q;q++)d=b[q],o=c.type(d),"string"===o||"number"===o?j.push(d):"object"===o&&null===g?g=d:"object"===o&&null===n?n=d:k("Invalid argument: "+d+" ("+o+")."+" Must be strings or ints (IDs) followed by one optional object and one optional query params object.");for(m=j.length,e="create"!==a,f="update"!==a&&"delete"!==a,p=null,e&&m===this.numParents&&(p=this.url),f&&m===this.numParents-1&&(p=this.urlNoId),null===p&&(f&&(l=this.numParents-1),e&&(l=(l?l+" or ":"")+this.numParents),k("Invalid number of ID arguments, required "+l+", provided "+m)),h=r=0,t=j.length;t>r;h=++r)i=j[h],p=p.replace(new RegExp("/:ID_"+(h+1)+"/"),"/"+i+"/");return n&&(p+="?"+c.param(n)),{url:p,data:g}},a.prototype.ajax=function(a,b,d){var e,f,g,h,i,l,m=this;return a||k("method missing"),b||k("url missing"),g={},this.opts.username&&this.opts.password&&(f=j(this.opts.username+":"+this.opts.password),g.Authorization="Basic "+f),d&&this.opts.stringifyData&&(d=n(d),g["Content-Type"]="application/json"),this.opts.methodOverride&&"GET"!==a&&"HEAD"!==a&&"POST"!==a&&(g["X-HTTP-Method-Override"]=a,a="POST"),this.opts.stripTrailingSlash&&(b=b.replace(/\/$/,"")),e={url:b,type:a,headers:g},d&&(e.data=d),e=c.extend(!0,{},this.opts.ajax,e),l=this.opts.cache&&c.inArray(a,this.opts.cachableMethods)>=0,l&&(h=this.root.cache.key(e),i=this.root.cache.get(h))?i:(i=this.opts.request(this.parent,e),l&&i.done(function(){return m.root.cache.put(h,i)}),i)},a}(),f.defaults=h,c.RestClient=f}(window,document,jQuery);