import{calcFromComponentValues as e}from"@csstools/css-calc";import{parseCommaSeparatedListOfComponentValues as s,isFunctionNode as o,isSimpleBlockNode as t}from"@csstools/css-parser-algorithms";import{tokenizer as n,stringify as r}from"@csstools/css-tokenizer";const c=["asin(","acos(","atan(","atan2(","sin(","cos(","tan("];function calc(a){const i=n({css:a}),l=[];for(;!i.endOfFile();)l.push(i.nextToken());l.push(i.nextToken());const u=s(l,{});let p=!1;for(let e=0;e<u.length;e++){const s=u[e];for(let e=0;e<s.length;e++){const n=s[e];if(o(n)&&c.includes(n.getName().toLowerCase()+"(")){p=!0;break}(t(n)||o(n))&&n.walk(((e,s)=>{if("number"!=typeof s)return;const t=e.node;return o(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(","):a}const creator=e=>{const s=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(e){if(!c.some((s=>e.value.toLowerCase().includes(s))))return;const o=calc(e.value);o!==e.value&&(e.cloneBefore({value:o}),s.preserve||e.remove())}}};creator.postcss=!0;export{creator as default};
