{"version":3,"file":"create-generator-easing.mjs","sources":["../../../../../src/animation/generators/utils/create-generator-easing.ts"],"sourcesContent":["import { millisecondsToSeconds } from \"motion-utils\"\nimport { GeneratorFactory, Transition } from \"../../types\"\nimport { calcGeneratorDuration, maxGeneratorDuration } from \"./calc-duration\"\n\n/**\n * Create a progress => progress easing function from a generator.\n */\nexport function createGeneratorEasing(\n    options: Transition,\n    scale = 100,\n    createGenerator: GeneratorFactory\n) {\n    /**\n     * The easing is generated over 0 - scale, but velocity is in the\n     * value's own units, so scale it to match. Otherwise an interrupted\n     * spring hands off the wrong speed, or direction. Keyframes with\n     * units (colours, filters, mixed units) give NaN, which is falsy,\n     * so their velocity passes through unscaled.\n     */\n    const { keyframes: k, velocity: v } = options as any\n    const delta = k && k[k.length - 1] - k[0]\n\n    const generator = createGenerator({\n        ...options,\n        velocity: v && delta ? (v * scale) / delta : v,\n        keyframes: [0, scale],\n    })\n    const duration = Math.min(\n        calcGeneratorDuration(generator),\n        maxGeneratorDuration\n    )\n\n    return {\n        type: \"keyframes\",\n        ease: (progress: number) => {\n            return generator.next(duration * progress).value / scale\n        },\n        duration: millisecondsToSeconds(duration),\n    }\n}\n"],"names":[],"mappings":";;;AAIA;;AAEG;AACG,SAAU,qBAAqB,CACjC,OAAmB,EACnB,KAAK,GAAG,GAAG,EACX,eAAiC,EAAA;AAEjC;;;;;;AAMG;IACH,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,OAAc;AACpD,IAAA,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEzC,MAAM,SAAS,GAAG,eAAe,CAAC;AAC9B,QAAA,GAAG,OAAO;AACV,QAAA,QAAQ,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,IAAI,KAAK,GAAG,CAAC;AAC9C,QAAA,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;AACxB,KAAA,CAAC;AACF,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CACrB,qBAAqB,CAAC,SAAS,CAAC,EAChC,oBAAoB,CACvB;IAED,OAAO;AACH,QAAA,IAAI,EAAE,WAAW;AACjB,QAAA,IAAI,EAAE,CAAC,QAAgB,KAAI;AACvB,YAAA,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,KAAK,GAAG,KAAK;QAC5D,CAAC;AACD,QAAA,QAAQ,EAAE,qBAAqB,CAAC,QAAQ,CAAC;KAC5C;AACL;;;;"}