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AAA,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,mBAAS,CAAC,CAAC,CAAC,CAAC,EAA7E,CAA6E,CAAC;QAC/G,IAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,IAAA,KAAyB,IAAI,EAA3B,GAAG,SAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAS,CAAC;QACpC,OAAO,+BAA6B,GAAG,eAAU,IAAI,mBAAc,OAAO,kBAAa,MAAM,MAAG,CAAC;IACnG,CAAC;IAED,6BAAS,GAAT;QACE,OAAO,eAAM,CAAC,wBAAe,CAAC,IAAI,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;IACH,gBAAC;AAAD,CAAC,AAhHD,IAgHC;AAhHY,8BAAS",
10 "sourcesContent": [
11 "'use strict';\nimport { extend, silentRejection } from '../common/common';\nimport { stringify } from '../common/strings';\nimport { is } from '../common/hof';\n\n/** An enum for Transition Rejection reasons */\nenum RejectType {\n /**\n * A new transition superseded this one.\n *\n * While this transition was running, a new transition started.\n * This transition is cancelled because it was superseded by new transition.\n */\n SUPERSEDED = 2,\n\n /**\n * The transition was aborted\n *\n * The transition was aborted by a hook which returned `false`\n */\n ABORTED = 3,\n\n /**\n * The transition was invalid\n *\n * The transition was never started because it was invalid\n */\n INVALID = 4,\n\n /**\n * The transition was ignored\n *\n * The transition was ignored because it would have no effect.\n *\n * Either:\n *\n * - The transition is targeting the current state and parameter values\n * - The transition is targeting the same state and parameter values as the currently running transition.\n */\n IGNORED = 5,\n\n /**\n * The transition errored.\n *\n * This generally means a hook threw an error or returned a rejected promise\n */\n ERROR = 6,\n}\n\nexport { RejectType };\n\n/** @internal */\nlet id = 0;\n\nexport class Rejection {\n /** @internal */\n $id = id++;\n /**\n * The type of the rejection.\n *\n * This value is an number representing the type of transition rejection.\n * If using Typescript, this is a Typescript enum.\n *\n * - [[RejectType.SUPERSEDED]] (`2`)\n * - [[RejectType.ABORTED]] (`3`)\n * - [[RejectType.INVALID]] (`4`)\n * - [[RejectType.IGNORED]] (`5`)\n * - [[RejectType.ERROR]] (`6`)\n *\n */\n type: RejectType;\n\n /**\n * A message describing the rejection\n */\n message: string;\n\n /**\n * A detail object\n *\n * This value varies based on the mechanism for rejecting the transition.\n * For example, if an error was thrown from a hook, the `detail` will be the `Error` object.\n * If a hook returned a rejected promise, the `detail` will be the rejected value.\n */\n detail: any;\n\n /**\n * Indicates if the transition was redirected.\n *\n * When a transition is redirected, the rejection [[type]] will be [[RejectType.SUPERSEDED]] and this flag will be true.\n */\n redirected: boolean;\n\n /** Returns true if the obj is a rejected promise created from the `asPromise` factory */\n static isRejectionPromise(obj: any): boolean {\n return obj && typeof obj.then === 'function' && is(Rejection)(obj._transitionRejection);\n }\n\n /** Returns a Rejection due to transition superseded */\n static superseded(detail?: any, options?: any): Rejection {\n const message = 'The transition has been superseded by a different transition';\n const rejection = new Rejection(RejectType.SUPERSEDED, message, detail);\n if (options && options.redirected) {\n rejection.redirected = true;\n }\n return rejection;\n }\n\n /** Returns a Rejection due to redirected transition */\n static redirected(detail?: any): Rejection {\n return Rejection.superseded(detail, { redirected: true });\n }\n\n /** Returns a Rejection due to invalid transition */\n static invalid(detail?: any): Rejection {\n const message = 'This transition is invalid';\n return new Rejection(RejectType.INVALID, message, detail);\n }\n\n /** Returns a Rejection due to ignored transition */\n static ignored(detail?: any): Rejection {\n const message = 'The transition was ignored';\n return new Rejection(RejectType.IGNORED, message, detail);\n }\n\n /** Returns a Rejection due to aborted transition */\n static aborted(detail?: any): Rejection {\n const message = 'The transition has been aborted';\n return new Rejection(RejectType.ABORTED, message, detail);\n }\n\n /** Returns a Rejection due to aborted transition */\n static errored(detail?: any): Rejection {\n const message = 'The transition errored';\n return new Rejection(RejectType.ERROR, message, detail);\n }\n\n /**\n * Returns a Rejection\n *\n * Normalizes a value as a Rejection.\n * If the value is already a Rejection, returns it.\n * Otherwise, wraps and returns the value as a Rejection (Rejection type: ERROR).\n *\n * @returns `detail` if it is already a `Rejection`, else returns an ERROR Rejection.\n */\n static normalize(detail?: Rejection | Error | any): Rejection {\n return is(Rejection)(detail) ? detail : Rejection.errored(detail);\n }\n\n constructor(type: number, message?: string, detail?: any) {\n this.type = type;\n this.message = message;\n this.detail = detail;\n }\n\n toString() {\n const detailString = (d: any) => (d && d.toString !== Object.prototype.toString ? d.toString() : stringify(d));\n const detail = detailString(this.detail);\n const { $id, type, message } = this;\n return `Transition Rejection($id: ${$id} type: ${type}, message: ${message}, detail: ${detail})`;\n }\n\n toPromise(): Promise<any> {\n return extend(silentRejection(this), { _transitionRejection: this });\n }\n}\n"
12 ]
13}
\No newline at end of file