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,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAC3D,CAAC;IACJ,CAAC;IAED,8BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;IAnFD,qFAAqF;IAC9E,wBAAY,GAAG,UAAC,SAA4B;QACjD,OAAA,uBAAU,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,iBAAiB,CAAC,KAAK,IAAI;IAA9D,CAA8D,CAAC;IAEjE,kFAAkF;IAC3E,8BAAkB,GAAG,UAAC,GAAQ,IAA8B,OAAA,uBAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAA1B,CAA0B,CAAC;IAE9F,uFAAuF;IAChF,mBAAO,GAAG,UAAC,GAAQ,IAAyB,OAAA,qBAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,EAAnC,CAAmC,CAAC;IA4EzF,kBAAC;CAAA,AAxLD,IAwLC;AAxLY,kCAAW",
10 "sourcesContent": [
11 "import { StateDeclaration, _ViewDeclaration, _StateDeclaration, LazyLoadResult } from './interface';\nimport { defaults, values, find, inherit } from '../common/common';\nimport { propEq } from '../common/hof';\nimport { Param } from '../params/param';\nimport { UrlMatcher } from '../url/urlMatcher';\nimport { Resolvable } from '../resolve/resolvable';\nimport { TransitionStateHookFn } from '../transition/interface';\nimport { TargetState } from './targetState';\nimport { Transition } from '../transition/transition';\nimport { Glob } from '../common/glob';\nimport { isObject, isFunction } from '../common/predicates';\n\n/**\n * Internal representation of a UI-Router state.\n *\n * Instances of this class are created when a [[StateDeclaration]] is registered with the [[StateRegistry]].\n *\n * A registered [[StateDeclaration]] is augmented with a getter ([[StateDeclaration.$$state]]) which returns the corresponding [[StateObject]] object.\n *\n * This class prototypally inherits from the corresponding [[StateDeclaration]].\n * Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].\n */\nexport class StateObject {\n /** The parent [[StateObject]] */\n public parent: StateObject;\n\n /** The name used to register the state */\n public name: string;\n\n /** Prototypally inherits from [[StateDeclaration.abstract]] */\n public abstract: boolean;\n\n /** Prototypally inherits from [[StateDeclaration.resolve]] */\n public resolve: { [key: string]: string | any[] | Function } | any[];\n\n /** A list of [[Resolvable]] objects. The internal representation of [[resolve]]. */\n public resolvables: Resolvable[];\n\n /** Prototypally inherits from [[StateDeclaration.resolvePolicy]] */\n public resolvePolicy: any;\n\n /** A compiled URLMatcher which detects when the state's URL is matched */\n public url: UrlMatcher;\n\n /** The parameters for the state, built from the URL and [[StateDeclaration.params]] */\n public params: { [key: string]: Param };\n\n /**\n * The views for the state.\n * Note: `@uirouter/core` does not register a builder for views.\n * The framework specific code should register a `views` builder.\n */\n public views: { [key: string]: _ViewDeclaration };\n\n /**\n * The original [[StateDeclaration]] used to build this [[StateObject]].\n * Note: `this` object also prototypally inherits from the `self` declaration object.\n */\n public self: StateDeclaration;\n\n /** The nearest parent [[StateObject]] which has a URL */\n public navigable: StateObject;\n\n /** The parent [[StateObject]] objects from this state up to the root */\n public path: StateObject[];\n\n /**\n * Prototypally inherits from [[StateDeclaration.data]]\n * Note: This is the only field on the [[StateDeclaration]] which is mutated.\n * The definition object's `data` field is replaced with a new object\n * which prototypally inherits from the parent state definition's `data` field.\n */\n public data: any;\n\n /**\n * An object containing the parent States' names as keys and\n * true as their values.\n */\n public includes: { [name: string]: boolean };\n\n /** Prototypally inherits from [[StateDeclaration.onExit]] */\n public onExit: TransitionStateHookFn;\n /** Prototypally inherits from [[StateDeclaration.onRetain]] */\n public onRetain: TransitionStateHookFn;\n /** Prototypally inherits from [[StateDeclaration.onEnter]] */\n public onEnter: TransitionStateHookFn;\n\n /** Prototypally inherits from [[StateDeclaration.lazyLoad]] */\n public lazyLoad: (transition: Transition, state: StateDeclaration) => Promise<LazyLoadResult>;\n\n /** Prototypally inherits from [[StateDeclaration.redirectTo]] */\n redirectTo:\n | string\n | (($transition$: Transition) => TargetState)\n | { state: string | StateDeclaration; params: { [key: string]: any } };\n\n /** @internal */\n __stateObjectCache: {\n /** Might be null */\n nameGlob?: Glob;\n };\n\n /**\n * Create a state object to put the private/internal implementation details onto.\n * The object's prototype chain looks like:\n * (Internal State Object) -> (Copy of State.prototype) -> (State Declaration object) -> (State Declaration's prototype...)\n *\n * @param stateDecl the user-supplied State Declaration\n * @returns {StateObject} an internal State object\n */\n static create(stateDecl: _StateDeclaration): StateObject {\n stateDecl = StateObject.isStateClass(stateDecl) ? new stateDecl() : stateDecl;\n\n const state = inherit(inherit(stateDecl, StateObject.prototype)) as StateObject;\n stateDecl.$$state = () => state;\n state.self = stateDecl;\n state.__stateObjectCache = {\n nameGlob: Glob.fromString(state.name), // might return null\n };\n return state;\n }\n\n /** Predicate which returns true if the object is an class with @State() decorator */\n static isStateClass = (stateDecl: _StateDeclaration): stateDecl is { new (): StateDeclaration } =>\n isFunction(stateDecl) && stateDecl['__uiRouterState'] === true;\n\n /** Predicate which returns true if the object is a [[StateDeclaration]] object */\n static isStateDeclaration = (obj: any): obj is StateDeclaration => isFunction(obj['$$state']);\n\n /** Predicate which returns true if the object is an internal [[StateObject]] object */\n static isState = (obj: any): obj is StateObject => isObject(obj['__stateObjectCache']);\n\n /** @deprecated use State.create() */\n constructor(config?: StateDeclaration) {\n return StateObject.create(config || {});\n }\n\n /**\n * Returns true if the provided parameter is the same state.\n *\n * Compares the identity of the state against the passed value, which is either an object\n * reference to the actual `State` instance, the original definition object passed to\n * `$stateProvider.state()`, or the fully-qualified name.\n *\n * @param ref Can be one of (a) a `State` instance, (b) an object that was passed\n * into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.\n * @returns Returns `true` if `ref` matches the current `State` instance.\n */\n is(ref: StateObject | StateDeclaration | string): boolean {\n return this === ref || this.self === ref || this.fqn() === ref;\n }\n\n /**\n * @deprecated this does not properly handle dot notation\n * @returns Returns a dot-separated name of the state.\n */\n fqn(): string {\n if (!this.parent || !(this.parent instanceof this.constructor)) return this.name;\n const name = this.parent.fqn();\n return name ? name + '.' + this.name : this.name;\n }\n\n /**\n * Returns the root node of this state's tree.\n *\n * @returns The root of this state's tree.\n */\n root(): StateObject {\n return (this.parent && this.parent.root()) || this;\n }\n\n /**\n * Gets the state's `Param` objects\n *\n * Gets the list of [[Param]] objects owned by the state.\n * If `opts.inherit` is true, it also includes the ancestor states' [[Param]] objects.\n * If `opts.matchingKeys` exists, returns only `Param`s whose `id` is a key on the `matchingKeys` object\n *\n * @param opts options\n */\n parameters(opts?: { inherit?: boolean; matchingKeys?: any }): Param[] {\n opts = defaults(opts, { inherit: true, matchingKeys: null });\n const inherited = (opts.inherit && this.parent && this.parent.parameters()) || [];\n return inherited\n .concat(values(this.params))\n .filter((param) => !opts.matchingKeys || opts.matchingKeys.hasOwnProperty(param.id));\n }\n\n /**\n * Returns a single [[Param]] that is owned by the state\n *\n * If `opts.inherit` is true, it also searches the ancestor states` [[Param]]s.\n * @param id the name of the [[Param]] to return\n * @param opts options\n */\n parameter(id: string, opts: { inherit?: boolean } = {}): Param {\n return (\n (this.url && this.url.parameter(id, opts)) ||\n find(values(this.params), propEq('id', id)) ||\n (opts.inherit && this.parent && this.parent.parameter(id))\n );\n }\n\n toString() {\n return this.fqn();\n }\n}\n"
12 ]
13}
\No newline at end of file