{"version":3,"file":"transform.mjs","sources":["../../../../src/effects/style/transform.ts"],"sourcesContent":["import { translateAlias } from \"../../render/html/utils/build-transform\"\nimport { transformValueTypes } from \"../../value/types/maps/transform\"\nimport { getValueAsType } from \"../../value/types/utils/get-as-type\"\nimport { MotionValueState } from \"../MotionValueState\"\n\n/**\n * Cache of `translateX(`-style openers so each render is a few string\n * concatenations rather than a template per transform.\n */\nconst openers: Record = {}\n\nexport function buildTransform(state: MotionValueState) {\n let transform = \"\"\n const { transformKeys: keys = [], transformValues: values = {} } = state\n\n /**\n * Loop over the bound transforms in order, adding the ones that\n * aren't at their default value to the transform string.\n */\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n const value = values[key].getCurrent()\n\n if (value === undefined) continue\n\n const parsed = typeof value === \"number\" ? value : parseFloat(value)\n\n if (parsed !== (key.startsWith(\"scale\") ? 1 : 0)) {\n transform +=\n (transform && \" \") +\n (openers[key] ||\n (openers[key] = (translateAlias[key] || key) + \"(\")) +\n getValueAsType(value, transformValueTypes[key]) +\n \")\"\n }\n }\n\n // See build-transform.ts: additive `rotate()` so user `rotate` isn't\n // clobbered. Not a `transformPropOrder` slot.\n const pathRotation = state.get(\"pathRotation\")?.get()\n if (pathRotation) {\n transform +=\n (transform && \" \") +\n \"rotate(\" +\n getValueAsType(pathRotation, transformValueTypes.pathRotation) +\n \")\"\n }\n\n return transform || \"none\"\n}\n"],"names":[],"mappings":";;;;AAKA;;;AAGG;AACH,MAAM,OAAO,GAA2B,EAAE;AAEpC,SAAU,cAAc,CAAC,KAAuB,EAAA;IAClD,IAAI,SAAS,GAAG,EAAE;AAClB,IAAA,MAAM,EAAE,aAAa,EAAE,IAAI,GAAG,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,KAAK;AAExE;;;AAGG;AACH,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAClC,QA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