UNPKG

@uirouter/core

Version:

UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps

7 lines 94.2 kB
/** * UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps * @version v6.1.0 * @link https://ui-router.github.io * @license MIT License, http://www.opensource.org/licenses/MIT */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self)["@uirouter/core"]={})}(this,function(v){"use strict";var n=function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),i=0;for(e=0;e<r;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n};function c(r){return function t(){if(arguments.length>=r.length)return r.apply(this,arguments);var e=Array.prototype.slice.call(arguments);return t.bind.apply(t,n([this],e))}}function r(){var r=arguments,n=r.length-1;return function(){for(var t=n,e=r[n].apply(this,arguments);t--;)e=r[t].call(this,e);return e}}function u(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.apply(null,[].slice.call(arguments).reverse())}var _=function(e){return function(t){return t&&t[e]}},g=c(function(t,e,r){return r&&r[t]===e}),a=function(t){return u.apply(null,t.split(".").map(_))},h=function(r){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return!r.apply(null,t)}};function t(r,n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.apply(null,t)&&n.apply(null,t)}}function s(r,n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.apply(null,t)||n.apply(null,t)}}var f=function(r){return function(t){return t.reduce(function(t,e){return t&&!!r(e)},!0)}},p=function(r){return function(t){return t.reduce(function(t,e){return t||!!r(e)},!1)}},l=function(e){return function(t){return null!=t&&t.constructor===e||t instanceof e}},d=function(t){return function(){return t}};function y(r){return function(t){for(var e=0;e<r.length;e++)if(r[e][0](t))return r[e][1](t)}}var e=Object.prototype.toString,i=function(e){return function(t){return typeof t===e}},o=i("undefined"),m=h(o),w=function(t){return null===t},b=s(w,o),E=i("function"),S=i("number"),R=i("string"),T=function(t){return null!==t&&"object"==typeof t},C=Array.isArray,P=function(t){return"[object Date]"===e.call(t)},k=function(t){return"[object RegExp]"===e.call(t)};function O(t){if(C(t)&&t.length){var e=t.slice(0,-1),r=t.slice(-1);return!(e.filter(h(R)).length||r.filter(h(E)).length)}return E(t)}var $=t(T,u(_("then"),E)),x=function(n,t){return t.reduce(function(t,e){return t[e]=(r=n+"."+e+"()",function(){throw new Error("No implementation for "+r+". The framework specific code did not implement this method.")}),t;var r},{})},H={$q:void 0,$injector:void 0},I=function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),i=0;for(e=0;e<r;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)n[i]=o[a];return n},V="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||void 0,j=V.angular||{},A=j.fromJson||JSON.parse.bind(JSON),D=j.toJson||JSON.stringify.bind(JSON),N=j.forEach||function(e,r,t){if(C(e))return e.forEach(r,t);Object.keys(e).forEach(function(t){return r(e[t],t)})},q=Object.assign||Et,F=j.equals||St;function U(t){return t}function L(){}function M(e,n,r,t,i){void 0===i&&(i=!1);var o=function(t){return e()[t].bind(r())};return(t=t||Object.keys(e())).reduce(function(t,e){var r;return t[e]=i?(r=e,function(){return n[r]=o(r),n[r].apply(null,arguments)}):o(e),t},n)}var G=function(t,e){return q(Object.create(t),e)},B=c(z);function z(t,e){return-1!==t.indexOf(e)}var W=c(J);function J(t,e){var r=t.indexOf(e);return 0<=r&&t.splice(r,1),t}var Q=c(Y);function Y(t,e){return t.push(e),e}var K=function(e){return e.slice().forEach(function(t){"function"==typeof t&&t(),W(e,t)})};function Z(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];var n=q.apply(void 0,I([{}],e.reverse()));return q(n,et(t||{},Object.keys(n)))}var X=function(t,e){return q(t,e)};function tt(t,e){var r=[];for(var n in t.path){if(t.path[n]!==e.path[n])break;r.push(t.path[n])}return r}function et(t,e){var r={};for(var n in t)-1!==e.indexOf(n)&&(r[n]=t[n]);return r}function rt(r,t){return Object.keys(r).filter(h(B(t))).reduce(function(t,e){return t[e]=r[e],t},{})}function nt(t,r){var e=C(t),n=e?[]:{},i=e?function(t){return n.push(t)}:function(t,e){return n[e]=t};return N(t,function(t,e){r(t,e)&&i(t,e)}),n}function it(t,r){var n;return N(t,function(t,e){n||r(t,e)&&(n=t)}),n}var ot=at;function at(t,r,n){return n=n||(C(t)?[]:{}),N(t,function(t,e){return n[e]=r(t,e)}),n}var st=function(e){return Object.keys(e).map(function(t){return e[t]})},ut=function(t,e){return t&&e},ct=function(t,e){return t||e},ft=function(t,e){return t.concat(e)},ht=function(t,e){return C(e)?t.concat(e.reduce(ht,[])):pt(t,e)};function pt(t,e){return t.push(e),t}var lt=function(t,e){return B(t,e)?t:pt(t,e)},dt=function(t){return t.reduce(ft,[])},vt=gt,yt=gt;function gt(r,n){return void 0===n&&(n="assert failure"),function(t){var e=r(t);if(!e)throw new Error(E(n)?n(t):n);return e}}function mt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return[];for(var r=t.reduce(function(t,e){return Math.min(e.length,t)},9007199254740991),n=[],i=function(e){switch(t.length){case 1:n.push([t[0][e]]);break;case 2:n.push([t[0][e],t[1][e]]);break;case 3:n.push([t[0][e],t[1][e],t[2][e]]);break;case 4:n.push([t[0][e],t[1][e],t[2][e],t[3][e]]);break;default:n.push(t.map(function(t){return t[e]}))}},o=0;o<r;o++)i(o);return n}function _t(t,e){var r,n;if(C(e)&&(r=e[0],n=e[1]),!R(r))throw new Error("invalid parameters to applyPairs");return t[r]=n,t}function wt(t){return t.length&&t[t.length-1]||void 0}function bt(t,e){return e&&Object.keys(e).forEach(function(t){return delete e[t]}),e||(e={}),q(e,t)}function Et(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var n=Object.keys(r),i=0;i<n.length;i++)t[n[i]]=r[n[i]]}return t}function St(t,e){if(t===e)return!0;if(null===t||null===e)return!1;if(t!=t&&e!=e)return!0;var r=typeof t;if(r!==typeof e||"object"!==r)return!1;var n,i,o=[t,e];if(f(C)(o))return i=e,(n=t).length===i.length&&mt(n,i).reduce(function(t,e){return t&&St(e[0],e[1])},!0);if(f(P)(o))return t.getTime()===e.getTime();if(f(k)(o))return t.toString()===e.toString();if(f(E)(o))return!0;if([E,C,P,k].map(p).reduce(function(t,e){return t||!!e(o)},!1))return!1;var a={};for(var s in t){if(!St(t[s],e[s]))return!1;a[s]=!0}for(var s in e)if(!a[s])return!1;return!0}var Rt,Tt=function(t){return t.catch(function(t){return 0})&&t},Ct=function(t){return Tt(H.$q.reject(t))},Pt=function(){function e(t){this.text=t,this.glob=t.split(".");var e=this.text.split(".").map(function(t){return"**"===t?"(?:|(?:\\.[^.]*)*)":"*"===t?"\\.[^.]*":"\\."+t}).join("");this.regexp=new RegExp("^"+e+"$")}return e.is=function(t){return!!/[!,*]+/.exec(t)},e.fromString=function(t){return e.is(t)?new e(t):null},e.prototype.matches=function(t){return this.regexp.test("."+t)},e}(),kt=function(){function t(t,e){void 0===t&&(t=[]),void 0===e&&(e=null),this._items=t,this._limit=e,this._evictListeners=[],this.onEvict=Q(this._evictListeners)}return t.prototype.enqueue=function(t){var e=this._items;return e.push(t),this._limit&&e.length>this._limit&&this.evict(),t},t.prototype.evict=function(){var e=this._items.shift();return this._evictListeners.forEach(function(t){return t(e)}),e},t.prototype.dequeue=function(){if(this.size())return this._items.splice(0,1)[0]},t.prototype.clear=function(){var t=this._items;return this._items=[],t},t.prototype.size=function(){return this._items.length},t.prototype.remove=function(t){var e=this._items.indexOf(t);return-1<e&&this._items.splice(e,1)[0]},t.prototype.peekTail=function(){return this._items[this._items.length-1]},t.prototype.peekHead=function(){if(this.size())return this._items[0]},t}();(Rt=v.RejectType||(v.RejectType={}))[Rt.SUPERSEDED=2]="SUPERSEDED",Rt[Rt.ABORTED=3]="ABORTED",Rt[Rt.INVALID=4]="INVALID",Rt[Rt.IGNORED=5]="IGNORED",Rt[Rt.ERROR=6]="ERROR";var Ot=0,$t=function(){function n(t,e,r){this.$id=Ot++,this.type=t,this.message=e,this.detail=r}return n.isRejectionPromise=function(t){return t&&"function"==typeof t.then&&l(n)(t._transitionRejection)},n.superseded=function(t,e){var r=new n(v.RejectType.SUPERSEDED,"The transition has been superseded by a different transition",t);return e&&e.redirected&&(r.redirected=!0),r},n.redirected=function(t){return n.superseded(t,{redirected:!0})},n.invalid=function(t){return new n(v.RejectType.INVALID,"This transition is invalid",t)},n.ignored=function(t){return new n(v.RejectType.IGNORED,"The transition was ignored",t)},n.aborted=function(t){return new n(v.RejectType.ABORTED,"The transition has been aborted",t)},n.errored=function(t){return new n(v.RejectType.ERROR,"The transition errored",t)},n.normalize=function(t){return l(n)(t)?t:n.errored(t)},n.prototype.toString=function(){var t,e=(t=this.detail)&&t.toString!==Object.prototype.toString?t.toString():jt(t);return"Transition Rejection($id: "+this.$id+" type: "+this.type+", message: "+this.message+", detail: "+e+")"},n.prototype.toPromise=function(){return q(Ct(this),{_transitionRejection:this})},n}();function xt(t,e){return e.length<=t?e:e.substr(0,t-3)+"..."}function Ht(t,e){for(;e.length<t;)e+=" ";return e}function It(t){var e=Vt(t),r=e.match(/^(function [^ ]+\([^)]*\))/),n=r?r[1]:e,i=t.name||"";return i&&n.match(/function \(/)?"function "+i+n.substr(9):n}function Vt(t){var e=C(t)?t.slice(-1)[0]:t;return e&&e.toString()||"undefined"}function jt(t){var e=[],r=$t.isRejectionPromise,n=y([[o,d("undefined")],[w,d("null")],[$,d("[Promise]")],[r,function(t){return t._transitionRejection.toString()}],[function(t){return T(t)&&!C(t)&&t.constructor!==Object&&E(t.toString)},function(t){return t.toString()}],[O,It],[d(!0),U]]);function i(t){if(T(t)){if(-1!==e.indexOf(t))return"[circular ref]";e.push(t)}return n(t)}return o(t)?i(t):JSON.stringify(t,function(t,e){return i(e)}).replace(/\\"/g,'"')}var At=function(r){return function(t){if(!t)return["",""];var e=t.indexOf(r);return-1===e?[t,""]:[t.substr(0,e),t.substr(e+1)]}},Dt=new RegExp("^(?:[a-z]+:)?//[^/]+/"),Nt=function(t){return t.replace(/\/[^/]*$/,"")},qt=At("#"),Ft=At("?"),Ut=At("="),Lt=function(t){return t?t.replace(/^#/,""):""};function Mt(t){var e=new RegExp("("+t+")","g");return function(t){return t.split(e).filter(U)}}function Gt(t,e){return R(wt(t))&&R(e)?t.slice(0,-1).concat(wt(t)+e):pt(t,e)}var Bt={log:L,error:L,table:L};var zt,Wt,Jt,Qt,Yt="undefined"!=typeof document&&document.documentMode&&9===document.documentMode?window&&window.console?(Jt=window.console,{log:(Qt=function(t){return Function.prototype.bind.call(t,Jt)})(Jt.log),error:Qt(Jt.log),table:Qt(Jt.log)}):Bt:console.table&&console.error?console:(zt=console,{log:Wt=zt.log.bind(zt),error:zt.error?zt.error.bind(zt):Wt,table:zt.table?zt.table.bind(zt):Wt});function Kt(t){if(!t)return"ui-view (defunct)";var e=t.creationContext?t.creationContext.name||"(root)":"(none)";return"[ui-view#"+t.id+" "+t.$type+":"+t.fqn+" ("+t.name+"@"+e+")]"}var Zt;function Xt(t){return S(t)?v.Category[t]:v.Category[v.Category[t]]}(Zt=v.Category||(v.Category={}))[Zt.RESOLVE=0]="RESOLVE",Zt[Zt.TRANSITION=1]="TRANSITION",Zt[Zt.HOOK=2]="HOOK",Zt[Zt.UIVIEW=3]="UIVIEW",Zt[Zt.VIEWCONFIG=4]="VIEWCONFIG";var te=a("$id"),ee=a("router.$id"),re=function(t){return"Transition #"+te(t)+"-"+ee(t)},ne=function(){function t(){this._enabled={},this.approximateDigests=0}return t.prototype._set=function(e,t){var r=this;t.length||(t=Object.keys(v.Category).map(function(t){return parseInt(t,10)}).filter(function(t){return!isNaN(t)}).map(function(t){return v.Category[t]})),t.map(Xt).forEach(function(t){return r._enabled[t]=e})},t.prototype.enable=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._set(!0,t)},t.prototype.disable=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._set(!1,t)},t.prototype.enabled=function(t){return!!this._enabled[Xt(t)]},t.prototype.traceTransitionStart=function(t){this.enabled(v.Category.TRANSITION)&&Yt.log(re(t)+": Started -> "+jt(t))},t.prototype.traceTransitionIgnored=function(t){this.enabled(v.Category.TRANSITION)&&Yt.log(re(t)+": Ignored <> "+jt(t))},t.prototype.traceHookInvocation=function(t,e,r){if(this.enabled(v.Category.HOOK)){var n=a("traceData.hookType")(r)||"internal",i=a("traceData.context.state.name")(r)||a("traceData.context")(r)||"unknown",o=It(t.registeredHook.callback);Yt.log(re(e)+": Hook -> "+n+" context: "+i+", "+xt(200,o))}},t.prototype.traceHookResult=function(t,e,r){this.enabled(v.Category.HOOK)&&Yt.log(re(e)+": <- Hook returned: "+xt(200,jt(t)))},t.prototype.traceResolvePath=function(t,e,r){this.enabled(v.Category.RESOLVE)&&Yt.log(re(r)+": Resolving "+t+" ("+e+")")},t.prototype.traceResolvableResolved=function(t,e){this.enabled(v.Category.RESOLVE)&&Yt.log(re(e)+": <- Resolved "+t+" to: "+xt(200,jt(t.data)))},t.prototype.traceError=function(t,e){this.enabled(v.Category.TRANSITION)&&Yt.log(re(e)+": <- Rejected "+jt(e)+", reason: "+t)},t.prototype.traceSuccess=function(t,e){this.enabled(v.Category.TRANSITION)&&Yt.log(re(e)+": <- Success "+jt(e)+", final state: "+t.name)},t.prototype.traceUIViewEvent=function(t,e,r){void 0===r&&(r=""),this.enabled(v.Category.UIVIEW)&&Yt.log("ui-view: "+Ht(30,t)+" "+Kt(e)+r)},t.prototype.traceUIViewConfigUpdated=function(t,e){this.enabled(v.Category.UIVIEW)&&this.traceUIViewEvent("Updating",t," with ViewConfig from context='"+e+"'")},t.prototype.traceUIViewFill=function(t,e){this.enabled(v.Category.UIVIEW)&&this.traceUIViewEvent("Fill",t," with: "+xt(200,e))},t.prototype.traceViewSync=function(t){if(this.enabled(v.Category.VIEWCONFIG)){var a="uiview component fqn",e=t.map(function(t){var e,r=t.uiView,n=t.viewConfig,i=r&&r.fqn,o=n&&n.viewDecl.$context.name+": ("+n.viewDecl.$name+")";return(e={})[a]=i,e["view config state (view name)"]=o,e}).sort(function(t,e){return(t[a]||"").localeCompare(e[a]||"")});Yt.table(e)}},t.prototype.traceViewServiceEvent=function(t,e){var r,n,i;this.enabled(v.Category.VIEWCONFIG)&&Yt.log("VIEWCONFIG: "+t+" "+(n=(r=e).viewDecl,i=n.$context.name||"(root)","[View#"+r.$id+" from '"+i+"' state]: target ui-view: '"+n.$uiViewName+"@"+n.$uiViewContextAnchor+"'"))},t.prototype.traceViewServiceUIViewEvent=function(t,e){this.enabled(v.Category.VIEWCONFIG)&&Yt.log("VIEWCONFIG: "+t+" "+Kt(e))},t}(),ie=new ne,oe=function(){function t(t){this.pattern=/.*/,this.inherit=!0,q(this,t)}return t.prototype.is=function(t,e){return!0},t.prototype.encode=function(t,e){return t},t.prototype.decode=function(t,e){return t},t.prototype.equals=function(t,e){return t==e},t.prototype.$subPattern=function(){var t=this.pattern.toString();return t.substr(1,t.length-2)},t.prototype.toString=function(){return"{ParamType:"+this.name+"}"},t.prototype.$normalize=function(t){return this.is(t)?t:this.decode(t)},t.prototype.$asArray=function(t,e){if(!t)return this;if("auto"===t&&!e)throw new Error("'auto' array mode is for query parameters only");return new ae(this,t)},t}();function ae(n,i){var o=this;function a(t){return C(t)?t:m(t)?[t]:[]}function s(r,n){return function(t){if(C(t)&&0===t.length)return t;var e=at(a(t),r);return!0===n?0===nt(e,function(t){return!t}).length:function(t){switch(t.length){case 0:return;case 1:return"auto"===i?t[0]:t;default:return t}}(e)}}function u(o){return function(t,e){var r=a(t),n=a(e);if(r.length!==n.length)return!1;for(var i=0;i<r.length;i++)if(!o(r[i],n[i]))return!1;return!0}}["encode","decode","equals","$normalize"].forEach(function(t){var e=n[t].bind(n),r="equals"===t?u:s;o[t]=r(e)}),q(this,{dynamic:n.dynamic,name:n.name,pattern:n.pattern,inherit:n.inherit,raw:n.raw,is:s(n.is.bind(n),!0),$arrayMode:i})}var se,ue=Object.prototype.hasOwnProperty,ce=function(t){return 0===["value","type","squash","array","dynamic"].filter(ue.bind(t||{})).length};function fe(t,e,r){var n=!1===r.reloadOnSearch&&e===v.DefType.SEARCH||void 0,i=it([r.dynamic,n],m),o=m(i)?{dynamic:i}:{},a=function(t){function e(){return t.value}t=ce(t)?{value:t}:t,e.__cacheable=!0;var r=O(t.value)?t.value:e;return q(t,{$$fn:r})}(r&&r.params&&r.params[t]);return q(o,a)}(se=v.DefType||(v.DefType={}))[se.PATH=0]="PATH",se[se.SEARCH=1]="SEARCH",se[se.CONFIG=2]="CONFIG";var he,pe=function(){function n(t,e,r,n,i){var o=fe(t,r,i);e=function(t,e,r,n,i){if(t.type&&e&&"string"!==e.name)throw new Error("Param '"+n+"' has two type configurations.");if(t.type&&e&&"string"===e.name&&i.type(t.type))return i.type(t.type);if(e)return e;if(t.type)return t.type instanceof oe?t.type:i.type(t.type);var o=r===v.DefType.CONFIG?"any":r===v.DefType.PATH?"path":r===v.DefType.SEARCH?"query":"string";return i.type(o)}(o,e,r,t,n.paramTypes);var a,s,u=(a={array:r===v.DefType.SEARCH&&"auto"},s=t.match(/\[\]$/)?{array:!0}:{},q(a,s,o).array);e=u?e.$asArray(u,r===v.DefType.SEARCH):e;var c=void 0!==o.value||r===v.DefType.SEARCH,f=m(o.dynamic)?!!o.dynamic:!!e.dynamic,h=m(o.raw)?!!o.raw:!!e.raw,p=function(t,e,r){var n=t.squash;if(!e||!1===n)return!1;if(!m(n)||null==n)return r;if(!0===n||R(n))return n;throw new Error("Invalid squash policy: '"+n+"'. Valid policies: false, true, or arbitrary string")}(o,c,n.defaultSquashPolicy()),l=function(t,e,r,n){var i=[{from:"",to:r||e?void 0:""},{from:null,to:r||e?void 0:""}],o=C(t.replace)?t.replace:[];R(n)&&o.push({from:n,to:void 0});var a=at(o,_("from"));return nt(i,function(t){return-1===a.indexOf(t.from)}).concat(o)}(o,u,c,p),d=m(o.inherit)?!!o.inherit:!!e.inherit;q(this,{id:t,type:e,location:r,isOptional:c,dynamic:f,raw:h,squash:p,replace:l,inherit:d,array:u,config:o})}return n.values=function(t,e){void 0===e&&(e={});for(var r={},n=0,i=t;n<i.length;n++){var o=i[n];r[o.id]=o.value(e[o.id])}return r},n.changed=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),t.filter(function(t){return!t.type.equals(e[t.id],r[t.id])})},n.equals=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),0===n.changed(t,e,r).length},n.validates=function(t,e){return void 0===e&&(e={}),t.map(function(t){return t.validates(e[t.id])}).reduce(ut,!0)},n.prototype.isDefaultValue=function(t){return this.isOptional&&this.type.equals(this.value(),t)},n.prototype.value=function(t){var i=this;return t=function(t){for(var e=0,r=i.replace;e<r.length;e++){var n=r[e];if(n.from===t)return n.to}return t}(t),o(t)?function(){if(i._defaultValueCache)return i._defaultValueCache.defaultValue;if(!H.$injector)throw new Error("Injectable functions cannot be called at configuration time");var t=H.$injector.invoke(i.config.$$fn);if(null!=t&&!i.type.is(t))throw new Error("Default value ("+t+") for parameter '"+i.id+"' is not an instance of ParamType ("+i.type.name+")");return i.config.$$fn.__cacheable&&(i._defaultValueCache={defaultValue:t}),t}():this.type.$normalize(t)},n.prototype.isSearch=function(){return this.location===v.DefType.SEARCH},n.prototype.validates=function(t){if((o(t)||null===t)&&this.isOptional)return!0;var e=this.type.$normalize(t);if(!this.type.is(e))return!1;var r=this.type.encode(e);return!(R(r)&&!this.type.pattern.exec(r))},n.prototype.toString=function(){return"{Param:"+this.id+" "+this.type+" squash: '"+this.squash+"' optional: "+this.isOptional+"}"},n}(),le=function(){function t(){this.enqueue=!0,this.typeQueue=[],this.defaultTypes=et(t.prototype,["hash","string","query","path","int","bool","date","json","any"]);this.types=G(at(this.defaultTypes,function(t,e){return new oe(q({name:e},t))}),{})}return t.prototype.dispose=function(){this.types={}},t.prototype.type=function(t,e,r){if(!m(e))return this.types[t];if(this.types.hasOwnProperty(t))throw new Error("A type named '"+t+"' has already been defined.");return this.types[t]=new oe(q({name:t},e)),r&&(this.typeQueue.push({name:t,def:r}),this.enqueue||this._flushTypeQueue()),this},t.prototype._flushTypeQueue=function(){for(;this.typeQueue.length;){var t=this.typeQueue.shift();if(t.pattern)throw new Error("You cannot override a type's .pattern at runtime.");q(this.types[t.name],H.$injector.invoke(t.def))}},t}();he=function(t){var e=function(t){return null!=t?t.toString():t},r={encode:e,decode:e,is:l(String),pattern:/.*/,equals:function(t,e){return t==e}};return q({},r,t)},q(le.prototype,{string:he({}),path:he({pattern:/[^/]*/}),query:he({}),hash:he({inherit:!1}),int:he({decode:function(t){return parseInt(t,10)},is:function(t){return!b(t)&&this.decode(t.toString())===t},pattern:/-?\d+/}),bool:he({encode:function(t){return t?1:0},decode:function(t){return 0!==parseInt(t,10)},is:l(Boolean),pattern:/0|1/}),date:he({encode:function(t){return this.is(t)?[t.getFullYear(),("0"+(t.getMonth()+1)).slice(-2),("0"+t.getDate()).slice(-2)].join("-"):void 0},decode:function(t){if(this.is(t))return t;var e=this.capture.exec(t);return e?new Date(e[1],e[2]-1,e[3]):void 0},is:function(t){return t instanceof Date&&!isNaN(t.valueOf())},equals:function(r,n){return["getFullYear","getMonth","getDate"].reduce(function(t,e){return t&&r[e]()===n[e]()},!0)},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/}),json:he({encode:D,decode:A,is:l(Object),equals:F,pattern:/[^/]*/}),any:he({encode:U,decode:U,is:function(){return!0},equals:F})});var de=function(){function t(t){void 0===t&&(t={}),q(this,t)}return t.prototype.$inherit=function(t,e,r){var n=tt(e,r),i={},o=[];for(var a in n)if(n[a]&&n[a].params){var s=n[a].params,u=Object.keys(s);if(u.length)for(var c in u)0==s[u[c]].inherit||0<=o.indexOf(u[c])||(o.push(u[c]),i[u[c]]=this[u[c]])}return q({},i,t)},t}(),ve=function(){function n(t){if(t instanceof n){var e=t;this.state=e.state,this.paramSchema=e.paramSchema.slice(),this.paramValues=q({},e.paramValues),this.resolvables=e.resolvables.slice(),this.views=e.views&&e.views.slice()}else{var r=t;this.state=r,this.paramSchema=r.parameters({inherit:!1}),this.paramValues={},this.resolvables=r.resolvables.map(function(t){return t.clone()})}}return n.prototype.clone=function(){return new n(this)},n.prototype.applyRawParams=function(n){return this.paramValues=this.paramSchema.reduce(function(t,e){return _t(t,[(r=e).id,r.value(n[r.id])]);var r},{}),this},n.prototype.parameter=function(t){return it(this.paramSchema,g("id",t))},n.prototype.equals=function(t,e){var r=this.diff(t,e);return r&&0===r.length},n.prototype.diff=function(t,e){if(this.state!==t.state)return!1;var r=e?e(this):this.paramSchema;return pe.changed(r,this.paramValues,t.paramValues)},n.clone=function(t){return t.clone()},n}(),ye=function(){function n(t,e,r,n){this._stateRegistry=t,this._identifier=e,this._identifier=e,this._params=q({},r||{}),this._options=q({},n||{}),this._definition=t.matcher.find(e,this._options.relative)}return n.prototype.name=function(){return this._definition&&this._definition.name||this._identifier},n.prototype.identifier=function(){return this._identifier},n.prototype.params=function(){return this._params},n.prototype.$state=function(){return this._definition},n.prototype.state=function(){return this._definition&&this._definition.self},n.prototype.options=function(){return this._options},n.prototype.exists=function(){return!(!this._definition||!this._definition.self)},n.prototype.valid=function(){return!this.error()},n.prototype.error=function(){var t=this.options().relative;if(this._definition||!t)return this._definition?this._definition.self?void 0:"State '"+this.name()+"' has an invalid definition":"No such state '"+this.name()+"'";var e=t.name?t.name:t;return"Could not resolve '"+this.name()+"' from state '"+e+"'"},n.prototype.toString=function(){return"'"+this.name()+"'"+jt(this.params())},n.prototype.withState=function(t){return new n(this._stateRegistry,t,this._params,this._options)},n.prototype.withParams=function(t,e){void 0===e&&(e=!1);var r=e?t:q({},this._params,t);return new n(this._stateRegistry,this._identifier,r,this._options)},n.prototype.withOptions=function(t,e){void 0===e&&(e=!1);var r=e?t:q({},this._options,t);return new n(this._stateRegistry,this._identifier,this._params,r)},n.isDef=function(t){return t&&t.state&&(R(t.state)||T(t.state)&&R(t.state.name))},n}(),ge=function(){function p(){}return p.makeTargetState=function(t,e){var r=wt(e).state;return new ye(t,r,e.map(_("paramValues")).reduce(X,{}),{})},p.buildPath=function(t){var e=t.params();return t.$state().path.map(function(t){return new ve(t).applyRawParams(e)})},p.buildToPath=function(t,e){var r=p.buildPath(e);return e.options().inherit?p.inheritParams(t,r,Object.keys(e.params())):r},p.applyViewConfigs=function(i,o,e){o.filter(function(t){return B(e,t.state)}).forEach(function(e){var t=st(e.state.views||{}),r=p.subPath(o,function(t){return t===e}),n=t.map(function(t){return i.createViewConfig(r,t)});e.views=n.reduce(ft,[])})},p.inheritParams=function(u,t,c){void 0===c&&(c=[]);var f=u.map(function(t){return t.paramSchema}).reduce(ft,[]).filter(function(t){return!t.inherit}).map(_("id"));return t.map(function(t){var e=q({},t&&t.paramValues),r=et(e,c);e=rt(e,c);var n,i,o,a=rt((n=u,i=t.state,o=it(n,g("state",i)),q({},o&&o.paramValues)||{}),f),s=q(e,a,r);return new ve(t.state).applyRawParams(s)})},p.treeChanges=function(t,n,e){for(var r,i,o,a,s,u,c=Math.min(t.length,n.length),f=0;f<c&&t[f].state!==e&&(r=t[f],i=n[f],r.equals(i,p.nonDynamicParams));)f++;a=(o=t).slice(0,f),s=o.slice(f);var h=a.map(function(t,e){var r=t.clone();return r.paramValues=n[e].paramValues,r});return u=n.slice(f),{from:o,to:h.concat(u),retained:a,retainedWithToParams:h,exiting:s,entering:u}},p.matching=function(t,e,i){var o=!1;return mt(t,e).reduce(function(t,e){var r=e[0],n=e[1];return(o=o||!r.equals(n,i))?t:t.concat(r)},[])},p.equals=function(t,e,r){return t.length===e.length&&p.matching(t,e,r).length===t.length},p.subPath=function(t,e){var r=it(t,e),n=t.indexOf(r);return-1===n?void 0:t.slice(0,n+1)},p.nonDynamicParams=function(t){return t.state.parameters({inherit:!1}).filter(function(t){return!t.dynamic})},p.paramValues=function(t){return t.reduce(function(t,e){return q(t,e.paramValues)},{})},p}(),me={when:{LAZY:"LAZY",EAGER:"EAGER"},async:{WAIT:"WAIT",NOWAIT:"NOWAIT"}},_e={when:"LAZY",async:"WAIT"},we=function(){function a(t,e,r,n,i){if(this.resolved=!1,this.promise=void 0,t instanceof a)q(this,t);else if(E(e)){if(b(t))throw new Error("new Resolvable(): token argument is required");if(!E(e))throw new Error("new Resolvable(): resolveFn argument must be a function");this.token=t,this.policy=n,this.resolveFn=e,this.deps=r||[],this.data=i,this.resolved=void 0!==i,this.promise=this.resolved?H.$q.when(this.data):void 0}else if(T(t)&&t.token&&(t.hasOwnProperty("resolveFn")||t.hasOwnProperty("data"))){var o=t;return new a(o.token,o.resolveFn,o.deps,o.policy,o.data)}}return a.prototype.getPolicy=function(t){var e=this.policy||{},r=t&&t.resolvePolicy||{};return{when:e.when||r.when||_e.when,async:e.async||r.async||_e.async}},a.prototype.resolve=function(e,r){var n=this,t=H.$q,i=e.findNode(this),o=i&&i.state,a=this.getPolicy(o).async,s=E(a)?a:U;return this.promise=t.when().then(function(){return t.all(e.getDependencies(n).map(function(t){return t.get(e,r)}))}).then(function(t){return n.resolveFn.apply(null,t)}).then(s).then(function(t){return n.data=t,n.resolved=!0,n.resolveFn=null,ie.traceResolvableResolved(n,r),n.data})},a.prototype.get=function(t,e){return this.promise||this.resolve(t,e)},a.prototype.toString=function(){return"Resolvable(token: "+jt(this.token)+", requires: ["+this.deps.map(jt)+"])"},a.prototype.clone=function(){return new a(this)},a.fromData=function(t,e){return new a(t,function(){return e},null,null,e)},a}(),be=me.when,Ee=[be.EAGER,be.LAZY],Se=[be.EAGER],Re="Native Injector",Te=function(){function t(t){this._path=t}return t.prototype.getTokens=function(){return this._path.reduce(function(t,e){return t.concat(e.resolvables.map(function(t){return t.token}))},[]).reduce(lt,[])},t.prototype.getResolvable=function(e){return wt(this._path.map(function(t){return t.resolvables}).reduce(ft,[]).filter(function(t){return t.token===e}))},t.prototype.getPolicy=function(t){var e=this.findNode(t);return t.getPolicy(e.state)},t.prototype.subContext=function(e){return new t(ge.subPath(this._path,function(t){return t.state===e}))},t.prototype.addResolvables=function(t,e){var r=it(this._path,g("state",e)),n=t.map(function(t){return t.token});r.resolvables=r.resolvables.filter(function(t){return-1===n.indexOf(t.token)}).concat(t)},t.prototype.resolvePath=function(t,s){var u=this;void 0===t&&(t="LAZY");var c=(B(Ee,t)?t:"LAZY")===me.when.EAGER?Se:Ee;ie.traceResolvePath(this._path,t,s);var f=function(e,r){return function(t){return B(e,u.getPolicy(t)[r])}},e=this._path.reduce(function(t,e){var r=e.resolvables.filter(f(c,"when")),n=r.filter(f(["NOWAIT"],"async")),i=r.filter(h(f(["NOWAIT"],"async"))),o=u.subContext(e.state),a=function(e){return e.get(o,s).then(function(t){return{token:e.token,value:t}})};return n.forEach(a),t.concat(i.map(a))},[]);return H.$q.all(e)},t.prototype.injector=function(){return this._injector||(this._injector=new Ce(this))},t.prototype.findNode=function(e){return it(this._path,function(t){return B(t.resolvables,e)})},t.prototype.getDependencies=function(e){var n=this,r=this.findNode(e),i=(ge.subPath(this._path,function(t){return t===r})||this._path).reduce(function(t,e){return t.concat(e.resolvables)},[]).filter(function(t){return t!==e});return e.deps.map(function(e){var t=i.filter(function(t){return t.token===e});if(t.length)return wt(t);var r=n.injector().getNative(e);if(o(r))throw new Error("Could not find Dependency Injection token: "+jt(e));return new we(e,function(){return r},[],r)})},t}(),Ce=function(){function t(t){this.context=t,this.native=this.get(Re)||H.$injector}return t.prototype.get=function(t){var e=this.context.getResolvable(t);if(e){if("NOWAIT"===this.context.getPolicy(e).async)return e.get(this.context);if(!e.resolved)throw new Error("Resolvable async .get() not complete:"+jt(e.token));return e.data}return this.getNative(t)},t.prototype.getAsync=function(t){var e=this.context.getResolvable(t);return e?e.get(this.context):H.$q.when(this.native.get(t))},t.prototype.getNative=function(t){return this.native&&this.native.get(t)},t}();function Pe(t){return t.name}function ke(t){return t.self.$$state=function(){return t},t.self}function Oe(t){return t.parent&&t.parent.data&&(t.data=t.self.data=G(t.parent.data,t.data)),t.data}var $e=function(a,s){return function(t){var e=t.self;if(e&&e.url&&e.name&&e.name.match(/\.\*\*$/)){var r={};bt(e,r),r.url+="{remainder:any}",e=r}var n=t.parent,i=function(t){if(!R(t))return!1;var e="^"===t.charAt(0);return{val:e?t.substring(1):t,root:e}}(e.url),o=i?a.compile(i.val,{state:e}):e.url;if(!o)return null;if(!a.isMatcher(o))throw new Error("Invalid url '"+o+"' in state '"+t+"'");return i&&i.root?o:(n&&n.navigable||s()).url.append(o)}};function xe(t){return t.parent?t.parent.path.concat(t):[t]}function He(t){var e=t.parent?q({},t.parent.includes):{};return e[t.name]=!0,e}function Ie(t){var e,r,n=function(t){return t.provide||t.token},i=y([[_("resolveFn"),function(t){return new we(n(t),t.resolveFn,t.deps,t.policy)}],[_("useFactory"),function(t){return new we(n(t),t.useFactory,t.deps||t.dependencies,t.policy)}],[_("useClass"),function(t){return new we(n(t),function(){return new t.useClass},[],t.policy)}],[_("useValue"),function(t){return new we(n(t),function(){return t.useValue},[],t.policy,t.useValue)}],[_("useExisting"),function(t){return new we(n(t),U,[t.useExisting],t.policy)}]]),o=y([[u(_("val"),R),function(t){return new we(t.token,U,[t.val],t.policy)}],[u(_("val"),C),function(t){return new we(t.token,wt(t.val),t.val.slice(0,-1),t.policy)}],[u(_("val"),E),function(t){return new we(t.token,t.val,(e=t.val,r=H.$injector,e.$inject||r&&r.annotate(e,r.strictDi)||"deferred"),t.policy);var e,r}]]),a=y([[l(we),function(t){return t}],[function(t){return!(!t.token||!t.resolveFn)},i],[function(t){return!(!t.provide&&!t.token||!(t.useValue||t.useFactory||t.useExisting||t.useClass))},i],[function(t){return!!(t&&t.val&&(R(t.val)||C(t.val)||E(t.val)))},o],[d(!0),function(t){throw new Error("Invalid resolve value: "+jt(t))}]]),s=t.resolve;return(C(s)?s:(e=s,r=t.resolvePolicy||{},Object.keys(e||{}).map(function(t){return{token:t,val:e[t],deps:void 0,policy:r[t]}}))).map(a)}var Ve,je,Ae=function(){function t(e,t){this.matcher=e;var n,r,i=this,o=function(){return e.find("")},a=function(t){return""===t.name};this.builders={name:[Pe],self:[ke],parent:[function(t){return a(t)?null:e.find(i.parentName(t))||o()}],data:[Oe],url:[$e(t,o)],navigable:[(r=a,function(t){return!r(t)&&t.url?t:t.parent?t.parent.navigable:null})],params:[(n=t.paramFactory,function(r){var t=r.url&&r.url.parameters({inherit:!1})||[],e=st(ot(rt(r.params||{},t.map(_("id"))),function(t,e){return n.fromConfig(e,null,r.self)}));return t.concat(e).map(function(t){return[t.id,t]}).reduce(_t,{})})],views:[],path:[xe],includes:[He],resolvables:[Ie]}}return t.prototype.builder=function(t,e){var r=this.builders,n=r[t]||[];return R(t)&&!m(e)?1<n.length?n:n[0]:R(t)&&E(e)?(r[t]=n,r[t].push(e),function(){return r[t].splice(r[t].indexOf(e,1))&&null}):void 0},t.prototype.build=function(t){var e=this.matcher,r=this.builders,n=this.parentName(t);if(n&&!e.find(n,void 0,!1))return null;for(var i in r)if(r.hasOwnProperty(i)){var o=r[i].reduce(function(e,r){return function(t){return r(t,e)}},L);t[i]=o(t)}return t},t.prototype.parentName=function(t){var e=t.name||"",r=e.split(".");if("**"===r.pop()&&r.pop(),r.length){if(t.parent)throw new Error("States that specify the 'parent:' property should not have a '.' in their name ("+e+")");return r.join(".")}return t.parent?R(t.parent)?t.parent:t.parent.name:""},t.prototype.name=function(t){var e=t.name;if(-1!==e.indexOf(".")||!t.parent)return e;var r=R(t.parent)?t.parent:t.parent.name;return r?r+"."+e:e},t}(),De=function(){function r(t){return r.create(t||{})}return r.create=function(t){t=r.isStateClass(t)?new t:t;var e=G(G(t,r.prototype));return t.$$state=function(){return e},e.self=t,e.__stateObjectCache={nameGlob:Pt.fromString(e.name)},e},r.prototype.is=function(t){return this===t||this.self===t||this.fqn()===t},r.prototype.fqn=function(){if(!(this.parent&&this.parent instanceof this.constructor))return this.name;var t=this.parent.fqn();return t?t+"."+this.name:this.name},r.prototype.root=function(){return this.parent&&this.parent.root()||this},r.prototype.parameters=function(e){return((e=Z(e,{inherit:!0,matchingKeys:null})).inherit&&this.parent&&this.parent.parameters()||[]).concat(st(this.params)).filter(function(t){return!e.matchingKeys||e.matchingKeys.hasOwnProperty(t.id)})},r.prototype.parameter=function(t,e){return void 0===e&&(e={}),this.url&&this.url.parameter(t,e)||it(st(this.params),g("id",t))||e.inherit&&this.parent&&this.parent.parameter(t)},r.prototype.toString=function(){return this.fqn()},r.isStateClass=function(t){return E(t)&&!0===t.__uiRouterState},r.isStateDeclaration=function(t){return E(t.$$state)},r.isState=function(t){return T(t.__stateObjectCache)},r}(),Ne=function(){function t(t){this._states=t}return t.prototype.isRelative=function(t){return 0===(t=t||"").indexOf(".")||0===t.indexOf("^")},t.prototype.find=function(t,e,r){if(void 0===r&&(r=!0),t||""===t){var n=R(t),i=n?t:t.name;this.isRelative(i)&&(i=this.resolvePath(i,e));var o=this._states[i];if(o&&(n||!(n||o!==t&&o.self!==t)))return o;if(n&&r){var a=st(this._states).filter(function(t){return t.__stateObjectCache.nameGlob&&t.__stateObjectCache.nameGlob.matches(i)});return 1<a.length&&Yt.error("stateMatcher.find: Found multiple matches for "+i+" using glob: ",a.map(function(t){return t.name})),a[0]}}},t.prototype.resolvePath=function(t,e){if(!e)throw new Error("No reference point given for path '"+t+"'");for(var r=this.find(e),n=t.split("."),i=n.length,o=0,a=r;o<i;o++)if(""!==n[o]||0!==o){if("^"!==n[o])break;if(!a.parent)throw new Error("Path '"+t+"' not valid for state '"+r.name+"'");a=a.parent}else a=r;var s=n.slice(o).join(".");return a.name+(a.name&&s?".":"")+s},t}(),qe=function(){function t(t,e,r,n){this.router=t,this.states=e,this.builder=r,this.listeners=n,this.queue=[]}return t.prototype.dispose=function(){this.queue=[]},t.prototype.register=function(t){var e=this.queue,r=De.create(t),n=r.name;if(!R(n))throw new Error("State must have a valid name");if(this.states.hasOwnProperty(n)||B(e.map(_("name")),n))throw new Error("State '"+n+"' is already defined");return e.push(r),this.flush(),r},t.prototype.flush=function(){for(var e=this,t=this.queue,r=this.states,n=this.builder,i=[],o=[],a={},s=function(t){return e.states.hasOwnProperty(t)&&e.states[t]},u=function(){i.length&&e.listeners.forEach(function(t){return t("registered",i.map(function(t){return t.self}))})};0<t.length;){var c=t.shift(),f=c.name,h=n.build(c),p=o.indexOf(c);if(h){var l=s(f);if(l&&l.name===f)throw new Error("State '"+f+"' is already defined");var d=s(f+".**");d&&this.router.stateRegistry.deregister(d),r[f]=c,this.attachRoute(c),0<=p&&o.splice(p,1),i.push(c)}else{var v=a[f];if(a[f]=t.length,0<=p&&v===t.length)return t.push(c),u(),r;p<0&&o.push(c),t.push(c)}}return u(),r},t.prototype.attachRoute=function(t){if(!t.abstract&&t.url){var e=this.router.urlService.rules;e.rule(e.urlRuleFactory.create(t))}},t}(),Fe=function(){function t(t){this.router=t,this.states={},this.listeners=[],this.matcher=new Ne(this.states),this.builder=new Ae(this.matcher,t.urlMatcherFactory),this.stateQueue=new qe(t,this.states,this.builder,this.listeners),this._registerRoot()}return t.prototype._registerRoot=function(){(this._root=this.stateQueue.register({name:"",url:"^",views:null,params:{"#":{value:null,type:"hash",dynamic:!0}},abstract:!0})).navigable=null},t.prototype.dispose=function(){var e=this;this.stateQueue.dispose(),this.listeners=[],this.get().forEach(function(t){return e.get(t)&&e.deregister(t)})},t.prototype.onStatesChanged=function(t){return this.listeners.push(t),function(){W(this.listeners)(t)}.bind(this)},t.prototype.root=function(){return this._root},t.prototype.register=function(t){return this.stateQueue.register(t)},t.prototype._deregisterTree=function(t){var r=this,n=this.get().map(function(t){return t.$$state()}),i=function(e){var t=n.filter(function(t){return-1!==e.indexOf(t.parent)});return 0===t.length?t:t.concat(i(t))},e=i([t]),o=[t].concat(e).reverse();return o.forEach(function(t){var e=r.router.urlService.rules;e.rules().filter(g("state",t)).forEach(function(t){return e.removeRule(t)}),delete r.states[t.name]}),o},t.prototype.deregister=function(t){var e=this.get(t);if(!e)throw new Error("Can't deregister state; not found: "+t);var r=this._deregisterTree(e.$$state());return this.listeners.forEach(function(t){return t("deregistered",r.map(function(t){return t.self}))}),r},t.prototype.get=function(t,e){var r=this;if(0===arguments.length)return Object.keys(this.states).map(function(t){return r.states[t].self});var n=this.matcher.find(t,e);return n&&n.self||null},t.prototype.decorator=function(t,e){return this.builder.builder(t,e)},t}();(Ve=v.TransitionHookPhase||(v.TransitionHookPhase={}))[Ve.CREATE=0]="CREATE",Ve[Ve.BEFORE=1]="BEFORE",Ve[Ve.RUN=2]="RUN",Ve[Ve.SUCCESS=3]="SUCCESS",Ve[Ve.ERROR=4]="ERROR",(je=v.TransitionHookScope||(v.TransitionHookScope={}))[je.TRANSITION=0]="TRANSITION",je[je.STATE=1]="STATE";var Ue={current:L,transition:null,traceData:{},bind:null},Le=function(){function o(t,e,r,n){var i=this;this.transition=t,this.stateContext=e,this.registeredHook=r,this.options=n,this.isSuperseded=function(){return i.type.hookPhase===v.TransitionHookPhase.RUN&&!i.options.transition.isActive()},this.options=Z(n,Ue),this.type=r.eventType}return o.chain=function(t,e){return t.reduce(function(t,e){return t.then(function(){return e.invokeHook()})},e||H.$q.when())},o.invokeHooks=function(t,e){for(var r=0;r<t.length;r++){var n=t[r].invokeHook();if($(n)){var i=t.slice(r+1);return o.chain(i,n).then(e)}}return e()},o.runAllHooks=function(t){t.forEach(function(t){return t.invokeHook()})},o.prototype.logError=function(t){this.transition.router.stateService.defaultErrorHandler()(t)},o.prototype.invokeHook=function(){var e=this,r=this.registeredHook;if(!r._deregistered){var t=this.getNotCurrentRejection();if(t)return t;var n=this.options;ie.traceHookInvocation(this,this.transition,n);var i=function(t){return r.eventType.getErrorHandler(e)(t)},o=function(t){return r.eventType.getResultHandler(e)(t)};try{var a=r.callback.call(n.bind,e.transition,e.stateContext);return!this.type.synchronous&&$(a)?a.catch(function(t){return $t.normalize(t).toPromise()}).then(o,i):o(a)}catch(t){return i($t.normalize(t))}finally{r.invokeLimit&&++r.invokeCount>=r.invokeLimit&&r.deregister()}}},o.prototype.handleHookResult=function(t){var e=this,r=this.getNotCurrentRejection();return r||($(t)?t.then(function(t){return e.handleHookResult(t)}):(ie.traceHookResult(t,this.transition,this.options),!1===t?$t.aborted("Hook aborted transition").toPromise():l(ye)(t)?$t.redirected(t).toPromise():void 0))},o.prototype.getNotCurrentRejection=function(){var t=this.transition.router;return t._disposed?$t.aborted("UIRouter instance #"+t.$id+" has been stopped (disposed)").toPromise():this.transition._aborted?$t.aborted().toPromise():this.isSuperseded()?$t.superseded(this.options.current()).toPromise():void 0},o.prototype.toString=function(){var t=this.options,e=this.registeredHook;return(a("traceData.hookType")(t)||"internal")+" context: "+(a("traceData.context.state.name")(t)||a("traceData.context")(t)||"unknown")+", "+xt(200,Vt(e.callback))},o.HANDLE_RESULT=function(e){return function(t){return e.handleHookResult(t)}},o.LOG_REJECTED_RESULT=function(e){return function(t){$(t)&&t.catch(function(t){return e.logError($t.normalize(t))})}},o.LOG_ERROR=function(e){return function(t){return e.logError(t)}},o.REJECT_ERROR=function(t){return function(t){return Ct(t)}},o.THROW_ERROR=function(t){return function(t){throw t}},o}();function Me(t,e,r){var i=R(e)?[e]:e;return!!(E(i)?i:function(t){for(var e=i,r=0;r<e.length;r++){var n=new Pt(e[r]);if(n&&n.matches(t.name)||!n&&e[r]===t.name)return!0}return!1})(t,r)}var Ge=function(){function t(t,e,r,n,i,o){void 0===o&&(o={}),this.tranSvc=t,this.eventType=e,this.callback=r,this.matchCriteria=n,this.removeHookFromRegistry=i,this.invokeCount=0,this._deregistered=!1,this.priority=o.priority||0,this.bind=o.bind||null,this.invokeLimit=o.invokeLimit}return t.prototype._matchingNodes=function(t,e,r){if(!0===e)return t;var n=t.filter(function(t){return Me(t.state,e,r)});return n.length?n:null},t.prototype._getDefaultMatchCriteria=function(){return ot(this.tranSvc._pluginapi._getPathTypes(),function(){return!0})},t.prototype._getMatchingNodes=function(o,a){var s=this,u=q(this._getDefaultMatchCriteria(),this.matchCriteria);return st(this.tranSvc._pluginapi._getPathTypes()).reduce(function(t,e){var r=e.scope===v.TransitionHookScope.STATE,n=o[e.name]||[],i=r?n:[wt(n)];return t[e.name]=s._matchingNodes(i,u[e.name],a),t},{})},t.prototype.matches=function(t,e){var r=this._getMatchingNodes(t,e);return st(r).every(U)?r:null},t.prototype.deregister=function(){this.removeHookFromRegistry(this),this._deregistered=!0},t}();function Be(t,i,o){var a=(t._registeredHooks=t._registeredHooks||{})[o.name]=[],s=W(a);function e(t,e,r){void 0===r&&(r={});var n=new Ge(i,o,e,t,s,r);return a.push(n),n.deregister.bind(n)}return t[o.name]=e}var ze=function(){function t(t){this.transition=t}return t.prototype.buildHooksForPhase=function(t){var e=this;return this.transition.router.transitionService._pluginapi._getEvents(t).map(function(t){return e.buildHooks(t)}).reduce(ft,[]).filter(U)},t.prototype.buildHooks=function(o){var a=this.transition,t=a.treeChanges(),e=this.getMatchingHooks(o,t,a);if(!e)return[];var s={transition:a,current:a.options().current};return e.map(function(i){return i.matches(t,a)[o.criteriaMatchPath.name].map(function(t){var e=q({bind:i.bind,traceData:{hookType:o.name,context:t}},s),r=o.criteriaMatchPath.scope===v.TransitionHookScope.STATE?t.state.self:null,n=new Le(a,r,i,e);return{hook:i,node:t,transitionHook:n}})}).reduce(ft,[]).sort(function(i){void 0===i&&(i=!1);return function(t,e){var r=i?-1:1,n=(t.node.state.path.length-e.node.state.path.length)*r;return 0!==n?n:e.hook.priority-t.hook.priority}}(o.reverseSort)).map(function(t){return t.transitionHook})},t.prototype.getMatchingHooks=function(e,r,n){var t=e.hookPhase===v.TransitionHookPhase.CREATE,i=this.transition.router.transitionService;return(t?[i]:[this.transition,i]).map(function(t){return t.getHooks(e.name)}).filter(vt(C,"broken event named: "+e.name)).reduce(ft,[]).filter(function(t){return t.matches(r,n)})},t}();var We=_("self"),Je=function(){function e(t,e,r){var n=this;if(this._deferred=H.$q.defer(),this.promise=this._deferred.promise,this._registeredHooks={},this._hookBuilder=new ze(this),this.isActive=function(){return n.router.globals.transition===n},this.router=r,!(this._targetState=e).valid())throw new Error(e.error());this._options=q({current:d(this)},e.options()),this.$id=r.transitionService._transitionCount++;var i=ge.buildToPath(t,e);this._treeChanges=ge.treeChanges(t,i,this._options.reloadState),this.createTransitionHookRegFns();var o=this._hookBuilder.buildHooksForPhase(v.TransitionHookPhase.CREATE);Le.invokeHooks(o,function(){return null}),this.applyViewConfigs(r)}return e.prototype.onBefore=function(t,e,r){},e.prototype.onStart=function(t,e,r){},e.prototype.onExit=function(t,e,r){},e.prototype.onRetain=function(t,e,r){},e.prototype.onEnter=function(t,e,r){},e.prototype.onFinish=function(t,e,r){},e.prototype.onSuccess=function(t,e,r){},e.prototype.onError=function(t,e,r){},e.prototype.createTransitionHookRegFns=function(){var e=this;this.router.transitionService._pluginapi._getEvents().filter(function(t){return t.hookPhase!==v.TransitionHookPhase.CREATE}).forEach(function(t){return Be(e,e.router.transitionService,t)})},e.prototype.getHooks=function(t){return this._registeredHooks[t]},e.prototype.applyViewConfigs=function(t){var e=this._treeChanges.entering.map(function(t){return t.state});ge.applyViewConfigs(t.transitionService.$view,this._treeChanges.to,e)},e.prototype.$from=function(){return wt(this._treeChanges.from).state},e.prototype.$to=function(){return wt(this._treeChanges.to).state},e.prototype.from=function(){return this.$from().self},e.prototype.to=function(){return this.$to().self},e.prototype.targetState=function(){return this._targetState},e.prototype.is=function(t){return t instanceof e?this.is({to:t.$to().name,from:t.$from().name}):!(t.to&&!Me(this.$to(),t.to,this)||t.from&&!Me(this.$from(),t.from,this))},e.prototype.params=function(t){return void 0===t&&(t="to"),Object.freeze(this._treeChanges[t].map(_("paramValues")).reduce(X,{}))},e.prototype.paramsChanged=function(){var t=this.params("from"),r=this.params("to"),e=[].concat(this._treeChanges.to).concat(this._treeChanges.from).map(function(t){return t.paramSchema}).reduce(ht,[]).reduce(lt,[]);return pe.changed(e,t,r).reduce(function(t,e){return t[e.id]=r[e.id],t},{})},e.prototype.injector=function(e,t){void 0===t&&(t="to");var r=this._treeChanges[t];return e&&(r=ge.subPath(r,function(t){return t.state===e||t.state.name===e})),new Te(r).injector()},e.prototype.getResolveTokens=function(t){return void 0===t&&(t="to"),new Te(this._treeChanges[t]).getTokens()},e.prototype.addResolvable=function(t,e){void 0===e&&(e=""),t=l(we)(t)?t:new we(t);var r="string"==typeof e?e:e.name,n=this._treeChanges.to,i=it(n,function(t){return t.state.name===r});new Te(n).addResolvables([t],i.state)},e.prototype.redirectedFrom=function(){return this._options.redirectedFrom||null},e.prototype.originalTransition=function(){var t=this.redirectedFrom();return t&&t.originalTransition()||this},e.prototype.options=function(){return this._options},e.prototype.entering=function(){return at(this._treeChanges.entering,_("state")).map(We)},e.prototype.exiting=function(){return at(this._treeChanges.exiting,_("state")).map(We).reverse()},e.prototype.retained=function(){return at(this._treeChanges.retained,_("state")).map(We)},e.prototype.views=function(t,e){void 0===t&&(t="entering");var r=this._treeChanges[t];return(r=e?r.filter(g("state",e)):r).map(_("views")).filter(U).reduce(ft,[])},e.prototype.treeChanges=function(t){return t?this._treeChanges[t]:this._treeChanges},e.prototype.redirect=function(t){for(var e=1,r=this;null!=(r=r.redirectedFrom());)if(20<++e)throw new Error("Too many consecutive Transition redirects (20+)");var n={redirectedFrom:this,source:"redirect"};"url"===this.options().source&&!1!==t.options().location&&(n.location="replace");var i=q({},this.options(),t.options(),n);t=t.withOptions(i,!0);var o,a=this.router.transitionService.create(this._treeChanges.from,t),s=this._treeChanges.entering,u=a._treeChanges.entering;return ge.matching(u,s,ge.nonDynamicParams).filter(h((o=t.options().reloadState,function(t){return o&&t.state.includes[o.name]}))).forEach(function(t,e){t.resolvables=s[e].resolvables}),a},e.prototype._changedParams=function(){var t=this._treeChanges;if(!this._options.reload&&(!t.exiting.length&&!t.entering.length&&t.to.length===t.from.length&&!mt(t.to,t.from).map(function(t){return t[0].state!==t[1].state}).reduce(ct,!1))){var e=t.to.map(function(t){return t.paramSchema}),r=[t.to,t.from].map(function(t){return t.map(function(t){return t.paramValues})});return mt(e,r[0],r[1]).map(function(t){var e=t[0],r=t[1],n=t[2];return pe.changed(e,r,n)}).reduce(ft,[])}},e.prototype.dynamic=function(){var t=this._changedParams();return!!t&&t.map(function(t){return t.dynamic}).reduce(ct,!1)},e.prototype.ignored=function(){return!!this._ignoredReason()},e.prototype._ignoredReason=function(){var t=this.router.globals.transition,n=this._options.reloadState,e=function(t,e){if(t.length!==e.length)return!1;var r=ge.matching(t,e);return t.length===r.filter(function(t){return!n||!t.state.includes[n.name]}).length},r=this.treeChanges(),i=t&&t.treeChanges();return i&&e(i.to,r.to)&&