{"version":3,"file":"ng-web-apis-view-transition.mjs","sources":["../../../libs/view-transition/src/services/view-transition.service.ts","../../../libs/view-transition/src/ng-web-apis-view-transition.ts"],"sourcesContent":["import {DOCUMENT} from '@angular/common';\nimport {inject, Injectable} from '@angular/core';\nimport {Observable, throwError} from 'rxjs';\n\n@Injectable({\n    providedIn: 'root',\n})\nexport class ViewTransitionService {\n    private readonly document = inject(DOCUMENT);\n\n    public get isSupported(): boolean {\n        return 'startViewTransition' in this.document;\n    }\n\n    public startViewTransition(\n        callback: () => Promise<void> | void,\n    ): Observable<ViewTransition> {\n        if (!this.isSupported) {\n            return throwError(\n                () => new Error('startViewTransition is not supported in your browser'),\n            );\n        }\n\n        return new Observable((subscriber) => {\n            const transition: ViewTransition =\n                this.document.startViewTransition(callback);\n\n            transition.updateCallbackDone.then(\n                () => {\n                    subscriber.next(transition);\n                },\n                (error: unknown) => {\n                    subscriber.error(error);\n                },\n            );\n\n            transition.ready.catch((error: unknown) => {\n                subscriber.error(error);\n            });\n\n            transition.finished.then(\n                () => {\n                    subscriber.complete();\n                },\n                (error: unknown) => {\n                    subscriber.error(error);\n                },\n            );\n\n            return () => {\n                transition.skipTransition();\n            };\n        });\n    }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAIA,MAGa,qBAAqB,CAAA;AACb,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE7C,IAAA,IAAW,WAAW,GAAA;AAClB,QAAA,OAAO,qBAAqB,IAAI,IAAI,CAAC,QAAQ,CAAC;KACjD;AAEM,IAAA,mBAAmB,CACtB,QAAoC,EAAA;AAEpC,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO,UAAU,CACb,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAC1E,CAAC;AACL,SAAA;AAED,QAAA,OAAO,IAAI,UAAU,CAAC,CAAC,UAAU,KAAI;YACjC,MAAM,U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