import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";const r=/calc\(/gi;const creator=s=>{const o=Object.assign({preserve:!0},s);return{postcssPlugin:"postcss-nested-calc",Declaration(s,{result:a}){if((s.value.match(r)||[]).length<2)return;if(s.variable)return;if(t(s))return;const n=s.value;let l;try{l=e(n)}catch{return void s.warn(a,`Failed to parse value '${n}'. Leaving the original value intact.`)}if(void 0===l)return;e.walk(l.nodes,t=>{t.type&&"function"===t.type&&"calc"===t.value.toLowerCase()&&e.walk(t.nodes,e=>{if(e.type&&"function"===e.type)return"calc"===e.value.toLowerCase()&&void(e.value="")})},!0);const c=String(l);c!==n&&(s.cloneBefore({value:c}),o.preserve||s.remove())}}};creator.postcss=!0;export{creator as default,creator as"module.exports"};
