/*! Angular API Mock v0.3.3 * Licensed with MIT * Made with ♥ from Seriema + Redhorn */ angular.module("apiMock",[]).config(["$httpProvider",function(a){a.interceptors.push("httpInterceptor")}]).provider("apiMock",function(){function a(a){var b=[];return angular.forEach(a,function(a,c){b.push(c)}),b}function b(a){function b(a){return 10>a?"0"+a:a}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+"."+b(a.getUTCMinutes())+"."+b(a.getUTCSeconds())+"."+(a.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"}function c(b,c,d){for(var e=a(b).sort(),f=0;fy.length}function r(a){if(!n(a.url))return a;var b=a.url,c=a.url.replace(o(a.url,x.apiPath),x.mockDataPath),d=c.split("?"),e=d[0],h=d[1]||"";if(!x.stripQueries){var i=g(h),j=angular.extend(a.params||{},i);"/"!==e[e.length-1]&&(e+="/"),e+=angular.lowercase(f(j))}return a.params=void 0,"/"===e[e.length-1]&&(e=e.slice(0,-1)),e+="."+a.method.toLowerCase()+".json",a.method="GET",a.url=e,u.info("apiMock: rerouting "+b+" to "+e),a}function s(a,b,c,d){t=a,u=b,v=c,w=d}var t,u,v,w,x={defaultMock:!1,mockDataPath:"/mock_data",apiPath:"/api",disable:!1,stripQueries:!0,delay:0},y=[],z=s.prototype;z._countFallbacks=function(){return y.length},z.getDelay=function(){return x.delay},z.onRequest=function(a){if(x.disable)return a;var b=j(a),c=k(b);switch(c.type){case"reroute":return r(a);case"recover":return p(a),a;case"respond":return m(c.value);case"ignore":default:return a}},z.onResponse=function(a){return q(a),a},z.recover=function(a){return x.disable?!1:void 0===a.config?!1:q(a.config)?(u.info("apiMock: recovering from failure at "+a.config.url),r(a.config)):!1},this.config=function(a){angular.extend(x,a)},this.$get=["$location","$log","$q","$filter",function(a,b,c,d){return new s(a,b,c,d)}]}).service("httpInterceptor",["$injector","$q","$timeout","apiMock",function(a,b,c,d){this.request=function(a){return d.onRequest(a)},this.response=function(a){var e=b.defer();return c(function(){e.resolve(d.onResponse(a))},d.getDelay(),!0),e.promise},this.responseError=function(e){var f=b.defer();return c(function(){var b=d.recover(e);if(b){var c=a.get("$http");c(b).then(function(a){f.resolve(a)})}else f.reject(e)},d.getDelay(),!0),f.promise}}]);