{"version":3,"file":"preset-autoprefix.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { Preset } from '@twind/core'\n\nimport { cssPropertyAlias, cssPropertyPrefixFlags, cssValuePrefixFlags } from 'style-vendorizer'\n\nconst CSSPrefixFlags = [\n  ['-webkit-', 1 << 0], // 0b001\n  ['-moz-', 1 << 1], // 0b010\n  ['-ms-', 1 << 2], // 0b100\n] as const\n\nexport default function presetAutoprefix(): Preset {\n  return ({ stringify }) => ({\n    stringify(property, value, context) {\n      let cssText = ''\n\n      // Resolve aliases, e.g. `gap` -> `grid-gap`\n      const propertyAlias = cssPropertyAlias(property)\n      if (propertyAlias) cssText += stringify(propertyAlias, value, context) + ';'\n\n      // Prefix properties, e.g. `backdrop-filter` -> `-webkit-backdrop-filter`\n      const propertyFlags = cssPropertyPrefixFlags(property)\n      const valueFlags = cssValuePrefixFlags(property, value)\n\n      for (const prefix of CSSPrefixFlags) {\n        if (propertyFlags & prefix[1]) {\n          cssText += stringify(prefix[0] + property, value, context) + ';'\n        }\n\n        if (valueFlags & prefix[1]) {\n          cssText += stringify(property, prefix[0] + value, context) + ';'\n        }\n      }\n\n      /* Include the standardized declaration last */\n      /* https://css-tricks.com/ordering-css3-properties/ */\n      return cssText + stringify(property, value, context)\n    },\n  })\n}\n"],"names":["CSSPrefixFlags","stringify","property","value","context","cssText","propertyAlias","cssPropertyAlias","propertyFlags","cssPropertyPrefixFlags","valueFlags","cssValuePrefixFlags","prefix"],"mappings":";qDAIMA,iBAAiB;IACrB;QAAC;QAAY;KAAO;;IACpB;QAAC;QAAS;KAAO;;IACjB;QAAC;QAAQ;KAAO;CACjB;iBADmB,QAAA;AAGL,WAAoC;IACjD,OAAO,CAAC,EAAEC,UAAS,EAAE,GAAM,CAAA;YACzBA,WAAUC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAE;gBAClC,IAAIC,UAAU;gBAGRC,gBAAgBC,gCAAiBL,CAAAA;gBACnCI,iBAAeD,CAAAA,WAAWJ,UAAUK,eAAeH,OAAOC,WAAW;;gBAGzE,IAAMI,gBAAgBC,sCAAuBP,CAAAA,WACvCQ,aAAaC,gBAAAA,oBAAoBT,UAAUC;gBAEjD,KAAK,IAAMS,UAAUZ,eAAgB;oBAC/BQ,gBAAgBI,MAAM,CAAC,EAAE,IAC3BP,CAAAA,WAAWJ,UAAUW,MAAM,CAAC,EAAE,GAAGV,UAAUC,OAAOC,WAAW,GAAA;oBAG3DM,aAAaE,MAAM,CAAC,EAAE,IACxBP,CAAAA,WAAWJ,UAAUC,UAAUU,MAAM,CAAC,EAAE,GAAGT,OAAOC,WAAW,GAAA;gBAEjE;gBAIA,6CAAA,GAAA,oDAAA,GAAA,OAAOC,UAAUJ,UAAUC,UAAUC,OAAOC;YAC9C;;AAEJ"}