{"version":3,"file":"main.68cfe88771174807.js","sources":["./e2e/factory/default-product.ts","./e2e/factory/default-conversion.ts","./e2e/factory/default-building-project.ts","./e2e/factory/mock.factory.ts","./e2e/constants.ts","./src/app/auth.guard.ts","./src/app/components/base-component/base-component.component.ts","./src/app/components/modal/modal.component.html","./src/app/components/modal/modal.component.ts","./src/app/directives/alert.directive.ts","./src/app/directives/has-feature-flag.directive.ts","./src/app/directives/required-error.directive.ts","./src/app/export-plugin.guard.ts","./src/app/feature-flag.guard.ts","./src/app/modules/asset-catalog/services/ready-number.service.ts","./src/app/modules/building-projects/building-projcts-route-paths.ts","./node_modules/@epicgames-ps/lib-pixelstreamingfrontend-ue5.4/dist/lib-pixelstreamingfrontend.esm.js","./node_modules/rxjs/dist/esm/internal/observable/dom/WebSocketSubject.js","./src/app/modules/visualization/services/PixelStreamErrorEventHandler.ts","./src/app/modules/visualization/services/pixel-streaming.service.ts","./node_modules/rxjs/dist/esm/internal/observable/dom/webSocket.js","./src/app/onboarding-screen.guard.ts","./src/app/product-catalog.guard.ts","./src/app/resolvers/configuration-resolver.service.ts","./src/app/route-paths.ts","./src/app/sales.guard.ts","./src/app/services/asset.service.ts","./src/app/services/auth.service.ts","./src/app/services/building-project.service.ts","./src/app/services/building.service.ts","./src/app/services/configuration.service.ts","./src/app/services/date.service.ts","./src/app/services/environment.service.ts","./src/app/components/dialogs/errordialog/errordialog.component.html","./src/app/components/dialogs/errordialog/errordialog.component.ts","./src/app/services/errordialog.service.ts","./src/app/services/exporter-plugin.service.ts","./src/app/services/favorites/favorites.service.ts","./src/app/services/filtered-articles.service.ts","./src/app/services/floorplan-ai.service.ts","./src/app/services/floorplan.service.ts","./src/app/services/floorplanner.service.ts","./src/app/services/icon-registry.service.ts","./src/app/components/dialogs/infobox-dialog/infobox-dialog.component.html","./src/app/components/dialogs/infobox-dialog/infobox-dialog.component.ts","./src/app/services/infobox-dialog.service.ts","./src/app/services/input-file.service.ts","./src/app/services/level.service.ts","./src/app/services/navigation-history.service.ts","./src/app/services/navigation.service.ts","./src/app/services/project.service.ts","./src/app/services/releasenotes.service.ts","./src/app/services/schema-properties.service.ts","./src/app/services/schemas.service.ts","./src/app/services/screenshot.service.ts","./src/app/services/service-cache.service.ts","./src/app/business-domain/Stream.ts","./src/app/services/streaming.service.ts","./node_modules/rxjs/dist/esm/internal/operators/retryWhen.js","./src/app/services/token.service.ts","./src/app/components/dialogs/two-actions-dialog/two-actions-dialog.component.html","./src/app/components/dialogs/two-actions-dialog/two-actions-dialog.component.ts","./src/app/services/two-actions-dialog.service.ts","./src/app/services/unit.service.ts","./src/app/services/unreal.service.ts","./src/app/services/url.service.ts","./src/app/services/utility.service.ts","./src/app/services/version.service.ts","./src/app/shared/components/dropdown/dropdown.component.html","./src/app/shared/components/dropdown/dropdown.component.ts","./src/app/shared/components/menus/top-menu.component.html","./src/app/shared/components/menus/top-menu.component.ts","./src/app/shared/components/signup-footer/signup-footer.component.ts","./src/app/shared/components/signup-footer/signup-footer.component.html","./src/app/shared/constants/feature-flags.constants.ts","./src/app/shared/shared-routing.module.ts","./src/app/shared/shared.module.ts","./src/app/user-group.guard.ts","./src/environments/environment.deploy.ts","./node_modules/@angular/animations/fesm2022/browser.mjs","./node_modules/@angular/platform-browser/fesm2022/animations.mjs","./node_modules/@angular/common/locales/global/de.js","./node_modules/@angular/material/fesm2022/autocomplete.mjs","./node_modules/@angular/material/fesm2022/badge.mjs","./node_modules/@angular/material/fesm2022/button-toggle.mjs","./node_modules/@angular/material/fesm2022/progress-bar.mjs","./node_modules/@sentry/core/build/esm/integration.js","./node_modules/@sentry/core/build/esm/integrations/inboundfilters.js","./node_modules/@sentry/core/build/esm/integrations/functiontostring.js","./node_modules/@sentry/core/build/esm/integrations/dedupe.js","./node_modules/@sentry/core/build/esm/utils-hoist/supports.js","./node_modules/@sentry/core/build/esm/utils-hoist/dsn.js","./node_modules/@sentry/core/build/esm/api.js","./node_modules/@sentry/core/build/esm/utils-hoist/envelope.js","./node_modules/@sentry/core/build/esm/utils-hoist/error.js","./node_modules/@sentry/core/build/esm/utils/parseSampleRate.js","./node_modules/@sentry/core/build/esm/baseclient.js","./node_modules/@sentry/core/build/esm/envelope.js","./node_modules/@sentry/core/build/esm/utils-hoist/clientreport.js","./node_modules/@sentry/core/build/esm/utils/sdkMetadata.js","./node_modules/@sentry/browser/build/npm/esm/debug-build.js","./node_modules/@sentry/browser/build/npm/esm/eventbuilder.js","./node_modules/@sentry/browser/build/npm/esm/helpers.js","./node_modules/@sentry/browser/build/npm/esm/client.js","./node_modules/@sentry/core/build/esm/utils-hoist/env.js","./node_modules/@sentry/browser/build/npm/esm/userfeedback.js","./node_modules/@sentry/core/build/esm/utils-hoist/instrument/handlers.js","./node_modules/@sentry-internal/browser-utils/build/esm/types.js","./node_modules/@sentry-internal/browser-utils/build/esm/instrument/dom.js","./node_modules/@sentry-internal/browser-utils/build/esm/instrument/xhr.js","./node_modules/@sentry/core/build/esm/utils-hoist/vendor/supportsHistory.js","./node_modules/@sentry-internal/browser-utils/build/esm/instrument/history.js","./node_modules/@sentry/core/build/esm/utils-hoist/instrument/console.js","./node_modules/@sentry/core/build/esm/utils-hoist/instrument/fetch.js","./node_modules/@sentry/core/build/esm/breadcrumbs.js","./node_modules/@sentry/core/build/esm/utils-hoist/severity.js","./node_modules/@sentry/core/build/esm/utils-hoist/breadcrumb-log-level.js","./node_modules/@sentry/core/build/esm/utils-hoist/url.js","./node_modules/@sentry/browser/build/npm/esm/integrations/breadcrumbs.js","./node_modules/@sentry/browser/build/npm/esm/integrations/browserapierrors.js","./node_modules/@sentry/browser/build/npm/esm/integrations/browsersession.js","./node_modules/@sentry/core/build/esm/utils-hoist/instrument/globalError.js","./node_modules/@sentry/core/build/esm/utils-hoist/instrument/globalUnhandledRejection.js","./node_modules/@sentry/browser/build/npm/esm/integrations/globalhandlers.js","./node_modules/@sentry/browser/build/npm/esm/integrations/httpcontext.js","./node_modules/@sentry/core/build/esm/utils-hoist/aggregate-errors.js","./node_modules/@sentry/browser/build/npm/esm/integrations/linkederrors.js","./node_modules/@sentry/browser/build/npm/esm/stack-parsers.js","./node_modules/@sentry-internal/browser-utils/build/esm/debug-build.js","./node_modules/@sentry-internal/browser-utils/build/esm/getNativeImplementation.js","./node_modules/@sentry/core/build/esm/transports/base.js","./node_modules/@sentry/core/build/esm/utils-hoist/promisebuffer.js","./node_modules/@sentry/core/build/esm/utils-hoist/ratelimit.js","./node_modules/@sentry/browser/build/npm/esm/transports/fetch.js","./node_modules/@sentry/browser/build/npm/esm/sdk.js","./node_modules/@sentry/core/build/esm/sdk.js","./node_modules/@sentry/core/build/esm/tracing/measurement.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/bindReporter.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/getNavigationEntry.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/getActivationStart.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/initMetric.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/generateUniqueID.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/observe.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/onHidden.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/runOnce.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/getVisibilityWatcher.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/whenActivated.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/onFCP.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getCLS.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getFID.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/interactions.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/lib/whenIdle.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getINP.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/getLCP.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/web-vitals/onTTFB.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/instrument.js","./node_modules/@sentry/core/build/esm/tracing/sentryNonRecordingSpan.js","./node_modules/@sentry/core/build/esm/tracing/utils.js","./node_modules/@sentry/core/build/esm/tracing/sentrySpan.js","./node_modules/@sentry/core/build/esm/tracing/logSpans.js","./node_modules/@sentry/core/build/esm/tracing/trace.js","./node_modules/@sentry/core/build/esm/tracing/sampling.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/utils.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/browserMetrics.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/cls.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/inp.js","./node_modules/@sentry/core/build/esm/tracing/idleSpan.js","./node_modules/@sentry/core/build/esm/tracing/errors.js","./node_modules/@sentry/core/build/esm/utils/traceData.js","./node_modules/@sentry/core/build/esm/fetch.js","./node_modules/@sentry/browser/build/npm/esm/tracing/request.js","./node_modules/@sentry/browser/build/npm/esm/tracing/browserTracingIntegration.js","./node_modules/@sentry/browser/build/npm/esm/tracing/backgroundtab.js","./node_modules/@sentry/angular/fesm2020/sentry-angular.mjs","./node_modules/ngx-device-detector/fesm2022/ngx-device-detector.mjs","./src/app/services/device-detector.service.ts","./src/app/components/app.component.html","./src/app/components/app.component.ts","./src/app/components/download/download.component.ts","./src/app/components/download/download.component.html","./src/app/components/manufacturer/manufacturer.component.ts","./src/app/components/manufacturer/manufacturer.component.html","./src/app/services/app-initialize.service.ts","./src/app/components/signup/login/login.component.html","./src/app/components/signup/login/login.component.ts","./src/app/components/signup/signup-header/signup-header.component.ts","./src/app/components/signup/login/request-password-reset/request-password-reset.component.html","./src/app/components/signup/login/request-password-reset/request-password-reset.component.ts","./src/app/directives/password-check.directive.ts","./src/app/components/signup/login/reset-password/reset-password.component.html","./src/app/components/signup/login/reset-password/reset-password.component.ts","./src/app/components/signup/register/confirmation/confirmation.component.html","./src/app/components/signup/register/confirmation/confirmation.component.ts","./src/app/components/signup/register/terms-of-service/terms-of-service.component.html","./src/app/components/signup/register/terms-of-service/terms-of-service.component.ts","./src/app/components/signup/register/register.component.html","./src/app/components/signup/register/register.component.ts","./src/app/components/visual-units/helpers/example-input-with-selector/example-input-with-selector.html","./src/app/components/visual-units/helpers/example-input-with-selector/example-input-with-selector.ts","./src/app/components/visual-units/visual-units.component.ts","./src/app/components/visual-units/visual-units.component.html","./src/app/components/visual-units/helpers/example-modal/example-modal.html","./src/app/services/preloading-strategy.service.ts","./src/app/app-routing.module.ts","./src/app/interceptors/auth.interceptor.ts","./src/app/interceptors/error.interceptor.data.ts","./src/app/interceptors/error.interceptor.ts","./src/app/app.module.ts","./src/main.ts","./node_modules/dijkstrajs/dijkstra.js","./node_modules/file-saver/dist/FileSaver.min.js","./node_modules/jszip/dist/jszip.min.js","./node_modules/path-browserify/index.js","./node_modules/qrcode/lib/browser.js","./node_modules/qrcode/lib/can-promise.js","./node_modules/qrcode/lib/core/alignment-pattern.js","./node_modules/qrcode/lib/core/alphanumeric-data.js","./node_modules/qrcode/lib/core/bit-buffer.js","./node_modules/qrcode/lib/core/bit-matrix.js","./node_modules/qrcode/lib/core/byte-data.js","./node_modules/qrcode/lib/core/error-correction-code.js","./node_modules/qrcode/lib/core/error-correction-level.js","./node_modules/qrcode/lib/core/finder-pattern.js","./node_modules/qrcode/lib/core/format-info.js","./node_modules/qrcode/lib/core/galois-field.js","./node_modules/qrcode/lib/core/kanji-data.js","./node_modules/qrcode/lib/core/mask-pattern.js","./node_modules/qrcode/lib/core/mode.js","./node_modules/qrcode/lib/core/numeric-data.js","./node_modules/qrcode/lib/core/polynomial.js","./node_modules/qrcode/lib/core/qrcode.js","./node_modules/qrcode/lib/core/reed-solomon-encoder.js","./node_modules/qrcode/lib/core/regex.js","./node_modules/qrcode/lib/core/segments.js","./node_modules/qrcode/lib/core/utils.js","./node_modules/qrcode/lib/core/version-check.js","./node_modules/qrcode/lib/core/version.js","./node_modules/qrcode/lib/renderer/canvas.js","./node_modules/qrcode/lib/renderer/svg-tag.js","./node_modules/qrcode/lib/renderer/utils.js","./node_modules/rxjs/dist/esm/internal/BehaviorSubject.js","./node_modules/rxjs/dist/esm/internal/Observable.js","./node_modules/rxjs/dist/esm/internal/ReplaySubject.js","./node_modules/rxjs/dist/esm/internal/util/ObjectUnsubscribedError.js","./node_modules/rxjs/dist/esm/internal/Subject.js","./node_modules/rxjs/dist/esm/internal/NotificationFactories.js","./node_modules/rxjs/dist/esm/internal/Subscriber.js","./node_modules/rxjs/dist/esm/internal/util/UnsubscriptionError.js","./node_modules/rxjs/dist/esm/internal/Subscription.js","./node_modules/rxjs/dist/esm/internal/config.js","./node_modules/rxjs/dist/esm/internal/firstValueFrom.js","./node_modules/rxjs/dist/esm/internal/observable/ConnectableObservable.js","./node_modules/rxjs/dist/esm/internal/observable/combineLatest.js","./node_modules/rxjs/dist/esm/internal/observable/concat.js","./node_modules/rxjs/dist/esm/internal/operators/concatAll.js","./node_modules/rxjs/dist/esm/internal/observable/defer.js","./node_modules/rxjs/dist/esm/internal/observable/empty.js","./node_modules/rxjs/dist/esm/internal/observable/forkJoin.js","./node_modules/rxjs/dist/esm/internal/operators/observeOn.js","./node_modules/rxjs/dist/esm/internal/operators/subscribeOn.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleAsyncIterable.js","./node_modules/rxjs/dist/esm/internal/observable/from.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduled.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleObservable.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleArray.js","./node_modules/rxjs/dist/esm/internal/scheduled/schedulePromise.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleIterable.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleReadableStreamLike.js","./node_modules/rxjs/dist/esm/internal/observable/fromEvent.js","./node_modules/rxjs/dist/esm/internal/observable/innerFrom.js","./node_modules/rxjs/dist/esm/internal/observable/merge.js","./node_modules/rxjs/dist/esm/internal/observable/of.js","./node_modules/rxjs/dist/esm/internal/observable/throwError.js","./node_modules/rxjs/dist/esm/internal/observable/timer.js","./node_modules/rxjs/dist/esm/internal/util/isDate.js","./node_modules/rxjs/dist/esm/internal/util/argsOrArgArray.js","./node_modules/rxjs/dist/esm/internal/observable/zip.js","./node_modules/rxjs/dist/esm/internal/operators/OperatorSubscriber.js","./node_modules/rxjs/dist/esm/internal/operators/auditTime.js","./node_modules/rxjs/dist/esm/internal/operators/audit.js","./node_modules/rxjs/dist/esm/internal/operators/catchError.js","./node_modules/rxjs/dist/esm/internal/operators/concatMap.js","./node_modules/rxjs/dist/esm/internal/operators/debounceTime.js","./node_modules/rxjs/dist/esm/internal/operators/defaultIfEmpty.js","./node_modules/rxjs/dist/esm/internal/operators/delayWhen.js","./node_modules/rxjs/dist/esm/internal/operators/ignoreElements.js","./node_modules/rxjs/dist/esm/internal/operators/delay.js","./node_modules/rxjs/dist/esm/internal/operators/distinctUntilChanged.js","./node_modules/rxjs/dist/esm/internal/operators/filter.js","./node_modules/rxjs/dist/esm/internal/operators/finalize.js","./node_modules/rxjs/dist/esm/internal/operators/first.js","./node_modules/rxjs/dist/esm/internal/operators/flatMap.js","./node_modules/rxjs/dist/esm/internal/operators/last.js","./node_modules/rxjs/dist/esm/internal/operators/map.js","./node_modules/rxjs/dist/esm/internal/operators/mapTo.js","./node_modules/rxjs/dist/esm/internal/operators/mergeAll.js","./node_modules/rxjs/dist/esm/internal/operators/mergeMap.js","./node_modules/rxjs/dist/esm/internal/operators/mergeInternals.js","./node_modules/rxjs/dist/esm/internal/operators/refCount.js","./node_modules/rxjs/dist/esm/internal/operators/share.js","./node_modules/rxjs/dist/esm/internal/operators/skip.js","./node_modules/rxjs/dist/esm/internal/operators/startWith.js","./node_modules/rxjs/dist/esm/internal/operators/switchMap.js","./node_modules/rxjs/dist/esm/internal/operators/take.js","./node_modules/rxjs/dist/esm/internal/operators/takeLast.js","./node_modules/rxjs/dist/esm/internal/operators/takeUntil.js","./node_modules/rxjs/dist/esm/internal/operators/tap.js","./node_modules/rxjs/dist/esm/internal/operators/throwIfEmpty.js","./node_modules/rxjs/dist/esm/internal/scheduler/Action.js","./node_modules/rxjs/dist/esm/internal/scheduler/intervalProvider.js","./node_modules/rxjs/dist/esm/internal/scheduler/AsyncAction.js","./node_modules/rxjs/dist/esm/internal/Scheduler.js","./node_modules/rxjs/dist/esm/internal/scheduler/AsyncScheduler.js","./node_modules/rxjs/dist/esm/internal/scheduler/animationFrameProvider.js","./node_modules/rxjs/dist/esm/internal/scheduler/animationFrame.js","./node_modules/rxjs/dist/esm/internal/scheduler/AnimationFrameScheduler.js","./node_modules/rxjs/dist/esm/internal/scheduler/AnimationFrameAction.js","./node_modules/rxjs/dist/esm/internal/scheduler/async.js","./node_modules/rxjs/dist/esm/internal/scheduler/dateTimestampProvider.js","./node_modules/rxjs/dist/esm/internal/scheduler/timeoutProvider.js","./node_modules/rxjs/dist/esm/internal/symbol/iterator.js","./node_modules/rxjs/dist/esm/internal/symbol/observable.js","./node_modules/rxjs/dist/esm/internal/util/EmptyError.js","./node_modules/rxjs/dist/esm/internal/util/args.js","./node_modules/rxjs/dist/esm/internal/util/argsArgArrayOrObject.js","./node_modules/rxjs/dist/esm/internal/util/arrRemove.js","./node_modules/rxjs/dist/esm/internal/util/createErrorClass.js","./node_modules/rxjs/dist/esm/internal/util/createObject.js","./node_modules/rxjs/dist/esm/internal/util/errorContext.js","./node_modules/rxjs/dist/esm/internal/util/executeSchedule.js","./node_modules/rxjs/dist/esm/internal/util/identity.js","./node_modules/rxjs/dist/esm/internal/util/isArrayLike.js","./node_modules/rxjs/dist/esm/internal/util/isAsyncIterable.js","./node_modules/rxjs/dist/esm/internal/util/isFunction.js","./node_modules/rxjs/dist/esm/internal/util/isInteropObservable.js","./node_modules/rxjs/dist/esm/internal/util/isIterable.js","./node_modules/rxjs/dist/esm/internal/util/isObservable.js","./node_modules/rxjs/dist/esm/internal/util/isPromise.js","./node_modules/rxjs/dist/esm/internal/util/isReadableStreamLike.js","./node_modules/rxjs/dist/esm/internal/util/isScheduler.js","./node_modules/rxjs/dist/esm/internal/util/lift.js","./node_modules/rxjs/dist/esm/internal/util/mapOneOrManyArgs.js","./node_modules/rxjs/dist/esm/internal/util/noop.js","./node_modules/rxjs/dist/esm/internal/util/pipe.js","./node_modules/rxjs/dist/esm/internal/util/reportUnhandledError.js","./node_modules/rxjs/dist/esm/internal/util/throwUnobservableError.js","./node_modules/sdp/sdp.js","./node_modules/@angular/animations/fesm2022/animations.mjs","./node_modules/@angular/cdk/fesm2022/a11y.mjs","./node_modules/@angular/cdk/fesm2022/bidi.mjs","./node_modules/@angular/cdk/fesm2022/coercion.mjs","./node_modules/@angular/cdk/fesm2022/collections.mjs","./node_modules/@angular/cdk/fesm2022/drag-drop.mjs","./node_modules/rxjs/dist/esm/internal/observable/interval.js","./node_modules/@angular/cdk/fesm2022/keycodes.mjs","./node_modules/@angular/cdk/fesm2022/layout.mjs","./node_modules/@angular/cdk/fesm2022/observers.mjs","./node_modules/@angular/cdk/fesm2022/observers/private.mjs","./node_modules/rxjs/dist/esm/internal/operators/shareReplay.js","./node_modules/@angular/cdk/fesm2022/overlay.mjs","./node_modules/rxjs/dist/esm/internal/operators/takeWhile.js","./node_modules/@angular/cdk/fesm2022/platform.mjs","./node_modules/@angular/cdk/fesm2022/portal.mjs","./node_modules/@angular/cdk/fesm2022/private.mjs","./node_modules/rxjs/dist/esm/internal/util/Immediate.js","./node_modules/rxjs/dist/esm/internal/scheduler/immediateProvider.js","./node_modules/rxjs/dist/esm/internal/scheduler/asap.js","./node_modules/rxjs/dist/esm/internal/scheduler/AsapScheduler.js","./node_modules/rxjs/dist/esm/internal/scheduler/AsapAction.js","./node_modules/@angular/cdk/fesm2022/scrolling.mjs","./node_modules/@angular/cdk/fesm2022/text-field.mjs","./node_modules/@angular/common/fesm2022/common.mjs","./node_modules/@angular/common/fesm2022/http.mjs","./node_modules/@angular/core/fesm2022/primitives/signals.mjs","./node_modules/@angular/core/fesm2022/core.mjs","./node_modules/@angular/forms/fesm2022/forms.mjs","./node_modules/@angular/material/fesm2022/button.mjs","./node_modules/@angular/material/fesm2022/card.mjs","./node_modules/@angular/material/fesm2022/checkbox.mjs","./node_modules/@angular/material/fesm2022/chips.mjs","./node_modules/@angular/material/fesm2022/core.mjs","./node_modules/@angular/material/fesm2022/datepicker.mjs","./node_modules/@angular/cdk/fesm2022/dialog.mjs","./node_modules/@angular/material/fesm2022/dialog.mjs","./node_modules/@angular/material/fesm2022/divider.mjs","./node_modules/@angular/cdk/fesm2022/accordion.mjs","./node_modules/@angular/material/fesm2022/expansion.mjs","./node_modules/@angular/material/fesm2022/form-field.mjs","./node_modules/rxjs/dist/esm/internal/operators/pairwise.js","./node_modules/@angular/material/fesm2022/grid-list.mjs","./node_modules/@angular/material/fesm2022/icon.mjs","./node_modules/@angular/material/fesm2022/input.mjs","./node_modules/@angular/material/fesm2022/list.mjs","./node_modules/@angular/material/fesm2022/menu.mjs","./node_modules/@angular/material/fesm2022/paginator.mjs","./node_modules/@angular/material/fesm2022/progress-spinner.mjs","./node_modules/@angular/material/fesm2022/radio.mjs","./node_modules/@angular/material/fesm2022/select.mjs","./node_modules/@angular/material/fesm2022/sidenav.mjs","./node_modules/@angular/material/fesm2022/slide-toggle.mjs","./node_modules/@angular/material/fesm2022/slider.mjs","./node_modules/@angular/material/fesm2022/snack-bar.mjs","./node_modules/@angular/material/fesm2022/sort.mjs","./node_modules/@angular/cdk/fesm2022/stepper.mjs","./node_modules/@angular/material/fesm2022/stepper.mjs","./node_modules/@angular/cdk/fesm2022/table.mjs","./node_modules/@angular/material/fesm2022/table.mjs","./node_modules/@angular/material/fesm2022/tabs.mjs","./node_modules/@angular/material/fesm2022/toolbar.mjs","./node_modules/@angular/material/fesm2022/tooltip.mjs","./node_modules/@angular/platform-browser/fesm2022/platform-browser.mjs","./node_modules/@angular/router/fesm2022/router.mjs","./node_modules/rxjs/dist/esm/internal/operators/scan.js","./node_modules/rxjs/dist/esm/internal/operators/scanInternals.js","./node_modules/@sentry/core/build/esm/asyncContext/stackStrategy.js","./node_modules/@sentry/core/build/esm/defaultScopes.js","./node_modules/@sentry/core/build/esm/asyncContext/index.js","./node_modules/@sentry/core/build/esm/carrier.js","./node_modules/@sentry/core/build/esm/constants.js","./node_modules/@sentry/core/build/esm/currentScopes.js","./node_modules/@sentry/core/build/esm/debug-build.js","./node_modules/@sentry/core/build/esm/exports.js","./node_modules/@sentry/core/build/esm/metrics/metric-summary.js","./node_modules/@sentry/core/build/esm/scope.js","./node_modules/@sentry/core/build/esm/semanticAttributes.js","./node_modules/@sentry/core/build/esm/session.js","./node_modules/@sentry/core/build/esm/tracing/dynamicSamplingContext.js","./node_modules/@sentry/core/build/esm/tracing/spanstatus.js","./node_modules/@sentry/core/build/esm/utils-hoist/baggage.js","./node_modules/@sentry/core/build/esm/utils-hoist/browser.js","./node_modules/@sentry/core/build/esm/utils-hoist/debug-build.js","./node_modules/@sentry/core/build/esm/utils-hoist/is.js","./node_modules/@sentry/core/build/esm/utils-hoist/logger.js","./node_modules/@sentry/core/build/esm/utils-hoist/misc.js","./node_modules/@sentry/core/build/esm/utils-hoist/normalize.js","./node_modules/@sentry/core/build/esm/utils-hoist/memo.js","./node_modules/@sentry/core/build/esm/utils-hoist/object.js","./node_modules/@sentry/core/build/esm/utils-hoist/propagationContext.js","./node_modules/@sentry/core/build/esm/utils-hoist/stacktrace.js","./node_modules/@sentry/core/build/esm/utils-hoist/string.js","./node_modules/@sentry/core/build/esm/utils-hoist/syncpromise.js","./node_modules/@sentry/core/build/esm/utils-hoist/time.js","./node_modules/@sentry/core/build/esm/utils-hoist/tracing.js","./node_modules/@sentry/core/build/esm/utils-hoist/version.js","./node_modules/@sentry/core/build/esm/utils-hoist/worldwide.js","./node_modules/@sentry/core/build/esm/utils/hasTracingEnabled.js","./node_modules/@sentry/core/build/esm/utils/merge.js","./node_modules/@sentry/core/build/esm/eventProcessors.js","./node_modules/@sentry/core/build/esm/utils-hoist/debug-ids.js","./node_modules/@sentry/core/build/esm/utils/applyScopeDataToEvent.js","./node_modules/@sentry/core/build/esm/utils/prepareEvent.js","./node_modules/@sentry/core/build/esm/utils/spanOnScope.js","./node_modules/@sentry/core/build/esm/utils/spanUtils.js","./node_modules/ngx-window-token/fesm2020/ngx-window-token.mjs","./node_modules/ngx-clipboard/fesm2020/ngx-clipboard.mjs","./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js","./node_modules/@babel/runtime/helpers/esm/typeof.js","./node_modules/@babel/runtime/helpers/esm/defineProperty.js","./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","./node_modules/@babel/runtime/helpers/esm/toPrimitive.js","./node_modules/tslib/tslib.es6.mjs"],"sourceRoot":"webpack:///","sourcesContent":["import { Product } from '../../src/app/business-domain/product.interface';\n\nexport const DEFAULT_PRODUCT: Product = {\n additionalCostsHint: false,\n hexcode: '',\n firstLevelCategoryName: '',\n secondLevelCategoryName: '',\n articleGroup: null,\n articleId: null,\n assetId: 'd2f8b08b-4fa2-408b-b9d6-4f23cd4f29b8',\n assetSourceId: 'fingerhaus',\n assetType: 'OBJECT',\n baseType: '',\n categoryId: '903f3913-8879-4125-afe9-34e7f2c69f93',\n collection: '',\n color: null,\n colorArea: '',\n colorId: null,\n colorName: '',\n coloration: '',\n commodityGroup: null,\n dek_type: '',\n deletionDate: null,\n desc1: null,\n desc2: null,\n desc3: null,\n description: null,\n diafArticleId: null,\n diafQuantityUnit: null,\n dimensions: '2110x860x140mm',\n displayName:\n 'Zimmertür Element LA 3, satinato Glas, Fachwerk Eiche Honig quer CPL, SmartKante, 60mm Bekleidung',\n extendsAssetId: null,\n fallbackSyncId: null,\n fiberType: undefined,\n floorType: '',\n flooringType: '',\n hashValueMD5: null,\n id: 'd2f8b08b-4fa2-408b-b9d6-4f23cd4f29b8',\n imageKeyARM: '',\n imageKeyBC: '',\n imageKeyN: '',\n installation: undefined,\n installationSystem: '',\n isDefault: true,\n isDiafLocked: null,\n isManufacturerAsset: 0,\n isPublished: 'PUBLISHED',\n isRotatable: '',\n layerType: '',\n layingSystem: '',\n length: '',\n livingStyle: null,\n manufacturer: 'FingerHaus GmbH',\n manufacturerUuid: '4ec1364c-6a60-4238-a416-9d968047db59',\n manufacturersId: '02af9d3e-4ff3-4418-a87e-ed0ee07daeed',\n markedForDeletion: 0,\n metallic: '',\n metadata: null,\n name: 'Zimmertür Element LA 3, satinato Glas',\n normal: '',\n note: '',\n path: '/PorterAssetsDoors/Assets/Grauthoff/GrauthoffShowcaseDoors/BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer.BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer',\n pe_bestand: null,\n plankFormat: '',\n preselectionId: '',\n price: '99.99',\n priceGroup: {\n displayName: { de: 'Inklusivleistung' },\n index: '0',\n },\n priceUnit: {\n index: '1',\n displayName: {\n de: 'Stück',\n },\n },\n priority: null,\n productGroup: null,\n productImages: {\n images: [\n {\n imageUrl:\n 'https://s3.eu-central-1.amazonaws.com/xcyde-porter-images/assets/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer.png',\n originalImageUrl:\n 'https://s3.eu-central-1.amazonaws.com/xcyde-porter-images/assets/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer_original.png',\n imageKey:\n 'assets/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer.png',\n },\n ],\n },\n productSchemaId: 'fh-fce92-021a-44a5-b9ed-3a25ba4654d1',\n productType: 'Innentüren',\n randomSeed: '',\n readyNumber: 'PRN-1054',\n roomIds: [],\n roughness: '',\n sorting: '',\n status: 'VISUALIZATION_READY',\n structure: '',\n supplierId: null,\n surfaceTexture: '',\n tags: [],\n textureARM: '',\n textureBC: '',\n textureN: '',\n texturePhysicalLength: '',\n texturePhysicalWidth: '',\n thickness: '',\n thumbnailURL:\n 'https://s3.eu-central-1.amazonaws.com/xcyde-porter-images/assets/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer/thumb-T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer.png',\n thumbnailURL256:\n 'https://s3.eu-central-1.amazonaws.com/xcyde-porter-images/assets/T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer/thumb-T_BP_GTI_GT_ZT_LA3_Satinato_GF_SK_CPL_FachwerkEicheHonigQuer.png',\n typeId: '3a4c3d89-9555-4b11-913b-900398586d84',\n updatedAt: '2023-10-16T15:02:22.000Z',\n upperLayer: '',\n width: '',\n};\n","import { Conversion } from '../temporary-interfaces';\r\n\r\nexport const DEFAULT_CONVERSION: Conversion = {\r\n name: '',\r\n numberOfFiles: 0,\r\n endTime: '',\r\n status: '',\r\n thumbnail: 'https://fml-thumbs-prod.s3.eu-west-1.amazonaws.com/257210586.png',\r\n userId: '1',\r\n id: 'cb015d08-753a-43bd-8096-eea13ae8bc97',\r\n conversionId: '343b4c212eec11ef8aff8b56e48995cf',\r\n startTime: '2024-06-20T10:02:30.000Z',\r\n type: 'AI',\r\n};\r\n","import { FingerhausProject } from '../../src/app/services/building-project.service';\nimport { ConfigurationResponse } from '../../src/app/services/configuration.service';\n\nexport const DEFAULT_CUSTOMER_INFO = {\n title: 'Herr',\n firstName: 'Max',\n lastName: 'Mustermann',\n street: 'Musterstraße 1',\n isocode: 'DE',\n zipcode: 12345,\n city: 'Musterstadt',\n phone: '0123456789',\n email: 'max@mustermann.de'\n};\n\nexport const DEFAULT_BUILDING_PROJECT: FingerhausProject = {\n bvhNumber: \"123456\",\n clientAppointmentDate: \"2024-04-02T02:00:00.000Z\",\n clientUserId: \"54a67ecd-b379-4aaa-805f-bff61f4d21e9\",\n consultantEmail: null,\n consultantFirstName: 'Max',\n consultantLastName: 'Mustermann',\n consultantUserId: null,\n contractSignDate: \"2024-03-05+01:00\",\n lockEmailSent: 1,\n status: \"FINISHED\",\n bvhData: {\n location: '',\n customers: [DEFAULT_CUSTOMER_INFO]\n }\n};\n\nexport const DEFAULT_BUILDING_PROJECT_INFO: ConfigurationResponse = {\n name: \"Max Mustermann\",\n id: \"Test\",\n bvhNumber: \"123456\",\n userId: \"54a67ecd-b379-4aaa-805f-bff61f4d21e9\",\n consultantUserId: \"Berater\",\n levelId: \"1\",\n levelName: \"Testing\",\n accessCode: \"000\",\n note: \"Something\",\n createdAt: \"2025-01-01T00:00:00Z\",\n updatedAt: \"2025-02-10\",\n clientAppointmentDate: \"2030-04-02T02:00:00.000Z\",\n contractSignDate: \"2024-03-05+01:00\",\n lockEmailSent: 1,\n consultantData: {},\n customerData: {},\n isLocked: 1,\n isStyle: 1,\n status: \"FINISHED\",\n actors: 2,\n actorSlots: 2,\n projectStage: undefined,\n bvhData: {\n location: 'Leipheim',\n customers: [DEFAULT_CUSTOMER_INFO]\n }\n};","import { Product } from '../../src/app/business-domain/product.interface';\nimport { ConfigurationResponse } from '../../src/app/services/configuration.service';\nimport { DEFAULT_PRODUCT } from './default-product';\nimport { Conversion } from '../temporary-interfaces';\nimport { DEFAULT_CONVERSION } from './default-conversion';\nimport { FingerhausProject } from '../../src/app/services/building-project.service';\nimport { DEFAULT_BUILDING_PROJECT, DEFAULT_BUILDING_PROJECT_INFO } from './default-building-project';\nexport class MockFactory {\n static createProduct(overrides: Partial = {}): Product {\n return { ...DEFAULT_PRODUCT, ...overrides };\n }\n\n static createConversion(overrides: Partial = {}): Conversion {\n return { ...DEFAULT_CONVERSION, ...overrides };\n }\n\n static createBuildingProject(overrides: Partial = {}): FingerhausProject {\n return { ...DEFAULT_BUILDING_PROJECT, ...overrides };\n }\n\n static createBuildingProjectInfo(overries: Partial = {}): ConfigurationResponse {\n return { ...DEFAULT_BUILDING_PROJECT_INFO, ...overries };\n }\n}\n","import { PriceElementValidation } from './elements/price-badge.element';\nimport { MockFactory } from './factory/mock.factory';\n\nexport const PATH_SEPARATOR = '/';\n\nexport const FH_BASE_URL = 'http://fingerhaus.localhost:4200';\nexport const PORTER_CATALOG_URL = 'http://localhost:4200/produkt-katalog-only';\nexport const PORTER_LOGIN_URL = 'http://localhost:4200/login';\n\nexport const CONFIGURATION_PARAMETER = 'configurationId';\nexport const CONFIGURATION_ID = '9e18d764-44ab-4159-b8cc-f61b060697e3';\n\nexport const PRICE_UNIT = {\n METER: 'm²',\n PIECE: 'Stück',\n LFM: 'Lfm.',\n};\n\nexport const PRICE_GROUP = {\n NORMAL: 'Inklusivleistung',\n EXTRA: 'Mehrpreisleistung',\n};\n\n// NORMAL-PRODUCT\nconst NORMAL_PRODUCT_PRICE_UNIT = MockFactory.createProduct({\n price: '99.99',\n priceGroup: { index: '0', displayName: { de: 'Inklusivleistung' } },\n priceUnit: { index: '1', displayName: { de: 'm²' } },\n});\nconst NORMAL_PRODUCT_PRICE_NO_UNIT = MockFactory.createProduct({\n price: '99.99',\n priceGroup: { index: '0', displayName: { de: 'Inklusivleistung' } },\n priceUnit: null,\n});\nconst NORMAL_PRODUCT_NO_PRICE_UNIT = MockFactory.createProduct({\n price: null,\n priceGroup: { index: '0', displayName: { de: 'Inklusivleistung' } },\n priceUnit: { index: '1', displayName: { de: 'm²' } },\n});\nconst NORMAL_PRODUCT_NO_PRICE_NO_UNIT = MockFactory.createProduct({\n price: null,\n priceGroup: { index: '0', displayName: { de: 'Inklusivleistung' } },\n priceUnit: null,\n});\n\n// EXTRA-PRODUCT\nconst EXTRA_PRODUCT_PRICE_UNIT = MockFactory.createProduct({\n price: '99.99',\n priceGroup: { index: '1', displayName: { de: 'Mehrpreisleistung' } },\n priceUnit: { index: '1', displayName: { de: 'm²' } },\n});\nconst EXTRA_PRODUCT_PRICE_NO_UNIT = MockFactory.createProduct({\n price: '99.99',\n priceGroup: { index: '1', displayName: { de: 'Mehrpreisleistung' } },\n priceUnit: null,\n});\nconst EXTRA_PRODUCT_NO_PRICE_UNIT = MockFactory.createProduct({\n price: null,\n priceGroup: { index: '1', displayName: { de: 'Mehrpreisleistung' } },\n priceUnit: { index: '1', displayName: { de: 'm²' } },\n});\nconst EXTRA_PRODUCT_NO_PRICE_NO_UNIT = MockFactory.createProduct({\n price: null,\n priceGroup: { index: '1', displayName: { de: 'Mehrpreisleistung' } },\n priceUnit: null,\n});\n\n// DATA TO MOCK REQUEST\nexport const DATA = {\n data: [\n NORMAL_PRODUCT_PRICE_UNIT,\n NORMAL_PRODUCT_PRICE_NO_UNIT,\n NORMAL_PRODUCT_NO_PRICE_UNIT,\n NORMAL_PRODUCT_NO_PRICE_NO_UNIT,\n EXTRA_PRODUCT_PRICE_UNIT,\n EXTRA_PRODUCT_PRICE_NO_UNIT,\n EXTRA_PRODUCT_NO_PRICE_UNIT,\n EXTRA_PRODUCT_NO_PRICE_NO_UNIT,\n ],\n};\n\nexport const EMPTY_BODY = [];\nexport const NOT_FOUND = { error: 'Kein Artikel für Hersteller vorhanden' };\n\nexport const PRODUCT_REQUEST_URL = '**/assets/search?page=0&limit=36';\nexport const DIAF_PRODUCT_GROUPS_URL = '**/diaf/productGroups';\nexport const DIAF_ARTICLE_URL =\n '**/diaf/article?manufacturersId=00e338b1-0ed1-4f60-9845-7768e5b8ab6c&manufacturerUuid=123456789123456789';\n\n// VALIDATIONS\nexport const NORMAL_PRODUCT_VALIDATION: PriceElementValidation = {\n icon: 'inclusive_product_check_circle',\n text: ' Inklusivleistung ',\n price: null,\n};\n\nexport const EXTRA_PRODUCT_VALIDATION: PriceElementValidation = {\n icon: null,\n text: ' Mehrpreisleistung ',\n price: ' 99,99 € / m² ',\n};\n\nexport const EXTRA_PRODUCT_VALIDATION_NO_UNIT: PriceElementValidation = {\n icon: null,\n text: ' Mehrpreisleistung ',\n price: ' 99,99 € ',\n};\n\nexport const EXTRA_PRODUCT_VALIDATION_NO_PRICE_NO_UNIT: PriceElementValidation = {\n icon: null,\n text: ' Mehrpreisleistung ',\n price: null,\n};\n\nexport const MANUFACTURER = {\n all: 'Alle Hersteller',\n luebke: 'Lübke baumetal GmbH',\n fingerhaus: 'FingerHaus GmbH',\n};\n\nexport const TEST_PRODUCT_SEARCH = '_E2E';\n\nexport const TEST_PRODUCT_NAME = {\n temporary: 'Temporary Product',\n zero: '_E2E-Testprodukt-0000-Kein Wohnstil-Nicht gesetzt',\n one: '_E2E-Testprodukt-0001-Natürlich-3D-Daten fehlen',\n sixteen: '_E2E-Testprodukt-0016-Kein Wohnstil-Produkt veröffentlicht',\n seventeen: '_E2E-Testprodukt-0017-Natürlich-Produkt veröffentlicht',\n twenty: '_E2E-Testprodukt-0020-Alle Wohnstile-3D-Daten fehlen',\n};\n\nexport const TEST_PAGINATION_PRODUCT_NAME = {\n nineteen: '_E2E-Testprodukt-Pagination-18',\n thirtySeven: '_E2E-Testprodukt-Pagination-37',\n};\n\nexport const TEST_CONFIGURATION_PRODUCT_NAME = {\n one: '_E2E-Testprodukt-Configuration-001',\n two: '_E2E-Testprodukt-Configuration-002',\n};\n\nexport const PRODUCT_NAME = {\n twg: 'TWG Laminat Mega XL Silent Eiche Catalina Skyline Large',\n test: 'Test DG - PORTER GmbH',\n greyWhite: 'Grauweiß',\n brilliantBlue: 'Brillantblau',\n signalViolet: 'Signalviolett',\n floor: 'Test Bodenbelag',\n};\n\nexport const PAGE = {\n one: '1',\n two: '2',\n three: '3',\n four: '4',\n six: '6',\n};\n\nexport const PRODUCT_STATUS = {\n none: 'Alle Status',\n notSet: 'Nicht gesetzt',\n requirementsOpen: 'Anforderungen offen',\n dataMissing: '3D-Daten fehlen',\n dataPresent: '3D-Daten liegen vor',\n dataPrepared: '3D-Daten aufbereitet',\n visualizationReady: 'In 3D bemusterbar',\n productPublished: 'Produkt veröffentlicht',\n};\n\nexport const STORAGE_PATH = {\n fingerhaus_builder: '.auth/fh-builder-storage.json',\n fingerhaus_consultant: '.auth/fh-consultant-storage.json',\n fingerhaus_productManager: '.auth/fh-product-manager-storage.json',\n porter_consultant: '.auth/porter-consultant-storage.json',\n};\n\nconst NG_ATTRIBUTE = {\n disabled: 'ng-reflect-disabled',\n isDisabled: 'ng-reflect-is-disabled',\n invalid: 'ng-invalid',\n model: 'ng-reflect-model',\n};\n\nconst ARIA_ATTRIBUTE = {\n invalid: 'aria-invalid',\n};\n\nconst MAT_ATTRIBUTE = {\n iconName: 'data-mat-icon-name',\n};\n\nexport const ATTRIBUTE = {\n NG: NG_ATTRIBUTE,\n ARIA: ARIA_ATTRIBUTE,\n MAT: MAT_ATTRIBUTE,\n placeholder: 'placeholder',\n dataPlaceholder: 'data-placeholder',\n required: 'required',\n disabled: 'disabled',\n src: 'src',\n};\n\nconst NG_CLASS = {\n pristine: 'ng-pristine',\n};\n\nconst MAT_CLASS = {\n selectDisabled: 'mat-mdc-select-disabled',\n};\n\nexport const CLASS = {\n NG: NG_CLASS,\n MAT: MAT_CLASS,\n accent: 'accent',\n current: 'current',\n favButtonNormal: 'fav-btn-normal',\n};\n\nexport const STRING = {\n empty: '',\n true: 'true',\n false: 'false',\n};\n\nexport const KEYBOARD_KEYS = {\n enter: 'Enter',\n tab: 'Tab',\n};\n\nexport const MAT_ICONS = {\n arrowLeft: 'keyboard_arrow_left',\n arrowRight: 'keyboard_arrow_right',\n};\n","import { Injectable } from '@angular/core';\nimport { Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { AuthService } from './services/auth.service';\n\n@Injectable()\nexport class AuthGuard {\n constructor(\n private authService: AuthService,\n private router: Router,\n ) {}\n\n async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise {\n if (this.authService.isAuthenticated()) {\n if (state.url.startsWith('/login')) {\n await this.router.navigate(['/'], {\n queryParams: { returnUrl: window.location.pathname + window.location.search },\n replaceUrl: true,\n });\n return false;\n }\n return true;\n } else {\n console.log('AuthGuard NOT Authenticated()');\n }\n \n if (\n state.url.startsWith('/login') ||\n state.url.startsWith('/register') ||\n state.url.startsWith('/confirmation')\n ) {\n return true;\n }\n\n await this.router.navigate(['/login'], {\n queryParams: { returnUrl: window.location.pathname + window.location.search },\n });\n \n return false;\n }\n}\n","import { EnvironmentService } from '../../services/environment.service';\nimport { AuthService } from '../../services/auth.service';\nimport { User } from '../../business-domain/User';\nimport { environment } from '../../../environments/environment';\nimport { FEATURE_FLAGS } from '../../shared/constants/feature-flags.constants';\n\nexport interface Fingerhaus {\n isAdmin: boolean;\n isConsultant: boolean;\n isProductManager: boolean;\n isBuilder: boolean;\n isReadOnly: boolean;\n}\n\nexport interface Licences {\n isAi: boolean;\n isPorter: boolean;\n isStreaming: boolean;\n isManufacturer: boolean;\n}\n\nexport interface UserGroups {\n licences: Licences;\n fingerhaus: Fingerhaus;\n isAiAlpha: boolean;\n}\n\nexport class BaseComponent {\n readonly user: User;\n userGroups: UserGroups;\n FEATURE_FLAGS = FEATURE_FLAGS;\n\n constructor(protected environment: EnvironmentService, protected auth: AuthService) {\n this.user = this.auth.getCurrentUser();\n this.userGroups = this.createUserGroups();\n }\n\n isFingerhaus(): boolean {\n return this.environment.isFingerhaus();\n }\n\n isPorter(): boolean {\n return this.environment.isPorter();\n }\n\n isEmbeddedAsIframe(): boolean {\n return window.self !== window.top;\n }\n\n private createUserGroups(): UserGroups {\n return (this.userGroups = {\n isAiAlpha: this.auth.hasUserGroup(environment.AI_ALPHA_GROUP),\n fingerhaus: {\n isAdmin: this.auth.hasUserGroup(environment.FINGERHAUS_ADMIN_GROUP),\n isBuilder: this.auth.hasUserGroup(environment.FINGERHAUS_BUILDER),\n isConsultant: this.auth.hasUserGroup(environment.FINGERHAUS_CONSULTANT_GROUP),\n isProductManager: this.auth.hasUserGroup(environment.FINGERHAUS_PRODUCT_MANAGEMENT_GROUP),\n isReadOnly: this.auth.hasUserGroup(environment.READ_ONLY_GROUP),\n },\n licences: {\n isAi: this.auth.hasUserGroup(environment.AI_LICENCE_GROUPS),\n isManufacturer: this.auth.hasUserGroup(environment.PORTER_MANUFACTURER_GROUPS),\n isPorter: this.auth.hasUserGroup(environment.PORTER_LICENCE_GROUPS),\n isStreaming: this.auth.hasUserGroup(environment.STREAMING_LICENCE_GROUP),\n },\n });\n }\n}\n","
\n\n
\n
\n
\n \n {{ configuration.icon }}\n \n {{ configuration.heading }}\n
\n
\n close\n
\n
\n \n
\n \n
\n \n
\n \n
\n
\n","import {\n Component,\n Input,\n HostBinding,\n EventEmitter,\n Output,\n Renderer2,\n Inject,\n OnDestroy,\n AfterViewInit,\n ViewChild,\n ElementRef,\n} from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport {MaterialIcon} from \"../../shared/interfaces/material-icon.type\";\n\ntype AllowedModalWidth = '400px' | '460px' | '600px' | '800px' | '1000px' | '1200px';\ntype Size = 'S' | 'M' | 'L';\n\nexport interface ModalConfiguration {\n showBackdrop: boolean;\n heading: string;\n size?: Size;\n width: AllowedModalWidth;\n height: string;\n icon?: MaterialIcon;\n}\n\n@Component({\n selector: 'modal',\n templateUrl: './modal.component.html',\n styleUrls: ['./modal.component.scss'],\n standalone: false\n})\nexport class ModalComponent implements OnDestroy, AfterViewInit {\n @ViewChild('backdrop') private backdrop: ElementRef;\n\n @Input() configuration: ModalConfiguration;\n\n @Output() closeEvent: EventEmitter = new EventEmitter();\n\n @HostBinding('style.width') get modalWidth() {\n return this.configuration.width;\n }\n @HostBinding('style.height') get modalHeight() {\n return this.configuration.height;\n }\n\n constructor(@Inject(DOCUMENT) private document: Document, private renderer: Renderer2) {}\n\n ngAfterViewInit() {\n this.addBackdrop();\n }\n\n ngOnDestroy() {\n this.removeBackdrop();\n }\n\n close() {\n this.closeEvent.emit();\n }\n\n private addBackdrop() {\n this.renderer.appendChild(this.document.body, this.backdrop.nativeElement);\n }\n\n private removeBackdrop() {\n this.renderer.removeChild(this.document.body, this.backdrop.nativeElement);\n }\n}\n","import { Directive, Input, ElementRef, Renderer2, OnInit } from '@angular/core';\n\ninterface Element {\n innerText: string;\n}\n\ntype AlertType = 'base' | 'info' | 'success' | 'warning' | 'error';\n\nconst INVALID_TYPE_ERROR_MESSAGE =\n 'You are using an invalid alert type. Please use base, info, success, warning or error as type';\n\nexport interface Alert {\n type?: AlertType;\n showIcon?: boolean;\n collapseIcon?: boolean;\n title?: string;\n text?: string;\n}\n\n@Directive({\n selector: 'alert',\n standalone: false\n})\nexport class AlertDirective implements OnInit, Alert {\n @Input() type: AlertType = 'base';\n @Input() showIcon = true;\n @Input() collapseIcon = false;\n @Input() title: string;\n @Input() text: string;\n\n rootElement: Element = this.el.nativeElement;\n iconElement: Element;\n contentElement: Element;\n titleElement: Element;\n textElement: Element;\n\n constructor(private el: ElementRef, private renderer: Renderer2) {}\n\n ngOnInit() {\n this.addAlertClassToRootElement();\n this.createElements();\n this.setupHierarchy();\n this.handleType();\n this.handleIcon();\n }\n\n private addAlertClassToRootElement() {\n this.renderer.addClass(this.rootElement, 'alert');\n }\n\n private createElements() {\n this.createIconElement();\n this.createContentElement();\n this.createTitleElement();\n this.createTextElement();\n }\n\n private createIconElement() {\n this.iconElement = this.renderer.createElement('mat-icon');\n this.renderer.setAttribute(this.iconElement, 'role', 'img');\n this.renderer.addClass(this.iconElement, 'mat-icon');\n this.renderer.addClass(this.iconElement, 'material-icons');\n }\n\n private createContentElement() {\n this.contentElement = this.renderer.createElement('div');\n this.renderer.addClass(this.contentElement, 'alert-content');\n }\n\n private createTitleElement() {\n this.titleElement = this.renderer.createElement('h2');\n this.renderer.addClass(this.titleElement, 'alert-title');\n this.titleElement.innerText = this.title;\n }\n\n private createTextElement() {\n this.textElement = this.renderer.createElement('div');\n this.textElement.innerText = this.text;\n }\n\n private setupHierarchy() {\n this.renderer.appendChild(this.rootElement, this.iconElement);\n this.renderer.appendChild(this.rootElement, this.contentElement);\n if (this.title) this.renderer.appendChild(this.contentElement, this.titleElement);\n if (this.text) this.renderer.appendChild(this.contentElement, this.textElement);\n }\n\n private handleType() {\n switch (this.type) {\n case 'base':\n if (this.showIcon) this.iconElement.innerText = 'info_outline';\n break;\n case 'info':\n this.renderer.addClass(this.rootElement, 'alert-info');\n this.iconElement.innerText = 'info';\n break;\n case 'success':\n this.renderer.addClass(this.rootElement, 'alert-success');\n this.iconElement.innerText = 'check_circle';\n break;\n case 'warning':\n this.renderer.addClass(this.rootElement, 'alert-warning');\n this.iconElement.innerText = 'warning';\n break;\n case 'error':\n this.renderer.addClass(this.rootElement, 'alert-error');\n this.iconElement.innerText = 'error';\n break;\n default:\n throw new Error(INVALID_TYPE_ERROR_MESSAGE);\n }\n }\n\n private handleIcon() {\n if (this.collapseIcon) this.doCollapseIcon();\n if (!this.showIcon) this.doHideIcon();\n }\n\n private doCollapseIcon() {\n this.renderer.setStyle(this.iconElement, 'display', 'none');\n }\n\n private doHideIcon() {\n this.renderer.setStyle(this.iconElement, 'visibility', 'hidden');\n }\n}\n","import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { AuthService } from '../services/auth.service';\n\n@Directive({\n selector: '[hasFeatureFlag]',\n standalone: false\n})\nexport class HasFeatureFlagDirective {\n constructor(\n private readonly templateRef: TemplateRef,\n private readonly viewContainer: ViewContainerRef,\n private readonly auth: AuthService\n ) {}\n\n @Input()\n set hasFeatureFlag(featureFlag: string) {\n if (this.auth.hasFeatureFlag(featureFlag)) {\n this.viewContainer.createEmbeddedView(this.templateRef);\n }\n }\n}\n","import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms';\n\nexport const requiredErrorValidator: ValidatorFn = (control: UntypedFormGroup): ValidationErrors | null => {\n for (const controlName in control.controls) {\n if (control.controls[controlName].touched && control.controls[controlName].errors && control.controls[controlName].errors.required) {\n return { required: true };\n }\n }\n\n return null;\n};\n","import { Injectable } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { ExporterPluginService } from './services/exporter-plugin.service';\nimport { AuthService } from './services/auth.service';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport {environment} from \"../environments/environment\";\n\n@Injectable()\nexport class ExportPluginGuard {\n constructor(private exporterPluginService: ExporterPluginService, private router: Router, private authService: AuthService) {}\n\n async canActivate(): Promise {\n if (this.exporterPluginService.usesExport() || this.authService.hasUserGroup([environment.adminGroup])) {\n return true;\n } else {\n await this.router.navigate(['/projects'], { queryParams: { returnUrl: window.location.pathname + window.location.search } });\n return false;\n }\n }\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot } from '@angular/router';\nimport { AuthService } from './services/auth.service';\nimport { NavigationService } from './services/navigation.service';\n\n@Injectable()\nexport class FeatureFlagGuard {\n constructor(\n private readonly authService: AuthService,\n private readonly navigationService: NavigationService\n ) {}\n\n async canActivate(route: ActivatedRouteSnapshot): Promise {\n if (this.authService.hasFeatureFlag(route.data.featureFlag)) {\n return true;\n } else {\n await this.navigationService.guardNavigation(route);\n return false;\n }\n }\n}\n","import {Injectable} from '@angular/core';\nimport { HttpParams } from '@angular/common/http';\nimport {Observable, of} from 'rxjs';\nimport {map, switchMap} from 'rxjs/operators';\nimport {AssetService} from '../../../services/asset.service';\nimport {AuthService} from '../../../services/auth.service';\nimport {AssetSearchResult} from '../models/asset-search-result';\n\nconst SHORTCUT_LENGTH = 1;\nconst DASH_LENGTH = 1;\nconst READY_NUMBER_LENGTH = 5;\nconst READY_NUMBER_PARAMETER_NAME = 'readyNumber';\nconst PARTNER_TAG_SHORTCUT = '%';\n\nconst NO_RESULT_FOUND: AssetSearchResult = {\n info: {\n icon: 'error',\n iconColor: 'warn',\n title: 'Die eingegebene PORTER-Ready-Nummer konnte nicht gefunden werden',\n text: 'Bitte überprüfen Sie Ihre Eingabe oder wenden Sie sich an unseren Support',\n },\n};\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ReadyNumberService {\n private partnerTag: string;\n private canSearch: boolean;\n\n constructor(private authService: AuthService, private assetService: AssetService) {}\n\n initialize() {\n this.partnerTag = this.authService.getCurrentUser().partnerTag;\n this.canSearch = !!this.partnerTag;\n }\n\n isValid(term: string): boolean {\n if(!this.canSearch) return false;\n \n const startsWithShortcut = this.startsWithShortcut(term);\n const startsWithPartnerTag = this.startsWithPartnerTag(term);\n const hasValidSearchLength = this.hasValidSearchLength(term);\n const hasValidPorterNumber = this.containsValidPorterReadyNumber(term);\n\n return (startsWithPartnerTag || startsWithShortcut) && hasValidSearchLength && hasValidPorterNumber;\n }\n\n search(term: string): Observable {\n if(!this.isValid(term)) return of(NO_RESULT_FOUND);\n \n term = this.startsWithPartnerTag(term) ? term : this.replaceShortcutWithTag(term);\n return this.fetchAssets(term);\n }\n\n private startsWithPartnerTag(term: string): boolean {\n return term.startsWith(this.partnerTag);\n }\n\n private startsWithShortcut(term: string): boolean {\n return term.startsWith(PARTNER_TAG_SHORTCUT);\n }\n \n private hasValidSearchLength(term: string): boolean {\n const prefixLength = this.startsWithPartnerTag(term) \n ? this.partnerTag.length + DASH_LENGTH \n : SHORTCUT_LENGTH;\n\n return term.length === prefixLength + READY_NUMBER_LENGTH;\n }\n\n private containsValidPorterReadyNumber(term: string): boolean {\n const porterReadyNumber = this.getExpectedReadyNumber(term);\n return this.isNumericString(porterReadyNumber) && this.hasValidLength(porterReadyNumber);\n }\n\n private getExpectedReadyNumber(term: string): string {\n return this.startsWithPartnerTag(term) ? term.substring(this.partnerTag.length + 1) : term.substring(1);\n }\n \n private isNumericString(value: string): boolean {\n return !isNaN(Number(value));\n }\n\n private hasValidLength(porterReadyNumber: string): boolean {\n return porterReadyNumber.length === READY_NUMBER_LENGTH;\n }\n \n private replaceShortcutWithTag(term: string): string {\n return this.partnerTag + '-' + this.getExpectedReadyNumber(term);\n }\n\n private fetchAssets(term: string): Observable {\n const parameters = this.createSearchParameters(term);\n \n return of(parameters).pipe(\n switchMap((params: HttpParams) => this.fetchAssetsByParameters(params)),\n map((result: AssetSearchResult) => this.processSearchResult(result))\n );\n }\n\n private createSearchParameters(term: string): HttpParams {\n let filteredParams = new HttpParams();\n filteredParams = filteredParams.append(READY_NUMBER_PARAMETER_NAME, term);\n return filteredParams;\n }\n\n private fetchAssetsByParameters(searchParams: HttpParams): Observable {\n return this.assetService.fetchAssetsByParameters(searchParams);\n }\n \n private processSearchResult(result: AssetSearchResult): AssetSearchResult {\n if (this.isEmpty(result)) {\n return NO_RESULT_FOUND;\n }\n\n this.markAsFound(result);\n return result;\n }\n\n private isEmpty(search: AssetSearchResult): boolean {\n return !(search.data?.length > 0);\n }\n \n private markAsFound(search: AssetSearchResult) {\n search.foundByReadyNumber = true;\n }\n}\n","export const BUILDING_PROJECT_PATHS = {\n projectNumberParameter: 'bvn',\n};\n","import*as e from\"sdp\";var t,s,n={d:(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},r={};n.d(r,{Dz:()=>ye,g$:()=>A,Lt:()=>k,Q9:()=>x,qf:()=>L,hV:()=>Ae,z$:()=>wt,J0:()=>Pe,De:()=>Te,$C:()=>Ee,al:()=>_,_W:()=>V,Gv:()=>se,m:()=>ne,tz:()=>z,Nu:()=>Re,zg:()=>He,vp:()=>he,vU:()=>ue,wF:()=>J,rv:()=>we,Nh:()=>be,ss:()=>_e,qW:()=>re,QL:()=>te,cf:()=>Ne,eM:()=>j,Yd:()=>i,Tk:()=>Ge,iM:()=>S,qy:()=>a,ce:()=>v,sK:()=>me,Ok:()=>Ce,q5:()=>ke,g:()=>Mt,xl:()=>q,I:()=>$,bx:()=>X,dD:()=>de,Ib:()=>M,Az:()=>w,Iw:()=>b,qY:()=>P,db:()=>R,mR:()=>ie,Tn:()=>C,rV:()=>Y,gh:()=>W,Mi:()=>N,j:()=>K,YB:()=>Q,Yt:()=>ee,i5:()=>Z,x_:()=>Se,Am:()=>pt,eR:()=>F,r8:()=>H,u3:()=>We,vd:()=>O,iV:()=>U,jZ:()=>I,SW:()=>B,ZH:()=>G,Ni:()=>vt,lh:()=>D,ZP:()=>ce,bq:()=>f,$f:()=>ft,eu:()=>le,Ax:()=>oe,Mc:()=>ae});class i{static GetStackTrace(){const e=new Error;let t=\"No Stack Available for this browser\";return e.stack&&(t=e.stack.toString().replace(/Error/g,\"\")),t}static SetLoggerVerbosity(e){null!=this.verboseLogLevel&&(this.verboseLogLevel=e)}static Log(e,t,s){if(s>this.verboseLogLevel)return;const n=`Level: Log\\nMsg: ${t}\\nCaller: ${e}`;console.log(n)}static Info(e,t,s){if(s>this.verboseLogLevel)return;const n=`Level: Info\\nMsg: ${t}`;console.info(n)}static Error(e,t){const s=`Level: Error\\nMsg: ${t}\\nCaller: ${e}`;console.error(s)}static Warning(e,t){const s=`Level: Warning\\nCaller: ${e}\\nMsg: ${t}`;console.warn(s)}}i.verboseLogLevel=5,function(e){e.LIST_STREAMERS=\"listStreamers\",e.SUBSCRIBE=\"subscribe\",e.UNSUBSCRIBE=\"unsubscribe\",e.ICE_CANDIDATE=\"iceCandidate\",e.OFFER=\"offer\",e.ANSWER=\"answer\",e.DATACHANNELREQUEST=\"dataChannelRequest\",e.SFURECVDATACHANNELREADY=\"peerDataChannelsReady\",e.PONG=\"pong\"}(t||(t={}));class a{sendFilter(e,t){return t}payload(){return i.Log(i.GetStackTrace(),\"Sending => \\n\"+JSON.stringify(this,this.sendFilter,4),6),JSON.stringify(this,this.sendFilter)}}class o extends a{constructor(){super(),this.type=t.LIST_STREAMERS}}class l extends a{constructor(e){super(),this.type=t.SUBSCRIBE,this.streamerId=e}}class d extends a{constructor(){super(),this.type=t.UNSUBSCRIBE}}class c extends a{constructor(e){super(),this.type=t.PONG,this.time=e}}class h extends a{constructor(e,s){super(),this.type=t.OFFER,this.minBitrate=0,this.maxBitrate=0,e&&(this.type=e.type,this.sdp=e.sdp,this.minBitrate=s.minBitrateBps,this.maxBitrate=s.maxBitrateBps)}sendFilter(e,t){if(\"minBitrate\"!=e&&\"maxBitrate\"!=e||!(t<=0))return t}}class u extends a{constructor(e,s){super(),this.type=t.ANSWER,this.minBitrate=0,this.maxBitrate=0,e&&(this.type=e.type,this.sdp=e.sdp,this.minBitrate=s.minBitrateBps,this.maxBitrate=s.maxBitrateBps)}sendFilter(e,t){if(\"minBitrate\"!=e&&\"maxBitrate\"!=e||!(t<=0))return t}}class g extends a{constructor(){super(),this.type=t.DATACHANNELREQUEST}}class m extends a{constructor(){super(),this.type=t.SFURECVDATACHANNELREADY}}class p{constructor(e){this.type=t.ICE_CANDIDATE,this.candidate=e}payload(){return i.Log(i.GetStackTrace(),\"Sending => \\n\"+JSON.stringify(this,void 0,4),6),JSON.stringify(this)}}!function(e){e.CONFIG=\"config\",e.STREAMER_LIST=\"streamerList\",e.STREAMER_ID_CHANGED=\"streamerIDChanged\",e.PLAYER_COUNT=\"playerCount\",e.OFFER=\"offer\",e.ANSWER=\"answer\",e.ICE_CANDIDATE=\"iceCandidate\",e.PEER_DATA_CHANNELS=\"peerDataChannels\",e.PING=\"ping\",e.WARNING=\"warning\"}(s||(s={}));class S{}class v extends S{}class C{constructor(){this.FromUEMessageHandlers=new Map}addMessageHandler(e,t){this.FromUEMessageHandlers.set(e,t)}handleMessage(e,t){this.FromUEMessageHandlers.has(e)?this.FromUEMessageHandlers.get(e)(t):i.Error(i.GetStackTrace(),`Message type of ${e} does not have a message handler registered on the frontend - ignoring message.`)}static setupDefaultHandlers(e){e.signallingProtocol.addMessageHandler(s.PING,(t=>{const n=new c((new Date).getTime()).payload();i.Log(i.GetStackTrace(),s.PING+\": \"+t,6),e.webSocket.send(n)})),e.signallingProtocol.addMessageHandler(s.CONFIG,(t=>{i.Log(i.GetStackTrace(),s.CONFIG,6);const n=JSON.parse(t);e.onConfig(n)})),e.signallingProtocol.addMessageHandler(s.STREAMER_LIST,(t=>{i.Log(i.GetStackTrace(),s.STREAMER_LIST,6);const n=JSON.parse(t);e.onStreamerList(n)})),e.signallingProtocol.addMessageHandler(s.STREAMER_ID_CHANGED,(t=>{i.Log(i.GetStackTrace(),s.STREAMER_ID_CHANGED,6);const n=JSON.parse(t);e.onStreamerIDChanged(n)})),e.signallingProtocol.addMessageHandler(s.PLAYER_COUNT,(t=>{i.Log(i.GetStackTrace(),s.PLAYER_COUNT,6);const n=JSON.parse(t);i.Log(i.GetStackTrace(),\"Player Count: \"+n.count,6),e.onPlayerCount(n)})),e.signallingProtocol.addMessageHandler(s.ANSWER,(t=>{i.Log(i.GetStackTrace(),s.ANSWER,6);const n=JSON.parse(t);e.onWebRtcAnswer(n)})),e.signallingProtocol.addMessageHandler(s.OFFER,(t=>{i.Log(i.GetStackTrace(),s.OFFER,6);const n=JSON.parse(t);e.onWebRtcOffer(n)})),e.signallingProtocol.addMessageHandler(s.ICE_CANDIDATE,(t=>{i.Log(i.GetStackTrace(),s.ICE_CANDIDATE,6);const n=JSON.parse(t);e.onIceCandidate(n.candidate)})),e.signallingProtocol.addMessageHandler(s.WARNING,(e=>{i.Warning(i.GetStackTrace(),`Warning received: ${e}`)})),e.signallingProtocol.addMessageHandler(s.PEER_DATA_CHANNELS,(t=>{i.Log(i.GetStackTrace(),s.PEER_DATA_CHANNELS,6);const n=JSON.parse(t);e.onWebRtcPeerDataChannels(n)}))}}class f{constructor(){this.WS_OPEN_STATE=1,this.onOpen=new EventTarget,this.onClose=new EventTarget,this.signallingProtocol=new C,C.setupDefaultHandlers(this)}connect(e){i.Log(i.GetStackTrace(),e,6);try{return this.webSocket=new WebSocket(e),this.webSocket.onopen=e=>this.handleOnOpen(e),this.webSocket.onerror=()=>this.handleOnError(),this.webSocket.onclose=e=>this.handleOnClose(e),this.webSocket.onmessage=e=>this.handleOnMessage(e),this.webSocket.onmessagebinary=e=>this.handleOnMessageBinary(e),!0}catch(e){return i.Error(e,e),!1}}handleOnMessageBinary(e){e&&e.data&&e.data.text().then((e=>{const t=new MessageEvent(\"messageFromBinary\",{data:e});this.handleOnMessage(t)})).catch((e=>{i.Error(i.GetStackTrace(),`Failed to parse binary blob from websocket, reason: ${e}`)}))}handleOnMessage(e){if(e.data&&e.data instanceof Blob)return void this.handleOnMessageBinary(e);const t=JSON.parse(e.data);i.Log(i.GetStackTrace(),\"received => \\n\"+JSON.stringify(JSON.parse(e.data),void 0,4),6),this.signallingProtocol.handleMessage(t.type,e.data)}handleOnOpen(e){i.Log(i.GetStackTrace(),\"Connected to the signalling server via WebSocket\",6),this.onOpen.dispatchEvent(new Event(\"open\"))}handleOnError(){i.Error(i.GetStackTrace(),\"WebSocket error\")}handleOnClose(e){i.Log(i.GetStackTrace(),\"Disconnected to the signalling server via WebSocket: \"+JSON.stringify(e.code)+\" - \"+e.reason),this.onClose.dispatchEvent(new CustomEvent(\"close\",{detail:e}))}requestStreamerList(){const e=new o;this.webSocket.send(e.payload())}sendSubscribe(e){const t=new l(e);this.webSocket.send(t.payload())}sendUnsubscribe(){const e=new d;this.webSocket.send(e.payload())}sendWebRtcOffer(e,t){const s=new h(e,t);this.webSocket.send(s.payload())}sendWebRtcAnswer(e,t){const s=new u(e,t);this.webSocket.send(s.payload())}sendWebRtcDatachannelRequest(){const e=new g;this.webSocket.send(e.payload())}sendSFURecvDataChannelReady(){const e=new m;this.webSocket.send(e.payload())}sendIceCandidate(e){if(i.Log(i.GetStackTrace(),\"Sending Ice Candidate\"),this.webSocket&&this.webSocket.readyState===this.WS_OPEN_STATE){const t=new p(e);this.webSocket.send(t.payload())}}close(){var e;null===(e=this.webSocket)||void 0===e||e.close()}onConfig(e){}onStreamerList(e){}onStreamerIDChanged(e){}onIceCandidate(e){}onWebRtcAnswer(e){}onWebRtcOffer(e){}onWebRtcPeerDataChannels(e){}onPlayerCount(e){}}class T{constructor(e){this.videoElementProvider=e,this.audioElement=document.createElement(\"Audio\"),this.videoElementProvider.setAudioElement(this.audioElement)}handleOnTrack(e){if(i.Log(i.GetStackTrace(),\"handleOnTrack \"+JSON.stringify(e.streams),6),\"probator\"==e.track.id)return;const t=this.videoElementProvider.getVideoElement();if(e.track&&i.Log(i.GetStackTrace(),\"Got track - \"+e.track.kind+\" id=\"+e.track.id+\" readyState=\"+e.track.readyState,6),\"audio\"!=e.track.kind)return\"video\"==e.track.kind&&t.srcObject!==e.streams[0]?(t.srcObject=e.streams[0],void i.Log(i.GetStackTrace(),\"Set video source from video track ontrack.\")):void 0;this.CreateAudioTrack(e.streams[0])}CreateAudioTrack(e){const t=this.videoElementProvider.getVideoElement();t.srcObject!=e&&t.srcObject&&t.srcObject!==e&&(this.audioElement.srcObject=e,i.Log(i.GetStackTrace(),\"Created new audio element to play separate audio stream.\"))}}class E{constructor(e){this.freezeFrameHeight=0,this.freezeFrameWidth=0,this.rootDiv=e,this.rootElement=document.createElement(\"div\"),this.rootElement.id=\"freezeFrame\",this.rootElement.style.display=\"none\",this.rootElement.style.pointerEvents=\"none\",this.rootElement.style.position=\"absolute\",this.rootElement.style.zIndex=\"20\",this.imageElement=document.createElement(\"img\"),this.imageElement.style.position=\"absolute\",this.rootElement.appendChild(this.imageElement),this.rootDiv.appendChild(this.rootElement)}setElementForShow(){this.rootElement.style.display=\"block\"}setElementForHide(){this.rootElement.style.display=\"none\"}updateImageElementSource(e){const t=btoa(e.reduce(((e,t)=>e+String.fromCharCode(t)),\"\"));this.imageElement.src=\"data:image/jpeg;base64,\"+t}setDimensionsFromElementAndResize(){this.freezeFrameHeight=this.imageElement.naturalHeight,this.freezeFrameWidth=this.imageElement.naturalWidth,this.resize()}resize(){if(0!==this.freezeFrameWidth&&0!==this.freezeFrameHeight){let e=0,t=0,s=0,n=0;const r=this.rootDiv.clientWidth/this.rootDiv.clientHeight,i=this.freezeFrameWidth/this.freezeFrameHeight;r{this.freezeFrame.setDimensionsFromElementAndResize(),t()}}processFreezeFrameMessage(e,t){this.receiving||(this.receiving=!0,this.valid=!1,this.size=0,this.jpeg=void 0),this.size=new DataView(e.slice(1,5).buffer).getInt32(0,!0);const s=e.slice(5);if(this.jpeg){const e=new Uint8Array(this.jpeg.length+s.length);e.set(this.jpeg,0),e.set(s,this.jpeg.length),this.jpeg=e}else this.jpeg=s,this.receiving=!0,i.Log(i.GetStackTrace(),`received first chunk of freeze frame: ${this.jpeg.length}/${this.size}`,6);this.jpeg.length===this.size?(this.receiving=!1,this.valid=!0,i.Log(i.GetStackTrace(),`received complete freeze frame ${this.size}`,6),this.updateFreezeFrameAndShow(this.jpeg,t)):this.jpeg.length>this.size&&(i.Error(i.GetStackTrace(),`received bigger freeze frame than advertised: ${this.jpeg.length}/${this.size}`),this.jpeg=void 0,this.receiving=!1)}}class M{constructor(e,t,s,n,r=(()=>{})){this.onChange=r,this.onChangeEmit=()=>{},this.id=e,this.description=s,this.label=t,this.value=n}set label(e){this._label=e,this.onChangeEmit(this._value)}get label(){return this._label}get value(){return this._value}set value(e){this._value=e,this.onChange(this._value,this),this.onChangeEmit(this._value)}}class w extends M{constructor(e,t,s,n,r,i=(()=>{})){super(e,t,s,n,i);const a=new URLSearchParams(window.location.search);if(r&&a.has(this.id)){const e=this.getUrlParamFlag();this.flag=e}else this.flag=n;this.useUrlParams=r}getUrlParamFlag(){const e=new URLSearchParams(window.location.search);return!!e.has(this.id)&&\"false\"!==e.get(this.id)&&\"False\"!==e.get(this.id)}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);!0===this.flag?e.set(this.id,\"true\"):e.set(this.id,\"false\"),window.history.replaceState({},\"\",\"\"!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}enable(){this.flag=!0}get flag(){return!!this.value}set flag(e){this.value=e}}class b extends M{constructor(e,t,s,n,r,i,a,o=(()=>{})){super(e,t,s,i,o),this._min=n,this._max=r;const l=new URLSearchParams(window.location.search);if(a&&l.has(this.id)){const e=Number.parseFloat(l.get(this.id));this.number=Number.isNaN(e)?i:e}else this.number=i;this.useUrlParams=a}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);e.set(this.id,this.number.toString()),window.history.replaceState({},\"\",\"\"!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}set number(e){this.value=this.clamp(e)}get number(){return this.value}clamp(e){return null==this._min&&null==this._max?e:null==this._min?Math.min(this._max,e):null==this._max?Math.max(this._min,e):Math.max(Math.min(this._max,e),this._min)}get min(){return this._min}get max(){return this._max}addOnChangedListener(e){this.onChange=e}}class R extends M{constructor(e,t,s,n,r,i=(()=>{})){super(e,t,s,n,i);const a=new URLSearchParams(window.location.search);if(r&&a.has(this.id)){const e=this.getUrlParamText();this.text=e}else this.text=n;this.useUrlParams=r}getUrlParamText(){var e;const t=new URLSearchParams(window.location.search);return t.has(this.id)&&null!==(e=t.get(this.id))&&void 0!==e?e:\"\"}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);e.set(this.id,this.text),window.history.replaceState({},\"\",\"\"!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}get text(){return this.value}set text(e){this.value=e}}class P extends M{constructor(e,t,s,n,r,i,a=(()=>{})){super(e,t,s,n,a),this.options=r;const o=new URLSearchParams(window.location.search),l=i&&o.has(this.id)?this.getUrlParamText():n;this.selected=l,this.useUrlParams=i}getUrlParamText(){var e;const t=new URLSearchParams(window.location.search);return t.has(this.id)&&null!==(e=t.get(this.id))&&void 0!==e?e:\"\"}updateURLParams(){if(this.useUrlParams){const e=new URLSearchParams(window.location.search);e.set(this.id,this.selected),window.history.replaceState({},\"\",\"\"!==e.toString()?`${location.pathname}?${e}`:`${location.pathname}`)}}addOnChangedListener(e){this.onChange=e}get options(){return this._options}set options(e){this._options=e,this.onChangeEmit(this.selected)}get selected(){return this.value}set selected(e){let t=this.options.filter((t=>-1!==t.indexOf(e)));t.length?this.value=t[0]:(t=this.options.filter((t=>-1!==t.indexOf(e.split(\" \")[0]))),t.length&&(this.value=t[0]))}}class k extends Event{constructor(e){super(\"afkWarningActivate\"),this.data=e}}class L extends Event{constructor(e){super(\"afkWarningUpdate\"),this.data=e}}class x extends Event{constructor(){super(\"afkWarningDeactivate\")}}class A extends Event{constructor(){super(\"afkTimedOut\")}}class F extends Event{constructor(e){super(\"videoEncoderAvgQP\"),this.data=e}}class D extends Event{constructor(){super(\"webRtcSdp\")}}class O extends Event{constructor(){super(\"webRtcAutoConnect\")}}class I extends Event{constructor(){super(\"webRtcConnecting\")}}class U extends Event{constructor(){super(\"webRtcConnected\")}}class G extends Event{constructor(){super(\"webRtcFailed\")}}class B extends Event{constructor(e){super(\"webRtcDisconnected\"),this.data=e}}class z extends Event{constructor(e){super(\"dataChannelOpen\"),this.data=e}}class _ extends Event{constructor(e){super(\"dataChannelClose\"),this.data=e}}class V extends Event{constructor(e){super(\"dataChannelError\"),this.data=e}}class H extends Event{constructor(){super(\"videoInitialized\")}}class W extends Event{constructor(){super(\"streamLoading\")}}class N extends Event{constructor(){super(\"streamConnect\")}}class K extends Event{constructor(){super(\"streamDisconnect\")}}class Q extends Event{constructor(){super(\"streamReconnect\")}}class q extends Event{constructor(e){super(\"playStreamError\"),this.data=e}}class $ extends Event{constructor(){super(\"playStream\")}}class X extends Event{constructor(e){super(\"playStreamRejected\"),this.data=e}}class j extends Event{constructor(e){super(\"loadFreezeFrame\"),this.data=e}}class J extends Event{constructor(){super(\"hideFreezeFrame\")}}class Y extends Event{constructor(e){super(\"statsReceived\"),this.data=e}}class Z extends Event{constructor(e){super(\"streamerListMessage\"),this.data=e}}class ee extends Event{constructor(e){super(\"StreamerIDChangedMessage\"),this.data=e}}class te extends Event{constructor(e){super(\"latencyTestResult\"),this.data=e}}class se extends Event{constructor(e){super(\"dataChannelLatencyTestResponse\"),this.data=e}}class ne extends Event{constructor(e){super(\"dataChannelLatencyTestResult\"),this.data=e}}class re extends Event{constructor(e){super(\"initialSettings\"),this.data=e}}class ie extends Event{constructor(e){super(\"settingsChanged\"),this.data=e}}class ae extends Event{constructor(){super(\"xrSessionStarted\")}}class oe extends Event{constructor(){super(\"xrSessionEnded\")}}class le extends Event{constructor(e){super(\"xrFrame\"),this.data=e}}class de extends Event{constructor(e){super(\"playerCount\"),this.data=e}}class ce extends Event{constructor(){super(\"webRtcTCPRelayDetected\")}}class he extends EventTarget{dispatchEvent(e){return super.dispatchEvent(e)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}}class ue{}ue.AutoConnect=\"AutoConnect\",ue.AutoPlayVideo=\"AutoPlayVideo\",ue.AFKDetection=\"TimeoutIfIdle\",ue.BrowserSendOffer=\"OfferToReceive\",ue.HoveringMouseMode=\"HoveringMouse\",ue.ForceMonoAudio=\"ForceMonoAudio\",ue.ForceTURN=\"ForceTURN\",ue.FakeMouseWithTouches=\"FakeMouseWithTouches\",ue.IsQualityController=\"ControlsQuality\",ue.MatchViewportResolution=\"MatchViewportRes\",ue.StartVideoMuted=\"StartVideoMuted\",ue.SuppressBrowserKeys=\"SuppressBrowserKeys\",ue.UseMic=\"UseMic\",ue.KeyboardInput=\"KeyboardInput\",ue.MouseInput=\"MouseInput\",ue.TouchInput=\"TouchInput\",ue.GamepadInput=\"GamepadInput\",ue.XRControllerInput=\"XRControllerInput\",ue.WaitForStreamer=\"WaitForStreamer\",ue.HideUI=\"HideUI\";const ge=e=>Object.getOwnPropertyNames(ue).some((t=>ue[t]===e));class me{}me.AFKTimeoutSecs=\"AFKTimeout\",me.AFKCountdownSecs=\"AFKCountdown\",me.MinQP=\"MinQP\",me.MaxQP=\"MaxQP\",me.WebRTCFPS=\"WebRTCFPS\",me.WebRTCMinBitrate=\"WebRTCMinBitrate\",me.WebRTCMaxBitrate=\"WebRTCMaxBitrate\",me.MaxReconnectAttempts=\"MaxReconnectAttempts\",me.StreamerAutoJoinInterval=\"StreamerAutoJoinInterval\";const pe=e=>Object.getOwnPropertyNames(me).some((t=>me[t]===e));class Se{}Se.SignallingServerUrl=\"ss\";const ve=e=>Object.getOwnPropertyNames(Se).some((t=>Se[t]===e));class Ce{}Ce.PreferredCodec=\"PreferredCodec\",Ce.StreamerId=\"StreamerId\";const fe=e=>Object.getOwnPropertyNames(Ce).some((t=>Ce[t]===e));class Te{constructor(e={}){this.flags=new Map,this.numericParameters=new Map,this.textParameters=new Map,this.optionParameters=new Map;const{initialSettings:t,useUrlParams:s}=e;this._useUrlParams=!!s,this.populateDefaultSettings(this._useUrlParams,t)}get useUrlParams(){return this._useUrlParams}populateDefaultSettings(e,t){this.textParameters.set(Se.SignallingServerUrl,new R(Se.SignallingServerUrl,\"Signalling url\",\"Url of the signalling server\",t&&t.hasOwnProperty(Se.SignallingServerUrl)?t[Se.SignallingServerUrl]:(\"https:\"===location.protocol?\"wss://\":\"ws://\")+window.location.hostname+(\"80\"===window.location.port||\"\"===window.location.port?\"\":`:${window.location.port}`),e)),this.optionParameters.set(Ce.StreamerId,new P(Ce.StreamerId,\"Streamer ID\",\"The ID of the streamer to stream.\",t&&t.hasOwnProperty(Ce.StreamerId)?t[Ce.StreamerId]:\"\",[],e)),this.optionParameters.set(Ce.PreferredCodec,new P(Ce.PreferredCodec,\"Preferred Codec\",\"The preferred codec to be used during codec negotiation\",\"H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\",t&&t.hasOwnProperty(Ce.PreferredCodec)?[t[Ce.PreferredCodec]]:function(){const e=[];if(!RTCRtpReceiver.getCapabilities)return e.push(\"Only available on Chrome\"),e;const t=/(VP\\d|H26\\d|AV1).*/;return RTCRtpReceiver.getCapabilities(\"video\").codecs.forEach((s=>{const n=s.mimeType.split(\"/\")[1]+\" \"+(s.sdpFmtpLine||\"\");null!==t.exec(n)&&e.push(n)})),e}(),e)),this.flags.set(ue.AutoConnect,new w(ue.AutoConnect,\"Auto connect to stream\",\"Whether we should attempt to auto connect to the signalling server or show a click to start prompt.\",!(!t||!t.hasOwnProperty(ue.AutoConnect))&&t[ue.AutoConnect],e)),this.flags.set(ue.AutoPlayVideo,new w(ue.AutoPlayVideo,\"Auto play video\",\"When video is ready automatically start playing it as opposed to showing a play button.\",!t||!t.hasOwnProperty(ue.AutoPlayVideo)||t[ue.AutoPlayVideo],e)),this.flags.set(ue.BrowserSendOffer,new w(ue.BrowserSendOffer,\"Browser send offer\",\"Browser will initiate the WebRTC handshake by sending the offer to the streamer\",!(!t||!t.hasOwnProperty(ue.BrowserSendOffer))&&t[ue.BrowserSendOffer],e)),this.flags.set(ue.UseMic,new w(ue.UseMic,\"Use microphone\",\"Make browser request microphone access and open an input audio track.\",!(!t||!t.hasOwnProperty(ue.UseMic))&&t[ue.UseMic],e)),this.flags.set(ue.StartVideoMuted,new w(ue.StartVideoMuted,\"Start video muted\",\"Video will start muted if true.\",!(!t||!t.hasOwnProperty(ue.StartVideoMuted))&&t[ue.StartVideoMuted],e)),this.flags.set(ue.SuppressBrowserKeys,new w(ue.SuppressBrowserKeys,\"Suppress browser keys\",\"Suppress certain browser keys that we use in UE, for example F5 to show shader complexity instead of refresh the page.\",!t||!t.hasOwnProperty(ue.SuppressBrowserKeys)||t[ue.SuppressBrowserKeys],e)),this.flags.set(ue.IsQualityController,new w(ue.IsQualityController,\"Is quality controller?\",\"True if this peer controls stream quality\",!t||!t.hasOwnProperty(ue.IsQualityController)||t[ue.IsQualityController],e)),this.flags.set(ue.ForceMonoAudio,new w(ue.ForceMonoAudio,\"Force mono audio\",\"Force browser to request mono audio in the SDP\",!(!t||!t.hasOwnProperty(ue.ForceMonoAudio))&&t[ue.ForceMonoAudio],e)),this.flags.set(ue.ForceTURN,new w(ue.ForceTURN,\"Force TURN\",\"Only generate TURN/Relayed ICE candidates.\",!(!t||!t.hasOwnProperty(ue.ForceTURN))&&t[ue.ForceTURN],e)),this.flags.set(ue.AFKDetection,new w(ue.AFKDetection,\"AFK if idle\",\"Timeout the experience if user is AFK for a period.\",!(!t||!t.hasOwnProperty(ue.AFKDetection))&&t[ue.AFKDetection],e)),this.flags.set(ue.MatchViewportResolution,new w(ue.MatchViewportResolution,\"Match viewport resolution\",\"Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.\",!(!t||!t.hasOwnProperty(ue.MatchViewportResolution))&&t[ue.MatchViewportResolution],e)),this.flags.set(ue.HoveringMouseMode,new w(ue.HoveringMouseMode,\"Control Scheme: Locked Mouse\",\"Either locked mouse, where the pointer is consumed by the video and locked to it, or hovering mouse, where the mouse is not consumed.\",!(!t||!t.hasOwnProperty(ue.HoveringMouseMode))&&t[ue.HoveringMouseMode],e,((e,t)=>{t.label=`Control Scheme: ${e?\"Hovering\":\"Locked\"} Mouse`}))),this.flags.set(ue.FakeMouseWithTouches,new w(ue.FakeMouseWithTouches,\"Fake mouse with touches\",\"A single finger touch is converted into a mouse event. This allows a non-touch application to be controlled partially via a touch device.\",!(!t||!t.hasOwnProperty(ue.FakeMouseWithTouches))&&t[ue.FakeMouseWithTouches],e)),this.flags.set(ue.KeyboardInput,new w(ue.KeyboardInput,\"Keyboard input\",\"If enabled, send keyboard events to streamer\",!t||!t.hasOwnProperty(ue.KeyboardInput)||t[ue.KeyboardInput],e)),this.flags.set(ue.MouseInput,new w(ue.MouseInput,\"Mouse input\",\"If enabled, send mouse events to streamer\",!t||!t.hasOwnProperty(ue.MouseInput)||t[ue.MouseInput],e)),this.flags.set(ue.TouchInput,new w(ue.TouchInput,\"Touch input\",\"If enabled, send touch events to streamer\",!t||!t.hasOwnProperty(ue.TouchInput)||t[ue.TouchInput],e)),this.flags.set(ue.GamepadInput,new w(ue.GamepadInput,\"Gamepad input\",\"If enabled, send gamepad events to streamer\",!t||!t.hasOwnProperty(ue.GamepadInput)||t[ue.GamepadInput],e)),this.flags.set(ue.XRControllerInput,new w(ue.XRControllerInput,\"XR controller input\",\"If enabled, send XR controller events to streamer\",!t||!t.hasOwnProperty(ue.XRControllerInput)||t[ue.XRControllerInput],e)),this.flags.set(ue.WaitForStreamer,new w(ue.WaitForStreamer,\"Wait for streamer\",\"Will continue trying to connect to the first streamer available.\",!t||!t.hasOwnProperty(ue.WaitForStreamer)||t[ue.WaitForStreamer],e)),this.flags.set(ue.HideUI,new w(ue.HideUI,\"Hide the UI overlay\",\"Will hide all UI overlay details\",!(!t||!t.hasOwnProperty(ue.HideUI))&&t[ue.HideUI],e)),this.numericParameters.set(me.AFKTimeoutSecs,new b(me.AFKTimeoutSecs,\"AFK timeout\",\"The time (in seconds) it takes for the application to time out if AFK timeout is enabled.\",0,null,t&&t.hasOwnProperty(me.AFKTimeoutSecs)?t[me.AFKTimeoutSecs]:120,e)),this.numericParameters.set(me.AFKCountdownSecs,new b(me.AFKCountdownSecs,\"AFK countdown\",\"The time (in seconds) for a user to respond before the stream is ended after an AFK timeout.\",10,null,10,e)),this.numericParameters.set(me.MaxReconnectAttempts,new b(me.MaxReconnectAttempts,\"Max Reconnects\",\"Maximum number of reconnects the application will attempt when a streamer disconnects.\",0,999,t&&t.hasOwnProperty(me.MaxReconnectAttempts)?t[me.MaxReconnectAttempts]:3,e)),this.numericParameters.set(me.MinQP,new b(me.MinQP,\"Min QP\",\"The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.\",0,51,t&&t.hasOwnProperty(me.MinQP)?t[me.MinQP]:0,e)),this.numericParameters.set(me.MaxQP,new b(me.MaxQP,\"Max QP\",\"The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.\",0,51,t&&t.hasOwnProperty(me.MaxQP)?t[me.MaxQP]:51,e)),this.numericParameters.set(me.WebRTCFPS,new b(me.WebRTCFPS,\"Max FPS\",\"The maximum FPS that WebRTC will try to transmit frames at.\",1,999,t&&t.hasOwnProperty(me.WebRTCFPS)?t[me.WebRTCFPS]:60,e)),this.numericParameters.set(me.WebRTCMinBitrate,new b(me.WebRTCMinBitrate,\"Min Bitrate (kbps)\",\"The minimum bitrate that WebRTC should use.\",0,5e5,t&&t.hasOwnProperty(me.WebRTCMinBitrate)?t[me.WebRTCMinBitrate]:0,e)),this.numericParameters.set(me.WebRTCMaxBitrate,new b(me.WebRTCMaxBitrate,\"Max Bitrate (kbps)\",\"The maximum bitrate that WebRTC should use.\",0,5e5,t&&t.hasOwnProperty(me.WebRTCMaxBitrate)?t[me.WebRTCMaxBitrate]:0,e)),this.numericParameters.set(me.StreamerAutoJoinInterval,new b(me.StreamerAutoJoinInterval,\"Streamer Auto Join Interval (ms)\",\"Delay between retries when waiting for an available streamer.\",500,9e5,t&&t.hasOwnProperty(me.StreamerAutoJoinInterval)?t[me.StreamerAutoJoinInterval]:3e3,e))}_addOnNumericSettingChangedListener(e,t){this.numericParameters.has(e)&&this.numericParameters.get(e).addOnChangedListener(t)}_addOnOptionSettingChangedListener(e,t){this.optionParameters.has(e)&&this.optionParameters.get(e).addOnChangedListener(t)}getNumericSettingValue(e){if(this.numericParameters.has(e))return this.numericParameters.get(e).number;throw new Error(`There is no numeric setting with the id of ${e}`)}getTextSettingValue(e){if(this.textParameters.has(e))return this.textParameters.get(e).value;throw new Error(`There is no numeric setting with the id of ${e}`)}setNumericSetting(e,t){if(!this.numericParameters.has(e))throw new Error(`There is no numeric setting with the id of ${e}`);this.numericParameters.get(e).number=t}_addOnSettingChangedListener(e,t){this.flags.has(e)&&(this.flags.get(e).onChange=t)}_addOnTextSettingChangedListener(e,t){this.textParameters.has(e)&&(this.textParameters.get(e).onChange=t)}getSettingOption(e){return this.optionParameters.get(e)}isFlagEnabled(e){return this.flags.get(e).flag}setFlagEnabled(e,t){this.flags.has(e)?this.flags.get(e).flag=t:i.Warning(i.GetStackTrace(),`Cannot toggle flag called ${e} - it does not exist in the Config.flags map.`)}setTextSetting(e,t){this.textParameters.has(e)?this.textParameters.get(e).text=t:i.Warning(i.GetStackTrace(),`Cannot set text setting called ${e} - it does not exist in the Config.textParameters map.`)}setOptionSettingOptions(e,t){this.optionParameters.has(e)?this.optionParameters.get(e).options=t:i.Warning(i.GetStackTrace(),`Cannot set text setting called ${e} - it does not exist in the Config.optionParameters map.`)}setOptionSettingValue(e,t){if(this.optionParameters.has(e)){const s=this.optionParameters.get(e),n=s.options;n.includes(t)||(n.push(t),s.options=n),s.selected=t}else i.Warning(i.GetStackTrace(),`Cannot set text setting called ${e} - it does not exist in the Config.enumParameters map.`)}setFlagLabel(e,t){this.flags.has(e)?this.flags.get(e).label=t:i.Warning(i.GetStackTrace(),`Cannot set label for flag called ${e} - it does not exist in the Config.flags map.`)}setSettings(e){for(const t of Object.keys(e))ge(t)?this.setFlagEnabled(t,e[t]):pe(t)?this.setNumericSetting(t,e[t]):ve(t)?this.setTextSetting(t,e[t]):fe(t)&&this.setOptionSettingValue(t,e[t])}getSettings(){const e={};for(const[t,s]of this.flags.entries())e[t]=s.flag;for(const[t,s]of this.numericParameters.entries())e[t]=s.number;for(const[t,s]of this.textParameters.entries())e[t]=s.text;for(const[t,s]of this.optionParameters.entries())e[t]=s.selected;return e}getFlags(){return Array.from(this.flags.values())}getTextSettings(){return Array.from(this.textParameters.values())}getNumericSettings(){return Array.from(this.numericParameters.values())}getOptionSettings(){return Array.from(this.optionParameters.values())}_registerOnChangeEvents(e){for(const t of this.flags.keys()){const s=this.flags.get(t);s&&(s.onChangeEmit=t=>e.dispatchEvent(new ie({id:s.id,type:\"flag\",value:t,target:s})))}for(const t of this.numericParameters.keys()){const s=this.numericParameters.get(t);s&&(s.onChangeEmit=t=>e.dispatchEvent(new ie({id:s.id,type:\"number\",value:t,target:s})))}for(const t of this.textParameters.keys()){const s=this.textParameters.get(t);s&&(s.onChangeEmit=t=>e.dispatchEvent(new ie({id:s.id,type:\"text\",value:t,target:s})))}for(const t of this.optionParameters.keys()){const s=this.optionParameters.get(t);s&&(s.onChangeEmit=t=>e.dispatchEvent(new ie({id:s.id,type:\"option\",value:t,target:s})))}}}var Ee;!function(e){e[e.LockedMouse=0]=\"LockedMouse\",e[e.HoveringMouse=1]=\"HoveringMouse\"}(Ee||(Ee={}));class ye{constructor(e,t,s){this.active=!1,this.countdownActive=!1,this.warnTimer=void 0,this.countDown=0,this.countDownTimer=void 0,this.config=e,this.pixelStreaming=t,this.onDismissAfk=s,this.onAFKTimedOutCallback=()=>{console.log(\"AFK timed out, did you want to override this callback?\")}}onAfkClick(){clearInterval(this.countDownTimer),(this.active||this.countdownActive)&&(this.startAfkWarningTimer(),this.pixelStreaming.dispatchEvent(new x))}startAfkWarningTimer(){this.config.getNumericSettingValue(me.AFKTimeoutSecs)>0&&this.config.isFlagEnabled(ue.AFKDetection)?this.active=!0:this.active=!1,this.resetAfkWarningTimer()}stopAfkWarningTimer(){this.active=!1,this.countdownActive=!1,clearTimeout(this.warnTimer),clearInterval(this.countDownTimer)}pauseAfkWarningTimer(){this.active=!1}resetAfkWarningTimer(){this.active&&this.config.isFlagEnabled(ue.AFKDetection)&&(clearTimeout(this.warnTimer),this.warnTimer=setTimeout((()=>this.activateAfkEvent()),1e3*this.config.getNumericSettingValue(me.AFKTimeoutSecs)))}activateAfkEvent(){this.pauseAfkWarningTimer(),this.pixelStreaming.dispatchEvent(new k({countDown:this.countDown,dismissAfk:this.onDismissAfk})),this.countDown=this.config.getNumericSettingValue(me.AFKCountdownSecs),this.countdownActive=!0,this.pixelStreaming.dispatchEvent(new L({countDown:this.countDown})),this.config.isFlagEnabled(ue.HoveringMouseMode)||document.exitPointerLock&&document.exitPointerLock(),this.countDownTimer=setInterval((()=>{this.countDown--,0==this.countDown?(this.pixelStreaming.dispatchEvent(new A),this.onAFKTimedOutCallback(),i.Log(i.GetStackTrace(),\"You have been disconnected due to inactivity\"),this.stopAfkWarningTimer()):this.pixelStreaming.dispatchEvent(new L({countDown:this.countDown}))}),1e3)}}class Me{constructor(){this.isReceivingFreezeFrame=!1}getDataChannelInstance(){return this}createDataChannel(e,t,s){this.peerConnection=e,this.label=t,this.datachannelOptions=s,null==s&&(this.datachannelOptions={},this.datachannelOptions.ordered=!0),this.dataChannel=this.peerConnection.createDataChannel(this.label,this.datachannelOptions),this.setupDataChannel()}setupDataChannel(){this.dataChannel.binaryType=\"arraybuffer\",this.dataChannel.onopen=e=>this.handleOnOpen(e),this.dataChannel.onclose=e=>this.handleOnClose(e),this.dataChannel.onmessage=e=>this.handleOnMessage(e),this.dataChannel.onerror=e=>this.handleOnError(e)}handleOnOpen(e){var t;i.Log(i.GetStackTrace(),`Data Channel (${this.label}) opened.`,7),this.onOpen(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}handleOnClose(e){var t;i.Log(i.GetStackTrace(),`Data Channel (${this.label}) closed.`,7),this.onClose(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}handleOnMessage(e){i.Log(i.GetStackTrace(),`Data Channel (${this.label}) message: ${e}`,8)}handleOnError(e){var t;i.Log(i.GetStackTrace(),`Data Channel (${this.label}) error: ${e}`,7),this.onError(null===(t=this.dataChannel)||void 0===t?void 0:t.label,e)}onOpen(e,t){}onClose(e,t){}onError(e,t){}}class we{}class be{}class Re{}class Pe{}class ke{}class Le{}class xe{}class Ae{constructor(){this.inboundVideoStats=new be,this.inboundAudioStats=new we,this.DataChannelStats=new Re,this.outBoundVideoStats=new ke,this.sessionStats=new Le,this.streamStats=new xe,this.codecs=new Map}processStats(e){this.localCandidates=new Array,this.remoteCandidates=new Array,this.candidatePairs=new Array,e.forEach((e=>{switch(e.type){case\"candidate-pair\":this.handleCandidatePair(e);break;case\"certificate\":case\"media-source\":case\"media-playout\":case\"outbound-rtp\":case\"peer-connection\":case\"remote-inbound-rtp\":break;case\"codec\":this.handleCodec(e);break;case\"data-channel\":this.handleDataChannel(e);break;case\"inbound-rtp\":this.handleInBoundRTP(e);break;case\"local-candidate\":this.handleLocalCandidate(e);break;case\"remote-candidate\":this.handleRemoteCandidate(e);break;case\"remote-outbound-rtp\":this.handleRemoteOutBound(e);break;case\"track\":this.handleTrack(e);break;case\"transport\":this.handleTransport(e);break;case\"stream\":this.handleStream(e);break;default:i.Error(i.GetStackTrace(),\"unhandled Stat Type\"),i.Log(i.GetStackTrace(),e)}}))}handleStream(e){this.streamStats=e}handleCandidatePair(e){this.candidatePairs.push(e)}handleDataChannel(e){this.DataChannelStats.bytesReceived=e.bytesReceived,this.DataChannelStats.bytesSent=e.bytesSent,this.DataChannelStats.dataChannelIdentifier=e.dataChannelIdentifier,this.DataChannelStats.id=e.id,this.DataChannelStats.label=e.label,this.DataChannelStats.messagesReceived=e.messagesReceived,this.DataChannelStats.messagesSent=e.messagesSent,this.DataChannelStats.protocol=e.protocol,this.DataChannelStats.state=e.state,this.DataChannelStats.timestamp=e.timestamp}handleLocalCandidate(e){const t=new Pe;t.label=\"local-candidate\",t.address=e.address,t.port=e.port,t.protocol=e.protocol,t.candidateType=e.candidateType,t.id=e.id,t.relayProtocol=e.relayProtocol,t.transportId=e.transportId,this.localCandidates.push(t)}handleRemoteCandidate(e){const t=new Pe;t.label=\"remote-candidate\",t.address=e.address,t.port=e.port,t.protocol=e.protocol,t.id=e.id,t.candidateType=e.candidateType,t.relayProtocol=e.relayProtocol,t.transportId=e.transportId,this.remoteCandidates.push(t)}handleInBoundRTP(e){switch(e.kind){case\"video\":this.inboundVideoStats=e,null!=this.lastVideoStats&&(this.inboundVideoStats.bitrate=8*(this.inboundVideoStats.bytesReceived-this.lastVideoStats.bytesReceived)/(this.inboundVideoStats.timestamp-this.lastVideoStats.timestamp),this.inboundVideoStats.bitrate=Math.floor(this.inboundVideoStats.bitrate)),this.lastVideoStats=Object.assign({},this.inboundVideoStats);break;case\"audio\":this.inboundAudioStats=e,null!=this.lastAudioStats&&(this.inboundAudioStats.bitrate=8*(this.inboundAudioStats.bytesReceived-this.lastAudioStats.bytesReceived)/(this.inboundAudioStats.timestamp-this.lastAudioStats.timestamp),this.inboundAudioStats.bitrate=Math.floor(this.inboundAudioStats.bitrate)),this.lastAudioStats=Object.assign({},this.inboundAudioStats);break;default:i.Log(i.GetStackTrace(),\"Kind is not handled\")}}handleRemoteOutBound(e){\"video\"===e.kind&&(this.outBoundVideoStats.bytesSent=e.bytesSent,this.outBoundVideoStats.id=e.id,this.outBoundVideoStats.localId=e.localId,this.outBoundVideoStats.packetsSent=e.packetsSent,this.outBoundVideoStats.remoteTimestamp=e.remoteTimestamp,this.outBoundVideoStats.timestamp=e.timestamp)}handleTrack(e){\"track\"!==e.type||\"video_label\"!==e.trackIdentifier&&\"video\"!==e.kind||(this.inboundVideoStats.framesDropped=e.framesDropped,this.inboundVideoStats.framesReceived=e.framesReceived,this.inboundVideoStats.frameHeight=e.frameHeight,this.inboundVideoStats.frameWidth=e.frameWidth)}handleTransport(e){this.transportStats=e}handleCodec(e){const t=e.id,s=`${e.mimeType.replace(\"video/\",\"\").replace(\"audio/\",\"\")}${e.sdpFmtpLine?` ${e.sdpFmtpLine}`:\"\"}`;this.codecs.set(t,s)}handleSessionStatistics(e,t,s){const n=Date.now()-e;this.sessionStats.runTime=new Date(n).toISOString().substr(11,8).toString();const r=null===t?\"Not sent yet\":t?\"true\":\"false\";this.sessionStats.controlsStreamInput=r,this.sessionStats.videoEncoderAvgQP=s}isNumber(e){return\"number\"==typeof e&&isFinite(e)}getActiveCandidatePair(){return this.transportStats?this.candidatePairs.find((e=>e.id===this.transportStats.selectedCandidatePairId),null):this.candidatePairs.find((e=>e.selected),null)}}const Fe=(De={parseRtpParameters:()=>e.parseRtpParameters,splitSections:()=>e.splitSections},Oe={},n.d(Oe,De),Oe);var De,Oe;class Ie{static isVideoTransciever(e){return this.canTransceiverReceiveVideo(e)||this.canTransceiverSendVideo(e)}static canTransceiverReceiveVideo(e){return!!e&&(\"sendrecv\"===e.direction||\"recvonly\"===e.direction)&&e.receiver&&e.receiver.track&&\"video\"===e.receiver.track.kind}static canTransceiverSendVideo(e){return!!e&&(\"sendrecv\"===e.direction||\"sendonly\"===e.direction)&&e.sender&&e.sender.track&&\"video\"===e.sender.track.kind}static isAudioTransciever(e){return this.canTransceiverReceiveAudio(e)||this.canTransceiverSendAudio(e)}static canTransceiverReceiveAudio(e){return!!e&&(\"sendrecv\"===e.direction||\"recvonly\"===e.direction)&&e.receiver&&e.receiver.track&&\"audio\"===e.receiver.track.kind}static canTransceiverSendAudio(e){return!!e&&(\"sendrecv\"===e.direction||\"sendonly\"===e.direction)&&e.sender&&e.sender.track&&\"audio\"===e.sender.track.kind}}var Ue,Ge,Be=function(e,t,s,n){return new(s||(s=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function o(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};class ze{constructor(e,t,s){this.config=t,this.createPeerConnection(e,s)}createPeerConnection(e,t){this.config.isFlagEnabled(ue.ForceTURN)&&(e.iceTransportPolicy=\"relay\",i.Log(i.GetStackTrace(),\"Forcing TURN usage by setting ICE Transport Policy in peer connection config.\")),this.peerConnection=new RTCPeerConnection(e),this.peerConnection.onsignalingstatechange=e=>this.handleSignalStateChange(e),this.peerConnection.oniceconnectionstatechange=e=>this.handleIceConnectionStateChange(e),this.peerConnection.onicegatheringstatechange=e=>this.handleIceGatheringStateChange(e),this.peerConnection.ontrack=e=>this.handleOnTrack(e),this.peerConnection.onicecandidate=e=>this.handleIceCandidate(e),this.peerConnection.ondatachannel=e=>this.handleDataChannel(e),this.aggregatedStats=new Ae,this.preferredCodec=t,this.updateCodecSelection=!0}createOffer(e,t){return Be(this,void 0,void 0,(function*(){i.Log(i.GetStackTrace(),\"Create Offer\",6);const s=\"localhost\"===location.hostname||\"127.0.0.1\"===location.hostname,n=\"https:\"===location.protocol;let r=t.isFlagEnabled(ue.UseMic);!r||s||n||(r=!1,i.Error(i.GetStackTrace(),\"Microphone access in the browser will not work if you are not on HTTPS or localhost. Disabling mic access.\"),i.Error(i.GetStackTrace(),\"For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'\")),this.setupTransceiversAsync(r).finally((()=>{var t;null===(t=this.peerConnection)||void 0===t||t.createOffer(e).then((e=>{var t;this.showTextOverlayConnecting(),e.sdp=this.mungeSDP(e.sdp,r),null===(t=this.peerConnection)||void 0===t||t.setLocalDescription(e),this.onSendWebRTCOffer(e)})).catch((()=>{this.showTextOverlaySetupFailure()}))}))}))}receiveOffer(e,t){var s;return Be(this,void 0,void 0,(function*(){i.Log(i.GetStackTrace(),\"Receive Offer\",6),null===(s=this.peerConnection)||void 0===s||s.setRemoteDescription(e).then((()=>{const s=\"localhost\"===location.hostname||\"127.0.0.1\"===location.hostname,n=\"https:\"===location.protocol;let r=t.isFlagEnabled(ue.UseMic);!r||s||n||(r=!1,i.Error(i.GetStackTrace(),\"Microphone access in the browser will not work if you are not on HTTPS or localhost. Disabling mic access.\"),i.Error(i.GetStackTrace(),\"For testing you can enable HTTP microphone access Chrome by visiting chrome://flags/ and enabling 'unsafely-treat-insecure-origin-as-secure'\")),this.config.setOptionSettingOptions(Ce.PreferredCodec,this.fuzzyIntersectUEAndBrowserCodecs(e)),this.setupTransceiversAsync(r).finally((()=>{var e;null===(e=this.peerConnection)||void 0===e||e.createAnswer().then((e=>{var t;return e.sdp=this.mungeSDP(e.sdp,r),null===(t=this.peerConnection)||void 0===t?void 0:t.setLocalDescription(e)})).then((()=>{var e;this.onSendWebRTCAnswer(null===(e=this.peerConnection)||void 0===e?void 0:e.currentLocalDescription)})).catch((()=>{i.Error(i.GetStackTrace(),\"createAnswer() failed\")}))}))}))}))}receiveAnswer(e){var t;null===(t=this.peerConnection)||void 0===t||t.setRemoteDescription(e),this.config.setOptionSettingOptions(Ce.PreferredCodec,this.fuzzyIntersectUEAndBrowserCodecs(e))}generateStats(){var e;null===(e=this.peerConnection)||void 0===e||e.getStats(null).then((e=>{this.aggregatedStats.processStats(e),this.onVideoStats(this.aggregatedStats),this.updateCodecSelection&&this.aggregatedStats.inboundVideoStats.codecId&&this.config.setOptionSettingValue(Ce.PreferredCodec,this.aggregatedStats.codecs.get(this.aggregatedStats.inboundVideoStats.codecId))}))}close(){this.peerConnection&&(this.peerConnection.close(),this.peerConnection=null)}mungeSDP(e,t){let s=e.replace(/(a=fmtp:\\d+ .*level-asymmetry-allowed=.*)\\r\\n/gm,\"$1;x-google-start-bitrate=10000;x-google-max-bitrate=100000\\r\\n\"),n=\"maxaveragebitrate=510000;\";return t&&(n+=\"sprop-maxcapturerate=48000;\"),n+=this.config.isFlagEnabled(ue.ForceMonoAudio)?\"stereo=0;\":\"stereo=1;\",n+=\"useinbandfec=1\",s=s.replace(\"useinbandfec=1\",n),s}handleOnIce(e){var t;i.Log(i.GetStackTrace(),\"peerconnection handleOnIce\",6),this.config.isFlagEnabled(ue.ForceTURN)&&e.candidate.indexOf(\"relay\")<0?i.Info(i.GetStackTrace(),`Dropping candidate because it was not TURN relay. | Type= ${e.type} | Protocol= ${e.protocol} | Address=${e.address} | Port=${e.port} |`,6):null===(t=this.peerConnection)||void 0===t||t.addIceCandidate(e)}handleSignalStateChange(e){i.Log(i.GetStackTrace(),\"signaling state change: \"+e,6)}handleIceConnectionStateChange(e){i.Log(i.GetStackTrace(),\"ice connection state change: \"+e,6),this.onIceConnectionStateChange(e)}handleIceGatheringStateChange(e){i.Log(i.GetStackTrace(),\"ice gathering state change: \"+JSON.stringify(e),6)}handleOnTrack(e){this.onTrack(e)}handleIceCandidate(e){this.onPeerIceCandidate(e)}handleDataChannel(e){this.onDataChannel(e)}onTrack(e){}onIceConnectionStateChange(e){}onPeerIceCandidate(e){}onDataChannel(e){}fuzzyIntersectUEAndBrowserCodecs(e){const t=new Array,s=this.parseAvailableCodecs(e),n=this.config.getSettingOption(Ce.PreferredCodec).options;for(const e of s)if(n.includes(e))t.push(e);else{const s=e.split(\" \")[0];for(const e of n)if(e.includes(s)){t.push(e);break}}return t}setupTransceiversAsync(e){var t,s,n,r,i,a,o,l,d,c,h,u;return Be(this,void 0,void 0,(function*(){let g=!1;for(const e of null!==(s=null===(t=this.peerConnection)||void 0===t?void 0:t.getTransceivers())&&void 0!==s?s:[])if(e&&e.receiver&&e.receiver.track&&\"video\"===e.receiver.track.kind){g=!0;break}if(g||null===(n=this.peerConnection)||void 0===n||n.addTransceiver(\"video\",{direction:\"recvonly\"}),RTCRtpReceiver.getCapabilities&&\"\"!=this.preferredCodec)for(const e of null!==(i=null===(r=this.peerConnection)||void 0===r?void 0:r.getTransceivers())&&void 0!==i?i:[])if(e&&e.receiver&&e.receiver.track&&\"video\"===e.receiver.track.kind&&e.setCodecPreferences){const t=this.preferredCodec.split(\" \"),s={mimeType:\"video/\"+t[0],clockRate:9e4,sdpFmtpLine:t[1]?t[1]:\"\"},n=[s];RTCRtpReceiver.getCapabilities(\"video\").codecs.forEach((e=>{(e.mimeType!=s.mimeType||(null==e?void 0:e.sdpFmtpLine)!=(null==s?void 0:s.sdpFmtpLine))&&n.push(e)}));for(const e of n)void 0!==(null==e?void 0:e.sdpFmtpLine)&&\"\"!==e.sdpFmtpLine||delete e.sdpFmtpLine;e.setCodecPreferences(n)}let m=!1;for(const e of null!==(o=null===(a=this.peerConnection)||void 0===a?void 0:a.getTransceivers())&&void 0!==o?o:[])if(e&&e.receiver&&e.receiver.track&&\"audio\"===e.receiver.track.kind){m=!0;break}if(e){const e={video:!1,audio:{autoGainControl:!1,channelCount:1,echoCancellation:!1,latency:0,noiseSuppression:!1,sampleRate:48e3,sampleSize:16,volume:1}},t=yield navigator.mediaDevices.getUserMedia(e);if(t)if(m){for(const e of null!==(c=null===(d=this.peerConnection)||void 0===d?void 0:d.getTransceivers())&&void 0!==c?c:[])if(Ie.canTransceiverReceiveAudio(e))for(const s of t.getTracks())s.kind&&\"audio\"==s.kind&&(e.sender.replaceTrack(s),e.direction=\"sendrecv\")}else for(const e of t.getTracks())e.kind&&\"audio\"==e.kind&&(null===(h=this.peerConnection)||void 0===h||h.addTransceiver(e,{direction:\"sendrecv\"}));else m||null===(u=this.peerConnection)||void 0===u||u.addTransceiver(\"audio\",{direction:\"recvonly\"})}else m||null===(l=this.peerConnection)||void 0===l||l.addTransceiver(\"audio\",{direction:\"recvonly\"})}))}onVideoStats(e){}onSendWebRTCOffer(e){}onSendWebRTCAnswer(e){}showTextOverlayConnecting(){}showTextOverlaySetupFailure(){}parseAvailableCodecs(e){if(!RTCRtpReceiver.getCapabilities)return[\"Only available on Chrome\"];const t=[],s=(0,Fe.splitSections)(e.sdp);return s.shift(),s.forEach((e=>{const{codecs:s}=(0,Fe.parseRtpParameters)(e),n=/(VP\\d|H26\\d|AV1).*/;s.forEach((e=>{const s=e.name+\" \"+Object.keys(e.parameters||{}).map((t=>t+\"=\"+e.parameters[t])).join(\";\");if(null!==n.exec(s)){\"VP9\"==e.name&&(e.parameters={\"profile-id\":\"0\"});const s=e.name+\" \"+Object.keys(e.parameters||{}).map((t=>t+\"=\"+e.parameters[t])).join(\";\");t.push(s)}}))})),t}}class _e{constructor(){this.PixelStreamingSettings=new Ve,this.EncoderSettings=new He,this.WebRTCSettings=new We}ueCompatible(){null!=this.WebRTCSettings.MaxFPS&&(this.WebRTCSettings.FPS=this.WebRTCSettings.MaxFPS)}}class Ve{}class He{}class We{}class Ne{constructor(){this.ReceiptTimeMs=null,this.TransmissionTimeMs=null,this.PreCaptureTimeMs=null,this.PostCaptureTimeMs=null,this.PreEncodeTimeMs=null,this.PostEncodeTimeMs=null,this.EncodeMs=null,this.CaptureToSendMs=null,this.testStartTimeMs=0,this.browserReceiptTimeMs=0,this.latencyExcludingDecode=0,this.testDuration=0,this.networkLatency=0,this.browserSendLatency=0,this.frameDisplayDeltaTimeMs=0,this.endToEndLatency=0,this.encodeLatency=0}setFrameDisplayDeltaTime(e){0==this.frameDisplayDeltaTimeMs&&(this.frameDisplayDeltaTimeMs=Math.round(e))}processFields(){null!=this.EncodeMs||null==this.PreEncodeTimeMs&&null==this.PostEncodeTimeMs||(i.Log(i.GetStackTrace(),`Setting Encode Ms \\n ${this.PostEncodeTimeMs} \\n ${this.PreEncodeTimeMs}`,6),this.EncodeMs=this.PostEncodeTimeMs-this.PreEncodeTimeMs),null!=this.CaptureToSendMs||null==this.PreCaptureTimeMs&&null==this.PostCaptureTimeMs||(i.Log(i.GetStackTrace(),`Setting CaptureToSendMs Ms \\n ${this.PostCaptureTimeMs} \\n ${this.PreCaptureTimeMs}`,6),this.CaptureToSendMs=this.PostCaptureTimeMs-this.PreCaptureTimeMs)}}class Ke{static setExtensionFromBytes(e,t){t.receiving||(t.mimetype=\"\",t.extension=\"\",t.receiving=!0,t.valid=!1,t.size=0,t.data=[],t.timestampStart=(new Date).getTime(),i.Log(i.GetStackTrace(),\"Received first chunk of file\",6));const s=new TextDecoder(\"utf-16\").decode(e.slice(1));i.Log(i.GetStackTrace(),s,6),t.extension=s}static setMimeTypeFromBytes(e,t){t.receiving||(t.mimetype=\"\",t.extension=\"\",t.receiving=!0,t.valid=!1,t.size=0,t.data=[],t.timestampStart=(new Date).getTime(),i.Log(i.GetStackTrace(),\"Received first chunk of file\",6));const s=new TextDecoder(\"utf-16\").decode(e.slice(1));i.Log(i.GetStackTrace(),s,6),t.mimetype=s}static setContentsFromBytes(e,t){if(!t.receiving)return;t.size=Math.ceil(new DataView(e.slice(1,5).buffer).getInt32(0,!0)/16379);const s=e.slice(5);if(t.data.push(s),i.Log(i.GetStackTrace(),`Received file chunk: ${t.data.length}/${t.size}`,6),t.data.length===t.size){t.receiving=!1,t.valid=!0,i.Log(i.GetStackTrace(),\"Received complete file\",6);const e=(new Date).getTime()-t.timestampStart,s=Math.round(16*t.size*1024/e);i.Log(i.GetStackTrace(),`Average transfer bitrate: ${s}kb/s over ${e/1e3} seconds`,6);const n=new Blob(t.data,{type:t.mimetype}),r=document.createElement(\"a\");r.setAttribute(\"href\",URL.createObjectURL(n)),r.setAttribute(\"download\",`transfer.${t.extension}`),document.body.append(r),r.remove()}else t.data.length>t.size&&(t.receiving=!1,i.Error(i.GetStackTrace(),`Received bigger file than advertised: ${t.data.length}/${t.size}`))}}class Qe{constructor(){this.mimetype=\"\",this.extension=\"\",this.receiving=!1,this.size=0,this.data=[],this.valid=!1}}class qe{}qe.mainButton=0,qe.auxiliaryButton=1,qe.secondaryButton=2,qe.fourthButton=3,qe.fifthButton=4;class $e{}$e.primaryButton=1,$e.secondaryButton=2,$e.auxiliaryButton=4,$e.fourthButton=8,$e.fifthButton=16;class Xe{constructor(){this.unregisterCallbacks=[]}addUnregisterCallback(e){this.unregisterCallbacks.push(e)}unregisterAll(){for(const e of this.unregisterCallbacks)e();this.unregisterCallbacks=[]}}class je{constructor(e,t,s){this.touchEventListenerTracker=new Xe,this.toStreamerMessagesProvider=e,this.videoElementProvider=t,this.coordinateConverter=s;const n=e=>this.onTouchStart(e),r=e=>this.onTouchEnd(e),i=e=>this.onTouchMove(e);document.addEventListener(\"touchstart\",n,{passive:!1}),document.addEventListener(\"touchend\",r,{passive:!1}),document.addEventListener(\"touchmove\",i,{passive:!1}),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"touchstart\",n))),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"touchend\",r))),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"touchmove\",i)))}unregisterTouchEvents(){this.touchEventListenerTracker.unregisterAll()}setVideoElementParentClientRect(e){this.videoElementParentClientRect=e}onTouchStart(e){if(this.videoElementProvider.isVideoReady()&&e.target===this.videoElementProvider.getVideoElement()){if(null==this.fakeTouchFinger){const t=e.changedTouches[0];this.fakeTouchFinger=new Je(t.identifier,t.clientX-this.videoElementParentClientRect.left,t.clientY-this.videoElementParentClientRect.top);const s=this.videoElementProvider.getVideoParentElement(),n=new MouseEvent(\"mouseenter\",t);s.dispatchEvent(n);const r=this.coordinateConverter.normalizeAndQuantizeUnsigned(this.fakeTouchFinger.x,this.fakeTouchFinger.y);this.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseDown\")([qe.mainButton,r.x,r.y])}e.preventDefault()}}onTouchEnd(e){if(!this.videoElementProvider.isVideoReady()||null==this.fakeTouchFinger)return;const t=this.videoElementProvider.getVideoParentElement(),s=this.toStreamerMessagesProvider.toStreamerHandlers;for(let n=0;nthis.handleOnCompositionEnd(e),t=e=>this.handleOnKeyDown(e),s=e=>this.handleOnKeyUp(e),n=e=>this.handleOnKeyPress(e);document.addEventListener(\"compositionend\",e),document.addEventListener(\"keydown\",t),document.addEventListener(\"keyup\",s),document.addEventListener(\"keypress\",n),this.keyboardEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"compositionend\",e))),this.keyboardEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"keydown\",t))),this.keyboardEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"keyup\",s))),this.keyboardEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"keypress\",n)))}unregisterKeyBoardEvents(){this.keyboardEventListenerTracker.unregisterAll()}handleOnKeyDown(e){const t=this.getKeycode(e);t&&229!==t&&(i.Log(i.GetStackTrace(),`key down ${t}, repeat = ${e.repeat}`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get(\"KeyDown\")([this.getKeycode(e),e.repeat?1:0]),this.activeKeysProvider.getActiveKeys().push(t),t===Ye.backSpace&&document.dispatchEvent(new KeyboardEvent(\"keypress\",{charCode:Ye.backSpace})),this.config.isFlagEnabled(ue.SuppressBrowserKeys)&&this.isKeyCodeBrowserKey(t)&&e.preventDefault())}handleOnKeyUp(e){const t=this.getKeycode(e);t&&(i.Log(i.GetStackTrace(),`key up ${t}`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get(\"KeyUp\")([t]),this.config.isFlagEnabled(ue.SuppressBrowserKeys)&&this.isKeyCodeBrowserKey(t)&&e.preventDefault())}handleOnKeyPress(e){if(!(\"charCode\"in e))return void i.Warning(i.GetStackTrace(),\"KeyboardEvent.charCode is deprecated in this browser, cannot send key press.\");const t=e.charCode;i.Log(i.GetStackTrace(),`key press ${t}`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get(\"KeyPress\")([t])}handleOnCompositionEnd(e){e.data&&e.data.length&&e.data.split(\"\").forEach((e=>{this.handleOnKeyDown(new KeyboardEvent(\"keydown\",{keyCode:e.toUpperCase().charCodeAt(0),charCode:e.charCodeAt(0)})),this.handleOnKeyPress(new KeyboardEvent(\"keypress\",{keyCode:e.toUpperCase().charCodeAt(0),charCode:e.charCodeAt(0)})),this.handleOnKeyUp(new KeyboardEvent(\"keyup\",{keyCode:e.toUpperCase().charCodeAt(0),charCode:e.charCodeAt(0)}))}))}getKeycode(e){if(!(\"keyCode\"in e)){const t=e;return t.code in this.CodeToKeyCode?this.CodeToKeyCode[t.code]:(i.Warning(i.GetStackTrace(),`Keyboard code of ${t.code} is not supported in our mapping, ignoring this key.`),null)}return e.keyCode===Ye.shift&&\"ShiftRight\"===e.code?Ye.rightShift:e.keyCode===Ye.control&&\"ControlRight\"===e.code?Ye.rightControl:e.keyCode===Ye.alt&&\"AltRight\"===e.code?Ye.rightAlt:e.keyCode}isKeyCodeBrowserKey(e){return e>=112&&e<=123||9===e}}class et{constructor(e,t,s){this.x=0,this.y=0,this.updateMouseMovePositionEvent=e=>{this.updateMouseMovePosition(e)},this.mouseEventListenerTracker=new Xe,this.videoElementProvider=e,this.mouseController=t,this.activeKeysProvider=s;const n=this.videoElementProvider.getVideoParentElement();this.x=n.getBoundingClientRect().width/2,this.y=n.getBoundingClientRect().height/2,this.coord=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(this.x,this.y)}unregisterMouseEvents(){this.mouseEventListenerTracker.unregisterAll()}lockStateChange(){const e=this.videoElementProvider.getVideoParentElement(),t=this.mouseController.toStreamerMessagesProvider.toStreamerHandlers;if(document.pointerLockElement===e||document.mozPointerLockElement===e)i.Log(i.GetStackTrace(),\"Pointer locked\",6),document.addEventListener(\"mousemove\",this.updateMouseMovePositionEvent,!1),this.mouseEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"mousemove\",this.updateMouseMovePositionEvent,!1)));else{i.Log(i.GetStackTrace(),\"The pointer lock status is now unlocked\",6),document.removeEventListener(\"mousemove\",this.updateMouseMovePositionEvent,!1);let e=this.activeKeysProvider.getActiveKeys();const s=new Set(e),n=[];s.forEach((e=>{n[e]})),n.forEach((e=>{t.get(\"KeyUp\")([e])})),e=[]}}updateMouseMovePosition(e){if(!this.videoElementProvider.isVideoReady())return;const t=this.mouseController.toStreamerMessagesProvider.toStreamerHandlers,s=this.videoElementProvider.getVideoParentElement().clientWidth,n=this.videoElementProvider.getVideoParentElement().clientHeight;this.x+=e.movementX,this.y+=e.movementY,this.x>s&&(this.x-=s),this.y>n&&(this.y-=n),this.x<0&&(this.x=s+this.x),this.y<0&&(this.y=n-this.y),this.coord=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(this.x,this.y);const r=this.mouseController.coordinateConverter.normalizeAndQuantizeSigned(e.movementX,e.movementY);t.get(\"MouseMove\")([this.coord.x,this.coord.y,r.x,r.y])}handleMouseDown(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseDown\")([e.button,this.coord.x,this.coord.y])}handleMouseUp(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseUp\")([e.button,this.coord.x,this.coord.y])}handleMouseWheel(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseWheel\")([e.wheelDelta,this.coord.x,this.coord.y])}handleMouseDouble(e){this.videoElementProvider.isVideoReady()&&this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseDouble\")([e.button,this.coord.x,this.coord.y])}handlePressMouseButtons(e){this.videoElementProvider.isVideoReady()&&this.mouseController.pressMouseButtons(e.buttons,this.x,this.y)}handleReleaseMouseButtons(e){this.videoElementProvider.isVideoReady()&&this.mouseController.releaseMouseButtons(e.buttons,this.x,this.y)}}class tt{constructor(e){this.mouseController=e}unregisterMouseEvents(){}updateMouseMovePosition(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;i.Log(i.GetStackTrace(),\"MouseMove\",6);const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY),s=this.mouseController.coordinateConverter.normalizeAndQuantizeSigned(e.movementX,e.movementY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseMove\")([t.x,t.y,s.x,s.y]),e.preventDefault()}handleMouseDown(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;i.Log(i.GetStackTrace(),\"onMouse Down\",6);const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseDown\")([e.button,t.x,t.y]),e.preventDefault()}handleMouseUp(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;i.Log(i.GetStackTrace(),\"onMouse Up\",6);const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseUp\")([e.button,t.x,t.y]),e.preventDefault()}handleContextMenu(e){this.mouseController.videoElementProvider.isVideoReady()&&e.preventDefault()}handleMouseWheel(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseWheel\")([e.wheelDelta,t.x,t.y]),e.preventDefault()}handleMouseDouble(e){if(!this.mouseController.videoElementProvider.isVideoReady())return;const t=this.mouseController.coordinateConverter.normalizeAndQuantizeUnsigned(e.offsetX,e.offsetY);this.mouseController.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseDouble\")([e.button,t.x,t.y])}handlePressMouseButtons(e){this.mouseController.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),\"onMouse press\",6),this.mouseController.pressMouseButtons(e.buttons,e.offsetX,e.offsetY))}handleReleaseMouseButtons(e){this.mouseController.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),\"onMouse release\",6),this.mouseController.releaseMouseButtons(e.buttons,e.offsetX,e.offsetY))}}class st{constructor(e,t,s,n){this.mouseEventListenerTracker=new Xe,this.toStreamerMessagesProvider=e,this.coordinateConverter=s,this.videoElementProvider=t,this.activeKeysProvider=n,this.registerMouseEnterAndLeaveEvents()}unregisterMouseEvents(){this.mouseEventListenerTracker.unregisterAll()}registerLockedMouseEvents(e){const t=this.videoElementProvider.getVideoParentElement(),s=new et(this.videoElementProvider,e,this.activeKeysProvider);if(t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock,document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock,t.requestPointerLock){const e=()=>{t.requestPointerLock()};t.addEventListener(\"click\",e),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"click\",e)))}const n=()=>s.lockStateChange();document.addEventListener(\"pointerlockchange\",n,!1),document.addEventListener(\"mozpointerlockchange\",n,!1),this.mouseEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"pointerlockchange\",n,!1))),this.mouseEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"mozpointerlockchange\",n,!1)));const r=e=>s.handleMouseDown(e),i=e=>s.handleMouseUp(e),a=e=>s.handleMouseWheel(e),o=e=>s.handleMouseDouble(e);t.addEventListener(\"mousedown\",r),t.addEventListener(\"mouseup\",i),t.addEventListener(\"wheel\",a),t.addEventListener(\"dblclick\",o),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"mousedown\",r))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"mouseup\",i))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"wheel\",a))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"dblclick\",o))),this.mouseEventListenerTracker.addUnregisterCallback((()=>s.unregisterMouseEvents())),this.mouseEventListenerTracker.addUnregisterCallback((()=>{!document.exitPointerLock||document.pointerLockElement!==t&&document.mozPointerLockElement!==t||document.exitPointerLock()}))}registerHoveringMouseEvents(e){const t=this.videoElementProvider.getVideoParentElement(),s=new tt(e),n=e=>s.updateMouseMovePosition(e),r=e=>s.handleMouseDown(e),i=e=>s.handleMouseUp(e),a=e=>s.handleContextMenu(e),o=e=>s.handleMouseWheel(e),l=e=>s.handleMouseDouble(e);t.addEventListener(\"mousemove\",n),t.addEventListener(\"mousedown\",r),t.addEventListener(\"mouseup\",i),t.addEventListener(\"contextmenu\",a),t.addEventListener(\"wheel\",o),t.addEventListener(\"dblclick\",l),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"mousemove\",n))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"mousedown\",r))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"mouseup\",i))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"contextmenu\",a))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"wheel\",o))),this.mouseEventListenerTracker.addUnregisterCallback((()=>t.removeEventListener(\"dblclick\",l))),this.mouseEventListenerTracker.addUnregisterCallback((()=>s.unregisterMouseEvents()))}registerMouseEnterAndLeaveEvents(){const e=this.videoElementProvider.getVideoParentElement(),t=e=>{this.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),\"Mouse Entered\",6),this.sendMouseEnter(),this.pressMouseButtons(e.buttons,e.x,e.y))},s=e=>{this.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),\"Mouse Left\",6),this.sendMouseLeave(),this.releaseMouseButtons(e.buttons,e.x,e.y))};e.addEventListener(\"mouseenter\",t),e.addEventListener(\"mouseleave\",s),this.mouseEventListenerTracker.addUnregisterCallback((()=>e.removeEventListener(\"mouseenter\",t))),this.mouseEventListenerTracker.addUnregisterCallback((()=>e.removeEventListener(\"mouseleave\",s)))}releaseMouseButtons(e,t,s){const n=this.coordinateConverter.normalizeAndQuantizeUnsigned(t,s);e&$e.primaryButton&&this.sendMouseUp(qe.mainButton,n.x,n.y),e&$e.secondaryButton&&this.sendMouseUp(qe.secondaryButton,n.x,n.y),e&$e.auxiliaryButton&&this.sendMouseUp(qe.auxiliaryButton,n.x,n.y),e&$e.fourthButton&&this.sendMouseUp(qe.fourthButton,n.x,n.y),e&$e.fifthButton&&this.sendMouseUp(qe.fifthButton,n.x,n.y)}pressMouseButtons(e,t,s){if(!this.videoElementProvider.isVideoReady())return;const n=this.coordinateConverter.normalizeAndQuantizeUnsigned(t,s);e&$e.primaryButton&&this.sendMouseDown(qe.mainButton,n.x,n.y),e&$e.secondaryButton&&this.sendMouseDown(qe.secondaryButton,n.x,n.y),e&$e.auxiliaryButton&&this.sendMouseDown(qe.auxiliaryButton,n.x,n.y),e&$e.fourthButton&&this.sendMouseDown(qe.fourthButton,n.x,n.y),e&$e.fifthButton&&this.sendMouseDown(qe.fifthButton,n.x,n.y)}sendMouseEnter(){this.videoElementProvider.isVideoReady()&&this.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseEnter\")()}sendMouseLeave(){this.videoElementProvider.isVideoReady()&&this.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseLeave\")()}sendMouseDown(e,t,s){this.videoElementProvider.isVideoReady()&&(i.Log(i.GetStackTrace(),`mouse button ${e} down at (${t}, ${s})`,6),this.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseDown\")([e,t,s]))}sendMouseUp(e,t,s){if(!this.videoElementProvider.isVideoReady())return;i.Log(i.GetStackTrace(),`mouse button ${e} up at (${t}, ${s})`,6);const n=this.coordinateConverter.normalizeAndQuantizeUnsigned(t,s);this.toStreamerMessagesProvider.toStreamerHandlers.get(\"MouseUp\")([e,n.x,n.y])}}class nt{constructor(e,t,s){this.fingers=[9,8,7,6,5,4,3,2,1,0],this.fingerIds=new Map,this.maxByteValue=255,this.touchEventListenerTracker=new Xe,this.toStreamerMessagesProvider=e,this.videoElementProvider=t,this.coordinateConverter=s,this.videoElementParent=t.getVideoElement();const n=e=>this.onTouchStart(e),r=e=>this.onTouchEnd(e),a=e=>this.onTouchMove(e);this.videoElementParent.addEventListener(\"touchstart\",n),this.videoElementParent.addEventListener(\"touchend\",r),this.videoElementParent.addEventListener(\"touchmove\",a),this.touchEventListenerTracker.addUnregisterCallback((()=>this.videoElementParent.removeEventListener(\"touchstart\",n))),this.touchEventListenerTracker.addUnregisterCallback((()=>this.videoElementParent.removeEventListener(\"touchend\",r))),this.touchEventListenerTracker.addUnregisterCallback((()=>this.videoElementParent.removeEventListener(\"touchmove\",a))),i.Log(i.GetStackTrace(),\"Touch Events Registered\",6);const o=e=>{e.preventDefault()};document.addEventListener(\"touchmove\",o),this.touchEventListenerTracker.addUnregisterCallback((()=>document.removeEventListener(\"touchmove\",o)))}unregisterTouchEvents(){this.touchEventListenerTracker.unregisterAll()}rememberTouch(e){const t=this.fingers.pop();void 0===t&&i.Log(i.GetStackTrace(),\"exhausted touch identifiers\",6),this.fingerIds.set(e.identifier,t)}forgetTouch(e){this.fingers.push(this.fingerIds.get(e.identifier)),this.fingers.sort((function(e,t){return t-e})),this.fingerIds.delete(e.identifier)}onTouchStart(e){if(this.videoElementProvider.isVideoReady()){for(let t=0;t0?o.force:1),c.inRange?1:0]);break;case\"TouchEnd\":n.get(\"TouchEnd\")([a,c.x,c.y,this.fingerIds.get(o.identifier),this.maxByteValue*o.force,c.inRange?1:0]);break;case\"TouchMove\":n.get(\"TouchMove\")([a,c.x,c.y,this.fingerIds.get(o.identifier),this.maxByteValue*(o.force>0?o.force:1),c.inRange?1:0])}}}}class rt{constructor(e){this.gamePadEventListenerTracker=new Xe,this.toStreamerMessagesProvider=e,this.requestAnimationFrame=(window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.requestAnimationFrame).bind(window);const t=window;if(window.addEventListener(\"beforeunload\",(e=>this.onBeforeUnload(e))),\"GamepadEvent\"in t){const e=e=>this.gamePadConnectHandler(e),t=e=>this.gamePadDisconnectHandler(e);window.addEventListener(\"gamepadconnected\",e),window.addEventListener(\"gamepaddisconnected\",t),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener(\"gamepadconnected\",e))),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener(\"gamepaddisconnected\",t)))}else if(\"WebKitGamepadEvent\"in t){const e=e=>this.gamePadConnectHandler(e),t=e=>this.gamePadDisconnectHandler(e);window.addEventListener(\"webkitgamepadconnected\",e),window.addEventListener(\"webkitgamepaddisconnected\",t),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener(\"webkitgamepadconnected\",e))),this.gamePadEventListenerTracker.addUnregisterCallback((()=>window.removeEventListener(\"webkitgamepaddisconnected\",t)))}if(this.controllers=[],navigator.getGamepads)for(const e of navigator.getGamepads())e&&this.gamePadConnectHandler(new GamepadEvent(\"gamepadconnected\",{gamepad:e}))}unregisterGamePadEvents(){this.gamePadEventListenerTracker.unregisterAll();for(const e of this.controllers)void 0!==e.id&&this.onGamepadDisconnected(e.id);this.controllers=[],this.onGamepadConnected=()=>{},this.onGamepadDisconnected=()=>{}}gamePadConnectHandler(e){i.Log(i.GetStackTrace(),\"Gamepad connect handler\",6);const t=e.gamepad,s={currentState:t,prevState:t,id:void 0};this.controllers.push(s),this.controllers[t.index].currentState=t,this.controllers[t.index].prevState=t,i.Log(i.GetStackTrace(),\"gamepad: \"+t.id+\" connected\",6),window.requestAnimationFrame((()=>this.updateStatus())),this.onGamepadConnected()}gamePadDisconnectHandler(e){i.Log(i.GetStackTrace(),\"Gamepad disconnect handler\",6),i.Log(i.GetStackTrace(),\"gamepad: \"+e.gamepad.id+\" disconnected\",6);const t=this.controllers[e.gamepad.index];delete this.controllers[e.gamepad.index],this.controllers=this.controllers.filter((e=>void 0!==e)),this.onGamepadDisconnected(t.id)}scanGamePads(){const e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[];for(let t=0;t0&&this.requestAnimationFrame((()=>this.updateStatus()))}onGamepadResponseReceived(e){for(const t of this.controllers)if(void 0===t.id){t.id=e;break}}onGamepadConnected(){}onGamepadDisconnected(e){}onBeforeUnload(e){for(const e of this.controllers)this.onGamepadDisconnected(e.id)}}!function(e){e[e.RightClusterBottomButton=0]=\"RightClusterBottomButton\",e[e.RightClusterRightButton=1]=\"RightClusterRightButton\",e[e.RightClusterLeftButton=2]=\"RightClusterLeftButton\",e[e.RightClusterTopButton=3]=\"RightClusterTopButton\",e[e.LeftShoulder=4]=\"LeftShoulder\",e[e.RightShoulder=5]=\"RightShoulder\",e[e.LeftTrigger=6]=\"LeftTrigger\",e[e.RightTrigger=7]=\"RightTrigger\",e[e.SelectOrBack=8]=\"SelectOrBack\",e[e.StartOrForward=9]=\"StartOrForward\",e[e.LeftAnalogPress=10]=\"LeftAnalogPress\",e[e.RightAnalogPress=11]=\"RightAnalogPress\",e[e.LeftClusterTopButton=12]=\"LeftClusterTopButton\",e[e.LeftClusterBottomButton=13]=\"LeftClusterBottomButton\",e[e.LeftClusterLeftButton=14]=\"LeftClusterLeftButton\",e[e.LeftClusterRightButton=15]=\"LeftClusterRightButton\",e[e.CentreButton=16]=\"CentreButton\",e[e.LeftStickHorizontal=0]=\"LeftStickHorizontal\",e[e.LeftStickVertical=1]=\"LeftStickVertical\",e[e.RightStickHorizontal=2]=\"RightStickHorizontal\",e[e.RightStickVertical=3]=\"RightStickVertical\"}(Ue||(Ue={}));class it{constructor(e,t,s){this.activeKeys=new at,this.toStreamerMessagesProvider=e,this.videoElementProvider=t,this.coordinateConverter=s}registerKeyBoard(e){i.Log(i.GetStackTrace(),\"Register Keyboard Events\",7);const t=new Ze(this.toStreamerMessagesProvider,e,this.activeKeys);return t.registerKeyBoardEvents(),t}registerMouse(e){i.Log(i.GetStackTrace(),\"Register Mouse Events\",7);const t=new st(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter,this.activeKeys);switch(e){case Ee.LockedMouse:t.registerLockedMouseEvents(t);break;case Ee.HoveringMouse:t.registerHoveringMouseEvents(t);break;default:i.Info(i.GetStackTrace(),\"unknown Control Scheme Type Defaulting to Locked Mouse Events\"),t.registerLockedMouseEvents(t)}return t}registerTouch(e,t){if(i.Log(i.GetStackTrace(),\"Registering Touch\",6),e){const e=new je(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter);return e.setVideoElementParentClientRect(t),e}return new nt(this.toStreamerMessagesProvider,this.videoElementProvider,this.coordinateConverter)}registerGamePad(){return i.Log(i.GetStackTrace(),\"Register Game Pad\",7),new rt(this.toStreamerMessagesProvider)}}class at{constructor(){this.activeKeys=[],this.activeKeys=[]}getActiveKeys(){return this.activeKeys}}class ot{constructor(e,t){this.lastTimeResized=(new Date).getTime(),this.videoElement=document.createElement(\"video\"),this.config=t,this.videoElement.id=\"streamingVideo\",this.videoElement.disablePictureInPicture=!0,this.videoElement.playsInline=!0,this.videoElement.style.width=\"100%\",this.videoElement.style.height=\"100%\",this.videoElement.style.position=\"absolute\",this.videoElement.style.pointerEvents=\"all\",e.appendChild(this.videoElement),this.onResizePlayerCallback=()=>{console.log(\"Resolution changed, restyling player, did you forget to override this function?\")},this.onMatchViewportResolutionCallback=()=>{console.log(\"Resolution changed and match viewport resolution is turned on, did you forget to override this function?\")},this.videoElement.onclick=()=>{null!=this.audioElement&&this.audioElement.paused&&this.audioElement.play(),this.videoElement.paused&&this.videoElement.play()},this.videoElement.onloadedmetadata=()=>{this.onVideoInitialized()},window.addEventListener(\"resize\",(()=>this.resizePlayerStyle()),!0),window.addEventListener(\"orientationchange\",(()=>this.onOrientationChange()))}setAudioElement(e){this.audioElement=e}play(){return this.videoElement.muted=this.config.isFlagEnabled(ue.StartVideoMuted),this.videoElement.autoplay=this.config.isFlagEnabled(ue.AutoPlayVideo),this.videoElement.play()}isPaused(){return this.videoElement.paused}isVideoReady(){return void 0!==this.videoElement.readyState&&this.videoElement.readyState>0}hasVideoSource(){return void 0!==this.videoElement.srcObject&&null!==this.videoElement.srcObject}getVideoElement(){return this.videoElement}getVideoParentElement(){return this.videoElement.parentElement}setVideoEnabled(e){this.videoElement.srcObject.getTracks().forEach((t=>t.enabled=e))}onVideoInitialized(){}onOrientationChange(){clearTimeout(this.orientationChangeTimeout),this.orientationChangeTimeout=window.setTimeout((()=>{this.resizePlayerStyle()}),500)}resizePlayerStyle(){const e=this.getVideoParentElement();e&&(this.updateVideoStreamSize(),e.classList.contains(\"fixed-size\")||this.resizePlayerStyleToFillParentElement(),this.onResizePlayerCallback())}resizePlayerStyleToFillParentElement(){this.getVideoParentElement().setAttribute(\"style\",\"top: 0px; left: 0px; width: 100%; height: 100%; cursor: default;\")}updateVideoStreamSize(){if(this.config.isFlagEnabled(ue.MatchViewportResolution))if((new Date).getTime()-this.lastTimeResized>300){const e=this.getVideoParentElement();if(!e)return;this.onMatchViewportResolutionCallback(e.clientWidth,e.clientHeight),this.lastTimeResized=(new Date).getTime()}else i.Log(i.GetStackTrace(),\"Resizing too often - skipping\",6),clearTimeout(this.resizeTimeoutHandle),this.resizeTimeoutHandle=window.setTimeout((()=>this.updateVideoStreamSize()),100)}}class lt{constructor(){this.toStreamerHandlers=new Map,this.fromStreamerHandlers=new Map,this.toStreamerMessages=new Map,this.fromStreamerMessages=new Map}populateDefaultProtocol(){this.toStreamerMessages.set(\"IFrameRequest\",{id:0,structure:[]}),this.toStreamerMessages.set(\"RequestQualityControl\",{id:1,structure:[]}),this.toStreamerMessages.set(\"FpsRequest\",{id:2,structure:[]}),this.toStreamerMessages.set(\"AverageBitrateRequest\",{id:3,structure:[]}),this.toStreamerMessages.set(\"StartStreaming\",{id:4,structure:[]}),this.toStreamerMessages.set(\"StopStreaming\",{id:5,structure:[]}),this.toStreamerMessages.set(\"LatencyTest\",{id:6,structure:[\"string\"]}),this.toStreamerMessages.set(\"RequestInitialSettings\",{id:7,structure:[]}),this.toStreamerMessages.set(\"TestEcho\",{id:8,structure:[]}),this.toStreamerMessages.set(\"DataChannelLatencyTest\",{id:9,structure:[]}),this.toStreamerMessages.set(\"UIInteraction\",{id:50,structure:[\"string\"]}),this.toStreamerMessages.set(\"Command\",{id:51,structure:[\"string\"]}),this.toStreamerMessages.set(\"KeyDown\",{id:60,structure:[\"uint8\",\"uint8\"]}),this.toStreamerMessages.set(\"KeyUp\",{id:61,structure:[\"uint8\"]}),this.toStreamerMessages.set(\"KeyPress\",{id:62,structure:[\"uint16\"]}),this.toStreamerMessages.set(\"MouseEnter\",{id:70,structure:[]}),this.toStreamerMessages.set(\"MouseLeave\",{id:71,structure:[]}),this.toStreamerMessages.set(\"MouseDown\",{id:72,structure:[\"uint8\",\"uint16\",\"uint16\"]}),this.toStreamerMessages.set(\"MouseUp\",{id:73,structure:[\"uint8\",\"uint16\",\"uint16\"]}),this.toStreamerMessages.set(\"MouseMove\",{id:74,structure:[\"uint16\",\"uint16\",\"int16\",\"int16\"]}),this.toStreamerMessages.set(\"MouseWheel\",{id:75,structure:[\"int16\",\"uint16\",\"uint16\"]}),this.toStreamerMessages.set(\"MouseDouble\",{id:76,structure:[\"uint8\",\"uint16\",\"uint16\"]}),this.toStreamerMessages.set(\"TouchStart\",{id:80,structure:[\"uint8\",\"uint16\",\"uint16\",\"uint8\",\"uint8\",\"uint8\"]}),this.toStreamerMessages.set(\"TouchEnd\",{id:81,structure:[\"uint8\",\"uint16\",\"uint16\",\"uint8\",\"uint8\",\"uint8\"]}),this.toStreamerMessages.set(\"TouchMove\",{id:82,structure:[\"uint8\",\"uint16\",\"uint16\",\"uint8\",\"uint8\",\"uint8\"]}),this.toStreamerMessages.set(\"GamepadConnected\",{id:93,structure:[]}),this.toStreamerMessages.set(\"GamepadButtonPressed\",{id:90,structure:[\"uint8\",\"uint8\",\"uint8\"]}),this.toStreamerMessages.set(\"GamepadButtonReleased\",{id:91,structure:[\"uint8\",\"uint8\",\"uint8\"]}),this.toStreamerMessages.set(\"GamepadAnalog\",{id:92,structure:[\"uint8\",\"uint8\",\"double\"]}),this.toStreamerMessages.set(\"GamepadDisconnected\",{id:94,structure:[\"uint8\"]}),this.fromStreamerMessages.set(0,\"QualityControlOwnership\"),this.fromStreamerMessages.set(1,\"Response\"),this.fromStreamerMessages.set(2,\"Command\"),this.fromStreamerMessages.set(3,\"FreezeFrame\"),this.fromStreamerMessages.set(4,\"UnfreezeFrame\"),this.fromStreamerMessages.set(5,\"VideoEncoderAvgQP\"),this.fromStreamerMessages.set(6,\"LatencyTest\"),this.fromStreamerMessages.set(7,\"InitialSettings\"),this.fromStreamerMessages.set(8,\"FileExtension\"),this.fromStreamerMessages.set(9,\"FileMimeType\"),this.fromStreamerMessages.set(10,\"FileContents\"),this.fromStreamerMessages.set(11,\"TestEcho\"),this.fromStreamerMessages.set(12,\"InputControlOwnership\"),this.fromStreamerMessages.set(13,\"GamepadResponse\"),this.fromStreamerMessages.set(14,\"DataChannelLatencyTest\"),this.fromStreamerMessages.set(255,\"Protocol\")}registerMessageHandler(e,t,s){switch(e){case Ge.ToStreamer:this.toStreamerHandlers.set(t,s);break;case Ge.FromStreamer:this.fromStreamerHandlers.set(t,s);break;default:i.Log(i.GetStackTrace(),`Unknown message direction ${e}`)}}}!function(e){e[e.ToStreamer=0]=\"ToStreamer\",e[e.FromStreamer=1]=\"FromStreamer\"}(Ge||(Ge={}));class dt{constructor(){this.responseEventListeners=new Map}addResponseEventListener(e,t){this.responseEventListeners.set(e,t)}removeResponseEventListener(e){this.responseEventListeners.delete(e)}onResponse(e){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.Response\",6);const t=new TextDecoder(\"utf-16\").decode(e.slice(1));i.Log(i.GetStackTrace(),t,6),this.responseEventListeners.forEach((e=>{e(t)}))}}class ct{constructor(e,t){this.dataChannelSender=e,this.toStreamerMessagesMapProvider=t}sendMessageToStreamer(e,t){void 0===t&&(t=[]);const s=this.toStreamerMessagesMapProvider.toStreamerMessages.get(e);if(void 0===s)return void i.Error(i.GetStackTrace(),`Attempted to send a message to the streamer with message type: ${e}, but the frontend hasn't been configured to send such a message. Check you've added the message type in your cpp`);if(s.structure&&t&&s.structure.length!==t.length)return void i.Error(i.GetStackTrace(),`Provided message data doesn't match expected layout. Expected [ ${s.structure.map((e=>{switch(e){case\"uint8\":case\"uint16\":case\"int16\":case\"float\":case\"double\":return\"number\";case\"string\":return\"string\"}})).toString()} ] but received [ ${t.map((e=>typeof e)).toString()} ]`);let n=0;const r=new TextEncoder;t.forEach(((e,t)=>{switch(s.structure[t]){case\"uint8\":n+=1;break;case\"uint16\":case\"int16\":n+=2;break;case\"float\":n+=4;break;case\"double\":n+=8;break;case\"string\":n+=2,n+=2*r.encode(e).length}}));const a=new DataView(new ArrayBuffer(n+1));a.setUint8(0,s.id);let o=1;t.forEach(((e,t)=>{switch(s.structure[t]){case\"uint8\":a.setUint8(o,e),o+=1;break;case\"uint16\":a.setUint16(o,e,!0),o+=2;break;case\"int16\":a.setInt16(o,e,!0),o+=2;break;case\"float\":a.setFloat32(o,e,!0),o+=4;break;case\"double\":a.setFloat64(o,e,!0),o+=8;break;case\"string\":a.setUint16(o,e.length,!0),o+=2;for(let t=0;t{throw new Error(\"Normalize and quantize unsigned, method not implemented.\")},this.normalizeAndQuantizeSignedFunc=()=>{throw new Error(\"Normalize and unquantize signed, method not implemented.\")},this.denormalizeAndUnquantizeUnsignedFunc=()=>{throw new Error(\"Denormalize and unquantize unsigned, method not implemented.\")}}normalizeAndQuantizeUnsigned(e,t){return this.normalizeAndQuantizeUnsignedFunc(e,t)}unquantizeAndDenormalizeUnsigned(e,t){return this.denormalizeAndUnquantizeUnsignedFunc(e,t)}normalizeAndQuantizeSigned(e,t){return this.normalizeAndQuantizeSignedFunc(e,t)}setupNormalizeAndQuantize(){if(this.videoElementParent=this.videoElementProvider.getVideoParentElement(),this.videoElement=this.videoElementProvider.getVideoElement(),this.videoElementParent&&this.videoElement){const e=this.videoElementParent.clientWidth||1,t=this.videoElementParent.clientHeight||1,s=this.videoElement.videoWidth||1,n=t/e,r=(this.videoElement.videoHeight||1)/s;n>r?(i.Log(i.GetStackTrace(),\"Setup Normalize and Quantize for playerAspectRatio > videoAspectRatio\",6),this.ratio=n/r,this.normalizeAndQuantizeUnsignedFunc=(e,t)=>this.normalizeAndQuantizeUnsignedPlayerBigger(e,t),this.normalizeAndQuantizeSignedFunc=(e,t)=>this.normalizeAndQuantizeSignedPlayerBigger(e,t),this.denormalizeAndUnquantizeUnsignedFunc=(e,t)=>this.denormalizeAndUnquantizeUnsignedPlayerBigger(e,t)):(i.Log(i.GetStackTrace(),\"Setup Normalize and Quantize for playerAspectRatio <= videoAspectRatio\",6),this.ratio=r/n,this.normalizeAndQuantizeUnsignedFunc=(e,t)=>this.normalizeAndQuantizeUnsignedPlayerSmaller(e,t),this.normalizeAndQuantizeSignedFunc=(e,t)=>this.normalizeAndQuantizeSignedPlayerSmaller(e,t),this.denormalizeAndUnquantizeUnsignedFunc=(e,t)=>this.denormalizeAndUnquantizeUnsignedPlayerSmaller(e,t))}}normalizeAndQuantizeUnsignedPlayerBigger(e,t){const s=e/this.videoElementParent.clientWidth,n=this.ratio*(t/this.videoElementParent.clientHeight-.5)+.5;return s<0||s>1||n<0||n>1?new mt(!1,65535,65535):new mt(!0,65536*s,65536*n)}denormalizeAndUnquantizeUnsignedPlayerBigger(e,t){const s=e/65536,n=(t/65536-.5)/this.ratio+.5;return new pt(s*this.videoElementParent.clientWidth,n*this.videoElementParent.clientHeight)}normalizeAndQuantizeSignedPlayerBigger(e,t){const s=e/(.5*this.videoElementParent.clientWidth),n=this.ratio*t/(.5*this.videoElementParent.clientHeight);return new St(32767*s,32767*n)}normalizeAndQuantizeUnsignedPlayerSmaller(e,t){const s=this.ratio*(e/this.videoElementParent.clientWidth-.5)+.5,n=t/this.videoElementParent.clientHeight;return s<0||s>1||n<0||n>1?new mt(!1,65535,65535):new mt(!0,65536*s,65536*n)}denormalizeAndUnquantizeUnsignedPlayerSmaller(e,t){const s=(e/65536-.5)/this.ratio+.5,n=t/65536;return new pt(s*this.videoElementParent.clientWidth,n*this.videoElementParent.clientHeight)}normalizeAndQuantizeSignedPlayerSmaller(e,t){const s=this.ratio*e/(.5*this.videoElementParent.clientWidth),n=t/(.5*this.videoElementParent.clientHeight);return new St(32767*s,32767*n)}}class mt{constructor(e,t,s){this.inRange=e,this.x=t,this.y=s}}class pt{constructor(e,t){this.x=e,this.y=t}}class St{constructor(e,t){this.x=e,this.y=t}}class vt{constructor(e,t){this.shouldShowPlayOverlay=!0,this.autoJoinTimer=void 0,this.config=e,this.pixelStreaming=t,this.responseController=new dt,this.file=new Qe,this.sdpConstraints={offerToReceiveAudio:!0,offerToReceiveVideo:!0},this.afkController=new ye(this.config,this.pixelStreaming,this.onAfkTriggered.bind(this)),this.afkController.onAFKTimedOutCallback=()=>{this.closeSignalingServer(\"You have been disconnected due to inactivity\")},this.freezeFrameController=new y(this.pixelStreaming.videoElementParent),this.videoPlayer=new ot(this.pixelStreaming.videoElementParent,this.config),this.videoPlayer.onVideoInitialized=()=>this.handleVideoInitialized(),this.videoPlayer.onMatchViewportResolutionCallback=(e,t)=>{const s={\"Resolution.Width\":e,\"Resolution.Height\":t};this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify(s)])},this.videoPlayer.onResizePlayerCallback=()=>{this.setUpMouseAndFreezeFrame()},this.streamController=new T(this.videoPlayer),this.coordinateConverter=new gt(this.videoPlayer),this.sendrecvDataChannelController=new Me,this.recvDataChannelController=new Me,this.registerDataChannelEventEmitters(this.sendrecvDataChannelController),this.registerDataChannelEventEmitters(this.recvDataChannelController),this.dataChannelSender=new ut(this.sendrecvDataChannelController),this.dataChannelSender.resetAfkWarningTimerOnDataSend=()=>this.afkController.resetAfkWarningTimer(),this.streamMessageController=new lt,this.webSocketController=new f,this.webSocketController.onConfig=e=>this.handleOnConfigMessage(e),this.webSocketController.onStreamerList=e=>this.handleStreamerListMessage(e),this.webSocketController.onStreamerIDChanged=e=>this.handleStreamerIDChangedMessage(e),this.webSocketController.onPlayerCount=e=>{this.pixelStreaming._onPlayerCount(e.count)},this.webSocketController.onOpen.addEventListener(\"open\",(()=>{this.config.isFlagEnabled(ue.BrowserSendOffer)||this.webSocketController.requestStreamerList()})),this.webSocketController.onClose.addEventListener(\"close\",(e=>{const t=this.shouldReconnect&&1001!=e.detail.code&&this.config.getNumericSettingValue(me.MaxReconnectAttempts)>0,s=this.disconnectMessage?this.disconnectMessage:e.detail.reason;this.pixelStreaming._onDisconnect(s,!t&&!this.isReconnecting),this.afkController.stopAfkWarningTimer(),this.statsTimerHandle&&void 0!==this.statsTimerHandle&&window.clearInterval(this.statsTimerHandle),this.setVideoEncoderAvgQP(0),this.setTouchInputEnabled(!1),this.setMouseInputEnabled(!1),this.setKeyboardInputEnabled(!1),this.setGamePadInputEnabled(!1),t&&setTimeout((()=>{this.isReconnecting=!0,this.reconnectAttempt++,this.tryReconnect(e.detail.reason)}),2e3)})),this.sendMessageController=new ct(this.dataChannelSender,this.streamMessageController),this.toStreamerMessagesController=new ht(this.sendMessageController),this.registerMessageHandlers(),this.streamMessageController.populateDefaultProtocol(),this.inputClassesFactory=new it(this.streamMessageController,this.videoPlayer,this.coordinateConverter),this.isUsingSFU=!1,this.isQualityController=!1,this.preferredCodec=\"\",this.shouldReconnect=!0,this.isReconnecting=!1,this.reconnectAttempt=0,this.config._addOnOptionSettingChangedListener(Ce.StreamerId,(e=>{\"\"!==e&&(this.peerConnectionController.peerConnection.close(),this.peerConnectionController.createPeerConnection(this.peerConfig,this.preferredCodec),this.subscribedStream=e,this.webSocketController.sendSubscribe(e))})),this.setVideoEncoderAvgQP(-1),this.signallingUrlBuilder=()=>{let e=this.config.getTextSettingValue(Se.SignallingServerUrl);return this.config.isFlagEnabled(ue.BrowserSendOffer)&&(e+=\"?\"+ue.BrowserSendOffer+\"=true\"),e}}requestUnquantizedAndDenormalizeUnsigned(e,t){return this.coordinateConverter.unquantizeAndDenormalizeUnsigned(e,t)}handleOnMessage(e){const t=new Uint8Array(e.data);i.Log(i.GetStackTrace(),\"Message incoming:\"+t,6);const s=this.streamMessageController.fromStreamerMessages.get(t[0]);this.streamMessageController.fromStreamerHandlers.get(s)(e.data)}registerMessageHandlers(){this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"QualityControlOwnership\",(e=>this.onQualityControlOwnership(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"Response\",(e=>this.responseController.onResponse(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"Command\",(e=>{this.onCommand(e)})),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"FreezeFrame\",(e=>this.onFreezeFrameMessage(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"UnfreezeFrame\",(()=>this.invalidateFreezeFrameAndEnableVideo())),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"VideoEncoderAvgQP\",(e=>this.handleVideoEncoderAvgQP(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"LatencyTest\",(e=>this.handleLatencyTestResult(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"DataChannelLatencyTest\",(e=>this.handleDataChannelLatencyTestResponse(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"InitialSettings\",(e=>this.handleInitialSettings(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"FileExtension\",(e=>this.onFileExtension(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"FileMimeType\",(e=>this.onFileMimeType(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"FileContents\",(e=>this.onFileContents(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"TestEcho\",(()=>{})),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"InputControlOwnership\",(e=>this.onInputControlOwnership(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"GamepadResponse\",(e=>this.onGamepadResponse(e))),this.streamMessageController.registerMessageHandler(Ge.FromStreamer,\"Protocol\",(e=>this.onProtocolMessage(e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"IFrameRequest\",(()=>this.sendMessageController.sendMessageToStreamer(\"IFrameRequest\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"RequestQualityControl\",(()=>this.sendMessageController.sendMessageToStreamer(\"RequestQualityControl\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"FpsRequest\",(()=>this.sendMessageController.sendMessageToStreamer(\"FpsRequest\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"AverageBitrateRequest\",(()=>this.sendMessageController.sendMessageToStreamer(\"AverageBitrateRequest\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"StartStreaming\",(()=>this.sendMessageController.sendMessageToStreamer(\"StartStreaming\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"StopStreaming\",(()=>this.sendMessageController.sendMessageToStreamer(\"StopStreaming\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"LatencyTest\",(e=>this.sendMessageController.sendMessageToStreamer(\"LatencyTest\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"RequestInitialSettings\",(()=>this.sendMessageController.sendMessageToStreamer(\"RequestInitialSettings\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"TestEcho\",(()=>{})),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"UIInteraction\",(e=>this.sendMessageController.sendMessageToStreamer(\"UIInteraction\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"Command\",(e=>this.sendMessageController.sendMessageToStreamer(\"Command\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"TextboxEntry\",(e=>this.sendMessageController.sendMessageToStreamer(\"TextboxEntry\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"KeyDown\",(e=>this.sendMessageController.sendMessageToStreamer(\"KeyDown\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"KeyUp\",(e=>this.sendMessageController.sendMessageToStreamer(\"KeyUp\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"KeyPress\",(e=>this.sendMessageController.sendMessageToStreamer(\"KeyPress\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"MouseEnter\",(e=>this.sendMessageController.sendMessageToStreamer(\"MouseEnter\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"MouseLeave\",(e=>this.sendMessageController.sendMessageToStreamer(\"MouseLeave\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"MouseDown\",(e=>this.sendMessageController.sendMessageToStreamer(\"MouseDown\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"MouseUp\",(e=>this.sendMessageController.sendMessageToStreamer(\"MouseUp\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"MouseMove\",(e=>this.sendMessageController.sendMessageToStreamer(\"MouseMove\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"MouseWheel\",(e=>this.sendMessageController.sendMessageToStreamer(\"MouseWheel\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"MouseDouble\",(e=>this.sendMessageController.sendMessageToStreamer(\"MouseDouble\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"TouchStart\",(e=>this.sendMessageController.sendMessageToStreamer(\"TouchStart\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"TouchEnd\",(e=>this.sendMessageController.sendMessageToStreamer(\"TouchEnd\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"TouchMove\",(e=>this.sendMessageController.sendMessageToStreamer(\"TouchMove\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"GamepadConnected\",(()=>this.sendMessageController.sendMessageToStreamer(\"GamepadConnected\"))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"GamepadButtonPressed\",(e=>this.sendMessageController.sendMessageToStreamer(\"GamepadButtonPressed\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"GamepadButtonReleased\",(e=>this.sendMessageController.sendMessageToStreamer(\"GamepadButtonReleased\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"GamepadAnalog\",(e=>this.sendMessageController.sendMessageToStreamer(\"GamepadAnalog\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"GamepadDisconnected\",(e=>this.sendMessageController.sendMessageToStreamer(\"GamepadDisconnected\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XREyeViews\",(e=>this.sendMessageController.sendMessageToStreamer(\"XREyeViews\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRHMDTransform\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRHMDTransform\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRControllerTransform\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRControllerTransform\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRSystem\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRSystem\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRButtonTouched\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRButtonTouched\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRButtonTouchReleased\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRButtonTouchReleased\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRButtonPressed\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRButtonPressed\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRButtonReleased\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRButtonReleased\",e))),this.streamMessageController.registerMessageHandler(Ge.ToStreamer,\"XRAnalog\",(e=>this.sendMessageController.sendMessageToStreamer(\"XRAnalog\",e)))}onCommand(e){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.Command\",6);const t=new TextDecoder(\"utf-16\").decode(e.slice(1));i.Log(i.GetStackTrace(),\"Data Channel Command: \"+t,6);const s=JSON.parse(t);\"onScreenKeyboard\"===s.command&&this.pixelStreaming._activateOnScreenKeyboard(s)}onProtocolMessage(e){try{const t=new TextDecoder(\"utf-16\").decode(e.slice(1)),s=JSON.parse(t);Object.prototype.hasOwnProperty.call(s,\"Direction\")||i.Error(i.GetStackTrace(),\"Malformed protocol received. Ensure the protocol message contains a direction\");const n=s.Direction;delete s.Direction,i.Log(i.GetStackTrace(),`Received new ${n==Ge.FromStreamer?\"FromStreamer\":\"ToStreamer\"} protocol. Updating existing protocol...`),Object.keys(s).forEach((e=>{const t=s[e];switch(n){case Ge.ToStreamer:if(!Object.prototype.hasOwnProperty.call(t,\"id\"))return void i.Error(i.GetStackTrace(),`ToStreamer->${e} protocol definition was malformed as it didn't contain at least an id\\n\\n Definition was: ${JSON.stringify(t,null,2)}`);if(\"UIInteraction\"===e||\"Command\"===e||\"LatencyTest\"===e)return;this.streamMessageController.toStreamerHandlers.get(e)?this.streamMessageController.toStreamerMessages.set(e,t):i.Error(i.GetStackTrace(),`There was no registered handler for \"${e}\" - try adding one using registerMessageHandler(MessageDirection.ToStreamer, \"${e}\", myHandler)`);break;case Ge.FromStreamer:if(!Object.prototype.hasOwnProperty.call(t,\"id\"))return void i.Error(i.GetStackTrace(),`FromStreamer->${e} protocol definition was malformed as it didn't contain at least an id\\n\\n Definition was: ${JSON.stringify(t,null,2)}`);this.streamMessageController.fromStreamerHandlers.get(e)?this.streamMessageController.fromStreamerMessages.set(t.id,e):i.Error(i.GetStackTrace(),`There was no registered handler for \"${t}\" - try adding one using registerMessageHandler(MessageDirection.FromStreamer, \"${e}\", myHandler)`);break;default:i.Error(i.GetStackTrace(),`Unknown direction: ${n}`)}})),this.toStreamerMessagesController.SendRequestInitialSettings(),this.toStreamerMessagesController.SendRequestQualityControl()}catch(e){i.Log(i.GetStackTrace(),e)}}onInputControlOwnership(e){const t=new Uint8Array(e);i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.InputControlOwnership\",6);const s=new Boolean(t[1]).valueOf();i.Log(i.GetStackTrace(),`Received input controller message - will your input control the stream: ${s}`),this.pixelStreaming._onInputControlOwnership(s)}onGamepadResponse(e){const t=new TextDecoder(\"utf-16\").decode(e.slice(1)),s=JSON.parse(t);this.gamePadController.onGamepadResponseReceived(s.controllerId)}onAfkTriggered(){this.afkController.onAfkClick(),this.videoPlayer.isPaused()&&this.videoPlayer.hasVideoSource()&&this.playStream()}setAfkEnabled(e){e?this.onAfkTriggered():this.afkController.stopAfkWarningTimer()}tryReconnect(e){this.webSocketController?(this.isReconnecting=!0,this.webSocketController.webSocket&&this.webSocketController.webSocket.readyState!=WebSocket.CLOSED?(this.closeSignalingServer(`${e} Restarting stream...`),setTimeout((()=>{this.tryReconnect(e)}),3e3)):(this.pixelStreaming._onWebRtcAutoConnect(),this.connectToSignallingServer())):i.Log(i.GetStackTrace(),\"The Web Socket Controller does not exist so this will not work right now.\")}loadFreezeFrameOrShowPlayOverlay(){this.pixelStreaming.dispatchEvent(new j({shouldShowPlayOverlay:this.shouldShowPlayOverlay,isValid:this.freezeFrameController.valid,jpegData:this.freezeFrameController.jpeg})),!0===this.shouldShowPlayOverlay?(i.Log(i.GetStackTrace(),\"showing play overlay\"),this.resizePlayerStyle()):(i.Log(i.GetStackTrace(),\"showing freeze frame\"),this.freezeFrameController.showFreezeFrame()),setTimeout((()=>{this.videoPlayer.setVideoEnabled(!1)}),this.freezeFrameController.freezeFrameDelay)}onFreezeFrameMessage(e){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.FreezeFrame\",6);const t=new Uint8Array(e);this.freezeFrameController.processFreezeFrameMessage(t,(()=>this.loadFreezeFrameOrShowPlayOverlay()))}invalidateFreezeFrameAndEnableVideo(){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.FreezeFrame\",6),setTimeout((()=>{this.pixelStreaming.dispatchEvent(new J),this.freezeFrameController.hideFreezeFrame()}),this.freezeFrameController.freezeFrameDelay),this.videoPlayer.getVideoElement()&&this.videoPlayer.setVideoEnabled(!0)}onFileExtension(e){const t=new Uint8Array(e);Ke.setExtensionFromBytes(t,this.file)}onFileMimeType(e){const t=new Uint8Array(e);Ke.setMimeTypeFromBytes(t,this.file)}onFileContents(e){const t=new Uint8Array(e);Ke.setContentsFromBytes(t,this.file)}playStream(){if(!this.videoPlayer.getVideoElement()){const e=\"Could not play video stream because the video player was not initialized correctly.\";return this.pixelStreaming.dispatchEvent(new q({message:e})),i.Error(i.GetStackTrace(),e),void this.closeSignalingServer(\"Stream not initialized correctly\")}if(this.videoPlayer.hasVideoSource()){if(this.setTouchInputEnabled(this.config.isFlagEnabled(ue.TouchInput)),this.pixelStreaming.dispatchEvent(new $),this.streamController.audioElement.srcObject){const e=this.config.isFlagEnabled(ue.StartVideoMuted);this.streamController.audioElement.muted=e,e?this.playVideo():this.streamController.audioElement.play().then((()=>{this.playVideo()})).catch((e=>{i.Log(i.GetStackTrace(),e),i.Log(i.GetStackTrace(),\"Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay.\"),this.pixelStreaming.dispatchEvent(new X({reason:e}))}))}else this.playVideo();this.shouldShowPlayOverlay=!1,this.freezeFrameController.showFreezeFrame()}else i.Warning(i.GetStackTrace(),\"Cannot play stream, the video element has no srcObject to play.\")}playVideo(){this.videoPlayer.play().catch((e=>{this.streamController.audioElement.srcObject&&this.streamController.audioElement.pause(),i.Log(i.GetStackTrace(),e),i.Log(i.GetStackTrace(),\"Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay.\"),this.pixelStreaming.dispatchEvent(new X({reason:e}))}))}autoPlayVideoOrSetUpPlayOverlay(){this.config.isFlagEnabled(ue.AutoPlayVideo)&&this.playStream(),this.resizePlayerStyle()}connectToSignallingServer(){this.locallyClosed=!1,this.shouldReconnect=!0,this.disconnectMessage=null;const e=this.signallingUrlBuilder();this.webSocketController.connect(e)}startSession(e){if(this.peerConfig=e,this.config.isFlagEnabled(ue.ForceTURN)&&!this.checkTurnServerAvailability(e))return i.Info(i.GetStackTrace(),\"No turn server was found in the Peer Connection Options. TURN cannot be forced, closing connection. Please use STUN instead\"),void this.closeSignalingServer(\"TURN cannot be forced, closing connection. Please use STUN instead.\");this.peerConnectionController=new ze(this.peerConfig,this.config,this.preferredCodec),this.peerConnectionController.onVideoStats=e=>this.handleVideoStats(e),this.peerConnectionController.onSendWebRTCOffer=e=>this.handleSendWebRTCOffer(e),this.peerConnectionController.onSendWebRTCAnswer=e=>this.handleSendWebRTCAnswer(e),this.peerConnectionController.onPeerIceCandidate=e=>this.handleSendIceCandidate(e),this.peerConnectionController.onDataChannel=e=>this.handleDataChannel(e),this.peerConnectionController.showTextOverlayConnecting=()=>this.pixelStreaming._onWebRtcConnecting(),this.peerConnectionController.showTextOverlaySetupFailure=()=>this.pixelStreaming._onWebRtcFailed();let t=!1;this.peerConnectionController.onIceConnectionStateChange=()=>{!t&&[\"connected\",\"completed\"].includes(this.peerConnectionController.peerConnection.iceConnectionState)&&(this.pixelStreaming._onWebRtcConnected(),t=!0)},this.peerConnectionController.onTrack=e=>this.streamController.handleOnTrack(e),this.config.isFlagEnabled(ue.BrowserSendOffer)&&(this.sendrecvDataChannelController.createDataChannel(this.peerConnectionController.peerConnection,\"cirrus\",this.datachannelOptions),this.sendrecvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e),this.peerConnectionController.createOffer(this.sdpConstraints,this.config))}checkTurnServerAvailability(e){if(!e.iceServers)return i.Info(i.GetStackTrace(),\"A turn sever was not found\"),!1;for(const t of e.iceServers)for(const e of t.urls)if(e.includes(\"turn\"))return i.Log(i.GetStackTrace(),`A turn sever was found at ${e}`),!0;return i.Info(i.GetStackTrace(),\"A turn sever was not found\"),!1}handleOnConfigMessage(e){this.resizePlayerStyle(),this.startSession(e.peerConnectionOptions),this.webSocketController.onWebRtcAnswer=e=>this.handleWebRtcAnswer(e),this.webSocketController.onWebRtcOffer=e=>this.handleWebRtcOffer(e),this.webSocketController.onWebRtcPeerDataChannels=e=>this.handleWebRtcSFUPeerDatachannels(e),this.webSocketController.onIceCandidate=e=>this.handleIceCandidate(e)}handleStreamerListMessage(e){i.Log(i.GetStackTrace(),`Got streamer list ${e.ids}`,6);let t=null;var s=this.config.getSettingOption(Ce.StreamerId);s.selected.toString().trim()&&(t=s.selected);const n=[...e.ids];n.unshift(\"\"),this.config.setOptionSettingOptions(Ce.StreamerId,n);let r=null;const a=this.config.isFlagEnabled(ue.WaitForStreamer),o=this.config.getNumericSettingValue(me.MaxReconnectAttempts),l=this.config.getNumericSettingValue(me.StreamerAutoJoinInterval),d=this.config.useUrlParams,c=new URLSearchParams(window.location.search);d&&c.has(Ce.StreamerId)?t=c.get(Ce.StreamerId):this.subscribedStream&&(t=this.subscribedStream),t&&e.ids.includes(t)?r=t:t&&a||1!=e.ids.length||(r=e.ids[0]),r?(this.isReconnecting=!1,this.reconnectAttempt=0,this.config.setOptionSettingValue(Ce.StreamerId,r)):a&&(this.reconnectAttempt{this.webSocketController.requestStreamerList()}),l)):(this.reconnectAttempt=0,this.isReconnecting=!1,this.shouldReconnect=!1)),this.pixelStreaming.dispatchEvent(new Z({messageStreamerList:e,autoSelectedStreamerId:r,wantedStreamerId:t}))}handleStreamerIDChangedMessage(e){const t=e.newID;var s=this.config.getSettingOption(Ce.StreamerId),n=s.onChange;s.onChange=()=>{};for(var r=s.options,i=0;ithis.webSocketController.sendSFURecvDataChannelReady(),this.recvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e)}else this.sendrecvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e)}handlePostWebrtcNegotiation(){this.afkController.startAfkWarningTimer(),this.pixelStreaming._onWebRtcSdp(),this.statsTimerHandle&&void 0!==this.statsTimerHandle&&window.clearInterval(this.statsTimerHandle),this.statsTimerHandle=window.setInterval((()=>this.getStats()),1e3),this.setMouseInputEnabled(this.config.isFlagEnabled(ue.MouseInput)),this.setKeyboardInputEnabled(this.config.isFlagEnabled(ue.KeyboardInput)),this.setGamePadInputEnabled(this.config.isFlagEnabled(ue.GamepadInput))}handleIceCandidate(e){i.Log(i.GetStackTrace(),\"Web RTC Controller: onWebRtcIce\",6);const t=new RTCIceCandidate(e);this.peerConnectionController.handleOnIce(t)}handleSendIceCandidate(e){i.Log(i.GetStackTrace(),\"OnIceCandidate\",6),e.candidate&&e.candidate.candidate&&this.webSocketController.sendIceCandidate(e.candidate)}handleDataChannel(e){i.Log(i.GetStackTrace(),\"Data channel created for us by browser as we are a receiving peer.\",6),this.sendrecvDataChannelController.dataChannel=e.channel,this.sendrecvDataChannelController.setupDataChannel(),this.sendrecvDataChannelController.handleOnMessage=e=>this.handleOnMessage(e)}handleSendWebRTCOffer(e){i.Log(i.GetStackTrace(),\"Sending the offer to the Server\",6);const t={minBitrateBps:1e3*this.config.getNumericSettingValue(me.WebRTCMinBitrate),maxBitrateBps:1e3*this.config.getNumericSettingValue(me.WebRTCMaxBitrate)};this.webSocketController.sendWebRtcOffer(e,t)}handleSendWebRTCAnswer(e){i.Log(i.GetStackTrace(),\"Sending the answer to the Server\",6);const t={minBitrateBps:1e3*this.config.getNumericSettingValue(me.WebRTCMinBitrate),maxBitrateBps:1e3*this.config.getNumericSettingValue(me.WebRTCMaxBitrate)};this.webSocketController.sendWebRtcAnswer(e,t),this.isUsingSFU&&this.webSocketController.sendWebRtcDatachannelRequest()}setUpMouseAndFreezeFrame(){this.videoElementParentClientRect=this.videoPlayer.getVideoParentElement().getBoundingClientRect(),this.coordinateConverter.setupNormalizeAndQuantize(),this.freezeFrameController.freezeFrame.resize()}closeSignalingServer(e){var t;this.locallyClosed=!0,this.shouldReconnect=!1,this.disconnectMessage=e,null===(t=this.webSocketController)||void 0===t||t.close()}closePeerConnection(){var e;null===(e=this.peerConnectionController)||void 0===e||e.close()}close(){this.closeSignalingServer(\"\"),this.closePeerConnection()}getStats(){this.peerConnectionController.generateStats()}sendLatencyTest(){this.latencyStartTime=Date.now(),this.streamMessageController.toStreamerHandlers.get(\"LatencyTest\")([JSON.stringify({StartTime:this.latencyStartTime})])}sendDataChannelLatencyTest(e){this.streamMessageController.toStreamerHandlers.get(\"DataChannelLatencyTest\")([JSON.stringify(e)])}sendEncoderMinQP(e){i.Log(i.GetStackTrace(),`MinQP=${e}\\n`,6),null!=e&&this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({\"Encoder.MinQP\":e})])}sendEncoderMaxQP(e){i.Log(i.GetStackTrace(),`MaxQP=${e}\\n`,6),null!=e&&this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({\"Encoder.MaxQP\":e})])}sendWebRTCMinBitrate(e){i.Log(i.GetStackTrace(),`WebRTC Min Bitrate=${e}`,6),null!=e&&this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({\"WebRTC.MinBitrate\":e})])}sendWebRTCMaxBitrate(e){i.Log(i.GetStackTrace(),`WebRTC Max Bitrate=${e}`,6),null!=e&&this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({\"WebRTC.MaxBitrate\":e})])}sendWebRTCFps(e){i.Log(i.GetStackTrace(),`WebRTC FPS=${e}`,6),null!=e&&(this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({\"WebRTC.Fps\":e})]),this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({\"WebRTC.MaxFps\":e})]))}sendShowFps(){i.Log(i.GetStackTrace(),\"---- Sending show stat to UE ----\",6),this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({\"stat.fps\":\"\"})])}sendIframeRequest(){i.Log(i.GetStackTrace(),\"---- Sending Request for an IFrame ----\",6),this.streamMessageController.toStreamerHandlers.get(\"IFrameRequest\")()}emitUIInteraction(e){i.Log(i.GetStackTrace(),\"---- Sending custom UIInteraction message ----\",6),this.streamMessageController.toStreamerHandlers.get(\"UIInteraction\")([JSON.stringify(e)])}emitCommand(e){i.Log(i.GetStackTrace(),\"---- Sending custom Command message ----\",6),this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify(e)])}emitConsoleCommand(e){i.Log(i.GetStackTrace(),\"---- Sending custom Command:ConsoleCommand message ----\",6),this.streamMessageController.toStreamerHandlers.get(\"Command\")([JSON.stringify({ConsoleCommand:e})])}sendRequestQualityControlOwnership(){i.Log(i.GetStackTrace(),\"---- Sending Request to Control Quality ----\",6),this.toStreamerMessagesController.SendRequestQualityControl()}handleLatencyTestResult(e){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.latencyTest\",6);const t=new TextDecoder(\"utf-16\").decode(e.slice(1)),s=new Ne;Object.assign(s,JSON.parse(t)),s.processFields(),s.testStartTimeMs=this.latencyStartTime,s.browserReceiptTimeMs=Date.now(),s.latencyExcludingDecode=~~(s.browserReceiptTimeMs-s.testStartTimeMs),s.testDuration=~~(s.TransmissionTimeMs-s.ReceiptTimeMs),s.networkLatency=~~(s.latencyExcludingDecode-s.testDuration),s.frameDisplayDeltaTimeMs&&s.browserReceiptTimeMs&&(s.endToEndLatency=(s.frameDisplayDeltaTimeMs,s.networkLatency,~~+s.CaptureToSendMs)),this.pixelStreaming._onLatencyTestResult(s)}handleDataChannelLatencyTestResponse(e){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.dataChannelLatencyResponse\",6);const t=new TextDecoder(\"utf-16\").decode(e.slice(1)),s=JSON.parse(t);this.pixelStreaming._onDataChannelLatencyTestResponse(s)}handleInitialSettings(e){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.InitialSettings\",6);const t=new TextDecoder(\"utf-16\").decode(e.slice(1)),s=JSON.parse(t),n=new _e;s.Encoder&&(n.EncoderSettings=s.Encoder),s.WebRTC&&(n.WebRTCSettings=s.WebRTC),s.PixelStreaming&&(n.PixelStreamingSettings=s.PixelStreaming),s.ConfigOptions&&void 0!==s.ConfigOptions.DefaultToHover&&this.config.setFlagEnabled(ue.HoveringMouseMode,!!s.ConfigOptions.DefaultToHover),n.ueCompatible(),i.Log(i.GetStackTrace(),t,6),this.pixelStreaming._onInitialSettings(n)}handleVideoEncoderAvgQP(e){i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.VideoEncoderAvgQP\",6);const t=Number(new TextDecoder(\"utf-16\").decode(e.slice(1)));this.setVideoEncoderAvgQP(t)}handleVideoInitialized(){this.pixelStreaming._onVideoInitialized(),this.autoPlayVideoOrSetUpPlayOverlay(),this.resizePlayerStyle(),this.videoPlayer.updateVideoStreamSize()}onQualityControlOwnership(e){const t=new Uint8Array(e);i.Log(i.GetStackTrace(),\"DataChannelReceiveMessageType.QualityControlOwnership\",6),this.isQualityController=new Boolean(t[1]).valueOf(),i.Log(i.GetStackTrace(),`Received quality controller message, will control quality: ${this.isQualityController}`),this.pixelStreaming._onQualityControlOwnership(this.isQualityController)}handleVideoStats(e){this.pixelStreaming._onVideoStats(e)}resizePlayerStyle(){this.videoPlayer.resizePlayerStyle()}setPreferredCodec(e){this.preferredCodec=e,this.peerConnectionController&&(this.peerConnectionController.preferredCodec=e,this.peerConnectionController.updateCodecSelection=!1)}setVideoEncoderAvgQP(e){this.videoAvgQp=e,this.pixelStreaming._onVideoEncoderAvgQP(this.videoAvgQp)}setKeyboardInputEnabled(e){var t;null===(t=this.keyboardController)||void 0===t||t.unregisterKeyBoardEvents(),e&&(this.keyboardController=this.inputClassesFactory.registerKeyBoard(this.config))}setMouseInputEnabled(e){var t;if(null===(t=this.mouseController)||void 0===t||t.unregisterMouseEvents(),e){const e=this.config.isFlagEnabled(ue.HoveringMouseMode)?Ee.HoveringMouse:Ee.LockedMouse;this.mouseController=this.inputClassesFactory.registerMouse(e)}}setTouchInputEnabled(e){var t;null===(t=this.touchController)||void 0===t||t.unregisterTouchEvents(),e&&(this.touchController=this.inputClassesFactory.registerTouch(this.config.isFlagEnabled(ue.FakeMouseWithTouches),this.videoElementParentClientRect))}setGamePadInputEnabled(e){var t;null===(t=this.gamePadController)||void 0===t||t.unregisterGamePadEvents(),e&&(this.gamePadController=this.inputClassesFactory.registerGamePad(),this.gamePadController.onGamepadConnected=()=>{this.streamMessageController.toStreamerHandlers.get(\"GamepadConnected\")()},this.gamePadController.onGamepadDisconnected=e=>{this.streamMessageController.toStreamerHandlers.get(\"GamepadDisconnected\")([e])})}registerDataChannelEventEmitters(e){e.onOpen=(e,t)=>this.pixelStreaming.dispatchEvent(new z({label:e,event:t})),e.onClose=(e,t)=>this.pixelStreaming.dispatchEvent(new _({label:e,event:t})),e.onError=(e,t)=>this.pixelStreaming.dispatchEvent(new V({label:e,event:t}))}registerMessageHandler(e,t,s){t===Ge.FromStreamer&&void 0===s&&i.Warning(i.GetStackTrace(),`Unable to register handler for ${e} as no handler was passed`),this.streamMessageController.registerMessageHandler(t,e,(n=>void 0===s&&t===Ge.ToStreamer?this.sendMessageController.sendMessageToStreamer(e,n):s(n)))}}class Ct{constructor(e){this.toStreamerMessagesProvider=e,this.controllers=[]}static deepCopyGamepad(e){return JSON.parse(JSON.stringify({buttons:e.buttons.map((e=>JSON.parse(JSON.stringify({pressed:e.pressed,touched:e.touched,value:e.value})))),axes:e.axes}))}updateStatus(e,t,s){if(e.gamepad){const n=t.getPose(e.gripSpace,s);if(!n)return;let r=0;e.profiles.includes(\"htc-vive\")?r=1:e.profiles.includes(\"oculus-touch\")&&(r=2),this.toStreamerMessagesProvider.toStreamerHandlers.get(\"XRSystem\")([r]);let i=2;switch(e.handedness){case\"left\":i=0;break;case\"right\":i=1}const a=n.transform.matrix,o=[];for(let e=0;e<16;e++)o[e]=new Float32Array([a[e]])[0];this.toStreamerMessagesProvider.toStreamerHandlers.get(\"XRControllerTransform\")([o[0],o[4],o[8],o[12],o[1],o[5],o[9],o[13],o[2],o[6],o[10],o[14],o[3],o[7],o[11],o[15],i]),void 0===this.controllers[i]&&(this.controllers[i]={prevState:void 0,currentState:void 0,id:void 0},this.controllers[i].prevState=Ct.deepCopyGamepad(e.gamepad)),this.controllers[i].currentState=Ct.deepCopyGamepad(e.gamepad);const l=this.controllers[i],d=l.currentState,c=l.prevState;for(let e=0;e{this.onXrSessionStarted(e)}))}}onXrSessionEnded(){i.Log(i.GetStackTrace(),\"XR Session ended\"),this.xrSession=null,this.onSessionEnded.dispatchEvent(new Event(\"xrSessionEnded\"))}initGL(){if(this.gl)return;const e=document.createElement(\"canvas\");this.gl=e.getContext(\"webgl2\",{xrCompatible:!0}),this.gl.clearColor(0,0,0,1)}initShaders(){const e=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(e,\"\\n attribute vec2 a_position;\\n attribute vec2 a_texCoord;\\n\\n // varyings\\n varying vec2 v_texCoord;\\n\\n void main() {\\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\\n // pass the texCoord to the fragment shader\\n // The GPU will interpolate this value between points.\\n v_texCoord = a_texCoord;\\n }\\n \"),this.gl.compileShader(e);const t=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(t,\"\\n precision mediump float;\\n\\n // our texture\\n uniform sampler2D u_image;\\n\\n // the texCoords passed in from the vertex shader.\\n varying vec2 v_texCoord;\\n\\n void main() {\\n gl_FragColor = texture2D(u_image, v_texCoord);\\n }\\n \"),this.gl.compileShader(t);const s=this.gl.createProgram();this.gl.attachShader(s,e),this.gl.attachShader(s,t),this.gl.linkProgram(s),this.gl.useProgram(s),this.positionLocation=this.gl.getAttribLocation(s,\"a_position\"),this.texcoordLocation=this.gl.getAttribLocation(s,\"a_texCoord\")}updateVideoTexture(){this.videoTexture||(this.videoTexture=this.gl.createTexture(),this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR));let e=this.webRtcController.videoPlayer.getVideoElement().videoHeight,t=this.webRtcController.videoPlayer.getVideoElement().videoWidth;this.prevVideoHeight!=e||this.prevVideoWidth!=t?this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,e,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.webRtcController.videoPlayer.getVideoElement()):this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,t,e,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.webRtcController.videoPlayer.getVideoElement()),this.prevVideoHeight=e,this.prevVideoWidth=t}initBuffers(){this.positionBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.enableVertexAttribArray(this.positionLocation),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([-1,1,1,1,-1,-1,-1,-1,1,1,1,-1]),this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.positionLocation,2,this.gl.FLOAT,!1,0,0),this.texcoordBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.texcoordBuffer),this.gl.enableVertexAttribArray(this.texcoordLocation),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this.texcoordLocation,2,this.gl.FLOAT,!1,0,0)}onXrSessionStarted(e){i.Log(i.GetStackTrace(),\"XR Session started\"),this.xrSession=e,this.xrSession.addEventListener(\"end\",(()=>{this.onXrSessionEnded()})),this.initGL(),this.initShaders(),this.initBuffers(),e.requestReferenceSpace(\"local\").then((t=>{if(this.xrRefSpace=t,this.xrSession.updateRenderState({baseLayer:new XRWebGLLayer(this.xrSession,this.gl)}),this.xrSession.supportedFrameRates)for(let t of this.xrSession.supportedFrameRates)90==t&&e.updateTargetFrameRate(90);this.xrSession.requestAnimationFrame(this.onXrFrame.bind(this))})),this.onSessionStarted.dispatchEvent(new Event(\"xrSessionStarted\"))}sendXRDataToUE(){if(null==this.leftView||null==this.rightView)return;const e=this.leftView.transform.matrix,t=this.leftView.projectionMatrix,s=this.rightView.transform.matrix,n=this.rightView.projectionMatrix;this.webRtcController.streamMessageController.toStreamerHandlers.get(\"XREyeViews\")([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15],t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15],s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15],n[0],n[4],n[8],n[12],n[1],n[5],n[9],n[13],n[2],n[6],n[10],n[14],n[3],n[7],n[11],n[15]])}onXrFrame(e,t){if(this.xrViewerPose=t.getViewerPose(this.xrRefSpace),this.xrViewerPose){if(this.updateViews(),null==this.leftView||null==this.rightView)return;this.sendXRDataToUE(),this.updateVideoTexture(),this.render()}this.webRtcController.config.isFlagEnabled(ue.XRControllerInput)&&this.xrSession.inputSources.forEach(((e,s,n)=>{this.xrGamepadController.updateStatus(e,t,this.xrRefSpace)}),this),this.xrSession.requestAnimationFrame(((e,t)=>this.onXrFrame(e,t))),this.onFrame.dispatchEvent(new le({time:e,frame:t}))}updateViews(){if(this.xrViewerPose)for(const e of this.xrViewerPose.views)\"left\"===e.eye?this.leftView=e:\"right\"===e.eye&&(this.rightView=e)}render(){if(!this.gl)return;const e=this.xrSession.renderState.baseLayer;this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e.framebuffer),this.gl.viewport(0,0,e.framebufferWidth,e.framebufferHeight),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}static isSessionSupported(e){return\"https:\"!==location.protocol&&i.Info(null,\"WebXR requires https, if you want WebXR use https.\"),navigator.xr?navigator.xr.isSessionSupported(e):new Promise((()=>!1))}}class Tt{constructor(e){this.editTextButton=null,this.hiddenInput=null,\"ontouchstart\"in document.documentElement&&this.createOnScreenKeyboardHelpers(e)}unquantizeAndDenormalizeUnsigned(e,t){return null}createOnScreenKeyboardHelpers(e){this.hiddenInput||(this.hiddenInput=document.createElement(\"input\"),this.hiddenInput.id=\"hiddenInput\",this.hiddenInput.maxLength=0,this.hiddenInput.style.position=\"absolute\",this.hiddenInput.style.left=\"-10%\",this.hiddenInput.style.width=\"0px\",this.hiddenInput.style.opacity=\"0\",e.appendChild(this.hiddenInput)),this.editTextButton||(this.editTextButton=document.createElement(\"button\"),this.editTextButton.id=\"editTextButton\",this.editTextButton.innerHTML=\"edit text\",e.appendChild(this.editTextButton),this.editTextButton.style.display=\"none\",this.editTextButton.addEventListener(\"touchend\",(e=>{this.hiddenInput.focus(),e.preventDefault()})))}showOnScreenKeyboard(e){if(e.showOnScreenKeyboard){this.editTextButton.style.display=\"default\";const t=this.unquantizeAndDenormalizeUnsigned(e.x,e.y);this.editTextButton.style.top=t.y.toString()+\"px\",this.editTextButton.style.left=(t.x-40).toString()+\"px\"}else this.editTextButton.style.display=\"none\",this.hiddenInput.blur()}}class Et{constructor(e){this.seq=e.Seq,this.playerSentTimestamp=Date.now(),this.requestFillerSize=e.Filler?e.Filler.length:0}update(e){this.playerReceivedTimestamp=Date.now(),this.streamerReceivedTimestamp=e.ReceivedTimestamp,this.streamerSentTimestamp=e.SentTimestamp,this.responseFillerSize=e.Filler?e.Filler.length:0}}class yt{constructor(e,t){this.sink=e,this.callback=t,this.records=new Map,this.seq=0}start(e){return!this.isRunning()&&(this.startTime=Date.now(),this.records.clear(),this.interval=setInterval((()=>{Date.now()-this.startTime>=e.duration?this.stop():this.sendRequest(e.requestSize,e.responseSize)}).bind(this),Math.floor(1e3/e.rps)),!0)}stop(){this.interval&&(clearInterval(this.interval),this.interval=void 0,this.callback(this.produceResult()))}produceResult(){const e=new Map(this.records);return{records:e,dataChannelRtt:Math.ceil(Array.from(this.records.values()).reduce(((e,t)=>e+(t.playerReceivedTimestamp-t.playerSentTimestamp)),0)/this.records.size),playerToStreamerTime:Math.ceil(Array.from(this.records.values()).reduce(((e,t)=>e+(t.streamerReceivedTimestamp-t.playerSentTimestamp)),0)/this.records.size),streamerToPlayerTime:Math.ceil(Array.from(this.records.values()).reduce(((e,t)=>e+(t.playerReceivedTimestamp-t.streamerSentTimestamp)),0)/this.records.size),exportLatencyAsCSV:()=>{let t=\"Timestamp;RTT;PlayerToStreamer;StreamerToPlayer;\\n\";return e.forEach((e=>{t+=e.playerSentTimestamp+\";\",t+=e.playerReceivedTimestamp-e.playerSentTimestamp+\";\",t+=e.streamerReceivedTimestamp-e.playerSentTimestamp+\";\",t+=e.playerReceivedTimestamp-e.streamerSentTimestamp+\";\",t+=\"\\n\"})),t}}}isRunning(){return!!this.interval}receive(e){if(!this.isRunning())return;if(!e)return void i.Error(i.GetStackTrace(),\"Undefined response from server\");let t=this.records.get(e.Seq);t&&t.update(e)}sendRequest(e,t){let s=this.createRequest(e,t),n=new Et(s);this.records.set(n.seq,n),this.sink(s)}createRequest(e,t){return{Seq:this.seq++,FillResponseSize:t,Filler:e?\"A\".repeat(e):\"\"}}}class Mt{constructor(e,t){this.allowConsoleCommands=!1,this.config=e,(null==t?void 0:t.videoElementParent)&&(this._videoElementParent=t.videoElementParent),this._eventEmitter=new he,this.configureSettings(),this.setWebRtcPlayerController(new vt(this.config,this)),this.onScreenKeyboardHelper=new Tt(this.videoElementParent),this.onScreenKeyboardHelper.unquantizeAndDenormalizeUnsigned=(e,t)=>this._webRtcController.requestUnquantizedAndDenormalizeUnsigned(e,t),this._activateOnScreenKeyboard=e=>this.onScreenKeyboardHelper.showOnScreenKeyboard(e),this._webXrController=new ft(this._webRtcController),this._setupWebRtcTCPRelayDetection=this._setupWebRtcTCPRelayDetection.bind(this),this._eventEmitter.addEventListener(\"webRtcConnected\",(e=>{this._eventEmitter.addEventListener(\"statsReceived\",this._setupWebRtcTCPRelayDetection)}))}get videoElementParent(){return this._videoElementParent||(this._videoElementParent=document.createElement(\"div\"),this._videoElementParent.id=\"videoElementParent\"),this._videoElementParent}configureSettings(){this.config._addOnSettingChangedListener(ue.IsQualityController,(e=>{!0!==e||this._webRtcController.isQualityController||this._webRtcController.sendRequestQualityControlOwnership()})),this.config._addOnSettingChangedListener(ue.AFKDetection,(e=>{this._webRtcController.setAfkEnabled(e)})),this.config._addOnSettingChangedListener(ue.MatchViewportResolution,(()=>{this._webRtcController.videoPlayer.updateVideoStreamSize()})),this.config._addOnSettingChangedListener(ue.HoveringMouseMode,(e=>{this.config.setFlagLabel(ue.HoveringMouseMode,`Control Scheme: ${e?\"Hovering\":\"Locked\"} Mouse`),this._webRtcController.setMouseInputEnabled(this.config.isFlagEnabled(ue.MouseInput))})),this.config._addOnSettingChangedListener(ue.KeyboardInput,(e=>{this._webRtcController.setKeyboardInputEnabled(e)})),this.config._addOnSettingChangedListener(ue.MouseInput,(e=>{this._webRtcController.setMouseInputEnabled(e)})),this.config._addOnSettingChangedListener(ue.FakeMouseWithTouches,(e=>{this._webRtcController.setTouchInputEnabled(this.config.isFlagEnabled(ue.TouchInput))})),this.config._addOnSettingChangedListener(ue.TouchInput,(e=>{this._webRtcController.setTouchInputEnabled(e)})),this.config._addOnSettingChangedListener(ue.GamepadInput,(e=>{this._webRtcController.setGamePadInputEnabled(e)})),this.config._addOnNumericSettingChangedListener(me.MinQP,(e=>{i.Log(i.GetStackTrace(),\"-------- Sending MinQP --------\",7),this._webRtcController.sendEncoderMinQP(e),i.Log(i.GetStackTrace(),\"-------------------------------------------\",7)})),this.config._addOnNumericSettingChangedListener(me.MaxQP,(e=>{i.Log(i.GetStackTrace(),\"-------- Sending encoder settings --------\",7),this._webRtcController.sendEncoderMaxQP(e),i.Log(i.GetStackTrace(),\"-------------------------------------------\",7)})),this.config._addOnNumericSettingChangedListener(me.WebRTCMinBitrate,(e=>{i.Log(i.GetStackTrace(),\"-------- Sending web rtc settings --------\",7),this._webRtcController.sendWebRTCMinBitrate(1e3*e),i.Log(i.GetStackTrace(),\"-------------------------------------------\",7)})),this.config._addOnNumericSettingChangedListener(me.WebRTCMaxBitrate,(e=>{i.Log(i.GetStackTrace(),\"-------- Sending web rtc settings --------\",7),this._webRtcController.sendWebRTCMaxBitrate(1e3*e),i.Log(i.GetStackTrace(),\"-------------------------------------------\",7)})),this.config._addOnNumericSettingChangedListener(me.WebRTCFPS,(e=>{i.Log(i.GetStackTrace(),\"-------- Sending web rtc settings --------\",7),this._webRtcController.sendWebRTCFps(e),i.Log(i.GetStackTrace(),\"-------------------------------------------\",7)})),this.config._addOnOptionSettingChangedListener(Ce.PreferredCodec,(e=>{this._webRtcController&&this._webRtcController.setPreferredCodec(e)})),this.config._registerOnChangeEvents(this._eventEmitter)}_activateOnScreenKeyboard(e){throw new Error(\"Method not implemented.\")}_onInputControlOwnership(e){this._inputController=e}setWebRtcPlayerController(e){this._webRtcController=e,this._webRtcController.setPreferredCodec(this.config.getSettingOption(Ce.PreferredCodec).selected),this._webRtcController.resizePlayerStyle(),this.checkForAutoConnect()}connect(){this._eventEmitter.dispatchEvent(new N),this._webRtcController.connectToSignallingServer()}reconnect(){this._eventEmitter.dispatchEvent(new Q),this._webRtcController.tryReconnect(\"Reconnecting...\")}disconnect(){this._eventEmitter.dispatchEvent(new K),this._webRtcController.close()}play(){this._onStreamLoading(),this._webRtcController.playStream()}checkForAutoConnect(){this.config.isFlagEnabled(ue.AutoConnect)&&(this._onWebRtcAutoConnect(),this._webRtcController.connectToSignallingServer())}unmuteMicrophone(e=!1){if(!this.config.isFlagEnabled(\"UseMic\"))return e?(this.config.setFlagEnabled(\"UseMic\",!0),void this.reconnect()):void i.Warning(i.GetStackTrace(),\"Trying to unmute mic, but PixelStreaming was initialized with no microphone track. Call with forceEnable == true to re-connect with a mic track.\");this.setMicrophoneMuted(!1)}muteMicrophone(){this.config.isFlagEnabled(\"UseMic\")?this.setMicrophoneMuted(!0):i.Info(i.GetStackTrace(),\"Trying to mute mic, but PixelStreaming has no microphone track, so sending sound is already disabled.\")}setMicrophoneMuted(e){var t,s,n,r;for(const i of null!==(r=null===(n=null===(s=null===(t=this._webRtcController)||void 0===t?void 0:t.peerConnectionController)||void 0===s?void 0:s.peerConnection)||void 0===n?void 0:n.getTransceivers())&&void 0!==r?r:[])Ie.canTransceiverSendAudio(i)&&(i.sender.track.enabled=!e)}_onWebRtcAutoConnect(){this._eventEmitter.dispatchEvent(new O)}_onWebRtcSdp(){this._eventEmitter.dispatchEvent(new D)}_onStreamLoading(){this._eventEmitter.dispatchEvent(new W)}_onDisconnect(e,t){this._eventEmitter.dispatchEvent(new B({eventString:e,allowClickToReconnect:t}))}_onWebRtcConnecting(){this._eventEmitter.dispatchEvent(new I)}_onWebRtcConnected(){this._eventEmitter.dispatchEvent(new U)}_onWebRtcFailed(){this._eventEmitter.dispatchEvent(new G)}_onVideoInitialized(){this._eventEmitter.dispatchEvent(new H),this._videoStartTime=Date.now()}_onLatencyTestResult(e){this._eventEmitter.dispatchEvent(new te({latencyTimings:e}))}_onDataChannelLatencyTestResponse(e){this._eventEmitter.dispatchEvent(new se({response:e}))}_onVideoStats(e){this._videoStartTime&&void 0!==this._videoStartTime||(this._videoStartTime=Date.now()),e.handleSessionStatistics(this._videoStartTime,this._inputController,this._webRtcController.videoAvgQp),this._eventEmitter.dispatchEvent(new Y({aggregatedStats:e}))}_onVideoEncoderAvgQP(e){this._eventEmitter.dispatchEvent(new F({avgQP:e}))}_onInitialSettings(e){var t;this._eventEmitter.dispatchEvent(new re({settings:e})),e.PixelStreamingSettings&&(this.allowConsoleCommands=null!==(t=e.PixelStreamingSettings.AllowPixelStreamingCommands)&&void 0!==t&&t,!1===this.allowConsoleCommands&&i.Info(i.GetStackTrace(),\"-AllowPixelStreamingCommands=false, sending arbitrary console commands from browser to UE is disabled.\"));const s=this.config.useUrlParams,n=new URLSearchParams(window.location.search);i.Info(i.GetStackTrace(),`using URL parameters ${s}`),e.EncoderSettings&&(this.config.setNumericSetting(me.MinQP,s&&n.has(me.MinQP)?Number.parseFloat(n.get(me.MinQP)):e.EncoderSettings.MinQP),this.config.setNumericSetting(me.MaxQP,s&&n.has(me.MaxQP)?Number.parseFloat(n.get(me.MaxQP)):e.EncoderSettings.MaxQP)),e.WebRTCSettings&&(this.config.setNumericSetting(me.WebRTCMinBitrate,s&&n.has(me.WebRTCMinBitrate)?Number.parseFloat(n.get(me.WebRTCMinBitrate)):e.WebRTCSettings.MinBitrate/1e3),this.config.setNumericSetting(me.WebRTCMaxBitrate,s&&n.has(me.WebRTCMaxBitrate)?Number.parseFloat(n.get(me.WebRTCMaxBitrate)):e.WebRTCSettings.MaxBitrate/1e3),this.config.setNumericSetting(me.WebRTCFPS,s&&n.has(me.WebRTCFPS)?Number.parseFloat(n.get(me.WebRTCFPS)):e.WebRTCSettings.FPS))}_onQualityControlOwnership(e){this.config.setFlagEnabled(ue.IsQualityController,e)}_onPlayerCount(e){this._eventEmitter.dispatchEvent(new de({count:e}))}_setupWebRtcTCPRelayDetection(e){let t=e.data.aggregatedStats.getActiveCandidatePair();if(null!=t){let s=e.data.aggregatedStats.localCandidates.find((e=>e.id==t.localCandidateId),null);null!=s&&\"relay\"==s.candidateType&&\"tcp\"==s.relayProtocol&&this._eventEmitter.dispatchEvent(new ce),this._eventEmitter.removeEventListener(\"statsReceived\",this._setupWebRtcTCPRelayDetection)}}requestLatencyTest(){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.sendLatencyTest(),!0)}requestDataChannelLatencyTest(e){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._dataChannelLatencyTestController||(this._dataChannelLatencyTestController=new yt(this._webRtcController.sendDataChannelLatencyTest.bind(this._webRtcController),(e=>{this._eventEmitter.dispatchEvent(new ne({result:e}))})),this.addEventListener(\"dataChannelLatencyTestResponse\",(({data:{response:e}})=>{this._dataChannelLatencyTestController.receive(e)}))),this._dataChannelLatencyTestController.start(e))}requestShowFps(){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.sendShowFps(),!0)}requestIframe(){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.sendIframeRequest(),!0)}emitUIInteraction(e){return!!this._webRtcController.videoPlayer.isVideoReady()&&(this._webRtcController.emitUIInteraction(e),!0)}emitCommand(e){return!(!this._webRtcController.videoPlayer.isVideoReady()||!this.allowConsoleCommands&&\"ConsoleCommand\"in e||(this._webRtcController.emitCommand(e),0))}emitConsoleCommand(e){return!(!this.allowConsoleCommands||!this._webRtcController.videoPlayer.isVideoReady()||(this._webRtcController.emitConsoleCommand(e),0))}addResponseEventListener(e,t){this._webRtcController.responseController.addResponseEventListener(e,t)}removeResponseEventListener(e){this._webRtcController.responseController.removeResponseEventListener(e)}dispatchEvent(e){return this._eventEmitter.dispatchEvent(e)}addEventListener(e,t){this._eventEmitter.addEventListener(e,t)}removeEventListener(e,t){this._eventEmitter.removeEventListener(e,t)}toggleXR(){this.webXrController.xrClicked()}setSignallingUrlBuilder(e){this._webRtcController.signallingUrlBuilder=e}get webSocketController(){return this._webRtcController.webSocketController}get webXrController(){return this._webXrController}registerMessageHandler(e,t,s){t!==Ge.FromStreamer||void 0!==s?t===Ge.ToStreamer&&void 0===s?this._webRtcController.streamMessageController.registerMessageHandler(t,e,(t=>this._webRtcController.sendMessageController.sendMessageToStreamer(e,t))):this._webRtcController.streamMessageController.registerMessageHandler(t,e,(e=>s(e))):i.Warning(i.GetStackTrace(),`Unable to register an undefined handler for ${e}`)}get toStreamerHandlers(){return this._webRtcController.streamMessageController.toStreamerHandlers}isReconnecting(){return this._webRtcController.isReconnecting}}class wt{}var bt=r.Dz,Rt=r.g$,Pt=r.Lt,kt=r.Q9,Lt=r.qf,xt=r.hV,At=r.z$,Ft=r.J0,Dt=r.De,Ot=r.$C,It=r.al,Ut=r._W,Gt=r.Gv,Bt=r.m,zt=r.tz,_t=r.Nu,Vt=r.zg,Ht=r.vp,Wt=r.vU,Nt=r.wF,Kt=r.rv,Qt=r.Nh,qt=r.ss,$t=r.qW,Xt=r.QL,jt=r.cf,Jt=r.eM,Yt=r.Yd,Zt=r.Tk,es=r.iM,ts=r.qy,ss=r.ce,ns=r.sK,rs=r.Ok,is=r.q5,as=r.g,os=r.xl,ls=r.I,ds=r.bx,cs=r.dD,hs=r.Ib,us=r.Az,gs=r.Iw,ms=r.qY,ps=r.db,Ss=r.mR,vs=r.Tn,Cs=r.rV,fs=r.gh,Ts=r.Mi,Es=r.j,ys=r.YB,Ms=r.Yt,ws=r.i5,bs=r.x_,Rs=r.Am,Ps=r.eR,ks=r.r8,Ls=r.u3,xs=r.vd,As=r.iV,Fs=r.jZ,Ds=r.SW,Os=r.ZH,Is=r.Ni,Us=r.lh,Gs=r.ZP,Bs=r.bq,zs=r.$f,_s=r.eu,Vs=r.Ax,Hs=r.Mc;export{bt as AfkLogic,Rt as AfkTimedOutEvent,Pt as AfkWarningActivateEvent,kt as AfkWarningDeactivateEvent,Lt as AfkWarningUpdateEvent,xt as AggregatedStats,At as CandidatePairStats,Ft as CandidateStat,Dt as Config,Ot as ControlSchemeType,It as DataChannelCloseEvent,Ut as DataChannelErrorEvent,Gt as DataChannelLatencyTestResponseEvent,Bt as DataChannelLatencyTestResultEvent,zt as DataChannelOpenEvent,_t as DataChannelStats,Vt as EncoderSettings,Ht as EventEmitter,Wt as Flags,Nt as HideFreezeFrameEvent,Kt as InboundAudioStats,Qt as InboundVideoStats,qt as InitialSettings,$t as InitialSettingsEvent,Xt as LatencyTestResultEvent,jt as LatencyTestResults,Jt as LoadFreezeFrameEvent,Yt as Logger,Zt as MessageDirection,es as MessageRecv,ts as MessageSend,ss as MessageStreamerList,ns as NumericParameters,rs as OptionParameters,is as OutBoundVideoStats,as as PixelStreaming,os as PlayStreamErrorEvent,ls as PlayStreamEvent,ds as PlayStreamRejectedEvent,cs as PlayerCountEvent,hs as SettingBase,us as SettingFlag,gs as SettingNumber,ms as SettingOption,ps as SettingText,Ss as SettingsChangedEvent,vs as SignallingProtocol,Cs as StatsReceivedEvent,fs as StreamLoadingEvent,Ts as StreamPreConnectEvent,Es as StreamPreDisconnectEvent,ys as StreamReconnectEvent,Ms as StreamerIDChangedMessageEvent,ws as StreamerListMessageEvent,bs as TextParameters,Rs as UnquantizedAndDenormalizeUnsigned,Ps as VideoEncoderAvgQPEvent,ks as VideoInitializedEvent,Ls as WebRTCSettings,xs as WebRtcAutoConnectEvent,As as WebRtcConnectedEvent,Fs as WebRtcConnectingEvent,Ds as WebRtcDisconnectedEvent,Os as WebRtcFailedEvent,Is as WebRtcPlayerController,Us as WebRtcSdpEvent,Gs as WebRtcTCPRelayDetectedEvent,Bs as WebSocketController,zs as WebXRController,_s as XrFrameEvent,Vs as XrSessionEndedEvent,Hs as XrSessionStartedEvent};","import { Subject, AnonymousSubject } from '../../Subject';\nimport { Subscriber } from '../../Subscriber';\nimport { Observable } from '../../Observable';\nimport { Subscription } from '../../Subscription';\nimport { ReplaySubject } from '../../ReplaySubject';\nconst DEFAULT_WEBSOCKET_CONFIG = {\n url: '',\n deserializer: (e) => JSON.parse(e.data),\n serializer: (value) => JSON.stringify(value),\n};\nconst WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';\nexport class WebSocketSubject extends AnonymousSubject {\n constructor(urlConfigOrSource, destination) {\n super();\n this._socket = null;\n if (urlConfigOrSource instanceof Observable) {\n this.destination = destination;\n this.source = urlConfigOrSource;\n }\n else {\n const config = (this._config = Object.assign({}, DEFAULT_WEBSOCKET_CONFIG));\n this._output = new Subject();\n if (typeof urlConfigOrSource === 'string') {\n config.url = urlConfigOrSource;\n }\n else {\n for (const key in urlConfigOrSource) {\n if (urlConfigOrSource.hasOwnProperty(key)) {\n config[key] = urlConfigOrSource[key];\n }\n }\n }\n if (!config.WebSocketCtor && WebSocket) {\n config.WebSocketCtor = WebSocket;\n }\n else if (!config.WebSocketCtor) {\n throw new Error('no WebSocket constructor can be found');\n }\n this.destination = new ReplaySubject();\n }\n }\n lift(operator) {\n const sock = new WebSocketSubject(this._config, this.destination);\n sock.operator = operator;\n sock.source = this;\n return sock;\n }\n _resetState() {\n this._socket = null;\n if (!this.source) {\n this.destination = new ReplaySubject();\n }\n this._output = new Subject();\n }\n multiplex(subMsg, unsubMsg, messageFilter) {\n const self = this;\n return new Observable((observer) => {\n try {\n self.next(subMsg());\n }\n catch (err) {\n observer.error(err);\n }\n const subscription = self.subscribe({\n next: (x) => {\n try {\n if (messageFilter(x)) {\n observer.next(x);\n }\n }\n catch (err) {\n observer.error(err);\n }\n },\n error: (err) => observer.error(err),\n complete: () => observer.complete(),\n });\n return () => {\n try {\n self.next(unsubMsg());\n }\n catch (err) {\n observer.error(err);\n }\n subscription.unsubscribe();\n };\n });\n }\n _connectSocket() {\n const { WebSocketCtor, protocol, url, binaryType } = this._config;\n const observer = this._output;\n let socket = null;\n try {\n socket = protocol ? new WebSocketCtor(url, protocol) : new WebSocketCtor(url);\n this._socket = socket;\n if (binaryType) {\n this._socket.binaryType = binaryType;\n }\n }\n catch (e) {\n observer.error(e);\n return;\n }\n const subscription = new Subscription(() => {\n this._socket = null;\n if (socket && socket.readyState === 1) {\n socket.close();\n }\n });\n socket.onopen = (evt) => {\n const { _socket } = this;\n if (!_socket) {\n socket.close();\n this._resetState();\n return;\n }\n const { openObserver } = this._config;\n if (openObserver) {\n openObserver.next(evt);\n }\n const queue = this.destination;\n this.destination = Subscriber.create((x) => {\n if (socket.readyState === 1) {\n try {\n const { serializer } = this._config;\n socket.send(serializer(x));\n }\n catch (e) {\n this.destination.error(e);\n }\n }\n }, (err) => {\n const { closingObserver } = this._config;\n if (closingObserver) {\n closingObserver.next(undefined);\n }\n if (err && err.code) {\n socket.close(err.code, err.reason);\n }\n else {\n observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));\n }\n this._resetState();\n }, () => {\n const { closingObserver } = this._config;\n if (closingObserver) {\n closingObserver.next(undefined);\n }\n socket.close();\n this._resetState();\n });\n if (queue && queue instanceof ReplaySubject) {\n subscription.add(queue.subscribe(this.destination));\n }\n };\n socket.onerror = (e) => {\n this._resetState();\n observer.error(e);\n };\n socket.onclose = (e) => {\n if (socket === this._socket) {\n this._resetState();\n }\n const { closeObserver } = this._config;\n if (closeObserver) {\n closeObserver.next(e);\n }\n if (e.wasClean) {\n observer.complete();\n }\n else {\n observer.error(e);\n }\n };\n socket.onmessage = (e) => {\n try {\n const { deserializer } = this._config;\n observer.next(deserializer(e));\n }\n catch (err) {\n observer.error(err);\n }\n };\n }\n _subscribe(subscriber) {\n const { source } = this;\n if (source) {\n return source.subscribe(subscriber);\n }\n if (!this._socket) {\n this._connectSocket();\n }\n this._output.subscribe(subscriber);\n subscriber.add(() => {\n const { _socket } = this;\n if (this._output.observers.length === 0) {\n if (_socket && (_socket.readyState === 1 || _socket.readyState === 0)) {\n _socket.close();\n }\n this._resetState();\n }\n });\n return subscriber;\n }\n unsubscribe() {\n const { _socket } = this;\n if (_socket && (_socket.readyState === 1 || _socket.readyState === 0)) {\n _socket.close();\n }\n this._resetState();\n super.unsubscribe();\n }\n}\n","import {\n DataChannelErrorEvent,\n PixelStreamingEvent,\n PlayStreamErrorEvent,\n WebRtcDisconnectedEvent,\n WebRtcFailedEvent,\n} from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.4';\nimport * as Sentry from '@sentry/angular';\nimport { ErrorDialogService } from '../../../services/errordialog.service';\nimport { PixelStreamingService, StreamErrorEvent } from './pixel-streaming.service';\n\nexport class PixelStreamErrorEventHandler {\n eventHandlerMap = new Map void>();\n\n constructor(\n private readonly pixelStreamingService: PixelStreamingService,\n private readonly errorDialogService: ErrorDialogService\n ) {\n this.registerErrorListeners();\n }\n\n handleError(eventType: string, error: StreamErrorEvent) {\n console.error(`${eventType} error`, error);\n Sentry.captureException(error);\n this.pixelStreamingService.disconnect();\n\n if (!this.pixelStreamingService.streamingError()) {\n this.showError(error);\n }\n }\n\n removeAllEventHandlers(): void {\n this.eventHandlerMap.forEach((handler, eventType) => {\n this.pixelStreamingService.pixelStreaming.removeEventListener(eventType, handler);\n });\n }\n\n private registerErrorListeners() {\n this.eventHandlerMap.set('webRtcDisconnected', (error: WebRtcDisconnectedEvent) => {\n this.handleError('WebRTC disconnected', error);\n });\n\n this.eventHandlerMap.set('dataChannelError', (error: DataChannelErrorEvent) => {\n this.handleError('Data channel error', error);\n });\n\n this.eventHandlerMap.set('playStreamError', (error: PlayStreamErrorEvent) => {\n this.handleError('Play stream error', error);\n });\n\n this.eventHandlerMap.set('webRtcFailed', (error: WebRtcFailedEvent) => {\n this.handleError('WebRTC connection failed', error);\n });\n }\n\n private showError(error: StreamErrorEvent) {\n this.pixelStreamingService.streamingError.set(true);\n this.pixelStreamingService.streamReady.set(false);\n this.errorDialogService.openDialog({\n errorCode: '0xPIXEL',\n location: 'pixelStreaming',\n devinfo: error,\n publicinfo:\n 'Fehler beim Verbinden mit dem Pixelstream. Bitte laden sie die Seite neu oder wenden Sie sich an unseren Support. Vielen Dank.',\n debug: false,\n autoFocus: false,\n });\n }\n}\n","import { Injectable, signal, WritableSignal } from '@angular/core';\nimport {\n AllSettings,\n Config,\n DataChannelErrorEvent,\n PixelStreaming,\n PlayStreamErrorEvent,\n WebRtcDisconnectedEvent,\n WebRtcFailedEvent,\n // Logger as PixelstreamingLogger\n} from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.4';\nimport { Observable } from 'rxjs';\nimport { webSocket, WebSocketSubject } from 'rxjs/webSocket';\nimport { environment } from '../../../../environments/environment';\nimport { ErrorDialogService } from '../../../services/errordialog.service';\nimport { TokenService } from '../../../services/token.service';\nimport { ServiceCacheService } from '../../../services/service-cache.service';\nimport { PixelStreamErrorEventHandler } from './PixelStreamErrorEventHandler';\n\ntype Status = 'READY' | 'NEXT' | 'IN_QUEUE' | 'NOT_IN_QUEUE';\n\nexport type StreamErrorEvent =\n | DataChannelErrorEvent\n | PlayStreamErrorEvent\n | WebRtcFailedEvent\n | WebRtcDisconnectedEvent;\n\nexport interface QueueStatus {\n status: Status;\n}\n\n// Documentation of the settings can be found here:\n// https://github.com/EpicGamesExt/PixelStreamingInfrastructure/blob/UE5.4-1.1.5/Frontend/Docs/Settings%20Panel.md\nconst initialSettings: Partial = {\n AutoPlayVideo: true,\n AutoConnect: true,\n ss: environment.pixelStreamingSessionUrl + '/connect',\n StartVideoMuted: true,\n HoveringMouse: true,\n // We handle the reconnect currently manually, but there is the option to use the reconnect feature of the pixel streaming\n MaxReconnectAttempts: 0,\n MinQP: 0,\n MaxQP: 0,\n WebRTCFPS: 60,\n MatchViewportRes: true,\n // Timeout can be set for further improvements e.g. to prevent the stream from being open while not used\n TimeoutIfIdle: false,\n // AFKTimeout: 60,\n // ControlsQuality: true,\n};\n\n@Injectable({\n providedIn: 'root',\n})\nexport class PixelStreamingService {\n pixelStreaming: PixelStreaming;\n pixelStreamErrorEventHandler: PixelStreamErrorEventHandler;\n\n streamingError: WritableSignal;\n streamReady: WritableSignal;\n\n private socket$: WebSocketSubject;\n\n constructor(\n private readonly tokenService: TokenService,\n private readonly errorDialogService: ErrorDialogService,\n private readonly serviceCacheService: ServiceCacheService\n ) {\n this.serviceCacheService.registerCacheClearer(() => this.disconnect());\n this.streamingError = signal(false);\n this.streamReady = signal(false);\n this.connectToQueue();\n this.pixelStreamErrorEventHandler = new PixelStreamErrorEventHandler(\n this,\n this.errorDialogService\n );\n // logger specific to the ue pixelstreaming implementation, useful for debugging\n // websocket and webRTC connections\n // PixelstreamingLogger.SetLoggerVerbosity(6)\n }\n\n connectToQueue() {\n if (!this.socket$) {\n this.socket$ = webSocket({\n url: environment.pixelStreamingSessionUrl + `?token=${this.tokenService.getToken().value}`,\n });\n }\n }\n\n getQueueStatus(): Observable {\n return this.socket$.asObservable();\n }\n\n connectToPixelStream(videoParent: HTMLElement) {\n const token = this.tokenService.getToken().value;\n if (!initialSettings.ss.includes('?token')) {\n initialSettings.ss += `?token=${token}`;\n }\n const config = new Config({ initialSettings });\n this.pixelStreaming = new PixelStreaming(config, { videoElementParent: videoParent });\n this.streamReady.set(true);\n\n this.initializeEventListeners();\n }\n\n disconnect() {\n this.streamReady.set(false);\n if (this.socket$) {\n this.disconnectFromQueue();\n }\n if (this.pixelStreaming) {\n this.pixelStreamErrorEventHandler.removeAllEventHandlers();\n this.disconnectPixelStream();\n }\n }\n\n private disconnectFromQueue() {\n this.socket$ = undefined;\n }\n\n private disconnectPixelStream() {\n this.pixelStreaming.disconnect();\n delete this.pixelStreaming;\n }\n\n private initializeEventListeners() {\n this.pixelStreaming.addEventListener('videoInitialized', () => {\n this.startStream();\n });\n\n this.pixelStreamErrorEventHandler.eventHandlerMap.forEach((handler, eventType) => {\n this.pixelStreaming.addEventListener(eventType, handler);\n });\n }\n\n private startStream() {\n this.streamingError.set(false);\n const { value: token, expiry: tokenExpiry } = {\n // If used locally this has to be changed to the token value from a token from DEV\n value: this.tokenService.getToken().value,\n expiry: this.tokenService.getToken().expiry,\n };\n this.pixelStreaming.emitUIInteraction({\n openStaticProject: {\n token,\n tokenExpiry,\n // TODO Specify correct project. Only test name for now\n projectName: environment.local\n ? 'TEMPLATE - Exklusives Flachdachhaus - DONT USE'\n : 'Fiktives Ausstellungshaus',\n },\n });\n }\n}\n","import { WebSocketSubject } from './WebSocketSubject';\nexport function webSocket(urlConfigOrSource) {\n return new WebSocketSubject(urlConfigOrSource);\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot } from '@angular/router';\nimport { NavigationService, Page } from './services/navigation.service';\nimport { AuthService } from './services/auth.service';\nimport { ConfigurationResolverService } from './resolvers/configuration-resolver.service';\n\nexport const LOCAL_STORAGE_ONBOARDING_SCREEN_VISIT_KEY = 'visitedAssetCatalog';\n\n@Injectable()\nexport class OnboardingScreenGuard {\n constructor(\n private navigationService: NavigationService,\n private authService: AuthService,\n private configurationResolverService: ConfigurationResolverService\n ) {}\n\n async canActivate(route: ActivatedRouteSnapshot): Promise {\n const onboardingScreenGroup: string[] = route.data.onboardingScreenGroup;\n const userIsInOnboardingUserGroup = this.isUserInOnboardingUserGroups(onboardingScreenGroup);\n \n if (userIsInOnboardingUserGroup && this.isFirstVisit()) {\n await this.handlePotentialConfigurationIdsFromURL(route);\n await this.redirectToOnboardingScreen();\n return false;\n }\n\n return true;\n }\n\n private isFirstVisit(): boolean {\n return this.localStorageDoesNotContainFirstVisitValue();\n }\n\n private localStorageDoesNotContainFirstVisitValue(): boolean {\n return !!!window.localStorage.getItem(LOCAL_STORAGE_ONBOARDING_SCREEN_VISIT_KEY);\n }\n\n private async redirectToOnboardingScreen() {\n await this.navigationService.navigateTo(Page.ONBOARDING_SCREEN);\n }\n\n private isUserInOnboardingUserGroups(onboardingUserGroups: string[]): boolean {\n return this.authService.hasUserGroup(onboardingUserGroups);\n }\n\n private async handlePotentialConfigurationIdsFromURL(route: ActivatedRouteSnapshot) {\n await this.configurationResolverService.resolve(route);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot } from '@angular/router';\nimport { environment } from '../environments/environment';\nimport { AuthService } from './services/auth.service';\nimport { EnvironmentService } from './services/environment.service';\nimport { NavigationService, Page } from './services/navigation.service';\n\n@Injectable()\nexport class ProductCatalogGuard {\n constructor(\n private readonly authService: AuthService,\n private readonly environmentService: EnvironmentService,\n private readonly navigationService: NavigationService\n ) {}\n\n async canActivate(route: ActivatedRouteSnapshot): Promise {\n if (\n this.authService.hasFeatureFlag(route.data.featureFlag) &&\n this.environmentService.isFingerhaus()\n ) {\n return true;\n } else {\n const page = this.isFingerhausConsultant() ? Page.MANAGEMENT : Page.CATALOG;\n await this.navigationService.navigateTo(page);\n return false;\n }\n }\n\n private isFingerhausConsultant(): boolean {\n return this.authService.hasUserGroup(environment.FINGERHAUS_CONSULTANT_GROUP);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, Params } from '@angular/router';\n\nimport { UrlService } from '../services/url.service';\nimport { ConfigurationService } from '../services/configuration.service';\nimport { BUILDING_PROJECT_PATHS } from '../modules/building-projects/building-projcts-route-paths';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ConfigurationResolverService {\n readonly ROUTE_PARAMETER_CONFIGURATION_ID_KEY = 'configurationId';\n\n constructor(private urlService: UrlService, private configurationService: ConfigurationService) {}\n\n async resolve(route: ActivatedRouteSnapshot) {\n const queryParameters = route.queryParams;\n\n /*\n TODO: Consider the following:\n For now, configurationId as Route Parameter is handled in app.component.ts and removed from the URL afterwards.\n Thus, it cannot be read in this resolver anymore. The logic in app.component should be reconsidered, so this resolver can handle it.\n */\n if (this.doesUrlContainIdAsRouteParameter()) {\n const id = this.getConfigurationIdFromRouteParameter();\n await this.setConfigurationByCodeFromRouteParameter(id);\n } else if (this.doesUrlContainIdAsQueryParameter(queryParameters)) {\n const accessCode = this.getAccessCodeFromQueryParams(queryParameters);\n await this.setConfigurationByAccessCode(accessCode);\n } else {\n try {\n await this.configurationService.initializeBaseConfiguration();\n } catch (error) {\n console.warn('Error while fetching base configuration', error);\n }\n }\n }\n\n private doesUrlContainIdAsRouteParameter(): boolean {\n return this.urlService.urlContains(this.ROUTE_PARAMETER_CONFIGURATION_ID_KEY);\n }\n\n private doesUrlContainIdAsQueryParameter(queryParameters: Params): boolean {\n return !!queryParameters[BUILDING_PROJECT_PATHS.projectNumberParameter];\n }\n\n private getAccessCodeFromQueryParams(queryParameters: Params): string {\n return queryParameters[BUILDING_PROJECT_PATHS.projectNumberParameter];\n }\n\n private getConfigurationIdFromRouteParameter(): string {\n return this.urlService.getRouteParameterValue('configurationId');\n }\n\n private async setConfigurationByCodeFromRouteParameter(id: string) {\n await this.configurationService.updateConfigurationById(id);\n }\n\n private async setConfigurationByAccessCode(accessCode: string) {\n await this.configurationService.setConfigurationByAccessCode(accessCode);\n }\n}\n","export const APP_PATHS = {\n assetCatalog: 'produkt-katalog',\n onboardingScreen: 'onboarding-screen',\n assetCatalogOnly: 'produkt-katalog-only',\n assetManagement: 'produkt-management',\n category: '/kategorie',\n buildingProjects: 'bauvorhaben',\n service: 'service',\n floorPlans: 'grundrisse',\n projects: 'projects',\n login: 'login',\n manufacturers: 'hersteller',\n register: 'register',\n reset: 'reset',\n // TODO: consider moving parameter to a child route\n confirmation: 'confirmation/:token',\n appLink: 'app-link',\n download: 'download',\n visualUnits: 'visual-units',\n visualization: 'visualization',\n webProtocol: 'web-protocol',\n};\n\n/*\nTODO: Add the paths of the routed modules here in further constants\nin order to manage them centrally here\n*/\n","import { Injectable } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { AuthService } from './services/auth.service';\n\n@Injectable()\nexport class SalesGuard {\n constructor(private authService: AuthService, private router: Router) {}\n\n async canActivate(): Promise {\n if (!this.authService.getCurrentUser().sales) {\n return true;\n }\n\n await this.router.navigateByUrl(window.location.pathname);\n return false;\n }\n}\n","import { HttpClient, HttpParams } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { environment } from '../../environments/environment';\nimport { AssetSearchResult } from \"../modules/asset-catalog/models/asset-search-result\";\n\n// TODO: Refactor, reconsider hard coded handling in frontend -> Endpoint needed?\nexport enum ProductStatus {\n NOT_SET = 'Nicht gesetzt',\n REQUIREMENTS_OPEN = 'Anforderungen offen',\n DATA_MISSING = '3D-Daten fehlen',\n DATA_PRESENT = '3D-Daten liegen vor',\n DATA_PREPARED = '3D-Daten aufbereitet',\n VISUALIZATION_READY = 'In 3D bemusterbar',\n}\n\nexport type ProductStatusKey = keyof typeof ProductStatus;\n\nexport interface ProductStatusObject {\n key: ProductStatusKey;\n value: string;\n}\n\nexport const PRODUCT_STATUS_LIST_OBJECT: ProductStatusObject[] = Object.entries(ProductStatus).map(([key, value]) => ({\n key: key as ProductStatusKey,\n value,\n}));\n\nconst ASSETS_PATH = '/assets/';\nconst ASSETS_SEARCH_PATH = ASSETS_PATH + 'search';\n\n@Injectable()\nexport class AssetService {\n constructor(private http: HttpClient) {}\n\n insertAsset(body: any): Observable {\n return this.http.post(environment.apiUrl + ASSETS_PATH, body);\n }\n\n updateAsset(assetId: string, body: any): Observable {\n return this.http.put(environment.apiUrl + ASSETS_PATH + assetId, body);\n }\n\n setIsPublished(assetId: string, isPublished: any): Observable {\n return this.http.post(\n environment.apiUrl + ASSETS_PATH + assetId + '/published/' + isPublished,\n {}\n );\n }\n\n deleteAssetById(assetId: string, forceDelete = true): Observable {\n if (forceDelete) {\n return this.http.delete(environment.apiUrl + ASSETS_PATH + assetId + '?option=force');\n }\n return this.http.delete(environment.apiUrl + ASSETS_PATH + assetId);\n }\n\n fetchAssetsById(assetId: string): Observable {\n return this.http.get(environment.apiUrl + ASSETS_PATH + assetId + '?thumbnail=true');\n }\n\n fetchAssetsByParameters(searchParams: HttpParams): Observable {\n return this.http.get(environment.apiUrl + ASSETS_SEARCH_PATH, { params: searchParams });\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { firstValueFrom, Observable } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\nimport { environment } from '../../environments/environment';\nimport { User } from '../business-domain/User';\nimport { Token } from './token.interface';\nimport { TokenService } from './token.service';\nimport { ServiceCacheService } from './service-cache.service';\n\nexport interface LoginData {\n email: string;\n password: string;\n}\n\n// DAI: LoginResponse should be adapted from BackEnd to match Token in FrontEnd\nexport interface LoginResponse {\n token: string;\n tokenExpiry: number;\n}\n\ninterface RegistrationData {\n company: string;\n username: string;\n email: string;\n password: string;\n industry: string;\n city: string;\n zipcode: string;\n street: string;\n houseNumber: string;\n firstName: string;\n lastName: string;\n}\n\nexport class ErrorType {\n static NO_CONNECTION = new ErrorType('No Connection to server');\n static DUPLICATE_USER = new ErrorType('User exists already');\n constructor(readonly message: string) {}\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n private user: User;\n\n constructor(\n private http: HttpClient,\n private tokenService: TokenService,\n private serviceCacheService: ServiceCacheService\n ) {\n this.user = null;\n }\n\n isAuthenticated(): boolean {\n return this.tokenService.hasValidToken();\n }\n\n logout() {\n this.tokenService.deleteToken();\n this.serviceCacheService.clearCache();\n }\n\n async login(data: LoginData) {\n this.deleteToken(); // TODO: consider removing\n\n const token = await this.doLoginRequest(data);\n this.cacheToken(token);\n await this.initializeUser();\n }\n\n register(data: RegistrationData): Observable {\n return this.http.post(environment.apiUrl + environment.usersEndpoint, data).pipe(\n catchError((error) => {\n if (error.error.message === 'DUPLICATE_USER') throw ErrorType.DUPLICATE_USER;\n throw ErrorType.NO_CONNECTION;\n })\n );\n }\n\n getCurrentUser(): User {\n return this.user;\n }\n\n isValidCode(code: string): Observable {\n return this.http\n .post(environment.apiUrl + '/sessions/validate', { code })\n .pipe(map((result) => !!result.token));\n }\n\n requestPasswordReset(email: string): Observable {\n return this.http.post(environment.apiUrl + environment.usersEndpoint + '/requestReset', {\n email,\n });\n }\n\n getEmailForResetToken(token: string): Observable<{ email: string }> {\n return this.http.get<{ email: string }>(\n environment.apiUrl + environment.usersEndpoint + `/reset/${token}`\n );\n }\n\n resetPassword(token: string, password: string): Observable {\n return this.http.post(environment.apiUrl + environment.usersEndpoint + '/reset', {\n token,\n password,\n });\n }\n\n confirm(token: string): Observable {\n return this.http.post(environment.apiUrl + environment.usersEndpoint + '/confirmation', {\n token,\n });\n }\n\n async initializeUser() {\n this.user = await this.fetchUser();\n }\n\n hasFeatureFlag(feature: string): boolean {\n return this.user.featureFlags.includes(feature);\n }\n\n hasUserGroup(userGroups: string[]): boolean {\n return userGroups.filter((v) => this.user.groups.includes(v)).length > 0;\n }\n\n private async doLoginRequest(data: LoginData): Promise {\n return await firstValueFrom(\n this.http.post(environment.apiUrl + environment.sessionsEndpoint, data)\n );\n }\n\n private createToken(result: LoginResponse): Token {\n return {\n value: result.token,\n expiry: String(result.tokenExpiry),\n };\n }\n\n private cacheToken(token: LoginResponse) {\n this.tokenService.setToken(this.createToken(token));\n }\n\n private deleteToken() {\n this.tokenService.deleteToken();\n }\n\n private async fetchUser(): Promise {\n return firstValueFrom(this.http.get(environment.apiUrl + environment.usersEndpoint));\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { environment } from '../../environments/environment';\n\nconst FINGERHAUS_PROJECTS_PATH = '/fhProjects';\n\nexport interface BaseProject {\n clientAppointmentDate: string;\n clientUserId: string;\n consultantEmail: string;\n consultantFirstName: string;\n consultantLastName: string;\n consultantUserId: string;\n contractSignDate: string;\n lockEmailSent: number;\n}\n\nexport interface BuildingProject extends BaseProject {\n customers: CustomerInfo[];\n number: string;\n location: string;\n status: ProjectStatus;\n}\n\nexport enum ProjectStatus {\n NOT_STARTED = 'Unbearbeitet',\n IN_PROGRESS = 'In Bearbeitung',\n FROZEN = 'Merkliste gesperrt',\n FINISHED = 'Abgeschlossen',\n}\n\nexport interface FingerhausProject extends BaseProject {\n bvhData: BuildingProjectData;\n bvhNumber: string;\n status: string;\n}\n\nexport interface BuildingProjectData {\n location: string;\n customers: CustomerInfo[];\n}\n\nexport interface CustomerInfo {\n title: string;\n firstName: string;\n lastName: string;\n street: string;\n isocode: string;\n zipcode: number;\n city: string;\n phone: string;\n email: string;\n}\n\nexport interface BuildingProjectResponse {\n fhProjects: FingerhausProject[];\n pageCount: number;\n}\n\n@Injectable()\nexport class BuildingProjectService {\n constructor(private readonly http: HttpClient) {}\n\n async getAllFingerhausBuildingProjects(): Promise {\n const response: BuildingProjectResponse = await this.http\n .get(environment.apiUrl + FINGERHAUS_PROJECTS_PATH)\n .toPromise();\n\n return response.fhProjects.map((project) => ({\n ...project,\n location: project.bvhData?.location,\n customers: project.bvhData?.customers,\n number: project.bvhNumber,\n status: ProjectStatus[project.status],\n }));\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { Building } from '../business-domain/Building';\nimport { environment } from '../../environments/environment';\n\ninterface Response {\n data: T;\n}\n\n@Injectable()\nexport class BuildingService {\n constructor(private http: HttpClient) {}\n\n public getBuildingsByUnit(buildingId: string): Observable {\n return this.http\n .get>(environment.apiUrl + `/units/${buildingId}/buildings`)\n .pipe(map((response) => response.data)) as Observable;\n }\n}\n","import { BehaviorSubject, firstValueFrom, Observable } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\nimport { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { environment } from '../../environments/environment';\nimport { ErrorDialogService } from './errordialog.service';\nimport { UrlService } from './url.service';\nimport { BuildingProjectData, CustomerInfo, ProjectStatus } from './building-project.service';\nimport { Product } from '../business-domain/product.interface';\n\nexport interface BaseConfiguration {\n name: string;\n id: string;\n bvhNumber: string;\n userId: string;\n consultantUserId: string;\n levelId: string;\n levelName: string;\n accessCode: string;\n note: string;\n createdAt: string;\n updatedAt: string;\n contractSignDate: string;\n lockEmailSent: any;\n consultantData: any;\n customerData: any;\n isLocked: number; // TODO Improvement: 0 and 1 - should come as a boolean from the Backend\n isStyle: number; // TODO Improvement: 0 and 1 - should come as a boolean from the Backend\n clientAppointmentDate: string;\n status: string;\n actors: any;\n actorSlots: any;\n projectStage: 'RELEASE' | 'BETA' | undefined;\n}\n\nexport interface Configuration extends BaseConfiguration {\n location: string;\n customers: CustomerInfo[];\n status: ProjectStatus;\n}\n\nexport interface ConfigurationResponse extends BaseConfiguration {\n bvhData: BuildingProjectData;\n}\n\ninterface ProductResponse {\n data: Product[];\n}\n\nexport const ROUTE_PARAMETER_CONFIGURATION_ID_KEY = 'configurationId';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ConfigurationService {\n readonly configuration$: Observable;\n private readonly configurationSubject: BehaviorSubject;\n\n constructor(\n private http: HttpClient,\n private errorDialogService: ErrorDialogService,\n private urlService: UrlService\n ) {\n this.configurationSubject = new BehaviorSubject(null);\n this.configuration$ = this.configurationSubject\n .asObservable()\n .pipe(filter((configuration) => !!configuration));\n }\n\n async initialize() {\n this.urlContainsId() ? await this.updateConfigurationByUrl() : await this.initializeBaseConfiguration();\n }\n\n async updateConfigurationById(id: string): Promise {\n const configuration = await this.getConfigurationByIdOrAccessCode(id)\n this.setConfiguration(configuration);\n return configuration;\n }\n\n async setConfigurationByAccessCode(accessCode: string): Promise {\n const configuration = await this.getConfigurationByCode(accessCode)\n this.setConfiguration(configuration);\n return configuration;\n }\n\n async updateConfigurationByUrl() {\n const id = this.getConfigurationByUrl();\n await this.updateConfigurationById(id);\n }\n\n updateConfiguration(configurationId: string, data: any) {\n this.http\n .put(environment.apiUrl + '/configurations/' + configurationId, {\n ...data,\n })\n .subscribe(\n () => {},\n (error) => {\n console.log('Error: ', error);\n console.log('updateConfiguration Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'configurations.service - updateConfiguration',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Speichern der Protokoll-Daten. Bitte laden Sie die Seite neu und versuchen es erneut.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n }\n );\n }\n\n async initializeBaseConfiguration() {\n const configuration = await this.fetchConfiguration();\n this.setConfiguration(configuration);\n }\n\n // load actor and actorSlot data for the configuration including the asset details\n loadConfigurationDetails(): Observable {\n return this.http\n .get(\n environment.apiUrl + '/configurations/' + this.configuration.id + '/load?includeAssets=true'\n )\n .pipe(map((res: any) => res.data));\n }\n\n getExcelExportForConfigurationId(configurationId: string) {\n this.http\n .get(environment.apiUrl + `/configurations/` + configurationId + '/excelExport', {\n responseType: 'blob',\n })\n .subscribe(\n (data) => {\n console.log('getExcelExportForConfigurationId Success: ', data);\n let url = window.URL.createObjectURL(data);\n let a = document.createElement('a');\n document.body.appendChild(a);\n a.setAttribute('style', 'display: none');\n a.href = url;\n a.download = 'protokoll-export.xlsx';\n a.click();\n window.URL.revokeObjectURL(url);\n a.remove();\n },\n (error) => {\n console.log('Error: ', error);\n console.log('getExcelExportForConfigurationId Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'configurations.service - getExcelExportForConfigurationId',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Herunterladen der Excel Datei. Bitte laden Sie die Seite neu und versuchen es erneut.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n }\n );\n }\n\n async createPreselectionForConfiguration(assetId: string): Promise {\n const url = environment.apiUrl + '/configurations/' + this.configuration.id + '/preselections';\n const body = { assetId: assetId };\n const result = (await this.http.post(url, body).toPromise()) as any;\n return result.id;\n }\n\n deletePreselectionById(preselectionId: string): Observable {\n console.log('ConfigurationService deletePreselectionById(): ', preselectionId);\n\n return this.http.delete(environment.apiUrl + '/preselections/' + preselectionId, {});\n }\n\n deletePreselectionsForSchemaAndConfiguration(schemaId): Observable {\n return this.http.delete(\n environment.apiUrl +\n '/schemas/' +\n schemaId +\n '/configurations/' +\n this.configuration.id +\n '/preselections/',\n {}\n );\n }\n\n async getFavorites(): Promise {\n return (await firstValueFrom(this.fetchFavorites())).data;\n }\n\n private fetchFavorites(): Observable {\n return this.http.get(\n `${environment.apiUrl}/configurations/${this.configuration.id}/preselections`\n );\n }\n\n async updatePreselectionNote(preselectionId: string, note: string) {\n return this.http\n .put(environment.apiUrl + '/preselections/' + preselectionId, { note: note })\n .toPromise()\n .catch((error) => {\n console.error(error.message);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'configurations.service - updatePreselectionNote',\n devinfo: error.message,\n publicinfo: 'Beim Speichern der Notiz ist ein Fehler aufgetreten.',\n debug: false,\n autoFocus: false,\n });\n });\n }\n\n async updateActorNote(actorId: string, configurationId: string, note: string) {\n return this.http\n .put(\n environment.apiUrl +\n '/configurations/' +\n configurationId +\n '/actorObjectConfigurations/' +\n actorId,\n { note: note }\n )\n .toPromise()\n .catch((error) => {\n console.error(error.message);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'configurations.service - updateActorNote',\n devinfo: error.message,\n publicinfo: 'Beim Speichern der Notiz ist ein Fehler aufgetreten.',\n debug: false,\n autoFocus: false,\n });\n });\n }\n\n async updateActorSlotNote(actorSlotId: string, configurationId: string, note: string) {\n return this.http\n .put(\n environment.apiUrl +\n '/configurations/' +\n configurationId +\n '/actorSlotMaterialConfiguration/' +\n actorSlotId,\n { note: note }\n )\n .toPromise()\n .catch((error) => {\n console.error(error.message);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'configurations.service - updateActorSlotNote',\n devinfo: error.message,\n publicinfo: 'Beim Speichern der Notiz ist ein Fehler aufgetreten.',\n debug: false,\n autoFocus: false,\n });\n });\n }\n\n urlContainsId(): boolean {\n return this.urlService.urlContains(ROUTE_PARAMETER_CONFIGURATION_ID_KEY);\n }\n\n private getConfigurationByUrl(): string {\n return this.urlService.getRouteParameterValue(ROUTE_PARAMETER_CONFIGURATION_ID_KEY);\n }\n\n private mapConfigurationResponseToConfiguration(response: ConfigurationResponse): Configuration {\n return {\n ...response,\n location: response.bvhData?.location,\n customers: response.bvhData?.customers,\n status: ProjectStatus[response.status],\n };\n }\n\n private get configuration(): Configuration {\n return this.configurationSubject.getValue();\n }\n\n private async getConfigurationByIdOrAccessCode(idOrAccessCode): Promise {\n const response = await firstValueFrom(\n this.http.get(environment.apiUrl + '/configurations/' + idOrAccessCode)\n\n );\n return this.mapConfigurationResponseToConfiguration(response);\n }\n\n private async getConfigurationByCode(code): Promise {\n const response = await firstValueFrom(\n this.http.get(environment.apiUrl + '/configurations/configurationCode/' + code)\n\n );\n return this.mapConfigurationResponseToConfiguration(response);\n }\n\n private setConfiguration(configuration: Configuration) {\n this.configurationSubject.next(configuration);\n }\n\n private async fetchConfiguration(): Promise {\n const response = await firstValueFrom(\n this.http.get(environment.apiUrl + '/users/configuration')\n );\n return this.mapConfigurationResponseToConfiguration(response);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { DatePipe } from '@angular/common';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class DateService {\n\n constructor(private datePipe: DatePipe) { }\n\n formatToGermanDateAndTime(dateString: string): string {\n const date = new Date(dateString)\n return this.datePipe.transform(date, \"dd.MM.yyyy, HH:mm 'Uhr'\");\n }\n\n formatToGermanDate(dateString: string): string {\n const date = new Date(dateString)\n return this.datePipe.transform(date, 'dd.MM.yyyy');\n }\n}\n","import { Injectable } from '@angular/core';\nimport { environment } from '../../environments/environment';\n\nenum CustomerSystem {\n FINGERHAUS = 'fingerhaus',\n PORTER = 'porter',\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class EnvironmentService {\n constructor() {}\n\n isFingerhaus(): boolean {\n return environment.customerSystem === CustomerSystem.FINGERHAUS;\n }\n\n isPorter(): boolean {\n return environment.customerSystem === CustomerSystem.PORTER;\n }\n}\n","\n
\n

\n

\n Fehlercode: {{ data.errorCode }}\n

\n

\n Debuginfo:\n {{ data.location }}:
\n {{ data.devinfo }}\n

\n
\n
\n \n
\n
","import { Component, Inject, SecurityContext } from '@angular/core';\nimport { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { ModalConfiguration } from '../../modal/modal.component';\n\nconst MODAL_CONFIGURATION: ModalConfiguration = {\n showBackdrop: true,\n heading: 'Es ist ein Fehler aufgetreten',\n size: 'S',\n width: '400px',\n height: 'auto',\n icon: 'warning',\n};\n\n@Component({\n selector: 'error-dialog',\n templateUrl: './errordialog.component.html',\n standalone: false\n})\nexport class ErrorDialogComponent {\n modalConfiguration: ModalConfiguration;\n\n constructor(\n private dialogRef: MatDialogRef,\n @Inject(MAT_DIALOG_DATA) public data: any,\n private domSanitizer: DomSanitizer\n ) {\n this.initializeModalConfiguration();\n }\n\n getSanitizedPublicInfo() {\n return this.domSanitizer.sanitize(SecurityContext.HTML, this.data.publicinfo);\n }\n\n close() {\n this.dialogRef.close();\n }\n\n private initializeModalConfiguration() {\n this.modalConfiguration = MODAL_CONFIGURATION;\n }\n}","import { Injectable } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\nimport { MatDialog } from '@angular/material/dialog';\nimport { ErrorDialogComponent } from '../components/dialogs/errordialog/errordialog.component';\n\n@Injectable()\nexport class ErrorDialogService {\n isDialogOpen: boolean;\n isErrorDialogOpenSubject: BehaviorSubject;\n constructor(private dialog: MatDialog) {\n this.initialize();\n }\n openDialog(data) {\n if (!this.isDialogOpen) {\n this.isDialogOpen = true;\n this.isErrorDialogOpenSubject.next(true);\n const dialogRef = this.dialog.open(ErrorDialogComponent, {\n data: data,\n autoFocus: false,\n });\n\n dialogRef.afterClosed().subscribe(() => {\n this.isDialogOpen = false;\n this.isErrorDialogOpenSubject.next(false);\n });\n }\n }\n\n private initialize() {\n this.isDialogOpen = false;\n this.isErrorDialogOpenSubject = new BehaviorSubject(false);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { TokenService } from './token.service';\n\ndeclare var sketchup: any;\ndeclare var revit: any;\n\n@Injectable()\nexport class ExporterPluginService {\n constructor() {}\n usesExportPlugin = typeof sketchup == 'object' || typeof revit == 'object';\n\n closePlugin() {\n if (this.usesExportPlugin) {\n try {\n if (typeof sketchup == 'object') sketchup.close();\n if (typeof revit == 'object') revit.sendTextToRevit('close');\n } catch (e) {\n console.log(e);\n }\n }\n }\n\n startUploadPlugin(tokenService: TokenService, unitId: string) {\n if (this.usesExportPlugin) {\n try {\n const tokenValue = tokenService.getToken().value;\n\n if (typeof sketchup == 'object')\n sketchup.upload_zip_action({ token: tokenValue, unitID: unitId });\n if (typeof revit == 'object')\n //use sendMessage to Revit witch one combined String, use \",\" to split strings.\n revit.sendTextToRevit('startUpload,' + tokenValue + ',' + unitId);\n return { uploadStarted: true, uploadError: false };\n } catch (e) {\n console.log(e);\n return { uploadStarted: false, uploadError: true };\n }\n }\n }\n \n usesExport(): boolean {\n return this.usesExportPlugin;\n }\n}\n","import { Injectable } from '@angular/core';\nimport { BehaviorSubject, firstValueFrom, Observable } from 'rxjs';\nimport { first } from 'rxjs/operators';\nimport { Product } from '../../business-domain/product.interface';\nimport { ConfigurationService } from '../configuration.service';\nimport { ErrorDialogService } from '../errordialog.service';\nimport { LevelService } from '../level.service';\nimport { ProductSchemaId, SchemasService } from '../schemas.service';\nimport { UnrealService } from '../unreal.service';\n\nexport enum FavoriteStatus {\n DESELECTED,\n SELECTED,\n HOVER,\n ROOM_SELECTED,\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class FavoritesService {\n private allFavorites$: BehaviorSubject = new BehaviorSubject([]);\n\n constructor(\n private levelService: LevelService,\n private configurationService: ConfigurationService,\n private schemasService: SchemasService,\n private errorDialogService: ErrorDialogService,\n private unrealService: UnrealService\n ) {}\n\n private get allFavorites(): Product[] {\n return this.allFavorites$.getValue();\n }\n\n getAllFavorites(): Observable {\n return this.allFavorites$.asObservable();\n }\n\n private findFavoriteIndex(id: string): number {\n return this.allFavorites.findIndex((favorite) => favorite.assetId === id);\n }\n\n // TODO: Can we not only use one find method?\n private findFavoriteByAssetId(assetId: string) {\n return this.allFavorites.find((favorite) => favorite.assetId === assetId);\n }\n\n // TODO: Can we not only use one find method?\n private findFavoriteById(id: string) {\n return this.allFavorites.find((favorite) => favorite.id === id);\n }\n\n private hasFavoriteCached(product: any) {\n return this.findFavoriteByAssetId(product.assetId);\n }\n\n async initialize() {\n const allFavorites = await this.configurationService.getFavorites();\n this.allFavorites$.next(allFavorites);\n }\n\n updateRoomIdsOnFavorite(id: string, roomIds: string[]) {\n const favorite = this.findFavoriteById(id);\n if (favorite) favorite.roomIds = roomIds;\n this.allFavorites$.next(this.allFavorites);\n }\n\n async add(product: any): Promise {\n if (!this.allFavorites) this.throwInvalidFavoritesError();\n if (this.hasFavoriteCached(product)) {\n this.showAssetAlreadyAddedError();\n this.throwAssetAlreadyAddedError();\n }\n\n try {\n const preselectionId = await this.configurationService.createPreselectionForConfiguration(product.assetId);\n this.unrealService.emitFavoriteAdded(product.id, preselectionId);\n this.allFavorites$.next([...this.allFavorites, { ...product, id: preselectionId }]);\n return preselectionId;\n } catch (error) {\n this.showCreatePreselectionError();\n this.throwCreatePreselectionError();\n }\n }\n\n remove(product: Product, preselectionId: string) {\n const preselectionIdToDelete = preselectionId || undefined;\n if (!preselectionIdToDelete) {\n return;\n }\n\n this.configurationService\n .deletePreselectionById(preselectionIdToDelete)\n .pipe(first())\n .subscribe(\n () => {\n this.unrealService.emitFavoriteDeleted(preselectionIdToDelete);\n this.removeFromCached(product);\n },\n (error) => {\n console.error(error.message);\n }\n );\n }\n\n removeFromProtocol(favorite: any) {\n console.log('removeFavoriteFromProtocol: ', favorite);\n\n let deletionId = favorite.id;\n /* If asset was chosen as favorite in session, its id as a favorite gets\n set as preselectionId, while loaded favorites already come with an id */\n if (favorite.preselectionId) {\n deletionId = favorite.preselectionId;\n }\n\n this.configurationService.deletePreselectionById(deletionId).subscribe(\n () => {\n this.unrealService.emitFavoriteDeleted(favorite.id);\n },\n (error) => {\n console.error(error.message);\n }\n );\n }\n\n async removeByCategory(schemaId: string): Promise {\n try {\n await firstValueFrom(this.configurationService.deletePreselectionsForSchemaAndConfiguration(schemaId));\n const ids = this.schemasService.getAllChildCategoryIds(schemaId);\n ids.push(schemaId);\n this.allFavorites$.next(this.filterFavoritesByCategories(ids));\n this.unrealService.emitFavoritesDeletedBySchema(schemaId);\n } catch (error) {\n console.error(error.message);\n }\n }\n\n filterFavoritesByCategories(ids: ProductSchemaId[]) {\n return this.allFavorites.filter((favorite) => {\n return !ids.some((id) => id === favorite.productSchemaId);\n });\n }\n\n removeAll() {\n const favoriteIds = [];\n this.allFavorites.forEach((favorite) => {\n //if asset was added to favorites in frontend\n if (favorite.preselectionId) favoriteIds.push(favorite.preselectionId);\n //if favorite already came from get favorites\n else favoriteIds.push(favorite.id);\n });\n this.levelService.deletePreselections(favoriteIds).subscribe(\n () => {\n this.allFavorites$.next([]);\n console.log('removed all favorites');\n },\n (error) => {\n console.error(error.message);\n }\n );\n }\n\n private removeFromCached(favorite: Product) {\n const index = this.findFavoriteIndex(favorite.assetId);\n const updatedFavorites = [...this.allFavorites];\n updatedFavorites.splice(index, 1);\n this.allFavorites$.next(updatedFavorites);\n }\n\n // ===================================================================================================================\n // ERROR HANDLING\n // ===================================================================================================================\n private showAssetAlreadyAddedError() {\n this.errorDialogService.openDialog({\n errorCode: '4Exxxx',\n location: 'FavoritesService',\n devinfo: 'Tried to add asset that already exists in favorites',\n publicinfo:\n 'Das Hinzufügen des Produktes in die Merkliste ist fehlgeschlagen. Es existiert bereits in der Merkliste.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n }\n\n private showCreatePreselectionError() {\n this.errorDialogService.openDialog({\n errorCode: '4Exxxx',\n location: 'FavoritesService',\n devinfo: 'Error in createPreselectionForConfiguration()',\n publicinfo:\n 'Das Hinzufügen des Produktes in die Merkliste ist fehlgeschlagen.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n }\n\n private throwInvalidFavoritesError() {\n throw new Error('Can not add Asset. Favorites are not defined. Configuration/BVN is maybe not initialized.');\n }\n\n private throwCreatePreselectionError() {\n throw new Error('Error when tyring to add asset to preselections');\n }\n\n private throwAssetAlreadyAddedError() {\n throw new Error('Tried to add asset that already exists in favorites');\n }\n\n // ===================================================================================================================\n // PRODUCT NOTE\n // ===================================================================================================================\n async getProductNote(preselectionId: string): Promise {\n const favorites = await this.configurationService.getFavorites();\n const favorite = favorites.find((f) => f.id === preselectionId);\n return favorite?.note;\n }\n\n async setProductNote(preselectionId: string, note: string) {\n await this.configurationService.updatePreselectionNote(preselectionId, note);\n this.allFavorites.find((favorite) => favorite.id === preselectionId).note = note;\n }\n}\n","import { HttpParams } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { BehaviorSubject, merge, Observable, of, Subject, Subscription } from 'rxjs';\nimport { filter, map, switchMap, take, takeUntil } from 'rxjs/operators';\nimport { AssetSearchResult } from '../modules/asset-catalog/models/asset-search-result';\nimport { ReadyNumberService } from '../modules/asset-catalog/services/ready-number.service';\nimport { APP_PATHS } from '../route-paths';\nimport { AssetService } from './asset.service';\nimport { CategoryPath, SchemasService } from './schemas.service';\nimport { ServiceCacheService } from './service-cache.service';\n\n////////////////// MOVE TO PROXY //////////////////////\nconst NO_RESULT_FOUND: AssetSearchResult = {\n info: {\n icon: 'error',\n iconColor: '', // no color for gray icon\n title: 'Keine Ergebnisse',\n text: 'Bitte überprüfen Sie Ihre Eingabe und
versuchen Sie es erneut.',\n },\n pageCount: 0,\n};\n\nconst SEARCH_TERM_TOO_SHORT: AssetSearchResult = {\n info: {\n icon: 'error',\n iconColor: '', // no color for gray icon\n title: 'Die Suche erfordert mindestens drei Zeichen',\n text: 'Bitte überprüfen Sie Ihre Eingabe und
versuchen Sie es erneut.',\n },\n pageCount: 0,\n};\n\nconst SEARCH_RESULT_PENDING: AssetSearchResult = {\n info: { pending: true },\n};\n////////////////// MOVE TO PROXY //////////////////////\n\ntype OrderBy = 'price';\ntype Order = 'ASC' | 'DESC';\n\n/*\nFor now simply called PropertyFilters to indicate that these fields concern object properties that every asset has\nin contrast to the resultSubsetParameters which is not related to any kind of asset object property and also to differentiate from\nthose PropertyFilters specific to certain schemas.\n*/\nexport interface PropertyFilters {\n schemaId?: string;\n searchTerm?: string;\n productStatus?: string;\n manufacturersId?: string;\n livingStyle?: string;\n priceGroup?: string;\n orderBy?: OrderBy;\n order?: Order;\n}\n\nexport interface ResultSubsetParameters {\n page?: number;\n limit?: number; // means the number of requested assets per page\n}\n\ntype PropertyFilterKeys = keyof PropertyFilters;\n\nconst SEARCH_TERM_PARAMETER = 'q';\nconst SCHEMA_ID_PARAMETER = 'productSchema';\nconst PRODUCT_STATUS_PARAMETER = 'status';\nconst LIVING_STYLE_PARAMETER = 'livingStyle';\nconst MANUFACTURER_ID_PARAMETER = 'manufacturersId';\nconst PRICE_GROUP_PARAMETER = 'priceGroup';\nconst ORDER_BY_PARAMETER = 'orderBy';\nconst ORDER_PARAMETER = 'order';\n\nconst MIN_SEARCH_TERM_LENGTH = 3;\nconst DEFAULT_NUMBER_OF_ASSETS = 36;\nconst DEFAULT_PAGE = 1;\n\nconst LIVING_STYLE_STORAGE_KEY = 'livingStyle';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class FilteredArticlesService {\n private readonly filteredArticlesSubject: BehaviorSubject;\n private readonly propertyFiltersSubject: BehaviorSubject;\n private readonly resultSubsetParametersSubject: BehaviorSubject;\n private readonly searchParams: BehaviorSubject;\n private readonly pendingRequestCancellation: Subject;\n\n readonly propertyFilters$: Observable;\n readonly resultSubsetParameters$: Observable;\n\n private configurationId: string;\n private searchBlocked: boolean;\n private searchParamsSubscription: Subscription;\n private pageFilterResetSubscription: Subscription;\n\n constructor(\n public router: Router,\n private readonly readyNumberService: ReadyNumberService,\n private readonly assetService: AssetService,\n private readonly schemasService: SchemasService,\n private readonly serviceCacheService: ServiceCacheService\n ) {\n this.serviceCacheService.registerCacheClearer(() => this.clear());\n this.filteredArticlesSubject = new BehaviorSubject(null);\n this.propertyFiltersSubject = this.initializePropertyFiltersSubject();\n this.resultSubsetParametersSubject = this.initializeResultSubsetParametersSubject();\n this.searchParams = new BehaviorSubject(null);\n\n this.propertyFilters$ = this.propertyFiltersSubject.asObservable();\n this.resultSubsetParameters$ = this.resultSubsetParametersSubject.asObservable();\n\n this.pendingRequestCancellation = new Subject();\n this.searchBlocked = false;\n }\n\n setSearchParams() {\n if (!this.searchBlocked) {\n let params = new HttpParams();\n\n const pageZeroBased = (+this.resultSubsetParameters.page - 1).toString(); // reset to 0-based counting for request\n params = params.append('page', pageZeroBased);\n params = params.append('limit', this.resultSubsetParameters.limit);\n\n const filterParams: { [key: string]: string | undefined } = {\n configurationId: this.configurationId,\n [SCHEMA_ID_PARAMETER]: this.propertyFilters.schemaId,\n [LIVING_STYLE_PARAMETER]: this.propertyFilters.livingStyle,\n [PRODUCT_STATUS_PARAMETER]: this.propertyFilters.productStatus,\n [SEARCH_TERM_PARAMETER]: this.propertyFilters.searchTerm,\n [MANUFACTURER_ID_PARAMETER]: this.propertyFilters.manufacturersId,\n [PRICE_GROUP_PARAMETER]: this.propertyFilters.priceGroup,\n [ORDER_BY_PARAMETER]: this.propertyFilters.orderBy,\n [ORDER_PARAMETER]: this.propertyFilters.order,\n };\n\n Object.entries(filterParams).forEach(([key, value]) => {\n if (value) {\n params = params.append(key, value);\n }\n });\n\n this.searchParams.next(params);\n } else {\n this.filteredArticlesSubject.next({ data: [] });\n }\n }\n\n getFilteredArticles(): Observable {\n return this.filteredArticlesSubject\n .asObservable()\n .pipe(filter((result: AssetSearchResult) => !!result));\n }\n\n getPropertyFilters(): Promise {\n return this.propertyFiltersSubject.asObservable().pipe(take(1)).toPromise();\n }\n\n removeFavoriteStatusFromAllAssets() {\n if (this.filteredArticlesSubject.getValue().data.length) {\n let filteredArticlesUpdated = { data: [] };\n this.filteredArticlesSubject.getValue().data.forEach((asset) => {\n asset.isFavorite = false;\n\n /*\n Important: create a deep copy of asset in order to allow change detection to trigger.\n As a result, article cards detect a change of the value of @input article.\n */\n filteredArticlesUpdated.data.push({ ...asset });\n });\n this.filteredArticlesSubject.next(filteredArticlesUpdated);\n }\n }\n\n clearConfigurationId() {\n this.configurationId = '';\n }\n\n async updateConfigurationId(id: string) {\n this.configurationId = id || undefined;\n }\n\n isSearchTermLengthValid(term: string): boolean {\n return term?.length >= MIN_SEARCH_TERM_LENGTH;\n }\n\n isValidPageParameter(value: any): boolean {\n return this.isAPositiveInteger(value);\n }\n\n handleSearchTermsOfInsufficientLength(term: string) {\n this.cancelPendingRequests();\n this.setSearchTermFilter(term);\n this.broadcastSearchTermTooShort();\n }\n\n hasAsset(id: string): boolean {\n return this.filteredArticles.data?.some((asset) => asset.id === id);\n }\n\n hasOnlyOneArticle(): boolean {\n return this.filteredArticles.data?.length === 1;\n }\n\n isOnPageOne(): boolean {\n return this.resultSubsetParameters.page === 1;\n }\n\n setPageToPrecedingPage() {\n this.setPageFilter(this.resultSubsetParameters.page - 1);\n }\n\n private sendSearchRequest(parameters: HttpParams): Observable {\n const searchTerm = this.getSearchTerm(parameters);\n return this.canSearchSimple(searchTerm)\n ? this.fetchSimpleSearchResult(parameters)\n : this.fetchReadyNumberSearchResult(searchTerm);\n }\n\n private canSearchSimple(searchTerm: string): boolean {\n return !searchTerm || !this.isReadyNumberSearch(searchTerm);\n }\n\n private fetchReadyNumberSearchResult(searchTerm: string): Observable {\n return this.readyNumberService.search(searchTerm);\n }\n\n private fetchSimpleSearchResult(searchParams: HttpParams): Observable {\n return this.fetchAssetsByParameters(searchParams).pipe(\n map((result: AssetSearchResult) => {\n if (result.data.length) return result;\n else return NO_RESULT_FOUND;\n })\n );\n }\n\n private getSearchTerm(parameters: HttpParams): string {\n return parameters.get(SEARCH_TERM_PARAMETER);\n }\n\n private initializeResultSubsetParametersSubject(): BehaviorSubject {\n return new BehaviorSubject({\n page: 1,\n limit: DEFAULT_NUMBER_OF_ASSETS,\n });\n }\n\n private initializePropertyFiltersSubject(): BehaviorSubject {\n /*\n TODO FH-1054: Maybe we should set all initial values to undefined instead null,\n so we can differentiate the states like \"Alle Hersteller\" from none being chosen?\n -> Such a check is needed here: asset-search-results -> shouldSchemaFilterBeSet\n */\n return new BehaviorSubject({\n schemaId: undefined,\n searchTerm: null,\n productStatus: null,\n manufacturersId: null,\n priceGroup: null,\n livingStyle: localStorage.getItem(LIVING_STYLE_STORAGE_KEY),\n orderBy: null,\n order: null,\n });\n }\n\n private get propertyFilters(): PropertyFilters {\n return this.propertyFiltersSubject.getValue();\n }\n\n private get resultSubsetParameters(): ResultSubsetParameters {\n return this.resultSubsetParametersSubject.getValue();\n }\n\n private get filteredArticles(): AssetSearchResult {\n return this.filteredArticlesSubject.getValue();\n }\n\n private fetchAssetsByParameters(searchParams: HttpParams): Observable {\n return this.assetService.fetchAssetsByParameters(searchParams);\n }\n\n private isReadyNumberSearch(searchTerm: string): boolean {\n return this.readyNumberService.isValid(searchTerm);\n }\n\n initializeSubscriptions() {\n // TODO FH-1054: connect setSearchParams by piping -> then no subscription should be necessary\n this.subscribeToSearchParams();\n this.initResetOfPageFilterOnRelevantChanges();\n }\n\n // TODO FH-1054: Is subscription obsolete? Should the logic simply be called at the end of setSearchParams?\n private subscribeToSearchParams() {\n /*\n acts as state of the latest search -> allows to ignore search results of requests\n that have been made obsolete by a new request/requests via piping through switchMap\n and thereby changing the observable which is subscribed\n */\n this.searchParamsSubscription = this.searchParams\n .pipe(\n filter((params) => !!params), // Get all valid filter/params\n switchMap((searchParams) => {\n const result = this.sendSearchRequest(searchParams);\n return merge(of(SEARCH_RESULT_PENDING).pipe(takeUntil(result)), result).pipe(\n takeUntil(this.pendingRequestCancellation)\n );\n })\n )\n .subscribe((result: AssetSearchResult) => {\n this.filteredArticlesSubject.next(result);\n });\n }\n\n //Logic for Dependencies - should this logic be part of this service or the overview-component / other service?\n private initResetOfPageFilterOnRelevantChanges() {\n this.pageFilterResetSubscription = this.propertyFilters$\n .pipe(\n map(() => this.resultSubsetParameters),\n filter((resultSubsetParameters) => {\n return resultSubsetParameters.page !== DEFAULT_PAGE;\n })\n )\n .subscribe(() => {\n this.setPageFilter(DEFAULT_PAGE);\n });\n }\n\n /////////////////////// BUSINESS LOGIC PROXY METHODS //////////////////////////\n private cancelPendingRequests() {\n this.pendingRequestCancellation.next();\n }\n\n private broadcastSearchTermTooShort() {\n this.filteredArticlesSubject.next(SEARCH_TERM_TOO_SHORT);\n }\n\n /*\n FH-1054: Place this into global utility service?\n */\n private isAPositiveInteger(value: number): boolean {\n return typeof value === 'number' && Number.isInteger(value) && value > 0;\n }\n\n private removeSubscriptions() {\n this.searchParamsSubscription?.unsubscribe();\n this.pageFilterResetSubscription?.unsubscribe();\n }\n\n private clear() {\n this.removeSubscriptions();\n this.clearAllPropertyFilters();\n }\n\n // TODO ============ Move to Filter-Class =================\n setFilter(filterName: PropertyFilterKeys, filterValue: string) {\n const currentFilters = this.propertyFilters;\n (currentFilters as any)[filterName] = filterValue;\n this.propertyFiltersSubject.next(currentFilters);\n }\n\n // TODO: Consider handling the case where the schemaId is not found\n async setSchemaFilter(path: CategoryPath) {\n const schemaId = this.schemasService.findSchemaId(path);\n this.setFilter('schemaId', schemaId);\n }\n\n // TODO FH-1054: Outsource business logic\n setSearchTermFilter(term: string) {\n term = term.trim();\n if (\n term.length >= MIN_SEARCH_TERM_LENGTH ||\n term.length === 0 || \n this.router.url.endsWith(APP_PATHS.assetCatalog)\n ) {\n this.searchBlocked = false;\n this.setFilter('searchTerm', term);\n } else if (term.length < MIN_SEARCH_TERM_LENGTH && !this.isReadyNumberSearch(term)) {\n this.searchBlocked = true;\n }\n }\n\n // Type is LivingStyle-Enum\n setLivingStyleFilter(value: string) {\n this.setFilter(LIVING_STYLE_PARAMETER, value);\n value != null\n ? localStorage.setItem(LIVING_STYLE_STORAGE_KEY, value)\n : localStorage.removeItem(LIVING_STYLE_STORAGE_KEY);\n }\n\n setProductStatusFilter(value: string) {\n this.setFilter('productStatus', value);\n }\n\n setManufacturerFilter(value: string) {\n this.setFilter(MANUFACTURER_ID_PARAMETER, value);\n }\n\n setPageFilter(page: number) {\n const currentFilters = this.resultSubsetParameters;\n currentFilters['page'] = page;\n this.resultSubsetParametersSubject.next(currentFilters);\n }\n\n setPriceGroupFilter(value: string) {\n this.setFilter(PRICE_GROUP_PARAMETER, value);\n }\n\n setSortingFilter(order: Order, orderBy: OrderBy) {\n this.setFilter(ORDER_BY_PARAMETER, orderBy || null);\n this.setFilter(ORDER_PARAMETER, order || null);\n }\n\n triggerSearch(text: string) {\n this.setSearchTermFilter(text);\n this.setSearchParams();\n }\n\n ////////////////// CLEARING PropertyFilters //////////////////\n clearAllPropertyFilters() {\n /*\n TODO: Consider replacing this with just the following:\n this.propertyFiltersSubject.next({});\n */\n this.propertyFiltersSubject.next({\n schemaId: null,\n searchTerm: null,\n productStatus: null,\n manufacturersId: null,\n livingStyle: null,\n priceGroup: null,\n orderBy: null,\n order: null,\n });\n }\n\n clearAllPropertyFiltersExcludingLivingStyle() {\n const { livingStyle } = this.propertyFilters;\n this.propertyFiltersSubject.next({\n schemaId: null,\n productStatus: null,\n manufacturersId: null,\n livingStyle,\n priceGroup: null,\n orderBy: null,\n order: null,\n searchTerm: null,\n });\n }\n\n clearAllPropertyFiltersExcludingSearchTerm() {\n const { searchTerm } = this.propertyFilters;\n this.propertyFiltersSubject.next({\n schemaId: null,\n productStatus: null,\n manufacturersId: null,\n livingStyle: null,\n priceGroup: null,\n orderBy: null,\n order: null,\n searchTerm,\n });\n }\n}\n","import { HttpClient, HttpEvent, HttpEventType, HttpRequest } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { MatDialogRef } from '@angular/material/dialog';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { STRING } from '../../../e2e/constants';\nimport { environment } from '../../environments/environment';\nimport {\n FloorplanUploadFile,\n UploaderGrundrisseComponent,\n} from '../modules/porter-floor-plans/components/uploader-grundrisse/uploader-grundrisse.component';\nimport { ErrorDialogService } from './errordialog.service';\nimport { FloorplannerService } from './floorplanner.service';\n\ntype ConversionStatus = 'COMPLETED' | 'FAILED' | 'REJECTED' | 'FORBIDDEN' | 'IN_PROGRESS';\n\nexport interface ConversionDataResponse {\n conversions: ConversionResponse[];\n totalCount: number;\n}\n\nexport interface ConversionData {\n list: Conversion[];\n totalCount: number;\n}\n\nexport interface Conversion extends ConversionResponse {\n conversionDate: string;\n conversionTime: string;\n iconTooltip: string;\n conversionLink: string;\n}\n\ninterface ConversionResponse {\n endTime?: string;\n startTime?: string;\n error: any;\n conversionId: string;\n evaluation_score: string; // TODO: Why is this a string and not a number from be Backend. It is used a number in the frontend.\n floorplannerProjectId: number;\n hasProject: boolean;\n name: string;\n status: ConversionStatus;\n unitId: string;\n downloadUrlIfc: string;\n downloadUrlCollada: string;\n downloadUrGltf: string;\n downloadUrlBlender: string;\n thumbnail?: string;\n numberOfFiles?: number;\n}\n\nconst API_URL = environment.apiUrl;\nconst VIEWER_LOCATION = window.location.origin + '/grundrisse/grundriss-editor?conversionId=';\nconst MAX_TIME_TO_WAIT = 60 * 60 * 1000; // 60 minutes\nconst RETRY_TIME = 6 * 1000; // 6 seconds\n\nconst CONVERSION_FORBIDDEN_ERROR = {\n errorCode: '0xFFFFFF',\n location: 'floorplan-ai-service - getStatusOfConversion',\n devinfo: '403 unauthorized',\n publicinfo:\n 'Sie haben keine Berechtigung zur Anzeige dieses Grundrisses.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nconst CONVERSION_FAILED_ERROR = {\n errorCode: '0xFFFFFF',\n location: 'floorplan-ai-service - getStatusOfConversion',\n devinfo: 'result.status === FAILED',\n publicinfo:\n 'Der gewünschte Grundriss konnte nicht verarbeitet werden. Bitte laden Sie die Seite neu und wählen Sie eine andere Datei.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nconst CONVERSION_REJECTED_ERROR = {\n errorCode: '0xFFFFFF',\n location: 'floorplan-ai-service - getStatusOfConversion',\n devinfo: 'result.status === REJECTED',\n publicinfo:\n 'Der angeforderte Grundriss ist ungültig. Wählen Sie einen bereits umgewandelten Grundriss aus der Historie oder laden Sie einen neuen Grundriss hoch.',\n debug: false,\n autoFocus: false,\n};\n\nconst CONVERSION_TIMED_OUT_ERROR = {\n errorCode: '0xFFFFFF',\n location: 'floorplan-ai-service - getStatusOfConversion',\n devinfo: 'Max upload tries reached.',\n publicinfo:\n 'Der Upload ist fehlgeschlagen. Bitte laden Sie die Seite neu und versuchen es erneut.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nconst USER_CONVERSION_ENDPOINT = '/floorplans-ai/userConversions';\nconst NO_PAGINATION_ENDPOINT = USER_CONVERSION_ENDPOINT + '?usePagination=false';\nconst PAGINATION_ENDPOINT = USER_CONVERSION_ENDPOINT + '?usePagination=true&perPage=';\nconst PAGE_PARAM = '&page=';\nconst INCLUDE_THUMBNAILS_PARAM = '&includeThumbnails=';\n\n@Injectable()\nexport class FloorplanAIService {\n private readonly uploadSubscriptions: any;\n private conversionId: string;\n private modal: MatDialogRef;\n\n constructor(\n private http: HttpClient,\n private errorDialogService: ErrorDialogService,\n private floorplannerService: FloorplannerService\n ) {\n this.uploadSubscriptions = {};\n }\n\n cancelUploads() {\n for (const filename in this.uploadSubscriptions) {\n this.unsubscribe(filename);\n }\n }\n\n async initializeFloorPlanner(\n conversionId: string,\n modal?: MatDialogRef\n ): Promise {\n this.modal = modal;\n\n const status = await this.waitForFinalConversionStatus(conversionId);\n\n if (status === 'COMPLETED') {\n const conversion = await this.getConversion(conversionId).toPromise();\n this.floorplannerService.initializeFloorplanner(conversion.floorplannerProjectId);\n return conversion;\n }\n\n this.showConversionErrors(status);\n }\n\n private async waitForFinalConversionStatus(conversionId: string): Promise {\n let status: ConversionStatus = 'IN_PROGRESS';\n let retryCount = 0;\n\n while (status === 'IN_PROGRESS' && !this.hasReachedRetryLimit(retryCount)) {\n status = await this.getCurrentConversionStatus(conversionId);\n\n if (status !== 'IN_PROGRESS') {\n return status;\n }\n\n retryCount++;\n await this.waitUntilNextRetry();\n }\n }\n\n private async getCurrentConversionStatus(conversionId: string): Promise {\n return (await this.getConversion(conversionId).toPromise()).status;\n }\n\n private hasReachedRetryLimit(retryCount: number) {\n return retryCount * RETRY_TIME >= MAX_TIME_TO_WAIT;\n }\n\n private waitUntilNextRetry() {\n return new Promise((resolve) => setTimeout(resolve, RETRY_TIME));\n }\n\n private showConversionErrors(status: ConversionStatus) {\n switch (status) {\n case 'IN_PROGRESS':\n this.showError(CONVERSION_TIMED_OUT_ERROR);\n throw new Error('Conversion timed out.');\n case 'FORBIDDEN':\n this.showError(CONVERSION_FORBIDDEN_ERROR);\n throw new Error('Conversion is forbidden.');\n case 'FAILED':\n this.showError(CONVERSION_FAILED_ERROR);\n throw new Error('Conversion failed.');\n case 'REJECTED':\n this.showError(CONVERSION_REJECTED_ERROR);\n throw new Error('Conversion rejected.');\n }\n }\n\n uploadFloorplans(\n files: FloorplanUploadFile[],\n conversionName: string,\n modal?: MatDialogRef\n ): Observable {\n return Observable.create(async (observer) => {\n let totalProgress = 0;\n let numComplete = 0;\n let currentProgress = 0;\n\n let floorPlans = Array(files.length);\n\n // get base64 strings of files\n for (let i = 0; i < files.length; i++) {\n // floorplans and files are in reversed order, so we need to keep track of the inverse of i\n let inv_i = files.length - 1 - i;\n\n const val = await this.toBase64(files[i]).toPromise();\n floorPlans[inv_i] = {\n fileName: files[i].name,\n file: val,\n scalingFactor: files[i].scalingFactor,\n heightWall: files[i].heightWall,\n };\n if (i == files.length - 1) {\n // last file\n this.startConversion(floorPlans, conversionName, modal).subscribe(\n (progress) => {\n const progressDiff = progress - currentProgress;\n totalProgress += Math.round(progressDiff / files.length);\n currentProgress = progress;\n observer.next(totalProgress);\n },\n null,\n () => {\n numComplete++;\n if (numComplete === files.length) observer.complete();\n }\n );\n }\n }\n });\n }\n\n /**\n * convert PDF or DXF files to images\n */\n convertFile(file: File, caller) {\n // convert file to base64 string\n this.toBase64(file).subscribe((base64String) => {\n // combine apiUrl and conversion route\n const url = API_URL + '/floorplans-ai/convertFile';\n\n // create request with base64 data\n const request = new HttpRequest('POST', url, { data: base64String });\n\n // subscribe to upload observer\n const uploadSub = this.http.request(request).subscribe((event: HttpEvent) => {\n // switch for response events\n switch (event.type) {\n // log response headers that are not 200\n case HttpEventType.ResponseHeader:\n if (!event.ok) console.log(event);\n break;\n\n // if we get a response - base64 data in the event.body\n case HttpEventType.Response:\n // redirect the response back to the caller\n caller.insertB64(event.body, file);\n break;\n\n // default case - do nothing\n default:\n break;\n }\n });\n });\n }\n\n transferAiConversionToProject(conversionId: string, unitId: string): Observable {\n return this.http.post(\n environment.apiUrl + '/conversions/' + conversionId + '/conversionExports',\n { unitId: unitId }\n );\n }\n\n getConversion(conversionId: string): Observable {\n return this.http.get(\n environment.apiUrl + `/floorplans-ai/conversions/` + conversionId,\n {}\n );\n }\n\n private unsubscribe(filename) {\n const subscription = this.uploadSubscriptions[filename];\n if (!subscription) return;\n\n subscription.unsubscribe();\n delete this.uploadSubscriptions[filename];\n }\n\n /**\n * convert File to base64 string\n */\n private toBase64(file: File): Observable {\n // create observable reader\n return Observable.create((observer) => {\n // create new FileReader\n const reader = new FileReader();\n\n // onLoad for reader\n reader.addEventListener('load', () => {\n // get base64 conversion from reader\n const fullBase64String = reader.result as string;\n\n // split the descriptive non-data part\n const base64String = fullBase64String.split(',')[1];\n\n // emit the result and complete the observer\n observer.next(base64String);\n observer.complete();\n });\n\n // read the provided file - starts the process\n reader.readAsDataURL(file);\n });\n }\n\n private showError(error: any) {\n this.allowClosingModal();\n this.errorDialogService.openDialog(error);\n }\n\n private allowClosingModal() {\n // TODO: Is this necessary? All our modals are closeable by default, right?\n if (this.modal) this.modal.disableClose = false;\n }\n\n private startConversion(\n floorplans: any[],\n conversionName: string,\n modal?: MatDialogRef\n ): Observable {\n return Observable.create((observer) => {\n const request = new HttpRequest(\n 'POST',\n API_URL + '/floorplans-ai',\n { name: conversionName, files: floorplans },\n { reportProgress: true }\n );\n\n this.http.request(request).subscribe(\n (event: HttpEvent) => {\n switch (event.type) {\n case HttpEventType.UploadProgress:\n const percentDone = Math.round((100 * event.loaded) / event.total);\n observer.next(percentDone);\n break;\n case HttpEventType.ResponseHeader:\n if (!event.ok) observer.error(event);\n break;\n case HttpEventType.Response:\n console.log(event);\n this.conversionId = event.body.conversionId;\n conversionName = event.body.name;\n break;\n default:\n break;\n }\n },\n (error) => {\n console.error(error);\n observer.error(error);\n },\n async () => {\n observer.complete();\n if (this.conversionId) {\n const nextUrl = VIEWER_LOCATION + this.conversionId + '&environment=' + API_URL;\n await this.initializeFloorPlanner(this.conversionId, modal);\n window.location.href = nextUrl;\n }\n }\n );\n });\n }\n\n getAllUserConversionDataWithoutThumbnail(): Observable {\n return this.http.get(environment.apiUrl + NO_PAGINATION_ENDPOINT).pipe(\n map((response: ConversionDataResponse) => {\n return {\n list: response.conversions.map(this.mapConversion),\n totalCount: response.totalCount,\n };\n })\n );\n }\n\n async getConversionDataByPageWithoutThumbnail(\n perPage: number,\n pageNumber: number\n ): Promise {\n const response = await this.http\n .get(\n environment.apiUrl +\n PAGINATION_ENDPOINT +\n perPage +\n PAGE_PARAM +\n pageNumber +\n INCLUDE_THUMBNAILS_PARAM +\n STRING.false\n )\n .toPromise();\n return {\n list: response.conversions.map(this.mapConversion),\n totalCount: response.totalCount,\n };\n }\n\n async getConversionDataByPageWithThumbnail(\n perPage: number,\n pageNumber: number\n ): Promise {\n const response = await this.http\n .get(\n environment.apiUrl +\n PAGINATION_ENDPOINT +\n perPage +\n PAGE_PARAM +\n pageNumber +\n INCLUDE_THUMBNAILS_PARAM +\n STRING.true\n )\n .toPromise();\n return {\n list: response.conversions.map(this.mapConversion),\n totalCount: response.totalCount,\n };\n }\n\n private mapConversion(conversion: ConversionResponse): Conversion {\n return {\n ...conversion,\n conversionDate: '',\n conversionTime: '',\n iconTooltip: '',\n conversionLink: ''\n };\n }\n}\n","import { HttpClient, HttpEvent, HttpEventType, HttpRequest } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { Floorplan } from '../business-domain/Floorplan';\nimport { environment } from '../../environments/environment';\n\n@Injectable()\nexport class FloorplanService {\n private uploadSubs: any;\n\n constructor(private http: HttpClient) {\n this.uploadSubs = {};\n }\n\n private unsub(filename) {\n const sub = this.uploadSubs[filename];\n if (!sub) return;\n\n sub.unsubscribe();\n delete this.uploadSubs[filename];\n }\n\n cancelUploads() {\n for (const filename in this.uploadSubs) {\n if (true) this.unsub(filename);\n }\n }\n\n deleteFloorplan(floorplanId: string): Observable {\n return this.http.delete(environment.apiUrl + '/floorplans/' + floorplanId);\n }\n\n uploadFloorplans(unitId: string, files: File[]): Observable {\n return Observable.create((observer) => {\n let totalProgress = 0;\n let numComplete = 0;\n\n for (const file of files) {\n let currentProgress = 0;\n const floorplan = { unitId, filename: file.name };\n this.uploadFloorplan(floorplan, file).subscribe(\n (progress) => {\n const progressDiff = progress - currentProgress;\n totalProgress += Math.round(progressDiff / files.length);\n currentProgress = progress;\n observer.next(totalProgress);\n },\n null,\n () => {\n numComplete++;\n if (numComplete === files.length) observer.complete();\n }\n );\n }\n });\n }\n\n uploadFloorplan(floorplan: { unitId: string; filename: string }, file: File): Observable {\n if (!floorplan.filename) floorplan.filename = file.name;\n\n return Observable.create((observer) => {\n const reader = new FileReader();\n reader.addEventListener('load', () => {\n const fullBase64String = reader.result as string; // contains encoding\n const base64String = fullBase64String.split(',')[1]; // use only data-part\n\n const request = new HttpRequest(\n 'POST',\n environment.apiUrl + '/floorplans',\n { ...floorplan, file: base64String },\n { reportProgress: true }\n );\n\n const uploadSub = this.http.request(request).subscribe(\n (event: HttpEvent) => {\n switch (event.type) {\n case HttpEventType.UploadProgress:\n const percentDone = Math.round((100 * event.loaded) / event.total);\n observer.next(percentDone);\n break;\n case HttpEventType.ResponseHeader:\n if (!event.ok) observer.error(event);\n break;\n default:\n break;\n }\n },\n (error) => {\n console.error(error);\n this.unsub(file.name);\n observer.error(error);\n },\n () => {\n this.unsub(file.name);\n observer.complete();\n }\n );\n this.uploadSubs[file.name] = uploadSub;\n });\n reader.readAsDataURL(file);\n });\n }\n\n getFloorplan(floorplanId: string, thumbnail = false): Observable {\n return this.http\n .get(environment.apiUrl + '/floorplans/' + floorplanId, {\n params: { thumbnail: String(thumbnail) },\n })\n .pipe(map((floorplan: { data: string }) => floorplan.data));\n }\n\n getFloorplansByUnit(unitId: string): Observable {\n return this.http.get(environment.apiUrl + `/units/${unitId}/floorplans`);\n }\n\n startConversion(floorplanId: string): Observable {\n return this.http.post(environment.apiUrl + `/floorplans/${floorplanId}/convert`, {});\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable, Inject } from '@angular/core';\nimport { environment } from '../../environments/environment';\nimport { ReplaySubject, Observable, forkJoin } from 'rxjs';\nimport { DOCUMENT } from '@angular/common';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { first } from 'rxjs/operators';\nimport { ErrorDialogService } from '../services/errordialog.service';\n\ndeclare var initFPEditor: any;\n\ndeclare global {\n interface Window {\n api?: any;\n }\n}\n\n@Injectable()\nexport class FloorplannerService {\n private _loadedLibraries: { [url: string]: ReplaySubject } = {};\n\n FPprojects: any;\n downloadJsonHref: any;\n FMLDownload: any;\n\n constructor(\n @Inject(DOCUMENT) private readonly document: any,\n private http: HttpClient,\n private sanitizer: DomSanitizer,\n private errorDialogService: ErrorDialogService\n ) {}\n\n lazyLoadFPScripts(): Observable {\n return forkJoin([this.loadScript('../../assets/js/floorplanner_embed.js')]);\n }\n\n private loadScript(url: string): Observable {\n if (this._loadedLibraries[url]) {\n return this._loadedLibraries[url].asObservable();\n }\n this._loadedLibraries[url] = new ReplaySubject();\n const script = this.document.createElement('script');\n script.type = 'text/javascript';\n script.async = true;\n script.src = url;\n script.onload = () => {\n this._loadedLibraries[url].next(null);\n this._loadedLibraries[url].complete();\n };\n this.document.body.appendChild(script);\n return this._loadedLibraries[url].asObservable();\n }\n\n initializeFloorplanner(floorplannerProjectId: number) {\n this.getUserToken().subscribe(\n (data) => {\n console.log('initFloorplanner Success: ', data.token, data.userId);\n console.log('initFloorplanner data: ', data);\n this.initFloorplannerEditor(floorplannerProjectId, data.token, data.userId);\n },\n (error) => {\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplaner.service - getUserToken',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Abruf des Benutzer-Token.
Bitte wenden Sie sich an unseren Support. Vielen Dank.',\n debug: false,\n autoFocus: false,\n });\n }\n );\n }\n\n listProjects(): void {\n console.log('listProjects()');\n\n this.http.get(environment.apiUrl + '/floorplanner/listProjects').subscribe(\n (data) => {\n this.FPprojects = data;\n console.log('listProjects Success: ', data);\n },\n (error) => {\n console.log('listProjects Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplaner.service - listProjects',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Abruf der Umwandlungen. Bitte laden Sie die Seite neu.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n }\n );\n }\n\n getUserToken(): any {\n console.log('getUserToken()');\n return this.http.get(environment.apiUrl + '/floorplanner/usertoken');\n }\n\n // settings for the editor can be found here: https://floorplanner.readme.io/reference/embedding-the-editor-v2#editor-settings\n initFloorplannerEditor(projectID: number, authToken: string, floorplannerUserId: string): void {\n initFPEditor({\n projectId: projectID,\n mountSelector: '#fp-editor-container',\n user: {\n id: floorplannerUserId,\n auth_token: authToken,\n // An array of permissions:\n // 'save' shows the save button in the top bar\n // 'no-export' hides the 2D & 3D export buttons in the top bar\n // 'hide-email' hides the email field at the bottom of the export popup\n // 'no-back-to-dashboard' hides the Back to dashboard button in the sidebar\n // 'ntl' turns off the cooldown period for renders\n permissions: ['save', 'no-back-to-dashboard', 'ntl', 'hide-email'],\n },\n language: 'de-DE',\n apiDomain: 'floorplanner.com',\n embedPrefix: 'https://fp-editor-cdn.floorplanner.com',\n kind: 'editor', // 'spaceplanner', 'editor', 'viewer' and 'roomplanner'\n templateId: 30558, // Load template for consistent branding\n brandingId: 333789,\n helpCenterLinkUrl: 'https://porter-gmbh.atlassian.net/wiki/spaces/SUPPORT/pages/2891317249/PORTER+Grundrisse',\n hiddenComponents: ['clear-design-button', 'duplicate-design-button', 'delete-design-button', 'designs-sidebar'],\n }).then((api) => {\n window.api = api;\n /* additional setup using editor API object */\n // api.onUpdated = (data) => console.log('floorplan updated', data);\n // api.onSave = (data) => console.log('floorplan saved', data);\n // api.onExport = (data) => console.log('floorplan exported', data);\n // api.state\t= (data) => console.log('floorplan state', data);\n });\n }\n\n // currently unused, becaus of floorplanner unmount error\n unmountFloorplannerEditor(): void {\n console.log('unount()', window.api);\n window.api.unmount();\n }\n\n // currently unused, becaus of floorplanner unmount error\n reloadFloorplannerEditor(): void {\n console.log('reload()', window.api);\n window.api.reload();\n }\n\n showProject(projectId: number): void {\n console.log('showProject()');\n console.log('projectId: ', projectId);\n\n this.http.get(environment.apiUrl + `/floorplanner/showProject/${projectId}`).subscribe(\n (data) => {\n console.log('showProject Success: ', data);\n // this.generateDownloadJsonUri(projectId);\n },\n (error) => {\n console.log('showProject Error: ', error);\n (error) => {\n console.log('listProjects Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplaner.service - showProject',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Abruf der Umwandlung. Bitte laden Sie die Seite neu.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n };\n }\n );\n }\n\n createProject(projectName: string): void {\n console.log('createProject(): ' + projectName);\n\n this.http.post(environment.apiUrl + `/floorplanner/createProject/${projectName}`, {}).subscribe(\n (data) => {\n console.log('createProject Success: ', data);\n },\n (error) => {\n console.log('createProject Error: ', error);\n (error) => {\n console.log('listProjects Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplaner.service - createProject',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Erstellen der Umwandlung. Bitte laden Sie die Seite neu.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n };\n }\n );\n }\n\n deleteProject(projectId: number): void {\n console.log('deleteProject(): ' + projectId);\n\n this.http.delete(environment.apiUrl + `/floorplanner/deleteProject/${projectId}`).subscribe(\n (data) => {\n console.log('deleteProject Success: ', data);\n },\n (error) => {\n console.log('deleteProject Error: ', error);\n (error) => {\n console.log('listProjects Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplaner.service - deleteProject',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Löschen der Umwandlung. Bitte laden Sie die Seite neu.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n };\n }\n );\n }\n\n downloadProjectFML(projectId: number): any {\n console.log('downloadProjectJSON(): ' + projectId);\n\n this.http.get(environment.apiUrl + `/floorplanner/downloadProjectFML/${projectId}`).subscribe(\n (data) => {\n console.log('downloadProjectJSON Success: ', data);\n let theJSON = JSON.stringify(data);\n let blob = new Blob([theJSON], { type: 'text/json' });\n let url = window.URL.createObjectURL(blob);\n let a = document.createElement('a');\n document.body.appendChild(a);\n a.setAttribute('style', 'display: none');\n a.href = url;\n a.download = 'export-' + projectId + '.json';\n a.click();\n window.URL.revokeObjectURL(url);\n a.remove();\n },\n (error) => {\n console.log('downloadProjectJSON Error: ', error);\n (error) => {\n console.log('listProjects Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplaner.service - downloadProjectJSON',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Herunterladen der ProjectFML. Bitte laden Sie die Seite neu.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n };\n }\n );\n }\n\n generateDownloadJsonUri(projectId) {\n console.log('generateDownloadJsonUri()');\n\n const resJsonResponse = this.downloadProjectFML(projectId);\n console.log('resJsonResponse: ', resJsonResponse);\n\n var theJSON = JSON.stringify(resJsonResponse);\n console.log('theJSON: ', theJSON);\n\n var uri = this.sanitizer.bypassSecurityTrustUrl(\n 'data:text/json;charset=UTF-8,' + encodeURIComponent(theJSON)\n );\n console.log('uri: ', uri);\n\n this.downloadJsonHref = uri;\n }\n\n downloadExcel(projectId: number): any {\n console.log('downloadExcel(): ' + projectId);\n\n this.http\n .post(\n environment.apiUrl + `/floorplans-ai/mass/`,\n { projectId, filename: 'export-' + projectId + '.xlsx' },\n { responseType: 'blob' }\n )\n .pipe(first())\n .subscribe(\n (data) => {\n console.log('downloadExcel Success: ', data);\n let url = window.URL.createObjectURL(data);\n let a = document.createElement('a');\n document.body.appendChild(a);\n a.setAttribute('style', 'display: none');\n a.href = url;\n a.download = 'export-' + projectId + '.xlsx';\n a.click();\n window.URL.revokeObjectURL(url);\n a.remove();\n },\n (error) => {\n console.log('Error: ', error);\n (error) => {\n console.log('downloadExcel Error: ', error);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplaner.service - downloadExcel',\n devinfo: error.message,\n publicinfo:\n 'Fehler beim Herunterladen der Excel Datei. Bitte laden Sie die Seite neu und versuchen es erneut.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n });\n };\n }\n );\n }\n}\n","import { Injectable } from '@angular/core';\nimport { MatIconRegistry } from '@angular/material/icon';\nimport { DomSanitizer } from '@angular/platform-browser';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IconRegistryService {\n constructor(\n private readonly iconRegistry: MatIconRegistry,\n private readonly sanitizer: DomSanitizer\n ) {}\n\n register(iconName: string, iconUrl: string) {\n this.iconRegistry.addSvgIcon(iconName, this.sanitizer.bypassSecurityTrustResourceUrl(iconUrl));\n }\n}\n","
\n
\n {{ data.icon }}\n

\n {{ data.title }}\n

\n
\n close\n
\n
\n
\n

{{ data.text }}

\n
\n
\n
\n \n
\n
\n","import {\n ChangeDetectionStrategy,\n Component,\n HostListener,\n Inject,\n Output,\n SecurityContext,\n} from '@angular/core';\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\nimport { DomSanitizer } from '@angular/platform-browser';\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n selector: 'infobox-dialog',\n templateUrl: './infobox-dialog.component.html',\n styleUrls: ['./infobox-dialog.component.scss'],\n standalone: false\n})\nexport class InfoboxDialogComponent {\n constructor(\n @Inject(MAT_DIALOG_DATA) public data: any,\n private domSanitizer: DomSanitizer,\n private dialogRef: MatDialogRef\n ) {}\n\n @HostListener('keydown.esc')\n public onEsc() {\n this.close();\n }\n\n close() {\n this.dialogRef.close(false);\n }\n\n getSanitizedContent() {\n return this.domSanitizer.sanitize(SecurityContext.HTML, this.data.content);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\nimport { Observable } from 'rxjs';\nimport { map, take } from 'rxjs/operators';\nimport { InfoboxDialogComponent } from '../components/dialogs/infobox-dialog/infobox-dialog.component';\n\n@Injectable()\nexport class InfoboxDialogService {\n constructor(private dialog: MatDialog) {}\n dialogRef: MatDialogRef;\n\n public open(options) {\n this.dialogRef = this.dialog.open(InfoboxDialogComponent, {\n autoFocus: false,\n backdropClass: 'backdropBackground',\n data: options,\n });\n }\n public confirmed(): Observable {\n return this.dialogRef.afterClosed().pipe(\n take(1),\n map((res) => {\n return res;\n })\n );\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient, HttpRequest, HttpEventType, HttpEvent } from '@angular/common/http';\nimport { Observable } from 'rxjs';\nimport { map, flatMap } from 'rxjs/operators';\nimport { InputFile } from '../business-domain/InputFile';\nimport { environment } from '../../environments/environment';\n\n@Injectable()\nexport class InputFileService {\n private inputFilesUrl = environment.apiUrl + '/inputFiles';\n\n constructor(private http: HttpClient) {}\n\n getInputFilesByUnit(unitId: string): Observable {\n return this.http.get(`${environment.apiUrl}/units/${unitId}/inputFiles`);\n }\n\n uploadInputFile(file: File, unitId: string, type: string): Observable {\n const formData: FormData = new FormData();\n formData.append('unitId', String(unitId));\n formData.append('type', type);\n formData.append('input', file, file.name);\n\n const req = new HttpRequest('POST', this.inputFilesUrl, formData, { reportProgress: true });\n\n return this.http.request(req).pipe(\n map((event: HttpEvent) => {\n if (event.type === HttpEventType.UploadProgress) return Math.round((100 * event.loaded) / event.total);\n if (event.type === HttpEventType.ResponseHeader && !event.ok) throw event;\n }),\n );\n }\n\n updateInputFile(file: File, unitId: string, type: string): Observable {\n return this.getInputFilesByUnit(unitId).pipe(\n flatMap((floorplans) => {\n const formData: FormData = new FormData();\n formData.append('type', type);\n formData.append('input', file, file.name);\n\n const req = new HttpRequest('PUT', this.inputFilesUrl + '/' + floorplans[0].id, formData, { reportProgress: true });\n return this.http.request(req);\n }),\n map((event: HttpEvent) => {\n if (event.type === HttpEventType.UploadProgress) return Math.round((100 * event.loaded) / event.total);\n if (event.type === HttpEventType.ResponseHeader && !event.ok) throw event;\n }),\n );\n }\n\n releaseForFinalEdit(inputFileId: string): Observable {\n return this.http.post(`${this.inputFilesUrl}/${inputFileId}/finalEdit`, {});\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\nimport { Observable } from 'rxjs';\nimport { map, first, tap } from 'rxjs/operators';\nimport { Level } from '../business-domain/Level';\nimport { environment } from './../../environments/environment';\nimport { ErrorDialogService } from '../services/errordialog.service';\n\ninterface Response {\n data: T;\n}\n\n@Injectable()\nexport class LevelService {\n constructor(private http: HttpClient, private errorDialogService: ErrorDialogService) {}\n\n public getLevelsByBuilding(buildingId: string): Observable {\n return this.http\n .get>(environment.apiUrl + `/buildings/${buildingId}/levels`)\n .pipe(map((response) => response.data)) as Observable;\n }\n\n public addAssetToPreselection(levelId: string, typeId: string, assetId: string): Observable {\n return this.http.post(\n environment.apiUrl + '/levels/' + levelId + '/types/' + typeId + '/preselections',\n { assetId: assetId }\n );\n }\n\n public getLevelById(levelId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId);\n }\n\n public getPreselectionsByLevel(levelId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId + '/preselections');\n }\n\n public getPreselection(levelId: string, typeId: string, preselectionId: string): Observable {\n return this.http.get(\n environment.apiUrl +\n '/levels/' +\n levelId +\n '/types/' +\n typeId +\n '/preselections/' +\n preselectionId\n );\n }\n\n public deletePreselection(\n levelId: string,\n typeId: string,\n preselectionId: string\n ): Observable {\n return this.http.delete(\n environment.apiUrl +\n '/levels/' +\n levelId +\n '/types/' +\n typeId +\n '/preselections/' +\n preselectionId\n );\n }\n\n public deletePreselections(preselectionIds: string[]): Observable {\n console.log('deletePreselections(): ', preselectionIds);\n const options = {\n headers: new HttpHeaders({\n 'Content-Type': 'application/json',\n }),\n body: {\n data: preselectionIds,\n },\n };\n\n return this.http.delete(environment.apiUrl + '/preselections', options);\n }\n\n public deletePreselectionsBySchema(levelId, schemaId: string): Observable {\n return this.http.delete(\n environment.apiUrl + '/levels/' + levelId + '/schemas/' + schemaId + '/preselections'\n );\n }\n\n public getType(levelId: string, typeId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId + '/types/' + typeId);\n }\n\n public getTypes(levelId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId + '/types');\n }\n\n public getTypeAndCategoryTree(): Observable {\n return this.http.get(environment.apiUrl + '/types/').pipe(\n map((res: any) => res.data)\n //tap((res) => console.log('getTypeAndCategoryTree tap = ', res))\n );\n }\n\n public getTypeName(typeId: string, types: any): string {\n for (let index = 0; index < types.length; index++) {\n if (types[index].id == typeId) {\n return types[index].displayName;\n }\n }\n }\n\n public getCategoriesForLevel(levelId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId + '/categories');\n }\n\n public getCategoriesForType(levelId: string, typeId: string): Observable {\n return this.http.get(\n environment.apiUrl + '/levels/' + levelId + '/types/' + typeId + '/categories'\n );\n }\n\n public getCategoryName(typeId: string, categories: any) {\n return categories.filter((item) => item.typeId === typeId).map((item) => item.displayName);\n }\n\n public getObjectMaterials(objectId: string): Observable {\n return this.http.get(environment.apiUrl + '/objects/' + objectId + '/materials');\n }\n\n public getColorsById(colorId: string): Observable {\n return this.http.get(environment.apiUrl + '/colors/' + colorId);\n }\n\n public getActorsByLevelId(levelId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId + '/objects');\n }\n\n public getActorSlotsByLevelId(levelId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId + '/actorSlots');\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Router, NavigationEnd } from '@angular/router';\nimport { filter, map } from 'rxjs/operators';\n\nconst LOCALSTORAGE_HISTORY = 'navigationHistory';\nconst MAX_NAVIGATION_HISTORY_LENGTH = 3;\n\n/*\n * We handle our history here manually. This can also be done by using angular location\n * which has built in functionality to handle the history.\n *\n * Document.location examples:\n * https://stackoverflow.com/questions/37517183/how-do-i-get-the-absolute-path-of-the-current-page-in-angular-2\n */\n@Injectable({ providedIn: 'root' })\nexport class NavigationHistoryService {\n private history: string[] = [];\n\n constructor(private router: Router) {}\n\n init() {\n const initialURL = decodeURI(this.router.url);\n if (this.localStorageHasHistory()) {\n this.history = this.getHistoryFromLocalStorage();\n }\n\n if (!this.hasHistory() || this.isPathDifferentFromLastOne(initialURL)) {\n if (this.hasHistoryReachedMaxLength()) this.history.shift();\n this.history.push(initialURL);\n this.updateHistoryInLocalStorage(this.history);\n }\n\n this.router.events\n .pipe(\n filter((event) => event instanceof NavigationEnd),\n map((event: NavigationEnd) => decodeURI(event.urlAfterRedirects)),\n filter(\n (path: string) =>\n this.isPathDifferentFromLastOne(path)\n )\n )\n .subscribe((path: string) => {\n if (this.hasHistoryReachedMaxLength()) this.history.shift();\n this.history.push(path);\n this.updateHistoryInLocalStorage(this.history);\n });\n }\n\n getLastRoute(): string | null {\n if (this.hasHistory()) {\n this.history.pop(); //remove current route\n return this.history.pop(); //get previous path and remove it from history\n }\n return null;\n }\n\n getLastRouteIncludingString(pathFragment: string): string | null {\n if (this.hasHistory()) {\n const reverseHistory = [...this.history].reverse();\n reverseHistory.shift(); //remove current route\n return reverseHistory.find((path) => path.includes(pathFragment));\n }\n return null;\n }\n\n getHistory(): string[] {\n return this.history;\n }\n\n hasHistory(): boolean {\n return this.history.length > 1;\n }\n\n localStorageHasHistory(): boolean {\n const entry: string[] = JSON.parse(window.localStorage.getItem(LOCALSTORAGE_HISTORY));\n return entry !== null && Array.isArray(entry) && entry.length > 0;\n }\n\n hasPreviousNavigation(): boolean {\n return this.history.length > 1;\n }\n\n getPreviousUrl(): string {\n if (this.history.length > 1) {\n return this.history[this.history.length - 2];\n }\n return '';\n }\n\n private isPathDifferentFromLastOne(path: string) {\n return this.getLastPath() !== path;\n }\n\n private hasHistoryReachedMaxLength() {\n return this.history.length >= MAX_NAVIGATION_HISTORY_LENGTH;\n }\n\n private getLastPath() {\n return this.history[this.history.length - 1];\n }\n\n private getHistoryFromLocalStorage(): string[] {\n let history = JSON.parse(window.localStorage.getItem(LOCALSTORAGE_HISTORY));\n return history;\n }\n\n private updateHistoryInLocalStorage(history: string[]) {\n window.localStorage.setItem(LOCALSTORAGE_HISTORY, JSON.stringify(history));\n }\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, NavigationExtras, Router } from '@angular/router';\nimport { environment } from '../../environments/environment';\nimport { APP_PATHS } from '../route-paths';\nimport { FEATURE_FLAGS } from '../shared/constants/feature-flags.constants';\nimport { AuthService } from './auth.service';\nimport { EnvironmentService } from './environment.service';\nimport { SchemasService } from './schemas.service';\n\nexport enum Page {\n CATALOG,\n ONBOARDING_SCREEN,\n LIVING_STYLE_CONSULTANT,\n LIVING_STYLE_INFO,\n FLOORPLANS,\n APP_LINK,\n MANAGEMENT,\n PROJECTS,\n BUILDING_PROJECTS,\n VISUALIZATION,\n}\n\nexport interface OnboardingScreenQueryParameters {\n livingStyleConsultant: 'open';\n livingStyleInfo: 'open';\n}\n\nconst LIVING_STYLE_CONSULTANT_QUERY_PARAMETER = {\n livingStyleConsultant: 'open',\n};\n\nconst LIVING_STYLE_INFO_QUERY_PARAMETER = {\n livingStyleInfo: 'open',\n};\n\nconst CATALOG_PAGE_QUERY_PARAMETER = {\n seite: 1,\n};\n\n// CHAT GPT\n// Use navigate()\n// when you want to navigate to a route within your Angular application and construct the route path\n// based on route configuration and parameters.\n//\n// Use navigateByUrl()\n// when you want to navigate to an external URL or to a route using an absolute URL string.\n@Injectable({\n providedIn: 'root',\n})\nexport class NavigationService {\n constructor(\n private readonly router: Router,\n private readonly authService: AuthService,\n private readonly environmentService: EnvironmentService,\n private readonly schemaService: SchemasService\n ) {}\n\n async navigateTo(page: Page) {\n console.log('navigateTo', Page[page]);\n switch (page) {\n case Page.CATALOG: {\n await this.navigateToAssetCatalog();\n break;\n }\n case Page.MANAGEMENT: {\n await this.navigateToAssetManagement();\n break;\n }\n case Page.ONBOARDING_SCREEN:\n await this.navigate(APP_PATHS.onboardingScreen);\n break;\n case Page.LIVING_STYLE_CONSULTANT:\n await this.navigate(APP_PATHS.onboardingScreen, LIVING_STYLE_CONSULTANT_QUERY_PARAMETER);\n break;\n case Page.LIVING_STYLE_INFO:\n await this.navigate(APP_PATHS.onboardingScreen, LIVING_STYLE_INFO_QUERY_PARAMETER);\n break;\n case Page.FLOORPLANS:\n await this.navigate(APP_PATHS.floorPlans);\n break;\n case Page.APP_LINK:\n await this.navigate(APP_PATHS.appLink);\n break;\n case Page.PROJECTS:\n await this.navigate(APP_PATHS.projects);\n break;\n case Page.BUILDING_PROJECTS:\n await this.navigate(APP_PATHS.buildingProjects);\n break;\n case Page.VISUALIZATION:\n await this.navigate(APP_PATHS.visualization);\n break;\n }\n }\n\n async navigateToCategory(categorySegments: string[]) {\n const categorySubRoute = 'kategorie';\n const baseRouteSegment = await this.getBaseRouteSegment();\n const routeSegments = [baseRouteSegment, categorySubRoute, ...categorySegments];\n try {\n const navigationResult = await this.router.navigate(routeSegments);\n if (!navigationResult) {\n console.error('Navigation failed. Route segments:', routeSegments);\n }\n } catch (error) {\n console.error('Navigation Error:', error);\n }\n }\n\n async getBaseRouteSegment(): Promise {\n const urlSegments = this.router.url.split('?')[0].split('/');\n if (urlSegments.length > 1) {\n return urlSegments[1];\n }\n }\n\n getPathForPrecedingPage(path: string): string {\n const substring = 'seite=';\n const parameterIndex = path.indexOf(substring);\n const charIndex = parameterIndex + substring.length;\n const page = path.charAt(charIndex);\n const newPage = +page - 1;\n const newPath = path.substring(0, charIndex) + newPage + path.substring(charIndex + 1);\n return newPath;\n }\n\n isAssetCatalog(): boolean {\n return this.router.url.includes(APP_PATHS.assetCatalog) || this.router.url.includes(APP_PATHS.assetCatalogOnly);\n }\n\n isAssetManagement(): boolean {\n return this.router.url.includes(APP_PATHS.assetManagement);\n }\n\n isBuildingProjects(): boolean {\n return this.router.url.includes(APP_PATHS.buildingProjects);\n }\n\n isVisualization(): boolean {\n return this.router.url.includes(APP_PATHS.visualization);\n }\n\n isFloorPlans(): boolean {\n return this.router.url.includes(APP_PATHS.floorPlans);\n }\n\n async guardNavigation(next: ActivatedRouteSnapshot) {\n if (this.isOnProjects(next) || this.isAdmin()) {\n await this.navigateTo(Page.FLOORPLANS);\n } else if (this.isBuilder()) {\n await this.navigateTo(Page.CATALOG);\n } else if (this.canNavigateToProductManagement()) {\n await this.navigateTo(Page.MANAGEMENT);\n } else {\n await this.navigateTo(Page.APP_LINK);\n }\n }\n\n private async navigate(url: string, queryParameters?: any) {\n const navigationExtras: NavigationExtras = {\n queryParams: queryParameters,\n };\n\n await this.router.navigate([url], navigationExtras);\n }\n\n private isAdmin() {\n return this.authService.hasUserGroup([environment.adminGroup]);\n }\n\n private isBuilder() {\n return this.authService.hasUserGroup(environment.FINGERHAUS_BUILDER);\n }\n\n private canNavigateToProductManagement() {\n return (\n this.authService.hasUserGroup(environment.FINGERHAUS_PRODUCT_MANAGEMENT_GROUP) ||\n this.authService.hasUserGroup(environment.FINGERHAUS_CONSULTANT_GROUP) ||\n this.authService.hasUserGroup(environment.FINGERHAUS_ADMIN_GROUP)\n );\n }\n\n private isOnProjects(next: ActivatedRouteSnapshot) {\n return next.routeConfig.path === 'projects';\n }\n\n private async navigateToAssetManagement() {\n const path = APP_PATHS.assetManagement;\n const fullPath = this.hasCategoryOverviewFeature() ? path : path + APP_PATHS.category;\n await this.navigate(fullPath, CATALOG_PAGE_QUERY_PARAMETER);\n }\n\n private async navigateToAssetCatalog() {\n let fullPath = APP_PATHS.assetCatalog;\n\n // If we are in the FingerHaus environment and the category overview feature is not enabled, navigate to the implicit \"all\" category\n if (this.environmentService.isFingerhaus() && !this.hasCategoryOverviewFeature()) {\n fullPath += APP_PATHS.category;\n }\n // If we are in the PORTER environment, navigate to the first category\n if (this.environmentService.isPorter()) {\n fullPath += APP_PATHS.category;\n fullPath += '/' + this.schemaService.getFirstCategoryName();\n }\n\n await this.navigate(fullPath);\n }\n\n private hasCategoryOverviewFeature() {\n return this.authService.hasFeatureFlag(FEATURE_FLAGS.categoryOverview);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { Project } from '../business-domain/Project';\nimport { environment } from './../../environments/environment';\n\ninterface Response {\n data: T;\n}\n\n@Injectable()\nexport class ProjectService {\n constructor(private http: HttpClient) {}\n\n public getProject(projectId: string): Observable {\n const endpoint = environment.projectEndpoint.replace(':projectId', String(projectId));\n return this.http.get(environment.apiUrl + endpoint);\n }\n\n public getProjects(): Observable {\n return this.http\n .get>(environment.apiUrl + environment.projectsEndpoint, {\n params: { includeImage: 'true' },\n })\n .pipe(map((response) => response.data)) as Observable;\n }\n\n public getProjectForLevelId(levelId: string): Observable {\n return this.http.get(environment.apiUrl + '/levels/' + levelId + '/project');\n }\n\n public insertProject(project: Project): Observable {\n const endpoint = environment.projectsEndpoint;\n return this.http.post(environment.apiUrl + endpoint, { ...project });\n }\n\n public updateProject(projectId: string, project: Project): Observable {\n const endpoint = environment.projectEndpoint.replace(':projectId', String(projectId));\n return this.http.put(environment.apiUrl + endpoint, { ...project });\n }\n\n public deleteProject(projectId: string) {\n const endpoint = environment.projectEndpoint.replace(':projectId', String(projectId));\n return this.http.delete(environment.apiUrl + endpoint);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { throwError } from 'rxjs';\nimport { HttpClient, HttpErrorResponse } from '@angular/common/http';\nimport { map, catchError } from 'rxjs/operators';\nimport { environment } from '../../environments/environment';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ReleaseNotesService {\n constructor(private http: HttpClient) {}\n\n getData() {\n return this.http.get(environment.apiUrl + '/versions/changelog ').pipe(\n map((data: any) => data.results),\n catchError(this.handleError),\n );\n }\n\n /**\n * Function to handle error when the server return an error\n *\n * @param error\n */\n private handleError(error: HttpErrorResponse) {\n if (error.error instanceof ErrorEvent) {\n // A client-side or network error occurred. Handle it accordingly.\n console.error('An error occurred:', error.error.message);\n } else {\n // The backend returned an unsuccessful response code. The response body may contain clues as to what went wrong,\n console.error(`Backend returned code ${error.status}, ` + `body was: ${error.error}`);\n }\n // return an observable with a user-facing error message\n return throwError(error);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient, HttpParams } from '@angular/common/http';\nimport { ErrorDialogService } from './errordialog.service';\nimport { environment } from '../../environments/environment';\n\nexport enum PropertyType {\n ENUM = 'ENUM',\n FILE = 'FILE',\n MULTISELECT = 'MULTISELECT',\n NUMBER = 'NUMBER',\n PRODUCT_IMAGES = 'PRODUCTIMAGES',\n STRING = 'STRING',\n TEXTAREA = 'TEXTAREA',\n}\n\nexport enum PropertyVisibilityLevel {\n CATALOGUE = 'CATALOGUE',\n DETAIL = 'DETAIL',\n FINGERHAUS = 'FINGERHAUS',\n LOG = 'LOG',\n MANAGEMENT = 'MANAGEMENT',\n NONE = 'NONE',\n}\n\nexport interface SchemaProperty {\n defaultValue: string;\n displayName: string;\n enums?: SchemaPropertyEnum[];\n isInheritable: number;\n name: string;\n order: number;\n propertyId: string;\n required: number;\n schemaId: string;\n type: PropertyType;\n visibilityLevel: PropertyVisibilityLevel;\n}\n\ninterface SchemaPropertyEnum {\n displayName: string;\n id: string;\n propertyId: string;\n value: number;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SchemaPropertiesService {\n // TODO: set desired language globally\n private locale = 'de';\n\n constructor(private http: HttpClient, private errorDialogService: ErrorDialogService) {}\n\n // TODO: Add logic in order to get properties from schemaTree in case one was already loaded before\n async getPropertiesOfSchema(\n schemaId: string,\n includeInherited: boolean,\n includeEnums: boolean\n ): Promise {\n let params = new HttpParams();\n let options: any;\n let res: any;\n let properties: SchemaProperty[];\n\n if (includeEnums) params = params.append('includeEnums', 'true');\n if (includeInherited) params = params.append('includeInherited', 'true');\n\n options = { params: params };\n res = await this.http\n .get(environment.apiUrl + '/schemas/' + schemaId + '/properties', options)\n .toPromise();\n\n properties = res.properties;\n\n this.parseDisplayNameWithLocale(properties); // TODO: consider not manipulating the object, but assign a returned object\n return properties;\n }\n\n filterPropertiesByVisibilityLevel(\n properties: SchemaProperty[],\n visibilityLevels: PropertyVisibilityLevel[]\n ): SchemaProperty[] {\n return properties.filter((property) => visibilityLevels.includes(property.visibilityLevel));\n }\n\n filterPropertiesByType(properties: SchemaProperty[], type: PropertyType[]): SchemaProperty[] {\n return properties.filter((property) => type.includes(property.type));\n }\n\n sortPropertiesByOrderValue(properties: SchemaProperty[]) {\n return properties.sort((a, b) => (a.order > b.order ? 1 : -1));\n }\n\n /**\n * Checks if the given property value is considered empty as per our policy (defined by POR-10125).\n * Empty means it does not have a value which can be considered a meaningful value of the property.\n *\n * @param value - The value to check.\n * @returns True if the value is null or undefined or an empty string, false otherwise.\n */\n isPropertyValueEmpty(value): boolean {\n return value === null || value === undefined || value === '';\n }\n\n private parseDisplayNameWithLocale(properties: any): void {\n // TODO QA: Want to use SchemaProperty[] here but \"property.enums\" is troublesome. is this a valid field on the SchemaProperty?\n for (let i = 0; i < properties.length; i++) {\n let property = properties[i];\n\n //parse displayName of schema\n try {\n if (JSON.parse(property.displayName))\n property.displayName = JSON.parse(property.displayName)[this.locale];\n } catch (error) {\n //console.error(error, 'Error in trying to parse displayName of property ', property);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'schemas-service, getPropertiesOfSchema()',\n devinfo: error.message /* Standard (falls verfügbar): error.message */,\n publicinfo:\n 'Beim Auslesen der Produktkategorie ist ein Fehler aufgetreten.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false /* Standardwert, nur für Entwickler zur Fehlersuche true */,\n autoFocus: false /* Standardwert */,\n });\n }\n\n // parse displayName of enums\n if (property.enums) {\n for (let j = 0; j < property.enums.length; j++) {\n let enu = property.enums[j];\n\n try {\n if (JSON.parse(enu.displayName))\n enu.displayName = JSON.parse(enu.displayName)[this.locale];\n } catch (error) {\n //console.error(error, 'Error in trying to parse displayName of property ', property);\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'schemas-service, getPropertiesOfSchema()',\n devinfo: error.message /* Standard (falls verfügbar): error.message */,\n publicinfo:\n 'Beim Auslesen der Produktkategorie ist ein Fehler aufgetreten.
Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false /* Standardwert, nur für Entwickler zur Fehlersuche true */,\n autoFocus: false /* Standardwert */,\n });\n }\n }\n }\n }\n }\n}\n","import { HttpClient, HttpParams } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { firstValueFrom } from 'rxjs';\nimport { environment } from '../../environments/environment';\nimport { Product } from '../business-domain/product.interface';\nimport { CategoryCard } from '../modules/asset-catalog/components/category-overview/category-overview.component';\nimport { NavigationService } from './navigation.service';\nimport { SchemaProperty } from './schema-properties.service';\nimport { Router } from '@angular/router';\nimport { APP_PATHS } from '../route-paths';\n\nexport enum SchemaType {\n All,\n Filtered,\n}\n\nexport type ProductSchemaId = string;\ntype ProductSchemaName = string;\n\nexport interface CategoryPath {\n firstCategoryName: string;\n secondCategoryName: string;\n thirdCategoryName: string;\n}\n\n// TODO DAI QA: Is not the name ProductCategory more fitting?\nexport interface CategorySchema {\n children: CategorySchema[];\n displayName: string;\n id: ProductSchemaId;\n isVisible: number;\n langCode: string;\n name: string;\n order: number;\n parentId: string;\n plural: string;\n schemaId: ProductSchemaId; // TODO DAI QA: I checked it and its the same as id. Why is this here?\n singular: string;\n thumbnailUrl: string;\n\n // TODO DAI QA: Not from BE\n productList?: Product[];\n properties?: SchemaProperty[];\n selected: boolean;\n}\n\ninterface CategorySchemaTree {\n data: CategorySchema[];\n}\n\n// TODO: Maybe rename to CategorySchemaService\n@Injectable({\n providedIn: 'root',\n})\nexport class SchemasService {\n allCategories: CategorySchema[];\n filteredCategories: CategorySchema[];\n private imageCache: Map = new Map();\n\n constructor(\n private readonly http: HttpClient,\n private readonly router: Router,\n ) {}\n\n async initialize() {\n this.allCategories = await this.fetchSchemaListWithProperties();\n this.filteredCategories = await this.fetchFilteredSchemaList();\n await this.cacheCategoryImages();\n }\n\n getCategoryForest(type: SchemaType = SchemaType.All): CategorySchema[] {\n let schema: CategorySchema[];\n\n switch (type) {\n case SchemaType.All:\n schema = this.allCategories;\n break;\n case SchemaType.Filtered:\n schema = this.filteredCategories;\n break;\n }\n\n return schema;\n }\n\n getFirstCategoryName(): string {\n const type = this.isAssetManagement() ? SchemaType.All : SchemaType.Filtered;\n switch (type) {\n case SchemaType.Filtered:\n return this.filteredCategories[0].displayName;\n case SchemaType.All:\n return this.allCategories[0].displayName;\n }\n }\n\n getParentCategoryCard(): CategoryCard[] {\n return this.filteredCategories.map((category) => {\n const cachedImage = this.getCachedImage(category.thumbnailUrl);\n return {\n name: category.displayName,\n imageUrl: cachedImage ? URL.createObjectURL(cachedImage) : category.thumbnailUrl,\n };\n });\n }\n\n getAllChildCategoryIds(id: ProductSchemaId): ProductSchemaId[] {\n const parentCategory = this.findCategory(id);\n const result: ProductSchemaId[] = [];\n\n parentCategory.children.forEach((child) => {\n result.push(child.id);\n child.children.forEach((grandChild) => {\n result.push(grandChild.id);\n });\n });\n\n return result;\n }\n\n // TODO: consider refactoring for readability\n findSchemaId(path: CategoryPath): ProductSchemaId {\n if (!path) return null;\n\n const pathSegments = [path.firstCategoryName, path.secondCategoryName, path.thirdCategoryName];\n const validPathSegments = pathSegments.filter((segment) => segment);\n\n let mostSpecificCategory: any = { children: this.allCategories };\n\n for (const segment of validPathSegments) {\n const foundChild = mostSpecificCategory.children.find((category: CategorySchema) => {\n return category.displayName === segment;\n });\n\n if (!foundChild) {\n return null;\n }\n mostSpecificCategory = foundChild;\n }\n\n return mostSpecificCategory.id;\n }\n\n isFirstLevelCategory(id: ProductSchemaId): boolean {\n return this.allCategories.some((category) => category.id == id);\n }\n\n //TODO: Rename this to findCategoryById\n findCategory(id: ProductSchemaId): CategorySchema {\n for (const parent of this.allCategories) {\n if (parent.id === id) return parent;\n\n for (const child of parent.children) {\n if (child.id === id) return child;\n\n for (const grandChild of child.children) {\n if (grandChild.id === id) return grandChild;\n }\n }\n }\n\n return null;\n }\n\n findCategoryByName(name: ProductSchemaId): CategorySchema {\n for (const parent of this.allCategories) {\n if (parent.name === name) return parent;\n\n for (const child of parent.children) {\n if (child.name === name) return child;\n\n for (const grandChild of child.children) {\n if (grandChild.name === name) return grandChild;\n }\n }\n }\n\n return null;\n }\n\n findFirstLevelParentCategoryById(id: ProductSchemaId): CategorySchema {\n for (const category of this.allCategories) {\n if (category.id === id) return category;\n\n for (const child of category.children || []) {\n if (child.id === id) return category;\n\n for (const grandChild of child.children || []) {\n if (grandChild.id === id) return category;\n }\n }\n }\n\n return null;\n }\n\n findFirstLevelParentCategoryByName(name: ProductSchemaName): CategorySchema {\n for (const category of this.allCategories) {\n if (category.name === name) return category;\n\n for (const child of category.children || []) {\n if (child.name === name) return category;\n\n for (const grandChild of child.children || []) {\n if (grandChild.name === name) return category;\n }\n }\n }\n return null;\n }\n\n private isAssetManagement(): boolean {\n return this.router.url.includes(APP_PATHS.assetManagement);\n }\n\n private async fetchFilteredSchemaList(): Promise {\n const tree: CategorySchemaTree = await firstValueFrom(\n this.http.get(environment.apiUrl + '/schemas/tree?filter=true')\n );\n return tree.data[0].children;\n }\n\n private async fetchSchemaListWithProperties(): Promise {\n let params = new HttpParams();\n params = params.append('includeProperties', 'true');\n const options = { params: params };\n\n const tree: CategorySchemaTree = await firstValueFrom(\n this.http.get(environment.apiUrl + '/schemas/tree', options)\n );\n\n return tree.data[0].children;\n }\n\n private async cacheCategoryImages(): Promise {\n const downloadImage = async (url: string): Promise => {\n const response = await fetch(url);\n return await response.blob();\n };\n\n const downloadPromises = this.filteredCategories\n .filter((category) => category.thumbnailUrl)\n .map(async (category) => {\n const imageBlob = await downloadImage(category.thumbnailUrl);\n this.imageCache.set(category.thumbnailUrl, imageBlob);\n });\n await Promise.all(downloadPromises);\n }\n\n getCachedImage(url: string): Blob | undefined {\n return this.imageCache.get(url);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, zip } from 'rxjs';\nimport { saveAs } from 'file-saver';\nimport { map } from 'rxjs/operators';\nimport * as path from 'path-browserify';\n\nconst JSZip = require('jszip');\n\nimport { environment } from '../../environments/environment';\nimport { Screenshot } from '../business-domain/Screenshot';\n\n@Injectable()\nexport class ScreenshotService {\n constructor(private http: HttpClient) {}\n\n getScreenshotsByLevel(levelId: string): Observable {\n return this.http.get(`${environment.apiUrl}/levels/${levelId}/screenshots`);\n }\n\n getScreenshot(screenshotId: string, thumbnail = false): Observable {\n return this.http\n .get(`${environment.apiUrl}/screenshots/${screenshotId}`, { params: { thumbnail: String(thumbnail) } })\n .pipe(map((screenshot: { data: string }) => screenshot.data));\n }\n\n deleteScreenshot(screenshotId: string): Observable {\n return this.http.delete(`${environment.apiUrl}/screenshots/${screenshotId}`);\n }\n\n downloadScreenshots(screenshots: Screenshot[]): void {\n zip(\n ...screenshots.map((screenshot) => this.getScreenshot(screenshot.id).pipe(map((data) => ({ ...screenshot, data })))),\n ).subscribe((downloadedScreenshots) => this.saveScreenshots(downloadedScreenshots));\n }\n\n shareScreenshots(unitId: string, screenshotIds: string[]): Observable {\n return this.http\n .post<{ code: string }>(`${environment.apiUrl}/screenshots/share`, { unitId, screenshotIds })\n .pipe(map((response) => response.code));\n }\n\n // CONSUMER STUFF\n\n getConsumerScreenshotsByCode(code: string): Observable {\n return this.http.get(`${environment.apiUrl}/screenshots/consumer`, { headers: { Authorization: `Code ${code}` } });\n }\n\n getConsumerScreenshot(code: string, screenshotId: string, thumbnail = false): Observable {\n return this.http\n .get(`${environment.apiUrl}/screenshots/consumer/${screenshotId}`, {\n headers: { Authorization: `Code ${code}` },\n params: { thumbnail: String(thumbnail) },\n })\n .pipe(map((screenshot: { data: string }) => screenshot.data));\n }\n\n downloadConsumerScreenshots(code: string, screenshots: Screenshot[]): void {\n zip(\n ...screenshots.map((screenshot) => this.getConsumerScreenshot(code, screenshot.id).pipe(map((data) => ({ ...screenshot, data })))),\n ).subscribe((downloadedScreenshots) => this.saveScreenshots(downloadedScreenshots));\n }\n\n getConsumerInformation(code: string): Observable<{ projectName: string; company: string }> {\n return this.http.get<{ projectName: string; company: string }>(`${environment.apiUrl}/screenshots/consumer/information`, {\n headers: { Authorization: `Code ${code}` },\n });\n }\n\n private convertBase64ToBlobData(base64Data: string, contentType: string = 'image/png', sliceSize = 512): Blob {\n const base64String = base64Data.split(',')[1];\n const byteCharacters = atob(base64String);\n const byteArrays = [];\n\n for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {\n const slice = byteCharacters.slice(offset, offset + sliceSize);\n\n const byteNumbers = new Array(slice.length);\n for (let i = 0; i < slice.length; i++) {\n byteNumbers[i] = slice.charCodeAt(i);\n }\n\n const byteArray = new Uint8Array(byteNumbers);\n\n byteArrays.push(byteArray);\n }\n\n const blob = new Blob(byteArrays, { type: contentType });\n return blob;\n }\n\n private saveScreenshots(screenshots: { data: string; filename: string }[]) {\n if (screenshots.length > 1) {\n const zip = new JSZip();\n\n screenshots.reduce((uniqueFilenames, screenshot) => {\n const filename = this.increaseFilenameNumber(uniqueFilenames, screenshot.filename);\n\n zip.file(filename, screenshot.data.split(',')[1], { base64: true });\n\n return [...uniqueFilenames, filename];\n }, []);\n\n zip.generateAsync({ type: 'blob' }).then((zipFile) => saveAs(zipFile, 'screenshots.zip'));\n } else {\n saveAs(this.convertBase64ToBlobData(screenshots[0].data), screenshots[0].filename);\n }\n }\n\n private increaseFilenameNumber(uniqueFilenames: string[], initialFilename: string): string {\n let filename: string = initialFilename;\n let i = 1;\n\n while (uniqueFilenames.includes(filename)) {\n const extension = path.extname(initialFilename);\n const baseFilename = path.basename(initialFilename, extension);\n\n filename = baseFilename + '-' + i + extension;\n i++;\n }\n\n return filename;\n }\n}\n","import { Injectable } from '@angular/core';\n\ntype CacheClearer = () => void;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ServiceCacheService {\n private cacheClearers: CacheClearer[];\n\n constructor() {\n this.cacheClearers = [];\n }\n\n registerCacheClearer(clearer: CacheClearer) {\n this.cacheClearers.push(clearer);\n }\n\n clearCache() {\n this.cacheClearers.forEach((clearer) => clearer());\n }\n}\n","export class Stream {\n id: string;\n instanceId: string;\n createdAt: string;\n createdBy: string;\n publicIP: string;\n status: string;\n\n constructor(id: string, publicIP: string, status?: string, instanceId?: string, createdAt?: string, createdBy?: string) {\n this.id = id;\n this.instanceId = instanceId;\n this.createdAt = createdAt;\n this.createdBy = createdBy;\n this.publicIP = publicIP;\n this.status = status;\n }\n}\n","import { Injectable } from '@angular/core';\nimport { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\n\nimport { HttpClient } from '@angular/common/http';\nimport { Observable } from 'rxjs';\n\nimport { environment } from '../../environments/environment';\nimport { Stream } from '../business-domain/Stream';\n\n// import 'rxjs/add/operator/retryWhen';\nimport { map, retryWhen, delay, tap, take, first } from 'rxjs/operators';\nimport { TokenService } from './token.service';\nimport { Router, ActivatedRoute } from '@angular/router';\nimport { AuthService } from './auth.service';\n\nexport class StreamingObject {\n sessionId: string;\n publicIP: string;\n status: string;\n}\n\n@Injectable()\nexport class StreamingService {\n constructor(\n private http: HttpClient,\n private tokenService: TokenService,\n public dialog: MatDialog,\n private router: Router,\n private route: ActivatedRoute,\n private authService: AuthService\n ) {}\n\n public usePixelStream = false;\n\n public startStreaming(): Observable {\n return this.http\n .post(`${environment.apiUrl}/streaming`, {})\n .pipe(map((stream) => new Stream(stream.sessionId, stream.publicIP)));\n }\n\n public leaveStreamingSession(sessionId): Observable {\n return this.http.post(`${environment.apiUrl}/streaming/${sessionId}/leave`, {});\n }\n\n public testStreamServer(maxRetryAttempts: number): Observable {\n let i = 0;\n\n // At the moment we want only one of the streams\n return this.http.get(`${environment.apiUrl}/streaming`).pipe(\n map((stream) => {\n i++;\n if (stream[0] && stream[0].status !== 'running') {\n if (i === maxRetryAttempts) return stream[0];\n throw stream[0]; // Catched by the retrywhen\n } else {\n return stream[0];\n }\n }),\n retryWhen((errors) => errors.pipe(delay(5000), take(maxRetryAttempts)))\n );\n }\n\n public async awaitTestingStreamServer(delayTime: number): Promise {\n if (!delayTime) delayTime = 0;\n return await this.testStreamServer(1)\n .pipe(\n map((oldstream) => !!oldstream),\n delay(delayTime),\n first()\n )\n .toPromise();\n }\n\n public sendMessageToIFrame(contentWindow: Window, action: String) {\n const message = this.createMessageByAction(action);\n contentWindow.postMessage(message, '*');\n }\n\n public createMessageByAction(action: String): String {\n const message = {\n action: action,\n token: this.tokenService.getToken().value,\n };\n\n /*\n switch (action) {\n case 'ORBIT_CONTROL': {\n message.action = action;\n break;\n }\n case 'FIRST_PERSON': {\n message.action = action;\n break;\n }\n case 'LAUNCH': {\n message.action = action;\n break;\n } default: {\n throw new Error('Action is not defined');\n }\n\n }*/\n\n return JSON.stringify(message);\n }\n\n //TODO: Move this to its own service if we want to support user access checks one more routes\n hasStreamingAccess(): boolean {\n return (this.authService.hasUserGroup([environment.streamGroup]) || this.authService.getCurrentUser().admin);\n }\n\n setShowStartStreamDialog(show: boolean): void {\n window.localStorage.setItem('showStartStream', show ? '1' : '0');\n }\n\n getShowStreamingDialog(start: boolean): boolean {\n const showDialog = start ? 'showStartStream' : 'showEndStream';\n const checkValueExists = function (value: string): boolean {\n return window.localStorage.getItem(value) !== null;\n };\n\n return (\n !checkValueExists(showDialog) || !!+parseInt(window.localStorage.getItem(showDialog), 10)\n );\n }\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { Subject } from '../Subject';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function retryWhen(notifier) {\n return operate((source, subscriber) => {\n let innerSub;\n let syncResub = false;\n let errors$;\n const subscribeForRetryWhen = () => {\n innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, (err) => {\n if (!errors$) {\n errors$ = new Subject();\n innerFrom(notifier(errors$)).subscribe(createOperatorSubscriber(subscriber, () => innerSub ? subscribeForRetryWhen() : (syncResub = true)));\n }\n if (errors$) {\n errors$.next(err);\n }\n }));\n if (syncResub) {\n innerSub.unsubscribe();\n innerSub = null;\n syncResub = false;\n subscribeForRetryWhen();\n }\n };\n subscribeForRetryWhen();\n });\n}\n","import { Observable, Subscription } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { environment } from '../../environments/environment';\nimport { UrlService } from './url.service';\nimport { Token } from './token.interface';\nimport { LoginResponse } from './auth.service';\n\n// TODO QA - Could the parameter value and the storage value not be the same?\nexport const ROUTE_PARAMETER_TOKEN_KEY = 'token';\nexport const ROUTE_PARAMETER_TOKEN_EXPIRY_KEY = 'token-expiry';\n\nconst STORAGE_VALUE_KEY = 'tokenValue';\nconst STORAGE_EXPIRY_KEY = 'tokenExpiry';\n\nconst DELAY_FACTOR = 0.8;\nconst INVALID_TOKEN = 'Invalid Token';\n\n@Injectable()\nexport class TokenService {\n constructor(private http: HttpClient, private urlService: UrlService) {}\n initialize() {\n // We need to prioritize the token from the URL over the token from the local storage\n // if the expiry of the url token is later than the expiry of the local storage token.\n // In this case the token in the local storage might be from a previous session\n // with a different user.\n if (\n this.urlContainsValidToken() &&\n (!this.hasValidToken() || this.getToken().expiry < this.getTokenByUrl().expiry)\n ) {\n this.setTokenByUrl();\n } else if (this.hasValidToken()) {\n this.startRefreshTimer();\n }\n }\n\n setToken(token: Token) {\n this.isValidToken(token) ? this.setTokenToLocalStorage(token) : this.throwInvalidTokenError();\n }\n\n getToken(): Token {\n return {\n value: this.getValueFromLocalStorage(),\n expiry: this.getExpiryFromLocalStorage(),\n };\n }\n\n getSyncToken(): Observable {\n return this.http.post(environment.apiUrl + '/sync/auth', {}).pipe(\n map((response: any) => {\n return { value: response.token, expiry: response.tokenExpiry };\n })\n );\n }\n\n deleteToken() {\n window.localStorage.removeItem(STORAGE_VALUE_KEY);\n window.localStorage.removeItem(STORAGE_EXPIRY_KEY);\n }\n\n hasValidToken(): boolean {\n return this.isValidToken(this.getToken());\n }\n\n private isValidToken(token: Token): boolean {\n return token && token.value && token.expiry && this.hasRemainingTime(token);\n }\n\n private hasRemainingTime(token: Token): boolean {\n return this.calculateRemainingTime(token) >= 0;\n }\n\n private urlContainsValidToken(): boolean {\n return (\n this.urlContainsValue() && this.urlContainsExpiry() && this.isValidToken(this.getTokenByUrl())\n );\n }\n\n private urlContainsValue(): boolean {\n return this.urlService.urlContains(ROUTE_PARAMETER_TOKEN_KEY);\n }\n\n private urlContainsExpiry(): boolean {\n return this.urlService.urlContains(ROUTE_PARAMETER_TOKEN_EXPIRY_KEY);\n }\n\n private setTokenByUrl() {\n this.setToken(this.getTokenByUrl());\n }\n\n private getTokenByUrl(): Token {\n return {\n value: this.urlService.getRouteParameterValue(ROUTE_PARAMETER_TOKEN_KEY),\n expiry: this.urlService.getRouteParameterValue(ROUTE_PARAMETER_TOKEN_EXPIRY_KEY),\n };\n }\n\n private setTokenToLocalStorage(token: Token) {\n this.setValueToLocalStorage(token.value);\n this.setExpiryToLocalStorage(token.expiry);\n\n this.startRefreshTimer();\n }\n\n private setValueToLocalStorage(value: string) {\n window.localStorage.setItem(STORAGE_VALUE_KEY, value);\n }\n\n private setExpiryToLocalStorage(expiry: string) {\n window.localStorage.setItem(STORAGE_EXPIRY_KEY, expiry);\n }\n\n private getValueFromLocalStorage(): string {\n return window.localStorage.getItem(STORAGE_VALUE_KEY);\n }\n\n private getExpiryFromLocalStorage(): string {\n return window.localStorage.getItem(STORAGE_EXPIRY_KEY);\n }\n\n private startRefreshTimer() {\n setTimeout(() => {\n this.setTokenByDatabase();\n }, this.calculateRefreshTimer());\n }\n\n private calculateRefreshTimer(): number {\n return this.calculateRemainingTime(this.getToken()) * DELAY_FACTOR;\n }\n\n private calculateRemainingTime(token: Token): number {\n return Number(token.expiry) - new Date().getTime();\n }\n\n private setTokenByDatabase() {\n const sub: Subscription = this.http\n .post(environment.apiUrl + environment.sessionRefreshEndpoint, {})\n .subscribe(\n (result) => {\n const token: Token = {\n value: result.token,\n expiry: String(result.tokenExpiry),\n };\n\n this.setToken(token);\n },\n (error) => {\n this.deleteToken();\n console.error(error);\n },\n () => sub.unsubscribe()\n );\n }\n\n private throwInvalidTokenError() {\n throw new Error(INVALID_TOKEN);\n }\n}\n","
\n
\n

\n {{ data.title }}\n

\n
\n close\n
\n
\n
\n

{{ data.subtitle }}

\n

\n
\n
\n \n\n \n
\n
\n","import { Component, HostListener, Inject, OnInit } from '@angular/core';\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\nimport { TwoActionsDialogService } from '../../../services/two-actions-dialog.service';\n\n@Component({\n selector: 'two-actions-dialog',\n templateUrl: './two-actions-dialog.component.html',\n styleUrls: ['./two-actions-dialog.component.scss'],\n standalone: false\n})\nexport class TwoActionsDialogComponent implements OnInit {\n constructor(\n private dialogRef: MatDialogRef,\n private twoActionsDialogService: TwoActionsDialogService,\n @Inject(MAT_DIALOG_DATA) public data: any\n ) {}\n\n ngOnInit(): void {}\n\n public close(value) {\n this.cancel();\n this.dialogRef.close(value);\n }\n\n @HostListener('keydown.esc')\n onEsc() {\n this.close(false);\n }\n\n confirm(): void {\n this.twoActionsDialogService.setConfirmed(true);\n }\n\n cancel(): void {\n this.twoActionsDialogService.setConfirmed(false);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { MatDialog, MatDialogRef } from '@angular/material/dialog';\nimport { Observable } from 'rxjs';\nimport { map, take } from 'rxjs/operators';\nimport { TwoActionsDialogComponent } from '../components/dialogs/two-actions-dialog/two-actions-dialog.component';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TwoActionsDialogService {\n constructor(private dialog: MatDialog) {}\n\n private dialogRef: MatDialogRef;\n private confirmed;\n\n public openDialog(options) {\n this.dialogRef = this.dialog.open(TwoActionsDialogComponent, {\n autoFocus: false,\n backdropClass: 'backdropBackground',\n data: options,\n });\n }\n\n public setConfirmed(confirmed: boolean) {\n this.confirmed = confirmed;\n }\n\n public result(): Observable {\n return this.dialogRef.afterClosed().pipe(\n take(1),\n map(() => this.confirmed)\n );\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, from } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport * as QRCode from 'qrcode';\nimport { Unit } from '../business-domain/Unit';\nimport { environment } from './../../environments/environment';\n\ninterface Response {\n data: T;\n}\n\n@Injectable()\nexport class UnitService {\n constructor(private http: HttpClient) {}\n\n public getUnit(unitId: string): Observable {\n return this.http.get(environment.apiUrl + '/units/' + unitId);\n }\n\n public getUnitsByProject(projectId: string): Observable {\n return this.http\n .get>(environment.apiUrl + `/projects/${projectId}/units`)\n .pipe(map((response) => response.data)) as Observable;\n }\n\n public insertUnit(unit: Unit): Observable {\n return this.http.post(environment.apiUrl + '/units', { ...unit });\n }\n\n public updateUnit(unitId: string, unit): Observable {\n return this.http.put(environment.apiUrl + '/units/' + unitId, { ...unit });\n }\n\n public deleteUnit(unitId: string): Observable {\n return this.http.delete(environment.apiUrl + '/units/' + unitId);\n }\n\n public generateQRCode(unitId: string): Observable {\n const arUrl = `${/^https?:\\/\\//i.test(environment.apiUrl) ? '' : window.location.origin}${environment.apiUrl}/units/${unitId}/ar/`;\n\n return from(QRCode.toDataURL(arUrl, { type: 'image/png' }));\n }\n\n public getActorSlotsOfUnit(unitId: string): Observable {\n return this.http.get(environment.apiUrl + '/units/' + unitId + '/actorSlots');\n }\n\n public addMaterialPreselectionToActorSlots(actorSlotIds: Array, materialId: string): Observable {\n return this.http.post(environment.apiUrl + '/actorSlots/' + actorSlotIds[0] + '/preSelections/globalAdd', {\n ids: actorSlotIds,\n data: [{ materialId: materialId, favorite: false }],\n });\n }\n}\n","import { Injectable } from '@angular/core';\n\ndeclare const ue: {\n interface: {\n broadcast(name: string, data?: any): void;\n // callFromUnreal(path: any):void;\n };\n};\n\ndeclare const ue4: typeof ue.interface.broadcast;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class UnrealService {\n constructor() {\n this.setupUnrealCalls();\n }\n\n private setupUnrealCalls() {\n // To call this method from Unreal you only have to use the WebInterface.call method and provide the method-name\n // as the first parameter. Here the name would be \"callFromUnreal\".\n // The Data you want to send from Unreal must be parsed first to a JSON value.\n // ue.interface.callFromUnreal = async (data: any) => {\n // What should happen when called from Unreal\n // };\n }\n\n beforeDialogOpen() {\n ue4('before_dialog_open');\n }\n\n afterDialogOpen() {\n ue4('after_dialog_open');\n }\n\n emitFavoriteAdded(assetId: string, preselectionId: string) {\n ue4('favorite_added', { assetId: assetId, preselectionId: preselectionId });\n }\n\n emitFavoriteDeleted(preselectionId: string) {\n ue4('favorite_deleted', { preselectionId: preselectionId });\n }\n\n emitFavoritesDeletedBySchema(schemaId: string) {\n ue4('favorites_deleted_by_schema', { schemaId: schemaId });\n }\n\n emitGoogleAnalyticsEvent(event) {\n ue4('send_to_google_analytics', { event: event });\n }\n\n emitExcelExportEventToUnreal(configurationId: string) {\n ue4('open_excel_export', { configurationId: configurationId });\n }\n\n emitJumpToActor(actorSlotId: string, actorId: string) {\n ue4('jump_to_actor', { actorSlotId: actorSlotId, actorId: actorId });\n }\n\n emitOpenURL(url: string) {\n ue4('open_url', { url: url });\n }\n}\n","import { Injectable } from '@angular/core';\n\nexport const SEPARATOR = '/';\n\n/*\n * This service should only be used temporary. Instead the navigation service should be used,\n * which itself should rely on angular location to extract the query parameters.\n * For now the parameters we extract are route parameters, see navigation service comment - at the bottom.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class UrlService {\n constructor() {}\n\n getUrl(): string {\n return decodeURI(window.location.href);\n }\n\n getBaseUrl(): string {\n return document.location.origin;\n }\n\n urlContains(path: string): boolean {\n return this.getUrl().includes(path);\n }\n\n logUrl() {\n console.log('Url: ', this.getUrl());\n }\n\n removePatternFromUrl(regex: RegExp): string {\n return window.location.href.replace(regex, '');\n }\n\n // Bad solution. It does not handle the use of multiple occurrences of the key or if it is used as query parameter\n getRouteParameterValue(key: string): string {\n const url = this.getUrl();\n const keyWithSeparator = key + SEPARATOR;\n\n const startIndex = url.indexOf(keyWithSeparator);\n const keyEndIndex = startIndex + keyWithSeparator.length;\n const endIndex = url.indexOf(SEPARATOR, keyEndIndex);\n\n const containsKey = startIndex !== -1;\n const containsSeparatorAfterValue = endIndex !== -1;\n\n if (containsKey) {\n if (containsSeparatorAfterValue) {\n return url.substring(keyEndIndex, endIndex);\n } else {\n return url.substring(keyEndIndex);\n }\n } else {\n return '';\n }\n }\n\n removeRouteParameters(keys: string[]): string {\n let result = this.getUrl();\n\n for (const key of keys) {\n result = this.removeRouteParameter(result, key);\n }\n\n return result;\n }\n\n private removeRouteParameter(url: string, key: string): string {\n const keyWithSeparator = key + SEPARATOR;\n\n const startIndex = url.indexOf(keyWithSeparator);\n const keyEndIndex = startIndex + keyWithSeparator.length;\n const endIndex = url.indexOf(SEPARATOR, keyEndIndex);\n\n const containsKey = startIndex !== -1;\n const containsSeparatorAfterValue = endIndex !== -1;\n\n let value;\n let routeParameter;\n\n if (containsKey) {\n if (containsSeparatorAfterValue) {\n value = url.substring(keyEndIndex, endIndex);\n routeParameter = keyWithSeparator + value + SEPARATOR;\n url = url.replace(routeParameter, '');\n } else {\n value = url.substring(keyEndIndex);\n routeParameter = keyWithSeparator + value;\n url = url.replace(routeParameter, '');\n }\n }\n\n return url;\n }\n}\n","import { Injectable } from '@angular/core';\n\n@Injectable()\nexport class UtilityService {\n public calculateColsFromWidth(width: number): number {\n if (width < 800) {\n return 1;\n } else if (width < 1200) {\n return 2;\n } else if (width < 1700) {\n return 3;\n } else if (width < 2400) {\n return 4;\n } else if (width < 3200) {\n return 5;\n } else {\n return 6;\n }\n }\n}\n","import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { environment } from '../../environments/environment';\nimport { Version } from '../business-domain/Version';\nimport { AuthService } from './auth.service';\n\n@Injectable()\nexport class VersionService {\n constructor(private http: HttpClient, private authService: AuthService) {}\n\n getLatestVersion() {\n let promise = new Promise((resolve, reject) => {\n let link = environment.apiUrl + '/versions/latest';\n this.http\n .get(link)\n .toPromise()\n .then(\n res => {\n resolve(res);\n },\n error => {\n reject(error.message);\n },\n );\n });\n return promise;\n }\n\n async downloadApplicationWithCode(code: string) {\n const hasValidCode = this.authService.isValidCode(code).subscribe(async res => {\n console.log(res);\n if (res) {\n const path = (await this.getLatestVersion()).path;\n var link = document.createElement('a');\n link.setAttribute('href', path);\n link.click();\n // we have to wait otherwise the page will close before the download starts\n await new Promise(resolve => setTimeout(resolve, 500));\n window.close();\n }\n });\n }\n}\n","
\n \n \n {{ option.label }}\n \n \n expand_more\n
\n","import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';\n\n//TODO: There might be a simpler alternative to these onClick functions\n// Could we use a two-way-binding like the following?\n/*\n \n \n {{option.label}}\n \n \n */\nexport interface DropdownOption {\n label: string;\n onClick: () => void;\n}\n\nexport interface DropdownConfiguration {\n isDisabled: boolean;\n title: string;\n placeholder: string;\n options: DropdownOption[];\n selectedItemIndex: number;\n autoWidth: boolean; \n}\n\nexport const DEFAULT_DROPDOWN_CONFIGURATION: DropdownConfiguration = {\n isDisabled: false,\n selectedItemIndex: null,\n title: 'Title',\n placeholder: 'Option auswählen',\n options: [],\n autoWidth: false,\n};\n\n@Component({\n selector: 'dropdown',\n templateUrl: './dropdown.component.html',\n styleUrls: ['./dropdown.component.scss'],\n standalone: false\n})\nexport class DropdownComponent {\n @Input() configuration: DropdownConfiguration;\n\n selectedItem: DropdownOption;\n \n // Handles async initialization of the configuration\n ngOnChanges(changes: SimpleChanges) {\n if (changes.configuration) {\n this.initializeSelectedItem();\n }\n }\n\n onSelectionChange(selectedItem: DropdownOption) {\n this.selectedItem = selectedItem;\n this.selectedItem.onClick();\n }\n\n private initializeSelectedItem() {\n if (this.configuration) this.selectedItem = this.configuration.options[this.configuration.selectedItemIndex];\n }\n}\n","
\n \n \n \n
\n \n \n \n \n Grundrisse\n
BETA
\n
\n Bemusterung\n \n\n \n Mehrkeyboard_arrow_down\n \n \n\n \n \n \n
\n\n \n \n \n\n \n
\n \n \n PORTER Grundrisse\n
BETA
\n \n \n \n \n \n \n \n
\n
\n \n \n\n \n
\n \n \n \n
\n help_center\n Help- & Supportcenter\n
\n
\n \n\n \n \n
\n \n person\n {{ user.company }}\n \n keyboard_arrow_down\n
\n \n
\n
\n
\n\n \n \n \n \n \n \n Abmelden\n \n \n
\n","import { Component, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';\nimport { filter } from 'rxjs/operators';\n\nimport { Project } from '../../../business-domain/Project';\nimport { BaseComponent } from '../../../components/base-component/base-component.component';\nimport { AuthService } from '../../../services/auth.service';\nimport { EnvironmentService } from '../../../services/environment.service';\nimport { ExporterPluginService } from '../../../services/exporter-plugin.service';\nimport { IconRegistryService } from '../../../services/icon-registry.service';\nimport { UrlService } from '../../../services/url.service';\nimport { NavigationService, Page } from '../../../services/navigation.service';\n\nimport { NavigationEnd, Router } from '@angular/router';\nimport { Subscription } from 'rxjs';\nimport { PixelStreamingService } from '../../../modules/visualization/services/pixel-streaming.service';\n\ntype ActiveLinks = {\n productManagement: boolean;\n productCatalog: boolean;\n buildingProjects: boolean;\n visualization: boolean;\n};\n\nconst DOWNLOAD_ICON_NAME = 'download';\nconst PORTER_ICON_NAME = 'porter-logo';\nconst PORTER_WORDMARK_ICON_NAME = 'porter-wortmarke';\nconst FINGERHAUS_LOGO_ICON_NAME = 'fingerhaus-logo';\n\nconst DOWNLOAD_ICON_URL = 'assets/icons/download-icon.svg';\nconst PORTER_ICON_URL = 'assets/icons/porter-logo.svg';\nconst PORTER_WORDMARK_URL = 'assets/icons/porter-wortmarke.svg';\nconst FINGERHAUS_LOGO_URL = 'assets/icons/fingerhaus-logo.svg';\n\nconst FLOOR_PLAN_EDITOR_PATH = 'grundriss-editor';\nconst CONFIGURATION_PATH = 'bemusterung';\n\nconst FLOOR_PLAN_URL = '/grundrisse';\n\n@Component({\n selector: 'app-top-menu',\n templateUrl: './top-menu.component.html',\n styleUrls: ['./top-menu.component.scss'],\n encapsulation: ViewEncapsulation.None,\n standalone: false\n})\nexport class TopMenuComponent extends BaseComponent implements OnInit, OnDestroy {\n @Input()\n projectName: string;\n @Input()\n newProjects: Project[];\n\n hideProfileMenu: boolean;\n usesExportPlugin: boolean;\n routerFloorPlanLink: string;\n \n isLinkActive: ActiveLinks;\n subscriptionsUntilDestroy: Subscription[];\n\n constructor(\n protected environment: EnvironmentService,\n protected auth: AuthService,\n private readonly iconRegistry: IconRegistryService,\n private readonly exportPluginService: ExporterPluginService,\n private readonly urlService: UrlService,\n private readonly navigationService: NavigationService,\n private readonly router: Router ,\n private readonly pixelStreamingService: PixelStreamingService\n ) {\n super(environment, auth);\n this.hideProfileMenu = this.isEmbeddedAsIframe();\n this.usesExportPlugin = this.exportPluginService.usesExportPlugin;\n this.routerFloorPlanLink = FLOOR_PLAN_URL;\n this.subscriptionsUntilDestroy = [];\n\n this.registerIcons();\n }\n\n ngOnInit() {\n this.subscribeToNavigationEnd();\n this.updateActiveLinks();\n }\n\n ngOnDestroy() {\n this.subscriptionsUntilDestroy.forEach((subscription) => subscription.unsubscribe());\n }\n\n get authenticated(): boolean {\n return this.auth.isAuthenticated();\n }\n\n logout() {\n this.auth.logout();\n this.pixelStreamingService.disconnect();\n }\n\n shouldShowHelpAndSupportButton(): boolean {\n return (\n this.userGroups.licences.isAi ||\n this.userGroups.licences.isPorter ||\n this.userGroups.licences.isManufacturer ||\n this.user.admin\n );\n }\n\n isProductManagementAccessible(): boolean {\n return (\n this.userGroups.fingerhaus.isAdmin ||\n this.userGroups.fingerhaus.isProductManager ||\n this.userGroups.fingerhaus.isConsultant\n );\n }\n\n isProductCatalogAccessible(): boolean {\n return !this.userGroups.fingerhaus.isProductManager && !this.userGroups.fingerhaus.isConsultant;\n }\n\n isInFloorplanEditor(): boolean {\n return this.urlService.urlContains(FLOOR_PLAN_EDITOR_PATH);\n }\n\n isInConfiguration(): boolean {\n return this.urlService.urlContains(CONFIGURATION_PATH);\n }\n\n async navigateToProductManagement() {\n await this.navigationService.navigateTo(Page.MANAGEMENT);\n }\n\n async navigateToProductCatalog() {\n await this.navigationService.navigateTo(Page.CATALOG);\n }\n\n async navigateToBuildingProjects() {\n await this.navigationService.navigateTo(Page.BUILDING_PROJECTS);\n }\n\n async navigateToVisualization() {\n await this.navigationService.navigateTo(Page.VISUALIZATION);\n }\n\n private registerIcons() {\n this.iconRegistry.register(DOWNLOAD_ICON_NAME, DOWNLOAD_ICON_URL);\n this.iconRegistry.register(PORTER_ICON_NAME, PORTER_ICON_URL);\n this.iconRegistry.register(PORTER_WORDMARK_ICON_NAME, PORTER_WORDMARK_URL);\n this.iconRegistry.register(FINGERHAUS_LOGO_ICON_NAME, FINGERHAUS_LOGO_URL);\n }\n\n isFingerhaus(): boolean {\n return this.environment.isFingerhaus();\n }\n\n private subscribeToNavigationEnd() {\n const subscription = this.router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(async () => {\n this.updateActiveLinks();\n });\n\n this.subscriptionsUntilDestroy.push(subscription);\n }\n\n private updateActiveLinks() {\n this.isLinkActive = {\n productManagement: this.navigationService.isAssetManagement(),\n productCatalog: this.navigationService.isAssetCatalog(),\n buildingProjects: this.navigationService.isBuildingProjects(),\n visualization: this.navigationService.isVisualization(),\n };\n }\n}\n","import { Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-signup-footer',\n templateUrl: './signup-footer.component.html',\n styleUrls: ['./signup-footer.component.scss'],\n standalone: false\n})\nexport class SignupFooterComponent implements OnInit {\n constructor() {}\n\n ngOnInit(): void {}\n}\n","\n","export const FEATURE_FLAGS = {\r\n floorplansOverview: 'FLOORPLANS_OVERVIEW',\r\n buildingProjectsOverview: 'BUILDING_PROJECTS_OVERVIEW',\r\n roomPreselection: 'PRESELECTION_ROOMS',\r\n pixelStreaming: 'PIXELSTREAMING',\r\n categoryOverview: 'CATEGORY_OVERVIEW',\r\n};\r\n","import { NgModule } from '@angular/core';\nimport { Routes, RouterModule } from '@angular/router';\n\nconst routes: Routes = [];\n\n@NgModule({\n imports: [RouterModule.forChild(routes)],\n exports: [RouterModule],\n})\nexport class SharedRoutingModule {}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatCheckboxModule } from '@angular/material/checkbox';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatMenuModule } from '@angular/material/menu';\nimport { MatSelectModule } from '@angular/material/select';\nimport { MatToolbarModule } from '@angular/material/toolbar';\nimport { MatTooltipModule } from '@angular/material/tooltip';\nimport { AlertDirective } from '../directives/alert.directive';\nimport { DragDropDirective } from './directives/dragndrop.directive';\nimport { ShowTooltipIfTruncatedDirective } from './directives/show-tooltip-if-truncated.directive';\nimport { SharedRoutingModule } from './shared-routing.module';\n\nimport { ModalComponent } from '../components/modal/modal.component';\nimport { SupportButtonComponent } from '../components/support-button/support-button.component';\nimport { HasFeatureFlagDirective } from '../directives/has-feature-flag.directive';\nimport { DropdownComponent } from './components/dropdown/dropdown.component';\nimport { TopMenuComponent } from './components/menus/top-menu.component';\nimport { NavigationBarComponent } from './components/navigation-bar/navigation-bar.component';\nimport { ProductNoteComponent } from './components/product-note/product-note.component';\nimport { ProjectFormComponent } from './components/project-form/project-form.component';\nimport { QuickMenuComponent } from './components/quickmenu/quick-menu.component';\nimport { RoomSelectorComponent } from './components/room-selector/room-selector.component';\nimport { SignupFooterComponent } from './components/signup-footer/signup-footer.component';\nimport { HasNotFeatureFlagDirective } from '../directives/has-not-feature-flag.directive';\n\n@NgModule({\n declarations: [\n AlertDirective,\n ShowTooltipIfTruncatedDirective,\n TopMenuComponent,\n ProjectFormComponent,\n DragDropDirective,\n ModalComponent,\n NavigationBarComponent,\n SignupFooterComponent,\n DropdownComponent,\n QuickMenuComponent,\n SupportButtonComponent,\n ProductNoteComponent,\n HasFeatureFlagDirective,\n HasNotFeatureFlagDirective,\n RoomSelectorComponent,\n ],\n imports: [\n CommonModule,\n ReactiveFormsModule,\n FormsModule,\n SharedRoutingModule,\n MatMenuModule,\n MatToolbarModule,\n MatIconModule,\n MatButtonModule,\n MatFormFieldModule,\n MatInputModule,\n MatSelectModule,\n MatCheckboxModule,\n MatTooltipModule,\n ],\n exports: [\n TopMenuComponent,\n ProjectFormComponent,\n DragDropDirective,\n ShowTooltipIfTruncatedDirective,\n AlertDirective,\n ModalComponent,\n NavigationBarComponent,\n SignupFooterComponent,\n DropdownComponent,\n QuickMenuComponent,\n SupportButtonComponent,\n ProductNoteComponent,\n HasFeatureFlagDirective,\n HasNotFeatureFlagDirective,\n RoomSelectorComponent,\n ],\n})\nexport class SharedModule {}\n","import { Injectable } from '@angular/core';\nimport { CanActivate, ActivatedRouteSnapshot, Data } from '@angular/router';\nimport { AuthService } from './services/auth.service';\nimport { NavigationService } from './services/navigation.service';\n\n@Injectable()\nexport class UserGroupGuard implements CanActivate {\n constructor(\n private readonly authService: AuthService,\n private readonly navigationService: NavigationService\n ) {}\n\n async canActivate(next: ActivatedRouteSnapshot): Promise {\n const data = next.data;\n\n if (this.isUserAuthorized(data)) {\n return true;\n } \n\n await this.navigationService.guardNavigation(next);\n return false;\n }\n\n private hasRequiredUserGroup(data: Data): boolean {\n const userGroup = data?.userGroup;\n return !!userGroup && this.authService.hasUserGroup(userGroup);\n }\n\n private isUserAuthorized(data: Data): boolean {\n return (this.hasRequiredUserGroup(data)) || this.authService.getCurrentUser().admin;\n }\n}\n","export const environment = {\n local: false,\n production: true,\n baseUrl: 'https://app.porter.de',\n apiUrl: 'https://app.porter.de/api',\n pixelStreamingSessionUrl: 'wss://app.porter.de/streaming/session',\n envSystem: 'Production',\n customerSystem: '',\n\n usersEndpoint: '/users',\n sessionsEndpoint: '/sessions',\n sessionRefreshEndpoint: '/sessions/refresh',\n projectEndpoint: '/projects/:projectId',\n projectsEndpoint: '/projects',\n adminGroup: 'admin',\n streamGroup: 'pixelstreaming',\n AI_LICENCE_GROUPS: [\n 'ai-entry',\n 'ai-basic',\n 'ai-professional',\n 'ai-professional-plus',\n 'ai-enterprise-solution',\n ],\n STREAMING_LICENCE_GROUP: ['pixelstreaming', 'porter-expert'],\n PORTER_LICENCE_GROUPS: ['porter-entry', 'porter-professional', 'porter-expert'],\n PORTER_MANUFACTURER_GROUPS: ['porter-elements'],\n FINGERHAUS_ADMIN_GROUP: ['fingerhaus-admin'],\n FINGERHAUS_CONSULTANT_GROUP: ['fingerhaus-berater'],\n FINGERHAUS_PRODUCT_MANAGEMENT_GROUP: ['fingerhaus-artikelpflege'],\n FINGERHAUS_BUILDER: ['fingerhaus-user'],\n AI_ALPHA_GROUP: ['admin', 'ai-alpha'],\n READ_ONLY_GROUP: ['fhReadOnly'],\n\n qrGroup: 'porter-qr-scan',\n\n consumerEndpoint: '/consumer',\n};\n","/**\n * @license Angular v19.0.6\n * (c) 2010-2024 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport { ɵAnimationGroupPlayer, NoopAnimationPlayer, AUTO_STYLE, ɵPRE_STYLE, sequence, AnimationMetadataType, style } from '@angular/animations';\nimport * as i0 from '@angular/core';\nimport { ɵRuntimeError, Injectable } from '@angular/core';\n\nconst LINE_START = '\\n - ';\nfunction invalidTimingValue(exp) {\n return new ɵRuntimeError(3000 /* RuntimeErrorCode.INVALID_TIMING_VALUE */, ngDevMode && `The provided timing value \"${exp}\" is invalid.`);\n}\nfunction negativeStepValue() {\n return new ɵRuntimeError(3100 /* RuntimeErrorCode.NEGATIVE_STEP_VALUE */, ngDevMode && 'Duration values below 0 are not allowed for this animation step.');\n}\nfunction negativeDelayValue() {\n return new ɵRuntimeError(3101 /* RuntimeErrorCode.NEGATIVE_DELAY_VALUE */, ngDevMode && 'Delay values below 0 are not allowed for this animation step.');\n}\nfunction invalidStyleParams(varName) {\n return new ɵRuntimeError(3001 /* RuntimeErrorCode.INVALID_STYLE_PARAMS */, ngDevMode &&\n `Unable to resolve the local animation param ${varName} in the given list of values`);\n}\nfunction invalidParamValue(varName) {\n return new ɵRuntimeError(3003 /* RuntimeErrorCode.INVALID_PARAM_VALUE */, ngDevMode && `Please provide a value for the animation param ${varName}`);\n}\nfunction invalidNodeType(nodeType) {\n return new ɵRuntimeError(3004 /* RuntimeErrorCode.INVALID_NODE_TYPE */, ngDevMode && `Unable to resolve animation metadata node #${nodeType}`);\n}\nfunction invalidCssUnitValue(userProvidedProperty, value) {\n return new ɵRuntimeError(3005 /* RuntimeErrorCode.INVALID_CSS_UNIT_VALUE */, ngDevMode && `Please provide a CSS unit value for ${userProvidedProperty}:${value}`);\n}\nfunction invalidTrigger() {\n return new ɵRuntimeError(3006 /* RuntimeErrorCode.INVALID_TRIGGER */, ngDevMode &&\n \"animation triggers cannot be prefixed with an `@` sign (e.g. trigger('@foo', [...]))\");\n}\nfunction invalidDefinition() {\n return new ɵRuntimeError(3007 /* RuntimeErrorCode.INVALID_DEFINITION */, ngDevMode && 'only state() and transition() definitions can sit inside of a trigger()');\n}\nfunction invalidState(metadataName, missingSubs) {\n return new ɵRuntimeError(3008 /* RuntimeErrorCode.INVALID_STATE */, ngDevMode &&\n `state(\"${metadataName}\", ...) must define default values for all the following style substitutions: ${missingSubs.join(', ')}`);\n}\nfunction invalidStyleValue(value) {\n return new ɵRuntimeError(3002 /* RuntimeErrorCode.INVALID_STYLE_VALUE */, ngDevMode && `The provided style string value ${value} is not allowed.`);\n}\nfunction invalidProperty(prop) {\n return new ɵRuntimeError(3009 /* RuntimeErrorCode.INVALID_PROPERTY */, ngDevMode &&\n `The provided animation property \"${prop}\" is not a supported CSS property for animations`);\n}\nfunction invalidParallelAnimation(prop, firstStart, firstEnd, secondStart, secondEnd) {\n return new ɵRuntimeError(3010 /* RuntimeErrorCode.INVALID_PARALLEL_ANIMATION */, ngDevMode &&\n `The CSS property \"${prop}\" that exists between the times of \"${firstStart}ms\" and \"${firstEnd}ms\" is also being animated in a parallel animation between the times of \"${secondStart}ms\" and \"${secondEnd}ms\"`);\n}\nfunction invalidKeyframes() {\n return new ɵRuntimeError(3011 /* RuntimeErrorCode.INVALID_KEYFRAMES */, ngDevMode && `keyframes() must be placed inside of a call to animate()`);\n}\nfunction invalidOffset() {\n return new ɵRuntimeError(3012 /* RuntimeErrorCode.INVALID_OFFSET */, ngDevMode && `Please ensure that all keyframe offsets are between 0 and 1`);\n}\nfunction keyframeOffsetsOutOfOrder() {\n return new ɵRuntimeError(3200 /* RuntimeErrorCode.KEYFRAME_OFFSETS_OUT_OF_ORDER */, ngDevMode && `Please ensure that all keyframe offsets are in order`);\n}\nfunction keyframesMissingOffsets() {\n return new ɵRuntimeError(3202 /* RuntimeErrorCode.KEYFRAMES_MISSING_OFFSETS */, ngDevMode && `Not all style() steps within the declared keyframes() contain offsets`);\n}\nfunction invalidStagger() {\n return new ɵRuntimeError(3013 /* RuntimeErrorCode.INVALID_STAGGER */, ngDevMode && `stagger() can only be used inside of query()`);\n}\nfunction invalidQuery(selector) {\n return new ɵRuntimeError(3014 /* RuntimeErrorCode.INVALID_QUERY */, ngDevMode &&\n `\\`query(\"${selector}\")\\` returned zero elements. (Use \\`query(\"${selector}\", { optional: true })\\` if you wish to allow this.)`);\n}\nfunction invalidExpression(expr) {\n return new ɵRuntimeError(3015 /* RuntimeErrorCode.INVALID_EXPRESSION */, ngDevMode && `The provided transition expression \"${expr}\" is not supported`);\n}\nfunction invalidTransitionAlias(alias) {\n return new ɵRuntimeError(3016 /* RuntimeErrorCode.INVALID_TRANSITION_ALIAS */, ngDevMode && `The transition alias value \"${alias}\" is not supported`);\n}\nfunction validationFailed(errors) {\n return new ɵRuntimeError(3500 /* RuntimeErrorCode.VALIDATION_FAILED */, ngDevMode && `animation validation failed:\\n${errors.map((err) => err.message).join('\\n')}`);\n}\nfunction buildingFailed(errors) {\n return new ɵRuntimeError(3501 /* RuntimeErrorCode.BUILDING_FAILED */, ngDevMode && `animation building failed:\\n${errors.map((err) => err.message).join('\\n')}`);\n}\nfunction triggerBuildFailed(name, errors) {\n return new ɵRuntimeError(3404 /* RuntimeErrorCode.TRIGGER_BUILD_FAILED */, ngDevMode &&\n `The animation trigger \"${name}\" has failed to build due to the following errors:\\n - ${errors\n .map((err) => err.message)\n .join('\\n - ')}`);\n}\nfunction animationFailed(errors) {\n return new ɵRuntimeError(3502 /* RuntimeErrorCode.ANIMATION_FAILED */, ngDevMode &&\n `Unable to animate due to the following errors:${LINE_START}${errors\n .map((err) => err.message)\n .join(LINE_START)}`);\n}\nfunction registerFailed(errors) {\n return new ɵRuntimeError(3503 /* RuntimeErrorCode.REGISTRATION_FAILED */, ngDevMode &&\n `Unable to build the animation due to the following errors: ${errors\n .map((err) => err.message)\n .join('\\n')}`);\n}\nfunction missingOrDestroyedAnimation() {\n return new ɵRuntimeError(3300 /* RuntimeErrorCode.MISSING_OR_DESTROYED_ANIMATION */, ngDevMode && \"The requested animation doesn't exist or has already been destroyed\");\n}\nfunction createAnimationFailed(errors) {\n return new ɵRuntimeError(3504 /* RuntimeErrorCode.CREATE_ANIMATION_FAILED */, ngDevMode &&\n `Unable to create the animation due to the following errors:${errors\n .map((err) => err.message)\n .join('\\n')}`);\n}\nfunction missingPlayer(id) {\n return new ɵRuntimeError(3301 /* RuntimeErrorCode.MISSING_PLAYER */, ngDevMode && `Unable to find the timeline player referenced by ${id}`);\n}\nfunction missingTrigger(phase, name) {\n return new ɵRuntimeError(3302 /* RuntimeErrorCode.MISSING_TRIGGER */, ngDevMode &&\n `Unable to listen on the animation trigger event \"${phase}\" because the animation trigger \"${name}\" doesn\\'t exist!`);\n}\nfunction missingEvent(name) {\n return new ɵRuntimeError(3303 /* RuntimeErrorCode.MISSING_EVENT */, ngDevMode &&\n `Unable to listen on the animation trigger \"${name}\" because the provided event is undefined!`);\n}\nfunction unsupportedTriggerEvent(phase, name) {\n return new ɵRuntimeError(3400 /* RuntimeErrorCode.UNSUPPORTED_TRIGGER_EVENT */, ngDevMode &&\n `The provided animation trigger event \"${phase}\" for the animation trigger \"${name}\" is not supported!`);\n}\nfunction unregisteredTrigger(name) {\n return new ɵRuntimeError(3401 /* RuntimeErrorCode.UNREGISTERED_TRIGGER */, ngDevMode && `The provided animation trigger \"${name}\" has not been registered!`);\n}\nfunction triggerTransitionsFailed(errors) {\n return new ɵRuntimeError(3402 /* RuntimeErrorCode.TRIGGER_TRANSITIONS_FAILED */, ngDevMode &&\n `Unable to process animations due to the following failed trigger transitions\\n ${errors\n .map((err) => err.message)\n .join('\\n')}`);\n}\nfunction triggerParsingFailed(name, errors) {\n return new ɵRuntimeError(3403 /* RuntimeErrorCode.TRIGGER_PARSING_FAILED */, ngDevMode &&\n `Animation parsing for the ${name} trigger have failed:${LINE_START}${errors\n .map((err) => err.message)\n .join(LINE_START)}`);\n}\nfunction transitionFailed(name, errors) {\n return new ɵRuntimeError(3505 /* RuntimeErrorCode.TRANSITION_FAILED */, ngDevMode && `@${name} has failed due to:\\n ${errors.map((err) => err.message).join('\\n- ')}`);\n}\n\n/**\n * Set of all animatable CSS properties\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties\n */\nconst ANIMATABLE_PROP_SET = new Set([\n '-moz-outline-radius',\n '-moz-outline-radius-bottomleft',\n '-moz-outline-radius-bottomright',\n '-moz-outline-radius-topleft',\n '-moz-outline-radius-topright',\n '-ms-grid-columns',\n '-ms-grid-rows',\n '-webkit-line-clamp',\n '-webkit-text-fill-color',\n '-webkit-text-stroke',\n '-webkit-text-stroke-color',\n 'accent-color',\n 'all',\n 'backdrop-filter',\n 'background',\n 'background-color',\n 'background-position',\n 'background-size',\n 'block-size',\n 'border',\n 'border-block-end',\n 'border-block-end-color',\n 'border-block-end-width',\n 'border-block-start',\n 'border-block-start-color',\n 'border-block-start-width',\n 'border-bottom',\n 'border-bottom-color',\n 'border-bottom-left-radius',\n 'border-bottom-right-radius',\n 'border-bottom-width',\n 'border-color',\n 'border-end-end-radius',\n 'border-end-start-radius',\n 'border-image-outset',\n 'border-image-slice',\n 'border-image-width',\n 'border-inline-end',\n 'border-inline-end-color',\n 'border-inline-end-width',\n 'border-inline-start',\n 'border-inline-start-color',\n 'border-inline-start-width',\n 'border-left',\n 'border-left-color',\n 'border-left-width',\n 'border-radius',\n 'border-right',\n 'border-right-color',\n 'border-right-width',\n 'border-start-end-radius',\n 'border-start-start-radius',\n 'border-top',\n 'border-top-color',\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-top-width',\n 'border-width',\n 'bottom',\n 'box-shadow',\n 'caret-color',\n 'clip',\n 'clip-path',\n 'color',\n 'column-count',\n 'column-gap',\n 'column-rule',\n 'column-rule-color',\n 'column-rule-width',\n 'column-width',\n 'columns',\n 'filter',\n 'flex',\n 'flex-basis',\n 'flex-grow',\n 'flex-shrink',\n 'font',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-variation-settings',\n 'font-weight',\n 'gap',\n 'grid-column-gap',\n 'grid-gap',\n 'grid-row-gap',\n 'grid-template-columns',\n 'grid-template-rows',\n 'height',\n 'inline-size',\n 'input-security',\n 'inset',\n 'inset-block',\n 'inset-block-end',\n 'inset-block-start',\n 'inset-inline',\n 'inset-inline-end',\n 'inset-inline-start',\n 'left',\n 'letter-spacing',\n 'line-clamp',\n 'line-height',\n 'margin',\n 'margin-block-end',\n 'margin-block-start',\n 'margin-bottom',\n 'margin-inline-end',\n 'margin-inline-start',\n 'margin-left',\n 'margin-right',\n 'margin-top',\n 'mask',\n 'mask-border',\n 'mask-position',\n 'mask-size',\n 'max-block-size',\n 'max-height',\n 'max-inline-size',\n 'max-lines',\n 'max-width',\n 'min-block-size',\n 'min-height',\n 'min-inline-size',\n 'min-width',\n 'object-position',\n 'offset',\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n 'opacity',\n 'order',\n 'outline',\n 'outline-color',\n 'outline-offset',\n 'outline-width',\n 'padding',\n 'padding-block-end',\n 'padding-block-start',\n 'padding-bottom',\n 'padding-inline-end',\n 'padding-inline-start',\n 'padding-left',\n 'padding-right',\n 'padding-top',\n 'perspective',\n 'perspective-origin',\n 'right',\n 'rotate',\n 'row-gap',\n 'scale',\n 'scroll-margin',\n 'scroll-margin-block',\n 'scroll-margin-block-end',\n 'scroll-margin-block-start',\n 'scroll-margin-bottom',\n 'scroll-margin-inline',\n 'scroll-margin-inline-end',\n 'scroll-margin-inline-start',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n 'scroll-padding',\n 'scroll-padding-block',\n 'scroll-padding-block-end',\n 'scroll-padding-block-start',\n 'scroll-padding-bottom',\n 'scroll-padding-inline',\n 'scroll-padding-inline-end',\n 'scroll-padding-inline-start',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n 'scroll-snap-coordinate',\n 'scroll-snap-destination',\n 'scrollbar-color',\n 'shape-image-threshold',\n 'shape-margin',\n 'shape-outside',\n 'tab-size',\n 'text-decoration',\n 'text-decoration-color',\n 'text-decoration-thickness',\n 'text-emphasis',\n 'text-emphasis-color',\n 'text-indent',\n 'text-shadow',\n 'text-underline-offset',\n 'top',\n 'transform',\n 'transform-origin',\n 'translate',\n 'vertical-align',\n 'visibility',\n 'width',\n 'word-spacing',\n 'z-index',\n 'zoom',\n]);\n\nfunction optimizeGroupPlayer(players) {\n switch (players.length) {\n case 0:\n return new NoopAnimationPlayer();\n case 1:\n return players[0];\n default:\n return new ɵAnimationGroupPlayer(players);\n }\n}\nfunction normalizeKeyframes$1(normalizer, keyframes, preStyles = new Map(), postStyles = new Map()) {\n const errors = [];\n const normalizedKeyframes = [];\n let previousOffset = -1;\n let previousKeyframe = null;\n keyframes.forEach((kf) => {\n const offset = kf.get('offset');\n const isSameOffset = offset == previousOffset;\n const normalizedKeyframe = (isSameOffset && previousKeyframe) || new Map();\n kf.forEach((val, prop) => {\n let normalizedProp = prop;\n let normalizedValue = val;\n if (prop !== 'offset') {\n normalizedProp = normalizer.normalizePropertyName(normalizedProp, errors);\n switch (normalizedValue) {\n case ɵPRE_STYLE:\n normalizedValue = preStyles.get(prop);\n break;\n case AUTO_STYLE:\n normalizedValue = postStyles.get(prop);\n break;\n default:\n normalizedValue = normalizer.normalizeStyleValue(prop, normalizedProp, normalizedValue, errors);\n break;\n }\n }\n normalizedKeyframe.set(normalizedProp, normalizedValue);\n });\n if (!isSameOffset) {\n normalizedKeyframes.push(normalizedKeyframe);\n }\n previousKeyframe = normalizedKeyframe;\n previousOffset = offset;\n });\n if (errors.length) {\n throw animationFailed(errors);\n }\n return normalizedKeyframes;\n}\nfunction listenOnPlayer(player, eventName, event, callback) {\n switch (eventName) {\n case 'start':\n player.onStart(() => callback(event && copyAnimationEvent(event, 'start', player)));\n break;\n case 'done':\n player.onDone(() => callback(event && copyAnimationEvent(event, 'done', player)));\n break;\n case 'destroy':\n player.onDestroy(() => callback(event && copyAnimationEvent(event, 'destroy', player)));\n break;\n }\n}\nfunction copyAnimationEvent(e, phaseName, player) {\n const totalTime = player.totalTime;\n const disabled = player.disabled ? true : false;\n const event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == undefined ? e.totalTime : totalTime, disabled);\n const data = e['_data'];\n if (data != null) {\n event['_data'] = data;\n }\n return event;\n}\nfunction makeAnimationEvent(element, triggerName, fromState, toState, phaseName = '', totalTime = 0, disabled) {\n return { element, triggerName, fromState, toState, phaseName, totalTime, disabled: !!disabled };\n}\nfunction getOrSetDefaultValue(map, key, defaultValue) {\n let value = map.get(key);\n if (!value) {\n map.set(key, (value = defaultValue));\n }\n return value;\n}\nfunction parseTimelineCommand(command) {\n const separatorPos = command.indexOf(':');\n const id = command.substring(1, separatorPos);\n const action = command.slice(separatorPos + 1);\n return [id, action];\n}\nconst documentElement = /* @__PURE__ */ (() => typeof document === 'undefined' ? null : document.documentElement)();\nfunction getParentElement(element) {\n const parent = element.parentNode || element.host || null; // consider host to support shadow DOM\n if (parent === documentElement) {\n return null;\n }\n return parent;\n}\nfunction containsVendorPrefix(prop) {\n // Webkit is the only real popular vendor prefix nowadays\n // cc: http://shouldiprefix.com/\n return prop.substring(1, 6) == 'ebkit'; // webkit or Webkit\n}\nlet _CACHED_BODY = null;\nlet _IS_WEBKIT = false;\nfunction validateStyleProperty(prop) {\n if (!_CACHED_BODY) {\n _CACHED_BODY = getBodyNode() || {};\n _IS_WEBKIT = _CACHED_BODY.style ? 'WebkitAppearance' in _CACHED_BODY.style : false;\n }\n let result = true;\n if (_CACHED_BODY.style && !containsVendorPrefix(prop)) {\n result = prop in _CACHED_BODY.style;\n if (!result && _IS_WEBKIT) {\n const camelProp = 'Webkit' + prop.charAt(0).toUpperCase() + prop.slice(1);\n result = camelProp in _CACHED_BODY.style;\n }\n }\n return result;\n}\nfunction validateWebAnimatableStyleProperty(prop) {\n return ANIMATABLE_PROP_SET.has(prop);\n}\nfunction getBodyNode() {\n if (typeof document != 'undefined') {\n return document.body;\n }\n return null;\n}\nfunction containsElement(elm1, elm2) {\n while (elm2) {\n if (elm2 === elm1) {\n return true;\n }\n elm2 = getParentElement(elm2);\n }\n return false;\n}\nfunction invokeQuery(element, selector, multi) {\n if (multi) {\n return Array.from(element.querySelectorAll(selector));\n }\n const elem = element.querySelector(selector);\n return elem ? [elem] : [];\n}\nfunction hypenatePropsKeys(original) {\n const newMap = new Map();\n original.forEach((val, prop) => {\n const newProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2');\n newMap.set(newProp, val);\n });\n return newMap;\n}\n\n/**\n * @publicApi\n *\n * `AnimationDriver` implentation for Noop animations\n */\nclass NoopAnimationDriver {\n /**\n * @returns Whether `prop` is a valid CSS property\n */\n validateStyleProperty(prop) {\n return validateStyleProperty(prop);\n }\n /**\n *\n * @returns Whether elm1 contains elm2.\n */\n containsElement(elm1, elm2) {\n return containsElement(elm1, elm2);\n }\n /**\n * @returns Rhe parent of the given element or `null` if the element is the `document`\n */\n getParentElement(element) {\n return getParentElement(element);\n }\n /**\n * @returns The result of the query selector on the element. The array will contain up to 1 item\n * if `multi` is `false`.\n */\n query(element, selector, multi) {\n return invokeQuery(element, selector, multi);\n }\n /**\n * @returns The `defaultValue` or empty string\n */\n computeStyle(element, prop, defaultValue) {\n return defaultValue || '';\n }\n /**\n * @returns An `NoopAnimationPlayer`\n */\n animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {\n return new NoopAnimationPlayer(duration, delay);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NoopAnimationDriver });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NoopAnimationDriver, decorators: [{\n type: Injectable\n }] });\n/**\n * @publicApi\n */\nclass AnimationDriver {\n /**\n * @deprecated Use the NoopAnimationDriver class.\n */\n static NOOP = new NoopAnimationDriver();\n}\n\nclass AnimationStyleNormalizer {\n}\nclass NoopAnimationStyleNormalizer {\n normalizePropertyName(propertyName, errors) {\n return propertyName;\n }\n normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {\n return value;\n }\n}\n\nconst ONE_SECOND = 1000;\nconst SUBSTITUTION_EXPR_START = '{{';\nconst SUBSTITUTION_EXPR_END = '}}';\nconst ENTER_CLASSNAME = 'ng-enter';\nconst LEAVE_CLASSNAME = 'ng-leave';\nconst NG_TRIGGER_CLASSNAME = 'ng-trigger';\nconst NG_TRIGGER_SELECTOR = '.ng-trigger';\nconst NG_ANIMATING_CLASSNAME = 'ng-animating';\nconst NG_ANIMATING_SELECTOR = '.ng-animating';\nfunction resolveTimingValue(value) {\n if (typeof value == 'number')\n return value;\n const matches = value.match(/^(-?[\\.\\d]+)(m?s)/);\n if (!matches || matches.length < 2)\n return 0;\n return _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);\n}\nfunction _convertTimeValueToMS(value, unit) {\n switch (unit) {\n case 's':\n return value * ONE_SECOND;\n default: // ms or something else\n return value;\n }\n}\nfunction resolveTiming(timings, errors, allowNegativeValues) {\n return timings.hasOwnProperty('duration')\n ? timings\n : parseTimeExpression(timings, errors, allowNegativeValues);\n}\nfunction parseTimeExpression(exp, errors, allowNegativeValues) {\n const regex = /^(-?[\\.\\d]+)(m?s)(?:\\s+(-?[\\.\\d]+)(m?s))?(?:\\s+([-a-z]+(?:\\(.+?\\))?))?$/i;\n let duration;\n let delay = 0;\n let easing = '';\n if (typeof exp === 'string') {\n const matches = exp.match(regex);\n if (matches === null) {\n errors.push(invalidTimingValue(exp));\n return { duration: 0, delay: 0, easing: '' };\n }\n duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);\n const delayMatch = matches[3];\n if (delayMatch != null) {\n delay = _convertTimeValueToMS(parseFloat(delayMatch), matches[4]);\n }\n const easingVal = matches[5];\n if (easingVal) {\n easing = easingVal;\n }\n }\n else {\n duration = exp;\n }\n if (!allowNegativeValues) {\n let containsErrors = false;\n let startIndex = errors.length;\n if (duration < 0) {\n errors.push(negativeStepValue());\n containsErrors = true;\n }\n if (delay < 0) {\n errors.push(negativeDelayValue());\n containsErrors = true;\n }\n if (containsErrors) {\n errors.splice(startIndex, 0, invalidTimingValue(exp));\n }\n }\n return { duration, delay, easing };\n}\nfunction normalizeKeyframes(keyframes) {\n if (!keyframes.length) {\n return [];\n }\n if (keyframes[0] instanceof Map) {\n return keyframes;\n }\n return keyframes.map((kf) => new Map(Object.entries(kf)));\n}\nfunction normalizeStyles(styles) {\n return Array.isArray(styles) ? new Map(...styles) : new Map(styles);\n}\nfunction setStyles(element, styles, formerStyles) {\n styles.forEach((val, prop) => {\n const camelProp = dashCaseToCamelCase(prop);\n if (formerStyles && !formerStyles.has(prop)) {\n formerStyles.set(prop, element.style[camelProp]);\n }\n element.style[camelProp] = val;\n });\n}\nfunction eraseStyles(element, styles) {\n styles.forEach((_, prop) => {\n const camelProp = dashCaseToCamelCase(prop);\n element.style[camelProp] = '';\n });\n}\nfunction normalizeAnimationEntry(steps) {\n if (Array.isArray(steps)) {\n if (steps.length == 1)\n return steps[0];\n return sequence(steps);\n }\n return steps;\n}\nfunction validateStyleParams(value, options, errors) {\n const params = options.params || {};\n const matches = extractStyleParams(value);\n if (matches.length) {\n matches.forEach((varName) => {\n if (!params.hasOwnProperty(varName)) {\n errors.push(invalidStyleParams(varName));\n }\n });\n }\n}\nconst PARAM_REGEX = new RegExp(`${SUBSTITUTION_EXPR_START}\\\\s*(.+?)\\\\s*${SUBSTITUTION_EXPR_END}`, 'g');\nfunction extractStyleParams(value) {\n let params = [];\n if (typeof value === 'string') {\n let match;\n while ((match = PARAM_REGEX.exec(value))) {\n params.push(match[1]);\n }\n PARAM_REGEX.lastIndex = 0;\n }\n return params;\n}\nfunction interpolateParams(value, params, errors) {\n const original = `${value}`;\n const str = original.replace(PARAM_REGEX, (_, varName) => {\n let localVal = params[varName];\n // this means that the value was never overridden by the data passed in by the user\n if (localVal == null) {\n errors.push(invalidParamValue(varName));\n localVal = '';\n }\n return localVal.toString();\n });\n // we do this to assert that numeric values stay as they are\n return str == original ? value : str;\n}\nconst DASH_CASE_REGEXP = /-+([a-z0-9])/g;\nfunction dashCaseToCamelCase(input) {\n return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());\n}\nfunction camelCaseToDashCase(input) {\n return input.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n}\nfunction allowPreviousPlayerStylesMerge(duration, delay) {\n return duration === 0 || delay === 0;\n}\nfunction balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles) {\n if (previousStyles.size && keyframes.length) {\n let startingKeyframe = keyframes[0];\n let missingStyleProps = [];\n previousStyles.forEach((val, prop) => {\n if (!startingKeyframe.has(prop)) {\n missingStyleProps.push(prop);\n }\n startingKeyframe.set(prop, val);\n });\n if (missingStyleProps.length) {\n for (let i = 1; i < keyframes.length; i++) {\n let kf = keyframes[i];\n missingStyleProps.forEach((prop) => kf.set(prop, computeStyle(element, prop)));\n }\n }\n }\n return keyframes;\n}\nfunction visitDslNode(visitor, node, context) {\n switch (node.type) {\n case AnimationMetadataType.Trigger:\n return visitor.visitTrigger(node, context);\n case AnimationMetadataType.State:\n return visitor.visitState(node, context);\n case AnimationMetadataType.Transition:\n return visitor.visitTransition(node, context);\n case AnimationMetadataType.Sequence:\n return visitor.visitSequence(node, context);\n case AnimationMetadataType.Group:\n return visitor.visitGroup(node, context);\n case AnimationMetadataType.Animate:\n return visitor.visitAnimate(node, context);\n case AnimationMetadataType.Keyframes:\n return visitor.visitKeyframes(node, context);\n case AnimationMetadataType.Style:\n return visitor.visitStyle(node, context);\n case AnimationMetadataType.Reference:\n return visitor.visitReference(node, context);\n case AnimationMetadataType.AnimateChild:\n return visitor.visitAnimateChild(node, context);\n case AnimationMetadataType.AnimateRef:\n return visitor.visitAnimateRef(node, context);\n case AnimationMetadataType.Query:\n return visitor.visitQuery(node, context);\n case AnimationMetadataType.Stagger:\n return visitor.visitStagger(node, context);\n default:\n throw invalidNodeType(node.type);\n }\n}\nfunction computeStyle(element, prop) {\n return window.getComputedStyle(element)[prop];\n}\n\nconst DIMENSIONAL_PROP_SET = new Set([\n 'width',\n 'height',\n 'minWidth',\n 'minHeight',\n 'maxWidth',\n 'maxHeight',\n 'left',\n 'top',\n 'bottom',\n 'right',\n 'fontSize',\n 'outlineWidth',\n 'outlineOffset',\n 'paddingTop',\n 'paddingLeft',\n 'paddingBottom',\n 'paddingRight',\n 'marginTop',\n 'marginLeft',\n 'marginBottom',\n 'marginRight',\n 'borderRadius',\n 'borderWidth',\n 'borderTopWidth',\n 'borderLeftWidth',\n 'borderRightWidth',\n 'borderBottomWidth',\n 'textIndent',\n 'perspective',\n]);\nclass WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {\n normalizePropertyName(propertyName, errors) {\n return dashCaseToCamelCase(propertyName);\n }\n normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {\n let unit = '';\n const strVal = value.toString().trim();\n if (DIMENSIONAL_PROP_SET.has(normalizedProperty) && value !== 0 && value !== '0') {\n if (typeof value === 'number') {\n unit = 'px';\n }\n else {\n const valAndSuffixMatch = value.match(/^[+-]?[\\d\\.]+([a-z]*)$/);\n if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {\n errors.push(invalidCssUnitValue(userProvidedProperty, value));\n }\n }\n }\n return strVal + unit;\n }\n}\n\nfunction createListOfWarnings(warnings) {\n const LINE_START = '\\n - ';\n return `${LINE_START}${warnings\n .filter(Boolean)\n .map((warning) => warning)\n .join(LINE_START)}`;\n}\nfunction warnValidation(warnings) {\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n console.warn(`animation validation warnings:${createListOfWarnings(warnings)}`);\n}\nfunction warnTriggerBuild(name, warnings) {\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n console.warn(`The animation trigger \"${name}\" has built with the following warnings:${createListOfWarnings(warnings)}`);\n}\nfunction warnRegister(warnings) {\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n console.warn(`Animation built with the following warnings:${createListOfWarnings(warnings)}`);\n}\nfunction triggerParsingWarnings(name, warnings) {\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n console.warn(`Animation parsing for the ${name} trigger presents the following warnings:${createListOfWarnings(warnings)}`);\n}\nfunction pushUnrecognizedPropertiesWarning(warnings, props) {\n if (props.length) {\n warnings.push(`The following provided properties are not recognized: ${props.join(', ')}`);\n }\n}\n\nconst ANY_STATE = '*';\nfunction parseTransitionExpr(transitionValue, errors) {\n const expressions = [];\n if (typeof transitionValue == 'string') {\n transitionValue\n .split(/\\s*,\\s*/)\n .forEach((str) => parseInnerTransitionStr(str, expressions, errors));\n }\n else {\n expressions.push(transitionValue);\n }\n return expressions;\n}\nfunction parseInnerTransitionStr(eventStr, expressions, errors) {\n if (eventStr[0] == ':') {\n const result = parseAnimationAlias(eventStr, errors);\n if (typeof result == 'function') {\n expressions.push(result);\n return;\n }\n eventStr = result;\n }\n const match = eventStr.match(/^(\\*|[-\\w]+)\\s*()\\s*(\\*|[-\\w]+)$/);\n if (match == null || match.length < 4) {\n errors.push(invalidExpression(eventStr));\n return expressions;\n }\n const fromState = match[1];\n const separator = match[2];\n const toState = match[3];\n expressions.push(makeLambdaFromStates(fromState, toState));\n const isFullAnyStateExpr = fromState == ANY_STATE && toState == ANY_STATE;\n if (separator[0] == '<' && !isFullAnyStateExpr) {\n expressions.push(makeLambdaFromStates(toState, fromState));\n }\n return;\n}\nfunction parseAnimationAlias(alias, errors) {\n switch (alias) {\n case ':enter':\n return 'void => *';\n case ':leave':\n return '* => void';\n case ':increment':\n return (fromState, toState) => parseFloat(toState) > parseFloat(fromState);\n case ':decrement':\n return (fromState, toState) => parseFloat(toState) < parseFloat(fromState);\n default:\n errors.push(invalidTransitionAlias(alias));\n return '* => *';\n }\n}\n// DO NOT REFACTOR ... keep the follow set instantiations\n// with the values intact (closure compiler for some reason\n// removes follow-up lines that add the values outside of\n// the constructor...\nconst TRUE_BOOLEAN_VALUES = new Set(['true', '1']);\nconst FALSE_BOOLEAN_VALUES = new Set(['false', '0']);\nfunction makeLambdaFromStates(lhs, rhs) {\n const LHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(lhs) || FALSE_BOOLEAN_VALUES.has(lhs);\n const RHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(rhs) || FALSE_BOOLEAN_VALUES.has(rhs);\n return (fromState, toState) => {\n let lhsMatch = lhs == ANY_STATE || lhs == fromState;\n let rhsMatch = rhs == ANY_STATE || rhs == toState;\n if (!lhsMatch && LHS_MATCH_BOOLEAN && typeof fromState === 'boolean') {\n lhsMatch = fromState ? TRUE_BOOLEAN_VALUES.has(lhs) : FALSE_BOOLEAN_VALUES.has(lhs);\n }\n if (!rhsMatch && RHS_MATCH_BOOLEAN && typeof toState === 'boolean') {\n rhsMatch = toState ? TRUE_BOOLEAN_VALUES.has(rhs) : FALSE_BOOLEAN_VALUES.has(rhs);\n }\n return lhsMatch && rhsMatch;\n };\n}\n\nconst SELF_TOKEN = ':self';\nconst SELF_TOKEN_REGEX = new RegExp(`s*${SELF_TOKEN}s*,?`, 'g');\n/*\n * [Validation]\n * The visitor code below will traverse the animation AST generated by the animation verb functions\n * (the output is a tree of objects) and attempt to perform a series of validations on the data. The\n * following corner-cases will be validated:\n *\n * 1. Overlap of animations\n * Given that a CSS property cannot be animated in more than one place at the same time, it's\n * important that this behavior is detected and validated. The way in which this occurs is that\n * each time a style property is examined, a string-map containing the property will be updated with\n * the start and end times for when the property is used within an animation step.\n *\n * If there are two or more parallel animations that are currently running (these are invoked by the\n * group()) on the same element then the validator will throw an error. Since the start/end timing\n * values are collected for each property then if the current animation step is animating the same\n * property and its timing values fall anywhere into the window of time that the property is\n * currently being animated within then this is what causes an error.\n *\n * 2. Timing values\n * The validator will validate to see if a timing value of `duration delay easing` or\n * `durationNumber` is valid or not.\n *\n * (note that upon validation the code below will replace the timing data with an object containing\n * {duration,delay,easing}.\n *\n * 3. Offset Validation\n * Each of the style() calls are allowed to have an offset value when placed inside of keyframes().\n * Offsets within keyframes() are considered valid when:\n *\n * - No offsets are used at all\n * - Each style() entry contains an offset value\n * - Each offset is between 0 and 1\n * - Each offset is greater to or equal than the previous one\n *\n * Otherwise an error will be thrown.\n */\nfunction buildAnimationAst(driver, metadata, errors, warnings) {\n return new AnimationAstBuilderVisitor(driver).build(metadata, errors, warnings);\n}\nconst ROOT_SELECTOR = '';\nclass AnimationAstBuilderVisitor {\n _driver;\n constructor(_driver) {\n this._driver = _driver;\n }\n build(metadata, errors, warnings) {\n const context = new AnimationAstBuilderContext(errors);\n this._resetContextStyleTimingState(context);\n const ast = (visitDslNode(this, normalizeAnimationEntry(metadata), context));\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (context.unsupportedCSSPropertiesFound.size) {\n pushUnrecognizedPropertiesWarning(warnings, [\n ...context.unsupportedCSSPropertiesFound.keys(),\n ]);\n }\n }\n return ast;\n }\n _resetContextStyleTimingState(context) {\n context.currentQuerySelector = ROOT_SELECTOR;\n context.collectedStyles = new Map();\n context.collectedStyles.set(ROOT_SELECTOR, new Map());\n context.currentTime = 0;\n }\n visitTrigger(metadata, context) {\n let queryCount = (context.queryCount = 0);\n let depCount = (context.depCount = 0);\n const states = [];\n const transitions = [];\n if (metadata.name.charAt(0) == '@') {\n context.errors.push(invalidTrigger());\n }\n metadata.definitions.forEach((def) => {\n this._resetContextStyleTimingState(context);\n if (def.type == AnimationMetadataType.State) {\n const stateDef = def;\n const name = stateDef.name;\n name\n .toString()\n .split(/\\s*,\\s*/)\n .forEach((n) => {\n stateDef.name = n;\n states.push(this.visitState(stateDef, context));\n });\n stateDef.name = name;\n }\n else if (def.type == AnimationMetadataType.Transition) {\n const transition = this.visitTransition(def, context);\n queryCount += transition.queryCount;\n depCount += transition.depCount;\n transitions.push(transition);\n }\n else {\n context.errors.push(invalidDefinition());\n }\n });\n return {\n type: AnimationMetadataType.Trigger,\n name: metadata.name,\n states,\n transitions,\n queryCount,\n depCount,\n options: null,\n };\n }\n visitState(metadata, context) {\n const styleAst = this.visitStyle(metadata.styles, context);\n const astParams = (metadata.options && metadata.options.params) || null;\n if (styleAst.containsDynamicStyles) {\n const missingSubs = new Set();\n const params = astParams || {};\n styleAst.styles.forEach((style) => {\n if (style instanceof Map) {\n style.forEach((value) => {\n extractStyleParams(value).forEach((sub) => {\n if (!params.hasOwnProperty(sub)) {\n missingSubs.add(sub);\n }\n });\n });\n }\n });\n if (missingSubs.size) {\n context.errors.push(invalidState(metadata.name, [...missingSubs.values()]));\n }\n }\n return {\n type: AnimationMetadataType.State,\n name: metadata.name,\n style: styleAst,\n options: astParams ? { params: astParams } : null,\n };\n }\n visitTransition(metadata, context) {\n context.queryCount = 0;\n context.depCount = 0;\n const animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context);\n const matchers = parseTransitionExpr(metadata.expr, context.errors);\n return {\n type: AnimationMetadataType.Transition,\n matchers,\n animation,\n queryCount: context.queryCount,\n depCount: context.depCount,\n options: normalizeAnimationOptions(metadata.options),\n };\n }\n visitSequence(metadata, context) {\n return {\n type: AnimationMetadataType.Sequence,\n steps: metadata.steps.map((s) => visitDslNode(this, s, context)),\n options: normalizeAnimationOptions(metadata.options),\n };\n }\n visitGroup(metadata, context) {\n const currentTime = context.currentTime;\n let furthestTime = 0;\n const steps = metadata.steps.map((step) => {\n context.currentTime = currentTime;\n const innerAst = visitDslNode(this, step, context);\n furthestTime = Math.max(furthestTime, context.currentTime);\n return innerAst;\n });\n context.currentTime = furthestTime;\n return {\n type: AnimationMetadataType.Group,\n steps,\n options: normalizeAnimationOptions(metadata.options),\n };\n }\n visitAnimate(metadata, context) {\n const timingAst = constructTimingAst(metadata.timings, context.errors);\n context.currentAnimateTimings = timingAst;\n let styleAst;\n let styleMetadata = metadata.styles\n ? metadata.styles\n : style({});\n if (styleMetadata.type == AnimationMetadataType.Keyframes) {\n styleAst = this.visitKeyframes(styleMetadata, context);\n }\n else {\n let styleMetadata = metadata.styles;\n let isEmpty = false;\n if (!styleMetadata) {\n isEmpty = true;\n const newStyleData = {};\n if (timingAst.easing) {\n newStyleData['easing'] = timingAst.easing;\n }\n styleMetadata = style(newStyleData);\n }\n context.currentTime += timingAst.duration + timingAst.delay;\n const _styleAst = this.visitStyle(styleMetadata, context);\n _styleAst.isEmptyStep = isEmpty;\n styleAst = _styleAst;\n }\n context.currentAnimateTimings = null;\n return {\n type: AnimationMetadataType.Animate,\n timings: timingAst,\n style: styleAst,\n options: null,\n };\n }\n visitStyle(metadata, context) {\n const ast = this._makeStyleAst(metadata, context);\n this._validateStyleAst(ast, context);\n return ast;\n }\n _makeStyleAst(metadata, context) {\n const styles = [];\n const metadataStyles = Array.isArray(metadata.styles) ? metadata.styles : [metadata.styles];\n for (let styleTuple of metadataStyles) {\n if (typeof styleTuple === 'string') {\n if (styleTuple === AUTO_STYLE) {\n styles.push(styleTuple);\n }\n else {\n context.errors.push(invalidStyleValue(styleTuple));\n }\n }\n else {\n styles.push(new Map(Object.entries(styleTuple)));\n }\n }\n let containsDynamicStyles = false;\n let collectedEasing = null;\n styles.forEach((styleData) => {\n if (styleData instanceof Map) {\n if (styleData.has('easing')) {\n collectedEasing = styleData.get('easing');\n styleData.delete('easing');\n }\n if (!containsDynamicStyles) {\n for (let value of styleData.values()) {\n if (value.toString().indexOf(SUBSTITUTION_EXPR_START) >= 0) {\n containsDynamicStyles = true;\n break;\n }\n }\n }\n }\n });\n return {\n type: AnimationMetadataType.Style,\n styles,\n easing: collectedEasing,\n offset: metadata.offset,\n containsDynamicStyles,\n options: null,\n };\n }\n _validateStyleAst(ast, context) {\n const timings = context.currentAnimateTimings;\n let endTime = context.currentTime;\n let startTime = context.currentTime;\n if (timings && startTime > 0) {\n startTime -= timings.duration + timings.delay;\n }\n ast.styles.forEach((tuple) => {\n if (typeof tuple === 'string')\n return;\n tuple.forEach((value, prop) => {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (!this._driver.validateStyleProperty(prop)) {\n tuple.delete(prop);\n context.unsupportedCSSPropertiesFound.add(prop);\n return;\n }\n }\n // This is guaranteed to have a defined Map at this querySelector location making it\n // safe to add the assertion here. It is set as a default empty map in prior methods.\n const collectedStyles = context.collectedStyles.get(context.currentQuerySelector);\n const collectedEntry = collectedStyles.get(prop);\n let updateCollectedStyle = true;\n if (collectedEntry) {\n if (startTime != endTime &&\n startTime >= collectedEntry.startTime &&\n endTime <= collectedEntry.endTime) {\n context.errors.push(invalidParallelAnimation(prop, collectedEntry.startTime, collectedEntry.endTime, startTime, endTime));\n updateCollectedStyle = false;\n }\n // we always choose the smaller start time value since we\n // want to have a record of the entire animation window where\n // the style property is being animated in between\n startTime = collectedEntry.startTime;\n }\n if (updateCollectedStyle) {\n collectedStyles.set(prop, { startTime, endTime });\n }\n if (context.options) {\n validateStyleParams(value, context.options, context.errors);\n }\n });\n });\n }\n visitKeyframes(metadata, context) {\n const ast = { type: AnimationMetadataType.Keyframes, styles: [], options: null };\n if (!context.currentAnimateTimings) {\n context.errors.push(invalidKeyframes());\n return ast;\n }\n const MAX_KEYFRAME_OFFSET = 1;\n let totalKeyframesWithOffsets = 0;\n const offsets = [];\n let offsetsOutOfOrder = false;\n let keyframesOutOfRange = false;\n let previousOffset = 0;\n const keyframes = metadata.steps.map((styles) => {\n const style = this._makeStyleAst(styles, context);\n let offsetVal = style.offset != null ? style.offset : consumeOffset(style.styles);\n let offset = 0;\n if (offsetVal != null) {\n totalKeyframesWithOffsets++;\n offset = style.offset = offsetVal;\n }\n keyframesOutOfRange = keyframesOutOfRange || offset < 0 || offset > 1;\n offsetsOutOfOrder = offsetsOutOfOrder || offset < previousOffset;\n previousOffset = offset;\n offsets.push(offset);\n return style;\n });\n if (keyframesOutOfRange) {\n context.errors.push(invalidOffset());\n }\n if (offsetsOutOfOrder) {\n context.errors.push(keyframeOffsetsOutOfOrder());\n }\n const length = metadata.steps.length;\n let generatedOffset = 0;\n if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) {\n context.errors.push(keyframesMissingOffsets());\n }\n else if (totalKeyframesWithOffsets == 0) {\n generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1);\n }\n const limit = length - 1;\n const currentTime = context.currentTime;\n const currentAnimateTimings = context.currentAnimateTimings;\n const animateDuration = currentAnimateTimings.duration;\n keyframes.forEach((kf, i) => {\n const offset = generatedOffset > 0 ? (i == limit ? 1 : generatedOffset * i) : offsets[i];\n const durationUpToThisFrame = offset * animateDuration;\n context.currentTime = currentTime + currentAnimateTimings.delay + durationUpToThisFrame;\n currentAnimateTimings.duration = durationUpToThisFrame;\n this._validateStyleAst(kf, context);\n kf.offset = offset;\n ast.styles.push(kf);\n });\n return ast;\n }\n visitReference(metadata, context) {\n return {\n type: AnimationMetadataType.Reference,\n animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context),\n options: normalizeAnimationOptions(metadata.options),\n };\n }\n visitAnimateChild(metadata, context) {\n context.depCount++;\n return {\n type: AnimationMetadataType.AnimateChild,\n options: normalizeAnimationOptions(metadata.options),\n };\n }\n visitAnimateRef(metadata, context) {\n return {\n type: AnimationMetadataType.AnimateRef,\n animation: this.visitReference(metadata.animation, context),\n options: normalizeAnimationOptions(metadata.options),\n };\n }\n visitQuery(metadata, context) {\n const parentSelector = context.currentQuerySelector;\n const options = (metadata.options || {});\n context.queryCount++;\n context.currentQuery = metadata;\n const [selector, includeSelf] = normalizeSelector(metadata.selector);\n context.currentQuerySelector = parentSelector.length\n ? parentSelector + ' ' + selector\n : selector;\n getOrSetDefaultValue(context.collectedStyles, context.currentQuerySelector, new Map());\n const animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context);\n context.currentQuery = null;\n context.currentQuerySelector = parentSelector;\n return {\n type: AnimationMetadataType.Query,\n selector,\n limit: options.limit || 0,\n optional: !!options.optional,\n includeSelf,\n animation,\n originalSelector: metadata.selector,\n options: normalizeAnimationOptions(metadata.options),\n };\n }\n visitStagger(metadata, context) {\n if (!context.currentQuery) {\n context.errors.push(invalidStagger());\n }\n const timings = metadata.timings === 'full'\n ? { duration: 0, delay: 0, easing: 'full' }\n : resolveTiming(metadata.timings, context.errors, true);\n return {\n type: AnimationMetadataType.Stagger,\n animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context),\n timings,\n options: null,\n };\n }\n}\nfunction normalizeSelector(selector) {\n const hasAmpersand = selector.split(/\\s*,\\s*/).find((token) => token == SELF_TOKEN)\n ? true\n : false;\n if (hasAmpersand) {\n selector = selector.replace(SELF_TOKEN_REGEX, '');\n }\n // Note: the :enter and :leave aren't normalized here since those\n // selectors are filled in at runtime during timeline building\n selector = selector\n .replace(/@\\*/g, NG_TRIGGER_SELECTOR)\n .replace(/@\\w+/g, (match) => NG_TRIGGER_SELECTOR + '-' + match.slice(1))\n .replace(/:animating/g, NG_ANIMATING_SELECTOR);\n return [selector, hasAmpersand];\n}\nfunction normalizeParams(obj) {\n return obj ? { ...obj } : null;\n}\nclass AnimationAstBuilderContext {\n errors;\n queryCount = 0;\n depCount = 0;\n currentTransition = null;\n currentQuery = null;\n currentQuerySelector = null;\n currentAnimateTimings = null;\n currentTime = 0;\n collectedStyles = new Map();\n options = null;\n unsupportedCSSPropertiesFound = new Set();\n constructor(errors) {\n this.errors = errors;\n }\n}\nfunction consumeOffset(styles) {\n if (typeof styles == 'string')\n return null;\n let offset = null;\n if (Array.isArray(styles)) {\n styles.forEach((styleTuple) => {\n if (styleTuple instanceof Map && styleTuple.has('offset')) {\n const obj = styleTuple;\n offset = parseFloat(obj.get('offset'));\n obj.delete('offset');\n }\n });\n }\n else if (styles instanceof Map && styles.has('offset')) {\n const obj = styles;\n offset = parseFloat(obj.get('offset'));\n obj.delete('offset');\n }\n return offset;\n}\nfunction constructTimingAst(value, errors) {\n if (value.hasOwnProperty('duration')) {\n return value;\n }\n if (typeof value == 'number') {\n const duration = resolveTiming(value, errors).duration;\n return makeTimingAst(duration, 0, '');\n }\n const strValue = value;\n const isDynamic = strValue.split(/\\s+/).some((v) => v.charAt(0) == '{' && v.charAt(1) == '{');\n if (isDynamic) {\n const ast = makeTimingAst(0, 0, '');\n ast.dynamic = true;\n ast.strValue = strValue;\n return ast;\n }\n const timings = resolveTiming(strValue, errors);\n return makeTimingAst(timings.duration, timings.delay, timings.easing);\n}\nfunction normalizeAnimationOptions(options) {\n if (options) {\n options = { ...options };\n if (options['params']) {\n options['params'] = normalizeParams(options['params']);\n }\n }\n else {\n options = {};\n }\n return options;\n}\nfunction makeTimingAst(duration, delay, easing) {\n return { duration, delay, easing };\n}\n\nfunction createTimelineInstruction(element, keyframes, preStyleProps, postStyleProps, duration, delay, easing = null, subTimeline = false) {\n return {\n type: 1 /* AnimationTransitionInstructionType.TimelineAnimation */,\n element,\n keyframes,\n preStyleProps,\n postStyleProps,\n duration,\n delay,\n totalTime: duration + delay,\n easing,\n subTimeline,\n };\n}\n\nclass ElementInstructionMap {\n _map = new Map();\n get(element) {\n return this._map.get(element) || [];\n }\n append(element, instructions) {\n let existingInstructions = this._map.get(element);\n if (!existingInstructions) {\n this._map.set(element, (existingInstructions = []));\n }\n existingInstructions.push(...instructions);\n }\n has(element) {\n return this._map.has(element);\n }\n clear() {\n this._map.clear();\n }\n}\n\nconst ONE_FRAME_IN_MILLISECONDS = 1;\nconst ENTER_TOKEN = ':enter';\nconst ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, 'g');\nconst LEAVE_TOKEN = ':leave';\nconst LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, 'g');\n/*\n * The code within this file aims to generate web-animations-compatible keyframes from Angular's\n * animation DSL code.\n *\n * The code below will be converted from:\n *\n * ```ts\n * sequence([\n * style({ opacity: 0 }),\n * animate(1000, style({ opacity: 0 }))\n * ])\n * ```\n *\n * To:\n * ```ts\n * keyframes = [{ opacity: 0, offset: 0 }, { opacity: 1, offset: 1 }]\n * duration = 1000\n * delay = 0\n * easing = ''\n * ```\n *\n * For this operation to cover the combination of animation verbs (style, animate, group, etc...) a\n * combination of AST traversal and merge-sort-like algorithms are used.\n *\n * [AST Traversal]\n * Each of the animation verbs, when executed, will return an string-map object representing what\n * type of action it is (style, animate, group, etc...) and the data associated with it. This means\n * that when functional composition mix of these functions is evaluated (like in the example above)\n * then it will end up producing a tree of objects representing the animation itself.\n *\n * When this animation object tree is processed by the visitor code below it will visit each of the\n * verb statements within the visitor. And during each visit it will build the context of the\n * animation keyframes by interacting with the `TimelineBuilder`.\n *\n * [TimelineBuilder]\n * This class is responsible for tracking the styles and building a series of keyframe objects for a\n * timeline between a start and end time. The builder starts off with an initial timeline and each\n * time the AST comes across a `group()`, `keyframes()` or a combination of the two within a\n * `sequence()` then it will generate a sub timeline for each step as well as a new one after\n * they are complete.\n *\n * As the AST is traversed, the timing state on each of the timelines will be incremented. If a sub\n * timeline was created (based on one of the cases above) then the parent timeline will attempt to\n * merge the styles used within the sub timelines into itself (only with group() this will happen).\n * This happens with a merge operation (much like how the merge works in mergeSort) and it will only\n * copy the most recently used styles from the sub timelines into the parent timeline. This ensures\n * that if the styles are used later on in another phase of the animation then they will be the most\n * up-to-date values.\n *\n * [How Missing Styles Are Updated]\n * Each timeline has a `backFill` property which is responsible for filling in new styles into\n * already processed keyframes if a new style shows up later within the animation sequence.\n *\n * ```ts\n * sequence([\n * style({ width: 0 }),\n * animate(1000, style({ width: 100 })),\n * animate(1000, style({ width: 200 })),\n * animate(1000, style({ width: 300 }))\n * animate(1000, style({ width: 400, height: 400 })) // notice how `height` doesn't exist anywhere\n * else\n * ])\n * ```\n *\n * What is happening here is that the `height` value is added later in the sequence, but is missing\n * from all previous animation steps. Therefore when a keyframe is created it would also be missing\n * from all previous keyframes up until where it is first used. For the timeline keyframe generation\n * to properly fill in the style it will place the previous value (the value from the parent\n * timeline) or a default value of `*` into the backFill map.\n *\n * When a sub-timeline is created it will have its own backFill property. This is done so that\n * styles present within the sub-timeline do not accidentally seep into the previous/future timeline\n * keyframes\n *\n * [Validation]\n * The code in this file is not responsible for validation. That functionality happens with within\n * the `AnimationValidatorVisitor` code.\n */\nfunction buildAnimationTimelines(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles = new Map(), finalStyles = new Map(), options, subInstructions, errors = []) {\n return new AnimationTimelineBuilderVisitor().buildKeyframes(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles, finalStyles, options, subInstructions, errors);\n}\nclass AnimationTimelineBuilderVisitor {\n buildKeyframes(driver, rootElement, ast, enterClassName, leaveClassName, startingStyles, finalStyles, options, subInstructions, errors = []) {\n subInstructions = subInstructions || new ElementInstructionMap();\n const context = new AnimationTimelineContext(driver, rootElement, subInstructions, enterClassName, leaveClassName, errors, []);\n context.options = options;\n const delay = options.delay ? resolveTimingValue(options.delay) : 0;\n context.currentTimeline.delayNextStep(delay);\n context.currentTimeline.setStyles([startingStyles], null, context.errors, options);\n visitDslNode(this, ast, context);\n // this checks to see if an actual animation happened\n const timelines = context.timelines.filter((timeline) => timeline.containsAnimation());\n // note: we just want to apply the final styles for the rootElement, so we do not\n // just apply the styles to the last timeline but the last timeline which\n // element is the root one (basically `*`-styles are replaced with the actual\n // state style values only for the root element)\n if (timelines.length && finalStyles.size) {\n let lastRootTimeline;\n for (let i = timelines.length - 1; i >= 0; i--) {\n const timeline = timelines[i];\n if (timeline.element === rootElement) {\n lastRootTimeline = timeline;\n break;\n }\n }\n if (lastRootTimeline && !lastRootTimeline.allowOnlyTimelineStyles()) {\n lastRootTimeline.setStyles([finalStyles], null, context.errors, options);\n }\n }\n return timelines.length\n ? timelines.map((timeline) => timeline.buildKeyframes())\n : [createTimelineInstruction(rootElement, [], [], [], 0, delay, '', false)];\n }\n visitTrigger(ast, context) {\n // these values are not visited in this AST\n }\n visitState(ast, context) {\n // these values are not visited in this AST\n }\n visitTransition(ast, context) {\n // these values are not visited in this AST\n }\n visitAnimateChild(ast, context) {\n const elementInstructions = context.subInstructions.get(context.element);\n if (elementInstructions) {\n const innerContext = context.createSubContext(ast.options);\n const startTime = context.currentTimeline.currentTime;\n const endTime = this._visitSubInstructions(elementInstructions, innerContext, innerContext.options);\n if (startTime != endTime) {\n // we do this on the upper context because we created a sub context for\n // the sub child animations\n context.transformIntoNewTimeline(endTime);\n }\n }\n context.previousNode = ast;\n }\n visitAnimateRef(ast, context) {\n const innerContext = context.createSubContext(ast.options);\n innerContext.transformIntoNewTimeline();\n this._applyAnimationRefDelays([ast.options, ast.animation.options], context, innerContext);\n this.visitReference(ast.animation, innerContext);\n context.transformIntoNewTimeline(innerContext.currentTimeline.currentTime);\n context.previousNode = ast;\n }\n _applyAnimationRefDelays(animationsRefsOptions, context, innerContext) {\n for (const animationRefOptions of animationsRefsOptions) {\n const animationDelay = animationRefOptions?.delay;\n if (animationDelay) {\n const animationDelayValue = typeof animationDelay === 'number'\n ? animationDelay\n : resolveTimingValue(interpolateParams(animationDelay, animationRefOptions?.params ?? {}, context.errors));\n innerContext.delayNextStep(animationDelayValue);\n }\n }\n }\n _visitSubInstructions(instructions, context, options) {\n const startTime = context.currentTimeline.currentTime;\n let furthestTime = startTime;\n // this is a special-case for when a user wants to skip a sub\n // animation from being fired entirely.\n const duration = options.duration != null ? resolveTimingValue(options.duration) : null;\n const delay = options.delay != null ? resolveTimingValue(options.delay) : null;\n if (duration !== 0) {\n instructions.forEach((instruction) => {\n const instructionTimings = context.appendInstructionToTimeline(instruction, duration, delay);\n furthestTime = Math.max(furthestTime, instructionTimings.duration + instructionTimings.delay);\n });\n }\n return furthestTime;\n }\n visitReference(ast, context) {\n context.updateOptions(ast.options, true);\n visitDslNode(this, ast.animation, context);\n context.previousNode = ast;\n }\n visitSequence(ast, context) {\n const subContextCount = context.subContextCount;\n let ctx = context;\n const options = ast.options;\n if (options && (options.params || options.delay)) {\n ctx = context.createSubContext(options);\n ctx.transformIntoNewTimeline();\n if (options.delay != null) {\n if (ctx.previousNode.type == AnimationMetadataType.Style) {\n ctx.currentTimeline.snapshotCurrentStyles();\n ctx.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;\n }\n const delay = resolveTimingValue(options.delay);\n ctx.delayNextStep(delay);\n }\n }\n if (ast.steps.length) {\n ast.steps.forEach((s) => visitDslNode(this, s, ctx));\n // this is here just in case the inner steps only contain or end with a style() call\n ctx.currentTimeline.applyStylesToKeyframe();\n // this means that some animation function within the sequence\n // ended up creating a sub timeline (which means the current\n // timeline cannot overlap with the contents of the sequence)\n if (ctx.subContextCount > subContextCount) {\n ctx.transformIntoNewTimeline();\n }\n }\n context.previousNode = ast;\n }\n visitGroup(ast, context) {\n const innerTimelines = [];\n let furthestTime = context.currentTimeline.currentTime;\n const delay = ast.options && ast.options.delay ? resolveTimingValue(ast.options.delay) : 0;\n ast.steps.forEach((s) => {\n const innerContext = context.createSubContext(ast.options);\n if (delay) {\n innerContext.delayNextStep(delay);\n }\n visitDslNode(this, s, innerContext);\n furthestTime = Math.max(furthestTime, innerContext.currentTimeline.currentTime);\n innerTimelines.push(innerContext.currentTimeline);\n });\n // this operation is run after the AST loop because otherwise\n // if the parent timeline's collected styles were updated then\n // it would pass in invalid data into the new-to-be forked items\n innerTimelines.forEach((timeline) => context.currentTimeline.mergeTimelineCollectedStyles(timeline));\n context.transformIntoNewTimeline(furthestTime);\n context.previousNode = ast;\n }\n _visitTiming(ast, context) {\n if (ast.dynamic) {\n const strValue = ast.strValue;\n const timingValue = context.params\n ? interpolateParams(strValue, context.params, context.errors)\n : strValue;\n return resolveTiming(timingValue, context.errors);\n }\n else {\n return { duration: ast.duration, delay: ast.delay, easing: ast.easing };\n }\n }\n visitAnimate(ast, context) {\n const timings = (context.currentAnimateTimings = this._visitTiming(ast.timings, context));\n const timeline = context.currentTimeline;\n if (timings.delay) {\n context.incrementTime(timings.delay);\n timeline.snapshotCurrentStyles();\n }\n const style = ast.style;\n if (style.type == AnimationMetadataType.Keyframes) {\n this.visitKeyframes(style, context);\n }\n else {\n context.incrementTime(timings.duration);\n this.visitStyle(style, context);\n timeline.applyStylesToKeyframe();\n }\n context.currentAnimateTimings = null;\n context.previousNode = ast;\n }\n visitStyle(ast, context) {\n const timeline = context.currentTimeline;\n const timings = context.currentAnimateTimings;\n // this is a special case for when a style() call\n // directly follows an animate() call (but not inside of an animate() call)\n if (!timings && timeline.hasCurrentStyleProperties()) {\n timeline.forwardFrame();\n }\n const easing = (timings && timings.easing) || ast.easing;\n if (ast.isEmptyStep) {\n timeline.applyEmptyStep(easing);\n }\n else {\n timeline.setStyles(ast.styles, easing, context.errors, context.options);\n }\n context.previousNode = ast;\n }\n visitKeyframes(ast, context) {\n const currentAnimateTimings = context.currentAnimateTimings;\n const startTime = context.currentTimeline.duration;\n const duration = currentAnimateTimings.duration;\n const innerContext = context.createSubContext();\n const innerTimeline = innerContext.currentTimeline;\n innerTimeline.easing = currentAnimateTimings.easing;\n ast.styles.forEach((step) => {\n const offset = step.offset || 0;\n innerTimeline.forwardTime(offset * duration);\n innerTimeline.setStyles(step.styles, step.easing, context.errors, context.options);\n innerTimeline.applyStylesToKeyframe();\n });\n // this will ensure that the parent timeline gets all the styles from\n // the child even if the new timeline below is not used\n context.currentTimeline.mergeTimelineCollectedStyles(innerTimeline);\n // we do this because the window between this timeline and the sub timeline\n // should ensure that the styles within are exactly the same as they were before\n context.transformIntoNewTimeline(startTime + duration);\n context.previousNode = ast;\n }\n visitQuery(ast, context) {\n // in the event that the first step before this is a style step we need\n // to ensure the styles are applied before the children are animated\n const startTime = context.currentTimeline.currentTime;\n const options = (ast.options || {});\n const delay = options.delay ? resolveTimingValue(options.delay) : 0;\n if (delay &&\n (context.previousNode.type === AnimationMetadataType.Style ||\n (startTime == 0 && context.currentTimeline.hasCurrentStyleProperties()))) {\n context.currentTimeline.snapshotCurrentStyles();\n context.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;\n }\n let furthestTime = startTime;\n const elms = context.invokeQuery(ast.selector, ast.originalSelector, ast.limit, ast.includeSelf, options.optional ? true : false, context.errors);\n context.currentQueryTotal = elms.length;\n let sameElementTimeline = null;\n elms.forEach((element, i) => {\n context.currentQueryIndex = i;\n const innerContext = context.createSubContext(ast.options, element);\n if (delay) {\n innerContext.delayNextStep(delay);\n }\n if (element === context.element) {\n sameElementTimeline = innerContext.currentTimeline;\n }\n visitDslNode(this, ast.animation, innerContext);\n // this is here just incase the inner steps only contain or end\n // with a style() call (which is here to signal that this is a preparatory\n // call to style an element before it is animated again)\n innerContext.currentTimeline.applyStylesToKeyframe();\n const endTime = innerContext.currentTimeline.currentTime;\n furthestTime = Math.max(furthestTime, endTime);\n });\n context.currentQueryIndex = 0;\n context.currentQueryTotal = 0;\n context.transformIntoNewTimeline(furthestTime);\n if (sameElementTimeline) {\n context.currentTimeline.mergeTimelineCollectedStyles(sameElementTimeline);\n context.currentTimeline.snapshotCurrentStyles();\n }\n context.previousNode = ast;\n }\n visitStagger(ast, context) {\n const parentContext = context.parentContext;\n const tl = context.currentTimeline;\n const timings = ast.timings;\n const duration = Math.abs(timings.duration);\n const maxTime = duration * (context.currentQueryTotal - 1);\n let delay = duration * context.currentQueryIndex;\n let staggerTransformer = timings.duration < 0 ? 'reverse' : timings.easing;\n switch (staggerTransformer) {\n case 'reverse':\n delay = maxTime - delay;\n break;\n case 'full':\n delay = parentContext.currentStaggerTime;\n break;\n }\n const timeline = context.currentTimeline;\n if (delay) {\n timeline.delayNextStep(delay);\n }\n const startingTime = timeline.currentTime;\n visitDslNode(this, ast.animation, context);\n context.previousNode = ast;\n // time = duration + delay\n // the reason why this computation is so complex is because\n // the inner timeline may either have a delay value or a stretched\n // keyframe depending on if a subtimeline is not used or is used.\n parentContext.currentStaggerTime =\n tl.currentTime - startingTime + (tl.startTime - parentContext.currentTimeline.startTime);\n }\n}\nconst DEFAULT_NOOP_PREVIOUS_NODE = {};\nclass AnimationTimelineContext {\n _driver;\n element;\n subInstructions;\n _enterClassName;\n _leaveClassName;\n errors;\n timelines;\n parentContext = null;\n currentTimeline;\n currentAnimateTimings = null;\n previousNode = DEFAULT_NOOP_PREVIOUS_NODE;\n subContextCount = 0;\n options = {};\n currentQueryIndex = 0;\n currentQueryTotal = 0;\n currentStaggerTime = 0;\n constructor(_driver, element, subInstructions, _enterClassName, _leaveClassName, errors, timelines, initialTimeline) {\n this._driver = _driver;\n this.element = element;\n this.subInstructions = subInstructions;\n this._enterClassName = _enterClassName;\n this._leaveClassName = _leaveClassName;\n this.errors = errors;\n this.timelines = timelines;\n this.currentTimeline = initialTimeline || new TimelineBuilder(this._driver, element, 0);\n timelines.push(this.currentTimeline);\n }\n get params() {\n return this.options.params;\n }\n updateOptions(options, skipIfExists) {\n if (!options)\n return;\n const newOptions = options;\n let optionsToUpdate = this.options;\n // NOTE: this will get patched up when other animation methods support duration overrides\n if (newOptions.duration != null) {\n optionsToUpdate.duration = resolveTimingValue(newOptions.duration);\n }\n if (newOptions.delay != null) {\n optionsToUpdate.delay = resolveTimingValue(newOptions.delay);\n }\n const newParams = newOptions.params;\n if (newParams) {\n let paramsToUpdate = optionsToUpdate.params;\n if (!paramsToUpdate) {\n paramsToUpdate = this.options.params = {};\n }\n Object.keys(newParams).forEach((name) => {\n if (!skipIfExists || !paramsToUpdate.hasOwnProperty(name)) {\n paramsToUpdate[name] = interpolateParams(newParams[name], paramsToUpdate, this.errors);\n }\n });\n }\n }\n _copyOptions() {\n const options = {};\n if (this.options) {\n const oldParams = this.options.params;\n if (oldParams) {\n const params = (options['params'] = {});\n Object.keys(oldParams).forEach((name) => {\n params[name] = oldParams[name];\n });\n }\n }\n return options;\n }\n createSubContext(options = null, element, newTime) {\n const target = element || this.element;\n const context = new AnimationTimelineContext(this._driver, target, this.subInstructions, this._enterClassName, this._leaveClassName, this.errors, this.timelines, this.currentTimeline.fork(target, newTime || 0));\n context.previousNode = this.previousNode;\n context.currentAnimateTimings = this.currentAnimateTimings;\n context.options = this._copyOptions();\n context.updateOptions(options);\n context.currentQueryIndex = this.currentQueryIndex;\n context.currentQueryTotal = this.currentQueryTotal;\n context.parentContext = this;\n this.subContextCount++;\n return context;\n }\n transformIntoNewTimeline(newTime) {\n this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;\n this.currentTimeline = this.currentTimeline.fork(this.element, newTime);\n this.timelines.push(this.currentTimeline);\n return this.currentTimeline;\n }\n appendInstructionToTimeline(instruction, duration, delay) {\n const updatedTimings = {\n duration: duration != null ? duration : instruction.duration,\n delay: this.currentTimeline.currentTime + (delay != null ? delay : 0) + instruction.delay,\n easing: '',\n };\n const builder = new SubTimelineBuilder(this._driver, instruction.element, instruction.keyframes, instruction.preStyleProps, instruction.postStyleProps, updatedTimings, instruction.stretchStartingKeyframe);\n this.timelines.push(builder);\n return updatedTimings;\n }\n incrementTime(time) {\n this.currentTimeline.forwardTime(this.currentTimeline.duration + time);\n }\n delayNextStep(delay) {\n // negative delays are not yet supported\n if (delay > 0) {\n this.currentTimeline.delayNextStep(delay);\n }\n }\n invokeQuery(selector, originalSelector, limit, includeSelf, optional, errors) {\n let results = [];\n if (includeSelf) {\n results.push(this.element);\n }\n if (selector.length > 0) {\n // only if :self is used then the selector can be empty\n selector = selector.replace(ENTER_TOKEN_REGEX, '.' + this._enterClassName);\n selector = selector.replace(LEAVE_TOKEN_REGEX, '.' + this._leaveClassName);\n const multi = limit != 1;\n let elements = this._driver.query(this.element, selector, multi);\n if (limit !== 0) {\n elements =\n limit < 0\n ? elements.slice(elements.length + limit, elements.length)\n : elements.slice(0, limit);\n }\n results.push(...elements);\n }\n if (!optional && results.length == 0) {\n errors.push(invalidQuery(originalSelector));\n }\n return results;\n }\n}\nclass TimelineBuilder {\n _driver;\n element;\n startTime;\n _elementTimelineStylesLookup;\n duration = 0;\n easing = null;\n _previousKeyframe = new Map();\n _currentKeyframe = new Map();\n _keyframes = new Map();\n _styleSummary = new Map();\n _localTimelineStyles = new Map();\n _globalTimelineStyles;\n _pendingStyles = new Map();\n _backFill = new Map();\n _currentEmptyStepKeyframe = null;\n constructor(_driver, element, startTime, _elementTimelineStylesLookup) {\n this._driver = _driver;\n this.element = element;\n this.startTime = startTime;\n this._elementTimelineStylesLookup = _elementTimelineStylesLookup;\n if (!this._elementTimelineStylesLookup) {\n this._elementTimelineStylesLookup = new Map();\n }\n this._globalTimelineStyles = this._elementTimelineStylesLookup.get(element);\n if (!this._globalTimelineStyles) {\n this._globalTimelineStyles = this._localTimelineStyles;\n this._elementTimelineStylesLookup.set(element, this._localTimelineStyles);\n }\n this._loadKeyframe();\n }\n containsAnimation() {\n switch (this._keyframes.size) {\n case 0:\n return false;\n case 1:\n return this.hasCurrentStyleProperties();\n default:\n return true;\n }\n }\n hasCurrentStyleProperties() {\n return this._currentKeyframe.size > 0;\n }\n get currentTime() {\n return this.startTime + this.duration;\n }\n delayNextStep(delay) {\n // in the event that a style() step is placed right before a stagger()\n // and that style() step is the very first style() value in the animation\n // then we need to make a copy of the keyframe [0, copy, 1] so that the delay\n // properly applies the style() values to work with the stagger...\n const hasPreStyleStep = this._keyframes.size === 1 && this._pendingStyles.size;\n if (this.duration || hasPreStyleStep) {\n this.forwardTime(this.currentTime + delay);\n if (hasPreStyleStep) {\n this.snapshotCurrentStyles();\n }\n }\n else {\n this.startTime += delay;\n }\n }\n fork(element, currentTime) {\n this.applyStylesToKeyframe();\n return new TimelineBuilder(this._driver, element, currentTime || this.currentTime, this._elementTimelineStylesLookup);\n }\n _loadKeyframe() {\n if (this._currentKeyframe) {\n this._previousKeyframe = this._currentKeyframe;\n }\n this._currentKeyframe = this._keyframes.get(this.duration);\n if (!this._currentKeyframe) {\n this._currentKeyframe = new Map();\n this._keyframes.set(this.duration, this._currentKeyframe);\n }\n }\n forwardFrame() {\n this.duration += ONE_FRAME_IN_MILLISECONDS;\n this._loadKeyframe();\n }\n forwardTime(time) {\n this.applyStylesToKeyframe();\n this.duration = time;\n this._loadKeyframe();\n }\n _updateStyle(prop, value) {\n this._localTimelineStyles.set(prop, value);\n this._globalTimelineStyles.set(prop, value);\n this._styleSummary.set(prop, { time: this.currentTime, value });\n }\n allowOnlyTimelineStyles() {\n return this._currentEmptyStepKeyframe !== this._currentKeyframe;\n }\n applyEmptyStep(easing) {\n if (easing) {\n this._previousKeyframe.set('easing', easing);\n }\n // special case for animate(duration):\n // all missing styles are filled with a `*` value then\n // if any destination styles are filled in later on the same\n // keyframe then they will override the overridden styles\n // We use `_globalTimelineStyles` here because there may be\n // styles in previous keyframes that are not present in this timeline\n for (let [prop, value] of this._globalTimelineStyles) {\n this._backFill.set(prop, value || AUTO_STYLE);\n this._currentKeyframe.set(prop, AUTO_STYLE);\n }\n this._currentEmptyStepKeyframe = this._currentKeyframe;\n }\n setStyles(input, easing, errors, options) {\n if (easing) {\n this._previousKeyframe.set('easing', easing);\n }\n const params = (options && options.params) || {};\n const styles = flattenStyles(input, this._globalTimelineStyles);\n for (let [prop, value] of styles) {\n const val = interpolateParams(value, params, errors);\n this._pendingStyles.set(prop, val);\n if (!this._localTimelineStyles.has(prop)) {\n this._backFill.set(prop, this._globalTimelineStyles.get(prop) ?? AUTO_STYLE);\n }\n this._updateStyle(prop, val);\n }\n }\n applyStylesToKeyframe() {\n if (this._pendingStyles.size == 0)\n return;\n this._pendingStyles.forEach((val, prop) => {\n this._currentKeyframe.set(prop, val);\n });\n this._pendingStyles.clear();\n this._localTimelineStyles.forEach((val, prop) => {\n if (!this._currentKeyframe.has(prop)) {\n this._currentKeyframe.set(prop, val);\n }\n });\n }\n snapshotCurrentStyles() {\n for (let [prop, val] of this._localTimelineStyles) {\n this._pendingStyles.set(prop, val);\n this._updateStyle(prop, val);\n }\n }\n getFinalKeyframe() {\n return this._keyframes.get(this.duration);\n }\n get properties() {\n const properties = [];\n for (let prop in this._currentKeyframe) {\n properties.push(prop);\n }\n return properties;\n }\n mergeTimelineCollectedStyles(timeline) {\n timeline._styleSummary.forEach((details1, prop) => {\n const details0 = this._styleSummary.get(prop);\n if (!details0 || details1.time > details0.time) {\n this._updateStyle(prop, details1.value);\n }\n });\n }\n buildKeyframes() {\n this.applyStylesToKeyframe();\n const preStyleProps = new Set();\n const postStyleProps = new Set();\n const isEmpty = this._keyframes.size === 1 && this.duration === 0;\n let finalKeyframes = [];\n this._keyframes.forEach((keyframe, time) => {\n const finalKeyframe = new Map([...this._backFill, ...keyframe]);\n finalKeyframe.forEach((value, prop) => {\n if (value === ɵPRE_STYLE) {\n preStyleProps.add(prop);\n }\n else if (value === AUTO_STYLE) {\n postStyleProps.add(prop);\n }\n });\n if (!isEmpty) {\n finalKeyframe.set('offset', time / this.duration);\n }\n finalKeyframes.push(finalKeyframe);\n });\n const preProps = [...preStyleProps.values()];\n const postProps = [...postStyleProps.values()];\n // special case for a 0-second animation (which is designed just to place styles onscreen)\n if (isEmpty) {\n const kf0 = finalKeyframes[0];\n const kf1 = new Map(kf0);\n kf0.set('offset', 0);\n kf1.set('offset', 1);\n finalKeyframes = [kf0, kf1];\n }\n return createTimelineInstruction(this.element, finalKeyframes, preProps, postProps, this.duration, this.startTime, this.easing, false);\n }\n}\nclass SubTimelineBuilder extends TimelineBuilder {\n keyframes;\n preStyleProps;\n postStyleProps;\n _stretchStartingKeyframe;\n timings;\n constructor(driver, element, keyframes, preStyleProps, postStyleProps, timings, _stretchStartingKeyframe = false) {\n super(driver, element, timings.delay);\n this.keyframes = keyframes;\n this.preStyleProps = preStyleProps;\n this.postStyleProps = postStyleProps;\n this._stretchStartingKeyframe = _stretchStartingKeyframe;\n this.timings = { duration: timings.duration, delay: timings.delay, easing: timings.easing };\n }\n containsAnimation() {\n return this.keyframes.length > 1;\n }\n buildKeyframes() {\n let keyframes = this.keyframes;\n let { delay, duration, easing } = this.timings;\n if (this._stretchStartingKeyframe && delay) {\n const newKeyframes = [];\n const totalTime = duration + delay;\n const startingGap = delay / totalTime;\n // the original starting keyframe now starts once the delay is done\n const newFirstKeyframe = new Map(keyframes[0]);\n newFirstKeyframe.set('offset', 0);\n newKeyframes.push(newFirstKeyframe);\n const oldFirstKeyframe = new Map(keyframes[0]);\n oldFirstKeyframe.set('offset', roundOffset(startingGap));\n newKeyframes.push(oldFirstKeyframe);\n /*\n When the keyframe is stretched then it means that the delay before the animation\n starts is gone. Instead the first keyframe is placed at the start of the animation\n and it is then copied to where it starts when the original delay is over. This basically\n means nothing animates during that delay, but the styles are still rendered. For this\n to work the original offset values that exist in the original keyframes must be \"warped\"\n so that they can take the new keyframe + delay into account.\n \n delay=1000, duration=1000, keyframes = 0 .5 1\n \n turns into\n \n delay=0, duration=2000, keyframes = 0 .33 .66 1\n */\n // offsets between 1 ... n -1 are all warped by the keyframe stretch\n const limit = keyframes.length - 1;\n for (let i = 1; i <= limit; i++) {\n let kf = new Map(keyframes[i]);\n const oldOffset = kf.get('offset');\n const timeAtKeyframe = delay + oldOffset * duration;\n kf.set('offset', roundOffset(timeAtKeyframe / totalTime));\n newKeyframes.push(kf);\n }\n // the new starting keyframe should be added at the start\n duration = totalTime;\n delay = 0;\n easing = '';\n keyframes = newKeyframes;\n }\n return createTimelineInstruction(this.element, keyframes, this.preStyleProps, this.postStyleProps, duration, delay, easing, true);\n }\n}\nfunction roundOffset(offset, decimalPoints = 3) {\n const mult = Math.pow(10, decimalPoints - 1);\n return Math.round(offset * mult) / mult;\n}\nfunction flattenStyles(input, allStyles) {\n const styles = new Map();\n let allProperties;\n input.forEach((token) => {\n if (token === '*') {\n allProperties ??= allStyles.keys();\n for (let prop of allProperties) {\n styles.set(prop, AUTO_STYLE);\n }\n }\n else {\n for (let [prop, val] of token) {\n styles.set(prop, val);\n }\n }\n });\n return styles;\n}\n\nfunction createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps, totalTime, errors) {\n return {\n type: 0 /* AnimationTransitionInstructionType.TransitionAnimation */,\n element,\n triggerName,\n isRemovalTransition,\n fromState,\n fromStyles,\n toState,\n toStyles,\n timelines,\n queriedElements,\n preStyleProps,\n postStyleProps,\n totalTime,\n errors,\n };\n}\n\nconst EMPTY_OBJECT = {};\nclass AnimationTransitionFactory {\n _triggerName;\n ast;\n _stateStyles;\n constructor(_triggerName, ast, _stateStyles) {\n this._triggerName = _triggerName;\n this.ast = ast;\n this._stateStyles = _stateStyles;\n }\n match(currentState, nextState, element, params) {\n return oneOrMoreTransitionsMatch(this.ast.matchers, currentState, nextState, element, params);\n }\n buildStyles(stateName, params, errors) {\n let styler = this._stateStyles.get('*');\n if (stateName !== undefined) {\n styler = this._stateStyles.get(stateName?.toString()) || styler;\n }\n return styler ? styler.buildStyles(params, errors) : new Map();\n }\n build(driver, element, currentState, nextState, enterClassName, leaveClassName, currentOptions, nextOptions, subInstructions, skipAstBuild) {\n const errors = [];\n const transitionAnimationParams = (this.ast.options && this.ast.options.params) || EMPTY_OBJECT;\n const currentAnimationParams = (currentOptions && currentOptions.params) || EMPTY_OBJECT;\n const currentStateStyles = this.buildStyles(currentState, currentAnimationParams, errors);\n const nextAnimationParams = (nextOptions && nextOptions.params) || EMPTY_OBJECT;\n const nextStateStyles = this.buildStyles(nextState, nextAnimationParams, errors);\n const queriedElements = new Set();\n const preStyleMap = new Map();\n const postStyleMap = new Map();\n const isRemoval = nextState === 'void';\n const animationOptions = {\n params: applyParamDefaults(nextAnimationParams, transitionAnimationParams),\n delay: this.ast.options?.delay,\n };\n const timelines = skipAstBuild\n ? []\n : buildAnimationTimelines(driver, element, this.ast.animation, enterClassName, leaveClassName, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors);\n let totalTime = 0;\n timelines.forEach((tl) => {\n totalTime = Math.max(tl.duration + tl.delay, totalTime);\n });\n if (errors.length) {\n return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, [], [], preStyleMap, postStyleMap, totalTime, errors);\n }\n timelines.forEach((tl) => {\n const elm = tl.element;\n const preProps = getOrSetDefaultValue(preStyleMap, elm, new Set());\n tl.preStyleProps.forEach((prop) => preProps.add(prop));\n const postProps = getOrSetDefaultValue(postStyleMap, elm, new Set());\n tl.postStyleProps.forEach((prop) => postProps.add(prop));\n if (elm !== element) {\n queriedElements.add(elm);\n }\n });\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n checkNonAnimatableInTimelines(timelines, this._triggerName, driver);\n }\n return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, timelines, [...queriedElements.values()], preStyleMap, postStyleMap, totalTime);\n }\n}\n/**\n * Checks inside a set of timelines if they try to animate a css property which is not considered\n * animatable, in that case it prints a warning on the console.\n * Besides that the function doesn't have any other effect.\n *\n * Note: this check is done here after the timelines are built instead of doing on a lower level so\n * that we can make sure that the warning appears only once per instruction (we can aggregate here\n * all the issues instead of finding them separately).\n *\n * @param timelines The built timelines for the current instruction.\n * @param triggerName The name of the trigger for the current instruction.\n * @param driver Animation driver used to perform the check.\n *\n */\nfunction checkNonAnimatableInTimelines(timelines, triggerName, driver) {\n if (!driver.validateAnimatableStyleProperty) {\n return;\n }\n const allowedNonAnimatableProps = new Set([\n // 'easing' is a utility/synthetic prop we use to represent\n // easing functions, it represents a property of the animation\n // which is not animatable but different values can be used\n // in different steps\n 'easing',\n ]);\n const invalidNonAnimatableProps = new Set();\n timelines.forEach(({ keyframes }) => {\n const nonAnimatablePropsInitialValues = new Map();\n keyframes.forEach((keyframe) => {\n const entriesToCheck = Array.from(keyframe.entries()).filter(([prop]) => !allowedNonAnimatableProps.has(prop));\n for (const [prop, value] of entriesToCheck) {\n if (!driver.validateAnimatableStyleProperty(prop)) {\n if (nonAnimatablePropsInitialValues.has(prop) && !invalidNonAnimatableProps.has(prop)) {\n const propInitialValue = nonAnimatablePropsInitialValues.get(prop);\n if (propInitialValue !== value) {\n invalidNonAnimatableProps.add(prop);\n }\n }\n else {\n nonAnimatablePropsInitialValues.set(prop, value);\n }\n }\n }\n });\n });\n if (invalidNonAnimatableProps.size > 0) {\n console.warn(`Warning: The animation trigger \"${triggerName}\" is attempting to animate the following` +\n ' not animatable properties: ' +\n Array.from(invalidNonAnimatableProps).join(', ') +\n '\\n' +\n '(to check the list of all animatable properties visit https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties)');\n }\n}\nfunction oneOrMoreTransitionsMatch(matchFns, currentState, nextState, element, params) {\n return matchFns.some((fn) => fn(currentState, nextState, element, params));\n}\nfunction applyParamDefaults(userParams, defaults) {\n const result = { ...defaults };\n Object.entries(userParams).forEach(([key, value]) => {\n if (value != null) {\n result[key] = value;\n }\n });\n return result;\n}\nclass AnimationStateStyles {\n styles;\n defaultParams;\n normalizer;\n constructor(styles, defaultParams, normalizer) {\n this.styles = styles;\n this.defaultParams = defaultParams;\n this.normalizer = normalizer;\n }\n buildStyles(params, errors) {\n const finalStyles = new Map();\n const combinedParams = applyParamDefaults(params, this.defaultParams);\n this.styles.styles.forEach((value) => {\n if (typeof value !== 'string') {\n value.forEach((val, prop) => {\n if (val) {\n val = interpolateParams(val, combinedParams, errors);\n }\n const normalizedProp = this.normalizer.normalizePropertyName(prop, errors);\n val = this.normalizer.normalizeStyleValue(prop, normalizedProp, val, errors);\n finalStyles.set(prop, val);\n });\n }\n });\n return finalStyles;\n }\n}\n\nfunction buildTrigger(name, ast, normalizer) {\n return new AnimationTrigger(name, ast, normalizer);\n}\nclass AnimationTrigger {\n name;\n ast;\n _normalizer;\n transitionFactories = [];\n fallbackTransition;\n states = new Map();\n constructor(name, ast, _normalizer) {\n this.name = name;\n this.ast = ast;\n this._normalizer = _normalizer;\n ast.states.forEach((ast) => {\n const defaultParams = (ast.options && ast.options.params) || {};\n this.states.set(ast.name, new AnimationStateStyles(ast.style, defaultParams, _normalizer));\n });\n balanceProperties(this.states, 'true', '1');\n balanceProperties(this.states, 'false', '0');\n ast.transitions.forEach((ast) => {\n this.transitionFactories.push(new AnimationTransitionFactory(name, ast, this.states));\n });\n this.fallbackTransition = createFallbackTransition(name, this.states, this._normalizer);\n }\n get containsQueries() {\n return this.ast.queryCount > 0;\n }\n matchTransition(currentState, nextState, element, params) {\n const entry = this.transitionFactories.find((f) => f.match(currentState, nextState, element, params));\n return entry || null;\n }\n matchStyles(currentState, params, errors) {\n return this.fallbackTransition.buildStyles(currentState, params, errors);\n }\n}\nfunction createFallbackTransition(triggerName, states, normalizer) {\n const matchers = [(fromState, toState) => true];\n const animation = { type: AnimationMetadataType.Sequence, steps: [], options: null };\n const transition = {\n type: AnimationMetadataType.Transition,\n animation,\n matchers,\n options: null,\n queryCount: 0,\n depCount: 0,\n };\n return new AnimationTransitionFactory(triggerName, transition, states);\n}\nfunction balanceProperties(stateMap, key1, key2) {\n if (stateMap.has(key1)) {\n if (!stateMap.has(key2)) {\n stateMap.set(key2, stateMap.get(key1));\n }\n }\n else if (stateMap.has(key2)) {\n stateMap.set(key1, stateMap.get(key2));\n }\n}\n\nconst EMPTY_INSTRUCTION_MAP = new ElementInstructionMap();\nclass TimelineAnimationEngine {\n bodyNode;\n _driver;\n _normalizer;\n _animations = new Map();\n _playersById = new Map();\n players = [];\n constructor(bodyNode, _driver, _normalizer) {\n this.bodyNode = bodyNode;\n this._driver = _driver;\n this._normalizer = _normalizer;\n }\n register(id, metadata) {\n const errors = [];\n const warnings = [];\n const ast = buildAnimationAst(this._driver, metadata, errors, warnings);\n if (errors.length) {\n throw registerFailed(errors);\n }\n else {\n if (warnings.length) {\n warnRegister(warnings);\n }\n this._animations.set(id, ast);\n }\n }\n _buildPlayer(i, preStyles, postStyles) {\n const element = i.element;\n const keyframes = normalizeKeyframes$1(this._normalizer, i.keyframes, preStyles, postStyles);\n return this._driver.animate(element, keyframes, i.duration, i.delay, i.easing, [], true);\n }\n create(id, element, options = {}) {\n const errors = [];\n const ast = this._animations.get(id);\n let instructions;\n const autoStylesMap = new Map();\n if (ast) {\n instructions = buildAnimationTimelines(this._driver, element, ast, ENTER_CLASSNAME, LEAVE_CLASSNAME, new Map(), new Map(), options, EMPTY_INSTRUCTION_MAP, errors);\n instructions.forEach((inst) => {\n const styles = getOrSetDefaultValue(autoStylesMap, inst.element, new Map());\n inst.postStyleProps.forEach((prop) => styles.set(prop, null));\n });\n }\n else {\n errors.push(missingOrDestroyedAnimation());\n instructions = [];\n }\n if (errors.length) {\n throw createAnimationFailed(errors);\n }\n autoStylesMap.forEach((styles, element) => {\n styles.forEach((_, prop) => {\n styles.set(prop, this._driver.computeStyle(element, prop, AUTO_STYLE));\n });\n });\n const players = instructions.map((i) => {\n const styles = autoStylesMap.get(i.element);\n return this._buildPlayer(i, new Map(), styles);\n });\n const player = optimizeGroupPlayer(players);\n this._playersById.set(id, player);\n player.onDestroy(() => this.destroy(id));\n this.players.push(player);\n return player;\n }\n destroy(id) {\n const player = this._getPlayer(id);\n player.destroy();\n this._playersById.delete(id);\n const index = this.players.indexOf(player);\n if (index >= 0) {\n this.players.splice(index, 1);\n }\n }\n _getPlayer(id) {\n const player = this._playersById.get(id);\n if (!player) {\n throw missingPlayer(id);\n }\n return player;\n }\n listen(id, element, eventName, callback) {\n // triggerName, fromState, toState are all ignored for timeline animations\n const baseEvent = makeAnimationEvent(element, '', '', '');\n listenOnPlayer(this._getPlayer(id), eventName, baseEvent, callback);\n return () => { };\n }\n command(id, element, command, args) {\n if (command == 'register') {\n this.register(id, args[0]);\n return;\n }\n if (command == 'create') {\n const options = (args[0] || {});\n this.create(id, element, options);\n return;\n }\n const player = this._getPlayer(id);\n switch (command) {\n case 'play':\n player.play();\n break;\n case 'pause':\n player.pause();\n break;\n case 'reset':\n player.reset();\n break;\n case 'restart':\n player.restart();\n break;\n case 'finish':\n player.finish();\n break;\n case 'init':\n player.init();\n break;\n case 'setPosition':\n player.setPosition(parseFloat(args[0]));\n break;\n case 'destroy':\n this.destroy(id);\n break;\n }\n }\n}\n\nconst QUEUED_CLASSNAME = 'ng-animate-queued';\nconst QUEUED_SELECTOR = '.ng-animate-queued';\nconst DISABLED_CLASSNAME = 'ng-animate-disabled';\nconst DISABLED_SELECTOR = '.ng-animate-disabled';\nconst STAR_CLASSNAME = 'ng-star-inserted';\nconst STAR_SELECTOR = '.ng-star-inserted';\nconst EMPTY_PLAYER_ARRAY = [];\nconst NULL_REMOVAL_STATE = {\n namespaceId: '',\n setForRemoval: false,\n setForMove: false,\n hasAnimation: false,\n removedBeforeQueried: false,\n};\nconst NULL_REMOVED_QUERIED_STATE = {\n namespaceId: '',\n setForMove: false,\n setForRemoval: false,\n hasAnimation: false,\n removedBeforeQueried: true,\n};\nconst REMOVAL_FLAG = '__ng_removed';\nclass StateValue {\n namespaceId;\n value;\n options;\n get params() {\n return this.options.params;\n }\n constructor(input, namespaceId = '') {\n this.namespaceId = namespaceId;\n const isObj = input && input.hasOwnProperty('value');\n const value = isObj ? input['value'] : input;\n this.value = normalizeTriggerValue(value);\n if (isObj) {\n // we drop the value property from options.\n const { value, ...options } = input;\n this.options = options;\n }\n else {\n this.options = {};\n }\n if (!this.options.params) {\n this.options.params = {};\n }\n }\n absorbOptions(options) {\n const newParams = options.params;\n if (newParams) {\n const oldParams = this.options.params;\n Object.keys(newParams).forEach((prop) => {\n if (oldParams[prop] == null) {\n oldParams[prop] = newParams[prop];\n }\n });\n }\n }\n}\nconst VOID_VALUE = 'void';\nconst DEFAULT_STATE_VALUE = new StateValue(VOID_VALUE);\nclass AnimationTransitionNamespace {\n id;\n hostElement;\n _engine;\n players = [];\n _triggers = new Map();\n _queue = [];\n _elementListeners = new Map();\n _hostClassName;\n constructor(id, hostElement, _engine) {\n this.id = id;\n this.hostElement = hostElement;\n this._engine = _engine;\n this._hostClassName = 'ng-tns-' + id;\n addClass(hostElement, this._hostClassName);\n }\n listen(element, name, phase, callback) {\n if (!this._triggers.has(name)) {\n throw missingTrigger(phase, name);\n }\n if (phase == null || phase.length == 0) {\n throw missingEvent(name);\n }\n if (!isTriggerEventValid(phase)) {\n throw unsupportedTriggerEvent(phase, name);\n }\n const listeners = getOrSetDefaultValue(this._elementListeners, element, []);\n const data = { name, phase, callback };\n listeners.push(data);\n const triggersWithStates = getOrSetDefaultValue(this._engine.statesByElement, element, new Map());\n if (!triggersWithStates.has(name)) {\n addClass(element, NG_TRIGGER_CLASSNAME);\n addClass(element, NG_TRIGGER_CLASSNAME + '-' + name);\n triggersWithStates.set(name, DEFAULT_STATE_VALUE);\n }\n return () => {\n // the event listener is removed AFTER the flush has occurred such\n // that leave animations callbacks can fire (otherwise if the node\n // is removed in between then the listeners would be deregistered)\n this._engine.afterFlush(() => {\n const index = listeners.indexOf(data);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n if (!this._triggers.has(name)) {\n triggersWithStates.delete(name);\n }\n });\n };\n }\n register(name, ast) {\n if (this._triggers.has(name)) {\n // throw\n return false;\n }\n else {\n this._triggers.set(name, ast);\n return true;\n }\n }\n _getTrigger(name) {\n const trigger = this._triggers.get(name);\n if (!trigger) {\n throw unregisteredTrigger(name);\n }\n return trigger;\n }\n trigger(element, triggerName, value, defaultToFallback = true) {\n const trigger = this._getTrigger(triggerName);\n const player = new TransitionAnimationPlayer(this.id, triggerName, element);\n let triggersWithStates = this._engine.statesByElement.get(element);\n if (!triggersWithStates) {\n addClass(element, NG_TRIGGER_CLASSNAME);\n addClass(element, NG_TRIGGER_CLASSNAME + '-' + triggerName);\n this._engine.statesByElement.set(element, (triggersWithStates = new Map()));\n }\n let fromState = triggersWithStates.get(triggerName);\n const toState = new StateValue(value, this.id);\n const isObj = value && value.hasOwnProperty('value');\n if (!isObj && fromState) {\n toState.absorbOptions(fromState.options);\n }\n triggersWithStates.set(triggerName, toState);\n if (!fromState) {\n fromState = DEFAULT_STATE_VALUE;\n }\n const isRemoval = toState.value === VOID_VALUE;\n // normally this isn't reached by here, however, if an object expression\n // is passed in then it may be a new object each time. Comparing the value\n // is important since that will stay the same despite there being a new object.\n // The removal arc here is special cased because the same element is triggered\n // twice in the event that it contains animations on the outer/inner portions\n // of the host container\n if (!isRemoval && fromState.value === toState.value) {\n // this means that despite the value not changing, some inner params\n // have changed which means that the animation final styles need to be applied\n if (!objEquals(fromState.params, toState.params)) {\n const errors = [];\n const fromStyles = trigger.matchStyles(fromState.value, fromState.params, errors);\n const toStyles = trigger.matchStyles(toState.value, toState.params, errors);\n if (errors.length) {\n this._engine.reportError(errors);\n }\n else {\n this._engine.afterFlush(() => {\n eraseStyles(element, fromStyles);\n setStyles(element, toStyles);\n });\n }\n }\n return;\n }\n const playersOnElement = getOrSetDefaultValue(this._engine.playersByElement, element, []);\n playersOnElement.forEach((player) => {\n // only remove the player if it is queued on the EXACT same trigger/namespace\n // we only also deal with queued players here because if the animation has\n // started then we want to keep the player alive until the flush happens\n // (which is where the previousPlayers are passed into the new player)\n if (player.namespaceId == this.id && player.triggerName == triggerName && player.queued) {\n player.destroy();\n }\n });\n let transition = trigger.matchTransition(fromState.value, toState.value, element, toState.params);\n let isFallbackTransition = false;\n if (!transition) {\n if (!defaultToFallback)\n return;\n transition = trigger.fallbackTransition;\n isFallbackTransition = true;\n }\n this._engine.totalQueuedPlayers++;\n this._queue.push({\n element,\n triggerName,\n transition,\n fromState,\n toState,\n player,\n isFallbackTransition,\n });\n if (!isFallbackTransition) {\n addClass(element, QUEUED_CLASSNAME);\n player.onStart(() => {\n removeClass(element, QUEUED_CLASSNAME);\n });\n }\n player.onDone(() => {\n let index = this.players.indexOf(player);\n if (index >= 0) {\n this.players.splice(index, 1);\n }\n const players = this._engine.playersByElement.get(element);\n if (players) {\n let index = players.indexOf(player);\n if (index >= 0) {\n players.splice(index, 1);\n }\n }\n });\n this.players.push(player);\n playersOnElement.push(player);\n return player;\n }\n deregister(name) {\n this._triggers.delete(name);\n this._engine.statesByElement.forEach((stateMap) => stateMap.delete(name));\n this._elementListeners.forEach((listeners, element) => {\n this._elementListeners.set(element, listeners.filter((entry) => {\n return entry.name != name;\n }));\n });\n }\n clearElementCache(element) {\n this._engine.statesByElement.delete(element);\n this._elementListeners.delete(element);\n const elementPlayers = this._engine.playersByElement.get(element);\n if (elementPlayers) {\n elementPlayers.forEach((player) => player.destroy());\n this._engine.playersByElement.delete(element);\n }\n }\n _signalRemovalForInnerTriggers(rootElement, context) {\n const elements = this._engine.driver.query(rootElement, NG_TRIGGER_SELECTOR, true);\n // emulate a leave animation for all inner nodes within this node.\n // If there are no animations found for any of the nodes then clear the cache\n // for the element.\n elements.forEach((elm) => {\n // this means that an inner remove() operation has already kicked off\n // the animation on this element...\n if (elm[REMOVAL_FLAG])\n return;\n const namespaces = this._engine.fetchNamespacesByElement(elm);\n if (namespaces.size) {\n namespaces.forEach((ns) => ns.triggerLeaveAnimation(elm, context, false, true));\n }\n else {\n this.clearElementCache(elm);\n }\n });\n // If the child elements were removed along with the parent, their animations might not\n // have completed. Clear all the elements from the cache so we don't end up with a memory leak.\n this._engine.afterFlushAnimationsDone(() => elements.forEach((elm) => this.clearElementCache(elm)));\n }\n triggerLeaveAnimation(element, context, destroyAfterComplete, defaultToFallback) {\n const triggerStates = this._engine.statesByElement.get(element);\n const previousTriggersValues = new Map();\n if (triggerStates) {\n const players = [];\n triggerStates.forEach((state, triggerName) => {\n previousTriggersValues.set(triggerName, state.value);\n // this check is here in the event that an element is removed\n // twice (both on the host level and the component level)\n if (this._triggers.has(triggerName)) {\n const player = this.trigger(element, triggerName, VOID_VALUE, defaultToFallback);\n if (player) {\n players.push(player);\n }\n }\n });\n if (players.length) {\n this._engine.markElementAsRemoved(this.id, element, true, context, previousTriggersValues);\n if (destroyAfterComplete) {\n optimizeGroupPlayer(players).onDone(() => this._engine.processLeaveNode(element));\n }\n return true;\n }\n }\n return false;\n }\n prepareLeaveAnimationListeners(element) {\n const listeners = this._elementListeners.get(element);\n const elementStates = this._engine.statesByElement.get(element);\n // if this statement fails then it means that the element was picked up\n // by an earlier flush (or there are no listeners at all to track the leave).\n if (listeners && elementStates) {\n const visitedTriggers = new Set();\n listeners.forEach((listener) => {\n const triggerName = listener.name;\n if (visitedTriggers.has(triggerName))\n return;\n visitedTriggers.add(triggerName);\n const trigger = this._triggers.get(triggerName);\n const transition = trigger.fallbackTransition;\n const fromState = elementStates.get(triggerName) || DEFAULT_STATE_VALUE;\n const toState = new StateValue(VOID_VALUE);\n const player = new TransitionAnimationPlayer(this.id, triggerName, element);\n this._engine.totalQueuedPlayers++;\n this._queue.push({\n element,\n triggerName,\n transition,\n fromState,\n toState,\n player,\n isFallbackTransition: true,\n });\n });\n }\n }\n removeNode(element, context) {\n const engine = this._engine;\n if (element.childElementCount) {\n this._signalRemovalForInnerTriggers(element, context);\n }\n // this means that a * => VOID animation was detected and kicked off\n if (this.triggerLeaveAnimation(element, context, true))\n return;\n // find the player that is animating and make sure that the\n // removal is delayed until that player has completed\n let containsPotentialParentTransition = false;\n if (engine.totalAnimations) {\n const currentPlayers = engine.players.length\n ? engine.playersByQueriedElement.get(element)\n : [];\n // when this `if statement` does not continue forward it means that\n // a previous animation query has selected the current element and\n // is animating it. In this situation want to continue forwards and\n // allow the element to be queued up for animation later.\n if (currentPlayers && currentPlayers.length) {\n containsPotentialParentTransition = true;\n }\n else {\n let parent = element;\n while ((parent = parent.parentNode)) {\n const triggers = engine.statesByElement.get(parent);\n if (triggers) {\n containsPotentialParentTransition = true;\n break;\n }\n }\n }\n }\n // at this stage we know that the element will either get removed\n // during flush or will be picked up by a parent query. Either way\n // we need to fire the listeners for this element when it DOES get\n // removed (once the query parent animation is done or after flush)\n this.prepareLeaveAnimationListeners(element);\n // whether or not a parent has an animation we need to delay the deferral of the leave\n // operation until we have more information (which we do after flush() has been called)\n if (containsPotentialParentTransition) {\n engine.markElementAsRemoved(this.id, element, false, context);\n }\n else {\n const removalFlag = element[REMOVAL_FLAG];\n if (!removalFlag || removalFlag === NULL_REMOVAL_STATE) {\n // we do this after the flush has occurred such\n // that the callbacks can be fired\n engine.afterFlush(() => this.clearElementCache(element));\n engine.destroyInnerAnimations(element);\n engine._onRemovalComplete(element, context);\n }\n }\n }\n insertNode(element, parent) {\n addClass(element, this._hostClassName);\n }\n drainQueuedTransitions(microtaskId) {\n const instructions = [];\n this._queue.forEach((entry) => {\n const player = entry.player;\n if (player.destroyed)\n return;\n const element = entry.element;\n const listeners = this._elementListeners.get(element);\n if (listeners) {\n listeners.forEach((listener) => {\n if (listener.name == entry.triggerName) {\n const baseEvent = makeAnimationEvent(element, entry.triggerName, entry.fromState.value, entry.toState.value);\n baseEvent['_data'] = microtaskId;\n listenOnPlayer(entry.player, listener.phase, baseEvent, listener.callback);\n }\n });\n }\n if (player.markedForDestroy) {\n this._engine.afterFlush(() => {\n // now we can destroy the element properly since the event listeners have\n // been bound to the player\n player.destroy();\n });\n }\n else {\n instructions.push(entry);\n }\n });\n this._queue = [];\n return instructions.sort((a, b) => {\n // if depCount == 0 them move to front\n // otherwise if a contains b then move back\n const d0 = a.transition.ast.depCount;\n const d1 = b.transition.ast.depCount;\n if (d0 == 0 || d1 == 0) {\n return d0 - d1;\n }\n return this._engine.driver.containsElement(a.element, b.element) ? 1 : -1;\n });\n }\n destroy(context) {\n this.players.forEach((p) => p.destroy());\n this._signalRemovalForInnerTriggers(this.hostElement, context);\n }\n}\nclass TransitionAnimationEngine {\n bodyNode;\n driver;\n _normalizer;\n players = [];\n newHostElements = new Map();\n playersByElement = new Map();\n playersByQueriedElement = new Map();\n statesByElement = new Map();\n disabledNodes = new Set();\n totalAnimations = 0;\n totalQueuedPlayers = 0;\n _namespaceLookup = {};\n _namespaceList = [];\n _flushFns = [];\n _whenQuietFns = [];\n namespacesByHostElement = new Map();\n collectedEnterElements = [];\n collectedLeaveElements = [];\n // this method is designed to be overridden by the code that uses this engine\n onRemovalComplete = (element, context) => { };\n /** @internal */\n _onRemovalComplete(element, context) {\n this.onRemovalComplete(element, context);\n }\n constructor(bodyNode, driver, _normalizer) {\n this.bodyNode = bodyNode;\n this.driver = driver;\n this._normalizer = _normalizer;\n }\n get queuedPlayers() {\n const players = [];\n this._namespaceList.forEach((ns) => {\n ns.players.forEach((player) => {\n if (player.queued) {\n players.push(player);\n }\n });\n });\n return players;\n }\n createNamespace(namespaceId, hostElement) {\n const ns = new AnimationTransitionNamespace(namespaceId, hostElement, this);\n if (this.bodyNode && this.driver.containsElement(this.bodyNode, hostElement)) {\n this._balanceNamespaceList(ns, hostElement);\n }\n else {\n // defer this later until flush during when the host element has\n // been inserted so that we know exactly where to place it in\n // the namespace list\n this.newHostElements.set(hostElement, ns);\n // given that this host element is a part of the animation code, it\n // may or may not be inserted by a parent node that is of an\n // animation renderer type. If this happens then we can still have\n // access to this item when we query for :enter nodes. If the parent\n // is a renderer then the set data-structure will normalize the entry\n this.collectEnterElement(hostElement);\n }\n return (this._namespaceLookup[namespaceId] = ns);\n }\n _balanceNamespaceList(ns, hostElement) {\n const namespaceList = this._namespaceList;\n const namespacesByHostElement = this.namespacesByHostElement;\n const limit = namespaceList.length - 1;\n if (limit >= 0) {\n let found = false;\n // Find the closest ancestor with an existing namespace so we can then insert `ns` after it,\n // establishing a top-down ordering of namespaces in `this._namespaceList`.\n let ancestor = this.driver.getParentElement(hostElement);\n while (ancestor) {\n const ancestorNs = namespacesByHostElement.get(ancestor);\n if (ancestorNs) {\n // An animation namespace has been registered for this ancestor, so we insert `ns`\n // right after it to establish top-down ordering of animation namespaces.\n const index = namespaceList.indexOf(ancestorNs);\n namespaceList.splice(index + 1, 0, ns);\n found = true;\n break;\n }\n ancestor = this.driver.getParentElement(ancestor);\n }\n if (!found) {\n // No namespace exists that is an ancestor of `ns`, so `ns` is inserted at the front to\n // ensure that any existing descendants are ordered after `ns`, retaining the desired\n // top-down ordering.\n namespaceList.unshift(ns);\n }\n }\n else {\n namespaceList.push(ns);\n }\n namespacesByHostElement.set(hostElement, ns);\n return ns;\n }\n register(namespaceId, hostElement) {\n let ns = this._namespaceLookup[namespaceId];\n if (!ns) {\n ns = this.createNamespace(namespaceId, hostElement);\n }\n return ns;\n }\n registerTrigger(namespaceId, name, trigger) {\n let ns = this._namespaceLookup[namespaceId];\n if (ns && ns.register(name, trigger)) {\n this.totalAnimations++;\n }\n }\n destroy(namespaceId, context) {\n if (!namespaceId)\n return;\n this.afterFlush(() => { });\n this.afterFlushAnimationsDone(() => {\n const ns = this._fetchNamespace(namespaceId);\n this.namespacesByHostElement.delete(ns.hostElement);\n const index = this._namespaceList.indexOf(ns);\n if (index >= 0) {\n this._namespaceList.splice(index, 1);\n }\n ns.destroy(context);\n delete this._namespaceLookup[namespaceId];\n });\n }\n _fetchNamespace(id) {\n return this._namespaceLookup[id];\n }\n fetchNamespacesByElement(element) {\n // normally there should only be one namespace per element, however\n // if @triggers are placed on both the component element and then\n // its host element (within the component code) then there will be\n // two namespaces returned. We use a set here to simply deduplicate\n // the namespaces in case (for the reason described above) there are multiple triggers\n const namespaces = new Set();\n const elementStates = this.statesByElement.get(element);\n if (elementStates) {\n for (let stateValue of elementStates.values()) {\n if (stateValue.namespaceId) {\n const ns = this._fetchNamespace(stateValue.namespaceId);\n if (ns) {\n namespaces.add(ns);\n }\n }\n }\n }\n return namespaces;\n }\n trigger(namespaceId, element, name, value) {\n if (isElementNode(element)) {\n const ns = this._fetchNamespace(namespaceId);\n if (ns) {\n ns.trigger(element, name, value);\n return true;\n }\n }\n return false;\n }\n insertNode(namespaceId, element, parent, insertBefore) {\n if (!isElementNode(element))\n return;\n // special case for when an element is removed and reinserted (move operation)\n // when this occurs we do not want to use the element for deletion later\n const details = element[REMOVAL_FLAG];\n if (details && details.setForRemoval) {\n details.setForRemoval = false;\n details.setForMove = true;\n const index = this.collectedLeaveElements.indexOf(element);\n if (index >= 0) {\n this.collectedLeaveElements.splice(index, 1);\n }\n }\n // in the event that the namespaceId is blank then the caller\n // code does not contain any animation code in it, but it is\n // just being called so that the node is marked as being inserted\n if (namespaceId) {\n const ns = this._fetchNamespace(namespaceId);\n // This if-statement is a workaround for router issue #21947.\n // The router sometimes hits a race condition where while a route\n // is being instantiated a new navigation arrives, triggering leave\n // animation of DOM that has not been fully initialized, until this\n // is resolved, we need to handle the scenario when DOM is not in a\n // consistent state during the animation.\n if (ns) {\n ns.insertNode(element, parent);\n }\n }\n // only *directives and host elements are inserted before\n if (insertBefore) {\n this.collectEnterElement(element);\n }\n }\n collectEnterElement(element) {\n this.collectedEnterElements.push(element);\n }\n markElementAsDisabled(element, value) {\n if (value) {\n if (!this.disabledNodes.has(element)) {\n this.disabledNodes.add(element);\n addClass(element, DISABLED_CLASSNAME);\n }\n }\n else if (this.disabledNodes.has(element)) {\n this.disabledNodes.delete(element);\n removeClass(element, DISABLED_CLASSNAME);\n }\n }\n removeNode(namespaceId, element, context) {\n if (isElementNode(element)) {\n const ns = namespaceId ? this._fetchNamespace(namespaceId) : null;\n if (ns) {\n ns.removeNode(element, context);\n }\n else {\n this.markElementAsRemoved(namespaceId, element, false, context);\n }\n const hostNS = this.namespacesByHostElement.get(element);\n if (hostNS && hostNS.id !== namespaceId) {\n hostNS.removeNode(element, context);\n }\n }\n else {\n this._onRemovalComplete(element, context);\n }\n }\n markElementAsRemoved(namespaceId, element, hasAnimation, context, previousTriggersValues) {\n this.collectedLeaveElements.push(element);\n element[REMOVAL_FLAG] = {\n namespaceId,\n setForRemoval: context,\n hasAnimation,\n removedBeforeQueried: false,\n previousTriggersValues,\n };\n }\n listen(namespaceId, element, name, phase, callback) {\n if (isElementNode(element)) {\n return this._fetchNamespace(namespaceId).listen(element, name, phase, callback);\n }\n return () => { };\n }\n _buildInstruction(entry, subTimelines, enterClassName, leaveClassName, skipBuildAst) {\n return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, enterClassName, leaveClassName, entry.fromState.options, entry.toState.options, subTimelines, skipBuildAst);\n }\n destroyInnerAnimations(containerElement) {\n let elements = this.driver.query(containerElement, NG_TRIGGER_SELECTOR, true);\n elements.forEach((element) => this.destroyActiveAnimationsForElement(element));\n if (this.playersByQueriedElement.size == 0)\n return;\n elements = this.driver.query(containerElement, NG_ANIMATING_SELECTOR, true);\n elements.forEach((element) => this.finishActiveQueriedAnimationOnElement(element));\n }\n destroyActiveAnimationsForElement(element) {\n const players = this.playersByElement.get(element);\n if (players) {\n players.forEach((player) => {\n // special case for when an element is set for destruction, but hasn't started.\n // in this situation we want to delay the destruction until the flush occurs\n // so that any event listeners attached to the player are triggered.\n if (player.queued) {\n player.markedForDestroy = true;\n }\n else {\n player.destroy();\n }\n });\n }\n }\n finishActiveQueriedAnimationOnElement(element) {\n const players = this.playersByQueriedElement.get(element);\n if (players) {\n players.forEach((player) => player.finish());\n }\n }\n whenRenderingDone() {\n return new Promise((resolve) => {\n if (this.players.length) {\n return optimizeGroupPlayer(this.players).onDone(() => resolve());\n }\n else {\n resolve();\n }\n });\n }\n processLeaveNode(element) {\n const details = element[REMOVAL_FLAG];\n if (details && details.setForRemoval) {\n // this will prevent it from removing it twice\n element[REMOVAL_FLAG] = NULL_REMOVAL_STATE;\n if (details.namespaceId) {\n this.destroyInnerAnimations(element);\n const ns = this._fetchNamespace(details.namespaceId);\n if (ns) {\n ns.clearElementCache(element);\n }\n }\n this._onRemovalComplete(element, details.setForRemoval);\n }\n if (element.classList?.contains(DISABLED_CLASSNAME)) {\n this.markElementAsDisabled(element, false);\n }\n this.driver.query(element, DISABLED_SELECTOR, true).forEach((node) => {\n this.markElementAsDisabled(node, false);\n });\n }\n flush(microtaskId = -1) {\n let players = [];\n if (this.newHostElements.size) {\n this.newHostElements.forEach((ns, element) => this._balanceNamespaceList(ns, element));\n this.newHostElements.clear();\n }\n if (this.totalAnimations && this.collectedEnterElements.length) {\n for (let i = 0; i < this.collectedEnterElements.length; i++) {\n const elm = this.collectedEnterElements[i];\n addClass(elm, STAR_CLASSNAME);\n }\n }\n if (this._namespaceList.length &&\n (this.totalQueuedPlayers || this.collectedLeaveElements.length)) {\n const cleanupFns = [];\n try {\n players = this._flushAnimations(cleanupFns, microtaskId);\n }\n finally {\n for (let i = 0; i < cleanupFns.length; i++) {\n cleanupFns[i]();\n }\n }\n }\n else {\n for (let i = 0; i < this.collectedLeaveElements.length; i++) {\n const element = this.collectedLeaveElements[i];\n this.processLeaveNode(element);\n }\n }\n this.totalQueuedPlayers = 0;\n this.collectedEnterElements.length = 0;\n this.collectedLeaveElements.length = 0;\n this._flushFns.forEach((fn) => fn());\n this._flushFns = [];\n if (this._whenQuietFns.length) {\n // we move these over to a variable so that\n // if any new callbacks are registered in another\n // flush they do not populate the existing set\n const quietFns = this._whenQuietFns;\n this._whenQuietFns = [];\n if (players.length) {\n optimizeGroupPlayer(players).onDone(() => {\n quietFns.forEach((fn) => fn());\n });\n }\n else {\n quietFns.forEach((fn) => fn());\n }\n }\n }\n reportError(errors) {\n throw triggerTransitionsFailed(errors);\n }\n _flushAnimations(cleanupFns, microtaskId) {\n const subTimelines = new ElementInstructionMap();\n const skippedPlayers = [];\n const skippedPlayersMap = new Map();\n const queuedInstructions = [];\n const queriedElements = new Map();\n const allPreStyleElements = new Map();\n const allPostStyleElements = new Map();\n const disabledElementsSet = new Set();\n this.disabledNodes.forEach((node) => {\n disabledElementsSet.add(node);\n const nodesThatAreDisabled = this.driver.query(node, QUEUED_SELECTOR, true);\n for (let i = 0; i < nodesThatAreDisabled.length; i++) {\n disabledElementsSet.add(nodesThatAreDisabled[i]);\n }\n });\n const bodyNode = this.bodyNode;\n const allTriggerElements = Array.from(this.statesByElement.keys());\n const enterNodeMap = buildRootMap(allTriggerElements, this.collectedEnterElements);\n // this must occur before the instructions are built below such that\n // the :enter queries match the elements (since the timeline queries\n // are fired during instruction building).\n const enterNodeMapIds = new Map();\n let i = 0;\n enterNodeMap.forEach((nodes, root) => {\n const className = ENTER_CLASSNAME + i++;\n enterNodeMapIds.set(root, className);\n nodes.forEach((node) => addClass(node, className));\n });\n const allLeaveNodes = [];\n const mergedLeaveNodes = new Set();\n const leaveNodesWithoutAnimations = new Set();\n for (let i = 0; i < this.collectedLeaveElements.length; i++) {\n const element = this.collectedLeaveElements[i];\n const details = element[REMOVAL_FLAG];\n if (details && details.setForRemoval) {\n allLeaveNodes.push(element);\n mergedLeaveNodes.add(element);\n if (details.hasAnimation) {\n this.driver\n .query(element, STAR_SELECTOR, true)\n .forEach((elm) => mergedLeaveNodes.add(elm));\n }\n else {\n leaveNodesWithoutAnimations.add(element);\n }\n }\n }\n const leaveNodeMapIds = new Map();\n const leaveNodeMap = buildRootMap(allTriggerElements, Array.from(mergedLeaveNodes));\n leaveNodeMap.forEach((nodes, root) => {\n const className = LEAVE_CLASSNAME + i++;\n leaveNodeMapIds.set(root, className);\n nodes.forEach((node) => addClass(node, className));\n });\n cleanupFns.push(() => {\n enterNodeMap.forEach((nodes, root) => {\n const className = enterNodeMapIds.get(root);\n nodes.forEach((node) => removeClass(node, className));\n });\n leaveNodeMap.forEach((nodes, root) => {\n const className = leaveNodeMapIds.get(root);\n nodes.forEach((node) => removeClass(node, className));\n });\n allLeaveNodes.forEach((element) => {\n this.processLeaveNode(element);\n });\n });\n const allPlayers = [];\n const erroneousTransitions = [];\n for (let i = this._namespaceList.length - 1; i >= 0; i--) {\n const ns = this._namespaceList[i];\n ns.drainQueuedTransitions(microtaskId).forEach((entry) => {\n const player = entry.player;\n const element = entry.element;\n allPlayers.push(player);\n if (this.collectedEnterElements.length) {\n const details = element[REMOVAL_FLAG];\n // animations for move operations (elements being removed and reinserted,\n // e.g. when the order of an *ngFor list changes) are currently not supported\n if (details && details.setForMove) {\n if (details.previousTriggersValues &&\n details.previousTriggersValues.has(entry.triggerName)) {\n const previousValue = details.previousTriggersValues.get(entry.triggerName);\n // we need to restore the previous trigger value since the element has\n // only been moved and hasn't actually left the DOM\n const triggersWithStates = this.statesByElement.get(entry.element);\n if (triggersWithStates && triggersWithStates.has(entry.triggerName)) {\n const state = triggersWithStates.get(entry.triggerName);\n state.value = previousValue;\n triggersWithStates.set(entry.triggerName, state);\n }\n }\n player.destroy();\n return;\n }\n }\n const nodeIsOrphaned = !bodyNode || !this.driver.containsElement(bodyNode, element);\n const leaveClassName = leaveNodeMapIds.get(element);\n const enterClassName = enterNodeMapIds.get(element);\n const instruction = this._buildInstruction(entry, subTimelines, enterClassName, leaveClassName, nodeIsOrphaned);\n if (instruction.errors && instruction.errors.length) {\n erroneousTransitions.push(instruction);\n return;\n }\n // even though the element may not be in the DOM, it may still\n // be added at a later point (due to the mechanics of content\n // projection and/or dynamic component insertion) therefore it's\n // important to still style the element.\n if (nodeIsOrphaned) {\n player.onStart(() => eraseStyles(element, instruction.fromStyles));\n player.onDestroy(() => setStyles(element, instruction.toStyles));\n skippedPlayers.push(player);\n return;\n }\n // if an unmatched transition is queued and ready to go\n // then it SHOULD NOT render an animation and cancel the\n // previously running animations.\n if (entry.isFallbackTransition) {\n player.onStart(() => eraseStyles(element, instruction.fromStyles));\n player.onDestroy(() => setStyles(element, instruction.toStyles));\n skippedPlayers.push(player);\n return;\n }\n // this means that if a parent animation uses this animation as a sub-trigger\n // then it will instruct the timeline builder not to add a player delay, but\n // instead stretch the first keyframe gap until the animation starts. This is\n // important in order to prevent extra initialization styles from being\n // required by the user for the animation.\n const timelines = [];\n instruction.timelines.forEach((tl) => {\n tl.stretchStartingKeyframe = true;\n if (!this.disabledNodes.has(tl.element)) {\n timelines.push(tl);\n }\n });\n instruction.timelines = timelines;\n subTimelines.append(element, instruction.timelines);\n const tuple = { instruction, player, element };\n queuedInstructions.push(tuple);\n instruction.queriedElements.forEach((element) => getOrSetDefaultValue(queriedElements, element, []).push(player));\n instruction.preStyleProps.forEach((stringMap, element) => {\n if (stringMap.size) {\n let setVal = allPreStyleElements.get(element);\n if (!setVal) {\n allPreStyleElements.set(element, (setVal = new Set()));\n }\n stringMap.forEach((_, prop) => setVal.add(prop));\n }\n });\n instruction.postStyleProps.forEach((stringMap, element) => {\n let setVal = allPostStyleElements.get(element);\n if (!setVal) {\n allPostStyleElements.set(element, (setVal = new Set()));\n }\n stringMap.forEach((_, prop) => setVal.add(prop));\n });\n });\n }\n if (erroneousTransitions.length) {\n const errors = [];\n erroneousTransitions.forEach((instruction) => {\n errors.push(transitionFailed(instruction.triggerName, instruction.errors));\n });\n allPlayers.forEach((player) => player.destroy());\n this.reportError(errors);\n }\n const allPreviousPlayersMap = new Map();\n // this map tells us which element in the DOM tree is contained by\n // which animation. Further down this map will get populated once\n // the players are built and in doing so we can use it to efficiently\n // figure out if a sub player is skipped due to a parent player having priority.\n const animationElementMap = new Map();\n queuedInstructions.forEach((entry) => {\n const element = entry.element;\n if (subTimelines.has(element)) {\n animationElementMap.set(element, element);\n this._beforeAnimationBuild(entry.player.namespaceId, entry.instruction, allPreviousPlayersMap);\n }\n });\n skippedPlayers.forEach((player) => {\n const element = player.element;\n const previousPlayers = this._getPreviousPlayers(element, false, player.namespaceId, player.triggerName, null);\n previousPlayers.forEach((prevPlayer) => {\n getOrSetDefaultValue(allPreviousPlayersMap, element, []).push(prevPlayer);\n prevPlayer.destroy();\n });\n });\n // this is a special case for nodes that will be removed either by\n // having their own leave animations or by being queried in a container\n // that will be removed once a parent animation is complete. The idea\n // here is that * styles must be identical to ! styles because of\n // backwards compatibility (* is also filled in by default in many places).\n // Otherwise * styles will return an empty value or \"auto\" since the element\n // passed to getComputedStyle will not be visible (since * === destination)\n const replaceNodes = allLeaveNodes.filter((node) => {\n return replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements);\n });\n // POST STAGE: fill the * styles\n const postStylesMap = new Map();\n const allLeaveQueriedNodes = cloakAndComputeStyles(postStylesMap, this.driver, leaveNodesWithoutAnimations, allPostStyleElements, AUTO_STYLE);\n allLeaveQueriedNodes.forEach((node) => {\n if (replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements)) {\n replaceNodes.push(node);\n }\n });\n // PRE STAGE: fill the ! styles\n const preStylesMap = new Map();\n enterNodeMap.forEach((nodes, root) => {\n cloakAndComputeStyles(preStylesMap, this.driver, new Set(nodes), allPreStyleElements, ɵPRE_STYLE);\n });\n replaceNodes.forEach((node) => {\n const post = postStylesMap.get(node);\n const pre = preStylesMap.get(node);\n postStylesMap.set(node, new Map([...(post?.entries() ?? []), ...(pre?.entries() ?? [])]));\n });\n const rootPlayers = [];\n const subPlayers = [];\n const NO_PARENT_ANIMATION_ELEMENT_DETECTED = {};\n queuedInstructions.forEach((entry) => {\n const { element, player, instruction } = entry;\n // this means that it was never consumed by a parent animation which\n // means that it is independent and therefore should be set for animation\n if (subTimelines.has(element)) {\n if (disabledElementsSet.has(element)) {\n player.onDestroy(() => setStyles(element, instruction.toStyles));\n player.disabled = true;\n player.overrideTotalTime(instruction.totalTime);\n skippedPlayers.push(player);\n return;\n }\n // this will flow up the DOM and query the map to figure out\n // if a parent animation has priority over it. In the situation\n // that a parent is detected then it will cancel the loop. If\n // nothing is detected, or it takes a few hops to find a parent,\n // then it will fill in the missing nodes and signal them as having\n // a detected parent (or a NO_PARENT value via a special constant).\n let parentWithAnimation = NO_PARENT_ANIMATION_ELEMENT_DETECTED;\n if (animationElementMap.size > 1) {\n let elm = element;\n const parentsToAdd = [];\n while ((elm = elm.parentNode)) {\n const detectedParent = animationElementMap.get(elm);\n if (detectedParent) {\n parentWithAnimation = detectedParent;\n break;\n }\n parentsToAdd.push(elm);\n }\n parentsToAdd.forEach((parent) => animationElementMap.set(parent, parentWithAnimation));\n }\n const innerPlayer = this._buildAnimation(player.namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap);\n player.setRealPlayer(innerPlayer);\n if (parentWithAnimation === NO_PARENT_ANIMATION_ELEMENT_DETECTED) {\n rootPlayers.push(player);\n }\n else {\n const parentPlayers = this.playersByElement.get(parentWithAnimation);\n if (parentPlayers && parentPlayers.length) {\n player.parentPlayer = optimizeGroupPlayer(parentPlayers);\n }\n skippedPlayers.push(player);\n }\n }\n else {\n eraseStyles(element, instruction.fromStyles);\n player.onDestroy(() => setStyles(element, instruction.toStyles));\n // there still might be a ancestor player animating this\n // element therefore we will still add it as a sub player\n // even if its animation may be disabled\n subPlayers.push(player);\n if (disabledElementsSet.has(element)) {\n skippedPlayers.push(player);\n }\n }\n });\n // find all of the sub players' corresponding inner animation players\n subPlayers.forEach((player) => {\n // even if no players are found for a sub animation it\n // will still complete itself after the next tick since it's Noop\n const playersForElement = skippedPlayersMap.get(player.element);\n if (playersForElement && playersForElement.length) {\n const innerPlayer = optimizeGroupPlayer(playersForElement);\n player.setRealPlayer(innerPlayer);\n }\n });\n // the reason why we don't actually play the animation is\n // because all that a skipped player is designed to do is to\n // fire the start/done transition callback events\n skippedPlayers.forEach((player) => {\n if (player.parentPlayer) {\n player.syncPlayerEvents(player.parentPlayer);\n }\n else {\n player.destroy();\n }\n });\n // run through all of the queued removals and see if they\n // were picked up by a query. If not then perform the removal\n // operation right away unless a parent animation is ongoing.\n for (let i = 0; i < allLeaveNodes.length; i++) {\n const element = allLeaveNodes[i];\n const details = element[REMOVAL_FLAG];\n removeClass(element, LEAVE_CLASSNAME);\n // this means the element has a removal animation that is being\n // taken care of and therefore the inner elements will hang around\n // until that animation is over (or the parent queried animation)\n if (details && details.hasAnimation)\n continue;\n let players = [];\n // if this element is queried or if it contains queried children\n // then we want for the element not to be removed from the page\n // until the queried animations have finished\n if (queriedElements.size) {\n let queriedPlayerResults = queriedElements.get(element);\n if (queriedPlayerResults && queriedPlayerResults.length) {\n players.push(...queriedPlayerResults);\n }\n let queriedInnerElements = this.driver.query(element, NG_ANIMATING_SELECTOR, true);\n for (let j = 0; j < queriedInnerElements.length; j++) {\n let queriedPlayers = queriedElements.get(queriedInnerElements[j]);\n if (queriedPlayers && queriedPlayers.length) {\n players.push(...queriedPlayers);\n }\n }\n }\n const activePlayers = players.filter((p) => !p.destroyed);\n if (activePlayers.length) {\n removeNodesAfterAnimationDone(this, element, activePlayers);\n }\n else {\n this.processLeaveNode(element);\n }\n }\n // this is required so the cleanup method doesn't remove them\n allLeaveNodes.length = 0;\n rootPlayers.forEach((player) => {\n this.players.push(player);\n player.onDone(() => {\n player.destroy();\n const index = this.players.indexOf(player);\n this.players.splice(index, 1);\n });\n player.play();\n });\n return rootPlayers;\n }\n afterFlush(callback) {\n this._flushFns.push(callback);\n }\n afterFlushAnimationsDone(callback) {\n this._whenQuietFns.push(callback);\n }\n _getPreviousPlayers(element, isQueriedElement, namespaceId, triggerName, toStateValue) {\n let players = [];\n if (isQueriedElement) {\n const queriedElementPlayers = this.playersByQueriedElement.get(element);\n if (queriedElementPlayers) {\n players = queriedElementPlayers;\n }\n }\n else {\n const elementPlayers = this.playersByElement.get(element);\n if (elementPlayers) {\n const isRemovalAnimation = !toStateValue || toStateValue == VOID_VALUE;\n elementPlayers.forEach((player) => {\n if (player.queued)\n return;\n if (!isRemovalAnimation && player.triggerName != triggerName)\n return;\n players.push(player);\n });\n }\n }\n if (namespaceId || triggerName) {\n players = players.filter((player) => {\n if (namespaceId && namespaceId != player.namespaceId)\n return false;\n if (triggerName && triggerName != player.triggerName)\n return false;\n return true;\n });\n }\n return players;\n }\n _beforeAnimationBuild(namespaceId, instruction, allPreviousPlayersMap) {\n const triggerName = instruction.triggerName;\n const rootElement = instruction.element;\n // when a removal animation occurs, ALL previous players are collected\n // and destroyed (even if they are outside of the current namespace)\n const targetNameSpaceId = instruction.isRemovalTransition\n ? undefined\n : namespaceId;\n const targetTriggerName = instruction.isRemovalTransition\n ? undefined\n : triggerName;\n for (const timelineInstruction of instruction.timelines) {\n const element = timelineInstruction.element;\n const isQueriedElement = element !== rootElement;\n const players = getOrSetDefaultValue(allPreviousPlayersMap, element, []);\n const previousPlayers = this._getPreviousPlayers(element, isQueriedElement, targetNameSpaceId, targetTriggerName, instruction.toState);\n previousPlayers.forEach((player) => {\n const realPlayer = player.getRealPlayer();\n if (realPlayer.beforeDestroy) {\n realPlayer.beforeDestroy();\n }\n player.destroy();\n players.push(player);\n });\n }\n // this needs to be done so that the PRE/POST styles can be\n // computed properly without interfering with the previous animation\n eraseStyles(rootElement, instruction.fromStyles);\n }\n _buildAnimation(namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap) {\n const triggerName = instruction.triggerName;\n const rootElement = instruction.element;\n // we first run this so that the previous animation player\n // data can be passed into the successive animation players\n const allQueriedPlayers = [];\n const allConsumedElements = new Set();\n const allSubElements = new Set();\n const allNewPlayers = instruction.timelines.map((timelineInstruction) => {\n const element = timelineInstruction.element;\n allConsumedElements.add(element);\n // FIXME (matsko): make sure to-be-removed animations are removed properly\n const details = element[REMOVAL_FLAG];\n if (details && details.removedBeforeQueried)\n return new NoopAnimationPlayer(timelineInstruction.duration, timelineInstruction.delay);\n const isQueriedElement = element !== rootElement;\n const previousPlayers = flattenGroupPlayers((allPreviousPlayersMap.get(element) || EMPTY_PLAYER_ARRAY).map((p) => p.getRealPlayer())).filter((p) => {\n // the `element` is not apart of the AnimationPlayer definition, but\n // Mock/WebAnimations\n // use the element within their implementation. This will be added in Angular5 to\n // AnimationPlayer\n const pp = p;\n return pp.element ? pp.element === element : false;\n });\n const preStyles = preStylesMap.get(element);\n const postStyles = postStylesMap.get(element);\n const keyframes = normalizeKeyframes$1(this._normalizer, timelineInstruction.keyframes, preStyles, postStyles);\n const player = this._buildPlayer(timelineInstruction, keyframes, previousPlayers);\n // this means that this particular player belongs to a sub trigger. It is\n // important that we match this player up with the corresponding (@trigger.listener)\n if (timelineInstruction.subTimeline && skippedPlayersMap) {\n allSubElements.add(element);\n }\n if (isQueriedElement) {\n const wrappedPlayer = new TransitionAnimationPlayer(namespaceId, triggerName, element);\n wrappedPlayer.setRealPlayer(player);\n allQueriedPlayers.push(wrappedPlayer);\n }\n return player;\n });\n allQueriedPlayers.forEach((player) => {\n getOrSetDefaultValue(this.playersByQueriedElement, player.element, []).push(player);\n player.onDone(() => deleteOrUnsetInMap(this.playersByQueriedElement, player.element, player));\n });\n allConsumedElements.forEach((element) => addClass(element, NG_ANIMATING_CLASSNAME));\n const player = optimizeGroupPlayer(allNewPlayers);\n player.onDestroy(() => {\n allConsumedElements.forEach((element) => removeClass(element, NG_ANIMATING_CLASSNAME));\n setStyles(rootElement, instruction.toStyles);\n });\n // this basically makes all of the callbacks for sub element animations\n // be dependent on the upper players for when they finish\n allSubElements.forEach((element) => {\n getOrSetDefaultValue(skippedPlayersMap, element, []).push(player);\n });\n return player;\n }\n _buildPlayer(instruction, keyframes, previousPlayers) {\n if (keyframes.length > 0) {\n return this.driver.animate(instruction.element, keyframes, instruction.duration, instruction.delay, instruction.easing, previousPlayers);\n }\n // special case for when an empty transition|definition is provided\n // ... there is no point in rendering an empty animation\n return new NoopAnimationPlayer(instruction.duration, instruction.delay);\n }\n}\nclass TransitionAnimationPlayer {\n namespaceId;\n triggerName;\n element;\n _player = new NoopAnimationPlayer();\n _containsRealPlayer = false;\n _queuedCallbacks = new Map();\n destroyed = false;\n parentPlayer = null;\n markedForDestroy = false;\n disabled = false;\n queued = true;\n totalTime = 0;\n constructor(namespaceId, triggerName, element) {\n this.namespaceId = namespaceId;\n this.triggerName = triggerName;\n this.element = element;\n }\n setRealPlayer(player) {\n if (this._containsRealPlayer)\n return;\n this._player = player;\n this._queuedCallbacks.forEach((callbacks, phase) => {\n callbacks.forEach((callback) => listenOnPlayer(player, phase, undefined, callback));\n });\n this._queuedCallbacks.clear();\n this._containsRealPlayer = true;\n this.overrideTotalTime(player.totalTime);\n this.queued = false;\n }\n getRealPlayer() {\n return this._player;\n }\n overrideTotalTime(totalTime) {\n this.totalTime = totalTime;\n }\n syncPlayerEvents(player) {\n const p = this._player;\n if (p.triggerCallback) {\n player.onStart(() => p.triggerCallback('start'));\n }\n player.onDone(() => this.finish());\n player.onDestroy(() => this.destroy());\n }\n _queueEvent(name, callback) {\n getOrSetDefaultValue(this._queuedCallbacks, name, []).push(callback);\n }\n onDone(fn) {\n if (this.queued) {\n this._queueEvent('done', fn);\n }\n this._player.onDone(fn);\n }\n onStart(fn) {\n if (this.queued) {\n this._queueEvent('start', fn);\n }\n this._player.onStart(fn);\n }\n onDestroy(fn) {\n if (this.queued) {\n this._queueEvent('destroy', fn);\n }\n this._player.onDestroy(fn);\n }\n init() {\n this._player.init();\n }\n hasStarted() {\n return this.queued ? false : this._player.hasStarted();\n }\n play() {\n !this.queued && this._player.play();\n }\n pause() {\n !this.queued && this._player.pause();\n }\n restart() {\n !this.queued && this._player.restart();\n }\n finish() {\n this._player.finish();\n }\n destroy() {\n this.destroyed = true;\n this._player.destroy();\n }\n reset() {\n !this.queued && this._player.reset();\n }\n setPosition(p) {\n if (!this.queued) {\n this._player.setPosition(p);\n }\n }\n getPosition() {\n return this.queued ? 0 : this._player.getPosition();\n }\n /** @internal */\n triggerCallback(phaseName) {\n const p = this._player;\n if (p.triggerCallback) {\n p.triggerCallback(phaseName);\n }\n }\n}\nfunction deleteOrUnsetInMap(map, key, value) {\n let currentValues = map.get(key);\n if (currentValues) {\n if (currentValues.length) {\n const index = currentValues.indexOf(value);\n currentValues.splice(index, 1);\n }\n if (currentValues.length == 0) {\n map.delete(key);\n }\n }\n return currentValues;\n}\nfunction normalizeTriggerValue(value) {\n // we use `!= null` here because it's the most simple\n // way to test against a \"falsy\" value without mixing\n // in empty strings or a zero value. DO NOT OPTIMIZE.\n return value != null ? value : null;\n}\nfunction isElementNode(node) {\n return node && node['nodeType'] === 1;\n}\nfunction isTriggerEventValid(eventName) {\n return eventName == 'start' || eventName == 'done';\n}\nfunction cloakElement(element, value) {\n const oldValue = element.style.display;\n element.style.display = value != null ? value : 'none';\n return oldValue;\n}\nfunction cloakAndComputeStyles(valuesMap, driver, elements, elementPropsMap, defaultStyle) {\n const cloakVals = [];\n elements.forEach((element) => cloakVals.push(cloakElement(element)));\n const failedElements = [];\n elementPropsMap.forEach((props, element) => {\n const styles = new Map();\n props.forEach((prop) => {\n const value = driver.computeStyle(element, prop, defaultStyle);\n styles.set(prop, value);\n // there is no easy way to detect this because a sub element could be removed\n // by a parent animation element being detached.\n if (!value || value.length == 0) {\n element[REMOVAL_FLAG] = NULL_REMOVED_QUERIED_STATE;\n failedElements.push(element);\n }\n });\n valuesMap.set(element, styles);\n });\n // we use a index variable here since Set.forEach(a, i) does not return\n // an index value for the closure (but instead just the value)\n let i = 0;\n elements.forEach((element) => cloakElement(element, cloakVals[i++]));\n return failedElements;\n}\n/*\nSince the Angular renderer code will return a collection of inserted\nnodes in all areas of a DOM tree, it's up to this algorithm to figure\nout which nodes are roots for each animation @trigger.\n\nBy placing each inserted node into a Set and traversing upwards, it\nis possible to find the @trigger elements and well any direct *star\ninsertion nodes, if a @trigger root is found then the enter element\nis placed into the Map[@trigger] spot.\n */\nfunction buildRootMap(roots, nodes) {\n const rootMap = new Map();\n roots.forEach((root) => rootMap.set(root, []));\n if (nodes.length == 0)\n return rootMap;\n const NULL_NODE = 1;\n const nodeSet = new Set(nodes);\n const localRootMap = new Map();\n function getRoot(node) {\n if (!node)\n return NULL_NODE;\n let root = localRootMap.get(node);\n if (root)\n return root;\n const parent = node.parentNode;\n if (rootMap.has(parent)) {\n // ngIf inside @trigger\n root = parent;\n }\n else if (nodeSet.has(parent)) {\n // ngIf inside ngIf\n root = NULL_NODE;\n }\n else {\n // recurse upwards\n root = getRoot(parent);\n }\n localRootMap.set(node, root);\n return root;\n }\n nodes.forEach((node) => {\n const root = getRoot(node);\n if (root !== NULL_NODE) {\n rootMap.get(root).push(node);\n }\n });\n return rootMap;\n}\nfunction addClass(element, className) {\n element.classList?.add(className);\n}\nfunction removeClass(element, className) {\n element.classList?.remove(className);\n}\nfunction removeNodesAfterAnimationDone(engine, element, players) {\n optimizeGroupPlayer(players).onDone(() => engine.processLeaveNode(element));\n}\nfunction flattenGroupPlayers(players) {\n const finalPlayers = [];\n _flattenGroupPlayersRecur(players, finalPlayers);\n return finalPlayers;\n}\nfunction _flattenGroupPlayersRecur(players, finalPlayers) {\n for (let i = 0; i < players.length; i++) {\n const player = players[i];\n if (player instanceof ɵAnimationGroupPlayer) {\n _flattenGroupPlayersRecur(player.players, finalPlayers);\n }\n else {\n finalPlayers.push(player);\n }\n }\n}\nfunction objEquals(a, b) {\n const k1 = Object.keys(a);\n const k2 = Object.keys(b);\n if (k1.length != k2.length)\n return false;\n for (let i = 0; i < k1.length; i++) {\n const prop = k1[i];\n if (!b.hasOwnProperty(prop) || a[prop] !== b[prop])\n return false;\n }\n return true;\n}\nfunction replacePostStylesAsPre(element, allPreStyleElements, allPostStyleElements) {\n const postEntry = allPostStyleElements.get(element);\n if (!postEntry)\n return false;\n let preEntry = allPreStyleElements.get(element);\n if (preEntry) {\n postEntry.forEach((data) => preEntry.add(data));\n }\n else {\n allPreStyleElements.set(element, postEntry);\n }\n allPostStyleElements.delete(element);\n return true;\n}\n\nclass AnimationEngine {\n _driver;\n _normalizer;\n _transitionEngine;\n _timelineEngine;\n _triggerCache = {};\n // this method is designed to be overridden by the code that uses this engine\n onRemovalComplete = (element, context) => { };\n constructor(doc, _driver, _normalizer) {\n this._driver = _driver;\n this._normalizer = _normalizer;\n this._transitionEngine = new TransitionAnimationEngine(doc.body, _driver, _normalizer);\n this._timelineEngine = new TimelineAnimationEngine(doc.body, _driver, _normalizer);\n this._transitionEngine.onRemovalComplete = (element, context) => this.onRemovalComplete(element, context);\n }\n registerTrigger(componentId, namespaceId, hostElement, name, metadata) {\n const cacheKey = componentId + '-' + name;\n let trigger = this._triggerCache[cacheKey];\n if (!trigger) {\n const errors = [];\n const warnings = [];\n const ast = buildAnimationAst(this._driver, metadata, errors, warnings);\n if (errors.length) {\n throw triggerBuildFailed(name, errors);\n }\n if (warnings.length) {\n warnTriggerBuild(name, warnings);\n }\n trigger = buildTrigger(name, ast, this._normalizer);\n this._triggerCache[cacheKey] = trigger;\n }\n this._transitionEngine.registerTrigger(namespaceId, name, trigger);\n }\n register(namespaceId, hostElement) {\n this._transitionEngine.register(namespaceId, hostElement);\n }\n destroy(namespaceId, context) {\n this._transitionEngine.destroy(namespaceId, context);\n }\n onInsert(namespaceId, element, parent, insertBefore) {\n this._transitionEngine.insertNode(namespaceId, element, parent, insertBefore);\n }\n onRemove(namespaceId, element, context) {\n this._transitionEngine.removeNode(namespaceId, element, context);\n }\n disableAnimations(element, disable) {\n this._transitionEngine.markElementAsDisabled(element, disable);\n }\n process(namespaceId, element, property, value) {\n if (property.charAt(0) == '@') {\n const [id, action] = parseTimelineCommand(property);\n const args = value;\n this._timelineEngine.command(id, element, action, args);\n }\n else {\n this._transitionEngine.trigger(namespaceId, element, property, value);\n }\n }\n listen(namespaceId, element, eventName, eventPhase, callback) {\n // @@listen\n if (eventName.charAt(0) == '@') {\n const [id, action] = parseTimelineCommand(eventName);\n return this._timelineEngine.listen(id, element, action, callback);\n }\n return this._transitionEngine.listen(namespaceId, element, eventName, eventPhase, callback);\n }\n flush(microtaskId = -1) {\n this._transitionEngine.flush(microtaskId);\n }\n get players() {\n return [...this._transitionEngine.players, ...this._timelineEngine.players];\n }\n whenRenderingDone() {\n return this._transitionEngine.whenRenderingDone();\n }\n afterFlushAnimationsDone(cb) {\n this._transitionEngine.afterFlushAnimationsDone(cb);\n }\n}\n\n/**\n * Returns an instance of `SpecialCasedStyles` if and when any special (non animateable) styles are\n * detected.\n *\n * In CSS there exist properties that cannot be animated within a keyframe animation\n * (whether it be via CSS keyframes or web-animations) and the animation implementation\n * will ignore them. This function is designed to detect those special cased styles and\n * return a container that will be executed at the start and end of the animation.\n *\n * @returns an instance of `SpecialCasedStyles` if any special styles are detected otherwise `null`\n */\nfunction packageNonAnimatableStyles(element, styles) {\n let startStyles = null;\n let endStyles = null;\n if (Array.isArray(styles) && styles.length) {\n startStyles = filterNonAnimatableStyles(styles[0]);\n if (styles.length > 1) {\n endStyles = filterNonAnimatableStyles(styles[styles.length - 1]);\n }\n }\n else if (styles instanceof Map) {\n startStyles = filterNonAnimatableStyles(styles);\n }\n return startStyles || endStyles ? new SpecialCasedStyles(element, startStyles, endStyles) : null;\n}\n/**\n * Designed to be executed during a keyframe-based animation to apply any special-cased styles.\n *\n * When started (when the `start()` method is run) then the provided `startStyles`\n * will be applied. When finished (when the `finish()` method is called) the\n * `endStyles` will be applied as well any any starting styles. Finally when\n * `destroy()` is called then all styles will be removed.\n */\nclass SpecialCasedStyles {\n _element;\n _startStyles;\n _endStyles;\n static initialStylesByElement = /* @__PURE__ */ new WeakMap();\n _state = 0 /* SpecialCasedStylesState.Pending */;\n _initialStyles;\n constructor(_element, _startStyles, _endStyles) {\n this._element = _element;\n this._startStyles = _startStyles;\n this._endStyles = _endStyles;\n let initialStyles = SpecialCasedStyles.initialStylesByElement.get(_element);\n if (!initialStyles) {\n SpecialCasedStyles.initialStylesByElement.set(_element, (initialStyles = new Map()));\n }\n this._initialStyles = initialStyles;\n }\n start() {\n if (this._state < 1 /* SpecialCasedStylesState.Started */) {\n if (this._startStyles) {\n setStyles(this._element, this._startStyles, this._initialStyles);\n }\n this._state = 1 /* SpecialCasedStylesState.Started */;\n }\n }\n finish() {\n this.start();\n if (this._state < 2 /* SpecialCasedStylesState.Finished */) {\n setStyles(this._element, this._initialStyles);\n if (this._endStyles) {\n setStyles(this._element, this._endStyles);\n this._endStyles = null;\n }\n this._state = 1 /* SpecialCasedStylesState.Started */;\n }\n }\n destroy() {\n this.finish();\n if (this._state < 3 /* SpecialCasedStylesState.Destroyed */) {\n SpecialCasedStyles.initialStylesByElement.delete(this._element);\n if (this._startStyles) {\n eraseStyles(this._element, this._startStyles);\n this._endStyles = null;\n }\n if (this._endStyles) {\n eraseStyles(this._element, this._endStyles);\n this._endStyles = null;\n }\n setStyles(this._element, this._initialStyles);\n this._state = 3 /* SpecialCasedStylesState.Destroyed */;\n }\n }\n}\nfunction filterNonAnimatableStyles(styles) {\n let result = null;\n styles.forEach((val, prop) => {\n if (isNonAnimatableStyle(prop)) {\n result = result || new Map();\n result.set(prop, val);\n }\n });\n return result;\n}\nfunction isNonAnimatableStyle(prop) {\n return prop === 'display' || prop === 'position';\n}\n\nclass WebAnimationsPlayer {\n element;\n keyframes;\n options;\n _specialStyles;\n _onDoneFns = [];\n _onStartFns = [];\n _onDestroyFns = [];\n _duration;\n _delay;\n _initialized = false;\n _finished = false;\n _started = false;\n _destroyed = false;\n _finalKeyframe;\n // the following original fns are persistent copies of the _onStartFns and _onDoneFns\n // and are used to reset the fns to their original values upon reset()\n // (since the _onStartFns and _onDoneFns get deleted after they are called)\n _originalOnDoneFns = [];\n _originalOnStartFns = [];\n // using non-null assertion because it's re(set) by init();\n domPlayer;\n time = 0;\n parentPlayer = null;\n currentSnapshot = new Map();\n constructor(element, keyframes, options, _specialStyles) {\n this.element = element;\n this.keyframes = keyframes;\n this.options = options;\n this._specialStyles = _specialStyles;\n this._duration = options['duration'];\n this._delay = options['delay'] || 0;\n this.time = this._duration + this._delay;\n }\n _onFinish() {\n if (!this._finished) {\n this._finished = true;\n this._onDoneFns.forEach((fn) => fn());\n this._onDoneFns = [];\n }\n }\n init() {\n this._buildPlayer();\n this._preparePlayerBeforeStart();\n }\n _buildPlayer() {\n if (this._initialized)\n return;\n this._initialized = true;\n const keyframes = this.keyframes;\n // @ts-expect-error overwriting a readonly property\n this.domPlayer = this._triggerWebAnimation(this.element, keyframes, this.options);\n this._finalKeyframe = keyframes.length ? keyframes[keyframes.length - 1] : new Map();\n const onFinish = () => this._onFinish();\n this.domPlayer.addEventListener('finish', onFinish);\n this.onDestroy(() => {\n // We must remove the `finish` event listener once an animation has completed all its\n // iterations. This action is necessary to prevent a memory leak since the listener captures\n // `this`, creating a closure that prevents `this` from being garbage collected.\n this.domPlayer.removeEventListener('finish', onFinish);\n });\n }\n _preparePlayerBeforeStart() {\n // this is required so that the player doesn't start to animate right away\n if (this._delay) {\n this._resetDomPlayerState();\n }\n else {\n this.domPlayer.pause();\n }\n }\n _convertKeyframesToObject(keyframes) {\n const kfs = [];\n keyframes.forEach((frame) => {\n kfs.push(Object.fromEntries(frame));\n });\n return kfs;\n }\n /** @internal */\n _triggerWebAnimation(element, keyframes, options) {\n return element.animate(this._convertKeyframesToObject(keyframes), options);\n }\n onStart(fn) {\n this._originalOnStartFns.push(fn);\n this._onStartFns.push(fn);\n }\n onDone(fn) {\n this._originalOnDoneFns.push(fn);\n this._onDoneFns.push(fn);\n }\n onDestroy(fn) {\n this._onDestroyFns.push(fn);\n }\n play() {\n this._buildPlayer();\n if (!this.hasStarted()) {\n this._onStartFns.forEach((fn) => fn());\n this._onStartFns = [];\n this._started = true;\n if (this._specialStyles) {\n this._specialStyles.start();\n }\n }\n this.domPlayer.play();\n }\n pause() {\n this.init();\n this.domPlayer.pause();\n }\n finish() {\n this.init();\n if (this._specialStyles) {\n this._specialStyles.finish();\n }\n this._onFinish();\n this.domPlayer.finish();\n }\n reset() {\n this._resetDomPlayerState();\n this._destroyed = false;\n this._finished = false;\n this._started = false;\n this._onStartFns = this._originalOnStartFns;\n this._onDoneFns = this._originalOnDoneFns;\n }\n _resetDomPlayerState() {\n if (this.domPlayer) {\n this.domPlayer.cancel();\n }\n }\n restart() {\n this.reset();\n this.play();\n }\n hasStarted() {\n return this._started;\n }\n destroy() {\n if (!this._destroyed) {\n this._destroyed = true;\n this._resetDomPlayerState();\n this._onFinish();\n if (this._specialStyles) {\n this._specialStyles.destroy();\n }\n this._onDestroyFns.forEach((fn) => fn());\n this._onDestroyFns = [];\n }\n }\n setPosition(p) {\n if (this.domPlayer === undefined) {\n this.init();\n }\n this.domPlayer.currentTime = p * this.time;\n }\n getPosition() {\n // tsc is complaining with TS2362 without the conversion to number\n return +(this.domPlayer.currentTime ?? 0) / this.time;\n }\n get totalTime() {\n return this._delay + this._duration;\n }\n beforeDestroy() {\n const styles = new Map();\n if (this.hasStarted()) {\n // note: this code is invoked only when the `play` function was called prior to this\n // (thus `hasStarted` returns true), this implies that the code that initializes\n // `_finalKeyframe` has also been executed and the non-null assertion can be safely used here\n const finalKeyframe = this._finalKeyframe;\n finalKeyframe.forEach((val, prop) => {\n if (prop !== 'offset') {\n styles.set(prop, this._finished ? val : computeStyle(this.element, prop));\n }\n });\n }\n this.currentSnapshot = styles;\n }\n /** @internal */\n triggerCallback(phaseName) {\n const methods = phaseName === 'start' ? this._onStartFns : this._onDoneFns;\n methods.forEach((fn) => fn());\n methods.length = 0;\n }\n}\n\nclass WebAnimationsDriver {\n validateStyleProperty(prop) {\n // Perform actual validation in dev mode only, in prod mode this check is a noop.\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n return validateStyleProperty(prop);\n }\n return true;\n }\n validateAnimatableStyleProperty(prop) {\n // Perform actual validation in dev mode only, in prod mode this check is a noop.\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const cssProp = camelCaseToDashCase(prop);\n return validateWebAnimatableStyleProperty(cssProp);\n }\n return true;\n }\n containsElement(elm1, elm2) {\n return containsElement(elm1, elm2);\n }\n getParentElement(element) {\n return getParentElement(element);\n }\n query(element, selector, multi) {\n return invokeQuery(element, selector, multi);\n }\n computeStyle(element, prop, defaultValue) {\n return computeStyle(element, prop);\n }\n animate(element, keyframes, duration, delay, easing, previousPlayers = []) {\n const fill = delay == 0 ? 'both' : 'forwards';\n const playerOptions = { duration, delay, fill };\n // we check for this to avoid having a null|undefined value be present\n // for the easing (which results in an error for certain browsers #9752)\n if (easing) {\n playerOptions['easing'] = easing;\n }\n const previousStyles = new Map();\n const previousWebAnimationPlayers = (previousPlayers.filter((player) => player instanceof WebAnimationsPlayer));\n if (allowPreviousPlayerStylesMerge(duration, delay)) {\n previousWebAnimationPlayers.forEach((player) => {\n player.currentSnapshot.forEach((val, prop) => previousStyles.set(prop, val));\n });\n }\n let _keyframes = normalizeKeyframes(keyframes).map((styles) => new Map(styles));\n _keyframes = balancePreviousStylesIntoKeyframes(element, _keyframes, previousStyles);\n const specialStyles = packageNonAnimatableStyles(element, _keyframes);\n return new WebAnimationsPlayer(element, _keyframes, playerOptions, specialStyles);\n }\n}\n\nfunction createEngine(type, doc) {\n // TODO: find a way to make this tree shakable.\n if (type === 'noop') {\n return new AnimationEngine(doc, new NoopAnimationDriver(), new NoopAnimationStyleNormalizer());\n }\n return new AnimationEngine(doc, new WebAnimationsDriver(), new WebAnimationsStyleNormalizer());\n}\n\nclass Animation {\n _driver;\n _animationAst;\n constructor(_driver, input) {\n this._driver = _driver;\n const errors = [];\n const warnings = [];\n const ast = buildAnimationAst(_driver, input, errors, warnings);\n if (errors.length) {\n throw validationFailed(errors);\n }\n if (warnings.length) {\n warnValidation(warnings);\n }\n this._animationAst = ast;\n }\n buildTimelines(element, startingStyles, destinationStyles, options, subInstructions) {\n const start = Array.isArray(startingStyles)\n ? normalizeStyles(startingStyles)\n : startingStyles;\n const dest = Array.isArray(destinationStyles)\n ? normalizeStyles(destinationStyles)\n : destinationStyles;\n const errors = [];\n subInstructions = subInstructions || new ElementInstructionMap();\n const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);\n if (errors.length) {\n throw buildingFailed(errors);\n }\n return result;\n }\n}\n\nconst ANIMATION_PREFIX = '@';\nconst DISABLE_ANIMATIONS_FLAG = '@.disabled';\nclass BaseAnimationRenderer {\n namespaceId;\n delegate;\n engine;\n _onDestroy;\n // We need to explicitly type this property because of an api-extractor bug\n // See https://github.com/microsoft/rushstack/issues/4390\n ɵtype = 0 /* AnimationRendererType.Regular */;\n constructor(namespaceId, delegate, engine, _onDestroy) {\n this.namespaceId = namespaceId;\n this.delegate = delegate;\n this.engine = engine;\n this._onDestroy = _onDestroy;\n }\n get data() {\n return this.delegate.data;\n }\n destroyNode(node) {\n this.delegate.destroyNode?.(node);\n }\n destroy() {\n this.engine.destroy(this.namespaceId, this.delegate);\n this.engine.afterFlushAnimationsDone(() => {\n // Call the renderer destroy method after the animations has finished as otherwise\n // styles will be removed too early which will cause an unstyled animation.\n queueMicrotask(() => {\n this.delegate.destroy();\n });\n });\n this._onDestroy?.();\n }\n createElement(name, namespace) {\n return this.delegate.createElement(name, namespace);\n }\n createComment(value) {\n return this.delegate.createComment(value);\n }\n createText(value) {\n return this.delegate.createText(value);\n }\n appendChild(parent, newChild) {\n this.delegate.appendChild(parent, newChild);\n this.engine.onInsert(this.namespaceId, newChild, parent, false);\n }\n insertBefore(parent, newChild, refChild, isMove = true) {\n this.delegate.insertBefore(parent, newChild, refChild);\n // If `isMove` true than we should animate this insert.\n this.engine.onInsert(this.namespaceId, newChild, parent, isMove);\n }\n removeChild(parent, oldChild, isHostElement) {\n // Prior to the changes in #57203, this method wasn't being called at all by `core` if the child\n // doesn't have a parent. There appears to be some animation-specific downstream logic that\n // depends on the null check happening before the animation engine. This check keeps the old\n // behavior while allowing `core` to not have to check for the parent element anymore.\n if (this.parentNode(oldChild)) {\n this.engine.onRemove(this.namespaceId, oldChild, this.delegate);\n }\n }\n selectRootElement(selectorOrNode, preserveContent) {\n return this.delegate.selectRootElement(selectorOrNode, preserveContent);\n }\n parentNode(node) {\n return this.delegate.parentNode(node);\n }\n nextSibling(node) {\n return this.delegate.nextSibling(node);\n }\n setAttribute(el, name, value, namespace) {\n this.delegate.setAttribute(el, name, value, namespace);\n }\n removeAttribute(el, name, namespace) {\n this.delegate.removeAttribute(el, name, namespace);\n }\n addClass(el, name) {\n this.delegate.addClass(el, name);\n }\n removeClass(el, name) {\n this.delegate.removeClass(el, name);\n }\n setStyle(el, style, value, flags) {\n this.delegate.setStyle(el, style, value, flags);\n }\n removeStyle(el, style, flags) {\n this.delegate.removeStyle(el, style, flags);\n }\n setProperty(el, name, value) {\n if (name.charAt(0) == ANIMATION_PREFIX && name == DISABLE_ANIMATIONS_FLAG) {\n this.disableAnimations(el, !!value);\n }\n else {\n this.delegate.setProperty(el, name, value);\n }\n }\n setValue(node, value) {\n this.delegate.setValue(node, value);\n }\n listen(target, eventName, callback) {\n return this.delegate.listen(target, eventName, callback);\n }\n disableAnimations(element, value) {\n this.engine.disableAnimations(element, value);\n }\n}\nclass AnimationRenderer extends BaseAnimationRenderer {\n factory;\n constructor(factory, namespaceId, delegate, engine, onDestroy) {\n super(namespaceId, delegate, engine, onDestroy);\n this.factory = factory;\n this.namespaceId = namespaceId;\n }\n setProperty(el, name, value) {\n if (name.charAt(0) == ANIMATION_PREFIX) {\n if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) {\n value = value === undefined ? true : !!value;\n this.disableAnimations(el, value);\n }\n else {\n this.engine.process(this.namespaceId, el, name.slice(1), value);\n }\n }\n else {\n this.delegate.setProperty(el, name, value);\n }\n }\n listen(target, eventName, callback) {\n if (eventName.charAt(0) == ANIMATION_PREFIX) {\n const element = resolveElementFromTarget(target);\n let name = eventName.slice(1);\n let phase = '';\n // @listener.phase is for trigger animation callbacks\n // @@listener is for animation builder callbacks\n if (name.charAt(0) != ANIMATION_PREFIX) {\n [name, phase] = parseTriggerCallbackName(name);\n }\n return this.engine.listen(this.namespaceId, element, name, phase, (event) => {\n const countId = event['_data'] || -1;\n this.factory.scheduleListenerCallback(countId, callback, event);\n });\n }\n return this.delegate.listen(target, eventName, callback);\n }\n}\nfunction resolveElementFromTarget(target) {\n switch (target) {\n case 'body':\n return document.body;\n case 'document':\n return document;\n case 'window':\n return window;\n default:\n return target;\n }\n}\nfunction parseTriggerCallbackName(triggerName) {\n const dotIndex = triggerName.indexOf('.');\n const trigger = triggerName.substring(0, dotIndex);\n const phase = triggerName.slice(dotIndex + 1);\n return [trigger, phase];\n}\n\nclass AnimationRendererFactory {\n delegate;\n engine;\n _zone;\n _currentId = 0;\n _microtaskId = 1;\n _animationCallbacksBuffer = [];\n _rendererCache = new Map();\n _cdRecurDepth = 0;\n constructor(delegate, engine, _zone) {\n this.delegate = delegate;\n this.engine = engine;\n this._zone = _zone;\n engine.onRemovalComplete = (element, delegate) => {\n delegate?.removeChild(null, element);\n };\n }\n createRenderer(hostElement, type) {\n const EMPTY_NAMESPACE_ID = '';\n // cache the delegates to find out which cached delegate can\n // be used by which cached renderer\n const delegate = this.delegate.createRenderer(hostElement, type);\n if (!hostElement || !type?.data?.['animation']) {\n const cache = this._rendererCache;\n let renderer = cache.get(delegate);\n if (!renderer) {\n // Ensure that the renderer is removed from the cache on destroy\n // since it may contain references to detached DOM nodes.\n const onRendererDestroy = () => cache.delete(delegate);\n renderer = new BaseAnimationRenderer(EMPTY_NAMESPACE_ID, delegate, this.engine, onRendererDestroy);\n // only cache this result when the base renderer is used\n cache.set(delegate, renderer);\n }\n return renderer;\n }\n const componentId = type.id;\n const namespaceId = type.id + '-' + this._currentId;\n this._currentId++;\n this.engine.register(namespaceId, hostElement);\n const registerTrigger = (trigger) => {\n if (Array.isArray(trigger)) {\n trigger.forEach(registerTrigger);\n }\n else {\n this.engine.registerTrigger(componentId, namespaceId, hostElement, trigger.name, trigger);\n }\n };\n const animationTriggers = type.data['animation'];\n animationTriggers.forEach(registerTrigger);\n return new AnimationRenderer(this, namespaceId, delegate, this.engine);\n }\n begin() {\n this._cdRecurDepth++;\n if (this.delegate.begin) {\n this.delegate.begin();\n }\n }\n _scheduleCountTask() {\n queueMicrotask(() => {\n this._microtaskId++;\n });\n }\n /** @internal */\n scheduleListenerCallback(count, fn, data) {\n if (count >= 0 && count < this._microtaskId) {\n this._zone.run(() => fn(data));\n return;\n }\n const animationCallbacksBuffer = this._animationCallbacksBuffer;\n if (animationCallbacksBuffer.length == 0) {\n queueMicrotask(() => {\n this._zone.run(() => {\n animationCallbacksBuffer.forEach((tuple) => {\n const [fn, data] = tuple;\n fn(data);\n });\n this._animationCallbacksBuffer = [];\n });\n });\n }\n animationCallbacksBuffer.push([fn, data]);\n }\n end() {\n this._cdRecurDepth--;\n // this is to prevent animations from running twice when an inner\n // component does CD when a parent component instead has inserted it\n if (this._cdRecurDepth == 0) {\n this._zone.runOutsideAngular(() => {\n this._scheduleCountTask();\n this.engine.flush(this._microtaskId);\n });\n }\n if (this.delegate.end) {\n this.delegate.end();\n }\n }\n whenRenderingDone() {\n return this.engine.whenRenderingDone();\n }\n /**\n * Used during HMR to clear any cached data about a component.\n * @param componentId ID of the component that is being replaced.\n */\n componentReplaced(componentId) {\n this.delegate.componentReplaced?.(componentId);\n }\n}\n\n/**\n * @module\n * @description\n * Entry point for all animation APIs of the animation browser package.\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\n\n// This file is not used to build this module. It is only used during editing\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { AnimationDriver, NoopAnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, BaseAnimationRenderer as ɵBaseAnimationRenderer, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, camelCaseToDashCase as ɵcamelCaseToDashCase, containsElement as ɵcontainsElement, createEngine as ɵcreateEngine, getParentElement as ɵgetParentElement, invokeQuery as ɵinvokeQuery, normalizeKeyframes as ɵnormalizeKeyframes, validateStyleProperty as ɵvalidateStyleProperty, validateWebAnimatableStyleProperty as ɵvalidateWebAnimatableStyleProperty };\n","/**\n * @license Angular v19.0.6\n * (c) 2010-2024 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport * as i0 from '@angular/core';\nimport { Injectable, Inject, RendererFactory2, NgZone, ANIMATION_MODULE_TYPE, NgModule, ɵperformanceMarkFeature } from '@angular/core';\nexport { ANIMATION_MODULE_TYPE } from '@angular/core';\nimport { ɵDomRendererFactory2, BrowserModule } from '@angular/platform-browser';\nimport * as i1 from '@angular/animations/browser';\nimport { ɵAnimationEngine, ɵWebAnimationsStyleNormalizer, ɵAnimationRendererFactory, ɵAnimationStyleNormalizer, AnimationDriver, ɵWebAnimationsDriver, NoopAnimationDriver } from '@angular/animations/browser';\nimport { DOCUMENT } from '@angular/common';\n\nclass InjectableAnimationEngine extends ɵAnimationEngine {\n // The `ApplicationRef` is injected here explicitly to force the dependency ordering.\n // Since the `ApplicationRef` should be created earlier before the `AnimationEngine`, they\n // both have `ngOnDestroy` hooks and `flush()` must be called after all views are destroyed.\n constructor(doc, driver, normalizer) {\n super(doc, driver, normalizer);\n }\n ngOnDestroy() {\n this.flush();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: InjectableAnimationEngine, deps: [{ token: DOCUMENT }, { token: i1.AnimationDriver }, { token: i1.ɵAnimationStyleNormalizer }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: InjectableAnimationEngine });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: InjectableAnimationEngine, decorators: [{\n type: Injectable\n }], ctorParameters: () => [{ type: Document, decorators: [{\n type: Inject,\n args: [DOCUMENT]\n }] }, { type: i1.AnimationDriver }, { type: i1.ɵAnimationStyleNormalizer }] });\nfunction instantiateDefaultStyleNormalizer() {\n return new ɵWebAnimationsStyleNormalizer();\n}\nfunction instantiateRendererFactory(renderer, engine, zone) {\n return new ɵAnimationRendererFactory(renderer, engine, zone);\n}\nconst SHARED_ANIMATION_PROVIDERS = [\n { provide: ɵAnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer },\n { provide: ɵAnimationEngine, useClass: InjectableAnimationEngine },\n {\n provide: RendererFactory2,\n useFactory: instantiateRendererFactory,\n deps: [ɵDomRendererFactory2, ɵAnimationEngine, NgZone],\n },\n];\n/**\n * Separate providers from the actual module so that we can do a local modification in Google3 to\n * include them in the BrowserModule.\n */\nconst BROWSER_ANIMATIONS_PROVIDERS = [\n { provide: AnimationDriver, useFactory: () => new ɵWebAnimationsDriver() },\n { provide: ANIMATION_MODULE_TYPE, useValue: 'BrowserAnimations' },\n ...SHARED_ANIMATION_PROVIDERS,\n];\n/**\n * Separate providers from the actual module so that we can do a local modification in Google3 to\n * include them in the BrowserTestingModule.\n */\nconst BROWSER_NOOP_ANIMATIONS_PROVIDERS = [\n { provide: AnimationDriver, useClass: NoopAnimationDriver },\n { provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations' },\n ...SHARED_ANIMATION_PROVIDERS,\n];\n\n/**\n * Exports `BrowserModule` with additional dependency-injection providers\n * for use with animations. See [Animations](guide/animations).\n * @publicApi\n */\nclass BrowserAnimationsModule {\n /**\n * Configures the module based on the specified object.\n *\n * @param config Object used to configure the behavior of the `BrowserAnimationsModule`.\n * @see {@link BrowserAnimationsModuleConfig}\n *\n * @usageNotes\n * When registering the `BrowserAnimationsModule`, you can use the `withConfig`\n * function as follows:\n * ```\n * @NgModule({\n * imports: [BrowserAnimationsModule.withConfig(config)]\n * })\n * class MyNgModule {}\n * ```\n */\n static withConfig(config) {\n return {\n ngModule: BrowserAnimationsModule,\n providers: config.disableAnimations\n ? BROWSER_NOOP_ANIMATIONS_PROVIDERS\n : BROWSER_ANIMATIONS_PROVIDERS,\n };\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserAnimationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserAnimationsModule, exports: [BrowserModule] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserAnimationsModule, providers: BROWSER_ANIMATIONS_PROVIDERS, imports: [BrowserModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserAnimationsModule, decorators: [{\n type: NgModule,\n args: [{\n exports: [BrowserModule],\n providers: BROWSER_ANIMATIONS_PROVIDERS,\n }]\n }] });\n/**\n * Returns the set of dependency-injection providers\n * to enable animations in an application. See [animations guide](guide/animations)\n * to learn more about animations in Angular.\n *\n * @usageNotes\n *\n * The function is useful when you want to enable animations in an application\n * bootstrapped using the `bootstrapApplication` function. In this scenario there\n * is no need to import the `BrowserAnimationsModule` NgModule at all, just add\n * providers returned by this function to the `providers` list as show below.\n *\n * ```ts\n * bootstrapApplication(RootComponent, {\n * providers: [\n * provideAnimations()\n * ]\n * });\n * ```\n *\n * @publicApi\n */\nfunction provideAnimations() {\n ɵperformanceMarkFeature('NgEagerAnimations');\n // Return a copy to prevent changes to the original array in case any in-place\n // alterations are performed to the `provideAnimations` call results in app code.\n return [...BROWSER_ANIMATIONS_PROVIDERS];\n}\n/**\n * A null player that must be imported to allow disabling of animations.\n * @publicApi\n */\nclass NoopAnimationsModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NoopAnimationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: NoopAnimationsModule, exports: [BrowserModule] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NoopAnimationsModule, providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS, imports: [BrowserModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NoopAnimationsModule, decorators: [{\n type: NgModule,\n args: [{\n exports: [BrowserModule],\n providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS,\n }]\n }] });\n/**\n * Returns the set of dependency-injection providers\n * to disable animations in an application. See [animations guide](guide/animations)\n * to learn more about animations in Angular.\n *\n * @usageNotes\n *\n * The function is useful when you want to bootstrap an application using\n * the `bootstrapApplication` function, but you need to disable animations\n * (for example, when running tests).\n *\n * ```ts\n * bootstrapApplication(RootComponent, {\n * providers: [\n * provideNoopAnimations()\n * ]\n * });\n * ```\n *\n * @publicApi\n */\nfunction provideNoopAnimations() {\n // Return a copy to prevent changes to the original array in case any in-place\n // alterations are performed to the `provideNoopAnimations` call results in app code.\n return [...BROWSER_NOOP_ANIMATIONS_PROVIDERS];\n}\n\n/**\n * @module\n * @description\n * Entry point for all animation APIs of the animation browser package.\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\n\n// This file is not used to build this module. It is only used during editing\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { BrowserAnimationsModule, NoopAnimationsModule, provideAnimations, provideNoopAnimations, InjectableAnimationEngine as ɵInjectableAnimationEngine };\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// THIS CODE IS GENERATED - DO NOT MODIFY.\n (function(global) {\n global.ng ??= {};\n global.ng.common ??= {};\n global.ng.common.locales ??= {};\n const u = undefined;\n function plural(val) {\nconst n = val, i = Math.floor(Math.abs(val)), v = val.toString().replace(/^[^.]*\\.?/, '').length;\n\nif (i === 1 && v === 0)\n return 1;\nreturn 5;\n}\n global.ng.common.locales['de'] = [\"de\",[[\"AM\",\"PM\"],u,u],u,[[\"S\",\"M\",\"D\",\"M\",\"D\",\"F\",\"S\"],[\"So.\",\"Mo.\",\"Di.\",\"Mi.\",\"Do.\",\"Fr.\",\"Sa.\"],[\"Sonntag\",\"Montag\",\"Dienstag\",\"Mittwoch\",\"Donnerstag\",\"Freitag\",\"Samstag\"],[\"So.\",\"Mo.\",\"Di.\",\"Mi.\",\"Do.\",\"Fr.\",\"Sa.\"]],[[\"S\",\"M\",\"D\",\"M\",\"D\",\"F\",\"S\"],[\"So\",\"Mo\",\"Di\",\"Mi\",\"Do\",\"Fr\",\"Sa\"],[\"Sonntag\",\"Montag\",\"Dienstag\",\"Mittwoch\",\"Donnerstag\",\"Freitag\",\"Samstag\"],[\"So.\",\"Mo.\",\"Di.\",\"Mi.\",\"Do.\",\"Fr.\",\"Sa.\"]],[[\"J\",\"F\",\"M\",\"A\",\"M\",\"J\",\"J\",\"A\",\"S\",\"O\",\"N\",\"D\"],[\"Jan.\",\"Feb.\",\"März\",\"Apr.\",\"Mai\",\"Juni\",\"Juli\",\"Aug.\",\"Sept.\",\"Okt.\",\"Nov.\",\"Dez.\"],[\"Januar\",\"Februar\",\"März\",\"April\",\"Mai\",\"Juni\",\"Juli\",\"August\",\"September\",\"Oktober\",\"November\",\"Dezember\"]],[[\"J\",\"F\",\"M\",\"A\",\"M\",\"J\",\"J\",\"A\",\"S\",\"O\",\"N\",\"D\"],[\"Jan\",\"Feb\",\"Mär\",\"Apr\",\"Mai\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Okt\",\"Nov\",\"Dez\"],[\"Januar\",\"Februar\",\"März\",\"April\",\"Mai\",\"Juni\",\"Juli\",\"August\",\"September\",\"Oktober\",\"November\",\"Dezember\"]],[[\"v. Chr.\",\"n. Chr.\"],u,u],1,[6,0],[\"dd.MM.yy\",\"dd.MM.y\",\"d. MMMM y\",\"EEEE, d. MMMM y\"],[\"HH:mm\",\"HH:mm:ss\",\"HH:mm:ss z\",\"HH:mm:ss zzzz\"],[\"{1}, {0}\",u,\"{1} 'um' {0}\",u],[\",\",\".\",\";\",\"%\",\"+\",\"-\",\"E\",\"·\",\"‰\",\"∞\",\"NaN\",\":\"],[\"#,##0.###\",\"#,##0 %\",\"#,##0.00 ¤\",\"#E0\"],\"EUR\",\"€\",\"Euro\",{\"ATS\":[\"öS\"],\"AUD\":[\"AU$\",\"$\"],\"BGM\":[\"BGK\"],\"BGO\":[\"BGJ\"],\"BYN\":[u,\"р.\"],\"CUC\":[u,\"Cub$\"],\"DEM\":[\"DM\"],\"FKP\":[u,\"Fl£\"],\"GHS\":[u,\"₵\"],\"GNF\":[u,\"F.G.\"],\"KMF\":[u,\"FC\"],\"PHP\":[u,\"₱\"],\"RON\":[u,\"L\"],\"RUR\":[u,\"р.\"],\"RWF\":[u,\"F.Rw\"],\"SYP\":[],\"THB\":[\"฿\"],\"TWD\":[\"NT$\"],\"XXX\":[],\"ZMW\":[u,\"K\"]},\"ltr\", plural, [[[\"Mitternacht\",\"morgens\",\"vorm.\",\"mittags\",\"nachm.\",\"abends\",\"nachts\"],u,[\"Mitternacht\",\"morgens\",\"vormittags\",\"mittags\",\"nachmittags\",\"abends\",\"nachts\"]],[[\"Mitternacht\",\"Morgen\",\"Vorm.\",\"Mittag\",\"Nachm.\",\"Abend\",\"Nacht\"],u,[\"Mitternacht\",\"Morgen\",\"Vormittag\",\"Mittag\",\"Nachmittag\",\"Abend\",\"Nacht\"]],[\"00:00\",[\"05:00\",\"10:00\"],[\"10:00\",\"12:00\"],[\"12:00\",\"13:00\"],[\"13:00\",\"18:00\"],[\"18:00\",\"24:00\"],[\"00:00\",\"05:00\"]]]];\n })(globalThis);\n ","import * as i0 from '@angular/core';\nimport { InjectionToken, inject, ChangeDetectorRef, ElementRef, EventEmitter, booleanAttribute, TemplateRef, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, ContentChildren, Input, Output, Directive, forwardRef, Injector, ViewContainerRef, NgZone, Renderer2, afterNextRender, NgModule } from '@angular/core';\nimport { MAT_OPTION_PARENT_COMPONENT, MatOption, MAT_OPTGROUP, MatOptionSelectionChange, _countGroupLabelsBeforeOption, _getOptionScrollPosition, MatOptionModule, MatCommonModule } from '@angular/material/core';\nexport { MatOptgroup, MatOption } from '@angular/material/core';\nimport { ViewportRuler, CdkScrollableModule } from '@angular/cdk/scrolling';\nimport { Overlay, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';\nimport { _IdGenerator, ActiveDescendantKeyManager, removeAriaReferencedId, addAriaReferencedId } from '@angular/cdk/a11y';\nimport { Platform, _getEventTarget } from '@angular/cdk/platform';\nimport { trigger, state, style, transition, group, animate } from '@angular/animations';\nimport { Subscription, Subject, merge, of, defer, Observable } from 'rxjs';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { hasModifierKey, ESCAPE, ENTER, UP_ARROW, DOWN_ARROW, TAB } from '@angular/cdk/keycodes';\nimport { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport { DOCUMENT } from '@angular/common';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { MAT_FORM_FIELD } from '@angular/material/form-field';\nimport { filter, map, startWith, switchMap, tap, delay, take } from 'rxjs/operators';\n\n// Animation values come from\n// TODO(mmalerba): Ideally find a way to import the values from MDC's code.\nconst panelAnimation = trigger('panelAnimation', [\n state('void, hidden', style({\n opacity: 0,\n transform: 'scaleY(0.8)',\n })),\n transition(':enter, hidden => visible', [\n group([\n animate('0.03s linear', style({ opacity: 1 })),\n animate('0.12s cubic-bezier(0, 0, 0.2, 1)', style({ transform: 'scaleY(1)' })),\n ]),\n ]),\n transition(':leave, visible => hidden', [animate('0.075s linear', style({ opacity: 0 }))]),\n]);\n\n/** Event object that is emitted when an autocomplete option is selected. */\nclass MatAutocompleteSelectedEvent {\n source;\n option;\n constructor(\n /** Reference to the autocomplete panel that emitted the event. */\n source, \n /** Option that was selected. */\n option) {\n this.source = source;\n this.option = option;\n }\n}\n/** Injection token to be used to override the default options for `mat-autocomplete`. */\nconst MAT_AUTOCOMPLETE_DEFAULT_OPTIONS = new InjectionToken('mat-autocomplete-default-options', {\n providedIn: 'root',\n factory: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY,\n});\n/** @docs-private */\nfunction MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY() {\n return {\n autoActiveFirstOption: false,\n autoSelectActiveOption: false,\n hideSingleSelectionIndicator: false,\n requireSelection: false,\n };\n}\n/** Autocomplete component. */\nclass MatAutocomplete {\n _changeDetectorRef = inject(ChangeDetectorRef);\n _elementRef = inject(ElementRef);\n _defaults = inject(MAT_AUTOCOMPLETE_DEFAULT_OPTIONS);\n _activeOptionChanges = Subscription.EMPTY;\n /** Emits when the panel animation is done. Null if the panel doesn't animate. */\n _animationDone = new EventEmitter();\n /** Manages active item in option list based on key events. */\n _keyManager;\n /** Whether the autocomplete panel should be visible, depending on option length. */\n showPanel = false;\n /** Whether the autocomplete panel is open. */\n get isOpen() {\n return this._isOpen && this.showPanel;\n }\n _isOpen = false;\n /** Latest trigger that opened the autocomplete. */\n _latestOpeningTrigger;\n /** @docs-private Sets the theme color of the panel. */\n _setColor(value) {\n this._color = value;\n this._changeDetectorRef.markForCheck();\n }\n /** @docs-private theme color of the panel */\n _color;\n // The @ViewChild query for TemplateRef here needs to be static because some code paths\n // lead to the overlay being created before change detection has finished for this component.\n // Notably, another component may trigger `focus` on the autocomplete-trigger.\n /** @docs-private */\n template;\n /** Element for the panel containing the autocomplete options. */\n panel;\n /** Reference to all options within the autocomplete. */\n options;\n /** Reference to all option groups within the autocomplete. */\n optionGroups;\n /** Aria label of the autocomplete. */\n ariaLabel;\n /** Input that can be used to specify the `aria-labelledby` attribute. */\n ariaLabelledby;\n /** Function that maps an option's control value to its display value in the trigger. */\n displayWith = null;\n /**\n * Whether the first option should be highlighted when the autocomplete panel is opened.\n * Can be configured globally through the `MAT_AUTOCOMPLETE_DEFAULT_OPTIONS` token.\n */\n autoActiveFirstOption;\n /** Whether the active option should be selected as the user is navigating. */\n autoSelectActiveOption;\n /**\n * Whether the user is required to make a selection when they're interacting with the\n * autocomplete. If the user moves away from the autocomplete without selecting an option from\n * the list, the value will be reset. If the user opens the panel and closes it without\n * interacting or selecting a value, the initial value will be kept.\n */\n requireSelection;\n /**\n * Specify the width of the autocomplete panel. Can be any CSS sizing value, otherwise it will\n * match the width of its host.\n */\n panelWidth;\n /** Whether ripples are disabled within the autocomplete panel. */\n disableRipple;\n /** Event that is emitted whenever an option from the list is selected. */\n optionSelected = new EventEmitter();\n /** Event that is emitted when the autocomplete panel is opened. */\n opened = new EventEmitter();\n /** Event that is emitted when the autocomplete panel is closed. */\n closed = new EventEmitter();\n /** Emits whenever an option is activated. */\n optionActivated = new EventEmitter();\n /**\n * Takes classes set on the host mat-autocomplete element and applies them to the panel\n * inside the overlay container to allow for easy styling.\n */\n set classList(value) {\n this._classList = value;\n this._elementRef.nativeElement.className = '';\n }\n _classList;\n /** Whether checkmark indicator for single-selection options is hidden. */\n get hideSingleSelectionIndicator() {\n return this._hideSingleSelectionIndicator;\n }\n set hideSingleSelectionIndicator(value) {\n this._hideSingleSelectionIndicator = value;\n this._syncParentProperties();\n }\n _hideSingleSelectionIndicator;\n /** Syncs the parent state with the individual options. */\n _syncParentProperties() {\n if (this.options) {\n for (const option of this.options) {\n option._changeDetectorRef.markForCheck();\n }\n }\n }\n /** Unique ID to be used by autocomplete trigger's \"aria-owns\" property. */\n id = inject(_IdGenerator).getId('mat-autocomplete-');\n /**\n * Tells any descendant `mat-optgroup` to use the inert a11y pattern.\n * @docs-private\n */\n inertGroups;\n constructor() {\n const platform = inject(Platform);\n // TODO(crisbeto): the problem that the `inertGroups` option resolves is only present on\n // Safari using VoiceOver. We should occasionally check back to see whether the bug\n // wasn't resolved in VoiceOver, and if it has, we can remove this and the `inertGroups`\n // option altogether.\n this.inertGroups = platform?.SAFARI || false;\n this.autoActiveFirstOption = !!this._defaults.autoActiveFirstOption;\n this.autoSelectActiveOption = !!this._defaults.autoSelectActiveOption;\n this.requireSelection = !!this._defaults.requireSelection;\n this._hideSingleSelectionIndicator = this._defaults.hideSingleSelectionIndicator ?? false;\n }\n ngAfterContentInit() {\n this._keyManager = new ActiveDescendantKeyManager(this.options)\n .withWrap()\n .skipPredicate(this._skipPredicate);\n this._activeOptionChanges = this._keyManager.change.subscribe(index => {\n if (this.isOpen) {\n this.optionActivated.emit({ source: this, option: this.options.toArray()[index] || null });\n }\n });\n // Set the initial visibility state.\n this._setVisibility();\n }\n ngOnDestroy() {\n this._keyManager?.destroy();\n this._activeOptionChanges.unsubscribe();\n this._animationDone.complete();\n }\n /**\n * Sets the panel scrollTop. This allows us to manually scroll to display options\n * above or below the fold, as they are not actually being focused when active.\n */\n _setScrollTop(scrollTop) {\n if (this.panel) {\n this.panel.nativeElement.scrollTop = scrollTop;\n }\n }\n /** Returns the panel's scrollTop. */\n _getScrollTop() {\n return this.panel ? this.panel.nativeElement.scrollTop : 0;\n }\n /** Panel should hide itself when the option list is empty. */\n _setVisibility() {\n this.showPanel = !!this.options.length;\n this._changeDetectorRef.markForCheck();\n }\n /** Emits the `select` event. */\n _emitSelectEvent(option) {\n const event = new MatAutocompleteSelectedEvent(this, option);\n this.optionSelected.emit(event);\n }\n /** Gets the aria-labelledby for the autocomplete panel. */\n _getPanelAriaLabelledby(labelId) {\n if (this.ariaLabel) {\n return null;\n }\n const labelExpression = labelId ? labelId + ' ' : '';\n return this.ariaLabelledby ? labelExpression + this.ariaLabelledby : labelId;\n }\n // `skipPredicate` determines if key manager should avoid putting a given option in the tab\n // order. Allow disabled list items to receive focus via keyboard to align with WAI ARIA\n // recommendation.\n //\n // Normally WAI ARIA's instructions are to exclude disabled items from the tab order, but it\n // makes a few exceptions for compound widgets.\n //\n // From [Developing a Keyboard Interface](\n // https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/):\n // \"For the following composite widget elements, keep them focusable when disabled: Options in a\n // Listbox...\"\n //\n // The user can focus disabled options using the keyboard, but the user cannot click disabled\n // options.\n _skipPredicate() {\n return false;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocomplete, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"16.1.0\", version: \"19.0.0\", type: MatAutocomplete, isStandalone: true, selector: \"mat-autocomplete\", inputs: { ariaLabel: [\"aria-label\", \"ariaLabel\"], ariaLabelledby: [\"aria-labelledby\", \"ariaLabelledby\"], displayWith: \"displayWith\", autoActiveFirstOption: [\"autoActiveFirstOption\", \"autoActiveFirstOption\", booleanAttribute], autoSelectActiveOption: [\"autoSelectActiveOption\", \"autoSelectActiveOption\", booleanAttribute], requireSelection: [\"requireSelection\", \"requireSelection\", booleanAttribute], panelWidth: \"panelWidth\", disableRipple: [\"disableRipple\", \"disableRipple\", booleanAttribute], classList: [\"class\", \"classList\"], hideSingleSelectionIndicator: [\"hideSingleSelectionIndicator\", \"hideSingleSelectionIndicator\", booleanAttribute] }, outputs: { optionSelected: \"optionSelected\", opened: \"opened\", closed: \"closed\", optionActivated: \"optionActivated\" }, host: { classAttribute: \"mat-mdc-autocomplete\" }, providers: [{ provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }], queries: [{ propertyName: \"options\", predicate: MatOption, descendants: true }, { propertyName: \"optionGroups\", predicate: MAT_OPTGROUP, descendants: true }], viewQueries: [{ propertyName: \"template\", first: true, predicate: TemplateRef, descendants: true, static: true }, { propertyName: \"panel\", first: true, predicate: [\"panel\"], descendants: true }], exportAs: [\"matAutocomplete\"], ngImport: i0, template: \"\\n \\n \\n \\n\\n\", styles: [\"div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:static;border-radius:var(--mat-autocomplete-container-shape, var(--mat-sys-corner-extra-small));box-shadow:var(--mat-autocomplete-container-elevation-shadow, 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12));background-color:var(--mat-autocomplete-background-color, var(--mat-sys-surface-container))}@media(forced-colors: active){div.mat-mdc-autocomplete-panel{outline:solid 1px}}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden{visibility:hidden;pointer-events:none}mat-autocomplete{display:none}\"], animations: [panelAnimation], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocomplete, decorators: [{\n type: Component,\n args: [{ selector: 'mat-autocomplete', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'matAutocomplete', host: {\n 'class': 'mat-mdc-autocomplete',\n }, providers: [{ provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }], animations: [panelAnimation], template: \"\\n \\n \\n \\n\\n\", styles: [\"div.mat-mdc-autocomplete-panel{width:100%;max-height:256px;visibility:hidden;transform-origin:center top;overflow:auto;padding:8px 0;box-sizing:border-box;position:static;border-radius:var(--mat-autocomplete-container-shape, var(--mat-sys-corner-extra-small));box-shadow:var(--mat-autocomplete-container-elevation-shadow, 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12));background-color:var(--mat-autocomplete-background-color, var(--mat-sys-surface-container))}@media(forced-colors: active){div.mat-mdc-autocomplete-panel{outline:solid 1px}}.cdk-overlay-pane:not(.mat-mdc-autocomplete-panel-above) div.mat-mdc-autocomplete-panel{border-top-left-radius:0;border-top-right-radius:0}.mat-mdc-autocomplete-panel-above div.mat-mdc-autocomplete-panel{border-bottom-left-radius:0;border-bottom-right-radius:0;transform-origin:center bottom}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-visible{visibility:visible}div.mat-mdc-autocomplete-panel.mat-mdc-autocomplete-hidden{visibility:hidden;pointer-events:none}mat-autocomplete{display:none}\"] }]\n }], ctorParameters: () => [], propDecorators: { template: [{\n type: ViewChild,\n args: [TemplateRef, { static: true }]\n }], panel: [{\n type: ViewChild,\n args: ['panel']\n }], options: [{\n type: ContentChildren,\n args: [MatOption, { descendants: true }]\n }], optionGroups: [{\n type: ContentChildren,\n args: [MAT_OPTGROUP, { descendants: true }]\n }], ariaLabel: [{\n type: Input,\n args: ['aria-label']\n }], ariaLabelledby: [{\n type: Input,\n args: ['aria-labelledby']\n }], displayWith: [{\n type: Input\n }], autoActiveFirstOption: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], autoSelectActiveOption: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], requireSelection: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], panelWidth: [{\n type: Input\n }], disableRipple: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], optionSelected: [{\n type: Output\n }], opened: [{\n type: Output\n }], closed: [{\n type: Output\n }], optionActivated: [{\n type: Output\n }], classList: [{\n type: Input,\n args: ['class']\n }], hideSingleSelectionIndicator: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }] } });\n\n/**\n * Directive applied to an element to make it usable\n * as a connection point for an autocomplete panel.\n */\nclass MatAutocompleteOrigin {\n elementRef = inject(ElementRef);\n constructor() { }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteOrigin, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: MatAutocompleteOrigin, isStandalone: true, selector: \"[matAutocompleteOrigin]\", exportAs: [\"matAutocompleteOrigin\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteOrigin, decorators: [{\n type: Directive,\n args: [{\n selector: '[matAutocompleteOrigin]',\n exportAs: 'matAutocompleteOrigin',\n }]\n }], ctorParameters: () => [] });\n\n/**\n * Provider that allows the autocomplete to register as a ControlValueAccessor.\n * @docs-private\n */\nconst MAT_AUTOCOMPLETE_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => MatAutocompleteTrigger),\n multi: true,\n};\n/**\n * Creates an error to be thrown when attempting to use an autocomplete trigger without a panel.\n * @docs-private\n */\nfunction getMatAutocompleteMissingPanelError() {\n return Error('Attempting to open an undefined instance of `mat-autocomplete`. ' +\n 'Make sure that the id passed to the `matAutocomplete` is correct and that ' +\n \"you're attempting to open it after the ngAfterContentInit hook.\");\n}\n/** Injection token that determines the scroll handling while the autocomplete panel is open. */\nconst MAT_AUTOCOMPLETE_SCROLL_STRATEGY = new InjectionToken('mat-autocomplete-scroll-strategy', {\n providedIn: 'root',\n factory: () => {\n const overlay = inject(Overlay);\n return () => overlay.scrollStrategies.reposition();\n },\n});\n/** @docs-private */\nfunction MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY(overlay) {\n return () => overlay.scrollStrategies.reposition();\n}\n/** @docs-private */\nconst MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER = {\n provide: MAT_AUTOCOMPLETE_SCROLL_STRATEGY,\n deps: [Overlay],\n useFactory: MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY,\n};\n/** Base class with all of the `MatAutocompleteTrigger` functionality. */\nclass MatAutocompleteTrigger {\n _injector = inject(Injector);\n _element = inject(ElementRef);\n _overlay = inject(Overlay);\n _viewContainerRef = inject(ViewContainerRef);\n _zone = inject(NgZone);\n _changeDetectorRef = inject(ChangeDetectorRef);\n _dir = inject(Directionality, { optional: true });\n _formField = inject(MAT_FORM_FIELD, { optional: true, host: true });\n _document = inject(DOCUMENT);\n _viewportRuler = inject(ViewportRuler);\n _scrollStrategy = inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY);\n _renderer = inject(Renderer2);\n _defaults = inject(MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, { optional: true });\n _overlayRef;\n _portal;\n _componentDestroyed = false;\n _initialized = new Subject();\n _keydownSubscription;\n _outsideClickSubscription;\n _cleanupWindowBlur;\n /** Old value of the native input. Used to work around issues with the `input` event on IE. */\n _previousValue;\n /** Value of the input element when the panel was attached (even if there are no options). */\n _valueOnAttach;\n /** Value on the previous keydown event. */\n _valueOnLastKeydown;\n /** Strategy that is used to position the panel. */\n _positionStrategy;\n /** Whether or not the label state is being overridden. */\n _manuallyFloatingLabel = false;\n /** The subscription for closing actions (some are bound to document). */\n _closingActionsSubscription;\n /** Subscription to viewport size changes. */\n _viewportSubscription = Subscription.EMPTY;\n /** Implements BreakpointObserver to be used to detect handset landscape */\n _breakpointObserver = inject(BreakpointObserver);\n _handsetLandscapeSubscription = Subscription.EMPTY;\n /**\n * Whether the autocomplete can open the next time it is focused. Used to prevent a focused,\n * closed autocomplete from being reopened if the user switches to another browser tab and then\n * comes back.\n */\n _canOpenOnNextFocus = true;\n /** Value inside the input before we auto-selected an option. */\n _valueBeforeAutoSelection;\n /**\n * Current option that we have auto-selected as the user is navigating,\n * but which hasn't been propagated to the model value yet.\n */\n _pendingAutoselectedOption;\n /** Stream of keyboard events that can close the panel. */\n _closeKeyEventStream = new Subject();\n /**\n * Event handler for when the window is blurred. Needs to be an\n * arrow function in order to preserve the context.\n */\n _windowBlurHandler = () => {\n // If the user blurred the window while the autocomplete is focused, it means that it'll be\n // refocused when they come back. In this case we want to skip the first focus event, if the\n // pane was closed, in order to avoid reopening it unintentionally.\n this._canOpenOnNextFocus =\n this._document.activeElement !== this._element.nativeElement || this.panelOpen;\n };\n /** `View -> model callback called when value changes` */\n _onChange = () => { };\n /** `View -> model callback called when autocomplete has been touched` */\n _onTouched = () => { };\n /** The autocomplete panel to be attached to this trigger. */\n autocomplete;\n /**\n * Position of the autocomplete panel relative to the trigger element. A position of `auto`\n * will render the panel underneath the trigger if there is enough space for it to fit in\n * the viewport, otherwise the panel will be shown above it. If the position is set to\n * `above` or `below`, the panel will always be shown above or below the trigger. no matter\n * whether it fits completely in the viewport.\n */\n position = 'auto';\n /**\n * Reference relative to which to position the autocomplete panel.\n * Defaults to the autocomplete trigger element.\n */\n connectedTo;\n /**\n * `autocomplete` attribute to be set on the input element.\n * @docs-private\n */\n autocompleteAttribute = 'off';\n /**\n * Whether the autocomplete is disabled. When disabled, the element will\n * act as a regular input and the user won't be able to open the panel.\n */\n autocompleteDisabled;\n constructor() { }\n /** Class to apply to the panel when it's above the input. */\n _aboveClass = 'mat-mdc-autocomplete-panel-above';\n ngAfterViewInit() {\n this._initialized.next();\n this._initialized.complete();\n this._cleanupWindowBlur = this._renderer.listen('window', 'blur', this._windowBlurHandler);\n }\n ngOnChanges(changes) {\n if (changes['position'] && this._positionStrategy) {\n this._setStrategyPositions(this._positionStrategy);\n if (this.panelOpen) {\n this._overlayRef.updatePosition();\n }\n }\n }\n ngOnDestroy() {\n this._cleanupWindowBlur?.();\n this._handsetLandscapeSubscription.unsubscribe();\n this._viewportSubscription.unsubscribe();\n this._componentDestroyed = true;\n this._destroyPanel();\n this._closeKeyEventStream.complete();\n this._clearFromModal();\n }\n /** Whether or not the autocomplete panel is open. */\n get panelOpen() {\n return this._overlayAttached && this.autocomplete.showPanel;\n }\n _overlayAttached = false;\n /** Opens the autocomplete suggestion panel. */\n openPanel() {\n this._openPanelInternal();\n }\n /** Closes the autocomplete suggestion panel. */\n closePanel() {\n this._resetLabel();\n if (!this._overlayAttached) {\n return;\n }\n if (this.panelOpen) {\n // Only emit if the panel was visible.\n // `afterNextRender` always runs outside of the Angular zone, so all the subscriptions from\n // `_subscribeToClosingActions()` are also outside of the Angular zone.\n // We should manually run in Angular zone to update UI after panel closing.\n this._zone.run(() => {\n this.autocomplete.closed.emit();\n });\n }\n // Only reset if this trigger is the latest one that opened the\n // autocomplete since another may have taken it over.\n if (this.autocomplete._latestOpeningTrigger === this) {\n this.autocomplete._isOpen = false;\n this.autocomplete._latestOpeningTrigger = null;\n }\n this._overlayAttached = false;\n this._pendingAutoselectedOption = null;\n if (this._overlayRef && this._overlayRef.hasAttached()) {\n this._overlayRef.detach();\n this._closingActionsSubscription.unsubscribe();\n }\n this._updatePanelState();\n // Note that in some cases this can end up being called after the component is destroyed.\n // Add a check to ensure that we don't try to run change detection on a destroyed view.\n if (!this._componentDestroyed) {\n // We need to trigger change detection manually, because\n // `fromEvent` doesn't seem to do it at the proper time.\n // This ensures that the label is reset when the\n // user clicks outside.\n this._changeDetectorRef.detectChanges();\n }\n // Remove aria-owns attribute when the autocomplete is no longer visible.\n if (this._trackedModal) {\n removeAriaReferencedId(this._trackedModal, 'aria-owns', this.autocomplete.id);\n }\n }\n /**\n * Updates the position of the autocomplete suggestion panel to ensure that it fits all options\n * within the viewport.\n */\n updatePosition() {\n if (this._overlayAttached) {\n this._overlayRef.updatePosition();\n }\n }\n /**\n * A stream of actions that should close the autocomplete panel, including\n * when an option is selected, on blur, and when TAB is pressed.\n */\n get panelClosingActions() {\n return merge(this.optionSelections, this.autocomplete._keyManager.tabOut.pipe(filter(() => this._overlayAttached)), this._closeKeyEventStream, this._getOutsideClickStream(), this._overlayRef\n ? this._overlayRef.detachments().pipe(filter(() => this._overlayAttached))\n : of()).pipe(\n // Normalize the output so we return a consistent type.\n map(event => (event instanceof MatOptionSelectionChange ? event : null)));\n }\n /** Stream of changes to the selection state of the autocomplete options. */\n optionSelections = defer(() => {\n const options = this.autocomplete ? this.autocomplete.options : null;\n if (options) {\n return options.changes.pipe(startWith(options), switchMap(() => merge(...options.map(option => option.onSelectionChange))));\n }\n // If there are any subscribers before `ngAfterViewInit`, the `autocomplete` will be undefined.\n // Return a stream that we'll replace with the real one once everything is in place.\n return this._initialized.pipe(switchMap(() => this.optionSelections));\n });\n /** The currently active option, coerced to MatOption type. */\n get activeOption() {\n if (this.autocomplete && this.autocomplete._keyManager) {\n return this.autocomplete._keyManager.activeItem;\n }\n return null;\n }\n /** Stream of clicks outside of the autocomplete panel. */\n _getOutsideClickStream() {\n return new Observable(observer => {\n const listener = (event) => {\n // If we're in the Shadow DOM, the event target will be the shadow root, so we have to\n // fall back to check the first element in the path of the click event.\n const clickTarget = _getEventTarget(event);\n const formField = this._formField\n ? this._formField.getConnectedOverlayOrigin().nativeElement\n : null;\n const customOrigin = this.connectedTo ? this.connectedTo.elementRef.nativeElement : null;\n if (this._overlayAttached &&\n clickTarget !== this._element.nativeElement &&\n // Normally focus moves inside `mousedown` so this condition will almost always be\n // true. Its main purpose is to handle the case where the input is focused from an\n // outside click which propagates up to the `body` listener within the same sequence\n // and causes the panel to close immediately (see #3106).\n this._document.activeElement !== this._element.nativeElement &&\n (!formField || !formField.contains(clickTarget)) &&\n (!customOrigin || !customOrigin.contains(clickTarget)) &&\n !!this._overlayRef &&\n !this._overlayRef.overlayElement.contains(clickTarget)) {\n observer.next(event);\n }\n };\n const cleanups = [\n this._renderer.listen('document', 'click', listener),\n this._renderer.listen('document', 'auxclick', listener),\n this._renderer.listen('document', 'touchend', listener),\n ];\n return () => {\n cleanups.forEach(current => current());\n };\n });\n }\n // Implemented as part of ControlValueAccessor.\n writeValue(value) {\n Promise.resolve(null).then(() => this._assignOptionValue(value));\n }\n // Implemented as part of ControlValueAccessor.\n registerOnChange(fn) {\n this._onChange = fn;\n }\n // Implemented as part of ControlValueAccessor.\n registerOnTouched(fn) {\n this._onTouched = fn;\n }\n // Implemented as part of ControlValueAccessor.\n setDisabledState(isDisabled) {\n this._element.nativeElement.disabled = isDisabled;\n }\n _handleKeydown(event) {\n const keyCode = event.keyCode;\n const hasModifier = hasModifierKey(event);\n // Prevent the default action on all escape key presses. This is here primarily to bring IE\n // in line with other browsers. By default, pressing escape on IE will cause it to revert\n // the input value to the one that it had on focus, however it won't dispatch any events\n // which means that the model value will be out of sync with the view.\n if (keyCode === ESCAPE && !hasModifier) {\n event.preventDefault();\n }\n this._valueOnLastKeydown = this._element.nativeElement.value;\n if (this.activeOption && keyCode === ENTER && this.panelOpen && !hasModifier) {\n this.activeOption._selectViaInteraction();\n this._resetActiveItem();\n event.preventDefault();\n }\n else if (this.autocomplete) {\n const prevActiveItem = this.autocomplete._keyManager.activeItem;\n const isArrowKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW;\n if (keyCode === TAB || (isArrowKey && !hasModifier && this.panelOpen)) {\n this.autocomplete._keyManager.onKeydown(event);\n }\n else if (isArrowKey && this._canOpen()) {\n this._openPanelInternal(this._valueOnLastKeydown);\n }\n if (isArrowKey || this.autocomplete._keyManager.activeItem !== prevActiveItem) {\n this._scrollToOption(this.autocomplete._keyManager.activeItemIndex || 0);\n if (this.autocomplete.autoSelectActiveOption && this.activeOption) {\n if (!this._pendingAutoselectedOption) {\n this._valueBeforeAutoSelection = this._valueOnLastKeydown;\n }\n this._pendingAutoselectedOption = this.activeOption;\n this._assignOptionValue(this.activeOption.value);\n }\n }\n }\n }\n _handleInput(event) {\n let target = event.target;\n let value = target.value;\n // Based on `NumberValueAccessor` from forms.\n if (target.type === 'number') {\n value = value == '' ? null : parseFloat(value);\n }\n // If the input has a placeholder, IE will fire the `input` event on page load,\n // focus and blur, in addition to when the user actually changed the value. To\n // filter out all of the extra events, we save the value on focus and between\n // `input` events, and we check whether it changed.\n // See: https://connect.microsoft.com/IE/feedback/details/885747/\n if (this._previousValue !== value) {\n this._previousValue = value;\n this._pendingAutoselectedOption = null;\n // If selection is required we don't write to the CVA while the user is typing.\n // At the end of the selection either the user will have picked something\n // or we'll reset the value back to null.\n if (!this.autocomplete || !this.autocomplete.requireSelection) {\n this._onChange(value);\n }\n if (!value) {\n this._clearPreviousSelectedOption(null, false);\n }\n else if (this.panelOpen && !this.autocomplete.requireSelection) {\n // Note that we don't reset this when `requireSelection` is enabled,\n // because the option will be reset when the panel is closed.\n const selectedOption = this.autocomplete.options?.find(option => option.selected);\n if (selectedOption) {\n const display = this._getDisplayValue(selectedOption.value);\n if (value !== display) {\n selectedOption.deselect(false);\n }\n }\n }\n if (this._canOpen() && this._document.activeElement === event.target) {\n // When the `input` event fires, the input's value will have already changed. This means\n // that if we take the `this._element.nativeElement.value` directly, it'll be one keystroke\n // behind. This can be a problem when the user selects a value, changes a character while\n // the input still has focus and then clicks away (see #28432). To work around it, we\n // capture the value in `keydown` so we can use it here.\n const valueOnAttach = this._valueOnLastKeydown ?? this._element.nativeElement.value;\n this._valueOnLastKeydown = null;\n this._openPanelInternal(valueOnAttach);\n }\n }\n }\n _handleFocus() {\n if (!this._canOpenOnNextFocus) {\n this._canOpenOnNextFocus = true;\n }\n else if (this._canOpen()) {\n this._previousValue = this._element.nativeElement.value;\n this._attachOverlay(this._previousValue);\n this._floatLabel(true);\n }\n }\n _handleClick() {\n if (this._canOpen() && !this.panelOpen) {\n this._openPanelInternal();\n }\n }\n /**\n * In \"auto\" mode, the label will animate down as soon as focus is lost.\n * This causes the value to jump when selecting an option with the mouse.\n * This method manually floats the label until the panel can be closed.\n * @param shouldAnimate Whether the label should be animated when it is floated.\n */\n _floatLabel(shouldAnimate = false) {\n if (this._formField && this._formField.floatLabel === 'auto') {\n if (shouldAnimate) {\n this._formField._animateAndLockLabel();\n }\n else {\n this._formField.floatLabel = 'always';\n }\n this._manuallyFloatingLabel = true;\n }\n }\n /** If the label has been manually elevated, return it to its normal state. */\n _resetLabel() {\n if (this._manuallyFloatingLabel) {\n if (this._formField) {\n this._formField.floatLabel = 'auto';\n }\n this._manuallyFloatingLabel = false;\n }\n }\n /**\n * This method listens to a stream of panel closing actions and resets the\n * stream every time the option list changes.\n */\n _subscribeToClosingActions() {\n const initialRender = new Observable(subscriber => {\n afterNextRender(() => {\n subscriber.next();\n }, { injector: this._injector });\n });\n const optionChanges = this.autocomplete.options.changes.pipe(tap(() => this._positionStrategy.reapplyLastPosition()), \n // Defer emitting to the stream until the next tick, because changing\n // bindings in here will cause \"changed after checked\" errors.\n delay(0));\n // When the options are initially rendered, and when the option list changes...\n return (merge(initialRender, optionChanges)\n .pipe(\n // create a new stream of panelClosingActions, replacing any previous streams\n // that were created, and flatten it so our stream only emits closing events...\n switchMap(() => this._zone.run(() => {\n // `afterNextRender` always runs outside of the Angular zone, thus we have to re-enter\n // the Angular zone. This will lead to change detection being called outside of the Angular\n // zone and the `autocomplete.opened` will also emit outside of the Angular.\n const wasOpen = this.panelOpen;\n this._resetActiveItem();\n this._updatePanelState();\n this._changeDetectorRef.detectChanges();\n if (this.panelOpen) {\n this._overlayRef.updatePosition();\n }\n if (wasOpen !== this.panelOpen) {\n // If the `panelOpen` state changed, we need to make sure to emit the `opened` or\n // `closed` event, because we may not have emitted it. This can happen\n // - if the users opens the panel and there are no options, but the\n // options come in slightly later or as a result of the value changing,\n // - if the panel is closed after the user entered a string that did not match any\n // of the available options,\n // - if a valid string is entered after an invalid one.\n if (this.panelOpen) {\n this._emitOpened();\n }\n else {\n this.autocomplete.closed.emit();\n }\n }\n return this.panelClosingActions;\n })), \n // when the first closing event occurs...\n take(1))\n // set the value, close the panel, and complete.\n .subscribe(event => this._setValueAndClose(event)));\n }\n /**\n * Emits the opened event once it's known that the panel will be shown and stores\n * the state of the trigger right before the opening sequence was finished.\n */\n _emitOpened() {\n this.autocomplete.opened.emit();\n }\n /** Destroys the autocomplete suggestion panel. */\n _destroyPanel() {\n if (this._overlayRef) {\n this.closePanel();\n this._overlayRef.dispose();\n this._overlayRef = null;\n }\n }\n /** Given a value, returns the string that should be shown within the input. */\n _getDisplayValue(value) {\n const autocomplete = this.autocomplete;\n return autocomplete && autocomplete.displayWith ? autocomplete.displayWith(value) : value;\n }\n _assignOptionValue(value) {\n const toDisplay = this._getDisplayValue(value);\n if (value == null) {\n this._clearPreviousSelectedOption(null, false);\n }\n // Simply falling back to an empty string if the display value is falsy does not work properly.\n // The display value can also be the number zero and shouldn't fall back to an empty string.\n this._updateNativeInputValue(toDisplay != null ? toDisplay : '');\n }\n _updateNativeInputValue(value) {\n // If it's used within a `MatFormField`, we should set it through the property so it can go\n // through change detection.\n if (this._formField) {\n this._formField._control.value = value;\n }\n else {\n this._element.nativeElement.value = value;\n }\n this._previousValue = value;\n }\n /**\n * This method closes the panel, and if a value is specified, also sets the associated\n * control to that value. It will also mark the control as dirty if this interaction\n * stemmed from the user.\n */\n _setValueAndClose(event) {\n const panel = this.autocomplete;\n const toSelect = event ? event.source : this._pendingAutoselectedOption;\n if (toSelect) {\n this._clearPreviousSelectedOption(toSelect);\n this._assignOptionValue(toSelect.value);\n // TODO(crisbeto): this should wait until the animation is done, otherwise the value\n // gets reset while the panel is still animating which looks glitchy. It'll likely break\n // some tests to change it at this point.\n this._onChange(toSelect.value);\n panel._emitSelectEvent(toSelect);\n this._element.nativeElement.focus();\n }\n else if (panel.requireSelection &&\n this._element.nativeElement.value !== this._valueOnAttach) {\n this._clearPreviousSelectedOption(null);\n this._assignOptionValue(null);\n // Wait for the animation to finish before clearing the form control value, otherwise\n // the options might change while the animation is running which looks glitchy.\n if (panel._animationDone) {\n panel._animationDone.pipe(take(1)).subscribe(() => this._onChange(null));\n }\n else {\n this._onChange(null);\n }\n }\n this.closePanel();\n }\n /**\n * Clear any previous selected option and emit a selection change event for this option\n */\n _clearPreviousSelectedOption(skip, emitEvent) {\n // Null checks are necessary here, because the autocomplete\n // or its options may not have been assigned yet.\n this.autocomplete?.options?.forEach(option => {\n if (option !== skip && option.selected) {\n option.deselect(emitEvent);\n }\n });\n }\n _openPanelInternal(valueOnAttach = this._element.nativeElement.value) {\n this._attachOverlay(valueOnAttach);\n this._floatLabel();\n // Add aria-owns attribute when the autocomplete becomes visible.\n if (this._trackedModal) {\n const panelId = this.autocomplete.id;\n addAriaReferencedId(this._trackedModal, 'aria-owns', panelId);\n }\n }\n _attachOverlay(valueOnAttach) {\n if (!this.autocomplete && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw getMatAutocompleteMissingPanelError();\n }\n let overlayRef = this._overlayRef;\n if (!overlayRef) {\n this._portal = new TemplatePortal(this.autocomplete.template, this._viewContainerRef, {\n id: this._formField?.getLabelId(),\n });\n overlayRef = this._overlay.create(this._getOverlayConfig());\n this._overlayRef = overlayRef;\n this._viewportSubscription = this._viewportRuler.change().subscribe(() => {\n if (this.panelOpen && overlayRef) {\n overlayRef.updateSize({ width: this._getPanelWidth() });\n }\n });\n // Subscribe to the breakpoint events stream to detect when screen is in\n // handsetLandscape.\n this._handsetLandscapeSubscription = this._breakpointObserver\n .observe(Breakpoints.HandsetLandscape)\n .subscribe(result => {\n const isHandsetLandscape = result.matches;\n // Check if result.matches Breakpoints.HandsetLandscape. Apply HandsetLandscape\n // settings to prevent overlay cutoff in that breakpoint. Fixes b/284148377\n if (isHandsetLandscape) {\n this._positionStrategy\n .withFlexibleDimensions(true)\n .withGrowAfterOpen(true)\n .withViewportMargin(8);\n }\n else {\n this._positionStrategy\n .withFlexibleDimensions(false)\n .withGrowAfterOpen(false)\n .withViewportMargin(0);\n }\n });\n }\n else {\n // Update the trigger, panel width and direction, in case anything has changed.\n this._positionStrategy.setOrigin(this._getConnectedElement());\n overlayRef.updateSize({ width: this._getPanelWidth() });\n }\n if (overlayRef && !overlayRef.hasAttached()) {\n overlayRef.attach(this._portal);\n this._valueOnAttach = valueOnAttach;\n this._valueOnLastKeydown = null;\n this._closingActionsSubscription = this._subscribeToClosingActions();\n }\n const wasOpen = this.panelOpen;\n this.autocomplete._isOpen = this._overlayAttached = true;\n this.autocomplete._latestOpeningTrigger = this;\n this.autocomplete._setColor(this._formField?.color);\n this._updatePanelState();\n this._applyModalPanelOwnership();\n // We need to do an extra `panelOpen` check in here, because the\n // autocomplete won't be shown if there are no options.\n if (this.panelOpen && wasOpen !== this.panelOpen) {\n this._emitOpened();\n }\n }\n /** Handles keyboard events coming from the overlay panel. */\n _handlePanelKeydown = (event) => {\n // Close when pressing ESCAPE or ALT + UP_ARROW, based on the a11y guidelines.\n // See: https://www.w3.org/TR/wai-aria-practices-1.1/#textbox-keyboard-interaction\n if ((event.keyCode === ESCAPE && !hasModifierKey(event)) ||\n (event.keyCode === UP_ARROW && hasModifierKey(event, 'altKey'))) {\n // If the user had typed something in before we autoselected an option, and they decided\n // to cancel the selection, restore the input value to the one they had typed in.\n if (this._pendingAutoselectedOption) {\n this._updateNativeInputValue(this._valueBeforeAutoSelection ?? '');\n this._pendingAutoselectedOption = null;\n }\n this._closeKeyEventStream.next();\n this._resetActiveItem();\n // We need to stop propagation, otherwise the event will eventually\n // reach the input itself and cause the overlay to be reopened.\n event.stopPropagation();\n event.preventDefault();\n }\n };\n /** Updates the panel's visibility state and any trigger state tied to id. */\n _updatePanelState() {\n this.autocomplete._setVisibility();\n // Note that here we subscribe and unsubscribe based on the panel's visiblity state,\n // because the act of subscribing will prevent events from reaching other overlays and\n // we don't want to block the events if there are no options.\n if (this.panelOpen) {\n const overlayRef = this._overlayRef;\n if (!this._keydownSubscription) {\n // Use the `keydownEvents` in order to take advantage of\n // the overlay event targeting provided by the CDK overlay.\n this._keydownSubscription = overlayRef.keydownEvents().subscribe(this._handlePanelKeydown);\n }\n if (!this._outsideClickSubscription) {\n // Subscribe to the pointer events stream so that it doesn't get picked up by other overlays.\n // TODO(crisbeto): we should switch `_getOutsideClickStream` eventually to use this stream,\n // but the behvior isn't exactly the same and it ends up breaking some internal tests.\n this._outsideClickSubscription = overlayRef.outsidePointerEvents().subscribe();\n }\n }\n else {\n this._keydownSubscription?.unsubscribe();\n this._outsideClickSubscription?.unsubscribe();\n this._keydownSubscription = this._outsideClickSubscription = null;\n }\n }\n _getOverlayConfig() {\n return new OverlayConfig({\n positionStrategy: this._getOverlayPosition(),\n scrollStrategy: this._scrollStrategy(),\n width: this._getPanelWidth(),\n direction: this._dir ?? undefined,\n panelClass: this._defaults?.overlayPanelClass,\n });\n }\n _getOverlayPosition() {\n // Set default Overlay Position\n const strategy = this._overlay\n .position()\n .flexibleConnectedTo(this._getConnectedElement())\n .withFlexibleDimensions(false)\n .withPush(false);\n this._setStrategyPositions(strategy);\n this._positionStrategy = strategy;\n return strategy;\n }\n /** Sets the positions on a position strategy based on the directive's input state. */\n _setStrategyPositions(positionStrategy) {\n // Note that we provide horizontal fallback positions, even though by default the dropdown\n // width matches the input, because consumers can override the width. See #18854.\n const belowPositions = [\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },\n ];\n // The overlay edge connected to the trigger should have squared corners, while\n // the opposite end has rounded corners. We apply a CSS class to swap the\n // border-radius based on the overlay position.\n const panelClass = this._aboveClass;\n const abovePositions = [\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', panelClass },\n { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom', panelClass },\n ];\n let positions;\n if (this.position === 'above') {\n positions = abovePositions;\n }\n else if (this.position === 'below') {\n positions = belowPositions;\n }\n else {\n positions = [...belowPositions, ...abovePositions];\n }\n positionStrategy.withPositions(positions);\n }\n _getConnectedElement() {\n if (this.connectedTo) {\n return this.connectedTo.elementRef;\n }\n return this._formField ? this._formField.getConnectedOverlayOrigin() : this._element;\n }\n _getPanelWidth() {\n return this.autocomplete.panelWidth || this._getHostWidth();\n }\n /** Returns the width of the input element, so the panel width can match it. */\n _getHostWidth() {\n return this._getConnectedElement().nativeElement.getBoundingClientRect().width;\n }\n /**\n * Reset the active item to -1. This is so that pressing arrow keys will activate the correct\n * option.\n *\n * If the consumer opted-in to automatically activatating the first option, activate the first\n * *enabled* option.\n */\n _resetActiveItem() {\n const autocomplete = this.autocomplete;\n if (autocomplete.autoActiveFirstOption) {\n // Find the index of the first *enabled* option. Avoid calling `_keyManager.setActiveItem`\n // because it activates the first option that passes the skip predicate, rather than the\n // first *enabled* option.\n let firstEnabledOptionIndex = -1;\n for (let index = 0; index < autocomplete.options.length; index++) {\n const option = autocomplete.options.get(index);\n if (!option.disabled) {\n firstEnabledOptionIndex = index;\n break;\n }\n }\n autocomplete._keyManager.setActiveItem(firstEnabledOptionIndex);\n }\n else {\n autocomplete._keyManager.setActiveItem(-1);\n }\n }\n /** Determines whether the panel can be opened. */\n _canOpen() {\n const element = this._element.nativeElement;\n return !element.readOnly && !element.disabled && !this.autocompleteDisabled;\n }\n /** Scrolls to a particular option in the list. */\n _scrollToOption(index) {\n // Given that we are not actually focusing active options, we must manually adjust scroll\n // to reveal options below the fold. First, we find the offset of the option from the top\n // of the panel. If that offset is below the fold, the new scrollTop will be the offset -\n // the panel height + the option height, so the active option will be just visible at the\n // bottom of the panel. If that offset is above the top of the visible panel, the new scrollTop\n // will become the offset. If that offset is visible within the panel already, the scrollTop is\n // not adjusted.\n const autocomplete = this.autocomplete;\n const labelCount = _countGroupLabelsBeforeOption(index, autocomplete.options, autocomplete.optionGroups);\n if (index === 0 && labelCount === 1) {\n // If we've got one group label before the option and we're at the top option,\n // scroll the list to the top. This is better UX than scrolling the list to the\n // top of the option, because it allows the user to read the top group's label.\n autocomplete._setScrollTop(0);\n }\n else if (autocomplete.panel) {\n const option = autocomplete.options.toArray()[index];\n if (option) {\n const element = option._getHostElement();\n const newScrollPosition = _getOptionScrollPosition(element.offsetTop, element.offsetHeight, autocomplete._getScrollTop(), autocomplete.panel.nativeElement.offsetHeight);\n autocomplete._setScrollTop(newScrollPosition);\n }\n }\n }\n /**\n * Track which modal we have modified the `aria-owns` attribute of. When the combobox trigger is\n * inside an aria-modal, we apply aria-owns to the parent modal with the `id` of the options\n * panel. Track the modal we have changed so we can undo the changes on destroy.\n */\n _trackedModal = null;\n /**\n * If the autocomplete trigger is inside of an `aria-modal` element, connect\n * that modal to the options panel with `aria-owns`.\n *\n * For some browser + screen reader combinations, when navigation is inside\n * of an `aria-modal` element, the screen reader treats everything outside\n * of that modal as hidden or invisible.\n *\n * This causes a problem when the combobox trigger is _inside_ of a modal, because the\n * options panel is rendered _outside_ of that modal, preventing screen reader navigation\n * from reaching the panel.\n *\n * We can work around this issue by applying `aria-owns` to the modal with the `id` of\n * the options panel. This effectively communicates to assistive technology that the\n * options panel is part of the same interaction as the modal.\n *\n * At time of this writing, this issue is present in VoiceOver.\n * See https://github.com/angular/components/issues/20694\n */\n _applyModalPanelOwnership() {\n // TODO(http://github.com/angular/components/issues/26853): consider de-duplicating this with\n // the `LiveAnnouncer` and any other usages.\n //\n // Note that the selector here is limited to CDK overlays at the moment in order to reduce the\n // section of the DOM we need to look through. This should cover all the cases we support, but\n // the selector can be expanded if it turns out to be too narrow.\n const modal = this._element.nativeElement.closest('body > .cdk-overlay-container [aria-modal=\"true\"]');\n if (!modal) {\n // Most commonly, the autocomplete trigger is not inside a modal.\n return;\n }\n const panelId = this.autocomplete.id;\n if (this._trackedModal) {\n removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);\n }\n addAriaReferencedId(modal, 'aria-owns', panelId);\n this._trackedModal = modal;\n }\n /** Clears the references to the listbox overlay element from the modal it was added to. */\n _clearFromModal() {\n if (this._trackedModal) {\n const panelId = this.autocomplete.id;\n removeAriaReferencedId(this._trackedModal, 'aria-owns', panelId);\n this._trackedModal = null;\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: MatAutocompleteTrigger, isStandalone: true, selector: \"input[matAutocomplete], textarea[matAutocomplete]\", inputs: { autocomplete: [\"matAutocomplete\", \"autocomplete\"], position: [\"matAutocompletePosition\", \"position\"], connectedTo: [\"matAutocompleteConnectedTo\", \"connectedTo\"], autocompleteAttribute: [\"autocomplete\", \"autocompleteAttribute\"], autocompleteDisabled: [\"matAutocompleteDisabled\", \"autocompleteDisabled\", booleanAttribute] }, host: { listeners: { \"focusin\": \"_handleFocus()\", \"blur\": \"_onTouched()\", \"input\": \"_handleInput($event)\", \"keydown\": \"_handleKeydown($event)\", \"click\": \"_handleClick()\" }, properties: { \"attr.autocomplete\": \"autocompleteAttribute\", \"attr.role\": \"autocompleteDisabled ? null : \\\"combobox\\\"\", \"attr.aria-autocomplete\": \"autocompleteDisabled ? null : \\\"list\\\"\", \"attr.aria-activedescendant\": \"(panelOpen && activeOption) ? activeOption.id : null\", \"attr.aria-expanded\": \"autocompleteDisabled ? null : panelOpen.toString()\", \"attr.aria-controls\": \"(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id\", \"attr.aria-haspopup\": \"autocompleteDisabled ? null : \\\"listbox\\\"\" }, classAttribute: \"mat-mdc-autocomplete-trigger\" }, providers: [MAT_AUTOCOMPLETE_VALUE_ACCESSOR], exportAs: [\"matAutocompleteTrigger\"], usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteTrigger, decorators: [{\n type: Directive,\n args: [{\n selector: `input[matAutocomplete], textarea[matAutocomplete]`,\n host: {\n 'class': 'mat-mdc-autocomplete-trigger',\n '[attr.autocomplete]': 'autocompleteAttribute',\n '[attr.role]': 'autocompleteDisabled ? null : \"combobox\"',\n '[attr.aria-autocomplete]': 'autocompleteDisabled ? null : \"list\"',\n '[attr.aria-activedescendant]': '(panelOpen && activeOption) ? activeOption.id : null',\n '[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',\n '[attr.aria-controls]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',\n '[attr.aria-haspopup]': 'autocompleteDisabled ? null : \"listbox\"',\n // Note: we use `focusin`, as opposed to `focus`, in order to open the panel\n // a little earlier. This avoids issues where IE delays the focusing of the input.\n '(focusin)': '_handleFocus()',\n '(blur)': '_onTouched()',\n '(input)': '_handleInput($event)',\n '(keydown)': '_handleKeydown($event)',\n '(click)': '_handleClick()',\n },\n exportAs: 'matAutocompleteTrigger',\n providers: [MAT_AUTOCOMPLETE_VALUE_ACCESSOR],\n }]\n }], ctorParameters: () => [], propDecorators: { autocomplete: [{\n type: Input,\n args: ['matAutocomplete']\n }], position: [{\n type: Input,\n args: ['matAutocompletePosition']\n }], connectedTo: [{\n type: Input,\n args: ['matAutocompleteConnectedTo']\n }], autocompleteAttribute: [{\n type: Input,\n args: ['autocomplete']\n }], autocompleteDisabled: [{\n type: Input,\n args: [{ alias: 'matAutocompleteDisabled', transform: booleanAttribute }]\n }] } });\n\nclass MatAutocompleteModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteModule, imports: [OverlayModule,\n MatOptionModule,\n MatCommonModule,\n MatAutocomplete,\n MatAutocompleteTrigger,\n MatAutocompleteOrigin], exports: [CdkScrollableModule,\n MatAutocomplete,\n MatOptionModule,\n MatCommonModule,\n MatAutocompleteTrigger,\n MatAutocompleteOrigin] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteModule, providers: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER], imports: [OverlayModule,\n MatOptionModule,\n MatCommonModule, CdkScrollableModule,\n MatOptionModule,\n MatCommonModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatAutocompleteModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [\n OverlayModule,\n MatOptionModule,\n MatCommonModule,\n MatAutocomplete,\n MatAutocompleteTrigger,\n MatAutocompleteOrigin,\n ],\n exports: [\n CdkScrollableModule,\n MatAutocomplete,\n MatOptionModule,\n MatCommonModule,\n MatAutocompleteTrigger,\n MatAutocompleteOrigin,\n ],\n providers: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY, MAT_AUTOCOMPLETE_SCROLL_STRATEGY, MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY, MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER, MAT_AUTOCOMPLETE_VALUE_ACCESSOR, MatAutocomplete, MatAutocompleteModule, MatAutocompleteOrigin, MatAutocompleteSelectedEvent, MatAutocompleteTrigger, getMatAutocompleteMissingPanelError };\n","import * as i0 from '@angular/core';\nimport { Component, ViewEncapsulation, ChangeDetectionStrategy, inject, NgZone, ElementRef, Renderer2, ANIMATION_MODULE_TYPE, booleanAttribute, Directive, Input, NgModule } from '@angular/core';\nimport { MatCommonModule } from '@angular/material/core';\nimport { AriaDescriber, _IdGenerator, InteractivityChecker, A11yModule } from '@angular/cdk/a11y';\nimport { DOCUMENT } from '@angular/common';\nimport { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from '@angular/cdk/private';\n\nconst BADGE_CONTENT_CLASS = 'mat-badge-content';\n/**\n * Component used to load the structural styles of the badge.\n * @docs-private\n */\nclass _MatBadgeStyleLoader {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _MatBadgeStyleLoader, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"14.0.0\", version: \"19.0.0\", type: _MatBadgeStyleLoader, isStandalone: true, selector: \"ng-component\", ngImport: i0, template: '', isInline: true, styles: [\".mat-badge{position:relative}.mat-badge.mat-badge{overflow:visible}.mat-badge-content{position:absolute;text-align:center;display:inline-block;transition:transform 200ms ease-in-out;transform:scale(0.6);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;box-sizing:border-box;pointer-events:none;background-color:var(--mat-badge-background-color, var(--mat-sys-error));color:var(--mat-badge-text-color, var(--mat-sys-on-error));font-family:var(--mat-badge-text-font, var(--mat-sys-label-small-font));font-weight:var(--mat-badge-text-weight, var(--mat-sys-label-small-weight));border-radius:var(--mat-badge-container-shape, var(--mat-sys-corner-full))}.mat-badge-above .mat-badge-content{bottom:100%}.mat-badge-below .mat-badge-content{top:100%}.mat-badge-before .mat-badge-content{right:100%}[dir=rtl] .mat-badge-before .mat-badge-content{right:auto;left:100%}.mat-badge-after .mat-badge-content{left:100%}[dir=rtl] .mat-badge-after .mat-badge-content{left:auto;right:100%}@media(forced-colors: active){.mat-badge-content{outline:solid 1px;border-radius:0}}.mat-badge-disabled .mat-badge-content{background-color:var(--mat-badge-disabled-state-background-color, color-mix(in srgb, var(--mat-sys-error) 38%, transparent));color:var(--mat-badge-disabled-state-text-color, var(--mat-sys-on-error))}.mat-badge-hidden .mat-badge-content{display:none}.ng-animate-disabled .mat-badge-content,.mat-badge-content._mat-animation-noopable{transition:none}.mat-badge-content.mat-badge-active{transform:none}.mat-badge-small .mat-badge-content{width:var(--mat-badge-legacy-small-size-container-size, unset);height:var(--mat-badge-legacy-small-size-container-size, unset);min-width:var(--mat-badge-small-size-container-size, 6px);min-height:var(--mat-badge-small-size-container-size, 6px);line-height:var(--mat-badge-small-size-line-height, 6px);padding:var(--mat-badge-small-size-container-padding, 0);font-size:var(--mat-badge-small-size-text-size, 0);margin:var(--mat-badge-small-size-container-offset, -6px 0)}.mat-badge-small.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-small-size-container-overlap-offset, -6px)}.mat-badge-medium .mat-badge-content{width:var(--mat-badge-legacy-container-size, unset);height:var(--mat-badge-legacy-container-size, unset);min-width:var(--mat-badge-container-size, 16px);min-height:var(--mat-badge-container-size, 16px);line-height:var(--mat-badge-line-height, 16px);padding:var(--mat-badge-container-padding, 0 4px);font-size:var(--mat-badge-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-container-offset, -12px 0)}.mat-badge-medium.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-container-overlap-offset, -12px)}.mat-badge-large .mat-badge-content{width:var(--mat-badge-legacy-large-size-container-size, unset);height:var(--mat-badge-legacy-large-size-container-size, unset);min-width:var(--mat-badge-large-size-container-size, 16px);min-height:var(--mat-badge-large-size-container-size, 16px);line-height:var(--mat-badge-large-size-line-height, 16px);padding:var(--mat-badge-large-size-container-padding, 0 4px);font-size:var(--mat-badge-large-size-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-large-size-container-offset, -12px 0)}.mat-badge-large.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-large-size-container-overlap-offset, -12px)}\"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _MatBadgeStyleLoader, decorators: [{\n type: Component,\n args: [{ encapsulation: ViewEncapsulation.None, template: '', changeDetection: ChangeDetectionStrategy.OnPush, styles: [\".mat-badge{position:relative}.mat-badge.mat-badge{overflow:visible}.mat-badge-content{position:absolute;text-align:center;display:inline-block;transition:transform 200ms ease-in-out;transform:scale(0.6);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;box-sizing:border-box;pointer-events:none;background-color:var(--mat-badge-background-color, var(--mat-sys-error));color:var(--mat-badge-text-color, var(--mat-sys-on-error));font-family:var(--mat-badge-text-font, var(--mat-sys-label-small-font));font-weight:var(--mat-badge-text-weight, var(--mat-sys-label-small-weight));border-radius:var(--mat-badge-container-shape, var(--mat-sys-corner-full))}.mat-badge-above .mat-badge-content{bottom:100%}.mat-badge-below .mat-badge-content{top:100%}.mat-badge-before .mat-badge-content{right:100%}[dir=rtl] .mat-badge-before .mat-badge-content{right:auto;left:100%}.mat-badge-after .mat-badge-content{left:100%}[dir=rtl] .mat-badge-after .mat-badge-content{left:auto;right:100%}@media(forced-colors: active){.mat-badge-content{outline:solid 1px;border-radius:0}}.mat-badge-disabled .mat-badge-content{background-color:var(--mat-badge-disabled-state-background-color, color-mix(in srgb, var(--mat-sys-error) 38%, transparent));color:var(--mat-badge-disabled-state-text-color, var(--mat-sys-on-error))}.mat-badge-hidden .mat-badge-content{display:none}.ng-animate-disabled .mat-badge-content,.mat-badge-content._mat-animation-noopable{transition:none}.mat-badge-content.mat-badge-active{transform:none}.mat-badge-small .mat-badge-content{width:var(--mat-badge-legacy-small-size-container-size, unset);height:var(--mat-badge-legacy-small-size-container-size, unset);min-width:var(--mat-badge-small-size-container-size, 6px);min-height:var(--mat-badge-small-size-container-size, 6px);line-height:var(--mat-badge-small-size-line-height, 6px);padding:var(--mat-badge-small-size-container-padding, 0);font-size:var(--mat-badge-small-size-text-size, 0);margin:var(--mat-badge-small-size-container-offset, -6px 0)}.mat-badge-small.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-small-size-container-overlap-offset, -6px)}.mat-badge-medium .mat-badge-content{width:var(--mat-badge-legacy-container-size, unset);height:var(--mat-badge-legacy-container-size, unset);min-width:var(--mat-badge-container-size, 16px);min-height:var(--mat-badge-container-size, 16px);line-height:var(--mat-badge-line-height, 16px);padding:var(--mat-badge-container-padding, 0 4px);font-size:var(--mat-badge-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-container-offset, -12px 0)}.mat-badge-medium.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-container-overlap-offset, -12px)}.mat-badge-large .mat-badge-content{width:var(--mat-badge-legacy-large-size-container-size, unset);height:var(--mat-badge-legacy-large-size-container-size, unset);min-width:var(--mat-badge-large-size-container-size, 16px);min-height:var(--mat-badge-large-size-container-size, 16px);line-height:var(--mat-badge-large-size-line-height, 16px);padding:var(--mat-badge-large-size-container-padding, 0 4px);font-size:var(--mat-badge-large-size-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-large-size-container-offset, -12px 0)}.mat-badge-large.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-large-size-container-overlap-offset, -12px)}\"] }]\n }] });\n/** Directive to display a text badge. */\nclass MatBadge {\n _ngZone = inject(NgZone);\n _elementRef = inject(ElementRef);\n _ariaDescriber = inject(AriaDescriber);\n _renderer = inject(Renderer2);\n _animationMode = inject(ANIMATION_MODULE_TYPE, { optional: true });\n _idGenerator = inject(_IdGenerator);\n /**\n * Theme color of the badge. This API is supported in M2 themes only, it\n * has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/badge/styling.\n *\n * For information on applying color variants in M3, see\n * https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants\n */\n get color() {\n return this._color;\n }\n set color(value) {\n this._setColor(value);\n this._color = value;\n }\n _color = 'primary';\n /** Whether the badge should overlap its contents or not */\n overlap = true;\n /** Whether the badge is disabled. */\n disabled;\n /**\n * Position the badge should reside.\n * Accepts any combination of 'above'|'below' and 'before'|'after'\n */\n position = 'above after';\n /** The content for the badge */\n get content() {\n return this._content;\n }\n set content(newContent) {\n this._updateRenderedContent(newContent);\n }\n _content;\n /** Message used to describe the decorated element via aria-describedby */\n get description() {\n return this._description;\n }\n set description(newDescription) {\n this._updateDescription(newDescription);\n }\n _description;\n /** Size of the badge. Can be 'small', 'medium', or 'large'. */\n size = 'medium';\n /** Whether the badge is hidden. */\n hidden;\n /** Visible badge element. */\n _badgeElement;\n /** Inline badge description. Used when the badge is applied to non-interactive host elements. */\n _inlineBadgeDescription;\n /** Whether the OnInit lifecycle hook has run yet */\n _isInitialized = false;\n /** InteractivityChecker to determine if the badge host is focusable. */\n _interactivityChecker = inject(InteractivityChecker);\n _document = inject(DOCUMENT);\n constructor() {\n inject(_CdkPrivateStyleLoader).load(_MatBadgeStyleLoader);\n inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const nativeElement = this._elementRef.nativeElement;\n if (nativeElement.nodeType !== nativeElement.ELEMENT_NODE) {\n throw Error('matBadge must be attached to an element node.');\n }\n // Heads-up for developers to avoid putting matBadge on \n // as it is aria-hidden by default docs mention this at:\n // https://material.angular.io/components/badge/overview#accessibility\n if (nativeElement.tagName.toLowerCase() === 'mat-icon' &&\n nativeElement.getAttribute('aria-hidden') === 'true') {\n console.warn(`Detected a matBadge on an \"aria-hidden\" \"\". ` +\n `Consider setting aria-hidden=\"false\" in order to surface the information assistive technology.` +\n `\\n${nativeElement.outerHTML}`);\n }\n }\n }\n /** Whether the badge is above the host or not */\n isAbove() {\n return this.position.indexOf('below') === -1;\n }\n /** Whether the badge is after the host or not */\n isAfter() {\n return this.position.indexOf('before') === -1;\n }\n /**\n * Gets the element into which the badge's content is being rendered. Undefined if the element\n * hasn't been created (e.g. if the badge doesn't have content).\n */\n getBadgeElement() {\n return this._badgeElement;\n }\n ngOnInit() {\n // We may have server-side rendered badge that we need to clear.\n // We need to do this in ngOnInit because the full content of the component\n // on which the badge is attached won't necessarily be in the DOM until this point.\n this._clearExistingBadges();\n if (this.content && !this._badgeElement) {\n this._badgeElement = this._createBadgeElement();\n this._updateRenderedContent(this.content);\n }\n this._isInitialized = true;\n }\n ngOnDestroy() {\n // ViewEngine only: when creating a badge through the Renderer, Angular remembers its index.\n // We have to destroy it ourselves, otherwise it'll be retained in memory.\n if (this._renderer.destroyNode) {\n this._renderer.destroyNode(this._badgeElement);\n this._inlineBadgeDescription?.remove();\n }\n this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this.description);\n }\n /** Gets whether the badge's host element is interactive. */\n _isHostInteractive() {\n // Ignore visibility since it requires an expensive style caluclation.\n return this._interactivityChecker.isFocusable(this._elementRef.nativeElement, {\n ignoreVisibility: true,\n });\n }\n /** Creates the badge element */\n _createBadgeElement() {\n const badgeElement = this._renderer.createElement('span');\n const activeClass = 'mat-badge-active';\n badgeElement.setAttribute('id', this._idGenerator.getId('mat-badge-content-'));\n // The badge is aria-hidden because we don't want it to appear in the page's navigation\n // flow. Instead, we use the badge to describe the decorated element with aria-describedby.\n badgeElement.setAttribute('aria-hidden', 'true');\n badgeElement.classList.add(BADGE_CONTENT_CLASS);\n if (this._animationMode === 'NoopAnimations') {\n badgeElement.classList.add('_mat-animation-noopable');\n }\n this._elementRef.nativeElement.appendChild(badgeElement);\n // animate in after insertion\n if (typeof requestAnimationFrame === 'function' && this._animationMode !== 'NoopAnimations') {\n this._ngZone.runOutsideAngular(() => {\n requestAnimationFrame(() => {\n badgeElement.classList.add(activeClass);\n });\n });\n }\n else {\n badgeElement.classList.add(activeClass);\n }\n return badgeElement;\n }\n /** Update the text content of the badge element in the DOM, creating the element if necessary. */\n _updateRenderedContent(newContent) {\n const newContentNormalized = `${newContent ?? ''}`.trim();\n // Don't create the badge element if the directive isn't initialized because we want to\n // append the badge element to the *end* of the host element's content for backwards\n // compatibility.\n if (this._isInitialized && newContentNormalized && !this._badgeElement) {\n this._badgeElement = this._createBadgeElement();\n }\n if (this._badgeElement) {\n this._badgeElement.textContent = newContentNormalized;\n }\n this._content = newContentNormalized;\n }\n /** Updates the host element's aria description via AriaDescriber. */\n _updateDescription(newDescription) {\n // Always start by removing the aria-describedby; we will add a new one if necessary.\n this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this.description);\n // NOTE: We only check whether the host is interactive here, which happens during\n // when then badge content changes. It is possible that the host changes\n // interactivity status separate from one of these. However, watching the interactivity\n // status of the host would require a `MutationObserver`, which is likely more code + overhead\n // than it's worth; from usages inside Google, we see that the vats majority of badges either\n // never change interactivity, or also set `matBadgeHidden` based on the same condition.\n if (!newDescription || this._isHostInteractive()) {\n this._removeInlineDescription();\n }\n this._description = newDescription;\n // We don't add `aria-describedby` for non-interactive hosts elements because we\n // instead insert the description inline.\n if (this._isHostInteractive()) {\n this._ariaDescriber.describe(this._elementRef.nativeElement, newDescription);\n }\n else {\n this._updateInlineDescription();\n }\n }\n _updateInlineDescription() {\n // Create the inline description element if it doesn't exist\n if (!this._inlineBadgeDescription) {\n this._inlineBadgeDescription = this._document.createElement('span');\n this._inlineBadgeDescription.classList.add('cdk-visually-hidden');\n }\n this._inlineBadgeDescription.textContent = this.description;\n this._badgeElement?.appendChild(this._inlineBadgeDescription);\n }\n _removeInlineDescription() {\n this._inlineBadgeDescription?.remove();\n this._inlineBadgeDescription = undefined;\n }\n /** Adds css theme class given the color to the component host */\n _setColor(colorPalette) {\n const classList = this._elementRef.nativeElement.classList;\n classList.remove(`mat-badge-${this._color}`);\n if (colorPalette) {\n classList.add(`mat-badge-${colorPalette}`);\n }\n }\n /** Clears any existing badges that might be left over from server-side rendering. */\n _clearExistingBadges() {\n // Only check direct children of this host element in order to avoid deleting\n // any badges that might exist in descendant elements.\n const badges = this._elementRef.nativeElement.querySelectorAll(`:scope > .${BADGE_CONTENT_CLASS}`);\n for (const badgeElement of Array.from(badges)) {\n if (badgeElement !== this._badgeElement) {\n badgeElement.remove();\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatBadge, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: MatBadge, isStandalone: true, selector: \"[matBadge]\", inputs: { color: [\"matBadgeColor\", \"color\"], overlap: [\"matBadgeOverlap\", \"overlap\", booleanAttribute], disabled: [\"matBadgeDisabled\", \"disabled\", booleanAttribute], position: [\"matBadgePosition\", \"position\"], content: [\"matBadge\", \"content\"], description: [\"matBadgeDescription\", \"description\"], size: [\"matBadgeSize\", \"size\"], hidden: [\"matBadgeHidden\", \"hidden\", booleanAttribute] }, host: { properties: { \"class.mat-badge-overlap\": \"overlap\", \"class.mat-badge-above\": \"isAbove()\", \"class.mat-badge-below\": \"!isAbove()\", \"class.mat-badge-before\": \"!isAfter()\", \"class.mat-badge-after\": \"isAfter()\", \"class.mat-badge-small\": \"size === \\\"small\\\"\", \"class.mat-badge-medium\": \"size === \\\"medium\\\"\", \"class.mat-badge-large\": \"size === \\\"large\\\"\", \"class.mat-badge-hidden\": \"hidden || !content\", \"class.mat-badge-disabled\": \"disabled\" }, classAttribute: \"mat-badge\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatBadge, decorators: [{\n type: Directive,\n args: [{\n selector: '[matBadge]',\n host: {\n 'class': 'mat-badge',\n '[class.mat-badge-overlap]': 'overlap',\n '[class.mat-badge-above]': 'isAbove()',\n '[class.mat-badge-below]': '!isAbove()',\n '[class.mat-badge-before]': '!isAfter()',\n '[class.mat-badge-after]': 'isAfter()',\n '[class.mat-badge-small]': 'size === \"small\"',\n '[class.mat-badge-medium]': 'size === \"medium\"',\n '[class.mat-badge-large]': 'size === \"large\"',\n '[class.mat-badge-hidden]': 'hidden || !content',\n '[class.mat-badge-disabled]': 'disabled',\n },\n }]\n }], ctorParameters: () => [], propDecorators: { color: [{\n type: Input,\n args: ['matBadgeColor']\n }], overlap: [{\n type: Input,\n args: [{ alias: 'matBadgeOverlap', transform: booleanAttribute }]\n }], disabled: [{\n type: Input,\n args: [{ alias: 'matBadgeDisabled', transform: booleanAttribute }]\n }], position: [{\n type: Input,\n args: ['matBadgePosition']\n }], content: [{\n type: Input,\n args: ['matBadge']\n }], description: [{\n type: Input,\n args: ['matBadgeDescription']\n }], size: [{\n type: Input,\n args: ['matBadgeSize']\n }], hidden: [{\n type: Input,\n args: [{ alias: 'matBadgeHidden', transform: booleanAttribute }]\n }] } });\n\nclass MatBadgeModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatBadgeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: MatBadgeModule, imports: [A11yModule, MatCommonModule, MatBadge, _MatBadgeStyleLoader], exports: [MatBadge, MatCommonModule] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatBadgeModule, imports: [A11yModule, MatCommonModule, MatCommonModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatBadgeModule, decorators: [{\n type: NgModule,\n args: [{\n // Note: we _shouldn't_ have to import `_MatBadgeStyleLoader`,\n // but it seems to be necessary for tests.\n imports: [A11yModule, MatCommonModule, MatBadge, _MatBadgeStyleLoader],\n exports: [MatBadge, MatCommonModule],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { MatBadge, MatBadgeModule };\n","import { _IdGenerator, FocusMonitor } from '@angular/cdk/a11y';\nimport { SelectionModel } from '@angular/cdk/collections';\nimport { RIGHT_ARROW, DOWN_ARROW, LEFT_ARROW, UP_ARROW, ENTER, SPACE } from '@angular/cdk/keycodes';\nimport * as i0 from '@angular/core';\nimport { InjectionToken, forwardRef, inject, ChangeDetectorRef, EventEmitter, booleanAttribute, Directive, ContentChildren, Input, Output, ElementRef, ANIMATION_MODULE_TYPE, HostAttributeToken, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, NgModule } from '@angular/core';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { _StructuralStylesLoader, MatRipple, MatPseudoCheckbox, MatCommonModule, MatRippleModule } from '@angular/material/core';\nimport { _CdkPrivateStyleLoader } from '@angular/cdk/private';\n\n/**\n * Injection token that can be used to configure the\n * default options for all button toggles within an app.\n */\nconst MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS = new InjectionToken('MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS', {\n providedIn: 'root',\n factory: MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY,\n});\nfunction MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY() {\n return {\n hideSingleSelectionIndicator: false,\n hideMultipleSelectionIndicator: false,\n disabledInteractive: false,\n };\n}\n/**\n * Injection token that can be used to reference instances of `MatButtonToggleGroup`.\n * It serves as alternative token to the actual `MatButtonToggleGroup` class which\n * could cause unnecessary retention of the class and its component metadata.\n */\nconst MAT_BUTTON_TOGGLE_GROUP = new InjectionToken('MatButtonToggleGroup');\n/**\n * Provider Expression that allows mat-button-toggle-group to register as a ControlValueAccessor.\n * This allows it to support [(ngModel)].\n * @docs-private\n */\nconst MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => MatButtonToggleGroup),\n multi: true,\n};\n/** Change event object emitted by button toggle. */\nclass MatButtonToggleChange {\n source;\n value;\n constructor(\n /** The button toggle that emits the event. */\n source, \n /** The value assigned to the button toggle. */\n value) {\n this.source = source;\n this.value = value;\n }\n}\n/** Exclusive selection button toggle group that behaves like a radio-button group. */\nclass MatButtonToggleGroup {\n _changeDetector = inject(ChangeDetectorRef);\n _dir = inject(Directionality, { optional: true });\n _multiple = false;\n _disabled = false;\n _disabledInteractive = false;\n _selectionModel;\n /**\n * Reference to the raw value that the consumer tried to assign. The real\n * value will exclude any values from this one that don't correspond to a\n * toggle. Useful for the cases where the value is assigned before the toggles\n * have been initialized or at the same that they're being swapped out.\n */\n _rawValue;\n /**\n * The method to be called in order to update ngModel.\n * Now `ngModel` binding is not supported in multiple selection mode.\n */\n _controlValueAccessorChangeFn = () => { };\n /** onTouch function registered via registerOnTouch (ControlValueAccessor). */\n _onTouched = () => { };\n /** Child button toggle buttons. */\n _buttonToggles;\n /** The appearance for all the buttons in the group. */\n appearance;\n /** `name` attribute for the underlying `input` element. */\n get name() {\n return this._name;\n }\n set name(value) {\n this._name = value;\n this._markButtonsForCheck();\n }\n _name = inject(_IdGenerator).getId('mat-button-toggle-group-');\n /** Whether the toggle group is vertical. */\n vertical;\n /** Value of the toggle group. */\n get value() {\n const selected = this._selectionModel ? this._selectionModel.selected : [];\n if (this.multiple) {\n return selected.map(toggle => toggle.value);\n }\n return selected[0] ? selected[0].value : undefined;\n }\n set value(newValue) {\n this._setSelectionByValue(newValue);\n this.valueChange.emit(this.value);\n }\n /**\n * Event that emits whenever the value of the group changes.\n * Used to facilitate two-way data binding.\n * @docs-private\n */\n valueChange = new EventEmitter();\n /** Selected button toggles in the group. */\n get selected() {\n const selected = this._selectionModel ? this._selectionModel.selected : [];\n return this.multiple ? selected : selected[0] || null;\n }\n /** Whether multiple button toggles can be selected. */\n get multiple() {\n return this._multiple;\n }\n set multiple(value) {\n this._multiple = value;\n this._markButtonsForCheck();\n }\n /** Whether multiple button toggle group is disabled. */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n this._disabled = value;\n this._markButtonsForCheck();\n }\n /** Whether buttons in the group should be interactive while they're disabled. */\n get disabledInteractive() {\n return this._disabledInteractive;\n }\n set disabledInteractive(value) {\n this._disabledInteractive = value;\n this._markButtonsForCheck();\n }\n /** The layout direction of the toggle button group. */\n get dir() {\n return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';\n }\n /** Event emitted when the group's value changes. */\n change = new EventEmitter();\n /** Whether checkmark indicator for single-selection button toggle groups is hidden. */\n get hideSingleSelectionIndicator() {\n return this._hideSingleSelectionIndicator;\n }\n set hideSingleSelectionIndicator(value) {\n this._hideSingleSelectionIndicator = value;\n this._markButtonsForCheck();\n }\n _hideSingleSelectionIndicator;\n /** Whether checkmark indicator for multiple-selection button toggle groups is hidden. */\n get hideMultipleSelectionIndicator() {\n return this._hideMultipleSelectionIndicator;\n }\n set hideMultipleSelectionIndicator(value) {\n this._hideMultipleSelectionIndicator = value;\n this._markButtonsForCheck();\n }\n _hideMultipleSelectionIndicator;\n constructor() {\n const defaultOptions = inject(MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, { optional: true });\n this.appearance =\n defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard';\n this.hideSingleSelectionIndicator = defaultOptions?.hideSingleSelectionIndicator ?? false;\n this.hideMultipleSelectionIndicator = defaultOptions?.hideMultipleSelectionIndicator ?? false;\n }\n ngOnInit() {\n this._selectionModel = new SelectionModel(this.multiple, undefined, false);\n }\n ngAfterContentInit() {\n this._selectionModel.select(...this._buttonToggles.filter(toggle => toggle.checked));\n if (!this.multiple) {\n this._initializeTabIndex();\n }\n }\n /**\n * Sets the model value. Implemented as part of ControlValueAccessor.\n * @param value Value to be set to the model.\n */\n writeValue(value) {\n this.value = value;\n this._changeDetector.markForCheck();\n }\n // Implemented as part of ControlValueAccessor.\n registerOnChange(fn) {\n this._controlValueAccessorChangeFn = fn;\n }\n // Implemented as part of ControlValueAccessor.\n registerOnTouched(fn) {\n this._onTouched = fn;\n }\n // Implemented as part of ControlValueAccessor.\n setDisabledState(isDisabled) {\n this.disabled = isDisabled;\n }\n /** Handle keydown event calling to single-select button toggle. */\n _keydown(event) {\n if (this.multiple || this.disabled) {\n return;\n }\n const target = event.target;\n const buttonId = target.id;\n const index = this._buttonToggles.toArray().findIndex(toggle => {\n return toggle.buttonId === buttonId;\n });\n let nextButton = null;\n switch (event.keyCode) {\n case SPACE:\n case ENTER:\n nextButton = this._buttonToggles.get(index) || null;\n break;\n case UP_ARROW:\n nextButton = this._getNextButton(index, -1);\n break;\n case LEFT_ARROW:\n nextButton = this._getNextButton(index, this.dir === 'ltr' ? -1 : 1);\n break;\n case DOWN_ARROW:\n nextButton = this._getNextButton(index, 1);\n break;\n case RIGHT_ARROW:\n nextButton = this._getNextButton(index, this.dir === 'ltr' ? 1 : -1);\n break;\n default:\n return;\n }\n if (nextButton) {\n event.preventDefault();\n nextButton._onButtonClick();\n nextButton.focus();\n }\n }\n /** Dispatch change event with current selection and group value. */\n _emitChangeEvent(toggle) {\n const event = new MatButtonToggleChange(toggle, this.value);\n this._rawValue = event.value;\n this._controlValueAccessorChangeFn(event.value);\n this.change.emit(event);\n }\n /**\n * Syncs a button toggle's selected state with the model value.\n * @param toggle Toggle to be synced.\n * @param select Whether the toggle should be selected.\n * @param isUserInput Whether the change was a result of a user interaction.\n * @param deferEvents Whether to defer emitting the change events.\n */\n _syncButtonToggle(toggle, select, isUserInput = false, deferEvents = false) {\n // Deselect the currently-selected toggle, if we're in single-selection\n // mode and the button being toggled isn't selected at the moment.\n if (!this.multiple && this.selected && !toggle.checked) {\n this.selected.checked = false;\n }\n if (this._selectionModel) {\n if (select) {\n this._selectionModel.select(toggle);\n }\n else {\n this._selectionModel.deselect(toggle);\n }\n }\n else {\n deferEvents = true;\n }\n // We need to defer in some cases in order to avoid \"changed after checked errors\", however\n // the side-effect is that we may end up updating the model value out of sequence in others\n // The `deferEvents` flag allows us to decide whether to do it on a case-by-case basis.\n if (deferEvents) {\n Promise.resolve().then(() => this._updateModelValue(toggle, isUserInput));\n }\n else {\n this._updateModelValue(toggle, isUserInput);\n }\n }\n /** Checks whether a button toggle is selected. */\n _isSelected(toggle) {\n return this._selectionModel && this._selectionModel.isSelected(toggle);\n }\n /** Determines whether a button toggle should be checked on init. */\n _isPrechecked(toggle) {\n if (typeof this._rawValue === 'undefined') {\n return false;\n }\n if (this.multiple && Array.isArray(this._rawValue)) {\n return this._rawValue.some(value => toggle.value != null && value === toggle.value);\n }\n return toggle.value === this._rawValue;\n }\n /** Initializes the tabindex attribute using the radio pattern. */\n _initializeTabIndex() {\n this._buttonToggles.forEach(toggle => {\n toggle.tabIndex = -1;\n });\n if (this.selected) {\n this.selected.tabIndex = 0;\n }\n else {\n for (let i = 0; i < this._buttonToggles.length; i++) {\n const toggle = this._buttonToggles.get(i);\n if (!toggle.disabled) {\n toggle.tabIndex = 0;\n break;\n }\n }\n }\n this._markButtonsForCheck();\n }\n /** Obtain the subsequent toggle to which the focus shifts. */\n _getNextButton(startIndex, offset) {\n const items = this._buttonToggles;\n for (let i = 1; i <= items.length; i++) {\n const index = (startIndex + offset * i + items.length) % items.length;\n const item = items.get(index);\n if (item && !item.disabled) {\n return item;\n }\n }\n return null;\n }\n /** Updates the selection state of the toggles in the group based on a value. */\n _setSelectionByValue(value) {\n this._rawValue = value;\n if (!this._buttonToggles) {\n return;\n }\n const toggles = this._buttonToggles.toArray();\n if (this.multiple && value) {\n if (!Array.isArray(value) && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error('Value must be an array in multiple-selection mode.');\n }\n this._clearSelection();\n value.forEach((currentValue) => this._selectValue(currentValue, toggles));\n }\n else {\n this._clearSelection();\n this._selectValue(value, toggles);\n }\n // In single selection mode we need at least one enabled toggle to always be focusable.\n if (!this.multiple && toggles.every(toggle => toggle.tabIndex === -1)) {\n for (const toggle of toggles) {\n if (!toggle.disabled) {\n toggle.tabIndex = 0;\n break;\n }\n }\n }\n }\n /** Clears the selected toggles. */\n _clearSelection() {\n this._selectionModel.clear();\n this._buttonToggles.forEach(toggle => {\n toggle.checked = false;\n // If the button toggle is in single select mode, initialize the tabIndex.\n if (!this.multiple) {\n toggle.tabIndex = -1;\n }\n });\n }\n /** Selects a value if there's a toggle that corresponds to it. */\n _selectValue(value, toggles) {\n for (const toggle of toggles) {\n if (toggle.value != null && toggle.value === value) {\n toggle.checked = true;\n this._selectionModel.select(toggle);\n if (!this.multiple) {\n // If the button toggle is in single select mode, reset the tabIndex.\n toggle.tabIndex = 0;\n }\n break;\n }\n }\n }\n /** Syncs up the group's value with the model and emits the change event. */\n _updateModelValue(toggle, isUserInput) {\n // Only emit the change event for user input.\n if (isUserInput) {\n this._emitChangeEvent(toggle);\n }\n // Note: we emit this one no matter whether it was a user interaction, because\n // it is used by Angular to sync up the two-way data binding.\n this.valueChange.emit(this.value);\n }\n /** Marks all of the child button toggles to be checked. */\n _markButtonsForCheck() {\n this._buttonToggles?.forEach(toggle => toggle._markForCheck());\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggleGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: MatButtonToggleGroup, isStandalone: true, selector: \"mat-button-toggle-group\", inputs: { appearance: \"appearance\", name: \"name\", vertical: [\"vertical\", \"vertical\", booleanAttribute], value: \"value\", multiple: [\"multiple\", \"multiple\", booleanAttribute], disabled: [\"disabled\", \"disabled\", booleanAttribute], disabledInteractive: [\"disabledInteractive\", \"disabledInteractive\", booleanAttribute], hideSingleSelectionIndicator: [\"hideSingleSelectionIndicator\", \"hideSingleSelectionIndicator\", booleanAttribute], hideMultipleSelectionIndicator: [\"hideMultipleSelectionIndicator\", \"hideMultipleSelectionIndicator\", booleanAttribute] }, outputs: { valueChange: \"valueChange\", change: \"change\" }, host: { listeners: { \"keydown\": \"_keydown($event)\" }, properties: { \"attr.role\": \"multiple ? 'group' : 'radiogroup'\", \"attr.aria-disabled\": \"disabled\", \"class.mat-button-toggle-vertical\": \"vertical\", \"class.mat-button-toggle-group-appearance-standard\": \"appearance === \\\"standard\\\"\" }, classAttribute: \"mat-button-toggle-group\" }, providers: [\n MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR,\n { provide: MAT_BUTTON_TOGGLE_GROUP, useExisting: MatButtonToggleGroup },\n ], queries: [{ propertyName: \"_buttonToggles\", predicate: i0.forwardRef(() => MatButtonToggle), descendants: true }], exportAs: [\"matButtonToggleGroup\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggleGroup, decorators: [{\n type: Directive,\n args: [{\n selector: 'mat-button-toggle-group',\n providers: [\n MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR,\n { provide: MAT_BUTTON_TOGGLE_GROUP, useExisting: MatButtonToggleGroup },\n ],\n host: {\n 'class': 'mat-button-toggle-group',\n '(keydown)': '_keydown($event)',\n '[attr.role]': \"multiple ? 'group' : 'radiogroup'\",\n '[attr.aria-disabled]': 'disabled',\n '[class.mat-button-toggle-vertical]': 'vertical',\n '[class.mat-button-toggle-group-appearance-standard]': 'appearance === \"standard\"',\n },\n exportAs: 'matButtonToggleGroup',\n }]\n }], ctorParameters: () => [], propDecorators: { _buttonToggles: [{\n type: ContentChildren,\n args: [forwardRef(() => MatButtonToggle), {\n // Note that this would technically pick up toggles\n // from nested groups, but that's not a case that we support.\n descendants: true,\n }]\n }], appearance: [{\n type: Input\n }], name: [{\n type: Input\n }], vertical: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], value: [{\n type: Input\n }], valueChange: [{\n type: Output\n }], multiple: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], disabled: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], disabledInteractive: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], change: [{\n type: Output\n }], hideSingleSelectionIndicator: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], hideMultipleSelectionIndicator: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }] } });\n/** Single button inside of a toggle group. */\nclass MatButtonToggle {\n _changeDetectorRef = inject(ChangeDetectorRef);\n _elementRef = inject(ElementRef);\n _focusMonitor = inject(FocusMonitor);\n _idGenerator = inject(_IdGenerator);\n _animationMode = inject(ANIMATION_MODULE_TYPE, { optional: true });\n _checked = false;\n /**\n * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will\n * take precedence so this may be omitted.\n */\n ariaLabel;\n /**\n * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element\n */\n ariaLabelledby = null;\n /** Underlying native `button` element. */\n _buttonElement;\n /** The parent button toggle group (exclusive selection). Optional. */\n buttonToggleGroup;\n /** Unique ID for the underlying `button` element. */\n get buttonId() {\n return `${this.id}-button`;\n }\n /** The unique ID for this button toggle. */\n id;\n /** HTML's 'name' attribute used to group radios for unique selection. */\n name;\n /** MatButtonToggleGroup reads this to assign its own value. */\n value;\n /** Tabindex of the toggle. */\n get tabIndex() {\n return this._tabIndex;\n }\n set tabIndex(value) {\n if (value !== this._tabIndex) {\n this._tabIndex = value;\n this._markForCheck();\n }\n }\n _tabIndex;\n /** Whether ripples are disabled on the button toggle. */\n disableRipple;\n /** The appearance style of the button. */\n get appearance() {\n return this.buttonToggleGroup ? this.buttonToggleGroup.appearance : this._appearance;\n }\n set appearance(value) {\n this._appearance = value;\n }\n _appearance;\n /** Whether the button is checked. */\n get checked() {\n return this.buttonToggleGroup ? this.buttonToggleGroup._isSelected(this) : this._checked;\n }\n set checked(value) {\n if (value !== this._checked) {\n this._checked = value;\n if (this.buttonToggleGroup) {\n this.buttonToggleGroup._syncButtonToggle(this, this._checked);\n }\n this._changeDetectorRef.markForCheck();\n }\n }\n /** Whether the button is disabled. */\n get disabled() {\n return this._disabled || (this.buttonToggleGroup && this.buttonToggleGroup.disabled);\n }\n set disabled(value) {\n this._disabled = value;\n }\n _disabled = false;\n /** Whether the button should remain interactive when it is disabled. */\n get disabledInteractive() {\n return (this._disabledInteractive ||\n (this.buttonToggleGroup !== null && this.buttonToggleGroup.disabledInteractive));\n }\n set disabledInteractive(value) {\n this._disabledInteractive = value;\n }\n _disabledInteractive;\n /** Event emitted when the group value changes. */\n change = new EventEmitter();\n constructor() {\n inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);\n const toggleGroup = inject(MAT_BUTTON_TOGGLE_GROUP, { optional: true });\n const defaultTabIndex = inject(new HostAttributeToken('tabindex'), { optional: true }) || '';\n const defaultOptions = inject(MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, { optional: true });\n this._tabIndex = parseInt(defaultTabIndex) || 0;\n this.buttonToggleGroup = toggleGroup;\n this.appearance =\n defaultOptions && defaultOptions.appearance ? defaultOptions.appearance : 'standard';\n this.disabledInteractive = defaultOptions?.disabledInteractive ?? false;\n }\n ngOnInit() {\n const group = this.buttonToggleGroup;\n this.id = this.id || this._idGenerator.getId('mat-button-toggle-');\n if (group) {\n if (group._isPrechecked(this)) {\n this.checked = true;\n }\n else if (group._isSelected(this) !== this._checked) {\n // As side effect of the circular dependency between the toggle group and the button,\n // we may end up in a state where the button is supposed to be checked on init, but it\n // isn't, because the checked value was assigned too early. This can happen when Ivy\n // assigns the static input value before the `ngOnInit` has run.\n group._syncButtonToggle(this, this._checked);\n }\n }\n }\n ngAfterViewInit() {\n // This serves two purposes:\n // 1. We don't want the animation to fire on the first render for pre-checked toggles so we\n // delay adding the class until the view is rendered.\n // 2. We don't want animation if the `NoopAnimationsModule` is provided.\n if (this._animationMode !== 'NoopAnimations') {\n this._elementRef.nativeElement.classList.add('mat-button-toggle-animations-enabled');\n }\n this._focusMonitor.monitor(this._elementRef, true);\n }\n ngOnDestroy() {\n const group = this.buttonToggleGroup;\n this._focusMonitor.stopMonitoring(this._elementRef);\n // Remove the toggle from the selection once it's destroyed. Needs to happen\n // on the next tick in order to avoid \"changed after checked\" errors.\n if (group && group._isSelected(this)) {\n group._syncButtonToggle(this, false, false, true);\n }\n }\n /** Focuses the button. */\n focus(options) {\n this._buttonElement.nativeElement.focus(options);\n }\n /** Checks the button toggle due to an interaction with the underlying native button. */\n _onButtonClick() {\n if (this.disabled) {\n return;\n }\n const newChecked = this.isSingleSelector() ? true : !this._checked;\n if (newChecked !== this._checked) {\n this._checked = newChecked;\n if (this.buttonToggleGroup) {\n this.buttonToggleGroup._syncButtonToggle(this, this._checked, true);\n this.buttonToggleGroup._onTouched();\n }\n }\n if (this.isSingleSelector()) {\n const focusable = this.buttonToggleGroup._buttonToggles.find(toggle => {\n return toggle.tabIndex === 0;\n });\n // Modify the tabindex attribute of the last focusable button toggle to -1.\n if (focusable) {\n focusable.tabIndex = -1;\n }\n // Modify the tabindex attribute of the presently selected button toggle to 0.\n this.tabIndex = 0;\n }\n // Emit a change event when it's the single selector\n this.change.emit(new MatButtonToggleChange(this, this.value));\n }\n /**\n * Marks the button toggle as needing checking for change detection.\n * This method is exposed because the parent button toggle group will directly\n * update bound properties of the radio button.\n */\n _markForCheck() {\n // When the group value changes, the button will not be notified.\n // Use `markForCheck` to explicit update button toggle's status.\n this._changeDetectorRef.markForCheck();\n }\n /** Gets the name that should be assigned to the inner DOM node. */\n _getButtonName() {\n if (this.isSingleSelector()) {\n return this.buttonToggleGroup.name;\n }\n return this.name || null;\n }\n /** Whether the toggle is in single selection mode. */\n isSingleSelector() {\n return this.buttonToggleGroup && !this.buttonToggleGroup.multiple;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggle, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"17.0.0\", version: \"19.0.0\", type: MatButtonToggle, isStandalone: true, selector: \"mat-button-toggle\", inputs: { ariaLabel: [\"aria-label\", \"ariaLabel\"], ariaLabelledby: [\"aria-labelledby\", \"ariaLabelledby\"], id: \"id\", name: \"name\", value: \"value\", tabIndex: \"tabIndex\", disableRipple: [\"disableRipple\", \"disableRipple\", booleanAttribute], appearance: \"appearance\", checked: [\"checked\", \"checked\", booleanAttribute], disabled: [\"disabled\", \"disabled\", booleanAttribute], disabledInteractive: [\"disabledInteractive\", \"disabledInteractive\", booleanAttribute] }, outputs: { change: \"change\" }, host: { attributes: { \"role\": \"presentation\" }, listeners: { \"focus\": \"focus()\" }, properties: { \"class.mat-button-toggle-standalone\": \"!buttonToggleGroup\", \"class.mat-button-toggle-checked\": \"checked\", \"class.mat-button-toggle-disabled\": \"disabled\", \"class.mat-button-toggle-disabled-interactive\": \"disabledInteractive\", \"class.mat-button-toggle-appearance-standard\": \"appearance === \\\"standard\\\"\", \"attr.aria-label\": \"null\", \"attr.aria-labelledby\": \"null\", \"attr.id\": \"id\", \"attr.name\": \"null\" }, classAttribute: \"mat-button-toggle\" }, viewQueries: [{ propertyName: \"_buttonElement\", first: true, predicate: [\"button\"], descendants: true }], exportAs: [\"matButtonToggle\"], ngImport: i0, template: \"\\n\\n\\n\\n\\n\", styles: [\".mat-button-toggle-standalone,.mat-button-toggle-group{position:relative;display:inline-flex;flex-direction:row;white-space:nowrap;overflow:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);transform:translateZ(0);border-radius:var(--mat-legacy-button-toggle-shape)}.mat-button-toggle-standalone:not([class*=mat-elevation-z]),.mat-button-toggle-group:not([class*=mat-elevation-z]){box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)}@media(forced-colors: active){.mat-button-toggle-standalone,.mat-button-toggle-group{outline:solid 1px}}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full));border:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard .mat-pseudo-checkbox,.mat-button-toggle-group-appearance-standard .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard:not([class*=mat-elevation-z]),.mat-button-toggle-group-appearance-standard:not([class*=mat-elevation-z]){box-shadow:none}@media(forced-colors: active){.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{outline:0}}.mat-button-toggle-vertical{flex-direction:column}.mat-button-toggle-vertical .mat-button-toggle-label-content{display:block}.mat-button-toggle{white-space:nowrap;position:relative;color:var(--mat-legacy-button-toggle-text-color);font-family:var(--mat-legacy-button-toggle-label-text-font);font-size:var(--mat-legacy-button-toggle-label-text-size);line-height:var(--mat-legacy-button-toggle-label-text-line-height);font-weight:var(--mat-legacy-button-toggle-label-text-weight);letter-spacing:var(--mat-legacy-button-toggle-label-text-tracking);--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-legacy-button-toggle-selected-state-text-color)}.mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-legacy-button-toggle-focus-state-layer-opacity)}.mat-button-toggle .mat-icon svg{vertical-align:top}.mat-button-toggle-checkbox-wrapper{display:inline-block;justify-content:flex-start;align-items:center;width:0;height:18px;line-height:18px;overflow:hidden;box-sizing:border-box;position:absolute;top:50%;left:16px;transform:translate3d(0, -50%, 0)}[dir=rtl] .mat-button-toggle-checkbox-wrapper{left:auto;right:16px}.mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:12px}[dir=rtl] .mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:auto;right:12px}.mat-button-toggle-checked .mat-button-toggle-checkbox-wrapper{width:18px}.mat-button-toggle-animations-enabled .mat-button-toggle-checkbox-wrapper{transition:width 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-checkbox-wrapper{transition:none}.mat-button-toggle-checked{color:var(--mat-legacy-button-toggle-selected-state-text-color);background-color:var(--mat-legacy-button-toggle-selected-state-background-color)}.mat-button-toggle-disabled{pointer-events:none;color:var(--mat-legacy-button-toggle-disabled-state-text-color);background-color:var(--mat-legacy-button-toggle-disabled-state-background-color);--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-legacy-button-toggle-disabled-state-text-color)}.mat-button-toggle-disabled.mat-button-toggle-checked{background-color:var(--mat-legacy-button-toggle-disabled-selected-state-background-color)}.mat-button-toggle-disabled-interactive{pointer-events:auto}.mat-button-toggle-appearance-standard{color:var(--mat-standard-button-toggle-text-color, var(--mat-sys-on-surface));background-color:var(--mat-standard-button-toggle-background-color, transparent);font-family:var(--mat-standard-button-toggle-label-text-font, var(--mat-sys-label-large-font));font-size:var(--mat-standard-button-toggle-label-text-size, var(--mat-sys-label-large-size));line-height:var(--mat-standard-button-toggle-label-text-line-height, var(--mat-sys-label-large-line-height));font-weight:var(--mat-standard-button-toggle-label-text-weight, var(--mat-sys-label-large-weight));letter-spacing:var(--mat-standard-button-toggle-label-text-tracking, var(--mat-sys-label-large-tracking))}.mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}[dir=rtl] .mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:none;border-top:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-appearance-standard.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container));background-color:var(--mat-standard-button-toggle-selected-state-background-color, var(--mat-sys-secondary-container))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled{color:var(--mat-standard-button-toggle-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-state-background-color, transparent)}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-selected-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) 12%, transparent))}.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{background-color:var(--mat-standard-button-toggle-state-layer-color, var(--mat-sys-on-surface))}.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-hover-state-layer-opacity, var(--mat-sys-hover-state-layer-opacity))}.mat-button-toggle-appearance-standard.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-focus-state-layer-opacity, var(--mat-sys-focus-state-layer-opacity))}@media(hover: none){.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{display:none}}.mat-button-toggle-label-content{-webkit-user-select:none;user-select:none;display:inline-block;padding:0 16px;line-height:var(--mat-legacy-button-toggle-height);position:relative}.mat-button-toggle-appearance-standard .mat-button-toggle-label-content{padding:0 12px;line-height:var(--mat-standard-button-toggle-height, 40px)}.mat-button-toggle-label-content>*{vertical-align:middle}.mat-button-toggle-focus-overlay{top:0;left:0;right:0;bottom:0;position:absolute;border-radius:inherit;pointer-events:none;opacity:0;background-color:var(--mat-legacy-button-toggle-state-layer-color)}@media(forced-colors: active){.mat-button-toggle-checked .mat-button-toggle-focus-overlay{border-bottom:solid 500px;opacity:.5;height:0}.mat-button-toggle-checked:hover .mat-button-toggle-focus-overlay{opacity:.6}.mat-button-toggle-checked.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{border-bottom:solid 500px}}.mat-button-toggle .mat-button-toggle-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}.mat-button-toggle-button{border:0;background:none;color:inherit;padding:0;margin:0;font:inherit;outline:none;width:100%;cursor:pointer}.mat-button-toggle-animations-enabled .mat-button-toggle-button{transition:padding 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-button{transition:none}.mat-button-toggle-disabled .mat-button-toggle-button{cursor:default}.mat-button-toggle-button::-moz-focus-inner{border:0}.mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:30px}[dir=rtl] .mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:0;padding-right:30px}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard{--mat-focus-indicator-border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full))}.mat-button-toggle-group-appearance-standard .mat-button-toggle:last-of-type .mat-button-toggle-button::before{border-top-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full));border-bottom-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full))}.mat-button-toggle-group-appearance-standard .mat-button-toggle:first-of-type .mat-button-toggle-button::before{border-top-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full));border-bottom-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full))}\"], dependencies: [{ kind: \"directive\", type: MatRipple, selector: \"[mat-ripple], [matRipple]\", inputs: [\"matRippleColor\", \"matRippleUnbounded\", \"matRippleCentered\", \"matRippleRadius\", \"matRippleAnimation\", \"matRippleDisabled\", \"matRippleTrigger\"], exportAs: [\"matRipple\"] }, { kind: \"component\", type: MatPseudoCheckbox, selector: \"mat-pseudo-checkbox\", inputs: [\"state\", \"disabled\", \"appearance\"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggle, decorators: [{\n type: Component,\n args: [{ selector: 'mat-button-toggle', encapsulation: ViewEncapsulation.None, exportAs: 'matButtonToggle', changeDetection: ChangeDetectionStrategy.OnPush, host: {\n '[class.mat-button-toggle-standalone]': '!buttonToggleGroup',\n '[class.mat-button-toggle-checked]': 'checked',\n '[class.mat-button-toggle-disabled]': 'disabled',\n '[class.mat-button-toggle-disabled-interactive]': 'disabledInteractive',\n '[class.mat-button-toggle-appearance-standard]': 'appearance === \"standard\"',\n 'class': 'mat-button-toggle',\n '[attr.aria-label]': 'null',\n '[attr.aria-labelledby]': 'null',\n '[attr.id]': 'id',\n '[attr.name]': 'null',\n '(focus)': 'focus()',\n 'role': 'presentation',\n }, imports: [MatRipple, MatPseudoCheckbox], template: \"\\n\\n\\n\\n\\n\", styles: [\".mat-button-toggle-standalone,.mat-button-toggle-group{position:relative;display:inline-flex;flex-direction:row;white-space:nowrap;overflow:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);transform:translateZ(0);border-radius:var(--mat-legacy-button-toggle-shape)}.mat-button-toggle-standalone:not([class*=mat-elevation-z]),.mat-button-toggle-group:not([class*=mat-elevation-z]){box-shadow:0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)}@media(forced-colors: active){.mat-button-toggle-standalone,.mat-button-toggle-group{outline:solid 1px}}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full));border:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard .mat-pseudo-checkbox,.mat-button-toggle-group-appearance-standard .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container))}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard:not([class*=mat-elevation-z]),.mat-button-toggle-group-appearance-standard:not([class*=mat-elevation-z]){box-shadow:none}@media(forced-colors: active){.mat-button-toggle-standalone.mat-button-toggle-appearance-standard,.mat-button-toggle-group-appearance-standard{outline:0}}.mat-button-toggle-vertical{flex-direction:column}.mat-button-toggle-vertical .mat-button-toggle-label-content{display:block}.mat-button-toggle{white-space:nowrap;position:relative;color:var(--mat-legacy-button-toggle-text-color);font-family:var(--mat-legacy-button-toggle-label-text-font);font-size:var(--mat-legacy-button-toggle-label-text-size);line-height:var(--mat-legacy-button-toggle-label-text-line-height);font-weight:var(--mat-legacy-button-toggle-label-text-weight);letter-spacing:var(--mat-legacy-button-toggle-label-text-tracking);--mat-minimal-pseudo-checkbox-selected-checkmark-color: var(--mat-legacy-button-toggle-selected-state-text-color)}.mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-legacy-button-toggle-focus-state-layer-opacity)}.mat-button-toggle .mat-icon svg{vertical-align:top}.mat-button-toggle-checkbox-wrapper{display:inline-block;justify-content:flex-start;align-items:center;width:0;height:18px;line-height:18px;overflow:hidden;box-sizing:border-box;position:absolute;top:50%;left:16px;transform:translate3d(0, -50%, 0)}[dir=rtl] .mat-button-toggle-checkbox-wrapper{left:auto;right:16px}.mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:12px}[dir=rtl] .mat-button-toggle-appearance-standard .mat-button-toggle-checkbox-wrapper{left:auto;right:12px}.mat-button-toggle-checked .mat-button-toggle-checkbox-wrapper{width:18px}.mat-button-toggle-animations-enabled .mat-button-toggle-checkbox-wrapper{transition:width 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-checkbox-wrapper{transition:none}.mat-button-toggle-checked{color:var(--mat-legacy-button-toggle-selected-state-text-color);background-color:var(--mat-legacy-button-toggle-selected-state-background-color)}.mat-button-toggle-disabled{pointer-events:none;color:var(--mat-legacy-button-toggle-disabled-state-text-color);background-color:var(--mat-legacy-button-toggle-disabled-state-background-color);--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-legacy-button-toggle-disabled-state-text-color)}.mat-button-toggle-disabled.mat-button-toggle-checked{background-color:var(--mat-legacy-button-toggle-disabled-selected-state-background-color)}.mat-button-toggle-disabled-interactive{pointer-events:auto}.mat-button-toggle-appearance-standard{color:var(--mat-standard-button-toggle-text-color, var(--mat-sys-on-surface));background-color:var(--mat-standard-button-toggle-background-color, transparent);font-family:var(--mat-standard-button-toggle-label-text-font, var(--mat-sys-label-large-font));font-size:var(--mat-standard-button-toggle-label-text-size, var(--mat-sys-label-large-size));line-height:var(--mat-standard-button-toggle-label-text-line-height, var(--mat-sys-label-large-line-height));font-weight:var(--mat-standard-button-toggle-label-text-weight, var(--mat-sys-label-large-weight));letter-spacing:var(--mat-standard-button-toggle-label-text-tracking, var(--mat-sys-label-large-tracking))}.mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}[dir=rtl] .mat-button-toggle-group-appearance-standard .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical .mat-button-toggle-appearance-standard+.mat-button-toggle-appearance-standard{border-left:none;border-right:none;border-top:solid 1px var(--mat-standard-button-toggle-divider-color, var(--mat-sys-outline))}.mat-button-toggle-appearance-standard.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-selected-state-text-color, var(--mat-sys-on-secondary-container));background-color:var(--mat-standard-button-toggle-selected-state-background-color, var(--mat-sys-secondary-container))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled{color:var(--mat-standard-button-toggle-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-state-background-color, transparent)}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled .mat-pseudo-checkbox{--mat-minimal-pseudo-checkbox-disabled-selected-checkmark-color: var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-button-toggle-appearance-standard.mat-button-toggle-disabled.mat-button-toggle-checked{color:var(--mat-standard-button-toggle-disabled-selected-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent));background-color:var(--mat-standard-button-toggle-disabled-selected-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) 12%, transparent))}.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{background-color:var(--mat-standard-button-toggle-state-layer-color, var(--mat-sys-on-surface))}.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-hover-state-layer-opacity, var(--mat-sys-hover-state-layer-opacity))}.mat-button-toggle-appearance-standard.cdk-keyboard-focused .mat-button-toggle-focus-overlay{opacity:var(--mat-standard-button-toggle-focus-state-layer-opacity, var(--mat-sys-focus-state-layer-opacity))}@media(hover: none){.mat-button-toggle-appearance-standard:hover .mat-button-toggle-focus-overlay{display:none}}.mat-button-toggle-label-content{-webkit-user-select:none;user-select:none;display:inline-block;padding:0 16px;line-height:var(--mat-legacy-button-toggle-height);position:relative}.mat-button-toggle-appearance-standard .mat-button-toggle-label-content{padding:0 12px;line-height:var(--mat-standard-button-toggle-height, 40px)}.mat-button-toggle-label-content>*{vertical-align:middle}.mat-button-toggle-focus-overlay{top:0;left:0;right:0;bottom:0;position:absolute;border-radius:inherit;pointer-events:none;opacity:0;background-color:var(--mat-legacy-button-toggle-state-layer-color)}@media(forced-colors: active){.mat-button-toggle-checked .mat-button-toggle-focus-overlay{border-bottom:solid 500px;opacity:.5;height:0}.mat-button-toggle-checked:hover .mat-button-toggle-focus-overlay{opacity:.6}.mat-button-toggle-checked.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay{border-bottom:solid 500px}}.mat-button-toggle .mat-button-toggle-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}.mat-button-toggle-button{border:0;background:none;color:inherit;padding:0;margin:0;font:inherit;outline:none;width:100%;cursor:pointer}.mat-button-toggle-animations-enabled .mat-button-toggle-button{transition:padding 150ms 45ms cubic-bezier(0.4, 0, 0.2, 1)}.mat-button-toggle-vertical .mat-button-toggle-button{transition:none}.mat-button-toggle-disabled .mat-button-toggle-button{cursor:default}.mat-button-toggle-button::-moz-focus-inner{border:0}.mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:30px}[dir=rtl] .mat-button-toggle-checked .mat-button-toggle-button:has(.mat-button-toggle-checkbox-wrapper){padding-left:0;padding-right:30px}.mat-button-toggle-standalone.mat-button-toggle-appearance-standard{--mat-focus-indicator-border-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full))}.mat-button-toggle-group-appearance-standard .mat-button-toggle:last-of-type .mat-button-toggle-button::before{border-top-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full));border-bottom-right-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full))}.mat-button-toggle-group-appearance-standard .mat-button-toggle:first-of-type .mat-button-toggle-button::before{border-top-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full));border-bottom-left-radius:var(--mat-standard-button-toggle-shape, var(--mat-sys-corner-full))}\"] }]\n }], ctorParameters: () => [], propDecorators: { ariaLabel: [{\n type: Input,\n args: ['aria-label']\n }], ariaLabelledby: [{\n type: Input,\n args: ['aria-labelledby']\n }], _buttonElement: [{\n type: ViewChild,\n args: ['button']\n }], id: [{\n type: Input\n }], name: [{\n type: Input\n }], value: [{\n type: Input\n }], tabIndex: [{\n type: Input\n }], disableRipple: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], appearance: [{\n type: Input\n }], checked: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], disabled: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], disabledInteractive: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], change: [{\n type: Output\n }] } });\n\nclass MatButtonToggleModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggleModule, imports: [MatCommonModule, MatRippleModule, MatButtonToggleGroup, MatButtonToggle], exports: [MatCommonModule, MatButtonToggleGroup, MatButtonToggle] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggleModule, imports: [MatCommonModule, MatRippleModule, MatButtonToggle, MatCommonModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatButtonToggleModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [MatCommonModule, MatRippleModule, MatButtonToggleGroup, MatButtonToggle],\n exports: [MatCommonModule, MatButtonToggleGroup, MatButtonToggle],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { MAT_BUTTON_TOGGLE_DEFAULT_OPTIONS, MAT_BUTTON_TOGGLE_GROUP, MAT_BUTTON_TOGGLE_GROUP_DEFAULT_OPTIONS_FACTORY, MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR, MatButtonToggle, MatButtonToggleChange, MatButtonToggleGroup, MatButtonToggleModule };\n","import * as i0 from '@angular/core';\nimport { InjectionToken, inject, ElementRef, NgZone, ChangeDetectorRef, Renderer2, ANIMATION_MODULE_TYPE, EventEmitter, numberAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, NgModule } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport { MatCommonModule } from '@angular/material/core';\n\n/** Injection token to be used to override the default options for `mat-progress-bar`. */\nconst MAT_PROGRESS_BAR_DEFAULT_OPTIONS = new InjectionToken('MAT_PROGRESS_BAR_DEFAULT_OPTIONS');\n/**\n * Injection token used to provide the current location to `MatProgressBar`.\n * Used to handle server-side rendering and to stub out during unit tests.\n * @docs-private\n */\nconst MAT_PROGRESS_BAR_LOCATION = new InjectionToken('mat-progress-bar-location', { providedIn: 'root', factory: MAT_PROGRESS_BAR_LOCATION_FACTORY });\n/** @docs-private */\nfunction MAT_PROGRESS_BAR_LOCATION_FACTORY() {\n const _document = inject(DOCUMENT);\n const _location = _document ? _document.location : null;\n return {\n // Note that this needs to be a function, rather than a property, because Angular\n // will only resolve it once, but we want the current path on each call.\n getPathname: () => (_location ? _location.pathname + _location.search : ''),\n };\n}\nclass MatProgressBar {\n _elementRef = inject(ElementRef);\n _ngZone = inject(NgZone);\n _changeDetectorRef = inject(ChangeDetectorRef);\n _renderer = inject(Renderer2);\n _cleanupTransitionEnd;\n _animationMode = inject(ANIMATION_MODULE_TYPE, { optional: true });\n constructor() {\n const defaults = inject(MAT_PROGRESS_BAR_DEFAULT_OPTIONS, {\n optional: true,\n });\n this._isNoopAnimation = this._animationMode === 'NoopAnimations';\n if (defaults) {\n if (defaults.color) {\n this.color = this._defaultColor = defaults.color;\n }\n this.mode = defaults.mode || this.mode;\n }\n }\n /** Flag that indicates whether NoopAnimations mode is set to true. */\n _isNoopAnimation = false;\n // TODO: should be typed as `ThemePalette` but internal apps pass in arbitrary strings.\n /**\n * Theme color of the progress bar. This API is supported in M2 themes only, it\n * has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/progress-bar/styling.\n *\n * For information on applying color variants in M3, see\n * https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants\n */\n get color() {\n return this._color || this._defaultColor;\n }\n set color(value) {\n this._color = value;\n }\n _color;\n _defaultColor = 'primary';\n /** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */\n get value() {\n return this._value;\n }\n set value(v) {\n this._value = clamp(v || 0);\n this._changeDetectorRef.markForCheck();\n }\n _value = 0;\n /** Buffer value of the progress bar. Defaults to zero. */\n get bufferValue() {\n return this._bufferValue || 0;\n }\n set bufferValue(v) {\n this._bufferValue = clamp(v || 0);\n this._changeDetectorRef.markForCheck();\n }\n _bufferValue = 0;\n /**\n * Event emitted when animation of the primary progress bar completes. This event will not\n * be emitted when animations are disabled, nor will it be emitted for modes with continuous\n * animations (indeterminate and query).\n */\n animationEnd = new EventEmitter();\n /**\n * Mode of the progress bar.\n *\n * Input must be one of these values: determinate, indeterminate, buffer, query, defaults to\n * 'determinate'.\n * Mirrored to mode attribute.\n */\n get mode() {\n return this._mode;\n }\n set mode(value) {\n // Note that we don't technically need a getter and a setter here,\n // but we use it to match the behavior of the existing mat-progress-bar.\n this._mode = value;\n this._changeDetectorRef.markForCheck();\n }\n _mode = 'determinate';\n ngAfterViewInit() {\n // Run outside angular so change detection didn't get triggered on every transition end\n // instead only on the animation that we care about (primary value bar's transitionend)\n this._ngZone.runOutsideAngular(() => {\n this._cleanupTransitionEnd = this._renderer.listen(this._elementRef.nativeElement, 'transitionend', this._transitionendHandler);\n });\n }\n ngOnDestroy() {\n this._cleanupTransitionEnd?.();\n }\n /** Gets the transform style that should be applied to the primary bar. */\n _getPrimaryBarTransform() {\n return `scaleX(${this._isIndeterminate() ? 1 : this.value / 100})`;\n }\n /** Gets the `flex-basis` value that should be applied to the buffer bar. */\n _getBufferBarFlexBasis() {\n return `${this.mode === 'buffer' ? this.bufferValue : 100}%`;\n }\n /** Returns whether the progress bar is indeterminate. */\n _isIndeterminate() {\n return this.mode === 'indeterminate' || this.mode === 'query';\n }\n /** Event handler for `transitionend` events. */\n _transitionendHandler = (event) => {\n if (this.animationEnd.observers.length === 0 ||\n !event.target ||\n !event.target.classList.contains('mdc-linear-progress__primary-bar')) {\n return;\n }\n if (this.mode === 'determinate' || this.mode === 'buffer') {\n this._ngZone.run(() => this.animationEnd.next({ value: this.value }));\n }\n };\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatProgressBar, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"17.0.0\", version: \"19.0.0\", type: MatProgressBar, isStandalone: true, selector: \"mat-progress-bar\", inputs: { color: \"color\", value: [\"value\", \"value\", numberAttribute], bufferValue: [\"bufferValue\", \"bufferValue\", numberAttribute], mode: \"mode\" }, outputs: { animationEnd: \"animationEnd\" }, host: { attributes: { \"role\": \"progressbar\", \"aria-valuemin\": \"0\", \"aria-valuemax\": \"100\", \"tabindex\": \"-1\" }, properties: { \"attr.aria-valuenow\": \"_isIndeterminate() ? null : value\", \"attr.mode\": \"mode\", \"class\": \"\\\"mat-\\\" + color\", \"class._mat-animation-noopable\": \"_isNoopAnimation\", \"class.mdc-linear-progress--animation-ready\": \"!_isNoopAnimation\", \"class.mdc-linear-progress--indeterminate\": \"_isIndeterminate()\" }, classAttribute: \"mat-mdc-progress-bar mdc-linear-progress\" }, exportAs: [\"matProgressBar\"], ngImport: i0, template: \"\\n
\\n
\\n \\n @if (mode === 'buffer') {\\n
\\n }\\n\\n\\n \\n\\n
\\n \\n
\\n\", styles: [\".mat-mdc-progress-bar{display:block;text-align:start}.mat-mdc-progress-bar[mode=query]{transform:scaleX(-1)}.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__buffer-dots,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__primary-bar,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__secondary-bar,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__bar-inner.mdc-linear-progress__bar-inner{animation:none}.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__primary-bar,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__buffer-bar{transition:transform 1ms}.mdc-linear-progress{position:relative;width:100%;transform:translateZ(0);outline:1px solid rgba(0,0,0,0);overflow-x:hidden;transition:opacity 250ms 0ms cubic-bezier(0.4, 0, 0.6, 1);height:max(var(--mdc-linear-progress-track-height, 4px),var(--mdc-linear-progress-active-indicator-height, 4px))}@media(forced-colors: active){.mdc-linear-progress{outline-color:CanvasText}}.mdc-linear-progress__bar{position:absolute;top:0;bottom:0;margin:auto 0;width:100%;animation:none;transform-origin:top left;transition:transform 250ms 0ms cubic-bezier(0.4, 0, 0.6, 1);height:var(--mdc-linear-progress-active-indicator-height, 4px)}.mdc-linear-progress--indeterminate .mdc-linear-progress__bar{transition:none}[dir=rtl] .mdc-linear-progress__bar{right:0;transform-origin:center right}.mdc-linear-progress__bar-inner{display:inline-block;position:absolute;width:100%;animation:none;border-top-style:solid;border-color:var(--mdc-linear-progress-active-indicator-color, var(--mat-sys-primary));border-top-width:var(--mdc-linear-progress-active-indicator-height, 4px)}.mdc-linear-progress__buffer{display:flex;position:absolute;top:0;bottom:0;margin:auto 0;width:100%;overflow:hidden;height:var(--mdc-linear-progress-track-height, 4px);border-radius:var(--mdc-linear-progress-track-shape, var(--mat-sys-corner-none))}.mdc-linear-progress__buffer-dots{-webkit-mask-image:url(\\\"data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' enable-background='new 0 0 5 2' xml:space='preserve' viewBox='0 0 5 2' preserveAspectRatio='xMinYMin slice'%3E%3Ccircle cx='1' cy='1' r='1'/%3E%3C/svg%3E\\\");mask-image:url(\\\"data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' enable-background='new 0 0 5 2' xml:space='preserve' viewBox='0 0 5 2' preserveAspectRatio='xMinYMin slice'%3E%3Ccircle cx='1' cy='1' r='1'/%3E%3C/svg%3E\\\");background-repeat:repeat-x;flex:auto;transform:rotate(180deg);animation:mdc-linear-progress-buffering 250ms infinite linear;background-color:var(--mdc-linear-progress-track-color, var(--mat-sys-surface-variant))}@media(forced-colors: active){.mdc-linear-progress__buffer-dots{background-color:ButtonBorder}}[dir=rtl] .mdc-linear-progress__buffer-dots{animation:mdc-linear-progress-buffering-reverse 250ms infinite linear;transform:rotate(0)}.mdc-linear-progress__buffer-bar{flex:0 1 100%;transition:flex-basis 250ms 0ms cubic-bezier(0.4, 0, 0.6, 1);background-color:var(--mdc-linear-progress-track-color, var(--mat-sys-surface-variant))}.mdc-linear-progress__primary-bar{transform:scaleX(0)}.mdc-linear-progress--indeterminate .mdc-linear-progress__primary-bar{left:-145.166611%}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__primary-bar{animation:mdc-linear-progress-primary-indeterminate-translate 2s infinite linear}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__primary-bar>.mdc-linear-progress__bar-inner{animation:mdc-linear-progress-primary-indeterminate-scale 2s infinite linear}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--animation-ready .mdc-linear-progress__primary-bar{animation-name:mdc-linear-progress-primary-indeterminate-translate-reverse}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--indeterminate .mdc-linear-progress__primary-bar{right:-145.166611%;left:auto}.mdc-linear-progress__secondary-bar{display:none}.mdc-linear-progress--indeterminate .mdc-linear-progress__secondary-bar{left:-54.888891%;display:block}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__secondary-bar{animation:mdc-linear-progress-secondary-indeterminate-translate 2s infinite linear}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__secondary-bar>.mdc-linear-progress__bar-inner{animation:mdc-linear-progress-secondary-indeterminate-scale 2s infinite linear}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--animation-ready .mdc-linear-progress__secondary-bar{animation-name:mdc-linear-progress-secondary-indeterminate-translate-reverse}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--indeterminate .mdc-linear-progress__secondary-bar{right:-54.888891%;left:auto}@keyframes mdc-linear-progress-buffering{from{transform:rotate(180deg) translateX(calc(var(--mdc-linear-progress-track-height, 4px) * -2.5))}}@keyframes mdc-linear-progress-primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes mdc-linear-progress-primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes mdc-linear-progress-secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes mdc-linear-progress-secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes mdc-linear-progress-primary-indeterminate-translate-reverse{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(-83.67142%)}100%{transform:translateX(-200.611057%)}}@keyframes mdc-linear-progress-secondary-indeterminate-translate-reverse{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(-37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(-84.386165%)}100%{transform:translateX(-160.277782%)}}@keyframes mdc-linear-progress-buffering-reverse{from{transform:translateX(-10px)}}\"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatProgressBar, decorators: [{\n type: Component,\n args: [{ selector: 'mat-progress-bar', exportAs: 'matProgressBar', host: {\n 'role': 'progressbar',\n 'aria-valuemin': '0',\n 'aria-valuemax': '100',\n // set tab index to -1 so screen readers will read the aria-label\n // Note: there is a known issue with JAWS that does not read progressbar aria labels on FireFox\n 'tabindex': '-1',\n '[attr.aria-valuenow]': '_isIndeterminate() ? null : value',\n '[attr.mode]': 'mode',\n 'class': 'mat-mdc-progress-bar mdc-linear-progress',\n '[class]': '\"mat-\" + color',\n '[class._mat-animation-noopable]': '_isNoopAnimation',\n '[class.mdc-linear-progress--animation-ready]': '!_isNoopAnimation',\n '[class.mdc-linear-progress--indeterminate]': '_isIndeterminate()',\n }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: \"\\n
\\n
\\n \\n @if (mode === 'buffer') {\\n
\\n }\\n\\n\\n \\n\\n
\\n \\n
\\n\", styles: [\".mat-mdc-progress-bar{display:block;text-align:start}.mat-mdc-progress-bar[mode=query]{transform:scaleX(-1)}.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__buffer-dots,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__primary-bar,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__secondary-bar,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__bar-inner.mdc-linear-progress__bar-inner{animation:none}.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__primary-bar,.mat-mdc-progress-bar._mat-animation-noopable .mdc-linear-progress__buffer-bar{transition:transform 1ms}.mdc-linear-progress{position:relative;width:100%;transform:translateZ(0);outline:1px solid rgba(0,0,0,0);overflow-x:hidden;transition:opacity 250ms 0ms cubic-bezier(0.4, 0, 0.6, 1);height:max(var(--mdc-linear-progress-track-height, 4px),var(--mdc-linear-progress-active-indicator-height, 4px))}@media(forced-colors: active){.mdc-linear-progress{outline-color:CanvasText}}.mdc-linear-progress__bar{position:absolute;top:0;bottom:0;margin:auto 0;width:100%;animation:none;transform-origin:top left;transition:transform 250ms 0ms cubic-bezier(0.4, 0, 0.6, 1);height:var(--mdc-linear-progress-active-indicator-height, 4px)}.mdc-linear-progress--indeterminate .mdc-linear-progress__bar{transition:none}[dir=rtl] .mdc-linear-progress__bar{right:0;transform-origin:center right}.mdc-linear-progress__bar-inner{display:inline-block;position:absolute;width:100%;animation:none;border-top-style:solid;border-color:var(--mdc-linear-progress-active-indicator-color, var(--mat-sys-primary));border-top-width:var(--mdc-linear-progress-active-indicator-height, 4px)}.mdc-linear-progress__buffer{display:flex;position:absolute;top:0;bottom:0;margin:auto 0;width:100%;overflow:hidden;height:var(--mdc-linear-progress-track-height, 4px);border-radius:var(--mdc-linear-progress-track-shape, var(--mat-sys-corner-none))}.mdc-linear-progress__buffer-dots{-webkit-mask-image:url(\\\"data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' enable-background='new 0 0 5 2' xml:space='preserve' viewBox='0 0 5 2' preserveAspectRatio='xMinYMin slice'%3E%3Ccircle cx='1' cy='1' r='1'/%3E%3C/svg%3E\\\");mask-image:url(\\\"data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' enable-background='new 0 0 5 2' xml:space='preserve' viewBox='0 0 5 2' preserveAspectRatio='xMinYMin slice'%3E%3Ccircle cx='1' cy='1' r='1'/%3E%3C/svg%3E\\\");background-repeat:repeat-x;flex:auto;transform:rotate(180deg);animation:mdc-linear-progress-buffering 250ms infinite linear;background-color:var(--mdc-linear-progress-track-color, var(--mat-sys-surface-variant))}@media(forced-colors: active){.mdc-linear-progress__buffer-dots{background-color:ButtonBorder}}[dir=rtl] .mdc-linear-progress__buffer-dots{animation:mdc-linear-progress-buffering-reverse 250ms infinite linear;transform:rotate(0)}.mdc-linear-progress__buffer-bar{flex:0 1 100%;transition:flex-basis 250ms 0ms cubic-bezier(0.4, 0, 0.6, 1);background-color:var(--mdc-linear-progress-track-color, var(--mat-sys-surface-variant))}.mdc-linear-progress__primary-bar{transform:scaleX(0)}.mdc-linear-progress--indeterminate .mdc-linear-progress__primary-bar{left:-145.166611%}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__primary-bar{animation:mdc-linear-progress-primary-indeterminate-translate 2s infinite linear}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__primary-bar>.mdc-linear-progress__bar-inner{animation:mdc-linear-progress-primary-indeterminate-scale 2s infinite linear}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--animation-ready .mdc-linear-progress__primary-bar{animation-name:mdc-linear-progress-primary-indeterminate-translate-reverse}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--indeterminate .mdc-linear-progress__primary-bar{right:-145.166611%;left:auto}.mdc-linear-progress__secondary-bar{display:none}.mdc-linear-progress--indeterminate .mdc-linear-progress__secondary-bar{left:-54.888891%;display:block}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__secondary-bar{animation:mdc-linear-progress-secondary-indeterminate-translate 2s infinite linear}.mdc-linear-progress--indeterminate.mdc-linear-progress--animation-ready .mdc-linear-progress__secondary-bar>.mdc-linear-progress__bar-inner{animation:mdc-linear-progress-secondary-indeterminate-scale 2s infinite linear}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--animation-ready .mdc-linear-progress__secondary-bar{animation-name:mdc-linear-progress-secondary-indeterminate-translate-reverse}[dir=rtl] .mdc-linear-progress.mdc-linear-progress--indeterminate .mdc-linear-progress__secondary-bar{right:-54.888891%;left:auto}@keyframes mdc-linear-progress-buffering{from{transform:rotate(180deg) translateX(calc(var(--mdc-linear-progress-track-height, 4px) * -2.5))}}@keyframes mdc-linear-progress-primary-indeterminate-translate{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(83.67142%)}100%{transform:translateX(200.611057%)}}@keyframes mdc-linear-progress-primary-indeterminate-scale{0%{transform:scaleX(0.08)}36.65%{animation-timing-function:cubic-bezier(0.334731, 0.12482, 0.785844, 1);transform:scaleX(0.08)}69.15%{animation-timing-function:cubic-bezier(0.06, 0.11, 0.6, 1);transform:scaleX(0.661479)}100%{transform:scaleX(0.08)}}@keyframes mdc-linear-progress-secondary-indeterminate-translate{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(84.386165%)}100%{transform:translateX(160.277782%)}}@keyframes mdc-linear-progress-secondary-indeterminate-scale{0%{animation-timing-function:cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);transform:scaleX(0.08)}19.15%{animation-timing-function:cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);transform:scaleX(0.457104)}44.15%{animation-timing-function:cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);transform:scaleX(0.72796)}100%{transform:scaleX(0.08)}}@keyframes mdc-linear-progress-primary-indeterminate-translate-reverse{0%{transform:translateX(0)}20%{animation-timing-function:cubic-bezier(0.5, 0, 0.701732, 0.495819);transform:translateX(0)}59.15%{animation-timing-function:cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);transform:translateX(-83.67142%)}100%{transform:translateX(-200.611057%)}}@keyframes mdc-linear-progress-secondary-indeterminate-translate-reverse{0%{animation-timing-function:cubic-bezier(0.15, 0, 0.515058, 0.409685);transform:translateX(0)}25%{animation-timing-function:cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);transform:translateX(-37.651913%)}48.35%{animation-timing-function:cubic-bezier(0.4, 0.627035, 0.6, 0.902026);transform:translateX(-84.386165%)}100%{transform:translateX(-160.277782%)}}@keyframes mdc-linear-progress-buffering-reverse{from{transform:translateX(-10px)}}\"] }]\n }], ctorParameters: () => [], propDecorators: { color: [{\n type: Input\n }], value: [{\n type: Input,\n args: [{ transform: numberAttribute }]\n }], bufferValue: [{\n type: Input,\n args: [{ transform: numberAttribute }]\n }], animationEnd: [{\n type: Output\n }], mode: [{\n type: Input\n }] } });\n/** Clamps a value to be between two numbers, by default 0 and 100. */\nfunction clamp(v, min = 0, max = 100) {\n return Math.max(min, Math.min(max, v));\n}\n\nclass MatProgressBarModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatProgressBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: MatProgressBarModule, imports: [MatProgressBar], exports: [MatProgressBar, MatCommonModule] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatProgressBarModule, imports: [MatCommonModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MatProgressBarModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [MatProgressBar],\n exports: [MatProgressBar, MatCommonModule],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { MAT_PROGRESS_BAR_DEFAULT_OPTIONS, MAT_PROGRESS_BAR_LOCATION, MAT_PROGRESS_BAR_LOCATION_FACTORY, MatProgressBar, MatProgressBarModule };\n","import { getClient } from './currentScopes.js';\nimport { DEBUG_BUILD } from './debug-build.js';\nimport { logger } from './utils-hoist/logger.js';\n\nconst installedIntegrations = [];\n\n/** Map of integrations assigned to a client */\n\n/**\n * Remove duplicates from the given array, preferring the last instance of any duplicate. Not guaranteed to\n * preserve the order of integrations in the array.\n *\n * @private\n */\nfunction filterDuplicates(integrations) {\n const integrationsByName = {};\n\n integrations.forEach((currentInstance) => {\n const { name } = currentInstance;\n\n const existingInstance = integrationsByName[name];\n\n // We want integrations later in the array to overwrite earlier ones of the same type, except that we never want a\n // default instance to overwrite an existing user instance\n if (existingInstance && !existingInstance.isDefaultInstance && currentInstance.isDefaultInstance) {\n return;\n }\n\n integrationsByName[name] = currentInstance;\n });\n\n return Object.values(integrationsByName);\n}\n\n/** Gets integrations to install */\nfunction getIntegrationsToSetup(options) {\n const defaultIntegrations = options.defaultIntegrations || [];\n const userIntegrations = options.integrations;\n\n // We flag default instances, so that later we can tell them apart from any user-created instances of the same class\n defaultIntegrations.forEach((integration) => {\n integration.isDefaultInstance = true;\n });\n\n let integrations;\n\n if (Array.isArray(userIntegrations)) {\n integrations = [...defaultIntegrations, ...userIntegrations];\n } else if (typeof userIntegrations === 'function') {\n const resolvedUserIntegrations = userIntegrations(defaultIntegrations);\n integrations = Array.isArray(resolvedUserIntegrations) ? resolvedUserIntegrations : [resolvedUserIntegrations];\n } else {\n integrations = defaultIntegrations;\n }\n\n const finalIntegrations = filterDuplicates(integrations);\n\n // The `Debug` integration prints copies of the `event` and `hint` which will be passed to `beforeSend` or\n // `beforeSendTransaction`. It therefore has to run after all other integrations, so that the changes of all event\n // processors will be reflected in the printed values. For lack of a more elegant way to guarantee that, we therefore\n // locate it and, assuming it exists, pop it out of its current spot and shove it onto the end of the array.\n const debugIndex = finalIntegrations.findIndex(integration => integration.name === 'Debug');\n if (debugIndex > -1) {\n const [debugInstance] = finalIntegrations.splice(debugIndex, 1) ;\n finalIntegrations.push(debugInstance);\n }\n\n return finalIntegrations;\n}\n\n/**\n * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default\n * integrations are added unless they were already provided before.\n * @param integrations array of integration instances\n * @param withDefault should enable default integrations\n */\nfunction setupIntegrations(client, integrations) {\n const integrationIndex = {};\n\n integrations.forEach(integration => {\n // guard against empty provided integrations\n if (integration) {\n setupIntegration(client, integration, integrationIndex);\n }\n });\n\n return integrationIndex;\n}\n\n/**\n * Execute the `afterAllSetup` hooks of the given integrations.\n */\nfunction afterSetupIntegrations(client, integrations) {\n for (const integration of integrations) {\n // guard against empty provided integrations\n if (integration && integration.afterAllSetup) {\n integration.afterAllSetup(client);\n }\n }\n}\n\n/** Setup a single integration. */\nfunction setupIntegration(client, integration, integrationIndex) {\n if (integrationIndex[integration.name]) {\n DEBUG_BUILD && logger.log(`Integration skipped because it was already installed: ${integration.name}`);\n return;\n }\n integrationIndex[integration.name] = integration;\n\n // `setupOnce` is only called the first time\n if (installedIntegrations.indexOf(integration.name) === -1 && typeof integration.setupOnce === 'function') {\n integration.setupOnce();\n installedIntegrations.push(integration.name);\n }\n\n // `setup` is run for each client\n if (integration.setup && typeof integration.setup === 'function') {\n integration.setup(client);\n }\n\n if (typeof integration.preprocessEvent === 'function') {\n const callback = integration.preprocessEvent.bind(integration) ;\n client.on('preprocessEvent', (event, hint) => callback(event, hint, client));\n }\n\n if (typeof integration.processEvent === 'function') {\n const callback = integration.processEvent.bind(integration) ;\n\n const processor = Object.assign((event, hint) => callback(event, hint, client), {\n id: integration.name,\n });\n\n client.addEventProcessor(processor);\n }\n\n DEBUG_BUILD && logger.log(`Integration installed: ${integration.name}`);\n}\n\n/** Add an integration to the current scope's client. */\nfunction addIntegration(integration) {\n const client = getClient();\n\n if (!client) {\n DEBUG_BUILD && logger.warn(`Cannot add integration \"${integration.name}\" because no SDK Client is available.`);\n return;\n }\n\n client.addIntegration(integration);\n}\n\n/**\n * Define an integration function that can be used to create an integration instance.\n * Note that this by design hides the implementation details of the integration, as they are considered internal.\n */\nfunction defineIntegration(fn) {\n return fn;\n}\n\nexport { addIntegration, afterSetupIntegrations, defineIntegration, getIntegrationsToSetup, installedIntegrations, setupIntegration, setupIntegrations };\n","import { DEBUG_BUILD } from '../debug-build.js';\nimport { defineIntegration } from '../integration.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { getEventDescription } from '../utils-hoist/misc.js';\nimport { stringMatchesSomePattern } from '../utils-hoist/string.js';\n\n// \"Script error.\" is hard coded into browsers for errors that it can't read.\n// this is the result of a script being pulled in from an external domain and CORS.\nconst DEFAULT_IGNORE_ERRORS = [\n /^Script error\\.?$/,\n /^Javascript error: Script error\\.? on line 0$/,\n /^ResizeObserver loop completed with undelivered notifications.$/, // The browser logs this when a ResizeObserver handler takes a bit longer. Usually this is not an actual issue though. It indicates slowness.\n /^Cannot redefine property: googletag$/, // This is thrown when google tag manager is used in combination with an ad blocker\n \"undefined is not an object (evaluating 'a.L')\", // Random error that happens but not actionable or noticeable to end-users.\n 'can\\'t redefine non-configurable property \"solana\"', // Probably a browser extension or custom browser (Brave) throwing this error\n \"vv().getRestrictions is not a function. (In 'vv().getRestrictions(1,a)', 'vv().getRestrictions' is undefined)\", // Error thrown by GTM, seemingly not affecting end-users\n \"Can't find variable: _AutofillCallbackHandler\", // Unactionable error in instagram webview https://developers.facebook.com/community/threads/320013549791141/\n /^Non-Error promise rejection captured with value: Object Not Found Matching Id:\\d+, MethodName:simulateEvent, ParamCount:\\d+$/, // unactionable error from CEFSharp, a .NET library that embeds chromium in .NET apps\n];\n\n/** Options for the InboundFilters integration */\n\nconst INTEGRATION_NAME = 'InboundFilters';\nconst _inboundFiltersIntegration = ((options = {}) => {\n return {\n name: INTEGRATION_NAME,\n processEvent(event, _hint, client) {\n const clientOptions = client.getOptions();\n const mergedOptions = _mergeOptions(options, clientOptions);\n return _shouldDropEvent(event, mergedOptions) ? null : event;\n },\n };\n}) ;\n\nconst inboundFiltersIntegration = defineIntegration(_inboundFiltersIntegration);\n\nfunction _mergeOptions(\n internalOptions = {},\n clientOptions = {},\n) {\n return {\n allowUrls: [...(internalOptions.allowUrls || []), ...(clientOptions.allowUrls || [])],\n denyUrls: [...(internalOptions.denyUrls || []), ...(clientOptions.denyUrls || [])],\n ignoreErrors: [\n ...(internalOptions.ignoreErrors || []),\n ...(clientOptions.ignoreErrors || []),\n ...(internalOptions.disableErrorDefaults ? [] : DEFAULT_IGNORE_ERRORS),\n ],\n ignoreTransactions: [...(internalOptions.ignoreTransactions || []), ...(clientOptions.ignoreTransactions || [])],\n ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true,\n };\n}\n\nfunction _shouldDropEvent(event, options) {\n if (options.ignoreInternal && _isSentryError(event)) {\n DEBUG_BUILD &&\n logger.warn(`Event dropped due to being internal Sentry Error.\\nEvent: ${getEventDescription(event)}`);\n return true;\n }\n if (_isIgnoredError(event, options.ignoreErrors)) {\n DEBUG_BUILD &&\n logger.warn(\n `Event dropped due to being matched by \\`ignoreErrors\\` option.\\nEvent: ${getEventDescription(event)}`,\n );\n return true;\n }\n if (_isUselessError(event)) {\n DEBUG_BUILD &&\n logger.warn(\n `Event dropped due to not having an error message, error type or stacktrace.\\nEvent: ${getEventDescription(\n event,\n )}`,\n );\n return true;\n }\n if (_isIgnoredTransaction(event, options.ignoreTransactions)) {\n DEBUG_BUILD &&\n logger.warn(\n `Event dropped due to being matched by \\`ignoreTransactions\\` option.\\nEvent: ${getEventDescription(event)}`,\n );\n return true;\n }\n if (_isDeniedUrl(event, options.denyUrls)) {\n DEBUG_BUILD &&\n logger.warn(\n `Event dropped due to being matched by \\`denyUrls\\` option.\\nEvent: ${getEventDescription(\n event,\n )}.\\nUrl: ${_getEventFilterUrl(event)}`,\n );\n return true;\n }\n if (!_isAllowedUrl(event, options.allowUrls)) {\n DEBUG_BUILD &&\n logger.warn(\n `Event dropped due to not being matched by \\`allowUrls\\` option.\\nEvent: ${getEventDescription(\n event,\n )}.\\nUrl: ${_getEventFilterUrl(event)}`,\n );\n return true;\n }\n return false;\n}\n\nfunction _isIgnoredError(event, ignoreErrors) {\n // If event.type, this is not an error\n if (event.type || !ignoreErrors || !ignoreErrors.length) {\n return false;\n }\n\n return _getPossibleEventMessages(event).some(message => stringMatchesSomePattern(message, ignoreErrors));\n}\n\nfunction _isIgnoredTransaction(event, ignoreTransactions) {\n if (event.type !== 'transaction' || !ignoreTransactions || !ignoreTransactions.length) {\n return false;\n }\n\n const name = event.transaction;\n return name ? stringMatchesSomePattern(name, ignoreTransactions) : false;\n}\n\nfunction _isDeniedUrl(event, denyUrls) {\n // TODO: Use Glob instead?\n if (!denyUrls || !denyUrls.length) {\n return false;\n }\n const url = _getEventFilterUrl(event);\n return !url ? false : stringMatchesSomePattern(url, denyUrls);\n}\n\nfunction _isAllowedUrl(event, allowUrls) {\n // TODO: Use Glob instead?\n if (!allowUrls || !allowUrls.length) {\n return true;\n }\n const url = _getEventFilterUrl(event);\n return !url ? true : stringMatchesSomePattern(url, allowUrls);\n}\n\nfunction _getPossibleEventMessages(event) {\n const possibleMessages = [];\n\n if (event.message) {\n possibleMessages.push(event.message);\n }\n\n let lastException;\n try {\n // @ts-expect-error Try catching to save bundle size\n lastException = event.exception.values[event.exception.values.length - 1];\n } catch (e) {\n // try catching to save bundle size checking existence of variables\n }\n\n if (lastException) {\n if (lastException.value) {\n possibleMessages.push(lastException.value);\n if (lastException.type) {\n possibleMessages.push(`${lastException.type}: ${lastException.value}`);\n }\n }\n }\n\n return possibleMessages;\n}\n\nfunction _isSentryError(event) {\n try {\n // @ts-expect-error can't be a sentry error if undefined\n return event.exception.values[0].type === 'SentryError';\n } catch (e) {\n // ignore\n }\n return false;\n}\n\nfunction _getLastValidUrl(frames = []) {\n for (let i = frames.length - 1; i >= 0; i--) {\n const frame = frames[i];\n\n if (frame && frame.filename !== '' && frame.filename !== '[native code]') {\n return frame.filename || null;\n }\n }\n\n return null;\n}\n\nfunction _getEventFilterUrl(event) {\n try {\n let frames;\n try {\n // @ts-expect-error we only care about frames if the whole thing here is defined\n frames = event.exception.values[0].stacktrace.frames;\n } catch (e) {\n // ignore\n }\n return frames ? _getLastValidUrl(frames) : null;\n } catch (oO) {\n DEBUG_BUILD && logger.error(`Cannot extract url for event ${getEventDescription(event)}`);\n return null;\n }\n}\n\nfunction _isUselessError(event) {\n if (event.type) {\n // event is not an error\n return false;\n }\n\n // We only want to consider events for dropping that actually have recorded exception values.\n if (!event.exception || !event.exception.values || event.exception.values.length === 0) {\n return false;\n }\n\n return (\n // No top-level message\n !event.message &&\n // There are no exception values that have a stacktrace, a non-generic-Error type or value\n !event.exception.values.some(value => value.stacktrace || (value.type && value.type !== 'Error') || value.value)\n );\n}\n\nexport { inboundFiltersIntegration };\n","import { getClient } from '../currentScopes.js';\nimport { defineIntegration } from '../integration.js';\nimport { getOriginalFunction } from '../utils-hoist/object.js';\n\nlet originalFunctionToString;\n\nconst INTEGRATION_NAME = 'FunctionToString';\n\nconst SETUP_CLIENTS = new WeakMap();\n\nconst _functionToStringIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n originalFunctionToString = Function.prototype.toString;\n\n // intrinsics (like Function.prototype) might be immutable in some environments\n // e.g. Node with --frozen-intrinsics, XS (an embedded JavaScript engine) or SES (a JavaScript proposal)\n try {\n Function.prototype.toString = function ( ...args) {\n const originalFunction = getOriginalFunction(this);\n const context =\n SETUP_CLIENTS.has(getClient() ) && originalFunction !== undefined ? originalFunction : this;\n return originalFunctionToString.apply(context, args);\n };\n } catch (e) {\n // ignore errors here, just don't patch this\n }\n },\n setup(client) {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) ;\n\n/**\n * Patch toString calls to return proper name for wrapped functions.\n *\n * ```js\n * Sentry.init({\n * integrations: [\n * functionToStringIntegration(),\n * ],\n * });\n * ```\n */\nconst functionToStringIntegration = defineIntegration(_functionToStringIntegration);\n\nexport { functionToStringIntegration };\n","import { defineIntegration } from '../integration.js';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { getFramesFromEvent } from '../utils-hoist/stacktrace.js';\n\nconst INTEGRATION_NAME = 'Dedupe';\n\nconst _dedupeIntegration = (() => {\n let previousEvent;\n\n return {\n name: INTEGRATION_NAME,\n processEvent(currentEvent) {\n // We want to ignore any non-error type events, e.g. transactions or replays\n // These should never be deduped, and also not be compared against as _previousEvent.\n if (currentEvent.type) {\n return currentEvent;\n }\n\n // Juuust in case something goes wrong\n try {\n if (_shouldDropEvent(currentEvent, previousEvent)) {\n DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.');\n return null;\n }\n } catch (_oO) {} // eslint-disable-line no-empty\n\n return (previousEvent = currentEvent);\n },\n };\n}) ;\n\n/**\n * Deduplication filter.\n */\nconst dedupeIntegration = defineIntegration(_dedupeIntegration);\n\n/** only exported for tests. */\nfunction _shouldDropEvent(currentEvent, previousEvent) {\n if (!previousEvent) {\n return false;\n }\n\n if (_isSameMessageEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n if (_isSameExceptionEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n return false;\n}\n\nfunction _isSameMessageEvent(currentEvent, previousEvent) {\n const currentMessage = currentEvent.message;\n const previousMessage = previousEvent.message;\n\n // If neither event has a message property, they were both exceptions, so bail out\n if (!currentMessage && !previousMessage) {\n return false;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) {\n return false;\n }\n\n if (currentMessage !== previousMessage) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\nfunction _isSameExceptionEvent(currentEvent, previousEvent) {\n const previousException = _getExceptionFromEvent(previousEvent);\n const currentException = _getExceptionFromEvent(currentEvent);\n\n if (!previousException || !currentException) {\n return false;\n }\n\n if (previousException.type !== currentException.type || previousException.value !== currentException.value) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\nfunction _isSameStacktrace(currentEvent, previousEvent) {\n let currentFrames = getFramesFromEvent(currentEvent);\n let previousFrames = getFramesFromEvent(previousEvent);\n\n // If neither event has a stacktrace, they are assumed to be the same\n if (!currentFrames && !previousFrames) {\n return true;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) {\n return false;\n }\n\n currentFrames = currentFrames ;\n previousFrames = previousFrames ;\n\n // If number of frames differ, they are not the same\n if (previousFrames.length !== currentFrames.length) {\n return false;\n }\n\n // Otherwise, compare the two\n for (let i = 0; i < previousFrames.length; i++) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const frameA = previousFrames[i];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const frameB = currentFrames[i];\n\n if (\n frameA.filename !== frameB.filename ||\n frameA.lineno !== frameB.lineno ||\n frameA.colno !== frameB.colno ||\n frameA.function !== frameB.function\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction _isSameFingerprint(currentEvent, previousEvent) {\n let currentFingerprint = currentEvent.fingerprint;\n let previousFingerprint = previousEvent.fingerprint;\n\n // If neither event has a fingerprint, they are assumed to be the same\n if (!currentFingerprint && !previousFingerprint) {\n return true;\n }\n\n // If only one event has a fingerprint, but not the other one, they are not the same\n if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) {\n return false;\n }\n\n currentFingerprint = currentFingerprint ;\n previousFingerprint = previousFingerprint ;\n\n // Otherwise, compare the two\n try {\n return !!(currentFingerprint.join('') === previousFingerprint.join(''));\n } catch (_oO) {\n return false;\n }\n}\n\nfunction _getExceptionFromEvent(event) {\n return event.exception && event.exception.values && event.exception.values[0];\n}\n\nexport { _shouldDropEvent, dedupeIntegration };\n","import { DEBUG_BUILD } from './debug-build.js';\nimport { logger } from './logger.js';\nimport { GLOBAL_OBJ } from './worldwide.js';\n\nconst WINDOW = GLOBAL_OBJ ;\n\n/**\n * Tells whether current environment supports ErrorEvent objects\n * {@link supportsErrorEvent}.\n *\n * @returns Answer to the given question.\n */\nfunction supportsErrorEvent() {\n try {\n new ErrorEvent('');\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * Tells whether current environment supports DOMError objects\n * {@link supportsDOMError}.\n *\n * @returns Answer to the given question.\n */\nfunction supportsDOMError() {\n try {\n // Chrome: VM89:1 Uncaught TypeError: Failed to construct 'DOMError':\n // 1 argument required, but only 0 present.\n // @ts-expect-error It really needs 1 argument, not 0.\n new DOMError('');\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * Tells whether current environment supports DOMException objects\n * {@link supportsDOMException}.\n *\n * @returns Answer to the given question.\n */\nfunction supportsDOMException() {\n try {\n new DOMException('');\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * Tells whether current environment supports Fetch API\n * {@link supportsFetch}.\n *\n * @returns Answer to the given question.\n */\nfunction supportsFetch() {\n if (!('fetch' in WINDOW)) {\n return false;\n }\n\n try {\n new Headers();\n new Request('http://www.example.com');\n new Response();\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * isNative checks if the given function is a native implementation\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nfunction isNativeFunction(func) {\n return func && /^function\\s+\\w+\\(\\)\\s+\\{\\s+\\[native code\\]\\s+\\}$/.test(func.toString());\n}\n\n/**\n * Tells whether current environment supports Fetch API natively\n * {@link supportsNativeFetch}.\n *\n * @returns true if `window.fetch` is natively implemented, false otherwise\n */\nfunction supportsNativeFetch() {\n if (typeof EdgeRuntime === 'string') {\n return true;\n }\n\n if (!supportsFetch()) {\n return false;\n }\n\n // Fast path to avoid DOM I/O\n // eslint-disable-next-line @typescript-eslint/unbound-method\n if (isNativeFunction(WINDOW.fetch)) {\n return true;\n }\n\n // window.fetch is implemented, but is polyfilled or already wrapped (e.g: by a chrome extension)\n // so create a \"pure\" iframe to see if that has native fetch\n let result = false;\n const doc = WINDOW.document;\n // eslint-disable-next-line deprecation/deprecation\n if (doc && typeof (doc.createElement ) === 'function') {\n try {\n const sandbox = doc.createElement('iframe');\n sandbox.hidden = true;\n doc.head.appendChild(sandbox);\n if (sandbox.contentWindow && sandbox.contentWindow.fetch) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n result = isNativeFunction(sandbox.contentWindow.fetch);\n }\n doc.head.removeChild(sandbox);\n } catch (err) {\n DEBUG_BUILD &&\n logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);\n }\n }\n\n return result;\n}\n\n/**\n * Tells whether current environment supports ReportingObserver API\n * {@link supportsReportingObserver}.\n *\n * @returns Answer to the given question.\n */\nfunction supportsReportingObserver() {\n return 'ReportingObserver' in WINDOW;\n}\n\n/**\n * Tells whether current environment supports Referrer Policy API\n * {@link supportsReferrerPolicy}.\n *\n * @returns Answer to the given question.\n */\nfunction supportsReferrerPolicy() {\n // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'\n // (see https://caniuse.com/#feat=referrer-policy),\n // it doesn't. And it throws an exception instead of ignoring this parameter...\n // REF: https://github.com/getsentry/raven-js/issues/1233\n\n if (!supportsFetch()) {\n return false;\n }\n\n try {\n new Request('_', {\n referrerPolicy: 'origin' ,\n });\n return true;\n } catch (e) {\n return false;\n }\n}\n\nexport { isNativeFunction, supportsDOMError, supportsDOMException, supportsErrorEvent, supportsFetch, supportsNativeFetch, supportsReferrerPolicy, supportsReportingObserver };\n","import { DEBUG_BUILD } from './debug-build.js';\nimport { consoleSandbox, logger } from './logger.js';\n\n/** Regular expression used to parse a Dsn. */\nconst DSN_REGEX = /^(?:(\\w+):)\\/\\/(?:(\\w+)(?::(\\w+)?)?@)([\\w.-]+)(?::(\\d+))?\\/(.+)/;\n\nfunction isValidProtocol(protocol) {\n return protocol === 'http' || protocol === 'https';\n}\n\n/**\n * Renders the string representation of this Dsn.\n *\n * By default, this will render the public representation without the password\n * component. To get the deprecated private representation, set `withPassword`\n * to true.\n *\n * @param withPassword When set to true, the password will be included.\n */\nfunction dsnToString(dsn, withPassword = false) {\n const { host, path, pass, port, projectId, protocol, publicKey } = dsn;\n return (\n `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ''}` +\n `@${host}${port ? `:${port}` : ''}/${path ? `${path}/` : path}${projectId}`\n );\n}\n\n/**\n * Parses a Dsn from a given string.\n *\n * @param str A Dsn as string\n * @returns Dsn as DsnComponents or undefined if @param str is not a valid DSN string\n */\nfunction dsnFromString(str) {\n const match = DSN_REGEX.exec(str);\n\n if (!match) {\n // This should be logged to the console\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.error(`Invalid Sentry Dsn: ${str}`);\n });\n return undefined;\n }\n\n const [protocol, publicKey, pass = '', host = '', port = '', lastPath = ''] = match.slice(1);\n let path = '';\n let projectId = lastPath;\n\n const split = projectId.split('/');\n if (split.length > 1) {\n path = split.slice(0, -1).join('/');\n projectId = split.pop() ;\n }\n\n if (projectId) {\n const projectMatch = projectId.match(/^\\d+/);\n if (projectMatch) {\n projectId = projectMatch[0];\n }\n }\n\n return dsnFromComponents({ host, pass, path, projectId, port, protocol: protocol , publicKey });\n}\n\nfunction dsnFromComponents(components) {\n return {\n protocol: components.protocol,\n publicKey: components.publicKey || '',\n pass: components.pass || '',\n host: components.host,\n port: components.port || '',\n path: components.path || '',\n projectId: components.projectId,\n };\n}\n\nfunction validateDsn(dsn) {\n if (!DEBUG_BUILD) {\n return true;\n }\n\n const { port, projectId, protocol } = dsn;\n\n const requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];\n const hasMissingRequiredComponent = requiredComponents.find(component => {\n if (!dsn[component]) {\n logger.error(`Invalid Sentry Dsn: ${component} missing`);\n return true;\n }\n return false;\n });\n\n if (hasMissingRequiredComponent) {\n return false;\n }\n\n if (!projectId.match(/^\\d+$/)) {\n logger.error(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);\n return false;\n }\n\n if (!isValidProtocol(protocol)) {\n logger.error(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);\n return false;\n }\n\n if (port && isNaN(parseInt(port, 10))) {\n logger.error(`Invalid Sentry Dsn: Invalid port ${port}`);\n return false;\n }\n\n return true;\n}\n\n/**\n * Creates a valid Sentry Dsn object, identifying a Sentry instance and project.\n * @returns a valid DsnComponents object or `undefined` if @param from is an invalid DSN source\n */\nfunction makeDsn(from) {\n const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);\n if (!components || !validateDsn(components)) {\n return undefined;\n }\n return components;\n}\n\nexport { dsnFromString, dsnToString, makeDsn };\n","import { makeDsn, dsnToString } from './utils-hoist/dsn.js';\n\nconst SENTRY_API_VERSION = '7';\n\n/** Returns the prefix to construct Sentry ingestion API endpoints. */\nfunction getBaseApiEndpoint(dsn) {\n const protocol = dsn.protocol ? `${dsn.protocol}:` : '';\n const port = dsn.port ? `:${dsn.port}` : '';\n return `${protocol}//${dsn.host}${port}${dsn.path ? `/${dsn.path}` : ''}/api/`;\n}\n\n/** Returns the ingest API endpoint for target. */\nfunction _getIngestEndpoint(dsn) {\n return `${getBaseApiEndpoint(dsn)}${dsn.projectId}/envelope/`;\n}\n\n/** Returns a URL-encoded string with auth config suitable for a query string. */\nfunction _encodedAuth(dsn, sdkInfo) {\n const params = {\n sentry_version: SENTRY_API_VERSION,\n };\n\n if (dsn.publicKey) {\n // We send only the minimum set of required information. See\n // https://github.com/getsentry/sentry-javascript/issues/2572.\n params.sentry_key = dsn.publicKey;\n }\n\n if (sdkInfo) {\n params.sentry_client = `${sdkInfo.name}/${sdkInfo.version}`;\n }\n\n return new URLSearchParams(params).toString();\n}\n\n/**\n * Returns the envelope endpoint URL with auth in the query string.\n *\n * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests.\n */\nfunction getEnvelopeEndpointWithUrlEncodedAuth(dsn, tunnel, sdkInfo) {\n return tunnel ? tunnel : `${_getIngestEndpoint(dsn)}?${_encodedAuth(dsn, sdkInfo)}`;\n}\n\n/** Returns the url to the report dialog endpoint. */\nfunction getReportDialogEndpoint(\n dsnLike,\n dialogOptions\n\n,\n) {\n const dsn = makeDsn(dsnLike);\n if (!dsn) {\n return '';\n }\n\n const endpoint = `${getBaseApiEndpoint(dsn)}embed/error-page/`;\n\n let encodedOptions = `dsn=${dsnToString(dsn)}`;\n for (const key in dialogOptions) {\n if (key === 'dsn') {\n continue;\n }\n\n if (key === 'onClose') {\n continue;\n }\n\n if (key === 'user') {\n const user = dialogOptions.user;\n if (!user) {\n continue;\n }\n if (user.name) {\n encodedOptions += `&name=${encodeURIComponent(user.name)}`;\n }\n if (user.email) {\n encodedOptions += `&email=${encodeURIComponent(user.email)}`;\n }\n } else {\n encodedOptions += `&${encodeURIComponent(key)}=${encodeURIComponent(dialogOptions[key] )}`;\n }\n }\n\n return `${endpoint}?${encodedOptions}`;\n}\n\nexport { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint };\n","import { dsnToString } from './dsn.js';\nimport { normalize } from './normalize.js';\nimport { dropUndefinedKeys } from './object.js';\nimport { GLOBAL_OBJ } from './worldwide.js';\n\n/**\n * Creates an envelope.\n * Make sure to always explicitly provide the generic to this function\n * so that the envelope types resolve correctly.\n */\nfunction createEnvelope(headers, items = []) {\n return [headers, items] ;\n}\n\n/**\n * Add an item to an envelope.\n * Make sure to always explicitly provide the generic to this function\n * so that the envelope types resolve correctly.\n */\nfunction addItemToEnvelope(envelope, newItem) {\n const [headers, items] = envelope;\n return [headers, [...items, newItem]] ;\n}\n\n/**\n * Convenience function to loop through the items and item types of an envelope.\n * (This function was mostly created because working with envelope types is painful at the moment)\n *\n * If the callback returns true, the rest of the items will be skipped.\n */\nfunction forEachEnvelopeItem(\n envelope,\n callback,\n) {\n const envelopeItems = envelope[1];\n\n for (const envelopeItem of envelopeItems) {\n const envelopeItemType = envelopeItem[0].type;\n const result = callback(envelopeItem, envelopeItemType);\n\n if (result) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Returns true if the envelope contains any of the given envelope item types\n */\nfunction envelopeContainsItemType(envelope, types) {\n return forEachEnvelopeItem(envelope, (_, type) => types.includes(type));\n}\n\n/**\n * Encode a string to UTF8 array.\n */\nfunction encodeUTF8(input) {\n return GLOBAL_OBJ.__SENTRY__ && GLOBAL_OBJ.__SENTRY__.encodePolyfill\n ? GLOBAL_OBJ.__SENTRY__.encodePolyfill(input)\n : new TextEncoder().encode(input);\n}\n\n/**\n * Decode a UTF8 array to string.\n */\nfunction decodeUTF8(input) {\n return GLOBAL_OBJ.__SENTRY__ && GLOBAL_OBJ.__SENTRY__.decodePolyfill\n ? GLOBAL_OBJ.__SENTRY__.decodePolyfill(input)\n : new TextDecoder().decode(input);\n}\n\n/**\n * Serializes an envelope.\n */\nfunction serializeEnvelope(envelope) {\n const [envHeaders, items] = envelope;\n\n // Initially we construct our envelope as a string and only convert to binary chunks if we encounter binary data\n let parts = JSON.stringify(envHeaders);\n\n function append(next) {\n if (typeof parts === 'string') {\n parts = typeof next === 'string' ? parts + next : [encodeUTF8(parts), next];\n } else {\n parts.push(typeof next === 'string' ? encodeUTF8(next) : next);\n }\n }\n\n for (const item of items) {\n const [itemHeaders, payload] = item;\n\n append(`\\n${JSON.stringify(itemHeaders)}\\n`);\n\n if (typeof payload === 'string' || payload instanceof Uint8Array) {\n append(payload);\n } else {\n let stringifiedPayload;\n try {\n stringifiedPayload = JSON.stringify(payload);\n } catch (e) {\n // In case, despite all our efforts to keep `payload` circular-dependency-free, `JSON.stringify()` still\n // fails, we try again after normalizing it again with infinite normalization depth. This of course has a\n // performance impact but in this case a performance hit is better than throwing.\n stringifiedPayload = JSON.stringify(normalize(payload));\n }\n append(stringifiedPayload);\n }\n }\n\n return typeof parts === 'string' ? parts : concatBuffers(parts);\n}\n\nfunction concatBuffers(buffers) {\n const totalLength = buffers.reduce((acc, buf) => acc + buf.length, 0);\n\n const merged = new Uint8Array(totalLength);\n let offset = 0;\n for (const buffer of buffers) {\n merged.set(buffer, offset);\n offset += buffer.length;\n }\n\n return merged;\n}\n\n/**\n * Parses an envelope\n */\nfunction parseEnvelope(env) {\n let buffer = typeof env === 'string' ? encodeUTF8(env) : env;\n\n function readBinary(length) {\n const bin = buffer.subarray(0, length);\n // Replace the buffer with the remaining data excluding trailing newline\n buffer = buffer.subarray(length + 1);\n return bin;\n }\n\n function readJson() {\n let i = buffer.indexOf(0xa);\n // If we couldn't find a newline, we must have found the end of the buffer\n if (i < 0) {\n i = buffer.length;\n }\n\n return JSON.parse(decodeUTF8(readBinary(i))) ;\n }\n\n const envelopeHeader = readJson();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const items = [];\n\n while (buffer.length) {\n const itemHeader = readJson();\n const binaryLength = typeof itemHeader.length === 'number' ? itemHeader.length : undefined;\n\n items.push([itemHeader, binaryLength ? readBinary(binaryLength) : readJson()]);\n }\n\n return [envelopeHeader, items];\n}\n\n/**\n * Creates envelope item for a single span\n */\nfunction createSpanEnvelopeItem(spanJson) {\n const spanHeaders = {\n type: 'span',\n };\n\n return [spanHeaders, spanJson];\n}\n\n/**\n * Creates attachment envelope items\n */\nfunction createAttachmentEnvelopeItem(attachment) {\n const buffer = typeof attachment.data === 'string' ? encodeUTF8(attachment.data) : attachment.data;\n\n return [\n dropUndefinedKeys({\n type: 'attachment',\n length: buffer.length,\n filename: attachment.filename,\n content_type: attachment.contentType,\n attachment_type: attachment.attachmentType,\n }),\n buffer,\n ];\n}\n\nconst ITEM_TYPE_TO_DATA_CATEGORY_MAP = {\n session: 'session',\n sessions: 'session',\n attachment: 'attachment',\n transaction: 'transaction',\n event: 'error',\n client_report: 'internal',\n user_report: 'default',\n profile: 'profile',\n profile_chunk: 'profile',\n replay_event: 'replay',\n replay_recording: 'replay',\n check_in: 'monitor',\n feedback: 'feedback',\n span: 'span',\n statsd: 'metric_bucket',\n raw_security: 'security',\n};\n\n/**\n * Maps the type of an envelope item to a data category.\n */\nfunction envelopeItemTypeToDataCategory(type) {\n return ITEM_TYPE_TO_DATA_CATEGORY_MAP[type];\n}\n\n/** Extracts the minimal SDK info from the metadata or an events */\nfunction getSdkMetadataForEnvelopeHeader(metadataOrEvent) {\n if (!metadataOrEvent || !metadataOrEvent.sdk) {\n return;\n }\n const { name, version } = metadataOrEvent.sdk;\n return { name, version };\n}\n\n/**\n * Creates event envelope headers, based on event, sdk info and tunnel\n * Note: This function was extracted from the core package to make it available in Replay\n */\nfunction createEventEnvelopeHeaders(\n event,\n sdkInfo,\n tunnel,\n dsn,\n) {\n const dynamicSamplingContext = event.sdkProcessingMetadata && event.sdkProcessingMetadata.dynamicSamplingContext;\n return {\n event_id: event.event_id ,\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n ...(dynamicSamplingContext && {\n trace: dropUndefinedKeys({ ...dynamicSamplingContext }),\n }),\n };\n}\n\nexport { addItemToEnvelope, createAttachmentEnvelopeItem, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem, envelopeContainsItemType, envelopeItemTypeToDataCategory, forEachEnvelopeItem, getSdkMetadataForEnvelopeHeader, parseEnvelope, serializeEnvelope };\n","/** An error emitted by Sentry SDKs and related utilities. */\nclass SentryError extends Error {\n /** Display name of this error instance. */\n\n constructor(\n message,\n logLevel = 'warn',\n ) {\n super(message);this.message = message;\n this.name = new.target.prototype.constructor.name;\n // This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line\n // out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes\n // instances of `SentryError` fail `obj instanceof SentryError` checks.\n Object.setPrototypeOf(this, new.target.prototype);\n this.logLevel = logLevel;\n }\n}\n\nexport { SentryError };\n","import { DEBUG_BUILD } from '../debug-build.js';\nimport { logger } from '../utils-hoist/logger.js';\n\n/**\n * Parse a sample rate from a given value.\n * This will either return a boolean or number sample rate, if the sample rate is valid (between 0 and 1).\n * If a string is passed, we try to convert it to a number.\n *\n * Any invalid sample rate will return `undefined`.\n */\nfunction parseSampleRate(sampleRate) {\n if (typeof sampleRate === 'boolean') {\n return Number(sampleRate);\n }\n\n const rate = typeof sampleRate === 'string' ? parseFloat(sampleRate) : sampleRate;\n if (typeof rate !== 'number' || isNaN(rate) || rate < 0 || rate > 1) {\n DEBUG_BUILD &&\n logger.warn(\n `[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n sampleRate,\n )} of type ${JSON.stringify(typeof sampleRate)}.`,\n );\n return undefined;\n }\n\n return rate;\n}\n\nexport { parseSampleRate };\n","import { getEnvelopeEndpointWithUrlEncodedAuth } from './api.js';\nimport { getTraceContextFromScope, getCurrentScope, getIsolationScope } from './currentScopes.js';\nimport { DEBUG_BUILD } from './debug-build.js';\nimport { createEventEnvelope, createSessionEnvelope } from './envelope.js';\nimport { setupIntegration, afterSetupIntegrations, setupIntegrations } from './integration.js';\nimport { updateSession } from './session.js';\nimport { getDynamicSamplingContextFromScope } from './tracing/dynamicSamplingContext.js';\nimport { createClientReportEnvelope } from './utils-hoist/clientreport.js';\nimport { makeDsn, dsnToString } from './utils-hoist/dsn.js';\nimport { addItemToEnvelope, createAttachmentEnvelopeItem } from './utils-hoist/envelope.js';\nimport { SentryError } from './utils-hoist/error.js';\nimport { isPrimitive, isThenable, isPlainObject, isParameterizedString } from './utils-hoist/is.js';\nimport { logger, consoleSandbox } from './utils-hoist/logger.js';\nimport { uuid4, checkOrSetAlreadyCaught } from './utils-hoist/misc.js';\nimport { resolvedSyncPromise, SyncPromise, rejectedSyncPromise } from './utils-hoist/syncpromise.js';\nimport { parseSampleRate } from './utils/parseSampleRate.js';\nimport { prepareEvent } from './utils/prepareEvent.js';\nimport { showSpanDropWarning } from './utils/spanUtils.js';\n\nconst ALREADY_SEEN_ERROR = \"Not capturing exception because it's already been captured.\";\n\n/**\n * Base implementation for all JavaScript SDK clients.\n *\n * Call the constructor with the corresponding options\n * specific to the client subclass. To access these options later, use\n * {@link Client.getOptions}.\n *\n * If a Dsn is specified in the options, it will be parsed and stored. Use\n * {@link Client.getDsn} to retrieve the Dsn at any moment. In case the Dsn is\n * invalid, the constructor will throw a {@link SentryException}. Note that\n * without a valid Dsn, the SDK will not send any events to Sentry.\n *\n * Before sending an event, it is passed through\n * {@link BaseClient._prepareEvent} to add SDK information and scope data\n * (breadcrumbs and context). To add more custom information, override this\n * method and extend the resulting prepared event.\n *\n * To issue automatically created events (e.g. via instrumentation), use\n * {@link Client.captureEvent}. It will prepare the event and pass it through\n * the callback lifecycle. To issue auto-breadcrumbs, use\n * {@link Client.addBreadcrumb}.\n *\n * @example\n * class NodeClient extends BaseClient {\n * public constructor(options: NodeOptions) {\n * super(options);\n * }\n *\n * // ...\n * }\n */\nclass BaseClient {\n /** Options passed to the SDK. */\n\n /** The client Dsn, if specified in options. Without this Dsn, the SDK will be disabled. */\n\n /** Array of set up integrations. */\n\n /** Number of calls being processed */\n\n /** Holds flushable */\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n\n /**\n * Initializes this client instance.\n *\n * @param options Options for the client.\n */\n constructor(options) {\n this._options = options;\n this._integrations = {};\n this._numProcessing = 0;\n this._outcomes = {};\n this._hooks = {};\n this._eventProcessors = [];\n\n if (options.dsn) {\n this._dsn = makeDsn(options.dsn);\n } else {\n DEBUG_BUILD && logger.warn('No DSN provided, client will not send events.');\n }\n\n if (this._dsn) {\n const url = getEnvelopeEndpointWithUrlEncodedAuth(\n this._dsn,\n options.tunnel,\n options._metadata ? options._metadata.sdk : undefined,\n );\n this._transport = options.transport({\n tunnel: this._options.tunnel,\n recordDroppedEvent: this.recordDroppedEvent.bind(this),\n ...options.transportOptions,\n url,\n });\n }\n\n // TODO(v9): Remove this deprecation warning\n const tracingOptions = ['enableTracing', 'tracesSampleRate', 'tracesSampler'] ;\n const undefinedOption = tracingOptions.find(option => option in options && options[option] == undefined);\n if (undefinedOption) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Deprecation warning: \\`${undefinedOption}\\` is set to undefined, which leads to tracing being enabled. In v9, a value of \\`undefined\\` will result in tracing being disabled.`,\n );\n });\n }\n }\n\n /**\n * @inheritDoc\n */\n captureException(exception, hint, scope) {\n const eventId = uuid4();\n\n // ensure we haven't captured this very object before\n if (checkOrSetAlreadyCaught(exception)) {\n DEBUG_BUILD && logger.log(ALREADY_SEEN_ERROR);\n return eventId;\n }\n\n const hintWithEventId = {\n event_id: eventId,\n ...hint,\n };\n\n this._process(\n this.eventFromException(exception, hintWithEventId).then(event =>\n this._captureEvent(event, hintWithEventId, scope),\n ),\n );\n\n return hintWithEventId.event_id;\n }\n\n /**\n * @inheritDoc\n */\n captureMessage(\n message,\n level,\n hint,\n currentScope,\n ) {\n const hintWithEventId = {\n event_id: uuid4(),\n ...hint,\n };\n\n const eventMessage = isParameterizedString(message) ? message : String(message);\n\n const promisedEvent = isPrimitive(message)\n ? this.eventFromMessage(eventMessage, level, hintWithEventId)\n : this.eventFromException(message, hintWithEventId);\n\n this._process(promisedEvent.then(event => this._captureEvent(event, hintWithEventId, currentScope)));\n\n return hintWithEventId.event_id;\n }\n\n /**\n * @inheritDoc\n */\n captureEvent(event, hint, currentScope) {\n const eventId = uuid4();\n\n // ensure we haven't captured this very object before\n if (hint && hint.originalException && checkOrSetAlreadyCaught(hint.originalException)) {\n DEBUG_BUILD && logger.log(ALREADY_SEEN_ERROR);\n return eventId;\n }\n\n const hintWithEventId = {\n event_id: eventId,\n ...hint,\n };\n\n const sdkProcessingMetadata = event.sdkProcessingMetadata || {};\n const capturedSpanScope = sdkProcessingMetadata.capturedSpanScope;\n\n this._process(this._captureEvent(event, hintWithEventId, capturedSpanScope || currentScope));\n\n return hintWithEventId.event_id;\n }\n\n /**\n * @inheritDoc\n */\n captureSession(session) {\n if (!(typeof session.release === 'string')) {\n DEBUG_BUILD && logger.warn('Discarded session because of missing or non-string release');\n } else {\n this.sendSession(session);\n // After sending, we set init false to indicate it's not the first occurrence\n updateSession(session, { init: false });\n }\n }\n\n /**\n * @inheritDoc\n */\n getDsn() {\n return this._dsn;\n }\n\n /**\n * @inheritDoc\n */\n getOptions() {\n return this._options;\n }\n\n /**\n * @see SdkMetadata\n *\n * @return The metadata of the SDK\n */\n getSdkMetadata() {\n return this._options._metadata;\n }\n\n /**\n * @inheritDoc\n */\n getTransport() {\n return this._transport;\n }\n\n /**\n * @inheritDoc\n */\n flush(timeout) {\n const transport = this._transport;\n if (transport) {\n this.emit('flush');\n return this._isClientDoneProcessing(timeout).then(clientFinished => {\n return transport.flush(timeout).then(transportFlushed => clientFinished && transportFlushed);\n });\n } else {\n return resolvedSyncPromise(true);\n }\n }\n\n /**\n * @inheritDoc\n */\n close(timeout) {\n return this.flush(timeout).then(result => {\n this.getOptions().enabled = false;\n this.emit('close');\n return result;\n });\n }\n\n /** Get all installed event processors. */\n getEventProcessors() {\n return this._eventProcessors;\n }\n\n /** @inheritDoc */\n addEventProcessor(eventProcessor) {\n this._eventProcessors.push(eventProcessor);\n }\n\n /** @inheritdoc */\n init() {\n if (\n this._isEnabled() ||\n // Force integrations to be setup even if no DSN was set when we have\n // Spotlight enabled. This is particularly important for browser as we\n // don't support the `spotlight` option there and rely on the users\n // adding the `spotlightBrowserIntegration()` to their integrations which\n // wouldn't get initialized with the check below when there's no DSN set.\n this._options.integrations.some(({ name }) => name.startsWith('Spotlight'))\n ) {\n this._setupIntegrations();\n }\n }\n\n /**\n * Gets an installed integration by its name.\n *\n * @returns The installed integration or `undefined` if no integration with that `name` was installed.\n */\n getIntegrationByName(integrationName) {\n return this._integrations[integrationName] ;\n }\n\n /**\n * @inheritDoc\n */\n addIntegration(integration) {\n const isAlreadyInstalled = this._integrations[integration.name];\n\n // This hook takes care of only installing if not already installed\n setupIntegration(this, integration, this._integrations);\n // Here we need to check manually to make sure to not run this multiple times\n if (!isAlreadyInstalled) {\n afterSetupIntegrations(this, [integration]);\n }\n }\n\n /**\n * @inheritDoc\n */\n sendEvent(event, hint = {}) {\n this.emit('beforeSendEvent', event, hint);\n\n let env = createEventEnvelope(event, this._dsn, this._options._metadata, this._options.tunnel);\n\n for (const attachment of hint.attachments || []) {\n env = addItemToEnvelope(env, createAttachmentEnvelopeItem(attachment));\n }\n\n const promise = this.sendEnvelope(env);\n if (promise) {\n promise.then(sendResponse => this.emit('afterSendEvent', event, sendResponse), null);\n }\n }\n\n /**\n * @inheritDoc\n */\n sendSession(session) {\n const env = createSessionEnvelope(session, this._dsn, this._options._metadata, this._options.tunnel);\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.sendEnvelope(env);\n }\n\n /**\n * @inheritDoc\n */\n recordDroppedEvent(reason, category, eventOrCount) {\n if (this._options.sendClientReports) {\n // TODO v9: We do not need the `event` passed as third argument anymore, and can possibly remove this overload\n // If event is passed as third argument, we assume this is a count of 1\n const count = typeof eventOrCount === 'number' ? eventOrCount : 1;\n\n // We want to track each category (error, transaction, session, replay_event) separately\n // but still keep the distinction between different type of outcomes.\n // We could use nested maps, but it's much easier to read and type this way.\n // A correct type for map-based implementation if we want to go that route\n // would be `Partial>>>`\n // With typescript 4.1 we could even use template literal types\n const key = `${reason}:${category}`;\n DEBUG_BUILD && logger.log(`Recording outcome: \"${key}\"${count > 1 ? ` (${count} times)` : ''}`);\n this._outcomes[key] = (this._outcomes[key] || 0) + count;\n }\n }\n\n // Keep on() & emit() signatures in sync with types' client.ts interface\n /* eslint-disable @typescript-eslint/unified-signatures */\n\n /** @inheritdoc */\n\n /** @inheritdoc */\n on(hook, callback) {\n const hooks = (this._hooks[hook] = this._hooks[hook] || []);\n\n // @ts-expect-error We assume the types are correct\n hooks.push(callback);\n\n // This function returns a callback execution handler that, when invoked,\n // deregisters a callback. This is crucial for managing instances where callbacks\n // need to be unregistered to prevent self-referencing in callback closures,\n // ensuring proper garbage collection.\n return () => {\n // @ts-expect-error We assume the types are correct\n const cbIndex = hooks.indexOf(callback);\n if (cbIndex > -1) {\n hooks.splice(cbIndex, 1);\n }\n };\n }\n\n /** @inheritdoc */\n\n /** @inheritdoc */\n emit(hook, ...rest) {\n const callbacks = this._hooks[hook];\n if (callbacks) {\n callbacks.forEach(callback => callback(...rest));\n }\n }\n\n /**\n * @inheritdoc\n */\n sendEnvelope(envelope) {\n this.emit('beforeEnvelope', envelope);\n\n if (this._isEnabled() && this._transport) {\n return this._transport.send(envelope).then(null, reason => {\n DEBUG_BUILD && logger.error('Error while sending envelope:', reason);\n return reason;\n });\n }\n\n DEBUG_BUILD && logger.error('Transport disabled');\n\n return resolvedSyncPromise({});\n }\n\n /* eslint-enable @typescript-eslint/unified-signatures */\n\n /** Setup integrations for this client. */\n _setupIntegrations() {\n const { integrations } = this._options;\n this._integrations = setupIntegrations(this, integrations);\n afterSetupIntegrations(this, integrations);\n }\n\n /** Updates existing session based on the provided event */\n _updateSessionFromEvent(session, event) {\n let crashed = false;\n let errored = false;\n const exceptions = event.exception && event.exception.values;\n\n if (exceptions) {\n errored = true;\n\n for (const ex of exceptions) {\n const mechanism = ex.mechanism;\n if (mechanism && mechanism.handled === false) {\n crashed = true;\n break;\n }\n }\n }\n\n // A session is updated and that session update is sent in only one of the two following scenarios:\n // 1. Session with non terminal status and 0 errors + an error occurred -> Will set error count to 1 and send update\n // 2. Session with non terminal status and 1 error + a crash occurred -> Will set status crashed and send update\n const sessionNonTerminal = session.status === 'ok';\n const shouldUpdateAndSend = (sessionNonTerminal && session.errors === 0) || (sessionNonTerminal && crashed);\n\n if (shouldUpdateAndSend) {\n updateSession(session, {\n ...(crashed && { status: 'crashed' }),\n errors: session.errors || Number(errored || crashed),\n });\n this.captureSession(session);\n }\n }\n\n /**\n * Determine if the client is finished processing. Returns a promise because it will wait `timeout` ms before saying\n * \"no\" (resolving to `false`) in order to give the client a chance to potentially finish first.\n *\n * @param timeout The time, in ms, after which to resolve to `false` if the client is still busy. Passing `0` (or not\n * passing anything) will make the promise wait as long as it takes for processing to finish before resolving to\n * `true`.\n * @returns A promise which will resolve to `true` if processing is already done or finishes before the timeout, and\n * `false` otherwise\n */\n _isClientDoneProcessing(timeout) {\n return new SyncPromise(resolve => {\n let ticked = 0;\n const tick = 1;\n\n const interval = setInterval(() => {\n if (this._numProcessing == 0) {\n clearInterval(interval);\n resolve(true);\n } else {\n ticked += tick;\n if (timeout && ticked >= timeout) {\n clearInterval(interval);\n resolve(false);\n }\n }\n }, tick);\n });\n }\n\n /** Determines whether this SDK is enabled and a transport is present. */\n _isEnabled() {\n return this.getOptions().enabled !== false && this._transport !== undefined;\n }\n\n /**\n * Adds common information to events.\n *\n * The information includes release and environment from `options`,\n * breadcrumbs and context (extra, tags and user) from the scope.\n *\n * Information that is already present in the event is never overwritten. For\n * nested objects, such as the context, keys are merged.\n *\n * @param event The original event.\n * @param hint May contain additional information about the original exception.\n * @param currentScope A scope containing event metadata.\n * @returns A new event with more information.\n */\n _prepareEvent(\n event,\n hint,\n currentScope = getCurrentScope(),\n isolationScope = getIsolationScope(),\n ) {\n const options = this.getOptions();\n const integrations = Object.keys(this._integrations);\n if (!hint.integrations && integrations.length > 0) {\n hint.integrations = integrations;\n }\n\n this.emit('preprocessEvent', event, hint);\n\n if (!event.type) {\n isolationScope.setLastEventId(event.event_id || hint.event_id);\n }\n\n return prepareEvent(options, event, hint, currentScope, this, isolationScope).then(evt => {\n if (evt === null) {\n return evt;\n }\n\n evt.contexts = {\n trace: getTraceContextFromScope(currentScope),\n ...evt.contexts,\n };\n\n const dynamicSamplingContext = getDynamicSamplingContextFromScope(this, currentScope);\n\n evt.sdkProcessingMetadata = {\n dynamicSamplingContext,\n ...evt.sdkProcessingMetadata,\n };\n\n return evt;\n });\n }\n\n /**\n * Processes the event and logs an error in case of rejection\n * @param event\n * @param hint\n * @param scope\n */\n _captureEvent(event, hint = {}, scope) {\n return this._processEvent(event, hint, scope).then(\n finalEvent => {\n return finalEvent.event_id;\n },\n reason => {\n if (DEBUG_BUILD) {\n // If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for\n // control flow, log just the message (no stack) as a log-level log.\n const sentryError = reason ;\n if (sentryError.logLevel === 'log') {\n logger.log(sentryError.message);\n } else {\n logger.warn(sentryError);\n }\n }\n return undefined;\n },\n );\n }\n\n /**\n * Processes an event (either error or message) and sends it to Sentry.\n *\n * This also adds breadcrumbs and context information to the event. However,\n * platform specific meta data (such as the User's IP address) must be added\n * by the SDK implementor.\n *\n *\n * @param event The event to send to Sentry.\n * @param hint May contain additional information about the original exception.\n * @param currentScope A scope containing event metadata.\n * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.\n */\n _processEvent(event, hint, currentScope) {\n const options = this.getOptions();\n const { sampleRate } = options;\n\n const isTransaction = isTransactionEvent(event);\n const isError = isErrorEvent(event);\n const eventType = event.type || 'error';\n const beforeSendLabel = `before send for type \\`${eventType}\\``;\n\n // 1.0 === 100% events are sent\n // 0.0 === 0% events are sent\n // Sampling for transaction happens somewhere else\n const parsedSampleRate = typeof sampleRate === 'undefined' ? undefined : parseSampleRate(sampleRate);\n if (isError && typeof parsedSampleRate === 'number' && Math.random() > parsedSampleRate) {\n this.recordDroppedEvent('sample_rate', 'error', event);\n return rejectedSyncPromise(\n new SentryError(\n `Discarding event because it's not included in the random sample (sampling rate = ${sampleRate})`,\n 'log',\n ),\n );\n }\n\n const dataCategory = eventType === 'replay_event' ? 'replay' : eventType;\n\n const sdkProcessingMetadata = event.sdkProcessingMetadata || {};\n const capturedSpanIsolationScope = sdkProcessingMetadata.capturedSpanIsolationScope;\n\n return this._prepareEvent(event, hint, currentScope, capturedSpanIsolationScope)\n .then(prepared => {\n if (prepared === null) {\n this.recordDroppedEvent('event_processor', dataCategory, event);\n throw new SentryError('An event processor returned `null`, will not send event.', 'log');\n }\n\n const isInternalException = hint.data && (hint.data ).__sentry__ === true;\n if (isInternalException) {\n return prepared;\n }\n\n const result = processBeforeSend(this, options, prepared, hint);\n return _validateBeforeSendResult(result, beforeSendLabel);\n })\n .then(processedEvent => {\n if (processedEvent === null) {\n this.recordDroppedEvent('before_send', dataCategory, event);\n if (isTransaction) {\n const spans = event.spans || [];\n // the transaction itself counts as one span, plus all the child spans that are added\n const spanCount = 1 + spans.length;\n this.recordDroppedEvent('before_send', 'span', spanCount);\n }\n throw new SentryError(`${beforeSendLabel} returned \\`null\\`, will not send event.`, 'log');\n }\n\n const session = currentScope && currentScope.getSession();\n if (!isTransaction && session) {\n this._updateSessionFromEvent(session, processedEvent);\n }\n\n if (isTransaction) {\n const spanCountBefore =\n (processedEvent.sdkProcessingMetadata && processedEvent.sdkProcessingMetadata.spanCountBeforeProcessing) ||\n 0;\n const spanCountAfter = processedEvent.spans ? processedEvent.spans.length : 0;\n\n const droppedSpanCount = spanCountBefore - spanCountAfter;\n if (droppedSpanCount > 0) {\n this.recordDroppedEvent('before_send', 'span', droppedSpanCount);\n }\n }\n\n // None of the Sentry built event processor will update transaction name,\n // so if the transaction name has been changed by an event processor, we know\n // it has to come from custom event processor added by a user\n const transactionInfo = processedEvent.transaction_info;\n if (isTransaction && transactionInfo && processedEvent.transaction !== event.transaction) {\n const source = 'custom';\n processedEvent.transaction_info = {\n ...transactionInfo,\n source,\n };\n }\n\n this.sendEvent(processedEvent, hint);\n return processedEvent;\n })\n .then(null, reason => {\n if (reason instanceof SentryError) {\n throw reason;\n }\n\n this.captureException(reason, {\n data: {\n __sentry__: true,\n },\n originalException: reason,\n });\n throw new SentryError(\n `Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\\nReason: ${reason}`,\n );\n });\n }\n\n /**\n * Occupies the client with processing and event\n */\n _process(promise) {\n this._numProcessing++;\n void promise.then(\n value => {\n this._numProcessing--;\n return value;\n },\n reason => {\n this._numProcessing--;\n return reason;\n },\n );\n }\n\n /**\n * Clears outcomes on this client and returns them.\n */\n _clearOutcomes() {\n const outcomes = this._outcomes;\n this._outcomes = {};\n return Object.entries(outcomes).map(([key, quantity]) => {\n const [reason, category] = key.split(':') ;\n return {\n reason,\n category,\n quantity,\n };\n });\n }\n\n /**\n * Sends client reports as an envelope.\n */\n _flushOutcomes() {\n DEBUG_BUILD && logger.log('Flushing outcomes...');\n\n const outcomes = this._clearOutcomes();\n\n if (outcomes.length === 0) {\n DEBUG_BUILD && logger.log('No outcomes to send');\n return;\n }\n\n // This is really the only place where we want to check for a DSN and only send outcomes then\n if (!this._dsn) {\n DEBUG_BUILD && logger.log('No dsn provided, will not send outcomes');\n return;\n }\n\n DEBUG_BUILD && logger.log('Sending outcomes:', outcomes);\n\n const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.sendEnvelope(envelope);\n }\n\n /**\n * @inheritDoc\n */\n\n}\n\n/**\n * Verifies that return value of configured `beforeSend` or `beforeSendTransaction` is of expected type, and returns the value if so.\n */\nfunction _validateBeforeSendResult(\n beforeSendResult,\n beforeSendLabel,\n) {\n const invalidValueError = `${beforeSendLabel} must return \\`null\\` or a valid event.`;\n if (isThenable(beforeSendResult)) {\n return beforeSendResult.then(\n event => {\n if (!isPlainObject(event) && event !== null) {\n throw new SentryError(invalidValueError);\n }\n return event;\n },\n e => {\n throw new SentryError(`${beforeSendLabel} rejected with ${e}`);\n },\n );\n } else if (!isPlainObject(beforeSendResult) && beforeSendResult !== null) {\n throw new SentryError(invalidValueError);\n }\n return beforeSendResult;\n}\n\n/**\n * Process the matching `beforeSendXXX` callback.\n */\nfunction processBeforeSend(\n client,\n options,\n event,\n hint,\n) {\n const { beforeSend, beforeSendTransaction, beforeSendSpan } = options;\n\n if (isErrorEvent(event) && beforeSend) {\n return beforeSend(event, hint);\n }\n\n if (isTransactionEvent(event)) {\n if (event.spans && beforeSendSpan) {\n const processedSpans = [];\n for (const span of event.spans) {\n const processedSpan = beforeSendSpan(span);\n if (processedSpan) {\n processedSpans.push(processedSpan);\n } else {\n showSpanDropWarning();\n client.recordDroppedEvent('before_send', 'span');\n }\n }\n event.spans = processedSpans;\n }\n\n if (beforeSendTransaction) {\n if (event.spans) {\n // We store the # of spans before processing in SDK metadata,\n // so we can compare it afterwards to determine how many spans were dropped\n const spanCountBefore = event.spans.length;\n event.sdkProcessingMetadata = {\n ...event.sdkProcessingMetadata,\n spanCountBeforeProcessing: spanCountBefore,\n };\n }\n return beforeSendTransaction(event, hint);\n }\n }\n\n return event;\n}\n\nfunction isErrorEvent(event) {\n return event.type === undefined;\n}\n\nfunction isTransactionEvent(event) {\n return event.type === 'transaction';\n}\n\nexport { BaseClient };\n","import { getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext.js';\nimport { dsnToString } from './utils-hoist/dsn.js';\nimport { getSdkMetadataForEnvelopeHeader, createEnvelope, createEventEnvelopeHeaders, createSpanEnvelopeItem } from './utils-hoist/envelope.js';\nimport './utils-hoist/version.js';\nimport './utils-hoist/debug-build.js';\nimport './utils-hoist/logger.js';\nimport { spanToJSON, showSpanDropWarning } from './utils/spanUtils.js';\n\n/**\n * Apply SdkInfo (name, version, packages, integrations) to the corresponding event key.\n * Merge with existing data if any.\n **/\nfunction enhanceEventWithSdkInfo(event, sdkInfo) {\n if (!sdkInfo) {\n return event;\n }\n event.sdk = event.sdk || {};\n event.sdk.name = event.sdk.name || sdkInfo.name;\n event.sdk.version = event.sdk.version || sdkInfo.version;\n event.sdk.integrations = [...(event.sdk.integrations || []), ...(sdkInfo.integrations || [])];\n event.sdk.packages = [...(event.sdk.packages || []), ...(sdkInfo.packages || [])];\n return event;\n}\n\n/** Creates an envelope from a Session */\nfunction createSessionEnvelope(\n session,\n dsn,\n metadata,\n tunnel,\n) {\n const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);\n const envelopeHeaders = {\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const envelopeItem =\n 'aggregates' in session ? [{ type: 'sessions' }, session] : [{ type: 'session' }, session.toJSON()];\n\n return createEnvelope(envelopeHeaders, [envelopeItem]);\n}\n\n/**\n * Create an Envelope from an event.\n */\nfunction createEventEnvelope(\n event,\n dsn,\n metadata,\n tunnel,\n) {\n const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);\n\n /*\n Note: Due to TS, event.type may be `replay_event`, theoretically.\n In practice, we never call `createEventEnvelope` with `replay_event` type,\n and we'd have to adjust a looot of types to make this work properly.\n We want to avoid casting this around, as that could lead to bugs (e.g. when we add another type)\n So the safe choice is to really guard against the replay_event type here.\n */\n const eventType = event.type && event.type !== 'replay_event' ? event.type : 'event';\n\n enhanceEventWithSdkInfo(event, metadata && metadata.sdk);\n\n const envelopeHeaders = createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn);\n\n // Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to\n // sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may\n // have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid\n // of this `delete`, lest we miss putting it back in the next time the property is in use.)\n delete event.sdkProcessingMetadata;\n\n const eventItem = [{ type: eventType }, event];\n return createEnvelope(envelopeHeaders, [eventItem]);\n}\n\n/**\n * Create envelope from Span item.\n *\n * Takes an optional client and runs spans through `beforeSendSpan` if available.\n */\nfunction createSpanEnvelope(spans, client) {\n function dscHasRequiredProps(dsc) {\n return !!dsc.trace_id && !!dsc.public_key;\n }\n\n // For the moment we'll obtain the DSC from the first span in the array\n // This might need to be changed if we permit sending multiple spans from\n // different segments in one envelope\n const dsc = getDynamicSamplingContextFromSpan(spans[0]);\n\n const dsn = client && client.getDsn();\n const tunnel = client && client.getOptions().tunnel;\n\n const headers = {\n sent_at: new Date().toISOString(),\n ...(dscHasRequiredProps(dsc) && { trace: dsc }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n\n const beforeSendSpan = client && client.getOptions().beforeSendSpan;\n const convertToSpanJSON = beforeSendSpan\n ? (span) => {\n const spanJson = beforeSendSpan(spanToJSON(span) );\n if (!spanJson) {\n showSpanDropWarning();\n }\n return spanJson;\n }\n : (span) => spanToJSON(span);\n\n const items = [];\n for (const span of spans) {\n const spanJson = convertToSpanJSON(span);\n if (spanJson) {\n items.push(createSpanEnvelopeItem(spanJson));\n }\n }\n\n return createEnvelope(headers, items);\n}\n\nexport { createEventEnvelope, createSessionEnvelope, createSpanEnvelope };\n","import { createEnvelope } from './envelope.js';\nimport { dateTimestampInSeconds } from './time.js';\n\n/**\n * Creates client report envelope\n * @param discarded_events An array of discard events\n * @param dsn A DSN that can be set on the header. Optional.\n */\nfunction createClientReportEnvelope(\n discarded_events,\n dsn,\n timestamp,\n) {\n const clientReportItem = [\n { type: 'client_report' },\n {\n timestamp: timestamp || dateTimestampInSeconds(),\n discarded_events,\n },\n ];\n return createEnvelope(dsn ? { dsn } : {}, [clientReportItem]);\n}\n\nexport { createClientReportEnvelope };\n","import { SDK_VERSION } from '../utils-hoist/version.js';\n\n/**\n * A builder for the SDK metadata in the options for the SDK initialization.\n *\n * Note: This function is identical to `buildMetadata` in Remix and NextJS and SvelteKit.\n * We don't extract it for bundle size reasons.\n * @see https://github.com/getsentry/sentry-javascript/pull/7404\n * @see https://github.com/getsentry/sentry-javascript/pull/4196\n *\n * If you make changes to this function consider updating the others as well.\n *\n * @param options SDK options object that gets mutated\n * @param names list of package names\n */\nfunction applySdkMetadata(options, name, names = [name], source = 'npm') {\n const metadata = options._metadata || {};\n\n if (!metadata.sdk) {\n metadata.sdk = {\n name: `sentry.javascript.${name}`,\n packages: names.map(name => ({\n name: `${source}:@sentry/${name}`,\n version: SDK_VERSION,\n })),\n version: SDK_VERSION,\n };\n }\n\n options._metadata = metadata;\n}\n\nexport { applySdkMetadata };\n","/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nconst DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);\n\nexport { DEBUG_BUILD };\n","import { addExceptionMechanism, resolvedSyncPromise, isErrorEvent, isDOMError, isDOMException, addExceptionTypeValue, isError, isPlainObject, isEvent, isParameterizedString, getClient, normalizeToSize, extractExceptionKeysForMessage } from '@sentry/core';\n\n/**\n * This function creates an exception from a JavaScript Error\n */\nfunction exceptionFromError(stackParser, ex) {\n // Get the frames first since Opera can lose the stack if we touch anything else first\n const frames = parseStackFrames(stackParser, ex);\n\n const exception = {\n type: extractType(ex),\n value: extractMessage(ex),\n };\n\n if (frames.length) {\n exception.stacktrace = { frames };\n }\n\n if (exception.type === undefined && exception.value === '') {\n exception.value = 'Unrecoverable error caught';\n }\n\n return exception;\n}\n\nfunction eventFromPlainObject(\n stackParser,\n exception,\n syntheticException,\n isUnhandledRejection,\n) {\n const client = getClient();\n const normalizeDepth = client && client.getOptions().normalizeDepth;\n\n // If we can, we extract an exception from the object properties\n const errorFromProp = getErrorPropertyFromObject(exception);\n\n const extra = {\n __serialized__: normalizeToSize(exception, normalizeDepth),\n };\n\n if (errorFromProp) {\n return {\n exception: {\n values: [exceptionFromError(stackParser, errorFromProp)],\n },\n extra,\n };\n }\n\n const event = {\n exception: {\n values: [\n {\n type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',\n value: getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }),\n } ,\n ],\n },\n extra,\n } ;\n\n if (syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n // event.exception.values[0] has been set above\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n event.exception.values[0].stacktrace = { frames };\n }\n }\n\n return event;\n}\n\nfunction eventFromError(stackParser, ex) {\n return {\n exception: {\n values: [exceptionFromError(stackParser, ex)],\n },\n };\n}\n\n/** Parses stack frames from an error */\nfunction parseStackFrames(\n stackParser,\n ex,\n) {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || '';\n\n const skipLines = getSkipFirstStackStringLines(ex);\n const framesToPop = getPopFirstTopFrames(ex);\n\n try {\n return stackParser(stacktrace, skipLines, framesToPop);\n } catch (e) {\n // no-empty\n }\n\n return [];\n}\n\n// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i;\n\n/**\n * Certain known React errors contain links that would be falsely\n * parsed as frames. This function check for these errors and\n * returns number of the stack string lines to skip.\n */\nfunction getSkipFirstStackStringLines(ex) {\n if (ex && reactMinifiedRegexp.test(ex.message)) {\n return 1;\n }\n\n return 0;\n}\n\n/**\n * If error has `framesToPop` property, it means that the\n * creator tells us the first x frames will be useless\n * and should be discarded. Typically error from wrapper function\n * which don't point to the actual location in the developer's code.\n *\n * Example: https://github.com/zertosh/invariant/blob/master/invariant.js#L46\n */\nfunction getPopFirstTopFrames(ex) {\n if (typeof ex.framesToPop === 'number') {\n return ex.framesToPop;\n }\n\n return 0;\n}\n\n// https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Exception\n// @ts-expect-error - WebAssembly.Exception is a valid class\nfunction isWebAssemblyException(exception) {\n // Check for support\n // @ts-expect-error - WebAssembly.Exception is a valid class\n if (typeof WebAssembly !== 'undefined' && typeof WebAssembly.Exception !== 'undefined') {\n // @ts-expect-error - WebAssembly.Exception is a valid class\n return exception instanceof WebAssembly.Exception;\n } else {\n return false;\n }\n}\n\n/**\n * Extracts from errors what we use as the exception `type` in error events.\n *\n * Usually, this is the `name` property on Error objects but WASM errors need to be treated differently.\n */\nfunction extractType(ex) {\n const name = ex && ex.name;\n\n // The name for WebAssembly.Exception Errors needs to be extracted differently.\n // Context: https://github.com/getsentry/sentry-javascript/issues/13787\n if (!name && isWebAssemblyException(ex)) {\n // Emscripten sets array[type, message] to the \"message\" property on the WebAssembly.Exception object\n const hasTypeInMessage = ex.message && Array.isArray(ex.message) && ex.message.length == 2;\n return hasTypeInMessage ? ex.message[0] : 'WebAssembly.Exception';\n }\n\n return name;\n}\n\n/**\n * There are cases where stacktrace.message is an Event object\n * https://github.com/getsentry/sentry-javascript/issues/1949\n * In this specific case we try to extract stacktrace.message.error.message\n */\nfunction extractMessage(ex) {\n const message = ex && ex.message;\n\n if (!message) {\n return 'No error message';\n }\n\n if (message.error && typeof message.error.message === 'string') {\n return message.error.message;\n }\n\n // Emscripten sets array[type, message] to the \"message\" property on the WebAssembly.Exception object\n if (isWebAssemblyException(ex) && Array.isArray(ex.message) && ex.message.length == 2) {\n return ex.message[1];\n }\n\n return message;\n}\n\n/**\n * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.\n * @hidden\n */\nfunction eventFromException(\n stackParser,\n exception,\n hint,\n attachStacktrace,\n) {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace);\n addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }\n event.level = 'error';\n if (hint && hint.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * Builds and Event from a Message\n * @hidden\n */\nfunction eventFromMessage(\n stackParser,\n message,\n level = 'info',\n hint,\n attachStacktrace,\n) {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n event.level = level;\n if (hint && hint.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * @hidden\n */\nfunction eventFromUnknownInput(\n stackParser,\n exception,\n syntheticException,\n attachStacktrace,\n isUnhandledRejection,\n) {\n let event;\n\n if (isErrorEvent(exception ) && (exception ).error) {\n // If it is an ErrorEvent with `error` property, extract it to get actual Error\n const errorEvent = exception ;\n return eventFromError(stackParser, errorEvent.error );\n }\n\n // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name\n // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be\n // `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.\n //\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n // https://webidl.spec.whatwg.org/#es-DOMException-specialness\n if (isDOMError(exception) || isDOMException(exception )) {\n const domException = exception ;\n\n if ('stack' in (exception )) {\n event = eventFromError(stackParser, exception );\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');\n const message = domException.message ? `${name}: ${domException.message}` : name;\n event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, message);\n }\n if ('code' in domException) {\n // eslint-disable-next-line deprecation/deprecation\n event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` };\n }\n\n return event;\n }\n if (isError(exception)) {\n // we have a real Error object, do nothing\n return eventFromError(stackParser, exception);\n }\n if (isPlainObject(exception) || isEvent(exception)) {\n // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize\n // it manually. This will allow us to group events based on top-level keys which is much better than creating a new\n // group on any key/value change.\n const objectException = exception ;\n event = eventFromPlainObject(stackParser, objectException, syntheticException, isUnhandledRejection);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n return event;\n }\n\n // If none of previous checks were valid, then it means that it's not:\n // - an instance of DOMError\n // - an instance of DOMException\n // - an instance of Event\n // - an instance of Error\n // - a valid ErrorEvent (one with an error property)\n // - a plain Object\n //\n // So bail out and capture it as a simple message:\n event = eventFromString(stackParser, exception , syntheticException, attachStacktrace);\n addExceptionTypeValue(event, `${exception}`, undefined);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n\n return event;\n}\n\nfunction eventFromString(\n stackParser,\n message,\n syntheticException,\n attachStacktrace,\n) {\n const event = {};\n\n if (attachStacktrace && syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n event.exception = {\n values: [{ value: message, stacktrace: { frames } }],\n };\n }\n addExceptionMechanism(event, { synthetic: true });\n }\n\n if (isParameterizedString(message)) {\n const { __sentry_template_string__, __sentry_template_values__ } = message;\n\n event.logentry = {\n message: __sentry_template_string__,\n params: __sentry_template_values__,\n };\n return event;\n }\n\n event.message = message;\n return event;\n}\n\nfunction getNonErrorObjectExceptionValue(\n exception,\n { isUnhandledRejection },\n) {\n const keys = extractExceptionKeysForMessage(exception);\n const captureType = isUnhandledRejection ? 'promise rejection' : 'exception';\n\n // Some ErrorEvent instances do not have an `error` property, which is why they are not handled before\n // We still want to try to get a decent message for these cases\n if (isErrorEvent(exception)) {\n return `Event \\`ErrorEvent\\` captured as ${captureType} with message \\`${exception.message}\\``;\n }\n\n if (isEvent(exception)) {\n const className = getObjectClassName(exception);\n return `Event \\`${className}\\` (type=${exception.type}) captured as ${captureType}`;\n }\n\n return `Object captured as ${captureType} with keys: ${keys}`;\n}\n\nfunction getObjectClassName(obj) {\n try {\n const prototype = Object.getPrototypeOf(obj);\n return prototype ? prototype.constructor.name : undefined;\n } catch (e) {\n // ignore errors here\n }\n}\n\n/** If a plain object has a property that is an `Error`, return this error. */\nfunction getErrorPropertyFromObject(obj) {\n for (const prop in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, prop)) {\n const value = obj[prop];\n if (value instanceof Error) {\n return value;\n }\n }\n }\n\n return undefined;\n}\n\nexport { eventFromException, eventFromMessage, eventFromUnknownInput, exceptionFromError, extractMessage, extractType };\n","import { GLOBAL_OBJ, getOriginalFunction, markFunctionWrapped, addNonEnumerableProperty, withScope, addExceptionTypeValue, addExceptionMechanism, captureException } from '@sentry/core';\n\nconst WINDOW = GLOBAL_OBJ ;\n\nlet ignoreOnError = 0;\n\n/**\n * @hidden\n */\nfunction shouldIgnoreOnError() {\n return ignoreOnError > 0;\n}\n\n/**\n * @hidden\n */\nfunction ignoreNextOnError() {\n // onerror should trigger before setTimeout\n ignoreOnError++;\n setTimeout(() => {\n ignoreOnError--;\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\n\n/**\n * Instruments the given function and sends an event to Sentry every time the\n * function throws an exception.\n *\n * @param fn A function to wrap. It is generally safe to pass an unbound function, because the returned wrapper always\n * has a correct `this` context.\n * @returns The wrapped function.\n * @hidden\n */\nfunction wrap(\n fn,\n options\n\n = {},\n) {\n // for future readers what this does is wrap a function and then create\n // a bi-directional wrapping between them.\n //\n // example: wrapped = wrap(original);\n // original.__sentry_wrapped__ -> wrapped\n // wrapped.__sentry_original__ -> original\n\n function isFunction(fn) {\n return typeof fn === 'function';\n }\n\n if (!isFunction(fn)) {\n return fn;\n }\n\n try {\n // if we're dealing with a function that was previously wrapped, return\n // the original wrapper.\n const wrapper = (fn ).__sentry_wrapped__;\n if (wrapper) {\n if (typeof wrapper === 'function') {\n return wrapper;\n } else {\n // If we find that the `__sentry_wrapped__` function is not a function at the time of accessing it, it means\n // that something messed with it. In that case we want to return the originally passed function.\n return fn;\n }\n }\n\n // We don't wanna wrap it twice\n if (getOriginalFunction(fn)) {\n return fn;\n }\n } catch (e) {\n // Just accessing custom props in some Selenium environments\n // can cause a \"Permission denied\" exception (see raven-js#495).\n // Bail on wrapping and return the function as-is (defers to window.onerror).\n return fn;\n }\n\n // Wrap the function itself\n // It is important that `sentryWrapped` is not an arrow function to preserve the context of `this`\n const sentryWrapped = function ( ...args) {\n try {\n // Also wrap arguments that are themselves functions\n const wrappedArguments = args.map(arg => wrap(arg, options));\n\n // Attempt to invoke user-land function\n // NOTE: If you are a Sentry user, and you are seeing this stack frame, it\n // means the sentry.javascript SDK caught an error invoking your application code. This\n // is expected behavior and NOT indicative of a bug with sentry.javascript.\n return fn.apply(this, wrappedArguments);\n } catch (ex) {\n ignoreNextOnError();\n\n withScope(scope => {\n scope.addEventProcessor(event => {\n if (options.mechanism) {\n addExceptionTypeValue(event, undefined, undefined);\n addExceptionMechanism(event, options.mechanism);\n }\n\n event.extra = {\n ...event.extra,\n arguments: args,\n };\n\n return event;\n });\n\n captureException(ex);\n });\n\n throw ex;\n }\n } ;\n\n // Wrap the wrapped function in a proxy, to ensure any other properties of the original function remain available\n try {\n for (const property in fn) {\n if (Object.prototype.hasOwnProperty.call(fn, property)) {\n sentryWrapped[property ] = fn[property ];\n }\n }\n } catch (e2) {\n // Accessing some objects may throw\n // ref: https://github.com/getsentry/sentry-javascript/issues/1168\n }\n\n // Signal that this function has been wrapped/filled already\n // for both debugging and to prevent it to being wrapped/filled twice\n markFunctionWrapped(sentryWrapped, fn);\n\n addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);\n\n // Restore original function name (not all browsers allow that)\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name');\n if (descriptor.configurable) {\n Object.defineProperty(sentryWrapped, 'name', {\n get() {\n return fn.name;\n },\n });\n }\n } catch (e3) {\n // This may throw if e.g. the descriptor does not exist, or a browser does not allow redefining `name`.\n // to save some bytes we simply try-catch this\n }\n\n return sentryWrapped;\n}\n\nexport { WINDOW, ignoreNextOnError, shouldIgnoreOnError, wrap };\n","import { BaseClient, getSDKSource, applySdkMetadata, logger } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build.js';\nimport { eventFromException, eventFromMessage } from './eventbuilder.js';\nimport { WINDOW } from './helpers.js';\nimport { createUserFeedbackEnvelope } from './userfeedback.js';\n\n/**\n * Configuration options for the Sentry Browser SDK.\n * @see @sentry/core Options for more information.\n */\n\n/**\n * The Sentry Browser SDK Client.\n *\n * @see BrowserOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nclass BrowserClient extends BaseClient {\n /**\n * Creates a new Browser SDK instance.\n *\n * @param options Configuration options for this SDK.\n */\n constructor(options) {\n const opts = {\n // We default this to true, as it is the safer scenario\n parentSpanIsAlwaysRootSpan: true,\n ...options,\n };\n const sdkSource = WINDOW.SENTRY_SDK_SOURCE || getSDKSource();\n applySdkMetadata(opts, 'browser', ['browser'], sdkSource);\n\n super(opts);\n\n if (opts.sendClientReports && WINDOW.document) {\n WINDOW.document.addEventListener('visibilitychange', () => {\n if (WINDOW.document.visibilityState === 'hidden') {\n this._flushOutcomes();\n }\n });\n }\n }\n\n /**\n * @inheritDoc\n */\n eventFromException(exception, hint) {\n return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n eventFromMessage(\n message,\n level = 'info',\n hint,\n ) {\n return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);\n }\n\n /**\n * Sends user feedback to Sentry.\n *\n * @deprecated Use `captureFeedback` instead.\n */\n captureUserFeedback(feedback) {\n if (!this._isEnabled()) {\n DEBUG_BUILD && logger.warn('SDK not enabled, will not capture user feedback.');\n return;\n }\n\n const envelope = createUserFeedbackEnvelope(feedback, {\n metadata: this.getSdkMetadata(),\n dsn: this.getDsn(),\n tunnel: this.getOptions().tunnel,\n });\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.sendEnvelope(envelope);\n }\n\n /**\n * @inheritDoc\n */\n _prepareEvent(event, hint, scope) {\n event.platform = event.platform || 'javascript';\n return super._prepareEvent(event, hint, scope);\n }\n}\n\nexport { BrowserClient };\n","/*\n * This module exists for optimizations in the build process through rollup and terser. We define some global\n * constants, which can be overridden during build. By guarding certain pieces of code with functions that return these\n * constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will\n * never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to\n * `logger` and preventing node-related code from appearing in browser bundles.\n *\n * Attention:\n * This file should not be used to define constants/flags that are intended to be used for tree-shaking conducted by\n * users. These flags should live in their respective packages, as we identified user tooling (specifically webpack)\n * having issues tree-shaking these constants across package boundaries.\n * An example for this is the __SENTRY_DEBUG__ constant. It is declared in each package individually because we want\n * users to be able to shake away expressions that it guards.\n */\n\n/**\n * Figures out if we're building a browser bundle.\n *\n * @returns true if this is a browser bundle build.\n */\nfunction isBrowserBundle() {\n return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__;\n}\n\n/**\n * Get source of SDK.\n */\nfunction getSDKSource() {\n // This comment is used to identify this line in the CDN bundle build step and replace this with \"return 'cdn';\"\n /* __SENTRY_SDK_SOURCE__ */ return 'npm';\n}\n\nexport { getSDKSource, isBrowserBundle };\n","import { dsnToString, createEnvelope } from '@sentry/core';\n\n/**\n * Creates an envelope from a user feedback.\n */\nfunction createUserFeedbackEnvelope(\n feedback,\n {\n metadata,\n tunnel,\n dsn,\n }\n\n,\n) {\n const headers = {\n event_id: feedback.event_id,\n sent_at: new Date().toISOString(),\n ...(metadata &&\n metadata.sdk && {\n sdk: {\n name: metadata.sdk.name,\n version: metadata.sdk.version,\n },\n }),\n ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }),\n };\n const item = createUserFeedbackEnvelopeItem(feedback);\n\n return createEnvelope(headers, [item]);\n}\n\nfunction createUserFeedbackEnvelopeItem(feedback) {\n const feedbackHeaders = {\n type: 'user_report',\n };\n return [feedbackHeaders, feedback];\n}\n\nexport { createUserFeedbackEnvelope };\n","import { DEBUG_BUILD } from '../debug-build.js';\nimport { logger } from '../logger.js';\nimport { getFunctionName } from '../stacktrace.js';\n\n// We keep the handlers globally\nconst handlers = {};\nconst instrumented = {};\n\n/** Add a handler function. */\nfunction addHandler(type, handler) {\n handlers[type] = handlers[type] || [];\n (handlers[type] ).push(handler);\n}\n\n/**\n * Reset all instrumentation handlers.\n * This can be used by tests to ensure we have a clean slate of instrumentation handlers.\n */\nfunction resetInstrumentationHandlers() {\n Object.keys(handlers).forEach(key => {\n handlers[key ] = undefined;\n });\n}\n\n/** Maybe run an instrumentation function, unless it was already called. */\nfunction maybeInstrument(type, instrumentFn) {\n if (!instrumented[type]) {\n instrumented[type] = true;\n try {\n instrumentFn();\n } catch (e) {\n DEBUG_BUILD && logger.error(`Error while instrumenting ${type}`, e);\n }\n }\n}\n\n/** Trigger handlers for a given instrumentation type. */\nfunction triggerHandlers(type, data) {\n const typeHandlers = type && handlers[type];\n if (!typeHandlers) {\n return;\n }\n\n for (const handler of typeHandlers) {\n try {\n handler(data);\n } catch (e) {\n DEBUG_BUILD &&\n logger.error(\n `Error while triggering instrumentation handler.\\nType: ${type}\\nName: ${getFunctionName(handler)}\\nError:`,\n e,\n );\n }\n }\n}\n\nexport { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers };\n","import { GLOBAL_OBJ } from '@sentry/core';\n\nconst WINDOW = GLOBAL_OBJ\n\n;\n\nexport { WINDOW };\n","import { addHandler, maybeInstrument, triggerHandlers, fill, addNonEnumerableProperty, uuid4 } from '@sentry/core';\nimport { WINDOW } from '../types.js';\n\nconst DEBOUNCE_DURATION = 1000;\n\nlet debounceTimerID;\nlet lastCapturedEventType;\nlet lastCapturedEventTargetId;\n\n/**\n * Add an instrumentation handler for when a click or a keypress happens.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nfunction addClickKeypressInstrumentationHandler(handler) {\n const type = 'dom';\n addHandler(type, handler);\n maybeInstrument(type, instrumentDOM);\n}\n\n/** Exported for tests only. */\nfunction instrumentDOM() {\n if (!WINDOW.document) {\n return;\n }\n\n // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom\n // handlers. (Normally we have only one, which captures a breadcrumb for each click or keypress.) Do this before\n // we instrument `addEventListener` so that we don't end up attaching this handler twice.\n const triggerDOMHandler = triggerHandlers.bind(null, 'dom');\n const globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);\n WINDOW.document.addEventListener('click', globalDOMEventHandler, false);\n WINDOW.document.addEventListener('keypress', globalDOMEventHandler, false);\n\n // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled\n // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That\n // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler\n // could potentially prevent the event from bubbling up to our global listeners. This way, our handler are still\n // guaranteed to fire at least once.)\n ['EventTarget', 'Node'].forEach((target) => {\n const globalObject = WINDOW ;\n const targetObj = globalObject[target];\n const proto = targetObj && targetObj.prototype;\n\n // eslint-disable-next-line no-prototype-builtins\n if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (originalAddEventListener) {\n return function ( type, listener, options) {\n if (type === 'click' || type == 'keypress') {\n try {\n const handlers = (this.__sentry_instrumentation_handlers__ =\n this.__sentry_instrumentation_handlers__ || {});\n const handlerForType = (handlers[type] = handlers[type] || { refCount: 0 });\n\n if (!handlerForType.handler) {\n const handler = makeDOMEventHandler(triggerDOMHandler);\n handlerForType.handler = handler;\n originalAddEventListener.call(this, type, handler, options);\n }\n\n handlerForType.refCount++;\n } catch (e) {\n // Accessing dom properties is always fragile.\n // Also allows us to skip `addEventListeners` calls with no proper `this` context.\n }\n }\n\n return originalAddEventListener.call(this, type, listener, options);\n };\n });\n\n fill(\n proto,\n 'removeEventListener',\n function (originalRemoveEventListener) {\n return function ( type, listener, options) {\n if (type === 'click' || type == 'keypress') {\n try {\n const handlers = this.__sentry_instrumentation_handlers__ || {};\n const handlerForType = handlers[type];\n\n if (handlerForType) {\n handlerForType.refCount--;\n // If there are no longer any custom handlers of the current type on this element, we can remove ours, too.\n if (handlerForType.refCount <= 0) {\n originalRemoveEventListener.call(this, type, handlerForType.handler, options);\n handlerForType.handler = undefined;\n delete handlers[type]; // eslint-disable-line @typescript-eslint/no-dynamic-delete\n }\n\n // If there are no longer any custom handlers of any type on this element, cleanup everything.\n if (Object.keys(handlers).length === 0) {\n delete this.__sentry_instrumentation_handlers__;\n }\n }\n } catch (e) {\n // Accessing dom properties is always fragile.\n // Also allows us to skip `addEventListeners` calls with no proper `this` context.\n }\n }\n\n return originalRemoveEventListener.call(this, type, listener, options);\n };\n },\n );\n });\n}\n\n/**\n * Check whether the event is similar to the last captured one. For example, two click events on the same button.\n */\nfunction isSimilarToLastCapturedEvent(event) {\n // If both events have different type, then user definitely performed two separate actions. e.g. click + keypress.\n if (event.type !== lastCapturedEventType) {\n return false;\n }\n\n try {\n // If both events have the same type, it's still possible that actions were performed on different targets.\n // e.g. 2 clicks on different buttons.\n if (!event.target || (event.target )._sentryId !== lastCapturedEventTargetId) {\n return false;\n }\n } catch (e) {\n // just accessing `target` property can throw an exception in some rare circumstances\n // see: https://github.com/getsentry/sentry-javascript/issues/838\n }\n\n // If both events have the same type _and_ same `target` (an element which triggered an event, _not necessarily_\n // to which an event listener was attached), we treat them as the same action, as we want to capture\n // only one breadcrumb. e.g. multiple clicks on the same button, or typing inside a user input box.\n return true;\n}\n\n/**\n * Decide whether an event should be captured.\n * @param event event to be captured\n */\nfunction shouldSkipDOMEvent(eventType, target) {\n // We are only interested in filtering `keypress` events for now.\n if (eventType !== 'keypress') {\n return false;\n }\n\n if (!target || !target.tagName) {\n return true;\n }\n\n // Only consider keypress events on actual input elements. This will disregard keypresses targeting body\n // e.g.tabbing through elements, hotkeys, etc.\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Wraps addEventListener to capture UI breadcrumbs\n */\nfunction makeDOMEventHandler(\n handler,\n globalListener = false,\n) {\n return (event) => {\n // It's possible this handler might trigger multiple times for the same\n // event (e.g. event propagation through node ancestors).\n // Ignore if we've already captured that event.\n if (!event || event['_sentryCaptured']) {\n return;\n }\n\n const target = getEventTarget(event);\n\n // We always want to skip _some_ events.\n if (shouldSkipDOMEvent(event.type, target)) {\n return;\n }\n\n // Mark event as \"seen\"\n addNonEnumerableProperty(event, '_sentryCaptured', true);\n\n if (target && !target._sentryId) {\n // Add UUID to event target so we can identify if\n addNonEnumerableProperty(target, '_sentryId', uuid4());\n }\n\n const name = event.type === 'keypress' ? 'input' : event.type;\n\n // If there is no last captured event, it means that we can safely capture the new event and store it for future comparisons.\n // If there is a last captured event, see if the new event is different enough to treat it as a unique one.\n // If that's the case, emit the previous event and store locally the newly-captured DOM event.\n if (!isSimilarToLastCapturedEvent(event)) {\n const handlerData = { event, name, global: globalListener };\n handler(handlerData);\n lastCapturedEventType = event.type;\n lastCapturedEventTargetId = target ? target._sentryId : undefined;\n }\n\n // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.\n clearTimeout(debounceTimerID);\n debounceTimerID = WINDOW.setTimeout(() => {\n lastCapturedEventTargetId = undefined;\n lastCapturedEventType = undefined;\n }, DEBOUNCE_DURATION);\n };\n}\n\nfunction getEventTarget(event) {\n try {\n return event.target ;\n } catch (e) {\n // just accessing `target` property can throw an exception in some rare circumstances\n // see: https://github.com/getsentry/sentry-javascript/issues/838\n return null;\n }\n}\n\nexport { addClickKeypressInstrumentationHandler, instrumentDOM };\n","import { addHandler, maybeInstrument, timestampInSeconds, isString, triggerHandlers } from '@sentry/core';\nimport { WINDOW } from '../types.js';\n\nconst SENTRY_XHR_DATA_KEY = '__sentry_xhr_v3__';\n\n/**\n * Add an instrumentation handler for when an XHR request happens.\n * The handler function is called once when the request starts and once when it ends,\n * which can be identified by checking if it has an `endTimestamp`.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nfunction addXhrInstrumentationHandler(handler) {\n const type = 'xhr';\n addHandler(type, handler);\n maybeInstrument(type, instrumentXHR);\n}\n\n/** Exported only for tests. */\nfunction instrumentXHR() {\n if (!(WINDOW ).XMLHttpRequest) {\n return;\n }\n\n const xhrproto = XMLHttpRequest.prototype;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n xhrproto.open = new Proxy(xhrproto.open, {\n apply(originalOpen, xhrOpenThisArg, xhrOpenArgArray) {\n // NOTE: If you are a Sentry user, and you are seeing this stack frame,\n // it means the error, that was caused by your XHR call did not\n // have a stack trace. If you are using HttpClient integration,\n // this is the expected behavior, as we are using this virtual error to capture\n // the location of your XHR call, and group your HttpClient events accordingly.\n const virtualError = new Error();\n\n const startTimestamp = timestampInSeconds() * 1000;\n\n // open() should always be called with two or more arguments\n // But to be on the safe side, we actually validate this and bail out if we don't have a method & url\n const method = isString(xhrOpenArgArray[0]) ? xhrOpenArgArray[0].toUpperCase() : undefined;\n const url = parseUrl(xhrOpenArgArray[1]);\n\n if (!method || !url) {\n return originalOpen.apply(xhrOpenThisArg, xhrOpenArgArray);\n }\n\n xhrOpenThisArg[SENTRY_XHR_DATA_KEY] = {\n method,\n url,\n request_headers: {},\n };\n\n // if Sentry key appears in URL, don't capture it as a request\n if (method === 'POST' && url.match(/sentry_key/)) {\n xhrOpenThisArg.__sentry_own_request__ = true;\n }\n\n const onreadystatechangeHandler = () => {\n // For whatever reason, this is not the same instance here as from the outer method\n const xhrInfo = xhrOpenThisArg[SENTRY_XHR_DATA_KEY];\n\n if (!xhrInfo) {\n return;\n }\n\n if (xhrOpenThisArg.readyState === 4) {\n try {\n // touching statusCode in some platforms throws\n // an exception\n xhrInfo.status_code = xhrOpenThisArg.status;\n } catch (e) {\n /* do nothing */\n }\n\n const handlerData = {\n endTimestamp: timestampInSeconds() * 1000,\n startTimestamp,\n xhr: xhrOpenThisArg,\n virtualError,\n };\n triggerHandlers('xhr', handlerData);\n }\n };\n\n if ('onreadystatechange' in xhrOpenThisArg && typeof xhrOpenThisArg.onreadystatechange === 'function') {\n xhrOpenThisArg.onreadystatechange = new Proxy(xhrOpenThisArg.onreadystatechange, {\n apply(originalOnreadystatechange, onreadystatechangeThisArg, onreadystatechangeArgArray) {\n onreadystatechangeHandler();\n return originalOnreadystatechange.apply(onreadystatechangeThisArg, onreadystatechangeArgArray);\n },\n });\n } else {\n xhrOpenThisArg.addEventListener('readystatechange', onreadystatechangeHandler);\n }\n\n // Intercepting `setRequestHeader` to access the request headers of XHR instance.\n // This will only work for user/library defined headers, not for the default/browser-assigned headers.\n // Request cookies are also unavailable for XHR, as `Cookie` header can't be defined by `setRequestHeader`.\n xhrOpenThisArg.setRequestHeader = new Proxy(xhrOpenThisArg.setRequestHeader, {\n apply(\n originalSetRequestHeader,\n setRequestHeaderThisArg,\n setRequestHeaderArgArray,\n ) {\n const [header, value] = setRequestHeaderArgArray;\n\n const xhrInfo = setRequestHeaderThisArg[SENTRY_XHR_DATA_KEY];\n\n if (xhrInfo && isString(header) && isString(value)) {\n xhrInfo.request_headers[header.toLowerCase()] = value;\n }\n\n return originalSetRequestHeader.apply(setRequestHeaderThisArg, setRequestHeaderArgArray);\n },\n });\n\n return originalOpen.apply(xhrOpenThisArg, xhrOpenArgArray);\n },\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n xhrproto.send = new Proxy(xhrproto.send, {\n apply(originalSend, sendThisArg, sendArgArray) {\n const sentryXhrData = sendThisArg[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return originalSend.apply(sendThisArg, sendArgArray);\n }\n\n if (sendArgArray[0] !== undefined) {\n sentryXhrData.body = sendArgArray[0];\n }\n\n const handlerData = {\n startTimestamp: timestampInSeconds() * 1000,\n xhr: sendThisArg,\n };\n triggerHandlers('xhr', handlerData);\n\n return originalSend.apply(sendThisArg, sendArgArray);\n },\n });\n}\n\nfunction parseUrl(url) {\n if (isString(url)) {\n return url;\n }\n\n try {\n // url can be a string or URL\n // but since URL is not available in IE11, we do not check for it,\n // but simply assume it is an URL and return `toString()` from it (which returns the full URL)\n // If that fails, we just return undefined\n return (url ).toString();\n } catch (e2) {} // eslint-disable-line no-empty\n\n return undefined;\n}\n\nexport { SENTRY_XHR_DATA_KEY, addXhrInstrumentationHandler, instrumentXHR };\n","import { GLOBAL_OBJ } from '../worldwide.js';\n\n// Based on https://github.com/angular/angular.js/pull/13945/files\n// The MIT License\n\n\nconst WINDOW = GLOBAL_OBJ ;\n\n/**\n * Tells whether current environment supports History API\n * {@link supportsHistory}.\n *\n * @returns Answer to the given question.\n */\nfunction supportsHistory() {\n // NOTE: in Chrome App environment, touching history.pushState, *even inside\n // a try/catch block*, will cause Chrome to output an error to console.error\n // borrowed from: https://github.com/angular/angular.js/pull/13945/files\n // TODO(v9): Remove this custom check, it is pretty old and likely not needed anymore\n const chromeVar = (WINDOW ).chrome;\n const isChromePackagedApp = chromeVar && chromeVar.app && chromeVar.app.runtime;\n const hasHistoryApi = 'history' in WINDOW && !!WINDOW.history.pushState && !!WINDOW.history.replaceState;\n\n return !isChromePackagedApp && hasHistoryApi;\n}\n\nexport { supportsHistory };\n","import { addHandler, maybeInstrument, supportsHistory, triggerHandlers, fill } from '@sentry/core';\nimport { WINDOW } from '../types.js';\n\nlet lastHref;\n\n/**\n * Add an instrumentation handler for when a fetch request happens.\n * The handler function is called once when the request starts and once when it ends,\n * which can be identified by checking if it has an `endTimestamp`.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nfunction addHistoryInstrumentationHandler(handler) {\n const type = 'history';\n addHandler(type, handler);\n maybeInstrument(type, instrumentHistory);\n}\n\nfunction instrumentHistory() {\n if (!supportsHistory()) {\n return;\n }\n\n const oldOnPopState = WINDOW.onpopstate;\n WINDOW.onpopstate = function ( ...args) {\n const to = WINDOW.location.href;\n // keep track of the current URL state, as we always receive only the updated state\n const from = lastHref;\n lastHref = to;\n const handlerData = { from, to };\n triggerHandlers('history', handlerData);\n if (oldOnPopState) {\n // Apparently this can throw in Firefox when incorrectly implemented plugin is installed.\n // https://github.com/getsentry/sentry-javascript/issues/3344\n // https://github.com/bugsnag/bugsnag-js/issues/469\n try {\n return oldOnPopState.apply(this, args);\n } catch (_oO) {\n // no-empty\n }\n }\n };\n\n function historyReplacementFunction(originalHistoryFunction) {\n return function ( ...args) {\n const url = args.length > 2 ? args[2] : undefined;\n if (url) {\n // coerce to string (this is what pushState does)\n const from = lastHref;\n const to = String(url);\n // keep track of the current URL state, as we always receive only the updated state\n lastHref = to;\n const handlerData = { from, to };\n triggerHandlers('history', handlerData);\n }\n return originalHistoryFunction.apply(this, args);\n };\n }\n\n fill(WINDOW.history, 'pushState', historyReplacementFunction);\n fill(WINDOW.history, 'replaceState', historyReplacementFunction);\n}\n\nexport { addHistoryInstrumentationHandler };\n","import { CONSOLE_LEVELS, originalConsoleMethods } from '../logger.js';\nimport { fill } from '../object.js';\nimport { GLOBAL_OBJ } from '../worldwide.js';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers.js';\n\n/**\n * Add an instrumentation handler for when a console.xxx method is called.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nfunction addConsoleInstrumentationHandler(handler) {\n const type = 'console';\n addHandler(type, handler);\n maybeInstrument(type, instrumentConsole);\n}\n\nfunction instrumentConsole() {\n if (!('console' in GLOBAL_OBJ)) {\n return;\n }\n\n CONSOLE_LEVELS.forEach(function (level) {\n if (!(level in GLOBAL_OBJ.console)) {\n return;\n }\n\n fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod) {\n originalConsoleMethods[level] = originalConsoleMethod;\n\n return function (...args) {\n const handlerData = { args, level };\n triggerHandlers('console', handlerData);\n\n const log = originalConsoleMethods[level];\n log && log.apply(GLOBAL_OBJ.console, args);\n };\n });\n });\n}\n\nexport { addConsoleInstrumentationHandler };\n","import { isError } from '../is.js';\nimport { fill, addNonEnumerableProperty } from '../object.js';\nimport { supportsNativeFetch } from '../supports.js';\nimport { timestampInSeconds } from '../time.js';\nimport { GLOBAL_OBJ } from '../worldwide.js';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers.js';\n\n/**\n * Add an instrumentation handler for when a fetch request happens.\n * The handler function is called once when the request starts and once when it ends,\n * which can be identified by checking if it has an `endTimestamp`.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nfunction addFetchInstrumentationHandler(\n handler,\n skipNativeFetchCheck,\n) {\n const type = 'fetch';\n addHandler(type, handler);\n maybeInstrument(type, () => instrumentFetch(undefined, skipNativeFetchCheck));\n}\n\n/**\n * Add an instrumentation handler for long-lived fetch requests, like consuming server-sent events (SSE) via fetch.\n * The handler will resolve the request body and emit the actual `endTimestamp`, so that the\n * span can be updated accordingly.\n *\n * Only used internally\n * @hidden\n */\nfunction addFetchEndInstrumentationHandler(handler) {\n const type = 'fetch-body-resolved';\n addHandler(type, handler);\n maybeInstrument(type, () => instrumentFetch(streamHandler));\n}\n\nfunction instrumentFetch(onFetchResolved, skipNativeFetchCheck = false) {\n if (skipNativeFetchCheck && !supportsNativeFetch()) {\n return;\n }\n\n fill(GLOBAL_OBJ, 'fetch', function (originalFetch) {\n return function (...args) {\n // We capture the error right here and not in the Promise error callback because Safari (and probably other\n // browsers too) will wipe the stack trace up to this point, only leaving us with this file which is useless.\n\n // NOTE: If you are a Sentry user, and you are seeing this stack frame,\n // it means the error, that was caused by your fetch call did not\n // have a stack trace, so the SDK backfilled the stack trace so\n // you can see which fetch call failed.\n const virtualError = new Error();\n\n const { method, url } = parseFetchArgs(args);\n const handlerData = {\n args,\n fetchData: {\n method,\n url,\n },\n startTimestamp: timestampInSeconds() * 1000,\n // // Adding the error to be able to fingerprint the failed fetch event in HttpClient instrumentation\n virtualError,\n };\n\n // if there is no callback, fetch is instrumented directly\n if (!onFetchResolved) {\n triggerHandlers('fetch', {\n ...handlerData,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return originalFetch.apply(GLOBAL_OBJ, args).then(\n async (response) => {\n if (onFetchResolved) {\n onFetchResolved(response);\n } else {\n triggerHandlers('fetch', {\n ...handlerData,\n endTimestamp: timestampInSeconds() * 1000,\n response,\n });\n }\n\n return response;\n },\n (error) => {\n triggerHandlers('fetch', {\n ...handlerData,\n endTimestamp: timestampInSeconds() * 1000,\n error,\n });\n\n if (isError(error) && error.stack === undefined) {\n // NOTE: If you are a Sentry user, and you are seeing this stack frame,\n // it means the error, that was caused by your fetch call did not\n // have a stack trace, so the SDK backfilled the stack trace so\n // you can see which fetch call failed.\n error.stack = virtualError.stack;\n addNonEnumerableProperty(error, 'framesToPop', 1);\n }\n\n // NOTE: If you are a Sentry user, and you are seeing this stack frame,\n // it means the sentry.javascript SDK caught an error invoking your application code.\n // This is expected behavior and NOT indicative of a bug with sentry.javascript.\n throw error;\n },\n );\n };\n });\n}\n\nasync function resolveResponse(res, onFinishedResolving) {\n if (res && res.body) {\n const body = res.body;\n const responseReader = body.getReader();\n\n // Define a maximum duration after which we just cancel\n const maxFetchDurationTimeout = setTimeout(\n () => {\n body.cancel().then(null, () => {\n // noop\n });\n },\n 90 * 1000, // 90s\n );\n\n let readingActive = true;\n while (readingActive) {\n let chunkTimeout;\n try {\n // abort reading if read op takes more than 5s\n chunkTimeout = setTimeout(() => {\n body.cancel().then(null, () => {\n // noop on error\n });\n }, 5000);\n\n // This .read() call will reject/throw when we abort due to timeouts through `body.cancel()`\n const { done } = await responseReader.read();\n\n clearTimeout(chunkTimeout);\n\n if (done) {\n onFinishedResolving();\n readingActive = false;\n }\n } catch (error) {\n readingActive = false;\n } finally {\n clearTimeout(chunkTimeout);\n }\n }\n\n clearTimeout(maxFetchDurationTimeout);\n\n responseReader.releaseLock();\n body.cancel().then(null, () => {\n // noop on error\n });\n }\n}\n\nfunction streamHandler(response) {\n // clone response for awaiting stream\n let clonedResponseForResolving;\n try {\n clonedResponseForResolving = response.clone();\n } catch (e) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n resolveResponse(clonedResponseForResolving, () => {\n triggerHandlers('fetch-body-resolved', {\n endTimestamp: timestampInSeconds() * 1000,\n response,\n });\n });\n}\n\nfunction hasProp(obj, prop) {\n return !!obj && typeof obj === 'object' && !!(obj )[prop];\n}\n\nfunction getUrlFromResource(resource) {\n if (typeof resource === 'string') {\n return resource;\n }\n\n if (!resource) {\n return '';\n }\n\n if (hasProp(resource, 'url')) {\n return resource.url;\n }\n\n if (resource.toString) {\n return resource.toString();\n }\n\n return '';\n}\n\n/**\n * Parses the fetch arguments to find the used Http method and the url of the request.\n * Exported for tests only.\n */\nfunction parseFetchArgs(fetchArgs) {\n if (fetchArgs.length === 0) {\n return { method: 'GET', url: '' };\n }\n\n if (fetchArgs.length === 2) {\n const [url, options] = fetchArgs ;\n\n return {\n url: getUrlFromResource(url),\n method: hasProp(options, 'method') ? String(options.method).toUpperCase() : 'GET',\n };\n }\n\n const arg = fetchArgs[0];\n return {\n url: getUrlFromResource(arg ),\n method: hasProp(arg, 'method') ? String(arg.method).toUpperCase() : 'GET',\n };\n}\n\nexport { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler, parseFetchArgs };\n","import { getClient, getIsolationScope } from './currentScopes.js';\nimport { consoleSandbox } from './utils-hoist/logger.js';\nimport { dateTimestampInSeconds } from './utils-hoist/time.js';\n\n/**\n * Default maximum number of breadcrumbs added to an event. Can be overwritten\n * with {@link Options.maxBreadcrumbs}.\n */\nconst DEFAULT_BREADCRUMBS = 100;\n\n/**\n * Records a new breadcrumb which will be attached to future events.\n *\n * Breadcrumbs will be added to subsequent events to provide more context on\n * user's actions prior to an error or crash.\n */\nfunction addBreadcrumb(breadcrumb, hint) {\n const client = getClient();\n const isolationScope = getIsolationScope();\n\n if (!client) return;\n\n const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } = client.getOptions();\n\n if (maxBreadcrumbs <= 0) return;\n\n const timestamp = dateTimestampInSeconds();\n const mergedBreadcrumb = { timestamp, ...breadcrumb };\n const finalBreadcrumb = beforeBreadcrumb\n ? (consoleSandbox(() => beforeBreadcrumb(mergedBreadcrumb, hint)) )\n : mergedBreadcrumb;\n\n if (finalBreadcrumb === null) return;\n\n if (client.emit) {\n client.emit('beforeAddBreadcrumb', finalBreadcrumb, hint);\n }\n\n isolationScope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);\n}\n\nexport { addBreadcrumb };\n","/**\n * @deprecated This variable has been deprecated and will be removed in the next major version.\n */\nconst validSeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'];\n\n/**\n * Converts a string-based level into a `SeverityLevel`, normalizing it along the way.\n *\n * @param level String representation of desired `SeverityLevel`.\n * @returns The `SeverityLevel` corresponding to the given string, or 'log' if the string isn't a valid level.\n */\nfunction severityLevelFromString(level) {\n return (\n level === 'warn' ? 'warning' : ['fatal', 'error', 'warning', 'log', 'info', 'debug'].includes(level) ? level : 'log'\n ) ;\n}\n\nexport { severityLevelFromString, validSeverityLevels };\n","/**\n * Determine a breadcrumb's log level (only `warning` or `error`) based on an HTTP status code.\n */\nfunction getBreadcrumbLogLevelFromHttpStatusCode(statusCode) {\n // NOTE: undefined defaults to 'info' in Sentry\n if (statusCode === undefined) {\n return undefined;\n } else if (statusCode >= 400 && statusCode < 500) {\n return 'warning';\n } else if (statusCode >= 500) {\n return 'error';\n } else {\n return undefined;\n }\n}\n\nexport { getBreadcrumbLogLevelFromHttpStatusCode };\n","/**\n * Parses string form of URL into an object\n * // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B\n * // intentionally using regex and not href parsing trick because React Native and other\n * // environments where DOM might not be available\n * @returns parsed URL object\n */\nfunction parseUrl(url) {\n if (!url) {\n return {};\n }\n\n const match = url.match(/^(([^:/?#]+):)?(\\/\\/([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$/);\n\n if (!match) {\n return {};\n }\n\n // coerce to undefined values to empty string so we don't get 'undefined'\n const query = match[6] || '';\n const fragment = match[8] || '';\n return {\n host: match[4],\n path: match[5],\n protocol: match[2],\n search: query,\n hash: fragment,\n relative: match[5] + query + fragment, // everything minus origin\n };\n}\n\n/**\n * Strip the query string and fragment off of a given URL or path (if present)\n *\n * @param urlPath Full URL or path, including possible query string and/or fragment\n * @returns URL or path without query string or fragment\n */\nfunction stripUrlQueryAndFragment(urlPath) {\n return (urlPath.split(/[?#]/, 1) )[0];\n}\n\n/**\n * Returns number of URL segments of a passed string URL.\n *\n * @deprecated This function will be removed in the next major version.\n */\n// TODO(v9): Hoist this function into the places where we use it. (as it stands only react router v6 instrumentation)\nfunction getNumberOfUrlSegments(url) {\n // split at '/' or at '\\/' to split regex urls correctly\n return url.split(/\\\\?\\//).filter(s => s.length > 0 && s !== ',').length;\n}\n\n/**\n * Takes a URL object and returns a sanitized string which is safe to use as span name\n * see: https://develop.sentry.dev/sdk/data-handling/#structuring-data\n */\nfunction getSanitizedUrlString(url) {\n const { protocol, host, path } = url;\n\n const filteredHost =\n (host &&\n host\n // Always filter out authority\n .replace(/^.*@/, '[filtered]:[filtered]@')\n // Don't show standard :80 (http) and :443 (https) ports to reduce the noise\n // TODO: Use new URL global if it exists\n .replace(/(:80)$/, '')\n .replace(/(:443)$/, '')) ||\n '';\n\n return `${protocol ? `${protocol}://` : ''}${filteredHost}${path}`;\n}\n\nexport { getNumberOfUrlSegments, getSanitizedUrlString, parseUrl, stripUrlQueryAndFragment };\n","import { addClickKeypressInstrumentationHandler, addXhrInstrumentationHandler, addHistoryInstrumentationHandler, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';\nimport { defineIntegration, addConsoleInstrumentationHandler, addFetchInstrumentationHandler, getClient, addBreadcrumb, getEventDescription, logger, htmlTreeAsString, getComponentName, severityLevelFromString, safeJoin, getBreadcrumbLogLevelFromHttpStatusCode, parseUrl } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { WINDOW } from '../helpers.js';\n\n/* eslint-disable max-lines */\n\n\n/** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */\nconst MAX_ALLOWED_STRING_LENGTH = 1024;\n\nconst INTEGRATION_NAME = 'Breadcrumbs';\n\nconst _breadcrumbsIntegration = ((options = {}) => {\n const _options = {\n console: true,\n dom: true,\n fetch: true,\n history: true,\n sentry: true,\n xhr: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n if (_options.console) {\n addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));\n }\n if (_options.dom) {\n addClickKeypressInstrumentationHandler(_getDomBreadcrumbHandler(client, _options.dom));\n }\n if (_options.xhr) {\n addXhrInstrumentationHandler(_getXhrBreadcrumbHandler(client));\n }\n if (_options.fetch) {\n addFetchInstrumentationHandler(_getFetchBreadcrumbHandler(client));\n }\n if (_options.history) {\n addHistoryInstrumentationHandler(_getHistoryBreadcrumbHandler(client));\n }\n if (_options.sentry) {\n client.on('beforeSendEvent', _getSentryBreadcrumbHandler(client));\n }\n },\n };\n}) ;\n\nconst breadcrumbsIntegration = defineIntegration(_breadcrumbsIntegration);\n\n/**\n * Adds a breadcrumb for Sentry events or transactions if this option is enabled.\n */\nfunction _getSentryBreadcrumbHandler(client) {\n return function addSentryBreadcrumb(event) {\n if (getClient() !== client) {\n return;\n }\n\n addBreadcrumb(\n {\n category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,\n event_id: event.event_id,\n level: event.level,\n message: getEventDescription(event),\n },\n {\n event,\n },\n );\n };\n}\n\n/**\n * A HOC that creates a function that creates breadcrumbs from DOM API calls.\n * This is a HOC so that we get access to dom options in the closure.\n */\nfunction _getDomBreadcrumbHandler(\n client,\n dom,\n) {\n return function _innerDomBreadcrumb(handlerData) {\n if (getClient() !== client) {\n return;\n }\n\n let target;\n let componentName;\n let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;\n\n let maxStringLength =\n typeof dom === 'object' && typeof dom.maxStringLength === 'number' ? dom.maxStringLength : undefined;\n if (maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH) {\n DEBUG_BUILD &&\n logger.warn(\n `\\`dom.maxStringLength\\` cannot exceed ${MAX_ALLOWED_STRING_LENGTH}, but a value of ${maxStringLength} was configured. Sentry will use ${MAX_ALLOWED_STRING_LENGTH} instead.`,\n );\n maxStringLength = MAX_ALLOWED_STRING_LENGTH;\n }\n\n if (typeof keyAttrs === 'string') {\n keyAttrs = [keyAttrs];\n }\n\n // Accessing event.target can throw (see getsentry/raven-js#838, #768)\n try {\n const event = handlerData.event ;\n const element = _isEvent(event) ? event.target : event;\n\n target = htmlTreeAsString(element, { keyAttrs, maxStringLength });\n componentName = getComponentName(element);\n } catch (e) {\n target = '';\n }\n\n if (target.length === 0) {\n return;\n }\n\n const breadcrumb = {\n category: `ui.${handlerData.name}`,\n message: target,\n };\n\n if (componentName) {\n breadcrumb.data = { 'ui.component_name': componentName };\n }\n\n addBreadcrumb(breadcrumb, {\n event: handlerData.event,\n name: handlerData.name,\n global: handlerData.global,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from console API calls\n */\nfunction _getConsoleBreadcrumbHandler(client) {\n return function _consoleBreadcrumb(handlerData) {\n if (getClient() !== client) {\n return;\n }\n\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: handlerData.args,\n logger: 'console',\n },\n level: severityLevelFromString(handlerData.level),\n message: safeJoin(handlerData.args, ' '),\n };\n\n if (handlerData.level === 'assert') {\n if (handlerData.args[0] === false) {\n breadcrumb.message = `Assertion failed: ${safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;\n breadcrumb.data.arguments = handlerData.args.slice(1);\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n addBreadcrumb(breadcrumb, {\n input: handlerData.args,\n level: handlerData.level,\n });\n };\n}\n\n/**\n * Creates breadcrumbs from XHR API calls\n */\nfunction _getXhrBreadcrumbHandler(client) {\n return function _xhrBreadcrumb(handlerData) {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n const sentryXhrData = handlerData.xhr[SENTRY_XHR_DATA_KEY];\n\n // We only capture complete, non-sentry requests\n if (!startTimestamp || !endTimestamp || !sentryXhrData) {\n return;\n }\n\n const { method, url, status_code, body } = sentryXhrData;\n\n const data = {\n method,\n url,\n status_code,\n };\n\n const hint = {\n xhr: handlerData.xhr,\n input: body,\n startTimestamp,\n endTimestamp,\n };\n\n const level = getBreadcrumbLogLevelFromHttpStatusCode(status_code);\n\n addBreadcrumb(\n {\n category: 'xhr',\n data,\n type: 'http',\n level,\n },\n hint,\n );\n };\n}\n\n/**\n * Creates breadcrumbs from fetch API calls\n */\nfunction _getFetchBreadcrumbHandler(client) {\n return function _fetchBreadcrumb(handlerData) {\n if (getClient() !== client) {\n return;\n }\n\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {\n // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)\n return;\n }\n\n if (handlerData.error) {\n const data = handlerData.fetchData;\n const hint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response ;\n const data = {\n ...handlerData.fetchData,\n status_code: response && response.status,\n };\n const hint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(data.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data,\n type: 'http',\n level,\n },\n hint,\n );\n }\n };\n}\n\n/**\n * Creates breadcrumbs from history API calls\n */\nfunction _getHistoryBreadcrumbHandler(client) {\n return function _historyBreadcrumb(handlerData) {\n if (getClient() !== client) {\n return;\n }\n\n let from = handlerData.from;\n let to = handlerData.to;\n const parsedLoc = parseUrl(WINDOW.location.href);\n let parsedFrom = from ? parseUrl(from) : undefined;\n const parsedTo = parseUrl(to);\n\n // Initial pushState doesn't provide `from` information\n if (!parsedFrom || !parsedFrom.path) {\n parsedFrom = parsedLoc;\n }\n\n // Use only the path component of the URL if the URL matches the current\n // document (almost all the time when using pushState)\n if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {\n to = parsedTo.relative;\n }\n if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {\n from = parsedFrom.relative;\n }\n\n addBreadcrumb({\n category: 'navigation',\n data: {\n from,\n to,\n },\n });\n };\n}\n\nfunction _isEvent(event) {\n return !!event && !!(event ).target;\n}\n\nexport { breadcrumbsIntegration };\n","import { defineIntegration, fill, getFunctionName, getOriginalFunction } from '@sentry/core';\nimport { WINDOW, wrap } from '../helpers.js';\n\nconst DEFAULT_EVENT_TARGET = [\n 'EventTarget',\n 'Window',\n 'Node',\n 'ApplicationCache',\n 'AudioTrackList',\n 'BroadcastChannel',\n 'ChannelMergerNode',\n 'CryptoOperation',\n 'EventSource',\n 'FileReader',\n 'HTMLUnknownElement',\n 'IDBDatabase',\n 'IDBRequest',\n 'IDBTransaction',\n 'KeyOperation',\n 'MediaController',\n 'MessagePort',\n 'ModalWindow',\n 'Notification',\n 'SVGElementInstance',\n 'Screen',\n 'SharedWorker',\n 'TextTrack',\n 'TextTrackCue',\n 'TextTrackList',\n 'WebSocket',\n 'WebSocketWorker',\n 'Worker',\n 'XMLHttpRequest',\n 'XMLHttpRequestEventTarget',\n 'XMLHttpRequestUpload',\n];\n\nconst INTEGRATION_NAME = 'BrowserApiErrors';\n\nconst _browserApiErrorsIntegration = ((options = {}) => {\n const _options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n // TODO: This currently only works for the first client this is setup\n // We may want to adjust this to check for client etc.\n setupOnce() {\n if (_options.setTimeout) {\n fill(WINDOW, 'setTimeout', _wrapTimeFunction);\n }\n\n if (_options.setInterval) {\n fill(WINDOW, 'setInterval', _wrapTimeFunction);\n }\n\n if (_options.requestAnimationFrame) {\n fill(WINDOW, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (_options.XMLHttpRequest && 'XMLHttpRequest' in WINDOW) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = _options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(_wrapEventTarget);\n }\n },\n };\n}) ;\n\n/**\n * Wrap timer functions and event targets to catch errors and provide better meta data.\n */\nconst browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration);\n\nfunction _wrapTimeFunction(original) {\n return function ( ...args) {\n const originalCallback = args[0];\n args[0] = wrap(originalCallback, {\n mechanism: {\n data: { function: getFunctionName(original) },\n handled: false,\n type: 'instrument',\n },\n });\n return original.apply(this, args);\n };\n}\n\nfunction _wrapRAF(original) {\n return function ( callback) {\n return original.apply(this, [\n wrap(callback, {\n mechanism: {\n data: {\n function: 'requestAnimationFrame',\n handler: getFunctionName(original),\n },\n handled: false,\n type: 'instrument',\n },\n }),\n ]);\n };\n}\n\nfunction _wrapXHR(originalSend) {\n return function ( ...args) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const xhr = this;\n const xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];\n\n xmlHttpRequestProps.forEach(prop => {\n if (prop in xhr && typeof xhr[prop] === 'function') {\n fill(xhr, prop, function (original) {\n const wrapOptions = {\n mechanism: {\n data: {\n function: prop,\n handler: getFunctionName(original),\n },\n handled: false,\n type: 'instrument',\n },\n };\n\n // If Instrument integration has been called before BrowserApiErrors, get the name of original function\n const originalFunction = getOriginalFunction(original);\n if (originalFunction) {\n wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);\n }\n\n // Otherwise wrap directly\n return wrap(original, wrapOptions);\n });\n }\n });\n\n return originalSend.apply(this, args);\n };\n}\n\nfunction _wrapEventTarget(target) {\n const globalObject = WINDOW ;\n const targetObj = globalObject[target];\n const proto = targetObj && targetObj.prototype;\n\n // eslint-disable-next-line no-prototype-builtins\n if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (original)\n\n {\n return function ( eventName, fn, options) {\n try {\n if (isEventListenerObject(fn)) {\n // ESlint disable explanation:\n // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would\n // introduce a bug here, because bind returns a new function that doesn't have our\n // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping.\n // Without those flags, every call to addEventListener wraps the function again, causing a memory leak.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n fn.handleEvent = wrap(fn.handleEvent, {\n mechanism: {\n data: {\n function: 'handleEvent',\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\n type: 'instrument',\n },\n });\n }\n } catch (e2) {\n // can sometimes get 'Permission denied to access property \"handle Event'\n }\n\n return original.apply(this, [\n eventName,\n wrap(fn, {\n mechanism: {\n data: {\n function: 'addEventListener',\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\n type: 'instrument',\n },\n }),\n options,\n ]);\n };\n });\n\n fill(proto, 'removeEventListener', function (originalRemoveEventListener)\n\n {\n return function ( eventName, fn, options) {\n /**\n * There are 2 possible scenarios here:\n *\n * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified\n * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function\n * as a pass-through, and call original `removeEventListener` with it.\n *\n * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using\n * our wrapped version of `addEventListener`, which internally calls `wrap` helper.\n * This helper \"wraps\" whole callback inside a try/catch statement, and attached appropriate metadata to it,\n * in order for us to make a distinction between wrapped/non-wrapped functions possible.\n * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.\n *\n * When someone adds a handler prior to initialization, and then do it again, but after,\n * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible\n * to get rid of the initial handler and it'd stick there forever.\n */\n try {\n const originalEventHandler = (fn ).__sentry_wrapped__;\n if (originalEventHandler) {\n originalRemoveEventListener.call(this, eventName, originalEventHandler, options);\n }\n } catch (e) {\n // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments\n }\n return originalRemoveEventListener.call(this, eventName, fn, options);\n };\n });\n}\n\nfunction isEventListenerObject(obj) {\n return typeof (obj ).handleEvent === 'function';\n}\n\nexport { browserApiErrorsIntegration };\n","import { addHistoryInstrumentationHandler } from '@sentry-internal/browser-utils';\nimport { defineIntegration, logger, startSession, captureSession } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { WINDOW } from '../helpers.js';\n\n/**\n * When added, automatically creates sessions which allow you to track adoption and crashes (crash free rate) in your Releases in Sentry.\n * More information: https://docs.sentry.io/product/releases/health/\n *\n * Note: In order for session tracking to work, you need to set up Releases: https://docs.sentry.io/product/releases/\n */\nconst browserSessionIntegration = defineIntegration(() => {\n return {\n name: 'BrowserSession',\n setupOnce() {\n if (typeof WINDOW.document === 'undefined') {\n DEBUG_BUILD &&\n logger.warn('Using the `browserSessionIntegration` in non-browser environments is not supported.');\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSession({ ignoreDuration: true });\n captureSession();\n\n // We want to create a session for every navigation as well\n addHistoryInstrumentationHandler(({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (from !== undefined && from !== to) {\n startSession({ ignoreDuration: true });\n captureSession();\n }\n });\n },\n };\n});\n\nexport { browserSessionIntegration };\n","import { GLOBAL_OBJ } from '../worldwide.js';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers.js';\n\nlet _oldOnErrorHandler = null;\n\n/**\n * Add an instrumentation handler for when an error is captured by the global error handler.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nfunction addGlobalErrorInstrumentationHandler(handler) {\n const type = 'error';\n addHandler(type, handler);\n maybeInstrument(type, instrumentError);\n}\n\nfunction instrumentError() {\n _oldOnErrorHandler = GLOBAL_OBJ.onerror;\n\n // Note: The reason we are doing window.onerror instead of window.addEventListener('error')\n // is that we are using this handler in the Loader Script, to handle buffered errors consistently\n GLOBAL_OBJ.onerror = function (\n msg,\n url,\n line,\n column,\n error,\n ) {\n const handlerData = {\n column,\n error,\n line,\n msg,\n url,\n };\n triggerHandlers('error', handlerData);\n\n if (_oldOnErrorHandler) {\n // eslint-disable-next-line prefer-rest-params\n return _oldOnErrorHandler.apply(this, arguments);\n }\n\n return false;\n };\n\n GLOBAL_OBJ.onerror.__SENTRY_INSTRUMENTED__ = true;\n}\n\nexport { addGlobalErrorInstrumentationHandler };\n","import { GLOBAL_OBJ } from '../worldwide.js';\nimport { addHandler, maybeInstrument, triggerHandlers } from './handlers.js';\n\nlet _oldOnUnhandledRejectionHandler = null;\n\n/**\n * Add an instrumentation handler for when an unhandled promise rejection is captured.\n *\n * Use at your own risk, this might break without changelog notice, only used internally.\n * @hidden\n */\nfunction addGlobalUnhandledRejectionInstrumentationHandler(\n handler,\n) {\n const type = 'unhandledrejection';\n addHandler(type, handler);\n maybeInstrument(type, instrumentUnhandledRejection);\n}\n\nfunction instrumentUnhandledRejection() {\n _oldOnUnhandledRejectionHandler = GLOBAL_OBJ.onunhandledrejection;\n\n // Note: The reason we are doing window.onunhandledrejection instead of window.addEventListener('unhandledrejection')\n // is that we are using this handler in the Loader Script, to handle buffered rejections consistently\n GLOBAL_OBJ.onunhandledrejection = function (e) {\n const handlerData = e;\n triggerHandlers('unhandledrejection', handlerData);\n\n if (_oldOnUnhandledRejectionHandler) {\n // eslint-disable-next-line prefer-rest-params\n return _oldOnUnhandledRejectionHandler.apply(this, arguments);\n }\n\n return true;\n };\n\n GLOBAL_OBJ.onunhandledrejection.__SENTRY_INSTRUMENTED__ = true;\n}\n\nexport { addGlobalUnhandledRejectionInstrumentationHandler };\n","import { defineIntegration, addGlobalErrorInstrumentationHandler, getClient, captureEvent, addGlobalUnhandledRejectionInstrumentationHandler, isPrimitive, isString, getLocationHref, UNKNOWN_FUNCTION, logger } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { eventFromUnknownInput } from '../eventbuilder.js';\nimport { shouldIgnoreOnError } from '../helpers.js';\n\nconst INTEGRATION_NAME = 'GlobalHandlers';\n\nconst _globalHandlersIntegration = ((options = {}) => {\n const _options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n Error.stackTraceLimit = 50;\n },\n setup(client) {\n if (_options.onerror) {\n _installGlobalOnErrorHandler(client);\n globalHandlerLog('onerror');\n }\n if (_options.onunhandledrejection) {\n _installGlobalOnUnhandledRejectionHandler(client);\n globalHandlerLog('onunhandledrejection');\n }\n },\n };\n}) ;\n\nconst globalHandlersIntegration = defineIntegration(_globalHandlersIntegration);\n\nfunction _installGlobalOnErrorHandler(client) {\n addGlobalErrorInstrumentationHandler(data => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const { msg, url, line, column, error } = data;\n\n const event = _enhanceEventWithInitialFrame(\n eventFromUnknownInput(stackParser, error || msg, undefined, attachStacktrace, false),\n url,\n line,\n column,\n );\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'onerror',\n },\n });\n });\n}\n\nfunction _installGlobalOnUnhandledRejectionHandler(client) {\n addGlobalUnhandledRejectionInstrumentationHandler(e => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const error = _getUnhandledRejectionError(e );\n\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'onunhandledrejection',\n },\n });\n });\n}\n\nfunction _getUnhandledRejectionError(error) {\n if (isPrimitive(error)) {\n return error;\n }\n\n // dig the object of the rejection out of known event types\n try {\n\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in (error )) {\n return (error ).reason;\n }\n\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n if ('detail' in (error ) && 'reason' in (error ).detail) {\n return (error ).detail.reason;\n }\n } catch (e2) {} // eslint-disable-line no-empty\n\n return error;\n}\n\n/**\n * Create an event from a promise rejection where the `reason` is a primitive.\n *\n * @param reason: The `reason` property of the promise rejection\n * @returns An Event object with an appropriate `exception` value\n */\nfunction _eventFromRejectionWithPrimitive(reason) {\n return {\n exception: {\n values: [\n {\n type: 'UnhandledRejection',\n // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n },\n ],\n },\n };\n}\n\nfunction _enhanceEventWithInitialFrame(\n event,\n url,\n line,\n column,\n) {\n // event.exception\n const e = (event.exception = event.exception || {});\n // event.exception.values\n const ev = (e.values = e.values || []);\n // event.exception.values[0]\n const ev0 = (ev[0] = ev[0] || {});\n // event.exception.values[0].stacktrace\n const ev0s = (ev0.stacktrace = ev0.stacktrace || {});\n // event.exception.values[0].stacktrace.frames\n const ev0sf = (ev0s.frames = ev0s.frames || []);\n\n const colno = column;\n const lineno = line;\n const filename = isString(url) && url.length > 0 ? url : getLocationHref();\n\n // event.exception.values[0].stacktrace.frames\n if (ev0sf.length === 0) {\n ev0sf.push({\n colno,\n filename,\n function: UNKNOWN_FUNCTION,\n in_app: true,\n lineno,\n });\n }\n\n return event;\n}\n\nfunction globalHandlerLog(type) {\n DEBUG_BUILD && logger.log(`Global Handler attached: ${type}`);\n}\n\nfunction getOptions() {\n const client = getClient();\n const options = (client && client.getOptions()) || {\n stackParser: () => [],\n attachStacktrace: false,\n };\n return options;\n}\n\nexport { globalHandlersIntegration };\n","import { defineIntegration } from '@sentry/core';\nimport { WINDOW } from '../helpers.js';\n\n/**\n * Collects information about HTTP request headers and\n * attaches them to the event.\n */\nconst httpContextIntegration = defineIntegration(() => {\n return {\n name: 'HttpContext',\n preprocessEvent(event) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n // grab as much info as exists and add it to the event\n const url = (event.request && event.request.url) || (WINDOW.location && WINDOW.location.href);\n const { referrer } = WINDOW.document || {};\n const { userAgent } = WINDOW.navigator || {};\n\n const headers = {\n ...(event.request && event.request.headers),\n ...(referrer && { Referer: referrer }),\n ...(userAgent && { 'User-Agent': userAgent }),\n };\n const request = { ...event.request, ...(url && { url }), headers };\n\n event.request = request;\n },\n };\n});\n\nexport { httpContextIntegration };\n","import { isInstanceOf } from './is.js';\nimport { truncate } from './string.js';\n\n/**\n * Creates exceptions inside `event.exception.values` for errors that are nested on properties based on the `key` parameter.\n */\nfunction applyAggregateErrorsToEvent(\n exceptionFromErrorImplementation,\n parser,\n maxValueLimit = 250,\n key,\n limit,\n event,\n hint,\n) {\n if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {\n return;\n }\n\n // Generally speaking the last item in `event.exception.values` is the exception originating from the original Error\n const originalException =\n event.exception.values.length > 0 ? event.exception.values[event.exception.values.length - 1] : undefined;\n\n // We only create exception grouping if there is an exception in the event.\n if (originalException) {\n event.exception.values = truncateAggregateExceptions(\n aggregateExceptionsFromError(\n exceptionFromErrorImplementation,\n parser,\n limit,\n hint.originalException ,\n key,\n event.exception.values,\n originalException,\n 0,\n ),\n maxValueLimit,\n );\n }\n}\n\nfunction aggregateExceptionsFromError(\n exceptionFromErrorImplementation,\n parser,\n limit,\n error,\n key,\n prevExceptions,\n exception,\n exceptionId,\n) {\n if (prevExceptions.length >= limit + 1) {\n return prevExceptions;\n }\n\n let newExceptions = [...prevExceptions];\n\n // Recursively call this function in order to walk down a chain of errors\n if (isInstanceOf(error[key], Error)) {\n applyExceptionGroupFieldsForParentException(exception, exceptionId);\n const newException = exceptionFromErrorImplementation(parser, error[key]);\n const newExceptionId = newExceptions.length;\n applyExceptionGroupFieldsForChildException(newException, key, newExceptionId, exceptionId);\n newExceptions = aggregateExceptionsFromError(\n exceptionFromErrorImplementation,\n parser,\n limit,\n error[key],\n key,\n [newException, ...newExceptions],\n newException,\n newExceptionId,\n );\n }\n\n // This will create exception grouping for AggregateErrors\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError\n if (Array.isArray(error.errors)) {\n error.errors.forEach((childError, i) => {\n if (isInstanceOf(childError, Error)) {\n applyExceptionGroupFieldsForParentException(exception, exceptionId);\n const newException = exceptionFromErrorImplementation(parser, childError);\n const newExceptionId = newExceptions.length;\n applyExceptionGroupFieldsForChildException(newException, `errors[${i}]`, newExceptionId, exceptionId);\n newExceptions = aggregateExceptionsFromError(\n exceptionFromErrorImplementation,\n parser,\n limit,\n childError,\n key,\n [newException, ...newExceptions],\n newException,\n newExceptionId,\n );\n }\n });\n }\n\n return newExceptions;\n}\n\nfunction applyExceptionGroupFieldsForParentException(exception, exceptionId) {\n // Don't know if this default makes sense. The protocol requires us to set these values so we pick *some* default.\n exception.mechanism = exception.mechanism || { type: 'generic', handled: true };\n\n exception.mechanism = {\n ...exception.mechanism,\n ...(exception.type === 'AggregateError' && { is_exception_group: true }),\n exception_id: exceptionId,\n };\n}\n\nfunction applyExceptionGroupFieldsForChildException(\n exception,\n source,\n exceptionId,\n parentId,\n) {\n // Don't know if this default makes sense. The protocol requires us to set these values so we pick *some* default.\n exception.mechanism = exception.mechanism || { type: 'generic', handled: true };\n\n exception.mechanism = {\n ...exception.mechanism,\n type: 'chained',\n source,\n exception_id: exceptionId,\n parent_id: parentId,\n };\n}\n\n/**\n * Truncate the message (exception.value) of all exceptions in the event.\n * Because this event processor is ran after `applyClientOptions`,\n * we need to truncate the message of the added exceptions here.\n */\nfunction truncateAggregateExceptions(exceptions, maxValueLength) {\n return exceptions.map(exception => {\n if (exception.value) {\n exception.value = truncate(exception.value, maxValueLength);\n }\n return exception;\n });\n}\n\nexport { applyAggregateErrorsToEvent };\n","import { defineIntegration, applyAggregateErrorsToEvent } from '@sentry/core';\nimport { exceptionFromError } from '../eventbuilder.js';\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\nconst INTEGRATION_NAME = 'LinkedErrors';\n\nconst _linkedErrorsIntegration = ((options = {}) => {\n const limit = options.limit || DEFAULT_LIMIT;\n const key = options.key || DEFAULT_KEY;\n\n return {\n name: INTEGRATION_NAME,\n preprocessEvent(event, hint, client) {\n const options = client.getOptions();\n\n applyAggregateErrorsToEvent(\n // This differs from the LinkedErrors integration in core by using a different exceptionFromError function\n exceptionFromError,\n options.stackParser,\n options.maxValueLength,\n key,\n limit,\n event,\n hint,\n );\n },\n };\n}) ;\n\n/**\n * Aggregrate linked errors in an event.\n */\nconst linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);\n\nexport { linkedErrorsIntegration };\n","import { createStackParser, UNKNOWN_FUNCTION } from '@sentry/core';\n\n// This was originally forked from https://github.com/csnover/TraceKit, and was largely\n// re - written as part of raven - js.\n//\n// This code was later copied to the JavaScript mono - repo and further modified and\n// refactored over the years.\n\n\nconst OPERA10_PRIORITY = 10;\nconst OPERA11_PRIORITY = 20;\nconst CHROME_PRIORITY = 30;\nconst WINJS_PRIORITY = 40;\nconst GECKO_PRIORITY = 50;\n\nfunction createFrame(filename, func, lineno, colno) {\n const frame = {\n filename,\n function: func === '' ? UNKNOWN_FUNCTION : func,\n in_app: true, // All browser frames are considered in_app\n };\n\n if (lineno !== undefined) {\n frame.lineno = lineno;\n }\n\n if (colno !== undefined) {\n frame.colno = colno;\n }\n\n return frame;\n}\n\n// This regex matches frames that have no function name (ie. are at the top level of a module).\n// For example \"at http://localhost:5000//script.js:1:126\"\n// Frames _with_ function names usually look as follows: \"at commitLayoutEffects (react-dom.development.js:23426:1)\"\nconst chromeRegexNoFnName = /^\\s*at (\\S+?)(?::(\\d+))(?::(\\d+))\\s*$/i;\n\n// This regex matches all the frames that have a function name.\nconst chromeRegex =\n /^\\s*at (?:(.+?\\)(?: \\[.+\\])?|.*?) ?\\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i;\n\nconst chromeEvalRegex = /\\((\\S*)(?::(\\d+))(?::(\\d+))\\)/;\n\n// Chromium based browsers: Chrome, Brave, new Opera, new Edge\n// We cannot call this variable `chrome` because it can conflict with global `chrome` variable in certain environments\n// See: https://github.com/getsentry/sentry-javascript/issues/6880\nconst chromeStackParserFn = line => {\n // If the stack line has no function name, we need to parse it differently\n const noFnParts = chromeRegexNoFnName.exec(line) ;\n\n if (noFnParts) {\n const [, filename, line, col] = noFnParts;\n return createFrame(filename, UNKNOWN_FUNCTION, +line, +col);\n }\n\n const parts = chromeRegex.exec(line) ;\n\n if (parts) {\n const isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line\n\n if (isEval) {\n const subMatch = chromeEvalRegex.exec(parts[2]) ;\n\n if (subMatch) {\n // throw out eval line/column and use top-most line/column number\n parts[2] = subMatch[1]; // url\n parts[3] = subMatch[2]; // line\n parts[4] = subMatch[3]; // column\n }\n }\n\n // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now\n // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)\n const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]);\n\n return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined);\n }\n\n return;\n};\n\nconst chromeStackLineParser = [CHROME_PRIORITY, chromeStackParserFn];\n\n// gecko regex: `(?:bundle|\\d+\\.js)`: `bundle` is for react native, `\\d+\\.js` also but specifically for ram bundles because it\n// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js\n// We need this specific case for now because we want no other regex to match.\nconst geckoREgex =\n /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. /=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i;\nconst geckoEvalRegex = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i;\n\nconst gecko = line => {\n const parts = geckoREgex.exec(line) ;\n\n if (parts) {\n const isEval = parts[3] && parts[3].indexOf(' > eval') > -1;\n if (isEval) {\n const subMatch = geckoEvalRegex.exec(parts[3]) ;\n\n if (subMatch) {\n // throw out eval line/column and use top-most line number\n parts[1] = parts[1] || 'eval';\n parts[3] = subMatch[1];\n parts[4] = subMatch[2];\n parts[5] = ''; // no column when eval\n }\n }\n\n let filename = parts[3];\n let func = parts[1] || UNKNOWN_FUNCTION;\n [func, filename] = extractSafariExtensionDetails(func, filename);\n\n return createFrame(filename, func, parts[4] ? +parts[4] : undefined, parts[5] ? +parts[5] : undefined);\n }\n\n return;\n};\n\nconst geckoStackLineParser = [GECKO_PRIORITY, gecko];\n\nconst winjsRegex = /^\\s*at (?:((?:\\[object object\\])?.+) )?\\(?((?:[-a-z]+):.*?):(\\d+)(?::(\\d+))?\\)?\\s*$/i;\n\nconst winjs = line => {\n const parts = winjsRegex.exec(line) ;\n\n return parts\n ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)\n : undefined;\n};\n\nconst winjsStackLineParser = [WINJS_PRIORITY, winjs];\n\nconst opera10Regex = / line (\\d+).*script (?:in )?(\\S+)(?:: in function (\\S+))?$/i;\n\nconst opera10 = line => {\n const parts = opera10Regex.exec(line) ;\n return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;\n};\n\nconst opera10StackLineParser = [OPERA10_PRIORITY, opera10];\n\nconst opera11Regex =\n / line (\\d+), column (\\d+)\\s*(?:in (?:]+)>|([^)]+))\\(.*\\))? in (.*):\\s*$/i;\n\nconst opera11 = line => {\n const parts = opera11Regex.exec(line) ;\n return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;\n};\n\nconst opera11StackLineParser = [OPERA11_PRIORITY, opera11];\n\nconst defaultStackLineParsers = [chromeStackLineParser, geckoStackLineParser];\n\nconst defaultStackParser = createStackParser(...defaultStackLineParsers);\n\n/**\n * Safari web extensions, starting version unknown, can produce \"frames-only\" stacktraces.\n * What it means, is that instead of format like:\n *\n * Error: wat\n * at function@url:row:col\n * at function@url:row:col\n * at function@url:row:col\n *\n * it produces something like:\n *\n * function@url:row:col\n * function@url:row:col\n * function@url:row:col\n *\n * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.\n * This function is extracted so that we can use it in both places without duplicating the logic.\n * Unfortunately \"just\" changing RegExp is too complicated now and making it pass all tests\n * and fix this case seems like an impossible, or at least way too time-consuming task.\n */\nconst extractSafariExtensionDetails = (func, filename) => {\n const isSafariExtension = func.indexOf('safari-extension') !== -1;\n const isSafariWebExtension = func.indexOf('safari-web-extension') !== -1;\n\n return isSafariExtension || isSafariWebExtension\n ? [\n func.indexOf('@') !== -1 ? (func.split('@')[0] ) : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`,\n ]\n : [func, filename];\n};\n\nexport { chromeStackLineParser, defaultStackLineParsers, defaultStackParser, geckoStackLineParser, opera10StackLineParser, opera11StackLineParser, winjsStackLineParser };\n","/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nconst DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);\n\nexport { DEBUG_BUILD };\n","import { isNativeFunction, logger } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build.js';\nimport { WINDOW } from './types.js';\n\n/**\n * We generally want to use window.fetch / window.setTimeout.\n * However, in some cases this may be wrapped (e.g. by Zone.js for Angular),\n * so we try to get an unpatched version of this from a sandboxed iframe.\n */\n\nconst cachedImplementations = {};\n\n/**\n * Get the native implementation of a browser function.\n *\n * This can be used to ensure we get an unwrapped version of a function, in cases where a wrapped function can lead to problems.\n *\n * The following methods can be retrieved:\n * - `setTimeout`: This can be wrapped by e.g. Angular, causing change detection to be triggered.\n * - `fetch`: This can be wrapped by e.g. ad-blockers, causing an infinite loop when a request is blocked.\n */\nfunction getNativeImplementation(\n name,\n) {\n const cached = cachedImplementations[name];\n if (cached) {\n return cached;\n }\n\n let impl = WINDOW[name] ;\n\n // Fast path to avoid DOM I/O\n if (isNativeFunction(impl)) {\n return (cachedImplementations[name] = impl.bind(WINDOW) );\n }\n\n const document = WINDOW.document;\n // eslint-disable-next-line deprecation/deprecation\n if (document && typeof document.createElement === 'function') {\n try {\n const sandbox = document.createElement('iframe');\n sandbox.hidden = true;\n document.head.appendChild(sandbox);\n const contentWindow = sandbox.contentWindow;\n if (contentWindow && contentWindow[name]) {\n impl = contentWindow[name] ;\n }\n document.head.removeChild(sandbox);\n } catch (e) {\n // Could not create sandbox iframe, just use window.xxx\n DEBUG_BUILD && logger.warn(`Could not create sandbox iframe for ${name} check, bailing to window.${name}: `, e);\n }\n }\n\n // Sanity check: This _should_ not happen, but if it does, we just skip caching...\n // This can happen e.g. in tests where fetch may not be available in the env, or similar.\n if (!impl) {\n return impl;\n }\n\n return (cachedImplementations[name] = impl.bind(WINDOW) );\n}\n\n/** Clear a cached implementation. */\nfunction clearCachedImplementation(name) {\n cachedImplementations[name] = undefined;\n}\n\n/**\n * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.\n * Whenever someone wraps the Fetch API and returns the wrong promise chain,\n * this chain becomes orphaned and there is no possible way to capture it's rejections\n * other than allowing it bubble up to this very handler. eg.\n *\n * const f = window.fetch;\n * window.fetch = function () {\n * const p = f.apply(this, arguments);\n *\n * p.then(function() {\n * console.log('hi.');\n * });\n *\n * return p;\n * }\n *\n * `p.then(function () { ... })` is producing a completely separate promise chain,\n * however, what's returned is `p` - the result of original `fetch` call.\n *\n * This mean, that whenever we use the Fetch API to send our own requests, _and_\n * some ad-blocker blocks it, this orphaned chain will _always_ reject,\n * effectively causing another event to be captured.\n * This makes a whole process become an infinite loop, which we need to somehow\n * deal with, and break it in one way or another.\n *\n * To deal with this issue, we are making sure that we _always_ use the real\n * browser Fetch API, instead of relying on what `window.fetch` exposes.\n * The only downside to this would be missing our own requests as breadcrumbs,\n * but because we are already not doing this, it should be just fine.\n *\n * Possible failed fetch error messages per-browser:\n *\n * Chrome: Failed to fetch\n * Edge: Failed to Fetch\n * Firefox: NetworkError when attempting to fetch resource\n * Safari: resource blocked by content blocker\n */\nfunction fetch(...rest) {\n return getNativeImplementation('fetch')(...rest);\n}\n\n/**\n * Get an unwrapped `setTimeout` method.\n * This ensures that even if e.g. Angular wraps `setTimeout`, we get the native implementation,\n * avoiding triggering change detection.\n */\nfunction setTimeout(...rest) {\n return getNativeImplementation('setTimeout')(...rest);\n}\n\nexport { clearCachedImplementation, fetch, getNativeImplementation, setTimeout };\n","import { DEBUG_BUILD } from '../debug-build.js';\nimport { forEachEnvelopeItem, envelopeItemTypeToDataCategory, createEnvelope, serializeEnvelope } from '../utils-hoist/envelope.js';\nimport { SentryError } from '../utils-hoist/error.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { makePromiseBuffer } from '../utils-hoist/promisebuffer.js';\nimport { isRateLimited, updateRateLimits } from '../utils-hoist/ratelimit.js';\nimport { resolvedSyncPromise } from '../utils-hoist/syncpromise.js';\n\nconst DEFAULT_TRANSPORT_BUFFER_SIZE = 64;\n\n/**\n * Creates an instance of a Sentry `Transport`\n *\n * @param options\n * @param makeRequest\n */\nfunction createTransport(\n options,\n makeRequest,\n buffer = makePromiseBuffer(\n options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE,\n ),\n) {\n let rateLimits = {};\n const flush = (timeout) => buffer.drain(timeout);\n\n function send(envelope) {\n const filteredEnvelopeItems = [];\n\n // Drop rate limited items from envelope\n forEachEnvelopeItem(envelope, (item, type) => {\n const dataCategory = envelopeItemTypeToDataCategory(type);\n if (isRateLimited(rateLimits, dataCategory)) {\n const event = getEventForEnvelopeItem(item, type);\n options.recordDroppedEvent('ratelimit_backoff', dataCategory, event);\n } else {\n filteredEnvelopeItems.push(item);\n }\n });\n\n // Skip sending if envelope is empty after filtering out rate limited events\n if (filteredEnvelopeItems.length === 0) {\n return resolvedSyncPromise({});\n }\n\n const filteredEnvelope = createEnvelope(envelope[0], filteredEnvelopeItems );\n\n // Creates client report for each item in an envelope\n const recordEnvelopeLoss = (reason) => {\n forEachEnvelopeItem(filteredEnvelope, (item, type) => {\n const event = getEventForEnvelopeItem(item, type);\n options.recordDroppedEvent(reason, envelopeItemTypeToDataCategory(type), event);\n });\n };\n\n const requestTask = () =>\n makeRequest({ body: serializeEnvelope(filteredEnvelope) }).then(\n response => {\n // We don't want to throw on NOK responses, but we want to at least log them\n if (response.statusCode !== undefined && (response.statusCode < 200 || response.statusCode >= 300)) {\n DEBUG_BUILD && logger.warn(`Sentry responded with status code ${response.statusCode} to sent event.`);\n }\n\n rateLimits = updateRateLimits(rateLimits, response);\n return response;\n },\n error => {\n recordEnvelopeLoss('network_error');\n throw error;\n },\n );\n\n return buffer.add(requestTask).then(\n result => result,\n error => {\n if (error instanceof SentryError) {\n DEBUG_BUILD && logger.error('Skipped sending event because buffer is full.');\n recordEnvelopeLoss('queue_overflow');\n return resolvedSyncPromise({});\n } else {\n throw error;\n }\n },\n );\n }\n\n return {\n send,\n flush,\n };\n}\n\nfunction getEventForEnvelopeItem(item, type) {\n if (type !== 'event' && type !== 'transaction') {\n return undefined;\n }\n\n return Array.isArray(item) ? (item )[1] : undefined;\n}\n\nexport { DEFAULT_TRANSPORT_BUFFER_SIZE, createTransport };\n","import { SentryError } from './error.js';\nimport { rejectedSyncPromise, SyncPromise, resolvedSyncPromise } from './syncpromise.js';\n\n/**\n * Creates an new PromiseBuffer object with the specified limit\n * @param limit max number of promises that can be stored in the buffer\n */\nfunction makePromiseBuffer(limit) {\n const buffer = [];\n\n function isReady() {\n return limit === undefined || buffer.length < limit;\n }\n\n /**\n * Remove a promise from the queue.\n *\n * @param task Can be any PromiseLike\n * @returns Removed promise.\n */\n function remove(task) {\n return buffer.splice(buffer.indexOf(task), 1)[0] || Promise.resolve(undefined);\n }\n\n /**\n * Add a promise (representing an in-flight action) to the queue, and set it to remove itself on fulfillment.\n *\n * @param taskProducer A function producing any PromiseLike; In previous versions this used to be `task:\n * PromiseLike`, but under that model, Promises were instantly created on the call-site and their executor\n * functions therefore ran immediately. Thus, even if the buffer was full, the action still happened. By\n * requiring the promise to be wrapped in a function, we can defer promise creation until after the buffer\n * limit check.\n * @returns The original promise.\n */\n function add(taskProducer) {\n if (!isReady()) {\n return rejectedSyncPromise(new SentryError('Not adding Promise because buffer limit was reached.'));\n }\n\n // start the task and add its promise to the queue\n const task = taskProducer();\n if (buffer.indexOf(task) === -1) {\n buffer.push(task);\n }\n void task\n .then(() => remove(task))\n // Use `then(null, rejectionHandler)` rather than `catch(rejectionHandler)` so that we can use `PromiseLike`\n // rather than `Promise`. `PromiseLike` doesn't have a `.catch` method, making its polyfill smaller. (ES5 didn't\n // have promises, so TS has to polyfill when down-compiling.)\n .then(null, () =>\n remove(task).then(null, () => {\n // We have to add another catch here because `remove()` starts a new promise chain.\n }),\n );\n return task;\n }\n\n /**\n * Wait for all promises in the queue to resolve or for timeout to expire, whichever comes first.\n *\n * @param timeout The time, in ms, after which to resolve to `false` if the queue is still non-empty. Passing `0` (or\n * not passing anything) will make the promise wait as long as it takes for the queue to drain before resolving to\n * `true`.\n * @returns A promise which will resolve to `true` if the queue is already empty or drains before the timeout, and\n * `false` otherwise\n */\n function drain(timeout) {\n return new SyncPromise((resolve, reject) => {\n let counter = buffer.length;\n\n if (!counter) {\n return resolve(true);\n }\n\n // wait for `timeout` ms and then resolve to `false` (if not cancelled first)\n const capturedSetTimeout = setTimeout(() => {\n if (timeout && timeout > 0) {\n resolve(false);\n }\n }, timeout);\n\n // if all promises resolve in time, cancel the timer and resolve to `true`\n buffer.forEach(item => {\n void resolvedSyncPromise(item).then(() => {\n if (!--counter) {\n clearTimeout(capturedSetTimeout);\n resolve(true);\n }\n }, reject);\n });\n });\n }\n\n return {\n $: buffer,\n add,\n drain,\n };\n}\n\nexport { makePromiseBuffer };\n","// Intentionally keeping the key broad, as we don't know for sure what rate limit headers get returned from backend\n\nconst DEFAULT_RETRY_AFTER = 60 * 1000; // 60 seconds\n\n/**\n * Extracts Retry-After value from the request header or returns default value\n * @param header string representation of 'Retry-After' header\n * @param now current unix timestamp\n *\n */\nfunction parseRetryAfterHeader(header, now = Date.now()) {\n const headerDelay = parseInt(`${header}`, 10);\n if (!isNaN(headerDelay)) {\n return headerDelay * 1000;\n }\n\n const headerDate = Date.parse(`${header}`);\n if (!isNaN(headerDate)) {\n return headerDate - now;\n }\n\n return DEFAULT_RETRY_AFTER;\n}\n\n/**\n * Gets the time that the given category is disabled until for rate limiting.\n * In case no category-specific limit is set but a general rate limit across all categories is active,\n * that time is returned.\n *\n * @return the time in ms that the category is disabled until or 0 if there's no active rate limit.\n */\nfunction disabledUntil(limits, dataCategory) {\n return limits[dataCategory] || limits.all || 0;\n}\n\n/**\n * Checks if a category is rate limited\n */\nfunction isRateLimited(limits, dataCategory, now = Date.now()) {\n return disabledUntil(limits, dataCategory) > now;\n}\n\n/**\n * Update ratelimits from incoming headers.\n *\n * @return the updated RateLimits object.\n */\nfunction updateRateLimits(\n limits,\n { statusCode, headers },\n now = Date.now(),\n) {\n const updatedRateLimits = {\n ...limits,\n };\n\n // \"The name is case-insensitive.\"\n // https://developer.mozilla.org/en-US/docs/Web/API/Headers/get\n const rateLimitHeader = headers && headers['x-sentry-rate-limits'];\n const retryAfterHeader = headers && headers['retry-after'];\n\n if (rateLimitHeader) {\n /**\n * rate limit headers are of the form\n *
,
,..\n * where each
is of the form\n * : : : : \n * where\n * is a delay in seconds\n * is the event type(s) (error, transaction, etc) being rate limited and is of the form\n * ;;...\n * is what's being limited (org, project, or key) - ignored by SDK\n * is an arbitrary string like \"org_quota\" - ignored by SDK\n * Semicolon-separated list of metric namespace identifiers. Defines which namespace(s) will be affected.\n * Only present if rate limit applies to the metric_bucket data category.\n */\n for (const limit of rateLimitHeader.trim().split(',')) {\n const [retryAfter, categories, , , namespaces] = limit.split(':', 5) ;\n const headerDelay = parseInt(retryAfter, 10);\n const delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default\n if (!categories) {\n updatedRateLimits.all = now + delay;\n } else {\n for (const category of categories.split(';')) {\n if (category === 'metric_bucket') {\n // namespaces will be present when category === 'metric_bucket'\n if (!namespaces || namespaces.split(';').includes('custom')) {\n updatedRateLimits[category] = now + delay;\n }\n } else {\n updatedRateLimits[category] = now + delay;\n }\n }\n }\n }\n } else if (retryAfterHeader) {\n updatedRateLimits.all = now + parseRetryAfterHeader(retryAfterHeader, now);\n } else if (statusCode === 429) {\n updatedRateLimits.all = now + 60 * 1000;\n }\n\n return updatedRateLimits;\n}\n\nexport { DEFAULT_RETRY_AFTER, disabledUntil, isRateLimited, parseRetryAfterHeader, updateRateLimits };\n","import { getNativeImplementation, clearCachedImplementation } from '@sentry-internal/browser-utils';\nimport { createTransport, rejectedSyncPromise } from '@sentry/core';\n\n/**\n * Creates a Transport that uses the Fetch API to send events to Sentry.\n */\nfunction makeFetchTransport(\n options,\n nativeFetch = getNativeImplementation('fetch'),\n) {\n let pendingBodySize = 0;\n let pendingCount = 0;\n\n function makeRequest(request) {\n const requestSize = request.body.length;\n pendingBodySize += requestSize;\n pendingCount++;\n\n const requestOptions = {\n body: request.body,\n method: 'POST',\n referrerPolicy: 'origin',\n headers: options.headers,\n // Outgoing requests are usually cancelled when navigating to a different page, causing a \"TypeError: Failed to\n // fetch\" error and sending a \"network_error\" client-outcome - in Chrome, the request status shows \"(cancelled)\".\n // The `keepalive` flag keeps outgoing requests alive, even when switching pages. We want this since we're\n // frequently sending events right before the user is switching pages (eg. when finishing navigation transactions).\n // Gotchas:\n // - `keepalive` isn't supported by Firefox\n // - As per spec (https://fetch.spec.whatwg.org/#http-network-or-cache-fetch):\n // If the sum of contentLength and inflightKeepaliveBytes is greater than 64 kibibytes, then return a network error.\n // We will therefore only activate the flag when we're below that limit.\n // There is also a limit of requests that can be open at the same time, so we also limit this to 15\n // See https://github.com/getsentry/sentry-javascript/pull/7553 for details\n keepalive: pendingBodySize <= 60000 && pendingCount < 15,\n ...options.fetchOptions,\n };\n\n if (!nativeFetch) {\n clearCachedImplementation('fetch');\n return rejectedSyncPromise('No fetch implementation available');\n }\n\n try {\n // TODO: This may need a `suppressTracing` call in the future when we switch the browser SDK to OTEL\n return nativeFetch(options.url, requestOptions).then(response => {\n pendingBodySize -= requestSize;\n pendingCount--;\n return {\n statusCode: response.status,\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n };\n });\n } catch (e) {\n clearCachedImplementation('fetch');\n pendingBodySize -= requestSize;\n pendingCount--;\n return rejectedSyncPromise(e);\n }\n }\n\n return createTransport(options, makeRequest);\n}\n\nexport { makeFetchTransport };\n","import { inboundFiltersIntegration, functionToStringIntegration, dedupeIntegration, consoleSandbox, supportsFetch, logger, stackParserFromStackParserOptions, getIntegrationsToSetup, initAndBind, getCurrentScope, lastEventId, getReportDialogEndpoint, getClient } from '@sentry/core';\nimport { BrowserClient } from './client.js';\nimport { DEBUG_BUILD } from './debug-build.js';\nimport { WINDOW } from './helpers.js';\nimport { breadcrumbsIntegration } from './integrations/breadcrumbs.js';\nimport { browserApiErrorsIntegration } from './integrations/browserapierrors.js';\nimport { browserSessionIntegration } from './integrations/browsersession.js';\nimport { globalHandlersIntegration } from './integrations/globalhandlers.js';\nimport { httpContextIntegration } from './integrations/httpcontext.js';\nimport { linkedErrorsIntegration } from './integrations/linkederrors.js';\nimport { defaultStackParser } from './stack-parsers.js';\nimport { makeFetchTransport } from './transports/fetch.js';\n\n/** Get the default integrations for the browser SDK. */\nfunction getDefaultIntegrations(options) {\n /**\n * Note: Please make sure this stays in sync with Angular SDK, which re-exports\n * `getDefaultIntegrations` but with an adjusted set of integrations.\n */\n const integrations = [\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n browserApiErrorsIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n ];\n\n // eslint-disable-next-line deprecation/deprecation\n if (options.autoSessionTracking !== false) {\n integrations.push(browserSessionIntegration());\n }\n\n return integrations;\n}\n\nfunction applyDefaultOptions(optionsArg = {}) {\n const defaultOptions = {\n defaultIntegrations: getDefaultIntegrations(optionsArg),\n release:\n typeof __SENTRY_RELEASE__ === 'string' // This allows build tooling to find-and-replace __SENTRY_RELEASE__ to inject a release value\n ? __SENTRY_RELEASE__\n : WINDOW.SENTRY_RELEASE && WINDOW.SENTRY_RELEASE.id // This supports the variable that sentry-webpack-plugin injects\n ? WINDOW.SENTRY_RELEASE.id\n : undefined,\n autoSessionTracking: true,\n sendClientReports: true,\n };\n\n // TODO: Instead of dropping just `defaultIntegrations`, we should simply\n // call `dropUndefinedKeys` on the entire `optionsArg`.\n // However, for this to work we need to adjust the `hasTracingEnabled()` logic\n // first as it differentiates between `undefined` and the key not being in the object.\n if (optionsArg.defaultIntegrations == null) {\n delete optionsArg.defaultIntegrations;\n }\n\n return { ...defaultOptions, ...optionsArg };\n}\n\nfunction shouldShowBrowserExtensionError() {\n const windowWithMaybeExtension =\n typeof WINDOW.window !== 'undefined' && (WINDOW );\n if (!windowWithMaybeExtension) {\n // No need to show the error if we're not in a browser window environment (e.g. service workers)\n return false;\n }\n\n const extensionKey = windowWithMaybeExtension.chrome ? 'chrome' : 'browser';\n const extensionObject = windowWithMaybeExtension[extensionKey];\n\n const runtimeId = extensionObject && extensionObject.runtime && extensionObject.runtime.id;\n const href = (WINDOW.location && WINDOW.location.href) || '';\n\n const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:', 'safari-web-extension:'];\n\n // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage\n const isDedicatedExtensionPage =\n !!runtimeId && WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}//`));\n\n // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine\n // see: https://github.com/getsentry/sentry-javascript/issues/12668\n const isNWjs = typeof windowWithMaybeExtension.nw !== 'undefined';\n\n return !!runtimeId && !isDedicatedExtensionPage && !isNWjs;\n}\n\n/**\n * A magic string that build tooling can leverage in order to inject a release value into the SDK.\n */\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nfunction init(browserOptions = {}) {\n const options = applyDefaultOptions(browserOptions);\n\n if (!options.skipBrowserExtensionCheck && shouldShowBrowserExtensionError()) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.error(\n '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',\n );\n });\n return;\n }\n\n if (DEBUG_BUILD) {\n if (!supportsFetch()) {\n logger.warn(\n 'No Fetch API detected. The Sentry SDK requires a Fetch API compatible environment to send events. Please add a Fetch API polyfill.',\n );\n }\n }\n const clientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || makeFetchTransport,\n };\n\n return initAndBind(BrowserClient, clientOptions);\n}\n\n/**\n * All properties the report dialog supports\n */\n\n/**\n * Present the user with a report dialog.\n *\n * @param options Everything is optional, we try to fetch all info need from the global scope.\n */\nfunction showReportDialog(options = {}) {\n // doesn't work without a document (React Native)\n if (!WINDOW.document) {\n DEBUG_BUILD && logger.error('Global document not defined in showReportDialog call');\n return;\n }\n\n const scope = getCurrentScope();\n const client = scope.getClient();\n const dsn = client && client.getDsn();\n\n if (!dsn) {\n DEBUG_BUILD && logger.error('DSN not configured for showReportDialog call');\n return;\n }\n\n if (scope) {\n options.user = {\n ...scope.getUser(),\n ...options.user,\n };\n }\n\n if (!options.eventId) {\n const eventId = lastEventId();\n if (eventId) {\n options.eventId = eventId;\n }\n }\n\n const script = WINDOW.document.createElement('script');\n script.async = true;\n script.crossOrigin = 'anonymous';\n script.src = getReportDialogEndpoint(dsn, options);\n\n if (options.onLoad) {\n script.onload = options.onLoad;\n }\n\n const { onClose } = options;\n if (onClose) {\n const reportDialogClosedMessageHandler = (event) => {\n if (event.data === '__sentry_reportdialog_closed__') {\n try {\n onClose();\n } finally {\n WINDOW.removeEventListener('message', reportDialogClosedMessageHandler);\n }\n }\n };\n WINDOW.addEventListener('message', reportDialogClosedMessageHandler);\n }\n\n const injectionPoint = WINDOW.document.head || WINDOW.document.body;\n if (injectionPoint) {\n injectionPoint.appendChild(script);\n } else {\n DEBUG_BUILD && logger.error('Not injecting report dialog. No injection point found in HTML');\n }\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nfunction forceLoad() {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nfunction onLoad(callback) {\n callback();\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n *\n * @deprecated Use `captureFeedback` instead.\n */\nfunction captureUserFeedback(feedback) {\n const client = getClient();\n if (client) {\n // eslint-disable-next-line deprecation/deprecation\n client.captureUserFeedback(feedback);\n }\n}\n\nexport { captureUserFeedback, forceLoad, getDefaultIntegrations, init, onLoad, showReportDialog };\n","import { getCurrentScope } from './currentScopes.js';\nimport { DEBUG_BUILD } from './debug-build.js';\nimport { logger, consoleSandbox } from './utils-hoist/logger.js';\n\n/** A class object that can instantiate Client objects. */\n\n/**\n * Internal function to create a new SDK client instance. The client is\n * installed and then bound to the current scope.\n *\n * @param clientClass The client class to instantiate.\n * @param options Options to pass to the client.\n */\nfunction initAndBind(\n clientClass,\n options,\n) {\n if (options.debug === true) {\n if (DEBUG_BUILD) {\n logger.enable();\n } else {\n // use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');\n });\n }\n }\n const scope = getCurrentScope();\n scope.update(options.initialScope);\n\n const client = new clientClass(options);\n setCurrentClient(client);\n client.init();\n return client;\n}\n\n/**\n * Make the given client the current client.\n */\nfunction setCurrentClient(client) {\n getCurrentScope().setClient(client);\n}\n\nexport { initAndBind, setCurrentClient };\n","import { DEBUG_BUILD } from '../debug-build.js';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT } from '../semanticAttributes.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { getRootSpan, getActiveSpan } from '../utils/spanUtils.js';\n\n/**\n * Adds a measurement to the active transaction on the current global scope. You can optionally pass in a different span\n * as the 4th parameter.\n */\nfunction setMeasurement(name, value, unit, activeSpan = getActiveSpan()) {\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n if (rootSpan) {\n DEBUG_BUILD && logger.log(`[Measurement] Setting measurement on root span: ${name} = ${value} ${unit}`);\n rootSpan.addEvent(name, {\n [SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE]: value,\n [SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT]: unit ,\n });\n }\n}\n\n/**\n * Convert timed events to measurements.\n */\nfunction timedEventsToMeasurements(events) {\n if (!events || events.length === 0) {\n return undefined;\n }\n\n const measurements = {};\n events.forEach(event => {\n const attributes = event.attributes || {};\n const unit = attributes[SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT] ;\n const value = attributes[SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE] ;\n\n if (typeof unit === 'string' && typeof value === 'number') {\n measurements[event.name] = { value, unit };\n }\n });\n\n return measurements;\n}\n\nexport { setMeasurement, timedEventsToMeasurements };\n","const getRating = (value, thresholds) => {\n if (value > thresholds[1]) {\n return 'poor';\n }\n if (value > thresholds[0]) {\n return 'needs-improvement';\n }\n return 'good';\n};\n\nconst bindReporter = (\n callback,\n metric,\n thresholds,\n reportAllChanges,\n) => {\n let prevValue;\n let delta;\n return (forceReport) => {\n if (metric.value >= 0) {\n if (forceReport || reportAllChanges) {\n delta = metric.value - (prevValue || 0);\n\n // Report the metric if there's a non-zero delta or if no previous\n // value exists (which can happen in the case of the document becoming\n // hidden when the metric value is 0).\n // See: https://github.com/GoogleChrome/web-vitals/issues/14\n if (delta || prevValue === undefined) {\n prevValue = metric.value;\n metric.delta = delta;\n metric.rating = getRating(metric.value, thresholds);\n callback(metric);\n }\n }\n }\n };\n};\n\nexport { bindReporter };\n","import { WINDOW } from '../../../types.js';\n\n/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n// sentry-specific change:\n// add optional param to not check for responseStart (see comment below)\nconst getNavigationEntry = (checkResponseStart = true) => {\n const navigationEntry =\n WINDOW.performance && WINDOW.performance.getEntriesByType && WINDOW.performance.getEntriesByType('navigation')[0];\n // Check to ensure the `responseStart` property is present and valid.\n // In some cases no value is reported by the browser (for\n // privacy/security reasons), and in other cases (bugs) the value is\n // negative or is larger than the current page time. Ignore these cases:\n // https://github.com/GoogleChrome/web-vitals/issues/137\n // https://github.com/GoogleChrome/web-vitals/issues/162\n // https://github.com/GoogleChrome/web-vitals/issues/275\n if (\n // sentry-specific change:\n // We don't want to check for responseStart for our own use of `getNavigationEntry`\n !checkResponseStart ||\n (navigationEntry && navigationEntry.responseStart > 0 && navigationEntry.responseStart < performance.now())\n ) {\n return navigationEntry;\n }\n};\n\nexport { getNavigationEntry };\n","import { getNavigationEntry } from './getNavigationEntry.js';\n\n/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nconst getActivationStart = () => {\n const navEntry = getNavigationEntry();\n return (navEntry && navEntry.activationStart) || 0;\n};\n\nexport { getActivationStart };\n","import { WINDOW } from '../../../types.js';\nimport { generateUniqueID } from './generateUniqueID.js';\nimport { getActivationStart } from './getActivationStart.js';\nimport { getNavigationEntry } from './getNavigationEntry.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nconst initMetric = (name, value) => {\n const navEntry = getNavigationEntry();\n let navigationType = 'navigate';\n\n if (navEntry) {\n if ((WINDOW.document && WINDOW.document.prerendering) || getActivationStart() > 0) {\n navigationType = 'prerender';\n } else if (WINDOW.document && WINDOW.document.wasDiscarded) {\n navigationType = 'restore';\n } else if (navEntry.type) {\n navigationType = navEntry.type.replace(/_/g, '-') ;\n }\n }\n\n // Use `entries` type specific for the metric.\n const entries = [];\n\n return {\n name,\n value: typeof value === 'undefined' ? -1 : value,\n rating: 'good' , // If needed, will be updated when reported. `const` to keep the type from widening to `string`.\n delta: 0,\n entries,\n id: generateUniqueID(),\n navigationType,\n };\n};\n\nexport { initMetric };\n","/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Performantly generate a unique, 30-char string by combining a version\n * number, the current timestamp with a 13-digit number integer.\n * @return {string}\n */\nconst generateUniqueID = () => {\n return `v4-${Date.now()}-${Math.floor(Math.random() * (9e12 - 1)) + 1e12}`;\n};\n\nexport { generateUniqueID };\n","/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Takes a performance entry type and a callback function, and creates a\n * `PerformanceObserver` instance that will observe the specified entry type\n * with buffering enabled and call the callback _for each entry_.\n *\n * This function also feature-detects entry support and wraps the logic in a\n * try/catch to avoid errors in unsupporting browsers.\n */\nconst observe = (\n type,\n callback,\n opts,\n) => {\n try {\n if (PerformanceObserver.supportedEntryTypes.includes(type)) {\n const po = new PerformanceObserver(list => {\n // Delay by a microtask to workaround a bug in Safari where the\n // callback is invoked immediately, rather than in a separate task.\n // See: https://github.com/GoogleChrome/web-vitals/issues/277\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => {\n callback(list.getEntries() );\n });\n });\n po.observe(\n Object.assign(\n {\n type,\n buffered: true,\n },\n opts || {},\n ) ,\n );\n return po;\n }\n } catch (e) {\n // Do nothing.\n }\n return;\n};\n\nexport { observe };\n","import { WINDOW } from '../../../types.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n// Sentry-specific change:\n// This function's logic was NOT updated to web-vitals 4.2.4 but we continue\n// to use the web-vitals 3.5.2 due to us having stricter browser support.\n// PR with context that made the changes: https://github.com/GoogleChrome/web-vitals/pull/442/files#r1530492402\n// The PR removed listening to the `pagehide` event, in favour of only listening to `visibilitychange` event.\n// This is \"more correct\" but some browsers we still support (Safari 12.1-14.0) don't fully support `visibilitychange`\n// or have known bugs w.r.t the `visibilitychange` event.\n// TODO (v9): If we decide to drop support for Safari 12.1-14.0, we can use the logic from web-vitals 4.2.4\n// In this case, we also need to update the integration tests that currently trigger the `pagehide` event to\n// simulate the page being hidden.\nconst onHidden = (cb) => {\n const onHiddenOrPageHide = (event) => {\n if (event.type === 'pagehide' || (WINDOW.document && WINDOW.document.visibilityState === 'hidden')) {\n cb(event);\n }\n };\n\n if (WINDOW.document) {\n addEventListener('visibilitychange', onHiddenOrPageHide, true);\n // Some browsers have buggy implementations of visibilitychange,\n // so we use pagehide in addition, just to be safe.\n addEventListener('pagehide', onHiddenOrPageHide, true);\n }\n};\n\nexport { onHidden };\n","/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst runOnce = (cb) => {\n let called = false;\n return () => {\n if (!called) {\n cb();\n called = true;\n }\n };\n};\n\nexport { runOnce };\n","import { WINDOW } from '../../../types.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nlet firstHiddenTime = -1;\n\nconst initHiddenTime = () => {\n // If the document is hidden when this code runs, assume it was always\n // hidden and the page was loaded in the background, with the one exception\n // that visibility state is always 'hidden' during prerendering, so we have\n // to ignore that case until prerendering finishes (see: `prerenderingchange`\n // event logic below).\n return WINDOW.document.visibilityState === 'hidden' && !WINDOW.document.prerendering ? 0 : Infinity;\n};\n\nconst onVisibilityUpdate = (event) => {\n // If the document is 'hidden' and no previous hidden timestamp has been\n // set, update it based on the current event data.\n if (WINDOW.document.visibilityState === 'hidden' && firstHiddenTime > -1) {\n // If the event is a 'visibilitychange' event, it means the page was\n // visible prior to this change, so the event timestamp is the first\n // hidden time.\n // However, if the event is not a 'visibilitychange' event, then it must\n // be a 'prerenderingchange' event, and the fact that the document is\n // still 'hidden' from the above check means the tab was activated\n // in a background state and so has always been hidden.\n firstHiddenTime = event.type === 'visibilitychange' ? event.timeStamp : 0;\n\n // Remove all listeners now that a `firstHiddenTime` value has been set.\n removeChangeListeners();\n }\n};\n\nconst addChangeListeners = () => {\n addEventListener('visibilitychange', onVisibilityUpdate, true);\n // IMPORTANT: when a page is prerendering, its `visibilityState` is\n // 'hidden', so in order to account for cases where this module checks for\n // visibility during prerendering, an additional check after prerendering\n // completes is also required.\n addEventListener('prerenderingchange', onVisibilityUpdate, true);\n};\n\nconst removeChangeListeners = () => {\n removeEventListener('visibilitychange', onVisibilityUpdate, true);\n removeEventListener('prerenderingchange', onVisibilityUpdate, true);\n};\n\nconst getVisibilityWatcher = () => {\n if (WINDOW.document && firstHiddenTime < 0) {\n // If the document is hidden when this code runs, assume it was hidden\n // since navigation start. This isn't a perfect heuristic, but it's the\n // best we can do until an API is available to support querying past\n // visibilityState.\n firstHiddenTime = initHiddenTime();\n addChangeListeners();\n }\n return {\n get firstHiddenTime() {\n return firstHiddenTime;\n },\n };\n};\n\nexport { getVisibilityWatcher };\n","import { WINDOW } from '../../../types.js';\n\n/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nconst whenActivated = (callback) => {\n if (WINDOW.document && WINDOW.document.prerendering) {\n addEventListener('prerenderingchange', () => callback(), true);\n } else {\n callback();\n }\n};\n\nexport { whenActivated };\n","import { bindReporter } from './lib/bindReporter.js';\nimport { getActivationStart } from './lib/getActivationStart.js';\nimport { getVisibilityWatcher } from './lib/getVisibilityWatcher.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { observe } from './lib/observe.js';\nimport { whenActivated } from './lib/whenActivated.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n/** Thresholds for FCP. See https://web.dev/articles/fcp#what_is_a_good_fcp_score */\nconst FCPThresholds = [1800, 3000];\n\n/**\n * Calculates the [FCP](https://web.dev/articles/fcp) value for the current page and\n * calls the `callback` function once the value is ready, along with the\n * relevant `paint` performance entry used to determine the value. The reported\n * value is a `DOMHighResTimeStamp`.\n */\nconst onFCP = (onReport, opts = {}) => {\n whenActivated(() => {\n const visibilityWatcher = getVisibilityWatcher();\n const metric = initMetric('FCP');\n let report;\n\n const handleEntries = (entries) => {\n entries.forEach(entry => {\n if (entry.name === 'first-contentful-paint') {\n po.disconnect();\n\n // Only report if the page wasn't hidden prior to the first paint.\n if (entry.startTime < visibilityWatcher.firstHiddenTime) {\n // The activationStart reference is used because FCP should be\n // relative to page activation rather than navigation start if the\n // page was prerendered. But in cases where `activationStart` occurs\n // after the FCP, this time should be clamped at 0.\n metric.value = Math.max(entry.startTime - getActivationStart(), 0);\n metric.entries.push(entry);\n report(true);\n }\n }\n });\n };\n\n const po = observe('paint', handleEntries);\n\n if (po) {\n report = bindReporter(onReport, metric, FCPThresholds, opts.reportAllChanges);\n }\n });\n};\n\nexport { FCPThresholds, onFCP };\n","import { bindReporter } from './lib/bindReporter.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { observe } from './lib/observe.js';\nimport { onHidden } from './lib/onHidden.js';\nimport { runOnce } from './lib/runOnce.js';\nimport { onFCP } from './onFCP.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n/** Thresholds for CLS. See https://web.dev/articles/cls#what_is_a_good_cls_score */\nconst CLSThresholds = [0.1, 0.25];\n\n/**\n * Calculates the [CLS](https://web.dev/articles/cls) value for the current page and\n * calls the `callback` function once the value is ready to be reported, along\n * with all `layout-shift` performance entries that were used in the metric\n * value calculation. The reported value is a `double` (corresponding to a\n * [layout shift score](https://web.dev/articles/cls#layout_shift_score)).\n *\n * If the `reportAllChanges` configuration option is set to `true`, the\n * `callback` function will be called as soon as the value is initially\n * determined as well as any time the value changes throughout the page\n * lifespan.\n *\n * _**Important:** CLS should be continually monitored for changes throughout\n * the entire lifespan of a page—including if the user returns to the page after\n * it's been hidden/backgrounded. However, since browsers often [will not fire\n * additional callbacks once the user has backgrounded a\n * page](https://developer.chrome.com/blog/page-lifecycle-api/#advice-hidden),\n * `callback` is always called when the page's visibility state changes to\n * hidden. As a result, the `callback` function might be called multiple times\n * during the same page load._\n */\nconst onCLS = (onReport, opts = {}) => {\n // Start monitoring FCP so we can only report CLS if FCP is also reported.\n // Note: this is done to match the current behavior of CrUX.\n onFCP(\n runOnce(() => {\n const metric = initMetric('CLS', 0);\n let report;\n\n let sessionValue = 0;\n let sessionEntries = [];\n\n const handleEntries = (entries) => {\n entries.forEach(entry => {\n // Only count layout shifts without recent user input.\n if (!entry.hadRecentInput) {\n const firstSessionEntry = sessionEntries[0];\n const lastSessionEntry = sessionEntries[sessionEntries.length - 1];\n\n // If the entry occurred less than 1 second after the previous entry\n // and less than 5 seconds after the first entry in the session,\n // include the entry in the current session. Otherwise, start a new\n // session.\n if (\n sessionValue &&\n firstSessionEntry &&\n lastSessionEntry &&\n entry.startTime - lastSessionEntry.startTime < 1000 &&\n entry.startTime - firstSessionEntry.startTime < 5000\n ) {\n sessionValue += entry.value;\n sessionEntries.push(entry);\n } else {\n sessionValue = entry.value;\n sessionEntries = [entry];\n }\n }\n });\n\n // If the current session value is larger than the current CLS value,\n // update CLS and the entries contributing to it.\n if (sessionValue > metric.value) {\n metric.value = sessionValue;\n metric.entries = sessionEntries;\n report();\n }\n };\n\n const po = observe('layout-shift', handleEntries);\n if (po) {\n report = bindReporter(onReport, metric, CLSThresholds, opts.reportAllChanges);\n\n onHidden(() => {\n handleEntries(po.takeRecords() );\n report(true);\n });\n\n // Queue a task to report (if nothing else triggers a report first).\n // This allows CLS to be reported as soon as FCP fires when\n // `reportAllChanges` is true.\n setTimeout(report, 0);\n }\n }),\n );\n};\n\nexport { CLSThresholds, onCLS };\n","import { bindReporter } from './lib/bindReporter.js';\nimport { getVisibilityWatcher } from './lib/getVisibilityWatcher.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { observe } from './lib/observe.js';\nimport { onHidden } from './lib/onHidden.js';\nimport { runOnce } from './lib/runOnce.js';\nimport { whenActivated } from './lib/whenActivated.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n/** Thresholds for FID. See https://web.dev/articles/fid#what_is_a_good_fid_score */\nconst FIDThresholds = [100, 300];\n\n/**\n * Calculates the [FID](https://web.dev/articles/fid) value for the current page and\n * calls the `callback` function once the value is ready, along with the\n * relevant `first-input` performance entry used to determine the value. The\n * reported value is a `DOMHighResTimeStamp`.\n *\n * _**Important:** since FID is only reported after the user interacts with the\n * page, it's possible that it will not be reported for some page loads._\n */\nconst onFID = (onReport, opts = {}) => {\n whenActivated(() => {\n const visibilityWatcher = getVisibilityWatcher();\n const metric = initMetric('FID');\n // eslint-disable-next-line prefer-const\n let report;\n\n const handleEntry = (entry) => {\n // Only report if the page wasn't hidden prior to the first input.\n if (entry.startTime < visibilityWatcher.firstHiddenTime) {\n metric.value = entry.processingStart - entry.startTime;\n metric.entries.push(entry);\n report(true);\n }\n };\n\n const handleEntries = (entries) => {\n (entries ).forEach(handleEntry);\n };\n\n const po = observe('first-input', handleEntries);\n\n report = bindReporter(onReport, metric, FIDThresholds, opts.reportAllChanges);\n\n if (po) {\n onHidden(\n runOnce(() => {\n handleEntries(po.takeRecords() );\n po.disconnect();\n }),\n );\n }\n });\n};\n\nexport { FIDThresholds, onFID };\n","import { observe } from '../observe.js';\n\n/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nlet interactionCountEstimate = 0;\nlet minKnownInteractionId = Infinity;\nlet maxKnownInteractionId = 0;\n\nconst updateEstimate = (entries) => {\n entries.forEach(e => {\n if (e.interactionId) {\n minKnownInteractionId = Math.min(minKnownInteractionId, e.interactionId);\n maxKnownInteractionId = Math.max(maxKnownInteractionId, e.interactionId);\n\n interactionCountEstimate = maxKnownInteractionId ? (maxKnownInteractionId - minKnownInteractionId) / 7 + 1 : 0;\n }\n });\n};\n\nlet po;\n\n/**\n * Returns the `interactionCount` value using the native API (if available)\n * or the polyfill estimate in this module.\n */\nconst getInteractionCount = () => {\n return po ? interactionCountEstimate : performance.interactionCount || 0;\n};\n\n/**\n * Feature detects native support or initializes the polyfill if needed.\n */\nconst initInteractionCountPolyfill = () => {\n if ('interactionCount' in performance || po) return;\n\n po = observe('event', updateEstimate, {\n type: 'event',\n buffered: true,\n durationThreshold: 0,\n } );\n};\n\nexport { getInteractionCount, initInteractionCountPolyfill };\n","import { getInteractionCount } from './polyfills/interactionCountPolyfill.js';\n\n/*\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n// A list of longest interactions on the page (by latency) sorted so the\n// longest one is first. The list is at most MAX_INTERACTIONS_TO_CONSIDER long.\nconst longestInteractionList = [];\n\n// A mapping of longest interactions by their interaction ID.\n// This is used for faster lookup.\nconst longestInteractionMap = new Map();\n\n// The default `durationThreshold` used across this library for observing\n// `event` entries via PerformanceObserver.\nconst DEFAULT_DURATION_THRESHOLD = 40;\n\n// Used to store the interaction count after a bfcache restore, since p98\n// interaction latencies should only consider the current navigation.\nlet prevInteractionCount = 0;\n\n/**\n * Returns the interaction count since the last bfcache restore (or for the\n * full page lifecycle if there were no bfcache restores).\n */\nconst getInteractionCountForNavigation = () => {\n return getInteractionCount() - prevInteractionCount;\n};\n\n/**\n * Returns the estimated p98 longest interaction based on the stored\n * interaction candidates and the interaction count for the current page.\n */\nconst estimateP98LongestInteraction = () => {\n const candidateInteractionIndex = Math.min(\n longestInteractionList.length - 1,\n Math.floor(getInteractionCountForNavigation() / 50),\n );\n\n return longestInteractionList[candidateInteractionIndex];\n};\n\n// To prevent unnecessary memory usage on pages with lots of interactions,\n// store at most 10 of the longest interactions to consider as INP candidates.\nconst MAX_INTERACTIONS_TO_CONSIDER = 10;\n\n/**\n * A list of callback functions to run before each entry is processed.\n * Exposing this list allows the attribution build to hook into the\n * entry processing pipeline.\n */\nconst entryPreProcessingCallbacks = [];\n\n/**\n * Takes a performance entry and adds it to the list of worst interactions\n * if its duration is long enough to make it among the worst. If the\n * entry is part of an existing interaction, it is merged and the latency\n * and entries list is updated as needed.\n */\nconst processInteractionEntry = (entry) => {\n entryPreProcessingCallbacks.forEach(cb => cb(entry));\n\n // Skip further processing for entries that cannot be INP candidates.\n if (!(entry.interactionId || entry.entryType === 'first-input')) return;\n\n // The least-long of the 10 longest interactions.\n const minLongestInteraction = longestInteractionList[longestInteractionList.length - 1];\n\n const existingInteraction = longestInteractionMap.get(entry.interactionId);\n\n // Only process the entry if it's possibly one of the ten longest,\n // or if it's part of an existing interaction.\n if (\n existingInteraction ||\n longestInteractionList.length < MAX_INTERACTIONS_TO_CONSIDER ||\n (minLongestInteraction && entry.duration > minLongestInteraction.latency)\n ) {\n // If the interaction already exists, update it. Otherwise create one.\n if (existingInteraction) {\n // If the new entry has a longer duration, replace the old entries,\n // otherwise add to the array.\n if (entry.duration > existingInteraction.latency) {\n existingInteraction.entries = [entry];\n existingInteraction.latency = entry.duration;\n } else if (\n entry.duration === existingInteraction.latency &&\n entry.startTime === (existingInteraction.entries[0] && existingInteraction.entries[0].startTime)\n ) {\n existingInteraction.entries.push(entry);\n }\n } else {\n const interaction = {\n id: entry.interactionId,\n latency: entry.duration,\n entries: [entry],\n };\n longestInteractionMap.set(interaction.id, interaction);\n longestInteractionList.push(interaction);\n }\n\n // Sort the entries by latency (descending) and keep only the top ten.\n longestInteractionList.sort((a, b) => b.latency - a.latency);\n if (longestInteractionList.length > MAX_INTERACTIONS_TO_CONSIDER) {\n longestInteractionList.splice(MAX_INTERACTIONS_TO_CONSIDER).forEach(i => longestInteractionMap.delete(i.id));\n }\n }\n};\n\nexport { DEFAULT_DURATION_THRESHOLD, entryPreProcessingCallbacks, estimateP98LongestInteraction, longestInteractionList, longestInteractionMap, processInteractionEntry };\n","import { WINDOW } from '../../../types.js';\nimport { onHidden } from './onHidden.js';\nimport { runOnce } from './runOnce.js';\n\n/*\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n/**\n * Runs the passed callback during the next idle period, or immediately\n * if the browser's visibility state is (or becomes) hidden.\n */\nconst whenIdle = (cb) => {\n const rIC = WINDOW.requestIdleCallback || WINDOW.setTimeout;\n\n let handle = -1;\n // eslint-disable-next-line no-param-reassign\n cb = runOnce(cb) ;\n // If the document is hidden, run the callback immediately, otherwise\n // race an idle callback with the next `visibilitychange` event.\n if (WINDOW.document && WINDOW.document.visibilityState === 'hidden') {\n cb();\n } else {\n handle = rIC(cb);\n onHidden(cb);\n }\n return handle;\n};\n\nexport { whenIdle };\n","import { WINDOW } from '../../types.js';\nimport { bindReporter } from './lib/bindReporter.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { DEFAULT_DURATION_THRESHOLD, processInteractionEntry, estimateP98LongestInteraction } from './lib/interactions.js';\nimport { observe } from './lib/observe.js';\nimport { onHidden } from './lib/onHidden.js';\nimport { initInteractionCountPolyfill } from './lib/polyfills/interactionCountPolyfill.js';\nimport { whenActivated } from './lib/whenActivated.js';\nimport { whenIdle } from './lib/whenIdle.js';\n\n/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n/** Thresholds for INP. See https://web.dev/articles/inp#what_is_a_good_inp_score */\nconst INPThresholds = [200, 500];\n\n/**\n * Calculates the [INP](https://web.dev/articles/inp) value for the current\n * page and calls the `callback` function once the value is ready, along with\n * the `event` performance entries reported for that interaction. The reported\n * value is a `DOMHighResTimeStamp`.\n *\n * A custom `durationThreshold` configuration option can optionally be passed to\n * control what `event-timing` entries are considered for INP reporting. The\n * default threshold is `40`, which means INP scores of less than 40 are\n * reported as 0. Note that this will not affect your 75th percentile INP value\n * unless that value is also less than 40 (well below the recommended\n * [good](https://web.dev/articles/inp#what_is_a_good_inp_score) threshold).\n *\n * If the `reportAllChanges` configuration option is set to `true`, the\n * `callback` function will be called as soon as the value is initially\n * determined as well as any time the value changes throughout the page\n * lifespan.\n *\n * _**Important:** INP should be continually monitored for changes throughout\n * the entire lifespan of a page—including if the user returns to the page after\n * it's been hidden/backgrounded. However, since browsers often [will not fire\n * additional callbacks once the user has backgrounded a\n * page](https://developer.chrome.com/blog/page-lifecycle-api/#advice-hidden),\n * `callback` is always called when the page's visibility state changes to\n * hidden. As a result, the `callback` function might be called multiple times\n * during the same page load._\n */\nconst onINP = (onReport, opts = {}) => {\n // Return if the browser doesn't support all APIs needed to measure INP.\n if (!('PerformanceEventTiming' in WINDOW && 'interactionId' in PerformanceEventTiming.prototype)) {\n return;\n }\n\n whenActivated(() => {\n // TODO(philipwalton): remove once the polyfill is no longer needed.\n initInteractionCountPolyfill();\n\n const metric = initMetric('INP');\n // eslint-disable-next-line prefer-const\n let report;\n\n const handleEntries = (entries) => {\n // Queue the `handleEntries()` callback in the next idle task.\n // This is needed to increase the chances that all event entries that\n // occurred between the user interaction and the next paint\n // have been dispatched. Note: there is currently an experiment\n // running in Chrome (EventTimingKeypressAndCompositionInteractionId)\n // 123+ that if rolled out fully may make this no longer necessary.\n whenIdle(() => {\n entries.forEach(processInteractionEntry);\n\n const inp = estimateP98LongestInteraction();\n\n if (inp && inp.latency !== metric.value) {\n metric.value = inp.latency;\n metric.entries = inp.entries;\n report();\n }\n });\n };\n\n const po = observe('event', handleEntries, {\n // Event Timing entries have their durations rounded to the nearest 8ms,\n // so a duration of 40ms would be any event that spans 2.5 or more frames\n // at 60Hz. This threshold is chosen to strike a balance between usefulness\n // and performance. Running this callback for any interaction that spans\n // just one or two frames is likely not worth the insight that could be\n // gained.\n durationThreshold: opts.durationThreshold != null ? opts.durationThreshold : DEFAULT_DURATION_THRESHOLD,\n });\n\n report = bindReporter(onReport, metric, INPThresholds, opts.reportAllChanges);\n\n if (po) {\n // Also observe entries of type `first-input`. This is useful in cases\n // where the first interaction is less than the `durationThreshold`.\n po.observe({ type: 'first-input', buffered: true });\n\n onHidden(() => {\n handleEntries(po.takeRecords() );\n report(true);\n });\n }\n });\n};\n\nexport { INPThresholds, onINP };\n","import { WINDOW } from '../../types.js';\nimport { bindReporter } from './lib/bindReporter.js';\nimport { getActivationStart } from './lib/getActivationStart.js';\nimport { getVisibilityWatcher } from './lib/getVisibilityWatcher.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { observe } from './lib/observe.js';\nimport { onHidden } from './lib/onHidden.js';\nimport { runOnce } from './lib/runOnce.js';\nimport { whenActivated } from './lib/whenActivated.js';\nimport { whenIdle } from './lib/whenIdle.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n/** Thresholds for LCP. See https://web.dev/articles/lcp#what_is_a_good_lcp_score */\nconst LCPThresholds = [2500, 4000];\n\nconst reportedMetricIDs = {};\n\n/**\n * Calculates the [LCP](https://web.dev/articles/lcp) value for the current page and\n * calls the `callback` function once the value is ready (along with the\n * relevant `largest-contentful-paint` performance entry used to determine the\n * value). The reported value is a `DOMHighResTimeStamp`.\n *\n * If the `reportAllChanges` configuration option is set to `true`, the\n * `callback` function will be called any time a new `largest-contentful-paint`\n * performance entry is dispatched, or once the final value of the metric has\n * been determined.\n */\nconst onLCP = (onReport, opts = {}) => {\n whenActivated(() => {\n const visibilityWatcher = getVisibilityWatcher();\n const metric = initMetric('LCP');\n let report;\n\n const handleEntries = (entries) => {\n // If reportAllChanges is set then call this function for each entry,\n // otherwise only consider the last one.\n if (!opts.reportAllChanges) {\n // eslint-disable-next-line no-param-reassign\n entries = entries.slice(-1);\n }\n\n entries.forEach(entry => {\n // Only report if the page wasn't hidden prior to LCP.\n if (entry.startTime < visibilityWatcher.firstHiddenTime) {\n // The startTime attribute returns the value of the renderTime if it is\n // not 0, and the value of the loadTime otherwise. The activationStart\n // reference is used because LCP should be relative to page activation\n // rather than navigation start if the page was pre-rendered. But in cases\n // where `activationStart` occurs after the LCP, this time should be\n // clamped at 0.\n metric.value = Math.max(entry.startTime - getActivationStart(), 0);\n metric.entries = [entry];\n report();\n }\n });\n };\n\n const po = observe('largest-contentful-paint', handleEntries);\n\n if (po) {\n report = bindReporter(onReport, metric, LCPThresholds, opts.reportAllChanges);\n\n const stopListening = runOnce(() => {\n if (!reportedMetricIDs[metric.id]) {\n handleEntries(po.takeRecords() );\n po.disconnect();\n reportedMetricIDs[metric.id] = true;\n report(true);\n }\n });\n\n // Stop listening after input. Note: while scrolling is an input that\n // stops LCP observation, it's unreliable since it can be programmatically\n // generated. See: https://github.com/GoogleChrome/web-vitals/issues/75\n ['keydown', 'click'].forEach(type => {\n // Wrap in a setTimeout so the callback is run in a separate task\n // to avoid extending the keyboard/click handler to reduce INP impact\n // https://github.com/GoogleChrome/web-vitals/issues/383\n if (WINDOW.document) {\n addEventListener(type, () => whenIdle(stopListening ), {\n once: true,\n capture: true,\n });\n }\n });\n\n onHidden(stopListening);\n }\n });\n};\n\nexport { LCPThresholds, onLCP };\n","import { WINDOW } from '../../types.js';\nimport { bindReporter } from './lib/bindReporter.js';\nimport { getActivationStart } from './lib/getActivationStart.js';\nimport { getNavigationEntry } from './lib/getNavigationEntry.js';\nimport { initMetric } from './lib/initMetric.js';\nimport { whenActivated } from './lib/whenActivated.js';\n\n/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\n/** Thresholds for TTFB. See https://web.dev/articles/ttfb#what_is_a_good_ttfb_score */\nconst TTFBThresholds = [800, 1800];\n\n/**\n * Runs in the next task after the page is done loading and/or prerendering.\n * @param callback\n */\nconst whenReady = (callback) => {\n if (WINDOW.document && WINDOW.document.prerendering) {\n whenActivated(() => whenReady(callback));\n } else if (WINDOW.document && WINDOW.document.readyState !== 'complete') {\n addEventListener('load', () => whenReady(callback), true);\n } else {\n // Queue a task so the callback runs after `loadEventEnd`.\n setTimeout(callback, 0);\n }\n};\n\n/**\n * Calculates the [TTFB](https://web.dev/articles/ttfb) value for the\n * current page and calls the `callback` function once the page has loaded,\n * along with the relevant `navigation` performance entry used to determine the\n * value. The reported value is a `DOMHighResTimeStamp`.\n *\n * Note, this function waits until after the page is loaded to call `callback`\n * in order to ensure all properties of the `navigation` entry are populated.\n * This is useful if you want to report on other metrics exposed by the\n * [Navigation Timing API](https://w3c.github.io/navigation-timing/). For\n * example, the TTFB metric starts from the page's [time\n * origin](https://www.w3.org/TR/hr-time-2/#sec-time-origin), which means it\n * includes time spent on DNS lookup, connection negotiation, network latency,\n * and server processing time.\n */\nconst onTTFB = (onReport, opts = {}) => {\n const metric = initMetric('TTFB');\n const report = bindReporter(onReport, metric, TTFBThresholds, opts.reportAllChanges);\n\n whenReady(() => {\n const navigationEntry = getNavigationEntry();\n\n if (navigationEntry) {\n // The activationStart reference is used because TTFB should be\n // relative to page activation rather than navigation start if the\n // page was prerendered. But in cases where `activationStart` occurs\n // after the first byte is received, this time should be clamped at 0.\n metric.value = Math.max(navigationEntry.responseStart - getActivationStart(), 0);\n\n metric.entries = [navigationEntry];\n report(true);\n }\n });\n};\n\nexport { TTFBThresholds, onTTFB };\n","import { logger, getFunctionName } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { onCLS } from './web-vitals/getCLS.js';\nimport { onFID } from './web-vitals/getFID.js';\nimport { onINP } from './web-vitals/getINP.js';\nimport { onLCP } from './web-vitals/getLCP.js';\nimport { observe } from './web-vitals/lib/observe.js';\nimport { onTTFB } from './web-vitals/onTTFB.js';\n\nconst handlers = {};\nconst instrumented = {};\n\nlet _previousCls;\nlet _previousFid;\nlet _previousLcp;\nlet _previousTtfb;\nlet _previousInp;\n\n/**\n * Add a callback that will be triggered when a CLS metric is available.\n * Returns a cleanup callback which can be called to remove the instrumentation handler.\n *\n * Pass `stopOnCallback = true` to stop listening for CLS when the cleanup callback is called.\n * This will lead to the CLS being finalized and frozen.\n */\nfunction addClsInstrumentationHandler(\n callback,\n stopOnCallback = false,\n) {\n return addMetricObserver('cls', callback, instrumentCls, _previousCls, stopOnCallback);\n}\n\n/**\n * Add a callback that will be triggered when a LCP metric is available.\n * Returns a cleanup callback which can be called to remove the instrumentation handler.\n *\n * Pass `stopOnCallback = true` to stop listening for LCP when the cleanup callback is called.\n * This will lead to the LCP being finalized and frozen.\n */\nfunction addLcpInstrumentationHandler(\n callback,\n stopOnCallback = false,\n) {\n return addMetricObserver('lcp', callback, instrumentLcp, _previousLcp, stopOnCallback);\n}\n\n/**\n * Add a callback that will be triggered when a FID metric is available.\n * Returns a cleanup callback which can be called to remove the instrumentation handler.\n */\nfunction addFidInstrumentationHandler(callback) {\n return addMetricObserver('fid', callback, instrumentFid, _previousFid);\n}\n\n/**\n * Add a callback that will be triggered when a FID metric is available.\n */\nfunction addTtfbInstrumentationHandler(callback) {\n return addMetricObserver('ttfb', callback, instrumentTtfb, _previousTtfb);\n}\n\n/**\n * Add a callback that will be triggered when a INP metric is available.\n * Returns a cleanup callback which can be called to remove the instrumentation handler.\n */\nfunction addInpInstrumentationHandler(\n callback,\n) {\n return addMetricObserver('inp', callback, instrumentInp, _previousInp);\n}\n\n/**\n * Add a callback that will be triggered when a performance observer is triggered,\n * and receives the entries of the observer.\n * Returns a cleanup callback which can be called to remove the instrumentation handler.\n */\nfunction addPerformanceInstrumentationHandler(\n type,\n callback,\n) {\n addHandler(type, callback);\n\n if (!instrumented[type]) {\n instrumentPerformanceObserver(type);\n instrumented[type] = true;\n }\n\n return getCleanupCallback(type, callback);\n}\n\n/** Trigger all handlers of a given type. */\nfunction triggerHandlers(type, data) {\n const typeHandlers = handlers[type];\n\n if (!typeHandlers || !typeHandlers.length) {\n return;\n }\n\n for (const handler of typeHandlers) {\n try {\n handler(data);\n } catch (e) {\n DEBUG_BUILD &&\n logger.error(\n `Error while triggering instrumentation handler.\\nType: ${type}\\nName: ${getFunctionName(handler)}\\nError:`,\n e,\n );\n }\n }\n}\n\nfunction instrumentCls() {\n return onCLS(\n metric => {\n triggerHandlers('cls', {\n metric,\n });\n _previousCls = metric;\n },\n // We want the callback to be called whenever the CLS value updates.\n // By default, the callback is only called when the tab goes to the background.\n { reportAllChanges: true },\n );\n}\n\nfunction instrumentFid() {\n return onFID(metric => {\n triggerHandlers('fid', {\n metric,\n });\n _previousFid = metric;\n });\n}\n\nfunction instrumentLcp() {\n return onLCP(\n metric => {\n triggerHandlers('lcp', {\n metric,\n });\n _previousLcp = metric;\n },\n // We want the callback to be called whenever the LCP value updates.\n // By default, the callback is only called when the tab goes to the background.\n { reportAllChanges: true },\n );\n}\n\nfunction instrumentTtfb() {\n return onTTFB(metric => {\n triggerHandlers('ttfb', {\n metric,\n });\n _previousTtfb = metric;\n });\n}\n\nfunction instrumentInp() {\n return onINP(metric => {\n triggerHandlers('inp', {\n metric,\n });\n _previousInp = metric;\n });\n}\n\nfunction addMetricObserver(\n type,\n callback,\n instrumentFn,\n previousValue,\n stopOnCallback = false,\n) {\n addHandler(type, callback);\n\n let stopListening;\n\n if (!instrumented[type]) {\n stopListening = instrumentFn();\n instrumented[type] = true;\n }\n\n if (previousValue) {\n callback({ metric: previousValue });\n }\n\n return getCleanupCallback(type, callback, stopOnCallback ? stopListening : undefined);\n}\n\nfunction instrumentPerformanceObserver(type) {\n const options = {};\n\n // Special per-type options we want to use\n if (type === 'event') {\n options.durationThreshold = 0;\n }\n\n observe(\n type,\n entries => {\n triggerHandlers(type, { entries });\n },\n options,\n );\n}\n\nfunction addHandler(type, handler) {\n handlers[type] = handlers[type] || [];\n (handlers[type] ).push(handler);\n}\n\n// Get a callback which can be called to remove the instrumentation handler\nfunction getCleanupCallback(\n type,\n callback,\n stopListening,\n) {\n return () => {\n if (stopListening) {\n stopListening();\n }\n\n const typeHandlers = handlers[type];\n\n if (!typeHandlers) {\n return;\n }\n\n const index = typeHandlers.indexOf(callback);\n if (index !== -1) {\n typeHandlers.splice(index, 1);\n }\n };\n}\n\n/**\n * Check if a PerformanceEntry is a PerformanceEventTiming by checking for the `duration` property.\n */\nfunction isPerformanceEventTiming(entry) {\n return 'duration' in entry;\n}\n\nexport { addClsInstrumentationHandler, addFidInstrumentationHandler, addInpInstrumentationHandler, addLcpInstrumentationHandler, addPerformanceInstrumentationHandler, addTtfbInstrumentationHandler, isPerformanceEventTiming };\n","import { generateTraceId, generateSpanId } from '../utils-hoist/propagationContext.js';\nimport { TRACE_FLAG_NONE } from '../utils/spanUtils.js';\n\n/**\n * A Sentry Span that is non-recording, meaning it will not be sent to Sentry.\n */\nclass SentryNonRecordingSpan {\n\n constructor(spanContext = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n }\n\n /** @inheritdoc */\n spanContext() {\n return {\n spanId: this._spanId,\n traceId: this._traceId,\n traceFlags: TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n end(_timestamp) {}\n\n /** @inheritdoc */\n setAttribute(_key, _value) {\n return this;\n }\n\n /** @inheritdoc */\n setAttributes(_values) {\n return this;\n }\n\n /** @inheritdoc */\n setStatus(_status) {\n return this;\n }\n\n /** @inheritdoc */\n updateName(_name) {\n return this;\n }\n\n /** @inheritdoc */\n isRecording() {\n return false;\n }\n\n /** @inheritdoc */\n addEvent(\n _name,\n _attributesOrStartTime,\n _startTime,\n ) {\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n addLink(_link) {\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n addLinks(_links) {\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n recordException(_exception, _time) {\n // noop\n }\n}\n\nexport { SentryNonRecordingSpan };\n","import { addNonEnumerableProperty } from '../utils-hoist/object.js';\n\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\n/** Store the scope & isolation scope for a span, which can the be used when it is finished. */\nfunction setCapturedScopesOnSpan(span, scope, isolationScope) {\n if (span) {\n addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);\n addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);\n }\n}\n\n/**\n * Grabs the scope and isolation scope off a span that were active when the span was started.\n */\nfunction getCapturedScopesOnSpan(span) {\n return {\n scope: (span )[SCOPE_ON_START_SPAN_FIELD],\n isolationScope: (span )[ISOLATION_SCOPE_ON_START_SPAN_FIELD],\n };\n}\n\nexport { getCapturedScopesOnSpan, setCapturedScopesOnSpan };\n","import { getClient, getCurrentScope } from '../currentScopes.js';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { createSpanEnvelope } from '../envelope.js';\nimport { getMetricSummaryJsonForSpan } from '../metrics/metric-summary.js';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME } from '../semanticAttributes.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { dropUndefinedKeys } from '../utils-hoist/object.js';\nimport { generateTraceId, generateSpanId } from '../utils-hoist/propagationContext.js';\nimport { timestampInSeconds } from '../utils-hoist/time.js';\nimport { TRACE_FLAG_SAMPLED, TRACE_FLAG_NONE, spanTimeInputToSeconds, getStatusMessage, getRootSpan, spanToJSON, getSpanDescendants, spanToTransactionTraceContext } from '../utils/spanUtils.js';\nimport { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext.js';\nimport { logSpanEnd } from './logSpans.js';\nimport { timedEventsToMeasurements } from './measurement.js';\nimport { getCapturedScopesOnSpan } from './utils.js';\n\nconst MAX_SPAN_COUNT = 1000;\n\n/**\n * Span contains all data about a span\n */\nclass SentrySpan {\n\n /** Epoch timestamp in seconds when the span started. */\n\n /** Epoch timestamp in seconds when the span ended. */\n\n /** Internal keeper of the status */\n\n /** The timed events added to this span. */\n\n /** if true, treat span as a standalone span (not part of a transaction) */\n\n /**\n * You should never call the constructor manually, always use `Sentry.startSpan()`\n * or other span methods.\n * @internal\n * @hideconstructor\n * @hidden\n */\n constructor(spanContext = {}) {\n this._traceId = spanContext.traceId || generateTraceId();\n this._spanId = spanContext.spanId || generateSpanId();\n this._startTime = spanContext.startTimestamp || timestampInSeconds();\n\n this._attributes = {};\n this.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,\n ...spanContext.attributes,\n });\n\n this._name = spanContext.name;\n\n if (spanContext.parentSpanId) {\n this._parentSpanId = spanContext.parentSpanId;\n }\n // We want to include booleans as well here\n if ('sampled' in spanContext) {\n this._sampled = spanContext.sampled;\n }\n if (spanContext.endTimestamp) {\n this._endTime = spanContext.endTimestamp;\n }\n\n this._events = [];\n\n this._isStandaloneSpan = spanContext.isStandalone;\n\n // If the span is already ended, ensure we finalize the span immediately\n if (this._endTime) {\n this._onSpanEnded();\n }\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n addLink(_link) {\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n addLinks(_links) {\n return this;\n }\n\n /**\n * This should generally not be used,\n * but it is needed for being compliant with the OTEL Span interface.\n *\n * @hidden\n * @internal\n */\n recordException(_exception, _time) {\n // noop\n }\n\n /** @inheritdoc */\n spanContext() {\n const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;\n return {\n spanId,\n traceId,\n traceFlags: sampled ? TRACE_FLAG_SAMPLED : TRACE_FLAG_NONE,\n };\n }\n\n /** @inheritdoc */\n setAttribute(key, value) {\n if (value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n } else {\n this._attributes[key] = value;\n }\n\n return this;\n }\n\n /** @inheritdoc */\n setAttributes(attributes) {\n Object.keys(attributes).forEach(key => this.setAttribute(key, attributes[key]));\n return this;\n }\n\n /**\n * This should generally not be used,\n * but we need it for browser tracing where we want to adjust the start time afterwards.\n * USE THIS WITH CAUTION!\n *\n * @hidden\n * @internal\n */\n updateStartTime(timeInput) {\n this._startTime = spanTimeInputToSeconds(timeInput);\n }\n\n /**\n * @inheritDoc\n */\n setStatus(value) {\n this._status = value;\n return this;\n }\n\n /**\n * @inheritDoc\n */\n updateName(name) {\n this._name = name;\n this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');\n return this;\n }\n\n /** @inheritdoc */\n end(endTimestamp) {\n // If already ended, skip\n if (this._endTime) {\n return;\n }\n\n this._endTime = spanTimeInputToSeconds(endTimestamp);\n logSpanEnd(this);\n\n this._onSpanEnded();\n }\n\n /**\n * Get JSON representation of this span.\n *\n * @hidden\n * @internal This method is purely for internal purposes and should not be used outside\n * of SDK code. If you need to get a JSON representation of a span,\n * use `spanToJSON(span)` instead.\n */\n getSpanJSON() {\n return dropUndefinedKeys({\n data: this._attributes,\n description: this._name,\n op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],\n parent_span_id: this._parentSpanId,\n span_id: this._spanId,\n start_timestamp: this._startTime,\n status: getStatusMessage(this._status),\n timestamp: this._endTime,\n trace_id: this._traceId,\n origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] ,\n _metrics_summary: getMetricSummaryJsonForSpan(this),\n profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] ,\n exclusive_time: this._attributes[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME] ,\n measurements: timedEventsToMeasurements(this._events),\n is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,\n segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,\n });\n }\n\n /** @inheritdoc */\n isRecording() {\n return !this._endTime && !!this._sampled;\n }\n\n /**\n * @inheritdoc\n */\n addEvent(\n name,\n attributesOrStartTime,\n startTime,\n ) {\n DEBUG_BUILD && logger.log('[Tracing] Adding an event to span:', name);\n\n const time = isSpanTimeInput(attributesOrStartTime) ? attributesOrStartTime : startTime || timestampInSeconds();\n const attributes = isSpanTimeInput(attributesOrStartTime) ? {} : attributesOrStartTime || {};\n\n const event = {\n name,\n time: spanTimeInputToSeconds(time),\n attributes,\n };\n\n this._events.push(event);\n\n return this;\n }\n\n /**\n * This method should generally not be used,\n * but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.\n * USE THIS WITH CAUTION!\n * @internal\n * @hidden\n * @experimental\n */\n isStandaloneSpan() {\n return !!this._isStandaloneSpan;\n }\n\n /** Emit `spanEnd` when the span is ended. */\n _onSpanEnded() {\n const client = getClient();\n if (client) {\n client.emit('spanEnd', this);\n }\n\n // A segment span is basically the root span of a local span tree.\n // So for now, this is either what we previously refer to as the root span,\n // or a standalone span.\n const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);\n\n if (!isSegmentSpan) {\n return;\n }\n\n // if this is a standalone span, we send it immediately\n if (this._isStandaloneSpan) {\n if (this._sampled) {\n sendSpanEnvelope(createSpanEnvelope([this], client));\n } else {\n DEBUG_BUILD &&\n logger.log('[Tracing] Discarding standalone span because its trace was not chosen to be sampled.');\n if (client) {\n client.recordDroppedEvent('sample_rate', 'span');\n }\n }\n return;\n }\n\n const transactionEvent = this._convertSpanToTransaction();\n if (transactionEvent) {\n const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();\n scope.captureEvent(transactionEvent);\n }\n }\n\n /**\n * Finish the transaction & prepare the event to send to Sentry.\n */\n _convertSpanToTransaction() {\n // We can only convert finished spans\n if (!isFullFinishedSpan(spanToJSON(this))) {\n return undefined;\n }\n\n if (!this._name) {\n DEBUG_BUILD && logger.warn('Transaction has no name, falling back to ``.');\n this._name = '';\n }\n\n const { scope: capturedSpanScope, isolationScope: capturedSpanIsolationScope } = getCapturedScopesOnSpan(this);\n const scope = capturedSpanScope || getCurrentScope();\n const client = scope.getClient() || getClient();\n\n if (this._sampled !== true) {\n // At this point if `sampled !== true` we want to discard the transaction.\n DEBUG_BUILD && logger.log('[Tracing] Discarding transaction because its trace was not chosen to be sampled.');\n\n if (client) {\n client.recordDroppedEvent('sample_rate', 'transaction');\n }\n\n return undefined;\n }\n\n // The transaction span itself as well as any potential standalone spans should be filtered out\n const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));\n\n const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);\n\n const source = this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ;\n\n // remove internal root span attributes we don't need to send.\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n spans.forEach(span => {\n span.data && delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];\n });\n // eslint-enabled-next-line @typescript-eslint/no-dynamic-delete\n\n const transaction = {\n contexts: {\n trace: spanToTransactionTraceContext(this),\n },\n spans:\n // spans.sort() mutates the array, but `spans` is already a copy so we can safely do this here\n // we do not use spans anymore after this point\n spans.length > MAX_SPAN_COUNT\n ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)\n : spans,\n start_timestamp: this._startTime,\n timestamp: this._endTime,\n transaction: this._name,\n type: 'transaction',\n sdkProcessingMetadata: {\n capturedSpanScope,\n capturedSpanIsolationScope,\n ...dropUndefinedKeys({\n dynamicSamplingContext: getDynamicSamplingContextFromSpan(this),\n }),\n },\n _metrics_summary: getMetricSummaryJsonForSpan(this),\n ...(source && {\n transaction_info: {\n source,\n },\n }),\n };\n\n const measurements = timedEventsToMeasurements(this._events);\n const hasMeasurements = measurements && Object.keys(measurements).length;\n\n if (hasMeasurements) {\n DEBUG_BUILD &&\n logger.log(\n '[Measurements] Adding measurements to transaction event',\n JSON.stringify(measurements, undefined, 2),\n );\n transaction.measurements = measurements;\n }\n\n return transaction;\n }\n}\n\nfunction isSpanTimeInput(value) {\n return (value && typeof value === 'number') || value instanceof Date || Array.isArray(value);\n}\n\n// We want to filter out any incomplete SpanJSON objects\nfunction isFullFinishedSpan(input) {\n return !!input.start_timestamp && !!input.timestamp && !!input.span_id && !!input.trace_id;\n}\n\n/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */\nfunction isStandaloneSpan(span) {\n return span instanceof SentrySpan && span.isStandaloneSpan();\n}\n\n/**\n * Sends a `SpanEnvelope`.\n *\n * Note: If the envelope's spans are dropped, e.g. via `beforeSendSpan`,\n * the envelope will not be sent either.\n */\nfunction sendSpanEnvelope(envelope) {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const spanItems = envelope[1];\n if (!spanItems || spanItems.length === 0) {\n client.recordDroppedEvent('before_send', 'span');\n return;\n }\n\n // sendEnvelope should not throw\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n client.sendEnvelope(envelope);\n}\n\nexport { SentrySpan };\n","import { DEBUG_BUILD } from '../debug-build.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { spanToJSON, spanIsSampled, getRootSpan } from '../utils/spanUtils.js';\n\n/**\n * Print a log message for a started span.\n */\nfunction logSpanStart(span) {\n if (!DEBUG_BUILD) return;\n\n const { description = '< unknown name >', op = '< unknown op >', parent_span_id: parentSpanId } = spanToJSON(span);\n const { spanId } = span.spanContext();\n\n const sampled = spanIsSampled(span);\n const rootSpan = getRootSpan(span);\n const isRootSpan = rootSpan === span;\n\n const header = `[Tracing] Starting ${sampled ? 'sampled' : 'unsampled'} ${isRootSpan ? 'root ' : ''}span`;\n\n const infoParts = [`op: ${op}`, `name: ${description}`, `ID: ${spanId}`];\n\n if (parentSpanId) {\n infoParts.push(`parent ID: ${parentSpanId}`);\n }\n\n if (!isRootSpan) {\n const { op, description } = spanToJSON(rootSpan);\n infoParts.push(`root ID: ${rootSpan.spanContext().spanId}`);\n if (op) {\n infoParts.push(`root op: ${op}`);\n }\n if (description) {\n infoParts.push(`root description: ${description}`);\n }\n }\n\n logger.log(`${header}\n ${infoParts.join('\\n ')}`);\n}\n\n/**\n * Print a log message for an ended span.\n */\nfunction logSpanEnd(span) {\n if (!DEBUG_BUILD) return;\n\n const { description = '< unknown name >', op = '< unknown op >' } = spanToJSON(span);\n const { spanId } = span.spanContext();\n const rootSpan = getRootSpan(span);\n const isRootSpan = rootSpan === span;\n\n const msg = `[Tracing] Finishing \"${op}\" ${isRootSpan ? 'root ' : ''}span \"${description}\" with ID ${spanId}`;\n logger.log(msg);\n}\n\nexport { logSpanEnd, logSpanStart };\n","import { getMainCarrier } from '../carrier.js';\nimport { withScope, getCurrentScope, getIsolationScope, getClient } from '../currentScopes.js';\nimport { getAsyncContextStrategy } from '../asyncContext/index.js';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE } from '../semanticAttributes.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { generateTraceId } from '../utils-hoist/propagationContext.js';\nimport { propagationContextFromHeaders } from '../utils-hoist/tracing.js';\nimport { handleCallbackErrors } from '../utils/handleCallbackErrors.js';\nimport { hasTracingEnabled } from '../utils/hasTracingEnabled.js';\nimport { _setSpanForScope, _getSpanForScope } from '../utils/spanOnScope.js';\nimport { spanToJSON, addChildSpanToSpan, spanIsSampled, spanTimeInputToSeconds, getRootSpan } from '../utils/spanUtils.js';\nimport { getDynamicSamplingContextFromSpan, freezeDscOnSpan } from './dynamicSamplingContext.js';\nimport { logSpanStart } from './logSpans.js';\nimport { sampleSpan } from './sampling.js';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan.js';\nimport { SentrySpan } from './sentrySpan.js';\nimport { SPAN_STATUS_ERROR } from './spanstatus.js';\nimport { setCapturedScopesOnSpan } from './utils.js';\n\nconst SUPPRESS_TRACING_KEY = '__SENTRY_SUPPRESS_TRACING__';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nfunction startSpan(options, callback) {\n const acs = getAcs();\n if (acs.startSpan) {\n return acs.startSpan(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n return withScope(options.scope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n _setSpanForScope(scope, activeSpan);\n\n return handleCallbackErrors(\n () => callback(activeSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n () => activeSpan.end(),\n );\n });\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span\n * after the function is done automatically. You'll have to call `span.end()` manually.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * You'll always get a span passed to the callback,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nfunction startSpanManual(options, callback) {\n const acs = getAcs();\n if (acs.startSpanManual) {\n return acs.startSpanManual(options, callback);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n return withScope(options.scope, () => {\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = getActiveSpanWrapper(customParentSpan);\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n const activeSpan = shouldSkipSpan\n ? new SentryNonRecordingSpan()\n : createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n\n _setSpanForScope(scope, activeSpan);\n\n function finishAndSetSpan() {\n activeSpan.end();\n }\n\n return handleCallbackErrors(\n () => callback(activeSpan, finishAndSetSpan),\n () => {\n // Only update the span status if it hasn't been changed yet, and the span is not yet finished\n const { status } = spanToJSON(activeSpan);\n if (activeSpan.isRecording() && (!status || status === 'ok')) {\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n },\n );\n });\n });\n}\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getActiveSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * This function will always return a span,\n * it may just be a non-recording span if the span is not sampled or if tracing is disabled.\n */\nfunction startInactiveSpan(options) {\n const acs = getAcs();\n if (acs.startInactiveSpan) {\n return acs.startInactiveSpan(options);\n }\n\n const spanArguments = parseSentrySpanArguments(options);\n const { forceTransaction, parentSpan: customParentSpan } = options;\n\n // If `options.scope` is defined, we use this as as a wrapper,\n // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`\n const wrapper = options.scope\n ? (callback) => withScope(options.scope, callback)\n : customParentSpan !== undefined\n ? (callback) => withActiveSpan(customParentSpan, callback)\n : (callback) => callback();\n\n return wrapper(() => {\n const scope = getCurrentScope();\n const parentSpan = getParentSpan(scope);\n\n const shouldSkipSpan = options.onlyIfParent && !parentSpan;\n\n if (shouldSkipSpan) {\n return new SentryNonRecordingSpan();\n }\n\n return createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n });\n });\n}\n\n/**\n * Continue a trace from `sentry-trace` and `baggage` values.\n * These values can be obtained from incoming request headers, or in the browser from ``\n * and `` HTML tags.\n *\n * Spans started with `startSpan`, `startSpanManual` and `startInactiveSpan`, within the callback will automatically\n * be attached to the incoming trace.\n */\nconst continueTrace = (\n options\n\n,\n callback,\n) => {\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.continueTrace) {\n return acs.continueTrace(options, callback);\n }\n\n const { sentryTrace, baggage } = options;\n\n return withScope(scope => {\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n scope.setPropagationContext(propagationContext);\n return callback();\n });\n};\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nfunction withActiveSpan(span, callback) {\n const acs = getAcs();\n if (acs.withActiveSpan) {\n return acs.withActiveSpan(span, callback);\n }\n\n return withScope(scope => {\n _setSpanForScope(scope, span || undefined);\n return callback(scope);\n });\n}\n\n/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */\nfunction suppressTracing(callback) {\n const acs = getAcs();\n\n if (acs.suppressTracing) {\n return acs.suppressTracing(callback);\n }\n\n return withScope(scope => {\n scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });\n return callback();\n });\n}\n\n/**\n * Starts a new trace for the duration of the provided callback. Spans started within the\n * callback will be part of the new trace instead of a potentially previously started trace.\n *\n * Important: Only use this function if you want to override the default trace lifetime and\n * propagation mechanism of the SDK for the duration and scope of the provided callback.\n * The newly created trace will also be the root of a new distributed trace, for example if\n * you make http requests within the callback.\n * This function might be useful if the operation you want to instrument should not be part\n * of a potentially ongoing trace.\n *\n * Default behavior:\n * - Server-side: A new trace is started for each incoming request.\n * - Browser: A new trace is started for each page our route. Navigating to a new route\n * or page will automatically create a new trace.\n */\nfunction startNewTrace(callback) {\n return withScope(scope => {\n scope.setPropagationContext({ traceId: generateTraceId() });\n DEBUG_BUILD && logger.info(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);\n return withActiveSpan(null, callback);\n });\n}\n\nfunction createChildOrRootSpan({\n parentSpan,\n spanArguments,\n forceTransaction,\n scope,\n}\n\n) {\n if (!hasTracingEnabled()) {\n return new SentryNonRecordingSpan();\n }\n\n const isolationScope = getIsolationScope();\n\n let span;\n if (parentSpan && !forceTransaction) {\n span = _startChildSpan(parentSpan, scope, spanArguments);\n addChildSpanToSpan(parentSpan, span);\n } else if (parentSpan) {\n // If we forced a transaction but have a parent span, make sure to continue from the parent span, not the scope\n const dsc = getDynamicSamplingContextFromSpan(parentSpan);\n const { traceId, spanId: parentSpanId } = parentSpan.spanContext();\n const parentSampled = spanIsSampled(parentSpan);\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n freezeDscOnSpan(span, dsc);\n } else {\n const {\n traceId,\n dsc,\n parentSpanId,\n sampled: parentSampled,\n } = {\n ...isolationScope.getPropagationContext(),\n ...scope.getPropagationContext(),\n };\n\n span = _startRootSpan(\n {\n traceId,\n parentSpanId,\n ...spanArguments,\n },\n scope,\n parentSampled,\n );\n\n if (dsc) {\n freezeDscOnSpan(span, dsc);\n }\n }\n\n logSpanStart(span);\n\n setCapturedScopesOnSpan(span, scope, isolationScope);\n\n return span;\n}\n\n/**\n * This converts StartSpanOptions to SentrySpanArguments.\n * For the most part (for now) we accept the same options,\n * but some of them need to be transformed.\n */\nfunction parseSentrySpanArguments(options) {\n const exp = options.experimental || {};\n const initialCtx = {\n isStandalone: exp.standalone,\n ...options,\n };\n\n if (options.startTime) {\n const ctx = { ...initialCtx };\n ctx.startTimestamp = spanTimeInputToSeconds(options.startTime);\n delete ctx.startTime;\n return ctx;\n }\n\n return initialCtx;\n}\n\nfunction getAcs() {\n const carrier = getMainCarrier();\n return getAsyncContextStrategy(carrier);\n}\n\nfunction _startRootSpan(spanArguments, scope, parentSampled) {\n const client = getClient();\n const options = (client && client.getOptions()) || {};\n\n const { name = '', attributes } = spanArguments;\n const [sampled, sampleRate] = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY]\n ? [false]\n : sampleSpan(options, {\n name,\n parentSampled,\n attributes,\n transactionContext: {\n name,\n parentSampled,\n },\n });\n\n const rootSpan = new SentrySpan({\n ...spanArguments,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',\n ...spanArguments.attributes,\n },\n sampled,\n });\n if (sampleRate !== undefined) {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, sampleRate);\n }\n\n if (client) {\n client.emit('spanStart', rootSpan);\n }\n\n return rootSpan;\n}\n\n/**\n * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.\n * This inherits the sampling decision from the parent span.\n */\nfunction _startChildSpan(parentSpan, scope, spanArguments) {\n const { spanId, traceId } = parentSpan.spanContext();\n const sampled = scope.getScopeData().sdkProcessingMetadata[SUPPRESS_TRACING_KEY] ? false : spanIsSampled(parentSpan);\n\n const childSpan = sampled\n ? new SentrySpan({\n ...spanArguments,\n parentSpanId: spanId,\n traceId,\n sampled,\n })\n : new SentryNonRecordingSpan({ traceId });\n\n addChildSpanToSpan(parentSpan, childSpan);\n\n const client = getClient();\n if (client) {\n client.emit('spanStart', childSpan);\n // If it has an endTimestamp, it's already ended\n if (spanArguments.endTimestamp) {\n client.emit('spanEnd', childSpan);\n }\n }\n\n return childSpan;\n}\n\nfunction getParentSpan(scope) {\n const span = _getSpanForScope(scope) ;\n\n if (!span) {\n return undefined;\n }\n\n const client = getClient();\n const options = client ? client.getOptions() : {};\n if (options.parentSpanIsAlwaysRootSpan) {\n return getRootSpan(span) ;\n }\n\n return span;\n}\n\nfunction getActiveSpanWrapper(parentSpan) {\n return parentSpan !== undefined\n ? (callback) => {\n return withActiveSpan(parentSpan, callback);\n }\n : (callback) => callback();\n}\n\nexport { continueTrace, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, withActiveSpan };\n","import { getIsolationScope } from '../currentScopes.js';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { hasTracingEnabled } from '../utils/hasTracingEnabled.js';\nimport { parseSampleRate } from '../utils/parseSampleRate.js';\n\n/**\n * Makes a sampling decision for the given options.\n *\n * Called every time a root span is created. Only root spans which emerge with a `sampled` value of `true` will be\n * sent to Sentry.\n */\nfunction sampleSpan(\n options,\n samplingContext,\n) {\n // nothing to do if tracing is not enabled\n if (!hasTracingEnabled(options)) {\n return [false];\n }\n\n // Casting this from unknown, as the type of `sdkProcessingMetadata` is only changed in v9 and `normalizedRequest` is set in SentryHttpInstrumentation\n const normalizedRequest = getIsolationScope().getScopeData().sdkProcessingMetadata\n .normalizedRequest ;\n\n const enhancedSamplingContext = {\n ...samplingContext,\n normalizedRequest: samplingContext.normalizedRequest || normalizedRequest,\n };\n\n // we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` nor `enableTracing` were defined, so one of these should\n // work; prefer the hook if so\n let sampleRate;\n if (typeof options.tracesSampler === 'function') {\n sampleRate = options.tracesSampler(enhancedSamplingContext);\n } else if (enhancedSamplingContext.parentSampled !== undefined) {\n sampleRate = enhancedSamplingContext.parentSampled;\n } else if (typeof options.tracesSampleRate !== 'undefined') {\n sampleRate = options.tracesSampleRate;\n } else {\n // When `enableTracing === true`, we use a sample rate of 100%\n sampleRate = 1;\n }\n\n // Since this is coming from the user (or from a function provided by the user), who knows what we might get.\n // (The only valid values are booleans or numbers between 0 and 1.)\n const parsedSampleRate = parseSampleRate(sampleRate);\n\n if (parsedSampleRate === undefined) {\n DEBUG_BUILD && logger.warn('[Tracing] Discarding transaction because of invalid sample rate.');\n return [false];\n }\n\n // if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped\n if (!parsedSampleRate) {\n DEBUG_BUILD &&\n logger.log(\n `[Tracing] Discarding transaction because ${\n typeof options.tracesSampler === 'function'\n ? 'tracesSampler returned 0 or false'\n : 'a negative sampling decision was inherited or tracesSampleRate is set to 0'\n }`,\n );\n return [false, parsedSampleRate];\n }\n\n // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is\n // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.\n const shouldSample = Math.random() < parsedSampleRate;\n\n // if we're not going to keep it, we're done\n if (!shouldSample) {\n DEBUG_BUILD &&\n logger.log(\n `[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number(\n sampleRate,\n )})`,\n );\n return [false, parsedSampleRate];\n }\n\n return [true, parsedSampleRate];\n}\n\nexport { sampleSpan };\n","import { spanToJSON, withActiveSpan, startInactiveSpan, getClient, getCurrentScope } from '@sentry/core';\nimport { WINDOW } from '../types.js';\n\n/**\n * Checks if a given value is a valid measurement value.\n */\nfunction isMeasurementValue(value) {\n return typeof value === 'number' && isFinite(value);\n}\n\n/**\n * Helper function to start child on transactions. This function will make sure that the transaction will\n * use the start timestamp of the created child span if it is earlier than the transactions actual\n * start timestamp.\n */\nfunction startAndEndSpan(\n parentSpan,\n startTimeInSeconds,\n endTime,\n { ...ctx },\n) {\n const parentStartTime = spanToJSON(parentSpan).start_timestamp;\n if (parentStartTime && parentStartTime > startTimeInSeconds) {\n // We can only do this for SentrySpans...\n if (typeof (parentSpan ).updateStartTime === 'function') {\n (parentSpan ).updateStartTime(startTimeInSeconds);\n }\n }\n\n // The return value only exists for tests\n return withActiveSpan(parentSpan, () => {\n const span = startInactiveSpan({\n startTime: startTimeInSeconds,\n ...ctx,\n });\n\n if (span) {\n span.end(endTime);\n }\n\n return span;\n });\n}\n\n/**\n * Starts an inactive, standalone span used to send web vital values to Sentry.\n * DO NOT use this for arbitrary spans, as these spans require special handling\n * during ingestion to extract metrics.\n *\n * This function adds a bunch of attributes and data to the span that's shared\n * by all web vital standalone spans. However, you need to take care of adding\n * the actual web vital value as an event to the span. Also, you need to assign\n * a transaction name and some other values that are specific to the web vital.\n *\n * Ultimately, you also need to take care of ending the span to send it off.\n *\n * @param options\n *\n * @returns an inactive, standalone and NOT YET ended span\n */\nfunction startStandaloneWebVitalSpan(options) {\n const client = getClient();\n if (!client) {\n return;\n }\n\n const { name, transaction, attributes: passedAttributes, startTime } = options;\n\n const { release, environment } = client.getOptions();\n // We need to get the replay, user, and activeTransaction from the current scope\n // so that we can associate replay id, profile id, and a user display to the span\n const replay = client.getIntegrationByName('Replay');\n const replayId = replay && replay.getReplayId();\n\n const scope = getCurrentScope();\n\n const user = scope.getUser();\n const userDisplay = user !== undefined ? user.email || user.id || user.ip_address : undefined;\n\n let profileId;\n try {\n // @ts-expect-error skip optional chaining to save bundle size with try catch\n profileId = scope.getScopeData().contexts.profile.profile_id;\n } catch (e) {\n // do nothing\n }\n\n const attributes = {\n release,\n environment,\n\n user: userDisplay || undefined,\n profile_id: profileId || undefined,\n replay_id: replayId || undefined,\n\n transaction,\n\n // Web vital score calculation relies on the user agent to account for different\n // browsers setting different thresholds for what is considered a good/meh/bad value.\n // For example: Chrome vs. Chrome Mobile\n 'user_agent.original': WINDOW.navigator && WINDOW.navigator.userAgent,\n\n ...passedAttributes,\n };\n\n return startInactiveSpan({\n name,\n attributes,\n startTime,\n experimental: {\n standalone: true,\n },\n });\n}\n\n/** Get the browser performance API. */\nfunction getBrowserPerformanceAPI() {\n // @ts-expect-error we want to make sure all of these are available, even if TS is sure they are\n return WINDOW && WINDOW.addEventListener && WINDOW.performance;\n}\n\n/**\n * Converts from milliseconds to seconds\n * @param time time in ms\n */\nfunction msToSec(time) {\n return time / 1000;\n}\n\nexport { getBrowserPerformanceAPI, isMeasurementValue, msToSec, startAndEndSpan, startStandaloneWebVitalSpan };\n","import { browserPerformanceTimeOrigin, getActiveSpan, spanToJSON, setMeasurement, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, parseUrl, htmlTreeAsString, getComponentName } from '@sentry/core';\nimport { WINDOW } from '../types.js';\nimport { trackClsAsStandaloneSpan } from './cls.js';\nimport { addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addLcpInstrumentationHandler, addFidInstrumentationHandler, addTtfbInstrumentationHandler } from './instrument.js';\nimport { getBrowserPerformanceAPI, msToSec, startAndEndSpan, isMeasurementValue } from './utils.js';\nimport { getActivationStart } from './web-vitals/lib/getActivationStart.js';\nimport { getNavigationEntry } from './web-vitals/lib/getNavigationEntry.js';\nimport { getVisibilityWatcher } from './web-vitals/lib/getVisibilityWatcher.js';\n\nconst MAX_INT_AS_BYTES = 2147483647;\n\nlet _performanceCursor = 0;\n\nlet _measurements = {};\nlet _lcpEntry;\nlet _clsEntry;\n\n/**\n * Start tracking web vitals.\n * The callback returned by this function can be used to stop tracking & ensure all measurements are final & captured.\n *\n * @returns A function that forces web vitals collection\n */\nfunction startTrackingWebVitals({ recordClsStandaloneSpans }) {\n const performance = getBrowserPerformanceAPI();\n if (performance && browserPerformanceTimeOrigin) {\n // @ts-expect-error we want to make sure all of these are available, even if TS is sure they are\n if (performance.mark) {\n WINDOW.performance.mark('sentry-tracing-init');\n }\n const fidCleanupCallback = _trackFID();\n const lcpCleanupCallback = _trackLCP();\n const ttfbCleanupCallback = _trackTtfb();\n const clsCleanupCallback = recordClsStandaloneSpans ? trackClsAsStandaloneSpan() : _trackCLS();\n\n return () => {\n fidCleanupCallback();\n lcpCleanupCallback();\n ttfbCleanupCallback();\n clsCleanupCallback && clsCleanupCallback();\n };\n }\n\n return () => undefined;\n}\n\n/**\n * Start tracking long tasks.\n */\nfunction startTrackingLongTasks() {\n addPerformanceInstrumentationHandler('longtask', ({ entries }) => {\n const parent = getActiveSpan();\n if (!parent) {\n return;\n }\n\n const { op: parentOp, start_timestamp: parentStartTimestamp } = spanToJSON(parent);\n\n for (const entry of entries) {\n const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);\n const duration = msToSec(entry.duration);\n\n if (parentOp === 'navigation' && parentStartTimestamp && startTime < parentStartTimestamp) {\n // Skip adding a span if the long task started before the navigation started.\n // `startAndEndSpan` will otherwise adjust the parent's start time to the span's start\n // time, potentially skewing the duration of the actual navigation as reported via our\n // routing instrumentations\n continue;\n }\n\n startAndEndSpan(parent, startTime, startTime + duration, {\n name: 'Main UI thread blocked',\n op: 'ui.long-task',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',\n },\n });\n }\n });\n}\n\n/**\n * Start tracking long animation frames.\n */\nfunction startTrackingLongAnimationFrames() {\n // NOTE: the current web-vitals version (3.5.2) does not support long-animation-frame, so\n // we directly observe `long-animation-frame` events instead of through the web-vitals\n // `observe` helper function.\n const observer = new PerformanceObserver(list => {\n const parent = getActiveSpan();\n if (!parent) {\n return;\n }\n for (const entry of list.getEntries() ) {\n if (!entry.scripts[0]) {\n continue;\n }\n\n const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);\n\n const { start_timestamp: parentStartTimestamp, op: parentOp } = spanToJSON(parent);\n\n if (parentOp === 'navigation' && parentStartTimestamp && startTime < parentStartTimestamp) {\n // Skip adding the span if the long animation frame started before the navigation started.\n // `startAndEndSpan` will otherwise adjust the parent's start time to the span's start\n // time, potentially skewing the duration of the actual navigation as reported via our\n // routing instrumentations\n continue;\n }\n\n const duration = msToSec(entry.duration);\n\n const attributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',\n };\n\n const initialScript = entry.scripts[0];\n const { invoker, invokerType, sourceURL, sourceFunctionName, sourceCharPosition } = initialScript;\n attributes['browser.script.invoker'] = invoker;\n attributes['browser.script.invoker_type'] = invokerType;\n if (sourceURL) {\n attributes['code.filepath'] = sourceURL;\n }\n if (sourceFunctionName) {\n attributes['code.function'] = sourceFunctionName;\n }\n if (sourceCharPosition !== -1) {\n attributes['browser.script.source_char_position'] = sourceCharPosition;\n }\n\n startAndEndSpan(parent, startTime, startTime + duration, {\n name: 'Main UI thread blocked',\n op: 'ui.long-animation-frame',\n attributes,\n });\n }\n });\n\n observer.observe({ type: 'long-animation-frame', buffered: true });\n}\n\n/**\n * Start tracking interaction events.\n */\nfunction startTrackingInteractions() {\n addPerformanceInstrumentationHandler('event', ({ entries }) => {\n const parent = getActiveSpan();\n if (!parent) {\n return;\n }\n for (const entry of entries) {\n if (entry.name === 'click') {\n const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);\n const duration = msToSec(entry.duration);\n\n const spanOptions = {\n name: htmlTreeAsString(entry.target),\n op: `ui.interaction.${entry.name}`,\n startTime: startTime,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',\n },\n };\n\n const componentName = getComponentName(entry.target);\n if (componentName) {\n spanOptions.attributes['ui.component_name'] = componentName;\n }\n\n startAndEndSpan(parent, startTime, startTime + duration, spanOptions);\n }\n }\n });\n}\n\n/**\n * Starts tracking the Cumulative Layout Shift on the current page and collects the value and last entry\n * to the `_measurements` object which ultimately is applied to the pageload span's measurements.\n */\nfunction _trackCLS() {\n return addClsInstrumentationHandler(({ metric }) => {\n const entry = metric.entries[metric.entries.length - 1] ;\n if (!entry) {\n return;\n }\n _measurements['cls'] = { value: metric.value, unit: '' };\n _clsEntry = entry;\n }, true);\n}\n\n/** Starts tracking the Largest Contentful Paint on the current page. */\nfunction _trackLCP() {\n return addLcpInstrumentationHandler(({ metric }) => {\n const entry = metric.entries[metric.entries.length - 1];\n if (!entry) {\n return;\n }\n\n _measurements['lcp'] = { value: metric.value, unit: 'millisecond' };\n _lcpEntry = entry ;\n }, true);\n}\n\n/** Starts tracking the First Input Delay on the current page. */\nfunction _trackFID() {\n return addFidInstrumentationHandler(({ metric }) => {\n const entry = metric.entries[metric.entries.length - 1];\n if (!entry) {\n return;\n }\n\n const timeOrigin = msToSec(browserPerformanceTimeOrigin );\n const startTime = msToSec(entry.startTime);\n _measurements['fid'] = { value: metric.value, unit: 'millisecond' };\n _measurements['mark.fid'] = { value: timeOrigin + startTime, unit: 'second' };\n });\n}\n\nfunction _trackTtfb() {\n return addTtfbInstrumentationHandler(({ metric }) => {\n const entry = metric.entries[metric.entries.length - 1];\n if (!entry) {\n return;\n }\n\n _measurements['ttfb'] = { value: metric.value, unit: 'millisecond' };\n });\n}\n\n/** Add performance related spans to a transaction */\nfunction addPerformanceEntries(span, options) {\n const performance = getBrowserPerformanceAPI();\n if (!performance || !performance.getEntries || !browserPerformanceTimeOrigin) {\n // Gatekeeper if performance API not available\n return;\n }\n\n const timeOrigin = msToSec(browserPerformanceTimeOrigin);\n\n const performanceEntries = performance.getEntries();\n\n const { op, start_timestamp: transactionStartTime } = spanToJSON(span);\n\n performanceEntries.slice(_performanceCursor).forEach(entry => {\n const startTime = msToSec(entry.startTime);\n const duration = msToSec(\n // Inexplicably, Chrome sometimes emits a negative duration. We need to work around this.\n // There is a SO post attempting to explain this, but it leaves one with open questions: https://stackoverflow.com/questions/23191918/peformance-getentries-and-negative-duration-display\n // The way we clamp the value is probably not accurate, since we have observed this happen for things that may take a while to load, like for example the replay worker.\n // TODO: Investigate why this happens and how to properly mitigate. For now, this is a workaround to prevent transactions being dropped due to negative duration spans.\n Math.max(0, entry.duration),\n );\n\n if (op === 'navigation' && transactionStartTime && timeOrigin + startTime < transactionStartTime) {\n return;\n }\n\n switch (entry.entryType) {\n case 'navigation': {\n _addNavigationSpans(span, entry , timeOrigin);\n break;\n }\n case 'mark':\n case 'paint':\n case 'measure': {\n _addMeasureSpans(span, entry, startTime, duration, timeOrigin);\n\n // capture web vitals\n const firstHidden = getVisibilityWatcher();\n // Only report if the page wasn't hidden prior to the web vital.\n const shouldRecord = entry.startTime < firstHidden.firstHiddenTime;\n\n if (entry.name === 'first-paint' && shouldRecord) {\n _measurements['fp'] = { value: entry.startTime, unit: 'millisecond' };\n }\n if (entry.name === 'first-contentful-paint' && shouldRecord) {\n _measurements['fcp'] = { value: entry.startTime, unit: 'millisecond' };\n }\n break;\n }\n case 'resource': {\n _addResourceSpans(span, entry , entry.name, startTime, duration, timeOrigin);\n break;\n }\n // Ignore other entry types.\n }\n });\n\n _performanceCursor = Math.max(performanceEntries.length - 1, 0);\n\n _trackNavigator(span);\n\n // Measurements are only available for pageload transactions\n if (op === 'pageload') {\n _addTtfbRequestTimeToMeasurements(_measurements);\n\n const fidMark = _measurements['mark.fid'];\n if (fidMark && _measurements['fid']) {\n // create span for FID\n startAndEndSpan(span, fidMark.value, fidMark.value + msToSec(_measurements['fid'].value), {\n name: 'first input delay',\n op: 'ui.action',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',\n },\n });\n\n // Delete mark.fid as we don't want it to be part of final payload\n delete _measurements['mark.fid'];\n }\n\n // If FCP is not recorded we should not record the cls value\n // according to the new definition of CLS.\n // TODO: Check if the first condition is still necessary: `onCLS` already only fires once `onFCP` was called.\n if (!('fcp' in _measurements) || !options.recordClsOnPageloadSpan) {\n delete _measurements.cls;\n }\n\n Object.entries(_measurements).forEach(([measurementName, measurement]) => {\n setMeasurement(measurementName, measurement.value, measurement.unit);\n });\n\n // Set timeOrigin which denotes the timestamp which to base the LCP/FCP/FP/TTFB measurements on\n span.setAttribute('performance.timeOrigin', timeOrigin);\n\n // In prerendering scenarios, where a page might be prefetched and pre-rendered before the user clicks the link,\n // the navigation starts earlier than when the user clicks it. Web Vitals should always be based on the\n // user-perceived time, so they are not reported from the actual start of the navigation, but rather from the\n // time where the user actively started the navigation, for example by clicking a link.\n // This is user action is called \"activation\" and the time between navigation and activation is stored in\n // the `activationStart` attribute of the \"navigation\" PerformanceEntry.\n span.setAttribute('performance.activationStart', getActivationStart());\n\n _setWebVitalAttributes(span);\n }\n\n _lcpEntry = undefined;\n _clsEntry = undefined;\n _measurements = {};\n}\n\n/**\n * Create measure related spans.\n * Exported only for tests.\n */\nfunction _addMeasureSpans(\n span,\n entry,\n startTime,\n duration,\n timeOrigin,\n) {\n const navEntry = getNavigationEntry(false);\n const requestTime = msToSec(navEntry ? navEntry.requestStart : 0);\n // Because performance.measure accepts arbitrary timestamps it can produce\n // spans that happen before the browser even makes a request for the page.\n //\n // An example of this is the automatically generated Next.js-before-hydration\n // spans created by the Next.js framework.\n //\n // To prevent this we will pin the start timestamp to the request start time\n // This does make duration inaccurate, so if this does happen, we will add\n // an attribute to the span\n const measureStartTimestamp = timeOrigin + Math.max(startTime, requestTime);\n const startTimeStamp = timeOrigin + startTime;\n const measureEndTimestamp = startTimeStamp + duration;\n\n const attributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',\n };\n\n if (measureStartTimestamp !== startTimeStamp) {\n attributes['sentry.browser.measure_happened_before_request'] = true;\n attributes['sentry.browser.measure_start_time'] = measureStartTimestamp;\n }\n\n startAndEndSpan(span, measureStartTimestamp, measureEndTimestamp, {\n name: entry.name ,\n op: entry.entryType ,\n attributes,\n });\n\n return measureStartTimestamp;\n}\n\n/** Instrument navigation entries */\nfunction _addNavigationSpans(span, entry, timeOrigin) {\n (['unloadEvent', 'redirect', 'domContentLoadedEvent', 'loadEvent', 'connect'] ).forEach(event => {\n _addPerformanceNavigationTiming(span, entry, event, timeOrigin);\n });\n _addPerformanceNavigationTiming(span, entry, 'secureConnection', timeOrigin, 'TLS/SSL');\n _addPerformanceNavigationTiming(span, entry, 'fetch', timeOrigin, 'cache');\n _addPerformanceNavigationTiming(span, entry, 'domainLookup', timeOrigin, 'DNS');\n\n _addRequest(span, entry, timeOrigin);\n}\n\n/** Create performance navigation related spans */\nfunction _addPerformanceNavigationTiming(\n span,\n entry,\n event,\n timeOrigin,\n name = event,\n) {\n const eventEnd = _getEndPropertyNameForNavigationTiming(event) ;\n const end = entry[eventEnd];\n const start = entry[`${event}Start`];\n if (!start || !end) {\n return;\n }\n startAndEndSpan(span, timeOrigin + msToSec(start), timeOrigin + msToSec(end), {\n op: `browser.${name}`,\n name: entry.name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',\n },\n });\n}\n\nfunction _getEndPropertyNameForNavigationTiming(event) {\n if (event === 'secureConnection') {\n return 'connectEnd';\n }\n if (event === 'fetch') {\n return 'domainLookupStart';\n }\n return `${event}End`;\n}\n\n/** Create request and response related spans */\nfunction _addRequest(span, entry, timeOrigin) {\n const requestStartTimestamp = timeOrigin + msToSec(entry.requestStart );\n const responseEndTimestamp = timeOrigin + msToSec(entry.responseEnd );\n const responseStartTimestamp = timeOrigin + msToSec(entry.responseStart );\n if (entry.responseEnd) {\n // It is possible that we are collecting these metrics when the page hasn't finished loading yet, for example when the HTML slowly streams in.\n // In this case, ie. when the document request hasn't finished yet, `entry.responseEnd` will be 0.\n // In order not to produce faulty spans, where the end timestamp is before the start timestamp, we will only collect\n // these spans when the responseEnd value is available. The backend (Relay) would drop the entire span if it contained faulty spans.\n startAndEndSpan(span, requestStartTimestamp, responseEndTimestamp, {\n op: 'browser.request',\n name: entry.name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',\n },\n });\n\n startAndEndSpan(span, responseStartTimestamp, responseEndTimestamp, {\n op: 'browser.response',\n name: entry.name,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',\n },\n });\n }\n}\n\n/**\n * Create resource-related spans.\n * Exported only for tests.\n */\nfunction _addResourceSpans(\n span,\n entry,\n resourceUrl,\n startTime,\n duration,\n timeOrigin,\n) {\n // we already instrument based on fetch and xhr, so we don't need to\n // duplicate spans here.\n if (entry.initiatorType === 'xmlhttprequest' || entry.initiatorType === 'fetch') {\n return;\n }\n\n const parsedUrl = parseUrl(resourceUrl);\n\n const attributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',\n };\n setResourceEntrySizeData(attributes, entry, 'transferSize', 'http.response_transfer_size');\n setResourceEntrySizeData(attributes, entry, 'encodedBodySize', 'http.response_content_length');\n setResourceEntrySizeData(attributes, entry, 'decodedBodySize', 'http.decoded_response_content_length');\n\n // `deliveryType` is experimental and does not exist everywhere\n const deliveryType = (entry ).deliveryType;\n if (deliveryType != null) {\n attributes['http.response_delivery_type'] = deliveryType;\n }\n\n // Types do not reflect this property yet\n const renderBlockingStatus = (entry )\n .renderBlockingStatus;\n if (renderBlockingStatus) {\n attributes['resource.render_blocking_status'] = renderBlockingStatus;\n }\n\n if (parsedUrl.protocol) {\n attributes['url.scheme'] = parsedUrl.protocol.split(':').pop(); // the protocol returned by parseUrl includes a :, but OTEL spec does not, so we remove it.\n }\n\n if (parsedUrl.host) {\n attributes['server.address'] = parsedUrl.host;\n }\n\n attributes['url.same_origin'] = resourceUrl.includes(WINDOW.location.origin);\n\n const startTimestamp = timeOrigin + startTime;\n const endTimestamp = startTimestamp + duration;\n\n startAndEndSpan(span, startTimestamp, endTimestamp, {\n name: resourceUrl.replace(WINDOW.location.origin, ''),\n op: entry.initiatorType ? `resource.${entry.initiatorType}` : 'resource.other',\n attributes,\n });\n}\n\n/**\n * Capture the information of the user agent.\n */\nfunction _trackNavigator(span) {\n const navigator = WINDOW.navigator ;\n if (!navigator) {\n return;\n }\n\n // track network connectivity\n const connection = navigator.connection;\n if (connection) {\n if (connection.effectiveType) {\n span.setAttribute('effectiveConnectionType', connection.effectiveType);\n }\n\n if (connection.type) {\n span.setAttribute('connectionType', connection.type);\n }\n\n if (isMeasurementValue(connection.rtt)) {\n _measurements['connection.rtt'] = { value: connection.rtt, unit: 'millisecond' };\n }\n }\n\n if (isMeasurementValue(navigator.deviceMemory)) {\n span.setAttribute('deviceMemory', `${navigator.deviceMemory} GB`);\n }\n\n if (isMeasurementValue(navigator.hardwareConcurrency)) {\n span.setAttribute('hardwareConcurrency', String(navigator.hardwareConcurrency));\n }\n}\n\n/** Add LCP / CLS data to span to allow debugging */\nfunction _setWebVitalAttributes(span) {\n if (_lcpEntry) {\n // Capture Properties of the LCP element that contributes to the LCP.\n\n if (_lcpEntry.element) {\n span.setAttribute('lcp.element', htmlTreeAsString(_lcpEntry.element));\n }\n\n if (_lcpEntry.id) {\n span.setAttribute('lcp.id', _lcpEntry.id);\n }\n\n if (_lcpEntry.url) {\n // Trim URL to the first 200 characters.\n span.setAttribute('lcp.url', _lcpEntry.url.trim().slice(0, 200));\n }\n\n if (_lcpEntry.loadTime != null) {\n // loadTime is the time of LCP that's related to receiving the LCP element response..\n span.setAttribute('lcp.loadTime', _lcpEntry.loadTime);\n }\n\n if (_lcpEntry.renderTime != null) {\n // renderTime is loadTime + rendering time\n // it's 0 if the LCP element is loaded from a 3rd party origin that doesn't send the\n // `Timing-Allow-Origin` header.\n span.setAttribute('lcp.renderTime', _lcpEntry.renderTime);\n }\n\n span.setAttribute('lcp.size', _lcpEntry.size);\n }\n\n // See: https://developer.mozilla.org/en-US/docs/Web/API/LayoutShift\n if (_clsEntry && _clsEntry.sources) {\n _clsEntry.sources.forEach((source, index) =>\n span.setAttribute(`cls.source.${index + 1}`, htmlTreeAsString(source.node)),\n );\n }\n}\n\nfunction setResourceEntrySizeData(\n attributes,\n entry,\n key,\n dataKey,\n) {\n const entryVal = entry[key];\n if (entryVal != null && entryVal < MAX_INT_AS_BYTES) {\n attributes[dataKey] = entryVal;\n }\n}\n\n/**\n * Add ttfb request time information to measurements.\n *\n * ttfb information is added via vendored web vitals library.\n */\nfunction _addTtfbRequestTimeToMeasurements(_measurements) {\n const navEntry = getNavigationEntry(false);\n if (!navEntry) {\n return;\n }\n\n const { responseStart, requestStart } = navEntry;\n\n if (requestStart <= responseStart) {\n _measurements['ttfb.requestTime'] = {\n value: responseStart - requestStart,\n unit: 'millisecond',\n };\n }\n}\n\nexport { _addMeasureSpans, _addResourceSpans, addPerformanceEntries, startTrackingInteractions, startTrackingLongAnimationFrames, startTrackingLongTasks, startTrackingWebVitals };\n","import { getClient, getActiveSpan, getRootSpan, spanToJSON, logger, browserPerformanceTimeOrigin, getCurrentScope, htmlTreeAsString, dropUndefinedKeys, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { addClsInstrumentationHandler } from './instrument.js';\nimport { msToSec, startStandaloneWebVitalSpan } from './utils.js';\nimport { onHidden } from './web-vitals/lib/onHidden.js';\n\n/**\n * Starts tracking the Cumulative Layout Shift on the current page and collects the value once\n *\n * - the page visibility is hidden\n * - a navigation span is started (to stop CLS measurement for SPA soft navigations)\n *\n * Once either of these events triggers, the CLS value is sent as a standalone span and we stop\n * measuring CLS.\n */\nfunction trackClsAsStandaloneSpan() {\n let standaloneCLsValue = 0;\n let standaloneClsEntry;\n let pageloadSpanId;\n\n if (!supportsLayoutShift()) {\n return;\n }\n\n let sentSpan = false;\n function _collectClsOnce() {\n if (sentSpan) {\n return;\n }\n sentSpan = true;\n if (pageloadSpanId) {\n sendStandaloneClsSpan(standaloneCLsValue, standaloneClsEntry, pageloadSpanId);\n }\n cleanupClsHandler();\n }\n\n const cleanupClsHandler = addClsInstrumentationHandler(({ metric }) => {\n const entry = metric.entries[metric.entries.length - 1] ;\n if (!entry) {\n return;\n }\n standaloneCLsValue = metric.value;\n standaloneClsEntry = entry;\n }, true);\n\n // use pagehide event from web-vitals\n onHidden(() => {\n _collectClsOnce();\n });\n\n // Since the call chain of this function is synchronous and evaluates before the SDK client is created,\n // we need to wait with subscribing to a client hook until the client is created. Therefore, we defer\n // to the next tick after the SDK setup.\n setTimeout(() => {\n const client = getClient();\n\n if (!client) {\n return;\n }\n\n const unsubscribeStartNavigation = client.on('startNavigationSpan', () => {\n _collectClsOnce();\n unsubscribeStartNavigation && unsubscribeStartNavigation();\n });\n\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n const spanJSON = rootSpan && spanToJSON(rootSpan);\n if (spanJSON && spanJSON.op === 'pageload') {\n pageloadSpanId = rootSpan.spanContext().spanId;\n }\n }, 0);\n}\n\nfunction sendStandaloneClsSpan(clsValue, entry, pageloadSpanId) {\n DEBUG_BUILD && logger.log(`Sending CLS span (${clsValue})`);\n\n const startTime = msToSec((browserPerformanceTimeOrigin || 0) + ((entry && entry.startTime) || 0));\n const routeName = getCurrentScope().getScopeData().transactionName;\n\n const name = entry ? htmlTreeAsString(entry.sources[0] && entry.sources[0].node) : 'Layout shift';\n\n const attributes = dropUndefinedKeys({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser.cls',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.webvital.cls',\n [SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: (entry && entry.duration) || 0,\n // attach the pageload span id to the CLS span so that we can link them in the UI\n 'sentry.pageload.span_id': pageloadSpanId,\n });\n\n const span = startStandaloneWebVitalSpan({\n name,\n transaction: routeName,\n attributes,\n startTime,\n });\n\n if (span) {\n span.addEvent('cls', {\n [SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT]: '',\n [SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE]: clsValue,\n });\n\n // LayoutShift performance entries always have a duration of 0, so we don't need to add `entry.duration` here\n // see: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/duration\n span.end(startTime);\n }\n}\n\nfunction supportsLayoutShift() {\n try {\n return PerformanceObserver.supportedEntryTypes.includes('layout-shift');\n } catch (e) {\n return false;\n }\n}\n\nexport { trackClsAsStandaloneSpan };\n","import { browserPerformanceTimeOrigin, getActiveSpan, getRootSpan, spanToJSON, getCurrentScope, htmlTreeAsString, dropUndefinedKeys, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE } from '@sentry/core';\nimport { addInpInstrumentationHandler, addPerformanceInstrumentationHandler, isPerformanceEventTiming } from './instrument.js';\nimport { getBrowserPerformanceAPI, msToSec, startStandaloneWebVitalSpan } from './utils.js';\n\nconst LAST_INTERACTIONS = [];\nconst INTERACTIONS_SPAN_MAP = new Map();\n\n/**\n * Start tracking INP webvital events.\n */\nfunction startTrackingINP() {\n const performance = getBrowserPerformanceAPI();\n if (performance && browserPerformanceTimeOrigin) {\n const inpCallback = _trackINP();\n\n return () => {\n inpCallback();\n };\n }\n\n return () => undefined;\n}\n\nconst INP_ENTRY_MAP = {\n click: 'click',\n pointerdown: 'click',\n pointerup: 'click',\n mousedown: 'click',\n mouseup: 'click',\n touchstart: 'click',\n touchend: 'click',\n mouseover: 'hover',\n mouseout: 'hover',\n mouseenter: 'hover',\n mouseleave: 'hover',\n pointerover: 'hover',\n pointerout: 'hover',\n pointerenter: 'hover',\n pointerleave: 'hover',\n dragstart: 'drag',\n dragend: 'drag',\n drag: 'drag',\n dragenter: 'drag',\n dragleave: 'drag',\n dragover: 'drag',\n drop: 'drag',\n keydown: 'press',\n keyup: 'press',\n keypress: 'press',\n input: 'press',\n};\n\n/** Starts tracking the Interaction to Next Paint on the current page. */\nfunction _trackINP() {\n return addInpInstrumentationHandler(({ metric }) => {\n if (metric.value == undefined) {\n return;\n }\n\n const entry = metric.entries.find(entry => entry.duration === metric.value && INP_ENTRY_MAP[entry.name]);\n\n if (!entry) {\n return;\n }\n\n const { interactionId } = entry;\n const interactionType = INP_ENTRY_MAP[entry.name];\n\n /** Build the INP span, create an envelope from the span, and then send the envelope */\n const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);\n const duration = msToSec(metric.value);\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan ? getRootSpan(activeSpan) : undefined;\n\n // We first try to lookup the span from our INTERACTIONS_SPAN_MAP,\n // where we cache the route per interactionId\n const cachedSpan = interactionId != null ? INTERACTIONS_SPAN_MAP.get(interactionId) : undefined;\n\n const spanToUse = cachedSpan || rootSpan;\n\n // Else, we try to use the active span.\n // Finally, we fall back to look at the transactionName on the scope\n const routeName = spanToUse ? spanToJSON(spanToUse).description : getCurrentScope().getScopeData().transactionName;\n\n const name = htmlTreeAsString(entry.target);\n const attributes = dropUndefinedKeys({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser.inp',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `ui.interaction.${interactionType}`,\n [SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: entry.duration,\n });\n\n const span = startStandaloneWebVitalSpan({\n name,\n transaction: routeName,\n attributes,\n startTime,\n });\n\n if (span) {\n span.addEvent('inp', {\n [SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT]: 'millisecond',\n [SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE]: metric.value,\n });\n\n span.end(startTime + duration);\n }\n });\n}\n\n/**\n * Register a listener to cache route information for INP interactions.\n * TODO(v9): `latestRoute` no longer needs to be passed in and will be removed in v9.\n */\nfunction registerInpInteractionListener(_latestRoute) {\n const handleEntries = ({ entries }) => {\n const activeSpan = getActiveSpan();\n const activeRootSpan = activeSpan && getRootSpan(activeSpan);\n\n entries.forEach(entry => {\n if (!isPerformanceEventTiming(entry) || !activeRootSpan) {\n return;\n }\n\n const interactionId = entry.interactionId;\n if (interactionId == null) {\n return;\n }\n\n // If the interaction was already recorded before, nothing more to do\n if (INTERACTIONS_SPAN_MAP.has(interactionId)) {\n return;\n }\n\n // We keep max. 10 interactions in the list, then remove the oldest one & clean up\n if (LAST_INTERACTIONS.length > 10) {\n const last = LAST_INTERACTIONS.shift() ;\n INTERACTIONS_SPAN_MAP.delete(last);\n }\n\n // We add the interaction to the list of recorded interactions\n // and store the span for this interaction\n LAST_INTERACTIONS.push(interactionId);\n INTERACTIONS_SPAN_MAP.set(interactionId, activeRootSpan);\n });\n };\n\n addPerformanceInstrumentationHandler('event', handleEntries);\n addPerformanceInstrumentationHandler('first-input', handleEntries);\n}\n\nexport { registerInpInteractionListener, startTrackingINP };\n","import { getClient, getCurrentScope } from '../currentScopes.js';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON } from '../semanticAttributes.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { timestampInSeconds } from '../utils-hoist/time.js';\nimport { hasTracingEnabled } from '../utils/hasTracingEnabled.js';\nimport { _setSpanForScope } from '../utils/spanOnScope.js';\nimport { getActiveSpan, spanTimeInputToSeconds, getSpanDescendants, spanToJSON, removeChildSpanFromSpan } from '../utils/spanUtils.js';\nimport { SentryNonRecordingSpan } from './sentryNonRecordingSpan.js';\nimport { SPAN_STATUS_ERROR } from './spanstatus.js';\nimport { startInactiveSpan } from './trace.js';\n\nconst TRACING_DEFAULTS = {\n idleTimeout: 1000,\n finalTimeout: 30000,\n childSpanTimeout: 15000,\n};\n\nconst FINISH_REASON_HEARTBEAT_FAILED = 'heartbeatFailed';\nconst FINISH_REASON_IDLE_TIMEOUT = 'idleTimeout';\nconst FINISH_REASON_FINAL_TIMEOUT = 'finalTimeout';\nconst FINISH_REASON_EXTERNAL_FINISH = 'externalFinish';\n\n/**\n * An idle span is a span that automatically finishes. It does this by tracking child spans as activities.\n * An idle span is always the active span.\n */\nfunction startIdleSpan(startSpanOptions, options = {}) {\n // Activities store a list of active spans\n const activities = new Map();\n\n // We should not use heartbeat if we finished a span\n let _finished = false;\n\n // Timer that tracks idleTimeout\n let _idleTimeoutID;\n\n // The reason why the span was finished\n let _finishReason = FINISH_REASON_EXTERNAL_FINISH;\n\n let _autoFinishAllowed = !options.disableAutoFinish;\n\n const _cleanupHooks = [];\n\n const {\n idleTimeout = TRACING_DEFAULTS.idleTimeout,\n finalTimeout = TRACING_DEFAULTS.finalTimeout,\n childSpanTimeout = TRACING_DEFAULTS.childSpanTimeout,\n beforeSpanEnd,\n } = options;\n\n const client = getClient();\n\n if (!client || !hasTracingEnabled()) {\n return new SentryNonRecordingSpan();\n }\n\n const scope = getCurrentScope();\n const previousActiveSpan = getActiveSpan();\n const span = _startIdleSpan(startSpanOptions);\n\n // We patch span.end to ensure we can run some things before the span is ended\n // eslint-disable-next-line @typescript-eslint/unbound-method\n span.end = new Proxy(span.end, {\n apply(target, thisArg, args) {\n if (beforeSpanEnd) {\n beforeSpanEnd(span);\n }\n\n // Just ensuring that this keeps working, even if we ever have more arguments here\n const [definedEndTimestamp, ...rest] = args;\n const timestamp = definedEndTimestamp || timestampInSeconds();\n const spanEndTimestamp = spanTimeInputToSeconds(timestamp);\n\n // Ensure we end with the last span timestamp, if possible\n const spans = getSpanDescendants(span).filter(child => child !== span);\n\n // If we have no spans, we just end, nothing else to do here\n if (!spans.length) {\n onIdleSpanEnded(spanEndTimestamp);\n return Reflect.apply(target, thisArg, [spanEndTimestamp, ...rest]);\n }\n\n const childEndTimestamps = spans\n .map(span => spanToJSON(span).timestamp)\n .filter(timestamp => !!timestamp) ;\n const latestSpanEndTimestamp = childEndTimestamps.length ? Math.max(...childEndTimestamps) : undefined;\n\n // In reality this should always exist here, but type-wise it may be undefined...\n const spanStartTimestamp = spanToJSON(span).start_timestamp;\n\n // The final endTimestamp should:\n // * Never be before the span start timestamp\n // * Be the latestSpanEndTimestamp, if there is one, and it is smaller than the passed span end timestamp\n // * Otherwise be the passed end timestamp\n // Final timestamp can never be after finalTimeout\n const endTimestamp = Math.min(\n spanStartTimestamp ? spanStartTimestamp + finalTimeout / 1000 : Infinity,\n Math.max(spanStartTimestamp || -Infinity, Math.min(spanEndTimestamp, latestSpanEndTimestamp || Infinity)),\n );\n\n onIdleSpanEnded(endTimestamp);\n return Reflect.apply(target, thisArg, [endTimestamp, ...rest]);\n },\n });\n\n /**\n * Cancels the existing idle timeout, if there is one.\n */\n function _cancelIdleTimeout() {\n if (_idleTimeoutID) {\n clearTimeout(_idleTimeoutID);\n _idleTimeoutID = undefined;\n }\n }\n\n /**\n * Restarts idle timeout, if there is no running idle timeout it will start one.\n */\n function _restartIdleTimeout(endTimestamp) {\n _cancelIdleTimeout();\n _idleTimeoutID = setTimeout(() => {\n if (!_finished && activities.size === 0 && _autoFinishAllowed) {\n _finishReason = FINISH_REASON_IDLE_TIMEOUT;\n span.end(endTimestamp);\n }\n }, idleTimeout);\n }\n\n /**\n * Restarts child span timeout, if there is none running it will start one.\n */\n function _restartChildSpanTimeout(endTimestamp) {\n _idleTimeoutID = setTimeout(() => {\n if (!_finished && _autoFinishAllowed) {\n _finishReason = FINISH_REASON_HEARTBEAT_FAILED;\n span.end(endTimestamp);\n }\n }, childSpanTimeout);\n }\n\n /**\n * Start tracking a specific activity.\n * @param spanId The span id that represents the activity\n */\n function _pushActivity(spanId) {\n _cancelIdleTimeout();\n activities.set(spanId, true);\n\n const endTimestamp = timestampInSeconds();\n // We need to add the timeout here to have the real endtimestamp of the idle span\n // Remember timestampInSeconds is in seconds, timeout is in ms\n _restartChildSpanTimeout(endTimestamp + childSpanTimeout / 1000);\n }\n\n /**\n * Remove an activity from usage\n * @param spanId The span id that represents the activity\n */\n function _popActivity(spanId) {\n if (activities.has(spanId)) {\n activities.delete(spanId);\n }\n\n if (activities.size === 0) {\n const endTimestamp = timestampInSeconds();\n // We need to add the timeout here to have the real endtimestamp of the idle span\n // Remember timestampInSeconds is in seconds, timeout is in ms\n _restartIdleTimeout(endTimestamp + idleTimeout / 1000);\n }\n }\n\n function onIdleSpanEnded(endTimestamp) {\n _finished = true;\n activities.clear();\n\n _cleanupHooks.forEach(cleanup => cleanup());\n\n _setSpanForScope(scope, previousActiveSpan);\n\n const spanJSON = spanToJSON(span);\n\n const { start_timestamp: startTimestamp } = spanJSON;\n // This should never happen, but to make TS happy...\n if (!startTimestamp) {\n return;\n }\n\n const attributes = spanJSON.data || {};\n if (!attributes[SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON]) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, _finishReason);\n }\n\n logger.log(`[Tracing] Idle span \"${spanJSON.op}\" finished`);\n\n const childSpans = getSpanDescendants(span).filter(child => child !== span);\n\n let discardedSpans = 0;\n childSpans.forEach(childSpan => {\n // We cancel all pending spans with status \"cancelled\" to indicate the idle span was finished early\n if (childSpan.isRecording()) {\n childSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });\n childSpan.end(endTimestamp);\n DEBUG_BUILD &&\n logger.log('[Tracing] Cancelling span since span ended early', JSON.stringify(childSpan, undefined, 2));\n }\n\n const childSpanJSON = spanToJSON(childSpan);\n const { timestamp: childEndTimestamp = 0, start_timestamp: childStartTimestamp = 0 } = childSpanJSON;\n\n const spanStartedBeforeIdleSpanEnd = childStartTimestamp <= endTimestamp;\n\n // Add a delta with idle timeout so that we prevent false positives\n const timeoutWithMarginOfError = (finalTimeout + idleTimeout) / 1000;\n const spanEndedBeforeFinalTimeout = childEndTimestamp - childStartTimestamp <= timeoutWithMarginOfError;\n\n if (DEBUG_BUILD) {\n const stringifiedSpan = JSON.stringify(childSpan, undefined, 2);\n if (!spanStartedBeforeIdleSpanEnd) {\n logger.log('[Tracing] Discarding span since it happened after idle span was finished', stringifiedSpan);\n } else if (!spanEndedBeforeFinalTimeout) {\n logger.log('[Tracing] Discarding span since it finished after idle span final timeout', stringifiedSpan);\n }\n }\n\n if (!spanEndedBeforeFinalTimeout || !spanStartedBeforeIdleSpanEnd) {\n removeChildSpanFromSpan(span, childSpan);\n discardedSpans++;\n }\n });\n\n if (discardedSpans > 0) {\n span.setAttribute('sentry.idle_span_discarded_spans', discardedSpans);\n }\n }\n\n _cleanupHooks.push(\n client.on('spanStart', startedSpan => {\n // If we already finished the idle span,\n // or if this is the idle span itself being started,\n // or if the started span has already been closed,\n // we don't care about it for activity\n if (_finished || startedSpan === span || !!spanToJSON(startedSpan).timestamp) {\n return;\n }\n\n const allSpans = getSpanDescendants(span);\n\n // If the span that was just started is a child of the idle span, we should track it\n if (allSpans.includes(startedSpan)) {\n _pushActivity(startedSpan.spanContext().spanId);\n }\n }),\n );\n\n _cleanupHooks.push(\n client.on('spanEnd', endedSpan => {\n if (_finished) {\n return;\n }\n\n _popActivity(endedSpan.spanContext().spanId);\n }),\n );\n\n _cleanupHooks.push(\n client.on('idleSpanEnableAutoFinish', spanToAllowAutoFinish => {\n if (spanToAllowAutoFinish === span) {\n _autoFinishAllowed = true;\n _restartIdleTimeout();\n\n if (activities.size) {\n _restartChildSpanTimeout();\n }\n }\n }),\n );\n\n // We only start the initial idle timeout if we are not delaying the auto finish\n if (!options.disableAutoFinish) {\n _restartIdleTimeout();\n }\n\n setTimeout(() => {\n if (!_finished) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' });\n _finishReason = FINISH_REASON_FINAL_TIMEOUT;\n span.end();\n }\n }, finalTimeout);\n\n return span;\n}\n\nfunction _startIdleSpan(options) {\n const span = startInactiveSpan(options);\n\n _setSpanForScope(getCurrentScope(), span);\n\n DEBUG_BUILD && logger.log('[Tracing] Started span is an idle span');\n\n return span;\n}\n\nexport { TRACING_DEFAULTS, startIdleSpan };\n","import { DEBUG_BUILD } from '../debug-build.js';\nimport { addGlobalErrorInstrumentationHandler } from '../utils-hoist/instrument/globalError.js';\nimport { addGlobalUnhandledRejectionInstrumentationHandler } from '../utils-hoist/instrument/globalUnhandledRejection.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport { getActiveSpan, getRootSpan } from '../utils/spanUtils.js';\nimport { SPAN_STATUS_ERROR } from './spanstatus.js';\n\nlet errorsInstrumented = false;\n\n/**\n * Ensure that global errors automatically set the active span status.\n */\nfunction registerSpanErrorInstrumentation() {\n if (errorsInstrumented) {\n return;\n }\n\n errorsInstrumented = true;\n addGlobalErrorInstrumentationHandler(errorCallback);\n addGlobalUnhandledRejectionInstrumentationHandler(errorCallback);\n}\n\n/**\n * If an error or unhandled promise occurs, we mark the active root span as failed\n */\nfunction errorCallback() {\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n if (rootSpan) {\n const message = 'internal_error';\n DEBUG_BUILD && logger.log(`[Tracing] Root span: ${message} -> Global error occurred`);\n rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message });\n }\n}\n\n// The function name will be lost when bundling but we need to be able to identify this listener later to maintain the\n// node.js default exit behaviour\nerrorCallback.tag = 'sentry_tracingErrorCallback';\n\nexport { registerSpanErrorInstrumentation };\n","import { getAsyncContextStrategy } from '../asyncContext/index.js';\nimport { getMainCarrier } from '../carrier.js';\nimport { getClient, getCurrentScope } from '../currentScopes.js';\nimport { isEnabled } from '../exports.js';\nimport '../tracing/errors.js';\nimport '../utils-hoist/version.js';\nimport '../utils-hoist/debug-build.js';\nimport { logger } from '../utils-hoist/logger.js';\nimport '../debug-build.js';\nimport '../utils-hoist/time.js';\nimport { getActiveSpan, spanToTraceHeader } from './spanUtils.js';\nimport { TRACEPARENT_REGEXP, generateSentryTraceHeader } from '../utils-hoist/tracing.js';\nimport { getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromScope } from '../tracing/dynamicSamplingContext.js';\nimport { dynamicSamplingContextToSentryBaggageHeader } from '../utils-hoist/baggage.js';\n\n/**\n * Extracts trace propagation data from the current span or from the client's scope (via transaction or propagation\n * context) and serializes it to `sentry-trace` and `baggage` values to strings. These values can be used to propagate\n * a trace via our tracing Http headers or Html `` tags.\n *\n * This function also applies some validation to the generated sentry-trace and baggage values to ensure that\n * only valid strings are returned.\n *\n * @returns an object with the tracing data values. The object keys are the name of the tracing key to be used as header\n * or meta tag name.\n */\nfunction getTraceData(options = {}) {\n const client = getClient();\n if (!isEnabled() || !client) {\n return {};\n }\n\n const carrier = getMainCarrier();\n const acs = getAsyncContextStrategy(carrier);\n if (acs.getTraceData) {\n return acs.getTraceData(options);\n }\n\n const scope = getCurrentScope();\n const span = options.span || getActiveSpan();\n const sentryTrace = span ? spanToTraceHeader(span) : scopeToTraceHeader(scope);\n const dsc = span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromScope(client, scope);\n const baggage = dynamicSamplingContextToSentryBaggageHeader(dsc);\n\n const isValidSentryTraceHeader = TRACEPARENT_REGEXP.test(sentryTrace);\n if (!isValidSentryTraceHeader) {\n logger.warn('Invalid sentry-trace data. Cannot generate trace data');\n return {};\n }\n\n return {\n 'sentry-trace': sentryTrace,\n baggage,\n };\n}\n\n/**\n * Get a sentry-trace header value for the given scope.\n */\nfunction scopeToTraceHeader(scope) {\n // TODO(v9): Use generateSpanId() instead of spanId\n // eslint-disable-next-line deprecation/deprecation\n const { traceId, sampled, spanId } = scope.getPropagationContext();\n return generateSentryTraceHeader(traceId, spanId, sampled);\n}\n\nexport { getTraceData };\n","import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP } from './semanticAttributes.js';\nimport './tracing/errors.js';\nimport { isInstanceOf } from './utils-hoist/is.js';\nimport './utils-hoist/version.js';\nimport './utils-hoist/debug-build.js';\nimport './utils-hoist/logger.js';\nimport './utils-hoist/time.js';\nimport './utils-hoist/syncpromise.js';\nimport { parseUrl } from './utils-hoist/url.js';\nimport { SENTRY_BAGGAGE_KEY_PREFIX } from './utils-hoist/baggage.js';\nimport './debug-build.js';\nimport { hasTracingEnabled } from './utils/hasTracingEnabled.js';\nimport { getActiveSpan } from './utils/spanUtils.js';\nimport { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan.js';\nimport { setHttpStatus, SPAN_STATUS_ERROR } from './tracing/spanstatus.js';\nimport { startInactiveSpan } from './tracing/trace.js';\nimport { getTraceData } from './utils/traceData.js';\n\n/**\n * Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.\n *\n * @returns Span if a span was created, otherwise void.\n */\nfunction instrumentFetchRequest(\n handlerData,\n shouldCreateSpan,\n shouldAttachHeaders,\n spans,\n spanOrigin = 'auto.http.browser',\n) {\n if (!handlerData.fetchData) {\n return undefined;\n }\n\n const shouldCreateSpanResult = hasTracingEnabled() && shouldCreateSpan(handlerData.fetchData.url);\n\n if (handlerData.endTimestamp && shouldCreateSpanResult) {\n const spanId = handlerData.fetchData.__span;\n if (!spanId) return;\n\n const span = spans[spanId];\n if (span) {\n endSpan(span, handlerData);\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n return undefined;\n }\n\n const { method, url } = handlerData.fetchData;\n\n const fullUrl = getFullURL(url);\n const host = fullUrl ? parseUrl(fullUrl).host : undefined;\n\n const hasParent = !!getActiveSpan();\n\n const span =\n shouldCreateSpanResult && hasParent\n ? startInactiveSpan({\n name: `${method} ${url}`,\n attributes: {\n url,\n type: 'fetch',\n 'http.method': method,\n 'http.url': fullUrl,\n 'server.address': host,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',\n },\n })\n : new SentryNonRecordingSpan();\n\n handlerData.fetchData.__span = span.spanContext().spanId;\n spans[span.spanContext().spanId] = span;\n\n if (shouldAttachHeaders(handlerData.fetchData.url)) {\n const request = handlerData.args[0];\n\n const options = handlerData.args[1] || {};\n\n const headers = _addTracingHeadersToFetchRequest(\n request,\n options,\n // If performance is disabled (TWP) or there's no active root span (pageload/navigation/interaction),\n // we do not want to use the span as base for the trace headers,\n // which means that the headers will be generated from the scope and the sampling decision is deferred\n hasTracingEnabled() && hasParent ? span : undefined,\n );\n if (headers) {\n // Ensure this is actually set, if no options have been passed previously\n handlerData.args[1] = options;\n options.headers = headers;\n }\n }\n\n return span;\n}\n\n/**\n * Adds sentry-trace and baggage headers to the various forms of fetch headers.\n */\nfunction _addTracingHeadersToFetchRequest(\n request,\n fetchOptionsObj\n\n,\n span,\n) {\n const traceHeaders = getTraceData({ span });\n const sentryTrace = traceHeaders['sentry-trace'];\n const baggage = traceHeaders.baggage;\n\n // Nothing to do, when we return undefined here, the original headers will be used\n if (!sentryTrace) {\n return undefined;\n }\n\n const headers = fetchOptionsObj.headers || (isRequest(request) ? request.headers : undefined);\n\n if (!headers) {\n return { ...traceHeaders };\n } else if (isHeaders(headers)) {\n const newHeaders = new Headers(headers);\n newHeaders.set('sentry-trace', sentryTrace);\n\n if (baggage) {\n const prevBaggageHeader = newHeaders.get('baggage');\n if (prevBaggageHeader) {\n const prevHeaderStrippedFromSentryBaggage = stripBaggageHeaderOfSentryBaggageValues(prevBaggageHeader);\n newHeaders.set(\n 'baggage',\n // If there are non-sentry entries (i.e. if the stripped string is non-empty/truthy) combine the stripped header and sentry baggage header\n // otherwise just set the sentry baggage header\n prevHeaderStrippedFromSentryBaggage ? `${prevHeaderStrippedFromSentryBaggage},${baggage}` : baggage,\n );\n } else {\n newHeaders.set('baggage', baggage);\n }\n }\n\n return newHeaders;\n } else if (Array.isArray(headers)) {\n const newHeaders = [\n ...headers\n // Remove any existing sentry-trace headers\n .filter(header => {\n return !(Array.isArray(header) && header[0] === 'sentry-trace');\n })\n // Get rid of previous sentry baggage values in baggage header\n .map(header => {\n if (Array.isArray(header) && header[0] === 'baggage' && typeof header[1] === 'string') {\n const [headerName, headerValue, ...rest] = header;\n return [headerName, stripBaggageHeaderOfSentryBaggageValues(headerValue), ...rest];\n } else {\n return header;\n }\n }),\n // Attach the new sentry-trace header\n ['sentry-trace', sentryTrace],\n ];\n\n if (baggage) {\n // If there are multiple entries with the same key, the browser will merge the values into a single request header.\n // Its therefore safe to simply push a \"baggage\" entry, even though there might already be another baggage header.\n newHeaders.push(['baggage', baggage]);\n }\n\n return newHeaders ;\n } else {\n const existingBaggageHeader = 'baggage' in headers ? headers.baggage : undefined;\n let newBaggageHeaders = [];\n\n if (Array.isArray(existingBaggageHeader)) {\n newBaggageHeaders = existingBaggageHeader\n .map(headerItem =>\n typeof headerItem === 'string' ? stripBaggageHeaderOfSentryBaggageValues(headerItem) : headerItem,\n )\n .filter(headerItem => headerItem === '');\n } else if (existingBaggageHeader) {\n newBaggageHeaders.push(stripBaggageHeaderOfSentryBaggageValues(existingBaggageHeader));\n }\n\n if (baggage) {\n newBaggageHeaders.push(baggage);\n }\n\n return {\n ...(headers ),\n 'sentry-trace': sentryTrace,\n baggage: newBaggageHeaders.length > 0 ? newBaggageHeaders.join(',') : undefined,\n };\n }\n}\n\n/**\n * Adds sentry-trace and baggage headers to the various forms of fetch headers.\n *\n * @deprecated This function will not be exported anymore in v9.\n */\nfunction addTracingHeadersToFetchRequest(\n request,\n _client,\n _scope,\n fetchOptionsObj\n\n,\n span,\n) {\n return _addTracingHeadersToFetchRequest(request , fetchOptionsObj, span);\n}\n\nfunction getFullURL(url) {\n try {\n const parsed = new URL(url);\n return parsed.href;\n } catch (e) {\n return undefined;\n }\n}\n\nfunction endSpan(span, handlerData) {\n if (handlerData.response) {\n setHttpStatus(span, handlerData.response.status);\n\n const contentLength =\n handlerData.response && handlerData.response.headers && handlerData.response.headers.get('content-length');\n\n if (contentLength) {\n const contentLengthNum = parseInt(contentLength);\n if (contentLengthNum > 0) {\n span.setAttribute('http.response_content_length', contentLengthNum);\n }\n }\n } else if (handlerData.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n span.end();\n}\n\nfunction stripBaggageHeaderOfSentryBaggageValues(baggageHeader) {\n return (\n baggageHeader\n .split(',')\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n .filter(baggageEntry => !baggageEntry.split('=')[0].startsWith(SENTRY_BAGGAGE_KEY_PREFIX))\n .join(',')\n );\n}\n\nfunction isRequest(request) {\n return typeof Request !== 'undefined' && isInstanceOf(request, Request);\n}\n\nfunction isHeaders(headers) {\n return typeof Headers !== 'undefined' && isInstanceOf(headers, Headers);\n}\n\nexport { addTracingHeadersToFetchRequest, instrumentFetchRequest };\n","import { addXhrInstrumentationHandler, addPerformanceInstrumentationHandler, SENTRY_XHR_DATA_KEY } from '@sentry-internal/browser-utils';\nimport { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler, instrumentFetchRequest, parseUrl, spanToJSON, browserPerformanceTimeOrigin, hasTracingEnabled, setHttpStatus, getActiveSpan, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SentryNonRecordingSpan, getTraceData, stringMatchesSomePattern } from '@sentry/core';\nimport { WINDOW } from '../helpers.js';\n\n/** Options for Request Instrumentation */\n\nconst responseToSpanId = new WeakMap();\nconst spanIdToEndTimestamp = new Map();\n\nconst defaultRequestInstrumentationOptions = {\n traceFetch: true,\n traceXHR: true,\n enableHTTPTimings: true,\n trackFetchStreamPerformance: false,\n};\n\n/** Registers span creators for xhr and fetch requests */\nfunction instrumentOutgoingRequests(client, _options) {\n const {\n traceFetch,\n traceXHR,\n trackFetchStreamPerformance,\n shouldCreateSpanForRequest,\n enableHTTPTimings,\n tracePropagationTargets,\n } = {\n traceFetch: defaultRequestInstrumentationOptions.traceFetch,\n traceXHR: defaultRequestInstrumentationOptions.traceXHR,\n trackFetchStreamPerformance: defaultRequestInstrumentationOptions.trackFetchStreamPerformance,\n ..._options,\n };\n\n const shouldCreateSpan =\n typeof shouldCreateSpanForRequest === 'function' ? shouldCreateSpanForRequest : (_) => true;\n\n const shouldAttachHeadersWithTargets = (url) => shouldAttachHeaders(url, tracePropagationTargets);\n\n const spans = {};\n\n if (traceFetch) {\n // Keeping track of http requests, whose body payloads resolved later than the initial resolved request\n // e.g. streaming using server sent events (SSE)\n client.addEventProcessor(event => {\n if (event.type === 'transaction' && event.spans) {\n event.spans.forEach(span => {\n if (span.op === 'http.client') {\n const updatedTimestamp = spanIdToEndTimestamp.get(span.span_id);\n if (updatedTimestamp) {\n span.timestamp = updatedTimestamp / 1000;\n spanIdToEndTimestamp.delete(span.span_id);\n }\n }\n });\n }\n return event;\n });\n\n if (trackFetchStreamPerformance) {\n addFetchEndInstrumentationHandler(handlerData => {\n if (handlerData.response) {\n const span = responseToSpanId.get(handlerData.response);\n if (span && handlerData.endTimestamp) {\n spanIdToEndTimestamp.set(span, handlerData.endTimestamp);\n }\n }\n });\n }\n\n addFetchInstrumentationHandler(handlerData => {\n const createdSpan = instrumentFetchRequest(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans);\n\n if (handlerData.response && handlerData.fetchData.__span) {\n responseToSpanId.set(handlerData.response, handlerData.fetchData.__span);\n }\n\n // We cannot use `window.location` in the generic fetch instrumentation,\n // but we need it for reliable `server.address` attribute.\n // so we extend this in here\n if (createdSpan) {\n const fullUrl = getFullURL(handlerData.fetchData.url);\n const host = fullUrl ? parseUrl(fullUrl).host : undefined;\n createdSpan.setAttributes({\n 'http.url': fullUrl,\n 'server.address': host,\n });\n }\n\n if (enableHTTPTimings && createdSpan) {\n addHTTPTimings(createdSpan);\n }\n });\n }\n\n if (traceXHR) {\n addXhrInstrumentationHandler(handlerData => {\n const createdSpan = xhrCallback(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans);\n if (enableHTTPTimings && createdSpan) {\n addHTTPTimings(createdSpan);\n }\n });\n }\n}\n\nfunction isPerformanceResourceTiming(entry) {\n return (\n entry.entryType === 'resource' &&\n 'initiatorType' in entry &&\n typeof (entry ).nextHopProtocol === 'string' &&\n (entry.initiatorType === 'fetch' || entry.initiatorType === 'xmlhttprequest')\n );\n}\n\n/**\n * Creates a temporary observer to listen to the next fetch/xhr resourcing timings,\n * so that when timings hit their per-browser limit they don't need to be removed.\n *\n * @param span A span that has yet to be finished, must contain `url` on data.\n */\nfunction addHTTPTimings(span) {\n const { url } = spanToJSON(span).data || {};\n\n if (!url || typeof url !== 'string') {\n return;\n }\n\n const cleanup = addPerformanceInstrumentationHandler('resource', ({ entries }) => {\n entries.forEach(entry => {\n if (isPerformanceResourceTiming(entry) && entry.name.endsWith(url)) {\n const spanData = resourceTimingEntryToSpanData(entry);\n spanData.forEach(data => span.setAttribute(...data));\n // In the next tick, clean this handler up\n // We have to wait here because otherwise this cleans itself up before it is fully done\n setTimeout(cleanup);\n }\n });\n });\n}\n\n/**\n * Converts ALPN protocol ids to name and version.\n *\n * (https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids)\n * @param nextHopProtocol PerformanceResourceTiming.nextHopProtocol\n */\nfunction extractNetworkProtocol(nextHopProtocol) {\n let name = 'unknown';\n let version = 'unknown';\n let _name = '';\n for (const char of nextHopProtocol) {\n // http/1.1 etc.\n if (char === '/') {\n [name, version] = nextHopProtocol.split('/') ;\n break;\n }\n // h2, h3 etc.\n if (!isNaN(Number(char))) {\n name = _name === 'h' ? 'http' : _name;\n version = nextHopProtocol.split(_name)[1] ;\n break;\n }\n _name += char;\n }\n if (_name === nextHopProtocol) {\n // webrtc, ftp, etc.\n name = _name;\n }\n return { name, version };\n}\n\nfunction getAbsoluteTime(time = 0) {\n return ((browserPerformanceTimeOrigin || performance.timeOrigin) + time) / 1000;\n}\n\nfunction resourceTimingEntryToSpanData(resourceTiming) {\n const { name, version } = extractNetworkProtocol(resourceTiming.nextHopProtocol);\n\n const timingSpanData = [];\n\n timingSpanData.push(['network.protocol.version', version], ['network.protocol.name', name]);\n\n if (!browserPerformanceTimeOrigin) {\n return timingSpanData;\n }\n return [\n ...timingSpanData,\n ['http.request.redirect_start', getAbsoluteTime(resourceTiming.redirectStart)],\n ['http.request.fetch_start', getAbsoluteTime(resourceTiming.fetchStart)],\n ['http.request.domain_lookup_start', getAbsoluteTime(resourceTiming.domainLookupStart)],\n ['http.request.domain_lookup_end', getAbsoluteTime(resourceTiming.domainLookupEnd)],\n ['http.request.connect_start', getAbsoluteTime(resourceTiming.connectStart)],\n ['http.request.secure_connection_start', getAbsoluteTime(resourceTiming.secureConnectionStart)],\n ['http.request.connection_end', getAbsoluteTime(resourceTiming.connectEnd)],\n ['http.request.request_start', getAbsoluteTime(resourceTiming.requestStart)],\n ['http.request.response_start', getAbsoluteTime(resourceTiming.responseStart)],\n ['http.request.response_end', getAbsoluteTime(resourceTiming.responseEnd)],\n ];\n}\n\n/**\n * A function that determines whether to attach tracing headers to a request.\n * We only export this function for testing purposes.\n */\nfunction shouldAttachHeaders(\n targetUrl,\n tracePropagationTargets,\n) {\n // window.location.href not being defined is an edge case in the browser but we need to handle it.\n // Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj\n const href = WINDOW.location && WINDOW.location.href;\n\n if (!href) {\n // If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`\n // BIG DISCLAIMER: Users can call URLs with a double slash (fetch(\"//example.com/api\")), this is a shorthand for \"send to the same protocol\",\n // so we need a to exclude those requests, because they might be cross origin.\n const isRelativeSameOriginRequest = !!targetUrl.match(/^\\/(?!\\/)/);\n if (!tracePropagationTargets) {\n return isRelativeSameOriginRequest;\n } else {\n return stringMatchesSomePattern(targetUrl, tracePropagationTargets);\n }\n } else {\n let resolvedUrl;\n let currentOrigin;\n\n // URL parsing may fail, we default to not attaching trace headers in that case.\n try {\n resolvedUrl = new URL(targetUrl, href);\n currentOrigin = new URL(href).origin;\n } catch (e) {\n return false;\n }\n\n const isSameOriginRequest = resolvedUrl.origin === currentOrigin;\n if (!tracePropagationTargets) {\n return isSameOriginRequest;\n } else {\n return (\n stringMatchesSomePattern(resolvedUrl.toString(), tracePropagationTargets) ||\n (isSameOriginRequest && stringMatchesSomePattern(resolvedUrl.pathname, tracePropagationTargets))\n );\n }\n }\n}\n\n/**\n * Create and track xhr request spans\n *\n * @returns Span if a span was created, otherwise void.\n */\nfunction xhrCallback(\n handlerData,\n shouldCreateSpan,\n shouldAttachHeaders,\n spans,\n) {\n const xhr = handlerData.xhr;\n const sentryXhrData = xhr && xhr[SENTRY_XHR_DATA_KEY];\n\n if (!xhr || xhr.__sentry_own_request__ || !sentryXhrData) {\n return undefined;\n }\n\n const shouldCreateSpanResult = hasTracingEnabled() && shouldCreateSpan(sentryXhrData.url);\n\n // check first if the request has finished and is tracked by an existing span which should now end\n if (handlerData.endTimestamp && shouldCreateSpanResult) {\n const spanId = xhr.__sentry_xhr_span_id__;\n if (!spanId) return;\n\n const span = spans[spanId];\n if (span && sentryXhrData.status_code !== undefined) {\n setHttpStatus(span, sentryXhrData.status_code);\n span.end();\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete spans[spanId];\n }\n return undefined;\n }\n\n const fullUrl = getFullURL(sentryXhrData.url);\n const host = fullUrl ? parseUrl(fullUrl).host : undefined;\n\n const hasParent = !!getActiveSpan();\n\n const span =\n shouldCreateSpanResult && hasParent\n ? startInactiveSpan({\n name: `${sentryXhrData.method} ${sentryXhrData.url}`,\n attributes: {\n type: 'xhr',\n 'http.method': sentryXhrData.method,\n 'http.url': fullUrl,\n url: sentryXhrData.url,\n 'server.address': host,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',\n },\n })\n : new SentryNonRecordingSpan();\n\n xhr.__sentry_xhr_span_id__ = span.spanContext().spanId;\n spans[xhr.__sentry_xhr_span_id__] = span;\n\n if (shouldAttachHeaders(sentryXhrData.url)) {\n addTracingHeadersToXhrRequest(\n xhr,\n // If performance is disabled (TWP) or there's no active root span (pageload/navigation/interaction),\n // we do not want to use the span as base for the trace headers,\n // which means that the headers will be generated from the scope and the sampling decision is deferred\n hasTracingEnabled() && hasParent ? span : undefined,\n );\n }\n\n return span;\n}\n\nfunction addTracingHeadersToXhrRequest(xhr, span) {\n const { 'sentry-trace': sentryTrace, baggage } = getTraceData({ span });\n\n if (sentryTrace) {\n setHeaderOnXhr(xhr, sentryTrace, baggage);\n }\n}\n\nfunction setHeaderOnXhr(\n xhr,\n sentryTraceHeader,\n sentryBaggageHeader,\n) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n xhr.setRequestHeader('sentry-trace', sentryTraceHeader);\n if (sentryBaggageHeader) {\n // From MDN: \"If this method is called several times with the same header, the values are merged into one single request header.\"\n // We can therefore simply set a baggage header without checking what was there before\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n xhr.setRequestHeader('baggage', sentryBaggageHeader);\n }\n } catch (_) {\n // Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.\n }\n}\n\nfunction getFullURL(url) {\n try {\n // By adding a base URL to new URL(), this will also work for relative urls\n // If `url` is a full URL, the base URL is ignored anyhow\n const parsed = new URL(url, WINDOW.location.origin);\n return parsed.href;\n } catch (e2) {\n return undefined;\n }\n}\n\nexport { defaultRequestInstrumentationOptions, extractNetworkProtocol, instrumentOutgoingRequests, shouldAttachHeaders, xhrCallback };\n","import { startTrackingWebVitals, startTrackingINP, startTrackingLongAnimationFrames, startTrackingLongTasks, startTrackingInteractions, addHistoryInstrumentationHandler, registerInpInteractionListener, addPerformanceEntries } from '@sentry-internal/browser-utils';\nimport { TRACING_DEFAULTS, registerSpanErrorInstrumentation, GLOBAL_OBJ, getClient, propagationContextFromHeaders, getCurrentScope, spanToJSON, getRootSpan, spanIsSampled, getDynamicSamplingContextFromSpan, browserPerformanceTimeOrigin, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan, getIsolationScope, generateTraceId, getDomElement, startIdleSpan, logger, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { WINDOW } from '../helpers.js';\nimport { registerBackgroundTabDetection } from './backgroundtab.js';\nimport { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './request.js';\n\n/* eslint-disable max-lines */\n\nconst BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing';\n\nconst DEFAULT_BROWSER_TRACING_OPTIONS = {\n ...TRACING_DEFAULTS,\n instrumentNavigation: true,\n instrumentPageLoad: true,\n markBackgroundSpan: true,\n enableLongTask: true,\n enableLongAnimationFrame: true,\n enableInp: true,\n _experiments: {},\n ...defaultRequestInstrumentationOptions,\n};\n\n/**\n * The Browser Tracing integration automatically instruments browser pageload/navigation\n * actions as transactions, and captures requests, metrics and errors as spans.\n *\n * The integration can be configured with a variety of options, and can be extended to use\n * any routing library.\n *\n * We explicitly export the proper type here, as this has to be extended in some cases.\n */\nconst browserTracingIntegration = ((_options = {}) => {\n registerSpanErrorInstrumentation();\n\n const {\n enableInp,\n enableLongTask,\n enableLongAnimationFrame,\n _experiments: { enableInteractions, enableStandaloneClsSpans },\n beforeStartSpan,\n idleTimeout,\n finalTimeout,\n childSpanTimeout,\n markBackgroundSpan,\n traceFetch,\n traceXHR,\n trackFetchStreamPerformance,\n shouldCreateSpanForRequest,\n enableHTTPTimings,\n instrumentPageLoad,\n instrumentNavigation,\n } = {\n ...DEFAULT_BROWSER_TRACING_OPTIONS,\n ..._options,\n };\n\n const _collectWebVitals = startTrackingWebVitals({ recordClsStandaloneSpans: enableStandaloneClsSpans || false });\n\n if (enableInp) {\n startTrackingINP();\n }\n\n if (\n enableLongAnimationFrame &&\n GLOBAL_OBJ.PerformanceObserver &&\n PerformanceObserver.supportedEntryTypes &&\n PerformanceObserver.supportedEntryTypes.includes('long-animation-frame')\n ) {\n startTrackingLongAnimationFrames();\n } else if (enableLongTask) {\n startTrackingLongTasks();\n }\n\n if (enableInteractions) {\n startTrackingInteractions();\n }\n\n const latestRoute = {\n name: undefined,\n source: undefined,\n };\n\n /** Create routing idle transaction. */\n function _createRouteSpan(client, startSpanOptions) {\n const isPageloadTransaction = startSpanOptions.op === 'pageload';\n\n const finalStartSpanOptions = beforeStartSpan\n ? beforeStartSpan(startSpanOptions)\n : startSpanOptions;\n\n const attributes = finalStartSpanOptions.attributes || {};\n\n // If `finalStartSpanOptions.name` is different than `startSpanOptions.name`\n // it is because `beforeStartSpan` set a custom name. Therefore we set the source to 'custom'.\n if (startSpanOptions.name !== finalStartSpanOptions.name) {\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = 'custom';\n finalStartSpanOptions.attributes = attributes;\n }\n\n latestRoute.name = finalStartSpanOptions.name;\n latestRoute.source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n\n const idleSpan = startIdleSpan(finalStartSpanOptions, {\n idleTimeout,\n finalTimeout,\n childSpanTimeout,\n // should wait for finish signal if it's a pageload transaction\n disableAutoFinish: isPageloadTransaction,\n beforeSpanEnd: span => {\n _collectWebVitals();\n addPerformanceEntries(span, { recordClsOnPageloadSpan: !enableStandaloneClsSpans });\n },\n });\n\n function emitFinish() {\n if (['interactive', 'complete'].includes(WINDOW.document.readyState)) {\n client.emit('idleSpanEnableAutoFinish', idleSpan);\n }\n }\n\n if (isPageloadTransaction && WINDOW.document) {\n WINDOW.document.addEventListener('readystatechange', () => {\n emitFinish();\n });\n\n emitFinish();\n }\n\n return idleSpan;\n }\n\n return {\n name: BROWSER_TRACING_INTEGRATION_ID,\n afterAllSetup(client) {\n let activeSpan;\n let startingUrl = WINDOW.location && WINDOW.location.href;\n\n function maybeEndActiveSpan() {\n if (activeSpan && !spanToJSON(activeSpan).timestamp) {\n DEBUG_BUILD && logger.log(`[Tracing] Finishing current active span with op: ${spanToJSON(activeSpan).op}`);\n // If there's an open active span, we need to finish it before creating an new one.\n activeSpan.end();\n }\n }\n\n client.on('startNavigationSpan', startSpanOptions => {\n if (getClient() !== client) {\n return;\n }\n\n maybeEndActiveSpan();\n\n activeSpan = _createRouteSpan(client, {\n op: 'navigation',\n ...startSpanOptions,\n });\n });\n\n client.on('startPageLoadSpan', (startSpanOptions, traceOptions = {}) => {\n if (getClient() !== client) {\n return;\n }\n maybeEndActiveSpan();\n\n const sentryTrace = traceOptions.sentryTrace || getMetaContent('sentry-trace');\n const baggage = traceOptions.baggage || getMetaContent('baggage');\n\n const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);\n getCurrentScope().setPropagationContext(propagationContext);\n\n activeSpan = _createRouteSpan(client, {\n op: 'pageload',\n ...startSpanOptions,\n });\n });\n\n // A trace should to stay the consistent over the entire time span of one route.\n // Therefore, when the initial pageload or navigation root span ends, we update the\n // scope's propagation context to keep span-specific attributes like the `sampled` decision and\n // the dynamic sampling context valid, even after the root span has ended.\n // This ensures that the trace data is consistent for the entire duration of the route.\n client.on('spanEnd', span => {\n const op = spanToJSON(span).op;\n if (span !== getRootSpan(span) || (op !== 'navigation' && op !== 'pageload')) {\n return;\n }\n\n const scope = getCurrentScope();\n const oldPropagationContext = scope.getPropagationContext();\n\n scope.setPropagationContext({\n ...oldPropagationContext,\n sampled: oldPropagationContext.sampled !== undefined ? oldPropagationContext.sampled : spanIsSampled(span),\n dsc: oldPropagationContext.dsc || getDynamicSamplingContextFromSpan(span),\n });\n });\n\n if (WINDOW.location) {\n if (instrumentPageLoad) {\n startBrowserTracingPageLoadSpan(client, {\n name: WINDOW.location.pathname,\n // pageload should always start at timeOrigin (and needs to be in s, not ms)\n startTime: browserPerformanceTimeOrigin ? browserPerformanceTimeOrigin / 1000 : undefined,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.browser',\n },\n });\n }\n\n if (instrumentNavigation) {\n addHistoryInstrumentationHandler(({ to, from }) => {\n /**\n * This early return is there to account for some cases where a navigation transaction starts right after\n * long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't\n * create an uneccessary navigation transaction.\n *\n * This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also\n * only be caused in certain development environments where the usage of a hot module reloader is causing\n * errors.\n */\n if (from === undefined && startingUrl && startingUrl.indexOf(to) !== -1) {\n startingUrl = undefined;\n return;\n }\n\n if (from !== to) {\n startingUrl = undefined;\n startBrowserTracingNavigationSpan(client, {\n name: WINDOW.location.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.browser',\n },\n });\n }\n });\n }\n }\n\n if (markBackgroundSpan) {\n registerBackgroundTabDetection();\n }\n\n if (enableInteractions) {\n registerInteractionListener(idleTimeout, finalTimeout, childSpanTimeout, latestRoute);\n }\n\n if (enableInp) {\n registerInpInteractionListener();\n }\n\n instrumentOutgoingRequests(client, {\n traceFetch,\n traceXHR,\n trackFetchStreamPerformance,\n tracePropagationTargets: client.getOptions().tracePropagationTargets,\n shouldCreateSpanForRequest,\n enableHTTPTimings,\n });\n },\n };\n}) ;\n\n/**\n * Manually start a page load span.\n * This will only do something if a browser tracing integration integration has been setup.\n *\n * If you provide a custom `traceOptions` object, it will be used to continue the trace\n * instead of the default behavior, which is to look it up on the tags.\n */\nfunction startBrowserTracingPageLoadSpan(\n client,\n spanOptions,\n traceOptions,\n) {\n client.emit('startPageLoadSpan', spanOptions, traceOptions);\n\n getCurrentScope().setTransactionName(spanOptions.name);\n\n const span = getActiveSpan();\n const op = span && spanToJSON(span).op;\n return op === 'pageload' ? span : undefined;\n}\n\n/**\n * Manually start a navigation span.\n * This will only do something if a browser tracing integration has been setup.\n */\nfunction startBrowserTracingNavigationSpan(client, spanOptions) {\n getIsolationScope().setPropagationContext({ traceId: generateTraceId() });\n getCurrentScope().setPropagationContext({ traceId: generateTraceId() });\n\n client.emit('startNavigationSpan', spanOptions);\n\n getCurrentScope().setTransactionName(spanOptions.name);\n\n const span = getActiveSpan();\n const op = span && spanToJSON(span).op;\n return op === 'navigation' ? span : undefined;\n}\n\n/** Returns the value of a meta tag */\nfunction getMetaContent(metaName) {\n // Can't specify generic to `getDomElement` because tracing can be used\n // in a variety of environments, have to disable `no-unsafe-member-access`\n // as a result.\n // eslint-disable-next-line deprecation/deprecation\n const metaTag = getDomElement(`meta[name=${metaName}]`);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return metaTag ? metaTag.getAttribute('content') : undefined;\n}\n\n/** Start listener for interaction transactions */\nfunction registerInteractionListener(\n idleTimeout,\n finalTimeout,\n childSpanTimeout,\n latestRoute,\n) {\n let inflightInteractionSpan;\n const registerInteractionTransaction = () => {\n const op = 'ui.action.click';\n\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n if (rootSpan) {\n const currentRootSpanOp = spanToJSON(rootSpan).op;\n if (['navigation', 'pageload'].includes(currentRootSpanOp )) {\n DEBUG_BUILD &&\n logger.warn(`[Tracing] Did not create ${op} span because a pageload or navigation span is in progress.`);\n return undefined;\n }\n }\n\n if (inflightInteractionSpan) {\n inflightInteractionSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON, 'interactionInterrupted');\n inflightInteractionSpan.end();\n inflightInteractionSpan = undefined;\n }\n\n if (!latestRoute.name) {\n DEBUG_BUILD && logger.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);\n return undefined;\n }\n\n inflightInteractionSpan = startIdleSpan(\n {\n name: latestRoute.name,\n op,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.source || 'url',\n },\n },\n {\n idleTimeout,\n finalTimeout,\n childSpanTimeout,\n },\n );\n };\n\n if (WINDOW.document) {\n addEventListener('click', registerInteractionTransaction, { once: false, capture: true });\n }\n}\n\nexport { BROWSER_TRACING_INTEGRATION_ID, browserTracingIntegration, getMetaContent, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan };\n","import { getActiveSpan, getRootSpan, spanToJSON, logger, SPAN_STATUS_ERROR } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build.js';\nimport { WINDOW } from '../helpers.js';\n\n/**\n * Add a listener that cancels and finishes a transaction when the global\n * document is hidden.\n */\nfunction registerBackgroundTabDetection() {\n if (WINDOW && WINDOW.document) {\n WINDOW.document.addEventListener('visibilitychange', () => {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n return;\n }\n\n const rootSpan = getRootSpan(activeSpan);\n\n if (WINDOW.document.hidden && rootSpan) {\n const cancelledStatus = 'cancelled';\n\n const { op, status } = spanToJSON(rootSpan);\n\n if (DEBUG_BUILD) {\n logger.log(`[Tracing] Transaction: ${cancelledStatus} -> since tab moved to the background, op: ${op}`);\n }\n\n // We should not set status if it is already set, this prevent important statuses like\n // error or data loss from being overwritten on transaction.\n if (!status) {\n rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message: cancelledStatus });\n }\n\n rootSpan.setAttribute('sentry.cancellation_reason', 'document.hidden');\n rootSpan.end();\n }\n });\n } else {\n DEBUG_BUILD && logger.warn('[Tracing] Could not set up background tab detection due to lack of global document');\n }\n}\n\nexport { registerBackgroundTabDetection };\n","import * as Sentry from '@sentry/browser';\nimport { breadcrumbsIntegration, globalHandlersIntegration, linkedErrorsIntegration, httpContextIntegration, browserSessionIntegration, init as init$1, setContext, browserTracingIntegration as browserTracingIntegration$1, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getClient, startBrowserTracingNavigationSpan, startInactiveSpan, getCurrentScope, getActiveSpan, getRootSpan } from '@sentry/browser';\nexport * from '@sentry/browser';\nimport * as i0 from '@angular/core';\nimport { VERSION, Injectable, Inject, Directive, Input, NgModule } from '@angular/core';\nimport { inboundFiltersIntegration, functionToStringIntegration, dedupeIntegration, applySdkMetadata, logger, isString, consoleSandbox, stripUrlQueryAndFragment, timestampInSeconds } from '@sentry/core';\nimport { HttpErrorResponse } from '@angular/common/http';\nimport * as i1 from '@angular/router';\nimport { NavigationStart, ResolveEnd, NavigationEnd, NavigationCancel, NavigationError } from '@angular/router';\nimport { Subscription } from 'rxjs';\nimport { filter, tap } from 'rxjs/operators';\n\n/*\n * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking\n * for users.\n *\n * We define \"magic strings\" like `__SENTRY_DEBUG__` that may get replaced with actual values during our, or the user's\n * build process. Take care when introducing new flags - they must not throw if they are not replaced. See the Debug\n * Build Flags section in CONTRIBUTING.md.\n */\n/** Flag that is true for debug builds, false otherwise. */\nconst IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;\n\n/**\n * Get the default integrations for the Angular SDK.\n */\nfunction getDefaultIntegrations(options = {}) {\n // Don't include the BrowserApiErrors integration as it interferes with the Angular SDK's `ErrorHandler`:\n // BrowserApiErrors would catch certain errors before they reach the `ErrorHandler` and\n // thus provide a lower fidelity error than what `SentryErrorHandler`\n // (see errorhandler.ts) would provide.\n //\n // see:\n // - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097\n // - https://github.com/getsentry/sentry-javascript/issues/2744\n const integrations = [\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n breadcrumbsIntegration(),\n globalHandlersIntegration(),\n linkedErrorsIntegration(),\n dedupeIntegration(),\n httpContextIntegration(),\n ];\n // eslint-disable-next-line deprecation/deprecation\n if (options.autoSessionTracking !== false) {\n integrations.push(browserSessionIntegration());\n }\n return integrations;\n}\n/**\n * Inits the Angular SDK\n */\nfunction init(options) {\n const opts = {\n defaultIntegrations: getDefaultIntegrations(),\n ...options,\n };\n applySdkMetadata(opts, 'angular');\n checkAndSetAngularVersion();\n return init$1(opts);\n}\nfunction checkAndSetAngularVersion() {\n const ANGULAR_MINIMUM_VERSION = 14;\n const angularVersion = VERSION && VERSION.major ? parseInt(VERSION.major, 10) : undefined;\n if (angularVersion) {\n if (angularVersion < ANGULAR_MINIMUM_VERSION) {\n IS_DEBUG_BUILD &&\n logger.warn(`This Sentry SDK does not officially support Angular ${angularVersion}.`, `This SDK only supports Angular ${ANGULAR_MINIMUM_VERSION} and above.`, \"If you're using lower Angular versions, check the Angular Version Compatibility table in our docs: https://docs.sentry.io/platforms/javascript/guides/angular/#angular-version-compatibility.\", 'Otherwise, please consider upgrading your Angular version.');\n }\n setContext('angular', { version: angularVersion });\n }\n}\n\n// In Angular 17 and future versions, zoneless support is forthcoming.\n// Therefore, it's advisable to safely check whether the `run` function is\n// available in the `` context.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\nconst isNgZoneEnabled = typeof Zone !== 'undefined' && Zone.root && Zone.root.run;\n/**\n * The function that does the same job as `NgZone.runOutsideAngular`.\n *\n * ⚠️ Note: All of the Sentry functionality called from inside the Angular\n * execution context must be wrapped in this function. Angular's rendering\n * relies on asynchronous tasks being scheduled within its execution context.\n * Since Sentry schedules tasks that do not interact with Angular's rendering,\n * it may prevent Angular from functioning reliably. Consequently, it may disrupt\n * processes such as server-side rendering or client-side hydration.\n */\nfunction runOutsideAngular(callback) {\n // Running the `callback` within the root execution context enables Angular\n // processes (such as SSR and hydration) to continue functioning normally without\n // timeouts and delays that could affect the user experience. This approach is\n // necessary because some of the Sentry functionality continues to run in the background.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return isNgZoneEnabled ? Zone.root.run(callback) : callback();\n}\n\n// https://github.com/angular/angular/blob/master/packages/core/src/util/errors.ts\nfunction tryToUnwrapZonejsError(error) {\n // TODO: once Angular14 is the minimum requirement ERROR_ORIGINAL_ERROR and\n // getOriginalError from error.ts can be used directly.\n return error && error.ngOriginalError\n ? error.ngOriginalError\n : error;\n}\nfunction extractHttpModuleError(error) {\n // The `error` property of http exception can be either an `Error` object, which we can use directly...\n if (isErrorOrErrorLikeObject(error.error)) {\n return error.error;\n }\n // ... or an`ErrorEvent`, which can provide us with the message but no stack...\n // guarding `ErrorEvent` against `undefined` as it's not defined in Node environments\n if (typeof ErrorEvent !== 'undefined' && error.error instanceof ErrorEvent && error.error.message) {\n return error.error.message;\n }\n // ...or the request body itself, which we can use as a message instead.\n if (typeof error.error === 'string') {\n return `Server returned code ${error.status} with body \"${error.error}\"`;\n }\n // If we don't have any detailed information, fallback to the request message itself.\n return error.message;\n}\nfunction isErrorOrErrorLikeObject(value) {\n if (value instanceof Error) {\n return true;\n }\n if (value === null || typeof value !== 'object') {\n return false;\n }\n const candidate = value;\n return (isString(candidate.name) &&\n isString(candidate.message) &&\n (undefined === candidate.stack || isString(candidate.stack)));\n}\n/**\n * Implementation of Angular's ErrorHandler provider that can be used as a drop-in replacement for the stock one.\n */\nclass SentryErrorHandler {\n constructor(options) {\n this._options = {\n logErrors: true,\n ...options,\n };\n }\n /**\n * Method executed when the injector is destroyed.\n */\n ngOnDestroy() {\n if (this._removeAfterSendEventListener) {\n this._removeAfterSendEventListener();\n }\n }\n /**\n * Method called for every value captured through the ErrorHandler\n */\n handleError(error) {\n const extractedError = this._extractError(error) || 'Handled unknown error';\n // Capture handled exception and send it to Sentry.\n const eventId = runOutsideAngular(() => Sentry.captureException(extractedError, {\n mechanism: { type: 'angular', handled: false },\n }));\n // When in development mode, log the error to console for immediate feedback.\n if (this._options.logErrors) {\n // eslint-disable-next-line no-console\n consoleSandbox(() => console.error(extractedError));\n }\n // Optionally show user dialog to provide details on what happened.\n if (this._options.showDialog) {\n const client = Sentry.getClient();\n if (client && !this._removeAfterSendEventListener) {\n this._removeAfterSendEventListener = client.on('afterSendEvent', (event) => {\n if (!event.type && event.event_id) {\n runOutsideAngular(() => {\n Sentry.showReportDialog({ ...this._options.dialogOptions, eventId: event.event_id });\n });\n }\n });\n }\n else if (!client) {\n runOutsideAngular(() => {\n Sentry.showReportDialog({ ...this._options.dialogOptions, eventId });\n });\n }\n }\n }\n /**\n * Used to pull a desired value that will be used to capture an event out of the raw value captured by ErrorHandler.\n */\n _extractError(error) {\n // Allow custom overrides of extracting function\n if (this._options.extractor) {\n const defaultExtractor = this._defaultExtractor.bind(this);\n return this._options.extractor(error, defaultExtractor);\n }\n return this._defaultExtractor(error);\n }\n /**\n * Default implementation of error extraction that handles default error wrapping, HTTP responses, ErrorEvent and few other known cases.\n */\n _defaultExtractor(errorCandidate) {\n const error = tryToUnwrapZonejsError(errorCandidate);\n // If it's http module error, extract as much information from it as we can.\n if (error instanceof HttpErrorResponse) {\n return extractHttpModuleError(error);\n }\n // We can handle messages and Error objects directly.\n if (typeof error === 'string' || isErrorOrErrorLikeObject(error)) {\n return error;\n }\n // Nothing was extracted, fallback to default error message.\n return null;\n }\n}\nSentryErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: SentryErrorHandler, deps: [{ token: 'errorHandlerOptions' }], target: i0.ɵɵFactoryTarget.Injectable });\nSentryErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: SentryErrorHandler, providedIn: 'root' });\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: SentryErrorHandler, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: function () { return [{ type: undefined, decorators: [{\n type: Inject,\n args: ['errorHandlerOptions']\n }] }]; } });\n/**\n * Factory function that creates an instance of a preconfigured ErrorHandler provider.\n */\nfunction createErrorHandler(config) {\n return new SentryErrorHandler(config);\n}\n\nconst ANGULAR_ROUTING_OP = 'ui.angular.routing';\nconst ANGULAR_INIT_OP = 'ui.angular.init';\nconst ANGULAR_OP = 'ui.angular';\n\nlet instrumentationInitialized;\n/**\n * A custom browser tracing integration for Angular.\n *\n * Use this integration in combination with `TraceService`\n */\nfunction browserTracingIntegration(options = {}) {\n // If the user opts out to set this up, we just don't initialize this.\n // That way, the TraceService will not actually do anything, functionally disabling this.\n if (options.instrumentNavigation !== false) {\n instrumentationInitialized = true;\n }\n return browserTracingIntegration$1({\n ...options,\n instrumentNavigation: false,\n });\n}\n/**\n * This function is extracted to make unit testing easier.\n */\nfunction _updateSpanAttributesForParametrizedUrl(route, span) {\n const attributes = (span && spanToJSON(span).data) || {};\n if (span && attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] === 'url') {\n span.updateName(route);\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, `auto.${spanToJSON(span).op}.angular`);\n }\n}\n/**\n * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.\n * Creates a new transaction for every route change and measures a duration of routing process.\n */\nclass TraceService {\n constructor(_router) {\n this._router = _router;\n this.navStart$ = this._router.events.pipe(filter((event) => event instanceof NavigationStart), tap(navigationEvent => {\n if (!instrumentationInitialized) {\n IS_DEBUG_BUILD &&\n logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');\n return;\n }\n if (this._routingSpan) {\n this._routingSpan.end();\n this._routingSpan = null;\n }\n const client = getClient();\n const strippedUrl = stripUrlQueryAndFragment(navigationEvent.url);\n if (client) {\n // see comment in `_isPageloadOngoing` for rationale\n if (!this._isPageloadOngoing()) {\n runOutsideAngular(() => {\n startBrowserTracingNavigationSpan(client, {\n name: strippedUrl,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.angular',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n },\n });\n });\n }\n else {\n // The first time we end up here, we set the pageload flag to false\n // Subsequent navigations are going to get their own navigation root span\n // even if the pageload root span is still ongoing.\n this._pageloadOngoing = false;\n }\n this._routingSpan =\n runOutsideAngular(() => startInactiveSpan({\n name: `${navigationEvent.url}`,\n op: ANGULAR_ROUTING_OP,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n url: strippedUrl,\n ...(navigationEvent.navigationTrigger && {\n navigationTrigger: navigationEvent.navigationTrigger,\n }),\n },\n })) || null;\n return;\n }\n }));\n // The ResolveEnd event is fired when the Angular router has resolved the URL and\n // the parameter<->value mapping. It holds the new resolved router state with\n // the mapping and the new URL.\n // Only After this event, the route is activated, meaning that the transaction\n // can be updated with the parameterized route name before e.g. the route's root\n // component is initialized. This should be early enough before outgoing requests\n // are made from the new route, with the exceptions of requests being made during\n // a navigation.\n this.resEnd$ = this._router.events.pipe(filter((event) => event instanceof ResolveEnd), tap(event => {\n const route = getParameterizedRouteFromSnapshot(event.state.root);\n if (route) {\n getCurrentScope().setTransactionName(route);\n }\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n _updateSpanAttributesForParametrizedUrl(route, rootSpan);\n }));\n this.navEnd$ = this._router.events.pipe(filter(event => event instanceof NavigationEnd || event instanceof NavigationCancel || event instanceof NavigationError), tap(() => {\n if (this._routingSpan) {\n runOutsideAngular(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._routingSpan.end();\n });\n this._routingSpan = null;\n }\n }));\n this._routingSpan = null;\n this._pageloadOngoing = true;\n this._subscription = new Subscription();\n this._subscription.add(this.navStart$.subscribe());\n this._subscription.add(this.resEnd$.subscribe());\n this._subscription.add(this.navEnd$.subscribe());\n }\n /**\n * This is used to prevent memory leaks when the root view is created and destroyed multiple times,\n * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.\n */\n ngOnDestroy() {\n this._subscription.unsubscribe();\n }\n /**\n * We only _avoid_ creating a navigation root span in one case:\n *\n * There is an ongoing pageload span AND the router didn't yet emit the first navigation start event\n *\n * The first navigation start event will create the child routing span\n * and update the pageload root span name on ResolveEnd.\n *\n * There's an edge case we need to avoid here: If the router fires the first navigation start event\n * _after_ the pageload root span finished. This is why we check for the pageload root span.\n * Possible real-world scenario: Angular application and/or router is bootstrapped after the pageload\n * idle root span finished\n *\n * The overall rationale is:\n * - if we already avoided creating a navigation root span once, we don't avoid it again\n * (i.e. set `_pageloadOngoing` to `false`)\n * - if `_pageloadOngoing` is already `false`, create a navigation root span\n * - if there's no active/pageload root span, create a navigation root span\n * - only if there's an ongoing pageload root span AND `_pageloadOngoing` is still `true,\n * don't create a navigation root span\n */\n _isPageloadOngoing() {\n if (!this._pageloadOngoing) {\n // pageload is already finished, no need to update\n return false;\n }\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n this._pageloadOngoing = false;\n return false;\n }\n const rootSpan = getRootSpan(activeSpan);\n this._pageloadOngoing = spanToJSON(rootSpan).op === 'pageload';\n return this._pageloadOngoing;\n }\n}\nTraceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceService, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });\nTraceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceService, providedIn: 'root' });\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceService, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: function () { return [{ type: i1.Router }]; } });\n/**\n * Captures the initialization lifecycle of the component this directive is applied to.\n * Specifically, this directive measures the time between `ngOnInit` and `ngAfterViewInit`\n * of the component.\n *\n * Falls back to the component's selector if no name is provided.\n *\n * @example\n * ```html\n * \n * ```\n */\nclass TraceDirective {\n constructor(_host) {\n this._host = _host;\n }\n /**\n * Implementation of OnInit lifecycle method\n * @inheritdoc\n */\n ngOnInit() {\n if (!this.componentName) {\n // Technically, the `trace` binding should always be provided.\n // However, if it is incorrectly declared on the element without a\n // value (e.g., ``), we fall back to using `tagName`\n // (which is e.g. `APP-COMPONENT`).\n this.componentName = this._host.nativeElement.tagName.toLowerCase();\n }\n if (getActiveSpan()) {\n this._tracingSpan = runOutsideAngular(() => startInactiveSpan({\n name: `<${this.componentName}>`,\n op: ANGULAR_INIT_OP,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_directive' },\n }));\n }\n }\n /**\n * Implementation of AfterViewInit lifecycle method\n * @inheritdoc\n */\n ngAfterViewInit() {\n const span = this._tracingSpan;\n if (span) {\n runOutsideAngular(() => span.end());\n }\n }\n}\nTraceDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });\nTraceDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"14.3.0\", type: TraceDirective, selector: \"[trace]\", inputs: { componentName: [\"trace\", \"componentName\"] }, ngImport: i0 });\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceDirective, decorators: [{\n type: Directive,\n args: [{ selector: '[trace]' }]\n }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { componentName: [{\n type: Input,\n args: ['trace']\n }] } });\n/**\n * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.\n */\nclass TraceModule {\n}\nTraceModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\nTraceModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceModule, declarations: [TraceDirective], exports: [TraceDirective] });\nTraceModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceModule });\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"14.3.0\", ngImport: i0, type: TraceModule, decorators: [{\n type: NgModule,\n args: [{\n declarations: [TraceDirective],\n exports: [TraceDirective],\n }]\n }] });\n/**\n * Decorator function that can be used to capture initialization lifecycle of the whole component.\n */\nfunction TraceClass(options) {\n let tracingSpan;\n /* eslint-disable @typescript-eslint/no-unsafe-member-access */\n return target => {\n const originalOnInit = target.prototype.ngOnInit;\n target.prototype.ngOnInit = function (...args) {\n tracingSpan = runOutsideAngular(() => startInactiveSpan({\n onlyIfParent: true,\n name: `<${options && options.name ? options.name : 'unnamed'}>`,\n op: ANGULAR_INIT_OP,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_class_decorator',\n },\n }));\n if (originalOnInit) {\n return originalOnInit.apply(this, args);\n }\n };\n const originalAfterViewInit = target.prototype.ngAfterViewInit;\n target.prototype.ngAfterViewInit = function (...args) {\n if (tracingSpan) {\n runOutsideAngular(() => tracingSpan.end());\n }\n if (originalAfterViewInit) {\n return originalAfterViewInit.apply(this, args);\n }\n };\n };\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n/**\n * Decorator function that can be used to capture a single lifecycle methods of the component.\n */\nfunction TraceMethod(options) {\n return (_target, propertyKey, descriptor) => {\n const originalMethod = descriptor.value;\n descriptor.value = function (...args) {\n const now = timestampInSeconds();\n runOutsideAngular(() => {\n startInactiveSpan({\n onlyIfParent: true,\n name: `<${options && options.name ? options.name : 'unnamed'}>`,\n op: `${ANGULAR_OP}.${String(propertyKey)}`,\n startTime: now,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_method_decorator',\n },\n }).end(now);\n });\n if (originalMethod) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return originalMethod.apply(this, args);\n }\n };\n return descriptor;\n };\n}\n/**\n * Takes the parameterized route from a given ActivatedRouteSnapshot and concatenates the snapshot's\n * child route with its parent to produce the complete parameterized URL of the activated route.\n * This happens recursively until the last child (i.e. the end of the URL) is reached.\n *\n * @param route the ActivatedRouteSnapshot of which its path and its child's path is concatenated\n *\n * @returns the concatenated parameterized route string\n */\nfunction getParameterizedRouteFromSnapshot(route) {\n const parts = [];\n let currentRoute = route && route.firstChild;\n while (currentRoute) {\n const path = currentRoute && currentRoute.routeConfig && currentRoute.routeConfig.path;\n if (path === null || path === undefined) {\n break;\n }\n parts.push(path);\n currentRoute = currentRoute.firstChild;\n }\n const fullPath = parts.filter(part => part).join('/');\n return fullPath ? `/${fullPath}/` : '/';\n}\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { SentryErrorHandler, TraceClass, TraceDirective, TraceMethod, TraceModule, TraceService, browserTracingIntegration, createErrorHandler, getDefaultIntegrations, init };\n","import * as i0 from '@angular/core';\nimport { PLATFORM_ID, Injectable, Inject } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\n\n/**\n * Created by ahsanayaz on 08/11/2016.\n */\nconst GENERAL = {\n UKNOWN: 'Unknown',\n};\nconst BROWSERS = {\n CHROME: 'Chrome',\n FIREFOX: 'Firefox',\n SAFARI: 'Safari',\n OPERA: 'Opera',\n IE: 'IE',\n MS_EDGE: 'MS-Edge',\n MS_EDGE_CHROMIUM: 'MS-Edge-Chromium',\n FB_MESSANGER: 'FB-Messanger',\n SAMSUNG: 'Samsung',\n UCBROWSER: 'UC-Browser',\n UNKNOWN: GENERAL.UKNOWN,\n};\nconst MOBILES_RE = {\n // tslint:disable-next-line:max-line-length\n HTC: /HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel/,\n NEXUS_PHONE: /Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6/,\n DELL: /Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b/,\n MOTOROLA: new RegExp(`Motorola|DROIDX|DROID BIONIC|\\\\bDroid\\\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|\n A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|\n MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|\n ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|\n WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|\n XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|\n XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\\\bMoto E\\\\b|XT1068|XT1092|XT1052`),\n SAMSUNG: new RegExp(`\\\\bSamsung\\\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|\n GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|\n GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|\n GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|\n GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|\n GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|\n GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|\n GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|\n GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|\n GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|\n GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|\n GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|\n GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|\n GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|\n GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|\n GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|\n GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|\n GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|\n SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|\n SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|\n SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|\n SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|\n SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|\n SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|\n SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|\n SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|\n SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|\n SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|\n SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|\n SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|\n SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|\n SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|\n SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|\n SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|\n SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|\n SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|\n SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|\n SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|\n SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|\n SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|\n SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|\n SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|\n SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|\n SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|\n SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|\n SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|\n SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|\n SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|\n SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|\n GT-N7105|SCH-I535|SM-N900A|SM-N900T|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|\n GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|\n GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|\n SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|\n SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|\n SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F`),\n LG: new RegExp(`\\\\bLG\\\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|\n LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|\n C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|\n LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|\n VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|\n MS323|M257)`),\n SONY: /SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533/,\n ASUS: /Asus.*Galaxy|PadFone.*Mobile/,\n NOKIA_LUMIA: /Lumia [0-9]{3,4}/,\n MICROMAX: /Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b/,\n PALM: /PalmSource|Palm/,\n VERTU: /Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature/,\n PANTECH: new RegExp(`PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|\n IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|\n IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|\n CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|\n P2000|P7040|P7000|C790`),\n FLY: /IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250/,\n WIKO: new RegExp(`KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|\n SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|\n CINK KING|CINK PEAX|CINK SLIM|SUBLIM`),\n I_MOBILE: /i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)/,\n SIMVALLEY: /\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b/,\n WOLFGANG: /AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q/,\n ALCATEL: /Alcatel|Mobile; rv:49.0|Mobile; ALCATEL 4052R; rv:48.0/,\n NINTENDO: /Nintendo (3DS|Switch)/,\n AMOI: /Amoi/,\n INQ: /INQ/,\n VITA: /\\bVita\\b/,\n BLACKBERRY: /\\bBlackBerry\\b|\\bBB10\\b|rim[0-9]+/,\n FIREFOX_OS: /\\bFirefox-OS\\b/,\n IPHONE: /\\biPhone\\b/,\n iPod: /\\biPod\\b/,\n ANDROID: /\\bAndroid\\b/,\n WINDOWS_PHONE: /\\bWindows-Phone\\b/,\n GENERIC_PHONE: new RegExp(`Tapatalk|PDA;|SAGEM|\\\\bmmp\\\\b|pocket|\\\\bpsp\\\\b|symbian|Smartphone|smartfon|treo|up.browser|\n up.link|vodafone|\\\\bwap\\\\b|nokia|Nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser`),\n};\nconst TABLETS_RE = {\n iPad: /iPad|iPad.*Mobile/,\n NexusTablet: /Android.*Nexus[\\s]+(7|9|10)/,\n GoogleTablet: /Android.*Pixel C/,\n SamsungTablet: new RegExp(`SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|\n GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|\n SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|\n GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|\n SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|\n GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|\n SHV-E230S|SHW-M180K|SHW-M180L|SM-T865|SM-T290|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|\n SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|\n GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T385M|SM-P585M|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|\n SM-P601|SM-P605|SM-P615|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|\n GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|\n SM-T510|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|\n SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T500|SM-T330|\n SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|\n SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|\n SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|\n SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|\n SM-T719|SM-T725|SM-T813|SM-T819|SM-T580|SM-T590|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|\n SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-P585Y|SM-X200|SM-T970`),\n Kindle: new RegExp(`Kindle|Silk.*Accelerated|Android.*\\\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|\n KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\\\b|Android.*Silk\\/[0-9.]+ like Chrome\\\n /[0-9.]+ (?!Mobile)`),\n SurfaceTablet: /Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)/,\n HPTablet: /HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10/,\n AsusTablet: new RegExp(`^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|\n TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|\n Slider SL101|\\\\bK00F\\\\b|\\\\bK00C\\\\b|\\\\bK00E\\\\b|\\\\bK00L\\\\b|TX201LA|ME176C|ME102A|\\\\bM80TA\\\\b|ME372CL|\n ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\\\bME70C\\\\b|ME581C|\n ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\\\bP027\\\\b|\\\\bP024\\\\b|\\\\bP00C\\\\b`),\n BlackBerryTablet: /PlayBook|RIM Tablet/,\n HTCtablet: /HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410/,\n MotorolaTablet: /xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617/,\n NookTablet: /Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2/,\n AcerTablet: new RegExp(`Android.*; \\\\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|\n W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\\\b|W3-810|\\\\bA3-A10\\\\b|\\\\bA3-A11\\\\b|\n \\\\bA3-A20\\\\b|\\\\bA3-A30`),\n ToshibaTablet: /Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO/,\n LGTablet: /\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b/,\n FujitsuTablet: /Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b/,\n PrestigioTablet: new RegExp(`PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|\n PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|\n PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|\n PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|\n PMT5887|PMT5001|PMT5002`),\n LenovoTablet: new RegExp(`Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|\n YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|\n B8000|B8080)(-|)(FL|F|HV|H|)|TB-X606F|TB-X103F|TB-X304F|TB-X304L|TB-X704F|TB-8703F|Tab2A7-10F|TB2-X30L|TB-8504F`),\n DellTablet: /Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7/,\n YarvikTablet: new RegExp(`Android.*\\\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|\n TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|\n TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|\n TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|\n TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\\\b`),\n MedionTablet: /Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB/,\n ArnovaTablet: /97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2/,\n IntensoTablet: /INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004/,\n IRUTablet: /M702pro/,\n MegafonTablet: /MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b/,\n EbodaTablet: /E-Boda (Supreme|Impresspeed|Izzycomm|Essential)/,\n AllViewTablet: /Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)/,\n ArchosTablet: new RegExp(`\\\\b(101G9|80G9|A101IT)\\\\b|Qilive 97R|Archos5|\\\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10|\n Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\\\b`),\n AinolTablet: /NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark/,\n NokiaLumiaTablet: /Lumia 2520/,\n SonyTablet: new RegExp(`Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|\n SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|\n EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|\n SGP612|SGP712`),\n PhilipsTablet: /\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b/,\n CubeTablet: /Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT/,\n CobyTablet: new RegExp(`MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|\n MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010`),\n MIDTablet: new RegExp(`M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|\n MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|\n MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10`),\n MSITablet: new RegExp(`MSI \\\\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|\n Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\\\b`),\n SMiTTablet: /Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)/,\n RockChipTablet: /Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A/,\n FlyTablet: /IQ310|Fly Vision/,\n bqTablet: new RegExp(`Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|\n Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))|Maxwell.*Lite|Maxwell.*Plus`),\n HuaweiTablet: new RegExp(`MediaPad|MediaPad 7 Youth|MediaPad T3 10|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|\n S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-W09|AGS-L09`),\n NecTablet: /\\bN-06D|\\bN-08D/,\n PantechTablet: /Pantech.*P4100/,\n BronchoTablet: /Broncho.*(N701|N708|N802|a710)/,\n VersusTablet: /TOUCHPAD.*[78910]|\\bTOUCHTAB\\b/,\n ZyncTablet: /z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900/,\n PositivoTablet: /TB07STA|TB10STA|TB07FTA|TB10FTA/,\n NabiTablet: /Android.*\\bNabi/,\n KoboTablet: /Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build/,\n DanewTablet: /DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b/,\n TexetTablet: new RegExp(`NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|\n TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|\n TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|\n TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|\n TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|\n TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|\n TB-436|TB-416|TB-146SE|TB-126SE`),\n PlaystationTablet: /Playstation.*(Portable|Vita)/,\n TrekstorTablet: /ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab/,\n PyleAudioTablet: /\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b/,\n AdvanTablet: new RegExp(`Android.* \\\\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|\n T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\\\b`),\n DanyTechTablet: `Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|\n Genius TAB GII|Genius TAB GIII|Genius Tab S1`,\n GalapadTablet: /Android.*\\bG1\\b(?!\\))/,\n MicromaxTablet: /Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b/,\n KarbonnTablet: /Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b/,\n AllFineTablet: /Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide/,\n PROSCANTablet: new RegExp(`\\\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|\n PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|\n PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|\n PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\\\b`),\n YONESTablet: /BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026/,\n ChangJiaTablet: new RegExp(`TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|\n TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|\n TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|\n TPC10111|TPC10203|TPC10205|TPC10503`),\n GUTablet: /TX-A1301|TX-M9002|Q702|kf026/,\n PointOfViewTablet: new RegExp(`TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|\n TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|\n TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|\n TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10`),\n OvermaxTablet: new RegExp(`OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|\n MagicTab|Stream|TB-08|TB-09)|Qualcore 1027`),\n HCLTablet: /HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync/,\n DPSTablet: /DPS Dream 9|DPS Dual 7/,\n VistureTablet: /V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10/,\n CrestaTablet: /CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989/,\n MediatekTablet: /\\bMT8125|MT8389|MT8135|MT8377\\b/,\n ConcordeTablet: /Concorde([ ]+)?Tab|ConCorde ReadMan/,\n GoCleverTablet: new RegExp(`GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|\n TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|\n GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|\n TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|\n TAB R104|TAB R83.3|TAB A1042`),\n ModecomTablet: new RegExp(`FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|\n FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|\n FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003`),\n VoninoTablet: new RegExp(`\\\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|\n Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|\n Primus[ _]?QS|Android.*\\\\bQ8\\\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\\\b`),\n ECSTablet: /V07OT2|TM105A|S10OT1|TR10CS1/,\n StorexTablet: /eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab/,\n VodafoneTablet: /SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497/,\n EssentielBTablet: /Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2/,\n RossMoorTablet: /RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711/,\n iMobileTablet: /i-mobile i-note/,\n TolinoTablet: /tolino tab [0-9.]+|tolino shine/,\n AudioSonicTablet: /\\bC-22Q|T7-QC|T-17B|T-17P\\b/,\n AMPETablet: /Android.* A78 /,\n SkkTablet: /Android.* (SKYPAD|PHOENIX|CYCLOPS)/,\n TecnoTablet: /TECNO P9|TECNO DP8D/,\n JXDTablet: new RegExp(`Android.* \\\\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|\n S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|\n P1000|P300|S18|S6600|S9100)\\\\b`),\n iJoyTablet: new RegExp(`Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|\n Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|\n Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|\n Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|\n Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)`),\n FX2Tablet: /FX2 PAD7|FX2 PAD10/,\n XoroTablet: new RegExp(`KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|\n PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|\n PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|\n TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151`),\n ViewsonicTablet: /ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a/,\n VerizonTablet: /QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1/,\n OdysTablet: /LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10/,\n CaptivaTablet: /CAPTIVA PAD/,\n IconbitTablet: new RegExp(`NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|\n NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S`),\n TeclastTablet: new RegExp(`T98 4G|\\\\bP80\\\\b|\\\\bX90HD\\\\b|X98 Air|X98 Air 3G|\\\\bX89\\\\b|P80 3G|\\\\bX80h\\\\b|P98 Air|\n \\\\bX89HD\\\\b|P98 3G|\\\\bP90HD\\\\b|P89 3G|X98 3G|\\\\bP70h\\\\b|P79HD 3G|G18d 3G|\\\\bP79HD\\\\b|\\\\bP89s\\\\b|\\\\bA88\\\\b|\n \\\\bP10HD\\\\b|\\\\bP19HD\\\\b|G18 3G|\\\\bP78HD\\\\b|\\\\bA78\\\\b|\\\\bP75\\\\b|G17s 3G|G17h 3G|\\\\bP85t\\\\b|\\\\bP90\\\\b|\n \\\\bP11\\\\b|\\\\bP98t\\\\b|\\\\bP98HD\\\\b|\\\\bG18d\\\\b|\\\\bP85s\\\\b|\\\\bP11HD\\\\b|\\\\bP88s\\\\b|\\\\bA80HD\\\\b|\\\\bA80se\\\\b|\n \\\\bA10h\\\\b|\\\\bP89\\\\b|\\\\bP78s\\\\b|\\\\bG18\\\\b|\\\\bP85\\\\b|\\\\bA70h\\\\b|\\\\bA70\\\\b|\\\\bG17\\\\b|\\\\bP18\\\\b|\\\\bA80s\\\\b|\n \\\\bA11s\\\\b|\\\\bP88HD\\\\b|\\\\bA80h\\\\b|\\\\bP76s\\\\b|\\\\bP76h\\\\b|\\\\bP98\\\\b|\\\\bA10HD\\\\b|\\\\bP78\\\\b|\\\\bP88\\\\b|\\\\bA11\\\\b|\n \\\\bA10t\\\\b|\\\\bP76a\\\\b|\\\\bP76t\\\\b|\\\\bP76e\\\\b|\\\\bP85HD\\\\b|\\\\bP85a\\\\b|\\\\bP86\\\\b|\\\\bP75HD\\\\b|\\\\bP76v\\\\b|\\\\bA12\\\\b|\n \\\\bP75a\\\\b|\\\\bA15\\\\b|\\\\bP76Ti\\\\b|\\\\bP81HD\\\\b|\\\\bA10\\\\b|\\\\bT760VE\\\\b|\\\\bT720HD\\\\b|\\\\bP76\\\\b|\\\\bP73\\\\b|\\\\bP71\\\\b|\n \\\\bP72\\\\b|\\\\bT720SE\\\\b|\\\\bC520Ti\\\\b|\\\\bT760\\\\b|\\\\bT720VE\\\\b|T720-3GE|T720-WiFi`),\n OndaTablet: new RegExp(`\\\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|\n V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|\n V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|\n Vi40)\\\\b[\\s]+|V10 \\\\b4G\\\\b`),\n JaytechTablet: /TPC-PA762/,\n BlaupunktTablet: /Endeavour 800NG|Endeavour 1010/,\n DigmaTablet: /\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b/,\n EvolioTablet: /ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b/,\n LavaTablet: /QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b/,\n AocTablet: /MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712/,\n MpmanTablet: new RegExp(`MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\n \\\\bMPG7\\\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|\n MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010`),\n CelkonTablet: /CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b/,\n WolderTablet: new RegExp(`miTab \\\\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|\n POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|\n FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\\\b`),\n MediacomTablet: 'M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA',\n MiTablet: /\\bMI PAD\\b|\\bHM NOTE 1W\\b/,\n NibiruTablet: /Nibiru M1|Nibiru Jupiter One/,\n NexoTablet: /NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI/,\n LeaderTablet: new RegExp(`TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|\n TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100`),\n UbislateTablet: /UbiSlate[\\s]?7C/,\n PocketBookTablet: /Pocketbook/,\n KocasoTablet: /\\b(TB-1207)\\b/,\n HisenseTablet: /\\b(F5281|E2371)\\b/,\n Hudl: /Hudl HT7S3|Hudl 2/,\n TelstraTablet: /T-Hub2/,\n Honeywell: /RT10A/,\n GenericTablet: new RegExp(`Android.*\\\\b97D\\\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\\\bA7EB\\\\b|CatNova8|\n A1_07|CT704|CT1002|\\\\bM721\\\\b|rk30sdk|\\\\bEVOTAB\\\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|\n Tablet-PC-4|Tagi Tab|\\\\bM6pro\\\\b|CT1020W|arc 10HD|\\\\bTP750\\\\b|\\\\bQTAQZ3\\\\b|WVT101|TM1088|KT107`),\n};\nconst DEVICES = {\n BLACKBERRY: 'Blackberry',\n FIREFOX_OS: 'Firefox-OS',\n CHROME_BOOK: 'Chrome-Book',\n WINDOWS_PHONE: 'Windows-Phone',\n VITA: 'Vita',\n PS4: 'PS4',\n MAC: 'Macintosh',\n CHROMECAST: 'Chromecast',\n APPLE_TV: 'Apple-TV',\n GOOGLE_TV: 'Google-TV',\n ANDROID: 'Android',\n Tesla: 'Tesla',\n iPad: 'iPad',\n IPHONE: 'iPhone',\n iPod: 'iPod',\n UNKNOWN: GENERAL.UKNOWN,\n HTC: 'HTC',\n NEXUS_PHONE: 'Nexus Phone',\n NexusTablet: 'Nexus Tablet',\n DELL: 'Dell',\n MOTOROLA: 'Motorola',\n SAMSUNG: 'Samsung',\n LG: 'LG',\n SONY: 'Sony',\n ASUS: 'Asus',\n NOKIA_LUMIA: 'Nokia Lumia',\n MICROMAX: 'Micromax',\n PALM: 'Palm',\n VERTU: 'Vertu',\n PANTECH: 'PANTECH',\n FLY: 'Fly',\n WIKO: `WIKO`,\n I_MOBILE: 'i-mobile',\n SIMVALLEY: 'Simvalley',\n WOLFGANG: 'Wolfgang',\n ALCATEL: 'Alcatel',\n HONEYWELL: 'Honeywell',\n NINTENDO: 'Nintendo',\n AMOI: 'Amoi',\n INQ: 'INQ',\n GENERIC_PHONE: 'Generic Phone',\n MI_SE_9: 'Mi SE 9',\n};\nconst DESKTOP_DEVICES = [\n DEVICES.PS4,\n DEVICES.CHROME_BOOK,\n DEVICES.MAC,\n DEVICES.DELL,\n DEVICES.ASUS,\n DEVICES.UNKNOWN,\n];\nconst OS = {\n WINDOWS: 'Windows',\n MAC: 'Mac',\n IOS: 'iOS',\n ANDROID: 'Android',\n LINUX: 'Linux',\n UNIX: 'Unix',\n FIREFOX_OS: 'Firefox-OS',\n CHROME_OS: 'Chrome-OS',\n WINDOWS_PHONE: 'Windows-Phone',\n UNKNOWN: GENERAL.UKNOWN,\n};\nconst OS_VERSIONS = {\n WINDOWS_3_11: 'windows-3-11',\n WINDOWS_95: 'windows-95',\n WINDOWS_ME: 'windows-me',\n WINDOWS_98: 'windows-98',\n WINDOWS_CE: 'windows-ce',\n WINDOWS_2000: 'windows-2000',\n WINDOWS_XP: 'windows-xp',\n WINDOWS_SERVER_2003: 'windows-server-2003',\n WINDOWS_VISTA: 'windows-vista',\n WINDOWS_7: 'windows-7',\n WINDOWS_8_1: 'windows-8-1',\n WINDOWS_8: 'windows-8',\n WINDOWS_10: 'windows-10',\n WINDOWS_PHONE_7_5: 'windows-phone-7-5',\n WINDOWS_PHONE_8_1: 'windows-phone-8-1',\n WINDOWS_PHONE_10: 'windows-phone-10',\n WINDOWS_NT_4_0: 'windows-nt-4-0',\n MACOSX_11_0: 'mac-os-x-11-0',\n MACOSX_16: 'mac-os-x-16',\n MACOSX_15: 'mac-os-x-15',\n MACOSX_14: 'mac-os-x-14',\n MACOSX_13: 'mac-os-x-13',\n MACOSX_12: 'mac-os-x-12',\n MACOSX_11: 'mac-os-x-11',\n MACOSX_10: 'mac-os-x-10',\n MACOSX_9: 'mac-os-x-9',\n MACOSX_8: 'mac-os-x-8',\n MACOSX_7: 'mac-os-x-7',\n MACOSX_6: 'mac-os-x-6',\n MACOSX_5: 'mac-os-x-5',\n MACOSX_4: 'mac-os-x-4',\n MACOSX_3: 'mac-os-x-3',\n MACOSX_2: 'mac-os-x-2',\n MACOSX: 'mac-os-x',\n iOS: 'iOS',\n ANDROID_9: 'android-9',\n UNKNOWN: GENERAL.UKNOWN.toLowerCase(),\n};\nconst OS_RE = {\n WINDOWS: {\n and: [{ or: [/\\bWindows|(Win\\d\\d)\\b/, /\\bWin 9x\\b/] }, { not: /\\bWindows Phone\\b/ }],\n },\n MAC: {\n and: [/\\bMac OS\\b/, { not: { or: [/\\biPhone\\b/, /\\biPad\\b/, /\\biPod\\b/, /\\bWindows Phone\\b/] } }],\n },\n IOS: {\n and: [{ or: [/\\biPad\\b/, /\\biPhone\\b/, /\\biPod\\b/] }, { not: /\\bWindows Phone\\b/ }],\n },\n ANDROID: { and: [/\\bAndroid\\b/, { not: /\\bWindows Phone\\b/ }] },\n LINUX: /\\bLinux\\b/,\n UNIX: /\\bUNIX\\b/,\n FIREFOX_OS: { and: [/\\bFirefox\\b/, /Mobile\\b/] },\n CHROME_OS: /\\bCrOS\\b/,\n WINDOWS_PHONE: { or: [/\\bIEMobile\\b/, /\\bWindows Phone\\b/] },\n PS4: /\\bMozilla\\/5.0 \\(PlayStation 4\\b/,\n VITA: /\\bMozilla\\/5.0 \\(Play(S|s)tation Vita\\b/,\n};\nconst BROWSERS_RE = {\n CHROME: {\n and: [\n { or: [/\\bChrome\\b/, /\\bCriOS\\b/, /\\bHeadlessChrome\\b/] },\n {\n not: {\n or: [/\\bOPR\\b/, /\\bEdg(e|A|iOS)\\b/, /\\bEdg\\/\\b/, /\\bSamsungBrowser\\b/, /\\bUCBrowser\\b/],\n },\n },\n ],\n },\n FIREFOX: { or: [/\\bFirefox\\b/, /\\bFxiOS\\b/] },\n SAFARI: {\n and: [\n /^((?!CriOS).)*\\Safari\\b.*$/,\n {\n not: {\n or: [/\\bOPR\\b/, /\\bEdg(e|A|iOS)\\b/, /\\bEdg\\/\\b/, /\\bWindows Phone\\b/, /\\bSamsungBrowser\\b/, /\\bUCBrowser\\b/],\n },\n },\n ],\n },\n OPERA: { or: [/Opera\\b/, /\\bOPR\\b/] },\n IE: {\n or: [/\\bMSIE\\b/, /\\bTrident\\b/, /^Mozilla\\/5\\.0 \\(Windows NT 10\\.0; Win64; x64\\)$/],\n },\n MS_EDGE: { or: [/\\bEdg(e|A|iOS)\\b/] },\n MS_EDGE_CHROMIUM: /\\bEdg\\/\\b/,\n PS4: /\\bMozilla\\/5.0 \\(PlayStation 4\\b/,\n VITA: /\\bMozilla\\/5.0 \\(Play(S|s)tation Vita\\b/,\n FB_MESSANGER: /\\bFBAN\\/MessengerForiOS\\b/,\n SAMSUNG: /\\bSamsungBrowser\\b/,\n UCBROWSER: /\\bUCBrowser\\b/,\n};\nconst DEVICES_RE = {\n ...MOBILES_RE,\n ...TABLETS_RE,\n ...OS_RE,\n FIREFOX_OS: { and: [/\\bFirefox\\b/, /\\bMobile\\b/] },\n CHROME_BOOK: /\\bCrOS\\b/,\n PS4: /\\bMozilla\\/5.0 \\(PlayStation 4\\b/,\n CHROMECAST: /\\bCrKey\\b/,\n APPLE_TV: /^iTunes-AppleTV\\/4.1$/,\n GOOGLE_TV: /\\bGoogleTV\\b/,\n Tesla: /Tesla\\/([0-9]{4}.[0-9]{1,2}.?[0-9]{0,2}.?[0-9]{0,2})-(.{7})/,\n MI_SE_9: /\\bXiaomi\\b/,\n MAC: {\n and: [/\\bMac OS\\b/, { not: { or: [/\\biPhone\\b/, /\\biPad\\b/, /\\biPod\\b/, /\\bWindows Phone\\b/] } }],\n },\n};\nconst OS_VERSIONS_RE_MAP = {\n WINDOWS_3_11: /Win16/,\n WINDOWS_95: /(Windows 95|Win95|Windows_95)/,\n WINDOWS_ME: /(Win 9x 4.90|Windows ME)/,\n WINDOWS_98: /(Windows 98|Win98)/,\n WINDOWS_CE: /Windows CE/,\n WINDOWS_2000: /(Windows NT 5.0|Windows 2000)/,\n WINDOWS_XP: /(Windows NT 5.1|Windows XP)/,\n WINDOWS_SERVER_2003: /Windows NT 5.2/,\n WINDOWS_VISTA: /Windows NT 6.0/,\n WINDOWS_7: /(Windows 7|Windows NT 6.1)/,\n WINDOWS_8_1: /(Windows 8.1|Windows NT 6.3)/,\n WINDOWS_8: /(Windows 8|Windows NT 6.2)/,\n WINDOWS_10: /(Windows NT 10.0)/,\n WINDOWS_PHONE_7_5: /(Windows Phone OS 7.5)/,\n WINDOWS_PHONE_8_1: /(Windows Phone 8.1)/,\n WINDOWS_PHONE_10: /(Windows Phone 10)/,\n WINDOWS_NT_4_0: {\n and: [/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/, { not: /Windows NT 10.0/ }],\n },\n MACOSX: /(MAC OS X\\s*[^ 0-9])/,\n MACOSX_3: /(Darwin 10.3|Mac OS X 10.3)/,\n MACOSX_4: /(Darwin 10.4|Mac OS X 10.4)/,\n MACOSX_5: /(Mac OS X 10.5)/,\n MACOSX_6: /(Mac OS X 10.6)/,\n MACOSX_7: /(Mac OS X 10.7)/,\n MACOSX_8: /(Mac OS X 10.8)/,\n MACOSX_9: /(Mac OS X 10.9)/,\n MACOSX_10: /(Mac OS X 10.10)/,\n MACOSX_11: /(Mac OS X 10.11)/,\n MACOSX_12: /(Mac OS X 10.12)/,\n MACOSX_13: /(Mac OS X 10.13)/,\n MACOSX_14: /(Mac OS X 10.14)/,\n MACOSX_15: /(Mac OS X 10.15)/,\n MACOSX_16: /(Mac OS X 10.16)/,\n MACOSX_11_0: {\n or: [/11_0 like Mac OS X/, /Mac OS X 11/],\n },\n iOS: /(iPhone OS\\s*[0-9_]+)/,\n ANDROID_9: /(Android 9)/,\n};\nconst BROWSER_VERSIONS_RE_MAP = {\n CHROME: [/\\bChrome\\/([\\d\\.]+)\\b/, /\\bCriOS\\/([\\d\\.]+)\\b/, /\\bHeadlessChrome\\/([\\d\\.]+)\\b/],\n FIREFOX: [/\\bFirefox\\/([\\d\\.]+)\\b/, /\\bFxiOS\\/([\\d\\.]+)\\b/],\n SAFARI: [/\\bVersion\\/([\\d\\.]+)\\b/, /\\bSafari\\/([\\d\\.]+)\\b/],\n OPERA: [/\\bVersion\\/([\\d\\.]+)\\b/, /\\bOPR\\/([\\d\\.]+)\\b/],\n IE: [/\\bMSIE ([\\d\\.]+\\w?)\\b/, /\\brv:([\\d\\.]+\\w?)\\b/],\n MS_EDGE: /\\bEdg(?:e|A|iOS)\\/([\\d\\.]+)\\b/,\n MS_EDGE_CHROMIUM: /\\bEdg\\/([\\d\\.]+)\\b/,\n SAMSUNG: /\\bSamsungBrowser\\/([\\d\\.]+)\\b/,\n UCBROWSER: /\\bUCBrowser\\/([\\d\\.]+)\\b/,\n};\nconst OS_VERSIONS_RE = Object.keys(OS_VERSIONS_RE_MAP).reduce((obj, key) => {\n obj[key] = OS_VERSIONS_RE_MAP[key];\n return obj;\n}, {});\nconst BROWSER_VERSIONS_RE = Object.keys(BROWSER_VERSIONS_RE_MAP).reduce((obj, key) => {\n obj[BROWSERS[key]] = BROWSER_VERSIONS_RE_MAP[key];\n return obj;\n}, {});\n\nvar Constants = /*#__PURE__*/Object.freeze({\n __proto__: null,\n BROWSERS: BROWSERS,\n BROWSERS_RE: BROWSERS_RE,\n BROWSER_VERSIONS_RE: BROWSER_VERSIONS_RE,\n BROWSER_VERSIONS_RE_MAP: BROWSER_VERSIONS_RE_MAP,\n DESKTOP_DEVICES: DESKTOP_DEVICES,\n DEVICES: DEVICES,\n DEVICES_RE: DEVICES_RE,\n GENERAL: GENERAL,\n MOBILES_RE: MOBILES_RE,\n OS: OS,\n OS_RE: OS_RE,\n OS_VERSIONS: OS_VERSIONS,\n OS_VERSIONS_RE: OS_VERSIONS_RE,\n OS_VERSIONS_RE_MAP: OS_VERSIONS_RE_MAP,\n TABLETS_RE: TABLETS_RE\n});\n\n/**\n * Created by ahsanayaz on 08/11/2016.\n */\nclass ReTree {\n constructor() { }\n test(str, regex) {\n if (typeof regex === 'string') {\n regex = new RegExp(regex);\n }\n if (regex instanceof RegExp) {\n return regex.test(str);\n }\n else if (regex && Array.isArray(regex.and)) {\n return regex.and.every((item) => {\n return this.test(str, item);\n });\n }\n else if (regex && Array.isArray(regex.or)) {\n return regex.or.some((item) => {\n return this.test(str, item);\n });\n }\n else if (regex && regex.not) {\n return !this.test(str, regex.not);\n }\n else {\n return false;\n }\n }\n exec(str, regex) {\n if (typeof regex === 'string') {\n regex = new RegExp(regex);\n }\n if (regex instanceof RegExp) {\n return regex.exec(str);\n }\n else if (regex && Array.isArray(regex)) {\n return regex.reduce((res, item) => {\n return !!res ? res : this.exec(str, item);\n }, null);\n }\n else {\n return null;\n }\n }\n}\n\n// tslint:disable: variable-name\n/**\n * Created by ahsanayaz on 08/11/2016.\n */\nvar DeviceType;\n(function (DeviceType) {\n DeviceType[\"Mobile\"] = \"mobile\";\n DeviceType[\"Tablet\"] = \"tablet\";\n DeviceType[\"Desktop\"] = \"desktop\";\n DeviceType[\"Unknown\"] = \"unknown\";\n})(DeviceType || (DeviceType = {}));\nvar OrientationType;\n(function (OrientationType) {\n OrientationType[\"Portrait\"] = \"portrait\";\n OrientationType[\"Landscape\"] = \"landscape\";\n})(OrientationType || (OrientationType = {}));\nconst iPad = 'iPad';\nclass DeviceDetectorService {\n constructor(platformId) {\n this.platformId = platformId;\n this.ua = '';\n this.userAgent = '';\n this.os = '';\n this.browser = '';\n this.device = '';\n this.os_version = '';\n this.browser_version = '';\n this.reTree = new ReTree();\n this.deviceType = '';\n this.orientation = '';\n if (isPlatformBrowser(this.platformId) && typeof window !== 'undefined') {\n this.userAgent = window.navigator.userAgent;\n }\n this.setDeviceInfo(this.userAgent);\n }\n /**\n * @author Ahsan Ayaz\n * @desc Sets the initial value of the device when the service is initiated.\n * This value is later accessible for usage\n */\n setDeviceInfo(ua = this.userAgent) {\n if (ua !== this.userAgent) {\n this.userAgent = ua;\n }\n const mappings = [\n { const: 'OS', prop: 'os' },\n { const: 'BROWSERS', prop: 'browser' },\n { const: 'DEVICES', prop: 'device' },\n { const: 'OS_VERSIONS', prop: 'os_version' },\n ];\n mappings.forEach(mapping => {\n this[mapping.prop] = Object.keys(Constants[mapping.const]).reduce((obj, item) => {\n if (Constants[mapping.const][item] === 'device') {\n // hack for iOS 13 Tablet\n if (isPlatformBrowser(this.platformId) &&\n (!!this.reTree.test(this.userAgent, TABLETS_RE[iPad]) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1))) {\n obj[Constants[mapping.const][item]] = iPad;\n return Object;\n }\n }\n obj[Constants[mapping.const][item]] = this.reTree.test(ua, Constants[`${mapping.const}_RE`][item]);\n return obj;\n }, {});\n });\n mappings.forEach(mapping => {\n this[mapping.prop] = Object.keys(Constants[mapping.const])\n .map(key => {\n return Constants[mapping.const][key];\n })\n .reduce((previousValue, currentValue) => {\n if (mapping.prop === 'device' && previousValue === Constants[mapping.const].ANDROID) {\n // if we have the actual device found, instead of 'Android', return the actual device\n return this[mapping.prop][currentValue] ? currentValue : previousValue;\n }\n else {\n return previousValue === Constants[mapping.const].UNKNOWN && this[mapping.prop][currentValue]\n ? currentValue\n : previousValue;\n }\n }, Constants[mapping.const].UNKNOWN);\n });\n this.browser_version = '0';\n if (this.browser !== BROWSERS.UNKNOWN) {\n const re = BROWSER_VERSIONS_RE[this.browser];\n const res = this.reTree.exec(ua, re);\n if (!!res) {\n this.browser_version = res[1];\n }\n }\n if (typeof window !== 'undefined' && window.matchMedia) {\n this.orientation = window.matchMedia('(orientation: landscape)').matches\n ? OrientationType.Landscape\n : OrientationType.Portrait;\n }\n else {\n this.orientation = GENERAL.UKNOWN;\n }\n this.deviceType = this.isTablet()\n ? DeviceType.Tablet\n : this.isMobile(this.userAgent)\n ? DeviceType.Mobile\n : this.isDesktop(this.userAgent)\n ? DeviceType.Desktop\n : DeviceType.Unknown;\n }\n /**\n * @author Ahsan Ayaz\n * @desc Returns the device information\n * @returns the device information object.\n */\n getDeviceInfo() {\n const deviceInfo = {\n userAgent: this.userAgent,\n os: this.os,\n browser: this.browser,\n device: this.device,\n os_version: this.os_version,\n browser_version: this.browser_version,\n deviceType: this.deviceType,\n orientation: this.orientation,\n };\n return deviceInfo;\n }\n /**\n * @author Ahsan Ayaz\n * @desc Compares the current device info with the mobile devices to check\n * if the current device is a mobile and also check current device is tablet so it will return false.\n * @returns whether the current device is a mobile\n */\n isMobile(userAgent = this.userAgent) {\n if (this.isTablet(userAgent)) {\n return false;\n }\n const match = Object.keys(MOBILES_RE).find(mobile => {\n return this.reTree.test(userAgent, MOBILES_RE[mobile]);\n });\n return !!match;\n }\n /**\n * @author Ahsan Ayaz\n * @desc Compares the current device info with the tablet devices to check\n * if the current device is a tablet.\n * @returns whether the current device is a tablet\n */\n isTablet(userAgent = this.userAgent) {\n if (isPlatformBrowser(this.platformId) &&\n (!!this.reTree.test(this.userAgent, TABLETS_RE[iPad]) ||\n (typeof navigator !== 'undefined' && navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1))) {\n return true;\n }\n const match = Object.keys(TABLETS_RE).find(mobile => {\n return !!this.reTree.test(userAgent, TABLETS_RE[mobile]);\n });\n return !!match;\n }\n /**\n * @author Ahsan Ayaz\n * @desc Compares the current device info with the desktop devices to check\n * if the current device is a desktop device.\n * @returns whether the current device is a desktop device\n */\n isDesktop(userAgent = this.userAgent) {\n if (this.device === DEVICES.UNKNOWN) {\n if (this.isMobile(userAgent) || this.isTablet(userAgent)) {\n return false;\n }\n }\n return DESKTOP_DEVICES.indexOf(this.device) > -1;\n }\n static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.3\", ngImport: i0, type: DeviceDetectorService, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.3\", ngImport: i0, type: DeviceDetectorService, providedIn: 'root' }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.3\", ngImport: i0, type: DeviceDetectorService, decorators: [{\n type: Injectable,\n args: [{\n providedIn: 'root',\n }]\n }], ctorParameters: () => [{ type: undefined, decorators: [{\n type: Inject,\n args: [PLATFORM_ID]\n }] }] });\n\n/*\n * Public API Surface of ngx-device-detector\n */\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { BROWSERS, BROWSERS_RE, BROWSER_VERSIONS_RE, BROWSER_VERSIONS_RE_MAP, DESKTOP_DEVICES, DEVICES, DEVICES_RE, DeviceDetectorService, DeviceType, GENERAL, MOBILES_RE, OS, OS_RE, OS_VERSIONS, OS_VERSIONS_RE, OS_VERSIONS_RE_MAP, OrientationType, ReTree, TABLETS_RE };\n","import { Component, Injectable, } from '@angular/core';\nimport { DeviceDetectorService } from 'ngx-device-detector';\n\n@Injectable()\nexport class UniversalDeviceDetectorService {\n isMobile = false;\n isTablet = false;\n isDesktopDevice = false;\n deviceInfo = null;\n os = null;\n\n constructor(private deviceService: DeviceDetectorService) {\n this.detectDevice();\n }\n\n detectDevice() {\n this.deviceInfo = this.deviceService.getDeviceInfo();\n this.isMobile = this.deviceService.isMobile();\n this.isTablet = this.deviceService.isTablet();\n this.isDesktopDevice = this.deviceService.isDesktop(); \n console.log(this.deviceInfo);\n // console.log(isMobile); // returns if the device is a mobile device (android / iPhone / windows-phone etc)\n // console.log(isTablet); // returns if the device us a tablet (iPad etc)\n // console.log(isDesktopDevice); // returns if the app is running on a Desktop browser.\n // console.log(\"os: \"+this.deviceService.os);\n // console.log(\"browser: \"+this.deviceService.browser);\n // console.log(\"device: \"+this.deviceService.device);\n // console.log(\"os_version: \"+this.deviceService.os_version);\n }\n\n getOS(){\n this.os = this.deviceService.os;\n return this.os;\n }\n}","\n\n\n
\n
\n
\n \n \n \n \n \n \n
\n
\n
\n

Hinweis

\n
\n
\n
\n

Die Anwendung ist nicht für das Smartphone geeignet.

\n

Bitte verwenden Sie daher Ihren Desktop-PC, Laptop oder Tablet.

\n
\n
\n
\n
\n
\n","import { Component, isDevMode, OnInit, Renderer2 } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport { environment } from '../../environments/environment';\nimport { UniversalDeviceDetectorService } from '../services/device-detector.service';\nimport { IconRegistryService } from '../services/icon-registry.service';\nimport { UrlService } from '../services/url.service';\n\ninterface EnvironmentSetup {\n name: string;\n title: string;\n theme: string;\n favoriteIconPath: string;\n logoName: string;\n logoPath: string;\n}\n\nconst FINGERHAUS: EnvironmentSetup = {\n name: 'fingerhaus',\n title: 'FingerHauszeit | Anwendung',\n theme: 'fingerhaus-theme',\n favoriteIconPath: '../../assets/icons/favicon-fingerhaus.ico',\n logoName: 'fingerhaus-logo',\n logoPath: 'assets/icons/fingerhaus-logo.svg',\n};\n\nconst PORTER: EnvironmentSetup = {\n name: 'porter',\n title: 'PORTER | Anwendung',\n theme: 'porter-theme',\n favoriteIconPath: '../../assets/icons/favicon.ico',\n logoName: 'porter-logo',\n logoPath: 'assets/icons/porter-logo.svg',\n};\n\n@Component({\n selector: 'app-root',\n templateUrl: './app.component.html',\n styleUrls: ['./app.component.scss'],\n standalone: false\n})\nexport class AppComponent implements OnInit {\n isMobile = false;\n favIcon: HTMLLinkElement = document.querySelector('#favicon');\n customerSystem: String;\n isServiceRoute = false;\n\n constructor(\n private iconRegistry: IconRegistryService,\n private deviceService: UniversalDeviceDetectorService,\n private renderer: Renderer2,\n private urlService: UrlService,\n private titleService: Title\n ) {\n this.registerLogos();\n }\n\n async ngOnInit() {\n this.recognizeDomain();\n this.handleMobile();\n this.logInformation();\n this.handleServiceRoute();\n }\n\n private recognizeDomain() {\n this.urlContainsFingerhaus()\n ? this.setupFingerhausEnvironment()\n : this.setupPorterEnvironment();\n this.updateCustomerSystem();\n }\n\n private urlContainsFingerhaus(): boolean {\n return this.urlService.urlContains(FINGERHAUS.name);\n }\n\n private setupFingerhausEnvironment() {\n environment.customerSystem = FINGERHAUS.name;\n document.documentElement.classList.remove(PORTER.theme);\n document.documentElement.classList.add(FINGERHAUS.theme);\n this.favIcon.href = FINGERHAUS.favoriteIconPath;\n this.titleService.setTitle(FINGERHAUS.title);\n }\n\n private setupPorterEnvironment() {\n environment.customerSystem = PORTER.name;\n document.documentElement.classList.remove(FINGERHAUS.theme);\n document.documentElement.classList.add(PORTER.theme);\n this.favIcon.href = PORTER.favoriteIconPath;\n this.titleService.setTitle(PORTER.title);\n }\n\n private updateCustomerSystem() {\n this.customerSystem = environment.customerSystem;\n }\n\n private handleMobile() {\n this.updateIsMobile();\n this.initializeWindowSizeListener();\n }\n\n private handleServiceRoute() {\n this.isServiceRoute =\n this.urlService.urlContains('service') && this.urlService.urlContains('authentication');\n }\n\n // TODO: Remove when there is a mobile version\n private updateIsMobile() {\n this.isMobile = window.innerWidth < 767 || this.deviceService.isMobile; // || window.innerHeight < 800;\n }\n\n private initializeWindowSizeListener() {\n this.renderer.listen(window, 'resize', () => this.updateIsMobile());\n }\n\n private logInformation() {\n this.logUrl();\n this.logDevelopmentMode();\n this.logEnvironmentSystem();\n this.logCustomerSystem();\n this.logDocument();\n }\n\n private logUrl() {\n this.urlService.logUrl();\n }\n\n private logDevelopmentMode() {\n if (isDevMode()) {\n console.log('Development Mode: Development');\n } else {\n console.log('Development Mode: Production');\n }\n }\n\n private logEnvironmentSystem() {\n switch (environment.envSystem) {\n case 'Development':\n console.log('Environment System: Development');\n console.log('API Url:', environment.apiUrl);\n break;\n case 'Staging':\n console.log('Environment System: Staging');\n console.log('API Url:', environment.apiUrl);\n break;\n case 'Production':\n console.log('Environment System: Production');\n console.log('API Url:', environment.apiUrl);\n break;\n default:\n console.log('Environment System: Undefined');\n console.log('API Url:', environment.apiUrl);\n break;\n }\n }\n\n private logCustomerSystem() {\n console.log('Environment CustomerSystem: ', environment.customerSystem);\n }\n\n private logDocument() {\n console.log('Document: ', document.documentElement.classList);\n }\n\n private registerLogos() {\n this.registerPorterLogo();\n this.registerFingerhausLogo();\n }\n\n private registerFingerhausLogo() {\n this.iconRegistry.register(FINGERHAUS.logoName, FINGERHAUS.logoPath);\n }\n\n private registerPorterLogo() {\n this.iconRegistry.register(PORTER.logoName, PORTER.logoPath);\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport { Component, Inject, OnInit } from '@angular/core';\nimport { IconRegistryService } from '../../services/icon-registry.service';\nimport { VersionService } from '../../services/version.service';\n\n@Component({\n selector: 'app-download',\n templateUrl: './download.component.html',\n styleUrls: ['./download.component.scss'],\n standalone: false\n})\nexport class DownloadComponent implements OnInit {\n constructor(\n private versionService: VersionService,\n private iconRegistry: IconRegistryService,\n @Inject(DOCUMENT) private document: Document\n ) {\n this.registerIcon();\n }\n\n async ngOnInit() {\n console.log('DownloadComponent ngOnInit()');\n await this.getLatestVersion();\n }\n\n getLatestVersion() {\n return this.versionService.getLatestVersion().then(\n (res) => {\n this.document.location.href = res.path;\n },\n (error) => {\n console.log('Failed to navigate to link, with error: ' + error);\n }\n );\n }\n\n private registerIcon() {\n this.iconRegistry.register('porter-logo', 'assets/icons/porter-logo.svg');\n }\n}\n","
\n
\n
\n \n
\n\n
\n
\n

PORTER Download

\n
\n
\n

Ihr Download wird automatisch gestartet...

\n

\n Sollte der Download der neuesten PORTER Version nicht starten, klicken Sie bitte den\n Button oder laden Sie die Seite neu.\n

\n
\n \n
\n
\n
\n
\n
\n","import { Component, OnInit, Renderer2 } from '@angular/core';\nimport { Alert } from '../../directives/alert.directive';\n\nconst PREVIEW_ALERT: Alert = {\n type: 'info',\n text:\n 'Hier können zukünftig Nutzer der Hersteller Lizenz die Anbindung Ihrer Produkte für die ' +\n 'virtuelle Bemusterung, Statistiken zu Ihren Produkten, Auswertungen zu bemusterten Produkten ' +\n \"und die wichtigsten KPI's (Key Performance Indicators) finden.\",\n};\n\n@Component({\n selector: 'app-manufacturer',\n templateUrl: './manufacturer.component.html',\n styleUrls: ['./manufacturer.component.scss'],\n standalone: false\n})\nexport class ManufacturerComponent implements OnInit {\n constructor(private renderer: Renderer2,) {}\n\n isShowing: boolean;\n\n ngOnInit(): void {\n this.isShowing = true;\n this.renderer.listen(window, 'resize', () => this.checkForMobile());\n }\n\n checkForMobile() {\n const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\n return width > 880;\n }\n\n toggleSidenav() {\n this.isShowing = !this.isShowing;\n }\n\n getAlert(): Alert {\n return PREVIEW_ALERT;\n }\n}\n","\n\n keyboard_arrow_left\n\n\n \n Loading\n \n\n \n

PORTER Hersteller | Startseite

\n
\n \n
\n
\n
\n","import { Injectable } from '@angular/core';\nimport { TokenService, ROUTE_PARAMETER_TOKEN_KEY, ROUTE_PARAMETER_TOKEN_EXPIRY_KEY } from './token.service';\nimport { ConfigurationService, ROUTE_PARAMETER_CONFIGURATION_ID_KEY } from './configuration.service';\nimport { UrlService } from './url.service';\nimport { Router } from '@angular/router';\nimport { AuthService } from './auth.service';\nimport { FavoritesService } from './favorites/favorites.service';\nimport { SchemasService } from './schemas.service';\nimport { FilteredArticlesService } from './filtered-articles.service';\nimport { ReadyNumberService } from '../modules/asset-catalog/services/ready-number.service';\n\nconst ROUTE_PARAMETER_KEYS = {\n download: '/download',\n downloadPorter: 'download.porter.de',\n tokenValue: ROUTE_PARAMETER_TOKEN_KEY,\n tokenExpiry: ROUTE_PARAMETER_TOKEN_EXPIRY_KEY,\n configurationId: ROUTE_PARAMETER_CONFIGURATION_ID_KEY,\n};\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AppInitializeService {\n constructor(\n private readonly tokenService: TokenService,\n private readonly configurationService: ConfigurationService,\n private readonly urlService: UrlService,\n private readonly router: Router,\n private readonly authService: AuthService,\n private readonly favoritesService: FavoritesService,\n private readonly schemasService: SchemasService,\n private readonly readyNumberService: ReadyNumberService,\n private readonly filteredArticlesService: FilteredArticlesService\n ) {}\n\n async initializeData() {\n try {\n // Order of initialization of the services is important\n // Schema service should be initialized before the configuration service since it does not require a configuration\n // In case of an error (e.g. missing configuration ID) in the configuration service, the schema service should still be initialized\n await this.schemasService.initialize();\n await this.configurationService.initialize();\n await this.favoritesService.initialize();\n } catch (error) {\n console.warn('Initialization Data', error);\n }\n\n //contains what needs to work independently if previous try block fails\n try {\n this.readyNumberService.initialize();\n this.filteredArticlesService.initializeSubscriptions();\n } catch (error) {\n console.warn('Error during cleanup initialization', error);\n }\n }\n\n private async initialize() {\n await this.initializeServices();\n await this.redirectNavigation();\n }\n\n private async initializeServices() {\n this.tokenService.initialize();\n\n if (this.authService.isAuthenticated()) {\n await this.authService.initializeUser();\n await this.initializeData();\n }\n }\n\n private async redirectNavigation() {\n this.urlContainsDownload()\n ? await this.navigateToDownload()\n : await this.navigateWithoutRouteParameters([\n ROUTE_PARAMETER_KEYS.configurationId,\n ROUTE_PARAMETER_KEYS.tokenValue,\n ROUTE_PARAMETER_KEYS.tokenExpiry,\n ]);\n }\n\n private urlContainsDownload(): boolean {\n const containsDownload = this.urlService.urlContains(ROUTE_PARAMETER_KEYS.download);\n const containsDownloadPorter = this.urlService.urlContains(ROUTE_PARAMETER_KEYS.downloadPorter);\n\n return containsDownload || containsDownloadPorter;\n }\n\n private async navigateToDownload() {\n await this.router.navigate([ROUTE_PARAMETER_KEYS.download]);\n }\n\n private async navigateWithoutRouteParameters(keys: string[]) {\n const baseUrl = this.urlService.getBaseUrl();\n const urlWithoutParameters = this.urlService.removeRouteParameters(keys);\n let path = urlWithoutParameters.replace(baseUrl, '');\n const dashIsLastCharacter = path.slice(-1) === '/';\n\n if (dashIsLastCharacter) {\n path = path.slice(0, -1); // Remove the Dash\n }\n if (window.location.pathname !== path) {\n /*\n Using await results in configuration-resolver being activated too early and\n ultimately in asset-catalog-user-group-guard not being called when opening catalog.\n\n POR-10876:\n We need to prevent such unexpected behavior. Maybe another resolver should be\n used for handling initial route parameters for confogiurationId and token, etc..\n */\n await this.router.navigateByUrl(path);\n }\n }\n\n static initializeApp(appInitService: AppInitializeService) {\n return (): Promise => appInitService.initialize();\n }\n}\n","\n
\n \n
\n arrow_back\n
zurück zu porter.de
\n
\n \n \n \n arrow_back\n
zurück zu fingerhaus.de
\n \n
\n\n\n
\n
\n \n \n \n \n \n \n
\n\n \n
\n

Anmelden

\n
\n\n \n\n \n\n
\n
\n \n E-Mail-Adresse eingeben\n \n\n E-Mail nicht registriert\n \n \n Ungültige E-Mail-Adresse\n \n \n
\n\n
\n \n Passwort eingeben\n\n \n {{\n hidePw ? 'visibility' : 'visibility_off'\n }}\n\n E-Mail oder Passwort inkorrekt\n Ihr Account wurde noch nicht bestätigt\n \n
\n \n \n \n\n
\n \n Anmelden\n \n
\n
\n
\n\n\n \n\n","import { Component, OnInit } from '@angular/core';\nimport { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';\nimport { ActivatedRoute, Router } from '@angular/router';\n\nimport { AuthService, LoginData } from '../../../services/auth.service';\nimport { ConversionData, FloorplanAIService } from '../../../services/floorplan-ai.service';\n\nimport { environment } from '../../../../environments/environment';\nimport { Alert } from '../../../directives/alert.directive';\nimport { ExporterPluginService } from '../../../services/exporter-plugin.service';\nimport { IconRegistryService } from '../../../services/icon-registry.service';\nimport { AppInitializeService } from '../../../services/app-initialize.service';\n\nconst SUCCESSFUL_LOGOUT_ALERT: Alert = {\n type: 'success',\n collapseIcon: true,\n text: 'Sie haben sich erfolgreich abgemeldet',\n};\n\nconst SESSION_TERMINATED_ALERT: Alert = {\n type: 'warning',\n collapseIcon: true,\n text: 'Ihre Session wurde beendet',\n};\n\nconst CONNECTION_FAILED_MESSAGE = 'Verbindung zum Server fehlgeschlagen';\n\n@Component({\n selector: 'app-login',\n templateUrl: './login.component.html',\n styleUrls: ['./login.component.scss'],\n standalone: false\n})\nexport class LoginComponent implements OnInit {\n returnUrl: string;\n customerSystem: string;\n\n hidePw: boolean;\n waitingForResponse: boolean;\n logout: boolean;\n sessionLost: boolean;\n\n hasInvalidCredentials: boolean;\n isUnconfirmedUser: boolean;\n isUsingExport: boolean;\n\n form: UntypedFormGroup;\n\n constructor(\n private readonly auth: AuthService,\n private readonly router: Router,\n private readonly activatedRoute: ActivatedRoute,\n private readonly floorplanAiService: FloorplanAIService,\n private readonly exporterPluginService: ExporterPluginService,\n private readonly iconRegistry: IconRegistryService,\n private readonly initializeService: AppInitializeService\n ) {\n this.hidePw = true;\n this.hasInvalidCredentials = false;\n this.waitingForResponse = false;\n this.logout = false;\n this.sessionLost = false;\n this.returnUrl = this.createReturnUrl();\n this.isUsingExport = this.exporterPluginService.usesExport();\n\n this.registerIcons();\n }\n\n ngOnInit(): void {\n this.customerSystem = environment.customerSystem;\n this.logout = this.activatedRoute.snapshot.queryParams.logout;\n this.sessionLost = this.activatedRoute.snapshot.queryParams.sessionLost;\n this.form = new UntypedFormGroup({\n email: new UntypedFormControl('', [Validators.required, Validators.email]),\n password: new UntypedFormControl(),\n });\n }\n\n get authenticated(): boolean {\n return this.auth.isAuthenticated();\n }\n\n async login() {\n const data: LoginData = this.form.value;\n\n // TODO DAI: If we move the error handling into the InterceptorService, we can remove the try-catch block\n try {\n this.waitingForResponse = true;\n await this.auth.login(data);\n\n await this.initializeService.initializeData(); // TODO: feels a little hacky IMO -> app is already running, we use states in services synchronously, but await initialization\n if (this.isUsingExportPlugin()) {\n await this.redirectToProjects();\n } else if (this.shouldRedirectToLatestUpload()) {\n this.redirectToLatestUpload();\n } else if (this.isValidReturnUrl()) {\n await this.redirectToReturnUrl();\n } else {\n await this.redirectToBaseUrl();\n }\n } catch (error) {\n // TODO DAI: Move to InterceptorService\n this.handleLoginError(error);\n this.waitingForResponse = false;\n }\n }\n\n clearErrors() {\n this.hasInvalidCredentials = false;\n this.isUnconfirmedUser = false;\n\n this.form.controls.email.setErrors(null);\n this.form.controls.email.updateValueAndValidity();\n this.form.controls.password.setErrors(null);\n this.form.controls.password.updateValueAndValidity();\n }\n\n private isUsingExportPlugin() {\n return this.exporterPluginService.usesExport();\n }\n\n private async redirectToProjects() {\n await this.router.navigate(['/projects']);\n }\n\n // TODO DAI: Move to InterceptorService\n private handleLoginError(error: any) {\n const hasNoConnection = error.error.message === 'NO_CONNECTION';\n\n if (hasNoConnection) {\n alert(CONNECTION_FAILED_MESSAGE);\n return;\n }\n\n this.hasInvalidCredentials = error.status === 401 || error.status === 500;\n this.isUnconfirmedUser = error.status === 403;\n\n this.form.controls.email.setErrors({ incorrect: true });\n this.form.controls.password.setErrors({ wrong: true });\n }\n\n private async redirectToReturnUrl() {\n await this.router.navigateByUrl(this.returnUrl);\n }\n\n private isValidReturnUrl(): boolean {\n return (\n this.returnUrl != '/' &&\n !this.returnUrl.startsWith('/register') &&\n !this.returnUrl.startsWith('/confirmation')\n );\n }\n\n private shouldRedirectToLatestUpload(): boolean {\n // on Grundrisse route, go to last conversion if no conversionId is included in path already\n return this.returnUrl.startsWith('/grundrisse') && !this.returnUrl.includes('conversionId');\n }\n\n async redirectToBaseUrl() {\n if (this.auth.hasUserGroup(environment.AI_LICENCE_GROUPS) || this.auth.getCurrentUser().admin) {\n await this.router.navigateByUrl('/grundrisse');\n } else if (this.auth.hasUserGroup(environment.FINGERHAUS_PRODUCT_MANAGEMENT_GROUP)) {\n await this.router.navigateByUrl('/produkt-management');\n } else if (this.auth.hasUserGroup(environment.FINGERHAUS_ADMIN_GROUP)) {\n await this.router.navigateByUrl('/benutzer-verwaltung');\n } else if (this.auth.hasUserGroup(environment.FINGERHAUS_CONSULTANT_GROUP)) {\n await this.router.navigateByUrl('/produkt-katalog');\n } else {\n await this.router.navigateByUrl('/app-link');\n }\n }\n\n private createReturnUrl(): string {\n return this.activatedRoute.snapshot.queryParams.returnUrl &&\n !/^\\/login/i.test(this.activatedRoute.snapshot.queryParams.returnUrl)\n ? this.activatedRoute.snapshot.queryParams.returnUrl\n : '/';\n }\n\n redirectToLatestUpload() {\n this.floorplanAiService.getAllUserConversionDataWithoutThumbnail().subscribe(\n (conversionData: ConversionData) => {\n const conversionList = conversionData.list;\n if (conversionList.length === 0) {\n window.location.replace(\n window.location.origin +\n '/grundrisse/grundriss-editor?conversionId=&environment=' +\n environment.apiUrl\n );\n return;\n }\n\n conversionList.forEach((conv) => {\n if (conv.status == 'COMPLETED' || conv.status === 'IN_PROGRESS') {\n window.location.replace(\n window.location.origin +\n '/grundrisse/grundriss-editor?conversionId=' +\n conv.conversionId +\n '&environment=' +\n environment.apiUrl\n );\n } else if (conv == conversionList[conversionList.length - 1]) {\n window.location.replace(\n window.location.origin +\n '/grundrisse/grundriss-editor?conversionId=&environment=' +\n environment.apiUrl\n );\n return;\n }\n });\n },\n (error) => {\n console.error(error.message);\n }\n );\n }\n\n getSuccessfulLogoutAlert(): Alert {\n return SUCCESSFUL_LOGOUT_ALERT;\n }\n\n getSessionTerminatedAlert(): Alert {\n return SESSION_TERMINATED_ALERT;\n }\n\n private registerIcons() {\n this.iconRegistry.register('porter-logo', 'assets/icons/porter-logo.svg');\n this.iconRegistry.register('fingerhaus-logo', 'assets/icons/fingerhaus-logo.svg');\n }\n}\n","import { Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-signup-header',\n templateUrl: './signup-header.component.html',\n styleUrls: ['./signup-header.component.scss'],\n standalone: false\n})\nexport class SignupHeaderComponent implements OnInit {\n constructor() {}\n\n ngOnInit(): void {}\n}\n","\n
\n
\n \n
\n\n
\n
\n

Passwort zurücksetzen

\n

Bitte prüfen Sie Ihr E-Mail Postfach!

\n
\n
\n

Bitte geben Sie Ihre E-Mail-Adresse ein, um Ihr Passwort zurückzusetzen.

\n

\n Wir haben Ihnen einen Link an die E-Mail-Adresse\n {{ emailCtrl.value }} gesendet, über welchen Sie ein neues Passwort\n vergeben können.\n

\n

\n Wollen Sie aber dennoch das Passwort nicht neu vergeben, können Sie sich wie gewohnt mit\n Ihrem bisherigen Passwort anmelden.\n

\n
\n\n
\n \n E-Mail-Adresse eingeben\n \n\n E-Mail-Adresse ist nicht registriert\n \n Ungültige E-Mail-Adresse\n \n\n
\n \n Passwort zurücksetzen\n \n \n
\n
\n\n
\n \n
\n\n \n
\n
\n\n","import { Component, OnInit } from '@angular/core';\nimport { UntypedFormControl, Validators } from '@angular/forms';\nimport { Router } from '@angular/router';\nimport { AuthService } from '../../../../services/auth.service';\nimport { IconRegistryService } from '../../../../services/icon-registry.service';\n\n@Component({\n selector: 'app-request-password-reset',\n templateUrl: './request-password-reset.component.html',\n styleUrls: ['./request-password-reset.component.scss'],\n standalone: false,\n})\nexport class RequestPasswordResetComponent implements OnInit {\n sent: boolean;\n emailCtrl = new UntypedFormControl('', [Validators.required, Validators.email]);\n waitingForResponse = false;\n\n constructor(\n private router: Router,\n private authService: AuthService,\n private iconRegistry: IconRegistryService\n ) {\n this.registerIcons();\n }\n\n async ngOnInit() {\n if (this.authService.isAuthenticated()) {\n await this.router.navigateByUrl('/');\n }\n }\n\n requestPasswordReset(): void {\n if (!this.emailCtrl) {\n console.error('Missing parameters');\n return; // should never actually happen\n }\n if (this.emailCtrl.hasError('email')) {\n console.error('Invalid email');\n return; // feedback is displayed automatically\n }\n\n this.waitingForResponse = true;\n this.authService.requestPasswordReset(this.emailCtrl.value).subscribe({\n next: () => {\n this.sent = true;\n },\n error: (error) => {\n console.error(error);\n this.emailCtrl.setErrors({ incorrect: true });\n },\n complete: () => {\n this.waitingForResponse = false;\n },\n });\n }\n\n private registerIcons() {\n this.iconRegistry.register('porter-logo', 'assets/icons/porter-logo.svg');\n }\n}\n","import { UntypedFormGroup, ValidatorFn, ValidationErrors } from '@angular/forms';\n\nconst removeNotMatching = (errors: ValidationErrors): ValidationErrors | null => {\n if (errors) {\n const { notMatching, ...others } = errors;\n if (Object.keys(others).length > 0) return others;\n }\n return null;\n};\n\nconst removeTooWeak = (errors: ValidationErrors): ValidationErrors | null => {\n if (errors) {\n const { tooWeak, ...others } = errors;\n if (Object.keys(others).length > 0) return others;\n }\n return null;\n};\n\nexport const passwordCheckValidator: ValidatorFn = (control: UntypedFormGroup): ValidationErrors | null => {\n const password = control.get('password');\n const passwordCheck = control.get('passwordCheck');\n\n // at least 1 lower case, 1 upper case, 1 number, 1 special charachter, length >= 8\n const pwRegexLower = new RegExp('[a-z]');\n const pwRegexUpper = new RegExp('[A-Z]');\n const pwRegexNumber = new RegExp('[0-9]');\n const pwRegexSpecial = new RegExp('[?!@#$%^&*]');\n\n if (\n password &&\n password.value &&\n !(\n pwRegexLower.test(password.value) &&\n pwRegexUpper.test(password.value) &&\n pwRegexNumber.test(password.value) &&\n pwRegexSpecial.test(password.value)\n )\n ) {\n password.setErrors({ ...password.errors, tooWeak: true });\n passwordCheck.setErrors(null);\n return { passwordsTooWeak: true };\n } else {\n const existingPasswordErrors = removeTooWeak(password.errors);\n password.setErrors(existingPasswordErrors);\n }\n\n // password matches passwordCheck field\n if (password && passwordCheck && password.value === passwordCheck.value) {\n const existingPasswordCheckErrors = removeNotMatching(passwordCheck.errors);\n passwordCheck.setErrors(existingPasswordCheckErrors);\n\n return null;\n }\n\n passwordCheck.setErrors({ ...passwordCheck.errors, notMatching: true });\n return { passwordsNotMatching: true };\n};\n","\n
\n
\n \n
\n
\n
\n

Passwort zurücksetzen

\n
\n
\n

\n Geben Sie ein neues Passwort für ihr PORTER-Konto mit der E-Mail-Adresse\n {{ email }} ein.\n

\n

\n Achtung: Minimum je ein Kleinbuchstaben, Großbuchstaben, Zahl, Sonderzeichen und 8 Zeichen\n verwenden!\n

\n
\n\n
\n \n Neues Passwort\n\n \n {{\n hidePw ? 'visibility' : 'visibility_off'\n }}\n\n Mindestens 8 Zeichen verwenden\n \n Kein Klein- & Großbuchstaben, Zahl & Sonderzeichen\n \n \n\n \n Passwort erneut eingeben\n\n \n {{\n hidePw ? 'visibility' : 'visibility_off'\n }}\n\n \n Passwörter stimmen nicht überein\n \n \n\n
\n \n Passwort zurücksetzen\n \n
\n
\n
\n\n
\n
\n

Passwort zurücksetzen

\n
\n
\n

\n Sind Sie sicher, dass Sie Ihr Passwort für die E-Mail-Adresse\n {{ email }} zurücksetzen möchten?\n

\n
\n
\n \n \n
\n
\n
\n\n","import { Component, OnInit } from '@angular/core';\nimport { UntypedFormControl, UntypedFormGroup } from '@angular/forms';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { AuthService } from '../../../../services/auth.service';\n\nimport { passwordCheckValidator } from '../../../../directives/password-check.directive';\nimport { IconRegistryService } from '../../../../services/icon-registry.service';\n\n@Component({\n selector: 'app-reset-password',\n templateUrl: './reset-password.component.html',\n styleUrls: ['./reset-password.component.scss'],\n standalone: false,\n})\nexport class ResetPasswordComponent implements OnInit {\n email: string;\n token: string;\n form: UntypedFormGroup;\n hidePw = true;\n confirm = false;\n waitingForResponse = false;\n\n constructor(\n private router: Router,\n private activatedRoute: ActivatedRoute,\n private authService: AuthService,\n private iconRegistry: IconRegistryService\n ) {\n this.registerIcons();\n }\n\n ngOnInit(): void {\n if (this.authService.isAuthenticated()) {\n this.router.navigate(['/']);\n } else {\n this.token = this.activatedRoute.snapshot.paramMap.get('token');\n\n this.authService.getEmailForResetToken(this.token).subscribe(\n (response) => (this.email = response.email),\n (error) => {\n // TODO: Display error that token is not valid\n this.router.navigate(['/reset']);\n }\n );\n\n this.form = new UntypedFormGroup(\n {\n password: new UntypedFormControl(),\n passwordCheck: new UntypedFormControl(),\n },\n { validators: passwordCheckValidator }\n );\n }\n }\n\n changeMode(confirm: boolean): void {\n this.confirm = confirm;\n }\n\n resetPassword(): void {\n if (!this.form.value.password || !this.form.value.passwordCheck) {\n console.error('Missing parameters');\n return; // should never actually happen\n }\n\n // TODO: password requirements?\n if (this.form.value.password !== this.form.value.passwordCheck) {\n console.log('passwords are different');\n this.form.controls.passwordCheck.setErrors({ incorrect: true });\n return;\n }\n\n this.authService.resetPassword(this.token, this.form.value.password).subscribe(\n () => {\n console.log('Reset was successful');\n this.router.navigate(['/login']);\n },\n (error) => {\n console.error(error.message);\n this.waitingForResponse = false;\n }\n );\n }\n\n private registerIcons() {\n this.iconRegistry.register('porter-logo', 'assets/icons/porter-logo.svg');\n }\n}\n","\n
\n
\n \n
\n\n
\n
\n

\n check_circle_outlineAktivierung erfolgreich\n

\n

\n error_outline Aktivierung fehlgeschlagen\n

\n
\n\n
\n

Ihr Account wurde erfolgreich aktiviert.

\n

\n Leider ist ein Fehler bei der Aktivierung Ihres Accounts aufgetreten. Es kann sein, dass Ihr\n Account bereits aktiviert ist.

\n Für weitere Hilfe kontaktieren Sie bitte unseren Support unter\n support@porter.de.\n

\n
\n\n
\n \n
\n
\n
\n\n","import { Component, OnInit } from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\n\nimport { AuthService } from '../../../../services/auth.service';\n\n@Component({\n selector: 'app-confirmation',\n templateUrl: './confirmation.component.html',\n styleUrls: ['./confirmation.component.scss'],\n standalone: false\n})\nexport class ConfirmationComponent implements OnInit {\n success: boolean;\n failure: boolean;\n\n constructor(private authService: AuthService, private route: ActivatedRoute) {}\n\n ngOnInit() {\n const token = this.route.snapshot.paramMap.get('token');\n\n this.authService.confirm(token).subscribe(\n () => {\n this.success = true;\n },\n (error) => {\n this.failure = true;\n console.error(error);\n },\n );\n }\n}\n","
\n
\n \n
\n
\n
\n

Nutzungsbedingungen

\n
\n
\n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sit amet neque felis.\n Sed ac gravida est, eu rutrum ligula. In hac habitasse platea dictumst. Pellentesque\n tristique faucibus gravida. Donec lobortis congue nulla, vel aliquam ex rutrum eu. Nulla\n varius eros eget scelerisque elementum. Aenean placerat ut neque ut molestie. Nulla pulvinar\n rutrum dui, at placerat purus. Nulla consequat eleifend augue, vel eleifend nisl aliquet in.\n Suspendisse ac tellus odio.\n

\n

\n Duis finibus accumsan posuere. Donec fringilla aliquet odio, sed interdum ex blandit sit\n amet. Aliquam erat volutpat. Fusce venenatis lorem id leo tincidunt, sit amet posuere erat\n aliquet. Maecenas commodo justo ut vestibulum volutpat. Nullam a massa non lectus feugiat\n tempus. Donec porttitor, ante a porttitor pulvinar, arcu elit fermentum orci, sed bibendum\n ipsum massa at risus. Aenean in ex faucibus, sagittis tellus id, dictum dolor. Duis lectus\n nulla, varius vulputate felis sed, volutpat scelerisque nunc. Nullam vehicula nibh nec\n libero eleifend accumsan. In porttitor finibus tortor, a ultrices turpis fermentum at.\n Aenean arcu neque, bibendum sed finibus id, malesuada nec metus. Orci varius natoque\n penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam sit amet eros a\n nulla consectetur molestie. Curabitur a libero a sapien varius aliquet et convallis orci.\n

\n

\n Fusce vulputate magna tortor, ac condimentum ipsum pellentesque et. Aliquam gravida nec\n felis eu facilisis. Donec ornare viverra arcu, ac mattis nisi faucibus gravida. Quisque in\n ante placerat, congue tortor bibendum, aliquet augue. Nam sed molestie neque, non\n ullamcorper nisi. Nunc massa elit, vulputate eu lacus et, dignissim vulputate nunc. Aliquam\n efficitur ullamcorper justo condimentum tempus. Vivamus id pulvinar augue. Nullam eget\n maximus turpis. Ut nec velit a dui placerat semper. Nullam egestas mollis efficitur. Morbi\n suscipit lorem ut sem posuere, at consequat sem tincidunt. Sed fringilla enim nec nunc\n consectetur, vel pharetra odio pulvinar. Pellentesque nulla quam, luctus non cursus vel,\n rutrum quis nisi.\n

\n

\n Aenean lobortis nibh quis odio rutrum, ac bibendum lectus sodales. Interdum et malesuada\n fames ac ante ipsum primis in faucibus. Nullam auctor condimentum purus vitae convallis.\n Donec vitae augue vel sapien lacinia fringilla facilisis nec est. Donec ac mollis nunc.\n Curabitur laoreet vestibulum ante, sit amet dapibus erat. Proin felis est, pulvinar non\n lobortis quis, commodo non arcu. Quisque vehicula sapien et est tempor vulputate. Donec in\n fringilla leo.\n

\n

\n Sed id lobortis nibh, at lacinia tortor. Quisque eget placerat libero. Morbi sollicitudin\n felis sed nisi viverra rutrum. Aliquam justo ipsum, consectetur a consectetur sit amet,\n efficitur sed quam. Sed dictum justo porta aliquam dictum. Ut viverra mattis dolor, vel\n gravida nisl. Nunc viverra diam elit, vel malesuada lorem vehicula ac.\n

\n

\n Vivamus venenatis eget sem eget fringilla. Proin ac orci purus. Mauris dictum commodo\n libero, vel ullamcorper eros hendrerit vitae. Vivamus porttitor ex quis augue laoreet, eu\n gravida arcu commodo. Pellentesque et volutpat ex. Nullam eu euismod orci, vitae rhoncus\n enim. Cras finibus leo id nulla semper iaculis. Suspendisse lectus augue, malesuada eu\n ornare a, sollicitudin lobortis enim. Mauris sit amet congue dolor. Morbi quis tristique\n sapien.\n

\n

\n Sed aliquet felis neque, et tristique nisi placerat varius. Aenean at mattis metus, ut\n interdum sem. In arcu lectus, finibus id tortor quis, tempor viverra purus. Donec dictum\n posuere elit a vestibulum. Class aptent taciti sociosqu ad litora torquent per conubia\n nostra, per inceptos himenaeos. Cras a convallis tortor. Cras sollicitudin nisl non quam\n tristique tincidunt. Integer non semper felis. Ut bibendum pharetra quam, quis pretium augue\n mattis nec. Praesent est odio, tempus quis lobortis at, ultricies a ante. Duis interdum\n mauris at lacus dignissim, nec efficitur turpis mollis. Vivamus hendrerit lacus sit amet\n odio pretium venenatis. Donec ultrices rutrum magna vitae placerat.\n

\n

\n Nam malesuada, tellus ut gravida consectetur, dui risus faucibus elit, sit amet imperdiet\n tellus mi eu neque. Vivamus sed consequat justo. Donec convallis varius maximus. Praesent\n malesuada auctor augue non euismod. Fusce sed est vehicula, facilisis nulla id, lacinia\n velit. Quisque vitae ipsum vitae tellus pellentesque laoreet. Integer sagittis dictum\n tincidunt. Phasellus tincidunt iaculis lorem nec feugiat. Suspendisse vel luctus ante. Sed\n imperdiet rutrum lorem, vel venenatis nulla pretium ac. Etiam a mi ut nisl euismod lacinia.\n Nam eu felis eu ante tristique faucibus pretium in tellus. Quisque feugiat velit et nulla\n pretium sagittis vitae sodales massa. Ut et porta ante. Nullam suscipit dui et pellentesque\n porttitor. Nulla blandit non libero tincidunt consequat.\n

\n

\n Donec tempor orci et consectetur ultrices. Curabitur rhoncus magna condimentum mauris\n ultrices, eget vehicula ligula laoreet. Nunc consequat vestibulum tincidunt. Nunc nec sem\n quis odio convallis commodo. In hac habitasse platea dictumst. Curabitur vehicula, metus sed\n molestie venenatis, ante ipsum vestibulum enim, nec rutrum eros ex eget dolor. Nullam\n suscipit, diam sed accumsan tristique, erat ante mattis ligula, vitae tempus est tellus at\n lorem. Vivamus et lectus maximus, pellentesque sem sed, commodo metus. Maecenas et ipsum ut\n augue gravida consequat sed ut diam. Sed eu ante a lectus pellentesque rhoncus sed a lectus.\n Praesent ut felis auctor, faucibus magna sit amet, lacinia massa. Aenean eget ultrices\n justo. Proin mattis dui id ante luctus, nec semper nisl lacinia. Lorem ipsum dolor sit amet,\n consectetur adipiscing elit. Nunc tincidunt non magna in mattis. Morbi neque purus,\n malesuada et nulla vel, interdum interdum erat.\n

\n

\n Phasellus lobortis rutrum magna ac ullamcorper. Aliquam non porta sapien, at finibus ipsum.\n Nunc ut orci malesuada, tincidunt felis vel, vulputate metus. Quisque venenatis est ac\n eleifend venenatis. Duis quis augue egestas purus bibendum euismod. Duis interdum quam eget\n mauris accumsan blandit. Curabitur et elit orci.\n

\n
\n\n
\n \n Zurück\n \n
\n
\n
\n","import { Component, Input, Output, EventEmitter } from '@angular/core';\n\n@Component({\n selector: 'app-terms-of-service',\n templateUrl: './terms-of-service.component.html',\n styleUrls: ['./terms-of-service.component.scss'],\n standalone: false\n})\nexport class TermsOfServiceComponent {\n @Input()\n backButton: boolean;\n\n @Output()\n backButtonClick = new EventEmitter();\n}\n","\n\n\n
\n \n
\n\n \n
\n
\n

Registrierung

\n
\n \n Unternehmen\n \n \n\n \n\n \n Vorname\n \n \n\n \n Nachname\n \n \n\n \n E-Mail-Adresse\n \n\n \n Ungültige E-Mail-Adresse\n \n \n E-Mail-Adresse wird bereits verwendet\n \n \n\n \n Passwort\n \n {{\n hidePw ? 'visibility' : 'visibility_off'\n }}\n\n mindestens 8 Zeichen und je 1 Kleinbuchstabe, Großbuchstabe, Zahl und\n Sonderzeichen\n \n\n \n Passwort wiederholen\n \n\n \n Passwörter stimmen nicht überein\n \n \n\n \n Branche\n \n \n\n \n Ort\n \n \n\n \n PLZ\n \n \n\n \n Straße\n \n \n\n \n Hausnummer\n \n \n\n \n Ich habe die\n Nutzungsbedingungen gelesen\n und stimme ihnen zu.\n \n\n \n\n

\n *Pflichtfelder\n

\n
\n \n Weiter\n \n
\n \n \n\n
\n
\n

Vielen Dank für Ihre Registrierung

\n
\n
\n

\n Ihr Account wird nun vorbereitet. Sie erhalten in Kürze (1-2 Werktage) weitere Informationen\n per E-Mail.
\n

\n
\n
\n \n
\n
\n\n\n\n \n\n\n\n","import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';\nimport { AbstractControl, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';\nimport { MatCheckbox } from '@angular/material/checkbox';\n\nimport { AuthService, ErrorType } from '../../../services/auth.service';\n\nimport { passwordCheckValidator } from '../../../directives/password-check.directive';\nimport { requiredErrorValidator } from '../../../directives/required-error.directive';\n\nimport { IconRegistryService } from '../../../services/icon-registry.service';\n\n@Component({\n selector: 'app-register',\n templateUrl: './register.component.html',\n styleUrls: ['./register.component.scss'],\n standalone: false,\n})\nexport class RegisterComponent implements OnInit {\n form: UntypedFormGroup;\n\n termsOfService = false;\n sent = false;\n hidePw = true;\n duplicateUser = false;\n waitingForResponse = false;\n\n @ViewChild('checkBox')\n checkBox: MatCheckbox;\n\n constructor(\n public authService: AuthService,\n private iconRegistry: IconRegistryService\n ) {\n this.registerIcons();\n }\n\n ngOnInit(): void {\n this.form = new UntypedFormGroup(\n {\n company: new UntypedFormControl(),\n //username: new FormControl(),\n lastName: new UntypedFormControl(),\n firstName: new UntypedFormControl(),\n email: new UntypedFormControl('', [Validators.required, Validators.email]),\n password: new UntypedFormControl(),\n passwordCheck: new UntypedFormControl(),\n industry: new UntypedFormControl(),\n city: new UntypedFormControl(),\n // TODO: Validate number!!\n zipcode: new UntypedFormControl(),\n street: new UntypedFormControl(),\n houseNumber: new UntypedFormControl(),\n termsOfService: new UntypedFormControl(),\n },\n { validators: [passwordCheckValidator, requiredErrorValidator] }\n );\n }\n\n get authenticated(): boolean {\n return this.authService.isAuthenticated();\n }\n\n editRegUser() {\n this.duplicateUser = false;\n\n //this.removeIncorrectError(this.form.controls.username);\n this.removeIncorrectError(this.form.controls.email);\n }\n\n private removeIncorrectError(formControl: AbstractControl): void {\n for (const errorName in formControl.errors) {\n if (errorName === 'incorrect') {\n delete formControl.errors[errorName];\n }\n }\n\n if (formControl.errors && Object.keys(formControl.errors).length === 0) formControl.setErrors(null);\n }\n\n register() {\n if (\n !this.form.value.company ||\n !this.form.value.email ||\n !this.form.value.password ||\n !this.form.value.passwordCheck ||\n !this.form.value.lastName ||\n !this.form.value.firstName\n ) {\n console.error('Missing parameters');\n return; // should never actually happen\n }\n\n if (this.form.controls.email.hasError('email')) {\n return;\n }\n\n if (this.form.value.password !== this.form.value.passwordCheck) {\n this.form.controls.passwordCheck.setErrors({ incorrect: true });\n return;\n }\n\n this.waitingForResponse = true;\n this.authService.register(this.form.value).subscribe(\n (data) => {\n this.sent = true;\n if (data.returnUrl) window.location = data.returnUrl;\n },\n (error) => {\n console.error(error.message);\n if (error === ErrorType.DUPLICATE_USER) {\n this.form.controls.email.setErrors({ incorrect: true });\n this.duplicateUser = true;\n }\n this.waitingForResponse = false;\n },\n () => {\n this.waitingForResponse = false;\n }\n );\n }\n\n private registerIcons() {\n this.iconRegistry.register('porter-logo', 'assets/icons/porter-logo.svg');\n }\n}\n","
\n
\n \n\n \n \n
\n \n \n \n {{ option.viewValue }}\n \n \n
\n \n
\n
\n","import { Component, OnInit } from '@angular/core';\nimport { AbstractControl, UntypedFormControl, UntypedFormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';\n\n@Component({\n selector: 'example-input-with-selector',\n templateUrl: './example-input-with-selector.html',\n styleUrls: ['./example-input-with-selector.scss'],\n standalone: false\n})\nexport class ExampleInputWithUnitSelector implements OnInit {\n referenceValue: any;\n exampleUnits: any[] = [\n { value: 100, viewValue: 'cm' },\n { value: 1, viewValue: 'm' },\n ];\n\n formGroup: UntypedFormGroup;\n\n constructor() {}\n\n ngOnInit() {\n /*\n set up form for wall height and attach it to floorplan object\n */\n this.setFileForm();\n }\n\n setFileForm() {\n this.formGroup = new UntypedFormGroup({\n inputValue: new UntypedFormControl(123),\n selectorValue: new UntypedFormControl('defaultValue', Validators.required),\n });\n }\n\n /*\n Validator to check if input value and mat-select value are valid in their combination\n */\n crossFieldValidator(): ValidatorFn {\n return (control: AbstractControl): ValidationErrors | null => {\n const inputVal = control.get('inputValue').value;\n const selectorVal = control.get('selectorValue').value;\n\n if (!inputVal) {\n return null;\n }\n let someValidityCondition = inputVal * selectorVal > 5;\n\n return someValidityCondition ? null : { belowMinHeight: true };\n };\n }\n\n onChange($event) {}\n\n onInputChange($event) {}\n}\n","import { Component} from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\n\nimport { ErrorDialogService } from '../../services/errordialog.service';\nimport { InfoboxDialogService } from '../../services/infobox-dialog.service';\nimport {\n DEFAULT_DROPDOWN_CONFIGURATION,\n DropdownConfiguration,\n} from '../../shared/components/dropdown/dropdown.component';\n\n@Component({\n selector: 'app-visual-units',\n templateUrl: './visual-units.component.html',\n styleUrls: ['./visual-units.component.scss'],\n standalone: false\n})\nexport class VisualUnitsComponent {\n showToggle = false;\n\n dropdownConfiguration_1: DropdownConfiguration;\n dropdownConfiguration_2: DropdownConfiguration;\n dropdownConfiguration_3: DropdownConfiguration;\n\n constructor(\n public dialog: MatDialog,\n private infoboxService: InfoboxDialogService,\n private errorDialogService: ErrorDialogService,\n ) {}\n\n ngOnInit() {\n this.initializeDropdowns();\n }\n\n private initializeDropdowns() {\n const options_1 = [\n { label: 'Keine', onClick: () => {} },\n { label: 'Biene', onClick: () => {} },\n { label: 'Hummel', onClick: () => {} },\n { label: 'Wespe', onClick: () => {} },\n ];\n\n const options_2 = [\n {\n label: 'this is a very very long example name for an option',\n onClick: () => {},\n },\n { label: 'two', onClick: () => {} },\n { label: 'three', onClick: () => {} },\n { label: 'four', onClick: () => {} },\n { label: 'five', onClick: () => {} },\n { label: 'six', onClick: () => {} },\n { label: 'seven', onClick: () => {} },\n { label: 'eight', onClick: () => {} },\n { label: 'nine', onClick: () => {} },\n { label: 'ten', onClick: () => {} },\n { label: 'eleven', onClick: () => {} },\n ];\n\n this.dropdownConfiguration_1 = {\n ...DEFAULT_DROPDOWN_CONFIGURATION,\n options: options_1,\n };\n\n this.dropdownConfiguration_2 = {\n ...DEFAULT_DROPDOWN_CONFIGURATION,\n options: options_2,\n };\n\n this.dropdownConfiguration_3 = {\n ...DEFAULT_DROPDOWN_CONFIGURATION,\n isDisabled: true,\n options: options_1,\n };\n }\n\n code_matbutton = '';\n code_matflatbutton = '';\n code_matstrokedbutton = '';\n code_matflatbutton_attributecolors_accent =\n '';\n code_matflatbutton_attributecolors_primary =\n '';\n code_matflatbutton_icon =\n '';\n code_maticonbutton =\n '';\n code_maticonbutton_bg =\n '';\n code_matbutton_size =\n '';\n\n openDialog() {\n this.dialog.open(ExampleModal, {\n width: 'auto',\n autoFocus: false,\n //: 'no-padding-dialog',\n });\n }\n\n toggleState() {\n this.showToggle = !this.showToggle;\n }\n\n openInfoboxDialog() {\n const options = {\n icon: 'language',\n title: 'PORTER Grundrisse',\n text: 'Die PORTER-Anwendung für Ihren Windows-PC.',\n content: '
  • Info 1
  • Info 2
  • ',\n buttonText: 'Optional Button', // buttonText.length determines if botton is visible\n };\n\n this.infoboxService.open(options);\n\n this.infoboxService.confirmed().subscribe((confirmed) => {\n //optional confirmation subscription\n });\n }\n\n openErrorDialog() {\n this.errorDialogService.openDialog({\n errorCode: '0xFFFFFF',\n location: 'floorplan-ai-service',\n devinfo: 'res.status === FAILED' /* Standard (falls verfügbar): error.message */,\n publicinfo:\n 'Der Grundriss konnte nicht verarbeitet werden.
    Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false /* Standardwert, nur für Entwickler zur Fehlersuche true */,\n autoFocus: false /* Standardwert */,\n });\n }\n}\n\n@Component({\n selector: 'example-modal',\n templateUrl: './helpers/example-modal/example-modal.html',\n styleUrls: ['./helpers/example-modal/example-modal.scss'],\n standalone: false\n})\nexport class ExampleModal {\n constructor(public dialog: MatDialog) {}\n\n closeDialog() {\n this.dialog.closeAll();\n }\n}\n\n/* @Component({\n selector: 'example-input-with-selector',\n templateUrl: './helpers/example-input-with-selector/example-input-with-selector.html',\n styleUrls: ['./helpers/example-input-with-selector/example-input-with-selector.scss'],\n})\nexport class ExampleInputWithUnitSelector implements OnInit {\n referenceValue: any;\n exampleUnits: any[] = [\n { value: 100, viewValue: 'cm' },\n { value: 1, viewValue: 'm' },\n ];\n\n formGroup: FormGroup;\n\n constructor() { }\n\n ngOnInit() {\n //set up form for wall height and attach it to floorplan object\n this.setFileForm();\n }\n\n setFileForm() {\n this.formGroup = new FormGroup(\n {\n inputValue: new FormControl(123),\n selectorValue: new FormControl('defaultValue', Validators.required),\n },\n\n );\n }\n\n\n //Validator to check if input value and mat-select value are valid in their combination\n\n crossFieldValidator(): ValidatorFn {\n return (control: AbstractControl): ValidationErrors | null => {\n const inputVal = control.get('inputValue').value;\n const selectorVal = control.get('selectorValue').value;\n\n if (!inputVal) {\n return null;\n }\n let someValidityCondition = (inputVal * selectorVal) > 5;\n\n return someValidityCondition ? null : { belowMinHeight: true };\n };\n }\n\n\n onChange($event) { };\n\n onInputChange($event) { };\n\n}\n */\n","
    \n
    \n

    Visual Units

    \n

    Übersicht visueller Standard-Komponenten aus HTML und CSS

    \n
    \n
    \n
    \n

    Dropdown

    \n

    \n This is our custom dropdown component which wraps a mat-select component as its core part.\n

    \n

    For usage details check out the DropdownConfiguration interface in the component.

    \n

    \n Note that while the mat-select needs to be overwritten by global styles, we keep them in the\n dropdown.component.scss. This is acchieved by importing the component styles in the global\n stylessheet and applying them to the host element in the @Component annotation in\n dropdown.component.ts. This is done because wrapping the dropdown styles inside the :host\n selector does not result in overwriting global Material styles\n

    \n
    \n
    \n
    \n
    \n

    Standard

    \n \n
    \n
    \n
    \n

    Scrollbar and overflowing Select-Option

    \n \n
    \n
    \n
    \n

    Disabled

    \n \n
    \n
    \n
    \n
    \n

    Standard Modal/Dialog

    \n

    \n Öffne den Dialog per Klick auf den Button, um einen Standard-Dialog auf Basis unserer\n modal-Klassen zu sehen.\n

    \n

    \n \n Unbedingt beachten: Angular Material ermöglicht es dem dialog ein config-Objekt zu\n übergeben.\n \n

    \n

    Liste der möglichen Properties:

    \n

    \n material.angular.io/components/dialog/api#MatDialogConfig\n

    \n

    \n Diese Möglichkeit sollte genutzt werden, um z.B. unerwünschten Auto-focus zu vermeinden, wie\n im folgenden Snippet. Angaben, wie width, die auch im CSS angegeben werden können bitte nur\n in Ausnahmefällen verwenden. Der Ursprung des Werts ist sonst schwer zu finden und in\n Dev-Tools gar nicht.\n

    \n
    \n    {{openDialog.toString()}}
    \n
    \n
    \n \n
    \n
    \n

    Infobox-Dialog

    \n

    \n Die Inhalte des Infobox-Dialog sind flexibel und müssen per infobox-dialog.service übergeben\n werden.\n

    \n

    Folgend die Properties des Beispiels.

    \n
    \n    {{openInfoboxDialog.toString()}}
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n

    Angular Material Buttons

    \n

    \n Das Prinzip der Angular material Buttons wurde auf die Bedürfnisse unserer Anwendung\n übertragen:\n https://material.angular.io/components/button\n

    \n

    \n Ein Button wir standardmäßig und ganz normal per HTML mit den unterschiedlichen Attribute\n Definitions und Klassenangaben integriert. Dabei müssen keine Veränderungen am CSS\n vorgenommen werden, um Farbe oder Größe individuell anzupassen..

    Beispiele (ohne\n die Einfärbung durch ein Theme):\n

    \n\n \n\n \n
    {{ code_matbutton }}
    \n
    \n\n \n\n \n
    {{ code_matflatbutton }}
    \n
    \n\n \n \n
    {{ code_matstrokedbutton }}
    \n
    \n\n

     

    \n

    \n Farben:\n

    \n\n

    \n Jeder Button kann dann per Attribute Definitions eingefärbt werden, in den\n 4 verfügbaren Farben (accent, primary, warn, disabled). Bei der disabled\n Variante sind zudem alle Stati/Funktionalitäten (Hover, Active, Klick-Ripple-Effekt)\n deaktiviert.

    Beispiel color=\"accent\":\n

    \n \n\n \n
    {{ code_matflatbutton_attributecolors_accent }}
    \n
    \n



    Beispiel color=\"primary\":

    \n \n\n \n
    {{ code_matflatbutton_attributecolors_primary }}
    \n
    \n\n

     

    \n

    \n Varianten:\n

    \n\n

    \n Insgesamt stehen 4 verschiedene Varianten an Buttons zur Verfügung (jeweils\n mit/ohne Icon):\n

    \n\n
      \n
    • \n mat-flat-button -> Flacher Button mit flächigem farbigen\n Hintergrund\n
    • \n
    • \n mat-stroked-button -> Outline Button mit farbiger border\n
    • \n
    • \n mat-button -> Button-Link mit farbigem Text und Ripple-Effekt bei\n Klick\n
    • \n
    • \n mat-icon-button -> Button ohne Texte, entweder mit oder ohne\n Hintergrund (siehe \"Only Icons\")\n
    • \n
    \n\n

     

    \n

    \n Icons:\n

    \n\n

    \n Zudem kann jeder Button (außer der mat-icon-button der immer eines dabei hat) mit einem\n Icon bzw. Material Icon (https://material.angular.io/components/icon/overview\n und\n https://fonts.google.com/icons)versehen werden.

    Beispiel:\n

    \n \n\n \n
    {{ code_matflatbutton_icon }}
    \n
    \n\n

     

    \n

    \n Only Icons :\n

    \n\n

    mat-icon-button ohne Hintergrund.

    Beispiel:

    \n\n \n\n \n
    {{ code_maticonbutton }}
    \n
    \n

     

    \n\n

    \n mat-icon button mit Hintergrund (hier muss class=\"icon-button-bg\"\n hinzugefügt werden).

    Beispiel:\n

    \n\n \n\n \n
    {{ code_maticonbutton_bg }}
    \n
    \n\n

     

    \n

    \n Button Sizes:\n

    \n

    \n Zudem gibt es 4 verschiedene Buttongrößen (hier muss class=\"button-size-xl\" hinzugefügt\n werden).

    Beispiel:\n

    \n\n \n \n
    {{ code_matbutton_size }}
    \n
    \n\n

    \n
    \n
    \n
    \n
    \n

    \n Buttontyp:    accent     |     primary\n     |     warn\n     |     disabled\n

    \n
    \n\n

    \n mat-flat-button\n \n \n \n \n

    \n

    \n mat-flat-button\n \n \n \n \n

    \n

    \n mat-stroked-button\n \n \n \n \n

    \n

    \n mat-stroked-button\n \n \n \n \n

    \n

    \n mat-button\n \n \n \n \n

    \n\n

    \n mat-button\n \n \n \n \n

    \n

    \n mat-icon-button\n \n \n \n \n

    \n

    \n mat-icon-button\n \n \n \n \n

    \n

     

    \n

    \n Button Sizes:\n

    \n

    \n .button-size-xl\n \n \n \n

    \n

    \n .button-size-l\n \n \n \n

    \n

    \n Default\n \n \n

    \n \n

    \n .button-size-s\n \n \n \n

    \n
    \n
    \n\n
    \n

    CSS Shadows

    \n

    Schattendefinitionen über Mixins.

    \n\n
    \n        @include shadow-2;\n      
    \n
    \n
    \n
    \n

    \n @include shadow-0\n @include shadow-2\n @include shadow-2-inset\n @include shadow-4\n @include shadow-8\n @include shadow-16\n @include shadow-24\n

    \n
    \n
    \n
    \n

    Basic Tooltips

    \n

    \n Die Tooltips aus Angular Material (https://material.angular.io/components/tooltip/overview)\n werden über folgende drei Optionen gesteuert:\n

    \n \n matTooltip=\"Tooltip Erklärungstext\"
    \n matTooltipClass=\"tooltip-icon | tooltip-definition | tooltip-interactive\"
    \n matTooltipPosition=\"above | below | left | right | before | after\"
    \n
    \n

    \n

    \n

    Icon Tooltip

    \n

    \n Ein Icon-Tooltip wird verwendet, um die Aktion oder den Namen einer interaktiven\n Icon-Schaltfläche zu verdeutlichen. Dieser besteht nur aus wenigen Worten, bestenfalls nur\n einem (maximal 2-3).\n

    \n

    \n

    Definition Tooltips

    \n

    \n Der Definitionstooltip bietet zusätzliche Hilfe oder definiert ein Element oder einen\n Begriff.\n

    \n
    \n
    \n \n \n Icon & above\n \n info\n \n \n \n Icon & below\n \n info\n \n \n \n Definition & left\n \n info\n \n \n \n Definition & right\n \n info\n \n \n \n
    \n\n
    \n

    HTML/Interactive Tooltips

    \n

    \n ! Bisherige Lösung mittels ng-tippy ist veraltet. Der Code dafür ist noch im auskommentiert\n hier im Templat enthalten. Bei Bedarf könnte er vielleicht wiederverwendet werden, falls\n künftig tippy.js direkt verwendet wrden soll.\n

    \n \n
    \n
    \n \n
    \n
    \n

    Input mit Dropdown für Einheit (IN ARBEIT)

    \n

    Eingebunden über Komponente example-input-with-selector in helpers.

    \n
    \n
    \n \n
    \n
    \n

    Toggle Button

    \n

    [Beschreibung]

    \n
    \n
    \n \n
    \n

    XYZ anzeigen

    \n
    \n
    \n
    \n

    Typography-Levels

    \n

    \n Unsere Standardgrößen für Fonts sind im Frontend über Typography-Levels umgesetzt, wie sie\n Angular-Material verwendet.\n

    \n

    \n Sie sind unterteilt in Heading- und Body-Levels. Heading- und Body-Levels unterscheiden sich\n grundsätzlich in line-heights und font-weights.\n

    \n

    \n Der Einsatz der Levels kann einerseits über die zuweisung zu Angular Material\n Standard-Levels erfolgen, sodass Material unsere levels in seine Standard-Klassen\n miteinbeiht. Andererseits können wir sie per Mixins einsetzen: @mixin\n get-level-styles($level-name, $important: '').\n

    \n
    \n
    \n
    \n

    \n

    \n

    \n

    \n

    \n

    \n

    \n

    \n

    \n

    \n
    \n
    \n
    \n

    Alerts

    \n
    \n
    \n

    Base Alerts

    \n \n\n \n\n \n\n \n\n \n\n

    Hidden Icons

    \n \n\n \n\n \n\n \n\n \n\n

    Collapsed Icons

    \n \n\n \n\n \n\n \n\n \n\n

    Only Text

    \n \n\n \n\n \n\n \n\n \n\n

    Only Title

    \n \n\n \n\n \n\n \n\n \n
    \n\n
    \n

    Wohnstil Label

    \n
    <span class=\"badge-small\">Natürlich</span>
    \n
    <span class=\"badge-medium\">Natürlich</span>
    \n
    \n
    \n
    \n Natürlich\n Natürlich\n
    \n
    \n\n
    \n

    Information Label

    \n
    <span class=\"info-label-transparent\">INFO</span>
    \n
    <span class=\"info-label-black\">INFO</span>
    \n
    <span class=\"info-label-black\">INFO</span>
    \n
    \n
    \n
    \n INFO\n INFO\n INFO\n
    \n
    \n\n
    \n

    [Bezeichnung]

    \n

    [Beschreibung]

    \n
    \n
    [Code der visuellen Komponente]
    \n
    \n\n","
    \n
    \n \n
    \n T ÜÄÖ Titel mittellange Überschrift\n ÜÄÖ gypq lorem ipsum dolor si amet\n
    \n
    \n close\n
    \n
    \n
    \n

    TÜÄÖ Titel Das ist ein Untertitel

    \n

    \n TÜÄÖ Titelgypq Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula\n eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes,\n nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.\n Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,\n arcu.ÜÄÖ gypq TÜÄÖ Titelgypq Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean\n commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient\n montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium\n quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec,\n vulputate eget, arcu.ÜÄÖ gypq TÜÄÖ Titelgypq Lorem ipsum dolor sit amet, consectetuer\n adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus\n et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec,\n pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo,\n fringilla vel, aliquet nec, vulputate eget, arcu.ÜÄÖ gypq TÜÄÖ Titelgypq Lorem ipsum dolor sit\n amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis\n natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis,\n ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede\n justo, fringilla vel, aliquet nec, vulputate eget, arcu.ÜÄÖ gypq TÜÄÖ Titelgypq Lorem ipsum\n dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.\n Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec\n quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis\n enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.ÜÄÖ gypq TÜÄÖ\n Titelgypq Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget\n dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur\n ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla\n consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,\n arcu.ÜÄÖ gypq TÜÄÖ Titelgypq Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean\n commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient\n montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium\n quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec,\n vulputate eget, arcu.ÜÄÖ gypq\n

    \n
    \n
    \n \n \n
    \n
    \n","import { Injectable } from '@angular/core';\nimport { PreloadingStrategy, Route } from '@angular/router';\nimport { Observable, of } from 'rxjs';\n@Injectable({\n providedIn: 'root',\n})\nexport class PreloadingStrategyService implements PreloadingStrategy {\n preload(route: Route, fn: () => Observable): Observable {\n if (route.data && route.data.preload) {\n return fn();\n }\n return of(null);\n }\n}\n","import { NgModule } from '@angular/core';\nimport { RouterModule, Routes } from '@angular/router';\n\nimport { environment } from '../environments/environment';\nimport { APP_PATHS } from './route-paths';\n\nimport { DownloadComponent } from './components/download/download.component';\nimport { ManufacturerComponent } from './components/manufacturer/manufacturer.component';\nimport { LoginComponent } from './components/signup/login/login.component';\nimport { RequestPasswordResetComponent } from './components/signup/login/request-password-reset/request-password-reset.component';\nimport { ResetPasswordComponent } from './components/signup/login/reset-password/reset-password.component';\nimport { ConfirmationComponent } from './components/signup/register/confirmation/confirmation.component';\nimport { RegisterComponent } from './components/signup/register/register.component';\nimport { VisualUnitsComponent } from './components/visual-units/visual-units.component';\n\nimport { AuthGuard } from './auth.guard';\nimport { OnboardingScreenGuard } from './onboarding-screen.guard';\nimport { ConfigurationResolverService } from './resolvers/configuration-resolver.service';\nimport { PreloadingStrategyService } from './services/preloading-strategy.service';\nimport { UserGroupGuard } from './user-group.guard';\nimport { FEATURE_FLAGS } from './shared/constants/feature-flags.constants';\nimport { FeatureFlagGuard } from './feature-flag.guard';\n\nconst routes: Routes = [\n {\n path: APP_PATHS.assetCatalog,\n canActivate: [AuthGuard, UserGroupGuard, OnboardingScreenGuard],\n resolve: { configurationId: ConfigurationResolverService },\n data: {\n preload: false,\n userGroup: environment.FINGERHAUS_ADMIN_GROUP.concat(environment.FINGERHAUS_BUILDER)\n // currently added non-ai groups to this route instead of dashboard\n .concat(environment.PORTER_MANUFACTURER_GROUPS)\n .concat(environment.STREAMING_LICENCE_GROUP)\n .concat(environment.PORTER_LICENCE_GROUPS),\n onboardingScreenGroup: environment.FINGERHAUS_BUILDER,\n },\n loadChildren: () =>\n import('./modules/asset-catalog-web-wrapper/asset-catalog-web-wrapper.module').then(\n (m) => m.AssetCatalogWebWrapperModule\n ),\n },\n\n {\n path: APP_PATHS.onboardingScreen,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n userGroup: environment.FINGERHAUS_ADMIN_GROUP.concat(environment.FINGERHAUS_BUILDER)\n .concat(environment.FINGERHAUS_PRODUCT_MANAGEMENT_GROUP)\n .concat(environment.FINGERHAUS_CONSULTANT_GROUP),\n },\n loadChildren: () =>\n import('./modules/onboarding-screen/onboarding-screen.module').then(\n (m) => m.OnboardingScreenModule\n ),\n },\n\n {\n path: APP_PATHS.assetCatalogOnly,\n canActivate: [AuthGuard, UserGroupGuard],\n resolve: { configurationId: ConfigurationResolverService },\n data: {\n preload: false,\n userGroup: environment.PORTER_LICENCE_GROUPS,\n },\n loadChildren: () =>\n import('./modules/asset-catalog-only-wrapper/asset-catalog-only-wrapper.module').then(\n (m) => m.AssetCatalogOnlyWrapperModule\n ),\n },\n\n {\n path: APP_PATHS.assetManagement,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n preload: false,\n userGroup: environment.FINGERHAUS_ADMIN_GROUP.concat(\n environment.FINGERHAUS_PRODUCT_MANAGEMENT_GROUP\n ).concat(environment.FINGERHAUS_CONSULTANT_GROUP),\n },\n loadChildren: () =>\n import('./modules/article-management/article-management.module').then(\n (m) => m.ArticleManagementModule\n ),\n },\n {\n path: APP_PATHS.buildingProjects,\n canActivate: [AuthGuard, FeatureFlagGuard],\n data: {\n preload: false,\n featureFlag: FEATURE_FLAGS.buildingProjectsOverview,\n },\n loadChildren: () =>\n import('./modules/building-projects/building-projects.module').then(\n (m) => m.BuildingProjectsModule\n ),\n },\n {\n path: APP_PATHS.visualization,\n canActivate: [AuthGuard, FeatureFlagGuard],\n data: {\n preload: false,\n featureFlag: FEATURE_FLAGS.pixelStreaming,\n },\n loadChildren: () =>\n import('./modules/visualization/visualization.module').then(\n (m) => m.VisualizationModule\n ),\n },\n\n {\n path: APP_PATHS.service,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n preload: false,\n userGroup: environment.PORTER_LICENCE_GROUPS,\n },\n loadChildren: () => import('./modules/service/service.module').then((m) => m.ServiceModule),\n },\n\n {\n path: APP_PATHS.floorPlans,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n preload: false,\n breadcrumb: 'PORTER Grundrisse Dashboard',\n userGroup: environment.AI_LICENCE_GROUPS,\n },\n loadChildren: () =>\n import('./modules/porter-floor-plans/porter-floor-plans.module').then(\n (m) => m.PorterFloorPlansModule\n ),\n },\n\n {\n path: APP_PATHS.projects,\n canActivate: [AuthGuard],\n data: {\n preload: false,\n breadcrumb: 'PORTER Bemusterung Projektübersicht',\n },\n loadChildren: () =>\n import('./modules/porter-bemusterung/porter-bemusterung.module').then(\n (m) => m.PorterBemusterungModule\n ),\n },\n\n {\n path: APP_PATHS.login,\n component: LoginComponent,\n canActivate: [AuthGuard],\n data: {\n breadcrumb: 'PORTER Login',\n },\n },\n\n {\n path: APP_PATHS.manufacturers,\n component: ManufacturerComponent,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n breadcrumb: 'PORTER Hersteller',\n },\n },\n\n {\n path: APP_PATHS.register,\n component: RegisterComponent,\n data: {\n breadcrumb: 'PORTER Registrierung',\n },\n },\n\n {\n path: APP_PATHS.reset,\n data: {\n breadcrumb: 'PORTER Passwort zurücksetzen',\n },\n children: [\n {\n path: ':token',\n component: ResetPasswordComponent,\n },\n {\n path: '',\n component: RequestPasswordResetComponent,\n },\n ],\n },\n\n {\n path: APP_PATHS.confirmation,\n component: ConfirmationComponent,\n data: {\n breadcrumb: 'PORTER Account aktivieren',\n },\n },\n\n {\n path: APP_PATHS.appLink,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n breadcrumb: 'PORTER Desktop Solution starten',\n userGroup: environment.PORTER_LICENCE_GROUPS.concat([environment.adminGroup]),\n },\n loadChildren: () => import('./modules/app-link/app-link.module').then((m) => m.AppLinkModule),\n },\n\n {\n path: APP_PATHS.download,\n component: DownloadComponent,\n data: {\n breadcrumb: 'PORTER Download',\n },\n },\n\n {\n path: APP_PATHS.visualUnits,\n component: VisualUnitsComponent,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n userGroup: [environment.adminGroup].concat(environment.FINGERHAUS_ADMIN_GROUP),\n breadcrumb: 'PORTER Visual Units',\n },\n },\n\n {\n path: APP_PATHS.webProtocol,\n canActivate: [AuthGuard, UserGroupGuard],\n data: {\n preload: false,\n breadcrumb: 'PORTER Bemusterungs-Protokoll',\n userGroup: environment.PORTER_LICENCE_GROUPS,\n },\n loadChildren: () =>\n import('./modules/web-protocol/web-protocol.module').then((m) => m.WebProtocolModule),\n },\n\n // redirect empty url to produkt-katalog\n {\n path: '',\n pathMatch: 'full',\n redirectTo: '/grundrisse',\n },\n\n // catch all route (= \"wildcard route\"), if the route doesn't match any of the others\n {\n // TODO: reactivate instead of redirect once dashboard is functional\n path: '**',\n // canActivate: [AuthGuard, UserGroupGuard],\n redirectTo: '/grundrisse',\n // data: {\n // userGroup: environment.PORTER_LICENCE_GROUPS.concat(environment.PORTER_MANUFACTURER_GROUPS)\n // .concat(environment.STREAMING_LICENCE_GROUP)\n // .concat(environment.AI_LICENCE_GROUPS)\n // .concat([environment.adminGroup]),\n // },\n // loadChildren: () =>\n // import('./modules/asset-catalog-web-wrapper/asset-catalog-web-wrapper.module').then(\n // (m) => m.AssetCatalogWebWrapperModule\n // ),\n },\n];\n\n@NgModule({\n imports: [\n RouterModule.forRoot(routes, {\n preloadingStrategy: PreloadingStrategyService\n}),\n ],\n exports: [RouterModule],\n})\nexport class AppRoutingModule {}\n","import { Injectable } from '@angular/core';\nimport {\n HttpEvent,\n HttpHandler,\n HttpInterceptor,\n HttpRequest,\n HttpErrorResponse,\n} from '@angular/common/http';\nimport { Router } from '@angular/router';\nimport { Observable, throwError } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\nimport { AuthService } from '../services/auth.service';\nimport { TokenService } from '../services/token.service';\nimport { MatDialog } from '@angular/material/dialog';\n\n@Injectable()\nexport class AuthInterceptor implements HttpInterceptor {\n constructor(\n private router: Router,\n private authService: AuthService,\n private tokenService: TokenService,\n private matDialog: MatDialog\n ) {}\n\n intercept(req: HttpRequest, next: HttpHandler): Observable> {\n const token = this.tokenService.getToken();\n\n if (token.value && !req.headers.get('Authorization')) {\n const headers = req.headers.set('Authorization', `Bearer ${token.value}`);\n req = req.clone({ headers: headers });\n }\n\n return next.handle(req).pipe(\n catchError((err) => {\n if (err instanceof HttpErrorResponse && err.status === 401) {\n this.authService.logout();\n // why is grundrisse a special case?\n if (window.location.pathname !== '/login' && window.location.pathname !== '/grundrisse') {\n this.matDialog.closeAll();\n this.router\n .navigate(['/login'], {\n queryParams: {\n returnUrl: window.location.pathname + window.location.search,\n sessionLost: true,\n },\n })\n .catch((navErr) => console.error(navErr));\n }\n }\n\n return throwError(err);\n })\n );\n }\n}\n","export const DUPLICATE_PRODUCT = {\n errorCode: '0xASSET1',\n location: 'Produkt anlegen',\n devinfo: '',\n publicinfo:\n 'Ein Produkt des gewählten Herstellers mit der angegebenen Hersteller-Artikelnummer wurde bereits erstellt.',\n debug: false,\n autoFocus: false,\n};\n\nexport const DIAF_EXPORT_MANUFACTURER_NOT_FOUND = {\n errorCode: '0xDIAFE1',\n location: 'DIAF request',\n devinfo: 'Manufacturer not found',\n publicinfo:\n 'Dieses Produkt konnte auf Grund eines Fehlers nicht exportiert werden.
    Bei Fragen wenden Sie sich bitte direkt an unseren
    Support.',\n debug: false,\n autoFocus: false,\n};\n\nexport const DIAF_EXPORT_MANUFACTURER_HAS_NO_DIAF_ID = {\n errorCode: '0xDIAFE2',\n location: 'DIAF request',\n devinfo: 'Manufacturer has no DIAF-Id',\n publicinfo:\n 'Dieses Produkt konnte auf Grund eines Fehlers nicht exportiert werden.
    Bei Fragen wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nexport const DIAF_EXPORT_MISSING_PARAMETERS_IN_DIAF_REQUEST = {\n errorCode: '0xDIAFE3',\n location: 'DIAF request',\n devinfo: 'Missing request parameters',\n publicinfo:\n 'Dieses Produkt konnte auf Grund eines Fehlers nicht exportiert werden.
    Bei Fragen wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nexport const FAILED_DIAF_REQUEST = {\n errorCode: '0xDIAFE4',\n location: 'DIAF export',\n devinfo: 'Error returned from DIAF',\n publicinfo:\n 'Die DIAF-Anfrage ist fehlgeschlagen.
    Bei Fragen wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nexport const DUPLICATE_REGISTRATION = {\n errorCode: '0xFFFFFF',\n location: 'register',\n devinfo: '',\n publicinfo:\n 'Für diese E-Mail-Adresse wurde bereits ein Nutzer registriert. Bitte nutzen Sie den Login um sich anzumelden oder wenden Sie sich an unseren Support. Vielen Dank.',\n debug: false,\n autoFocus: false,\n};\n\nexport const INVALID_FLOOR_PLAN_CONVERSION = {\n errorCode: '0xA12730',\n location: '/grundrisse/grundriss-editor',\n devinfo: '',\n publicinfo:\n 'Diese Umwandlungs ID ist ungültig.
    Mögliche Lösungen finden Sie in unserem Help- & Supportcenter. Bestehen dann noch Fragen, wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nexport const NO_FLOOR_PLAN_CONVERSION = {\n errorCode: '0xFFFFFF',\n location: 'dashboard - getFirstPageOfLatestUserConversions',\n devinfo: '',\n publicinfo:\n 'Sie haben noch keine Grundriss-Umwandlungen. Bitte laden Sie einen ersten Grundriss hoch.',\n debug: false,\n autoFocus: false,\n};\n\nexport const NO_BUILDING_PROJECT = {\n errorCode: '0xFFFFFF',\n location: 'configuration service - getConfigurationByCode',\n devinfo: '',\n publicinfo:\n 'Es liegt kein Bauvorhaben für diese BV-Nummer vor.

    Bei Fragen wenden Sie sich bitte direkt an unseren Support.',\n debug: false,\n autoFocus: false,\n};\n\nexport const FAILED_DIAF_EXPORT_WITH_DUPLICATE_PRODUCT_NUMBER: any = {\n icon: 'cancel',\n iconColor: 'warn',\n title: 'Produkt existiert bereits in DIAF',\n buttonText: 'Okay',\n text: 'Dieses Produkt wurde nicht exportiert, weil in DIAF bereits ein Produkt mit gleicher Produktdatennummer vorhanden ist.',\n};\n\nexport const FAILED_DIAF_EXPORT_WITH_DUPLICATE_MANUFACTURER_PRODUCT: any = {\n icon: 'cancel',\n iconColor: 'warn',\n title: 'Produkt existiert bereits in DIAF',\n buttonText: 'Okay',\n text: 'Dieses Produkt wurde nicht exportiert. In DIAF ist bereits ein Produkt des gewählten Herstellers mit der angegebenen Hersteller-Artikelnummer vorhanden.',\n};\n\nexport const FAILED_DIAF_EXPORT_WITH_MANUFACTURER_NOT_PRESENT: any = {\n icon: 'cancel',\n iconColor: 'warn',\n title: 'Hersteller nicht vorhanden',\n buttonText: 'Okay',\n text: 'Dieses Produkt wurde nicht exportiert. In DIAF ist der gewählte Hersteller nicht vorhanden.',\n};","import { Injectable } from '@angular/core';\nimport { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpErrorResponse } from '@angular/common/http';\nimport { Observable, throwError } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\nimport { ErrorDialogService } from '../services/errordialog.service';\nimport { InfoboxDialogService } from '../services/infobox-dialog.service';\nimport {\n DUPLICATE_PRODUCT,\n DUPLICATE_REGISTRATION,\n FAILED_DIAF_EXPORT_WITH_DUPLICATE_MANUFACTURER_PRODUCT,\n FAILED_DIAF_EXPORT_WITH_DUPLICATE_PRODUCT_NUMBER,\n FAILED_DIAF_REQUEST,\n INVALID_FLOOR_PLAN_CONVERSION,\n DIAF_EXPORT_MANUFACTURER_HAS_NO_DIAF_ID,\n DIAF_EXPORT_MANUFACTURER_NOT_FOUND,\n DIAF_EXPORT_MISSING_PARAMETERS_IN_DIAF_REQUEST,\n NO_BUILDING_PROJECT,\n NO_FLOOR_PLAN_CONVERSION,\n FAILED_DIAF_EXPORT_WITH_MANUFACTURER_NOT_PRESENT,\n} from './error.interceptor.data';\n\n@Injectable()\nexport class ErrorInterceptor implements HttpInterceptor {\n private interceptedError: any;\n private expectedErrorOccured: boolean;\n\n constructor(\n private readonly errorDialogService: ErrorDialogService,\n private readonly infoboxDialogService: InfoboxDialogService\n ) {}\n\n intercept(req: HttpRequest, next: HttpHandler): Observable> {\n return next.handle(req).pipe(\n catchError((error) => {\n this.interceptedError = error;\n this.expectedErrorOccured = false;\n\n if (this.isHttpError() && this.shouldShowErrors()) {\n this.showGeneralErrors();\n this.showFloorPlanErrors();\n this.showBuildingProjectErrors();\n this.showDiafErrors();\n this.showUnexpectedErrors();\n }\n\n return throwError(this.interceptedError);\n })\n );\n }\n\n private isHttpError(): boolean {\n return this.interceptedError instanceof HttpErrorResponse;\n }\n\n private shouldShowErrors() {\n return !(this.isMissingToken() || this.isOnLoginPage() || this.isDiafRequest() || this.isConfigurationErrorOnWrongPage());\n }\n\n private showGeneralErrors() {\n if (this.isDuplicateRegistrationError()) {\n this.showError(DUPLICATE_REGISTRATION);\n }\n\n if (this.isDuplicateProduct()) {\n this.showError(DUPLICATE_PRODUCT);\n }\n\n if (this.hasNoManufacturer()) {\n this.showError(DIAF_EXPORT_MANUFACTURER_NOT_FOUND);\n }\n }\n\n private showFloorPlanErrors() {\n if (this.isInvalidFloorPlanConversion()) {\n this.showError(INVALID_FLOOR_PLAN_CONVERSION);\n }\n\n if (this.isFloorPlanConversionNotPresent()) {\n this.showError(NO_FLOOR_PLAN_CONVERSION);\n }\n }\n\n private showBuildingProjectErrors() {\n if (this.hasNoBuildingProject()) {\n this.showError(NO_BUILDING_PROJECT);\n }\n }\n\n private showDiafErrors() {\n if (this.manufacturerHasNoDiafId()) {\n this.showError(DIAF_EXPORT_MANUFACTURER_HAS_NO_DIAF_ID);\n }\n\n if (this.hasMissingParametersInDiafRequest()) {\n this.showError(DIAF_EXPORT_MISSING_PARAMETERS_IN_DIAF_REQUEST);\n }\n\n if (this.isDiafSystemError()) {\n if (this.isDiafProductNumberAlreadyPresent()) {\n this.showInfo(FAILED_DIAF_EXPORT_WITH_DUPLICATE_PRODUCT_NUMBER);\n } else if (this.isManufacturerAndManufacturerArticleNumberAlreadyPresent()) {\n this.showInfo(FAILED_DIAF_EXPORT_WITH_DUPLICATE_MANUFACTURER_PRODUCT);\n } else if (this.isManufacturerNotPresent()){\n this.showInfo(FAILED_DIAF_EXPORT_WITH_MANUFACTURER_NOT_PRESENT) \n } else {\n this.showError(FAILED_DIAF_REQUEST);\n }\n }\n }\n\n private showUnexpectedErrors() {\n if (!this.expectedErrorOccured) {\n if (this.isValidError()) {\n this.showError(this.interceptedError.error);\n } else {\n this.showError(this.buildUnknownErrorMessage());\n }\n }\n }\n\n private isMissingToken() {\n return this.interceptedError.error.errorCode === '0xPAVRR5';\n }\n private isOnLoginPage() {\n return window.location.pathname === '/login';\n }\n\n private isDiafRequest() {\n // don't show error dialog on DIAF request\n // TODO: Remove this if in backend the return object includes the error message instead of a thrown 404 error\n // TODO: error texts from DIAF change over time, previous ones are kept inside the condition just in case\n return (\n this.interceptedError.status == 404 &&\n (this.interceptedError.error.error == 'Artikel_Nr Hersteller nicht vorhanden' ||\n this.interceptedError.error.error == 'Artikelnr . nicht vorhanden' ||\n this.interceptedError.error.error == 'Kein Artikel für Hersteller vorhanden' ||\n this.interceptedError.error.error == 'Artikel_Nr zum Hersteller nicht vorhanden')\n );\n }\n\n private isDuplicateRegistrationError() {\n return window.location.pathname === '/register' && this.interceptedError.status == 409;\n }\n\n private isDuplicateProduct() {\n return this.interceptedError.error.errorCode == '0xASSET1';\n }\n\n private buildUnknownErrorMessage() {\n const errorMessage = this.interceptedError.message || 'Unknown Error';\n const supportMessage =\n '

    Bei Fragen wenden Sie sich bitte direkt an unseren Support.';\n const message = errorMessage + supportMessage;\n return {\n errorCode: '0xFFFFFF',\n location: '',\n devinfo: '',\n publicinfo: message,\n debug: false,\n autoFocus: false,\n };\n }\n\n private isValidError() {\n return (\n this.interceptedError.error != undefined && this.interceptedError.error.errorCode != undefined\n );\n }\n\n private hasNoBuildingProject() {\n // TODO: Refactor condition\n return (\n /^\\/bauvorhaben\\/\\d+\\/merkliste$/.test(window.location.pathname) &&\n this.interceptedError.status == 403\n );\n }\n\n private isFloorPlanConversionNotPresent() {\n return (\n window.location.pathname === '/grundrisse/grundriss-editor' &&\n this.interceptedError.status == 500\n );\n }\n\n private isInvalidFloorPlanConversion() {\n return (\n window.location.pathname === '/grundrisse/grundriss-editor' &&\n this.interceptedError.status == 404\n );\n }\n\n private isConfigurationErrorOnWrongPage(): boolean {\n const errorMessage = 'No base configuration was found for user';\n // TODO Move window.location.pathname to navigation service\n const currentPath = window.location.pathname;\n return this.interceptedError.error.message === errorMessage && \n (currentPath === '/app-link' || currentPath === '/service/authentication' || currentPath === '/projects' || currentPath.includes('/grundrisse'));\n }\n\n private isManufacturerAndManufacturerArticleNumberAlreadyPresent() {\n // The following error is also returned if in addition to manufacturer and manufacurerUuId also productDataId already exists\n return (\n this.interceptedError.error.devinfo == 'Hersteller und Hersteller-Artikelnr bereits vorhanden'\n );\n }\n\n private isDiafProductNumberAlreadyPresent(): boolean {\n return this.interceptedError.error.devinfo == 'Produktdatennummer bereits vorhanden';\n }\n\n private isManufacturerNotPresent(): boolean {\n return this.interceptedError.error.devinfo == 'Hersteller nicht vorhanden';\n }\n\n private hasNoManufacturer(): boolean {\n return this.interceptedError.error.errorCode == '0xDIAFE1';\n }\n\n private manufacturerHasNoDiafId(): boolean {\n return this.interceptedError.error.errorCode == '0xDIAFE2';\n }\n\n private hasMissingParametersInDiafRequest(): boolean {\n return this.interceptedError.error.errorCode == '0xDIAFE3';\n }\n\n private isDiafSystemError(): boolean {\n return this.interceptedError.error.errorCode == '0xDIAFE4';\n }\n\n private showInfo(data: any) {\n this.expectedErrorOccured = true;\n this.infoboxDialogService.open(data);\n }\n\n private showError(data: any) {\n this.expectedErrorOccured = true;\n this.errorDialogService.openDialog(data);\n }\n}\n","import { DragDropModule } from '@angular/cdk/drag-drop';\r\nimport { LayoutModule } from '@angular/cdk/layout';\r\nimport { CommonModule, DatePipe } from '@angular/common';\r\nimport { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';\r\nimport {\r\n APP_INITIALIZER,\r\n CUSTOM_ELEMENTS_SCHEMA,\r\n DEFAULT_CURRENCY_CODE,\r\n ErrorHandler,\r\n NgModule,\r\n inject,\r\n provideAppInitializer,\r\n} from '@angular/core';\r\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\r\nimport { BrowserModule } from '@angular/platform-browser';\r\nimport { BrowserAnimationsModule } from '@angular/platform-browser/animations';\r\nimport { Router } from '@angular/router';\r\n\r\nimport '@angular/common/locales/global/de';\r\n\r\n// Material Design Components\r\nimport { MatAutocompleteModule } from '@angular/material/autocomplete';\r\nimport { MatBadgeModule } from '@angular/material/badge';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatButtonToggleModule } from '@angular/material/button-toggle';\r\nimport { MatCardModule } from '@angular/material/card';\r\nimport { MatCheckboxModule } from '@angular/material/checkbox';\r\nimport { MatChipsModule } from '@angular/material/chips';\r\nimport { MatNativeDateModule, MatRippleModule } from '@angular/material/core';\r\nimport { MatDatepickerModule } from '@angular/material/datepicker';\r\nimport { MatDialogModule } from '@angular/material/dialog';\r\nimport { MatDividerModule } from '@angular/material/divider';\r\nimport { MatExpansionModule } from '@angular/material/expansion';\r\nimport { MatGridListModule } from '@angular/material/grid-list';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatListModule } from '@angular/material/list';\r\nimport { MatMenuModule } from '@angular/material/menu';\r\nimport { MatPaginatorModule } from '@angular/material/paginator';\r\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\r\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\r\nimport { MatRadioModule } from '@angular/material/radio';\r\nimport { MatSelectModule } from '@angular/material/select';\r\nimport { MatSidenavModule } from '@angular/material/sidenav';\r\nimport { MatSlideToggleModule } from '@angular/material/slide-toggle';\r\nimport { MatSliderModule } from '@angular/material/slider';\r\nimport { MatSnackBarModule } from '@angular/material/snack-bar';\r\nimport { MatSortModule } from '@angular/material/sort';\r\nimport { MatStepperModule } from '@angular/material/stepper';\r\nimport { MatTableModule } from '@angular/material/table';\r\nimport { MatTabsModule } from '@angular/material/tabs';\r\nimport { MatToolbarModule } from '@angular/material/toolbar';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\n\r\n// 3D Party\r\nimport * as Sentry from '@sentry/angular';\r\nimport { ClipboardModule } from 'ngx-clipboard';\r\n\r\nimport { AppComponent } from './components/app.component';\r\nimport { LoginComponent } from './components/signup/login/login.component';\r\n\r\nimport { ErrorDialogComponent } from './components/dialogs/errordialog/errordialog.component';\r\nimport { StreamDialogComponent } from './components/dialogs/stream-dialog/stream-dialog.component';\r\nimport { DownloadComponent } from './components/download/download.component';\r\nimport { RequestPasswordResetComponent } from './components/signup/login/request-password-reset/request-password-reset.component';\r\nimport { ResetPasswordComponent } from './components/signup/login/reset-password/reset-password.component';\r\nimport { ConfirmationComponent } from './components/signup/register/confirmation/confirmation.component';\r\nimport { RegisterComponent } from './components/signup/register/register.component';\r\nimport { TermsOfServiceComponent } from './components/signup/register/terms-of-service/terms-of-service.component';\r\nimport {\r\n ExampleModal,\r\n VisualUnitsComponent,\r\n} from './components/visual-units/visual-units.component';\r\n\r\n// Services\r\nimport { AssetService } from './services/asset.service';\r\nimport { BuildingService } from './services/building.service';\r\nimport { DateService } from './services/date.service';\r\nimport { UniversalDeviceDetectorService } from './services/device-detector.service';\r\nimport { EnvironmentService } from './services/environment.service';\r\nimport { ErrorDialogService } from './services/errordialog.service';\r\nimport { ExporterPluginService } from './services/exporter-plugin.service';\r\nimport { FilteredArticlesService } from './services/filtered-articles.service';\r\nimport { FloorplanAIService } from './services/floorplan-ai.service';\r\nimport { FloorplanService } from './services/floorplan.service';\r\nimport { FloorplannerService } from './services/floorplanner.service';\r\nimport { InfoboxDialogService } from './services/infobox-dialog.service';\r\nimport { InputFileService } from './services/input-file.service';\r\nimport { LevelService } from './services/level.service';\r\nimport { NavigationHistoryService } from './services/navigation-history.service';\r\nimport { NavigationService } from './services/navigation.service';\r\nimport { ProjectService } from './services/project.service';\r\nimport { ReleaseNotesService } from './services/releasenotes.service';\r\nimport { SchemaPropertiesService } from './services/schema-properties.service';\r\nimport { SchemasService } from './services/schemas.service';\r\nimport { ScreenshotService } from './services/screenshot.service';\r\nimport { StreamingService } from './services/streaming.service';\r\nimport { TokenService } from './services/token.service';\r\nimport { TwoActionsDialogService } from './services/two-actions-dialog.service';\r\nimport { UnitService } from './services/unit.service';\r\nimport { UnrealService } from './services/unreal.service';\r\nimport { UrlService } from './services/url.service';\r\nimport { UtilityService } from './services/utility.service';\r\nimport { VersionService } from './services/version.service';\r\n\r\n// Resolvers\r\nimport { ConfigurationResolverService } from './resolvers/configuration-resolver.service';\r\n\r\n// Routing\r\nimport { AppRoutingModule } from './app-routing.module';\r\n\r\n// Shared Module\r\nimport { SharedModule } from './shared/shared.module';\r\n\r\n// TODO: Core Modules?\r\nimport { AuthGuard } from './auth.guard';\r\nimport { ExportPluginGuard } from './export-plugin.guard';\r\nimport { SalesGuard } from './sales.guard';\r\nimport { UserGroupGuard } from './user-group.guard';\r\n\r\n// Interceptors\r\nimport { AuthInterceptor } from './interceptors/auth.interceptor';\r\nimport { ErrorInterceptor } from './interceptors/error.interceptor';\r\n\r\nimport { AppInitializeService } from './services/app-initialize.service';\r\n\r\n// Pipes\r\nimport { FloorplanFetchPipe } from './pipes/floorplan-fetch.pipe';\r\nimport { ScreenshotFetchPipe } from './pipes/screenshot-fetch.pipe';\r\n\r\nimport { InfoboxDialogComponent } from './components/dialogs/infobox-dialog/infobox-dialog.component';\r\nimport { SignupHeaderComponent } from './components/signup/signup-header/signup-header.component';\r\n\r\nimport { TraceService } from '@sentry/angular';\r\nimport { ClosingDialogComponent } from './components/dialogs/closing-dialog/closing-dialog.component';\r\nimport { TwoActionsDialogComponent } from './components/dialogs/two-actions-dialog/two-actions-dialog.component';\r\nimport { WarningDialogComponent } from './components/dialogs/warning-dialog/warning-dialog.component';\r\nimport { ManufacturerComponent } from './components/manufacturer/manufacturer.component';\r\nimport { ExampleInputWithUnitSelector } from './components/visual-units/helpers/example-input-with-selector/example-input-with-selector';\r\nimport { FeatureFlagGuard } from './feature-flag.guard';\r\nimport { OnboardingScreenGuard } from './onboarding-screen.guard';\r\nimport { ProductCatalogGuard } from './product-catalog.guard';\r\n\r\n@NgModule({\r\n declarations: [\r\n AppComponent,\r\n LoginComponent,\r\n ScreenshotFetchPipe,\r\n FloorplanFetchPipe,\r\n RequestPasswordResetComponent,\r\n ResetPasswordComponent,\r\n RegisterComponent,\r\n ConfirmationComponent,\r\n TermsOfServiceComponent,\r\n ErrorDialogComponent,\r\n StreamDialogComponent,\r\n DownloadComponent,\r\n SignupHeaderComponent,\r\n InfoboxDialogComponent,\r\n ManufacturerComponent,\r\n VisualUnitsComponent,\r\n ExampleModal,\r\n ExampleInputWithUnitSelector,\r\n ClosingDialogComponent,\r\n WarningDialogComponent,\r\n TwoActionsDialogComponent,\r\n ],\r\n exports: [MatIconModule],\r\n bootstrap: [AppComponent],\r\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\r\n imports: [\r\n CommonModule,\r\n BrowserModule,\r\n AppRoutingModule,\r\n SharedModule,\r\n BrowserAnimationsModule,\r\n ReactiveFormsModule,\r\n FormsModule,\r\n ClipboardModule,\r\n // Material Design Components\r\n MatAutocompleteModule,\r\n MatBadgeModule,\r\n MatButtonModule,\r\n MatButtonToggleModule,\r\n MatCardModule,\r\n MatCheckboxModule,\r\n MatChipsModule,\r\n MatStepperModule,\r\n MatDatepickerModule,\r\n MatDialogModule,\r\n MatDividerModule,\r\n MatExpansionModule,\r\n MatGridListModule,\r\n MatIconModule,\r\n MatInputModule,\r\n MatListModule,\r\n MatMenuModule,\r\n MatNativeDateModule,\r\n MatPaginatorModule,\r\n MatProgressBarModule,\r\n MatProgressSpinnerModule,\r\n MatRadioModule,\r\n MatRippleModule,\r\n MatSelectModule,\r\n MatSidenavModule,\r\n MatSliderModule,\r\n MatSlideToggleModule,\r\n MatSnackBarModule,\r\n MatSortModule,\r\n MatTableModule,\r\n MatTabsModule,\r\n MatToolbarModule,\r\n MatTooltipModule,\r\n // CDK\r\n DragDropModule,\r\n LayoutModule,\r\n ],\r\n providers: [\r\n AuthGuard,\r\n SalesGuard,\r\n UserGroupGuard,\r\n ExportPluginGuard,\r\n OnboardingScreenGuard,\r\n FeatureFlagGuard,\r\n ProductCatalogGuard,\r\n EnvironmentService,\r\n TokenService,\r\n ProjectService,\r\n ScreenshotService,\r\n FloorplanService,\r\n FloorplannerService,\r\n UnitService,\r\n BuildingService,\r\n LevelService,\r\n InputFileService,\r\n UtilityService,\r\n StreamingService,\r\n ExporterPluginService,\r\n ErrorDialogService,\r\n VersionService,\r\n FloorplanAIService,\r\n InfoboxDialogService,\r\n UniversalDeviceDetectorService,\r\n ReleaseNotesService,\r\n AssetService,\r\n FilteredArticlesService,\r\n SchemasService,\r\n SchemaPropertiesService,\r\n TwoActionsDialogService,\r\n NavigationService,\r\n NavigationHistoryService,\r\n UrlService,\r\n UnrealService,\r\n ConfigurationResolverService,\r\n AppInitializeService,\r\n DatePipe,\r\n DateService,\r\n { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },\r\n { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },\r\n {\r\n provide: ErrorHandler,\r\n useValue: Sentry.createErrorHandler({\r\n //TODO: set localhost in environment.envSystem and use the variable\r\n //showDialog: !environment.apiUrl.includes('localhost'),\r\n showDialog: false,\r\n }),\r\n },\r\n {\r\n provide: Sentry.TraceService,\r\n deps: [Router],\r\n },\r\n {\r\n // Sentry currently does not provide an updated way to not use APP_INITIALIZER\r\n provide: APP_INITIALIZER,\r\n useFactory: () => () => {},\r\n deps: [TraceService],\r\n multi: true,\r\n },\r\n provideAppInitializer(() => {\r\n const initializerFn = AppInitializeService.initializeApp(inject(AppInitializeService));\r\n return initializerFn();\r\n }),\r\n { provide: DEFAULT_CURRENCY_CODE, useValue: 'EUR' },\r\n provideHttpClient(withInterceptorsFromDi()),\r\n ],\r\n})\r\nexport class AppModule {}\r\n","import { enableProdMode } from '@angular/core';\nimport { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\n\nimport { AppModule } from './app/app.module';\nimport { environment } from './environments/environment';\nimport * as Sentry from '@sentry/angular';\n\nif (environment.production) {\n enableProdMode();\n}\n\nSentry.init({\n //TODO: set localhost in environment.envSystem and use the variable\n environment: environment.apiUrl.includes('localhost') ? 'local' : environment.envSystem,\n dsn: 'https://de4c07f82bb1acb41ad643242a5ebedb@o4507106472951808.ingest.de.sentry.io/4507108247928912',\n integrations: [Sentry.browserTracingIntegration()],\n tracePropagationTargets: [environment.apiUrl],\n\n //TODO: Adjust this!\n // Set tracesSampleRate to 1.0 to capture 100%\n // of transactions for performance monitoring.\n // We recommend adjusting this value in production\n tracesSampleRate: 0.2,\n});\n\nplatformBrowserDynamic()\n .bootstrapModule(AppModule)\n .catch((err) => console.log(err));\n","'use strict';\n\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin \n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nvar dijkstra = {\n single_source_shortest_paths: function(graph, s, d) {\n // Predecessor map for each node that has been encountered.\n // node ID => predecessor node ID\n var predecessors = {};\n\n // Costs of shortest paths from s to all nodes encountered.\n // node ID => cost\n var costs = {};\n costs[s] = 0;\n\n // Costs of shortest paths from s to all nodes encountered; differs from\n // `costs` in that it provides easy access to the node that currently has\n // the known shortest path from s.\n // XXX: Do we actually need both `costs` and `open`?\n var open = dijkstra.PriorityQueue.make();\n open.push(s, 0);\n\n var closest,\n u, v,\n cost_of_s_to_u,\n adjacent_nodes,\n cost_of_e,\n cost_of_s_to_u_plus_cost_of_e,\n cost_of_s_to_v,\n first_visit;\n while (!open.empty()) {\n // In the nodes remaining in graph that have a known cost from s,\n // find the node, u, that currently has the shortest path from s.\n closest = open.pop();\n u = closest.value;\n cost_of_s_to_u = closest.cost;\n\n // Get nodes adjacent to u...\n adjacent_nodes = graph[u] || {};\n\n // ...and explore the edges that connect u to those nodes, updating\n // the cost of the shortest paths to any or all of those nodes as\n // necessary. v is the node across the current edge from u.\n for (v in adjacent_nodes) {\n if (adjacent_nodes.hasOwnProperty(v)) {\n // Get the cost of the edge running from u to v.\n cost_of_e = adjacent_nodes[v];\n\n // Cost of s to u plus the cost of u to v across e--this is *a*\n // cost from s to v that may or may not be less than the current\n // known cost to v.\n cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n // If we haven't visited v yet OR if the current known cost from s to\n // v is greater than the new cost we just found (cost of s to u plus\n // cost of u to v across e), update v's cost in the cost list and\n // update v's predecessor in the predecessor list (it's now u).\n cost_of_s_to_v = costs[v];\n first_visit = (typeof costs[v] === 'undefined');\n if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n costs[v] = cost_of_s_to_u_plus_cost_of_e;\n open.push(v, cost_of_s_to_u_plus_cost_of_e);\n predecessors[v] = u;\n }\n }\n }\n }\n\n if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {\n var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');\n throw new Error(msg);\n }\n\n return predecessors;\n },\n\n extract_shortest_path_from_predecessor_list: function(predecessors, d) {\n var nodes = [];\n var u = d;\n var predecessor;\n while (u) {\n nodes.push(u);\n predecessor = predecessors[u];\n u = predecessors[u];\n }\n nodes.reverse();\n return nodes;\n },\n\n find_path: function(graph, s, d) {\n var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);\n return dijkstra.extract_shortest_path_from_predecessor_list(\n predecessors, d);\n },\n\n /**\n * A very naive priority queue implementation.\n */\n PriorityQueue: {\n make: function (opts) {\n var T = dijkstra.PriorityQueue,\n t = {},\n key;\n opts = opts || {};\n for (key in T) {\n if (T.hasOwnProperty(key)) {\n t[key] = T[key];\n }\n }\n t.queue = [];\n t.sorter = opts.sorter || T.default_sorter;\n return t;\n },\n\n default_sorter: function (a, b) {\n return a.cost - b.cost;\n },\n\n /**\n * Add a new item to the queue and ensure the highest priority element\n * is at the front of the queue.\n */\n push: function (value, cost) {\n var item = {value: value, cost: cost};\n this.queue.push(item);\n this.queue.sort(this.sorter);\n },\n\n /**\n * Return the highest priority element in the queue.\n */\n pop: function () {\n return this.queue.shift();\n },\n\n empty: function () {\n return this.queue.length === 0;\n }\n }\n};\n\n\n// node.js module exports\nif (typeof module !== 'undefined') {\n module.exports = dijkstra;\n}\n","(function(a,b){if(\"function\"==typeof define&&define.amd)define([],b);else if(\"undefined\"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){\"use strict\";function b(a,b){return\"undefined\"==typeof b?b={autoBom:!1}:\"object\"!=typeof b&&(console.warn(\"Deprecated: Expected third argument to be a object\"),b={autoBom:!b}),b.autoBom&&/^\\s*(?:text\\/\\S*|application\\/xml|\\S*\\/\\S*\\+xml)\\s*;.*charset\\s*=\\s*utf-8/i.test(a.type)?new Blob([\"\\uFEFF\",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open(\"GET\",a),d.responseType=\"blob\",d.onload=function(){g(d.response,b,c)},d.onerror=function(){console.error(\"could not download file\")},d.send()}function d(a){var b=new XMLHttpRequest;b.open(\"HEAD\",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent(\"click\"))}catch(c){var b=document.createEvent(\"MouseEvents\");b.initMouseEvent(\"click\",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f=\"object\"==typeof window&&window.window===window?window:\"object\"==typeof self&&self.self===self?self:\"object\"==typeof global&&global.global===global?global:void 0,a=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||(\"object\"!=typeof window||window!==f?function(){}:\"download\"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement(\"a\");g=g||b.name||\"download\",j.download=g,j.rel=\"noopener\",\"string\"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target=\"_blank\")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:\"msSaveOrOpenBlob\"in navigator?function(f,g,h){if(g=g||f.name||\"download\",\"string\"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement(\"a\");i.href=f,i.target=\"_blank\",setTimeout(function(){e(i)})}}:function(b,d,e,g){if(g=g||open(\"\",\"_blank\"),g&&(g.document.title=g.document.body.innerText=\"downloading...\"),\"string\"==typeof b)return c(b,d,e);var h=\"application/octet-stream\"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\\/[\\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&\"undefined\"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,\"data:attachment/file;\"),g?g.location.href=a:location=a,g=null},k.readAsDataURL(b)}else{var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m)},4E4)}});f.saveAs=g.saveAs=g,\"undefined\"!=typeof module&&(module.exports=g)});\n\n","/*!\n\nJSZip v3.10.1 - A JavaScript class for generating and reading zip files\n\n\n(c) 2009-2016 Stuart Knightley \nDual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.\n\nJSZip uses the library pako released under the MIT license :\nhttps://github.com/nodeca/pako/blob/main/LICENSE\n*/\n\n!function(e){if(\"object\"==typeof exports&&\"undefined\"!=typeof module)module.exports=e();else if(\"function\"==typeof define&&define.amd)define([],e);else{(\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:this).JSZip=e()}}(function(){return function s(a,o,h){function u(r,e){if(!o[r]){if(!a[r]){var t=\"function\"==typeof require&&require;if(!e&&t)return t(r,!0);if(l)return l(r,!0);var n=new Error(\"Cannot find module '\"+r+\"'\");throw n.code=\"MODULE_NOT_FOUND\",n}var i=o[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return u(t||e)},i,i.exports,s,a,o,h)}return o[r].exports}for(var l=\"function\"==typeof require&&require,e=0;e>2,s=(3&t)<<4|r>>4,a=1>6:64,o=2>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(o++)))>>2,n=(3&s)<<6|(a=p.indexOf(e.charAt(o++))),l[h++]=t,64!==s&&(l[h++]=r),64!==a&&(l[h++]=n);return l}},{\"./support\":30,\"./utils\":32}],2:[function(e,t,r){\"use strict\";var n=e(\"./external\"),i=e(\"./stream/DataWorker\"),s=e(\"./stream/Crc32Probe\"),a=e(\"./stream/DataLengthProbe\");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a(\"data_length\")),t=this;return e.on(\"end\",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error(\"Bug : uncompressed data size mismatch\")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo(\"compressedSize\",this.compressedSize).withStreamInfo(\"uncompressedSize\",this.uncompressedSize).withStreamInfo(\"crc32\",this.crc32).withStreamInfo(\"compression\",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new a(\"uncompressedSize\")).pipe(t.compressWorker(r)).pipe(new a(\"compressedSize\")).withStreamInfo(\"compression\",t)},t.exports=o},{\"./external\":6,\"./stream/Crc32Probe\":25,\"./stream/DataLengthProbe\":26,\"./stream/DataWorker\":27}],3:[function(e,t,r){\"use strict\";var n=e(\"./stream/GenericWorker\");r.STORE={magic:\"\\0\\0\",compressWorker:function(){return new n(\"STORE compression\")},uncompressWorker:function(){return new n(\"STORE decompression\")}},r.DEFLATE=e(\"./flate\")},{\"./flate\":7,\"./stream/GenericWorker\":28}],4:[function(e,t,r){\"use strict\";var n=e(\"./utils\");var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?\"string\"!==n.getTypeOf(e)?function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length,0):0}},{\"./utils\":32}],5:[function(e,t,r){\"use strict\";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){\"use strict\";var n=null;n=\"undefined\"!=typeof Promise?Promise:e(\"lie\"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,r){\"use strict\";var n=\"undefined\"!=typeof Uint8Array&&\"undefined\"!=typeof Uint16Array&&\"undefined\"!=typeof Uint32Array,i=e(\"pako\"),s=e(\"./utils\"),a=e(\"./stream/GenericWorker\"),o=n?\"uint8array\":\"array\";function h(e,t){a.call(this,\"FlateWorker/\"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic=\"\\b\\0\",s.inherits(h,a),h.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(e){return new h(\"Deflate\",e)},r.uncompressWorker=function(){return new h(\"Inflate\",{})}},{\"./stream/GenericWorker\":28,\"./utils\":32,pako:38}],8:[function(e,t,r){\"use strict\";function A(e,t){var r,n=\"\";for(r=0;r>>=8;return n}function n(e,t,r,n,i,s){var a,o,h=e.file,u=e.compression,l=s!==O.utf8encode,f=I.transformTo(\"string\",s(h.name)),c=I.transformTo(\"string\",O.utf8encode(h.name)),d=h.comment,p=I.transformTo(\"string\",s(d)),m=I.transformTo(\"string\",O.utf8encode(d)),_=c.length!==h.name.length,g=m.length!==d.length,b=\"\",v=\"\",y=\"\",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),\"UNIX\"===i?(C=798,z|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(e){return 63&(e||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+c,b+=\"up\"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+=\"uc\"+A(y.length,2)+y);var E=\"\";return E+=\"\\n\\0\",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+\"\\0\\0\\0\\0\"+A(z,4)+A(n,4)+f+b+p}}var I=e(\"../utils\"),i=e(\"../stream/GenericWorker\"),O=e(\"../utf8\"),B=e(\"../crc32\"),R=e(\"../signature\");function s(e,t,r,n){i.call(this,\"ZipFileWorker\"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(s,i),s.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,i.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},s.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},s.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=n(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return R.DATA_DESCRIPTOR+A(e.crc32,4)+A(e.compressedSize,4)+A(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},s.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo(\"string\",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{\"../utils\":32}],19:[function(e,t,r){\"use strict\";var n=e(\"./Uint8ArrayReader\");function i(e){n.call(this,e)}e(\"../utils\").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{\"../utils\":32,\"./Uint8ArrayReader\":21}],20:[function(e,t,r){\"use strict\";var n=e(\"./DataReader\");function i(e){n.call(this,e)}e(\"../utils\").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{\"../utils\":32,\"./DataReader\":18}],21:[function(e,t,r){\"use strict\";var n=e(\"./ArrayReader\");function i(e){n.call(this,e)}e(\"../utils\").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{\"../utils\":32,\"./ArrayReader\":17}],22:[function(e,t,r){\"use strict\";var n=e(\"../utils\"),i=e(\"../support\"),s=e(\"./ArrayReader\"),a=e(\"./StringReader\"),o=e(\"./NodeBufferReader\"),h=e(\"./Uint8ArrayReader\");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),\"string\"!==t||i.uint8array?\"nodebuffer\"===t?new o(e):i.uint8array?new h(n.transformTo(\"uint8array\",e)):new s(n.transformTo(\"array\",e)):new a(e)}},{\"../support\":30,\"../utils\":32,\"./ArrayReader\":17,\"./NodeBufferReader\":19,\"./StringReader\":20,\"./Uint8ArrayReader\":21}],23:[function(e,t,r){\"use strict\";r.LOCAL_FILE_HEADER=\"PK\u0003\u0004\",r.CENTRAL_FILE_HEADER=\"PK\u0001\u0002\",r.CENTRAL_DIRECTORY_END=\"PK\u0005\u0006\",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR=\"PK\u0006\u0007\",r.ZIP64_CENTRAL_DIRECTORY_END=\"PK\u0006\u0006\",r.DATA_DESCRIPTOR=\"PK\u0007\\b\"},{}],24:[function(e,t,r){\"use strict\";var n=e(\"./GenericWorker\"),i=e(\"../utils\");function s(e){n.call(this,\"ConvertWorker to \"+e),this.destType=e}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{\"../utils\":32,\"./GenericWorker\":28}],25:[function(e,t,r){\"use strict\";var n=e(\"./GenericWorker\"),i=e(\"../crc32\");function s(){n.call(this,\"Crc32Probe\"),this.withStreamInfo(\"crc32\",0)}e(\"../utils\").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{\"../crc32\":4,\"../utils\":32,\"./GenericWorker\":28}],26:[function(e,t,r){\"use strict\";var n=e(\"../utils\"),i=e(\"./GenericWorker\");function s(e){i.call(this,\"DataLengthProbe for \"+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{\"../utils\":32,\"./GenericWorker\":28}],27:[function(e,t,r){\"use strict\";var n=e(\"../utils\"),i=e(\"./GenericWorker\");function s(e){i.call(this,\"DataWorker\");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type=\"\",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case\"string\":e=this.data.substring(this.index,t);break;case\"uint8array\":e=this.data.subarray(this.index,t);break;case\"array\":case\"nodebuffer\":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{\"../utils\":32,\"./GenericWorker\":28}],28:[function(e,t,r){\"use strict\";function n(e){this.name=e||\"default\",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit(\"data\",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit(\"end\"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit(\"error\",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit(\"error\",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r \"+e:e}},t.exports=n},{}],29:[function(e,t,r){\"use strict\";var h=e(\"../utils\"),i=e(\"./ConvertWorker\"),s=e(\"./GenericWorker\"),u=e(\"../base64\"),n=e(\"../support\"),a=e(\"../external\"),o=null;if(n.nodestream)try{o=e(\"../nodejs/NodejsStreamOutputAdapter\")}catch(e){}function l(e,o){return new a.Promise(function(t,r){var n=[],i=e._internalType,s=e._outputType,a=e._mimeType;e.on(\"data\",function(e,t){n.push(e),o&&o(t)}).on(\"error\",function(e){n=[],r(e)}).on(\"end\",function(){try{var e=function(e,t,r){switch(e){case\"blob\":return h.newBlob(h.transformTo(\"arraybuffer\",t),r);case\"base64\":return u.encode(t);default:return h.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return h.nodebuffer?o.transformTo(\"nodebuffer\",e).toString(\"utf-8\"):function(e){var t,r,n,i,s=e.length,a=new Array(2*s);for(t=r=0;t>10&1023,a[r++]=56320|1023&n)}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(e=o.transformTo(h.uint8array?\"uint8array\":\"array\",e))},o.inherits(a,n),a.prototype.processChunk=function(e){var t=o.transformTo(h.uint8array?\"uint8array\":\"array\",e.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(h.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta})},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=a,o.inherits(l,n),l.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta})},s.Utf8EncodeWorker=l},{\"./nodejsUtils\":14,\"./stream/GenericWorker\":28,\"./support\":30,\"./utils\":32}],32:[function(e,t,a){\"use strict\";var o=e(\"./support\"),h=e(\"./base64\"),r=e(\"./nodejsUtils\"),u=e(\"./external\");function n(e){return e}function l(e,t){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||\"/\"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new h.Buf8(e.length),r=0,n=t.length;r>10&1023,o[n++]=56320|1023&i)}return l(o,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}},{\"./common\":41}],43:[function(e,t,r){\"use strict\";t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,r){\"use strict\";var h,c=e(\"../utils/common\"),u=e(\"./trees\"),d=e(\"./adler32\"),p=e(\"./crc32\"),n=e(\"./messages\"),l=0,f=4,m=0,_=-2,g=-1,b=4,i=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(e,t){return e.msg=n[t],t}function T(e){return(e<<1)-(4e.avail_out&&(r=e.avail_out),0!==r&&(c.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function N(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function U(e,t){e.pending_buf[e.pending++]=t}function P(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function L(e,t){var r,n,i=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,u=e.window,l=e.w_mask,f=e.prev,c=e.strstart+S,d=u[s+a-1],p=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&sh&&0!=--i);return a<=e.lookahead?a:e.lookahead}function j(e){var t,r,n,i,s,a,o,h,u,l,f=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-z)){for(c.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);i+=f}if(0===e.strm.avail_in)break;if(a=e.strm,o=e.window,h=e.strstart+e.lookahead,u=i,l=void 0,l=a.avail_in,u=x)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===l)return A;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return A;if(e.strstart-e.block_start>=e.w_size-z&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(e,t){return Y(e,t,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,m):_},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=E);else{var a=v+(n.w_bits-8<<4)<<8;a|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=E,P(n,a),0!==n.strstart&&(P(n,e.adler>>>16),P(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&F(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=E)):n.status=E),0!==n.pending){if(F(e),0===e.avail_out)return n.last_flush=-1,m}else if(0===e.avail_in&&T(t)<=T(r)&&t!==f)return R(e,-5);if(666===n.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===l)return A;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===l)return A;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=x?(r=u._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):h[n.level].func(n,t);if(o!==O&&o!==B||(n.status=666),o===A||o===O)return 0===e.avail_out&&(n.last_flush=-1),m;if(o===I&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),F(e),0===e.avail_out))return n.last_flush=-1,m}return t!==f?m:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(P(n,e.adler>>>16),P(n,65535&e.adler)),F(e),0=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new c.Buf8(r.w_size),c.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,o=e.next_in,h=e.input,e.avail_in=l,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,i=r.lookahead-(x-1);r.ins_h=(r.ins_h<>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<>>=y,p-=y),p<15&&(d+=z[n++]<>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<>>=y,p-=y,(y=s-a)>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg=\"incorrect header check\",r.mode=30;break}if(8!=(15&u)){e.msg=\"unknown compression method\",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg=\"invalid window size\",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg=\"invalid block type\",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg=\"invalid code lengths set\",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l>>=_,l-=_,0===r.have){e.msg=\"invalid bit length repeat\",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l>>=_)),u>>>=3,l-=3}else{for(z=_+7;l>>=_)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg=\"invalid bit length repeat\",r.mode=30;break}for(;d--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg=\"invalid code -- missing end-of-block\",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg=\"invalid literal/lengths set\",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg=\"invalid distances set\",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg=\"invalid literal/length code\",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg=\"invalid distance code\",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg=\"invalid distance too far back\",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg=\"invalid distance too far back\",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=a-r.offset,d=r.length;for(hd?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]]}if(k>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o))}}function W(e){var t;for(t=0;t>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u>=7;n>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{\"../utils/common\":41}],53:[function(e,t,r){\"use strict\";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(r,n){\"use strict\";if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i=\"[object process]\"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e)})}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1},r.postMessage(\"\",\"*\"),r.onmessage=t,e}}()?(a=\"setImmediate$\"+Math.random()+\"$\",r.addEventListener?r.addEventListener(\"message\",d,!1):r.attachEvent(\"onmessage\",d),function(e){r.postMessage(a+e,\"*\")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data)},function(e){t.port2.postMessage(e)}):l&&\"onreadystatechange\"in l.createElement(\"script\")?(s=l.documentElement,function(e){var t=l.createElement(\"script\");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(c,0,e)},e.setImmediate=function(e){\"function\"!=typeof e&&(e=new Function(\"\"+e));for(var t=new Array(arguments.length-1),r=0;r 2) {\n var lastSlashIndex = res.lastIndexOf('/');\n if (lastSlashIndex !== res.length - 1) {\n if (lastSlashIndex === -1) {\n res = '';\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n } else if (res.length === 2 || res.length === 1) {\n res = '';\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n if (res.length > 0)\n res += '/..';\n else\n res = '..';\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0)\n res += '/' + path.slice(lastSlash + 1, i);\n else\n res = path.slice(lastSlash + 1, i);\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n } else if (code === 46 /*.*/ && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n\nfunction _format(sep, pathObject) {\n var dir = pathObject.dir || pathObject.root;\n var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');\n if (!dir) {\n return base;\n }\n if (dir === pathObject.root) {\n return dir + base;\n }\n return dir + sep + base;\n}\n\nvar posix = {\n // path.resolve([from ...], to)\n resolve: function resolve() {\n var resolvedPath = '';\n var resolvedAbsolute = false;\n var cwd;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path;\n if (i >= 0)\n path = arguments[i];\n else {\n if (cwd === undefined)\n cwd = process.cwd();\n path = cwd;\n }\n\n assertPath(path);\n\n // Skip empty entries\n if (path.length === 0) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);\n\n if (resolvedAbsolute) {\n if (resolvedPath.length > 0)\n return '/' + resolvedPath;\n else\n return '/';\n } else if (resolvedPath.length > 0) {\n return resolvedPath;\n } else {\n return '.';\n }\n },\n\n normalize: function normalize(path) {\n assertPath(path);\n\n if (path.length === 0) return '.';\n\n var isAbsolute = path.charCodeAt(0) === 47 /*/*/;\n var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;\n\n // Normalize the path\n path = normalizeStringPosix(path, !isAbsolute);\n\n if (path.length === 0 && !isAbsolute) path = '.';\n if (path.length > 0 && trailingSeparator) path += '/';\n\n if (isAbsolute) return '/' + path;\n return path;\n },\n\n isAbsolute: function isAbsolute(path) {\n assertPath(path);\n return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;\n },\n\n join: function join() {\n if (arguments.length === 0)\n return '.';\n var joined;\n for (var i = 0; i < arguments.length; ++i) {\n var arg = arguments[i];\n assertPath(arg);\n if (arg.length > 0) {\n if (joined === undefined)\n joined = arg;\n else\n joined += '/' + arg;\n }\n }\n if (joined === undefined)\n return '.';\n return posix.normalize(joined);\n },\n\n relative: function relative(from, to) {\n assertPath(from);\n assertPath(to);\n\n if (from === to) return '';\n\n from = posix.resolve(from);\n to = posix.resolve(to);\n\n if (from === to) return '';\n\n // Trim any leading backslashes\n var fromStart = 1;\n for (; fromStart < from.length; ++fromStart) {\n if (from.charCodeAt(fromStart) !== 47 /*/*/)\n break;\n }\n var fromEnd = from.length;\n var fromLen = fromEnd - fromStart;\n\n // Trim any leading backslashes\n var toStart = 1;\n for (; toStart < to.length; ++toStart) {\n if (to.charCodeAt(toStart) !== 47 /*/*/)\n break;\n }\n var toEnd = to.length;\n var toLen = toEnd - toStart;\n\n // Compare paths to find the longest common path from root\n var length = fromLen < toLen ? fromLen : toLen;\n var lastCommonSep = -1;\n var i = 0;\n for (; i <= length; ++i) {\n if (i === length) {\n if (toLen > length) {\n if (to.charCodeAt(toStart + i) === 47 /*/*/) {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n } else if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n } else if (fromLen > length) {\n if (from.charCodeAt(fromStart + i) === 47 /*/*/) {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n } else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo'; to='/'\n lastCommonSep = 0;\n }\n }\n break;\n }\n var fromCode = from.charCodeAt(fromStart + i);\n var toCode = to.charCodeAt(toStart + i);\n if (fromCode !== toCode)\n break;\n else if (fromCode === 47 /*/*/)\n lastCommonSep = i;\n }\n\n var out = '';\n // Generate the relative path based on the path difference between `to`\n // and `from`\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {\n if (out.length === 0)\n out += '..';\n else\n out += '/..';\n }\n }\n\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts\n if (out.length > 0)\n return out + to.slice(toStart + lastCommonSep);\n else {\n toStart += lastCommonSep;\n if (to.charCodeAt(toStart) === 47 /*/*/)\n ++toStart;\n return to.slice(toStart);\n }\n },\n\n _makeLong: function _makeLong(path) {\n return path;\n },\n\n dirname: function dirname(path) {\n assertPath(path);\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) return '//';\n return path.slice(0, end);\n },\n\n basename: function basename(path, ext) {\n if (ext !== undefined && typeof ext !== 'string') throw new TypeError('\"ext\" argument must be a string');\n assertPath(path);\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n if (ext.length === path.length && ext === path) return '';\n var extIdx = ext.length - 1;\n var firstNonSlashEnd = -1;\n for (i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (code === ext.charCodeAt(extIdx)) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n\n if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;\n return path.slice(start, end);\n } else {\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n }\n },\n\n extname: function extname(path) {\n assertPath(path);\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\n },\n\n format: function format(pathObject) {\n if (pathObject === null || typeof pathObject !== 'object') {\n throw new TypeError('The \"pathObject\" argument must be of type Object. Received type ' + typeof pathObject);\n }\n return _format('/', pathObject);\n },\n\n parse: function parse(path) {\n assertPath(path);\n\n var ret = { root: '', dir: '', base: '', ext: '', name: '' };\n if (path.length === 0) return ret;\n var code = path.charCodeAt(0);\n var isAbsolute = code === 47 /*/*/;\n var start;\n if (isAbsolute) {\n ret.root = '/';\n start = 1;\n } else {\n start = 0;\n }\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n var i = path.length - 1;\n\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n\n // Get non-dir info\n for (; i >= start; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n if (end !== -1) {\n if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);\n }\n } else {\n if (startPart === 0 && isAbsolute) {\n ret.name = path.slice(1, startDot);\n ret.base = path.slice(1, end);\n } else {\n ret.name = path.slice(startPart, startDot);\n ret.base = path.slice(startPart, end);\n }\n ret.ext = path.slice(startDot, end);\n }\n\n if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';\n\n return ret;\n },\n\n sep: '/',\n delimiter: ':',\n win32: null,\n posix: null\n};\n\nposix.posix = posix;\n\nmodule.exports = posix;\n","\nconst canPromise = require('./can-promise')\n\nconst QRCode = require('./core/qrcode')\nconst CanvasRenderer = require('./renderer/canvas')\nconst SvgRenderer = require('./renderer/svg-tag.js')\n\nfunction renderCanvas (renderFunc, canvas, text, opts, cb) {\n const args = [].slice.call(arguments, 1)\n const argsNum = args.length\n const isLastArgCb = typeof args[argsNum - 1] === 'function'\n\n if (!isLastArgCb && !canPromise()) {\n throw new Error('Callback required as last argument')\n }\n\n if (isLastArgCb) {\n if (argsNum < 2) {\n throw new Error('Too few arguments provided')\n }\n\n if (argsNum === 2) {\n cb = text\n text = canvas\n canvas = opts = undefined\n } else if (argsNum === 3) {\n if (canvas.getContext && typeof cb === 'undefined') {\n cb = opts\n opts = undefined\n } else {\n cb = opts\n opts = text\n text = canvas\n canvas = undefined\n }\n }\n } else {\n if (argsNum < 1) {\n throw new Error('Too few arguments provided')\n }\n\n if (argsNum === 1) {\n text = canvas\n canvas = opts = undefined\n } else if (argsNum === 2 && !canvas.getContext) {\n opts = text\n text = canvas\n canvas = undefined\n }\n\n return new Promise(function (resolve, reject) {\n try {\n const data = QRCode.create(text, opts)\n resolve(renderFunc(data, canvas, opts))\n } catch (e) {\n reject(e)\n }\n })\n }\n\n try {\n const data = QRCode.create(text, opts)\n cb(null, renderFunc(data, canvas, opts))\n } catch (e) {\n cb(e)\n }\n}\n\nexports.create = QRCode.create\nexports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render)\nexports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)\n\n// only svg for now.\nexports.toString = renderCanvas.bind(null, function (data, _, opts) {\n return SvgRenderer.render(data, opts)\n})\n","// can-promise has a crash in some versions of react native that dont have\n// standard global objects\n// https://github.com/soldair/node-qrcode/issues/157\n\nmodule.exports = function () {\n return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then\n}\n","/**\n * Alignment pattern are fixed reference pattern in defined positions\n * in a matrix symbology, which enables the decode software to re-synchronise\n * the coordinate mapping of the image modules in the event of moderate amounts\n * of distortion of the image.\n *\n * Alignment patterns are present only in QR Code symbols of version 2 or larger\n * and their number depends on the symbol version.\n */\n\nconst getSymbolSize = require('./utils').getSymbolSize\n\n/**\n * Calculate the row/column coordinates of the center module of each alignment pattern\n * for the specified QR Code version.\n *\n * The alignment patterns are positioned symmetrically on either side of the diagonal\n * running from the top left corner of the symbol to the bottom right corner.\n *\n * Since positions are simmetrical only half of the coordinates are returned.\n * Each item of the array will represent in turn the x and y coordinate.\n * @see {@link getPositions}\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinate\n */\nexports.getRowColCoords = function getRowColCoords (version) {\n if (version === 1) return []\n\n const posCount = Math.floor(version / 7) + 2\n const size = getSymbolSize(version)\n const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2\n const positions = [size - 7] // Last coord is always (size - 7)\n\n for (let i = 1; i < posCount - 1; i++) {\n positions[i] = positions[i - 1] - intervals\n }\n\n positions.push(6) // First coord is always 6\n\n return positions.reverse()\n}\n\n/**\n * Returns an array containing the positions of each alignment pattern.\n * Each array's element represent the center point of the pattern as (x, y) coordinates\n *\n * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}\n * and filtering out the items that overlaps with finder pattern\n *\n * @example\n * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.\n * The alignment patterns, therefore, are to be centered on (row, column)\n * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).\n * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns\n * and are not therefore used for alignment patterns.\n *\n * let pos = getPositions(7)\n * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinates\n */\nexports.getPositions = function getPositions (version) {\n const coords = []\n const pos = exports.getRowColCoords(version)\n const posLength = pos.length\n\n for (let i = 0; i < posLength; i++) {\n for (let j = 0; j < posLength; j++) {\n // Skip if position is occupied by finder patterns\n if ((i === 0 && j === 0) || // top-left\n (i === 0 && j === posLength - 1) || // bottom-left\n (i === posLength - 1 && j === 0)) { // top-right\n continue\n }\n\n coords.push([pos[i], pos[j]])\n }\n }\n\n return coords\n}\n","const Mode = require('./mode')\n\n/**\n * Array of characters available in alphanumeric mode\n *\n * As per QR Code specification, to each character\n * is assigned a value from 0 to 44 which in this case coincides\n * with the array index\n *\n * @type {Array}\n */\nconst ALPHA_NUM_CHARS = [\n '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',\n 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\n ' ', '$', '%', '*', '+', '-', '.', '/', ':'\n]\n\nfunction AlphanumericData (data) {\n this.mode = Mode.ALPHANUMERIC\n this.data = data\n}\n\nAlphanumericData.getBitsLength = function getBitsLength (length) {\n return 11 * Math.floor(length / 2) + 6 * (length % 2)\n}\n\nAlphanumericData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nAlphanumericData.prototype.getBitsLength = function getBitsLength () {\n return AlphanumericData.getBitsLength(this.data.length)\n}\n\nAlphanumericData.prototype.write = function write (bitBuffer) {\n let i\n\n // Input data characters are divided into groups of two characters\n // and encoded as 11-bit binary codes.\n for (i = 0; i + 2 <= this.data.length; i += 2) {\n // The character value of the first character is multiplied by 45\n let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45\n\n // The character value of the second digit is added to the product\n value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])\n\n // The sum is then stored as 11-bit binary number\n bitBuffer.put(value, 11)\n }\n\n // If the number of input data characters is not a multiple of two,\n // the character value of the final character is encoded as a 6-bit binary number.\n if (this.data.length % 2) {\n bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)\n }\n}\n\nmodule.exports = AlphanumericData\n","function BitBuffer () {\n this.buffer = []\n this.length = 0\n}\n\nBitBuffer.prototype = {\n\n get: function (index) {\n const bufIndex = Math.floor(index / 8)\n return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1\n },\n\n put: function (num, length) {\n for (let i = 0; i < length; i++) {\n this.putBit(((num >>> (length - i - 1)) & 1) === 1)\n }\n },\n\n getLengthInBits: function () {\n return this.length\n },\n\n putBit: function (bit) {\n const bufIndex = Math.floor(this.length / 8)\n if (this.buffer.length <= bufIndex) {\n this.buffer.push(0)\n }\n\n if (bit) {\n this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))\n }\n\n this.length++\n }\n}\n\nmodule.exports = BitBuffer\n","/**\n * Helper class to handle QR Code symbol modules\n *\n * @param {Number} size Symbol size\n */\nfunction BitMatrix (size) {\n if (!size || size < 1) {\n throw new Error('BitMatrix size must be defined and greater than 0')\n }\n\n this.size = size\n this.data = new Uint8Array(size * size)\n this.reservedBit = new Uint8Array(size * size)\n}\n\n/**\n * Set bit value at specified location\n * If reserved flag is set, this bit will be ignored during masking process\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n * @param {Boolean} reserved\n */\nBitMatrix.prototype.set = function (row, col, value, reserved) {\n const index = row * this.size + col\n this.data[index] = value\n if (reserved) this.reservedBit[index] = true\n}\n\n/**\n * Returns bit value at specified location\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.get = function (row, col) {\n return this.data[row * this.size + col]\n}\n\n/**\n * Applies xor operator at specified location\n * (used during masking process)\n *\n * @param {Number} row\n * @param {Number} col\n * @param {Boolean} value\n */\nBitMatrix.prototype.xor = function (row, col, value) {\n this.data[row * this.size + col] ^= value\n}\n\n/**\n * Check if bit at specified location is reserved\n *\n * @param {Number} row\n * @param {Number} col\n * @return {Boolean}\n */\nBitMatrix.prototype.isReserved = function (row, col) {\n return this.reservedBit[row * this.size + col]\n}\n\nmodule.exports = BitMatrix\n","const Mode = require('./mode')\n\nfunction ByteData (data) {\n this.mode = Mode.BYTE\n if (typeof (data) === 'string') {\n this.data = new TextEncoder().encode(data)\n } else {\n this.data = new Uint8Array(data)\n }\n}\n\nByteData.getBitsLength = function getBitsLength (length) {\n return length * 8\n}\n\nByteData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nByteData.prototype.getBitsLength = function getBitsLength () {\n return ByteData.getBitsLength(this.data.length)\n}\n\nByteData.prototype.write = function (bitBuffer) {\n for (let i = 0, l = this.data.length; i < l; i++) {\n bitBuffer.put(this.data[i], 8)\n }\n}\n\nmodule.exports = ByteData\n","const ECLevel = require('./error-correction-level')\r\n\r\nconst EC_BLOCKS_TABLE = [\r\n// L M Q H\r\n 1, 1, 1, 1,\r\n 1, 1, 1, 1,\r\n 1, 1, 2, 2,\r\n 1, 2, 2, 4,\r\n 1, 2, 4, 4,\r\n 2, 4, 4, 4,\r\n 2, 4, 6, 5,\r\n 2, 4, 6, 6,\r\n 2, 5, 8, 8,\r\n 4, 5, 8, 8,\r\n 4, 5, 8, 11,\r\n 4, 8, 10, 11,\r\n 4, 9, 12, 16,\r\n 4, 9, 16, 16,\r\n 6, 10, 12, 18,\r\n 6, 10, 17, 16,\r\n 6, 11, 16, 19,\r\n 6, 13, 18, 21,\r\n 7, 14, 21, 25,\r\n 8, 16, 20, 25,\r\n 8, 17, 23, 25,\r\n 9, 17, 23, 34,\r\n 9, 18, 25, 30,\r\n 10, 20, 27, 32,\r\n 12, 21, 29, 35,\r\n 12, 23, 34, 37,\r\n 12, 25, 34, 40,\r\n 13, 26, 35, 42,\r\n 14, 28, 38, 45,\r\n 15, 29, 40, 48,\r\n 16, 31, 43, 51,\r\n 17, 33, 45, 54,\r\n 18, 35, 48, 57,\r\n 19, 37, 51, 60,\r\n 19, 38, 53, 63,\r\n 20, 40, 56, 66,\r\n 21, 43, 59, 70,\r\n 22, 45, 62, 74,\r\n 24, 47, 65, 77,\r\n 25, 49, 68, 81\r\n]\r\n\r\nconst EC_CODEWORDS_TABLE = [\r\n// L M Q H\r\n 7, 10, 13, 17,\r\n 10, 16, 22, 28,\r\n 15, 26, 36, 44,\r\n 20, 36, 52, 64,\r\n 26, 48, 72, 88,\r\n 36, 64, 96, 112,\r\n 40, 72, 108, 130,\r\n 48, 88, 132, 156,\r\n 60, 110, 160, 192,\r\n 72, 130, 192, 224,\r\n 80, 150, 224, 264,\r\n 96, 176, 260, 308,\r\n 104, 198, 288, 352,\r\n 120, 216, 320, 384,\r\n 132, 240, 360, 432,\r\n 144, 280, 408, 480,\r\n 168, 308, 448, 532,\r\n 180, 338, 504, 588,\r\n 196, 364, 546, 650,\r\n 224, 416, 600, 700,\r\n 224, 442, 644, 750,\r\n 252, 476, 690, 816,\r\n 270, 504, 750, 900,\r\n 300, 560, 810, 960,\r\n 312, 588, 870, 1050,\r\n 336, 644, 952, 1110,\r\n 360, 700, 1020, 1200,\r\n 390, 728, 1050, 1260,\r\n 420, 784, 1140, 1350,\r\n 450, 812, 1200, 1440,\r\n 480, 868, 1290, 1530,\r\n 510, 924, 1350, 1620,\r\n 540, 980, 1440, 1710,\r\n 570, 1036, 1530, 1800,\r\n 570, 1064, 1590, 1890,\r\n 600, 1120, 1680, 1980,\r\n 630, 1204, 1770, 2100,\r\n 660, 1260, 1860, 2220,\r\n 720, 1316, 1950, 2310,\r\n 750, 1372, 2040, 2430\r\n]\r\n\r\n/**\r\n * Returns the number of error correction block that the QR Code should contain\r\n * for the specified version and error correction level.\r\n *\r\n * @param {Number} version QR Code version\r\n * @param {Number} errorCorrectionLevel Error correction level\r\n * @return {Number} Number of error correction blocks\r\n */\r\nexports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {\r\n switch (errorCorrectionLevel) {\r\n case ECLevel.L:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]\r\n case ECLevel.M:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]\r\n case ECLevel.Q:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]\r\n case ECLevel.H:\r\n return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]\r\n default:\r\n return undefined\r\n }\r\n}\r\n\r\n/**\r\n * Returns the number of error correction codewords to use for the specified\r\n * version and error correction level.\r\n *\r\n * @param {Number} version QR Code version\r\n * @param {Number} errorCorrectionLevel Error correction level\r\n * @return {Number} Number of error correction codewords\r\n */\r\nexports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {\r\n switch (errorCorrectionLevel) {\r\n case ECLevel.L:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]\r\n case ECLevel.M:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]\r\n case ECLevel.Q:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]\r\n case ECLevel.H:\r\n return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]\r\n default:\r\n return undefined\r\n }\r\n}\r\n","exports.L = { bit: 1 }\nexports.M = { bit: 0 }\nexports.Q = { bit: 3 }\nexports.H = { bit: 2 }\n\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'l':\n case 'low':\n return exports.L\n\n case 'm':\n case 'medium':\n return exports.M\n\n case 'q':\n case 'quartile':\n return exports.Q\n\n case 'h':\n case 'high':\n return exports.H\n\n default:\n throw new Error('Unknown EC Level: ' + string)\n }\n}\n\nexports.isValid = function isValid (level) {\n return level && typeof level.bit !== 'undefined' &&\n level.bit >= 0 && level.bit < 4\n}\n\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n","const getSymbolSize = require('./utils').getSymbolSize\nconst FINDER_PATTERN_SIZE = 7\n\n/**\n * Returns an array containing the positions of each finder pattern.\n * Each array's element represent the top-left point of the pattern as (x, y) coordinates\n *\n * @param {Number} version QR Code version\n * @return {Array} Array of coordinates\n */\nexports.getPositions = function getPositions (version) {\n const size = getSymbolSize(version)\n\n return [\n // top-left\n [0, 0],\n // top-right\n [size - FINDER_PATTERN_SIZE, 0],\n // bottom-left\n [0, size - FINDER_PATTERN_SIZE]\n ]\n}\n","const Utils = require('./utils')\n\nconst G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)\nconst G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)\nconst G15_BCH = Utils.getBCHDigit(G15)\n\n/**\n * Returns format information with relative error correction bits\n *\n * The format information is a 15-bit sequence containing 5 data bits,\n * with 10 error correction bits calculated using the (15, 5) BCH code.\n *\n * @param {Number} errorCorrectionLevel Error correction level\n * @param {Number} mask Mask pattern\n * @return {Number} Encoded format information bits\n */\nexports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {\n const data = ((errorCorrectionLevel.bit << 3) | mask)\n let d = data << 10\n\n while (Utils.getBCHDigit(d) - G15_BCH >= 0) {\n d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))\n }\n\n // xor final data with mask pattern in order to ensure that\n // no combination of Error Correction Level and data mask pattern\n // will result in an all-zero data string\n return ((data << 10) | d) ^ G15_MASK\n}\n","const EXP_TABLE = new Uint8Array(512)\nconst LOG_TABLE = new Uint8Array(256)\n/**\n * Precompute the log and anti-log tables for faster computation later\n *\n * For each possible value in the galois field 2^8, we will pre-compute\n * the logarithm and anti-logarithm (exponential) of this value\n *\n * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}\n */\n;(function initTables () {\n let x = 1\n for (let i = 0; i < 255; i++) {\n EXP_TABLE[i] = x\n LOG_TABLE[x] = i\n\n x <<= 1 // multiply by 2\n\n // The QR code specification says to use byte-wise modulo 100011101 arithmetic.\n // This means that when a number is 256 or larger, it should be XORed with 0x11D.\n if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)\n x ^= 0x11D\n }\n }\n\n // Optimization: double the size of the anti-log table so that we don't need to mod 255 to\n // stay inside the bounds (because we will mainly use this table for the multiplication of\n // two GF numbers, no more).\n // @see {@link mul}\n for (let i = 255; i < 512; i++) {\n EXP_TABLE[i] = EXP_TABLE[i - 255]\n }\n}())\n\n/**\n * Returns log value of n inside Galois Field\n *\n * @param {Number} n\n * @return {Number}\n */\nexports.log = function log (n) {\n if (n < 1) throw new Error('log(' + n + ')')\n return LOG_TABLE[n]\n}\n\n/**\n * Returns anti-log value of n inside Galois Field\n *\n * @param {Number} n\n * @return {Number}\n */\nexports.exp = function exp (n) {\n return EXP_TABLE[n]\n}\n\n/**\n * Multiplies two number inside Galois Field\n *\n * @param {Number} x\n * @param {Number} y\n * @return {Number}\n */\nexports.mul = function mul (x, y) {\n if (x === 0 || y === 0) return 0\n\n // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized\n // @see {@link initTables}\n return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]\n}\n","const Mode = require('./mode')\nconst Utils = require('./utils')\n\nfunction KanjiData (data) {\n this.mode = Mode.KANJI\n this.data = data\n}\n\nKanjiData.getBitsLength = function getBitsLength (length) {\n return length * 13\n}\n\nKanjiData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nKanjiData.prototype.getBitsLength = function getBitsLength () {\n return KanjiData.getBitsLength(this.data.length)\n}\n\nKanjiData.prototype.write = function (bitBuffer) {\n let i\n\n // In the Shift JIS system, Kanji characters are represented by a two byte combination.\n // These byte values are shifted from the JIS X 0208 values.\n // JIS X 0208 gives details of the shift coded representation.\n for (i = 0; i < this.data.length; i++) {\n let value = Utils.toSJIS(this.data[i])\n\n // For characters with Shift JIS values from 0x8140 to 0x9FFC:\n if (value >= 0x8140 && value <= 0x9FFC) {\n // Subtract 0x8140 from Shift JIS value\n value -= 0x8140\n\n // For characters with Shift JIS values from 0xE040 to 0xEBBF\n } else if (value >= 0xE040 && value <= 0xEBBF) {\n // Subtract 0xC140 from Shift JIS value\n value -= 0xC140\n } else {\n throw new Error(\n 'Invalid SJIS character: ' + this.data[i] + '\\n' +\n 'Make sure your charset is UTF-8')\n }\n\n // Multiply most significant byte of result by 0xC0\n // and add least significant byte to product\n value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)\n\n // Convert result to a 13-bit binary string\n bitBuffer.put(value, 13)\n }\n}\n\nmodule.exports = KanjiData\n","/**\n * Data mask pattern reference\n * @type {Object}\n */\nexports.Patterns = {\n PATTERN000: 0,\n PATTERN001: 1,\n PATTERN010: 2,\n PATTERN011: 3,\n PATTERN100: 4,\n PATTERN101: 5,\n PATTERN110: 6,\n PATTERN111: 7\n}\n\n/**\n * Weighted penalty scores for the undesirable features\n * @type {Object}\n */\nconst PenaltyScores = {\n N1: 3,\n N2: 3,\n N3: 40,\n N4: 10\n}\n\n/**\n * Check if mask pattern value is valid\n *\n * @param {Number} mask Mask pattern\n * @return {Boolean} true if valid, false otherwise\n */\nexports.isValid = function isValid (mask) {\n return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7\n}\n\n/**\n * Returns mask pattern from a value.\n * If value is not valid, returns undefined\n *\n * @param {Number|String} value Mask pattern value\n * @return {Number} Valid mask pattern or undefined\n */\nexports.from = function from (value) {\n return exports.isValid(value) ? parseInt(value, 10) : undefined\n}\n\n/**\n* Find adjacent modules in row/column with the same color\n* and assign a penalty value.\n*\n* Points: N1 + i\n* i is the amount by which the number of adjacent modules of the same color exceeds 5\n*/\nexports.getPenaltyN1 = function getPenaltyN1 (data) {\n const size = data.size\n let points = 0\n let sameCountCol = 0\n let sameCountRow = 0\n let lastCol = null\n let lastRow = null\n\n for (let row = 0; row < size; row++) {\n sameCountCol = sameCountRow = 0\n lastCol = lastRow = null\n\n for (let col = 0; col < size; col++) {\n let module = data.get(row, col)\n if (module === lastCol) {\n sameCountCol++\n } else {\n if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)\n lastCol = module\n sameCountCol = 1\n }\n\n module = data.get(col, row)\n if (module === lastRow) {\n sameCountRow++\n } else {\n if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)\n lastRow = module\n sameCountRow = 1\n }\n }\n\n if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)\n if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)\n }\n\n return points\n}\n\n/**\n * Find 2x2 blocks with the same color and assign a penalty value\n *\n * Points: N2 * (m - 1) * (n - 1)\n */\nexports.getPenaltyN2 = function getPenaltyN2 (data) {\n const size = data.size\n let points = 0\n\n for (let row = 0; row < size - 1; row++) {\n for (let col = 0; col < size - 1; col++) {\n const last = data.get(row, col) +\n data.get(row, col + 1) +\n data.get(row + 1, col) +\n data.get(row + 1, col + 1)\n\n if (last === 4 || last === 0) points++\n }\n }\n\n return points * PenaltyScores.N2\n}\n\n/**\n * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,\n * preceded or followed by light area 4 modules wide\n *\n * Points: N3 * number of pattern found\n */\nexports.getPenaltyN3 = function getPenaltyN3 (data) {\n const size = data.size\n let points = 0\n let bitsCol = 0\n let bitsRow = 0\n\n for (let row = 0; row < size; row++) {\n bitsCol = bitsRow = 0\n for (let col = 0; col < size; col++) {\n bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)\n if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++\n\n bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)\n if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++\n }\n }\n\n return points * PenaltyScores.N3\n}\n\n/**\n * Calculate proportion of dark modules in entire symbol\n *\n * Points: N4 * k\n *\n * k is the rating of the deviation of the proportion of dark modules\n * in the symbol from 50% in steps of 5%\n */\nexports.getPenaltyN4 = function getPenaltyN4 (data) {\n let darkCount = 0\n const modulesCount = data.data.length\n\n for (let i = 0; i < modulesCount; i++) darkCount += data.data[i]\n\n const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)\n\n return k * PenaltyScores.N4\n}\n\n/**\n * Return mask value at given position\n *\n * @param {Number} maskPattern Pattern reference value\n * @param {Number} i Row\n * @param {Number} j Column\n * @return {Boolean} Mask value\n */\nfunction getMaskAt (maskPattern, i, j) {\n switch (maskPattern) {\n case exports.Patterns.PATTERN000: return (i + j) % 2 === 0\n case exports.Patterns.PATTERN001: return i % 2 === 0\n case exports.Patterns.PATTERN010: return j % 3 === 0\n case exports.Patterns.PATTERN011: return (i + j) % 3 === 0\n case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0\n case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0\n case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0\n case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0\n\n default: throw new Error('bad maskPattern:' + maskPattern)\n }\n}\n\n/**\n * Apply a mask pattern to a BitMatrix\n *\n * @param {Number} pattern Pattern reference number\n * @param {BitMatrix} data BitMatrix data\n */\nexports.applyMask = function applyMask (pattern, data) {\n const size = data.size\n\n for (let col = 0; col < size; col++) {\n for (let row = 0; row < size; row++) {\n if (data.isReserved(row, col)) continue\n data.xor(row, col, getMaskAt(pattern, row, col))\n }\n }\n}\n\n/**\n * Returns the best mask pattern for data\n *\n * @param {BitMatrix} data\n * @return {Number} Mask pattern reference number\n */\nexports.getBestMask = function getBestMask (data, setupFormatFunc) {\n const numPatterns = Object.keys(exports.Patterns).length\n let bestPattern = 0\n let lowerPenalty = Infinity\n\n for (let p = 0; p < numPatterns; p++) {\n setupFormatFunc(p)\n exports.applyMask(p, data)\n\n // Calculate penalty\n const penalty =\n exports.getPenaltyN1(data) +\n exports.getPenaltyN2(data) +\n exports.getPenaltyN3(data) +\n exports.getPenaltyN4(data)\n\n // Undo previously applied mask\n exports.applyMask(p, data)\n\n if (penalty < lowerPenalty) {\n lowerPenalty = penalty\n bestPattern = p\n }\n }\n\n return bestPattern\n}\n","const VersionCheck = require('./version-check')\nconst Regex = require('./regex')\n\n/**\n * Numeric mode encodes data from the decimal digit set (0 - 9)\n * (byte values 30HEX to 39HEX).\n * Normally, 3 data characters are represented by 10 bits.\n *\n * @type {Object}\n */\nexports.NUMERIC = {\n id: 'Numeric',\n bit: 1 << 0,\n ccBits: [10, 12, 14]\n}\n\n/**\n * Alphanumeric mode encodes data from a set of 45 characters,\n * i.e. 10 numeric digits (0 - 9),\n * 26 alphabetic characters (A - Z),\n * and 9 symbols (SP, $, %, *, +, -, ., /, :).\n * Normally, two input characters are represented by 11 bits.\n *\n * @type {Object}\n */\nexports.ALPHANUMERIC = {\n id: 'Alphanumeric',\n bit: 1 << 1,\n ccBits: [9, 11, 13]\n}\n\n/**\n * In byte mode, data is encoded at 8 bits per character.\n *\n * @type {Object}\n */\nexports.BYTE = {\n id: 'Byte',\n bit: 1 << 2,\n ccBits: [8, 16, 16]\n}\n\n/**\n * The Kanji mode efficiently encodes Kanji characters in accordance with\n * the Shift JIS system based on JIS X 0208.\n * The Shift JIS values are shifted from the JIS X 0208 values.\n * JIS X 0208 gives details of the shift coded representation.\n * Each two-byte character value is compacted to a 13-bit binary codeword.\n *\n * @type {Object}\n */\nexports.KANJI = {\n id: 'Kanji',\n bit: 1 << 3,\n ccBits: [8, 10, 12]\n}\n\n/**\n * Mixed mode will contain a sequences of data in a combination of any of\n * the modes described above\n *\n * @type {Object}\n */\nexports.MIXED = {\n bit: -1\n}\n\n/**\n * Returns the number of bits needed to store the data length\n * according to QR Code specifications.\n *\n * @param {Mode} mode Data mode\n * @param {Number} version QR Code version\n * @return {Number} Number of bits\n */\nexports.getCharCountIndicator = function getCharCountIndicator (mode, version) {\n if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)\n\n if (!VersionCheck.isValid(version)) {\n throw new Error('Invalid version: ' + version)\n }\n\n if (version >= 1 && version < 10) return mode.ccBits[0]\n else if (version < 27) return mode.ccBits[1]\n return mode.ccBits[2]\n}\n\n/**\n * Returns the most efficient mode to store the specified data\n *\n * @param {String} dataStr Input data string\n * @return {Mode} Best mode\n */\nexports.getBestModeForData = function getBestModeForData (dataStr) {\n if (Regex.testNumeric(dataStr)) return exports.NUMERIC\n else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC\n else if (Regex.testKanji(dataStr)) return exports.KANJI\n else return exports.BYTE\n}\n\n/**\n * Return mode name as string\n *\n * @param {Mode} mode Mode object\n * @returns {String} Mode name\n */\nexports.toString = function toString (mode) {\n if (mode && mode.id) return mode.id\n throw new Error('Invalid mode')\n}\n\n/**\n * Check if input param is a valid mode object\n *\n * @param {Mode} mode Mode object\n * @returns {Boolean} True if valid mode, false otherwise\n */\nexports.isValid = function isValid (mode) {\n return mode && mode.bit && mode.ccBits\n}\n\n/**\n * Get mode object from its name\n *\n * @param {String} string Mode name\n * @returns {Mode} Mode object\n */\nfunction fromString (string) {\n if (typeof string !== 'string') {\n throw new Error('Param is not a string')\n }\n\n const lcStr = string.toLowerCase()\n\n switch (lcStr) {\n case 'numeric':\n return exports.NUMERIC\n case 'alphanumeric':\n return exports.ALPHANUMERIC\n case 'kanji':\n return exports.KANJI\n case 'byte':\n return exports.BYTE\n default:\n throw new Error('Unknown mode: ' + string)\n }\n}\n\n/**\n * Returns mode from a value.\n * If value is not a valid mode, returns defaultValue\n *\n * @param {Mode|String} value Encoding mode\n * @param {Mode} defaultValue Fallback value\n * @return {Mode} Encoding mode\n */\nexports.from = function from (value, defaultValue) {\n if (exports.isValid(value)) {\n return value\n }\n\n try {\n return fromString(value)\n } catch (e) {\n return defaultValue\n }\n}\n","const Mode = require('./mode')\n\nfunction NumericData (data) {\n this.mode = Mode.NUMERIC\n this.data = data.toString()\n}\n\nNumericData.getBitsLength = function getBitsLength (length) {\n return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)\n}\n\nNumericData.prototype.getLength = function getLength () {\n return this.data.length\n}\n\nNumericData.prototype.getBitsLength = function getBitsLength () {\n return NumericData.getBitsLength(this.data.length)\n}\n\nNumericData.prototype.write = function write (bitBuffer) {\n let i, group, value\n\n // The input data string is divided into groups of three digits,\n // and each group is converted to its 10-bit binary equivalent.\n for (i = 0; i + 3 <= this.data.length; i += 3) {\n group = this.data.substr(i, 3)\n value = parseInt(group, 10)\n\n bitBuffer.put(value, 10)\n }\n\n // If the number of input digits is not an exact multiple of three,\n // the final one or two digits are converted to 4 or 7 bits respectively.\n const remainingNum = this.data.length - i\n if (remainingNum > 0) {\n group = this.data.substr(i)\n value = parseInt(group, 10)\n\n bitBuffer.put(value, remainingNum * 3 + 1)\n }\n}\n\nmodule.exports = NumericData\n","const GF = require('./galois-field')\n\n/**\n * Multiplies two polynomials inside Galois Field\n *\n * @param {Uint8Array} p1 Polynomial\n * @param {Uint8Array} p2 Polynomial\n * @return {Uint8Array} Product of p1 and p2\n */\nexports.mul = function mul (p1, p2) {\n const coeff = new Uint8Array(p1.length + p2.length - 1)\n\n for (let i = 0; i < p1.length; i++) {\n for (let j = 0; j < p2.length; j++) {\n coeff[i + j] ^= GF.mul(p1[i], p2[j])\n }\n }\n\n return coeff\n}\n\n/**\n * Calculate the remainder of polynomials division\n *\n * @param {Uint8Array} divident Polynomial\n * @param {Uint8Array} divisor Polynomial\n * @return {Uint8Array} Remainder\n */\nexports.mod = function mod (divident, divisor) {\n let result = new Uint8Array(divident)\n\n while ((result.length - divisor.length) >= 0) {\n const coeff = result[0]\n\n for (let i = 0; i < divisor.length; i++) {\n result[i] ^= GF.mul(divisor[i], coeff)\n }\n\n // remove all zeros from buffer head\n let offset = 0\n while (offset < result.length && result[offset] === 0) offset++\n result = result.slice(offset)\n }\n\n return result\n}\n\n/**\n * Generate an irreducible generator polynomial of specified degree\n * (used by Reed-Solomon encoder)\n *\n * @param {Number} degree Degree of the generator polynomial\n * @return {Uint8Array} Buffer containing polynomial coefficients\n */\nexports.generateECPolynomial = function generateECPolynomial (degree) {\n let poly = new Uint8Array([1])\n for (let i = 0; i < degree; i++) {\n poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]))\n }\n\n return poly\n}\n","const Utils = require('./utils')\nconst ECLevel = require('./error-correction-level')\nconst BitBuffer = require('./bit-buffer')\nconst BitMatrix = require('./bit-matrix')\nconst AlignmentPattern = require('./alignment-pattern')\nconst FinderPattern = require('./finder-pattern')\nconst MaskPattern = require('./mask-pattern')\nconst ECCode = require('./error-correction-code')\nconst ReedSolomonEncoder = require('./reed-solomon-encoder')\nconst Version = require('./version')\nconst FormatInfo = require('./format-info')\nconst Mode = require('./mode')\nconst Segments = require('./segments')\n\n/**\n * QRCode for JavaScript\n *\n * modified by Ryan Day for nodejs support\n * Copyright (c) 2011 Ryan Day\n *\n * Licensed under the MIT license:\n * http://www.opensource.org/licenses/mit-license.php\n *\n//---------------------------------------------------------------------\n// QRCode for JavaScript\n//\n// Copyright (c) 2009 Kazuhiko Arase\n//\n// URL: http://www.d-project.com/\n//\n// Licensed under the MIT license:\n// http://www.opensource.org/licenses/mit-license.php\n//\n// The word \"QR Code\" is registered trademark of\n// DENSO WAVE INCORPORATED\n// http://www.denso-wave.com/qrcode/faqpatent-e.html\n//\n//---------------------------------------------------------------------\n*/\n\n/**\n * Add finder patterns bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupFinderPattern (matrix, version) {\n const size = matrix.size\n const pos = FinderPattern.getPositions(version)\n\n for (let i = 0; i < pos.length; i++) {\n const row = pos[i][0]\n const col = pos[i][1]\n\n for (let r = -1; r <= 7; r++) {\n if (row + r <= -1 || size <= row + r) continue\n\n for (let c = -1; c <= 7; c++) {\n if (col + c <= -1 || size <= col + c) continue\n\n if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||\n (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||\n (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {\n matrix.set(row + r, col + c, true, true)\n } else {\n matrix.set(row + r, col + c, false, true)\n }\n }\n }\n }\n}\n\n/**\n * Add timing pattern bits to matrix\n *\n * Note: this function must be called before {@link setupAlignmentPattern}\n *\n * @param {BitMatrix} matrix Modules matrix\n */\nfunction setupTimingPattern (matrix) {\n const size = matrix.size\n\n for (let r = 8; r < size - 8; r++) {\n const value = r % 2 === 0\n matrix.set(r, 6, value, true)\n matrix.set(6, r, value, true)\n }\n}\n\n/**\n * Add alignment patterns bits to matrix\n *\n * Note: this function must be called after {@link setupTimingPattern}\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupAlignmentPattern (matrix, version) {\n const pos = AlignmentPattern.getPositions(version)\n\n for (let i = 0; i < pos.length; i++) {\n const row = pos[i][0]\n const col = pos[i][1]\n\n for (let r = -2; r <= 2; r++) {\n for (let c = -2; c <= 2; c++) {\n if (r === -2 || r === 2 || c === -2 || c === 2 ||\n (r === 0 && c === 0)) {\n matrix.set(row + r, col + c, true, true)\n } else {\n matrix.set(row + r, col + c, false, true)\n }\n }\n }\n }\n}\n\n/**\n * Add version info bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Number} version QR Code version\n */\nfunction setupVersionInfo (matrix, version) {\n const size = matrix.size\n const bits = Version.getEncodedBits(version)\n let row, col, mod\n\n for (let i = 0; i < 18; i++) {\n row = Math.floor(i / 3)\n col = i % 3 + size - 8 - 3\n mod = ((bits >> i) & 1) === 1\n\n matrix.set(row, col, mod, true)\n matrix.set(col, row, mod, true)\n }\n}\n\n/**\n * Add format info bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @param {Number} maskPattern Mask pattern reference value\n */\nfunction setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {\n const size = matrix.size\n const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)\n let i, mod\n\n for (i = 0; i < 15; i++) {\n mod = ((bits >> i) & 1) === 1\n\n // vertical\n if (i < 6) {\n matrix.set(i, 8, mod, true)\n } else if (i < 8) {\n matrix.set(i + 1, 8, mod, true)\n } else {\n matrix.set(size - 15 + i, 8, mod, true)\n }\n\n // horizontal\n if (i < 8) {\n matrix.set(8, size - i - 1, mod, true)\n } else if (i < 9) {\n matrix.set(8, 15 - i - 1 + 1, mod, true)\n } else {\n matrix.set(8, 15 - i - 1, mod, true)\n }\n }\n\n // fixed module\n matrix.set(size - 8, 8, 1, true)\n}\n\n/**\n * Add encoded data bits to matrix\n *\n * @param {BitMatrix} matrix Modules matrix\n * @param {Uint8Array} data Data codewords\n */\nfunction setupData (matrix, data) {\n const size = matrix.size\n let inc = -1\n let row = size - 1\n let bitIndex = 7\n let byteIndex = 0\n\n for (let col = size - 1; col > 0; col -= 2) {\n if (col === 6) col--\n\n while (true) {\n for (let c = 0; c < 2; c++) {\n if (!matrix.isReserved(row, col - c)) {\n let dark = false\n\n if (byteIndex < data.length) {\n dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)\n }\n\n matrix.set(row, col - c, dark)\n bitIndex--\n\n if (bitIndex === -1) {\n byteIndex++\n bitIndex = 7\n }\n }\n }\n\n row += inc\n\n if (row < 0 || size <= row) {\n row -= inc\n inc = -inc\n break\n }\n }\n }\n}\n\n/**\n * Create encoded codewords from data input\n *\n * @param {Number} version QR Code version\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @param {ByteData} data Data input\n * @return {Uint8Array} Buffer containing encoded codewords\n */\nfunction createData (version, errorCorrectionLevel, segments) {\n // Prepare data buffer\n const buffer = new BitBuffer()\n\n segments.forEach(function (data) {\n // prefix data with mode indicator (4 bits)\n buffer.put(data.mode.bit, 4)\n\n // Prefix data with character count indicator.\n // The character count indicator is a string of bits that represents the\n // number of characters that are being encoded.\n // The character count indicator must be placed after the mode indicator\n // and must be a certain number of bits long, depending on the QR version\n // and data mode\n // @see {@link Mode.getCharCountIndicator}.\n buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))\n\n // add binary data sequence to buffer\n data.write(buffer)\n })\n\n // Calculate required number of bits\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8\n\n // Add a terminator.\n // If the bit string is shorter than the total number of required bits,\n // a terminator of up to four 0s must be added to the right side of the string.\n // If the bit string is more than four bits shorter than the required number of bits,\n // add four 0s to the end.\n if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {\n buffer.put(0, 4)\n }\n\n // If the bit string is fewer than four bits shorter, add only the number of 0s that\n // are needed to reach the required number of bits.\n\n // After adding the terminator, if the number of bits in the string is not a multiple of 8,\n // pad the string on the right with 0s to make the string's length a multiple of 8.\n while (buffer.getLengthInBits() % 8 !== 0) {\n buffer.putBit(0)\n }\n\n // Add pad bytes if the string is still shorter than the total number of required bits.\n // Extend the buffer to fill the data capacity of the symbol corresponding to\n // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)\n // and 00010001 (0x11) alternately.\n const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8\n for (let i = 0; i < remainingByte; i++) {\n buffer.put(i % 2 ? 0x11 : 0xEC, 8)\n }\n\n return createCodewords(buffer, version, errorCorrectionLevel)\n}\n\n/**\n * Encode input data with Reed-Solomon and return codewords with\n * relative error correction bits\n *\n * @param {BitBuffer} bitBuffer Data to encode\n * @param {Number} version QR Code version\n * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level\n * @return {Uint8Array} Buffer containing encoded codewords\n */\nfunction createCodewords (bitBuffer, version, errorCorrectionLevel) {\n // Total codewords for this QR code version (Data + Error correction)\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n\n // Total number of error correction codewords\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n\n // Total number of data codewords\n const dataTotalCodewords = totalCodewords - ecTotalCodewords\n\n // Total number of blocks\n const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)\n\n // Calculate how many blocks each group should contain\n const blocksInGroup2 = totalCodewords % ecTotalBlocks\n const blocksInGroup1 = ecTotalBlocks - blocksInGroup2\n\n const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)\n\n const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)\n const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1\n\n // Number of EC codewords is the same for both groups\n const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1\n\n // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount\n const rs = new ReedSolomonEncoder(ecCount)\n\n let offset = 0\n const dcData = new Array(ecTotalBlocks)\n const ecData = new Array(ecTotalBlocks)\n let maxDataSize = 0\n const buffer = new Uint8Array(bitBuffer.buffer)\n\n // Divide the buffer into the required number of blocks\n for (let b = 0; b < ecTotalBlocks; b++) {\n const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2\n\n // extract a block of data from buffer\n dcData[b] = buffer.slice(offset, offset + dataSize)\n\n // Calculate EC codewords for this data block\n ecData[b] = rs.encode(dcData[b])\n\n offset += dataSize\n maxDataSize = Math.max(maxDataSize, dataSize)\n }\n\n // Create final data\n // Interleave the data and error correction codewords from each block\n const data = new Uint8Array(totalCodewords)\n let index = 0\n let i, r\n\n // Add data codewords\n for (i = 0; i < maxDataSize; i++) {\n for (r = 0; r < ecTotalBlocks; r++) {\n if (i < dcData[r].length) {\n data[index++] = dcData[r][i]\n }\n }\n }\n\n // Apped EC codewords\n for (i = 0; i < ecCount; i++) {\n for (r = 0; r < ecTotalBlocks; r++) {\n data[index++] = ecData[r][i]\n }\n }\n\n return data\n}\n\n/**\n * Build QR Code symbol\n *\n * @param {String} data Input string\n * @param {Number} version QR Code version\n * @param {ErrorCorretionLevel} errorCorrectionLevel Error level\n * @param {MaskPattern} maskPattern Mask pattern\n * @return {Object} Object containing symbol data\n */\nfunction createSymbol (data, version, errorCorrectionLevel, maskPattern) {\n let segments\n\n if (Array.isArray(data)) {\n segments = Segments.fromArray(data)\n } else if (typeof data === 'string') {\n let estimatedVersion = version\n\n if (!estimatedVersion) {\n const rawSegments = Segments.rawSplit(data)\n\n // Estimate best version that can contain raw splitted segments\n estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel)\n }\n\n // Build optimized segments\n // If estimated version is undefined, try with the highest version\n segments = Segments.fromString(data, estimatedVersion || 40)\n } else {\n throw new Error('Invalid data')\n }\n\n // Get the min version that can contain data\n const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel)\n\n // If no version is found, data cannot be stored\n if (!bestVersion) {\n throw new Error('The amount of data is too big to be stored in a QR Code')\n }\n\n // If not specified, use min version as default\n if (!version) {\n version = bestVersion\n\n // Check if the specified version can contain the data\n } else if (version < bestVersion) {\n throw new Error('\\n' +\n 'The chosen QR Code version cannot contain this amount of data.\\n' +\n 'Minimum version required to store current data is: ' + bestVersion + '.\\n'\n )\n }\n\n const dataBits = createData(version, errorCorrectionLevel, segments)\n\n // Allocate matrix buffer\n const moduleCount = Utils.getSymbolSize(version)\n const modules = new BitMatrix(moduleCount)\n\n // Add function modules\n setupFinderPattern(modules, version)\n setupTimingPattern(modules)\n setupAlignmentPattern(modules, version)\n\n // Add temporary dummy bits for format info just to set them as reserved.\n // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}\n // since the masking operation must be performed only on the encoding region.\n // These blocks will be replaced with correct values later in code.\n setupFormatInfo(modules, errorCorrectionLevel, 0)\n\n if (version >= 7) {\n setupVersionInfo(modules, version)\n }\n\n // Add data codewords\n setupData(modules, dataBits)\n\n if (isNaN(maskPattern)) {\n // Find best mask pattern\n maskPattern = MaskPattern.getBestMask(modules,\n setupFormatInfo.bind(null, modules, errorCorrectionLevel))\n }\n\n // Apply mask pattern\n MaskPattern.applyMask(maskPattern, modules)\n\n // Replace format info bits with correct values\n setupFormatInfo(modules, errorCorrectionLevel, maskPattern)\n\n return {\n modules: modules,\n version: version,\n errorCorrectionLevel: errorCorrectionLevel,\n maskPattern: maskPattern,\n segments: segments\n }\n}\n\n/**\n * QR Code\n *\n * @param {String | Array} data Input data\n * @param {Object} options Optional configurations\n * @param {Number} options.version QR Code version\n * @param {String} options.errorCorrectionLevel Error correction level\n * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis\n */\nexports.create = function create (data, options) {\n if (typeof data === 'undefined' || data === '') {\n throw new Error('No input text')\n }\n\n let errorCorrectionLevel = ECLevel.M\n let version\n let mask\n\n if (typeof options !== 'undefined') {\n // Use higher error correction level as default\n errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)\n version = Version.from(options.version)\n mask = MaskPattern.from(options.maskPattern)\n\n if (options.toSJISFunc) {\n Utils.setToSJISFunction(options.toSJISFunc)\n }\n }\n\n return createSymbol(data, version, errorCorrectionLevel, mask)\n}\n","const Polynomial = require('./polynomial')\n\nfunction ReedSolomonEncoder (degree) {\n this.genPoly = undefined\n this.degree = degree\n\n if (this.degree) this.initialize(this.degree)\n}\n\n/**\n * Initialize the encoder.\n * The input param should correspond to the number of error correction codewords.\n *\n * @param {Number} degree\n */\nReedSolomonEncoder.prototype.initialize = function initialize (degree) {\n // create an irreducible generator polynomial\n this.degree = degree\n this.genPoly = Polynomial.generateECPolynomial(this.degree)\n}\n\n/**\n * Encodes a chunk of data\n *\n * @param {Uint8Array} data Buffer containing input data\n * @return {Uint8Array} Buffer containing encoded data\n */\nReedSolomonEncoder.prototype.encode = function encode (data) {\n if (!this.genPoly) {\n throw new Error('Encoder not initialized')\n }\n\n // Calculate EC for this data block\n // extends data size to data+genPoly size\n const paddedData = new Uint8Array(data.length + this.degree)\n paddedData.set(data)\n\n // The error correction codewords are the remainder after dividing the data codewords\n // by a generator polynomial\n const remainder = Polynomial.mod(paddedData, this.genPoly)\n\n // return EC data blocks (last n byte, where n is the degree of genPoly)\n // If coefficients number in remainder are less than genPoly degree,\n // pad with 0s to the left to reach the needed number of coefficients\n const start = this.degree - remainder.length\n if (start > 0) {\n const buff = new Uint8Array(this.degree)\n buff.set(remainder, start)\n\n return buff\n }\n\n return remainder\n}\n\nmodule.exports = ReedSolomonEncoder\n","const numeric = '[0-9]+'\nconst alphanumeric = '[A-Z $%*+\\\\-./:]+'\nlet kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +\n '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +\n '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +\n '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+'\nkanji = kanji.replace(/u/g, '\\\\u')\n\nconst byte = '(?:(?![A-Z0-9 $%*+\\\\-./:]|' + kanji + ')(?:.|[\\r\\n]))+'\n\nexports.KANJI = new RegExp(kanji, 'g')\nexports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\\\-./:]+', 'g')\nexports.BYTE = new RegExp(byte, 'g')\nexports.NUMERIC = new RegExp(numeric, 'g')\nexports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')\n\nconst TEST_KANJI = new RegExp('^' + kanji + '$')\nconst TEST_NUMERIC = new RegExp('^' + numeric + '$')\nconst TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\\\-./:]+$')\n\nexports.testKanji = function testKanji (str) {\n return TEST_KANJI.test(str)\n}\n\nexports.testNumeric = function testNumeric (str) {\n return TEST_NUMERIC.test(str)\n}\n\nexports.testAlphanumeric = function testAlphanumeric (str) {\n return TEST_ALPHANUMERIC.test(str)\n}\n","const Mode = require('./mode')\nconst NumericData = require('./numeric-data')\nconst AlphanumericData = require('./alphanumeric-data')\nconst ByteData = require('./byte-data')\nconst KanjiData = require('./kanji-data')\nconst Regex = require('./regex')\nconst Utils = require('./utils')\nconst dijkstra = require('dijkstrajs')\n\n/**\n * Returns UTF8 byte length\n *\n * @param {String} str Input string\n * @return {Number} Number of byte\n */\nfunction getStringByteLength (str) {\n return unescape(encodeURIComponent(str)).length\n}\n\n/**\n * Get a list of segments of the specified mode\n * from a string\n *\n * @param {Mode} mode Segment mode\n * @param {String} str String to process\n * @return {Array} Array of object with segments data\n */\nfunction getSegments (regex, mode, str) {\n const segments = []\n let result\n\n while ((result = regex.exec(str)) !== null) {\n segments.push({\n data: result[0],\n index: result.index,\n mode: mode,\n length: result[0].length\n })\n }\n\n return segments\n}\n\n/**\n * Extracts a series of segments with the appropriate\n * modes from a string\n *\n * @param {String} dataStr Input string\n * @return {Array} Array of object with segments data\n */\nfunction getSegmentsFromString (dataStr) {\n const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)\n const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)\n let byteSegs\n let kanjiSegs\n\n if (Utils.isKanjiModeEnabled()) {\n byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)\n kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)\n } else {\n byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)\n kanjiSegs = []\n }\n\n const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)\n\n return segs\n .sort(function (s1, s2) {\n return s1.index - s2.index\n })\n .map(function (obj) {\n return {\n data: obj.data,\n mode: obj.mode,\n length: obj.length\n }\n })\n}\n\n/**\n * Returns how many bits are needed to encode a string of\n * specified length with the specified mode\n *\n * @param {Number} length String length\n * @param {Mode} mode Segment mode\n * @return {Number} Bit length\n */\nfunction getSegmentBitsLength (length, mode) {\n switch (mode) {\n case Mode.NUMERIC:\n return NumericData.getBitsLength(length)\n case Mode.ALPHANUMERIC:\n return AlphanumericData.getBitsLength(length)\n case Mode.KANJI:\n return KanjiData.getBitsLength(length)\n case Mode.BYTE:\n return ByteData.getBitsLength(length)\n }\n}\n\n/**\n * Merges adjacent segments which have the same mode\n *\n * @param {Array} segs Array of object with segments data\n * @return {Array} Array of object with segments data\n */\nfunction mergeSegments (segs) {\n return segs.reduce(function (acc, curr) {\n const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null\n if (prevSeg && prevSeg.mode === curr.mode) {\n acc[acc.length - 1].data += curr.data\n return acc\n }\n\n acc.push(curr)\n return acc\n }, [])\n}\n\n/**\n * Generates a list of all possible nodes combination which\n * will be used to build a segments graph.\n *\n * Nodes are divided by groups. Each group will contain a list of all the modes\n * in which is possible to encode the given text.\n *\n * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.\n * The group for '12345' will contain then 3 objects, one for each\n * possible encoding mode.\n *\n * Each node represents a possible segment.\n *\n * @param {Array} segs Array of object with segments data\n * @return {Array} Array of object with segments data\n */\nfunction buildNodes (segs) {\n const nodes = []\n for (let i = 0; i < segs.length; i++) {\n const seg = segs[i]\n\n switch (seg.mode) {\n case Mode.NUMERIC:\n nodes.push([seg,\n { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },\n { data: seg.data, mode: Mode.BYTE, length: seg.length }\n ])\n break\n case Mode.ALPHANUMERIC:\n nodes.push([seg,\n { data: seg.data, mode: Mode.BYTE, length: seg.length }\n ])\n break\n case Mode.KANJI:\n nodes.push([seg,\n { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }\n ])\n break\n case Mode.BYTE:\n nodes.push([\n { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }\n ])\n }\n }\n\n return nodes\n}\n\n/**\n * Builds a graph from a list of nodes.\n * All segments in each node group will be connected with all the segments of\n * the next group and so on.\n *\n * At each connection will be assigned a weight depending on the\n * segment's byte length.\n *\n * @param {Array} nodes Array of object with segments data\n * @param {Number} version QR Code version\n * @return {Object} Graph of all possible segments\n */\nfunction buildGraph (nodes, version) {\n const table = {}\n const graph = { start: {} }\n let prevNodeIds = ['start']\n\n for (let i = 0; i < nodes.length; i++) {\n const nodeGroup = nodes[i]\n const currentNodeIds = []\n\n for (let j = 0; j < nodeGroup.length; j++) {\n const node = nodeGroup[j]\n const key = '' + i + j\n\n currentNodeIds.push(key)\n table[key] = { node: node, lastCount: 0 }\n graph[key] = {}\n\n for (let n = 0; n < prevNodeIds.length; n++) {\n const prevNodeId = prevNodeIds[n]\n\n if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {\n graph[prevNodeId][key] =\n getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -\n getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)\n\n table[prevNodeId].lastCount += node.length\n } else {\n if (table[prevNodeId]) table[prevNodeId].lastCount = node.length\n\n graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +\n 4 + Mode.getCharCountIndicator(node.mode, version) // switch cost\n }\n }\n }\n\n prevNodeIds = currentNodeIds\n }\n\n for (let n = 0; n < prevNodeIds.length; n++) {\n graph[prevNodeIds[n]].end = 0\n }\n\n return { map: graph, table: table }\n}\n\n/**\n * Builds a segment from a specified data and mode.\n * If a mode is not specified, the more suitable will be used.\n *\n * @param {String} data Input data\n * @param {Mode | String} modesHint Data mode\n * @return {Segment} Segment\n */\nfunction buildSingleSegment (data, modesHint) {\n let mode\n const bestMode = Mode.getBestModeForData(data)\n\n mode = Mode.from(modesHint, bestMode)\n\n // Make sure data can be encoded\n if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {\n throw new Error('\"' + data + '\"' +\n ' cannot be encoded with mode ' + Mode.toString(mode) +\n '.\\n Suggested mode is: ' + Mode.toString(bestMode))\n }\n\n // Use Mode.BYTE if Kanji support is disabled\n if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {\n mode = Mode.BYTE\n }\n\n switch (mode) {\n case Mode.NUMERIC:\n return new NumericData(data)\n\n case Mode.ALPHANUMERIC:\n return new AlphanumericData(data)\n\n case Mode.KANJI:\n return new KanjiData(data)\n\n case Mode.BYTE:\n return new ByteData(data)\n }\n}\n\n/**\n * Builds a list of segments from an array.\n * Array can contain Strings or Objects with segment's info.\n *\n * For each item which is a string, will be generated a segment with the given\n * string and the more appropriate encoding mode.\n *\n * For each item which is an object, will be generated a segment with the given\n * data and mode.\n * Objects must contain at least the property \"data\".\n * If property \"mode\" is not present, the more suitable mode will be used.\n *\n * @param {Array} array Array of objects with segments data\n * @return {Array} Array of Segments\n */\nexports.fromArray = function fromArray (array) {\n return array.reduce(function (acc, seg) {\n if (typeof seg === 'string') {\n acc.push(buildSingleSegment(seg, null))\n } else if (seg.data) {\n acc.push(buildSingleSegment(seg.data, seg.mode))\n }\n\n return acc\n }, [])\n}\n\n/**\n * Builds an optimized sequence of segments from a string,\n * which will produce the shortest possible bitstream.\n *\n * @param {String} data Input string\n * @param {Number} version QR Code version\n * @return {Array} Array of segments\n */\nexports.fromString = function fromString (data, version) {\n const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())\n\n const nodes = buildNodes(segs)\n const graph = buildGraph(nodes, version)\n const path = dijkstra.find_path(graph.map, 'start', 'end')\n\n const optimizedSegs = []\n for (let i = 1; i < path.length - 1; i++) {\n optimizedSegs.push(graph.table[path[i]].node)\n }\n\n return exports.fromArray(mergeSegments(optimizedSegs))\n}\n\n/**\n * Splits a string in various segments with the modes which\n * best represent their content.\n * The produced segments are far from being optimized.\n * The output of this function is only used to estimate a QR Code version\n * which may contain the data.\n *\n * @param {string} data Input string\n * @return {Array} Array of segments\n */\nexports.rawSplit = function rawSplit (data) {\n return exports.fromArray(\n getSegmentsFromString(data, Utils.isKanjiModeEnabled())\n )\n}\n","let toSJISFunction\nconst CODEWORDS_COUNT = [\n 0, // Not used\n 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,\n 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,\n 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,\n 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706\n]\n\n/**\n * Returns the QR Code size for the specified version\n *\n * @param {Number} version QR Code version\n * @return {Number} size of QR code\n */\nexports.getSymbolSize = function getSymbolSize (version) {\n if (!version) throw new Error('\"version\" cannot be null or undefined')\n if (version < 1 || version > 40) throw new Error('\"version\" should be in range from 1 to 40')\n return version * 4 + 17\n}\n\n/**\n * Returns the total number of codewords used to store data and EC information.\n *\n * @param {Number} version QR Code version\n * @return {Number} Data length in bits\n */\nexports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {\n return CODEWORDS_COUNT[version]\n}\n\n/**\n * Encode data with Bose-Chaudhuri-Hocquenghem\n *\n * @param {Number} data Value to encode\n * @return {Number} Encoded value\n */\nexports.getBCHDigit = function (data) {\n let digit = 0\n\n while (data !== 0) {\n digit++\n data >>>= 1\n }\n\n return digit\n}\n\nexports.setToSJISFunction = function setToSJISFunction (f) {\n if (typeof f !== 'function') {\n throw new Error('\"toSJISFunc\" is not a valid function.')\n }\n\n toSJISFunction = f\n}\n\nexports.isKanjiModeEnabled = function () {\n return typeof toSJISFunction !== 'undefined'\n}\n\nexports.toSJIS = function toSJIS (kanji) {\n return toSJISFunction(kanji)\n}\n","/**\n * Check if QR Code version is valid\n *\n * @param {Number} version QR Code version\n * @return {Boolean} true if valid version, false otherwise\n */\nexports.isValid = function isValid (version) {\n return !isNaN(version) && version >= 1 && version <= 40\n}\n","const Utils = require('./utils')\nconst ECCode = require('./error-correction-code')\nconst ECLevel = require('./error-correction-level')\nconst Mode = require('./mode')\nconst VersionCheck = require('./version-check')\n\n// Generator polynomial used to encode version information\nconst G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)\nconst G18_BCH = Utils.getBCHDigit(G18)\n\nfunction getBestVersionForDataLength (mode, length, errorCorrectionLevel) {\n for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {\n if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {\n return currentVersion\n }\n }\n\n return undefined\n}\n\nfunction getReservedBitsCount (mode, version) {\n // Character count indicator + mode indicator bits\n return Mode.getCharCountIndicator(mode, version) + 4\n}\n\nfunction getTotalBitsFromDataArray (segments, version) {\n let totalBits = 0\n\n segments.forEach(function (data) {\n const reservedBits = getReservedBitsCount(data.mode, version)\n totalBits += reservedBits + data.getBitsLength()\n })\n\n return totalBits\n}\n\nfunction getBestVersionForMixedData (segments, errorCorrectionLevel) {\n for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {\n const length = getTotalBitsFromDataArray(segments, currentVersion)\n if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {\n return currentVersion\n }\n }\n\n return undefined\n}\n\n/**\n * Returns version number from a value.\n * If value is not a valid version, returns defaultValue\n *\n * @param {Number|String} value QR Code version\n * @param {Number} defaultValue Fallback value\n * @return {Number} QR Code version number\n */\nexports.from = function from (value, defaultValue) {\n if (VersionCheck.isValid(value)) {\n return parseInt(value, 10)\n }\n\n return defaultValue\n}\n\n/**\n * Returns how much data can be stored with the specified QR code version\n * and error correction level\n *\n * @param {Number} version QR Code version (1-40)\n * @param {Number} errorCorrectionLevel Error correction level\n * @param {Mode} mode Data mode\n * @return {Number} Quantity of storable data\n */\nexports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {\n if (!VersionCheck.isValid(version)) {\n throw new Error('Invalid QR Code version')\n }\n\n // Use Byte mode as default\n if (typeof mode === 'undefined') mode = Mode.BYTE\n\n // Total codewords for this QR code version (Data + Error correction)\n const totalCodewords = Utils.getSymbolTotalCodewords(version)\n\n // Total number of error correction codewords\n const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)\n\n // Total number of data codewords\n const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8\n\n if (mode === Mode.MIXED) return dataTotalCodewordsBits\n\n const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)\n\n // Return max number of storable codewords\n switch (mode) {\n case Mode.NUMERIC:\n return Math.floor((usableBits / 10) * 3)\n\n case Mode.ALPHANUMERIC:\n return Math.floor((usableBits / 11) * 2)\n\n case Mode.KANJI:\n return Math.floor(usableBits / 13)\n\n case Mode.BYTE:\n default:\n return Math.floor(usableBits / 8)\n }\n}\n\n/**\n * Returns the minimum version needed to contain the amount of data\n *\n * @param {Segment} data Segment of data\n * @param {Number} [errorCorrectionLevel=H] Error correction level\n * @param {Mode} mode Data mode\n * @return {Number} QR Code version\n */\nexports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {\n let seg\n\n const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)\n\n if (Array.isArray(data)) {\n if (data.length > 1) {\n return getBestVersionForMixedData(data, ecl)\n }\n\n if (data.length === 0) {\n return 1\n }\n\n seg = data[0]\n } else {\n seg = data\n }\n\n return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)\n}\n\n/**\n * Returns version information with relative error correction bits\n *\n * The version information is included in QR Code symbols of version 7 or larger.\n * It consists of an 18-bit sequence containing 6 data bits,\n * with 12 error correction bits calculated using the (18, 6) Golay code.\n *\n * @param {Number} version QR Code version\n * @return {Number} Encoded version info bits\n */\nexports.getEncodedBits = function getEncodedBits (version) {\n if (!VersionCheck.isValid(version) || version < 7) {\n throw new Error('Invalid QR Code version')\n }\n\n let d = version << 12\n\n while (Utils.getBCHDigit(d) - G18_BCH >= 0) {\n d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))\n }\n\n return (version << 12) | d\n}\n","const Utils = require('./utils')\n\nfunction clearCanvas (ctx, canvas, size) {\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n\n if (!canvas.style) canvas.style = {}\n canvas.height = size\n canvas.width = size\n canvas.style.height = size + 'px'\n canvas.style.width = size + 'px'\n}\n\nfunction getCanvasElement () {\n try {\n return document.createElement('canvas')\n } catch (e) {\n throw new Error('You need to specify a canvas element')\n }\n}\n\nexports.render = function render (qrData, canvas, options) {\n let opts = options\n let canvasEl = canvas\n\n if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {\n opts = canvas\n canvas = undefined\n }\n\n if (!canvas) {\n canvasEl = getCanvasElement()\n }\n\n opts = Utils.getOptions(opts)\n const size = Utils.getImageWidth(qrData.modules.size, opts)\n\n const ctx = canvasEl.getContext('2d')\n const image = ctx.createImageData(size, size)\n Utils.qrToImageData(image.data, qrData, opts)\n\n clearCanvas(ctx, canvasEl, size)\n ctx.putImageData(image, 0, 0)\n\n return canvasEl\n}\n\nexports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {\n let opts = options\n\n if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {\n opts = canvas\n canvas = undefined\n }\n\n if (!opts) opts = {}\n\n const canvasEl = exports.render(qrData, canvas, opts)\n\n const type = opts.type || 'image/png'\n const rendererOpts = opts.rendererOpts || {}\n\n return canvasEl.toDataURL(type, rendererOpts.quality)\n}\n","const Utils = require('./utils')\n\nfunction getColorAttrib (color, attrib) {\n const alpha = color.a / 255\n const str = attrib + '=\"' + color.hex + '\"'\n\n return alpha < 1\n ? str + ' ' + attrib + '-opacity=\"' + alpha.toFixed(2).slice(1) + '\"'\n : str\n}\n\nfunction svgCmd (cmd, x, y) {\n let str = cmd + x\n if (typeof y !== 'undefined') str += ' ' + y\n\n return str\n}\n\nfunction qrToPath (data, size, margin) {\n let path = ''\n let moveBy = 0\n let newRow = false\n let lineLength = 0\n\n for (let i = 0; i < data.length; i++) {\n const col = Math.floor(i % size)\n const row = Math.floor(i / size)\n\n if (!col && !newRow) newRow = true\n\n if (data[i]) {\n lineLength++\n\n if (!(i > 0 && col > 0 && data[i - 1])) {\n path += newRow\n ? svgCmd('M', col + margin, 0.5 + row + margin)\n : svgCmd('m', moveBy, 0)\n\n moveBy = 0\n newRow = false\n }\n\n if (!(col + 1 < size && data[i + 1])) {\n path += svgCmd('h', lineLength)\n lineLength = 0\n }\n } else {\n moveBy++\n }\n }\n\n return path\n}\n\nexports.render = function render (qrData, options, cb) {\n const opts = Utils.getOptions(options)\n const size = qrData.modules.size\n const data = qrData.modules.data\n const qrcodesize = size + opts.margin * 2\n\n const bg = !opts.color.light.a\n ? ''\n : ''\n\n const path =\n ''\n\n const viewBox = 'viewBox=\"' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '\"'\n\n const width = !opts.width ? '' : 'width=\"' + opts.width + '\" height=\"' + opts.width + '\" '\n\n const svgTag = '' + bg + path + '\\n'\n\n if (typeof cb === 'function') {\n cb(null, svgTag)\n }\n\n return svgTag\n}\n","function hex2rgba (hex) {\n if (typeof hex === 'number') {\n hex = hex.toString()\n }\n\n if (typeof hex !== 'string') {\n throw new Error('Color should be defined as hex string')\n }\n\n let hexCode = hex.slice().replace('#', '').split('')\n if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {\n throw new Error('Invalid hex color: ' + hex)\n }\n\n // Convert from short to long form (fff -> ffffff)\n if (hexCode.length === 3 || hexCode.length === 4) {\n hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {\n return [c, c]\n }))\n }\n\n // Add default alpha value\n if (hexCode.length === 6) hexCode.push('F', 'F')\n\n const hexValue = parseInt(hexCode.join(''), 16)\n\n return {\n r: (hexValue >> 24) & 255,\n g: (hexValue >> 16) & 255,\n b: (hexValue >> 8) & 255,\n a: hexValue & 255,\n hex: '#' + hexCode.slice(0, 6).join('')\n }\n}\n\nexports.getOptions = function getOptions (options) {\n if (!options) options = {}\n if (!options.color) options.color = {}\n\n const margin = typeof options.margin === 'undefined' ||\n options.margin === null ||\n options.margin < 0\n ? 4\n : options.margin\n\n const width = options.width && options.width >= 21 ? options.width : undefined\n const scale = options.scale || 4\n\n return {\n width: width,\n scale: width ? 4 : scale,\n margin: margin,\n color: {\n dark: hex2rgba(options.color.dark || '#000000ff'),\n light: hex2rgba(options.color.light || '#ffffffff')\n },\n type: options.type,\n rendererOpts: options.rendererOpts || {}\n }\n}\n\nexports.getScale = function getScale (qrSize, opts) {\n return opts.width && opts.width >= qrSize + opts.margin * 2\n ? opts.width / (qrSize + opts.margin * 2)\n : opts.scale\n}\n\nexports.getImageWidth = function getImageWidth (qrSize, opts) {\n const scale = exports.getScale(qrSize, opts)\n return Math.floor((qrSize + opts.margin * 2) * scale)\n}\n\nexports.qrToImageData = function qrToImageData (imgData, qr, opts) {\n const size = qr.modules.size\n const data = qr.modules.data\n const scale = exports.getScale(size, opts)\n const symbolSize = Math.floor((size + opts.margin * 2) * scale)\n const scaledMargin = opts.margin * scale\n const palette = [opts.color.light, opts.color.dark]\n\n for (let i = 0; i < symbolSize; i++) {\n for (let j = 0; j < symbolSize; j++) {\n let posDst = (i * symbolSize + j) * 4\n let pxColor = opts.color.light\n\n if (i >= scaledMargin && j >= scaledMargin &&\n i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {\n const iSrc = Math.floor((i - scaledMargin) / scale)\n const jSrc = Math.floor((j - scaledMargin) / scale)\n pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0]\n }\n\n imgData[posDst++] = pxColor.r\n imgData[posDst++] = pxColor.g\n imgData[posDst++] = pxColor.b\n imgData[posDst] = pxColor.a\n }\n }\n}\n","import { Subject } from './Subject';\nexport class BehaviorSubject extends Subject {\n constructor(_value) {\n super();\n this._value = _value;\n }\n get value() {\n return this.getValue();\n }\n _subscribe(subscriber) {\n const subscription = super._subscribe(subscriber);\n !subscription.closed && subscriber.next(this._value);\n return subscription;\n }\n getValue() {\n const { hasError, thrownError, _value } = this;\n if (hasError) {\n throw thrownError;\n }\n this._throwIfClosed();\n return _value;\n }\n next(value) {\n super.next((this._value = value));\n }\n}\n","import { SafeSubscriber, Subscriber } from './Subscriber';\nimport { isSubscription } from './Subscription';\nimport { observable as Symbol_observable } from './symbol/observable';\nimport { pipeFromArray } from './util/pipe';\nimport { config } from './config';\nimport { isFunction } from './util/isFunction';\nimport { errorContext } from './util/errorContext';\nexport class Observable {\n constructor(subscribe) {\n if (subscribe) {\n this._subscribe = subscribe;\n }\n }\n lift(operator) {\n const observable = new Observable();\n observable.source = this;\n observable.operator = operator;\n return observable;\n }\n subscribe(observerOrNext, error, complete) {\n const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);\n errorContext(() => {\n const { operator, source } = this;\n subscriber.add(operator\n ?\n operator.call(subscriber, source)\n : source\n ?\n this._subscribe(subscriber)\n :\n this._trySubscribe(subscriber));\n });\n return subscriber;\n }\n _trySubscribe(sink) {\n try {\n return this._subscribe(sink);\n }\n catch (err) {\n sink.error(err);\n }\n }\n forEach(next, promiseCtor) {\n promiseCtor = getPromiseCtor(promiseCtor);\n return new promiseCtor((resolve, reject) => {\n const subscriber = new SafeSubscriber({\n next: (value) => {\n try {\n next(value);\n }\n catch (err) {\n reject(err);\n subscriber.unsubscribe();\n }\n },\n error: reject,\n complete: resolve,\n });\n this.subscribe(subscriber);\n });\n }\n _subscribe(subscriber) {\n var _a;\n return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);\n }\n [Symbol_observable]() {\n return this;\n }\n pipe(...operations) {\n return pipeFromArray(operations)(this);\n }\n toPromise(promiseCtor) {\n promiseCtor = getPromiseCtor(promiseCtor);\n return new promiseCtor((resolve, reject) => {\n let value;\n this.subscribe((x) => (value = x), (err) => reject(err), () => resolve(value));\n });\n }\n}\nObservable.create = (subscribe) => {\n return new Observable(subscribe);\n};\nfunction getPromiseCtor(promiseCtor) {\n var _a;\n return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;\n}\nfunction isObserver(value) {\n return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);\n}\nfunction isSubscriber(value) {\n return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));\n}\n","import { Subject } from './Subject';\nimport { dateTimestampProvider } from './scheduler/dateTimestampProvider';\nexport class ReplaySubject extends Subject {\n constructor(_bufferSize = Infinity, _windowTime = Infinity, _timestampProvider = dateTimestampProvider) {\n super();\n this._bufferSize = _bufferSize;\n this._windowTime = _windowTime;\n this._timestampProvider = _timestampProvider;\n this._buffer = [];\n this._infiniteTimeWindow = true;\n this._infiniteTimeWindow = _windowTime === Infinity;\n this._bufferSize = Math.max(1, _bufferSize);\n this._windowTime = Math.max(1, _windowTime);\n }\n next(value) {\n const { isStopped, _buffer, _infiniteTimeWindow, _timestampProvider, _windowTime } = this;\n if (!isStopped) {\n _buffer.push(value);\n !_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime);\n }\n this._trimBuffer();\n super.next(value);\n }\n _subscribe(subscriber) {\n this._throwIfClosed();\n this._trimBuffer();\n const subscription = this._innerSubscribe(subscriber);\n const { _infiniteTimeWindow, _buffer } = this;\n const copy = _buffer.slice();\n for (let i = 0; i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) {\n subscriber.next(copy[i]);\n }\n this._checkFinalizedStatuses(subscriber);\n return subscription;\n }\n _trimBuffer() {\n const { _bufferSize, _timestampProvider, _buffer, _infiniteTimeWindow } = this;\n const adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;\n _bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);\n if (!_infiniteTimeWindow) {\n const now = _timestampProvider.now();\n let last = 0;\n for (let i = 1; i < _buffer.length && _buffer[i] <= now; i += 2) {\n last = i;\n }\n last && _buffer.splice(0, last + 1);\n }\n }\n}\n","import { createErrorClass } from './createErrorClass';\nexport const ObjectUnsubscribedError = createErrorClass((_super) => function ObjectUnsubscribedErrorImpl() {\n _super(this);\n this.name = 'ObjectUnsubscribedError';\n this.message = 'object unsubscribed';\n});\n","import { Observable } from './Observable';\nimport { Subscription, EMPTY_SUBSCRIPTION } from './Subscription';\nimport { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';\nimport { arrRemove } from './util/arrRemove';\nimport { errorContext } from './util/errorContext';\nexport class Subject extends Observable {\n constructor() {\n super();\n this.closed = false;\n this.currentObservers = null;\n this.observers = [];\n this.isStopped = false;\n this.hasError = false;\n this.thrownError = null;\n }\n lift(operator) {\n const subject = new AnonymousSubject(this, this);\n subject.operator = operator;\n return subject;\n }\n _throwIfClosed() {\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n }\n next(value) {\n errorContext(() => {\n this._throwIfClosed();\n if (!this.isStopped) {\n if (!this.currentObservers) {\n this.currentObservers = Array.from(this.observers);\n }\n for (const observer of this.currentObservers) {\n observer.next(value);\n }\n }\n });\n }\n error(err) {\n errorContext(() => {\n this._throwIfClosed();\n if (!this.isStopped) {\n this.hasError = this.isStopped = true;\n this.thrownError = err;\n const { observers } = this;\n while (observers.length) {\n observers.shift().error(err);\n }\n }\n });\n }\n complete() {\n errorContext(() => {\n this._throwIfClosed();\n if (!this.isStopped) {\n this.isStopped = true;\n const { observers } = this;\n while (observers.length) {\n observers.shift().complete();\n }\n }\n });\n }\n unsubscribe() {\n this.isStopped = this.closed = true;\n this.observers = this.currentObservers = null;\n }\n get observed() {\n var _a;\n return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;\n }\n _trySubscribe(subscriber) {\n this._throwIfClosed();\n return super._trySubscribe(subscriber);\n }\n _subscribe(subscriber) {\n this._throwIfClosed();\n this._checkFinalizedStatuses(subscriber);\n return this._innerSubscribe(subscriber);\n }\n _innerSubscribe(subscriber) {\n const { hasError, isStopped, observers } = this;\n if (hasError || isStopped) {\n return EMPTY_SUBSCRIPTION;\n }\n this.currentObservers = null;\n observers.push(subscriber);\n return new Subscription(() => {\n this.currentObservers = null;\n arrRemove(observers, subscriber);\n });\n }\n _checkFinalizedStatuses(subscriber) {\n const { hasError, thrownError, isStopped } = this;\n if (hasError) {\n subscriber.error(thrownError);\n }\n else if (isStopped) {\n subscriber.complete();\n }\n }\n asObservable() {\n const observable = new Observable();\n observable.source = this;\n return observable;\n }\n}\nSubject.create = (destination, source) => {\n return new AnonymousSubject(destination, source);\n};\nexport class AnonymousSubject extends Subject {\n constructor(destination, source) {\n super();\n this.destination = destination;\n this.source = source;\n }\n next(value) {\n var _a, _b;\n (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);\n }\n error(err) {\n var _a, _b;\n (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);\n }\n complete() {\n var _a, _b;\n (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);\n }\n _subscribe(subscriber) {\n var _a, _b;\n return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;\n }\n}\n","export const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined))();\nexport function errorNotification(error) {\n return createNotification('E', undefined, error);\n}\nexport function nextNotification(value) {\n return createNotification('N', value, undefined);\n}\nexport function createNotification(kind, value, error) {\n return {\n kind,\n value,\n error,\n };\n}\n","import { isFunction } from './util/isFunction';\nimport { isSubscription, Subscription } from './Subscription';\nimport { config } from './config';\nimport { reportUnhandledError } from './util/reportUnhandledError';\nimport { noop } from './util/noop';\nimport { nextNotification, errorNotification, COMPLETE_NOTIFICATION } from './NotificationFactories';\nimport { timeoutProvider } from './scheduler/timeoutProvider';\nimport { captureError } from './util/errorContext';\nexport class Subscriber extends Subscription {\n constructor(destination) {\n super();\n this.isStopped = false;\n if (destination) {\n this.destination = destination;\n if (isSubscription(destination)) {\n destination.add(this);\n }\n }\n else {\n this.destination = EMPTY_OBSERVER;\n }\n }\n static create(next, error, complete) {\n return new SafeSubscriber(next, error, complete);\n }\n next(value) {\n if (this.isStopped) {\n handleStoppedNotification(nextNotification(value), this);\n }\n else {\n this._next(value);\n }\n }\n error(err) {\n if (this.isStopped) {\n handleStoppedNotification(errorNotification(err), this);\n }\n else {\n this.isStopped = true;\n this._error(err);\n }\n }\n complete() {\n if (this.isStopped) {\n handleStoppedNotification(COMPLETE_NOTIFICATION, this);\n }\n else {\n this.isStopped = true;\n this._complete();\n }\n }\n unsubscribe() {\n if (!this.closed) {\n this.isStopped = true;\n super.unsubscribe();\n this.destination = null;\n }\n }\n _next(value) {\n this.destination.next(value);\n }\n _error(err) {\n try {\n this.destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n }\n _complete() {\n try {\n this.destination.complete();\n }\n finally {\n this.unsubscribe();\n }\n }\n}\nconst _bind = Function.prototype.bind;\nfunction bind(fn, thisArg) {\n return _bind.call(fn, thisArg);\n}\nclass ConsumerObserver {\n constructor(partialObserver) {\n this.partialObserver = partialObserver;\n }\n next(value) {\n const { partialObserver } = this;\n if (partialObserver.next) {\n try {\n partialObserver.next(value);\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n error(err) {\n const { partialObserver } = this;\n if (partialObserver.error) {\n try {\n partialObserver.error(err);\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n else {\n handleUnhandledError(err);\n }\n }\n complete() {\n const { partialObserver } = this;\n if (partialObserver.complete) {\n try {\n partialObserver.complete();\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n }\n}\nexport class SafeSubscriber extends Subscriber {\n constructor(observerOrNext, error, complete) {\n super();\n let partialObserver;\n if (isFunction(observerOrNext) || !observerOrNext) {\n partialObserver = {\n next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),\n error: error !== null && error !== void 0 ? error : undefined,\n complete: complete !== null && complete !== void 0 ? complete : undefined,\n };\n }\n else {\n let context;\n if (this && config.useDeprecatedNextContext) {\n context = Object.create(observerOrNext);\n context.unsubscribe = () => this.unsubscribe();\n partialObserver = {\n next: observerOrNext.next && bind(observerOrNext.next, context),\n error: observerOrNext.error && bind(observerOrNext.error, context),\n complete: observerOrNext.complete && bind(observerOrNext.complete, context),\n };\n }\n else {\n partialObserver = observerOrNext;\n }\n }\n this.destination = new ConsumerObserver(partialObserver);\n }\n}\nfunction handleUnhandledError(error) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n captureError(error);\n }\n else {\n reportUnhandledError(error);\n }\n}\nfunction defaultErrorHandler(err) {\n throw err;\n}\nfunction handleStoppedNotification(notification, subscriber) {\n const { onStoppedNotification } = config;\n onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));\n}\nexport const EMPTY_OBSERVER = {\n closed: true,\n next: noop,\n error: defaultErrorHandler,\n complete: noop,\n};\n","import { createErrorClass } from './createErrorClass';\nexport const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {\n _super(this);\n this.message = errors\n ? `${errors.length} errors occurred during unsubscription:\n${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\\n ')}`\n : '';\n this.name = 'UnsubscriptionError';\n this.errors = errors;\n});\n","import { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nimport { arrRemove } from './util/arrRemove';\nexport class Subscription {\n constructor(initialTeardown) {\n this.initialTeardown = initialTeardown;\n this.closed = false;\n this._parentage = null;\n this._finalizers = null;\n }\n unsubscribe() {\n let errors;\n if (!this.closed) {\n this.closed = true;\n const { _parentage } = this;\n if (_parentage) {\n this._parentage = null;\n if (Array.isArray(_parentage)) {\n for (const parent of _parentage) {\n parent.remove(this);\n }\n }\n else {\n _parentage.remove(this);\n }\n }\n const { initialTeardown: initialFinalizer } = this;\n if (isFunction(initialFinalizer)) {\n try {\n initialFinalizer();\n }\n catch (e) {\n errors = e instanceof UnsubscriptionError ? e.errors : [e];\n }\n }\n const { _finalizers } = this;\n if (_finalizers) {\n this._finalizers = null;\n for (const finalizer of _finalizers) {\n try {\n execFinalizer(finalizer);\n }\n catch (err) {\n errors = errors !== null && errors !== void 0 ? errors : [];\n if (err instanceof UnsubscriptionError) {\n errors = [...errors, ...err.errors];\n }\n else {\n errors.push(err);\n }\n }\n }\n }\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n }\n }\n add(teardown) {\n var _a;\n if (teardown && teardown !== this) {\n if (this.closed) {\n execFinalizer(teardown);\n }\n else {\n if (teardown instanceof Subscription) {\n if (teardown.closed || teardown._hasParent(this)) {\n return;\n }\n teardown._addParent(this);\n }\n (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);\n }\n }\n }\n _hasParent(parent) {\n const { _parentage } = this;\n return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));\n }\n _addParent(parent) {\n const { _parentage } = this;\n this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;\n }\n _removeParent(parent) {\n const { _parentage } = this;\n if (_parentage === parent) {\n this._parentage = null;\n }\n else if (Array.isArray(_parentage)) {\n arrRemove(_parentage, parent);\n }\n }\n remove(teardown) {\n const { _finalizers } = this;\n _finalizers && arrRemove(_finalizers, teardown);\n if (teardown instanceof Subscription) {\n teardown._removeParent(this);\n }\n }\n}\nSubscription.EMPTY = (() => {\n const empty = new Subscription();\n empty.closed = true;\n return empty;\n})();\nexport const EMPTY_SUBSCRIPTION = Subscription.EMPTY;\nexport function isSubscription(value) {\n return (value instanceof Subscription ||\n (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));\n}\nfunction execFinalizer(finalizer) {\n if (isFunction(finalizer)) {\n finalizer();\n }\n else {\n finalizer.unsubscribe();\n }\n}\n","export const config = {\n onUnhandledError: null,\n onStoppedNotification: null,\n Promise: undefined,\n useDeprecatedSynchronousErrorHandling: false,\n useDeprecatedNextContext: false,\n};\n","import { EmptyError } from './util/EmptyError';\nimport { SafeSubscriber } from './Subscriber';\nexport function firstValueFrom(source, config) {\n const hasConfig = typeof config === 'object';\n return new Promise((resolve, reject) => {\n const subscriber = new SafeSubscriber({\n next: (value) => {\n resolve(value);\n subscriber.unsubscribe();\n },\n error: reject,\n complete: () => {\n if (hasConfig) {\n resolve(config.defaultValue);\n }\n else {\n reject(new EmptyError());\n }\n },\n });\n source.subscribe(subscriber);\n });\n}\n","import { Observable } from '../Observable';\nimport { Subscription } from '../Subscription';\nimport { refCount as higherOrderRefCount } from '../operators/refCount';\nimport { createOperatorSubscriber } from '../operators/OperatorSubscriber';\nimport { hasLift } from '../util/lift';\nexport class ConnectableObservable extends Observable {\n constructor(source, subjectFactory) {\n super();\n this.source = source;\n this.subjectFactory = subjectFactory;\n this._subject = null;\n this._refCount = 0;\n this._connection = null;\n if (hasLift(source)) {\n this.lift = source.lift;\n }\n }\n _subscribe(subscriber) {\n return this.getSubject().subscribe(subscriber);\n }\n getSubject() {\n const subject = this._subject;\n if (!subject || subject.isStopped) {\n this._subject = this.subjectFactory();\n }\n return this._subject;\n }\n _teardown() {\n this._refCount = 0;\n const { _connection } = this;\n this._subject = this._connection = null;\n _connection === null || _connection === void 0 ? void 0 : _connection.unsubscribe();\n }\n connect() {\n let connection = this._connection;\n if (!connection) {\n connection = this._connection = new Subscription();\n const subject = this.getSubject();\n connection.add(this.source.subscribe(createOperatorSubscriber(subject, undefined, () => {\n this._teardown();\n subject.complete();\n }, (err) => {\n this._teardown();\n subject.error(err);\n }, () => this._teardown())));\n if (connection.closed) {\n this._connection = null;\n connection = Subscription.EMPTY;\n }\n }\n return connection;\n }\n refCount() {\n return higherOrderRefCount()(this);\n }\n}\n","import { Observable } from '../Observable';\nimport { argsArgArrayOrObject } from '../util/argsArgArrayOrObject';\nimport { from } from './from';\nimport { identity } from '../util/identity';\nimport { mapOneOrManyArgs } from '../util/mapOneOrManyArgs';\nimport { popResultSelector, popScheduler } from '../util/args';\nimport { createObject } from '../util/createObject';\nimport { createOperatorSubscriber } from '../operators/OperatorSubscriber';\nimport { executeSchedule } from '../util/executeSchedule';\nexport function combineLatest(...args) {\n const scheduler = popScheduler(args);\n const resultSelector = popResultSelector(args);\n const { args: observables, keys } = argsArgArrayOrObject(args);\n if (observables.length === 0) {\n return from([], scheduler);\n }\n const result = new Observable(combineLatestInit(observables, scheduler, keys\n ?\n (values) => createObject(keys, values)\n :\n identity));\n return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result;\n}\nexport function combineLatestInit(observables, scheduler, valueTransform = identity) {\n return (subscriber) => {\n maybeSchedule(scheduler, () => {\n const { length } = observables;\n const values = new Array(length);\n let active = length;\n let remainingFirstValues = length;\n for (let i = 0; i < length; i++) {\n maybeSchedule(scheduler, () => {\n const source = from(observables[i], scheduler);\n let hasFirstValue = false;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n values[i] = value;\n if (!hasFirstValue) {\n hasFirstValue = true;\n remainingFirstValues--;\n }\n if (!remainingFirstValues) {\n subscriber.next(valueTransform(values.slice()));\n }\n }, () => {\n if (!--active) {\n subscriber.complete();\n }\n }));\n }, subscriber);\n }\n }, subscriber);\n };\n}\nfunction maybeSchedule(scheduler, execute, subscription) {\n if (scheduler) {\n executeSchedule(subscription, scheduler, execute);\n }\n else {\n execute();\n }\n}\n","import { concatAll } from '../operators/concatAll';\nimport { popScheduler } from '../util/args';\nimport { from } from './from';\nexport function concat(...args) {\n return concatAll()(from(args, popScheduler(args)));\n}\n","import { mergeAll } from './mergeAll';\nexport function concatAll() {\n return mergeAll(1);\n}\n","import { Observable } from '../Observable';\nimport { innerFrom } from './innerFrom';\nexport function defer(observableFactory) {\n return new Observable((subscriber) => {\n innerFrom(observableFactory()).subscribe(subscriber);\n });\n}\n","import { Observable } from '../Observable';\nexport const EMPTY = new Observable((subscriber) => subscriber.complete());\nexport function empty(scheduler) {\n return scheduler ? emptyScheduled(scheduler) : EMPTY;\n}\nfunction emptyScheduled(scheduler) {\n return new Observable((subscriber) => scheduler.schedule(() => subscriber.complete()));\n}\n","import { Observable } from '../Observable';\nimport { argsArgArrayOrObject } from '../util/argsArgArrayOrObject';\nimport { innerFrom } from './innerFrom';\nimport { popResultSelector } from '../util/args';\nimport { createOperatorSubscriber } from '../operators/OperatorSubscriber';\nimport { mapOneOrManyArgs } from '../util/mapOneOrManyArgs';\nimport { createObject } from '../util/createObject';\nexport function forkJoin(...args) {\n const resultSelector = popResultSelector(args);\n const { args: sources, keys } = argsArgArrayOrObject(args);\n const result = new Observable((subscriber) => {\n const { length } = sources;\n if (!length) {\n subscriber.complete();\n return;\n }\n const values = new Array(length);\n let remainingCompletions = length;\n let remainingEmissions = length;\n for (let sourceIndex = 0; sourceIndex < length; sourceIndex++) {\n let hasValue = false;\n innerFrom(sources[sourceIndex]).subscribe(createOperatorSubscriber(subscriber, (value) => {\n if (!hasValue) {\n hasValue = true;\n remainingEmissions--;\n }\n values[sourceIndex] = value;\n }, () => remainingCompletions--, undefined, () => {\n if (!remainingCompletions || !hasValue) {\n if (!remainingEmissions) {\n subscriber.next(keys ? createObject(keys, values) : values);\n }\n subscriber.complete();\n }\n }));\n }\n });\n return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result;\n}\n","import { executeSchedule } from '../util/executeSchedule';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function observeOn(scheduler, delay = 0) {\n return operate((source, subscriber) => {\n source.subscribe(createOperatorSubscriber(subscriber, (value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay), () => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay), (err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)));\n });\n}\n","import { operate } from '../util/lift';\nexport function subscribeOn(scheduler, delay = 0) {\n return operate((source, subscriber) => {\n subscriber.add(scheduler.schedule(() => source.subscribe(subscriber), delay));\n });\n}\n","import { Observable } from '../Observable';\nimport { executeSchedule } from '../util/executeSchedule';\nexport function scheduleAsyncIterable(input, scheduler) {\n if (!input) {\n throw new Error('Iterable cannot be null');\n }\n return new Observable((subscriber) => {\n executeSchedule(subscriber, scheduler, () => {\n const iterator = input[Symbol.asyncIterator]();\n executeSchedule(subscriber, scheduler, () => {\n iterator.next().then((result) => {\n if (result.done) {\n subscriber.complete();\n }\n else {\n subscriber.next(result.value);\n }\n });\n }, 0, true);\n });\n });\n}\n","import { scheduled } from '../scheduled/scheduled';\nimport { innerFrom } from './innerFrom';\nexport function from(input, scheduler) {\n return scheduler ? scheduled(input, scheduler) : innerFrom(input);\n}\n","import { scheduleObservable } from './scheduleObservable';\nimport { schedulePromise } from './schedulePromise';\nimport { scheduleArray } from './scheduleArray';\nimport { scheduleIterable } from './scheduleIterable';\nimport { scheduleAsyncIterable } from './scheduleAsyncIterable';\nimport { isInteropObservable } from '../util/isInteropObservable';\nimport { isPromise } from '../util/isPromise';\nimport { isArrayLike } from '../util/isArrayLike';\nimport { isIterable } from '../util/isIterable';\nimport { isAsyncIterable } from '../util/isAsyncIterable';\nimport { createInvalidObservableTypeError } from '../util/throwUnobservableError';\nimport { isReadableStreamLike } from '../util/isReadableStreamLike';\nimport { scheduleReadableStreamLike } from './scheduleReadableStreamLike';\nexport function scheduled(input, scheduler) {\n if (input != null) {\n if (isInteropObservable(input)) {\n return scheduleObservable(input, scheduler);\n }\n if (isArrayLike(input)) {\n return scheduleArray(input, scheduler);\n }\n if (isPromise(input)) {\n return schedulePromise(input, scheduler);\n }\n if (isAsyncIterable(input)) {\n return scheduleAsyncIterable(input, scheduler);\n }\n if (isIterable(input)) {\n return scheduleIterable(input, scheduler);\n }\n if (isReadableStreamLike(input)) {\n return scheduleReadableStreamLike(input, scheduler);\n }\n }\n throw createInvalidObservableTypeError(input);\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { observeOn } from '../operators/observeOn';\nimport { subscribeOn } from '../operators/subscribeOn';\nexport function scheduleObservable(input, scheduler) {\n return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));\n}\n","import { Observable } from '../Observable';\nexport function scheduleArray(input, scheduler) {\n return new Observable((subscriber) => {\n let i = 0;\n return scheduler.schedule(function () {\n if (i === input.length) {\n subscriber.complete();\n }\n else {\n subscriber.next(input[i++]);\n if (!subscriber.closed) {\n this.schedule();\n }\n }\n });\n });\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { observeOn } from '../operators/observeOn';\nimport { subscribeOn } from '../operators/subscribeOn';\nexport function schedulePromise(input, scheduler) {\n return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));\n}\n","import { Observable } from '../Observable';\nimport { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { isFunction } from '../util/isFunction';\nimport { executeSchedule } from '../util/executeSchedule';\nexport function scheduleIterable(input, scheduler) {\n return new Observable((subscriber) => {\n let iterator;\n executeSchedule(subscriber, scheduler, () => {\n iterator = input[Symbol_iterator]();\n executeSchedule(subscriber, scheduler, () => {\n let value;\n let done;\n try {\n ({ value, done } = iterator.next());\n }\n catch (err) {\n subscriber.error(err);\n return;\n }\n if (done) {\n subscriber.complete();\n }\n else {\n subscriber.next(value);\n }\n }, 0, true);\n });\n return () => isFunction(iterator === null || iterator === void 0 ? void 0 : iterator.return) && iterator.return();\n });\n}\n","import { scheduleAsyncIterable } from './scheduleAsyncIterable';\nimport { readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';\nexport function scheduleReadableStreamLike(input, scheduler) {\n return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { Observable } from '../Observable';\nimport { mergeMap } from '../operators/mergeMap';\nimport { isArrayLike } from '../util/isArrayLike';\nimport { isFunction } from '../util/isFunction';\nimport { mapOneOrManyArgs } from '../util/mapOneOrManyArgs';\nconst nodeEventEmitterMethods = ['addListener', 'removeListener'];\nconst eventTargetMethods = ['addEventListener', 'removeEventListener'];\nconst jqueryMethods = ['on', 'off'];\nexport function fromEvent(target, eventName, options, resultSelector) {\n if (isFunction(options)) {\n resultSelector = options;\n options = undefined;\n }\n if (resultSelector) {\n return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector));\n }\n const [add, remove] = isEventTarget(target)\n ? eventTargetMethods.map((methodName) => (handler) => target[methodName](eventName, handler, options))\n :\n isNodeStyleEventEmitter(target)\n ? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName))\n : isJQueryStyleEventEmitter(target)\n ? jqueryMethods.map(toCommonHandlerRegistry(target, eventName))\n : [];\n if (!add) {\n if (isArrayLike(target)) {\n return mergeMap((subTarget) => fromEvent(subTarget, eventName, options))(innerFrom(target));\n }\n }\n if (!add) {\n throw new TypeError('Invalid event target');\n }\n return new Observable((subscriber) => {\n const handler = (...args) => subscriber.next(1 < args.length ? args : args[0]);\n add(handler);\n return () => remove(handler);\n });\n}\nfunction toCommonHandlerRegistry(target, eventName) {\n return (methodName) => (handler) => target[methodName](eventName, handler);\n}\nfunction isNodeStyleEventEmitter(target) {\n return isFunction(target.addListener) && isFunction(target.removeListener);\n}\nfunction isJQueryStyleEventEmitter(target) {\n return isFunction(target.on) && isFunction(target.off);\n}\nfunction isEventTarget(target) {\n return isFunction(target.addEventListener) && isFunction(target.removeEventListener);\n}\n","import { __asyncValues, __awaiter } from \"tslib\";\nimport { isArrayLike } from '../util/isArrayLike';\nimport { isPromise } from '../util/isPromise';\nimport { Observable } from '../Observable';\nimport { isInteropObservable } from '../util/isInteropObservable';\nimport { isAsyncIterable } from '../util/isAsyncIterable';\nimport { createInvalidObservableTypeError } from '../util/throwUnobservableError';\nimport { isIterable } from '../util/isIterable';\nimport { isReadableStreamLike, readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';\nimport { isFunction } from '../util/isFunction';\nimport { reportUnhandledError } from '../util/reportUnhandledError';\nimport { observable as Symbol_observable } from '../symbol/observable';\nexport function innerFrom(input) {\n if (input instanceof Observable) {\n return input;\n }\n if (input != null) {\n if (isInteropObservable(input)) {\n return fromInteropObservable(input);\n }\n if (isArrayLike(input)) {\n return fromArrayLike(input);\n }\n if (isPromise(input)) {\n return fromPromise(input);\n }\n if (isAsyncIterable(input)) {\n return fromAsyncIterable(input);\n }\n if (isIterable(input)) {\n return fromIterable(input);\n }\n if (isReadableStreamLike(input)) {\n return fromReadableStreamLike(input);\n }\n }\n throw createInvalidObservableTypeError(input);\n}\nexport function fromInteropObservable(obj) {\n return new Observable((subscriber) => {\n const obs = obj[Symbol_observable]();\n if (isFunction(obs.subscribe)) {\n return obs.subscribe(subscriber);\n }\n throw new TypeError('Provided object does not correctly implement Symbol.observable');\n });\n}\nexport function fromArrayLike(array) {\n return new Observable((subscriber) => {\n for (let i = 0; i < array.length && !subscriber.closed; i++) {\n subscriber.next(array[i]);\n }\n subscriber.complete();\n });\n}\nexport function fromPromise(promise) {\n return new Observable((subscriber) => {\n promise\n .then((value) => {\n if (!subscriber.closed) {\n subscriber.next(value);\n subscriber.complete();\n }\n }, (err) => subscriber.error(err))\n .then(null, reportUnhandledError);\n });\n}\nexport function fromIterable(iterable) {\n return new Observable((subscriber) => {\n for (const value of iterable) {\n subscriber.next(value);\n if (subscriber.closed) {\n return;\n }\n }\n subscriber.complete();\n });\n}\nexport function fromAsyncIterable(asyncIterable) {\n return new Observable((subscriber) => {\n process(asyncIterable, subscriber).catch((err) => subscriber.error(err));\n });\n}\nexport function fromReadableStreamLike(readableStream) {\n return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));\n}\nfunction process(asyncIterable, subscriber) {\n var asyncIterable_1, asyncIterable_1_1;\n var e_1, _a;\n return __awaiter(this, void 0, void 0, function* () {\n try {\n for (asyncIterable_1 = __asyncValues(asyncIterable); asyncIterable_1_1 = yield asyncIterable_1.next(), !asyncIterable_1_1.done;) {\n const value = asyncIterable_1_1.value;\n subscriber.next(value);\n if (subscriber.closed) {\n return;\n }\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)) yield _a.call(asyncIterable_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n subscriber.complete();\n });\n}\n","import { mergeAll } from '../operators/mergeAll';\nimport { innerFrom } from './innerFrom';\nimport { EMPTY } from './empty';\nimport { popNumber, popScheduler } from '../util/args';\nimport { from } from './from';\nexport function merge(...args) {\n const scheduler = popScheduler(args);\n const concurrent = popNumber(args, Infinity);\n const sources = args;\n return !sources.length\n ?\n EMPTY\n : sources.length === 1\n ?\n innerFrom(sources[0])\n :\n mergeAll(concurrent)(from(sources, scheduler));\n}\n","import { popScheduler } from '../util/args';\nimport { from } from './from';\nexport function of(...args) {\n const scheduler = popScheduler(args);\n return from(args, scheduler);\n}\n","import { Observable } from '../Observable';\nimport { isFunction } from '../util/isFunction';\nexport function throwError(errorOrErrorFactory, scheduler) {\n const errorFactory = isFunction(errorOrErrorFactory) ? errorOrErrorFactory : () => errorOrErrorFactory;\n const init = (subscriber) => subscriber.error(errorFactory());\n return new Observable(scheduler ? (subscriber) => scheduler.schedule(init, 0, subscriber) : init);\n}\n","import { Observable } from '../Observable';\nimport { async as asyncScheduler } from '../scheduler/async';\nimport { isScheduler } from '../util/isScheduler';\nimport { isValidDate } from '../util/isDate';\nexport function timer(dueTime = 0, intervalOrScheduler, scheduler = asyncScheduler) {\n let intervalDuration = -1;\n if (intervalOrScheduler != null) {\n if (isScheduler(intervalOrScheduler)) {\n scheduler = intervalOrScheduler;\n }\n else {\n intervalDuration = intervalOrScheduler;\n }\n }\n return new Observable((subscriber) => {\n let due = isValidDate(dueTime) ? +dueTime - scheduler.now() : dueTime;\n if (due < 0) {\n due = 0;\n }\n let n = 0;\n return scheduler.schedule(function () {\n if (!subscriber.closed) {\n subscriber.next(n++);\n if (0 <= intervalDuration) {\n this.schedule(undefined, intervalDuration);\n }\n else {\n subscriber.complete();\n }\n }\n }, due);\n });\n}\n","export function isValidDate(value) {\n return value instanceof Date && !isNaN(value);\n}\n","const { isArray } = Array;\nexport function argsOrArgArray(args) {\n return args.length === 1 && isArray(args[0]) ? args[0] : args;\n}\n","import { Observable } from '../Observable';\nimport { innerFrom } from './innerFrom';\nimport { argsOrArgArray } from '../util/argsOrArgArray';\nimport { EMPTY } from './empty';\nimport { createOperatorSubscriber } from '../operators/OperatorSubscriber';\nimport { popResultSelector } from '../util/args';\nexport function zip(...args) {\n const resultSelector = popResultSelector(args);\n const sources = argsOrArgArray(args);\n return sources.length\n ? new Observable((subscriber) => {\n let buffers = sources.map(() => []);\n let completed = sources.map(() => false);\n subscriber.add(() => {\n buffers = completed = null;\n });\n for (let sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) {\n innerFrom(sources[sourceIndex]).subscribe(createOperatorSubscriber(subscriber, (value) => {\n buffers[sourceIndex].push(value);\n if (buffers.every((buffer) => buffer.length)) {\n const result = buffers.map((buffer) => buffer.shift());\n subscriber.next(resultSelector ? resultSelector(...result) : result);\n if (buffers.some((buffer, i) => !buffer.length && completed[i])) {\n subscriber.complete();\n }\n }\n }, () => {\n completed[sourceIndex] = true;\n !buffers[sourceIndex].length && subscriber.complete();\n }));\n }\n return () => {\n buffers = completed = null;\n };\n })\n : EMPTY;\n}\n","import { Subscriber } from '../Subscriber';\nexport function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {\n return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);\n}\nexport class OperatorSubscriber extends Subscriber {\n constructor(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {\n super(destination);\n this.onFinalize = onFinalize;\n this.shouldUnsubscribe = shouldUnsubscribe;\n this._next = onNext\n ? function (value) {\n try {\n onNext(value);\n }\n catch (err) {\n destination.error(err);\n }\n }\n : super._next;\n this._error = onError\n ? function (err) {\n try {\n onError(err);\n }\n catch (err) {\n destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n }\n : super._error;\n this._complete = onComplete\n ? function () {\n try {\n onComplete();\n }\n catch (err) {\n destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n }\n : super._complete;\n }\n unsubscribe() {\n var _a;\n if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {\n const { closed } = this;\n super.unsubscribe();\n !closed && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));\n }\n }\n}\n","import { asyncScheduler } from '../scheduler/async';\nimport { audit } from './audit';\nimport { timer } from '../observable/timer';\nexport function auditTime(duration, scheduler = asyncScheduler) {\n return audit(() => timer(duration, scheduler));\n}\n","import { operate } from '../util/lift';\nimport { innerFrom } from '../observable/innerFrom';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function audit(durationSelector) {\n return operate((source, subscriber) => {\n let hasValue = false;\n let lastValue = null;\n let durationSubscriber = null;\n let isComplete = false;\n const endDuration = () => {\n durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();\n durationSubscriber = null;\n if (hasValue) {\n hasValue = false;\n const value = lastValue;\n lastValue = null;\n subscriber.next(value);\n }\n isComplete && subscriber.complete();\n };\n const cleanupDuration = () => {\n durationSubscriber = null;\n isComplete && subscriber.complete();\n };\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n hasValue = true;\n lastValue = value;\n if (!durationSubscriber) {\n innerFrom(durationSelector(value)).subscribe((durationSubscriber = createOperatorSubscriber(subscriber, endDuration, cleanupDuration)));\n }\n }, () => {\n isComplete = true;\n (!hasValue || !durationSubscriber || durationSubscriber.closed) && subscriber.complete();\n }));\n });\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nimport { operate } from '../util/lift';\nexport function catchError(selector) {\n return operate((source, subscriber) => {\n let innerSub = null;\n let syncUnsub = false;\n let handledResult;\n innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, (err) => {\n handledResult = innerFrom(selector(err, catchError(selector)(source)));\n if (innerSub) {\n innerSub.unsubscribe();\n innerSub = null;\n handledResult.subscribe(subscriber);\n }\n else {\n syncUnsub = true;\n }\n }));\n if (syncUnsub) {\n innerSub.unsubscribe();\n innerSub = null;\n handledResult.subscribe(subscriber);\n }\n });\n}\n","import { mergeMap } from './mergeMap';\nimport { isFunction } from '../util/isFunction';\nexport function concatMap(project, resultSelector) {\n return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);\n}\n","import { asyncScheduler } from '../scheduler/async';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function debounceTime(dueTime, scheduler = asyncScheduler) {\n return operate((source, subscriber) => {\n let activeTask = null;\n let lastValue = null;\n let lastTime = null;\n const emit = () => {\n if (activeTask) {\n activeTask.unsubscribe();\n activeTask = null;\n const value = lastValue;\n lastValue = null;\n subscriber.next(value);\n }\n };\n function emitWhenIdle() {\n const targetTime = lastTime + dueTime;\n const now = scheduler.now();\n if (now < targetTime) {\n activeTask = this.schedule(undefined, targetTime - now);\n subscriber.add(activeTask);\n return;\n }\n emit();\n }\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n lastValue = value;\n lastTime = scheduler.now();\n if (!activeTask) {\n activeTask = scheduler.schedule(emitWhenIdle, dueTime);\n subscriber.add(activeTask);\n }\n }, () => {\n emit();\n subscriber.complete();\n }, undefined, () => {\n lastValue = activeTask = null;\n }));\n });\n}\n","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function defaultIfEmpty(defaultValue) {\n return operate((source, subscriber) => {\n let hasValue = false;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n hasValue = true;\n subscriber.next(value);\n }, () => {\n if (!hasValue) {\n subscriber.next(defaultValue);\n }\n subscriber.complete();\n }));\n });\n}\n","import { concat } from '../observable/concat';\nimport { take } from './take';\nimport { ignoreElements } from './ignoreElements';\nimport { mapTo } from './mapTo';\nimport { mergeMap } from './mergeMap';\nimport { innerFrom } from '../observable/innerFrom';\nexport function delayWhen(delayDurationSelector, subscriptionDelay) {\n if (subscriptionDelay) {\n return (source) => concat(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));\n }\n return mergeMap((value, index) => innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)));\n}\n","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nimport { noop } from '../util/noop';\nexport function ignoreElements() {\n return operate((source, subscriber) => {\n source.subscribe(createOperatorSubscriber(subscriber, noop));\n });\n}\n","import { asyncScheduler } from '../scheduler/async';\nimport { delayWhen } from './delayWhen';\nimport { timer } from '../observable/timer';\nexport function delay(due, scheduler = asyncScheduler) {\n const duration = timer(due, scheduler);\n return delayWhen(() => duration);\n}\n","import { identity } from '../util/identity';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function distinctUntilChanged(comparator, keySelector = identity) {\n comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;\n return operate((source, subscriber) => {\n let previousKey;\n let first = true;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n const currentKey = keySelector(value);\n if (first || !comparator(previousKey, currentKey)) {\n first = false;\n previousKey = currentKey;\n subscriber.next(value);\n }\n }));\n });\n}\nfunction defaultCompare(a, b) {\n return a === b;\n}\n","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function filter(predicate, thisArg) {\n return operate((source, subscriber) => {\n let index = 0;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => predicate.call(thisArg, value, index++) && subscriber.next(value)));\n });\n}\n","import { operate } from '../util/lift';\nexport function finalize(callback) {\n return operate((source, subscriber) => {\n try {\n source.subscribe(subscriber);\n }\n finally {\n subscriber.add(callback);\n }\n });\n}\n","import { EmptyError } from '../util/EmptyError';\nimport { filter } from './filter';\nimport { take } from './take';\nimport { defaultIfEmpty } from './defaultIfEmpty';\nimport { throwIfEmpty } from './throwIfEmpty';\nimport { identity } from '../util/identity';\nexport function first(predicate, defaultValue) {\n const hasDefaultValue = arguments.length >= 2;\n return (source) => source.pipe(predicate ? filter((v, i) => predicate(v, i, source)) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(() => new EmptyError()));\n}\n","import { mergeMap } from './mergeMap';\nexport const flatMap = mergeMap;\n","import { EmptyError } from '../util/EmptyError';\nimport { filter } from './filter';\nimport { takeLast } from './takeLast';\nimport { throwIfEmpty } from './throwIfEmpty';\nimport { defaultIfEmpty } from './defaultIfEmpty';\nimport { identity } from '../util/identity';\nexport function last(predicate, defaultValue) {\n const hasDefaultValue = arguments.length >= 2;\n return (source) => source.pipe(predicate ? filter((v, i) => predicate(v, i, source)) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(() => new EmptyError()));\n}\n","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function map(project, thisArg) {\n return operate((source, subscriber) => {\n let index = 0;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n subscriber.next(project.call(thisArg, value, index++));\n }));\n });\n}\n","import { map } from './map';\nexport function mapTo(value) {\n return map(() => value);\n}\n","import { mergeMap } from './mergeMap';\nimport { identity } from '../util/identity';\nexport function mergeAll(concurrent = Infinity) {\n return mergeMap(identity, concurrent);\n}\n","import { map } from './map';\nimport { innerFrom } from '../observable/innerFrom';\nimport { operate } from '../util/lift';\nimport { mergeInternals } from './mergeInternals';\nimport { isFunction } from '../util/isFunction';\nexport function mergeMap(project, resultSelector, concurrent = Infinity) {\n if (isFunction(resultSelector)) {\n return mergeMap((a, i) => map((b, ii) => resultSelector(a, b, i, ii))(innerFrom(project(a, i))), concurrent);\n }\n else if (typeof resultSelector === 'number') {\n concurrent = resultSelector;\n }\n return operate((source, subscriber) => mergeInternals(source, subscriber, project, concurrent));\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { executeSchedule } from '../util/executeSchedule';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {\n const buffer = [];\n let active = 0;\n let index = 0;\n let isComplete = false;\n const checkComplete = () => {\n if (isComplete && !buffer.length && !active) {\n subscriber.complete();\n }\n };\n const outerNext = (value) => (active < concurrent ? doInnerSub(value) : buffer.push(value));\n const doInnerSub = (value) => {\n expand && subscriber.next(value);\n active++;\n let innerComplete = false;\n innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, (innerValue) => {\n onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);\n if (expand) {\n outerNext(innerValue);\n }\n else {\n subscriber.next(innerValue);\n }\n }, () => {\n innerComplete = true;\n }, undefined, () => {\n if (innerComplete) {\n try {\n active--;\n while (buffer.length && active < concurrent) {\n const bufferedValue = buffer.shift();\n if (innerSubScheduler) {\n executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));\n }\n else {\n doInnerSub(bufferedValue);\n }\n }\n checkComplete();\n }\n catch (err) {\n subscriber.error(err);\n }\n }\n }));\n };\n source.subscribe(createOperatorSubscriber(subscriber, outerNext, () => {\n isComplete = true;\n checkComplete();\n }));\n return () => {\n additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();\n };\n}\n","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function refCount() {\n return operate((source, subscriber) => {\n let connection = null;\n source._refCount++;\n const refCounter = createOperatorSubscriber(subscriber, undefined, undefined, undefined, () => {\n if (!source || source._refCount <= 0 || 0 < --source._refCount) {\n connection = null;\n return;\n }\n const sharedConnection = source._connection;\n const conn = connection;\n connection = null;\n if (sharedConnection && (!conn || sharedConnection === conn)) {\n sharedConnection.unsubscribe();\n }\n subscriber.unsubscribe();\n });\n source.subscribe(refCounter);\n if (!refCounter.closed) {\n connection = source.connect();\n }\n });\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { Subject } from '../Subject';\nimport { SafeSubscriber } from '../Subscriber';\nimport { operate } from '../util/lift';\nexport function share(options = {}) {\n const { connector = () => new Subject(), resetOnError = true, resetOnComplete = true, resetOnRefCountZero = true } = options;\n return (wrapperSource) => {\n let connection;\n let resetConnection;\n let subject;\n let refCount = 0;\n let hasCompleted = false;\n let hasErrored = false;\n const cancelReset = () => {\n resetConnection === null || resetConnection === void 0 ? void 0 : resetConnection.unsubscribe();\n resetConnection = undefined;\n };\n const reset = () => {\n cancelReset();\n connection = subject = undefined;\n hasCompleted = hasErrored = false;\n };\n const resetAndUnsubscribe = () => {\n const conn = connection;\n reset();\n conn === null || conn === void 0 ? void 0 : conn.unsubscribe();\n };\n return operate((source, subscriber) => {\n refCount++;\n if (!hasErrored && !hasCompleted) {\n cancelReset();\n }\n const dest = (subject = subject !== null && subject !== void 0 ? subject : connector());\n subscriber.add(() => {\n refCount--;\n if (refCount === 0 && !hasErrored && !hasCompleted) {\n resetConnection = handleReset(resetAndUnsubscribe, resetOnRefCountZero);\n }\n });\n dest.subscribe(subscriber);\n if (!connection &&\n refCount > 0) {\n connection = new SafeSubscriber({\n next: (value) => dest.next(value),\n error: (err) => {\n hasErrored = true;\n cancelReset();\n resetConnection = handleReset(reset, resetOnError, err);\n dest.error(err);\n },\n complete: () => {\n hasCompleted = true;\n cancelReset();\n resetConnection = handleReset(reset, resetOnComplete);\n dest.complete();\n },\n });\n innerFrom(source).subscribe(connection);\n }\n })(wrapperSource);\n };\n}\nfunction handleReset(reset, on, ...args) {\n if (on === true) {\n reset();\n return;\n }\n if (on === false) {\n return;\n }\n const onSubscriber = new SafeSubscriber({\n next: () => {\n onSubscriber.unsubscribe();\n reset();\n },\n });\n return innerFrom(on(...args)).subscribe(onSubscriber);\n}\n","import { filter } from './filter';\nexport function skip(count) {\n return filter((_, index) => count <= index);\n}\n","import { concat } from '../observable/concat';\nimport { popScheduler } from '../util/args';\nimport { operate } from '../util/lift';\nexport function startWith(...values) {\n const scheduler = popScheduler(values);\n return operate((source, subscriber) => {\n (scheduler ? concat(values, source, scheduler) : concat(values, source)).subscribe(subscriber);\n });\n}\n","import { innerFrom } from '../observable/innerFrom';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function switchMap(project, resultSelector) {\n return operate((source, subscriber) => {\n let innerSubscriber = null;\n let index = 0;\n let isComplete = false;\n const checkComplete = () => isComplete && !innerSubscriber && subscriber.complete();\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();\n let innerIndex = 0;\n const outerIndex = index++;\n innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, (innerValue) => subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue), () => {\n innerSubscriber = null;\n checkComplete();\n })));\n }, () => {\n isComplete = true;\n checkComplete();\n }));\n });\n}\n","import { EMPTY } from '../observable/empty';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function take(count) {\n return count <= 0\n ?\n () => EMPTY\n : operate((source, subscriber) => {\n let seen = 0;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n if (++seen <= count) {\n subscriber.next(value);\n if (count <= seen) {\n subscriber.complete();\n }\n }\n }));\n });\n}\n","import { EMPTY } from '../observable/empty';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function takeLast(count) {\n return count <= 0\n ? () => EMPTY\n : operate((source, subscriber) => {\n let buffer = [];\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n buffer.push(value);\n count < buffer.length && buffer.shift();\n }, () => {\n for (const value of buffer) {\n subscriber.next(value);\n }\n subscriber.complete();\n }, undefined, () => {\n buffer = null;\n }));\n });\n}\n","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nimport { innerFrom } from '../observable/innerFrom';\nimport { noop } from '../util/noop';\nexport function takeUntil(notifier) {\n return operate((source, subscriber) => {\n innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));\n !subscriber.closed && source.subscribe(subscriber);\n });\n}\n","import { isFunction } from '../util/isFunction';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nimport { identity } from '../util/identity';\nexport function tap(observerOrNext, error, complete) {\n const tapObserver = isFunction(observerOrNext) || error || complete\n ?\n { next: observerOrNext, error, complete }\n : observerOrNext;\n return tapObserver\n ? operate((source, subscriber) => {\n var _a;\n (_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);\n let isUnsub = true;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n var _a;\n (_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);\n subscriber.next(value);\n }, () => {\n var _a;\n isUnsub = false;\n (_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);\n subscriber.complete();\n }, (err) => {\n var _a;\n isUnsub = false;\n (_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);\n subscriber.error(err);\n }, () => {\n var _a, _b;\n if (isUnsub) {\n (_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);\n }\n (_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);\n }));\n })\n :\n identity;\n}\n","import { EmptyError } from '../util/EmptyError';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function throwIfEmpty(errorFactory = defaultErrorFactory) {\n return operate((source, subscriber) => {\n let hasValue = false;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n hasValue = true;\n subscriber.next(value);\n }, () => (hasValue ? subscriber.complete() : subscriber.error(errorFactory()))));\n });\n}\nfunction defaultErrorFactory() {\n return new EmptyError();\n}\n","import { Subscription } from '../Subscription';\nexport class Action extends Subscription {\n constructor(scheduler, work) {\n super();\n }\n schedule(state, delay = 0) {\n return this;\n }\n}\n","export const intervalProvider = {\n setInterval(handler, timeout, ...args) {\n const { delegate } = intervalProvider;\n if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {\n return delegate.setInterval(handler, timeout, ...args);\n }\n return setInterval(handler, timeout, ...args);\n },\n clearInterval(handle) {\n const { delegate } = intervalProvider;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);\n },\n delegate: undefined,\n};\n","import { Action } from './Action';\nimport { intervalProvider } from './intervalProvider';\nimport { arrRemove } from '../util/arrRemove';\nexport class AsyncAction extends Action {\n constructor(scheduler, work) {\n super(scheduler, work);\n this.scheduler = scheduler;\n this.work = work;\n this.pending = false;\n }\n schedule(state, delay = 0) {\n var _a;\n if (this.closed) {\n return this;\n }\n this.state = state;\n const id = this.id;\n const scheduler = this.scheduler;\n if (id != null) {\n this.id = this.recycleAsyncId(scheduler, id, delay);\n }\n this.pending = true;\n this.delay = delay;\n this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);\n return this;\n }\n requestAsyncId(scheduler, _id, delay = 0) {\n return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);\n }\n recycleAsyncId(_scheduler, id, delay = 0) {\n if (delay != null && this.delay === delay && this.pending === false) {\n return id;\n }\n if (id != null) {\n intervalProvider.clearInterval(id);\n }\n return undefined;\n }\n execute(state, delay) {\n if (this.closed) {\n return new Error('executing a cancelled action');\n }\n this.pending = false;\n const error = this._execute(state, delay);\n if (error) {\n return error;\n }\n else if (this.pending === false && this.id != null) {\n this.id = this.recycleAsyncId(this.scheduler, this.id, null);\n }\n }\n _execute(state, _delay) {\n let errored = false;\n let errorValue;\n try {\n this.work(state);\n }\n catch (e) {\n errored = true;\n errorValue = e ? e : new Error('Scheduled action threw falsy error');\n }\n if (errored) {\n this.unsubscribe();\n return errorValue;\n }\n }\n unsubscribe() {\n if (!this.closed) {\n const { id, scheduler } = this;\n const { actions } = scheduler;\n this.work = this.state = this.scheduler = null;\n this.pending = false;\n arrRemove(actions, this);\n if (id != null) {\n this.id = this.recycleAsyncId(scheduler, id, null);\n }\n this.delay = null;\n super.unsubscribe();\n }\n }\n}\n","import { dateTimestampProvider } from './scheduler/dateTimestampProvider';\nexport class Scheduler {\n constructor(schedulerActionCtor, now = Scheduler.now) {\n this.schedulerActionCtor = schedulerActionCtor;\n this.now = now;\n }\n schedule(work, delay = 0, state) {\n return new this.schedulerActionCtor(this, work).schedule(state, delay);\n }\n}\nScheduler.now = dateTimestampProvider.now;\n","import { Scheduler } from '../Scheduler';\nexport class AsyncScheduler extends Scheduler {\n constructor(SchedulerAction, now = Scheduler.now) {\n super(SchedulerAction, now);\n this.actions = [];\n this._active = false;\n }\n flush(action) {\n const { actions } = this;\n if (this._active) {\n actions.push(action);\n return;\n }\n let error;\n this._active = true;\n do {\n if ((error = action.execute(action.state, action.delay))) {\n break;\n }\n } while ((action = actions.shift()));\n this._active = false;\n if (error) {\n while ((action = actions.shift())) {\n action.unsubscribe();\n }\n throw error;\n }\n }\n}\n","import { Subscription } from '../Subscription';\nexport const animationFrameProvider = {\n schedule(callback) {\n let request = requestAnimationFrame;\n let cancel = cancelAnimationFrame;\n const { delegate } = animationFrameProvider;\n if (delegate) {\n request = delegate.requestAnimationFrame;\n cancel = delegate.cancelAnimationFrame;\n }\n const handle = request((timestamp) => {\n cancel = undefined;\n callback(timestamp);\n });\n return new Subscription(() => cancel === null || cancel === void 0 ? void 0 : cancel(handle));\n },\n requestAnimationFrame(...args) {\n const { delegate } = animationFrameProvider;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.requestAnimationFrame) || requestAnimationFrame)(...args);\n },\n cancelAnimationFrame(...args) {\n const { delegate } = animationFrameProvider;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.cancelAnimationFrame) || cancelAnimationFrame)(...args);\n },\n delegate: undefined,\n};\n","import { AnimationFrameAction } from './AnimationFrameAction';\nimport { AnimationFrameScheduler } from './AnimationFrameScheduler';\nexport const animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);\nexport const animationFrame = animationFrameScheduler;\n","import { AsyncScheduler } from './AsyncScheduler';\nexport class AnimationFrameScheduler extends AsyncScheduler {\n flush(action) {\n this._active = true;\n const flushId = this._scheduled;\n this._scheduled = undefined;\n const { actions } = this;\n let error;\n action = action || actions.shift();\n do {\n if ((error = action.execute(action.state, action.delay))) {\n break;\n }\n } while ((action = actions[0]) && action.id === flushId && actions.shift());\n this._active = false;\n if (error) {\n while ((action = actions[0]) && action.id === flushId && actions.shift()) {\n action.unsubscribe();\n }\n throw error;\n }\n }\n}\n","import { AsyncAction } from './AsyncAction';\nimport { animationFrameProvider } from './animationFrameProvider';\nexport class AnimationFrameAction extends AsyncAction {\n constructor(scheduler, work) {\n super(scheduler, work);\n this.scheduler = scheduler;\n this.work = work;\n }\n requestAsyncId(scheduler, id, delay = 0) {\n if (delay !== null && delay > 0) {\n return super.requestAsyncId(scheduler, id, delay);\n }\n scheduler.actions.push(this);\n return scheduler._scheduled || (scheduler._scheduled = animationFrameProvider.requestAnimationFrame(() => scheduler.flush(undefined)));\n }\n recycleAsyncId(scheduler, id, delay = 0) {\n var _a;\n if (delay != null ? delay > 0 : this.delay > 0) {\n return super.recycleAsyncId(scheduler, id, delay);\n }\n const { actions } = scheduler;\n if (id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) {\n animationFrameProvider.cancelAnimationFrame(id);\n scheduler._scheduled = undefined;\n }\n return undefined;\n }\n}\n","import { AsyncAction } from './AsyncAction';\nimport { AsyncScheduler } from './AsyncScheduler';\nexport const asyncScheduler = new AsyncScheduler(AsyncAction);\nexport const async = asyncScheduler;\n","export const dateTimestampProvider = {\n now() {\n return (dateTimestampProvider.delegate || Date).now();\n },\n delegate: undefined,\n};\n","export const timeoutProvider = {\n setTimeout(handler, timeout, ...args) {\n const { delegate } = timeoutProvider;\n if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {\n return delegate.setTimeout(handler, timeout, ...args);\n }\n return setTimeout(handler, timeout, ...args);\n },\n clearTimeout(handle) {\n const { delegate } = timeoutProvider;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);\n },\n delegate: undefined,\n};\n","export function getSymbolIterator() {\n if (typeof Symbol !== 'function' || !Symbol.iterator) {\n return '@@iterator';\n }\n return Symbol.iterator;\n}\nexport const iterator = getSymbolIterator();\n","export const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();\n","import { createErrorClass } from './createErrorClass';\nexport const EmptyError = createErrorClass((_super) => function EmptyErrorImpl() {\n _super(this);\n this.name = 'EmptyError';\n this.message = 'no elements in sequence';\n});\n","import { isFunction } from './isFunction';\nimport { isScheduler } from './isScheduler';\nfunction last(arr) {\n return arr[arr.length - 1];\n}\nexport function popResultSelector(args) {\n return isFunction(last(args)) ? args.pop() : undefined;\n}\nexport function popScheduler(args) {\n return isScheduler(last(args)) ? args.pop() : undefined;\n}\nexport function popNumber(args, defaultValue) {\n return typeof last(args) === 'number' ? args.pop() : defaultValue;\n}\n","const { isArray } = Array;\nconst { getPrototypeOf, prototype: objectProto, keys: getKeys } = Object;\nexport function argsArgArrayOrObject(args) {\n if (args.length === 1) {\n const first = args[0];\n if (isArray(first)) {\n return { args: first, keys: null };\n }\n if (isPOJO(first)) {\n const keys = getKeys(first);\n return {\n args: keys.map((key) => first[key]),\n keys,\n };\n }\n }\n return { args: args, keys: null };\n}\nfunction isPOJO(obj) {\n return obj && typeof obj === 'object' && getPrototypeOf(obj) === objectProto;\n}\n","export function arrRemove(arr, item) {\n if (arr) {\n const index = arr.indexOf(item);\n 0 <= index && arr.splice(index, 1);\n }\n}\n","export function createErrorClass(createImpl) {\n const _super = (instance) => {\n Error.call(instance);\n instance.stack = new Error().stack;\n };\n const ctorFunc = createImpl(_super);\n ctorFunc.prototype = Object.create(Error.prototype);\n ctorFunc.prototype.constructor = ctorFunc;\n return ctorFunc;\n}\n","export function createObject(keys, values) {\n return keys.reduce((result, key, i) => ((result[key] = values[i]), result), {});\n}\n","import { config } from '../config';\nlet context = null;\nexport function errorContext(cb) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n const isRoot = !context;\n if (isRoot) {\n context = { errorThrown: false, error: null };\n }\n cb();\n if (isRoot) {\n const { errorThrown, error } = context;\n context = null;\n if (errorThrown) {\n throw error;\n }\n }\n }\n else {\n cb();\n }\n}\nexport function captureError(err) {\n if (config.useDeprecatedSynchronousErrorHandling && context) {\n context.errorThrown = true;\n context.error = err;\n }\n}\n","export function executeSchedule(parentSubscription, scheduler, work, delay = 0, repeat = false) {\n const scheduleSubscription = scheduler.schedule(function () {\n work();\n if (repeat) {\n parentSubscription.add(this.schedule(null, delay));\n }\n else {\n this.unsubscribe();\n }\n }, delay);\n parentSubscription.add(scheduleSubscription);\n if (!repeat) {\n return scheduleSubscription;\n }\n}\n","export function identity(x) {\n return x;\n}\n","export const isArrayLike = ((x) => x && typeof x.length === 'number' && typeof x !== 'function');\n","import { isFunction } from './isFunction';\nexport function isAsyncIterable(obj) {\n return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);\n}\n","export function isFunction(value) {\n return typeof value === 'function';\n}\n","import { observable as Symbol_observable } from '../symbol/observable';\nimport { isFunction } from './isFunction';\nexport function isInteropObservable(input) {\n return isFunction(input[Symbol_observable]);\n}\n","import { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { isFunction } from './isFunction';\nexport function isIterable(input) {\n return isFunction(input === null || input === void 0 ? void 0 : input[Symbol_iterator]);\n}\n","import { Observable } from '../Observable';\nimport { isFunction } from './isFunction';\nexport function isObservable(obj) {\n return !!obj && (obj instanceof Observable || (isFunction(obj.lift) && isFunction(obj.subscribe)));\n}\n","import { isFunction } from \"./isFunction\";\nexport function isPromise(value) {\n return isFunction(value === null || value === void 0 ? void 0 : value.then);\n}\n","import { __asyncGenerator, __await } from \"tslib\";\nimport { isFunction } from './isFunction';\nexport function readableStreamLikeToAsyncGenerator(readableStream) {\n return __asyncGenerator(this, arguments, function* readableStreamLikeToAsyncGenerator_1() {\n const reader = readableStream.getReader();\n try {\n while (true) {\n const { value, done } = yield __await(reader.read());\n if (done) {\n return yield __await(void 0);\n }\n yield yield __await(value);\n }\n }\n finally {\n reader.releaseLock();\n }\n });\n}\nexport function isReadableStreamLike(obj) {\n return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);\n}\n","import { isFunction } from './isFunction';\nexport function isScheduler(value) {\n return value && isFunction(value.schedule);\n}\n","import { isFunction } from './isFunction';\nexport function hasLift(source) {\n return isFunction(source === null || source === void 0 ? void 0 : source.lift);\n}\nexport function operate(init) {\n return (source) => {\n if (hasLift(source)) {\n return source.lift(function (liftedSource) {\n try {\n return init(liftedSource, this);\n }\n catch (err) {\n this.error(err);\n }\n });\n }\n throw new TypeError('Unable to lift unknown Observable type');\n };\n}\n","import { map } from \"../operators/map\";\nconst { isArray } = Array;\nfunction callOrApply(fn, args) {\n return isArray(args) ? fn(...args) : fn(args);\n}\nexport function mapOneOrManyArgs(fn) {\n return map(args => callOrApply(fn, args));\n}\n","export function noop() { }\n","import { identity } from './identity';\nexport function pipe(...fns) {\n return pipeFromArray(fns);\n}\nexport function pipeFromArray(fns) {\n if (fns.length === 0) {\n return identity;\n }\n if (fns.length === 1) {\n return fns[0];\n }\n return function piped(input) {\n return fns.reduce((prev, fn) => fn(prev), input);\n };\n}\n","import { config } from '../config';\nimport { timeoutProvider } from '../scheduler/timeoutProvider';\nexport function reportUnhandledError(err) {\n timeoutProvider.setTimeout(() => {\n const { onUnhandledError } = config;\n if (onUnhandledError) {\n onUnhandledError(err);\n }\n else {\n throw err;\n }\n });\n}\n","export function createInvalidObservableTypeError(input) {\n return new TypeError(`You provided ${input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`);\n}\n","/* eslint-env node */\n'use strict';\n\n// SDP helpers.\nconst SDPUtils = {};\n\n// Generate an alphanumeric identifier for cname or mids.\n// TODO: use UUIDs instead? https://gist.github.com/jed/982883\nSDPUtils.generateIdentifier = function() {\n return Math.random().toString(36).substring(2, 12);\n};\n\n// The RTCP CNAME used by all peerconnections from the same JS.\nSDPUtils.localCName = SDPUtils.generateIdentifier();\n\n// Splits SDP into lines, dealing with both CRLF and LF.\nSDPUtils.splitLines = function(blob) {\n return blob.trim().split('\\n').map(line => line.trim());\n};\n// Splits SDP into sessionpart and mediasections. Ensures CRLF.\nSDPUtils.splitSections = function(blob) {\n const parts = blob.split('\\nm=');\n return parts.map((part, index) => (index > 0 ?\n 'm=' + part : part).trim() + '\\r\\n');\n};\n\n// Returns the session description.\nSDPUtils.getDescription = function(blob) {\n const sections = SDPUtils.splitSections(blob);\n return sections && sections[0];\n};\n\n// Returns the individual media sections.\nSDPUtils.getMediaSections = function(blob) {\n const sections = SDPUtils.splitSections(blob);\n sections.shift();\n return sections;\n};\n\n// Returns lines that start with a certain prefix.\nSDPUtils.matchPrefix = function(blob, prefix) {\n return SDPUtils.splitLines(blob).filter(line => line.indexOf(prefix) === 0);\n};\n\n// Parses an ICE candidate line. Sample input:\n// candidate:702786350 2 udp 41819902 8.8.8.8 60769 typ relay raddr 8.8.8.8\n// rport 55996\"\n// Input can be prefixed with a=.\nSDPUtils.parseCandidate = function(line) {\n let parts;\n // Parse both variants.\n if (line.indexOf('a=candidate:') === 0) {\n parts = line.substring(12).split(' ');\n } else {\n parts = line.substring(10).split(' ');\n }\n\n const candidate = {\n foundation: parts[0],\n component: {1: 'rtp', 2: 'rtcp'}[parts[1]] || parts[1],\n protocol: parts[2].toLowerCase(),\n priority: parseInt(parts[3], 10),\n ip: parts[4],\n address: parts[4], // address is an alias for ip.\n port: parseInt(parts[5], 10),\n // skip parts[6] == 'typ'\n type: parts[7],\n };\n\n for (let i = 8; i < parts.length; i += 2) {\n switch (parts[i]) {\n case 'raddr':\n candidate.relatedAddress = parts[i + 1];\n break;\n case 'rport':\n candidate.relatedPort = parseInt(parts[i + 1], 10);\n break;\n case 'tcptype':\n candidate.tcpType = parts[i + 1];\n break;\n case 'ufrag':\n candidate.ufrag = parts[i + 1]; // for backward compatibility.\n candidate.usernameFragment = parts[i + 1];\n break;\n default: // extension handling, in particular ufrag. Don't overwrite.\n if (candidate[parts[i]] === undefined) {\n candidate[parts[i]] = parts[i + 1];\n }\n break;\n }\n }\n return candidate;\n};\n\n// Translates a candidate object into SDP candidate attribute.\n// This does not include the a= prefix!\nSDPUtils.writeCandidate = function(candidate) {\n const sdp = [];\n sdp.push(candidate.foundation);\n\n const component = candidate.component;\n if (component === 'rtp') {\n sdp.push(1);\n } else if (component === 'rtcp') {\n sdp.push(2);\n } else {\n sdp.push(component);\n }\n sdp.push(candidate.protocol.toUpperCase());\n sdp.push(candidate.priority);\n sdp.push(candidate.address || candidate.ip);\n sdp.push(candidate.port);\n\n const type = candidate.type;\n sdp.push('typ');\n sdp.push(type);\n if (type !== 'host' && candidate.relatedAddress &&\n candidate.relatedPort) {\n sdp.push('raddr');\n sdp.push(candidate.relatedAddress);\n sdp.push('rport');\n sdp.push(candidate.relatedPort);\n }\n if (candidate.tcpType && candidate.protocol.toLowerCase() === 'tcp') {\n sdp.push('tcptype');\n sdp.push(candidate.tcpType);\n }\n if (candidate.usernameFragment || candidate.ufrag) {\n sdp.push('ufrag');\n sdp.push(candidate.usernameFragment || candidate.ufrag);\n }\n return 'candidate:' + sdp.join(' ');\n};\n\n// Parses an ice-options line, returns an array of option tags.\n// Sample input:\n// a=ice-options:foo bar\nSDPUtils.parseIceOptions = function(line) {\n return line.substring(14).split(' ');\n};\n\n// Parses a rtpmap line, returns RTCRtpCoddecParameters. Sample input:\n// a=rtpmap:111 opus/48000/2\nSDPUtils.parseRtpMap = function(line) {\n let parts = line.substring(9).split(' ');\n const parsed = {\n payloadType: parseInt(parts.shift(), 10), // was: id\n };\n\n parts = parts[0].split('/');\n\n parsed.name = parts[0];\n parsed.clockRate = parseInt(parts[1], 10); // was: clockrate\n parsed.channels = parts.length === 3 ? parseInt(parts[2], 10) : 1;\n // legacy alias, got renamed back to channels in ORTC.\n parsed.numChannels = parsed.channels;\n return parsed;\n};\n\n// Generates a rtpmap line from RTCRtpCodecCapability or\n// RTCRtpCodecParameters.\nSDPUtils.writeRtpMap = function(codec) {\n let pt = codec.payloadType;\n if (codec.preferredPayloadType !== undefined) {\n pt = codec.preferredPayloadType;\n }\n const channels = codec.channels || codec.numChannels || 1;\n return 'a=rtpmap:' + pt + ' ' + codec.name + '/' + codec.clockRate +\n (channels !== 1 ? '/' + channels : '') + '\\r\\n';\n};\n\n// Parses a extmap line (headerextension from RFC 5285). Sample input:\n// a=extmap:2 urn:ietf:params:rtp-hdrext:toffset\n// a=extmap:2/sendonly urn:ietf:params:rtp-hdrext:toffset\nSDPUtils.parseExtmap = function(line) {\n const parts = line.substring(9).split(' ');\n return {\n id: parseInt(parts[0], 10),\n direction: parts[0].indexOf('/') > 0 ? parts[0].split('/')[1] : 'sendrecv',\n uri: parts[1],\n attributes: parts.slice(2).join(' '),\n };\n};\n\n// Generates an extmap line from RTCRtpHeaderExtensionParameters or\n// RTCRtpHeaderExtension.\nSDPUtils.writeExtmap = function(headerExtension) {\n return 'a=extmap:' + (headerExtension.id || headerExtension.preferredId) +\n (headerExtension.direction && headerExtension.direction !== 'sendrecv'\n ? '/' + headerExtension.direction\n : '') +\n ' ' + headerExtension.uri +\n (headerExtension.attributes ? ' ' + headerExtension.attributes : '') +\n '\\r\\n';\n};\n\n// Parses a fmtp line, returns dictionary. Sample input:\n// a=fmtp:96 vbr=on;cng=on\n// Also deals with vbr=on; cng=on\nSDPUtils.parseFmtp = function(line) {\n const parsed = {};\n let kv;\n const parts = line.substring(line.indexOf(' ') + 1).split(';');\n for (let j = 0; j < parts.length; j++) {\n kv = parts[j].trim().split('=');\n parsed[kv[0].trim()] = kv[1];\n }\n return parsed;\n};\n\n// Generates a fmtp line from RTCRtpCodecCapability or RTCRtpCodecParameters.\nSDPUtils.writeFmtp = function(codec) {\n let line = '';\n let pt = codec.payloadType;\n if (codec.preferredPayloadType !== undefined) {\n pt = codec.preferredPayloadType;\n }\n if (codec.parameters && Object.keys(codec.parameters).length) {\n const params = [];\n Object.keys(codec.parameters).forEach(param => {\n if (codec.parameters[param] !== undefined) {\n params.push(param + '=' + codec.parameters[param]);\n } else {\n params.push(param);\n }\n });\n line += 'a=fmtp:' + pt + ' ' + params.join(';') + '\\r\\n';\n }\n return line;\n};\n\n// Parses a rtcp-fb line, returns RTCPRtcpFeedback object. Sample input:\n// a=rtcp-fb:98 nack rpsi\nSDPUtils.parseRtcpFb = function(line) {\n const parts = line.substring(line.indexOf(' ') + 1).split(' ');\n return {\n type: parts.shift(),\n parameter: parts.join(' '),\n };\n};\n\n// Generate a=rtcp-fb lines from RTCRtpCodecCapability or RTCRtpCodecParameters.\nSDPUtils.writeRtcpFb = function(codec) {\n let lines = '';\n let pt = codec.payloadType;\n if (codec.preferredPayloadType !== undefined) {\n pt = codec.preferredPayloadType;\n }\n if (codec.rtcpFeedback && codec.rtcpFeedback.length) {\n // FIXME: special handling for trr-int?\n codec.rtcpFeedback.forEach(fb => {\n lines += 'a=rtcp-fb:' + pt + ' ' + fb.type +\n (fb.parameter && fb.parameter.length ? ' ' + fb.parameter : '') +\n '\\r\\n';\n });\n }\n return lines;\n};\n\n// Parses a RFC 5576 ssrc media attribute. Sample input:\n// a=ssrc:3735928559 cname:something\nSDPUtils.parseSsrcMedia = function(line) {\n const sp = line.indexOf(' ');\n const parts = {\n ssrc: parseInt(line.substring(7, sp), 10),\n };\n const colon = line.indexOf(':', sp);\n if (colon > -1) {\n parts.attribute = line.substring(sp + 1, colon);\n parts.value = line.substring(colon + 1);\n } else {\n parts.attribute = line.substring(sp + 1);\n }\n return parts;\n};\n\n// Parse a ssrc-group line (see RFC 5576). Sample input:\n// a=ssrc-group:semantics 12 34\nSDPUtils.parseSsrcGroup = function(line) {\n const parts = line.substring(13).split(' ');\n return {\n semantics: parts.shift(),\n ssrcs: parts.map(ssrc => parseInt(ssrc, 10)),\n };\n};\n\n// Extracts the MID (RFC 5888) from a media section.\n// Returns the MID or undefined if no mid line was found.\nSDPUtils.getMid = function(mediaSection) {\n const mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:')[0];\n if (mid) {\n return mid.substring(6);\n }\n};\n\n// Parses a fingerprint line for DTLS-SRTP.\nSDPUtils.parseFingerprint = function(line) {\n const parts = line.substring(14).split(' ');\n return {\n algorithm: parts[0].toLowerCase(), // algorithm is case-sensitive in Edge.\n value: parts[1].toUpperCase(), // the definition is upper-case in RFC 4572.\n };\n};\n\n// Extracts DTLS parameters from SDP media section or sessionpart.\n// FIXME: for consistency with other functions this should only\n// get the fingerprint line as input. See also getIceParameters.\nSDPUtils.getDtlsParameters = function(mediaSection, sessionpart) {\n const lines = SDPUtils.matchPrefix(mediaSection + sessionpart,\n 'a=fingerprint:');\n // Note: a=setup line is ignored since we use the 'auto' role in Edge.\n return {\n role: 'auto',\n fingerprints: lines.map(SDPUtils.parseFingerprint),\n };\n};\n\n// Serializes DTLS parameters to SDP.\nSDPUtils.writeDtlsParameters = function(params, setupType) {\n let sdp = 'a=setup:' + setupType + '\\r\\n';\n params.fingerprints.forEach(fp => {\n sdp += 'a=fingerprint:' + fp.algorithm + ' ' + fp.value + '\\r\\n';\n });\n return sdp;\n};\n\n// Parses a=crypto lines into\n// https://rawgit.com/aboba/edgertc/master/msortc-rs4.html#dictionary-rtcsrtpsdesparameters-members\nSDPUtils.parseCryptoLine = function(line) {\n const parts = line.substring(9).split(' ');\n return {\n tag: parseInt(parts[0], 10),\n cryptoSuite: parts[1],\n keyParams: parts[2],\n sessionParams: parts.slice(3),\n };\n};\n\nSDPUtils.writeCryptoLine = function(parameters) {\n return 'a=crypto:' + parameters.tag + ' ' +\n parameters.cryptoSuite + ' ' +\n (typeof parameters.keyParams === 'object'\n ? SDPUtils.writeCryptoKeyParams(parameters.keyParams)\n : parameters.keyParams) +\n (parameters.sessionParams ? ' ' + parameters.sessionParams.join(' ') : '') +\n '\\r\\n';\n};\n\n// Parses the crypto key parameters into\n// https://rawgit.com/aboba/edgertc/master/msortc-rs4.html#rtcsrtpkeyparam*\nSDPUtils.parseCryptoKeyParams = function(keyParams) {\n if (keyParams.indexOf('inline:') !== 0) {\n return null;\n }\n const parts = keyParams.substring(7).split('|');\n return {\n keyMethod: 'inline',\n keySalt: parts[0],\n lifeTime: parts[1],\n mkiValue: parts[2] ? parts[2].split(':')[0] : undefined,\n mkiLength: parts[2] ? parts[2].split(':')[1] : undefined,\n };\n};\n\nSDPUtils.writeCryptoKeyParams = function(keyParams) {\n return keyParams.keyMethod + ':'\n + keyParams.keySalt +\n (keyParams.lifeTime ? '|' + keyParams.lifeTime : '') +\n (keyParams.mkiValue && keyParams.mkiLength\n ? '|' + keyParams.mkiValue + ':' + keyParams.mkiLength\n : '');\n};\n\n// Extracts all SDES parameters.\nSDPUtils.getCryptoParameters = function(mediaSection, sessionpart) {\n const lines = SDPUtils.matchPrefix(mediaSection + sessionpart,\n 'a=crypto:');\n return lines.map(SDPUtils.parseCryptoLine);\n};\n\n// Parses ICE information from SDP media section or sessionpart.\n// FIXME: for consistency with other functions this should only\n// get the ice-ufrag and ice-pwd lines as input.\nSDPUtils.getIceParameters = function(mediaSection, sessionpart) {\n const ufrag = SDPUtils.matchPrefix(mediaSection + sessionpart,\n 'a=ice-ufrag:')[0];\n const pwd = SDPUtils.matchPrefix(mediaSection + sessionpart,\n 'a=ice-pwd:')[0];\n if (!(ufrag && pwd)) {\n return null;\n }\n return {\n usernameFragment: ufrag.substring(12),\n password: pwd.substring(10),\n };\n};\n\n// Serializes ICE parameters to SDP.\nSDPUtils.writeIceParameters = function(params) {\n let sdp = 'a=ice-ufrag:' + params.usernameFragment + '\\r\\n' +\n 'a=ice-pwd:' + params.password + '\\r\\n';\n if (params.iceLite) {\n sdp += 'a=ice-lite\\r\\n';\n }\n return sdp;\n};\n\n// Parses the SDP media section and returns RTCRtpParameters.\nSDPUtils.parseRtpParameters = function(mediaSection) {\n const description = {\n codecs: [],\n headerExtensions: [],\n fecMechanisms: [],\n rtcp: [],\n };\n const lines = SDPUtils.splitLines(mediaSection);\n const mline = lines[0].split(' ');\n description.profile = mline[2];\n for (let i = 3; i < mline.length; i++) { // find all codecs from mline[3..]\n const pt = mline[i];\n const rtpmapline = SDPUtils.matchPrefix(\n mediaSection, 'a=rtpmap:' + pt + ' ')[0];\n if (rtpmapline) {\n const codec = SDPUtils.parseRtpMap(rtpmapline);\n const fmtps = SDPUtils.matchPrefix(\n mediaSection, 'a=fmtp:' + pt + ' ');\n // Only the first a=fmtp: is considered.\n codec.parameters = fmtps.length ? SDPUtils.parseFmtp(fmtps[0]) : {};\n codec.rtcpFeedback = SDPUtils.matchPrefix(\n mediaSection, 'a=rtcp-fb:' + pt + ' ')\n .map(SDPUtils.parseRtcpFb);\n description.codecs.push(codec);\n // parse FEC mechanisms from rtpmap lines.\n switch (codec.name.toUpperCase()) {\n case 'RED':\n case 'ULPFEC':\n description.fecMechanisms.push(codec.name.toUpperCase());\n break;\n default: // only RED and ULPFEC are recognized as FEC mechanisms.\n break;\n }\n }\n }\n SDPUtils.matchPrefix(mediaSection, 'a=extmap:').forEach(line => {\n description.headerExtensions.push(SDPUtils.parseExtmap(line));\n });\n const wildcardRtcpFb = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-fb:* ')\n .map(SDPUtils.parseRtcpFb);\n description.codecs.forEach(codec => {\n wildcardRtcpFb.forEach(fb=> {\n const duplicate = codec.rtcpFeedback.find(existingFeedback => {\n return existingFeedback.type === fb.type &&\n existingFeedback.parameter === fb.parameter;\n });\n if (!duplicate) {\n codec.rtcpFeedback.push(fb);\n }\n });\n });\n // FIXME: parse rtcp.\n return description;\n};\n\n// Generates parts of the SDP media section describing the capabilities /\n// parameters.\nSDPUtils.writeRtpDescription = function(kind, caps) {\n let sdp = '';\n\n // Build the mline.\n sdp += 'm=' + kind + ' ';\n sdp += caps.codecs.length > 0 ? '9' : '0'; // reject if no codecs.\n sdp += ' ' + (caps.profile || 'UDP/TLS/RTP/SAVPF') + ' ';\n sdp += caps.codecs.map(codec => {\n if (codec.preferredPayloadType !== undefined) {\n return codec.preferredPayloadType;\n }\n return codec.payloadType;\n }).join(' ') + '\\r\\n';\n\n sdp += 'c=IN IP4 0.0.0.0\\r\\n';\n sdp += 'a=rtcp:9 IN IP4 0.0.0.0\\r\\n';\n\n // Add a=rtpmap lines for each codec. Also fmtp and rtcp-fb.\n caps.codecs.forEach(codec => {\n sdp += SDPUtils.writeRtpMap(codec);\n sdp += SDPUtils.writeFmtp(codec);\n sdp += SDPUtils.writeRtcpFb(codec);\n });\n let maxptime = 0;\n caps.codecs.forEach(codec => {\n if (codec.maxptime > maxptime) {\n maxptime = codec.maxptime;\n }\n });\n if (maxptime > 0) {\n sdp += 'a=maxptime:' + maxptime + '\\r\\n';\n }\n\n if (caps.headerExtensions) {\n caps.headerExtensions.forEach(extension => {\n sdp += SDPUtils.writeExtmap(extension);\n });\n }\n // FIXME: write fecMechanisms.\n return sdp;\n};\n\n// Parses the SDP media section and returns an array of\n// RTCRtpEncodingParameters.\nSDPUtils.parseRtpEncodingParameters = function(mediaSection) {\n const encodingParameters = [];\n const description = SDPUtils.parseRtpParameters(mediaSection);\n const hasRed = description.fecMechanisms.indexOf('RED') !== -1;\n const hasUlpfec = description.fecMechanisms.indexOf('ULPFEC') !== -1;\n\n // filter a=ssrc:... cname:, ignore PlanB-msid\n const ssrcs = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:')\n .map(line => SDPUtils.parseSsrcMedia(line))\n .filter(parts => parts.attribute === 'cname');\n const primarySsrc = ssrcs.length > 0 && ssrcs[0].ssrc;\n let secondarySsrc;\n\n const flows = SDPUtils.matchPrefix(mediaSection, 'a=ssrc-group:FID')\n .map(line => {\n const parts = line.substring(17).split(' ');\n return parts.map(part => parseInt(part, 10));\n });\n if (flows.length > 0 && flows[0].length > 1 && flows[0][0] === primarySsrc) {\n secondarySsrc = flows[0][1];\n }\n\n description.codecs.forEach(codec => {\n if (codec.name.toUpperCase() === 'RTX' && codec.parameters.apt) {\n let encParam = {\n ssrc: primarySsrc,\n codecPayloadType: parseInt(codec.parameters.apt, 10),\n };\n if (primarySsrc && secondarySsrc) {\n encParam.rtx = {ssrc: secondarySsrc};\n }\n encodingParameters.push(encParam);\n if (hasRed) {\n encParam = JSON.parse(JSON.stringify(encParam));\n encParam.fec = {\n ssrc: primarySsrc,\n mechanism: hasUlpfec ? 'red+ulpfec' : 'red',\n };\n encodingParameters.push(encParam);\n }\n }\n });\n if (encodingParameters.length === 0 && primarySsrc) {\n encodingParameters.push({\n ssrc: primarySsrc,\n });\n }\n\n // we support both b=AS and b=TIAS but interpret AS as TIAS.\n let bandwidth = SDPUtils.matchPrefix(mediaSection, 'b=');\n if (bandwidth.length) {\n if (bandwidth[0].indexOf('b=TIAS:') === 0) {\n bandwidth = parseInt(bandwidth[0].substring(7), 10);\n } else if (bandwidth[0].indexOf('b=AS:') === 0) {\n // use formula from JSEP to convert b=AS to TIAS value.\n bandwidth = parseInt(bandwidth[0].substring(5), 10) * 1000 * 0.95\n - (50 * 40 * 8);\n } else {\n bandwidth = undefined;\n }\n encodingParameters.forEach(params => {\n params.maxBitrate = bandwidth;\n });\n }\n return encodingParameters;\n};\n\n// parses http://draft.ortc.org/#rtcrtcpparameters*\nSDPUtils.parseRtcpParameters = function(mediaSection) {\n const rtcpParameters = {};\n\n // Gets the first SSRC. Note that with RTX there might be multiple\n // SSRCs.\n const remoteSsrc = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:')\n .map(line => SDPUtils.parseSsrcMedia(line))\n .filter(obj => obj.attribute === 'cname')[0];\n if (remoteSsrc) {\n rtcpParameters.cname = remoteSsrc.value;\n rtcpParameters.ssrc = remoteSsrc.ssrc;\n }\n\n // Edge uses the compound attribute instead of reducedSize\n // compound is !reducedSize\n const rsize = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-rsize');\n rtcpParameters.reducedSize = rsize.length > 0;\n rtcpParameters.compound = rsize.length === 0;\n\n // parses the rtcp-mux attrіbute.\n // Note that Edge does not support unmuxed RTCP.\n const mux = SDPUtils.matchPrefix(mediaSection, 'a=rtcp-mux');\n rtcpParameters.mux = mux.length > 0;\n\n return rtcpParameters;\n};\n\nSDPUtils.writeRtcpParameters = function(rtcpParameters) {\n let sdp = '';\n if (rtcpParameters.reducedSize) {\n sdp += 'a=rtcp-rsize\\r\\n';\n }\n if (rtcpParameters.mux) {\n sdp += 'a=rtcp-mux\\r\\n';\n }\n if (rtcpParameters.ssrc !== undefined && rtcpParameters.cname) {\n sdp += 'a=ssrc:' + rtcpParameters.ssrc +\n ' cname:' + rtcpParameters.cname + '\\r\\n';\n }\n return sdp;\n};\n\n\n// parses either a=msid: or a=ssrc:... msid lines and returns\n// the id of the MediaStream and MediaStreamTrack.\nSDPUtils.parseMsid = function(mediaSection) {\n let parts;\n const spec = SDPUtils.matchPrefix(mediaSection, 'a=msid:');\n if (spec.length === 1) {\n parts = spec[0].substring(7).split(' ');\n return {stream: parts[0], track: parts[1]};\n }\n const planB = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:')\n .map(line => SDPUtils.parseSsrcMedia(line))\n .filter(msidParts => msidParts.attribute === 'msid');\n if (planB.length > 0) {\n parts = planB[0].value.split(' ');\n return {stream: parts[0], track: parts[1]};\n }\n};\n\n// SCTP\n// parses draft-ietf-mmusic-sctp-sdp-26 first and falls back\n// to draft-ietf-mmusic-sctp-sdp-05\nSDPUtils.parseSctpDescription = function(mediaSection) {\n const mline = SDPUtils.parseMLine(mediaSection);\n const maxSizeLine = SDPUtils.matchPrefix(mediaSection, 'a=max-message-size:');\n let maxMessageSize;\n if (maxSizeLine.length > 0) {\n maxMessageSize = parseInt(maxSizeLine[0].substring(19), 10);\n }\n if (isNaN(maxMessageSize)) {\n maxMessageSize = 65536;\n }\n const sctpPort = SDPUtils.matchPrefix(mediaSection, 'a=sctp-port:');\n if (sctpPort.length > 0) {\n return {\n port: parseInt(sctpPort[0].substring(12), 10),\n protocol: mline.fmt,\n maxMessageSize,\n };\n }\n const sctpMapLines = SDPUtils.matchPrefix(mediaSection, 'a=sctpmap:');\n if (sctpMapLines.length > 0) {\n const parts = sctpMapLines[0]\n .substring(10)\n .split(' ');\n return {\n port: parseInt(parts[0], 10),\n protocol: parts[1],\n maxMessageSize,\n };\n }\n};\n\n// SCTP\n// outputs the draft-ietf-mmusic-sctp-sdp-26 version that all browsers\n// support by now receiving in this format, unless we originally parsed\n// as the draft-ietf-mmusic-sctp-sdp-05 format (indicated by the m-line\n// protocol of DTLS/SCTP -- without UDP/ or TCP/)\nSDPUtils.writeSctpDescription = function(media, sctp) {\n let output = [];\n if (media.protocol !== 'DTLS/SCTP') {\n output = [\n 'm=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.protocol + '\\r\\n',\n 'c=IN IP4 0.0.0.0\\r\\n',\n 'a=sctp-port:' + sctp.port + '\\r\\n',\n ];\n } else {\n output = [\n 'm=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.port + '\\r\\n',\n 'c=IN IP4 0.0.0.0\\r\\n',\n 'a=sctpmap:' + sctp.port + ' ' + sctp.protocol + ' 65535\\r\\n',\n ];\n }\n if (sctp.maxMessageSize !== undefined) {\n output.push('a=max-message-size:' + sctp.maxMessageSize + '\\r\\n');\n }\n return output.join('');\n};\n\n// Generate a session ID for SDP.\n// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-20#section-5.2.1\n// recommends using a cryptographically random +ve 64-bit value\n// but right now this should be acceptable and within the right range\nSDPUtils.generateSessionId = function() {\n return Math.random().toString().substr(2, 22);\n};\n\n// Write boiler plate for start of SDP\n// sessId argument is optional - if not supplied it will\n// be generated randomly\n// sessVersion is optional and defaults to 2\n// sessUser is optional and defaults to 'thisisadapterortc'\nSDPUtils.writeSessionBoilerplate = function(sessId, sessVer, sessUser) {\n let sessionId;\n const version = sessVer !== undefined ? sessVer : 2;\n if (sessId) {\n sessionId = sessId;\n } else {\n sessionId = SDPUtils.generateSessionId();\n }\n const user = sessUser || 'thisisadapterortc';\n // FIXME: sess-id should be an NTP timestamp.\n return 'v=0\\r\\n' +\n 'o=' + user + ' ' + sessionId + ' ' + version +\n ' IN IP4 127.0.0.1\\r\\n' +\n 's=-\\r\\n' +\n 't=0 0\\r\\n';\n};\n\n// Gets the direction from the mediaSection or the sessionpart.\nSDPUtils.getDirection = function(mediaSection, sessionpart) {\n // Look for sendrecv, sendonly, recvonly, inactive, default to sendrecv.\n const lines = SDPUtils.splitLines(mediaSection);\n for (let i = 0; i < lines.length; i++) {\n switch (lines[i]) {\n case 'a=sendrecv':\n case 'a=sendonly':\n case 'a=recvonly':\n case 'a=inactive':\n return lines[i].substring(2);\n default:\n // FIXME: What should happen here?\n }\n }\n if (sessionpart) {\n return SDPUtils.getDirection(sessionpart);\n }\n return 'sendrecv';\n};\n\nSDPUtils.getKind = function(mediaSection) {\n const lines = SDPUtils.splitLines(mediaSection);\n const mline = lines[0].split(' ');\n return mline[0].substring(2);\n};\n\nSDPUtils.isRejected = function(mediaSection) {\n return mediaSection.split(' ', 2)[1] === '0';\n};\n\nSDPUtils.parseMLine = function(mediaSection) {\n const lines = SDPUtils.splitLines(mediaSection);\n const parts = lines[0].substring(2).split(' ');\n return {\n kind: parts[0],\n port: parseInt(parts[1], 10),\n protocol: parts[2],\n fmt: parts.slice(3).join(' '),\n };\n};\n\nSDPUtils.parseOLine = function(mediaSection) {\n const line = SDPUtils.matchPrefix(mediaSection, 'o=')[0];\n const parts = line.substring(2).split(' ');\n return {\n username: parts[0],\n sessionId: parts[1],\n sessionVersion: parseInt(parts[2], 10),\n netType: parts[3],\n addressType: parts[4],\n address: parts[5],\n };\n};\n\n// a very naive interpretation of a valid SDP.\nSDPUtils.isValidSDP = function(blob) {\n if (typeof blob !== 'string' || blob.length === 0) {\n return false;\n }\n const lines = SDPUtils.splitLines(blob);\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].length < 2 || lines[i].charAt(1) !== '=') {\n return false;\n }\n // TODO: check the modifier a bit more.\n }\n return true;\n};\n\n// Expose public methods.\nif (typeof module === 'object') {\n module.exports = SDPUtils;\n}\n","/**\n * @license Angular v19.0.6\n * (c) 2010-2024 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport { DOCUMENT } from '@angular/common';\nimport * as i0 from '@angular/core';\nimport { inject, Injectable, ANIMATION_MODULE_TYPE, ViewEncapsulation, ɵRuntimeError, Inject } from '@angular/core';\n\n/**\n * @description Constants for the categories of parameters that can be defined for animations.\n *\n * A corresponding function defines a set of parameters for each category, and\n * collects them into a corresponding `AnimationMetadata` object.\n *\n * @publicApi\n */\nvar AnimationMetadataType;\n(function (AnimationMetadataType) {\n /**\n * Associates a named animation state with a set of CSS styles.\n * See [`state()`](api/animations/state)\n */\n AnimationMetadataType[AnimationMetadataType[\"State\"] = 0] = \"State\";\n /**\n * Data for a transition from one animation state to another.\n * See `transition()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Transition\"] = 1] = \"Transition\";\n /**\n * Contains a set of animation steps.\n * See `sequence()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Sequence\"] = 2] = \"Sequence\";\n /**\n * Contains a set of animation steps.\n * See `{@link animations/group group()}`\n */\n AnimationMetadataType[AnimationMetadataType[\"Group\"] = 3] = \"Group\";\n /**\n * Contains an animation step.\n * See `animate()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Animate\"] = 4] = \"Animate\";\n /**\n * Contains a set of animation steps.\n * See `keyframes()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Keyframes\"] = 5] = \"Keyframes\";\n /**\n * Contains a set of CSS property-value pairs into a named style.\n * See `style()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Style\"] = 6] = \"Style\";\n /**\n * Associates an animation with an entry trigger that can be attached to an element.\n * See `trigger()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Trigger\"] = 7] = \"Trigger\";\n /**\n * Contains a re-usable animation.\n * See `animation()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Reference\"] = 8] = \"Reference\";\n /**\n * Contains data to use in executing child animations returned by a query.\n * See `animateChild()`\n */\n AnimationMetadataType[AnimationMetadataType[\"AnimateChild\"] = 9] = \"AnimateChild\";\n /**\n * Contains animation parameters for a re-usable animation.\n * See `useAnimation()`\n */\n AnimationMetadataType[AnimationMetadataType[\"AnimateRef\"] = 10] = \"AnimateRef\";\n /**\n * Contains child-animation query data.\n * See `query()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Query\"] = 11] = \"Query\";\n /**\n * Contains data for staggering an animation sequence.\n * See `stagger()`\n */\n AnimationMetadataType[AnimationMetadataType[\"Stagger\"] = 12] = \"Stagger\";\n})(AnimationMetadataType || (AnimationMetadataType = {}));\n/**\n * Specifies automatic styling.\n *\n * @publicApi\n */\nconst AUTO_STYLE = '*';\n/**\n * Creates a named animation trigger, containing a list of [`state()`](api/animations/state)\n * and `transition()` entries to be evaluated when the expression\n * bound to the trigger changes.\n *\n * @param name An identifying string.\n * @param definitions An animation definition object, containing an array of\n * [`state()`](api/animations/state) and `transition()` declarations.\n *\n * @return An object that encapsulates the trigger data.\n *\n * @usageNotes\n * Define an animation trigger in the `animations` section of `@Component` metadata.\n * In the template, reference the trigger by name and bind it to a trigger expression that\n * evaluates to a defined animation state, using the following format:\n *\n * `[@triggerName]=\"expression\"`\n *\n * Animation trigger bindings convert all values to strings, and then match the\n * previous and current values against any linked transitions.\n * Booleans can be specified as `1` or `true` and `0` or `false`.\n *\n * ### Usage Example\n *\n * The following example creates an animation trigger reference based on the provided\n * name value.\n * The provided animation value is expected to be an array consisting of state and\n * transition declarations.\n *\n * ```ts\n * @Component({\n * selector: \"my-component\",\n * templateUrl: \"my-component-tpl.html\",\n * animations: [\n * trigger(\"myAnimationTrigger\", [\n * state(...),\n * state(...),\n * transition(...),\n * transition(...)\n * ])\n * ]\n * })\n * class MyComponent {\n * myStatusExp = \"something\";\n * }\n * ```\n *\n * The template associated with this component makes use of the defined trigger\n * by binding to an element within its template code.\n *\n * ```html\n * \n *
    ...
    \n * ```\n *\n * ### Using an inline function\n * The `transition` animation method also supports reading an inline function which can decide\n * if its associated animation should be run.\n *\n * ```ts\n * // this method is run each time the `myAnimationTrigger` trigger value changes.\n * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:\n string]: any}): boolean {\n * // notice that `element` and `params` are also available here\n * return toState == 'yes-please-animate';\n * }\n *\n * @Component({\n * selector: 'my-component',\n * templateUrl: 'my-component-tpl.html',\n * animations: [\n * trigger('myAnimationTrigger', [\n * transition(myInlineMatcherFn, [\n * // the animation sequence code\n * ]),\n * ])\n * ]\n * })\n * class MyComponent {\n * myStatusExp = \"yes-please-animate\";\n * }\n * ```\n *\n * ### Disabling Animations\n * When true, the special animation control binding `@.disabled` binding prevents\n * all animations from rendering.\n * Place the `@.disabled` binding on an element to disable\n * animations on the element itself, as well as any inner animation triggers\n * within the element.\n *\n * The following example shows how to use this feature:\n *\n * ```angular-ts\n * @Component({\n * selector: 'my-component',\n * template: `\n *
    \n *
    \n *
    \n * `,\n * animations: [\n * trigger(\"childAnimation\", [\n * // ...\n * ])\n * ]\n * })\n * class MyComponent {\n * isDisabled = true;\n * exp = '...';\n * }\n * ```\n *\n * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating,\n * along with any inner animations.\n *\n * ### Disable animations application-wide\n * When an area of the template is set to have animations disabled,\n * **all** inner components have their animations disabled as well.\n * This means that you can disable all animations for an app\n * by placing a host binding set on `@.disabled` on the topmost Angular component.\n *\n * ```ts\n * import {Component, HostBinding} from '@angular/core';\n *\n * @Component({\n * selector: 'app-component',\n * templateUrl: 'app.component.html',\n * })\n * class AppComponent {\n * @HostBinding('@.disabled')\n * public animationsDisabled = true;\n * }\n * ```\n *\n * ### Overriding disablement of inner animations\n * Despite inner animations being disabled, a parent animation can `query()`\n * for inner elements located in disabled areas of the template and still animate\n * them if needed. This is also the case for when a sub animation is\n * queried by a parent and then later animated using `animateChild()`.\n *\n * ### Detecting when an animation is disabled\n * If a region of the DOM (or the entire application) has its animations disabled, the animation\n * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides\n * an instance of an `AnimationEvent`. If animations are disabled,\n * the `.disabled` flag on the event is true.\n *\n * @publicApi\n */\nfunction trigger(name, definitions) {\n return { type: AnimationMetadataType.Trigger, name, definitions, options: {} };\n}\n/**\n * Defines an animation step that combines styling information with timing information.\n *\n * @param timings Sets `AnimateTimings` for the parent animation.\n * A string in the format \"duration [delay] [easing]\".\n * - Duration and delay are expressed as a number and optional time unit,\n * such as \"1s\" or \"10ms\" for one second and 10 milliseconds, respectively.\n * The default unit is milliseconds.\n * - The easing value controls how the animation accelerates and decelerates\n * during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,\n * `ease-in-out`, or a `cubic-bezier()` function call.\n * If not supplied, no easing is applied.\n *\n * For example, the string \"1s 100ms ease-out\" specifies a duration of\n * 1000 milliseconds, and delay of 100 ms, and the \"ease-out\" easing style,\n * which decelerates near the end of the duration.\n * @param styles Sets AnimationStyles for the parent animation.\n * A function call to either `style()` or `keyframes()`\n * that returns a collection of CSS style entries to be applied to the parent animation.\n * When null, uses the styles from the destination state.\n * This is useful when describing an animation step that will complete an animation;\n * see \"Animating to the final state\" in `transitions()`.\n * @returns An object that encapsulates the animation step.\n *\n * @usageNotes\n * Call within an animation `sequence()`, `{@link animations/group group()}`, or\n * `transition()` call to specify an animation step\n * that applies given style data to the parent animation for a given amount of time.\n *\n * ### Syntax Examples\n * **Timing examples**\n *\n * The following examples show various `timings` specifications.\n * - `animate(500)` : Duration is 500 milliseconds.\n * - `animate(\"1s\")` : Duration is 1000 milliseconds.\n * - `animate(\"100ms 0.5s\")` : Duration is 100 milliseconds, delay is 500 milliseconds.\n * - `animate(\"5s ease-in\")` : Duration is 5000 milliseconds, easing in.\n * - `animate(\"5s 10ms cubic-bezier(.17,.67,.88,.1)\")` : Duration is 5000 milliseconds, delay is 10\n * milliseconds, easing according to a bezier curve.\n *\n * **Style examples**\n *\n * The following example calls `style()` to set a single CSS style.\n * ```ts\n * animate(500, style({ background: \"red\" }))\n * ```\n * The following example calls `keyframes()` to set a CSS style\n * to different values for successive keyframes.\n * ```ts\n * animate(500, keyframes(\n * [\n * style({ background: \"blue\" }),\n * style({ background: \"red\" })\n * ])\n * ```\n *\n * @publicApi\n */\nfunction animate(timings, styles = null) {\n return { type: AnimationMetadataType.Animate, styles, timings };\n}\n/**\n * @description Defines a list of animation steps to be run in parallel.\n *\n * @param steps An array of animation step objects.\n * - When steps are defined by `style()` or `animate()`\n * function calls, each call within the group is executed instantly.\n * - To specify offset styles to be applied at a later time, define steps with\n * `keyframes()`, or use `animate()` calls with a delay value.\n * For example:\n *\n * ```ts\n * group([\n * animate(\"1s\", style({ background: \"black\" })),\n * animate(\"2s\", style({ color: \"white\" }))\n * ])\n * ```\n *\n * @param options An options object containing a delay and\n * developer-defined parameters that provide styling defaults and\n * can be overridden on invocation.\n *\n * @return An object that encapsulates the group data.\n *\n * @usageNotes\n * Grouped animations are useful when a series of styles must be\n * animated at different starting times and closed off at different ending times.\n *\n * When called within a `sequence()` or a\n * `transition()` call, does not continue to the next\n * instruction until all of the inner animation steps have completed.\n *\n * @publicApi\n */\nfunction group(steps, options = null) {\n return { type: AnimationMetadataType.Group, steps, options };\n}\n/**\n * Defines a list of animation steps to be run sequentially, one by one.\n *\n * @param steps An array of animation step objects.\n * - Steps defined by `style()` calls apply the styling data immediately.\n * - Steps defined by `animate()` calls apply the styling data over time\n * as specified by the timing data.\n *\n * ```ts\n * sequence([\n * style({ opacity: 0 }),\n * animate(\"1s\", style({ opacity: 1 }))\n * ])\n * ```\n *\n * @param options An options object containing a delay and\n * developer-defined parameters that provide styling defaults and\n * can be overridden on invocation.\n *\n * @return An object that encapsulates the sequence data.\n *\n * @usageNotes\n * When you pass an array of steps to a\n * `transition()` call, the steps run sequentially by default.\n * Compare this to the `{@link animations/group group()}` call, which runs animation steps in\n *parallel.\n *\n * When a sequence is used within a `{@link animations/group group()}` or a `transition()` call,\n * execution continues to the next instruction only after each of the inner animation\n * steps have completed.\n *\n * @publicApi\n **/\nfunction sequence(steps, options = null) {\n return { type: AnimationMetadataType.Sequence, steps, options };\n}\n/**\n * Declares a key/value object containing CSS properties/styles that\n * can then be used for an animation [`state`](api/animations/state), within an animation\n *`sequence`, or as styling data for calls to `animate()` and `keyframes()`.\n *\n * @param tokens A set of CSS styles or HTML styles associated with an animation state.\n * The value can be any of the following:\n * - A key-value style pair associating a CSS property with a value.\n * - An array of key-value style pairs.\n * - An asterisk (*), to use auto-styling, where styles are derived from the element\n * being animated and applied to the animation when it starts.\n *\n * Auto-styling can be used to define a state that depends on layout or other\n * environmental factors.\n *\n * @return An object that encapsulates the style data.\n *\n * @usageNotes\n * The following examples create animation styles that collect a set of\n * CSS property values:\n *\n * ```ts\n * // string values for CSS properties\n * style({ background: \"red\", color: \"blue\" })\n *\n * // numerical pixel values\n * style({ width: 100, height: 0 })\n * ```\n *\n * The following example uses auto-styling to allow an element to animate from\n * a height of 0 up to its full height:\n *\n * ```ts\n * style({ height: 0 }),\n * animate(\"1s\", style({ height: \"*\" }))\n * ```\n *\n * @publicApi\n **/\nfunction style(tokens) {\n return { type: AnimationMetadataType.Style, styles: tokens, offset: null };\n}\n/**\n * Declares an animation state within a trigger attached to an element.\n *\n * @param name One or more names for the defined state in a comma-separated string.\n * The following reserved state names can be supplied to define a style for specific use\n * cases:\n *\n * - `void` You can associate styles with this name to be used when\n * the element is detached from the application. For example, when an `ngIf` evaluates\n * to false, the state of the associated element is void.\n * - `*` (asterisk) Indicates the default state. You can associate styles with this name\n * to be used as the fallback when the state that is being animated is not declared\n * within the trigger.\n *\n * @param styles A set of CSS styles associated with this state, created using the\n * `style()` function.\n * This set of styles persists on the element once the state has been reached.\n * @param options Parameters that can be passed to the state when it is invoked.\n * 0 or more key-value pairs.\n * @return An object that encapsulates the new state data.\n *\n * @usageNotes\n * Use the `trigger()` function to register states to an animation trigger.\n * Use the `transition()` function to animate between states.\n * When a state is active within a component, its associated styles persist on the element,\n * even when the animation ends.\n *\n * @publicApi\n **/\nfunction state(name, styles, options) {\n return { type: AnimationMetadataType.State, name, styles, options };\n}\n/**\n * Defines a set of animation styles, associating each style with an optional `offset` value.\n *\n * @param steps A set of animation styles with optional offset data.\n * The optional `offset` value for a style specifies a percentage of the total animation\n * time at which that style is applied.\n * @returns An object that encapsulates the keyframes data.\n *\n * @usageNotes\n * Use with the `animate()` call. Instead of applying animations\n * from the current state\n * to the destination state, keyframes describe how each style entry is applied and at what point\n * within the animation arc.\n * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).\n *\n * ### Usage\n *\n * In the following example, the offset values describe\n * when each `backgroundColor` value is applied. The color is red at the start, and changes to\n * blue when 20% of the total time has elapsed.\n *\n * ```ts\n * // the provided offset values\n * animate(\"5s\", keyframes([\n * style({ backgroundColor: \"red\", offset: 0 }),\n * style({ backgroundColor: \"blue\", offset: 0.2 }),\n * style({ backgroundColor: \"orange\", offset: 0.3 }),\n * style({ backgroundColor: \"black\", offset: 1 })\n * ]))\n * ```\n *\n * If there are no `offset` values specified in the style entries, the offsets\n * are calculated automatically.\n *\n * ```ts\n * animate(\"5s\", keyframes([\n * style({ backgroundColor: \"red\" }) // offset = 0\n * style({ backgroundColor: \"blue\" }) // offset = 0.33\n * style({ backgroundColor: \"orange\" }) // offset = 0.66\n * style({ backgroundColor: \"black\" }) // offset = 1\n * ]))\n *```\n\n * @publicApi\n */\nfunction keyframes(steps) {\n return { type: AnimationMetadataType.Keyframes, steps };\n}\n/**\n * Declares an animation transition which is played when a certain specified condition is met.\n *\n * @param stateChangeExpr A string with a specific format or a function that specifies when the\n * animation transition should occur (see [State Change Expression](#state-change-expression)).\n *\n * @param steps One or more animation objects that represent the animation's instructions.\n *\n * @param options An options object that can be used to specify a delay for the animation or provide\n * custom parameters for it.\n *\n * @returns An object that encapsulates the transition data.\n *\n * @usageNotes\n *\n * ### State Change Expression\n *\n * The State Change Expression instructs Angular when to run the transition's animations, it can\n *either be\n * - a string with a specific syntax\n * - or a function that compares the previous and current state (value of the expression bound to\n * the element's trigger) and returns `true` if the transition should occur or `false` otherwise\n *\n * The string format can be:\n * - `fromState => toState`, which indicates that the transition's animations should occur then the\n * expression bound to the trigger's element goes from `fromState` to `toState`\n *\n * _Example:_\n * ```ts\n * transition('open => closed', animate('.5s ease-out', style({ height: 0 }) ))\n * ```\n *\n * - `fromState <=> toState`, which indicates that the transition's animations should occur then\n * the expression bound to the trigger's element goes from `fromState` to `toState` or vice versa\n *\n * _Example:_\n * ```ts\n * transition('enabled <=> disabled', animate('1s cubic-bezier(0.8,0.3,0,1)'))\n * ```\n *\n * - `:enter`/`:leave`, which indicates that the transition's animations should occur when the\n * element enters or exists the DOM\n *\n * _Example:_\n * ```ts\n * transition(':enter', [\n * style({ opacity: 0 }),\n * animate('500ms', style({ opacity: 1 }))\n * ])\n * ```\n *\n * - `:increment`/`:decrement`, which indicates that the transition's animations should occur when\n * the numerical expression bound to the trigger's element has increased in value or decreased\n *\n * _Example:_\n * ```ts\n * transition(':increment', query('@counter', animateChild()))\n * ```\n *\n * - a sequence of any of the above divided by commas, which indicates that transition's animations\n * should occur whenever one of the state change expressions matches\n *\n * _Example:_\n * ```ts\n * transition(':increment, * => enabled, :enter', animate('1s ease', keyframes([\n * style({ transform: 'scale(1)', offset: 0}),\n * style({ transform: 'scale(1.1)', offset: 0.7}),\n * style({ transform: 'scale(1)', offset: 1})\n * ]))),\n * ```\n *\n * Also note that in such context:\n * - `void` can be used to indicate the absence of the element\n * - asterisks can be used as wildcards that match any state\n * - (as a consequence of the above, `void => *` is equivalent to `:enter` and `* => void` is\n * equivalent to `:leave`)\n * - `true` and `false` also match expression values of `1` and `0` respectively (but do not match\n * _truthy_ and _falsy_ values)\n *\n *
    \n *\n * Be careful about entering end leaving elements as their transitions present a common\n * pitfall for developers.\n *\n * Note that when an element with a trigger enters the DOM its `:enter` transition always\n * gets executed, but its `:leave` transition will not be executed if the element is removed\n * alongside its parent (as it will be removed \"without warning\" before its transition has\n * a chance to be executed, the only way that such transition can occur is if the element\n * is exiting the DOM on its own).\n *\n *\n *
    \n *\n * ### Animating to a Final State\n *\n * If the final step in a transition is a call to `animate()` that uses a timing value\n * with no `style` data, that step is automatically considered the final animation arc,\n * for the element to reach the final state, in such case Angular automatically adds or removes\n * CSS styles to ensure that the element is in the correct final state.\n *\n *\n * ### Usage Examples\n *\n * - Transition animations applied based on\n * the trigger's expression value\n *\n * ```html\n *
    \n * ...\n *
    \n * ```\n *\n * ```ts\n * trigger(\"myAnimationTrigger\", [\n * ..., // states\n * transition(\"on => off, open => closed\", animate(500)),\n * transition(\"* <=> error\", query('.indicator', animateChild()))\n * ])\n * ```\n *\n * - Transition animations applied based on custom logic dependent\n * on the trigger's expression value and provided parameters\n *\n * ```html\n *
    \n * ...\n *
    \n * ```\n *\n * ```ts\n * trigger(\"myAnimationTrigger\", [\n * ..., // states\n * transition(\n * (fromState, toState, _element, params) =>\n * ['firststep', 'laststep'].includes(fromState.toLowerCase())\n * && toState === params?.['target'],\n * animate('1s')\n * )\n * ])\n * ```\n *\n * @publicApi\n **/\nfunction transition(stateChangeExpr, steps, options = null) {\n return { type: AnimationMetadataType.Transition, expr: stateChangeExpr, animation: steps, options };\n}\n/**\n * Produces a reusable animation that can be invoked in another animation or sequence,\n * by calling the `useAnimation()` function.\n *\n * @param steps One or more animation objects, as returned by the `animate()`\n * or `sequence()` function, that form a transformation from one state to another.\n * A sequence is used by default when you pass an array.\n * @param options An options object that can contain a delay value for the start of the\n * animation, and additional developer-defined parameters.\n * Provided values for additional parameters are used as defaults,\n * and override values can be passed to the caller on invocation.\n * @returns An object that encapsulates the animation data.\n *\n * @usageNotes\n * The following example defines a reusable animation, providing some default parameter\n * values.\n *\n * ```ts\n * var fadeAnimation = animation([\n * style({ opacity: '{{ start }}' }),\n * animate('{{ time }}',\n * style({ opacity: '{{ end }}'}))\n * ],\n * { params: { time: '1000ms', start: 0, end: 1 }});\n * ```\n *\n * The following invokes the defined animation with a call to `useAnimation()`,\n * passing in override parameter values.\n *\n * ```js\n * useAnimation(fadeAnimation, {\n * params: {\n * time: '2s',\n * start: 1,\n * end: 0\n * }\n * })\n * ```\n *\n * If any of the passed-in parameter values are missing from this call,\n * the default values are used. If one or more parameter values are missing before a step is\n * animated, `useAnimation()` throws an error.\n *\n * @publicApi\n */\nfunction animation(steps, options = null) {\n return { type: AnimationMetadataType.Reference, animation: steps, options };\n}\n/**\n * Executes a queried inner animation element within an animation sequence.\n *\n * @param options An options object that can contain a delay value for the start of the\n * animation, and additional override values for developer-defined parameters.\n * @return An object that encapsulates the child animation data.\n *\n * @usageNotes\n * Each time an animation is triggered in Angular, the parent animation\n * has priority and any child animations are blocked. In order\n * for a child animation to run, the parent animation must query each of the elements\n * containing child animations, and run them using this function.\n *\n * Note that this feature is designed to be used with `query()` and it will only work\n * with animations that are assigned using the Angular animation library. CSS keyframes\n * and transitions are not handled by this API.\n *\n * @publicApi\n */\nfunction animateChild(options = null) {\n return { type: AnimationMetadataType.AnimateChild, options };\n}\n/**\n * Starts a reusable animation that is created using the `animation()` function.\n *\n * @param animation The reusable animation to start.\n * @param options An options object that can contain a delay value for the start of\n * the animation, and additional override values for developer-defined parameters.\n * @return An object that contains the animation parameters.\n *\n * @publicApi\n */\nfunction useAnimation(animation, options = null) {\n return { type: AnimationMetadataType.AnimateRef, animation, options };\n}\n/**\n * Finds one or more inner elements within the current element that is\n * being animated within a sequence. Use with `animate()`.\n *\n * @param selector The element to query, or a set of elements that contain Angular-specific\n * characteristics, specified with one or more of the following tokens.\n * - `query(\":enter\")` or `query(\":leave\")` : Query for newly inserted/removed elements (not\n * all elements can be queried via these tokens, see\n * [Entering and Leaving Elements](#entering-and-leaving-elements))\n * - `query(\":animating\")` : Query all currently animating elements.\n * - `query(\"@triggerName\")` : Query elements that contain an animation trigger.\n * - `query(\"@*\")` : Query all elements that contain an animation triggers.\n * - `query(\":self\")` : Include the current element into the animation sequence.\n *\n * @param animation One or more animation steps to apply to the queried element or elements.\n * An array is treated as an animation sequence.\n * @param options An options object. Use the 'limit' field to limit the total number of\n * items to collect.\n * @return An object that encapsulates the query data.\n *\n * @usageNotes\n *\n * ### Multiple Tokens\n *\n * Tokens can be merged into a combined query selector string. For example:\n *\n * ```ts\n * query(':self, .record:enter, .record:leave, @subTrigger', [...])\n * ```\n *\n * The `query()` function collects multiple elements and works internally by using\n * `element.querySelectorAll`. Use the `limit` field of an options object to limit\n * the total number of items to be collected. For example:\n *\n * ```js\n * query('div', [\n * animate(...),\n * animate(...)\n * ], { limit: 1 })\n * ```\n *\n * By default, throws an error when zero items are found. Set the\n * `optional` flag to ignore this error. For example:\n *\n * ```js\n * query('.some-element-that-may-not-be-there', [\n * animate(...),\n * animate(...)\n * ], { optional: true })\n * ```\n *\n * ### Entering and Leaving Elements\n *\n * Not all elements can be queried via the `:enter` and `:leave` tokens, the only ones\n * that can are those that Angular assumes can enter/leave based on their own logic\n * (if their insertion/removal is simply a consequence of that of their parent they\n * should be queried via a different token in their parent's `:enter`/`:leave` transitions).\n *\n * The only elements Angular assumes can enter/leave based on their own logic (thus the only\n * ones that can be queried via the `:enter` and `:leave` tokens) are:\n * - Those inserted dynamically (via `ViewContainerRef`)\n * - Those that have a structural directive (which, under the hood, are a subset of the above ones)\n *\n *
    \n *\n * Note that elements will be successfully queried via `:enter`/`:leave` even if their\n * insertion/removal is not done manually via `ViewContainerRef`or caused by their structural\n * directive (e.g. they enter/exit alongside their parent).\n *\n *
    \n *\n *
    \n *\n * There is an exception to what previously mentioned, besides elements entering/leaving based on\n * their own logic, elements with an animation trigger can always be queried via `:leave` when\n * their parent is also leaving.\n *\n *
    \n *\n * ### Usage Example\n *\n * The following example queries for inner elements and animates them\n * individually using `animate()`.\n *\n * ```angular-ts\n * @Component({\n * selector: 'inner',\n * template: `\n *
    \n *

    Title

    \n *
    \n * Blah blah blah\n *
    \n *
    \n * `,\n * animations: [\n * trigger('queryAnimation', [\n * transition('* => goAnimate', [\n * // hide the inner elements\n * query('h1', style({ opacity: 0 })),\n * query('.content', style({ opacity: 0 })),\n *\n * // animate the inner elements in, one by one\n * query('h1', animate(1000, style({ opacity: 1 }))),\n * query('.content', animate(1000, style({ opacity: 1 }))),\n * ])\n * ])\n * ]\n * })\n * class Cmp {\n * exp = '';\n *\n * goAnimate() {\n * this.exp = 'goAnimate';\n * }\n * }\n * ```\n *\n * @publicApi\n */\nfunction query(selector, animation, options = null) {\n return { type: AnimationMetadataType.Query, selector, animation, options };\n}\n/**\n * Use within an animation `query()` call to issue a timing gap after\n * each queried item is animated.\n *\n * @param timings A delay value.\n * @param animation One ore more animation steps.\n * @returns An object that encapsulates the stagger data.\n *\n * @usageNotes\n * In the following example, a container element wraps a list of items stamped out\n * by an `ngFor`. The container element contains an animation trigger that will later be set\n * to query for each of the inner items.\n *\n * Each time items are added, the opacity fade-in animation runs,\n * and each removed item is faded out.\n * When either of these animations occur, the stagger effect is\n * applied after each item's animation is started.\n *\n * ```html\n * \n * \n *
    \n *
    \n *
    \n * {{ item }}\n *
    \n *
    \n * ```\n *\n * Here is the component code:\n *\n * ```ts\n * import {trigger, transition, style, animate, query, stagger} from '@angular/animations';\n * @Component({\n * templateUrl: 'list.component.html',\n * animations: [\n * trigger('listAnimation', [\n * ...\n * ])\n * ]\n * })\n * class ListComponent {\n * items = [];\n *\n * showItems() {\n * this.items = [0,1,2,3,4];\n * }\n *\n * hideItems() {\n * this.items = [];\n * }\n *\n * toggle() {\n * this.items.length ? this.hideItems() : this.showItems();\n * }\n * }\n * ```\n *\n * Here is the animation trigger code:\n *\n * ```ts\n * trigger('listAnimation', [\n * transition('* => *', [ // each time the binding value changes\n * query(':leave', [\n * stagger(100, [\n * animate('0.5s', style({ opacity: 0 }))\n * ])\n * ]),\n * query(':enter', [\n * style({ opacity: 0 }),\n * stagger(100, [\n * animate('0.5s', style({ opacity: 1 }))\n * ])\n * ])\n * ])\n * ])\n * ```\n *\n * @publicApi\n */\nfunction stagger(timings, animation) {\n return { type: AnimationMetadataType.Stagger, timings, animation };\n}\n\n/**\n * An injectable service that produces an animation sequence programmatically within an\n * Angular component or directive.\n * Provided by the `BrowserAnimationsModule` or `NoopAnimationsModule`.\n *\n * @usageNotes\n *\n * To use this service, add it to your component or directive as a dependency.\n * The service is instantiated along with your component.\n *\n * Apps do not typically need to create their own animation players, but if you\n * do need to, follow these steps:\n *\n * 1. Use the [AnimationBuilder.build](api/animations/AnimationBuilder#build)() method\n * to create a programmatic animation. The method returns an `AnimationFactory` instance.\n *\n * 2. Use the factory object to create an `AnimationPlayer` and attach it to a DOM element.\n *\n * 3. Use the player object to control the animation programmatically.\n *\n * For example:\n *\n * ```ts\n * // import the service from BrowserAnimationsModule\n * import {AnimationBuilder} from '@angular/animations';\n * // require the service as a dependency\n * class MyCmp {\n * constructor(private _builder: AnimationBuilder) {}\n *\n * makeAnimation(element: any) {\n * // first define a reusable animation\n * const myAnimation = this._builder.build([\n * style({ width: 0 }),\n * animate(1000, style({ width: '100px' }))\n * ]);\n *\n * // use the returned factory object to create a player\n * const player = myAnimation.create(element);\n *\n * player.play();\n * }\n * }\n * ```\n *\n * @publicApi\n */\nclass AnimationBuilder {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: AnimationBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: AnimationBuilder, providedIn: 'root', useFactory: () => inject(BrowserAnimationBuilder) });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: AnimationBuilder, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root', useFactory: () => inject(BrowserAnimationBuilder) }]\n }] });\n/**\n * A factory object returned from the\n * [AnimationBuilder.build](api/animations/AnimationBuilder#build)()\n * method.\n *\n * @publicApi\n */\nclass AnimationFactory {\n}\nclass BrowserAnimationBuilder extends AnimationBuilder {\n animationModuleType = inject(ANIMATION_MODULE_TYPE, { optional: true });\n _nextAnimationId = 0;\n _renderer;\n constructor(rootRenderer, doc) {\n super();\n const typeData = {\n id: '0',\n encapsulation: ViewEncapsulation.None,\n styles: [],\n data: { animation: [] },\n };\n this._renderer = rootRenderer.createRenderer(doc.body, typeData);\n if (this.animationModuleType === null && !isAnimationRenderer(this._renderer)) {\n // We only support AnimationRenderer & DynamicDelegationRenderer for this AnimationBuilder\n throw new ɵRuntimeError(3600 /* RuntimeErrorCode.BROWSER_ANIMATION_BUILDER_INJECTED_WITHOUT_ANIMATIONS */, (typeof ngDevMode === 'undefined' || ngDevMode) &&\n 'Angular detected that the `AnimationBuilder` was injected, but animation support was not enabled. ' +\n 'Please make sure that you enable animations in your application by calling `provideAnimations()` or `provideAnimationsAsync()` function.');\n }\n }\n build(animation) {\n const id = this._nextAnimationId;\n this._nextAnimationId++;\n const entry = Array.isArray(animation) ? sequence(animation) : animation;\n issueAnimationCommand(this._renderer, null, id, 'register', [entry]);\n return new BrowserAnimationFactory(id, this._renderer);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserAnimationBuilder, deps: [{ token: i0.RendererFactory2 }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserAnimationBuilder, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserAnimationBuilder, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [{ type: i0.RendererFactory2 }, { type: Document, decorators: [{\n type: Inject,\n args: [DOCUMENT]\n }] }] });\nclass BrowserAnimationFactory extends AnimationFactory {\n _id;\n _renderer;\n constructor(_id, _renderer) {\n super();\n this._id = _id;\n this._renderer = _renderer;\n }\n create(element, options) {\n return new RendererAnimationPlayer(this._id, element, options || {}, this._renderer);\n }\n}\nclass RendererAnimationPlayer {\n id;\n element;\n _renderer;\n parentPlayer = null;\n _started = false;\n constructor(id, element, options, _renderer) {\n this.id = id;\n this.element = element;\n this._renderer = _renderer;\n this._command('create', options);\n }\n _listen(eventName, callback) {\n return this._renderer.listen(this.element, `@@${this.id}:${eventName}`, callback);\n }\n _command(command, ...args) {\n issueAnimationCommand(this._renderer, this.element, this.id, command, args);\n }\n onDone(fn) {\n this._listen('done', fn);\n }\n onStart(fn) {\n this._listen('start', fn);\n }\n onDestroy(fn) {\n this._listen('destroy', fn);\n }\n init() {\n this._command('init');\n }\n hasStarted() {\n return this._started;\n }\n play() {\n this._command('play');\n this._started = true;\n }\n pause() {\n this._command('pause');\n }\n restart() {\n this._command('restart');\n }\n finish() {\n this._command('finish');\n }\n destroy() {\n this._command('destroy');\n }\n reset() {\n this._command('reset');\n this._started = false;\n }\n setPosition(p) {\n this._command('setPosition', p);\n }\n getPosition() {\n return unwrapAnimationRenderer(this._renderer)?.engine?.players[this.id]?.getPosition() ?? 0;\n }\n totalTime = 0;\n}\nfunction issueAnimationCommand(renderer, element, id, command, args) {\n renderer.setProperty(element, `@@${id}:${command}`, args);\n}\n/**\n * The following 2 methods cannot reference their correct types (AnimationRenderer &\n * DynamicDelegationRenderer) since this would introduce a import cycle.\n */\nfunction unwrapAnimationRenderer(renderer) {\n const type = renderer.ɵtype;\n if (type === 0 /* AnimationRendererType.Regular */) {\n return renderer;\n }\n else if (type === 1 /* AnimationRendererType.Delegated */) {\n return renderer.animationRenderer;\n }\n return null;\n}\nfunction isAnimationRenderer(renderer) {\n const type = renderer.ɵtype;\n return type === 0 /* AnimationRendererType.Regular */ || type === 1 /* AnimationRendererType.Delegated */;\n}\n\n/**\n * An empty programmatic controller for reusable animations.\n * Used internally when animations are disabled, to avoid\n * checking for the null case when an animation player is expected.\n *\n * @see {@link animate}\n * @see {@link AnimationPlayer}\n *\n * @publicApi\n */\nclass NoopAnimationPlayer {\n _onDoneFns = [];\n _onStartFns = [];\n _onDestroyFns = [];\n _originalOnDoneFns = [];\n _originalOnStartFns = [];\n _started = false;\n _destroyed = false;\n _finished = false;\n _position = 0;\n parentPlayer = null;\n totalTime;\n constructor(duration = 0, delay = 0) {\n this.totalTime = duration + delay;\n }\n _onFinish() {\n if (!this._finished) {\n this._finished = true;\n this._onDoneFns.forEach((fn) => fn());\n this._onDoneFns = [];\n }\n }\n onStart(fn) {\n this._originalOnStartFns.push(fn);\n this._onStartFns.push(fn);\n }\n onDone(fn) {\n this._originalOnDoneFns.push(fn);\n this._onDoneFns.push(fn);\n }\n onDestroy(fn) {\n this._onDestroyFns.push(fn);\n }\n hasStarted() {\n return this._started;\n }\n init() { }\n play() {\n if (!this.hasStarted()) {\n this._onStart();\n this.triggerMicrotask();\n }\n this._started = true;\n }\n /** @internal */\n triggerMicrotask() {\n queueMicrotask(() => this._onFinish());\n }\n _onStart() {\n this._onStartFns.forEach((fn) => fn());\n this._onStartFns = [];\n }\n pause() { }\n restart() { }\n finish() {\n this._onFinish();\n }\n destroy() {\n if (!this._destroyed) {\n this._destroyed = true;\n if (!this.hasStarted()) {\n this._onStart();\n }\n this.finish();\n this._onDestroyFns.forEach((fn) => fn());\n this._onDestroyFns = [];\n }\n }\n reset() {\n this._started = false;\n this._finished = false;\n this._onStartFns = this._originalOnStartFns;\n this._onDoneFns = this._originalOnDoneFns;\n }\n setPosition(position) {\n this._position = this.totalTime ? position * this.totalTime : 1;\n }\n getPosition() {\n return this.totalTime ? this._position / this.totalTime : 1;\n }\n /** @internal */\n triggerCallback(phaseName) {\n const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;\n methods.forEach((fn) => fn());\n methods.length = 0;\n }\n}\n\n/**\n * A programmatic controller for a group of reusable animations.\n * Used internally to control animations.\n *\n * @see {@link AnimationPlayer}\n * @see {@link animations/group group}\n *\n */\nclass AnimationGroupPlayer {\n _onDoneFns = [];\n _onStartFns = [];\n _finished = false;\n _started = false;\n _destroyed = false;\n _onDestroyFns = [];\n parentPlayer = null;\n totalTime = 0;\n players;\n constructor(_players) {\n this.players = _players;\n let doneCount = 0;\n let destroyCount = 0;\n let startCount = 0;\n const total = this.players.length;\n if (total == 0) {\n queueMicrotask(() => this._onFinish());\n }\n else {\n this.players.forEach((player) => {\n player.onDone(() => {\n if (++doneCount == total) {\n this._onFinish();\n }\n });\n player.onDestroy(() => {\n if (++destroyCount == total) {\n this._onDestroy();\n }\n });\n player.onStart(() => {\n if (++startCount == total) {\n this._onStart();\n }\n });\n });\n }\n this.totalTime = this.players.reduce((time, player) => Math.max(time, player.totalTime), 0);\n }\n _onFinish() {\n if (!this._finished) {\n this._finished = true;\n this._onDoneFns.forEach((fn) => fn());\n this._onDoneFns = [];\n }\n }\n init() {\n this.players.forEach((player) => player.init());\n }\n onStart(fn) {\n this._onStartFns.push(fn);\n }\n _onStart() {\n if (!this.hasStarted()) {\n this._started = true;\n this._onStartFns.forEach((fn) => fn());\n this._onStartFns = [];\n }\n }\n onDone(fn) {\n this._onDoneFns.push(fn);\n }\n onDestroy(fn) {\n this._onDestroyFns.push(fn);\n }\n hasStarted() {\n return this._started;\n }\n play() {\n if (!this.parentPlayer) {\n this.init();\n }\n this._onStart();\n this.players.forEach((player) => player.play());\n }\n pause() {\n this.players.forEach((player) => player.pause());\n }\n restart() {\n this.players.forEach((player) => player.restart());\n }\n finish() {\n this._onFinish();\n this.players.forEach((player) => player.finish());\n }\n destroy() {\n this._onDestroy();\n }\n _onDestroy() {\n if (!this._destroyed) {\n this._destroyed = true;\n this._onFinish();\n this.players.forEach((player) => player.destroy());\n this._onDestroyFns.forEach((fn) => fn());\n this._onDestroyFns = [];\n }\n }\n reset() {\n this.players.forEach((player) => player.reset());\n this._destroyed = false;\n this._finished = false;\n this._started = false;\n }\n setPosition(p) {\n const timeAtPosition = p * this.totalTime;\n this.players.forEach((player) => {\n const position = player.totalTime ? Math.min(1, timeAtPosition / player.totalTime) : 1;\n player.setPosition(position);\n });\n }\n getPosition() {\n const longestPlayer = this.players.reduce((longestSoFar, player) => {\n const newPlayerIsLongest = longestSoFar === null || player.totalTime > longestSoFar.totalTime;\n return newPlayerIsLongest ? player : longestSoFar;\n }, null);\n return longestPlayer != null ? longestPlayer.getPosition() : 0;\n }\n beforeDestroy() {\n this.players.forEach((player) => {\n if (player.beforeDestroy) {\n player.beforeDestroy();\n }\n });\n }\n /** @internal */\n triggerCallback(phaseName) {\n const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;\n methods.forEach((fn) => fn());\n methods.length = 0;\n }\n}\n\nconst ɵPRE_STYLE = '!';\n\n/**\n * @module\n * @description\n * Entry point for all animation APIs of the animation package.\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\n\n// This file is not used to build this module. It is only used during editing\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { AUTO_STYLE, AnimationBuilder, AnimationFactory, AnimationMetadataType, NoopAnimationPlayer, animate, animateChild, animation, group, keyframes, query, sequence, stagger, state, style, transition, trigger, useAnimation, AnimationGroupPlayer as ɵAnimationGroupPlayer, BrowserAnimationBuilder as ɵBrowserAnimationBuilder, ɵPRE_STYLE };\n","import { DOCUMENT } from '@angular/common';\nimport * as i0 from '@angular/core';\nimport { inject, APP_ID, Injectable, signal, QueryList, isSignal, effect, InjectionToken, afterNextRender, NgZone, Injector, ElementRef, booleanAttribute, Directive, Input, EventEmitter, Output, NgModule } from '@angular/core';\nimport { Platform, _getFocusedElementPierceShadowDom, normalizePassiveListenerOptions, _getEventTarget, _getShadowRoot } from '@angular/cdk/platform';\nimport { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from '@angular/cdk/private';\nimport { A, Z, ZERO, NINE, hasModifierKey, PAGE_DOWN, PAGE_UP, END, HOME, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW, TAB, ALT, CONTROL, MAC_META, META, SHIFT } from '@angular/cdk/keycodes';\nimport { Subject, Subscription, isObservable, of, BehaviorSubject } from 'rxjs';\nimport { tap, debounceTime, filter, map, take, skip, distinctUntilChanged, takeUntil } from 'rxjs/operators';\nimport { coerceObservable } from '@angular/cdk/coercion/private';\nimport { ContentObserver, ObserversModule } from '@angular/cdk/observers';\nimport { coerceElement } from '@angular/cdk/coercion';\nimport { BreakpointObserver } from '@angular/cdk/layout';\n\n/** IDs are delimited by an empty space, as per the spec. */\nconst ID_DELIMITER = ' ';\n/**\n * Adds the given ID to the specified ARIA attribute on an element.\n * Used for attributes such as aria-labelledby, aria-owns, etc.\n */\nfunction addAriaReferencedId(el, attr, id) {\n const ids = getAriaReferenceIds(el, attr);\n id = id.trim();\n if (ids.some(existingId => existingId.trim() === id)) {\n return;\n }\n ids.push(id);\n el.setAttribute(attr, ids.join(ID_DELIMITER));\n}\n/**\n * Removes the given ID from the specified ARIA attribute on an element.\n * Used for attributes such as aria-labelledby, aria-owns, etc.\n */\nfunction removeAriaReferencedId(el, attr, id) {\n const ids = getAriaReferenceIds(el, attr);\n id = id.trim();\n const filteredIds = ids.filter(val => val !== id);\n if (filteredIds.length) {\n el.setAttribute(attr, filteredIds.join(ID_DELIMITER));\n }\n else {\n el.removeAttribute(attr);\n }\n}\n/**\n * Gets the list of IDs referenced by the given ARIA attribute on an element.\n * Used for attributes such as aria-labelledby, aria-owns, etc.\n */\nfunction getAriaReferenceIds(el, attr) {\n // Get string array of all individual ids (whitespace delimited) in the attribute value\n const attrValue = el.getAttribute(attr);\n return attrValue?.match(/\\S+/g) ?? [];\n}\n\n/**\n * ID used for the body container where all messages are appended.\n * @deprecated No longer being used. To be removed.\n * @breaking-change 14.0.0\n */\nconst MESSAGES_CONTAINER_ID = 'cdk-describedby-message-container';\n/**\n * ID prefix used for each created message element.\n * @deprecated To be turned into a private variable.\n * @breaking-change 14.0.0\n */\nconst CDK_DESCRIBEDBY_ID_PREFIX = 'cdk-describedby-message';\n/**\n * Attribute given to each host element that is described by a message element.\n * @deprecated To be turned into a private variable.\n * @breaking-change 14.0.0\n */\nconst CDK_DESCRIBEDBY_HOST_ATTRIBUTE = 'cdk-describedby-host';\n/** Global incremental identifier for each registered message element. */\nlet nextId = 0;\n/**\n * Utility that creates visually hidden elements with a message content. Useful for elements that\n * want to use aria-describedby to further describe themselves without adding additional visual\n * content.\n */\nclass AriaDescriber {\n _platform = inject(Platform);\n _document = inject(DOCUMENT);\n /** Map of all registered message elements that have been placed into the document. */\n _messageRegistry = new Map();\n /** Container for all registered messages. */\n _messagesContainer = null;\n /** Unique ID for the service. */\n _id = `${nextId++}`;\n constructor() {\n inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);\n this._id = inject(APP_ID) + '-' + nextId++;\n }\n describe(hostElement, message, role) {\n if (!this._canBeDescribed(hostElement, message)) {\n return;\n }\n const key = getKey(message, role);\n if (typeof message !== 'string') {\n // We need to ensure that the element has an ID.\n setMessageId(message, this._id);\n this._messageRegistry.set(key, { messageElement: message, referenceCount: 0 });\n }\n else if (!this._messageRegistry.has(key)) {\n this._createMessageElement(message, role);\n }\n if (!this._isElementDescribedByMessage(hostElement, key)) {\n this._addMessageReference(hostElement, key);\n }\n }\n removeDescription(hostElement, message, role) {\n if (!message || !this._isElementNode(hostElement)) {\n return;\n }\n const key = getKey(message, role);\n if (this._isElementDescribedByMessage(hostElement, key)) {\n this._removeMessageReference(hostElement, key);\n }\n // If the message is a string, it means that it's one that we created for the\n // consumer so we can remove it safely, otherwise we should leave it in place.\n if (typeof message === 'string') {\n const registeredMessage = this._messageRegistry.get(key);\n if (registeredMessage && registeredMessage.referenceCount === 0) {\n this._deleteMessageElement(key);\n }\n }\n if (this._messagesContainer?.childNodes.length === 0) {\n this._messagesContainer.remove();\n this._messagesContainer = null;\n }\n }\n /** Unregisters all created message elements and removes the message container. */\n ngOnDestroy() {\n const describedElements = this._document.querySelectorAll(`[${CDK_DESCRIBEDBY_HOST_ATTRIBUTE}=\"${this._id}\"]`);\n for (let i = 0; i < describedElements.length; i++) {\n this._removeCdkDescribedByReferenceIds(describedElements[i]);\n describedElements[i].removeAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE);\n }\n this._messagesContainer?.remove();\n this._messagesContainer = null;\n this._messageRegistry.clear();\n }\n /**\n * Creates a new element in the visually hidden message container element with the message\n * as its content and adds it to the message registry.\n */\n _createMessageElement(message, role) {\n const messageElement = this._document.createElement('div');\n setMessageId(messageElement, this._id);\n messageElement.textContent = message;\n if (role) {\n messageElement.setAttribute('role', role);\n }\n this._createMessagesContainer();\n this._messagesContainer.appendChild(messageElement);\n this._messageRegistry.set(getKey(message, role), { messageElement, referenceCount: 0 });\n }\n /** Deletes the message element from the global messages container. */\n _deleteMessageElement(key) {\n this._messageRegistry.get(key)?.messageElement?.remove();\n this._messageRegistry.delete(key);\n }\n /** Creates the global container for all aria-describedby messages. */\n _createMessagesContainer() {\n if (this._messagesContainer) {\n return;\n }\n const containerClassName = 'cdk-describedby-message-container';\n const serverContainers = this._document.querySelectorAll(`.${containerClassName}[platform=\"server\"]`);\n for (let i = 0; i < serverContainers.length; i++) {\n // When going from the server to the client, we may end up in a situation where there's\n // already a container on the page, but we don't have a reference to it. Clear the\n // old container so we don't get duplicates. Doing this, instead of emptying the previous\n // container, should be slightly faster.\n serverContainers[i].remove();\n }\n const messagesContainer = this._document.createElement('div');\n // We add `visibility: hidden` in order to prevent text in this container from\n // being searchable by the browser's Ctrl + F functionality.\n // Screen-readers will still read the description for elements with aria-describedby even\n // when the description element is not visible.\n messagesContainer.style.visibility = 'hidden';\n // Even though we use `visibility: hidden`, we still apply `cdk-visually-hidden` so that\n // the description element doesn't impact page layout.\n messagesContainer.classList.add(containerClassName);\n messagesContainer.classList.add('cdk-visually-hidden');\n if (!this._platform.isBrowser) {\n messagesContainer.setAttribute('platform', 'server');\n }\n this._document.body.appendChild(messagesContainer);\n this._messagesContainer = messagesContainer;\n }\n /** Removes all cdk-describedby messages that are hosted through the element. */\n _removeCdkDescribedByReferenceIds(element) {\n // Remove all aria-describedby reference IDs that are prefixed by CDK_DESCRIBEDBY_ID_PREFIX\n const originalReferenceIds = getAriaReferenceIds(element, 'aria-describedby').filter(id => id.indexOf(CDK_DESCRIBEDBY_ID_PREFIX) != 0);\n element.setAttribute('aria-describedby', originalReferenceIds.join(' '));\n }\n /**\n * Adds a message reference to the element using aria-describedby and increments the registered\n * message's reference count.\n */\n _addMessageReference(element, key) {\n const registeredMessage = this._messageRegistry.get(key);\n // Add the aria-describedby reference and set the\n // describedby_host attribute to mark the element.\n addAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);\n element.setAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE, this._id);\n registeredMessage.referenceCount++;\n }\n /**\n * Removes a message reference from the element using aria-describedby\n * and decrements the registered message's reference count.\n */\n _removeMessageReference(element, key) {\n const registeredMessage = this._messageRegistry.get(key);\n registeredMessage.referenceCount--;\n removeAriaReferencedId(element, 'aria-describedby', registeredMessage.messageElement.id);\n element.removeAttribute(CDK_DESCRIBEDBY_HOST_ATTRIBUTE);\n }\n /** Returns true if the element has been described by the provided message ID. */\n _isElementDescribedByMessage(element, key) {\n const referenceIds = getAriaReferenceIds(element, 'aria-describedby');\n const registeredMessage = this._messageRegistry.get(key);\n const messageId = registeredMessage && registeredMessage.messageElement.id;\n return !!messageId && referenceIds.indexOf(messageId) != -1;\n }\n /** Determines whether a message can be described on a particular element. */\n _canBeDescribed(element, message) {\n if (!this._isElementNode(element)) {\n return false;\n }\n if (message && typeof message === 'object') {\n // We'd have to make some assumptions about the description element's text, if the consumer\n // passed in an element. Assume that if an element is passed in, the consumer has verified\n // that it can be used as a description.\n return true;\n }\n const trimmedMessage = message == null ? '' : `${message}`.trim();\n const ariaLabel = element.getAttribute('aria-label');\n // We shouldn't set descriptions if they're exactly the same as the `aria-label` of the\n // element, because screen readers will end up reading out the same text twice in a row.\n return trimmedMessage ? !ariaLabel || ariaLabel.trim() !== trimmedMessage : false;\n }\n /** Checks whether a node is an Element node. */\n _isElementNode(element) {\n return element.nodeType === this._document.ELEMENT_NODE;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: AriaDescriber, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: AriaDescriber, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: AriaDescriber, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/** Gets a key that can be used to look messages up in the registry. */\nfunction getKey(message, role) {\n return typeof message === 'string' ? `${role || ''}/${message}` : message;\n}\n/** Assigns a unique ID to an element, if it doesn't have one already. */\nfunction setMessageId(element, serviceId) {\n if (!element.id) {\n element.id = `${CDK_DESCRIBEDBY_ID_PREFIX}-${serviceId}-${nextId++}`;\n }\n}\n\nconst DEFAULT_TYPEAHEAD_DEBOUNCE_INTERVAL_MS = 200;\n/**\n * Selects items based on keyboard inputs. Implements the typeahead functionality of\n * `role=\"listbox\"` or `role=\"tree\"` and other related roles.\n */\nclass Typeahead {\n _letterKeyStream = new Subject();\n _items = [];\n _selectedItemIndex = -1;\n /** Buffer for the letters that the user has pressed */\n _pressedLetters = [];\n _skipPredicateFn;\n _selectedItem = new Subject();\n selectedItem = this._selectedItem;\n constructor(initialItems, config) {\n const typeAheadInterval = typeof config?.debounceInterval === 'number'\n ? config.debounceInterval\n : DEFAULT_TYPEAHEAD_DEBOUNCE_INTERVAL_MS;\n if (config?.skipPredicate) {\n this._skipPredicateFn = config.skipPredicate;\n }\n if ((typeof ngDevMode === 'undefined' || ngDevMode) &&\n initialItems.length &&\n initialItems.some(item => typeof item.getLabel !== 'function')) {\n throw new Error('KeyManager items in typeahead mode must implement the `getLabel` method.');\n }\n this.setItems(initialItems);\n this._setupKeyHandler(typeAheadInterval);\n }\n destroy() {\n this._pressedLetters = [];\n this._letterKeyStream.complete();\n this._selectedItem.complete();\n }\n setCurrentSelectedItemIndex(index) {\n this._selectedItemIndex = index;\n }\n setItems(items) {\n this._items = items;\n }\n handleKey(event) {\n const keyCode = event.keyCode;\n // Attempt to use the `event.key` which also maps it to the user's keyboard language,\n // otherwise fall back to resolving alphanumeric characters via the keyCode.\n if (event.key && event.key.length === 1) {\n this._letterKeyStream.next(event.key.toLocaleUpperCase());\n }\n else if ((keyCode >= A && keyCode <= Z) || (keyCode >= ZERO && keyCode <= NINE)) {\n this._letterKeyStream.next(String.fromCharCode(keyCode));\n }\n }\n /** Gets whether the user is currently typing into the manager using the typeahead feature. */\n isTyping() {\n return this._pressedLetters.length > 0;\n }\n /** Resets the currently stored sequence of typed letters. */\n reset() {\n this._pressedLetters = [];\n }\n _setupKeyHandler(typeAheadInterval) {\n // Debounce the presses of non-navigational keys, collect the ones that correspond to letters\n // and convert those letters back into a string. Afterwards find the first item that starts\n // with that string and select it.\n this._letterKeyStream\n .pipe(tap(letter => this._pressedLetters.push(letter)), debounceTime(typeAheadInterval), filter(() => this._pressedLetters.length > 0), map(() => this._pressedLetters.join('').toLocaleUpperCase()))\n .subscribe(inputString => {\n // Start at 1 because we want to start searching at the item immediately\n // following the current active item.\n for (let i = 1; i < this._items.length + 1; i++) {\n const index = (this._selectedItemIndex + i) % this._items.length;\n const item = this._items[index];\n if (!this._skipPredicateFn?.(item) &&\n item.getLabel?.().toLocaleUpperCase().trim().indexOf(inputString) === 0) {\n this._selectedItem.next(item);\n break;\n }\n }\n this._pressedLetters = [];\n });\n }\n}\n\n/**\n * This class manages keyboard events for selectable lists. If you pass it a query list\n * of items, it will set the active item correctly when arrow events occur.\n */\nclass ListKeyManager {\n _items;\n _activeItemIndex = -1;\n _activeItem = signal(null);\n _wrap = false;\n _typeaheadSubscription = Subscription.EMPTY;\n _itemChangesSubscription;\n _vertical = true;\n _horizontal;\n _allowedModifierKeys = [];\n _homeAndEnd = false;\n _pageUpAndDown = { enabled: false, delta: 10 };\n _effectRef;\n _typeahead;\n /**\n * Predicate function that can be used to check whether an item should be skipped\n * by the key manager. By default, disabled items are skipped.\n */\n _skipPredicateFn = (item) => item.disabled;\n constructor(_items, injector) {\n this._items = _items;\n // We allow for the items to be an array because, in some cases, the consumer may\n // not have access to a QueryList of the items they want to manage (e.g. when the\n // items aren't being collected via `ViewChildren` or `ContentChildren`).\n if (_items instanceof QueryList) {\n this._itemChangesSubscription = _items.changes.subscribe((newItems) => this._itemsChanged(newItems.toArray()));\n }\n else if (isSignal(_items)) {\n if (!injector && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw new Error('ListKeyManager constructed with a signal must receive an injector');\n }\n this._effectRef = effect(() => this._itemsChanged(_items()), { injector });\n }\n }\n /**\n * Stream that emits any time the TAB key is pressed, so components can react\n * when focus is shifted off of the list.\n */\n tabOut = new Subject();\n /** Stream that emits whenever the active item of the list manager changes. */\n change = new Subject();\n /**\n * Sets the predicate function that determines which items should be skipped by the\n * list key manager.\n * @param predicate Function that determines whether the given item should be skipped.\n */\n skipPredicate(predicate) {\n this._skipPredicateFn = predicate;\n return this;\n }\n /**\n * Configures wrapping mode, which determines whether the active item will wrap to\n * the other end of list when there are no more items in the given direction.\n * @param shouldWrap Whether the list should wrap when reaching the end.\n */\n withWrap(shouldWrap = true) {\n this._wrap = shouldWrap;\n return this;\n }\n /**\n * Configures whether the key manager should be able to move the selection vertically.\n * @param enabled Whether vertical selection should be enabled.\n */\n withVerticalOrientation(enabled = true) {\n this._vertical = enabled;\n return this;\n }\n /**\n * Configures the key manager to move the selection horizontally.\n * Passing in `null` will disable horizontal movement.\n * @param direction Direction in which the selection can be moved.\n */\n withHorizontalOrientation(direction) {\n this._horizontal = direction;\n return this;\n }\n /**\n * Modifier keys which are allowed to be held down and whose default actions will be prevented\n * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.\n */\n withAllowedModifierKeys(keys) {\n this._allowedModifierKeys = keys;\n return this;\n }\n /**\n * Turns on typeahead mode which allows users to set the active item by typing.\n * @param debounceInterval Time to wait after the last keystroke before setting the active item.\n */\n withTypeAhead(debounceInterval = 200) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const items = this._getItemsArray();\n if (items.length > 0 && items.some(item => typeof item.getLabel !== 'function')) {\n throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');\n }\n }\n this._typeaheadSubscription.unsubscribe();\n const items = this._getItemsArray();\n this._typeahead = new Typeahead(items, {\n debounceInterval: typeof debounceInterval === 'number' ? debounceInterval : undefined,\n skipPredicate: item => this._skipPredicateFn(item),\n });\n this._typeaheadSubscription = this._typeahead.selectedItem.subscribe(item => {\n this.setActiveItem(item);\n });\n return this;\n }\n /** Cancels the current typeahead sequence. */\n cancelTypeahead() {\n this._typeahead?.reset();\n return this;\n }\n /**\n * Configures the key manager to activate the first and last items\n * respectively when the Home or End key is pressed.\n * @param enabled Whether pressing the Home or End key activates the first/last item.\n */\n withHomeAndEnd(enabled = true) {\n this._homeAndEnd = enabled;\n return this;\n }\n /**\n * Configures the key manager to activate every 10th, configured or first/last element in up/down direction\n * respectively when the Page-Up or Page-Down key is pressed.\n * @param enabled Whether pressing the Page-Up or Page-Down key activates the first/last item.\n * @param delta Whether pressing the Home or End key activates the first/last item.\n */\n withPageUpDown(enabled = true, delta = 10) {\n this._pageUpAndDown = { enabled, delta };\n return this;\n }\n setActiveItem(item) {\n const previousActiveItem = this._activeItem();\n this.updateActiveItem(item);\n if (this._activeItem() !== previousActiveItem) {\n this.change.next(this._activeItemIndex);\n }\n }\n /**\n * Sets the active item depending on the key event passed in.\n * @param event Keyboard event to be used for determining which element should be active.\n */\n onKeydown(event) {\n const keyCode = event.keyCode;\n const modifiers = ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'];\n const isModifierAllowed = modifiers.every(modifier => {\n return !event[modifier] || this._allowedModifierKeys.indexOf(modifier) > -1;\n });\n switch (keyCode) {\n case TAB:\n this.tabOut.next();\n return;\n case DOWN_ARROW:\n if (this._vertical && isModifierAllowed) {\n this.setNextItemActive();\n break;\n }\n else {\n return;\n }\n case UP_ARROW:\n if (this._vertical && isModifierAllowed) {\n this.setPreviousItemActive();\n break;\n }\n else {\n return;\n }\n case RIGHT_ARROW:\n if (this._horizontal && isModifierAllowed) {\n this._horizontal === 'rtl' ? this.setPreviousItemActive() : this.setNextItemActive();\n break;\n }\n else {\n return;\n }\n case LEFT_ARROW:\n if (this._horizontal && isModifierAllowed) {\n this._horizontal === 'rtl' ? this.setNextItemActive() : this.setPreviousItemActive();\n break;\n }\n else {\n return;\n }\n case HOME:\n if (this._homeAndEnd && isModifierAllowed) {\n this.setFirstItemActive();\n break;\n }\n else {\n return;\n }\n case END:\n if (this._homeAndEnd && isModifierAllowed) {\n this.setLastItemActive();\n break;\n }\n else {\n return;\n }\n case PAGE_UP:\n if (this._pageUpAndDown.enabled && isModifierAllowed) {\n const targetIndex = this._activeItemIndex - this._pageUpAndDown.delta;\n this._setActiveItemByIndex(targetIndex > 0 ? targetIndex : 0, 1);\n break;\n }\n else {\n return;\n }\n case PAGE_DOWN:\n if (this._pageUpAndDown.enabled && isModifierAllowed) {\n const targetIndex = this._activeItemIndex + this._pageUpAndDown.delta;\n const itemsLength = this._getItemsArray().length;\n this._setActiveItemByIndex(targetIndex < itemsLength ? targetIndex : itemsLength - 1, -1);\n break;\n }\n else {\n return;\n }\n default:\n if (isModifierAllowed || hasModifierKey(event, 'shiftKey')) {\n this._typeahead?.handleKey(event);\n }\n // Note that we return here, in order to avoid preventing\n // the default action of non-navigational keys.\n return;\n }\n this._typeahead?.reset();\n event.preventDefault();\n }\n /** Index of the currently active item. */\n get activeItemIndex() {\n return this._activeItemIndex;\n }\n /** The active item. */\n get activeItem() {\n return this._activeItem();\n }\n /** Gets whether the user is currently typing into the manager using the typeahead feature. */\n isTyping() {\n return !!this._typeahead && this._typeahead.isTyping();\n }\n /** Sets the active item to the first enabled item in the list. */\n setFirstItemActive() {\n this._setActiveItemByIndex(0, 1);\n }\n /** Sets the active item to the last enabled item in the list. */\n setLastItemActive() {\n this._setActiveItemByIndex(this._getItemsArray().length - 1, -1);\n }\n /** Sets the active item to the next enabled item in the list. */\n setNextItemActive() {\n this._activeItemIndex < 0 ? this.setFirstItemActive() : this._setActiveItemByDelta(1);\n }\n /** Sets the active item to a previous enabled item in the list. */\n setPreviousItemActive() {\n this._activeItemIndex < 0 && this._wrap\n ? this.setLastItemActive()\n : this._setActiveItemByDelta(-1);\n }\n updateActiveItem(item) {\n const itemArray = this._getItemsArray();\n const index = typeof item === 'number' ? item : itemArray.indexOf(item);\n const activeItem = itemArray[index];\n // Explicitly check for `null` and `undefined` because other falsy values are valid.\n this._activeItem.set(activeItem == null ? null : activeItem);\n this._activeItemIndex = index;\n this._typeahead?.setCurrentSelectedItemIndex(index);\n }\n /** Cleans up the key manager. */\n destroy() {\n this._typeaheadSubscription.unsubscribe();\n this._itemChangesSubscription?.unsubscribe();\n this._effectRef?.destroy();\n this._typeahead?.destroy();\n this.tabOut.complete();\n this.change.complete();\n }\n /**\n * This method sets the active item, given a list of items and the delta between the\n * currently active item and the new active item. It will calculate differently\n * depending on whether wrap mode is turned on.\n */\n _setActiveItemByDelta(delta) {\n this._wrap ? this._setActiveInWrapMode(delta) : this._setActiveInDefaultMode(delta);\n }\n /**\n * Sets the active item properly given \"wrap\" mode. In other words, it will continue to move\n * down the list until it finds an item that is not disabled, and it will wrap if it\n * encounters either end of the list.\n */\n _setActiveInWrapMode(delta) {\n const items = this._getItemsArray();\n for (let i = 1; i <= items.length; i++) {\n const index = (this._activeItemIndex + delta * i + items.length) % items.length;\n const item = items[index];\n if (!this._skipPredicateFn(item)) {\n this.setActiveItem(index);\n return;\n }\n }\n }\n /**\n * Sets the active item properly given the default mode. In other words, it will\n * continue to move down the list until it finds an item that is not disabled. If\n * it encounters either end of the list, it will stop and not wrap.\n */\n _setActiveInDefaultMode(delta) {\n this._setActiveItemByIndex(this._activeItemIndex + delta, delta);\n }\n /**\n * Sets the active item to the first enabled item starting at the index specified. If the\n * item is disabled, it will move in the fallbackDelta direction until it either\n * finds an enabled item or encounters the end of the list.\n */\n _setActiveItemByIndex(index, fallbackDelta) {\n const items = this._getItemsArray();\n if (!items[index]) {\n return;\n }\n while (this._skipPredicateFn(items[index])) {\n index += fallbackDelta;\n if (!items[index]) {\n return;\n }\n }\n this.setActiveItem(index);\n }\n /** Returns the items as an array. */\n _getItemsArray() {\n if (isSignal(this._items)) {\n return this._items();\n }\n return this._items instanceof QueryList ? this._items.toArray() : this._items;\n }\n /** Callback for when the items have changed. */\n _itemsChanged(newItems) {\n this._typeahead?.setItems(newItems);\n const activeItem = this._activeItem();\n if (activeItem) {\n const newIndex = newItems.indexOf(activeItem);\n if (newIndex > -1 && newIndex !== this._activeItemIndex) {\n this._activeItemIndex = newIndex;\n this._typeahead?.setCurrentSelectedItemIndex(newIndex);\n }\n }\n }\n}\n\nclass ActiveDescendantKeyManager extends ListKeyManager {\n setActiveItem(index) {\n if (this.activeItem) {\n this.activeItem.setInactiveStyles();\n }\n super.setActiveItem(index);\n if (this.activeItem) {\n this.activeItem.setActiveStyles();\n }\n }\n}\n\nclass FocusKeyManager extends ListKeyManager {\n _origin = 'program';\n /**\n * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.\n * @param origin Focus origin to be used when focusing items.\n */\n setFocusOrigin(origin) {\n this._origin = origin;\n return this;\n }\n setActiveItem(item) {\n super.setActiveItem(item);\n if (this.activeItem) {\n this.activeItem.focus(this._origin);\n }\n }\n}\n\n/**\n * This class manages keyboard events for trees. If you pass it a QueryList or other list of tree\n * items, it will set the active item, focus, handle expansion and typeahead correctly when\n * keyboard events occur.\n */\nclass TreeKeyManager {\n /** The index of the currently active (focused) item. */\n _activeItemIndex = -1;\n /** The currently active (focused) item. */\n _activeItem = null;\n /** Whether or not we activate the item when it's focused. */\n _shouldActivationFollowFocus = false;\n /**\n * The orientation that the tree is laid out in. In `rtl` mode, the behavior of Left and\n * Right arrow are switched.\n */\n _horizontalOrientation = 'ltr';\n /**\n * Predicate function that can be used to check whether an item should be skipped\n * by the key manager.\n *\n * The default value for this doesn't skip any elements in order to keep tree items focusable\n * when disabled. This aligns with ARIA guidelines:\n * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols.\n */\n _skipPredicateFn = (_item) => false;\n /** Function to determine equivalent items. */\n _trackByFn = (item) => item;\n /** Synchronous cache of the items to manage. */\n _items = [];\n _typeahead;\n _typeaheadSubscription = Subscription.EMPTY;\n _hasInitialFocused = false;\n _initializeFocus() {\n if (this._hasInitialFocused || this._items.length === 0) {\n return;\n }\n let activeIndex = 0;\n for (let i = 0; i < this._items.length; i++) {\n if (!this._skipPredicateFn(this._items[i]) && !this._isItemDisabled(this._items[i])) {\n activeIndex = i;\n break;\n }\n }\n const activeItem = this._items[activeIndex];\n // Use `makeFocusable` here, because we want the item to just be focusable, not actually\n // capture the focus since the user isn't interacting with it. See #29628.\n if (activeItem.makeFocusable) {\n this._activeItem?.unfocus();\n this._activeItemIndex = activeIndex;\n this._activeItem = activeItem;\n this._typeahead?.setCurrentSelectedItemIndex(activeIndex);\n activeItem.makeFocusable();\n }\n else {\n // Backwards compatibility for items that don't implement `makeFocusable`.\n this.focusItem(activeIndex);\n }\n this._hasInitialFocused = true;\n }\n /**\n *\n * @param items List of TreeKeyManager options. Can be synchronous or asynchronous.\n * @param config Optional configuration options. By default, use 'ltr' horizontal orientation. By\n * default, do not skip any nodes. By default, key manager only calls `focus` method when items\n * are focused and does not call `activate`. If `typeaheadDefaultInterval` is `true`, use a\n * default interval of 200ms.\n */\n constructor(items, config) {\n // We allow for the items to be an array or Observable because, in some cases, the consumer may\n // not have access to a QueryList of the items they want to manage (e.g. when the\n // items aren't being collected via `ViewChildren` or `ContentChildren`).\n if (items instanceof QueryList) {\n this._items = items.toArray();\n items.changes.subscribe((newItems) => {\n this._items = newItems.toArray();\n this._typeahead?.setItems(this._items);\n this._updateActiveItemIndex(this._items);\n this._initializeFocus();\n });\n }\n else if (isObservable(items)) {\n items.subscribe(newItems => {\n this._items = newItems;\n this._typeahead?.setItems(newItems);\n this._updateActiveItemIndex(newItems);\n this._initializeFocus();\n });\n }\n else {\n this._items = items;\n this._initializeFocus();\n }\n if (typeof config.shouldActivationFollowFocus === 'boolean') {\n this._shouldActivationFollowFocus = config.shouldActivationFollowFocus;\n }\n if (config.horizontalOrientation) {\n this._horizontalOrientation = config.horizontalOrientation;\n }\n if (config.skipPredicate) {\n this._skipPredicateFn = config.skipPredicate;\n }\n if (config.trackBy) {\n this._trackByFn = config.trackBy;\n }\n if (typeof config.typeAheadDebounceInterval !== 'undefined') {\n this._setTypeAhead(config.typeAheadDebounceInterval);\n }\n }\n /** Stream that emits any time the focused item changes. */\n change = new Subject();\n /** Cleans up the key manager. */\n destroy() {\n this._typeaheadSubscription.unsubscribe();\n this._typeahead?.destroy();\n this.change.complete();\n }\n /**\n * Handles a keyboard event on the tree.\n * @param event Keyboard event that represents the user interaction with the tree.\n */\n onKeydown(event) {\n const key = event.key;\n switch (key) {\n case 'Tab':\n // Return early here, in order to allow Tab to actually tab out of the tree\n return;\n case 'ArrowDown':\n this._focusNextItem();\n break;\n case 'ArrowUp':\n this._focusPreviousItem();\n break;\n case 'ArrowRight':\n this._horizontalOrientation === 'rtl'\n ? this._collapseCurrentItem()\n : this._expandCurrentItem();\n break;\n case 'ArrowLeft':\n this._horizontalOrientation === 'rtl'\n ? this._expandCurrentItem()\n : this._collapseCurrentItem();\n break;\n case 'Home':\n this._focusFirstItem();\n break;\n case 'End':\n this._focusLastItem();\n break;\n case 'Enter':\n case ' ':\n this._activateCurrentItem();\n break;\n default:\n if (event.key === '*') {\n this._expandAllItemsAtCurrentItemLevel();\n break;\n }\n this._typeahead?.handleKey(event);\n // Return here, in order to avoid preventing the default action of non-navigational\n // keys or resetting the buffer of pressed letters.\n return;\n }\n // Reset the typeahead since the user has used a navigational key.\n this._typeahead?.reset();\n event.preventDefault();\n }\n /** Index of the currently active item. */\n getActiveItemIndex() {\n return this._activeItemIndex;\n }\n /** The currently active item. */\n getActiveItem() {\n return this._activeItem;\n }\n /** Focus the first available item. */\n _focusFirstItem() {\n this.focusItem(this._findNextAvailableItemIndex(-1));\n }\n /** Focus the last available item. */\n _focusLastItem() {\n this.focusItem(this._findPreviousAvailableItemIndex(this._items.length));\n }\n /** Focus the next available item. */\n _focusNextItem() {\n this.focusItem(this._findNextAvailableItemIndex(this._activeItemIndex));\n }\n /** Focus the previous available item. */\n _focusPreviousItem() {\n this.focusItem(this._findPreviousAvailableItemIndex(this._activeItemIndex));\n }\n focusItem(itemOrIndex, options = {}) {\n // Set default options\n options.emitChangeEvent ??= true;\n let index = typeof itemOrIndex === 'number'\n ? itemOrIndex\n : this._items.findIndex(item => this._trackByFn(item) === this._trackByFn(itemOrIndex));\n if (index < 0 || index >= this._items.length) {\n return;\n }\n const activeItem = this._items[index];\n // If we're just setting the same item, don't re-call activate or focus\n if (this._activeItem !== null &&\n this._trackByFn(activeItem) === this._trackByFn(this._activeItem)) {\n return;\n }\n const previousActiveItem = this._activeItem;\n this._activeItem = activeItem ?? null;\n this._activeItemIndex = index;\n this._typeahead?.setCurrentSelectedItemIndex(index);\n this._activeItem?.focus();\n previousActiveItem?.unfocus();\n if (options.emitChangeEvent) {\n this.change.next(this._activeItem);\n }\n if (this._shouldActivationFollowFocus) {\n this._activateCurrentItem();\n }\n }\n _updateActiveItemIndex(newItems) {\n const activeItem = this._activeItem;\n if (!activeItem) {\n return;\n }\n const newIndex = newItems.findIndex(item => this._trackByFn(item) === this._trackByFn(activeItem));\n if (newIndex > -1 && newIndex !== this._activeItemIndex) {\n this._activeItemIndex = newIndex;\n this._typeahead?.setCurrentSelectedItemIndex(newIndex);\n }\n }\n _setTypeAhead(debounceInterval) {\n this._typeahead = new Typeahead(this._items, {\n debounceInterval: typeof debounceInterval === 'number' ? debounceInterval : undefined,\n skipPredicate: item => this._skipPredicateFn(item),\n });\n this._typeaheadSubscription = this._typeahead.selectedItem.subscribe(item => {\n this.focusItem(item);\n });\n }\n _findNextAvailableItemIndex(startingIndex) {\n for (let i = startingIndex + 1; i < this._items.length; i++) {\n if (!this._skipPredicateFn(this._items[i])) {\n return i;\n }\n }\n return startingIndex;\n }\n _findPreviousAvailableItemIndex(startingIndex) {\n for (let i = startingIndex - 1; i >= 0; i--) {\n if (!this._skipPredicateFn(this._items[i])) {\n return i;\n }\n }\n return startingIndex;\n }\n /**\n * If the item is already expanded, we collapse the item. Otherwise, we will focus the parent.\n */\n _collapseCurrentItem() {\n if (!this._activeItem) {\n return;\n }\n if (this._isCurrentItemExpanded()) {\n this._activeItem.collapse();\n }\n else {\n const parent = this._activeItem.getParent();\n if (!parent || this._skipPredicateFn(parent)) {\n return;\n }\n this.focusItem(parent);\n }\n }\n /**\n * If the item is already collapsed, we expand the item. Otherwise, we will focus the first child.\n */\n _expandCurrentItem() {\n if (!this._activeItem) {\n return;\n }\n if (!this._isCurrentItemExpanded()) {\n this._activeItem.expand();\n }\n else {\n coerceObservable(this._activeItem.getChildren())\n .pipe(take(1))\n .subscribe(children => {\n const firstChild = children.find(child => !this._skipPredicateFn(child));\n if (!firstChild) {\n return;\n }\n this.focusItem(firstChild);\n });\n }\n }\n _isCurrentItemExpanded() {\n if (!this._activeItem) {\n return false;\n }\n return typeof this._activeItem.isExpanded === 'boolean'\n ? this._activeItem.isExpanded\n : this._activeItem.isExpanded();\n }\n _isItemDisabled(item) {\n return typeof item.isDisabled === 'boolean' ? item.isDisabled : item.isDisabled?.();\n }\n /** For all items that are the same level as the current item, we expand those items. */\n _expandAllItemsAtCurrentItemLevel() {\n if (!this._activeItem) {\n return;\n }\n const parent = this._activeItem.getParent();\n let itemsToExpand;\n if (!parent) {\n itemsToExpand = of(this._items.filter(item => item.getParent() === null));\n }\n else {\n itemsToExpand = coerceObservable(parent.getChildren());\n }\n itemsToExpand.pipe(take(1)).subscribe(items => {\n for (const item of items) {\n item.expand();\n }\n });\n }\n _activateCurrentItem() {\n this._activeItem?.activate();\n }\n}\n/** @docs-private */\nfunction TREE_KEY_MANAGER_FACTORY() {\n return (items, options) => new TreeKeyManager(items, options);\n}\n/** Injection token that determines the key manager to use. */\nconst TREE_KEY_MANAGER = new InjectionToken('tree-key-manager', {\n providedIn: 'root',\n factory: TREE_KEY_MANAGER_FACTORY,\n});\n/** @docs-private */\nconst TREE_KEY_MANAGER_FACTORY_PROVIDER = {\n provide: TREE_KEY_MANAGER,\n useFactory: TREE_KEY_MANAGER_FACTORY,\n};\n\n// NoopTreeKeyManager is a \"noop\" implementation of TreeKeyMangerStrategy. Methods are noops. Does\n// not emit to streams.\n//\n// Used for applications built before TreeKeyManager to opt-out of TreeKeyManager and revert to\n// legacy behavior.\n/**\n * @docs-private\n *\n * Opt-out of Tree of key manager behavior.\n *\n * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.\n * - Tree does not respond to keyboard interaction\n * - Tree node allows tabindex to be set by Input binding\n * - Tree node allows tabindex to be set by attribute binding\n *\n * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a\n * TreeKeyManagerStrategy instead. To be removed in a future version.\n *\n * @breaking-change 21.0.0\n */\nclass NoopTreeKeyManager {\n _isNoopTreeKeyManager = true;\n // Provide change as required by TreeKeyManagerStrategy. NoopTreeKeyManager is a \"noop\"\n // implementation that does not emit to streams.\n change = new Subject();\n destroy() {\n this.change.complete();\n }\n onKeydown() {\n // noop\n }\n getActiveItemIndex() {\n // Always return null. NoopTreeKeyManager is a \"noop\" implementation that does not maintain\n // the active item.\n return null;\n }\n getActiveItem() {\n // Always return null. NoopTreeKeyManager is a \"noop\" implementation that does not maintain\n // the active item.\n return null;\n }\n focusItem() {\n // noop\n }\n}\n/**\n * @docs-private\n *\n * Opt-out of Tree of key manager behavior.\n *\n * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.\n * - Tree does not respond to keyboard interaction\n * - Tree node allows tabindex to be set by Input binding\n * - Tree node allows tabindex to be set by attribute binding\n *\n * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a\n * TreeKeyManagerStrategy instead. To be removed in a future version.\n *\n * @breaking-change 21.0.0\n */\nfunction NOOP_TREE_KEY_MANAGER_FACTORY() {\n return () => new NoopTreeKeyManager();\n}\n/**\n * @docs-private\n *\n * Opt-out of Tree of key manager behavior.\n *\n * When provided, Tree has same focus management behavior as before TreeKeyManager was introduced.\n * - Tree does not respond to keyboard interaction\n * - Tree node allows tabindex to be set by Input binding\n * - Tree node allows tabindex to be set by attribute binding\n *\n * @deprecated NoopTreeKeyManager deprecated. Use TreeKeyManager or inject a\n * TreeKeyManagerStrategy instead. To be removed in a future version.\n *\n * @breaking-change 21.0.0\n */\nconst NOOP_TREE_KEY_MANAGER_FACTORY_PROVIDER = {\n provide: TREE_KEY_MANAGER,\n useFactory: NOOP_TREE_KEY_MANAGER_FACTORY,\n};\n\n/**\n * Configuration for the isFocusable method.\n */\nclass IsFocusableConfig {\n /**\n * Whether to count an element as focusable even if it is not currently visible.\n */\n ignoreVisibility = false;\n}\n// The InteractivityChecker leans heavily on the ally.js accessibility utilities.\n// Methods like `isTabbable` are only covering specific edge-cases for the browsers which are\n// supported.\n/**\n * Utility for checking the interactivity of an element, such as whether it is focusable or\n * tabbable.\n */\nclass InteractivityChecker {\n _platform = inject(Platform);\n constructor() { }\n /**\n * Gets whether an element is disabled.\n *\n * @param element Element to be checked.\n * @returns Whether the element is disabled.\n */\n isDisabled(element) {\n // This does not capture some cases, such as a non-form control with a disabled attribute or\n // a form control inside of a disabled form, but should capture the most common cases.\n return element.hasAttribute('disabled');\n }\n /**\n * Gets whether an element is visible for the purposes of interactivity.\n *\n * This will capture states like `display: none` and `visibility: hidden`, but not things like\n * being clipped by an `overflow: hidden` parent or being outside the viewport.\n *\n * @returns Whether the element is visible.\n */\n isVisible(element) {\n return hasGeometry(element) && getComputedStyle(element).visibility === 'visible';\n }\n /**\n * Gets whether an element can be reached via Tab key.\n * Assumes that the element has already been checked with isFocusable.\n *\n * @param element Element to be checked.\n * @returns Whether the element is tabbable.\n */\n isTabbable(element) {\n // Nothing is tabbable on the server 😎\n if (!this._platform.isBrowser) {\n return false;\n }\n const frameElement = getFrameElement(getWindow(element));\n if (frameElement) {\n // Frame elements inherit their tabindex onto all child elements.\n if (getTabIndexValue(frameElement) === -1) {\n return false;\n }\n // Browsers disable tabbing to an element inside of an invisible frame.\n if (!this.isVisible(frameElement)) {\n return false;\n }\n }\n let nodeName = element.nodeName.toLowerCase();\n let tabIndexValue = getTabIndexValue(element);\n if (element.hasAttribute('contenteditable')) {\n return tabIndexValue !== -1;\n }\n if (nodeName === 'iframe' || nodeName === 'object') {\n // The frame or object's content may be tabbable depending on the content, but it's\n // not possibly to reliably detect the content of the frames. We always consider such\n // elements as non-tabbable.\n return false;\n }\n // In iOS, the browser only considers some specific elements as tabbable.\n if (this._platform.WEBKIT && this._platform.IOS && !isPotentiallyTabbableIOS(element)) {\n return false;\n }\n if (nodeName === 'audio') {\n // Audio elements without controls enabled are never tabbable, regardless\n // of the tabindex attribute explicitly being set.\n if (!element.hasAttribute('controls')) {\n return false;\n }\n // Audio elements with controls are by default tabbable unless the\n // tabindex attribute is set to `-1` explicitly.\n return tabIndexValue !== -1;\n }\n if (nodeName === 'video') {\n // For all video elements, if the tabindex attribute is set to `-1`, the video\n // is not tabbable. Note: We cannot rely on the default `HTMLElement.tabIndex`\n // property as that one is set to `-1` in Chrome, Edge and Safari v13.1. The\n // tabindex attribute is the source of truth here.\n if (tabIndexValue === -1) {\n return false;\n }\n // If the tabindex is explicitly set, and not `-1` (as per check before), the\n // video element is always tabbable (regardless of whether it has controls or not).\n if (tabIndexValue !== null) {\n return true;\n }\n // Otherwise (when no explicit tabindex is set), a video is only tabbable if it\n // has controls enabled. Firefox is special as videos are always tabbable regardless\n // of whether there are controls or not.\n return this._platform.FIREFOX || element.hasAttribute('controls');\n }\n return element.tabIndex >= 0;\n }\n /**\n * Gets whether an element can be focused by the user.\n *\n * @param element Element to be checked.\n * @param config The config object with options to customize this method's behavior\n * @returns Whether the element is focusable.\n */\n isFocusable(element, config) {\n // Perform checks in order of left to most expensive.\n // Again, naive approach that does not capture many edge cases and browser quirks.\n return (isPotentiallyFocusable(element) &&\n !this.isDisabled(element) &&\n (config?.ignoreVisibility || this.isVisible(element)));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: InteractivityChecker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: InteractivityChecker, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: InteractivityChecker, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/**\n * Returns the frame element from a window object. Since browsers like MS Edge throw errors if\n * the frameElement property is being accessed from a different host address, this property\n * should be accessed carefully.\n */\nfunction getFrameElement(window) {\n try {\n return window.frameElement;\n }\n catch {\n return null;\n }\n}\n/** Checks whether the specified element has any geometry / rectangles. */\nfunction hasGeometry(element) {\n // Use logic from jQuery to check for an invisible element.\n // See https://github.com/jquery/jquery/blob/master/src/css/hiddenVisibleSelectors.js#L12\n return !!(element.offsetWidth ||\n element.offsetHeight ||\n (typeof element.getClientRects === 'function' && element.getClientRects().length));\n}\n/** Gets whether an element's */\nfunction isNativeFormElement(element) {\n let nodeName = element.nodeName.toLowerCase();\n return (nodeName === 'input' ||\n nodeName === 'select' ||\n nodeName === 'button' ||\n nodeName === 'textarea');\n}\n/** Gets whether an element is an ``. */\nfunction isHiddenInput(element) {\n return isInputElement(element) && element.type == 'hidden';\n}\n/** Gets whether an element is an anchor that has an href attribute. */\nfunction isAnchorWithHref(element) {\n return isAnchorElement(element) && element.hasAttribute('href');\n}\n/** Gets whether an element is an input element. */\nfunction isInputElement(element) {\n return element.nodeName.toLowerCase() == 'input';\n}\n/** Gets whether an element is an anchor element. */\nfunction isAnchorElement(element) {\n return element.nodeName.toLowerCase() == 'a';\n}\n/** Gets whether an element has a valid tabindex. */\nfunction hasValidTabIndex(element) {\n if (!element.hasAttribute('tabindex') || element.tabIndex === undefined) {\n return false;\n }\n let tabIndex = element.getAttribute('tabindex');\n return !!(tabIndex && !isNaN(parseInt(tabIndex, 10)));\n}\n/**\n * Returns the parsed tabindex from the element attributes instead of returning the\n * evaluated tabindex from the browsers defaults.\n */\nfunction getTabIndexValue(element) {\n if (!hasValidTabIndex(element)) {\n return null;\n }\n // See browser issue in Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054\n const tabIndex = parseInt(element.getAttribute('tabindex') || '', 10);\n return isNaN(tabIndex) ? -1 : tabIndex;\n}\n/** Checks whether the specified element is potentially tabbable on iOS */\nfunction isPotentiallyTabbableIOS(element) {\n let nodeName = element.nodeName.toLowerCase();\n let inputType = nodeName === 'input' && element.type;\n return (inputType === 'text' ||\n inputType === 'password' ||\n nodeName === 'select' ||\n nodeName === 'textarea');\n}\n/**\n * Gets whether an element is potentially focusable without taking current visible/disabled state\n * into account.\n */\nfunction isPotentiallyFocusable(element) {\n // Inputs are potentially focusable *unless* they're type=\"hidden\".\n if (isHiddenInput(element)) {\n return false;\n }\n return (isNativeFormElement(element) ||\n isAnchorWithHref(element) ||\n element.hasAttribute('contenteditable') ||\n hasValidTabIndex(element));\n}\n/** Gets the parent window of a DOM node with regards of being inside of an iframe. */\nfunction getWindow(node) {\n // ownerDocument is null if `node` itself *is* a document.\n return (node.ownerDocument && node.ownerDocument.defaultView) || window;\n}\n\n/**\n * Class that allows for trapping focus within a DOM element.\n *\n * This class currently uses a relatively simple approach to focus trapping.\n * It assumes that the tab order is the same as DOM order, which is not necessarily true.\n * Things like `tabIndex > 0`, flex `order`, and shadow roots can cause the two to be misaligned.\n */\nclass FocusTrap {\n _element;\n _checker;\n _ngZone;\n _document;\n _injector;\n _startAnchor;\n _endAnchor;\n _hasAttached = false;\n // Event listeners for the anchors. Need to be regular functions so that we can unbind them later.\n startAnchorListener = () => this.focusLastTabbableElement();\n endAnchorListener = () => this.focusFirstTabbableElement();\n /** Whether the focus trap is active. */\n get enabled() {\n return this._enabled;\n }\n set enabled(value) {\n this._enabled = value;\n if (this._startAnchor && this._endAnchor) {\n this._toggleAnchorTabIndex(value, this._startAnchor);\n this._toggleAnchorTabIndex(value, this._endAnchor);\n }\n }\n _enabled = true;\n constructor(_element, _checker, _ngZone, _document, deferAnchors = false, \n /** @breaking-change 20.0.0 param to become required */\n _injector) {\n this._element = _element;\n this._checker = _checker;\n this._ngZone = _ngZone;\n this._document = _document;\n this._injector = _injector;\n if (!deferAnchors) {\n this.attachAnchors();\n }\n }\n /** Destroys the focus trap by cleaning up the anchors. */\n destroy() {\n const startAnchor = this._startAnchor;\n const endAnchor = this._endAnchor;\n if (startAnchor) {\n startAnchor.removeEventListener('focus', this.startAnchorListener);\n startAnchor.remove();\n }\n if (endAnchor) {\n endAnchor.removeEventListener('focus', this.endAnchorListener);\n endAnchor.remove();\n }\n this._startAnchor = this._endAnchor = null;\n this._hasAttached = false;\n }\n /**\n * Inserts the anchors into the DOM. This is usually done automatically\n * in the constructor, but can be deferred for cases like directives with `*ngIf`.\n * @returns Whether the focus trap managed to attach successfully. This may not be the case\n * if the target element isn't currently in the DOM.\n */\n attachAnchors() {\n // If we're not on the browser, there can be no focus to trap.\n if (this._hasAttached) {\n return true;\n }\n this._ngZone.runOutsideAngular(() => {\n if (!this._startAnchor) {\n this._startAnchor = this._createAnchor();\n this._startAnchor.addEventListener('focus', this.startAnchorListener);\n }\n if (!this._endAnchor) {\n this._endAnchor = this._createAnchor();\n this._endAnchor.addEventListener('focus', this.endAnchorListener);\n }\n });\n if (this._element.parentNode) {\n this._element.parentNode.insertBefore(this._startAnchor, this._element);\n this._element.parentNode.insertBefore(this._endAnchor, this._element.nextSibling);\n this._hasAttached = true;\n }\n return this._hasAttached;\n }\n /**\n * Waits for the zone to stabilize, then focuses the first tabbable element.\n * @returns Returns a promise that resolves with a boolean, depending\n * on whether focus was moved successfully.\n */\n focusInitialElementWhenReady(options) {\n return new Promise(resolve => {\n this._executeOnStable(() => resolve(this.focusInitialElement(options)));\n });\n }\n /**\n * Waits for the zone to stabilize, then focuses\n * the first tabbable element within the focus trap region.\n * @returns Returns a promise that resolves with a boolean, depending\n * on whether focus was moved successfully.\n */\n focusFirstTabbableElementWhenReady(options) {\n return new Promise(resolve => {\n this._executeOnStable(() => resolve(this.focusFirstTabbableElement(options)));\n });\n }\n /**\n * Waits for the zone to stabilize, then focuses\n * the last tabbable element within the focus trap region.\n * @returns Returns a promise that resolves with a boolean, depending\n * on whether focus was moved successfully.\n */\n focusLastTabbableElementWhenReady(options) {\n return new Promise(resolve => {\n this._executeOnStable(() => resolve(this.focusLastTabbableElement(options)));\n });\n }\n /**\n * Get the specified boundary element of the trapped region.\n * @param bound The boundary to get (start or end of trapped region).\n * @returns The boundary element.\n */\n _getRegionBoundary(bound) {\n // Contains the deprecated version of selector, for temporary backwards comparability.\n const markers = this._element.querySelectorAll(`[cdk-focus-region-${bound}], ` + `[cdkFocusRegion${bound}], ` + `[cdk-focus-${bound}]`);\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n for (let i = 0; i < markers.length; i++) {\n // @breaking-change 8.0.0\n if (markers[i].hasAttribute(`cdk-focus-${bound}`)) {\n console.warn(`Found use of deprecated attribute 'cdk-focus-${bound}', ` +\n `use 'cdkFocusRegion${bound}' instead. The deprecated ` +\n `attribute will be removed in 8.0.0.`, markers[i]);\n }\n else if (markers[i].hasAttribute(`cdk-focus-region-${bound}`)) {\n console.warn(`Found use of deprecated attribute 'cdk-focus-region-${bound}', ` +\n `use 'cdkFocusRegion${bound}' instead. The deprecated attribute ` +\n `will be removed in 8.0.0.`, markers[i]);\n }\n }\n }\n if (bound == 'start') {\n return markers.length ? markers[0] : this._getFirstTabbableElement(this._element);\n }\n return markers.length\n ? markers[markers.length - 1]\n : this._getLastTabbableElement(this._element);\n }\n /**\n * Focuses the element that should be focused when the focus trap is initialized.\n * @returns Whether focus was moved successfully.\n */\n focusInitialElement(options) {\n // Contains the deprecated version of selector, for temporary backwards comparability.\n const redirectToElement = this._element.querySelector(`[cdk-focus-initial], ` + `[cdkFocusInitial]`);\n if (redirectToElement) {\n // @breaking-change 8.0.0\n if ((typeof ngDevMode === 'undefined' || ngDevMode) &&\n redirectToElement.hasAttribute(`cdk-focus-initial`)) {\n console.warn(`Found use of deprecated attribute 'cdk-focus-initial', ` +\n `use 'cdkFocusInitial' instead. The deprecated attribute ` +\n `will be removed in 8.0.0`, redirectToElement);\n }\n // Warn the consumer if the element they've pointed to\n // isn't focusable, when not in production mode.\n if ((typeof ngDevMode === 'undefined' || ngDevMode) &&\n !this._checker.isFocusable(redirectToElement)) {\n console.warn(`Element matching '[cdkFocusInitial]' is not focusable.`, redirectToElement);\n }\n if (!this._checker.isFocusable(redirectToElement)) {\n const focusableChild = this._getFirstTabbableElement(redirectToElement);\n focusableChild?.focus(options);\n return !!focusableChild;\n }\n redirectToElement.focus(options);\n return true;\n }\n return this.focusFirstTabbableElement(options);\n }\n /**\n * Focuses the first tabbable element within the focus trap region.\n * @returns Whether focus was moved successfully.\n */\n focusFirstTabbableElement(options) {\n const redirectToElement = this._getRegionBoundary('start');\n if (redirectToElement) {\n redirectToElement.focus(options);\n }\n return !!redirectToElement;\n }\n /**\n * Focuses the last tabbable element within the focus trap region.\n * @returns Whether focus was moved successfully.\n */\n focusLastTabbableElement(options) {\n const redirectToElement = this._getRegionBoundary('end');\n if (redirectToElement) {\n redirectToElement.focus(options);\n }\n return !!redirectToElement;\n }\n /**\n * Checks whether the focus trap has successfully been attached.\n */\n hasAttached() {\n return this._hasAttached;\n }\n /** Get the first tabbable element from a DOM subtree (inclusive). */\n _getFirstTabbableElement(root) {\n if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {\n return root;\n }\n const children = root.children;\n for (let i = 0; i < children.length; i++) {\n const tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE\n ? this._getFirstTabbableElement(children[i])\n : null;\n if (tabbableChild) {\n return tabbableChild;\n }\n }\n return null;\n }\n /** Get the last tabbable element from a DOM subtree (inclusive). */\n _getLastTabbableElement(root) {\n if (this._checker.isFocusable(root) && this._checker.isTabbable(root)) {\n return root;\n }\n // Iterate in reverse DOM order.\n const children = root.children;\n for (let i = children.length - 1; i >= 0; i--) {\n const tabbableChild = children[i].nodeType === this._document.ELEMENT_NODE\n ? this._getLastTabbableElement(children[i])\n : null;\n if (tabbableChild) {\n return tabbableChild;\n }\n }\n return null;\n }\n /** Creates an anchor element. */\n _createAnchor() {\n const anchor = this._document.createElement('div');\n this._toggleAnchorTabIndex(this._enabled, anchor);\n anchor.classList.add('cdk-visually-hidden');\n anchor.classList.add('cdk-focus-trap-anchor');\n anchor.setAttribute('aria-hidden', 'true');\n return anchor;\n }\n /**\n * Toggles the `tabindex` of an anchor, based on the enabled state of the focus trap.\n * @param isEnabled Whether the focus trap is enabled.\n * @param anchor Anchor on which to toggle the tabindex.\n */\n _toggleAnchorTabIndex(isEnabled, anchor) {\n // Remove the tabindex completely, rather than setting it to -1, because if the\n // element has a tabindex, the user might still hit it when navigating with the arrow keys.\n isEnabled ? anchor.setAttribute('tabindex', '0') : anchor.removeAttribute('tabindex');\n }\n /**\n * Toggles the`tabindex` of both anchors to either trap Tab focus or allow it to escape.\n * @param enabled: Whether the anchors should trap Tab.\n */\n toggleAnchors(enabled) {\n if (this._startAnchor && this._endAnchor) {\n this._toggleAnchorTabIndex(enabled, this._startAnchor);\n this._toggleAnchorTabIndex(enabled, this._endAnchor);\n }\n }\n /** Executes a function when the zone is stable. */\n _executeOnStable(fn) {\n // TODO: remove this conditional when injector is required in the constructor.\n if (this._injector) {\n afterNextRender(fn, { injector: this._injector });\n }\n else {\n setTimeout(fn);\n }\n }\n}\n/**\n * Factory that allows easy instantiation of focus traps.\n */\nclass FocusTrapFactory {\n _checker = inject(InteractivityChecker);\n _ngZone = inject(NgZone);\n _document = inject(DOCUMENT);\n _injector = inject(Injector);\n constructor() {\n inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);\n }\n /**\n * Creates a focus-trapped region around the given element.\n * @param element The element around which focus will be trapped.\n * @param deferCaptureElements Defers the creation of focus-capturing elements to be done\n * manually by the user.\n * @returns The created focus trap instance.\n */\n create(element, deferCaptureElements = false) {\n return new FocusTrap(element, this._checker, this._ngZone, this._document, deferCaptureElements, this._injector);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusTrapFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusTrapFactory, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusTrapFactory, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/** Directive for trapping focus within a region. */\nclass CdkTrapFocus {\n _elementRef = inject(ElementRef);\n _focusTrapFactory = inject(FocusTrapFactory);\n /** Underlying FocusTrap instance. */\n focusTrap;\n /** Previously focused element to restore focus to upon destroy when using autoCapture. */\n _previouslyFocusedElement = null;\n /** Whether the focus trap is active. */\n get enabled() {\n return this.focusTrap?.enabled || false;\n }\n set enabled(value) {\n if (this.focusTrap) {\n this.focusTrap.enabled = value;\n }\n }\n /**\n * Whether the directive should automatically move focus into the trapped region upon\n * initialization and return focus to the previous activeElement upon destruction.\n */\n autoCapture;\n constructor() {\n const platform = inject(Platform);\n if (platform.isBrowser) {\n this.focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement, true);\n }\n }\n ngOnDestroy() {\n this.focusTrap?.destroy();\n // If we stored a previously focused element when using autoCapture, return focus to that\n // element now that the trapped region is being destroyed.\n if (this._previouslyFocusedElement) {\n this._previouslyFocusedElement.focus();\n this._previouslyFocusedElement = null;\n }\n }\n ngAfterContentInit() {\n this.focusTrap?.attachAnchors();\n if (this.autoCapture) {\n this._captureFocus();\n }\n }\n ngDoCheck() {\n if (this.focusTrap && !this.focusTrap.hasAttached()) {\n this.focusTrap.attachAnchors();\n }\n }\n ngOnChanges(changes) {\n const autoCaptureChange = changes['autoCapture'];\n if (autoCaptureChange &&\n !autoCaptureChange.firstChange &&\n this.autoCapture &&\n this.focusTrap?.hasAttached()) {\n this._captureFocus();\n }\n }\n _captureFocus() {\n this._previouslyFocusedElement = _getFocusedElementPierceShadowDom();\n this.focusTrap?.focusInitialElementWhenReady();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkTrapFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkTrapFocus, isStandalone: true, selector: \"[cdkTrapFocus]\", inputs: { enabled: [\"cdkTrapFocus\", \"enabled\", booleanAttribute], autoCapture: [\"cdkTrapFocusAutoCapture\", \"autoCapture\", booleanAttribute] }, exportAs: [\"cdkTrapFocus\"], usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkTrapFocus, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkTrapFocus]',\n exportAs: 'cdkTrapFocus',\n }]\n }], ctorParameters: () => [], propDecorators: { enabled: [{\n type: Input,\n args: [{ alias: 'cdkTrapFocus', transform: booleanAttribute }]\n }], autoCapture: [{\n type: Input,\n args: [{ alias: 'cdkTrapFocusAutoCapture', transform: booleanAttribute }]\n }] } });\n\n/**\n * Class that allows for trapping focus within a DOM element.\n *\n * This class uses a strategy pattern that determines how it traps focus.\n * See FocusTrapInertStrategy.\n */\nclass ConfigurableFocusTrap extends FocusTrap {\n _focusTrapManager;\n _inertStrategy;\n /** Whether the FocusTrap is enabled. */\n get enabled() {\n return this._enabled;\n }\n set enabled(value) {\n this._enabled = value;\n if (this._enabled) {\n this._focusTrapManager.register(this);\n }\n else {\n this._focusTrapManager.deregister(this);\n }\n }\n constructor(_element, _checker, _ngZone, _document, _focusTrapManager, _inertStrategy, config, injector) {\n super(_element, _checker, _ngZone, _document, config.defer, injector);\n this._focusTrapManager = _focusTrapManager;\n this._inertStrategy = _inertStrategy;\n this._focusTrapManager.register(this);\n }\n /** Notifies the FocusTrapManager that this FocusTrap will be destroyed. */\n destroy() {\n this._focusTrapManager.deregister(this);\n super.destroy();\n }\n /** @docs-private Implemented as part of ManagedFocusTrap. */\n _enable() {\n this._inertStrategy.preventFocus(this);\n this.toggleAnchors(true);\n }\n /** @docs-private Implemented as part of ManagedFocusTrap. */\n _disable() {\n this._inertStrategy.allowFocus(this);\n this.toggleAnchors(false);\n }\n}\n\n/**\n * Lightweight FocusTrapInertStrategy that adds a document focus event\n * listener to redirect focus back inside the FocusTrap.\n */\nclass EventListenerFocusTrapInertStrategy {\n /** Focus event handler. */\n _listener = null;\n /** Adds a document event listener that keeps focus inside the FocusTrap. */\n preventFocus(focusTrap) {\n // Ensure there's only one listener per document\n if (this._listener) {\n focusTrap._document.removeEventListener('focus', this._listener, true);\n }\n this._listener = (e) => this._trapFocus(focusTrap, e);\n focusTrap._ngZone.runOutsideAngular(() => {\n focusTrap._document.addEventListener('focus', this._listener, true);\n });\n }\n /** Removes the event listener added in preventFocus. */\n allowFocus(focusTrap) {\n if (!this._listener) {\n return;\n }\n focusTrap._document.removeEventListener('focus', this._listener, true);\n this._listener = null;\n }\n /**\n * Refocuses the first element in the FocusTrap if the focus event target was outside\n * the FocusTrap.\n *\n * This is an event listener callback. The event listener is added in runOutsideAngular,\n * so all this code runs outside Angular as well.\n */\n _trapFocus(focusTrap, event) {\n const target = event.target;\n const focusTrapRoot = focusTrap._element;\n // Don't refocus if target was in an overlay, because the overlay might be associated\n // with an element inside the FocusTrap, ex. mat-select.\n if (target && !focusTrapRoot.contains(target) && !target.closest?.('div.cdk-overlay-pane')) {\n // Some legacy FocusTrap usages have logic that focuses some element on the page\n // just before FocusTrap is destroyed. For backwards compatibility, wait\n // to be sure FocusTrap is still enabled before refocusing.\n setTimeout(() => {\n // Check whether focus wasn't put back into the focus trap while the timeout was pending.\n if (focusTrap.enabled && !focusTrapRoot.contains(focusTrap._document.activeElement)) {\n focusTrap.focusFirstTabbableElement();\n }\n });\n }\n }\n}\n\n/** The injection token used to specify the inert strategy. */\nconst FOCUS_TRAP_INERT_STRATEGY = new InjectionToken('FOCUS_TRAP_INERT_STRATEGY');\n\n/** Injectable that ensures only the most recently enabled FocusTrap is active. */\nclass FocusTrapManager {\n // A stack of the FocusTraps on the page. Only the FocusTrap at the\n // top of the stack is active.\n _focusTrapStack = [];\n /**\n * Disables the FocusTrap at the top of the stack, and then pushes\n * the new FocusTrap onto the stack.\n */\n register(focusTrap) {\n // Dedupe focusTraps that register multiple times.\n this._focusTrapStack = this._focusTrapStack.filter(ft => ft !== focusTrap);\n let stack = this._focusTrapStack;\n if (stack.length) {\n stack[stack.length - 1]._disable();\n }\n stack.push(focusTrap);\n focusTrap._enable();\n }\n /**\n * Removes the FocusTrap from the stack, and activates the\n * FocusTrap that is the new top of the stack.\n */\n deregister(focusTrap) {\n focusTrap._disable();\n const stack = this._focusTrapStack;\n const i = stack.indexOf(focusTrap);\n if (i !== -1) {\n stack.splice(i, 1);\n if (stack.length) {\n stack[stack.length - 1]._enable();\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusTrapManager, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusTrapManager, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusTrapManager, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n\n/** Factory that allows easy instantiation of configurable focus traps. */\nclass ConfigurableFocusTrapFactory {\n _checker = inject(InteractivityChecker);\n _ngZone = inject(NgZone);\n _focusTrapManager = inject(FocusTrapManager);\n _document = inject(DOCUMENT);\n _inertStrategy;\n _injector = inject(Injector);\n constructor() {\n const inertStrategy = inject(FOCUS_TRAP_INERT_STRATEGY, { optional: true });\n // TODO split up the strategies into different modules, similar to DateAdapter.\n this._inertStrategy = inertStrategy || new EventListenerFocusTrapInertStrategy();\n }\n create(element, config = { defer: false }) {\n let configObject;\n if (typeof config === 'boolean') {\n configObject = { defer: config };\n }\n else {\n configObject = config;\n }\n return new ConfigurableFocusTrap(element, this._checker, this._ngZone, this._document, this._focusTrapManager, this._inertStrategy, configObject, this._injector);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ConfigurableFocusTrapFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ConfigurableFocusTrapFactory, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ConfigurableFocusTrapFactory, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/** Gets whether an event could be a faked `mousedown` event dispatched by a screen reader. */\nfunction isFakeMousedownFromScreenReader(event) {\n // Some screen readers will dispatch a fake `mousedown` event when pressing enter or space on\n // a clickable element. We can distinguish these events when `event.buttons` is zero, or\n // `event.detail` is zero depending on the browser:\n // - `event.buttons` works on Firefox, but fails on Chrome.\n // - `detail` works on Chrome, but fails on Firefox.\n return event.buttons === 0 || event.detail === 0;\n}\n/** Gets whether an event could be a faked `touchstart` event dispatched by a screen reader. */\nfunction isFakeTouchstartFromScreenReader(event) {\n const touch = (event.touches && event.touches[0]) || (event.changedTouches && event.changedTouches[0]);\n // A fake `touchstart` can be distinguished from a real one by looking at the `identifier`\n // which is typically >= 0 on a real device versus -1 from a screen reader. Just to be safe,\n // we can also look at `radiusX` and `radiusY`. This behavior was observed against a Windows 10\n // device with a touch screen running NVDA v2020.4 and Firefox 85 or Chrome 88.\n return (!!touch &&\n touch.identifier === -1 &&\n (touch.radiusX == null || touch.radiusX === 1) &&\n (touch.radiusY == null || touch.radiusY === 1));\n}\n\n/**\n * Injectable options for the InputModalityDetector. These are shallowly merged with the default\n * options.\n */\nconst INPUT_MODALITY_DETECTOR_OPTIONS = new InjectionToken('cdk-input-modality-detector-options');\n/**\n * Default options for the InputModalityDetector.\n *\n * Modifier keys are ignored by default (i.e. when pressed won't cause the service to detect\n * keyboard input modality) for two reasons:\n *\n * 1. Modifier keys are commonly used with mouse to perform actions such as 'right click' or 'open\n * in new tab', and are thus less representative of actual keyboard interaction.\n * 2. VoiceOver triggers some keyboard events when linearly navigating with Control + Option (but\n * confusingly not with Caps Lock). Thus, to have parity with other screen readers, we ignore\n * these keys so as to not update the input modality.\n *\n * Note that we do not by default ignore the right Meta key on Safari because it has the same key\n * code as the ContextMenu key on other browsers. When we switch to using event.key, we can\n * distinguish between the two.\n */\nconst INPUT_MODALITY_DETECTOR_DEFAULT_OPTIONS = {\n ignoreKeys: [ALT, CONTROL, MAC_META, META, SHIFT],\n};\n/**\n * The amount of time needed to pass after a touchstart event in order for a subsequent mousedown\n * event to be attributed as mouse and not touch.\n *\n * This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found\n * that a value of around 650ms seems appropriate.\n */\nconst TOUCH_BUFFER_MS = 650;\n/**\n * Event listener options that enable capturing and also mark the listener as passive if the browser\n * supports it.\n */\nconst modalityEventListenerOptions = normalizePassiveListenerOptions({\n passive: true,\n capture: true,\n});\n/**\n * Service that detects the user's input modality.\n *\n * This service does not update the input modality when a user navigates with a screen reader\n * (e.g. linear navigation with VoiceOver, object navigation / browse mode with NVDA, virtual PC\n * cursor mode with JAWS). This is in part due to technical limitations (i.e. keyboard events do not\n * fire as expected in these modes) but is also arguably the correct behavior. Navigating with a\n * screen reader is akin to visually scanning a page, and should not be interpreted as actual user\n * input interaction.\n *\n * When a user is not navigating but *interacting* with a screen reader, this service attempts to\n * update the input modality to keyboard, but in general this service's behavior is largely\n * undefined.\n */\nclass InputModalityDetector {\n _platform = inject(Platform);\n /** Emits whenever an input modality is detected. */\n modalityDetected;\n /** Emits when the input modality changes. */\n modalityChanged;\n /** The most recently detected input modality. */\n get mostRecentModality() {\n return this._modality.value;\n }\n /**\n * The most recently detected input modality event target. Is null if no input modality has been\n * detected or if the associated event target is null for some unknown reason.\n */\n _mostRecentTarget = null;\n /** The underlying BehaviorSubject that emits whenever an input modality is detected. */\n _modality = new BehaviorSubject(null);\n /** Options for this InputModalityDetector. */\n _options;\n /**\n * The timestamp of the last touch input modality. Used to determine whether mousedown events\n * should be attributed to mouse or touch.\n */\n _lastTouchMs = 0;\n /**\n * Handles keydown events. Must be an arrow function in order to preserve the context when it gets\n * bound.\n */\n _onKeydown = (event) => {\n // If this is one of the keys we should ignore, then ignore it and don't update the input\n // modality to keyboard.\n if (this._options?.ignoreKeys?.some(keyCode => keyCode === event.keyCode)) {\n return;\n }\n this._modality.next('keyboard');\n this._mostRecentTarget = _getEventTarget(event);\n };\n /**\n * Handles mousedown events. Must be an arrow function in order to preserve the context when it\n * gets bound.\n */\n _onMousedown = (event) => {\n // Touches trigger both touch and mouse events, so we need to distinguish between mouse events\n // that were triggered via mouse vs touch. To do so, check if the mouse event occurs closely\n // after the previous touch event.\n if (Date.now() - this._lastTouchMs < TOUCH_BUFFER_MS) {\n return;\n }\n // Fake mousedown events are fired by some screen readers when controls are activated by the\n // screen reader. Attribute them to keyboard input modality.\n this._modality.next(isFakeMousedownFromScreenReader(event) ? 'keyboard' : 'mouse');\n this._mostRecentTarget = _getEventTarget(event);\n };\n /**\n * Handles touchstart events. Must be an arrow function in order to preserve the context when it\n * gets bound.\n */\n _onTouchstart = (event) => {\n // Same scenario as mentioned in _onMousedown, but on touch screen devices, fake touchstart\n // events are fired. Again, attribute to keyboard input modality.\n if (isFakeTouchstartFromScreenReader(event)) {\n this._modality.next('keyboard');\n return;\n }\n // Store the timestamp of this touch event, as it's used to distinguish between mouse events\n // triggered via mouse vs touch.\n this._lastTouchMs = Date.now();\n this._modality.next('touch');\n this._mostRecentTarget = _getEventTarget(event);\n };\n constructor() {\n const ngZone = inject(NgZone);\n const document = inject(DOCUMENT);\n const options = inject(INPUT_MODALITY_DETECTOR_OPTIONS, { optional: true });\n this._options = {\n ...INPUT_MODALITY_DETECTOR_DEFAULT_OPTIONS,\n ...options,\n };\n // Skip the first emission as it's null.\n this.modalityDetected = this._modality.pipe(skip(1));\n this.modalityChanged = this.modalityDetected.pipe(distinctUntilChanged());\n // If we're not in a browser, this service should do nothing, as there's no relevant input\n // modality to detect.\n if (this._platform.isBrowser) {\n ngZone.runOutsideAngular(() => {\n document.addEventListener('keydown', this._onKeydown, modalityEventListenerOptions);\n document.addEventListener('mousedown', this._onMousedown, modalityEventListenerOptions);\n document.addEventListener('touchstart', this._onTouchstart, modalityEventListenerOptions);\n });\n }\n }\n ngOnDestroy() {\n this._modality.complete();\n if (this._platform.isBrowser) {\n document.removeEventListener('keydown', this._onKeydown, modalityEventListenerOptions);\n document.removeEventListener('mousedown', this._onMousedown, modalityEventListenerOptions);\n document.removeEventListener('touchstart', this._onTouchstart, modalityEventListenerOptions);\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: InputModalityDetector, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: InputModalityDetector, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: InputModalityDetector, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\nconst LIVE_ANNOUNCER_ELEMENT_TOKEN = new InjectionToken('liveAnnouncerElement', {\n providedIn: 'root',\n factory: LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY,\n});\n/** @docs-private */\nfunction LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY() {\n return null;\n}\n/** Injection token that can be used to configure the default options for the LiveAnnouncer. */\nconst LIVE_ANNOUNCER_DEFAULT_OPTIONS = new InjectionToken('LIVE_ANNOUNCER_DEFAULT_OPTIONS');\n\nlet uniqueIds = 0;\nclass LiveAnnouncer {\n _ngZone = inject(NgZone);\n _defaultOptions = inject(LIVE_ANNOUNCER_DEFAULT_OPTIONS, {\n optional: true,\n });\n _liveElement;\n _document = inject(DOCUMENT);\n _previousTimeout;\n _currentPromise;\n _currentResolve;\n constructor() {\n const elementToken = inject(LIVE_ANNOUNCER_ELEMENT_TOKEN, { optional: true });\n this._liveElement = elementToken || this._createLiveElement();\n }\n announce(message, ...args) {\n const defaultOptions = this._defaultOptions;\n let politeness;\n let duration;\n if (args.length === 1 && typeof args[0] === 'number') {\n duration = args[0];\n }\n else {\n [politeness, duration] = args;\n }\n this.clear();\n clearTimeout(this._previousTimeout);\n if (!politeness) {\n politeness =\n defaultOptions && defaultOptions.politeness ? defaultOptions.politeness : 'polite';\n }\n if (duration == null && defaultOptions) {\n duration = defaultOptions.duration;\n }\n // TODO: ensure changing the politeness works on all environments we support.\n this._liveElement.setAttribute('aria-live', politeness);\n if (this._liveElement.id) {\n this._exposeAnnouncerToModals(this._liveElement.id);\n }\n // This 100ms timeout is necessary for some browser + screen-reader combinations:\n // - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout.\n // - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a\n // second time without clearing and then using a non-zero delay.\n // (using JAWS 17 at time of this writing).\n return this._ngZone.runOutsideAngular(() => {\n if (!this._currentPromise) {\n this._currentPromise = new Promise(resolve => (this._currentResolve = resolve));\n }\n clearTimeout(this._previousTimeout);\n this._previousTimeout = setTimeout(() => {\n this._liveElement.textContent = message;\n if (typeof duration === 'number') {\n this._previousTimeout = setTimeout(() => this.clear(), duration);\n }\n // For some reason in tests this can be undefined\n // Probably related to ZoneJS and every other thing that patches browser APIs in tests\n this._currentResolve?.();\n this._currentPromise = this._currentResolve = undefined;\n }, 100);\n return this._currentPromise;\n });\n }\n /**\n * Clears the current text from the announcer element. Can be used to prevent\n * screen readers from reading the text out again while the user is going\n * through the page landmarks.\n */\n clear() {\n if (this._liveElement) {\n this._liveElement.textContent = '';\n }\n }\n ngOnDestroy() {\n clearTimeout(this._previousTimeout);\n this._liveElement?.remove();\n this._liveElement = null;\n this._currentResolve?.();\n this._currentPromise = this._currentResolve = undefined;\n }\n _createLiveElement() {\n const elementClass = 'cdk-live-announcer-element';\n const previousElements = this._document.getElementsByClassName(elementClass);\n const liveEl = this._document.createElement('div');\n // Remove any old containers. This can happen when coming in from a server-side-rendered page.\n for (let i = 0; i < previousElements.length; i++) {\n previousElements[i].remove();\n }\n liveEl.classList.add(elementClass);\n liveEl.classList.add('cdk-visually-hidden');\n liveEl.setAttribute('aria-atomic', 'true');\n liveEl.setAttribute('aria-live', 'polite');\n liveEl.id = `cdk-live-announcer-${uniqueIds++}`;\n this._document.body.appendChild(liveEl);\n return liveEl;\n }\n /**\n * Some browsers won't expose the accessibility node of the live announcer element if there is an\n * `aria-modal` and the live announcer is outside of it. This method works around the issue by\n * pointing the `aria-owns` of all modals to the live announcer element.\n */\n _exposeAnnouncerToModals(id) {\n // TODO(http://github.com/angular/components/issues/26853): consider de-duplicating this with\n // the `SnakBarContainer` and other usages.\n //\n // Note that the selector here is limited to CDK overlays at the moment in order to reduce the\n // section of the DOM we need to look through. This should cover all the cases we support, but\n // the selector can be expanded if it turns out to be too narrow.\n const modals = this._document.querySelectorAll('body > .cdk-overlay-container [aria-modal=\"true\"]');\n for (let i = 0; i < modals.length; i++) {\n const modal = modals[i];\n const ariaOwns = modal.getAttribute('aria-owns');\n if (!ariaOwns) {\n modal.setAttribute('aria-owns', id);\n }\n else if (ariaOwns.indexOf(id) === -1) {\n modal.setAttribute('aria-owns', ariaOwns + ' ' + id);\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: LiveAnnouncer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: LiveAnnouncer, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: LiveAnnouncer, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/**\n * A directive that works similarly to aria-live, but uses the LiveAnnouncer to ensure compatibility\n * with a wider range of browsers and screen readers.\n */\nclass CdkAriaLive {\n _elementRef = inject(ElementRef);\n _liveAnnouncer = inject(LiveAnnouncer);\n _contentObserver = inject(ContentObserver);\n _ngZone = inject(NgZone);\n /** The aria-live politeness level to use when announcing messages. */\n get politeness() {\n return this._politeness;\n }\n set politeness(value) {\n this._politeness = value === 'off' || value === 'assertive' ? value : 'polite';\n if (this._politeness === 'off') {\n if (this._subscription) {\n this._subscription.unsubscribe();\n this._subscription = null;\n }\n }\n else if (!this._subscription) {\n this._subscription = this._ngZone.runOutsideAngular(() => {\n return this._contentObserver.observe(this._elementRef).subscribe(() => {\n // Note that we use textContent here, rather than innerText, in order to avoid a reflow.\n const elementText = this._elementRef.nativeElement.textContent;\n // The `MutationObserver` fires also for attribute\n // changes which we don't want to announce.\n if (elementText !== this._previousAnnouncedText) {\n this._liveAnnouncer.announce(elementText, this._politeness, this.duration);\n this._previousAnnouncedText = elementText;\n }\n });\n });\n }\n }\n _politeness = 'polite';\n /** Time in milliseconds after which to clear out the announcer element. */\n duration;\n _previousAnnouncedText;\n _subscription;\n constructor() {\n inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);\n }\n ngOnDestroy() {\n if (this._subscription) {\n this._subscription.unsubscribe();\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkAriaLive, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkAriaLive, isStandalone: true, selector: \"[cdkAriaLive]\", inputs: { politeness: [\"cdkAriaLive\", \"politeness\"], duration: [\"cdkAriaLiveDuration\", \"duration\"] }, exportAs: [\"cdkAriaLive\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkAriaLive, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkAriaLive]',\n exportAs: 'cdkAriaLive',\n }]\n }], ctorParameters: () => [], propDecorators: { politeness: [{\n type: Input,\n args: ['cdkAriaLive']\n }], duration: [{\n type: Input,\n args: ['cdkAriaLiveDuration']\n }] } });\n\n/** Detection mode used for attributing the origin of a focus event. */\nvar FocusMonitorDetectionMode;\n(function (FocusMonitorDetectionMode) {\n /**\n * Any mousedown, keydown, or touchstart event that happened in the previous\n * tick or the current tick will be used to assign a focus event's origin (to\n * either mouse, keyboard, or touch). This is the default option.\n */\n FocusMonitorDetectionMode[FocusMonitorDetectionMode[\"IMMEDIATE\"] = 0] = \"IMMEDIATE\";\n /**\n * A focus event's origin is always attributed to the last corresponding\n * mousedown, keydown, or touchstart event, no matter how long ago it occurred.\n */\n FocusMonitorDetectionMode[FocusMonitorDetectionMode[\"EVENTUAL\"] = 1] = \"EVENTUAL\";\n})(FocusMonitorDetectionMode || (FocusMonitorDetectionMode = {}));\n/** InjectionToken for FocusMonitorOptions. */\nconst FOCUS_MONITOR_DEFAULT_OPTIONS = new InjectionToken('cdk-focus-monitor-default-options');\n/**\n * Event listener options that enable capturing and also\n * mark the listener as passive if the browser supports it.\n */\nconst captureEventListenerOptions = normalizePassiveListenerOptions({\n passive: true,\n capture: true,\n});\n/** Monitors mouse and keyboard events to determine the cause of focus events. */\nclass FocusMonitor {\n _ngZone = inject(NgZone);\n _platform = inject(Platform);\n _inputModalityDetector = inject(InputModalityDetector);\n /** The focus origin that the next focus event is a result of. */\n _origin = null;\n /** The FocusOrigin of the last focus event tracked by the FocusMonitor. */\n _lastFocusOrigin;\n /** Whether the window has just been focused. */\n _windowFocused = false;\n /** The timeout id of the window focus timeout. */\n _windowFocusTimeoutId;\n /** The timeout id of the origin clearing timeout. */\n _originTimeoutId;\n /**\n * Whether the origin was determined via a touch interaction. Necessary as properly attributing\n * focus events to touch interactions requires special logic.\n */\n _originFromTouchInteraction = false;\n /** Map of elements being monitored to their info. */\n _elementInfo = new Map();\n /** The number of elements currently being monitored. */\n _monitoredElementCount = 0;\n /**\n * Keeps track of the root nodes to which we've currently bound a focus/blur handler,\n * as well as the number of monitored elements that they contain. We have to treat focus/blur\n * handlers differently from the rest of the events, because the browser won't emit events\n * to the document when focus moves inside of a shadow root.\n */\n _rootNodeFocusListenerCount = new Map();\n /**\n * The specified detection mode, used for attributing the origin of a focus\n * event.\n */\n _detectionMode;\n /**\n * Event listener for `focus` events on the window.\n * Needs to be an arrow function in order to preserve the context when it gets bound.\n */\n _windowFocusListener = () => {\n // Make a note of when the window regains focus, so we can\n // restore the origin info for the focused element.\n this._windowFocused = true;\n this._windowFocusTimeoutId = setTimeout(() => (this._windowFocused = false));\n };\n /** Used to reference correct document/window */\n _document = inject(DOCUMENT, { optional: true });\n /** Subject for stopping our InputModalityDetector subscription. */\n _stopInputModalityDetector = new Subject();\n constructor() {\n const options = inject(FOCUS_MONITOR_DEFAULT_OPTIONS, {\n optional: true,\n });\n this._detectionMode = options?.detectionMode || FocusMonitorDetectionMode.IMMEDIATE;\n }\n /**\n * Event listener for `focus` and 'blur' events on the document.\n * Needs to be an arrow function in order to preserve the context when it gets bound.\n */\n _rootNodeFocusAndBlurListener = (event) => {\n const target = _getEventTarget(event);\n // We need to walk up the ancestor chain in order to support `checkChildren`.\n for (let element = target; element; element = element.parentElement) {\n if (event.type === 'focus') {\n this._onFocus(event, element);\n }\n else {\n this._onBlur(event, element);\n }\n }\n };\n monitor(element, checkChildren = false) {\n const nativeElement = coerceElement(element);\n // Do nothing if we're not on the browser platform or the passed in node isn't an element.\n if (!this._platform.isBrowser || nativeElement.nodeType !== 1) {\n // Note: we don't want the observable to emit at all so we don't pass any parameters.\n return of();\n }\n // If the element is inside the shadow DOM, we need to bind our focus/blur listeners to\n // the shadow root, rather than the `document`, because the browser won't emit focus events\n // to the `document`, if focus is moving within the same shadow root.\n const rootNode = _getShadowRoot(nativeElement) || this._getDocument();\n const cachedInfo = this._elementInfo.get(nativeElement);\n // Check if we're already monitoring this element.\n if (cachedInfo) {\n if (checkChildren) {\n // TODO(COMP-318): this can be problematic, because it'll turn all non-checkChildren\n // observers into ones that behave as if `checkChildren` was turned on. We need a more\n // robust solution.\n cachedInfo.checkChildren = true;\n }\n return cachedInfo.subject;\n }\n // Create monitored element info.\n const info = {\n checkChildren: checkChildren,\n subject: new Subject(),\n rootNode,\n };\n this._elementInfo.set(nativeElement, info);\n this._registerGlobalListeners(info);\n return info.subject;\n }\n stopMonitoring(element) {\n const nativeElement = coerceElement(element);\n const elementInfo = this._elementInfo.get(nativeElement);\n if (elementInfo) {\n elementInfo.subject.complete();\n this._setClasses(nativeElement);\n this._elementInfo.delete(nativeElement);\n this._removeGlobalListeners(elementInfo);\n }\n }\n focusVia(element, origin, options) {\n const nativeElement = coerceElement(element);\n const focusedElement = this._getDocument().activeElement;\n // If the element is focused already, calling `focus` again won't trigger the event listener\n // which means that the focus classes won't be updated. If that's the case, update the classes\n // directly without waiting for an event.\n if (nativeElement === focusedElement) {\n this._getClosestElementsInfo(nativeElement).forEach(([currentElement, info]) => this._originChanged(currentElement, origin, info));\n }\n else {\n this._setOrigin(origin);\n // `focus` isn't available on the server\n if (typeof nativeElement.focus === 'function') {\n nativeElement.focus(options);\n }\n }\n }\n ngOnDestroy() {\n this._elementInfo.forEach((_info, element) => this.stopMonitoring(element));\n }\n /** Access injected document if available or fallback to global document reference */\n _getDocument() {\n return this._document || document;\n }\n /** Use defaultView of injected document if available or fallback to global window reference */\n _getWindow() {\n const doc = this._getDocument();\n return doc.defaultView || window;\n }\n _getFocusOrigin(focusEventTarget) {\n if (this._origin) {\n // If the origin was realized via a touch interaction, we need to perform additional checks\n // to determine whether the focus origin should be attributed to touch or program.\n if (this._originFromTouchInteraction) {\n return this._shouldBeAttributedToTouch(focusEventTarget) ? 'touch' : 'program';\n }\n else {\n return this._origin;\n }\n }\n // If the window has just regained focus, we can restore the most recent origin from before the\n // window blurred. Otherwise, we've reached the point where we can't identify the source of the\n // focus. This typically means one of two things happened:\n //\n // 1) The element was programmatically focused, or\n // 2) The element was focused via screen reader navigation (which generally doesn't fire\n // events).\n //\n // Because we can't distinguish between these two cases, we default to setting `program`.\n if (this._windowFocused && this._lastFocusOrigin) {\n return this._lastFocusOrigin;\n }\n // If the interaction is coming from an input label, we consider it a mouse interactions.\n // This is a special case where focus moves on `click`, rather than `mousedown` which breaks\n // our detection, because all our assumptions are for `mousedown`. We need to handle this\n // special case, because it's very common for checkboxes and radio buttons.\n if (focusEventTarget && this._isLastInteractionFromInputLabel(focusEventTarget)) {\n return 'mouse';\n }\n return 'program';\n }\n /**\n * Returns whether the focus event should be attributed to touch. Recall that in IMMEDIATE mode, a\n * touch origin isn't immediately reset at the next tick (see _setOrigin). This means that when we\n * handle a focus event following a touch interaction, we need to determine whether (1) the focus\n * event was directly caused by the touch interaction or (2) the focus event was caused by a\n * subsequent programmatic focus call triggered by the touch interaction.\n * @param focusEventTarget The target of the focus event under examination.\n */\n _shouldBeAttributedToTouch(focusEventTarget) {\n // Please note that this check is not perfect. Consider the following edge case:\n //\n //
    \n //
    \n //
    \n //\n // Suppose there is a FocusMonitor in IMMEDIATE mode attached to #parent. When the user touches\n // #child, #parent is programmatically focused. This code will attribute the focus to touch\n // instead of program. This is a relatively minor edge-case that can be worked around by using\n // focusVia(parent, 'program') to focus #parent.\n return (this._detectionMode === FocusMonitorDetectionMode.EVENTUAL ||\n !!focusEventTarget?.contains(this._inputModalityDetector._mostRecentTarget));\n }\n /**\n * Sets the focus classes on the element based on the given focus origin.\n * @param element The element to update the classes on.\n * @param origin The focus origin.\n */\n _setClasses(element, origin) {\n element.classList.toggle('cdk-focused', !!origin);\n element.classList.toggle('cdk-touch-focused', origin === 'touch');\n element.classList.toggle('cdk-keyboard-focused', origin === 'keyboard');\n element.classList.toggle('cdk-mouse-focused', origin === 'mouse');\n element.classList.toggle('cdk-program-focused', origin === 'program');\n }\n /**\n * Updates the focus origin. If we're using immediate detection mode, we schedule an async\n * function to clear the origin at the end of a timeout. The duration of the timeout depends on\n * the origin being set.\n * @param origin The origin to set.\n * @param isFromInteraction Whether we are setting the origin from an interaction event.\n */\n _setOrigin(origin, isFromInteraction = false) {\n this._ngZone.runOutsideAngular(() => {\n this._origin = origin;\n this._originFromTouchInteraction = origin === 'touch' && isFromInteraction;\n // If we're in IMMEDIATE mode, reset the origin at the next tick (or in `TOUCH_BUFFER_MS` ms\n // for a touch event). We reset the origin at the next tick because Firefox focuses one tick\n // after the interaction event. We wait `TOUCH_BUFFER_MS` ms before resetting the origin for\n // a touch event because when a touch event is fired, the associated focus event isn't yet in\n // the event queue. Before doing so, clear any pending timeouts.\n if (this._detectionMode === FocusMonitorDetectionMode.IMMEDIATE) {\n clearTimeout(this._originTimeoutId);\n const ms = this._originFromTouchInteraction ? TOUCH_BUFFER_MS : 1;\n this._originTimeoutId = setTimeout(() => (this._origin = null), ms);\n }\n });\n }\n /**\n * Handles focus events on a registered element.\n * @param event The focus event.\n * @param element The monitored element.\n */\n _onFocus(event, element) {\n // NOTE(mmalerba): We currently set the classes based on the focus origin of the most recent\n // focus event affecting the monitored element. If we want to use the origin of the first event\n // instead we should check for the cdk-focused class here and return if the element already has\n // it. (This only matters for elements that have includesChildren = true).\n // If we are not counting child-element-focus as focused, make sure that the event target is the\n // monitored element itself.\n const elementInfo = this._elementInfo.get(element);\n const focusEventTarget = _getEventTarget(event);\n if (!elementInfo || (!elementInfo.checkChildren && element !== focusEventTarget)) {\n return;\n }\n this._originChanged(element, this._getFocusOrigin(focusEventTarget), elementInfo);\n }\n /**\n * Handles blur events on a registered element.\n * @param event The blur event.\n * @param element The monitored element.\n */\n _onBlur(event, element) {\n // If we are counting child-element-focus as focused, make sure that we aren't just blurring in\n // order to focus another child of the monitored element.\n const elementInfo = this._elementInfo.get(element);\n if (!elementInfo ||\n (elementInfo.checkChildren &&\n event.relatedTarget instanceof Node &&\n element.contains(event.relatedTarget))) {\n return;\n }\n this._setClasses(element);\n this._emitOrigin(elementInfo, null);\n }\n _emitOrigin(info, origin) {\n if (info.subject.observers.length) {\n this._ngZone.run(() => info.subject.next(origin));\n }\n }\n _registerGlobalListeners(elementInfo) {\n if (!this._platform.isBrowser) {\n return;\n }\n const rootNode = elementInfo.rootNode;\n const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode) || 0;\n if (!rootNodeFocusListeners) {\n this._ngZone.runOutsideAngular(() => {\n rootNode.addEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);\n rootNode.addEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);\n });\n }\n this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners + 1);\n // Register global listeners when first element is monitored.\n if (++this._monitoredElementCount === 1) {\n // Note: we listen to events in the capture phase so we\n // can detect them even if the user stops propagation.\n this._ngZone.runOutsideAngular(() => {\n const window = this._getWindow();\n window.addEventListener('focus', this._windowFocusListener);\n });\n // The InputModalityDetector is also just a collection of global listeners.\n this._inputModalityDetector.modalityDetected\n .pipe(takeUntil(this._stopInputModalityDetector))\n .subscribe(modality => {\n this._setOrigin(modality, true /* isFromInteraction */);\n });\n }\n }\n _removeGlobalListeners(elementInfo) {\n const rootNode = elementInfo.rootNode;\n if (this._rootNodeFocusListenerCount.has(rootNode)) {\n const rootNodeFocusListeners = this._rootNodeFocusListenerCount.get(rootNode);\n if (rootNodeFocusListeners > 1) {\n this._rootNodeFocusListenerCount.set(rootNode, rootNodeFocusListeners - 1);\n }\n else {\n rootNode.removeEventListener('focus', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);\n rootNode.removeEventListener('blur', this._rootNodeFocusAndBlurListener, captureEventListenerOptions);\n this._rootNodeFocusListenerCount.delete(rootNode);\n }\n }\n // Unregister global listeners when last element is unmonitored.\n if (!--this._monitoredElementCount) {\n const window = this._getWindow();\n window.removeEventListener('focus', this._windowFocusListener);\n // Equivalently, stop our InputModalityDetector subscription.\n this._stopInputModalityDetector.next();\n // Clear timeouts for all potentially pending timeouts to prevent the leaks.\n clearTimeout(this._windowFocusTimeoutId);\n clearTimeout(this._originTimeoutId);\n }\n }\n /** Updates all the state on an element once its focus origin has changed. */\n _originChanged(element, origin, elementInfo) {\n this._setClasses(element, origin);\n this._emitOrigin(elementInfo, origin);\n this._lastFocusOrigin = origin;\n }\n /**\n * Collects the `MonitoredElementInfo` of a particular element and\n * all of its ancestors that have enabled `checkChildren`.\n * @param element Element from which to start the search.\n */\n _getClosestElementsInfo(element) {\n const results = [];\n this._elementInfo.forEach((info, currentElement) => {\n if (currentElement === element || (info.checkChildren && currentElement.contains(element))) {\n results.push([currentElement, info]);\n }\n });\n return results;\n }\n /**\n * Returns whether an interaction is likely to have come from the user clicking the `label` of\n * an `input` or `textarea` in order to focus it.\n * @param focusEventTarget Target currently receiving focus.\n */\n _isLastInteractionFromInputLabel(focusEventTarget) {\n const { _mostRecentTarget: mostRecentTarget, mostRecentModality } = this._inputModalityDetector;\n // If the last interaction used the mouse on an element contained by one of the labels\n // of an `input`/`textarea` that is currently focused, it is very likely that the\n // user redirected focus using the label.\n if (mostRecentModality !== 'mouse' ||\n !mostRecentTarget ||\n mostRecentTarget === focusEventTarget ||\n (focusEventTarget.nodeName !== 'INPUT' && focusEventTarget.nodeName !== 'TEXTAREA') ||\n focusEventTarget.disabled) {\n return false;\n }\n const labels = focusEventTarget.labels;\n if (labels) {\n for (let i = 0; i < labels.length; i++) {\n if (labels[i].contains(mostRecentTarget)) {\n return true;\n }\n }\n }\n return false;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusMonitor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusMonitor, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FocusMonitor, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/**\n * Directive that determines how a particular element was focused (via keyboard, mouse, touch, or\n * programmatically) and adds corresponding classes to the element.\n *\n * There are two variants of this directive:\n * 1) cdkMonitorElementFocus: does not consider an element to be focused if one of its children is\n * focused.\n * 2) cdkMonitorSubtreeFocus: considers an element focused if it or any of its children are focused.\n */\nclass CdkMonitorFocus {\n _elementRef = inject(ElementRef);\n _focusMonitor = inject(FocusMonitor);\n _monitorSubscription;\n _focusOrigin = null;\n cdkFocusChange = new EventEmitter();\n constructor() { }\n get focusOrigin() {\n return this._focusOrigin;\n }\n ngAfterViewInit() {\n const element = this._elementRef.nativeElement;\n this._monitorSubscription = this._focusMonitor\n .monitor(element, element.nodeType === 1 && element.hasAttribute('cdkMonitorSubtreeFocus'))\n .subscribe(origin => {\n this._focusOrigin = origin;\n this.cdkFocusChange.emit(origin);\n });\n }\n ngOnDestroy() {\n this._focusMonitor.stopMonitoring(this._elementRef);\n if (this._monitorSubscription) {\n this._monitorSubscription.unsubscribe();\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkMonitorFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkMonitorFocus, isStandalone: true, selector: \"[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]\", outputs: { cdkFocusChange: \"cdkFocusChange\" }, exportAs: [\"cdkMonitorFocus\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkMonitorFocus, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]',\n exportAs: 'cdkMonitorFocus',\n }]\n }], ctorParameters: () => [], propDecorators: { cdkFocusChange: [{\n type: Output\n }] } });\n\n/** Set of possible high-contrast mode backgrounds. */\nvar HighContrastMode;\n(function (HighContrastMode) {\n HighContrastMode[HighContrastMode[\"NONE\"] = 0] = \"NONE\";\n HighContrastMode[HighContrastMode[\"BLACK_ON_WHITE\"] = 1] = \"BLACK_ON_WHITE\";\n HighContrastMode[HighContrastMode[\"WHITE_ON_BLACK\"] = 2] = \"WHITE_ON_BLACK\";\n})(HighContrastMode || (HighContrastMode = {}));\n/** CSS class applied to the document body when in black-on-white high-contrast mode. */\nconst BLACK_ON_WHITE_CSS_CLASS = 'cdk-high-contrast-black-on-white';\n/** CSS class applied to the document body when in white-on-black high-contrast mode. */\nconst WHITE_ON_BLACK_CSS_CLASS = 'cdk-high-contrast-white-on-black';\n/** CSS class applied to the document body when in high-contrast mode. */\nconst HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS = 'cdk-high-contrast-active';\n/**\n * Service to determine whether the browser is currently in a high-contrast-mode environment.\n *\n * Microsoft Windows supports an accessibility feature called \"High Contrast Mode\". This mode\n * changes the appearance of all applications, including web applications, to dramatically increase\n * contrast.\n *\n * IE, Edge, and Firefox currently support this mode. Chrome does not support Windows High Contrast\n * Mode. This service does not detect high-contrast mode as added by the Chrome \"High Contrast\"\n * browser extension.\n */\nclass HighContrastModeDetector {\n _platform = inject(Platform);\n /**\n * Figuring out the high contrast mode and adding the body classes can cause\n * some expensive layouts. This flag is used to ensure that we only do it once.\n */\n _hasCheckedHighContrastMode;\n _document = inject(DOCUMENT);\n _breakpointSubscription;\n constructor() {\n this._breakpointSubscription = inject(BreakpointObserver)\n .observe('(forced-colors: active)')\n .subscribe(() => {\n if (this._hasCheckedHighContrastMode) {\n this._hasCheckedHighContrastMode = false;\n this._applyBodyHighContrastModeCssClasses();\n }\n });\n }\n /** Gets the current high-contrast-mode for the page. */\n getHighContrastMode() {\n if (!this._platform.isBrowser) {\n return HighContrastMode.NONE;\n }\n // Create a test element with an arbitrary background-color that is neither black nor\n // white; high-contrast mode will coerce the color to either black or white. Also ensure that\n // appending the test element to the DOM does not affect layout by absolutely positioning it\n const testElement = this._document.createElement('div');\n testElement.style.backgroundColor = 'rgb(1,2,3)';\n testElement.style.position = 'absolute';\n this._document.body.appendChild(testElement);\n // Get the computed style for the background color, collapsing spaces to normalize between\n // browsers. Once we get this color, we no longer need the test element. Access the `window`\n // via the document so we can fake it in tests. Note that we have extra null checks, because\n // this logic will likely run during app bootstrap and throwing can break the entire app.\n const documentWindow = this._document.defaultView || window;\n const computedStyle = documentWindow && documentWindow.getComputedStyle\n ? documentWindow.getComputedStyle(testElement)\n : null;\n const computedColor = ((computedStyle && computedStyle.backgroundColor) || '').replace(/ /g, '');\n testElement.remove();\n switch (computedColor) {\n // Pre Windows 11 dark theme.\n case 'rgb(0,0,0)':\n // Windows 11 dark themes.\n case 'rgb(45,50,54)':\n case 'rgb(32,32,32)':\n return HighContrastMode.WHITE_ON_BLACK;\n // Pre Windows 11 light theme.\n case 'rgb(255,255,255)':\n // Windows 11 light theme.\n case 'rgb(255,250,239)':\n return HighContrastMode.BLACK_ON_WHITE;\n }\n return HighContrastMode.NONE;\n }\n ngOnDestroy() {\n this._breakpointSubscription.unsubscribe();\n }\n /** Applies CSS classes indicating high-contrast mode to document body (browser-only). */\n _applyBodyHighContrastModeCssClasses() {\n if (!this._hasCheckedHighContrastMode && this._platform.isBrowser && this._document.body) {\n const bodyClasses = this._document.body.classList;\n bodyClasses.remove(HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS, BLACK_ON_WHITE_CSS_CLASS, WHITE_ON_BLACK_CSS_CLASS);\n this._hasCheckedHighContrastMode = true;\n const mode = this.getHighContrastMode();\n if (mode === HighContrastMode.BLACK_ON_WHITE) {\n bodyClasses.add(HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS, BLACK_ON_WHITE_CSS_CLASS);\n }\n else if (mode === HighContrastMode.WHITE_ON_BLACK) {\n bodyClasses.add(HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS, WHITE_ON_BLACK_CSS_CLASS);\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: HighContrastModeDetector, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: HighContrastModeDetector, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: HighContrastModeDetector, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\nclass A11yModule {\n constructor() {\n inject(HighContrastModeDetector)._applyBodyHighContrastModeCssClasses();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: A11yModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: A11yModule, imports: [ObserversModule, CdkAriaLive, CdkTrapFocus, CdkMonitorFocus], exports: [CdkAriaLive, CdkTrapFocus, CdkMonitorFocus] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: A11yModule, imports: [ObserversModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: A11yModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [ObserversModule, CdkAriaLive, CdkTrapFocus, CdkMonitorFocus],\n exports: [CdkAriaLive, CdkTrapFocus, CdkMonitorFocus],\n }]\n }], ctorParameters: () => [] });\n\n/**\n * Keeps track of the ID count per prefix. This helps us make the IDs a bit more deterministic\n * like they were before the service was introduced. Note that ideally we wouldn't have to do\n * this, but there are some internal tests that rely on the IDs.\n */\nconst counters = {};\n/** Service that generates unique IDs for DOM nodes. */\nclass _IdGenerator {\n _appId = inject(APP_ID);\n /**\n * Generates a unique ID with a specific prefix.\n * @param prefix Prefix to add to the ID.\n */\n getId(prefix) {\n // Omit the app ID if it's the default `ng`. Since the vast majority of pages have one\n // Angular app on them, we can reduce the amount of breakages by not adding it.\n if (this._appId !== 'ng') {\n prefix += this._appId;\n }\n if (!counters.hasOwnProperty(prefix)) {\n counters[prefix] = 0;\n }\n return `${prefix}${counters[prefix]++}`;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _IdGenerator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _IdGenerator, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _IdGenerator, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { A11yModule, ActiveDescendantKeyManager, AriaDescriber, CDK_DESCRIBEDBY_HOST_ATTRIBUTE, CDK_DESCRIBEDBY_ID_PREFIX, CdkAriaLive, CdkMonitorFocus, CdkTrapFocus, ConfigurableFocusTrap, ConfigurableFocusTrapFactory, EventListenerFocusTrapInertStrategy, FOCUS_MONITOR_DEFAULT_OPTIONS, FOCUS_TRAP_INERT_STRATEGY, FocusKeyManager, FocusMonitor, FocusMonitorDetectionMode, FocusTrap, FocusTrapFactory, HighContrastMode, HighContrastModeDetector, INPUT_MODALITY_DETECTOR_DEFAULT_OPTIONS, INPUT_MODALITY_DETECTOR_OPTIONS, InputModalityDetector, InteractivityChecker, IsFocusableConfig, LIVE_ANNOUNCER_DEFAULT_OPTIONS, LIVE_ANNOUNCER_ELEMENT_TOKEN, LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY, ListKeyManager, LiveAnnouncer, MESSAGES_CONTAINER_ID, NOOP_TREE_KEY_MANAGER_FACTORY, NOOP_TREE_KEY_MANAGER_FACTORY_PROVIDER, NoopTreeKeyManager, TREE_KEY_MANAGER, TREE_KEY_MANAGER_FACTORY, TREE_KEY_MANAGER_FACTORY_PROVIDER, TreeKeyManager, _IdGenerator, addAriaReferencedId, getAriaReferenceIds, isFakeMousedownFromScreenReader, isFakeTouchstartFromScreenReader, removeAriaReferencedId };\n","import * as i0 from '@angular/core';\nimport { InjectionToken, inject, EventEmitter, Injectable, Directive, Output, Input, NgModule } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\n/**\n * Injection token used to inject the document into Directionality.\n * This is used so that the value can be faked in tests.\n *\n * We can't use the real document in tests because changing the real `dir` causes geometry-based\n * tests in Safari to fail.\n *\n * We also can't re-provide the DOCUMENT token from platform-browser because the unit tests\n * themselves use things like `querySelector` in test code.\n *\n * This token is defined in a separate file from Directionality as a workaround for\n * https://github.com/angular/angular/issues/22559\n *\n * @docs-private\n */\nconst DIR_DOCUMENT = new InjectionToken('cdk-dir-doc', {\n providedIn: 'root',\n factory: DIR_DOCUMENT_FACTORY,\n});\n/** @docs-private */\nfunction DIR_DOCUMENT_FACTORY() {\n return inject(DOCUMENT);\n}\n\n/** Regex that matches locales with an RTL script. Taken from `goog.i18n.bidi.isRtlLanguage`. */\nconst RTL_LOCALE_PATTERN = /^(ar|ckb|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_](Adlm|Arab|Hebr|Nkoo|Rohg|Thaa))(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)/i;\n/** Resolves a string value to a specific direction. */\nfunction _resolveDirectionality(rawValue) {\n const value = rawValue?.toLowerCase() || '';\n if (value === 'auto' && typeof navigator !== 'undefined' && navigator?.language) {\n return RTL_LOCALE_PATTERN.test(navigator.language) ? 'rtl' : 'ltr';\n }\n return value === 'rtl' ? 'rtl' : 'ltr';\n}\n/**\n * The directionality (LTR / RTL) context for the application (or a subtree of it).\n * Exposes the current direction and a stream of direction changes.\n */\nclass Directionality {\n /** The current 'ltr' or 'rtl' value. */\n value = 'ltr';\n /** Stream that emits whenever the 'ltr' / 'rtl' state changes. */\n change = new EventEmitter();\n constructor() {\n const _document = inject(DIR_DOCUMENT, { optional: true });\n if (_document) {\n const bodyDir = _document.body ? _document.body.dir : null;\n const htmlDir = _document.documentElement ? _document.documentElement.dir : null;\n this.value = _resolveDirectionality(bodyDir || htmlDir || 'ltr');\n }\n }\n ngOnDestroy() {\n this.change.complete();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Directionality, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Directionality, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Directionality, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/**\n * Directive to listen for changes of direction of part of the DOM.\n *\n * Provides itself as Directionality such that descendant directives only need to ever inject\n * Directionality to get the closest direction.\n */\nclass Dir {\n /** Normalized direction that accounts for invalid/unsupported values. */\n _dir = 'ltr';\n /** Whether the `value` has been set to its initial value. */\n _isInitialized = false;\n /** Direction as passed in by the consumer. */\n _rawDir;\n /** Event emitted when the direction changes. */\n change = new EventEmitter();\n /** @docs-private */\n get dir() {\n return this._dir;\n }\n set dir(value) {\n const previousValue = this._dir;\n // Note: `_resolveDirectionality` resolves the language based on the browser's language,\n // whereas the browser does it based on the content of the element. Since doing so based\n // on the content can be expensive, for now we're doing the simpler matching.\n this._dir = _resolveDirectionality(value);\n this._rawDir = value;\n if (previousValue !== this._dir && this._isInitialized) {\n this.change.emit(this._dir);\n }\n }\n /** Current layout direction of the element. */\n get value() {\n return this.dir;\n }\n /** Initialize once default value has been set. */\n ngAfterContentInit() {\n this._isInitialized = true;\n }\n ngOnDestroy() {\n this.change.complete();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Dir, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: Dir, isStandalone: true, selector: \"[dir]\", inputs: { dir: \"dir\" }, outputs: { change: \"dirChange\" }, host: { properties: { \"attr.dir\": \"_rawDir\" } }, providers: [{ provide: Directionality, useExisting: Dir }], exportAs: [\"dir\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Dir, decorators: [{\n type: Directive,\n args: [{\n selector: '[dir]',\n providers: [{ provide: Directionality, useExisting: Dir }],\n host: { '[attr.dir]': '_rawDir' },\n exportAs: 'dir',\n }]\n }], propDecorators: { change: [{\n type: Output,\n args: ['dirChange']\n }], dir: [{\n type: Input\n }] } });\n\nclass BidiModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BidiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: BidiModule, imports: [Dir], exports: [Dir] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BidiModule });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BidiModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [Dir],\n exports: [Dir],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { BidiModule, DIR_DOCUMENT, Dir, Directionality };\n","import { ElementRef } from '@angular/core';\n\n/** Coerces a data-bound value (typically a string) to a boolean. */\nfunction coerceBooleanProperty(value) {\n return value != null && `${value}` !== 'false';\n}\n\nfunction coerceNumberProperty(value, fallbackValue = 0) {\n if (_isNumberValue(value)) {\n return Number(value);\n }\n return arguments.length === 2 ? fallbackValue : 0;\n}\n/**\n * Whether the provided value is considered a number.\n * @docs-private\n */\nfunction _isNumberValue(value) {\n // parseFloat(value) handles most of the cases we're interested in (it treats null, empty string,\n // and other non-number values as NaN, where Number just uses 0) but it considers the string\n // '123hello' to be a valid number. Therefore we also check if Number(value) is NaN.\n return !isNaN(parseFloat(value)) && !isNaN(Number(value));\n}\n\nfunction coerceArray(value) {\n return Array.isArray(value) ? value : [value];\n}\n\n/** Coerces a value to a CSS pixel value. */\nfunction coerceCssPixelValue(value) {\n if (value == null) {\n return '';\n }\n return typeof value === 'string' ? value : `${value}px`;\n}\n\n/**\n * Coerces an ElementRef or an Element into an element.\n * Useful for APIs that can accept either a ref or the native element itself.\n */\nfunction coerceElement(elementOrRef) {\n return elementOrRef instanceof ElementRef ? elementOrRef.nativeElement : elementOrRef;\n}\n\n/**\n * Coerces a value to an array of trimmed non-empty strings.\n * Any input that is not an array, `null` or `undefined` will be turned into a string\n * via `toString()` and subsequently split with the given separator.\n * `null` and `undefined` will result in an empty array.\n * This results in the following outcomes:\n * - `null` -> `[]`\n * - `[null]` -> `[\"null\"]`\n * - `[\"a\", \"b \", \" \"]` -> `[\"a\", \"b\"]`\n * - `[1, [2, 3]]` -> `[\"1\", \"2,3\"]`\n * - `[{ a: 0 }]` -> `[\"[object Object]\"]`\n * - `{ a: 0 }` -> `[\"[object\", \"Object]\"]`\n *\n * Useful for defining CSS classes or table columns.\n * @param value the value to coerce into an array of strings\n * @param separator split-separator if value isn't an array\n */\nfunction coerceStringArray(value, separator = /\\s+/) {\n const result = [];\n if (value != null) {\n const sourceValues = Array.isArray(value) ? value : `${value}`.split(separator);\n for (const sourceValue of sourceValues) {\n const trimmedString = `${sourceValue}`.trim();\n if (trimmedString) {\n result.push(trimmedString);\n }\n }\n }\n return result;\n}\n\nexport { _isNumberValue, coerceArray, coerceBooleanProperty, coerceCssPixelValue, coerceElement, coerceNumberProperty, coerceStringArray };\n","import { ConnectableObservable, isObservable, of, Subject } from 'rxjs';\nimport * as i0 from '@angular/core';\nimport { InjectionToken, Injectable } from '@angular/core';\n\nclass DataSource {\n}\n/** Checks whether an object is a data source. */\nfunction isDataSource(value) {\n // Check if the value is a DataSource by observing if it has a connect function. Cannot\n // be checked as an `instanceof DataSource` since people could create their own sources\n // that match the interface, but don't extend DataSource. We also can't use `isObservable`\n // here, because of some internal apps.\n return value && typeof value.connect === 'function' && !(value instanceof ConnectableObservable);\n}\n\n/** DataSource wrapper for a native array. */\nclass ArrayDataSource extends DataSource {\n _data;\n constructor(_data) {\n super();\n this._data = _data;\n }\n connect() {\n return isObservable(this._data) ? this._data : of(this._data);\n }\n disconnect() { }\n}\n\n/** Indicates how a view was changed by a {@link _ViewRepeater}. */\nvar _ViewRepeaterOperation;\n(function (_ViewRepeaterOperation) {\n /** The content of an existing view was replaced with another item. */\n _ViewRepeaterOperation[_ViewRepeaterOperation[\"REPLACED\"] = 0] = \"REPLACED\";\n /** A new view was created with `createEmbeddedView`. */\n _ViewRepeaterOperation[_ViewRepeaterOperation[\"INSERTED\"] = 1] = \"INSERTED\";\n /** The position of a view changed, but the content remains the same. */\n _ViewRepeaterOperation[_ViewRepeaterOperation[\"MOVED\"] = 2] = \"MOVED\";\n /** A view was detached from the view container. */\n _ViewRepeaterOperation[_ViewRepeaterOperation[\"REMOVED\"] = 3] = \"REMOVED\";\n})(_ViewRepeaterOperation || (_ViewRepeaterOperation = {}));\n/**\n * Injection token for {@link _ViewRepeater}. This token is for use by Angular Material only.\n * @docs-private\n */\nconst _VIEW_REPEATER_STRATEGY = new InjectionToken('_ViewRepeater');\n\n/**\n * A repeater that destroys views when they are removed from a\n * {@link ViewContainerRef}. When new items are inserted into the container,\n * the repeater will always construct a new embedded view for each item.\n *\n * @template T The type for the embedded view's $implicit property.\n * @template R The type for the item in each IterableDiffer change record.\n * @template C The type for the context passed to each embedded view.\n */\nclass _DisposeViewRepeaterStrategy {\n applyChanges(changes, viewContainerRef, itemContextFactory, itemValueResolver, itemViewChanged) {\n changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => {\n let view;\n let operation;\n if (record.previousIndex == null) {\n const insertContext = itemContextFactory(record, adjustedPreviousIndex, currentIndex);\n view = viewContainerRef.createEmbeddedView(insertContext.templateRef, insertContext.context, insertContext.index);\n operation = _ViewRepeaterOperation.INSERTED;\n }\n else if (currentIndex == null) {\n viewContainerRef.remove(adjustedPreviousIndex);\n operation = _ViewRepeaterOperation.REMOVED;\n }\n else {\n view = viewContainerRef.get(adjustedPreviousIndex);\n viewContainerRef.move(view, currentIndex);\n operation = _ViewRepeaterOperation.MOVED;\n }\n if (itemViewChanged) {\n itemViewChanged({\n context: view?.context,\n operation,\n record,\n });\n }\n });\n }\n detach() { }\n}\n\n/**\n * A repeater that caches views when they are removed from a\n * {@link ViewContainerRef}. When new items are inserted into the container,\n * the repeater will reuse one of the cached views instead of creating a new\n * embedded view. Recycling cached views reduces the quantity of expensive DOM\n * inserts.\n *\n * @template T The type for the embedded view's $implicit property.\n * @template R The type for the item in each IterableDiffer change record.\n * @template C The type for the context passed to each embedded view.\n */\nclass _RecycleViewRepeaterStrategy {\n /**\n * The size of the cache used to store unused views.\n * Setting the cache size to `0` will disable caching. Defaults to 20 views.\n */\n viewCacheSize = 20;\n /**\n * View cache that stores embedded view instances that have been previously stamped out,\n * but don't are not currently rendered. The view repeater will reuse these views rather than\n * creating brand new ones.\n *\n * TODO(michaeljamesparsons) Investigate whether using a linked list would improve performance.\n */\n _viewCache = [];\n /** Apply changes to the DOM. */\n applyChanges(changes, viewContainerRef, itemContextFactory, itemValueResolver, itemViewChanged) {\n // Rearrange the views to put them in the right location.\n changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => {\n let view;\n let operation;\n if (record.previousIndex == null) {\n // Item added.\n const viewArgsFactory = () => itemContextFactory(record, adjustedPreviousIndex, currentIndex);\n view = this._insertView(viewArgsFactory, currentIndex, viewContainerRef, itemValueResolver(record));\n operation = view ? _ViewRepeaterOperation.INSERTED : _ViewRepeaterOperation.REPLACED;\n }\n else if (currentIndex == null) {\n // Item removed.\n this._detachAndCacheView(adjustedPreviousIndex, viewContainerRef);\n operation = _ViewRepeaterOperation.REMOVED;\n }\n else {\n // Item moved.\n view = this._moveView(adjustedPreviousIndex, currentIndex, viewContainerRef, itemValueResolver(record));\n operation = _ViewRepeaterOperation.MOVED;\n }\n if (itemViewChanged) {\n itemViewChanged({\n context: view?.context,\n operation,\n record,\n });\n }\n });\n }\n detach() {\n for (const view of this._viewCache) {\n view.destroy();\n }\n this._viewCache = [];\n }\n /**\n * Inserts a view for a new item, either from the cache or by creating a new\n * one. Returns `undefined` if the item was inserted into a cached view.\n */\n _insertView(viewArgsFactory, currentIndex, viewContainerRef, value) {\n const cachedView = this._insertViewFromCache(currentIndex, viewContainerRef);\n if (cachedView) {\n cachedView.context.$implicit = value;\n return undefined;\n }\n const viewArgs = viewArgsFactory();\n return viewContainerRef.createEmbeddedView(viewArgs.templateRef, viewArgs.context, viewArgs.index);\n }\n /** Detaches the view at the given index and inserts into the view cache. */\n _detachAndCacheView(index, viewContainerRef) {\n const detachedView = viewContainerRef.detach(index);\n this._maybeCacheView(detachedView, viewContainerRef);\n }\n /** Moves view at the previous index to the current index. */\n _moveView(adjustedPreviousIndex, currentIndex, viewContainerRef, value) {\n const view = viewContainerRef.get(adjustedPreviousIndex);\n viewContainerRef.move(view, currentIndex);\n view.context.$implicit = value;\n return view;\n }\n /**\n * Cache the given detached view. If the cache is full, the view will be\n * destroyed.\n */\n _maybeCacheView(view, viewContainerRef) {\n if (this._viewCache.length < this.viewCacheSize) {\n this._viewCache.push(view);\n }\n else {\n const index = viewContainerRef.indexOf(view);\n // The host component could remove views from the container outside of\n // the view repeater. It's unlikely this will occur, but just in case,\n // destroy the view on its own, otherwise destroy it through the\n // container to ensure that all the references are removed.\n if (index === -1) {\n view.destroy();\n }\n else {\n viewContainerRef.remove(index);\n }\n }\n }\n /** Inserts a recycled view from the cache at the given index. */\n _insertViewFromCache(index, viewContainerRef) {\n const cachedView = this._viewCache.pop();\n if (cachedView) {\n viewContainerRef.insert(cachedView, index);\n }\n return cachedView || null;\n }\n}\n\n/**\n * Class to be used to power selecting one or more options from a list.\n */\nclass SelectionModel {\n _multiple;\n _emitChanges;\n compareWith;\n /** Currently-selected values. */\n _selection = new Set();\n /** Keeps track of the deselected options that haven't been emitted by the change event. */\n _deselectedToEmit = [];\n /** Keeps track of the selected options that haven't been emitted by the change event. */\n _selectedToEmit = [];\n /** Cache for the array value of the selected items. */\n _selected;\n /** Selected values. */\n get selected() {\n if (!this._selected) {\n this._selected = Array.from(this._selection.values());\n }\n return this._selected;\n }\n /** Event emitted when the value has changed. */\n changed = new Subject();\n constructor(_multiple = false, initiallySelectedValues, _emitChanges = true, compareWith) {\n this._multiple = _multiple;\n this._emitChanges = _emitChanges;\n this.compareWith = compareWith;\n if (initiallySelectedValues && initiallySelectedValues.length) {\n if (_multiple) {\n initiallySelectedValues.forEach(value => this._markSelected(value));\n }\n else {\n this._markSelected(initiallySelectedValues[0]);\n }\n // Clear the array in order to avoid firing the change event for preselected values.\n this._selectedToEmit.length = 0;\n }\n }\n /**\n * Selects a value or an array of values.\n * @param values The values to select\n * @return Whether the selection changed as a result of this call\n * @breaking-change 16.0.0 make return type boolean\n */\n select(...values) {\n this._verifyValueAssignment(values);\n values.forEach(value => this._markSelected(value));\n const changed = this._hasQueuedChanges();\n this._emitChangeEvent();\n return changed;\n }\n /**\n * Deselects a value or an array of values.\n * @param values The values to deselect\n * @return Whether the selection changed as a result of this call\n * @breaking-change 16.0.0 make return type boolean\n */\n deselect(...values) {\n this._verifyValueAssignment(values);\n values.forEach(value => this._unmarkSelected(value));\n const changed = this._hasQueuedChanges();\n this._emitChangeEvent();\n return changed;\n }\n /**\n * Sets the selected values\n * @param values The new selected values\n * @return Whether the selection changed as a result of this call\n * @breaking-change 16.0.0 make return type boolean\n */\n setSelection(...values) {\n this._verifyValueAssignment(values);\n const oldValues = this.selected;\n const newSelectedSet = new Set(values);\n values.forEach(value => this._markSelected(value));\n oldValues\n .filter(value => !newSelectedSet.has(this._getConcreteValue(value, newSelectedSet)))\n .forEach(value => this._unmarkSelected(value));\n const changed = this._hasQueuedChanges();\n this._emitChangeEvent();\n return changed;\n }\n /**\n * Toggles a value between selected and deselected.\n * @param value The value to toggle\n * @return Whether the selection changed as a result of this call\n * @breaking-change 16.0.0 make return type boolean\n */\n toggle(value) {\n return this.isSelected(value) ? this.deselect(value) : this.select(value);\n }\n /**\n * Clears all of the selected values.\n * @param flushEvent Whether to flush the changes in an event.\n * If false, the changes to the selection will be flushed along with the next event.\n * @return Whether the selection changed as a result of this call\n * @breaking-change 16.0.0 make return type boolean\n */\n clear(flushEvent = true) {\n this._unmarkAll();\n const changed = this._hasQueuedChanges();\n if (flushEvent) {\n this._emitChangeEvent();\n }\n return changed;\n }\n /**\n * Determines whether a value is selected.\n */\n isSelected(value) {\n return this._selection.has(this._getConcreteValue(value));\n }\n /**\n * Determines whether the model does not have a value.\n */\n isEmpty() {\n return this._selection.size === 0;\n }\n /**\n * Determines whether the model has a value.\n */\n hasValue() {\n return !this.isEmpty();\n }\n /**\n * Sorts the selected values based on a predicate function.\n */\n sort(predicate) {\n if (this._multiple && this.selected) {\n this._selected.sort(predicate);\n }\n }\n /**\n * Gets whether multiple values can be selected.\n */\n isMultipleSelection() {\n return this._multiple;\n }\n /** Emits a change event and clears the records of selected and deselected values. */\n _emitChangeEvent() {\n // Clear the selected values so they can be re-cached.\n this._selected = null;\n if (this._selectedToEmit.length || this._deselectedToEmit.length) {\n this.changed.next({\n source: this,\n added: this._selectedToEmit,\n removed: this._deselectedToEmit,\n });\n this._deselectedToEmit = [];\n this._selectedToEmit = [];\n }\n }\n /** Selects a value. */\n _markSelected(value) {\n value = this._getConcreteValue(value);\n if (!this.isSelected(value)) {\n if (!this._multiple) {\n this._unmarkAll();\n }\n if (!this.isSelected(value)) {\n this._selection.add(value);\n }\n if (this._emitChanges) {\n this._selectedToEmit.push(value);\n }\n }\n }\n /** Deselects a value. */\n _unmarkSelected(value) {\n value = this._getConcreteValue(value);\n if (this.isSelected(value)) {\n this._selection.delete(value);\n if (this._emitChanges) {\n this._deselectedToEmit.push(value);\n }\n }\n }\n /** Clears out the selected values. */\n _unmarkAll() {\n if (!this.isEmpty()) {\n this._selection.forEach(value => this._unmarkSelected(value));\n }\n }\n /**\n * Verifies the value assignment and throws an error if the specified value array is\n * including multiple values while the selection model is not supporting multiple values.\n */\n _verifyValueAssignment(values) {\n if (values.length > 1 && !this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw getMultipleValuesInSingleSelectionError();\n }\n }\n /** Whether there are queued up change to be emitted. */\n _hasQueuedChanges() {\n return !!(this._deselectedToEmit.length || this._selectedToEmit.length);\n }\n /** Returns a value that is comparable to inputValue by applying compareWith function, returns the same inputValue otherwise. */\n _getConcreteValue(inputValue, selection) {\n if (!this.compareWith) {\n return inputValue;\n }\n else {\n selection = selection ?? this._selection;\n for (let selectedValue of selection) {\n if (this.compareWith(inputValue, selectedValue)) {\n return selectedValue;\n }\n }\n return inputValue;\n }\n }\n}\n/**\n * Returns an error that reports that multiple values are passed into a selection model\n * with a single value.\n * @docs-private\n */\nfunction getMultipleValuesInSingleSelectionError() {\n return Error('Cannot pass multiple values into SelectionModel with single-value mode.');\n}\n\n/**\n * Class to coordinate unique selection based on name.\n * Intended to be consumed as an Angular service.\n * This service is needed because native radio change events are only fired on the item currently\n * being selected, and we still need to uncheck the previous selection.\n *\n * This service does not *store* any IDs and names because they may change at any time, so it is\n * less error-prone if they are simply passed through when the events occur.\n */\nclass UniqueSelectionDispatcher {\n _listeners = [];\n /**\n * Notify other items that selection for the given name has been set.\n * @param id ID of the item.\n * @param name Name of the item.\n */\n notify(id, name) {\n for (let listener of this._listeners) {\n listener(id, name);\n }\n }\n /**\n * Listen for future changes to item selection.\n * @return Function used to deregister listener\n */\n listen(listener) {\n this._listeners.push(listener);\n return () => {\n this._listeners = this._listeners.filter((registered) => {\n return listener !== registered;\n });\n };\n }\n ngOnDestroy() {\n this._listeners = [];\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: UniqueSelectionDispatcher, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: UniqueSelectionDispatcher, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: UniqueSelectionDispatcher, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { ArrayDataSource, DataSource, SelectionModel, UniqueSelectionDispatcher, _DisposeViewRepeaterStrategy, _RecycleViewRepeaterStrategy, _VIEW_REPEATER_STRATEGY, _ViewRepeaterOperation, getMultipleValuesInSingleSelectionError, isDataSource };\n","import * as i0 from '@angular/core';\nimport { signal, Component, ViewEncapsulation, ChangeDetectionStrategy, inject, NgZone, Injectable, RendererFactory2, InjectionToken, ElementRef, booleanAttribute, Directive, Input, ViewContainerRef, ChangeDetectorRef, EventEmitter, Injector, afterNextRender, numberAttribute, Output, TemplateRef, NgModule } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\nimport { ViewportRuler, ScrollDispatcher, CdkScrollableModule } from '@angular/cdk/scrolling';\nimport { isFakeTouchstartFromScreenReader, isFakeMousedownFromScreenReader, _IdGenerator } from '@angular/cdk/a11y';\nimport { coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';\nimport { _getEventTarget, normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';\nimport { Subject, Subscription, interval, animationFrameScheduler, Observable, merge, BehaviorSubject } from 'rxjs';\nimport { takeUntil, map, take, tap, switchMap, startWith } from 'rxjs/operators';\nimport { _CdkPrivateStyleLoader } from '@angular/cdk/private';\nimport { Directionality } from '@angular/cdk/bidi';\n\n/** Creates a deep clone of an element. */\nfunction deepCloneNode(node) {\n const clone = node.cloneNode(true);\n const descendantsWithId = clone.querySelectorAll('[id]');\n const nodeName = node.nodeName.toLowerCase();\n // Remove the `id` to avoid having multiple elements with the same id on the page.\n clone.removeAttribute('id');\n for (let i = 0; i < descendantsWithId.length; i++) {\n descendantsWithId[i].removeAttribute('id');\n }\n if (nodeName === 'canvas') {\n transferCanvasData(node, clone);\n }\n else if (nodeName === 'input' || nodeName === 'select' || nodeName === 'textarea') {\n transferInputData(node, clone);\n }\n transferData('canvas', node, clone, transferCanvasData);\n transferData('input, textarea, select', node, clone, transferInputData);\n return clone;\n}\n/** Matches elements between an element and its clone and allows for their data to be cloned. */\nfunction transferData(selector, node, clone, callback) {\n const descendantElements = node.querySelectorAll(selector);\n if (descendantElements.length) {\n const cloneElements = clone.querySelectorAll(selector);\n for (let i = 0; i < descendantElements.length; i++) {\n callback(descendantElements[i], cloneElements[i]);\n }\n }\n}\n// Counter for unique cloned radio button names.\nlet cloneUniqueId = 0;\n/** Transfers the data of one input element to another. */\nfunction transferInputData(source, clone) {\n // Browsers throw an error when assigning the value of a file input programmatically.\n if (clone.type !== 'file') {\n clone.value = source.value;\n }\n // Radio button `name` attributes must be unique for radio button groups\n // otherwise original radio buttons can lose their checked state\n // once the clone is inserted in the DOM.\n if (clone.type === 'radio' && clone.name) {\n clone.name = `mat-clone-${clone.name}-${cloneUniqueId++}`;\n }\n}\n/** Transfers the data of one canvas element to another. */\nfunction transferCanvasData(source, clone) {\n const context = clone.getContext('2d');\n if (context) {\n // In some cases `drawImage` can throw (e.g. if the canvas size is 0x0).\n // We can't do much about it so just ignore the error.\n try {\n context.drawImage(source, 0, 0);\n }\n catch { }\n }\n}\n\n/** Gets a mutable version of an element's bounding `DOMRect`. */\nfunction getMutableClientRect(element) {\n const rect = element.getBoundingClientRect();\n // We need to clone the `clientRect` here, because all the values on it are readonly\n // and we need to be able to update them. Also we can't use a spread here, because\n // the values on a `DOMRect` aren't own properties. See:\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes\n return {\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n width: rect.width,\n height: rect.height,\n x: rect.x,\n y: rect.y,\n };\n}\n/**\n * Checks whether some coordinates are within a `DOMRect`.\n * @param clientRect DOMRect that is being checked.\n * @param x Coordinates along the X axis.\n * @param y Coordinates along the Y axis.\n */\nfunction isInsideClientRect(clientRect, x, y) {\n const { top, bottom, left, right } = clientRect;\n return y >= top && y <= bottom && x >= left && x <= right;\n}\n/**\n * Updates the top/left positions of a `DOMRect`, as well as their bottom/right counterparts.\n * @param domRect `DOMRect` that should be updated.\n * @param top Amount to add to the `top` position.\n * @param left Amount to add to the `left` position.\n */\nfunction adjustDomRect(domRect, top, left) {\n domRect.top += top;\n domRect.bottom = domRect.top + domRect.height;\n domRect.left += left;\n domRect.right = domRect.left + domRect.width;\n}\n/**\n * Checks whether the pointer coordinates are close to a DOMRect.\n * @param rect DOMRect to check against.\n * @param threshold Threshold around the DOMRect.\n * @param pointerX Coordinates along the X axis.\n * @param pointerY Coordinates along the Y axis.\n */\nfunction isPointerNearDomRect(rect, threshold, pointerX, pointerY) {\n const { top, right, bottom, left, width, height } = rect;\n const xThreshold = width * threshold;\n const yThreshold = height * threshold;\n return (pointerY > top - yThreshold &&\n pointerY < bottom + yThreshold &&\n pointerX > left - xThreshold &&\n pointerX < right + xThreshold);\n}\n\n/** Keeps track of the scroll position and dimensions of the parents of an element. */\nclass ParentPositionTracker {\n _document;\n /** Cached positions of the scrollable parent elements. */\n positions = new Map();\n constructor(_document) {\n this._document = _document;\n }\n /** Clears the cached positions. */\n clear() {\n this.positions.clear();\n }\n /** Caches the positions. Should be called at the beginning of a drag sequence. */\n cache(elements) {\n this.clear();\n this.positions.set(this._document, {\n scrollPosition: this.getViewportScrollPosition(),\n });\n elements.forEach(element => {\n this.positions.set(element, {\n scrollPosition: { top: element.scrollTop, left: element.scrollLeft },\n clientRect: getMutableClientRect(element),\n });\n });\n }\n /** Handles scrolling while a drag is taking place. */\n handleScroll(event) {\n const target = _getEventTarget(event);\n const cachedPosition = this.positions.get(target);\n if (!cachedPosition) {\n return null;\n }\n const scrollPosition = cachedPosition.scrollPosition;\n let newTop;\n let newLeft;\n if (target === this._document) {\n const viewportScrollPosition = this.getViewportScrollPosition();\n newTop = viewportScrollPosition.top;\n newLeft = viewportScrollPosition.left;\n }\n else {\n newTop = target.scrollTop;\n newLeft = target.scrollLeft;\n }\n const topDifference = scrollPosition.top - newTop;\n const leftDifference = scrollPosition.left - newLeft;\n // Go through and update the cached positions of the scroll\n // parents that are inside the element that was scrolled.\n this.positions.forEach((position, node) => {\n if (position.clientRect && target !== node && target.contains(node)) {\n adjustDomRect(position.clientRect, topDifference, leftDifference);\n }\n });\n scrollPosition.top = newTop;\n scrollPosition.left = newLeft;\n return { top: topDifference, left: leftDifference };\n }\n /**\n * Gets the scroll position of the viewport. Note that we use the scrollX and scrollY directly,\n * instead of going through the `ViewportRuler`, because the first value the ruler looks at is\n * the top/left offset of the `document.documentElement` which works for most cases, but breaks\n * if the element is offset by something like the `BlockScrollStrategy`.\n */\n getViewportScrollPosition() {\n return { top: window.scrollY, left: window.scrollX };\n }\n}\n\n/**\n * Gets the root HTML element of an embedded view.\n * If the root is not an HTML element it gets wrapped in one.\n */\nfunction getRootNode(viewRef, _document) {\n const rootNodes = viewRef.rootNodes;\n if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {\n return rootNodes[0];\n }\n const wrapper = _document.createElement('div');\n rootNodes.forEach(node => wrapper.appendChild(node));\n return wrapper;\n}\n\n/**\n * Shallow-extends a stylesheet object with another stylesheet-like object.\n * Note that the keys in `source` have to be dash-cased.\n * @docs-private\n */\nfunction extendStyles(dest, source, importantProperties) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n const value = source[key];\n if (value) {\n dest.setProperty(key, value, importantProperties?.has(key) ? 'important' : '');\n }\n else {\n dest.removeProperty(key);\n }\n }\n }\n return dest;\n}\n/**\n * Toggles whether the native drag interactions should be enabled for an element.\n * @param element Element on which to toggle the drag interactions.\n * @param enable Whether the drag interactions should be enabled.\n * @docs-private\n */\nfunction toggleNativeDragInteractions(element, enable) {\n const userSelect = enable ? '' : 'none';\n extendStyles(element.style, {\n 'touch-action': enable ? '' : 'none',\n '-webkit-user-drag': enable ? '' : 'none',\n '-webkit-tap-highlight-color': enable ? '' : 'transparent',\n 'user-select': userSelect,\n '-ms-user-select': userSelect,\n '-webkit-user-select': userSelect,\n '-moz-user-select': userSelect,\n });\n}\n/**\n * Toggles whether an element is visible while preserving its dimensions.\n * @param element Element whose visibility to toggle\n * @param enable Whether the element should be visible.\n * @param importantProperties Properties to be set as `!important`.\n * @docs-private\n */\nfunction toggleVisibility(element, enable, importantProperties) {\n extendStyles(element.style, {\n position: enable ? '' : 'fixed',\n top: enable ? '' : '0',\n opacity: enable ? '' : '0',\n left: enable ? '' : '-999em',\n }, importantProperties);\n}\n/**\n * Combines a transform string with an optional other transform\n * that exited before the base transform was applied.\n */\nfunction combineTransforms(transform, initialTransform) {\n return initialTransform && initialTransform != 'none'\n ? transform + ' ' + initialTransform\n : transform;\n}\n/**\n * Matches the target element's size to the source's size.\n * @param target Element that needs to be resized.\n * @param sourceRect Dimensions of the source element.\n */\nfunction matchElementSize(target, sourceRect) {\n target.style.width = `${sourceRect.width}px`;\n target.style.height = `${sourceRect.height}px`;\n target.style.transform = getTransform(sourceRect.left, sourceRect.top);\n}\n/**\n * Gets a 3d `transform` that can be applied to an element.\n * @param x Desired position of the element along the X axis.\n * @param y Desired position of the element along the Y axis.\n */\nfunction getTransform(x, y) {\n // Round the transforms since some browsers will\n // blur the elements for sub-pixel transforms.\n return `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`;\n}\n\n/** Parses a CSS time value to milliseconds. */\nfunction parseCssTimeUnitsToMs(value) {\n // Some browsers will return it in seconds, whereas others will return milliseconds.\n const multiplier = value.toLowerCase().indexOf('ms') > -1 ? 1 : 1000;\n return parseFloat(value) * multiplier;\n}\n/** Gets the transform transition duration, including the delay, of an element in milliseconds. */\nfunction getTransformTransitionDurationInMs(element) {\n const computedStyle = getComputedStyle(element);\n const transitionedProperties = parseCssPropertyValue(computedStyle, 'transition-property');\n const property = transitionedProperties.find(prop => prop === 'transform' || prop === 'all');\n // If there's no transition for `all` or `transform`, we shouldn't do anything.\n if (!property) {\n return 0;\n }\n // Get the index of the property that we're interested in and match\n // it up to the same index in `transition-delay` and `transition-duration`.\n const propertyIndex = transitionedProperties.indexOf(property);\n const rawDurations = parseCssPropertyValue(computedStyle, 'transition-duration');\n const rawDelays = parseCssPropertyValue(computedStyle, 'transition-delay');\n return (parseCssTimeUnitsToMs(rawDurations[propertyIndex]) +\n parseCssTimeUnitsToMs(rawDelays[propertyIndex]));\n}\n/** Parses out multiple values from a computed style into an array. */\nfunction parseCssPropertyValue(computedStyle, name) {\n const value = computedStyle.getPropertyValue(name);\n return value.split(',').map(part => part.trim());\n}\n\n/** Inline styles to be set as `!important` while dragging. */\nconst importantProperties = new Set([\n // Needs to be important, because some `mat-table` sets `position: sticky !important`. See #22781.\n 'position',\n]);\nclass PreviewRef {\n _document;\n _rootElement;\n _direction;\n _initialDomRect;\n _previewTemplate;\n _previewClass;\n _pickupPositionOnPage;\n _initialTransform;\n _zIndex;\n _renderer;\n /** Reference to the view of the preview element. */\n _previewEmbeddedView;\n /** Reference to the preview element. */\n _preview;\n get element() {\n return this._preview;\n }\n constructor(_document, _rootElement, _direction, _initialDomRect, _previewTemplate, _previewClass, _pickupPositionOnPage, _initialTransform, _zIndex, _renderer) {\n this._document = _document;\n this._rootElement = _rootElement;\n this._direction = _direction;\n this._initialDomRect = _initialDomRect;\n this._previewTemplate = _previewTemplate;\n this._previewClass = _previewClass;\n this._pickupPositionOnPage = _pickupPositionOnPage;\n this._initialTransform = _initialTransform;\n this._zIndex = _zIndex;\n this._renderer = _renderer;\n }\n attach(parent) {\n this._preview = this._createPreview();\n parent.appendChild(this._preview);\n // The null check is necessary for browsers that don't support the popover API.\n // Note that we use a string access for compatibility with Closure.\n if (supportsPopover(this._preview)) {\n this._preview['showPopover']();\n }\n }\n destroy() {\n this._preview.remove();\n this._previewEmbeddedView?.destroy();\n this._preview = this._previewEmbeddedView = null;\n }\n setTransform(value) {\n this._preview.style.transform = value;\n }\n getBoundingClientRect() {\n return this._preview.getBoundingClientRect();\n }\n addClass(className) {\n this._preview.classList.add(className);\n }\n getTransitionDuration() {\n return getTransformTransitionDurationInMs(this._preview);\n }\n addEventListener(name, handler) {\n return this._renderer.listen(this._preview, name, handler);\n }\n _createPreview() {\n const previewConfig = this._previewTemplate;\n const previewClass = this._previewClass;\n const previewTemplate = previewConfig ? previewConfig.template : null;\n let preview;\n if (previewTemplate && previewConfig) {\n // Measure the element before we've inserted the preview\n // since the insertion could throw off the measurement.\n const rootRect = previewConfig.matchSize ? this._initialDomRect : null;\n const viewRef = previewConfig.viewContainer.createEmbeddedView(previewTemplate, previewConfig.context);\n viewRef.detectChanges();\n preview = getRootNode(viewRef, this._document);\n this._previewEmbeddedView = viewRef;\n if (previewConfig.matchSize) {\n matchElementSize(preview, rootRect);\n }\n else {\n preview.style.transform = getTransform(this._pickupPositionOnPage.x, this._pickupPositionOnPage.y);\n }\n }\n else {\n preview = deepCloneNode(this._rootElement);\n matchElementSize(preview, this._initialDomRect);\n if (this._initialTransform) {\n preview.style.transform = this._initialTransform;\n }\n }\n extendStyles(preview.style, {\n // It's important that we disable the pointer events on the preview, because\n // it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.\n 'pointer-events': 'none',\n // If the preview has a margin, it can throw off our positioning so we reset it. The reset\n // value for `margin-right` needs to be `auto` when opened as a popover, because our\n // positioning is always top/left based, but native popover seems to position itself\n // to the top/right if `` or `` have `dir=\"rtl\"` (see #29604). Setting it\n // to `auto` pushed it to the top/left corner in RTL and is a noop in LTR.\n 'margin': supportsPopover(preview) ? '0 auto 0 0' : '0',\n 'position': 'fixed',\n 'top': '0',\n 'left': '0',\n 'z-index': this._zIndex + '',\n }, importantProperties);\n toggleNativeDragInteractions(preview, false);\n preview.classList.add('cdk-drag-preview');\n preview.setAttribute('popover', 'manual');\n preview.setAttribute('dir', this._direction);\n if (previewClass) {\n if (Array.isArray(previewClass)) {\n previewClass.forEach(className => preview.classList.add(className));\n }\n else {\n preview.classList.add(previewClass);\n }\n }\n return preview;\n }\n}\n/** Checks whether a specific element supports the popover API. */\nfunction supportsPopover(element) {\n return 'showPopover' in element;\n}\n\n/** Options that can be used to bind a passive event listener. */\nconst passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });\n/** Options that can be used to bind an active event listener. */\nconst activeEventListenerOptions = normalizePassiveListenerOptions({ passive: false });\n/** Event options that can be used to bind an active, capturing event. */\nconst activeCapturingEventOptions$1 = normalizePassiveListenerOptions({\n passive: false,\n capture: true,\n});\n/**\n * Time in milliseconds for which to ignore mouse events, after\n * receiving a touch event. Used to avoid doing double work for\n * touch devices where the browser fires fake mouse events, in\n * addition to touch events.\n */\nconst MOUSE_EVENT_IGNORE_TIME = 800;\n/** Inline styles to be set as `!important` while dragging. */\nconst dragImportantProperties = new Set([\n // Needs to be important, because some `mat-table` sets `position: sticky !important`. See #22781.\n 'position',\n]);\n/**\n * Reference to a draggable item. Used to manipulate or dispose of the item.\n */\nclass DragRef {\n _config;\n _document;\n _ngZone;\n _viewportRuler;\n _dragDropRegistry;\n _renderer;\n /** Element displayed next to the user's pointer while the element is dragged. */\n _preview;\n /** Container into which to insert the preview. */\n _previewContainer;\n /** Reference to the view of the placeholder element. */\n _placeholderRef;\n /** Element that is rendered instead of the draggable item while it is being sorted. */\n _placeholder;\n /** Coordinates within the element at which the user picked up the element. */\n _pickupPositionInElement;\n /** Coordinates on the page at which the user picked up the element. */\n _pickupPositionOnPage;\n /**\n * Anchor node used to save the place in the DOM where the element was\n * picked up so that it can be restored at the end of the drag sequence.\n */\n _anchor;\n /**\n * CSS `transform` applied to the element when it isn't being dragged. We need a\n * passive transform in order for the dragged element to retain its new position\n * after the user has stopped dragging and because we need to know the relative\n * position in case they start dragging again. This corresponds to `element.style.transform`.\n */\n _passiveTransform = { x: 0, y: 0 };\n /** CSS `transform` that is applied to the element while it's being dragged. */\n _activeTransform = { x: 0, y: 0 };\n /** Inline `transform` value that the element had before the first dragging sequence. */\n _initialTransform;\n /**\n * Whether the dragging sequence has been started. Doesn't\n * necessarily mean that the element has been moved.\n */\n _hasStartedDragging = signal(false);\n /** Whether the element has moved since the user started dragging it. */\n _hasMoved;\n /** Drop container in which the DragRef resided when dragging began. */\n _initialContainer;\n /** Index at which the item started in its initial container. */\n _initialIndex;\n /** Cached positions of scrollable parent elements. */\n _parentPositions;\n /** Emits when the item is being moved. */\n _moveEvents = new Subject();\n /** Keeps track of the direction in which the user is dragging along each axis. */\n _pointerDirectionDelta;\n /** Pointer position at which the last change in the delta occurred. */\n _pointerPositionAtLastDirectionChange;\n /** Position of the pointer at the last pointer event. */\n _lastKnownPointerPosition;\n /**\n * Root DOM node of the drag instance. This is the element that will\n * be moved around as the user is dragging.\n */\n _rootElement;\n /**\n * Nearest ancestor SVG, relative to which coordinates are calculated if dragging SVGElement\n */\n _ownerSVGElement;\n /**\n * Inline style value of `-webkit-tap-highlight-color` at the time the\n * dragging was started. Used to restore the value once we're done dragging.\n */\n _rootElementTapHighlight;\n /** Subscription to pointer movement events. */\n _pointerMoveSubscription = Subscription.EMPTY;\n /** Subscription to the event that is dispatched when the user lifts their pointer. */\n _pointerUpSubscription = Subscription.EMPTY;\n /** Subscription to the viewport being scrolled. */\n _scrollSubscription = Subscription.EMPTY;\n /** Subscription to the viewport being resized. */\n _resizeSubscription = Subscription.EMPTY;\n /**\n * Time at which the last touch event occurred. Used to avoid firing the same\n * events multiple times on touch devices where the browser will fire a fake\n * mouse event for each touch event, after a certain time.\n */\n _lastTouchEventTime;\n /** Time at which the last dragging sequence was started. */\n _dragStartTime;\n /** Cached reference to the boundary element. */\n _boundaryElement = null;\n /** Whether the native dragging interactions have been enabled on the root element. */\n _nativeInteractionsEnabled = true;\n /** Client rect of the root element when the dragging sequence has started. */\n _initialDomRect;\n /** Cached dimensions of the preview element. Should be read via `_getPreviewRect`. */\n _previewRect;\n /** Cached dimensions of the boundary element. */\n _boundaryRect;\n /** Element that will be used as a template to create the draggable item's preview. */\n _previewTemplate;\n /** Template for placeholder element rendered to show where a draggable would be dropped. */\n _placeholderTemplate;\n /** Elements that can be used to drag the draggable item. */\n _handles = [];\n /** Registered handles that are currently disabled. */\n _disabledHandles = new Set();\n /** Droppable container that the draggable is a part of. */\n _dropContainer;\n /** Layout direction of the item. */\n _direction = 'ltr';\n /** Ref that the current drag item is nested in. */\n _parentDragRef;\n /**\n * Cached shadow root that the element is placed in. `null` means that the element isn't in\n * the shadow DOM and `undefined` means that it hasn't been resolved yet. Should be read via\n * `_getShadowRoot`, not directly.\n */\n _cachedShadowRoot;\n /** Axis along which dragging is locked. */\n lockAxis;\n /**\n * Amount of milliseconds to wait after the user has put their\n * pointer down before starting to drag the element.\n */\n dragStartDelay = 0;\n /** Class to be added to the preview element. */\n previewClass;\n /**\n * If the parent of the dragged element has a `scale` transform, it can throw off the\n * positioning when the user starts dragging. Use this input to notify the CDK of the scale.\n */\n scale = 1;\n /** Whether starting to drag this element is disabled. */\n get disabled() {\n return this._disabled || !!(this._dropContainer && this._dropContainer.disabled);\n }\n set disabled(value) {\n if (value !== this._disabled) {\n this._disabled = value;\n this._toggleNativeDragInteractions();\n this._handles.forEach(handle => toggleNativeDragInteractions(handle, value));\n }\n }\n _disabled = false;\n /** Emits as the drag sequence is being prepared. */\n beforeStarted = new Subject();\n /** Emits when the user starts dragging the item. */\n started = new Subject();\n /** Emits when the user has released a drag item, before any animations have started. */\n released = new Subject();\n /** Emits when the user stops dragging an item in the container. */\n ended = new Subject();\n /** Emits when the user has moved the item into a new container. */\n entered = new Subject();\n /** Emits when the user removes the item its container by dragging it into another container. */\n exited = new Subject();\n /** Emits when the user drops the item inside a container. */\n dropped = new Subject();\n /**\n * Emits as the user is dragging the item. Use with caution,\n * because this event will fire for every pixel that the user has dragged.\n */\n moved = this._moveEvents;\n /** Arbitrary data that can be attached to the drag item. */\n data;\n /**\n * Function that can be used to customize the logic of how the position of the drag item\n * is limited while it's being dragged. Gets called with a point containing the current position\n * of the user's pointer on the page, a reference to the item being dragged and its dimensions.\n * Should return a point describing where the item should be rendered.\n */\n constrainPosition;\n constructor(element, _config, _document, _ngZone, _viewportRuler, _dragDropRegistry, _renderer) {\n this._config = _config;\n this._document = _document;\n this._ngZone = _ngZone;\n this._viewportRuler = _viewportRuler;\n this._dragDropRegistry = _dragDropRegistry;\n this._renderer = _renderer;\n this.withRootElement(element).withParent(_config.parentDragRef || null);\n this._parentPositions = new ParentPositionTracker(_document);\n _dragDropRegistry.registerDragItem(this);\n }\n /**\n * Returns the element that is being used as a placeholder\n * while the current element is being dragged.\n */\n getPlaceholderElement() {\n return this._placeholder;\n }\n /** Returns the root draggable element. */\n getRootElement() {\n return this._rootElement;\n }\n /**\n * Gets the currently-visible element that represents the drag item.\n * While dragging this is the placeholder, otherwise it's the root element.\n */\n getVisibleElement() {\n return this.isDragging() ? this.getPlaceholderElement() : this.getRootElement();\n }\n /** Registers the handles that can be used to drag the element. */\n withHandles(handles) {\n this._handles = handles.map(handle => coerceElement(handle));\n this._handles.forEach(handle => toggleNativeDragInteractions(handle, this.disabled));\n this._toggleNativeDragInteractions();\n // Delete any lingering disabled handles that may have been destroyed. Note that we re-create\n // the set, rather than iterate over it and filter out the destroyed handles, because while\n // the ES spec allows for sets to be modified while they're being iterated over, some polyfills\n // use an array internally which may throw an error.\n const disabledHandles = new Set();\n this._disabledHandles.forEach(handle => {\n if (this._handles.indexOf(handle) > -1) {\n disabledHandles.add(handle);\n }\n });\n this._disabledHandles = disabledHandles;\n return this;\n }\n /**\n * Registers the template that should be used for the drag preview.\n * @param template Template that from which to stamp out the preview.\n */\n withPreviewTemplate(template) {\n this._previewTemplate = template;\n return this;\n }\n /**\n * Registers the template that should be used for the drag placeholder.\n * @param template Template that from which to stamp out the placeholder.\n */\n withPlaceholderTemplate(template) {\n this._placeholderTemplate = template;\n return this;\n }\n /**\n * Sets an alternate drag root element. The root element is the element that will be moved as\n * the user is dragging. Passing an alternate root element is useful when trying to enable\n * dragging on an element that you might not have access to.\n */\n withRootElement(rootElement) {\n const element = coerceElement(rootElement);\n if (element !== this._rootElement) {\n if (this._rootElement) {\n this._removeRootElementListeners(this._rootElement);\n }\n this._ngZone.runOutsideAngular(() => {\n element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);\n element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);\n element.addEventListener('dragstart', this._nativeDragStart, activeEventListenerOptions);\n });\n this._initialTransform = undefined;\n this._rootElement = element;\n }\n if (typeof SVGElement !== 'undefined' && this._rootElement instanceof SVGElement) {\n this._ownerSVGElement = this._rootElement.ownerSVGElement;\n }\n return this;\n }\n /**\n * Element to which the draggable's position will be constrained.\n */\n withBoundaryElement(boundaryElement) {\n this._boundaryElement = boundaryElement ? coerceElement(boundaryElement) : null;\n this._resizeSubscription.unsubscribe();\n if (boundaryElement) {\n this._resizeSubscription = this._viewportRuler\n .change(10)\n .subscribe(() => this._containInsideBoundaryOnResize());\n }\n return this;\n }\n /** Sets the parent ref that the ref is nested in. */\n withParent(parent) {\n this._parentDragRef = parent;\n return this;\n }\n /** Removes the dragging functionality from the DOM element. */\n dispose() {\n this._removeRootElementListeners(this._rootElement);\n // Do this check before removing from the registry since it'll\n // stop being considered as dragged once it is removed.\n if (this.isDragging()) {\n // Since we move out the element to the end of the body while it's being\n // dragged, we have to make sure that it's removed if it gets destroyed.\n this._rootElement?.remove();\n }\n this._anchor?.remove();\n this._destroyPreview();\n this._destroyPlaceholder();\n this._dragDropRegistry.removeDragItem(this);\n this._removeListeners();\n this.beforeStarted.complete();\n this.started.complete();\n this.released.complete();\n this.ended.complete();\n this.entered.complete();\n this.exited.complete();\n this.dropped.complete();\n this._moveEvents.complete();\n this._handles = [];\n this._disabledHandles.clear();\n this._dropContainer = undefined;\n this._resizeSubscription.unsubscribe();\n this._parentPositions.clear();\n this._boundaryElement =\n this._rootElement =\n this._ownerSVGElement =\n this._placeholderTemplate =\n this._previewTemplate =\n this._anchor =\n this._parentDragRef =\n null;\n }\n /** Checks whether the element is currently being dragged. */\n isDragging() {\n return this._hasStartedDragging() && this._dragDropRegistry.isDragging(this);\n }\n /** Resets a standalone drag item to its initial position. */\n reset() {\n this._rootElement.style.transform = this._initialTransform || '';\n this._activeTransform = { x: 0, y: 0 };\n this._passiveTransform = { x: 0, y: 0 };\n }\n /**\n * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.\n * @param handle Handle element that should be disabled.\n */\n disableHandle(handle) {\n if (!this._disabledHandles.has(handle) && this._handles.indexOf(handle) > -1) {\n this._disabledHandles.add(handle);\n toggleNativeDragInteractions(handle, true);\n }\n }\n /**\n * Enables a handle, if it has been disabled.\n * @param handle Handle element to be enabled.\n */\n enableHandle(handle) {\n if (this._disabledHandles.has(handle)) {\n this._disabledHandles.delete(handle);\n toggleNativeDragInteractions(handle, this.disabled);\n }\n }\n /** Sets the layout direction of the draggable item. */\n withDirection(direction) {\n this._direction = direction;\n return this;\n }\n /** Sets the container that the item is part of. */\n _withDropContainer(container) {\n this._dropContainer = container;\n }\n /**\n * Gets the current position in pixels the draggable outside of a drop container.\n */\n getFreeDragPosition() {\n const position = this.isDragging() ? this._activeTransform : this._passiveTransform;\n return { x: position.x, y: position.y };\n }\n /**\n * Sets the current position in pixels the draggable outside of a drop container.\n * @param value New position to be set.\n */\n setFreeDragPosition(value) {\n this._activeTransform = { x: 0, y: 0 };\n this._passiveTransform.x = value.x;\n this._passiveTransform.y = value.y;\n if (!this._dropContainer) {\n this._applyRootElementTransform(value.x, value.y);\n }\n return this;\n }\n /**\n * Sets the container into which to insert the preview element.\n * @param value Container into which to insert the preview.\n */\n withPreviewContainer(value) {\n this._previewContainer = value;\n return this;\n }\n /** Updates the item's sort order based on the last-known pointer position. */\n _sortFromLastPointerPosition() {\n const position = this._lastKnownPointerPosition;\n if (position && this._dropContainer) {\n this._updateActiveDropContainer(this._getConstrainedPointerPosition(position), position);\n }\n }\n /** Unsubscribes from the global subscriptions. */\n _removeListeners() {\n this._pointerMoveSubscription.unsubscribe();\n this._pointerUpSubscription.unsubscribe();\n this._scrollSubscription.unsubscribe();\n this._getShadowRoot()?.removeEventListener('selectstart', shadowDomSelectStart, activeCapturingEventOptions$1);\n }\n /** Destroys the preview element and its ViewRef. */\n _destroyPreview() {\n this._preview?.destroy();\n this._preview = null;\n }\n /** Destroys the placeholder element and its ViewRef. */\n _destroyPlaceholder() {\n this._placeholder?.remove();\n this._placeholderRef?.destroy();\n this._placeholder = this._placeholderRef = null;\n }\n /** Handler for the `mousedown`/`touchstart` events. */\n _pointerDown = (event) => {\n this.beforeStarted.next();\n // Delegate the event based on whether it started from a handle or the element itself.\n if (this._handles.length) {\n const targetHandle = this._getTargetHandle(event);\n if (targetHandle && !this._disabledHandles.has(targetHandle) && !this.disabled) {\n this._initializeDragSequence(targetHandle, event);\n }\n }\n else if (!this.disabled) {\n this._initializeDragSequence(this._rootElement, event);\n }\n };\n /** Handler that is invoked when the user moves their pointer after they've initiated a drag. */\n _pointerMove = (event) => {\n const pointerPosition = this._getPointerPositionOnPage(event);\n if (!this._hasStartedDragging()) {\n const distanceX = Math.abs(pointerPosition.x - this._pickupPositionOnPage.x);\n const distanceY = Math.abs(pointerPosition.y - this._pickupPositionOnPage.y);\n const isOverThreshold = distanceX + distanceY >= this._config.dragStartThreshold;\n // Only start dragging after the user has moved more than the minimum distance in either\n // direction. Note that this is preferable over doing something like `skip(minimumDistance)`\n // in the `pointerMove` subscription, because we're not guaranteed to have one move event\n // per pixel of movement (e.g. if the user moves their pointer quickly).\n if (isOverThreshold) {\n const isDelayElapsed = Date.now() >= this._dragStartTime + this._getDragStartDelay(event);\n const container = this._dropContainer;\n if (!isDelayElapsed) {\n this._endDragSequence(event);\n return;\n }\n // Prevent other drag sequences from starting while something in the container is still\n // being dragged. This can happen while we're waiting for the drop animation to finish\n // and can cause errors, because some elements might still be moving around.\n if (!container || (!container.isDragging() && !container.isReceiving())) {\n // Prevent the default action as soon as the dragging sequence is considered as\n // \"started\" since waiting for the next event can allow the device to begin scrolling.\n if (event.cancelable) {\n event.preventDefault();\n }\n this._hasStartedDragging.set(true);\n this._ngZone.run(() => this._startDragSequence(event));\n }\n }\n return;\n }\n // We prevent the default action down here so that we know that dragging has started. This is\n // important for touch devices where doing this too early can unnecessarily block scrolling,\n // if there's a dragging delay.\n if (event.cancelable) {\n event.preventDefault();\n }\n const constrainedPointerPosition = this._getConstrainedPointerPosition(pointerPosition);\n this._hasMoved = true;\n this._lastKnownPointerPosition = pointerPosition;\n this._updatePointerDirectionDelta(constrainedPointerPosition);\n if (this._dropContainer) {\n this._updateActiveDropContainer(constrainedPointerPosition, pointerPosition);\n }\n else {\n // If there's a position constraint function, we want the element's top/left to be at the\n // specific position on the page. Use the initial position as a reference if that's the case.\n const offset = this.constrainPosition ? this._initialDomRect : this._pickupPositionOnPage;\n const activeTransform = this._activeTransform;\n activeTransform.x = constrainedPointerPosition.x - offset.x + this._passiveTransform.x;\n activeTransform.y = constrainedPointerPosition.y - offset.y + this._passiveTransform.y;\n this._applyRootElementTransform(activeTransform.x, activeTransform.y);\n }\n // Since this event gets fired for every pixel while dragging, we only\n // want to fire it if the consumer opted into it. Also we have to\n // re-enter the zone because we run all of the events on the outside.\n if (this._moveEvents.observers.length) {\n this._ngZone.run(() => {\n this._moveEvents.next({\n source: this,\n pointerPosition: constrainedPointerPosition,\n event,\n distance: this._getDragDistance(constrainedPointerPosition),\n delta: this._pointerDirectionDelta,\n });\n });\n }\n };\n /** Handler that is invoked when the user lifts their pointer up, after initiating a drag. */\n _pointerUp = (event) => {\n this._endDragSequence(event);\n };\n /**\n * Clears subscriptions and stops the dragging sequence.\n * @param event Browser event object that ended the sequence.\n */\n _endDragSequence(event) {\n // Note that here we use `isDragging` from the service, rather than from `this`.\n // The difference is that the one from the service reflects whether a dragging sequence\n // has been initiated, whereas the one on `this` includes whether the user has passed\n // the minimum dragging threshold.\n if (!this._dragDropRegistry.isDragging(this)) {\n return;\n }\n this._removeListeners();\n this._dragDropRegistry.stopDragging(this);\n this._toggleNativeDragInteractions();\n if (this._handles) {\n this._rootElement.style.webkitTapHighlightColor =\n this._rootElementTapHighlight;\n }\n if (!this._hasStartedDragging()) {\n return;\n }\n this.released.next({ source: this, event });\n if (this._dropContainer) {\n // Stop scrolling immediately, instead of waiting for the animation to finish.\n this._dropContainer._stopScrolling();\n this._animatePreviewToPlaceholder().then(() => {\n this._cleanupDragArtifacts(event);\n this._cleanupCachedDimensions();\n this._dragDropRegistry.stopDragging(this);\n });\n }\n else {\n // Convert the active transform into a passive one. This means that next time\n // the user starts dragging the item, its position will be calculated relatively\n // to the new passive transform.\n this._passiveTransform.x = this._activeTransform.x;\n const pointerPosition = this._getPointerPositionOnPage(event);\n this._passiveTransform.y = this._activeTransform.y;\n this._ngZone.run(() => {\n this.ended.next({\n source: this,\n distance: this._getDragDistance(pointerPosition),\n dropPoint: pointerPosition,\n event,\n });\n });\n this._cleanupCachedDimensions();\n this._dragDropRegistry.stopDragging(this);\n }\n }\n /** Starts the dragging sequence. */\n _startDragSequence(event) {\n if (isTouchEvent(event)) {\n this._lastTouchEventTime = Date.now();\n }\n this._toggleNativeDragInteractions();\n // Needs to happen before the root element is moved.\n const shadowRoot = this._getShadowRoot();\n const dropContainer = this._dropContainer;\n if (shadowRoot) {\n // In some browsers the global `selectstart` that we maintain in the `DragDropRegistry`\n // doesn't cross the shadow boundary so we have to prevent it at the shadow root (see #28792).\n this._ngZone.runOutsideAngular(() => {\n shadowRoot.addEventListener('selectstart', shadowDomSelectStart, activeCapturingEventOptions$1);\n });\n }\n if (dropContainer) {\n const element = this._rootElement;\n const parent = element.parentNode;\n const placeholder = (this._placeholder = this._createPlaceholderElement());\n const anchor = (this._anchor =\n this._anchor ||\n this._document.createComment(typeof ngDevMode === 'undefined' || ngDevMode ? 'cdk-drag-anchor' : ''));\n // Insert an anchor node so that we can restore the element's position in the DOM.\n parent.insertBefore(anchor, element);\n // There's no risk of transforms stacking when inside a drop container so\n // we can keep the initial transform up to date any time dragging starts.\n this._initialTransform = element.style.transform || '';\n // Create the preview after the initial transform has\n // been cached, because it can be affected by the transform.\n this._preview = new PreviewRef(this._document, this._rootElement, this._direction, this._initialDomRect, this._previewTemplate || null, this.previewClass || null, this._pickupPositionOnPage, this._initialTransform, this._config.zIndex || 1000, this._renderer);\n this._preview.attach(this._getPreviewInsertionPoint(parent, shadowRoot));\n // We move the element out at the end of the body and we make it hidden, because keeping it in\n // place will throw off the consumer's `:last-child` selectors. We can't remove the element\n // from the DOM completely, because iOS will stop firing all subsequent events in the chain.\n toggleVisibility(element, false, dragImportantProperties);\n this._document.body.appendChild(parent.replaceChild(placeholder, element));\n this.started.next({ source: this, event }); // Emit before notifying the container.\n dropContainer.start();\n this._initialContainer = dropContainer;\n this._initialIndex = dropContainer.getItemIndex(this);\n }\n else {\n this.started.next({ source: this, event });\n this._initialContainer = this._initialIndex = undefined;\n }\n // Important to run after we've called `start` on the parent container\n // so that it has had time to resolve its scrollable parents.\n this._parentPositions.cache(dropContainer ? dropContainer.getScrollableParents() : []);\n }\n /**\n * Sets up the different variables and subscriptions\n * that will be necessary for the dragging sequence.\n * @param referenceElement Element that started the drag sequence.\n * @param event Browser event object that started the sequence.\n */\n _initializeDragSequence(referenceElement, event) {\n // Stop propagation if the item is inside another\n // draggable so we don't start multiple drag sequences.\n if (this._parentDragRef) {\n event.stopPropagation();\n }\n const isDragging = this.isDragging();\n const isTouchSequence = isTouchEvent(event);\n const isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;\n const rootElement = this._rootElement;\n const target = _getEventTarget(event);\n const isSyntheticEvent = !isTouchSequence &&\n this._lastTouchEventTime &&\n this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();\n const isFakeEvent = isTouchSequence\n ? isFakeTouchstartFromScreenReader(event)\n : isFakeMousedownFromScreenReader(event);\n // If the event started from an element with the native HTML drag&drop, it'll interfere\n // with our own dragging (e.g. `img` tags do it by default). Prevent the default action\n // to stop it from happening. Note that preventing on `dragstart` also seems to work, but\n // it's flaky and it fails if the user drags it away quickly. Also note that we only want\n // to do this for `mousedown` since doing the same for `touchstart` will stop any `click`\n // events from firing on touch devices.\n if (target && target.draggable && event.type === 'mousedown') {\n event.preventDefault();\n }\n // Abort if the user is already dragging or is using a mouse button other than the primary one.\n if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent || isFakeEvent) {\n return;\n }\n // If we've got handles, we need to disable the tap highlight on the entire root element,\n // otherwise iOS will still add it, even though all the drag interactions on the handle\n // are disabled.\n if (this._handles.length) {\n const rootStyles = rootElement.style;\n this._rootElementTapHighlight = rootStyles.webkitTapHighlightColor || '';\n rootStyles.webkitTapHighlightColor = 'transparent';\n }\n this._hasMoved = false;\n this._hasStartedDragging.set(this._hasMoved);\n // Avoid multiple subscriptions and memory leaks when multi touch\n // (isDragging check above isn't enough because of possible temporal and/or dimensional delays)\n this._removeListeners();\n this._initialDomRect = this._rootElement.getBoundingClientRect();\n this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);\n this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);\n this._scrollSubscription = this._dragDropRegistry\n .scrolled(this._getShadowRoot())\n .subscribe(scrollEvent => this._updateOnScroll(scrollEvent));\n if (this._boundaryElement) {\n this._boundaryRect = getMutableClientRect(this._boundaryElement);\n }\n // If we have a custom preview we can't know ahead of time how large it'll be so we position\n // it next to the cursor. The exception is when the consumer has opted into making the preview\n // the same size as the root element, in which case we do know the size.\n const previewTemplate = this._previewTemplate;\n this._pickupPositionInElement =\n previewTemplate && previewTemplate.template && !previewTemplate.matchSize\n ? { x: 0, y: 0 }\n : this._getPointerPositionInElement(this._initialDomRect, referenceElement, event);\n const pointerPosition = (this._pickupPositionOnPage =\n this._lastKnownPointerPosition =\n this._getPointerPositionOnPage(event));\n this._pointerDirectionDelta = { x: 0, y: 0 };\n this._pointerPositionAtLastDirectionChange = { x: pointerPosition.x, y: pointerPosition.y };\n this._dragStartTime = Date.now();\n this._dragDropRegistry.startDragging(this, event);\n }\n /** Cleans up the DOM artifacts that were added to facilitate the element being dragged. */\n _cleanupDragArtifacts(event) {\n // Restore the element's visibility and insert it at its old position in the DOM.\n // It's important that we maintain the position, because moving the element around in the DOM\n // can throw off `NgFor` which does smart diffing and re-creates elements only when necessary,\n // while moving the existing elements in all other cases.\n toggleVisibility(this._rootElement, true, dragImportantProperties);\n this._anchor.parentNode.replaceChild(this._rootElement, this._anchor);\n this._destroyPreview();\n this._destroyPlaceholder();\n this._initialDomRect =\n this._boundaryRect =\n this._previewRect =\n this._initialTransform =\n undefined;\n // Re-enter the NgZone since we bound `document` events on the outside.\n this._ngZone.run(() => {\n const container = this._dropContainer;\n const currentIndex = container.getItemIndex(this);\n const pointerPosition = this._getPointerPositionOnPage(event);\n const distance = this._getDragDistance(pointerPosition);\n const isPointerOverContainer = container._isOverContainer(pointerPosition.x, pointerPosition.y);\n this.ended.next({ source: this, distance, dropPoint: pointerPosition, event });\n this.dropped.next({\n item: this,\n currentIndex,\n previousIndex: this._initialIndex,\n container: container,\n previousContainer: this._initialContainer,\n isPointerOverContainer,\n distance,\n dropPoint: pointerPosition,\n event,\n });\n container.drop(this, currentIndex, this._initialIndex, this._initialContainer, isPointerOverContainer, distance, pointerPosition, event);\n this._dropContainer = this._initialContainer;\n });\n }\n /**\n * Updates the item's position in its drop container, or moves it\n * into a new one, depending on its current drag position.\n */\n _updateActiveDropContainer({ x, y }, { x: rawX, y: rawY }) {\n // Drop container that draggable has been moved into.\n let newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);\n // If we couldn't find a new container to move the item into, and the item has left its\n // initial container, check whether the it's over the initial container. This handles the\n // case where two containers are connected one way and the user tries to undo dragging an\n // item into a new container.\n if (!newContainer &&\n this._dropContainer !== this._initialContainer &&\n this._initialContainer._isOverContainer(x, y)) {\n newContainer = this._initialContainer;\n }\n if (newContainer && newContainer !== this._dropContainer) {\n this._ngZone.run(() => {\n // Notify the old container that the item has left.\n this.exited.next({ item: this, container: this._dropContainer });\n this._dropContainer.exit(this);\n // Notify the new container that the item has entered.\n this._dropContainer = newContainer;\n this._dropContainer.enter(this, x, y, newContainer === this._initialContainer &&\n // If we're re-entering the initial container and sorting is disabled,\n // put item the into its starting index to begin with.\n newContainer.sortingDisabled\n ? this._initialIndex\n : undefined);\n this.entered.next({\n item: this,\n container: newContainer,\n currentIndex: newContainer.getItemIndex(this),\n });\n });\n }\n // Dragging may have been interrupted as a result of the events above.\n if (this.isDragging()) {\n this._dropContainer._startScrollingIfNecessary(rawX, rawY);\n this._dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);\n if (this.constrainPosition) {\n this._applyPreviewTransform(x, y);\n }\n else {\n this._applyPreviewTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);\n }\n }\n }\n /**\n * Animates the preview element from its current position to the location of the drop placeholder.\n * @returns Promise that resolves when the animation completes.\n */\n _animatePreviewToPlaceholder() {\n // If the user hasn't moved yet, the transitionend event won't fire.\n if (!this._hasMoved) {\n return Promise.resolve();\n }\n const placeholderRect = this._placeholder.getBoundingClientRect();\n // Apply the class that adds a transition to the preview.\n this._preview.addClass('cdk-drag-animating');\n // Move the preview to the placeholder position.\n this._applyPreviewTransform(placeholderRect.left, placeholderRect.top);\n // If the element doesn't have a `transition`, the `transitionend` event won't fire. Since\n // we need to trigger a style recalculation in order for the `cdk-drag-animating` class to\n // apply its style, we take advantage of the available info to figure out whether we need to\n // bind the event in the first place.\n const duration = this._preview.getTransitionDuration();\n if (duration === 0) {\n return Promise.resolve();\n }\n return this._ngZone.runOutsideAngular(() => {\n return new Promise(resolve => {\n const handler = (event) => {\n if (!event ||\n (this._preview &&\n _getEventTarget(event) === this._preview.element &&\n event.propertyName === 'transform')) {\n cleanupListener();\n resolve();\n clearTimeout(timeout);\n }\n };\n // If a transition is short enough, the browser might not fire the `transitionend` event.\n // Since we know how long it's supposed to take, add a timeout with a 50% buffer that'll\n // fire if the transition hasn't completed when it was supposed to.\n const timeout = setTimeout(handler, duration * 1.5);\n const cleanupListener = this._preview.addEventListener('transitionend', handler);\n });\n });\n }\n /** Creates an element that will be shown instead of the current element while dragging. */\n _createPlaceholderElement() {\n const placeholderConfig = this._placeholderTemplate;\n const placeholderTemplate = placeholderConfig ? placeholderConfig.template : null;\n let placeholder;\n if (placeholderTemplate) {\n this._placeholderRef = placeholderConfig.viewContainer.createEmbeddedView(placeholderTemplate, placeholderConfig.context);\n this._placeholderRef.detectChanges();\n placeholder = getRootNode(this._placeholderRef, this._document);\n }\n else {\n placeholder = deepCloneNode(this._rootElement);\n }\n // Stop pointer events on the preview so the user can't\n // interact with it while the preview is animating.\n placeholder.style.pointerEvents = 'none';\n placeholder.classList.add('cdk-drag-placeholder');\n return placeholder;\n }\n /**\n * Figures out the coordinates at which an element was picked up.\n * @param referenceElement Element that initiated the dragging.\n * @param event Event that initiated the dragging.\n */\n _getPointerPositionInElement(elementRect, referenceElement, event) {\n const handleElement = referenceElement === this._rootElement ? null : referenceElement;\n const referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;\n const point = isTouchEvent(event) ? event.targetTouches[0] : event;\n const scrollPosition = this._getViewportScrollPosition();\n const x = point.pageX - referenceRect.left - scrollPosition.left;\n const y = point.pageY - referenceRect.top - scrollPosition.top;\n return {\n x: referenceRect.left - elementRect.left + x,\n y: referenceRect.top - elementRect.top + y,\n };\n }\n /** Determines the point of the page that was touched by the user. */\n _getPointerPositionOnPage(event) {\n const scrollPosition = this._getViewportScrollPosition();\n const point = isTouchEvent(event)\n ? // `touches` will be empty for start/end events so we have to fall back to `changedTouches`.\n // Also note that on real devices we're guaranteed for either `touches` or `changedTouches`\n // to have a value, but Firefox in device emulation mode has a bug where both can be empty\n // for `touchstart` and `touchend` so we fall back to a dummy object in order to avoid\n // throwing an error. The value returned here will be incorrect, but since this only\n // breaks inside a developer tool and the value is only used for secondary information,\n // we can get away with it. See https://bugzilla.mozilla.org/show_bug.cgi?id=1615824.\n event.touches[0] || event.changedTouches[0] || { pageX: 0, pageY: 0 }\n : event;\n const x = point.pageX - scrollPosition.left;\n const y = point.pageY - scrollPosition.top;\n // if dragging SVG element, try to convert from the screen coordinate system to the SVG\n // coordinate system\n if (this._ownerSVGElement) {\n const svgMatrix = this._ownerSVGElement.getScreenCTM();\n if (svgMatrix) {\n const svgPoint = this._ownerSVGElement.createSVGPoint();\n svgPoint.x = x;\n svgPoint.y = y;\n return svgPoint.matrixTransform(svgMatrix.inverse());\n }\n }\n return { x, y };\n }\n /** Gets the pointer position on the page, accounting for any position constraints. */\n _getConstrainedPointerPosition(point) {\n const dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;\n let { x, y } = this.constrainPosition\n ? this.constrainPosition(point, this, this._initialDomRect, this._pickupPositionInElement)\n : point;\n if (this.lockAxis === 'x' || dropContainerLock === 'x') {\n y =\n this._pickupPositionOnPage.y -\n (this.constrainPosition ? this._pickupPositionInElement.y : 0);\n }\n else if (this.lockAxis === 'y' || dropContainerLock === 'y') {\n x =\n this._pickupPositionOnPage.x -\n (this.constrainPosition ? this._pickupPositionInElement.x : 0);\n }\n if (this._boundaryRect) {\n // If not using a custom constrain we need to account for the pickup position in the element\n // otherwise we do not need to do this, as it has already been accounted for\n const { x: pickupX, y: pickupY } = !this.constrainPosition\n ? this._pickupPositionInElement\n : { x: 0, y: 0 };\n const boundaryRect = this._boundaryRect;\n const { width: previewWidth, height: previewHeight } = this._getPreviewRect();\n const minY = boundaryRect.top + pickupY;\n const maxY = boundaryRect.bottom - (previewHeight - pickupY);\n const minX = boundaryRect.left + pickupX;\n const maxX = boundaryRect.right - (previewWidth - pickupX);\n x = clamp$1(x, minX, maxX);\n y = clamp$1(y, minY, maxY);\n }\n return { x, y };\n }\n /** Updates the current drag delta, based on the user's current pointer position on the page. */\n _updatePointerDirectionDelta(pointerPositionOnPage) {\n const { x, y } = pointerPositionOnPage;\n const delta = this._pointerDirectionDelta;\n const positionSinceLastChange = this._pointerPositionAtLastDirectionChange;\n // Amount of pixels the user has dragged since the last time the direction changed.\n const changeX = Math.abs(x - positionSinceLastChange.x);\n const changeY = Math.abs(y - positionSinceLastChange.y);\n // Because we handle pointer events on a per-pixel basis, we don't want the delta\n // to change for every pixel, otherwise anything that depends on it can look erratic.\n // To make the delta more consistent, we track how much the user has moved since the last\n // delta change and we only update it after it has reached a certain threshold.\n if (changeX > this._config.pointerDirectionChangeThreshold) {\n delta.x = x > positionSinceLastChange.x ? 1 : -1;\n positionSinceLastChange.x = x;\n }\n if (changeY > this._config.pointerDirectionChangeThreshold) {\n delta.y = y > positionSinceLastChange.y ? 1 : -1;\n positionSinceLastChange.y = y;\n }\n return delta;\n }\n /** Toggles the native drag interactions, based on how many handles are registered. */\n _toggleNativeDragInteractions() {\n if (!this._rootElement || !this._handles) {\n return;\n }\n const shouldEnable = this._handles.length > 0 || !this.isDragging();\n if (shouldEnable !== this._nativeInteractionsEnabled) {\n this._nativeInteractionsEnabled = shouldEnable;\n toggleNativeDragInteractions(this._rootElement, shouldEnable);\n }\n }\n /** Removes the manually-added event listeners from the root element. */\n _removeRootElementListeners(element) {\n element.removeEventListener('mousedown', this._pointerDown, activeEventListenerOptions);\n element.removeEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);\n element.removeEventListener('dragstart', this._nativeDragStart, activeEventListenerOptions);\n }\n /**\n * Applies a `transform` to the root element, taking into account any existing transforms on it.\n * @param x New transform value along the X axis.\n * @param y New transform value along the Y axis.\n */\n _applyRootElementTransform(x, y) {\n const scale = 1 / this.scale;\n const transform = getTransform(x * scale, y * scale);\n const styles = this._rootElement.style;\n // Cache the previous transform amount only after the first drag sequence, because\n // we don't want our own transforms to stack on top of each other.\n // Should be excluded none because none + translate3d(x, y, x) is invalid css\n if (this._initialTransform == null) {\n this._initialTransform =\n styles.transform && styles.transform != 'none' ? styles.transform : '';\n }\n // Preserve the previous `transform` value, if there was one. Note that we apply our own\n // transform before the user's, because things like rotation can affect which direction\n // the element will be translated towards.\n styles.transform = combineTransforms(transform, this._initialTransform);\n }\n /**\n * Applies a `transform` to the preview, taking into account any existing transforms on it.\n * @param x New transform value along the X axis.\n * @param y New transform value along the Y axis.\n */\n _applyPreviewTransform(x, y) {\n // Only apply the initial transform if the preview is a clone of the original element, otherwise\n // it could be completely different and the transform might not make sense anymore.\n const initialTransform = this._previewTemplate?.template ? undefined : this._initialTransform;\n const transform = getTransform(x, y);\n this._preview.setTransform(combineTransforms(transform, initialTransform));\n }\n /**\n * Gets the distance that the user has dragged during the current drag sequence.\n * @param currentPosition Current position of the user's pointer.\n */\n _getDragDistance(currentPosition) {\n const pickupPosition = this._pickupPositionOnPage;\n if (pickupPosition) {\n return { x: currentPosition.x - pickupPosition.x, y: currentPosition.y - pickupPosition.y };\n }\n return { x: 0, y: 0 };\n }\n /** Cleans up any cached element dimensions that we don't need after dragging has stopped. */\n _cleanupCachedDimensions() {\n this._boundaryRect = this._previewRect = undefined;\n this._parentPositions.clear();\n }\n /**\n * Checks whether the element is still inside its boundary after the viewport has been resized.\n * If not, the position is adjusted so that the element fits again.\n */\n _containInsideBoundaryOnResize() {\n let { x, y } = this._passiveTransform;\n if ((x === 0 && y === 0) || this.isDragging() || !this._boundaryElement) {\n return;\n }\n // Note: don't use `_clientRectAtStart` here, because we want the latest position.\n const elementRect = this._rootElement.getBoundingClientRect();\n const boundaryRect = this._boundaryElement.getBoundingClientRect();\n // It's possible that the element got hidden away after dragging (e.g. by switching to a\n // different tab). Don't do anything in this case so we don't clear the user's position.\n if ((boundaryRect.width === 0 && boundaryRect.height === 0) ||\n (elementRect.width === 0 && elementRect.height === 0)) {\n return;\n }\n const leftOverflow = boundaryRect.left - elementRect.left;\n const rightOverflow = elementRect.right - boundaryRect.right;\n const topOverflow = boundaryRect.top - elementRect.top;\n const bottomOverflow = elementRect.bottom - boundaryRect.bottom;\n // If the element has become wider than the boundary, we can't\n // do much to make it fit so we just anchor it to the left.\n if (boundaryRect.width > elementRect.width) {\n if (leftOverflow > 0) {\n x += leftOverflow;\n }\n if (rightOverflow > 0) {\n x -= rightOverflow;\n }\n }\n else {\n x = 0;\n }\n // If the element has become taller than the boundary, we can't\n // do much to make it fit so we just anchor it to the top.\n if (boundaryRect.height > elementRect.height) {\n if (topOverflow > 0) {\n y += topOverflow;\n }\n if (bottomOverflow > 0) {\n y -= bottomOverflow;\n }\n }\n else {\n y = 0;\n }\n if (x !== this._passiveTransform.x || y !== this._passiveTransform.y) {\n this.setFreeDragPosition({ y, x });\n }\n }\n /** Gets the drag start delay, based on the event type. */\n _getDragStartDelay(event) {\n const value = this.dragStartDelay;\n if (typeof value === 'number') {\n return value;\n }\n else if (isTouchEvent(event)) {\n return value.touch;\n }\n return value ? value.mouse : 0;\n }\n /** Updates the internal state of the draggable element when scrolling has occurred. */\n _updateOnScroll(event) {\n const scrollDifference = this._parentPositions.handleScroll(event);\n if (scrollDifference) {\n const target = _getEventTarget(event);\n // DOMRect dimensions are based on the scroll position of the page and its parent\n // node so we have to update the cached boundary DOMRect if the user has scrolled.\n if (this._boundaryRect &&\n target !== this._boundaryElement &&\n target.contains(this._boundaryElement)) {\n adjustDomRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);\n }\n this._pickupPositionOnPage.x += scrollDifference.left;\n this._pickupPositionOnPage.y += scrollDifference.top;\n // If we're in free drag mode, we have to update the active transform, because\n // it isn't relative to the viewport like the preview inside a drop list.\n if (!this._dropContainer) {\n this._activeTransform.x -= scrollDifference.left;\n this._activeTransform.y -= scrollDifference.top;\n this._applyRootElementTransform(this._activeTransform.x, this._activeTransform.y);\n }\n }\n }\n /** Gets the scroll position of the viewport. */\n _getViewportScrollPosition() {\n return (this._parentPositions.positions.get(this._document)?.scrollPosition ||\n this._parentPositions.getViewportScrollPosition());\n }\n /**\n * Lazily resolves and returns the shadow root of the element. We do this in a function, rather\n * than saving it in property directly on init, because we want to resolve it as late as possible\n * in order to ensure that the element has been moved into the shadow DOM. Doing it inside the\n * constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.\n */\n _getShadowRoot() {\n if (this._cachedShadowRoot === undefined) {\n this._cachedShadowRoot = _getShadowRoot(this._rootElement);\n }\n return this._cachedShadowRoot;\n }\n /** Gets the element into which the drag preview should be inserted. */\n _getPreviewInsertionPoint(initialParent, shadowRoot) {\n const previewContainer = this._previewContainer || 'global';\n if (previewContainer === 'parent') {\n return initialParent;\n }\n if (previewContainer === 'global') {\n const documentRef = this._document;\n // We can't use the body if the user is in fullscreen mode,\n // because the preview will render under the fullscreen element.\n // TODO(crisbeto): dedupe this with the `FullscreenOverlayContainer` eventually.\n return (shadowRoot ||\n documentRef.fullscreenElement ||\n documentRef.webkitFullscreenElement ||\n documentRef.mozFullScreenElement ||\n documentRef.msFullscreenElement ||\n documentRef.body);\n }\n return coerceElement(previewContainer);\n }\n /** Lazily resolves and returns the dimensions of the preview. */\n _getPreviewRect() {\n // Cache the preview element rect if we haven't cached it already or if\n // we cached it too early before the element dimensions were computed.\n if (!this._previewRect || (!this._previewRect.width && !this._previewRect.height)) {\n this._previewRect = this._preview\n ? this._preview.getBoundingClientRect()\n : this._initialDomRect;\n }\n return this._previewRect;\n }\n /** Handles a native `dragstart` event. */\n _nativeDragStart = (event) => {\n if (this._handles.length) {\n const targetHandle = this._getTargetHandle(event);\n if (targetHandle && !this._disabledHandles.has(targetHandle) && !this.disabled) {\n event.preventDefault();\n }\n }\n else if (!this.disabled) {\n // Usually this isn't necessary since the we prevent the default action in `pointerDown`,\n // but some cases like dragging of links can slip through (see #24403).\n event.preventDefault();\n }\n };\n /** Gets a handle that is the target of an event. */\n _getTargetHandle(event) {\n return this._handles.find(handle => {\n return event.target && (event.target === handle || handle.contains(event.target));\n });\n }\n}\n/** Clamps a value between a minimum and a maximum. */\nfunction clamp$1(value, min, max) {\n return Math.max(min, Math.min(max, value));\n}\n/** Determines whether an event is a touch event. */\nfunction isTouchEvent(event) {\n // This function is called for every pixel that the user has dragged so we need it to be\n // as fast as possible. Since we only bind mouse events and touch events, we can assume\n // that if the event's name starts with `t`, it's a touch event.\n return event.type[0] === 't';\n}\n/** Callback invoked for `selectstart` events inside the shadow DOM. */\nfunction shadowDomSelectStart(event) {\n event.preventDefault();\n}\n\n/**\n * Moves an item one index in an array to another.\n * @param array Array in which to move the item.\n * @param fromIndex Starting index of the item.\n * @param toIndex Index to which the item should be moved.\n */\nfunction moveItemInArray(array, fromIndex, toIndex) {\n const from = clamp(fromIndex, array.length - 1);\n const to = clamp(toIndex, array.length - 1);\n if (from === to) {\n return;\n }\n const target = array[from];\n const delta = to < from ? -1 : 1;\n for (let i = from; i !== to; i += delta) {\n array[i] = array[i + delta];\n }\n array[to] = target;\n}\n/**\n * Moves an item from one array to another.\n * @param currentArray Array from which to transfer the item.\n * @param targetArray Array into which to put the item.\n * @param currentIndex Index of the item in its current array.\n * @param targetIndex Index at which to insert the item.\n */\nfunction transferArrayItem(currentArray, targetArray, currentIndex, targetIndex) {\n const from = clamp(currentIndex, currentArray.length - 1);\n const to = clamp(targetIndex, targetArray.length);\n if (currentArray.length) {\n targetArray.splice(to, 0, currentArray.splice(from, 1)[0]);\n }\n}\n/**\n * Copies an item from one array to another, leaving it in its\n * original position in current array.\n * @param currentArray Array from which to copy the item.\n * @param targetArray Array into which is copy the item.\n * @param currentIndex Index of the item in its current array.\n * @param targetIndex Index at which to insert the item.\n *\n */\nfunction copyArrayItem(currentArray, targetArray, currentIndex, targetIndex) {\n const to = clamp(targetIndex, targetArray.length);\n if (currentArray.length) {\n targetArray.splice(to, 0, currentArray[currentIndex]);\n }\n}\n/** Clamps a number between zero and a maximum. */\nfunction clamp(value, max) {\n return Math.max(0, Math.min(max, value));\n}\n\n/**\n * Strategy that only supports sorting along a single axis.\n * Items are reordered using CSS transforms which allows for sorting to be animated.\n * @docs-private\n */\nclass SingleAxisSortStrategy {\n _dragDropRegistry;\n /** Root element container of the drop list. */\n _element;\n /** Function used to determine if an item can be sorted into a specific index. */\n _sortPredicate;\n /** Cache of the dimensions of all the items inside the container. */\n _itemPositions = [];\n /**\n * Draggable items that are currently active inside the container. Includes the items\n * that were there at the start of the sequence, as well as any items that have been dragged\n * in, but haven't been dropped yet.\n */\n _activeDraggables;\n /** Direction in which the list is oriented. */\n orientation = 'vertical';\n /** Layout direction of the drop list. */\n direction;\n constructor(_dragDropRegistry) {\n this._dragDropRegistry = _dragDropRegistry;\n }\n /**\n * Keeps track of the item that was last swapped with the dragged item, as well as what direction\n * the pointer was moving in when the swap occurred and whether the user's pointer continued to\n * overlap with the swapped item after the swapping occurred.\n */\n _previousSwap = {\n drag: null,\n delta: 0,\n overlaps: false,\n };\n /**\n * To be called when the drag sequence starts.\n * @param items Items that are currently in the list.\n */\n start(items) {\n this.withItems(items);\n }\n /**\n * To be called when an item is being sorted.\n * @param item Item to be sorted.\n * @param pointerX Position of the item along the X axis.\n * @param pointerY Position of the item along the Y axis.\n * @param pointerDelta Direction in which the pointer is moving along each axis.\n */\n sort(item, pointerX, pointerY, pointerDelta) {\n const siblings = this._itemPositions;\n const newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);\n if (newIndex === -1 && siblings.length > 0) {\n return null;\n }\n const isHorizontal = this.orientation === 'horizontal';\n const currentIndex = siblings.findIndex(currentItem => currentItem.drag === item);\n const siblingAtNewPosition = siblings[newIndex];\n const currentPosition = siblings[currentIndex].clientRect;\n const newPosition = siblingAtNewPosition.clientRect;\n const delta = currentIndex > newIndex ? 1 : -1;\n // How many pixels the item's placeholder should be offset.\n const itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);\n // How many pixels all the other items should be offset.\n const siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);\n // Save the previous order of the items before moving the item to its new index.\n // We use this to check whether an item has been moved as a result of the sorting.\n const oldOrder = siblings.slice();\n // Shuffle the array in place.\n moveItemInArray(siblings, currentIndex, newIndex);\n siblings.forEach((sibling, index) => {\n // Don't do anything if the position hasn't changed.\n if (oldOrder[index] === sibling) {\n return;\n }\n const isDraggedItem = sibling.drag === item;\n const offset = isDraggedItem ? itemOffset : siblingOffset;\n const elementToOffset = isDraggedItem\n ? item.getPlaceholderElement()\n : sibling.drag.getRootElement();\n // Update the offset to reflect the new position.\n sibling.offset += offset;\n const transformAmount = Math.round(sibling.offset * (1 / sibling.drag.scale));\n // Since we're moving the items with a `transform`, we need to adjust their cached\n // client rects to reflect their new position, as well as swap their positions in the cache.\n // Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the\n // elements may be mid-animation which will give us a wrong result.\n if (isHorizontal) {\n // Round the transforms since some browsers will\n // blur the elements, for sub-pixel transforms.\n elementToOffset.style.transform = combineTransforms(`translate3d(${transformAmount}px, 0, 0)`, sibling.initialTransform);\n adjustDomRect(sibling.clientRect, 0, offset);\n }\n else {\n elementToOffset.style.transform = combineTransforms(`translate3d(0, ${transformAmount}px, 0)`, sibling.initialTransform);\n adjustDomRect(sibling.clientRect, offset, 0);\n }\n });\n // Note that it's important that we do this after the client rects have been adjusted.\n this._previousSwap.overlaps = isInsideClientRect(newPosition, pointerX, pointerY);\n this._previousSwap.drag = siblingAtNewPosition.drag;\n this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;\n return { previousIndex: currentIndex, currentIndex: newIndex };\n }\n /**\n * Called when an item is being moved into the container.\n * @param item Item that was moved into the container.\n * @param pointerX Position of the item along the X axis.\n * @param pointerY Position of the item along the Y axis.\n * @param index Index at which the item entered. If omitted, the container will try to figure it\n * out automatically.\n */\n enter(item, pointerX, pointerY, index) {\n const newIndex = index == null || index < 0\n ? // We use the coordinates of where the item entered the drop\n // zone to figure out at which index it should be inserted.\n this._getItemIndexFromPointerPosition(item, pointerX, pointerY)\n : index;\n const activeDraggables = this._activeDraggables;\n const currentIndex = activeDraggables.indexOf(item);\n const placeholder = item.getPlaceholderElement();\n let newPositionReference = activeDraggables[newIndex];\n // If the item at the new position is the same as the item that is being dragged,\n // it means that we're trying to restore the item to its initial position. In this\n // case we should use the next item from the list as the reference.\n if (newPositionReference === item) {\n newPositionReference = activeDraggables[newIndex + 1];\n }\n // If we didn't find a new position reference, it means that either the item didn't start off\n // in this container, or that the item requested to be inserted at the end of the list.\n if (!newPositionReference &&\n (newIndex == null || newIndex === -1 || newIndex < activeDraggables.length - 1) &&\n this._shouldEnterAsFirstChild(pointerX, pointerY)) {\n newPositionReference = activeDraggables[0];\n }\n // Since the item may be in the `activeDraggables` already (e.g. if the user dragged it\n // into another container and back again), we have to ensure that it isn't duplicated.\n if (currentIndex > -1) {\n activeDraggables.splice(currentIndex, 1);\n }\n // Don't use items that are being dragged as a reference, because\n // their element has been moved down to the bottom of the body.\n if (newPositionReference && !this._dragDropRegistry.isDragging(newPositionReference)) {\n const element = newPositionReference.getRootElement();\n element.parentElement.insertBefore(placeholder, element);\n activeDraggables.splice(newIndex, 0, item);\n }\n else {\n this._element.appendChild(placeholder);\n activeDraggables.push(item);\n }\n // The transform needs to be cleared so it doesn't throw off the measurements.\n placeholder.style.transform = '';\n // Note that usually `start` is called together with `enter` when an item goes into a new\n // container. This will cache item positions, but we need to refresh them since the amount\n // of items has changed.\n this._cacheItemPositions();\n }\n /** Sets the items that are currently part of the list. */\n withItems(items) {\n this._activeDraggables = items.slice();\n this._cacheItemPositions();\n }\n /** Assigns a sort predicate to the strategy. */\n withSortPredicate(predicate) {\n this._sortPredicate = predicate;\n }\n /** Resets the strategy to its initial state before dragging was started. */\n reset() {\n // TODO(crisbeto): may have to wait for the animations to finish.\n this._activeDraggables?.forEach(item => {\n const rootElement = item.getRootElement();\n if (rootElement) {\n const initialTransform = this._itemPositions.find(p => p.drag === item)?.initialTransform;\n rootElement.style.transform = initialTransform || '';\n }\n });\n this._itemPositions = [];\n this._activeDraggables = [];\n this._previousSwap.drag = null;\n this._previousSwap.delta = 0;\n this._previousSwap.overlaps = false;\n }\n /**\n * Gets a snapshot of items currently in the list.\n * Can include items that we dragged in from another list.\n */\n getActiveItemsSnapshot() {\n return this._activeDraggables;\n }\n /** Gets the index of a specific item. */\n getItemIndex(item) {\n // Items are sorted always by top/left in the cache, however they flow differently in RTL.\n // The rest of the logic still stands no matter what orientation we're in, however\n // we need to invert the array when determining the index.\n const items = this.orientation === 'horizontal' && this.direction === 'rtl'\n ? this._itemPositions.slice().reverse()\n : this._itemPositions;\n return items.findIndex(currentItem => currentItem.drag === item);\n }\n /** Used to notify the strategy that the scroll position has changed. */\n updateOnScroll(topDifference, leftDifference) {\n // Since we know the amount that the user has scrolled we can shift all of the\n // client rectangles ourselves. This is cheaper than re-measuring everything and\n // we can avoid inconsistent behavior where we might be measuring the element before\n // its position has changed.\n this._itemPositions.forEach(({ clientRect }) => {\n adjustDomRect(clientRect, topDifference, leftDifference);\n });\n // We need two loops for this, because we want all of the cached\n // positions to be up-to-date before we re-sort the item.\n this._itemPositions.forEach(({ drag }) => {\n if (this._dragDropRegistry.isDragging(drag)) {\n // We need to re-sort the item manually, because the pointer move\n // events won't be dispatched while the user is scrolling.\n drag._sortFromLastPointerPosition();\n }\n });\n }\n withElementContainer(container) {\n this._element = container;\n }\n /** Refreshes the position cache of the items and sibling containers. */\n _cacheItemPositions() {\n const isHorizontal = this.orientation === 'horizontal';\n this._itemPositions = this._activeDraggables\n .map(drag => {\n const elementToMeasure = drag.getVisibleElement();\n return {\n drag,\n offset: 0,\n initialTransform: elementToMeasure.style.transform || '',\n clientRect: getMutableClientRect(elementToMeasure),\n };\n })\n .sort((a, b) => {\n return isHorizontal\n ? a.clientRect.left - b.clientRect.left\n : a.clientRect.top - b.clientRect.top;\n });\n }\n /**\n * Gets the offset in pixels by which the item that is being dragged should be moved.\n * @param currentPosition Current position of the item.\n * @param newPosition Position of the item where the current item should be moved.\n * @param delta Direction in which the user is moving.\n */\n _getItemOffsetPx(currentPosition, newPosition, delta) {\n const isHorizontal = this.orientation === 'horizontal';\n let itemOffset = isHorizontal\n ? newPosition.left - currentPosition.left\n : newPosition.top - currentPosition.top;\n // Account for differences in the item width/height.\n if (delta === -1) {\n itemOffset += isHorizontal\n ? newPosition.width - currentPosition.width\n : newPosition.height - currentPosition.height;\n }\n return itemOffset;\n }\n /**\n * Gets the offset in pixels by which the items that aren't being dragged should be moved.\n * @param currentIndex Index of the item currently being dragged.\n * @param siblings All of the items in the list.\n * @param delta Direction in which the user is moving.\n */\n _getSiblingOffsetPx(currentIndex, siblings, delta) {\n const isHorizontal = this.orientation === 'horizontal';\n const currentPosition = siblings[currentIndex].clientRect;\n const immediateSibling = siblings[currentIndex + delta * -1];\n let siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;\n if (immediateSibling) {\n const start = isHorizontal ? 'left' : 'top';\n const end = isHorizontal ? 'right' : 'bottom';\n // Get the spacing between the start of the current item and the end of the one immediately\n // after it in the direction in which the user is dragging, or vice versa. We add it to the\n // offset in order to push the element to where it will be when it's inline and is influenced\n // by the `margin` of its siblings.\n if (delta === -1) {\n siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];\n }\n else {\n siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];\n }\n }\n return siblingOffset;\n }\n /**\n * Checks if pointer is entering in the first position\n * @param pointerX Position of the user's pointer along the X axis.\n * @param pointerY Position of the user's pointer along the Y axis.\n */\n _shouldEnterAsFirstChild(pointerX, pointerY) {\n if (!this._activeDraggables.length) {\n return false;\n }\n const itemPositions = this._itemPositions;\n const isHorizontal = this.orientation === 'horizontal';\n // `itemPositions` are sorted by position while `activeDraggables` are sorted by child index\n // check if container is using some sort of \"reverse\" ordering (eg: flex-direction: row-reverse)\n const reversed = itemPositions[0].drag !== this._activeDraggables[0];\n if (reversed) {\n const lastItemRect = itemPositions[itemPositions.length - 1].clientRect;\n return isHorizontal ? pointerX >= lastItemRect.right : pointerY >= lastItemRect.bottom;\n }\n else {\n const firstItemRect = itemPositions[0].clientRect;\n return isHorizontal ? pointerX <= firstItemRect.left : pointerY <= firstItemRect.top;\n }\n }\n /**\n * Gets the index of an item in the drop container, based on the position of the user's pointer.\n * @param item Item that is being sorted.\n * @param pointerX Position of the user's pointer along the X axis.\n * @param pointerY Position of the user's pointer along the Y axis.\n * @param delta Direction in which the user is moving their pointer.\n */\n _getItemIndexFromPointerPosition(item, pointerX, pointerY, delta) {\n const isHorizontal = this.orientation === 'horizontal';\n const index = this._itemPositions.findIndex(({ drag, clientRect }) => {\n // Skip the item itself.\n if (drag === item) {\n return false;\n }\n if (delta) {\n const direction = isHorizontal ? delta.x : delta.y;\n // If the user is still hovering over the same item as last time, their cursor hasn't left\n // the item after we made the swap, and they didn't change the direction in which they're\n // dragging, we don't consider it a direction swap.\n if (drag === this._previousSwap.drag &&\n this._previousSwap.overlaps &&\n direction === this._previousSwap.delta) {\n return false;\n }\n }\n return isHorizontal\n ? // Round these down since most browsers report client rects with\n // sub-pixel precision, whereas the pointer coordinates are rounded to pixels.\n pointerX >= Math.floor(clientRect.left) && pointerX < Math.floor(clientRect.right)\n : pointerY >= Math.floor(clientRect.top) && pointerY < Math.floor(clientRect.bottom);\n });\n return index === -1 || !this._sortPredicate(index, item) ? -1 : index;\n }\n}\n\n/**\n * Strategy that only supports sorting on a list that might wrap.\n * Items are reordered by moving their DOM nodes around.\n * @docs-private\n */\nclass MixedSortStrategy {\n _document;\n _dragDropRegistry;\n /** Root element container of the drop list. */\n _element;\n /** Function used to determine if an item can be sorted into a specific index. */\n _sortPredicate;\n /** Lazily-resolved root node containing the list. Use `_getRootNode` to read this. */\n _rootNode;\n /**\n * Draggable items that are currently active inside the container. Includes the items\n * that were there at the start of the sequence, as well as any items that have been dragged\n * in, but haven't been dropped yet.\n */\n _activeItems;\n /**\n * Keeps track of the item that was last swapped with the dragged item, as well as what direction\n * the pointer was moving in when the swap occurred and whether the user's pointer continued to\n * overlap with the swapped item after the swapping occurred.\n */\n _previousSwap = {\n drag: null,\n deltaX: 0,\n deltaY: 0,\n overlaps: false,\n };\n /**\n * Keeps track of the relationship between a node and its next sibling. This information\n * is used to restore the DOM to the order it was in before dragging started.\n */\n _relatedNodes = [];\n constructor(_document, _dragDropRegistry) {\n this._document = _document;\n this._dragDropRegistry = _dragDropRegistry;\n }\n /**\n * To be called when the drag sequence starts.\n * @param items Items that are currently in the list.\n */\n start(items) {\n const childNodes = this._element.childNodes;\n this._relatedNodes = [];\n for (let i = 0; i < childNodes.length; i++) {\n const node = childNodes[i];\n this._relatedNodes.push([node, node.nextSibling]);\n }\n this.withItems(items);\n }\n /**\n * To be called when an item is being sorted.\n * @param item Item to be sorted.\n * @param pointerX Position of the item along the X axis.\n * @param pointerY Position of the item along the Y axis.\n * @param pointerDelta Direction in which the pointer is moving along each axis.\n */\n sort(item, pointerX, pointerY, pointerDelta) {\n const newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);\n const previousSwap = this._previousSwap;\n if (newIndex === -1 || this._activeItems[newIndex] === item) {\n return null;\n }\n const toSwapWith = this._activeItems[newIndex];\n // Prevent too many swaps over the same item.\n if (previousSwap.drag === toSwapWith &&\n previousSwap.overlaps &&\n previousSwap.deltaX === pointerDelta.x &&\n previousSwap.deltaY === pointerDelta.y) {\n return null;\n }\n const previousIndex = this.getItemIndex(item);\n const current = item.getPlaceholderElement();\n const overlapElement = toSwapWith.getRootElement();\n if (newIndex > previousIndex) {\n overlapElement.after(current);\n }\n else {\n overlapElement.before(current);\n }\n moveItemInArray(this._activeItems, previousIndex, newIndex);\n const newOverlapElement = this._getRootNode().elementFromPoint(pointerX, pointerY);\n // Note: it's tempting to save the entire `pointerDelta` object here, however that'll\n // break this functionality, because the same object is passed for all `sort` calls.\n previousSwap.deltaX = pointerDelta.x;\n previousSwap.deltaY = pointerDelta.y;\n previousSwap.drag = toSwapWith;\n previousSwap.overlaps =\n overlapElement === newOverlapElement || overlapElement.contains(newOverlapElement);\n return {\n previousIndex,\n currentIndex: newIndex,\n };\n }\n /**\n * Called when an item is being moved into the container.\n * @param item Item that was moved into the container.\n * @param pointerX Position of the item along the X axis.\n * @param pointerY Position of the item along the Y axis.\n * @param index Index at which the item entered. If omitted, the container will try to figure it\n * out automatically.\n */\n enter(item, pointerX, pointerY, index) {\n let enterIndex = index == null || index < 0\n ? this._getItemIndexFromPointerPosition(item, pointerX, pointerY)\n : index;\n // In some cases (e.g. when the container has padding) we might not be able to figure\n // out which item to insert the dragged item next to, because the pointer didn't overlap\n // with anything. In that case we find the item that's closest to the pointer.\n if (enterIndex === -1) {\n enterIndex = this._getClosestItemIndexToPointer(item, pointerX, pointerY);\n }\n const targetItem = this._activeItems[enterIndex];\n const currentIndex = this._activeItems.indexOf(item);\n if (currentIndex > -1) {\n this._activeItems.splice(currentIndex, 1);\n }\n if (targetItem && !this._dragDropRegistry.isDragging(targetItem)) {\n this._activeItems.splice(enterIndex, 0, item);\n targetItem.getRootElement().before(item.getPlaceholderElement());\n }\n else {\n this._activeItems.push(item);\n this._element.appendChild(item.getPlaceholderElement());\n }\n }\n /** Sets the items that are currently part of the list. */\n withItems(items) {\n this._activeItems = items.slice();\n }\n /** Assigns a sort predicate to the strategy. */\n withSortPredicate(predicate) {\n this._sortPredicate = predicate;\n }\n /** Resets the strategy to its initial state before dragging was started. */\n reset() {\n const root = this._element;\n const previousSwap = this._previousSwap;\n // Moving elements around in the DOM can break things like the `@for` loop, because it\n // uses comment nodes to know where to insert elements. To avoid such issues, we restore\n // the DOM nodes in the list to their original order when the list is reset.\n // Note that this could be simpler if we just saved all the nodes, cleared the root\n // and then appended them in the original order. We don't do it, because it can break\n // down depending on when the snapshot was taken. E.g. we may end up snapshotting the\n // placeholder element which is removed after dragging.\n for (let i = this._relatedNodes.length - 1; i > -1; i--) {\n const [node, nextSibling] = this._relatedNodes[i];\n if (node.parentNode === root && node.nextSibling !== nextSibling) {\n if (nextSibling === null) {\n root.appendChild(node);\n }\n else if (nextSibling.parentNode === root) {\n root.insertBefore(node, nextSibling);\n }\n }\n }\n this._relatedNodes = [];\n this._activeItems = [];\n previousSwap.drag = null;\n previousSwap.deltaX = previousSwap.deltaY = 0;\n previousSwap.overlaps = false;\n }\n /**\n * Gets a snapshot of items currently in the list.\n * Can include items that we dragged in from another list.\n */\n getActiveItemsSnapshot() {\n return this._activeItems;\n }\n /** Gets the index of a specific item. */\n getItemIndex(item) {\n return this._activeItems.indexOf(item);\n }\n /** Used to notify the strategy that the scroll position has changed. */\n updateOnScroll() {\n this._activeItems.forEach(item => {\n if (this._dragDropRegistry.isDragging(item)) {\n // We need to re-sort the item manually, because the pointer move\n // events won't be dispatched while the user is scrolling.\n item._sortFromLastPointerPosition();\n }\n });\n }\n withElementContainer(container) {\n if (container !== this._element) {\n this._element = container;\n this._rootNode = undefined;\n }\n }\n /**\n * Gets the index of an item in the drop container, based on the position of the user's pointer.\n * @param item Item that is being sorted.\n * @param pointerX Position of the user's pointer along the X axis.\n * @param pointerY Position of the user's pointer along the Y axis.\n * @param delta Direction in which the user is moving their pointer.\n */\n _getItemIndexFromPointerPosition(item, pointerX, pointerY) {\n const elementAtPoint = this._getRootNode().elementFromPoint(Math.floor(pointerX), Math.floor(pointerY));\n const index = elementAtPoint\n ? this._activeItems.findIndex(item => {\n const root = item.getRootElement();\n return elementAtPoint === root || root.contains(elementAtPoint);\n })\n : -1;\n return index === -1 || !this._sortPredicate(index, item) ? -1 : index;\n }\n /** Lazily resolves the list's root node. */\n _getRootNode() {\n // Resolve the root node lazily to ensure that the drop list is in its final place in the DOM.\n if (!this._rootNode) {\n this._rootNode = _getShadowRoot(this._element) || this._document;\n }\n return this._rootNode;\n }\n /**\n * Finds the index of the item that's closest to the item being dragged.\n * @param item Item being dragged.\n * @param pointerX Position of the user's pointer along the X axis.\n * @param pointerY Position of the user's pointer along the Y axis.\n */\n _getClosestItemIndexToPointer(item, pointerX, pointerY) {\n if (this._activeItems.length === 0) {\n return -1;\n }\n if (this._activeItems.length === 1) {\n return 0;\n }\n let minDistance = Infinity;\n let minIndex = -1;\n // Find the Euclidean distance (https://en.wikipedia.org/wiki/Euclidean_distance) between each\n // item and the pointer, and return the smallest one. Note that this is a bit flawed in that DOM\n // nodes are rectangles, not points, so we use the top/left coordinates. It should be enough\n // for our purposes.\n for (let i = 0; i < this._activeItems.length; i++) {\n const current = this._activeItems[i];\n if (current !== item) {\n const { x, y } = current.getRootElement().getBoundingClientRect();\n const distance = Math.hypot(pointerX - x, pointerY - y);\n if (distance < minDistance) {\n minDistance = distance;\n minIndex = i;\n }\n }\n }\n return minIndex;\n }\n}\n\n/**\n * Proximity, as a ratio to width/height, at which a\n * dragged item will affect the drop container.\n */\nconst DROP_PROXIMITY_THRESHOLD = 0.05;\n/**\n * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the\n * viewport. The value comes from trying it out manually until it feels right.\n */\nconst SCROLL_PROXIMITY_THRESHOLD = 0.05;\n/** Vertical direction in which we can auto-scroll. */\nvar AutoScrollVerticalDirection;\n(function (AutoScrollVerticalDirection) {\n AutoScrollVerticalDirection[AutoScrollVerticalDirection[\"NONE\"] = 0] = \"NONE\";\n AutoScrollVerticalDirection[AutoScrollVerticalDirection[\"UP\"] = 1] = \"UP\";\n AutoScrollVerticalDirection[AutoScrollVerticalDirection[\"DOWN\"] = 2] = \"DOWN\";\n})(AutoScrollVerticalDirection || (AutoScrollVerticalDirection = {}));\n/** Horizontal direction in which we can auto-scroll. */\nvar AutoScrollHorizontalDirection;\n(function (AutoScrollHorizontalDirection) {\n AutoScrollHorizontalDirection[AutoScrollHorizontalDirection[\"NONE\"] = 0] = \"NONE\";\n AutoScrollHorizontalDirection[AutoScrollHorizontalDirection[\"LEFT\"] = 1] = \"LEFT\";\n AutoScrollHorizontalDirection[AutoScrollHorizontalDirection[\"RIGHT\"] = 2] = \"RIGHT\";\n})(AutoScrollHorizontalDirection || (AutoScrollHorizontalDirection = {}));\n/**\n * Reference to a drop list. Used to manipulate or dispose of the container.\n */\nclass DropListRef {\n _dragDropRegistry;\n _ngZone;\n _viewportRuler;\n /** Element that the drop list is attached to. */\n element;\n /** Whether starting a dragging sequence from this container is disabled. */\n disabled = false;\n /** Whether sorting items within the list is disabled. */\n sortingDisabled = false;\n /** Locks the position of the draggable elements inside the container along the specified axis. */\n lockAxis;\n /**\n * Whether auto-scrolling the view when the user\n * moves their pointer close to the edges is disabled.\n */\n autoScrollDisabled = false;\n /** Number of pixels to scroll for each frame when auto-scrolling an element. */\n autoScrollStep = 2;\n /**\n * Function that is used to determine whether an item\n * is allowed to be moved into a drop container.\n */\n enterPredicate = () => true;\n /** Function that is used to determine whether an item can be sorted into a particular index. */\n sortPredicate = () => true;\n /** Emits right before dragging has started. */\n beforeStarted = new Subject();\n /**\n * Emits when the user has moved a new drag item into this container.\n */\n entered = new Subject();\n /**\n * Emits when the user removes an item from the container\n * by dragging it into another container.\n */\n exited = new Subject();\n /** Emits when the user drops an item inside the container. */\n dropped = new Subject();\n /** Emits as the user is swapping items while actively dragging. */\n sorted = new Subject();\n /** Emits when a dragging sequence is started in a list connected to the current one. */\n receivingStarted = new Subject();\n /** Emits when a dragging sequence is stopped from a list connected to the current one. */\n receivingStopped = new Subject();\n /** Arbitrary data that can be attached to the drop list. */\n data;\n /** Element that is the direct parent of the drag items. */\n _container;\n /** Whether an item in the list is being dragged. */\n _isDragging = false;\n /** Keeps track of the positions of any parent scrollable elements. */\n _parentPositions;\n /** Strategy being used to sort items within the list. */\n _sortStrategy;\n /** Cached `DOMRect` of the drop list. */\n _domRect;\n /** Draggable items in the container. */\n _draggables = [];\n /** Drop lists that are connected to the current one. */\n _siblings = [];\n /** Connected siblings that currently have a dragged item. */\n _activeSiblings = new Set();\n /** Subscription to the window being scrolled. */\n _viewportScrollSubscription = Subscription.EMPTY;\n /** Vertical direction in which the list is currently scrolling. */\n _verticalScrollDirection = AutoScrollVerticalDirection.NONE;\n /** Horizontal direction in which the list is currently scrolling. */\n _horizontalScrollDirection = AutoScrollHorizontalDirection.NONE;\n /** Node that is being auto-scrolled. */\n _scrollNode;\n /** Used to signal to the current auto-scroll sequence when to stop. */\n _stopScrollTimers = new Subject();\n /** Shadow root of the current element. Necessary for `elementFromPoint` to resolve correctly. */\n _cachedShadowRoot = null;\n /** Reference to the document. */\n _document;\n /** Elements that can be scrolled while the user is dragging. */\n _scrollableElements = [];\n /** Initial value for the element's `scroll-snap-type` style. */\n _initialScrollSnap;\n /** Direction of the list's layout. */\n _direction = 'ltr';\n constructor(element, _dragDropRegistry, _document, _ngZone, _viewportRuler) {\n this._dragDropRegistry = _dragDropRegistry;\n this._ngZone = _ngZone;\n this._viewportRuler = _viewportRuler;\n const coercedElement = (this.element = coerceElement(element));\n this._document = _document;\n this.withOrientation('vertical').withElementContainer(coercedElement);\n _dragDropRegistry.registerDropContainer(this);\n this._parentPositions = new ParentPositionTracker(_document);\n }\n /** Removes the drop list functionality from the DOM element. */\n dispose() {\n this._stopScrolling();\n this._stopScrollTimers.complete();\n this._viewportScrollSubscription.unsubscribe();\n this.beforeStarted.complete();\n this.entered.complete();\n this.exited.complete();\n this.dropped.complete();\n this.sorted.complete();\n this.receivingStarted.complete();\n this.receivingStopped.complete();\n this._activeSiblings.clear();\n this._scrollNode = null;\n this._parentPositions.clear();\n this._dragDropRegistry.removeDropContainer(this);\n }\n /** Whether an item from this list is currently being dragged. */\n isDragging() {\n return this._isDragging;\n }\n /** Starts dragging an item. */\n start() {\n this._draggingStarted();\n this._notifyReceivingSiblings();\n }\n /**\n * Attempts to move an item into the container.\n * @param item Item that was moved into the container.\n * @param pointerX Position of the item along the X axis.\n * @param pointerY Position of the item along the Y axis.\n * @param index Index at which the item entered. If omitted, the container will try to figure it\n * out automatically.\n */\n enter(item, pointerX, pointerY, index) {\n this._draggingStarted();\n // If sorting is disabled, we want the item to return to its starting\n // position if the user is returning it to its initial container.\n if (index == null && this.sortingDisabled) {\n index = this._draggables.indexOf(item);\n }\n this._sortStrategy.enter(item, pointerX, pointerY, index);\n // Note that this usually happens inside `_draggingStarted` as well, but the dimensions\n // can change when the sort strategy moves the item around inside `enter`.\n this._cacheParentPositions();\n // Notify siblings at the end so that the item has been inserted into the `activeDraggables`.\n this._notifyReceivingSiblings();\n this.entered.next({ item, container: this, currentIndex: this.getItemIndex(item) });\n }\n /**\n * Removes an item from the container after it was dragged into another container by the user.\n * @param item Item that was dragged out.\n */\n exit(item) {\n this._reset();\n this.exited.next({ item, container: this });\n }\n /**\n * Drops an item into this container.\n * @param item Item being dropped into the container.\n * @param currentIndex Index at which the item should be inserted.\n * @param previousIndex Index of the item when dragging started.\n * @param previousContainer Container from which the item got dragged in.\n * @param isPointerOverContainer Whether the user's pointer was over the\n * container when the item was dropped.\n * @param distance Distance the user has dragged since the start of the dragging sequence.\n * @param event Event that triggered the dropping sequence.\n *\n * @breaking-change 15.0.0 `previousIndex` and `event` parameters to become required.\n */\n drop(item, currentIndex, previousIndex, previousContainer, isPointerOverContainer, distance, dropPoint, event = {}) {\n this._reset();\n this.dropped.next({\n item,\n currentIndex,\n previousIndex,\n container: this,\n previousContainer,\n isPointerOverContainer,\n distance,\n dropPoint,\n event,\n });\n }\n /**\n * Sets the draggable items that are a part of this list.\n * @param items Items that are a part of this list.\n */\n withItems(items) {\n const previousItems = this._draggables;\n this._draggables = items;\n items.forEach(item => item._withDropContainer(this));\n if (this.isDragging()) {\n const draggedItems = previousItems.filter(item => item.isDragging());\n // If all of the items being dragged were removed\n // from the list, abort the current drag sequence.\n if (draggedItems.every(item => items.indexOf(item) === -1)) {\n this._reset();\n }\n else {\n this._sortStrategy.withItems(this._draggables);\n }\n }\n return this;\n }\n /** Sets the layout direction of the drop list. */\n withDirection(direction) {\n this._direction = direction;\n if (this._sortStrategy instanceof SingleAxisSortStrategy) {\n this._sortStrategy.direction = direction;\n }\n return this;\n }\n /**\n * Sets the containers that are connected to this one. When two or more containers are\n * connected, the user will be allowed to transfer items between them.\n * @param connectedTo Other containers that the current containers should be connected to.\n */\n connectedTo(connectedTo) {\n this._siblings = connectedTo.slice();\n return this;\n }\n /**\n * Sets the orientation of the container.\n * @param orientation New orientation for the container.\n */\n withOrientation(orientation) {\n if (orientation === 'mixed') {\n this._sortStrategy = new MixedSortStrategy(this._document, this._dragDropRegistry);\n }\n else {\n const strategy = new SingleAxisSortStrategy(this._dragDropRegistry);\n strategy.direction = this._direction;\n strategy.orientation = orientation;\n this._sortStrategy = strategy;\n }\n this._sortStrategy.withElementContainer(this._container);\n this._sortStrategy.withSortPredicate((index, item) => this.sortPredicate(index, item, this));\n return this;\n }\n /**\n * Sets which parent elements are can be scrolled while the user is dragging.\n * @param elements Elements that can be scrolled.\n */\n withScrollableParents(elements) {\n const element = this._container;\n // We always allow the current element to be scrollable\n // so we need to ensure that it's in the array.\n this._scrollableElements =\n elements.indexOf(element) === -1 ? [element, ...elements] : elements.slice();\n return this;\n }\n /**\n * Configures the drop list so that a different element is used as the container for the\n * dragged items. This is useful for the cases when one might not have control over the\n * full DOM that sets up the dragging.\n * Note that the alternate container needs to be a descendant of the drop list.\n * @param container New element container to be assigned.\n */\n withElementContainer(container) {\n if (container === this._container) {\n return this;\n }\n const element = coerceElement(this.element);\n if ((typeof ngDevMode === 'undefined' || ngDevMode) &&\n container !== element &&\n !element.contains(container)) {\n throw new Error('Invalid DOM structure for drop list. Alternate container element must be a descendant of the drop list.');\n }\n const oldContainerIndex = this._scrollableElements.indexOf(this._container);\n const newContainerIndex = this._scrollableElements.indexOf(container);\n if (oldContainerIndex > -1) {\n this._scrollableElements.splice(oldContainerIndex, 1);\n }\n if (newContainerIndex > -1) {\n this._scrollableElements.splice(newContainerIndex, 1);\n }\n if (this._sortStrategy) {\n this._sortStrategy.withElementContainer(container);\n }\n this._cachedShadowRoot = null;\n this._scrollableElements.unshift(container);\n this._container = container;\n return this;\n }\n /** Gets the scrollable parents that are registered with this drop container. */\n getScrollableParents() {\n return this._scrollableElements;\n }\n /**\n * Figures out the index of an item in the container.\n * @param item Item whose index should be determined.\n */\n getItemIndex(item) {\n return this._isDragging\n ? this._sortStrategy.getItemIndex(item)\n : this._draggables.indexOf(item);\n }\n /**\n * Whether the list is able to receive the item that\n * is currently being dragged inside a connected drop list.\n */\n isReceiving() {\n return this._activeSiblings.size > 0;\n }\n /**\n * Sorts an item inside the container based on its position.\n * @param item Item to be sorted.\n * @param pointerX Position of the item along the X axis.\n * @param pointerY Position of the item along the Y axis.\n * @param pointerDelta Direction in which the pointer is moving along each axis.\n */\n _sortItem(item, pointerX, pointerY, pointerDelta) {\n // Don't sort the item if sorting is disabled or it's out of range.\n if (this.sortingDisabled ||\n !this._domRect ||\n !isPointerNearDomRect(this._domRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {\n return;\n }\n const result = this._sortStrategy.sort(item, pointerX, pointerY, pointerDelta);\n if (result) {\n this.sorted.next({\n previousIndex: result.previousIndex,\n currentIndex: result.currentIndex,\n container: this,\n item,\n });\n }\n }\n /**\n * Checks whether the user's pointer is close to the edges of either the\n * viewport or the drop list and starts the auto-scroll sequence.\n * @param pointerX User's pointer position along the x axis.\n * @param pointerY User's pointer position along the y axis.\n */\n _startScrollingIfNecessary(pointerX, pointerY) {\n if (this.autoScrollDisabled) {\n return;\n }\n let scrollNode;\n let verticalScrollDirection = AutoScrollVerticalDirection.NONE;\n let horizontalScrollDirection = AutoScrollHorizontalDirection.NONE;\n // Check whether we should start scrolling any of the parent containers.\n this._parentPositions.positions.forEach((position, element) => {\n // We have special handling for the `document` below. Also this would be\n // nicer with a for...of loop, but it requires changing a compiler flag.\n if (element === this._document || !position.clientRect || scrollNode) {\n return;\n }\n if (isPointerNearDomRect(position.clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {\n [verticalScrollDirection, horizontalScrollDirection] = getElementScrollDirections(element, position.clientRect, this._direction, pointerX, pointerY);\n if (verticalScrollDirection || horizontalScrollDirection) {\n scrollNode = element;\n }\n }\n });\n // Otherwise check if we can start scrolling the viewport.\n if (!verticalScrollDirection && !horizontalScrollDirection) {\n const { width, height } = this._viewportRuler.getViewportSize();\n const domRect = {\n width,\n height,\n top: 0,\n right: width,\n bottom: height,\n left: 0,\n };\n verticalScrollDirection = getVerticalScrollDirection(domRect, pointerY);\n horizontalScrollDirection = getHorizontalScrollDirection(domRect, pointerX);\n scrollNode = window;\n }\n if (scrollNode &&\n (verticalScrollDirection !== this._verticalScrollDirection ||\n horizontalScrollDirection !== this._horizontalScrollDirection ||\n scrollNode !== this._scrollNode)) {\n this._verticalScrollDirection = verticalScrollDirection;\n this._horizontalScrollDirection = horizontalScrollDirection;\n this._scrollNode = scrollNode;\n if ((verticalScrollDirection || horizontalScrollDirection) && scrollNode) {\n this._ngZone.runOutsideAngular(this._startScrollInterval);\n }\n else {\n this._stopScrolling();\n }\n }\n }\n /** Stops any currently-running auto-scroll sequences. */\n _stopScrolling() {\n this._stopScrollTimers.next();\n }\n /** Starts the dragging sequence within the list. */\n _draggingStarted() {\n const styles = this._container.style;\n this.beforeStarted.next();\n this._isDragging = true;\n if ((typeof ngDevMode === 'undefined' || ngDevMode) &&\n // Prevent the check from running on apps not using an alternate container. Ideally we\n // would always run it, but introducing it at this stage would be a breaking change.\n this._container !== coerceElement(this.element)) {\n for (const drag of this._draggables) {\n if (!drag.isDragging() && drag.getVisibleElement().parentNode !== this._container) {\n throw new Error('Invalid DOM structure for drop list. All items must be placed directly inside of the element container.');\n }\n }\n }\n // We need to disable scroll snapping while the user is dragging, because it breaks automatic\n // scrolling. The browser seems to round the value based on the snapping points which means\n // that we can't increment/decrement the scroll position.\n this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';\n styles.scrollSnapType = styles.msScrollSnapType = 'none';\n this._sortStrategy.start(this._draggables);\n this._cacheParentPositions();\n this._viewportScrollSubscription.unsubscribe();\n this._listenToScrollEvents();\n }\n /** Caches the positions of the configured scrollable parents. */\n _cacheParentPositions() {\n this._parentPositions.cache(this._scrollableElements);\n // The list element is always in the `scrollableElements`\n // so we can take advantage of the cached `DOMRect`.\n this._domRect = this._parentPositions.positions.get(this._container).clientRect;\n }\n /** Resets the container to its initial state. */\n _reset() {\n this._isDragging = false;\n const styles = this._container.style;\n styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;\n this._siblings.forEach(sibling => sibling._stopReceiving(this));\n this._sortStrategy.reset();\n this._stopScrolling();\n this._viewportScrollSubscription.unsubscribe();\n this._parentPositions.clear();\n }\n /** Starts the interval that'll auto-scroll the element. */\n _startScrollInterval = () => {\n this._stopScrolling();\n interval(0, animationFrameScheduler)\n .pipe(takeUntil(this._stopScrollTimers))\n .subscribe(() => {\n const node = this._scrollNode;\n const scrollStep = this.autoScrollStep;\n if (this._verticalScrollDirection === AutoScrollVerticalDirection.UP) {\n node.scrollBy(0, -scrollStep);\n }\n else if (this._verticalScrollDirection === AutoScrollVerticalDirection.DOWN) {\n node.scrollBy(0, scrollStep);\n }\n if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.LEFT) {\n node.scrollBy(-scrollStep, 0);\n }\n else if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.RIGHT) {\n node.scrollBy(scrollStep, 0);\n }\n });\n };\n /**\n * Checks whether the user's pointer is positioned over the container.\n * @param x Pointer position along the X axis.\n * @param y Pointer position along the Y axis.\n */\n _isOverContainer(x, y) {\n return this._domRect != null && isInsideClientRect(this._domRect, x, y);\n }\n /**\n * Figures out whether an item should be moved into a sibling\n * drop container, based on its current position.\n * @param item Drag item that is being moved.\n * @param x Position of the item along the X axis.\n * @param y Position of the item along the Y axis.\n */\n _getSiblingContainerFromPosition(item, x, y) {\n return this._siblings.find(sibling => sibling._canReceive(item, x, y));\n }\n /**\n * Checks whether the drop list can receive the passed-in item.\n * @param item Item that is being dragged into the list.\n * @param x Position of the item along the X axis.\n * @param y Position of the item along the Y axis.\n */\n _canReceive(item, x, y) {\n if (!this._domRect ||\n !isInsideClientRect(this._domRect, x, y) ||\n !this.enterPredicate(item, this)) {\n return false;\n }\n const elementFromPoint = this._getShadowRoot().elementFromPoint(x, y);\n // If there's no element at the pointer position, then\n // the client rect is probably scrolled out of the view.\n if (!elementFromPoint) {\n return false;\n }\n // The `DOMRect`, that we're using to find the container over which the user is\n // hovering, doesn't give us any information on whether the element has been scrolled\n // out of the view or whether it's overlapping with other containers. This means that\n // we could end up transferring the item into a container that's invisible or is positioned\n // below another one. We use the result from `elementFromPoint` to get the top-most element\n // at the pointer position and to find whether it's one of the intersecting drop containers.\n return elementFromPoint === this._container || this._container.contains(elementFromPoint);\n }\n /**\n * Called by one of the connected drop lists when a dragging sequence has started.\n * @param sibling Sibling in which dragging has started.\n */\n _startReceiving(sibling, items) {\n const activeSiblings = this._activeSiblings;\n if (!activeSiblings.has(sibling) &&\n items.every(item => {\n // Note that we have to add an exception to the `enterPredicate` for items that started off\n // in this drop list. The drag ref has logic that allows an item to return to its initial\n // container, if it has left the initial container and none of the connected containers\n // allow it to enter. See `DragRef._updateActiveDropContainer` for more context.\n return this.enterPredicate(item, this) || this._draggables.indexOf(item) > -1;\n })) {\n activeSiblings.add(sibling);\n this._cacheParentPositions();\n this._listenToScrollEvents();\n this.receivingStarted.next({\n initiator: sibling,\n receiver: this,\n items,\n });\n }\n }\n /**\n * Called by a connected drop list when dragging has stopped.\n * @param sibling Sibling whose dragging has stopped.\n */\n _stopReceiving(sibling) {\n this._activeSiblings.delete(sibling);\n this._viewportScrollSubscription.unsubscribe();\n this.receivingStopped.next({ initiator: sibling, receiver: this });\n }\n /**\n * Starts listening to scroll events on the viewport.\n * Used for updating the internal state of the list.\n */\n _listenToScrollEvents() {\n this._viewportScrollSubscription = this._dragDropRegistry\n .scrolled(this._getShadowRoot())\n .subscribe(event => {\n if (this.isDragging()) {\n const scrollDifference = this._parentPositions.handleScroll(event);\n if (scrollDifference) {\n this._sortStrategy.updateOnScroll(scrollDifference.top, scrollDifference.left);\n }\n }\n else if (this.isReceiving()) {\n this._cacheParentPositions();\n }\n });\n }\n /**\n * Lazily resolves and returns the shadow root of the element. We do this in a function, rather\n * than saving it in property directly on init, because we want to resolve it as late as possible\n * in order to ensure that the element has been moved into the shadow DOM. Doing it inside the\n * constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.\n */\n _getShadowRoot() {\n if (!this._cachedShadowRoot) {\n const shadowRoot = _getShadowRoot(this._container);\n this._cachedShadowRoot = shadowRoot || this._document;\n }\n return this._cachedShadowRoot;\n }\n /** Notifies any siblings that may potentially receive the item. */\n _notifyReceivingSiblings() {\n const draggedItems = this._sortStrategy\n .getActiveItemsSnapshot()\n .filter(item => item.isDragging());\n this._siblings.forEach(sibling => sibling._startReceiving(this, draggedItems));\n }\n}\n/**\n * Gets whether the vertical auto-scroll direction of a node.\n * @param clientRect Dimensions of the node.\n * @param pointerY Position of the user's pointer along the y axis.\n */\nfunction getVerticalScrollDirection(clientRect, pointerY) {\n const { top, bottom, height } = clientRect;\n const yThreshold = height * SCROLL_PROXIMITY_THRESHOLD;\n if (pointerY >= top - yThreshold && pointerY <= top + yThreshold) {\n return AutoScrollVerticalDirection.UP;\n }\n else if (pointerY >= bottom - yThreshold && pointerY <= bottom + yThreshold) {\n return AutoScrollVerticalDirection.DOWN;\n }\n return AutoScrollVerticalDirection.NONE;\n}\n/**\n * Gets whether the horizontal auto-scroll direction of a node.\n * @param clientRect Dimensions of the node.\n * @param pointerX Position of the user's pointer along the x axis.\n */\nfunction getHorizontalScrollDirection(clientRect, pointerX) {\n const { left, right, width } = clientRect;\n const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;\n if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {\n return AutoScrollHorizontalDirection.LEFT;\n }\n else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {\n return AutoScrollHorizontalDirection.RIGHT;\n }\n return AutoScrollHorizontalDirection.NONE;\n}\n/**\n * Gets the directions in which an element node should be scrolled,\n * assuming that the user's pointer is already within it scrollable region.\n * @param element Element for which we should calculate the scroll direction.\n * @param clientRect Bounding client rectangle of the element.\n * @param direction Layout direction of the drop list.\n * @param pointerX Position of the user's pointer along the x axis.\n * @param pointerY Position of the user's pointer along the y axis.\n */\nfunction getElementScrollDirections(element, clientRect, direction, pointerX, pointerY) {\n const computedVertical = getVerticalScrollDirection(clientRect, pointerY);\n const computedHorizontal = getHorizontalScrollDirection(clientRect, pointerX);\n let verticalScrollDirection = AutoScrollVerticalDirection.NONE;\n let horizontalScrollDirection = AutoScrollHorizontalDirection.NONE;\n // Note that we here we do some extra checks for whether the element is actually scrollable in\n // a certain direction and we only assign the scroll direction if it is. We do this so that we\n // can allow other elements to be scrolled, if the current element can't be scrolled anymore.\n // This allows us to handle cases where the scroll regions of two scrollable elements overlap.\n if (computedVertical) {\n const scrollTop = element.scrollTop;\n if (computedVertical === AutoScrollVerticalDirection.UP) {\n if (scrollTop > 0) {\n verticalScrollDirection = AutoScrollVerticalDirection.UP;\n }\n }\n else if (element.scrollHeight - scrollTop > element.clientHeight) {\n verticalScrollDirection = AutoScrollVerticalDirection.DOWN;\n }\n }\n if (computedHorizontal) {\n const scrollLeft = element.scrollLeft;\n if (direction === 'rtl') {\n if (computedHorizontal === AutoScrollHorizontalDirection.RIGHT) {\n // In RTL `scrollLeft` will be negative when scrolled.\n if (scrollLeft < 0) {\n horizontalScrollDirection = AutoScrollHorizontalDirection.RIGHT;\n }\n }\n else if (element.scrollWidth + scrollLeft > element.clientWidth) {\n horizontalScrollDirection = AutoScrollHorizontalDirection.LEFT;\n }\n }\n else {\n if (computedHorizontal === AutoScrollHorizontalDirection.LEFT) {\n if (scrollLeft > 0) {\n horizontalScrollDirection = AutoScrollHorizontalDirection.LEFT;\n }\n }\n else if (element.scrollWidth - scrollLeft > element.clientWidth) {\n horizontalScrollDirection = AutoScrollHorizontalDirection.RIGHT;\n }\n }\n }\n return [verticalScrollDirection, horizontalScrollDirection];\n}\n\n/** Event options that can be used to bind an active, capturing event. */\nconst activeCapturingEventOptions = normalizePassiveListenerOptions({\n passive: false,\n capture: true,\n});\n/**\n * Component used to load the drag&drop reset styles.\n * @docs-private\n */\nclass _ResetsLoader {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _ResetsLoader, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"14.0.0\", version: \"19.0.0\", type: _ResetsLoader, isStandalone: true, selector: \"ng-component\", host: { attributes: { \"cdk-drag-resets-container\": \"\" } }, ngImport: i0, template: '', isInline: true, styles: [\"@layer cdk-resets{.cdk-drag-preview{background:none;border:none;padding:0;color:inherit;inset:auto}}.cdk-drag-placeholder *,.cdk-drag-preview *{pointer-events:none !important}\"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _ResetsLoader, decorators: [{\n type: Component,\n args: [{ encapsulation: ViewEncapsulation.None, template: '', changeDetection: ChangeDetectionStrategy.OnPush, host: { 'cdk-drag-resets-container': '' }, styles: [\"@layer cdk-resets{.cdk-drag-preview{background:none;border:none;padding:0;color:inherit;inset:auto}}.cdk-drag-placeholder *,.cdk-drag-preview *{pointer-events:none !important}\"] }]\n }] });\n// TODO(crisbeto): remove generics when making breaking changes.\n/**\n * Service that keeps track of all the drag item and drop container\n * instances, and manages global event listeners on the `document`.\n * @docs-private\n */\nclass DragDropRegistry {\n _ngZone = inject(NgZone);\n _document = inject(DOCUMENT);\n _styleLoader = inject(_CdkPrivateStyleLoader);\n /** Registered drop container instances. */\n _dropInstances = new Set();\n /** Registered drag item instances. */\n _dragInstances = new Set();\n /** Drag item instances that are currently being dragged. */\n _activeDragInstances = signal([]);\n /** Keeps track of the event listeners that we've bound to the `document`. */\n _globalListeners = new Map();\n /**\n * Predicate function to check if an item is being dragged. Moved out into a property,\n * because it'll be called a lot and we don't want to create a new function every time.\n */\n _draggingPredicate = (item) => item.isDragging();\n /**\n * Map tracking DOM nodes and their corresponding drag directives. Note that this is different\n * from looking through the `_dragInstances` and getting their root node, because the root node\n * isn't necessarily the node that the directive is set on.\n */\n _domNodesToDirectives = null;\n /**\n * Emits the `touchmove` or `mousemove` events that are dispatched\n * while the user is dragging a drag item instance.\n */\n pointerMove = new Subject();\n /**\n * Emits the `touchend` or `mouseup` events that are dispatched\n * while the user is dragging a drag item instance.\n */\n pointerUp = new Subject();\n /**\n * Emits when the viewport has been scrolled while the user is dragging an item.\n * @deprecated To be turned into a private member. Use the `scrolled` method instead.\n * @breaking-change 13.0.0\n */\n scroll = new Subject();\n constructor() { }\n /** Adds a drop container to the registry. */\n registerDropContainer(drop) {\n if (!this._dropInstances.has(drop)) {\n this._dropInstances.add(drop);\n }\n }\n /** Adds a drag item instance to the registry. */\n registerDragItem(drag) {\n this._dragInstances.add(drag);\n // The `touchmove` event gets bound once, ahead of time, because WebKit\n // won't preventDefault on a dynamically-added `touchmove` listener.\n // See https://bugs.webkit.org/show_bug.cgi?id=184250.\n if (this._dragInstances.size === 1) {\n this._ngZone.runOutsideAngular(() => {\n // The event handler has to be explicitly active,\n // because newer browsers make it passive by default.\n this._document.addEventListener('touchmove', this._persistentTouchmoveListener, activeCapturingEventOptions);\n });\n }\n }\n /** Removes a drop container from the registry. */\n removeDropContainer(drop) {\n this._dropInstances.delete(drop);\n }\n /** Removes a drag item instance from the registry. */\n removeDragItem(drag) {\n this._dragInstances.delete(drag);\n this.stopDragging(drag);\n if (this._dragInstances.size === 0) {\n this._document.removeEventListener('touchmove', this._persistentTouchmoveListener, activeCapturingEventOptions);\n }\n }\n /**\n * Starts the dragging sequence for a drag instance.\n * @param drag Drag instance which is being dragged.\n * @param event Event that initiated the dragging.\n */\n startDragging(drag, event) {\n // Do not process the same drag twice to avoid memory leaks and redundant listeners\n if (this._activeDragInstances().indexOf(drag) > -1) {\n return;\n }\n this._styleLoader.load(_ResetsLoader);\n this._activeDragInstances.update(instances => [...instances, drag]);\n if (this._activeDragInstances().length === 1) {\n // We explicitly bind __active__ listeners here, because newer browsers will default to\n // passive ones for `mousemove` and `touchmove`. The events need to be active, because we\n // use `preventDefault` to prevent the page from scrolling while the user is dragging.\n const isTouchEvent = event.type.startsWith('touch');\n const endEventHandler = {\n handler: (e) => this.pointerUp.next(e),\n options: true,\n };\n if (isTouchEvent) {\n this._globalListeners.set('touchend', endEventHandler);\n this._globalListeners.set('touchcancel', endEventHandler);\n }\n else {\n this._globalListeners.set('mouseup', endEventHandler);\n }\n this._globalListeners\n .set('scroll', {\n handler: (e) => this.scroll.next(e),\n // Use capturing so that we pick up scroll changes in any scrollable nodes that aren't\n // the document. See https://github.com/angular/components/issues/17144.\n options: true,\n })\n // Preventing the default action on `mousemove` isn't enough to disable text selection\n // on Safari so we need to prevent the selection event as well. Alternatively this can\n // be done by setting `user-select: none` on the `body`, however it has causes a style\n // recalculation which can be expensive on pages with a lot of elements.\n .set('selectstart', {\n handler: this._preventDefaultWhileDragging,\n options: activeCapturingEventOptions,\n });\n // We don't have to bind a move event for touch drag sequences, because\n // we already have a persistent global one bound from `registerDragItem`.\n if (!isTouchEvent) {\n this._globalListeners.set('mousemove', {\n handler: (e) => this.pointerMove.next(e),\n options: activeCapturingEventOptions,\n });\n }\n this._ngZone.runOutsideAngular(() => {\n this._globalListeners.forEach((config, name) => {\n this._document.addEventListener(name, config.handler, config.options);\n });\n });\n }\n }\n /** Stops dragging a drag item instance. */\n stopDragging(drag) {\n this._activeDragInstances.update(instances => {\n const index = instances.indexOf(drag);\n if (index > -1) {\n instances.splice(index, 1);\n return [...instances];\n }\n return instances;\n });\n if (this._activeDragInstances().length === 0) {\n this._clearGlobalListeners();\n }\n }\n /** Gets whether a drag item instance is currently being dragged. */\n isDragging(drag) {\n return this._activeDragInstances().indexOf(drag) > -1;\n }\n /**\n * Gets a stream that will emit when any element on the page is scrolled while an item is being\n * dragged.\n * @param shadowRoot Optional shadow root that the current dragging sequence started from.\n * Top-level listeners won't pick up events coming from the shadow DOM so this parameter can\n * be used to include an additional top-level listener at the shadow root level.\n */\n scrolled(shadowRoot) {\n const streams = [this.scroll];\n if (shadowRoot && shadowRoot !== this._document) {\n // Note that this is basically the same as `fromEvent` from rxjs, but we do it ourselves,\n // because we want to guarantee that the event is bound outside of the `NgZone`. With\n // `fromEvent` it'll only happen if the subscription is outside the `NgZone`.\n streams.push(new Observable((observer) => {\n return this._ngZone.runOutsideAngular(() => {\n const eventOptions = true;\n const callback = (event) => {\n if (this._activeDragInstances().length) {\n observer.next(event);\n }\n };\n shadowRoot.addEventListener('scroll', callback, eventOptions);\n return () => {\n shadowRoot.removeEventListener('scroll', callback, eventOptions);\n };\n });\n }));\n }\n return merge(...streams);\n }\n /**\n * Tracks the DOM node which has a draggable directive.\n * @param node Node to track.\n * @param dragRef Drag directive set on the node.\n */\n registerDirectiveNode(node, dragRef) {\n this._domNodesToDirectives ??= new WeakMap();\n this._domNodesToDirectives.set(node, dragRef);\n }\n /**\n * Stops tracking a draggable directive node.\n * @param node Node to stop tracking.\n */\n removeDirectiveNode(node) {\n this._domNodesToDirectives?.delete(node);\n }\n /**\n * Gets the drag directive corresponding to a specific DOM node, if any.\n * @param node Node for which to do the lookup.\n */\n getDragDirectiveForNode(node) {\n return this._domNodesToDirectives?.get(node) || null;\n }\n ngOnDestroy() {\n this._dragInstances.forEach(instance => this.removeDragItem(instance));\n this._dropInstances.forEach(instance => this.removeDropContainer(instance));\n this._domNodesToDirectives = null;\n this._clearGlobalListeners();\n this.pointerMove.complete();\n this.pointerUp.complete();\n }\n /**\n * Event listener that will prevent the default browser action while the user is dragging.\n * @param event Event whose default action should be prevented.\n */\n _preventDefaultWhileDragging = (event) => {\n if (this._activeDragInstances().length > 0) {\n event.preventDefault();\n }\n };\n /** Event listener for `touchmove` that is bound even if no dragging is happening. */\n _persistentTouchmoveListener = (event) => {\n if (this._activeDragInstances().length > 0) {\n // Note that we only want to prevent the default action after dragging has actually started.\n // Usually this is the same time at which the item is added to the `_activeDragInstances`,\n // but it could be pushed back if the user has set up a drag delay or threshold.\n if (this._activeDragInstances().some(this._draggingPredicate)) {\n event.preventDefault();\n }\n this.pointerMove.next(event);\n }\n };\n /** Clears out the global event listeners from the `document`. */\n _clearGlobalListeners() {\n this._globalListeners.forEach((config, name) => {\n this._document.removeEventListener(name, config.handler, config.options);\n });\n this._globalListeners.clear();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDropRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDropRegistry, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDropRegistry, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/** Default configuration to be used when creating a `DragRef`. */\nconst DEFAULT_CONFIG = {\n dragStartThreshold: 5,\n pointerDirectionChangeThreshold: 5,\n};\n/**\n * Service that allows for drag-and-drop functionality to be attached to DOM elements.\n */\nclass DragDrop {\n _document = inject(DOCUMENT);\n _ngZone = inject(NgZone);\n _viewportRuler = inject(ViewportRuler);\n _dragDropRegistry = inject(DragDropRegistry);\n _renderer = inject(RendererFactory2).createRenderer(null, null);\n constructor() { }\n /**\n * Turns an element into a draggable item.\n * @param element Element to which to attach the dragging functionality.\n * @param config Object used to configure the dragging behavior.\n */\n createDrag(element, config = DEFAULT_CONFIG) {\n return new DragRef(element, config, this._document, this._ngZone, this._viewportRuler, this._dragDropRegistry, this._renderer);\n }\n /**\n * Turns an element into a drop list.\n * @param element Element to which to attach the drop list functionality.\n */\n createDropList(element) {\n return new DropListRef(element, this._dragDropRegistry, this._document, this._ngZone, this._viewportRuler);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDrop, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDrop, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDrop, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/**\n * Injection token that can be used for a `CdkDrag` to provide itself as a parent to the\n * drag-specific child directive (`CdkDragHandle`, `CdkDragPreview` etc.). Used primarily\n * to avoid circular imports.\n * @docs-private\n */\nconst CDK_DRAG_PARENT = new InjectionToken('CDK_DRAG_PARENT');\n\n/**\n * Asserts that a particular node is an element.\n * @param node Node to be checked.\n * @param name Name to attach to the error message.\n */\nfunction assertElementNode(node, name) {\n if (node.nodeType !== 1) {\n throw Error(`${name} must be attached to an element node. ` + `Currently attached to \"${node.nodeName}\".`);\n }\n}\n\n/**\n * Injection token that can be used to reference instances of `CdkDragHandle`. It serves as\n * alternative token to the actual `CdkDragHandle` class which could cause unnecessary\n * retention of the class and its directive metadata.\n */\nconst CDK_DRAG_HANDLE = new InjectionToken('CdkDragHandle');\n/** Handle that can be used to drag a CdkDrag instance. */\nclass CdkDragHandle {\n element = inject(ElementRef);\n _parentDrag = inject(CDK_DRAG_PARENT, { optional: true, skipSelf: true });\n _dragDropRegistry = inject(DragDropRegistry);\n /** Emits when the state of the handle has changed. */\n _stateChanges = new Subject();\n /** Whether starting to drag through this handle is disabled. */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n this._disabled = value;\n this._stateChanges.next(this);\n }\n _disabled = false;\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertElementNode(this.element.nativeElement, 'cdkDragHandle');\n }\n this._parentDrag?._addHandle(this);\n }\n ngAfterViewInit() {\n if (!this._parentDrag) {\n let parent = this.element.nativeElement.parentElement;\n while (parent) {\n const ref = this._dragDropRegistry.getDragDirectiveForNode(parent);\n if (ref) {\n this._parentDrag = ref;\n ref._addHandle(this);\n break;\n }\n parent = parent.parentElement;\n }\n }\n }\n ngOnDestroy() {\n this._parentDrag?._removeHandle(this);\n this._stateChanges.complete();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDragHandle, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkDragHandle, isStandalone: true, selector: \"[cdkDragHandle]\", inputs: { disabled: [\"cdkDragHandleDisabled\", \"disabled\", booleanAttribute] }, host: { classAttribute: \"cdk-drag-handle\" }, providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDragHandle, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkDragHandle]',\n host: {\n 'class': 'cdk-drag-handle',\n },\n providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }],\n }]\n }], ctorParameters: () => [], propDecorators: { disabled: [{\n type: Input,\n args: [{ alias: 'cdkDragHandleDisabled', transform: booleanAttribute }]\n }] } });\n\n/**\n * Injection token that can be used to configure the\n * behavior of the drag&drop-related components.\n */\nconst CDK_DRAG_CONFIG = new InjectionToken('CDK_DRAG_CONFIG');\n\n/**\n * Injection token that can be used to reference instances of `CdkDropList`. It serves as\n * alternative token to the actual `CdkDropList` class which could cause unnecessary\n * retention of the class and its directive metadata.\n */\nconst CDK_DROP_LIST = new InjectionToken('CdkDropList');\n/** Element that can be moved inside a CdkDropList container. */\nclass CdkDrag {\n element = inject(ElementRef);\n dropContainer = inject(CDK_DROP_LIST, { optional: true, skipSelf: true });\n _ngZone = inject(NgZone);\n _viewContainerRef = inject(ViewContainerRef);\n _dir = inject(Directionality, { optional: true });\n _changeDetectorRef = inject(ChangeDetectorRef);\n _selfHandle = inject(CDK_DRAG_HANDLE, { optional: true, self: true });\n _parentDrag = inject(CDK_DRAG_PARENT, { optional: true, skipSelf: true });\n _dragDropRegistry = inject(DragDropRegistry);\n _destroyed = new Subject();\n _handles = new BehaviorSubject([]);\n _previewTemplate;\n _placeholderTemplate;\n /** Reference to the underlying drag instance. */\n _dragRef;\n /** Arbitrary data to attach to this drag instance. */\n data;\n /** Locks the position of the dragged element along the specified axis. */\n lockAxis;\n /**\n * Selector that will be used to determine the root draggable element, starting from\n * the `cdkDrag` element and going up the DOM. Passing an alternate root element is useful\n * when trying to enable dragging on an element that you might not have access to.\n */\n rootElementSelector;\n /**\n * Node or selector that will be used to determine the element to which the draggable's\n * position will be constrained. If a string is passed in, it'll be used as a selector that\n * will be matched starting from the element's parent and going up the DOM until a match\n * has been found.\n */\n boundaryElement;\n /**\n * Amount of milliseconds to wait after the user has put their\n * pointer down before starting to drag the element.\n */\n dragStartDelay;\n /**\n * Sets the position of a `CdkDrag` that is outside of a drop container.\n * Can be used to restore the element's position for a returning user.\n */\n freeDragPosition;\n /** Whether starting to drag this element is disabled. */\n get disabled() {\n return this._disabled || !!(this.dropContainer && this.dropContainer.disabled);\n }\n set disabled(value) {\n this._disabled = value;\n this._dragRef.disabled = this._disabled;\n }\n _disabled;\n /**\n * Function that can be used to customize the logic of how the position of the drag item\n * is limited while it's being dragged. Gets called with a point containing the current position\n * of the user's pointer on the page, a reference to the item being dragged and its dimensions.\n * Should return a point describing where the item should be rendered.\n */\n constrainPosition;\n /** Class to be added to the preview element. */\n previewClass;\n /**\n * Configures the place into which the preview of the item will be inserted. Can be configured\n * globally through `CDK_DROP_LIST`. Possible values:\n * - `global` - Preview will be inserted at the bottom of the ``. The advantage is that\n * you don't have to worry about `overflow: hidden` or `z-index`, but the item won't retain\n * its inherited styles.\n * - `parent` - Preview will be inserted into the parent of the drag item. The advantage is that\n * inherited styles will be preserved, but it may be clipped by `overflow: hidden` or not be\n * visible due to `z-index`. Furthermore, the preview is going to have an effect over selectors\n * like `:nth-child` and some flexbox configurations.\n * - `ElementRef | HTMLElement` - Preview will be inserted into a specific element.\n * Same advantages and disadvantages as `parent`.\n */\n previewContainer;\n /**\n * If the parent of the dragged element has a `scale` transform, it can throw off the\n * positioning when the user starts dragging. Use this input to notify the CDK of the scale.\n */\n scale = 1;\n /** Emits when the user starts dragging the item. */\n started = new EventEmitter();\n /** Emits when the user has released a drag item, before any animations have started. */\n released = new EventEmitter();\n /** Emits when the user stops dragging an item in the container. */\n ended = new EventEmitter();\n /** Emits when the user has moved the item into a new container. */\n entered = new EventEmitter();\n /** Emits when the user removes the item its container by dragging it into another container. */\n exited = new EventEmitter();\n /** Emits when the user drops the item inside a container. */\n dropped = new EventEmitter();\n /**\n * Emits as the user is dragging the item. Use with caution,\n * because this event will fire for every pixel that the user has dragged.\n */\n moved = new Observable((observer) => {\n const subscription = this._dragRef.moved\n .pipe(map(movedEvent => ({\n source: this,\n pointerPosition: movedEvent.pointerPosition,\n event: movedEvent.event,\n delta: movedEvent.delta,\n distance: movedEvent.distance,\n })))\n .subscribe(observer);\n return () => {\n subscription.unsubscribe();\n };\n });\n _injector = inject(Injector);\n constructor() {\n const dropContainer = this.dropContainer;\n const config = inject(CDK_DRAG_CONFIG, { optional: true });\n const dragDrop = inject(DragDrop);\n this._dragRef = dragDrop.createDrag(this.element, {\n dragStartThreshold: config && config.dragStartThreshold != null ? config.dragStartThreshold : 5,\n pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null\n ? config.pointerDirectionChangeThreshold\n : 5,\n zIndex: config?.zIndex,\n });\n this._dragRef.data = this;\n this._dragDropRegistry.registerDirectiveNode(this.element.nativeElement, this);\n if (config) {\n this._assignDefaults(config);\n }\n // Note that usually the container is assigned when the drop list is picks up the item, but in\n // some cases (mainly transplanted views with OnPush, see #18341) we may end up in a situation\n // where there are no items on the first change detection pass, but the items get picked up as\n // soon as the user triggers another pass by dragging. This is a problem, because the item would\n // have to switch from standalone mode to drag mode in the middle of the dragging sequence which\n // is too late since the two modes save different kinds of information. We work around it by\n // assigning the drop container both from here and the list.\n if (dropContainer) {\n this._dragRef._withDropContainer(dropContainer._dropListRef);\n dropContainer.addItem(this);\n // The drop container reads this so we need to sync it here.\n dropContainer._dropListRef.beforeStarted.pipe(takeUntil(this._destroyed)).subscribe(() => {\n this._dragRef.scale = this.scale;\n });\n }\n this._syncInputs(this._dragRef);\n this._handleEvents(this._dragRef);\n }\n /**\n * Returns the element that is being used as a placeholder\n * while the current element is being dragged.\n */\n getPlaceholderElement() {\n return this._dragRef.getPlaceholderElement();\n }\n /** Returns the root draggable element. */\n getRootElement() {\n return this._dragRef.getRootElement();\n }\n /** Resets a standalone drag item to its initial position. */\n reset() {\n this._dragRef.reset();\n }\n /**\n * Gets the pixel coordinates of the draggable outside of a drop container.\n */\n getFreeDragPosition() {\n return this._dragRef.getFreeDragPosition();\n }\n /**\n * Sets the current position in pixels the draggable outside of a drop container.\n * @param value New position to be set.\n */\n setFreeDragPosition(value) {\n this._dragRef.setFreeDragPosition(value);\n }\n ngAfterViewInit() {\n // We need to wait until after render, in order for the reference\n // element to be in the proper place in the DOM. This is mostly relevant\n // for draggable elements inside portals since they get stamped out in\n // their original DOM position, and then they get transferred to the portal.\n afterNextRender(() => {\n this._updateRootElement();\n this._setupHandlesListener();\n this._dragRef.scale = this.scale;\n if (this.freeDragPosition) {\n this._dragRef.setFreeDragPosition(this.freeDragPosition);\n }\n }, { injector: this._injector });\n }\n ngOnChanges(changes) {\n const rootSelectorChange = changes['rootElementSelector'];\n const positionChange = changes['freeDragPosition'];\n // We don't have to react to the first change since it's being\n // handled in the `afterNextRender` queued up in the constructor.\n if (rootSelectorChange && !rootSelectorChange.firstChange) {\n this._updateRootElement();\n }\n // Scale affects the free drag position so we need to sync it up here.\n this._dragRef.scale = this.scale;\n // Skip the first change since it's being handled in the `afterNextRender` queued up in the\n // constructor.\n if (positionChange && !positionChange.firstChange && this.freeDragPosition) {\n this._dragRef.setFreeDragPosition(this.freeDragPosition);\n }\n }\n ngOnDestroy() {\n if (this.dropContainer) {\n this.dropContainer.removeItem(this);\n }\n this._dragDropRegistry.removeDirectiveNode(this.element.nativeElement);\n // Unnecessary in most cases, but used to avoid extra change detections with `zone-paths-rxjs`.\n this._ngZone.runOutsideAngular(() => {\n this._handles.complete();\n this._destroyed.next();\n this._destroyed.complete();\n this._dragRef.dispose();\n });\n }\n _addHandle(handle) {\n const handles = this._handles.getValue();\n handles.push(handle);\n this._handles.next(handles);\n }\n _removeHandle(handle) {\n const handles = this._handles.getValue();\n const index = handles.indexOf(handle);\n if (index > -1) {\n handles.splice(index, 1);\n this._handles.next(handles);\n }\n }\n _setPreviewTemplate(preview) {\n this._previewTemplate = preview;\n }\n _resetPreviewTemplate(preview) {\n if (preview === this._previewTemplate) {\n this._previewTemplate = null;\n }\n }\n _setPlaceholderTemplate(placeholder) {\n this._placeholderTemplate = placeholder;\n }\n _resetPlaceholderTemplate(placeholder) {\n if (placeholder === this._placeholderTemplate) {\n this._placeholderTemplate = null;\n }\n }\n /** Syncs the root element with the `DragRef`. */\n _updateRootElement() {\n const element = this.element.nativeElement;\n let rootElement = element;\n if (this.rootElementSelector) {\n rootElement =\n element.closest !== undefined\n ? element.closest(this.rootElementSelector)\n : // Comment tag doesn't have closest method, so use parent's one.\n element.parentElement?.closest(this.rootElementSelector);\n }\n if (rootElement && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n assertElementNode(rootElement, 'cdkDrag');\n }\n this._dragRef.withRootElement(rootElement || element);\n }\n /** Gets the boundary element, based on the `boundaryElement` value. */\n _getBoundaryElement() {\n const boundary = this.boundaryElement;\n if (!boundary) {\n return null;\n }\n if (typeof boundary === 'string') {\n return this.element.nativeElement.closest(boundary);\n }\n return coerceElement(boundary);\n }\n /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */\n _syncInputs(ref) {\n ref.beforeStarted.subscribe(() => {\n if (!ref.isDragging()) {\n const dir = this._dir;\n const dragStartDelay = this.dragStartDelay;\n const placeholder = this._placeholderTemplate\n ? {\n template: this._placeholderTemplate.templateRef,\n context: this._placeholderTemplate.data,\n viewContainer: this._viewContainerRef,\n }\n : null;\n const preview = this._previewTemplate\n ? {\n template: this._previewTemplate.templateRef,\n context: this._previewTemplate.data,\n matchSize: this._previewTemplate.matchSize,\n viewContainer: this._viewContainerRef,\n }\n : null;\n ref.disabled = this.disabled;\n ref.lockAxis = this.lockAxis;\n ref.scale = this.scale;\n ref.dragStartDelay =\n typeof dragStartDelay === 'object' && dragStartDelay\n ? dragStartDelay\n : coerceNumberProperty(dragStartDelay);\n ref.constrainPosition = this.constrainPosition;\n ref.previewClass = this.previewClass;\n ref\n .withBoundaryElement(this._getBoundaryElement())\n .withPlaceholderTemplate(placeholder)\n .withPreviewTemplate(preview)\n .withPreviewContainer(this.previewContainer || 'global');\n if (dir) {\n ref.withDirection(dir.value);\n }\n }\n });\n // This only needs to be resolved once.\n ref.beforeStarted.pipe(take(1)).subscribe(() => {\n // If we managed to resolve a parent through DI, use it.\n if (this._parentDrag) {\n ref.withParent(this._parentDrag._dragRef);\n return;\n }\n // Otherwise fall back to resolving the parent by looking up the DOM. This can happen if\n // the item was projected into another item by something like `ngTemplateOutlet`.\n let parent = this.element.nativeElement.parentElement;\n while (parent) {\n const parentDrag = this._dragDropRegistry.getDragDirectiveForNode(parent);\n if (parentDrag) {\n ref.withParent(parentDrag._dragRef);\n break;\n }\n parent = parent.parentElement;\n }\n });\n }\n /** Handles the events from the underlying `DragRef`. */\n _handleEvents(ref) {\n ref.started.subscribe(startEvent => {\n this.started.emit({ source: this, event: startEvent.event });\n // Since all of these events run outside of change detection,\n // we need to ensure that everything is marked correctly.\n this._changeDetectorRef.markForCheck();\n });\n ref.released.subscribe(releaseEvent => {\n this.released.emit({ source: this, event: releaseEvent.event });\n });\n ref.ended.subscribe(endEvent => {\n this.ended.emit({\n source: this,\n distance: endEvent.distance,\n dropPoint: endEvent.dropPoint,\n event: endEvent.event,\n });\n // Since all of these events run outside of change detection,\n // we need to ensure that everything is marked correctly.\n this._changeDetectorRef.markForCheck();\n });\n ref.entered.subscribe(enterEvent => {\n this.entered.emit({\n container: enterEvent.container.data,\n item: this,\n currentIndex: enterEvent.currentIndex,\n });\n });\n ref.exited.subscribe(exitEvent => {\n this.exited.emit({\n container: exitEvent.container.data,\n item: this,\n });\n });\n ref.dropped.subscribe(dropEvent => {\n this.dropped.emit({\n previousIndex: dropEvent.previousIndex,\n currentIndex: dropEvent.currentIndex,\n previousContainer: dropEvent.previousContainer.data,\n container: dropEvent.container.data,\n isPointerOverContainer: dropEvent.isPointerOverContainer,\n item: this,\n distance: dropEvent.distance,\n dropPoint: dropEvent.dropPoint,\n event: dropEvent.event,\n });\n });\n }\n /** Assigns the default input values based on a provided config object. */\n _assignDefaults(config) {\n const { lockAxis, dragStartDelay, constrainPosition, previewClass, boundaryElement, draggingDisabled, rootElementSelector, previewContainer, } = config;\n this.disabled = draggingDisabled == null ? false : draggingDisabled;\n this.dragStartDelay = dragStartDelay || 0;\n if (lockAxis) {\n this.lockAxis = lockAxis;\n }\n if (constrainPosition) {\n this.constrainPosition = constrainPosition;\n }\n if (previewClass) {\n this.previewClass = previewClass;\n }\n if (boundaryElement) {\n this.boundaryElement = boundaryElement;\n }\n if (rootElementSelector) {\n this.rootElementSelector = rootElementSelector;\n }\n if (previewContainer) {\n this.previewContainer = previewContainer;\n }\n }\n /** Sets up the listener that syncs the handles with the drag ref. */\n _setupHandlesListener() {\n // Listen for any newly-added handles.\n this._handles\n .pipe(\n // Sync the new handles with the DragRef.\n tap(handles => {\n const handleElements = handles.map(handle => handle.element);\n // Usually handles are only allowed to be a descendant of the drag element, but if\n // the consumer defined a different drag root, we should allow the drag element\n // itself to be a handle too.\n if (this._selfHandle && this.rootElementSelector) {\n handleElements.push(this.element);\n }\n this._dragRef.withHandles(handleElements);\n }), \n // Listen if the state of any of the handles changes.\n switchMap((handles) => {\n return merge(...handles.map(item => item._stateChanges.pipe(startWith(item))));\n }), takeUntil(this._destroyed))\n .subscribe(handleInstance => {\n // Enabled/disable the handle that changed in the DragRef.\n const dragRef = this._dragRef;\n const handle = handleInstance.element.nativeElement;\n handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);\n });\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDrag, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkDrag, isStandalone: true, selector: \"[cdkDrag]\", inputs: { data: [\"cdkDragData\", \"data\"], lockAxis: [\"cdkDragLockAxis\", \"lockAxis\"], rootElementSelector: [\"cdkDragRootElement\", \"rootElementSelector\"], boundaryElement: [\"cdkDragBoundary\", \"boundaryElement\"], dragStartDelay: [\"cdkDragStartDelay\", \"dragStartDelay\"], freeDragPosition: [\"cdkDragFreeDragPosition\", \"freeDragPosition\"], disabled: [\"cdkDragDisabled\", \"disabled\", booleanAttribute], constrainPosition: [\"cdkDragConstrainPosition\", \"constrainPosition\"], previewClass: [\"cdkDragPreviewClass\", \"previewClass\"], previewContainer: [\"cdkDragPreviewContainer\", \"previewContainer\"], scale: [\"cdkDragScale\", \"scale\", numberAttribute] }, outputs: { started: \"cdkDragStarted\", released: \"cdkDragReleased\", ended: \"cdkDragEnded\", entered: \"cdkDragEntered\", exited: \"cdkDragExited\", dropped: \"cdkDragDropped\", moved: \"cdkDragMoved\" }, host: { properties: { \"class.cdk-drag-disabled\": \"disabled\", \"class.cdk-drag-dragging\": \"_dragRef.isDragging()\" }, classAttribute: \"cdk-drag\" }, providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }], exportAs: [\"cdkDrag\"], usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDrag, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkDrag]',\n exportAs: 'cdkDrag',\n host: {\n 'class': 'cdk-drag',\n '[class.cdk-drag-disabled]': 'disabled',\n '[class.cdk-drag-dragging]': '_dragRef.isDragging()',\n },\n providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }],\n }]\n }], ctorParameters: () => [], propDecorators: { data: [{\n type: Input,\n args: ['cdkDragData']\n }], lockAxis: [{\n type: Input,\n args: ['cdkDragLockAxis']\n }], rootElementSelector: [{\n type: Input,\n args: ['cdkDragRootElement']\n }], boundaryElement: [{\n type: Input,\n args: ['cdkDragBoundary']\n }], dragStartDelay: [{\n type: Input,\n args: ['cdkDragStartDelay']\n }], freeDragPosition: [{\n type: Input,\n args: ['cdkDragFreeDragPosition']\n }], disabled: [{\n type: Input,\n args: [{ alias: 'cdkDragDisabled', transform: booleanAttribute }]\n }], constrainPosition: [{\n type: Input,\n args: ['cdkDragConstrainPosition']\n }], previewClass: [{\n type: Input,\n args: ['cdkDragPreviewClass']\n }], previewContainer: [{\n type: Input,\n args: ['cdkDragPreviewContainer']\n }], scale: [{\n type: Input,\n args: [{ alias: 'cdkDragScale', transform: numberAttribute }]\n }], started: [{\n type: Output,\n args: ['cdkDragStarted']\n }], released: [{\n type: Output,\n args: ['cdkDragReleased']\n }], ended: [{\n type: Output,\n args: ['cdkDragEnded']\n }], entered: [{\n type: Output,\n args: ['cdkDragEntered']\n }], exited: [{\n type: Output,\n args: ['cdkDragExited']\n }], dropped: [{\n type: Output,\n args: ['cdkDragDropped']\n }], moved: [{\n type: Output,\n args: ['cdkDragMoved']\n }] } });\n\n/**\n * Injection token that can be used to reference instances of `CdkDropListGroup`. It serves as\n * alternative token to the actual `CdkDropListGroup` class which could cause unnecessary\n * retention of the class and its directive metadata.\n */\nconst CDK_DROP_LIST_GROUP = new InjectionToken('CdkDropListGroup');\n/**\n * Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`\n * elements that are placed inside a `cdkDropListGroup` will be connected to each other\n * automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input\n * from `cdkDropList`.\n */\nclass CdkDropListGroup {\n /** Drop lists registered inside the group. */\n _items = new Set();\n /** Whether starting a dragging sequence from inside this group is disabled. */\n disabled = false;\n ngOnDestroy() {\n this._items.clear();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDropListGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkDropListGroup, isStandalone: true, selector: \"[cdkDropListGroup]\", inputs: { disabled: [\"cdkDropListGroupDisabled\", \"disabled\", booleanAttribute] }, providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }], exportAs: [\"cdkDropListGroup\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDropListGroup, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkDropListGroup]',\n exportAs: 'cdkDropListGroup',\n providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }],\n }]\n }], propDecorators: { disabled: [{\n type: Input,\n args: [{ alias: 'cdkDropListGroupDisabled', transform: booleanAttribute }]\n }] } });\n\n/** Container that wraps a set of draggable items. */\nclass CdkDropList {\n element = inject(ElementRef);\n _changeDetectorRef = inject(ChangeDetectorRef);\n _scrollDispatcher = inject(ScrollDispatcher);\n _dir = inject(Directionality, { optional: true });\n _group = inject(CDK_DROP_LIST_GROUP, {\n optional: true,\n skipSelf: true,\n });\n /** Emits when the list has been destroyed. */\n _destroyed = new Subject();\n /** Whether the element's scrollable parents have been resolved. */\n _scrollableParentsResolved;\n /** Keeps track of the drop lists that are currently on the page. */\n static _dropLists = [];\n /** Reference to the underlying drop list instance. */\n _dropListRef;\n /**\n * Other draggable containers that this container is connected to and into which the\n * container's items can be transferred. Can either be references to other drop containers,\n * or their unique IDs.\n */\n connectedTo = [];\n /** Arbitrary data to attach to this container. */\n data;\n /** Direction in which the list is oriented. */\n orientation;\n /**\n * Unique ID for the drop zone. Can be used as a reference\n * in the `connectedTo` of another `CdkDropList`.\n */\n id = inject(_IdGenerator).getId('cdk-drop-list-');\n /** Locks the position of the draggable elements inside the container along the specified axis. */\n lockAxis;\n /** Whether starting a dragging sequence from this container is disabled. */\n get disabled() {\n return this._disabled || (!!this._group && this._group.disabled);\n }\n set disabled(value) {\n // Usually we sync the directive and ref state right before dragging starts, in order to have\n // a single point of failure and to avoid having to use setters for everything. `disabled` is\n // a special case, because it can prevent the `beforeStarted` event from firing, which can lock\n // the user in a disabled state, so we also need to sync it as it's being set.\n this._dropListRef.disabled = this._disabled = value;\n }\n _disabled;\n /** Whether sorting within this drop list is disabled. */\n sortingDisabled;\n /**\n * Function that is used to determine whether an item\n * is allowed to be moved into a drop container.\n */\n enterPredicate = () => true;\n /** Functions that is used to determine whether an item can be sorted into a particular index. */\n sortPredicate = () => true;\n /** Whether to auto-scroll the view when the user moves their pointer close to the edges. */\n autoScrollDisabled;\n /** Number of pixels to scroll for each frame when auto-scrolling an element. */\n autoScrollStep;\n /**\n * Selector that will be used to resolve an alternate element container for the drop list.\n * Passing an alternate container is useful for the cases where one might not have control\n * over the parent node of the draggable items within the list (e.g. due to content projection).\n * This allows for usages like:\n *\n * ```\n *
    \n *
    \n *
    \n *
    \n *
    \n * ```\n */\n elementContainerSelector;\n /** Emits when the user drops an item inside the container. */\n dropped = new EventEmitter();\n /**\n * Emits when the user has moved a new drag item into this container.\n */\n entered = new EventEmitter();\n /**\n * Emits when the user removes an item from the container\n * by dragging it into another container.\n */\n exited = new EventEmitter();\n /** Emits as the user is swapping items while actively dragging. */\n sorted = new EventEmitter();\n /**\n * Keeps track of the items that are registered with this container. Historically we used to\n * do this with a `ContentChildren` query, however queries don't handle transplanted views very\n * well which means that we can't handle cases like dragging the headers of a `mat-table`\n * correctly. What we do instead is to have the items register themselves with the container\n * and then we sort them based on their position in the DOM.\n */\n _unsortedItems = new Set();\n constructor() {\n const dragDrop = inject(DragDrop);\n const config = inject(CDK_DRAG_CONFIG, { optional: true });\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertElementNode(this.element.nativeElement, 'cdkDropList');\n }\n this._dropListRef = dragDrop.createDropList(this.element);\n this._dropListRef.data = this;\n if (config) {\n this._assignDefaults(config);\n }\n this._dropListRef.enterPredicate = (drag, drop) => {\n return this.enterPredicate(drag.data, drop.data);\n };\n this._dropListRef.sortPredicate = (index, drag, drop) => {\n return this.sortPredicate(index, drag.data, drop.data);\n };\n this._setupInputSyncSubscription(this._dropListRef);\n this._handleEvents(this._dropListRef);\n CdkDropList._dropLists.push(this);\n if (this._group) {\n this._group._items.add(this);\n }\n }\n /** Registers an items with the drop list. */\n addItem(item) {\n this._unsortedItems.add(item);\n if (this._dropListRef.isDragging()) {\n this._syncItemsWithRef();\n }\n }\n /** Removes an item from the drop list. */\n removeItem(item) {\n this._unsortedItems.delete(item);\n if (this._dropListRef.isDragging()) {\n this._syncItemsWithRef();\n }\n }\n /** Gets the registered items in the list, sorted by their position in the DOM. */\n getSortedItems() {\n return Array.from(this._unsortedItems).sort((a, b) => {\n const documentPosition = a._dragRef\n .getVisibleElement()\n .compareDocumentPosition(b._dragRef.getVisibleElement());\n // `compareDocumentPosition` returns a bitmask so we have to use a bitwise operator.\n // https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition\n // tslint:disable-next-line:no-bitwise\n return documentPosition & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;\n });\n }\n ngOnDestroy() {\n const index = CdkDropList._dropLists.indexOf(this);\n if (index > -1) {\n CdkDropList._dropLists.splice(index, 1);\n }\n if (this._group) {\n this._group._items.delete(this);\n }\n this._unsortedItems.clear();\n this._dropListRef.dispose();\n this._destroyed.next();\n this._destroyed.complete();\n }\n /** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */\n _setupInputSyncSubscription(ref) {\n if (this._dir) {\n this._dir.change\n .pipe(startWith(this._dir.value), takeUntil(this._destroyed))\n .subscribe(value => ref.withDirection(value));\n }\n ref.beforeStarted.subscribe(() => {\n const siblings = coerceArray(this.connectedTo).map(drop => {\n if (typeof drop === 'string') {\n const correspondingDropList = CdkDropList._dropLists.find(list => list.id === drop);\n if (!correspondingDropList && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n console.warn(`CdkDropList could not find connected drop list with id \"${drop}\"`);\n }\n return correspondingDropList;\n }\n return drop;\n });\n if (this._group) {\n this._group._items.forEach(drop => {\n if (siblings.indexOf(drop) === -1) {\n siblings.push(drop);\n }\n });\n }\n // Note that we resolve the scrollable parents here so that we delay the resolution\n // as long as possible, ensuring that the element is in its final place in the DOM.\n if (!this._scrollableParentsResolved) {\n const scrollableParents = this._scrollDispatcher\n .getAncestorScrollContainers(this.element)\n .map(scrollable => scrollable.getElementRef().nativeElement);\n this._dropListRef.withScrollableParents(scrollableParents);\n // Only do this once since it involves traversing the DOM and the parents\n // shouldn't be able to change without the drop list being destroyed.\n this._scrollableParentsResolved = true;\n }\n if (this.elementContainerSelector) {\n const container = this.element.nativeElement.querySelector(this.elementContainerSelector);\n if (!container && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw new Error(`CdkDropList could not find an element container matching the selector \"${this.elementContainerSelector}\"`);\n }\n ref.withElementContainer(container);\n }\n ref.disabled = this.disabled;\n ref.lockAxis = this.lockAxis;\n ref.sortingDisabled = this.sortingDisabled;\n ref.autoScrollDisabled = this.autoScrollDisabled;\n ref.autoScrollStep = coerceNumberProperty(this.autoScrollStep, 2);\n ref\n .connectedTo(siblings.filter(drop => drop && drop !== this).map(list => list._dropListRef))\n .withOrientation(this.orientation);\n });\n }\n /** Handles events from the underlying DropListRef. */\n _handleEvents(ref) {\n ref.beforeStarted.subscribe(() => {\n this._syncItemsWithRef();\n this._changeDetectorRef.markForCheck();\n });\n ref.entered.subscribe(event => {\n this.entered.emit({\n container: this,\n item: event.item.data,\n currentIndex: event.currentIndex,\n });\n });\n ref.exited.subscribe(event => {\n this.exited.emit({\n container: this,\n item: event.item.data,\n });\n this._changeDetectorRef.markForCheck();\n });\n ref.sorted.subscribe(event => {\n this.sorted.emit({\n previousIndex: event.previousIndex,\n currentIndex: event.currentIndex,\n container: this,\n item: event.item.data,\n });\n });\n ref.dropped.subscribe(dropEvent => {\n this.dropped.emit({\n previousIndex: dropEvent.previousIndex,\n currentIndex: dropEvent.currentIndex,\n previousContainer: dropEvent.previousContainer.data,\n container: dropEvent.container.data,\n item: dropEvent.item.data,\n isPointerOverContainer: dropEvent.isPointerOverContainer,\n distance: dropEvent.distance,\n dropPoint: dropEvent.dropPoint,\n event: dropEvent.event,\n });\n // Mark for check since all of these events run outside of change\n // detection and we're not guaranteed for something else to have triggered it.\n this._changeDetectorRef.markForCheck();\n });\n merge(ref.receivingStarted, ref.receivingStopped).subscribe(() => this._changeDetectorRef.markForCheck());\n }\n /** Assigns the default input values based on a provided config object. */\n _assignDefaults(config) {\n const { lockAxis, draggingDisabled, sortingDisabled, listAutoScrollDisabled, listOrientation } = config;\n this.disabled = draggingDisabled == null ? false : draggingDisabled;\n this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;\n this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;\n this.orientation = listOrientation || 'vertical';\n if (lockAxis) {\n this.lockAxis = lockAxis;\n }\n }\n /** Syncs up the registered drag items with underlying drop list ref. */\n _syncItemsWithRef() {\n this._dropListRef.withItems(this.getSortedItems().map(item => item._dragRef));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDropList, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkDropList, isStandalone: true, selector: \"[cdkDropList], cdk-drop-list\", inputs: { connectedTo: [\"cdkDropListConnectedTo\", \"connectedTo\"], data: [\"cdkDropListData\", \"data\"], orientation: [\"cdkDropListOrientation\", \"orientation\"], id: \"id\", lockAxis: [\"cdkDropListLockAxis\", \"lockAxis\"], disabled: [\"cdkDropListDisabled\", \"disabled\", booleanAttribute], sortingDisabled: [\"cdkDropListSortingDisabled\", \"sortingDisabled\", booleanAttribute], enterPredicate: [\"cdkDropListEnterPredicate\", \"enterPredicate\"], sortPredicate: [\"cdkDropListSortPredicate\", \"sortPredicate\"], autoScrollDisabled: [\"cdkDropListAutoScrollDisabled\", \"autoScrollDisabled\", booleanAttribute], autoScrollStep: [\"cdkDropListAutoScrollStep\", \"autoScrollStep\"], elementContainerSelector: [\"cdkDropListElementContainer\", \"elementContainerSelector\"] }, outputs: { dropped: \"cdkDropListDropped\", entered: \"cdkDropListEntered\", exited: \"cdkDropListExited\", sorted: \"cdkDropListSorted\" }, host: { properties: { \"attr.id\": \"id\", \"class.cdk-drop-list-disabled\": \"disabled\", \"class.cdk-drop-list-dragging\": \"_dropListRef.isDragging()\", \"class.cdk-drop-list-receiving\": \"_dropListRef.isReceiving()\" }, classAttribute: \"cdk-drop-list\" }, providers: [\n // Prevent child drop lists from picking up the same group as their parent.\n { provide: CDK_DROP_LIST_GROUP, useValue: undefined },\n { provide: CDK_DROP_LIST, useExisting: CdkDropList },\n ], exportAs: [\"cdkDropList\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDropList, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkDropList], cdk-drop-list',\n exportAs: 'cdkDropList',\n providers: [\n // Prevent child drop lists from picking up the same group as their parent.\n { provide: CDK_DROP_LIST_GROUP, useValue: undefined },\n { provide: CDK_DROP_LIST, useExisting: CdkDropList },\n ],\n host: {\n 'class': 'cdk-drop-list',\n '[attr.id]': 'id',\n '[class.cdk-drop-list-disabled]': 'disabled',\n '[class.cdk-drop-list-dragging]': '_dropListRef.isDragging()',\n '[class.cdk-drop-list-receiving]': '_dropListRef.isReceiving()',\n },\n }]\n }], ctorParameters: () => [], propDecorators: { connectedTo: [{\n type: Input,\n args: ['cdkDropListConnectedTo']\n }], data: [{\n type: Input,\n args: ['cdkDropListData']\n }], orientation: [{\n type: Input,\n args: ['cdkDropListOrientation']\n }], id: [{\n type: Input\n }], lockAxis: [{\n type: Input,\n args: ['cdkDropListLockAxis']\n }], disabled: [{\n type: Input,\n args: [{ alias: 'cdkDropListDisabled', transform: booleanAttribute }]\n }], sortingDisabled: [{\n type: Input,\n args: [{ alias: 'cdkDropListSortingDisabled', transform: booleanAttribute }]\n }], enterPredicate: [{\n type: Input,\n args: ['cdkDropListEnterPredicate']\n }], sortPredicate: [{\n type: Input,\n args: ['cdkDropListSortPredicate']\n }], autoScrollDisabled: [{\n type: Input,\n args: [{ alias: 'cdkDropListAutoScrollDisabled', transform: booleanAttribute }]\n }], autoScrollStep: [{\n type: Input,\n args: ['cdkDropListAutoScrollStep']\n }], elementContainerSelector: [{\n type: Input,\n args: ['cdkDropListElementContainer']\n }], dropped: [{\n type: Output,\n args: ['cdkDropListDropped']\n }], entered: [{\n type: Output,\n args: ['cdkDropListEntered']\n }], exited: [{\n type: Output,\n args: ['cdkDropListExited']\n }], sorted: [{\n type: Output,\n args: ['cdkDropListSorted']\n }] } });\n\n/**\n * Injection token that can be used to reference instances of `CdkDragPreview`. It serves as\n * alternative token to the actual `CdkDragPreview` class which could cause unnecessary\n * retention of the class and its directive metadata.\n */\nconst CDK_DRAG_PREVIEW = new InjectionToken('CdkDragPreview');\n/**\n * Element that will be used as a template for the preview\n * of a CdkDrag when it is being dragged.\n */\nclass CdkDragPreview {\n templateRef = inject(TemplateRef);\n _drag = inject(CDK_DRAG_PARENT, { optional: true });\n /** Context data to be added to the preview template instance. */\n data;\n /** Whether the preview should preserve the same size as the item that is being dragged. */\n matchSize = false;\n constructor() {\n this._drag?._setPreviewTemplate(this);\n }\n ngOnDestroy() {\n this._drag?._resetPreviewTemplate(this);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDragPreview, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkDragPreview, isStandalone: true, selector: \"ng-template[cdkDragPreview]\", inputs: { data: \"data\", matchSize: [\"matchSize\", \"matchSize\", booleanAttribute] }, providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDragPreview, decorators: [{\n type: Directive,\n args: [{\n selector: 'ng-template[cdkDragPreview]',\n providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }],\n }]\n }], ctorParameters: () => [], propDecorators: { data: [{\n type: Input\n }], matchSize: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }] } });\n\n/**\n * Injection token that can be used to reference instances of `CdkDragPlaceholder`. It serves as\n * alternative token to the actual `CdkDragPlaceholder` class which could cause unnecessary\n * retention of the class and its directive metadata.\n */\nconst CDK_DRAG_PLACEHOLDER = new InjectionToken('CdkDragPlaceholder');\n/**\n * Element that will be used as a template for the placeholder of a CdkDrag when\n * it is being dragged. The placeholder is displayed in place of the element being dragged.\n */\nclass CdkDragPlaceholder {\n templateRef = inject(TemplateRef);\n _drag = inject(CDK_DRAG_PARENT, { optional: true });\n /** Context data to be added to the placeholder template instance. */\n data;\n constructor() {\n this._drag?._setPlaceholderTemplate(this);\n }\n ngOnDestroy() {\n this._drag?._resetPlaceholderTemplate(this);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDragPlaceholder, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkDragPlaceholder, isStandalone: true, selector: \"ng-template[cdkDragPlaceholder]\", inputs: { data: \"data\" }, providers: [{ provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder }], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkDragPlaceholder, decorators: [{\n type: Directive,\n args: [{\n selector: 'ng-template[cdkDragPlaceholder]',\n providers: [{ provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder }],\n }]\n }], ctorParameters: () => [], propDecorators: { data: [{\n type: Input\n }] } });\n\nconst DRAG_DROP_DIRECTIVES = [\n CdkDropList,\n CdkDropListGroup,\n CdkDrag,\n CdkDragHandle,\n CdkDragPreview,\n CdkDragPlaceholder,\n];\nclass DragDropModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDropModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDropModule, imports: [CdkDropList,\n CdkDropListGroup,\n CdkDrag,\n CdkDragHandle,\n CdkDragPreview,\n CdkDragPlaceholder], exports: [CdkScrollableModule, CdkDropList,\n CdkDropListGroup,\n CdkDrag,\n CdkDragHandle,\n CdkDragPreview,\n CdkDragPlaceholder] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDropModule, providers: [DragDrop], imports: [CdkScrollableModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: DragDropModule, decorators: [{\n type: NgModule,\n args: [{\n imports: DRAG_DROP_DIRECTIVES,\n exports: [CdkScrollableModule, ...DRAG_DROP_DIRECTIVES],\n providers: [DragDrop],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { CDK_DRAG_CONFIG, CDK_DRAG_HANDLE, CDK_DRAG_PARENT, CDK_DRAG_PLACEHOLDER, CDK_DRAG_PREVIEW, CDK_DROP_LIST, CDK_DROP_LIST_GROUP, CdkDrag, CdkDragHandle, CdkDragPlaceholder, CdkDragPreview, CdkDropList, CdkDropListGroup, DragDrop, DragDropModule, DragDropRegistry, DragRef, DropListRef, copyArrayItem, moveItemInArray, transferArrayItem };\n","import { asyncScheduler } from '../scheduler/async';\nimport { timer } from './timer';\nexport function interval(period = 0, scheduler = asyncScheduler) {\n if (period < 0) {\n period = 0;\n }\n return timer(period, period, scheduler);\n}\n","const MAC_ENTER = 3;\nconst BACKSPACE = 8;\nconst TAB = 9;\nconst NUM_CENTER = 12;\nconst ENTER = 13;\nconst SHIFT = 16;\nconst CONTROL = 17;\nconst ALT = 18;\nconst PAUSE = 19;\nconst CAPS_LOCK = 20;\nconst ESCAPE = 27;\nconst SPACE = 32;\nconst PAGE_UP = 33;\nconst PAGE_DOWN = 34;\nconst END = 35;\nconst HOME = 36;\nconst LEFT_ARROW = 37;\nconst UP_ARROW = 38;\nconst RIGHT_ARROW = 39;\nconst DOWN_ARROW = 40;\nconst PLUS_SIGN = 43;\nconst PRINT_SCREEN = 44;\nconst INSERT = 45;\nconst DELETE = 46;\nconst ZERO = 48;\nconst ONE = 49;\nconst TWO = 50;\nconst THREE = 51;\nconst FOUR = 52;\nconst FIVE = 53;\nconst SIX = 54;\nconst SEVEN = 55;\nconst EIGHT = 56;\nconst NINE = 57;\nconst FF_SEMICOLON = 59; // Firefox (Gecko) fires this for semicolon instead of 186\nconst FF_EQUALS = 61; // Firefox (Gecko) fires this for equals instead of 187\nconst QUESTION_MARK = 63;\nconst AT_SIGN = 64;\nconst A = 65;\nconst B = 66;\nconst C = 67;\nconst D = 68;\nconst E = 69;\nconst F = 70;\nconst G = 71;\nconst H = 72;\nconst I = 73;\nconst J = 74;\nconst K = 75;\nconst L = 76;\nconst M = 77;\nconst N = 78;\nconst O = 79;\nconst P = 80;\nconst Q = 81;\nconst R = 82;\nconst S = 83;\nconst T = 84;\nconst U = 85;\nconst V = 86;\nconst W = 87;\nconst X = 88;\nconst Y = 89;\nconst Z = 90;\nconst META = 91; // WIN_KEY_LEFT\nconst MAC_WK_CMD_LEFT = 91;\nconst MAC_WK_CMD_RIGHT = 93;\nconst CONTEXT_MENU = 93;\nconst NUMPAD_ZERO = 96;\nconst NUMPAD_ONE = 97;\nconst NUMPAD_TWO = 98;\nconst NUMPAD_THREE = 99;\nconst NUMPAD_FOUR = 100;\nconst NUMPAD_FIVE = 101;\nconst NUMPAD_SIX = 102;\nconst NUMPAD_SEVEN = 103;\nconst NUMPAD_EIGHT = 104;\nconst NUMPAD_NINE = 105;\nconst NUMPAD_MULTIPLY = 106;\nconst NUMPAD_PLUS = 107;\nconst NUMPAD_MINUS = 109;\nconst NUMPAD_PERIOD = 110;\nconst NUMPAD_DIVIDE = 111;\nconst F1 = 112;\nconst F2 = 113;\nconst F3 = 114;\nconst F4 = 115;\nconst F5 = 116;\nconst F6 = 117;\nconst F7 = 118;\nconst F8 = 119;\nconst F9 = 120;\nconst F10 = 121;\nconst F11 = 122;\nconst F12 = 123;\nconst NUM_LOCK = 144;\nconst SCROLL_LOCK = 145;\nconst FIRST_MEDIA = 166;\nconst FF_MINUS = 173;\nconst MUTE = 173; // Firefox (Gecko) fires 181 for MUTE\nconst VOLUME_DOWN = 174; // Firefox (Gecko) fires 182 for VOLUME_DOWN\nconst VOLUME_UP = 175; // Firefox (Gecko) fires 183 for VOLUME_UP\nconst FF_MUTE = 181;\nconst FF_VOLUME_DOWN = 182;\nconst LAST_MEDIA = 183;\nconst FF_VOLUME_UP = 183;\nconst SEMICOLON = 186; // Firefox (Gecko) fires 59 for SEMICOLON\nconst EQUALS = 187; // Firefox (Gecko) fires 61 for EQUALS\nconst COMMA = 188;\nconst DASH = 189; // Firefox (Gecko) fires 173 for DASH/MINUS\nconst PERIOD = 190;\nconst SLASH = 191;\nconst APOSTROPHE = 192;\nconst TILDE = 192;\nconst OPEN_SQUARE_BRACKET = 219;\nconst BACKSLASH = 220;\nconst CLOSE_SQUARE_BRACKET = 221;\nconst SINGLE_QUOTE = 222;\nconst MAC_META = 224;\n\n/**\n * Checks whether a modifier key is pressed.\n * @param event Event to be checked.\n */\nfunction hasModifierKey(event, ...modifiers) {\n if (modifiers.length) {\n return modifiers.some(modifier => event[modifier]);\n }\n return event.altKey || event.shiftKey || event.ctrlKey || event.metaKey;\n}\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { A, ALT, APOSTROPHE, AT_SIGN, B, BACKSLASH, BACKSPACE, C, CAPS_LOCK, CLOSE_SQUARE_BRACKET, COMMA, CONTEXT_MENU, CONTROL, D, DASH, DELETE, DOWN_ARROW, E, EIGHT, END, ENTER, EQUALS, ESCAPE, F, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, FF_EQUALS, FF_MINUS, FF_MUTE, FF_SEMICOLON, FF_VOLUME_DOWN, FF_VOLUME_UP, FIRST_MEDIA, FIVE, FOUR, G, H, HOME, I, INSERT, J, K, L, LAST_MEDIA, LEFT_ARROW, M, MAC_ENTER, MAC_META, MAC_WK_CMD_LEFT, MAC_WK_CMD_RIGHT, META, MUTE, N, NINE, NUMPAD_DIVIDE, NUMPAD_EIGHT, NUMPAD_FIVE, NUMPAD_FOUR, NUMPAD_MINUS, NUMPAD_MULTIPLY, NUMPAD_NINE, NUMPAD_ONE, NUMPAD_PERIOD, NUMPAD_PLUS, NUMPAD_SEVEN, NUMPAD_SIX, NUMPAD_THREE, NUMPAD_TWO, NUMPAD_ZERO, NUM_CENTER, NUM_LOCK, O, ONE, OPEN_SQUARE_BRACKET, P, PAGE_DOWN, PAGE_UP, PAUSE, PERIOD, PLUS_SIGN, PRINT_SCREEN, Q, QUESTION_MARK, R, RIGHT_ARROW, S, SCROLL_LOCK, SEMICOLON, SEVEN, SHIFT, SINGLE_QUOTE, SIX, SLASH, SPACE, T, TAB, THREE, TILDE, TWO, U, UP_ARROW, V, VOLUME_DOWN, VOLUME_UP, W, X, Y, Z, ZERO, hasModifierKey };\n","import * as i0 from '@angular/core';\nimport { NgModule, inject, CSP_NONCE, Injectable, NgZone } from '@angular/core';\nimport { coerceArray } from '@angular/cdk/coercion';\nimport { Subject, combineLatest, concat, Observable } from 'rxjs';\nimport { take, skip, debounceTime, map, startWith, takeUntil } from 'rxjs/operators';\nimport { Platform } from '@angular/cdk/platform';\n\nclass LayoutModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: LayoutModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: LayoutModule });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: LayoutModule });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: LayoutModule, decorators: [{\n type: NgModule,\n args: [{}]\n }] });\n\n/** Global registry for all dynamically-created, injected media queries. */\nconst mediaQueriesForWebkitCompatibility = new Set();\n/** Style tag that holds all of the dynamically-created media queries. */\nlet mediaQueryStyleNode;\n/** A utility for calling matchMedia queries. */\nclass MediaMatcher {\n _platform = inject(Platform);\n _nonce = inject(CSP_NONCE, { optional: true });\n /** The internal matchMedia method to return back a MediaQueryList like object. */\n _matchMedia;\n constructor() {\n this._matchMedia =\n this._platform.isBrowser && window.matchMedia\n ? // matchMedia is bound to the window scope intentionally as it is an illegal invocation to\n // call it from a different scope.\n window.matchMedia.bind(window)\n : noopMatchMedia;\n }\n /**\n * Evaluates the given media query and returns the native MediaQueryList from which results\n * can be retrieved.\n * Confirms the layout engine will trigger for the selector query provided and returns the\n * MediaQueryList for the query provided.\n */\n matchMedia(query) {\n if (this._platform.WEBKIT || this._platform.BLINK) {\n createEmptyStyleRule(query, this._nonce);\n }\n return this._matchMedia(query);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MediaMatcher, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MediaMatcher, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MediaMatcher, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/**\n * Creates an empty stylesheet that is used to work around browser inconsistencies related to\n * `matchMedia`. At the time of writing, it handles the following cases:\n * 1. On WebKit browsers, a media query has to have at least one rule in order for `matchMedia`\n * to fire. We work around it by declaring a dummy stylesheet with a `@media` declaration.\n * 2. In some cases Blink browsers will stop firing the `matchMedia` listener if none of the rules\n * inside the `@media` match existing elements on the page. We work around it by having one rule\n * targeting the `body`. See https://github.com/angular/components/issues/23546.\n */\nfunction createEmptyStyleRule(query, nonce) {\n if (mediaQueriesForWebkitCompatibility.has(query)) {\n return;\n }\n try {\n if (!mediaQueryStyleNode) {\n mediaQueryStyleNode = document.createElement('style');\n if (nonce) {\n mediaQueryStyleNode.setAttribute('nonce', nonce);\n }\n mediaQueryStyleNode.setAttribute('type', 'text/css');\n document.head.appendChild(mediaQueryStyleNode);\n }\n if (mediaQueryStyleNode.sheet) {\n mediaQueryStyleNode.sheet.insertRule(`@media ${query} {body{ }}`, 0);\n mediaQueriesForWebkitCompatibility.add(query);\n }\n }\n catch (e) {\n console.error(e);\n }\n}\n/** No-op matchMedia replacement for non-browser platforms. */\nfunction noopMatchMedia(query) {\n // Use `as any` here to avoid adding additional necessary properties for\n // the noop matcher.\n return {\n matches: query === 'all' || query === '',\n media: query,\n addListener: () => { },\n removeListener: () => { },\n };\n}\n\n/** Utility for checking the matching state of `@media` queries. */\nclass BreakpointObserver {\n _mediaMatcher = inject(MediaMatcher);\n _zone = inject(NgZone);\n /** A map of all media queries currently being listened for. */\n _queries = new Map();\n /** A subject for all other observables to takeUntil based on. */\n _destroySubject = new Subject();\n constructor() { }\n /** Completes the active subject, signalling to all other observables to complete. */\n ngOnDestroy() {\n this._destroySubject.next();\n this._destroySubject.complete();\n }\n /**\n * Whether one or more media queries match the current viewport size.\n * @param value One or more media queries to check.\n * @returns Whether any of the media queries match.\n */\n isMatched(value) {\n const queries = splitQueries(coerceArray(value));\n return queries.some(mediaQuery => this._registerQuery(mediaQuery).mql.matches);\n }\n /**\n * Gets an observable of results for the given queries that will emit new results for any changes\n * in matching of the given queries.\n * @param value One or more media queries to check.\n * @returns A stream of matches for the given queries.\n */\n observe(value) {\n const queries = splitQueries(coerceArray(value));\n const observables = queries.map(query => this._registerQuery(query).observable);\n let stateObservable = combineLatest(observables);\n // Emit the first state immediately, and then debounce the subsequent emissions.\n stateObservable = concat(stateObservable.pipe(take(1)), stateObservable.pipe(skip(1), debounceTime(0)));\n return stateObservable.pipe(map(breakpointStates => {\n const response = {\n matches: false,\n breakpoints: {},\n };\n breakpointStates.forEach(({ matches, query }) => {\n response.matches = response.matches || matches;\n response.breakpoints[query] = matches;\n });\n return response;\n }));\n }\n /** Registers a specific query to be listened for. */\n _registerQuery(query) {\n // Only set up a new MediaQueryList if it is not already being listened for.\n if (this._queries.has(query)) {\n return this._queries.get(query);\n }\n const mql = this._mediaMatcher.matchMedia(query);\n // Create callback for match changes and add it is as a listener.\n const queryObservable = new Observable((observer) => {\n // Listener callback methods are wrapped to be placed back in ngZone. Callbacks must be placed\n // back into the zone because matchMedia is only included in Zone.js by loading the\n // webapis-media-query.js file alongside the zone.js file. Additionally, some browsers do not\n // have MediaQueryList inherit from EventTarget, which causes inconsistencies in how Zone.js\n // patches it.\n const handler = (e) => this._zone.run(() => observer.next(e));\n mql.addListener(handler);\n return () => {\n mql.removeListener(handler);\n };\n }).pipe(startWith(mql), map(({ matches }) => ({ query, matches })), takeUntil(this._destroySubject));\n // Add the MediaQueryList to the set of queries.\n const output = { observable: queryObservable, mql };\n this._queries.set(query, output);\n return output;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BreakpointObserver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BreakpointObserver, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BreakpointObserver, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/**\n * Split each query string into separate query strings if two queries are provided as comma\n * separated.\n */\nfunction splitQueries(queries) {\n return queries\n .map(query => query.split(','))\n .reduce((a1, a2) => a1.concat(a2))\n .map(query => query.trim());\n}\n\n// PascalCase is being used as Breakpoints is used like an enum.\n// tslint:disable-next-line:variable-name\nconst Breakpoints = {\n XSmall: '(max-width: 599.98px)',\n Small: '(min-width: 600px) and (max-width: 959.98px)',\n Medium: '(min-width: 960px) and (max-width: 1279.98px)',\n Large: '(min-width: 1280px) and (max-width: 1919.98px)',\n XLarge: '(min-width: 1920px)',\n Handset: '(max-width: 599.98px) and (orientation: portrait), ' +\n '(max-width: 959.98px) and (orientation: landscape)',\n Tablet: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait), ' +\n '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',\n Web: '(min-width: 840px) and (orientation: portrait), ' +\n '(min-width: 1280px) and (orientation: landscape)',\n HandsetPortrait: '(max-width: 599.98px) and (orientation: portrait)',\n TabletPortrait: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait)',\n WebPortrait: '(min-width: 840px) and (orientation: portrait)',\n HandsetLandscape: '(max-width: 959.98px) and (orientation: landscape)',\n TabletLandscape: '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',\n WebLandscape: '(min-width: 1280px) and (orientation: landscape)',\n};\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { BreakpointObserver, Breakpoints, LayoutModule, MediaMatcher };\n","import { coerceElement, coerceNumberProperty } from '@angular/cdk/coercion';\nimport * as i0 from '@angular/core';\nimport { Injectable, inject, NgZone, ElementRef, EventEmitter, booleanAttribute, Directive, Output, Input, NgModule } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\nimport { map, filter, debounceTime } from 'rxjs/operators';\n\n// Angular may add, remove, or edit comment nodes during change detection. We don't care about\n// these changes because they don't affect the user-preceived content, and worse it can cause\n// infinite change detection cycles where the change detection updates a comment, triggering the\n// MutationObserver, triggering another change detection and kicking the cycle off again.\nfunction shouldIgnoreRecord(record) {\n // Ignore changes to comment text.\n if (record.type === 'characterData' && record.target instanceof Comment) {\n return true;\n }\n // Ignore addition / removal of comments.\n if (record.type === 'childList') {\n for (let i = 0; i < record.addedNodes.length; i++) {\n if (!(record.addedNodes[i] instanceof Comment)) {\n return false;\n }\n }\n for (let i = 0; i < record.removedNodes.length; i++) {\n if (!(record.removedNodes[i] instanceof Comment)) {\n return false;\n }\n }\n return true;\n }\n // Observe everything else.\n return false;\n}\n/**\n * Factory that creates a new MutationObserver and allows us to stub it out in unit tests.\n * @docs-private\n */\nclass MutationObserverFactory {\n create(callback) {\n return typeof MutationObserver === 'undefined' ? null : new MutationObserver(callback);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MutationObserverFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MutationObserverFactory, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: MutationObserverFactory, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n/** An injectable service that allows watching elements for changes to their content. */\nclass ContentObserver {\n _mutationObserverFactory = inject(MutationObserverFactory);\n /** Keeps track of the existing MutationObservers so they can be reused. */\n _observedElements = new Map();\n _ngZone = inject(NgZone);\n constructor() { }\n ngOnDestroy() {\n this._observedElements.forEach((_, element) => this._cleanupObserver(element));\n }\n observe(elementOrRef) {\n const element = coerceElement(elementOrRef);\n return new Observable((observer) => {\n const stream = this._observeElement(element);\n const subscription = stream\n .pipe(map(records => records.filter(record => !shouldIgnoreRecord(record))), filter(records => !!records.length))\n .subscribe(records => {\n this._ngZone.run(() => {\n observer.next(records);\n });\n });\n return () => {\n subscription.unsubscribe();\n this._unobserveElement(element);\n };\n });\n }\n /**\n * Observes the given element by using the existing MutationObserver if available, or creating a\n * new one if not.\n */\n _observeElement(element) {\n return this._ngZone.runOutsideAngular(() => {\n if (!this._observedElements.has(element)) {\n const stream = new Subject();\n const observer = this._mutationObserverFactory.create(mutations => stream.next(mutations));\n if (observer) {\n observer.observe(element, {\n characterData: true,\n childList: true,\n subtree: true,\n });\n }\n this._observedElements.set(element, { observer, stream, count: 1 });\n }\n else {\n this._observedElements.get(element).count++;\n }\n return this._observedElements.get(element).stream;\n });\n }\n /**\n * Un-observes the given element and cleans up the underlying MutationObserver if nobody else is\n * observing this element.\n */\n _unobserveElement(element) {\n if (this._observedElements.has(element)) {\n this._observedElements.get(element).count--;\n if (!this._observedElements.get(element).count) {\n this._cleanupObserver(element);\n }\n }\n }\n /** Clean up the underlying MutationObserver for the specified element. */\n _cleanupObserver(element) {\n if (this._observedElements.has(element)) {\n const { observer, stream } = this._observedElements.get(element);\n if (observer) {\n observer.disconnect();\n }\n stream.complete();\n this._observedElements.delete(element);\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ContentObserver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ContentObserver, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ContentObserver, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/**\n * Directive that triggers a callback whenever the content of\n * its associated element has changed.\n */\nclass CdkObserveContent {\n _contentObserver = inject(ContentObserver);\n _elementRef = inject(ElementRef);\n /** Event emitted for each change in the element's content. */\n event = new EventEmitter();\n /**\n * Whether observing content is disabled. This option can be used\n * to disconnect the underlying MutationObserver until it is needed.\n */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n this._disabled = value;\n this._disabled ? this._unsubscribe() : this._subscribe();\n }\n _disabled = false;\n /** Debounce interval for emitting the changes. */\n get debounce() {\n return this._debounce;\n }\n set debounce(value) {\n this._debounce = coerceNumberProperty(value);\n this._subscribe();\n }\n _debounce;\n _currentSubscription = null;\n constructor() { }\n ngAfterContentInit() {\n if (!this._currentSubscription && !this.disabled) {\n this._subscribe();\n }\n }\n ngOnDestroy() {\n this._unsubscribe();\n }\n _subscribe() {\n this._unsubscribe();\n const stream = this._contentObserver.observe(this._elementRef);\n this._currentSubscription = (this.debounce ? stream.pipe(debounceTime(this.debounce)) : stream).subscribe(this.event);\n }\n _unsubscribe() {\n this._currentSubscription?.unsubscribe();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkObserveContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkObserveContent, isStandalone: true, selector: \"[cdkObserveContent]\", inputs: { disabled: [\"cdkObserveContentDisabled\", \"disabled\", booleanAttribute], debounce: \"debounce\" }, outputs: { event: \"cdkObserveContent\" }, exportAs: [\"cdkObserveContent\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkObserveContent, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkObserveContent]',\n exportAs: 'cdkObserveContent',\n }]\n }], ctorParameters: () => [], propDecorators: { event: [{\n type: Output,\n args: ['cdkObserveContent']\n }], disabled: [{\n type: Input,\n args: [{ alias: 'cdkObserveContentDisabled', transform: booleanAttribute }]\n }], debounce: [{\n type: Input\n }] } });\nclass ObserversModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ObserversModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: ObserversModule, imports: [CdkObserveContent], exports: [CdkObserveContent] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ObserversModule, providers: [MutationObserverFactory] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ObserversModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [CdkObserveContent],\n exports: [CdkObserveContent],\n providers: [MutationObserverFactory],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { CdkObserveContent, ContentObserver, MutationObserverFactory, ObserversModule };\n","import * as i0 from '@angular/core';\nimport { inject, NgZone, RendererFactory2, Injectable } from '@angular/core';\nimport { Subject, Observable } from 'rxjs';\nimport { filter, shareReplay, takeUntil } from 'rxjs/operators';\n\n/**\n * Handler that logs \"ResizeObserver loop limit exceeded\" errors.\n * These errors are not shown in the Chrome console, so we log them to ensure developers are aware.\n * @param e The error\n */\nconst loopLimitExceededErrorHandler = (e) => {\n if (e instanceof ErrorEvent && e.message === 'ResizeObserver loop limit exceeded') {\n console.error(`${e.message}. This could indicate a performance issue with your app. See https://github.com/WICG/resize-observer/blob/master/explainer.md#error-handling`);\n }\n};\n/**\n * A shared ResizeObserver to be used for a particular box type (content-box, border-box, or\n * device-pixel-content-box)\n */\nclass SingleBoxSharedResizeObserver {\n _box;\n /** Stream that emits when the shared observer is destroyed. */\n _destroyed = new Subject();\n /** Stream of all events from the ResizeObserver. */\n _resizeSubject = new Subject();\n /** ResizeObserver used to observe element resize events. */\n _resizeObserver;\n /** A map of elements to streams of their resize events. */\n _elementObservables = new Map();\n constructor(\n /** The box type to observe for resizes. */\n _box) {\n this._box = _box;\n if (typeof ResizeObserver !== 'undefined') {\n this._resizeObserver = new ResizeObserver(entries => this._resizeSubject.next(entries));\n }\n }\n /**\n * Gets a stream of resize events for the given element.\n * @param target The element to observe.\n * @return The stream of resize events for the element.\n */\n observe(target) {\n if (!this._elementObservables.has(target)) {\n this._elementObservables.set(target, new Observable(observer => {\n const subscription = this._resizeSubject.subscribe(observer);\n this._resizeObserver?.observe(target, { box: this._box });\n return () => {\n this._resizeObserver?.unobserve(target);\n subscription.unsubscribe();\n this._elementObservables.delete(target);\n };\n }).pipe(filter(entries => entries.some(entry => entry.target === target)), \n // Share a replay of the last event so that subsequent calls to observe the same element\n // receive initial sizing info like the first one. Also enable ref counting so the\n // element will be automatically unobserved when there are no more subscriptions.\n shareReplay({ bufferSize: 1, refCount: true }), takeUntil(this._destroyed)));\n }\n return this._elementObservables.get(target);\n }\n /** Destroys this instance. */\n destroy() {\n this._destroyed.next();\n this._destroyed.complete();\n this._resizeSubject.complete();\n this._elementObservables.clear();\n }\n}\n/**\n * Allows observing resize events on multiple elements using a shared set of ResizeObserver.\n * Sharing a ResizeObserver instance is recommended for better performance (see\n * https://github.com/WICG/resize-observer/issues/59).\n *\n * Rather than share a single `ResizeObserver`, this class creates one `ResizeObserver` per type\n * of observed box ('content-box', 'border-box', and 'device-pixel-content-box'). This avoids\n * later calls to `observe` with a different box type from influencing the events dispatched to\n * earlier calls.\n */\nclass SharedResizeObserver {\n _cleanupErrorListener;\n /** Map of box type to shared resize observer. */\n _observers = new Map();\n /** The Angular zone. */\n _ngZone = inject(NgZone);\n constructor() {\n if (typeof ResizeObserver !== 'undefined' && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n this._ngZone.runOutsideAngular(() => {\n const renderer = inject(RendererFactory2).createRenderer(null, null);\n this._cleanupErrorListener = renderer.listen('window', 'error', loopLimitExceededErrorHandler);\n });\n }\n }\n ngOnDestroy() {\n for (const [, observer] of this._observers) {\n observer.destroy();\n }\n this._observers.clear();\n this._cleanupErrorListener?.();\n }\n /**\n * Gets a stream of resize events for the given target element and box type.\n * @param target The element to observe for resizes.\n * @param options Options to pass to the `ResizeObserver`\n * @return The stream of resize events for the element.\n */\n observe(target, options) {\n const box = options?.box || 'content-box';\n if (!this._observers.has(box)) {\n this._observers.set(box, new SingleBoxSharedResizeObserver(box));\n }\n return this._observers.get(box).observe(target);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: SharedResizeObserver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: SharedResizeObserver, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: SharedResizeObserver, decorators: [{\n type: Injectable,\n args: [{\n providedIn: 'root',\n }]\n }], ctorParameters: () => [] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { SharedResizeObserver };\n","import { ReplaySubject } from '../ReplaySubject';\nimport { share } from './share';\nexport function shareReplay(configOrBufferSize, windowTime, scheduler) {\n let bufferSize;\n let refCount = false;\n if (configOrBufferSize && typeof configOrBufferSize === 'object') {\n ({ bufferSize = Infinity, windowTime = Infinity, refCount = false, scheduler } = configOrBufferSize);\n }\n else {\n bufferSize = (configOrBufferSize !== null && configOrBufferSize !== void 0 ? configOrBufferSize : Infinity);\n }\n return share({\n connector: () => new ReplaySubject(bufferSize, windowTime, scheduler),\n resetOnError: true,\n resetOnComplete: false,\n resetOnRefCountZero: refCount,\n });\n}\n","import { ScrollDispatcher, ViewportRuler, ScrollingModule } from '@angular/cdk/scrolling';\nexport { CdkScrollable, ScrollDispatcher, ViewportRuler } from '@angular/cdk/scrolling';\nimport { DOCUMENT, Location } from '@angular/common';\nimport * as i0 from '@angular/core';\nimport { inject, NgZone, Injectable, RendererFactory2, Component, ChangeDetectionStrategy, ViewEncapsulation, untracked, afterRender, afterNextRender, ElementRef, Injector, ANIMATION_MODULE_TYPE, EnvironmentInjector, ApplicationRef, InjectionToken, Directive, EventEmitter, TemplateRef, ViewContainerRef, booleanAttribute, Input, Output, NgModule } from '@angular/core';\nimport { coerceCssPixelValue, coerceArray } from '@angular/cdk/coercion';\nimport { supportsScrollBehavior, Platform, _getEventTarget, _isTestEnvironment } from '@angular/cdk/platform';\nimport { filter, takeUntil, takeWhile } from 'rxjs/operators';\nimport { Directionality, BidiModule } from '@angular/cdk/bidi';\nimport { DomPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal';\nimport { _IdGenerator } from '@angular/cdk/a11y';\nimport { _CdkPrivateStyleLoader } from '@angular/cdk/private';\nimport { Subject, Subscription, merge } from 'rxjs';\nimport { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';\n\nconst scrollBehaviorSupported = supportsScrollBehavior();\n/**\n * Strategy that will prevent the user from scrolling while the overlay is visible.\n */\nclass BlockScrollStrategy {\n _viewportRuler;\n _previousHTMLStyles = { top: '', left: '' };\n _previousScrollPosition;\n _isEnabled = false;\n _document;\n constructor(_viewportRuler, document) {\n this._viewportRuler = _viewportRuler;\n this._document = document;\n }\n /** Attaches this scroll strategy to an overlay. */\n attach() { }\n /** Blocks page-level scroll while the attached overlay is open. */\n enable() {\n if (this._canBeEnabled()) {\n const root = this._document.documentElement;\n this._previousScrollPosition = this._viewportRuler.getViewportScrollPosition();\n // Cache the previous inline styles in case the user had set them.\n this._previousHTMLStyles.left = root.style.left || '';\n this._previousHTMLStyles.top = root.style.top || '';\n // Note: we're using the `html` node, instead of the `body`, because the `body` may\n // have the user agent margin, whereas the `html` is guaranteed not to have one.\n root.style.left = coerceCssPixelValue(-this._previousScrollPosition.left);\n root.style.top = coerceCssPixelValue(-this._previousScrollPosition.top);\n root.classList.add('cdk-global-scrollblock');\n this._isEnabled = true;\n }\n }\n /** Unblocks page-level scroll while the attached overlay is open. */\n disable() {\n if (this._isEnabled) {\n const html = this._document.documentElement;\n const body = this._document.body;\n const htmlStyle = html.style;\n const bodyStyle = body.style;\n const previousHtmlScrollBehavior = htmlStyle.scrollBehavior || '';\n const previousBodyScrollBehavior = bodyStyle.scrollBehavior || '';\n this._isEnabled = false;\n htmlStyle.left = this._previousHTMLStyles.left;\n htmlStyle.top = this._previousHTMLStyles.top;\n html.classList.remove('cdk-global-scrollblock');\n // Disable user-defined smooth scrolling temporarily while we restore the scroll position.\n // See https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior\n // Note that we don't mutate the property if the browser doesn't support `scroll-behavior`,\n // because it can throw off feature detections in `supportsScrollBehavior` which\n // checks for `'scrollBehavior' in documentElement.style`.\n if (scrollBehaviorSupported) {\n htmlStyle.scrollBehavior = bodyStyle.scrollBehavior = 'auto';\n }\n window.scroll(this._previousScrollPosition.left, this._previousScrollPosition.top);\n if (scrollBehaviorSupported) {\n htmlStyle.scrollBehavior = previousHtmlScrollBehavior;\n bodyStyle.scrollBehavior = previousBodyScrollBehavior;\n }\n }\n }\n _canBeEnabled() {\n // Since the scroll strategies can't be singletons, we have to use a global CSS class\n // (`cdk-global-scrollblock`) to make sure that we don't try to disable global\n // scrolling multiple times.\n const html = this._document.documentElement;\n if (html.classList.contains('cdk-global-scrollblock') || this._isEnabled) {\n return false;\n }\n const body = this._document.body;\n const viewport = this._viewportRuler.getViewportSize();\n return body.scrollHeight > viewport.height || body.scrollWidth > viewport.width;\n }\n}\n\n/**\n * Returns an error to be thrown when attempting to attach an already-attached scroll strategy.\n */\nfunction getMatScrollStrategyAlreadyAttachedError() {\n return Error(`Scroll strategy has already been attached.`);\n}\n\n/**\n * Strategy that will close the overlay as soon as the user starts scrolling.\n */\nclass CloseScrollStrategy {\n _scrollDispatcher;\n _ngZone;\n _viewportRuler;\n _config;\n _scrollSubscription = null;\n _overlayRef;\n _initialScrollPosition;\n constructor(_scrollDispatcher, _ngZone, _viewportRuler, _config) {\n this._scrollDispatcher = _scrollDispatcher;\n this._ngZone = _ngZone;\n this._viewportRuler = _viewportRuler;\n this._config = _config;\n }\n /** Attaches this scroll strategy to an overlay. */\n attach(overlayRef) {\n if (this._overlayRef && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw getMatScrollStrategyAlreadyAttachedError();\n }\n this._overlayRef = overlayRef;\n }\n /** Enables the closing of the attached overlay on scroll. */\n enable() {\n if (this._scrollSubscription) {\n return;\n }\n const stream = this._scrollDispatcher.scrolled(0).pipe(filter(scrollable => {\n return (!scrollable ||\n !this._overlayRef.overlayElement.contains(scrollable.getElementRef().nativeElement));\n }));\n if (this._config && this._config.threshold && this._config.threshold > 1) {\n this._initialScrollPosition = this._viewportRuler.getViewportScrollPosition().top;\n this._scrollSubscription = stream.subscribe(() => {\n const scrollPosition = this._viewportRuler.getViewportScrollPosition().top;\n if (Math.abs(scrollPosition - this._initialScrollPosition) > this._config.threshold) {\n this._detach();\n }\n else {\n this._overlayRef.updatePosition();\n }\n });\n }\n else {\n this._scrollSubscription = stream.subscribe(this._detach);\n }\n }\n /** Disables the closing the attached overlay on scroll. */\n disable() {\n if (this._scrollSubscription) {\n this._scrollSubscription.unsubscribe();\n this._scrollSubscription = null;\n }\n }\n detach() {\n this.disable();\n this._overlayRef = null;\n }\n /** Detaches the overlay ref and disables the scroll strategy. */\n _detach = () => {\n this.disable();\n if (this._overlayRef.hasAttached()) {\n this._ngZone.run(() => this._overlayRef.detach());\n }\n };\n}\n\n/** Scroll strategy that doesn't do anything. */\nclass NoopScrollStrategy {\n /** Does nothing, as this scroll strategy is a no-op. */\n enable() { }\n /** Does nothing, as this scroll strategy is a no-op. */\n disable() { }\n /** Does nothing, as this scroll strategy is a no-op. */\n attach() { }\n}\n\n/**\n * Gets whether an element is scrolled outside of view by any of its parent scrolling containers.\n * @param element Dimensions of the element (from getBoundingClientRect)\n * @param scrollContainers Dimensions of element's scrolling containers (from getBoundingClientRect)\n * @returns Whether the element is scrolled out of view\n * @docs-private\n */\nfunction isElementScrolledOutsideView(element, scrollContainers) {\n return scrollContainers.some(containerBounds => {\n const outsideAbove = element.bottom < containerBounds.top;\n const outsideBelow = element.top > containerBounds.bottom;\n const outsideLeft = element.right < containerBounds.left;\n const outsideRight = element.left > containerBounds.right;\n return outsideAbove || outsideBelow || outsideLeft || outsideRight;\n });\n}\n/**\n * Gets whether an element is clipped by any of its scrolling containers.\n * @param element Dimensions of the element (from getBoundingClientRect)\n * @param scrollContainers Dimensions of element's scrolling containers (from getBoundingClientRect)\n * @returns Whether the element is clipped\n * @docs-private\n */\nfunction isElementClippedByScrolling(element, scrollContainers) {\n return scrollContainers.some(scrollContainerRect => {\n const clippedAbove = element.top < scrollContainerRect.top;\n const clippedBelow = element.bottom > scrollContainerRect.bottom;\n const clippedLeft = element.left < scrollContainerRect.left;\n const clippedRight = element.right > scrollContainerRect.right;\n return clippedAbove || clippedBelow || clippedLeft || clippedRight;\n });\n}\n\n/**\n * Strategy that will update the element position as the user is scrolling.\n */\nclass RepositionScrollStrategy {\n _scrollDispatcher;\n _viewportRuler;\n _ngZone;\n _config;\n _scrollSubscription = null;\n _overlayRef;\n constructor(_scrollDispatcher, _viewportRuler, _ngZone, _config) {\n this._scrollDispatcher = _scrollDispatcher;\n this._viewportRuler = _viewportRuler;\n this._ngZone = _ngZone;\n this._config = _config;\n }\n /** Attaches this scroll strategy to an overlay. */\n attach(overlayRef) {\n if (this._overlayRef && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw getMatScrollStrategyAlreadyAttachedError();\n }\n this._overlayRef = overlayRef;\n }\n /** Enables repositioning of the attached overlay on scroll. */\n enable() {\n if (!this._scrollSubscription) {\n const throttle = this._config ? this._config.scrollThrottle : 0;\n this._scrollSubscription = this._scrollDispatcher.scrolled(throttle).subscribe(() => {\n this._overlayRef.updatePosition();\n // TODO(crisbeto): make `close` on by default once all components can handle it.\n if (this._config && this._config.autoClose) {\n const overlayRect = this._overlayRef.overlayElement.getBoundingClientRect();\n const { width, height } = this._viewportRuler.getViewportSize();\n // TODO(crisbeto): include all ancestor scroll containers here once\n // we have a way of exposing the trigger element to the scroll strategy.\n const parentRects = [{ width, height, bottom: height, right: width, top: 0, left: 0 }];\n if (isElementScrolledOutsideView(overlayRect, parentRects)) {\n this.disable();\n this._ngZone.run(() => this._overlayRef.detach());\n }\n }\n });\n }\n }\n /** Disables repositioning of the attached overlay on scroll. */\n disable() {\n if (this._scrollSubscription) {\n this._scrollSubscription.unsubscribe();\n this._scrollSubscription = null;\n }\n }\n detach() {\n this.disable();\n this._overlayRef = null;\n }\n}\n\n/**\n * Options for how an overlay will handle scrolling.\n *\n * Users can provide a custom value for `ScrollStrategyOptions` to replace the default\n * behaviors. This class primarily acts as a factory for ScrollStrategy instances.\n */\nclass ScrollStrategyOptions {\n _scrollDispatcher = inject(ScrollDispatcher);\n _viewportRuler = inject(ViewportRuler);\n _ngZone = inject(NgZone);\n _document = inject(DOCUMENT);\n constructor() { }\n /** Do nothing on scroll. */\n noop = () => new NoopScrollStrategy();\n /**\n * Close the overlay as soon as the user scrolls.\n * @param config Configuration to be used inside the scroll strategy.\n */\n close = (config) => new CloseScrollStrategy(this._scrollDispatcher, this._ngZone, this._viewportRuler, config);\n /** Block scrolling. */\n block = () => new BlockScrollStrategy(this._viewportRuler, this._document);\n /**\n * Update the overlay's position on scroll.\n * @param config Configuration to be used inside the scroll strategy.\n * Allows debouncing the reposition calls.\n */\n reposition = (config) => new RepositionScrollStrategy(this._scrollDispatcher, this._viewportRuler, this._ngZone, config);\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollStrategyOptions, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollStrategyOptions, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollStrategyOptions, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/** Initial configuration used when creating an overlay. */\nclass OverlayConfig {\n /** Strategy with which to position the overlay. */\n positionStrategy;\n /** Strategy to be used when handling scroll events while the overlay is open. */\n scrollStrategy = new NoopScrollStrategy();\n /** Custom class to add to the overlay pane. */\n panelClass = '';\n /** Whether the overlay has a backdrop. */\n hasBackdrop = false;\n /** Custom class to add to the backdrop */\n backdropClass = 'cdk-overlay-dark-backdrop';\n /** The width of the overlay panel. If a number is provided, pixel units are assumed. */\n width;\n /** The height of the overlay panel. If a number is provided, pixel units are assumed. */\n height;\n /** The min-width of the overlay panel. If a number is provided, pixel units are assumed. */\n minWidth;\n /** The min-height of the overlay panel. If a number is provided, pixel units are assumed. */\n minHeight;\n /** The max-width of the overlay panel. If a number is provided, pixel units are assumed. */\n maxWidth;\n /** The max-height of the overlay panel. If a number is provided, pixel units are assumed. */\n maxHeight;\n /**\n * Direction of the text in the overlay panel. If a `Directionality` instance\n * is passed in, the overlay will handle changes to its value automatically.\n */\n direction;\n /**\n * Whether the overlay should be disposed of when the user goes backwards/forwards in history.\n * Note that this usually doesn't include clicking on links (unless the user is using\n * the `HashLocationStrategy`).\n */\n disposeOnNavigation = false;\n constructor(config) {\n if (config) {\n // Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,\n // loses the array generic type in the `for of`. But we *also* have to use `Array` because\n // typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`\n const configKeys = Object.keys(config);\n for (const key of configKeys) {\n if (config[key] !== undefined) {\n // TypeScript, as of version 3.5, sees the left-hand-side of this expression\n // as \"I don't know *which* key this is, so the only valid value is the intersection\n // of all the possible values.\" In this case, that happens to be `undefined`. TypeScript\n // is not smart enough to see that the right-hand-side is actually an access of the same\n // exact type with the same exact key, meaning that the value type must be identical.\n // So we use `any` to work around this.\n this[key] = config[key];\n }\n }\n }\n }\n}\n\n/** The points of the origin element and the overlay element to connect. */\nclass ConnectionPositionPair {\n offsetX;\n offsetY;\n panelClass;\n /** X-axis attachment point for connected overlay origin. Can be 'start', 'end', or 'center'. */\n originX;\n /** Y-axis attachment point for connected overlay origin. Can be 'top', 'bottom', or 'center'. */\n originY;\n /** X-axis attachment point for connected overlay. Can be 'start', 'end', or 'center'. */\n overlayX;\n /** Y-axis attachment point for connected overlay. Can be 'top', 'bottom', or 'center'. */\n overlayY;\n constructor(origin, overlay, \n /** Offset along the X axis. */\n offsetX, \n /** Offset along the Y axis. */\n offsetY, \n /** Class(es) to be applied to the panel while this position is active. */\n panelClass) {\n this.offsetX = offsetX;\n this.offsetY = offsetY;\n this.panelClass = panelClass;\n this.originX = origin.originX;\n this.originY = origin.originY;\n this.overlayX = overlay.overlayX;\n this.overlayY = overlay.overlayY;\n }\n}\n/**\n * Set of properties regarding the position of the origin and overlay relative to the viewport\n * with respect to the containing Scrollable elements.\n *\n * The overlay and origin are clipped if any part of their bounding client rectangle exceeds the\n * bounds of any one of the strategy's Scrollable's bounding client rectangle.\n *\n * The overlay and origin are outside view if there is no overlap between their bounding client\n * rectangle and any one of the strategy's Scrollable's bounding client rectangle.\n *\n * ----------- -----------\n * | outside | | clipped |\n * | view | --------------------------\n * | | | | | |\n * ---------- | ----------- |\n * -------------------------- | |\n * | | | Scrollable |\n * | | | |\n * | | --------------------------\n * | Scrollable |\n * | |\n * --------------------------\n *\n * @docs-private\n */\nclass ScrollingVisibility {\n isOriginClipped;\n isOriginOutsideView;\n isOverlayClipped;\n isOverlayOutsideView;\n}\n/** The change event emitted by the strategy when a fallback position is used. */\nclass ConnectedOverlayPositionChange {\n connectionPair;\n scrollableViewProperties;\n constructor(\n /** The position used as a result of this change. */\n connectionPair, \n /** @docs-private */\n scrollableViewProperties) {\n this.connectionPair = connectionPair;\n this.scrollableViewProperties = scrollableViewProperties;\n }\n}\n/**\n * Validates whether a vertical position property matches the expected values.\n * @param property Name of the property being validated.\n * @param value Value of the property being validated.\n * @docs-private\n */\nfunction validateVerticalPosition(property, value) {\n if (value !== 'top' && value !== 'bottom' && value !== 'center') {\n throw Error(`ConnectedPosition: Invalid ${property} \"${value}\". ` +\n `Expected \"top\", \"bottom\" or \"center\".`);\n }\n}\n/**\n * Validates whether a horizontal position property matches the expected values.\n * @param property Name of the property being validated.\n * @param value Value of the property being validated.\n * @docs-private\n */\nfunction validateHorizontalPosition(property, value) {\n if (value !== 'start' && value !== 'end' && value !== 'center') {\n throw Error(`ConnectedPosition: Invalid ${property} \"${value}\". ` +\n `Expected \"start\", \"end\" or \"center\".`);\n }\n}\n\n/**\n * Service for dispatching events that land on the body to appropriate overlay ref,\n * if any. It maintains a list of attached overlays to determine best suited overlay based\n * on event target and order of overlay opens.\n */\nclass BaseOverlayDispatcher {\n /** Currently attached overlays in the order they were attached. */\n _attachedOverlays = [];\n _document = inject(DOCUMENT);\n _isAttached;\n constructor() { }\n ngOnDestroy() {\n this.detach();\n }\n /** Add a new overlay to the list of attached overlay refs. */\n add(overlayRef) {\n // Ensure that we don't get the same overlay multiple times.\n this.remove(overlayRef);\n this._attachedOverlays.push(overlayRef);\n }\n /** Remove an overlay from the list of attached overlay refs. */\n remove(overlayRef) {\n const index = this._attachedOverlays.indexOf(overlayRef);\n if (index > -1) {\n this._attachedOverlays.splice(index, 1);\n }\n // Remove the global listener once there are no more overlays.\n if (this._attachedOverlays.length === 0) {\n this.detach();\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BaseOverlayDispatcher, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BaseOverlayDispatcher, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: BaseOverlayDispatcher, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/**\n * Service for dispatching keyboard events that land on the body to appropriate overlay ref,\n * if any. It maintains a list of attached overlays to determine best suited overlay based\n * on event target and order of overlay opens.\n */\nclass OverlayKeyboardDispatcher extends BaseOverlayDispatcher {\n _ngZone = inject(NgZone);\n _renderer = inject(RendererFactory2).createRenderer(null, null);\n _cleanupKeydown;\n /** Add a new overlay to the list of attached overlay refs. */\n add(overlayRef) {\n super.add(overlayRef);\n // Lazily start dispatcher once first overlay is added\n if (!this._isAttached) {\n this._ngZone.runOutsideAngular(() => {\n this._cleanupKeydown = this._renderer.listen('body', 'keydown', this._keydownListener);\n });\n this._isAttached = true;\n }\n }\n /** Detaches the global keyboard event listener. */\n detach() {\n if (this._isAttached) {\n this._cleanupKeydown?.();\n this._isAttached = false;\n }\n }\n /** Keyboard event listener that will be attached to the body. */\n _keydownListener = (event) => {\n const overlays = this._attachedOverlays;\n for (let i = overlays.length - 1; i > -1; i--) {\n // Dispatch the keydown event to the top overlay which has subscribers to its keydown events.\n // We want to target the most recent overlay, rather than trying to match where the event came\n // from, because some components might open an overlay, but keep focus on a trigger element\n // (e.g. for select and autocomplete). We skip overlays without keydown event subscriptions,\n // because we don't want overlays that don't handle keyboard events to block the ones below\n // them that do.\n if (overlays[i]._keydownEvents.observers.length > 0) {\n this._ngZone.run(() => overlays[i]._keydownEvents.next(event));\n break;\n }\n }\n };\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayKeyboardDispatcher, deps: null, target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayKeyboardDispatcher, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayKeyboardDispatcher, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n\n/**\n * Service for dispatching mouse click events that land on the body to appropriate overlay ref,\n * if any. It maintains a list of attached overlays to determine best suited overlay based\n * on event target and order of overlay opens.\n */\nclass OverlayOutsideClickDispatcher extends BaseOverlayDispatcher {\n _platform = inject(Platform);\n _ngZone = inject(NgZone, { optional: true });\n _cursorOriginalValue;\n _cursorStyleIsSet = false;\n _pointerDownEventTarget;\n /** Add a new overlay to the list of attached overlay refs. */\n add(overlayRef) {\n super.add(overlayRef);\n // Safari on iOS does not generate click events for non-interactive\n // elements. However, we want to receive a click for any element outside\n // the overlay. We can force a \"clickable\" state by setting\n // `cursor: pointer` on the document body. See:\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#Safari_Mobile\n // https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html\n if (!this._isAttached) {\n const body = this._document.body;\n /** @breaking-change 14.0.0 _ngZone will be required. */\n if (this._ngZone) {\n this._ngZone.runOutsideAngular(() => this._addEventListeners(body));\n }\n else {\n this._addEventListeners(body);\n }\n // click event is not fired on iOS. To make element \"clickable\" we are\n // setting the cursor to pointer\n if (this._platform.IOS && !this._cursorStyleIsSet) {\n this._cursorOriginalValue = body.style.cursor;\n body.style.cursor = 'pointer';\n this._cursorStyleIsSet = true;\n }\n this._isAttached = true;\n }\n }\n /** Detaches the global keyboard event listener. */\n detach() {\n if (this._isAttached) {\n const body = this._document.body;\n body.removeEventListener('pointerdown', this._pointerDownListener, true);\n body.removeEventListener('click', this._clickListener, true);\n body.removeEventListener('auxclick', this._clickListener, true);\n body.removeEventListener('contextmenu', this._clickListener, true);\n if (this._platform.IOS && this._cursorStyleIsSet) {\n body.style.cursor = this._cursorOriginalValue;\n this._cursorStyleIsSet = false;\n }\n this._isAttached = false;\n }\n }\n _addEventListeners(body) {\n body.addEventListener('pointerdown', this._pointerDownListener, true);\n body.addEventListener('click', this._clickListener, true);\n body.addEventListener('auxclick', this._clickListener, true);\n body.addEventListener('contextmenu', this._clickListener, true);\n }\n /** Store pointerdown event target to track origin of click. */\n _pointerDownListener = (event) => {\n this._pointerDownEventTarget = _getEventTarget(event);\n };\n /** Click event listener that will be attached to the body propagate phase. */\n _clickListener = (event) => {\n const target = _getEventTarget(event);\n // In case of a click event, we want to check the origin of the click\n // (e.g. in case where a user starts a click inside the overlay and\n // releases the click outside of it).\n // This is done by using the event target of the preceding pointerdown event.\n // Every click event caused by a pointer device has a preceding pointerdown\n // event, unless the click was programmatically triggered (e.g. in a unit test).\n const origin = event.type === 'click' && this._pointerDownEventTarget\n ? this._pointerDownEventTarget\n : target;\n // Reset the stored pointerdown event target, to avoid having it interfere\n // in subsequent events.\n this._pointerDownEventTarget = null;\n // We copy the array because the original may be modified asynchronously if the\n // outsidePointerEvents listener decides to detach overlays resulting in index errors inside\n // the for loop.\n const overlays = this._attachedOverlays.slice();\n // Dispatch the mouse event to the top overlay which has subscribers to its mouse events.\n // We want to target all overlays for which the click could be considered as outside click.\n // As soon as we reach an overlay for which the click is not outside click we break off\n // the loop.\n for (let i = overlays.length - 1; i > -1; i--) {\n const overlayRef = overlays[i];\n if (overlayRef._outsidePointerEvents.observers.length < 1 || !overlayRef.hasAttached()) {\n continue;\n }\n // If it's a click inside the overlay, just break - we should do nothing\n // If it's an outside click (both origin and target of the click) dispatch the mouse event,\n // and proceed with the next overlay\n if (containsPierceShadowDom(overlayRef.overlayElement, target) ||\n containsPierceShadowDom(overlayRef.overlayElement, origin)) {\n break;\n }\n const outsidePointerEvents = overlayRef._outsidePointerEvents;\n /** @breaking-change 14.0.0 _ngZone will be required. */\n if (this._ngZone) {\n this._ngZone.run(() => outsidePointerEvents.next(event));\n }\n else {\n outsidePointerEvents.next(event);\n }\n }\n };\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayOutsideClickDispatcher, deps: null, target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayOutsideClickDispatcher, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayOutsideClickDispatcher, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n/** Version of `Element.contains` that transcends shadow DOM boundaries. */\nfunction containsPierceShadowDom(parent, child) {\n const supportsShadowRoot = typeof ShadowRoot !== 'undefined' && ShadowRoot;\n let current = child;\n while (current) {\n if (current === parent) {\n return true;\n }\n current =\n supportsShadowRoot && current instanceof ShadowRoot ? current.host : current.parentNode;\n }\n return false;\n}\n\nclass _CdkOverlayStyleLoader {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _CdkOverlayStyleLoader, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"14.0.0\", version: \"19.0.0\", type: _CdkOverlayStyleLoader, isStandalone: true, selector: \"ng-component\", host: { attributes: { \"cdk-overlay-style-loader\": \"\" } }, ngImport: i0, template: '', isInline: true, styles: [\".cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}.cdk-overlay-container{position:fixed}@layer cdk-overlay{.cdk-overlay-container{z-index:1000}}.cdk-overlay-container:empty{display:none}.cdk-global-overlay-wrapper{display:flex;position:absolute}@layer cdk-overlay{.cdk-global-overlay-wrapper{z-index:1000}}.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%}@layer cdk-overlay{.cdk-overlay-pane{z-index:1000}}.cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0}@layer cdk-overlay{.cdk-overlay-backdrop{z-index:1000;transition:opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}}.cdk-overlay-backdrop-showing{opacity:1}@media(forced-colors: active){.cdk-overlay-backdrop-showing{opacity:.6}}@layer cdk-overlay{.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}}.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}.cdk-overlay-backdrop-noop-animation{transition:none}.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px}@layer cdk-overlay{.cdk-overlay-connected-position-bounding-box{z-index:1000}}.cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}\"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _CdkOverlayStyleLoader, decorators: [{\n type: Component,\n args: [{ template: '', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'cdk-overlay-style-loader': '' }, styles: [\".cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}.cdk-overlay-container{position:fixed}@layer cdk-overlay{.cdk-overlay-container{z-index:1000}}.cdk-overlay-container:empty{display:none}.cdk-global-overlay-wrapper{display:flex;position:absolute}@layer cdk-overlay{.cdk-global-overlay-wrapper{z-index:1000}}.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%}@layer cdk-overlay{.cdk-overlay-pane{z-index:1000}}.cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0}@layer cdk-overlay{.cdk-overlay-backdrop{z-index:1000;transition:opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}}.cdk-overlay-backdrop-showing{opacity:1}@media(forced-colors: active){.cdk-overlay-backdrop-showing{opacity:.6}}@layer cdk-overlay{.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}}.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}.cdk-overlay-backdrop-noop-animation{transition:none}.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px}@layer cdk-overlay{.cdk-overlay-connected-position-bounding-box{z-index:1000}}.cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}\"] }]\n }] });\n/** Container inside which all overlays will render. */\nclass OverlayContainer {\n _platform = inject(Platform);\n _containerElement;\n _document = inject(DOCUMENT);\n _styleLoader = inject(_CdkPrivateStyleLoader);\n constructor() { }\n ngOnDestroy() {\n this._containerElement?.remove();\n }\n /**\n * This method returns the overlay container element. It will lazily\n * create the element the first time it is called to facilitate using\n * the container in non-browser environments.\n * @returns the container element\n */\n getContainerElement() {\n this._loadStyles();\n if (!this._containerElement) {\n this._createContainer();\n }\n return this._containerElement;\n }\n /**\n * Create the overlay container element, which is simply a div\n * with the 'cdk-overlay-container' class on the document body.\n */\n _createContainer() {\n const containerClass = 'cdk-overlay-container';\n // TODO(crisbeto): remove the testing check once we have an overlay testing\n // module or Angular starts tearing down the testing `NgModule`. See:\n // https://github.com/angular/angular/issues/18831\n if (this._platform.isBrowser || _isTestEnvironment()) {\n const oppositePlatformContainers = this._document.querySelectorAll(`.${containerClass}[platform=\"server\"], ` + `.${containerClass}[platform=\"test\"]`);\n // Remove any old containers from the opposite platform.\n // This can happen when transitioning from the server to the client.\n for (let i = 0; i < oppositePlatformContainers.length; i++) {\n oppositePlatformContainers[i].remove();\n }\n }\n const container = this._document.createElement('div');\n container.classList.add(containerClass);\n // A long time ago we kept adding new overlay containers whenever a new app was instantiated,\n // but at some point we added logic which clears the duplicate ones in order to avoid leaks.\n // The new logic was a little too aggressive since it was breaking some legitimate use cases.\n // To mitigate the problem we made it so that only containers from a different platform are\n // cleared, but the side-effect was that people started depending on the overly-aggressive\n // logic to clean up their tests for them. Until we can introduce an overlay-specific testing\n // module which does the cleanup, we try to detect that we're in a test environment and we\n // always clear the container. See #17006.\n // TODO(crisbeto): remove the test environment check once we have an overlay testing module.\n if (_isTestEnvironment()) {\n container.setAttribute('platform', 'test');\n }\n else if (!this._platform.isBrowser) {\n container.setAttribute('platform', 'server');\n }\n this._document.body.appendChild(container);\n this._containerElement = container;\n }\n /** Loads the structural styles necessary for the overlay to work. */\n _loadStyles() {\n this._styleLoader.load(_CdkOverlayStyleLoader);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayContainer, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayContainer, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/**\n * Reference to an overlay that has been created with the Overlay service.\n * Used to manipulate or dispose of said overlay.\n */\nclass OverlayRef {\n _portalOutlet;\n _host;\n _pane;\n _config;\n _ngZone;\n _keyboardDispatcher;\n _document;\n _location;\n _outsideClickDispatcher;\n _animationsDisabled;\n _injector;\n _renderer;\n _backdropElement = null;\n _backdropTimeout;\n _backdropClick = new Subject();\n _attachments = new Subject();\n _detachments = new Subject();\n _positionStrategy;\n _scrollStrategy;\n _locationChanges = Subscription.EMPTY;\n _cleanupBackdropClick;\n _cleanupBackdropTransitionEnd;\n /**\n * Reference to the parent of the `_host` at the time it was detached. Used to restore\n * the `_host` to its original position in the DOM when it gets re-attached.\n */\n _previousHostParent;\n /** Stream of keydown events dispatched to this overlay. */\n _keydownEvents = new Subject();\n /** Stream of mouse outside events dispatched to this overlay. */\n _outsidePointerEvents = new Subject();\n _renders = new Subject();\n _afterRenderRef;\n /** Reference to the currently-running `afterNextRender` call. */\n _afterNextRenderRef;\n constructor(_portalOutlet, _host, _pane, _config, _ngZone, _keyboardDispatcher, _document, _location, _outsideClickDispatcher, _animationsDisabled = false, _injector, _renderer) {\n this._portalOutlet = _portalOutlet;\n this._host = _host;\n this._pane = _pane;\n this._config = _config;\n this._ngZone = _ngZone;\n this._keyboardDispatcher = _keyboardDispatcher;\n this._document = _document;\n this._location = _location;\n this._outsideClickDispatcher = _outsideClickDispatcher;\n this._animationsDisabled = _animationsDisabled;\n this._injector = _injector;\n this._renderer = _renderer;\n if (_config.scrollStrategy) {\n this._scrollStrategy = _config.scrollStrategy;\n this._scrollStrategy.attach(this);\n }\n this._positionStrategy = _config.positionStrategy;\n // Users could open the overlay from an `effect`, in which case we need to\n // run the `afterRender` as `untracked`. We don't recommend that users do\n // this, but we also don't want to break users who are doing it.\n this._afterRenderRef = untracked(() => afterRender(() => {\n this._renders.next();\n }, { injector: this._injector }));\n }\n /** The overlay's HTML element */\n get overlayElement() {\n return this._pane;\n }\n /** The overlay's backdrop HTML element. */\n get backdropElement() {\n return this._backdropElement;\n }\n /**\n * Wrapper around the panel element. Can be used for advanced\n * positioning where a wrapper with specific styling is\n * required around the overlay pane.\n */\n get hostElement() {\n return this._host;\n }\n /**\n * Attaches content, given via a Portal, to the overlay.\n * If the overlay is configured to have a backdrop, it will be created.\n *\n * @param portal Portal instance to which to attach the overlay.\n * @returns The portal attachment result.\n */\n attach(portal) {\n // Insert the host into the DOM before attaching the portal, otherwise\n // the animations module will skip animations on repeat attachments.\n if (!this._host.parentElement && this._previousHostParent) {\n this._previousHostParent.appendChild(this._host);\n }\n const attachResult = this._portalOutlet.attach(portal);\n if (this._positionStrategy) {\n this._positionStrategy.attach(this);\n }\n this._updateStackingOrder();\n this._updateElementSize();\n this._updateElementDirection();\n if (this._scrollStrategy) {\n this._scrollStrategy.enable();\n }\n // We need to clean this up ourselves, because we're passing in an\n // `EnvironmentInjector` below which won't ever be destroyed.\n // Otherwise it causes some callbacks to be retained (see #29696).\n this._afterNextRenderRef?.destroy();\n // Update the position once the overlay is fully rendered before attempting to position it,\n // as the position may depend on the size of the rendered content.\n this._afterNextRenderRef = afterNextRender(() => {\n // The overlay could've been detached before the callback executed.\n if (this.hasAttached()) {\n this.updatePosition();\n }\n }, { injector: this._injector });\n // Enable pointer events for the overlay pane element.\n this._togglePointerEvents(true);\n if (this._config.hasBackdrop) {\n this._attachBackdrop();\n }\n if (this._config.panelClass) {\n this._toggleClasses(this._pane, this._config.panelClass, true);\n }\n // Only emit the `attachments` event once all other setup is done.\n this._attachments.next();\n // Track this overlay by the keyboard dispatcher\n this._keyboardDispatcher.add(this);\n if (this._config.disposeOnNavigation) {\n this._locationChanges = this._location.subscribe(() => this.dispose());\n }\n this._outsideClickDispatcher.add(this);\n // TODO(crisbeto): the null check is here, because the portal outlet returns `any`.\n // We should be guaranteed for the result to be `ComponentRef | EmbeddedViewRef`, but\n // `instanceof EmbeddedViewRef` doesn't appear to work at the moment.\n if (typeof attachResult?.onDestroy === 'function') {\n // In most cases we control the portal and we know when it is being detached so that\n // we can finish the disposal process. The exception is if the user passes in a custom\n // `ViewContainerRef` that isn't destroyed through the overlay API. Note that we use\n // `detach` here instead of `dispose`, because we don't know if the user intends to\n // reattach the overlay at a later point. It also has the advantage of waiting for animations.\n attachResult.onDestroy(() => {\n if (this.hasAttached()) {\n // We have to delay the `detach` call, because detaching immediately prevents\n // other destroy hooks from running. This is likely a framework bug similar to\n // https://github.com/angular/angular/issues/46119\n this._ngZone.runOutsideAngular(() => Promise.resolve().then(() => this.detach()));\n }\n });\n }\n return attachResult;\n }\n /**\n * Detaches an overlay from a portal.\n * @returns The portal detachment result.\n */\n detach() {\n if (!this.hasAttached()) {\n return;\n }\n this.detachBackdrop();\n // When the overlay is detached, the pane element should disable pointer events.\n // This is necessary because otherwise the pane element will cover the page and disable\n // pointer events therefore. Depends on the position strategy and the applied pane boundaries.\n this._togglePointerEvents(false);\n if (this._positionStrategy && this._positionStrategy.detach) {\n this._positionStrategy.detach();\n }\n if (this._scrollStrategy) {\n this._scrollStrategy.disable();\n }\n const detachmentResult = this._portalOutlet.detach();\n // Only emit after everything is detached.\n this._detachments.next();\n // Remove this overlay from keyboard dispatcher tracking.\n this._keyboardDispatcher.remove(this);\n // Keeping the host element in the DOM can cause scroll jank, because it still gets\n // rendered, even though it's transparent and unclickable which is why we remove it.\n this._detachContentWhenEmpty();\n this._locationChanges.unsubscribe();\n this._outsideClickDispatcher.remove(this);\n return detachmentResult;\n }\n /** Cleans up the overlay from the DOM. */\n dispose() {\n const isAttached = this.hasAttached();\n if (this._positionStrategy) {\n this._positionStrategy.dispose();\n }\n this._disposeScrollStrategy();\n this._disposeBackdrop(this._backdropElement);\n this._locationChanges.unsubscribe();\n this._keyboardDispatcher.remove(this);\n this._portalOutlet.dispose();\n this._attachments.complete();\n this._backdropClick.complete();\n this._keydownEvents.complete();\n this._outsidePointerEvents.complete();\n this._outsideClickDispatcher.remove(this);\n this._host?.remove();\n this._afterNextRenderRef?.destroy();\n this._previousHostParent = this._pane = this._host = null;\n if (isAttached) {\n this._detachments.next();\n }\n this._detachments.complete();\n this._afterRenderRef.destroy();\n this._renders.complete();\n }\n /** Whether the overlay has attached content. */\n hasAttached() {\n return this._portalOutlet.hasAttached();\n }\n /** Gets an observable that emits when the backdrop has been clicked. */\n backdropClick() {\n return this._backdropClick;\n }\n /** Gets an observable that emits when the overlay has been attached. */\n attachments() {\n return this._attachments;\n }\n /** Gets an observable that emits when the overlay has been detached. */\n detachments() {\n return this._detachments;\n }\n /** Gets an observable of keydown events targeted to this overlay. */\n keydownEvents() {\n return this._keydownEvents;\n }\n /** Gets an observable of pointer events targeted outside this overlay. */\n outsidePointerEvents() {\n return this._outsidePointerEvents;\n }\n /** Gets the current overlay configuration, which is immutable. */\n getConfig() {\n return this._config;\n }\n /** Updates the position of the overlay based on the position strategy. */\n updatePosition() {\n if (this._positionStrategy) {\n this._positionStrategy.apply();\n }\n }\n /** Switches to a new position strategy and updates the overlay position. */\n updatePositionStrategy(strategy) {\n if (strategy === this._positionStrategy) {\n return;\n }\n if (this._positionStrategy) {\n this._positionStrategy.dispose();\n }\n this._positionStrategy = strategy;\n if (this.hasAttached()) {\n strategy.attach(this);\n this.updatePosition();\n }\n }\n /** Update the size properties of the overlay. */\n updateSize(sizeConfig) {\n this._config = { ...this._config, ...sizeConfig };\n this._updateElementSize();\n }\n /** Sets the LTR/RTL direction for the overlay. */\n setDirection(dir) {\n this._config = { ...this._config, direction: dir };\n this._updateElementDirection();\n }\n /** Add a CSS class or an array of classes to the overlay pane. */\n addPanelClass(classes) {\n if (this._pane) {\n this._toggleClasses(this._pane, classes, true);\n }\n }\n /** Remove a CSS class or an array of classes from the overlay pane. */\n removePanelClass(classes) {\n if (this._pane) {\n this._toggleClasses(this._pane, classes, false);\n }\n }\n /**\n * Returns the layout direction of the overlay panel.\n */\n getDirection() {\n const direction = this._config.direction;\n if (!direction) {\n return 'ltr';\n }\n return typeof direction === 'string' ? direction : direction.value;\n }\n /** Switches to a new scroll strategy. */\n updateScrollStrategy(strategy) {\n if (strategy === this._scrollStrategy) {\n return;\n }\n this._disposeScrollStrategy();\n this._scrollStrategy = strategy;\n if (this.hasAttached()) {\n strategy.attach(this);\n strategy.enable();\n }\n }\n /** Updates the text direction of the overlay panel. */\n _updateElementDirection() {\n this._host.setAttribute('dir', this.getDirection());\n }\n /** Updates the size of the overlay element based on the overlay config. */\n _updateElementSize() {\n if (!this._pane) {\n return;\n }\n const style = this._pane.style;\n style.width = coerceCssPixelValue(this._config.width);\n style.height = coerceCssPixelValue(this._config.height);\n style.minWidth = coerceCssPixelValue(this._config.minWidth);\n style.minHeight = coerceCssPixelValue(this._config.minHeight);\n style.maxWidth = coerceCssPixelValue(this._config.maxWidth);\n style.maxHeight = coerceCssPixelValue(this._config.maxHeight);\n }\n /** Toggles the pointer events for the overlay pane element. */\n _togglePointerEvents(enablePointer) {\n this._pane.style.pointerEvents = enablePointer ? '' : 'none';\n }\n /** Attaches a backdrop for this overlay. */\n _attachBackdrop() {\n const showingClass = 'cdk-overlay-backdrop-showing';\n this._backdropElement = this._document.createElement('div');\n this._backdropElement.classList.add('cdk-overlay-backdrop');\n if (this._animationsDisabled) {\n this._backdropElement.classList.add('cdk-overlay-backdrop-noop-animation');\n }\n if (this._config.backdropClass) {\n this._toggleClasses(this._backdropElement, this._config.backdropClass, true);\n }\n // Insert the backdrop before the pane in the DOM order,\n // in order to handle stacked overlays properly.\n this._host.parentElement.insertBefore(this._backdropElement, this._host);\n // Forward backdrop clicks such that the consumer of the overlay can perform whatever\n // action desired when such a click occurs (usually closing the overlay).\n this._cleanupBackdropClick?.();\n this._cleanupBackdropClick = this._renderer.listen(this._backdropElement, 'click', (event) => this._backdropClick.next(event));\n // Add class to fade-in the backdrop after one frame.\n if (!this._animationsDisabled && typeof requestAnimationFrame !== 'undefined') {\n this._ngZone.runOutsideAngular(() => {\n requestAnimationFrame(() => {\n if (this._backdropElement) {\n this._backdropElement.classList.add(showingClass);\n }\n });\n });\n }\n else {\n this._backdropElement.classList.add(showingClass);\n }\n }\n /**\n * Updates the stacking order of the element, moving it to the top if necessary.\n * This is required in cases where one overlay was detached, while another one,\n * that should be behind it, was destroyed. The next time both of them are opened,\n * the stacking will be wrong, because the detached element's pane will still be\n * in its original DOM position.\n */\n _updateStackingOrder() {\n if (this._host.nextSibling) {\n this._host.parentNode.appendChild(this._host);\n }\n }\n /** Detaches the backdrop (if any) associated with the overlay. */\n detachBackdrop() {\n const backdropToDetach = this._backdropElement;\n if (!backdropToDetach) {\n return;\n }\n if (this._animationsDisabled) {\n this._disposeBackdrop(backdropToDetach);\n return;\n }\n backdropToDetach.classList.remove('cdk-overlay-backdrop-showing');\n this._ngZone.runOutsideAngular(() => {\n this._cleanupBackdropTransitionEnd?.();\n this._cleanupBackdropTransitionEnd = this._renderer.listen(backdropToDetach, 'transitionend', (event) => {\n this._disposeBackdrop(event.target);\n });\n });\n // If the backdrop doesn't have a transition, the `transitionend` event won't fire.\n // In this case we make it unclickable and we try to remove it after a delay.\n backdropToDetach.style.pointerEvents = 'none';\n // Run this outside the Angular zone because there's nothing that Angular cares about.\n // If it were to run inside the Angular zone, every test that used Overlay would have to be\n // either async or fakeAsync.\n this._backdropTimeout = this._ngZone.runOutsideAngular(() => setTimeout(() => {\n this._disposeBackdrop(backdropToDetach);\n }, 500));\n }\n /** Toggles a single CSS class or an array of classes on an element. */\n _toggleClasses(element, cssClasses, isAdd) {\n const classes = coerceArray(cssClasses || []).filter(c => !!c);\n if (classes.length) {\n isAdd ? element.classList.add(...classes) : element.classList.remove(...classes);\n }\n }\n /** Detaches the overlay content next time the zone stabilizes. */\n _detachContentWhenEmpty() {\n // Normally we wouldn't have to explicitly run this outside the `NgZone`, however\n // if the consumer is using `zone-patch-rxjs`, the `Subscription.unsubscribe` call will\n // be patched to run inside the zone, which will throw us into an infinite loop.\n this._ngZone.runOutsideAngular(() => {\n // We can't remove the host here immediately, because the overlay pane's content\n // might still be animating. This stream helps us avoid interrupting the animation\n // by waiting for the pane to become empty.\n const subscription = this._renders\n .pipe(takeUntil(merge(this._attachments, this._detachments)))\n .subscribe(() => {\n // Needs a couple of checks for the pane and host, because\n // they may have been removed by the time the zone stabilizes.\n if (!this._pane || !this._host || this._pane.children.length === 0) {\n if (this._pane && this._config.panelClass) {\n this._toggleClasses(this._pane, this._config.panelClass, false);\n }\n if (this._host && this._host.parentElement) {\n this._previousHostParent = this._host.parentElement;\n this._host.remove();\n }\n subscription.unsubscribe();\n }\n });\n });\n }\n /** Disposes of a scroll strategy. */\n _disposeScrollStrategy() {\n const scrollStrategy = this._scrollStrategy;\n if (scrollStrategy) {\n scrollStrategy.disable();\n if (scrollStrategy.detach) {\n scrollStrategy.detach();\n }\n }\n }\n /** Removes a backdrop element from the DOM. */\n _disposeBackdrop(backdrop) {\n this._cleanupBackdropClick?.();\n this._cleanupBackdropTransitionEnd?.();\n if (backdrop) {\n backdrop.remove();\n // It is possible that a new portal has been attached to this overlay since we started\n // removing the backdrop. If that is the case, only clear the backdrop reference if it\n // is still the same instance that we started to remove.\n if (this._backdropElement === backdrop) {\n this._backdropElement = null;\n }\n }\n if (this._backdropTimeout) {\n clearTimeout(this._backdropTimeout);\n this._backdropTimeout = undefined;\n }\n }\n}\n\n// TODO: refactor clipping detection into a separate thing (part of scrolling module)\n// TODO: doesn't handle both flexible width and height when it has to scroll along both axis.\n/** Class to be added to the overlay bounding box. */\nconst boundingBoxClass = 'cdk-overlay-connected-position-bounding-box';\n/** Regex used to split a string on its CSS units. */\nconst cssUnitPattern = /([A-Za-z%]+)$/;\n/**\n * A strategy for positioning overlays. Using this strategy, an overlay is given an\n * implicit position relative some origin element. The relative position is defined in terms of\n * a point on the origin element that is connected to a point on the overlay element. For example,\n * a basic dropdown is connecting the bottom-left corner of the origin to the top-left corner\n * of the overlay.\n */\nclass FlexibleConnectedPositionStrategy {\n _viewportRuler;\n _document;\n _platform;\n _overlayContainer;\n /** The overlay to which this strategy is attached. */\n _overlayRef;\n /** Whether we're performing the very first positioning of the overlay. */\n _isInitialRender;\n /** Last size used for the bounding box. Used to avoid resizing the overlay after open. */\n _lastBoundingBoxSize = { width: 0, height: 0 };\n /** Whether the overlay was pushed in a previous positioning. */\n _isPushed = false;\n /** Whether the overlay can be pushed on-screen on the initial open. */\n _canPush = true;\n /** Whether the overlay can grow via flexible width/height after the initial open. */\n _growAfterOpen = false;\n /** Whether the overlay's width and height can be constrained to fit within the viewport. */\n _hasFlexibleDimensions = true;\n /** Whether the overlay position is locked. */\n _positionLocked = false;\n /** Cached origin dimensions */\n _originRect;\n /** Cached overlay dimensions */\n _overlayRect;\n /** Cached viewport dimensions */\n _viewportRect;\n /** Cached container dimensions */\n _containerRect;\n /** Amount of space that must be maintained between the overlay and the edge of the viewport. */\n _viewportMargin = 0;\n /** The Scrollable containers used to check scrollable view properties on position change. */\n _scrollables = [];\n /** Ordered list of preferred positions, from most to least desirable. */\n _preferredPositions = [];\n /** The origin element against which the overlay will be positioned. */\n _origin;\n /** The overlay pane element. */\n _pane;\n /** Whether the strategy has been disposed of already. */\n _isDisposed;\n /**\n * Parent element for the overlay panel used to constrain the overlay panel's size to fit\n * within the viewport.\n */\n _boundingBox;\n /** The last position to have been calculated as the best fit position. */\n _lastPosition;\n /** The last calculated scroll visibility. Only tracked */\n _lastScrollVisibility;\n /** Subject that emits whenever the position changes. */\n _positionChanges = new Subject();\n /** Subscription to viewport size changes. */\n _resizeSubscription = Subscription.EMPTY;\n /** Default offset for the overlay along the x axis. */\n _offsetX = 0;\n /** Default offset for the overlay along the y axis. */\n _offsetY = 0;\n /** Selector to be used when finding the elements on which to set the transform origin. */\n _transformOriginSelector;\n /** Keeps track of the CSS classes that the position strategy has applied on the overlay panel. */\n _appliedPanelClasses = [];\n /** Amount by which the overlay was pushed in each axis during the last time it was positioned. */\n _previousPushAmount;\n /** Observable sequence of position changes. */\n positionChanges = this._positionChanges;\n /** Ordered list of preferred positions, from most to least desirable. */\n get positions() {\n return this._preferredPositions;\n }\n constructor(connectedTo, _viewportRuler, _document, _platform, _overlayContainer) {\n this._viewportRuler = _viewportRuler;\n this._document = _document;\n this._platform = _platform;\n this._overlayContainer = _overlayContainer;\n this.setOrigin(connectedTo);\n }\n /** Attaches this position strategy to an overlay. */\n attach(overlayRef) {\n if (this._overlayRef &&\n overlayRef !== this._overlayRef &&\n (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error('This position strategy is already attached to an overlay');\n }\n this._validatePositions();\n overlayRef.hostElement.classList.add(boundingBoxClass);\n this._overlayRef = overlayRef;\n this._boundingBox = overlayRef.hostElement;\n this._pane = overlayRef.overlayElement;\n this._isDisposed = false;\n this._isInitialRender = true;\n this._lastPosition = null;\n this._resizeSubscription.unsubscribe();\n this._resizeSubscription = this._viewportRuler.change().subscribe(() => {\n // When the window is resized, we want to trigger the next reposition as if it\n // was an initial render, in order for the strategy to pick a new optimal position,\n // otherwise position locking will cause it to stay at the old one.\n this._isInitialRender = true;\n this.apply();\n });\n }\n /**\n * Updates the position of the overlay element, using whichever preferred position relative\n * to the origin best fits on-screen.\n *\n * The selection of a position goes as follows:\n * - If any positions fit completely within the viewport as-is,\n * choose the first position that does so.\n * - If flexible dimensions are enabled and at least one satisfies the given minimum width/height,\n * choose the position with the greatest available size modified by the positions' weight.\n * - If pushing is enabled, take the position that went off-screen the least and push it\n * on-screen.\n * - If none of the previous criteria were met, use the position that goes off-screen the least.\n * @docs-private\n */\n apply() {\n // We shouldn't do anything if the strategy was disposed or we're on the server.\n if (this._isDisposed || !this._platform.isBrowser) {\n return;\n }\n // If the position has been applied already (e.g. when the overlay was opened) and the\n // consumer opted into locking in the position, re-use the old position, in order to\n // prevent the overlay from jumping around.\n if (!this._isInitialRender && this._positionLocked && this._lastPosition) {\n this.reapplyLastPosition();\n return;\n }\n this._clearPanelClasses();\n this._resetOverlayElementStyles();\n this._resetBoundingBoxStyles();\n // We need the bounding rects for the origin, the overlay and the container to determine how to position\n // the overlay relative to the origin.\n // We use the viewport rect to determine whether a position would go off-screen.\n this._viewportRect = this._getNarrowedViewportRect();\n this._originRect = this._getOriginRect();\n this._overlayRect = this._pane.getBoundingClientRect();\n this._containerRect = this._overlayContainer.getContainerElement().getBoundingClientRect();\n const originRect = this._originRect;\n const overlayRect = this._overlayRect;\n const viewportRect = this._viewportRect;\n const containerRect = this._containerRect;\n // Positions where the overlay will fit with flexible dimensions.\n const flexibleFits = [];\n // Fallback if none of the preferred positions fit within the viewport.\n let fallback;\n // Go through each of the preferred positions looking for a good fit.\n // If a good fit is found, it will be applied immediately.\n for (let pos of this._preferredPositions) {\n // Get the exact (x, y) coordinate for the point-of-origin on the origin element.\n let originPoint = this._getOriginPoint(originRect, containerRect, pos);\n // From that point-of-origin, get the exact (x, y) coordinate for the top-left corner of the\n // overlay in this position. We use the top-left corner for calculations and later translate\n // this into an appropriate (top, left, bottom, right) style.\n let overlayPoint = this._getOverlayPoint(originPoint, overlayRect, pos);\n // Calculate how well the overlay would fit into the viewport with this point.\n let overlayFit = this._getOverlayFit(overlayPoint, overlayRect, viewportRect, pos);\n // If the overlay, without any further work, fits into the viewport, use this position.\n if (overlayFit.isCompletelyWithinViewport) {\n this._isPushed = false;\n this._applyPosition(pos, originPoint);\n return;\n }\n // If the overlay has flexible dimensions, we can use this position\n // so long as there's enough space for the minimum dimensions.\n if (this._canFitWithFlexibleDimensions(overlayFit, overlayPoint, viewportRect)) {\n // Save positions where the overlay will fit with flexible dimensions. We will use these\n // if none of the positions fit *without* flexible dimensions.\n flexibleFits.push({\n position: pos,\n origin: originPoint,\n overlayRect,\n boundingBoxRect: this._calculateBoundingBoxRect(originPoint, pos),\n });\n continue;\n }\n // If the current preferred position does not fit on the screen, remember the position\n // if it has more visible area on-screen than we've seen and move onto the next preferred\n // position.\n if (!fallback || fallback.overlayFit.visibleArea < overlayFit.visibleArea) {\n fallback = { overlayFit, overlayPoint, originPoint, position: pos, overlayRect };\n }\n }\n // If there are any positions where the overlay would fit with flexible dimensions, choose the\n // one that has the greatest area available modified by the position's weight\n if (flexibleFits.length) {\n let bestFit = null;\n let bestScore = -1;\n for (const fit of flexibleFits) {\n const score = fit.boundingBoxRect.width * fit.boundingBoxRect.height * (fit.position.weight || 1);\n if (score > bestScore) {\n bestScore = score;\n bestFit = fit;\n }\n }\n this._isPushed = false;\n this._applyPosition(bestFit.position, bestFit.origin);\n return;\n }\n // When none of the preferred positions fit within the viewport, take the position\n // that went off-screen the least and attempt to push it on-screen.\n if (this._canPush) {\n // TODO(jelbourn): after pushing, the opening \"direction\" of the overlay might not make sense.\n this._isPushed = true;\n this._applyPosition(fallback.position, fallback.originPoint);\n return;\n }\n // All options for getting the overlay within the viewport have been exhausted, so go with the\n // position that went off-screen the least.\n this._applyPosition(fallback.position, fallback.originPoint);\n }\n detach() {\n this._clearPanelClasses();\n this._lastPosition = null;\n this._previousPushAmount = null;\n this._resizeSubscription.unsubscribe();\n }\n /** Cleanup after the element gets destroyed. */\n dispose() {\n if (this._isDisposed) {\n return;\n }\n // We can't use `_resetBoundingBoxStyles` here, because it resets\n // some properties to zero, rather than removing them.\n if (this._boundingBox) {\n extendStyles(this._boundingBox.style, {\n top: '',\n left: '',\n right: '',\n bottom: '',\n height: '',\n width: '',\n alignItems: '',\n justifyContent: '',\n });\n }\n if (this._pane) {\n this._resetOverlayElementStyles();\n }\n if (this._overlayRef) {\n this._overlayRef.hostElement.classList.remove(boundingBoxClass);\n }\n this.detach();\n this._positionChanges.complete();\n this._overlayRef = this._boundingBox = null;\n this._isDisposed = true;\n }\n /**\n * This re-aligns the overlay element with the trigger in its last calculated position,\n * even if a position higher in the \"preferred positions\" list would now fit. This\n * allows one to re-align the panel without changing the orientation of the panel.\n */\n reapplyLastPosition() {\n if (this._isDisposed || !this._platform.isBrowser) {\n return;\n }\n const lastPosition = this._lastPosition;\n if (lastPosition) {\n this._originRect = this._getOriginRect();\n this._overlayRect = this._pane.getBoundingClientRect();\n this._viewportRect = this._getNarrowedViewportRect();\n this._containerRect = this._overlayContainer.getContainerElement().getBoundingClientRect();\n const originPoint = this._getOriginPoint(this._originRect, this._containerRect, lastPosition);\n this._applyPosition(lastPosition, originPoint);\n }\n else {\n this.apply();\n }\n }\n /**\n * Sets the list of Scrollable containers that host the origin element so that\n * on reposition we can evaluate if it or the overlay has been clipped or outside view. Every\n * Scrollable must be an ancestor element of the strategy's origin element.\n */\n withScrollableContainers(scrollables) {\n this._scrollables = scrollables;\n return this;\n }\n /**\n * Adds new preferred positions.\n * @param positions List of positions options for this overlay.\n */\n withPositions(positions) {\n this._preferredPositions = positions;\n // If the last calculated position object isn't part of the positions anymore, clear\n // it in order to avoid it being picked up if the consumer tries to re-apply.\n if (positions.indexOf(this._lastPosition) === -1) {\n this._lastPosition = null;\n }\n this._validatePositions();\n return this;\n }\n /**\n * Sets a minimum distance the overlay may be positioned to the edge of the viewport.\n * @param margin Required margin between the overlay and the viewport edge in pixels.\n */\n withViewportMargin(margin) {\n this._viewportMargin = margin;\n return this;\n }\n /** Sets whether the overlay's width and height can be constrained to fit within the viewport. */\n withFlexibleDimensions(flexibleDimensions = true) {\n this._hasFlexibleDimensions = flexibleDimensions;\n return this;\n }\n /** Sets whether the overlay can grow after the initial open via flexible width/height. */\n withGrowAfterOpen(growAfterOpen = true) {\n this._growAfterOpen = growAfterOpen;\n return this;\n }\n /** Sets whether the overlay can be pushed on-screen if none of the provided positions fit. */\n withPush(canPush = true) {\n this._canPush = canPush;\n return this;\n }\n /**\n * Sets whether the overlay's position should be locked in after it is positioned\n * initially. When an overlay is locked in, it won't attempt to reposition itself\n * when the position is re-applied (e.g. when the user scrolls away).\n * @param isLocked Whether the overlay should locked in.\n */\n withLockedPosition(isLocked = true) {\n this._positionLocked = isLocked;\n return this;\n }\n /**\n * Sets the origin, relative to which to position the overlay.\n * Using an element origin is useful for building components that need to be positioned\n * relatively to a trigger (e.g. dropdown menus or tooltips), whereas using a point can be\n * used for cases like contextual menus which open relative to the user's pointer.\n * @param origin Reference to the new origin.\n */\n setOrigin(origin) {\n this._origin = origin;\n return this;\n }\n /**\n * Sets the default offset for the overlay's connection point on the x-axis.\n * @param offset New offset in the X axis.\n */\n withDefaultOffsetX(offset) {\n this._offsetX = offset;\n return this;\n }\n /**\n * Sets the default offset for the overlay's connection point on the y-axis.\n * @param offset New offset in the Y axis.\n */\n withDefaultOffsetY(offset) {\n this._offsetY = offset;\n return this;\n }\n /**\n * Configures that the position strategy should set a `transform-origin` on some elements\n * inside the overlay, depending on the current position that is being applied. This is\n * useful for the cases where the origin of an animation can change depending on the\n * alignment of the overlay.\n * @param selector CSS selector that will be used to find the target\n * elements onto which to set the transform origin.\n */\n withTransformOriginOn(selector) {\n this._transformOriginSelector = selector;\n return this;\n }\n /**\n * Gets the (x, y) coordinate of a connection point on the origin based on a relative position.\n */\n _getOriginPoint(originRect, containerRect, pos) {\n let x;\n if (pos.originX == 'center') {\n // Note: when centering we should always use the `left`\n // offset, otherwise the position will be wrong in RTL.\n x = originRect.left + originRect.width / 2;\n }\n else {\n const startX = this._isRtl() ? originRect.right : originRect.left;\n const endX = this._isRtl() ? originRect.left : originRect.right;\n x = pos.originX == 'start' ? startX : endX;\n }\n // When zooming in Safari the container rectangle contains negative values for the position\n // and we need to re-add them to the calculated coordinates.\n if (containerRect.left < 0) {\n x -= containerRect.left;\n }\n let y;\n if (pos.originY == 'center') {\n y = originRect.top + originRect.height / 2;\n }\n else {\n y = pos.originY == 'top' ? originRect.top : originRect.bottom;\n }\n // Normally the containerRect's top value would be zero, however when the overlay is attached to an input\n // (e.g. in an autocomplete), mobile browsers will shift everything in order to put the input in the middle\n // of the screen and to make space for the virtual keyboard. We need to account for this offset,\n // otherwise our positioning will be thrown off.\n // Additionally, when zooming in Safari this fixes the vertical position.\n if (containerRect.top < 0) {\n y -= containerRect.top;\n }\n return { x, y };\n }\n /**\n * Gets the (x, y) coordinate of the top-left corner of the overlay given a given position and\n * origin point to which the overlay should be connected.\n */\n _getOverlayPoint(originPoint, overlayRect, pos) {\n // Calculate the (overlayStartX, overlayStartY), the start of the\n // potential overlay position relative to the origin point.\n let overlayStartX;\n if (pos.overlayX == 'center') {\n overlayStartX = -overlayRect.width / 2;\n }\n else if (pos.overlayX === 'start') {\n overlayStartX = this._isRtl() ? -overlayRect.width : 0;\n }\n else {\n overlayStartX = this._isRtl() ? 0 : -overlayRect.width;\n }\n let overlayStartY;\n if (pos.overlayY == 'center') {\n overlayStartY = -overlayRect.height / 2;\n }\n else {\n overlayStartY = pos.overlayY == 'top' ? 0 : -overlayRect.height;\n }\n // The (x, y) coordinates of the overlay.\n return {\n x: originPoint.x + overlayStartX,\n y: originPoint.y + overlayStartY,\n };\n }\n /** Gets how well an overlay at the given point will fit within the viewport. */\n _getOverlayFit(point, rawOverlayRect, viewport, position) {\n // Round the overlay rect when comparing against the\n // viewport, because the viewport is always rounded.\n const overlay = getRoundedBoundingClientRect(rawOverlayRect);\n let { x, y } = point;\n let offsetX = this._getOffset(position, 'x');\n let offsetY = this._getOffset(position, 'y');\n // Account for the offsets since they could push the overlay out of the viewport.\n if (offsetX) {\n x += offsetX;\n }\n if (offsetY) {\n y += offsetY;\n }\n // How much the overlay would overflow at this position, on each side.\n let leftOverflow = 0 - x;\n let rightOverflow = x + overlay.width - viewport.width;\n let topOverflow = 0 - y;\n let bottomOverflow = y + overlay.height - viewport.height;\n // Visible parts of the element on each axis.\n let visibleWidth = this._subtractOverflows(overlay.width, leftOverflow, rightOverflow);\n let visibleHeight = this._subtractOverflows(overlay.height, topOverflow, bottomOverflow);\n let visibleArea = visibleWidth * visibleHeight;\n return {\n visibleArea,\n isCompletelyWithinViewport: overlay.width * overlay.height === visibleArea,\n fitsInViewportVertically: visibleHeight === overlay.height,\n fitsInViewportHorizontally: visibleWidth == overlay.width,\n };\n }\n /**\n * Whether the overlay can fit within the viewport when it may resize either its width or height.\n * @param fit How well the overlay fits in the viewport at some position.\n * @param point The (x, y) coordinates of the overlay at some position.\n * @param viewport The geometry of the viewport.\n */\n _canFitWithFlexibleDimensions(fit, point, viewport) {\n if (this._hasFlexibleDimensions) {\n const availableHeight = viewport.bottom - point.y;\n const availableWidth = viewport.right - point.x;\n const minHeight = getPixelValue(this._overlayRef.getConfig().minHeight);\n const minWidth = getPixelValue(this._overlayRef.getConfig().minWidth);\n const verticalFit = fit.fitsInViewportVertically || (minHeight != null && minHeight <= availableHeight);\n const horizontalFit = fit.fitsInViewportHorizontally || (minWidth != null && minWidth <= availableWidth);\n return verticalFit && horizontalFit;\n }\n return false;\n }\n /**\n * Gets the point at which the overlay can be \"pushed\" on-screen. If the overlay is larger than\n * the viewport, the top-left corner will be pushed on-screen (with overflow occurring on the\n * right and bottom).\n *\n * @param start Starting point from which the overlay is pushed.\n * @param rawOverlayRect Dimensions of the overlay.\n * @param scrollPosition Current viewport scroll position.\n * @returns The point at which to position the overlay after pushing. This is effectively a new\n * originPoint.\n */\n _pushOverlayOnScreen(start, rawOverlayRect, scrollPosition) {\n // If the position is locked and we've pushed the overlay already, reuse the previous push\n // amount, rather than pushing it again. If we were to continue pushing, the element would\n // remain in the viewport, which goes against the expectations when position locking is enabled.\n if (this._previousPushAmount && this._positionLocked) {\n return {\n x: start.x + this._previousPushAmount.x,\n y: start.y + this._previousPushAmount.y,\n };\n }\n // Round the overlay rect when comparing against the\n // viewport, because the viewport is always rounded.\n const overlay = getRoundedBoundingClientRect(rawOverlayRect);\n const viewport = this._viewportRect;\n // Determine how much the overlay goes outside the viewport on each\n // side, which we'll use to decide which direction to push it.\n const overflowRight = Math.max(start.x + overlay.width - viewport.width, 0);\n const overflowBottom = Math.max(start.y + overlay.height - viewport.height, 0);\n const overflowTop = Math.max(viewport.top - scrollPosition.top - start.y, 0);\n const overflowLeft = Math.max(viewport.left - scrollPosition.left - start.x, 0);\n // Amount by which to push the overlay in each axis such that it remains on-screen.\n let pushX = 0;\n let pushY = 0;\n // If the overlay fits completely within the bounds of the viewport, push it from whichever\n // direction is goes off-screen. Otherwise, push the top-left corner such that its in the\n // viewport and allow for the trailing end of the overlay to go out of bounds.\n if (overlay.width <= viewport.width) {\n pushX = overflowLeft || -overflowRight;\n }\n else {\n pushX = start.x < this._viewportMargin ? viewport.left - scrollPosition.left - start.x : 0;\n }\n if (overlay.height <= viewport.height) {\n pushY = overflowTop || -overflowBottom;\n }\n else {\n pushY = start.y < this._viewportMargin ? viewport.top - scrollPosition.top - start.y : 0;\n }\n this._previousPushAmount = { x: pushX, y: pushY };\n return {\n x: start.x + pushX,\n y: start.y + pushY,\n };\n }\n /**\n * Applies a computed position to the overlay and emits a position change.\n * @param position The position preference\n * @param originPoint The point on the origin element where the overlay is connected.\n */\n _applyPosition(position, originPoint) {\n this._setTransformOrigin(position);\n this._setOverlayElementStyles(originPoint, position);\n this._setBoundingBoxStyles(originPoint, position);\n if (position.panelClass) {\n this._addPanelClasses(position.panelClass);\n }\n // Notify that the position has been changed along with its change properties.\n // We only emit if we've got any subscriptions, because the scroll visibility\n // calculations can be somewhat expensive.\n if (this._positionChanges.observers.length) {\n const scrollVisibility = this._getScrollVisibility();\n // We're recalculating on scroll, but we only want to emit if anything\n // changed since downstream code might be hitting the `NgZone`.\n if (position !== this._lastPosition ||\n !this._lastScrollVisibility ||\n !compareScrollVisibility(this._lastScrollVisibility, scrollVisibility)) {\n const changeEvent = new ConnectedOverlayPositionChange(position, scrollVisibility);\n this._positionChanges.next(changeEvent);\n }\n this._lastScrollVisibility = scrollVisibility;\n }\n // Save the last connected position in case the position needs to be re-calculated.\n this._lastPosition = position;\n this._isInitialRender = false;\n }\n /** Sets the transform origin based on the configured selector and the passed-in position. */\n _setTransformOrigin(position) {\n if (!this._transformOriginSelector) {\n return;\n }\n const elements = this._boundingBox.querySelectorAll(this._transformOriginSelector);\n let xOrigin;\n let yOrigin = position.overlayY;\n if (position.overlayX === 'center') {\n xOrigin = 'center';\n }\n else if (this._isRtl()) {\n xOrigin = position.overlayX === 'start' ? 'right' : 'left';\n }\n else {\n xOrigin = position.overlayX === 'start' ? 'left' : 'right';\n }\n for (let i = 0; i < elements.length; i++) {\n elements[i].style.transformOrigin = `${xOrigin} ${yOrigin}`;\n }\n }\n /**\n * Gets the position and size of the overlay's sizing container.\n *\n * This method does no measuring and applies no styles so that we can cheaply compute the\n * bounds for all positions and choose the best fit based on these results.\n */\n _calculateBoundingBoxRect(origin, position) {\n const viewport = this._viewportRect;\n const isRtl = this._isRtl();\n let height, top, bottom;\n if (position.overlayY === 'top') {\n // Overlay is opening \"downward\" and thus is bound by the bottom viewport edge.\n top = origin.y;\n height = viewport.height - top + this._viewportMargin;\n }\n else if (position.overlayY === 'bottom') {\n // Overlay is opening \"upward\" and thus is bound by the top viewport edge. We need to add\n // the viewport margin back in, because the viewport rect is narrowed down to remove the\n // margin, whereas the `origin` position is calculated based on its `DOMRect`.\n bottom = viewport.height - origin.y + this._viewportMargin * 2;\n height = viewport.height - bottom + this._viewportMargin;\n }\n else {\n // If neither top nor bottom, it means that the overlay is vertically centered on the\n // origin point. Note that we want the position relative to the viewport, rather than\n // the page, which is why we don't use something like `viewport.bottom - origin.y` and\n // `origin.y - viewport.top`.\n const smallestDistanceToViewportEdge = Math.min(viewport.bottom - origin.y + viewport.top, origin.y);\n const previousHeight = this._lastBoundingBoxSize.height;\n height = smallestDistanceToViewportEdge * 2;\n top = origin.y - smallestDistanceToViewportEdge;\n if (height > previousHeight && !this._isInitialRender && !this._growAfterOpen) {\n top = origin.y - previousHeight / 2;\n }\n }\n // The overlay is opening 'right-ward' (the content flows to the right).\n const isBoundedByRightViewportEdge = (position.overlayX === 'start' && !isRtl) || (position.overlayX === 'end' && isRtl);\n // The overlay is opening 'left-ward' (the content flows to the left).\n const isBoundedByLeftViewportEdge = (position.overlayX === 'end' && !isRtl) || (position.overlayX === 'start' && isRtl);\n let width, left, right;\n if (isBoundedByLeftViewportEdge) {\n right = viewport.width - origin.x + this._viewportMargin * 2;\n width = origin.x - this._viewportMargin;\n }\n else if (isBoundedByRightViewportEdge) {\n left = origin.x;\n width = viewport.right - origin.x;\n }\n else {\n // If neither start nor end, it means that the overlay is horizontally centered on the\n // origin point. Note that we want the position relative to the viewport, rather than\n // the page, which is why we don't use something like `viewport.right - origin.x` and\n // `origin.x - viewport.left`.\n const smallestDistanceToViewportEdge = Math.min(viewport.right - origin.x + viewport.left, origin.x);\n const previousWidth = this._lastBoundingBoxSize.width;\n width = smallestDistanceToViewportEdge * 2;\n left = origin.x - smallestDistanceToViewportEdge;\n if (width > previousWidth && !this._isInitialRender && !this._growAfterOpen) {\n left = origin.x - previousWidth / 2;\n }\n }\n return { top: top, left: left, bottom: bottom, right: right, width, height };\n }\n /**\n * Sets the position and size of the overlay's sizing wrapper. The wrapper is positioned on the\n * origin's connection point and stretches to the bounds of the viewport.\n *\n * @param origin The point on the origin element where the overlay is connected.\n * @param position The position preference\n */\n _setBoundingBoxStyles(origin, position) {\n const boundingBoxRect = this._calculateBoundingBoxRect(origin, position);\n // It's weird if the overlay *grows* while scrolling, so we take the last size into account\n // when applying a new size.\n if (!this._isInitialRender && !this._growAfterOpen) {\n boundingBoxRect.height = Math.min(boundingBoxRect.height, this._lastBoundingBoxSize.height);\n boundingBoxRect.width = Math.min(boundingBoxRect.width, this._lastBoundingBoxSize.width);\n }\n const styles = {};\n if (this._hasExactPosition()) {\n styles.top = styles.left = '0';\n styles.bottom = styles.right = styles.maxHeight = styles.maxWidth = '';\n styles.width = styles.height = '100%';\n }\n else {\n const maxHeight = this._overlayRef.getConfig().maxHeight;\n const maxWidth = this._overlayRef.getConfig().maxWidth;\n styles.height = coerceCssPixelValue(boundingBoxRect.height);\n styles.top = coerceCssPixelValue(boundingBoxRect.top);\n styles.bottom = coerceCssPixelValue(boundingBoxRect.bottom);\n styles.width = coerceCssPixelValue(boundingBoxRect.width);\n styles.left = coerceCssPixelValue(boundingBoxRect.left);\n styles.right = coerceCssPixelValue(boundingBoxRect.right);\n // Push the pane content towards the proper direction.\n if (position.overlayX === 'center') {\n styles.alignItems = 'center';\n }\n else {\n styles.alignItems = position.overlayX === 'end' ? 'flex-end' : 'flex-start';\n }\n if (position.overlayY === 'center') {\n styles.justifyContent = 'center';\n }\n else {\n styles.justifyContent = position.overlayY === 'bottom' ? 'flex-end' : 'flex-start';\n }\n if (maxHeight) {\n styles.maxHeight = coerceCssPixelValue(maxHeight);\n }\n if (maxWidth) {\n styles.maxWidth = coerceCssPixelValue(maxWidth);\n }\n }\n this._lastBoundingBoxSize = boundingBoxRect;\n extendStyles(this._boundingBox.style, styles);\n }\n /** Resets the styles for the bounding box so that a new positioning can be computed. */\n _resetBoundingBoxStyles() {\n extendStyles(this._boundingBox.style, {\n top: '0',\n left: '0',\n right: '0',\n bottom: '0',\n height: '',\n width: '',\n alignItems: '',\n justifyContent: '',\n });\n }\n /** Resets the styles for the overlay pane so that a new positioning can be computed. */\n _resetOverlayElementStyles() {\n extendStyles(this._pane.style, {\n top: '',\n left: '',\n bottom: '',\n right: '',\n position: '',\n transform: '',\n });\n }\n /** Sets positioning styles to the overlay element. */\n _setOverlayElementStyles(originPoint, position) {\n const styles = {};\n const hasExactPosition = this._hasExactPosition();\n const hasFlexibleDimensions = this._hasFlexibleDimensions;\n const config = this._overlayRef.getConfig();\n if (hasExactPosition) {\n const scrollPosition = this._viewportRuler.getViewportScrollPosition();\n extendStyles(styles, this._getExactOverlayY(position, originPoint, scrollPosition));\n extendStyles(styles, this._getExactOverlayX(position, originPoint, scrollPosition));\n }\n else {\n styles.position = 'static';\n }\n // Use a transform to apply the offsets. We do this because the `center` positions rely on\n // being in the normal flex flow and setting a `top` / `left` at all will completely throw\n // off the position. We also can't use margins, because they won't have an effect in some\n // cases where the element doesn't have anything to \"push off of\". Finally, this works\n // better both with flexible and non-flexible positioning.\n let transformString = '';\n let offsetX = this._getOffset(position, 'x');\n let offsetY = this._getOffset(position, 'y');\n if (offsetX) {\n transformString += `translateX(${offsetX}px) `;\n }\n if (offsetY) {\n transformString += `translateY(${offsetY}px)`;\n }\n styles.transform = transformString.trim();\n // If a maxWidth or maxHeight is specified on the overlay, we remove them. We do this because\n // we need these values to both be set to \"100%\" for the automatic flexible sizing to work.\n // The maxHeight and maxWidth are set on the boundingBox in order to enforce the constraint.\n // Note that this doesn't apply when we have an exact position, in which case we do want to\n // apply them because they'll be cleared from the bounding box.\n if (config.maxHeight) {\n if (hasExactPosition) {\n styles.maxHeight = coerceCssPixelValue(config.maxHeight);\n }\n else if (hasFlexibleDimensions) {\n styles.maxHeight = '';\n }\n }\n if (config.maxWidth) {\n if (hasExactPosition) {\n styles.maxWidth = coerceCssPixelValue(config.maxWidth);\n }\n else if (hasFlexibleDimensions) {\n styles.maxWidth = '';\n }\n }\n extendStyles(this._pane.style, styles);\n }\n /** Gets the exact top/bottom for the overlay when not using flexible sizing or when pushing. */\n _getExactOverlayY(position, originPoint, scrollPosition) {\n // Reset any existing styles. This is necessary in case the\n // preferred position has changed since the last `apply`.\n let styles = { top: '', bottom: '' };\n let overlayPoint = this._getOverlayPoint(originPoint, this._overlayRect, position);\n if (this._isPushed) {\n overlayPoint = this._pushOverlayOnScreen(overlayPoint, this._overlayRect, scrollPosition);\n }\n // We want to set either `top` or `bottom` based on whether the overlay wants to appear\n // above or below the origin and the direction in which the element will expand.\n if (position.overlayY === 'bottom') {\n // When using `bottom`, we adjust the y position such that it is the distance\n // from the bottom of the viewport rather than the top.\n const documentHeight = this._document.documentElement.clientHeight;\n styles.bottom = `${documentHeight - (overlayPoint.y + this._overlayRect.height)}px`;\n }\n else {\n styles.top = coerceCssPixelValue(overlayPoint.y);\n }\n return styles;\n }\n /** Gets the exact left/right for the overlay when not using flexible sizing or when pushing. */\n _getExactOverlayX(position, originPoint, scrollPosition) {\n // Reset any existing styles. This is necessary in case the preferred position has\n // changed since the last `apply`.\n let styles = { left: '', right: '' };\n let overlayPoint = this._getOverlayPoint(originPoint, this._overlayRect, position);\n if (this._isPushed) {\n overlayPoint = this._pushOverlayOnScreen(overlayPoint, this._overlayRect, scrollPosition);\n }\n // We want to set either `left` or `right` based on whether the overlay wants to appear \"before\"\n // or \"after\" the origin, which determines the direction in which the element will expand.\n // For the horizontal axis, the meaning of \"before\" and \"after\" change based on whether the\n // page is in RTL or LTR.\n let horizontalStyleProperty;\n if (this._isRtl()) {\n horizontalStyleProperty = position.overlayX === 'end' ? 'left' : 'right';\n }\n else {\n horizontalStyleProperty = position.overlayX === 'end' ? 'right' : 'left';\n }\n // When we're setting `right`, we adjust the x position such that it is the distance\n // from the right edge of the viewport rather than the left edge.\n if (horizontalStyleProperty === 'right') {\n const documentWidth = this._document.documentElement.clientWidth;\n styles.right = `${documentWidth - (overlayPoint.x + this._overlayRect.width)}px`;\n }\n else {\n styles.left = coerceCssPixelValue(overlayPoint.x);\n }\n return styles;\n }\n /**\n * Gets the view properties of the trigger and overlay, including whether they are clipped\n * or completely outside the view of any of the strategy's scrollables.\n */\n _getScrollVisibility() {\n // Note: needs fresh rects since the position could've changed.\n const originBounds = this._getOriginRect();\n const overlayBounds = this._pane.getBoundingClientRect();\n // TODO(jelbourn): instead of needing all of the client rects for these scrolling containers\n // every time, we should be able to use the scrollTop of the containers if the size of those\n // containers hasn't changed.\n const scrollContainerBounds = this._scrollables.map(scrollable => {\n return scrollable.getElementRef().nativeElement.getBoundingClientRect();\n });\n return {\n isOriginClipped: isElementClippedByScrolling(originBounds, scrollContainerBounds),\n isOriginOutsideView: isElementScrolledOutsideView(originBounds, scrollContainerBounds),\n isOverlayClipped: isElementClippedByScrolling(overlayBounds, scrollContainerBounds),\n isOverlayOutsideView: isElementScrolledOutsideView(overlayBounds, scrollContainerBounds),\n };\n }\n /** Subtracts the amount that an element is overflowing on an axis from its length. */\n _subtractOverflows(length, ...overflows) {\n return overflows.reduce((currentValue, currentOverflow) => {\n return currentValue - Math.max(currentOverflow, 0);\n }, length);\n }\n /** Narrows the given viewport rect by the current _viewportMargin. */\n _getNarrowedViewportRect() {\n // We recalculate the viewport rect here ourselves, rather than using the ViewportRuler,\n // because we want to use the `clientWidth` and `clientHeight` as the base. The difference\n // being that the client properties don't include the scrollbar, as opposed to `innerWidth`\n // and `innerHeight` that do. This is necessary, because the overlay container uses\n // 100% `width` and `height` which don't include the scrollbar either.\n const width = this._document.documentElement.clientWidth;\n const height = this._document.documentElement.clientHeight;\n const scrollPosition = this._viewportRuler.getViewportScrollPosition();\n return {\n top: scrollPosition.top + this._viewportMargin,\n left: scrollPosition.left + this._viewportMargin,\n right: scrollPosition.left + width - this._viewportMargin,\n bottom: scrollPosition.top + height - this._viewportMargin,\n width: width - 2 * this._viewportMargin,\n height: height - 2 * this._viewportMargin,\n };\n }\n /** Whether the we're dealing with an RTL context */\n _isRtl() {\n return this._overlayRef.getDirection() === 'rtl';\n }\n /** Determines whether the overlay uses exact or flexible positioning. */\n _hasExactPosition() {\n return !this._hasFlexibleDimensions || this._isPushed;\n }\n /** Retrieves the offset of a position along the x or y axis. */\n _getOffset(position, axis) {\n if (axis === 'x') {\n // We don't do something like `position['offset' + axis]` in\n // order to avoid breaking minifiers that rename properties.\n return position.offsetX == null ? this._offsetX : position.offsetX;\n }\n return position.offsetY == null ? this._offsetY : position.offsetY;\n }\n /** Validates that the current position match the expected values. */\n _validatePositions() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (!this._preferredPositions.length) {\n throw Error('FlexibleConnectedPositionStrategy: At least one position is required.');\n }\n // TODO(crisbeto): remove these once Angular's template type\n // checking is advanced enough to catch these cases.\n this._preferredPositions.forEach(pair => {\n validateHorizontalPosition('originX', pair.originX);\n validateVerticalPosition('originY', pair.originY);\n validateHorizontalPosition('overlayX', pair.overlayX);\n validateVerticalPosition('overlayY', pair.overlayY);\n });\n }\n }\n /** Adds a single CSS class or an array of classes on the overlay panel. */\n _addPanelClasses(cssClasses) {\n if (this._pane) {\n coerceArray(cssClasses).forEach(cssClass => {\n if (cssClass !== '' && this._appliedPanelClasses.indexOf(cssClass) === -1) {\n this._appliedPanelClasses.push(cssClass);\n this._pane.classList.add(cssClass);\n }\n });\n }\n }\n /** Clears the classes that the position strategy has applied from the overlay panel. */\n _clearPanelClasses() {\n if (this._pane) {\n this._appliedPanelClasses.forEach(cssClass => {\n this._pane.classList.remove(cssClass);\n });\n this._appliedPanelClasses = [];\n }\n }\n /** Returns the DOMRect of the current origin. */\n _getOriginRect() {\n const origin = this._origin;\n if (origin instanceof ElementRef) {\n return origin.nativeElement.getBoundingClientRect();\n }\n // Check for Element so SVG elements are also supported.\n if (origin instanceof Element) {\n return origin.getBoundingClientRect();\n }\n const width = origin.width || 0;\n const height = origin.height || 0;\n // If the origin is a point, return a client rect as if it was a 0x0 element at the point.\n return {\n top: origin.y,\n bottom: origin.y + height,\n left: origin.x,\n right: origin.x + width,\n height,\n width,\n };\n }\n}\n/** Shallow-extends a stylesheet object with another stylesheet object. */\nfunction extendStyles(destination, source) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n destination[key] = source[key];\n }\n }\n return destination;\n}\n/**\n * Extracts the pixel value as a number from a value, if it's a number\n * or a CSS pixel string (e.g. `1337px`). Otherwise returns null.\n */\nfunction getPixelValue(input) {\n if (typeof input !== 'number' && input != null) {\n const [value, units] = input.split(cssUnitPattern);\n return !units || units === 'px' ? parseFloat(value) : null;\n }\n return input || null;\n}\n/**\n * Gets a version of an element's bounding `DOMRect` where all the values are rounded down to\n * the nearest pixel. This allows us to account for the cases where there may be sub-pixel\n * deviations in the `DOMRect` returned by the browser (e.g. when zoomed in with a percentage\n * size, see #21350).\n */\nfunction getRoundedBoundingClientRect(clientRect) {\n return {\n top: Math.floor(clientRect.top),\n right: Math.floor(clientRect.right),\n bottom: Math.floor(clientRect.bottom),\n left: Math.floor(clientRect.left),\n width: Math.floor(clientRect.width),\n height: Math.floor(clientRect.height),\n };\n}\n/** Returns whether two `ScrollingVisibility` objects are identical. */\nfunction compareScrollVisibility(a, b) {\n if (a === b) {\n return true;\n }\n return (a.isOriginClipped === b.isOriginClipped &&\n a.isOriginOutsideView === b.isOriginOutsideView &&\n a.isOverlayClipped === b.isOverlayClipped &&\n a.isOverlayOutsideView === b.isOverlayOutsideView);\n}\nconst STANDARD_DROPDOWN_BELOW_POSITIONS = [\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },\n { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },\n];\nconst STANDARD_DROPDOWN_ADJACENT_POSITIONS = [\n { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },\n { originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },\n { originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },\n { originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },\n];\n\n/** Class to be added to the overlay pane wrapper. */\nconst wrapperClass = 'cdk-global-overlay-wrapper';\n/**\n * A strategy for positioning overlays. Using this strategy, an overlay is given an\n * explicit position relative to the browser's viewport. We use flexbox, instead of\n * transforms, in order to avoid issues with subpixel rendering which can cause the\n * element to become blurry.\n */\nclass GlobalPositionStrategy {\n /** The overlay to which this strategy is attached. */\n _overlayRef;\n _cssPosition = 'static';\n _topOffset = '';\n _bottomOffset = '';\n _alignItems = '';\n _xPosition = '';\n _xOffset = '';\n _width = '';\n _height = '';\n _isDisposed = false;\n attach(overlayRef) {\n const config = overlayRef.getConfig();\n this._overlayRef = overlayRef;\n if (this._width && !config.width) {\n overlayRef.updateSize({ width: this._width });\n }\n if (this._height && !config.height) {\n overlayRef.updateSize({ height: this._height });\n }\n overlayRef.hostElement.classList.add(wrapperClass);\n this._isDisposed = false;\n }\n /**\n * Sets the top position of the overlay. Clears any previously set vertical position.\n * @param value New top offset.\n */\n top(value = '') {\n this._bottomOffset = '';\n this._topOffset = value;\n this._alignItems = 'flex-start';\n return this;\n }\n /**\n * Sets the left position of the overlay. Clears any previously set horizontal position.\n * @param value New left offset.\n */\n left(value = '') {\n this._xOffset = value;\n this._xPosition = 'left';\n return this;\n }\n /**\n * Sets the bottom position of the overlay. Clears any previously set vertical position.\n * @param value New bottom offset.\n */\n bottom(value = '') {\n this._topOffset = '';\n this._bottomOffset = value;\n this._alignItems = 'flex-end';\n return this;\n }\n /**\n * Sets the right position of the overlay. Clears any previously set horizontal position.\n * @param value New right offset.\n */\n right(value = '') {\n this._xOffset = value;\n this._xPosition = 'right';\n return this;\n }\n /**\n * Sets the overlay to the start of the viewport, depending on the overlay direction.\n * This will be to the left in LTR layouts and to the right in RTL.\n * @param offset Offset from the edge of the screen.\n */\n start(value = '') {\n this._xOffset = value;\n this._xPosition = 'start';\n return this;\n }\n /**\n * Sets the overlay to the end of the viewport, depending on the overlay direction.\n * This will be to the right in LTR layouts and to the left in RTL.\n * @param offset Offset from the edge of the screen.\n */\n end(value = '') {\n this._xOffset = value;\n this._xPosition = 'end';\n return this;\n }\n /**\n * Sets the overlay width and clears any previously set width.\n * @param value New width for the overlay\n * @deprecated Pass the `width` through the `OverlayConfig`.\n * @breaking-change 8.0.0\n */\n width(value = '') {\n if (this._overlayRef) {\n this._overlayRef.updateSize({ width: value });\n }\n else {\n this._width = value;\n }\n return this;\n }\n /**\n * Sets the overlay height and clears any previously set height.\n * @param value New height for the overlay\n * @deprecated Pass the `height` through the `OverlayConfig`.\n * @breaking-change 8.0.0\n */\n height(value = '') {\n if (this._overlayRef) {\n this._overlayRef.updateSize({ height: value });\n }\n else {\n this._height = value;\n }\n return this;\n }\n /**\n * Centers the overlay horizontally with an optional offset.\n * Clears any previously set horizontal position.\n *\n * @param offset Overlay offset from the horizontal center.\n */\n centerHorizontally(offset = '') {\n this.left(offset);\n this._xPosition = 'center';\n return this;\n }\n /**\n * Centers the overlay vertically with an optional offset.\n * Clears any previously set vertical position.\n *\n * @param offset Overlay offset from the vertical center.\n */\n centerVertically(offset = '') {\n this.top(offset);\n this._alignItems = 'center';\n return this;\n }\n /**\n * Apply the position to the element.\n * @docs-private\n */\n apply() {\n // Since the overlay ref applies the strategy asynchronously, it could\n // have been disposed before it ends up being applied. If that is the\n // case, we shouldn't do anything.\n if (!this._overlayRef || !this._overlayRef.hasAttached()) {\n return;\n }\n const styles = this._overlayRef.overlayElement.style;\n const parentStyles = this._overlayRef.hostElement.style;\n const config = this._overlayRef.getConfig();\n const { width, height, maxWidth, maxHeight } = config;\n const shouldBeFlushHorizontally = (width === '100%' || width === '100vw') &&\n (!maxWidth || maxWidth === '100%' || maxWidth === '100vw');\n const shouldBeFlushVertically = (height === '100%' || height === '100vh') &&\n (!maxHeight || maxHeight === '100%' || maxHeight === '100vh');\n const xPosition = this._xPosition;\n const xOffset = this._xOffset;\n const isRtl = this._overlayRef.getConfig().direction === 'rtl';\n let marginLeft = '';\n let marginRight = '';\n let justifyContent = '';\n if (shouldBeFlushHorizontally) {\n justifyContent = 'flex-start';\n }\n else if (xPosition === 'center') {\n justifyContent = 'center';\n if (isRtl) {\n marginRight = xOffset;\n }\n else {\n marginLeft = xOffset;\n }\n }\n else if (isRtl) {\n if (xPosition === 'left' || xPosition === 'end') {\n justifyContent = 'flex-end';\n marginLeft = xOffset;\n }\n else if (xPosition === 'right' || xPosition === 'start') {\n justifyContent = 'flex-start';\n marginRight = xOffset;\n }\n }\n else if (xPosition === 'left' || xPosition === 'start') {\n justifyContent = 'flex-start';\n marginLeft = xOffset;\n }\n else if (xPosition === 'right' || xPosition === 'end') {\n justifyContent = 'flex-end';\n marginRight = xOffset;\n }\n styles.position = this._cssPosition;\n styles.marginLeft = shouldBeFlushHorizontally ? '0' : marginLeft;\n styles.marginTop = shouldBeFlushVertically ? '0' : this._topOffset;\n styles.marginBottom = this._bottomOffset;\n styles.marginRight = shouldBeFlushHorizontally ? '0' : marginRight;\n parentStyles.justifyContent = justifyContent;\n parentStyles.alignItems = shouldBeFlushVertically ? 'flex-start' : this._alignItems;\n }\n /**\n * Cleans up the DOM changes from the position strategy.\n * @docs-private\n */\n dispose() {\n if (this._isDisposed || !this._overlayRef) {\n return;\n }\n const styles = this._overlayRef.overlayElement.style;\n const parent = this._overlayRef.hostElement;\n const parentStyles = parent.style;\n parent.classList.remove(wrapperClass);\n parentStyles.justifyContent =\n parentStyles.alignItems =\n styles.marginTop =\n styles.marginBottom =\n styles.marginLeft =\n styles.marginRight =\n styles.position =\n '';\n this._overlayRef = null;\n this._isDisposed = true;\n }\n}\n\n/** Builder for overlay position strategy. */\nclass OverlayPositionBuilder {\n _viewportRuler = inject(ViewportRuler);\n _document = inject(DOCUMENT);\n _platform = inject(Platform);\n _overlayContainer = inject(OverlayContainer);\n constructor() { }\n /**\n * Creates a global position strategy.\n */\n global() {\n return new GlobalPositionStrategy();\n }\n /**\n * Creates a flexible position strategy.\n * @param origin Origin relative to which to position the overlay.\n */\n flexibleConnectedTo(origin) {\n return new FlexibleConnectedPositionStrategy(origin, this._viewportRuler, this._document, this._platform, this._overlayContainer);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayPositionBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayPositionBuilder, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayPositionBuilder, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/**\n * Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be\n * used as a low-level building block for other components. Dialogs, tooltips, menus,\n * selects, etc. can all be built using overlays. The service should primarily be used by authors\n * of re-usable components rather than developers building end-user applications.\n *\n * An overlay *is* a PortalOutlet, so any kind of Portal can be loaded into one.\n */\nclass Overlay {\n scrollStrategies = inject(ScrollStrategyOptions);\n _overlayContainer = inject(OverlayContainer);\n _positionBuilder = inject(OverlayPositionBuilder);\n _keyboardDispatcher = inject(OverlayKeyboardDispatcher);\n _injector = inject(Injector);\n _ngZone = inject(NgZone);\n _document = inject(DOCUMENT);\n _directionality = inject(Directionality);\n _location = inject(Location);\n _outsideClickDispatcher = inject(OverlayOutsideClickDispatcher);\n _animationsModuleType = inject(ANIMATION_MODULE_TYPE, { optional: true });\n _idGenerator = inject(_IdGenerator);\n _renderer = inject(RendererFactory2).createRenderer(null, null);\n _appRef;\n _styleLoader = inject(_CdkPrivateStyleLoader);\n constructor() { }\n /**\n * Creates an overlay.\n * @param config Configuration applied to the overlay.\n * @returns Reference to the created overlay.\n */\n create(config) {\n // This is done in the overlay container as well, but we have it here\n // since it's common to mock out the overlay container in tests.\n this._styleLoader.load(_CdkOverlayStyleLoader);\n const host = this._createHostElement();\n const pane = this._createPaneElement(host);\n const portalOutlet = this._createPortalOutlet(pane);\n const overlayConfig = new OverlayConfig(config);\n overlayConfig.direction = overlayConfig.direction || this._directionality.value;\n return new OverlayRef(portalOutlet, host, pane, overlayConfig, this._ngZone, this._keyboardDispatcher, this._document, this._location, this._outsideClickDispatcher, this._animationsModuleType === 'NoopAnimations', this._injector.get(EnvironmentInjector), this._renderer);\n }\n /**\n * Gets a position builder that can be used, via fluent API,\n * to construct and configure a position strategy.\n * @returns An overlay position builder.\n */\n position() {\n return this._positionBuilder;\n }\n /**\n * Creates the DOM element for an overlay and appends it to the overlay container.\n * @returns Newly-created pane element\n */\n _createPaneElement(host) {\n const pane = this._document.createElement('div');\n pane.id = this._idGenerator.getId('cdk-overlay-');\n pane.classList.add('cdk-overlay-pane');\n host.appendChild(pane);\n return pane;\n }\n /**\n * Creates the host element that wraps around an overlay\n * and can be used for advanced positioning.\n * @returns Newly-create host element.\n */\n _createHostElement() {\n const host = this._document.createElement('div');\n this._overlayContainer.getContainerElement().appendChild(host);\n return host;\n }\n /**\n * Create a DomPortalOutlet into which the overlay content can be loaded.\n * @param pane The DOM element to turn into a portal outlet.\n * @returns A portal outlet for the given DOM element.\n */\n _createPortalOutlet(pane) {\n // We have to resolve the ApplicationRef later in order to allow people\n // to use overlay-based providers during app initialization.\n if (!this._appRef) {\n this._appRef = this._injector.get(ApplicationRef);\n }\n return new DomPortalOutlet(pane, null, this._appRef, this._injector, this._document);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Overlay, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Overlay, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Overlay, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/** Default set of positions for the overlay. Follows the behavior of a dropdown. */\nconst defaultPositionList = [\n {\n originX: 'start',\n originY: 'bottom',\n overlayX: 'start',\n overlayY: 'top',\n },\n {\n originX: 'start',\n originY: 'top',\n overlayX: 'start',\n overlayY: 'bottom',\n },\n {\n originX: 'end',\n originY: 'top',\n overlayX: 'end',\n overlayY: 'bottom',\n },\n {\n originX: 'end',\n originY: 'bottom',\n overlayX: 'end',\n overlayY: 'top',\n },\n];\n/** Injection token that determines the scroll handling while the connected overlay is open. */\nconst CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY = new InjectionToken('cdk-connected-overlay-scroll-strategy', {\n providedIn: 'root',\n factory: () => {\n const overlay = inject(Overlay);\n return () => overlay.scrollStrategies.reposition();\n },\n});\n/**\n * Directive applied to an element to make it usable as an origin for an Overlay using a\n * ConnectedPositionStrategy.\n */\nclass CdkOverlayOrigin {\n elementRef = inject(ElementRef);\n constructor() { }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkOverlayOrigin, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkOverlayOrigin, isStandalone: true, selector: \"[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]\", exportAs: [\"cdkOverlayOrigin\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkOverlayOrigin, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]',\n exportAs: 'cdkOverlayOrigin',\n }]\n }], ctorParameters: () => [] });\n/**\n * Directive to facilitate declarative creation of an\n * Overlay using a FlexibleConnectedPositionStrategy.\n */\nclass CdkConnectedOverlay {\n _overlay = inject(Overlay);\n _dir = inject(Directionality, { optional: true });\n _overlayRef;\n _templatePortal;\n _backdropSubscription = Subscription.EMPTY;\n _attachSubscription = Subscription.EMPTY;\n _detachSubscription = Subscription.EMPTY;\n _positionSubscription = Subscription.EMPTY;\n _offsetX;\n _offsetY;\n _position;\n _scrollStrategyFactory = inject(CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY);\n _disposeOnNavigation = false;\n _ngZone = inject(NgZone);\n /** Origin for the connected overlay. */\n origin;\n /** Registered connected position pairs. */\n positions;\n /**\n * This input overrides the positions input if specified. It lets users pass\n * in arbitrary positioning strategies.\n */\n positionStrategy;\n /** The offset in pixels for the overlay connection point on the x-axis */\n get offsetX() {\n return this._offsetX;\n }\n set offsetX(offsetX) {\n this._offsetX = offsetX;\n if (this._position) {\n this._updatePositionStrategy(this._position);\n }\n }\n /** The offset in pixels for the overlay connection point on the y-axis */\n get offsetY() {\n return this._offsetY;\n }\n set offsetY(offsetY) {\n this._offsetY = offsetY;\n if (this._position) {\n this._updatePositionStrategy(this._position);\n }\n }\n /** The width of the overlay panel. */\n width;\n /** The height of the overlay panel. */\n height;\n /** The min width of the overlay panel. */\n minWidth;\n /** The min height of the overlay panel. */\n minHeight;\n /** The custom class to be set on the backdrop element. */\n backdropClass;\n /** The custom class to add to the overlay pane element. */\n panelClass;\n /** Margin between the overlay and the viewport edges. */\n viewportMargin = 0;\n /** Strategy to be used when handling scroll events while the overlay is open. */\n scrollStrategy;\n /** Whether the overlay is open. */\n open = false;\n /** Whether the overlay can be closed by user interaction. */\n disableClose = false;\n /** CSS selector which to set the transform origin. */\n transformOriginSelector;\n /** Whether or not the overlay should attach a backdrop. */\n hasBackdrop = false;\n /** Whether or not the overlay should be locked when scrolling. */\n lockPosition = false;\n /** Whether the overlay's width and height can be constrained to fit within the viewport. */\n flexibleDimensions = false;\n /** Whether the overlay can grow after the initial open when flexible positioning is turned on. */\n growAfterOpen = false;\n /** Whether the overlay can be pushed on-screen if none of the provided positions fit. */\n push = false;\n /** Whether the overlay should be disposed of when the user goes backwards/forwards in history. */\n get disposeOnNavigation() {\n return this._disposeOnNavigation;\n }\n set disposeOnNavigation(value) {\n this._disposeOnNavigation = value;\n }\n /** Event emitted when the backdrop is clicked. */\n backdropClick = new EventEmitter();\n /** Event emitted when the position has changed. */\n positionChange = new EventEmitter();\n /** Event emitted when the overlay has been attached. */\n attach = new EventEmitter();\n /** Event emitted when the overlay has been detached. */\n detach = new EventEmitter();\n /** Emits when there are keyboard events that are targeted at the overlay. */\n overlayKeydown = new EventEmitter();\n /** Emits when there are mouse outside click events that are targeted at the overlay. */\n overlayOutsideClick = new EventEmitter();\n // TODO(jelbourn): inputs for size, scroll behavior, animation, etc.\n constructor() {\n const templateRef = inject(TemplateRef);\n const viewContainerRef = inject(ViewContainerRef);\n this._templatePortal = new TemplatePortal(templateRef, viewContainerRef);\n this.scrollStrategy = this._scrollStrategyFactory();\n }\n /** The associated overlay reference. */\n get overlayRef() {\n return this._overlayRef;\n }\n /** The element's layout direction. */\n get dir() {\n return this._dir ? this._dir.value : 'ltr';\n }\n ngOnDestroy() {\n this._attachSubscription.unsubscribe();\n this._detachSubscription.unsubscribe();\n this._backdropSubscription.unsubscribe();\n this._positionSubscription.unsubscribe();\n if (this._overlayRef) {\n this._overlayRef.dispose();\n }\n }\n ngOnChanges(changes) {\n if (this._position) {\n this._updatePositionStrategy(this._position);\n this._overlayRef.updateSize({\n width: this.width,\n minWidth: this.minWidth,\n height: this.height,\n minHeight: this.minHeight,\n });\n if (changes['origin'] && this.open) {\n this._position.apply();\n }\n }\n if (changes['open']) {\n this.open ? this._attachOverlay() : this._detachOverlay();\n }\n }\n /** Creates an overlay */\n _createOverlay() {\n if (!this.positions || !this.positions.length) {\n this.positions = defaultPositionList;\n }\n const overlayRef = (this._overlayRef = this._overlay.create(this._buildConfig()));\n this._attachSubscription = overlayRef.attachments().subscribe(() => this.attach.emit());\n this._detachSubscription = overlayRef.detachments().subscribe(() => this.detach.emit());\n overlayRef.keydownEvents().subscribe((event) => {\n this.overlayKeydown.next(event);\n if (event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)) {\n event.preventDefault();\n this._detachOverlay();\n }\n });\n this._overlayRef.outsidePointerEvents().subscribe((event) => {\n const origin = this._getOriginElement();\n const target = _getEventTarget(event);\n if (!origin || (origin !== target && !origin.contains(target))) {\n this.overlayOutsideClick.next(event);\n }\n });\n }\n /** Builds the overlay config based on the directive's inputs */\n _buildConfig() {\n const positionStrategy = (this._position =\n this.positionStrategy || this._createPositionStrategy());\n const overlayConfig = new OverlayConfig({\n direction: this._dir || 'ltr',\n positionStrategy,\n scrollStrategy: this.scrollStrategy,\n hasBackdrop: this.hasBackdrop,\n disposeOnNavigation: this.disposeOnNavigation,\n });\n if (this.width || this.width === 0) {\n overlayConfig.width = this.width;\n }\n if (this.height || this.height === 0) {\n overlayConfig.height = this.height;\n }\n if (this.minWidth || this.minWidth === 0) {\n overlayConfig.minWidth = this.minWidth;\n }\n if (this.minHeight || this.minHeight === 0) {\n overlayConfig.minHeight = this.minHeight;\n }\n if (this.backdropClass) {\n overlayConfig.backdropClass = this.backdropClass;\n }\n if (this.panelClass) {\n overlayConfig.panelClass = this.panelClass;\n }\n return overlayConfig;\n }\n /** Updates the state of a position strategy, based on the values of the directive inputs. */\n _updatePositionStrategy(positionStrategy) {\n const positions = this.positions.map(currentPosition => ({\n originX: currentPosition.originX,\n originY: currentPosition.originY,\n overlayX: currentPosition.overlayX,\n overlayY: currentPosition.overlayY,\n offsetX: currentPosition.offsetX || this.offsetX,\n offsetY: currentPosition.offsetY || this.offsetY,\n panelClass: currentPosition.panelClass || undefined,\n }));\n return positionStrategy\n .setOrigin(this._getOrigin())\n .withPositions(positions)\n .withFlexibleDimensions(this.flexibleDimensions)\n .withPush(this.push)\n .withGrowAfterOpen(this.growAfterOpen)\n .withViewportMargin(this.viewportMargin)\n .withLockedPosition(this.lockPosition)\n .withTransformOriginOn(this.transformOriginSelector);\n }\n /** Returns the position strategy of the overlay to be set on the overlay config */\n _createPositionStrategy() {\n const strategy = this._overlay.position().flexibleConnectedTo(this._getOrigin());\n this._updatePositionStrategy(strategy);\n return strategy;\n }\n _getOrigin() {\n if (this.origin instanceof CdkOverlayOrigin) {\n return this.origin.elementRef;\n }\n else {\n return this.origin;\n }\n }\n _getOriginElement() {\n if (this.origin instanceof CdkOverlayOrigin) {\n return this.origin.elementRef.nativeElement;\n }\n if (this.origin instanceof ElementRef) {\n return this.origin.nativeElement;\n }\n if (typeof Element !== 'undefined' && this.origin instanceof Element) {\n return this.origin;\n }\n return null;\n }\n /** Attaches the overlay and subscribes to backdrop clicks if backdrop exists */\n _attachOverlay() {\n if (!this._overlayRef) {\n this._createOverlay();\n }\n else {\n // Update the overlay size, in case the directive's inputs have changed\n this._overlayRef.getConfig().hasBackdrop = this.hasBackdrop;\n }\n if (!this._overlayRef.hasAttached()) {\n this._overlayRef.attach(this._templatePortal);\n }\n if (this.hasBackdrop) {\n this._backdropSubscription = this._overlayRef.backdropClick().subscribe(event => {\n this.backdropClick.emit(event);\n });\n }\n else {\n this._backdropSubscription.unsubscribe();\n }\n this._positionSubscription.unsubscribe();\n // Only subscribe to `positionChanges` if requested, because putting\n // together all the information for it can be expensive.\n if (this.positionChange.observers.length > 0) {\n this._positionSubscription = this._position.positionChanges\n .pipe(takeWhile(() => this.positionChange.observers.length > 0))\n .subscribe(position => {\n this._ngZone.run(() => this.positionChange.emit(position));\n if (this.positionChange.observers.length === 0) {\n this._positionSubscription.unsubscribe();\n }\n });\n }\n }\n /** Detaches the overlay and unsubscribes to backdrop clicks if backdrop exists */\n _detachOverlay() {\n if (this._overlayRef) {\n this._overlayRef.detach();\n }\n this._backdropSubscription.unsubscribe();\n this._positionSubscription.unsubscribe();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkConnectedOverlay, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkConnectedOverlay, isStandalone: true, selector: \"[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]\", inputs: { origin: [\"cdkConnectedOverlayOrigin\", \"origin\"], positions: [\"cdkConnectedOverlayPositions\", \"positions\"], positionStrategy: [\"cdkConnectedOverlayPositionStrategy\", \"positionStrategy\"], offsetX: [\"cdkConnectedOverlayOffsetX\", \"offsetX\"], offsetY: [\"cdkConnectedOverlayOffsetY\", \"offsetY\"], width: [\"cdkConnectedOverlayWidth\", \"width\"], height: [\"cdkConnectedOverlayHeight\", \"height\"], minWidth: [\"cdkConnectedOverlayMinWidth\", \"minWidth\"], minHeight: [\"cdkConnectedOverlayMinHeight\", \"minHeight\"], backdropClass: [\"cdkConnectedOverlayBackdropClass\", \"backdropClass\"], panelClass: [\"cdkConnectedOverlayPanelClass\", \"panelClass\"], viewportMargin: [\"cdkConnectedOverlayViewportMargin\", \"viewportMargin\"], scrollStrategy: [\"cdkConnectedOverlayScrollStrategy\", \"scrollStrategy\"], open: [\"cdkConnectedOverlayOpen\", \"open\"], disableClose: [\"cdkConnectedOverlayDisableClose\", \"disableClose\"], transformOriginSelector: [\"cdkConnectedOverlayTransformOriginOn\", \"transformOriginSelector\"], hasBackdrop: [\"cdkConnectedOverlayHasBackdrop\", \"hasBackdrop\", booleanAttribute], lockPosition: [\"cdkConnectedOverlayLockPosition\", \"lockPosition\", booleanAttribute], flexibleDimensions: [\"cdkConnectedOverlayFlexibleDimensions\", \"flexibleDimensions\", booleanAttribute], growAfterOpen: [\"cdkConnectedOverlayGrowAfterOpen\", \"growAfterOpen\", booleanAttribute], push: [\"cdkConnectedOverlayPush\", \"push\", booleanAttribute], disposeOnNavigation: [\"cdkConnectedOverlayDisposeOnNavigation\", \"disposeOnNavigation\", booleanAttribute] }, outputs: { backdropClick: \"backdropClick\", positionChange: \"positionChange\", attach: \"attach\", detach: \"detach\", overlayKeydown: \"overlayKeydown\", overlayOutsideClick: \"overlayOutsideClick\" }, exportAs: [\"cdkConnectedOverlay\"], usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkConnectedOverlay, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]',\n exportAs: 'cdkConnectedOverlay',\n }]\n }], ctorParameters: () => [], propDecorators: { origin: [{\n type: Input,\n args: ['cdkConnectedOverlayOrigin']\n }], positions: [{\n type: Input,\n args: ['cdkConnectedOverlayPositions']\n }], positionStrategy: [{\n type: Input,\n args: ['cdkConnectedOverlayPositionStrategy']\n }], offsetX: [{\n type: Input,\n args: ['cdkConnectedOverlayOffsetX']\n }], offsetY: [{\n type: Input,\n args: ['cdkConnectedOverlayOffsetY']\n }], width: [{\n type: Input,\n args: ['cdkConnectedOverlayWidth']\n }], height: [{\n type: Input,\n args: ['cdkConnectedOverlayHeight']\n }], minWidth: [{\n type: Input,\n args: ['cdkConnectedOverlayMinWidth']\n }], minHeight: [{\n type: Input,\n args: ['cdkConnectedOverlayMinHeight']\n }], backdropClass: [{\n type: Input,\n args: ['cdkConnectedOverlayBackdropClass']\n }], panelClass: [{\n type: Input,\n args: ['cdkConnectedOverlayPanelClass']\n }], viewportMargin: [{\n type: Input,\n args: ['cdkConnectedOverlayViewportMargin']\n }], scrollStrategy: [{\n type: Input,\n args: ['cdkConnectedOverlayScrollStrategy']\n }], open: [{\n type: Input,\n args: ['cdkConnectedOverlayOpen']\n }], disableClose: [{\n type: Input,\n args: ['cdkConnectedOverlayDisableClose']\n }], transformOriginSelector: [{\n type: Input,\n args: ['cdkConnectedOverlayTransformOriginOn']\n }], hasBackdrop: [{\n type: Input,\n args: [{ alias: 'cdkConnectedOverlayHasBackdrop', transform: booleanAttribute }]\n }], lockPosition: [{\n type: Input,\n args: [{ alias: 'cdkConnectedOverlayLockPosition', transform: booleanAttribute }]\n }], flexibleDimensions: [{\n type: Input,\n args: [{ alias: 'cdkConnectedOverlayFlexibleDimensions', transform: booleanAttribute }]\n }], growAfterOpen: [{\n type: Input,\n args: [{ alias: 'cdkConnectedOverlayGrowAfterOpen', transform: booleanAttribute }]\n }], push: [{\n type: Input,\n args: [{ alias: 'cdkConnectedOverlayPush', transform: booleanAttribute }]\n }], disposeOnNavigation: [{\n type: Input,\n args: [{ alias: 'cdkConnectedOverlayDisposeOnNavigation', transform: booleanAttribute }]\n }], backdropClick: [{\n type: Output\n }], positionChange: [{\n type: Output\n }], attach: [{\n type: Output\n }], detach: [{\n type: Output\n }], overlayKeydown: [{\n type: Output\n }], overlayOutsideClick: [{\n type: Output\n }] } });\n/** @docs-private */\nfunction CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {\n return () => overlay.scrollStrategies.reposition();\n}\n/** @docs-private */\nconst CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = {\n provide: CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY,\n deps: [Overlay],\n useFactory: CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY,\n};\n\nclass OverlayModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayModule, imports: [BidiModule, PortalModule, ScrollingModule, CdkConnectedOverlay, CdkOverlayOrigin], exports: [CdkConnectedOverlay, CdkOverlayOrigin, ScrollingModule] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayModule, providers: [Overlay, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER], imports: [BidiModule, PortalModule, ScrollingModule, ScrollingModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: OverlayModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [BidiModule, PortalModule, ScrollingModule, CdkConnectedOverlay, CdkOverlayOrigin],\n exports: [CdkConnectedOverlay, CdkOverlayOrigin, ScrollingModule],\n providers: [Overlay, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER],\n }]\n }] });\n\n/**\n * Alternative to OverlayContainer that supports correct displaying of overlay elements in\n * Fullscreen mode\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen\n *\n * Should be provided in the root component.\n */\nclass FullscreenOverlayContainer extends OverlayContainer {\n _renderer = inject(RendererFactory2).createRenderer(null, null);\n _fullScreenEventName;\n _cleanupFullScreenListener;\n constructor() {\n super();\n }\n ngOnDestroy() {\n super.ngOnDestroy();\n this._cleanupFullScreenListener?.();\n }\n _createContainer() {\n const eventName = this._getEventName();\n super._createContainer();\n this._adjustParentForFullscreenChange();\n if (eventName) {\n this._cleanupFullScreenListener?.();\n this._cleanupFullScreenListener = this._renderer.listen('document', eventName, () => {\n this._adjustParentForFullscreenChange();\n });\n }\n }\n _adjustParentForFullscreenChange() {\n if (this._containerElement) {\n const fullscreenElement = this.getFullscreenElement();\n const parent = fullscreenElement || this._document.body;\n parent.appendChild(this._containerElement);\n }\n }\n _getEventName() {\n if (!this._fullScreenEventName) {\n const _document = this._document;\n if (_document.fullscreenEnabled) {\n this._fullScreenEventName = 'fullscreenchange';\n }\n else if (_document.webkitFullscreenEnabled) {\n this._fullScreenEventName = 'webkitfullscreenchange';\n }\n else if (_document.mozFullScreenEnabled) {\n this._fullScreenEventName = 'mozfullscreenchange';\n }\n else if (_document.msFullscreenEnabled) {\n this._fullScreenEventName = 'MSFullscreenChange';\n }\n }\n return this._fullScreenEventName;\n }\n /**\n * When the page is put into fullscreen mode, a specific element is specified.\n * Only that element and its children are visible when in fullscreen mode.\n */\n getFullscreenElement() {\n const _document = this._document;\n return (_document.fullscreenElement ||\n _document.webkitFullscreenElement ||\n _document.mozFullScreenElement ||\n _document.msFullscreenElement ||\n null);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FullscreenOverlayContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FullscreenOverlayContainer, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: FullscreenOverlayContainer, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { BlockScrollStrategy, CdkConnectedOverlay, CdkOverlayOrigin, CloseScrollStrategy, ConnectedOverlayPositionChange, ConnectionPositionPair, FlexibleConnectedPositionStrategy, FullscreenOverlayContainer, GlobalPositionStrategy, NoopScrollStrategy, Overlay, OverlayConfig, OverlayContainer, OverlayKeyboardDispatcher, OverlayModule, OverlayOutsideClickDispatcher, OverlayPositionBuilder, OverlayRef, RepositionScrollStrategy, STANDARD_DROPDOWN_ADJACENT_POSITIONS, STANDARD_DROPDOWN_BELOW_POSITIONS, ScrollStrategyOptions, ScrollingVisibility, validateHorizontalPosition, validateVerticalPosition };\n","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function takeWhile(predicate, inclusive = false) {\n return operate((source, subscriber) => {\n let index = 0;\n source.subscribe(createOperatorSubscriber(subscriber, (value) => {\n const result = predicate(value, index++);\n (result || inclusive) && subscriber.next(value);\n !result && subscriber.complete();\n }));\n });\n}\n","import * as i0 from '@angular/core';\nimport { inject, PLATFORM_ID, Injectable, NgModule } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\n\n// Whether the current platform supports the V8 Break Iterator. The V8 check\n// is necessary to detect all Blink based browsers.\nlet hasV8BreakIterator;\n// We need a try/catch around the reference to `Intl`, because accessing it in some cases can\n// cause IE to throw. These cases are tied to particular versions of Windows and can happen if\n// the consumer is providing a polyfilled `Map`. See:\n// https://github.com/Microsoft/ChakraCore/issues/3189\n// https://github.com/angular/components/issues/15687\ntry {\n hasV8BreakIterator = typeof Intl !== 'undefined' && Intl.v8BreakIterator;\n}\ncatch {\n hasV8BreakIterator = false;\n}\n/**\n * Service to detect the current platform by comparing the userAgent strings and\n * checking browser-specific global properties.\n */\nclass Platform {\n _platformId = inject(PLATFORM_ID);\n // We want to use the Angular platform check because if the Document is shimmed\n // without the navigator, the following checks will fail. This is preferred because\n // sometimes the Document may be shimmed without the user's knowledge or intention\n /** Whether the Angular application is being rendered in the browser. */\n isBrowser = this._platformId\n ? isPlatformBrowser(this._platformId)\n : typeof document === 'object' && !!document;\n /** Whether the current browser is Microsoft Edge. */\n EDGE = this.isBrowser && /(edge)/i.test(navigator.userAgent);\n /** Whether the current rendering engine is Microsoft Trident. */\n TRIDENT = this.isBrowser && /(msie|trident)/i.test(navigator.userAgent);\n // EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.\n /** Whether the current rendering engine is Blink. */\n BLINK = this.isBrowser &&\n !!(window.chrome || hasV8BreakIterator) &&\n typeof CSS !== 'undefined' &&\n !this.EDGE &&\n !this.TRIDENT;\n // Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to\n // ensure that Webkit runs standalone and is not used as another engine's base.\n /** Whether the current rendering engine is WebKit. */\n WEBKIT = this.isBrowser &&\n /AppleWebKit/i.test(navigator.userAgent) &&\n !this.BLINK &&\n !this.EDGE &&\n !this.TRIDENT;\n /** Whether the current platform is Apple iOS. */\n IOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);\n // It's difficult to detect the plain Gecko engine, because most of the browsers identify\n // them self as Gecko-like browsers and modify the userAgent's according to that.\n // Since we only cover one explicit Firefox case, we can simply check for Firefox\n // instead of having an unstable check for Gecko.\n /** Whether the current browser is Firefox. */\n FIREFOX = this.isBrowser && /(firefox|minefield)/i.test(navigator.userAgent);\n /** Whether the current platform is Android. */\n // Trident on mobile adds the android platform to the userAgent to trick detections.\n ANDROID = this.isBrowser && /android/i.test(navigator.userAgent) && !this.TRIDENT;\n // Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake\n // this and just place the Safari keyword in the userAgent. To be more safe about Safari every\n // Safari browser should also use Webkit as its layout engine.\n /** Whether the current browser is Safari. */\n SAFARI = this.isBrowser && /safari/i.test(navigator.userAgent) && this.WEBKIT;\n constructor() { }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Platform, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Platform, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: Platform, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\nclass PlatformModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PlatformModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: PlatformModule });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PlatformModule });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PlatformModule, decorators: [{\n type: NgModule,\n args: [{}]\n }] });\n\n/** Cached result Set of input types support by the current browser. */\nlet supportedInputTypes;\n/** Types of `` that *might* be supported. */\nconst candidateInputTypes = [\n // `color` must come first. Chrome 56 shows a warning if we change the type to `color` after\n // first changing it to something else:\n // The specified value \"\" does not conform to the required format.\n // The format is \"#rrggbb\" where rr, gg, bb are two-digit hexadecimal numbers.\n 'color',\n 'button',\n 'checkbox',\n 'date',\n 'datetime-local',\n 'email',\n 'file',\n 'hidden',\n 'image',\n 'month',\n 'number',\n 'password',\n 'radio',\n 'range',\n 'reset',\n 'search',\n 'submit',\n 'tel',\n 'text',\n 'time',\n 'url',\n 'week',\n];\n/** @returns The input types supported by this browser. */\nfunction getSupportedInputTypes() {\n // Result is cached.\n if (supportedInputTypes) {\n return supportedInputTypes;\n }\n // We can't check if an input type is not supported until we're on the browser, so say that\n // everything is supported when not on the browser. We don't use `Platform` here since it's\n // just a helper function and can't inject it.\n if (typeof document !== 'object' || !document) {\n supportedInputTypes = new Set(candidateInputTypes);\n return supportedInputTypes;\n }\n let featureTestInput = document.createElement('input');\n supportedInputTypes = new Set(candidateInputTypes.filter(value => {\n featureTestInput.setAttribute('type', value);\n return featureTestInput.type === value;\n }));\n return supportedInputTypes;\n}\n\n/** Cached result of whether the user's browser supports passive event listeners. */\nlet supportsPassiveEvents;\n/**\n * Checks whether the user's browser supports passive event listeners.\n * See: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n */\nfunction supportsPassiveEventListeners() {\n if (supportsPassiveEvents == null && typeof window !== 'undefined') {\n try {\n window.addEventListener('test', null, Object.defineProperty({}, 'passive', {\n get: () => (supportsPassiveEvents = true),\n }));\n }\n finally {\n supportsPassiveEvents = supportsPassiveEvents || false;\n }\n }\n return supportsPassiveEvents;\n}\n/**\n * Normalizes an `AddEventListener` object to something that can be passed\n * to `addEventListener` on any browser, no matter whether it supports the\n * `options` parameter.\n * @param options Object to be normalized.\n */\nfunction normalizePassiveListenerOptions(options) {\n return supportsPassiveEventListeners() ? options : !!options.capture;\n}\n\n/** The possible ways the browser may handle the horizontal scroll axis in RTL languages. */\nvar RtlScrollAxisType;\n(function (RtlScrollAxisType) {\n /**\n * scrollLeft is 0 when scrolled all the way left and (scrollWidth - clientWidth) when scrolled\n * all the way right.\n */\n RtlScrollAxisType[RtlScrollAxisType[\"NORMAL\"] = 0] = \"NORMAL\";\n /**\n * scrollLeft is -(scrollWidth - clientWidth) when scrolled all the way left and 0 when scrolled\n * all the way right.\n */\n RtlScrollAxisType[RtlScrollAxisType[\"NEGATED\"] = 1] = \"NEGATED\";\n /**\n * scrollLeft is (scrollWidth - clientWidth) when scrolled all the way left and 0 when scrolled\n * all the way right.\n */\n RtlScrollAxisType[RtlScrollAxisType[\"INVERTED\"] = 2] = \"INVERTED\";\n})(RtlScrollAxisType || (RtlScrollAxisType = {}));\n/** Cached result of the way the browser handles the horizontal scroll axis in RTL mode. */\nlet rtlScrollAxisType;\n/** Cached result of the check that indicates whether the browser supports scroll behaviors. */\nlet scrollBehaviorSupported;\n/** Check whether the browser supports scroll behaviors. */\nfunction supportsScrollBehavior() {\n if (scrollBehaviorSupported == null) {\n // If we're not in the browser, it can't be supported. Also check for `Element`, because\n // some projects stub out the global `document` during SSR which can throw us off.\n if (typeof document !== 'object' || !document || typeof Element !== 'function' || !Element) {\n scrollBehaviorSupported = false;\n return scrollBehaviorSupported;\n }\n // If the element can have a `scrollBehavior` style, we can be sure that it's supported.\n if ('scrollBehavior' in document.documentElement.style) {\n scrollBehaviorSupported = true;\n }\n else {\n // At this point we have 3 possibilities: `scrollTo` isn't supported at all, it's\n // supported but it doesn't handle scroll behavior, or it has been polyfilled.\n const scrollToFunction = Element.prototype.scrollTo;\n if (scrollToFunction) {\n // We can detect if the function has been polyfilled by calling `toString` on it. Native\n // functions are obfuscated using `[native code]`, whereas if it was overwritten we'd get\n // the actual function source. Via https://davidwalsh.name/detect-native-function. Consider\n // polyfilled functions as supporting scroll behavior.\n scrollBehaviorSupported = !/\\{\\s*\\[native code\\]\\s*\\}/.test(scrollToFunction.toString());\n }\n else {\n scrollBehaviorSupported = false;\n }\n }\n }\n return scrollBehaviorSupported;\n}\n/**\n * Checks the type of RTL scroll axis used by this browser. As of time of writing, Chrome is NORMAL,\n * Firefox & Safari are NEGATED, and IE & Edge are INVERTED.\n */\nfunction getRtlScrollAxisType() {\n // We can't check unless we're on the browser. Just assume 'normal' if we're not.\n if (typeof document !== 'object' || !document) {\n return RtlScrollAxisType.NORMAL;\n }\n if (rtlScrollAxisType == null) {\n // Create a 1px wide scrolling container and a 2px wide content element.\n const scrollContainer = document.createElement('div');\n const containerStyle = scrollContainer.style;\n scrollContainer.dir = 'rtl';\n containerStyle.width = '1px';\n containerStyle.overflow = 'auto';\n containerStyle.visibility = 'hidden';\n containerStyle.pointerEvents = 'none';\n containerStyle.position = 'absolute';\n const content = document.createElement('div');\n const contentStyle = content.style;\n contentStyle.width = '2px';\n contentStyle.height = '1px';\n scrollContainer.appendChild(content);\n document.body.appendChild(scrollContainer);\n rtlScrollAxisType = RtlScrollAxisType.NORMAL;\n // The viewport starts scrolled all the way to the right in RTL mode. If we are in a NORMAL\n // browser this would mean that the scrollLeft should be 1. If it's zero instead we know we're\n // dealing with one of the other two types of browsers.\n if (scrollContainer.scrollLeft === 0) {\n // In a NEGATED browser the scrollLeft is always somewhere in [-maxScrollAmount, 0]. For an\n // INVERTED browser it is always somewhere in [0, maxScrollAmount]. We can determine which by\n // setting to the scrollLeft to 1. This is past the max for a NEGATED browser, so it will\n // return 0 when we read it again.\n scrollContainer.scrollLeft = 1;\n rtlScrollAxisType =\n scrollContainer.scrollLeft === 0 ? RtlScrollAxisType.NEGATED : RtlScrollAxisType.INVERTED;\n }\n scrollContainer.remove();\n }\n return rtlScrollAxisType;\n}\n\nlet shadowDomIsSupported;\n/** Checks whether the user's browser support Shadow DOM. */\nfunction _supportsShadowDom() {\n if (shadowDomIsSupported == null) {\n const head = typeof document !== 'undefined' ? document.head : null;\n shadowDomIsSupported = !!(head && (head.createShadowRoot || head.attachShadow));\n }\n return shadowDomIsSupported;\n}\n/** Gets the shadow root of an element, if supported and the element is inside the Shadow DOM. */\nfunction _getShadowRoot(element) {\n if (_supportsShadowDom()) {\n const rootNode = element.getRootNode ? element.getRootNode() : null;\n // Note that this should be caught by `_supportsShadowDom`, but some\n // teams have been able to hit this code path on unsupported browsers.\n if (typeof ShadowRoot !== 'undefined' && ShadowRoot && rootNode instanceof ShadowRoot) {\n return rootNode;\n }\n }\n return null;\n}\n/**\n * Gets the currently-focused element on the page while\n * also piercing through Shadow DOM boundaries.\n */\nfunction _getFocusedElementPierceShadowDom() {\n let activeElement = typeof document !== 'undefined' && document\n ? document.activeElement\n : null;\n while (activeElement && activeElement.shadowRoot) {\n const newActiveElement = activeElement.shadowRoot.activeElement;\n if (newActiveElement === activeElement) {\n break;\n }\n else {\n activeElement = newActiveElement;\n }\n }\n return activeElement;\n}\n/** Gets the target of an event while accounting for Shadow DOM. */\nfunction _getEventTarget(event) {\n // If an event is bound outside the Shadow DOM, the `event.target` will\n // point to the shadow root so we have to use `composedPath` instead.\n return (event.composedPath ? event.composedPath()[0] : event.target);\n}\n\n/** Gets whether the code is currently running in a test environment. */\nfunction _isTestEnvironment() {\n // We can't use `declare const` because it causes conflicts inside Google with the real typings\n // for these symbols and we can't read them off the global object, because they don't appear to\n // be attached there for some runners like Jest.\n // (see: https://github.com/angular/components/issues/23365#issuecomment-938146643)\n return (\n // @ts-ignore\n (typeof __karma__ !== 'undefined' && !!__karma__) ||\n // @ts-ignore\n (typeof jasmine !== 'undefined' && !!jasmine) ||\n // @ts-ignore\n (typeof jest !== 'undefined' && !!jest) ||\n // @ts-ignore\n (typeof Mocha !== 'undefined' && !!Mocha));\n}\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { Platform, PlatformModule, RtlScrollAxisType, _getEventTarget, _getFocusedElementPierceShadowDom, _getShadowRoot, _isTestEnvironment, _supportsShadowDom, getRtlScrollAxisType, getSupportedInputTypes, normalizePassiveListenerOptions, supportsPassiveEventListeners, supportsScrollBehavior };\n","import * as i0 from '@angular/core';\nimport { ElementRef, NgModuleRef, createComponent, Injector, inject, TemplateRef, ViewContainerRef, Directive, EventEmitter, Input, Output, NgModule } from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\n/**\n * Throws an exception when attempting to attach a null portal to a host.\n * @docs-private\n */\nfunction throwNullPortalError() {\n throw Error('Must provide a portal to attach');\n}\n/**\n * Throws an exception when attempting to attach a portal to a host that is already attached.\n * @docs-private\n */\nfunction throwPortalAlreadyAttachedError() {\n throw Error('Host already has a portal attached');\n}\n/**\n * Throws an exception when attempting to attach a portal to an already-disposed host.\n * @docs-private\n */\nfunction throwPortalOutletAlreadyDisposedError() {\n throw Error('This PortalOutlet has already been disposed');\n}\n/**\n * Throws an exception when attempting to attach an unknown portal type.\n * @docs-private\n */\nfunction throwUnknownPortalTypeError() {\n throw Error('Attempting to attach an unknown Portal type. BasePortalOutlet accepts either ' +\n 'a ComponentPortal or a TemplatePortal.');\n}\n/**\n * Throws an exception when attempting to attach a portal to a null host.\n * @docs-private\n */\nfunction throwNullPortalOutletError() {\n throw Error('Attempting to attach a portal to a null PortalOutlet');\n}\n/**\n * Throws an exception when attempting to detach a portal that is not attached.\n * @docs-private\n */\nfunction throwNoPortalAttachedError() {\n throw Error('Attempting to detach a portal that is not attached to a host');\n}\n\n/**\n * A `Portal` is something that you want to render somewhere else.\n * It can be attach to / detached from a `PortalOutlet`.\n */\nclass Portal {\n _attachedHost;\n /** Attach this portal to a host. */\n attach(host) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (host == null) {\n throwNullPortalOutletError();\n }\n if (host.hasAttached()) {\n throwPortalAlreadyAttachedError();\n }\n }\n this._attachedHost = host;\n return host.attach(this);\n }\n /** Detach this portal from its host */\n detach() {\n let host = this._attachedHost;\n if (host != null) {\n this._attachedHost = null;\n host.detach();\n }\n else if (typeof ngDevMode === 'undefined' || ngDevMode) {\n throwNoPortalAttachedError();\n }\n }\n /** Whether this portal is attached to a host. */\n get isAttached() {\n return this._attachedHost != null;\n }\n /**\n * Sets the PortalOutlet reference without performing `attach()`. This is used directly by\n * the PortalOutlet when it is performing an `attach()` or `detach()`.\n */\n setAttachedHost(host) {\n this._attachedHost = host;\n }\n}\n/**\n * A `ComponentPortal` is a portal that instantiates some Component upon attachment.\n */\nclass ComponentPortal extends Portal {\n /** The type of the component that will be instantiated for attachment. */\n component;\n /**\n * Where the attached component should live in Angular's *logical* component tree.\n * This is different from where the component *renders*, which is determined by the PortalOutlet.\n * The origin is necessary when the host is outside of the Angular application context.\n */\n viewContainerRef;\n /** Injector used for the instantiation of the component. */\n injector;\n /**\n * @deprecated No longer in use. To be removed.\n * @breaking-change 18.0.0\n */\n componentFactoryResolver;\n /**\n * List of DOM nodes that should be projected through `` of the attached component.\n */\n projectableNodes;\n constructor(component, viewContainerRef, injector, \n /**\n * @deprecated No longer in use. To be removed.\n * @breaking-change 18.0.0\n */\n _componentFactoryResolver, projectableNodes) {\n super();\n this.component = component;\n this.viewContainerRef = viewContainerRef;\n this.injector = injector;\n this.projectableNodes = projectableNodes;\n }\n}\n/**\n * A `TemplatePortal` is a portal that represents some embedded template (TemplateRef).\n */\nclass TemplatePortal extends Portal {\n templateRef;\n viewContainerRef;\n context;\n injector;\n constructor(\n /** The embedded template that will be used to instantiate an embedded View in the host. */\n templateRef, \n /** Reference to the ViewContainer into which the template will be stamped out. */\n viewContainerRef, \n /** Contextual data to be passed in to the embedded view. */\n context, \n /** The injector to use for the embedded view. */\n injector) {\n super();\n this.templateRef = templateRef;\n this.viewContainerRef = viewContainerRef;\n this.context = context;\n this.injector = injector;\n }\n get origin() {\n return this.templateRef.elementRef;\n }\n /**\n * Attach the portal to the provided `PortalOutlet`.\n * When a context is provided it will override the `context` property of the `TemplatePortal`\n * instance.\n */\n attach(host, context = this.context) {\n this.context = context;\n return super.attach(host);\n }\n detach() {\n this.context = undefined;\n return super.detach();\n }\n}\n/**\n * A `DomPortal` is a portal whose DOM element will be taken from its current position\n * in the DOM and moved into a portal outlet, when it is attached. On detach, the content\n * will be restored to its original position.\n */\nclass DomPortal extends Portal {\n /** DOM node hosting the portal's content. */\n element;\n constructor(element) {\n super();\n this.element = element instanceof ElementRef ? element.nativeElement : element;\n }\n}\n/**\n * Partial implementation of PortalOutlet that handles attaching\n * ComponentPortal and TemplatePortal.\n */\nclass BasePortalOutlet {\n /** The portal currently attached to the host. */\n _attachedPortal;\n /** A function that will permanently dispose this host. */\n _disposeFn;\n /** Whether this host has already been permanently disposed. */\n _isDisposed = false;\n /** Whether this host has an attached portal. */\n hasAttached() {\n return !!this._attachedPortal;\n }\n /** Attaches a portal. */\n attach(portal) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (!portal) {\n throwNullPortalError();\n }\n if (this.hasAttached()) {\n throwPortalAlreadyAttachedError();\n }\n if (this._isDisposed) {\n throwPortalOutletAlreadyDisposedError();\n }\n }\n if (portal instanceof ComponentPortal) {\n this._attachedPortal = portal;\n return this.attachComponentPortal(portal);\n }\n else if (portal instanceof TemplatePortal) {\n this._attachedPortal = portal;\n return this.attachTemplatePortal(portal);\n // @breaking-change 10.0.0 remove null check for `this.attachDomPortal`.\n }\n else if (this.attachDomPortal && portal instanceof DomPortal) {\n this._attachedPortal = portal;\n return this.attachDomPortal(portal);\n }\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n throwUnknownPortalTypeError();\n }\n }\n // @breaking-change 10.0.0 `attachDomPortal` to become a required abstract method.\n attachDomPortal = null;\n /** Detaches a previously attached portal. */\n detach() {\n if (this._attachedPortal) {\n this._attachedPortal.setAttachedHost(null);\n this._attachedPortal = null;\n }\n this._invokeDisposeFn();\n }\n /** Permanently dispose of this portal host. */\n dispose() {\n if (this.hasAttached()) {\n this.detach();\n }\n this._invokeDisposeFn();\n this._isDisposed = true;\n }\n /** @docs-private */\n setDisposeFn(fn) {\n this._disposeFn = fn;\n }\n _invokeDisposeFn() {\n if (this._disposeFn) {\n this._disposeFn();\n this._disposeFn = null;\n }\n }\n}\n/**\n * @deprecated Use `BasePortalOutlet` instead.\n * @breaking-change 9.0.0\n */\nclass BasePortalHost extends BasePortalOutlet {\n}\n\n/**\n * A PortalOutlet for attaching portals to an arbitrary DOM element outside of the Angular\n * application context.\n */\nclass DomPortalOutlet extends BasePortalOutlet {\n outletElement;\n _appRef;\n _defaultInjector;\n _document;\n /**\n * @param outletElement Element into which the content is projected.\n * @param _unusedComponentFactoryResolver Used to resolve the component factory.\n * Only required when attaching component portals.\n * @param _appRef Reference to the application. Only used in component portals when there\n * is no `ViewContainerRef` available.\n * @param _defaultInjector Injector to use as a fallback when the portal being attached doesn't\n * have one. Only used for component portals.\n * @param _document Reference to the document. Used when attaching a DOM portal. Will eventually\n * become a required parameter.\n */\n constructor(\n /** Element into which the content is projected. */\n outletElement, \n /**\n * @deprecated No longer in use. To be removed.\n * @breaking-change 18.0.0\n */\n _unusedComponentFactoryResolver, _appRef, _defaultInjector, \n /**\n * @deprecated `_document` Parameter to be made required.\n * @breaking-change 10.0.0\n */\n _document) {\n super();\n this.outletElement = outletElement;\n this._appRef = _appRef;\n this._defaultInjector = _defaultInjector;\n this._document = _document;\n }\n /**\n * Attach the given ComponentPortal to DOM element.\n * @param portal Portal to be attached\n * @returns Reference to the created component.\n */\n attachComponentPortal(portal) {\n let componentRef;\n // If the portal specifies a ViewContainerRef, we will use that as the attachment point\n // for the component (in terms of Angular's component tree, not rendering).\n // When the ViewContainerRef is missing, we use the factory to create the component directly\n // and then manually attach the view to the application.\n if (portal.viewContainerRef) {\n const injector = portal.injector || portal.viewContainerRef.injector;\n const ngModuleRef = injector.get(NgModuleRef, null, { optional: true }) || undefined;\n componentRef = portal.viewContainerRef.createComponent(portal.component, {\n index: portal.viewContainerRef.length,\n injector,\n ngModuleRef,\n projectableNodes: portal.projectableNodes || undefined,\n });\n this.setDisposeFn(() => componentRef.destroy());\n }\n else {\n if ((typeof ngDevMode === 'undefined' || ngDevMode) && !this._appRef) {\n throw Error('Cannot attach component portal to outlet without an ApplicationRef.');\n }\n componentRef = createComponent(portal.component, {\n elementInjector: portal.injector || this._defaultInjector || Injector.NULL,\n environmentInjector: this._appRef.injector,\n projectableNodes: portal.projectableNodes || undefined,\n });\n this._appRef.attachView(componentRef.hostView);\n this.setDisposeFn(() => {\n // Verify that the ApplicationRef has registered views before trying to detach a host view.\n // This check also protects the `detachView` from being called on a destroyed ApplicationRef.\n if (this._appRef.viewCount > 0) {\n this._appRef.detachView(componentRef.hostView);\n }\n componentRef.destroy();\n });\n }\n // At this point the component has been instantiated, so we move it to the location in the DOM\n // where we want it to be rendered.\n this.outletElement.appendChild(this._getComponentRootNode(componentRef));\n this._attachedPortal = portal;\n return componentRef;\n }\n /**\n * Attaches a template portal to the DOM as an embedded view.\n * @param portal Portal to be attached.\n * @returns Reference to the created embedded view.\n */\n attachTemplatePortal(portal) {\n let viewContainer = portal.viewContainerRef;\n let viewRef = viewContainer.createEmbeddedView(portal.templateRef, portal.context, {\n injector: portal.injector,\n });\n // The method `createEmbeddedView` will add the view as a child of the viewContainer.\n // But for the DomPortalOutlet the view can be added everywhere in the DOM\n // (e.g Overlay Container) To move the view to the specified host element. We just\n // re-append the existing root nodes.\n viewRef.rootNodes.forEach(rootNode => this.outletElement.appendChild(rootNode));\n // Note that we want to detect changes after the nodes have been moved so that\n // any directives inside the portal that are looking at the DOM inside a lifecycle\n // hook won't be invoked too early.\n viewRef.detectChanges();\n this.setDisposeFn(() => {\n let index = viewContainer.indexOf(viewRef);\n if (index !== -1) {\n viewContainer.remove(index);\n }\n });\n this._attachedPortal = portal;\n // TODO(jelbourn): Return locals from view.\n return viewRef;\n }\n /**\n * Attaches a DOM portal by transferring its content into the outlet.\n * @param portal Portal to be attached.\n * @deprecated To be turned into a method.\n * @breaking-change 10.0.0\n */\n attachDomPortal = (portal) => {\n const element = portal.element;\n if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error('DOM portal content must be attached to a parent node.');\n }\n // Anchor used to save the element's previous position so\n // that we can restore it when the portal is detached.\n const anchorNode = this._document.createComment('dom-portal');\n element.parentNode.insertBefore(anchorNode, element);\n this.outletElement.appendChild(element);\n this._attachedPortal = portal;\n super.setDisposeFn(() => {\n // We can't use `replaceWith` here because IE doesn't support it.\n if (anchorNode.parentNode) {\n anchorNode.parentNode.replaceChild(element, anchorNode);\n }\n });\n };\n /**\n * Clears out a portal from the DOM.\n */\n dispose() {\n super.dispose();\n this.outletElement.remove();\n }\n /** Gets the root HTMLElement for an instantiated component. */\n _getComponentRootNode(componentRef) {\n return componentRef.hostView.rootNodes[0];\n }\n}\n/**\n * @deprecated Use `DomPortalOutlet` instead.\n * @breaking-change 9.0.0\n */\nclass DomPortalHost extends DomPortalOutlet {\n}\n\n/**\n * Directive version of a `TemplatePortal`. Because the directive *is* a TemplatePortal,\n * the directive instance itself can be attached to a host, enabling declarative use of portals.\n */\nclass CdkPortal extends TemplatePortal {\n constructor() {\n const templateRef = inject(TemplateRef);\n const viewContainerRef = inject(ViewContainerRef);\n super(templateRef, viewContainerRef);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkPortal, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkPortal, isStandalone: true, selector: \"[cdkPortal]\", exportAs: [\"cdkPortal\"], usesInheritance: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkPortal, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkPortal]',\n exportAs: 'cdkPortal',\n }]\n }], ctorParameters: () => [] });\n/**\n * @deprecated Use `CdkPortal` instead.\n * @breaking-change 9.0.0\n */\nclass TemplatePortalDirective extends CdkPortal {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: TemplatePortalDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: TemplatePortalDirective, isStandalone: true, selector: \"[cdk-portal], [portal]\", providers: [\n {\n provide: CdkPortal,\n useExisting: TemplatePortalDirective,\n },\n ], exportAs: [\"cdkPortal\"], usesInheritance: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: TemplatePortalDirective, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdk-portal], [portal]',\n exportAs: 'cdkPortal',\n providers: [\n {\n provide: CdkPortal,\n useExisting: TemplatePortalDirective,\n },\n ],\n }]\n }] });\n/**\n * Directive version of a PortalOutlet. Because the directive *is* a PortalOutlet, portals can be\n * directly attached to it, enabling declarative use.\n *\n * Usage:\n * ``\n */\nclass CdkPortalOutlet extends BasePortalOutlet {\n _moduleRef = inject(NgModuleRef, { optional: true });\n _document = inject(DOCUMENT);\n _viewContainerRef = inject(ViewContainerRef);\n /** Whether the portal component is initialized. */\n _isInitialized = false;\n /** Reference to the currently-attached component/view ref. */\n _attachedRef;\n constructor() {\n super();\n }\n /** Portal associated with the Portal outlet. */\n get portal() {\n return this._attachedPortal;\n }\n set portal(portal) {\n // Ignore the cases where the `portal` is set to a falsy value before the lifecycle hooks have\n // run. This handles the cases where the user might do something like `
    `\n // and attach a portal programmatically in the parent component. When Angular does the first CD\n // round, it will fire the setter with empty string, causing the user's content to be cleared.\n if (this.hasAttached() && !portal && !this._isInitialized) {\n return;\n }\n if (this.hasAttached()) {\n super.detach();\n }\n if (portal) {\n super.attach(portal);\n }\n this._attachedPortal = portal || null;\n }\n /** Emits when a portal is attached to the outlet. */\n attached = new EventEmitter();\n /** Component or view reference that is attached to the portal. */\n get attachedRef() {\n return this._attachedRef;\n }\n ngOnInit() {\n this._isInitialized = true;\n }\n ngOnDestroy() {\n super.dispose();\n this._attachedRef = this._attachedPortal = null;\n }\n /**\n * Attach the given ComponentPortal to this PortalOutlet.\n *\n * @param portal Portal to be attached to the portal outlet.\n * @returns Reference to the created component.\n */\n attachComponentPortal(portal) {\n portal.setAttachedHost(this);\n // If the portal specifies an origin, use that as the logical location of the component\n // in the application tree. Otherwise use the location of this PortalOutlet.\n const viewContainerRef = portal.viewContainerRef != null ? portal.viewContainerRef : this._viewContainerRef;\n const ref = viewContainerRef.createComponent(portal.component, {\n index: viewContainerRef.length,\n injector: portal.injector || viewContainerRef.injector,\n projectableNodes: portal.projectableNodes || undefined,\n ngModuleRef: this._moduleRef || undefined,\n });\n // If we're using a view container that's different from the injected one (e.g. when the portal\n // specifies its own) we need to move the component into the outlet, otherwise it'll be rendered\n // inside of the alternate view container.\n if (viewContainerRef !== this._viewContainerRef) {\n this._getRootNode().appendChild(ref.hostView.rootNodes[0]);\n }\n super.setDisposeFn(() => ref.destroy());\n this._attachedPortal = portal;\n this._attachedRef = ref;\n this.attached.emit(ref);\n return ref;\n }\n /**\n * Attach the given TemplatePortal to this PortalHost as an embedded View.\n * @param portal Portal to be attached.\n * @returns Reference to the created embedded view.\n */\n attachTemplatePortal(portal) {\n portal.setAttachedHost(this);\n const viewRef = this._viewContainerRef.createEmbeddedView(portal.templateRef, portal.context, {\n injector: portal.injector,\n });\n super.setDisposeFn(() => this._viewContainerRef.clear());\n this._attachedPortal = portal;\n this._attachedRef = viewRef;\n this.attached.emit(viewRef);\n return viewRef;\n }\n /**\n * Attaches the given DomPortal to this PortalHost by moving all of the portal content into it.\n * @param portal Portal to be attached.\n * @deprecated To be turned into a method.\n * @breaking-change 10.0.0\n */\n attachDomPortal = (portal) => {\n const element = portal.element;\n if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error('DOM portal content must be attached to a parent node.');\n }\n // Anchor used to save the element's previous position so\n // that we can restore it when the portal is detached.\n const anchorNode = this._document.createComment('dom-portal');\n portal.setAttachedHost(this);\n element.parentNode.insertBefore(anchorNode, element);\n this._getRootNode().appendChild(element);\n this._attachedPortal = portal;\n super.setDisposeFn(() => {\n if (anchorNode.parentNode) {\n anchorNode.parentNode.replaceChild(element, anchorNode);\n }\n });\n };\n /** Gets the root node of the portal outlet. */\n _getRootNode() {\n const nativeElement = this._viewContainerRef.element.nativeElement;\n // The directive could be set on a template which will result in a comment\n // node being the root. Use the comment's parent node if that is the case.\n return (nativeElement.nodeType === nativeElement.ELEMENT_NODE\n ? nativeElement\n : nativeElement.parentNode);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkPortalOutlet, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkPortalOutlet, isStandalone: true, selector: \"[cdkPortalOutlet]\", inputs: { portal: [\"cdkPortalOutlet\", \"portal\"] }, outputs: { attached: \"attached\" }, exportAs: [\"cdkPortalOutlet\"], usesInheritance: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkPortalOutlet, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkPortalOutlet]',\n exportAs: 'cdkPortalOutlet',\n }]\n }], ctorParameters: () => [], propDecorators: { portal: [{\n type: Input,\n args: ['cdkPortalOutlet']\n }], attached: [{\n type: Output\n }] } });\n/**\n * @deprecated Use `CdkPortalOutlet` instead.\n * @breaking-change 9.0.0\n */\nclass PortalHostDirective extends CdkPortalOutlet {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PortalHostDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: PortalHostDirective, isStandalone: true, selector: \"[cdkPortalHost], [portalHost]\", inputs: { portal: [\"cdkPortalHost\", \"portal\"] }, providers: [\n {\n provide: CdkPortalOutlet,\n useExisting: PortalHostDirective,\n },\n ], exportAs: [\"cdkPortalHost\"], usesInheritance: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PortalHostDirective, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkPortalHost], [portalHost]',\n exportAs: 'cdkPortalHost',\n inputs: [{ name: 'portal', alias: 'cdkPortalHost' }],\n providers: [\n {\n provide: CdkPortalOutlet,\n useExisting: PortalHostDirective,\n },\n ],\n }]\n }] });\nclass PortalModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PortalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: PortalModule, imports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective], exports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PortalModule });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: PortalModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],\n exports: [CdkPortal, CdkPortalOutlet, TemplatePortalDirective, PortalHostDirective],\n }]\n }] });\n\n/**\n * Custom injector to be used when providing custom\n * injection tokens to components inside a portal.\n * @docs-private\n * @deprecated Use `Injector.create` instead.\n * @breaking-change 11.0.0\n */\nclass PortalInjector {\n _parentInjector;\n _customTokens;\n constructor(_parentInjector, _customTokens) {\n this._parentInjector = _parentInjector;\n this._customTokens = _customTokens;\n }\n get(token, notFoundValue) {\n const value = this._customTokens.get(token);\n if (typeof value !== 'undefined') {\n return value;\n }\n return this._parentInjector.get(token, notFoundValue);\n }\n}\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { BasePortalHost, BasePortalOutlet, CdkPortal, CdkPortalOutlet, ComponentPortal, DomPortal, DomPortalHost, DomPortalOutlet, Portal, PortalHostDirective, PortalInjector, PortalModule, TemplatePortal, TemplatePortalDirective };\n","import * as i0 from '@angular/core';\nimport { inject, Injector, EnvironmentInjector, ApplicationRef, createComponent, Injectable, Component, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';\n\n/** Apps in which we've loaded styles. */\nconst appsWithLoaders = new WeakMap();\n/**\n * Service that loads structural styles dynamically\n * and ensures that they're only loaded once per app.\n */\nclass _CdkPrivateStyleLoader {\n _appRef;\n _injector = inject(Injector);\n _environmentInjector = inject(EnvironmentInjector);\n /**\n * Loads a set of styles.\n * @param loader Component which will be instantiated to load the styles.\n */\n load(loader) {\n // Resolve the app ref lazily to avoid circular dependency errors if this is called too early.\n const appRef = (this._appRef = this._appRef || this._injector.get(ApplicationRef));\n let data = appsWithLoaders.get(appRef);\n // If we haven't loaded for this app before, we have to initialize it.\n if (!data) {\n data = { loaders: new Set(), refs: [] };\n appsWithLoaders.set(appRef, data);\n // When the app is destroyed, we need to clean up all the related loaders.\n appRef.onDestroy(() => {\n appsWithLoaders.get(appRef)?.refs.forEach(ref => ref.destroy());\n appsWithLoaders.delete(appRef);\n });\n }\n // If the loader hasn't been loaded before, we need to instatiate it.\n if (!data.loaders.has(loader)) {\n data.loaders.add(loader);\n data.refs.push(createComponent(loader, { environmentInjector: this._environmentInjector }));\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _CdkPrivateStyleLoader, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _CdkPrivateStyleLoader, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _CdkPrivateStyleLoader, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n\n/**\n * Component used to load the .cdk-visually-hidden styles.\n * @docs-private\n */\nclass _VisuallyHiddenLoader {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _VisuallyHiddenLoader, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"14.0.0\", version: \"19.0.0\", type: _VisuallyHiddenLoader, isStandalone: true, selector: \"ng-component\", exportAs: [\"cdkVisuallyHidden\"], ngImport: i0, template: '', isInline: true, styles: [\".cdk-visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap;outline:0;-webkit-appearance:none;-moz-appearance:none;left:0}[dir=rtl] .cdk-visually-hidden{left:auto;right:0}\"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _VisuallyHiddenLoader, decorators: [{\n type: Component,\n args: [{ exportAs: 'cdkVisuallyHidden', encapsulation: ViewEncapsulation.None, template: '', changeDetection: ChangeDetectionStrategy.OnPush, styles: [\".cdk-visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap;outline:0;-webkit-appearance:none;-moz-appearance:none;left:0}[dir=rtl] .cdk-visually-hidden{left:auto;right:0}\"] }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { _CdkPrivateStyleLoader, _VisuallyHiddenLoader };\n","let nextHandle = 1;\nlet resolved;\nconst activeHandles = {};\nfunction findAndClearHandle(handle) {\n if (handle in activeHandles) {\n delete activeHandles[handle];\n return true;\n }\n return false;\n}\nexport const Immediate = {\n setImmediate(cb) {\n const handle = nextHandle++;\n activeHandles[handle] = true;\n if (!resolved) {\n resolved = Promise.resolve();\n }\n resolved.then(() => findAndClearHandle(handle) && cb());\n return handle;\n },\n clearImmediate(handle) {\n findAndClearHandle(handle);\n },\n};\nexport const TestTools = {\n pending() {\n return Object.keys(activeHandles).length;\n }\n};\n","import { Immediate } from '../util/Immediate';\nconst { setImmediate, clearImmediate } = Immediate;\nexport const immediateProvider = {\n setImmediate(...args) {\n const { delegate } = immediateProvider;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.setImmediate) || setImmediate)(...args);\n },\n clearImmediate(handle) {\n const { delegate } = immediateProvider;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearImmediate) || clearImmediate)(handle);\n },\n delegate: undefined,\n};\n","import { AsapAction } from './AsapAction';\nimport { AsapScheduler } from './AsapScheduler';\nexport const asapScheduler = new AsapScheduler(AsapAction);\nexport const asap = asapScheduler;\n","import { AsyncScheduler } from './AsyncScheduler';\nexport class AsapScheduler extends AsyncScheduler {\n flush(action) {\n this._active = true;\n const flushId = this._scheduled;\n this._scheduled = undefined;\n const { actions } = this;\n let error;\n action = action || actions.shift();\n do {\n if ((error = action.execute(action.state, action.delay))) {\n break;\n }\n } while ((action = actions[0]) && action.id === flushId && actions.shift());\n this._active = false;\n if (error) {\n while ((action = actions[0]) && action.id === flushId && actions.shift()) {\n action.unsubscribe();\n }\n throw error;\n }\n }\n}\n","import { AsyncAction } from './AsyncAction';\nimport { immediateProvider } from './immediateProvider';\nexport class AsapAction extends AsyncAction {\n constructor(scheduler, work) {\n super(scheduler, work);\n this.scheduler = scheduler;\n this.work = work;\n }\n requestAsyncId(scheduler, id, delay = 0) {\n if (delay !== null && delay > 0) {\n return super.requestAsyncId(scheduler, id, delay);\n }\n scheduler.actions.push(this);\n return scheduler._scheduled || (scheduler._scheduled = immediateProvider.setImmediate(scheduler.flush.bind(scheduler, undefined)));\n }\n recycleAsyncId(scheduler, id, delay = 0) {\n var _a;\n if (delay != null ? delay > 0 : this.delay > 0) {\n return super.recycleAsyncId(scheduler, id, delay);\n }\n const { actions } = scheduler;\n if (id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) {\n immediateProvider.clearImmediate(id);\n if (scheduler._scheduled === id) {\n scheduler._scheduled = undefined;\n }\n }\n return undefined;\n }\n}\n","import { coerceNumberProperty, coerceElement } from '@angular/cdk/coercion';\nimport * as i0 from '@angular/core';\nimport { InjectionToken, forwardRef, Directive, Input, inject, NgZone, Injectable, ElementRef, RendererFactory2, ChangeDetectorRef, Injector, afterNextRender, booleanAttribute, Optional, Inject, Component, ViewEncapsulation, ChangeDetectionStrategy, Output, ViewChild, ViewContainerRef, TemplateRef, IterableDiffers, NgModule } from '@angular/core';\nimport { Subject, of, Observable, fromEvent, animationFrameScheduler, asapScheduler, Subscription, isObservable } from 'rxjs';\nimport { distinctUntilChanged, auditTime, filter, takeUntil, startWith, pairwise, switchMap, shareReplay } from 'rxjs/operators';\nimport { Platform, getRtlScrollAxisType, RtlScrollAxisType, supportsScrollBehavior } from '@angular/cdk/platform';\nimport { DOCUMENT } from '@angular/common';\nimport { Directionality, BidiModule } from '@angular/cdk/bidi';\nimport { _VIEW_REPEATER_STRATEGY, isDataSource, ArrayDataSource, _RecycleViewRepeaterStrategy } from '@angular/cdk/collections';\n\n/** The injection token used to specify the virtual scrolling strategy. */\nconst VIRTUAL_SCROLL_STRATEGY = new InjectionToken('VIRTUAL_SCROLL_STRATEGY');\n\n/** Virtual scrolling strategy for lists with items of known fixed size. */\nclass FixedSizeVirtualScrollStrategy {\n _scrolledIndexChange = new Subject();\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n scrolledIndexChange = this._scrolledIndexChange.pipe(distinctUntilChanged());\n /** The attached viewport. */\n _viewport = null;\n /** The size of the items in the virtually scrolling list. */\n _itemSize;\n /** The minimum amount of buffer rendered beyond the viewport (in pixels). */\n _minBufferPx;\n /** The number of buffer items to render beyond the edge of the viewport (in pixels). */\n _maxBufferPx;\n /**\n * @param itemSize The size of the items in the virtually scrolling list.\n * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more\n * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.\n */\n constructor(itemSize, minBufferPx, maxBufferPx) {\n this._itemSize = itemSize;\n this._minBufferPx = minBufferPx;\n this._maxBufferPx = maxBufferPx;\n }\n /**\n * Attaches this scroll strategy to a viewport.\n * @param viewport The viewport to attach this strategy to.\n */\n attach(viewport) {\n this._viewport = viewport;\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n /** Detaches this scroll strategy from the currently attached viewport. */\n detach() {\n this._scrolledIndexChange.complete();\n this._viewport = null;\n }\n /**\n * Update the item size and buffer size.\n * @param itemSize The size of the items in the virtually scrolling list.\n * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more\n * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.\n */\n updateItemAndBufferSize(itemSize, minBufferPx, maxBufferPx) {\n if (maxBufferPx < minBufferPx && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');\n }\n this._itemSize = itemSize;\n this._minBufferPx = minBufferPx;\n this._maxBufferPx = maxBufferPx;\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onContentScrolled() {\n this._updateRenderedRange();\n }\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onDataLengthChanged() {\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onContentRendered() {\n /* no-op */\n }\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onRenderedOffsetChanged() {\n /* no-op */\n }\n /**\n * Scroll to the offset for the given index.\n * @param index The index of the element to scroll to.\n * @param behavior The ScrollBehavior to use when scrolling.\n */\n scrollToIndex(index, behavior) {\n if (this._viewport) {\n this._viewport.scrollToOffset(index * this._itemSize, behavior);\n }\n }\n /** Update the viewport's total content size. */\n _updateTotalContentSize() {\n if (!this._viewport) {\n return;\n }\n this._viewport.setTotalContentSize(this._viewport.getDataLength() * this._itemSize);\n }\n /** Update the viewport's rendered range. */\n _updateRenderedRange() {\n if (!this._viewport) {\n return;\n }\n const renderedRange = this._viewport.getRenderedRange();\n const newRange = { start: renderedRange.start, end: renderedRange.end };\n const viewportSize = this._viewport.getViewportSize();\n const dataLength = this._viewport.getDataLength();\n let scrollOffset = this._viewport.measureScrollOffset();\n // Prevent NaN as result when dividing by zero.\n let firstVisibleIndex = this._itemSize > 0 ? scrollOffset / this._itemSize : 0;\n // If user scrolls to the bottom of the list and data changes to a smaller list\n if (newRange.end > dataLength) {\n // We have to recalculate the first visible index based on new data length and viewport size.\n const maxVisibleItems = Math.ceil(viewportSize / this._itemSize);\n const newVisibleIndex = Math.max(0, Math.min(firstVisibleIndex, dataLength - maxVisibleItems));\n // If first visible index changed we must update scroll offset to handle start/end buffers\n // Current range must also be adjusted to cover the new position (bottom of new list).\n if (firstVisibleIndex != newVisibleIndex) {\n firstVisibleIndex = newVisibleIndex;\n scrollOffset = newVisibleIndex * this._itemSize;\n newRange.start = Math.floor(firstVisibleIndex);\n }\n newRange.end = Math.max(0, Math.min(dataLength, newRange.start + maxVisibleItems));\n }\n const startBuffer = scrollOffset - newRange.start * this._itemSize;\n if (startBuffer < this._minBufferPx && newRange.start != 0) {\n const expandStart = Math.ceil((this._maxBufferPx - startBuffer) / this._itemSize);\n newRange.start = Math.max(0, newRange.start - expandStart);\n newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + (viewportSize + this._minBufferPx) / this._itemSize));\n }\n else {\n const endBuffer = newRange.end * this._itemSize - (scrollOffset + viewportSize);\n if (endBuffer < this._minBufferPx && newRange.end != dataLength) {\n const expandEnd = Math.ceil((this._maxBufferPx - endBuffer) / this._itemSize);\n if (expandEnd > 0) {\n newRange.end = Math.min(dataLength, newRange.end + expandEnd);\n newRange.start = Math.max(0, Math.floor(firstVisibleIndex - this._minBufferPx / this._itemSize));\n }\n }\n }\n this._viewport.setRenderedRange(newRange);\n this._viewport.setRenderedContentOffset(this._itemSize * newRange.start);\n this._scrolledIndexChange.next(Math.floor(firstVisibleIndex));\n }\n}\n/**\n * Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created\n * `FixedSizeVirtualScrollStrategy` from the given directive.\n * @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the\n * `FixedSizeVirtualScrollStrategy` from.\n */\nfunction _fixedSizeVirtualScrollStrategyFactory(fixedSizeDir) {\n return fixedSizeDir._scrollStrategy;\n}\n/** A virtual scroll strategy that supports fixed-size items. */\nclass CdkFixedSizeVirtualScroll {\n /** The size of the items in the list (in pixels). */\n get itemSize() {\n return this._itemSize;\n }\n set itemSize(value) {\n this._itemSize = coerceNumberProperty(value);\n }\n _itemSize = 20;\n /**\n * The minimum amount of buffer rendered beyond the viewport (in pixels).\n * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.\n */\n get minBufferPx() {\n return this._minBufferPx;\n }\n set minBufferPx(value) {\n this._minBufferPx = coerceNumberProperty(value);\n }\n _minBufferPx = 100;\n /**\n * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.\n */\n get maxBufferPx() {\n return this._maxBufferPx;\n }\n set maxBufferPx(value) {\n this._maxBufferPx = coerceNumberProperty(value);\n }\n _maxBufferPx = 200;\n /** The scroll strategy used by this directive. */\n _scrollStrategy = new FixedSizeVirtualScrollStrategy(this.itemSize, this.minBufferPx, this.maxBufferPx);\n ngOnChanges() {\n this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkFixedSizeVirtualScroll, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkFixedSizeVirtualScroll, isStandalone: true, selector: \"cdk-virtual-scroll-viewport[itemSize]\", inputs: { itemSize: \"itemSize\", minBufferPx: \"minBufferPx\", maxBufferPx: \"maxBufferPx\" }, providers: [\n {\n provide: VIRTUAL_SCROLL_STRATEGY,\n useFactory: _fixedSizeVirtualScrollStrategyFactory,\n deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],\n },\n ], usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkFixedSizeVirtualScroll, decorators: [{\n type: Directive,\n args: [{\n selector: 'cdk-virtual-scroll-viewport[itemSize]',\n providers: [\n {\n provide: VIRTUAL_SCROLL_STRATEGY,\n useFactory: _fixedSizeVirtualScrollStrategyFactory,\n deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],\n },\n ],\n }]\n }], propDecorators: { itemSize: [{\n type: Input\n }], minBufferPx: [{\n type: Input\n }], maxBufferPx: [{\n type: Input\n }] } });\n\n/** Time in ms to throttle the scrolling events by default. */\nconst DEFAULT_SCROLL_TIME = 20;\n/**\n * Service contained all registered Scrollable references and emits an event when any one of the\n * Scrollable references emit a scrolled event.\n */\nclass ScrollDispatcher {\n _ngZone = inject(NgZone);\n _platform = inject(Platform);\n /** Used to reference correct document/window */\n _document = inject(DOCUMENT, { optional: true });\n constructor() { }\n /** Subject for notifying that a registered scrollable reference element has been scrolled. */\n _scrolled = new Subject();\n /** Keeps track of the global `scroll` and `resize` subscriptions. */\n _globalSubscription = null;\n /** Keeps track of the amount of subscriptions to `scrolled`. Used for cleaning up afterwards. */\n _scrolledCount = 0;\n /**\n * Map of all the scrollable references that are registered with the service and their\n * scroll event subscriptions.\n */\n scrollContainers = new Map();\n /**\n * Registers a scrollable instance with the service and listens for its scrolled events. When the\n * scrollable is scrolled, the service emits the event to its scrolled observable.\n * @param scrollable Scrollable instance to be registered.\n */\n register(scrollable) {\n if (!this.scrollContainers.has(scrollable)) {\n this.scrollContainers.set(scrollable, scrollable.elementScrolled().subscribe(() => this._scrolled.next(scrollable)));\n }\n }\n /**\n * De-registers a Scrollable reference and unsubscribes from its scroll event observable.\n * @param scrollable Scrollable instance to be deregistered.\n */\n deregister(scrollable) {\n const scrollableReference = this.scrollContainers.get(scrollable);\n if (scrollableReference) {\n scrollableReference.unsubscribe();\n this.scrollContainers.delete(scrollable);\n }\n }\n /**\n * Returns an observable that emits an event whenever any of the registered Scrollable\n * references (or window, document, or body) fire a scrolled event. Can provide a time in ms\n * to override the default \"throttle\" time.\n *\n * **Note:** in order to avoid hitting change detection for every scroll event,\n * all of the events emitted from this stream will be run outside the Angular zone.\n * If you need to update any data bindings as a result of a scroll event, you have\n * to run the callback using `NgZone.run`.\n */\n scrolled(auditTimeInMs = DEFAULT_SCROLL_TIME) {\n if (!this._platform.isBrowser) {\n return of();\n }\n return new Observable((observer) => {\n if (!this._globalSubscription) {\n this._addGlobalListener();\n }\n // In the case of a 0ms delay, use an observable without auditTime\n // since it does add a perceptible delay in processing overhead.\n const subscription = auditTimeInMs > 0\n ? this._scrolled.pipe(auditTime(auditTimeInMs)).subscribe(observer)\n : this._scrolled.subscribe(observer);\n this._scrolledCount++;\n return () => {\n subscription.unsubscribe();\n this._scrolledCount--;\n if (!this._scrolledCount) {\n this._removeGlobalListener();\n }\n };\n });\n }\n ngOnDestroy() {\n this._removeGlobalListener();\n this.scrollContainers.forEach((_, container) => this.deregister(container));\n this._scrolled.complete();\n }\n /**\n * Returns an observable that emits whenever any of the\n * scrollable ancestors of an element are scrolled.\n * @param elementOrElementRef Element whose ancestors to listen for.\n * @param auditTimeInMs Time to throttle the scroll events.\n */\n ancestorScrolled(elementOrElementRef, auditTimeInMs) {\n const ancestors = this.getAncestorScrollContainers(elementOrElementRef);\n return this.scrolled(auditTimeInMs).pipe(filter(target => {\n return !target || ancestors.indexOf(target) > -1;\n }));\n }\n /** Returns all registered Scrollables that contain the provided element. */\n getAncestorScrollContainers(elementOrElementRef) {\n const scrollingContainers = [];\n this.scrollContainers.forEach((_subscription, scrollable) => {\n if (this._scrollableContainsElement(scrollable, elementOrElementRef)) {\n scrollingContainers.push(scrollable);\n }\n });\n return scrollingContainers;\n }\n /** Use defaultView of injected document if available or fallback to global window reference */\n _getWindow() {\n return this._document.defaultView || window;\n }\n /** Returns true if the element is contained within the provided Scrollable. */\n _scrollableContainsElement(scrollable, elementOrElementRef) {\n let element = coerceElement(elementOrElementRef);\n let scrollableElement = scrollable.getElementRef().nativeElement;\n // Traverse through the element parents until we reach null, checking if any of the elements\n // are the scrollable's element.\n do {\n if (element == scrollableElement) {\n return true;\n }\n } while ((element = element.parentElement));\n return false;\n }\n /** Sets up the global scroll listeners. */\n _addGlobalListener() {\n this._globalSubscription = this._ngZone.runOutsideAngular(() => {\n const window = this._getWindow();\n return fromEvent(window.document, 'scroll').subscribe(() => this._scrolled.next());\n });\n }\n /** Cleans up the global scroll listener. */\n _removeGlobalListener() {\n if (this._globalSubscription) {\n this._globalSubscription.unsubscribe();\n this._globalSubscription = null;\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollDispatcher, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollDispatcher, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollDispatcher, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\n/**\n * Sends an event when the directive's element is scrolled. Registers itself with the\n * ScrollDispatcher service to include itself as part of its collection of scrolling events that it\n * can be listened to through the service.\n */\nclass CdkScrollable {\n elementRef = inject(ElementRef);\n scrollDispatcher = inject(ScrollDispatcher);\n ngZone = inject(NgZone);\n dir = inject(Directionality, { optional: true });\n _destroyed = new Subject();\n _elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(this.elementRef.nativeElement, 'scroll')\n .pipe(takeUntil(this._destroyed))\n .subscribe(observer)));\n constructor() { }\n ngOnInit() {\n this.scrollDispatcher.register(this);\n }\n ngOnDestroy() {\n this.scrollDispatcher.deregister(this);\n this._destroyed.next();\n this._destroyed.complete();\n }\n /** Returns observable that emits when a scroll event is fired on the host element. */\n elementScrolled() {\n return this._elementScrolled;\n }\n /** Gets the ElementRef for the viewport. */\n getElementRef() {\n return this.elementRef;\n }\n /**\n * Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo\n * method, since browsers are not consistent about what scrollLeft means in RTL. For this method\n * left and right always refer to the left and right side of the scrolling container irrespective\n * of the layout direction. start and end refer to left and right in an LTR context and vice-versa\n * in an RTL context.\n * @param options specified the offsets to scroll to.\n */\n scrollTo(options) {\n const el = this.elementRef.nativeElement;\n const isRtl = this.dir && this.dir.value == 'rtl';\n // Rewrite start & end offsets as right or left offsets.\n if (options.left == null) {\n options.left = isRtl ? options.end : options.start;\n }\n if (options.right == null) {\n options.right = isRtl ? options.start : options.end;\n }\n // Rewrite the bottom offset as a top offset.\n if (options.bottom != null) {\n options.top =\n el.scrollHeight - el.clientHeight - options.bottom;\n }\n // Rewrite the right offset as a left offset.\n if (isRtl && getRtlScrollAxisType() != RtlScrollAxisType.NORMAL) {\n if (options.left != null) {\n options.right =\n el.scrollWidth - el.clientWidth - options.left;\n }\n if (getRtlScrollAxisType() == RtlScrollAxisType.INVERTED) {\n options.left = options.right;\n }\n else if (getRtlScrollAxisType() == RtlScrollAxisType.NEGATED) {\n options.left = options.right ? -options.right : options.right;\n }\n }\n else {\n if (options.right != null) {\n options.left =\n el.scrollWidth - el.clientWidth - options.right;\n }\n }\n this._applyScrollToOptions(options);\n }\n _applyScrollToOptions(options) {\n const el = this.elementRef.nativeElement;\n if (supportsScrollBehavior()) {\n el.scrollTo(options);\n }\n else {\n if (options.top != null) {\n el.scrollTop = options.top;\n }\n if (options.left != null) {\n el.scrollLeft = options.left;\n }\n }\n }\n /**\n * Measures the scroll offset relative to the specified edge of the viewport. This method can be\n * used instead of directly checking scrollLeft or scrollTop, since browsers are not consistent\n * about what scrollLeft means in RTL. The values returned by this method are normalized such that\n * left and right always refer to the left and right side of the scrolling container irrespective\n * of the layout direction. start and end refer to left and right in an LTR context and vice-versa\n * in an RTL context.\n * @param from The edge to measure from.\n */\n measureScrollOffset(from) {\n const LEFT = 'left';\n const RIGHT = 'right';\n const el = this.elementRef.nativeElement;\n if (from == 'top') {\n return el.scrollTop;\n }\n if (from == 'bottom') {\n return el.scrollHeight - el.clientHeight - el.scrollTop;\n }\n // Rewrite start & end as left or right offsets.\n const isRtl = this.dir && this.dir.value == 'rtl';\n if (from == 'start') {\n from = isRtl ? RIGHT : LEFT;\n }\n else if (from == 'end') {\n from = isRtl ? LEFT : RIGHT;\n }\n if (isRtl && getRtlScrollAxisType() == RtlScrollAxisType.INVERTED) {\n // For INVERTED, scrollLeft is (scrollWidth - clientWidth) when scrolled all the way left and\n // 0 when scrolled all the way right.\n if (from == LEFT) {\n return el.scrollWidth - el.clientWidth - el.scrollLeft;\n }\n else {\n return el.scrollLeft;\n }\n }\n else if (isRtl && getRtlScrollAxisType() == RtlScrollAxisType.NEGATED) {\n // For NEGATED, scrollLeft is -(scrollWidth - clientWidth) when scrolled all the way left and\n // 0 when scrolled all the way right.\n if (from == LEFT) {\n return el.scrollLeft + el.scrollWidth - el.clientWidth;\n }\n else {\n return -el.scrollLeft;\n }\n }\n else {\n // For NORMAL, as well as non-RTL contexts, scrollLeft is 0 when scrolled all the way left and\n // (scrollWidth - clientWidth) when scrolled all the way right.\n if (from == LEFT) {\n return el.scrollLeft;\n }\n else {\n return el.scrollWidth - el.clientWidth - el.scrollLeft;\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkScrollable, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkScrollable, isStandalone: true, selector: \"[cdk-scrollable], [cdkScrollable]\", ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkScrollable, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdk-scrollable], [cdkScrollable]',\n }]\n }], ctorParameters: () => [] });\n\n/** Time in ms to throttle the resize events by default. */\nconst DEFAULT_RESIZE_TIME = 20;\n/**\n * Simple utility for getting the bounds of the browser viewport.\n * @docs-private\n */\nclass ViewportRuler {\n _platform = inject(Platform);\n _listeners;\n /** Cached viewport dimensions. */\n _viewportSize;\n /** Stream of viewport change events. */\n _change = new Subject();\n /** Used to reference correct document/window */\n _document = inject(DOCUMENT, { optional: true });\n constructor() {\n const ngZone = inject(NgZone);\n const renderer = inject(RendererFactory2).createRenderer(null, null);\n ngZone.runOutsideAngular(() => {\n if (this._platform.isBrowser) {\n const changeListener = (event) => this._change.next(event);\n this._listeners = [\n renderer.listen('window', 'resize', changeListener),\n renderer.listen('window', 'orientationchange', changeListener),\n ];\n }\n // Clear the cached position so that the viewport is re-measured next time it is required.\n // We don't need to keep track of the subscription, because it is completed on destroy.\n this.change().subscribe(() => (this._viewportSize = null));\n });\n }\n ngOnDestroy() {\n this._listeners?.forEach(cleanup => cleanup());\n this._change.complete();\n }\n /** Returns the viewport's width and height. */\n getViewportSize() {\n if (!this._viewportSize) {\n this._updateViewportSize();\n }\n const output = { width: this._viewportSize.width, height: this._viewportSize.height };\n // If we're not on a browser, don't cache the size since it'll be mocked out anyway.\n if (!this._platform.isBrowser) {\n this._viewportSize = null;\n }\n return output;\n }\n /** Gets a DOMRect for the viewport's bounds. */\n getViewportRect() {\n // Use the document element's bounding rect rather than the window scroll properties\n // (e.g. pageYOffset, scrollY) due to in issue in Chrome and IE where window scroll\n // properties and client coordinates (boundingClientRect, clientX/Y, etc.) are in different\n // conceptual viewports. Under most circumstances these viewports are equivalent, but they\n // can disagree when the page is pinch-zoomed (on devices that support touch).\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=489206#c4\n // We use the documentElement instead of the body because, by default (without a css reset)\n // browsers typically give the document body an 8px margin, which is not included in\n // getBoundingClientRect().\n const scrollPosition = this.getViewportScrollPosition();\n const { width, height } = this.getViewportSize();\n return {\n top: scrollPosition.top,\n left: scrollPosition.left,\n bottom: scrollPosition.top + height,\n right: scrollPosition.left + width,\n height,\n width,\n };\n }\n /** Gets the (top, left) scroll position of the viewport. */\n getViewportScrollPosition() {\n // While we can get a reference to the fake document\n // during SSR, it doesn't have getBoundingClientRect.\n if (!this._platform.isBrowser) {\n return { top: 0, left: 0 };\n }\n // The top-left-corner of the viewport is determined by the scroll position of the document\n // body, normally just (scrollLeft, scrollTop). However, Chrome and Firefox disagree about\n // whether `document.body` or `document.documentElement` is the scrolled element, so reading\n // `scrollTop` and `scrollLeft` is inconsistent. However, using the bounding rect of\n // `document.documentElement` works consistently, where the `top` and `left` values will\n // equal negative the scroll position.\n const document = this._document;\n const window = this._getWindow();\n const documentElement = document.documentElement;\n const documentRect = documentElement.getBoundingClientRect();\n const top = -documentRect.top ||\n document.body.scrollTop ||\n window.scrollY ||\n documentElement.scrollTop ||\n 0;\n const left = -documentRect.left ||\n document.body.scrollLeft ||\n window.scrollX ||\n documentElement.scrollLeft ||\n 0;\n return { top, left };\n }\n /**\n * Returns a stream that emits whenever the size of the viewport changes.\n * This stream emits outside of the Angular zone.\n * @param throttleTime Time in milliseconds to throttle the stream.\n */\n change(throttleTime = DEFAULT_RESIZE_TIME) {\n return throttleTime > 0 ? this._change.pipe(auditTime(throttleTime)) : this._change;\n }\n /** Use defaultView of injected document if available or fallback to global window reference */\n _getWindow() {\n return this._document.defaultView || window;\n }\n /** Updates the cached viewport size. */\n _updateViewportSize() {\n const window = this._getWindow();\n this._viewportSize = this._platform.isBrowser\n ? { width: window.innerWidth, height: window.innerHeight }\n : { width: 0, height: 0 };\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ViewportRuler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ViewportRuler, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ViewportRuler, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n\nconst VIRTUAL_SCROLLABLE = new InjectionToken('VIRTUAL_SCROLLABLE');\n/**\n * Extending the {@link CdkScrollable} to be used as scrolling container for virtual scrolling.\n */\nclass CdkVirtualScrollable extends CdkScrollable {\n constructor() {\n super();\n }\n /**\n * Measure the viewport size for the provided orientation.\n *\n * @param orientation The orientation to measure the size from.\n */\n measureViewportSize(orientation) {\n const viewportEl = this.elementRef.nativeElement;\n return orientation === 'horizontal' ? viewportEl.clientWidth : viewportEl.clientHeight;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollable, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkVirtualScrollable, isStandalone: true, usesInheritance: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollable, decorators: [{\n type: Directive\n }], ctorParameters: () => [] });\n\n/** Checks if the given ranges are equal. */\nfunction rangesEqual(r1, r2) {\n return r1.start == r2.start && r1.end == r2.end;\n}\n/**\n * Scheduler to be used for scroll events. Needs to fall back to\n * something that doesn't rely on requestAnimationFrame on environments\n * that don't support it (e.g. server-side rendering).\n */\nconst SCROLL_SCHEDULER = typeof requestAnimationFrame !== 'undefined' ? animationFrameScheduler : asapScheduler;\n/** A viewport that virtualizes its scrolling with the help of `CdkVirtualForOf`. */\nclass CdkVirtualScrollViewport extends CdkVirtualScrollable {\n elementRef = inject(ElementRef);\n _changeDetectorRef = inject(ChangeDetectorRef);\n _scrollStrategy = inject(VIRTUAL_SCROLL_STRATEGY, {\n optional: true,\n });\n scrollable = inject(VIRTUAL_SCROLLABLE, { optional: true });\n _platform = inject(Platform);\n /** Emits when the viewport is detached from a CdkVirtualForOf. */\n _detachedSubject = new Subject();\n /** Emits when the rendered range changes. */\n _renderedRangeSubject = new Subject();\n /** The direction the viewport scrolls. */\n get orientation() {\n return this._orientation;\n }\n set orientation(orientation) {\n if (this._orientation !== orientation) {\n this._orientation = orientation;\n this._calculateSpacerSize();\n }\n }\n _orientation = 'vertical';\n /**\n * Whether rendered items should persist in the DOM after scrolling out of view. By default, items\n * will be removed.\n */\n appendOnly = false;\n // Note: we don't use the typical EventEmitter here because we need to subscribe to the scroll\n // strategy lazily (i.e. only if the user is actually listening to the events). We do this because\n // depending on how the strategy calculates the scrolled index, it may come at a cost to\n // performance.\n /** Emits when the index of the first element visible in the viewport changes. */\n scrolledIndexChange = new Observable((observer) => this._scrollStrategy.scrolledIndexChange.subscribe(index => Promise.resolve().then(() => this.ngZone.run(() => observer.next(index)))));\n /** The element that wraps the rendered content. */\n _contentWrapper;\n /** A stream that emits whenever the rendered range changes. */\n renderedRangeStream = this._renderedRangeSubject;\n /**\n * The total size of all content (in pixels), including content that is not currently rendered.\n */\n _totalContentSize = 0;\n /** A string representing the `style.width` property value to be used for the spacer element. */\n _totalContentWidth = '';\n /** A string representing the `style.height` property value to be used for the spacer element. */\n _totalContentHeight = '';\n /**\n * The CSS transform applied to the rendered subset of items so that they appear within the bounds\n * of the visible viewport.\n */\n _renderedContentTransform;\n /** The currently rendered range of indices. */\n _renderedRange = { start: 0, end: 0 };\n /** The length of the data bound to this viewport (in number of items). */\n _dataLength = 0;\n /** The size of the viewport (in pixels). */\n _viewportSize = 0;\n /** the currently attached CdkVirtualScrollRepeater. */\n _forOf;\n /** The last rendered content offset that was set. */\n _renderedContentOffset = 0;\n /**\n * Whether the last rendered content offset was to the end of the content (and therefore needs to\n * be rewritten as an offset to the start of the content).\n */\n _renderedContentOffsetNeedsRewrite = false;\n /** Whether there is a pending change detection cycle. */\n _isChangeDetectionPending = false;\n /** A list of functions to run after the next change detection cycle. */\n _runAfterChangeDetection = [];\n /** Subscription to changes in the viewport size. */\n _viewportChanges = Subscription.EMPTY;\n _injector = inject(Injector);\n _isDestroyed = false;\n constructor() {\n super();\n const viewportRuler = inject(ViewportRuler);\n if (!this._scrollStrategy && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error('Error: cdk-virtual-scroll-viewport requires the \"itemSize\" property to be set.');\n }\n this._viewportChanges = viewportRuler.change().subscribe(() => {\n this.checkViewportSize();\n });\n if (!this.scrollable) {\n // No scrollable is provided, so the virtual-scroll-viewport needs to become a scrollable\n this.elementRef.nativeElement.classList.add('cdk-virtual-scrollable');\n this.scrollable = this;\n }\n }\n ngOnInit() {\n // Scrolling depends on the element dimensions which we can't get during SSR.\n if (!this._platform.isBrowser) {\n return;\n }\n if (this.scrollable === this) {\n super.ngOnInit();\n }\n // It's still too early to measure the viewport at this point. Deferring with a promise allows\n // the Viewport to be rendered with the correct size before we measure. We run this outside the\n // zone to avoid causing more change detection cycles. We handle the change detection loop\n // ourselves instead.\n this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {\n this._measureViewportSize();\n this._scrollStrategy.attach(this);\n this.scrollable\n .elementScrolled()\n .pipe(\n // Start off with a fake scroll event so we properly detect our initial position.\n startWith(null), \n // Collect multiple events into one until the next animation frame. This way if\n // there are multiple scroll events in the same frame we only need to recheck\n // our layout once.\n auditTime(0, SCROLL_SCHEDULER), \n // Usually `elementScrolled` is completed when the scrollable is destroyed, but\n // that may not be the case if a `CdkVirtualScrollableElement` is used so we have\n // to unsubscribe here just in case.\n takeUntil(this._destroyed))\n .subscribe(() => this._scrollStrategy.onContentScrolled());\n this._markChangeDetectionNeeded();\n }));\n }\n ngOnDestroy() {\n this.detach();\n this._scrollStrategy.detach();\n // Complete all subjects\n this._renderedRangeSubject.complete();\n this._detachedSubject.complete();\n this._viewportChanges.unsubscribe();\n this._isDestroyed = true;\n super.ngOnDestroy();\n }\n /** Attaches a `CdkVirtualScrollRepeater` to this viewport. */\n attach(forOf) {\n if (this._forOf && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error('CdkVirtualScrollViewport is already attached.');\n }\n // Subscribe to the data stream of the CdkVirtualForOf to keep track of when the data length\n // changes. Run outside the zone to avoid triggering change detection, since we're managing the\n // change detection loop ourselves.\n this.ngZone.runOutsideAngular(() => {\n this._forOf = forOf;\n this._forOf.dataStream.pipe(takeUntil(this._detachedSubject)).subscribe(data => {\n const newLength = data.length;\n if (newLength !== this._dataLength) {\n this._dataLength = newLength;\n this._scrollStrategy.onDataLengthChanged();\n }\n this._doChangeDetection();\n });\n });\n }\n /** Detaches the current `CdkVirtualForOf`. */\n detach() {\n this._forOf = null;\n this._detachedSubject.next();\n }\n /** Gets the length of the data bound to this viewport (in number of items). */\n getDataLength() {\n return this._dataLength;\n }\n /** Gets the size of the viewport (in pixels). */\n getViewportSize() {\n return this._viewportSize;\n }\n // TODO(mmalerba): This is technically out of sync with what's really rendered until a render\n // cycle happens. I'm being careful to only call it after the render cycle is complete and before\n // setting it to something else, but its error prone and should probably be split into\n // `pendingRange` and `renderedRange`, the latter reflecting whats actually in the DOM.\n /** Get the current rendered range of items. */\n getRenderedRange() {\n return this._renderedRange;\n }\n measureBoundingClientRectWithScrollOffset(from) {\n return this.getElementRef().nativeElement.getBoundingClientRect()[from];\n }\n /**\n * Sets the total size of all content (in pixels), including content that is not currently\n * rendered.\n */\n setTotalContentSize(size) {\n if (this._totalContentSize !== size) {\n this._totalContentSize = size;\n this._calculateSpacerSize();\n this._markChangeDetectionNeeded();\n }\n }\n /** Sets the currently rendered range of indices. */\n setRenderedRange(range) {\n if (!rangesEqual(this._renderedRange, range)) {\n if (this.appendOnly) {\n range = { start: 0, end: Math.max(this._renderedRange.end, range.end) };\n }\n this._renderedRangeSubject.next((this._renderedRange = range));\n this._markChangeDetectionNeeded(() => this._scrollStrategy.onContentRendered());\n }\n }\n /**\n * Gets the offset from the start of the viewport to the start of the rendered data (in pixels).\n */\n getOffsetToRenderedContentStart() {\n return this._renderedContentOffsetNeedsRewrite ? null : this._renderedContentOffset;\n }\n /**\n * Sets the offset from the start of the viewport to either the start or end of the rendered data\n * (in pixels).\n */\n setRenderedContentOffset(offset, to = 'to-start') {\n // In appendOnly, we always start from the top\n offset = this.appendOnly && to === 'to-start' ? 0 : offset;\n // For a horizontal viewport in a right-to-left language we need to translate along the x-axis\n // in the negative direction.\n const isRtl = this.dir && this.dir.value == 'rtl';\n const isHorizontal = this.orientation == 'horizontal';\n const axis = isHorizontal ? 'X' : 'Y';\n const axisDirection = isHorizontal && isRtl ? -1 : 1;\n let transform = `translate${axis}(${Number(axisDirection * offset)}px)`;\n this._renderedContentOffset = offset;\n if (to === 'to-end') {\n transform += ` translate${axis}(-100%)`;\n // The viewport should rewrite this as a `to-start` offset on the next render cycle. Otherwise\n // elements will appear to expand in the wrong direction (e.g. `mat-expansion-panel` would\n // expand upward).\n this._renderedContentOffsetNeedsRewrite = true;\n }\n if (this._renderedContentTransform != transform) {\n // We know this value is safe because we parse `offset` with `Number()` before passing it\n // into the string.\n this._renderedContentTransform = transform;\n this._markChangeDetectionNeeded(() => {\n if (this._renderedContentOffsetNeedsRewrite) {\n this._renderedContentOffset -= this.measureRenderedContentSize();\n this._renderedContentOffsetNeedsRewrite = false;\n this.setRenderedContentOffset(this._renderedContentOffset);\n }\n else {\n this._scrollStrategy.onRenderedOffsetChanged();\n }\n });\n }\n }\n /**\n * Scrolls to the given offset from the start of the viewport. Please note that this is not always\n * the same as setting `scrollTop` or `scrollLeft`. In a horizontal viewport with right-to-left\n * direction, this would be the equivalent of setting a fictional `scrollRight` property.\n * @param offset The offset to scroll to.\n * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.\n */\n scrollToOffset(offset, behavior = 'auto') {\n const options = { behavior };\n if (this.orientation === 'horizontal') {\n options.start = offset;\n }\n else {\n options.top = offset;\n }\n this.scrollable.scrollTo(options);\n }\n /**\n * Scrolls to the offset for the given index.\n * @param index The index of the element to scroll to.\n * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.\n */\n scrollToIndex(index, behavior = 'auto') {\n this._scrollStrategy.scrollToIndex(index, behavior);\n }\n /**\n * Gets the current scroll offset from the start of the scrollable (in pixels).\n * @param from The edge to measure the offset from. Defaults to 'top' in vertical mode and 'start'\n * in horizontal mode.\n */\n measureScrollOffset(from) {\n // This is to break the call cycle\n let measureScrollOffset;\n if (this.scrollable == this) {\n measureScrollOffset = (_from) => super.measureScrollOffset(_from);\n }\n else {\n measureScrollOffset = (_from) => this.scrollable.measureScrollOffset(_from);\n }\n return Math.max(0, measureScrollOffset(from ?? (this.orientation === 'horizontal' ? 'start' : 'top')) -\n this.measureViewportOffset());\n }\n /**\n * Measures the offset of the viewport from the scrolling container\n * @param from The edge to measure from.\n */\n measureViewportOffset(from) {\n let fromRect;\n const LEFT = 'left';\n const RIGHT = 'right';\n const isRtl = this.dir?.value == 'rtl';\n if (from == 'start') {\n fromRect = isRtl ? RIGHT : LEFT;\n }\n else if (from == 'end') {\n fromRect = isRtl ? LEFT : RIGHT;\n }\n else if (from) {\n fromRect = from;\n }\n else {\n fromRect = this.orientation === 'horizontal' ? 'left' : 'top';\n }\n const scrollerClientRect = this.scrollable.measureBoundingClientRectWithScrollOffset(fromRect);\n const viewportClientRect = this.elementRef.nativeElement.getBoundingClientRect()[fromRect];\n return viewportClientRect - scrollerClientRect;\n }\n /** Measure the combined size of all of the rendered items. */\n measureRenderedContentSize() {\n const contentEl = this._contentWrapper.nativeElement;\n return this.orientation === 'horizontal' ? contentEl.offsetWidth : contentEl.offsetHeight;\n }\n /**\n * Measure the total combined size of the given range. Throws if the range includes items that are\n * not rendered.\n */\n measureRangeSize(range) {\n if (!this._forOf) {\n return 0;\n }\n return this._forOf.measureRangeSize(range, this.orientation);\n }\n /** Update the viewport dimensions and re-render. */\n checkViewportSize() {\n // TODO: Cleanup later when add logic for handling content resize\n this._measureViewportSize();\n this._scrollStrategy.onDataLengthChanged();\n }\n /** Measure the viewport size. */\n _measureViewportSize() {\n this._viewportSize = this.scrollable.measureViewportSize(this.orientation);\n }\n /** Queue up change detection to run. */\n _markChangeDetectionNeeded(runAfter) {\n if (runAfter) {\n this._runAfterChangeDetection.push(runAfter);\n }\n // Use a Promise to batch together calls to `_doChangeDetection`. This way if we set a bunch of\n // properties sequentially we only have to run `_doChangeDetection` once at the end.\n if (!this._isChangeDetectionPending) {\n this._isChangeDetectionPending = true;\n this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {\n this._doChangeDetection();\n }));\n }\n }\n /** Run change detection. */\n _doChangeDetection() {\n if (this._isDestroyed) {\n return;\n }\n this.ngZone.run(() => {\n // Apply changes to Angular bindings. Note: We must call `markForCheck` to run change detection\n // from the root, since the repeated items are content projected in. Calling `detectChanges`\n // instead does not properly check the projected content.\n this._changeDetectorRef.markForCheck();\n // Apply the content transform. The transform can't be set via an Angular binding because\n // bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of\n // string literals, a variable that can only be 'X' or 'Y', and user input that is run through\n // the `Number` function first to coerce it to a numeric value.\n this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;\n afterNextRender(() => {\n this._isChangeDetectionPending = false;\n const runAfterChangeDetection = this._runAfterChangeDetection;\n this._runAfterChangeDetection = [];\n for (const fn of runAfterChangeDetection) {\n fn();\n }\n }, { injector: this._injector });\n });\n }\n /** Calculates the `style.width` and `style.height` for the spacer element. */\n _calculateSpacerSize() {\n this._totalContentHeight =\n this.orientation === 'horizontal' ? '' : `${this._totalContentSize}px`;\n this._totalContentWidth =\n this.orientation === 'horizontal' ? `${this._totalContentSize}px` : '';\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollViewport, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkVirtualScrollViewport, isStandalone: true, selector: \"cdk-virtual-scroll-viewport\", inputs: { orientation: \"orientation\", appendOnly: [\"appendOnly\", \"appendOnly\", booleanAttribute] }, outputs: { scrolledIndexChange: \"scrolledIndexChange\" }, host: { properties: { \"class.cdk-virtual-scroll-orientation-horizontal\": \"orientation === \\\"horizontal\\\"\", \"class.cdk-virtual-scroll-orientation-vertical\": \"orientation !== \\\"horizontal\\\"\" }, classAttribute: \"cdk-virtual-scroll-viewport\" }, providers: [\n {\n provide: CdkScrollable,\n useFactory: (virtualScrollable, viewport) => virtualScrollable || viewport,\n deps: [[new Optional(), new Inject(VIRTUAL_SCROLLABLE)], CdkVirtualScrollViewport],\n },\n ], viewQueries: [{ propertyName: \"_contentWrapper\", first: true, predicate: [\"contentWrapper\"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: \"\\n
    \\n \\n
    \\n\\n
    \\n\", styles: [\"cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}\"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollViewport, decorators: [{\n type: Component,\n args: [{ selector: 'cdk-virtual-scroll-viewport', host: {\n 'class': 'cdk-virtual-scroll-viewport',\n '[class.cdk-virtual-scroll-orientation-horizontal]': 'orientation === \"horizontal\"',\n '[class.cdk-virtual-scroll-orientation-vertical]': 'orientation !== \"horizontal\"',\n }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [\n {\n provide: CdkScrollable,\n useFactory: (virtualScrollable, viewport) => virtualScrollable || viewport,\n deps: [[new Optional(), new Inject(VIRTUAL_SCROLLABLE)], CdkVirtualScrollViewport],\n },\n ], template: \"\\n
    \\n \\n
    \\n\\n
    \\n\", styles: [\"cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}\"] }]\n }], ctorParameters: () => [], propDecorators: { orientation: [{\n type: Input\n }], appendOnly: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], scrolledIndexChange: [{\n type: Output\n }], _contentWrapper: [{\n type: ViewChild,\n args: ['contentWrapper', { static: true }]\n }] } });\n\n/** Helper to extract the offset of a DOM Node in a certain direction. */\nfunction getOffset(orientation, direction, node) {\n const el = node;\n if (!el.getBoundingClientRect) {\n return 0;\n }\n const rect = el.getBoundingClientRect();\n if (orientation === 'horizontal') {\n return direction === 'start' ? rect.left : rect.right;\n }\n return direction === 'start' ? rect.top : rect.bottom;\n}\n/**\n * A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling\n * container.\n */\nclass CdkVirtualForOf {\n _viewContainerRef = inject(ViewContainerRef);\n _template = inject(TemplateRef);\n _differs = inject(IterableDiffers);\n _viewRepeater = inject(_VIEW_REPEATER_STRATEGY);\n _viewport = inject(CdkVirtualScrollViewport, { skipSelf: true });\n /** Emits when the rendered view of the data changes. */\n viewChange = new Subject();\n /** Subject that emits when a new DataSource instance is given. */\n _dataSourceChanges = new Subject();\n /** The DataSource to display. */\n get cdkVirtualForOf() {\n return this._cdkVirtualForOf;\n }\n set cdkVirtualForOf(value) {\n this._cdkVirtualForOf = value;\n if (isDataSource(value)) {\n this._dataSourceChanges.next(value);\n }\n else {\n // If value is an an NgIterable, convert it to an array.\n this._dataSourceChanges.next(new ArrayDataSource(isObservable(value) ? value : Array.from(value || [])));\n }\n }\n _cdkVirtualForOf;\n /**\n * The `TrackByFunction` to use for tracking changes. The `TrackByFunction` takes the index and\n * the item and produces a value to be used as the item's identity when tracking changes.\n */\n get cdkVirtualForTrackBy() {\n return this._cdkVirtualForTrackBy;\n }\n set cdkVirtualForTrackBy(fn) {\n this._needsUpdate = true;\n this._cdkVirtualForTrackBy = fn\n ? (index, item) => fn(index + (this._renderedRange ? this._renderedRange.start : 0), item)\n : undefined;\n }\n _cdkVirtualForTrackBy;\n /** The template used to stamp out new elements. */\n set cdkVirtualForTemplate(value) {\n if (value) {\n this._needsUpdate = true;\n this._template = value;\n }\n }\n /**\n * The size of the cache used to store templates that are not being used for re-use later.\n * Setting the cache size to `0` will disable caching. Defaults to 20 templates.\n */\n get cdkVirtualForTemplateCacheSize() {\n return this._viewRepeater.viewCacheSize;\n }\n set cdkVirtualForTemplateCacheSize(size) {\n this._viewRepeater.viewCacheSize = coerceNumberProperty(size);\n }\n /** Emits whenever the data in the current DataSource changes. */\n dataStream = this._dataSourceChanges.pipe(\n // Start off with null `DataSource`.\n startWith(null), \n // Bundle up the previous and current data sources so we can work with both.\n pairwise(), \n // Use `_changeDataSource` to disconnect from the previous data source and connect to the\n // new one, passing back a stream of data changes which we run through `switchMap` to give\n // us a data stream that emits the latest data from whatever the current `DataSource` is.\n switchMap(([prev, cur]) => this._changeDataSource(prev, cur)), \n // Replay the last emitted data when someone subscribes.\n shareReplay(1));\n /** The differ used to calculate changes to the data. */\n _differ = null;\n /** The most recent data emitted from the DataSource. */\n _data;\n /** The currently rendered items. */\n _renderedItems;\n /** The currently rendered range of indices. */\n _renderedRange;\n /** Whether the rendered data should be updated during the next ngDoCheck cycle. */\n _needsUpdate = false;\n _destroyed = new Subject();\n constructor() {\n const ngZone = inject(NgZone);\n this.dataStream.subscribe(data => {\n this._data = data;\n this._onRenderedDataChange();\n });\n this._viewport.renderedRangeStream.pipe(takeUntil(this._destroyed)).subscribe(range => {\n this._renderedRange = range;\n if (this.viewChange.observers.length) {\n ngZone.run(() => this.viewChange.next(this._renderedRange));\n }\n this._onRenderedDataChange();\n });\n this._viewport.attach(this);\n }\n /**\n * Measures the combined size (width for horizontal orientation, height for vertical) of all items\n * in the specified range. Throws an error if the range includes items that are not currently\n * rendered.\n */\n measureRangeSize(range, orientation) {\n if (range.start >= range.end) {\n return 0;\n }\n if ((range.start < this._renderedRange.start || range.end > this._renderedRange.end) &&\n (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw Error(`Error: attempted to measure an item that isn't rendered.`);\n }\n // The index into the list of rendered views for the first item in the range.\n const renderedStartIndex = range.start - this._renderedRange.start;\n // The length of the range we're measuring.\n const rangeLen = range.end - range.start;\n // Loop over all the views, find the first and land node and compute the size by subtracting\n // the top of the first node from the bottom of the last one.\n let firstNode;\n let lastNode;\n // Find the first node by starting from the beginning and going forwards.\n for (let i = 0; i < rangeLen; i++) {\n const view = this._viewContainerRef.get(i + renderedStartIndex);\n if (view && view.rootNodes.length) {\n firstNode = lastNode = view.rootNodes[0];\n break;\n }\n }\n // Find the last node by starting from the end and going backwards.\n for (let i = rangeLen - 1; i > -1; i--) {\n const view = this._viewContainerRef.get(i + renderedStartIndex);\n if (view && view.rootNodes.length) {\n lastNode = view.rootNodes[view.rootNodes.length - 1];\n break;\n }\n }\n return firstNode && lastNode\n ? getOffset(orientation, 'end', lastNode) - getOffset(orientation, 'start', firstNode)\n : 0;\n }\n ngDoCheck() {\n if (this._differ && this._needsUpdate) {\n // TODO(mmalerba): We should differentiate needs update due to scrolling and a new portion of\n // this list being rendered (can use simpler algorithm) vs needs update due to data actually\n // changing (need to do this diff).\n const changes = this._differ.diff(this._renderedItems);\n if (!changes) {\n this._updateContext();\n }\n else {\n this._applyChanges(changes);\n }\n this._needsUpdate = false;\n }\n }\n ngOnDestroy() {\n this._viewport.detach();\n this._dataSourceChanges.next(undefined);\n this._dataSourceChanges.complete();\n this.viewChange.complete();\n this._destroyed.next();\n this._destroyed.complete();\n this._viewRepeater.detach();\n }\n /** React to scroll state changes in the viewport. */\n _onRenderedDataChange() {\n if (!this._renderedRange) {\n return;\n }\n this._renderedItems = this._data.slice(this._renderedRange.start, this._renderedRange.end);\n if (!this._differ) {\n // Use a wrapper function for the `trackBy` so any new values are\n // picked up automatically without having to recreate the differ.\n this._differ = this._differs.find(this._renderedItems).create((index, item) => {\n return this.cdkVirtualForTrackBy ? this.cdkVirtualForTrackBy(index, item) : item;\n });\n }\n this._needsUpdate = true;\n }\n /** Swap out one `DataSource` for another. */\n _changeDataSource(oldDs, newDs) {\n if (oldDs) {\n oldDs.disconnect(this);\n }\n this._needsUpdate = true;\n return newDs ? newDs.connect(this) : of();\n }\n /** Update the `CdkVirtualForOfContext` for all views. */\n _updateContext() {\n const count = this._data.length;\n let i = this._viewContainerRef.length;\n while (i--) {\n const view = this._viewContainerRef.get(i);\n view.context.index = this._renderedRange.start + i;\n view.context.count = count;\n this._updateComputedContextProperties(view.context);\n view.detectChanges();\n }\n }\n /** Apply changes to the DOM. */\n _applyChanges(changes) {\n this._viewRepeater.applyChanges(changes, this._viewContainerRef, (record, _adjustedPreviousIndex, currentIndex) => this._getEmbeddedViewArgs(record, currentIndex), record => record.item);\n // Update $implicit for any items that had an identity change.\n changes.forEachIdentityChange((record) => {\n const view = this._viewContainerRef.get(record.currentIndex);\n view.context.$implicit = record.item;\n });\n // Update the context variables on all items.\n const count = this._data.length;\n let i = this._viewContainerRef.length;\n while (i--) {\n const view = this._viewContainerRef.get(i);\n view.context.index = this._renderedRange.start + i;\n view.context.count = count;\n this._updateComputedContextProperties(view.context);\n }\n }\n /** Update the computed properties on the `CdkVirtualForOfContext`. */\n _updateComputedContextProperties(context) {\n context.first = context.index === 0;\n context.last = context.index === context.count - 1;\n context.even = context.index % 2 === 0;\n context.odd = !context.even;\n }\n _getEmbeddedViewArgs(record, index) {\n // Note that it's important that we insert the item directly at the proper index,\n // rather than inserting it and the moving it in place, because if there's a directive\n // on the same node that injects the `ViewContainerRef`, Angular will insert another\n // comment node which can throw off the move when it's being repeated for all items.\n return {\n templateRef: this._template,\n context: {\n $implicit: record.item,\n // It's guaranteed that the iterable is not \"undefined\" or \"null\" because we only\n // generate views for elements if the \"cdkVirtualForOf\" iterable has elements.\n cdkVirtualForOf: this._cdkVirtualForOf,\n index: -1,\n count: -1,\n first: false,\n last: false,\n odd: false,\n even: false,\n },\n index,\n };\n }\n static ngTemplateContextGuard(directive, context) {\n return true;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualForOf, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkVirtualForOf, isStandalone: true, selector: \"[cdkVirtualFor][cdkVirtualForOf]\", inputs: { cdkVirtualForOf: \"cdkVirtualForOf\", cdkVirtualForTrackBy: \"cdkVirtualForTrackBy\", cdkVirtualForTemplate: \"cdkVirtualForTemplate\", cdkVirtualForTemplateCacheSize: \"cdkVirtualForTemplateCacheSize\" }, providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualForOf, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkVirtualFor][cdkVirtualForOf]',\n providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }],\n }]\n }], ctorParameters: () => [], propDecorators: { cdkVirtualForOf: [{\n type: Input\n }], cdkVirtualForTrackBy: [{\n type: Input\n }], cdkVirtualForTemplate: [{\n type: Input\n }], cdkVirtualForTemplateCacheSize: [{\n type: Input\n }] } });\n\n/**\n * Provides a virtual scrollable for the element it is attached to.\n */\nclass CdkVirtualScrollableElement extends CdkVirtualScrollable {\n constructor() {\n super();\n }\n measureBoundingClientRectWithScrollOffset(from) {\n return (this.getElementRef().nativeElement.getBoundingClientRect()[from] -\n this.measureScrollOffset(from));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollableElement, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkVirtualScrollableElement, isStandalone: true, selector: \"[cdkVirtualScrollingElement]\", host: { classAttribute: \"cdk-virtual-scrollable\" }, providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableElement }], usesInheritance: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollableElement, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkVirtualScrollingElement]',\n providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableElement }],\n host: {\n 'class': 'cdk-virtual-scrollable',\n },\n }]\n }], ctorParameters: () => [] });\n\n/**\n * Provides as virtual scrollable for the global / window scrollbar.\n */\nclass CdkVirtualScrollableWindow extends CdkVirtualScrollable {\n _elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(document, 'scroll').pipe(takeUntil(this._destroyed)).subscribe(observer)));\n constructor() {\n super();\n this.elementRef = new ElementRef(document.documentElement);\n }\n measureBoundingClientRectWithScrollOffset(from) {\n return this.getElementRef().nativeElement.getBoundingClientRect()[from];\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollableWindow, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkVirtualScrollableWindow, isStandalone: true, selector: \"cdk-virtual-scroll-viewport[scrollWindow]\", providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableWindow }], usesInheritance: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkVirtualScrollableWindow, decorators: [{\n type: Directive,\n args: [{\n selector: 'cdk-virtual-scroll-viewport[scrollWindow]',\n providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableWindow }],\n }]\n }], ctorParameters: () => [] });\n\nclass CdkScrollableModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkScrollableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkScrollableModule, imports: [CdkScrollable], exports: [CdkScrollable] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkScrollableModule });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkScrollableModule, decorators: [{\n type: NgModule,\n args: [{\n exports: [CdkScrollable],\n imports: [CdkScrollable],\n }]\n }] });\n/**\n * @docs-primary-export\n */\nclass ScrollingModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollingModule, imports: [BidiModule, CdkScrollableModule, CdkVirtualScrollViewport,\n CdkFixedSizeVirtualScroll,\n CdkVirtualForOf,\n CdkVirtualScrollableWindow,\n CdkVirtualScrollableElement], exports: [BidiModule, CdkScrollableModule, CdkFixedSizeVirtualScroll,\n CdkVirtualForOf,\n CdkVirtualScrollViewport,\n CdkVirtualScrollableWindow,\n CdkVirtualScrollableElement] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollingModule, imports: [BidiModule,\n CdkScrollableModule, BidiModule, CdkScrollableModule] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: ScrollingModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [\n BidiModule,\n CdkScrollableModule,\n CdkVirtualScrollViewport,\n CdkFixedSizeVirtualScroll,\n CdkVirtualForOf,\n CdkVirtualScrollableWindow,\n CdkVirtualScrollableElement,\n ],\n exports: [\n BidiModule,\n CdkScrollableModule,\n CdkFixedSizeVirtualScroll,\n CdkVirtualForOf,\n CdkVirtualScrollViewport,\n CdkVirtualScrollableWindow,\n CdkVirtualScrollableElement,\n ],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { CdkFixedSizeVirtualScroll, CdkScrollable, CdkScrollableModule, CdkVirtualForOf, CdkVirtualScrollViewport, CdkVirtualScrollable, CdkVirtualScrollableElement, CdkVirtualScrollableWindow, DEFAULT_RESIZE_TIME, DEFAULT_SCROLL_TIME, FixedSizeVirtualScrollStrategy, ScrollDispatcher, ScrollingModule, VIRTUAL_SCROLLABLE, VIRTUAL_SCROLL_STRATEGY, ViewportRuler, _fixedSizeVirtualScrollStrategyFactory };\n","import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';\nimport * as i0 from '@angular/core';\nimport { Component, ChangeDetectionStrategy, ViewEncapsulation, inject, NgZone, Injectable, ElementRef, EventEmitter, Directive, Output, Renderer2, booleanAttribute, Input, NgModule } from '@angular/core';\nimport { _CdkPrivateStyleLoader } from '@angular/cdk/private';\nimport { coerceElement, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { EMPTY, Subject, fromEvent } from 'rxjs';\nimport { DOCUMENT } from '@angular/common';\nimport { auditTime, takeUntil } from 'rxjs/operators';\n\n/** Component used to load the structural styles of the text field. */\nclass _CdkTextFieldStyleLoader {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _CdkTextFieldStyleLoader, deps: [], target: i0.ɵɵFactoryTarget.Component });\n static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: \"14.0.0\", version: \"19.0.0\", type: _CdkTextFieldStyleLoader, isStandalone: true, selector: \"ng-component\", host: { attributes: { \"cdk-text-field-style-loader\": \"\" } }, ngImport: i0, template: '', isInline: true, styles: [\"textarea.cdk-textarea-autosize{resize:none}textarea.cdk-textarea-autosize-measuring{padding:2px 0 !important;box-sizing:content-box !important;height:auto !important;overflow:hidden !important}textarea.cdk-textarea-autosize-measuring-firefox{padding:2px 0 !important;box-sizing:content-box !important;height:0 !important}@keyframes cdk-text-field-autofill-start{/*!*/}@keyframes cdk-text-field-autofill-end{/*!*/}.cdk-text-field-autofill-monitored:-webkit-autofill{animation:cdk-text-field-autofill-start 0s 1ms}.cdk-text-field-autofill-monitored:not(:-webkit-autofill){animation:cdk-text-field-autofill-end 0s 1ms}\"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: _CdkTextFieldStyleLoader, decorators: [{\n type: Component,\n args: [{ template: '', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'cdk-text-field-style-loader': '' }, styles: [\"textarea.cdk-textarea-autosize{resize:none}textarea.cdk-textarea-autosize-measuring{padding:2px 0 !important;box-sizing:content-box !important;height:auto !important;overflow:hidden !important}textarea.cdk-textarea-autosize-measuring-firefox{padding:2px 0 !important;box-sizing:content-box !important;height:0 !important}@keyframes cdk-text-field-autofill-start{/*!*/}@keyframes cdk-text-field-autofill-end{/*!*/}.cdk-text-field-autofill-monitored:-webkit-autofill{animation:cdk-text-field-autofill-start 0s 1ms}.cdk-text-field-autofill-monitored:not(:-webkit-autofill){animation:cdk-text-field-autofill-end 0s 1ms}\"] }]\n }] });\n\n/** Options to pass to the animationstart listener. */\nconst listenerOptions = normalizePassiveListenerOptions({ passive: true });\n/**\n * An injectable service that can be used to monitor the autofill state of an input.\n * Based on the following blog post:\n * https://medium.com/@brunn/detecting-autofilled-fields-in-javascript-aed598d25da7\n */\nclass AutofillMonitor {\n _platform = inject(Platform);\n _ngZone = inject(NgZone);\n _styleLoader = inject(_CdkPrivateStyleLoader);\n _monitoredElements = new Map();\n constructor() { }\n monitor(elementOrRef) {\n if (!this._platform.isBrowser) {\n return EMPTY;\n }\n this._styleLoader.load(_CdkTextFieldStyleLoader);\n const element = coerceElement(elementOrRef);\n const info = this._monitoredElements.get(element);\n if (info) {\n return info.subject;\n }\n const result = new Subject();\n const cssClass = 'cdk-text-field-autofilled';\n const listener = ((event) => {\n // Animation events fire on initial element render, we check for the presence of the autofill\n // CSS class to make sure this is a real change in state, not just the initial render before\n // we fire off events.\n if (event.animationName === 'cdk-text-field-autofill-start' &&\n !element.classList.contains(cssClass)) {\n element.classList.add(cssClass);\n this._ngZone.run(() => result.next({ target: event.target, isAutofilled: true }));\n }\n else if (event.animationName === 'cdk-text-field-autofill-end' &&\n element.classList.contains(cssClass)) {\n element.classList.remove(cssClass);\n this._ngZone.run(() => result.next({ target: event.target, isAutofilled: false }));\n }\n });\n this._ngZone.runOutsideAngular(() => {\n element.addEventListener('animationstart', listener, listenerOptions);\n element.classList.add('cdk-text-field-autofill-monitored');\n });\n this._monitoredElements.set(element, {\n subject: result,\n unlisten: () => {\n element.removeEventListener('animationstart', listener, listenerOptions);\n },\n });\n return result;\n }\n stopMonitoring(elementOrRef) {\n const element = coerceElement(elementOrRef);\n const info = this._monitoredElements.get(element);\n if (info) {\n info.unlisten();\n info.subject.complete();\n element.classList.remove('cdk-text-field-autofill-monitored');\n element.classList.remove('cdk-text-field-autofilled');\n this._monitoredElements.delete(element);\n }\n }\n ngOnDestroy() {\n this._monitoredElements.forEach((_info, element) => this.stopMonitoring(element));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: AutofillMonitor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: AutofillMonitor, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: AutofillMonitor, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/** A directive that can be used to monitor the autofill state of an input. */\nclass CdkAutofill {\n _elementRef = inject(ElementRef);\n _autofillMonitor = inject(AutofillMonitor);\n /** Emits when the autofill state of the element changes. */\n cdkAutofill = new EventEmitter();\n constructor() { }\n ngOnInit() {\n this._autofillMonitor\n .monitor(this._elementRef)\n .subscribe(event => this.cdkAutofill.emit(event));\n }\n ngOnDestroy() {\n this._autofillMonitor.stopMonitoring(this._elementRef);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkAutofill, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.0\", type: CdkAutofill, isStandalone: true, selector: \"[cdkAutofill]\", outputs: { cdkAutofill: \"cdkAutofill\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkAutofill, decorators: [{\n type: Directive,\n args: [{\n selector: '[cdkAutofill]',\n }]\n }], ctorParameters: () => [], propDecorators: { cdkAutofill: [{\n type: Output\n }] } });\n\n/** Directive to automatically resize a textarea to fit its content. */\nclass CdkTextareaAutosize {\n _elementRef = inject(ElementRef);\n _platform = inject(Platform);\n _ngZone = inject(NgZone);\n _renderer = inject(Renderer2);\n /** Keep track of the previous textarea value to avoid resizing when the value hasn't changed. */\n _previousValue;\n _initialHeight;\n _destroyed = new Subject();\n _listenerCleanups;\n _minRows;\n _maxRows;\n _enabled = true;\n /**\n * Value of minRows as of last resize. If the minRows has decreased, the\n * height of the textarea needs to be recomputed to reflect the new minimum. The maxHeight\n * does not have the same problem because it does not affect the textarea's scrollHeight.\n */\n _previousMinRows = -1;\n _textareaElement;\n /** Minimum amount of rows in the textarea. */\n get minRows() {\n return this._minRows;\n }\n set minRows(value) {\n this._minRows = coerceNumberProperty(value);\n this._setMinHeight();\n }\n /** Maximum amount of rows in the textarea. */\n get maxRows() {\n return this._maxRows;\n }\n set maxRows(value) {\n this._maxRows = coerceNumberProperty(value);\n this._setMaxHeight();\n }\n /** Whether autosizing is enabled or not */\n get enabled() {\n return this._enabled;\n }\n set enabled(value) {\n // Only act if the actual value changed. This specifically helps to not run\n // resizeToFitContent too early (i.e. before ngAfterViewInit)\n if (this._enabled !== value) {\n (this._enabled = value) ? this.resizeToFitContent(true) : this.reset();\n }\n }\n get placeholder() {\n return this._textareaElement.placeholder;\n }\n set placeholder(value) {\n this._cachedPlaceholderHeight = undefined;\n if (value) {\n this._textareaElement.setAttribute('placeholder', value);\n }\n else {\n this._textareaElement.removeAttribute('placeholder');\n }\n this._cacheTextareaPlaceholderHeight();\n }\n /** Cached height of a textarea with a single row. */\n _cachedLineHeight;\n /** Cached height of a textarea with only the placeholder. */\n _cachedPlaceholderHeight;\n /** Used to reference correct document/window */\n _document = inject(DOCUMENT, { optional: true });\n _hasFocus;\n _isViewInited = false;\n constructor() {\n const styleLoader = inject(_CdkPrivateStyleLoader);\n styleLoader.load(_CdkTextFieldStyleLoader);\n this._textareaElement = this._elementRef.nativeElement;\n }\n /** Sets the minimum height of the textarea as determined by minRows. */\n _setMinHeight() {\n const minHeight = this.minRows && this._cachedLineHeight ? `${this.minRows * this._cachedLineHeight}px` : null;\n if (minHeight) {\n this._textareaElement.style.minHeight = minHeight;\n }\n }\n /** Sets the maximum height of the textarea as determined by maxRows. */\n _setMaxHeight() {\n const maxHeight = this.maxRows && this._cachedLineHeight ? `${this.maxRows * this._cachedLineHeight}px` : null;\n if (maxHeight) {\n this._textareaElement.style.maxHeight = maxHeight;\n }\n }\n ngAfterViewInit() {\n if (this._platform.isBrowser) {\n // Remember the height which we started with in case autosizing is disabled\n this._initialHeight = this._textareaElement.style.height;\n this.resizeToFitContent();\n this._ngZone.runOutsideAngular(() => {\n const window = this._getWindow();\n fromEvent(window, 'resize')\n .pipe(auditTime(16), takeUntil(this._destroyed))\n .subscribe(() => this.resizeToFitContent(true));\n this._listenerCleanups = [\n this._renderer.listen(this._textareaElement, 'focus', this._handleFocusEvent),\n this._renderer.listen(this._textareaElement, 'blur', this._handleFocusEvent),\n ];\n });\n this._isViewInited = true;\n this.resizeToFitContent(true);\n }\n }\n ngOnDestroy() {\n this._listenerCleanups?.forEach(cleanup => cleanup());\n this._destroyed.next();\n this._destroyed.complete();\n }\n /**\n * Cache the height of a single-row textarea if it has not already been cached.\n *\n * We need to know how large a single \"row\" of a textarea is in order to apply minRows and\n * maxRows. For the initial version, we will assume that the height of a single line in the\n * textarea does not ever change.\n */\n _cacheTextareaLineHeight() {\n if (this._cachedLineHeight) {\n return;\n }\n // Use a clone element because we have to override some styles.\n let textareaClone = this._textareaElement.cloneNode(false);\n textareaClone.rows = 1;\n // Use `position: absolute` so that this doesn't cause a browser layout and use\n // `visibility: hidden` so that nothing is rendered. Clear any other styles that\n // would affect the height.\n textareaClone.style.position = 'absolute';\n textareaClone.style.visibility = 'hidden';\n textareaClone.style.border = 'none';\n textareaClone.style.padding = '0';\n textareaClone.style.height = '';\n textareaClone.style.minHeight = '';\n textareaClone.style.maxHeight = '';\n // In Firefox it happens that textarea elements are always bigger than the specified amount\n // of rows. This is because Firefox tries to add extra space for the horizontal scrollbar.\n // As a workaround that removes the extra space for the scrollbar, we can just set overflow\n // to hidden. This ensures that there is no invalid calculation of the line height.\n // See Firefox bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=33654\n textareaClone.style.overflow = 'hidden';\n this._textareaElement.parentNode.appendChild(textareaClone);\n this._cachedLineHeight = textareaClone.clientHeight;\n textareaClone.remove();\n // Min and max heights have to be re-calculated if the cached line height changes\n this._setMinHeight();\n this._setMaxHeight();\n }\n _measureScrollHeight() {\n const element = this._textareaElement;\n const previousMargin = element.style.marginBottom || '';\n const isFirefox = this._platform.FIREFOX;\n const needsMarginFiller = isFirefox && this._hasFocus;\n const measuringClass = isFirefox\n ? 'cdk-textarea-autosize-measuring-firefox'\n : 'cdk-textarea-autosize-measuring';\n // In some cases the page might move around while we're measuring the `textarea` on Firefox. We\n // work around it by assigning a temporary margin with the same height as the `textarea` so that\n // it occupies the same amount of space. See #23233.\n if (needsMarginFiller) {\n element.style.marginBottom = `${element.clientHeight}px`;\n }\n // Reset the textarea height to auto in order to shrink back to its default size.\n // Also temporarily force overflow:hidden, so scroll bars do not interfere with calculations.\n element.classList.add(measuringClass);\n // The measuring class includes a 2px padding to workaround an issue with Chrome,\n // so we account for that extra space here by subtracting 4 (2px top + 2px bottom).\n const scrollHeight = element.scrollHeight - 4;\n element.classList.remove(measuringClass);\n if (needsMarginFiller) {\n element.style.marginBottom = previousMargin;\n }\n return scrollHeight;\n }\n _cacheTextareaPlaceholderHeight() {\n if (!this._isViewInited || this._cachedPlaceholderHeight != undefined) {\n return;\n }\n if (!this.placeholder) {\n this._cachedPlaceholderHeight = 0;\n return;\n }\n const value = this._textareaElement.value;\n this._textareaElement.value = this._textareaElement.placeholder;\n this._cachedPlaceholderHeight = this._measureScrollHeight();\n this._textareaElement.value = value;\n }\n /** Handles `focus` and `blur` events. */\n _handleFocusEvent = (event) => {\n this._hasFocus = event.type === 'focus';\n };\n ngDoCheck() {\n if (this._platform.isBrowser) {\n this.resizeToFitContent();\n }\n }\n /**\n * Resize the textarea to fit its content.\n * @param force Whether to force a height recalculation. By default the height will be\n * recalculated only if the value changed since the last call.\n */\n resizeToFitContent(force = false) {\n // If autosizing is disabled, just skip everything else\n if (!this._enabled) {\n return;\n }\n this._cacheTextareaLineHeight();\n this._cacheTextareaPlaceholderHeight();\n // If we haven't determined the line-height yet, we know we're still hidden and there's no point\n // in checking the height of the textarea.\n if (!this._cachedLineHeight) {\n return;\n }\n const textarea = this._elementRef.nativeElement;\n const value = textarea.value;\n // Only resize if the value or minRows have changed since these calculations can be expensive.\n if (!force && this._minRows === this._previousMinRows && value === this._previousValue) {\n return;\n }\n const scrollHeight = this._measureScrollHeight();\n const height = Math.max(scrollHeight, this._cachedPlaceholderHeight || 0);\n // Use the scrollHeight to know how large the textarea *would* be if fit its entire value.\n textarea.style.height = `${height}px`;\n this._ngZone.runOutsideAngular(() => {\n if (typeof requestAnimationFrame !== 'undefined') {\n requestAnimationFrame(() => this._scrollToCaretPosition(textarea));\n }\n else {\n setTimeout(() => this._scrollToCaretPosition(textarea));\n }\n });\n this._previousValue = value;\n this._previousMinRows = this._minRows;\n }\n /**\n * Resets the textarea to its original size\n */\n reset() {\n // Do not try to change the textarea, if the initialHeight has not been determined yet\n // This might potentially remove styles when reset() is called before ngAfterViewInit\n if (this._initialHeight !== undefined) {\n this._textareaElement.style.height = this._initialHeight;\n }\n }\n _noopInputHandler() {\n // no-op handler that ensures we're running change detection on input events.\n }\n /** Access injected document if available or fallback to global document reference */\n _getDocument() {\n return this._document || document;\n }\n /** Use defaultView of injected document if available or fallback to global window reference */\n _getWindow() {\n const doc = this._getDocument();\n return doc.defaultView || window;\n }\n /**\n * Scrolls a textarea to the caret position. On Firefox resizing the textarea will\n * prevent it from scrolling to the caret position. We need to re-set the selection\n * in order for it to scroll to the proper position.\n */\n _scrollToCaretPosition(textarea) {\n const { selectionStart, selectionEnd } = textarea;\n // IE will throw an \"Unspecified error\" if we try to set the selection range after the\n // element has been removed from the DOM. Assert that the directive hasn't been destroyed\n // between the time we requested the animation frame and when it was executed.\n // Also note that we have to assert that the textarea is focused before we set the\n // selection range. Setting the selection range on a non-focused textarea will cause\n // it to receive focus on IE and Edge.\n if (!this._destroyed.isStopped && this._hasFocus) {\n textarea.setSelectionRange(selectionStart, selectionEnd);\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkTextareaAutosize, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.0\", type: CdkTextareaAutosize, isStandalone: true, selector: \"textarea[cdkTextareaAutosize]\", inputs: { minRows: [\"cdkAutosizeMinRows\", \"minRows\"], maxRows: [\"cdkAutosizeMaxRows\", \"maxRows\"], enabled: [\"cdkTextareaAutosize\", \"enabled\", booleanAttribute], placeholder: \"placeholder\" }, host: { attributes: { \"rows\": \"1\" }, listeners: { \"input\": \"_noopInputHandler()\" }, classAttribute: \"cdk-textarea-autosize\" }, exportAs: [\"cdkTextareaAutosize\"], ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: CdkTextareaAutosize, decorators: [{\n type: Directive,\n args: [{\n selector: 'textarea[cdkTextareaAutosize]',\n exportAs: 'cdkTextareaAutosize',\n host: {\n 'class': 'cdk-textarea-autosize',\n // Textarea elements that have the directive applied should have a single row by default.\n // Browsers normally show two rows by default and therefore this limits the minRows binding.\n 'rows': '1',\n '(input)': '_noopInputHandler()',\n },\n }]\n }], ctorParameters: () => [], propDecorators: { minRows: [{\n type: Input,\n args: ['cdkAutosizeMinRows']\n }], maxRows: [{\n type: Input,\n args: ['cdkAutosizeMaxRows']\n }], enabled: [{\n type: Input,\n args: [{ alias: 'cdkTextareaAutosize', transform: booleanAttribute }]\n }], placeholder: [{\n type: Input\n }] } });\n\nclass TextFieldModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: TextFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.0\", ngImport: i0, type: TextFieldModule, imports: [CdkAutofill, CdkTextareaAutosize], exports: [CdkAutofill, CdkTextareaAutosize] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: TextFieldModule });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.0\", ngImport: i0, type: TextFieldModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [CdkAutofill, CdkTextareaAutosize],\n exports: [CdkAutofill, CdkTextareaAutosize],\n }]\n }] });\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { AutofillMonitor, CdkAutofill, CdkTextareaAutosize, TextFieldModule };\n","/**\n * @license Angular v19.0.6\n * (c) 2010-2024 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport * as i0 from '@angular/core';\nimport { Injectable, InjectionToken, inject, Optional, Inject, ɵɵinject, ɵfindLocaleData, ɵLocaleDataIndex, ɵgetLocaleCurrencyCode, ɵgetLocalePluralCase, LOCALE_ID, ɵregisterLocaleData, ɵstringify, Directive, Input, createNgModule, NgModuleRef, ɵRuntimeError, Host, Attribute, RendererStyleFlags2, untracked, ɵisPromise, ɵisSubscribable, Pipe, DEFAULT_CURRENCY_CODE, NgModule, Version, ɵɵdefineInjectable, PLATFORM_ID, ɵformatRuntimeError, ɵIMAGE_CONFIG, Renderer2, ElementRef, Injector, ɵperformanceMarkFeature, NgZone, ApplicationRef, ChangeDetectorRef, numberAttribute, booleanAttribute, ɵIMAGE_CONFIG_DEFAULTS, ɵunwrapSafeValue } from '@angular/core';\nexport { ɵIMAGE_CONFIG as IMAGE_CONFIG } from '@angular/core';\nimport { Subject } from 'rxjs';\n\nlet _DOM = null;\nfunction getDOM() {\n return _DOM;\n}\nfunction setRootDomAdapter(adapter) {\n _DOM ??= adapter;\n}\n/**\n * Provides DOM operations in an environment-agnostic way.\n *\n * @security Tread carefully! Interacting with the DOM directly is dangerous and\n * can introduce XSS risks.\n */\nclass DomAdapter {\n}\n\n/**\n * This class wraps the platform Navigation API which allows server-specific and test\n * implementations.\n */\nclass PlatformNavigation {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PlatformNavigation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PlatformNavigation, providedIn: 'platform', useFactory: () => window.navigation });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PlatformNavigation, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'platform', useFactory: () => window.navigation }]\n }] });\n\n/**\n * A DI Token representing the main rendering context.\n * In a browser and SSR this is the DOM Document.\n * When using SSR, that document is created by [Domino](https://github.com/angular/domino).\n *\n * @publicApi\n */\nconst DOCUMENT = new InjectionToken(ngDevMode ? 'DocumentToken' : '');\n\n/**\n * This class should not be used directly by an application developer. Instead, use\n * {@link Location}.\n *\n * `PlatformLocation` encapsulates all calls to DOM APIs, which allows the Router to be\n * platform-agnostic.\n * This means that we can have different implementation of `PlatformLocation` for the different\n * platforms that Angular supports. For example, `@angular/platform-browser` provides an\n * implementation specific to the browser environment, while `@angular/platform-server` provides\n * one suitable for use with server-side rendering.\n *\n * The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}\n * when they need to interact with the DOM APIs like pushState, popState, etc.\n *\n * {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly\n * by the {@link Router} in order to navigate between routes. Since all interactions between {@link\n * Router} /\n * {@link Location} / {@link LocationStrategy} and DOM APIs flow through the `PlatformLocation`\n * class, they are all platform-agnostic.\n *\n * @publicApi\n */\nclass PlatformLocation {\n historyGo(relativePosition) {\n throw new Error(ngDevMode ? 'Not implemented' : '');\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PlatformLocation, providedIn: 'platform', useFactory: () => inject(BrowserPlatformLocation) });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PlatformLocation, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'platform', useFactory: () => inject(BrowserPlatformLocation) }]\n }] });\n/**\n * @description\n * Indicates when a location is initialized.\n *\n * @publicApi\n */\nconst LOCATION_INITIALIZED = new InjectionToken(ngDevMode ? 'Location Initialized' : '');\n/**\n * `PlatformLocation` encapsulates all of the direct calls to platform APIs.\n * This class should not be used directly by an application developer. Instead, use\n * {@link Location}.\n *\n * @publicApi\n */\nclass BrowserPlatformLocation extends PlatformLocation {\n _location;\n _history;\n _doc = inject(DOCUMENT);\n constructor() {\n super();\n this._location = window.location;\n this._history = window.history;\n }\n getBaseHrefFromDOM() {\n return getDOM().getBaseHref(this._doc);\n }\n onPopState(fn) {\n const window = getDOM().getGlobalEventTarget(this._doc, 'window');\n window.addEventListener('popstate', fn, false);\n return () => window.removeEventListener('popstate', fn);\n }\n onHashChange(fn) {\n const window = getDOM().getGlobalEventTarget(this._doc, 'window');\n window.addEventListener('hashchange', fn, false);\n return () => window.removeEventListener('hashchange', fn);\n }\n get href() {\n return this._location.href;\n }\n get protocol() {\n return this._location.protocol;\n }\n get hostname() {\n return this._location.hostname;\n }\n get port() {\n return this._location.port;\n }\n get pathname() {\n return this._location.pathname;\n }\n get search() {\n return this._location.search;\n }\n get hash() {\n return this._location.hash;\n }\n set pathname(newPath) {\n this._location.pathname = newPath;\n }\n pushState(state, title, url) {\n this._history.pushState(state, title, url);\n }\n replaceState(state, title, url) {\n this._history.replaceState(state, title, url);\n }\n forward() {\n this._history.forward();\n }\n back() {\n this._history.back();\n }\n historyGo(relativePosition = 0) {\n this._history.go(relativePosition);\n }\n getState() {\n return this._history.state;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserPlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserPlatformLocation, providedIn: 'platform', useFactory: () => new BrowserPlatformLocation() });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: BrowserPlatformLocation, decorators: [{\n type: Injectable,\n args: [{\n providedIn: 'platform',\n useFactory: () => new BrowserPlatformLocation(),\n }]\n }], ctorParameters: () => [] });\n\n/**\n * Joins two parts of a URL with a slash if needed.\n *\n * @param start URL string\n * @param end URL string\n *\n *\n * @returns The joined URL string.\n */\nfunction joinWithSlash(start, end) {\n if (start.length == 0) {\n return end;\n }\n if (end.length == 0) {\n return start;\n }\n let slashes = 0;\n if (start.endsWith('/')) {\n slashes++;\n }\n if (end.startsWith('/')) {\n slashes++;\n }\n if (slashes == 2) {\n return start + end.substring(1);\n }\n if (slashes == 1) {\n return start + end;\n }\n return start + '/' + end;\n}\n/**\n * Removes a trailing slash from a URL string if needed.\n * Looks for the first occurrence of either `#`, `?`, or the end of the\n * line as `/` characters and removes the trailing slash if one exists.\n *\n * @param url URL string.\n *\n * @returns The URL string, modified if needed.\n */\nfunction stripTrailingSlash(url) {\n const match = url.match(/#|\\?|$/);\n const pathEndIdx = (match && match.index) || url.length;\n const droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);\n return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);\n}\n/**\n * Normalizes URL parameters by prepending with `?` if needed.\n *\n * @param params String of URL parameters.\n *\n * @returns The normalized URL parameters string.\n */\nfunction normalizeQueryParams(params) {\n return params && params[0] !== '?' ? '?' + params : params;\n}\n\n/**\n * Enables the `Location` service to read route state from the browser's URL.\n * Angular provides two strategies:\n * `HashLocationStrategy` and `PathLocationStrategy`.\n *\n * Applications should use the `Router` or `Location` services to\n * interact with application route state.\n *\n * For instance, `HashLocationStrategy` produces URLs like\n * http://example.com/#/foo,\n * and `PathLocationStrategy` produces\n * http://example.com/foo as an equivalent URL.\n *\n * See these two classes for more.\n *\n * @publicApi\n */\nclass LocationStrategy {\n historyGo(relativePosition) {\n throw new Error(ngDevMode ? 'Not implemented' : '');\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LocationStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LocationStrategy, providedIn: 'root', useFactory: () => inject(PathLocationStrategy) });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LocationStrategy, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root', useFactory: () => inject(PathLocationStrategy) }]\n }] });\n/**\n * A predefined DI token for the base href\n * to be used with the `PathLocationStrategy`.\n * The base href is the URL prefix that should be preserved when generating\n * and recognizing URLs.\n *\n * @usageNotes\n *\n * The following example shows how to use this token to configure the root app injector\n * with a base href value, so that the DI framework can supply the dependency anywhere in the app.\n *\n * ```ts\n * import {NgModule} from '@angular/core';\n * import {APP_BASE_HREF} from '@angular/common';\n *\n * @NgModule({\n * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]\n * })\n * class AppModule {}\n * ```\n *\n * @publicApi\n */\nconst APP_BASE_HREF = new InjectionToken(ngDevMode ? 'appBaseHref' : '');\n/**\n * @description\n * A {@link LocationStrategy} used to configure the {@link Location} service to\n * represent its state in the\n * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the\n * browser's URL.\n *\n * If you're using `PathLocationStrategy`, you may provide a {@link APP_BASE_HREF}\n * or add a `` element to the document to override the default.\n *\n * For instance, if you provide an `APP_BASE_HREF` of `'/my/app/'` and call\n * `location.go('/foo')`, the browser's URL will become\n * `example.com/my/app/foo`. To ensure all relative URIs resolve correctly,\n * the `` and/or `APP_BASE_HREF` should end with a `/`.\n *\n * Similarly, if you add `` to the document and call\n * `location.go('/foo')`, the browser's URL will become\n * `example.com/my/app/foo`.\n *\n * Note that when using `PathLocationStrategy`, neither the query nor\n * the fragment in the `` will be preserved, as outlined\n * by the [RFC](https://tools.ietf.org/html/rfc3986#section-5.2.2).\n *\n * @usageNotes\n *\n * ### Example\n *\n * {@example common/location/ts/path_location_component.ts region='LocationComponent'}\n *\n * @publicApi\n */\nclass PathLocationStrategy extends LocationStrategy {\n _platformLocation;\n _baseHref;\n _removeListenerFns = [];\n constructor(_platformLocation, href) {\n super();\n this._platformLocation = _platformLocation;\n this._baseHref =\n href ??\n this._platformLocation.getBaseHrefFromDOM() ??\n inject(DOCUMENT).location?.origin ??\n '';\n }\n /** @nodoc */\n ngOnDestroy() {\n while (this._removeListenerFns.length) {\n this._removeListenerFns.pop()();\n }\n }\n onPopState(fn) {\n this._removeListenerFns.push(this._platformLocation.onPopState(fn), this._platformLocation.onHashChange(fn));\n }\n getBaseHref() {\n return this._baseHref;\n }\n prepareExternalUrl(internal) {\n return joinWithSlash(this._baseHref, internal);\n }\n path(includeHash = false) {\n const pathname = this._platformLocation.pathname + normalizeQueryParams(this._platformLocation.search);\n const hash = this._platformLocation.hash;\n return hash && includeHash ? `${pathname}${hash}` : pathname;\n }\n pushState(state, title, url, queryParams) {\n const externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams));\n this._platformLocation.pushState(state, title, externalUrl);\n }\n replaceState(state, title, url, queryParams) {\n const externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams));\n this._platformLocation.replaceState(state, title, externalUrl);\n }\n forward() {\n this._platformLocation.forward();\n }\n back() {\n this._platformLocation.back();\n }\n getState() {\n return this._platformLocation.getState();\n }\n historyGo(relativePosition = 0) {\n this._platformLocation.historyGo?.(relativePosition);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PathLocationStrategy, deps: [{ token: PlatformLocation }, { token: APP_BASE_HREF, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PathLocationStrategy, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PathLocationStrategy, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [{ type: PlatformLocation }, { type: undefined, decorators: [{\n type: Optional\n }, {\n type: Inject,\n args: [APP_BASE_HREF]\n }] }] });\n\n/**\n * @description\n * A {@link LocationStrategy} used to configure the {@link Location} service to\n * represent its state in the\n * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)\n * of the browser's URL.\n *\n * For instance, if you call `location.go('/foo')`, the browser's URL will become\n * `example.com#/foo`.\n *\n * @usageNotes\n *\n * ### Example\n *\n * {@example common/location/ts/hash_location_component.ts region='LocationComponent'}\n *\n * @publicApi\n */\nclass HashLocationStrategy extends LocationStrategy {\n _platformLocation;\n _baseHref = '';\n _removeListenerFns = [];\n constructor(_platformLocation, _baseHref) {\n super();\n this._platformLocation = _platformLocation;\n if (_baseHref != null) {\n this._baseHref = _baseHref;\n }\n }\n /** @nodoc */\n ngOnDestroy() {\n while (this._removeListenerFns.length) {\n this._removeListenerFns.pop()();\n }\n }\n onPopState(fn) {\n this._removeListenerFns.push(this._platformLocation.onPopState(fn), this._platformLocation.onHashChange(fn));\n }\n getBaseHref() {\n return this._baseHref;\n }\n path(includeHash = false) {\n // the hash value is always prefixed with a `#`\n // and if it is empty then it will stay empty\n const path = this._platformLocation.hash ?? '#';\n return path.length > 0 ? path.substring(1) : path;\n }\n prepareExternalUrl(internal) {\n const url = joinWithSlash(this._baseHref, internal);\n return url.length > 0 ? '#' + url : url;\n }\n pushState(state, title, path, queryParams) {\n let url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams));\n if (url.length == 0) {\n url = this._platformLocation.pathname;\n }\n this._platformLocation.pushState(state, title, url);\n }\n replaceState(state, title, path, queryParams) {\n let url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams));\n if (url.length == 0) {\n url = this._platformLocation.pathname;\n }\n this._platformLocation.replaceState(state, title, url);\n }\n forward() {\n this._platformLocation.forward();\n }\n back() {\n this._platformLocation.back();\n }\n getState() {\n return this._platformLocation.getState();\n }\n historyGo(relativePosition = 0) {\n this._platformLocation.historyGo?.(relativePosition);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HashLocationStrategy, deps: [{ token: PlatformLocation }, { token: APP_BASE_HREF, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HashLocationStrategy });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HashLocationStrategy, decorators: [{\n type: Injectable\n }], ctorParameters: () => [{ type: PlatformLocation }, { type: undefined, decorators: [{\n type: Optional\n }, {\n type: Inject,\n args: [APP_BASE_HREF]\n }] }] });\n\n/**\n * @description\n *\n * A service that applications can use to interact with a browser's URL.\n *\n * Depending on the `LocationStrategy` used, `Location` persists\n * to the URL's path or the URL's hash segment.\n *\n * @usageNotes\n *\n * It's better to use the `Router.navigate()` service to trigger route changes. Use\n * `Location` only if you need to interact with or create normalized URLs outside of\n * routing.\n *\n * `Location` is responsible for normalizing the URL against the application's base href.\n * A normalized URL is absolute from the URL host, includes the application's base href, and has no\n * trailing slash:\n * - `/my/app/user/123` is normalized\n * - `my/app/user/123` **is not** normalized\n * - `/my/app/user/123/` **is not** normalized\n *\n * ### Example\n *\n * {@example common/location/ts/path_location_component.ts region='LocationComponent'}\n *\n * @publicApi\n */\nclass Location {\n /** @internal */\n _subject = new Subject();\n /** @internal */\n _basePath;\n /** @internal */\n _locationStrategy;\n /** @internal */\n _urlChangeListeners = [];\n /** @internal */\n _urlChangeSubscription = null;\n constructor(locationStrategy) {\n this._locationStrategy = locationStrategy;\n const baseHref = this._locationStrategy.getBaseHref();\n // Note: This class's interaction with base HREF does not fully follow the rules\n // outlined in the spec https://www.freesoft.org/CIE/RFC/1808/18.htm.\n // Instead of trying to fix individual bugs with more and more code, we should\n // investigate using the URL constructor and providing the base as a second\n // argument.\n // https://developer.mozilla.org/en-US/docs/Web/API/URL/URL#parameters\n this._basePath = _stripOrigin(stripTrailingSlash(_stripIndexHtml(baseHref)));\n this._locationStrategy.onPopState((ev) => {\n this._subject.next({\n 'url': this.path(true),\n 'pop': true,\n 'state': ev.state,\n 'type': ev.type,\n });\n });\n }\n /** @nodoc */\n ngOnDestroy() {\n this._urlChangeSubscription?.unsubscribe();\n this._urlChangeListeners = [];\n }\n /**\n * Normalizes the URL path for this location.\n *\n * @param includeHash True to include an anchor fragment in the path.\n *\n * @returns The normalized URL path.\n */\n // TODO: vsavkin. Remove the boolean flag and always include hash once the deprecated router is\n // removed.\n path(includeHash = false) {\n return this.normalize(this._locationStrategy.path(includeHash));\n }\n /**\n * Reports the current state of the location history.\n * @returns The current value of the `history.state` object.\n */\n getState() {\n return this._locationStrategy.getState();\n }\n /**\n * Normalizes the given path and compares to the current normalized path.\n *\n * @param path The given URL path.\n * @param query Query parameters.\n *\n * @returns True if the given URL path is equal to the current normalized path, false\n * otherwise.\n */\n isCurrentPathEqualTo(path, query = '') {\n return this.path() == this.normalize(path + normalizeQueryParams(query));\n }\n /**\n * Normalizes a URL path by stripping any trailing slashes.\n *\n * @param url String representing a URL.\n *\n * @returns The normalized URL string.\n */\n normalize(url) {\n return Location.stripTrailingSlash(_stripBasePath(this._basePath, _stripIndexHtml(url)));\n }\n /**\n * Normalizes an external URL path.\n * If the given URL doesn't begin with a leading slash (`'/'`), adds one\n * before normalizing. Adds a hash if `HashLocationStrategy` is\n * in use, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.\n *\n * @param url String representing a URL.\n *\n * @returns A normalized platform-specific URL.\n */\n prepareExternalUrl(url) {\n if (url && url[0] !== '/') {\n url = '/' + url;\n }\n return this._locationStrategy.prepareExternalUrl(url);\n }\n // TODO: rename this method to pushState\n /**\n * Changes the browser's URL to a normalized version of a given URL, and pushes a\n * new item onto the platform's history.\n *\n * @param path URL path to normalize.\n * @param query Query parameters.\n * @param state Location history state.\n *\n */\n go(path, query = '', state = null) {\n this._locationStrategy.pushState(state, '', path, query);\n this._notifyUrlChangeListeners(this.prepareExternalUrl(path + normalizeQueryParams(query)), state);\n }\n /**\n * Changes the browser's URL to a normalized version of the given URL, and replaces\n * the top item on the platform's history stack.\n *\n * @param path URL path to normalize.\n * @param query Query parameters.\n * @param state Location history state.\n */\n replaceState(path, query = '', state = null) {\n this._locationStrategy.replaceState(state, '', path, query);\n this._notifyUrlChangeListeners(this.prepareExternalUrl(path + normalizeQueryParams(query)), state);\n }\n /**\n * Navigates forward in the platform's history.\n */\n forward() {\n this._locationStrategy.forward();\n }\n /**\n * Navigates back in the platform's history.\n */\n back() {\n this._locationStrategy.back();\n }\n /**\n * Navigate to a specific page from session history, identified by its relative position to the\n * current page.\n *\n * @param relativePosition Position of the target page in the history relative to the current\n * page.\n * A negative value moves backwards, a positive value moves forwards, e.g. `location.historyGo(2)`\n * moves forward two pages and `location.historyGo(-2)` moves back two pages. When we try to go\n * beyond what's stored in the history session, we stay in the current page. Same behaviour occurs\n * when `relativePosition` equals 0.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/History_API#Moving_to_a_specific_point_in_history\n */\n historyGo(relativePosition = 0) {\n this._locationStrategy.historyGo?.(relativePosition);\n }\n /**\n * Registers a URL change listener. Use to catch updates performed by the Angular\n * framework that are not detectible through \"popstate\" or \"hashchange\" events.\n *\n * @param fn The change handler function, which take a URL and a location history state.\n * @returns A function that, when executed, unregisters a URL change listener.\n */\n onUrlChange(fn) {\n this._urlChangeListeners.push(fn);\n this._urlChangeSubscription ??= this.subscribe((v) => {\n this._notifyUrlChangeListeners(v.url, v.state);\n });\n return () => {\n const fnIndex = this._urlChangeListeners.indexOf(fn);\n this._urlChangeListeners.splice(fnIndex, 1);\n if (this._urlChangeListeners.length === 0) {\n this._urlChangeSubscription?.unsubscribe();\n this._urlChangeSubscription = null;\n }\n };\n }\n /** @internal */\n _notifyUrlChangeListeners(url = '', state) {\n this._urlChangeListeners.forEach((fn) => fn(url, state));\n }\n /**\n * Subscribes to the platform's `popState` events.\n *\n * Note: `Location.go()` does not trigger the `popState` event in the browser. Use\n * `Location.onUrlChange()` to subscribe to URL changes instead.\n *\n * @param value Event that is triggered when the state history changes.\n * @param exception The exception to throw.\n *\n * @see [onpopstate](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate)\n *\n * @returns Subscribed events.\n */\n subscribe(onNext, onThrow, onReturn) {\n return this._subject.subscribe({\n next: onNext,\n error: onThrow ?? undefined,\n complete: onReturn ?? undefined,\n });\n }\n /**\n * Normalizes URL parameters by prepending with `?` if needed.\n *\n * @param params String of URL parameters.\n *\n * @returns The normalized URL parameters string.\n */\n static normalizeQueryParams = normalizeQueryParams;\n /**\n * Joins two parts of a URL with a slash if needed.\n *\n * @param start URL string\n * @param end URL string\n *\n *\n * @returns The joined URL string.\n */\n static joinWithSlash = joinWithSlash;\n /**\n * Removes a trailing slash from a URL string if needed.\n * Looks for the first occurrence of either `#`, `?`, or the end of the\n * line as `/` characters and removes the trailing slash if one exists.\n *\n * @param url URL string.\n *\n * @returns The URL string, modified if needed.\n */\n static stripTrailingSlash = stripTrailingSlash;\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: Location, deps: [{ token: LocationStrategy }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: Location, providedIn: 'root', useFactory: createLocation });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: Location, decorators: [{\n type: Injectable,\n args: [{\n providedIn: 'root',\n // See #23917\n useFactory: createLocation,\n }]\n }], ctorParameters: () => [{ type: LocationStrategy }] });\nfunction createLocation() {\n return new Location(ɵɵinject(LocationStrategy));\n}\nfunction _stripBasePath(basePath, url) {\n if (!basePath || !url.startsWith(basePath)) {\n return url;\n }\n const strippedUrl = url.substring(basePath.length);\n if (strippedUrl === '' || ['/', ';', '?', '#'].includes(strippedUrl[0])) {\n return strippedUrl;\n }\n return url;\n}\nfunction _stripIndexHtml(url) {\n return url.replace(/\\/index.html$/, '');\n}\nfunction _stripOrigin(baseHref) {\n // DO NOT REFACTOR! Previously, this check looked like this:\n // `/^(https?:)?\\/\\//.test(baseHref)`, but that resulted in\n // syntactically incorrect code after Closure Compiler minification.\n // This was likely caused by a bug in Closure Compiler, but\n // for now, the check is rewritten to use `new RegExp` instead.\n const isAbsoluteUrl = new RegExp('^(https?:)?//').test(baseHref);\n if (isAbsoluteUrl) {\n const [, pathname] = baseHref.split(/\\/\\/[^\\/]+/);\n return pathname;\n }\n return baseHref;\n}\n\n/** @internal */\nconst CURRENCIES_EN = { \"ADP\": [undefined, undefined, 0], \"AFN\": [undefined, \"؋\", 0], \"ALL\": [undefined, undefined, 0], \"AMD\": [undefined, \"֏\", 2], \"AOA\": [undefined, \"Kz\"], \"ARS\": [undefined, \"$\"], \"AUD\": [\"A$\", \"$\"], \"AZN\": [undefined, \"₼\"], \"BAM\": [undefined, \"KM\"], \"BBD\": [undefined, \"$\"], \"BDT\": [undefined, \"৳\"], \"BHD\": [undefined, undefined, 3], \"BIF\": [undefined, undefined, 0], \"BMD\": [undefined, \"$\"], \"BND\": [undefined, \"$\"], \"BOB\": [undefined, \"Bs\"], \"BRL\": [\"R$\"], \"BSD\": [undefined, \"$\"], \"BWP\": [undefined, \"P\"], \"BYN\": [undefined, undefined, 2], \"BYR\": [undefined, undefined, 0], \"BZD\": [undefined, \"$\"], \"CAD\": [\"CA$\", \"$\", 2], \"CHF\": [undefined, undefined, 2], \"CLF\": [undefined, undefined, 4], \"CLP\": [undefined, \"$\", 0], \"CNY\": [\"CN¥\", \"¥\"], \"COP\": [undefined, \"$\", 2], \"CRC\": [undefined, \"₡\", 2], \"CUC\": [undefined, \"$\"], \"CUP\": [undefined, \"$\"], \"CZK\": [undefined, \"Kč\", 2], \"DJF\": [undefined, undefined, 0], \"DKK\": [undefined, \"kr\", 2], \"DOP\": [undefined, \"$\"], \"EGP\": [undefined, \"E£\"], \"ESP\": [undefined, \"₧\", 0], \"EUR\": [\"€\"], \"FJD\": [undefined, \"$\"], \"FKP\": [undefined, \"£\"], \"GBP\": [\"£\"], \"GEL\": [undefined, \"₾\"], \"GHS\": [undefined, \"GH₵\"], \"GIP\": [undefined, \"£\"], \"GNF\": [undefined, \"FG\", 0], \"GTQ\": [undefined, \"Q\"], \"GYD\": [undefined, \"$\", 2], \"HKD\": [\"HK$\", \"$\"], \"HNL\": [undefined, \"L\"], \"HRK\": [undefined, \"kn\"], \"HUF\": [undefined, \"Ft\", 2], \"IDR\": [undefined, \"Rp\", 2], \"ILS\": [\"₪\"], \"INR\": [\"₹\"], \"IQD\": [undefined, undefined, 0], \"IRR\": [undefined, undefined, 0], \"ISK\": [undefined, \"kr\", 0], \"ITL\": [undefined, undefined, 0], \"JMD\": [undefined, \"$\"], \"JOD\": [undefined, undefined, 3], \"JPY\": [\"¥\", undefined, 0], \"KHR\": [undefined, \"៛\"], \"KMF\": [undefined, \"CF\", 0], \"KPW\": [undefined, \"₩\", 0], \"KRW\": [\"₩\", undefined, 0], \"KWD\": [undefined, undefined, 3], \"KYD\": [undefined, \"$\"], \"KZT\": [undefined, \"₸\"], \"LAK\": [undefined, \"₭\", 0], \"LBP\": [undefined, \"L£\", 0], \"LKR\": [undefined, \"Rs\"], \"LRD\": [undefined, \"$\"], \"LTL\": [undefined, \"Lt\"], \"LUF\": [undefined, undefined, 0], \"LVL\": [undefined, \"Ls\"], \"LYD\": [undefined, undefined, 3], \"MGA\": [undefined, \"Ar\", 0], \"MGF\": [undefined, undefined, 0], \"MMK\": [undefined, \"K\", 0], \"MNT\": [undefined, \"₮\", 2], \"MRO\": [undefined, undefined, 0], \"MUR\": [undefined, \"Rs\", 2], \"MXN\": [\"MX$\", \"$\"], \"MYR\": [undefined, \"RM\"], \"NAD\": [undefined, \"$\"], \"NGN\": [undefined, \"₦\"], \"NIO\": [undefined, \"C$\"], \"NOK\": [undefined, \"kr\", 2], \"NPR\": [undefined, \"Rs\"], \"NZD\": [\"NZ$\", \"$\"], \"OMR\": [undefined, undefined, 3], \"PHP\": [\"₱\"], \"PKR\": [undefined, \"Rs\", 2], \"PLN\": [undefined, \"zł\"], \"PYG\": [undefined, \"₲\", 0], \"RON\": [undefined, \"lei\"], \"RSD\": [undefined, undefined, 0], \"RUB\": [undefined, \"₽\"], \"RWF\": [undefined, \"RF\", 0], \"SBD\": [undefined, \"$\"], \"SEK\": [undefined, \"kr\", 2], \"SGD\": [undefined, \"$\"], \"SHP\": [undefined, \"£\"], \"SLE\": [undefined, undefined, 2], \"SLL\": [undefined, undefined, 0], \"SOS\": [undefined, undefined, 0], \"SRD\": [undefined, \"$\"], \"SSP\": [undefined, \"£\"], \"STD\": [undefined, undefined, 0], \"STN\": [undefined, \"Db\"], \"SYP\": [undefined, \"£\", 0], \"THB\": [undefined, \"฿\"], \"TMM\": [undefined, undefined, 0], \"TND\": [undefined, undefined, 3], \"TOP\": [undefined, \"T$\"], \"TRL\": [undefined, undefined, 0], \"TRY\": [undefined, \"₺\"], \"TTD\": [undefined, \"$\"], \"TWD\": [\"NT$\", \"$\", 2], \"TZS\": [undefined, undefined, 2], \"UAH\": [undefined, \"₴\"], \"UGX\": [undefined, undefined, 0], \"USD\": [\"$\"], \"UYI\": [undefined, undefined, 0], \"UYU\": [undefined, \"$\"], \"UYW\": [undefined, undefined, 4], \"UZS\": [undefined, undefined, 2], \"VEF\": [undefined, \"Bs\", 2], \"VND\": [\"₫\", undefined, 0], \"VUV\": [undefined, undefined, 0], \"XAF\": [\"FCFA\", undefined, 0], \"XCD\": [\"EC$\", \"$\"], \"XOF\": [\"F CFA\", undefined, 0], \"XPF\": [\"CFPF\", undefined, 0], \"XXX\": [\"¤\"], \"YER\": [undefined, undefined, 0], \"ZAR\": [undefined, \"R\"], \"ZMK\": [undefined, undefined, 0], \"ZMW\": [undefined, \"ZK\"], \"ZWD\": [undefined, undefined, 0] };\n\n/**\n * Format styles that can be used to represent numbers.\n * @see {@link getLocaleNumberFormat}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated `getLocaleNumberFormat` is deprecated\n */\nvar NumberFormatStyle;\n(function (NumberFormatStyle) {\n NumberFormatStyle[NumberFormatStyle[\"Decimal\"] = 0] = \"Decimal\";\n NumberFormatStyle[NumberFormatStyle[\"Percent\"] = 1] = \"Percent\";\n NumberFormatStyle[NumberFormatStyle[\"Currency\"] = 2] = \"Currency\";\n NumberFormatStyle[NumberFormatStyle[\"Scientific\"] = 3] = \"Scientific\";\n})(NumberFormatStyle || (NumberFormatStyle = {}));\n/**\n * Plurality cases used for translating plurals to different languages.\n *\n * @see {@link NgPlural}\n * @see {@link NgPluralCase}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated `getLocalePluralCase` is deprecated\n */\nvar Plural;\n(function (Plural) {\n Plural[Plural[\"Zero\"] = 0] = \"Zero\";\n Plural[Plural[\"One\"] = 1] = \"One\";\n Plural[Plural[\"Two\"] = 2] = \"Two\";\n Plural[Plural[\"Few\"] = 3] = \"Few\";\n Plural[Plural[\"Many\"] = 4] = \"Many\";\n Plural[Plural[\"Other\"] = 5] = \"Other\";\n})(Plural || (Plural = {}));\n/**\n * Context-dependant translation forms for strings.\n * Typically the standalone version is for the nominative form of the word,\n * and the format version is used for the genitive case.\n * @see [CLDR website](http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles)\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated locale data getters are deprecated\n */\nvar FormStyle;\n(function (FormStyle) {\n FormStyle[FormStyle[\"Format\"] = 0] = \"Format\";\n FormStyle[FormStyle[\"Standalone\"] = 1] = \"Standalone\";\n})(FormStyle || (FormStyle = {}));\n/**\n * String widths available for translations.\n * The specific character widths are locale-specific.\n * Examples are given for the word \"Sunday\" in English.\n *\n * @publicApi\n *\n * @deprecated locale data getters are deprecated\n */\nvar TranslationWidth;\n(function (TranslationWidth) {\n /** 1 character for `en-US`. For example: 'S' */\n TranslationWidth[TranslationWidth[\"Narrow\"] = 0] = \"Narrow\";\n /** 3 characters for `en-US`. For example: 'Sun' */\n TranslationWidth[TranslationWidth[\"Abbreviated\"] = 1] = \"Abbreviated\";\n /** Full length for `en-US`. For example: \"Sunday\" */\n TranslationWidth[TranslationWidth[\"Wide\"] = 2] = \"Wide\";\n /** 2 characters for `en-US`, For example: \"Su\" */\n TranslationWidth[TranslationWidth[\"Short\"] = 3] = \"Short\";\n})(TranslationWidth || (TranslationWidth = {}));\n/**\n * String widths available for date-time formats.\n * The specific character widths are locale-specific.\n * Examples are given for `en-US`.\n *\n * @see {@link getLocaleDateFormat}\n * @see {@link getLocaleTimeFormat}\n * @see {@link getLocaleDateTimeFormat}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n * @publicApi\n *\n * @deprecated Date locale data getters are deprecated\n */\nvar FormatWidth;\n(function (FormatWidth) {\n /**\n * For `en-US`, `'M/d/yy, h:mm a'`\n * (Example: `6/15/15, 9:03 AM`)\n */\n FormatWidth[FormatWidth[\"Short\"] = 0] = \"Short\";\n /**\n * For `en-US`, `'MMM d, y, h:mm:ss a'`\n * (Example: `Jun 15, 2015, 9:03:01 AM`)\n */\n FormatWidth[FormatWidth[\"Medium\"] = 1] = \"Medium\";\n /**\n * For `en-US`, `'MMMM d, y, h:mm:ss a z'`\n * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`)\n */\n FormatWidth[FormatWidth[\"Long\"] = 2] = \"Long\";\n /**\n * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'`\n * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`)\n */\n FormatWidth[FormatWidth[\"Full\"] = 3] = \"Full\";\n})(FormatWidth || (FormatWidth = {}));\n// This needs to be an object literal, rather than an enum, because TypeScript 5.4+\n// doesn't allow numeric keys and we have `Infinity` and `NaN`.\n/**\n * Symbols that can be used to replace placeholders in number patterns.\n * Examples are based on `en-US` values.\n *\n * @see {@link getLocaleNumberSymbol}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated `getLocaleNumberSymbol` is deprecated\n *\n * @object-literal-as-enum\n */\nconst NumberSymbol = {\n /**\n * Decimal separator.\n * For `en-US`, the dot character.\n * Example: 2,345`.`67\n */\n Decimal: 0,\n /**\n * Grouping separator, typically for thousands.\n * For `en-US`, the comma character.\n * Example: 2`,`345.67\n */\n Group: 1,\n /**\n * List-item separator.\n * Example: \"one, two, and three\"\n */\n List: 2,\n /**\n * Sign for percentage (out of 100).\n * Example: 23.4%\n */\n PercentSign: 3,\n /**\n * Sign for positive numbers.\n * Example: +23\n */\n PlusSign: 4,\n /**\n * Sign for negative numbers.\n * Example: -23\n */\n MinusSign: 5,\n /**\n * Computer notation for exponential value (n times a power of 10).\n * Example: 1.2E3\n */\n Exponential: 6,\n /**\n * Human-readable format of exponential.\n * Example: 1.2x103\n */\n SuperscriptingExponent: 7,\n /**\n * Sign for permille (out of 1000).\n * Example: 23.4‰\n */\n PerMille: 8,\n /**\n * Infinity, can be used with plus and minus.\n * Example: ∞, +∞, -∞\n */\n Infinity: 9,\n /**\n * Not a number.\n * Example: NaN\n */\n NaN: 10,\n /**\n * Symbol used between time units.\n * Example: 10:52\n */\n TimeSeparator: 11,\n /**\n * Decimal separator for currency values (fallback to `Decimal`).\n * Example: $2,345.67\n */\n CurrencyDecimal: 12,\n /**\n * Group separator for currency values (fallback to `Group`).\n * Example: $2,345.67\n */\n CurrencyGroup: 13,\n};\n/**\n * The value for each day of the week, based on the `en-US` locale\n *\n * @publicApi\n *\n * @deprecated Week locale getters are deprecated\n */\nvar WeekDay;\n(function (WeekDay) {\n WeekDay[WeekDay[\"Sunday\"] = 0] = \"Sunday\";\n WeekDay[WeekDay[\"Monday\"] = 1] = \"Monday\";\n WeekDay[WeekDay[\"Tuesday\"] = 2] = \"Tuesday\";\n WeekDay[WeekDay[\"Wednesday\"] = 3] = \"Wednesday\";\n WeekDay[WeekDay[\"Thursday\"] = 4] = \"Thursday\";\n WeekDay[WeekDay[\"Friday\"] = 5] = \"Friday\";\n WeekDay[WeekDay[\"Saturday\"] = 6] = \"Saturday\";\n})(WeekDay || (WeekDay = {}));\n/**\n * Retrieves the locale ID from the currently loaded locale.\n * The loaded locale could be, for example, a global one rather than a regional one.\n * @param locale A locale code, such as `fr-FR`.\n * @returns The locale code. For example, `fr`.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * This function serves no purpose when relying on the `Intl` API.\n */\nfunction getLocaleId(locale) {\n return ɵfindLocaleData(locale)[ɵLocaleDataIndex.LocaleId];\n}\n/**\n * Retrieves day period strings for the given locale.\n *\n * @param locale A locale code for the locale format rules to use.\n * @param formStyle The required grammatical form.\n * @param width The required character width.\n * @returns An array of localized period strings. For example, `[AM, PM]` for `en-US`.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.DateTimeFormat` for date formating instead.\n */\nfunction getLocaleDayPeriods(locale, formStyle, width) {\n const data = ɵfindLocaleData(locale);\n const amPmData = [\n data[ɵLocaleDataIndex.DayPeriodsFormat],\n data[ɵLocaleDataIndex.DayPeriodsStandalone],\n ];\n const amPm = getLastDefinedValue(amPmData, formStyle);\n return getLastDefinedValue(amPm, width);\n}\n/**\n * Retrieves days of the week for the given locale, using the Gregorian calendar.\n *\n * @param locale A locale code for the locale format rules to use.\n * @param formStyle The required grammatical form.\n * @param width The required character width.\n * @returns An array of localized name strings.\n * For example,`[Sunday, Monday, ... Saturday]` for `en-US`.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.DateTimeFormat` for date formating instead.\n */\nfunction getLocaleDayNames(locale, formStyle, width) {\n const data = ɵfindLocaleData(locale);\n const daysData = [\n data[ɵLocaleDataIndex.DaysFormat],\n data[ɵLocaleDataIndex.DaysStandalone],\n ];\n const days = getLastDefinedValue(daysData, formStyle);\n return getLastDefinedValue(days, width);\n}\n/**\n * Retrieves months of the year for the given locale, using the Gregorian calendar.\n *\n * @param locale A locale code for the locale format rules to use.\n * @param formStyle The required grammatical form.\n * @param width The required character width.\n * @returns An array of localized name strings.\n * For example, `[January, February, ...]` for `en-US`.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.DateTimeFormat` for date formating instead.\n */\nfunction getLocaleMonthNames(locale, formStyle, width) {\n const data = ɵfindLocaleData(locale);\n const monthsData = [\n data[ɵLocaleDataIndex.MonthsFormat],\n data[ɵLocaleDataIndex.MonthsStandalone],\n ];\n const months = getLastDefinedValue(monthsData, formStyle);\n return getLastDefinedValue(months, width);\n}\n/**\n * Retrieves Gregorian-calendar eras for the given locale.\n * @param locale A locale code for the locale format rules to use.\n * @param width The required character width.\n\n * @returns An array of localized era strings.\n * For example, `[AD, BC]` for `en-US`.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.DateTimeFormat` for date formating instead.\n */\nfunction getLocaleEraNames(locale, width) {\n const data = ɵfindLocaleData(locale);\n const erasData = data[ɵLocaleDataIndex.Eras];\n return getLastDefinedValue(erasData, width);\n}\n/**\n * Retrieves the first day of the week for the given locale.\n *\n * @param locale A locale code for the locale format rules to use.\n * @returns A day index number, using the 0-based week-day index for `en-US`\n * (Sunday = 0, Monday = 1, ...).\n * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).\n * You may want to rely on the following alternatives:\n * - Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (monday) if `getWeekInfo` is not supported.\n * - Other librairies like [`date-fns`](https://date-fns.org/), [`day.js`](https://day.js.org/en/) or [`weekstart`](https://www.npmjs.com/package/weekstart) library provide their own locale based data for the first day of the week.\n */\nfunction getLocaleFirstDayOfWeek(locale) {\n const data = ɵfindLocaleData(locale);\n return data[ɵLocaleDataIndex.FirstDayOfWeek];\n}\n/**\n * Range of week days that are considered the week-end for the given locale.\n *\n * @param locale A locale code for the locale format rules to use.\n * @returns The range of day values, `[startDay, endDay]`.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Intl's [`getWeekInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) has partial support (Chromium M99 & Safari 17).\n * Libraries like [`Luxon`](https://moment.github.io/luxon/#/) rely on `Intl` but fallback on the ISO 8601 definition (Saturday+Sunday) if `getWeekInfo` is not supported .\n */\nfunction getLocaleWeekEndRange(locale) {\n const data = ɵfindLocaleData(locale);\n return data[ɵLocaleDataIndex.WeekendRange];\n}\n/**\n * Retrieves a localized date-value formatting string.\n *\n * @param locale A locale code for the locale format rules to use.\n * @param width The format type.\n * @returns The localized formatting string.\n * @see {@link FormatWidth}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.DateTimeFormat` for date formating instead.\n */\nfunction getLocaleDateFormat(locale, width) {\n const data = ɵfindLocaleData(locale);\n return getLastDefinedValue(data[ɵLocaleDataIndex.DateFormat], width);\n}\n/**\n * Retrieves a localized time-value formatting string.\n *\n * @param locale A locale code for the locale format rules to use.\n * @param width The format type.\n * @returns The localized formatting string.\n * @see {@link FormatWidth}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n\n * @publicApi\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.DateTimeFormat` for date formating instead.\n */\nfunction getLocaleTimeFormat(locale, width) {\n const data = ɵfindLocaleData(locale);\n return getLastDefinedValue(data[ɵLocaleDataIndex.TimeFormat], width);\n}\n/**\n * Retrieves a localized date-time formatting string.\n *\n * @param locale A locale code for the locale format rules to use.\n * @param width The format type.\n * @returns The localized formatting string.\n * @see {@link FormatWidth}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.DateTimeFormat` for date formating instead.\n */\nfunction getLocaleDateTimeFormat(locale, width) {\n const data = ɵfindLocaleData(locale);\n const dateTimeFormatData = data[ɵLocaleDataIndex.DateTimeFormat];\n return getLastDefinedValue(dateTimeFormatData, width);\n}\n/**\n * Retrieves a localized number symbol that can be used to replace placeholders in number formats.\n * @param locale The locale code.\n * @param symbol The symbol to localize. Must be one of `NumberSymbol`.\n * @returns The character for the localized symbol.\n * @see {@link NumberSymbol}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.NumberFormat` to format numbers instead.\n */\nfunction getLocaleNumberSymbol(locale, symbol) {\n const data = ɵfindLocaleData(locale);\n const res = data[ɵLocaleDataIndex.NumberSymbols][symbol];\n if (typeof res === 'undefined') {\n if (symbol === NumberSymbol.CurrencyDecimal) {\n return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];\n }\n else if (symbol === NumberSymbol.CurrencyGroup) {\n return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Group];\n }\n }\n return res;\n}\n/**\n * Retrieves a number format for a given locale.\n *\n * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`\n * when used to format the number 12345.678 could result in \"12'345,678\". That would happen if the\n * grouping separator for your language is an apostrophe, and the decimal separator is a comma.\n *\n * Important: The characters `.` `,` `0` `#` (and others below) are special placeholders\n * that stand for the decimal separator, and so on, and are NOT real characters.\n * You must NOT \"translate\" the placeholders. For example, don't change `.` to `,` even though in\n * your language the decimal point is written with a comma. The symbols should be replaced by the\n * local equivalents, using the appropriate `NumberSymbol` for your language.\n *\n * Here are the special characters used in number patterns:\n *\n * | Symbol | Meaning |\n * |--------|---------|\n * | . | Replaced automatically by the character used for the decimal point. |\n * | , | Replaced by the \"grouping\" (thousands) separator. |\n * | 0 | Replaced by a digit (or zero if there aren't enough digits). |\n * | # | Replaced by a digit (or nothing if there aren't enough). |\n * | ¤ | Replaced by a currency symbol, such as $ or USD. |\n * | % | Marks a percent format. The % symbol may change position, but must be retained. |\n * | E | Marks a scientific format. The E symbol may change position, but must be retained. |\n * | ' | Special characters used as literal characters are quoted with ASCII single quotes. |\n *\n * @param locale A locale code for the locale format rules to use.\n * @param type The type of numeric value to be formatted (such as `Decimal` or `Currency`.)\n * @returns The localized format string.\n * @see {@link NumberFormatStyle}\n * @see [CLDR website](http://cldr.unicode.org/translation/number-patterns)\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Let `Intl.NumberFormat` determine the number format instead\n */\nfunction getLocaleNumberFormat(locale, type) {\n const data = ɵfindLocaleData(locale);\n return data[ɵLocaleDataIndex.NumberFormats][type];\n}\n/**\n * Retrieves the symbol used to represent the currency for the main country\n * corresponding to a given locale. For example, '$' for `en-US`.\n *\n * @param locale A locale code for the locale format rules to use.\n * @returns The localized symbol character,\n * or `null` if the main country cannot be determined.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Use the `Intl` API to format a currency with from currency code\n */\nfunction getLocaleCurrencySymbol(locale) {\n const data = ɵfindLocaleData(locale);\n return data[ɵLocaleDataIndex.CurrencySymbol] || null;\n}\n/**\n * Retrieves the name of the currency for the main country corresponding\n * to a given locale. For example, 'US Dollar' for `en-US`.\n * @param locale A locale code for the locale format rules to use.\n * @returns The currency name,\n * or `null` if the main country cannot be determined.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Use the `Intl` API to format a currency with from currency code\n */\nfunction getLocaleCurrencyName(locale) {\n const data = ɵfindLocaleData(locale);\n return data[ɵLocaleDataIndex.CurrencyName] || null;\n}\n/**\n * Retrieves the default currency code for the given locale.\n *\n * The default is defined as the first currency which is still in use.\n *\n * @param locale The code of the locale whose currency code we want.\n * @returns The code of the default currency for the given locale.\n *\n * @publicApi\n *\n * @deprecated We recommend you create a map of locale to ISO 4217 currency codes.\n * Time relative currency data is provided by the CLDR project. See https://www.unicode.org/cldr/charts/44/supplemental/detailed_territory_currency_information.html\n */\nfunction getLocaleCurrencyCode(locale) {\n return ɵgetLocaleCurrencyCode(locale);\n}\n/**\n * Retrieves the currency values for a given locale.\n * @param locale A locale code for the locale format rules to use.\n * @returns The currency values.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n */\nfunction getLocaleCurrencies(locale) {\n const data = ɵfindLocaleData(locale);\n return data[ɵLocaleDataIndex.Currencies];\n}\n/**\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Use `Intl.PluralRules` instead\n */\nconst getLocalePluralCase = ɵgetLocalePluralCase;\nfunction checkFullData(data) {\n if (!data[ɵLocaleDataIndex.ExtraData]) {\n throw new Error(`Missing extra locale data for the locale \"${data[ɵLocaleDataIndex.LocaleId]}\". Use \"registerLocaleData\" to load new data. See the \"I18n guide\" on angular.io to know more.`);\n }\n}\n/**\n * Retrieves locale-specific rules used to determine which day period to use\n * when more than one period is defined for a locale.\n *\n * There is a rule for each defined day period. The\n * first rule is applied to the first day period and so on.\n * Fall back to AM/PM when no rules are available.\n *\n * A rule can specify a period as time range, or as a single time value.\n *\n * This functionality is only available when you have loaded the full locale data.\n * See the [\"I18n guide\"](guide/i18n/format-data-locale).\n *\n * @param locale A locale code for the locale format rules to use.\n * @returns The rules for the locale, a single time value or array of *from-time, to-time*,\n * or null if no periods are available.\n *\n * @see {@link getLocaleExtraDayPeriods}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * Let `Intl.DateTimeFormat` determine the day period instead.\n */\nfunction getLocaleExtraDayPeriodRules(locale) {\n const data = ɵfindLocaleData(locale);\n checkFullData(data);\n const rules = data[ɵLocaleDataIndex.ExtraData][2 /* ɵExtraLocaleDataIndex.ExtraDayPeriodsRules */] || [];\n return rules.map((rule) => {\n if (typeof rule === 'string') {\n return extractTime(rule);\n }\n return [extractTime(rule[0]), extractTime(rule[1])];\n });\n}\n/**\n * Retrieves locale-specific day periods, which indicate roughly how a day is broken up\n * in different languages.\n * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.\n *\n * This functionality is only available when you have loaded the full locale data.\n * See the [\"I18n guide\"](guide/i18n/format-data-locale).\n *\n * @param locale A locale code for the locale format rules to use.\n * @param formStyle The required grammatical form.\n * @param width The required character width.\n * @returns The translated day-period strings.\n * @see {@link getLocaleExtraDayPeriodRules}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * To extract a day period use `Intl.DateTimeFormat` with the `dayPeriod` option instead.\n */\nfunction getLocaleExtraDayPeriods(locale, formStyle, width) {\n const data = ɵfindLocaleData(locale);\n checkFullData(data);\n const dayPeriodsData = [\n data[ɵLocaleDataIndex.ExtraData][0 /* ɵExtraLocaleDataIndex.ExtraDayPeriodFormats */],\n data[ɵLocaleDataIndex.ExtraData][1 /* ɵExtraLocaleDataIndex.ExtraDayPeriodStandalone */],\n ];\n const dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];\n return getLastDefinedValue(dayPeriods, width) || [];\n}\n/**\n * Retrieves the writing direction of a specified locale\n * @param locale A locale code for the locale format rules to use.\n * @publicApi\n * @returns 'rtl' or 'ltr'\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * For dates and numbers, let `Intl.DateTimeFormat()` and `Intl.NumberFormat()` determine the writing direction.\n * The `Intl` alternative [`getTextInfo`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo).\n * has only partial support (Chromium M99 & Safari 17).\n * 3rd party alternatives like [`rtl-detect`](https://www.npmjs.com/package/rtl-detect) can work around this issue.\n */\nfunction getLocaleDirection(locale) {\n const data = ɵfindLocaleData(locale);\n return data[ɵLocaleDataIndex.Directionality];\n}\n/**\n * Retrieves the first value that is defined in an array, going backwards from an index position.\n *\n * To avoid repeating the same data (as when the \"format\" and \"standalone\" forms are the same)\n * add the first value to the locale data arrays, and add other values only if they are different.\n *\n * @param data The data array to retrieve from.\n * @param index A 0-based index into the array to start from.\n * @returns The value immediately before the given index position.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n */\nfunction getLastDefinedValue(data, index) {\n for (let i = index; i > -1; i--) {\n if (typeof data[i] !== 'undefined') {\n return data[i];\n }\n }\n throw new Error('Locale data API: locale data undefined');\n}\n/**\n * Extracts the hours and minutes from a string like \"15:45\"\n */\nfunction extractTime(time) {\n const [h, m] = time.split(':');\n return { hours: +h, minutes: +m };\n}\n/**\n * Retrieves the currency symbol for a given currency code.\n *\n * For example, for the default `en-US` locale, the code `USD` can\n * be represented by the narrow symbol `$` or the wide symbol `US$`.\n *\n * @param code The currency code.\n * @param format The format, `wide` or `narrow`.\n * @param locale A locale code for the locale format rules to use.\n *\n * @returns The symbol, or the currency code if no symbol is available.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * You can use `Intl.NumberFormat().formatToParts()` to extract the currency symbol.\n * For example: `Intl.NumberFormat('en', {style:'currency', currency: 'USD'}).formatToParts().find(part => part.type === 'currency').value`\n * returns `$` for USD currency code in the `en` locale.\n * Note: `US$` is a currency symbol for the `en-ca` locale but not the `en-us` locale.\n */\nfunction getCurrencySymbol(code, format, locale = 'en') {\n const currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];\n const symbolNarrow = currency[1 /* ɵCurrencyIndex.SymbolNarrow */];\n if (format === 'narrow' && typeof symbolNarrow === 'string') {\n return symbolNarrow;\n }\n return currency[0 /* ɵCurrencyIndex.Symbol */] || code;\n}\n// Most currencies have cents, that's why the default is 2\nconst DEFAULT_NB_OF_CURRENCY_DIGITS = 2;\n/**\n * Reports the number of decimal digits for a given currency.\n * The value depends upon the presence of cents in that particular currency.\n *\n * @param code The currency code.\n * @returns The number of decimal digits, typically 0 or 2.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n *\n * @deprecated Angular recommends relying on the `Intl` API for i18n.\n * This function should not be used anymore. Let `Intl.NumberFormat` determine the number of digits to display for the currency\n */\nfunction getNumberOfCurrencyDigits(code) {\n let digits;\n const currency = CURRENCIES_EN[code];\n if (currency) {\n digits = currency[2 /* ɵCurrencyIndex.NbOfDigits */];\n }\n return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS;\n}\n\nconst ISO8601_DATE_REGEX = /^(\\d{4,})-?(\\d\\d)-?(\\d\\d)(?:T(\\d\\d)(?::?(\\d\\d)(?::?(\\d\\d)(?:\\.(\\d+))?)?)?(Z|([+-])(\\d\\d):?(\\d\\d))?)?$/;\n// 1 2 3 4 5 6 7 8 9 10 11\nconst NAMED_FORMATS = {};\nconst DATE_FORMATS_SPLIT = /((?:[^BEGHLMOSWYZabcdhmswyz']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|Y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{1,6}|c{1,6}|a{1,5}|b{1,5}|B{1,5}|h{1,2}|H{1,2}|m{1,2}|s{1,2}|S{1,3}|z{1,4}|Z{1,5}|O{1,4}))([\\s\\S]*)/;\nvar ZoneWidth;\n(function (ZoneWidth) {\n ZoneWidth[ZoneWidth[\"Short\"] = 0] = \"Short\";\n ZoneWidth[ZoneWidth[\"ShortGMT\"] = 1] = \"ShortGMT\";\n ZoneWidth[ZoneWidth[\"Long\"] = 2] = \"Long\";\n ZoneWidth[ZoneWidth[\"Extended\"] = 3] = \"Extended\";\n})(ZoneWidth || (ZoneWidth = {}));\nvar DateType;\n(function (DateType) {\n DateType[DateType[\"FullYear\"] = 0] = \"FullYear\";\n DateType[DateType[\"Month\"] = 1] = \"Month\";\n DateType[DateType[\"Date\"] = 2] = \"Date\";\n DateType[DateType[\"Hours\"] = 3] = \"Hours\";\n DateType[DateType[\"Minutes\"] = 4] = \"Minutes\";\n DateType[DateType[\"Seconds\"] = 5] = \"Seconds\";\n DateType[DateType[\"FractionalSeconds\"] = 6] = \"FractionalSeconds\";\n DateType[DateType[\"Day\"] = 7] = \"Day\";\n})(DateType || (DateType = {}));\nvar TranslationType;\n(function (TranslationType) {\n TranslationType[TranslationType[\"DayPeriods\"] = 0] = \"DayPeriods\";\n TranslationType[TranslationType[\"Days\"] = 1] = \"Days\";\n TranslationType[TranslationType[\"Months\"] = 2] = \"Months\";\n TranslationType[TranslationType[\"Eras\"] = 3] = \"Eras\";\n})(TranslationType || (TranslationType = {}));\n/**\n * @ngModule CommonModule\n * @description\n *\n * Formats a date according to locale rules.\n *\n * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch)\n * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).\n * @param format The date-time components to include. See `DatePipe` for details.\n * @param locale A locale code for the locale format rules to use.\n * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`).\n * If not specified, uses host system settings.\n *\n * @returns The formatted date string.\n *\n * @see {@link DatePipe}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n */\nfunction formatDate(value, format, locale, timezone) {\n let date = toDate(value);\n const namedFormat = getNamedFormat(locale, format);\n format = namedFormat || format;\n let parts = [];\n let match;\n while (format) {\n match = DATE_FORMATS_SPLIT.exec(format);\n if (match) {\n parts = parts.concat(match.slice(1));\n const part = parts.pop();\n if (!part) {\n break;\n }\n format = part;\n }\n else {\n parts.push(format);\n break;\n }\n }\n let dateTimezoneOffset = date.getTimezoneOffset();\n if (timezone) {\n dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);\n date = convertTimezoneToLocal(date, timezone, true);\n }\n let text = '';\n parts.forEach((value) => {\n const dateFormatter = getDateFormatter(value);\n text += dateFormatter\n ? dateFormatter(date, locale, dateTimezoneOffset)\n : value === \"''\"\n ? \"'\"\n : value.replace(/(^'|'$)/g, '').replace(/''/g, \"'\");\n });\n return text;\n}\n/**\n * Create a new Date object with the given date value, and the time set to midnight.\n *\n * We cannot use `new Date(year, month, date)` because it maps years between 0 and 99 to 1900-1999.\n * See: https://github.com/angular/angular/issues/40377\n *\n * Note that this function returns a Date object whose time is midnight in the current locale's\n * timezone. In the future we might want to change this to be midnight in UTC, but this would be a\n * considerable breaking change.\n */\nfunction createDate(year, month, date) {\n // The `newDate` is set to midnight (UTC) on January 1st 1970.\n // - In PST this will be December 31st 1969 at 4pm.\n // - In GMT this will be January 1st 1970 at 1am.\n // Note that they even have different years, dates and months!\n const newDate = new Date(0);\n // `setFullYear()` allows years like 0001 to be set correctly. This function does not\n // change the internal time of the date.\n // Consider calling `setFullYear(2019, 8, 20)` (September 20, 2019).\n // - In PST this will now be September 20, 2019 at 4pm\n // - In GMT this will now be September 20, 2019 at 1am\n newDate.setFullYear(year, month, date);\n // We want the final date to be at local midnight, so we reset the time.\n // - In PST this will now be September 20, 2019 at 12am\n // - In GMT this will now be September 20, 2019 at 12am\n newDate.setHours(0, 0, 0);\n return newDate;\n}\nfunction getNamedFormat(locale, format) {\n const localeId = getLocaleId(locale);\n NAMED_FORMATS[localeId] ??= {};\n if (NAMED_FORMATS[localeId][format]) {\n return NAMED_FORMATS[localeId][format];\n }\n let formatValue = '';\n switch (format) {\n case 'shortDate':\n formatValue = getLocaleDateFormat(locale, FormatWidth.Short);\n break;\n case 'mediumDate':\n formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);\n break;\n case 'longDate':\n formatValue = getLocaleDateFormat(locale, FormatWidth.Long);\n break;\n case 'fullDate':\n formatValue = getLocaleDateFormat(locale, FormatWidth.Full);\n break;\n case 'shortTime':\n formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);\n break;\n case 'mediumTime':\n formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);\n break;\n case 'longTime':\n formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);\n break;\n case 'fullTime':\n formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);\n break;\n case 'short':\n const shortTime = getNamedFormat(locale, 'shortTime');\n const shortDate = getNamedFormat(locale, 'shortDate');\n formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [\n shortTime,\n shortDate,\n ]);\n break;\n case 'medium':\n const mediumTime = getNamedFormat(locale, 'mediumTime');\n const mediumDate = getNamedFormat(locale, 'mediumDate');\n formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [\n mediumTime,\n mediumDate,\n ]);\n break;\n case 'long':\n const longTime = getNamedFormat(locale, 'longTime');\n const longDate = getNamedFormat(locale, 'longDate');\n formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [\n longTime,\n longDate,\n ]);\n break;\n case 'full':\n const fullTime = getNamedFormat(locale, 'fullTime');\n const fullDate = getNamedFormat(locale, 'fullDate');\n formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [\n fullTime,\n fullDate,\n ]);\n break;\n }\n if (formatValue) {\n NAMED_FORMATS[localeId][format] = formatValue;\n }\n return formatValue;\n}\nfunction formatDateTime(str, opt_values) {\n if (opt_values) {\n str = str.replace(/\\{([^}]+)}/g, function (match, key) {\n return opt_values != null && key in opt_values ? opt_values[key] : match;\n });\n }\n return str;\n}\nfunction padNumber(num, digits, minusSign = '-', trim, negWrap) {\n let neg = '';\n if (num < 0 || (negWrap && num <= 0)) {\n if (negWrap) {\n num = -num + 1;\n }\n else {\n num = -num;\n neg = minusSign;\n }\n }\n let strNum = String(num);\n while (strNum.length < digits) {\n strNum = '0' + strNum;\n }\n if (trim) {\n strNum = strNum.slice(strNum.length - digits);\n }\n return neg + strNum;\n}\nfunction formatFractionalSeconds(milliseconds, digits) {\n const strMs = padNumber(milliseconds, 3);\n return strMs.substring(0, digits);\n}\n/**\n * Returns a date formatter that transforms a date into its locale digit representation\n */\nfunction dateGetter(name, size, offset = 0, trim = false, negWrap = false) {\n return function (date, locale) {\n let part = getDatePart(name, date);\n if (offset > 0 || part > -offset) {\n part += offset;\n }\n if (name === DateType.Hours) {\n if (part === 0 && offset === -12) {\n part = 12;\n }\n }\n else if (name === DateType.FractionalSeconds) {\n return formatFractionalSeconds(part, size);\n }\n const localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);\n return padNumber(part, size, localeMinus, trim, negWrap);\n };\n}\nfunction getDatePart(part, date) {\n switch (part) {\n case DateType.FullYear:\n return date.getFullYear();\n case DateType.Month:\n return date.getMonth();\n case DateType.Date:\n return date.getDate();\n case DateType.Hours:\n return date.getHours();\n case DateType.Minutes:\n return date.getMinutes();\n case DateType.Seconds:\n return date.getSeconds();\n case DateType.FractionalSeconds:\n return date.getMilliseconds();\n case DateType.Day:\n return date.getDay();\n default:\n throw new Error(`Unknown DateType value \"${part}\".`);\n }\n}\n/**\n * Returns a date formatter that transforms a date into its locale string representation\n */\nfunction dateStrGetter(name, width, form = FormStyle.Format, extended = false) {\n return function (date, locale) {\n return getDateTranslation(date, locale, name, width, form, extended);\n };\n}\n/**\n * Returns the locale translation of a date for a given form, type and width\n */\nfunction getDateTranslation(date, locale, name, width, form, extended) {\n switch (name) {\n case TranslationType.Months:\n return getLocaleMonthNames(locale, form, width)[date.getMonth()];\n case TranslationType.Days:\n return getLocaleDayNames(locale, form, width)[date.getDay()];\n case TranslationType.DayPeriods:\n const currentHours = date.getHours();\n const currentMinutes = date.getMinutes();\n if (extended) {\n const rules = getLocaleExtraDayPeriodRules(locale);\n const dayPeriods = getLocaleExtraDayPeriods(locale, form, width);\n const index = rules.findIndex((rule) => {\n if (Array.isArray(rule)) {\n // morning, afternoon, evening, night\n const [from, to] = rule;\n const afterFrom = currentHours >= from.hours && currentMinutes >= from.minutes;\n const beforeTo = currentHours < to.hours || (currentHours === to.hours && currentMinutes < to.minutes);\n // We must account for normal rules that span a period during the day (e.g. 6am-9am)\n // where `from` is less (earlier) than `to`. But also rules that span midnight (e.g.\n // 10pm - 5am) where `from` is greater (later!) than `to`.\n //\n // In the first case the current time must be BOTH after `from` AND before `to`\n // (e.g. 8am is after 6am AND before 10am).\n //\n // In the second case the current time must be EITHER after `from` OR before `to`\n // (e.g. 4am is before 5am but not after 10pm; and 11pm is not before 5am but it is\n // after 10pm).\n if (from.hours < to.hours) {\n if (afterFrom && beforeTo) {\n return true;\n }\n }\n else if (afterFrom || beforeTo) {\n return true;\n }\n }\n else {\n // noon or midnight\n if (rule.hours === currentHours && rule.minutes === currentMinutes) {\n return true;\n }\n }\n return false;\n });\n if (index !== -1) {\n return dayPeriods[index];\n }\n }\n // if no rules for the day periods, we use am/pm by default\n return getLocaleDayPeriods(locale, form, width)[currentHours < 12 ? 0 : 1];\n case TranslationType.Eras:\n return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1];\n default:\n // This default case is not needed by TypeScript compiler, as the switch is exhaustive.\n // However Closure Compiler does not understand that and reports an error in typed mode.\n // The `throw new Error` below works around the problem, and the unexpected: never variable\n // makes sure tsc still checks this code is unreachable.\n const unexpected = name;\n throw new Error(`unexpected translation type ${unexpected}`);\n }\n}\n/**\n * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or\n * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,\n * extended = +04:30)\n */\nfunction timeZoneGetter(width) {\n return function (date, locale, offset) {\n const zone = -1 * offset;\n const minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);\n const hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);\n switch (width) {\n case ZoneWidth.Short:\n return ((zone >= 0 ? '+' : '') +\n padNumber(hours, 2, minusSign) +\n padNumber(Math.abs(zone % 60), 2, minusSign));\n case ZoneWidth.ShortGMT:\n return 'GMT' + (zone >= 0 ? '+' : '') + padNumber(hours, 1, minusSign);\n case ZoneWidth.Long:\n return ('GMT' +\n (zone >= 0 ? '+' : '') +\n padNumber(hours, 2, minusSign) +\n ':' +\n padNumber(Math.abs(zone % 60), 2, minusSign));\n case ZoneWidth.Extended:\n if (offset === 0) {\n return 'Z';\n }\n else {\n return ((zone >= 0 ? '+' : '') +\n padNumber(hours, 2, minusSign) +\n ':' +\n padNumber(Math.abs(zone % 60), 2, minusSign));\n }\n default:\n throw new Error(`Unknown zone width \"${width}\"`);\n }\n };\n}\nconst JANUARY = 0;\nconst THURSDAY = 4;\nfunction getFirstThursdayOfYear(year) {\n const firstDayOfYear = createDate(year, JANUARY, 1).getDay();\n return createDate(year, 0, 1 + (firstDayOfYear <= THURSDAY ? THURSDAY : THURSDAY + 7) - firstDayOfYear);\n}\n/**\n * ISO Week starts on day 1 (Monday) and ends with day 0 (Sunday)\n */\nfunction getThursdayThisIsoWeek(datetime) {\n // getDay returns 0-6 range with sunday as 0.\n const currentDay = datetime.getDay();\n // On a Sunday, read the previous Thursday since ISO weeks start on Monday.\n const deltaToThursday = currentDay === 0 ? -3 : THURSDAY - currentDay;\n return createDate(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + deltaToThursday);\n}\nfunction weekGetter(size, monthBased = false) {\n return function (date, locale) {\n let result;\n if (monthBased) {\n const nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;\n const today = date.getDate();\n result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);\n }\n else {\n const thisThurs = getThursdayThisIsoWeek(date);\n // Some days of a year are part of next year according to ISO 8601.\n // Compute the firstThurs from the year of this week's Thursday\n const firstThurs = getFirstThursdayOfYear(thisThurs.getFullYear());\n const diff = thisThurs.getTime() - firstThurs.getTime();\n result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week\n }\n return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));\n };\n}\n/**\n * Returns a date formatter that provides the week-numbering year for the input date.\n */\nfunction weekNumberingYearGetter(size, trim = false) {\n return function (date, locale) {\n const thisThurs = getThursdayThisIsoWeek(date);\n const weekNumberingYear = thisThurs.getFullYear();\n return padNumber(weekNumberingYear, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign), trim);\n };\n}\nconst DATE_FORMATS = {};\n// Based on CLDR formats:\n// See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n// See also explanations: http://cldr.unicode.org/translation/date-time\n// TODO(ocombe): support all missing cldr formats: U, Q, D, F, e, j, J, C, A, v, V, X, x\nfunction getDateFormatter(format) {\n if (DATE_FORMATS[format]) {\n return DATE_FORMATS[format];\n }\n let formatter;\n switch (format) {\n // Era name (AD/BC)\n case 'G':\n case 'GG':\n case 'GGG':\n formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Abbreviated);\n break;\n case 'GGGG':\n formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Wide);\n break;\n case 'GGGGG':\n formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Narrow);\n break;\n // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)\n case 'y':\n formatter = dateGetter(DateType.FullYear, 1, 0, false, true);\n break;\n // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)\n case 'yy':\n formatter = dateGetter(DateType.FullYear, 2, 0, true, true);\n break;\n // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)\n case 'yyy':\n formatter = dateGetter(DateType.FullYear, 3, 0, false, true);\n break;\n // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)\n case 'yyyy':\n formatter = dateGetter(DateType.FullYear, 4, 0, false, true);\n break;\n // 1 digit representation of the week-numbering year, e.g. (AD 1 => 1, AD 199 => 199)\n case 'Y':\n formatter = weekNumberingYearGetter(1);\n break;\n // 2 digit representation of the week-numbering year, padded (00-99). (e.g. AD 2001 => 01, AD\n // 2010 => 10)\n case 'YY':\n formatter = weekNumberingYearGetter(2, true);\n break;\n // 3 digit representation of the week-numbering year, padded (000-999). (e.g. AD 1 => 001, AD\n // 2010 => 2010)\n case 'YYY':\n formatter = weekNumberingYearGetter(3);\n break;\n // 4 digit representation of the week-numbering year (e.g. AD 1 => 0001, AD 2010 => 2010)\n case 'YYYY':\n formatter = weekNumberingYearGetter(4);\n break;\n // Month of the year (1-12), numeric\n case 'M':\n case 'L':\n formatter = dateGetter(DateType.Month, 1, 1);\n break;\n case 'MM':\n case 'LL':\n formatter = dateGetter(DateType.Month, 2, 1);\n break;\n // Month of the year (January, ...), string, format\n case 'MMM':\n formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated);\n break;\n case 'MMMM':\n formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide);\n break;\n case 'MMMMM':\n formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow);\n break;\n // Month of the year (January, ...), string, standalone\n case 'LLL':\n formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated, FormStyle.Standalone);\n break;\n case 'LLLL':\n formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide, FormStyle.Standalone);\n break;\n case 'LLLLL':\n formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow, FormStyle.Standalone);\n break;\n // Week of the year (1, ... 52)\n case 'w':\n formatter = weekGetter(1);\n break;\n case 'ww':\n formatter = weekGetter(2);\n break;\n // Week of the month (1, ...)\n case 'W':\n formatter = weekGetter(1, true);\n break;\n // Day of the month (1-31)\n case 'd':\n formatter = dateGetter(DateType.Date, 1);\n break;\n case 'dd':\n formatter = dateGetter(DateType.Date, 2);\n break;\n // Day of the Week StandAlone (1, 1, Mon, Monday, M, Mo)\n case 'c':\n case 'cc':\n formatter = dateGetter(DateType.Day, 1);\n break;\n case 'ccc':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated, FormStyle.Standalone);\n break;\n case 'cccc':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide, FormStyle.Standalone);\n break;\n case 'ccccc':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow, FormStyle.Standalone);\n break;\n case 'cccccc':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short, FormStyle.Standalone);\n break;\n // Day of the Week\n case 'E':\n case 'EE':\n case 'EEE':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated);\n break;\n case 'EEEE':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide);\n break;\n case 'EEEEE':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow);\n break;\n case 'EEEEEE':\n formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short);\n break;\n // Generic period of the day (am-pm)\n case 'a':\n case 'aa':\n case 'aaa':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated);\n break;\n case 'aaaa':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide);\n break;\n case 'aaaaa':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow);\n break;\n // Extended period of the day (midnight, at night, ...), standalone\n case 'b':\n case 'bb':\n case 'bbb':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Standalone, true);\n break;\n case 'bbbb':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Standalone, true);\n break;\n case 'bbbbb':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Standalone, true);\n break;\n // Extended period of the day (midnight, night, ...), standalone\n case 'B':\n case 'BB':\n case 'BBB':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Format, true);\n break;\n case 'BBBB':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Format, true);\n break;\n case 'BBBBB':\n formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Format, true);\n break;\n // Hour in AM/PM, (1-12)\n case 'h':\n formatter = dateGetter(DateType.Hours, 1, -12);\n break;\n case 'hh':\n formatter = dateGetter(DateType.Hours, 2, -12);\n break;\n // Hour of the day (0-23)\n case 'H':\n formatter = dateGetter(DateType.Hours, 1);\n break;\n // Hour in day, padded (00-23)\n case 'HH':\n formatter = dateGetter(DateType.Hours, 2);\n break;\n // Minute of the hour (0-59)\n case 'm':\n formatter = dateGetter(DateType.Minutes, 1);\n break;\n case 'mm':\n formatter = dateGetter(DateType.Minutes, 2);\n break;\n // Second of the minute (0-59)\n case 's':\n formatter = dateGetter(DateType.Seconds, 1);\n break;\n case 'ss':\n formatter = dateGetter(DateType.Seconds, 2);\n break;\n // Fractional second\n case 'S':\n formatter = dateGetter(DateType.FractionalSeconds, 1);\n break;\n case 'SS':\n formatter = dateGetter(DateType.FractionalSeconds, 2);\n break;\n case 'SSS':\n formatter = dateGetter(DateType.FractionalSeconds, 3);\n break;\n // Timezone ISO8601 short format (-0430)\n case 'Z':\n case 'ZZ':\n case 'ZZZ':\n formatter = timeZoneGetter(ZoneWidth.Short);\n break;\n // Timezone ISO8601 extended format (-04:30)\n case 'ZZZZZ':\n formatter = timeZoneGetter(ZoneWidth.Extended);\n break;\n // Timezone GMT short format (GMT+4)\n case 'O':\n case 'OO':\n case 'OOO':\n // Should be location, but fallback to format O instead because we don't have the data yet\n case 'z':\n case 'zz':\n case 'zzz':\n formatter = timeZoneGetter(ZoneWidth.ShortGMT);\n break;\n // Timezone GMT long format (GMT+0430)\n case 'OOOO':\n case 'ZZZZ':\n // Should be location, but fallback to format O instead because we don't have the data yet\n case 'zzzz':\n formatter = timeZoneGetter(ZoneWidth.Long);\n break;\n default:\n return null;\n }\n DATE_FORMATS[format] = formatter;\n return formatter;\n}\nfunction timezoneToOffset(timezone, fallback) {\n // Support: IE 11 only, Edge 13-15+\n // IE/Edge do not \"understand\" colon (`:`) in timezone\n timezone = timezone.replace(/:/g, '');\n const requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;\n return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;\n}\nfunction addDateMinutes(date, minutes) {\n date = new Date(date.getTime());\n date.setMinutes(date.getMinutes() + minutes);\n return date;\n}\nfunction convertTimezoneToLocal(date, timezone, reverse) {\n const reverseValue = reverse ? -1 : 1;\n const dateTimezoneOffset = date.getTimezoneOffset();\n const timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);\n return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));\n}\n/**\n * Converts a value to date.\n *\n * Supported input formats:\n * - `Date`\n * - number: timestamp\n * - string: numeric (e.g. \"1234\"), ISO and date strings in a format supported by\n * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).\n * Note: ISO strings without time return a date without timeoffset.\n *\n * Throws if unable to convert to a date.\n */\nfunction toDate(value) {\n if (isDate(value)) {\n return value;\n }\n if (typeof value === 'number' && !isNaN(value)) {\n return new Date(value);\n }\n if (typeof value === 'string') {\n value = value.trim();\n if (/^(\\d{4}(-\\d{1,2}(-\\d{1,2})?)?)$/.test(value)) {\n /* For ISO Strings without time the day, month and year must be extracted from the ISO String\n before Date creation to avoid time offset and errors in the new Date.\n If we only replace '-' with ',' in the ISO String (\"2015,01,01\"), and try to create a new\n date, some browsers (e.g. IE 9) will throw an invalid Date error.\n If we leave the '-' (\"2015-01-01\") and try to create a new Date(\"2015-01-01\") the timeoffset\n is applied.\n Note: ISO months are 0 for January, 1 for February, ... */\n const [y, m = 1, d = 1] = value.split('-').map((val) => +val);\n return createDate(y, m - 1, d);\n }\n const parsedNb = parseFloat(value);\n // any string that only contains numbers, like \"1234\" but not like \"1234hello\"\n if (!isNaN(value - parsedNb)) {\n return new Date(parsedNb);\n }\n let match;\n if ((match = value.match(ISO8601_DATE_REGEX))) {\n return isoStringToDate(match);\n }\n }\n const date = new Date(value);\n if (!isDate(date)) {\n throw new Error(`Unable to convert \"${value}\" into a date`);\n }\n return date;\n}\n/**\n * Converts a date in ISO8601 to a Date.\n * Used instead of `Date.parse` because of browser discrepancies.\n */\nfunction isoStringToDate(match) {\n const date = new Date(0);\n let tzHour = 0;\n let tzMin = 0;\n // match[8] means that the string contains \"Z\" (UTC) or a timezone like \"+01:00\" or \"+0100\"\n const dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;\n const timeSetter = match[8] ? date.setUTCHours : date.setHours;\n // if there is a timezone defined like \"+01:00\" or \"+0100\"\n if (match[9]) {\n tzHour = Number(match[9] + match[10]);\n tzMin = Number(match[9] + match[11]);\n }\n dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n const h = Number(match[4] || 0) - tzHour;\n const m = Number(match[5] || 0) - tzMin;\n const s = Number(match[6] || 0);\n // The ECMAScript specification (https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.11)\n // defines that `DateTime` milliseconds should always be rounded down, so that `999.9ms`\n // becomes `999ms`.\n const ms = Math.floor(parseFloat('0.' + (match[7] || 0)) * 1000);\n timeSetter.call(date, h, m, s, ms);\n return date;\n}\nfunction isDate(value) {\n return value instanceof Date && !isNaN(value.valueOf());\n}\n\nconst NUMBER_FORMAT_REGEXP = /^(\\d+)?\\.((\\d+)(-(\\d+))?)?$/;\nconst MAX_DIGITS = 22;\nconst DECIMAL_SEP = '.';\nconst ZERO_CHAR = '0';\nconst PATTERN_SEP = ';';\nconst GROUP_SEP = ',';\nconst DIGIT_CHAR = '#';\nconst CURRENCY_CHAR = '¤';\nconst PERCENT_CHAR = '%';\n/**\n * Transforms a number to a locale string based on a style and a format.\n */\nfunction formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent = false) {\n let formattedText = '';\n let isZero = false;\n if (!isFinite(value)) {\n formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);\n }\n else {\n let parsedNumber = parseNumber(value);\n if (isPercent) {\n parsedNumber = toPercent(parsedNumber);\n }\n let minInt = pattern.minInt;\n let minFraction = pattern.minFrac;\n let maxFraction = pattern.maxFrac;\n if (digitsInfo) {\n const parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);\n if (parts === null) {\n throw new Error(`${digitsInfo} is not a valid digit info`);\n }\n const minIntPart = parts[1];\n const minFractionPart = parts[3];\n const maxFractionPart = parts[5];\n if (minIntPart != null) {\n minInt = parseIntAutoRadix(minIntPart);\n }\n if (minFractionPart != null) {\n minFraction = parseIntAutoRadix(minFractionPart);\n }\n if (maxFractionPart != null) {\n maxFraction = parseIntAutoRadix(maxFractionPart);\n }\n else if (minFractionPart != null && minFraction > maxFraction) {\n maxFraction = minFraction;\n }\n }\n roundNumber(parsedNumber, minFraction, maxFraction);\n let digits = parsedNumber.digits;\n let integerLen = parsedNumber.integerLen;\n const exponent = parsedNumber.exponent;\n let decimals = [];\n isZero = digits.every((d) => !d);\n // pad zeros for small numbers\n for (; integerLen < minInt; integerLen++) {\n digits.unshift(0);\n }\n // pad zeros for small numbers\n for (; integerLen < 0; integerLen++) {\n digits.unshift(0);\n }\n // extract decimals digits\n if (integerLen > 0) {\n decimals = digits.splice(integerLen, digits.length);\n }\n else {\n decimals = digits;\n digits = [0];\n }\n // format the integer digits with grouping separators\n const groups = [];\n if (digits.length >= pattern.lgSize) {\n groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));\n }\n while (digits.length > pattern.gSize) {\n groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));\n }\n if (digits.length) {\n groups.unshift(digits.join(''));\n }\n formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));\n // append the decimal digits\n if (decimals.length) {\n formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');\n }\n if (exponent) {\n formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;\n }\n }\n if (value < 0 && !isZero) {\n formattedText = pattern.negPre + formattedText + pattern.negSuf;\n }\n else {\n formattedText = pattern.posPre + formattedText + pattern.posSuf;\n }\n return formattedText;\n}\n/**\n * @ngModule CommonModule\n * @description\n *\n * Formats a number as currency using locale rules.\n *\n * @param value The number to format.\n * @param locale A locale code for the locale format rules to use.\n * @param currency A string containing the currency symbol or its name,\n * such as \"$\" or \"Canadian Dollar\". Used in output string, but does not affect the operation\n * of the function.\n * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)\n * currency code, such as `USD` for the US dollar and `EUR` for the euro.\n * Used to determine the number of digits in the decimal part.\n * @param digitsInfo Decimal representation options, specified by a string in the following format:\n * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.\n *\n * @returns The formatted currency value.\n *\n * @see {@link formatNumber}\n * @see {@link DecimalPipe}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n */\nfunction formatCurrency(value, locale, currency, currencyCode, digitsInfo) {\n const format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency);\n const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));\n pattern.minFrac = getNumberOfCurrencyDigits(currencyCode);\n pattern.maxFrac = pattern.minFrac;\n const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo);\n return (res\n .replace(CURRENCY_CHAR, currency)\n // if we have 2 time the currency character, the second one is ignored\n .replace(CURRENCY_CHAR, '')\n // If there is a spacing between currency character and the value and\n // the currency character is suppressed by passing an empty string, the\n // spacing character would remain as part of the string. Then we\n // should remove it.\n .trim());\n}\n/**\n * @ngModule CommonModule\n * @description\n *\n * Formats a number as a percentage according to locale rules.\n *\n * @param value The number to format.\n * @param locale A locale code for the locale format rules to use.\n * @param digitsInfo Decimal representation options, specified by a string in the following format:\n * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.\n *\n * @returns The formatted percentage value.\n *\n * @see {@link formatNumber}\n * @see {@link DecimalPipe}\n * @see [Internationalization (i18n) Guide](guide/i18n)\n * @publicApi\n *\n */\nfunction formatPercent(value, locale, digitsInfo) {\n const format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);\n const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));\n const res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);\n return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));\n}\n/**\n * @ngModule CommonModule\n * @description\n *\n * Formats a number as text, with group sizing, separator, and other\n * parameters based on the locale.\n *\n * @param value The number to format.\n * @param locale A locale code for the locale format rules to use.\n * @param digitsInfo Decimal representation options, specified by a string in the following format:\n * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.\n *\n * @returns The formatted text string.\n * @see [Internationalization (i18n) Guide](guide/i18n)\n *\n * @publicApi\n */\nfunction formatNumber(value, locale, digitsInfo) {\n const format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal);\n const pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));\n return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo);\n}\nfunction parseNumberFormat(format, minusSign = '-') {\n const p = {\n minInt: 1,\n minFrac: 0,\n maxFrac: 0,\n posPre: '',\n posSuf: '',\n negPre: '',\n negSuf: '',\n gSize: 0,\n lgSize: 0,\n };\n const patternParts = format.split(PATTERN_SEP);\n const positive = patternParts[0];\n const negative = patternParts[1];\n const positiveParts = positive.indexOf(DECIMAL_SEP) !== -1\n ? positive.split(DECIMAL_SEP)\n : [\n positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1),\n positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1),\n ], integer = positiveParts[0], fraction = positiveParts[1] || '';\n p.posPre = integer.substring(0, integer.indexOf(DIGIT_CHAR));\n for (let i = 0; i < fraction.length; i++) {\n const ch = fraction.charAt(i);\n if (ch === ZERO_CHAR) {\n p.minFrac = p.maxFrac = i + 1;\n }\n else if (ch === DIGIT_CHAR) {\n p.maxFrac = i + 1;\n }\n else {\n p.posSuf += ch;\n }\n }\n const groups = integer.split(GROUP_SEP);\n p.gSize = groups[1] ? groups[1].length : 0;\n p.lgSize = groups[2] || groups[1] ? (groups[2] || groups[1]).length : 0;\n if (negative) {\n const trunkLen = positive.length - p.posPre.length - p.posSuf.length, pos = negative.indexOf(DIGIT_CHAR);\n p.negPre = negative.substring(0, pos).replace(/'/g, '');\n p.negSuf = negative.slice(pos + trunkLen).replace(/'/g, '');\n }\n else {\n p.negPre = minusSign + p.posPre;\n p.negSuf = p.posSuf;\n }\n return p;\n}\n// Transforms a parsed number into a percentage by multiplying it by 100\nfunction toPercent(parsedNumber) {\n // if the number is 0, don't do anything\n if (parsedNumber.digits[0] === 0) {\n return parsedNumber;\n }\n // Getting the current number of decimals\n const fractionLen = parsedNumber.digits.length - parsedNumber.integerLen;\n if (parsedNumber.exponent) {\n parsedNumber.exponent += 2;\n }\n else {\n if (fractionLen === 0) {\n parsedNumber.digits.push(0, 0);\n }\n else if (fractionLen === 1) {\n parsedNumber.digits.push(0);\n }\n parsedNumber.integerLen += 2;\n }\n return parsedNumber;\n}\n/**\n * Parses a number.\n * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/\n */\nfunction parseNumber(num) {\n let numStr = Math.abs(num) + '';\n let exponent = 0, digits, integerLen;\n let i, j, zeros;\n // Decimal point?\n if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {\n numStr = numStr.replace(DECIMAL_SEP, '');\n }\n // Exponential form?\n if ((i = numStr.search(/e/i)) > 0) {\n // Work out the exponent.\n if (integerLen < 0)\n integerLen = i;\n integerLen += +numStr.slice(i + 1);\n numStr = numStr.substring(0, i);\n }\n else if (integerLen < 0) {\n // There was no decimal point or exponent so it is an integer.\n integerLen = numStr.length;\n }\n // Count the number of leading zeros.\n for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) {\n /* empty */\n }\n if (i === (zeros = numStr.length)) {\n // The digits are all zero.\n digits = [0];\n integerLen = 1;\n }\n else {\n // Count the number of trailing zeros\n zeros--;\n while (numStr.charAt(zeros) === ZERO_CHAR)\n zeros--;\n // Trailing zeros are insignificant so ignore them\n integerLen -= i;\n digits = [];\n // Convert string to array of digits without leading/trailing zeros.\n for (j = 0; i <= zeros; i++, j++) {\n digits[j] = Number(numStr.charAt(i));\n }\n }\n // If the number overflows the maximum allowed digits then use an exponent.\n if (integerLen > MAX_DIGITS) {\n digits = digits.splice(0, MAX_DIGITS - 1);\n exponent = integerLen - 1;\n integerLen = 1;\n }\n return { digits, exponent, integerLen };\n}\n/**\n * Round the parsed number to the specified number of decimal places\n * This function changes the parsedNumber in-place\n */\nfunction roundNumber(parsedNumber, minFrac, maxFrac) {\n if (minFrac > maxFrac) {\n throw new Error(`The minimum number of digits after fraction (${minFrac}) is higher than the maximum (${maxFrac}).`);\n }\n let digits = parsedNumber.digits;\n let fractionLen = digits.length - parsedNumber.integerLen;\n const fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);\n // The index of the digit to where rounding is to occur\n let roundAt = fractionSize + parsedNumber.integerLen;\n let digit = digits[roundAt];\n if (roundAt > 0) {\n // Drop fractional digits beyond `roundAt`\n digits.splice(Math.max(parsedNumber.integerLen, roundAt));\n // Set non-fractional digits beyond `roundAt` to 0\n for (let j = roundAt; j < digits.length; j++) {\n digits[j] = 0;\n }\n }\n else {\n // We rounded to zero so reset the parsedNumber\n fractionLen = Math.max(0, fractionLen);\n parsedNumber.integerLen = 1;\n digits.length = Math.max(1, (roundAt = fractionSize + 1));\n digits[0] = 0;\n for (let i = 1; i < roundAt; i++)\n digits[i] = 0;\n }\n if (digit >= 5) {\n if (roundAt - 1 < 0) {\n for (let k = 0; k > roundAt; k--) {\n digits.unshift(0);\n parsedNumber.integerLen++;\n }\n digits.unshift(1);\n parsedNumber.integerLen++;\n }\n else {\n digits[roundAt - 1]++;\n }\n }\n // Pad out with zeros to get the required fraction length\n for (; fractionLen < Math.max(0, fractionSize); fractionLen++)\n digits.push(0);\n let dropTrailingZeros = fractionSize !== 0;\n // Minimal length = nb of decimals required + current nb of integers\n // Any number besides that is optional and can be removed if it's a trailing 0\n const minLen = minFrac + parsedNumber.integerLen;\n // Do any carrying, e.g. a digit was rounded up to 10\n const carry = digits.reduceRight(function (carry, d, i, digits) {\n d = d + carry;\n digits[i] = d < 10 ? d : d - 10; // d % 10\n if (dropTrailingZeros) {\n // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52)\n if (digits[i] === 0 && i >= minLen) {\n digits.pop();\n }\n else {\n dropTrailingZeros = false;\n }\n }\n return d >= 10 ? 1 : 0; // Math.floor(d / 10);\n }, 0);\n if (carry) {\n digits.unshift(carry);\n parsedNumber.integerLen++;\n }\n}\nfunction parseIntAutoRadix(text) {\n const result = parseInt(text);\n if (isNaN(result)) {\n throw new Error('Invalid integer literal when parsing ' + text);\n }\n return result;\n}\n\n/**\n * @publicApi\n */\nclass NgLocalization {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgLocalization, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgLocalization, providedIn: 'root', useFactory: (locale) => new NgLocaleLocalization(locale), deps: [{ token: LOCALE_ID }] });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgLocalization, decorators: [{\n type: Injectable,\n args: [{\n providedIn: 'root',\n useFactory: (locale) => new NgLocaleLocalization(locale),\n deps: [LOCALE_ID],\n }]\n }] });\n/**\n * Returns the plural category for a given value.\n * - \"=value\" when the case exists,\n * - the plural category otherwise\n */\nfunction getPluralCategory(value, cases, ngLocalization, locale) {\n let key = `=${value}`;\n if (cases.indexOf(key) > -1) {\n return key;\n }\n key = ngLocalization.getPluralCategory(value, locale);\n if (cases.indexOf(key) > -1) {\n return key;\n }\n if (cases.indexOf('other') > -1) {\n return 'other';\n }\n throw new Error(`No plural message found for value \"${value}\"`);\n}\n/**\n * Returns the plural case based on the locale\n *\n * @publicApi\n */\nclass NgLocaleLocalization extends NgLocalization {\n locale;\n constructor(locale) {\n super();\n this.locale = locale;\n }\n getPluralCategory(value, locale) {\n const plural = getLocalePluralCase(locale || this.locale)(value);\n switch (plural) {\n case Plural.Zero:\n return 'zero';\n case Plural.One:\n return 'one';\n case Plural.Two:\n return 'two';\n case Plural.Few:\n return 'few';\n case Plural.Many:\n return 'many';\n default:\n return 'other';\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgLocaleLocalization, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgLocaleLocalization });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgLocaleLocalization, decorators: [{\n type: Injectable\n }], ctorParameters: () => [{ type: undefined, decorators: [{\n type: Inject,\n args: [LOCALE_ID]\n }] }] });\n\n/**\n * Register global data to be used internally by Angular. See the\n * [\"I18n guide\"](guide/i18n/format-data-locale) to know how to import additional locale\n * data.\n *\n * The signature registerLocaleData(data: any, extraData?: any) is deprecated since v5.1\n *\n * @publicApi\n */\nfunction registerLocaleData(data, localeId, extraData) {\n return ɵregisterLocaleData(data, localeId, extraData);\n}\n\nfunction parseCookieValue(cookieStr, name) {\n name = encodeURIComponent(name);\n for (const cookie of cookieStr.split(';')) {\n const eqIndex = cookie.indexOf('=');\n const [cookieName, cookieValue] = eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)];\n if (cookieName.trim() === name) {\n return decodeURIComponent(cookieValue);\n }\n }\n return null;\n}\n\nconst WS_REGEXP = /\\s+/;\nconst EMPTY_ARRAY = [];\n/**\n * @ngModule CommonModule\n *\n * @usageNotes\n * ```html\n * ...\n *\n * ...\n *\n * ...\n *\n * ...\n *\n * ...\n * ```\n *\n * @description\n *\n * Adds and removes CSS classes on an HTML element.\n *\n * The CSS classes are updated as follows, depending on the type of the expression evaluation:\n * - `string` - the CSS classes listed in the string (space delimited) are added,\n * - `Array` - the CSS classes declared as Array elements are added,\n * - `Object` - keys are CSS classes that get added when the expression given in the value\n * evaluates to a truthy value, otherwise they are removed.\n *\n * @publicApi\n */\nclass NgClass {\n _ngEl;\n _renderer;\n initialClasses = EMPTY_ARRAY;\n rawClass;\n stateMap = new Map();\n constructor(_ngEl, _renderer) {\n this._ngEl = _ngEl;\n this._renderer = _renderer;\n }\n set klass(value) {\n this.initialClasses = value != null ? value.trim().split(WS_REGEXP) : EMPTY_ARRAY;\n }\n set ngClass(value) {\n this.rawClass = typeof value === 'string' ? value.trim().split(WS_REGEXP) : value;\n }\n /*\n The NgClass directive uses the custom change detection algorithm for its inputs. The custom\n algorithm is necessary since inputs are represented as complex object or arrays that need to be\n deeply-compared.\n \n This algorithm is perf-sensitive since NgClass is used very frequently and its poor performance\n might negatively impact runtime performance of the entire change detection cycle. The design of\n this algorithm is making sure that:\n - there is no unnecessary DOM manipulation (CSS classes are added / removed from the DOM only when\n needed), even if references to bound objects change;\n - there is no memory allocation if nothing changes (even relatively modest memory allocation\n during the change detection cycle can result in GC pauses for some of the CD cycles).\n \n The algorithm works by iterating over the set of bound classes, staring with [class] binding and\n then going over [ngClass] binding. For each CSS class name:\n - check if it was seen before (this information is tracked in the state map) and if its value\n changed;\n - mark it as \"touched\" - names that are not marked are not present in the latest set of binding\n and we can remove such class name from the internal data structures;\n \n After iteration over all the CSS class names we've got data structure with all the information\n necessary to synchronize changes to the DOM - it is enough to iterate over the state map, flush\n changes to the DOM and reset internal data structures so those are ready for the next change\n detection cycle.\n */\n ngDoCheck() {\n // classes from the [class] binding\n for (const klass of this.initialClasses) {\n this._updateState(klass, true);\n }\n // classes from the [ngClass] binding\n const rawClass = this.rawClass;\n if (Array.isArray(rawClass) || rawClass instanceof Set) {\n for (const klass of rawClass) {\n this._updateState(klass, true);\n }\n }\n else if (rawClass != null) {\n for (const klass of Object.keys(rawClass)) {\n this._updateState(klass, Boolean(rawClass[klass]));\n }\n }\n this._applyStateDiff();\n }\n _updateState(klass, nextEnabled) {\n const state = this.stateMap.get(klass);\n if (state !== undefined) {\n if (state.enabled !== nextEnabled) {\n state.changed = true;\n state.enabled = nextEnabled;\n }\n state.touched = true;\n }\n else {\n this.stateMap.set(klass, { enabled: nextEnabled, changed: true, touched: true });\n }\n }\n _applyStateDiff() {\n for (const stateEntry of this.stateMap) {\n const klass = stateEntry[0];\n const state = stateEntry[1];\n if (state.changed) {\n this._toggleClass(klass, state.enabled);\n state.changed = false;\n }\n else if (!state.touched) {\n // A class that was previously active got removed from the new collection of classes -\n // remove from the DOM as well.\n if (state.enabled) {\n this._toggleClass(klass, false);\n }\n this.stateMap.delete(klass);\n }\n state.touched = false;\n }\n }\n _toggleClass(klass, enabled) {\n if (ngDevMode) {\n if (typeof klass !== 'string') {\n throw new Error(`NgClass can only toggle CSS classes expressed as strings, got ${ɵstringify(klass)}`);\n }\n }\n klass = klass.trim();\n if (klass.length > 0) {\n klass.split(WS_REGEXP).forEach((klass) => {\n if (enabled) {\n this._renderer.addClass(this._ngEl.nativeElement, klass);\n }\n else {\n this._renderer.removeClass(this._ngEl.nativeElement, klass);\n }\n });\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgClass, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgClass, isStandalone: true, selector: \"[ngClass]\", inputs: { klass: [\"class\", \"klass\"], ngClass: \"ngClass\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgClass, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngClass]',\n }]\n }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { klass: [{\n type: Input,\n args: ['class']\n }], ngClass: [{\n type: Input,\n args: ['ngClass']\n }] } });\n\n/**\n * Instantiates a {@link Component} type and inserts its Host View into the current View.\n * `NgComponentOutlet` provides a declarative approach for dynamic component creation.\n *\n * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and\n * any existing component will be destroyed.\n *\n * @usageNotes\n *\n * ### Fine tune control\n *\n * You can control the component creation process by using the following optional attributes:\n *\n * * `ngComponentOutletInputs`: Optional component inputs object, which will be bind to the\n * component.\n *\n * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for\n * the Component. Defaults to the injector of the current view container.\n *\n * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content\n * section of the component, if it exists.\n *\n * * `ngComponentOutletNgModule`: Optional NgModule class reference to allow loading another\n * module dynamically, then loading a component from that module.\n *\n * * `ngComponentOutletNgModuleFactory`: Deprecated config option that allows providing optional\n * NgModule factory to allow loading another module dynamically, then loading a component from that\n * module. Use `ngComponentOutletNgModule` instead.\n *\n * ### Syntax\n *\n * Simple\n * ```html\n * \n * ```\n *\n * With inputs\n * ```html\n * \n * \n * ```\n *\n * Customized injector/content\n * ```html\n * \n * \n * ```\n *\n * Customized NgModule reference\n * ```html\n * \n * \n * ```\n *\n * ### A simple example\n *\n * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}\n *\n * A more complete example with additional options:\n *\n * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}\n *\n * @publicApi\n * @ngModule CommonModule\n */\nclass NgComponentOutlet {\n _viewContainerRef;\n ngComponentOutlet = null;\n ngComponentOutletInputs;\n ngComponentOutletInjector;\n ngComponentOutletContent;\n ngComponentOutletNgModule;\n /**\n * @deprecated This input is deprecated, use `ngComponentOutletNgModule` instead.\n */\n ngComponentOutletNgModuleFactory;\n _componentRef;\n _moduleRef;\n /**\n * A helper data structure that allows us to track inputs that were part of the\n * ngComponentOutletInputs expression. Tracking inputs is necessary for proper removal of ones\n * that are no longer referenced.\n */\n _inputsUsed = new Map();\n constructor(_viewContainerRef) {\n this._viewContainerRef = _viewContainerRef;\n }\n _needToReCreateNgModuleInstance(changes) {\n // Note: square brackets property accessor is safe for Closure compiler optimizations (the\n // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that\n // were changed).\n return (changes['ngComponentOutletNgModule'] !== undefined ||\n changes['ngComponentOutletNgModuleFactory'] !== undefined);\n }\n _needToReCreateComponentInstance(changes) {\n // Note: square brackets property accessor is safe for Closure compiler optimizations (the\n // `changes` argument of the `ngOnChanges` lifecycle hook retains the names of the fields that\n // were changed).\n return (changes['ngComponentOutlet'] !== undefined ||\n changes['ngComponentOutletContent'] !== undefined ||\n changes['ngComponentOutletInjector'] !== undefined ||\n this._needToReCreateNgModuleInstance(changes));\n }\n /** @nodoc */\n ngOnChanges(changes) {\n if (this._needToReCreateComponentInstance(changes)) {\n this._viewContainerRef.clear();\n this._inputsUsed.clear();\n this._componentRef = undefined;\n if (this.ngComponentOutlet) {\n const injector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;\n if (this._needToReCreateNgModuleInstance(changes)) {\n this._moduleRef?.destroy();\n if (this.ngComponentOutletNgModule) {\n this._moduleRef = createNgModule(this.ngComponentOutletNgModule, getParentInjector(injector));\n }\n else if (this.ngComponentOutletNgModuleFactory) {\n this._moduleRef = this.ngComponentOutletNgModuleFactory.create(getParentInjector(injector));\n }\n else {\n this._moduleRef = undefined;\n }\n }\n this._componentRef = this._viewContainerRef.createComponent(this.ngComponentOutlet, {\n injector,\n ngModuleRef: this._moduleRef,\n projectableNodes: this.ngComponentOutletContent,\n });\n }\n }\n }\n /** @nodoc */\n ngDoCheck() {\n if (this._componentRef) {\n if (this.ngComponentOutletInputs) {\n for (const inputName of Object.keys(this.ngComponentOutletInputs)) {\n this._inputsUsed.set(inputName, true);\n }\n }\n this._applyInputStateDiff(this._componentRef);\n }\n }\n /** @nodoc */\n ngOnDestroy() {\n this._moduleRef?.destroy();\n }\n _applyInputStateDiff(componentRef) {\n for (const [inputName, touched] of this._inputsUsed) {\n if (!touched) {\n // The input that was previously active no longer exists and needs to be set to undefined.\n componentRef.setInput(inputName, undefined);\n this._inputsUsed.delete(inputName);\n }\n else {\n // Since touched is true, it can be asserted that the inputs object is not empty.\n componentRef.setInput(inputName, this.ngComponentOutletInputs[inputName]);\n this._inputsUsed.set(inputName, false);\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgComponentOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgComponentOutlet, isStandalone: true, selector: \"[ngComponentOutlet]\", inputs: { ngComponentOutlet: \"ngComponentOutlet\", ngComponentOutletInputs: \"ngComponentOutletInputs\", ngComponentOutletInjector: \"ngComponentOutletInjector\", ngComponentOutletContent: \"ngComponentOutletContent\", ngComponentOutletNgModule: \"ngComponentOutletNgModule\", ngComponentOutletNgModuleFactory: \"ngComponentOutletNgModuleFactory\" }, usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgComponentOutlet, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngComponentOutlet]',\n standalone: true,\n }]\n }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngComponentOutlet: [{\n type: Input\n }], ngComponentOutletInputs: [{\n type: Input\n }], ngComponentOutletInjector: [{\n type: Input\n }], ngComponentOutletContent: [{\n type: Input\n }], ngComponentOutletNgModule: [{\n type: Input\n }], ngComponentOutletNgModuleFactory: [{\n type: Input\n }] } });\n// Helper function that returns an Injector instance of a parent NgModule.\nfunction getParentInjector(injector) {\n const parentNgModule = injector.get(NgModuleRef);\n return parentNgModule.injector;\n}\n\n/**\n * @publicApi\n */\nclass NgForOfContext {\n $implicit;\n ngForOf;\n index;\n count;\n constructor(\n /** Reference to the current item from the collection. */\n $implicit, \n /**\n * The value of the iterable expression. Useful when the expression is\n * more complex then a property access, for example when using the async pipe\n * (`userStreams | async`).\n */\n ngForOf, \n /** Returns an index of the current item in the collection. */\n index, \n /** Returns total amount of items in the collection. */\n count) {\n this.$implicit = $implicit;\n this.ngForOf = ngForOf;\n this.index = index;\n this.count = count;\n }\n // Indicates whether this is the first item in the collection.\n get first() {\n return this.index === 0;\n }\n // Indicates whether this is the last item in the collection.\n get last() {\n return this.index === this.count - 1;\n }\n // Indicates whether an index of this item in the collection is even.\n get even() {\n return this.index % 2 === 0;\n }\n // Indicates whether an index of this item in the collection is odd.\n get odd() {\n return !this.even;\n }\n}\n/**\n * A [structural directive](guide/directives/structural-directives) that renders\n * a template for each item in a collection.\n * The directive is placed on an element, which becomes the parent\n * of the cloned templates.\n *\n * The `ngForOf` directive is generally used in the\n * [shorthand form](guide/directives/structural-directives#asterisk) `*ngFor`.\n * In this form, the template to be rendered for each iteration is the content\n * of an anchor element containing the directive.\n *\n * The following example shows the shorthand syntax with some options,\n * contained in an `
  • ` element.\n *\n * ```html\n *
  • ...
  • \n * ```\n *\n * The shorthand form expands into a long form that uses the `ngForOf` selector\n * on an `` element.\n * The content of the `` element is the `
  • ` element that held the\n * short-form directive.\n *\n * Here is the expanded version of the short-form example.\n *\n * ```html\n * \n *
  • ...
  • \n *
    \n * ```\n *\n * Angular automatically expands the shorthand syntax as it compiles the template.\n * The context for each embedded view is logically merged to the current component\n * context according to its lexical position.\n *\n * When using the shorthand syntax, Angular allows only [one structural directive\n * on an element](guide/directives/structural-directives#one-per-element).\n * If you want to iterate conditionally, for example,\n * put the `*ngIf` on a container element that wraps the `*ngFor` element.\n * For further discussion, see\n * [Structural Directives](guide/directives/structural-directives#one-per-element).\n *\n * @usageNotes\n *\n * ### Local variables\n *\n * `NgForOf` provides exported values that can be aliased to local variables.\n * For example:\n *\n * ```html\n *
  • \n * {{i}}/{{users.length}}. {{user}} default\n *
  • \n * ```\n *\n * The following exported values can be aliased to local variables:\n *\n * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).\n * - `ngForOf: NgIterable`: The value of the iterable expression. Useful when the expression is\n * more complex then a property access, for example when using the async pipe (`userStreams |\n * async`).\n * - `index: number`: The index of the current item in the iterable.\n * - `count: number`: The length of the iterable.\n * - `first: boolean`: True when the item is the first item in the iterable.\n * - `last: boolean`: True when the item is the last item in the iterable.\n * - `even: boolean`: True when the item has an even index in the iterable.\n * - `odd: boolean`: True when the item has an odd index in the iterable.\n *\n * ### Change propagation\n *\n * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:\n *\n * * When an item is added, a new instance of the template is added to the DOM.\n * * When an item is removed, its template instance is removed from the DOM.\n * * When items are reordered, their respective templates are reordered in the DOM.\n *\n * Angular uses object identity to track insertions and deletions within the iterator and reproduce\n * those changes in the DOM. This has important implications for animations and any stateful\n * controls that are present, such as `` elements that accept user input. Inserted rows can\n * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state\n * such as user input.\n * For more on animations, see [Transitions and Triggers](guide/animations/transition-and-triggers).\n *\n * The identities of elements in the iterator can change while the data does not.\n * This can happen, for example, if the iterator is produced from an RPC to the server, and that\n * RPC is re-run. Even if the data hasn't changed, the second response produces objects with\n * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old\n * elements were deleted and all new elements inserted).\n *\n * To avoid this expensive operation, you can customize the default tracking algorithm.\n * by supplying the `trackBy` option to `NgForOf`.\n * `trackBy` takes a function that has two arguments: `index` and `item`.\n * If `trackBy` is given, Angular tracks changes by the return value of the function.\n *\n * @see [Structural Directives](guide/directives/structural-directives)\n * @ngModule CommonModule\n * @publicApi\n */\nclass NgForOf {\n _viewContainer;\n _template;\n _differs;\n /**\n * The value of the iterable expression, which can be used as a\n * [template input variable](guide/directives/structural-directives#shorthand).\n */\n set ngForOf(ngForOf) {\n this._ngForOf = ngForOf;\n this._ngForOfDirty = true;\n }\n /**\n * Specifies a custom `TrackByFunction` to compute the identity of items in an iterable.\n *\n * If a custom `TrackByFunction` is not provided, `NgForOf` will use the item's [object\n * identity](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)\n * as the key.\n *\n * `NgForOf` uses the computed key to associate items in an iterable with DOM elements\n * it produces for these items.\n *\n * A custom `TrackByFunction` is useful to provide good user experience in cases when items in an\n * iterable rendered using `NgForOf` have a natural identifier (for example, custom ID or a\n * primary key), and this iterable could be updated with new object instances that still\n * represent the same underlying entity (for example, when data is re-fetched from the server,\n * and the iterable is recreated and re-rendered, but most of the data is still the same).\n *\n * @see {@link TrackByFunction}\n */\n set ngForTrackBy(fn) {\n if ((typeof ngDevMode === 'undefined' || ngDevMode) && fn != null && typeof fn !== 'function') {\n console.warn(`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +\n `See https://angular.io/api/common/NgForOf#change-propagation for more information.`);\n }\n this._trackByFn = fn;\n }\n get ngForTrackBy() {\n return this._trackByFn;\n }\n _ngForOf = null;\n _ngForOfDirty = true;\n _differ = null;\n // TODO(issue/24571): remove '!'\n // waiting for microsoft/typescript#43662 to allow the return type `TrackByFunction|undefined` for\n // the getter\n _trackByFn;\n constructor(_viewContainer, _template, _differs) {\n this._viewContainer = _viewContainer;\n this._template = _template;\n this._differs = _differs;\n }\n /**\n * A reference to the template that is stamped out for each item in the iterable.\n * @see [template reference variable](guide/templates/variables#template-reference-variables)\n */\n set ngForTemplate(value) {\n // TODO(TS2.1): make TemplateRef>> once we move to TS v2.1\n // The current type is too restrictive; a template that just uses index, for example,\n // should be acceptable.\n if (value) {\n this._template = value;\n }\n }\n /**\n * Applies the changes when needed.\n * @nodoc\n */\n ngDoCheck() {\n if (this._ngForOfDirty) {\n this._ngForOfDirty = false;\n // React on ngForOf changes only once all inputs have been initialized\n const value = this._ngForOf;\n if (!this._differ && value) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n try {\n // CAUTION: this logic is duplicated for production mode below, as the try-catch\n // is only present in development builds.\n this._differ = this._differs.find(value).create(this.ngForTrackBy);\n }\n catch {\n let errorMessage = `Cannot find a differ supporting object '${value}' of type '` +\n `${getTypeName(value)}'. NgFor only supports binding to Iterables, such as Arrays.`;\n if (typeof value === 'object') {\n errorMessage += ' Did you mean to use the keyvalue pipe?';\n }\n throw new ɵRuntimeError(-2200 /* RuntimeErrorCode.NG_FOR_MISSING_DIFFER */, errorMessage);\n }\n }\n else {\n // CAUTION: this logic is duplicated for development mode above, as the try-catch\n // is only present in development builds.\n this._differ = this._differs.find(value).create(this.ngForTrackBy);\n }\n }\n }\n if (this._differ) {\n const changes = this._differ.diff(this._ngForOf);\n if (changes)\n this._applyChanges(changes);\n }\n }\n _applyChanges(changes) {\n const viewContainer = this._viewContainer;\n changes.forEachOperation((item, adjustedPreviousIndex, currentIndex) => {\n if (item.previousIndex == null) {\n // NgForOf is never \"null\" or \"undefined\" here because the differ detected\n // that a new item needs to be inserted from the iterable. This implies that\n // there is an iterable value for \"_ngForOf\".\n viewContainer.createEmbeddedView(this._template, new NgForOfContext(item.item, this._ngForOf, -1, -1), currentIndex === null ? undefined : currentIndex);\n }\n else if (currentIndex == null) {\n viewContainer.remove(adjustedPreviousIndex === null ? undefined : adjustedPreviousIndex);\n }\n else if (adjustedPreviousIndex !== null) {\n const view = viewContainer.get(adjustedPreviousIndex);\n viewContainer.move(view, currentIndex);\n applyViewChange(view, item);\n }\n });\n for (let i = 0, ilen = viewContainer.length; i < ilen; i++) {\n const viewRef = viewContainer.get(i);\n const context = viewRef.context;\n context.index = i;\n context.count = ilen;\n context.ngForOf = this._ngForOf;\n }\n changes.forEachIdentityChange((record) => {\n const viewRef = viewContainer.get(record.currentIndex);\n applyViewChange(viewRef, record);\n });\n }\n /**\n * Asserts the correct type of the context for the template that `NgForOf` will render.\n *\n * The presence of this method is a signal to the Ivy template type-check compiler that the\n * `NgForOf` structural directive renders its template with a specific context type.\n */\n static ngTemplateContextGuard(dir, ctx) {\n return true;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgForOf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgForOf, isStandalone: true, selector: \"[ngFor][ngForOf]\", inputs: { ngForOf: \"ngForOf\", ngForTrackBy: \"ngForTrackBy\", ngForTemplate: \"ngForTemplate\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgForOf, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngFor][ngForOf]',\n }]\n }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.IterableDiffers }], propDecorators: { ngForOf: [{\n type: Input\n }], ngForTrackBy: [{\n type: Input\n }], ngForTemplate: [{\n type: Input\n }] } });\nfunction applyViewChange(view, record) {\n view.context.$implicit = record.item;\n}\nfunction getTypeName(type) {\n return type['name'] || typeof type;\n}\n\n/**\n * A structural directive that conditionally includes a template based on the value of\n * an expression coerced to Boolean.\n * When the expression evaluates to true, Angular renders the template\n * provided in a `then` clause, and when false or null,\n * Angular renders the template provided in an optional `else` clause. The default\n * template for the `else` clause is blank.\n *\n * A [shorthand form](guide/directives/structural-directives#asterisk) of the directive,\n * `*ngIf=\"condition\"`, is generally used, provided\n * as an attribute of the anchor element for the inserted template.\n * Angular expands this into a more explicit version, in which the anchor element\n * is contained in an `` element.\n *\n * Simple form with shorthand syntax:\n *\n * ```html\n *
    Content to render when condition is true.
    \n * ```\n *\n * Simple form with expanded syntax:\n *\n * ```html\n *
    Content to render when condition is\n * true.
    \n * ```\n *\n * Form with an \"else\" block:\n *\n * ```html\n *
    Content to render when condition is true.
    \n * Content to render when condition is false.\n * ```\n *\n * Shorthand form with \"then\" and \"else\" blocks:\n *\n * ```html\n *
    \n * Content to render when condition is true.\n * Content to render when condition is false.\n * ```\n *\n * Form with storing the value locally:\n *\n * ```html\n *
    {{value}}
    \n * Content to render when value is null.\n * ```\n *\n * @usageNotes\n *\n * The `*ngIf` directive is most commonly used to conditionally show an inline template,\n * as seen in the following example.\n * The default `else` template is blank.\n *\n * {@example common/ngIf/ts/module.ts region='NgIfSimple'}\n *\n * ### Showing an alternative template using `else`\n *\n * To display a template when `expression` evaluates to false, use an `else` template\n * binding as shown in the following example.\n * The `else` binding points to an `` element labeled `#elseBlock`.\n * The template can be defined anywhere in the component view, but is typically placed right after\n * `ngIf` for readability.\n *\n * {@example common/ngIf/ts/module.ts region='NgIfElse'}\n *\n * ### Using an external `then` template\n *\n * In the previous example, the then-clause template is specified inline, as the content of the\n * tag that contains the `ngIf` directive. You can also specify a template that is defined\n * externally, by referencing a labeled `` element. When you do this, you can\n * change which template to use at runtime, as shown in the following example.\n *\n * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}\n *\n * ### Storing a conditional result in a variable\n *\n * You might want to show a set of properties from the same object. If you are waiting\n * for asynchronous data, the object can be undefined.\n * In this case, you can use `ngIf` and store the result of the condition in a local\n * variable as shown in the following example.\n *\n * {@example common/ngIf/ts/module.ts region='NgIfAs'}\n *\n * This code uses only one `AsyncPipe`, so only one subscription is created.\n * The conditional statement stores the result of `userStream|async` in the local variable `user`.\n * You can then bind the local `user` repeatedly.\n *\n * The conditional displays the data only if `userStream` returns a value,\n * so you don't need to use the\n * safe-navigation-operator (`?.`)\n * to guard against null values when accessing properties.\n * You can display an alternative template while waiting for the data.\n *\n * ### Shorthand syntax\n *\n * The shorthand syntax `*ngIf` expands into two separate template specifications\n * for the \"then\" and \"else\" clauses. For example, consider the following shorthand statement,\n * that is meant to show a loading page while waiting for data to be loaded.\n *\n * ```html\n *
    \n * ...\n *
    \n *\n * \n *
    Loading...
    \n *
    \n * ```\n *\n * You can see that the \"else\" clause references the ``\n * with the `#loading` label, and the template for the \"then\" clause\n * is provided as the content of the anchor element.\n *\n * However, when Angular expands the shorthand syntax, it creates\n * another `` tag, with `ngIf` and `ngIfElse` directives.\n * The anchor element containing the template for the \"then\" clause becomes\n * the content of this unlabeled `` tag.\n *\n * ```html\n * \n *
    \n * ...\n *
    \n *
    \n *\n * \n *
    Loading...
    \n *
    \n * ```\n *\n * The presence of the implicit template object has implications for the nesting of\n * structural directives. For more on this subject, see\n * [Structural Directives](guide/directives/structural-directives#one-per-element).\n *\n * @ngModule CommonModule\n * @publicApi\n */\nclass NgIf {\n _viewContainer;\n _context = new NgIfContext();\n _thenTemplateRef = null;\n _elseTemplateRef = null;\n _thenViewRef = null;\n _elseViewRef = null;\n constructor(_viewContainer, templateRef) {\n this._viewContainer = _viewContainer;\n this._thenTemplateRef = templateRef;\n }\n /**\n * The Boolean expression to evaluate as the condition for showing a template.\n */\n set ngIf(condition) {\n this._context.$implicit = this._context.ngIf = condition;\n this._updateView();\n }\n /**\n * A template to show if the condition expression evaluates to true.\n */\n set ngIfThen(templateRef) {\n assertTemplate('ngIfThen', templateRef);\n this._thenTemplateRef = templateRef;\n this._thenViewRef = null; // clear previous view if any.\n this._updateView();\n }\n /**\n * A template to show if the condition expression evaluates to false.\n */\n set ngIfElse(templateRef) {\n assertTemplate('ngIfElse', templateRef);\n this._elseTemplateRef = templateRef;\n this._elseViewRef = null; // clear previous view if any.\n this._updateView();\n }\n _updateView() {\n if (this._context.$implicit) {\n if (!this._thenViewRef) {\n this._viewContainer.clear();\n this._elseViewRef = null;\n if (this._thenTemplateRef) {\n this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);\n }\n }\n }\n else {\n if (!this._elseViewRef) {\n this._viewContainer.clear();\n this._thenViewRef = null;\n if (this._elseTemplateRef) {\n this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);\n }\n }\n }\n }\n /** @internal */\n static ngIfUseIfTypeGuard;\n /**\n * Assert the correct type of the expression bound to the `ngIf` input within the template.\n *\n * The presence of this static field is a signal to the Ivy template type check compiler that\n * when the `NgIf` structural directive renders its template, the type of the expression bound\n * to `ngIf` should be narrowed in some way. For `NgIf`, the binding expression itself is used to\n * narrow its type, which allows the strictNullChecks feature of TypeScript to work with `NgIf`.\n */\n static ngTemplateGuard_ngIf;\n /**\n * Asserts the correct type of the context for the template that `NgIf` will render.\n *\n * The presence of this method is a signal to the Ivy template type-check compiler that the\n * `NgIf` structural directive renders its template with a specific context type.\n */\n static ngTemplateContextGuard(dir, ctx) {\n return true;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgIf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgIf, isStandalone: true, selector: \"[ngIf]\", inputs: { ngIf: \"ngIf\", ngIfThen: \"ngIfThen\", ngIfElse: \"ngIfElse\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgIf, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngIf]',\n }]\n }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }], propDecorators: { ngIf: [{\n type: Input\n }], ngIfThen: [{\n type: Input\n }], ngIfElse: [{\n type: Input\n }] } });\n/**\n * @publicApi\n */\nclass NgIfContext {\n $implicit = null;\n ngIf = null;\n}\nfunction assertTemplate(property, templateRef) {\n const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);\n if (!isTemplateRefOrNull) {\n throw new Error(`${property} must be a TemplateRef, but received '${ɵstringify(templateRef)}'.`);\n }\n}\n\nclass SwitchView {\n _viewContainerRef;\n _templateRef;\n _created = false;\n constructor(_viewContainerRef, _templateRef) {\n this._viewContainerRef = _viewContainerRef;\n this._templateRef = _templateRef;\n }\n create() {\n this._created = true;\n this._viewContainerRef.createEmbeddedView(this._templateRef);\n }\n destroy() {\n this._created = false;\n this._viewContainerRef.clear();\n }\n enforceState(created) {\n if (created && !this._created) {\n this.create();\n }\n else if (!created && this._created) {\n this.destroy();\n }\n }\n}\n/**\n * @ngModule CommonModule\n *\n * @description\n * The `[ngSwitch]` directive on a container specifies an expression to match against.\n * The expressions to match are provided by `ngSwitchCase` directives on views within the container.\n * - Every view that matches is rendered.\n * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.\n * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`\n * or `ngSwitchDefault` directive are preserved at the location.\n *\n * @usageNotes\n * Define a container element for the directive, and specify the switch expression\n * to match against as an attribute:\n *\n * ```html\n * \n * ```\n *\n * Within the container, `*ngSwitchCase` statements specify the match expressions\n * as attributes. Include `*ngSwitchDefault` as the final case.\n *\n * ```html\n * \n * ...\n * ...\n * ...\n * \n * ```\n *\n * ### Usage Examples\n *\n * The following example shows how to use more than one case to display the same view:\n *\n * ```html\n * \n * \n * ...\n * ...\n * ...\n * \n * ...\n * \n * ```\n *\n * The following example shows how cases can be nested:\n * ```html\n * \n * ...\n * ...\n * ...\n * \n * \n * \n * \n * \n * ...\n * \n * ```\n *\n * @publicApi\n * @see {@link NgSwitchCase}\n * @see {@link NgSwitchDefault}\n * @see [Structural Directives](guide/directives/structural-directives)\n *\n */\nclass NgSwitch {\n _defaultViews = [];\n _defaultUsed = false;\n _caseCount = 0;\n _lastCaseCheckIndex = 0;\n _lastCasesMatched = false;\n _ngSwitch;\n set ngSwitch(newValue) {\n this._ngSwitch = newValue;\n if (this._caseCount === 0) {\n this._updateDefaultCases(true);\n }\n }\n /** @internal */\n _addCase() {\n return this._caseCount++;\n }\n /** @internal */\n _addDefault(view) {\n this._defaultViews.push(view);\n }\n /** @internal */\n _matchCase(value) {\n const matched = value === this._ngSwitch;\n this._lastCasesMatched ||= matched;\n this._lastCaseCheckIndex++;\n if (this._lastCaseCheckIndex === this._caseCount) {\n this._updateDefaultCases(!this._lastCasesMatched);\n this._lastCaseCheckIndex = 0;\n this._lastCasesMatched = false;\n }\n return matched;\n }\n _updateDefaultCases(useDefault) {\n if (this._defaultViews.length > 0 && useDefault !== this._defaultUsed) {\n this._defaultUsed = useDefault;\n for (const defaultView of this._defaultViews) {\n defaultView.enforceState(useDefault);\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgSwitch, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgSwitch, isStandalone: true, selector: \"[ngSwitch]\", inputs: { ngSwitch: \"ngSwitch\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgSwitch, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngSwitch]',\n }]\n }], propDecorators: { ngSwitch: [{\n type: Input\n }] } });\n/**\n * @ngModule CommonModule\n *\n * @description\n * Provides a switch case expression to match against an enclosing `ngSwitch` expression.\n * When the expressions match, the given `NgSwitchCase` template is rendered.\n * If multiple match expressions match the switch expression value, all of them are displayed.\n *\n * @usageNotes\n *\n * Within a switch container, `*ngSwitchCase` statements specify the match expressions\n * as attributes. Include `*ngSwitchDefault` as the final case.\n *\n * ```html\n * \n * ...\n * ...\n * ...\n * \n * ```\n *\n * Each switch-case statement contains an in-line HTML template or template reference\n * that defines the subtree to be selected if the value of the match expression\n * matches the value of the switch expression.\n *\n * As of Angular v17 the NgSwitch directive uses strict equality comparison (`===`) instead of\n * loose equality (`==`) to match different cases.\n *\n * @publicApi\n * @see {@link NgSwitch}\n * @see {@link NgSwitchDefault}\n *\n */\nclass NgSwitchCase {\n ngSwitch;\n _view;\n /**\n * Stores the HTML template to be selected on match.\n */\n ngSwitchCase;\n constructor(viewContainer, templateRef, ngSwitch) {\n this.ngSwitch = ngSwitch;\n if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {\n throwNgSwitchProviderNotFoundError('ngSwitchCase', 'NgSwitchCase');\n }\n ngSwitch._addCase();\n this._view = new SwitchView(viewContainer, templateRef);\n }\n /**\n * Performs case matching. For internal use only.\n * @nodoc\n */\n ngDoCheck() {\n this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgSwitchCase, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgSwitchCase, isStandalone: true, selector: \"[ngSwitchCase]\", inputs: { ngSwitchCase: \"ngSwitchCase\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgSwitchCase, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngSwitchCase]',\n }]\n }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{\n type: Optional\n }, {\n type: Host\n }] }], propDecorators: { ngSwitchCase: [{\n type: Input\n }] } });\n/**\n * @ngModule CommonModule\n *\n * @description\n *\n * Creates a view that is rendered when no `NgSwitchCase` expressions\n * match the `NgSwitch` expression.\n * This statement should be the final case in an `NgSwitch`.\n *\n * @publicApi\n * @see {@link NgSwitch}\n * @see {@link NgSwitchCase}\n *\n */\nclass NgSwitchDefault {\n constructor(viewContainer, templateRef, ngSwitch) {\n if ((typeof ngDevMode === 'undefined' || ngDevMode) && !ngSwitch) {\n throwNgSwitchProviderNotFoundError('ngSwitchDefault', 'NgSwitchDefault');\n }\n ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgSwitchDefault, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: NgSwitch, host: true, optional: true }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgSwitchDefault, isStandalone: true, selector: \"[ngSwitchDefault]\", ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgSwitchDefault, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngSwitchDefault]',\n }]\n }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: NgSwitch, decorators: [{\n type: Optional\n }, {\n type: Host\n }] }] });\nfunction throwNgSwitchProviderNotFoundError(attrName, directiveName) {\n throw new ɵRuntimeError(2000 /* RuntimeErrorCode.PARENT_NG_SWITCH_NOT_FOUND */, `An element with the \"${attrName}\" attribute ` +\n `(matching the \"${directiveName}\" directive) must be located inside an element with the \"ngSwitch\" attribute ` +\n `(matching \"NgSwitch\" directive)`);\n}\nfunction stringifyValue(value) {\n return typeof value === 'string' ? `'${value}'` : String(value);\n}\n\n/**\n * @ngModule CommonModule\n *\n * @usageNotes\n * ```html\n * \n * there is nothing\n * there is one\n * there are a few\n * \n * ```\n *\n * @description\n *\n * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.\n *\n * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees\n * that match the switch expression's pluralization category.\n *\n * To use this directive you must provide a container element that sets the `[ngPlural]` attribute\n * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their\n * expression:\n * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value\n * matches the switch expression exactly,\n * - otherwise, the view will be treated as a \"category match\", and will only display if exact\n * value matches aren't found and the value maps to its category for the defined locale.\n *\n * See http://cldr.unicode.org/index/cldr-spec/plural-rules\n *\n * @publicApi\n */\nclass NgPlural {\n _localization;\n _activeView;\n _caseViews = {};\n constructor(_localization) {\n this._localization = _localization;\n }\n set ngPlural(value) {\n this._updateView(value);\n }\n addCase(value, switchView) {\n this._caseViews[value] = switchView;\n }\n _updateView(switchValue) {\n this._clearViews();\n const cases = Object.keys(this._caseViews);\n const key = getPluralCategory(switchValue, cases, this._localization);\n this._activateView(this._caseViews[key]);\n }\n _clearViews() {\n if (this._activeView)\n this._activeView.destroy();\n }\n _activateView(view) {\n if (view) {\n this._activeView = view;\n this._activeView.create();\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgPlural, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgPlural, isStandalone: true, selector: \"[ngPlural]\", inputs: { ngPlural: \"ngPlural\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgPlural, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngPlural]',\n }]\n }], ctorParameters: () => [{ type: NgLocalization }], propDecorators: { ngPlural: [{\n type: Input\n }] } });\n/**\n * @ngModule CommonModule\n *\n * @description\n *\n * Creates a view that will be added/removed from the parent {@link NgPlural} when the\n * given expression matches the plural expression according to CLDR rules.\n *\n * @usageNotes\n * ```html\n * \n * ...\n * ...\n * \n *```\n *\n * See {@link NgPlural} for more details and example.\n *\n * @publicApi\n */\nclass NgPluralCase {\n value;\n constructor(value, template, viewContainer, ngPlural) {\n this.value = value;\n const isANumber = !isNaN(Number(value));\n ngPlural.addCase(isANumber ? `=${value}` : value, new SwitchView(viewContainer, template));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgPluralCase, deps: [{ token: 'ngPluralCase', attribute: true }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: NgPlural, host: true }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgPluralCase, isStandalone: true, selector: \"[ngPluralCase]\", ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgPluralCase, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngPluralCase]',\n }]\n }], ctorParameters: () => [{ type: undefined, decorators: [{\n type: Attribute,\n args: ['ngPluralCase']\n }] }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: NgPlural, decorators: [{\n type: Host\n }] }] });\n\n/**\n * @ngModule CommonModule\n *\n * @usageNotes\n *\n * Set the font of the containing element to the result of an expression.\n *\n * ```html\n * ...\n * ```\n *\n * Set the width of the containing element to a pixel value returned by an expression.\n *\n * ```html\n * ...\n * ```\n *\n * Set a collection of style values using an expression that returns key-value pairs.\n *\n * ```html\n * ...\n * ```\n *\n * @description\n *\n * An attribute directive that updates styles for the containing HTML element.\n * Sets one or more style properties, specified as colon-separated key-value pairs.\n * The key is a style name, with an optional `.` suffix\n * (such as 'top.px', 'font-style.em').\n * The value is an expression to be evaluated.\n * The resulting non-null value, expressed in the given unit,\n * is assigned to the given style property.\n * If the result of evaluation is null, the corresponding style is removed.\n *\n * @publicApi\n */\nclass NgStyle {\n _ngEl;\n _differs;\n _renderer;\n _ngStyle = null;\n _differ = null;\n constructor(_ngEl, _differs, _renderer) {\n this._ngEl = _ngEl;\n this._differs = _differs;\n this._renderer = _renderer;\n }\n set ngStyle(values) {\n this._ngStyle = values;\n if (!this._differ && values) {\n this._differ = this._differs.find(values).create();\n }\n }\n ngDoCheck() {\n if (this._differ) {\n const changes = this._differ.diff(this._ngStyle);\n if (changes) {\n this._applyChanges(changes);\n }\n }\n }\n _setStyle(nameAndUnit, value) {\n const [name, unit] = nameAndUnit.split('.');\n const flags = name.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashCase;\n if (value != null) {\n this._renderer.setStyle(this._ngEl.nativeElement, name, unit ? `${value}${unit}` : value, flags);\n }\n else {\n this._renderer.removeStyle(this._ngEl.nativeElement, name, flags);\n }\n }\n _applyChanges(changes) {\n changes.forEachRemovedItem((record) => this._setStyle(record.key, null));\n changes.forEachAddedItem((record) => this._setStyle(record.key, record.currentValue));\n changes.forEachChangedItem((record) => this._setStyle(record.key, record.currentValue));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgStyle, deps: [{ token: i0.ElementRef }, { token: i0.KeyValueDiffers }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgStyle, isStandalone: true, selector: \"[ngStyle]\", inputs: { ngStyle: \"ngStyle\" }, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgStyle, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngStyle]',\n }]\n }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.KeyValueDiffers }, { type: i0.Renderer2 }], propDecorators: { ngStyle: [{\n type: Input,\n args: ['ngStyle']\n }] } });\n\n/**\n * @ngModule CommonModule\n *\n * @description\n *\n * Inserts an embedded view from a prepared `TemplateRef`.\n *\n * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.\n * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding\n * by the local template `let` declarations.\n *\n * @usageNotes\n * ```html\n * \n * ```\n *\n * Using the key `$implicit` in the context object will set its value as default.\n *\n * ### Example\n *\n * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}\n *\n * @publicApi\n */\nclass NgTemplateOutlet {\n _viewContainerRef;\n _viewRef = null;\n /**\n * A context object to attach to the {@link EmbeddedViewRef}. This should be an\n * object, the object's keys will be available for binding by the local template `let`\n * declarations.\n * Using the key `$implicit` in the context object will set its value as default.\n */\n ngTemplateOutletContext = null;\n /**\n * A string defining the template reference and optionally the context object for the template.\n */\n ngTemplateOutlet = null;\n /** Injector to be used within the embedded view. */\n ngTemplateOutletInjector = null;\n constructor(_viewContainerRef) {\n this._viewContainerRef = _viewContainerRef;\n }\n ngOnChanges(changes) {\n if (this._shouldRecreateView(changes)) {\n const viewContainerRef = this._viewContainerRef;\n if (this._viewRef) {\n viewContainerRef.remove(viewContainerRef.indexOf(this._viewRef));\n }\n // If there is no outlet, clear the destroyed view ref.\n if (!this.ngTemplateOutlet) {\n this._viewRef = null;\n return;\n }\n // Create a context forward `Proxy` that will always bind to the user-specified context,\n // without having to destroy and re-create views whenever the context changes.\n const viewContext = this._createContextForwardProxy();\n this._viewRef = viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, viewContext, {\n injector: this.ngTemplateOutletInjector ?? undefined,\n });\n }\n }\n /**\n * We need to re-create existing embedded view if either is true:\n * - the outlet changed.\n * - the injector changed.\n */\n _shouldRecreateView(changes) {\n return !!changes['ngTemplateOutlet'] || !!changes['ngTemplateOutletInjector'];\n }\n /**\n * For a given outlet instance, we create a proxy object that delegates\n * to the user-specified context. This allows changing, or swapping out\n * the context object completely without having to destroy/re-create the view.\n */\n _createContextForwardProxy() {\n return new Proxy({}, {\n set: (_target, prop, newValue) => {\n if (!this.ngTemplateOutletContext) {\n return false;\n }\n return Reflect.set(this.ngTemplateOutletContext, prop, newValue);\n },\n get: (_target, prop, receiver) => {\n if (!this.ngTemplateOutletContext) {\n return undefined;\n }\n return Reflect.get(this.ngTemplateOutletContext, prop, receiver);\n },\n });\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgTemplateOutlet, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"14.0.0\", version: \"19.0.6\", type: NgTemplateOutlet, isStandalone: true, selector: \"[ngTemplateOutlet]\", inputs: { ngTemplateOutletContext: \"ngTemplateOutletContext\", ngTemplateOutlet: \"ngTemplateOutlet\", ngTemplateOutletInjector: \"ngTemplateOutletInjector\" }, usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgTemplateOutlet, decorators: [{\n type: Directive,\n args: [{\n selector: '[ngTemplateOutlet]',\n }]\n }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { ngTemplateOutletContext: [{\n type: Input\n }], ngTemplateOutlet: [{\n type: Input\n }], ngTemplateOutletInjector: [{\n type: Input\n }] } });\n\n/**\n * A collection of Angular directives that are likely to be used in each and every Angular\n * application.\n */\nconst COMMON_DIRECTIVES = [\n NgClass,\n NgComponentOutlet,\n NgForOf,\n NgIf,\n NgTemplateOutlet,\n NgStyle,\n NgSwitch,\n NgSwitchCase,\n NgSwitchDefault,\n NgPlural,\n NgPluralCase,\n];\n\nfunction invalidPipeArgumentError(type, value) {\n return new ɵRuntimeError(2100 /* RuntimeErrorCode.INVALID_PIPE_ARGUMENT */, ngDevMode && `InvalidPipeArgument: '${value}' for pipe '${ɵstringify(type)}'`);\n}\n\nclass SubscribableStrategy {\n createSubscription(async, updateLatestValue) {\n // Subscription can be side-effectful, and we don't want any signal reads which happen in the\n // side effect of the subscription to be tracked by a component's template when that\n // subscription is triggered via the async pipe. So we wrap the subscription in `untracked` to\n // decouple from the current reactive context.\n //\n // `untracked` also prevents signal _writes_ which happen in the subscription side effect from\n // being treated as signal writes during the template evaluation (which throws errors).\n return untracked(() => async.subscribe({\n next: updateLatestValue,\n error: (e) => {\n throw e;\n },\n }));\n }\n dispose(subscription) {\n // See the comment in `createSubscription` above on the use of `untracked`.\n untracked(() => subscription.unsubscribe());\n }\n}\nclass PromiseStrategy {\n createSubscription(async, updateLatestValue) {\n return async.then(updateLatestValue, (e) => {\n throw e;\n });\n }\n dispose(subscription) { }\n}\nconst _promiseStrategy = new PromiseStrategy();\nconst _subscribableStrategy = new SubscribableStrategy();\n/**\n * @ngModule CommonModule\n * @description\n *\n * Unwraps a value from an asynchronous primitive.\n *\n * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has\n * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for\n * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid\n * potential memory leaks. When the reference of the expression changes, the `async` pipe\n * automatically unsubscribes from the old `Observable` or `Promise` and subscribes to the new one.\n *\n * @usageNotes\n *\n * ### Examples\n *\n * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the\n * promise.\n *\n * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}\n *\n * It's also possible to use `async` with Observables. The example below binds the `time` Observable\n * to the view. The Observable continuously updates the view with the current time.\n *\n * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}\n *\n * @publicApi\n */\nclass AsyncPipe {\n _ref;\n _latestValue = null;\n markForCheckOnValueUpdate = true;\n _subscription = null;\n _obj = null;\n _strategy = null;\n constructor(ref) {\n // Assign `ref` into `this._ref` manually instead of declaring `_ref` in the constructor\n // parameter list, as the type of `this._ref` includes `null` unlike the type of `ref`.\n this._ref = ref;\n }\n ngOnDestroy() {\n if (this._subscription) {\n this._dispose();\n }\n // Clear the `ChangeDetectorRef` and its association with the view data, to mitigate\n // potential memory leaks in Observables that could otherwise cause the view data to\n // be retained.\n // https://github.com/angular/angular/issues/17624\n this._ref = null;\n }\n transform(obj) {\n if (!this._obj) {\n if (obj) {\n try {\n // Only call `markForCheck` if the value is updated asynchronously.\n // Synchronous updates _during_ subscription should not wastefully mark for check -\n // this value is already going to be returned from the transform function.\n this.markForCheckOnValueUpdate = false;\n this._subscribe(obj);\n }\n finally {\n this.markForCheckOnValueUpdate = true;\n }\n }\n return this._latestValue;\n }\n if (obj !== this._obj) {\n this._dispose();\n return this.transform(obj);\n }\n return this._latestValue;\n }\n _subscribe(obj) {\n this._obj = obj;\n this._strategy = this._selectStrategy(obj);\n this._subscription = this._strategy.createSubscription(obj, (value) => this._updateLatestValue(obj, value));\n }\n _selectStrategy(obj) {\n if (ɵisPromise(obj)) {\n return _promiseStrategy;\n }\n if (ɵisSubscribable(obj)) {\n return _subscribableStrategy;\n }\n throw invalidPipeArgumentError(AsyncPipe, obj);\n }\n _dispose() {\n // Note: `dispose` is only called if a subscription has been initialized before, indicating\n // that `this._strategy` is also available.\n this._strategy.dispose(this._subscription);\n this._latestValue = null;\n this._subscription = null;\n this._obj = null;\n }\n _updateLatestValue(async, value) {\n if (async === this._obj) {\n this._latestValue = value;\n if (this.markForCheckOnValueUpdate) {\n this._ref?.markForCheck();\n }\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: AsyncPipe, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: AsyncPipe, isStandalone: true, name: \"async\", pure: false });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: AsyncPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'async',\n pure: false,\n }]\n }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }] });\n\n/**\n * Transforms text to all lower case.\n *\n * @see {@link UpperCasePipe}\n * @see {@link TitleCasePipe}\n * @usageNotes\n *\n * The following example defines a view that allows the user to enter\n * text, and then uses the pipe to convert the input text to all lower case.\n *\n * {@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe'}\n *\n * @ngModule CommonModule\n * @publicApi\n */\nclass LowerCasePipe {\n transform(value) {\n if (value == null)\n return null;\n if (typeof value !== 'string') {\n throw invalidPipeArgumentError(LowerCasePipe, value);\n }\n return value.toLowerCase();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LowerCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: LowerCasePipe, isStandalone: true, name: \"lowercase\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LowerCasePipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'lowercase',\n }]\n }] });\n//\n// Regex below matches any Unicode word and number compatible with ES5. In ES2018 the same result\n// can be achieved by using /[0-9\\p{L}]\\S*/gu and also known as Unicode Property Escapes\n// (https://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no\n// transpilation of this functionality down to ES5 without external tool, the only solution is\n// to use already transpiled form. Example can be found here -\n// https://mothereff.in/regexpu#input=var+regex+%3D+%2F%5B0-9%5Cp%7BL%7D%5D%5CS*%2Fgu%3B%0A%0A&unicodePropertyEscape=1\n//\nconst unicodeWordMatch = /(?:[0-9A-Za-z\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088E\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u09FC\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0AF9\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58-\\u0C5A\\u0C5D\\u0C60\\u0C61\\u0C80\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D04-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D54-\\u0D56\\u0D5F-\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C88\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7CA\\uA7D0\\uA7D1\\uA7D3\\uA7D5-\\uA7D9\\uA7F2-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8FD\\uA8FE\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB69\\uAB70-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]|\\uD800[\\uDC00-\\uDC0B\\uDC0D-\\uDC26\\uDC28-\\uDC3A\\uDC3C\\uDC3D\\uDC3F-\\uDC4D\\uDC50-\\uDC5D\\uDC80-\\uDCFA\\uDE80-\\uDE9C\\uDEA0-\\uDED0\\uDF00-\\uDF1F\\uDF2D-\\uDF40\\uDF42-\\uDF49\\uDF50-\\uDF75\\uDF80-\\uDF9D\\uDFA0-\\uDFC3\\uDFC8-\\uDFCF]|\\uD801[\\uDC00-\\uDC9D\\uDCB0-\\uDCD3\\uDCD8-\\uDCFB\\uDD00-\\uDD27\\uDD30-\\uDD63\\uDD70-\\uDD7A\\uDD7C-\\uDD8A\\uDD8C-\\uDD92\\uDD94\\uDD95\\uDD97-\\uDDA1\\uDDA3-\\uDDB1\\uDDB3-\\uDDB9\\uDDBB\\uDDBC\\uDE00-\\uDF36\\uDF40-\\uDF55\\uDF60-\\uDF67\\uDF80-\\uDF85\\uDF87-\\uDFB0\\uDFB2-\\uDFBA]|\\uD802[\\uDC00-\\uDC05\\uDC08\\uDC0A-\\uDC35\\uDC37\\uDC38\\uDC3C\\uDC3F-\\uDC55\\uDC60-\\uDC76\\uDC80-\\uDC9E\\uDCE0-\\uDCF2\\uDCF4\\uDCF5\\uDD00-\\uDD15\\uDD20-\\uDD39\\uDD80-\\uDDB7\\uDDBE\\uDDBF\\uDE00\\uDE10-\\uDE13\\uDE15-\\uDE17\\uDE19-\\uDE35\\uDE60-\\uDE7C\\uDE80-\\uDE9C\\uDEC0-\\uDEC7\\uDEC9-\\uDEE4\\uDF00-\\uDF35\\uDF40-\\uDF55\\uDF60-\\uDF72\\uDF80-\\uDF91]|\\uD803[\\uDC00-\\uDC48\\uDC80-\\uDCB2\\uDCC0-\\uDCF2\\uDD00-\\uDD23\\uDE80-\\uDEA9\\uDEB0\\uDEB1\\uDF00-\\uDF1C\\uDF27\\uDF30-\\uDF45\\uDF70-\\uDF81\\uDFB0-\\uDFC4\\uDFE0-\\uDFF6]|\\uD804[\\uDC03-\\uDC37\\uDC71\\uDC72\\uDC75\\uDC83-\\uDCAF\\uDCD0-\\uDCE8\\uDD03-\\uDD26\\uDD44\\uDD47\\uDD50-\\uDD72\\uDD76\\uDD83-\\uDDB2\\uDDC1-\\uDDC4\\uDDDA\\uDDDC\\uDE00-\\uDE11\\uDE13-\\uDE2B\\uDE80-\\uDE86\\uDE88\\uDE8A-\\uDE8D\\uDE8F-\\uDE9D\\uDE9F-\\uDEA8\\uDEB0-\\uDEDE\\uDF05-\\uDF0C\\uDF0F\\uDF10\\uDF13-\\uDF28\\uDF2A-\\uDF30\\uDF32\\uDF33\\uDF35-\\uDF39\\uDF3D\\uDF50\\uDF5D-\\uDF61]|\\uD805[\\uDC00-\\uDC34\\uDC47-\\uDC4A\\uDC5F-\\uDC61\\uDC80-\\uDCAF\\uDCC4\\uDCC5\\uDCC7\\uDD80-\\uDDAE\\uDDD8-\\uDDDB\\uDE00-\\uDE2F\\uDE44\\uDE80-\\uDEAA\\uDEB8\\uDF00-\\uDF1A\\uDF40-\\uDF46]|\\uD806[\\uDC00-\\uDC2B\\uDCA0-\\uDCDF\\uDCFF-\\uDD06\\uDD09\\uDD0C-\\uDD13\\uDD15\\uDD16\\uDD18-\\uDD2F\\uDD3F\\uDD41\\uDDA0-\\uDDA7\\uDDAA-\\uDDD0\\uDDE1\\uDDE3\\uDE00\\uDE0B-\\uDE32\\uDE3A\\uDE50\\uDE5C-\\uDE89\\uDE9D\\uDEB0-\\uDEF8]|\\uD807[\\uDC00-\\uDC08\\uDC0A-\\uDC2E\\uDC40\\uDC72-\\uDC8F\\uDD00-\\uDD06\\uDD08\\uDD09\\uDD0B-\\uDD30\\uDD46\\uDD60-\\uDD65\\uDD67\\uDD68\\uDD6A-\\uDD89\\uDD98\\uDEE0-\\uDEF2\\uDFB0]|\\uD808[\\uDC00-\\uDF99]|\\uD809[\\uDC80-\\uDD43]|\\uD80B[\\uDF90-\\uDFF0]|[\\uD80C\\uD81C-\\uD820\\uD822\\uD840-\\uD868\\uD86A-\\uD86C\\uD86F-\\uD872\\uD874-\\uD879\\uD880-\\uD883][\\uDC00-\\uDFFF]|\\uD80D[\\uDC00-\\uDC2E]|\\uD811[\\uDC00-\\uDE46]|\\uD81A[\\uDC00-\\uDE38\\uDE40-\\uDE5E\\uDE70-\\uDEBE\\uDED0-\\uDEED\\uDF00-\\uDF2F\\uDF40-\\uDF43\\uDF63-\\uDF77\\uDF7D-\\uDF8F]|\\uD81B[\\uDE40-\\uDE7F\\uDF00-\\uDF4A\\uDF50\\uDF93-\\uDF9F\\uDFE0\\uDFE1\\uDFE3]|\\uD821[\\uDC00-\\uDFF7]|\\uD823[\\uDC00-\\uDCD5\\uDD00-\\uDD08]|\\uD82B[\\uDFF0-\\uDFF3\\uDFF5-\\uDFFB\\uDFFD\\uDFFE]|\\uD82C[\\uDC00-\\uDD22\\uDD50-\\uDD52\\uDD64-\\uDD67\\uDD70-\\uDEFB]|\\uD82F[\\uDC00-\\uDC6A\\uDC70-\\uDC7C\\uDC80-\\uDC88\\uDC90-\\uDC99]|\\uD835[\\uDC00-\\uDC54\\uDC56-\\uDC9C\\uDC9E\\uDC9F\\uDCA2\\uDCA5\\uDCA6\\uDCA9-\\uDCAC\\uDCAE-\\uDCB9\\uDCBB\\uDCBD-\\uDCC3\\uDCC5-\\uDD05\\uDD07-\\uDD0A\\uDD0D-\\uDD14\\uDD16-\\uDD1C\\uDD1E-\\uDD39\\uDD3B-\\uDD3E\\uDD40-\\uDD44\\uDD46\\uDD4A-\\uDD50\\uDD52-\\uDEA5\\uDEA8-\\uDEC0\\uDEC2-\\uDEDA\\uDEDC-\\uDEFA\\uDEFC-\\uDF14\\uDF16-\\uDF34\\uDF36-\\uDF4E\\uDF50-\\uDF6E\\uDF70-\\uDF88\\uDF8A-\\uDFA8\\uDFAA-\\uDFC2\\uDFC4-\\uDFCB]|\\uD837[\\uDF00-\\uDF1E]|\\uD838[\\uDD00-\\uDD2C\\uDD37-\\uDD3D\\uDD4E\\uDE90-\\uDEAD\\uDEC0-\\uDEEB]|\\uD839[\\uDFE0-\\uDFE6\\uDFE8-\\uDFEB\\uDFED\\uDFEE\\uDFF0-\\uDFFE]|\\uD83A[\\uDC00-\\uDCC4\\uDD00-\\uDD43\\uDD4B]|\\uD83B[\\uDE00-\\uDE03\\uDE05-\\uDE1F\\uDE21\\uDE22\\uDE24\\uDE27\\uDE29-\\uDE32\\uDE34-\\uDE37\\uDE39\\uDE3B\\uDE42\\uDE47\\uDE49\\uDE4B\\uDE4D-\\uDE4F\\uDE51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB]|\\uD869[\\uDC00-\\uDEDF\\uDF00-\\uDFFF]|\\uD86D[\\uDC00-\\uDF38\\uDF40-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEA1\\uDEB0-\\uDFFF]|\\uD87A[\\uDC00-\\uDFE0]|\\uD87E[\\uDC00-\\uDE1D]|\\uD884[\\uDC00-\\uDF4A])\\S*/g;\n/**\n * Transforms text to title case.\n * Capitalizes the first letter of each word and transforms the\n * rest of the word to lower case.\n * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.\n *\n * @see {@link LowerCasePipe}\n * @see {@link UpperCasePipe}\n *\n * @usageNotes\n * The following example shows the result of transforming various strings into title case.\n *\n * {@example common/pipes/ts/titlecase_pipe.ts region='TitleCasePipe'}\n *\n * @ngModule CommonModule\n * @publicApi\n */\nclass TitleCasePipe {\n transform(value) {\n if (value == null)\n return null;\n if (typeof value !== 'string') {\n throw invalidPipeArgumentError(TitleCasePipe, value);\n }\n return value.replace(unicodeWordMatch, (txt) => txt[0].toUpperCase() + txt.slice(1).toLowerCase());\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: TitleCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: TitleCasePipe, isStandalone: true, name: \"titlecase\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: TitleCasePipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'titlecase',\n }]\n }] });\n/**\n * Transforms text to all upper case.\n * @see {@link LowerCasePipe}\n * @see {@link TitleCasePipe}\n *\n * @ngModule CommonModule\n * @publicApi\n */\nclass UpperCasePipe {\n transform(value) {\n if (value == null)\n return null;\n if (typeof value !== 'string') {\n throw invalidPipeArgumentError(UpperCasePipe, value);\n }\n return value.toUpperCase();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: UpperCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: UpperCasePipe, isStandalone: true, name: \"uppercase\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: UpperCasePipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'uppercase',\n }]\n }] });\n\n/**\n * The default date format of Angular date pipe, which corresponds to the following format:\n * `'MMM d,y'` (e.g. `Jun 15, 2015`)\n */\nconst DEFAULT_DATE_FORMAT = 'mediumDate';\n\n/**\n * Optionally-provided default timezone to use for all instances of `DatePipe` (such as `'+0430'`).\n * If the value isn't provided, the `DatePipe` will use the end-user's local system timezone.\n *\n * @deprecated use DATE_PIPE_DEFAULT_OPTIONS token to configure DatePipe\n */\nconst DATE_PIPE_DEFAULT_TIMEZONE = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_TIMEZONE' : '');\n/**\n * DI token that allows to provide default configuration for the `DatePipe` instances in an\n * application. The value is an object which can include the following fields:\n * - `dateFormat`: configures the default date format. If not provided, the `DatePipe`\n * will use the 'mediumDate' as a value.\n * - `timezone`: configures the default timezone. If not provided, the `DatePipe` will\n * use the end-user's local system timezone.\n *\n * @see {@link DatePipeConfig}\n *\n * @usageNotes\n *\n * Various date pipe default values can be overwritten by providing this token with\n * the value that has this interface.\n *\n * For example:\n *\n * Override the default date format by providing a value using the token:\n * ```ts\n * providers: [\n * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {dateFormat: 'shortDate'}}\n * ]\n * ```\n *\n * Override the default timezone by providing a value using the token:\n * ```ts\n * providers: [\n * {provide: DATE_PIPE_DEFAULT_OPTIONS, useValue: {timezone: '-1200'}}\n * ]\n * ```\n */\nconst DATE_PIPE_DEFAULT_OPTIONS = new InjectionToken(ngDevMode ? 'DATE_PIPE_DEFAULT_OPTIONS' : '');\n/**\n * @ngModule CommonModule\n * @description\n *\n * Formats a date value according to locale rules.\n *\n * `DatePipe` is executed only when it detects a pure change to the input value.\n * A pure change is either a change to a primitive input value\n * (such as `String`, `Number`, `Boolean`, or `Symbol`),\n * or a changed object reference (such as `Date`, `Array`, `Function`, or `Object`).\n *\n * Note that mutating a `Date` object does not cause the pipe to be rendered again.\n * To ensure that the pipe is executed, you must create a new `Date` object.\n *\n * Only the `en-US` locale data comes with Angular. To localize dates\n * in another language, you must import the corresponding locale data.\n * See the [I18n guide](guide/i18n/format-data-locale) for more information.\n *\n * The time zone of the formatted value can be specified either by passing it in as the second\n * parameter of the pipe, or by setting the default through the `DATE_PIPE_DEFAULT_OPTIONS`\n * injection token. The value that is passed in as the second parameter takes precedence over\n * the one defined using the injection token.\n *\n * @see {@link formatDate}\n *\n *\n * @usageNotes\n *\n * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to\n * reformat the date on every change-detection cycle, treat the date as an immutable object\n * and change the reference when the pipe needs to run again.\n *\n * ### Pre-defined format options\n *\n * | Option | Equivalent to | Examples (given in `en-US` locale) |\n * |---------------|-------------------------------------|-------------------------------------------------|\n * | `'short'` | `'M/d/yy, h:mm a'` | `6/15/15, 9:03 AM` |\n * | `'medium'` | `'MMM d, y, h:mm:ss a'` | `Jun 15, 2015, 9:03:01 AM` |\n * | `'long'` | `'MMMM d, y, h:mm:ss a z'` | `June 15, 2015 at 9:03:01 AM GMT+1` |\n * | `'full'` | `'EEEE, MMMM d, y, h:mm:ss a zzzz'` | `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00` |\n * | `'shortDate'` | `'M/d/yy'` | `6/15/15` |\n * | `'mediumDate'`| `'MMM d, y'` | `Jun 15, 2015` |\n * | `'longDate'` | `'MMMM d, y'` | `June 15, 2015` |\n * | `'fullDate'` | `'EEEE, MMMM d, y'` | `Monday, June 15, 2015` |\n * | `'shortTime'` | `'h:mm a'` | `9:03 AM` |\n * | `'mediumTime'`| `'h:mm:ss a'` | `9:03:01 AM` |\n * | `'longTime'` | `'h:mm:ss a z'` | `9:03:01 AM GMT+1` |\n * | `'fullTime'` | `'h:mm:ss a zzzz'` | `9:03:01 AM GMT+01:00` |\n *\n * ### Custom format options\n *\n * You can construct a format string using symbols to specify the components\n * of a date-time value, as described in the following table.\n * Format details depend on the locale.\n * Fields marked with (*) are only available in the extra data set for the given locale.\n *\n * | Field type | Format | Description | Example Value |\n * |-------------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|\n * | Era | G, GG & GGG | Abbreviated | AD |\n * | | GGGG | Wide | Anno Domini |\n * | | GGGGG | Narrow | A |\n * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |\n * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |\n * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |\n * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |\n * | ISO Week-numbering year | Y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |\n * | | YY | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |\n * | | YYY | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |\n * | | YYYY | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |\n * | Month | M | Numeric: 1 digit | 9, 12 |\n * | | MM | Numeric: 2 digits + zero padded | 09, 12 |\n * | | MMM | Abbreviated | Sep |\n * | | MMMM | Wide | September |\n * | | MMMMM | Narrow | S |\n * | Month standalone | L | Numeric: 1 digit | 9, 12 |\n * | | LL | Numeric: 2 digits + zero padded | 09, 12 |\n * | | LLL | Abbreviated | Sep |\n * | | LLLL | Wide | September |\n * | | LLLLL | Narrow | S |\n * | ISO Week of year | w | Numeric: minimum digits | 1... 53 |\n * | | ww | Numeric: 2 digits + zero padded | 01... 53 |\n * | Week of month | W | Numeric: 1 digit | 1... 5 |\n * | Day of month | d | Numeric: minimum digits | 1 |\n * | | dd | Numeric: 2 digits + zero padded | 01 |\n * | Week day | E, EE & EEE | Abbreviated | Tue |\n * | | EEEE | Wide | Tuesday |\n * | | EEEEE | Narrow | T |\n * | | EEEEEE | Short | Tu |\n * | Week day standalone | c, cc | Numeric: 1 digit | 2 |\n * | | ccc | Abbreviated | Tue |\n * | | cccc | Wide | Tuesday |\n * | | ccccc | Narrow | T |\n * | | cccccc | Short | Tu |\n * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |\n * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |\n * | | aaaaa | Narrow | a/p |\n * | Period* | B, BB & BBB | Abbreviated | mid. |\n * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |\n * | | BBBBB | Narrow | md |\n * | Period standalone* | b, bb & bbb | Abbreviated | mid. |\n * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |\n * | | bbbbb | Narrow | md |\n * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |\n * | | hh | Numeric: 2 digits + zero padded | 01, 12 |\n * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |\n * | | HH | Numeric: 2 digits + zero padded | 00, 23 |\n * | Minute | m | Numeric: minimum digits | 8, 59 |\n * | | mm | Numeric: 2 digits + zero padded | 08, 59 |\n * | Second | s | Numeric: minimum digits | 0... 59 |\n * | | ss | Numeric: 2 digits + zero padded | 00... 59 |\n * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |\n * | | SS | Numeric: 2 digits + zero padded | 00... 99 |\n * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |\n * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |\n * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |\n * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |\n * | | ZZZZ | Long localized GMT format | GMT-8:00 |\n * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |\n * | | O, OO & OOO | Short localized GMT format | GMT-8 |\n * | | OOOO | Long localized GMT format | GMT-08:00 |\n *\n *\n * ### Format examples\n *\n * These examples transform a date into various formats,\n * assuming that `dateObj` is a JavaScript `Date` object for\n * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,\n * given in the local time for the `en-US` locale.\n *\n * ```\n * {{ dateObj | date }} // output is 'Jun 15, 2015'\n * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'\n * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'\n * {{ dateObj | date:'mm:ss' }} // output is '43:11'\n * {{ dateObj | date:\"MMM dd, yyyy 'at' hh:mm a\" }} // output is 'Jun 15, 2015 at 09:43 PM'\n * ```\n *\n * ### Usage example\n *\n * The following component uses a date pipe to display the current date in different formats.\n *\n * ```angular-ts\n * @Component({\n * selector: 'date-pipe',\n * template: `
    \n *

    Today is {{today | date}}

    \n *

    Or if you prefer, {{today | date:'fullDate'}}

    \n *

    The time is {{today | date:'h:mm a z'}}

    \n *
    `\n * })\n * // Get the current date and time as a date-time value.\n * export class DatePipeComponent {\n * today: number = Date.now();\n * }\n * ```\n *\n * @publicApi\n */\nclass DatePipe {\n locale;\n defaultTimezone;\n defaultOptions;\n constructor(locale, defaultTimezone, defaultOptions) {\n this.locale = locale;\n this.defaultTimezone = defaultTimezone;\n this.defaultOptions = defaultOptions;\n }\n transform(value, format, timezone, locale) {\n if (value == null || value === '' || value !== value)\n return null;\n try {\n const _format = format ?? this.defaultOptions?.dateFormat ?? DEFAULT_DATE_FORMAT;\n const _timezone = timezone ?? this.defaultOptions?.timezone ?? this.defaultTimezone ?? undefined;\n return formatDate(value, _format, locale || this.locale, _timezone);\n }\n catch (error) {\n throw invalidPipeArgumentError(DatePipe, error.message);\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: DatePipe, deps: [{ token: LOCALE_ID }, { token: DATE_PIPE_DEFAULT_TIMEZONE, optional: true }, { token: DATE_PIPE_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: DatePipe, isStandalone: true, name: \"date\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: DatePipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'date',\n }]\n }], ctorParameters: () => [{ type: undefined, decorators: [{\n type: Inject,\n args: [LOCALE_ID]\n }] }, { type: undefined, decorators: [{\n type: Inject,\n args: [DATE_PIPE_DEFAULT_TIMEZONE]\n }, {\n type: Optional\n }] }, { type: undefined, decorators: [{\n type: Inject,\n args: [DATE_PIPE_DEFAULT_OPTIONS]\n }, {\n type: Optional\n }] }] });\n\nconst _INTERPOLATION_REGEXP = /#/g;\n/**\n * @ngModule CommonModule\n * @description\n *\n * Maps a value to a string that pluralizes the value according to locale rules.\n *\n * @usageNotes\n *\n * ### Example\n *\n * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}\n *\n * @publicApi\n */\nclass I18nPluralPipe {\n _localization;\n constructor(_localization) {\n this._localization = _localization;\n }\n /**\n * @param value the number to be formatted\n * @param pluralMap an object that mimics the ICU format, see\n * https://unicode-org.github.io/icu/userguide/format_parse/messages/.\n * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by\n * default).\n */\n transform(value, pluralMap, locale) {\n if (value == null)\n return '';\n if (typeof pluralMap !== 'object' || pluralMap === null) {\n throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);\n }\n const key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);\n return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: I18nPluralPipe, deps: [{ token: NgLocalization }], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: I18nPluralPipe, isStandalone: true, name: \"i18nPlural\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: I18nPluralPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'i18nPlural',\n }]\n }], ctorParameters: () => [{ type: NgLocalization }] });\n\n/**\n * @ngModule CommonModule\n * @description\n *\n * Generic selector that displays the string that matches the current value.\n *\n * If none of the keys of the `mapping` match the `value`, then the content\n * of the `other` key is returned when present, otherwise an empty string is returned.\n *\n * @usageNotes\n *\n * ### Example\n *\n * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}\n *\n * @publicApi\n */\nclass I18nSelectPipe {\n /**\n * @param value a string to be internationalized.\n * @param mapping an object that indicates the text that should be displayed\n * for different values of the provided `value`.\n */\n transform(value, mapping) {\n if (value == null)\n return '';\n if (typeof mapping !== 'object' || typeof value !== 'string') {\n throw invalidPipeArgumentError(I18nSelectPipe, mapping);\n }\n if (mapping.hasOwnProperty(value)) {\n return mapping[value];\n }\n if (mapping.hasOwnProperty('other')) {\n return mapping['other'];\n }\n return '';\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: I18nSelectPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: I18nSelectPipe, isStandalone: true, name: \"i18nSelect\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: I18nSelectPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'i18nSelect',\n }]\n }] });\n\n/**\n * @ngModule CommonModule\n * @description\n *\n * Converts a value into its JSON-format representation. Useful for debugging.\n *\n * @usageNotes\n *\n * The following component uses a JSON pipe to convert an object\n * to JSON format, and displays the string in both formats for comparison.\n *\n * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}\n *\n * @publicApi\n */\nclass JsonPipe {\n /**\n * @param value A value of any type to convert into a JSON-format string.\n */\n transform(value) {\n return JSON.stringify(value, null, 2);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: JsonPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: JsonPipe, isStandalone: true, name: \"json\", pure: false });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: JsonPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'json',\n pure: false,\n }]\n }] });\n\nfunction makeKeyValuePair(key, value) {\n return { key: key, value: value };\n}\n/**\n * @ngModule CommonModule\n * @description\n *\n * Transforms Object or Map into an array of key value pairs.\n *\n * The output array will be ordered by keys.\n * By default the comparator will be by Unicode point value.\n * You can optionally pass a compareFn if your keys are complex types.\n * Passing `null` as the compareFn will use natural ordering of the input.\n *\n * @usageNotes\n * ### Examples\n *\n * This examples show how an Object or a Map can be iterated by ngFor with the use of this\n * keyvalue pipe.\n *\n * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}\n *\n * @publicApi\n */\nclass KeyValuePipe {\n differs;\n constructor(differs) {\n this.differs = differs;\n }\n differ;\n keyValues = [];\n compareFn = defaultComparator;\n transform(input, compareFn = defaultComparator) {\n if (!input || (!(input instanceof Map) && typeof input !== 'object')) {\n return null;\n }\n // make a differ for whatever type we've been passed in\n this.differ ??= this.differs.find(input).create();\n const differChanges = this.differ.diff(input);\n const compareFnChanged = compareFn !== this.compareFn;\n if (differChanges) {\n this.keyValues = [];\n differChanges.forEachItem((r) => {\n this.keyValues.push(makeKeyValuePair(r.key, r.currentValue));\n });\n }\n if (differChanges || compareFnChanged) {\n if (compareFn) {\n this.keyValues.sort(compareFn);\n }\n this.compareFn = compareFn;\n }\n return this.keyValues;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: KeyValuePipe, deps: [{ token: i0.KeyValueDiffers }], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: KeyValuePipe, isStandalone: true, name: \"keyvalue\", pure: false });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: KeyValuePipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'keyvalue',\n pure: false,\n }]\n }], ctorParameters: () => [{ type: i0.KeyValueDiffers }] });\nfunction defaultComparator(keyValueA, keyValueB) {\n const a = keyValueA.key;\n const b = keyValueB.key;\n // if same exit with 0;\n if (a === b)\n return 0;\n // make sure that undefined are at the end of the sort.\n if (a === undefined)\n return 1;\n if (b === undefined)\n return -1;\n // make sure that nulls are at the end of the sort.\n if (a === null)\n return 1;\n if (b === null)\n return -1;\n if (typeof a == 'string' && typeof b == 'string') {\n return a < b ? -1 : 1;\n }\n if (typeof a == 'number' && typeof b == 'number') {\n return a - b;\n }\n if (typeof a == 'boolean' && typeof b == 'boolean') {\n return a < b ? -1 : 1;\n }\n // `a` and `b` are of different types. Compare their string values.\n const aString = String(a);\n const bString = String(b);\n return aString == bString ? 0 : aString < bString ? -1 : 1;\n}\n\n/**\n * @ngModule CommonModule\n * @description\n *\n * Formats a value according to digit options and locale rules.\n * Locale determines group sizing and separator,\n * decimal point character, and other locale-specific configurations.\n *\n * @see {@link formatNumber}\n *\n * @usageNotes\n *\n * ### digitsInfo\n *\n * The value's decimal representation is specified by the `digitsInfo`\n * parameter, written in the following format:
    \n *\n * ```\n * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}\n * ```\n *\n * - `minIntegerDigits`:\n * The minimum number of integer digits before the decimal point.\n * Default is 1.\n *\n * - `minFractionDigits`:\n * The minimum number of digits after the decimal point.\n * Default is 0.\n *\n * - `maxFractionDigits`:\n * The maximum number of digits after the decimal point.\n * Default is 3.\n *\n * If the formatted value is truncated it will be rounded using the \"to-nearest\" method:\n *\n * ```\n * {{3.6 | number: '1.0-0'}}\n * \n *\n * {{-3.6 | number:'1.0-0'}}\n * \n * ```\n *\n * ### locale\n *\n * `locale` will format a value according to locale rules.\n * Locale determines group sizing and separator,\n * decimal point character, and other locale-specific configurations.\n *\n * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.\n *\n * See [Setting your app locale](guide/i18n/locale-id).\n *\n * ### Example\n *\n * The following code shows how the pipe transforms values\n * according to various format specifications,\n * where the caller's default locale is `en-US`.\n *\n * {@example common/pipes/ts/number_pipe.ts region='NumberPipe'}\n *\n * @publicApi\n */\nclass DecimalPipe {\n _locale;\n constructor(_locale) {\n this._locale = _locale;\n }\n transform(value, digitsInfo, locale) {\n if (!isValue(value))\n return null;\n locale ||= this._locale;\n try {\n const num = strToNumber(value);\n return formatNumber(num, locale, digitsInfo);\n }\n catch (error) {\n throw invalidPipeArgumentError(DecimalPipe, error.message);\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: DecimalPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: DecimalPipe, isStandalone: true, name: \"number\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: DecimalPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'number',\n }]\n }], ctorParameters: () => [{ type: undefined, decorators: [{\n type: Inject,\n args: [LOCALE_ID]\n }] }] });\n/**\n * @ngModule CommonModule\n * @description\n *\n * Transforms a number to a percentage\n * string, formatted according to locale rules that determine group sizing and\n * separator, decimal-point character, and other locale-specific\n * configurations.\n *\n * @see {@link formatPercent}\n *\n * @usageNotes\n * The following code shows how the pipe transforms numbers\n * into text strings, according to various format specifications,\n * where the caller's default locale is `en-US`.\n *\n * {@example common/pipes/ts/percent_pipe.ts region='PercentPipe'}\n *\n * @publicApi\n */\nclass PercentPipe {\n _locale;\n constructor(_locale) {\n this._locale = _locale;\n }\n /**\n *\n * @param value The number to be formatted as a percentage.\n * @param digitsInfo Decimal representation options, specified by a string\n * in the following format:
    \n * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}.\n * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.\n * Default is `1`.\n * - `minFractionDigits`: The minimum number of digits after the decimal point.\n * Default is `0`.\n * - `maxFractionDigits`: The maximum number of digits after the decimal point.\n * Default is `0`.\n * @param locale A locale code for the locale format rules to use.\n * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.\n * See [Setting your app locale](guide/i18n/locale-id).\n */\n transform(value, digitsInfo, locale) {\n if (!isValue(value))\n return null;\n locale ||= this._locale;\n try {\n const num = strToNumber(value);\n return formatPercent(num, locale, digitsInfo);\n }\n catch (error) {\n throw invalidPipeArgumentError(PercentPipe, error.message);\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PercentPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: PercentPipe, isStandalone: true, name: \"percent\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PercentPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'percent',\n }]\n }], ctorParameters: () => [{ type: undefined, decorators: [{\n type: Inject,\n args: [LOCALE_ID]\n }] }] });\n/**\n * @ngModule CommonModule\n * @description\n *\n * Transforms a number to a currency string, formatted according to locale rules\n * that determine group sizing and separator, decimal-point character,\n * and other locale-specific configurations.\n *\n *\n * @see {@link getCurrencySymbol}\n * @see {@link formatCurrency}\n *\n * @usageNotes\n * The following code shows how the pipe transforms numbers\n * into text strings, according to various format specifications,\n * where the caller's default locale is `en-US`.\n *\n * {@example common/pipes/ts/currency_pipe.ts region='CurrencyPipe'}\n *\n * @publicApi\n */\nclass CurrencyPipe {\n _locale;\n _defaultCurrencyCode;\n constructor(_locale, _defaultCurrencyCode = 'USD') {\n this._locale = _locale;\n this._defaultCurrencyCode = _defaultCurrencyCode;\n }\n transform(value, currencyCode = this._defaultCurrencyCode, display = 'symbol', digitsInfo, locale) {\n if (!isValue(value))\n return null;\n locale ||= this._locale;\n if (typeof display === 'boolean') {\n if ((typeof ngDevMode === 'undefined' || ngDevMode) && console && console.warn) {\n console.warn(`Warning: the currency pipe has been changed in Angular v5. The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are \"code\", \"symbol\" or \"symbol-narrow\".`);\n }\n display = display ? 'symbol' : 'code';\n }\n let currency = currencyCode || this._defaultCurrencyCode;\n if (display !== 'code') {\n if (display === 'symbol' || display === 'symbol-narrow') {\n currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);\n }\n else {\n currency = display;\n }\n }\n try {\n const num = strToNumber(value);\n return formatCurrency(num, locale, currency, currencyCode, digitsInfo);\n }\n catch (error) {\n throw invalidPipeArgumentError(CurrencyPipe, error.message);\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: CurrencyPipe, deps: [{ token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: CurrencyPipe, isStandalone: true, name: \"currency\" });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: CurrencyPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'currency',\n }]\n }], ctorParameters: () => [{ type: undefined, decorators: [{\n type: Inject,\n args: [LOCALE_ID]\n }] }, { type: undefined, decorators: [{\n type: Inject,\n args: [DEFAULT_CURRENCY_CODE]\n }] }] });\nfunction isValue(value) {\n return !(value == null || value === '' || value !== value);\n}\n/**\n * Transforms a string into a number (if needed).\n */\nfunction strToNumber(value) {\n // Convert strings to numbers\n if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) {\n return Number(value);\n }\n if (typeof value !== 'number') {\n throw new Error(`${value} is not a number`);\n }\n return value;\n}\n\n/**\n * @ngModule CommonModule\n * @description\n *\n * Creates a new `Array` or `String` containing a subset (slice) of the elements.\n *\n * @usageNotes\n *\n * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`\n * and `String.prototype.slice()`.\n *\n * When operating on an `Array`, the returned `Array` is always a copy even when all\n * the elements are being returned.\n *\n * When operating on a blank value, the pipe returns the blank value.\n *\n * ### List Example\n *\n * This `ngFor` example:\n *\n * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}\n *\n * produces the following:\n *\n * ```html\n *
  • b
  • \n *
  • c
  • \n * ```\n *\n * ### String Examples\n *\n * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}\n *\n * @publicApi\n */\nclass SlicePipe {\n transform(value, start, end) {\n if (value == null)\n return null;\n if (!this.supports(value)) {\n throw invalidPipeArgumentError(SlicePipe, value);\n }\n return value.slice(start, end);\n }\n supports(obj) {\n return typeof obj === 'string' || Array.isArray(obj);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: SlicePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });\n static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: SlicePipe, isStandalone: true, name: \"slice\", pure: false });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: SlicePipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'slice',\n pure: false,\n }]\n }] });\n\n/**\n * @module\n * @description\n * This module provides a set of common Pipes.\n */\n/**\n * A collection of Angular pipes that are likely to be used in each and every application.\n */\nconst COMMON_PIPES = [\n AsyncPipe,\n UpperCasePipe,\n LowerCasePipe,\n JsonPipe,\n SlicePipe,\n DecimalPipe,\n PercentPipe,\n TitleCasePipe,\n CurrencyPipe,\n DatePipe,\n I18nPluralPipe,\n I18nSelectPipe,\n KeyValuePipe,\n];\n\n// Note: This does not contain the location providers,\n// as they need some platform specific implementations to work.\n/**\n * Exports all the basic Angular directives and pipes,\n * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.\n * Re-exported by `BrowserModule`, which is included automatically in the root\n * `AppModule` when you create a new app with the CLI `new` command.\n *\n * @publicApi\n */\nclass CommonModule {\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: CommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });\n static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: \"14.0.0\", version: \"19.0.6\", ngImport: i0, type: CommonModule, imports: [NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase, AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, KeyValuePipe], exports: [NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase, AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, KeyValuePipe] });\n static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: CommonModule });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: CommonModule, decorators: [{\n type: NgModule,\n args: [{\n imports: [COMMON_DIRECTIVES, COMMON_PIPES],\n exports: [COMMON_DIRECTIVES, COMMON_PIPES],\n }]\n }] });\n\nconst PLATFORM_BROWSER_ID = 'browser';\nconst PLATFORM_SERVER_ID = 'server';\n/**\n * Returns whether a platform id represents a browser platform.\n * @publicApi\n */\nfunction isPlatformBrowser(platformId) {\n return platformId === PLATFORM_BROWSER_ID;\n}\n/**\n * Returns whether a platform id represents a server platform.\n * @publicApi\n */\nfunction isPlatformServer(platformId) {\n return platformId === PLATFORM_SERVER_ID;\n}\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the common package.\n */\n/**\n * @publicApi\n */\nconst VERSION = new Version('19.0.6');\n\n/**\n * Defines a scroll position manager. Implemented by `BrowserViewportScroller`.\n *\n * @publicApi\n */\nclass ViewportScroller {\n // De-sugared tree-shakable injection\n // See #23917\n /** @nocollapse */\n static ɵprov = /** @pureOrBreakMyCode */ /* @__PURE__ */ ɵɵdefineInjectable({\n token: ViewportScroller,\n providedIn: 'root',\n factory: () => isPlatformBrowser(inject(PLATFORM_ID))\n ? new BrowserViewportScroller(inject(DOCUMENT), window)\n : new NullViewportScroller(),\n });\n}\n/**\n * Manages the scroll position for a browser window.\n */\nclass BrowserViewportScroller {\n document;\n window;\n offset = () => [0, 0];\n constructor(document, window) {\n this.document = document;\n this.window = window;\n }\n /**\n * Configures the top offset used when scrolling to an anchor.\n * @param offset A position in screen coordinates (a tuple with x and y values)\n * or a function that returns the top offset position.\n *\n */\n setOffset(offset) {\n if (Array.isArray(offset)) {\n this.offset = () => offset;\n }\n else {\n this.offset = offset;\n }\n }\n /**\n * Retrieves the current scroll position.\n * @returns The position in screen coordinates.\n */\n getScrollPosition() {\n return [this.window.scrollX, this.window.scrollY];\n }\n /**\n * Sets the scroll position.\n * @param position The new position in screen coordinates.\n */\n scrollToPosition(position) {\n this.window.scrollTo(position[0], position[1]);\n }\n /**\n * Scrolls to an element and attempts to focus the element.\n *\n * Note that the function name here is misleading in that the target string may be an ID for a\n * non-anchor element.\n *\n * @param target The ID of an element or name of the anchor.\n *\n * @see https://html.spec.whatwg.org/#the-indicated-part-of-the-document\n * @see https://html.spec.whatwg.org/#scroll-to-fragid\n */\n scrollToAnchor(target) {\n const elSelected = findAnchorFromDocument(this.document, target);\n if (elSelected) {\n this.scrollToElement(elSelected);\n // After scrolling to the element, the spec dictates that we follow the focus steps for the\n // target. Rather than following the robust steps, simply attempt focus.\n //\n // @see https://html.spec.whatwg.org/#get-the-focusable-area\n // @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus\n // @see https://html.spec.whatwg.org/#focusable-area\n elSelected.focus();\n }\n }\n /**\n * Disables automatic scroll restoration provided by the browser.\n */\n setHistoryScrollRestoration(scrollRestoration) {\n this.window.history.scrollRestoration = scrollRestoration;\n }\n /**\n * Scrolls to an element using the native offset and the specified offset set on this scroller.\n *\n * The offset can be used when we know that there is a floating header and scrolling naively to an\n * element (ex: `scrollIntoView`) leaves the element hidden behind the floating header.\n */\n scrollToElement(el) {\n const rect = el.getBoundingClientRect();\n const left = rect.left + this.window.pageXOffset;\n const top = rect.top + this.window.pageYOffset;\n const offset = this.offset();\n this.window.scrollTo(left - offset[0], top - offset[1]);\n }\n}\nfunction findAnchorFromDocument(document, target) {\n const documentResult = document.getElementById(target) || document.getElementsByName(target)[0];\n if (documentResult) {\n return documentResult;\n }\n // `getElementById` and `getElementsByName` won't pierce through the shadow DOM so we\n // have to traverse the DOM manually and do the lookup through the shadow roots.\n if (typeof document.createTreeWalker === 'function' &&\n document.body &&\n typeof document.body.attachShadow === 'function') {\n const treeWalker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT);\n let currentNode = treeWalker.currentNode;\n while (currentNode) {\n const shadowRoot = currentNode.shadowRoot;\n if (shadowRoot) {\n // Note that `ShadowRoot` doesn't support `getElementsByName`\n // so we have to fall back to `querySelector`.\n const result = shadowRoot.getElementById(target) || shadowRoot.querySelector(`[name=\"${target}\"]`);\n if (result) {\n return result;\n }\n }\n currentNode = treeWalker.nextNode();\n }\n }\n return null;\n}\n/**\n * Provides an empty implementation of the viewport scroller.\n */\nclass NullViewportScroller {\n /**\n * Empty implementation\n */\n setOffset(offset) { }\n /**\n * Empty implementation\n */\n getScrollPosition() {\n return [0, 0];\n }\n /**\n * Empty implementation\n */\n scrollToPosition(position) { }\n /**\n * Empty implementation\n */\n scrollToAnchor(anchor) { }\n /**\n * Empty implementation\n */\n setHistoryScrollRestoration(scrollRestoration) { }\n}\n\n/**\n * A wrapper around the `XMLHttpRequest` constructor.\n *\n * @publicApi\n */\nclass XhrFactory {\n}\n\n/**\n * Value (out of 100) of the requested quality for placeholder images.\n */\nconst PLACEHOLDER_QUALITY = '20';\n\n// Converts a string that represents a URL into a URL class instance.\nfunction getUrl(src, win) {\n // Don't use a base URL is the URL is absolute.\n return isAbsoluteUrl(src) ? new URL(src) : new URL(src, win.location.href);\n}\n// Checks whether a URL is absolute (i.e. starts with `http://` or `https://`).\nfunction isAbsoluteUrl(src) {\n return /^https?:\\/\\//.test(src);\n}\n// Given a URL, extract the hostname part.\n// If a URL is a relative one - the URL is returned as is.\nfunction extractHostname(url) {\n return isAbsoluteUrl(url) ? new URL(url).hostname : url;\n}\nfunction isValidPath(path) {\n const isString = typeof path === 'string';\n if (!isString || path.trim() === '') {\n return false;\n }\n // Calling new URL() will throw if the path string is malformed\n try {\n const url = new URL(path);\n return true;\n }\n catch {\n return false;\n }\n}\nfunction normalizePath(path) {\n return path.endsWith('/') ? path.slice(0, -1) : path;\n}\nfunction normalizeSrc(src) {\n return src.startsWith('/') ? src.slice(1) : src;\n}\n\n/**\n * Noop image loader that does no transformation to the original src and just returns it as is.\n * This loader is used as a default one if more specific logic is not provided in an app config.\n *\n * @see {@link ImageLoader}\n * @see {@link NgOptimizedImage}\n */\nconst noopImageLoader = (config) => config.src;\n/**\n * Injection token that configures the image loader function.\n *\n * @see {@link ImageLoader}\n * @see {@link NgOptimizedImage}\n * @publicApi\n */\nconst IMAGE_LOADER = new InjectionToken(ngDevMode ? 'ImageLoader' : '', {\n providedIn: 'root',\n factory: () => noopImageLoader,\n});\n/**\n * Internal helper function that makes it easier to introduce custom image loaders for the\n * `NgOptimizedImage` directive. It is enough to specify a URL builder function to obtain full DI\n * configuration for a given loader: a DI token corresponding to the actual loader function, plus DI\n * tokens managing preconnect check functionality.\n * @param buildUrlFn a function returning a full URL based on loader's configuration\n * @param exampleUrls example of full URLs for a given loader (used in error messages)\n * @returns a set of DI providers corresponding to the configured image loader\n */\nfunction createImageLoader(buildUrlFn, exampleUrls) {\n return function provideImageLoader(path) {\n if (!isValidPath(path)) {\n throwInvalidPathError(path, exampleUrls || []);\n }\n // The trailing / is stripped (if provided) to make URL construction (concatenation) easier in\n // the individual loader functions.\n path = normalizePath(path);\n const loaderFn = (config) => {\n if (isAbsoluteUrl(config.src)) {\n // Image loader functions expect an image file name (e.g. `my-image.png`)\n // or a relative path + a file name (e.g. `/a/b/c/my-image.png`) as an input,\n // so the final absolute URL can be constructed.\n // When an absolute URL is provided instead - the loader can not\n // build a final URL, thus the error is thrown to indicate that.\n throwUnexpectedAbsoluteUrlError(path, config.src);\n }\n return buildUrlFn(path, { ...config, src: normalizeSrc(config.src) });\n };\n const providers = [{ provide: IMAGE_LOADER, useValue: loaderFn }];\n return providers;\n };\n}\nfunction throwInvalidPathError(path, exampleUrls) {\n throw new ɵRuntimeError(2959 /* RuntimeErrorCode.INVALID_LOADER_ARGUMENTS */, ngDevMode &&\n `Image loader has detected an invalid path (\\`${path}\\`). ` +\n `To fix this, supply a path using one of the following formats: ${exampleUrls.join(' or ')}`);\n}\nfunction throwUnexpectedAbsoluteUrlError(path, url) {\n throw new ɵRuntimeError(2959 /* RuntimeErrorCode.INVALID_LOADER_ARGUMENTS */, ngDevMode &&\n `Image loader has detected a \\`\\` tag with an invalid \\`ngSrc\\` attribute: ${url}. ` +\n `This image loader expects \\`ngSrc\\` to be a relative URL - ` +\n `however the provided value is an absolute URL. ` +\n `To fix this, provide \\`ngSrc\\` as a path relative to the base URL ` +\n `configured for this loader (\\`${path}\\`).`);\n}\n\n/**\n * Function that generates an ImageLoader for [Cloudflare Image\n * Resizing](https://developers.cloudflare.com/images/image-resizing/) and turns it into an Angular\n * provider. Note: Cloudflare has multiple image products - this provider is specifically for\n * Cloudflare Image Resizing; it will not work with Cloudflare Images or Cloudflare Polish.\n *\n * @param path Your domain name, e.g. https://mysite.com\n * @returns Provider that provides an ImageLoader function\n *\n * @publicApi\n */\nconst provideCloudflareLoader = createImageLoader(createCloudflareUrl, ngDevMode ? ['https:///cdn-cgi/image//'] : undefined);\nfunction createCloudflareUrl(path, config) {\n let params = `format=auto`;\n if (config.width) {\n params += `,width=${config.width}`;\n }\n // When requesting a placeholder image we ask for a low quality image to reduce the load time.\n if (config.isPlaceholder) {\n params += `,quality=${PLACEHOLDER_QUALITY}`;\n }\n // Cloudflare image URLs format:\n // https://developers.cloudflare.com/images/image-resizing/url-format/\n return `${path}/cdn-cgi/image/${params}/${config.src}`;\n}\n\n/**\n * Name and URL tester for Cloudinary.\n */\nconst cloudinaryLoaderInfo = {\n name: 'Cloudinary',\n testUrl: isCloudinaryUrl,\n};\nconst CLOUDINARY_LOADER_REGEX = /https?\\:\\/\\/[^\\/]+\\.cloudinary\\.com\\/.+/;\n/**\n * Tests whether a URL is from Cloudinary CDN.\n */\nfunction isCloudinaryUrl(url) {\n return CLOUDINARY_LOADER_REGEX.test(url);\n}\n/**\n * Function that generates an ImageLoader for Cloudinary and turns it into an Angular provider.\n *\n * @param path Base URL of your Cloudinary images\n * This URL should match one of the following formats:\n * https://res.cloudinary.com/mysite\n * https://mysite.cloudinary.com\n * https://subdomain.mysite.com\n * @returns Set of providers to configure the Cloudinary loader.\n *\n * @publicApi\n */\nconst provideCloudinaryLoader = createImageLoader(createCloudinaryUrl, ngDevMode\n ? [\n 'https://res.cloudinary.com/mysite',\n 'https://mysite.cloudinary.com',\n 'https://subdomain.mysite.com',\n ]\n : undefined);\nfunction createCloudinaryUrl(path, config) {\n // Cloudinary image URLformat:\n // https://cloudinary.com/documentation/image_transformations#transformation_url_structure\n // Example of a Cloudinary image URL:\n // https://res.cloudinary.com/mysite/image/upload/c_scale,f_auto,q_auto,w_600/marketing/tile-topics-m.png\n // For a placeholder image, we use the lowest image setting available to reduce the load time\n // else we use the auto size\n const quality = config.isPlaceholder ? 'q_auto:low' : 'q_auto';\n let params = `f_auto,${quality}`;\n if (config.width) {\n params += `,w_${config.width}`;\n }\n if (config.loaderParams?.['rounded']) {\n params += `,r_max`;\n }\n return `${path}/image/upload/${params}/${config.src}`;\n}\n\n/**\n * Name and URL tester for ImageKit.\n */\nconst imageKitLoaderInfo = {\n name: 'ImageKit',\n testUrl: isImageKitUrl,\n};\nconst IMAGE_KIT_LOADER_REGEX = /https?\\:\\/\\/[^\\/]+\\.imagekit\\.io\\/.+/;\n/**\n * Tests whether a URL is from ImageKit CDN.\n */\nfunction isImageKitUrl(url) {\n return IMAGE_KIT_LOADER_REGEX.test(url);\n}\n/**\n * Function that generates an ImageLoader for ImageKit and turns it into an Angular provider.\n *\n * @param path Base URL of your ImageKit images\n * This URL should match one of the following formats:\n * https://ik.imagekit.io/myaccount\n * https://subdomain.mysite.com\n * @returns Set of providers to configure the ImageKit loader.\n *\n * @publicApi\n */\nconst provideImageKitLoader = createImageLoader(createImagekitUrl, ngDevMode ? ['https://ik.imagekit.io/mysite', 'https://subdomain.mysite.com'] : undefined);\nfunction createImagekitUrl(path, config) {\n // Example of an ImageKit image URL:\n // https://ik.imagekit.io/demo/tr:w-300,h-300/medium_cafe_B1iTdD0C.jpg\n const { src, width } = config;\n const params = [];\n if (width) {\n params.push(`w-${width}`);\n }\n // When requesting a placeholder image we ask for a low quality image to reduce the load time.\n if (config.isPlaceholder) {\n params.push(`q-${PLACEHOLDER_QUALITY}`);\n }\n const urlSegments = params.length ? [path, `tr:${params.join(',')}`, src] : [path, src];\n const url = new URL(urlSegments.join('/'));\n return url.href;\n}\n\n/**\n * Name and URL tester for Imgix.\n */\nconst imgixLoaderInfo = {\n name: 'Imgix',\n testUrl: isImgixUrl,\n};\nconst IMGIX_LOADER_REGEX = /https?\\:\\/\\/[^\\/]+\\.imgix\\.net\\/.+/;\n/**\n * Tests whether a URL is from Imgix CDN.\n */\nfunction isImgixUrl(url) {\n return IMGIX_LOADER_REGEX.test(url);\n}\n/**\n * Function that generates an ImageLoader for Imgix and turns it into an Angular provider.\n *\n * @param path path to the desired Imgix origin,\n * e.g. https://somepath.imgix.net or https://images.mysite.com\n * @returns Set of providers to configure the Imgix loader.\n *\n * @publicApi\n */\nconst provideImgixLoader = createImageLoader(createImgixUrl, ngDevMode ? ['https://somepath.imgix.net/'] : undefined);\nfunction createImgixUrl(path, config) {\n const url = new URL(`${path}/${config.src}`);\n // This setting ensures the smallest allowable format is set.\n url.searchParams.set('auto', 'format');\n if (config.width) {\n url.searchParams.set('w', config.width.toString());\n }\n // When requesting a placeholder image we ask a low quality image to reduce the load time.\n if (config.isPlaceholder) {\n url.searchParams.set('q', PLACEHOLDER_QUALITY);\n }\n return url.href;\n}\n\n/**\n * Name and URL tester for Netlify.\n */\nconst netlifyLoaderInfo = {\n name: 'Netlify',\n testUrl: isNetlifyUrl,\n};\nconst NETLIFY_LOADER_REGEX = /https?\\:\\/\\/[^\\/]+\\.netlify\\.app\\/.+/;\n/**\n * Tests whether a URL is from a Netlify site. This won't catch sites with a custom domain,\n * but it's a good start for sites in development. This is only used to warn users who haven't\n * configured an image loader.\n */\nfunction isNetlifyUrl(url) {\n return NETLIFY_LOADER_REGEX.test(url);\n}\n/**\n * Function that generates an ImageLoader for Netlify and turns it into an Angular provider.\n *\n * @param path optional URL of the desired Netlify site. Defaults to the current site.\n * @returns Set of providers to configure the Netlify loader.\n *\n * @publicApi\n */\nfunction provideNetlifyLoader(path) {\n if (path && !isValidPath(path)) {\n throw new ɵRuntimeError(2959 /* RuntimeErrorCode.INVALID_LOADER_ARGUMENTS */, ngDevMode &&\n `Image loader has detected an invalid path (\\`${path}\\`). ` +\n `To fix this, supply either the full URL to the Netlify site, or leave it empty to use the current site.`);\n }\n if (path) {\n const url = new URL(path);\n path = url.origin;\n }\n const loaderFn = (config) => {\n return createNetlifyUrl(config, path);\n };\n const providers = [{ provide: IMAGE_LOADER, useValue: loaderFn }];\n return providers;\n}\nconst validParams = new Map([\n ['height', 'h'],\n ['fit', 'fit'],\n ['quality', 'q'],\n ['q', 'q'],\n ['position', 'position'],\n]);\nfunction createNetlifyUrl(config, path) {\n // Note: `path` can be undefined, in which case we use a fake one to construct a `URL` instance.\n const url = new URL(path ?? 'https://a/');\n url.pathname = '/.netlify/images';\n if (!isAbsoluteUrl(config.src) && !config.src.startsWith('/')) {\n config.src = '/' + config.src;\n }\n url.searchParams.set('url', config.src);\n if (config.width) {\n url.searchParams.set('w', config.width.toString());\n }\n // When requesting a placeholder image we ask for a low quality image to reduce the load time.\n // If the quality is specified in the loader config - always use provided value.\n const configQuality = config.loaderParams?.['quality'] ?? config.loaderParams?.['q'];\n if (config.isPlaceholder && !configQuality) {\n url.searchParams.set('q', PLACEHOLDER_QUALITY);\n }\n for (const [param, value] of Object.entries(config.loaderParams ?? {})) {\n if (validParams.has(param)) {\n url.searchParams.set(validParams.get(param), value.toString());\n }\n else {\n if (ngDevMode) {\n console.warn(ɵformatRuntimeError(2959 /* RuntimeErrorCode.INVALID_LOADER_ARGUMENTS */, `The Netlify image loader has detected an \\`\\` tag with the unsupported attribute \"\\`${param}\\`\".`));\n }\n }\n }\n // The \"a\" hostname is used for relative URLs, so we can remove it from the final URL.\n return url.hostname === 'a' ? url.href.replace(url.origin, '') : url.href;\n}\n\n// Assembles directive details string, useful for error messages.\nfunction imgDirectiveDetails(ngSrc, includeNgSrc = true) {\n const ngSrcInfo = includeNgSrc\n ? `(activated on an element with the \\`ngSrc=\"${ngSrc}\"\\`) `\n : '';\n return `The NgOptimizedImage directive ${ngSrcInfo}has detected that`;\n}\n\n/**\n * Asserts that the application is in development mode. Throws an error if the application is in\n * production mode. This assert can be used to make sure that there is no dev-mode code invoked in\n * the prod mode accidentally.\n */\nfunction assertDevMode(checkName) {\n if (!ngDevMode) {\n throw new ɵRuntimeError(2958 /* RuntimeErrorCode.UNEXPECTED_DEV_MODE_CHECK_IN_PROD_MODE */, `Unexpected invocation of the ${checkName} in the prod mode. ` +\n `Please make sure that the prod mode is enabled for production builds.`);\n }\n}\n\n/**\n * Observer that detects whether an image with `NgOptimizedImage`\n * is treated as a Largest Contentful Paint (LCP) element. If so,\n * asserts that the image has the `priority` attribute.\n *\n * Note: this is a dev-mode only class and it does not appear in prod bundles,\n * thus there is no `ngDevMode` use in the code.\n *\n * Based on https://web.dev/lcp/#measure-lcp-in-javascript.\n */\nclass LCPImageObserver {\n // Map of full image URLs -> original `ngSrc` values.\n images = new Map();\n window = null;\n observer = null;\n constructor() {\n const isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n assertDevMode('LCP checker');\n const win = inject(DOCUMENT).defaultView;\n if (isBrowser && typeof PerformanceObserver !== 'undefined') {\n this.window = win;\n this.observer = this.initPerformanceObserver();\n }\n }\n /**\n * Inits PerformanceObserver and subscribes to LCP events.\n * Based on https://web.dev/lcp/#measure-lcp-in-javascript\n */\n initPerformanceObserver() {\n const observer = new PerformanceObserver((entryList) => {\n const entries = entryList.getEntries();\n if (entries.length === 0)\n return;\n // We use the latest entry produced by the `PerformanceObserver` as the best\n // signal on which element is actually an LCP one. As an example, the first image to load on\n // a page, by virtue of being the only thing on the page so far, is often a LCP candidate\n // and gets reported by PerformanceObserver, but isn't necessarily the LCP element.\n const lcpElement = entries[entries.length - 1];\n // Cast to `any` due to missing `element` on the `LargestContentfulPaint` type of entry.\n // See https://developer.mozilla.org/en-US/docs/Web/API/LargestContentfulPaint\n const imgSrc = lcpElement.element?.src ?? '';\n // Exclude `data:` and `blob:` URLs, since they are not supported by the directive.\n if (imgSrc.startsWith('data:') || imgSrc.startsWith('blob:'))\n return;\n const img = this.images.get(imgSrc);\n if (!img)\n return;\n if (!img.priority && !img.alreadyWarnedPriority) {\n img.alreadyWarnedPriority = true;\n logMissingPriorityError(imgSrc);\n }\n if (img.modified && !img.alreadyWarnedModified) {\n img.alreadyWarnedModified = true;\n logModifiedWarning(imgSrc);\n }\n });\n observer.observe({ type: 'largest-contentful-paint', buffered: true });\n return observer;\n }\n registerImage(rewrittenSrc, originalNgSrc, isPriority) {\n if (!this.observer)\n return;\n const newObservedImageState = {\n priority: isPriority,\n modified: false,\n alreadyWarnedModified: false,\n alreadyWarnedPriority: false,\n };\n this.images.set(getUrl(rewrittenSrc, this.window).href, newObservedImageState);\n }\n unregisterImage(rewrittenSrc) {\n if (!this.observer)\n return;\n this.images.delete(getUrl(rewrittenSrc, this.window).href);\n }\n updateImage(originalSrc, newSrc) {\n if (!this.observer)\n return;\n const originalUrl = getUrl(originalSrc, this.window).href;\n const img = this.images.get(originalUrl);\n if (img) {\n img.modified = true;\n this.images.set(getUrl(newSrc, this.window).href, img);\n this.images.delete(originalUrl);\n }\n }\n ngOnDestroy() {\n if (!this.observer)\n return;\n this.observer.disconnect();\n this.images.clear();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LCPImageObserver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LCPImageObserver, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: LCPImageObserver, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\nfunction logMissingPriorityError(ngSrc) {\n const directiveDetails = imgDirectiveDetails(ngSrc);\n console.error(ɵformatRuntimeError(2955 /* RuntimeErrorCode.LCP_IMG_MISSING_PRIORITY */, `${directiveDetails} this image is the Largest Contentful Paint (LCP) ` +\n `element but was not marked \"priority\". This image should be marked ` +\n `\"priority\" in order to prioritize its loading. ` +\n `To fix this, add the \"priority\" attribute.`));\n}\nfunction logModifiedWarning(ngSrc) {\n const directiveDetails = imgDirectiveDetails(ngSrc);\n console.warn(ɵformatRuntimeError(2964 /* RuntimeErrorCode.LCP_IMG_NGSRC_MODIFIED */, `${directiveDetails} this image is the Largest Contentful Paint (LCP) ` +\n `element and has had its \"ngSrc\" attribute modified. This can cause ` +\n `slower loading performance. It is recommended not to modify the \"ngSrc\" ` +\n `property on any image which could be the LCP element.`));\n}\n\n// Set of origins that are always excluded from the preconnect checks.\nconst INTERNAL_PRECONNECT_CHECK_BLOCKLIST = new Set(['localhost', '127.0.0.1', '0.0.0.0']);\n/**\n * Injection token to configure which origins should be excluded\n * from the preconnect checks. It can either be a single string or an array of strings\n * to represent a group of origins, for example:\n *\n * ```ts\n * {provide: PRECONNECT_CHECK_BLOCKLIST, useValue: 'https://your-domain.com'}\n * ```\n *\n * or:\n *\n * ```ts\n * {provide: PRECONNECT_CHECK_BLOCKLIST,\n * useValue: ['https://your-domain-1.com', 'https://your-domain-2.com']}\n * ```\n *\n * @publicApi\n */\nconst PRECONNECT_CHECK_BLOCKLIST = new InjectionToken(ngDevMode ? 'PRECONNECT_CHECK_BLOCKLIST' : '');\n/**\n * Contains the logic to detect whether an image, marked with the \"priority\" attribute\n * has a corresponding `` tag in the `document.head`.\n *\n * Note: this is a dev-mode only class, which should not appear in prod bundles,\n * thus there is no `ngDevMode` use in the code.\n */\nclass PreconnectLinkChecker {\n document = inject(DOCUMENT);\n isServer = isPlatformServer(inject(PLATFORM_ID));\n /**\n * Set of tags found on this page.\n * The `null` value indicates that there was no DOM query operation performed.\n */\n preconnectLinks = null;\n /*\n * Keep track of all already seen origin URLs to avoid repeating the same check.\n */\n alreadySeen = new Set();\n window = null;\n blocklist = new Set(INTERNAL_PRECONNECT_CHECK_BLOCKLIST);\n constructor() {\n assertDevMode('preconnect link checker');\n const win = this.document.defaultView;\n if (typeof win !== 'undefined') {\n this.window = win;\n }\n const blocklist = inject(PRECONNECT_CHECK_BLOCKLIST, { optional: true });\n if (blocklist) {\n this.populateBlocklist(blocklist);\n }\n }\n populateBlocklist(origins) {\n if (Array.isArray(origins)) {\n deepForEach(origins, (origin) => {\n this.blocklist.add(extractHostname(origin));\n });\n }\n else {\n this.blocklist.add(extractHostname(origins));\n }\n }\n /**\n * Checks that a preconnect resource hint exists in the head for the\n * given src.\n *\n * @param rewrittenSrc src formatted with loader\n * @param originalNgSrc ngSrc value\n */\n assertPreconnect(rewrittenSrc, originalNgSrc) {\n if (this.isServer)\n return;\n const imgUrl = getUrl(rewrittenSrc, this.window);\n if (this.blocklist.has(imgUrl.hostname) || this.alreadySeen.has(imgUrl.origin))\n return;\n // Register this origin as seen, so we don't check it again later.\n this.alreadySeen.add(imgUrl.origin);\n // Note: we query for preconnect links only *once* and cache the results\n // for the entire lifespan of an application, since it's unlikely that the\n // list would change frequently. This allows to make sure there are no\n // performance implications of making extra DOM lookups for each image.\n this.preconnectLinks ??= this.queryPreconnectLinks();\n if (!this.preconnectLinks.has(imgUrl.origin)) {\n console.warn(ɵformatRuntimeError(2956 /* RuntimeErrorCode.PRIORITY_IMG_MISSING_PRECONNECT_TAG */, `${imgDirectiveDetails(originalNgSrc)} there is no preconnect tag present for this ` +\n `image. Preconnecting to the origin(s) that serve priority images ensures that these ` +\n `images are delivered as soon as possible. To fix this, please add the following ` +\n `element into the of the document:\\n` +\n ` `));\n }\n }\n queryPreconnectLinks() {\n const preconnectUrls = new Set();\n const selector = 'link[rel=preconnect]';\n const links = Array.from(this.document.querySelectorAll(selector));\n for (let link of links) {\n const url = getUrl(link.href, this.window);\n preconnectUrls.add(url.origin);\n }\n return preconnectUrls;\n }\n ngOnDestroy() {\n this.preconnectLinks?.clear();\n this.alreadySeen.clear();\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PreconnectLinkChecker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PreconnectLinkChecker, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PreconnectLinkChecker, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }], ctorParameters: () => [] });\n/**\n * Invokes a callback for each element in the array. Also invokes a callback\n * recursively for each nested array.\n */\nfunction deepForEach(input, fn) {\n for (let value of input) {\n Array.isArray(value) ? deepForEach(value, fn) : fn(value);\n }\n}\n\n/**\n * In SSR scenarios, a preload `` element is generated for priority images.\n * Having a large number of preload tags may negatively affect the performance,\n * so we warn developers (by throwing an error) if the number of preloaded images\n * is above a certain threshold. This const specifies this threshold.\n */\nconst DEFAULT_PRELOADED_IMAGES_LIMIT = 5;\n/**\n * Helps to keep track of priority images that already have a corresponding\n * preload tag (to avoid generating multiple preload tags with the same URL).\n *\n * This Set tracks the original src passed into the `ngSrc` input not the src after it has been\n * run through the specified `IMAGE_LOADER`.\n */\nconst PRELOADED_IMAGES = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'NG_OPTIMIZED_PRELOADED_IMAGES' : '', {\n providedIn: 'root',\n factory: () => new Set(),\n});\n\n/**\n * @description Contains the logic needed to track and add preload link tags to the `` tag. It\n * will also track what images have already had preload link tags added so as to not duplicate link\n * tags.\n *\n * In dev mode this service will validate that the number of preloaded images does not exceed the\n * configured default preloaded images limit: {@link DEFAULT_PRELOADED_IMAGES_LIMIT}.\n */\nclass PreloadLinkCreator {\n preloadedImages = inject(PRELOADED_IMAGES);\n document = inject(DOCUMENT);\n /**\n * @description Add a preload `` to the `` of the `index.html` that is served from the\n * server while using Angular Universal and SSR to kick off image loads for high priority images.\n *\n * The `sizes` (passed in from the user) and `srcset` (parsed and formatted from `ngSrcset`)\n * properties used to set the corresponding attributes, `imagesizes` and `imagesrcset`\n * respectively, on the preload `` tag so that the correctly sized image is preloaded from\n * the CDN.\n *\n * {@link https://web.dev/preload-responsive-images/#imagesrcset-and-imagesizes}\n *\n * @param renderer The `Renderer2` passed in from the directive\n * @param src The original src of the image that is set on the `ngSrc` input.\n * @param srcset The parsed and formatted srcset created from the `ngSrcset` input\n * @param sizes The value of the `sizes` attribute passed in to the `` tag\n */\n createPreloadLinkTag(renderer, src, srcset, sizes) {\n if (ngDevMode) {\n if (this.preloadedImages.size >= DEFAULT_PRELOADED_IMAGES_LIMIT) {\n throw new ɵRuntimeError(2961 /* RuntimeErrorCode.TOO_MANY_PRELOADED_IMAGES */, ngDevMode &&\n `The \\`NgOptimizedImage\\` directive has detected that more than ` +\n `${DEFAULT_PRELOADED_IMAGES_LIMIT} images were marked as priority. ` +\n `This might negatively affect an overall performance of the page. ` +\n `To fix this, remove the \"priority\" attribute from images with less priority.`);\n }\n }\n if (this.preloadedImages.has(src)) {\n return;\n }\n this.preloadedImages.add(src);\n const preload = renderer.createElement('link');\n renderer.setAttribute(preload, 'as', 'image');\n renderer.setAttribute(preload, 'href', src);\n renderer.setAttribute(preload, 'rel', 'preload');\n renderer.setAttribute(preload, 'fetchpriority', 'high');\n if (sizes) {\n renderer.setAttribute(preload, 'imageSizes', sizes);\n }\n if (srcset) {\n renderer.setAttribute(preload, 'imageSrcset', srcset);\n }\n renderer.appendChild(this.document.head, preload);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PreloadLinkCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PreloadLinkCreator, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: PreloadLinkCreator, decorators: [{\n type: Injectable,\n args: [{ providedIn: 'root' }]\n }] });\n\n/**\n * When a Base64-encoded image is passed as an input to the `NgOptimizedImage` directive,\n * an error is thrown. The image content (as a string) might be very long, thus making\n * it hard to read an error message if the entire string is included. This const defines\n * the number of characters that should be included into the error message. The rest\n * of the content is truncated.\n */\nconst BASE64_IMG_MAX_LENGTH_IN_ERROR = 50;\n/**\n * RegExpr to determine whether a src in a srcset is using width descriptors.\n * Should match something like: \"100w, 200w\".\n */\nconst VALID_WIDTH_DESCRIPTOR_SRCSET = /^((\\s*\\d+w\\s*(,|$)){1,})$/;\n/**\n * RegExpr to determine whether a src in a srcset is using density descriptors.\n * Should match something like: \"1x, 2x, 50x\". Also supports decimals like \"1.5x, 1.50x\".\n */\nconst VALID_DENSITY_DESCRIPTOR_SRCSET = /^((\\s*\\d+(\\.\\d+)?x\\s*(,|$)){1,})$/;\n/**\n * Srcset values with a density descriptor higher than this value will actively\n * throw an error. Such densities are not permitted as they cause image sizes\n * to be unreasonably large and slow down LCP.\n */\nconst ABSOLUTE_SRCSET_DENSITY_CAP = 3;\n/**\n * Used only in error message text to communicate best practices, as we will\n * only throw based on the slightly more conservative ABSOLUTE_SRCSET_DENSITY_CAP.\n */\nconst RECOMMENDED_SRCSET_DENSITY_CAP = 2;\n/**\n * Used in generating automatic density-based srcsets\n */\nconst DENSITY_SRCSET_MULTIPLIERS = [1, 2];\n/**\n * Used to determine which breakpoints to use on full-width images\n */\nconst VIEWPORT_BREAKPOINT_CUTOFF = 640;\n/**\n * Used to determine whether two aspect ratios are similar in value.\n */\nconst ASPECT_RATIO_TOLERANCE = 0.1;\n/**\n * Used to determine whether the image has been requested at an overly\n * large size compared to the actual rendered image size (after taking\n * into account a typical device pixel ratio). In pixels.\n */\nconst OVERSIZED_IMAGE_TOLERANCE = 1000;\n/**\n * Used to limit automatic srcset generation of very large sources for\n * fixed-size images. In pixels.\n */\nconst FIXED_SRCSET_WIDTH_LIMIT = 1920;\nconst FIXED_SRCSET_HEIGHT_LIMIT = 1080;\n/**\n * Default blur radius of the CSS filter used on placeholder images, in pixels\n */\nconst PLACEHOLDER_BLUR_AMOUNT = 15;\n/**\n * Placeholder dimension (height or width) limit in pixels. Angular produces a warning\n * when this limit is crossed.\n */\nconst PLACEHOLDER_DIMENSION_LIMIT = 1000;\n/**\n * Used to warn or error when the user provides an overly large dataURL for the placeholder\n * attribute.\n * Character count of Base64 images is 1 character per byte, and base64 encoding is approximately\n * 33% larger than base images, so 4000 characters is around 3KB on disk and 10000 characters is\n * around 7.7KB. Experimentally, 4000 characters is about 20x20px in PNG or medium-quality JPEG\n * format, and 10,000 is around 50x50px, but there's quite a bit of variation depending on how the\n * image is saved.\n */\nconst DATA_URL_WARN_LIMIT = 4000;\nconst DATA_URL_ERROR_LIMIT = 10000;\n/** Info about built-in loaders we can test for. */\nconst BUILT_IN_LOADERS = [\n imgixLoaderInfo,\n imageKitLoaderInfo,\n cloudinaryLoaderInfo,\n netlifyLoaderInfo,\n];\n/**\n * Threshold for the PRIORITY_TRUE_COUNT\n */\nconst PRIORITY_COUNT_THRESHOLD = 10;\n/**\n * This count is used to log a devMode warning\n * when the count of directive instances with priority=true\n * exceeds the threshold PRIORITY_COUNT_THRESHOLD\n */\nlet IMGS_WITH_PRIORITY_ATTR_COUNT = 0;\n/**\n * This function is for testing purpose.\n */\nfunction resetImagePriorityCount() {\n IMGS_WITH_PRIORITY_ATTR_COUNT = 0;\n}\n/**\n * Directive that improves image loading performance by enforcing best practices.\n *\n * `NgOptimizedImage` ensures that the loading of the Largest Contentful Paint (LCP) image is\n * prioritized by:\n * - Automatically setting the `fetchpriority` attribute on the `` tag\n * - Lazy loading non-priority images by default\n * - Automatically generating a preconnect link tag in the document head\n *\n * In addition, the directive:\n * - Generates appropriate asset URLs if a corresponding `ImageLoader` function is provided\n * - Automatically generates a srcset\n * - Requires that `width` and `height` are set\n * - Warns if `width` or `height` have been set incorrectly\n * - Warns if the image will be visually distorted when rendered\n *\n * @usageNotes\n * The `NgOptimizedImage` directive is marked as [standalone](guide/components/importing) and can\n * be imported directly.\n *\n * Follow the steps below to enable and use the directive:\n * 1. Import it into the necessary NgModule or a standalone Component.\n * 2. Optionally provide an `ImageLoader` if you use an image hosting service.\n * 3. Update the necessary `` tags in templates and replace `src` attributes with `ngSrc`.\n * Using a `ngSrc` allows the directive to control when the `src` gets set, which triggers an image\n * download.\n *\n * Step 1: import the `NgOptimizedImage` directive.\n *\n * ```ts\n * import { NgOptimizedImage } from '@angular/common';\n *\n * // Include it into the necessary NgModule\n * @NgModule({\n * imports: [NgOptimizedImage],\n * })\n * class AppModule {}\n *\n * // ... or a standalone Component\n * @Component({\n * imports: [NgOptimizedImage],\n * })\n * class MyStandaloneComponent {}\n * ```\n *\n * Step 2: configure a loader.\n *\n * To use the **default loader**: no additional code changes are necessary. The URL returned by the\n * generic loader will always match the value of \"src\". In other words, this loader applies no\n * transformations to the resource URL and the value of the `ngSrc` attribute will be used as is.\n *\n * To use an existing loader for a **third-party image service**: add the provider factory for your\n * chosen service to the `providers` array. In the example below, the Imgix loader is used:\n *\n * ```ts\n * import {provideImgixLoader} from '@angular/common';\n *\n * // Call the function and add the result to the `providers` array:\n * providers: [\n * provideImgixLoader(\"https://my.base.url/\"),\n * ],\n * ```\n *\n * The `NgOptimizedImage` directive provides the following functions:\n * - `provideCloudflareLoader`\n * - `provideCloudinaryLoader`\n * - `provideImageKitLoader`\n * - `provideImgixLoader`\n *\n * If you use a different image provider, you can create a custom loader function as described\n * below.\n *\n * To use a **custom loader**: provide your loader function as a value for the `IMAGE_LOADER` DI\n * token.\n *\n * ```ts\n * import {IMAGE_LOADER, ImageLoaderConfig} from '@angular/common';\n *\n * // Configure the loader using the `IMAGE_LOADER` token.\n * providers: [\n * {\n * provide: IMAGE_LOADER,\n * useValue: (config: ImageLoaderConfig) => {\n * return `https://example.com/${config.src}-${config.width}.jpg`;\n * }\n * },\n * ],\n * ```\n *\n * Step 3: update `` tags in templates to use `ngSrc` instead of `src`.\n *\n * ```html\n * \n * ```\n *\n * @publicApi\n */\nclass NgOptimizedImage {\n imageLoader = inject(IMAGE_LOADER);\n config = processConfig(inject(ɵIMAGE_CONFIG));\n renderer = inject(Renderer2);\n imgElement = inject(ElementRef).nativeElement;\n injector = inject(Injector);\n isServer = isPlatformServer(inject(PLATFORM_ID));\n preloadLinkCreator = inject(PreloadLinkCreator);\n // a LCP image observer - should be injected only in the dev mode\n lcpObserver = ngDevMode ? this.injector.get(LCPImageObserver) : null;\n /**\n * Calculate the rewritten `src` once and store it.\n * This is needed to avoid repetitive calculations and make sure the directive cleanup in the\n * `ngOnDestroy` does not rely on the `IMAGE_LOADER` logic (which in turn can rely on some other\n * instance that might be already destroyed).\n */\n _renderedSrc = null;\n /**\n * Name of the source image.\n * Image name will be processed by the image loader and the final URL will be applied as the `src`\n * property of the image.\n */\n ngSrc;\n /**\n * A comma separated list of width or density descriptors.\n * The image name will be taken from `ngSrc` and combined with the list of width or density\n * descriptors to generate the final `srcset` property of the image.\n *\n * Example:\n * ```\n * =>\n * \n * ```\n */\n ngSrcset;\n /**\n * The base `sizes` attribute passed through to the `` element.\n * Providing sizes causes the image to create an automatic responsive srcset.\n */\n sizes;\n /**\n * For responsive images: the intrinsic width of the image in pixels.\n * For fixed size images: the desired rendered width of the image in pixels.\n */\n width;\n /**\n * For responsive images: the intrinsic height of the image in pixels.\n * For fixed size images: the desired rendered height of the image in pixels.\n */\n height;\n /**\n * The desired loading behavior (lazy, eager, or auto). Defaults to `lazy`,\n * which is recommended for most images.\n *\n * Warning: Setting images as loading=\"eager\" or loading=\"auto\" marks them\n * as non-priority images and can hurt loading performance. For images which\n * may be the LCP element, use the `priority` attribute instead of `loading`.\n */\n loading;\n /**\n * Indicates whether this image should have a high priority.\n */\n priority = false;\n /**\n * Data to pass through to custom loaders.\n */\n loaderParams;\n /**\n * Disables automatic srcset generation for this image.\n */\n disableOptimizedSrcset = false;\n /**\n * Sets the image to \"fill mode\", which eliminates the height/width requirement and adds\n * styles such that the image fills its containing element.\n */\n fill = false;\n /**\n * A URL or data URL for an image to be used as a placeholder while this image loads.\n */\n placeholder;\n /**\n * Configuration object for placeholder settings. Options:\n * * blur: Setting this to false disables the automatic CSS blur.\n */\n placeholderConfig;\n /**\n * Value of the `src` attribute if set on the host `` element.\n * This input is exclusively read to assert that `src` is not set in conflict\n * with `ngSrc` and that images don't start to load until a lazy loading strategy is set.\n * @internal\n */\n src;\n /**\n * Value of the `srcset` attribute if set on the host `` element.\n * This input is exclusively read to assert that `srcset` is not set in conflict\n * with `ngSrcset` and that images don't start to load until a lazy loading strategy is set.\n * @internal\n */\n srcset;\n /** @nodoc */\n ngOnInit() {\n ɵperformanceMarkFeature('NgOptimizedImage');\n if (ngDevMode) {\n const ngZone = this.injector.get(NgZone);\n assertNonEmptyInput(this, 'ngSrc', this.ngSrc);\n assertValidNgSrcset(this, this.ngSrcset);\n assertNoConflictingSrc(this);\n if (this.ngSrcset) {\n assertNoConflictingSrcset(this);\n }\n assertNotBase64Image(this);\n assertNotBlobUrl(this);\n if (this.fill) {\n assertEmptyWidthAndHeight(this);\n // This leaves the Angular zone to avoid triggering unnecessary change detection cycles when\n // `load` tasks are invoked on images.\n ngZone.runOutsideAngular(() => assertNonZeroRenderedHeight(this, this.imgElement, this.renderer));\n }\n else {\n assertNonEmptyWidthAndHeight(this);\n if (this.height !== undefined) {\n assertGreaterThanZero(this, this.height, 'height');\n }\n if (this.width !== undefined) {\n assertGreaterThanZero(this, this.width, 'width');\n }\n // Only check for distorted images when not in fill mode, where\n // images may be intentionally stretched, cropped or letterboxed.\n ngZone.runOutsideAngular(() => assertNoImageDistortion(this, this.imgElement, this.renderer));\n }\n assertValidLoadingInput(this);\n if (!this.ngSrcset) {\n assertNoComplexSizes(this);\n }\n assertValidPlaceholder(this, this.imageLoader);\n assertNotMissingBuiltInLoader(this.ngSrc, this.imageLoader);\n assertNoNgSrcsetWithoutLoader(this, this.imageLoader);\n assertNoLoaderParamsWithoutLoader(this, this.imageLoader);\n if (this.lcpObserver !== null) {\n const ngZone = this.injector.get(NgZone);\n ngZone.runOutsideAngular(() => {\n this.lcpObserver.registerImage(this.getRewrittenSrc(), this.ngSrc, this.priority);\n });\n }\n if (this.priority) {\n const checker = this.injector.get(PreconnectLinkChecker);\n checker.assertPreconnect(this.getRewrittenSrc(), this.ngSrc);\n if (!this.isServer) {\n const applicationRef = this.injector.get(ApplicationRef);\n assetPriorityCountBelowThreshold(applicationRef);\n }\n }\n }\n if (this.placeholder) {\n this.removePlaceholderOnLoad(this.imgElement);\n }\n this.setHostAttributes();\n }\n setHostAttributes() {\n // Must set width/height explicitly in case they are bound (in which case they will\n // only be reflected and not found by the browser)\n if (this.fill) {\n this.sizes ||= '100vw';\n }\n else {\n this.setHostAttribute('width', this.width.toString());\n this.setHostAttribute('height', this.height.toString());\n }\n this.setHostAttribute('loading', this.getLoadingBehavior());\n this.setHostAttribute('fetchpriority', this.getFetchPriority());\n // The `data-ng-img` attribute flags an image as using the directive, to allow\n // for analysis of the directive's performance.\n this.setHostAttribute('ng-img', 'true');\n // The `src` and `srcset` attributes should be set last since other attributes\n // could affect the image's loading behavior.\n const rewrittenSrcset = this.updateSrcAndSrcset();\n if (this.sizes) {\n if (this.getLoadingBehavior() === 'lazy') {\n this.setHostAttribute('sizes', 'auto, ' + this.sizes);\n }\n else {\n this.setHostAttribute('sizes', this.sizes);\n }\n }\n else {\n if (this.ngSrcset &&\n VALID_WIDTH_DESCRIPTOR_SRCSET.test(this.ngSrcset) &&\n this.getLoadingBehavior() === 'lazy') {\n this.setHostAttribute('sizes', 'auto, 100vw');\n }\n }\n if (this.isServer && this.priority) {\n this.preloadLinkCreator.createPreloadLinkTag(this.renderer, this.getRewrittenSrc(), rewrittenSrcset, this.sizes);\n }\n }\n /** @nodoc */\n ngOnChanges(changes) {\n if (ngDevMode) {\n assertNoPostInitInputChange(this, changes, [\n 'ngSrcset',\n 'width',\n 'height',\n 'priority',\n 'fill',\n 'loading',\n 'sizes',\n 'loaderParams',\n 'disableOptimizedSrcset',\n ]);\n }\n if (changes['ngSrc'] && !changes['ngSrc'].isFirstChange()) {\n const oldSrc = this._renderedSrc;\n this.updateSrcAndSrcset(true);\n const newSrc = this._renderedSrc;\n if (this.lcpObserver !== null && oldSrc && newSrc && oldSrc !== newSrc) {\n const ngZone = this.injector.get(NgZone);\n ngZone.runOutsideAngular(() => {\n this.lcpObserver?.updateImage(oldSrc, newSrc);\n });\n }\n }\n if (ngDevMode && changes['placeholder']?.currentValue && !this.isServer) {\n assertPlaceholderDimensions(this, this.imgElement);\n }\n }\n callImageLoader(configWithoutCustomParams) {\n let augmentedConfig = configWithoutCustomParams;\n if (this.loaderParams) {\n augmentedConfig.loaderParams = this.loaderParams;\n }\n return this.imageLoader(augmentedConfig);\n }\n getLoadingBehavior() {\n if (!this.priority && this.loading !== undefined) {\n return this.loading;\n }\n return this.priority ? 'eager' : 'lazy';\n }\n getFetchPriority() {\n return this.priority ? 'high' : 'auto';\n }\n getRewrittenSrc() {\n // ImageLoaderConfig supports setting a width property. However, we're not setting width here\n // because if the developer uses rendered width instead of intrinsic width in the HTML width\n // attribute, the image requested may be too small for 2x+ screens.\n if (!this._renderedSrc) {\n const imgConfig = { src: this.ngSrc };\n // Cache calculated image src to reuse it later in the code.\n this._renderedSrc = this.callImageLoader(imgConfig);\n }\n return this._renderedSrc;\n }\n getRewrittenSrcset() {\n const widthSrcSet = VALID_WIDTH_DESCRIPTOR_SRCSET.test(this.ngSrcset);\n const finalSrcs = this.ngSrcset\n .split(',')\n .filter((src) => src !== '')\n .map((srcStr) => {\n srcStr = srcStr.trim();\n const width = widthSrcSet ? parseFloat(srcStr) : parseFloat(srcStr) * this.width;\n return `${this.callImageLoader({ src: this.ngSrc, width })} ${srcStr}`;\n });\n return finalSrcs.join(', ');\n }\n getAutomaticSrcset() {\n if (this.sizes) {\n return this.getResponsiveSrcset();\n }\n else {\n return this.getFixedSrcset();\n }\n }\n getResponsiveSrcset() {\n const { breakpoints } = this.config;\n let filteredBreakpoints = breakpoints;\n if (this.sizes?.trim() === '100vw') {\n // Since this is a full-screen-width image, our srcset only needs to include\n // breakpoints with full viewport widths.\n filteredBreakpoints = breakpoints.filter((bp) => bp >= VIEWPORT_BREAKPOINT_CUTOFF);\n }\n const finalSrcs = filteredBreakpoints.map((bp) => `${this.callImageLoader({ src: this.ngSrc, width: bp })} ${bp}w`);\n return finalSrcs.join(', ');\n }\n updateSrcAndSrcset(forceSrcRecalc = false) {\n if (forceSrcRecalc) {\n // Reset cached value, so that the followup `getRewrittenSrc()` call\n // will recalculate it and update the cache.\n this._renderedSrc = null;\n }\n const rewrittenSrc = this.getRewrittenSrc();\n this.setHostAttribute('src', rewrittenSrc);\n let rewrittenSrcset = undefined;\n if (this.ngSrcset) {\n rewrittenSrcset = this.getRewrittenSrcset();\n }\n else if (this.shouldGenerateAutomaticSrcset()) {\n rewrittenSrcset = this.getAutomaticSrcset();\n }\n if (rewrittenSrcset) {\n this.setHostAttribute('srcset', rewrittenSrcset);\n }\n return rewrittenSrcset;\n }\n getFixedSrcset() {\n const finalSrcs = DENSITY_SRCSET_MULTIPLIERS.map((multiplier) => `${this.callImageLoader({\n src: this.ngSrc,\n width: this.width * multiplier,\n })} ${multiplier}x`);\n return finalSrcs.join(', ');\n }\n shouldGenerateAutomaticSrcset() {\n let oversizedImage = false;\n if (!this.sizes) {\n oversizedImage =\n this.width > FIXED_SRCSET_WIDTH_LIMIT || this.height > FIXED_SRCSET_HEIGHT_LIMIT;\n }\n return (!this.disableOptimizedSrcset &&\n !this.srcset &&\n this.imageLoader !== noopImageLoader &&\n !oversizedImage);\n }\n /**\n * Returns an image url formatted for use with the CSS background-image property. Expects one of:\n * * A base64 encoded image, which is wrapped and passed through.\n * * A boolean. If true, calls the image loader to generate a small placeholder url.\n */\n generatePlaceholder(placeholderInput) {\n const { placeholderResolution } = this.config;\n if (placeholderInput === true) {\n return `url(${this.callImageLoader({\n src: this.ngSrc,\n width: placeholderResolution,\n isPlaceholder: true,\n })})`;\n }\n else if (typeof placeholderInput === 'string') {\n return `url(${placeholderInput})`;\n }\n return null;\n }\n /**\n * Determines if blur should be applied, based on an optional boolean\n * property `blur` within the optional configuration object `placeholderConfig`.\n */\n shouldBlurPlaceholder(placeholderConfig) {\n if (!placeholderConfig || !placeholderConfig.hasOwnProperty('blur')) {\n return true;\n }\n return Boolean(placeholderConfig.blur);\n }\n removePlaceholderOnLoad(img) {\n const callback = () => {\n const changeDetectorRef = this.injector.get(ChangeDetectorRef);\n removeLoadListenerFn();\n removeErrorListenerFn();\n this.placeholder = false;\n changeDetectorRef.markForCheck();\n };\n const removeLoadListenerFn = this.renderer.listen(img, 'load', callback);\n const removeErrorListenerFn = this.renderer.listen(img, 'error', callback);\n callOnLoadIfImageIsLoaded(img, callback);\n }\n /** @nodoc */\n ngOnDestroy() {\n if (ngDevMode) {\n if (!this.priority && this._renderedSrc !== null && this.lcpObserver !== null) {\n this.lcpObserver.unregisterImage(this._renderedSrc);\n }\n }\n }\n setHostAttribute(name, value) {\n this.renderer.setAttribute(this.imgElement, name, value);\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgOptimizedImage, deps: [], target: i0.ɵɵFactoryTarget.Directive });\n static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: \"16.1.0\", version: \"19.0.6\", type: NgOptimizedImage, isStandalone: true, selector: \"img[ngSrc]\", inputs: { ngSrc: [\"ngSrc\", \"ngSrc\", unwrapSafeUrl], ngSrcset: \"ngSrcset\", sizes: \"sizes\", width: [\"width\", \"width\", numberAttribute], height: [\"height\", \"height\", numberAttribute], loading: \"loading\", priority: [\"priority\", \"priority\", booleanAttribute], loaderParams: \"loaderParams\", disableOptimizedSrcset: [\"disableOptimizedSrcset\", \"disableOptimizedSrcset\", booleanAttribute], fill: [\"fill\", \"fill\", booleanAttribute], placeholder: [\"placeholder\", \"placeholder\", booleanOrUrlAttribute], placeholderConfig: \"placeholderConfig\", src: \"src\", srcset: \"srcset\" }, host: { properties: { \"style.position\": \"fill ? \\\"absolute\\\" : null\", \"style.width\": \"fill ? \\\"100%\\\" : null\", \"style.height\": \"fill ? \\\"100%\\\" : null\", \"style.inset\": \"fill ? \\\"0\\\" : null\", \"style.background-size\": \"placeholder ? \\\"cover\\\" : null\", \"style.background-position\": \"placeholder ? \\\"50% 50%\\\" : null\", \"style.background-repeat\": \"placeholder ? \\\"no-repeat\\\" : null\", \"style.background-image\": \"placeholder ? generatePlaceholder(placeholder) : null\", \"style.filter\": \"placeholder && shouldBlurPlaceholder(placeholderConfig) ? \\\"blur(15px)\\\" : null\" } }, usesOnChanges: true, ngImport: i0 });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: NgOptimizedImage, decorators: [{\n type: Directive,\n args: [{\n selector: 'img[ngSrc]',\n host: {\n '[style.position]': 'fill ? \"absolute\" : null',\n '[style.width]': 'fill ? \"100%\" : null',\n '[style.height]': 'fill ? \"100%\" : null',\n '[style.inset]': 'fill ? \"0\" : null',\n '[style.background-size]': 'placeholder ? \"cover\" : null',\n '[style.background-position]': 'placeholder ? \"50% 50%\" : null',\n '[style.background-repeat]': 'placeholder ? \"no-repeat\" : null',\n '[style.background-image]': 'placeholder ? generatePlaceholder(placeholder) : null',\n '[style.filter]': `placeholder && shouldBlurPlaceholder(placeholderConfig) ? \"blur(${PLACEHOLDER_BLUR_AMOUNT}px)\" : null`,\n },\n }]\n }], propDecorators: { ngSrc: [{\n type: Input,\n args: [{ required: true, transform: unwrapSafeUrl }]\n }], ngSrcset: [{\n type: Input\n }], sizes: [{\n type: Input\n }], width: [{\n type: Input,\n args: [{ transform: numberAttribute }]\n }], height: [{\n type: Input,\n args: [{ transform: numberAttribute }]\n }], loading: [{\n type: Input\n }], priority: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], loaderParams: [{\n type: Input\n }], disableOptimizedSrcset: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], fill: [{\n type: Input,\n args: [{ transform: booleanAttribute }]\n }], placeholder: [{\n type: Input,\n args: [{ transform: booleanOrUrlAttribute }]\n }], placeholderConfig: [{\n type: Input\n }], src: [{\n type: Input\n }], srcset: [{\n type: Input\n }] } });\n/***** Helpers *****/\n/**\n * Sorts provided config breakpoints and uses defaults.\n */\nfunction processConfig(config) {\n let sortedBreakpoints = {};\n if (config.breakpoints) {\n sortedBreakpoints.breakpoints = config.breakpoints.sort((a, b) => a - b);\n }\n return Object.assign({}, ɵIMAGE_CONFIG_DEFAULTS, config, sortedBreakpoints);\n}\n/***** Assert functions *****/\n/**\n * Verifies that there is no `src` set on a host element.\n */\nfunction assertNoConflictingSrc(dir) {\n if (dir.src) {\n throw new ɵRuntimeError(2950 /* RuntimeErrorCode.UNEXPECTED_SRC_ATTR */, `${imgDirectiveDetails(dir.ngSrc)} both \\`src\\` and \\`ngSrc\\` have been set. ` +\n `Supplying both of these attributes breaks lazy loading. ` +\n `The NgOptimizedImage directive sets \\`src\\` itself based on the value of \\`ngSrc\\`. ` +\n `To fix this, please remove the \\`src\\` attribute.`);\n }\n}\n/**\n * Verifies that there is no `srcset` set on a host element.\n */\nfunction assertNoConflictingSrcset(dir) {\n if (dir.srcset) {\n throw new ɵRuntimeError(2951 /* RuntimeErrorCode.UNEXPECTED_SRCSET_ATTR */, `${imgDirectiveDetails(dir.ngSrc)} both \\`srcset\\` and \\`ngSrcset\\` have been set. ` +\n `Supplying both of these attributes breaks lazy loading. ` +\n `The NgOptimizedImage directive sets \\`srcset\\` itself based on the value of ` +\n `\\`ngSrcset\\`. To fix this, please remove the \\`srcset\\` attribute.`);\n }\n}\n/**\n * Verifies that the `ngSrc` is not a Base64-encoded image.\n */\nfunction assertNotBase64Image(dir) {\n let ngSrc = dir.ngSrc.trim();\n if (ngSrc.startsWith('data:')) {\n if (ngSrc.length > BASE64_IMG_MAX_LENGTH_IN_ERROR) {\n ngSrc = ngSrc.substring(0, BASE64_IMG_MAX_LENGTH_IN_ERROR) + '...';\n }\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc, false)} \\`ngSrc\\` is a Base64-encoded string ` +\n `(${ngSrc}). NgOptimizedImage does not support Base64-encoded strings. ` +\n `To fix this, disable the NgOptimizedImage directive for this element ` +\n `by removing \\`ngSrc\\` and using a standard \\`src\\` attribute instead.`);\n }\n}\n/**\n * Verifies that the 'sizes' only includes responsive values.\n */\nfunction assertNoComplexSizes(dir) {\n let sizes = dir.sizes;\n if (sizes?.match(/((\\)|,)\\s|^)\\d+px/)) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc, false)} \\`sizes\\` was set to a string including ` +\n `pixel values. For automatic \\`srcset\\` generation, \\`sizes\\` must only include responsive ` +\n `values, such as \\`sizes=\"50vw\"\\` or \\`sizes=\"(min-width: 768px) 50vw, 100vw\"\\`. ` +\n `To fix this, modify the \\`sizes\\` attribute, or provide your own \\`ngSrcset\\` value directly.`);\n }\n}\nfunction assertValidPlaceholder(dir, imageLoader) {\n assertNoPlaceholderConfigWithoutPlaceholder(dir);\n assertNoRelativePlaceholderWithoutLoader(dir, imageLoader);\n assertNoOversizedDataUrl(dir);\n}\n/**\n * Verifies that placeholderConfig isn't being used without placeholder\n */\nfunction assertNoPlaceholderConfigWithoutPlaceholder(dir) {\n if (dir.placeholderConfig && !dir.placeholder) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc, false)} \\`placeholderConfig\\` options were provided for an ` +\n `image that does not use the \\`placeholder\\` attribute, and will have no effect.`);\n }\n}\n/**\n * Warns if a relative URL placeholder is specified, but no loader is present to provide the small\n * image.\n */\nfunction assertNoRelativePlaceholderWithoutLoader(dir, imageLoader) {\n if (dir.placeholder === true && imageLoader === noopImageLoader) {\n throw new ɵRuntimeError(2963 /* RuntimeErrorCode.MISSING_NECESSARY_LOADER */, `${imgDirectiveDetails(dir.ngSrc)} the \\`placeholder\\` attribute is set to true but ` +\n `no image loader is configured (i.e. the default one is being used), ` +\n `which would result in the same image being used for the primary image and its placeholder. ` +\n `To fix this, provide a loader or remove the \\`placeholder\\` attribute from the image.`);\n }\n}\n/**\n * Warns or throws an error if an oversized dataURL placeholder is provided.\n */\nfunction assertNoOversizedDataUrl(dir) {\n if (dir.placeholder &&\n typeof dir.placeholder === 'string' &&\n dir.placeholder.startsWith('data:')) {\n if (dir.placeholder.length > DATA_URL_ERROR_LIMIT) {\n throw new ɵRuntimeError(2965 /* RuntimeErrorCode.OVERSIZED_PLACEHOLDER */, `${imgDirectiveDetails(dir.ngSrc)} the \\`placeholder\\` attribute is set to a data URL which is longer ` +\n `than ${DATA_URL_ERROR_LIMIT} characters. This is strongly discouraged, as large inline placeholders ` +\n `directly increase the bundle size of Angular and hurt page load performance. To fix this, generate ` +\n `a smaller data URL placeholder.`);\n }\n if (dir.placeholder.length > DATA_URL_WARN_LIMIT) {\n console.warn(ɵformatRuntimeError(2965 /* RuntimeErrorCode.OVERSIZED_PLACEHOLDER */, `${imgDirectiveDetails(dir.ngSrc)} the \\`placeholder\\` attribute is set to a data URL which is longer ` +\n `than ${DATA_URL_WARN_LIMIT} characters. This is discouraged, as large inline placeholders ` +\n `directly increase the bundle size of Angular and hurt page load performance. For better loading performance, ` +\n `generate a smaller data URL placeholder.`));\n }\n }\n}\n/**\n * Verifies that the `ngSrc` is not a Blob URL.\n */\nfunction assertNotBlobUrl(dir) {\n const ngSrc = dir.ngSrc.trim();\n if (ngSrc.startsWith('blob:')) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} \\`ngSrc\\` was set to a blob URL (${ngSrc}). ` +\n `Blob URLs are not supported by the NgOptimizedImage directive. ` +\n `To fix this, disable the NgOptimizedImage directive for this element ` +\n `by removing \\`ngSrc\\` and using a regular \\`src\\` attribute instead.`);\n }\n}\n/**\n * Verifies that the input is set to a non-empty string.\n */\nfunction assertNonEmptyInput(dir, name, value) {\n const isString = typeof value === 'string';\n const isEmptyString = isString && value.trim() === '';\n if (!isString || isEmptyString) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} \\`${name}\\` has an invalid value ` +\n `(\\`${value}\\`). To fix this, change the value to a non-empty string.`);\n }\n}\n/**\n * Verifies that the `ngSrcset` is in a valid format, e.g. \"100w, 200w\" or \"1x, 2x\".\n */\nfunction assertValidNgSrcset(dir, value) {\n if (value == null)\n return;\n assertNonEmptyInput(dir, 'ngSrcset', value);\n const stringVal = value;\n const isValidWidthDescriptor = VALID_WIDTH_DESCRIPTOR_SRCSET.test(stringVal);\n const isValidDensityDescriptor = VALID_DENSITY_DESCRIPTOR_SRCSET.test(stringVal);\n if (isValidDensityDescriptor) {\n assertUnderDensityCap(dir, stringVal);\n }\n const isValidSrcset = isValidWidthDescriptor || isValidDensityDescriptor;\n if (!isValidSrcset) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} \\`ngSrcset\\` has an invalid value (\\`${value}\\`). ` +\n `To fix this, supply \\`ngSrcset\\` using a comma-separated list of one or more width ` +\n `descriptors (e.g. \"100w, 200w\") or density descriptors (e.g. \"1x, 2x\").`);\n }\n}\nfunction assertUnderDensityCap(dir, value) {\n const underDensityCap = value\n .split(',')\n .every((num) => num === '' || parseFloat(num) <= ABSOLUTE_SRCSET_DENSITY_CAP);\n if (!underDensityCap) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} the \\`ngSrcset\\` contains an unsupported image density:` +\n `\\`${value}\\`. NgOptimizedImage generally recommends a max image density of ` +\n `${RECOMMENDED_SRCSET_DENSITY_CAP}x but supports image densities up to ` +\n `${ABSOLUTE_SRCSET_DENSITY_CAP}x. The human eye cannot distinguish between image densities ` +\n `greater than ${RECOMMENDED_SRCSET_DENSITY_CAP}x - which makes them unnecessary for ` +\n `most use cases. Images that will be pinch-zoomed are typically the primary use case for ` +\n `${ABSOLUTE_SRCSET_DENSITY_CAP}x images. Please remove the high density descriptor and try again.`);\n }\n}\n/**\n * Creates a `RuntimeError` instance to represent a situation when an input is set after\n * the directive has initialized.\n */\nfunction postInitInputChangeError(dir, inputName) {\n let reason;\n if (inputName === 'width' || inputName === 'height') {\n reason =\n `Changing \\`${inputName}\\` may result in different attribute value ` +\n `applied to the underlying image element and cause layout shifts on a page.`;\n }\n else {\n reason =\n `Changing the \\`${inputName}\\` would have no effect on the underlying ` +\n `image element, because the resource loading has already occurred.`;\n }\n return new ɵRuntimeError(2953 /* RuntimeErrorCode.UNEXPECTED_INPUT_CHANGE */, `${imgDirectiveDetails(dir.ngSrc)} \\`${inputName}\\` was updated after initialization. ` +\n `The NgOptimizedImage directive will not react to this input change. ${reason} ` +\n `To fix this, either switch \\`${inputName}\\` to a static value ` +\n `or wrap the image element in an @if that is gated on the necessary value.`);\n}\n/**\n * Verify that none of the listed inputs has changed.\n */\nfunction assertNoPostInitInputChange(dir, changes, inputs) {\n inputs.forEach((input) => {\n const isUpdated = changes.hasOwnProperty(input);\n if (isUpdated && !changes[input].isFirstChange()) {\n if (input === 'ngSrc') {\n // When the `ngSrc` input changes, we detect that only in the\n // `ngOnChanges` hook, thus the `ngSrc` is already set. We use\n // `ngSrc` in the error message, so we use a previous value, but\n // not the updated one in it.\n dir = { ngSrc: changes[input].previousValue };\n }\n throw postInitInputChangeError(dir, input);\n }\n });\n}\n/**\n * Verifies that a specified input is a number greater than 0.\n */\nfunction assertGreaterThanZero(dir, inputValue, inputName) {\n const validNumber = typeof inputValue === 'number' && inputValue > 0;\n const validString = typeof inputValue === 'string' && /^\\d+$/.test(inputValue.trim()) && parseInt(inputValue) > 0;\n if (!validNumber && !validString) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} \\`${inputName}\\` has an invalid value. ` +\n `To fix this, provide \\`${inputName}\\` as a number greater than 0.`);\n }\n}\n/**\n * Verifies that the rendered image is not visually distorted. Effectively this is checking:\n * - Whether the \"width\" and \"height\" attributes reflect the actual dimensions of the image.\n * - Whether image styling is \"correct\" (see below for a longer explanation).\n */\nfunction assertNoImageDistortion(dir, img, renderer) {\n const callback = () => {\n removeLoadListenerFn();\n removeErrorListenerFn();\n const computedStyle = window.getComputedStyle(img);\n let renderedWidth = parseFloat(computedStyle.getPropertyValue('width'));\n let renderedHeight = parseFloat(computedStyle.getPropertyValue('height'));\n const boxSizing = computedStyle.getPropertyValue('box-sizing');\n if (boxSizing === 'border-box') {\n const paddingTop = computedStyle.getPropertyValue('padding-top');\n const paddingRight = computedStyle.getPropertyValue('padding-right');\n const paddingBottom = computedStyle.getPropertyValue('padding-bottom');\n const paddingLeft = computedStyle.getPropertyValue('padding-left');\n renderedWidth -= parseFloat(paddingRight) + parseFloat(paddingLeft);\n renderedHeight -= parseFloat(paddingTop) + parseFloat(paddingBottom);\n }\n const renderedAspectRatio = renderedWidth / renderedHeight;\n const nonZeroRenderedDimensions = renderedWidth !== 0 && renderedHeight !== 0;\n const intrinsicWidth = img.naturalWidth;\n const intrinsicHeight = img.naturalHeight;\n const intrinsicAspectRatio = intrinsicWidth / intrinsicHeight;\n const suppliedWidth = dir.width;\n const suppliedHeight = dir.height;\n const suppliedAspectRatio = suppliedWidth / suppliedHeight;\n // Tolerance is used to account for the impact of subpixel rendering.\n // Due to subpixel rendering, the rendered, intrinsic, and supplied\n // aspect ratios of a correctly configured image may not exactly match.\n // For example, a `width=4030 height=3020` image might have a rendered\n // size of \"1062w, 796.48h\". (An aspect ratio of 1.334... vs. 1.333...)\n const inaccurateDimensions = Math.abs(suppliedAspectRatio - intrinsicAspectRatio) > ASPECT_RATIO_TOLERANCE;\n const stylingDistortion = nonZeroRenderedDimensions &&\n Math.abs(intrinsicAspectRatio - renderedAspectRatio) > ASPECT_RATIO_TOLERANCE;\n if (inaccurateDimensions) {\n console.warn(ɵformatRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} the aspect ratio of the image does not match ` +\n `the aspect ratio indicated by the width and height attributes. ` +\n `\\nIntrinsic image size: ${intrinsicWidth}w x ${intrinsicHeight}h ` +\n `(aspect-ratio: ${round(intrinsicAspectRatio)}). \\nSupplied width and height attributes: ` +\n `${suppliedWidth}w x ${suppliedHeight}h (aspect-ratio: ${round(suppliedAspectRatio)}). ` +\n `\\nTo fix this, update the width and height attributes.`));\n }\n else if (stylingDistortion) {\n console.warn(ɵformatRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} the aspect ratio of the rendered image ` +\n `does not match the image's intrinsic aspect ratio. ` +\n `\\nIntrinsic image size: ${intrinsicWidth}w x ${intrinsicHeight}h ` +\n `(aspect-ratio: ${round(intrinsicAspectRatio)}). \\nRendered image size: ` +\n `${renderedWidth}w x ${renderedHeight}h (aspect-ratio: ` +\n `${round(renderedAspectRatio)}). \\nThis issue can occur if \"width\" and \"height\" ` +\n `attributes are added to an image without updating the corresponding ` +\n `image styling. To fix this, adjust image styling. In most cases, ` +\n `adding \"height: auto\" or \"width: auto\" to the image styling will fix ` +\n `this issue.`));\n }\n else if (!dir.ngSrcset && nonZeroRenderedDimensions) {\n // If `ngSrcset` hasn't been set, sanity check the intrinsic size.\n const recommendedWidth = RECOMMENDED_SRCSET_DENSITY_CAP * renderedWidth;\n const recommendedHeight = RECOMMENDED_SRCSET_DENSITY_CAP * renderedHeight;\n const oversizedWidth = intrinsicWidth - recommendedWidth >= OVERSIZED_IMAGE_TOLERANCE;\n const oversizedHeight = intrinsicHeight - recommendedHeight >= OVERSIZED_IMAGE_TOLERANCE;\n if (oversizedWidth || oversizedHeight) {\n console.warn(ɵformatRuntimeError(2960 /* RuntimeErrorCode.OVERSIZED_IMAGE */, `${imgDirectiveDetails(dir.ngSrc)} the intrinsic image is significantly ` +\n `larger than necessary. ` +\n `\\nRendered image size: ${renderedWidth}w x ${renderedHeight}h. ` +\n `\\nIntrinsic image size: ${intrinsicWidth}w x ${intrinsicHeight}h. ` +\n `\\nRecommended intrinsic image size: ${recommendedWidth}w x ${recommendedHeight}h. ` +\n `\\nNote: Recommended intrinsic image size is calculated assuming a maximum DPR of ` +\n `${RECOMMENDED_SRCSET_DENSITY_CAP}. To improve loading time, resize the image ` +\n `or consider using the \"ngSrcset\" and \"sizes\" attributes.`));\n }\n }\n };\n const removeLoadListenerFn = renderer.listen(img, 'load', callback);\n // We only listen to the `error` event to remove the `load` event listener because it will not be\n // fired if the image fails to load. This is done to prevent memory leaks in development mode\n // because image elements aren't garbage-collected properly. It happens because zone.js stores the\n // event listener directly on the element and closures capture `dir`.\n const removeErrorListenerFn = renderer.listen(img, 'error', () => {\n removeLoadListenerFn();\n removeErrorListenerFn();\n });\n callOnLoadIfImageIsLoaded(img, callback);\n}\n/**\n * Verifies that a specified input is set.\n */\nfunction assertNonEmptyWidthAndHeight(dir) {\n let missingAttributes = [];\n if (dir.width === undefined)\n missingAttributes.push('width');\n if (dir.height === undefined)\n missingAttributes.push('height');\n if (missingAttributes.length > 0) {\n throw new ɵRuntimeError(2954 /* RuntimeErrorCode.REQUIRED_INPUT_MISSING */, `${imgDirectiveDetails(dir.ngSrc)} these required attributes ` +\n `are missing: ${missingAttributes.map((attr) => `\"${attr}\"`).join(', ')}. ` +\n `Including \"width\" and \"height\" attributes will prevent image-related layout shifts. ` +\n `To fix this, include \"width\" and \"height\" attributes on the image tag or turn on ` +\n `\"fill\" mode with the \\`fill\\` attribute.`);\n }\n}\n/**\n * Verifies that width and height are not set. Used in fill mode, where those attributes don't make\n * sense.\n */\nfunction assertEmptyWidthAndHeight(dir) {\n if (dir.width || dir.height) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} the attributes \\`height\\` and/or \\`width\\` are present ` +\n `along with the \\`fill\\` attribute. Because \\`fill\\` mode causes an image to fill its containing ` +\n `element, the size attributes have no effect and should be removed.`);\n }\n}\n/**\n * Verifies that the rendered image has a nonzero height. If the image is in fill mode, provides\n * guidance that this can be caused by the containing element's CSS position property.\n */\nfunction assertNonZeroRenderedHeight(dir, img, renderer) {\n const callback = () => {\n removeLoadListenerFn();\n removeErrorListenerFn();\n const renderedHeight = img.clientHeight;\n if (dir.fill && renderedHeight === 0) {\n console.warn(ɵformatRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} the height of the fill-mode image is zero. ` +\n `This is likely because the containing element does not have the CSS 'position' ` +\n `property set to one of the following: \"relative\", \"fixed\", or \"absolute\". ` +\n `To fix this problem, make sure the container element has the CSS 'position' ` +\n `property defined and the height of the element is not zero.`));\n }\n };\n const removeLoadListenerFn = renderer.listen(img, 'load', callback);\n // See comments in the `assertNoImageDistortion`.\n const removeErrorListenerFn = renderer.listen(img, 'error', () => {\n removeLoadListenerFn();\n removeErrorListenerFn();\n });\n callOnLoadIfImageIsLoaded(img, callback);\n}\n/**\n * Verifies that the `loading` attribute is set to a valid input &\n * is not used on priority images.\n */\nfunction assertValidLoadingInput(dir) {\n if (dir.loading && dir.priority) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} the \\`loading\\` attribute ` +\n `was used on an image that was marked \"priority\". ` +\n `Setting \\`loading\\` on priority images is not allowed ` +\n `because these images will always be eagerly loaded. ` +\n `To fix this, remove the “loading” attribute from the priority image.`);\n }\n const validInputs = ['auto', 'eager', 'lazy'];\n if (typeof dir.loading === 'string' && !validInputs.includes(dir.loading)) {\n throw new ɵRuntimeError(2952 /* RuntimeErrorCode.INVALID_INPUT */, `${imgDirectiveDetails(dir.ngSrc)} the \\`loading\\` attribute ` +\n `has an invalid value (\\`${dir.loading}\\`). ` +\n `To fix this, provide a valid value (\"lazy\", \"eager\", or \"auto\").`);\n }\n}\n/**\n * Warns if NOT using a loader (falling back to the generic loader) and\n * the image appears to be hosted on one of the image CDNs for which\n * we do have a built-in image loader. Suggests switching to the\n * built-in loader.\n *\n * @param ngSrc Value of the ngSrc attribute\n * @param imageLoader ImageLoader provided\n */\nfunction assertNotMissingBuiltInLoader(ngSrc, imageLoader) {\n if (imageLoader === noopImageLoader) {\n let builtInLoaderName = '';\n for (const loader of BUILT_IN_LOADERS) {\n if (loader.testUrl(ngSrc)) {\n builtInLoaderName = loader.name;\n break;\n }\n }\n if (builtInLoaderName) {\n console.warn(ɵformatRuntimeError(2962 /* RuntimeErrorCode.MISSING_BUILTIN_LOADER */, `NgOptimizedImage: It looks like your images may be hosted on the ` +\n `${builtInLoaderName} CDN, but your app is not using Angular's ` +\n `built-in loader for that CDN. We recommend switching to use ` +\n `the built-in by calling \\`provide${builtInLoaderName}Loader()\\` ` +\n `in your \\`providers\\` and passing it your instance's base URL. ` +\n `If you don't want to use the built-in loader, define a custom ` +\n `loader function using IMAGE_LOADER to silence this warning.`));\n }\n }\n}\n/**\n * Warns if ngSrcset is present and no loader is configured (i.e. the default one is being used).\n */\nfunction assertNoNgSrcsetWithoutLoader(dir, imageLoader) {\n if (dir.ngSrcset && imageLoader === noopImageLoader) {\n console.warn(ɵformatRuntimeError(2963 /* RuntimeErrorCode.MISSING_NECESSARY_LOADER */, `${imgDirectiveDetails(dir.ngSrc)} the \\`ngSrcset\\` attribute is present but ` +\n `no image loader is configured (i.e. the default one is being used), ` +\n `which would result in the same image being used for all configured sizes. ` +\n `To fix this, provide a loader or remove the \\`ngSrcset\\` attribute from the image.`));\n }\n}\n/**\n * Warns if loaderParams is present and no loader is configured (i.e. the default one is being\n * used).\n */\nfunction assertNoLoaderParamsWithoutLoader(dir, imageLoader) {\n if (dir.loaderParams && imageLoader === noopImageLoader) {\n console.warn(ɵformatRuntimeError(2963 /* RuntimeErrorCode.MISSING_NECESSARY_LOADER */, `${imgDirectiveDetails(dir.ngSrc)} the \\`loaderParams\\` attribute is present but ` +\n `no image loader is configured (i.e. the default one is being used), ` +\n `which means that the loaderParams data will not be consumed and will not affect the URL. ` +\n `To fix this, provide a custom loader or remove the \\`loaderParams\\` attribute from the image.`));\n }\n}\n/**\n * Warns if the priority attribute is used too often on page load\n */\nasync function assetPriorityCountBelowThreshold(appRef) {\n if (IMGS_WITH_PRIORITY_ATTR_COUNT === 0) {\n IMGS_WITH_PRIORITY_ATTR_COUNT++;\n await appRef.whenStable();\n if (IMGS_WITH_PRIORITY_ATTR_COUNT > PRIORITY_COUNT_THRESHOLD) {\n console.warn(ɵformatRuntimeError(2966 /* RuntimeErrorCode.TOO_MANY_PRIORITY_ATTRIBUTES */, `NgOptimizedImage: The \"priority\" attribute is set to true more than ${PRIORITY_COUNT_THRESHOLD} times (${IMGS_WITH_PRIORITY_ATTR_COUNT} times). ` +\n `Marking too many images as \"high\" priority can hurt your application's LCP (https://web.dev/lcp). ` +\n `\"Priority\" should only be set on the image expected to be the page's LCP element.`));\n }\n }\n else {\n IMGS_WITH_PRIORITY_ATTR_COUNT++;\n }\n}\n/**\n * Warns if placeholder's dimension are over a threshold.\n *\n * This assert function is meant to only run on the browser.\n */\nfunction assertPlaceholderDimensions(dir, imgElement) {\n const computedStyle = window.getComputedStyle(imgElement);\n let renderedWidth = parseFloat(computedStyle.getPropertyValue('width'));\n let renderedHeight = parseFloat(computedStyle.getPropertyValue('height'));\n if (renderedWidth > PLACEHOLDER_DIMENSION_LIMIT || renderedHeight > PLACEHOLDER_DIMENSION_LIMIT) {\n console.warn(ɵformatRuntimeError(2967 /* RuntimeErrorCode.PLACEHOLDER_DIMENSION_LIMIT_EXCEEDED */, `${imgDirectiveDetails(dir.ngSrc)} it uses a placeholder image, but at least one ` +\n `of the dimensions attribute (height or width) exceeds the limit of ${PLACEHOLDER_DIMENSION_LIMIT}px. ` +\n `To fix this, use a smaller image as a placeholder.`));\n }\n}\nfunction callOnLoadIfImageIsLoaded(img, callback) {\n // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete\n // The spec defines that `complete` is truthy once its request state is fully available.\n // The image may already be available if it’s loaded from the browser cache.\n // In that case, the `load` event will not fire at all, meaning that all setup\n // callbacks listening for the `load` event will not be invoked.\n // In Safari, there is a known behavior where the `complete` property of an\n // `HTMLImageElement` may sometimes return `true` even when the image is not fully loaded.\n // Checking both `img.complete` and `img.naturalWidth` is the most reliable way to\n // determine if an image has been fully loaded, especially in browsers where the\n // `complete` property may return `true` prematurely.\n if (img.complete && img.naturalWidth) {\n callback();\n }\n}\nfunction round(input) {\n return Number.isInteger(input) ? input : input.toFixed(2);\n}\n// Transform function to handle SafeValue input for ngSrc. This doesn't do any sanitization,\n// as that is not needed for img.src and img.srcset. This transform is purely for compatibility.\nfunction unwrapSafeUrl(value) {\n if (typeof value === 'string') {\n return value;\n }\n return ɵunwrapSafeValue(value);\n}\n// Transform function to handle inputs which may be booleans, strings, or string representations\n// of boolean values. Used for the placeholder attribute.\nfunction booleanOrUrlAttribute(value) {\n if (typeof value === 'string' && value !== 'true' && value !== 'false' && value !== '') {\n return value;\n }\n return booleanAttribute(value);\n}\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the common package.\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\n// This file only reexports content of the `src` folder. Keep it that way.\n\n// This file is not used to build this module. It is only used during editing\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { APP_BASE_HREF, AsyncPipe, BrowserPlatformLocation, CommonModule, CurrencyPipe, DATE_PIPE_DEFAULT_OPTIONS, DATE_PIPE_DEFAULT_TIMEZONE, DOCUMENT, DatePipe, DecimalPipe, FormStyle, FormatWidth, HashLocationStrategy, I18nPluralPipe, I18nSelectPipe, IMAGE_LOADER, JsonPipe, KeyValuePipe, LOCATION_INITIALIZED, Location, LocationStrategy, LowerCasePipe, NgClass, NgComponentOutlet, NgForOf as NgFor, NgForOf, NgForOfContext, NgIf, NgIfContext, NgLocaleLocalization, NgLocalization, NgOptimizedImage, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NumberFormatStyle, NumberSymbol, PRECONNECT_CHECK_BLOCKLIST, PathLocationStrategy, PercentPipe, PlatformLocation, Plural, SlicePipe, TitleCasePipe, TranslationWidth, UpperCasePipe, VERSION, ViewportScroller, WeekDay, XhrFactory, formatCurrency, formatDate, formatNumber, formatPercent, getCurrencySymbol, getLocaleCurrencyCode, getLocaleCurrencyName, getLocaleCurrencySymbol, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleDayNames, getLocaleDayPeriods, getLocaleDirection, getLocaleEraNames, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocaleFirstDayOfWeek, getLocaleId, getLocaleMonthNames, getLocaleNumberFormat, getLocaleNumberSymbol, getLocalePluralCase, getLocaleTimeFormat, getLocaleWeekEndRange, getNumberOfCurrencyDigits, isPlatformBrowser, isPlatformServer, provideCloudflareLoader, provideCloudinaryLoader, provideImageKitLoader, provideImgixLoader, provideNetlifyLoader, registerLocaleData, DomAdapter as ɵDomAdapter, NullViewportScroller as ɵNullViewportScroller, PLATFORM_BROWSER_ID as ɵPLATFORM_BROWSER_ID, PLATFORM_SERVER_ID as ɵPLATFORM_SERVER_ID, PlatformNavigation as ɵPlatformNavigation, getDOM as ɵgetDOM, normalizeQueryParams as ɵnormalizeQueryParams, parseCookieValue as ɵparseCookieValue, setRootDomAdapter as ɵsetRootDomAdapter };\n","/**\n * @license Angular v19.0.6\n * (c) 2010-2024 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport * as i0 from '@angular/core';\nimport { Injectable, inject, NgZone, runInInjectionContext, InjectionToken, ɵPendingTasksInternal, PLATFORM_ID, ɵConsole, ɵformatRuntimeError, Inject, ɵRuntimeError, makeEnvironmentProviders, NgModule, TransferState, makeStateKey, ɵperformanceMarkFeature, APP_BOOTSTRAP_LISTENER, ApplicationRef, ɵtruncateMiddle } from '@angular/core';\nimport { of, Observable, from } from 'rxjs';\nimport { concatMap, filter, map, finalize, switchMap, tap } from 'rxjs/operators';\nimport * as i1 from '@angular/common';\nimport { isPlatformServer, DOCUMENT, ɵparseCookieValue } from '@angular/common';\n\n/**\n * Transforms an `HttpRequest` into a stream of `HttpEvent`s, one of which will likely be a\n * `HttpResponse`.\n *\n * `HttpHandler` is injectable. When injected, the handler instance dispatches requests to the\n * first interceptor in the chain, which dispatches to the second, etc, eventually reaching the\n * `HttpBackend`.\n *\n * In an `HttpInterceptor`, the `HttpHandler` parameter is the next interceptor in the chain.\n *\n * @publicApi\n */\nclass HttpHandler {\n}\n/**\n * A final `HttpHandler` which will dispatch the request via browser HTTP APIs to a backend.\n *\n * Interceptors sit between the `HttpClient` interface and the `HttpBackend`.\n *\n * When injected, `HttpBackend` dispatches requests directly to the backend, without going\n * through the interceptor chain.\n *\n * @publicApi\n */\nclass HttpBackend {\n}\n\n/**\n * Represents the header configuration options for an HTTP request.\n * Instances are immutable. Modifying methods return a cloned\n * instance with the change. The original object is never changed.\n *\n * @publicApi\n */\nclass HttpHeaders {\n /**\n * Internal map of lowercase header names to values.\n */\n // TODO(issue/24571): remove '!'.\n headers;\n /**\n * Internal map of lowercased header names to the normalized\n * form of the name (the form seen first).\n */\n normalizedNames = new Map();\n /**\n * Complete the lazy initialization of this object (needed before reading).\n */\n lazyInit;\n /**\n * Queued updates to be materialized the next initialization.\n */\n lazyUpdate = null;\n /** Constructs a new HTTP header object with the given values.*/\n constructor(headers) {\n if (!headers) {\n this.headers = new Map();\n }\n else if (typeof headers === 'string') {\n this.lazyInit = () => {\n this.headers = new Map();\n headers.split('\\n').forEach((line) => {\n const index = line.indexOf(':');\n if (index > 0) {\n const name = line.slice(0, index);\n const value = line.slice(index + 1).trim();\n this.addHeaderEntry(name, value);\n }\n });\n };\n }\n else if (typeof Headers !== 'undefined' && headers instanceof Headers) {\n this.headers = new Map();\n headers.forEach((value, name) => {\n this.addHeaderEntry(name, value);\n });\n }\n else {\n this.lazyInit = () => {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertValidHeaders(headers);\n }\n this.headers = new Map();\n Object.entries(headers).forEach(([name, values]) => {\n this.setHeaderEntries(name, values);\n });\n };\n }\n }\n /**\n * Checks for existence of a given header.\n *\n * @param name The header name to check for existence.\n *\n * @returns True if the header exists, false otherwise.\n */\n has(name) {\n this.init();\n return this.headers.has(name.toLowerCase());\n }\n /**\n * Retrieves the first value of a given header.\n *\n * @param name The header name.\n *\n * @returns The value string if the header exists, null otherwise\n */\n get(name) {\n this.init();\n const values = this.headers.get(name.toLowerCase());\n return values && values.length > 0 ? values[0] : null;\n }\n /**\n * Retrieves the names of the headers.\n *\n * @returns A list of header names.\n */\n keys() {\n this.init();\n return Array.from(this.normalizedNames.values());\n }\n /**\n * Retrieves a list of values for a given header.\n *\n * @param name The header name from which to retrieve values.\n *\n * @returns A string of values if the header exists, null otherwise.\n */\n getAll(name) {\n this.init();\n return this.headers.get(name.toLowerCase()) || null;\n }\n /**\n * Appends a new value to the existing set of values for a header\n * and returns them in a clone of the original instance.\n *\n * @param name The header name for which to append the values.\n * @param value The value to append.\n *\n * @returns A clone of the HTTP headers object with the value appended to the given header.\n */\n append(name, value) {\n return this.clone({ name, value, op: 'a' });\n }\n /**\n * Sets or modifies a value for a given header in a clone of the original instance.\n * If the header already exists, its value is replaced with the given value\n * in the returned object.\n *\n * @param name The header name.\n * @param value The value or values to set or override for the given header.\n *\n * @returns A clone of the HTTP headers object with the newly set header value.\n */\n set(name, value) {\n return this.clone({ name, value, op: 's' });\n }\n /**\n * Deletes values for a given header in a clone of the original instance.\n *\n * @param name The header name.\n * @param value The value or values to delete for the given header.\n *\n * @returns A clone of the HTTP headers object with the given value deleted.\n */\n delete(name, value) {\n return this.clone({ name, value, op: 'd' });\n }\n maybeSetNormalizedName(name, lcName) {\n if (!this.normalizedNames.has(lcName)) {\n this.normalizedNames.set(lcName, name);\n }\n }\n init() {\n if (!!this.lazyInit) {\n if (this.lazyInit instanceof HttpHeaders) {\n this.copyFrom(this.lazyInit);\n }\n else {\n this.lazyInit();\n }\n this.lazyInit = null;\n if (!!this.lazyUpdate) {\n this.lazyUpdate.forEach((update) => this.applyUpdate(update));\n this.lazyUpdate = null;\n }\n }\n }\n copyFrom(other) {\n other.init();\n Array.from(other.headers.keys()).forEach((key) => {\n this.headers.set(key, other.headers.get(key));\n this.normalizedNames.set(key, other.normalizedNames.get(key));\n });\n }\n clone(update) {\n const clone = new HttpHeaders();\n clone.lazyInit = !!this.lazyInit && this.lazyInit instanceof HttpHeaders ? this.lazyInit : this;\n clone.lazyUpdate = (this.lazyUpdate || []).concat([update]);\n return clone;\n }\n applyUpdate(update) {\n const key = update.name.toLowerCase();\n switch (update.op) {\n case 'a':\n case 's':\n let value = update.value;\n if (typeof value === 'string') {\n value = [value];\n }\n if (value.length === 0) {\n return;\n }\n this.maybeSetNormalizedName(update.name, key);\n const base = (update.op === 'a' ? this.headers.get(key) : undefined) || [];\n base.push(...value);\n this.headers.set(key, base);\n break;\n case 'd':\n const toDelete = update.value;\n if (!toDelete) {\n this.headers.delete(key);\n this.normalizedNames.delete(key);\n }\n else {\n let existing = this.headers.get(key);\n if (!existing) {\n return;\n }\n existing = existing.filter((value) => toDelete.indexOf(value) === -1);\n if (existing.length === 0) {\n this.headers.delete(key);\n this.normalizedNames.delete(key);\n }\n else {\n this.headers.set(key, existing);\n }\n }\n break;\n }\n }\n addHeaderEntry(name, value) {\n const key = name.toLowerCase();\n this.maybeSetNormalizedName(name, key);\n if (this.headers.has(key)) {\n this.headers.get(key).push(value);\n }\n else {\n this.headers.set(key, [value]);\n }\n }\n setHeaderEntries(name, values) {\n const headerValues = (Array.isArray(values) ? values : [values]).map((value) => value.toString());\n const key = name.toLowerCase();\n this.headers.set(key, headerValues);\n this.maybeSetNormalizedName(name, key);\n }\n /**\n * @internal\n */\n forEach(fn) {\n this.init();\n Array.from(this.normalizedNames.keys()).forEach((key) => fn(this.normalizedNames.get(key), this.headers.get(key)));\n }\n}\n/**\n * Verifies that the headers object has the right shape: the values\n * must be either strings, numbers or arrays. Throws an error if an invalid\n * header value is present.\n */\nfunction assertValidHeaders(headers) {\n for (const [key, value] of Object.entries(headers)) {\n if (!(typeof value === 'string' || typeof value === 'number') && !Array.isArray(value)) {\n throw new Error(`Unexpected value of the \\`${key}\\` header provided. ` +\n `Expecting either a string, a number or an array, but got: \\`${value}\\`.`);\n }\n }\n}\n\n/**\n * Provides encoding and decoding of URL parameter and query-string values.\n *\n * Serializes and parses URL parameter keys and values to encode and decode them.\n * If you pass URL query parameters without encoding,\n * the query parameters can be misinterpreted at the receiving end.\n *\n *\n * @publicApi\n */\nclass HttpUrlEncodingCodec {\n /**\n * Encodes a key name for a URL parameter or query-string.\n * @param key The key name.\n * @returns The encoded key name.\n */\n encodeKey(key) {\n return standardEncoding(key);\n }\n /**\n * Encodes the value of a URL parameter or query-string.\n * @param value The value.\n * @returns The encoded value.\n */\n encodeValue(value) {\n return standardEncoding(value);\n }\n /**\n * Decodes an encoded URL parameter or query-string key.\n * @param key The encoded key name.\n * @returns The decoded key name.\n */\n decodeKey(key) {\n return decodeURIComponent(key);\n }\n /**\n * Decodes an encoded URL parameter or query-string value.\n * @param value The encoded value.\n * @returns The decoded value.\n */\n decodeValue(value) {\n return decodeURIComponent(value);\n }\n}\nfunction paramParser(rawParams, codec) {\n const map = new Map();\n if (rawParams.length > 0) {\n // The `window.location.search` can be used while creating an instance of the `HttpParams` class\n // (e.g. `new HttpParams({ fromString: window.location.search })`). The `window.location.search`\n // may start with the `?` char, so we strip it if it's present.\n const params = rawParams.replace(/^\\?/, '').split('&');\n params.forEach((param) => {\n const eqIdx = param.indexOf('=');\n const [key, val] = eqIdx == -1\n ? [codec.decodeKey(param), '']\n : [codec.decodeKey(param.slice(0, eqIdx)), codec.decodeValue(param.slice(eqIdx + 1))];\n const list = map.get(key) || [];\n list.push(val);\n map.set(key, list);\n });\n }\n return map;\n}\n/**\n * Encode input string with standard encodeURIComponent and then un-encode specific characters.\n */\nconst STANDARD_ENCODING_REGEX = /%(\\d[a-f0-9])/gi;\nconst STANDARD_ENCODING_REPLACEMENTS = {\n '40': '@',\n '3A': ':',\n '24': '$',\n '2C': ',',\n '3B': ';',\n '3D': '=',\n '3F': '?',\n '2F': '/',\n};\nfunction standardEncoding(v) {\n return encodeURIComponent(v).replace(STANDARD_ENCODING_REGEX, (s, t) => STANDARD_ENCODING_REPLACEMENTS[t] ?? s);\n}\nfunction valueToString(value) {\n return `${value}`;\n}\n/**\n * An HTTP request/response body that represents serialized parameters,\n * per the MIME type `application/x-www-form-urlencoded`.\n *\n * This class is immutable; all mutation operations return a new instance.\n *\n * @publicApi\n */\nclass HttpParams {\n map;\n encoder;\n updates = null;\n cloneFrom = null;\n constructor(options = {}) {\n this.encoder = options.encoder || new HttpUrlEncodingCodec();\n if (!!options.fromString) {\n if (!!options.fromObject) {\n throw new Error(`Cannot specify both fromString and fromObject.`);\n }\n this.map = paramParser(options.fromString, this.encoder);\n }\n else if (!!options.fromObject) {\n this.map = new Map();\n Object.keys(options.fromObject).forEach((key) => {\n const value = options.fromObject[key];\n // convert the values to strings\n const values = Array.isArray(value) ? value.map(valueToString) : [valueToString(value)];\n this.map.set(key, values);\n });\n }\n else {\n this.map = null;\n }\n }\n /**\n * Reports whether the body includes one or more values for a given parameter.\n * @param param The parameter name.\n * @returns True if the parameter has one or more values,\n * false if it has no value or is not present.\n */\n has(param) {\n this.init();\n return this.map.has(param);\n }\n /**\n * Retrieves the first value for a parameter.\n * @param param The parameter name.\n * @returns The first value of the given parameter,\n * or `null` if the parameter is not present.\n */\n get(param) {\n this.init();\n const res = this.map.get(param);\n return !!res ? res[0] : null;\n }\n /**\n * Retrieves all values for a parameter.\n * @param param The parameter name.\n * @returns All values in a string array,\n * or `null` if the parameter not present.\n */\n getAll(param) {\n this.init();\n return this.map.get(param) || null;\n }\n /**\n * Retrieves all the parameters for this body.\n * @returns The parameter names in a string array.\n */\n keys() {\n this.init();\n return Array.from(this.map.keys());\n }\n /**\n * Appends a new value to existing values for a parameter.\n * @param param The parameter name.\n * @param value The new value to add.\n * @return A new body with the appended value.\n */\n append(param, value) {\n return this.clone({ param, value, op: 'a' });\n }\n /**\n * Constructs a new body with appended values for the given parameter name.\n * @param params parameters and values\n * @return A new body with the new value.\n */\n appendAll(params) {\n const updates = [];\n Object.keys(params).forEach((param) => {\n const value = params[param];\n if (Array.isArray(value)) {\n value.forEach((_value) => {\n updates.push({ param, value: _value, op: 'a' });\n });\n }\n else {\n updates.push({ param, value: value, op: 'a' });\n }\n });\n return this.clone(updates);\n }\n /**\n * Replaces the value for a parameter.\n * @param param The parameter name.\n * @param value The new value.\n * @return A new body with the new value.\n */\n set(param, value) {\n return this.clone({ param, value, op: 's' });\n }\n /**\n * Removes a given value or all values from a parameter.\n * @param param The parameter name.\n * @param value The value to remove, if provided.\n * @return A new body with the given value removed, or with all values\n * removed if no value is specified.\n */\n delete(param, value) {\n return this.clone({ param, value, op: 'd' });\n }\n /**\n * Serializes the body to an encoded string, where key-value pairs (separated by `=`) are\n * separated by `&`s.\n */\n toString() {\n this.init();\n return (this.keys()\n .map((key) => {\n const eKey = this.encoder.encodeKey(key);\n // `a: ['1']` produces `'a=1'`\n // `b: []` produces `''`\n // `c: ['1', '2']` produces `'c=1&c=2'`\n return this.map.get(key)\n .map((value) => eKey + '=' + this.encoder.encodeValue(value))\n .join('&');\n })\n // filter out empty values because `b: []` produces `''`\n // which results in `a=1&&c=1&c=2` instead of `a=1&c=1&c=2` if we don't\n .filter((param) => param !== '')\n .join('&'));\n }\n clone(update) {\n const clone = new HttpParams({ encoder: this.encoder });\n clone.cloneFrom = this.cloneFrom || this;\n clone.updates = (this.updates || []).concat(update);\n return clone;\n }\n init() {\n if (this.map === null) {\n this.map = new Map();\n }\n if (this.cloneFrom !== null) {\n this.cloneFrom.init();\n this.cloneFrom.keys().forEach((key) => this.map.set(key, this.cloneFrom.map.get(key)));\n this.updates.forEach((update) => {\n switch (update.op) {\n case 'a':\n case 's':\n const base = (update.op === 'a' ? this.map.get(update.param) : undefined) || [];\n base.push(valueToString(update.value));\n this.map.set(update.param, base);\n break;\n case 'd':\n if (update.value !== undefined) {\n let base = this.map.get(update.param) || [];\n const idx = base.indexOf(valueToString(update.value));\n if (idx !== -1) {\n base.splice(idx, 1);\n }\n if (base.length > 0) {\n this.map.set(update.param, base);\n }\n else {\n this.map.delete(update.param);\n }\n }\n else {\n this.map.delete(update.param);\n break;\n }\n }\n });\n this.cloneFrom = this.updates = null;\n }\n }\n}\n\n/**\n * A token used to manipulate and access values stored in `HttpContext`.\n *\n * @publicApi\n */\nclass HttpContextToken {\n defaultValue;\n constructor(defaultValue) {\n this.defaultValue = defaultValue;\n }\n}\n/**\n * Http context stores arbitrary user defined values and ensures type safety without\n * actually knowing the types. It is backed by a `Map` and guarantees that keys do not clash.\n *\n * This context is mutable and is shared between cloned requests unless explicitly specified.\n *\n * @usageNotes\n *\n * ### Usage Example\n *\n * ```ts\n * // inside cache.interceptors.ts\n * export const IS_CACHE_ENABLED = new HttpContextToken(() => false);\n *\n * export class CacheInterceptor implements HttpInterceptor {\n *\n * intercept(req: HttpRequest, delegate: HttpHandler): Observable> {\n * if (req.context.get(IS_CACHE_ENABLED) === true) {\n * return ...;\n * }\n * return delegate.handle(req);\n * }\n * }\n *\n * // inside a service\n *\n * this.httpClient.get('/api/weather', {\n * context: new HttpContext().set(IS_CACHE_ENABLED, true)\n * }).subscribe(...);\n * ```\n *\n * @publicApi\n */\nclass HttpContext {\n map = new Map();\n /**\n * Store a value in the context. If a value is already present it will be overwritten.\n *\n * @param token The reference to an instance of `HttpContextToken`.\n * @param value The value to store.\n *\n * @returns A reference to itself for easy chaining.\n */\n set(token, value) {\n this.map.set(token, value);\n return this;\n }\n /**\n * Retrieve the value associated with the given token.\n *\n * @param token The reference to an instance of `HttpContextToken`.\n *\n * @returns The stored value or default if one is defined.\n */\n get(token) {\n if (!this.map.has(token)) {\n this.map.set(token, token.defaultValue());\n }\n return this.map.get(token);\n }\n /**\n * Delete the value associated with the given token.\n *\n * @param token The reference to an instance of `HttpContextToken`.\n *\n * @returns A reference to itself for easy chaining.\n */\n delete(token) {\n this.map.delete(token);\n return this;\n }\n /**\n * Checks for existence of a given token.\n *\n * @param token The reference to an instance of `HttpContextToken`.\n *\n * @returns True if the token exists, false otherwise.\n */\n has(token) {\n return this.map.has(token);\n }\n /**\n * @returns a list of tokens currently stored in the context.\n */\n keys() {\n return this.map.keys();\n }\n}\n\n/**\n * Determine whether the given HTTP method may include a body.\n */\nfunction mightHaveBody(method) {\n switch (method) {\n case 'DELETE':\n case 'GET':\n case 'HEAD':\n case 'OPTIONS':\n case 'JSONP':\n return false;\n default:\n return true;\n }\n}\n/**\n * Safely assert whether the given value is an ArrayBuffer.\n *\n * In some execution environments ArrayBuffer is not defined.\n */\nfunction isArrayBuffer(value) {\n return typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;\n}\n/**\n * Safely assert whether the given value is a Blob.\n *\n * In some execution environments Blob is not defined.\n */\nfunction isBlob(value) {\n return typeof Blob !== 'undefined' && value instanceof Blob;\n}\n/**\n * Safely assert whether the given value is a FormData instance.\n *\n * In some execution environments FormData is not defined.\n */\nfunction isFormData(value) {\n return typeof FormData !== 'undefined' && value instanceof FormData;\n}\n/**\n * Safely assert whether the given value is a URLSearchParams instance.\n *\n * In some execution environments URLSearchParams is not defined.\n */\nfunction isUrlSearchParams(value) {\n return typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams;\n}\n/**\n * An outgoing HTTP request with an optional typed body.\n *\n * `HttpRequest` represents an outgoing request, including URL, method,\n * headers, body, and other request configuration options. Instances should be\n * assumed to be immutable. To modify a `HttpRequest`, the `clone`\n * method should be used.\n *\n * @publicApi\n */\nclass HttpRequest {\n url;\n /**\n * The request body, or `null` if one isn't set.\n *\n * Bodies are not enforced to be immutable, as they can include a reference to any\n * user-defined data type. However, interceptors should take care to preserve\n * idempotence by treating them as such.\n */\n body = null;\n /**\n * Outgoing headers for this request.\n */\n // TODO(issue/24571): remove '!'.\n headers;\n /**\n * Shared and mutable context that can be used by interceptors\n */\n context;\n /**\n * Whether this request should be made in a way that exposes progress events.\n *\n * Progress events are expensive (change detection runs on each event) and so\n * they should only be requested if the consumer intends to monitor them.\n *\n * Note: The `FetchBackend` doesn't support progress report on uploads.\n */\n reportProgress = false;\n /**\n * Whether this request should be sent with outgoing credentials (cookies).\n */\n withCredentials = false;\n /**\n * The expected response type of the server.\n *\n * This is used to parse the response appropriately before returning it to\n * the requestee.\n */\n responseType = 'json';\n /**\n * The outgoing HTTP request method.\n */\n method;\n /**\n * Outgoing URL parameters.\n *\n * To pass a string representation of HTTP parameters in the URL-query-string format,\n * the `HttpParamsOptions`' `fromString` may be used. For example:\n *\n * ```\n * new HttpParams({fromString: 'angular=awesome'})\n * ```\n */\n // TODO(issue/24571): remove '!'.\n params;\n /**\n * The outgoing URL with all URL parameters set.\n */\n urlWithParams;\n /**\n * The HttpTransferCache option for the request\n */\n transferCache;\n constructor(method, url, third, fourth) {\n this.url = url;\n this.method = method.toUpperCase();\n // Next, need to figure out which argument holds the HttpRequestInit\n // options, if any.\n let options;\n // Check whether a body argument is expected. The only valid way to omit\n // the body argument is to use a known no-body method like GET.\n if (mightHaveBody(this.method) || !!fourth) {\n // Body is the third argument, options are the fourth.\n this.body = third !== undefined ? third : null;\n options = fourth;\n }\n else {\n // No body required, options are the third argument. The body stays null.\n options = third;\n }\n // If options have been passed, interpret them.\n if (options) {\n // Normalize reportProgress and withCredentials.\n this.reportProgress = !!options.reportProgress;\n this.withCredentials = !!options.withCredentials;\n // Override default response type of 'json' if one is provided.\n if (!!options.responseType) {\n this.responseType = options.responseType;\n }\n // Override headers if they're provided.\n if (!!options.headers) {\n this.headers = options.headers;\n }\n if (!!options.context) {\n this.context = options.context;\n }\n if (!!options.params) {\n this.params = options.params;\n }\n // We do want to assign transferCache even if it's falsy (false is valid value)\n this.transferCache = options.transferCache;\n }\n // If no headers have been passed in, construct a new HttpHeaders instance.\n this.headers ??= new HttpHeaders();\n // If no context have been passed in, construct a new HttpContext instance.\n this.context ??= new HttpContext();\n // If no parameters have been passed in, construct a new HttpUrlEncodedParams instance.\n if (!this.params) {\n this.params = new HttpParams();\n this.urlWithParams = url;\n }\n else {\n // Encode the parameters to a string in preparation for inclusion in the URL.\n const params = this.params.toString();\n if (params.length === 0) {\n // No parameters, the visible URL is just the URL given at creation time.\n this.urlWithParams = url;\n }\n else {\n // Does the URL already have query parameters? Look for '?'.\n const qIdx = url.indexOf('?');\n // There are 3 cases to handle:\n // 1) No existing parameters -> append '?' followed by params.\n // 2) '?' exists and is followed by existing query string ->\n // append '&' followed by params.\n // 3) '?' exists at the end of the url -> append params directly.\n // This basically amounts to determining the character, if any, with\n // which to join the URL and parameters.\n const sep = qIdx === -1 ? '?' : qIdx < url.length - 1 ? '&' : '';\n this.urlWithParams = url + sep + params;\n }\n }\n }\n /**\n * Transform the free-form body into a serialized format suitable for\n * transmission to the server.\n */\n serializeBody() {\n // If no body is present, no need to serialize it.\n if (this.body === null) {\n return null;\n }\n // Check whether the body is already in a serialized form. If so,\n // it can just be returned directly.\n if (typeof this.body === 'string' ||\n isArrayBuffer(this.body) ||\n isBlob(this.body) ||\n isFormData(this.body) ||\n isUrlSearchParams(this.body)) {\n return this.body;\n }\n // Check whether the body is an instance of HttpUrlEncodedParams.\n if (this.body instanceof HttpParams) {\n return this.body.toString();\n }\n // Check whether the body is an object or array, and serialize with JSON if so.\n if (typeof this.body === 'object' ||\n typeof this.body === 'boolean' ||\n Array.isArray(this.body)) {\n return JSON.stringify(this.body);\n }\n // Fall back on toString() for everything else.\n return this.body.toString();\n }\n /**\n * Examine the body and attempt to infer an appropriate MIME type\n * for it.\n *\n * If no such type can be inferred, this method will return `null`.\n */\n detectContentTypeHeader() {\n // An empty body has no content type.\n if (this.body === null) {\n return null;\n }\n // FormData bodies rely on the browser's content type assignment.\n if (isFormData(this.body)) {\n return null;\n }\n // Blobs usually have their own content type. If it doesn't, then\n // no type can be inferred.\n if (isBlob(this.body)) {\n return this.body.type || null;\n }\n // Array buffers have unknown contents and thus no type can be inferred.\n if (isArrayBuffer(this.body)) {\n return null;\n }\n // Technically, strings could be a form of JSON data, but it's safe enough\n // to assume they're plain strings.\n if (typeof this.body === 'string') {\n return 'text/plain';\n }\n // `HttpUrlEncodedParams` has its own content-type.\n if (this.body instanceof HttpParams) {\n return 'application/x-www-form-urlencoded;charset=UTF-8';\n }\n // Arrays, objects, boolean and numbers will be encoded as JSON.\n if (typeof this.body === 'object' ||\n typeof this.body === 'number' ||\n typeof this.body === 'boolean') {\n return 'application/json';\n }\n // No type could be inferred.\n return null;\n }\n clone(update = {}) {\n // For method, url, and responseType, take the current value unless\n // it is overridden in the update hash.\n const method = update.method || this.method;\n const url = update.url || this.url;\n const responseType = update.responseType || this.responseType;\n // Carefully handle the transferCache to differentiate between\n // `false` and `undefined` in the update args.\n const transferCache = update.transferCache ?? this.transferCache;\n // The body is somewhat special - a `null` value in update.body means\n // whatever current body is present is being overridden with an empty\n // body, whereas an `undefined` value in update.body implies no\n // override.\n const body = update.body !== undefined ? update.body : this.body;\n // Carefully handle the boolean options to differentiate between\n // `false` and `undefined` in the update args.\n const withCredentials = update.withCredentials ?? this.withCredentials;\n const reportProgress = update.reportProgress ?? this.reportProgress;\n // Headers and params may be appended to if `setHeaders` or\n // `setParams` are used.\n let headers = update.headers || this.headers;\n let params = update.params || this.params;\n // Pass on context if needed\n const context = update.context ?? this.context;\n // Check whether the caller has asked to add headers.\n if (update.setHeaders !== undefined) {\n // Set every requested header.\n headers = Object.keys(update.setHeaders).reduce((headers, name) => headers.set(name, update.setHeaders[name]), headers);\n }\n // Check whether the caller has asked to set params.\n if (update.setParams) {\n // Set every requested param.\n params = Object.keys(update.setParams).reduce((params, param) => params.set(param, update.setParams[param]), params);\n }\n // Finally, construct the new HttpRequest using the pieces from above.\n return new HttpRequest(method, url, body, {\n params,\n headers,\n context,\n reportProgress,\n responseType,\n withCredentials,\n transferCache,\n });\n }\n}\n\n/**\n * Type enumeration for the different kinds of `HttpEvent`.\n *\n * @publicApi\n */\nvar HttpEventType;\n(function (HttpEventType) {\n /**\n * The request was sent out over the wire.\n */\n HttpEventType[HttpEventType[\"Sent\"] = 0] = \"Sent\";\n /**\n * An upload progress event was received.\n *\n * Note: The `FetchBackend` doesn't support progress report on uploads.\n */\n HttpEventType[HttpEventType[\"UploadProgress\"] = 1] = \"UploadProgress\";\n /**\n * The response status code and headers were received.\n */\n HttpEventType[HttpEventType[\"ResponseHeader\"] = 2] = \"ResponseHeader\";\n /**\n * A download progress event was received.\n */\n HttpEventType[HttpEventType[\"DownloadProgress\"] = 3] = \"DownloadProgress\";\n /**\n * The full response including the body was received.\n */\n HttpEventType[HttpEventType[\"Response\"] = 4] = \"Response\";\n /**\n * A custom event from an interceptor or a backend.\n */\n HttpEventType[HttpEventType[\"User\"] = 5] = \"User\";\n})(HttpEventType || (HttpEventType = {}));\n/**\n * Base class for both `HttpResponse` and `HttpHeaderResponse`.\n *\n * @publicApi\n */\nclass HttpResponseBase {\n /**\n * All response headers.\n */\n headers;\n /**\n * Response status code.\n */\n status;\n /**\n * Textual description of response status code, defaults to OK.\n *\n * Do not depend on this.\n */\n statusText;\n /**\n * URL of the resource retrieved, or null if not available.\n */\n url;\n /**\n * Whether the status code falls in the 2xx range.\n */\n ok;\n /**\n * Type of the response, narrowed to either the full response or the header.\n */\n // TODO(issue/24571): remove '!'.\n type;\n /**\n * Super-constructor for all responses.\n *\n * The single parameter accepted is an initialization hash. Any properties\n * of the response passed there will override the default values.\n */\n constructor(init, defaultStatus = 200, defaultStatusText = 'OK') {\n // If the hash has values passed, use them to initialize the response.\n // Otherwise use the default values.\n this.headers = init.headers || new HttpHeaders();\n this.status = init.status !== undefined ? init.status : defaultStatus;\n this.statusText = init.statusText || defaultStatusText;\n this.url = init.url || null;\n // Cache the ok value to avoid defining a getter.\n this.ok = this.status >= 200 && this.status < 300;\n }\n}\n/**\n * A partial HTTP response which only includes the status and header data,\n * but no response body.\n *\n * `HttpHeaderResponse` is a `HttpEvent` available on the response\n * event stream, only when progress events are requested.\n *\n * @publicApi\n */\nclass HttpHeaderResponse extends HttpResponseBase {\n /**\n * Create a new `HttpHeaderResponse` with the given parameters.\n */\n constructor(init = {}) {\n super(init);\n }\n type = HttpEventType.ResponseHeader;\n /**\n * Copy this `HttpHeaderResponse`, overriding its contents with the\n * given parameter hash.\n */\n clone(update = {}) {\n // Perform a straightforward initialization of the new HttpHeaderResponse,\n // overriding the current parameters with new ones if given.\n return new HttpHeaderResponse({\n headers: update.headers || this.headers,\n status: update.status !== undefined ? update.status : this.status,\n statusText: update.statusText || this.statusText,\n url: update.url || this.url || undefined,\n });\n }\n}\n/**\n * A full HTTP response, including a typed response body (which may be `null`\n * if one was not returned).\n *\n * `HttpResponse` is a `HttpEvent` available on the response event\n * stream.\n *\n * @publicApi\n */\nclass HttpResponse extends HttpResponseBase {\n /**\n * The response body, or `null` if one was not returned.\n */\n body;\n /**\n * Construct a new `HttpResponse`.\n */\n constructor(init = {}) {\n super(init);\n this.body = init.body !== undefined ? init.body : null;\n }\n type = HttpEventType.Response;\n clone(update = {}) {\n return new HttpResponse({\n body: update.body !== undefined ? update.body : this.body,\n headers: update.headers || this.headers,\n status: update.status !== undefined ? update.status : this.status,\n statusText: update.statusText || this.statusText,\n url: update.url || this.url || undefined,\n });\n }\n}\n/**\n * A response that represents an error or failure, either from a\n * non-successful HTTP status, an error while executing the request,\n * or some other failure which occurred during the parsing of the response.\n *\n * Any error returned on the `Observable` response stream will be\n * wrapped in an `HttpErrorResponse` to provide additional context about\n * the state of the HTTP layer when the error occurred. The error property\n * will contain either a wrapped Error object or the error response returned\n * from the server.\n *\n * @publicApi\n */\nclass HttpErrorResponse extends HttpResponseBase {\n name = 'HttpErrorResponse';\n message;\n error;\n /**\n * Errors are never okay, even when the status code is in the 2xx success range.\n */\n ok = false;\n constructor(init) {\n // Initialize with a default status of 0 / Unknown Error.\n super(init, 0, 'Unknown Error');\n // If the response was successful, then this was a parse error. Otherwise, it was\n // a protocol-level failure of some sort. Either the request failed in transit\n // or the server returned an unsuccessful status code.\n if (this.status >= 200 && this.status < 300) {\n this.message = `Http failure during parsing for ${init.url || '(unknown url)'}`;\n }\n else {\n this.message = `Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${init.statusText}`;\n }\n this.error = init.error || null;\n }\n}\n/**\n * We use these constant to prevent pulling the whole HttpStatusCode enum\n * Those are the only ones referenced directly by the framework\n */\nconst HTTP_STATUS_CODE_OK = 200;\nconst HTTP_STATUS_CODE_NO_CONTENT = 204;\n/**\n * Http status codes.\n * As per https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml\n * @publicApi\n */\nvar HttpStatusCode;\n(function (HttpStatusCode) {\n HttpStatusCode[HttpStatusCode[\"Continue\"] = 100] = \"Continue\";\n HttpStatusCode[HttpStatusCode[\"SwitchingProtocols\"] = 101] = \"SwitchingProtocols\";\n HttpStatusCode[HttpStatusCode[\"Processing\"] = 102] = \"Processing\";\n HttpStatusCode[HttpStatusCode[\"EarlyHints\"] = 103] = \"EarlyHints\";\n HttpStatusCode[HttpStatusCode[\"Ok\"] = 200] = \"Ok\";\n HttpStatusCode[HttpStatusCode[\"Created\"] = 201] = \"Created\";\n HttpStatusCode[HttpStatusCode[\"Accepted\"] = 202] = \"Accepted\";\n HttpStatusCode[HttpStatusCode[\"NonAuthoritativeInformation\"] = 203] = \"NonAuthoritativeInformation\";\n HttpStatusCode[HttpStatusCode[\"NoContent\"] = 204] = \"NoContent\";\n HttpStatusCode[HttpStatusCode[\"ResetContent\"] = 205] = \"ResetContent\";\n HttpStatusCode[HttpStatusCode[\"PartialContent\"] = 206] = \"PartialContent\";\n HttpStatusCode[HttpStatusCode[\"MultiStatus\"] = 207] = \"MultiStatus\";\n HttpStatusCode[HttpStatusCode[\"AlreadyReported\"] = 208] = \"AlreadyReported\";\n HttpStatusCode[HttpStatusCode[\"ImUsed\"] = 226] = \"ImUsed\";\n HttpStatusCode[HttpStatusCode[\"MultipleChoices\"] = 300] = \"MultipleChoices\";\n HttpStatusCode[HttpStatusCode[\"MovedPermanently\"] = 301] = \"MovedPermanently\";\n HttpStatusCode[HttpStatusCode[\"Found\"] = 302] = \"Found\";\n HttpStatusCode[HttpStatusCode[\"SeeOther\"] = 303] = \"SeeOther\";\n HttpStatusCode[HttpStatusCode[\"NotModified\"] = 304] = \"NotModified\";\n HttpStatusCode[HttpStatusCode[\"UseProxy\"] = 305] = \"UseProxy\";\n HttpStatusCode[HttpStatusCode[\"Unused\"] = 306] = \"Unused\";\n HttpStatusCode[HttpStatusCode[\"TemporaryRedirect\"] = 307] = \"TemporaryRedirect\";\n HttpStatusCode[HttpStatusCode[\"PermanentRedirect\"] = 308] = \"PermanentRedirect\";\n HttpStatusCode[HttpStatusCode[\"BadRequest\"] = 400] = \"BadRequest\";\n HttpStatusCode[HttpStatusCode[\"Unauthorized\"] = 401] = \"Unauthorized\";\n HttpStatusCode[HttpStatusCode[\"PaymentRequired\"] = 402] = \"PaymentRequired\";\n HttpStatusCode[HttpStatusCode[\"Forbidden\"] = 403] = \"Forbidden\";\n HttpStatusCode[HttpStatusCode[\"NotFound\"] = 404] = \"NotFound\";\n HttpStatusCode[HttpStatusCode[\"MethodNotAllowed\"] = 405] = \"MethodNotAllowed\";\n HttpStatusCode[HttpStatusCode[\"NotAcceptable\"] = 406] = \"NotAcceptable\";\n HttpStatusCode[HttpStatusCode[\"ProxyAuthenticationRequired\"] = 407] = \"ProxyAuthenticationRequired\";\n HttpStatusCode[HttpStatusCode[\"RequestTimeout\"] = 408] = \"RequestTimeout\";\n HttpStatusCode[HttpStatusCode[\"Conflict\"] = 409] = \"Conflict\";\n HttpStatusCode[HttpStatusCode[\"Gone\"] = 410] = \"Gone\";\n HttpStatusCode[HttpStatusCode[\"LengthRequired\"] = 411] = \"LengthRequired\";\n HttpStatusCode[HttpStatusCode[\"PreconditionFailed\"] = 412] = \"PreconditionFailed\";\n HttpStatusCode[HttpStatusCode[\"PayloadTooLarge\"] = 413] = \"PayloadTooLarge\";\n HttpStatusCode[HttpStatusCode[\"UriTooLong\"] = 414] = \"UriTooLong\";\n HttpStatusCode[HttpStatusCode[\"UnsupportedMediaType\"] = 415] = \"UnsupportedMediaType\";\n HttpStatusCode[HttpStatusCode[\"RangeNotSatisfiable\"] = 416] = \"RangeNotSatisfiable\";\n HttpStatusCode[HttpStatusCode[\"ExpectationFailed\"] = 417] = \"ExpectationFailed\";\n HttpStatusCode[HttpStatusCode[\"ImATeapot\"] = 418] = \"ImATeapot\";\n HttpStatusCode[HttpStatusCode[\"MisdirectedRequest\"] = 421] = \"MisdirectedRequest\";\n HttpStatusCode[HttpStatusCode[\"UnprocessableEntity\"] = 422] = \"UnprocessableEntity\";\n HttpStatusCode[HttpStatusCode[\"Locked\"] = 423] = \"Locked\";\n HttpStatusCode[HttpStatusCode[\"FailedDependency\"] = 424] = \"FailedDependency\";\n HttpStatusCode[HttpStatusCode[\"TooEarly\"] = 425] = \"TooEarly\";\n HttpStatusCode[HttpStatusCode[\"UpgradeRequired\"] = 426] = \"UpgradeRequired\";\n HttpStatusCode[HttpStatusCode[\"PreconditionRequired\"] = 428] = \"PreconditionRequired\";\n HttpStatusCode[HttpStatusCode[\"TooManyRequests\"] = 429] = \"TooManyRequests\";\n HttpStatusCode[HttpStatusCode[\"RequestHeaderFieldsTooLarge\"] = 431] = \"RequestHeaderFieldsTooLarge\";\n HttpStatusCode[HttpStatusCode[\"UnavailableForLegalReasons\"] = 451] = \"UnavailableForLegalReasons\";\n HttpStatusCode[HttpStatusCode[\"InternalServerError\"] = 500] = \"InternalServerError\";\n HttpStatusCode[HttpStatusCode[\"NotImplemented\"] = 501] = \"NotImplemented\";\n HttpStatusCode[HttpStatusCode[\"BadGateway\"] = 502] = \"BadGateway\";\n HttpStatusCode[HttpStatusCode[\"ServiceUnavailable\"] = 503] = \"ServiceUnavailable\";\n HttpStatusCode[HttpStatusCode[\"GatewayTimeout\"] = 504] = \"GatewayTimeout\";\n HttpStatusCode[HttpStatusCode[\"HttpVersionNotSupported\"] = 505] = \"HttpVersionNotSupported\";\n HttpStatusCode[HttpStatusCode[\"VariantAlsoNegotiates\"] = 506] = \"VariantAlsoNegotiates\";\n HttpStatusCode[HttpStatusCode[\"InsufficientStorage\"] = 507] = \"InsufficientStorage\";\n HttpStatusCode[HttpStatusCode[\"LoopDetected\"] = 508] = \"LoopDetected\";\n HttpStatusCode[HttpStatusCode[\"NotExtended\"] = 510] = \"NotExtended\";\n HttpStatusCode[HttpStatusCode[\"NetworkAuthenticationRequired\"] = 511] = \"NetworkAuthenticationRequired\";\n})(HttpStatusCode || (HttpStatusCode = {}));\n\n/**\n * Constructs an instance of `HttpRequestOptions` from a source `HttpMethodOptions` and\n * the given `body`. This function clones the object and adds the body.\n *\n * Note that the `responseType` *options* value is a String that identifies the\n * single data type of the response.\n * A single overload version of the method handles each response type.\n * The value of `responseType` cannot be a union, as the combined signature could imply.\n *\n */\nfunction addBody(options, body) {\n return {\n body,\n headers: options.headers,\n context: options.context,\n observe: options.observe,\n params: options.params,\n reportProgress: options.reportProgress,\n responseType: options.responseType,\n withCredentials: options.withCredentials,\n transferCache: options.transferCache,\n };\n}\n/**\n * Performs HTTP requests.\n * This service is available as an injectable class, with methods to perform HTTP requests.\n * Each request method has multiple signatures, and the return type varies based on\n * the signature that is called (mainly the values of `observe` and `responseType`).\n *\n * Note that the `responseType` *options* value is a String that identifies the\n * single data type of the response.\n * A single overload version of the method handles each response type.\n * The value of `responseType` cannot be a union, as the combined signature could imply.\n\n * TODO(adev): review\n * @usageNotes\n *\n * ### HTTP Request Example\n *\n * ```ts\n * // GET heroes whose name contains search term\n * searchHeroes(term: string): observable{\n *\n * const params = new HttpParams({fromString: 'name=term'});\n * return this.httpClient.request('GET', this.heroesUrl, {responseType:'json', params});\n * }\n * ```\n *\n * Alternatively, the parameter string can be used without invoking HttpParams\n * by directly joining to the URL.\n * ```ts\n * this.httpClient.request('GET', this.heroesUrl + '?' + 'name=term', {responseType:'json'});\n * ```\n *\n *\n * ### JSONP Example\n * ```ts\n * requestJsonp(url, callback = 'callback') {\n * return this.httpClient.jsonp(this.heroesURL, callback);\n * }\n * ```\n *\n * ### PATCH Example\n * ```ts\n * // PATCH one of the heroes' name\n * patchHero (id: number, heroName: string): Observable<{}> {\n * const url = `${this.heroesUrl}/${id}`; // PATCH api/heroes/42\n * return this.httpClient.patch(url, {name: heroName}, httpOptions)\n * .pipe(catchError(this.handleError('patchHero')));\n * }\n * ```\n *\n * @see [HTTP Guide](guide/http)\n * @see [HTTP Request](api/common/http/HttpRequest)\n *\n * @publicApi\n */\nclass HttpClient {\n handler;\n constructor(handler) {\n this.handler = handler;\n }\n /**\n * Constructs an observable for a generic HTTP request that, when subscribed,\n * fires the request through the chain of registered interceptors and on to the\n * server.\n *\n * You can pass an `HttpRequest` directly as the only parameter. In this case,\n * the call returns an observable of the raw `HttpEvent` stream.\n *\n * Alternatively you can pass an HTTP method as the first parameter,\n * a URL string as the second, and an options hash containing the request body as the third.\n * See `addBody()`. In this case, the specified `responseType` and `observe` options determine the\n * type of returned observable.\n * * The `responseType` value determines how a successful response body is parsed.\n * * If `responseType` is the default `json`, you can pass a type interface for the resulting\n * object as a type parameter to the call.\n *\n * The `observe` value determines the return type, according to what you are interested in\n * observing.\n * * An `observe` value of events returns an observable of the raw `HttpEvent` stream, including\n * progress events by default.\n * * An `observe` value of response returns an observable of `HttpResponse`,\n * where the `T` parameter depends on the `responseType` and any optionally provided type\n * parameter.\n * * An `observe` value of body returns an observable of `` with the same `T` body type.\n *\n */\n request(first, url, options = {}) {\n let req;\n // First, check whether the primary argument is an instance of `HttpRequest`.\n if (first instanceof HttpRequest) {\n // It is. The other arguments must be undefined (per the signatures) and can be\n // ignored.\n req = first;\n }\n else {\n // It's a string, so it represents a URL. Construct a request based on it,\n // and incorporate the remaining arguments (assuming `GET` unless a method is\n // provided.\n // Figure out the headers.\n let headers = undefined;\n if (options.headers instanceof HttpHeaders) {\n headers = options.headers;\n }\n else {\n headers = new HttpHeaders(options.headers);\n }\n // Sort out parameters.\n let params = undefined;\n if (!!options.params) {\n if (options.params instanceof HttpParams) {\n params = options.params;\n }\n else {\n params = new HttpParams({ fromObject: options.params });\n }\n }\n // Construct the request.\n req = new HttpRequest(first, url, options.body !== undefined ? options.body : null, {\n headers,\n context: options.context,\n params,\n reportProgress: options.reportProgress,\n // By default, JSON is assumed to be returned for all calls.\n responseType: options.responseType || 'json',\n withCredentials: options.withCredentials,\n transferCache: options.transferCache,\n });\n }\n // Start with an Observable.of() the initial request, and run the handler (which\n // includes all interceptors) inside a concatMap(). This way, the handler runs\n // inside an Observable chain, which causes interceptors to be re-run on every\n // subscription (this also makes retries re-run the handler, including interceptors).\n const events$ = of(req).pipe(concatMap((req) => this.handler.handle(req)));\n // If coming via the API signature which accepts a previously constructed HttpRequest,\n // the only option is to get the event stream. Otherwise, return the event stream if\n // that is what was requested.\n if (first instanceof HttpRequest || options.observe === 'events') {\n return events$;\n }\n // The requested stream contains either the full response or the body. In either\n // case, the first step is to filter the event stream to extract a stream of\n // responses(s).\n const res$ = (events$.pipe(filter((event) => event instanceof HttpResponse)));\n // Decide which stream to return.\n switch (options.observe || 'body') {\n case 'body':\n // The requested stream is the body. Map the response stream to the response\n // body. This could be done more simply, but a misbehaving interceptor might\n // transform the response body into a different format and ignore the requested\n // responseType. Guard against this by validating that the response is of the\n // requested type.\n switch (req.responseType) {\n case 'arraybuffer':\n return res$.pipe(map((res) => {\n // Validate that the body is an ArrayBuffer.\n if (res.body !== null && !(res.body instanceof ArrayBuffer)) {\n throw new Error('Response is not an ArrayBuffer.');\n }\n return res.body;\n }));\n case 'blob':\n return res$.pipe(map((res) => {\n // Validate that the body is a Blob.\n if (res.body !== null && !(res.body instanceof Blob)) {\n throw new Error('Response is not a Blob.');\n }\n return res.body;\n }));\n case 'text':\n return res$.pipe(map((res) => {\n // Validate that the body is a string.\n if (res.body !== null && typeof res.body !== 'string') {\n throw new Error('Response is not a string.');\n }\n return res.body;\n }));\n case 'json':\n default:\n // No validation needed for JSON responses, as they can be of any type.\n return res$.pipe(map((res) => res.body));\n }\n case 'response':\n // The response stream was requested directly, so return it.\n return res$;\n default:\n // Guard against new future observe types being added.\n throw new Error(`Unreachable: unhandled observe type ${options.observe}}`);\n }\n }\n /**\n * Constructs an observable that, when subscribed, causes the configured\n * `DELETE` request to execute on the server. See the individual overloads for\n * details on the return type.\n *\n * @param url The endpoint URL.\n * @param options The HTTP options to send with the request.\n *\n */\n delete(url, options = {}) {\n return this.request('DELETE', url, options);\n }\n /**\n * Constructs an observable that, when subscribed, causes the configured\n * `GET` request to execute on the server. See the individual overloads for\n * details on the return type.\n */\n get(url, options = {}) {\n return this.request('GET', url, options);\n }\n /**\n * Constructs an observable that, when subscribed, causes the configured\n * `HEAD` request to execute on the server. The `HEAD` method returns\n * meta information about the resource without transferring the\n * resource itself. See the individual overloads for\n * details on the return type.\n */\n head(url, options = {}) {\n return this.request('HEAD', url, options);\n }\n /**\n * Constructs an `Observable` that, when subscribed, causes a request with the special method\n * `JSONP` to be dispatched via the interceptor pipeline.\n * The [JSONP pattern](https://en.wikipedia.org/wiki/JSONP) works around limitations of certain\n * API endpoints that don't support newer,\n * and preferable [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) protocol.\n * JSONP treats the endpoint API as a JavaScript file and tricks the browser to process the\n * requests even if the API endpoint is not located on the same domain (origin) as the client-side\n * application making the request.\n * The endpoint API must support JSONP callback for JSONP requests to work.\n * The resource API returns the JSON response wrapped in a callback function.\n * You can pass the callback function name as one of the query parameters.\n * Note that JSONP requests can only be used with `GET` requests.\n *\n * @param url The resource URL.\n * @param callbackParam The callback function name.\n *\n */\n jsonp(url, callbackParam) {\n return this.request('JSONP', url, {\n params: new HttpParams().append(callbackParam, 'JSONP_CALLBACK'),\n observe: 'body',\n responseType: 'json',\n });\n }\n /**\n * Constructs an `Observable` that, when subscribed, causes the configured\n * `OPTIONS` request to execute on the server. This method allows the client\n * to determine the supported HTTP methods and other capabilities of an endpoint,\n * without implying a resource action. See the individual overloads for\n * details on the return type.\n */\n options(url, options = {}) {\n return this.request('OPTIONS', url, options);\n }\n /**\n * Constructs an observable that, when subscribed, causes the configured\n * `PATCH` request to execute on the server. See the individual overloads for\n * details on the return type.\n */\n patch(url, body, options = {}) {\n return this.request('PATCH', url, addBody(options, body));\n }\n /**\n * Constructs an observable that, when subscribed, causes the configured\n * `POST` request to execute on the server. The server responds with the location of\n * the replaced resource. See the individual overloads for\n * details on the return type.\n */\n post(url, body, options = {}) {\n return this.request('POST', url, addBody(options, body));\n }\n /**\n * Constructs an observable that, when subscribed, causes the configured\n * `PUT` request to execute on the server. The `PUT` method replaces an existing resource\n * with a new set of values.\n * See the individual overloads for details on the return type.\n */\n put(url, body, options = {}) {\n return this.request('PUT', url, addBody(options, body));\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HttpClient, deps: [{ token: HttpHandler }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HttpClient });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HttpClient, decorators: [{\n type: Injectable\n }], ctorParameters: () => [{ type: HttpHandler }] });\n\nconst XSSI_PREFIX$1 = /^\\)\\]\\}',?\\n/;\nconst REQUEST_URL_HEADER = `X-Request-URL`;\n/**\n * Determine an appropriate URL for the response, by checking either\n * response url or the X-Request-URL header.\n */\nfunction getResponseUrl$1(response) {\n if (response.url) {\n return response.url;\n }\n // stored as lowercase in the map\n const xRequestUrl = REQUEST_URL_HEADER.toLocaleLowerCase();\n return response.headers.get(xRequestUrl);\n}\n/**\n * Uses `fetch` to send requests to a backend server.\n *\n * This `FetchBackend` requires the support of the\n * [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) which is available on all\n * supported browsers and on Node.js v18 or later.\n *\n * @see {@link HttpHandler}\n *\n * @publicApi\n */\nclass FetchBackend {\n // We use an arrow function to always reference the current global implementation of `fetch`.\n // This is helpful for cases when the global `fetch` implementation is modified by external code,\n // see https://github.com/angular/angular/issues/57527.\n fetchImpl = inject(FetchFactory, { optional: true })?.fetch ?? ((...args) => globalThis.fetch(...args));\n ngZone = inject(NgZone);\n handle(request) {\n return new Observable((observer) => {\n const aborter = new AbortController();\n this.doRequest(request, aborter.signal, observer).then(noop, (error) => observer.error(new HttpErrorResponse({ error })));\n return () => aborter.abort();\n });\n }\n async doRequest(request, signal, observer) {\n const init = this.createRequestInit(request);\n let response;\n try {\n // Run fetch outside of Angular zone.\n // This is due to Node.js fetch implementation (Undici) which uses a number of setTimeouts to check if\n // the response should eventually timeout which causes extra CD cycles every 500ms\n const fetchPromise = this.ngZone.runOutsideAngular(() => this.fetchImpl(request.urlWithParams, { signal, ...init }));\n // Make sure Zone.js doesn't trigger false-positive unhandled promise\n // error in case the Promise is rejected synchronously. See function\n // description for additional information.\n silenceSuperfluousUnhandledPromiseRejection(fetchPromise);\n // Send the `Sent` event before awaiting the response.\n observer.next({ type: HttpEventType.Sent });\n response = await fetchPromise;\n }\n catch (error) {\n observer.error(new HttpErrorResponse({\n error,\n status: error.status ?? 0,\n statusText: error.statusText,\n url: request.urlWithParams,\n headers: error.headers,\n }));\n return;\n }\n const headers = new HttpHeaders(response.headers);\n const statusText = response.statusText;\n const url = getResponseUrl$1(response) ?? request.urlWithParams;\n let status = response.status;\n let body = null;\n if (request.reportProgress) {\n observer.next(new HttpHeaderResponse({ headers, status, statusText, url }));\n }\n if (response.body) {\n // Read Progress\n const contentLength = response.headers.get('content-length');\n const chunks = [];\n const reader = response.body.getReader();\n let receivedLength = 0;\n let decoder;\n let partialText;\n // We have to check whether the Zone is defined in the global scope because this may be called\n // when the zone is nooped.\n const reqZone = typeof Zone !== 'undefined' && Zone.current;\n // Perform response processing outside of Angular zone to\n // ensure no excessive change detection runs are executed\n // Here calling the async ReadableStreamDefaultReader.read() is responsible for triggering CD\n await this.ngZone.runOutsideAngular(async () => {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n chunks.push(value);\n receivedLength += value.length;\n if (request.reportProgress) {\n partialText =\n request.responseType === 'text'\n ? (partialText ?? '') +\n (decoder ??= new TextDecoder()).decode(value, { stream: true })\n : undefined;\n const reportProgress = () => observer.next({\n type: HttpEventType.DownloadProgress,\n total: contentLength ? +contentLength : undefined,\n loaded: receivedLength,\n partialText,\n });\n reqZone ? reqZone.run(reportProgress) : reportProgress();\n }\n }\n });\n // Combine all chunks.\n const chunksAll = this.concatChunks(chunks, receivedLength);\n try {\n const contentType = response.headers.get('Content-Type') ?? '';\n body = this.parseBody(request, chunksAll, contentType);\n }\n catch (error) {\n // Body loading or parsing failed\n observer.error(new HttpErrorResponse({\n error,\n headers: new HttpHeaders(response.headers),\n status: response.status,\n statusText: response.statusText,\n url: getResponseUrl$1(response) ?? request.urlWithParams,\n }));\n return;\n }\n }\n // Same behavior as the XhrBackend\n if (status === 0) {\n status = body ? HTTP_STATUS_CODE_OK : 0;\n }\n // ok determines whether the response will be transmitted on the event or\n // error channel. Unsuccessful status codes (not 2xx) will always be errors,\n // but a successful status code can still result in an error if the user\n // asked for JSON data and the body cannot be parsed as such.\n const ok = status >= 200 && status < 300;\n if (ok) {\n observer.next(new HttpResponse({\n body,\n headers,\n status,\n statusText,\n url,\n }));\n // The full body has been received and delivered, no further events\n // are possible. This request is complete.\n observer.complete();\n }\n else {\n observer.error(new HttpErrorResponse({\n error: body,\n headers,\n status,\n statusText,\n url,\n }));\n }\n }\n parseBody(request, binContent, contentType) {\n switch (request.responseType) {\n case 'json':\n // stripping the XSSI when present\n const text = new TextDecoder().decode(binContent).replace(XSSI_PREFIX$1, '');\n return text === '' ? null : JSON.parse(text);\n case 'text':\n return new TextDecoder().decode(binContent);\n case 'blob':\n return new Blob([binContent], { type: contentType });\n case 'arraybuffer':\n return binContent.buffer;\n }\n }\n createRequestInit(req) {\n // We could share some of this logic with the XhrBackend\n const headers = {};\n const credentials = req.withCredentials ? 'include' : undefined;\n // Setting all the requested headers.\n req.headers.forEach((name, values) => (headers[name] = values.join(',')));\n // Add an Accept header if one isn't present already.\n if (!req.headers.has('Accept')) {\n headers['Accept'] = 'application/json, text/plain, */*';\n }\n // Auto-detect the Content-Type header if one isn't present already.\n if (!req.headers.has('Content-Type')) {\n const detectedType = req.detectContentTypeHeader();\n // Sometimes Content-Type detection fails.\n if (detectedType !== null) {\n headers['Content-Type'] = detectedType;\n }\n }\n return {\n body: req.serializeBody(),\n method: req.method,\n headers,\n credentials,\n };\n }\n concatChunks(chunks, totalLength) {\n const chunksAll = new Uint8Array(totalLength);\n let position = 0;\n for (const chunk of chunks) {\n chunksAll.set(chunk, position);\n position += chunk.length;\n }\n return chunksAll;\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: FetchBackend, deps: [], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: FetchBackend });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: FetchBackend, decorators: [{\n type: Injectable\n }] });\n/**\n * Abstract class to provide a mocked implementation of `fetch()`\n */\nclass FetchFactory {\n}\nfunction noop() { }\n/**\n * Zone.js treats a rejected promise that has not yet been awaited\n * as an unhandled error. This function adds a noop `.then` to make\n * sure that Zone.js doesn't throw an error if the Promise is rejected\n * synchronously.\n */\nfunction silenceSuperfluousUnhandledPromiseRejection(promise) {\n promise.then(noop, noop);\n}\n\nfunction interceptorChainEndFn(req, finalHandlerFn) {\n return finalHandlerFn(req);\n}\n/**\n * Constructs a `ChainedInterceptorFn` which adapts a legacy `HttpInterceptor` to the\n * `ChainedInterceptorFn` interface.\n */\nfunction adaptLegacyInterceptorToChain(chainTailFn, interceptor) {\n return (initialRequest, finalHandlerFn) => interceptor.intercept(initialRequest, {\n handle: (downstreamRequest) => chainTailFn(downstreamRequest, finalHandlerFn),\n });\n}\n/**\n * Constructs a `ChainedInterceptorFn` which wraps and invokes a functional interceptor in the given\n * injector.\n */\nfunction chainedInterceptorFn(chainTailFn, interceptorFn, injector) {\n return (initialRequest, finalHandlerFn) => runInInjectionContext(injector, () => interceptorFn(initialRequest, (downstreamRequest) => chainTailFn(downstreamRequest, finalHandlerFn)));\n}\n/**\n * A multi-provider token that represents the array of registered\n * `HttpInterceptor` objects.\n *\n * @publicApi\n */\nconst HTTP_INTERCEPTORS = new InjectionToken(ngDevMode ? 'HTTP_INTERCEPTORS' : '');\n/**\n * A multi-provided token of `HttpInterceptorFn`s.\n */\nconst HTTP_INTERCEPTOR_FNS = new InjectionToken(ngDevMode ? 'HTTP_INTERCEPTOR_FNS' : '');\n/**\n * A multi-provided token of `HttpInterceptorFn`s that are only set in root.\n */\nconst HTTP_ROOT_INTERCEPTOR_FNS = new InjectionToken(ngDevMode ? 'HTTP_ROOT_INTERCEPTOR_FNS' : '');\n// TODO(atscott): We need a larger discussion about stability and what should contribute to stability.\n// Should the whole interceptor chain contribute to stability or just the backend request #55075?\n// Should HttpClient contribute to stability automatically at all?\nconst REQUESTS_CONTRIBUTE_TO_STABILITY = new InjectionToken(ngDevMode ? 'REQUESTS_CONTRIBUTE_TO_STABILITY' : '', { providedIn: 'root', factory: () => true });\n/**\n * Creates an `HttpInterceptorFn` which lazily initializes an interceptor chain from the legacy\n * class-based interceptors and runs the request through it.\n */\nfunction legacyInterceptorFnFactory() {\n let chain = null;\n return (req, handler) => {\n if (chain === null) {\n const interceptors = inject(HTTP_INTERCEPTORS, { optional: true }) ?? [];\n // Note: interceptors are wrapped right-to-left so that final execution order is\n // left-to-right. That is, if `interceptors` is the array `[a, b, c]`, we want to\n // produce a chain that is conceptually `c(b(a(end)))`, which we build from the inside\n // out.\n chain = interceptors.reduceRight(adaptLegacyInterceptorToChain, interceptorChainEndFn);\n }\n const pendingTasks = inject(ɵPendingTasksInternal);\n const contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);\n if (contributeToStability) {\n const taskId = pendingTasks.add();\n return chain(req, handler).pipe(finalize(() => pendingTasks.remove(taskId)));\n }\n else {\n return chain(req, handler);\n }\n };\n}\nlet fetchBackendWarningDisplayed = false;\n/** Internal function to reset the flag in tests */\nfunction resetFetchBackendWarningFlag() {\n fetchBackendWarningDisplayed = false;\n}\nclass HttpInterceptorHandler extends HttpHandler {\n backend;\n injector;\n chain = null;\n pendingTasks = inject(ɵPendingTasksInternal);\n contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);\n constructor(backend, injector) {\n super();\n this.backend = backend;\n this.injector = injector;\n // We strongly recommend using fetch backend for HTTP calls when SSR is used\n // for an application. The logic below checks if that's the case and produces\n // a warning otherwise.\n if ((typeof ngDevMode === 'undefined' || ngDevMode) && !fetchBackendWarningDisplayed) {\n const isServer = isPlatformServer(injector.get(PLATFORM_ID));\n // This flag is necessary because provideHttpClientTesting() overrides the backend\n // even if `withFetch()` is used within the test. When the testing HTTP backend is provided,\n // no HTTP calls are actually performed during the test, so producing a warning would be\n // misleading.\n const isTestingBackend = this.backend.isTestingBackend;\n if (isServer && !(this.backend instanceof FetchBackend) && !isTestingBackend) {\n fetchBackendWarningDisplayed = true;\n injector\n .get(ɵConsole)\n .warn(ɵformatRuntimeError(2801 /* RuntimeErrorCode.NOT_USING_FETCH_BACKEND_IN_SSR */, 'Angular detected that `HttpClient` is not configured ' +\n \"to use `fetch` APIs. It's strongly recommended to \" +\n 'enable `fetch` for applications that use Server-Side Rendering ' +\n 'for better performance and compatibility. ' +\n 'To enable `fetch`, add the `withFetch()` to the `provideHttpClient()` ' +\n 'call at the root of the application.'));\n }\n }\n }\n handle(initialRequest) {\n if (this.chain === null) {\n const dedupedInterceptorFns = Array.from(new Set([\n ...this.injector.get(HTTP_INTERCEPTOR_FNS),\n ...this.injector.get(HTTP_ROOT_INTERCEPTOR_FNS, []),\n ]));\n // Note: interceptors are wrapped right-to-left so that final execution order is\n // left-to-right. That is, if `dedupedInterceptorFns` is the array `[a, b, c]`, we want to\n // produce a chain that is conceptually `c(b(a(end)))`, which we build from the inside\n // out.\n this.chain = dedupedInterceptorFns.reduceRight((nextSequencedFn, interceptorFn) => chainedInterceptorFn(nextSequencedFn, interceptorFn, this.injector), interceptorChainEndFn);\n }\n if (this.contributeToStability) {\n const taskId = this.pendingTasks.add();\n return this.chain(initialRequest, (downstreamRequest) => this.backend.handle(downstreamRequest)).pipe(finalize(() => this.pendingTasks.remove(taskId)));\n }\n else {\n return this.chain(initialRequest, (downstreamRequest) => this.backend.handle(downstreamRequest));\n }\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HttpInterceptorHandler, deps: [{ token: HttpBackend }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HttpInterceptorHandler });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"19.0.6\", ngImport: i0, type: HttpInterceptorHandler, decorators: [{\n type: Injectable\n }], ctorParameters: () => [{ type: HttpBackend }, { type: i0.EnvironmentInjector }] });\n\n// Every request made through JSONP needs a callback name that's unique across the\n// whole page. Each request is assigned an id and the callback name is constructed\n// from that. The next id to be assigned is tracked in a global variable here that\n// is shared among all applications on the page.\nlet nextRequestId = 0;\n/**\n * When a pending