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IAC7B,CAAC;IAYD,IAAI,KAAK;QACP,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAG,CAAC;IAC9B,CAAC;CAmFF;AACD,eAAe,aAAa,CAAC\"}","code":"/** @license\r\n *  Copyright 2016 - present The Material Motion Authors. All Rights Reserved.\r\n *\r\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\r\n *  use this file except in compliance with the License. You may obtain a copy\r\n *  of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n *  Unless required by applicable law or agreed to in writing, software\r\n *  distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\r\n *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r\n *  License for the specific language governing permissions and limitations\r\n *  under the License.\r\n */\r\nimport { combineLatest, } from '../combineLatest';\r\nimport { createProperty, } from '../observables';\r\nimport { State, } from '../enums/State';\r\nimport { anyOf, } from '../aggregators';\r\nimport { subscribe, } from '../subscribe';\r\nimport { DEFAULT_DAMPING, DEFAULT_STIFFNESS, DEFAULT_THRESHOLD, NumericSpring, } from './NumericSpring';\r\n/**\r\n * `Point2DSpring` is a spring that accepts and emits `Point2D`s for its\r\n * configuration values.  Internally, it is composed of two independent\r\n * `NumericSpring`s.\r\n *\r\n * Because each internal spring emits independently, `value$` will emit\r\n * intermediate values (e.g. changing `initialValue` from `{ x: 0, y: 0 }` to\r\n * `{ x: 5, y: 4 }` will cause 2 emissions, one when `x` changes and one when\r\n * `y` changes.)  This may be corrected in a future release, when emits could be\r\n * batched into one per frame.\r\n */\r\nexport class Point2DSpring {\r\n    constructor() {\r\n        this.xSpring = new NumericSpring();\r\n        this.ySpring = new NumericSpring();\r\n        this.destination$ = createProperty({\r\n            initialValue: { x: 0, y: 0 },\r\n        });\r\n        this.initialValue$ = createProperty({\r\n            initialValue: { x: 0, y: 0 },\r\n        });\r\n        this.initialVelocity$ = createProperty({\r\n            initialValue: { x: 0, y: 0 },\r\n        });\r\n        this.stiffness$ = createProperty({\r\n            initialValue: DEFAULT_STIFFNESS,\r\n        });\r\n        this.damping$ = createProperty({\r\n            initialValue: DEFAULT_DAMPING,\r\n        });\r\n        this.threshold$ = createProperty({\r\n            initialValue: DEFAULT_THRESHOLD,\r\n        });\r\n        this.enabled$ = createProperty({\r\n            initialValue: true,\r\n        });\r\n        this.state$ = anyOf([\r\n            this.xSpring.state$.isAnyOf([State.ACTIVE]),\r\n            this.ySpring.state$.isAnyOf([State.ACTIVE]),\r\n        ]).dedupe().rewrite({\r\n            mapping: {\r\n                true: State.ACTIVE,\r\n                false: State.AT_REST,\r\n            },\r\n        })._remember();\r\n        // Since this emits `Point2D`s, it's probably safe to presume it will be used\r\n        // for translation.  But, to be consistent with `NumericSpring`, we write\r\n        // outputs to `value$` rather than `styleStreams`.\r\n        // If `value$` were debounced, it would emit its terminal value after `state$`\r\n        // is `AT_REST`.  This might be OK in practice (since there would only be one\r\n        // final frame emitted while the interaction is `AT_REST`).  However, to\r\n        // maintain the contract that `state$` will be `ACTIVE` whenever the stream is\r\n        // animating, and to make testing simpler, we don't debounce here.\r\n        //\r\n        // If it were debounced, we'd have to either ensure that `state$` waits until\r\n        // the next frame before emitting `AT_REST`, or accept that they are out-of-\r\n        // sync and add an extra mockRAF.step() to the relevant tests.\r\n        this.value$ = combineLatest({\r\n            x: this.xSpring.value$,\r\n            y: this.ySpring.value$,\r\n        });\r\n        subscribe({\r\n            sink: this.xSpring.destination$,\r\n            source: this.destination$.pluck('x'),\r\n        });\r\n        subscribe({\r\n            sink: this.ySpring.destination$,\r\n            source: this.destination$.pluck('y'),\r\n        });\r\n        subscribe({\r\n            sink: this.xSpring.initialValue$,\r\n            source: this.initialValue$.pluck('x'),\r\n        });\r\n        subscribe({\r\n            sink: this.ySpring.initialValue$,\r\n            source: this.initialValue$.pluck('y'),\r\n        });\r\n        subscribe({\r\n            sink: this.xSpring.initialVelocity$,\r\n            source: this.initialVelocity$.pluck('x'),\r\n        });\r\n        subscribe({\r\n            sink: this.ySpring.initialVelocity$,\r\n            source: this.initialVelocity$.pluck('y'),\r\n        });\r\n        subscribe({\r\n            sinks: [\r\n                this.xSpring.stiffness$,\r\n                this.ySpring.stiffness$,\r\n            ],\r\n            source: this.stiffness$,\r\n        });\r\n        subscribe({\r\n            sinks: [\r\n                this.xSpring.damping$,\r\n                this.ySpring.damping$,\r\n            ],\r\n            source: this.damping$,\r\n        });\r\n        subscribe({\r\n            sinks: [\r\n                this.xSpring.threshold$,\r\n                this.ySpring.threshold$,\r\n            ],\r\n            source: this.threshold$,\r\n        });\r\n        subscribe({\r\n            sinks: [\r\n                this.xSpring.enabled$,\r\n                this.ySpring.enabled$,\r\n            ],\r\n            source: this.enabled$,\r\n        });\r\n    }\r\n    get destination() {\r\n        return this.destination$.read();\r\n    }\r\n    set destination(value) {\r\n        this.destination$.write(value);\r\n    }\r\n    get initialValue() {\r\n        return this.initialValue$.read();\r\n    }\r\n    set initialValue(value) {\r\n        this.initialValue$.write(value);\r\n    }\r\n    get initialVelocity() {\r\n        return this.initialVelocity$.read();\r\n    }\r\n    set initialVelocity(value) {\r\n        this.initialVelocity$.write(value);\r\n    }\r\n    get stiffness() {\r\n        return this.stiffness$.read();\r\n    }\r\n    set stiffness(value) {\r\n        this.stiffness$.write(value);\r\n    }\r\n    get damping() {\r\n        return this.damping$.read();\r\n    }\r\n    set damping(value) {\r\n        this.damping$.write(value);\r\n    }\r\n    get threshold() {\r\n        return this.threshold$.read();\r\n    }\r\n    set threshold(value) {\r\n        this.threshold$.write(value);\r\n    }\r\n    get enabled() {\r\n        return this.enabled$.read();\r\n    }\r\n    set enabled(value) {\r\n        this.enabled$.write(value);\r\n    }\r\n    get state() {\r\n        return this.state$._read();\r\n    }\r\n}\r\nexport default Point2DSpring;\r\n//# sourceMappingURL=Point2DSpring.js.map"}
