> =>\n is.und(a) ? [] : is.arr(a) ? (a as any) : [a]\n\n/** Copy the `queue`, then iterate it after the `queue` is cleared */\nexport function flush(\n queue: Map
,\n iterator: (entry: [P, T]) => void\n): void\nexport function flush(queue: Set, iterator: (value: T) => void): void\nexport function flush(queue: any, iterator: any) {\n if (queue.size) {\n const items = Array.from(queue)\n queue.clear()\n each(items, iterator)\n }\n}\n","const $config = Symbol.for('FluidValue:config')\n\nexport {\n hasFluidValue,\n getFluidValue,\n getFluidConfig,\n setFluidConfig,\n addFluidObserver,\n}\n\n/** Does the given value have a `FluidConfig` object? */\nconst hasFluidValue = (arg: any): arg is FluidValue => !!getFluidConfig(arg)\n\n/** Get the current value of a fluid object. Returns the first argument when it's not a fluid object. */\nfunction getFluidValue(\n target: T | FluidValue\n): Exclude | U\nfunction getFluidValue(arg: any) {\n const config = getFluidConfig(arg)\n return config ? config.get() : arg\n}\n\ntype GetFluidConfig = T extends FluidValue\n ? FluidConfig\n : FluidConfig | undefined\n\n/** Get the methods for observing the given object. Returns undefined if not a fluid object. */\nfunction getFluidConfig(arg: T): GetFluidConfig\nfunction getFluidConfig(arg: any) {\n if (arg) return arg[$config]\n}\n\n/** Set the methods for observing the given object. */\nfunction setFluidConfig(target: object, config: FluidConfig) {\n Object.defineProperty(target, $config, {\n value: config,\n configurable: true,\n })\n}\n\n/** Add an observer to a fluid object. Returns an unsubscribe function if the target is a fluid object, otherwise undefined. */\nfunction addFluidObserver(\n target: FluidValue,\n observer: FluidObserver\n): () => void\n\nfunction addFluidObserver(\n target: object,\n observer: FluidObserver\n): (() => void) | undefined\n\nfunction addFluidObserver(target: object, observer: FluidObserver) {\n const config = getFluidConfig(target)\n if (config) {\n config.addChild(observer)\n return () => config!.removeChild(observer)\n }\n}\n\nexport interface ChangeEvent {\n type: 'change'\n parent: FluidValue\n value: T\n}\n\n/**\n * An event sent to `FluidObserver` objects.\n */\nexport interface FluidEvent {\n type: string\n parent: FluidValue\n}\n\n/**\n * Compatibility layer for external data sources.\n */\nexport interface FluidConfig = any> {\n get(): T\n addChild(child: FluidObserver): void\n removeChild(child: FluidObserver): void\n}\n\n/**\n * This class stores a single dynamic value, which can be observed by multiple `FluidObserver` objects.\n *\n * In order to support non-writable streams, this class doesn't expect a `set` method to exist.\n *\n * It can send *any* event to observers, not only change events.\n */\nexport abstract class FluidValue = any>\n implements FluidConfig {\n constructor() {\n setFluidConfig(this, this)\n }\n abstract get(): T\n abstract addChild(child: FluidObserver): void\n abstract removeChild(child: FluidObserver): void\n}\n\n/**\n * This object can observe any `FluidValue` object that sends compatible events.\n */\nexport interface FluidObserver {\n onParentChange(event: ChangeEvent | Event): void\n}\n\n/**\n * Add the `FluidValue` type to every property.\n */\nexport type FluidProps = T extends object\n ? { [P in keyof T]: T[P] | FluidValue> }\n : unknown\n","import { useEffect, useRef, useState } from 'react'\n\n// Explicit type annotation fixes TS2742 error.\ntype UseOnce = (effect: React.EffectCallback) => void\n\nexport const useOnce: UseOnce = effect => useEffect(effect, [])\n\n/** Return a function that re-renders this component, if still mounted */\nexport const useForceUpdate = () => {\n const update = useState(0)[1]\n const unmounted = useRef(false)\n useOnce(() => () => {\n unmounted.current = true\n })\n return () => {\n if (!unmounted.current) {\n update({})\n }\n }\n}\n\n/** Use a value from the previous render */\nexport function usePrev(value: T): T | undefined {\n const prevRef = useRef(undefined)\n useEffect(() => {\n prevRef.current = value\n })\n return prevRef.current\n}\n","import * as G from './globals'\nimport { is } from './helpers'\nimport {\n Animatable,\n InterpolatorFn,\n EasingFunction,\n ExtrapolateType,\n InterpolatorConfig,\n InterpolatorFactory,\n} from './types'\n\nexport const createInterpolator: InterpolatorFactory = (\n range: readonly number[] | InterpolatorFn | InterpolatorConfig,\n output?: readonly Animatable[],\n extrapolate?: ExtrapolateType\n) => {\n if (is.fun(range)) {\n return range\n }\n\n if (is.arr(range)) {\n return createInterpolator({\n range,\n output: output!,\n extrapolate,\n })\n }\n\n if (is.str(range.output[0])) {\n return G.createStringInterpolator(range as any) as any\n }\n\n const config = range as InterpolatorConfig\n const outputRange = config.output\n const inputRange = config.range || [0, 1]\n\n const extrapolateLeft =\n config.extrapolateLeft || config.extrapolate || 'extend'\n const extrapolateRight =\n config.extrapolateRight || config.extrapolate || 'extend'\n const easing = config.easing || (t => t)\n\n return (input: number) => {\n const range = findRange(input, inputRange)\n return interpolate(\n input,\n inputRange[range],\n inputRange[range + 1],\n outputRange[range],\n outputRange[range + 1],\n easing,\n extrapolateLeft,\n extrapolateRight,\n config.map\n )\n }\n}\n\nfunction interpolate(\n input: number,\n inputMin: number,\n inputMax: number,\n outputMin: number,\n outputMax: number,\n easing: EasingFunction,\n extrapolateLeft: ExtrapolateType,\n extrapolateRight: ExtrapolateType,\n map?: (x: number) => number\n) {\n let result = map ? map(input) : input\n // Extrapolate\n if (result < inputMin) {\n if (extrapolateLeft === 'identity') return result\n else if (extrapolateLeft === 'clamp') result = inputMin\n }\n if (result > inputMax) {\n if (extrapolateRight === 'identity') return result\n else if (extrapolateRight === 'clamp') result = inputMax\n }\n if (outputMin === outputMax) return outputMin\n if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax\n // Input Range\n if (inputMin === -Infinity) result = -result\n else if (inputMax === Infinity) result = result - inputMin\n else result = (result - inputMin) / (inputMax - inputMin)\n // Easing\n result = easing(result)\n // Output Range\n if (outputMin === -Infinity) result = -result\n else if (outputMax === Infinity) result = result + outputMin\n else result = result * (outputMax - outputMin) + outputMin\n return result\n}\n\nfunction findRange(input: number, inputRange: readonly number[]) {\n for (var i = 1; i < inputRange.length - 1; ++i)\n if (inputRange[i] >= input) break\n return i - 1\n}\n","import { defineHidden } from '@react-spring/shared'\nimport { AnimatedValue } from './AnimatedValue'\n\nconst $node: any = Symbol.for('Animated:node')\n\nexport const isAnimated = (value: any): value is Animated =>\n !!value && value[$node] === value\n\n/** Get the owner's `Animated` node. */\nexport const getAnimated = (owner: any): Animated | undefined =>\n owner && owner[$node]\n\n/** Set the owner's `Animated` node. */\nexport const setAnimated = (owner: any, node: Animated) =>\n defineHidden(owner, $node, node)\n\n/** Get every `AnimatedValue` in the owner's `Animated` node. */\nexport const getPayload = (owner: any): AnimatedValue[] | undefined =>\n owner && owner[$node] && owner[$node].getPayload()\n\nexport abstract class Animated {\n /** The cache of animated values */\n protected payload?: Payload\n\n constructor() {\n // This makes \"isAnimated\" return true.\n setAnimated(this, this)\n }\n\n /** Get the current value. Pass `true` for only animated values. */\n abstract getValue(animated?: boolean): T\n\n /** Set the current value. */\n abstract setValue(value: T): void\n\n /** Reset any animation state. */\n abstract reset(goal?: T): void\n\n /** Get every `AnimatedValue` used by this node. */\n getPayload(): Payload {\n return this.payload || []\n }\n}\n\nexport type Payload = readonly AnimatedValue[]\n","import { is } from '@react-spring/shared'\nimport { Animated, Payload } from './Animated'\n\n/** An animated number or a native attribute value */\nexport class AnimatedValue extends Animated {\n done = true\n elapsedTime!: number\n lastPosition!: number\n lastVelocity?: number | null\n v0?: number | null\n\n constructor(protected _value: T) {\n super()\n if (is.num(this._value)) {\n this.lastPosition = this._value\n }\n }\n\n static create(from: T, _to?: T | null) {\n return new AnimatedValue(from)\n }\n\n getPayload(): Payload {\n return [this]\n }\n\n getValue() {\n return this._value\n }\n\n /**\n * Set the current value and optionally round it.\n *\n * The `step` argument does nothing whenever it equals `undefined` or `0`.\n * It works with fractions and whole numbers. The best use case is (probably)\n * rounding to the pixel grid with a step of:\n *\n * 1 / window.devicePixelRatio\n */\n setValue(value: T, step?: number) {\n if (is.num(value)) {\n this.lastPosition = value\n if (step) {\n value = (Math.round(value / step) * step) as any\n if (this.done) {\n this.lastPosition = value as any\n }\n }\n }\n if (this._value === value) {\n return false\n }\n this._value = value\n return true\n }\n\n reset() {\n const { done } = this\n this.done = false\n if (is.num(this._value)) {\n this.elapsedTime = 0\n this.lastPosition = this._value\n if (done) this.lastVelocity = null\n this.v0 = null\n }\n }\n}\n","import { AnimatedValue } from './AnimatedValue'\nimport { is, createInterpolator } from '@react-spring/shared'\n\ntype Value = string | number\n\nexport class AnimatedString extends AnimatedValue {\n protected _value!: number\n protected _string: string | null = null\n protected _toString: (input: number) => string\n\n constructor(from: string, to: string) {\n super(0)\n this._toString = createInterpolator({ output: [from, to] })\n }\n\n static create(from: T, to: T | null = from): AnimatedValue {\n if (is.str(from) && is.str(to)) {\n return new AnimatedString(from, to) as any\n }\n throw TypeError('Expected \"from\" and \"to\" to be strings')\n }\n\n getValue() {\n let value = this._string\n return value == null ? (this._string = this._toString(this._value)) : value\n }\n\n setValue(value: Value) {\n if (!is.num(value)) {\n this._string = value\n this._value = 1\n } else if (super.setValue(value)) {\n this._string = null\n } else {\n return false\n }\n return true\n }\n\n reset(goal?: string) {\n if (goal) {\n this._toString = createInterpolator({\n output: [this.getValue(), goal],\n })\n }\n this._value = 0\n super.reset()\n }\n}\n","import { FluidValue } from '@react-spring/shared'\nimport { HostConfig } from './createHost'\n\nexport type TreeContext = {\n dependencies: Set\n host: HostConfig\n}\n\nexport const TreeContext: { current: TreeContext | null } = { current: null }\n","import { Lookup, each, getFluidConfig } from '@react-spring/shared'\nimport { Animated, isAnimated, getPayload } from './Animated'\nimport { AnimatedValue } from './AnimatedValue'\nimport { TreeContext } from './context'\n\ntype Source = Lookup | null\n\n/** An object containing `Animated` nodes */\nexport class AnimatedObject extends Animated {\n protected source!: Source\n constructor(source: Source = null) {\n super()\n this.setValue(source)\n }\n\n getValue(animated?: boolean): Source {\n if (!this.source) return null\n const values: Lookup = {}\n each(this.source, (source, key) => {\n if (isAnimated(source)) {\n values[key] = source.getValue(animated)\n } else {\n const config = getFluidConfig(source)\n if (config) {\n values[key] = config.get()\n } else if (!animated) {\n values[key] = source\n }\n }\n })\n return values\n }\n\n /** Replace the raw object data */\n setValue(source: Source) {\n this.source = source\n this.payload = this._makePayload(source)\n }\n\n reset() {\n if (this.payload) {\n each(this.payload, node => node.reset())\n }\n }\n\n /** Create a payload set. */\n protected _makePayload(source: Source) {\n if (source) {\n const payload = new Set()\n each(source, this._addToPayload, payload)\n return Array.from(payload)\n }\n }\n\n /** Add to a payload set. */\n protected _addToPayload(this: Set, source: any) {\n const config = getFluidConfig(source)\n if (config && TreeContext.current) {\n TreeContext.current.dependencies.add(source)\n }\n const payload = getPayload(source)\n if (payload) {\n each(payload, node => this.add(node))\n }\n }\n}\n","import { isAnimatedString, each } from '@react-spring/shared'\nimport { AnimatedObject } from './AnimatedObject'\nimport { AnimatedString } from './AnimatedString'\nimport { AnimatedValue } from './AnimatedValue'\n\ntype Value = number | string\ntype Source = AnimatedValue[]\n\n/** An array of animated nodes */\nexport class AnimatedArray<\n T extends ReadonlyArray = Value[]\n> extends AnimatedObject {\n protected source!: Source\n constructor(from: T, to?: T) {\n super(null)\n super.setValue(this._makeAnimated(from, to))\n }\n\n static create>(from: T, to?: T) {\n return new AnimatedArray(from, to)\n }\n\n getValue(): T {\n return this.source.map(node => node.getValue()) as any\n }\n\n setValue(newValue: T | null) {\n const payload = this.getPayload()\n // Reuse the payload when lengths are equal.\n if (newValue && newValue.length == payload.length) {\n each(payload, (node, i) => node.setValue(newValue[i]))\n } else {\n // Remake the payload when length changes.\n this.source = this._makeAnimated(newValue)\n this.payload = this._makePayload(this.source)\n }\n }\n\n /** Convert the `from` and `to` values to an array of `Animated` nodes */\n protected _makeAnimated(from: T | null, to: T = from!) {\n return from\n ? from.map((from, i) =>\n (isAnimatedString(from) ? AnimatedString : AnimatedValue).create(\n from,\n to[i]\n )\n )\n : []\n }\n}\n","import { FluidObserver, FluidEvent } from '@react-spring/shared'\nimport * as G from '@react-spring/shared/globals'\n\nimport { AnimatedObject } from './AnimatedObject'\nimport { TreeContext } from './context'\n\ntype Props = object & { style?: any }\n\nexport class AnimatedProps extends AnimatedObject implements FluidObserver {\n /** Equals true when an update is scheduled for \"end of frame\" */\n dirty = false\n\n constructor(public update: () => void) {\n super(null)\n }\n\n setValue(props: Props | null, context?: TreeContext) {\n if (!props) return // The constructor passes null.\n if (context) {\n TreeContext.current = context\n if (props.style) {\n const { createAnimatedStyle } = context.host\n props = { ...props, style: createAnimatedStyle(props.style) }\n }\n }\n super.setValue(props)\n TreeContext.current = null\n }\n\n /** @internal */\n onParentChange({ type }: FluidEvent) {\n if (!this.dirty && type === 'change') {\n this.dirty = true\n G.frameLoop.onFrame(() => {\n this.dirty = false\n this.update()\n })\n }\n }\n}\n","import * as React from 'react'\nimport { forwardRef, useRef, Ref } from 'react'\nimport { useLayoutEffect } from 'react-layout-effect'\nimport { is, each, useForceUpdate, ElementType, FluidConfig } from '@react-spring/shared'\n\nimport { AnimatedProps } from './AnimatedProps'\nimport { HostConfig } from './createHost'\n\nexport type AnimatableComponent = string | Exclude\n\nexport const withAnimated = (Component: any, host: HostConfig) =>\n forwardRef((rawProps: any, ref: Ref) => {\n const instanceRef = useRef(null)\n const hasInstance: boolean =\n // Function components must use \"forwardRef\" to avoid being\n // re-rendered on every animation frame.\n !is.fun(Component) ||\n (Component.prototype && Component.prototype.isReactComponent)\n\n const forceUpdate = useForceUpdate()\n const props = new AnimatedProps(() => {\n const instance = instanceRef.current\n if (hasInstance && !instance) {\n return // The wrapped component forgot to forward its ref.\n }\n\n const didUpdate = instance\n ? host.applyAnimatedValues(instance, props.getValue(true)!)\n : false\n\n // Re-render the component when native updates fail.\n if (didUpdate === false) {\n forceUpdate()\n }\n })\n\n const dependencies = new Set()\n props.setValue(rawProps, { dependencies, host })\n\n useLayoutEffect(() => {\n each(dependencies, dep => dep.addChild(props))\n return () => each(dependencies, dep => dep.removeChild(props))\n })\n\n return (\n {\n instanceRef.current = updateRef(ref, value)\n })\n }\n />\n )\n })\n\nfunction updateRef(ref: Ref, value: T) {\n if (ref) {\n if (is.fun(ref)) ref(value)\n else (ref as any).current = value\n }\n return value\n}\n","import { is, each, Lookup } from '@react-spring/shared'\nimport { AnimatableComponent, withAnimated } from './withAnimated'\nimport { Animated } from './Animated'\nimport { AnimatedObject } from './AnimatedObject'\n\nexport interface HostConfig {\n /** Provide custom logic for native updates */\n applyAnimatedValues: (node: any, props: Lookup) => boolean | void\n /** Wrap the `style` prop with an animated node */\n createAnimatedStyle: (style: Lookup) => Animated\n /** Intercept props before they're passed to an animated component */\n getComponentProps: (props: Lookup) => typeof props\n}\n\n// A stub type that gets replaced by @react-spring/web and others.\ntype WithAnimated = {\n (Component: AnimatableComponent): any\n [key: string]: any\n}\n\n// For storing the animated version on the original component\nconst cacheKey = Symbol.for('AnimatedComponent')\n\nexport const createHost = (\n components: AnimatableComponent[] | { [key: string]: AnimatableComponent },\n {\n applyAnimatedValues = () => false,\n createAnimatedStyle = style => new AnimatedObject(style),\n getComponentProps = props => props,\n }: Partial = {}\n) => {\n const hostConfig: HostConfig = {\n applyAnimatedValues,\n createAnimatedStyle,\n getComponentProps,\n }\n\n const animated: WithAnimated = (Component: any) => {\n const displayName = getDisplayName(Component) || 'Anonymous'\n\n if (is.str(Component)) {\n Component = withAnimated(Component, hostConfig)\n } else {\n Component =\n Component[cacheKey] ||\n (Component[cacheKey] = withAnimated(Component, hostConfig))\n }\n\n Component.displayName = `Animated(${displayName})`\n return Component\n }\n\n each(components, (Component, key) => {\n if (!is.str(key)) {\n key = getDisplayName(Component)!\n }\n animated[key] = animated(Component)\n })\n\n return {\n animated,\n }\n}\n\nconst getDisplayName = (arg: AnimatableComponent) =>\n is.str(arg)\n ? arg\n : arg && is.str(arg.displayName)\n ? arg.displayName\n : (is.fun(arg) && arg.name) || null\n","import { useState, useRef, useEffect } from 'react';\n\nfunction areInputsEqual(newInputs, lastInputs) {\n if (newInputs.length !== lastInputs.length) {\n return false;\n }\n\n for (var i = 0; i < newInputs.length; i++) {\n if (newInputs[i] !== lastInputs[i]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction useMemoOne(getResult, inputs) {\n var initial = useState(function () {\n return {\n inputs: inputs,\n result: getResult()\n };\n })[0];\n var committed = useRef(initial);\n var isInputMatch = Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));\n var cache = isInputMatch ? committed.current : {\n inputs: inputs,\n result: getResult()\n };\n useEffect(function () {\n committed.current = cache;\n }, [cache]);\n return cache.result;\n}\nfunction useCallbackOne(callback, inputs) {\n return useMemoOne(function () {\n return callback;\n }, inputs);\n}\nvar useMemo = useMemoOne;\nvar useCallback = useCallbackOne;\n\nexport { useCallback, useCallbackOne, useMemo, useMemoOne };\n","declare const console: any\n\nconst prefix = 'react-spring: '\n\nlet flagInterpolate = false\nexport function deprecateInterpolate() {\n if (!flagInterpolate) {\n flagInterpolate = true\n console.warn(\n prefix +\n 'The \"interpolate\" function is deprecated in v10 (use \"to\" instead)'\n )\n }\n}\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","// const INTEGER = '[-+]?\\\\d+';\nconst NUMBER = '[-+]?\\\\d*\\\\.?\\\\d+'\nconst PERCENTAGE = NUMBER + '%'\n\nfunction call(...parts: string[]) {\n return '\\\\(\\\\s*(' + parts.join(')\\\\s*,\\\\s*(') + ')\\\\s*\\\\)'\n}\n\nexport const rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER))\nexport const rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER))\nexport const hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE))\nexport const hsla = new RegExp(\n 'hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)\n)\nexport const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/\nexport const hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/\nexport const hex6 = /^#([0-9a-fA-F]{6})$/\nexport const hex8 = /^#([0-9a-fA-F]{8})$/\n","/*\nhttps://github.com/react-community/normalize-css-color\n\nBSD 3-Clause License\n\nCopyright (c) 2016, React Community\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n* Neither the name of the copyright holder nor the names of its\n contributors may be used to endorse or promote products derived from\n this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\nimport * as matchers from './colorMatchers'\nimport * as G from './globals'\n\nexport function normalizeColor(color: number | string) {\n let match\n\n if (typeof color === 'number') {\n return color >>> 0 === color && color >= 0 && color <= 0xffffffff\n ? color\n : null\n }\n\n // Ordered based on occurrences on Facebook codebase\n if ((match = matchers.hex6.exec(color)))\n return parseInt(match[1] + 'ff', 16) >>> 0\n\n if (G.colorNames && G.colorNames[color] !== undefined) {\n return G.colorNames[color]\n }\n\n if ((match = matchers.rgb.exec(color))) {\n return (\n ((parse255(match[1]) << 24) | // r\n (parse255(match[2]) << 16) | // g\n (parse255(match[3]) << 8) | // b\n 0x000000ff) >>> // a\n 0\n )\n }\n\n if ((match = matchers.rgba.exec(color))) {\n return (\n ((parse255(match[1]) << 24) | // r\n (parse255(match[2]) << 16) | // g\n (parse255(match[3]) << 8) | // b\n parse1(match[4])) >>> // a\n 0\n )\n }\n\n if ((match = matchers.hex3.exec(color))) {\n return (\n parseInt(\n match[1] +\n match[1] + // r\n match[2] +\n match[2] + // g\n match[3] +\n match[3] + // b\n 'ff', // a\n 16\n ) >>> 0\n )\n }\n\n // https://drafts.csswg.org/css-color-4/#hex-notation\n if ((match = matchers.hex8.exec(color))) return parseInt(match[1], 16) >>> 0\n\n if ((match = matchers.hex4.exec(color))) {\n return (\n parseInt(\n match[1] +\n match[1] + // r\n match[2] +\n match[2] + // g\n match[3] +\n match[3] + // b\n match[4] +\n match[4], // a\n 16\n ) >>> 0\n )\n }\n\n if ((match = matchers.hsl.exec(color))) {\n return (\n (hslToRgb(\n parse360(match[1]), // h\n parsePercentage(match[2]), // s\n parsePercentage(match[3]) // l\n ) |\n 0x000000ff) >>> // a\n 0\n )\n }\n\n if ((match = matchers.hsla.exec(color))) {\n return (\n (hslToRgb(\n parse360(match[1]), // h\n parsePercentage(match[2]), // s\n parsePercentage(match[3]) // l\n ) |\n parse1(match[4])) >>> // a\n 0\n )\n }\n return null\n}\n\nfunction hue2rgb(h: number, c: number, x: number) {\n if (h < 60) return [c, x, 0]\n if (h < 120) return [x, c, 0]\n if (h < 180) return [0, c, x]\n if (h < 240) return [0, x, c]\n if (h < 300) return [x, 0, c]\n return [c, 0, x]\n}\n\nfunction hslToRgb(h: number, s: number, l: number) {\n const C = (1 - Math.abs(2 * l - 1)) * s\n const X = C * (1 - Math.abs(((h / 60) % 2) - 1))\n const M = l - C / 2\n const [R1, G1, B1] = hue2rgb(h, C, X)\n return (\n (Math.round((R1 + M) * 255) << 24) |\n (Math.round((G1 + M) * 255) << 16) |\n (Math.round((B1 + M) * 255) << 8)\n )\n}\n\nfunction parse255(str: string) {\n const int = parseInt(str, 10)\n if (int < 0) return 0\n if (int > 255) return 255\n return int\n}\n\nfunction parse360(str: string) {\n const int = parseFloat(str)\n return (((int % 360) + 360) % 360) / 360\n}\n\nfunction parse1(str: string) {\n const num = parseFloat(str)\n if (num < 0) return 0\n if (num > 1) return 255\n return Math.round(num * 255)\n}\n\nfunction parsePercentage(str: string) {\n // parseFloat conveniently ignores the final %\n const int = parseFloat(str)\n if (int < 0) return 0\n if (int > 100) return 1\n return int / 100\n}\n","import { normalizeColor } from './normalizeColor'\n\nexport function colorToRgba(input: string) {\n let int32Color = normalizeColor(input)\n if (int32Color === null) return input\n int32Color = int32Color || 0\n let r = (int32Color & 0xff000000) >>> 24\n let g = (int32Color & 0x00ff0000) >>> 16\n let b = (int32Color & 0x0000ff00) >>> 8\n let a = (int32Color & 0x000000ff) / 255\n return `rgba(${r}, ${g}, ${b}, ${a})`\n}\n","import { getFluidValue } from 'fluids'\nimport { createInterpolator } from './createInterpolator'\nimport { InterpolatorConfig } from './types'\nimport { colorToRgba } from './colorToRgba'\nimport * as G from './globals'\n\n// Problem: https://github.com/animatedjs/animated/pull/102\n// Solution: https://stackoverflow.com/questions/638565/parsing-scientific-notation-sensibly/658662\nconst numberRegex = /[+\\-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g\n\n// Covers rgb, rgba, hsl, hsla\n// Taken from https://gist.github.com/olmokramer/82ccce673f86db7cda5e\nconst colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\\((-?\\d+%?[,\\s]+){2,3}\\s*[\\d\\.]+%?\\))/gi\n\n// Covers color names (transparent, blue, etc.)\nlet colorNamesRegex: RegExp\n\n// rgba requires that the r,g,b are integers.... so we want to round them,\n// but we *dont* want to round the opacity (4th column).\nconst rgbaRegex = /rgba\\(([0-9\\.-]+), ([0-9\\.-]+), ([0-9\\.-]+), ([0-9\\.-]+)\\)/gi\nconst rgbaRound = (_: any, p1: number, p2: number, p3: number, p4: number) =>\n `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`\n\n/**\n * Supports string shapes by extracting numbers so new values can be computed,\n * and recombines those values into new strings of the same shape. Supports\n * things like:\n *\n * \"rgba(123, 42, 99, 0.36)\" // colors\n * \"-45deg\" // values with units\n * \"0 2px 2px 0px rgba(0, 0, 0, 0.12)\" // CSS box-shadows\n * \"rotate(0deg) translate(2px, 3px)\" // CSS transforms\n */\nexport const createStringInterpolator = (\n config: InterpolatorConfig\n) => {\n if (!colorNamesRegex)\n colorNamesRegex = G.colorNames\n ? new RegExp(`(${Object.keys(G.colorNames).join('|')})`, 'g')\n : /^\\b$/ // never match\n\n // Convert colors to rgba(...)\n const output = config.output.map(value =>\n getFluidValue(value)\n .replace(colorRegex, colorToRgba)\n .replace(colorNamesRegex, colorToRgba)\n )\n\n // Convert [\"1px 2px\", \"0px 0px\"] into [[1, 2], [0, 0]]\n const keyframes = output.map(value => value.match(numberRegex)!.map(Number))\n\n // Convert [\"1px 2px\", \"0px 0px\"] into [[1, 0], [2, 0]]\n const outputRanges = keyframes[0].map((_, i) =>\n keyframes.map(values => {\n if (!(i in values)) {\n throw Error('The arity of each \"output\" value must be equal')\n }\n return values[i]\n })\n )\n\n // Create an interpolator for each animated number\n const interpolators = outputRanges.map(output =>\n createInterpolator({ ...config, output })\n )\n\n // Use the first `output` as a template for each call\n return (input: number) => {\n let i = 0\n return output[0]\n .replace(numberRegex, () => String(interpolators[i++](input)))\n .replace(rgbaRegex, rgbaRound)\n }\n}\n","import { is } from '@react-spring/shared'\nimport { config as configs } from './constants'\n\nconst linear = (t: number) => t\nconst defaults: any = {\n ...configs.default,\n mass: 1,\n damping: 1,\n easing: linear,\n clamp: false,\n}\n\nexport class AnimationConfig {\n /**\n * With higher tension, the spring will resist bouncing and try harder to stop at its end value.\n *\n * When tension is zero, no animation occurs.\n */\n tension!: number\n\n /**\n * The damping ratio coefficient, or just the damping ratio when `speed` is defined.\n *\n * When `speed` is defined, this value should be between 0 and 1.\n *\n * Higher friction means the spring will slow down faster.\n */\n friction!: number\n\n /**\n * The natural frequency (in seconds), which dictates the number of bounces\n * per second when no damping exists.\n *\n * When defined, `tension` is derived from this, and `friction` is derived\n * from `tension` and `damping`.\n */\n frequency?: number\n\n /**\n * The damping ratio, which dictates how the spring slows down.\n *\n * Set to `0` to never slow down. Set to `1` to slow down without bouncing.\n * Between `0` and `1` is for you to explore.\n *\n * Only works when `frequency` is defined.\n *\n * Defaults to 1\n */\n damping!: number\n\n /**\n * Higher mass means more friction is required to slow down.\n *\n * Defaults to 1, which works fine most of the time.\n */\n mass!: number\n\n /**\n * The initial velocity of one or more values.\n */\n velocity: number | number[] = 0\n\n /**\n * The smallest velocity before the animation is considered \"not moving\".\n *\n * When undefined, `precision` is used instead.\n */\n restVelocity?: number\n\n /**\n * The smallest distance from a value before that distance is essentially zero.\n *\n * This helps in deciding when a spring is \"at rest\". The spring must be within\n * this distance from its final value, and its velocity must be lower than this\n * value too (unless `restVelocity` is defined).\n */\n precision?: number\n\n /**\n * For `duration` animations only. Note: The `duration` is not affected\n * by this property.\n *\n * Defaults to `0`, which means \"start from the beginning\".\n *\n * Setting to `1+` makes an immediate animation.\n *\n * Setting to `0.5` means \"start from the middle of the easing function\".\n *\n * Any number `>= 0` and `<= 1` makes sense here.\n */\n progress?: number\n\n /**\n * Animation length in number of milliseconds.\n */\n duration?: number\n\n /**\n * The animation curve. Only used when `duration` is defined.\n *\n * Defaults to quadratic ease-in-out.\n */\n easing!: (t: number) => number\n\n /**\n * Avoid overshooting by ending abruptly at the goal value.\n */\n clamp!: boolean\n\n /**\n * When above zero, the spring will bounce instead of overshooting when\n * exceeding its goal value. Its velocity is multiplied by `-1 + bounce`\n * whenever its current value equals or exceeds its goal. For example,\n * setting `bounce` to `0.5` chops the velocity in half on each bounce,\n * in addition to any friction.\n */\n bounce?: number\n\n /**\n * \"Decay animations\" decelerate without an explicit goal value.\n * Useful for scrolling animations.\n *\n * Use `true` for the default exponential decay factor (`0.998`).\n *\n * When a `number` between `0` and `1` is given, a lower number makes the\n * animation slow down faster. And setting to `1` would make an unending\n * animation.\n */\n decay?: boolean | number\n\n /**\n * While animating, round to the nearest multiple of this number.\n * The `from` and `to` values are never rounded, as well as any value\n * passed to the `set` method of an animated value.\n */\n round?: number\n\n constructor() {\n Object.assign(this, defaults)\n }\n}\n\nexport function mergeConfig(\n config: AnimationConfig,\n newConfig: Partial,\n defaultConfig?: Partial\n): typeof config\n\nexport function mergeConfig(\n config: any,\n newConfig: object,\n defaultConfig?: object\n) {\n if (defaultConfig) {\n defaultConfig = { ...defaultConfig }\n sanitizeConfig(defaultConfig, newConfig)\n newConfig = { ...defaultConfig, ...newConfig }\n }\n\n sanitizeConfig(config, newConfig)\n Object.assign(config, newConfig)\n\n for (const key in defaults) {\n if (config[key] == null) {\n config[key] = defaults[key]\n }\n }\n\n let { mass, frequency, damping } = config\n if (!is.und(frequency)) {\n if (frequency < 0.01) frequency = 0.01\n if (damping < 0) damping = 0\n config.tension = Math.pow((2 * Math.PI) / frequency, 2) * mass\n config.friction = (4 * Math.PI * damping * mass) / frequency\n }\n\n return config\n}\n\n// Prevent a config from accidentally overriding new props.\n// This depends on which \"config\" props take precedence when defined.\nfunction sanitizeConfig(\n config: Partial,\n props: Partial\n) {\n if (!is.und(props.decay)) {\n config.duration = undefined\n } else {\n const isTensionConfig = !is.und(props.tension) || !is.und(props.friction)\n if (\n isTensionConfig ||\n !is.und(props.frequency) ||\n !is.und(props.damping) ||\n !is.und(props.mass)\n ) {\n config.duration = undefined\n config.decay = undefined\n }\n if (isTensionConfig) {\n config.frequency = undefined\n }\n }\n}\n","// The `mass` prop defaults to 1\nexport const config = {\n default: { tension: 170, friction: 26 },\n gentle: { tension: 120, friction: 14 },\n wobbly: { tension: 180, friction: 12 },\n stiff: { tension: 210, friction: 20 },\n slow: { tension: 280, friction: 60 },\n molasses: { tension: 280, friction: 120 },\n} as const\n","import { AnimatedValue } from '@react-spring/animated'\nimport { FluidValue } from '@react-spring/shared'\nimport { AnimationConfig } from './AnimationConfig'\nimport { OnStart, OnChange } from './types'\n\nconst emptyArray: readonly any[] = []\n\n/** @internal */\ntype OnRest = (cancel?: boolean) => void\n\n/** An animation being executed by the frameloop */\nexport class Animation {\n changed = false\n values: readonly AnimatedValue[] = emptyArray\n toValues: readonly number[] | null = null\n fromValues: readonly number[] = emptyArray\n\n to!: T | FluidValue\n from!: T | FluidValue\n config = new AnimationConfig()\n immediate = false\n onStart?: OnStart\n onChange?: OnChange\n onRest: OnRest[] = []\n}\n","import { useMemoOne } from 'use-memo-one'\nimport {\n is,\n each,\n toArray,\n getFluidConfig,\n isAnimatedString,\n AnyFn,\n OneOrMore,\n FluidValue,\n Lookup,\n Falsy,\n} from '@react-spring/shared'\nimport * as G from '@react-spring/shared/globals'\nimport { ReservedProps, ForwardProps, InferTo } from './types'\n\n// @see https://github.com/alexreardon/use-memo-one/pull/10\nexport const useMemo: typeof useMemoOne = (create, deps) =>\n useMemoOne(create, deps || [{}])\n\nexport function callProp(\n value: T,\n ...args: T extends AnyFn ? Parameters : unknown[]\n): T extends AnyFn ? U : T {\n return is.fun(value) ? value(...args) : value\n}\n\n/** Try to coerce the given value into a boolean using the given key */\nexport const matchProp = (\n value: boolean | OneOrMore | ((key: any) => boolean) | undefined,\n key: string | undefined\n) =>\n value === true ||\n !!(\n key &&\n value &&\n (is.fun(value) ? value(key) : toArray(value).includes(key))\n )\n\nexport const concatFn = (first: T | undefined, last: T) =>\n first ? (...args: Parameters) => (first(...args), last(...args)) : last\n\ntype AnyProps = OneOrMore | ((i: number, arg: Arg) => T)\n\nexport const getProps = (\n props: AnyProps | null | undefined,\n i: number,\n arg: Arg\n) =>\n props &&\n (is.fun(props) ? props(i, arg) : is.arr(props) ? props[i] : { ...props })\n\n/** Returns `true` if the given prop is having its default value set. */\nexport const hasDefaultProp = (props: T, key: keyof T) =>\n !is.und(getDefaultProp(props, key))\n\n/** Get the default value being set for the given `key` */\nexport const getDefaultProp = (props: T, key: keyof T) =>\n props.default === true\n ? props[key]\n : props.default\n ? props.default[key]\n : undefined\n\n/**\n * Extract the default props from an update.\n *\n * When the `default` prop is falsy, this function still behaves as if\n * `default: true` was used. The `default` prop is always respected when\n * truthy.\n */\nexport const getDefaultProps = (\n props: Lookup,\n omitKeys: (string | Falsy)[] = [],\n defaults: Lookup = {} as any\n) => {\n let keys: readonly string[] = DEFAULT_PROPS\n if (props.default && props.default !== true) {\n props = props.default\n keys = Object.keys(props)\n }\n for (const key of keys) {\n const value = props[key]\n if (!is.und(value) && !omitKeys.includes(key)) {\n defaults[key] = value\n }\n }\n return defaults as T\n}\n\n/** Merge the default props of an update into a props cache. */\nexport const mergeDefaultProps = (\n defaults: Lookup,\n props: Lookup,\n omitKeys?: (string | Falsy)[]\n) => getDefaultProps(props, omitKeys, defaults)\n\n/** These props can have default values */\nexport const DEFAULT_PROPS = [\n 'pause',\n 'cancel',\n 'config',\n 'immediate',\n 'onDelayEnd',\n 'onProps',\n 'onStart',\n 'onChange',\n 'onRest',\n] as const\n\nconst RESERVED_PROPS: Required = {\n config: 1,\n from: 1,\n to: 1,\n ref: 1,\n loop: 1,\n reset: 1,\n pause: 1,\n cancel: 1,\n reverse: 1,\n immediate: 1,\n default: 1,\n delay: 1,\n onDelayEnd: 1,\n onProps: 1,\n onStart: 1,\n onChange: 1,\n onRest: 1,\n\n // Transition props\n items: 1,\n trail: 1,\n sort: 1,\n expires: 1,\n initial: 1,\n enter: 1,\n update: 1,\n leave: 1,\n children: 1,\n\n // Internal props\n keys: 1,\n callId: 1,\n parentId: 1,\n}\n\n/**\n * Extract any properties whose keys are *not* reserved for customizing your\n * animations. All hooks use this function, which means `useTransition` props\n * are reserved for `useSpring` calls, etc.\n */\nfunction getForwardProps(\n props: Props\n): ForwardProps | undefined {\n const forward: any = {}\n\n let count = 0\n each(props, (value, prop) => {\n if (!RESERVED_PROPS[prop]) {\n forward[prop] = value\n count++\n }\n })\n\n if (count) {\n return forward\n }\n}\n\n/**\n * Clone the given `props` and move all non-reserved props\n * into the `to` prop.\n */\nexport function inferTo(props: T): InferTo {\n const to = getForwardProps(props)\n if (to) {\n const out: any = { to }\n each(props, (val, key) => key in to || (out[key] = val))\n return out\n }\n return { ...props } as any\n}\n\n// Compute the goal value, converting \"red\" to \"rgba(255, 0, 0, 1)\" in the process\nexport function computeGoal(value: T | FluidValue): T {\n const config = getFluidConfig(value)\n return config\n ? computeGoal(config.get())\n : is.arr(value)\n ? value.map(computeGoal)\n : isAnimatedString(value)\n ? (G.createStringInterpolator({\n range: [0, 1],\n output: [value, value] as any,\n })(1) as any)\n : value\n}\n","import { matchProp, callProp } from './helpers'\nimport { RunAsyncState, RunAsyncProps } from './runAsync'\nimport { SpringProps, AnimationResolver } from './types'\nimport { AsyncResult } from './AnimationResult'\nimport { Timeout, Globals as G } from '@react-spring/shared'\n\ninterface ScheduledProps {\n key?: string\n props: Pick, 'cancel' | 'pause' | 'delay'>\n state: RunAsyncState\n actions: {\n pause: () => void\n resume: () => void\n start: (props: RunAsyncProps, resolve: AnimationResolver) => void\n }\n}\n\n/**\n * This function sets a timeout if both the `delay` prop exists and\n * the `cancel` prop is not `true`.\n *\n * The `actions.start` function must handle the `cancel` prop itself,\n * but the `pause` prop is taken care of.\n */\nexport function scheduleProps(\n callId: number,\n { key, props, state, actions }: ScheduledProps\n): AsyncResult {\n return new Promise((resolve, reject) => {\n let delay: number\n let timeout: Timeout\n\n let pause = false\n let cancel = matchProp(props.cancel, key)\n\n if (cancel) {\n onStart()\n } else {\n delay = callProp(props.delay || 0, key)\n pause = matchProp(props.pause, key)\n if (pause) {\n state.resumeQueue.add(onResume)\n actions.pause()\n } else {\n actions.resume()\n onResume()\n }\n }\n\n function onPause() {\n state.resumeQueue.add(onResume)\n timeout.cancel()\n // Cache the remaining delay.\n delay = timeout.time - G.now()\n }\n\n function onResume() {\n if (delay > 0) {\n state.pauseQueue.add(onPause)\n timeout = G.frameLoop.setTimeout(onStart, delay)\n } else {\n onStart()\n }\n }\n\n function onStart() {\n state.pauseQueue.delete(onPause)\n\n // Maybe cancelled during its delay.\n if (callId <= (state.cancelId || 0)) {\n cancel = true\n }\n\n try {\n actions.start({ ...props, callId, delay, cancel, pause }, resolve)\n } catch (err) {\n reject(err)\n }\n }\n })\n}\n","import { SpringPhase } from './SpringPhase'\nimport { SpringStopFn } from './types'\n\n/** @internal */\nexport interface AnimationTarget {\n get(): T\n is(phase: SpringPhase): boolean\n start(props: any): AsyncResult\n stop: SpringStopFn\n}\n\n/** The object given to the `onRest` prop and `start` promise. */\nexport interface AnimationResult {\n value: T\n target?: AnimationTarget\n /** When true, no animation ever started. */\n noop?: boolean\n /** When true, the animation was neither cancelled nor stopped prematurely. */\n finished?: boolean\n /** When true, the animation was cancelled before it could finish. */\n cancelled?: boolean\n}\n\n/** The promised result of an animation. */\nexport type AsyncResult = Promise>\n\n/** @internal */\nexport const getCombinedResult = (\n target: AnimationTarget,\n results: AnimationResult[]\n): AnimationResult =>\n results.length == 1\n ? results[0]\n : results.some(result => result.cancelled)\n ? getCancelledResult(target)\n : results.every(result => result.noop)\n ? getNoopResult(target)\n : getFinishedResult(\n target,\n results.every(result => result.finished)\n )\n\n/** No-op results are for updates that never start an animation. */\nexport const getNoopResult = (\n target: AnimationTarget,\n value = target.get()\n) => ({\n value,\n noop: true,\n finished: true,\n target,\n})\n\nexport const getFinishedResult = (\n target: AnimationTarget,\n finished: boolean,\n value = target.get()\n) => ({\n value,\n finished,\n target,\n})\n\nexport const getCancelledResult = (\n target: AnimationTarget,\n value = target.get()\n) => ({\n value,\n cancelled: true,\n target,\n})\n","import { is, each } from '@react-spring/shared'\nimport * as G from '@react-spring/shared/globals'\n\nimport { getDefaultProps } from './helpers'\nimport {\n SpringChain,\n SpringDefaultProps,\n SpringProps,\n SpringToFn,\n} from './types'\nimport {\n getCancelledResult,\n getFinishedResult,\n AnimationResult,\n AsyncResult,\n AnimationTarget,\n} from './AnimationResult'\n\nexport interface RunAsyncProps extends SpringProps {\n callId: number\n parentId?: number\n cancel: boolean\n pause: boolean\n delay: number\n to?: any\n}\n\nexport interface RunAsyncState {\n pauseQueue: Set\n resumeQueue: Set\n asyncId?: number\n asyncTo?: SpringChain | SpringToFn\n promise?: AsyncResult\n cancelId?: number\n}\n\n/**\n * Start an async chain or an async script.\n *\n * Always call `runAsync` in the action callback of a `scheduleProps` call.\n *\n * The `T` parameter can be a set of animated values (as an object type)\n * or a primitive type for a single animated value.\n */\nexport async function runAsync(\n to: SpringChain | SpringToFn,\n props: RunAsyncProps,\n state: RunAsyncState,\n target: AnimationTarget\n): AsyncResult {\n if (props.pause) {\n await new Promise(resume => {\n state.resumeQueue.add(resume)\n })\n }\n\n const { callId, parentId, onRest } = props\n const { asyncTo: prevTo, promise: prevPromise } = state\n\n if (!parentId && to === prevTo && !props.reset) {\n return prevPromise!\n }\n\n return (state.promise = (async (): AsyncResult => {\n state.asyncId = callId\n state.asyncTo = to\n\n // The default props of any `animate` calls.\n const defaultProps = getDefaultProps>(props, [\n // The `onRest` prop is only called when the `runAsync` promise is resolved.\n 'onRest',\n ])\n\n let preventBail!: () => void\n let bail: (error: any) => void\n\n // This promise is rejected when the animation is interrupted.\n const bailPromise = new Promise(\n (resolve, reject) => ((preventBail = resolve), (bail = reject))\n )\n\n // Stop animating when an error is caught.\n const withBailHandler = (\n fn: (...args: Args) => AsyncResult\n ) => (...args: Args) => {\n const onError = (err: any) => {\n if (err instanceof BailSignal) {\n bail(err) // Stop animating.\n }\n throw err\n }\n try {\n return fn(...args).catch(onError)\n } catch (err) {\n onError(err)\n }\n }\n\n const bailIfEnded = (bailSignal: BailSignal) => {\n const bailResult =\n // The `cancel` prop or `stop` method was used.\n (callId <= (state.cancelId || 0) && getCancelledResult(target)) ||\n // The async `to` prop was replaced.\n (callId !== state.asyncId && getFinishedResult(target, false))\n\n if (bailResult) {\n bailSignal.result = bailResult\n throw bailSignal\n }\n }\n\n // Note: This function cannot use the `async` keyword, because we want the\n // `throw` statements to interrupt the caller.\n const animate: any = withBailHandler((arg1: any, arg2?: any) => {\n const bailSignal = new BailSignal()\n bailIfEnded(bailSignal)\n\n const props: any = is.obj(arg1) ? { ...arg1 } : { ...arg2, to: arg1 }\n props.parentId = callId\n\n each(defaultProps, (value, key) => {\n if (is.und(props[key])) {\n props[key] = value as any\n }\n })\n\n return target.start(props).then(async result => {\n bailIfEnded(bailSignal)\n\n if (target.is('PAUSED')) {\n await new Promise(resume => {\n state.resumeQueue.add(resume)\n })\n }\n\n return result\n })\n })\n\n let result!: AnimationResult\n try {\n let animating!: Promise\n\n // Async sequence\n if (is.arr(to)) {\n animating = (async (queue: any[]) => {\n for (const props of queue) {\n await animate(props)\n }\n })(to)\n }\n\n // Async script\n else if (is.fun(to)) {\n animating = Promise.resolve(\n to(animate, target.stop.bind(target) as any)\n )\n }\n\n await Promise.all([animating.then(preventBail), bailPromise])\n result = getFinishedResult(target, true)\n\n // Bail handling\n } catch (err) {\n if (err instanceof BailSignal) {\n result = err.result\n } else {\n throw err\n }\n\n // Reset the async state.\n } finally {\n if (callId == state.asyncId) {\n state.asyncId = parentId\n state.asyncTo = parentId ? prevTo : undefined\n state.promise = parentId ? prevPromise : undefined\n }\n }\n\n if (is.fun(onRest)) {\n G.batchedUpdates(() => {\n onRest(result)\n })\n }\n\n return result\n })())\n}\n\nexport function cancelAsync(state: RunAsyncState, callId: number) {\n state.cancelId = callId\n state.asyncId = state.asyncTo = state.promise = undefined\n}\n\n/** This error is thrown to signal an interrupted async animation. */\nexport class BailSignal extends Error {\n result!: AnimationResult\n constructor() {\n super(\n 'An async animation has been interrupted. You see this error because you ' +\n 'forgot to use `await` or `.catch(...)` on its returned promise.'\n )\n }\n}\n","import { each, InterpolatorArgs, FluidValue, FluidObserver } from '@react-spring/shared'\nimport { getAnimated } from '@react-spring/animated'\nimport { deprecateInterpolate } from '@react-spring/shared/deprecations'\nimport * as G from '@react-spring/shared/globals'\n\nimport { Interpolation } from './Interpolation'\n\nexport const isFrameValue = (value: any): value is FrameValue =>\n value instanceof FrameValue\n\nlet nextId = 1\n\n/**\n * A kind of `FluidValue` that manages an `AnimatedValue` node.\n *\n * Its underlying value can be accessed and even observed.\n */\nexport abstract class FrameValue\n extends FluidValue>\n implements FluidObserver {\n readonly id = nextId++\n\n abstract key?: string\n abstract get idle(): boolean\n\n protected _priority = 0\n protected _children = new Set>()\n\n get priority() {\n return this._priority\n }\n set priority(priority: number) {\n if (this._priority != priority) {\n this._priority = priority\n this._onPriorityChange(priority)\n }\n }\n\n /** Get the current value */\n get(): T {\n const node = getAnimated(this)\n return node && node.getValue()\n }\n\n /** Create a spring that maps our value to another value */\n to(...args: InterpolatorArgs) {\n return G.to(this, args) as Interpolation\n }\n\n /** @deprecated Use the `to` method instead. */\n interpolate(...args: InterpolatorArgs) {\n deprecateInterpolate()\n return G.to(this, args) as Interpolation\n }\n\n /** @internal */\n abstract advance(dt: number): void\n\n /** @internal */\n addChild(child: FrameValue.Observer): void {\n if (!this._children.size) this._attach()\n this._children.add(child)\n }\n\n /** @internal */\n removeChild(child: FrameValue.Observer): void {\n this._children.delete(child)\n if (!this._children.size) this._detach()\n }\n\n /** @internal */\n onParentChange({ type }: FrameValue.Event) {\n if (this.idle) {\n // Start animating when a parent does.\n if (type == 'start') {\n this._reset()\n this._start()\n }\n }\n // Reset our animation state when a parent does, but only when\n // our animation is active.\n else if (type == 'reset') {\n this._reset()\n }\n }\n\n /** Called when the first child is added. */\n protected _attach() {}\n\n /** Called when the last child is removed. */\n protected _detach() {}\n\n /**\n * Reset our animation state (eg: start values, velocity, etc)\n * and tell our children to do the same.\n *\n * This is called when our goal value is changed during (or before)\n * an animation.\n */\n protected _reset() {\n this._emit({\n type: 'reset',\n parent: this,\n })\n }\n\n /**\n * Start animating if possible.\n *\n * Note: Be sure to call `_reset` first, or the animation will break.\n * This method would like to call `_reset` for you, but that would\n * interfere with paused animations.\n */\n protected _start() {\n this._emit({\n type: 'start',\n parent: this,\n })\n }\n\n /** Tell our children about our new value */\n protected _onChange(value: T, idle = false) {\n this._emit({\n type: 'change',\n parent: this,\n value,\n idle,\n })\n }\n\n /** Tell our children about our new priority */\n protected _onPriorityChange(priority: number) {\n if (!this.idle) {\n // Make the frameloop aware of our new priority.\n G.frameLoop.start(this)\n }\n this._emit({\n type: 'priority',\n parent: this,\n priority,\n })\n }\n\n protected _emit(event: FrameValue.Event) {\n // Clone \"_children\" so it can be safely mutated inside the loop.\n each(Array.from(this._children), child => {\n child.onParentChange(event)\n })\n }\n}\n\nexport declare namespace FrameValue {\n /** A parent changed its value */\n interface ChangeEvent {\n type: 'change'\n value: T\n idle: boolean\n }\n\n /** A parent changed its priority */\n interface PriorityEvent {\n type: 'priority'\n priority: number\n }\n\n /** A parent reset the internal state of its current animation */\n interface ResetEvent {\n type: 'reset'\n }\n\n /** A parent entered the frameloop */\n interface StartEvent {\n type: 'start'\n }\n\n /** Events sent to children of `FrameValue` objects */\n export type Event = { parent: FrameValue } & (\n | ChangeEvent