{"version":3,"names":["_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","withDelay","ReduceMotion","getReduceMotionFromConfig","BaseAnimationBuilder","constructor","System","Error","duration","durationMs","instance","createInstance","durationV","delay","delayMs","delayV","withCallback","callback","callbackV","reduceMotion","reduceMotionV","getDuration","randomDelay","randomizeDelay","getDelay","Math","random","getReduceMotion","getDelayFunction","isDelayProvided","animation","_","build"],"sources":["BaseAnimationBuilder.ts"],"sourcesContent":["'use strict';\nimport { withDelay } from '../../animation';\nimport type {\n EntryExitAnimationFunction,\n AnimationFunction,\n LayoutAnimationFunction,\n} from './commonTypes';\n\nimport { ReduceMotion } from '../../commonTypes';\nimport { getReduceMotionFromConfig } from '../../animation/util';\n\nexport class BaseAnimationBuilder {\n durationV?: number;\n delayV?: number;\n reduceMotionV: ReduceMotion = ReduceMotion.System;\n randomizeDelay = false;\n callbackV?: (finished: boolean) => void;\n\n static createInstance: (\n this: T\n ) => InstanceType;\n\n build = (): EntryExitAnimationFunction | LayoutAnimationFunction => {\n throw new Error('[Reanimated] Unimplemented method in child class.');\n };\n\n /**\n * Lets you adjust the animation duration. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param durationMs - Length of the animation (in milliseconds).\n */\n static duration(\n this: T,\n durationMs: number\n ): InstanceType {\n const instance = this.createInstance();\n return instance.duration(durationMs);\n }\n\n duration(durationMs: number): this {\n this.durationV = durationMs;\n return this;\n }\n\n /**\n * Lets you adjust the delay before the animation starts (in milliseconds). Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param delayMs - Delay before the animation starts (in milliseconds).\n */\n static delay(\n this: T,\n delayMs: number\n ): InstanceType {\n const instance = this.createInstance();\n return instance.delay(delayMs);\n }\n\n delay(delayMs: number): this {\n this.delayV = delayMs;\n return this;\n }\n\n /**\n * The callback that will fire after the animation ends. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param callback - Callback that will fire after the animation ends.\n */\n static withCallback(\n this: T,\n callback: (finished: boolean) => void\n ): InstanceType {\n const instance = this.createInstance();\n return instance.withCallback(callback);\n }\n\n withCallback(callback: (finished: boolean) => void): this {\n this.callbackV = callback;\n return this;\n }\n\n /**\n * Lets you adjust the behavior when the device's reduced motion accessibility setting is turned on. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n */\n static reduceMotion(\n this: T,\n reduceMotion: ReduceMotion\n ): InstanceType {\n const instance = this.createInstance();\n return instance.reduceMotion(reduceMotion);\n }\n\n reduceMotion(reduceMotionV: ReduceMotion): this {\n this.reduceMotionV = reduceMotionV;\n return this;\n }\n\n // 300ms is the default animation duration. If any animation has different default has to override this method.\n static getDuration(): number {\n return 300;\n }\n\n getDuration(): number {\n return this.durationV ?? 300;\n }\n\n /**\n * @deprecated Use `.delay()` with `Math.random()` instead\n */\n static randomDelay(\n this: T\n ): InstanceType {\n const instance = this.createInstance();\n return instance.randomDelay();\n }\n\n randomDelay(): this {\n this.randomizeDelay = true;\n return this;\n }\n\n // when randomizeDelay is set to true, randomize delay between 0 and provided value (or 1000ms if delay is not provided)\n getDelay(): number {\n return this.randomizeDelay\n ? Math.random() * (this.delayV ?? 1000)\n : this.delayV ?? 0;\n }\n\n getReduceMotion(): ReduceMotion {\n return this.reduceMotionV;\n }\n\n getDelayFunction(): AnimationFunction {\n const isDelayProvided = this.randomizeDelay || this.delayV;\n const reduceMotion = this.getReduceMotion();\n return isDelayProvided\n ? (delay, animation) => {\n 'worklet';\n return withDelay(delay, animation, reduceMotion);\n }\n : (_, animation) => {\n 'worklet';\n animation.reduceMotion = getReduceMotionFromConfig(reduceMotion);\n return animation;\n };\n }\n\n static build(\n this: T\n ): EntryExitAnimationFunction | LayoutAnimationFunction {\n const instance = this.createInstance();\n return instance.build();\n }\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AACb,SAASU,SAAS,QAAQ,iBAAiB;AAO3C,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,yBAAyB,QAAQ,sBAAsB;AAEhE,OAAO,MAAMC,oBAAoB,CAAC;EAAAC,YAAA;IAAA3B,eAAA;IAAAA,eAAA;IAAAA,eAAA,wBAGFwB,YAAY,CAACI,MAAM;IAAA5B,eAAA,yBAChC,KAAK;IAAAA,eAAA;IAAAA,eAAA,gBAOd,MAA4D;MACl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