!function(e,t,r,n){"use strict";t=void0!==t&&t.Math==Math?t:"undefined"!=typeofself&&self.Math==Math?self:Function("return this")();e.api=e.fn.api=function(r){varo,s=e.isFunction(this)?e(t):e(this),i=s.selector||"",a=(newDate).getTime(),u=[],c=arguments[0],d="string"==typeofc,l=[].slice.call(arguments,1);returns.each(function(){vars,g,f,p,m,b,v=e.isPlainObject(r)?e.extend(!0,{},e.fn.api.settings,r):e.extend({},e.fn.api.settings),h=v.namespace,y=v.metadata,q=v.selector,R=v.error,x=v.className,S="."+h,A="module-"+h,k=e(this),T=k.closest(q.form),P=v.stateContext?e(v.stateContext):k,j=this,O=P[0],w=k.data(A);b={initialize:function(){d||b.bind.events(),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),w=b,k.data(A,w)},destroy:function(){b.verbose("Destroying previous module for",j),k.removeData(A).off(S)},bind:{events:function(){vare=b.get.event();e?(b.verbose("Attaching API events to element",e),k.on(e+S,b.event.trigger)):"now"==v.on&&(b.debug("Querying API endpoint immediately"),b.query())}},decode:{json:function(e){if(e!==n&&"string"==typeofe)try{e=JSON.parse(e)}catch(e){}returne}},read:{cachedResponse:function(e){varr;if(t.Storage!==n)returnr=sessionStorage.getItem(e),b.debug("Using cached response",e,r),r=b.decode.json(r);b.error(R.noStorage)}},write:{cachedResponse:function(r,o){o&&""===o?b.debug("Response empty, not caching",o):t.Storage!==n?(e.isPlainObject(o)&&(o=JSON.stringify(o)),sessionStorage.setItem(r,o),b.verbose("Storing cached response for url",r,o)):b.error(R.noStorage)}},query:function(){if(b.is.disabled())b.debug("Element is disabled API request aborted");else{if(b.is.loading()){if(!v.interruptRequests)returnvoidb.debug("Cancelling request, previous request is still pending");b.debug("Interrupting previous request"),b.abort()}if(v.defaultData&&e.extend(!0,v.urlData,b.get.defaultData()),v.serializeForm&&(v.data=b.add.formData(v.data)),!1===(g=b.get.settings()))returnb.cancelled=!0,voidb.error(R.beforeSend);if(b.cancelled=!1,(f=b.get.templatedURL())||b.is.mocked()){if((f=b.add.urlData(f))||b.is.mocked()){if(g.url=v.base+f,s=e.extend(!0,{},v,{type:v.method||v.type,data:p,url:v.base+f,beforeSend:v.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),b.debug("Querying URL",s.url),b.verbose("Using AJAX settings",s),"local"===v.cache&&b.read.cachedResponse(f))returnb.debug("Response returned from local cache"),b.request=b.create.request(),voidb.request.resolveWith(O,[b.read.cachedResponse(f)]);v.throttle?v.throttleFirstRequest||b.timer?(b.debug("Throttling request",v.throttle),clearTimeout(b.timer),b.timer=setTimeout(function(){b.timer&&deleteb.timer,b.debug("Sending throttled request",p,s.method),b.send.request()},v.throttle)):(b.debug("Sending request",p,s.method),b.send.request(),b.timer=setTimeout(function(){},v.throttle)):(b.debug("Sending request",p,s.method),b.send.request())}}elseb.error(R.missingURL)}},should:{removeError:function(){return!0===v.hideError||"auto"===v.hideError&&!b.is.form()}},is:{disabled:function(){returnk.filter(q.disabled).length>0},expectingJSON:function(){return"json"===v.dataType||"jsonp"===v.dataType},form:function(){returnk.is("form")||P.is("form")},mocked:function(){returnv.mockResponse||v.mockResponseAsync||v.response||v.responseAsync},input:function(){returnk.is("input")},loading:function(){return!!b.request&&"pending"==b.request.state()},abortedRequest:function(e){returne&&e.readyState!==n&&0===e.readyState?(b.verbose("XHR request determined to be aborted"),!0):(b.verbose("XHR request was not aborted"),!1)},validResponse:function(t){returnb.is.expectingJSON()&&e.isFunction(v.successTest)?(b.debug("Checking JSON returned success",v.successTest,t),v.successTest(t)?(b.debug("Response passed success test",t),!0):(b.debug("Response failed success test",t),!1)):(b.verbose("Response is not JSON, skipping validation",v.successTest,t),!0)}},was:{cancelled:function(){returnb.cancelled||!1},succesful:function(){returnb.request&&"resolved"==b.request.state()},failure:function(){returnb.request&&"rejected