"use strict";var e=require("@csstools/color-helpers"),o=require("postcss-value-parser");const creator=e=>{const l=Object.assign({preserve:!0},e);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const e=new Map;return{OnceExit:()=>{e.clear()},Declaration:c=>{if("text-decoration"!==c.prop.toLowerCase())return;const a=c.parent;if(!a)return;const u=a.index(c);if(a.nodes.some((o=>"decl"===o.type&&"text-decoration"===o.prop.toLowerCase()&&e.get(c.value)===o.value&&a.index(o)!==u)))return;const i=o(c.value),d=i.nodes.filter((e=>"space"!==e.type&&"comment"!==e.type));if(d.find((e=>"var"===e.value.toLowerCase()&&"function"===e.type)))return;if(d.find((e=>"word"===e.type&&r.includes(e.value))))return;const p={line:[],style:null,color:null,thickness:null};for(let e=0;e<d.length;e++){const r=d[e];if(p.line.length||"word"!==r.type||!t.includes(r.value.toLowerCase()))if(p.line.length||"word"!==r.type||"none"!==r.value.toLowerCase())if(p.style||"word"!==r.type||!n.includes(r.value.toLowerCase()))if(p.thickness||"word"!==r.type||!s.includes(r.value.toLowerCase()))if(p.thickness||"function"!==r.type||"calc"!==r.value.toLowerCase())if(p.color||!nodeIsAColor(r)){if("word"!==r.type)return;{let e;try{e=o.unit(r.value)}catch(e){return}if(!e||!e.unit)return;p.thickness=r,"%"===e.unit&&(p.thickness={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"function",value:"calc",nodes:[{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"0.01em"},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"*"},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:e.number}]})}}else p.color=r;else p.thickness=r;else p.thickness=r;else p.style=r;else p.line.push(r);else{const o=r;let n=r;for(;;){const o=d[e+1];if(!o||"word"!==o.type||!t.includes(o.value.toLowerCase()))break;n=o,e++}p.line=i.nodes.slice(i.nodes.indexOf(o),i.nodes.indexOf(n)+1)}}p.line.length||p.line.push({before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"none"}),p.style||(p.style={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"solid"}),p.color||(p.color={before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"word",value:"currentColor"});const f=o.stringify(p.line);if(c.value.toLowerCase()===f.toLowerCase()){const e=c.next();return void(e&&"decl"===e.type&&"text-decoration"===e.prop.toLowerCase()||c.cloneBefore({prop:"-webkit-text-decoration",value:f}))}c.cloneBefore({prop:"text-decoration",value:f});const v=o.stringify([...p.line,{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},p.style,{before:"",after:"",sourceIndex:0,sourceEndIndex:0,type:"space",value:" "},p.color]);p.thickness&&c.cloneBefore({prop:"text-decoration",value:v}),p.thickness&&c.cloneBefore({prop:"text-decoration-thickness",value:o.stringify([p.thickness])}),e.set(c.value,f),e.set(v,f),l.preserve||c.remove()}}}}};function nodeIsAColor(e){return!("word"!==e.type||!e.value.startsWith("#"))||(!("word"!==e.type||!c.includes(e.value.toLowerCase()))||!("function"!==e.type||!l.includes(e.value.toLowerCase())))}creator.postcss=!0;const r=["unset","inherit","initial","revert","revert-layer"],t=["underline","overline","line-through","blink","spelling-error","grammar-error"],n=["solid","double","dotted","dashed","wavy"],s=["auto","from-font"],l=["color","color-mix","hsl","hsla","hwb","lab","lch","oklab","oklch","rgb","rgba"],c=["currentcolor","transparent",...Object.keys(e.namedColors)];module.exports=creator;
