{"ast":null,"code":"import { EventEmitter } from \"@angular/core\";\nimport { ActivatedRoute, NavigationStart, Router } from \"@angular/router\";\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/router\";\nexport let FxTracker = /*#__PURE__*/(() => {\n  class FxTracker {\n    constructor(router) {\n      this.router = router;\n      this.history = [];\n      this.historyChange = new EventEmitter();\n      this.indexChange = new EventEmitter();\n      router.events.subscribe(event => {\n        if (event.constructor == NavigationStart) {\n          this.produceByRoute(this.activatedRoute);\n        }\n      });\n    }\n\n    ngAfterViewInit() {\n      Promise.resolve().then(() => this.loaded = true);\n    }\n\n    produceByRoute(activatedRoute) {\n      const path = this.getRoutePath(activatedRoute);\n      this.produceFxId(path);\n      this.value = path;\n    }\n\n    produceFxId(value) {\n      this.history = this.history || [];\n\n      if (this.orderArray) {\n        this.id = this.produceOrderFxId(value);\n      } else {\n        this.index = this.index == null ? 0 : this.index;\n        const histLen = this.history.length;\n        const isBack = histLen && this.history[this.index + 1] == value;\n        const isForward = histLen && this.history[this.index - 1] == value;\n\n        if (isBack) {\n          this.indexChange.emit(++this.index);\n          this.id = this.id === 0 ? false : 0;\n          return this.id;\n        }\n\n        this.id = this.id === 1 ? true : 1;\n\n        if (isForward) {\n          this.indexChange.emit(--this.index);\n          return this.id;\n        }\n      }\n\n      this.history.splice(this.index, 0, value);\n      this.indexChange.emit(this.index);\n      this.history.splice(25, this.history.length);\n      this.historyChange.emit(this.history);\n      return this.id;\n    }\n\n    produceOrderFxId(value) {\n      let oldIndex = 0;\n      let newIndex = 0;\n      const oldValue = this.orderArray[this.orderIndex];\n\n      for (let index = this.orderArray.length - 1; index >= 0; --index) {\n        let item = this.orderArray[index];\n\n        if (value === item) {\n          newIndex = index;\n        }\n\n        if (oldValue === item) {\n          oldIndex = index;\n        }\n      }\n\n      this.orderIndex = newIndex;\n\n      if (newIndex <= oldIndex) {\n        return this.id = this.id === 0 ? false : 0;\n      }\n\n      return this.id = this.id === 1 ? true : 1;\n    }\n\n    getRoutePath(activatedRoute) {\n      var _a;\n\n      let target = activatedRoute;\n\n      while (target.firstChild) target = target.firstChild;\n\n      const snap = target._routerState.snapshot;\n      const ngOldPath = (_a = target.routeConfig) === null || _a === void 0 ? void 0 : _a.path;\n      const path = ngOldPath || snap.url;\n      return path;\n    }\n\n    delayOutFx() {\n      Promise.resolve().then(() => this.inFx = false);\n    }\n\n  }\n\n  FxTracker.ɵfac = function FxTracker_Factory(t) {\n    return new (t || FxTracker)(i0.ɵɵdirectiveInject(i1.Router));\n  };\n\n  FxTracker.ɵdir = i0.ɵɵdefineDirective({\n    type: FxTracker,\n    selectors: [[\"fx-tracker\"]],\n    inputs: {\n      value: \"value\",\n      activatedRoute: \"activatedRoute\",\n      orderArray: \"orderArray\",\n      history: \"history\",\n      index: \"index\",\n      id: \"id\"\n    },\n    outputs: {\n      historyChange: \"historyChange\",\n      indexChange: \"indexChange\"\n    },\n    exportAs: [\"FxTracker\"]\n  });\n  return FxTracker;\n})();","map":null,"metadata":{},"sourceType":"module"}