styimat 4.2.0 → 4.3.0

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/styimat.js CHANGED
@@ -34,7 +34,7 @@ const styimat = (function() {
34
34
  importCache: true,
35
35
  importTimeout: 5000,
36
36
  enableAlias: true,
37
- enableMacros: true,
37
+ enableMacros: true
38
38
  };
39
39
 
40
40
  // 全局P3支持检测结果
@@ -49,6 +49,8 @@ const styimat = (function() {
49
49
  // 宏定义存储
50
50
  const macroRegistry = new Map();
51
51
 
52
+ const pluginMap = new Map();
53
+
52
54
  /**
53
55
  * 解析配置头
54
56
  */
@@ -386,7 +388,7 @@ const styimat = (function() {
386
388
  /**
387
389
  * 解析一行CSS
388
390
  */
389
- function parseSingleLineCSS(cssString, aliases=[]) {
391
+ function parseSingleLineCSS(cssString, aliases, macros) {
390
392
  let str = cssString.trim();
391
393
 
392
394
  if (str.endsWith(';')) {
@@ -459,6 +461,13 @@ const styimat = (function() {
459
461
  property = aliases.get(property);
460
462
  }
461
463
 
464
+ if (property.startsWith("@") && macros.get(property.slice(1))) {
465
+ const macro = macros.get(property.slice(1));
466
+ const args = parseMacroArguments(value.split(" ").join(","), macro.params);
467
+ property = applyMacro(macro.body, args, config);
468
+ value = "";
469
+ }
470
+
462
471
  result.push({ [property]: value });
463
472
  }
464
473
 
@@ -1143,7 +1152,7 @@ const styimat = (function() {
1143
1152
  /**
1144
1153
  * 解析嵌套规则
1145
1154
  */
1146
- function parseNestedRules(cssText, config, aliases) {
1155
+ function parseNestedRules(cssText, config, aliases, macros) {
1147
1156
  const lines = cssText.split('\n');
1148
1157
  const stack = [];
1149
1158
  const rootRules = [];
@@ -1188,11 +1197,12 @@ const styimat = (function() {
1188
1197
  if (!trimmed.includes('{') && !trimmed.includes('}') && trimmed.includes(':')) {
1189
1198
  if (stack.length > 0) {
1190
1199
  const currentRule = stack[stack.length - 1];
1191
- const parsed = parseSingleLineCSS(trimmed, aliases);
1200
+ const parsed = parseSingleLineCSS(trimmed, aliases, macros);
1192
1201
  parsed.forEach(obj => {
1193
1202
  const key = Object.keys(obj)[0];
1194
1203
  const value = processCSSValue(obj[key], config);
1195
- currentRule.properties.push(`${key}: ${value}`);
1204
+
1205
+ currentRule.properties.push(value === "" ? key : `${key}: ${value}`);
1196
1206
  });
1197
1207
  }
1198
1208
  continue;
@@ -1210,13 +1220,13 @@ const styimat = (function() {
1210
1220
  }
1211
1221
  }
1212
1222
 
1213
- return convertRulesToCSS(rootRules, config, '', aliases);
1223
+ return convertRulesToCSS(rootRules, config, '', aliases, macros);
1214
1224
  }
1215
1225
 
1216
1226
  /**
1217
1227
  * 将规则树转换为CSS字符串
1218
1228
  */
1219
- function convertRulesToCSS(rules, config, parentSelector = '', aliases=[]) {
1229
+ function convertRulesToCSS(rules, config, parentSelector = '', aliases, macros) {
1220
1230
  let result = '';
1221
1231
  const isParentAt = parentSelector.startsWith("@");
1222
1232
 
@@ -1241,18 +1251,18 @@ const styimat = (function() {
1241
1251
  if (rule.properties.length > 0) {
1242
1252
  result += (isAt ? "" : fullSelector) + ' {\n';
1243
1253
  for (const prop of rule.properties) {
1244
- const parsed = parseSingleLineCSS(prop, aliases);
1254
+ const parsed = parseSingleLineCSS(prop, aliases, macros);
1245
1255
  parsed.forEach(obj => {
1246
1256
  const key = Object.keys(obj)[0];
1247
1257
  const value = processCSSValue(obj[key], config);
1248
- result += (isParentAt ? " ".repeat(config.indentSize) : '') + " ".repeat(config.indentSize) +`${key}: ${value};\n`;
1258
+ result += (isParentAt ? " ".repeat(config.indentSize) : '') + " ".repeat(config.indentSize) + (value === "" ? key : `${key}: ${value};\n`);
1249
1259
  });
1250
1260
  }
1251
1261
  result += isParentAt ? " ".repeat(config.indentSize) + '}\n' : '}\n\n';
1252
1262
  }
1253
1263
 
1254
1264
  if (rule.children && rule.children.length > 0) {
1255
- result += convertRulesToCSS(rule.children, config, fullSelector, aliases);
1265
+ result += convertRulesToCSS(rule.children, config, fullSelector, aliases, macros);
1256
1266
  }
1257
1267
 
1258
1268
  if (isParentAt){
@@ -1327,13 +1337,6 @@ const styimat = (function() {
1327
1337
  }
1328
1338
 
1329
1339
  if (trimmed === '}' && currentSelector) {
1330
- if (selectorVariables.has(currentSelector)) {
1331
- const vars = selectorVariables.get(currentSelector);
1332
- const indent = line.match(/^(\s*)/)[0];
1333
- for (const [varName, varValue] of Object.entries(vars)) {
1334
- result += ' --' + varName + ': ' + varValue + ';\n';
1335
- }
1336
- }
1337
1340
  currentSelector = null;
1338
1341
  }
1339
1342
 
@@ -1489,7 +1492,7 @@ const styimat = (function() {
1489
1492
  let processedCSS = cssWithoutVars.trim();
1490
1493
  if (finalConfig.enableNesting && cssWithoutVars.includes('{')) {
1491
1494
  try {
1492
- processedCSS = parseNestedRules(cssWithoutVars, finalConfig, aliases);
1495
+ processedCSS = parseNestedRules(cssWithoutVars, finalConfig, aliases, macros);
1493
1496
  } catch (error) {
1494
1497
  console.warn('嵌套解析失败,使用原始CSS:', error);
1495
1498
  }
@@ -1504,7 +1507,17 @@ const styimat = (function() {
1504
1507
 
1505
1508
  finalCSS = replaceVariableUses(finalCSS, globalVariables, selectorVariables, finalConfig);
1506
1509
 
1507
- return rootRule + finalCSS;
1510
+ for (const [name, plugin] of pluginMap) {
1511
+ try {
1512
+ if(plugin.enable) finalCSS = plugin.convert(finalCSS, finalConfig);
1513
+ } catch (error) {
1514
+ console.error('插件处理失败:', error);
1515
+ }
1516
+ }
1517
+
1518
+ let fullCSS = rootRule + finalCSS;
1519
+
1520
+ return fullCSS;
1508
1521
  };
1509
1522
 
1510
1523
  const hasImports = cssText && /@import\s+([^;]+?)\s*;/g.test(cssText);
@@ -1632,6 +1645,40 @@ const styimat = (function() {
1632
1645
  }
1633
1646
  },
1634
1647
 
1648
+ plugins: new Proxy({},{
1649
+ set(target, name, plugin) {
1650
+ const createdFunc = plugin.created ?? (() => {});
1651
+ createdFunc();
1652
+ pluginMap.set(name, plugin);
1653
+ return true;
1654
+ },
1655
+ get(target, name) {
1656
+ return pluginMap.get(name);
1657
+ },
1658
+ deleteProperty(target, name) {
1659
+ pluginMap.get(name)?.deleted();
1660
+ pluginMap.delete(name);
1661
+ return true;
1662
+ },
1663
+ has(terget, name) {
1664
+ return pluginMap.has(name);
1665
+ },
1666
+ ownKeys() {
1667
+ return Array.from(pluginMap.keys());
1668
+ },
1669
+ getOwnPropertyDescriptor(target, prop) {
1670
+ if (pluginMap.has(prop)) {
1671
+ return {
1672
+ enumerable: true,
1673
+ configurable: true,
1674
+ writable: true,
1675
+ value: pluginMap.get(prop)
1676
+ };
1677
+ }
1678
+ return undefined;
1679
+ }
1680
+ }),
1681
+
1635
1682
  aliases: {
1636
1683
  add: function(alias, property) {
1637
1684
  aliasMap.set(alias, property);
@@ -1918,7 +1965,7 @@ const styimat = (function() {
1918
1965
  })();
1919
1966
 
1920
1967
  if (typeof define === 'function' && define.amd) {
1921
- define([], ()=>styimat);
1968
+ define([], _=>styimat);
1922
1969
  } else if (typeof module === 'object' && module.exports) {
1923
1970
  module.exports = styimat;
1924
1971
  } else {
@@ -1,34 +1,33 @@
1
1
  /*!
2
2
  * MIT License
3
3
  * Copyright (c) 2025 王小玗
4
- */const styimat=(function(){let d={rootSelector:":root",variablePrefix:"--",preserveOriginal:!1,indentSize:4,enableNesting:!0,autoProcessStyleTags:!0,styleTagAttribute:"e",convertLabToRGB:!0,convertLchToRGB:!0,enableP3:!0,enableMath:!0,mathPrecision:6,importBaseUrl:"",importCache:!0,importTimeout:5e3,enableAlias:!0,enableMacros:!0},x=null;const V=new Map,B=new Map,v=new Map;function ee(e){const t={...d},n=e.split(`
5
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("#")){const a=o.substring(1).trim(),c=a.indexOf(" ");if(c!==-1){const l=a.substring(0,c).trim(),i=a.substring(c+1).trim(),u=se(l);u in t?i==="true"||i==="false"?t[u]=i==="true":!isNaN(i)&&i.trim()!==""?t[u]=Number(i):t[u]=i:console.warn(`\u672A\u77E5\u7684\u914D\u7F6E\u9879: ${l}`)}else console.warn(`\u65E0\u6548\u7684\u914D\u7F6E\u884C: ${o}`)}else s.push(r)}return{config:t,css:s.join(`
6
- `)}}function te(e){const t=new Map,n=e.split(`
7
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("@alias")){const a=o.match(/^@alias\s+([a-zA-Z0-9_-]+)\s+(.+?)\s*;$/);if(a){const c=a[1],l=a[2];t.set(c,l);continue}}s.push(r)}return{aliases:t,css:s.join(`
8
- `)}}function N(e,t){if(!t.enableMacros)return{macros:new Map,css:e};const n=new Map,s=e.split(`
9
- `),r=[];let o=!1,a="",c=[],l=[],i=0;for(let u of s){const p=u.trim();if(!o&&p.startsWith("@macro")){const f=p.match(/^@macro\s+([a-zA-Z0-9_-]+)\s*\(([^)]*)\)\s*\{$/);if(f){o=!0,a=f[1],c=f[2].split(",").map(h=>h.trim()).filter(h=>h).map(h=>{const m=h.split(":").map(y=>y.trim());return{name:m[0].slice(1),defaultValue:m[1]||null}}),l=[],i=1;continue}}if(o){for(const f of u)f==="{"&&i++,f==="}"&&i--;i===0?(n.set(a,{params:c,body:l.join(`
10
- `)}),o=!1,a="",c=[],l=[]):l.push(u);continue}r.push(u)}return{macros:n,css:r.join(`
11
- `)}}function ne(e,t,n){if(!n.enableMacros||t.size===0)return e;const s=Array.from(t.keys()).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),r=new RegExp(`@(${s})\\s*\\(([^)]*)\\)\\s*;?`,"g");return(a=>{let c=a,l=!1;do l=!1,c=c.replace(r,(i,u,p)=>{l=!0;const f=t.get(u);if(!f)return console.warn(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${u}`),i;const h=H(p,f.params);return W(f.body,h,n)});while(l);return c})(e)}function H(e,t){const n=new Map,s=re(e);for(let r=0;r<t.length;r++){const o=t[r];let a;r<s.length?a=s[r]:o.defaultValue!==null?a=o.defaultValue:(console.warn(`\u5B8F\u8C03\u7528\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${o.name}`),a=""),n.set(o.name,a)}return s.length>t.length&&console.warn("\u5B8F\u8C03\u7528\u4F20\u9012\u4E86\u8FC7\u591A\u53C2\u6570\uFF0C\u591A\u4F59\u7684\u53C2\u6570\u5C06\u88AB\u5FFD\u7565"),n}function re(e){const t=[];let n="",s=!1,r="",o=0,a=0;for(let c=0;c<e.length;c++){const l=e[c];(l==='"'||l==="'")&&!s?(s=!0,r=l):l===r&&s&&(s=!1,r=""),s||(l==="("&&o++,l===")"&&o--,l==="["&&a++,l==="]"&&a--),l===","&&!s&&o===0&&a===0?(t.push(n.trim()),n=""):n+=l}return n.trim()&&t.push(n.trim()),t}function W(e,t,n){let s=e;for(const[r,o]of t){const a=new RegExp(`\\$${r}`,"g");s=s.replace(a,o)}if(n.enableMacros){const r=Array.from(v.keys()).map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");if(r){const o=new RegExp(`@(${r})\\s*\\(([^)]*)\\)\\s*;?`,"g");let a;do a=!1,s=s.replace(o,(c,l,i)=>{a=!0;const u=v.get(l);if(!u)return c;const p=H(i,u.params);return W(u.body,p,n)});while(a)}}return s=R(s,n),s}function se(e){return e.replace(/-([a-z])/g,function(t,n){return n.toUpperCase()})}function O(){if(x!==null)return x;if(typeof window>"u"||!window.CSS)return x=!1,!1;try{x=CSS.supports("color","color(display-p3 1 0 0)")}catch(e){console.warn("P3\u652F\u6301\u68C0\u6D4B\u5931\u8D25:",e),x=!1}return x}function G(e,t=[]){let n=e.trim();if(n.endsWith(";")&&(n=n.slice(0,-1)),!n)return[];const s=[];let r="",o=0,a=!1,c="";for(let i=0;i<n.length;i++){const u=n[i];(u==='"'||u==="'")&&!a?(a=!0,c=u):u===c&&a&&(a=!1,c=""),a||(u==="("?o++:u===")"&&o--),u===";"&&!a&&o===0?r.trim()&&(s.push(r.trim()),r=""):r+=u}r.trim()&&s.push(r.trim());const l=[];for(const i of s){if(!i.trim())continue;const u=oe(i);if(u===-1){console.warn(`\u65E0\u6548\u7684CSS\u58F0\u660E: "${i}"`);continue}let p=i.substring(0,u).trim(),f=i.substring(u+1).trim();f.endsWith(";")&&(f=f.slice(0,-1).trim()),t.get(p)&&(p=t.get(p)),l.push({[p]:f})}return l}function oe(e){let t=!1,n="";for(let s=0;s<e.length;s++){const r=e[s];if((r==='"'||r==="'")&&!t?(t=!0,n=r):r===n&&t&&(t=!1,n=""),r===":"&&!t)return s}return-1}function _(e,t){if(!t.enableMath)return`math(${e})`;try{let n=e.replace(/\s+/g,"");const s=U(n,t);return ae(n)?ce(n,s):q(s,t.mathPrecision)}catch(n){return console.warn("math()\u8868\u8FBE\u5F0F\u89E3\u6790\u5931\u8D25:",e,n),`math(${e})`}}function U(e,t){for(;e.includes("(")&&e.includes(")");){const n=e.lastIndexOf("("),s=e.indexOf(")",n);if(s===-1)break;const r=e.substring(n+1,s),o=U(r,t);e=e.substring(0,n)+o+e.substring(s+1)}return X(e,t)}function X(e,t){const n=[{regex:/([\d.]+(?:[a-zA-Z%]+)?)\*([\d.]+(?:[a-zA-Z%]+)?)/,handler:le},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\/([\d.]+(?:[a-zA-Z%]+)?)/,handler:ie},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\+([\d.]+(?:[a-zA-Z%]+)?)/,handler:ue},{regex:/([\d.]+(?:[a-zA-Z%]+)?)-([\d.]+(?:[a-zA-Z%]+)?)/,handler:fe}];let s=e;for(const o of n){let a;for(;(a=e.match(o.regex))!==null;){const c=z(a[1]),l=z(a[2]),i=o.handler(c,l);e=e.substring(0,a.index)+i.value+e.substring(a.index+a[0].length)}}return e!==s?X(e,t):z(e).value}function z(e){const t=e.match(/^([\d.]+)([a-zA-Z%]*)$/);if(!t)throw new Error(`\u65E0\u6CD5\u89E3\u6790\u503C: ${e}`);const n=parseFloat(t[1]),s=t[2]||"";return{value:n,unit:s}}function ae(e){return/[a-zA-Z%]/.test(e)}function ce(e,t){const n=e.match(/([a-zA-Z%]+)(?!.*[a-zA-Z%])/);return n?t+n[1]:e.includes("%")?t+"%":t+"px"}function le(e,t){return e.unit===t.unit||!e.unit&&!t.unit?{value:e.value*t.value,unit:e.unit||t.unit}:{value:`${e.value}${e.unit}*${t.value}${t.unit}`,unit:""}}function ie(e,t){if(t.value===0)throw new Error("\u9664\u4EE5\u96F6");return e.unit&&!t.unit?{value:e.value/t.value,unit:e.unit}:e.unit===t.unit?{value:e.value/t.value,unit:""}:{value:`${e.value}${e.unit}/${t.value}${t.unit}`,unit:""}}function ue(e,t){return e.unit===t.unit?{value:e.value+t.value,unit:e.unit}:{value:`${e.value}${e.unit}+${t.value}${t.unit}`,unit:""}}function fe(e,t){return e.unit===t.unit?{value:e.value-t.value,unit:e.unit}:{value:`${e.value}${e.unit}-${t.value}${t.unit}`,unit:""}}function q(e,t=6){const n=Math.pow(10,t),r=(Math.round(e*n)/n).toString();return r.includes(".")?r.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""):r}function pe(e,t){if(!t.enableMath)return e;let n=e;const s=/math\(([^)]+)\)/gi,r=a=>a.replace(s,(c,l)=>_(l,t));let o;do o=n,n=r(n);while(n!==o&&n.includes("math("));return n}function he(e,t){if(!t.convertLabToRGB&&!t.convertLchToRGB)return e;let n=e;n=de(n,t);const s=/(lab|lch)\([^)]+\)/gi,r=new Map,o=c=>c.replace(s,l=>{if(r.has(l))return r.get(l);let i=l;return l.toLowerCase().startsWith("lab(")?t.convertLabToRGB&&(i=me(l,t)):l.toLowerCase().startsWith("lch(")&&t.convertLchToRGB&&(i=ge(l,t)),r.set(l,i),i});let a;do a=n,n=o(n);while(n!==a);return n}function de(e,t){let n=e;const s=/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/gi,r=/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/gi,o=new Map;return n=n.replace(s,(a,c,l,i)=>{if(o.has(a))return o.get(a);try{const u=parseInt(c,16)/255*100,p=(parseInt(l,16)-128)*1.5,f=(parseInt(i,16)-128)*1.5,h=L(u,p,f,t);return o.set(a,h),h}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lab#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n=n.replace(r,(a,c,l,i)=>{if(o.has(a))return o.get(a);try{const u=parseInt(c,16)/255*100,p=parseInt(l,16)/255*150,f=parseInt(i)/100*360,h=A(u,p,f),m=L(h.L,h.a,h.b,t);return o.set(a,m),m}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lch#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n}function me(e,t){const n=/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=e.match(n);if(!s)return e;try{let r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]),a=parseFloat(s[4]),c=s[5]!==void 0?s[5].includes("%")?parseFloat(s[5])/100:parseFloat(s[5]):null;return L(r,o,a,t,c)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LAB\u989C\u8272: ${e}`,r),e}}function ge(e,t){const n=/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=e.match(n);if(!s)return e;try{let r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]);let a=parseFloat(s[4]);o<0&&console.warn(`LCH\u4E2D\u7684C\u503C\u4E0D\u80FD\u4E3A\u8D1F: ${o}`),a=(a%360+360)%360;const c=A(r,o,a),l=s[6]!==void 0?s[6].includes("%")?parseFloat(s[6])/100:parseFloat(s[6]):null;return L(c.L,c.a,c.b,t,l)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LCH\u989C\u8272: ${e}`,r),e}}function A(e,t,n){const s=n*Math.PI/180,r=t*Math.cos(s),o=t*Math.sin(s);return{L:e,a:r,b:o}}function C(e,t,n){const s=(g,b,$)=>{const I=(g+16)/116,Z=b/500+I,j=I-$/200,Le=Z**3>.008856?Z**3:(116*Z-16)/903.3,Re=g>903.3*.008856?((g+16)/116)**3:g/903.3,xe=j**3>.008856?j**3:(116*j-16)/903.3;return[Le*.95047,Re*1,xe*1.08883]},r=(g,b,$)=>{const w=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]],M=w[0][0]*g+w[0][1]*b+w[0][2]*$,S=w[1][0]*g+w[1][1]*b+w[1][2]*$,F=w[2][0]*g+w[2][1]*b+w[2][2]*$;return[M,S,F]},o=g=>{const b=g<0?-1:1,$=Math.abs(g);return $<=.0031308?b*12.92*$:b*(1.055*Math.pow($,.4166666666666667)-.055)},a=g=>Math.max(0,Math.min(255,Math.round(g*255))),[c,l,i]=s(e,t,n),[u,p,f]=r(c,l,i),h=o(u),m=o(p),y=o(f);return{r:a(h),g:a(m),b:a(y)}}function E(e,t,n){const s=(c,l,i)=>{const y=(c+16)/116,g=l/500+y,b=y-i/200,$=g**3>.008856?g**3:(116*g-16)/903.3,w=c>903.3*.008856?((c+16)/116)**3:c/903.3,M=b**3>.008856?b**3:(116*b-16)/903.3;return[$*.95047,w*1,M*1.08883]},r=(c,l,i)=>{const u=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]],p=u[0][0]*c+u[0][1]*l+u[0][2]*i,f=u[1][0]*c+u[1][1]*l+u[1][2]*i,h=u[2][0]*c+u[2][1]*l+u[2][2]*i;return[p,f,h]},o=c=>{const l=c<0?-1:1,i=Math.abs(c);return i<=.0031308?l*12.92*i:l*(1.055*Math.pow(i,.4166666666666667)-.055)},a=c=>Math.max(0,Math.min(255,Math.round(c*255)));try{const[c,l,i]=s(e,t,n),[u,p,f]=r(c,l,i),h=o(u),m=o(p),y=o(f);return{r:Math.max(0,Math.min(1,h)),g:Math.max(0,Math.min(1,m)),b:Math.max(0,Math.min(1,y))}}catch(c){console.warn("P3\u8F6C\u6362\u5931\u8D25:",c);const l=C(e,t,n);return{r:l.r/255,g:l.g/255,b:l.b/255}}}function L(e,t,n,s,r=null){if(!s.enableP3||!O()){const o=C(e,t,n);return r!==null?`rgba(${o.r}, ${o.g}, ${o.b}, ${r})`:`rgb(${o.r}, ${o.g}, ${o.b})`}else{const o=E(e,t,n);return r!==null?`color(display-p3 ${o.r.toFixed(4)} ${o.g.toFixed(4)} ${o.b.toFixed(4)} / ${r})`:`color(display-p3 ${o.r.toFixed(4)} ${o.g.toFixed(4)} ${o.b.toFixed(4)})`}}function R(e,t){let n=e;return t.enableMath&&(n=pe(n,t)),(t.convertLabToRGB||t.convertLchToRGB)&&(n=he(n,t)),n}function be(e,t){const n=e.split(`
12
- `),s={},r=new Map;let o="",a=null,c=!1,l=0;for(let i of n){const u=i.trim(),p=u.match(/^\$([a-zA-Z0-9_-]+)\s*:\s*(.+?);?$/);if(p){const[,f,h]=p,m=R(Y(h.trim(),{...s,...a?r.get(a)||{}:{}}),t);a?(r.has(a)||r.set(a,{}),r.get(a)[f]=m):s[f]=m;continue}if(u.endsWith("{")){a=u.slice(0,-1).trim(),c=!0,o+=i+`
13
- `;continue}if(u==="}"){if(c&&a&&r.has(a)){const f=r.get(a),h=" ".repeat(l);for(const[m,y]of Object.entries(f))o+=`${h} --${m}: ${y};
14
- `}c=!1,a=null}o+=i+`
15
- `,i.includes("{")&&(l+=t.indentSize),i.includes("}")&&(l=Math.max(0,l-t.indentSize))}return{globalVariables:s,selectorVariables:r,cssWithoutVars:o.trim()}}function ye(e,t,n){const s=e.split(`
16
- `),r=[],o=[];let a=0;for(let c=0;c<s.length;c++){const l=s[c],i=l.trim();if(!i)continue;const u=l.match(/^(\s*)/)[0].length;if(i==="}"){if(r.length>0){const p=r.pop();if(r.length>0){const f=r[r.length-1];f.children||(f.children=[]),f.children.push(p)}else o.push(p)}continue}if(i.endsWith("{")){const f={selector:i.slice(0,-1).trim(),properties:[],children:[]};r.push(f);continue}if(!i.includes("{")&&!i.includes("}")&&i.includes(":")){if(r.length>0){const p=r[r.length-1];G(i,n).forEach(h=>{const m=Object.keys(h)[0],y=R(h[m],t);p.properties.push(`${m}: ${y}`)})}continue}}for(;r.length>0;){const c=r.pop();if(r.length===0)o.push(c);else{const l=r[r.length-1];l.children||(l.children=[]),l.children.push(c)}}return D(o,t,"",n)}function D(e,t,n="",s=[]){let r="";const o=n.startsWith("@");for(const a of e){const c=a.selector.startsWith("@");let l=(o?" ".repeat(t.indentSize):"")+a.selector;if(c&&(l=a.selector+` {
17
- `),n&&(l.includes("&")?l=l.replace(/&/g,n):l.trim().startsWith(":")?l=n+l:l=n+(o?"":" ")+l),a.properties.length>0){r+=(c?"":l)+` {
18
- `;for(const i of a.properties)G(i,s).forEach(p=>{const f=Object.keys(p)[0],h=R(p[f],t);r+=(o?" ".repeat(t.indentSize):"")+" ".repeat(t.indentSize)+`${f}: ${h};
19
- `});r+=o?" ".repeat(t.indentSize)+`}
4
+ */const styimat=(function(){let g={rootSelector:":root",variablePrefix:"--",preserveOriginal:!1,indentSize:4,enableNesting:!0,autoProcessStyleTags:!0,styleTagAttribute:"e",convertLabToRGB:!0,convertLchToRGB:!0,enableP3:!0,enableMath:!0,mathPrecision:6,importBaseUrl:"",importCache:!0,importTimeout:5e3,enableAlias:!0,enableMacros:!0},F=null;const I=new Map,_=new Map,M=new Map,C=new Map;function ne(t){const e={...g},n=t.split(`
5
+ `),s=[];for(let o of n){const r=o.trim();if(r.startsWith("#")){const a=r.substring(1).trim(),c=a.indexOf(" ");if(c!==-1){const l=a.substring(0,c).trim(),i=a.substring(c+1).trim(),u=ae(l);u in e?i==="true"||i==="false"?e[u]=i==="true":!isNaN(i)&&i.trim()!==""?e[u]=Number(i):e[u]=i:console.warn(`\u672A\u77E5\u7684\u914D\u7F6E\u9879: ${l}`)}else console.warn(`\u65E0\u6548\u7684\u914D\u7F6E\u884C: ${r}`)}else s.push(o)}return{config:e,css:s.join(`
6
+ `)}}function re(t){const e=new Map,n=t.split(`
7
+ `),s=[];for(let o of n){const r=o.trim();if(r.startsWith("@alias")){const a=r.match(/^@alias\s+([a-zA-Z0-9_-]+)\s+(.+?)\s*;$/);if(a){const c=a[1],l=a[2];e.set(c,l);continue}}s.push(o)}return{aliases:e,css:s.join(`
8
+ `)}}function U(t,e){if(!e.enableMacros)return{macros:new Map,css:t};const n=new Map,s=t.split(`
9
+ `),o=[];let r=!1,a="",c=[],l=[],i=0;for(let u of s){const h=u.trim();if(!r&&h.startsWith("@macro")){const p=h.match(/^@macro\s+([a-zA-Z0-9_-]+)\s*\(([^)]*)\)\s*\{$/);if(p){r=!0,a=p[1],c=p[2].split(",").map(f=>f.trim()).filter(f=>f).map(f=>{const d=f.split(":").map(b=>b.trim());return{name:d[0].slice(1),defaultValue:d[1]||null}}),l=[],i=1;continue}}if(r){for(const p of u)p==="{"&&i++,p==="}"&&i--;i===0?(n.set(a,{params:c,body:l.join(`
10
+ `)}),r=!1,a="",c=[],l=[]):l.push(u);continue}o.push(u)}return{macros:n,css:o.join(`
11
+ `)}}function se(t,e,n){if(!n.enableMacros||e.size===0)return t;const s=Array.from(e.keys()).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),o=new RegExp(`@(${s})\\s*\\(([^)]*)\\)\\s*;?`,"g");return(a=>{let c=a,l=!1;do l=!1,c=c.replace(o,(i,u,h)=>{l=!0;const p=e.get(u);if(!p)return console.warn(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${u}`),i;const f=O(h,p.params);return k(p.body,f,n)});while(l);return c})(t)}function O(t,e){const n=new Map,s=oe(t);for(let o=0;o<e.length;o++){const r=e[o];let a;o<s.length?a=s[o]:r.defaultValue!==null?a=r.defaultValue:(console.warn(`\u5B8F\u8C03\u7528\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${r.name}`),a=""),n.set(r.name,a)}return s.length>e.length&&console.warn("\u5B8F\u8C03\u7528\u4F20\u9012\u4E86\u8FC7\u591A\u53C2\u6570\uFF0C\u591A\u4F59\u7684\u53C2\u6570\u5C06\u88AB\u5FFD\u7565"),n}function oe(t){const e=[];let n="",s=!1,o="",r=0,a=0;for(let c=0;c<t.length;c++){const l=t[c];(l==='"'||l==="'")&&!s?(s=!0,o=l):l===o&&s&&(s=!1,o=""),s||(l==="("&&r++,l===")"&&r--,l==="["&&a++,l==="]"&&a--),l===","&&!s&&r===0&&a===0?(e.push(n.trim()),n=""):n+=l}return n.trim()&&e.push(n.trim()),e}function k(t,e,n){let s=t;for(const[o,r]of e){const a=new RegExp(`\\$${o}`,"g");s=s.replace(a,r)}if(n.enableMacros){const o=Array.from(M.keys()).map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");if(o){const r=new RegExp(`@(${o})\\s*\\(([^)]*)\\)\\s*;?`,"g");let a;do a=!1,s=s.replace(r,(c,l,i)=>{a=!0;const u=M.get(l);if(!u)return c;const h=O(i,u.params);return k(u.body,h,n)});while(a)}}return s=x(s,n),s}function ae(t){return t.replace(/-([a-z])/g,function(e,n){return n.toUpperCase()})}function Z(){if(F!==null)return F;if(typeof window>"u"||!window.CSS)return F=!1,!1;try{F=CSS.supports("color","color(display-p3 1 0 0)")}catch(t){console.warn("P3\u652F\u6301\u68C0\u6D4B\u5931\u8D25:",t),F=!1}return F}function X(t,e,n){let s=t.trim();if(s.endsWith(";")&&(s=s.slice(0,-1)),!s)return[];const o=[];let r="",a=0,c=!1,l="";for(let u=0;u<s.length;u++){const h=s[u];(h==='"'||h==="'")&&!c?(c=!0,l=h):h===l&&c&&(c=!1,l=""),c||(h==="("?a++:h===")"&&a--),h===";"&&!c&&a===0?r.trim()&&(o.push(r.trim()),r=""):r+=h}r.trim()&&o.push(r.trim());const i=[];for(const u of o){if(!u.trim())continue;const h=ce(u);if(h===-1){console.warn(`\u65E0\u6548\u7684CSS\u58F0\u660E: "${u}"`);continue}let p=u.substring(0,h).trim(),f=u.substring(h+1).trim();if(f.endsWith(";")&&(f=f.slice(0,-1).trim()),e.get(p)&&(p=e.get(p)),p.startsWith("@")&&n.get(p.slice(1))){const d=n.get(p.slice(1)),b=O(f.split(" ").join(","),d.params);p=k(d.body,b,te),f=""}i.push({[p]:f})}return i}function ce(t){let e=!1,n="";for(let s=0;s<t.length;s++){const o=t[s];if((o==='"'||o==="'")&&!e?(e=!0,n=o):o===n&&e&&(e=!1,n=""),o===":"&&!e)return s}return-1}function j(t,e){if(!e.enableMath)return`math(${t})`;try{let n=t.replace(/\s+/g,"");const s=q(n,e);return le(n)?ie(n,s):Y(s,e.mathPrecision)}catch(n){return console.warn("math()\u8868\u8FBE\u5F0F\u89E3\u6790\u5931\u8D25:",t,n),`math(${t})`}}function q(t,e){for(;t.includes("(")&&t.includes(")");){const n=t.lastIndexOf("("),s=t.indexOf(")",n);if(s===-1)break;const o=t.substring(n+1,s),r=q(o,e);t=t.substring(0,n)+r+t.substring(s+1)}return D(t,e)}function D(t,e){const n=[{regex:/([\d.]+(?:[a-zA-Z%]+)?)\*([\d.]+(?:[a-zA-Z%]+)?)/,handler:ue},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\/([\d.]+(?:[a-zA-Z%]+)?)/,handler:fe},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\+([\d.]+(?:[a-zA-Z%]+)?)/,handler:pe},{regex:/([\d.]+(?:[a-zA-Z%]+)?)-([\d.]+(?:[a-zA-Z%]+)?)/,handler:he}];let s=t;for(const r of n){let a;for(;(a=t.match(r.regex))!==null;){const c=T(a[1]),l=T(a[2]),i=r.handler(c,l);t=t.substring(0,a.index)+i.value+t.substring(a.index+a[0].length)}}return t!==s?D(t,e):T(t).value}function T(t){const e=t.match(/^([\d.]+)([a-zA-Z%]*)$/);if(!e)throw new Error(`\u65E0\u6CD5\u89E3\u6790\u503C: ${t}`);const n=parseFloat(e[1]),s=e[2]||"";return{value:n,unit:s}}function le(t){return/[a-zA-Z%]/.test(t)}function ie(t,e){const n=t.match(/([a-zA-Z%]+)(?!.*[a-zA-Z%])/);return n?e+n[1]:t.includes("%")?e+"%":e+"px"}function ue(t,e){return t.unit===e.unit||!t.unit&&!e.unit?{value:t.value*e.value,unit:t.unit||e.unit}:{value:`${t.value}${t.unit}*${e.value}${e.unit}`,unit:""}}function fe(t,e){if(e.value===0)throw new Error("\u9664\u4EE5\u96F6");return t.unit&&!e.unit?{value:t.value/e.value,unit:t.unit}:t.unit===e.unit?{value:t.value/e.value,unit:""}:{value:`${t.value}${t.unit}/${e.value}${e.unit}`,unit:""}}function pe(t,e){return t.unit===e.unit?{value:t.value+e.value,unit:t.unit}:{value:`${t.value}${t.unit}+${e.value}${e.unit}`,unit:""}}function he(t,e){return t.unit===e.unit?{value:t.value-e.value,unit:t.unit}:{value:`${t.value}${t.unit}-${e.value}${e.unit}`,unit:""}}function Y(t,e=6){const n=Math.pow(10,e),o=(Math.round(t*n)/n).toString();return o.includes(".")?o.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""):o}function de(t,e){if(!e.enableMath)return t;let n=t;const s=/math\(([^)]+)\)/gi,o=a=>a.replace(s,(c,l)=>j(l,e));let r;do r=n,n=o(n);while(n!==r&&n.includes("math("));return n}function me(t,e){if(!e.convertLabToRGB&&!e.convertLchToRGB)return t;let n=t;n=ge(n,e);const s=/(lab|lch)\([^)]+\)/gi,o=new Map,r=c=>c.replace(s,l=>{if(o.has(l))return o.get(l);let i=l;return l.toLowerCase().startsWith("lab(")?e.convertLabToRGB&&(i=be(l,e)):l.toLowerCase().startsWith("lch(")&&e.convertLchToRGB&&(i=ye(l,e)),o.set(l,i),i});let a;do a=n,n=r(n);while(n!==a);return n}function ge(t,e){let n=t;const s=/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/gi,o=/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/gi,r=new Map;return n=n.replace(s,(a,c,l,i)=>{if(r.has(a))return r.get(a);try{const u=parseInt(c,16)/255*100,h=(parseInt(l,16)-128)*1.5,p=(parseInt(i,16)-128)*1.5,f=R(u,h,p,e);return r.set(a,f),f}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lab#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n=n.replace(o,(a,c,l,i)=>{if(r.has(a))return r.get(a);try{const u=parseInt(c,16)/255*100,h=parseInt(l,16)/255*150,p=parseInt(i)/100*360,f=L(u,h,p),d=R(f.L,f.a,f.b,e);return r.set(a,d),d}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lch#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n}function be(t,e){const n=/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=t.match(n);if(!s)return t;try{let o=parseFloat(s[1]);s[2]==="%"?o=o:(o<0&&(o=0),o>100&&(o=100));const r=parseFloat(s[3]),a=parseFloat(s[4]),c=s[5]!==void 0?s[5].includes("%")?parseFloat(s[5])/100:parseFloat(s[5]):null;return R(o,r,a,e,c)}catch(o){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LAB\u989C\u8272: ${t}`,o),t}}function ye(t,e){const n=/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=t.match(n);if(!s)return t;try{let o=parseFloat(s[1]);s[2]==="%"?o=o:(o<0&&(o=0),o>100&&(o=100));const r=parseFloat(s[3]);let a=parseFloat(s[4]);r<0&&console.warn(`LCH\u4E2D\u7684C\u503C\u4E0D\u80FD\u4E3A\u8D1F: ${r}`),a=(a%360+360)%360;const c=L(o,r,a),l=s[6]!==void 0?s[6].includes("%")?parseFloat(s[6])/100:parseFloat(s[6]):null;return R(c.L,c.a,c.b,e,l)}catch(o){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LCH\u989C\u8272: ${t}`,o),t}}function L(t,e,n){const s=n*Math.PI/180,o=e*Math.cos(s),r=e*Math.sin(s);return{L:t,a:o,b:r}}function A(t,e,n){const s=(m,y,$)=>{const E=(m+16)/116,B=y/500+E,G=E-$/200,Re=B**3>.008856?B**3:(116*B-16)/903.3,xe=m>903.3*.008856?((m+16)/116)**3:m/903.3,Pe=G**3>.008856?G**3:(116*G-16)/903.3;return[Re*.95047,xe*1,Pe*1.08883]},o=(m,y,$)=>{const w=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]],v=w[0][0]*m+w[0][1]*y+w[0][2]*$,H=w[1][0]*m+w[1][1]*y+w[1][2]*$,S=w[2][0]*m+w[2][1]*y+w[2][2]*$;return[v,H,S]},r=m=>{const y=m<0?-1:1,$=Math.abs(m);return $<=.0031308?y*12.92*$:y*(1.055*Math.pow($,.4166666666666667)-.055)},a=m=>Math.max(0,Math.min(255,Math.round(m*255))),[c,l,i]=s(t,e,n),[u,h,p]=o(c,l,i),f=r(u),d=r(h),b=r(p);return{r:a(f),g:a(d),b:a(b)}}function V(t,e,n){const s=(c,l,i)=>{const b=(c+16)/116,m=l/500+b,y=b-i/200,$=m**3>.008856?m**3:(116*m-16)/903.3,w=c>903.3*.008856?((c+16)/116)**3:c/903.3,v=y**3>.008856?y**3:(116*y-16)/903.3;return[$*.95047,w*1,v*1.08883]},o=(c,l,i)=>{const u=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]],h=u[0][0]*c+u[0][1]*l+u[0][2]*i,p=u[1][0]*c+u[1][1]*l+u[1][2]*i,f=u[2][0]*c+u[2][1]*l+u[2][2]*i;return[h,p,f]},r=c=>{const l=c<0?-1:1,i=Math.abs(c);return i<=.0031308?l*12.92*i:l*(1.055*Math.pow(i,.4166666666666667)-.055)},a=c=>Math.max(0,Math.min(255,Math.round(c*255)));try{const[c,l,i]=s(t,e,n),[u,h,p]=o(c,l,i),f=r(u),d=r(h),b=r(p);return{r:Math.max(0,Math.min(1,f)),g:Math.max(0,Math.min(1,d)),b:Math.max(0,Math.min(1,b))}}catch(c){console.warn("P3\u8F6C\u6362\u5931\u8D25:",c);const l=A(t,e,n);return{r:l.r/255,g:l.g/255,b:l.b/255}}}function R(t,e,n,s,o=null){if(!s.enableP3||!Z()){const r=A(t,e,n);return o!==null?`rgba(${r.r}, ${r.g}, ${r.b}, ${o})`:`rgb(${r.r}, ${r.g}, ${r.b})`}else{const r=V(t,e,n);return o!==null?`color(display-p3 ${r.r.toFixed(4)} ${r.g.toFixed(4)} ${r.b.toFixed(4)} / ${o})`:`color(display-p3 ${r.r.toFixed(4)} ${r.g.toFixed(4)} ${r.b.toFixed(4)})`}}function x(t,e){let n=t;return e.enableMath&&(n=de(n,e)),(e.convertLabToRGB||e.convertLchToRGB)&&(n=me(n,e)),n}function $e(t,e){const n=t.split(`
12
+ `),s={},o=new Map;let r="",a=null,c=!1,l=0;for(let i of n){const u=i.trim(),h=u.match(/^\$([a-zA-Z0-9_-]+)\s*:\s*(.+?);?$/);if(h){const[,p,f]=h,d=x(K(f.trim(),{...s,...a?o.get(a)||{}:{}}),e);a?(o.has(a)||o.set(a,{}),o.get(a)[p]=d):s[p]=d;continue}if(u.endsWith("{")){a=u.slice(0,-1).trim(),c=!0,r+=i+`
13
+ `;continue}if(u==="}"){if(c&&a&&o.has(a)){const p=o.get(a),f=" ".repeat(l);for(const[d,b]of Object.entries(p))r+=`${f} --${d}: ${b};
14
+ `}c=!1,a=null}r+=i+`
15
+ `,i.includes("{")&&(l+=e.indentSize),i.includes("}")&&(l=Math.max(0,l-e.indentSize))}return{globalVariables:s,selectorVariables:o,cssWithoutVars:r.trim()}}function we(t,e,n,s){const o=t.split(`
16
+ `),r=[],a=[];let c=0;for(let l=0;l<o.length;l++){const i=o[l],u=i.trim();if(!u)continue;const h=i.match(/^(\s*)/)[0].length;if(u==="}"){if(r.length>0){const p=r.pop();if(r.length>0){const f=r[r.length-1];f.children||(f.children=[]),f.children.push(p)}else a.push(p)}continue}if(u.endsWith("{")){const f={selector:u.slice(0,-1).trim(),properties:[],children:[]};r.push(f);continue}if(!u.includes("{")&&!u.includes("}")&&u.includes(":")){if(r.length>0){const p=r[r.length-1];X(u,n,s).forEach(d=>{const b=Object.keys(d)[0],m=x(d[b],e);p.properties.push(m===""?b:`${b}: ${m}`)})}continue}}for(;r.length>0;){const l=r.pop();if(r.length===0)a.push(l);else{const i=r[r.length-1];i.children||(i.children=[]),i.children.push(l)}}return Q(a,e,"",n,s)}function Q(t,e,n="",s,o){let r="";const a=n.startsWith("@");for(const c of t){const l=c.selector.startsWith("@");let i=(a?" ".repeat(e.indentSize):"")+c.selector;if(l&&(i=c.selector+` {
17
+ `),n&&(i.includes("&")?i=i.replace(/&/g,n):i.trim().startsWith(":")?i=n+i:i=n+(a?"":" ")+i),c.properties.length>0){r+=(l?"":i)+` {
18
+ `;for(const u of c.properties)X(u,s,o).forEach(p=>{const f=Object.keys(p)[0],d=x(p[f],e);r+=(a?" ".repeat(e.indentSize):"")+" ".repeat(e.indentSize)+(d===""?f:`${f}: ${d};
19
+ `)});r+=a?" ".repeat(e.indentSize)+`}
20
20
  `:`}
21
21
 
22
- `}a.children&&a.children.length>0&&(r+=D(a.children,t,l,s)),o&&(r+=`}
22
+ `}c.children&&c.children.length>0&&(r+=Q(c.children,e,i,s,o)),a&&(r+=`}
23
23
 
24
24
  `)}return r.trim()+`
25
25
 
26
- `}function Y(e,t){return e.replace(/\$([a-zA-Z0-9_-]+)/g,(n,s)=>t[s]?`var(--${s})`:n)}function $e(e,t,n,s){let r=e;return r=r.replace(/(?:\$\$|\$)([a-zA-Z0-9_-]+)/g,(o,a)=>o.startsWith("$$")?`attr(${a})`:`var(--${a})`),r=R(r,s),r}function we(e,t){if(Object.keys(e).length===0)return"";const n=Object.entries(e).map(([s,r])=>{const o=R(Y(r,e),t);return" ".repeat(t.indentSize)+`--${s}: ${o};`}).join(`
27
- `);return`${t.rootSelector} {
26
+ `}function K(t,e){return t.replace(/\$([a-zA-Z0-9_-]+)/g,(n,s)=>e[s]?`var(--${s})`:n)}function ve(t,e,n,s){let o=t;return o=o.replace(/(?:\$\$|\$)([a-zA-Z0-9_-]+)/g,(r,a)=>r.startsWith("$$")?`attr(${a})`:`var(--${a})`),o=x(o,s),o}function Me(t,e){if(Object.keys(t).length===0)return"";const n=Object.entries(t).map(([s,o])=>{const r=x(K(o,t),e);return" ".repeat(e.indentSize)+`--${s}: ${r};`}).join(`
27
+ `);return`${e.rootSelector} {
28
28
  ${n}
29
29
  }
30
30
 
31
- `}function ve(e,t,n){let s="";const r=e.split(`
32
- `);let o=null;for(let a of r){const c=a.trim();if(c.endsWith("{")&&(o=c.slice(0,-1).trim()),c==="}"&&o){if(t.has(o)){const l=t.get(o),i=a.match(/^(\s*)/)[0];for(const[u,p]of Object.entries(l))s+=" --"+u+": "+p+`;
33
- `}o=null}s+=R(a,n)+`
34
- `}return s.trim()}async function Q(e,t){const n=/@import\s+([^;]+?)\s*;/g;return(async r=>{const o=[],a=r.replace(n,(c,l)=>{const i=Me(l,t).then(u=>Q(u,t)).catch(u=>(console.warn(`\u65E0\u6CD5\u5BFC\u5165CSS\u6587\u4EF6: ${l}`,u),""));return o.push(i),`__IMPORT_PLACEHOLDER_${o.length-1}__`});if(o.length>0){const c=await Promise.all(o);let l=a;for(let i=0;i<c.length;i++)l=l.replace(`__IMPORT_PLACEHOLDER_${i}__`,c[i]);return l}return a})(e)}async function Me(e,t){if(t.importCache&&V.has(e))return V.get(e);const n=t.importBaseUrl?new URL(e,t.importBaseUrl).href:e;let s;if(typeof process<"u"&&process.versions&&process.versions.node&&typeof require<"u")try{const o=require("fs"),a=require("path");let c=n;n.startsWith(".")&&(c=a.join(process.cwd(),n)),s=o.readFileSync(c,"utf-8")}catch(o){throw new Error(`Node.js\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${n} - ${o.message}`)}else try{const o=new AbortController,a=setTimeout(()=>o.abort(),t.importTimeout),c=await fetch(n,{signal:o.signal,headers:{Accept:"text/css"}});if(clearTimeout(a),!c.ok)throw new Error(`HTTP\u9519\u8BEF: ${c.status} ${c.statusText}`);s=await c.text()}catch(o){throw o.name==="AbortError"?new Error(`\u5BFC\u5165\u8D85\u65F6: ${n}`):new Error(`\u65E0\u6CD5\u83B7\u53D6CSS: ${n} - ${o.message}`)}return t.importCache&&V.set(e,s),s}function P(e,t={}){const n=(o,a)=>{const{config:c,css:l}=ee(o),i={...d,...t,...c};let u=l,p=new Map;if(i.enableAlias){const{aliases:S,css:F}=te(u);p=S,u=F}let f=u,h=new Map;if(i.enableMacros){const{macros:S,css:F}=N(f,i);h=S,f=F;for(const[J,I]of h)v.set(J,I)}let m=f;i.enableMacros&&h.size>0&&(m=ne(m,h,i));const{globalVariables:y,selectorVariables:g,cssWithoutVars:b}=be(m,i);let $=b.trim();if(i.enableNesting&&b.includes("{"))try{$=ye(b,i,p)}catch(S){console.warn("\u5D4C\u5957\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CBCSS:",S)}const w=we(y,i);let M=$;return g.size>0&&(M=ve($,g,i)),M=$e(M,y,g,i),w+M},s=e&&/@import\s+([^;]+?)\s*;/g.test(e),r={...d,...t};return s?(async()=>{try{const o=await Q(e,r);return n(o,r)}catch(o){return console.error("@import\u5904\u7406\u5931\u8D25:",o),n(e,r)}})():n(e,r)}function K(e={}){const t={...d,...e},n=document.querySelectorAll(`style[${t.styleTagAttribute||"e"}]`);return n.forEach(s=>{let r=s.textContent;(async()=>{try{s.getAttribute("src")&&(r="@import "+s.getAttribute("src")+";");const a=await P(r,t),c=document.createElement("style");c.textContent=a,s.parentNode.insertBefore(c,s.nextSibling),t.preserveOriginal?s.style.display="none":s.remove()}catch(a){console.error("\u5904\u7406style\u6807\u7B7E\u5931\u8D25:",a)}})()}),n.length}function Ce(e={}){d={...d,...e}}function k(e,t={}){const n={...d,...t};if(e){if(/@import\s+([^;]+?)\s*;/g.test(e))return(async()=>{try{const r=await P(e,n),o=document.createElement("style");return o.textContent=r,document.head.appendChild(o),o}catch(r){return console.error("\u5E94\u7528CSS\u5931\u8D25:",r),null}})();{const r=P(e,n),o=document.createElement("style");return o.textContent=r,document.head.appendChild(o),o}}else document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{K(n)}):K(n)}const Se={convert:P,apply:k,config:Ce,supportsP3:O(),detectP3Support:O,imports:{clearCache:function(){V.clear()},setBaseUrl:function(e){d.importBaseUrl=e},setCacheEnabled:function(e){d.importCache=e},setTimeout:function(e){d.importTimeout=e}},aliases:{add:function(e,t){B.set(e,t)},remove:function(e){B.delete(e)},getAll:function(){return Array.from(B.entries())},clear:function(){B.clear()}},macros:{define:function(e,t,n=[]){if(typeof t=="function"){const r=t.toString().match(/{([\s\S]*)}/);r&&v.set(e,{params:n.map(o=>typeof o=="string"?{name:o}:o),body:r[1].trim()})}else v.set(e,{params:n.map(s=>typeof s=="string"?{name:s}:s),body:t})},call:function(e,...t){const n=v.get(e);if(!n)throw new Error(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${e}`);const s=new Map;for(let r=0;r<n.params.length;r++){const o=n.params[r],a=r<t.length?t[r]:o.defaultValue;if(a===void 0&&o.defaultValue===null)throw new Error(`\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${o.name}`);s.set(o.name,a!==void 0?a:"")}return W(n.body,s,d)},getAll:function(){return Array.from(v.entries())},remove:function(e){v.delete(e)},clear:function(){v.clear()},parse:function(e){const{macros:t}=N(e,d);for(const[n,s]of t)v.set(n,s)}},math:{evaluate:function(e){return _(e,d)},parseUnit:z,round:q,test:function(e,t={}){const n={...d,...t};try{const s=_(e,n);return{success:!0,expression:e,result:s,parsed:z(s.replace(/^calc\(|\)$/g,""))}}catch(s){return{success:!1,expression:e,error:s.message}}}},colorUtils:{labToRGB:C,lchToLab:A,lchToRGB:function(e,t,n){const s=A(e,t,n);return C(s.L,s.a,s.b)},labToP3:E,lchToP3:function(e,t,n){const s=A(e,t,n);return E(s.L,s.a,s.b)},parseHexLab:function(e){const t=e.match(/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i);if(!t)return null;const n=t[1],s=t[2],r=t[3],o=parseInt(n,16)/255*100,a=(parseInt(s,16)-128)*1.5,c=(parseInt(r,16)-128)*1.5;return C(o,a,c)},parseHexLch:function(e){const t=e.match(/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/i);if(!t)return null;const n=t[1],s=t[2],r=t[3],o=parseInt(n,16)/255*100,a=parseInt(s,16)/255*150,c=parseInt(r)/100*360,l=A(o,a,c);return C(l.L,l.a,l.b)},generateColor:function(e,t,n,s=null,r=!0){return L(e,t,n,{enableP3:r},s)},parseColor:function(e){try{const t=e.match(/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(t){let s=parseFloat(t[1]);const r=parseFloat(t[3]),o=parseFloat(t[4]),a=t[5]?t[5].includes("%")?parseFloat(t[5])/100:parseFloat(t[5]):null,c=L(s,r,o,d,a);return{L:s,A:r,B:o,alpha:a,rgb:C(s,r,o),p3:E(s,r,o),colorString:c}}const n=e.match(/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(n){let s=parseFloat(n[1]);const r=parseFloat(n[3]);let o=parseFloat(n[4]);const a=n[6]?n[6].includes("%")?parseFloat(n[6])/100:parseFloat(n[6]):null,c=A(s,r,o),l=L(c.L,c.a,c.b,d,a);return{L:s,C:r,H:o,alpha:a,lab:c,rgb:C(c.L,c.a,c.b),p3:E(c.L,c.a,c.b),colorString:l}}return null}catch(t){return console.warn("\u65E0\u6CD5\u89E3\u6790\u989C\u8272:",e,t),null}}}},T=function(...e){if(e.length>1||e[0]&&e[0].raw)return Ae(...e);const t=e[0];if(typeof t=="string"){const n=P(t,{...d,...e[1]});return n&&typeof n.then=="function",n}return typeof t=="object"&&t!==null?(d={...d,...t},T):e.length===0?k():T};function Ae(e,...t){let n=e[0];for(let r=0;r<t.length;r++){const o=t[r];let a="";typeof o=="function"?a=o():Array.isArray(o)?a=o.join(" "):a=String(o??""),n+=a+e[r+1]}const s=P(n,d);return s&&typeof s.then=="function",s}return Object.assign(T,Se),Object.setPrototypeOf(T,Function.prototype),typeof window<"u"&&(k(),Object.defineProperty(window.HTMLElement.prototype,"cssVar",{get(){const e=this;return new Proxy(()=>{},{get(t,n){const s=n.startsWith("--")?n:`--${n}`;return e.style.getPropertyValue(s)},set(t,n,s){const r=n.startsWith("--")?n:`--${n}`;return e.style.setProperty(r,s),!0},apply(t,n,s){const r=s[0],o=s[1],a=r.startsWith("--")?r:`--${r}`;if(o===void 0)return e.style.getPropertyValue(a);e.style.setProperty(a,o)}})}})),T})();if(typeof define=="function"&&define.amd)define([],()=>styimat);else if(typeof module=="object"&&module.exports)module.exports=styimat;else{const d=globalThis??(typeof self<"u"&&self)??(typeof window<"u"&&window)??global??{};d.styimat=styimat}
31
+ `}function Ce(t,e,n){let s="";const o=t.split(`
32
+ `);let r=null;for(let a of o){const c=a.trim();c.endsWith("{")&&(r=c.slice(0,-1).trim()),c==="}"&&r&&(r=null),s+=x(a,n)+`
33
+ `}return s.trim()}async function J(t,e){const n=/@import\s+([^;]+?)\s*;/g;return(async o=>{const r=[],a=o.replace(n,(c,l)=>{const i=Se(l,e).then(u=>J(u,e)).catch(u=>(console.warn(`\u65E0\u6CD5\u5BFC\u5165CSS\u6587\u4EF6: ${l}`,u),""));return r.push(i),`__IMPORT_PLACEHOLDER_${r.length-1}__`});if(r.length>0){const c=await Promise.all(r);let l=a;for(let i=0;i<c.length;i++)l=l.replace(`__IMPORT_PLACEHOLDER_${i}__`,c[i]);return l}return a})(t)}async function Se(t,e){if(e.importCache&&I.has(t))return I.get(t);const n=e.importBaseUrl?new URL(t,e.importBaseUrl).href:t;let s;if(typeof process<"u"&&process.versions&&process.versions.node&&typeof require<"u")try{const r=require("fs"),a=require("path");let c=n;n.startsWith(".")&&(c=a.join(process.cwd(),n)),s=r.readFileSync(c,"utf-8")}catch(r){throw new Error(`Node.js\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${n} - ${r.message}`)}else try{const r=new AbortController,a=setTimeout(()=>r.abort(),e.importTimeout),c=await fetch(n,{signal:r.signal,headers:{Accept:"text/css"}});if(clearTimeout(a),!c.ok)throw new Error(`HTTP\u9519\u8BEF: ${c.status} ${c.statusText}`);s=await c.text()}catch(r){throw r.name==="AbortError"?new Error(`\u5BFC\u5165\u8D85\u65F6: ${n}`):new Error(`\u65E0\u6CD5\u83B7\u53D6CSS: ${n} - ${r.message}`)}return e.importCache&&I.set(t,s),s}function z(t,e={}){const n=(r,a)=>{const{config:c,css:l}=ne(r),i={...g,...e,...c};let u=l,h=new Map;if(i.enableAlias){const{aliases:S,css:P}=re(u);h=S,u=P}let p=u,f=new Map;if(i.enableMacros){const{macros:S,css:P}=U(p,i);f=S,p=P;for(const[E,B]of f)M.set(E,B)}let d=p;i.enableMacros&&f.size>0&&(d=se(d,f,i));const{globalVariables:b,selectorVariables:m,cssWithoutVars:y}=$e(d,i);let $=y.trim();if(i.enableNesting&&y.includes("{"))try{$=we(y,i,h,f)}catch(S){console.warn("\u5D4C\u5957\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CBCSS:",S)}const w=Me(b,i);let v=$;m.size>0&&(v=Ce($,m,i)),v=ve(v,b,m,i);for(const[S,P]of C)try{P.enable&&(v=P.convert(v,i))}catch(E){console.error("\u63D2\u4EF6\u5904\u7406\u5931\u8D25:",E)}return w+v},s=t&&/@import\s+([^;]+?)\s*;/g.test(t),o={...g,...e};return s?(async()=>{try{const r=await J(t,o);return n(r,o)}catch(r){return console.error("@import\u5904\u7406\u5931\u8D25:",r),n(t,o)}})():n(t,o)}function ee(t={}){const e={...g,...t},n=document.querySelectorAll(`style[${e.styleTagAttribute||"e"}]`);return n.forEach(s=>{let o=s.textContent;(async()=>{try{s.getAttribute("src")&&(o="@import "+s.getAttribute("src")+";");const a=await z(o,e),c=document.createElement("style");c.textContent=a,s.parentNode.insertBefore(c,s.nextSibling),e.preserveOriginal?s.style.display="none":s.remove()}catch(a){console.error("\u5904\u7406style\u6807\u7B7E\u5931\u8D25:",a)}})()}),n.length}function te(t={}){g={...g,...t}}function N(t,e={}){const n={...g,...e};if(t){if(/@import\s+([^;]+?)\s*;/g.test(t))return(async()=>{try{const o=await z(t,n),r=document.createElement("style");return r.textContent=o,document.head.appendChild(r),r}catch(o){return console.error("\u5E94\u7528CSS\u5931\u8D25:",o),null}})();{const o=z(t,n),r=document.createElement("style");return r.textContent=o,document.head.appendChild(r),r}}else document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{ee(n)}):ee(n)}const Ae={convert:z,apply:N,config:te,supportsP3:Z(),detectP3Support:Z,imports:{clearCache:function(){I.clear()},setBaseUrl:function(t){g.importBaseUrl=t},setCacheEnabled:function(t){g.importCache=t},setTimeout:function(t){g.importTimeout=t}},plugins:new Proxy({},{set(t,e,n){return(n.created??(()=>{}))(),C.set(e,n),!0},get(t,e){return C.get(e)},deleteProperty(t,e){return C.get(e)?.deleted(),C.delete(e),!0},has(t,e){return C.has(e)},ownKeys(){return Array.from(C.keys())},getOwnPropertyDescriptor(t,e){if(C.has(e))return{enumerable:!0,configurable:!0,writable:!0,value:C.get(e)}}}),aliases:{add:function(t,e){_.set(t,e)},remove:function(t){_.delete(t)},getAll:function(){return Array.from(_.entries())},clear:function(){_.clear()}},macros:{define:function(t,e,n=[]){if(typeof e=="function"){const o=e.toString().match(/{([\s\S]*)}/);o&&M.set(t,{params:n.map(r=>typeof r=="string"?{name:r}:r),body:o[1].trim()})}else M.set(t,{params:n.map(s=>typeof s=="string"?{name:s}:s),body:e})},call:function(t,...e){const n=M.get(t);if(!n)throw new Error(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${t}`);const s=new Map;for(let o=0;o<n.params.length;o++){const r=n.params[o],a=o<e.length?e[o]:r.defaultValue;if(a===void 0&&r.defaultValue===null)throw new Error(`\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${r.name}`);s.set(r.name,a!==void 0?a:"")}return k(n.body,s,g)},getAll:function(){return Array.from(M.entries())},remove:function(t){M.delete(t)},clear:function(){M.clear()},parse:function(t){const{macros:e}=U(t,g);for(const[n,s]of e)M.set(n,s)}},math:{evaluate:function(t){return j(t,g)},parseUnit:T,round:Y,test:function(t,e={}){const n={...g,...e};try{const s=j(t,n);return{success:!0,expression:t,result:s,parsed:T(s.replace(/^calc\(|\)$/g,""))}}catch(s){return{success:!1,expression:t,error:s.message}}}},colorUtils:{labToRGB:A,lchToLab:L,lchToRGB:function(t,e,n){const s=L(t,e,n);return A(s.L,s.a,s.b)},labToP3:V,lchToP3:function(t,e,n){const s=L(t,e,n);return V(s.L,s.a,s.b)},parseHexLab:function(t){const e=t.match(/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i);if(!e)return null;const n=e[1],s=e[2],o=e[3],r=parseInt(n,16)/255*100,a=(parseInt(s,16)-128)*1.5,c=(parseInt(o,16)-128)*1.5;return A(r,a,c)},parseHexLch:function(t){const e=t.match(/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/i);if(!e)return null;const n=e[1],s=e[2],o=e[3],r=parseInt(n,16)/255*100,a=parseInt(s,16)/255*150,c=parseInt(o)/100*360,l=L(r,a,c);return A(l.L,l.a,l.b)},generateColor:function(t,e,n,s=null,o=!0){return R(t,e,n,{enableP3:o},s)},parseColor:function(t){try{const e=t.match(/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(e){let s=parseFloat(e[1]);const o=parseFloat(e[3]),r=parseFloat(e[4]),a=e[5]?e[5].includes("%")?parseFloat(e[5])/100:parseFloat(e[5]):null,c=R(s,o,r,g,a);return{L:s,A:o,B:r,alpha:a,rgb:A(s,o,r),p3:V(s,o,r),colorString:c}}const n=t.match(/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(n){let s=parseFloat(n[1]);const o=parseFloat(n[3]);let r=parseFloat(n[4]);const a=n[6]?n[6].includes("%")?parseFloat(n[6])/100:parseFloat(n[6]):null,c=L(s,o,r),l=R(c.L,c.a,c.b,g,a);return{L:s,C:o,H:r,alpha:a,lab:c,rgb:A(c.L,c.a,c.b),p3:V(c.L,c.a,c.b),colorString:l}}return null}catch(e){return console.warn("\u65E0\u6CD5\u89E3\u6790\u989C\u8272:",t,e),null}}}},W=function(...t){if(t.length>1||t[0]&&t[0].raw)return Le(...t);const e=t[0];if(typeof e=="string"){const n=z(e,{...g,...t[1]});return n&&typeof n.then=="function",n}return typeof e=="object"&&e!==null?(g={...g,...e},W):t.length===0?N():W};function Le(t,...e){let n=t[0];for(let o=0;o<e.length;o++){const r=e[o];let a="";typeof r=="function"?a=r():Array.isArray(r)?a=r.join(" "):a=String(r??""),n+=a+t[o+1]}const s=z(n,g);return s&&typeof s.then=="function",s}return Object.assign(W,Ae),Object.setPrototypeOf(W,Function.prototype),typeof window<"u"&&(N(),Object.defineProperty(window.HTMLElement.prototype,"cssVar",{get(){const t=this;return new Proxy(()=>{},{get(e,n){const s=n.startsWith("--")?n:`--${n}`;return t.style.getPropertyValue(s)},set(e,n,s){const o=n.startsWith("--")?n:`--${n}`;return t.style.setProperty(o,s),!0},apply(e,n,s){const o=s[0],r=s[1],a=o.startsWith("--")?o:`--${o}`;if(r===void 0)return t.style.getPropertyValue(a);t.style.setProperty(a,r)}})}})),W})();if(typeof define=="function"&&define.amd)define([],g=>styimat);else if(typeof module=="object"&&module.exports)module.exports=styimat;else{const g=globalThis??(typeof self<"u"&&self)??(typeof window<"u"&&window)??global??{};g.styimat=styimat}
@@ -1,34 +1,33 @@
1
1
  /*!
2
2
  * MIT License
3
3
  * Copyright (c) 2025 王小玗
4
- */const V=(function(){let d={rootSelector:":root",variablePrefix:"--",preserveOriginal:!1,indentSize:4,enableNesting:!0,autoProcessStyleTags:!0,styleTagAttribute:"e",convertLabToRGB:!0,convertLchToRGB:!0,enableP3:!0,enableMath:!0,mathPrecision:6,importBaseUrl:"",importCache:!0,importTimeout:5e3,enableAlias:!0,enableMacros:!0},x=null;const B=new Map,I=new Map,v=new Map;function te(e){const t={...d},n=e.split(`
5
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("#")){const a=o.substring(1).trim(),c=a.indexOf(" ");if(c!==-1){const l=a.substring(0,c).trim(),i=a.substring(c+1).trim(),u=oe(l);u in t?i==="true"||i==="false"?t[u]=i==="true":!isNaN(i)&&i.trim()!==""?t[u]=Number(i):t[u]=i:console.warn(`\u672A\u77E5\u7684\u914D\u7F6E\u9879: ${l}`)}else console.warn(`\u65E0\u6548\u7684\u914D\u7F6E\u884C: ${o}`)}else s.push(r)}return{config:t,css:s.join(`
6
- `)}}function ne(e){const t=new Map,n=e.split(`
7
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("@alias")){const a=o.match(/^@alias\s+([a-zA-Z0-9_-]+)\s+(.+?)\s*;$/);if(a){const c=a[1],l=a[2];t.set(c,l);continue}}s.push(r)}return{aliases:t,css:s.join(`
8
- `)}}function H(e,t){if(!t.enableMacros)return{macros:new Map,css:e};const n=new Map,s=e.split(`
9
- `),r=[];let o=!1,a="",c=[],l=[],i=0;for(let u of s){const p=u.trim();if(!o&&p.startsWith("@macro")){const f=p.match(/^@macro\s+([a-zA-Z0-9_-]+)\s*\(([^)]*)\)\s*\{$/);if(f){o=!0,a=f[1],c=f[2].split(",").map(h=>h.trim()).filter(h=>h).map(h=>{const m=h.split(":").map(y=>y.trim());return{name:m[0].slice(1),defaultValue:m[1]||null}}),l=[],i=1;continue}}if(o){for(const f of u)f==="{"&&i++,f==="}"&&i--;i===0?(n.set(a,{params:c,body:l.join(`
10
- `)}),o=!1,a="",c=[],l=[]):l.push(u);continue}r.push(u)}return{macros:n,css:r.join(`
11
- `)}}function re(e,t,n){if(!n.enableMacros||t.size===0)return e;const s=Array.from(t.keys()).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),r=new RegExp(`@(${s})\\s*\\(([^)]*)\\)\\s*;?`,"g");return(a=>{let c=a,l=!1;do l=!1,c=c.replace(r,(i,u,p)=>{l=!0;const f=t.get(u);if(!f)return console.warn(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${u}`),i;const h=U(p,f.params);return O(f.body,h,n)});while(l);return c})(e)}function U(e,t){const n=new Map,s=se(e);for(let r=0;r<t.length;r++){const o=t[r];let a;r<s.length?a=s[r]:o.defaultValue!==null?a=o.defaultValue:(console.warn(`\u5B8F\u8C03\u7528\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${o.name}`),a=""),n.set(o.name,a)}return s.length>t.length&&console.warn("\u5B8F\u8C03\u7528\u4F20\u9012\u4E86\u8FC7\u591A\u53C2\u6570\uFF0C\u591A\u4F59\u7684\u53C2\u6570\u5C06\u88AB\u5FFD\u7565"),n}function se(e){const t=[];let n="",s=!1,r="",o=0,a=0;for(let c=0;c<e.length;c++){const l=e[c];(l==='"'||l==="'")&&!s?(s=!0,r=l):l===r&&s&&(s=!1,r=""),s||(l==="("&&o++,l===")"&&o--,l==="["&&a++,l==="]"&&a--),l===","&&!s&&o===0&&a===0?(t.push(n.trim()),n=""):n+=l}return n.trim()&&t.push(n.trim()),t}function O(e,t,n){let s=e;for(const[r,o]of t){const a=new RegExp(`\\$${r}`,"g");s=s.replace(a,o)}if(n.enableMacros){const r=Array.from(v.keys()).map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");if(r){const o=new RegExp(`@(${r})\\s*\\(([^)]*)\\)\\s*;?`,"g");let a;do a=!1,s=s.replace(o,(c,l,i)=>{a=!0;const u=v.get(l);if(!u)return c;const p=U(i,u.params);return O(u.body,p,n)});while(a)}}return s=R(s,n),s}function oe(e){return e.replace(/-([a-z])/g,function(t,n){return n.toUpperCase()})}function _(){if(x!==null)return x;if(typeof window>"u"||!window.CSS)return x=!1,!1;try{x=CSS.supports("color","color(display-p3 1 0 0)")}catch(e){console.warn("P3\u652F\u6301\u68C0\u6D4B\u5931\u8D25:",e),x=!1}return x}function G(e,t=[]){let n=e.trim();if(n.endsWith(";")&&(n=n.slice(0,-1)),!n)return[];const s=[];let r="",o=0,a=!1,c="";for(let i=0;i<n.length;i++){const u=n[i];(u==='"'||u==="'")&&!a?(a=!0,c=u):u===c&&a&&(a=!1,c=""),a||(u==="("?o++:u===")"&&o--),u===";"&&!a&&o===0?r.trim()&&(s.push(r.trim()),r=""):r+=u}r.trim()&&s.push(r.trim());const l=[];for(const i of s){if(!i.trim())continue;const u=ae(i);if(u===-1){console.warn(`\u65E0\u6548\u7684CSS\u58F0\u660E: "${i}"`);continue}let p=i.substring(0,u).trim(),f=i.substring(u+1).trim();f.endsWith(";")&&(f=f.slice(0,-1).trim()),t.get(p)&&(p=t.get(p)),l.push({[p]:f})}return l}function ae(e){let t=!1,n="";for(let s=0;s<e.length;s++){const r=e[s];if((r==='"'||r==="'")&&!t?(t=!0,n=r):r===n&&t&&(t=!1,n=""),r===":"&&!t)return s}return-1}function k(e,t){if(!t.enableMath)return`math(${e})`;try{let n=e.replace(/\s+/g,"");const s=X(n,t);return ce(n)?le(n,s):D(s,t.mathPrecision)}catch(n){return console.warn("math()\u8868\u8FBE\u5F0F\u89E3\u6790\u5931\u8D25:",e,n),`math(${e})`}}function X(e,t){for(;e.includes("(")&&e.includes(")");){const n=e.lastIndexOf("("),s=e.indexOf(")",n);if(s===-1)break;const r=e.substring(n+1,s),o=X(r,t);e=e.substring(0,n)+o+e.substring(s+1)}return q(e,t)}function q(e,t){const n=[{regex:/([\d.]+(?:[a-zA-Z%]+)?)\*([\d.]+(?:[a-zA-Z%]+)?)/,handler:ie},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\/([\d.]+(?:[a-zA-Z%]+)?)/,handler:ue},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\+([\d.]+(?:[a-zA-Z%]+)?)/,handler:fe},{regex:/([\d.]+(?:[a-zA-Z%]+)?)-([\d.]+(?:[a-zA-Z%]+)?)/,handler:pe}];let s=e;for(const o of n){let a;for(;(a=e.match(o.regex))!==null;){const c=z(a[1]),l=z(a[2]),i=o.handler(c,l);e=e.substring(0,a.index)+i.value+e.substring(a.index+a[0].length)}}return e!==s?q(e,t):z(e).value}function z(e){const t=e.match(/^([\d.]+)([a-zA-Z%]*)$/);if(!t)throw new Error(`\u65E0\u6CD5\u89E3\u6790\u503C: ${e}`);const n=parseFloat(t[1]),s=t[2]||"";return{value:n,unit:s}}function ce(e){return/[a-zA-Z%]/.test(e)}function le(e,t){const n=e.match(/([a-zA-Z%]+)(?!.*[a-zA-Z%])/);return n?t+n[1]:e.includes("%")?t+"%":t+"px"}function ie(e,t){return e.unit===t.unit||!e.unit&&!t.unit?{value:e.value*t.value,unit:e.unit||t.unit}:{value:`${e.value}${e.unit}*${t.value}${t.unit}`,unit:""}}function ue(e,t){if(t.value===0)throw new Error("\u9664\u4EE5\u96F6");return e.unit&&!t.unit?{value:e.value/t.value,unit:e.unit}:e.unit===t.unit?{value:e.value/t.value,unit:""}:{value:`${e.value}${e.unit}/${t.value}${t.unit}`,unit:""}}function fe(e,t){return e.unit===t.unit?{value:e.value+t.value,unit:e.unit}:{value:`${e.value}${e.unit}+${t.value}${t.unit}`,unit:""}}function pe(e,t){return e.unit===t.unit?{value:e.value-t.value,unit:e.unit}:{value:`${e.value}${e.unit}-${t.value}${t.unit}`,unit:""}}function D(e,t=6){const n=Math.pow(10,t),r=(Math.round(e*n)/n).toString();return r.includes(".")?r.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""):r}function he(e,t){if(!t.enableMath)return e;let n=e;const s=/math\(([^)]+)\)/gi,r=a=>a.replace(s,(c,l)=>k(l,t));let o;do o=n,n=r(n);while(n!==o&&n.includes("math("));return n}function de(e,t){if(!t.convertLabToRGB&&!t.convertLchToRGB)return e;let n=e;n=me(n,t);const s=/(lab|lch)\([^)]+\)/gi,r=new Map,o=c=>c.replace(s,l=>{if(r.has(l))return r.get(l);let i=l;return l.toLowerCase().startsWith("lab(")?t.convertLabToRGB&&(i=ge(l,t)):l.toLowerCase().startsWith("lch(")&&t.convertLchToRGB&&(i=be(l,t)),r.set(l,i),i});let a;do a=n,n=o(n);while(n!==a);return n}function me(e,t){let n=e;const s=/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/gi,r=/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/gi,o=new Map;return n=n.replace(s,(a,c,l,i)=>{if(o.has(a))return o.get(a);try{const u=parseInt(c,16)/255*100,p=(parseInt(l,16)-128)*1.5,f=(parseInt(i,16)-128)*1.5,h=L(u,p,f,t);return o.set(a,h),h}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lab#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n=n.replace(r,(a,c,l,i)=>{if(o.has(a))return o.get(a);try{const u=parseInt(c,16)/255*100,p=parseInt(l,16)/255*150,f=parseInt(i)/100*360,h=A(u,p,f),m=L(h.L,h.a,h.b,t);return o.set(a,m),m}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lch#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n}function ge(e,t){const n=/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=e.match(n);if(!s)return e;try{let r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]),a=parseFloat(s[4]),c=s[5]!==void 0?s[5].includes("%")?parseFloat(s[5])/100:parseFloat(s[5]):null;return L(r,o,a,t,c)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LAB\u989C\u8272: ${e}`,r),e}}function be(e,t){const n=/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=e.match(n);if(!s)return e;try{let r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]);let a=parseFloat(s[4]);o<0&&console.warn(`LCH\u4E2D\u7684C\u503C\u4E0D\u80FD\u4E3A\u8D1F: ${o}`),a=(a%360+360)%360;const c=A(r,o,a),l=s[6]!==void 0?s[6].includes("%")?parseFloat(s[6])/100:parseFloat(s[6]):null;return L(c.L,c.a,c.b,t,l)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LCH\u989C\u8272: ${e}`,r),e}}function A(e,t,n){const s=n*Math.PI/180,r=t*Math.cos(s),o=t*Math.sin(s);return{L:e,a:r,b:o}}function C(e,t,n){const s=(g,b,$)=>{const W=(g+16)/116,j=b/500+W,N=W-$/200,Re=j**3>.008856?j**3:(116*j-16)/903.3,xe=g>903.3*.008856?((g+16)/116)**3:g/903.3,Pe=N**3>.008856?N**3:(116*N-16)/903.3;return[Re*.95047,xe*1,Pe*1.08883]},r=(g,b,$)=>{const w=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]],M=w[0][0]*g+w[0][1]*b+w[0][2]*$,S=w[1][0]*g+w[1][1]*b+w[1][2]*$,F=w[2][0]*g+w[2][1]*b+w[2][2]*$;return[M,S,F]},o=g=>{const b=g<0?-1:1,$=Math.abs(g);return $<=.0031308?b*12.92*$:b*(1.055*Math.pow($,.4166666666666667)-.055)},a=g=>Math.max(0,Math.min(255,Math.round(g*255))),[c,l,i]=s(e,t,n),[u,p,f]=r(c,l,i),h=o(u),m=o(p),y=o(f);return{r:a(h),g:a(m),b:a(y)}}function E(e,t,n){const s=(c,l,i)=>{const y=(c+16)/116,g=l/500+y,b=y-i/200,$=g**3>.008856?g**3:(116*g-16)/903.3,w=c>903.3*.008856?((c+16)/116)**3:c/903.3,M=b**3>.008856?b**3:(116*b-16)/903.3;return[$*.95047,w*1,M*1.08883]},r=(c,l,i)=>{const u=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]],p=u[0][0]*c+u[0][1]*l+u[0][2]*i,f=u[1][0]*c+u[1][1]*l+u[1][2]*i,h=u[2][0]*c+u[2][1]*l+u[2][2]*i;return[p,f,h]},o=c=>{const l=c<0?-1:1,i=Math.abs(c);return i<=.0031308?l*12.92*i:l*(1.055*Math.pow(i,.4166666666666667)-.055)},a=c=>Math.max(0,Math.min(255,Math.round(c*255)));try{const[c,l,i]=s(e,t,n),[u,p,f]=r(c,l,i),h=o(u),m=o(p),y=o(f);return{r:Math.max(0,Math.min(1,h)),g:Math.max(0,Math.min(1,m)),b:Math.max(0,Math.min(1,y))}}catch(c){console.warn("P3\u8F6C\u6362\u5931\u8D25:",c);const l=C(e,t,n);return{r:l.r/255,g:l.g/255,b:l.b/255}}}function L(e,t,n,s,r=null){if(!s.enableP3||!_()){const o=C(e,t,n);return r!==null?`rgba(${o.r}, ${o.g}, ${o.b}, ${r})`:`rgb(${o.r}, ${o.g}, ${o.b})`}else{const o=E(e,t,n);return r!==null?`color(display-p3 ${o.r.toFixed(4)} ${o.g.toFixed(4)} ${o.b.toFixed(4)} / ${r})`:`color(display-p3 ${o.r.toFixed(4)} ${o.g.toFixed(4)} ${o.b.toFixed(4)})`}}function R(e,t){let n=e;return t.enableMath&&(n=he(n,t)),(t.convertLabToRGB||t.convertLchToRGB)&&(n=de(n,t)),n}function ye(e,t){const n=e.split(`
12
- `),s={},r=new Map;let o="",a=null,c=!1,l=0;for(let i of n){const u=i.trim(),p=u.match(/^\$([a-zA-Z0-9_-]+)\s*:\s*(.+?);?$/);if(p){const[,f,h]=p,m=R(Q(h.trim(),{...s,...a?r.get(a)||{}:{}}),t);a?(r.has(a)||r.set(a,{}),r.get(a)[f]=m):s[f]=m;continue}if(u.endsWith("{")){a=u.slice(0,-1).trim(),c=!0,o+=i+`
13
- `;continue}if(u==="}"){if(c&&a&&r.has(a)){const f=r.get(a),h=" ".repeat(l);for(const[m,y]of Object.entries(f))o+=`${h} --${m}: ${y};
14
- `}c=!1,a=null}o+=i+`
15
- `,i.includes("{")&&(l+=t.indentSize),i.includes("}")&&(l=Math.max(0,l-t.indentSize))}return{globalVariables:s,selectorVariables:r,cssWithoutVars:o.trim()}}function $e(e,t,n){const s=e.split(`
16
- `),r=[],o=[];let a=0;for(let c=0;c<s.length;c++){const l=s[c],i=l.trim();if(!i)continue;const u=l.match(/^(\s*)/)[0].length;if(i==="}"){if(r.length>0){const p=r.pop();if(r.length>0){const f=r[r.length-1];f.children||(f.children=[]),f.children.push(p)}else o.push(p)}continue}if(i.endsWith("{")){const f={selector:i.slice(0,-1).trim(),properties:[],children:[]};r.push(f);continue}if(!i.includes("{")&&!i.includes("}")&&i.includes(":")){if(r.length>0){const p=r[r.length-1];G(i,n).forEach(h=>{const m=Object.keys(h)[0],y=R(h[m],t);p.properties.push(`${m}: ${y}`)})}continue}}for(;r.length>0;){const c=r.pop();if(r.length===0)o.push(c);else{const l=r[r.length-1];l.children||(l.children=[]),l.children.push(c)}}return Y(o,t,"",n)}function Y(e,t,n="",s=[]){let r="";const o=n.startsWith("@");for(const a of e){const c=a.selector.startsWith("@");let l=(o?" ".repeat(t.indentSize):"")+a.selector;if(c&&(l=a.selector+` {
17
- `),n&&(l.includes("&")?l=l.replace(/&/g,n):l.trim().startsWith(":")?l=n+l:l=n+(o?"":" ")+l),a.properties.length>0){r+=(c?"":l)+` {
18
- `;for(const i of a.properties)G(i,s).forEach(p=>{const f=Object.keys(p)[0],h=R(p[f],t);r+=(o?" ".repeat(t.indentSize):"")+" ".repeat(t.indentSize)+`${f}: ${h};
19
- `});r+=o?" ".repeat(t.indentSize)+`}
4
+ */const I=(function(){let g={rootSelector:":root",variablePrefix:"--",preserveOriginal:!1,indentSize:4,enableNesting:!0,autoProcessStyleTags:!0,styleTagAttribute:"e",convertLabToRGB:!0,convertLchToRGB:!0,enableP3:!0,enableMath:!0,mathPrecision:6,importBaseUrl:"",importCache:!0,importTimeout:5e3,enableAlias:!0,enableMacros:!0},F=null;const _=new Map,k=new Map,M=new Map,C=new Map;function re(t){const e={...g},n=t.split(`
5
+ `),s=[];for(let o of n){const r=o.trim();if(r.startsWith("#")){const a=r.substring(1).trim(),c=a.indexOf(" ");if(c!==-1){const l=a.substring(0,c).trim(),i=a.substring(c+1).trim(),u=ce(l);u in e?i==="true"||i==="false"?e[u]=i==="true":!isNaN(i)&&i.trim()!==""?e[u]=Number(i):e[u]=i:console.warn(`\u672A\u77E5\u7684\u914D\u7F6E\u9879: ${l}`)}else console.warn(`\u65E0\u6548\u7684\u914D\u7F6E\u884C: ${r}`)}else s.push(o)}return{config:e,css:s.join(`
6
+ `)}}function se(t){const e=new Map,n=t.split(`
7
+ `),s=[];for(let o of n){const r=o.trim();if(r.startsWith("@alias")){const a=r.match(/^@alias\s+([a-zA-Z0-9_-]+)\s+(.+?)\s*;$/);if(a){const c=a[1],l=a[2];e.set(c,l);continue}}s.push(o)}return{aliases:e,css:s.join(`
8
+ `)}}function X(t,e){if(!e.enableMacros)return{macros:new Map,css:t};const n=new Map,s=t.split(`
9
+ `),o=[];let r=!1,a="",c=[],l=[],i=0;for(let u of s){const h=u.trim();if(!r&&h.startsWith("@macro")){const p=h.match(/^@macro\s+([a-zA-Z0-9_-]+)\s*\(([^)]*)\)\s*\{$/);if(p){r=!0,a=p[1],c=p[2].split(",").map(f=>f.trim()).filter(f=>f).map(f=>{const d=f.split(":").map(b=>b.trim());return{name:d[0].slice(1),defaultValue:d[1]||null}}),l=[],i=1;continue}}if(r){for(const p of u)p==="{"&&i++,p==="}"&&i--;i===0?(n.set(a,{params:c,body:l.join(`
10
+ `)}),r=!1,a="",c=[],l=[]):l.push(u);continue}o.push(u)}return{macros:n,css:o.join(`
11
+ `)}}function oe(t,e,n){if(!n.enableMacros||e.size===0)return t;const s=Array.from(e.keys()).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),o=new RegExp(`@(${s})\\s*\\(([^)]*)\\)\\s*;?`,"g");return(a=>{let c=a,l=!1;do l=!1,c=c.replace(o,(i,u,h)=>{l=!0;const p=e.get(u);if(!p)return console.warn(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${u}`),i;const f=Z(h,p.params);return O(p.body,f,n)});while(l);return c})(t)}function Z(t,e){const n=new Map,s=ae(t);for(let o=0;o<e.length;o++){const r=e[o];let a;o<s.length?a=s[o]:r.defaultValue!==null?a=r.defaultValue:(console.warn(`\u5B8F\u8C03\u7528\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${r.name}`),a=""),n.set(r.name,a)}return s.length>e.length&&console.warn("\u5B8F\u8C03\u7528\u4F20\u9012\u4E86\u8FC7\u591A\u53C2\u6570\uFF0C\u591A\u4F59\u7684\u53C2\u6570\u5C06\u88AB\u5FFD\u7565"),n}function ae(t){const e=[];let n="",s=!1,o="",r=0,a=0;for(let c=0;c<t.length;c++){const l=t[c];(l==='"'||l==="'")&&!s?(s=!0,o=l):l===o&&s&&(s=!1,o=""),s||(l==="("&&r++,l===")"&&r--,l==="["&&a++,l==="]"&&a--),l===","&&!s&&r===0&&a===0?(e.push(n.trim()),n=""):n+=l}return n.trim()&&e.push(n.trim()),e}function O(t,e,n){let s=t;for(const[o,r]of e){const a=new RegExp(`\\$${o}`,"g");s=s.replace(a,r)}if(n.enableMacros){const o=Array.from(M.keys()).map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");if(o){const r=new RegExp(`@(${o})\\s*\\(([^)]*)\\)\\s*;?`,"g");let a;do a=!1,s=s.replace(r,(c,l,i)=>{a=!0;const u=M.get(l);if(!u)return c;const h=Z(i,u.params);return O(u.body,h,n)});while(a)}}return s=R(s,n),s}function ce(t){return t.replace(/-([a-z])/g,function(e,n){return n.toUpperCase()})}function j(){if(F!==null)return F;if(typeof window>"u"||!window.CSS)return F=!1,!1;try{F=CSS.supports("color","color(display-p3 1 0 0)")}catch(t){console.warn("P3\u652F\u6301\u68C0\u6D4B\u5931\u8D25:",t),F=!1}return F}function q(t,e,n){let s=t.trim();if(s.endsWith(";")&&(s=s.slice(0,-1)),!s)return[];const o=[];let r="",a=0,c=!1,l="";for(let u=0;u<s.length;u++){const h=s[u];(h==='"'||h==="'")&&!c?(c=!0,l=h):h===l&&c&&(c=!1,l=""),c||(h==="("?a++:h===")"&&a--),h===";"&&!c&&a===0?r.trim()&&(o.push(r.trim()),r=""):r+=h}r.trim()&&o.push(r.trim());const i=[];for(const u of o){if(!u.trim())continue;const h=le(u);if(h===-1){console.warn(`\u65E0\u6548\u7684CSS\u58F0\u660E: "${u}"`);continue}let p=u.substring(0,h).trim(),f=u.substring(h+1).trim();if(f.endsWith(";")&&(f=f.slice(0,-1).trim()),e.get(p)&&(p=e.get(p)),p.startsWith("@")&&n.get(p.slice(1))){const d=n.get(p.slice(1)),b=Z(f.split(" ").join(","),d.params);p=O(d.body,b,ne),f=""}i.push({[p]:f})}return i}function le(t){let e=!1,n="";for(let s=0;s<t.length;s++){const o=t[s];if((o==='"'||o==="'")&&!e?(e=!0,n=o):o===n&&e&&(e=!1,n=""),o===":"&&!e)return s}return-1}function N(t,e){if(!e.enableMath)return`math(${t})`;try{let n=t.replace(/\s+/g,"");const s=D(n,e);return ie(n)?ue(n,s):Q(s,e.mathPrecision)}catch(n){return console.warn("math()\u8868\u8FBE\u5F0F\u89E3\u6790\u5931\u8D25:",t,n),`math(${t})`}}function D(t,e){for(;t.includes("(")&&t.includes(")");){const n=t.lastIndexOf("("),s=t.indexOf(")",n);if(s===-1)break;const o=t.substring(n+1,s),r=D(o,e);t=t.substring(0,n)+r+t.substring(s+1)}return Y(t,e)}function Y(t,e){const n=[{regex:/([\d.]+(?:[a-zA-Z%]+)?)\*([\d.]+(?:[a-zA-Z%]+)?)/,handler:fe},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\/([\d.]+(?:[a-zA-Z%]+)?)/,handler:pe},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\+([\d.]+(?:[a-zA-Z%]+)?)/,handler:he},{regex:/([\d.]+(?:[a-zA-Z%]+)?)-([\d.]+(?:[a-zA-Z%]+)?)/,handler:de}];let s=t;for(const r of n){let a;for(;(a=t.match(r.regex))!==null;){const c=T(a[1]),l=T(a[2]),i=r.handler(c,l);t=t.substring(0,a.index)+i.value+t.substring(a.index+a[0].length)}}return t!==s?Y(t,e):T(t).value}function T(t){const e=t.match(/^([\d.]+)([a-zA-Z%]*)$/);if(!e)throw new Error(`\u65E0\u6CD5\u89E3\u6790\u503C: ${t}`);const n=parseFloat(e[1]),s=e[2]||"";return{value:n,unit:s}}function ie(t){return/[a-zA-Z%]/.test(t)}function ue(t,e){const n=t.match(/([a-zA-Z%]+)(?!.*[a-zA-Z%])/);return n?e+n[1]:t.includes("%")?e+"%":e+"px"}function fe(t,e){return t.unit===e.unit||!t.unit&&!e.unit?{value:t.value*e.value,unit:t.unit||e.unit}:{value:`${t.value}${t.unit}*${e.value}${e.unit}`,unit:""}}function pe(t,e){if(e.value===0)throw new Error("\u9664\u4EE5\u96F6");return t.unit&&!e.unit?{value:t.value/e.value,unit:t.unit}:t.unit===e.unit?{value:t.value/e.value,unit:""}:{value:`${t.value}${t.unit}/${e.value}${e.unit}`,unit:""}}function he(t,e){return t.unit===e.unit?{value:t.value+e.value,unit:t.unit}:{value:`${t.value}${t.unit}+${e.value}${e.unit}`,unit:""}}function de(t,e){return t.unit===e.unit?{value:t.value-e.value,unit:t.unit}:{value:`${t.value}${t.unit}-${e.value}${e.unit}`,unit:""}}function Q(t,e=6){const n=Math.pow(10,e),o=(Math.round(t*n)/n).toString();return o.includes(".")?o.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""):o}function me(t,e){if(!e.enableMath)return t;let n=t;const s=/math\(([^)]+)\)/gi,o=a=>a.replace(s,(c,l)=>N(l,e));let r;do r=n,n=o(n);while(n!==r&&n.includes("math("));return n}function ge(t,e){if(!e.convertLabToRGB&&!e.convertLchToRGB)return t;let n=t;n=be(n,e);const s=/(lab|lch)\([^)]+\)/gi,o=new Map,r=c=>c.replace(s,l=>{if(o.has(l))return o.get(l);let i=l;return l.toLowerCase().startsWith("lab(")?e.convertLabToRGB&&(i=ye(l,e)):l.toLowerCase().startsWith("lch(")&&e.convertLchToRGB&&(i=$e(l,e)),o.set(l,i),i});let a;do a=n,n=r(n);while(n!==a);return n}function be(t,e){let n=t;const s=/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/gi,o=/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/gi,r=new Map;return n=n.replace(s,(a,c,l,i)=>{if(r.has(a))return r.get(a);try{const u=parseInt(c,16)/255*100,h=(parseInt(l,16)-128)*1.5,p=(parseInt(i,16)-128)*1.5,f=x(u,h,p,e);return r.set(a,f),f}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lab#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n=n.replace(o,(a,c,l,i)=>{if(r.has(a))return r.get(a);try{const u=parseInt(c,16)/255*100,h=parseInt(l,16)/255*150,p=parseInt(i)/100*360,f=L(u,h,p),d=x(f.L,f.a,f.b,e);return r.set(a,d),d}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lch#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${a}`,u),a}}),n}function ye(t,e){const n=/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=t.match(n);if(!s)return t;try{let o=parseFloat(s[1]);s[2]==="%"?o=o:(o<0&&(o=0),o>100&&(o=100));const r=parseFloat(s[3]),a=parseFloat(s[4]),c=s[5]!==void 0?s[5].includes("%")?parseFloat(s[5])/100:parseFloat(s[5]):null;return x(o,r,a,e,c)}catch(o){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LAB\u989C\u8272: ${t}`,o),t}}function $e(t,e){const n=/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i,s=t.match(n);if(!s)return t;try{let o=parseFloat(s[1]);s[2]==="%"?o=o:(o<0&&(o=0),o>100&&(o=100));const r=parseFloat(s[3]);let a=parseFloat(s[4]);r<0&&console.warn(`LCH\u4E2D\u7684C\u503C\u4E0D\u80FD\u4E3A\u8D1F: ${r}`),a=(a%360+360)%360;const c=L(o,r,a),l=s[6]!==void 0?s[6].includes("%")?parseFloat(s[6])/100:parseFloat(s[6]):null;return x(c.L,c.a,c.b,e,l)}catch(o){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LCH\u989C\u8272: ${t}`,o),t}}function L(t,e,n){const s=n*Math.PI/180,o=e*Math.cos(s),r=e*Math.sin(s);return{L:t,a:o,b:r}}function A(t,e,n){const s=(m,y,$)=>{const E=(m+16)/116,B=y/500+E,G=E-$/200,Re=B**3>.008856?B**3:(116*B-16)/903.3,Pe=m>903.3*.008856?((m+16)/116)**3:m/903.3,Fe=G**3>.008856?G**3:(116*G-16)/903.3;return[Re*.95047,Pe*1,Fe*1.08883]},o=(m,y,$)=>{const w=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]],v=w[0][0]*m+w[0][1]*y+w[0][2]*$,U=w[1][0]*m+w[1][1]*y+w[1][2]*$,S=w[2][0]*m+w[2][1]*y+w[2][2]*$;return[v,U,S]},r=m=>{const y=m<0?-1:1,$=Math.abs(m);return $<=.0031308?y*12.92*$:y*(1.055*Math.pow($,.4166666666666667)-.055)},a=m=>Math.max(0,Math.min(255,Math.round(m*255))),[c,l,i]=s(t,e,n),[u,h,p]=o(c,l,i),f=r(u),d=r(h),b=r(p);return{r:a(f),g:a(d),b:a(b)}}function V(t,e,n){const s=(c,l,i)=>{const b=(c+16)/116,m=l/500+b,y=b-i/200,$=m**3>.008856?m**3:(116*m-16)/903.3,w=c>903.3*.008856?((c+16)/116)**3:c/903.3,v=y**3>.008856?y**3:(116*y-16)/903.3;return[$*.95047,w*1,v*1.08883]},o=(c,l,i)=>{const u=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]],h=u[0][0]*c+u[0][1]*l+u[0][2]*i,p=u[1][0]*c+u[1][1]*l+u[1][2]*i,f=u[2][0]*c+u[2][1]*l+u[2][2]*i;return[h,p,f]},r=c=>{const l=c<0?-1:1,i=Math.abs(c);return i<=.0031308?l*12.92*i:l*(1.055*Math.pow(i,.4166666666666667)-.055)},a=c=>Math.max(0,Math.min(255,Math.round(c*255)));try{const[c,l,i]=s(t,e,n),[u,h,p]=o(c,l,i),f=r(u),d=r(h),b=r(p);return{r:Math.max(0,Math.min(1,f)),g:Math.max(0,Math.min(1,d)),b:Math.max(0,Math.min(1,b))}}catch(c){console.warn("P3\u8F6C\u6362\u5931\u8D25:",c);const l=A(t,e,n);return{r:l.r/255,g:l.g/255,b:l.b/255}}}function x(t,e,n,s,o=null){if(!s.enableP3||!j()){const r=A(t,e,n);return o!==null?`rgba(${r.r}, ${r.g}, ${r.b}, ${o})`:`rgb(${r.r}, ${r.g}, ${r.b})`}else{const r=V(t,e,n);return o!==null?`color(display-p3 ${r.r.toFixed(4)} ${r.g.toFixed(4)} ${r.b.toFixed(4)} / ${o})`:`color(display-p3 ${r.r.toFixed(4)} ${r.g.toFixed(4)} ${r.b.toFixed(4)})`}}function R(t,e){let n=t;return e.enableMath&&(n=me(n,e)),(e.convertLabToRGB||e.convertLchToRGB)&&(n=ge(n,e)),n}function we(t,e){const n=t.split(`
12
+ `),s={},o=new Map;let r="",a=null,c=!1,l=0;for(let i of n){const u=i.trim(),h=u.match(/^\$([a-zA-Z0-9_-]+)\s*:\s*(.+?);?$/);if(h){const[,p,f]=h,d=R(J(f.trim(),{...s,...a?o.get(a)||{}:{}}),e);a?(o.has(a)||o.set(a,{}),o.get(a)[p]=d):s[p]=d;continue}if(u.endsWith("{")){a=u.slice(0,-1).trim(),c=!0,r+=i+`
13
+ `;continue}if(u==="}"){if(c&&a&&o.has(a)){const p=o.get(a),f=" ".repeat(l);for(const[d,b]of Object.entries(p))r+=`${f} --${d}: ${b};
14
+ `}c=!1,a=null}r+=i+`
15
+ `,i.includes("{")&&(l+=e.indentSize),i.includes("}")&&(l=Math.max(0,l-e.indentSize))}return{globalVariables:s,selectorVariables:o,cssWithoutVars:r.trim()}}function ve(t,e,n,s){const o=t.split(`
16
+ `),r=[],a=[];let c=0;for(let l=0;l<o.length;l++){const i=o[l],u=i.trim();if(!u)continue;const h=i.match(/^(\s*)/)[0].length;if(u==="}"){if(r.length>0){const p=r.pop();if(r.length>0){const f=r[r.length-1];f.children||(f.children=[]),f.children.push(p)}else a.push(p)}continue}if(u.endsWith("{")){const f={selector:u.slice(0,-1).trim(),properties:[],children:[]};r.push(f);continue}if(!u.includes("{")&&!u.includes("}")&&u.includes(":")){if(r.length>0){const p=r[r.length-1];q(u,n,s).forEach(d=>{const b=Object.keys(d)[0],m=R(d[b],e);p.properties.push(m===""?b:`${b}: ${m}`)})}continue}}for(;r.length>0;){const l=r.pop();if(r.length===0)a.push(l);else{const i=r[r.length-1];i.children||(i.children=[]),i.children.push(l)}}return K(a,e,"",n,s)}function K(t,e,n="",s,o){let r="";const a=n.startsWith("@");for(const c of t){const l=c.selector.startsWith("@");let i=(a?" ".repeat(e.indentSize):"")+c.selector;if(l&&(i=c.selector+` {
17
+ `),n&&(i.includes("&")?i=i.replace(/&/g,n):i.trim().startsWith(":")?i=n+i:i=n+(a?"":" ")+i),c.properties.length>0){r+=(l?"":i)+` {
18
+ `;for(const u of c.properties)q(u,s,o).forEach(p=>{const f=Object.keys(p)[0],d=R(p[f],e);r+=(a?" ".repeat(e.indentSize):"")+" ".repeat(e.indentSize)+(d===""?f:`${f}: ${d};
19
+ `)});r+=a?" ".repeat(e.indentSize)+`}
20
20
  `:`}
21
21
 
22
- `}a.children&&a.children.length>0&&(r+=Y(a.children,t,l,s)),o&&(r+=`}
22
+ `}c.children&&c.children.length>0&&(r+=K(c.children,e,i,s,o)),a&&(r+=`}
23
23
 
24
24
  `)}return r.trim()+`
25
25
 
26
- `}function Q(e,t){return e.replace(/\$([a-zA-Z0-9_-]+)/g,(n,s)=>t[s]?`var(--${s})`:n)}function we(e,t,n,s){let r=e;return r=r.replace(/(?:\$\$|\$)([a-zA-Z0-9_-]+)/g,(o,a)=>o.startsWith("$$")?`attr(${a})`:`var(--${a})`),r=R(r,s),r}function ve(e,t){if(Object.keys(e).length===0)return"";const n=Object.entries(e).map(([s,r])=>{const o=R(Q(r,e),t);return" ".repeat(t.indentSize)+`--${s}: ${o};`}).join(`
27
- `);return`${t.rootSelector} {
26
+ `}function J(t,e){return t.replace(/\$([a-zA-Z0-9_-]+)/g,(n,s)=>e[s]?`var(--${s})`:n)}function Me(t,e,n,s){let o=t;return o=o.replace(/(?:\$\$|\$)([a-zA-Z0-9_-]+)/g,(r,a)=>r.startsWith("$$")?`attr(${a})`:`var(--${a})`),o=R(o,s),o}function Ce(t,e){if(Object.keys(t).length===0)return"";const n=Object.entries(t).map(([s,o])=>{const r=R(J(o,t),e);return" ".repeat(e.indentSize)+`--${s}: ${r};`}).join(`
27
+ `);return`${e.rootSelector} {
28
28
  ${n}
29
29
  }
30
30
 
31
- `}function Me(e,t,n){let s="";const r=e.split(`
32
- `);let o=null;for(let a of r){const c=a.trim();if(c.endsWith("{")&&(o=c.slice(0,-1).trim()),c==="}"&&o){if(t.has(o)){const l=t.get(o),i=a.match(/^(\s*)/)[0];for(const[u,p]of Object.entries(l))s+=" --"+u+": "+p+`;
33
- `}o=null}s+=R(a,n)+`
34
- `}return s.trim()}async function K(e,t){const n=/@import\s+([^;]+?)\s*;/g;return(async r=>{const o=[],a=r.replace(n,(c,l)=>{const i=Ce(l,t).then(u=>K(u,t)).catch(u=>(console.warn(`\u65E0\u6CD5\u5BFC\u5165CSS\u6587\u4EF6: ${l}`,u),""));return o.push(i),`__IMPORT_PLACEHOLDER_${o.length-1}__`});if(o.length>0){const c=await Promise.all(o);let l=a;for(let i=0;i<c.length;i++)l=l.replace(`__IMPORT_PLACEHOLDER_${i}__`,c[i]);return l}return a})(e)}async function Ce(e,t){if(t.importCache&&B.has(e))return B.get(e);const n=t.importBaseUrl?new URL(e,t.importBaseUrl).href:e;let s;if(typeof process<"u"&&process.versions&&process.versions.node&&typeof require<"u")try{const o=require("fs"),a=require("path");let c=n;n.startsWith(".")&&(c=a.join(process.cwd(),n)),s=o.readFileSync(c,"utf-8")}catch(o){throw new Error(`Node.js\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${n} - ${o.message}`)}else try{const o=new AbortController,a=setTimeout(()=>o.abort(),t.importTimeout),c=await fetch(n,{signal:o.signal,headers:{Accept:"text/css"}});if(clearTimeout(a),!c.ok)throw new Error(`HTTP\u9519\u8BEF: ${c.status} ${c.statusText}`);s=await c.text()}catch(o){throw o.name==="AbortError"?new Error(`\u5BFC\u5165\u8D85\u65F6: ${n}`):new Error(`\u65E0\u6CD5\u83B7\u53D6CSS: ${n} - ${o.message}`)}return t.importCache&&B.set(e,s),s}function P(e,t={}){const n=(o,a)=>{const{config:c,css:l}=te(o),i={...d,...t,...c};let u=l,p=new Map;if(i.enableAlias){const{aliases:S,css:F}=ne(u);p=S,u=F}let f=u,h=new Map;if(i.enableMacros){const{macros:S,css:F}=H(f,i);h=S,f=F;for(const[ee,W]of h)v.set(ee,W)}let m=f;i.enableMacros&&h.size>0&&(m=re(m,h,i));const{globalVariables:y,selectorVariables:g,cssWithoutVars:b}=ye(m,i);let $=b.trim();if(i.enableNesting&&b.includes("{"))try{$=$e(b,i,p)}catch(S){console.warn("\u5D4C\u5957\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CBCSS:",S)}const w=ve(y,i);let M=$;return g.size>0&&(M=Me($,g,i)),M=we(M,y,g,i),w+M},s=e&&/@import\s+([^;]+?)\s*;/g.test(e),r={...d,...t};return s?(async()=>{try{const o=await K(e,r);return n(o,r)}catch(o){return console.error("@import\u5904\u7406\u5931\u8D25:",o),n(e,r)}})():n(e,r)}function J(e={}){const t={...d,...e},n=document.querySelectorAll(`style[${t.styleTagAttribute||"e"}]`);return n.forEach(s=>{let r=s.textContent;(async()=>{try{s.getAttribute("src")&&(r="@import "+s.getAttribute("src")+";");const a=await P(r,t),c=document.createElement("style");c.textContent=a,s.parentNode.insertBefore(c,s.nextSibling),t.preserveOriginal?s.style.display="none":s.remove()}catch(a){console.error("\u5904\u7406style\u6807\u7B7E\u5931\u8D25:",a)}})()}),n.length}function Se(e={}){d={...d,...e}}function Z(e,t={}){const n={...d,...t};if(e){if(/@import\s+([^;]+?)\s*;/g.test(e))return(async()=>{try{const r=await P(e,n),o=document.createElement("style");return o.textContent=r,document.head.appendChild(o),o}catch(r){return console.error("\u5E94\u7528CSS\u5931\u8D25:",r),null}})();{const r=P(e,n),o=document.createElement("style");return o.textContent=r,document.head.appendChild(o),o}}else document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{J(n)}):J(n)}const Ae={convert:P,apply:Z,config:Se,supportsP3:_(),detectP3Support:_,imports:{clearCache:function(){B.clear()},setBaseUrl:function(e){d.importBaseUrl=e},setCacheEnabled:function(e){d.importCache=e},setTimeout:function(e){d.importTimeout=e}},aliases:{add:function(e,t){I.set(e,t)},remove:function(e){I.delete(e)},getAll:function(){return Array.from(I.entries())},clear:function(){I.clear()}},macros:{define:function(e,t,n=[]){if(typeof t=="function"){const r=t.toString().match(/{([\s\S]*)}/);r&&v.set(e,{params:n.map(o=>typeof o=="string"?{name:o}:o),body:r[1].trim()})}else v.set(e,{params:n.map(s=>typeof s=="string"?{name:s}:s),body:t})},call:function(e,...t){const n=v.get(e);if(!n)throw new Error(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${e}`);const s=new Map;for(let r=0;r<n.params.length;r++){const o=n.params[r],a=r<t.length?t[r]:o.defaultValue;if(a===void 0&&o.defaultValue===null)throw new Error(`\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${o.name}`);s.set(o.name,a!==void 0?a:"")}return O(n.body,s,d)},getAll:function(){return Array.from(v.entries())},remove:function(e){v.delete(e)},clear:function(){v.clear()},parse:function(e){const{macros:t}=H(e,d);for(const[n,s]of t)v.set(n,s)}},math:{evaluate:function(e){return k(e,d)},parseUnit:z,round:D,test:function(e,t={}){const n={...d,...t};try{const s=k(e,n);return{success:!0,expression:e,result:s,parsed:z(s.replace(/^calc\(|\)$/g,""))}}catch(s){return{success:!1,expression:e,error:s.message}}}},colorUtils:{labToRGB:C,lchToLab:A,lchToRGB:function(e,t,n){const s=A(e,t,n);return C(s.L,s.a,s.b)},labToP3:E,lchToP3:function(e,t,n){const s=A(e,t,n);return E(s.L,s.a,s.b)},parseHexLab:function(e){const t=e.match(/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i);if(!t)return null;const n=t[1],s=t[2],r=t[3],o=parseInt(n,16)/255*100,a=(parseInt(s,16)-128)*1.5,c=(parseInt(r,16)-128)*1.5;return C(o,a,c)},parseHexLch:function(e){const t=e.match(/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/i);if(!t)return null;const n=t[1],s=t[2],r=t[3],o=parseInt(n,16)/255*100,a=parseInt(s,16)/255*150,c=parseInt(r)/100*360,l=A(o,a,c);return C(l.L,l.a,l.b)},generateColor:function(e,t,n,s=null,r=!0){return L(e,t,n,{enableP3:r},s)},parseColor:function(e){try{const t=e.match(/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(t){let s=parseFloat(t[1]);const r=parseFloat(t[3]),o=parseFloat(t[4]),a=t[5]?t[5].includes("%")?parseFloat(t[5])/100:parseFloat(t[5]):null,c=L(s,r,o,d,a);return{L:s,A:r,B:o,alpha:a,rgb:C(s,r,o),p3:E(s,r,o),colorString:c}}const n=e.match(/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(n){let s=parseFloat(n[1]);const r=parseFloat(n[3]);let o=parseFloat(n[4]);const a=n[6]?n[6].includes("%")?parseFloat(n[6])/100:parseFloat(n[6]):null,c=A(s,r,o),l=L(c.L,c.a,c.b,d,a);return{L:s,C:r,H:o,alpha:a,lab:c,rgb:C(c.L,c.a,c.b),p3:E(c.L,c.a,c.b),colorString:l}}return null}catch(t){return console.warn("\u65E0\u6CD5\u89E3\u6790\u989C\u8272:",e,t),null}}}},T=function(...e){if(e.length>1||e[0]&&e[0].raw)return Le(...e);const t=e[0];if(typeof t=="string"){const n=P(t,{...d,...e[1]});return n&&typeof n.then=="function",n}return typeof t=="object"&&t!==null?(d={...d,...t},T):e.length===0?Z():T};function Le(e,...t){let n=e[0];for(let r=0;r<t.length;r++){const o=t[r];let a="";typeof o=="function"?a=o():Array.isArray(o)?a=o.join(" "):a=String(o??""),n+=a+e[r+1]}const s=P(n,d);return s&&typeof s.then=="function",s}return Object.assign(T,Ae),Object.setPrototypeOf(T,Function.prototype),typeof window<"u"&&(Z(),Object.defineProperty(window.HTMLElement.prototype,"cssVar",{get(){const e=this;return new Proxy(()=>{},{get(t,n){const s=n.startsWith("--")?n:`--${n}`;return e.style.getPropertyValue(s)},set(t,n,s){const r=n.startsWith("--")?n:`--${n}`;return e.style.setProperty(r,s),!0},apply(t,n,s){const r=s[0],o=s[1],a=r.startsWith("--")?r:`--${r}`;if(o===void 0)return e.style.getPropertyValue(a);e.style.setProperty(a,o)}})}})),T})();if(typeof define=="function"&&define.amd)define([],()=>V);else if(typeof module=="object"&&module.exports)module.exports=V;else{const d=globalThis??(typeof self<"u"&&self)??(typeof window<"u"&&window)??global??{};d.styimat=V}export default V;export const{convert,apply,config,supportsP3,detectP3Support,imports,aliases,macros,math,colorUtils}=V;
31
+ `}function Se(t,e,n){let s="";const o=t.split(`
32
+ `);let r=null;for(let a of o){const c=a.trim();c.endsWith("{")&&(r=c.slice(0,-1).trim()),c==="}"&&r&&(r=null),s+=R(a,n)+`
33
+ `}return s.trim()}async function ee(t,e){const n=/@import\s+([^;]+?)\s*;/g;return(async o=>{const r=[],a=o.replace(n,(c,l)=>{const i=Ae(l,e).then(u=>ee(u,e)).catch(u=>(console.warn(`\u65E0\u6CD5\u5BFC\u5165CSS\u6587\u4EF6: ${l}`,u),""));return r.push(i),`__IMPORT_PLACEHOLDER_${r.length-1}__`});if(r.length>0){const c=await Promise.all(r);let l=a;for(let i=0;i<c.length;i++)l=l.replace(`__IMPORT_PLACEHOLDER_${i}__`,c[i]);return l}return a})(t)}async function Ae(t,e){if(e.importCache&&_.has(t))return _.get(t);const n=e.importBaseUrl?new URL(t,e.importBaseUrl).href:t;let s;if(typeof process<"u"&&process.versions&&process.versions.node&&typeof require<"u")try{const r=require("fs"),a=require("path");let c=n;n.startsWith(".")&&(c=a.join(process.cwd(),n)),s=r.readFileSync(c,"utf-8")}catch(r){throw new Error(`Node.js\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${n} - ${r.message}`)}else try{const r=new AbortController,a=setTimeout(()=>r.abort(),e.importTimeout),c=await fetch(n,{signal:r.signal,headers:{Accept:"text/css"}});if(clearTimeout(a),!c.ok)throw new Error(`HTTP\u9519\u8BEF: ${c.status} ${c.statusText}`);s=await c.text()}catch(r){throw r.name==="AbortError"?new Error(`\u5BFC\u5165\u8D85\u65F6: ${n}`):new Error(`\u65E0\u6CD5\u83B7\u53D6CSS: ${n} - ${r.message}`)}return e.importCache&&_.set(t,s),s}function z(t,e={}){const n=(r,a)=>{const{config:c,css:l}=re(r),i={...g,...e,...c};let u=l,h=new Map;if(i.enableAlias){const{aliases:S,css:P}=se(u);h=S,u=P}let p=u,f=new Map;if(i.enableMacros){const{macros:S,css:P}=X(p,i);f=S,p=P;for(const[E,B]of f)M.set(E,B)}let d=p;i.enableMacros&&f.size>0&&(d=oe(d,f,i));const{globalVariables:b,selectorVariables:m,cssWithoutVars:y}=we(d,i);let $=y.trim();if(i.enableNesting&&y.includes("{"))try{$=ve(y,i,h,f)}catch(S){console.warn("\u5D4C\u5957\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CBCSS:",S)}const w=Ce(b,i);let v=$;m.size>0&&(v=Se($,m,i)),v=Me(v,b,m,i);for(const[S,P]of C)try{P.enable&&(v=P.convert(v,i))}catch(E){console.error("\u63D2\u4EF6\u5904\u7406\u5931\u8D25:",E)}return w+v},s=t&&/@import\s+([^;]+?)\s*;/g.test(t),o={...g,...e};return s?(async()=>{try{const r=await ee(t,o);return n(r,o)}catch(r){return console.error("@import\u5904\u7406\u5931\u8D25:",r),n(t,o)}})():n(t,o)}function te(t={}){const e={...g,...t},n=document.querySelectorAll(`style[${e.styleTagAttribute||"e"}]`);return n.forEach(s=>{let o=s.textContent;(async()=>{try{s.getAttribute("src")&&(o="@import "+s.getAttribute("src")+";");const a=await z(o,e),c=document.createElement("style");c.textContent=a,s.parentNode.insertBefore(c,s.nextSibling),e.preserveOriginal?s.style.display="none":s.remove()}catch(a){console.error("\u5904\u7406style\u6807\u7B7E\u5931\u8D25:",a)}})()}),n.length}function ne(t={}){g={...g,...t}}function H(t,e={}){const n={...g,...e};if(t){if(/@import\s+([^;]+?)\s*;/g.test(t))return(async()=>{try{const o=await z(t,n),r=document.createElement("style");return r.textContent=o,document.head.appendChild(r),r}catch(o){return console.error("\u5E94\u7528CSS\u5931\u8D25:",o),null}})();{const o=z(t,n),r=document.createElement("style");return r.textContent=o,document.head.appendChild(r),r}}else document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{te(n)}):te(n)}const Le={convert:z,apply:H,config:ne,supportsP3:j(),detectP3Support:j,imports:{clearCache:function(){_.clear()},setBaseUrl:function(t){g.importBaseUrl=t},setCacheEnabled:function(t){g.importCache=t},setTimeout:function(t){g.importTimeout=t}},plugins:new Proxy({},{set(t,e,n){return(n.created??(()=>{}))(),C.set(e,n),!0},get(t,e){return C.get(e)},deleteProperty(t,e){return C.get(e)?.deleted(),C.delete(e),!0},has(t,e){return C.has(e)},ownKeys(){return Array.from(C.keys())},getOwnPropertyDescriptor(t,e){if(C.has(e))return{enumerable:!0,configurable:!0,writable:!0,value:C.get(e)}}}),aliases:{add:function(t,e){k.set(t,e)},remove:function(t){k.delete(t)},getAll:function(){return Array.from(k.entries())},clear:function(){k.clear()}},macros:{define:function(t,e,n=[]){if(typeof e=="function"){const o=e.toString().match(/{([\s\S]*)}/);o&&M.set(t,{params:n.map(r=>typeof r=="string"?{name:r}:r),body:o[1].trim()})}else M.set(t,{params:n.map(s=>typeof s=="string"?{name:s}:s),body:e})},call:function(t,...e){const n=M.get(t);if(!n)throw new Error(`\u672A\u5B9A\u4E49\u7684\u5B8F: ${t}`);const s=new Map;for(let o=0;o<n.params.length;o++){const r=n.params[o],a=o<e.length?e[o]:r.defaultValue;if(a===void 0&&r.defaultValue===null)throw new Error(`\u7F3A\u5C11\u5FC5\u9700\u53C2\u6570: ${r.name}`);s.set(r.name,a!==void 0?a:"")}return O(n.body,s,g)},getAll:function(){return Array.from(M.entries())},remove:function(t){M.delete(t)},clear:function(){M.clear()},parse:function(t){const{macros:e}=X(t,g);for(const[n,s]of e)M.set(n,s)}},math:{evaluate:function(t){return N(t,g)},parseUnit:T,round:Q,test:function(t,e={}){const n={...g,...e};try{const s=N(t,n);return{success:!0,expression:t,result:s,parsed:T(s.replace(/^calc\(|\)$/g,""))}}catch(s){return{success:!1,expression:t,error:s.message}}}},colorUtils:{labToRGB:A,lchToLab:L,lchToRGB:function(t,e,n){const s=L(t,e,n);return A(s.L,s.a,s.b)},labToP3:V,lchToP3:function(t,e,n){const s=L(t,e,n);return V(s.L,s.a,s.b)},parseHexLab:function(t){const e=t.match(/lab#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i);if(!e)return null;const n=e[1],s=e[2],o=e[3],r=parseInt(n,16)/255*100,a=(parseInt(s,16)-128)*1.5,c=(parseInt(o,16)-128)*1.5;return A(r,a,c)},parseHexLch:function(t){const e=t.match(/lch#([0-9a-f]{2})([0-9a-f]{2})(\d{1,3})/i);if(!e)return null;const n=e[1],s=e[2],o=e[3],r=parseInt(n,16)/255*100,a=parseInt(s,16)/255*150,c=parseInt(o)/100*360,l=L(r,a,c);return A(l.L,l.a,l.b)},generateColor:function(t,e,n,s=null,o=!0){return x(t,e,n,{enableP3:o},s)},parseColor:function(t){try{const e=t.match(/lab\(\s*([\d.]+)(%?)\s+([\d.-]+)\s+([\d.-]+)(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(e){let s=parseFloat(e[1]);const o=parseFloat(e[3]),r=parseFloat(e[4]),a=e[5]?e[5].includes("%")?parseFloat(e[5])/100:parseFloat(e[5]):null,c=x(s,o,r,g,a);return{L:s,A:o,B:r,alpha:a,rgb:A(s,o,r),p3:V(s,o,r),colorString:c}}const n=t.match(/lch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(deg)?(?:\s*\/\s*([\d.%]+))?\s*\)/i);if(n){let s=parseFloat(n[1]);const o=parseFloat(n[3]);let r=parseFloat(n[4]);const a=n[6]?n[6].includes("%")?parseFloat(n[6])/100:parseFloat(n[6]):null,c=L(s,o,r),l=x(c.L,c.a,c.b,g,a);return{L:s,C:o,H:r,alpha:a,lab:c,rgb:A(c.L,c.a,c.b),p3:V(c.L,c.a,c.b),colorString:l}}return null}catch(e){return console.warn("\u65E0\u6CD5\u89E3\u6790\u989C\u8272:",t,e),null}}}},W=function(...t){if(t.length>1||t[0]&&t[0].raw)return xe(...t);const e=t[0];if(typeof e=="string"){const n=z(e,{...g,...t[1]});return n&&typeof n.then=="function",n}return typeof e=="object"&&e!==null?(g={...g,...e},W):t.length===0?H():W};function xe(t,...e){let n=t[0];for(let o=0;o<e.length;o++){const r=e[o];let a="";typeof r=="function"?a=r():Array.isArray(r)?a=r.join(" "):a=String(r??""),n+=a+t[o+1]}const s=z(n,g);return s&&typeof s.then=="function",s}return Object.assign(W,Le),Object.setPrototypeOf(W,Function.prototype),typeof window<"u"&&(H(),Object.defineProperty(window.HTMLElement.prototype,"cssVar",{get(){const t=this;return new Proxy(()=>{},{get(e,n){const s=n.startsWith("--")?n:`--${n}`;return t.style.getPropertyValue(s)},set(e,n,s){const o=n.startsWith("--")?n:`--${n}`;return t.style.setProperty(o,s),!0},apply(e,n,s){const o=s[0],r=s[1],a=o.startsWith("--")?o:`--${o}`;if(r===void 0)return t.style.getPropertyValue(a);t.style.setProperty(a,r)}})}})),W})();if(typeof define=="function"&&define.amd)define([],g=>I);else if(typeof module=="object"&&module.exports)module.exports=I;else{const g=globalThis??(typeof self<"u"&&self)??(typeof window<"u"&&window)??global??{};g.styimat=I}export default I;export const{convert,apply,config,supportsP3,detectP3Support,imports,plugins,aliases,macros,math,colorUtils}=I;