@stacksjs/ts-css 0.3.21 → 0.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cssx.js CHANGED
@@ -8,7 +8,7 @@ var yc=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};
8
8
  `),s=Math.max(...o.map((u)=>u.length))+2,c=`\u250C${"\u2500".repeat(s)}\u2510`,a=`\u2514${"\u2500".repeat(s)}\u2518`,l=o.map((u)=>{let f=" ".repeat(s-u.length-2);return`\u2502 ${u}${f} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:r,message:P.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:P.cyan(c)})),l.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:r,message:P.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:r,message:P.cyan(a),showTimestamp:!1}))}else if(!D())console.error(`${n} ${this.environment}.INFO: [BOX] ${e}`);let i=`${n} ${this.environment}.INFO: [BOX] ${e}
9
9
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if(D())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${P.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();J.stdin.removeListener("data",r);try{if(typeof J.stdin.setRawMode==="function")J.stdin.setRawMode(!1)}catch{}J.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof J.stdin.setRawMode==="function")J.stdin.setRawMode(!0)}catch{}J.stdin.resume(),J.stdin.once("data",r)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let r=e;if(t&&t.length>0){let s=/%([sdijfo%])/g,c=0;if(r=e.replace(s,(a,l)=>{if(l==="%")return"%";if(c>=t.length)return a;let u=t[c++];switch(l){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return a}}),c<t.length)r+=` ${t.slice(c).map((a)=>typeof a==="object"?JSON.stringify(a,null,2):String(a)).join(" ")}`}if(this.fancy&&!D()){let s=this.options.showTags!==!1&&this.name?P.gray(this.formatTag(this.name)):"",c=P.blue("\u25D0");console.error(`${c} ${s} ${P.cyan(r)}`)}let o=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
10
10
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(o)}progress(e,t=""){if(!this.enabled||!this.fancy||D()||e<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let r=20;return this.activeProgressBar={total:e,current:0,message:t,barLength:r,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(s,c)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||D())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,s)),c!==void 0)this.activeProgressBar.message=c;let a=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,a)},finish:(s)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||D())return;if(this.activeProgressBar.current=this.activeProgressBar.total,s!==void 0)this.activeProgressBar.message=s;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(s,c="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||D())return;J.stdout.write(`${"\r".padEnd(J.stdout.columns||80)}\r`),this.log(c,s),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||D()||!J.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,o=P.green("\u2501".repeat(n)),s=P.gray("\u2501".repeat(i)),c=`[${o}${s}]`,a=`${r}%`.padStart(4),l=e.message?` ${e.message}`:"",u=t||r===100?P.green("\u2713"):P.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${P.gray(this.formatTag(this.name))}`:"",d=`\r${u}${f} ${c} ${a}${l}`,h=J.stdout.columns||80,m=" ".repeat(Math.max(0,h-d.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${d}${m}`,J.stdout.write(e.lastRenderedLine),t)J.stdout.write(`
11
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||D()||!J.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(D()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Jt(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let o=nt(this.config.logDirectory,n);if(e.before)try{if((await rt(o)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${o}:`,s);continue}r.push(o)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Xt(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function cr(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&I(t[0])&&"id"in t[0]&&t[0].id===3&&I(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(I(t)&&I(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(I(e)&&"arr"in e&&Array.isArray(e.arr)&&I(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&I(t[0])&&I(e[0])){let n=[...t];for(let i of e)if(I(i)&&"name"in i){if(!n.find((s)=>I(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(I(i)&&"path"in i){if(!n.find((s)=>I(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((o)=>wr(o,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!I(t)||!I(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(I(i)&&I(r[n]))r[n]=cr(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&I(i[0])&&I(r[n][0])){let o=[...i];for(let s of r[n])if(I(s)&&"name"in s){if(!o.find((a)=>I(a)&&("name"in a)&&a.name===s.name))o.push(s)}else if(I(s)&&"path"in s){if(!o.find((a)=>I(a)&&("path"in a)&&a.path===s.path))o.push(s)}else if(!o.some((c)=>wr(c,s)))o.push(s);r[n]=o}else if(i.every((o)=>typeof o==="string")&&r[n].every((o)=>typeof o==="string")){let o=[...i];for(let s of r[n])if(!o.includes(s))o.push(s);r[n]=o}else r[n]=i;else r[n]=i}return r}function ri(e,t,r="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return r==="replace"?t:cr(e,t);if(Array.isArray(e))return r==="replace"?t:cr(e,t);if(!I(t)||!I(e))return t;let n={...e};for(let i of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let o=t[i],s=n[i];if(o===null||o===void 0)continue;if(Array.isArray(o)||Array.isArray(s))if(r==="replace")n[i]=o;else n[i]=cr(s,o);else if(I(o)&&I(s))n[i]=ri(s,o,r);else n[i]=o}return n}function wr(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!wr(e[r],t[r]))return!1;return!0}if(I(e)&&I(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!wr(e[i],t[i]))return!1}return!0}return!1}function I(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function sr(e,t,r="replace"){if(!ys(e))return null;try{let n=await import(e),i=n.default||n;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return ri(t,i,r)}catch{return null}}catch{return null}}function Cd(e,t,r=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),i={...t};function o(s,c=[]){let a={...s};for(let[l,u]of Object.entries(s)){let f=[...c,l],d=(g)=>g.replace(/([A-Z])/g,"_$1").toUpperCase(),h=`${n}_${f.map(d).join("_")}`,m=`${n}_${f.map((g)=>g.toUpperCase()).join("_")}`;if(r)Z.info(`Checking environment variable ${h} for config ${e}.${f.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))a[l]=o(u,f);else{let g=Tt.env[h]||Tt.env[m];if(g!==void 0){if(r)Z.info(`Using environment variable ${g?h:m} for config ${e}.${f.join(".")}`);if(typeof u==="number")a[l]=Number(g);else if(typeof u==="boolean")a[l]=g.toLowerCase()==="true";else if(Array.isArray(u))try{let p=JSON.parse(g);if(Array.isArray(p))a[l]=p;else a[l]=g.split(",").map((y)=>y.trim())}catch{a[l]=g.split(",").map((p)=>p.trim())}else a[l]=g}}}return a}return o(i)}async function $d({name:e="",alias:t,cwd:r,configDir:n,defaultConfig:i,verbose:o=!1,checkEnv:s=!0,arrayStrategy:c="replace"}){let a=s&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Cd(e,i,o):i,l=r||Tt.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(o)Z.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${l}`);let f=[e,`.${e}`].filter(Boolean),d=[`${e}.config`,`.${e}.config`].filter(Boolean),h=t?[t,`.${t}`]:[],m=t?[`${t}.config`,`.${t}.config`]:[],g=Array.from(new Set([l,re(l,"config"),re(l,".config"),n?re(l,n):void 0].filter(Boolean)));for(let p of g){if(o)Z.info(`Searching for configuration in: ${p}`);let x=[re(l,"config"),re(l,".config")].concat(n?[re(l,n)]:[]).includes(p)?[...f,...d,...h,...m]:[...d,...f,...m,...h];for(let w of x)for(let T of u){let S=re(p,`${w}${T}`),j=await sr(S,a,c);if(j!==null){if(o)Z.success(`Configuration loaded from: ${S}`);return j}}}if(e){let p=re(wn(),".config",e),y=["config",`${e}.config`];if(t)y.push(`${t}.config`);if(o)Z.info(`Checking user config directory: ${p}`);for(let x of y)for(let w of u){let T=re(p,`${x}${w}`),S=await sr(T,a,c);if(S!==null){if(o)Z.success(`Configuration loaded from user config directory: ${T}`);return S}}}if(e){let p=re(wn(),".config"),y=[`.${e}.config`];if(t)y.push(`.${t}.config`);if(o)Z.info(`Checking user config directory for dotfile configs: ${p}`);for(let x of y)for(let w of u){let T=re(p,`${x}${w}`),S=await sr(T,a,c);if(S!==null){if(o)Z.success(`Configuration loaded from user config directory dotfile: ${T}`);return S}}}if(e){let p=wn(),y=[`.${e}.config`,`.${e}`];if(t)y.push(`.${t}.config`),y.push(`.${t}`);if(o)Z.info(`Checking user home directory for dotfile configs: ${p}`);for(let x of y)for(let w of u){let T=re(p,`${x}${w}`),S=await sr(T,a,c);if(S!==null){if(o)Z.success(`Configuration loaded from user home directory: ${T}`);return S}}}try{let p=re(l,"package.json");if(ys(p)){let y=await import(p),x=y[e];if(!x&&t){if(x=y[t],x&&o)Z.success(`Using alias "${t}" configuration from package.json`)}if(x&&typeof x==="object"&&!Array.isArray(x))try{if(o)Z.success(`Configuration loaded from package.json: ${x===y[e]?e:t}`);return ri(a,x,c)}catch(w){if(o)Z.warn("Failed to merge package.json config:",w)}}}catch(p){if(o)Z.warn("Failed to load package.json:",p)}if(o)Z.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return a}function Rd(e,t={}){let r=mr.cwd();while(r.includes("storage"))r=Oo(r,"..");let n=Oo(r,e||"");if(t?.relative)return Tf(mr.cwd(),n);return n}async function kd(){try{let e=await $d({name:"clarity",alias:"logging",defaultConfig:dr,cwd:mr.cwd()});return{...dr,...e||{}}}catch{return dr}}function K(){if(Ee.env.NODE_ENV==="test"||Ee.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Sd(){if(Ee.env.NODE_ENV==="test"||Ee.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ee<"u"){let e=Ee.type;if(e==="renderer"||e==="worker")return!1;return!!(Ee.versions&&(Ee.versions.node||Ee.versions.bun))}return!1}class ws{async format(e){let t=await Sd(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:at.pid,hostname:t(),environment:at.env.NODE_ENV||"development",platform:at.platform,version:at.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:at.env.NODE_ENV||at.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Cr{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...zn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new ws,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??N.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),o=this.generateKey();this.currentKeyId=i,this.keys.set(i,o),this.encryptionKeys.set(i,{key:o,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...hr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...hr};return{...hr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:zn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!K()&&this.config.writeToFile===!0}async writeToFile(e){let r=(async()=>{let i,o=0,s=3,c=1000;while(o<s)try{try{try{await Wf(this.config.logDirectory,Uo.F_OK|Uo.W_OK)}catch(l){if(l instanceof Error&&"code"in l)if(l.code==="ENOENT")await zf(this.config.logDirectory,{recursive:!0,mode:493});else if(l.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw l;else throw l}}catch(l){throw console.error("Debug: [writeToFile] Failed to create log directory:",l),l}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:ke.from(e);try{if(!Zt(this.currentLogFile))await En(this.currentLogFile,"",{mode:420});if(i=Vo(this.currentLogFile,"a",420),Uf(i,a,{flag:"a"}),Bo(i),i!==void 0)An(i),i=void 0;if((await ot(this.currentLogFile)).size===0){if(await En(this.currentLogFile,a,{flag:"w",mode:420}),(await ot(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(l){let u=l;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(o<s-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${o+1}/${s}:`,f);let d=c*2**o;await new Promise((h)=>setTimeout(h,d)),o++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{An(i)}catch(l){console.error("Debug: [writeToFile] Error closing file descriptor:",l)}}}catch(a){if(o===s-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}o++;let l=c*2**(o-1);await new Promise((u)=>setTimeout(u,l))}})();this.pendingOperations.push(r);let n=this.pendingOperations.length-1;try{await r}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(n,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return st(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return st(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return st(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(K())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let t=this.config.rotation.keyRotation;if(!t?.enabled)return;let r=typeof t.interval==="number"?t.interval:60,n=Math.max(r,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},n)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let t=this.config.rotation.keyRotation,r=this.generateKeyId(),n=this.generateKey();this.currentKeyId=r,this.keys.set(r,n),this.encryptionKeys.set(r,{key:n,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,c],[,a])=>a.createdAt.getTime()-c.createdAt.getTime()),o=typeof t.maxKeys==="number"?t.maxKeys:1,s=Math.max(1,o);if(i.length>s)for(let[c]of i.slice(s))this.encryptionKeys.delete(c),this.keys.delete(c)}generateKeyId(){return Sn(16).toString("hex")}generateKey(){return Sn(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=Sn(16),n=jf("aes-256-gcm",t,r),i=ke.isBuffer(e)?e:ke.from(e,"utf8"),o=n.update(i),s=n.final(),c=o.length+s.length,a=n.getAuthTag(),l=ke.allocUnsafe(16+c+16);return r.copy(l,0),o.copy(l,16),s.copy(l,16+o.length),a.copy(l,16+c),{encrypted:l,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=zo(),i=[];n.on("data",(o)=>i.push(o)),n.on("end",()=>t(ke.from(ke.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(K())return;if(!this.shouldWriteToFile())return;let e=await ot(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Qt(this.config.logDirectory),o=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,l)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(l.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,c=`${r}.${s}`;if(await ot(r).catch(()=>null))try{if(await Wo(r,c),t.compress)try{let a=`${c}.gz`;await this.compressLogFile(c,a),await er(c)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${r}.1`;await En(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),o=r.replace(/\.log$/,`-${i}.log`);if(await ot(r).catch(()=>null))await Wo(r,o)}if(this.currentLogFile=n,t.maxFiles){let o=(await Qt(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,c)=>c.localeCompare(s));for(let s of o.slice(t.maxFiles))await er(st(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=jo(e),n=Vf(t),i=zo();await Gf(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Zt(this.currentLogFile))try{let e=Vo(this.currentLogFile,"r+");Bo(e),An(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!K()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let t=(await Qt(this.config.logDirectory)).filter((r)=>(r.includes("temp")||r.includes(".tmp"))&&r.includes(this.name));for(let r of t)try{await er(st(this.config.logDirectory,r))}catch(n){console.error(`Failed to delete temp file ${r}:`,n)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?A.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||K())return!1;let e=typeof N.env.NO_COLOR<"u",t=N.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof N.stderr<"u"&&N.stderr.isTTY||typeof N.stdout<"u"&&N.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:o,showTimestamp:s=!0}=e,c=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(s)h.push(t);if(o==="warning")h.push("WARN");else if(o==="error")h.push("ERROR");else if(r)h.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)h.push(n.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=N.stdout.columns||120,l="";if(o==="warning"||o==="error")l=`${r} ${i}`;else if(o==="info"||o==="success")l=`${r} ${n} ${i}`;else l=`${r} ${n} ${A.cyan(i)}`;if(!s)return l.trim();let u=c(l).trim().length,f=c(t).length,d=Math.max(1,a-2-u-f);return`${l.trim()}${" ".repeat(d)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let c=Number.parseInt(s,10);return c<t[0].length?String(t[0][c]):o});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let c=t[n++];switch(s){case"s":return String(c);case"d":case"i":return Number(c).toString();case"j":case"o":return JSON.stringify(c,null,2);default:return o}});if(n<t.length)i+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let o=A.underline(A.blue(n)),s=this.toAbsoluteFilePath(i);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let c=`file://${encodeURI(s)}`,a="\x1B]8;;",l="\x1B\\";return`\x1B]8;;${c}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(r,n)=>A.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>A.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>A.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>A.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>A.strikethrough(n)),t}supportsHyperlinks(){if(K())return!1;let e=N.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let r=N.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(Kf(t)||t.startsWith("./")||t.startsWith("../"))t=Hf(t);else return null;return Zt(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,c;if(t instanceof Error)s=t.message,c=t.stack;else s=this.formatMessage(t,r);let{consoleText:a,fileText:l}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let f=this.options.showIcons===!1?"":Os[e],d=this.options.showTags!==!1&&this.name?A.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:A.gray(a),level:e}),console.error(h);break;case"info":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:a,level:e}),console.warn(h);break;case"success":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:A.green(a),level:e}),console.error(h);break;case"warning":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:a,level:e}),console.warn(h);break;case"error":if(h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:a,level:e}),console.error(h),c){let m=c.split(`
11
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||D()||!J.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(D()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Jt(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let o=nt(this.config.logDirectory,n);if(e.before)try{if((await rt(o)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${o}:`,s);continue}r.push(o)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Xt(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function cr(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&I(t[0])&&"id"in t[0]&&t[0].id===3&&I(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(I(t)&&I(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(I(e)&&"arr"in e&&Array.isArray(e.arr)&&I(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&I(t[0])&&I(e[0])){let n=[...t];for(let i of e)if(I(i)&&"name"in i){if(!n.find((s)=>I(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(I(i)&&"path"in i){if(!n.find((s)=>I(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((o)=>wr(o,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!I(t)||!I(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(I(i)&&I(r[n]))r[n]=cr(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&I(i[0])&&I(r[n][0])){let o=[...i];for(let s of r[n])if(I(s)&&"name"in s){if(!o.find((a)=>I(a)&&("name"in a)&&a.name===s.name))o.push(s)}else if(I(s)&&"path"in s){if(!o.find((a)=>I(a)&&("path"in a)&&a.path===s.path))o.push(s)}else if(!o.some((c)=>wr(c,s)))o.push(s);r[n]=o}else if(i.every((o)=>typeof o==="string")&&r[n].every((o)=>typeof o==="string")){let o=[...i];for(let s of r[n])if(!o.includes(s))o.push(s);r[n]=o}else r[n]=i;else r[n]=i}return r}function ri(e,t,r="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return r==="replace"?t:cr(e,t);if(Array.isArray(e))return r==="replace"?t:cr(e,t);if(!I(t)||!I(e))return t;let n={...e};for(let i of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let o=t[i],s=n[i];if(o===null||o===void 0)continue;if(Array.isArray(o)||Array.isArray(s))if(r==="replace")n[i]=o;else n[i]=cr(s,o);else if(I(o)&&I(s))n[i]=ri(s,o,r);else n[i]=o}return n}function wr(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!wr(e[r],t[r]))return!1;return!0}if(I(e)&&I(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!wr(e[i],t[i]))return!1}return!0}return!1}function I(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function sr(e,t,r="replace"){if(!ys(e))return null;try{let n=await import(e),i=n.default||n;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return ri(t,i,r)}catch{return null}}catch{return null}}function Cd(e,t,r=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),i={...t};function o(s,c=[]){let a={...s};for(let[l,u]of Object.entries(s)){let f=[...c,l],d=(g)=>g.replace(/([A-Z])/g,"_$1").toUpperCase(),h=`${n}_${f.map(d).join("_")}`,m=`${n}_${f.map((g)=>g.toUpperCase()).join("_")}`;if(r)Z.info(`Checking environment variable ${h} for config ${e}.${f.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))a[l]=o(u,f);else{let g=Tt.env[h]||Tt.env[m];if(g!==void 0){if(r)Z.info(`Using environment variable ${g?h:m} for config ${e}.${f.join(".")}`);if(typeof u==="number")a[l]=Number(g);else if(typeof u==="boolean")a[l]=g.toLowerCase()==="true";else if(Array.isArray(u))try{let p=JSON.parse(g);if(Array.isArray(p))a[l]=p;else a[l]=g.split(",").map((y)=>y.trim())}catch{a[l]=g.split(",").map((p)=>p.trim())}else a[l]=g}}}return a}return o(i)}async function $d({name:e="",alias:t,cwd:r,configDir:n,defaultConfig:i,verbose:o=!1,checkEnv:s=!0,arrayStrategy:c="replace"}){let a=s&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Cd(e,i,o):i,l=r||Tt.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(o)Z.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${l}`);let f=[e,`.${e}`].filter(Boolean),d=[`${e}.config`,`.${e}.config`].filter(Boolean),h=t?[t,`.${t}`]:[],m=t?[`${t}.config`,`.${t}.config`]:[],g=Array.from(new Set([l,re(l,"config"),re(l,".config"),n?re(l,n):void 0].filter(Boolean)));for(let p of g){if(o)Z.info(`Searching for configuration in: ${p}`);let b=[re(l,"config"),re(l,".config")].concat(n?[re(l,n)]:[]).includes(p)?[...f,...d,...h,...m]:[...d,...f,...m,...h];for(let w of b)for(let T of u){let S=re(p,`${w}${T}`),j=await sr(S,a,c);if(j!==null){if(o)Z.success(`Configuration loaded from: ${S}`);return j}}}if(e){let p=re(wn(),".config",e),y=["config",`${e}.config`];if(t)y.push(`${t}.config`);if(o)Z.info(`Checking user config directory: ${p}`);for(let b of y)for(let w of u){let T=re(p,`${b}${w}`),S=await sr(T,a,c);if(S!==null){if(o)Z.success(`Configuration loaded from user config directory: ${T}`);return S}}}if(e){let p=re(wn(),".config"),y=[`.${e}.config`];if(t)y.push(`.${t}.config`);if(o)Z.info(`Checking user config directory for dotfile configs: ${p}`);for(let b of y)for(let w of u){let T=re(p,`${b}${w}`),S=await sr(T,a,c);if(S!==null){if(o)Z.success(`Configuration loaded from user config directory dotfile: ${T}`);return S}}}if(e){let p=wn(),y=[`.${e}.config`,`.${e}`];if(t)y.push(`.${t}.config`),y.push(`.${t}`);if(o)Z.info(`Checking user home directory for dotfile configs: ${p}`);for(let b of y)for(let w of u){let T=re(p,`${b}${w}`),S=await sr(T,a,c);if(S!==null){if(o)Z.success(`Configuration loaded from user home directory: ${T}`);return S}}}try{let p=re(l,"package.json");if(ys(p)){let y=await import(p),b=y[e];if(!b&&t){if(b=y[t],b&&o)Z.success(`Using alias "${t}" configuration from package.json`)}if(b&&typeof b==="object"&&!Array.isArray(b))try{if(o)Z.success(`Configuration loaded from package.json: ${b===y[e]?e:t}`);return ri(a,b,c)}catch(w){if(o)Z.warn("Failed to merge package.json config:",w)}}}catch(p){if(o)Z.warn("Failed to load package.json:",p)}if(o)Z.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return a}function Rd(e,t={}){let r=mr.cwd();while(r.includes("storage"))r=Oo(r,"..");let n=Oo(r,e||"");if(t?.relative)return Tf(mr.cwd(),n);return n}async function kd(){try{let e=await $d({name:"clarity",alias:"logging",defaultConfig:dr,cwd:mr.cwd()});return{...dr,...e||{}}}catch{return dr}}function K(){if(Ee.env.NODE_ENV==="test"||Ee.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Sd(){if(Ee.env.NODE_ENV==="test"||Ee.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ee<"u"){let e=Ee.type;if(e==="renderer"||e==="worker")return!1;return!!(Ee.versions&&(Ee.versions.node||Ee.versions.bun))}return!1}class ws{async format(e){let t=await Sd(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:at.pid,hostname:t(),environment:at.env.NODE_ENV||"development",platform:at.platform,version:at.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:at.env.NODE_ENV||at.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Cr{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...zn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new ws,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??N.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),o=this.generateKey();this.currentKeyId=i,this.keys.set(i,o),this.encryptionKeys.set(i,{key:o,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...hr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...hr};return{...hr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:zn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!K()&&this.config.writeToFile===!0}async writeToFile(e){let r=(async()=>{let i,o=0,s=3,c=1000;while(o<s)try{try{try{await Wf(this.config.logDirectory,Uo.F_OK|Uo.W_OK)}catch(l){if(l instanceof Error&&"code"in l)if(l.code==="ENOENT")await zf(this.config.logDirectory,{recursive:!0,mode:493});else if(l.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw l;else throw l}}catch(l){throw console.error("Debug: [writeToFile] Failed to create log directory:",l),l}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:ke.from(e);try{if(!Zt(this.currentLogFile))await En(this.currentLogFile,"",{mode:420});if(i=Vo(this.currentLogFile,"a",420),Uf(i,a,{flag:"a"}),Bo(i),i!==void 0)An(i),i=void 0;if((await ot(this.currentLogFile)).size===0){if(await En(this.currentLogFile,a,{flag:"w",mode:420}),(await ot(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(l){let u=l;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(o<s-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${o+1}/${s}:`,f);let d=c*2**o;await new Promise((h)=>setTimeout(h,d)),o++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{An(i)}catch(l){console.error("Debug: [writeToFile] Error closing file descriptor:",l)}}}catch(a){if(o===s-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}o++;let l=c*2**(o-1);await new Promise((u)=>setTimeout(u,l))}})();this.pendingOperations.push(r);let n=this.pendingOperations.length-1;try{await r}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(n,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return st(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return st(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return st(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(K())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let t=this.config.rotation.keyRotation;if(!t?.enabled)return;let r=typeof t.interval==="number"?t.interval:60,n=Math.max(r,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},n)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let t=this.config.rotation.keyRotation,r=this.generateKeyId(),n=this.generateKey();this.currentKeyId=r,this.keys.set(r,n),this.encryptionKeys.set(r,{key:n,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,c],[,a])=>a.createdAt.getTime()-c.createdAt.getTime()),o=typeof t.maxKeys==="number"?t.maxKeys:1,s=Math.max(1,o);if(i.length>s)for(let[c]of i.slice(s))this.encryptionKeys.delete(c),this.keys.delete(c)}generateKeyId(){return Sn(16).toString("hex")}generateKey(){return Sn(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=Sn(16),n=jf("aes-256-gcm",t,r),i=ke.isBuffer(e)?e:ke.from(e,"utf8"),o=n.update(i),s=n.final(),c=o.length+s.length,a=n.getAuthTag(),l=ke.allocUnsafe(16+c+16);return r.copy(l,0),o.copy(l,16),s.copy(l,16+o.length),a.copy(l,16+c),{encrypted:l,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=zo(),i=[];n.on("data",(o)=>i.push(o)),n.on("end",()=>t(ke.from(ke.concat(i)))),n.on("error",r),n.write(e),n.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(K())return;if(!this.shouldWriteToFile())return;let e=await ot(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Qt(this.config.logDirectory),o=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,l)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(l.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,c=`${r}.${s}`;if(await ot(r).catch(()=>null))try{if(await Wo(r,c),t.compress)try{let a=`${c}.gz`;await this.compressLogFile(c,a),await er(c)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${r}.1`;await En(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),o=r.replace(/\.log$/,`-${i}.log`);if(await ot(r).catch(()=>null))await Wo(r,o)}if(this.currentLogFile=n,t.maxFiles){let o=(await Qt(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,c)=>c.localeCompare(s));for(let s of o.slice(t.maxFiles))await er(st(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=jo(e),n=Vf(t),i=zo();await Gf(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Zt(this.currentLogFile))try{let e=Vo(this.currentLogFile,"r+");Bo(e),An(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!K()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let t=(await Qt(this.config.logDirectory)).filter((r)=>(r.includes("temp")||r.includes(".tmp"))&&r.includes(this.name));for(let r of t)try{await er(st(this.config.logDirectory,r))}catch(n){console.error(`Failed to delete temp file ${r}:`,n)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?A.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||K())return!1;let e=typeof N.env.NO_COLOR<"u",t=N.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof N.stderr<"u"&&N.stderr.isTTY||typeof N.stdout<"u"&&N.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:o,showTimestamp:s=!0}=e,c=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(s)h.push(t);if(o==="warning")h.push("WARN");else if(o==="error")h.push("ERROR");else if(r)h.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)h.push(n.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=N.stdout.columns||120,l="";if(o==="warning"||o==="error")l=`${r} ${i}`;else if(o==="info"||o==="success")l=`${r} ${n} ${i}`;else l=`${r} ${n} ${A.cyan(i)}`;if(!s)return l.trim();let u=c(l).trim().length,f=c(t).length,d=Math.max(1,a-2-u-f);return`${l.trim()}${" ".repeat(d)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let c=Number.parseInt(s,10);return c<t[0].length?String(t[0][c]):o});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let c=t[n++];switch(s){case"s":return String(c);case"d":case"i":return Number(c).toString();case"j":case"o":return JSON.stringify(c,null,2);default:return o}});if(n<t.length)i+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let o=A.underline(A.blue(n)),s=this.toAbsoluteFilePath(i);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let c=`file://${encodeURI(s)}`,a="\x1B]8;;",l="\x1B\\";return`\x1B]8;;${c}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(r,n)=>A.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>A.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>A.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>A.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>A.strikethrough(n)),t}supportsHyperlinks(){if(K())return!1;let e=N.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let r=N.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(Kf(t)||t.startsWith("./")||t.startsWith("../"))t=Hf(t);else return null;return Zt(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,c;if(t instanceof Error)s=t.message,c=t.stack;else s=this.formatMessage(t,r);let{consoleText:a,fileText:l}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let f=this.options.showIcons===!1?"":Os[e],d=this.options.showTags!==!1&&this.name?A.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:A.gray(a),level:e}),console.error(h);break;case"info":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:a,level:e}),console.warn(h);break;case"success":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:A.green(a),level:e}),console.error(h);break;case"warning":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:a,level:e}),console.warn(h);break;case"error":if(h=this.formatConsoleMessage({timestamp:i,icon:f,tag:d,message:a,level:e}),console.error(h),c){let m=c.split(`
12
12
  `);for(let g of m)if(g.trim()&&!g.includes(s))console.error(this.formatConsoleMessage({timestamp:i,message:A.gray(` ${g}`),level:e,showTimestamp:!1}))}break}}else if(!K()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),c)console.error(c)}if(!this.shouldLog(e))return;let u=`${o} ${this.environment}.${e.toUpperCase()}: ${l}
13
13
  `;if(c)u+=`${c}
14
14
  `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(c,a)=>{},finish:(c)=>{},interrupt:(c,a)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!K()&&N.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(c,a)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,c),this.activeProgressBar.total),a!==void 0)this.activeProgressBar.message=a;if(this.shouldStyleConsole()&&!K()&&N.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(c)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,c)},interrupt:(c,a="info")=>{if(!K()&&N.stdout.isTTY)N.stdout.write(`
@@ -59,7 +59,7 @@ export type ConfigOf = Config
59
59
  `;r+=`| Variable | Type | Description | Example |
60
60
  `,r+=`|----------|------|-------------|----------|
61
61
  `;for(let n of e)r+=`| \`${n.key}\` | ${n.type} | ${n.description} | \`${n.example}\` |
62
- `;return r}}function $h(e,t,r={}){return Ks(e,t,r,new WeakMap)}function Ks(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:o=!1,customMerger:s}=r;if(t===null||t===void 0)return o?e:t;if(s){let c=s(e,t);if(c!==void 0)return c}if(Array.isArray(t)||Array.isArray(e))return Hs(e,t,i,n);if(!ue(t)||!ue(e))return t;return Ah(e,t,r,n)}function Hs(e,t,r,n){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(r){case"replace":return t;case"concat":return Rh(e,t);case"smart":return kh(e,t,n);default:return t}return t}function Rh(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>Xn(i,n)))r.push(n);return r}function kh(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(ue(t[0])&&ue(e[0]))return Sh(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Sh(e,t,r){let n=[...t];for(let i of e){if(!ue(i)){n.push(i);continue}let o=["id","name","key","path","type"],s=!1;for(let c of o)if(c in i){if(n.find((l)=>ue(l)&&(c in l)&&l[c]===i[c])){s=!0;break}}if(!s)n.push(i)}return n}function Ah(e,t,r,n){let i=t;if(ue(i)&&n.has(i))return n.get(i);let o={...e};if(ue(i))n.set(i,o);for(let s in i){if(!Object.prototype.hasOwnProperty.call(i,s))continue;let c=i[s],a=o[s];if(r.skipNullish&&(c===null||c===void 0))continue;if(c===null||c===void 0){o[s]=c;continue}if(ue(c)&&ue(a))o[s]=Ks(a,c,r,n);else if(Array.isArray(c)||Array.isArray(a))o[s]=Hs(a,c,r.arrayMergeMode||"smart",n);else o[s]=c}return o}function Gs(e,t,r="replace"){return $h(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function Xn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Xn(e[r],t[r]))return!1;return!0}if(ue(e)&&ue(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Xn(e[i],t[i]))return!1}return!0}return!1}function ue(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class qs{extensions=ms;async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:o,trackPerformance:s=!0,verbose:c=!1}=r;if(i){let l=gr.getWithFileCheck("file",e);if(l){if(c)console.log(`Configuration loaded from cache: ${e}`);return l}}let a=async()=>{if(!lr(e))return null;try{let l=`?t=${Date.now()}`,u=await import(e+l),f=u.default||u,d="default"in u,h=Object.keys(u).length>0;if(!d&&!h)throw new Sr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof f!=="object"||f===null||Array.isArray(f))throw new Sr(e,Error("Configuration must export a valid object"),"unknown");let p={config:Gs(t,f,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)gr.setWithFileCheck("file",p,e,o);return p}catch(l){throw l instanceof Error?He.configLoad(e,l):He.configLoad(e,Error(String(l)))}};if(s)return Zn.track("loadFromPath",a,{path:e});return a()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){return wf({name:e,directory:t,alias:r})}generateNamePatterns(e,t){return ps({name:e,alias:t})}checkFileAccess(e){return Ch(async()=>lr(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!lr(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let o of i)for(let s of this.extensions){let c=ds(e,`${o}${s}`);if(await this.checkFileAccess(c))n.push(c)}}else try{let{readdirSync:i}=await import("fs"),o=i(e);for(let s of o)if(this.looksLikeConfigFile(s)){let c=ds(e,s);if(await this.checkFileAccess(c))n.push(c)}}catch{return[]}return n}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((r)=>r.test(e))}async validateConfigFile(e){let t=[];try{if(!lr(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),o=i(e,"utf8");JSON.parse(o)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class Ys{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:c=!0,verbose:a=!1}=r,l=async()=>{let u=[],f=[],d={stopOnFirstError:n,validateRequired:i,validateTypes:o,customRules:s,trackPerformance:c,verbose:a};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,d);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],d);else return this.validateWithJSONSchema(e,t,d)}catch(h){return u.push({path:"",message:`Validation failed: ${h}`,rule:"system"}),{isValid:!1,errors:u,warnings:f}}};if(c)return await Zn.track("validateConfiguration",l);return l()}async validateWithSchemaFile(e,t,r){try{if(!Eh(t))throw new Ar(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new Ar(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,c=Array.isArray(t.type)?t.type:[t.type];if(!c.includes(s)){if(n.push({path:r,message:`Expected type ${c.join(" or ")}, got ${s}`,expected:c.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),o.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)n.push({path:r,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))n.push({path:r,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)n.push({path:r,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)n.push({path:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let s=0;s<e.length;s++){let c=r?`${r}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,c,n,i,o),o.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let c of t.required)if(!(c in s)){if(n.push({path:r?`${r}.${c}`:c,message:`Missing required property '${c}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[c,a]of Object.entries(t.properties))if(c in s){let l=r?`${r}.${c}`:c;if(this.validateObjectAgainstSchema(s[c],a,l,n,i,o),o.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let c=new Set(Object.keys(t.properties||{}));for(let a of Object.keys(s))if(!c.has(a))i.push({path:r?`${r}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),c=this.validateWithRule(s,o,o.path);if(n.push(...c),r.stopOnFirstError&&n.length>0)break}catch(s){n.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))n.push({path:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,o,s]=n;t.push({path:i,required:!o,type:this.mapTypeScriptType(s)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:Th},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function Nh(e){if(!e)return"";let t=Array.isArray(e)?e.filter(Boolean):[e];if(t.length===0)return"";if(t.length===1)return` or alias "${t[0]}"`;return` or aliases ${t.map((r)=>`"${r}"`).join(", ")}`}class Js{fileLoader=new qs;envProcessor=new ai;validator=new Ys;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:o,...s}=e;try{if(r?.enabled){let a=this.checkCache(s.name||"",s);if(a)return a}let c;try{c=await this.loadConfigurationStrategies(s,!0,r)}catch(a){if(s.configFile)throw a;let l=s.__strictErrorHandling;if(a instanceof Error&&a.name==="ConfigNotFoundError"){if(l)throw a;c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`No configuration file found for "${s.name||"config"}", using defaults with environment variables`]}}else if(a instanceof Error&&a.name==="ConfigLoadError"){let u=a.message.includes("EACCES")||a.message.includes("EPERM")||a.message.includes("permission denied"),f=!u&&(a.message.includes("syntax")||a.message.includes("Expected")||a.message.includes("Unexpected")||a.message.includes("BuildMessage")||a.message.includes("errors building")),d=a.message.includes("Configuration must export a valid object")||a.message.includes("Configuration file is empty and exports nothing");if(l&&(d||u))throw a;if(f&&(!l||!d))c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!l)c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${a.message}`]};else throw a}else c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${a instanceof Error?a.message:String(a)}`]}}if(i||o)await this.validateConfiguration(c.config,i,o,s.name);if(r?.enabled&&c)this.cacheResult(s.name||"",c,r,s);if(n?.enabled){let a={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(a);if(n.slowThreshold&&a.duration>n.slowThreshold)he.warn(`Slow configuration loading detected: ${a.duration}ms for ${s.name}`);c.metrics=a}return c}catch(c){if(c instanceof Error&&c.name==="ConfigNotFoundError")throw c;let a=Date.now()-t;throw he.error(`Configuration loading failed after ${a}ms:`,[c instanceof Error?c:Error(String(c))]),c}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,configFile:o,cwd:s,configDir:c,defaultConfig:a,checkEnv:l=!0,arrayStrategy:u="replace",verbose:f=!1}=e,d=s||Er.cwd(),h=[];if(o){let x=ve(d,o);h.push(x);let w=l?St(n,a,f):a,T=await this.fileLoader.tryLoadFromPaths([x],w,{arrayStrategy:u,verbose:f,cacheTtl:r?.ttl,useCache:!r?.ttl||r.ttl>100});if(!T)throw He.configNotFound(n||o,h,i);if(f)he.success(`Configuration loaded from explicit path: ${x}`);return this.finalizeResult(T,h,l,n,f)}let m=await this.loadLocalConfiguration(n,i,d,c,a,u,f,l,r);if(m)return h.push(...this.getLocalSearchPaths(n,i,d,c)),this.finalizeResult(m,h,l,n,f);let g=await this.loadHomeConfiguration(n,i,a,u,f,l);if(g)return h.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(g,h,l,n,f);let p=await this.loadPackageJsonConfiguration(n,i,d,a,u,f,l);if(p)return h.push(ve(d,"package.json")),this.finalizeResult(p,h,l,n,f);if(h.push(...this.getAllSearchPaths(n,i,d,c)),t)throw He.configNotFound(n,h,i);return{...await this.applyEnvironmentVariables(n,a,l,f),warnings:[`No configuration file found for "${n}"${Nh(i)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,o,s,c,a){let l=c?St(e,i,s):i,u=this.getLocalDirectories(r,n);for(let f of u){if(s)he.info(`Searching for configuration in: ${f}`);let d=this.fileLoader.generateConfigPaths(e,f,t),h=await this.fileLoader.tryLoadFromPaths(d,l,{arrayStrategy:o,verbose:s,cacheTtl:a?.ttl,useCache:!a?.ttl||a.ttl>100});if(h){if(s)he.success(`Configuration loaded from: ${h.source.path}`);return h}}return null}async loadHomeConfiguration(e,t,r,n,i,o){if(!e)return null;let s=o?St(e,r,i):r,c=[ve(et(),".config",e),ve(et(),".config"),et()];for(let a of c){if(i)he.info(`Checking home directory: ${a}`);let l=this.fileLoader.generateConfigPaths(e,a,t),u=await this.fileLoader.tryLoadFromPaths(l,s,{arrayStrategy:n,verbose:i});if(u){if(i)he.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,o,s){let c=s?St(e,n,o):n;try{let a=ve(r,"package.json");if(!$f(a))return null;let l={};try{l=JSON.parse(Rf(a,"utf8"))}catch(d){if(o)he.warn("Failed to parse package.json:",[d instanceof Error?d:Error(String(d))]);return null}let u=l[e],f=e;if(!u&&t){let d=Array.isArray(t)?t:[t];for(let h of d){if(!h)continue;if(l[h]){u=l[h],f=h;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)he.success(`Configuration loaded from package.json: ${f}`);return{config:Gs(c,u,i),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(o)he.warn("Failed to load package.json:",[a instanceof Error?a:Error(String(a))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:St(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let o=r(e);if(o)i.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)i.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(i.length>0)throw He.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return gr.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);gr.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;r.push(`alias:${n}`)}if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configFile)r.push(`configFile:${t.configFile}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Cf({cwd:e,configDir:t})}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(ve(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),o=[];for(let s of i)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let r=[ve(et(),".config",e),ve(et(),".config"),et()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}async function Xs(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},r="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let n;if(r)n=await jn.loadConfig(e);else n=await jn.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return n?.config??t}catch(n){if(e.configFile)throw n;let i=n instanceof Error?n.name:"UnknownError",o=n instanceof Error?n.message:String(n);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||o.includes("config"))&&e.verbose)he.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);let c=r?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await jn.applyEnvironmentVariables(c.name||"",t,!0,c.verbose||!1))?.config??t;return t}}function St(e,t,r=!1){let n=new ai,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,c=[]){let a={...s};for(let[l,u]of Object.entries(s)){let f=[...c,l],d=[`${i}_${f.join("_").toUpperCase()}`,`${i}_${f.map((g)=>g.toUpperCase()).join("")}`,`${i}_${f.map((g)=>g.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],h,m;for(let g of d)if(h=Er.env[g],h!==void 0){m=g;break}if(h!==void 0&&m)if(typeof u==="boolean")a[l]=["true","1","yes"].includes(h.toLowerCase());else if(typeof u==="number"){let g=Number(h);if(!Number.isNaN(g))a[l]=g}else if(Array.isArray(u))try{a[l]=JSON.parse(h)}catch{a[l]=h.split(",").map((g)=>g.trim())}else a[l]=h;else if(u&&typeof u==="object"&&!Array.isArray(u))a[l]=o(u,f)}return a}return o(t)}var gr,Zn,ms,cd,ud=(e)=>e,dd=(e,t)=>{for(var r in t)cd(e,r,{get:t[r],enumerable:!0,configurable:!0,set:fd.bind(t,r)})},hd=(e,t)=>()=>(e&&(t=e(e=0)),t),xs,Es,ft,It,Ts,Bd,Vd,es,ur,Wn,X,P,Ud,ts,Wd,rs,zd,Kd,_n,Hd,ns,is,Ln,Gd,qd,Yd,Jd,fr,Ns,Xd,Z,Zd,Qd,os,dr,zn,H,A,eh,ss,th,as,rh,nh,Mn,ih,ls,cs,oh,Fn,sh,ah,lh,ch,uh,hr,Os,fh,dh="0.15.6",ae,$r,Nt,Kn,Hn,Rr,Gn,qn,Ot,Yn,Jn,Fe,Is,Ps,ge,Ne,_s,Ls,hh,mh,Ms,kr,O1,Y,E,I1,yh,P1,bh,_1,L1,us,M1,xh,vh,F1,fs,D1,j1,B1,V1,U1,Dn,wh,W1,me,Ds,Sr,js,Bs,si,Vs,Us,Ar,Ws,zs,He,Th,he,jn,q1,Y1;var Zs=yc(()=>{gr=new hs,Zn=new gs,ms=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];cd=Object.defineProperty;xs={};dd(xs,{withErrorRecovery:()=>Cs,tryLoadConfig:()=>Md,loadConfigWithResult:()=>_d,loadConfig:()=>As,isRetryableError:()=>Ed,isConfigNotFoundError:()=>Ad,isBunfigError:()=>$s,globalPerformanceMonitor:()=>It,globalCache:()=>ft,getEnvOrDefault:()=>Td,generateConfigTypes:()=>Fd,defaultGeneratedDir:()=>Ls,defaultConfigDir:()=>_s,deepMergeWithArrayStrategy:()=>ni,deepMerge:()=>Rs,createLibraryConfig:()=>Dd,config:()=>Ld,bunfigPlugin:()=>jd,applyEnvVarsToConfig:()=>Et,TypeGenerationError:()=>qn,SchemaValidationError:()=>Ot,PluginError:()=>Jn,PerformanceMonitor:()=>ei,FileSystemError:()=>Gn,ErrorFactory:()=>Fe,EnvVarError:()=>Rr,EnvProcessor:()=>Tr,ConfigValidator:()=>ii,ConfigValidationError:()=>Kn,ConfigNotFoundError:()=>$r,ConfigMergeError:()=>Hn,ConfigLoader:()=>oi,ConfigLoadError:()=>Nt,ConfigFileLoader:()=>Nr,ConfigCache:()=>Qn,CacheUtils:()=>Ts,BunfigError:()=>ae,BrowserConfigError:()=>Yn,ArrayMergeStrategies:()=>Is});hh=hd(async()=>{Es=import.meta.require,ft=new Qn,It=new ei,Ts={createKey:gd,isEquivalent:md,estimateMemoryUsage:pd},Bd=yr(Vn.cwd(),"config"),Vd=yr(Vn.cwd(),"src/generated"),es=pr.env.CLARITY_LOG_DIR||Nf(xd(),"logs"),ur={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:es,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},Wn=await vd(),X={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,reset:"\x1B[0m"},P=X,Ud=X.red,ts=X.green,Wd=X.yellow,rs=X.blue,zd=X.magenta,Kd=X.cyan,_n=X.white,Hd=X.gray,ns=X.bgRed,is=X.bgYellow,Ln=X.bold,Gd=X.dim,qd=X.italic,Yd=X.underline,Jd=X.reset,fr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ns={debug:"\uD83D\uDD0D",info:rs("\u2139"),success:ts("\u2713"),warning:is(_n(Ln(" WARN "))),error:ns(_n(Ln(" ERROR ")))},Xd=new vr("stacks"),Z=new vr("bunfig",{showTags:!0}),Zd=re(Tt.cwd(),"config"),Qd=re(Tt.cwd(),"src/generated"),os=mr.env.CLARITY_LOG_DIR||Ef(Rd(),"logs"),dr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:os,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},zn=await kd(),H={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},A=H,eh=H.red,ss=H.green,th=H.yellow,as=H.blue,rh=H.magenta,nh=H.cyan,Mn=H.white,ih=H.gray,ls=H.bgRed,cs=H.bgYellow,oh=H.bgGray,Fn=H.bold,sh=H.dim,ah=H.italic,lh=H.underline,ch=H.strikethrough,uh=H.reset,hr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Os={debug:"\uD83D\uDD0D",info:as("\u2139"),success:ss("\u2713"),warning:cs(Mn(Fn(" WARN "))),error:ls(Mn(Fn(" ERROR ")))},fh=new Cr("stacks"),ae=class extends Error{timestamp;context;constructor(t,r={}){super(t);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=r,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let t=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([r,n])=>`${r}: ${n}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${t}`}},$r=class extends ae{code="CONFIG_NOT_FOUND";constructor(t,r,n){let i=n?` or alias "${n}"`:"";super(`Configuration "${t}"${i} not found`,{configName:t,alias:n,searchPaths:r,searchPathCount:r.length})}},Nt=class extends ae{code="CONFIG_LOAD_ERROR";constructor(t,r,n){super(`Failed to load configuration from "${t}": ${r.message}`,{configPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}},Kn=class extends ae{code="CONFIG_VALIDATION_ERROR";constructor(t,r,n){super(`Configuration validation failed for "${t}"`,{configPath:t,configName:n,validationErrors:r,errorCount:r.length})}},Hn=class extends ae{code="CONFIG_MERGE_ERROR";constructor(t,r,n,i){super(`Failed to merge configuration from "${t}" with "${r}": ${n.message}`,{sourcePath:t,targetPath:r,configName:i,originalError:n.name,originalMessage:n.message});this.cause=n}},Rr=class extends ae{code="ENV_VAR_ERROR";constructor(t,r,n,i){super(`Failed to parse environment variable "${t}" with value "${r}" as ${n}`,{envKey:t,envValue:r,expectedType:n,configName:i})}},Gn=class extends ae{code="FILE_SYSTEM_ERROR";constructor(t,r,n){super(`File system ${t} failed for "${r}": ${n.message}`,{operation:t,path:r,originalError:n.name,originalMessage:n.message});this.cause=n}},qn=class extends ae{code="TYPE_GENERATION_ERROR";constructor(t,r,n){super(`Failed to generate types from "${t}" to "${r}": ${n.message}`,{configDir:t,outputPath:r,originalError:n.name,originalMessage:n.message});this.cause=n}},Ot=class extends ae{code="SCHEMA_VALIDATION_ERROR";constructor(t,r,n){super(`Schema validation failed${n?` for config "${n}"`:""}`,{schemaPath:t,configName:n,validationErrors:r,errorCount:r.length})}},Yn=class extends ae{code="BROWSER_CONFIG_ERROR";constructor(t,r,n,i){super(`Failed to fetch configuration from "${t}": ${r} ${n}`,{endpoint:t,status:r,statusText:n,configName:i})}},Jn=class extends ae{code="PLUGIN_ERROR";constructor(t,r,n){super(`Plugin "${t}" failed during ${r}: ${n.message}`,{pluginName:t,operation:r,originalError:n.name,originalMessage:n.message});this.cause=n}},Fe={configNotFound(e,t,r){return new $r(e,t,r)},configLoad(e,t,r){return new Nt(e,t,r)},configValidation(e,t,r){return new Kn(e,t,r)},configMerge(e,t,r,n){return new Hn(e,t,r,n)},envVar(e,t,r,n){return new Rr(e,t,r,n)},fileSystem(e,t,r){return new Gn(e,t,r)},typeGeneration(e,t,r){return new qn(e,t,r)},schemaValidation(e,t,r){return new Ot(e,t,r)},browserConfig(e,t,r,n){return new Yn(e,t,r,n)},plugin(e,t,r){return new Jn(e,t,r)}},Is={replace:"replace",concat:"concat",smart:"smart"},Ps=/^https?:\/\//,ge=new Cr("bunfig",{showTags:!0}),Ne=new oi,_s=ne(Ge.cwd(),"config"),Ls=ne(Ge.cwd(),"src/generated")});mh=br.env.CLARITY_LOG_DIR||Zf(gh(),"logs"),Ms={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:mh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},kr={...Ms},O1=(async()=>{try{let{loadConfig:e}=await hh().then(()=>xs),t=await e({name:"clarity",alias:"logging",defaultConfig:Ms,cwd:br.cwd()});if(t)Object.assign(kr,t)}catch{}return kr})();Y={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},E=Y,I1=Y.red,yh=Y.green,P1=Y.yellow,bh=Y.blue,_1=Y.magenta,L1=Y.cyan,us=Y.white,M1=Y.gray,xh=Y.bgRed,vh=Y.bgYellow,F1=Y.bgGray,fs=Y.bold,D1=Y.dim,j1=Y.italic,B1=Y.underline,V1=Y.strikethrough,U1=Y.reset,Dn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},wh={debug:"\uD83D\uDD0D",info:bh("\u2139"),success:yh("\u2713"),warning:vh(us(fs(" WARN "))),error:xh(us(fs(" ERROR ")))};W1=new Or("stacks");me=class me extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};Ds=class Ds extends me{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r===void 0?[]:Array.isArray(r)?r.filter(Boolean):[r],i="";if(n.length===1)i=` or alias "${n[0]}"`;else if(n.length>1)i=` or aliases ${n.map((o)=>`"${o}"`).join(", ")}`;super(`Configuration "${e}"${i} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}};Sr=class Sr extends me{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}};js=class js extends me{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Bs=class Bs extends me{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}};si=class si extends me{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}};Vs=class Vs extends me{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Us=class Us extends me{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Ar=class Ar extends me{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Ws=class Ws extends me{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}};zs=class zs extends me{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}};He={configNotFound(e,t,r){return new Ds(e,t,r)},configLoad(e,t,r){return new Sr(e,t,r)},configValidation(e,t,r){return new js(e,t,r)},configMerge(e,t,r,n){return new Bs(e,t,r,n)},envVar(e,t,r,n){return new si(e,t,r,n)},fileSystem(e,t,r){return new Vs(e,t,r)},typeGeneration(e,t,r){return new Us(e,t,r)},schemaValidation(e,t,r){return new Ar(e,t,r)},browserConfig(e,t,r,n){return new Ws(e,t,r,n)},plugin(e,t,r){return new zs(e,t,r)}};Th=/^https?:\/\//;he=new Or("bunfig",{showTags:!0});jn=new Js;q1=ve(Er.cwd(),"config"),Y1=ve(Er.cwd(),"src/generated")});import{existsSync as Be,statSync as ox,watch as mc}from"fs";import{unlink as sx}from"fs/promises";import{dirname as ax,resolve as Ii}from"path";import ye from"process";var{Glob:lx}=globalThis.Bun;import{EventEmitter as bc}from"events";import Ie from"process";import _i from"process";import Zr from"process";import Mt from"process";import vt from"process";import Di from"tty";import su,{stdin as Rx,stdout as kx}from"process";import{existsSync as fu}from"fs";import Yr from"fs/promises";import ji from"os";import Jr from"path";import Ve from"process";function Xr(e){return e.replace(/[<[].+/,"").trim()}function xc(e){let t=/<([^>]+)>/g,r=/\[([^\]]+)\]/g,n=[],i=(c)=>{let a=!1,l=c[1];if(l.startsWith("..."))l=l.slice(3),a=!0;else if(l.endsWith("..."))l=l.slice(0,-3),a=!0;return{required:c[0].startsWith("<"),value:l.trim(),variadic:a}},o;while(o=t.exec(e))n.push(i(o));let s;while(s=r.exec(e))n.push(i(s));return n}function vc(e){let t={alias:{},boolean:[]};for(let[r,n]of e.entries()){if(n.names.length>1)t.alias[n.names[0]]=n.names.slice(1);if(n.isBoolean)if(n.negated){if(!e.some((o,s)=>s!==r&&o.names.some((c)=>n.names.includes(c))&&typeof o.required==="boolean"))t.boolean.push(n.names[0])}else t.boolean.push(n.names[0])}return t}function Li(e){return e.reduce((t,r)=>t.length>=r.length?t:r,"")}function qr(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Lt(e){return e.replace(/([a-z])-([a-z])/g,(t,r,n)=>r+n.toUpperCase())}function wc(e,t,r){let n=0,i=t.length,o=e,s;for(;n<i;++n)s=o[t[n]],o=o[t[n]]=n===i-1?r:s!=null?s:!!~t[n+1].indexOf(".")||!(+t[n+1]>-1)?{}:[]}function Cc(e,t){for(let r of Object.keys(t)){let n=t[r];if(e[r]===void 0)continue;if(n.shouldTransform){if(e[r]=Array.prototype.concat.call([],e[r]),typeof n.transformFunction==="function")e[r]=e[r].map(n.transformFunction)}}}function $c(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function wt(e){return e.split(".").map((t,r)=>r===0?Lt(t):t).join(".")}class Ct extends Error{exitCode=2;isUsageError=!0;usage;constructor(e,t){super(e);if(this.name=this.constructor.name,t!==void 0)this.usage=t;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(e).stack}format(e=!1){if(e&&this.stack)return`${this.message}
62
+ `;return r}}function $h(e,t,r={}){return Ks(e,t,r,new WeakMap)}function Ks(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:o=!1,customMerger:s}=r;if(t===null||t===void 0)return o?e:t;if(s){let c=s(e,t);if(c!==void 0)return c}if(Array.isArray(t)||Array.isArray(e))return Hs(e,t,i,n);if(!ue(t)||!ue(e))return t;return Ah(e,t,r,n)}function Hs(e,t,r,n){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(r){case"replace":return t;case"concat":return Rh(e,t);case"smart":return kh(e,t,n);default:return t}return t}function Rh(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>Xn(i,n)))r.push(n);return r}function kh(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(ue(t[0])&&ue(e[0]))return Sh(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Sh(e,t,r){let n=[...t];for(let i of e){if(!ue(i)){n.push(i);continue}let o=["id","name","key","path","type"],s=!1;for(let c of o)if(c in i){if(n.find((l)=>ue(l)&&(c in l)&&l[c]===i[c])){s=!0;break}}if(!s)n.push(i)}return n}function Ah(e,t,r,n){let i=t;if(ue(i)&&n.has(i))return n.get(i);let o={...e};if(ue(i))n.set(i,o);for(let s in i){if(!Object.prototype.hasOwnProperty.call(i,s))continue;let c=i[s],a=o[s];if(r.skipNullish&&(c===null||c===void 0))continue;if(c===null||c===void 0){o[s]=c;continue}if(ue(c)&&ue(a))o[s]=Ks(a,c,r,n);else if(Array.isArray(c)||Array.isArray(a))o[s]=Hs(a,c,r.arrayMergeMode||"smart",n);else o[s]=c}return o}function Gs(e,t,r="replace"){return $h(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function Xn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Xn(e[r],t[r]))return!1;return!0}if(ue(e)&&ue(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Xn(e[i],t[i]))return!1}return!0}return!1}function ue(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class qs{extensions=ms;async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:o,trackPerformance:s=!0,verbose:c=!1}=r;if(i){let l=gr.getWithFileCheck("file",e);if(l){if(c)console.log(`Configuration loaded from cache: ${e}`);return l}}let a=async()=>{if(!lr(e))return null;try{let l=`?t=${Date.now()}`,u=await import(e+l),f=u.default||u,d="default"in u,h=Object.keys(u).length>0;if(!d&&!h)throw new Sr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof f!=="object"||f===null||Array.isArray(f))throw new Sr(e,Error("Configuration must export a valid object"),"unknown");let p={config:Gs(t,f,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)gr.setWithFileCheck("file",p,e,o);return p}catch(l){throw l instanceof Error?He.configLoad(e,l):He.configLoad(e,Error(String(l)))}};if(s)return Zn.track("loadFromPath",a,{path:e});return a()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){return wf({name:e,directory:t,alias:r})}generateNamePatterns(e,t){return ps({name:e,alias:t})}checkFileAccess(e){return Ch(async()=>lr(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!lr(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let o of i)for(let s of this.extensions){let c=ds(e,`${o}${s}`);if(await this.checkFileAccess(c))n.push(c)}}else try{let{readdirSync:i}=await import("fs"),o=i(e);for(let s of o)if(this.looksLikeConfigFile(s)){let c=ds(e,s);if(await this.checkFileAccess(c))n.push(c)}}catch{return[]}return n}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((r)=>r.test(e))}async validateConfigFile(e){let t=[];try{if(!lr(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),o=i(e,"utf8");JSON.parse(o)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class Ys{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:c=!0,verbose:a=!1}=r,l=async()=>{let u=[],f=[],d={stopOnFirstError:n,validateRequired:i,validateTypes:o,customRules:s,trackPerformance:c,verbose:a};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,d);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],d);else return this.validateWithJSONSchema(e,t,d)}catch(h){return u.push({path:"",message:`Validation failed: ${h}`,rule:"system"}),{isValid:!1,errors:u,warnings:f}}};if(c)return await Zn.track("validateConfiguration",l);return l()}async validateWithSchemaFile(e,t,r){try{if(!Eh(t))throw new Ar(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new Ar(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,c=Array.isArray(t.type)?t.type:[t.type];if(!c.includes(s)){if(n.push({path:r,message:`Expected type ${c.join(" or ")}, got ${s}`,expected:c.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),o.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)n.push({path:r,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))n.push({path:r,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)n.push({path:r,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)n.push({path:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let s=0;s<e.length;s++){let c=r?`${r}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,c,n,i,o),o.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let c of t.required)if(!(c in s)){if(n.push({path:r?`${r}.${c}`:c,message:`Missing required property '${c}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[c,a]of Object.entries(t.properties))if(c in s){let l=r?`${r}.${c}`:c;if(this.validateObjectAgainstSchema(s[c],a,l,n,i,o),o.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let c=new Set(Object.keys(t.properties||{}));for(let a of Object.keys(s))if(!c.has(a))i.push({path:r?`${r}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),c=this.validateWithRule(s,o,o.path);if(n.push(...c),r.stopOnFirstError&&n.length>0)break}catch(s){n.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))n.push({path:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,o,s]=n;t.push({path:i,required:!o,type:this.mapTypeScriptType(s)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:Th},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function Nh(e){if(!e)return"";let t=Array.isArray(e)?e.filter(Boolean):[e];if(t.length===0)return"";if(t.length===1)return` or alias "${t[0]}"`;return` or aliases ${t.map((r)=>`"${r}"`).join(", ")}`}class Js{fileLoader=new qs;envProcessor=new ai;validator=new Ys;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:o,...s}=e;try{if(r?.enabled){let a=this.checkCache(s.name||"",s);if(a)return a}let c;try{c=await this.loadConfigurationStrategies(s,!0,r)}catch(a){if(s.configFile)throw a;let l=s.__strictErrorHandling;if(a instanceof Error&&a.name==="ConfigNotFoundError"){if(l)throw a;c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`No configuration file found for "${s.name||"config"}", using defaults with environment variables`]}}else if(a instanceof Error&&a.name==="ConfigLoadError"){let u=a.message.includes("EACCES")||a.message.includes("EPERM")||a.message.includes("permission denied"),f=!u&&(a.message.includes("syntax")||a.message.includes("Expected")||a.message.includes("Unexpected")||a.message.includes("BuildMessage")||a.message.includes("errors building")),d=a.message.includes("Configuration must export a valid object")||a.message.includes("Configuration file is empty and exports nothing");if(l&&(d||u))throw a;if(f&&(!l||!d))c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!l)c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${a.message}`]};else throw a}else c={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${a instanceof Error?a.message:String(a)}`]}}if(i||o)await this.validateConfiguration(c.config,i,o,s.name);if(r?.enabled&&c)this.cacheResult(s.name||"",c,r,s);if(n?.enabled){let a={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(a);if(n.slowThreshold&&a.duration>n.slowThreshold)he.warn(`Slow configuration loading detected: ${a.duration}ms for ${s.name}`);c.metrics=a}return c}catch(c){if(c instanceof Error&&c.name==="ConfigNotFoundError")throw c;let a=Date.now()-t;throw he.error(`Configuration loading failed after ${a}ms:`,[c instanceof Error?c:Error(String(c))]),c}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,configFile:o,cwd:s,configDir:c,defaultConfig:a,checkEnv:l=!0,arrayStrategy:u="replace",verbose:f=!1}=e,d=s||Er.cwd(),h=[];if(o){let b=ve(d,o);h.push(b);let w=l?St(n,a,f):a,T=await this.fileLoader.tryLoadFromPaths([b],w,{arrayStrategy:u,verbose:f,cacheTtl:r?.ttl,useCache:!r?.ttl||r.ttl>100});if(!T)throw He.configNotFound(n||o,h,i);if(f)he.success(`Configuration loaded from explicit path: ${b}`);return this.finalizeResult(T,h,l,n,f)}let m=await this.loadLocalConfiguration(n,i,d,c,a,u,f,l,r);if(m)return h.push(...this.getLocalSearchPaths(n,i,d,c)),this.finalizeResult(m,h,l,n,f);let g=await this.loadHomeConfiguration(n,i,a,u,f,l);if(g)return h.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(g,h,l,n,f);let p=await this.loadPackageJsonConfiguration(n,i,d,a,u,f,l);if(p)return h.push(ve(d,"package.json")),this.finalizeResult(p,h,l,n,f);if(h.push(...this.getAllSearchPaths(n,i,d,c)),t)throw He.configNotFound(n,h,i);return{...await this.applyEnvironmentVariables(n,a,l,f),warnings:[`No configuration file found for "${n}"${Nh(i)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,o,s,c,a){let l=c?St(e,i,s):i,u=this.getLocalDirectories(r,n);for(let f of u){if(s)he.info(`Searching for configuration in: ${f}`);let d=this.fileLoader.generateConfigPaths(e,f,t),h=await this.fileLoader.tryLoadFromPaths(d,l,{arrayStrategy:o,verbose:s,cacheTtl:a?.ttl,useCache:!a?.ttl||a.ttl>100});if(h){if(s)he.success(`Configuration loaded from: ${h.source.path}`);return h}}return null}async loadHomeConfiguration(e,t,r,n,i,o){if(!e)return null;let s=o?St(e,r,i):r,c=[ve(et(),".config",e),ve(et(),".config"),et()];for(let a of c){if(i)he.info(`Checking home directory: ${a}`);let l=this.fileLoader.generateConfigPaths(e,a,t),u=await this.fileLoader.tryLoadFromPaths(l,s,{arrayStrategy:n,verbose:i});if(u){if(i)he.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,o,s){let c=s?St(e,n,o):n;try{let a=ve(r,"package.json");if(!$f(a))return null;let l={};try{l=JSON.parse(Rf(a,"utf8"))}catch(d){if(o)he.warn("Failed to parse package.json:",[d instanceof Error?d:Error(String(d))]);return null}let u=l[e],f=e;if(!u&&t){let d=Array.isArray(t)?t:[t];for(let h of d){if(!h)continue;if(l[h]){u=l[h],f=h;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)he.success(`Configuration loaded from package.json: ${f}`);return{config:Gs(c,u,i),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(o)he.warn("Failed to load package.json:",[a instanceof Error?a:Error(String(a))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:St(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let o=r(e);if(o)i.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)i.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(i.length>0)throw He.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return gr.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);gr.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;r.push(`alias:${n}`)}if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configFile)r.push(`configFile:${t.configFile}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Cf({cwd:e,configDir:t})}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(ve(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),o=[];for(let s of i)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let r=[ve(et(),".config",e),ve(et(),".config"),et()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}async function Xs(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},r="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let n;if(r)n=await jn.loadConfig(e);else n=await jn.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return n?.config??t}catch(n){if(e.configFile)throw n;let i=n instanceof Error?n.name:"UnknownError",o=n instanceof Error?n.message:String(n);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||o.includes("config"))&&e.verbose)he.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);let c=r?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await jn.applyEnvironmentVariables(c.name||"",t,!0,c.verbose||!1))?.config??t;return t}}function St(e,t,r=!1){let n=new ai,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,c=[]){let a={...s};for(let[l,u]of Object.entries(s)){let f=[...c,l],d=[`${i}_${f.join("_").toUpperCase()}`,`${i}_${f.map((g)=>g.toUpperCase()).join("")}`,`${i}_${f.map((g)=>g.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],h,m;for(let g of d)if(h=Er.env[g],h!==void 0){m=g;break}if(h!==void 0&&m)if(typeof u==="boolean")a[l]=["true","1","yes"].includes(h.toLowerCase());else if(typeof u==="number"){let g=Number(h);if(!Number.isNaN(g))a[l]=g}else if(Array.isArray(u))try{a[l]=JSON.parse(h)}catch{a[l]=h.split(",").map((g)=>g.trim())}else a[l]=h;else if(u&&typeof u==="object"&&!Array.isArray(u))a[l]=o(u,f)}return a}return o(t)}var gr,Zn,ms,cd,ud=(e)=>e,dd=(e,t)=>{for(var r in t)cd(e,r,{get:t[r],enumerable:!0,configurable:!0,set:fd.bind(t,r)})},hd=(e,t)=>()=>(e&&(t=e(e=0)),t),xs,Es,ft,It,Ts,Bd,Vd,es,ur,Wn,X,P,Ud,ts,Wd,rs,zd,Kd,_n,Hd,ns,is,Ln,Gd,qd,Yd,Jd,fr,Ns,Xd,Z,Zd,Qd,os,dr,zn,H,A,eh,ss,th,as,rh,nh,Mn,ih,ls,cs,oh,Fn,sh,ah,lh,ch,uh,hr,Os,fh,dh="0.15.6",ae,$r,Nt,Kn,Hn,Rr,Gn,qn,Ot,Yn,Jn,Fe,Is,Ps,ge,Ne,_s,Ls,hh,mh,Ms,kr,O1,Y,E,I1,yh,P1,bh,_1,L1,us,M1,xh,vh,F1,fs,D1,j1,B1,V1,U1,Dn,wh,W1,me,Ds,Sr,js,Bs,si,Vs,Us,Ar,Ws,zs,He,Th,he,jn,q1,Y1;var Zs=yc(()=>{gr=new hs,Zn=new gs,ms=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];cd=Object.defineProperty;xs={};dd(xs,{withErrorRecovery:()=>Cs,tryLoadConfig:()=>Md,loadConfigWithResult:()=>_d,loadConfig:()=>As,isRetryableError:()=>Ed,isConfigNotFoundError:()=>Ad,isBunfigError:()=>$s,globalPerformanceMonitor:()=>It,globalCache:()=>ft,getEnvOrDefault:()=>Td,generateConfigTypes:()=>Fd,defaultGeneratedDir:()=>Ls,defaultConfigDir:()=>_s,deepMergeWithArrayStrategy:()=>ni,deepMerge:()=>Rs,createLibraryConfig:()=>Dd,config:()=>Ld,bunfigPlugin:()=>jd,applyEnvVarsToConfig:()=>Et,TypeGenerationError:()=>qn,SchemaValidationError:()=>Ot,PluginError:()=>Jn,PerformanceMonitor:()=>ei,FileSystemError:()=>Gn,ErrorFactory:()=>Fe,EnvVarError:()=>Rr,EnvProcessor:()=>Tr,ConfigValidator:()=>ii,ConfigValidationError:()=>Kn,ConfigNotFoundError:()=>$r,ConfigMergeError:()=>Hn,ConfigLoader:()=>oi,ConfigLoadError:()=>Nt,ConfigFileLoader:()=>Nr,ConfigCache:()=>Qn,CacheUtils:()=>Ts,BunfigError:()=>ae,BrowserConfigError:()=>Yn,ArrayMergeStrategies:()=>Is});hh=hd(async()=>{Es=import.meta.require,ft=new Qn,It=new ei,Ts={createKey:gd,isEquivalent:md,estimateMemoryUsage:pd},Bd=yr(Vn.cwd(),"config"),Vd=yr(Vn.cwd(),"src/generated"),es=pr.env.CLARITY_LOG_DIR||Nf(xd(),"logs"),ur={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:es,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},Wn=await vd(),X={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,reset:"\x1B[0m"},P=X,Ud=X.red,ts=X.green,Wd=X.yellow,rs=X.blue,zd=X.magenta,Kd=X.cyan,_n=X.white,Hd=X.gray,ns=X.bgRed,is=X.bgYellow,Ln=X.bold,Gd=X.dim,qd=X.italic,Yd=X.underline,Jd=X.reset,fr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ns={debug:"\uD83D\uDD0D",info:rs("\u2139"),success:ts("\u2713"),warning:is(_n(Ln(" WARN "))),error:ns(_n(Ln(" ERROR ")))},Xd=new vr("stacks"),Z=new vr("bunfig",{showTags:!0}),Zd=re(Tt.cwd(),"config"),Qd=re(Tt.cwd(),"src/generated"),os=mr.env.CLARITY_LOG_DIR||Ef(Rd(),"logs"),dr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:os,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},zn=await kd(),H={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},A=H,eh=H.red,ss=H.green,th=H.yellow,as=H.blue,rh=H.magenta,nh=H.cyan,Mn=H.white,ih=H.gray,ls=H.bgRed,cs=H.bgYellow,oh=H.bgGray,Fn=H.bold,sh=H.dim,ah=H.italic,lh=H.underline,ch=H.strikethrough,uh=H.reset,hr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Os={debug:"\uD83D\uDD0D",info:as("\u2139"),success:ss("\u2713"),warning:cs(Mn(Fn(" WARN "))),error:ls(Mn(Fn(" ERROR ")))},fh=new Cr("stacks"),ae=class extends Error{timestamp;context;constructor(t,r={}){super(t);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=r,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let t=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([r,n])=>`${r}: ${n}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${t}`}},$r=class extends ae{code="CONFIG_NOT_FOUND";constructor(t,r,n){let i=n?` or alias "${n}"`:"";super(`Configuration "${t}"${i} not found`,{configName:t,alias:n,searchPaths:r,searchPathCount:r.length})}},Nt=class extends ae{code="CONFIG_LOAD_ERROR";constructor(t,r,n){super(`Failed to load configuration from "${t}": ${r.message}`,{configPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}},Kn=class extends ae{code="CONFIG_VALIDATION_ERROR";constructor(t,r,n){super(`Configuration validation failed for "${t}"`,{configPath:t,configName:n,validationErrors:r,errorCount:r.length})}},Hn=class extends ae{code="CONFIG_MERGE_ERROR";constructor(t,r,n,i){super(`Failed to merge configuration from "${t}" with "${r}": ${n.message}`,{sourcePath:t,targetPath:r,configName:i,originalError:n.name,originalMessage:n.message});this.cause=n}},Rr=class extends ae{code="ENV_VAR_ERROR";constructor(t,r,n,i){super(`Failed to parse environment variable "${t}" with value "${r}" as ${n}`,{envKey:t,envValue:r,expectedType:n,configName:i})}},Gn=class extends ae{code="FILE_SYSTEM_ERROR";constructor(t,r,n){super(`File system ${t} failed for "${r}": ${n.message}`,{operation:t,path:r,originalError:n.name,originalMessage:n.message});this.cause=n}},qn=class extends ae{code="TYPE_GENERATION_ERROR";constructor(t,r,n){super(`Failed to generate types from "${t}" to "${r}": ${n.message}`,{configDir:t,outputPath:r,originalError:n.name,originalMessage:n.message});this.cause=n}},Ot=class extends ae{code="SCHEMA_VALIDATION_ERROR";constructor(t,r,n){super(`Schema validation failed${n?` for config "${n}"`:""}`,{schemaPath:t,configName:n,validationErrors:r,errorCount:r.length})}},Yn=class extends ae{code="BROWSER_CONFIG_ERROR";constructor(t,r,n,i){super(`Failed to fetch configuration from "${t}": ${r} ${n}`,{endpoint:t,status:r,statusText:n,configName:i})}},Jn=class extends ae{code="PLUGIN_ERROR";constructor(t,r,n){super(`Plugin "${t}" failed during ${r}: ${n.message}`,{pluginName:t,operation:r,originalError:n.name,originalMessage:n.message});this.cause=n}},Fe={configNotFound(e,t,r){return new $r(e,t,r)},configLoad(e,t,r){return new Nt(e,t,r)},configValidation(e,t,r){return new Kn(e,t,r)},configMerge(e,t,r,n){return new Hn(e,t,r,n)},envVar(e,t,r,n){return new Rr(e,t,r,n)},fileSystem(e,t,r){return new Gn(e,t,r)},typeGeneration(e,t,r){return new qn(e,t,r)},schemaValidation(e,t,r){return new Ot(e,t,r)},browserConfig(e,t,r,n){return new Yn(e,t,r,n)},plugin(e,t,r){return new Jn(e,t,r)}},Is={replace:"replace",concat:"concat",smart:"smart"},Ps=/^https?:\/\//,ge=new Cr("bunfig",{showTags:!0}),Ne=new oi,_s=ne(Ge.cwd(),"config"),Ls=ne(Ge.cwd(),"src/generated")});mh=br.env.CLARITY_LOG_DIR||Zf(gh(),"logs"),Ms={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:mh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},kr={...Ms},O1=(async()=>{try{let{loadConfig:e}=await hh().then(()=>xs),t=await e({name:"clarity",alias:"logging",defaultConfig:Ms,cwd:br.cwd()});if(t)Object.assign(kr,t)}catch{}return kr})();Y={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},E=Y,I1=Y.red,yh=Y.green,P1=Y.yellow,bh=Y.blue,_1=Y.magenta,L1=Y.cyan,us=Y.white,M1=Y.gray,xh=Y.bgRed,vh=Y.bgYellow,F1=Y.bgGray,fs=Y.bold,D1=Y.dim,j1=Y.italic,B1=Y.underline,V1=Y.strikethrough,U1=Y.reset,Dn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},wh={debug:"\uD83D\uDD0D",info:bh("\u2139"),success:yh("\u2713"),warning:vh(us(fs(" WARN "))),error:xh(us(fs(" ERROR ")))};W1=new Or("stacks");me=class me extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};Ds=class Ds extends me{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r===void 0?[]:Array.isArray(r)?r.filter(Boolean):[r],i="";if(n.length===1)i=` or alias "${n[0]}"`;else if(n.length>1)i=` or aliases ${n.map((o)=>`"${o}"`).join(", ")}`;super(`Configuration "${e}"${i} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}};Sr=class Sr extends me{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}};js=class js extends me{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Bs=class Bs extends me{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}};si=class si extends me{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}};Vs=class Vs extends me{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Us=class Us extends me{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Ar=class Ar extends me{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Ws=class Ws extends me{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}};zs=class zs extends me{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}};He={configNotFound(e,t,r){return new Ds(e,t,r)},configLoad(e,t,r){return new Sr(e,t,r)},configValidation(e,t,r){return new js(e,t,r)},configMerge(e,t,r,n){return new Bs(e,t,r,n)},envVar(e,t,r,n){return new si(e,t,r,n)},fileSystem(e,t,r){return new Vs(e,t,r)},typeGeneration(e,t,r){return new Us(e,t,r)},schemaValidation(e,t,r){return new Ar(e,t,r)},browserConfig(e,t,r,n){return new Ws(e,t,r,n)},plugin(e,t,r){return new zs(e,t,r)}};Th=/^https?:\/\//;he=new Or("bunfig",{showTags:!0});jn=new Js;q1=ve(Er.cwd(),"config"),Y1=ve(Er.cwd(),"src/generated")});import{existsSync as Be,statSync as ox,watch as mc}from"fs";import{unlink as sx}from"fs/promises";import{dirname as ax,resolve as Ii}from"path";import ye from"process";var{Glob:lx}=globalThis.Bun;import{EventEmitter as bc}from"events";import Ie from"process";import _i from"process";import Zr from"process";import Mt from"process";import vt from"process";import Di from"tty";import su,{stdin as Rx,stdout as kx}from"process";import{existsSync as fu}from"fs";import Yr from"fs/promises";import ji from"os";import Jr from"path";import Ve from"process";function Xr(e){return e.replace(/[<[].+/,"").trim()}function xc(e){let t=/<([^>]+)>/g,r=/\[([^\]]+)\]/g,n=[],i=(c)=>{let a=!1,l=c[1];if(l.startsWith("..."))l=l.slice(3),a=!0;else if(l.endsWith("..."))l=l.slice(0,-3),a=!0;return{required:c[0].startsWith("<"),value:l.trim(),variadic:a}},o;while(o=t.exec(e))n.push(i(o));let s;while(s=r.exec(e))n.push(i(s));return n}function vc(e){let t={alias:{},boolean:[]};for(let[r,n]of e.entries()){if(n.names.length>1)t.alias[n.names[0]]=n.names.slice(1);if(n.isBoolean)if(n.negated){if(!e.some((o,s)=>s!==r&&o.names.some((c)=>n.names.includes(c))&&typeof o.required==="boolean"))t.boolean.push(n.names[0])}else t.boolean.push(n.names[0])}return t}function Li(e){return e.reduce((t,r)=>t.length>=r.length?t:r,"")}function qr(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Lt(e){return e.replace(/([a-z])-([a-z])/g,(t,r,n)=>r+n.toUpperCase())}function wc(e,t,r){let n=0,i=t.length,o=e,s;for(;n<i;++n)s=o[t[n]],o=o[t[n]]=n===i-1?r:s!=null?s:!!~t[n+1].indexOf(".")||!(+t[n+1]>-1)?{}:[]}function Cc(e,t){for(let r of Object.keys(t)){let n=t[r];if(e[r]===void 0)continue;if(n.shouldTransform){if(e[r]=Array.prototype.concat.call([],e[r]),typeof n.transformFunction==="function")e[r]=e[r].map(n.transformFunction)}}}function $c(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function wt(e){return e.split(".").map((t,r)=>r===0?Lt(t):t).join(".")}class Ct extends Error{exitCode=2;isUsageError=!0;usage;constructor(e,t){super(e);if(this.name=this.constructor.name,t!==void 0)this.usage=t;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(e).stack}format(e=!1){if(e&&this.stack)return`${this.message}
63
63
 
64
64
  Stack trace:
65
65
  ${this.stack}`;return this.message}}function Rc(e){if(e instanceof Ct)return!0;return!!e&&typeof e==="object"&&e.name==="ClappError"&&typeof e.message==="string"}function kc(){let{env:e}=_i,{TERM:t,TERM_PROGRAM:r}=e;if(_i.platform!=="win32")return t!=="linux";return Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||e.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Ft="\x1B",B=`${Ft}[`;var Mi={to(e,t){if(!t)return`${B}${e+1}G`;return`${B}${t+1};${e+1}H`},move(e,t){let r="";if(e<0)r+=`${B}${-e}D`;else if(e>0)r+=`${B}${e}C`;if(t<0)r+=`${B}${-t}A`;else if(t>0)r+=`${B}${t}B`;return r},up:(e=1)=>`${B}${e}A`,down:(e=1)=>`${B}${e}B`,forward:(e=1)=>`${B}${e}C`,backward:(e=1)=>`${B}${e}D`,nextLine:(e=1)=>`${B}E`.repeat(e),prevLine:(e=1)=>`${B}F`.repeat(e),left:`${B}G`,hide:`${B}?25l`,show:`${B}?25h`,save:`${Ft}7`,restore:`${Ft}8`};var mx={screen:`${B}2J`,up:(e=1)=>`${B}1J`.repeat(e),down:(e=1)=>`${B}J`.repeat(e),line:`${B}2K`,lineEnd:`${B}K`,lineStart:`${B}1K`,lines(e){let t="";for(let r=0;r<e;r++)t+=this.line+(r<e-1?Mi.up():"");if(e)t+=Mi.left;return t}},px={screen:`${Ft}c`};function Sc(e,t){let r=[];for(let n=0;n<=t.length;n++)r[n]=[n];for(let n=0;n<=e.length;n++)r[0][n]=n;for(let n=1;n<=t.length;n++)for(let i=1;i<=e.length;i++)if(t.charAt(n-1)===e.charAt(i-1))r[n][i]=r[n-1][i-1];else r[n][i]=Math.min(r[n-1][i-1]+1,r[n][i-1]+1,r[n-1][i]+1);return r[t.length][e.length]}function Bi(e,t,r=2,n=3){return t.map((i)=>({cmd:i,distance:Sc(e,i)})).filter(({distance:i})=>i<=r).sort((i,o)=>i.distance-o.distance).slice(0,n).map(({cmd:i})=>i)}function Ac(e,t={}){let r={_:[]},n=t.alias||{},i=new Set(t.boolean||[]),o={};for(let a of Object.keys(n))for(let l of n[a])o[l]=a;for(let a of i)if(n[a])for(let l of n[a])i.add(l);function s(a,l){if(a===void 0)return l;if(typeof l==="boolean")return l;return Array.isArray(a)?[...a,l]:[a,l]}function c(a,l){let u=o[a]||a,f=s(r[u],l);if(r[u]=f,n[u])for(let d of n[u])r[d]=f;if(o[a]&&n[o[a]])for(let d of n[o[a]])r[d]=f;r[a]=f}for(let a=0;a<e.length;a++){let l=e[a];if(l==="--"){r._.push(...e.slice(a+1));break}if(l.startsWith("--")){let u=l.indexOf("=");if(u!==-1){let f=Lt(l.slice(2,u)),d=l.slice(u+1);c(f,d)}else{let f=l.slice(2);if(f.startsWith("no-")){let m=Lt(f.slice(3));c(m,!1);continue}let d=Lt(f),h=o[d]||d;if(i.has(h)||i.has(d))c(d,!0);else{let m=e[a+1];if(m!==void 0&&!m.startsWith("-"))c(d,m),a++;else c(d,!0)}}}else if(l.startsWith("-")&&l.length>1){let u=l.slice(1);for(let f=0;f<u.length;f++){let d=u[f],h=o[d]||d;if(f===u.length-1&&!i.has(h)&&!i.has(d)){let m=e[a+1];if(m!==void 0&&!m.startsWith("-"))c(d,m),a++;else c(d,!0)}else c(d,!0)}}else r._.push(l)}return r}class Vi{rawName;description;name;names;isBoolean;required;config;negated;variadic;constructor(e,t,r){if(this.rawName=e,this.description=t,this.config=Object.assign({},r),e=e.replace(/\.\*/g,""),this.negated=!1,this.variadic=/[<[](?:\.\.\.[^\]>]+|[^\]>]+\.\.\.)[\]>]/.test(e),this.names=Xr(e).split(",").map((n)=>{let i=n.trim().replace(/^-{1,2}/,"");if(i.startsWith("no-"))this.negated=!0,i=i.replace(/^no-/,"");return wt(i)}).sort((n,i)=>n.length>i.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(e.includes("<"))this.required=!0;else if(e.includes("["))this.required=!1;else this.isBoolean=!0}}var bx=Zr.argv,Ec=`${Zr.platform}-${Zr.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,Fi=Mt.argv,Tc=`${Mt.platform}-${Mt.arch} node-${Mt.version}`;class Qr{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(e,t,r,n){this.rawName=e,this.description=t,this.config=r,this.cli=n,this.options=[],this.aliasNames=[],this.name=Xr(e);let i=Xr(e),o=i.indexOf(":");if(o>0)this.namespace=i.substring(0,o),this.name=i.substring(o+1);if(this.args=xc(e),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!r)this.config={}}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,r){let n=new Vi(e,t,r);return this.options.push(n),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}before(e){return this.beforeHooks.push(e),this}after(e){return this.afterHooks.push(e),this}use(e){return this.middleware.push(e),this}isMatched(e){if(this.aliasNames.includes(e))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===e;return this.name===e}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof en}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(e){let t=wt(e.split(".")[0]);return!!this.options.find((r)=>r.names.some((n)=>wt(n)===t))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:r,options:n,helpCallback:i}=this.cli.globalCommand,o=[{body:`${e}${r?`/${r}`:""}`}];if(o.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let l=Li(t.map((m)=>m.rawName)),u=new Map,f=[];for(let m of t)if(m.namespace){if(!u.has(m.namespace))u.set(m.namespace,[]);u.get(m.namespace).push(m)}else f.push(m);let d="";if(f.sort((m,g)=>m.rawName<g.rawName?-1:m.rawName>g.rawName?1:0),f.length>0)d+=f.map((m)=>` ${qr(m.rawName,l.length)} ${m.description}`).join(`
@@ -88,10 +88,10 @@ Received ${r}, cleaning up...`),e)try{await e()}catch(n){console.error("Error du
88
88
  `)),this.enableDidYouMean){let t=[];for(let n of this.commands){if(n.displayName)t.push(n.displayName);if(n.aliasNames)t.push(...n.aliasNames)}let r=Bi(e,t);if(r.length>0)console.log(xt.yellow("Did you mean one of these?")),r.forEach((n)=>console.log(` ${xt.dim("\u2022")} ${this.name} ${n}`)),console.log("")}console.log(xt.dim("Run"),`${this.name} --help`,xt.dim("to see all available commands")),Ie.exit(1)}async parse(e=Fi,t={}){let{run:r=!0,exitOnError:n=!1}=t;if(n)try{return await this.parse(e,{run:r})}catch(a){throw this.handleUsageError(a),a}if(this.rawArgs=e,!this.name)this.name=e[1]?$c(e[1]):"cli";let i=!0,o=e.slice(2),s=o[0];if(s&&!s.startsWith("-")){for(let a of this.commands)if(a.isMatched(s)){let l=this.mri(o,a);i=!1;let u={...l,args:l.args.slice(1)};this.setParsedInfo(u,a,s),this.emit(`command:${s}`,a);break}if(i){let a=o[1];if(a&&!a.startsWith("-")){let l=`${s}:${a}`;for(let u of this.commands)if(u.isMatched(l)){let f=this.mri(o,u);i=!1;let d={...f,args:f.args.slice(2)};this.setParsedInfo(d,u,l),this.emit(`command:${l}`,u);break}}}}if(i){for(let a of this.commands)if(a.name===""){i=!1;let l=this.mri(o,a);this.setParsedInfo(l,a),this.emit("command:!",a);break}}if(i){let a=this.mri(e.slice(2));this.setParsedInfo(a)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction||this.options.interaction===!1)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji||this.options.emoji===!1)this.useEmoji=!1;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache||this.options.cache===!1)this.isNoCache=!0;if(this.options.help&&this.showHelpOnExit)this.outputHelp(),r=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),r=!1,this.unsetMatchedCommand();let c={args:this.args,options:this.options};if(r)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return c}mri(e,t){let r=[...this.globalCommand.options,...t?t.options:[]],n=vc(r),i=[],o=e.indexOf("--");if(o>-1)i=e.slice(o+1),e=e.slice(0,o);let s=Ac(e,n),c={_:s._};for(let d of Object.keys(s))if(d!=="_")c[wt(d)]=s[d];let a=c._,l={"--":i},u=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,f=Object.create(null);for(let d of r){if(!u&&d.config.default!==void 0)for(let h of d.names)l[h]=d.config.default;if(Array.isArray(d.config.type)){if(f[d.name]===void 0)f[d.name]={shouldTransform:!0,transformFunction:d.config.type[0]}}}for(let d of Object.keys(c))if(d!=="_"){let h=d.split(".");wc(l,h,c[d]),Cc(l,f)}for(let d of r){if(!d.variadic)continue;for(let h of d.names){let m=l[h];if(m===void 0||Array.isArray(m))continue;if(d.config.default!==void 0&&m===d.config.default)continue;l[h]=[m]}}return{args:a,options:l}}async run(e=Fi){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!Rc(e)||e.isUsageError===!1)return;let t=e.message||"command-line error",r=this.name?`${this.name}: `:"",n=/--help/.test(t)?"":e.usage?`
89
89
  Usage: ${e.usage}`:`
90
90
  Run \`${this.name??"cli"} --help\` for usage.`;Ie.stderr.write(`${r}${t}${n}
91
- `),Ie.exit(e.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:r}=this;if(!r||!r.commandAction)return;r.checkUnknownOptions(),r.checkOptionValue(),r.checkRequiredArgs();let n=[];r.args.forEach((c,a)=>{if(c.variadic)n.push(e.slice(a));else n.push(e[a])}),n.push(t);let i={command:r,args:n,options:t};for(let c of r.beforeHooks)await c(i);let o,s=async()=>{let c=r.commandAction.apply(this,n);if(c instanceof Promise)o=await c;else o=c;return o};if(r.middleware.length>0){let c=0,a=async()=>{if(c<r.middleware.length){let l=r.middleware[c++];await l({...i,next:a})}else await s()};await a()}else await s();for(let c of r.afterHooks)await c(i);return o}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return Ie.removeAllListeners("SIGINT"),Ie.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class Ui{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,r=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:r})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,r]of this.cache.entries())if(e-r.timestamp>r.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var vx=new Ui;function Pc(){if("FORCE_COLOR"in vt.env)return vt.env.FORCE_COLOR!=="0";if("NO_COLOR"in vt.env||vt.env.TERM==="dumb")return!1;if(vt.platform==="win32")return!0;return Di.isatty(1)&&Di.isatty(2)}var Wi=Pc();function M(e,t){if(!Wi)return(r)=>r;return(r)=>e+r+t}var _c=M("\x1B[0m","\x1B[0m"),Lc=M("\x1B[31m","\x1B[39m"),Mc=M("\x1B[32m","\x1B[39m"),Fc=M("\x1B[33m","\x1B[39m"),Dc=M("\x1B[34m","\x1B[39m"),jc=M("\x1B[35m","\x1B[39m"),Bc=M("\x1B[36m","\x1B[39m"),Vc=M("\x1B[37m","\x1B[39m"),Uc=M("\x1B[90m","\x1B[39m"),Wc=M("\x1B[1m","\x1B[22m"),zc=M("\x1B[3m","\x1B[23m"),Kc=M("\x1B[4m","\x1B[24m"),Hc=M("\x1B[2m","\x1B[22m"),Gc=M("\x1B[7m","\x1B[27m"),qc=M("\x1B[8m","\x1B[28m"),Yc=M("\x1B[9m","\x1B[29m"),Jc=M("\x1B[41m","\x1B[49m"),Xc=M("\x1B[42m","\x1B[49m"),Zc=M("\x1B[43m","\x1B[49m"),Qc=M("\x1B[44m","\x1B[49m"),eu=M("\x1B[45m","\x1B[49m"),tu=M("\x1B[46m","\x1B[49m"),ru=M("\x1B[47m","\x1B[49m"),nu=Wi,iu={reset:_c,red:Lc,green:Mc,yellow:Fc,blue:Dc,magenta:jc,cyan:Bc,white:Vc,gray:Uc,bold:Wc,italic:zc,underline:Kc,dim:Hc,inverse:Gc,hidden:qc,strikethrough:Yc,bgRed:Jc,bgGreen:Xc,bgYellow:Zc,bgBlue:Qc,bgMagenta:eu,bgCyan:tu,bgWhite:ru,isColorSupported:nu},ou=iu,au=["up","down","left","right","space","enter","cancel"],Sx={actions:new Set(au),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var Ax=su.platform.startsWith("win"),Ex=Symbol("clapp:cancel");var lu=kc();var _=(e,t)=>lu?e:t,Tx=_("\u25C6","*"),Nx=_("\u25A0","x"),Ox=_("\u25B2","x"),Ix=_("\u25C7","o"),Px=_("\u250C","T"),cu=_("\u2502","|"),_x=_("\u2514","\u2014"),Lx=_("\u25CF",">"),Mx=_("\u25CB"," "),Fx=_("\u25FB","[\u2022]"),Dx=_("\u25FC","[+]"),jx=_("\u25FB","[ ]"),Bx=_("\u25AA","\u2022"),Vx=_("\u2500","-"),Ux=_("\u256E","+"),Wx=_("\u251C","+"),zx=_("\u256F","+"),Kx=_("\u25CF","\u2022"),Hx=_("\u25C6","*"),Gx=_("\u25B2","!"),qx=_("\u25A0","x");var Yx={light:_("\u2500","-"),heavy:_("\u2501","="),block:_("\u2588","#")};function uu(){return`${ou.gray(cu)} `}var Jx=uu();class zi{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=ji.homedir(),t=Jr.join(e,".config","clapp");this.configPath=Jr.join(t,"telemetry.json")}async isEnabled(){if(Ve.env.DO_NOT_TRACK==="1"||Ve.env.DO_NOT_TRACK==="true")return!1;if(Ve.env.NO_TELEMETRY==="1"||Ve.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let e=await this.loadConfig();if(e.enabled=!0,!e.userId)e.userId=this.generateUserId();await this.saveConfig(e)}async disable(){let e=await this.loadConfig();e.enabled=!1,await this.saveConfig(e)}async track(e,t){if(!await this.isEnabled())return;let n={event:e,...t,timestamp:Date.now(),platform:ji.platform(),nodeVersion:Ve.version};if(this.events.push(n),this.events.length>=10)await this.send()}async trackCommand(e,t){await this.track("command",{command:e,duration:t})}async trackError(e,t){await this.track("error",{error:e,command:t})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let t=await this.loadConfig();return t.lastSent=Date.now(),await this.saveConfig(t),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let t=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(t),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(e){return new Promise((t)=>setTimeout(t,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:Ve.env.DO_NOT_TRACK==="1"||Ve.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(fu(this.configPath)){let e=await Yr.readFile(this.configPath,"utf-8");return this.config=JSON.parse(e),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(e){this.config=e;try{let t=Jr.dirname(this.configPath);await Yr.mkdir(t,{recursive:!0}),await Yr.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),t=Date.now().toString(36);return`${e}-${t}`}}var rv=new zi;var rn="0.3.21";function be(e){return{prev:null,next:null,data:e}}class le{head=null;tail=null;cursors=[];allocateCursor(e,t){let r={prev:e,next:t};return this.cursors.push(r),r}releaseCursor(){this.cursors.pop()}updateCursors(e,t,r,n){for(let i of this.cursors){if(i.prev===e)i.prev=t;if(i.next===r)i.next=n}}static createItem(e){return be(e)}createItem(e){return be(e)}get isEmpty(){return this.head===null}get first(){return this.head?.data??null}get last(){return this.tail?.data??null}*[Symbol.iterator](){for(let e=this.head;e!=null;e=e.next)yield e.data}fromArray(e){let t=null;this.head=null;for(let r of e){let n=be(r);if(n.prev=t,t)t.next=n;else this.head=n;t=n}return this.tail=t,this}toArray(){let e=[];for(let t=this.head;t!=null;t=t.next)e.push(t.data);return e}toJSON(){return this.toArray()}forEach(e,t){let r=this.allocateCursor(null,this.head);while(r.next!==null){let n=r.next;r.prev=n,r.next=n.next,e.call(t,n.data,n,this)}this.releaseCursor()}forEachRight(e,t){let r=this.allocateCursor(this.tail,null);while(r.prev!==null){let n=r.prev;r.next=n,r.prev=n.prev,e.call(t,n.data,n,this)}this.releaseCursor()}reduce(e,t){let r=t,n=0;for(let i=this.head;i!=null;i=i.next)r=e(r,i.data,n++,this);return r}some(e){let t=0;for(let r=this.head;r!=null;r=r.next)if(e(r.data,t++,this))return!0;return!1}map(e){let t=new le,r=null,n=0;for(let i=this.head;i!=null;i=i.next){let o=be(e(i.data,n++,this));if(o.prev=r,r)r.next=o;else t.head=o;r=o}return t.tail=r,t}filter(e){let t=new le,r=null,n=0;for(let i=this.head;i!=null;i=i.next)if(e(i.data,n++,this)){let o=be(i.data);if(o.prev=r,r)r.next=o;else t.head=o;r=o}return t.tail=r,t}clear(){let e=this.head;while(e){let t=e.next;e.prev=null,e.next=null,e=t}this.head=null,this.tail=null}copy(){let e=new le,t=null;for(let r=this.head;r!=null;r=r.next){let n=be(r.data);if(n.prev=t,t)t.next=n;else e.head=n;t=n}return e.tail=t,e}prepend(e){return this.insert(e,this.head)}prependData(e){return this.insert(be(e),this.head)}append(e){return this.insert(e,null)}appendData(e){return this.insert(be(e),null)}insert(e,t=null){if(t!=null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e,null,null)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else if(this.updateCursors(this.tail,e,null,e),this.tail!==null)this.tail.next=e,e.prev=this.tail,this.tail=e;else this.head=e,this.tail=e;return this}insertData(e,t=null){return this.insert(be(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else if(this.head===e)this.head=e.next;else throw Error("item doesn't belong to list");if(e.next!==null)e.next.prev=e.prev;else if(this.tail===e)this.tail=e.prev;else throw Error("item doesn't belong to list");return e.prev=null,e.next=null,e}push(e){this.insert(be(e),null)}pop(){if(this.tail===null)return null;return this.remove(this.tail)}unshift(e){this.prependData(e)}shift(){if(this.head===null)return null;return this.remove(this.head)}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e,null)}insertList(e,t=null){if(e.head===null)return this;if(t!==null){if(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null)t.prev.next=e.head,e.head.prev=t.prev;else this.head=e.head;t.prev=e.tail,e.tail.next=t}else{if(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null)this.tail.next=e.head,e.head.prev=this.tail;else this.head=e.head;this.tail=e.tail}return e.head=null,e.tail=null,this}replace(e,t){if(t instanceof le)this.insertList(t,e),this.remove(e);else this.insert(t,e),this.remove(e)}}function Q(e){switch(e.type){case"StyleSheet":return oe(e.children,"");case"Rule":return`${Q(e.prelude)}{${Q(e.block)}}`;case"Block":return hu(e.children);case"Atrule":{let t=`@${e.name}`;if(e.prelude){let r=Q(e.prelude);if(r)t+=` ${r}`}if(e.block)t+=`{${Q(e.block)}}`;else t+=";";return t}case"AtrulePrelude":return oe(e.children,"");case"SelectorList":return oe(e.children,",");case"Selector":return oe(e.children,"");case"TypeSelector":return e.name;case"IdSelector":return`#${e.name}`;case"ClassSelector":return`.${e.name}`;case"NestingSelector":return"&";case"AttributeSelector":{let t=`[${e.name.name}`;if(e.matcher&&e.value)if(t+=e.matcher,e.value.type==="String")t+=`"${nn(e.value.value)}"`;else t+=e.value.name;if(e.flags)t+=` ${e.flags}`;return t+="]",t}case"PseudoClassSelector":return e.children?`:${e.name}(${oe(e.children,"")})`:`:${e.name}`;case"PseudoElementSelector":return e.children?`::${e.name}(${oe(e.children,"")})`:`::${e.name}`;case"Combinator":return e.name===" "?" ":e.name;case"Declaration":return`${e.property}:${Q(e.value)}${e.important?"!important":""}`;case"DeclarationList":return oe(e.children,";");case"Value":return oe(e.children,"");case"Identifier":return e.name;case"Number":return e.value;case"Percentage":return`${e.value}%`;case"Dimension":return e.value+e.unit;case"String":return`"${nn(e.value)}"`;case"Url":return/[\s"'()\\\u0000-\u001F\u007F]/.test(e.value)?`url("${nn(e.value)}")`:`url(${e.value})`;case"Hash":return`#${e.name}`;case"Operator":return e.value;case"Function":return`${e.name}(${oe(e.children,"")})`;case"Parentheses":return`(${oe(e.children,"")})`;case"Brackets":return`[${oe(e.children,"")}]`;case"Raw":return e.value;case"Comment":return e.value.startsWith("!")?`/*${e.value}*/`:"";case"WhiteSpace":return" ";case"CDO":return"<!--";case"CDC":return"-->";case"AnPlusB":{let t=e.a??"",r=e.b??"";if(t&&r){let n=Number(r);return`${t==="1"?"":t==="-1"?"-":t}n${n>=0?`+${r}`:r}`}if(t)return`${t==="1"?"":t==="-1"?"-":t}n`;return r}case"Ratio":return`${e.left.value}/${e.right.value}`;case"UnicodeRange":return e.value;case"Nth":return e.selector?`${Q(e.nth)} of ${Q(e.selector)}`:Q(e.nth);case"MediaQueryList":return oe(e.children,",");case"MediaQuery":return oe(e.children,"");case"MediaFeature":{let t=`(${e.name}`;if(e.value)t+=`:${Q(e.value)}`;return t+=")",t}}return""}function oe(e,t){let r="",n=!0,i=null,o=e.head;while(o!=null){let s=o.data;if(s.type==="WhiteSpace"){let a=o.next?o.next.data:null;if(Ki(i)||Ki(a)){o=o.next;continue}}let c=Q(s);if(!c){o=o.next;continue}if(!n&&t&&!mu(i))r+=t;n=!1,r+=c,i=s,o=o.next}return r}function hu(e){let t="",r=null,n=e.head;while(n!=null){let i=n.data,o=Q(i);if(!o){n=n.next;continue}if(r&&gu(r,i))t+=";";t+=o,r=i,n=n.next}return t}function gu(e,t){return e.type==="Declaration"&&t.type!=="Comment"}function Ki(e){if(!e||e.type!=="Operator")return!1;let t=e.value;return t===":"||t===","||t==="/"}function mu(e){if(!e)return!1;return e.type==="Operator"||e.type==="Combinator"}function nn(e){let t="";for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===92)t+="\\\\";else if(n===34)t+="\\\"";else if(n<32||n===127){let i=n.toString(16),o=r+1<e.length?e.charCodeAt(r+1):-1,s=o===32||o===9||o===10||o===12||o===13||o>=48&&o<=57||o>=65&&o<=70||o>=97&&o<=102;t+=`\\${i}${s?" ":""}`}else t+=e[r]}return t}var We=(()=>{let e=new Uint8Array(128);for(let t=0;t<128;t++){let r=0;if(t===32||t===9||t===10||t===12||t===13)r|=1;if(t>=48&&t<=57)r|=2;if(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102)r|=4;if(t>=65&&t<=90||t>=97&&t<=122||t===95)r|=8;if(t===10||t===12||t===13)r|=16;e[t]=r}return e})();function fe(e){return e<128&&(We[e]&2)!==0}function $t(e){return e<128&&(We[e]&4)!==0}function Hi(e){return e>=128||e<128&&(We[e]&8)!==0}function pu(e){return e===45||e>=128||e<128&&(We[e]&10)!==0}function yu(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function sn(e){return e<128&&(We[e]&16)!==0}function Re(e){return e<128&&(We[e]&1)!==0}function Ue(e,t){if(e!==92)return!1;if(sn(t))return!1;return!0}function on(e,t,r){if(e===45)return Hi(t)||t===45||Ue(t,r);if(Hi(e))return!0;if(e===92)return Ue(e,t);return!1}function bu(e,t,r){if(e===43||e===45){if(fe(t))return!0;if(t===46&&fe(r))return!0;return!1}if(e===46)return fe(t);return fe(e)}class Dt{source;offset=0;types;starts;ends;count=0;_tokens=null;_lineStarts=null;constructor(e){this.source=e;let t=Math.max(64,Math.ceil(e.length/3));this.types=new Uint8Array(t),this.starts=new Uint32Array(t),this.ends=new Uint32Array(t),this.tokenize()}get lineStarts(){if(this._lineStarts==null)this._lineStarts=xu(this.source);return this._lineStarts}get tokens(){if(this._tokens!=null)return this._tokens;let e=Array.from({length:this.count});for(let t=0;t<this.count;t++)e[t]={type:this.types[t],start:this.starts[t],end:this.ends[t]};return this._tokens=e,e}addToken(e,t,r){if(this.count>=this.types.length)this.grow();this.types[this.count]=e,this.starts[this.count]=t,this.ends[this.count]=r,this.count++}grow(){let t=this.types.length*2,r=new Uint8Array(t);r.set(this.types),this.types=r;let n=new Uint32Array(t);n.set(this.starts),this.starts=n;let i=new Uint32Array(t);i.set(this.ends),this.ends=i}tokenize(){let e=this.source,t=0,r=e.length;while(t<r){let n=e.charCodeAt(t);if(n===47&&e.charCodeAt(t+1)===42){let s=t;t+=2;while(t<r&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t=t<r?t+2:r,this.addToken(25,s,t);continue}if(Re(n)){let s=t;while(t<r&&Re(e.charCodeAt(t)))t++;this.addToken(13,s,t);continue}if(n===34||n===39){t=this.consumeString(n,t);continue}if(n===35){if(t+1<r&&(pu(e.charCodeAt(t+1))||Ue(e.charCodeAt(t+1),e.charCodeAt(t+2)))){let s=t;t++,t=this.consumeName(t),this.addToken(4,s,t);continue}this.addToken(9,t,t+1),t++;continue}switch(n){case 40:this.addToken(21,t,t+1),t++;continue;case 41:this.addToken(22,t,t+1),t++;continue;case 91:this.addToken(19,t,t+1),t++;continue;case 93:this.addToken(20,t,t+1),t++;continue;case 123:this.addToken(23,t,t+1),t++;continue;case 125:this.addToken(24,t,t+1),t++;continue;case 44:this.addToken(18,t,t+1),t++;continue;case 58:this.addToken(16,t,t+1),t++;continue;case 59:this.addToken(17,t,t+1),t++;continue}if(n===60&&e.startsWith("!--",t+1)){this.addToken(14,t,t+4),t+=4;continue}if(n===45&&e.startsWith("->",t+1)){this.addToken(15,t,t+3),t+=3;continue}if(n===64){let s=e.charCodeAt(t+1),c=e.charCodeAt(t+2),a=e.charCodeAt(t+3);if(on(s,c,a)){let l=t;t++,t=this.consumeName(t),this.addToken(3,l,t);continue}this.addToken(9,t,t+1),t++;continue}let i=e.charCodeAt(t+1),o=e.charCodeAt(t+2);if(bu(n,i,o)){t=this.consumeNumeric(t);continue}if(on(n,i,o)){t=this.consumeIdentLike(t);continue}if(n===92){if(Ue(n,i)){t=this.consumeIdentLike(t);continue}this.addToken(9,t,t+1),t++;continue}this.addToken(9,t,t+1),t++}this.addToken(0,r,r)}consumeString(e,t){let r=this.source,n=r.length,i=t+1;while(i<n){let o=r.charCodeAt(i);if(o===e)return i++,this.addToken(5,t,i),i;if(sn(o))return this.addToken(6,t,i),i;if(o===92){let s=r.charCodeAt(i+1);if(sn(s)){i+=2;continue}if(i+1<n){i=this.consumeEscapeSkip(i+1);continue}}i++}return this.addToken(5,t,i),i}consumeEscapeSkip(e){let t=this.source;if(e>=t.length)return e;let r=t.charCodeAt(e);if($t(r)){let n=1;e++;while(n<6&&e<t.length&&$t(t.charCodeAt(e)))e++,n++;if(e<t.length&&Re(t.charCodeAt(e)))e++;return e}return e+1}consumeName(e){let t=this.source,r=t.length,n=e;while(n<r){let i=t.charCodeAt(n);if(i<128&&(We[i]&10)!==0){n++;continue}if(i===45){n++;continue}if(i>=128){n++;continue}if(i===92&&Ue(i,t.charCodeAt(n+1))){n=this.consumeEscapeSkip(n+1);continue}break}return n}consumeNumber(e){let t=this.source,r=e;if(t.charCodeAt(r)===43||t.charCodeAt(r)===45)r++;while(r<t.length&&fe(t.charCodeAt(r)))r++;if(t.charCodeAt(r)===46&&fe(t.charCodeAt(r+1))){r+=2;while(r<t.length&&fe(t.charCodeAt(r)))r++}let n=t.charCodeAt(r);if(n===69||n===101){let i=t.charCodeAt(r+1),o=t.charCodeAt(r+2);if(fe(i)){r+=2;while(r<t.length&&fe(t.charCodeAt(r)))r++}else if((i===43||i===45)&&fe(o)){r+=3;while(r<t.length&&fe(t.charCodeAt(r)))r++}}return r}consumeNumeric(e){let t=this.source,r=this.consumeNumber(e),n=t.charCodeAt(r),i=t.charCodeAt(r+1),o=t.charCodeAt(r+2);if(on(n,i,o)){let s=this.consumeName(r);return this.addToken(12,e,s),s}if(n===37)return this.addToken(11,e,r+1),r+1;return this.addToken(10,e,r),r}consumeIdentLike(e){let t=this.source,r=this.consumeName(e),n=t.charCodeAt(r);if(n===40&&r-e===3){let i=t.charCodeAt(e)|32,o=t.charCodeAt(e+1)|32,s=t.charCodeAt(e+2)|32;if(i===117&&o===114&&s===108){let c=r+1;while(c<t.length&&Re(t.charCodeAt(c)))c++;let a=t.charCodeAt(c);if(a===34||a===39)return this.addToken(2,e,r+1),r+1;return this.consumeUrl(e,r)}}if(n===40)return this.addToken(2,e,r+1),r+1;return this.addToken(1,e,r),r}consumeUrl(e,t){let r=this.source,n=r.length,i=t+1;while(i<n&&Re(r.charCodeAt(i)))i++;while(i<n){let o=r.charCodeAt(i);if(o===41)return i++,this.addToken(7,e,i),i;if(Re(o)){let s=i;while(i<n&&Re(r.charCodeAt(i)))i++;if(i>=n)return this.addToken(7,e,i),i;if(r.charCodeAt(i)===41)return i++,this.addToken(7,e,i),i;return this.consumeBadUrl(e,s)}if(o===34||o===39||o===40||yu(o))return this.consumeBadUrl(e,i);if(o===92){if(Ue(o,r.charCodeAt(i+1))){i=this.consumeEscapeSkip(i+1);continue}return this.consumeBadUrl(e,i)}i++}return this.addToken(7,e,i),i}consumeBadUrl(e,t){let r=this.source,n=t;while(n<r.length){let i=r.charCodeAt(n);if(i===41){n++;break}if(i===92&&Ue(i,r.charCodeAt(n+1))){n=this.consumeEscapeSkip(n+1);continue}n++}return this.addToken(8,e,n),n}locate(e){let t=this.lineStarts,r=0,n=t.length-1;while(r<n){let o=r+n+1>>1;if(t[o]<=e)r=o;else n=o-1}let i=t[r];return{line:r+1,column:e-i+1}}}function xu(e){let t=[0],r=e.length;for(let n=0;n<r;n++){let i=e.charCodeAt(n);if(i===10)t.push(n+1);else if(i===13){if(e.charCodeAt(n+1)!==10)t.push(n+1)}}return t}function an(e,t,r){for(let n=t;n<r;n++)if(e.charCodeAt(n)===92)return vu(e,t,r,n);return e.slice(t,r)}function vu(e,t,r,n){let i=e.slice(t,n),o=n;while(o<r){if(e.charCodeAt(o)!==92){i+=e[o],o++;continue}if(o+1>=r){o++;continue}let c=e.charCodeAt(o+1);if(c===10){o+=2;continue}if(c===13){o+=e.charCodeAt(o+2)===10?3:2;continue}if($t(c)){let a=o+1,l="";while(l.length<6&&a<r&&$t(e.charCodeAt(a)))l+=e[a],a++;let u=Number.parseInt(l,16);if(a<r&&Re(e.charCodeAt(a)))a++;i+=u===0||u>=55296&&u<=57343||u>1114111?String.fromCodePoint(65533):String.fromCodePoint(u),o=a;continue}i+=e[o+1],o+=2}return i}function ln(e,t,r){for(let n=t;n<r;n++)if(e.charCodeAt(n)===92)return wu(e,t,r,n);return e.slice(t,r)}function wu(e,t,r,n){let i=e.slice(t,n),o=n;while(o<r){if(e.charCodeAt(o)!==92){i+=e[o],o++;continue}let c=o+1,a="";while(a.length<6&&c<r&&$t(e.charCodeAt(c)))a+=e[c],c++;if(a.length>0){let l=Number.parseInt(a,16);if(c<r&&Re(e.charCodeAt(c)))c++;i+=l===0||l>=55296&&l<=57343||l>1114111?String.fromCodePoint(65533):String.fromCodePoint(l),o=c;continue}if(c<r){i+=e[c],o=c+1;continue}i+=String.fromCodePoint(65533),o=c}return i}function Qi(e,t){let r=new Dt(e);return{source:e,types:r.types,starts:r.starts,ends:r.ends,count:r.count,end:r.count,pos:0,positions:t.positions??!1,filename:t.filename,parseValue:t.parseValue??!0,parseAtrulePrelude:t.parseAtrulePrelude??!0,parseCustomProperty:t.parseCustomProperty??!1,parseRulePrelude:t.parseRulePrelude??!0,onParseError:t.onParseError,tokenizer:r}}function b(e){return e.pos<e.end?e.types[e.pos]:0}function v(e){let t=e.pos;if(t>=e.end)return{type:0,start:e.starts[t]??e.source.length,end:e.ends[t]??e.source.length};return{type:e.types[t],start:e.starts[t],end:e.ends[t]}}function C(e){let t=e.pos++;if(t>=e.end)return{type:0,start:e.starts[t]??e.source.length,end:e.ends[t]??e.source.length};return{type:e.types[t],start:e.starts[t],end:e.ends[t]}}function xe(e,t){return e.source.slice(t.start,t.end)}function de(e){let{types:t,end:r}=e;while(e.pos<r){let n=t[e.pos];if(n===13||n===25)e.pos++;else break}}function Gi(e){let{types:t,end:r}=e;while(e.pos<r&&t[e.pos]===13)e.pos++}function R(e,t,r){if(!e.positions)return null;let n=e.tokenizer.locate(t.start),i=e.tokenizer.locate(r.end);return{source:e.filename??"<unknown>",start:{offset:t.start,line:n.line,column:n.column},end:{offset:r.end,line:i.line,column:i.column}}}function eo(e){if(!e.positions)return null;let t=v(e),r=e.tokenizer.locate(t.start);return{source:e.filename??"<unknown>",start:{offset:t.start,line:r.line,column:r.column},end:{offset:t.start,line:r.line,column:r.column}}}function jt(e,t,r,n){return{type:"Raw",value:e,loc:R(n,t,r)}}function te(){return new le}function cn(e,t,r,n){if(e.onParseError){let{line:i,column:o}=e.tokenizer.locate(r.start),s=SyntaxError(`${e.filename??"<input>"}:${i}:${o}: ${t}`);s.line=i,s.column=o,s.offset=r.start,e.onParseError(s,n)}return n}function Vt(e,t={}){let r=Qi(e,t);switch(t.context??"stylesheet"){case"stylesheet":return Ji(r);case"atrule":return Ut(r)??qi(r);case"atrulePrelude":return ku(r);case"mediaQuery":case"mediaQueryList":return Yi(r);case"rule":return fn(r);case"selectorList":return gn(r);case"selector":return io(r);case"block":return dn(r);case"declarationList":return Eu(r);case"declaration":return hn(r)??qi(r);case"value":return Tu(r);case"raw":return Yi(r);default:return Ji(r)}}function qi(e){return{type:"StyleSheet",children:te(),loc:eo(e)}}function Yi(e){let t=v(e),r=t;while(b(e)!==0)r=C(e);return{type:"Raw",value:e.source.slice(t.start,r.end),loc:R(e,t,r)}}function Ji(e){let t=v(e),r=te(),{types:n,end:i}=e;while(e.pos<i){let c=n[e.pos];if(c===13){e.pos++;continue}if(c===25){let u={type:25,start:e.starts[e.pos],end:e.ends[e.pos]},f=un(e,u);e.pos++,r.appendData(f);continue}if(c===0)break;if(c===14||c===15){e.pos++;continue}if(c===3){let u=Ut(e);if(u)r.appendData(u);continue}if(c===24){e.pos++;continue}let a=e.pos,l=fn(e);if(r.appendData(l),e.pos===a)e.pos++}let o=e.end-1,s=o>=0?{type:e.types[o],start:e.starts[o],end:e.ends[o]}:{type:0,start:0,end:0};return{type:"StyleSheet",children:r,loc:R(e,t,s)}}function un(e,t){return{type:"Comment",value:e.source.slice(t.start+2,t.end-2),loc:R(e,t,t)}}function Ut(e){let t=v(e);if(t.type!==3)return null;e.pos++;let r=Bt(e.source,t.start+1,t.end);de(e);let n=e.pos,i=v(e),{types:o,end:s}=e,c=n,a=n;while(c<s){let f=o[c];if(f===0||f===17||f===23)break;if(f!==13&&f!==25)a=c+1;c++}let l=null;if(a>n){let f=e.starts[n],d=e.ends[a-1],h={type:o[a-1],start:e.starts[a-1],end:d},m=e.source.slice(f,d).trim();if(m.length>0)if(e.parseAtrulePrelude)try{let g=e.end;e.end=a,e.pos=n;let p=te();while(b(e)!==0){let y=ze(e);if(y)p.appendData(y)}if(ro(p),e.end=g,e.pos=c,p.isEmpty)l=jt(m,i,h,e);else l={type:"AtrulePrelude",children:p,loc:null}}catch(g){let p=jt(m,i,h,e);cn(e,`Failed to parse @${r} prelude: ${g.message}`,i,p),l=p,e.pos=c}else l=jt(m,i,h,e),e.pos=c;else e.pos=c}else e.pos=c;let u=null;if(b(e)===17)C(e);else if(b(e)===23)u=dn(e,Ru.has(r));return{type:"Atrule",name:r,prelude:l,block:u,loc:R(e,t,v(e))}}var $u=new Set(["is","not","where","has","matches","-moz-any","-webkit-any"]),Ru=new Set(["media","supports","document","layer","container","scope","starting-style","-moz-document","keyframes","-webkit-keyframes","-moz-keyframes","-o-keyframes"]);function ku(e){let t=v(e),r=te();while(b(e)!==0){if(v(e).type===13){e.pos++;continue}let i=ze(e);if(i)r.appendData(i)}return{type:"AtrulePrelude",children:r,loc:R(e,t,v(e))}}function fn(e){let t=v(e),r;if(e.parseRulePrelude)r=gn(e);else{let i=v(e),o=i;while(b(e)!==0&&b(e)!==23)o=C(e);let s=e.source.slice(i.start,o.end).trim();r=jt(s,i,o,e)}let n=dn(e,!0);return{type:"Rule",prelude:r,block:n,loc:R(e,t,v(e))}}function dn(e,t=!1){let r=v(e);if(b(e)!==23)return{type:"Block",children:te(),loc:eo(e)};e.pos++;let n=te(),{types:i,end:o}=e;while(e.pos<o){let s=i[e.pos];if(s===24||s===0)break;if(s===13){e.pos++;continue}if(s===25){let a={type:25,start:e.starts[e.pos],end:e.ends[e.pos]};e.pos++,n.appendData(un(e,a));continue}if(s===3){let a=Ut(e);if(a)n.appendData(a);continue}if(t&&Su(e,Au)){let a=fn(e);n.appendData(a);continue}let c=hn(e);if(c)n.appendData(c);if(e.pos<o&&i[e.pos]===17)e.pos++}if(b(e)===24)e.pos++;return{type:"Block",children:n,loc:R(e,r,v(e))}}function Su(e,t){let r=e.pos,n=t(e);return e.pos=r,n}function Au(e){let{types:t,end:r}=e;while(e.pos<r){let n=t[e.pos];if(n===23)return!0;if(n===17||n===24||n===0)return!1;e.pos++}return!1}function Eu(e){let t=v(e),r=te();while(b(e)!==0&&b(e)!==24){let n=v(e);if(n.type===13){e.pos++;continue}if(n.type===25){r.appendData(un(e,C(e)));continue}if(n.type===17){e.pos++;continue}if(n.type===3){let o=Ut(e);if(o)r.appendData(o);continue}let i=hn(e);if(i)r.appendData(i);if(b(e)===17)C(e)}return{type:"DeclarationList",children:r,loc:R(e,t,v(e))}}function hn(e){de(e);let t=v(e);if(t.type!==1&&t.type!==4&&!(t.type===9&&e.source[t.start]==="*"&&e.source[t.start+1]===" "))if(t.type===9&&e.source[t.start]==="*")e.pos++;else{cn(e,"Expected property name",t,{type:"Raw",value:"",loc:null});let{types:S,end:j}=e;while(e.pos<j){let q=S[e.pos];if(q===0||q===17||q===24)break;e.pos++}return null}let r=e.starts[e.pos],n=e.ends[e.pos];e.pos++;let i=e.source.slice(r,n);if(Gi(e),b(e)!==16){cn(e,`Expected ':' after property "${i}"`,v(e),{type:"Raw",value:"",loc:null});let{types:S,end:j}=e;while(e.pos<j){let q=S[e.pos];if(q===0||q===17||q===24)break;e.pos++}return null}e.pos++,Gi(e);let{types:o,starts:s,end:c,pos:a}=e,l=a,u=a,f=-1,d=-1;while(l<c){let S=o[l];if(S===0||S===17||S===24)break;if(S===9&&e.source.charCodeAt(s[l])===33){let j=l+1;while(j<c&&o[j]===13)j++;if(j<c&&o[j]===1){let q=s[j];if(e.ends[j]-q===9&&(e.source.charCodeAt(q)|32)===105&&(e.source.charCodeAt(q+1)|32)===109&&(e.source.charCodeAt(q+2)|32)===112&&(e.source.charCodeAt(q+3)|32)===111&&(e.source.charCodeAt(q+4)|32)===114&&(e.source.charCodeAt(q+5)|32)===116&&(e.source.charCodeAt(q+6)|32)===97&&(e.source.charCodeAt(q+7)|32)===110&&(e.source.charCodeAt(q+8)|32)===116){d=l,f=j,l=j+1;continue}}}if(S!==13&&S!==25)u=l+1;l++}let h=u,m=f>=0?{type:1,start:s[f],end:e.ends[f]}:null,g=i.startsWith("--"),p,y=s[a],x=h>a?e.ends[h-1]:y,w={type:o[a],start:y,end:e.ends[a]},T=h>a?{type:o[h-1],start:s[h-1],end:x}:w;if(g&&!e.parseCustomProperty||!e.parseValue)p={type:"Raw",value:e.source.slice(y,x).trim(),loc:R(e,w,T)};else if(h===a)p={type:"Value",children:te(),loc:R(e,w,T)};else{let S=e.end;e.end=h,e.pos=a,p=to(e),e.end=S}return e.pos=l,{type:"Declaration",property:i,important:m?!0:!1,value:p,loc:R(e,t,v(e))}}function Tu(e){return to(e)}function to(e){let t=v(e),r=te();while(b(e)!==0&&b(e)!==17&&b(e)!==24&&b(e)!==22&&b(e)!==20){let n=ze(e);if(n)r.appendData(n)}return no(r),{type:"Value",children:r,loc:R(e,t,v(e))}}function ro(e){for(let t of e)if("children"in t&&t.children instanceof le)ro(t.children);no(e)}function no(e){let t=e.head;while(t){if(t.data.type==="Number"){let r=t.next;while(r&&r.data.type==="WhiteSpace")r=r.next;if(r&&r.data.type==="Operator"&&r.data.value==="/"){let n=r.next;while(n&&n.data.type==="WhiteSpace")n=n.next;if(n&&n.data.type==="Number"){let i={type:"Ratio",left:t.data,right:n.data,loc:null},o=t.next;while(o&&o!==n.next){let s=o.next;e.remove(o),o=s}e.replace(t,e.createItem(i)),t=e.head;continue}}}t=t.next}}function ze(e){let t=e.pos;if(t>=e.end)return null;let r=e.types[t],n=e.starts[t],i=e.ends[t],o=e.source;switch(r){case 13:return e.pos++,e.positions?{type:"WhiteSpace",value:" ",loc:ee(e,n,i)}:{type:"WhiteSpace",value:" ",loc:null};case 25:return e.pos++,{type:"Comment",value:o.slice(n+2,i-2),loc:e.positions?ee(e,n,i):null};case 10:return e.pos++,{type:"Number",value:o.slice(n,i),loc:e.positions?ee(e,n,i):null};case 11:return e.pos++,{type:"Percentage",value:o.slice(n,i-1),loc:e.positions?ee(e,n,i):null};case 12:{e.pos++;let s=n,c=o.charCodeAt(s);if(c===43||c===45)s++;let a=!1;while(s<i){let u=o.charCodeAt(s);if(u>=48&&u<=57){s++;continue}if(u===46&&!a){a=!0,s++;continue}break}let l=o.charCodeAt(s);if(l===69||l===101){let u=s+1,f=o.charCodeAt(u);if(f===43||f===45)u++;let d=!1;while(u<i){let h=o.charCodeAt(u);if(h>=48&&h<=57){u++,d=!0;continue}break}if(d)s=u}return{type:"Dimension",value:o.slice(n,s),unit:o.slice(s,i),loc:e.positions?ee(e,n,i):null}}case 1:return e.pos++,{type:"Identifier",name:ln(o,n,i),loc:e.positions?ee(e,n,i):null};case 5:{e.pos++;let s=n+1,a=i-n>=2&&o.charCodeAt(i-1)===o.charCodeAt(n)?i-1:i;return{type:"String",value:an(o,s,a),loc:e.positions?ee(e,n,i):null}}case 7:{e.pos++;let s=n+4;while(s<i&&Xi(o.charCodeAt(s)))s++;let c=i;if(c>s&&o.charCodeAt(c-1)===41)c--;while(c>s&&Xi(o.charCodeAt(c-1)))c--;let a;if(c-s>=2){let l=o.charCodeAt(s),u=o.charCodeAt(c-1);if((l===34||l===39)&&l===u)a=o.slice(s+1,c-1);else a=o.slice(s,c)}else a=o.slice(s,c);return{type:"Url",value:a,loc:e.positions?ee(e,n,i):null}}case 4:return e.pos++,{type:"Hash",name:o.slice(n+1,i),loc:e.positions?ee(e,n,i):null};case 2:return Ou(e);case 21:return Iu(e);case 18:return e.pos++,{type:"Operator",value:",",loc:e.positions?ee(e,n,i):null};case 16:return e.pos++,{type:"Operator",value:":",loc:e.positions?ee(e,n,i):null};case 9:{e.pos++;let s=o.charCodeAt(n),c=o[n];if(Nu(s))return{type:"Operator",value:c,loc:e.positions?ee(e,n,i):null};return{type:"Identifier",name:c,loc:e.positions?ee(e,n,i):null}}case 19:{e.pos++;let s=te();while(b(e)!==0&&b(e)!==20){let a=ze(e);if(a)s.appendData(a)}let c=e.pos<e.end?e.ends[e.pos]:i;if(b(e)===20)e.pos++;return{type:"Brackets",children:s,loc:e.positions?ee(e,n,c):null}}case 3:case 23:case 24:case 22:case 20:case 17:case 0:case 14:case 15:case 6:case 8:return e.pos++,{type:"Raw",value:o.slice(n,i),loc:e.positions?ee(e,n,i):null}}return e.pos++,null}function Xi(e){return e===32||e===9||e===10||e===12||e===13}function Nu(e){return e===47||e===43||e===45||e===42||e===61||e===62||e===60||e===126||e===124||e===36||e===94||e===33||e===38}function Bt(e,t,r){for(let n=t;n<r;n++){let i=e.charCodeAt(n);if(i>=65&&i<=90)return e.slice(t,r).toLowerCase()}return e.slice(t,r)}function ee(e,t,r){let n=e.tokenizer.locate(t),i=e.tokenizer.locate(r);return{source:e.filename??"<unknown>",start:{offset:t,line:n.line,column:n.column},end:{offset:r,line:i.line,column:i.column}}}function Ou(e){let t=C(e),r=Bt(e.source,t.start,t.end-1),n=te();while(b(e)!==0&&b(e)!==22){let i=ze(e);if(i)n.appendData(i)}if(b(e)===22)C(e);if(r==="url"){for(let i=n.head;i!=null;i=i.next)if(i.data.type==="String")return{type:"Url",value:i.data.value,loc:R(e,t,v(e))}}return{type:"Function",name:r,children:n,loc:R(e,t,v(e))}}function Iu(e){let t=C(e),r=te();while(b(e)!==0&&b(e)!==22){let n=ze(e);if(n)r.appendData(n)}if(b(e)===22)C(e);return{type:"Parentheses",children:r,loc:R(e,t,v(e))}}function gn(e){let t=v(e),r=te();while(b(e)!==0){if(de(e),b(e)===0||b(e)===23)break;let n=io(e);if(n.children.head!==null)r.appendData(n);if(de(e),b(e)===18){C(e);continue}break}return{type:"SelectorList",children:r,loc:R(e,t,v(e))}}function io(e){let t=v(e),r=te(),n=!0;while(b(e)!==0&&b(e)!==18&&b(e)!==23){let i=v(e);if(i.type===13){if(C(e),!n&&b(e)!==0&&b(e)!==18&&b(e)!==23&&!Zi(e)&&!Pu(e)){let s={type:"Combinator",name:" ",loc:R(e,i,i)};r.appendData(s),n=!0}continue}if(i.type===9&&e.source.charCodeAt(i.start)===124&&e.types[e.pos+1]===9&&e.source.charCodeAt(e.starts[e.pos+1])===124){let s=v(e);C(e);let c=C(e),a={type:"Combinator",name:"||",loc:R(e,s,c)};r.appendData(a),n=!0,de(e);continue}if(Zi(e)){let s=C(e),a={type:"Combinator",name:e.source[s.start],loc:R(e,s,s)};r.appendData(a),n=!0,de(e);continue}let o=_u(e);if(!o)break;r.appendData(o),n=!1}while(r.tail&&r.tail.data.type==="Combinator")r.remove(r.tail);return{type:"Selector",children:r,loc:R(e,t,v(e))}}function Zi(e){let t=v(e);if(t.type!==9)return!1;let r=e.source[t.start];return r===">"||r==="+"||r==="~"}function Pu(e){if(e.types[e.pos]!==9)return!1;if(e.source.charCodeAt(e.starts[e.pos])!==124)return!1;if(e.types[e.pos+1]!==9)return!1;return e.source.charCodeAt(e.starts[e.pos+1])===124}function _u(e){let t=v(e);switch(t.type){case 1:{if(C(e),b(e)===9&&e.source[v(e).start]==="|"&&e.source[v(e).start+1]!=="="&&!(e.types[e.pos+1]===9&&e.source.charCodeAt(e.starts[e.pos+1])===124)){if(C(e),b(e)===1){let n=C(e);return{type:"TypeSelector",name:`${xe(e,t)}|${xe(e,n)}`,loc:R(e,t,n)}}if(b(e)===9&&e.source[v(e).start]==="*"){let n=C(e);return{type:"TypeSelector",name:`${xe(e,t)}|*`,loc:R(e,t,n)}}}return{type:"TypeSelector",name:xe(e,t),loc:R(e,t,t)}}case 11:return C(e),{type:"TypeSelector",name:xe(e,t),loc:R(e,t,t)};case 10:return C(e),{type:"TypeSelector",name:xe(e,t),loc:R(e,t,t)};case 9:{let r=e.source[t.start];if(r==="*")return C(e),{type:"TypeSelector",name:"*",loc:R(e,t,t)};if(r==="."){if(C(e),b(e)===1){let n=C(e);return{type:"ClassSelector",name:xe(e,n),loc:R(e,t,n)}}return null}if(r==="&")return C(e),{type:"NestingSelector",loc:R(e,t,t)};return C(e),null}case 4:return C(e),{type:"IdSelector",name:e.source.slice(t.start+1,t.end),loc:R(e,t,t)};case 16:{C(e);let r=b(e)===16;if(r)C(e);return Lu(e,r,t)}case 19:return Mu(e)}return null}function Lu(e,t,r){let n=v(e);if(n.type===1){C(e);let i=Bt(e.source,n.start,n.end);return t?{type:"PseudoElementSelector",name:i,children:null,loc:R(e,r,n)}:{type:"PseudoClassSelector",name:i,children:null,loc:R(e,r,n)}}if(n.type===2){C(e);let i=Bt(e.source,n.start,n.end-1),o=te();if(!t&&$u.has(i)){let a=v(e),l=a,u=1;while(b(e)!==0&&u>0){if(b(e)===21||b(e)===2)u++;else if(b(e)===22){if(u--,u===0)break}l=C(e)}if(b(e)===22)C(e);let f=e.source.slice(a.start,l.end).trim();if(f.length>0){let d=Qi(f,{positions:!1}),h=gn(d);o.appendData(h)}}else{while(b(e)!==0&&b(e)!==22){let a=ze(e);if(a)o.appendData(a)}if(b(e)===22)C(e)}if(t)return{type:"PseudoElementSelector",name:i,children:o,loc:R(e,r,v(e))};return{type:"PseudoClassSelector",name:i,children:o,loc:R(e,r,v(e))}}return null}function Mu(e){let t=C(e);de(e);let r=v(e);if(r.type!==1)return null;C(e);let n={type:"Identifier",name:xe(e,r),loc:R(e,r,r)};de(e);let i=null,o=null,s=null,c=v(e);if(c.type===9){let l=e.source[c.start],u=e.source[c.start+1];if(l==="=")i="=",C(e);else if((l==="~"||l==="|"||l==="^"||l==="$"||l==="*")&&u==="="){C(e);let h=v(e);if(h.type===9&&e.source[h.start]==="=")C(e),i=`${l}=`}de(e);let f=v(e);if(f.type===5){C(e);let h=f.end-f.start>=2&&e.source.charCodeAt(f.end-1)===e.source.charCodeAt(f.start);o={type:"String",value:an(e.source,f.start+1,h?f.end-1:f.end),loc:R(e,f,f)}}else if(f.type===1)C(e),o={type:"Identifier",name:xe(e,f),loc:R(e,f,f)};de(e);let d=v(e);if(d.type===1)C(e),s=xe(e,d)}de(e);let a=v(e);if(b(e)===20)a=C(e);return{type:"AttributeSelector",name:n,matcher:i,value:o,flags:s,loc:R(e,t,a)}}var oo=Symbol("walkSkip"),V=Symbol("walkStop");function Fu(e){return{root:e,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null}}function Du(e,t){let r=Fu(e),n=typeof t==="function"?t:t.enter,i=typeof t==="function"?null:t.leave??null,o=typeof t==="function"?null:t.visit??null,s=typeof t==="function"?!1:t.reverse??!1;function c(a,l,u){let f=null,d;switch(a.type){case"StyleSheet":f="stylesheet",d=r.stylesheet,r.stylesheet=a;break;case"Atrule":f="atrule",d=r.atrule,r.atrule=a;break;case"AtrulePrelude":f="atrulePrelude",d=r.atrulePrelude,r.atrulePrelude=a;break;case"Rule":f="rule",d=r.rule,r.rule=a;break;case"Selector":f="selector",d=r.selector,r.selector=a;break;case"Block":f="block",d=r.block,r.block=a;break;case"Declaration":f="declaration",d=r.declaration,r.declaration=a;break;case"Function":f="function",d=r.function,r.function=a;break}let h;if((o===null||o===a.type)&&n){let m=n.call(r,a,l,u);if(m===oo){if(f)r[f]=d;return}if(m===V){if(f)r[f]=d;return V}}if(h=ju(a,s,c),h===V){if(f)r[f]=d;return V}if((o===null||o===a.type)&&i){if(i.call(r,a,l,u)===V){if(f)r[f]=d;return V}}if(f)r[f]=d;return}return c(e,null,null)}var Ke=Object.assign(Du,{skip:oo,stop:V});function ju(e,t,r){if("children"in e&&e.children instanceof le)return Bu(e.children,t,r);if(e.type==="Rule"){if(r(e.prelude,null,null)===V)return V;if(r(e.block,null,null)===V)return V;return}if(e.type==="Atrule"){if(e.prelude){if(r(e.prelude,null,null)===V)return V}if(e.block){if(r(e.block,null,null)===V)return V}return}if(e.type==="Declaration")return r(e.value,null,null);if(e.type==="AttributeSelector"){if(r(e.name,null,null)===V)return V;if(e.value)return r(e.value,null,null);return}return}function Bu(e,t,r){let n;if(t)e.forEachRight((i,o,s)=>{if(n)return;if(r(i,o,s)===V)n=V});else e.forEach((i,o,s)=>{if(n)return;if(r(i,o,s)===V)n=V});return n}function Qe(e,t={}){let r=t.exclamation??!1,n=!1;Ke(e,(i,o,s)=>{if(i.type!=="Comment")return;let c=i.value.startsWith("!");if(r===!0&&c)return;if(r==="first-exclamation"&&c&&!n){n=!0;return}if(o&&s)s.remove(o)})}function Wt(e){Ke(e,(t)=>{if(t.type!=="Block"&&t.type!=="DeclarationList")return;if(!("children"in t)||!t.children)return;let r=t.children,n=r.head;if(n==null||n.next==null)return;let i=0;for(let c=n;c!=null;c=c.next)if(c.data.type==="Declaration"){if(i++,i>=2)break}if(i<2)return;let o=new Map,s=[];for(let c=n;c!=null;c=c.next){let a=c.data;if(a.type!=="Declaration")continue;let l=a.property,u=o.get(l);if(u){let f=!!u.decl.important,d=!!a.important;if(d||f===d)s.push(u.item),o.set(l,{item:c,decl:a});else s.push(c)}else o.set(l,{item:c,decl:a})}for(let c of s)r.remove(c)})}var Vu={black:"#000",fuchsia:"#f0f",white:"#fff",red:"#f00",cyan:"#0ff",blue:"#00f",yellow:"#ff0",magenta:"#f0f",lime:"#0f0",silver:"#c0c0c0",gray:"#808080",maroon:"#800000",olive:"#808000",green:"#008000",purple:"#800080",teal:"#008080",navy:"#000080"},Uu={"#f00":"red","#ff0000":"red","#000080":"navy","#008080":"teal"};function pn(e){if(!e.startsWith("#"))return e;let t=e.slice(1);if(t.length===6){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5])return`#${t[0]}${t[2]}${t[4]}`}if(t.length===8){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&t[6]===t[7])return`#${t[0]}${t[2]}${t[4]}${t[6]}`}return e}function so(e){let t=e.toLowerCase();return Vu[t]??null}function ao(e){let t=e.toLowerCase();return Uu[t]??null}function Wu(e,t,r){let n=(e<<16|t<<8|r).toString(16).padStart(6,"0");return pn(`#${n}`)}var zu=/^rgba?\(\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*(?:[,/]\s*([+-]?\d*\.?\d+%?)\s*)?\)$/;function lo(e){let t=zu.exec(e.trim());if(!t)return e;let r=mn(t[1]),n=mn(t[2]),i=mn(t[3]);if(t[4]!==void 0&&!Ku(t[4]))return e;return Wu(r,n,i)}function Ku(e){if(e.endsWith("%"))return Number.parseFloat(e)>=100;return Number.parseFloat(e)>=1}function mn(e){if(e.endsWith("%"))return Math.max(0,Math.min(255,Math.round(Number.parseFloat(e)*2.55)));return Math.max(0,Math.min(255,Math.round(Number.parseFloat(e))))}var Hu=new Set(["px","pt","pc","in","cm","mm","q","em","rem","ex","ch","cap","ic","lh","rlh","vw","vh","vi","vb","vmin","vmax","svw","svh","svi","svb","svmin","svmax","lvw","lvh","lvi","lvb","lvmin","lvmax","dvw","dvh","dvi","dvb","dvmin","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"]);function zt(e){if(e.charCodeAt(0)===43)e=e.slice(1);if(e.includes(".")){let t=e.replace(/(\.\d*?)0+($|[eE])/,"$1$2");t=t.replace(/\.($|[eE])/,"$1"),e=t}if(e.startsWith("0.")&&e.length>2)e=e.slice(1);else if(e.startsWith("-0.")&&e.length>3)e=`-${e.slice(2)}`;if(e==="-0"||e==="-.0"||e==="-0.0")e="0";return e}function co(e,t){let r=zt(e);if((r==="0"||r==="-0")&&Hu.has(t.toLowerCase()))return{value:"0",unit:""};return{value:r,unit:t}}function uo(e){return zt(e)}function fo(e,t){let r=Number.parseFloat(e);if(!Number.isFinite(r))return e;let n=t<0?0:t;return r.toFixed(n)}var ho=new Set(["color","background","background-color","border","border-color","border-top","border-top-color","border-right","border-right-color","border-bottom","border-bottom-color","border-left","border-left-color","border-block","border-block-color","border-block-start-color","border-block-end-color","border-inline","border-inline-color","border-inline-start-color","border-inline-end-color","outline","outline-color","caret-color","fill","stroke","flood-color","lighting-color","stop-color","column-rule","column-rule-color","text-decoration","text-decoration-color","text-emphasis","text-emphasis-color","text-shadow","box-shadow","accent-color","scrollbar-color"]);function go(e){if(!e||e.type!=="Operator")return!1;let t=e.value;return t===":"||t===","||t==="/"}function Gu(e){let t=e.children;if(!t)return;while(t.head&&t.head.data.type==="WhiteSpace")t.remove(t.head);while(t.tail&&t.tail.data.type==="WhiteSpace")t.remove(t.tail);let r=t.head;while(r){let n=r.next;if(r.data.type==="WhiteSpace"){let i=r.prev&&go(r.prev.data),o=n&&go(n.data);if(i||o)t.remove(r)}r=n}}function yn(e,t={}){let r=t.floatPrecision??null,n=r===null?null:(i)=>fo(i,r);Ke(e,{enter(i,o,s){switch(i.type){case"Number":{let c=n?n(i.value):i.value;i.value=zt(c);return}case"Percentage":{let c=n?n(i.value):i.value;i.value=uo(c);return}case"Dimension":{let c=n?n(i.value):i.value,a=co(c,i.unit);i.value=a.value,i.unit=a.unit;return}case"Hash":{let c=pn(`#${i.name}`).slice(1);if(i.name=c,o&&s&&this.declaration&&ho.has(this.declaration.property.toLowerCase())){let a=ao(`#${c}`);if(a&&a.length<c.length+1){let l={type:"Identifier",name:a,loc:i.loc};s.replace(o,s.createItem(l))}}return}case"Identifier":{if(!o||!s||!this.declaration)return;if(!ho.has(this.declaration.property.toLowerCase()))return;let c=so(i.name);if(c&&c.length<i.name.length){let a={type:"Hash",name:c.slice(1),loc:i.loc};s.replace(o,s.createItem(a))}return}case"Url":return;case"Function":{let c=i.name.toLowerCase();if((c==="rgb"||c==="rgba")&&o&&s)i.__rgbReplaceCandidate=!0}}},leave(i,o,s){if(i.type==="Parentheses"||i.type==="Function"||i.type==="Value")Gu(i);if(i.type==="Function"&&i.__rgbReplaceCandidate&&o&&s){let c=Q(i),a=lo(c);if(a!==c&&a.startsWith("#")){let l={type:"Hash",name:a.slice(1),loc:i.loc};s.replace(o,s.createItem(l))}}}})}function qu(e,t={}){let r=Vt(e,{context:"stylesheet"});return mo(r,t)}function bn(e,t={}){let r=Vt(e,{context:"declarationList"});return mo(r,t)}function mo(e,t){if(t.comments===!1)Qe(e,{exclamation:!1});else if(t.comments==="first-exclamation")Qe(e,{exclamation:"first-exclamation"});else Qe(e,{exclamation:!0});return yn(e,{floatPrecision:t.floatPrecision??null}),Wt(e),{css:Q(e),ast:e}}function Le(e,t,r){if(e.size>=1e4){let n=e.keys().next().value;if(n!==void 0)e.delete(n)}return e.set(t,r),r}var po=new Map,_e=new Map;var xn={col:"col",row:"row",jc:"justify",ji:"justify-items",js:"justify-self",ai:"items",ac:"content",as:"self",wrap:"wrap",nowrap:"nowrap",c:"center",s:"start",e:"end",sb:"between",sa:"around",se:"evenly",st:"stretch",thin:"thin",extralight:"extralight",light:"light",normal:"normal",medium:"medium",semibold:"semibold",bold:"bold",extrabold:"extrabold",black:"black",t:"top",r:"right",b:"bottom",l:"left"},Xu=/[%#()]/,Zu=/^\d+(?:\.\d+)?(?:px|rem|em|vh|vw|dvh|dvw|svh|svw|lvh|lvw|ch|ex|lh|cap|ic|rlh|vi|vb|vmin|vmax|cqw|cqh|cqi|cqb|cqmin|cqmax|cm|mm|in|pt|pc|Q)$/,$o=["calc","min","max","clamp","mod","rem","sin","cos","tan","asin","acos","atan","atan2","pow","sqrt","hypot","log","exp","round"],Qu=new Set($o);function se(e){return Xu.test(e)||Zu.test(e)}function yo(e){if(!$o.some((o)=>e.includes(`${o}(`)))return e;let t="",r=[],n=null,i=null;for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);if(s>=48&&s<=57)n=o;else if(n!==null&&(s===37||s>=97&&s<=122||s>=65&&s<=90))n=o;else i=n,n=null;if(s===40){t+=e[o];let a=o;for(let u=o-1;u>=0;u--){let f=e.charCodeAt(u);if(f>=48&&f<=57||f>=97&&f<=122)a=u;else break}let l=e.slice(a,o);if(Qu.has(l))r.unshift(!0);else if(r[0]&&l==="")r.unshift(!0);else r.unshift(!1);continue}if(s===41){t+=e[o],r.shift();continue}if(s===44&&r[0]){t+=", ";continue}if(s===32&&r[0]&&t.charCodeAt(t.length-1)===32)continue;if((s===43||s===45||s===42||s===47)&&r[0]){let a=t.trimEnd(),l=a.charCodeAt(a.length-1),u=a.charCodeAt(a.length-2),f=e.charCodeAt(o+1),d=l===43||l===45||l===42||l===47,h=f===43||f===45||f===42||f===47;if((l===101||l===69)&&u>=48&&u<=57)t+=e[o];else if(d||l===40||l===44)t+=e[o];else if(e.charCodeAt(o-1)===32)t+=`${e[o]} `;else if(l>=48&&l<=57||f>=48&&f<=57||l===41||f===40||h||i!==null&&i===o-1)t+=` ${e[o]} `;else t+=e[o];continue}t+=e[o]}return t}function Kt(e){if(!e.includes("_"))return yo(e);let t="",r=0;while(r<e.length){let n=e[r];if(n==="\\"&&e[r+1]==="_"){t+="_",r+=2;continue}if(n==="u"&&e.slice(r,r+4)==="url("){let i=r,o=1;r+=4;while(r<e.length&&o>0){if(e[r]==="(")o++;else if(e[r]===")")o--;r++}t+=e.slice(i,r);continue}t+=n==="_"?" ":n,r++}return yo(t)}function bo(e,t){if(t.length!==2)return null;let[r,n]=t;if(r!=="min"&&r!=="max")return null;return[se(n)?`${r}-${e}-[${n}]`:`${r}-${e}-${n}`]}var ef={flex:{expand:(e,t)=>{let r=t[e]||e;if(["col","row","col-reverse","row-reverse","wrap","nowrap","wrap-reverse"].includes(r))return`flex-${r}`;let n=e.match(/^(jc|ji|js|ai|ac|as)-(.+)$/);if(n){let i=t[n[1]]||n[1],o=t[n[2]]||n[2];return`${i}-${o}`}if(/^\d+$/.test(r)||["grow","shrink","auto","initial","none"].includes(r))return`flex-${r}`;return null}},grid:{expand:(e,t)=>{let r=t[e]||e;if(e.startsWith("cols-")||e.startsWith("rows-"))return`grid-${e}`;if(e.startsWith("flow-"))return`grid-${e}`;if(e.startsWith("gap-"))return e;return null}},text:{expand:(e,t)=>{let r=t[e]||e;if(se(r))return`text-[${r}]`;if(/^\d{3}$/.test(r))return{"100":"font-thin","200":"font-extralight","300":"font-light","400":"font-normal","500":"font-medium","600":"font-semibold","700":"font-bold","800":"font-extrabold","900":"font-black"}[r]||`font-[${r}]`;if(/^[a-z-]+$/i.test(r)&&!["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl","9xl"].includes(r)){if(["white","black","inherit","current","transparent"].includes(r.toLowerCase()))return`text-${r}`;if(["red","blue","green","yellow","purple","pink","gray","slate","zinc","neutral","stone","orange","amber","lime","emerald","teal","cyan","sky","indigo","violet","fuchsia","rose"].includes(r.toLowerCase()))return`text-${r}-500`;return`font-[${r}]`}return`text-${r}`}},font:{expand:(e,t)=>{let r=t[e]||e,n=["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],i=["sans","serif","mono"];if(n.includes(r)||i.includes(r))return`font-${r}`;if(/^\d{3}$/.test(r))return{"100":"font-thin","200":"font-extralight","300":"font-light","400":"font-normal","500":"font-medium","600":"font-semibold","700":"font-bold","800":"font-extrabold","900":"font-black"}[r]||`font-[${r}]`;return`font-[${r}]`}},bg:{expand:(e,t)=>`bg-${t[e]||e}`},w:{expand:(e,t)=>{let r=t[e]||e;if(se(r))return`w-[${r}]`;return`w-${r}`},multiValue:(e)=>bo("w",e)},h:{expand:(e,t)=>{let r=t[e]||e;if(se(r))return`h-[${r}]`;return`h-${r}`},multiValue:(e)=>bo("h",e)},p:{expand:(e)=>`p-${e}`},px:{expand:(e)=>`px-${e}`},py:{expand:(e)=>`py-${e}`},pt:{expand:(e)=>`pt-${e}`},pr:{expand:(e)=>`pr-${e}`},pb:{expand:(e)=>`pb-${e}`},pl:{expand:(e)=>`pl-${e}`},m:{expand:(e)=>`m-${e}`},mx:{expand:(e)=>`mx-${e}`},my:{expand:(e)=>`my-${e}`},mt:{expand:(e)=>`mt-${e}`},mr:{expand:(e)=>`mr-${e}`},mb:{expand:(e)=>`mb-${e}`},ml:{expand:(e)=>`ml-${e}`},scroll:{expand:(e)=>{if(["x","y"].includes(e))return null;if(["auto","hidden","scroll","visible"].includes(e))return`overflow-${e}`;return null},multiValue:(e)=>{if(e.length===2){let[t,r]=e;if(["x","y"].includes(t)&&["auto","hidden","scroll","visible"].includes(r))return[`overflow-${t}-${r}`]}return null}},overflow:{expand:(e)=>`overflow-${e}`,multiValue:(e)=>{if(e.length===2){let[t,r]=e;if(["x","y"].includes(t))return[`overflow-${t}-${r}`]}return null}},border:{expand:(e)=>`border-${e}`},rounded:{expand:(e)=>`rounded-${e}`},shadow:{expand:(e)=>`shadow-${e}`},gap:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-"))return`gap-${e}`;return`gap-${e}`}},space:{expand:(e)=>`space-${e}`},opacity:{expand:(e)=>`opacity-${e}`},z:{expand:(e)=>`z-${e}`},inset:{expand:(e,t)=>{let r=t[e]||e;if(r.startsWith("x-")||r.startsWith("y-"))return`inset-${r}`;if(se(r))return`inset-[${r}]`;return`inset-${r}`}},top:{expand:(e)=>se(e)?`top-[${e}]`:`top-${e}`},right:{expand:(e)=>se(e)?`right-[${e}]`:`right-${e}`},bottom:{expand:(e)=>se(e)?`bottom-[${e}]`:`bottom-${e}`},left:{expand:(e)=>se(e)?`left-[${e}]`:`left-${e}`},duration:{expand:(e)=>`duration-${e}`},delay:{expand:(e)=>`delay-${e}`},ease:{expand:(e)=>`ease-${e}`},transition:{expand:(e)=>{if(["all","none","colors","opacity","shadow","transform"].includes(e))return`transition-${e}`;if(/^\d+$/.test(e))return`duration-${e}`;if(["linear","in","out","in-out","ease-linear","ease-in","ease-out","ease-in-out"].includes(e))return e.startsWith("ease-")?e:`ease-${e}`;return`transition-${e}`}},translate:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-")||e.startsWith("z-"))return`translate-${e}`;return`translate-${e}`}},rotate:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-")||e.startsWith("z-"))return`rotate-${e}`;return`rotate-${e}`}},scale:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-")||e.startsWith("z-"))return`scale-${e}`;return`scale-${e}`}},skew:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-"))return`skew-${e}`;return`skew-${e}`}},origin:{expand:(e)=>`origin-${e}`},cursor:{expand:(e)=>`cursor-${e}`},select:{expand:(e)=>`select-${e}`},resize:{expand:(e)=>`resize-${e}`},appearance:{expand:(e)=>`appearance-${e}`},pointer:{expand:(e)=>`pointer-events-${e}`},outline:{expand:(e)=>`outline-${e}`},ring:{expand:(e)=>`ring-${e}`},blur:{expand:(e)=>`blur-${e}`},brightness:{expand:(e)=>`brightness-${e}`},contrast:{expand:(e)=>`contrast-${e}`},grayscale:{expand:(e)=>`grayscale-${e}`},saturate:{expand:(e)=>`saturate-${e}`},sepia:{expand:(e)=>`sepia-${e}`},backdrop:{expand:(e)=>`backdrop-${e}`},aspect:{expand:(e)=>`aspect-${e}`},columns:{expand:(e)=>`columns-${e}`},break:{expand:(e)=>`break-${e}`},object:{expand:(e)=>`object-${e}`},overscroll:{expand:(e)=>`overscroll-${e}`},place:{expand:(e)=>`place-${e}`},items:{expand:(e)=>`items-${e}`},justify:{expand:(e)=>`justify-${e}`},content:{expand:(e)=>`content-${e}`},self:{expand:(e)=>`self-${e}`},order:{expand:(e)=>`order-${e}`},col:{expand:(e)=>`col-${e}`},row:{expand:(e)=>`row-${e}`},tracking:{expand:(e)=>`tracking-${e}`},leading:{expand:(e)=>`leading-${e}`},list:{expand:(e)=>`list-${e}`},decoration:{expand:(e)=>`decoration-${e}`},underline:{expand:(e)=>`underline-${e}`},accent:{expand:(e)=>`accent-${e}`},caret:{expand:(e)=>`caret-${e}`},"scroll-m":{expand:(e)=>`scroll-m-${e}`},"scroll-p":{expand:(e)=>`scroll-p-${e}`},snap:{expand:(e)=>`snap-${e}`},touch:{expand:(e)=>`touch-${e}`},will:{expand:(e)=>`will-change-${e}`},fill:{expand:(e)=>`fill-${e}`},stroke:{expand:(e)=>`stroke-${e}`},sr:{expand:(e)=>`sr-${e}`},invert:{expand:(e)=>`invert-${e}`},"hue-rotate":{expand:(e)=>se(e)?`hue-rotate-[${e}]`:`hue-rotate-${e}`},"drop-shadow":{expand:(e)=>`drop-shadow-${e}`},"backdrop-invert":{expand:(e)=>`backdrop-invert-${e}`},"backdrop-hue-rotate":{expand:(e)=>se(e)?`backdrop-hue-rotate-[${e}]`:`backdrop-hue-rotate-${e}`},animate:{expand:(e)=>`animate-${e}`},"forced-colors":{expand:(e)=>`forced-colors-${e}`}},Rt=new Set(["sm","md","lg","xl","2xl","hover","focus","active","visited","disabled","enabled","focus-within","focus-visible","group-hover","group-focus","peer-hover","peer-focus","*","**","dark","first","last","odd","even","only","first-of-type","last-of-type","only-of-type","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","user-valid","user-invalid","inert","empty","before","after","selection","marker","file","first-letter","first-line","backdrop","details-content","print","motion-safe","motion-reduce","pointer-none","pointer-coarse","pointer-fine","any-pointer-none","any-pointer-coarse","any-pointer-fine","inverted-colors","noscript","starting","contrast-more","contrast-less","rtl","ltr","portrait","landscape","@sm","@md","@lg","@xl","@2xl"]),xo=new WeakMap,vo=new WeakMap;function tf(e){if(!e)return xn;let t=xo.get(e);if(!t)t=e.aliases?{...xn,...e.aliases}:xn,xo.set(e,t);return t}function rf(e){if(!e?.aliases)return"";let t=vo.get(e);if(t===void 0)t=JSON.stringify(e.aliases),vo.set(e,t);return t}function kt(e){let t=[],r="",n=0;for(let i=0;i<e.length;i++){let o=e[i];if(o==="[")n++;else if(o==="]")n--;if(o===":"&&n===0)t.push(r),r="";else r+=o}return t.push(r),t}function nf(e,t){let r=`${e}:${t?.colonSyntax}:${rf(t)}`,n=_e.get(r);if(n)return n;let i=tf(t);if(t?.colonSyntax===!0){let g=e.match(/^([a-z][a-z0-9-]*):([^[\]:]+)$/i);if(g){let[,p,y]=g;if(!Rt.has(p)){if(se(y)){let w=[`${p}-[${y}]`];return Le(_e,r,w),w}let x=y.startsWith("-")?[`-${p}-${y.slice(1)}`]:[`${p}-${y}`];return Le(_e,r,x),x}}}let o="",s=e,c=!1;if(s.startsWith("-"))c=!0,s=s.slice(1);let a=s.match(/^((?:[a-z@][a-z0-9-]*:)+)(.+)$/i);if(a){if(a[1].slice(0,-1).split(":").every((y)=>Rt.has(y)))o=a[1],s=a[2]}let l=s.match(/^([a-z][a-z0-9-]*)\[([^\]]*)\]$/i);if(!l||s.includes("-[")){let g=[e];return Le(_e,r,g),g}let[,u,f]=l,d=f.split(/\s+/).filter(Boolean);if(d.length===0)return Le(_e,r,[]),[];let h=ef[u.toLowerCase()];if(h?.multiValue){let g=h.multiValue(d,i);if(g){let p=g.map((y)=>`${o}${c?"-":""}${y}`);return Le(_e,r,p),p}}if(!h){let g=[];for(let p of d){let y=p.match(/^([a-z@][a-z0-9-]*):(.+)$/i),x="",w=p;if(y&&Rt.has(y[1]))x=`${y[1]}:`,w=y[2];let T="";if(w.startsWith("-"))T="-",w=w.slice(1);let S="";if(w.endsWith("!"))S="!",w=w.slice(0,-1);let j=c?"-":"";if(se(w))g.push(`${o}${x}${S}${j}${T}${u}-[${w}]`);else g.push(`${o}${x}${S}${j}${T}${u}-${w}`)}return Le(_e,r,g),g}let m=[];for(let g of d){let p=g.match(/^([a-z@][a-z0-9-]*):(.+)$/i),y="",x=g;if(p&&Rt.has(p[1]))y=`${p[1]}:`,x=p[2];let w="";if(x.startsWith("-"))w="-",x=x.slice(1);let T="";if(x.endsWith("!"))T="!",x=x.slice(0,-1);let S=h.expand(x,i);if(S){let j=c?"-":"";m.push(`${o}${y}${T}${j}${w}${S}`)}}return Le(_e,r,m),m}function of(e,t){let r=new Set;if(!t?.enabled)return r;let n=t.prefix??"tc-",i=["class","className","style","id","name","type","value","href","src","alt","title","role","for","action","method","target","rel","placeholder","disabled","checked","selected","readonly","required","maxlength","minlength","pattern","autocomplete","autofocus","tabindex","contenteditable","draggable","spellcheck","lang","dir","hidden","slot","part","is","key","ref"],o=t.ignoreAttributes||i,s=(l)=>{let u=l.includes(":")?l.split(":").pop():l;for(let f of o)if(f.endsWith("*")){if(u.startsWith(f.slice(0,-1)))return!0}else if(u===f)return!0;if(u.startsWith("on"))return!0;if(u.startsWith("data-")||u.startsWith("aria-"))return!0;return!1},c=/<([a-z][a-z0-9-]*)\s([^>]*)>/gi,a;while((a=c.exec(e))!==null){let l=a[2],u=/([a-z][a-z0-9-:]*)(?:=["']([^"']*)["'])?(?=\s|$|\/?>)/gi,f;while((f=u.exec(l))!==null){let d=f[1],h=f[2];if(n){if(!d.startsWith(n))continue;d=d.slice(n.length)}if(s(d))continue;let m="",g=d,p=d.match(/^((?:[a-z@][a-z0-9-]*:)+)([a-z][a-z0-9-]*)$/i);if(p){if(p[1].slice(0,-1).split(":").every((w)=>Rt.has(w)))m=p[1],g=p[2]}if(h!==void 0){let y=h.split(/\s+/).filter(Boolean);for(let x of y){let w=`${m}${g}-${x}`;if(wo(w.replace(/^(?:[a-z@][a-z0-9-]*:)+/gi,"")))r.add(w)}}else{let y=`${m}${g}`;if(wo(g))r.add(y)}}}return r}function wo(e){if(!e||e.length===0)return!1;return/^[a-z][a-z0-9-/]*(?:-\[[^\]]+\])?$/i.test(e)}function vn(e){let t=po.get(e);if(t)return t;let r=uf(e);return r.base=cf(r),Le(po,e,r),r}var sf=new Set(["bg","text","border","ring","placeholder","divide","accent","caret","fill","stroke","outline","decoration","shadow","ring-offset","from","via","to"]),af=/^(.+?)\/(\d+|\[\d*\.?\d+\])$/,lf=/^(\d+)\/(\d+)$/;function Co(e){let t=!1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===45){if(!t||r+1>=e.length)return;return[e.slice(0,r),e.slice(r+1)]}if(n>=97&&n<=122){t=!0;continue}return}return}function cf(e){let t=e.raw;for(let r of e.variants)if(t.startsWith(`${r}:`))t=t.slice(r.length+1);if(e.important){if(t.charCodeAt(0)===33)t=t.slice(1);else if(t.charCodeAt(t.length-1)===33)t=t.slice(0,-1)}return t}function uf(e){let t=!1,r=e;if(e.startsWith("!"))t=!0,r=e.slice(1);else if(e.endsWith("!")&&e.length>1)t=!0,r=e.slice(0,-1);{let h=kt(r),m=h[h.length-1],g=!1;if(m.charCodeAt(0)===33&&m.length>1)g=!0,m=m.slice(1);let p=m.match(/^\[([a-z-]+):(.+)\]$/);if(p)return{raw:e,variants:h.slice(0,-1),utility:p[1],value:Kt(p[2]),important:t||g,arbitrary:!0}}let n=r.match(/^((?:[a-z-]+:)*)(-?[a-z-]+?)-\[([^\]]+)\]\/\[([^\]]+)\]$/);if(n){let[,h,m,g,p]=n,y=h?h.split(":").filter(Boolean):[],x=m.startsWith("-"),w=x?m.slice(1):m,T=Kt(g);if(x)T=T.startsWith("-")?T:`-${T}`;return{raw:e,variants:y,utility:w,value:`${T}/${p}`,important:t,arbitrary:!0,modifierArbitrary:!0}}let i=r.match(/^((?:[a-z-]+:)*)(-?[a-z-]+?)-\[(.+)\]$/);if(i){let h=i[1],m=h?h.split(":").filter(Boolean):[],g=i[2],p=g.startsWith("-");if(p)g=g.slice(1);let y=Kt(i[3]),x,w=y.match(/^(color|length|url|number|percentage|position|line-width|absolute-size|relative-size|image|angle|time|flex|string|family-name):(.*)/i);if(w)x=w[1].toLowerCase(),y=w[2];if(p)y=y.startsWith("-")?y:`-${y}`;return{raw:e,variants:m,utility:g,value:y,important:t,arbitrary:!0,typeHint:x}}let o=kt(r),s=o[o.length-1],c=o.slice(0,-1);if(s.startsWith("!")&&s.length>1)t=!0,s=s.slice(1);else if(s.endsWith("!")&&s.length>1)t=!0,s=s.slice(0,-1);if(c.length>0)r=`${c.join(":")}:${s}`;else r=s;if(["inline-block","inline-flex","inline-grid","flex-row","flex-row-reverse","flex-col","flex-col-reverse","flex-wrap","flex-wrap-reverse","flex-nowrap","flex-1","flex-auto","flex-initial","flex-none","flex-grow","flex-shrink"].includes(s))return{raw:e,variants:c,utility:s,value:void 0,important:t,arbitrary:!1};let l=s.match(/^([a-z-]+?)-\[(.+?)\]$/);if(l){let h=Kt(l[2]),m,g=h.match(/^(color|length|url|number|percentage|position|line-width|absolute-size|relative-size|image|angle|time|flex|string|family-name):(.*)/i);if(g)m=g[1].toLowerCase(),h=g[2];return{raw:e,variants:c,utility:l[1],value:h,important:t,arbitrary:!0,typeHint:m}}let u=["inset-x","inset-y","border-t","border-r","border-b","border-l","border-x","border-y","border-s","border-e","grid-cols","grid-rows","grid-flow","auto-cols","auto-rows","col-span","row-span","col-start","col-end","row-start","row-end","translate-x","translate-y","translate-z","scale-x","scale-y","scale-z","rotate-x","rotate-y","rotate-z","skew-x","skew-y","scroll-m","scroll-mx","scroll-my","scroll-mt","scroll-mr","scroll-mb","scroll-ml","scroll-p","scroll-px","scroll-py","scroll-pt","scroll-pr","scroll-pb","scroll-pl","gap-x","gap-y","overflow-x","overflow-y","min-w","max-w","min-h","max-h","space-x","space-y","ring-offset","underline-offset","outline-offset","backdrop-blur","backdrop-brightness","backdrop-contrast","backdrop-grayscale","backdrop-invert","backdrop-saturate","backdrop-sepia","hue-rotate","drop-shadow","mask-clip","flex-grow","flex-shrink","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","perspective-origin","justify-self","form-input","form-textarea","form-select","form-multiselect","form-checkbox","form-radio","mix-blend","bg-blend","line-clamp","border-spacing","border-spacing-x","border-spacing-y","rounded-s","rounded-e","rounded-ss","rounded-se","rounded-es","rounded-ee","rounded-t","rounded-r","rounded-b","rounded-l","rounded-tl","rounded-tr","rounded-bl","rounded-br","border-opacity","ring-opacity","stroke-dasharray","stroke-dashoffset","animate-iteration","animate-duration","animate-delay","text-emphasis-color","text-emphasis","text-shadow","word-spacing","column-gap","column-rule","font-stretch","list-image"];if(s==="divide-x"||s==="divide-y")return{raw:e,variants:c,utility:s,value:void 0,important:t,arbitrary:!1};let f=s.match(/^(divide-[xy])-(.+)$/);if(f)return{raw:e,variants:c,utility:f[1],value:f[2],important:t,arbitrary:!1};for(let h of u)if(s.startsWith(`${h}-`))return{raw:e,variants:c,utility:h,value:s.slice(h.length+1),important:t,arbitrary:!1};if(s.startsWith("-")){let h=s.slice(1);for(let g of u)if(h.startsWith(`${g}-`))return{raw:e,variants:c,utility:g,value:`-${h.slice(g.length+1)}`,important:t,arbitrary:!1};let m=Co(h);if(m)return{raw:e,variants:c,utility:m[0],value:`-${m[1]}`,important:t,arbitrary:!1};return{raw:e,variants:c,utility:h,value:void 0,important:t,arbitrary:!1}}let d=Co(s);if(d){let[h,m]=d,g=m.match(af);if(g&&sf.has(h))return{raw:e,variants:c,utility:h,value:`${g[1]}/${g[2]}`,important:t,arbitrary:!1};let p=m.match(lf);if(p)return{raw:e,variants:c,utility:h,value:`${p[1]}/${p[2]}`,important:t,arbitrary:!1};return{raw:e,variants:c,utility:h,value:m,important:t,arbitrary:!1}}return{raw:e,variants:c,utility:s,value:void 0,important:t,arbitrary:!1}}function ff(e){return/^\[[a-z-]+:[^\]]+\]$/i.test(e)}function df(e){if(!e)return!1;if(e==="*"||e==="**")return!0;if(e.startsWith("[")&&e.endsWith("]"))return e.length>2;return/^(?:@[a-z0-9]|[a-z])[a-z0-9.-]*(?:\[[^\]]+\])?(?:\/[\w-]+)?$/i.test(e)}function hf(e,t){let r=e;if(r.startsWith("!"))r=r.slice(1);if(r.endsWith("!"))r=r.slice(0,-1);if(!r)return!1;if(ff(r))return!0;if(t?.enabled&&/^[a-z]+\[[^\]]+\]$/i.test(r))return!0;return/^[-@]?[a-z][a-z0-9.-]*(?:-\[[^\]]+\])?(?:\/(?:[\w.]+|[\w-]+|\[[^\]]+\]))?$/i.test(r)}function Ro(e,t){if(!e||e.length===0)return!1;if(t?.colonSyntax&&/^[a-z]+:[^[\]:]+$/i.test(e))return!0;let r=e;if(r.startsWith("!"))r=r.slice(1);if(r.endsWith("!"))r=r.slice(0,-1);if(!r)return!1;let n=kt(r);for(let i=0;i<n.length-1;i++)if(!df(n[i]))return!1;return hf(n[n.length-1],t)}function Gt(e){let t=[],r="",n=0;for(let i of e)if(i==="[")n++,r+=i;else if(i==="]")n--,r+=i;else if(/\s/.test(i)&&n===0){if(r)t.push(r),r=""}else r+=i;if(r)t.push(r);return t}function qt(e,t){let r=new Set,n=[/class(?:Name)?=["']([^"']+)["']/g,/class(?:Name)?=\{["']([^"']+)["']\}/g,/class(?:Name)?=\{`([^`]+)`\}/g];for(let o of n){let s;while((s=o.exec(e))!==null){let c=s[1],a=c.match(/["']([^"']+)["']/g);if(a)for(let f of a){let d=f.replace(/["']/g,""),h=Gt(d);for(let m of h)Ht(r,m,t)}let l=c.replace(/["'`]/g," ").replace(/\$\{[^}]+\}/g," "),u=Gt(l).filter((f)=>Ro(f,t?.bracketSyntax));for(let f of u)Ht(r,f,t)}}let i=[/class(?:Name|:list)?=\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,/:class="([^"]*)"/g,/:class='([^']*)'/g,/\bx-class="([^"]*)"/g,/\bx-class='([^']*)'/g];for(let o of i){let s;while((s=o.exec(e))!==null){let c=s[1].match(/["'`]([^"'`]+)["'`]/g);if(c)for(let a of c){let l=a.replace(/["'`]/g,"").replace(/\$\{[^}]+\}/g," ");for(let u of Gt(l))Ht(r,u,t)}}}if(t?.codeStrings?.enabled!==!1)for(let o of ko(e,t?.bracketSyntax))Ht(r,o,t);if(t?.attributify?.enabled){let o=of(e,t.attributify);for(let s of o)r.add(s)}return r}function gf(e,t){if(!/[-:/[]/.test(e))return!1;if(e.startsWith("-")&&!/^-[a-z]/i.test(e))return!1;return Ro(e,t)}function ko(e,t){let r=new Set,n=e.length,i=0,o="";while(i<n){let s=e[i];if(s==="/"&&e[i+1]==="/"){let d=e.indexOf(`
92
- `,i);i=d===-1?n:d;continue}if(s==="/"&&e[i+1]==="*"){let d=e.indexOf("*/",i+2);i=d===-1?n:d+2;continue}if(s==="/"&&(!/[\w$)\]]/.test(o)||pf(e,i))){let d=yf(e,i);if(d!==-1){i=d,o=")";continue}}if(s!=='"'&&s!=="'"&&s!=="`"){if(!/\s/.test(s))o=s;i++;continue}o=")";let c=xf(e,i),a=s==="`",l=i+1,u="",f=!1;while(l<n){let d=e[l];if(d==="\\"){u+=e[l+1]??"",l+=2;continue}if(d===s){f=!0,l++;break}if(!a&&d===`
93
- `)break;if(a&&d==="$"&&e[l+1]==="{"){let h=1;l+=2;let m=l;while(l<n&&h>0){if(e[l]==="{")h++;else if(e[l]==="}")h--;l++}for(let g of ko(e.slice(m,l-1),t))r.add(g);u+=" ";continue}u+=d,l++}if(f){if(c){for(let d of u.match(bf)??[])r.add(d);i=l;continue}for(let d of Gt(u))if(gf(d,t))r.add(d);i=l}else i++}return r}var mf=new Set(["return","typeof","case","in","of","delete","void","throw","new","else","do","yield","await","instanceof"]);function pf(e,t){let r=t;while(r>0&&/\s/.test(e[r-1]))r--;let n=r;while(n>0&&/[\w$]/.test(e[n-1]))n--;if(n===r||!mf.has(e.slice(n,r)))return!1;let i=n;while(i>0&&/\s/.test(e[i-1]))i--;return e[i-1]!=="."}function yf(e,t){let r=!1;for(let n=t+1;n<e.length;n++){let i=e[n];if(i===`
94
- `)return-1;if(i==="\\"){n++;continue}if(i==="[")r=!0;else if(i==="]")r=!1;else if(i==="/"&&!r){let o=n+1;while(o<e.length&&/[a-z]/i.test(e[o]))o++;return o}}return-1}var bf=/(?<![\w-])i-[a-z0-9]+(?:-[a-z0-9]+)+(?![\w-])/gi;function xf(e,t){let r=e.lastIndexOf("<",t),n=e.lastIndexOf(">",t);if(r<=n)return!1;let i=e[r+1];if(!i||!/[A-Za-z!/]/.test(i))return!1;let o=t-1;while(o>r&&/\s/.test(e[o]))o--;if(e[o]==="=")return!0;if(e[o]==="{"){o--;while(o>r&&/\s/.test(e[o]))o--;return e[o]==="="}return!1}function Ht(e,t,r){if(r?.bracketSyntax?.enabled){let n=/^[a-z]+\[[^\]]+\]$/i.test(t),i=r.bracketSyntax.colonSyntax&&/^[a-z]+:[^[\]]+$/i.test(t);if(n||i){let o=nf(t,r.bracketSyntax);for(let s of o)e.add(s);return}}e.add(t)}var Yt={getCSS:()=>`
91
+ `),Ie.exit(e.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:r}=this;if(!r||!r.commandAction)return;r.checkUnknownOptions(),r.checkOptionValue(),r.checkRequiredArgs();let n=[];r.args.forEach((c,a)=>{if(c.variadic)n.push(e.slice(a));else n.push(e[a])}),n.push(t);let i={command:r,args:n,options:t};for(let c of r.beforeHooks)await c(i);let o,s=async()=>{let c=r.commandAction.apply(this,n);if(c instanceof Promise)o=await c;else o=c;return o};if(r.middleware.length>0){let c=0,a=async()=>{if(c<r.middleware.length){let l=r.middleware[c++];await l({...i,next:a})}else await s()};await a()}else await s();for(let c of r.afterHooks)await c(i);return o}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return Ie.removeAllListeners("SIGINT"),Ie.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class Ui{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,r=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:r})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,r]of this.cache.entries())if(e-r.timestamp>r.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var vx=new Ui;function Pc(){if("FORCE_COLOR"in vt.env)return vt.env.FORCE_COLOR!=="0";if("NO_COLOR"in vt.env||vt.env.TERM==="dumb")return!1;if(vt.platform==="win32")return!0;return Di.isatty(1)&&Di.isatty(2)}var Wi=Pc();function M(e,t){if(!Wi)return(r)=>r;return(r)=>e+r+t}var _c=M("\x1B[0m","\x1B[0m"),Lc=M("\x1B[31m","\x1B[39m"),Mc=M("\x1B[32m","\x1B[39m"),Fc=M("\x1B[33m","\x1B[39m"),Dc=M("\x1B[34m","\x1B[39m"),jc=M("\x1B[35m","\x1B[39m"),Bc=M("\x1B[36m","\x1B[39m"),Vc=M("\x1B[37m","\x1B[39m"),Uc=M("\x1B[90m","\x1B[39m"),Wc=M("\x1B[1m","\x1B[22m"),zc=M("\x1B[3m","\x1B[23m"),Kc=M("\x1B[4m","\x1B[24m"),Hc=M("\x1B[2m","\x1B[22m"),Gc=M("\x1B[7m","\x1B[27m"),qc=M("\x1B[8m","\x1B[28m"),Yc=M("\x1B[9m","\x1B[29m"),Jc=M("\x1B[41m","\x1B[49m"),Xc=M("\x1B[42m","\x1B[49m"),Zc=M("\x1B[43m","\x1B[49m"),Qc=M("\x1B[44m","\x1B[49m"),eu=M("\x1B[45m","\x1B[49m"),tu=M("\x1B[46m","\x1B[49m"),ru=M("\x1B[47m","\x1B[49m"),nu=Wi,iu={reset:_c,red:Lc,green:Mc,yellow:Fc,blue:Dc,magenta:jc,cyan:Bc,white:Vc,gray:Uc,bold:Wc,italic:zc,underline:Kc,dim:Hc,inverse:Gc,hidden:qc,strikethrough:Yc,bgRed:Jc,bgGreen:Xc,bgYellow:Zc,bgBlue:Qc,bgMagenta:eu,bgCyan:tu,bgWhite:ru,isColorSupported:nu},ou=iu,au=["up","down","left","right","space","enter","cancel"],Sx={actions:new Set(au),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var Ax=su.platform.startsWith("win"),Ex=Symbol("clapp:cancel");var lu=kc();var _=(e,t)=>lu?e:t,Tx=_("\u25C6","*"),Nx=_("\u25A0","x"),Ox=_("\u25B2","x"),Ix=_("\u25C7","o"),Px=_("\u250C","T"),cu=_("\u2502","|"),_x=_("\u2514","\u2014"),Lx=_("\u25CF",">"),Mx=_("\u25CB"," "),Fx=_("\u25FB","[\u2022]"),Dx=_("\u25FC","[+]"),jx=_("\u25FB","[ ]"),Bx=_("\u25AA","\u2022"),Vx=_("\u2500","-"),Ux=_("\u256E","+"),Wx=_("\u251C","+"),zx=_("\u256F","+"),Kx=_("\u25CF","\u2022"),Hx=_("\u25C6","*"),Gx=_("\u25B2","!"),qx=_("\u25A0","x");var Yx={light:_("\u2500","-"),heavy:_("\u2501","="),block:_("\u2588","#")};function uu(){return`${ou.gray(cu)} `}var Jx=uu();class zi{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=ji.homedir(),t=Jr.join(e,".config","clapp");this.configPath=Jr.join(t,"telemetry.json")}async isEnabled(){if(Ve.env.DO_NOT_TRACK==="1"||Ve.env.DO_NOT_TRACK==="true")return!1;if(Ve.env.NO_TELEMETRY==="1"||Ve.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let e=await this.loadConfig();if(e.enabled=!0,!e.userId)e.userId=this.generateUserId();await this.saveConfig(e)}async disable(){let e=await this.loadConfig();e.enabled=!1,await this.saveConfig(e)}async track(e,t){if(!await this.isEnabled())return;let n={event:e,...t,timestamp:Date.now(),platform:ji.platform(),nodeVersion:Ve.version};if(this.events.push(n),this.events.length>=10)await this.send()}async trackCommand(e,t){await this.track("command",{command:e,duration:t})}async trackError(e,t){await this.track("error",{error:e,command:t})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let t=await this.loadConfig();return t.lastSent=Date.now(),await this.saveConfig(t),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let t=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(t),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(e){return new Promise((t)=>setTimeout(t,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:Ve.env.DO_NOT_TRACK==="1"||Ve.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(fu(this.configPath)){let e=await Yr.readFile(this.configPath,"utf-8");return this.config=JSON.parse(e),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(e){this.config=e;try{let t=Jr.dirname(this.configPath);await Yr.mkdir(t,{recursive:!0}),await Yr.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),t=Date.now().toString(36);return`${e}-${t}`}}var rv=new zi;var rn="0.3.22";function be(e){return{prev:null,next:null,data:e}}class le{head=null;tail=null;cursors=[];allocateCursor(e,t){let r={prev:e,next:t};return this.cursors.push(r),r}releaseCursor(){this.cursors.pop()}updateCursors(e,t,r,n){for(let i of this.cursors){if(i.prev===e)i.prev=t;if(i.next===r)i.next=n}}static createItem(e){return be(e)}createItem(e){return be(e)}get isEmpty(){return this.head===null}get first(){return this.head?.data??null}get last(){return this.tail?.data??null}*[Symbol.iterator](){for(let e=this.head;e!=null;e=e.next)yield e.data}fromArray(e){let t=null;this.head=null;for(let r of e){let n=be(r);if(n.prev=t,t)t.next=n;else this.head=n;t=n}return this.tail=t,this}toArray(){let e=[];for(let t=this.head;t!=null;t=t.next)e.push(t.data);return e}toJSON(){return this.toArray()}forEach(e,t){let r=this.allocateCursor(null,this.head);while(r.next!==null){let n=r.next;r.prev=n,r.next=n.next,e.call(t,n.data,n,this)}this.releaseCursor()}forEachRight(e,t){let r=this.allocateCursor(this.tail,null);while(r.prev!==null){let n=r.prev;r.next=n,r.prev=n.prev,e.call(t,n.data,n,this)}this.releaseCursor()}reduce(e,t){let r=t,n=0;for(let i=this.head;i!=null;i=i.next)r=e(r,i.data,n++,this);return r}some(e){let t=0;for(let r=this.head;r!=null;r=r.next)if(e(r.data,t++,this))return!0;return!1}map(e){let t=new le,r=null,n=0;for(let i=this.head;i!=null;i=i.next){let o=be(e(i.data,n++,this));if(o.prev=r,r)r.next=o;else t.head=o;r=o}return t.tail=r,t}filter(e){let t=new le,r=null,n=0;for(let i=this.head;i!=null;i=i.next)if(e(i.data,n++,this)){let o=be(i.data);if(o.prev=r,r)r.next=o;else t.head=o;r=o}return t.tail=r,t}clear(){let e=this.head;while(e){let t=e.next;e.prev=null,e.next=null,e=t}this.head=null,this.tail=null}copy(){let e=new le,t=null;for(let r=this.head;r!=null;r=r.next){let n=be(r.data);if(n.prev=t,t)t.next=n;else e.head=n;t=n}return e.tail=t,e}prepend(e){return this.insert(e,this.head)}prependData(e){return this.insert(be(e),this.head)}append(e){return this.insert(e,null)}appendData(e){return this.insert(be(e),null)}insert(e,t=null){if(t!=null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e,null,null)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else if(this.updateCursors(this.tail,e,null,e),this.tail!==null)this.tail.next=e,e.prev=this.tail,this.tail=e;else this.head=e,this.tail=e;return this}insertData(e,t=null){return this.insert(be(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else if(this.head===e)this.head=e.next;else throw Error("item doesn't belong to list");if(e.next!==null)e.next.prev=e.prev;else if(this.tail===e)this.tail=e.prev;else throw Error("item doesn't belong to list");return e.prev=null,e.next=null,e}push(e){this.insert(be(e),null)}pop(){if(this.tail===null)return null;return this.remove(this.tail)}unshift(e){this.prependData(e)}shift(){if(this.head===null)return null;return this.remove(this.head)}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e,null)}insertList(e,t=null){if(e.head===null)return this;if(t!==null){if(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null)t.prev.next=e.head,e.head.prev=t.prev;else this.head=e.head;t.prev=e.tail,e.tail.next=t}else{if(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null)this.tail.next=e.head,e.head.prev=this.tail;else this.head=e.head;this.tail=e.tail}return e.head=null,e.tail=null,this}replace(e,t){if(t instanceof le)this.insertList(t,e),this.remove(e);else this.insert(t,e),this.remove(e)}}function Q(e){switch(e.type){case"StyleSheet":return oe(e.children,"");case"Rule":return`${Q(e.prelude)}{${Q(e.block)}}`;case"Block":return hu(e.children);case"Atrule":{let t=`@${e.name}`;if(e.prelude){let r=Q(e.prelude);if(r)t+=` ${r}`}if(e.block)t+=`{${Q(e.block)}}`;else t+=";";return t}case"AtrulePrelude":return oe(e.children,"");case"SelectorList":return oe(e.children,",");case"Selector":return oe(e.children,"");case"TypeSelector":return e.name;case"IdSelector":return`#${e.name}`;case"ClassSelector":return`.${e.name}`;case"NestingSelector":return"&";case"AttributeSelector":{let t=`[${e.name.name}`;if(e.matcher&&e.value)if(t+=e.matcher,e.value.type==="String")t+=`"${nn(e.value.value)}"`;else t+=e.value.name;if(e.flags)t+=` ${e.flags}`;return t+="]",t}case"PseudoClassSelector":return e.children?`:${e.name}(${oe(e.children,"")})`:`:${e.name}`;case"PseudoElementSelector":return e.children?`::${e.name}(${oe(e.children,"")})`:`::${e.name}`;case"Combinator":return e.name===" "?" ":e.name;case"Declaration":return`${e.property}:${Q(e.value)}${e.important?"!important":""}`;case"DeclarationList":return oe(e.children,";");case"Value":return oe(e.children,"");case"Identifier":return e.name;case"Number":return e.value;case"Percentage":return`${e.value}%`;case"Dimension":return e.value+e.unit;case"String":return`"${nn(e.value)}"`;case"Url":return/[\s"'()\\\u0000-\u001F\u007F]/.test(e.value)?`url("${nn(e.value)}")`:`url(${e.value})`;case"Hash":return`#${e.name}`;case"Operator":return e.value;case"Function":return`${e.name}(${oe(e.children,"")})`;case"Parentheses":return`(${oe(e.children,"")})`;case"Brackets":return`[${oe(e.children,"")}]`;case"Raw":return e.value;case"Comment":return e.value.startsWith("!")?`/*${e.value}*/`:"";case"WhiteSpace":return" ";case"CDO":return"<!--";case"CDC":return"-->";case"AnPlusB":{let t=e.a??"",r=e.b??"";if(t&&r){let n=Number(r);return`${t==="1"?"":t==="-1"?"-":t}n${n>=0?`+${r}`:r}`}if(t)return`${t==="1"?"":t==="-1"?"-":t}n`;return r}case"Ratio":return`${e.left.value}/${e.right.value}`;case"UnicodeRange":return e.value;case"Nth":return e.selector?`${Q(e.nth)} of ${Q(e.selector)}`:Q(e.nth);case"MediaQueryList":return oe(e.children,",");case"MediaQuery":return oe(e.children,"");case"MediaFeature":{let t=`(${e.name}`;if(e.value)t+=`:${Q(e.value)}`;return t+=")",t}}return""}function oe(e,t){let r="",n=!0,i=null,o=e.head;while(o!=null){let s=o.data;if(s.type==="WhiteSpace"){let a=o.next?o.next.data:null;if(Ki(i)||Ki(a)){o=o.next;continue}}let c=Q(s);if(!c){o=o.next;continue}if(!n&&t&&!mu(i))r+=t;n=!1,r+=c,i=s,o=o.next}return r}function hu(e){let t="",r=null,n=e.head;while(n!=null){let i=n.data,o=Q(i);if(!o){n=n.next;continue}if(r&&gu(r,i))t+=";";t+=o,r=i,n=n.next}return t}function gu(e,t){return e.type==="Declaration"&&t.type!=="Comment"}function Ki(e){if(!e||e.type!=="Operator")return!1;let t=e.value;return t===":"||t===","||t==="/"}function mu(e){if(!e)return!1;return e.type==="Operator"||e.type==="Combinator"}function nn(e){let t="";for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===92)t+="\\\\";else if(n===34)t+="\\\"";else if(n<32||n===127){let i=n.toString(16),o=r+1<e.length?e.charCodeAt(r+1):-1,s=o===32||o===9||o===10||o===12||o===13||o>=48&&o<=57||o>=65&&o<=70||o>=97&&o<=102;t+=`\\${i}${s?" ":""}`}else t+=e[r]}return t}var We=(()=>{let e=new Uint8Array(128);for(let t=0;t<128;t++){let r=0;if(t===32||t===9||t===10||t===12||t===13)r|=1;if(t>=48&&t<=57)r|=2;if(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102)r|=4;if(t>=65&&t<=90||t>=97&&t<=122||t===95)r|=8;if(t===10||t===12||t===13)r|=16;e[t]=r}return e})();function fe(e){return e<128&&(We[e]&2)!==0}function $t(e){return e<128&&(We[e]&4)!==0}function Hi(e){return e>=128||e<128&&(We[e]&8)!==0}function pu(e){return e===45||e>=128||e<128&&(We[e]&10)!==0}function yu(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function sn(e){return e<128&&(We[e]&16)!==0}function Re(e){return e<128&&(We[e]&1)!==0}function Ue(e,t){if(e!==92)return!1;if(sn(t))return!1;return!0}function on(e,t,r){if(e===45)return Hi(t)||t===45||Ue(t,r);if(Hi(e))return!0;if(e===92)return Ue(e,t);return!1}function bu(e,t,r){if(e===43||e===45){if(fe(t))return!0;if(t===46&&fe(r))return!0;return!1}if(e===46)return fe(t);return fe(e)}class Dt{source;offset=0;types;starts;ends;count=0;_tokens=null;_lineStarts=null;constructor(e){this.source=e;let t=Math.max(64,Math.ceil(e.length/3));this.types=new Uint8Array(t),this.starts=new Uint32Array(t),this.ends=new Uint32Array(t),this.tokenize()}get lineStarts(){if(this._lineStarts==null)this._lineStarts=xu(this.source);return this._lineStarts}get tokens(){if(this._tokens!=null)return this._tokens;let e=Array.from({length:this.count});for(let t=0;t<this.count;t++)e[t]={type:this.types[t],start:this.starts[t],end:this.ends[t]};return this._tokens=e,e}addToken(e,t,r){if(this.count>=this.types.length)this.grow();this.types[this.count]=e,this.starts[this.count]=t,this.ends[this.count]=r,this.count++}grow(){let t=this.types.length*2,r=new Uint8Array(t);r.set(this.types),this.types=r;let n=new Uint32Array(t);n.set(this.starts),this.starts=n;let i=new Uint32Array(t);i.set(this.ends),this.ends=i}tokenize(){let e=this.source,t=0,r=e.length;while(t<r){let n=e.charCodeAt(t);if(n===47&&e.charCodeAt(t+1)===42){let s=t;t+=2;while(t<r&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t=t<r?t+2:r,this.addToken(25,s,t);continue}if(Re(n)){let s=t;while(t<r&&Re(e.charCodeAt(t)))t++;this.addToken(13,s,t);continue}if(n===34||n===39){t=this.consumeString(n,t);continue}if(n===35){if(t+1<r&&(pu(e.charCodeAt(t+1))||Ue(e.charCodeAt(t+1),e.charCodeAt(t+2)))){let s=t;t++,t=this.consumeName(t),this.addToken(4,s,t);continue}this.addToken(9,t,t+1),t++;continue}switch(n){case 40:this.addToken(21,t,t+1),t++;continue;case 41:this.addToken(22,t,t+1),t++;continue;case 91:this.addToken(19,t,t+1),t++;continue;case 93:this.addToken(20,t,t+1),t++;continue;case 123:this.addToken(23,t,t+1),t++;continue;case 125:this.addToken(24,t,t+1),t++;continue;case 44:this.addToken(18,t,t+1),t++;continue;case 58:this.addToken(16,t,t+1),t++;continue;case 59:this.addToken(17,t,t+1),t++;continue}if(n===60&&e.startsWith("!--",t+1)){this.addToken(14,t,t+4),t+=4;continue}if(n===45&&e.startsWith("->",t+1)){this.addToken(15,t,t+3),t+=3;continue}if(n===64){let s=e.charCodeAt(t+1),c=e.charCodeAt(t+2),a=e.charCodeAt(t+3);if(on(s,c,a)){let l=t;t++,t=this.consumeName(t),this.addToken(3,l,t);continue}this.addToken(9,t,t+1),t++;continue}let i=e.charCodeAt(t+1),o=e.charCodeAt(t+2);if(bu(n,i,o)){t=this.consumeNumeric(t);continue}if(on(n,i,o)){t=this.consumeIdentLike(t);continue}if(n===92){if(Ue(n,i)){t=this.consumeIdentLike(t);continue}this.addToken(9,t,t+1),t++;continue}this.addToken(9,t,t+1),t++}this.addToken(0,r,r)}consumeString(e,t){let r=this.source,n=r.length,i=t+1;while(i<n){let o=r.charCodeAt(i);if(o===e)return i++,this.addToken(5,t,i),i;if(sn(o))return this.addToken(6,t,i),i;if(o===92){let s=r.charCodeAt(i+1);if(sn(s)){i+=2;continue}if(i+1<n){i=this.consumeEscapeSkip(i+1);continue}}i++}return this.addToken(5,t,i),i}consumeEscapeSkip(e){let t=this.source;if(e>=t.length)return e;let r=t.charCodeAt(e);if($t(r)){let n=1;e++;while(n<6&&e<t.length&&$t(t.charCodeAt(e)))e++,n++;if(e<t.length&&Re(t.charCodeAt(e)))e++;return e}return e+1}consumeName(e){let t=this.source,r=t.length,n=e;while(n<r){let i=t.charCodeAt(n);if(i<128&&(We[i]&10)!==0){n++;continue}if(i===45){n++;continue}if(i>=128){n++;continue}if(i===92&&Ue(i,t.charCodeAt(n+1))){n=this.consumeEscapeSkip(n+1);continue}break}return n}consumeNumber(e){let t=this.source,r=e;if(t.charCodeAt(r)===43||t.charCodeAt(r)===45)r++;while(r<t.length&&fe(t.charCodeAt(r)))r++;if(t.charCodeAt(r)===46&&fe(t.charCodeAt(r+1))){r+=2;while(r<t.length&&fe(t.charCodeAt(r)))r++}let n=t.charCodeAt(r);if(n===69||n===101){let i=t.charCodeAt(r+1),o=t.charCodeAt(r+2);if(fe(i)){r+=2;while(r<t.length&&fe(t.charCodeAt(r)))r++}else if((i===43||i===45)&&fe(o)){r+=3;while(r<t.length&&fe(t.charCodeAt(r)))r++}}return r}consumeNumeric(e){let t=this.source,r=this.consumeNumber(e),n=t.charCodeAt(r),i=t.charCodeAt(r+1),o=t.charCodeAt(r+2);if(on(n,i,o)){let s=this.consumeName(r);return this.addToken(12,e,s),s}if(n===37)return this.addToken(11,e,r+1),r+1;return this.addToken(10,e,r),r}consumeIdentLike(e){let t=this.source,r=this.consumeName(e),n=t.charCodeAt(r);if(n===40&&r-e===3){let i=t.charCodeAt(e)|32,o=t.charCodeAt(e+1)|32,s=t.charCodeAt(e+2)|32;if(i===117&&o===114&&s===108){let c=r+1;while(c<t.length&&Re(t.charCodeAt(c)))c++;let a=t.charCodeAt(c);if(a===34||a===39)return this.addToken(2,e,r+1),r+1;return this.consumeUrl(e,r)}}if(n===40)return this.addToken(2,e,r+1),r+1;return this.addToken(1,e,r),r}consumeUrl(e,t){let r=this.source,n=r.length,i=t+1;while(i<n&&Re(r.charCodeAt(i)))i++;while(i<n){let o=r.charCodeAt(i);if(o===41)return i++,this.addToken(7,e,i),i;if(Re(o)){let s=i;while(i<n&&Re(r.charCodeAt(i)))i++;if(i>=n)return this.addToken(7,e,i),i;if(r.charCodeAt(i)===41)return i++,this.addToken(7,e,i),i;return this.consumeBadUrl(e,s)}if(o===34||o===39||o===40||yu(o))return this.consumeBadUrl(e,i);if(o===92){if(Ue(o,r.charCodeAt(i+1))){i=this.consumeEscapeSkip(i+1);continue}return this.consumeBadUrl(e,i)}i++}return this.addToken(7,e,i),i}consumeBadUrl(e,t){let r=this.source,n=t;while(n<r.length){let i=r.charCodeAt(n);if(i===41){n++;break}if(i===92&&Ue(i,r.charCodeAt(n+1))){n=this.consumeEscapeSkip(n+1);continue}n++}return this.addToken(8,e,n),n}locate(e){let t=this.lineStarts,r=0,n=t.length-1;while(r<n){let o=r+n+1>>1;if(t[o]<=e)r=o;else n=o-1}let i=t[r];return{line:r+1,column:e-i+1}}}function xu(e){let t=[0],r=e.length;for(let n=0;n<r;n++){let i=e.charCodeAt(n);if(i===10)t.push(n+1);else if(i===13){if(e.charCodeAt(n+1)!==10)t.push(n+1)}}return t}function an(e,t,r){for(let n=t;n<r;n++)if(e.charCodeAt(n)===92)return vu(e,t,r,n);return e.slice(t,r)}function vu(e,t,r,n){let i=e.slice(t,n),o=n;while(o<r){if(e.charCodeAt(o)!==92){i+=e[o],o++;continue}if(o+1>=r){o++;continue}let c=e.charCodeAt(o+1);if(c===10){o+=2;continue}if(c===13){o+=e.charCodeAt(o+2)===10?3:2;continue}if($t(c)){let a=o+1,l="";while(l.length<6&&a<r&&$t(e.charCodeAt(a)))l+=e[a],a++;let u=Number.parseInt(l,16);if(a<r&&Re(e.charCodeAt(a)))a++;i+=u===0||u>=55296&&u<=57343||u>1114111?String.fromCodePoint(65533):String.fromCodePoint(u),o=a;continue}i+=e[o+1],o+=2}return i}function ln(e,t,r){for(let n=t;n<r;n++)if(e.charCodeAt(n)===92)return wu(e,t,r,n);return e.slice(t,r)}function wu(e,t,r,n){let i=e.slice(t,n),o=n;while(o<r){if(e.charCodeAt(o)!==92){i+=e[o],o++;continue}let c=o+1,a="";while(a.length<6&&c<r&&$t(e.charCodeAt(c)))a+=e[c],c++;if(a.length>0){let l=Number.parseInt(a,16);if(c<r&&Re(e.charCodeAt(c)))c++;i+=l===0||l>=55296&&l<=57343||l>1114111?String.fromCodePoint(65533):String.fromCodePoint(l),o=c;continue}if(c<r){i+=e[c],o=c+1;continue}i+=String.fromCodePoint(65533),o=c}return i}function Qi(e,t){let r=new Dt(e);return{source:e,types:r.types,starts:r.starts,ends:r.ends,count:r.count,end:r.count,pos:0,positions:t.positions??!1,filename:t.filename,parseValue:t.parseValue??!0,parseAtrulePrelude:t.parseAtrulePrelude??!0,parseCustomProperty:t.parseCustomProperty??!1,parseRulePrelude:t.parseRulePrelude??!0,onParseError:t.onParseError,tokenizer:r}}function x(e){return e.pos<e.end?e.types[e.pos]:0}function v(e){let t=e.pos;if(t>=e.end)return{type:0,start:e.starts[t]??e.source.length,end:e.ends[t]??e.source.length};return{type:e.types[t],start:e.starts[t],end:e.ends[t]}}function C(e){let t=e.pos++;if(t>=e.end)return{type:0,start:e.starts[t]??e.source.length,end:e.ends[t]??e.source.length};return{type:e.types[t],start:e.starts[t],end:e.ends[t]}}function xe(e,t){return e.source.slice(t.start,t.end)}function de(e){let{types:t,end:r}=e;while(e.pos<r){let n=t[e.pos];if(n===13||n===25)e.pos++;else break}}function Gi(e){let{types:t,end:r}=e;while(e.pos<r&&t[e.pos]===13)e.pos++}function R(e,t,r){if(!e.positions)return null;let n=e.tokenizer.locate(t.start),i=e.tokenizer.locate(r.end);return{source:e.filename??"<unknown>",start:{offset:t.start,line:n.line,column:n.column},end:{offset:r.end,line:i.line,column:i.column}}}function eo(e){if(!e.positions)return null;let t=v(e),r=e.tokenizer.locate(t.start);return{source:e.filename??"<unknown>",start:{offset:t.start,line:r.line,column:r.column},end:{offset:t.start,line:r.line,column:r.column}}}function jt(e,t,r,n){return{type:"Raw",value:e,loc:R(n,t,r)}}function te(){return new le}function cn(e,t,r,n){if(e.onParseError){let{line:i,column:o}=e.tokenizer.locate(r.start),s=SyntaxError(`${e.filename??"<input>"}:${i}:${o}: ${t}`);s.line=i,s.column=o,s.offset=r.start,e.onParseError(s,n)}return n}function Vt(e,t={}){let r=Qi(e,t);switch(t.context??"stylesheet"){case"stylesheet":return Ji(r);case"atrule":return Ut(r)??qi(r);case"atrulePrelude":return ku(r);case"mediaQuery":case"mediaQueryList":return Yi(r);case"rule":return fn(r);case"selectorList":return gn(r);case"selector":return io(r);case"block":return dn(r);case"declarationList":return Eu(r);case"declaration":return hn(r)??qi(r);case"value":return Tu(r);case"raw":return Yi(r);default:return Ji(r)}}function qi(e){return{type:"StyleSheet",children:te(),loc:eo(e)}}function Yi(e){let t=v(e),r=t;while(x(e)!==0)r=C(e);return{type:"Raw",value:e.source.slice(t.start,r.end),loc:R(e,t,r)}}function Ji(e){let t=v(e),r=te(),{types:n,end:i}=e;while(e.pos<i){let c=n[e.pos];if(c===13){e.pos++;continue}if(c===25){let u={type:25,start:e.starts[e.pos],end:e.ends[e.pos]},f=un(e,u);e.pos++,r.appendData(f);continue}if(c===0)break;if(c===14||c===15){e.pos++;continue}if(c===3){let u=Ut(e);if(u)r.appendData(u);continue}if(c===24){e.pos++;continue}let a=e.pos,l=fn(e);if(r.appendData(l),e.pos===a)e.pos++}let o=e.end-1,s=o>=0?{type:e.types[o],start:e.starts[o],end:e.ends[o]}:{type:0,start:0,end:0};return{type:"StyleSheet",children:r,loc:R(e,t,s)}}function un(e,t){return{type:"Comment",value:e.source.slice(t.start+2,t.end-2),loc:R(e,t,t)}}function Ut(e){let t=v(e);if(t.type!==3)return null;e.pos++;let r=Bt(e.source,t.start+1,t.end);de(e);let n=e.pos,i=v(e),{types:o,end:s}=e,c=n,a=n;while(c<s){let f=o[c];if(f===0||f===17||f===23)break;if(f!==13&&f!==25)a=c+1;c++}let l=null;if(a>n){let f=e.starts[n],d=e.ends[a-1],h={type:o[a-1],start:e.starts[a-1],end:d},m=e.source.slice(f,d).trim();if(m.length>0)if(e.parseAtrulePrelude)try{let g=e.end;e.end=a,e.pos=n;let p=te();while(x(e)!==0){let y=ze(e);if(y)p.appendData(y)}if(ro(p),e.end=g,e.pos=c,p.isEmpty)l=jt(m,i,h,e);else l={type:"AtrulePrelude",children:p,loc:null}}catch(g){let p=jt(m,i,h,e);cn(e,`Failed to parse @${r} prelude: ${g.message}`,i,p),l=p,e.pos=c}else l=jt(m,i,h,e),e.pos=c;else e.pos=c}else e.pos=c;let u=null;if(x(e)===17)C(e);else if(x(e)===23)u=dn(e,Ru.has(r));return{type:"Atrule",name:r,prelude:l,block:u,loc:R(e,t,v(e))}}var $u=new Set(["is","not","where","has","matches","-moz-any","-webkit-any"]),Ru=new Set(["media","supports","document","layer","container","scope","starting-style","-moz-document","keyframes","-webkit-keyframes","-moz-keyframes","-o-keyframes"]);function ku(e){let t=v(e),r=te();while(x(e)!==0){if(v(e).type===13){e.pos++;continue}let i=ze(e);if(i)r.appendData(i)}return{type:"AtrulePrelude",children:r,loc:R(e,t,v(e))}}function fn(e){let t=v(e),r;if(e.parseRulePrelude)r=gn(e);else{let i=v(e),o=i;while(x(e)!==0&&x(e)!==23)o=C(e);let s=e.source.slice(i.start,o.end).trim();r=jt(s,i,o,e)}let n=dn(e,!0);return{type:"Rule",prelude:r,block:n,loc:R(e,t,v(e))}}function dn(e,t=!1){let r=v(e);if(x(e)!==23)return{type:"Block",children:te(),loc:eo(e)};e.pos++;let n=te(),{types:i,end:o}=e;while(e.pos<o){let s=i[e.pos];if(s===24||s===0)break;if(s===13){e.pos++;continue}if(s===25){let a={type:25,start:e.starts[e.pos],end:e.ends[e.pos]};e.pos++,n.appendData(un(e,a));continue}if(s===3){let a=Ut(e);if(a)n.appendData(a);continue}if(t&&Su(e,Au)){let a=fn(e);n.appendData(a);continue}let c=hn(e);if(c)n.appendData(c);if(e.pos<o&&i[e.pos]===17)e.pos++}if(x(e)===24)e.pos++;return{type:"Block",children:n,loc:R(e,r,v(e))}}function Su(e,t){let r=e.pos,n=t(e);return e.pos=r,n}function Au(e){let{types:t,end:r}=e;while(e.pos<r){let n=t[e.pos];if(n===23)return!0;if(n===17||n===24||n===0)return!1;e.pos++}return!1}function Eu(e){let t=v(e),r=te();while(x(e)!==0&&x(e)!==24){let n=v(e);if(n.type===13){e.pos++;continue}if(n.type===25){r.appendData(un(e,C(e)));continue}if(n.type===17){e.pos++;continue}if(n.type===3){let o=Ut(e);if(o)r.appendData(o);continue}let i=hn(e);if(i)r.appendData(i);if(x(e)===17)C(e)}return{type:"DeclarationList",children:r,loc:R(e,t,v(e))}}function hn(e){de(e);let t=v(e);if(t.type!==1&&t.type!==4&&!(t.type===9&&e.source[t.start]==="*"&&e.source[t.start+1]===" "))if(t.type===9&&e.source[t.start]==="*")e.pos++;else{cn(e,"Expected property name",t,{type:"Raw",value:"",loc:null});let{types:S,end:j}=e;while(e.pos<j){let q=S[e.pos];if(q===0||q===17||q===24)break;e.pos++}return null}let r=e.starts[e.pos],n=e.ends[e.pos];e.pos++;let i=e.source.slice(r,n);if(Gi(e),x(e)!==16){cn(e,`Expected ':' after property "${i}"`,v(e),{type:"Raw",value:"",loc:null});let{types:S,end:j}=e;while(e.pos<j){let q=S[e.pos];if(q===0||q===17||q===24)break;e.pos++}return null}e.pos++,Gi(e);let{types:o,starts:s,end:c,pos:a}=e,l=a,u=a,f=-1,d=-1;while(l<c){let S=o[l];if(S===0||S===17||S===24)break;if(S===9&&e.source.charCodeAt(s[l])===33){let j=l+1;while(j<c&&o[j]===13)j++;if(j<c&&o[j]===1){let q=s[j];if(e.ends[j]-q===9&&(e.source.charCodeAt(q)|32)===105&&(e.source.charCodeAt(q+1)|32)===109&&(e.source.charCodeAt(q+2)|32)===112&&(e.source.charCodeAt(q+3)|32)===111&&(e.source.charCodeAt(q+4)|32)===114&&(e.source.charCodeAt(q+5)|32)===116&&(e.source.charCodeAt(q+6)|32)===97&&(e.source.charCodeAt(q+7)|32)===110&&(e.source.charCodeAt(q+8)|32)===116){d=l,f=j,l=j+1;continue}}}if(S!==13&&S!==25)u=l+1;l++}let h=u,m=f>=0?{type:1,start:s[f],end:e.ends[f]}:null,g=i.startsWith("--"),p,y=s[a],b=h>a?e.ends[h-1]:y,w={type:o[a],start:y,end:e.ends[a]},T=h>a?{type:o[h-1],start:s[h-1],end:b}:w;if(g&&!e.parseCustomProperty||!e.parseValue)p={type:"Raw",value:e.source.slice(y,b).trim(),loc:R(e,w,T)};else if(h===a)p={type:"Value",children:te(),loc:R(e,w,T)};else{let S=e.end;e.end=h,e.pos=a,p=to(e),e.end=S}return e.pos=l,{type:"Declaration",property:i,important:m?!0:!1,value:p,loc:R(e,t,v(e))}}function Tu(e){return to(e)}function to(e){let t=v(e),r=te();while(x(e)!==0&&x(e)!==17&&x(e)!==24&&x(e)!==22&&x(e)!==20){let n=ze(e);if(n)r.appendData(n)}return no(r),{type:"Value",children:r,loc:R(e,t,v(e))}}function ro(e){for(let t of e)if("children"in t&&t.children instanceof le)ro(t.children);no(e)}function no(e){let t=e.head;while(t){if(t.data.type==="Number"){let r=t.next;while(r&&r.data.type==="WhiteSpace")r=r.next;if(r&&r.data.type==="Operator"&&r.data.value==="/"){let n=r.next;while(n&&n.data.type==="WhiteSpace")n=n.next;if(n&&n.data.type==="Number"){let i={type:"Ratio",left:t.data,right:n.data,loc:null},o=t.next;while(o&&o!==n.next){let s=o.next;e.remove(o),o=s}e.replace(t,e.createItem(i)),t=e.head;continue}}}t=t.next}}function ze(e){let t=e.pos;if(t>=e.end)return null;let r=e.types[t],n=e.starts[t],i=e.ends[t],o=e.source;switch(r){case 13:return e.pos++,e.positions?{type:"WhiteSpace",value:" ",loc:ee(e,n,i)}:{type:"WhiteSpace",value:" ",loc:null};case 25:return e.pos++,{type:"Comment",value:o.slice(n+2,i-2),loc:e.positions?ee(e,n,i):null};case 10:return e.pos++,{type:"Number",value:o.slice(n,i),loc:e.positions?ee(e,n,i):null};case 11:return e.pos++,{type:"Percentage",value:o.slice(n,i-1),loc:e.positions?ee(e,n,i):null};case 12:{e.pos++;let s=n,c=o.charCodeAt(s);if(c===43||c===45)s++;let a=!1;while(s<i){let u=o.charCodeAt(s);if(u>=48&&u<=57){s++;continue}if(u===46&&!a){a=!0,s++;continue}break}let l=o.charCodeAt(s);if(l===69||l===101){let u=s+1,f=o.charCodeAt(u);if(f===43||f===45)u++;let d=!1;while(u<i){let h=o.charCodeAt(u);if(h>=48&&h<=57){u++,d=!0;continue}break}if(d)s=u}return{type:"Dimension",value:o.slice(n,s),unit:o.slice(s,i),loc:e.positions?ee(e,n,i):null}}case 1:return e.pos++,{type:"Identifier",name:ln(o,n,i),loc:e.positions?ee(e,n,i):null};case 5:{e.pos++;let s=n+1,a=i-n>=2&&o.charCodeAt(i-1)===o.charCodeAt(n)?i-1:i;return{type:"String",value:an(o,s,a),loc:e.positions?ee(e,n,i):null}}case 7:{e.pos++;let s=n+4;while(s<i&&Xi(o.charCodeAt(s)))s++;let c=i;if(c>s&&o.charCodeAt(c-1)===41)c--;while(c>s&&Xi(o.charCodeAt(c-1)))c--;let a;if(c-s>=2){let l=o.charCodeAt(s),u=o.charCodeAt(c-1);if((l===34||l===39)&&l===u)a=o.slice(s+1,c-1);else a=o.slice(s,c)}else a=o.slice(s,c);return{type:"Url",value:a,loc:e.positions?ee(e,n,i):null}}case 4:return e.pos++,{type:"Hash",name:o.slice(n+1,i),loc:e.positions?ee(e,n,i):null};case 2:return Ou(e);case 21:return Iu(e);case 18:return e.pos++,{type:"Operator",value:",",loc:e.positions?ee(e,n,i):null};case 16:return e.pos++,{type:"Operator",value:":",loc:e.positions?ee(e,n,i):null};case 9:{e.pos++;let s=o.charCodeAt(n),c=o[n];if(Nu(s))return{type:"Operator",value:c,loc:e.positions?ee(e,n,i):null};return{type:"Identifier",name:c,loc:e.positions?ee(e,n,i):null}}case 19:{e.pos++;let s=te();while(x(e)!==0&&x(e)!==20){let a=ze(e);if(a)s.appendData(a)}let c=e.pos<e.end?e.ends[e.pos]:i;if(x(e)===20)e.pos++;return{type:"Brackets",children:s,loc:e.positions?ee(e,n,c):null}}case 3:case 23:case 24:case 22:case 20:case 17:case 0:case 14:case 15:case 6:case 8:return e.pos++,{type:"Raw",value:o.slice(n,i),loc:e.positions?ee(e,n,i):null}}return e.pos++,null}function Xi(e){return e===32||e===9||e===10||e===12||e===13}function Nu(e){return e===47||e===43||e===45||e===42||e===61||e===62||e===60||e===126||e===124||e===36||e===94||e===33||e===38}function Bt(e,t,r){for(let n=t;n<r;n++){let i=e.charCodeAt(n);if(i>=65&&i<=90)return e.slice(t,r).toLowerCase()}return e.slice(t,r)}function ee(e,t,r){let n=e.tokenizer.locate(t),i=e.tokenizer.locate(r);return{source:e.filename??"<unknown>",start:{offset:t,line:n.line,column:n.column},end:{offset:r,line:i.line,column:i.column}}}function Ou(e){let t=C(e),r=Bt(e.source,t.start,t.end-1),n=te();while(x(e)!==0&&x(e)!==22){let i=ze(e);if(i)n.appendData(i)}if(x(e)===22)C(e);if(r==="url"){for(let i=n.head;i!=null;i=i.next)if(i.data.type==="String")return{type:"Url",value:i.data.value,loc:R(e,t,v(e))}}return{type:"Function",name:r,children:n,loc:R(e,t,v(e))}}function Iu(e){let t=C(e),r=te();while(x(e)!==0&&x(e)!==22){let n=ze(e);if(n)r.appendData(n)}if(x(e)===22)C(e);return{type:"Parentheses",children:r,loc:R(e,t,v(e))}}function gn(e){let t=v(e),r=te();while(x(e)!==0){if(de(e),x(e)===0||x(e)===23)break;let n=io(e);if(n.children.head!==null)r.appendData(n);if(de(e),x(e)===18){C(e);continue}break}return{type:"SelectorList",children:r,loc:R(e,t,v(e))}}function io(e){let t=v(e),r=te(),n=!0;while(x(e)!==0&&x(e)!==18&&x(e)!==23){let i=v(e);if(i.type===13){if(C(e),!n&&x(e)!==0&&x(e)!==18&&x(e)!==23&&!Zi(e)&&!Pu(e)){let s={type:"Combinator",name:" ",loc:R(e,i,i)};r.appendData(s),n=!0}continue}if(i.type===9&&e.source.charCodeAt(i.start)===124&&e.types[e.pos+1]===9&&e.source.charCodeAt(e.starts[e.pos+1])===124){let s=v(e);C(e);let c=C(e),a={type:"Combinator",name:"||",loc:R(e,s,c)};r.appendData(a),n=!0,de(e);continue}if(Zi(e)){let s=C(e),a={type:"Combinator",name:e.source[s.start],loc:R(e,s,s)};r.appendData(a),n=!0,de(e);continue}let o=_u(e);if(!o)break;r.appendData(o),n=!1}while(r.tail&&r.tail.data.type==="Combinator")r.remove(r.tail);return{type:"Selector",children:r,loc:R(e,t,v(e))}}function Zi(e){let t=v(e);if(t.type!==9)return!1;let r=e.source[t.start];return r===">"||r==="+"||r==="~"}function Pu(e){if(e.types[e.pos]!==9)return!1;if(e.source.charCodeAt(e.starts[e.pos])!==124)return!1;if(e.types[e.pos+1]!==9)return!1;return e.source.charCodeAt(e.starts[e.pos+1])===124}function _u(e){let t=v(e);switch(t.type){case 1:{if(C(e),x(e)===9&&e.source[v(e).start]==="|"&&e.source[v(e).start+1]!=="="&&!(e.types[e.pos+1]===9&&e.source.charCodeAt(e.starts[e.pos+1])===124)){if(C(e),x(e)===1){let n=C(e);return{type:"TypeSelector",name:`${xe(e,t)}|${xe(e,n)}`,loc:R(e,t,n)}}if(x(e)===9&&e.source[v(e).start]==="*"){let n=C(e);return{type:"TypeSelector",name:`${xe(e,t)}|*`,loc:R(e,t,n)}}}return{type:"TypeSelector",name:xe(e,t),loc:R(e,t,t)}}case 11:return C(e),{type:"TypeSelector",name:xe(e,t),loc:R(e,t,t)};case 10:return C(e),{type:"TypeSelector",name:xe(e,t),loc:R(e,t,t)};case 9:{let r=e.source[t.start];if(r==="*")return C(e),{type:"TypeSelector",name:"*",loc:R(e,t,t)};if(r==="."){if(C(e),x(e)===1){let n=C(e);return{type:"ClassSelector",name:xe(e,n),loc:R(e,t,n)}}return null}if(r==="&")return C(e),{type:"NestingSelector",loc:R(e,t,t)};return C(e),null}case 4:return C(e),{type:"IdSelector",name:e.source.slice(t.start+1,t.end),loc:R(e,t,t)};case 16:{C(e);let r=x(e)===16;if(r)C(e);return Lu(e,r,t)}case 19:return Mu(e)}return null}function Lu(e,t,r){let n=v(e);if(n.type===1){C(e);let i=Bt(e.source,n.start,n.end);return t?{type:"PseudoElementSelector",name:i,children:null,loc:R(e,r,n)}:{type:"PseudoClassSelector",name:i,children:null,loc:R(e,r,n)}}if(n.type===2){C(e);let i=Bt(e.source,n.start,n.end-1),o=te();if(!t&&$u.has(i)){let a=v(e),l=a,u=1;while(x(e)!==0&&u>0){if(x(e)===21||x(e)===2)u++;else if(x(e)===22){if(u--,u===0)break}l=C(e)}if(x(e)===22)C(e);let f=e.source.slice(a.start,l.end).trim();if(f.length>0){let d=Qi(f,{positions:!1}),h=gn(d);o.appendData(h)}}else{while(x(e)!==0&&x(e)!==22){let a=ze(e);if(a)o.appendData(a)}if(x(e)===22)C(e)}if(t)return{type:"PseudoElementSelector",name:i,children:o,loc:R(e,r,v(e))};return{type:"PseudoClassSelector",name:i,children:o,loc:R(e,r,v(e))}}return null}function Mu(e){let t=C(e);de(e);let r=v(e);if(r.type!==1)return null;C(e);let n={type:"Identifier",name:xe(e,r),loc:R(e,r,r)};de(e);let i=null,o=null,s=null,c=v(e);if(c.type===9){let l=e.source[c.start],u=e.source[c.start+1];if(l==="=")i="=",C(e);else if((l==="~"||l==="|"||l==="^"||l==="$"||l==="*")&&u==="="){C(e);let h=v(e);if(h.type===9&&e.source[h.start]==="=")C(e),i=`${l}=`}de(e);let f=v(e);if(f.type===5){C(e);let h=f.end-f.start>=2&&e.source.charCodeAt(f.end-1)===e.source.charCodeAt(f.start);o={type:"String",value:an(e.source,f.start+1,h?f.end-1:f.end),loc:R(e,f,f)}}else if(f.type===1)C(e),o={type:"Identifier",name:xe(e,f),loc:R(e,f,f)};de(e);let d=v(e);if(d.type===1)C(e),s=xe(e,d)}de(e);let a=v(e);if(x(e)===20)a=C(e);return{type:"AttributeSelector",name:n,matcher:i,value:o,flags:s,loc:R(e,t,a)}}var oo=Symbol("walkSkip"),V=Symbol("walkStop");function Fu(e){return{root:e,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null}}function Du(e,t){let r=Fu(e),n=typeof t==="function"?t:t.enter,i=typeof t==="function"?null:t.leave??null,o=typeof t==="function"?null:t.visit??null,s=typeof t==="function"?!1:t.reverse??!1;function c(a,l,u){let f=null,d;switch(a.type){case"StyleSheet":f="stylesheet",d=r.stylesheet,r.stylesheet=a;break;case"Atrule":f="atrule",d=r.atrule,r.atrule=a;break;case"AtrulePrelude":f="atrulePrelude",d=r.atrulePrelude,r.atrulePrelude=a;break;case"Rule":f="rule",d=r.rule,r.rule=a;break;case"Selector":f="selector",d=r.selector,r.selector=a;break;case"Block":f="block",d=r.block,r.block=a;break;case"Declaration":f="declaration",d=r.declaration,r.declaration=a;break;case"Function":f="function",d=r.function,r.function=a;break}let h;if((o===null||o===a.type)&&n){let m=n.call(r,a,l,u);if(m===oo){if(f)r[f]=d;return}if(m===V){if(f)r[f]=d;return V}}if(h=ju(a,s,c),h===V){if(f)r[f]=d;return V}if((o===null||o===a.type)&&i){if(i.call(r,a,l,u)===V){if(f)r[f]=d;return V}}if(f)r[f]=d;return}return c(e,null,null)}var Ke=Object.assign(Du,{skip:oo,stop:V});function ju(e,t,r){if("children"in e&&e.children instanceof le)return Bu(e.children,t,r);if(e.type==="Rule"){if(r(e.prelude,null,null)===V)return V;if(r(e.block,null,null)===V)return V;return}if(e.type==="Atrule"){if(e.prelude){if(r(e.prelude,null,null)===V)return V}if(e.block){if(r(e.block,null,null)===V)return V}return}if(e.type==="Declaration")return r(e.value,null,null);if(e.type==="AttributeSelector"){if(r(e.name,null,null)===V)return V;if(e.value)return r(e.value,null,null);return}return}function Bu(e,t,r){let n;if(t)e.forEachRight((i,o,s)=>{if(n)return;if(r(i,o,s)===V)n=V});else e.forEach((i,o,s)=>{if(n)return;if(r(i,o,s)===V)n=V});return n}function Qe(e,t={}){let r=t.exclamation??!1,n=!1;Ke(e,(i,o,s)=>{if(i.type!=="Comment")return;let c=i.value.startsWith("!");if(r===!0&&c)return;if(r==="first-exclamation"&&c&&!n){n=!0;return}if(o&&s)s.remove(o)})}function Wt(e){Ke(e,(t)=>{if(t.type!=="Block"&&t.type!=="DeclarationList")return;if(!("children"in t)||!t.children)return;let r=t.children,n=r.head;if(n==null||n.next==null)return;let i=0;for(let c=n;c!=null;c=c.next)if(c.data.type==="Declaration"){if(i++,i>=2)break}if(i<2)return;let o=new Map,s=[];for(let c=n;c!=null;c=c.next){let a=c.data;if(a.type!=="Declaration")continue;let l=a.property,u=o.get(l);if(u){let f=!!u.decl.important,d=!!a.important;if(d||f===d)s.push(u.item),o.set(l,{item:c,decl:a});else s.push(c)}else o.set(l,{item:c,decl:a})}for(let c of s)r.remove(c)})}var Vu={black:"#000",fuchsia:"#f0f",white:"#fff",red:"#f00",cyan:"#0ff",blue:"#00f",yellow:"#ff0",magenta:"#f0f",lime:"#0f0",silver:"#c0c0c0",gray:"#808080",maroon:"#800000",olive:"#808000",green:"#008000",purple:"#800080",teal:"#008080",navy:"#000080"},Uu={"#f00":"red","#ff0000":"red","#000080":"navy","#008080":"teal"};function pn(e){if(!e.startsWith("#"))return e;let t=e.slice(1);if(t.length===6){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5])return`#${t[0]}${t[2]}${t[4]}`}if(t.length===8){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&t[6]===t[7])return`#${t[0]}${t[2]}${t[4]}${t[6]}`}return e}function so(e){let t=e.toLowerCase();return Vu[t]??null}function ao(e){let t=e.toLowerCase();return Uu[t]??null}function Wu(e,t,r){let n=(e<<16|t<<8|r).toString(16).padStart(6,"0");return pn(`#${n}`)}var zu=/^rgba?\(\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*(?:[,/]\s*([+-]?\d*\.?\d+%?)\s*)?\)$/;function lo(e){let t=zu.exec(e.trim());if(!t)return e;let r=mn(t[1]),n=mn(t[2]),i=mn(t[3]);if(t[4]!==void 0&&!Ku(t[4]))return e;return Wu(r,n,i)}function Ku(e){if(e.endsWith("%"))return Number.parseFloat(e)>=100;return Number.parseFloat(e)>=1}function mn(e){if(e.endsWith("%"))return Math.max(0,Math.min(255,Math.round(Number.parseFloat(e)*2.55)));return Math.max(0,Math.min(255,Math.round(Number.parseFloat(e))))}var Hu=new Set(["px","pt","pc","in","cm","mm","q","em","rem","ex","ch","cap","ic","lh","rlh","vw","vh","vi","vb","vmin","vmax","svw","svh","svi","svb","svmin","svmax","lvw","lvh","lvi","lvb","lvmin","lvmax","dvw","dvh","dvi","dvb","dvmin","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"]);function zt(e){if(e.charCodeAt(0)===43)e=e.slice(1);if(e.includes(".")){let t=e.replace(/(\.\d*?)0+($|[eE])/,"$1$2");t=t.replace(/\.($|[eE])/,"$1"),e=t}if(e.startsWith("0.")&&e.length>2)e=e.slice(1);else if(e.startsWith("-0.")&&e.length>3)e=`-${e.slice(2)}`;if(e==="-0"||e==="-.0"||e==="-0.0")e="0";return e}function co(e,t){let r=zt(e);if((r==="0"||r==="-0")&&Hu.has(t.toLowerCase()))return{value:"0",unit:""};return{value:r,unit:t}}function uo(e){return zt(e)}function fo(e,t){let r=Number.parseFloat(e);if(!Number.isFinite(r))return e;let n=t<0?0:t;return r.toFixed(n)}var ho=new Set(["color","background","background-color","border","border-color","border-top","border-top-color","border-right","border-right-color","border-bottom","border-bottom-color","border-left","border-left-color","border-block","border-block-color","border-block-start-color","border-block-end-color","border-inline","border-inline-color","border-inline-start-color","border-inline-end-color","outline","outline-color","caret-color","fill","stroke","flood-color","lighting-color","stop-color","column-rule","column-rule-color","text-decoration","text-decoration-color","text-emphasis","text-emphasis-color","text-shadow","box-shadow","accent-color","scrollbar-color"]);function go(e){if(!e||e.type!=="Operator")return!1;let t=e.value;return t===":"||t===","||t==="/"}function Gu(e){let t=e.children;if(!t)return;while(t.head&&t.head.data.type==="WhiteSpace")t.remove(t.head);while(t.tail&&t.tail.data.type==="WhiteSpace")t.remove(t.tail);let r=t.head;while(r){let n=r.next;if(r.data.type==="WhiteSpace"){let i=r.prev&&go(r.prev.data),o=n&&go(n.data);if(i||o)t.remove(r)}r=n}}function yn(e,t={}){let r=t.floatPrecision??null,n=r===null?null:(i)=>fo(i,r);Ke(e,{enter(i,o,s){switch(i.type){case"Number":{let c=n?n(i.value):i.value;i.value=zt(c);return}case"Percentage":{let c=n?n(i.value):i.value;i.value=uo(c);return}case"Dimension":{let c=n?n(i.value):i.value,a=co(c,i.unit);i.value=a.value,i.unit=a.unit;return}case"Hash":{let c=pn(`#${i.name}`).slice(1);if(i.name=c,o&&s&&this.declaration&&ho.has(this.declaration.property.toLowerCase())){let a=ao(`#${c}`);if(a&&a.length<c.length+1){let l={type:"Identifier",name:a,loc:i.loc};s.replace(o,s.createItem(l))}}return}case"Identifier":{if(!o||!s||!this.declaration)return;if(!ho.has(this.declaration.property.toLowerCase()))return;let c=so(i.name);if(c&&c.length<i.name.length){let a={type:"Hash",name:c.slice(1),loc:i.loc};s.replace(o,s.createItem(a))}return}case"Url":return;case"Function":{let c=i.name.toLowerCase();if((c==="rgb"||c==="rgba")&&o&&s)i.__rgbReplaceCandidate=!0}}},leave(i,o,s){if(i.type==="Parentheses"||i.type==="Function"||i.type==="Value")Gu(i);if(i.type==="Function"&&i.__rgbReplaceCandidate&&o&&s){let c=Q(i),a=lo(c);if(a!==c&&a.startsWith("#")){let l={type:"Hash",name:a.slice(1),loc:i.loc};s.replace(o,s.createItem(l))}}}})}function qu(e,t={}){let r=Vt(e,{context:"stylesheet"});return mo(r,t)}function bn(e,t={}){let r=Vt(e,{context:"declarationList"});return mo(r,t)}function mo(e,t){if(t.comments===!1)Qe(e,{exclamation:!1});else if(t.comments==="first-exclamation")Qe(e,{exclamation:"first-exclamation"});else Qe(e,{exclamation:!0});return yn(e,{floatPrecision:t.floatPrecision??null}),Wt(e),{css:Q(e),ast:e}}function Le(e,t,r){if(e.size>=1e4){let n=e.keys().next().value;if(n!==void 0)e.delete(n)}return e.set(t,r),r}var po=new Map,_e=new Map;var xn={col:"col",row:"row",jc:"justify",ji:"justify-items",js:"justify-self",ai:"items",ac:"content",as:"self",wrap:"wrap",nowrap:"nowrap",c:"center",s:"start",e:"end",sb:"between",sa:"around",se:"evenly",st:"stretch",thin:"thin",extralight:"extralight",light:"light",normal:"normal",medium:"medium",semibold:"semibold",bold:"bold",extrabold:"extrabold",black:"black",t:"top",r:"right",b:"bottom",l:"left"},Xu=/[%#()]/,Zu=/^\d+(?:\.\d+)?(?:px|rem|em|vh|vw|dvh|dvw|svh|svw|lvh|lvw|ch|ex|lh|cap|ic|rlh|vi|vb|vmin|vmax|cqw|cqh|cqi|cqb|cqmin|cqmax|cm|mm|in|pt|pc|Q)$/,$o=["calc","min","max","clamp","mod","rem","sin","cos","tan","asin","acos","atan","atan2","pow","sqrt","hypot","log","exp","round"],Qu=new Set($o);function se(e){return Xu.test(e)||Zu.test(e)}function yo(e){if(!$o.some((o)=>e.includes(`${o}(`)))return e;let t="",r=[],n=null,i=null;for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);if(s>=48&&s<=57)n=o;else if(n!==null&&(s===37||s>=97&&s<=122||s>=65&&s<=90))n=o;else i=n,n=null;if(s===40){t+=e[o];let a=o;for(let u=o-1;u>=0;u--){let f=e.charCodeAt(u);if(f>=48&&f<=57||f>=97&&f<=122)a=u;else break}let l=e.slice(a,o);if(Qu.has(l))r.unshift(!0);else if(r[0]&&l==="")r.unshift(!0);else r.unshift(!1);continue}if(s===41){t+=e[o],r.shift();continue}if(s===44&&r[0]){t+=", ";continue}if(s===32&&r[0]&&t.charCodeAt(t.length-1)===32)continue;if((s===43||s===45||s===42||s===47)&&r[0]){let a=t.trimEnd(),l=a.charCodeAt(a.length-1),u=a.charCodeAt(a.length-2),f=e.charCodeAt(o+1),d=l===43||l===45||l===42||l===47,h=f===43||f===45||f===42||f===47;if((l===101||l===69)&&u>=48&&u<=57)t+=e[o];else if(d||l===40||l===44)t+=e[o];else if(e.charCodeAt(o-1)===32)t+=`${e[o]} `;else if(l>=48&&l<=57||f>=48&&f<=57||l===41||f===40||h||i!==null&&i===o-1)t+=` ${e[o]} `;else t+=e[o];continue}t+=e[o]}return t}function Kt(e){if(!e.includes("_"))return yo(e);let t="",r=0;while(r<e.length){let n=e[r];if(n==="\\"&&e[r+1]==="_"){t+="_",r+=2;continue}if(n==="u"&&e.slice(r,r+4)==="url("){let i=r,o=1;r+=4;while(r<e.length&&o>0){if(e[r]==="(")o++;else if(e[r]===")")o--;r++}t+=e.slice(i,r);continue}t+=n==="_"?" ":n,r++}return yo(t)}function bo(e,t){if(t.length!==2)return null;let[r,n]=t;if(r!=="min"&&r!=="max")return null;return[se(n)?`${r}-${e}-[${n}]`:`${r}-${e}-${n}`]}var ef={flex:{expand:(e,t)=>{let r=t[e]||e;if(["col","row","col-reverse","row-reverse","wrap","nowrap","wrap-reverse"].includes(r))return`flex-${r}`;let n=e.match(/^(jc|ji|js|ai|ac|as)-(.+)$/);if(n){let i=t[n[1]]||n[1],o=t[n[2]]||n[2];return`${i}-${o}`}if(/^\d+$/.test(r)||["grow","shrink","auto","initial","none"].includes(r))return`flex-${r}`;return null}},grid:{expand:(e,t)=>{let r=t[e]||e;if(e.startsWith("cols-")||e.startsWith("rows-"))return`grid-${e}`;if(e.startsWith("flow-"))return`grid-${e}`;if(e.startsWith("gap-"))return e;return null}},text:{expand:(e,t)=>{let r=t[e]||e;if(se(r))return`text-[${r}]`;if(/^\d{3}$/.test(r))return{"100":"font-thin","200":"font-extralight","300":"font-light","400":"font-normal","500":"font-medium","600":"font-semibold","700":"font-bold","800":"font-extrabold","900":"font-black"}[r]||`font-[${r}]`;if(/^[a-z-]+$/i.test(r)&&!["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl","9xl"].includes(r)){if(["white","black","inherit","current","transparent"].includes(r.toLowerCase()))return`text-${r}`;if(["red","blue","green","yellow","purple","pink","gray","slate","zinc","neutral","stone","orange","amber","lime","emerald","teal","cyan","sky","indigo","violet","fuchsia","rose"].includes(r.toLowerCase()))return`text-${r}-500`;return`font-[${r}]`}return`text-${r}`}},font:{expand:(e,t)=>{let r=t[e]||e,n=["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],i=["sans","serif","mono"];if(n.includes(r)||i.includes(r))return`font-${r}`;if(/^\d{3}$/.test(r))return{"100":"font-thin","200":"font-extralight","300":"font-light","400":"font-normal","500":"font-medium","600":"font-semibold","700":"font-bold","800":"font-extrabold","900":"font-black"}[r]||`font-[${r}]`;return`font-[${r}]`}},bg:{expand:(e,t)=>`bg-${t[e]||e}`},w:{expand:(e,t)=>{let r=t[e]||e;if(se(r))return`w-[${r}]`;return`w-${r}`},multiValue:(e)=>bo("w",e)},h:{expand:(e,t)=>{let r=t[e]||e;if(se(r))return`h-[${r}]`;return`h-${r}`},multiValue:(e)=>bo("h",e)},p:{expand:(e)=>`p-${e}`},px:{expand:(e)=>`px-${e}`},py:{expand:(e)=>`py-${e}`},pt:{expand:(e)=>`pt-${e}`},pr:{expand:(e)=>`pr-${e}`},pb:{expand:(e)=>`pb-${e}`},pl:{expand:(e)=>`pl-${e}`},m:{expand:(e)=>`m-${e}`},mx:{expand:(e)=>`mx-${e}`},my:{expand:(e)=>`my-${e}`},mt:{expand:(e)=>`mt-${e}`},mr:{expand:(e)=>`mr-${e}`},mb:{expand:(e)=>`mb-${e}`},ml:{expand:(e)=>`ml-${e}`},scroll:{expand:(e)=>{if(["x","y"].includes(e))return null;if(["auto","hidden","scroll","visible"].includes(e))return`overflow-${e}`;return null},multiValue:(e)=>{if(e.length===2){let[t,r]=e;if(["x","y"].includes(t)&&["auto","hidden","scroll","visible"].includes(r))return[`overflow-${t}-${r}`]}return null}},overflow:{expand:(e)=>`overflow-${e}`,multiValue:(e)=>{if(e.length===2){let[t,r]=e;if(["x","y"].includes(t))return[`overflow-${t}-${r}`]}return null}},border:{expand:(e)=>`border-${e}`},rounded:{expand:(e)=>`rounded-${e}`},shadow:{expand:(e)=>`shadow-${e}`},gap:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-"))return`gap-${e}`;return`gap-${e}`}},space:{expand:(e)=>`space-${e}`},opacity:{expand:(e)=>`opacity-${e}`},z:{expand:(e)=>`z-${e}`},inset:{expand:(e,t)=>{let r=t[e]||e;if(r.startsWith("x-")||r.startsWith("y-"))return`inset-${r}`;if(se(r))return`inset-[${r}]`;return`inset-${r}`}},top:{expand:(e)=>se(e)?`top-[${e}]`:`top-${e}`},right:{expand:(e)=>se(e)?`right-[${e}]`:`right-${e}`},bottom:{expand:(e)=>se(e)?`bottom-[${e}]`:`bottom-${e}`},left:{expand:(e)=>se(e)?`left-[${e}]`:`left-${e}`},duration:{expand:(e)=>`duration-${e}`},delay:{expand:(e)=>`delay-${e}`},ease:{expand:(e)=>`ease-${e}`},transition:{expand:(e)=>{if(["all","none","colors","opacity","shadow","transform"].includes(e))return`transition-${e}`;if(/^\d+$/.test(e))return`duration-${e}`;if(["linear","in","out","in-out","ease-linear","ease-in","ease-out","ease-in-out"].includes(e))return e.startsWith("ease-")?e:`ease-${e}`;return`transition-${e}`}},translate:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-")||e.startsWith("z-"))return`translate-${e}`;return`translate-${e}`}},rotate:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-")||e.startsWith("z-"))return`rotate-${e}`;return`rotate-${e}`}},scale:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-")||e.startsWith("z-"))return`scale-${e}`;return`scale-${e}`}},skew:{expand:(e)=>{if(e.startsWith("x-")||e.startsWith("y-"))return`skew-${e}`;return`skew-${e}`}},origin:{expand:(e)=>`origin-${e}`},cursor:{expand:(e)=>`cursor-${e}`},select:{expand:(e)=>`select-${e}`},resize:{expand:(e)=>`resize-${e}`},appearance:{expand:(e)=>`appearance-${e}`},pointer:{expand:(e)=>`pointer-events-${e}`},outline:{expand:(e)=>`outline-${e}`},ring:{expand:(e)=>`ring-${e}`},blur:{expand:(e)=>`blur-${e}`},brightness:{expand:(e)=>`brightness-${e}`},contrast:{expand:(e)=>`contrast-${e}`},grayscale:{expand:(e)=>`grayscale-${e}`},saturate:{expand:(e)=>`saturate-${e}`},sepia:{expand:(e)=>`sepia-${e}`},backdrop:{expand:(e)=>`backdrop-${e}`},aspect:{expand:(e)=>`aspect-${e}`},columns:{expand:(e)=>`columns-${e}`},break:{expand:(e)=>`break-${e}`},object:{expand:(e)=>`object-${e}`},overscroll:{expand:(e)=>`overscroll-${e}`},place:{expand:(e)=>`place-${e}`},items:{expand:(e)=>`items-${e}`},justify:{expand:(e)=>`justify-${e}`},content:{expand:(e)=>`content-${e}`},self:{expand:(e)=>`self-${e}`},order:{expand:(e)=>`order-${e}`},col:{expand:(e)=>`col-${e}`},row:{expand:(e)=>`row-${e}`},tracking:{expand:(e)=>`tracking-${e}`},leading:{expand:(e)=>`leading-${e}`},list:{expand:(e)=>`list-${e}`},decoration:{expand:(e)=>`decoration-${e}`},underline:{expand:(e)=>`underline-${e}`},accent:{expand:(e)=>`accent-${e}`},caret:{expand:(e)=>`caret-${e}`},"scroll-m":{expand:(e)=>`scroll-m-${e}`},"scroll-p":{expand:(e)=>`scroll-p-${e}`},snap:{expand:(e)=>`snap-${e}`},touch:{expand:(e)=>`touch-${e}`},will:{expand:(e)=>`will-change-${e}`},fill:{expand:(e)=>`fill-${e}`},stroke:{expand:(e)=>`stroke-${e}`},sr:{expand:(e)=>`sr-${e}`},invert:{expand:(e)=>`invert-${e}`},"hue-rotate":{expand:(e)=>se(e)?`hue-rotate-[${e}]`:`hue-rotate-${e}`},"drop-shadow":{expand:(e)=>`drop-shadow-${e}`},"backdrop-invert":{expand:(e)=>`backdrop-invert-${e}`},"backdrop-hue-rotate":{expand:(e)=>se(e)?`backdrop-hue-rotate-[${e}]`:`backdrop-hue-rotate-${e}`},animate:{expand:(e)=>`animate-${e}`},"forced-colors":{expand:(e)=>`forced-colors-${e}`}},Rt=new Set(["sm","md","lg","xl","2xl","hover","focus","active","visited","disabled","enabled","focus-within","focus-visible","group-hover","group-focus","peer-hover","peer-focus","*","**","dark","first","last","odd","even","only","first-of-type","last-of-type","only-of-type","checked","indeterminate","default","required","valid","invalid","in-range","out-of-range","placeholder-shown","autofill","read-only","user-valid","user-invalid","inert","empty","before","after","selection","marker","file","first-letter","first-line","backdrop","details-content","print","motion-safe","motion-reduce","pointer-none","pointer-coarse","pointer-fine","any-pointer-none","any-pointer-coarse","any-pointer-fine","inverted-colors","noscript","starting","contrast-more","contrast-less","rtl","ltr","portrait","landscape","@sm","@md","@lg","@xl","@2xl"]),xo=new WeakMap,vo=new WeakMap;function tf(e){if(!e)return xn;let t=xo.get(e);if(!t)t=e.aliases?{...xn,...e.aliases}:xn,xo.set(e,t);return t}function rf(e){if(!e?.aliases)return"";let t=vo.get(e);if(t===void 0)t=JSON.stringify(e.aliases),vo.set(e,t);return t}function kt(e){let t=[],r="",n=0;for(let i=0;i<e.length;i++){let o=e[i];if(o==="[")n++;else if(o==="]")n--;if(o===":"&&n===0)t.push(r),r="";else r+=o}return t.push(r),t}function nf(e,t){let r=`${e}:${t?.colonSyntax}:${rf(t)}`,n=_e.get(r);if(n)return n;let i=tf(t);if(t?.colonSyntax===!0){let g=e.match(/^([a-z][a-z0-9-]*):([^[\]:]+)$/i);if(g){let[,p,y]=g;if(!Rt.has(p)){if(se(y)){let w=[`${p}-[${y}]`];return Le(_e,r,w),w}let b=y.startsWith("-")?[`-${p}-${y.slice(1)}`]:[`${p}-${y}`];return Le(_e,r,b),b}}}let o="",s=e,c=!1;if(s.startsWith("-"))c=!0,s=s.slice(1);let a=s.match(/^((?:[a-z@][a-z0-9-]*:)+)(.+)$/i);if(a){if(a[1].slice(0,-1).split(":").every((y)=>Rt.has(y)))o=a[1],s=a[2]}let l=s.match(/^([a-z][a-z0-9-]*)\[([^\]]*)\]$/i);if(!l||s.includes("-[")){let g=[e];return Le(_e,r,g),g}let[,u,f]=l,d=f.split(/\s+/).filter(Boolean);if(d.length===0)return Le(_e,r,[]),[];let h=ef[u.toLowerCase()];if(h?.multiValue){let g=h.multiValue(d,i);if(g){let p=g.map((y)=>`${o}${c?"-":""}${y}`);return Le(_e,r,p),p}}if(!h){let g=[];for(let p of d){let y=p.match(/^([a-z@][a-z0-9-]*):(.+)$/i),b="",w=p;if(y&&Rt.has(y[1]))b=`${y[1]}:`,w=y[2];let T="";if(w.startsWith("-"))T="-",w=w.slice(1);let S="";if(w.endsWith("!"))S="!",w=w.slice(0,-1);let j=c?"-":"";if(se(w))g.push(`${o}${b}${S}${j}${T}${u}-[${w}]`);else g.push(`${o}${b}${S}${j}${T}${u}-${w}`)}return Le(_e,r,g),g}let m=[];for(let g of d){let p=g.match(/^([a-z@][a-z0-9-]*):(.+)$/i),y="",b=g;if(p&&Rt.has(p[1]))y=`${p[1]}:`,b=p[2];let w="";if(b.startsWith("-"))w="-",b=b.slice(1);let T="";if(b.endsWith("!"))T="!",b=b.slice(0,-1);let S=h.expand(b,i);if(S){let j=c?"-":"";m.push(`${o}${y}${T}${j}${w}${S}`)}}return Le(_e,r,m),m}function of(e,t){let r=new Set;if(!t?.enabled)return r;let n=t.prefix??"tc-",i=["class","className","style","id","name","type","value","href","src","alt","title","role","for","action","method","target","rel","placeholder","disabled","checked","selected","readonly","required","maxlength","minlength","pattern","autocomplete","autofocus","tabindex","contenteditable","draggable","spellcheck","lang","dir","hidden","slot","part","is","key","ref"],o=t.ignoreAttributes||i,s=(l)=>{let u=l.includes(":")?l.split(":").pop():l;for(let f of o)if(f.endsWith("*")){if(u.startsWith(f.slice(0,-1)))return!0}else if(u===f)return!0;if(u.startsWith("on"))return!0;if(u.startsWith("data-")||u.startsWith("aria-"))return!0;return!1},c=/<([a-z][a-z0-9-]*)\s([^>]*)>/gi,a;while((a=c.exec(e))!==null){let l=a[2],u=/([a-z][a-z0-9-:]*)(?:=["']([^"']*)["'])?(?=\s|$|\/?>)/gi,f;while((f=u.exec(l))!==null){let d=f[1],h=f[2];if(n){if(!d.startsWith(n))continue;d=d.slice(n.length)}if(s(d))continue;let m="",g=d,p=d.match(/^((?:[a-z@][a-z0-9-]*:)+)([a-z][a-z0-9-]*)$/i);if(p){if(p[1].slice(0,-1).split(":").every((w)=>Rt.has(w)))m=p[1],g=p[2]}if(h!==void 0){let y=h.split(/\s+/).filter(Boolean);for(let b of y){let w=`${m}${g}-${b}`;if(wo(w.replace(/^(?:[a-z@][a-z0-9-]*:)+/gi,"")))r.add(w)}}else{let y=`${m}${g}`;if(wo(g))r.add(y)}}}return r}function wo(e){if(!e||e.length===0)return!1;return/^[a-z][a-z0-9-/]*(?:-\[[^\]]+\])?$/i.test(e)}function vn(e){let t=po.get(e);if(t)return t;let r=uf(e);return r.base=cf(r),Le(po,e,r),r}var sf=new Set(["bg","text","border","ring","placeholder","divide","accent","caret","fill","stroke","outline","decoration","shadow","ring-offset","from","via","to"]),af=/^(.+?)\/(\d+|\[\d*\.?\d+\])$/,lf=/^(\d+)\/(\d+)$/;function Co(e){let t=!1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===45){if(!t||r+1>=e.length)return;return[e.slice(0,r),e.slice(r+1)]}if(n>=97&&n<=122){t=!0;continue}return}return}function cf(e){let t=e.raw;for(let r of e.variants)if(t.startsWith(`${r}:`))t=t.slice(r.length+1);if(e.important){if(t.charCodeAt(0)===33)t=t.slice(1);else if(t.charCodeAt(t.length-1)===33)t=t.slice(0,-1)}return t}function uf(e){let t=!1,r=e;if(e.startsWith("!"))t=!0,r=e.slice(1);else if(e.endsWith("!")&&e.length>1)t=!0,r=e.slice(0,-1);{let h=kt(r),m=h[h.length-1],g=!1;if(m.charCodeAt(0)===33&&m.length>1)g=!0,m=m.slice(1);let p=m.match(/^\[([a-z-]+):(.+)\]$/);if(p)return{raw:e,variants:h.slice(0,-1),utility:p[1],value:Kt(p[2]),important:t||g,arbitrary:!0}}let n=r.match(/^((?:[a-z-]+:)*)(-?[a-z-]+?)-\[([^\]]+)\]\/\[([^\]]+)\]$/);if(n){let[,h,m,g,p]=n,y=h?h.split(":").filter(Boolean):[],b=m.startsWith("-"),w=b?m.slice(1):m,T=Kt(g);if(b)T=T.startsWith("-")?T:`-${T}`;return{raw:e,variants:y,utility:w,value:`${T}/${p}`,important:t,arbitrary:!0,modifierArbitrary:!0}}let i=r.match(/^((?:[a-z-]+:)*)(-?[a-z-]+?)-\[(.+)\]$/);if(i){let h=i[1],m=h?h.split(":").filter(Boolean):[],g=i[2],p=g.startsWith("-");if(p)g=g.slice(1);let y=Kt(i[3]),b,w=y.match(/^(color|length|url|number|percentage|position|line-width|absolute-size|relative-size|image|angle|time|flex|string|family-name):(.*)/i);if(w)b=w[1].toLowerCase(),y=w[2];if(p)y=y.startsWith("-")?y:`-${y}`;return{raw:e,variants:m,utility:g,value:y,important:t,arbitrary:!0,typeHint:b}}let o=kt(r),s=o[o.length-1],c=o.slice(0,-1);if(s.startsWith("!")&&s.length>1)t=!0,s=s.slice(1);else if(s.endsWith("!")&&s.length>1)t=!0,s=s.slice(0,-1);if(c.length>0)r=`${c.join(":")}:${s}`;else r=s;if(["inline-block","inline-flex","inline-grid","flex-row","flex-row-reverse","flex-col","flex-col-reverse","flex-wrap","flex-wrap-reverse","flex-nowrap","flex-1","flex-auto","flex-initial","flex-none","flex-grow","flex-shrink"].includes(s))return{raw:e,variants:c,utility:s,value:void 0,important:t,arbitrary:!1};let l=s.match(/^([a-z-]+?)-\[(.+?)\]$/);if(l){let h=Kt(l[2]),m,g=h.match(/^(color|length|url|number|percentage|position|line-width|absolute-size|relative-size|image|angle|time|flex|string|family-name):(.*)/i);if(g)m=g[1].toLowerCase(),h=g[2];return{raw:e,variants:c,utility:l[1],value:h,important:t,arbitrary:!0,typeHint:m}}let u=["inset-x","inset-y","border-t","border-r","border-b","border-l","border-x","border-y","border-s","border-e","grid-cols","grid-rows","grid-flow","auto-cols","auto-rows","col-span","row-span","col-start","col-end","row-start","row-end","translate-x","translate-y","translate-z","scale-x","scale-y","scale-z","rotate-x","rotate-y","rotate-z","skew-x","skew-y","scroll-m","scroll-mx","scroll-my","scroll-mt","scroll-mr","scroll-mb","scroll-ml","scroll-p","scroll-px","scroll-py","scroll-pt","scroll-pr","scroll-pb","scroll-pl","gap-x","gap-y","overflow-x","overflow-y","min-w","max-w","min-h","max-h","space-x","space-y","ring-offset","underline-offset","outline-offset","backdrop-blur","backdrop-brightness","backdrop-contrast","backdrop-grayscale","backdrop-invert","backdrop-saturate","backdrop-sepia","hue-rotate","drop-shadow","mask-clip","flex-grow","flex-shrink","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","perspective-origin","justify-self","form-input","form-textarea","form-select","form-multiselect","form-checkbox","form-radio","mix-blend","bg-blend","line-clamp","border-spacing","border-spacing-x","border-spacing-y","rounded-s","rounded-e","rounded-ss","rounded-se","rounded-es","rounded-ee","rounded-t","rounded-r","rounded-b","rounded-l","rounded-tl","rounded-tr","rounded-bl","rounded-br","border-opacity","ring-opacity","stroke-dasharray","stroke-dashoffset","animate-iteration","animate-duration","animate-delay","text-emphasis-color","text-emphasis","text-shadow","word-spacing","column-gap","column-rule","font-stretch","list-image"];if(s==="divide-x"||s==="divide-y")return{raw:e,variants:c,utility:s,value:void 0,important:t,arbitrary:!1};let f=s.match(/^(divide-[xy])-(.+)$/);if(f)return{raw:e,variants:c,utility:f[1],value:f[2],important:t,arbitrary:!1};for(let h of u)if(s.startsWith(`${h}-`))return{raw:e,variants:c,utility:h,value:s.slice(h.length+1),important:t,arbitrary:!1};if(s.startsWith("-")){let h=s.slice(1);for(let g of u)if(h.startsWith(`${g}-`))return{raw:e,variants:c,utility:g,value:`-${h.slice(g.length+1)}`,important:t,arbitrary:!1};let m=Co(h);if(m)return{raw:e,variants:c,utility:m[0],value:`-${m[1]}`,important:t,arbitrary:!1};return{raw:e,variants:c,utility:h,value:void 0,important:t,arbitrary:!1}}let d=Co(s);if(d){let[h,m]=d,g=m.match(af);if(g&&sf.has(h))return{raw:e,variants:c,utility:h,value:`${g[1]}/${g[2]}`,important:t,arbitrary:!1};let p=m.match(lf);if(p)return{raw:e,variants:c,utility:h,value:`${p[1]}/${p[2]}`,important:t,arbitrary:!1};return{raw:e,variants:c,utility:h,value:m,important:t,arbitrary:!1}}return{raw:e,variants:c,utility:s,value:void 0,important:t,arbitrary:!1}}function ff(e){return/^\[[a-z-]+:[^\]]+\]$/i.test(e)}function df(e){if(!e)return!1;if(e==="*"||e==="**")return!0;if(e.startsWith("[")&&e.endsWith("]"))return e.length>2;return/^(?:@[a-z0-9]|[a-z])[a-z0-9.-]*(?:\[[^\]]+\])?(?:\/[\w-]+)?$/i.test(e)}function hf(e,t){let r=e;if(r.startsWith("!"))r=r.slice(1);if(r.endsWith("!"))r=r.slice(0,-1);if(!r)return!1;if(ff(r))return!0;if(t?.enabled&&/^[a-z]+\[[^\]]+\]$/i.test(r))return!0;return/^[-@]?[a-z][a-z0-9.-]*(?:-\[[^\]]+\])?(?:\/(?:[\w.]+|[\w-]+|\[[^\]]+\]))?$/i.test(r)}function Ro(e,t){if(!e||e.length===0)return!1;if(t?.colonSyntax&&/^[a-z]+:[^[\]:]+$/i.test(e))return!0;let r=e;if(r.startsWith("!"))r=r.slice(1);if(r.endsWith("!"))r=r.slice(0,-1);if(!r)return!1;let n=kt(r);for(let i=0;i<n.length-1;i++)if(!df(n[i]))return!1;return hf(n[n.length-1],t)}function Gt(e){let t=[],r="",n=0;for(let i of e)if(i==="[")n++,r+=i;else if(i==="]")n--,r+=i;else if(/\s/.test(i)&&n===0){if(r)t.push(r),r=""}else r+=i;if(r)t.push(r);return t}function qt(e,t){let r=new Set,n=[/class(?:Name)?=["']([^"']+)["']/g,/class(?:Name)?=\{["']([^"']+)["']\}/g,/class(?:Name)?=\{`([^`]+)`\}/g];for(let o of n){let s;while((s=o.exec(e))!==null){let c=s[1],a=c.match(/["']([^"']+)["']/g);if(a)for(let f of a){let d=f.replace(/["']/g,""),h=Gt(d);for(let m of h)Ht(r,m,t)}let l=c.replace(/["'`]/g," ").replace(/\$\{[^}]+\}/g," "),u=Gt(l).filter((f)=>Ro(f,t?.bracketSyntax));for(let f of u)Ht(r,f,t)}}let i=[/class(?:Name|:list)?=\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,/:class="([^"]*)"/g,/:class='([^']*)'/g,/\bx-class="([^"]*)"/g,/\bx-class='([^']*)'/g];for(let o of i){let s;while((s=o.exec(e))!==null){let c=s[1].match(/["'`]([^"'`]+)["'`]/g);if(c)for(let a of c){let l=a.replace(/["'`]/g,"").replace(/\$\{[^}]+\}/g," ");for(let u of Gt(l))Ht(r,u,t)}}}if(t?.codeStrings?.enabled!==!1)for(let o of ko(e,t?.bracketSyntax))Ht(r,o,t);if(t?.attributify?.enabled){let o=of(e,t.attributify);for(let s of o)r.add(s)}return r}function gf(e,t){if(!/[-:/[]/.test(e))return!1;if(e.startsWith("-")&&!/^-[a-z]/i.test(e))return!1;return Ro(e,t)}function ko(e,t){let r=new Set,n=e.length,i=0,o=/[<>]/g,s=o.exec(e),c=-1,a=-1,l="";while(i<n){let u=e[i];if(u==="/"&&e[i+1]==="/"){let p=e.indexOf(`
92
+ `,i);i=p===-1?n:p;continue}if(u==="/"&&e[i+1]==="*"){let p=e.indexOf("*/",i+2);i=p===-1?n:p+2;continue}if(u==="/"&&(!/[\w$)\]]/.test(l)||pf(e,i))){let p=yf(e,i);if(p!==-1){i=p,l=")";continue}}if(u!=='"'&&u!=="'"&&u!=="`"){if(!/\s/.test(u))l=u;i++;continue}l=")";while(s&&s.index<i){if(s[0]==="<")c=s.index;else a=s.index;s=o.exec(e)}let f=xf(e,i,c,a),d=u==="`",h=i+1,m="",g=!1;while(h<n){let p=e[h];if(p==="\\"){m+=e[h+1]??"",h+=2;continue}if(p===u){g=!0,h++;break}if(!d&&p===`
93
+ `)break;if(d&&p==="$"&&e[h+1]==="{"){let y=1;h+=2;let b=h;while(h<n&&y>0){if(e[h]==="{")y++;else if(e[h]==="}")y--;h++}for(let w of ko(e.slice(b,h-1),t))r.add(w);m+=" ";continue}m+=p,h++}if(g){if(f){for(let p of m.match(bf)??[])r.add(p);i=h;continue}for(let p of Gt(m))if(gf(p,t))r.add(p);i=h}else i++}return r}var mf=new Set(["return","typeof","case","in","of","delete","void","throw","new","else","do","yield","await","instanceof"]);function pf(e,t){let r=t;while(r>0&&/\s/.test(e[r-1]))r--;let n=r;while(n>0&&/[\w$]/.test(e[n-1]))n--;if(n===r||!mf.has(e.slice(n,r)))return!1;let i=n;while(i>0&&/\s/.test(e[i-1]))i--;return e[i-1]!=="."}function yf(e,t){let r=!1;for(let n=t+1;n<e.length;n++){let i=e[n];if(i===`
94
+ `)return-1;if(i==="\\"){n++;continue}if(i==="[")r=!0;else if(i==="]")r=!1;else if(i==="/"&&!r){let o=n+1;while(o<e.length&&/[a-z]/i.test(e[o]))o++;return o}}return-1}var bf=/(?<![\w-])i-[a-z0-9]+(?:-[a-z0-9]+)+(?![\w-])/gi;function xf(e,t,r,n){if(r<=n)return!1;let i=e[r+1];if(!i||!/[A-Za-z!/]/.test(i))return!1;let o=t-1;while(o>r&&/\s/.test(e[o]))o--;if(e[o]==="=")return!0;if(e[o]==="{"){o--;while(o>r&&/\s/.test(e[o]))o--;return e[o]==="="}return!1}function Ht(e,t,r){if(r?.bracketSyntax?.enabled){let n=/^[a-z]+\[[^\]]+\]$/i.test(t),i=r.bracketSyntax.colonSyntax&&/^[a-z]+:[^[\]]+$/i.test(t);if(n||i){let o=nf(t,r.bracketSyntax);for(let s of o)e.add(s);return}}e.add(t)}var Yt={getCSS:()=>`
95
95
  /*
96
96
  ! Tailwind CSS Preflight | MIT License | https://tailwindcss.com
97
97
  */