import e from"postcss-selector-parser";const t=e().astSync(":link").nodes[0],s=e().astSync(":visited").nodes[0],n=e().astSync("area[href]").nodes[0],o=e().astSync("[href]").nodes[0];function replaceAnyLink(e,t,s,n){const o=[],r=[];try{for(let t=0;t{const r=[];if(e.walkPseudos((e=>{if(":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length)return;if(!l)return void r.push([t.clone({}),s.clone({})]);const c=getTagElementsNextToPseudo(e);c.includes("area")?r.push([t.clone({}),s.clone({}),o.clone({})]):c.length?r.push([t.clone({}),s.clone({})]):r.push([t.clone({}),s.clone({}),n.clone({})])})),!r.length)return;cartesianProduct(...r).forEach((t=>{const s=e.clone({});s.walkPseudos((e=>{":any-link"!==e.value.toLowerCase()||e.nodes&&e.nodes.length||(insertNode(e.parent,e,t.shift()),e.remove())})),c.push(s.toString())}))})).processSync(r),c}function cartesianProduct(...e){const t=[],s=e.length-1;return function helper(n,o){for(let r=0,l=e[o].length;r=0&&("combinator"!==t.nodes[s].type&&!e.isPseudoElement(t.nodes[s].type));s--)r=s;if("tag"!==o){for(let s=c;s{const t={preserve:!0,...e},s={areaHrefNeedsFixing:!1,...Object(t.subFeatures)};return{postcssPlugin:"postcss-pseudo-class-any-link",prepare(){const e=new WeakSet;return{Rule(n,{result:o}){if(!n.selector.toLowerCase().includes(":any-link"))return;if(e.has(n))return;if((n.raws.selector&&n.raws.selector.raw||n.selector).endsWith(":"))return;replaceAnyLink(n,o,t.preserve,s.areaHrefNeedsFixing)&&e.add(n)}}}}};creator.postcss=!0;export{creator as default};