import{calcFromComponentValues as e}from"@csstools/css-calc";import{parseCommaSeparatedListOfComponentValues as o,isFunctionNode as s,isSimpleBlockNode as t}from"@csstools/css-parser-algorithms";import{tokenizer as n,stringify as r}from"@csstools/css-tokenizer";const c=["mod(","rem(","round("];function calc(l){const a=n({css:l}),i=[];for(;!a.endOfFile();)i.push(a.nextToken());i.push(a.nextToken());const u=o(i,{});let p=!1;for(let e=0;e<u.length;e++){const o=u[e];for(let e=0;e<o.length;e++){const n=o[e];if(s(n)&&c.includes(n.getName().toLowerCase()+"(")){p=!0;break}(t(n)||s(n))&&n.walk(((e,o)=>{if("number"!=typeof o)return;const t=e.node;return s(t)&&c.includes(t.getName().toLowerCase()+"(")?(p=!0,!1):void 0}))}}return p?e(u,{precision:5,toCanonicalUnits:!0}).map((e=>e.map((e=>r(...e.tokens()))).join(""))).join(","):l}const creator=e=>{const o=Object.assign({preserve:!1,onInvalid:""},e);return{postcssPlugin:"postcss-stepped-value-functions",Declaration(e){if(!c.some((o=>e.value.toLowerCase().includes(o))))return;const s=calc(e.value);s!==e.value&&(e.cloneBefore({value:s}),o.preserve||e.remove())}}};creator.postcss=!0;export{creator as default};
