text: /**
   * stormpath-sdk-angularjs
   * Copyright Stormpath, Inc. 2015
   * 
   * @version v0.7.1-dev-2015-10-08
   * @link https://github.com/stormpath/stormpath-sdk-angularjs
   * @license Apache-2.0
   */
  "undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(a,b){"use strict";b.module("stormpath",["stormpath.CONFIG","stormpath.auth","stormpath.userService"]).factory("SpAuthInterceptor",[function(){function a(){}return a.prototype.request=function(a){return a.withCredentials=!0,a},new a}]).config(["$httpProvider",function(a){a.interceptors.push("SpAuthInterceptor")}]).provider("$stormpath",[function(){this.$get=["$user","$state","STORMPATH_CONFIG","$rootScope",function(a,b,c,d){function e(){var a=new i;return this.encodeUrlForm=a.encode.bind(a),this}function f(a,b){d.$broadcast(c.STATE_CHANGE_UNAUTHENTICATED,a,b)}function g(a,b){d.$broadcast(c.STATE_CHANGE_UNAUTHORIZED,a,b)}function h(b){var c=b;return c&&c.authorize&&c.authorize.group?a.currentUser.inGroup(c.authorize.group):(console.error("Unknown authorize configuration for spStateConfig",b),!1)}function i(){return this.delimiter="&",this.arrayPrefixGenerators={brackets:function(a){return a+"[]"},indices:function(a,b){return a+"["+b+"]"},repeat:function(a){return a}},this}return e.prototype.stateChangeInterceptor=function(c){d.$on("$stateChangeStart",function(d,e,i){var j=e.sp||{};!j.authenticate&&!j.authorize||a.currentUser?j.waitForUser&&null===a.currentUser?(d.preventDefault(),a.get()["finally"](function(){b.go(e.name,i)})):a.currentUser&&j.authorize?h(j)||(d.preventDefault(),g(e,i)):e.name===c.loginState&&a.currentUser&&a.currentUser.href&&(d.preventDefault(),b.go(c.defaultPostLoginState)):(d.preventDefault(),a.get().then(function(){j.authorize?h(j)?b.go(e.name,i):g(e,i):b.go(e.name,i)},function(){f(e,i)}))})},e.prototype.uiRouter=function(a){var e=this;a="object"==typeof a?a:{},this.stateChangeInterceptor(a),a.loginState&&(e.unauthenticatedWather=d.$on(c.STATE_CHANGE_UNAUTHENTICATED,function(c,d,f){e.postLogin={toState:d,toParams:f},b.go(a.loginState)})),d.$on(c.AUTHENTICATION_SUCCESS_EVENT_NAME,function(){e.postLogin&&a.autoRedirect!==!1?b.go(e.postLogin.toState,e.postLogin.toParams).then(function(){e.postLogin=null}):a.defaultPostLoginState&&b.go(a.defaultPostLoginState)}),a.forbiddenState&&(e.forbiddenWatcher=d.$on(c.STATE_CHANGE_UNAUTHORIZED,function(){b.go(a.forbiddenState)}))},e.prototype.regexAttrParser=function(a){var b;return b=a instanceof RegExp?a:a&&/^\/.+\/[gim]?$/.test(a)?new RegExp(a.split("/")[1],a.split("/")[2]):a},i.prototype.stringify=function(a,b,c){if(a instanceof Date?a=a.toISOString():null===a&&(a=""),"string"==typeof a||"number"==typeof a||"boolean"==typeof a)return[encodeURIComponent(b)+"="+encodeURIComponent(a)];var d=[];if("undefined"==typeof a)return d;for(var e=Object.keys(a),f=0,g=e.length;g>f;++f){var h=e[f];d=d.concat(Array.isArray(a)?this.stringify(a[h],c(b,h),c):this.stringify(a[h],b+"["+h+"]",c))}return d},i.prototype.encode=function(a,b){b=b||{};var c="undefined"==typeof b.delimiter?this.delimiter:b.delimiter,d=[];if("object"!=typeof a||null===a)return"";var e;e=b.arrayFormat in this.arrayPrefixGenerators?b.arrayFormat:"indices"in b?b.indices?"indices":"repeat":"indices";for(var f=this.arrayPrefixGenerators[e],g=Object.keys(a),h=0,i=g.length;i>h;++h){var j=g[h];d=d.concat(this.stringify(a[j],j,f))}return d.join(c)},new e}]}]).run(["$rootScope","$user","STORMPATH_CONFIG",function(a,b,c){a.user=b.currentUser||null,b.get()["finally"](function(){a.user=b.currentUser}),a.$on(c.GET_USER_EVENT,function(){a.user=b.currentUser}),a.$on(c.SESSION_END_EVENT,function(){a.user=b.currentUser})}]).directive("ifUser",["$user","$rootScope",function(a,b){return{link:function(a,c){b.$watch("user",function(a){a&&a.href?c.removeClass("ng-hide"):c.addClass("ng-hide")})}}}]).directive("ifNotUser",["$user","$rootScope",function(a,b){return{link:function(a,c){b.$watch("user",function(a){a&&a.href?c.addClass("ng-hide"):c.removeClass("ng-hide")})}}}]).directive("ifUserInGroup",["$user","$rootScope","$parse","$stormpath",function(a,b,c,d){return{link:function(e,f,g){function h(){var b=a.currentUser;b&&b.groupTest(i||j)?f.removeClass("ng-hide"):f.addClass("ng-hide")}var i,j=g.ifUserInGroup;j&&(e.$watch(c(j),function(a){i=d.regexAttrParser(a),h()}),b.$watch("user",function(){h()}))}}}]).directive("ifUserNotInGroup",["$user","$rootScope","$parse","$stormpath",function(a,b,c,d){return{link:function(e,f,g){function h(){var b=a.currentUser;b&&b.groupTest(i||j)?f.addClass("ng-hide"):f.removeClass("ng-hide")}var i,j=g.ifUserNotInGroup;j&&(e.$watch(c(j),function(a){i=d.regexAttrParser(a),h()}),b.$watch("user",function(){h()}))}}}]).directive("whileResolvingUser",["$user","$rootScope",function(a,b){return{link:function(c,d){b.$watch("user",function(){a.currentUser||a.currentUser===!1?d.addClass("ng-hide"):d.removeClass("ng-hide")})}}}]).directive("ifUserStateKnown",["$user","$rootScope",function(a,b){return{link:function(c,d){b.$watch("user",function(){a.currentUser||a.currentUser===!1?d.removeClass("ng-hide"):d.addClass("ng-hide")})}}}]).directive("ifUserStateUnknown",["$user","$rootScope",function(a,b){return{link:function(c,d){b.$watch("user",function(){null===a.currentUser?d.removeClass("ng-hide"):d.addClass("ng-hide")})}}}]).directive("spLogout",["$auth",function(a){return{link:function(b,c){c.on("click",function(){a.endSession()})}}}]),b.module("stormpath.auth",["stormpath.CONFIG"]).config(["$injector","STORMPATH_CONFIG",function(a,b){var c={$get:["$http","$user","$rootScope","$spFormEncoder",function(a,c,d,e){function f(){return this}function g(){return c.get()}function h(a){d.$broadcast(b.AUTHENTICATION_SUCCESS_EVENT_NAME,a)}function i(a){d.$broadcast(b.AUTHENTICATION_FAILURE_EVENT_NAME,a)}return f.prototype.authenticate=function(c){var d=a(e.formPost({url:b.getUrl("AUTHENTICATION_ENDPOINT"),method:"POST",withCredentials:!0,data:c})),f=d.then(g).then(h);return d["catch"](i),f},f.prototype.endSession=function(){var c=a.get(b.getUrl("DESTROY_SESSION_ENDPOINT"));return c.then(function(){d.$broadcast(b.SESSION_END_EVENT)},function(a){console.error("logout error",a)}),c},new f}]};a.get("$provide").provider(b.AUTH_SERVICE_NAME,c)}]),b.module("stormpath.CONFIG",[]).constant("STORMPATH_CONFIG",function(){var a={AUTHENTICATION_SUCCESS_EVENT_NAME:"$authenticated",AUTHENTICATION_FAILURE_EVENT_NAME:"$authenticationFailure",AUTH_SERVICE_NAME:"$auth",AUTHENTICATION_ENDPOINT:"/login",CURRENT_USER_URI:"/me",DESTROY_SESSION_ENDPOINT:"/logout",EMAIL_VERIFICATION_ENDPOINT:"/verify",ENDPOINT_PREFIX:"",FORM_CONTENT_TYPE:"application/x-www-form-urlencoded",GET_USER_EVENT:"$currentUser",NOT_LOGGED_IN_EVENT:"$notLoggedin",FORGOT_PASSWORD_ENDPOINT:"/forgot",CHANGE_PASSWORD_ENDPOINT:"/change",SESSION_END_EVENT:"$sessionEnd",STATE_CHANGE_UNAUTHENTICATED:"$stateChangeUnauthenticated",STATE_CHANGE_UNAUTHORIZED:"$stateChangeUnauthorized",REGISTER_URI:"/register",REGISTERED_EVENT_NAME:"$registered"};return a.getUrl=function(a){return this.ENDPOINT_PREFIX+this[a]},a}()),b.module("stormpath").controller("SpEmailVerificationCtrl",["$scope","$location","$user",function(a,b,c){a.showVerificationError=!1,a.verifying=!1,a.reVerificationSent=!1,a.needsReVerification=!1,a.resendFailed=!1,a.formModel={username:""},b.search().sptoken?(a.verifying=!0,c.verify(b.search().sptoken).then(function(){a.verified=!0})["catch"](function(){a.needsReVerification=!0,a.showVerificationError=!0})["finally"](function(){a.verifying=!1})):(a.needsReVerification=!0,a.showVerificationError=!0),a.submit=function(){a.posting=!0,a.resendFailed=!1,a.showVerificationError=!1,c.resendVerificationEmail({login:a.formModel.username}).then(function(){a.reVerificationSent=!0})["catch"](function(){a.resendFailed=!0})["finally"](function(){a.posting=!1})}}]).directive("spEmailVerification",function(){return{templateUrl:function(a,b){return b.templateUrl||"spEmailVerification.tpl.html"},controller:"SpEmailVerificationCtrl"}}),b.module("stormpath").provider("$spFormEncoder",[function(){this.$get=["STORMPATH_CONFIG",function(a){function b(){var a=new c;return this.encodeUrlForm=a.encode.bind(a),this}function c(){return this.delimiter="&",this.arrayPrefixGenerators={brackets:function(a){return a+"[]"},indices:function(a,b){return a+"["+b+"]"},repeat:function(a){return a}},this}return b.prototype.formPost=function(b){if("application/x-www-form-urlencoded"===a.FORM_CONTENT_TYPE){var c=b.headers?b.headers:b.headers={};c["Content-Type"]=a.FORM_CONTENT_TYPE,b.data=this.encodeUrlForm(b.data)}return b},c.prototype.stringify=function(a,b,c){if(a instanceof Date?a=a.toISOString():null===a&&(a=""),"string"==typeof a||"number"==typeof a||"boolean"==typeof a)return[encodeURIComponent(b)+"="+encodeURIComponent(a)];var d=[];if("undefined"==typeof a)return d;for(var e=Object.keys(a),f=0,g=e.length;g>f;++f){var h=e[f];d=d.concat(Array.isArray(a)?this.stringify(a[h],c(b,h),c):this.stringify(a[h],b+"["+h+"]",c))}return d},c.prototype.encode=function(a,b){b=b||{};var c="undefined"==typeof b.delimiter?this.delimiter:b.delimiter,d=[];if("object"!=typeof a||null===a)return"";var e;e=b.arrayFormat in this.arrayPrefixGenerators?b.arrayFormat:"indices"in b?b.indices?"indices":"repeat":"indices";for(var f=this.arrayPrefixGenerators[e],g=Object.keys(a),h=0,i=g.length;i>h;++h){var j=g[h];d=d.concat(this.stringify(a[j],j,f))}return d.join(c)},new b}]}]),b.module("stormpath").controller("SpLoginFormCtrl",["$scope","$auth",function(a,b){a.formModel={username:"",password:""},a.posting=!1,a.submit=function(){a.posting=!0,a.error=null,b.authenticate(a.formModel)["catch"](function(b){a.posting=!1,a.error=b.data&&b.data.error||"XHR Error"})}}]).directive("spLoginForm",function(){return{templateUrl:function(a,b){return b.templateUrl||"spLoginForm.tpl.html"},controller:"SpLoginFormCtrl"}}),b.module("stormpath").controller("SpPasswordResetRequestCtrl",["$scope","$user",function(a,b){a.sent=!1,a.posting=!1,a.formModel={username:""},a.requestFailed=!1,a.submit=function(){a.posting=!0,a.requestFailed=!1,b.passwordResetRequest({email:a.formModel.email}).then(function(){a.sent=!0})["catch"](function(){a.requestFailed=!0})["finally"](function(){a.posting=!1})}}]).controller("SpPasswordResetCtrl",["$scope","$location","$user",function(a,b,c){var d=b.search().sptoken;a.showVerificationError=!1,a.verifying=!1,a.verified=!1,a.posting=!1,a.reset=!1,a.error=null,a.resendFailed=!1,a.formModel={password:"",confirmPassword:""},"string"==typeof d?(a.verifying=!0,c.verifyPasswordResetToken(d).then(function(){a.verified=!0})["catch"](function(){a.showVerificationError=!0})["finally"](function(){a.verifying=!1})):a.showVerificationError=!0,a.submit=function(){return a.formModel.password!==a.formModel.confirmPassword?void(a.error="Passwords do not match"):(a.posting=!0,a.error=null,a.showVerificationError=!1,void c.resetPassword(d,{password:a.formModel.password}).then(function(){a.reset=!0})["catch"](function(b){a.error=b.data.error})["finally"](function(){a.posting=!1}))}}]).directive("spPasswordResetRequestForm",function(){return{templateUrl:function(a,b){return b.templateUrl||"spPasswordResetRequestForm.tpl.html"},controller:"SpPasswordResetRequestCtrl"}}).directive("spPasswordResetForm",function(){return{templateUrl:function(a,b){return b.templateUrl||"spPasswordResetForm.tpl.html"},controller:"SpPasswordResetCtrl"}}),b.module("stormpath").controller("SpRegistrationFormCtrl",["$scope","$user","$auth","$location",function(a,b,c,d){a.formModel="object"==typeof a.formModel?a.formModel:{givenName:"",surname:"",email:"",password:""},a.created=!1,a.enabled=!1,a.creating=!1,a.authenticating=!1,a.submit=function(){a.creating=!0,a.error=null,b.create(a.formModel).then(function(b){a.created=!0,a.enabled="ENABLED"===b.status,a.enabled&&a.autoLogin?(a.authenticating=!0,c.authenticate({username:a.formModel.email,password:a.formModel.password}).then(function(){a.postLoginPath&&d.path(a.postLoginPath)})["catch"](function(b){a.error=b.data.error})["finally"](function(){a.authenticating=!1,a.creating=!1})):a.creating=!1})["catch"](function(b){a.creating=!1,a.error=b.data.error})}}]).directive("spRegistrationForm",function(){return{templateUrl:function(a,b){return b.templateUrl||"spRegistrationForm.tpl.html"},controller:"SpRegistrationFormCtrl",link:function(a,b,c){a.autoLogin="true"===c.autoLogin,a.postLoginState=c.postLoginState||""}}}),b.module("stormpath.userService",["stormpath.CONFIG"]).provider("$user",[function(){function a(a){var b=this;Object.keys(a).map(function(c){b[c]=a[c]})}a.prototype.inGroup=function(a){return this.groups.items.filter(function(b){return b.name===a}).length>0},a.prototype.matchesGroupExpression=function(a){return this.groups.items.filter(function(b){return a.test(b.name)}).length>0},a.prototype.groupTest=function(a){return a instanceof RegExp&&this.matchesGroupExpression(a)?!0:this.inGroup(a)?!0:!1},this.$get=["$q","$http","STORMPATH_CONFIG","$rootScope","$spFormEncoder",function(b,c,d,e,f){function g(){return this.cachedUserOp=null,this.currentUser=null,this}function h(a){e.$broadcast(d.REGISTERED_EVENT_NAME,a)}function i(a){e.$broadcast(d.GET_USER_EVENT,a)}function j(){e.$broadcast(d.NOT_LOGGED_IN_EVENT)}g.prototype.create=function(a){var e=b.defer();return c(f.formPost({url:d.getUrl("REGISTER_URI"),method:"POST",data:a})).then(function(a){e.resolve(a.data),h(a.data)},e.reject),e.promise},g.prototype.get=function(){var e=b.defer(),f=this;return f.cachedUserOp?f.cachedUserOp.promise:null!==f.currentUser&&f.currentUser!==!1?(e.resolve(f.currentUser),e.promise):(f.cachedUserOp=e,c.get(d.getUrl("CURRENT_USER_URI"),{withCredentials:!0}).then(function(b){f.cachedUserOp=null,f.currentUser=new a(b.data),i(f.currentUser),e.resolve(f.currentUser)},function(a){f.currentUser=!1,401===a.status&&j(),f.cachedUserOp=null,e.reject(a)}),e.promise)},g.prototype.resendVerificationEmail=function(a){return c({method:"POST",url:d.getUrl("EMAIL_VERIFICATION_ENDPOINT"),data:a})},g.prototype.verify=function(a){return c({url:d.getUrl("EMAIL_VERIFICATION_ENDPOINT")+"?sptoken="+a})},g.prototype.verifyPasswordResetToken=function(a){return c.get(d.getUrl("CHANGE_PASSWORD_ENDPOINT")+"?sptoken="+a)},g.prototype.passwordResetRequest=function(a){return c(f.formPost({method:"POST",url:d.getUrl("FORGOT_PASSWORD_ENDPOINT"),data:a}))},g.prototype.resetPassword=function(a,b){return b.sptoken=a,c(f.formPost({method:"POST",url:d.getUrl("CHANGE_PASSWORD_ENDPOINT"),data:b}))};var k=new g;return e.$on(d.SESSION_END_EVENT,function(){k.currentUser=!1}),k}]}])}(window,window.angular);