{"version":3,"file":"vendor.js","sources":["./node_modules/@progress/kendo-common/dist/es2015/accessors/field-list.js","./node_modules/@progress/kendo-common/dist/es2015/accessors/getter.js","./node_modules/@progress/kendo-common/dist/es2015/accessors/setter.js","./node_modules/@progress/kendo-common/dist/es2015/main.js","./node_modules/@progress/kendo-common/dist/es2015/support.js","./node_modules/@progress/kendo-common/dist/es2015/util.js","./node_modules/@progress/kendo-draggable/dist/es2015/main.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/arc-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/circle-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/export-image.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/group-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/image-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/multi-path-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/node-map.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/path-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/rect-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/root-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/surface-cursor.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/surface.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/text-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/canvas/utils/render-path.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/animation-frame.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/class.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/color/color.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/color/named-colors.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/color/parse-color.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/html-encode.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/log-to-console.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/observable.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/support.js","./node_modules/@progress/kendo-drawing/dist/es2015/common/throttle.js","./node_modules/@progress/kendo-drawing/dist/es2015/core/base-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/core/constants.js","./node_modules/@progress/kendo-drawing/dist/es2015/core/has-observers.js","./node_modules/@progress/kendo-drawing/dist/es2015/core/options-store.js","./node_modules/@progress/kendo-drawing/dist/es2015/core/surface.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/arc.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/circle.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/constants.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/calculate-curve-at.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/close-or-less.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/close.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/complex-number.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/curve-intersections-count.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/ellipse-extreme-angles.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/has-roots-in-range.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/is-out-of-end-point.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/line-intersection.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/line-intersections-count.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/solve-cubic-equation.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/math/to-cubic-polynomial.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/matrix.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/point.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/rect.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/segment.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/size.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/to-matrix.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/transform.js","./node_modules/@progress/kendo-drawing/dist/es2015/geometry/transformation.js","./node_modules/@progress/kendo-drawing/dist/es2015/gradients/gradient-stop.js","./node_modules/@progress/kendo-drawing/dist/es2015/gradients/gradient.js","./node_modules/@progress/kendo-drawing/dist/es2015/gradients/linear-gradient.js","./node_modules/@progress/kendo-drawing/dist/es2015/gradients/radial-gradient.js","./node_modules/@progress/kendo-drawing/dist/es2015/gradients/stops-array.js","./node_modules/@progress/kendo-drawing/dist/es2015/mixins/measurable.js","./node_modules/@progress/kendo-drawing/dist/es2015/mixins/paintable.js","./node_modules/@progress/kendo-drawing/dist/es2015/mixins/traversable.js","./node_modules/@progress/kendo-drawing/dist/es2015/mixins/with-accessors.js","./node_modules/@progress/kendo-drawing/dist/es2015/mixins/with-geometry.js","./node_modules/@progress/kendo-drawing/dist/es2015/mixins/with-options.js","./node_modules/@progress/kendo-drawing/dist/es2015/mixins/with-points.js","./node_modules/@progress/kendo-drawing/dist/es2015/parsing/parse-path.js","./node_modules/@progress/kendo-drawing/dist/es2015/parsing/shape-map.js","./node_modules/@progress/kendo-drawing/dist/es2015/search/quad-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/search/quad-root.js","./node_modules/@progress/kendo-drawing/dist/es2015/search/shapes-quad-tree.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/element.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/elements-array.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/geometry-elements-array.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/group.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/image.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/path.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/utils/elements-bounding-box.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/utils/elements-clippend-bounding-box.js","./node_modules/@progress/kendo-drawing/dist/es2015/shapes/utils/points-to-curve.js","./node_modules/@progress/kendo-drawing/dist/es2015/surface-factory.js","./node_modules/@progress/kendo-drawing/dist/es2015/surface.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/arc-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/circle-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/clip-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/constants.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/definition-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/gradient-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/gradient-stop-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/group-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/image-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/linear-gradient-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/multi-path-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/node-map.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/path-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/radial-gradient-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/rect-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/root-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/surface.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/text-node.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/utils/render-all-attributes.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/utils/render-attribute.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/utils/render-style.js","./node_modules/@progress/kendo-drawing/dist/es2015/svg/utils/render-svg.js","./node_modules/@progress/kendo-drawing/dist/es2015/text-metrics.js","./node_modules/@progress/kendo-drawing/dist/es2015/text-metrics/lru-cache.js","./node_modules/@progress/kendo-drawing/dist/es2015/text-metrics/measure-text.js","./node_modules/@progress/kendo-drawing/dist/es2015/text-metrics/text-metrics.js","./node_modules/@progress/kendo-drawing/dist/es2015/text-metrics/util.js","./node_modules/@progress/kendo-drawing/dist/es2015/util.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/append.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/arabic-to-roman.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/bind-events.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/constants.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/create-promise.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/defined.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/definition-id.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/deg.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/element-offset.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/element-padding.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/element-scale.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/element-size.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/element-styles.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/encode-base64.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/encode-utf.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/event-coordinates.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/event-element.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/is-transparent.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/last.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/limit-value.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/merge-sort.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/now.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/promise-all.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/rad.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/round.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/unbind-events.js","./node_modules/@progress/kendo-drawing/dist/es2015/util/value-or-default.js","./node_modules/@progress/kendo-inputs-common/dist/es2015/common/drawing-utils.js","./node_modules/@progress/kendo-inputs-common/dist/es2015/signature/signature-pad.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/constants.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/currency.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/date-field-name.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/date-format-names.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/default-data.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/first-day.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/info.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/load-dates.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/load-numbers.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/load-units.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/load.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/number-symbols.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/parse-range-date.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/set-data.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/territory.js","./node_modules/@progress/kendo-intl/dist/es2015/cldr/weekend-range.js","./node_modules/@progress/kendo-intl/dist/es2015/common/constants.js","./node_modules/@progress/kendo-intl/dist/es2015/common/format-string.js","./node_modules/@progress/kendo-intl/dist/es2015/common/is-date.js","./node_modules/@progress/kendo-intl/dist/es2015/common/is-negative-zero.js","./node_modules/@progress/kendo-intl/dist/es2015/common/is-number.js","./node_modules/@progress/kendo-intl/dist/es2015/common/is-string.js","./node_modules/@progress/kendo-intl/dist/es2015/common/pad.js","./node_modules/@progress/kendo-intl/dist/es2015/common/round.js","./node_modules/@progress/kendo-intl/dist/es2015/dates.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/constants.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/date-name-type.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/date-pattern.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/format-date.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/format-names.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/parse-date.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/split-date-format.js","./node_modules/@progress/kendo-intl/dist/es2015/dates/time-utils.js","./node_modules/@progress/kendo-intl/dist/es2015/error-details.js","./node_modules/@progress/kendo-intl/dist/es2015/errors.js","./node_modules/@progress/kendo-intl/dist/es2015/format.js","./node_modules/@progress/kendo-intl/dist/es2015/main.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/custom-number-format.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/format-currency-symbol.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/format-number.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/format-options.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/group-integer.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/is-currency-style.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/parse-number.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/standard-number-format.js","./node_modules/@progress/kendo-intl/dist/es2015/numbers/utils.js","./node_modules/@progress/kendo-popup-common/dist/es2015/add-scroll.js","./node_modules/@progress/kendo-popup-common/dist/es2015/align-element.js","./node_modules/@progress/kendo-popup-common/dist/es2015/align-point.js","./node_modules/@progress/kendo-popup-common/dist/es2015/align.js","./node_modules/@progress/kendo-popup-common/dist/es2015/apply-location-offset.js","./node_modules/@progress/kendo-popup-common/dist/es2015/bounding-offset.js","./node_modules/@progress/kendo-popup-common/dist/es2015/collision.js","./node_modules/@progress/kendo-popup-common/dist/es2015/document.js","./node_modules/@progress/kendo-popup-common/dist/es2015/dom-utils.js","./node_modules/@progress/kendo-popup-common/dist/es2015/element-scroll-position.js","./node_modules/@progress/kendo-popup-common/dist/es2015/is-body-offset.js","./node_modules/@progress/kendo-popup-common/dist/es2015/main.js","./node_modules/@progress/kendo-popup-common/dist/es2015/offset-parent-scroll-position.js","./node_modules/@progress/kendo-popup-common/dist/es2015/offset-parent.js","./node_modules/@progress/kendo-popup-common/dist/es2015/offset.js","./node_modules/@progress/kendo-popup-common/dist/es2015/owner-document.js","./node_modules/@progress/kendo-popup-common/dist/es2015/parent-scroll-position.js","./node_modules/@progress/kendo-popup-common/dist/es2015/parents.js","./node_modules/@progress/kendo-popup-common/dist/es2015/position-element.js","./node_modules/@progress/kendo-popup-common/dist/es2015/position-with-scroll.js","./node_modules/@progress/kendo-popup-common/dist/es2015/position.js","./node_modules/@progress/kendo-popup-common/dist/es2015/remove-scroll.js","./node_modules/@progress/kendo-popup-common/dist/es2015/restrict-to-view.js","./node_modules/@progress/kendo-popup-common/dist/es2015/scroll-position.js","./node_modules/@progress/kendo-popup-common/dist/es2015/scrollbar-width.js","./node_modules/@progress/kendo-popup-common/dist/es2015/sibling-container.js","./node_modules/@progress/kendo-popup-common/dist/es2015/siblings.js","./node_modules/@progress/kendo-popup-common/dist/es2015/utils.js","./node_modules/@progress/kendo-popup-common/dist/es2015/window-viewport.js","./node_modules/@progress/kendo-popup-common/dist/es2015/window.js","./node_modules/@progress/kendo-popup-common/dist/es2015/z-index.js","./node_modules/@progress/kendo-svg-icons/dist/index.es.js","./node_modules/@w11k/ngx-componentdestroyed/dist/es2015/index.js","./node_modules/rxjs/dist/esm/internal/BehaviorSubject.js","./node_modules/rxjs/dist/esm/internal/NotificationFactories.js","./node_modules/rxjs/dist/esm/internal/Observable.js","./node_modules/rxjs/dist/esm/internal/ReplaySubject.js","./node_modules/rxjs/dist/esm/internal/Scheduler.js","./node_modules/rxjs/dist/esm/internal/Subject.js","./node_modules/rxjs/dist/esm/internal/Subscriber.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/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/observable/from.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/interval.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/operators/OperatorSubscriber.js","./node_modules/rxjs/dist/esm/internal/operators/audit.js","./node_modules/rxjs/dist/esm/internal/operators/auditTime.js","./node_modules/rxjs/dist/esm/internal/operators/catchError.js","./node_modules/rxjs/dist/esm/internal/operators/concatAll.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/delay.js","./node_modules/rxjs/dist/esm/internal/operators/delayWhen.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/ignoreElements.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/mergeInternals.js","./node_modules/rxjs/dist/esm/internal/operators/mergeMap.js","./node_modules/rxjs/dist/esm/internal/operators/observeOn.js","./node_modules/rxjs/dist/esm/internal/operators/partition.js","./node_modules/rxjs/dist/esm/internal/operators/refCount.js","./node_modules/rxjs/dist/esm/internal/operators/retry.js","./node_modules/rxjs/dist/esm/internal/operators/scan.js","./node_modules/rxjs/dist/esm/internal/operators/scanInternals.js","./node_modules/rxjs/dist/esm/internal/operators/share.js","./node_modules/rxjs/dist/esm/internal/operators/shareReplay.js","./node_modules/rxjs/dist/esm/internal/operators/skip.js","./node_modules/rxjs/dist/esm/internal/operators/skipWhile.js","./node_modules/rxjs/dist/esm/internal/operators/startWith.js","./node_modules/rxjs/dist/esm/internal/operators/subscribeOn.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/throttle.js","./node_modules/rxjs/dist/esm/internal/operators/throttleTime.js","./node_modules/rxjs/dist/esm/internal/operators/throwIfEmpty.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleArray.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleAsyncIterable.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleIterable.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleObservable.js","./node_modules/rxjs/dist/esm/internal/scheduled/schedulePromise.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduleReadableStreamLike.js","./node_modules/rxjs/dist/esm/internal/scheduled/scheduled.js","./node_modules/rxjs/dist/esm/internal/scheduler/Action.js","./node_modules/rxjs/dist/esm/internal/scheduler/AsyncAction.js","./node_modules/rxjs/dist/esm/internal/scheduler/AsyncScheduler.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/intervalProvider.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/ObjectUnsubscribedError.js","./node_modules/rxjs/dist/esm/internal/util/UnsubscriptionError.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/isDate.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/not.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/@angular/animations/fesm2022/animations.mjs","./node_modules/@angular/animations/fesm2022/browser.mjs","./node_modules/@angular/common/fesm2022/common.mjs","./node_modules/@angular/common/fesm2022/http.mjs","./node_modules/@angular/core/fesm2022/core.mjs","./node_modules/@angular/core/fesm2022/primitives/event-dispatch.mjs","./node_modules/@angular/core/fesm2022/primitives/signals.mjs","./node_modules/@angular/forms/fesm2022/forms.mjs","./node_modules/@angular/platform-browser/fesm2022/animations.mjs","./node_modules/@angular/platform-browser/fesm2022/platform-browser.mjs","./node_modules/@angular/router/fesm2022/router.mjs","./node_modules/@auth0/angular-jwt/fesm2020/auth0-angular-jwt.mjs","./node_modules/@ngx-translate/core/dist/fesm2022/ngx-translate-core.mjs","./node_modules/@progress/kendo-angular-buttons/fesm2020/progress-kendo-angular-buttons.mjs","./node_modules/@progress/kendo-angular-common/fesm2020/progress-kendo-angular-common.mjs","./node_modules/@progress/kendo-angular-dialog/fesm2020/progress-kendo-angular-dialog.mjs","./node_modules/@progress/kendo-angular-dropdowns/fesm2020/progress-kendo-angular-dropdowns.mjs","./node_modules/@progress/kendo-angular-icons/fesm2020/progress-kendo-angular-icons.mjs","./node_modules/@progress/kendo-angular-inputs/fesm2020/progress-kendo-angular-inputs.mjs","./node_modules/@progress/kendo-angular-intl/fesm2020/progress-kendo-angular-intl.mjs","./node_modules/@progress/kendo-angular-l10n/fesm2020/progress-kendo-angular-l10n.mjs","./node_modules/@progress/kendo-angular-navigation/fesm2020/progress-kendo-angular-navigation.mjs","./node_modules/@progress/kendo-angular-popup/fesm2020/progress-kendo-angular-popup.mjs","./node_modules/@progress/kendo-angular-treeview/fesm2020/progress-kendo-angular-treeview.mjs","./node_modules/@progress/kendo-licensing/dist/index.mjs","./node_modules/@sentry-internal/browser-utils/build/esm/debug-build.js","./node_modules/@sentry-internal/browser-utils/build/esm/getNativeImplementation.js","./node_modules/@sentry-internal/browser-utils/build/esm/instrument/dom.js","./node_modules/@sentry-internal/browser-utils/build/esm/instrument/history.js","./node_modules/@sentry-internal/browser-utils/build/esm/instrument/xhr.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-internal/browser-utils/build/esm/metrics/instrument.js","./node_modules/@sentry-internal/browser-utils/build/esm/metrics/utils.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/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/lib/bindReporter.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/getActivationStart.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/getVisibilityWatcher.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/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/polyfills/interactionCountPolyfill.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/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/onTTFB.js","./node_modules/@sentry-internal/browser-utils/build/esm/types.js","./node_modules/@sentry-internal/feedback/build/npm/esm/index.js","./node_modules/@sentry-internal/replay-canvas/build/npm/esm/index.js","./node_modules/@sentry-internal/replay/build/npm/esm/index.js","./node_modules/@sentry/angular/fesm2020/sentry-angular.mjs","./node_modules/@sentry/browser/build/npm/esm/client.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/feedbackAsync.js","./node_modules/@sentry/browser/build/npm/esm/feedbackSync.js","./node_modules/@sentry/browser/build/npm/esm/helpers.js","./node_modules/@sentry/browser/build/npm/esm/index.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/contextlines.js","./node_modules/@sentry/browser/build/npm/esm/integrations/globalhandlers.js","./node_modules/@sentry/browser/build/npm/esm/integrations/httpclient.js","./node_modules/@sentry/browser/build/npm/esm/integrations/httpcontext.js","./node_modules/@sentry/browser/build/npm/esm/integrations/linkederrors.js","./node_modules/@sentry/browser/build/npm/esm/integrations/reportingobserver.js","./node_modules/@sentry/browser/build/npm/esm/metrics.js","./node_modules/@sentry/browser/build/npm/esm/profiling/integration.js","./node_modules/@sentry/browser/build/npm/esm/profiling/startProfileForSpan.js","./node_modules/@sentry/browser/build/npm/esm/profiling/utils.js","./node_modules/@sentry/browser/build/npm/esm/sdk.js","./node_modules/@sentry/browser/build/npm/esm/stack-parsers.js","./node_modules/@sentry/browser/build/npm/esm/tracing/backgroundtab.js","./node_modules/@sentry/browser/build/npm/esm/tracing/browserTracingIntegration.js","./node_modules/@sentry/browser/build/npm/esm/tracing/request.js","./node_modules/@sentry/browser/build/npm/esm/transports/fetch.js","./node_modules/@sentry/browser/build/npm/esm/transports/offline.js","./node_modules/@sentry/browser/build/npm/esm/userfeedback.js","./node_modules/@sentry/browser/build/npm/esm/utils/lazyLoadIntegration.js","./node_modules/@sentry/core/build/esm/api.js","./node_modules/@sentry/core/build/esm/asyncContext/index.js","./node_modules/@sentry/core/build/esm/asyncContext/stackStrategy.js","./node_modules/@sentry/core/build/esm/baseclient.js","./node_modules/@sentry/core/build/esm/breadcrumbs.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/defaultScopes.js","./node_modules/@sentry/core/build/esm/envelope.js","./node_modules/@sentry/core/build/esm/eventProcessors.js","./node_modules/@sentry/core/build/esm/exports.js","./node_modules/@sentry/core/build/esm/feedback.js","./node_modules/@sentry/core/build/esm/fetch.js","./node_modules/@sentry/core/build/esm/getCurrentHubShim.js","./node_modules/@sentry/core/build/esm/integration.js","./node_modules/@sentry/core/build/esm/integrations/captureconsole.js","./node_modules/@sentry/core/build/esm/integrations/debug.js","./node_modules/@sentry/core/build/esm/integrations/dedupe.js","./node_modules/@sentry/core/build/esm/integrations/extraerrordata.js","./node_modules/@sentry/core/build/esm/integrations/functiontostring.js","./node_modules/@sentry/core/build/esm/integrations/inboundfilters.js","./node_modules/@sentry/core/build/esm/integrations/metadata.js","./node_modules/@sentry/core/build/esm/integrations/rewriteframes.js","./node_modules/@sentry/core/build/esm/integrations/sessiontiming.js","./node_modules/@sentry/core/build/esm/integrations/third-party-errors-filter.js","./node_modules/@sentry/core/build/esm/integrations/zoderrors.js","./node_modules/@sentry/core/build/esm/metadata.js","./node_modules/@sentry/core/build/esm/metrics/browser-aggregator.js","./node_modules/@sentry/core/build/esm/metrics/constants.js","./node_modules/@sentry/core/build/esm/metrics/envelope.js","./node_modules/@sentry/core/build/esm/metrics/exports.js","./node_modules/@sentry/core/build/esm/metrics/instance.js","./node_modules/@sentry/core/build/esm/metrics/metric-summary.js","./node_modules/@sentry/core/build/esm/metrics/utils.js","./node_modules/@sentry/core/build/esm/scope.js","./node_modules/@sentry/core/build/esm/sdk.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/errors.js","./node_modules/@sentry/core/build/esm/tracing/hubextensions.js","./node_modules/@sentry/core/build/esm/tracing/idleSpan.js","./node_modules/@sentry/core/build/esm/tracing/logSpans.js","./node_modules/@sentry/core/build/esm/tracing/measurement.js","./node_modules/@sentry/core/build/esm/tracing/sampling.js","./node_modules/@sentry/core/build/esm/tracing/sentryNonRecordingSpan.js","./node_modules/@sentry/core/build/esm/tracing/sentrySpan.js","./node_modules/@sentry/core/build/esm/tracing/spanstatus.js","./node_modules/@sentry/core/build/esm/tracing/trace.js","./node_modules/@sentry/core/build/esm/tracing/utils.js","./node_modules/@sentry/core/build/esm/transports/base.js","./node_modules/@sentry/core/build/esm/transports/multiplexed.js","./node_modules/@sentry/core/build/esm/transports/offline.js","./node_modules/@sentry/core/build/esm/utils/applyScopeDataToEvent.js","./node_modules/@sentry/core/build/esm/utils/handleCallbackErrors.js","./node_modules/@sentry/core/build/esm/utils/hasTracingEnabled.js","./node_modules/@sentry/core/build/esm/utils/isSentryRequestUrl.js","./node_modules/@sentry/core/build/esm/utils/parameterize.js","./node_modules/@sentry/core/build/esm/utils/parseSampleRate.js","./node_modules/@sentry/core/build/esm/utils/prepareEvent.js","./node_modules/@sentry/core/build/esm/utils/sdkMetadata.js","./node_modules/@sentry/core/build/esm/utils/spanOnScope.js","./node_modules/@sentry/core/build/esm/utils/spanUtils.js","./node_modules/@sentry/utils/build/esm/aggregate-errors.js","./node_modules/@sentry/utils/build/esm/baggage.js","./node_modules/@sentry/utils/build/esm/breadcrumb-log-level.js","./node_modules/@sentry/utils/build/esm/browser.js","./node_modules/@sentry/utils/build/esm/buildPolyfills/_nullishCoalesce.js","./node_modules/@sentry/utils/build/esm/buildPolyfills/_optionalChain.js","./node_modules/@sentry/utils/build/esm/clientreport.js","./node_modules/@sentry/utils/build/esm/debug-build.js","./node_modules/@sentry/utils/build/esm/dsn.js","./node_modules/@sentry/utils/build/esm/env.js","./node_modules/@sentry/utils/build/esm/envelope.js","./node_modules/@sentry/utils/build/esm/error.js","./node_modules/@sentry/utils/build/esm/instrument/console.js","./node_modules/@sentry/utils/build/esm/instrument/fetch.js","./node_modules/@sentry/utils/build/esm/instrument/globalError.js","./node_modules/@sentry/utils/build/esm/instrument/globalUnhandledRejection.js","./node_modules/@sentry/utils/build/esm/instrument/handlers.js","./node_modules/@sentry/utils/build/esm/is.js","./node_modules/@sentry/utils/build/esm/isBrowser.js","./node_modules/@sentry/utils/build/esm/logger.js","./node_modules/@sentry/utils/build/esm/memo.js","./node_modules/@sentry/utils/build/esm/misc.js","./node_modules/@sentry/utils/build/esm/node.js","./node_modules/@sentry/utils/build/esm/normalize.js","./node_modules/@sentry/utils/build/esm/object.js","./node_modules/@sentry/utils/build/esm/path.js","./node_modules/@sentry/utils/build/esm/promisebuffer.js","./node_modules/@sentry/utils/build/esm/propagationContext.js","./node_modules/@sentry/utils/build/esm/ratelimit.js","./node_modules/@sentry/utils/build/esm/severity.js","./node_modules/@sentry/utils/build/esm/stacktrace.js","./node_modules/@sentry/utils/build/esm/string.js","./node_modules/@sentry/utils/build/esm/supports.js","./node_modules/@sentry/utils/build/esm/syncpromise.js","./node_modules/@sentry/utils/build/esm/time.js","./node_modules/@sentry/utils/build/esm/tracing.js","./node_modules/@sentry/utils/build/esm/url.js","./node_modules/@sentry/utils/build/esm/vendor/supportsHistory.js","./node_modules/@sentry/utils/build/esm/version.js","./node_modules/@sentry/utils/build/esm/worldwide.js","./node_modules/ngx-cookie-service/fesm2022/ngx-cookie-service.mjs","./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js","./node_modules/tslib/tslib.es6.mjs"],"sourceRoot":"webpack:///","sourcesContent":["const FIELD_REGEX = /\\[(?:(\\d+)|['\"](.*?)['\"])\\]|((?:(?!\\[.*?\\]|\\.).)+)/g;\n/**\n * @hidden\n */\nexport function fieldList(field) {\n const fields = [];\n field.replace(FIELD_REGEX, function (_match, index, indexAccessor, fieldName) {\n fields.push(index !== undefined ? index : (indexAccessor || fieldName));\n });\n return fields;\n}\n","import { fieldList } from './field-list';\nconst getterCache = {};\n// tslint:disable-next-line:no-string-literal\ngetterCache['undefined'] = obj => obj;\n/**\n * @hidden\n */\nexport function getter(field) {\n if (getterCache[field]) {\n return getterCache[field];\n }\n const fields = fieldList(field);\n getterCache[field] = function (obj) {\n let result = obj;\n for (let idx = 0; idx < fields.length && result; idx++) {\n result = result[fields[idx]];\n }\n return result;\n };\n return getterCache[field];\n}\n","import { fieldList } from './field-list';\nconst setterCache = {};\n// tslint:disable-next-line:no-string-literal\nsetterCache['undefined'] = obj => obj;\nconst defaultValue = (nextField, options) => options && options.arrays && !isNaN(Number(nextField)) ? [] : {};\n/**\n * @hidden\n */\nexport function setter(field) {\n if (setterCache[field]) {\n return setterCache[field];\n }\n const fields = fieldList(field);\n setterCache[field] = (obj, value, options) => {\n let root = obj;\n const depth = fields.length - 1;\n for (let idx = 0; idx < depth && root; idx++) {\n root = root[fields[idx]] = root[fields[idx]] || defaultValue(fields[idx + 1], options);\n }\n root[fields[depth]] = value;\n };\n return setterCache[field];\n}\n","export { detectMobileOS, detectDesktopBrowser, browser, mobileOS, touch, msPointers, pointers, touchEnabled } from './support';\nexport { getter } from './accessors/getter';\nexport { setter } from './accessors/setter';\n","/* tslint:disable:object-literal-sort-keys max-line-length */\nimport { isWindowAvailable } from './util';\nconst agentRxs = {\n wp: /(Windows Phone(?: OS)?)\\s(\\d+)\\.(\\d+(\\.\\d+)?)/,\n fire: /(Silk)\\/(\\d+)\\.(\\d+(\\.\\d+)?)/,\n android: /(Android|Android.*(?:Opera|Firefox).*?\\/)\\s*(\\d+)(\\.(\\d+(\\.\\d+)?))?/,\n iphone: /(iPhone|iPod).*OS\\s+(\\d+)[\\._]([\\d\\._]+)/,\n ipad: /(iPad).*OS\\s+(\\d+)[\\._]([\\d_]+)/,\n meego: /(MeeGo).+NokiaBrowser\\/(\\d+)\\.([\\d\\._]+)/,\n webos: /(webOS)\\/(\\d+)\\.(\\d+(\\.\\d+)?)/,\n blackberry: /(BlackBerry|BB10).*?Version\\/(\\d+)\\.(\\d+(\\.\\d+)?)/,\n playbook: /(PlayBook).*?Tablet\\s*OS\\s*(\\d+)\\.(\\d+(\\.\\d+)?)/,\n windows: /(MSIE)\\s+(\\d+)\\.(\\d+(\\.\\d+)?)/,\n tizen: /(tizen).*?Version\\/(\\d+)\\.(\\d+(\\.\\d+)?)/i,\n sailfish: /(sailfish).*rv:(\\d+)\\.(\\d+(\\.\\d+)?).*firefox/i,\n ffos: /(Mobile).*rv:(\\d+)\\.(\\d+(\\.\\d+)?).*Firefox/\n};\nconst osRxs = {\n ios: /^i(phone|pad|pod)$/i,\n android: /^android|fire$/i,\n blackberry: /^blackberry|playbook/i,\n windows: /windows/,\n wp: /wp/,\n flat: /sailfish|ffos|tizen/i,\n meego: /meego/\n};\nconst desktopBrowserRxs = {\n edge: /(edge)[ \\/]([\\w.]+)/i,\n webkit: /(chrome)[ \\/]([\\w.]+)/i,\n safari: /(webkit)[ \\/]([\\w.]+)/i,\n opera: /(opera)(?:.*version|)[ \\/]([\\w.]+)/i,\n msie: /(msie\\s|trident.*? rv:)([\\w.]+)/i,\n mozilla: /(mozilla)(?:.*? rv:([\\w.]+)|)/i\n};\nconst mobileBrowserRxs = {\n omini: /Opera\\sMini/i,\n omobile: /Opera\\sMobi/i,\n firefox: /Firefox|Fennec/i,\n mobilesafari: /version\\/.*safari/i,\n ie: /MSIE|Windows\\sPhone/i,\n chrome: /chrome|crios/i,\n webkit: /webkit/i\n};\nconst testRx = (agent, rxs, dflt) => {\n for (let rx in rxs) {\n if (rxs.hasOwnProperty(rx) && rxs[rx].test(agent)) {\n return rx;\n }\n }\n return dflt !== undefined ? dflt : agent;\n};\n/**\n * A function that detects the mobile browser based on the given UserAgent.\n *\n * @param ua - The user agent string.\n * @returns - A browser info object containing the browser type and version.\n *\n * @example\n * ```ts-no-run\n * const userAgent = 'Mozilla/5.0 (Linux; Android 8.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Focus/1.3 Chrome/61.0.3163.81 Mobile Safari/537.36';\n * detectMobileOS(userAgent); // { android: true };\n * ```\n */\nexport const detectMobileOS = (ua) => {\n let minorVersion;\n let match = [];\n for (let agent in agentRxs) {\n if (agentRxs.hasOwnProperty(agent)) {\n match = ua.match(agentRxs[agent]);\n if (!match) {\n continue;\n }\n if (agent === 'windows' && 'plugins' in window.navigator) {\n return null;\n } // Break if not Metro/Mobile Windows\n const os = {};\n os.device = agent;\n os.browser = testRx(ua, mobileBrowserRxs, 'default');\n os.name = testRx(agent, osRxs);\n os[os.name] = true;\n os.majorVersion = match[2];\n os.minorVersion = match[3] ? match[3].replace('_', '.') : '.0';\n minorVersion = os.minorVersion.replace('.', '').substr(0, 2);\n os.flatVersion = os.majorVersion + minorVersion +\n (new Array(3 - (minorVersion.length < 3 ? minorVersion.length : 2)).join('0'));\n os.cordova = typeof window.PhoneGap !== undefined\n || typeof window.cordova !== undefined; // Use file protocol to detect appModes.\n os.appMode = window.navigator.standalone\n || (/file|local|wmapp/).test(window.location.protocol)\n || os.cordova; // Use file protocol to detect appModes.\n return os;\n }\n }\n return null;\n};\n/**\n * A function that detects the desktop browser based on the given UserAgent.\n *\n * @param ua - The user agent string.\n * @returns - A browser info object containing the browser type and version.\n *\n * @example\n * ```ts-no-run\n * const userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19';\n * detectDesktopBrowser(userAgent); // { chrome: true, webkit: true };\n * ```\n */\nexport const detectDesktopBrowser = (ua) => {\n let browserInfo = null;\n let match = [];\n for (let agent in desktopBrowserRxs) {\n if (desktopBrowserRxs.hasOwnProperty(agent)) {\n match = ua.match(desktopBrowserRxs[agent]);\n if (match) {\n browserInfo = {};\n browserInfo[agent] = true;\n browserInfo[match[1].toLowerCase().split(' ')[0].split('/')[0]] = true;\n browserInfo.version = parseInt(document.documentMode || match[2], 10);\n break;\n }\n }\n }\n return browserInfo;\n};\nconst userAgent = isWindowAvailable() && window.navigator ? window.navigator.userAgent : null;\n/**\n * A constant holding the desktop browser info. The variable persists the result of the detectDesktopBrowser(window.navigator.userAgent) call.\n * If no desktop browser is detected, the constant will be `null`.\n */\nexport const browser = userAgent ? detectDesktopBrowser(userAgent) : null;\n/**\n * A constant holding the mobile OS info. The variable persists the result of the detectMobileOS(window.navigator.userAgent) call.\n * If no mobile OS is detected, the constant will be `null`.\n */\nexport const mobileOS = userAgent ? detectMobileOS(userAgent) : null;\n/**\n * A constant reporting the browser `touch` events support.\n */\nexport const touch = isWindowAvailable() && 'ontouchstart' in window;\n/**\n * @hidden\n * A constant reporting the browser `msPointers` events support.\n */\nexport const msPointers = browser && !browser.chrome && window.MSPointerEvent;\n/**\n * A constant reporting the browser `pointers` events support.\n */\nexport const pointers = browser && !browser.chrome && window.PointerEvent;\n/**\n * A constant reporting whether the browser is touch enabled.\n */\nexport const touchEnabled = mobileOS && (touch || msPointers || pointers);\n","/**\n * @hidden\n */\nexport const isWindowAvailable = () => {\n return typeof window !== 'undefined';\n};\n","const proxy = (a, b) => (e) => b(a(e));\n\nconst bind = (el, event, callback) =>\n el.addEventListener && el.addEventListener(event, callback);\n\nconst unbind = (el, event, callback) =>\n el && el.removeEventListener && el.removeEventListener(event, callback);\n\nconst noop = () => { /* empty */ };\n\nconst preventDefault = e => e.preventDefault();\n\nconst touchRegExp = /touch/;\n\n// 300ms is the usual mouse interval;\n// // However, an underpowered mobile device under a heavy load may queue mouse events for a longer period.\nconst IGNORE_MOUSE_TIMEOUT = 2000;\n\nfunction normalizeEvent(e) {\n if (e.type.match(touchRegExp)) {\n return {\n pageX: e.changedTouches[0].pageX,\n pageY: e.changedTouches[0].pageY,\n clientX: e.changedTouches[0].clientX,\n clientY: e.changedTouches[0].clientY,\n type: e.type,\n originalEvent: e,\n isTouch: true\n };\n }\n\n return {\n pageX: e.pageX,\n pageY: e.pageY,\n clientX: e.clientX,\n clientY: e.clientY,\n offsetX: e.offsetX,\n offsetY: e.offsetY,\n type: e.type,\n ctrlKey: e.ctrlKey,\n shiftKey: e.shiftKey,\n altKey: e.altKey,\n originalEvent: e\n };\n}\n\nexport class Draggable {\n static supportPointerEvent() {\n return (typeof window !== 'undefined') && window.PointerEvent;\n }\n\n get document() {\n return this._element\n ? this._element.ownerDocument\n : document;\n }\n\n constructor({ press = noop, drag = noop, release = noop, mouseOnly = false }) {\n this._pressHandler = proxy(normalizeEvent, press);\n this._dragHandler = proxy(normalizeEvent, drag);\n this._releaseHandler = proxy(normalizeEvent, release);\n this._ignoreMouse = false;\n this._mouseOnly = mouseOnly;\n\n this._touchstart = (e) => {\n if (e.touches.length === 1) {\n this._pressHandler(e);\n }\n };\n\n this._touchmove = (e) => {\n if (e.touches.length === 1) {\n this._dragHandler(e);\n }\n };\n\n this._touchend = (e) => {\n // the last finger has been lifted, and the user is not doing gesture.\n // there might be a better way to handle this.\n if (e.touches.length === 0 && e.changedTouches.length === 1) {\n this._releaseHandler(e);\n this._ignoreMouse = true;\n setTimeout(this._restoreMouse, IGNORE_MOUSE_TIMEOUT);\n }\n };\n\n this._restoreMouse = () => {\n this._ignoreMouse = false;\n };\n\n this._mousedown = (e) => {\n const { which } = e;\n\n if ((which && which > 1) || this._ignoreMouse) {\n return;\n }\n\n bind(this.document, \"mousemove\", this._mousemove);\n bind(this.document, \"mouseup\", this._mouseup);\n this._pressHandler(e);\n };\n\n this._mousemove = (e) => {\n this._dragHandler(e);\n };\n\n this._mouseup = (e) => {\n unbind(this.document, \"mousemove\", this._mousemove);\n unbind(this.document, \"mouseup\", this._mouseup);\n this._releaseHandler(e);\n };\n\n this._pointerdown = (e) => {\n if (e.isPrimary && e.button === 0) {\n bind(this.document, \"pointermove\", this._pointermove);\n bind(this.document, \"pointerup\", this._pointerup);\n bind(this.document, \"pointercancel\", this._pointerup);\n bind(this.document, \"contextmenu\", preventDefault);\n\n this._pressHandler(e);\n }\n };\n\n this._pointermove = (e) => {\n if (e.isPrimary) {\n this._dragHandler(e);\n }\n };\n\n this._pointerup = (e) => {\n if (e.isPrimary) {\n unbind(this.document, \"pointermove\", this._pointermove);\n unbind(this.document, \"pointerup\", this._pointerup);\n unbind(this.document, \"pointercancel\", this._pointerup);\n unbind(this.document, \"contextmenu\", preventDefault);\n\n this._releaseHandler(e);\n }\n };\n }\n\n cancelDrag() {\n unbind(this.document, \"pointermove\", this._pointermove);\n unbind(this.document, \"pointerup\", this._pointerup);\n unbind(this.document, \"pointercancel\", this._pointerup);\n }\n\n bindTo(element) {\n if (element === this._element) {\n return;\n }\n\n if (this._element) {\n this._unbindFromCurrent();\n }\n\n this._element = element;\n this._bindToCurrent();\n }\n\n _bindToCurrent() {\n const element = this._element;\n\n if (this._usePointers()) {\n bind(element, \"pointerdown\", this._pointerdown);\n return;\n }\n\n bind(element, \"mousedown\", this._mousedown);\n\n if (!this._mouseOnly) {\n bind(element, \"touchstart\", this._touchstart);\n bind(element, \"touchmove\", this._touchmove);\n bind(element, \"touchend\", this._touchend);\n }\n }\n\n _unbindFromCurrent() {\n const element = this._element;\n\n if (this._usePointers()) {\n unbind(element, \"pointerdown\", this._pointerdown);\n unbind(this.document, \"pointermove\", this._pointermove);\n unbind(this.document, \"pointerup\", this._pointerup);\n unbind(this.document, \"contextmenu\", preventDefault);\n unbind(this.document, \"pointercancel\", this._pointerup);\n return;\n }\n\n unbind(element, \"mousedown\", this._mousedown);\n\n if (!this._mouseOnly) {\n unbind(element, \"touchstart\", this._touchstart);\n unbind(element, \"touchmove\", this._touchmove);\n unbind(element, \"touchend\", this._touchend);\n }\n }\n\n _usePointers() {\n return !this._mouseOnly && Draggable.supportPointerEvent();\n }\n\n update({ press = noop, drag = noop, release = noop, mouseOnly = false }) {\n this._pressHandler = proxy(normalizeEvent, press);\n this._dragHandler = proxy(normalizeEvent, drag);\n this._releaseHandler = proxy(normalizeEvent, release);\n this._mouseOnly = mouseOnly;\n }\n\n destroy() {\n this._unbindFromCurrent();\n this._element = null;\n }\n}\n\n// Re-export as \"default\" field to address a bug\n// where the ES Module is imported by CommonJS code.\n//\n// See https://github.com/telerik/kendo-angular/issues/1314\nDraggable.default = Draggable;\n\n// Rollup won't output exports['default'] otherwise\nexport default Draggable;\n\n","import PathNode from './path-node';\nimport renderPath from './utils/render-path';\n\nclass ArcNode extends PathNode {\n renderPoints(ctx) {\n const path = this.srcElement.toPath();\n renderPath(ctx, path);\n }\n}\n\nexport default ArcNode;\n","import PathNode from './path-node';\n\nclass CircleNode extends PathNode {\n renderPoints(ctx) {\n const { center, radius } = this.srcElement.geometry();\n\n ctx.arc(center.x, center.y, radius, 0, Math.PI * 2);\n }\n}\n\nexport default CircleNode;\n","import Surface from './surface';\nimport { transform } from '../geometry';\nimport Group from '../shapes/group';\n\nexport default function exportImage(group, options) {\n const defaults = {\n width: \"800px\", height: \"600px\",\n cors: \"Anonymous\"\n };\n\n let exportRoot = group;\n const bbox = group.clippedBBox();\n\n\n if (bbox) {\n const origin = bbox.getOrigin();\n exportRoot = new Group();\n exportRoot.transform(transform().translate(-origin.x, -origin.y));\n exportRoot.children.push(group);\n\n const size = bbox.getSize();\n defaults.width = size.width + \"px\";\n defaults.height = size.height + \"px\";\n }\n\n const surfaceOptions = Object.assign(defaults, options);\n\n const container = document.createElement(\"div\");\n const style = container.style;\n\n style.display = \"none\";\n style.width = surfaceOptions.width;\n style.height = surfaceOptions.height;\n document.body.appendChild(container);\n\n const surface = new Surface(container, surfaceOptions);\n surface.suspendTracking();\n surface.draw(exportRoot);\n\n const promise = surface.image();\n const destroy = () => {\n surface.destroy();\n document.body.removeChild(container);\n };\n promise.then(destroy, destroy);\n\n return promise;\n}","import Node from './node';\nimport traversable from '../mixins/traversable';\n\n\nclass GroupNode extends traversable(Node, \"childNodes\") {\n renderTo(ctx) {\n if (!this.visible()) {\n return;\n }\n\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n this.setOpacity(ctx);\n\n const childNodes = this.childNodes;\n for (let i = 0; i < childNodes.length; i++) {\n let child = childNodes[i];\n if (child.visible()) {\n child.renderTo(ctx);\n }\n }\n\n ctx.restore();\n }\n}\n\nexport default GroupNode;\n","import PathNode from './path-node';\nimport { createPromise } from '../util';\n\nclass ImageNode extends PathNode {\n constructor(srcElement, cors) {\n super(srcElement);\n\n this.onLoad = this.onLoad.bind(this);\n this.onError = this.onError.bind(this);\n\n this.loading = createPromise();\n\n const img = this.img = new Image();\n const src = srcElement.src();\n\n if (cors && !(/^data:/i.test(src))) {\n img.crossOrigin = cors;\n }\n\n if (src) {\n img.src = src;\n }\n\n if (img.complete) {\n this.onLoad();\n } else {\n img.onload = this.onLoad;\n img.onerror = this.onError;\n }\n }\n\n renderTo(ctx) {\n if (this.loading.state() === \"resolved\") {\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n\n this.drawImage(ctx);\n\n ctx.restore();\n }\n }\n\n optionsChange(e) {\n if (e.field === \"src\") {\n this.loading = createPromise();\n this.img.src = this.srcElement.src();\n } else {\n super.optionsChange(e);\n }\n }\n\n onLoad() {\n this.loading.resolve();\n this.invalidate();\n }\n\n onError() {\n this.loading.reject(new Error(\n \"Unable to load image '\" + this.img.src +\n \"'. Check for connectivity and verify CORS headers.\"\n ));\n }\n\n drawImage(ctx) {\n const rect = this.srcElement.rect();\n const topLeft = rect.topLeft();\n\n ctx.drawImage(\n this.img, topLeft.x, topLeft.y, rect.width(), rect.height()\n );\n }\n}\n\nexport default ImageNode;\n","import PathNode from './path-node';\nimport renderPath from './utils/render-path';\n\nclass MultiPathNode extends PathNode {\n renderPoints(ctx) {\n const paths = this.srcElement.paths;\n for (let i = 0; i < paths.length; i++) {\n renderPath(ctx, paths[i]);\n }\n }\n}\n\nexport default MultiPathNode;\n","const NODE_MAP = {};\n\nexport default NODE_MAP;","import BaseNode from '../core/base-node';\nimport NODE_MAP from './node-map';\nimport { defined } from '../util';\n\nclass Node extends BaseNode {\n constructor(srcElement) {\n super(srcElement);\n if (srcElement) {\n this.initClip();\n }\n }\n\n initClip() {\n const clip = this.srcElement.clip();\n if (clip) {\n this.clip = clip;\n clip.addObserver(this);\n }\n }\n\n clear() {\n if (this.srcElement) {\n this.srcElement.removeObserver(this);\n }\n\n this.clearClip();\n\n super.clear();\n }\n\n clearClip() {\n if (this.clip) {\n this.clip.removeObserver(this);\n delete this.clip;\n }\n }\n\n setClip(ctx) {\n if (this.clip) {\n ctx.beginPath();\n\n const clipNode = new NODE_MAP[this.clip.nodeType](this.clip);\n clipNode.renderPoints(ctx, this.clip);\n\n ctx.clip(\"evenodd\");\n }\n }\n\n optionsChange(e) {\n if (e.field === \"clip\") {\n this.clearClip();\n this.initClip();\n }\n\n super.optionsChange(e);\n }\n\n setTransform(ctx) {\n if (this.srcElement) {\n const transform = this.srcElement.transform();\n if (transform) {\n ctx.transform.apply(ctx, transform.matrix().toArray(6));\n }\n }\n }\n\n loadElements(elements, pos, cors) {\n for (let i = 0; i < elements.length; i++) {\n let srcElement = elements[i];\n let children = srcElement.children;\n\n let childNode = new NODE_MAP[srcElement.nodeType](srcElement, cors);\n\n if (children && children.length > 0) {\n childNode.load(children, pos, cors);\n }\n\n if (defined(pos)) {\n this.insertAt(childNode, pos);\n } else {\n this.append(childNode);\n }\n }\n }\n\n load(elements, pos, cors) {\n this.loadElements(elements, pos, cors);\n\n this.invalidate();\n }\n\n setOpacity(ctx) {\n if (this.srcElement) {\n const opacity = this.srcElement.opacity();\n if (defined(opacity)) {\n this.globalAlpha(ctx, opacity);\n }\n }\n }\n\n globalAlpha(ctx, value) {\n let opactity = value;\n if (opactity && ctx.globalAlpha) {\n opactity *= ctx.globalAlpha;\n }\n ctx.globalAlpha = opactity;\n }\n\n visible() {\n const src = this.srcElement;\n return !src || (src && src.options.visible !== false);\n }\n}\n\nexport default Node;","import Node from './node';\nimport { parseColor } from '../common';\nimport { isTransparent, valueOrDefault } from '../util';\nimport LinearGradient from '../gradients/linear-gradient';\nimport RadialGradient from '../gradients/radial-gradient';\nimport { DASH_ARRAYS, SOLID, BUTT } from '../core/constants';\nimport renderPath from './utils/render-path';\n\nfunction addGradientStops(gradient, stops) {\n for (let idx = 0; idx < stops.length; idx++) {\n let stop = stops[idx];\n let color = parseColor(stop.color());\n\n color.a *= stop.opacity();\n\n gradient.addColorStop(stop.offset(), color.toCssRgba());\n }\n}\n\nclass PathNode extends Node {\n\n renderTo(ctx) {\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n this.setOpacity(ctx);\n\n ctx.beginPath();\n\n this.renderPoints(ctx, this.srcElement);\n\n this.setLineDash(ctx);\n this.setLineCap(ctx);\n this.setLineJoin(ctx);\n\n this.setFill(ctx);\n this.setStroke(ctx);\n\n ctx.restore();\n }\n\n setFill(ctx) {\n const fill = this.srcElement.options.fill;\n let hasFill = false;\n\n if (fill) {\n if (fill.nodeType === \"Gradient\") {\n this.setGradientFill(ctx, fill);\n hasFill = true;\n } else if (!isTransparent(fill.color)) {\n ctx.fillStyle = fill.color;\n\n ctx.save();\n this.globalAlpha(ctx, fill.opacity);\n ctx.fill();\n ctx.restore();\n\n hasFill = true;\n }\n }\n\n return hasFill;\n }\n\n setGradientFill(ctx, fill) {\n const bbox = this.srcElement.rawBBox();\n let gradient;\n\n if (fill instanceof LinearGradient) {\n let start = fill.start();\n let end = fill.end();\n gradient = ctx.createLinearGradient(start.x, start.y, end.x, end.y);\n } else if (fill instanceof RadialGradient) {\n let center = fill.center();\n gradient = ctx.createRadialGradient(center.x, center.y, 0, center.x, center.y, fill.radius());\n }\n\n addGradientStops(gradient, fill.stops);\n\n ctx.save();\n\n if (!fill.userSpace()) {\n ctx.transform(bbox.width(), 0, 0, bbox.height(), bbox.origin.x, bbox.origin.y);\n }\n ctx.fillStyle = gradient;\n ctx.fill();\n\n ctx.restore();\n }\n\n setStroke(ctx) {\n const stroke = this.srcElement.options.stroke;\n if (stroke && !isTransparent(stroke.color) && stroke.width > 0) {\n ctx.strokeStyle = stroke.color;\n ctx.lineWidth = valueOrDefault(stroke.width, 1);\n ctx.lineJoin = valueOrDefault(stroke.lineJoin, ctx.lineJoin);\n\n ctx.save();\n this.globalAlpha(ctx, stroke.opacity);\n ctx.stroke();\n ctx.restore();\n\n return true;\n }\n }\n\n dashType() {\n const stroke = this.srcElement.options.stroke;\n if (stroke && stroke.dashType) {\n return stroke.dashType.toLowerCase();\n }\n }\n\n setLineDash(ctx) {\n const dashType = this.dashType();\n if (dashType && dashType !== SOLID) {\n const dashArray = DASH_ARRAYS[dashType];\n if (ctx.setLineDash) {\n ctx.setLineDash(dashArray);\n } else {\n ctx.mozDash = dashArray;\n ctx.webkitLineDash = dashArray;\n }\n }\n }\n\n setLineCap(ctx) {\n const dashType = this.dashType();\n const stroke = this.srcElement.options.stroke;\n if (dashType && dashType !== SOLID) {\n ctx.lineCap = BUTT;\n } else if (stroke && stroke.lineCap) {\n ctx.lineCap = stroke.lineCap;\n }\n }\n\n setLineJoin(ctx) {\n const stroke = this.srcElement.options.stroke;\n if (stroke && stroke.lineJoin) {\n ctx.lineJoin = stroke.lineJoin;\n }\n }\n\n renderPoints(ctx, path) {\n renderPath(ctx, path);\n }\n}\n\nexport default PathNode;\n","import { Path } from '../shapes/path';\nimport PathNode from './path-node';\n\nclass RectNode extends PathNode {\n renderPoints(ctx) {\n const geometry = this.srcElement.geometry();\n const [ rx, ry ] = geometry.cornerRadius;\n\n if (rx === 0 && ry === 0) {\n const { origin, size } = geometry;\n ctx.rect(origin.x, origin.y, size.width, size.height);\n } else {\n super.renderPoints(ctx, Path.fromRect(geometry));\n }\n }\n}\n\nexport default RectNode;\n","import GroupNode from './group-node';\nimport traversable from '../mixins/traversable';\nimport { animationFrame, throttle } from '../common';\n\n\nconst FRAME_DELAY = 1000 / 60;\n\nclass RootNode extends traversable(GroupNode, \"childNodes\") {\n constructor(canvas, size) {\n super();\n\n this.canvas = canvas;\n this.size = size;\n this.ctx = canvas.getContext(\"2d\");\n\n const invalidateHandler = this._invalidate.bind(this);\n this.invalidate = throttle(() => {\n animationFrame(invalidateHandler);\n }, FRAME_DELAY);\n }\n\n destroy() {\n super.destroy();\n this.canvas = null;\n this.ctx = null;\n }\n\n load(elements, pos, cors) {\n this.loadElements(elements, pos, cors);\n this._invalidate();\n }\n\n _rescale(scale) {\n const { canvas, size } = this;\n canvas.width = size.width * scale;\n canvas.height = size.height * scale;\n this.ctx.scale(scale, scale);\n }\n\n _devicePixelRatio() {\n if (typeof window.devicePixelRatio === 'number') {\n return window.devicePixelRatio;\n }\n\n return 1;\n }\n\n _invalidate(options) {\n if (!this.ctx) {\n return;\n }\n\n const fixedScale = options && options.fixedScale;\n const scale = fixedScale ? 1 : this._devicePixelRatio();\n this._rescale(scale);\n\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n this.renderTo(this.ctx);\n }\n}\n\nexport default RootNode;\n","import { defined } from '../util';\n\nclass SurfaceCursor {\n\n constructor(surface) {\n surface.bind(\"mouseenter\", this._mouseenter.bind(this));\n surface.bind(\"mouseleave\", this._mouseleave.bind(this));\n\n this.element = surface.element;\n }\n\n clear() {\n this._resetCursor();\n }\n\n destroy() {\n this._resetCursor();\n delete this.element;\n }\n\n _mouseenter(e) {\n const cursor = this._shapeCursor(e);\n\n if (!cursor) {\n this._resetCursor();\n } else {\n if (!this._current) {\n this._defaultCursor = this._getCursor();\n }\n\n this._setCursor(cursor);\n }\n }\n\n _mouseleave() {\n this._resetCursor();\n }\n\n _shapeCursor(e) {\n let shape = e.element;\n\n while (shape && !defined(shape.options.cursor)) {\n shape = shape.parent;\n }\n\n if (shape) {\n return shape.options.cursor;\n }\n }\n\n _getCursor() {\n if (this.element) {\n return this.element.style.cursor;\n }\n }\n\n _setCursor(cursor) {\n if (this.element) {\n this.element.style.cursor = cursor;\n this._current = cursor;\n }\n }\n\n _resetCursor() {\n if (this._current) {\n this._setCursor(this._defaultCursor || \"\");\n delete this._current;\n }\n }\n}\n\nexport default SurfaceCursor;\n\n","import BaseSurface from '../core/surface';\nimport { createPromise, promiseAll, bindEvents, elementSize, unbindEvents } from '../util';\nimport RootNode from './root-node';\nimport ShapesQuadTree from '../search/shapes-quad-tree';\nimport SurfaceCursor from './surface-cursor';\n\nimport ArcNode from './arc-node';\nimport CircleNode from './circle-node';\nimport GroupNode from './group-node';\nimport ImageNode from './image-node';\nimport MultiPathNode from './multi-path-node';\nimport PathNode from './path-node';\nimport RectNode from './rect-node';\nimport TextNode from './text-node';\nimport NODE_MAP from './node-map';\n\nNODE_MAP.Arc = ArcNode;\nNODE_MAP.Circle = CircleNode;\nNODE_MAP.Group = GroupNode;\nNODE_MAP.Image = ImageNode;\nNODE_MAP.MultiPath = MultiPathNode;\nNODE_MAP.Path = PathNode;\nNODE_MAP.Rect = RectNode;\nNODE_MAP.Text = TextNode;\n\n\nclass Surface extends BaseSurface {\n get type() {\n return \"canvas\";\n }\n\n constructor(element, options) {\n super(element, options);\n\n this.element.innerHTML = this._template(this);\n\n const canvas = this.element.firstElementChild;\n canvas.style.width = '100%';\n canvas.style.height = '100%';\n\n const size = elementSize(element);\n\n canvas.width = size.width;\n canvas.height = size.height;\n\n this._rootElement = canvas;\n\n this._root = new RootNode(canvas, size);\n\n this._mouseTrackHandler = this._trackMouse.bind(this);\n\n bindEvents(this.element, {\n click: this._mouseTrackHandler,\n mousemove: this._mouseTrackHandler\n });\n }\n\n destroy() {\n super.destroy();\n\n if (this._root) {\n this._root.destroy();\n this._root = null;\n }\n\n if (this._searchTree) {\n this._searchTree.clear();\n delete this._searchTree;\n }\n\n if (this._cursor) {\n this._cursor.destroy();\n delete this._cursor;\n }\n\n unbindEvents(this.element, {\n click: this._mouseTrackHandler,\n mousemove: this._mouseTrackHandler\n });\n }\n\n draw(element) {\n super.draw(element);\n this._root.load([ element ], undefined, this.options.cors);\n\n if (this._searchTree) {\n this._searchTree.add([ element ]);\n }\n }\n\n clear() {\n super.clear();\n this._root.clear();\n\n if (this._searchTree) {\n this._searchTree.clear();\n }\n\n if (this._cursor) {\n this._cursor.clear();\n }\n }\n\n eventTarget(e) {\n if (this._searchTree) {\n const point = this._surfacePoint(e);\n const shape = this._searchTree.pointShape(point);\n return shape;\n }\n }\n\n image() {\n const { _root: root, _rootElement: rootElement } = this;\n const loadingStates = [];\n\n root.traverse((childNode) => {\n if (childNode.loading) {\n loadingStates.push(childNode.loading);\n }\n });\n\n const promise = createPromise();\n const resolveDataURL = () => {\n root._invalidate({ fixedScale: true });\n\n try {\n const data = rootElement.toDataURL();\n promise.resolve(data);\n } catch (e) {\n promise.reject(e);\n }\n };\n\n promiseAll(loadingStates).then(resolveDataURL, resolveDataURL);\n\n return promise;\n }\n\n suspendTracking() {\n super.suspendTracking();\n if (this._searchTree) {\n this._searchTree.clear();\n delete this._searchTree;\n }\n }\n\n resumeTracking() {\n super.resumeTracking();\n if (!this._searchTree) {\n this._searchTree = new ShapesQuadTree();\n\n const childNodes = this._root.childNodes;\n const rootElements = [];\n for (let idx = 0; idx < childNodes.length; idx++) {\n rootElements.push(childNodes[idx].srcElement);\n }\n this._searchTree.add(rootElements);\n }\n }\n\n _resize() {\n this._rootElement.width = this._size.width;\n this._rootElement.height = this._size.height;\n\n this._root.size = this._size;\n this._root.invalidate();\n }\n\n _template() {\n return \"\";\n }\n\n _enableTracking() {\n this._searchTree = new ShapesQuadTree();\n this._cursor = new SurfaceCursor(this);\n\n super._enableTracking();\n }\n\n _trackMouse(e) {\n if (this._suspendedTracking) {\n return;\n }\n\n const shape = this.eventTarget(e);\n\n if (e.type !== \"click\") {\n const currentShape = this._currentShape;\n if (currentShape && currentShape !== shape) {\n this.trigger(\"mouseleave\", {\n element: currentShape,\n originalEvent: e,\n type: \"mouseleave\"\n });\n }\n\n if (shape && currentShape !== shape) {\n this.trigger(\"mouseenter\", {\n element: shape,\n originalEvent: e,\n type: \"mouseenter\"\n });\n }\n\n this.trigger(\"mousemove\", {\n element: shape,\n originalEvent: e,\n type: \"mousemove\"\n });\n\n this._currentShape = shape;\n } else if (shape) {\n this.trigger(\"click\", {\n element: shape,\n originalEvent: e,\n type: \"click\"\n });\n }\n }\n}\n\nexport default Surface;\n","import PathNode from './path-node';\n\nclass TextNode extends PathNode {\n renderTo(ctx) {\n const text = this.srcElement;\n const pos = text.position();\n const size = text.measure();\n\n ctx.save();\n\n this.setTransform(ctx);\n this.setClip(ctx);\n this.setOpacity(ctx);\n\n ctx.beginPath();\n\n ctx.font = text.options.font;\n ctx.textAlign = 'left';\n\n if (text.options.paintOrder === 'stroke') {\n this.stroke(ctx, text, pos, size);\n this.fill(ctx, text, pos, size);\n } else {\n this.fill(ctx, text, pos, size);\n this.stroke(ctx, text, pos, size);\n }\n\n ctx.restore();\n }\n\n stroke(ctx, text, pos, size) {\n if (this.setStroke(ctx)) {\n this.setLineDash(ctx);\n ctx.strokeText(text.content(), pos.x, pos.y + size.baseline);\n }\n }\n\n fill(ctx, text, pos, size) {\n if (this.setFill(ctx)) {\n ctx.fillText(text.content(), pos.x, pos.y + size.baseline);\n }\n }\n}\n\n\nexport default TextNode;\n","\nexport default function renderPath(ctx, path) {\n const segments = path.segments;\n\n if (segments.length === 0) {\n return;\n }\n\n let segment = segments[0];\n let anchor = segment.anchor();\n ctx.moveTo(anchor.x, anchor.y);\n\n for (let i = 1; i < segments.length; i++) {\n segment = segments[i];\n anchor = segment.anchor();\n\n let prevSeg = segments[i - 1];\n let prevOut = prevSeg.controlOut();\n let controlIn = segment.controlIn();\n\n if (prevOut && controlIn) {\n ctx.bezierCurveTo(prevOut.x, prevOut.y,\n controlIn.x, controlIn.y,\n anchor.x, anchor.y);\n } else {\n ctx.lineTo(anchor.x, anchor.y);\n }\n }\n\n if (path.options.closed) {\n ctx.closePath();\n }\n}\n","let animationFrameProxy = (callback) => {\n const wnd = typeof window !== \"undefined\" ? window : {};\n const animationFrame = wnd.requestAnimationFrame ||\n wnd.webkitRequestAnimationFrame ||\n wnd.mozRequestAnimationFrame ||\n wnd.oRequestAnimationFrame ||\n wnd.msRequestAnimationFrame ||\n function(callback) { setTimeout(callback, 1000 / 60); };\n\n animationFrameProxy = callback => animationFrame.call(wnd, callback);\n animationFrameProxy(callback);\n};\n\nexport default animationFrameProxy;\n","export default class Class {\n // Empty base class needed for compatibility with Kendo UI for jQuery\n}\n","import Class from '../class';\nimport namedColors from './named-colors';\nimport { Bytes, RGB, HSV, HSL } from './parse-color';\n\nconst DARK_TRESHOLD = 180;\n\nclass Color extends Class {\n constructor(value) {\n super();\n\n if (arguments.length === 1) {\n const formats = Color.formats;\n const resolvedColor = this.resolveColor(value);\n\n for (let idx = 0; idx < formats.length; idx++) {\n const formatRegex = formats[idx].re;\n const processor = formats[idx].process;\n const parts = formatRegex.exec(resolvedColor);\n\n if (parts) {\n const channels = processor(parts);\n this.r = channels[0];\n this.g = channels[1];\n this.b = channels[2];\n }\n }\n } else {\n this.r = arguments[0];\n this.g = arguments[1];\n this.b = arguments[2];\n }\n\n this.r = this.normalizeByte(this.r);\n this.g = this.normalizeByte(this.g);\n this.b = this.normalizeByte(this.b);\n }\n\n toHex() {\n const pad = this.padDigit;\n const r = this.r.toString(16);\n const g = this.g.toString(16);\n const b = this.b.toString(16);\n\n return \"#\" + pad(r) + pad(g) + pad(b);\n }\n\n resolveColor(value) {\n let color = value || \"black\";\n\n if (color.charAt(0) === \"#\") {\n color = color.substr(1, 6);\n }\n\n color = color.replace(/ /g, \"\");\n color = color.toLowerCase();\n color = Color.namedColors[color] || color;\n\n return color;\n }\n\n normalizeByte(value) {\n if (value < 0 || isNaN(value)) {\n return 0;\n }\n\n return value > 255 ? 255 : value;\n }\n\n padDigit(value) {\n return (value.length === 1) ? \"0\" + value : value;\n }\n\n brightness(value) {\n const round = Math.round;\n\n this.r = round(this.normalizeByte(this.r * value));\n this.g = round(this.normalizeByte(this.g * value));\n this.b = round(this.normalizeByte(this.b * value));\n\n return this;\n }\n\n percBrightness() {\n return Math.sqrt(0.241 * this.r * this.r + 0.691 * this.g * this.g + 0.068 * this.b * this.b);\n }\n\n isDark() {\n return this.percBrightness() < DARK_TRESHOLD;\n }\n\n static fromBytes(r, g, b, a) {\n return new Bytes(r, g, b, a != null ? a : 1);\n }\n\n static fromRGB(r, g, b, a) {\n return new RGB(r, g, b, a != null ? a : 1);\n }\n\n static fromHSV(h, s, v, a) {\n return new HSV(h, s, v, a != null ? a : 1);\n }\n\n static fromHSL(h, s, l, a) {\n return new HSL(h, s, l, a != null ? a : 1);\n }\n}\n\nColor.formats = [ {\n re: /^rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\)$/,\n process: function(parts) {\n return [\n parseInt(parts[1], 10), parseInt(parts[2], 10), parseInt(parts[3], 10)\n ];\n }\n}, {\n re: /^(\\w{2})(\\w{2})(\\w{2})$/,\n process: function(parts) {\n return [\n parseInt(parts[1], 16), parseInt(parts[2], 16), parseInt(parts[3], 16)\n ];\n }\n}, {\n re: /^(\\w{1})(\\w{1})(\\w{1})$/,\n process: function(parts) {\n return [\n parseInt(parts[1] + parts[1], 16),\n parseInt(parts[2] + parts[2], 16),\n parseInt(parts[3] + parts[3], 16)\n ];\n }\n} ];\n\nColor.namedColors = namedColors;\n\nexport default Color;","const namedColors = {\n aliceblue: \"f0f8ff\", antiquewhite: \"faebd7\", aqua: \"00ffff\",\n aquamarine: \"7fffd4\", azure: \"f0ffff\", beige: \"f5f5dc\",\n bisque: \"ffe4c4\", black: \"000000\", blanchedalmond: \"ffebcd\",\n blue: \"0000ff\", blueviolet: \"8a2be2\", brown: \"a52a2a\",\n burlywood: \"deb887\", cadetblue: \"5f9ea0\", chartreuse: \"7fff00\",\n chocolate: \"d2691e\", coral: \"ff7f50\", cornflowerblue: \"6495ed\",\n cornsilk: \"fff8dc\", crimson: \"dc143c\", cyan: \"00ffff\",\n darkblue: \"00008b\", darkcyan: \"008b8b\", darkgoldenrod: \"b8860b\",\n darkgray: \"a9a9a9\", darkgrey: \"a9a9a9\", darkgreen: \"006400\",\n darkkhaki: \"bdb76b\", darkmagenta: \"8b008b\", darkolivegreen: \"556b2f\",\n darkorange: \"ff8c00\", darkorchid: \"9932cc\", darkred: \"8b0000\",\n darksalmon: \"e9967a\", darkseagreen: \"8fbc8f\", darkslateblue: \"483d8b\",\n darkslategray: \"2f4f4f\", darkslategrey: \"2f4f4f\", darkturquoise: \"00ced1\",\n darkviolet: \"9400d3\", deeppink: \"ff1493\", deepskyblue: \"00bfff\",\n dimgray: \"696969\", dimgrey: \"696969\", dodgerblue: \"1e90ff\",\n firebrick: \"b22222\", floralwhite: \"fffaf0\", forestgreen: \"228b22\",\n fuchsia: \"ff00ff\", gainsboro: \"dcdcdc\", ghostwhite: \"f8f8ff\",\n gold: \"ffd700\", goldenrod: \"daa520\", gray: \"808080\",\n grey: \"808080\", green: \"008000\", greenyellow: \"adff2f\",\n honeydew: \"f0fff0\", hotpink: \"ff69b4\", indianred: \"cd5c5c\",\n indigo: \"4b0082\", ivory: \"fffff0\", khaki: \"f0e68c\",\n lavender: \"e6e6fa\", lavenderblush: \"fff0f5\", lawngreen: \"7cfc00\",\n lemonchiffon: \"fffacd\", lightblue: \"add8e6\", lightcoral: \"f08080\",\n lightcyan: \"e0ffff\", lightgoldenrodyellow: \"fafad2\", lightgray: \"d3d3d3\",\n lightgrey: \"d3d3d3\", lightgreen: \"90ee90\", lightpink: \"ffb6c1\",\n lightsalmon: \"ffa07a\", lightseagreen: \"20b2aa\", lightskyblue: \"87cefa\",\n lightslategray: \"778899\", lightslategrey: \"778899\", lightsteelblue: \"b0c4de\",\n lightyellow: \"ffffe0\", lime: \"00ff00\", limegreen: \"32cd32\",\n linen: \"faf0e6\", magenta: \"ff00ff\", maroon: \"800000\",\n mediumaquamarine: \"66cdaa\", mediumblue: \"0000cd\", mediumorchid: \"ba55d3\",\n mediumpurple: \"9370d8\", mediumseagreen: \"3cb371\", mediumslateblue: \"7b68ee\",\n mediumspringgreen: \"00fa9a\", mediumturquoise: \"48d1cc\", mediumvioletred: \"c71585\",\n midnightblue: \"191970\", mintcream: \"f5fffa\", mistyrose: \"ffe4e1\",\n moccasin: \"ffe4b5\", navajowhite: \"ffdead\", navy: \"000080\",\n oldlace: \"fdf5e6\", olive: \"808000\", olivedrab: \"6b8e23\",\n orange: \"ffa500\", orangered: \"ff4500\", orchid: \"da70d6\",\n palegoldenrod: \"eee8aa\", palegreen: \"98fb98\", paleturquoise: \"afeeee\",\n palevioletred: \"d87093\", papayawhip: \"ffefd5\", peachpuff: \"ffdab9\",\n peru: \"cd853f\", pink: \"ffc0cb\", plum: \"dda0dd\",\n powderblue: \"b0e0e6\", purple: \"800080\", red: \"ff0000\",\n rosybrown: \"bc8f8f\", royalblue: \"4169e1\", saddlebrown: \"8b4513\",\n salmon: \"fa8072\", sandybrown: \"f4a460\", seagreen: \"2e8b57\",\n seashell: \"fff5ee\", sienna: \"a0522d\", silver: \"c0c0c0\",\n skyblue: \"87ceeb\", slateblue: \"6a5acd\", slategray: \"708090\",\n slategrey: \"708090\", snow: \"fffafa\", springgreen: \"00ff7f\",\n steelblue: \"4682b4\", tan: \"d2b48c\", teal: \"008080\",\n thistle: \"d8bfd8\", tomato: \"ff6347\", turquoise: \"40e0d0\",\n violet: \"ee82ee\", wheat: \"f5deb3\", white: \"ffffff\",\n whitesmoke: \"f5f5f5\", yellow: \"ffff00\", yellowgreen: \"9acd32\"\n};\n\nexport default namedColors;","import Class from '../class';\nimport support from '../support';\nimport namedColors from './named-colors';\n\nconst browser = support.browser;\n\nlet matchNamedColor = (color) => {\n const colorNames = Object.keys(namedColors);\n colorNames.push(\"transparent\");\n\n const regexp = new RegExp(\"^(\" + colorNames.join(\"|\") + \")(\\\\W|$)\", \"i\");\n matchNamedColor = (color) => regexp.exec(color);\n\n return regexp.exec(color);\n};\n\nclass BaseColor extends Class {\n constructor() { super(); }\n toHSV() { return this; }\n\n toRGB() { return this; }\n\n toHex(options) { return this.toBytes().toHex(options); }\n\n toBytes() { return this; }\n\n toCss(options) { return \"#\" + this.toHex(options); }\n\n toCssRgba() {\n const rgb = this.toBytes();\n return `rgba(${ rgb.r }, ${ rgb.g }, ${ rgb.b }, ${ parseFloat((Number(this.a)).toFixed(3)) })`;\n }\n\n toDisplay() {\n if (browser.msie && browser.version < 9) {\n return this.toCss(); // no RGBA support; does it support any opacity in colors?\n }\n return this.toCssRgba();\n }\n\n equals(c) {\n return c === this || ((c !== null && c !== undefined) && this.toCssRgba() === parseColor(c).toCssRgba());\n }\n\n diff(other) {\n if (other === null) {\n return NaN;\n }\n\n const c1 = this.toBytes();\n const c2 = other.toBytes();\n\n return Math.sqrt(Math.pow((c1.r - c2.r) * 0.30, 2) +\n Math.pow((c1.g - c2.g) * 0.59, 2) +\n Math.pow((c1.b - c2.b) * 0.11, 2));\n }\n\n clone() {\n let c = this.toBytes();\n if (c === this) {\n c = new Bytes(c.r, c.g, c.b, c.a);\n }\n\n return c;\n }\n}\n\nclass RGB extends BaseColor {\n constructor(r, g, b, a) {\n super();\n\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = a;\n }\n\n toHSV() {\n const { r, g, b } = this;\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n const delta = max - min;\n const v = max;\n let h, s;\n\n if (delta === 0) {\n return new HSV(0, 0, v, this.a);\n }\n\n if (max !== 0) {\n s = delta / max;\n if (r === max) {\n h = (g - b) / delta;\n } else if (g === max) {\n h = 2 + (b - r) / delta;\n } else {\n h = 4 + (r - g) / delta;\n }\n\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n } else {\n s = 0;\n h = -1;\n }\n\n return new HSV(h, s, v, this.a);\n }\n\n toHSL() {\n const { r, g, b } = this;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h, s, l = (max + min) / 2;\n\n if (max === min) {\n h = s = 0;\n } else {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n default: break;\n }\n }\n\n return new HSL(h * 60, s * 100, l * 100, this.a);\n }\n\n toBytes() {\n return new Bytes(this.r * 255, this.g * 255, this.b * 255, this.a);\n }\n}\n\nclass Bytes extends RGB {\n constructor(r, g, b, a) {\n super(Math.round(r), Math.round(g), Math.round(b), a);\n }\n\n toRGB() {\n return new RGB(this.r / 255, this.g / 255, this.b / 255, this.a);\n }\n\n toHSV() {\n return this.toRGB().toHSV();\n }\n\n toHSL() {\n return this.toRGB().toHSL();\n }\n\n toHex(options) {\n let value = hex(this.r, 2) + hex(this.g, 2) + hex(this.b, 2);\n\n if (options && options.alpha) {\n value += hex(Math.round(this.a * 255), 2);\n }\n\n return value;\n }\n\n toBytes() {\n return this;\n }\n}\n\nfunction hex(n, width, pad = \"0\") {\n let result = n.toString(16);\n while (width > result.length) {\n result = pad + result;\n }\n\n return result;\n}\n\nclass HSV extends BaseColor {\n constructor(h, s, v, a) {\n super();\n\n this.h = h;\n this.s = s;\n this.v = v;\n this.a = a;\n }\n\n toRGB() {\n let { h, s, v } = this;\n let r, g, b;\n\n if (s === 0) {\n r = g = b = v;\n } else {\n h /= 60;\n\n const i = Math.floor(h);\n const f = h - i;\n const p = v * (1 - s);\n const q = v * (1 - s * f);\n const t = v * (1 - s * (1 - f));\n\n switch (i) {\n case 0: r = v; g = t; b = p; break;\n case 1: r = q; g = v; b = p; break;\n case 2: r = p; g = v; b = t; break;\n case 3: r = p; g = q; b = v; break;\n case 4: r = t; g = p; b = v; break;\n default: r = v; g = p; b = q; break;\n }\n }\n\n return new RGB(r, g, b, this.a);\n }\n\n toHSL() {\n return this.toRGB().toHSL();\n }\n\n toBytes() {\n return this.toRGB().toBytes();\n }\n}\n\nclass HSL extends BaseColor {\n constructor(h, s, l, a) {\n super();\n\n this.h = h;\n this.s = s;\n this.l = l;\n this.a = a;\n }\n\n toRGB() {\n let h = this.h / 360;\n let s = this.s / 100;\n let l = this.l / 100;\n let r, g, b;\n\n if (s === 0) {\n r = g = b = l; // achromatic\n } else {\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return new RGB(r, g, b, this.a);\n }\n\n toHSV() {\n return this.toRGB().toHSV();\n }\n\n toBytes() {\n return this.toRGB().toBytes();\n }\n}\n\nfunction hue2rgb(p, q, s) {\n let t = s;\n\n if (t < 0) {\n t += 1;\n }\n\n if (t > 1) {\n t -= 1;\n }\n\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n\n if (t < 1 / 2) {\n return q;\n }\n\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n\n return p;\n}\n\nfunction alphaFromHex(a) {\n return parseFloat(parseFloat(parseInt(a, 16) / 255 ).toFixed(3));\n}\n\nexport { RGB, Bytes, HSV, HSL };\n\nexport default function parseColor(value, safe) {\n let m, ret;\n\n if (!value || value === \"none\") {\n return null;\n }\n\n if (value instanceof BaseColor) {\n return value;\n }\n\n let color = value.toLowerCase();\n if ((m = matchNamedColor(color))) {\n if (m[1] === \"transparent\") {\n color = new RGB(1, 1, 1, 0);\n } else {\n color = parseColor(namedColors[m[1]], safe);\n }\n color.match = [ m[1] ];\n return color;\n }\n if ((m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})\\b/i.exec(color))) {\n ret = new Bytes(parseInt(m[1], 16),\n parseInt(m[2], 16),\n parseInt(m[3], 16), 1);\n } else if ((m = /^#?([0-9a-f])([0-9a-f])([0-9a-f])\\b/i.exec(color))) {\n ret = new Bytes(parseInt(m[1] + m[1], 16),\n parseInt(m[2] + m[2], 16),\n parseInt(m[3] + m[3], 16), 1);\n } else if ((m = /^#?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])\\b/i.exec(color))) { // Parse 4 digit hex color\n ret = new Bytes(parseInt(m[1] + m[1], 16),\n parseInt(m[2] + m[2], 16),\n parseInt(m[3] + m[3], 16),\n alphaFromHex(m[4] + m[4]));\n } else if ((m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})\\b/i.exec(color))) { // Parse 8 digit hex color\n ret = new Bytes(parseInt(m[1], 16),\n parseInt(m[2], 16),\n parseInt(m[3], 16),\n alphaFromHex(m[4]));\n } else if ((m = /^rgb\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*\\)/.exec(color))) {\n ret = new Bytes(parseInt(m[1], 10),\n parseInt(m[2], 10),\n parseInt(m[3], 10), 1);\n } else if ((m = /^rgba\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9.]+)\\s*\\)/.exec(color))) {\n ret = new Bytes(parseInt(m[1], 10),\n parseInt(m[2], 10),\n parseInt(m[3], 10), parseFloat(m[4]));\n } else if ((m = /^rgb\\(\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*\\)/.exec(color))) {\n ret = new RGB(parseFloat(m[1]) / 100,\n parseFloat(m[2]) / 100,\n parseFloat(m[3]) / 100, 1);\n } else if ((m = /^rgba\\(\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9]*\\.?[0-9]+)%\\s*,\\s*([0-9.]+)\\s*\\)/.exec(color))) {\n ret = new RGB(parseFloat(m[1]) / 100,\n parseFloat(m[2]) / 100,\n parseFloat(m[3]) / 100, parseFloat(m[4]));\n } else if ((m = /^color\\(\\s*srgb\\s*([0-9]*\\.?[0-9]+)\\s+([0-9]*\\.?[0-9]+)\\s+([0-9]*\\.?[0-9]+)\\s*(\\/\\s+([0-9]*\\.?[0-9]+))?\\)/.exec(color))) {\n ret = new RGB(\n parseFloat(m[1]),\n parseFloat(m[2]),\n parseFloat(m[3]),\n parseFloat(m[5] || '1'));\n }\n\n if (ret) {\n ret.match = m;\n } else if (!safe) {\n throw new Error(\"Cannot parse color: \" + color);\n }\n\n return ret;\n}\n","const ampRegExp = /&/g;\nconst ltRegExp = //g;\n\nexport default function htmlEncode(value) {\n return String(value).replace(ampRegExp, \"&\").replace(ltRegExp, \"<\").replace(gtRegExp, \">\").replace(quoteRegExp, \""\").replace(aposRegExp, \"'\");\n}","/* eslint-disable no-console */\n\nexport default function logToConsole(message) {\n const console = window.console;\n\n if (typeof(console) != \"undefined\" && console.log) {\n console.log(message);\n }\n}","import Class from './class';\n\nclass Observable extends Class {\n constructor() {\n super();\n\n this._events = {};\n }\n\n bind(eventName, handlers, one) {\n const eventNames = getArray(eventName);\n const handlersIsFunction = isFunction(handlers);\n const length = eventNames.length;\n\n if (handlers === undefined) {\n for (let field in eventName) {\n this.bind(field, eventName[field]);\n }\n return this;\n }\n\n for (let idx = 0; idx < length; idx++) {\n const eventName = eventNames[idx];\n\n let handler = handlersIsFunction ? handlers : handlers[eventName];\n\n if (handler) {\n if (one) {\n const original = handler;\n handler = () => { // eslint-disable-line no-loop-func\n this.unbind(eventName, handler);\n original.apply(this, arguments);\n };\n handler.original = original;\n }\n let events = this._events[eventName] = this._events[eventName] || [];\n events.push(handler);\n }\n }\n\n return this;\n }\n\n one(eventNames, handlers) {\n return this.bind(eventNames, handlers, true);\n }\n\n first(eventName, handlers) {\n const eventNames = getArray(eventName);\n const handlersIsFunction = isFunction(handlers);\n\n for (let idx = 0, length = eventNames.length; idx < length; idx++) {\n const eventName = eventNames[idx];\n\n const handler = handlersIsFunction ? handlers : handlers[eventName];\n\n if (handler) {\n const events = this._events[eventName] = this._events[eventName] || [];\n events.unshift(handler);\n }\n }\n\n return this;\n }\n\n trigger(eventName, e = {}) {\n let events = this._events[eventName];\n\n if (events) {\n const length = events.length;\n\n e.sender = this;\n e._defaultPrevented = false;\n e.preventDefault = preventDefault;\n e.isDefaultPrevented = isDefaultPrevented;\n\n events = events.slice();\n\n for (let idx = 0; idx < length; idx++) {\n events[idx].call(this, e);\n }\n\n return e._defaultPrevented === true;\n }\n\n return false;\n }\n\n unbind(eventName, handler) {\n const events = this._events[eventName];\n\n if (eventName === undefined) {\n this._events = {};\n } else if (events) {\n if (handler) {\n for (let idx = events.length - 1; idx >= 0; idx--) {\n if (events[idx] === handler || events[idx].original === handler) {\n events.splice(idx, 1);\n }\n }\n } else {\n this._events[eventName] = [];\n }\n }\n\n return this;\n }\n}\n\nfunction isFunction(value) {\n return typeof value === \"function\";\n}\n\nfunction getArray(value) {\n return typeof value === \"string\" ? [ value ] : value;\n}\n\nfunction preventDefault() {\n this._defaultPrevented = true;\n}\n\nfunction isDefaultPrevented() {\n return this._defaultPrevented === true;\n}\n\nexport default Observable;","function matchUserAgent(userAgent) {\n const browserRxs = {\n edge: /(edge)[ \\/]([\\w.]+)/i,\n webkit: /(chrome)[ \\/]([\\w.]+)/i,\n safari: /(webkit)[ \\/]([\\w.]+)/i,\n opera: /(opera)(?:.*version|)[ \\/]([\\w.]+)/i,\n msie: /(msie\\s|trident.*? rv:)([\\w.]+)/i,\n mozilla: /(mozilla)(?:.*? rv:([\\w.]+))/i\n };\n\n let browser = {};\n\n for (let agent in browserRxs) {\n if (browserRxs.hasOwnProperty(agent)) {\n const match = userAgent.match(browserRxs[agent]);\n if (match) {\n browser[agent] = true;\n browser[match[1].toLowerCase().split(\" \")[0].split(\"/\")[0]] = true;\n browser.version = parseInt(document.documentMode || match[2], 10);\n\n break;\n }\n }\n }\n\n return browser;\n}\n\nlet browser = null;\n\nconst support = {\n get browser() {\n if (typeof window === 'undefined' || browser) {\n return browser;\n }\n\n browser = matchUserAgent(window.navigator.userAgent);\n return browser;\n }\n};\n\nexport default support;\n","import now from '../util/now';\n\nexport default function throttle(fn, delay) {\n let lastExecTime = 0;\n let timeout;\n\n if (!delay || delay <= 0) {\n return fn;\n }\n\n const throttled = function() {\n const elapsed = now() - lastExecTime;\n const args = arguments;\n\n const exec = function() {\n fn.apply(null, args);\n lastExecTime = now();\n };\n\n // first execution\n if (!lastExecTime) {\n return exec();\n }\n\n if (timeout) {\n clearTimeout(timeout);\n }\n\n if (elapsed > delay) {\n exec();\n } else {\n timeout = setTimeout(exec, delay - elapsed);\n }\n };\n\n throttled.cancel = function() {\n clearTimeout(timeout);\n };\n\n return throttled;\n}\n","import { Class } from '../common';\n\nclass BaseNode extends Class {\n constructor(srcElement) {\n super();\n\n this.childNodes = [];\n this.parent = null;\n\n if (srcElement) {\n this.srcElement = srcElement;\n this.observe();\n }\n }\n\n destroy() {\n if (this.srcElement) {\n this.srcElement.removeObserver(this);\n }\n\n const children = this.childNodes;\n for (let i = 0; i < children.length; i++) {\n this.childNodes[i].destroy();\n }\n\n this.parent = null;\n }\n\n load() {}\n\n observe() {\n if (this.srcElement) {\n this.srcElement.addObserver(this);\n }\n }\n\n append(node) {\n this.childNodes.push(node);\n node.parent = this;\n }\n\n insertAt(node, pos) {\n this.childNodes.splice(pos, 0, node);\n node.parent = this;\n }\n\n remove(index, count) {\n const end = index + count;\n for (let i = index; i < end; i++) {\n this.childNodes[i].removeSelf();\n }\n this.childNodes.splice(index, count);\n }\n\n removeSelf() {\n this.clear();\n this.destroy();\n }\n\n clear() {\n this.remove(0, this.childNodes.length);\n }\n\n invalidate() {\n if (this.parent) {\n this.parent.invalidate();\n }\n }\n\n geometryChange() {\n this.invalidate();\n }\n\n optionsChange() {\n this.invalidate();\n }\n\n childrenChange(e) {\n if (e.action === \"add\") {\n this.load(e.items, e.index);\n } else if (e.action === \"remove\") {\n this.remove(e.index, e.items.length);\n }\n\n this.invalidate();\n }\n}\n\nexport default BaseNode;","const DASH_ARRAYS = {\n dot: [ 1.5, 3.5 ],\n dash: [ 4, 3.5 ],\n longdash: [ 8, 3.5 ],\n dashdot: [ 3.5, 3.5, 1.5, 3.5 ],\n longdashdot: [ 8, 3.5, 1.5, 3.5 ],\n longdashdotdot: [ 8, 3.5, 1.5, 3.5, 1.5, 3.5 ]\n};\n\nconst SOLID = \"solid\";\nconst BUTT = \"butt\";\n\nexport { DASH_ARRAYS, SOLID, BUTT };\n","import { Class } from '../common';\n\nclass HasObservers extends Class {\n observers() {\n this._observers = this._observers || [];\n return this._observers;\n }\n\n addObserver(element) {\n if (!this._observers) {\n this._observers = [ element ];\n } else {\n this._observers.push(element);\n }\n return this;\n }\n\n removeObserver(element) {\n const observers = this.observers();\n const index = observers.indexOf(element);\n if (index !== -1) {\n observers.splice(index, 1);\n }\n return this;\n }\n\n trigger(methodName, event) {\n const observers = this._observers;\n\n if (observers && !this._suspended) {\n for (let idx = 0; idx < observers.length; idx++) {\n let observer = observers[idx];\n if (observer[methodName]) {\n observer[methodName](event);\n }\n }\n }\n return this;\n }\n\n optionsChange(e = {}) {\n e.element = this;\n this.trigger(\"optionsChange\", e);\n }\n\n geometryChange() {\n this.trigger(\"geometryChange\", {\n element: this\n });\n }\n\n suspend() {\n this._suspended = (this._suspended || 0) + 1;\n return this;\n }\n\n resume() {\n this._suspended = Math.max((this._suspended || 0) - 1, 0);\n return this;\n }\n\n _observerField(field, value) {\n if (this[field]) {\n this[field].removeObserver(this);\n }\n this[field] = value;\n value.addObserver(this);\n }\n}\n\nexport default HasObservers;\n\n","import { Class } from '../common';\nimport HasObservers from './has-observers';\nimport { defined } from '../util';\n\n\nconst toString = {}.toString;\n\nclass OptionsStore extends HasObservers {\n constructor(options, prefix = \"\") {\n super();\n\n this.prefix = prefix;\n\n for (let field in options) {\n let member = options[field];\n member = this._wrap(member, field);\n this[field] = member;\n }\n }\n\n get(field) {\n const parts = field.split(\".\");\n let result = this;\n\n while (parts.length && result) {\n let part = parts.shift();\n result = result[part];\n }\n\n return result;\n }\n\n set(field, value) {\n const current = this.get(field);\n\n if (current !== value) {\n this._set(field, this._wrap(value, field));\n this.optionsChange({\n field: this.prefix + field,\n value: value\n });\n }\n }\n\n _set(field, value) {\n const composite = field.indexOf(\".\") >= 0;\n let parentObj = this;\n let fieldName = field;\n\n if (composite) {\n const parts = fieldName.split(\".\");\n let prefix = this.prefix;\n\n while (parts.length > 1) {\n fieldName = parts.shift();\n prefix += fieldName + \".\";\n\n let obj = parentObj[fieldName];\n\n if (!obj) {\n obj = new OptionsStore({}, prefix);\n obj.addObserver(this);\n parentObj[fieldName] = obj;\n }\n parentObj = obj;\n }\n fieldName = parts[0];\n }\n\n parentObj._clear(fieldName);\n parentObj[fieldName] = value;\n }\n\n _clear(field) {\n const current = this[field];\n if (current && current.removeObserver) {\n current.removeObserver(this);\n }\n }\n\n _wrap(object, field) {\n const type = toString.call(object);\n let wrapped = object;\n\n if (wrapped !== null && defined(wrapped) && type === \"[object Object]\") {\n if (!(object instanceof OptionsStore) && !(object instanceof Class)) {\n wrapped = new OptionsStore(wrapped, this.prefix + field + \".\");\n }\n\n wrapped.addObserver(this);\n }\n\n return wrapped;\n }\n}\n\nexport default OptionsStore;\n","import Group from '../shapes/group';\nimport Point from '../geometry/point';\nimport { Observable } from '../common';\nimport { eventElement, eventCoordinates, elementPadding, elementScale, elementSize, elementOffset } from '../util';\n\nconst events = [\n \"click\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"resize\"\n];\n\nclass Surface extends Observable {\n constructor(element, options) {\n super();\n\n this.options = Object.assign({}, options);\n this.element = element;\n this.element._kendoExportVisual = this.exportVisual.bind(this);\n\n this._click = this._handler(\"click\");\n this._mouseenter = this._handler(\"mouseenter\");\n this._mouseleave = this._handler(\"mouseleave\");\n this._mousemove = this._handler(\"mousemove\");\n\n this._visual = new Group();\n\n elementSize(element, this.options);\n\n this.bind(events, this.options);\n\n this._enableTracking();\n }\n\n draw(element) {\n this._visual.children.push(element);\n }\n\n clear() {\n this._visual.children = [];\n }\n\n destroy() {\n this._visual = null;\n this.element._kendoExportVisual = null;\n this.unbind();\n }\n\n eventTarget(e) {\n let domNode = eventElement(e);\n let node;\n\n while (!node && domNode) {\n node = domNode._kendoNode;\n if (domNode === this.element) {\n break;\n }\n\n domNode = domNode.parentElement;\n }\n\n if (node) {\n return node.srcElement;\n }\n }\n\n exportVisual() {\n return this._visual;\n }\n\n getSize() {\n return elementSize(this.element);\n }\n\n currentSize(size) {\n if (size) {\n this._size = size;\n } else {\n return this._size;\n }\n }\n\n setSize(size) {\n elementSize(this.element, size);\n\n this.currentSize(size);\n this._resize();\n }\n\n resize(force) {\n const size = this.getSize();\n const currentSize = this.currentSize();\n\n if (force || (size.width > 0 || size.height > 0) && (!currentSize || size.width !== currentSize.width || size.height !== currentSize.height)) {\n this.currentSize(size);\n this._resize(size, force);\n this.trigger(\"resize\", size);\n }\n }\n\n size(value) {\n if (!value) {\n return this.getSize();\n }\n\n this.setSize(value);\n }\n\n suspendTracking() {\n this._suspendedTracking = true;\n }\n\n resumeTracking() {\n this._suspendedTracking = false;\n }\n\n _enableTracking() {}\n\n _resize() {}\n\n _handler(eventName) {\n return (e) => {\n const node = this.eventTarget(e);\n if (node && !this._suspendedTracking) {\n this.trigger(eventName, {\n element: node,\n originalEvent: e,\n type: eventName\n });\n }\n };\n }\n\n _elementOffset() {\n const element = this.element;\n const padding = elementPadding(element);\n const { left, top } = elementOffset(element);\n\n return {\n left: left + padding.left,\n top: top + padding.top\n };\n }\n\n _surfacePoint(e) {\n const offset = this._elementOffset();\n const coord = eventCoordinates(e);\n const x = coord.x - offset.left;\n const y = coord.y - offset.top;\n\n const inverseTransform = elementScale(this.element).invert();\n const point = new Point(\n x,\n y\n ).transform(inverseTransform);\n\n return point;\n }\n}\n\nexport default Surface;\n","export { default as Circle } from './geometry/circle';\nexport { default as Arc } from './geometry/arc';\nexport { default as Rect } from './geometry/rect';\nexport { default as Point } from './geometry/point';\nexport { default as Segment } from './geometry/segment';\nexport { default as Matrix } from './geometry/matrix';\nexport { default as Size } from './geometry/size';\nexport { default as toMatrix } from './geometry/to-matrix';\nexport { default as Transformation } from './geometry/transformation';\nexport { default as transform } from './geometry/transform';\n","import HasObservers from '../core/has-observers';\nimport { deg, rad, round } from '../util';\nimport withAccessors from '../mixins/with-accessors';\n\nimport closeOrLess from './math/close-or-less';\nimport lineIntersection from './math/line-intersection';\nimport ellipseExtremeAngles from './math/ellipse-extreme-angles';\n\nimport { PRECISION } from './constants';\nimport Point from './point';\nimport Rect from './rect';\nimport transform from './transform';\n\n\nconst MAX_INTERVAL = 45;\nconst pow = Math.pow;\nconst accessors = [ \"radiusX\", \"radiusY\", \"startAngle\", \"endAngle\", \"anticlockwise\" ];\n\nclass Arc extends withAccessors(HasObservers, accessors) {\n constructor(center = new Point(), options = {}) {\n super();\n\n this.setCenter(center);\n\n this.radiusX = options.radiusX;\n this.radiusY = options.radiusY || options.radiusX;\n this.startAngle = options.startAngle;\n this.endAngle = options.endAngle;\n this.anticlockwise = options.anticlockwise || false;\n this.xRotation = options.xRotation;\n }\n\n clone() {\n return new Arc(this.center, {\n radiusX: this.radiusX,\n radiusY: this.radiusY,\n startAngle: this.startAngle,\n endAngle: this.endAngle,\n anticlockwise: this.anticlockwise\n });\n }\n\n setCenter(value) {\n this._observerField(\"center\", Point.create(value));\n this.geometryChange();\n return this;\n }\n\n getCenter() {\n return this.center;\n }\n\n pointAt(angle) {\n const center = this.center;\n const radian = rad(angle);\n\n return new Point(\n center.x + this.radiusX * Math.cos(radian),\n center.y + this.radiusY * Math.sin(radian)\n );\n }\n\n curvePoints() {\n const startAngle = this.startAngle;\n const dir = this.anticlockwise ? -1 : 1;\n const curvePoints = [ this.pointAt(startAngle) ];\n const interval = this._arcInterval();\n const intervalAngle = interval.endAngle - interval.startAngle;\n const subIntervalsCount = Math.ceil(intervalAngle / MAX_INTERVAL);\n const subIntervalAngle = intervalAngle / subIntervalsCount;\n let currentAngle = startAngle;\n let transformation;\n if (this.xRotation) {\n transformation = transform().rotate(this.xRotation, this.center);\n }\n\n for (let i = 1; i <= subIntervalsCount; i++) {\n const nextAngle = currentAngle + dir * subIntervalAngle;\n const points = this._intervalCurvePoints(currentAngle, nextAngle, transformation);\n\n curvePoints.push(points.cp1, points.cp2, points.p2);\n currentAngle = nextAngle;\n }\n\n return curvePoints;\n }\n\n bbox(matrix) {\n const interval = this._arcInterval();\n const startAngle = interval.startAngle;\n const endAngle = interval.endAngle;\n const extremeAngles = ellipseExtremeAngles(this.center, this.radiusX, this.radiusY, matrix);\n const extremeX = deg(extremeAngles.x);\n const extremeY = deg(extremeAngles.y);\n const endPoint = this.pointAt(endAngle).transformCopy(matrix);\n let currentAngleX = bboxStartAngle(extremeX, startAngle);\n let currentAngleY = bboxStartAngle(extremeY, startAngle);\n let currentPoint = this.pointAt(startAngle).transformCopy(matrix);\n let minPoint = Point.min(currentPoint, endPoint);\n let maxPoint = Point.max(currentPoint, endPoint);\n\n while (currentAngleX < endAngle || currentAngleY < endAngle) {\n let currentPointX;\n if (currentAngleX < endAngle) {\n currentPointX = this.pointAt(currentAngleX).transformCopy(matrix);\n currentAngleX += 90;\n }\n\n let currentPointY;\n if (currentAngleY < endAngle) {\n currentPointY = this.pointAt(currentAngleY).transformCopy(matrix);\n currentAngleY += 90;\n }\n\n currentPoint = new Point(currentPointX.x, currentPointY.y);\n minPoint = Point.min(minPoint, currentPoint);\n maxPoint = Point.max(maxPoint, currentPoint);\n }\n\n return Rect.fromPoints(minPoint, maxPoint);\n }\n\n _arcInterval() {\n let { startAngle, endAngle, anticlockwise } = this;\n\n if (anticlockwise) {\n let oldStart = startAngle;\n startAngle = endAngle;\n endAngle = oldStart;\n }\n\n if (startAngle > endAngle || (anticlockwise && startAngle === endAngle)) {\n endAngle += 360;\n }\n\n return {\n startAngle: startAngle,\n endAngle: endAngle\n };\n }\n\n _intervalCurvePoints(startAngle, endAngle, transformation) {\n const p1 = this.pointAt(startAngle);\n const p2 = this.pointAt(endAngle);\n const p1Derivative = this._derivativeAt(startAngle);\n const p2Derivative = this._derivativeAt(endAngle);\n const t = (rad(endAngle) - rad(startAngle)) / 3;\n const cp1 = new Point(p1.x + t * p1Derivative.x, p1.y + t * p1Derivative.y);\n const cp2 = new Point(p2.x - t * p2Derivative.x, p2.y - t * p2Derivative.y);\n if (transformation) {\n p1.transform(transformation);\n p2.transform(transformation);\n cp1.transform(transformation);\n cp2.transform(transformation);\n }\n\n return {\n p1: p1,\n cp1: cp1,\n cp2: cp2,\n p2: p2\n };\n }\n\n _derivativeAt(angle) {\n const radian = rad(angle);\n\n return new Point(-this.radiusX * Math.sin(radian), this.radiusY * Math.cos(radian));\n }\n\n containsPoint(point) {\n const interval = this._arcInterval();\n const intervalAngle = interval.endAngle - interval.startAngle;\n const { center, radiusX, radiusY } = this;\n const distance = center.distanceTo(point);\n const angleRad = Math.atan2(point.y - center.y, point.x - center.x);\n const pointRadius = (radiusX * radiusY) /\n Math.sqrt(pow(radiusX, 2) * pow(Math.sin(angleRad), 2) + pow(radiusY, 2) * pow(Math.cos(angleRad), 2));\n const startPoint = this.pointAt(this.startAngle).round(PRECISION);\n const endPoint = this.pointAt(this.endAngle).round(PRECISION);\n const intersection = lineIntersection(center, point.round(PRECISION), startPoint, endPoint);\n let containsPoint;\n\n if (intervalAngle < 180) {\n containsPoint = intersection && closeOrLess(center.distanceTo(intersection), distance) && closeOrLess(distance, pointRadius);\n } else {\n let angle = calculateAngle(center.x, center.y, radiusX, radiusY, point.x, point.y);\n if (angle !== 360) {\n angle = (360 + angle) % 360;\n }\n\n let inAngleRange = interval.startAngle <= angle && angle <= interval.endAngle;\n containsPoint = (inAngleRange && closeOrLess(distance, pointRadius)) || (!inAngleRange && (!intersection || intersection.equals(point)));\n }\n return containsPoint;\n }\n\n _isOnPath(point, width) {\n const interval = this._arcInterval();\n const center = this.center;\n let angle = calculateAngle(center.x, center.y, this.radiusX, this.radiusY, point.x, point.y);\n if (angle !== 360) {\n angle = (360 + angle) % 360;\n }\n\n const inAngleRange = interval.startAngle <= angle && angle <= interval.endAngle;\n\n return inAngleRange && this.pointAt(angle).distanceTo(point) <= width;\n }\n\n static fromPoints(start, end, rx, ry, largeArc, swipe, rotation) {// eslint-disable-line max-params\n const arcParameters = normalizeArcParameters({\n x1: start.x,\n y1: start.y,\n x2: end.x,\n y2: end.y,\n rx: rx,\n ry: ry,\n largeArc: largeArc,\n swipe: swipe,\n rotation: rotation\n });\n\n return new Arc(arcParameters.center, {\n startAngle: arcParameters.startAngle,\n endAngle: arcParameters.endAngle,\n radiusX: arcParameters.radiusX,\n radiusY: arcParameters.radiusY,\n xRotation: arcParameters.xRotation,\n anticlockwise: swipe === 0\n });\n }\n}\n\nfunction calculateAngle(cx, cy, rx, ry, x, y) {\n const cos = round((x - cx) / rx, 3);\n const sin = round((y - cy) / ry, 3);\n\n return round(deg(Math.atan2(sin, cos)));\n}\n\nfunction normalizeArcParameters(parameters) {\n let { x1, y1, x2, y2, rx, ry, largeArc, swipe, rotation = 0 } = parameters;\n\n const radians = rad(rotation);\n const cosine = Math.cos(radians);\n const sine = Math.sin(radians);\n\n const xT = cosine * (x1 - x2) / 2 + sine * (y1 - y2) / 2;\n const yT = -sine * (x1 - x2) / 2 + cosine * (y1 - y2) / 2;\n\n const sign = largeArc !== swipe ? 1 : -1;\n\n const xt2 = Math.pow(xT, 2);\n const yt2 = Math.pow(yT, 2);\n let rx2 = Math.pow(rx, 2);\n let ry2 = Math.pow(ry, 2);\n\n let delta = xt2 / rx2 + yt2 / ry2;\n\n if (delta > 1) {\n delta = Math.sqrt(xt2 / rx2 + yt2 / ry2);\n rx = delta * rx;\n rx2 = Math.pow(rx, 2);\n\n ry = delta * ry;\n ry2 = Math.pow(ry, 2);\n }\n\n let constT = sign * Math.sqrt((rx2 * ry2 - rx2 * yt2 - ry2 * xt2) / (rx2 * yt2 + ry2 * xt2));\n // due to rounding errors the value could become NaN even after radii correction\n if (isNaN(constT)) {\n constT = 0;\n }\n\n const cxT = constT * (rx * yT) / ry;\n const cyT = - constT * (ry * xT) / rx;\n\n const cx = cosine * cxT - sine * cyT + (x1 + x2) / 2;\n const cy = sine * cxT + cosine * cyT + (y1 + y2) / 2;\n\n\n const uX = (xT - cxT) / rx;\n const uY = (yT - cyT) / ry;\n const vX = -(xT + cxT) / rx;\n const vY = -(yT + cyT) / ry;\n\n const startAngle = (uY >= 0 ? 1 : -1) * deg(Math.acos(uX / Math.sqrt(uX * uX + uY * uY)));\n\n const angleCosine = round((uX * vX + uY * vY) / (Math.sqrt(uX * uX + uY * uY) * Math.sqrt(vX * vX + vY * vY)), 10);\n let angle = (uX * vY - uY * vX >= 0 ? 1 : -1) * deg(Math.acos(angleCosine));\n\n if (!swipe && angle > 0) {\n angle -= 360;\n }\n\n if (swipe && angle < 0) {\n angle += 360;\n }\n let endAngle = startAngle + angle;\n const signEndAngle = endAngle >= 0 ? 1 : -1;\n endAngle = (Math.abs(endAngle) % 360) * signEndAngle;\n\n return {\n center: new Point(cx, cy),\n startAngle: startAngle,\n endAngle: endAngle,\n radiusX: rx,\n radiusY: ry,\n xRotation: rotation\n };\n}\n\nfunction bboxStartAngle(angle, start) {\n let startAngle = angle;\n\n while (startAngle < start) {\n startAngle += 90;\n }\n\n return startAngle;\n}\n\nexport default Arc;\n","import withAccessors from '../mixins/with-accessors';\nimport Point from './point';\nimport Rect from './rect';\nimport ellipseExtremeAngles from './math/ellipse-extreme-angles';\nimport HasObservers from '../core/has-observers';\nimport { rad } from '../util';\n\n\nconst PI_DIV_2 = Math.PI / 2;\n\nclass Circle extends withAccessors(HasObservers, [ \"radius\" ]) {\n constructor(center = new Point(), radius = 0) {\n super();\n\n this.setCenter(center);\n this.setRadius(radius);\n }\n\n setCenter(value) {\n this._observerField(\"center\", Point.create(value));\n this.geometryChange();\n return this;\n }\n\n getCenter() {\n return this.center;\n }\n\n equals(other) {\n return other &&\n other.center.equals(this.center) &&\n other.radius === this.radius;\n }\n\n clone() {\n return new Circle(this.center.clone(), this.radius);\n }\n\n pointAt(angle) {\n return this._pointAt(rad(angle));\n }\n\n bbox(matrix) {\n const extremeAngles = ellipseExtremeAngles(this.center, this.radius, this.radius, matrix);\n let minPoint = Point.maxPoint();\n let maxPoint = Point.minPoint();\n\n for (let i = 0; i < 4; i++) {\n let currentPointX = this._pointAt(extremeAngles.x + i * PI_DIV_2).transformCopy(matrix);\n let currentPointY = this._pointAt(extremeAngles.y + i * PI_DIV_2).transformCopy(matrix);\n let currentPoint = new Point(currentPointX.x, currentPointY.y);\n\n minPoint = Point.min(minPoint, currentPoint);\n maxPoint = Point.max(maxPoint, currentPoint);\n }\n\n return Rect.fromPoints(minPoint, maxPoint);\n }\n\n _pointAt(angle) {\n const { center, radius } = this;\n\n return new Point(\n center.x + radius * Math.cos(angle),\n center.y + radius * Math.sin(angle)\n );\n }\n\n containsPoint(point) {\n const { center, radius } = this;\n const inCircle = Math.pow(point.x - center.x, 2) +\n Math.pow(point.y - center.y, 2) <= Math.pow(radius, 2);\n return inCircle;\n }\n\n _isOnPath(point, width) {\n const { center, radius } = this;\n const pointDistance = center.distanceTo(point);\n\n return radius - width <= pointDistance && pointDistance <= radius + width;\n }\n}\n\nexport default Circle;\n","const PRECISION = 10;\n\nexport { PRECISION };","export default function calculateCurveAt(t, field, points) {\n const t1 = 1 - t;\n return Math.pow(t1, 3) * points[0][field] +\n 3 * Math.pow(t1, 2) * t * points[1][field] +\n 3 * Math.pow(t, 2) * t1 * points[2][field] +\n Math.pow(t, 3) * points[3][field];\n}","import close from './close';\n\nexport default function closeOrLess(a, b, tolerance) {\n return a < b || close(a, b, tolerance);\n}","import { PRECISION } from '../constants';\n\nimport { round } from '../../util';\n\nexport default function close(a, b, tolerance = PRECISION) {\n return round(Math.abs(a - b), tolerance) === 0;\n}","import { PRECISION } from '../constants';\nimport { Class } from '../../common';\nimport { round } from '../../util';\n\nclass ComplexNumber extends Class {\n\n constructor(real = 0, img = 0) {\n super();\n\n this.real = real;\n this.img = img;\n }\n\n add(cNumber) {\n return new ComplexNumber(round(this.real + cNumber.real, PRECISION), round(this.img + cNumber.img, PRECISION));\n }\n\n addConstant(value) {\n return new ComplexNumber(this.real + value, this.img);\n }\n\n negate() {\n return new ComplexNumber(-this.real, -this.img);\n }\n\n multiply(cNumber) {\n return new ComplexNumber(this.real * cNumber.real - this.img * cNumber.img,\n this.real * cNumber.img + this.img * cNumber.real);\n }\n\n multiplyConstant(value) {\n return new ComplexNumber(this.real * value, this.img * value);\n }\n\n nthRoot(n) {\n const rad = Math.atan2(this.img, this.real);\n const r = Math.sqrt(Math.pow(this.img, 2) + Math.pow(this.real, 2));\n const nthR = Math.pow(r, 1 / n);\n\n return new ComplexNumber(nthR * Math.cos(rad / n), nthR * Math.sin(rad / n)); //Moivre's formula\n }\n\n equals(cNumber) {\n return this.real === cNumber.real && this.img === cNumber.img;\n }\n\n isReal() {\n return this.img === 0;\n }\n}\n\nexport default ComplexNumber;","import toCubicPolynomial from './to-cubic-polynomial';\nimport solveCubicEquation from './solve-cubic-equation';\nimport calculateCurveAt from './calculate-curve-at';\nimport close from './close';\n\nexport default function curveIntersectionsCount(points, point, bbox) {\n const polynomial = toCubicPolynomial(points, \"x\");\n const roots = solveCubicEquation(polynomial[0], polynomial[1], polynomial[2], polynomial[3] - point.x);\n let rayIntersection, intersectsRay;\n let count = 0;\n for (let i = 0; i < roots.length; i++) {\n rayIntersection = calculateCurveAt(roots[i], \"y\", points);\n intersectsRay = close(rayIntersection, point.y) || rayIntersection > point.y;\n if (intersectsRay && (((roots[i] === 0 || roots[i] === 1) && bbox.bottomRight().x > point.x) || (0 < roots[i] && roots[i] < 1))) {\n count++;\n }\n }\n\n return count;\n}","export default function ellipseExtremeAngles(center, rx, ry, matrix) {\n let extremeX = 0;\n let extremeY = 0;\n\n if (matrix) {\n extremeX = Math.atan2(matrix.c * ry, matrix.a * rx);\n if (matrix.b !== 0) {\n extremeY = Math.atan2(matrix.d * ry, matrix.b * rx);\n }\n }\n\n return {\n x: extremeX,\n y: extremeY\n };\n}","import toCubicPolynomial from './to-cubic-polynomial';\nimport solveCubicEquation from './solve-cubic-equation';\nimport calculateCurveAt from './calculate-curve-at';\n\nexport default function hasRootsInRange(points, point, field, rootField, range) {\n const polynomial = toCubicPolynomial(points, rootField);\n const roots = solveCubicEquation(polynomial[0], polynomial[1], polynomial[2], polynomial[3] - point[rootField]);\n let intersection;\n\n for (let idx = 0; idx < roots.length; idx++) {\n if (0 <= roots[idx] && roots[idx] <= 1) {\n intersection = calculateCurveAt(roots[idx], field, points);\n if (Math.abs(intersection - point[field]) <= range) {\n return true;\n }\n }\n }\n}","import { deg } from '../../util';\nimport transform from '../transform';\n\nexport default function isOutOfEndPoint(endPoint, controlPoint, point) {\n const angle = deg(Math.atan2(controlPoint.y - endPoint.y, controlPoint.x - endPoint.x));\n const rotatedPoint = point.transformCopy(transform().rotate(-angle, endPoint));\n\n return rotatedPoint.x < endPoint.x;\n}","import Point from '../point';\n\nexport default function lineIntersection(p0, p1, p2, p3) {\n const s1x = p1.x - p0.x;\n const s2x = p3.x - p2.x;\n const s1y = p1.y - p0.y;\n const s2y = p3.y - p2.y;\n const nx = p0.x - p2.x;\n const ny = p0.y - p2.y;\n const d = s1x * s2y - s2x * s1y;\n const s = (s1x * ny - s1y * nx) / d;\n const t = (s2x * ny - s2y * nx) / d;\n\n if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {\n return new Point(p0.x + t * s1x, p0.y + t * s1y);\n }\n}","export default function lineIntersectionsCount(a, b, point) {\n let intersects;\n if (a.x !== b.x) {\n const minX = Math.min(a.x, b.x);\n const maxX = Math.max(a.x, b.x);\n const minY = Math.min(a.y, b.y);\n const maxY = Math.max(a.y, b.y);\n const inRange = minX <= point.x && point.x < maxX;\n\n if (minY === maxY) {\n intersects = point.y <= minY && inRange;\n } else {\n intersects = inRange && (((maxY - minY) * ((a.x - b.x) * (a.y - b.y) > 0 ? point.x - minX : maxX - point.x)) / (maxX - minX) + minY - point.y) >= 0;\n }\n }\n\n return intersects ? 1 : 0;\n}","import ComplexNumber from './complex-number';\nimport { PRECISION } from '../constants';\nimport { round } from '../../util';\n\nfunction numberSign(x) {\n return x < 0 ? -1 : 1;\n}\n\nfunction solveQuadraticEquation(a, b, c) {\n const squareRoot = Math.sqrt(Math.pow(b, 2) - 4 * a * c);\n return [\n (-b + squareRoot) / (2 * a),\n (-b - squareRoot) / (2 * a)\n ];\n}\n\n//Cardano's formula\nexport default function solveCubicEquation(a, b, c, d) {\n if (a === 0) {\n return solveQuadraticEquation(b, c, d);\n }\n\n const p = (3 * a * c - Math.pow(b, 2)) / (3 * Math.pow(a, 2));\n const q = (2 * Math.pow(b, 3) - 9 * a * b * c + 27 * Math.pow(a, 2) * d) / (27 * Math.pow(a, 3));\n const Q = Math.pow(p / 3, 3) + Math.pow(q / 2, 2);\n const i = new ComplexNumber(0,1);\n const b3a = -b / (3 * a);\n let x1, x2, y1, y2, y3, z1, z2;\n\n if (Q < 0) {\n x1 = new ComplexNumber(-q / 2, Math.sqrt(-Q)).nthRoot(3);\n x2 = new ComplexNumber(-q / 2, - Math.sqrt(-Q)).nthRoot(3);\n } else {\n x1 = -q / 2 + Math.sqrt(Q);\n x1 = new ComplexNumber(numberSign(x1) * Math.pow(Math.abs(x1), 1 / 3));\n x2 = -q / 2 - Math.sqrt(Q);\n x2 = new ComplexNumber(numberSign(x2) * Math.pow(Math.abs(x2), 1 / 3));\n }\n\n y1 = x1.add(x2);\n\n z1 = x1.add(x2).multiplyConstant(-1 / 2);\n z2 = x1.add(x2.negate()).multiplyConstant(Math.sqrt(3) / 2);\n\n y2 = z1.add(i.multiply(z2));\n y3 = z1.add(i.negate().multiply(z2));\n\n const result = [];\n\n if (y1.isReal()) {\n result.push(round(y1.real + b3a, PRECISION));\n }\n if (y2.isReal()) {\n result.push(round(y2.real + b3a, PRECISION));\n }\n if (y3.isReal()) {\n result.push(round(y3.real + b3a, PRECISION));\n }\n\n return result;\n}","export default function toCubicPolynomial(points, field) {\n return [ -points[0][field] + 3 * points[1][field] - 3 * points[2][field] + points[3][field],\n 3 * (points[0][field] - 2 * points[1][field] + points[2][field]),\n 3 * (-points[0][field] + points[1][field]),\n points[0][field]\n ];\n}","import { Class } from '../common';\nimport defined from '../util/defined';\nimport rad from '../util/rad';\nimport round from '../util/round';\n\nclass Matrix extends Class {\n\n constructor(a = 0, b = 0, c = 0, d = 0, e = 0, f = 0) {\n super();\n\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n }\n\n multiplyCopy(matrix) {\n return new Matrix(\n this.a * matrix.a + this.c * matrix.b,\n this.b * matrix.a + this.d * matrix.b,\n this.a * matrix.c + this.c * matrix.d,\n this.b * matrix.c + this.d * matrix.d,\n this.a * matrix.e + this.c * matrix.f + this.e,\n this.b * matrix.e + this.d * matrix.f + this.f\n );\n }\n\n invert() {\n const { a, b, c: d, d: e, e: g, f: h } = this;\n const det = a * e - b * d;\n\n if (det === 0) {\n return null;\n }\n\n return new Matrix(e / det, -b / det, -d / det, a / det,\n (d * h - e * g) / det, (b * g - a * h) / det);\n }\n\n clone() {\n return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);\n }\n\n equals(other) {\n if (!other) {\n return false;\n }\n\n return this.a === other.a && this.b === other.b &&\n this.c === other.c && this.d === other.d &&\n this.e === other.e && this.f === other.f;\n }\n\n round(precision) {\n this.a = round(this.a, precision);\n this.b = round(this.b, precision);\n this.c = round(this.c, precision);\n this.d = round(this.d, precision);\n this.e = round(this.e, precision);\n this.f = round(this.f, precision);\n\n return this;\n }\n\n toArray(precision) {\n const result = [ this.a, this.b, this.c, this.d, this.e, this.f ];\n\n if (defined(precision)) {\n for (let i = 0; i < result.length; i++) {\n result[i] = round(result[i], precision);\n }\n }\n\n return result;\n }\n\n toString(precision, separator = \",\") {\n return this.toArray(precision).join(separator);\n }\n\n static translate(x, y) {\n return new Matrix(1, 0, 0, 1, x, y);\n }\n\n static unit() {\n return new Matrix(1, 0, 0, 1, 0, 0);\n }\n\n static rotate(angle, x, y) {\n const matrix = new Matrix();\n matrix.a = Math.cos(rad(angle));\n matrix.b = Math.sin(rad(angle));\n matrix.c = -matrix.b;\n matrix.d = matrix.a;\n matrix.e = (x - x * matrix.a + y * matrix.b) || 0;\n matrix.f = (y - y * matrix.a - x * matrix.b) || 0;\n\n return matrix;\n }\n\n static scale(scaleX, scaleY) {\n return new Matrix(scaleX, 0, 0, scaleY, 0, 0);\n }\n}\n\nMatrix.IDENTITY = Matrix.unit();\n\nexport default Matrix;\n","import withAccessors from '../mixins/with-accessors';\nimport HasObservers from '../core/has-observers';\nimport { defined, MIN_NUM, MAX_NUM, round } from '../util';\nimport Matrix from './matrix';\nimport toMatrix from './to-matrix';\n\n\nclass Point extends withAccessors(HasObservers, [ \"x\", \"y\" ]) {\n constructor(x, y) {\n super();\n\n this.x = x || 0;\n this.y = y || 0;\n }\n\n equals(other) {\n return other && other.x === this.x && other.y === this.y;\n }\n\n clone() {\n return new Point(this.x, this.y);\n }\n\n rotate(angle, origin) {\n const originPoint = Point.create(origin) || Point.ZERO;\n\n return this.transform(Matrix.rotate(angle, originPoint.x, originPoint.y));\n }\n\n translate(x, y) {\n this.x += x;\n this.y += y;\n\n this.geometryChange();\n\n return this;\n }\n\n translateWith(point) {\n return this.translate(point.x, point.y);\n }\n\n move(x, y) {\n this.x = this.y = 0;\n return this.translate(x, y);\n }\n\n scale(scaleX, scaleY = scaleX) {\n this.x *= scaleX;\n this.y *= scaleY;\n\n this.geometryChange();\n\n return this;\n }\n\n scaleCopy(scaleX, scaleY) {\n return this.clone().scale(scaleX, scaleY);\n }\n\n transform(transformation) {\n const matrix = toMatrix(transformation);\n const { x, y } = this;\n\n this.x = matrix.a * x + matrix.c * y + matrix.e;\n this.y = matrix.b * x + matrix.d * y + matrix.f;\n\n this.geometryChange();\n\n return this;\n }\n\n transformCopy(transformation) {\n const point = this.clone();\n\n if (transformation) {\n point.transform(transformation);\n }\n\n return point;\n }\n\n distanceTo(point) {\n const dx = this.x - point.x;\n const dy = this.y - point.y;\n\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n round(digits) {\n this.x = round(this.x, digits);\n this.y = round(this.y, digits);\n\n this.geometryChange();\n\n return this;\n }\n\n toArray(digits) {\n const doRound = defined(digits);\n const x = doRound ? round(this.x, digits) : this.x;\n const y = doRound ? round(this.y, digits) : this.y;\n\n return [ x, y ];\n }\n\n toString(digits, separator = \" \") {\n let { x, y } = this;\n\n if (defined(digits)) {\n x = round(x, digits);\n y = round(y, digits);\n }\n\n return x + separator + y;\n }\n\n static create(arg0, arg1) {\n if (defined(arg0)) {\n if (arg0 instanceof Point) {\n return arg0;\n } else if (arguments.length === 1 && arg0.length === 2) {\n return new Point(arg0[0], arg0[1]);\n }\n\n return new Point(arg0, arg1);\n }\n }\n\n static min() {\n let minX = MAX_NUM;\n let minY = MAX_NUM;\n\n for (let i = 0; i < arguments.length; i++) {\n let point = arguments[i];\n minX = Math.min(point.x, minX);\n minY = Math.min(point.y, minY);\n }\n\n return new Point(minX, minY);\n }\n\n static max() {\n let maxX = MIN_NUM;\n let maxY = MIN_NUM;\n\n for (let i = 0; i < arguments.length; i++) {\n const point = arguments[i];\n maxX = Math.max(point.x, maxX);\n maxY = Math.max(point.y, maxY);\n }\n\n return new Point(maxX, maxY);\n }\n\n static minPoint() {\n return new Point(MIN_NUM, MIN_NUM);\n }\n\n static maxPoint() {\n return new Point(MAX_NUM, MAX_NUM);\n }\n\n static get ZERO() {\n return new Point(0, 0);\n }\n}\n\nexport default Point;\n","import HasObservers from '../core/has-observers';\nimport Point from './point';\nimport Size from './size';\n\nclass Rect extends HasObservers {\n constructor(origin = new Point(), size = new Size(), cornerRadius = 0) {\n super();\n\n this.setOrigin(origin);\n this.setSize(size);\n this.setCornerRadius(cornerRadius);\n }\n\n clone() {\n return new Rect(\n this.origin.clone(),\n this.size.clone()\n );\n }\n\n equals(other) {\n return other &&\n other.origin.equals(this.origin) &&\n other.size.equals(this.size);\n }\n\n setOrigin(value) {\n this._observerField(\"origin\", Point.create(value));\n this.geometryChange();\n return this;\n }\n\n getOrigin() {\n return this.origin;\n }\n\n setCornerRadius(radius) {\n this.cornerRadius = Array.isArray(radius) ? radius : [ radius, radius ];\n\n this.geometryChange();\n return this;\n }\n\n getCornerRadius() {\n return this.cornerRadius;\n }\n\n setSize(value) {\n this._observerField(\"size\", Size.create(value));\n this.geometryChange();\n return this;\n }\n\n getSize() {\n return this.size;\n }\n\n width() {\n return this.size.width;\n }\n\n height() {\n return this.size.height;\n }\n\n topLeft() {\n return this.origin.clone();\n }\n\n bottomRight() {\n return this.origin.clone().translate(this.width(), this.height());\n }\n\n topRight() {\n return this.origin.clone().translate(this.width(), 0);\n }\n\n bottomLeft() {\n return this.origin.clone().translate(0, this.height());\n }\n\n center() {\n return this.origin.clone().translate(this.width() / 2, this.height() / 2);\n }\n\n bbox(matrix) {\n const tl = this.topLeft().transformCopy(matrix);\n const tr = this.topRight().transformCopy(matrix);\n const br = this.bottomRight().transformCopy(matrix);\n const bl = this.bottomLeft().transformCopy(matrix);\n\n return Rect.fromPoints(tl, tr, br, bl);\n }\n\n transformCopy(m) {\n return Rect.fromPoints(\n this.topLeft().transform(m),\n this.bottomRight().transform(m)\n );\n }\n\n expand(x, y = x) {\n\n this.size.width += 2 * x;\n this.size.height += 2 * y;\n\n this.origin.translate(-x, -y);\n\n return this;\n }\n\n expandCopy(x, y) {\n return this.clone().expand(x, y);\n }\n\n containsPoint(point) {\n const origin = this.origin;\n const bottomRight = this.bottomRight();\n return !(point.x < origin.x || point.y < origin.y || bottomRight.x < point.x || bottomRight.y < point.y);\n }\n\n _isOnPath(point, width) {\n const rectOuter = this.expandCopy(width, width);\n const rectInner = this.expandCopy(-width, -width);\n\n return rectOuter.containsPoint(point) && !rectInner.containsPoint(point);\n }\n\n static fromPoints() {\n const topLeft = Point.min.apply(null, arguments);\n const bottomRight = Point.max.apply(null, arguments);\n const size = new Size(\n bottomRight.x - topLeft.x,\n bottomRight.y - topLeft.y\n );\n\n return new Rect(topLeft, size);\n }\n\n static union(a, b) {\n return Rect.fromPoints(\n Point.min(a.topLeft(), b.topLeft()),\n Point.max(a.bottomRight(), b.bottomRight())\n );\n }\n\n static intersect(a, b) {\n const rect1 = {\n left: a.topLeft().x,\n top: a.topLeft().y,\n right: a.bottomRight().x,\n bottom: a.bottomRight().y\n };\n\n const rect2 = {\n left: b.topLeft().x,\n top: b.topLeft().y,\n right: b.bottomRight().x,\n bottom: b.bottomRight().y\n };\n\n if (rect1.left <= rect2.right &&\n rect2.left <= rect1.right &&\n rect1.top <= rect2.bottom &&\n rect2.top <= rect1.bottom) {\n return Rect.fromPoints(\n new Point(Math.max(rect1.left, rect2.left), Math.max(rect1.top, rect2.top)),\n new Point(Math.min(rect1.right, rect2.right), Math.min(rect1.bottom, rect2.bottom))\n );\n }\n }\n}\n\nexport default Rect;\n","import HasObservers from '../core/has-observers';\nimport Rect from './rect';\nimport Point from './point';\nimport transform from './transform';\nimport { deg, MIN_NUM, MAX_NUM } from '../util';\nimport isOutOfEndPoint from './math/is-out-of-end-point';\nimport calculateCurveAt from './math/calculate-curve-at';\nimport hasRootsInRange from './math/has-roots-in-range';\nimport curveIntersectionsCount from './math/curve-intersections-count';\nimport lineIntersectionsCount from './math/line-intersections-count';\nimport withPoints from '../mixins/with-points';\n\n\nconst points = [ \"anchor\", \"controlIn\", \"controlOut\" ];\n\nclass Segment extends withPoints(HasObservers, points) {\n constructor(anchor, controlIn, controlOut) {\n super();\n\n this.anchor(anchor || new Point());\n this.controlIn(controlIn);\n this.controlOut(controlOut);\n }\n\n bboxTo(toSegment, matrix) {\n const segmentAnchor = this.anchor().transformCopy(matrix);\n const toSegmentAnchor = toSegment.anchor().transformCopy(matrix);\n let rect;\n\n if (this.controlOut() && toSegment.controlIn()) {\n rect = this._curveBoundingBox(\n segmentAnchor, this.controlOut().transformCopy(matrix),\n toSegment.controlIn().transformCopy(matrix), toSegmentAnchor\n );\n } else {\n rect = this._lineBoundingBox(segmentAnchor, toSegmentAnchor);\n }\n\n return rect;\n }\n\n _lineBoundingBox(p1, p2) {\n return Rect.fromPoints(p1, p2);\n }\n\n _curveBoundingBox(p1, cp1, cp2, p2) {\n const points = [ p1, cp1, cp2, p2 ];\n const extremesX = this._curveExtremesFor(points, \"x\");\n const extremesY = this._curveExtremesFor(points, \"y\");\n const xLimits = arrayLimits([ extremesX.min, extremesX.max, p1.x, p2.x ]);\n const yLimits = arrayLimits([ extremesY.min, extremesY.max, p1.y, p2.y ]);\n\n return Rect.fromPoints(new Point(xLimits.min, yLimits.min), new Point(xLimits.max, yLimits.max));\n }\n\n _curveExtremesFor(points, field) {\n const extremes = this._curveExtremes(\n points[0][field], points[1][field],\n points[2][field], points[3][field]\n );\n\n return {\n min: calculateCurveAt(extremes.min, field, points),\n max: calculateCurveAt(extremes.max, field, points)\n };\n }\n\n _curveExtremes(x1, x2, x3, x4) {\n const a = x1 - 3 * x2 + 3 * x3 - x4;\n const b = - 2 * (x1 - 2 * x2 + x3);\n const c = x1 - x2;\n const sqrt = Math.sqrt(b * b - 4 * a * c);\n let t1 = 0;\n let t2 = 1;\n\n if (a === 0) {\n if (b !== 0) {\n t1 = t2 = -c / b;\n }\n } else if (!isNaN(sqrt)) {\n t1 = (- b + sqrt) / (2 * a);\n t2 = (- b - sqrt) / (2 * a);\n }\n\n let min = Math.max(Math.min(t1, t2), 0);\n if (min < 0 || min > 1) {\n min = 0;\n }\n\n let max = Math.min(Math.max(t1, t2), 1);\n if (max > 1 || max < 0) {\n max = 1;\n }\n\n return {\n min: min,\n max: max\n };\n }\n\n _intersectionsTo(segment, point) {\n let intersectionsCount;\n if (this.controlOut() && segment.controlIn()) {\n intersectionsCount = curveIntersectionsCount([ this.anchor(), this.controlOut(), segment.controlIn(), segment.anchor() ], point, this.bboxTo(segment));\n } else {\n intersectionsCount = lineIntersectionsCount(this.anchor(), segment.anchor(), point);\n }\n return intersectionsCount;\n }\n\n _isOnCurveTo(segment, point, width, endSegment) {\n const bbox = this.bboxTo(segment).expand(width, width);\n if (bbox.containsPoint(point)) {\n const p1 = this.anchor();\n const p2 = this.controlOut();\n const p3 = segment.controlIn();\n const p4 = segment.anchor();\n\n if (endSegment === \"start\" && p1.distanceTo(point) <= width) {\n return !isOutOfEndPoint(p1, p2, point);\n } else if (endSegment === \"end\" && p4.distanceTo(point) <= width) {\n return !isOutOfEndPoint(p4, p3, point);\n }\n\n //the approach is not entirely correct but is close and the alternatives are solving a 6th degree polynomial or testing the segment points\n const points = [ p1, p2, p3, p4 ];\n if (hasRootsInRange(points, point, \"x\", \"y\", width) || hasRootsInRange(points, point, \"y\", \"x\", width)) {\n return true;\n }\n const rotation = transform().rotate(45, point);\n const rotatedPoints = [ p1.transformCopy(rotation), p2.transformCopy(rotation), p3.transformCopy(rotation), p4.transformCopy(rotation) ];\n return hasRootsInRange(rotatedPoints, point, \"x\", \"y\", width) || hasRootsInRange(rotatedPoints, point, \"y\", \"x\", width);\n }\n }\n\n _isOnLineTo(segment, point, width) {\n const p1 = this.anchor();\n const p2 = segment.anchor();\n const angle = deg(Math.atan2(p2.y - p1.y, p2.x - p1.x));\n const rect = new Rect([ p1.x, p1.y - width / 2 ], [ p1.distanceTo(p2), width ]);\n return rect.containsPoint(point.transformCopy(transform().rotate(-angle, p1)));\n }\n\n _isOnPathTo(segment, point, width, endSegment) {\n let isOnPath;\n if (this.controlOut() && segment.controlIn()) {\n isOnPath = this._isOnCurveTo(segment, point, width / 2, endSegment);\n } else {\n isOnPath = this._isOnLineTo(segment, point, width);\n }\n return isOnPath;\n }\n}\n\nfunction arrayLimits(arr) {\n let length = arr.length;\n let min = MAX_NUM;\n let max = MIN_NUM;\n\n for (let i = 0; i < length; i ++) {\n max = Math.max(max, arr[i]);\n min = Math.min(min, arr[i]);\n }\n\n return {\n min: min,\n max: max\n };\n}\n\nexport default Segment;\n","import HasObservers from '../core/has-observers';\nimport withAccessors from '../mixins/with-accessors';\nimport { defined, round } from '../util';\n\n\nclass Size extends withAccessors(HasObservers, [ \"width\", \"height\" ]) {\n constructor(width, height) {\n super();\n\n this.width = width || 0;\n this.height = height || 0;\n }\n\n equals(other) {\n return other && other.width === this.width && other.height === this.height;\n }\n\n clone() {\n return new Size(this.width, this.height);\n }\n\n toArray(digits) {\n const doRound = defined(digits);\n const width = doRound ? round(this.width, digits) : this.width;\n const height = doRound ? round(this.height, digits) : this.height;\n\n return [ width, height ];\n }\n\n static create(arg0, arg1) {\n if (defined(arg0)) {\n if (arg0 instanceof Size) {\n return arg0;\n } else if (arguments.length === 1 && arg0.length === 2) {\n return new Size(arg0[0], arg0[1]);\n }\n\n return new Size(arg0, arg1);\n }\n }\n\n static get ZERO() {\n return new Size(0, 0);\n }\n}\n\nexport default Size;\n","export default function toMatrix(transformation) {\n if (transformation && typeof transformation.matrix === \"function\") {\n return transformation.matrix();\n }\n\n return transformation;\n}","import Transformation from './transformation';\n\nexport default function transform(matrix) {\n if (matrix === null) {\n return null;\n }\n\n if (matrix instanceof Transformation) {\n return matrix;\n }\n\n return new Transformation(matrix);\n}","import HasObservers from '../core/has-observers';\nimport toMatrix from './to-matrix';\nimport Matrix from './matrix';\nimport Point from './point';\n\nclass Transformation extends HasObservers {\n constructor(matrix = Matrix.unit()) {\n super();\n\n this._matrix = matrix;\n }\n\n clone() {\n return new Transformation(\n this._matrix.clone()\n );\n }\n\n equals(other) {\n return other &&\n other._matrix.equals(this._matrix);\n }\n\n translate(x, y) {\n this._matrix = this._matrix.multiplyCopy(Matrix.translate(x, y));\n\n this._optionsChange();\n return this;\n }\n\n scale(scaleX, scaleY = scaleX, origin = null) {\n let originPoint = origin;\n\n if (originPoint) {\n originPoint = Point.create(originPoint);\n this._matrix = this._matrix.multiplyCopy(Matrix.translate(originPoint.x, originPoint.y));\n }\n\n this._matrix = this._matrix.multiplyCopy(Matrix.scale(scaleX, scaleY));\n\n if (originPoint) {\n this._matrix = this._matrix.multiplyCopy(Matrix.translate(-originPoint.x, -originPoint.y));\n }\n\n this._optionsChange();\n return this;\n }\n\n rotate(angle, origin) {\n const originPoint = Point.create(origin) || Point.ZERO;\n\n this._matrix = this._matrix.multiplyCopy(Matrix.rotate(angle, originPoint.x, originPoint.y));\n\n this._optionsChange();\n return this;\n }\n\n multiply(transformation) {\n const matrix = toMatrix(transformation);\n\n this._matrix = this._matrix.multiplyCopy(matrix);\n\n this._optionsChange();\n return this;\n }\n\n matrix(value) {\n if (value) {\n this._matrix = value;\n this._optionsChange();\n return this;\n }\n\n return this._matrix;\n }\n\n _optionsChange() {\n this.optionsChange({\n field: \"transform\",\n value: this\n });\n }\n}\n\nexport default Transformation;\n","import OptionsStore from '../core/options-store';\nimport withOptions from '../mixins/with-options';\nimport HasObservers from '../core/has-observers';\nimport { defined } from '../util';\n\n\nconst options = [ \"offset\", \"color\", \"opacity\" ];\n\nclass GradientStop extends withOptions(HasObservers, options) {\n constructor(offset, color, opacity) {\n super();\n\n this.options = new OptionsStore({\n offset: offset,\n color: color,\n opacity: defined(opacity) ? opacity : 1\n });\n\n this.options.addObserver(this);\n }\n\n static create(arg) {\n if (defined(arg)) {\n let stop;\n if (arg instanceof GradientStop) {\n stop = arg;\n } else if (arg.length > 1) {\n stop = new GradientStop(arg[0], arg[1], arg[2]);\n } else {\n stop = new GradientStop(arg.offset, arg.color, arg.opacity);\n }\n\n return stop;\n }\n }\n}\n\nexport default GradientStop;\n","import StopsArray from './stops-array';\nimport GradientStop from './gradient-stop';\nimport HasObservers from '../core/has-observers';\nimport { defined, definitionId } from '../util';\n\nclass Gradient extends HasObservers {\n get nodeType() {\n return \"Gradient\";\n }\n\n constructor(options = {}) {\n super();\n\n this.stops = new StopsArray(this._createStops(options.stops));\n this.stops.addObserver(this);\n this._userSpace = options.userSpace;\n this.id = definitionId();\n }\n\n userSpace(value) {\n if (defined(value)) {\n this._userSpace = value;\n this.optionsChange();\n return this;\n }\n\n return this._userSpace;\n }\n\n _createStops(stops = []) {\n const result = [];\n for (let idx = 0; idx < stops.length; idx++) {\n result.push(GradientStop.create(stops[idx]));\n }\n\n return result;\n }\n\n addStop(offset, color, opacity) {\n this.stops.push(new GradientStop(offset, color, opacity));\n }\n\n removeStop(stop) {\n const index = this.stops.indexOf(stop);\n if (index >= 0) {\n this.stops.splice(index, 1);\n }\n }\n\n optionsChange(e) {\n this.trigger(\"optionsChange\", {\n field: \"gradient\" + (e ? \".\" + e.field : \"\"),\n value: this\n });\n }\n\n geometryChange() {\n this.optionsChange();\n }\n}\n\nexport default Gradient;\n","import withPoints from '../mixins/with-points';\nimport Point from '../geometry/point';\nimport Gradient from './gradient';\n\n\nconst points = [ \"start\", \"end\" ];\n\nclass LinearGradient extends withPoints(Gradient, points) {\n constructor(options = {}) {\n super(options);\n\n this.start(options.start || new Point());\n this.end(options.end || new Point(1, 0));\n }\n}\n\nexport default LinearGradient;\n","import withPoints from '../mixins/with-points';\nimport Point from '../geometry/point';\nimport Gradient from './gradient';\nimport { defined } from '../util';\n\n\nclass RadialGradient extends withPoints(Gradient, [ \"center\" ]) {\n constructor(options = {}) {\n super(options);\n\n this.center(options.center || new Point());\n this._radius = defined(options.radius) ? options.radius : 1;\n this._fallbackFill = options.fallbackFill;\n }\n\n radius(value) {\n if (defined(value)) {\n this._radius = value;\n this.geometryChange();\n return this;\n }\n\n return this._radius;\n }\n\n fallbackFill(value) {\n if (defined(value)) {\n this._fallbackFill = value;\n this.optionsChange();\n return this;\n }\n\n return this._fallbackFill;\n }\n}\n\nexport default RadialGradient;\n","import ElementsArray from '../shapes/elements-array';\n\nclass StopsArray extends ElementsArray {\n _change() {\n this.optionsChange({\n field: \"stops\"\n });\n }\n}\n\nexport default StopsArray;","import Matrix from '../geometry/matrix';\nimport toMatrix from '../geometry/to-matrix';\n\nconst IDENTITY_MATRIX_HASH = Matrix.IDENTITY.toString();\n\nconst measurable = TBase => (\n class extends TBase {\n bbox(transformation) {\n const combinedMatrix = toMatrix(this.currentTransform(transformation));\n const matrixHash = combinedMatrix ? combinedMatrix.toString() : IDENTITY_MATRIX_HASH;\n let bbox;\n\n if (this._bboxCache && this._matrixHash === matrixHash) {\n bbox = this._bboxCache.clone();\n } else {\n bbox = this._bbox(combinedMatrix);\n this._bboxCache = bbox ? bbox.clone() : null;\n this._matrixHash = matrixHash;\n }\n\n const strokeWidth = this.options.get(\"stroke.width\");\n if (strokeWidth && bbox) {\n bbox.expand(strokeWidth / 2);\n }\n\n return bbox;\n }\n\n geometryChange() {\n delete this._bboxCache;\n this.trigger(\"geometryChange\", {\n element: this\n });\n }\n }\n);\n\nexport default measurable;","import { defined } from '../util';\n\nconst GRADIENT = \"Gradient\";\n\nconst paintable = TBase => (\n class extends TBase {\n fill(color, opacity) {\n const options = this.options;\n\n if (defined(color)) {\n if (color && color.nodeType !== GRADIENT) {\n const newFill = {\n color: color\n };\n if (defined(opacity)) {\n newFill.opacity = opacity;\n }\n options.set(\"fill\", newFill);\n } else {\n options.set(\"fill\", color);\n }\n\n return this;\n }\n\n return options.get(\"fill\");\n }\n\n stroke(color, width, opacity) {\n if (defined(color)) {\n this.options.set(\"stroke.color\", color);\n\n if (defined(width)) {\n this.options.set(\"stroke.width\", width);\n }\n\n if (defined(opacity)) {\n this.options.set(\"stroke.opacity\", opacity);\n }\n\n return this;\n }\n\n return this.options.get(\"stroke\");\n }\n }\n);\n\nexport default paintable;\n","const traversable = (TBase, childrenField) => (\n class extends TBase {\n traverse(callback) {\n const children = this[childrenField];\n\n for (let i = 0; i < children.length; i++) {\n let child = children[i];\n\n if (child.traverse) {\n child.traverse(callback);\n } else {\n callback(child);\n }\n }\n\n return this;\n }\n }\n);\n\nexport default traversable;\n","function setAccessor(field) {\n return function(value) {\n if (this[field] !== value) {\n this[field] = value;\n this.geometryChange();\n }\n\n return this;\n };\n}\n\nfunction getAccessor(field) {\n return function() {\n return this[field];\n };\n}\n\nfunction defineAccessors(fn, fields) {\n for (let i = 0; i < fields.length; i++) {\n let name = fields[i];\n let capitalized = name.charAt(0).toUpperCase() +\n name.substring(1, name.length);\n\n fn[\"set\" + capitalized] = setAccessor(name);\n fn[\"get\" + capitalized] = getAccessor(name);\n }\n}\n\nconst withAccessors = (TBase, names) => {\n const result = class extends TBase {};\n defineAccessors(result.prototype, names);\n\n return result;\n};\n\nexport default withAccessors;\n","import { defined } from '../util';\n\nfunction geometryAccessor(name) {\n const fieldName = \"_\" + name;\n return function(value) {\n if (defined(value)) {\n this._observerField(fieldName, value);\n this.geometryChange();\n return this;\n }\n\n return this[fieldName];\n };\n}\n\nfunction defineGeometryAccessors(fn, names) {\n for (let i = 0; i < names.length; i++) {\n fn[names[i]] = geometryAccessor(names[i]);\n }\n}\n\nconst withGeometry = (TBase, names = [ \"geometry\" ]) => {\n const result = class extends TBase {};\n defineGeometryAccessors(result.prototype, names);\n\n return result;\n};\n\nexport default withGeometry;\n","import { defined } from '../util';\n\nfunction optionsAccessor(name) {\n return function(value) {\n if (defined(value)) {\n this.options.set(name, value);\n return this;\n }\n\n return this.options.get(name);\n };\n}\n\nfunction defineOptionsAccessors(fn, names) {\n for (let i = 0; i < names.length; i++) {\n fn[names[i]] = optionsAccessor(names[i]);\n }\n}\n\nconst withOptions = (TBase, names) => {\n const result = class extends TBase {};\n defineOptionsAccessors(result.prototype, names);\n\n return result;\n};\n\nexport default withOptions;\n","import { defined } from '../util';\nimport Point from '../geometry/point';\n\nfunction pointAccessor(name) {\n const fieldName = \"_\" + name;\n return function(value) {\n if (defined(value)) {\n this._observerField(fieldName, Point.create(value));\n this.geometryChange();\n return this;\n }\n\n return this[fieldName];\n };\n}\n\nfunction definePointAccessors(fn, names) {\n for (let i = 0; i < names.length; i++) {\n fn[names[i]] = pointAccessor(names[i]);\n }\n}\n\nconst withPoints = (TBase, names) => {\n const result = class extends TBase {};\n definePointAccessors(result.prototype, names);\n\n return result;\n};\n\nexport default withPoints;\n","import Point from '../geometry/point';\nimport ShapeMap from './shape-map';\n\nconst SEGMENT_REGEX = /([a-df-z]{1})([^a-df-z]*)(z)?/gi;\nconst SPLIT_REGEX = /[,\\s]?([+\\-]?(?:\\d*\\.\\d+|\\d+)(?:[eE][+\\-]?\\d+)?)/g;\nconst MOVE = \"m\";\nconst CLOSE = \"z\";\n\nfunction parseParameters(str) {\n const parameters = [];\n str.replace(SPLIT_REGEX, function(match, number) {\n parameters.push(parseFloat(number));\n });\n return parameters;\n}\n\nfunction parsePath(pathInstance, str) {\n const position = new Point();\n let previousCommand;\n\n str.replace(SEGMENT_REGEX, (match, element, params, closePath) => {\n let command = element.toLowerCase();\n const isRelative = command === element;\n const parameters = parseParameters(params.trim());\n\n if (command === MOVE) {\n if (isRelative) {\n position.x += parameters[0];\n position.y += parameters[1];\n } else {\n position.x = parameters[0];\n position.y = parameters[1];\n }\n\n pathInstance.moveTo(position.x, position.y);\n\n if (parameters.length > 2) {\n command = \"l\";\n parameters.splice(0, 2);\n }\n }\n\n if (ShapeMap[command]) {\n ShapeMap[command](\n pathInstance, {\n parameters: parameters,\n position: position,\n isRelative: isRelative,\n previousCommand: previousCommand\n }\n );\n\n if (closePath && closePath.toLowerCase() === CLOSE) {\n pathInstance.close();\n }\n } else if (command !== MOVE) {\n throw new Error(\"Error while parsing SVG path. Unsupported command: \" + command);\n }\n\n previousCommand = command;\n });\n\n return pathInstance;\n}\n\nexport default parsePath;\n\n","import Point from '../geometry/point';\nimport { last } from '../util';\n\nconst ShapeMap = {\n l: function(path, options) {\n const { parameters, position } = options;\n\n for (let i = 0; i < parameters.length; i += 2) {\n let point = new Point(parameters[i], parameters[i + 1]);\n\n if (options.isRelative) {\n point.translateWith(position);\n }\n\n path.lineTo(point.x, point.y);\n\n position.x = point.x;\n position.y = point.y;\n }\n },\n\n c: function(path, options) {\n const { parameters, position } = options;\n\n for (let i = 0; i < parameters.length; i += 6) {\n let controlOut = new Point(parameters[i], parameters[i + 1]);\n let controlIn = new Point(parameters[i + 2], parameters[i + 3]);\n let point = new Point(parameters[i + 4], parameters[i + 5]);\n if (options.isRelative) {\n controlIn.translateWith(position);\n controlOut.translateWith(position);\n point.translateWith(position);\n }\n\n path.curveTo(controlOut, controlIn, point);\n\n position.x = point.x;\n position.y = point.y;\n }\n },\n\n v: function(path, options) {\n const value = options.isRelative ? 0 : options.position.x;\n\n toLineParamaters(options.parameters, true, value);\n this.l(path, options);\n },\n\n h: function(path, options) {\n const value = options.isRelative ? 0 : options.position.y;\n\n toLineParamaters(options.parameters, false, value);\n this.l(path, options);\n },\n\n a: function(path, options) {\n const { parameters, position } = options;\n\n for (let i = 0; i < parameters.length; i += 7) {\n const radiusX = parameters[i];\n const radiusY = parameters[i + 1];\n const rotation = parameters[i + 2];\n const largeArc = parameters[i + 3];\n const swipe = parameters[i + 4];\n const endPoint = new Point(parameters[i + 5], parameters[i + 6]);\n\n if (options.isRelative) {\n endPoint.translateWith(position);\n }\n if (position.x !== endPoint.x || position.y !== endPoint.y) {\n path.arcTo(endPoint, radiusX, radiusY, largeArc, swipe, rotation);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n }\n },\n\n s: function(path, options) {\n const { parameters, position, previousCommand } = options;\n let lastControlIn;\n\n if (previousCommand === \"s\" || previousCommand === \"c\") {\n lastControlIn = last(last(path.paths).segments).controlIn();\n }\n\n for (let i = 0; i < parameters.length; i += 4) {\n let controlIn = new Point(parameters[i], parameters[i + 1]);\n let endPoint = new Point(parameters[i + 2], parameters[i + 3]);\n let controlOut;\n\n if (options.isRelative) {\n controlIn.translateWith(position);\n endPoint.translateWith(position);\n }\n\n if (lastControlIn) {\n controlOut = reflectionPoint(lastControlIn, position);\n } else {\n controlOut = position.clone();\n }\n\n lastControlIn = controlIn;\n\n path.curveTo(controlOut, controlIn, endPoint);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n },\n\n q: function(path, options) {\n const { parameters, position } = options;\n\n for (let i = 0; i < parameters.length; i += 4) {\n let controlPoint = new Point(parameters[i], parameters[i + 1]);\n let endPoint = new Point(parameters[i + 2], parameters[i + 3]);\n\n if (options.isRelative) {\n controlPoint.translateWith(position);\n endPoint.translateWith(position);\n }\n\n let cubicControlPoints = quadraticToCubicControlPoints(position, controlPoint, endPoint);\n\n path.curveTo(cubicControlPoints.controlOut, cubicControlPoints.controlIn, endPoint);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n },\n\n t: function(path, options) {\n const { parameters, position, previousCommand } = options;\n let controlPoint;\n\n if (previousCommand === \"q\" || previousCommand === \"t\") {\n let lastSegment = last(last(path.paths).segments);\n controlPoint = lastSegment.controlIn().clone()\n .translateWith(position.scaleCopy(-1 / 3))\n .scale(3 / 2);\n }\n\n for (let i = 0; i < parameters.length; i += 2) {\n let endPoint = new Point(parameters[i], parameters[i + 1]);\n if (options.isRelative) {\n endPoint.translateWith(position);\n }\n\n if (controlPoint) {\n controlPoint = reflectionPoint(controlPoint, position);\n } else {\n controlPoint = position.clone();\n }\n\n let cubicControlPoints = quadraticToCubicControlPoints(position, controlPoint, endPoint);\n\n path.curveTo(cubicControlPoints.controlOut, cubicControlPoints.controlIn, endPoint);\n\n position.x = endPoint.x;\n position.y = endPoint.y;\n }\n }\n};\n\nfunction toLineParamaters(parameters, isVertical, value) {\n const insertPosition = isVertical ? 0 : 1;\n\n for (let i = 0; i < parameters.length; i += 2) {\n parameters.splice(i + insertPosition, 0, value);\n }\n}\n\nfunction reflectionPoint(point, center) {\n if (point && center) {\n return center.scaleCopy(2).translate(-point.x, -point.y);\n }\n}\n\nconst third = 1 / 3;\n\nfunction quadraticToCubicControlPoints(position, controlPoint, endPoint) {\n const scaledPoint = controlPoint.clone().scale(2 / 3);\n return {\n controlOut: scaledPoint.clone().translateWith(position.scaleCopy(third)),\n controlIn: scaledPoint.translateWith(endPoint.scaleCopy(third))\n };\n}\n\nexport default ShapeMap;","import QuadRoot from './quad-root';\nimport { Rect } from '../geometry';\nimport { append } from '../util';\n\nclass QuadNode extends QuadRoot {\n constructor(rect) {\n super();\n this.children = [];\n this.rect = rect;\n }\n\n inBounds(rect) {\n const nodeRect = this.rect;\n const nodeBottomRight = nodeRect.bottomRight();\n const bottomRight = rect.bottomRight();\n const inBounds = nodeRect.origin.x <= rect.origin.x && nodeRect.origin.y <= rect.origin.y && bottomRight.x <= nodeBottomRight.x &&\n bottomRight.y <= nodeBottomRight.y;\n return inBounds;\n }\n\n pointShapes(point) {\n const children = this.children;\n const length = children.length;\n const result = super.pointShapes(point);\n for (let idx = 0; idx < length; idx++) {\n append(result, children[idx].pointShapes(point));\n }\n return result;\n }\n\n insert(shape, bbox) {\n const children = this.children;\n let inserted = false;\n\n if (this.inBounds(bbox)) {\n if (this.shapes.length < 4) {\n this._add(shape, bbox);\n } else {\n if (!children.length) {\n this._initChildren();\n }\n\n for (let idx = 0; idx < children.length; idx++) {\n if (children[idx].insert(shape, bbox)) {\n inserted = true;\n break;\n }\n }\n\n if (!inserted) {\n this._add(shape, bbox);\n }\n }\n inserted = true;\n }\n\n return inserted;\n }\n\n _initChildren() {\n const { rect, children } = this;\n const center = rect.center();\n const halfWidth = rect.width() / 2;\n const halfHeight = rect.height() / 2;\n\n children.push(\n new QuadNode(new Rect([ rect.origin.x, rect.origin.y ], [ halfWidth, halfHeight ])),\n new QuadNode(new Rect([ center.x, rect.origin.y ], [ halfWidth, halfHeight ])),\n new QuadNode(new Rect([ rect.origin.x, center.y ], [ halfWidth, halfHeight ])),\n new QuadNode(new Rect([ center.x, center.y ], [ halfWidth, halfHeight ]))\n );\n }\n}\n\nexport default QuadNode;","import { Class } from '../common';\n\nclass QuadRoot extends Class {\n constructor() {\n super();\n\n this.shapes = [];\n }\n\n _add(shape, bbox) {\n this.shapes.push({\n bbox: bbox,\n shape: shape\n });\n shape._quadNode = this;\n }\n\n pointShapes(point) {\n const shapes = this.shapes;\n const length = shapes.length;\n const result = [];\n for (let idx = 0; idx < length; idx++) {\n if (shapes[idx].bbox.containsPoint(point)) {\n result.push(shapes[idx].shape);\n }\n }\n return result;\n }\n\n insert(shape, bbox) {\n this._add(shape, bbox);\n }\n\n remove(shape) {\n const shapes = this.shapes;\n const length = shapes.length;\n\n for (let idx = 0; idx < length; idx++) {\n if (shapes[idx].shape === shape) {\n shapes.splice(idx, 1);\n break;\n }\n }\n }\n}\n\nexport default QuadRoot;","import QuadRoot from './quad-root';\nimport QuadNode from './quad-node';\nimport { Rect } from '../geometry';\nimport { Class } from '../common';\nimport { append } from '../util';\n\nconst ROOT_SIZE = 3000;\nconst LEVEL_STEP = 10000;\nconst MAX_LEVEL = 75;\n\nclass ShapesQuadTree extends Class {\n\n constructor() {\n super();\n\n this.initRoots();\n }\n\n initRoots() {\n this.rootMap = {};\n this.root = new QuadRoot();\n this.rootElements = [];\n }\n\n clear() {\n const rootElements = this.rootElements;\n for (let idx = 0; idx < rootElements.length; idx++) {\n this.remove(rootElements[idx]);\n }\n this.initRoots();\n }\n\n pointShape(point) {\n const sectorRoot = ( this.rootMap[ Math.floor( point.x / ROOT_SIZE ) ] || {} )[ Math.floor( point.y / ROOT_SIZE ) ];\n let result = this.root.pointShapes(point);\n\n if (sectorRoot) {\n result = result.concat(sectorRoot.pointShapes(point));\n }\n\n this.assignZindex(result);\n\n result.sort(zIndexComparer);\n for (let idx = 0; idx < result.length; idx++) {\n if (result[idx].containsPoint(point)) {\n return result[idx];\n }\n }\n }\n\n assignZindex(elements) {\n for (let idx = 0; idx < elements.length; idx++) {\n let element = elements[idx];\n let zIndex = 0;\n let levelWeight = Math.pow(LEVEL_STEP, MAX_LEVEL);\n let parents = [];\n\n while (element) {\n parents.push(element);\n element = element.parent;\n }\n\n while (parents.length) {\n element = parents.pop();\n zIndex += ((element.parent ? element.parent.children : this.rootElements).indexOf(element) + 1) * levelWeight;\n levelWeight /= LEVEL_STEP;\n }\n\n elements[idx]._zIndex = zIndex;\n }\n }\n\n optionsChange(e) {\n if (e.field === \"transform\" || e.field === \"stroke.width\") {\n this.bboxChange(e.element);\n }\n }\n\n geometryChange(e) {\n this.bboxChange(e.element);\n }\n\n bboxChange(element) {\n if (element.nodeType === \"Group\") {\n for (let idx = 0; idx < element.children.length; idx++) {\n this.bboxChange(element.children[idx]);\n }\n } else {\n if (element._quadNode) {\n element._quadNode.remove(element);\n }\n this._insertShape(element);\n }\n }\n\n add(elements) {\n const elementsArray = Array.isArray(elements) ? elements.slice(0) : [ elements ];\n\n append(this.rootElements, elementsArray);\n this._insert(elementsArray);\n }\n\n childrenChange(e) {\n if (e.action === \"remove\") {\n for (let idx = 0; idx < e.items.length; idx++) {\n this.remove(e.items[idx]);\n }\n } else {\n this._insert(Array.prototype.slice.call(e.items, 0));\n }\n }\n\n _insert(elements) {\n let element;\n\n while (elements.length > 0) {\n element = elements.pop();\n element.addObserver(this);\n if (element.nodeType === \"Group\") {\n append(elements, element.children);\n } else {\n this._insertShape(element);\n }\n }\n }\n\n _insertShape(shape) {\n const bbox = shape.bbox();\n if (bbox) {\n const sectors = this.getSectors(bbox);\n const x = sectors[0][0];\n const y = sectors[1][0];\n\n if (this.inRoot(sectors)) {\n this.root.insert(shape, bbox);\n } else {\n const rootMap = this.rootMap;\n if (!rootMap[x]) {\n rootMap[x] = {};\n }\n\n if (!rootMap[x][y]) {\n rootMap[x][y] = new QuadNode(\n new Rect([ x * ROOT_SIZE, y * ROOT_SIZE ], [ ROOT_SIZE, ROOT_SIZE ])\n );\n }\n\n rootMap[x][y].insert(shape, bbox);\n }\n }\n }\n\n remove(element) {\n element.removeObserver(this);\n\n if (element.nodeType === \"Group\") {\n const children = element.children;\n for (let idx = 0; idx < children.length; idx++) {\n this.remove(children[idx]);\n }\n } else if (element._quadNode) {\n element._quadNode.remove(element);\n delete element._quadNode;\n }\n }\n\n inRoot(sectors) {\n return sectors[0].length > 1 || sectors[1].length > 1;\n }\n\n getSectors(rect) {\n const bottomRight = rect.bottomRight();\n const bottomX = Math.floor(bottomRight.x / ROOT_SIZE);\n const bottomY = Math.floor(bottomRight.y / ROOT_SIZE);\n const sectors = [ [], [] ];\n for (let x = Math.floor(rect.origin.x / ROOT_SIZE); x <= bottomX; x++) {\n sectors[0].push(x);\n }\n for (let y = Math.floor(rect.origin.y / ROOT_SIZE); y <= bottomY; y++) {\n sectors[1].push(y);\n }\n return sectors;\n }\n}\n\nfunction zIndexComparer(x1, x2) {\n if (x1._zIndex < x2._zIndex) {\n return 1;\n }\n if (x1._zIndex > x2._zIndex) {\n return -1;\n }\n\n return 0;\n}\n\nexport default ShapesQuadTree;","import OptionsStore from '../core/options-store';\nimport Rect from '../geometry/rect';\nimport Matrix from '../geometry/matrix';\nimport createTransform from '../geometry/transform';\nimport toMatrix from '../geometry/to-matrix';\nimport HasObservers from '../core/has-observers';\nimport { defined, definitionId, isTransparent, valueOrDefault } from '../util';\n\nclass Element extends HasObservers {\n get nodeType() {\n return \"Rect\";\n }\n\n constructor(options) {\n super();\n\n this._initOptions(options);\n }\n\n _initOptions(options = {}) {\n const { clip, transform } = options;\n\n if (transform) {\n options.transform = createTransform(transform);\n }\n\n if (clip && !clip.id) {\n clip.id = definitionId();\n }\n\n this.options = new OptionsStore(options);\n this.options.addObserver(this);\n }\n\n transform(value) {\n if (defined(value)) {\n this.options.set(\"transform\", createTransform(value));\n } else {\n return this.options.get(\"transform\");\n }\n }\n\n parentTransform() {\n let element = this;\n let parentMatrix;\n\n while (element.parent) {\n element = element.parent;\n let transformation = element.transform();\n if (transformation) {\n parentMatrix = transformation.matrix().multiplyCopy(parentMatrix || Matrix.unit());\n }\n }\n\n if (parentMatrix) {\n return createTransform(parentMatrix);\n }\n }\n\n currentTransform(parentTransform = this.parentTransform()) {\n const elementTransform = this.transform();\n const elementMatrix = toMatrix(elementTransform);\n\n let parentMatrix = toMatrix(parentTransform);\n let combinedMatrix;\n\n if (elementMatrix && parentMatrix) {\n combinedMatrix = parentMatrix.multiplyCopy(elementMatrix);\n } else {\n combinedMatrix = elementMatrix || parentMatrix;\n }\n\n if (combinedMatrix) {\n return createTransform(combinedMatrix);\n }\n }\n\n visible(value) {\n if (defined(value)) {\n this.options.set(\"visible\", value);\n return this;\n }\n\n return this.options.get(\"visible\") !== false;\n }\n\n clip(value) {\n const options = this.options;\n if (defined(value)) {\n if (value && !value.id) {\n value.id = definitionId();\n }\n options.set(\"clip\", value);\n return this;\n }\n\n return options.get(\"clip\");\n }\n\n opacity(value) {\n if (defined(value)) {\n this.options.set(\"opacity\", value);\n return this;\n }\n\n return valueOrDefault(this.options.get(\"opacity\"), 1);\n }\n\n className(value) {\n if (defined(value)) {\n this.options.set(\"className\", value);\n return this;\n }\n\n return this.options.get(\"className\");\n }\n\n clippedBBox(transformation) {\n const bbox = this._clippedBBox(transformation);\n if (bbox) {\n const clip = this.clip();\n return clip ? Rect.intersect(bbox, clip.bbox(transformation)) : bbox;\n }\n }\n\n containsPoint(point, parentTransform) {\n if (this.visible()) {\n const transform = this.currentTransform(parentTransform);\n let transformedPoint = point;\n if (transform) {\n transformedPoint = point.transformCopy(transform.matrix().invert());\n }\n return (this._hasFill() && this._containsPoint(transformedPoint)) || (this._isOnPath && this._hasStroke() && this._isOnPath(transformedPoint));\n }\n return false;\n }\n\n _hasFill() {\n const fill = this.options.fill;\n return fill && !isTransparent(fill.color);\n }\n\n _hasStroke() {\n const stroke = this.options.stroke;\n return stroke && stroke.width > 0 && !isTransparent(stroke.color);\n }\n\n _clippedBBox(transformation) {\n return this.bbox(transformation);\n }\n}\n\nexport default Element;\n","import HasObservers from '../core/has-observers';\n\nconst push = [].push;\nconst pop = [].pop;\nconst splice = [].splice;\nconst shift = [].shift;\nconst slice = [].slice;\nconst unshift = [].unshift;\n\nclass ElementsArray extends HasObservers {\n constructor(array = []) {\n super();\n\n this.length = 0;\n this._splice(0, array.length, array);\n }\n\n elements(value) {\n if (value) {\n this._splice(0, this.length, value);\n\n this._change();\n return this;\n }\n\n return this.slice(0);\n }\n\n push() {\n const elements = arguments;\n const result = push.apply(this, elements);\n\n this._add(elements);\n\n return result;\n }\n\n slice() {\n return slice.call(this);\n }\n\n pop() {\n const length = this.length;\n const result = pop.apply(this);\n\n if (length) {\n this._remove([ result ]);\n }\n\n return result;\n }\n\n splice(index, howMany) {\n const elements = slice.call(arguments, 2);\n const result = this._splice(index, howMany, elements);\n\n this._change();\n\n return result;\n }\n\n shift() {\n const length = this.length;\n const result = shift.apply(this);\n\n if (length) {\n this._remove([ result ]);\n }\n\n return result;\n }\n\n unshift() {\n const elements = arguments;\n const result = unshift.apply(this, elements);\n\n this._add(elements);\n\n return result;\n }\n\n indexOf(element) {\n const length = this.length;\n\n for (let idx = 0; idx < length; idx++) {\n if (this[idx] === element) {\n return idx;\n }\n }\n return -1;\n }\n\n _splice(index, howMany, elements) {\n const result = splice.apply(this, [ index, howMany ].concat(elements));\n\n this._clearObserver(result);\n this._setObserver(elements);\n\n return result;\n }\n\n _add(elements) {\n this._setObserver(elements);\n this._change();\n }\n\n _remove(elements) {\n this._clearObserver(elements);\n this._change();\n }\n\n _setObserver(elements) {\n for (let idx = 0; idx < elements.length; idx++) {\n elements[idx].addObserver(this);\n }\n }\n\n _clearObserver(elements) {\n for (let idx = 0; idx < elements.length; idx++) {\n elements[idx].removeObserver(this);\n }\n }\n\n _change() {}\n}\n\nexport default ElementsArray;\n","import ElementsArray from './elements-array';\n\nclass GeometryElementsArray extends ElementsArray {\n _change() {\n this.geometryChange();\n }\n}\n\nexport default GeometryElementsArray;","import Element from './element';\nimport traversable from '../mixins/traversable';\nimport { append } from '../util';\nimport elementsBoundingBox from './utils/elements-bounding-box';\nimport elementsClippedBoundingBox from './utils/elements-clippend-bounding-box';\n\n\nclass Group extends traversable(Element, \"children\") {\n get nodeType() {\n return \"Group\";\n }\n\n constructor(options) {\n super(options);\n this.children = [];\n }\n\n childrenChange(action, items, index) {\n this.trigger(\"childrenChange\",{\n action: action,\n items: items,\n index: index\n });\n }\n\n append() {\n append(this.children, arguments);\n this._reparent(arguments, this);\n\n this.childrenChange(\"add\", arguments);\n\n return this;\n }\n\n insert(index, element) {\n this.children.splice(index, 0, element);\n element.parent = this;\n\n this.childrenChange(\"add\", [ element ], index);\n\n return this;\n }\n\n insertAt(element, index) {\n return this.insert(index, element);\n }\n\n remove(element) {\n const index = this.children.indexOf(element);\n if (index >= 0) {\n this.children.splice(index, 1);\n element.parent = null;\n this.childrenChange(\"remove\", [ element ], index);\n }\n\n return this;\n }\n\n removeAt(index) {\n if (0 <= index && index < this.children.length) {\n let element = this.children[index];\n this.children.splice(index, 1);\n element.parent = null;\n this.childrenChange(\"remove\", [ element ], index);\n }\n\n return this;\n }\n\n clear() {\n const items = this.children;\n this.children = [];\n this._reparent(items, null);\n\n this.childrenChange(\"remove\", items, 0);\n\n return this;\n }\n\n bbox(transformation) {\n return elementsBoundingBox(this.children, true, this.currentTransform(transformation));\n }\n\n rawBBox() {\n return elementsBoundingBox(this.children, false);\n }\n\n _clippedBBox(transformation) {\n return elementsClippedBoundingBox(this.children, this.currentTransform(transformation));\n }\n\n currentTransform(transformation) {\n return Element.prototype.currentTransform.call(this, transformation) || null;\n }\n\n containsPoint(point, parentTransform) {\n if (this.visible()) {\n const children = this.children;\n const transform = this.currentTransform(parentTransform);\n for (let idx = 0; idx < children.length; idx++) {\n if (children[idx].containsPoint(point, transform)) {\n return true;\n }\n }\n }\n return false;\n }\n\n _reparent(elements, newParent) {\n for (let i = 0; i < elements.length; i++) {\n const child = elements[i];\n const parent = child.parent;\n if (parent && parent !== this && parent.remove) {\n parent.remove(child);\n }\n\n child.parent = newParent;\n }\n }\n}\n\nexport default Group;","import withGeometry from '../mixins/with-geometry';\nimport Element from './element';\nimport Rect from '../geometry/rect';\nimport toMatrix from '../geometry/to-matrix';\nimport { defined } from '../util';\n\n\nclass Image extends withGeometry(Element, [ \"rect\" ]) {\n get nodeType() {\n return \"Image\";\n }\n\n constructor(src, rect = new Rect(), options = {}) {\n super(options);\n\n this.src(src);\n this.rect(rect);\n }\n\n src(value) {\n if (defined(value)) {\n this.options.set(\"src\", value);\n return this;\n }\n\n return this.options.get(\"src\");\n }\n\n bbox(transformation) {\n const combinedMatrix = toMatrix(this.currentTransform(transformation));\n return this._rect.bbox(combinedMatrix);\n }\n\n rawBBox() {\n return this._rect.bbox();\n }\n\n _containsPoint(point) {\n return this._rect.containsPoint(point);\n }\n\n _hasFill() {\n return this.src();\n }\n}\n\nexport default Image;","import GeometryElementsArray from './geometry-elements-array';\nimport Element from './element';\nimport { pointsToCurve } from './utils/points-to-curve';\nimport paintable from '../mixins/paintable';\nimport measurable from '../mixins/measurable';\nimport Arc from '../geometry/arc';\nimport Rect from '../geometry/rect';\nimport Segment from '../geometry/segment';\nimport Point from '../geometry/point';\nimport Size from '../geometry/size';\nimport lineIntersectionsCount from '../geometry/math/line-intersections-count';\nimport { defined, last, rad } from '../util';\nimport parsePath from '../parsing/parse-path';\nimport elementsBoundingBox from './utils/elements-bounding-box';\nimport elementsClippedBoundingBox from './utils/elements-clippend-bounding-box';\nimport limitValue from '../util/limit-value';\n\nconst SPACE = ' ';\nconst printPoints = (precision) => (...points) => points.map(p => p.toString(precision)).join(SPACE);\nconst segmentType = (segmentStart, segmentEnd) => segmentStart.controlOut() && segmentEnd.controlIn() ? 'C' : 'L';\n\nexport class Path extends paintable(measurable(Element)) {\n get nodeType() {\n return 'Path';\n }\n\n constructor(options) {\n super(options);\n this.segments = new GeometryElementsArray();\n this.segments.addObserver(this);\n\n if (!defined(this.options.stroke)) {\n this.stroke('#000');\n\n if (!defined(this.options.stroke.lineJoin)) {\n this.options.set('stroke.lineJoin', 'miter');\n }\n }\n }\n\n moveTo(x, y) {\n this.suspend();\n this.segments.elements([]);\n this.resume();\n\n this.lineTo(x, y);\n\n return this;\n }\n\n lineTo(x, y) {\n const point = defined(y) ? new Point(x, y) : x;\n const segment = new Segment(point);\n\n this.segments.push(segment);\n\n return this;\n }\n\n curveTo(controlOut, controlIn, point) {\n if (this.segments.length > 0) {\n const lastSegment = last(this.segments);\n const segment = new Segment(point, controlIn);\n this.suspend();\n lastSegment.controlOut(controlOut);\n this.resume();\n\n this.segments.push(segment);\n }\n\n return this;\n }\n\n arc(startAngle, endAngle, radiusX, radiusY, anticlockwise) {\n if (this.segments.length > 0) {\n const lastSegment = last(this.segments);\n const anchor = lastSegment.anchor();\n const start = rad(startAngle);\n const center = new Point(anchor.x - radiusX * Math.cos(start),\n anchor.y - radiusY * Math.sin(start));\n const arc = new Arc(center, {\n startAngle: startAngle,\n endAngle: endAngle,\n radiusX: radiusX,\n radiusY: radiusY,\n anticlockwise: anticlockwise\n });\n\n this._addArcSegments(arc);\n }\n\n return this;\n }\n\n arcTo(end, rx, ry, largeArc, swipe, rotation) {\n if (this.segments.length > 0) {\n const lastSegment = last(this.segments);\n const anchor = lastSegment.anchor();\n const arc = Arc.fromPoints(anchor, Point.create(end), rx, ry, largeArc, swipe, rotation);\n\n this._addArcSegments(arc);\n }\n return this;\n }\n\n _addArcSegments(arc) {\n this.suspend();\n\n const curvePoints = arc.curvePoints();\n\n for (let i = 1; i < curvePoints.length; i += 3) {\n this.curveTo(curvePoints[i], curvePoints[i + 1], curvePoints[i + 2]);\n }\n\n this.resume();\n this.geometryChange();\n }\n\n close() {\n this.options.closed = true;\n this.geometryChange();\n\n return this;\n }\n\n rawBBox() {\n return this._bbox();\n }\n\n toString(digits) {\n let output = '';\n\n const segments = this.segments;\n const length = segments.length;\n if (length > 0) {\n const parts = [];\n const print = printPoints(digits);\n let currentType;\n\n for (let i = 1; i < length; i++) {\n let type = segmentType(segments[i - 1], segments[i]);\n if (type !== currentType) {\n currentType = type;\n parts.push(type);\n }\n\n if (type === 'L') {\n parts.push(print(segments[i].anchor()));\n } else {\n parts.push(print(\n segments[i - 1].controlOut(), segments[i].controlIn(), segments[i].anchor()\n ));\n }\n }\n\n output = 'M' + print(segments[0].anchor()) + SPACE + parts.join(SPACE);\n if (this.options.closed) {\n output += 'Z';\n }\n }\n\n return output;\n }\n\n _containsPoint(point) {\n const segments = this.segments;\n const length = segments.length;\n let intersectionsCount = 0;\n let previous, current;\n\n for (let idx = 1; idx < length; idx++) {\n previous = segments[idx - 1];\n current = segments[idx];\n intersectionsCount += previous._intersectionsTo(current, point);\n }\n\n if (this.options.closed || !segments[0].anchor().equals(segments[length - 1].anchor())) {\n intersectionsCount += lineIntersectionsCount(segments[0].anchor(), segments[length - 1].anchor(), point);\n }\n\n return intersectionsCount % 2 !== 0;\n }\n\n _isOnPath(point, width) {\n const segments = this.segments;\n const length = segments.length;\n const pathWidth = width || this.options.stroke.width;\n\n if (length > 1) {\n if (segments[0]._isOnPathTo(segments[1], point, pathWidth, 'start')) {\n return true;\n }\n\n for (let idx = 2; idx <= length - 2; idx++) {\n if (segments[idx - 1]._isOnPathTo(segments[idx], point, pathWidth)) {\n return true;\n }\n }\n\n if (segments[length - 2]._isOnPathTo(segments[length - 1], point, pathWidth, 'end')) {\n return true;\n }\n }\n return false;\n }\n\n _bbox(matrix) {\n const segments = this.segments;\n const length = segments.length;\n let boundingBox;\n\n if (length === 1) {\n let anchor = segments[0].anchor().transformCopy(matrix);\n boundingBox = new Rect(anchor, Size.ZERO);\n } else if (length > 0) {\n for (let i = 1; i < length; i++) {\n let segmentBox = segments[i - 1].bboxTo(segments[i], matrix);\n if (boundingBox) {\n boundingBox = Rect.union(boundingBox, segmentBox);\n } else {\n boundingBox = segmentBox;\n }\n }\n }\n\n return boundingBox;\n }\n\n static parse(str, options) {\n return MultiPath.parse(str, options);\n }\n\n static fromRect(rect, options) {\n const path = new Path(options);\n let [ rx, ry ] = rect.cornerRadius;\n\n if (rx === 0 && ry === 0) {\n path.moveTo(rect.topLeft())\n .lineTo(rect.topRight())\n .lineTo(rect.bottomRight())\n .lineTo(rect.bottomLeft())\n .close();\n } else {\n const origin = rect.origin;\n const { x, y } = origin;\n const width = rect.width();\n const height = rect.height();\n rx = limitValue(rx, 0, width / 2);\n ry = limitValue(ry, 0, height / 2);\n\n path.moveTo(x + rx, y)\n .lineTo(x + width - rx, y)\n .arcTo([ x + width, y + ry ], rx, ry, false)\n .lineTo(x + width, y + height - ry)\n .arcTo([ x + width - rx, y + height ], rx, ry, false)\n .lineTo(x + rx, y + height)\n .arcTo([ x, y + height - ry ], rx, ry, false)\n .lineTo(x, y + ry)\n .arcTo([ x + rx, y ], rx, ry, false);\n }\n\n return path;\n }\n\n static fromPoints(points, options) {\n if (points) {\n const path = new Path(options);\n\n for (let i = 0; i < points.length; i++) {\n let point = Point.create(points[i]);\n if (point) {\n if (i === 0) {\n path.moveTo(point);\n } else {\n path.lineTo(point);\n }\n }\n }\n\n return path;\n }\n }\n\n static curveFromPoints(points, options) {\n if (points) {\n const segments = pointsToCurve(points);\n const path = new Path(options);\n path.segments.push.apply(path.segments, segments);\n\n return path;\n }\n }\n\n static fromArc(arc, options) {\n const path = new Path(options);\n const startAngle = arc.startAngle;\n const start = arc.pointAt(startAngle);\n path.moveTo(start.x, start.y);\n path.arc(startAngle, arc.endAngle, arc.radiusX, arc.radiusY, arc.anticlockwise);\n return path;\n }\n}\n\nexport class MultiPath extends paintable(measurable(Element)) {\n static parse(str, options) {\n const instance = new MultiPath(options);\n return parsePath(instance, str);\n }\n\n toString(digits) {\n const paths = this.paths;\n let output = '';\n\n if (paths.length > 0) {\n const result = [];\n\n for (let i = 0; i < paths.length; i++) {\n result.push(paths[i].toString(digits));\n }\n\n output = result.join(SPACE);\n }\n\n return output;\n }\n\n get nodeType() {\n return 'MultiPath';\n }\n\n constructor(options) {\n super(options);\n this.paths = new GeometryElementsArray();\n this.paths.addObserver(this);\n\n if (!defined(this.options.stroke)) {\n this.stroke('#000');\n }\n }\n\n moveTo(x, y) {\n const path = new Path();\n path.moveTo(x, y);\n\n this.paths.push(path);\n\n return this;\n }\n\n lineTo(x, y) {\n if (this.paths.length > 0) {\n last(this.paths).lineTo(x, y);\n }\n\n return this;\n }\n\n curveTo(controlOut, controlIn, point) {\n if (this.paths.length > 0) {\n last(this.paths).curveTo(controlOut, controlIn, point);\n }\n\n return this;\n }\n\n arc(startAngle, endAngle, radiusX, radiusY, anticlockwise) {\n if (this.paths.length > 0) {\n last(this.paths).arc(startAngle, endAngle, radiusX, radiusY, anticlockwise);\n }\n\n return this;\n }\n\n arcTo(end, rx, ry, largeArc, swipe, rotation) {\n if (this.paths.length > 0) {\n last(this.paths).arcTo(end, rx, ry, largeArc, swipe, rotation);\n }\n\n return this;\n }\n\n close() {\n if (this.paths.length > 0) {\n last(this.paths).close();\n }\n\n return this;\n }\n\n _bbox(matrix) {\n return elementsBoundingBox(this.paths, true, matrix);\n }\n\n rawBBox() {\n return elementsBoundingBox(this.paths, false);\n }\n\n _containsPoint(point) {\n const paths = this.paths;\n\n for (let idx = 0; idx < paths.length; idx++) {\n if (paths[idx]._containsPoint(point)) {\n return true;\n }\n }\n return false;\n }\n\n _isOnPath(point) {\n const paths = this.paths;\n const width = this.options.stroke.width;\n\n for (let idx = 0; idx < paths.length; idx++) {\n if (paths[idx]._isOnPath(point, width)) {\n return true;\n }\n }\n return false;\n }\n\n _clippedBBox(transformation) {\n return elementsClippedBoundingBox(this.paths, this.currentTransform(transformation));\n }\n}\n\n","import Rect from '../../geometry/rect';\n\nexport default function elementsBoundingBox(elements, applyTransform, transformation) {\n let boundingBox;\n\n for (let i = 0; i < elements.length; i++) {\n let element = elements[i];\n if (element.visible()) {\n let elementBoundingBox = applyTransform ? element.bbox(transformation) : element.rawBBox();\n if (elementBoundingBox) {\n if (boundingBox) {\n boundingBox = Rect.union(boundingBox, elementBoundingBox);\n } else {\n boundingBox = elementBoundingBox;\n }\n }\n }\n }\n\n return boundingBox;\n}\n\n","import Rect from '../../geometry/rect';\n\nexport default function elementsClippedBoundingBox(elements, transformation) {\n let boundingBox;\n\n for (let i = 0; i < elements.length; i++) {\n let element = elements[i];\n if (element.visible()) {\n let elementBoundingBox = element.clippedBBox(transformation);\n if (elementBoundingBox) {\n if (boundingBox) {\n boundingBox = Rect.union(boundingBox, elementBoundingBox);\n } else {\n boundingBox = elementBoundingBox;\n }\n }\n }\n }\n\n return boundingBox;\n}","import { Point, Segment } from '../../geometry';\nimport { last, round } from '../../util';\n\nconst WEIGHT = 0.333;\nconst EXTREMUM_ALLOWED_DEVIATION = 0.01;\nconst X = \"x\";\nconst Y = \"y\";\n\nexport function pointsToCurve(pointsIn, closed) {\n const points = pointsIn.slice(0);\n const segments = [];\n let length = points.length;\n\n if (length > 2) {\n removeDuplicates(0, points);\n length = points.length;\n }\n\n if (length < 2 || (length === 2 && points[0].equals(points[1]))) {\n return segments;\n }\n\n let p0 = points[0];\n let p1 = points[1];\n let p2 = points[2];\n\n segments.push(new Segment(p0));\n\n while (p0.equals(points[length - 1])) {\n closed = true;\n points.pop();\n length--;\n }\n\n if (length === 2) {\n const tangent = getTangent(p0,p1, X, Y);\n\n last(segments).controlOut(\n firstControlPoint(tangent, p0, p1, X, Y)\n );\n\n segments.push(new Segment(\n p1,\n secondControlPoint(tangent, p0, p1, X, Y)\n ));\n\n return segments;\n }\n\n let initialControlPoint, lastControlPoint;\n\n if (closed) {\n p0 = points[length - 1]; p1 = points[0]; p2 = points[1];\n const controlPoints = getControlPoints(p0, p1, p2);\n initialControlPoint = controlPoints[1];\n lastControlPoint = controlPoints[0];\n } else {\n const tangent = getTangent(p0, p1, X,Y);\n initialControlPoint = firstControlPoint(tangent, p0, p1, X, Y);\n }\n\n let cp0 = initialControlPoint;\n for (let idx = 0; idx <= length - 3; idx++) {\n removeDuplicates(idx, points);\n length = points.length;\n if (idx + 3 <= length) {\n p0 = points[idx]; p1 = points[idx + 1]; p2 = points[idx + 2];\n const controlPoints = getControlPoints(p0,p1,p2);\n\n last(segments).controlOut(cp0);\n cp0 = controlPoints[1];\n\n const cp1 = controlPoints[0];\n segments.push(new Segment(p1, cp1));\n }\n }\n\n if (closed) {\n p0 = points[length - 2]; p1 = points[length - 1]; p2 = points[0];\n const controlPoints = getControlPoints(p0, p1, p2);\n\n last(segments).controlOut(cp0);\n segments.push(new Segment(\n p1,\n controlPoints[0]\n ));\n\n last(segments).controlOut(controlPoints[1]);\n segments.push(new Segment(\n p2,\n lastControlPoint\n ));\n } else {\n const tangent = getTangent(p1, p2, X, Y);\n\n last(segments).controlOut(cp0);\n segments.push(new Segment(\n p2,\n secondControlPoint(tangent, p1, p2, X, Y)\n ));\n }\n\n return segments;\n}\n\nexport function pointsToClosedCurve(pointsIn) {\n return pointsToCurve(pointsIn, true);\n}\n\nexport function removeDuplicates(idx, points) {\n while (points[idx + 1] && (points[idx].equals(points[idx + 1]) || points[idx + 1].equals(points[idx + 2]))) {\n points.splice(idx + 1, 1);\n }\n}\n\nexport function invertAxis(p0, p1, p2) {\n let invertAxis = false;\n\n if (p0.x === p1.x) {\n invertAxis = true;\n } else if (p1.x === p2.x) {\n if ((p1.y < p2.y && p0.y <= p1.y) || (p2.y < p1.y && p1.y <= p0.y)) {\n invertAxis = true;\n }\n } else {\n const fn = lineFunction(p0,p1);\n const y2 = calculateFunction(fn, p2.x);\n if (!(p0.y <= p1.y && p2.y <= y2) &&\n !(p1.y <= p0.y && p2.y >= y2)) {\n invertAxis = true;\n }\n }\n\n return invertAxis;\n}\n\nexport function isLine(p0, p1, p2) {\n const fn = lineFunction(p0, p1);\n const y2 = calculateFunction(fn, p2.x);\n\n return (p0.x === p1.x && p1.x === p2.x) || round(y2, 1) === round(p2.y, 1);\n}\n\nexport function lineFunction(p1, p2) {\n const a = (p2.y - p1.y) / (p2.x - p1.x);\n const b = p1.y - a * p1.x;\n\n return [ b, a ];\n}\n\nexport function getControlPoints(p0, p1, p2) {\n let xField = X;\n let yField = Y;\n let restrict = false;\n let switchOrientation = false;\n let tangent;\n\n if (isLine(p0, p1, p2)) {\n tangent = getTangent(p0, p1, X, Y);\n } else {\n const monotonic = {\n x: isMonotonicByField(p0, p1, p2, X),\n y: isMonotonicByField(p0, p1, p2, Y)\n };\n\n if (monotonic.x && monotonic.y) {\n tangent = getTangent(p0, p2, X, Y);\n restrict = true;\n } else {\n if (invertAxis(p0, p1, p2)) {\n xField = Y;\n yField = X;\n }\n\n if (monotonic[xField]) {\n tangent = 0;\n } else {\n let sign;\n if ((p2[yField] < p0[yField] && p0[yField] <= p1[yField]) ||\n (p0[yField] < p2[yField] && p1[yField] <= p0[yField])) {\n sign = numberSign((p2[yField] - p0[yField]) * (p1[xField] - p0[xField]));\n } else {\n sign = -numberSign((p2[xField] - p0[xField]) * (p1[yField] - p0[yField]));\n }\n\n tangent = EXTREMUM_ALLOWED_DEVIATION * sign;\n switchOrientation = true;\n }\n }\n }\n\n const secondCP = secondControlPoint(tangent, p0, p1, xField, yField);\n\n if (switchOrientation) {\n const oldXField = xField;\n xField = yField;\n yField = oldXField;\n }\n\n const firstCP = firstControlPoint(tangent, p1, p2, xField, yField);\n\n if (restrict) {\n restrictControlPoint(p0, p1, secondCP, tangent);\n restrictControlPoint(p1, p2, firstCP, tangent);\n }\n\n return [ secondCP, firstCP ];\n}\n\nexport function restrictControlPoint(p1, p2, cp, tangent) {\n if (p1.y < p2.y) {\n if (p2.y < cp.y) {\n cp.x = p1.x + (p2.y - p1.y) / tangent;\n cp.y = p2.y;\n } else if (cp.y < p1.y) {\n cp.x = p2.x - (p2.y - p1.y) / tangent;\n cp.y = p1.y;\n }\n } else {\n if (cp.y < p2.y) {\n cp.x = p1.x - (p1.y - p2.y) / tangent;\n cp.y = p2.y;\n } else if (p1.y < cp.y) {\n cp.x = p2.x + (p1.y - p2.y) / tangent;\n cp.y = p1.y;\n }\n }\n}\n\nexport function getTangent(p0, p1, xField, yField) {\n const x = p1[xField] - p0[xField];\n const y = p1[yField] - p0[yField];\n let tangent;\n\n if (x === 0) {\n tangent = 0;\n } else {\n tangent = y / x;\n }\n\n return tangent;\n}\n\nexport function isMonotonicByField(p0, p1, p2, field) {\n return (p2[field] > p1[field] && p1[field] > p0[field]) ||\n (p2[field] < p1[field] && p1[field] < p0[field]);\n}\n\nexport function firstControlPoint(tangent, p0, p3, xField, yField) {\n const t1 = p0[xField];\n const t2 = p3[xField];\n const distance = (t2 - t1) * WEIGHT;\n\n return point(t1 + distance, p0[yField] + distance * tangent, xField, yField);\n}\n\nexport function secondControlPoint(tangent, p0, p3, xField, yField) {\n const t1 = p0[xField];\n const t2 = p3[xField];\n const distance = (t2 - t1) * WEIGHT;\n\n return point(t2 - distance, p3[yField] - distance * tangent, xField, yField);\n}\n\nexport function point(xValue, yValue, xField, yField) {\n const controlPoint = new Point();\n controlPoint[xField] = xValue;\n controlPoint[yField] = yValue;\n\n return controlPoint;\n}\n\nexport function calculateFunction(fn, x) {\n const length = fn.length;\n let result = 0;\n\n for (let i = 0; i < length; i++) {\n result += Math.pow(x,i) * fn[i];\n }\n return result;\n}\n\nexport function numberSign(value) {\n return value <= 0 ? -1 : 1;\n}\n","import { Class, logToConsole } from './common';\nimport SVGSurface from './svg/surface';\nimport CanvasSurface from './canvas/surface';\n\nlet instance;\nlet support;\n\nconst hasDocument = () => typeof document !== \"undefined\";\n\nconst supportsCanvas = () => hasDocument() &&\n document.createElement(\"canvas\").getContext;\n\nconst supportsSVG = () => hasDocument() &&\n document.implementation.hasFeature(\"http://www.w3.org/TR/SVG11/feature#BasicStructure\", \"1.1\");\n\nclass SurfaceFactory extends Class {\n static get support() {\n if (!support) {\n support = {\n canvas: supportsCanvas(),\n svg: supportsSVG()\n };\n }\n\n return support;\n }\n\n static get current() {\n if (!instance) {\n instance = new SurfaceFactory();\n }\n\n return instance;\n }\n\n constructor() {\n super();\n\n this._items = [ {\n name: \"svg\",\n type: SVGSurface\n }, {\n name: \"canvas\",\n type: CanvasSurface\n } ];\n }\n\n create(element, options) {\n const items = this._items;\n let match = items[0];\n\n if (options && options.type) {\n const preferred = options.type.toLowerCase();\n for (let i = 0; i < items.length; i++) {\n if (items[i].name === preferred) {\n match = items[i];\n break;\n }\n }\n }\n\n if (match) {\n return new match.type(element, options);\n }\n\n logToConsole(\n \"Warning: Unable to create Kendo UI Drawing Surface. Possible causes:\\n\" +\n `- The browser does not support SVG and Canvas. User agent: ${ navigator.userAgent }`);\n }\n}\n\nexport default SurfaceFactory;\n\n","import BaseSurface from './core/surface';\nimport SurfaceFactory from './surface-factory';\n\nclass Surface extends BaseSurface {\n static get support() {\n return SurfaceFactory.support;\n }\n\n static create(element, options) {\n return SurfaceFactory.current.create(element, options);\n }\n}\n\nexport default Surface;\n\n","import { POINT_DIGITS } from './constants';\nimport PathNode from './path-node';\n\nclass ArcNode extends PathNode {\n renderData() {\n return this.srcElement.toPath().toString(POINT_DIGITS);\n }\n}\n\nexport default ArcNode;\n","import PathNode from './path-node';\n\nclass CircleNode extends PathNode {\n\n geometryChange() {\n const center = this.center();\n this.attr(\"cx\", center.x);\n this.attr(\"cy\", center.y);\n this.attr(\"r\", this.radius());\n this.invalidate();\n }\n\n center() {\n return this.srcElement.geometry().center;\n }\n\n radius() {\n return this.srcElement.geometry().radius;\n }\n\n template() {\n return `
[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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: AnimationBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: AnimationBuilder, providedIn: 'root', useFactory: () => inject(BrowserAnimationBuilder) }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", 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 constructor(rootRenderer, doc) {\n super();\n this.animationModuleType = inject(ANIMATION_MODULE_TYPE, { optional: true });\n this._nextAnimationId = 0;\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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: BrowserAnimationBuilder, deps: [{ token: i0.RendererFactory2 }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: BrowserAnimationBuilder, providedIn: 'root' }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", 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 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 constructor(id, element, options, _renderer) {\n this.id = id;\n this.element = element;\n this._renderer = _renderer;\n this.parentPlayer = null;\n this._started = false;\n this.totalTime = 0;\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}\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 constructor(duration = 0, delay = 0) {\n this._onDoneFns = [];\n this._onStartFns = [];\n this._onDestroyFns = [];\n this._originalOnDoneFns = [];\n this._originalOnStartFns = [];\n this._started = false;\n this._destroyed = false;\n this._finished = false;\n this._position = 0;\n this.parentPlayer = null;\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 constructor(_players) {\n this._onDoneFns = [];\n this._onStartFns = [];\n this._finished = false;\n this._started = false;\n this._destroyed = false;\n this._onDestroyFns = [];\n this.parentPlayer = null;\n this.totalTime = 0;\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","/**\n * @license Angular v18.2.8\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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: NoopAnimationDriver }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", 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 { this.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 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 constructor(errors) {\n this.errors = errors;\n this.queryCount = 0;\n this.depCount = 0;\n this.currentTransition = null;\n this.currentQuery = null;\n this.currentQuerySelector = null;\n this.currentAnimateTimings = null;\n this.currentTime = 0;\n this.collectedStyles = new Map();\n this.options = null;\n this.unsupportedCSSPropertiesFound = new Set();\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 constructor() {\n this._map = new Map();\n }\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 * ```\n * sequence([\n * style({ opacity: 0 }),\n * animate(1000, style({ opacity: 0 }))\n * ])\n * ```\n *\n * To:\n * ```\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 * ```\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 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.parentContext = null;\n this.currentAnimateTimings = null;\n this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE;\n this.subContextCount = 0;\n this.options = {};\n this.currentQueryIndex = 0;\n this.currentQueryTotal = 0;\n this.currentStaggerTime = 0;\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 constructor(_driver, element, startTime, _elementTimelineStylesLookup) {\n this._driver = _driver;\n this.element = element;\n this.startTime = startTime;\n this._elementTimelineStylesLookup = _elementTimelineStylesLookup;\n this.duration = 0;\n this.easing = null;\n this._previousKeyframe = new Map();\n this._currentKeyframe = new Map();\n this._keyframes = new Map();\n this._styleSummary = new Map();\n this._localTimelineStyles = new Map();\n this._pendingStyles = new Map();\n this._backFill = new Map();\n this._currentEmptyStepKeyframe = null;\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 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 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 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 constructor(name, ast, _normalizer) {\n this.name = name;\n this.ast = ast;\n this._normalizer = _normalizer;\n this.transitionFactories = [];\n this.states = new Map();\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 constructor(bodyNode, _driver, _normalizer) {\n this.bodyNode = bodyNode;\n this._driver = _driver;\n this._normalizer = _normalizer;\n this._animations = new Map();\n this._playersById = new Map();\n this.players = [];\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 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 constructor(id, hostElement, _engine) {\n this.id = id;\n this.hostElement = hostElement;\n this._engine = _engine;\n this.players = [];\n this._triggers = new Map();\n this._queue = [];\n this._elementListeners = new Map();\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 /** @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 this.players = [];\n this.newHostElements = new Map();\n this.playersByElement = new Map();\n this.playersByQueriedElement = new Map();\n this.statesByElement = new Map();\n this.disabledNodes = new Set();\n this.totalAnimations = 0;\n this.totalQueuedPlayers = 0;\n this._namespaceLookup = {};\n this._namespaceList = [];\n this._flushFns = [];\n this._whenQuietFns = [];\n this.namespacesByHostElement = new Map();\n this.collectedEnterElements = [];\n this.collectedLeaveElements = [];\n // this method is designed to be overridden by the code that uses this engine\n this.onRemovalComplete = (element, context) => { };\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 constructor(namespaceId, triggerName, element) {\n this.namespaceId = namespaceId;\n this.triggerName = triggerName;\n this.element = element;\n this._player = new NoopAnimationPlayer();\n this._containsRealPlayer = false;\n this._queuedCallbacks = new Map();\n this.destroyed = false;\n this.parentPlayer = null;\n this.markedForDestroy = false;\n this.disabled = false;\n this.queued = true;\n this.totalTime = 0;\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 constructor(doc, _driver, _normalizer) {\n this._driver = _driver;\n this._normalizer = _normalizer;\n this._triggerCache = {};\n // this method is designed to be overridden by the code that uses this engine\n this.onRemovalComplete = (element, context) => { };\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 static { this.initialStylesByElement = new WeakMap(); }\n constructor(_element, _startStyles, _endStyles) {\n this._element = _element;\n this._startStyles = _startStyles;\n this._endStyles = _endStyles;\n this._state = 0 /* SpecialCasedStylesState.Pending */;\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 constructor(element, keyframes, options, _specialStyles) {\n this.element = element;\n this.keyframes = keyframes;\n this.options = options;\n this._specialStyles = _specialStyles;\n this._onDoneFns = [];\n this._onStartFns = [];\n this._onDestroyFns = [];\n this._initialized = false;\n this._finished = false;\n this._started = false;\n this._destroyed = false;\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 this._originalOnDoneFns = [];\n this._originalOnStartFns = [];\n this.time = 0;\n this.parentPlayer = null;\n this.currentSnapshot = new Map();\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 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 constructor(namespaceId, delegate, engine, _onDestroy) {\n this.namespaceId = namespaceId;\n this.delegate = delegate;\n this.engine = engine;\n this._onDestroy = _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 this.ɵtype = 0 /* AnimationRendererType.Regular */;\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 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 constructor(delegate, engine, _zone) {\n this.delegate = delegate;\n this.engine = engine;\n this._zone = _zone;\n this._currentId = 0;\n this._microtaskId = 1;\n this._animationCallbacksBuffer = [];\n this._rendererCache = new Map();\n this._cdRecurDepth = 0;\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\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 v18.2.8\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, EventEmitter, ɵɵ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, ɵwhenStable, ɵunwrapSafeValue } from '@angular/core';\nexport { ɵIMAGE_CONFIG as IMAGE_CONFIG } from '@angular/core';\n\nlet _DOM = null;\nfunction getDOM() {\n return _DOM;\n}\nfunction setRootDomAdapter(adapter) {\n _DOM ??= adapter;\n}\n/* tslint:disable:requireParameterType */\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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: PlatformNavigation, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: PlatformNavigation, providedIn: 'platform', useFactory: () => window.navigation }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", 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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: PlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: PlatformLocation, providedIn: 'platform', useFactory: () => inject(BrowserPlatformLocation) }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", 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 constructor() {\n super();\n this._doc = inject(DOCUMENT);\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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: BrowserPlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: BrowserPlatformLocation, providedIn: 'platform', useFactory: () => new BrowserPlatformLocation() }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", 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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: LocationStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }\n static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: LocationStrategy, providedIn: 'root', useFactory: () => inject(PathLocationStrategy) }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", 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 * ```typescript\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 `Today is {{today | date}}
\n *Or if you prefer, {{today | date:'fullDate'}}
\n *The time is {{today | date:'h:mm a z'}}
\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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: PercentPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe }); }\n static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"18.2.8\", ngImport: i0, type: PercentPipe, isStandalone: true, name: \"percent\" }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: PercentPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'percent',\n standalone: true,\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 * {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 `2`.\n * - `maxFractionDigits`: The maximum number of digits after the decimal point.\n * Default is `2`.\n * If not provided, the number will be formatted with the proper amount of digits,\n * depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies.\n * For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.\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, 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 { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: CurrencyPipe, deps: [{ token: LOCALE_ID }, { token: DEFAULT_CURRENCY_CODE }], target: i0.ɵɵFactoryTarget.Pipe }); }\n static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: \"14.0.0\", version: \"18.2.8\", ngImport: i0, type: CurrencyPipe, isStandalone: true, name: \"currency\" }); }\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"18.2.8\", ngImport: i0, type: CurrencyPipe, decorators: [{\n type: Pipe,\n args: [{\n name: 'currency',\n standalone: true,\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 *