{ "version": 3, "sources": ["src/app/features/trips/directives/trips-itinerary-section.directive.ts", "src/app/features/trips/services/trips-itinerary-menu.service.ts"], "sourcesContent": ["import {\n AfterViewInit,\n Directive,\n ElementRef,\n Input,\n OnDestroy,\n} from '@angular/core';\nimport { EnvironmentService } from '@core/services/environment.service';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { distinctUntilChanged, shareReplay } from 'rxjs/operators';\n\n@Directive({\n selector: '[appTripsItinerarySection]',\n standalone: true,\n})\nexport class TripsItinerarySectionDirective\n implements AfterViewInit, OnDestroy\n{\n @Input() title: string;\n @Input() observerOptions: IntersectionObserverInit = {\n root: null,\n // remove 100px from top of the viewport container\n rootMargin: '-100px 0px 0px 0px',\n threshold: 0.0,\n };\n private _isVisible = new BehaviorSubject(false);\n isVisible: Observable;\n\n private observer: IntersectionObserver;\n\n constructor(\n private elementRef: ElementRef,\n private environmentService: EnvironmentService\n ) {\n this.isVisible = this._isVisible.pipe(\n distinctUntilChanged(),\n shareReplay(1)\n );\n }\n\n scrollIntoView() {\n this.elementRef.nativeElement.scrollIntoView({\n behavior: 'smooth',\n block: 'start',\n });\n }\n\n ngAfterViewInit(): void {\n if (this.environmentService.isBrowser()) {\n const options = this.observerOptions;\n this.observer = new IntersectionObserver((entries, observer) => {\n const isVisible = entries\n .map(value => value.isIntersecting)\n .reduce(\n (previousValue, currentValue) =>\n previousValue && currentValue,\n true\n );\n this._isVisible.next(isVisible);\n }, options);\n this.observer.observe(this.elementRef.nativeElement);\n }\n }\n\n ngOnDestroy(): void {\n if (this.environmentService.isBrowser()) {\n this.observer.unobserve(this.elementRef.nativeElement);\n }\n }\n}\n", "import { Injectable } from '@angular/core';\nimport { TripsItinerarySectionDirective } from '@features/trips/directives/trips-itinerary-section.directive';\nimport { BehaviorSubject, combineLatest, Observable } from 'rxjs';\nimport {\n distinctUntilChanged,\n map,\n shareReplay,\n switchMap,\n} from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'any',\n})\nexport class TripsItineraryMenuService {\n private _sections = new BehaviorSubject(\n []\n );\n\n activeMenuItem: Observable;\n activeIndex: Observable;\n get sections(): Observable {\n return this._sections;\n }\n\n constructor() {\n const visibilityChanges = this._sections.pipe(\n switchMap(sections =>\n combineLatest(sections.map(section => section.isVisible))\n )\n );\n this.activeIndex = visibilityChanges.pipe(\n map(visibility => visibility.indexOf(true) || 0),\n distinctUntilChanged(),\n shareReplay(1)\n );\n this.activeMenuItem = combineLatest([\n this._sections,\n this.activeIndex,\n ]).pipe(\n map(([sections, activeIndex]) => sections[activeIndex] || null),\n distinctUntilChanged(),\n shareReplay(1)\n );\n }\n\n updateMenuItems(sections: TripsItinerarySectionDirective[]) {\n this._sections.next(sections);\n }\n}\n"], "mappings": "qJAeA,IAAaA,GAA8B,IAAA,CAArC,MAAOA,CAA8B,CAevCC,YACYC,EACAC,EAAsC,CADtC,KAAAD,WAAAA,EACA,KAAAC,mBAAAA,EAbH,KAAAC,gBAA4C,CACjDC,KAAM,KAENC,WAAY,qBACZC,UAAW,GAEP,KAAAC,WAAa,IAAIC,EAAyB,EAAK,EASnD,KAAKC,UAAY,KAAKF,WAAWG,KAC7BC,EAAoB,EACpBC,EAAY,CAAC,CAAC,CAEtB,CAEAC,gBAAc,CACV,KAAKZ,WAAWa,cAAcD,eAAe,CACzCE,SAAU,SACVC,MAAO,QACV,CACL,CAEAC,iBAAe,CACX,GAAI,KAAKf,mBAAmBgB,UAAS,EAAI,CACrC,IAAMC,EAAU,KAAKhB,gBACrB,KAAKiB,SAAW,IAAIC,qBAAqB,CAACC,EAASF,IAAY,CAC3D,IAAMX,EAAYa,EACbC,IAAIC,GAASA,EAAMC,cAAc,EACjCC,OACG,CAACC,EAAeC,IACZD,GAAiBC,EACrB,EAAI,EAEZ,KAAKrB,WAAWsB,KAAKpB,CAAS,CAClC,EAAGU,CAAO,EACV,KAAKC,SAASU,QAAQ,KAAK7B,WAAWa,aAAa,CACvD,CACJ,CAEAiB,aAAW,CACH,KAAK7B,mBAAmBgB,UAAS,GACjC,KAAKE,SAASY,UAAU,KAAK/B,WAAWa,aAAa,CAE7D,iDArDSf,GAA8BkC,EAAAC,CAAA,EAAAD,EAAAE,CAAA,CAAA,CAAA,CAAA,+BAA9BpC,EAA8BqC,UAAA,CAAA,CAAA,GAAA,2BAAA,EAAA,CAAA,EAAAC,OAAA,CAAAC,MAAA,QAAAnC,gBAAA,iBAAA,EAAAoC,WAAA,EAAA,CAAA,CAAA,SAA9BxC,CAA8B,GAAA,ECF3C,IAAayC,GAAyB,IAAA,CAAhC,MAAOA,CAAyB,CAOlC,IAAIC,UAAQ,CACR,OAAO,KAAKC,SAChB,CAEAC,aAAA,CAVQ,KAAAD,UAAY,IAAIE,EACpB,CAAA,CAAE,EAUF,IAAMC,EAAoB,KAAKH,UAAUI,KACrCC,EAAUN,GACNO,EAAcP,EAASQ,IAAIC,GAAWA,EAAQC,SAAS,CAAC,CAAC,CAC5D,EAEL,KAAKC,YAAcP,EAAkBC,KACjCG,EAAII,GAAcA,EAAWC,QAAQ,EAAI,GAAK,CAAC,EAC/CC,EAAoB,EACpBC,EAAY,CAAC,CAAC,EAElB,KAAKC,eAAiBT,EAAc,CAChC,KAAKN,UACL,KAAKU,WAAW,CACnB,EAAEN,KACCG,EAAI,CAAC,CAACR,EAAUW,CAAW,IAAMX,EAASW,CAAW,GAAK,IAAI,EAC9DG,EAAoB,EACpBC,EAAY,CAAC,CAAC,CAEtB,CAEAE,gBAAgBjB,EAA0C,CACtD,KAAKC,UAAUiB,KAAKlB,CAAQ,CAChC,iDAlCSD,EAAyB,CAAA,iCAAzBA,EAAyBoB,QAAzBpB,EAAyBqB,UAAAC,WAFtB,KAAK,CAAA,CAAA,SAERtB,CAAyB,GAAA", "names": ["TripsItinerarySectionDirective", "constructor", "elementRef", "environmentService", "observerOptions", "root", "rootMargin", "threshold", "_isVisible", "BehaviorSubject", "isVisible", "pipe", "distinctUntilChanged", "shareReplay", "scrollIntoView", "nativeElement", "behavior", "block", "ngAfterViewInit", "isBrowser", "options", "observer", "IntersectionObserver", "entries", "map", "value", "isIntersecting", "reduce", "previousValue", "currentValue", "next", "observe", "ngOnDestroy", "unobserve", "\u0275\u0275directiveInject", "ElementRef", "EnvironmentService", "selectors", "inputs", "title", "standalone", "TripsItineraryMenuService", "sections", "_sections", "constructor", "BehaviorSubject", "visibilityChanges", "pipe", "switchMap", "combineLatest", "map", "section", "isVisible", "activeIndex", "visibility", "indexOf", "distinctUntilChanged", "shareReplay", "activeMenuItem", "updateMenuItems", "next", "factory", "\u0275fac", "providedIn"] }