the-forest/client/node_modules/css-has-pseudo/dist/cli.cjs

4 lines
84 KiB
JavaScript
Raw Normal View History

2024-09-17 20:35:18 -04:00
#!/usr/bin/env node
"use strict";var e=require("postcss-selector-parser"),t=require("tty"),r=require("path"),n=require("url"),s=require("fs");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e),a=i(t),l=i(r),u=i(n),c=i(s);const h=e=>{e="object"==typeof e&&e||p;const t=Boolean(!("preserve"in e)||e.preserve);return{postcssPlugin:"css-has-pseudo",Rule:(e,{result:r})=>{if(!e.selector.includes(":has("))return;let n;try{const t=o.default((e=>{e.walkPseudos((e=>{if(":has"===e.value&&e.nodes){const t=d(e);e.value=t?":not-has":":has";const r=o.default.attribute({attribute:f(String(e))});t?e.parent.parent.replaceWith(r):e.replaceWith(r)}}))})).processSync(e.selector);n=String(t)}catch(t){return void e.warn(r,`Failed to parse selector : ${e.selector}`)}void 0!==n&&n!==e.selector&&(t?e.cloneBefore({selector:n}):e.selector=n)}}};h.postcss=!0;const p={preserve:!0},f=e=>{let t="",r="";const n=()=>{if(r){const e=encodeURIComponent(r);let n="",s="";const i=()=>{n&&(s+=n,n="")};let o=!1;for(let t=0;t<e.length;t++){const r=e[t];if(o)n+=r,o=!1;else switch(r){case"%":i(),s+="\\"+r;continue;case"\\":n+=r,o=!0;continue;default:n+=r;continue}}i(),t+=s,r=""}};let s=!1;for(let i=0;i<e.length;i++){const o=e[i];if(s)r+=o,s=!1;else switch(o){case":":case"[":case"]":case",":case"(":case")":n(),t+="\\"+o;continue;case"\\":r+=o,s=!0;continue;default:r+=o;continue}}return n(),t},d=e=>{var t,r;return"pseudo"===(null==(t=e.parent)||null==(r=t.parent)?void 0:r.type)&&":not"===e.parent.parent.value};var g;!function(e){e.InvalidArguments="INVALID_ARGUMENTS"}(g||(g={}));var m={exports:{}};let w=a.default,y=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||"win32"===process.platform||w.isatty(1)&&"dumb"!==process.env.TERM||"CI"in process.env),v=(e,t,r=e)=>n=>{let s=""+n,i=s.indexOf(t,e.length);return~i?e+S(s,t,r,i)+t:e+s+t},S=(e,t,r,n)=>{let s=e.substring(0,n)+r,i=e.substring(n+t.length),o=i.indexOf(t);return~o?s+S(i,t,r,o):s+i},C=(e=y)=>({isColorSupported:e,reset:e?e=>`${e}`:String,bold:e?v("","",""):String,dim:e?v("","",""):String,italic:e?v("",""):String,underline:e?v("",""):String,inverse:e?v("",""):String,hidden:e?v("",""):String,strikethrough:e?v("",""):String,black:e?v("",""):String,red:e?v("",""):String,green:e?v("",""):String,yellow:e?v("",""):String,blue:e?v("",""):String,magenta:e?v("",""):String,cyan:e?v("",""):String,white:e?v("",""):String,gray:e?v("",""):String,bgBlack:e?v("",""):String,bgRed:e?v("",""):String,bgGreen:e?v("",""):String,bgYellow:e?v("",""):String,bgBlue:e?v("",""):String,bgMagenta:e?v("",""):String,bgCyan:e?v("",""):String,bgWhite:e?v("",""):String});m.exports=C(),m.exports.createColors=C;const b="'".charCodeAt(0),_='"'.charCodeAt(0),x="\\".charCodeAt(0),O="/".charCodeAt(0),A="\n".charCodeAt(0),M=" ".charCodeAt(0),k="\f".charCodeAt(0),E="\t".charCodeAt(0),L="\r".charCodeAt(0),R="[".charCodeAt(0),P="]".charCodeAt(0),I="(".charCodeAt(0),j=")".charCodeAt(0),N="{".charCodeAt(0),U="}".charCodeAt(0),B=";".charCodeAt(0),D="*".charCodeAt(0),F=":".charCodeAt(0),T="@".charCodeAt(0),$=/[\t\n\f\r "#'()/;[\\\]{}]/g,G=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,z=/.[\n"'(/\\]/,W=/[\da-f]/i;var V=function(e,t={}){let r,n,s,i,o,a,l,u,c,h,p=e.css.valueOf(),f=t.ignoreErrors,d=p.length,g=0,m=[],w=[];function y(t){throw e.error("Unclosed "+t,g)}return{back:function(e){w.push(e)},nextToken:function(e){if(w.length)return w.pop();if(g>=d)return;let t=!!e&&e.ignoreUnclosed;switch(r=p.charCodeAt(g),r){case A:case M:case E:case L:case k:n=g;do{n+=1,r=p.charCodeAt(n)}while(r===M||r===A||r===E||r===L||r===k);h=["space",p.slice(g,n)],g=n-1;break;case R:case P:case N:case U:case F:case B:case j:{let e=String.fromCharCode(r);h=[e,e,g];break}case I:if(u=m.length?m.pop()[1]:"",c=p.charCodeAt(g+1),"url"===u&&c!==b&&c!==_&&