styimat 4.1.0 → 4.2.1

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.
@@ -1,31 +1,34 @@
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},M=null;const T=new Map,F=new Map;function Y(t){const e={...d},n=t.split(`
5
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("#")){const i=o.substring(1).trim(),c=i.indexOf(" ");if(c!==-1){const a=i.substring(0,c).trim(),l=i.substring(c+1).trim(),u=Q(a);u in e?l==="true"||l==="false"?e[u]=l==="true":!isNaN(l)&&l.trim()!==""?e[u]=Number(l):e[u]=l:console.warn(`\u672A\u77E5\u7684\u914D\u7F6E\u9879: ${a}`)}else console.warn(`\u65E0\u6548\u7684\u914D\u7F6E\u884C: ${o}`)}else s.push(r)}return{config:e,css:s.join(`
6
- `)}}function D(t){const e=new Map,n=t.split(`
7
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("@alias")){const i=o.match(/^@alias\s+([a-zA-Z0-9_-]+)\s+(.+?)\s*;$/);if(i){const c=i[1],a=i[2];e.set(c,a),console.log(`\u6CE8\u518C\u522B\u540D: ${c} -> ${a}`);continue}}s.push(r)}return{aliases:e,css:s.join(`
8
- `)}}function Q(t){return t.replace(/-([a-z])/g,function(e,n){return n.toUpperCase()})}function E(){if(M!==null)return M;if(typeof window>"u"||!window.CSS)return M=!1,!1;try{M=CSS.supports("color","color(display-p3 1 0 0)")}catch(t){console.warn("P3\u652F\u6301\u68C0\u6D4B\u5931\u8D25:",t),M=!1}return M}function V(t,e=[]){let n=t.trim();if(n.endsWith(";")&&(n=n.slice(0,-1)),!n)return[];const s=[];let r="",o=0,i=!1,c="";for(let l=0;l<n.length;l++){const u=n[l];(u==='"'||u==="'")&&!i?(i=!0,c=u):u===c&&i&&(i=!1,c=""),i||(u==="("?o++:u===")"&&o--),u===";"&&!i&&o===0?r.trim()&&(s.push(r.trim()),r=""):r+=u}r.trim()&&s.push(r.trim());const a=[];for(const l of s){if(!l.trim())continue;const u=K(l);if(u===-1){console.warn(`\u65E0\u6548\u7684CSS\u58F0\u660E: "${l}"`);continue}let p=l.substring(0,u).trim(),f=l.substring(u+1).trim();f.endsWith(";")&&(f=f.slice(0,-1).trim()),e.get(p)&&(p=e.get(p)),a.push({[p]:f})}return a}function K(t){let e=!1,n="";for(let s=0;s<t.length;s++){const r=t[s];if((r==='"'||r==="'")&&!e?(e=!0,n=r):r===n&&e&&(e=!1,n=""),r===":"&&!e)return s}return-1}function I(t,e){if(!e.enableMath)return`math(${t})`;try{let n=t.replace(/\s+/g,"");const s=_(n,e);return J(n)?tt(n,s):k(s,e.mathPrecision)}catch(n){return console.warn("math()\u8868\u8FBE\u5F0F\u89E3\u6790\u5931\u8D25:",t,n),`math(${t})`}}function _(t,e){for(;t.includes("(")&&t.includes(")");){const n=t.lastIndexOf("("),s=t.indexOf(")",n);if(s===-1)break;const r=t.substring(n+1,s),o=_(r,e);t=t.substring(0,n)+o+t.substring(s+1)}return Z(t,e)}function Z(t,e){const n=[{regex:/([\d.]+(?:[a-zA-Z%]+)?)\*([\d.]+(?:[a-zA-Z%]+)?)/,handler:et},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\/([\d.]+(?:[a-zA-Z%]+)?)/,handler:nt},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\+([\d.]+(?:[a-zA-Z%]+)?)/,handler:rt},{regex:/([\d.]+(?:[a-zA-Z%]+)?)-([\d.]+(?:[a-zA-Z%]+)?)/,handler:st}];let s=t;for(const o of n){let i;for(;(i=t.match(o.regex))!==null;){const c=x(i[1]),a=x(i[2]),l=o.handler(c,a);t=t.substring(0,i.index)+l.value+t.substring(i.index+i[0].length)}}return t!==s?Z(t,e):x(t).value}function x(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 J(t){return/[a-zA-Z%]/.test(t)}function tt(t,e){const n=t.match(/([a-zA-Z%]+)(?!.*[a-zA-Z%])/);return n?e+n[1]:t.includes("%")?e+"%":e+"px"}function et(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 nt(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 rt(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 st(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 k(t,e=6){const n=Math.pow(10,e),r=(Math.round(t*n)/n).toString();return r.includes(".")?r.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""):r}function ot(t,e){if(!e.enableMath)return t;let n=t;const s=/math\(([^)]+)\)/gi,r=i=>i.replace(s,(c,a)=>I(a,e));let o;do o=n,n=r(n);while(n!==o&&n.includes("math("));return n}function it(t,e){if(!e.convertLabToRGB&&!e.convertLchToRGB)return t;let n=t;n=ct(n,e);const s=/(lab|lch)\([^)]+\)/gi,r=new Map,o=c=>c.replace(s,a=>{if(r.has(a))return r.get(a);let l=a;return a.toLowerCase().startsWith("lab(")?e.convertLabToRGB&&(l=at(a,e)):a.toLowerCase().startsWith("lch(")&&e.convertLchToRGB&&(l=lt(a,e)),r.set(a,l),l});let i;do i=n,n=o(n);while(n!==i);return n}function ct(t,e){let n=t;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,(i,c,a,l)=>{if(o.has(i))return o.get(i);try{const u=parseInt(c,16)/255*100,p=(parseInt(a,16)-128)*1.5,f=(parseInt(l,16)-128)*1.5,h=S(u,p,f,e);return o.set(i,h),h}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lab#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${i}`,u),i}}),n=n.replace(r,(i,c,a,l)=>{if(o.has(i))return o.get(i);try{const u=parseInt(c,16)/255*100,p=parseInt(a,16)/255*150,f=parseInt(l)/100*360,h=C(u,p,f),m=S(h.L,h.a,h.b,e);return o.set(i,m),m}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lch#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${i}`,u),i}}),n}function at(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 r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]),i=parseFloat(s[4]),c=s[5]!==void 0?s[5].includes("%")?parseFloat(s[5])/100:parseFloat(s[5]):null;return S(r,o,i,e,c)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LAB\u989C\u8272: ${t}`,r),t}}function lt(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 r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]);let i=parseFloat(s[4]);o<0&&console.warn(`LCH\u4E2D\u7684C\u503C\u4E0D\u80FD\u4E3A\u8D1F: ${o}`),i=(i%360+360)%360;const c=C(r,o,i),a=s[6]!==void 0?s[6].includes("%")?parseFloat(s[6])/100:parseFloat(s[6]):null;return S(c.L,c.a,c.b,e,a)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LCH\u989C\u8272: ${t}`,r),t}}function C(t,e,n){const s=n*Math.PI/180,r=e*Math.cos(s),o=e*Math.sin(s);return{L:t,a:r,b:o}}function w(t,e,n){const s=(g,b,y)=>{const q=(g+16)/116,O=b/500+q,W=q-y/200,$t=O**3>.008856?O**3:(116*O-16)/903.3,vt=g>903.3*.008856?((g+16)/116)**3:g/903.3,wt=W**3>.008856?W**3:(116*W-16)/903.3;return[$t*.95047,vt*1,wt*1.08883]},r=(g,b,y)=>{const v=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]],z=v[0][0]*g+v[0][1]*b+v[0][2]*y,U=v[1][0]*g+v[1][1]*b+v[1][2]*y,X=v[2][0]*g+v[2][1]*b+v[2][2]*y;return[z,U,X]},o=g=>{const b=g<0?-1:1,y=Math.abs(g);return y<=.0031308?b*12.92*y:b*(1.055*Math.pow(y,.4166666666666667)-.055)},i=g=>Math.max(0,Math.min(255,Math.round(g*255))),[c,a,l]=s(t,e,n),[u,p,f]=r(c,a,l),h=o(u),m=o(p),$=o(f);return{r:i(h),g:i(m),b:i($)}}function R(t,e,n){const s=(c,a,l)=>{const $=(c+16)/116,g=a/500+$,b=$-l/200,y=g**3>.008856?g**3:(116*g-16)/903.3,v=c>903.3*.008856?((c+16)/116)**3:c/903.3,z=b**3>.008856?b**3:(116*b-16)/903.3;return[y*.95047,v*1,z*1.08883]},r=(c,a,l)=>{const u=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]],p=u[0][0]*c+u[0][1]*a+u[0][2]*l,f=u[1][0]*c+u[1][1]*a+u[1][2]*l,h=u[2][0]*c+u[2][1]*a+u[2][2]*l;return[p,f,h]},o=c=>{const a=c<0?-1:1,l=Math.abs(c);return l<=.0031308?a*12.92*l:a*(1.055*Math.pow(l,.4166666666666667)-.055)},i=c=>Math.max(0,Math.min(255,Math.round(c*255)));try{const[c,a,l]=s(t,e,n),[u,p,f]=r(c,a,l),h=o(u),m=o(p),$=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,$))}}catch(c){console.warn("P3\u8F6C\u6362\u5931\u8D25:",c);const a=w(t,e,n);return{r:a.r/255,g:a.g/255,b:a.b/255}}}function S(t,e,n,s,r=null){if(!s.enableP3||!E()){const o=w(t,e,n);return r!==null?`rgba(${o.r}, ${o.g}, ${o.b}, ${r})`:`rgb(${o.r}, ${o.g}, ${o.b})`}else{const o=R(t,e,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 A(t,e){let n=t;return e.enableMath&&(n=ot(n,e)),(e.convertLabToRGB||e.convertLchToRGB)&&(n=it(n,e)),n}function ut(t,e){const n=t.split(`
9
- `),s={},r=new Map;let o="",i=null,c=!1,a=0;for(let l of n){const u=l.trim(),p=u.match(/^\$([a-zA-Z0-9_-]+)\s*:\s*(.+?);?$/);if(p){const[,f,h]=p,m=A(H(h.trim(),{...s,...i?r.get(i)||{}:{}}),e);i?(r.has(i)||r.set(i,{}),r.get(i)[f]=m):s[f]=m;continue}if(u.endsWith("{")){i=u.slice(0,-1).trim(),c=!0,o+=l+`
10
- `;continue}if(u==="}"){if(c&&i&&r.has(i)){const f=r.get(i),h=" ".repeat(a);for(const[m,$]of Object.entries(f))o+=`${h} --${m}: ${$};
11
- `}c=!1,i=null}o+=l+`
12
- `,l.includes("{")&&(a+=e.indentSize),l.includes("}")&&(a=Math.max(0,a-e.indentSize))}return{globalVariables:s,selectorVariables:r,cssWithoutVars:o.trim()}}function ft(t,e,n){const s=t.split(`
13
- `),r=[],o=[];let i=0;for(let c=0;c<s.length;c++){const a=s[c],l=a.trim();if(!l)continue;const u=a.match(/^(\s*)/)[0].length;if(l==="}"){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(l.endsWith("{")){const f={selector:l.slice(0,-1).trim(),properties:[],children:[]};r.push(f);continue}if(!l.includes("{")&&!l.includes("}")&&l.includes(":")){if(r.length>0){const p=r[r.length-1];V(l,n).forEach(h=>{const m=Object.keys(h)[0],$=A(h[m],e);p.properties.push(`${m}: ${$}`)})}continue}}for(;r.length>0;){const c=r.pop();if(r.length===0)o.push(c);else{const a=r[r.length-1];a.children||(a.children=[]),a.children.push(c)}}return j(o,e,"",n)}function j(t,e,n="",s=[]){let r="";const o=n.startsWith("@");for(const i of t){const c=i.selector.startsWith("@");let a=(o?" ".repeat(e.indentSize):"")+i.selector;if(c&&(a=i.selector+` {
14
- `),n&&(a.includes("&")?a=a.replace(/&/g,n):a.trim().startsWith(":")?a=n+a:a=n+(o?"":" ")+a),i.properties.length>0){r+=(c?"":a)+` {
15
- `;for(const l of i.properties)V(l,s).forEach(p=>{const f=Object.keys(p)[0],h=A(p[f],e);r+=(o?" ".repeat(e.indentSize):"")+" ".repeat(e.indentSize)+`${f}: ${h};
16
- `});r+=o?" ".repeat(e.indentSize)+`}
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)+`}
17
20
  `:`}
18
21
 
19
- `}i.children&&i.children.length>0&&(r+=j(i.children,e,a,s)),o&&(r+=`}
22
+ `}a.children&&a.children.length>0&&(r+=D(a.children,t,l,s)),o&&(r+=`}
20
23
 
21
24
  `)}return r.trim()+`
22
25
 
23
- `}function H(t,e){return t.replace(/\$([a-zA-Z0-9_-]+)/g,(n,s)=>e[s]?`var(--${s})`:n)}function pt(t,e,n,s){let r=t;return r=r.replace(/(?:\$\$|\$)([a-zA-Z0-9_-]+)/g,(o,i)=>o.startsWith("$$")?`attr(${i})`:`var(--${i})`),r=A(r,s),r}function ht(t,e){if(Object.keys(t).length===0)return"";const n=Object.entries(t).map(([s,r])=>{const o=A(H(r,t),e);return" ".repeat(e.indentSize)+`--${s}: ${o};`}).join(`
24
- `);return`${e.rootSelector} {
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} {
25
28
  ${n}
26
29
  }
27
30
 
28
- `}function dt(t,e,n){let s="";const r=t.split(`
29
- `);let o=null;for(let i of r){const c=i.trim();if(c.endsWith("{")&&(o=c.slice(0,-1).trim()),c==="}"&&o){if(e.has(o)){const a=e.get(o),l=i.match(/^(\s*)/)[0];for(const[u,p]of Object.entries(a))s+=" --"+u+": "+p+`;
30
- `}o=null}s+=A(i,n)+`
31
- `}return s.trim()}async function N(t,e){const n=/@import\s+([^;]+?)\s*;/g;return(async r=>{const o=[],i=r.replace(n,(c,a)=>{const l=mt(a,e).then(u=>N(u,e)).catch(u=>(console.warn(`\u65E0\u6CD5\u5BFC\u5165CSS\u6587\u4EF6: ${a}`,u),""));return o.push(l),`__IMPORT_PLACEHOLDER_${o.length-1}__`});if(o.length>0){const c=await Promise.all(o);let a=i;for(let l=0;l<c.length;l++)a=a.replace(`__IMPORT_PLACEHOLDER_${l}__`,c[l]);return a}return i})(t)}async function mt(t,e){if(e.importCache&&T.has(t))return T.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 o=require("fs"),i=require("path");let c=n;n.startsWith(".")&&(c=i.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,i=setTimeout(()=>o.abort(),e.importTimeout),c=await fetch(n,{signal:o.signal,headers:{Accept:"text/css"}});if(clearTimeout(i),!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 e.importCache&&T.set(t,s),s}function L(t,e={}){const n=(o,i)=>{const{config:c,css:a}=Y(o),l={...d,...e,...c};let u=a,p=new Map;if(l.enableAlias){const{aliases:y,css:v}=D(u);p=y,u=v}const{globalVariables:f,selectorVariables:h,cssWithoutVars:m}=ut(u,l);let $=m.trim();if(l.enableNesting&&m.includes("{"))try{$=ft(m,l,p)}catch(y){console.warn("\u5D4C\u5957\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CBCSS:",y)}const g=ht(f,l);let b=$;return h.size>0&&(b=dt($,h,l)),b=pt(b,f,h,l),g+b},s=t&&/@import\s+([^;]+?)\s*;/g.test(t),r={...d,...e};return s?(async()=>{try{const o=await N(t,r);return n(o,r)}catch(o){return console.error("@import\u5904\u7406\u5931\u8D25:",o),n(cleanedCSS,r)}})():n(t,r)}function G(t={}){const e={...d,...t},n=document.querySelectorAll(`style[${e.styleTagAttribute||"e"}]`);return n.forEach(s=>{let r=s.textContent;(async()=>{try{s.getAttribute("src")&&(r="@import "+s.getAttribute("src")+";");const i=await L(r,e),c=document.createElement("style");c.textContent=i,s.parentNode.insertBefore(c,s.nextSibling),e.preserveOriginal?s.style.display="none":s.remove()}catch(i){console.error("\u5904\u7406style\u6807\u7B7E\u5931\u8D25:",i)}})()}),n.length}function gt(t={}){d={...d,...t}}function B(t,e={}){const n={...d,...e};if(t){if(/@import\s+([^;]+?)\s*;/g.test(t))return(async()=>{try{const r=await L(t,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=L(t,n),o=document.createElement("style");return o.textContent=r,document.head.appendChild(o),o}}else document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{G(n)}):G(n)}const bt={convert:L,apply:B,config:gt,supportsP3:E(),detectP3Support:E,imports:{clearCache:function(){T.clear()},setBaseUrl:function(t){d.importBaseUrl=t},setCacheEnabled:function(t){d.importCache=t},setTimeout:function(t){d.importTimeout=t}},aliases:{add:function(t,e){F.set(t,e)},remove:function(t){F.delete(t)},getAll:function(){return Array.from(F.entries())},clear:function(){F.clear()}},math:{evaluate:function(t){return I(t,d)},parseUnit:x,round:k,test:function(t,e={}){const n={...d,...e};try{const s=I(t,n);return{success:!0,expression:t,result:s,parsed:x(s.replace(/^calc\(|\)$/g,""))}}catch(s){return{success:!1,expression:t,error:s.message}}}},colorUtils:{labToRGB:w,lchToLab:C,lchToRGB:function(t,e,n){const s=C(t,e,n);return w(s.L,s.a,s.b)},labToP3:R,lchToP3:function(t,e,n){const s=C(t,e,n);return R(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],r=e[3],o=parseInt(n,16)/255*100,i=(parseInt(s,16)-128)*1.5,c=(parseInt(r,16)-128)*1.5;return w(o,i,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],r=e[3],o=parseInt(n,16)/255*100,i=parseInt(s,16)/255*150,c=parseInt(r)/100*360,a=C(o,i,c);return w(a.L,a.a,a.b)},generateColor:function(t,e,n,s=null,r=!0){return S(t,e,n,{enableP3:r},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 r=parseFloat(e[3]),o=parseFloat(e[4]),i=e[5]?e[5].includes("%")?parseFloat(e[5])/100:parseFloat(e[5]):null,c=S(s,r,o,d,i);return{L:s,A:r,B:o,alpha:i,rgb:w(s,r,o),p3:R(s,r,o),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 r=parseFloat(n[3]);let o=parseFloat(n[4]);const i=n[6]?n[6].includes("%")?parseFloat(n[6])/100:parseFloat(n[6]):null,c=C(s,r,o),a=S(c.L,c.a,c.b,d,i);return{L:s,C:r,H:o,alpha:i,lab:c,rgb:w(c.L,c.a,c.b),p3:R(c.L,c.a,c.b),colorString:a}}return null}catch(e){return console.warn("\u65E0\u6CD5\u89E3\u6790\u989C\u8272:",t,e),null}}}},P=function(...t){if(t.length>1||t[0]&&t[0].raw)return yt(...t);const e=t[0];if(typeof e=="string"){const n=L(e,{...d,...t[1]});return n&&typeof n.then=="function",n}return typeof e=="object"&&e!==null?(d={...d,...e},P):t.length===0?B():P};function yt(t,...e){let n=t[0];for(let r=0;r<e.length;r++){const o=e[r];let i="";typeof o=="function"?i=o():Array.isArray(o)?i=o.join(" "):i=String(o??""),n+=i+t[r+1]}const s=L(n,d);return s&&typeof s.then=="function",s}return Object.assign(P,bt),Object.setPrototypeOf(P,Function.prototype),typeof window<"u"&&(B(),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 r=n.startsWith("--")?n:`--${n}`;return t.style.setProperty(r,s),!0},apply(e,n,s){const r=s[0],o=s[1],i=r.startsWith("--")?r:`--${r}`;if(o===void 0)return t.style.getPropertyValue(i);t.style.setProperty(i,o)}})}})),P})();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 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}
@@ -1,31 +1,34 @@
1
1
  /*!
2
2
  * MIT License
3
3
  * Copyright (c) 2025 王小玗
4
- */const T=(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},M=null;const F=new Map,z=new Map;function D(t){const e={...d},n=t.split(`
5
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("#")){const c=o.substring(1).trim(),i=c.indexOf(" ");if(i!==-1){const a=c.substring(0,i).trim(),l=c.substring(i+1).trim(),u=K(a);u in e?l==="true"||l==="false"?e[u]=l==="true":!isNaN(l)&&l.trim()!==""?e[u]=Number(l):e[u]=l:console.warn(`\u672A\u77E5\u7684\u914D\u7F6E\u9879: ${a}`)}else console.warn(`\u65E0\u6548\u7684\u914D\u7F6E\u884C: ${o}`)}else s.push(r)}return{config:e,css:s.join(`
6
- `)}}function Q(t){const e=new Map,n=t.split(`
7
- `),s=[];for(let r of n){const o=r.trim();if(o.startsWith("@alias")){const c=o.match(/^@alias\s+([a-zA-Z0-9_-]+)\s+(.+?)\s*;$/);if(c){const i=c[1],a=c[2];e.set(i,a),console.log(`\u6CE8\u518C\u522B\u540D: ${i} -> ${a}`);continue}}s.push(r)}return{aliases:e,css:s.join(`
8
- `)}}function K(t){return t.replace(/-([a-z])/g,function(e,n){return n.toUpperCase()})}function I(){if(M!==null)return M;if(typeof window>"u"||!window.CSS)return M=!1,!1;try{M=CSS.supports("color","color(display-p3 1 0 0)")}catch(t){console.warn("P3\u652F\u6301\u68C0\u6D4B\u5931\u8D25:",t),M=!1}return M}function _(t,e=[]){let n=t.trim();if(n.endsWith(";")&&(n=n.slice(0,-1)),!n)return[];const s=[];let r="",o=0,c=!1,i="";for(let l=0;l<n.length;l++){const u=n[l];(u==='"'||u==="'")&&!c?(c=!0,i=u):u===i&&c&&(c=!1,i=""),c||(u==="("?o++:u===")"&&o--),u===";"&&!c&&o===0?r.trim()&&(s.push(r.trim()),r=""):r+=u}r.trim()&&s.push(r.trim());const a=[];for(const l of s){if(!l.trim())continue;const u=J(l);if(u===-1){console.warn(`\u65E0\u6548\u7684CSS\u58F0\u660E: "${l}"`);continue}let p=l.substring(0,u).trim(),f=l.substring(u+1).trim();f.endsWith(";")&&(f=f.slice(0,-1).trim()),e.get(p)&&(p=e.get(p)),a.push({[p]:f})}return a}function J(t){let e=!1,n="";for(let s=0;s<t.length;s++){const r=t[s];if((r==='"'||r==="'")&&!e?(e=!0,n=r):r===n&&e&&(e=!1,n=""),r===":"&&!e)return s}return-1}function B(t,e){if(!e.enableMath)return`math(${t})`;try{let n=t.replace(/\s+/g,"");const s=Z(n,e);return tt(n)?et(n,s):j(s,e.mathPrecision)}catch(n){return console.warn("math()\u8868\u8FBE\u5F0F\u89E3\u6790\u5931\u8D25:",t,n),`math(${t})`}}function Z(t,e){for(;t.includes("(")&&t.includes(")");){const n=t.lastIndexOf("("),s=t.indexOf(")",n);if(s===-1)break;const r=t.substring(n+1,s),o=Z(r,e);t=t.substring(0,n)+o+t.substring(s+1)}return k(t,e)}function k(t,e){const n=[{regex:/([\d.]+(?:[a-zA-Z%]+)?)\*([\d.]+(?:[a-zA-Z%]+)?)/,handler:nt},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\/([\d.]+(?:[a-zA-Z%]+)?)/,handler:rt},{regex:/([\d.]+(?:[a-zA-Z%]+)?)\+([\d.]+(?:[a-zA-Z%]+)?)/,handler:st},{regex:/([\d.]+(?:[a-zA-Z%]+)?)-([\d.]+(?:[a-zA-Z%]+)?)/,handler:ot}];let s=t;for(const o of n){let c;for(;(c=t.match(o.regex))!==null;){const i=x(c[1]),a=x(c[2]),l=o.handler(i,a);t=t.substring(0,c.index)+l.value+t.substring(c.index+c[0].length)}}return t!==s?k(t,e):x(t).value}function x(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 tt(t){return/[a-zA-Z%]/.test(t)}function et(t,e){const n=t.match(/([a-zA-Z%]+)(?!.*[a-zA-Z%])/);return n?e+n[1]:t.includes("%")?e+"%":e+"px"}function nt(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 rt(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 st(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 ot(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 j(t,e=6){const n=Math.pow(10,e),r=(Math.round(t*n)/n).toString();return r.includes(".")?r.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""):r}function ct(t,e){if(!e.enableMath)return t;let n=t;const s=/math\(([^)]+)\)/gi,r=c=>c.replace(s,(i,a)=>B(a,e));let o;do o=n,n=r(n);while(n!==o&&n.includes("math("));return n}function it(t,e){if(!e.convertLabToRGB&&!e.convertLchToRGB)return t;let n=t;n=at(n,e);const s=/(lab|lch)\([^)]+\)/gi,r=new Map,o=i=>i.replace(s,a=>{if(r.has(a))return r.get(a);let l=a;return a.toLowerCase().startsWith("lab(")?e.convertLabToRGB&&(l=lt(a,e)):a.toLowerCase().startsWith("lch(")&&e.convertLchToRGB&&(l=ut(a,e)),r.set(a,l),l});let c;do c=n,n=o(n);while(n!==c);return n}function at(t,e){let n=t;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,(c,i,a,l)=>{if(o.has(c))return o.get(c);try{const u=parseInt(i,16)/255*100,p=(parseInt(a,16)-128)*1.5,f=(parseInt(l,16)-128)*1.5,h=S(u,p,f,e);return o.set(c,h),h}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lab#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${c}`,u),c}}),n=n.replace(r,(c,i,a,l)=>{if(o.has(c))return o.get(c);try{const u=parseInt(i,16)/255*100,p=parseInt(a,16)/255*150,f=parseInt(l)/100*360,h=C(u,p,f),m=S(h.L,h.a,h.b,e);return o.set(c,m),m}catch(u){return console.warn(`\u65E0\u6CD5\u89E3\u6790lch#\u5341\u516D\u8FDB\u5236\u989C\u8272: ${c}`,u),c}}),n}function lt(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 r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]),c=parseFloat(s[4]),i=s[5]!==void 0?s[5].includes("%")?parseFloat(s[5])/100:parseFloat(s[5]):null;return S(r,o,c,e,i)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LAB\u989C\u8272: ${t}`,r),t}}function ut(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 r=parseFloat(s[1]);s[2]==="%"?r=r:(r<0&&(r=0),r>100&&(r=100));const o=parseFloat(s[3]);let c=parseFloat(s[4]);o<0&&console.warn(`LCH\u4E2D\u7684C\u503C\u4E0D\u80FD\u4E3A\u8D1F: ${o}`),c=(c%360+360)%360;const i=C(r,o,c),a=s[6]!==void 0?s[6].includes("%")?parseFloat(s[6])/100:parseFloat(s[6]):null;return S(i.L,i.a,i.b,e,a)}catch(r){return console.warn(`\u65E0\u6CD5\u8F6C\u6362LCH\u989C\u8272: ${t}`,r),t}}function C(t,e,n){const s=n*Math.PI/180,r=e*Math.cos(s),o=e*Math.sin(s);return{L:t,a:r,b:o}}function w(t,e,n){const s=(g,b,y)=>{const Y=(g+16)/116,W=b/500+Y,V=Y-y/200,vt=W**3>.008856?W**3:(116*W-16)/903.3,wt=g>903.3*.008856?((g+16)/116)**3:g/903.3,Ct=V**3>.008856?V**3:(116*V-16)/903.3;return[vt*.95047,wt*1,Ct*1.08883]},r=(g,b,y)=>{const v=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]],E=v[0][0]*g+v[0][1]*b+v[0][2]*y,X=v[1][0]*g+v[1][1]*b+v[1][2]*y,q=v[2][0]*g+v[2][1]*b+v[2][2]*y;return[E,X,q]},o=g=>{const b=g<0?-1:1,y=Math.abs(g);return y<=.0031308?b*12.92*y:b*(1.055*Math.pow(y,.4166666666666667)-.055)},c=g=>Math.max(0,Math.min(255,Math.round(g*255))),[i,a,l]=s(t,e,n),[u,p,f]=r(i,a,l),h=o(u),m=o(p),$=o(f);return{r:c(h),g:c(m),b:c($)}}function P(t,e,n){const s=(i,a,l)=>{const $=(i+16)/116,g=a/500+$,b=$-l/200,y=g**3>.008856?g**3:(116*g-16)/903.3,v=i>903.3*.008856?((i+16)/116)**3:i/903.3,E=b**3>.008856?b**3:(116*b-16)/903.3;return[y*.95047,v*1,E*1.08883]},r=(i,a,l)=>{const u=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]],p=u[0][0]*i+u[0][1]*a+u[0][2]*l,f=u[1][0]*i+u[1][1]*a+u[1][2]*l,h=u[2][0]*i+u[2][1]*a+u[2][2]*l;return[p,f,h]},o=i=>{const a=i<0?-1:1,l=Math.abs(i);return l<=.0031308?a*12.92*l:a*(1.055*Math.pow(l,.4166666666666667)-.055)},c=i=>Math.max(0,Math.min(255,Math.round(i*255)));try{const[i,a,l]=s(t,e,n),[u,p,f]=r(i,a,l),h=o(u),m=o(p),$=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,$))}}catch(i){console.warn("P3\u8F6C\u6362\u5931\u8D25:",i);const a=w(t,e,n);return{r:a.r/255,g:a.g/255,b:a.b/255}}}function S(t,e,n,s,r=null){if(!s.enableP3||!I()){const o=w(t,e,n);return r!==null?`rgba(${o.r}, ${o.g}, ${o.b}, ${r})`:`rgb(${o.r}, ${o.g}, ${o.b})`}else{const o=P(t,e,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 A(t,e){let n=t;return e.enableMath&&(n=ct(n,e)),(e.convertLabToRGB||e.convertLchToRGB)&&(n=it(n,e)),n}function ft(t,e){const n=t.split(`
9
- `),s={},r=new Map;let o="",c=null,i=!1,a=0;for(let l of n){const u=l.trim(),p=u.match(/^\$([a-zA-Z0-9_-]+)\s*:\s*(.+?);?$/);if(p){const[,f,h]=p,m=A(N(h.trim(),{...s,...c?r.get(c)||{}:{}}),e);c?(r.has(c)||r.set(c,{}),r.get(c)[f]=m):s[f]=m;continue}if(u.endsWith("{")){c=u.slice(0,-1).trim(),i=!0,o+=l+`
10
- `;continue}if(u==="}"){if(i&&c&&r.has(c)){const f=r.get(c),h=" ".repeat(a);for(const[m,$]of Object.entries(f))o+=`${h} --${m}: ${$};
11
- `}i=!1,c=null}o+=l+`
12
- `,l.includes("{")&&(a+=e.indentSize),l.includes("}")&&(a=Math.max(0,a-e.indentSize))}return{globalVariables:s,selectorVariables:r,cssWithoutVars:o.trim()}}function pt(t,e,n){const s=t.split(`
13
- `),r=[],o=[];let c=0;for(let i=0;i<s.length;i++){const a=s[i],l=a.trim();if(!l)continue;const u=a.match(/^(\s*)/)[0].length;if(l==="}"){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(l.endsWith("{")){const f={selector:l.slice(0,-1).trim(),properties:[],children:[]};r.push(f);continue}if(!l.includes("{")&&!l.includes("}")&&l.includes(":")){if(r.length>0){const p=r[r.length-1];_(l,n).forEach(h=>{const m=Object.keys(h)[0],$=A(h[m],e);p.properties.push(`${m}: ${$}`)})}continue}}for(;r.length>0;){const i=r.pop();if(r.length===0)o.push(i);else{const a=r[r.length-1];a.children||(a.children=[]),a.children.push(i)}}return H(o,e,"",n)}function H(t,e,n="",s=[]){let r="";const o=n.startsWith("@");for(const c of t){const i=c.selector.startsWith("@");let a=(o?" ".repeat(e.indentSize):"")+c.selector;if(i&&(a=c.selector+` {
14
- `),n&&(a.includes("&")?a=a.replace(/&/g,n):a.trim().startsWith(":")?a=n+a:a=n+(o?"":" ")+a),c.properties.length>0){r+=(i?"":a)+` {
15
- `;for(const l of c.properties)_(l,s).forEach(p=>{const f=Object.keys(p)[0],h=A(p[f],e);r+=(o?" ".repeat(e.indentSize):"")+" ".repeat(e.indentSize)+`${f}: ${h};
16
- `});r+=o?" ".repeat(e.indentSize)+`}
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)+`}
17
20
  `:`}
18
21
 
19
- `}c.children&&c.children.length>0&&(r+=H(c.children,e,a,s)),o&&(r+=`}
22
+ `}a.children&&a.children.length>0&&(r+=Y(a.children,t,l,s)),o&&(r+=`}
20
23
 
21
24
  `)}return r.trim()+`
22
25
 
23
- `}function N(t,e){return t.replace(/\$([a-zA-Z0-9_-]+)/g,(n,s)=>e[s]?`var(--${s})`:n)}function ht(t,e,n,s){let r=t;return r=r.replace(/(?:\$\$|\$)([a-zA-Z0-9_-]+)/g,(o,c)=>o.startsWith("$$")?`attr(${c})`:`var(--${c})`),r=A(r,s),r}function dt(t,e){if(Object.keys(t).length===0)return"";const n=Object.entries(t).map(([s,r])=>{const o=A(N(r,t),e);return" ".repeat(e.indentSize)+`--${s}: ${o};`}).join(`
24
- `);return`${e.rootSelector} {
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} {
25
28
  ${n}
26
29
  }
27
30
 
28
- `}function mt(t,e,n){let s="";const r=t.split(`
29
- `);let o=null;for(let c of r){const i=c.trim();if(i.endsWith("{")&&(o=i.slice(0,-1).trim()),i==="}"&&o){if(e.has(o)){const a=e.get(o),l=c.match(/^(\s*)/)[0];for(const[u,p]of Object.entries(a))s+=" --"+u+": "+p+`;
30
- `}o=null}s+=A(c,n)+`
31
- `}return s.trim()}async function U(t,e){const n=/@import\s+([^;]+?)\s*;/g;return(async r=>{const o=[],c=r.replace(n,(i,a)=>{const l=gt(a,e).then(u=>U(u,e)).catch(u=>(console.warn(`\u65E0\u6CD5\u5BFC\u5165CSS\u6587\u4EF6: ${a}`,u),""));return o.push(l),`__IMPORT_PLACEHOLDER_${o.length-1}__`});if(o.length>0){const i=await Promise.all(o);let a=c;for(let l=0;l<i.length;l++)a=a.replace(`__IMPORT_PLACEHOLDER_${l}__`,i[l]);return a}return c})(t)}async function gt(t,e){if(e.importCache&&F.has(t))return F.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 o=require("fs"),c=require("path");let i=n;n.startsWith(".")&&(i=c.join(process.cwd(),n)),s=o.readFileSync(i,"utf-8")}catch(o){throw new Error(`Node.js\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${n} - ${o.message}`)}else try{const o=new AbortController,c=setTimeout(()=>o.abort(),e.importTimeout),i=await fetch(n,{signal:o.signal,headers:{Accept:"text/css"}});if(clearTimeout(c),!i.ok)throw new Error(`HTTP\u9519\u8BEF: ${i.status} ${i.statusText}`);s=await i.text()}catch(o){throw o.name==="AbortError"?new Error(`\u5BFC\u5165\u8D85\u65F6: ${n}`):new Error(`\u65E0\u6CD5\u83B7\u53D6CSS: ${n} - ${o.message}`)}return e.importCache&&F.set(t,s),s}function L(t,e={}){const n=(o,c)=>{const{config:i,css:a}=D(o),l={...d,...e,...i};let u=a,p=new Map;if(l.enableAlias){const{aliases:y,css:v}=Q(u);p=y,u=v}const{globalVariables:f,selectorVariables:h,cssWithoutVars:m}=ft(u,l);let $=m.trim();if(l.enableNesting&&m.includes("{"))try{$=pt(m,l,p)}catch(y){console.warn("\u5D4C\u5957\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CBCSS:",y)}const g=dt(f,l);let b=$;return h.size>0&&(b=mt($,h,l)),b=ht(b,f,h,l),g+b},s=t&&/@import\s+([^;]+?)\s*;/g.test(t),r={...d,...e};return s?(async()=>{try{const o=await U(t,r);return n(o,r)}catch(o){return console.error("@import\u5904\u7406\u5931\u8D25:",o),n(cleanedCSS,r)}})():n(t,r)}function G(t={}){const e={...d,...t},n=document.querySelectorAll(`style[${e.styleTagAttribute||"e"}]`);return n.forEach(s=>{let r=s.textContent;(async()=>{try{s.getAttribute("src")&&(r="@import "+s.getAttribute("src")+";");const c=await L(r,e),i=document.createElement("style");i.textContent=c,s.parentNode.insertBefore(i,s.nextSibling),e.preserveOriginal?s.style.display="none":s.remove()}catch(c){console.error("\u5904\u7406style\u6807\u7B7E\u5931\u8D25:",c)}})()}),n.length}function bt(t={}){d={...d,...t}}function O(t,e={}){const n={...d,...e};if(t){if(/@import\s+([^;]+?)\s*;/g.test(t))return(async()=>{try{const r=await L(t,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=L(t,n),o=document.createElement("style");return o.textContent=r,document.head.appendChild(o),o}}else document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{G(n)}):G(n)}const yt={convert:L,apply:O,config:bt,supportsP3:I(),detectP3Support:I,imports:{clearCache:function(){F.clear()},setBaseUrl:function(t){d.importBaseUrl=t},setCacheEnabled:function(t){d.importCache=t},setTimeout:function(t){d.importTimeout=t}},aliases:{add:function(t,e){z.set(t,e)},remove:function(t){z.delete(t)},getAll:function(){return Array.from(z.entries())},clear:function(){z.clear()}},math:{evaluate:function(t){return B(t,d)},parseUnit:x,round:j,test:function(t,e={}){const n={...d,...e};try{const s=B(t,n);return{success:!0,expression:t,result:s,parsed:x(s.replace(/^calc\(|\)$/g,""))}}catch(s){return{success:!1,expression:t,error:s.message}}}},colorUtils:{labToRGB:w,lchToLab:C,lchToRGB:function(t,e,n){const s=C(t,e,n);return w(s.L,s.a,s.b)},labToP3:P,lchToP3:function(t,e,n){const s=C(t,e,n);return P(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],r=e[3],o=parseInt(n,16)/255*100,c=(parseInt(s,16)-128)*1.5,i=(parseInt(r,16)-128)*1.5;return w(o,c,i)},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],r=e[3],o=parseInt(n,16)/255*100,c=parseInt(s,16)/255*150,i=parseInt(r)/100*360,a=C(o,c,i);return w(a.L,a.a,a.b)},generateColor:function(t,e,n,s=null,r=!0){return S(t,e,n,{enableP3:r},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 r=parseFloat(e[3]),o=parseFloat(e[4]),c=e[5]?e[5].includes("%")?parseFloat(e[5])/100:parseFloat(e[5]):null,i=S(s,r,o,d,c);return{L:s,A:r,B:o,alpha:c,rgb:w(s,r,o),p3:P(s,r,o),colorString:i}}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 r=parseFloat(n[3]);let o=parseFloat(n[4]);const c=n[6]?n[6].includes("%")?parseFloat(n[6])/100:parseFloat(n[6]):null,i=C(s,r,o),a=S(i.L,i.a,i.b,d,c);return{L:s,C:r,H:o,alpha:c,lab:i,rgb:w(i.L,i.a,i.b),p3:P(i.L,i.a,i.b),colorString:a}}return null}catch(e){return console.warn("\u65E0\u6CD5\u89E3\u6790\u989C\u8272:",t,e),null}}}},R=function(...t){if(t.length>1||t[0]&&t[0].raw)return $t(...t);const e=t[0];if(typeof e=="string"){const n=L(e,{...d,...t[1]});return n&&typeof n.then=="function",n}return typeof e=="object"&&e!==null?(d={...d,...e},R):t.length===0?O():R};function $t(t,...e){let n=t[0];for(let r=0;r<e.length;r++){const o=e[r];let c="";typeof o=="function"?c=o():Array.isArray(o)?c=o.join(" "):c=String(o??""),n+=c+t[r+1]}const s=L(n,d);return s&&typeof s.then=="function",s}return Object.assign(R,yt),Object.setPrototypeOf(R,Function.prototype),typeof window<"u"&&(O(),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 r=n.startsWith("--")?n:`--${n}`;return t.style.setProperty(r,s),!0},apply(e,n,s){const r=s[0],o=s[1],c=r.startsWith("--")?r:`--${r}`;if(o===void 0)return t.style.getPropertyValue(c);t.style.setProperty(c,o)}})}})),R})();if(typeof define=="function"&&define.amd)define([],()=>T);else if(typeof module=="object"&&module.exports)module.exports=T;else{const d=globalThis??(typeof self<"u"&&self)??typeof window<"u"&window??global??{};d.styimat=T}export default T;export const{convert,apply,config,supportsP3,detectP3Support,imports,aliases,math,colorUtils}=T;
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;