@fwkui/x-css 1.0.14 → 1.0.15

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/README.md CHANGED
@@ -213,6 +213,23 @@ Ví dụ:
213
213
  <div class="w[calc(100%;-;10px)]"></div>
214
214
  ```
215
215
 
216
+ Chuỗi thuộc tính bằng `&` (đúng):
217
+ 1. `fk-dF&fxdC@;li`
218
+ 2. `fk-md:dF&fxdC`
219
+ 3. `md:[row]&[col]@;li` (với `aliases.row`, `aliases.col`)
220
+
221
+ Quy ước `aliases` khuyến nghị (đầy đủ declaration):
222
+ ```js
223
+ aliases: {
224
+ row: ['display:flex', 'padding:5px'],
225
+ col: ['flex-direction: column', 'margin:5px']
226
+ }
227
+ ```
228
+
229
+ Sai -> Đúng:
230
+ 1. `aliases: { row:['dF'], col:['fxdC'] }` -> sai (không còn hỗ trợ).
231
+ 2. `aliases: { row:['display:flex'], col:['flex-direction: column'] }` -> đúng.
232
+
216
233
  ## Dùng Trong React / Component
217
234
 
218
235
  ```jsx
@@ -250,7 +267,13 @@ xcss.cssObserve(document, {
250
267
  prefix: 'fk-',
251
268
  excludePrefixes: ['bs-', 'rs-'],
252
269
  excludes: ['legacy-*'],
253
- dictionaryImport: true
270
+ dictionaryImport: true,
271
+ cache: {
272
+ styleId: 'fwkui',
273
+ version: 'v1',
274
+ compression: true,
275
+ debounceMs: 1000
276
+ }
254
277
  });
255
278
  ```
256
279
 
@@ -300,6 +323,23 @@ Lưu ý:
300
323
  1. Với `dictionaryImport: true` hoặc `string`, engine có thể tải dictionary bất đồng bộ tùy môi trường runtime.
301
324
  2. Nếu cần chắc chắn dictionary đã sẵn sàng trước khi render quan trọng, dùng `await engine.ready`.
302
325
 
326
+ `cache`:
327
+ 1. `styleId` (mặc định `fwkui`): id thẻ `<style>` runtime.
328
+ 2. `version` (mặc định `v1`): tham gia vào cache key để chủ động invalidate.
329
+ 3. `compression` (mặc định `true`): nén cache trước khi lưu `localStorage`.
330
+ 4. `debounceMs` (mặc định `1000`): debounce chu kỳ nén + lưu cache.
331
+
332
+ Khi `compression: true`:
333
+ 1. Ưu tiên `CompressionStream` (deflate-raw + base64) nếu runtime hỗ trợ.
334
+ 2. Tự động fallback về LZW để tương thích ngược.
335
+ 3. Đọc cache vẫn hỗ trợ key cũ `xcss_cache_v1` để migrate dần.
336
+
337
+ Quy tắc cache key:
338
+ `cacheKey = styleId + "_cache_" + version`
339
+
340
+ Ví dụ mặc định:
341
+ `fwkui_cache_v1`
342
+
303
343
  Nếu import dictionary ngoài:
304
344
 
305
345
  ```js
@@ -368,6 +408,88 @@ Quy trình thay link:
368
408
  3. Thay `dictionaryImport` bằng URL thật.
369
409
  4. Chờ `await engine.ready` trước khi render class.
370
410
 
411
+ ## Bootloader Từ Cache (Khuyến nghị)
412
+
413
+ Khuyến nghị dùng helper `getBootloaderScript` để chèn script vào `<head>` trước bundle/module, giúp giảm FOUC khi đã có cache CSS.
414
+
415
+ ### Dùng helper `getBootloaderScript`
416
+
417
+ ```js
418
+ import { getBootloaderScript } from '@fwkui/x-css';
419
+
420
+ const styleId = 'fwkui';
421
+ const version = 'v1';
422
+
423
+ const bootloaderScript = getBootloaderScript(styleId, version);
424
+ const bootloaderScriptCompact = getBootloaderScript(styleId, version, { compact: true });
425
+ ```
426
+
427
+ ### Cấu trúc chèn vào `<head>` (khuyến nghị)
428
+
429
+ ```html
430
+ <head>
431
+ <!-- 1) Bootloader từ cache: chạy sớm nhất để giảm FOUC -->
432
+ <script>
433
+ /* nội dung từ getBootloaderScript(styleId, version) */
434
+ </script>
435
+
436
+ <!-- 2) Bundle/module của app -->
437
+ <script type="module" src="/assets/main.js"></script>
438
+ </head>
439
+ ```
440
+
441
+ ### Đoạn dán thủ công vào `<head>` (copy/paste)
442
+
443
+ Thay 2 biến ngay đầu script nếu cần:
444
+ 1. `sid = 'fwkui'` -> đổi theo `cache.styleId`.
445
+ 2. `ver = 'v1'` -> đổi theo `cache.version`.
446
+
447
+ ```html
448
+ <script>
449
+ (async()=>{const sid='fwkui',ver='v1',k=sid+'_cache_'+ver,l='xcss_cache_v1';const L=s=>{if(!s)return'';const d={};let z=256;for(let i=0;i<256;i++)d[i]=String.fromCharCode(i);const c=[...s].map(ch=>ch.charCodeAt(0));let p=c[0],ph=d[p]||'',r=ph;for(let i=1;i<c.length;i++){const x=c[i];let e=d[x];if(!e)e=x===z?ph+ph[0]:'';r+=e;d[z++]=ph+e[0];ph=e;}return r};const S=()=>typeof DecompressionStream!=='undefined'&&typeof Blob!=='undefined'&&typeof Response!=='undefined';const B=b=>{if(typeof atob==='function'){const s=atob(b),u=new Uint8Array(s.length);for(let i=0;i<s.length;i++)u[i]=s.charCodeAt(i);return u;}if(typeof Buffer!=='undefined')return new Uint8Array(Buffer.from(b,'base64'));throw new Error('base64');};const D=async p=>{if(!S())return null;try{return await new Response(new Blob([B(p)]).stream().pipeThrough(new DecompressionStream('deflate-raw'))).text();}catch{return null;}};const P=async raw=>{if(!raw)return null;try{let j=JSON.parse(raw);if(j&&j.__xcss_cache_v===3&&j.compressed===true&&j.algorithm==='deflate-raw'&&j.encoding==='base64'&&typeof j.payload==='string'){const ex=await D(j.payload);if(!ex)return null;j=JSON.parse(ex);}else if(j&&j.__xcss_cache_v===2&&j.compressed===true&&typeof j.payload==='string'){const ex=L(j.payload);if(!ex)return null;j=JSON.parse(ex);}return j&&j.cssText?j:null;}catch{return null;}};try{if(typeof window==='undefined'||!window.localStorage)return;let p=null;for(const kk of (k===l?[k]:[k,l])){p=await P(localStorage.getItem(kk));if(p)break;}if(!p)return;let st=document.getElementById(sid);if(!st){st=document.createElement('style');st.id=sid;document.head.appendChild(st);}let css=p.cssText.root?p.cssText.root+'\\n':'';for(const n in p.cssText)if(n!=='root')css+=(p.cssText[n]||'')+'\\n';st.textContent=css;}catch{}})();
450
+ </script>
451
+ ```
452
+
453
+ Ví dụ render HTML từ server:
454
+
455
+ ```js
456
+ import { getBootloaderScript } from '@fwkui/x-css';
457
+
458
+ const styleId = 'fwkui';
459
+ const version = 'v1';
460
+ const bootloaderScript = getBootloaderScript(styleId, version, { compact: true });
461
+
462
+ const html = `
463
+ <!doctype html>
464
+ <html>
465
+ <head>
466
+ <meta charset="UTF-8" />
467
+ <script>${bootloaderScript}</script>
468
+ <script type="module" src="/assets/main.js"></script>
469
+ </head>
470
+ <body><div id="app"></div></body>
471
+ </html>`;
472
+ ```
473
+
474
+ Lưu ý:
475
+ 1. Đồng bộ `styleId` + `version` giữa bootloader và cấu hình `xcss.css(...)`.
476
+ 2. Script tạo từ `getBootloaderScript` ưu tiên `DecompressionStream` (cache deflate-raw) và fallback LZW/legacy.
477
+ 3. Sau bootloader vẫn cần gọi `xcss.cssObserve(...)` như bình thường.
478
+ 4. Tương thích ngược: tham số thứ 2 vẫn chấp nhận `cacheKey` cũ nếu bạn đang dùng API trước đó.
479
+ 5. Dùng `{ compact: true }` khi muốn script trả về ở dạng nén gọn để nhúng HTML.
480
+ 6. Nếu dữ liệu cache dưới key hiện tại bị lỗi/không decode được, engine sẽ tự xóa key đó để lần chạy sau lưu lại dữ liệu mới.
481
+
482
+ ### Khi nào nên dùng `getBootloaderScript`
483
+
484
+ 1. SSR/MPA hoặc trang tĩnh cần giảm FOUC ngay từ first paint.
485
+ 2. Ứng dụng có cache CSS trong `localStorage` và muốn render gần như tức thì trước khi bundle chạy.
486
+ 3. Khi bạn chủ động kiểm soát thứ tự script trong `<head>`.
487
+
488
+ Không bắt buộc dùng khi:
489
+ 1. Trang không cần tối ưu first paint.
490
+ 2. Không dùng cache runtime.
491
+ 3. CSP không cho inline script (trừ khi đã cấu hình nonce/hash phù hợp).
492
+
371
493
  ## SSR Và Static Extraction
372
494
 
373
495
  SSR:
@@ -1,5 +1,5 @@
1
1
  import _default from './index.mjs';
2
- export { XCSSConfig, clsx, getCss, setClsxRoot } from './index.mjs';
2
+ export { BootloaderScriptOptions, XCSSConfig, clsx, getBootloaderScript, getCss, setClsxRoot } from './index.mjs';
3
3
 
4
4
 
5
5
 
@@ -1,5 +1,5 @@
1
1
  import _default from './index.js';
2
- export { XCSSConfig, clsx, getCss, setClsxRoot } from './index.js';
2
+ export { BootloaderScriptOptions, XCSSConfig, clsx, getBootloaderScript, getCss, setClsxRoot } from './index.js';
3
3
 
4
4
 
5
5
 
@@ -1,12 +1,131 @@
1
- "use strict";var ne=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var Oe=(e,n)=>{for(var s in n)ne(e,s,{get:n[s],enumerable:!0})},Pe=(e,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let d of Ae(n))!Ie.call(e,d)&&d!==s&&ne(e,d,{get:()=>n[d],enumerable:!(r=De(n,d))||r.enumerable});return e};var ke=e=>Pe(ne({},"__esModule",{value:!0}),e);var Fe={};Oe(Fe,{clsx:()=>Ke,default:()=>qe,getCss:()=>Ue,setClsxRoot:()=>We});module.exports=ke(Fe);var ge=e=>(e=e||new Map,{all:e,on(n,s){let r=e.get(n);r?r.push(s):e.set(n,[s])},off(n,s){let r=e.get(n);r&&(s?r.splice(r.indexOf(s)>>>0,1):e.set(n,[]))},emit(n,s){let r=e.get(n);r&&r.slice().forEach(S=>{S(s)});let d=e.get("*");d&&d.slice().forEach(S=>{S(n,s)})}});function $e(e){return e>=97&&e<=122}function re(e){if(!e||e.length<2)return null;let n=0,s=e.length,r="",d=e.lastIndexOf("@");if(d>0){let C=e.lastIndexOf("]");(C===-1||d>C)&&(r=e.substring(d+1),s=d)}let S="",I="",$=e.indexOf(":",n);if($>0&&$<s){let C=e.substring(n,$);n=$+1,S=C}let T=n;for(;T<s;){let C=e.charCodeAt(T);if(C>=48&&C<=57)T++;else break}if(T>n&&(I=e.substring(n,T),n=T),n>=s)return null;if(e.charCodeAt(n)===38)return{mq:S,layer:I,prop:"&",val:e.substring(n+1,s),selector:r};if(e.charCodeAt(n)===91){let C=e.indexOf("]",n);if(C>n)return{mq:S,layer:I,prop:e.substring(n,C+1),val:"",selector:r}}let R=n;for(;R<s;){let C=e.charCodeAt(R);if(C===45||C===46){if(R+1<s){let O=e.charCodeAt(R+1);if(C===45&&O===45&&R>n||O>=48&&O<=57)break}R++;continue}if(!$e(C))break;R++}if(R===n)return null;let m=e.substring(n,R),v=e.substring(R,s);return{mq:S,layer:I,prop:m,val:v,selector:r}}var se=e=>{if(!e||typeof e!="object")return null;let n=e,s=n.default&&typeof n.default=="object"?n.default:n,r=s.SHORT_PROPERTIES,d=s.COMMON_VALUES,S=s.SPECIFIC_VALUES;return!r||!d||!S||typeof r!="object"||typeof d!="object"||typeof S!="object"?null:{SHORT_PROPERTIES:r,COMMON_VALUES:d,SPECIFIC_VALUES:S}},je=async e=>{let n=await import(e),s=se(n);if(!s)throw new Error(Se);return s},Se="XCSS: dictionary module must export SHORT_PROPERTIES, COMMON_VALUES and SPECIFIC_VALUES",he=()=>{let e=typeof require=="function"?require:null;if(!e)return null;for(let n of["./dictionary.js","./dictionary"])try{let s=e(n),r=se(s);if(r)return r}catch{}return null},He=async()=>{let e=he();if(e)return e;let n=["./dictionary.mjs","./dictionary.js","./dictionary"],s=null;for(let r of n)try{let d=await import(r),S=se(d);if(S)return S}catch(d){s=d}throw s||new Error(Se)},Me=(e,n)=>{if(!e||typeof document>"u")return;n=n||"fwkui";let s=Array.from({length:24},(r,d)=>"l"+d);if(!e.querySelector('style[id="'+n+'"]')){let r=document.createElement("style");if(r.id=n,!(e instanceof ShadowRoot))document.head.append(r);else try{e.prepend(r)}catch{e.appendChild(r)}let d=`@layer ${s.join(", ")};`,S=setInterval(()=>{if(r.sheet){clearInterval(S);try{r.sheet.insertRule(d,r.sheet.cssRules.length)}catch{}}},10)}},Le=e=>{let n=Array.isArray(e.excludes)?e.excludes:Array.isArray(e.exclude)?e.exclude:[],s=JSON.stringify({base:e.base||"",aliases:e.aliases||{},breakpoints:e.breakpoints||[],theme:e.theme||{},prefix:e.prefix||"",excludes:n,excludePrefixes:e.excludePrefixes||[],dictionaryImport:e.dictionaryImport??!0}),r=0;if(s.length===0)return r.toString();for(let d=0;d<s.length;d++){let S=s.charCodeAt(d);r=(r<<5)-r+S,r|=0}return r.toString()},q="xcss_cache_v1",oe=(e={base:"",aliases:{},excludes:[],excludePrefixes:[],breakpoints:[],theme:{},prefix:"",dictionaryImport:!0})=>{let{base:n=null,breakpoints:s=[],aliases:r={},theme:d={},excludes:S=[],exclude:I=[],excludePrefixes:$=[],prefix:T="",dictionaryImport:R=!0}=e||{};Array.isArray(s)||(s=[]),Array.isArray(S)||(S=[]),Array.isArray(I)||(I=[]),Array.isArray($)||($=[]),(!r||typeof r!="object")&&(r={}),(!d||typeof d!="object")&&(d={});let m=[...S,...I],v=$.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0),C=t=>{let o=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+o.replace(/\*/g,".*")+"$")},O=m.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0).map(t=>{if(t.includes("*")){let o=C(t);return c=>o.test(c)}return o=>o===t}),L=t=>v.some(o=>t.startsWith(o))?!0:O.some(o=>o(t)),J=t=>!(T&&!t.startsWith(T)||L(t)),D={},H={},z={},Y={},ce=()=>{Y={...z,...d}},_=t=>{if(!t){D={},H={},z={},ce();return}D=t.SHORT_PROPERTIES,H=t.SPECIFIC_VALUES,z=t.COMMON_VALUES,ce()},X=!0,F=Promise.resolve();if(R===!1)_(null);else if(typeof R=="string")X=!1,_(null),F=je(R).then(t=>{_(t)}).catch(t=>{console.warn("XCSS: Failed to import dictionary from URL",t)}).finally(()=>{X=!0});else{let t=he();t?_(t):(X=!1,_(null),F=He().then(o=>{_(o)}).catch(o=>{console.warn("XCSS: Failed to load built-in dictionary module",o)}).finally(()=>{X=!0}))}let me=(t=typeof document<"u"?document:void 0)=>{let o=typeof window<"u"&&typeof document<"u",c=null;t&&(c="getRootNode"in t?t.getRootNode():t);let x=new Map;o&&c&&Me(c);let h=ge(),w=[{default:""},{xs:"screen and (max-width: 575px)"},{sm:"screen and (min-width: 576px)"},{md:"screen and (min-width: 768px)"},{lg:"screen and (min-width: 992px)"},{xl:"screen and (min-width: 1200px)"},{"2xl":"screen and (min-width: 1400px)"},{sma:"screen and (max-width: 768px)"},{mda:"screen and (max-width: 992px)"},{lga:"screen and (max-width: 1200px)"},{xla:"screen and (max-width: 1400px)"},...s],E=w.filter((l,i)=>w.findLastIndex(a=>Object.keys(a)[0]==Object.keys(l)[0])==i),f=E.map(l=>Object.keys(l)[0]),y={},u={},b={root:""},A={root:[]},j={root:!1},V=Le(e),K=null,Z=!1,we=l=>{if(!(!o||!window.localStorage))try{localStorage.setItem(q,JSON.stringify(l))}catch(i){console.warn("XCSS: Failed to save cache",i)}},de=()=>{o&&(K&&clearTimeout(K),K=setTimeout(()=>{let l={};for(let g in y)l[g]=Array.from(y[g]);let i={};Object.keys(b).forEach(g=>{if(g==="root")i[g]=b[g];else{let p=w.find(P=>Object.keys(P)[0]===g)?.[g];p&&b[g]?i[g]=`@media ${p} {
2
- ${b[g]}
3
- }`:i[g]=b[g]||""}});let a={configHash:V,cssText:i,rulesSet:l,keys:Array.from(x.entries())};we(a)},1e3))};if(o&&window.localStorage)try{let l=localStorage.getItem(q);if(l){let i=JSON.parse(l);if(i&&i.configHash===V){if(i.keys&&i.keys.forEach(([a,g])=>x.set(a,g)),i.cssText)for(let a in i.cssText){let g=i.cssText[a];if(a!=="root"){let p=/@media[^{]+\{\n?([\s\S]+)\n?\}/.exec(g);p&&p[1]?b[a]=p[1].trim():b[a]=g}else b[a]=g}Z=!0}else localStorage.removeItem(q)}}catch(l){console.error(l)}if(o&&(u.root=new CSSStyleSheet),f.forEach(l=>{if(y[l]=new Set,o){let i=E.find(a=>Object.keys(a)[0]==l)?.[l]||"";u[l]=new CSSStyleSheet({media:i})}Z||(b[l]=""),A[l]=[],j[l]=!1}),Z&&o&&window.localStorage){let l=localStorage.getItem(q);if(l){let i=JSON.parse(l);if(i.rulesSet)for(let a in i.rulesSet)y[a]&&i.rulesSet[a].forEach(g=>y[a].add(g))}if(c){let i=c.querySelector('style[id="fwkui"]');i&&i.remove()}}n&&Array.isArray(n)?(b.root=n.join(`
4
- `),o&&u.root&&u.root.replaceSync(b.root)):(b.root=n||"",o&&u.root&&u.root.replaceSync(b.root)),o&&c&&["root",...f].forEach(l=>{u[l]&&c?.adoptedStyleSheets&&(c.adoptedStyleSheets.includes(u[l])||(c.adoptedStyleSheets=[...c.adoptedStyleSheets,u[l]]))});let Re=(l,i)=>{let{media:a,property:g,selector:p,layer:P,className:k}=i,W=b,M=A,ee=j;P=Number(P)||0;let ue=x.get(l),ve=ue?`.${ue}${p}`:`.${k}${p}`;var te=`@layer l${P}{${ve}{${g}}}`;y[a]||(y[a]=new Set);let pe=y[a];if(!pe.has(te))if(pe.add(te),M[a]||(M[a]=[]),M[a].push(te),o)ee[a]||(ee[a]=!0,queueMicrotask(()=>{let U=M[a],ye=u[a];U.length>0&&(W[a]+=(W[a]?`
5
- `:"")+U.join(`
6
- `),ye&&ye.replaceSync(W[a]),M[a]=[],de()),ee[a]=!1}));else{let U=M[a];U.length>0&&(W[a]+=(W[a]?`
7
- `:"")+U.join(`
8
- `),M[a]=[])}},Te=l=>{l.forEach(i=>{let a=G(i);a&&Re(i,a)})},fe=l=>{if(l.length===0)return;let i=()=>Te(l);X?i():F.then(i)};return h.on("observeDom",fe),{clsx:(...l)=>{let i=l.map(p=>Array.isArray(p)?p:[p]).flat(1/0).map(p=>typeof p=="string"?p.split(/(\s|\t)+/g):[]).flat(1/0);i=i.filter(p=>typeof p=="string"&&p.trim()),i=[...new Set(i)];let a=p=>{if(!J(p))return!1;if(X)return!!G(p);let P=T?p.slice(T.length):p,k=re(P);return k?k.prop.startsWith("[")?!0:(k.prop==="&",k.val.length>0):!1},g=i.map(p=>{let P=p;if(x.has(p))P=x.get(p);else if(a(p)){let k="D"+x.size.toString(32).toUpperCase();x.set(p,k),P=k,de()}return P});return o?queueMicrotask(()=>h.emit("observeDom",i)):h.emit("observeDom",i),g.join(" ")},observe:()=>{!o||!c||Ee(c,l=>{fe(l)})},getCssString:()=>Object.entries(b).map(([l,i])=>{if(!i)return"";if(l==="root"||l==="default")return i;let a=w.find(g=>Object.keys(g)[0]===l)?.[l];return a?`@media ${a} {
9
- ${i}
10
- }`:i}).join(`
11
- `)}};function Ce(t){let o=new RegExp("^(\\[(?<p>[a-zA-Z]+)\\])$"),{p:c=""}=o.exec(t)?.groups??{};if(c&&r[c]&&Array.isArray(r[c])){let x=r[c],h=[],w=!0;for(let E of x){let f=G(E);f&&f.property?h.push(f.property):typeof CSS<"u"&&CSS.supports(E)||typeof CSS>"u"?h.push(E):w=!1}if(h.length>0&&(typeof CSS>"u"||w))return h.join(";")}return null}function xe(t,o){let c=Ce(t+o);if(c)return c;if(!t||o===void 0)return null;let x=D[t],h=x||t,w=o[0],E=!1,f=o;if(w==="!"&&(E=!0,f=f.substring(1),w=f[0]),f.startsWith("--"))f="var("+f+")";else if(w==="["&&f.endsWith("]"))f=f.substring(1,f.length-1);else if(f.length>0){let A=f[0].toLowerCase()+f.substring(1),j=H[t]?.[A]||Y[A];if(!j){let V=f.toLowerCase();j=H[t]?.[V]||Y[V]}f=j||f}if(f=f.replace(/(';|;)/g,A=>A=="';"?";":" "),!f)return null;let y=f+(E?" !important":""),u=[h+":"+y];switch(h){case"mx":u=[`margin-left:${y}`,`margin-right:${y}`];break;case"my":u=[`margin-top:${y}`,`margin-bottom:${y}`];break;case"px":u=[`padding-left:${y}`,`padding-right:${y}`];break;case"py":u=[`padding-top:${y}`,`padding-bottom:${y}`];break;case"bdx":u=[`border-left:${y}`,`border-right:${y}`];break;case"bdy":u=[`border-top:${y}`,`border-bottom:${y}`];break}return!(typeof CSS<"u")||u.every(A=>CSS.supports(A))?u.join(";"):null}function G(t){if(!J(t))return null;let o=T?t.slice(T.length):t,c=re(o);if(!c)return null;let{mq:x="default",layer:h="0",prop:w,val:E,selector:f=""}=c,y=[],u=xe(w,E);if(u&&y.push(u),y.length==0)return null;let b=f.replace(/(';|;)/g,K=>K=="';"?";":" "),A=typeof CSS<"u"?CSS.escape(t):be(t),j=`selector(${A}${b})`;return typeof CSS<"u"&&b&&!CSS.supports(j)?null:{media:x||"default",layer:h||"0",className:A,property:y.join(";"),selector:b,cssRules:`.${A}${b}{${y.join(";")}}`}}let be=t=>t.replace(/([^\w-])/g,"\\$1"),Q=t=>{var o=[...t?.classList||[]].filter(c=>{if(c){let x=c.charCodeAt(0)==45?c.charCodeAt(1):c.charCodeAt(0);return x>=97&&x<=122||x>=48&&x<=57}return!1});return t?.children?.length>0&&Array.from(t?.children).forEach(c=>{o.push(...Q(c))}),o.flat(1/0)},Ee=(t,o)=>{if(typeof o!="function")throw new Error("Callback is not a function");if(!t)return;let c;"documentElement"in t?c=t.documentElement:(t instanceof Element||"tagName"in t||"host"in t)&&(c=t),c&&(c instanceof Element&&o(Q(c)),typeof MutationObserver<"u"&&new MutationObserver(x=>{for(let h of x)if(h.type=="attributes"&&h.attributeName=="class"){if(h.target.nodeType==1){let w=String(h.target?.className??""),E=String(h?.oldValue??"");if(w||E){let f=w.split(" ").map(u=>u.trim()).filter(u=>u),y=E.split(" ").map(u=>u.trim()).filter(u=>u);f=f.filter(u=>!y.includes(u)),typeof o=="function"&&o([...new Set(f)])}}}else if(h.type=="childList"&&h.addedNodes.length>0){let w=[...h.addedNodes].filter(E=>E.nodeType==1).map(E=>Q(E)).flat(1/0);typeof o=="function"&&o([...new Set(w)])}}).observe(c,{attributes:!0,attributeOldValue:!0,attributeFilter:["class"],childList:!0,subtree:!0}))};return{buildCss:me,exportCache:()=>typeof localStorage>"u"?null:JSON.parse(localStorage.getItem(q)||"null"),ready:F}},_e=(e,n)=>{oe(n).buildCss(e).observe()},Xe=(e,n)=>oe(n).buildCss(e).clsx,N={css:oe,cssObserve:_e,clsx:Xe};var ie="__FWXCSS_SHARED__",Ve=()=>{let e=new WeakMap,n=null,s=typeof document<"u"?document:null,r=m=>{if(!m)return!1;let v=typeof Document<"u",C=typeof ShadowRoot<"u",O=v&&m instanceof Document,L=C&&m instanceof ShadowRoot;return O||L},d=()=>(n||(n=N.css().buildCss(void 0)),n),S=m=>N.css({base:"html,body{font-size:16px;padding:0;margin:0;}"}).buildCss(m),I=m=>{if(!m)return d();let v=e.get(m);return v||(v=S(m),e.set(m,v)),v};return{clsx:(...m)=>{let v,C=m[m.length-1];r(C)&&(v=C,m=m.slice(0,-1));let O=[],L=D=>{if(D){if(typeof D=="string"||typeof D=="number"){O.push(String(D));return}if(Array.isArray(D)){D.forEach(L);return}typeof D=="object"&&Object.keys(D).forEach(H=>{D[H]&&O.push(H)})}};return m.forEach(L),I(v||s).clsx(O.join(" "))},setClsxRoot:m=>{s=m||(typeof document<"u"?document:null)},getCss:()=>d().getCssString()}},ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:global,B=ae[ie]||Ve();ae[ie]||(ae[ie]=B);var Ke=B.clsx,We=B.setClsxRoot,Ue=B.getCss,le=N;typeof document<"u"&&(le.cssObserve(document),console.log("\u{1F680} fwxcss Auto-Observer Activated"));var qe=le;0&&(module.exports={clsx,getCss,setClsxRoot});
1
+ "use strict";var xe=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=Object.prototype.hasOwnProperty;var lt=(e,t)=>{for(var n in t)xe(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of at(t))!ct.call(e,i)&&i!==n&&xe(e,i,{get:()=>t[i],enumerable:!(s=it(t,i))||s.enumerable});return e};var ut=e=>dt(xe({},"__esModule",{value:!0}),e);var Mt={};lt(Mt,{clsx:()=>Pt,default:()=>Kt,getBootloaderScript:()=>Fe,getCss:()=>Xt,setClsxRoot:()=>$t});module.exports=ut(Mt);var Le=e=>(e=e||new Map,{all:e,on(t,n){let s=e.get(t);s?s.push(n):e.set(t,[n])},off(t,n){let s=e.get(t);s&&(n?s.splice(s.indexOf(n)>>>0,1):e.set(t,[]))},emit(t,n){let s=e.get(t);s&&s.slice().forEach(u=>{u(n)});let i=e.get("*");i&&i.slice().forEach(u=>{u(t,n)})}});function ft(e,t,n){let s=0;for(let i=t;i<n;i++){let u=e.charCodeAt(i);if(u===91){s++;continue}if(u===93){s>0&&s--;continue}if(u===58&&s===0)return i}return-1}function pt(e,t,n){let s=0;for(let i=n-1;i>=t;i--){let u=e.charCodeAt(i);if(u===93){s++;continue}if(u===91){s>0&&s--;continue}if(u===64&&s===0)return i}return-1}function yt(e,t,n){let s=0;for(let i=t;i<n;i++){let u=e.charCodeAt(i);if(u===91){s++;continue}if(u===93){if(s===0)return!1;s--}}return s===0}function ht(e){return e>=97&&e<=122}function ce(e){if(!e||e.length<2||!yt(e,0,e.length))return null;let t=0,n=e.length,s="",i=pt(e,t,n);i>t&&(s=e.substring(i+1,n),n=i);let u="",b="",w=ft(e,t,n);if(w>0&&w<n){let x=e.substring(t,w);t=w+1,u=x}let T=t;for(;T<n;){let x=e.charCodeAt(T);if(x>=48&&x<=57)T++;else break}if(T>t&&(b=e.substring(t,T),t=T),t>=n||e.charCodeAt(t)===38)return null;if(e.charCodeAt(t)===91){let x=e.indexOf("]",t);if(x>t)return{mq:u,layer:b,prop:e.substring(t,x+1),val:"",selector:s}}let E=t;for(;E<n;){let x=e.charCodeAt(E);if(x===45||x===46){if(E+1<n){let X=e.charCodeAt(E+1);if(x===45&&X===45&&E>t||X>=48&&X<=57)break}E++;continue}if(!ht(x))break;E++}if(E===t)return null;let R=e.substring(t,E),A=e.substring(E,n);return{mq:u,layer:b,prop:R,val:A,selector:s}}var q="xcss_cache_v1",He=e=>{let t=typeof e?.styleId=="string"&&e.styleId.trim()?e.styleId.trim():"fwkui",n=typeof e?.version=="string"&&e.version.trim()?e.version.trim():"v1",s=e?.compression??!0,i=typeof e?.debounceMs=="number"&&e.debounceMs>=0?e.debounceMs:1e3;return{styleId:t,version:n,compression:s,debounceMs:i}},gt=e=>`${e.styleId}_cache_${e.version}`,We=e=>{if(!e||typeof e!="object")return!1;let t=e;return t.__xcss_cache_v===2&&t.compressed===!0&&typeof t.payload=="string"},Ee=e=>{if(!e||typeof e!="object")return!1;let t=e;return t.__xcss_cache_v===3&&t.compressed===!0&&t.algorithm==="deflate-raw"&&t.encoding==="base64"&&typeof t.payload=="string"},Ue=()=>typeof CompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u",Ve=()=>typeof DecompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u",St=e=>{if(typeof btoa=="function"){let n="";for(let i=0;i<e.length;i+=32768){let u=e.subarray(i,i+32768);for(let b=0;b<u.length;b++)n+=String.fromCharCode(u[b])}return btoa(n)}let t=globalThis.Buffer;if(typeof t<"u")return t.from(e).toString("base64");throw new Error("XCSS: base64 encoding is not supported in this runtime")},mt=e=>{if(typeof atob=="function"){let n=atob(e),s=new Uint8Array(n.length);for(let i=0;i<n.length;i++)s[i]=n.charCodeAt(i);return s}let t=globalThis.Buffer;if(typeof t<"u")return new Uint8Array(t.from(e,"base64"));throw new Error("XCSS: base64 decoding is not supported in this runtime")},Ct=async e=>{if(!Ue())throw new Error("XCSS: CompressionStream is not supported");let t=new Blob([e]).stream().pipeThrough(new CompressionStream("deflate-raw")),n=await new Response(t).arrayBuffer();return St(new Uint8Array(n))},bt=async e=>{if(!Ve())throw new Error("XCSS: DecompressionStream is not supported");let t=mt(e),n=new Uint8Array(t.length);n.set(t);let s=new Blob([n.buffer]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return await new Response(s).text()},wt=e=>{try{let t=JSON.parse(e);return Ee(t)}catch{return!1}},xt=e=>{if(!e)return"";let t=new Map,n=[],s=256;for(let u=0;u<256;u++)t.set(String.fromCharCode(u),u);let i=e[0];for(let u=1;u<e.length;u++){let b=e[u],w=i+b;t.has(w)?i=w:(n.push(t.get(i)),t.set(w,s++),i=b)}return n.push(t.get(i)),n.map(u=>String.fromCharCode(u)).join("")},Ne=e=>{if(!e)return"";let t=new Map,n=256,s="";for(let w=0;w<256;w++)t.set(w,String.fromCharCode(w));let i=e.split("").map(w=>w.charCodeAt(0)),u=i[0],b=t.get(u)||"";s=b;for(let w=1;w<i.length;w++){let T=i[w],E=t.get(T);E||(E=T===n?b+b[0]:""),s+=E,t.set(n++,b+E[0]),b=E}return s},Re=e=>{if(!e||typeof e!="object")return null;let t=e,n=t.default&&typeof t.default=="object"?t.default:t,s=n.SHORT_PROPERTIES,i=n.COMMON_VALUES,u=n.SPECIFIC_VALUES;return!s||!i||!u||typeof s!="object"||typeof i!="object"||typeof u!="object"?null:{SHORT_PROPERTIES:s,COMMON_VALUES:i,SPECIFIC_VALUES:u}},vt=async e=>{let t=await import(e),n=Re(t);if(!n)throw new Error(qe);return n},qe="XCSS: dictionary module must export SHORT_PROPERTIES, COMMON_VALUES and SPECIFIC_VALUES",Ze=()=>{let e=typeof require=="function"?require:null;if(!e)return null;for(let t of["./dictionary.js","./dictionary"])try{let n=e(t),s=Re(n);if(s)return s}catch{}return null},Et=async()=>{let e=Ze();if(e)return e;let t=["./dictionary.mjs","./dictionary.js","./dictionary"],n=null;for(let s of t)try{let i=await import(s),u=Re(i);if(u)return u}catch(i){n=i}throw n||new Error(qe)},Rt=(e,t)=>{if(!e||typeof document>"u")return;t=t||"fwkui";let n=Array.from({length:24},(s,i)=>"l"+i);if(!e.querySelector('style[id="'+t+'"]')){let s=document.createElement("style");if(s.id=t,!(e instanceof ShadowRoot))document.head.append(s);else try{e.prepend(s)}catch{e.appendChild(s)}let i=`@layer ${n.join(", ")};`,u=setInterval(()=>{if(s.sheet){clearInterval(u);try{s.sheet.insertRule(i,s.sheet.cssRules.length)}catch{}}},10)}},Dt=e=>{let t=Array.isArray(e.excludes)?e.excludes:Array.isArray(e.exclude)?e.exclude:[],n=He(e.cache),s=JSON.stringify({base:e.base||"",aliases:e.aliases||{},breakpoints:e.breakpoints||[],theme:e.theme||{},prefix:e.prefix||"",excludes:t,excludePrefixes:e.excludePrefixes||[],dictionaryImport:e.dictionaryImport??!0,cache:n}),i=0;if(s.length===0)return i.toString();for(let u=0;u<s.length;u++){let b=s.charCodeAt(u);i=(i<<5)-i+b,i|=0}return i.toString()},ve=e=>{if(!e)return null;try{let t=JSON.parse(e);if(We(t)){let n=Ne(t.payload);return n?JSON.parse(n):null}return Ee(t)?null:t}catch{return null}},Tt=async e=>{if(!e)return null;try{let t=JSON.parse(e);if(We(t)){let n=Ne(t.payload);return n?JSON.parse(n):null}if(Ee(t)){let n=await bt(t.payload);return n?JSON.parse(n):null}return t}catch{return null}},Be=(e,t)=>{if(e==="root")return t;let n=/@media[^{]+\{\n?([\s\S]+)\n?\}/.exec(t);return n&&n[1]?n[1].trim():t},De=(e={base:"",aliases:{},excludes:[],excludePrefixes:[],breakpoints:[],theme:{},prefix:"",dictionaryImport:!0,cache:{styleId:"fwkui",version:"v1",compression:!0,debounceMs:1e3}})=>{let{base:t=null,breakpoints:n=[],aliases:s={},theme:i={},excludes:u=[],exclude:b=[],excludePrefixes:w=[],prefix:T="",dictionaryImport:E=!0,cache:R={}}=e||{};Array.isArray(n)||(n=[]),Array.isArray(u)||(u=[]),Array.isArray(b)||(b=[]),Array.isArray(w)||(w=[]),(!s||typeof s!="object")&&(s={}),(!i||typeof i!="object")&&(i={});let A=He(R),x=gt(A),X=[...u,...b],Z=w.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0),ke=r=>{let o=r.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+o.replace(/\*/g,".*")+"$")},K=X.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0).map(r=>{if(r.includes("*")){let o=ke(r);return l=>o.test(l)}return o=>o===r}),re=r=>Z.some(o=>r.startsWith(o))?!0:K.some(o=>o(r)),Ie=r=>!(re(r)||T&&!r.startsWith(T)),Je=["default","xs","sm","md","lg","xl","2xl","sma","mda","lga","xla"],ze=n.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r)).map(r=>Object.keys(r)[0]).filter(r=>typeof r=="string"&&r.length>0),Ye=new Set([...Je,...ze]),ue=r=>!r||Ye.has(r),Ge=E!==!1,Qe=new Set(["mx","my","px","py","bdx","bdy"]),fe=new Set,pe=r=>r?!Ge||!V||Object.keys(V).length===0?!0:!!V[r]||Qe.has(r)||fe.has(r):!1,V={},ne={},ye={},he={},Oe=()=>{he={...ye,...i}},F=r=>{if(!r){V={},ne={},ye={},fe=new Set,Oe();return}V=r.SHORT_PROPERTIES,ne=r.SPECIFIC_VALUES,ye=r.COMMON_VALUES,fe=new Set(Object.values(V)),Oe()},J=!0,se=Promise.resolve();if(E===!1)F(null);else if(typeof E=="string")J=!1,F(null),se=vt(E).then(r=>{F(r)}).catch(r=>{console.warn("XCSS: Failed to import dictionary from URL",r)}).finally(()=>{J=!0});else{let r=Ze();r?F(r):(J=!1,F(null),se=Et().then(o=>{F(o)}).catch(o=>{console.warn("XCSS: Failed to load built-in dictionary module",o)}).finally(()=>{J=!0}))}let G=null,et=(r=typeof document<"u"?document:void 0)=>{let o=typeof window<"u"&&typeof document<"u",l=null,g=Array.isArray(t)?t.length>0:!!t;r&&(l="getRootNode"in r?r.getRootNode():r);let p=new Map;o&&l&&Rt(l,A.styleId);let v=Le(),_=[{default:""},{xs:"screen and (max-width: 575px)"},{sm:"screen and (min-width: 576px)"},{md:"screen and (min-width: 768px)"},{lg:"screen and (min-width: 992px)"},{xl:"screen and (min-width: 1200px)"},{"2xl":"screen and (min-width: 1400px)"},{sma:"screen and (max-width: 768px)"},{mda:"screen and (max-width: 992px)"},{lga:"screen and (max-width: 1200px)"},{xla:"screen and (max-width: 1400px)"},...n],y=_.filter((a,d)=>_.findLastIndex(c=>Object.keys(c)[0]==Object.keys(a)[0])==d),C=y.map(a=>Object.keys(a)[0]),f={},D={},S={root:""},M={root:[]},L={root:!1},Q=Dt(e),z=null,k=0,j=!1,O=null,Y=null,W=[],B=a=>{try{window.localStorage.setItem(x,a)}catch(d){console.warn("XCSS: Failed to save cache",d)}},oe=(a,d)=>{!o||!window.localStorage||typeof d=="string"&&window.localStorage.getItem(a)!==d||window.localStorage.removeItem(a)},N=a=>{if(!o||!window.localStorage)return;G=a;let d=++k;try{let c=JSON.stringify(a),h=()=>{let m={__xcss_cache_v:2,compressed:!0,payload:xt(c)};B(JSON.stringify(m))};if(!A.compression){B(c);return}if(Ue()&&Ve()){Ct(c).then(m=>{if(d!==k)return;B(JSON.stringify({__xcss_cache_v:3,compressed:!0,algorithm:"deflate-raw",encoding:"base64",payload:m}))}).catch(()=>{d===k&&h()});return}h()}catch(c){console.warn("XCSS: Failed to save cache",c)}},ie=()=>{o&&(z&&clearTimeout(z),z=setTimeout(()=>{let a={};for(let h in f)a[h]=Array.from(f[h]);let d={};Object.keys(S).forEach(h=>{if(h==="root")d[h]=S[h];else{let m=_.find($=>Object.keys($)[0]===h)?.[h];m&&S[h]?d[h]=`@media ${m} {
2
+ ${S[h]}
3
+ }`:d[h]=S[h]||""}});let c={configHash:Q,cssText:d,rulesSet:a,keys:Array.from(p.entries())};N(c)},A.debounceMs))};if(o&&window.localStorage)try{let a=x===q?[x]:[x,q];for(let d of a){let c=window.localStorage.getItem(d);if(!c)continue;let h=ve(c);if(!h){if(wt(c)){W.push({key:d,raw:c});continue}window.localStorage.removeItem(d);continue}if(h.configHash!==Q){window.localStorage.removeItem(d);continue}O=h,Y=d,j=!0;break}if(O){if(O.keys&&O.keys.forEach(([d,c])=>p.set(d,c)),O.cssText)for(let d in O.cssText){let c=O.cssText[d];S[d]=Be(d,c)}G=O}}catch(a){console.error(a)}o&&(D.root=new CSSStyleSheet),C.forEach(a=>{if(f[a]=new Set,o){let d=y.find(c=>Object.keys(c)[0]==a)?.[a]||"";D[a]=new CSSStyleSheet({media:d})}j||(S[a]=""),M[a]=[],L[a]=!1});let I=()=>{if(!l)return;let a=l.querySelector(`style[id="${A.styleId}"]`);a&&a.remove()},ae=(a,d)=>{if(a.keys&&a.keys.forEach(([c,h])=>p.set(c,h)),a.cssText)for(let c in a.cssText){if(c==="root"&&g)continue;let h=Be(c,a.cssText[c]);S[c]=h,o&&D[c]&&D[c].replaceSync(h)}if(a.rulesSet)for(let c in a.rulesSet)f[c]||(f[c]=new Set),a.rulesSet[c].forEach(h=>f[c].add(h));o&&window.localStorage&&d===q&&x!==q&&(N(a),window.localStorage.removeItem(q)),G=a,I()};j&&O&&ae(O,Y),t&&Array.isArray(t)?(S.root=t.join(`
4
+ `),o&&D.root&&D.root.replaceSync(S.root)):(S.root=t||"",o&&D.root&&D.root.replaceSync(S.root)),o&&l&&["root",...C].forEach(a=>{D[a]&&l?.adoptedStyleSheets&&(l.adoptedStyleSheets.includes(D[a])||(l.adoptedStyleSheets=[...l.adoptedStyleSheets,D[a]]))}),o&&window.localStorage&&W.length>0&&(async()=>{for(let a of W){let d=await Tt(a.raw);if(!d){oe(a.key,a.raw);continue}if(d.configHash!==Q){oe(a.key,a.raw);continue}if(!j){j=!0,O=d,Y=a.key,ae(d,a.key);break}}})();let me=(a,d)=>{let{media:c,property:h,selector:m,layer:$,className:P}=d,U=S,H=M,be=L;$=Number($)||0;let Ke=p.get(a),ot=Ke?`.${Ke}${m}`:`.${P}${m}`;var we=`@layer l${$}{${ot}{${h}}}`;f[c]||(f[c]=new Set);let Me=f[c];if(!Me.has(we))if(Me.add(we),H[c]||(H[c]=[]),H[c].push(we),o)be[c]||(be[c]=!0,queueMicrotask(()=>{let te=H[c],je=D[c];te.length>0&&(U[c]+=(U[c]?`
5
+ `:"")+te.join(`
6
+ `),je&&je.replaceSync(U[c]),H[c]=[],ie()),be[c]=!1}));else{let te=H[c];te.length>0&&(U[c]+=(U[c]?`
7
+ `:"")+te.join(`
8
+ `),H[c]=[])}},Ce=a=>{a.forEach(d=>{let c=Xe(d);c&&me(d,c)})},ee=a=>{if(a.length===0)return;let d=()=>Ce(a);J?d():se.then(d)};return v.on("observeDom",ee),{clsx:(...a)=>{let d=a.map(m=>Array.isArray(m)?m:[m]).flat(1/0).map(m=>typeof m=="string"?m.split(/(\s|\t)+/g):[]).flat(1/0);d=d.filter(m=>typeof m=="string"&&m.trim()),d=[...new Set(d)];let c=m=>{if(!Ie(m))return!1;if(J)return!!Xe(m);let $=T?m.slice(T.length):m,P=ce($);if(!P||!ue(P.mq))return!1;let U=(P.selector||"").replace(/(';|;)/g,H=>H=="';"?";":" ");return U&&!ge(U)?!1:P.prop.startsWith("[")?!!Pe(P.prop+P.val):pe(P.prop)?(P.prop==="&",P.val.length>0):!1},h=d.map(m=>{let $=m;if(p.has(m))$=p.get(m);else if(c(m)){let P="D"+p.size.toString(32).toUpperCase();p.set(m,P),$=P,ie()}return $});return o?queueMicrotask(()=>v.emit("observeDom",d)):v.emit("observeDom",d),h.join(" ")},observe:()=>{!o||!l||st(l,a=>{ee(a)})},getCssString:()=>Object.entries(S).map(([a,d])=>{if(!d)return"";if(a==="root"||a==="default")return d;let c=_.find(h=>Object.keys(h)[0]===a)?.[a];return c?`@media ${c} {
9
+ ${d}
10
+ }`:d}).join(`
11
+ `)}};function Pe(r){let o=new RegExp("^(\\[(?<p>[a-zA-Z]+)\\])$"),{p:l=""}=o.exec(r)?.groups??{};if(l&&s[l]&&Array.isArray(s[l])){let g=s[l],p=[],v=!0,_=y=>{let C=y.trim();if(!C)return null;let f=C.endsWith(";")?C.slice(0,-1).trim():C,D=f.indexOf(":");if(D<=0||D>=f.length-1)return null;let S=f.slice(0,D).trim(),M=f.slice(D+1).trim();return!S||!M||!/^(?:--[a-zA-Z0-9-_]+|-?[a-zA-Z][a-zA-Z0-9-]*)$/.test(S)?null:`${S}:${M}`};for(let y of g){if(typeof y!="string"){v=!1;break}let C=_(y);if(C){if(typeof CSS<"u"&&!CSS.supports(C)){v=!1;break}p.push(C);continue}v=!1;break}if(p.length>0&&v)return p.join(";")}return null}function $e(r,o){let l=Pe(r+o);if(l)return l;if(!r||o===void 0)return null;let g=V[r],p=g||r,v=o[0],_=!1,y=o;if(v==="!"&&(_=!0,y=y.substring(1),v=y[0]),y.startsWith("--"))y="var("+y+")";else if(v==="["&&y.endsWith("]"))y=y.substring(1,y.length-1);else if(y.length>0){let S=y[0].toLowerCase()+y.substring(1),M=ne[r]?.[S]||he[S];if(!M){let L=y.toLowerCase();M=ne[r]?.[L]||he[L]}y=M||y}if(y=y.replace(/(';|;)/g,S=>S=="';"?";":" "),!y)return null;let C=y+(_?" !important":""),f=[p+":"+C];switch(p){case"mx":f=[`margin-left:${C}`,`margin-right:${C}`];break;case"my":f=[`margin-top:${C}`,`margin-bottom:${C}`];break;case"px":f=[`padding-left:${C}`,`padding-right:${C}`];break;case"py":f=[`padding-top:${C}`,`padding-bottom:${C}`];break;case"bdx":f=[`border-left:${C}`,`border-right:${C}`];break;case"bdy":f=[`border-top:${C}`,`border-bottom:${C}`];break}return!(typeof CSS<"u")||f.every(S=>CSS.supports(S))?f.join(";"):null}let tt=r=>{let o=0;for(let l=r.length-1;l>=0;l--){let g=r[l];if(g==="]"){o++;continue}if(g==="["){o>0&&o--;continue}if(g==="@"&&o===0)return{body:r.slice(0,l),selector:r.slice(l+1)}}return{body:r,selector:""}},rt=r=>{let o=[],l=0,g=0;for(let p=0;p<r.length;p++){let v=r[p];if(v==="["){g++;continue}if(v==="]"){g>0&&g--;continue}v==="&"&&g===0&&(o.push(r.slice(l,p)),l=p+1)}return o.push(r.slice(l)),o},ge=r=>{if(!r)return!0;let o=r.trim();if(!o)return!0;if(/[{}]/.test(o)||o==="#"||o==="("||o===")"||o===","||o===">"||o==="+"||o==="~"||o.startsWith("(")||o.startsWith(")"))return!1;let l=0;for(let g=0;g<o.length;g++){let p=o[g];if(p==="("){l++;continue}if(p===")"){if(l===0)return!1;l--}}return l===0};function Xe(r){if(!Ie(r))return null;let o=T?r.slice(T.length):r,l=typeof CSS<"u"?CSS.escape(r):nt(r);if(o.includes("&")&&!o.startsWith("&")){let{body:L,selector:Q}=tt(o),z=rt(L).map(k=>k.trim()).filter(k=>k.length>0).map(k=>T&&k.startsWith(T)?k.slice(T.length):k);if(z.length>1){let k="",j="",O=Q,Y=!1,W=[];for(let N of z){let ie=O?`${N}@${O}`:N,I=ce(ie);if(!I||!ue(I.mq)||!I.prop.startsWith("[")&&!pe(I.prop))return null;Y?(!I.mq&&k&&(I.mq=k),!I.layer&&j&&(I.layer=j)):(k=I.mq||"",j=I.layer||"",Y=!0);let ae=I.mq||"",me=I.layer||"",Ce=I.selector||"";if(ae!==k||me!==j||Ce!==O)return null;let ee=$e(I.prop,I.val);if(!ee)return null;W.push(ee)}if(W.length===0)return null;let B=O.replace(/(';|;)/g,N=>N=="';"?";":" "),oe=`selector(${l}${B})`;if(B){if(typeof CSS<"u"){if(!CSS.supports(oe))return null}else if(!ge(B))return null}return{media:k||"default",layer:j||"0",className:l,property:W.join(";"),selector:B,cssRules:`.${l}${B}{${W.join(";")}}`}}}let g=ce(o);if(!g||!ue(g.mq)||!g.prop.startsWith("[")&&!pe(g.prop))return null;let{mq:p="default",layer:v="0",prop:_,val:y,selector:C=""}=g,f=[],D=$e(_,y);if(D&&f.push(D),f.length===0)return null;let S=C.replace(/(';|;)/g,L=>L=="';"?";":" "),M=`selector(${l}${S})`;if(S){if(typeof CSS<"u"){if(!CSS.supports(M))return null}else if(!ge(S))return null}return{media:p||"default",layer:v||"0",className:l,property:f.join(";"),selector:S,cssRules:`.${l}${S}{${f.join(";")}}`}}let nt=r=>r.replace(/([^\w-])/g,"\\$1"),Se=r=>{var o=[...r?.classList||[]].filter(l=>{if(l){let g=l.charCodeAt(0)==45?l.charCodeAt(1):l.charCodeAt(0);return g>=97&&g<=122||g>=48&&g<=57}return!1});return r?.children?.length>0&&Array.from(r?.children).forEach(l=>{o.push(...Se(l))}),o.flat(1/0)},st=(r,o)=>{if(typeof o!="function")throw new Error("Callback is not a function");if(!r)return;let l;"documentElement"in r?l=r.documentElement:(r instanceof Element||"tagName"in r||"host"in r)&&(l=r),l&&(l instanceof Element&&o(Se(l)),typeof MutationObserver<"u"&&new MutationObserver(g=>{for(let p of g)if(p.type=="attributes"&&p.attributeName=="class"){if(p.target.nodeType==1){let v=String(p.target?.className??""),_=String(p?.oldValue??"");if(v||_){let y=v.split(" ").map(f=>f.trim()).filter(f=>f),C=_.split(" ").map(f=>f.trim()).filter(f=>f);y=y.filter(f=>!C.includes(f)),typeof o=="function"&&o([...new Set(y)])}}}else if(p.type=="childList"&&p.addedNodes.length>0){let v=[...p.addedNodes].filter(_=>_.nodeType==1).map(_=>Se(_)).flat(1/0);typeof o=="function"&&o([...new Set(v)])}}).observe(l,{attributes:!0,attributeOldValue:!0,attributeFilter:["class"],childList:!0,subtree:!0}))};return{buildCss:et,exportCache:()=>{if(typeof window>"u"||!window.localStorage)return G;let r=ve(window.localStorage.getItem(x));if(r)return r;if(x!==q){let o=ve(window.localStorage.getItem(q));if(o)return o}return G},ready:se}},_t=(e,t)=>{De(t).buildCss(e).observe()},At=(e,t)=>De(t).buildCss(e).clsx,le={css:De,cssObserve:_t,clsx:At};var kt="xcss_cache_v1",It=(e,t)=>{let n=String(t||"").trim();return n?n===kt||n.includes("_cache_")?n:`${e}_cache_${n}`:`${e}_cache_v1`},Fe=(e="fwkui",t="v1",n)=>{let s=String(e||"").trim()||"fwkui",i=It(s,t),u=JSON.stringify(s),b=JSON.stringify(i),w=`
12
+ (async function () {
13
+ function decompressLZW(compressed) {
14
+ if (!compressed) return '';
15
+ var dictionary = {};
16
+ var dictSize = 256;
17
+ var i;
18
+ for (i = 0; i < 256; i++) dictionary[i] = String.fromCharCode(i);
19
+ var codes = compressed.split('').map(function (ch) { return ch.charCodeAt(0); });
20
+ var previous = codes[0];
21
+ var phrase = dictionary[previous] || '';
22
+ var result = phrase;
23
+ for (i = 1; i < codes.length; i++) {
24
+ var current = codes[i];
25
+ var entry = dictionary[current];
26
+ if (!entry) entry = current === dictSize ? phrase + phrase[0] : '';
27
+ result += entry;
28
+ dictionary[dictSize++] = phrase + entry[0];
29
+ phrase = entry;
30
+ }
31
+ return result;
32
+ }
33
+
34
+ function canUseStream() {
35
+ return (
36
+ typeof DecompressionStream !== 'undefined' &&
37
+ typeof Blob !== 'undefined' &&
38
+ typeof Response !== 'undefined'
39
+ );
40
+ }
41
+
42
+ function base64ToBytes(base64) {
43
+ if (typeof atob === 'function') {
44
+ var binary = atob(base64);
45
+ var bytes = new Uint8Array(binary.length);
46
+ for (var i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
47
+ return bytes;
48
+ }
49
+ if (typeof Buffer !== 'undefined') {
50
+ return new Uint8Array(Buffer.from(base64, 'base64'));
51
+ }
52
+ throw new Error('No base64 decoder');
53
+ }
54
+
55
+ async function decompressDeflateRawBase64(payload) {
56
+ if (!canUseStream()) return null;
57
+ try {
58
+ var bytes = base64ToBytes(payload);
59
+ var stream = new Blob([bytes]).stream().pipeThrough(new DecompressionStream('deflate-raw'));
60
+ return await new Response(stream).text();
61
+ } catch (_error) {
62
+ return null;
63
+ }
64
+ }
65
+
66
+ async function parseCache(raw) {
67
+ if (!raw) return null;
68
+ try {
69
+ var parsed = JSON.parse(raw);
70
+ if (
71
+ parsed &&
72
+ parsed.__xcss_cache_v === 3 &&
73
+ parsed.compressed === true &&
74
+ parsed.algorithm === 'deflate-raw' &&
75
+ parsed.encoding === 'base64' &&
76
+ typeof parsed.payload === 'string'
77
+ ) {
78
+ var expandedStream = await decompressDeflateRawBase64(parsed.payload);
79
+ if (!expandedStream) return null;
80
+ parsed = JSON.parse(expandedStream);
81
+ } else if (parsed && parsed.__xcss_cache_v === 2 && parsed.compressed === true && typeof parsed.payload === 'string') {
82
+ var expanded = decompressLZW(parsed.payload);
83
+ if (!expanded) return null;
84
+ parsed = JSON.parse(expanded);
85
+ }
86
+ if (!parsed || !parsed.cssText) return null;
87
+ return parsed;
88
+ } catch (_error) {
89
+ return null;
90
+ }
91
+ }
92
+
93
+ try {
94
+ if (typeof window === 'undefined' || !window.localStorage) return;
95
+
96
+ var styleId = ${u};
97
+ var primaryKey = ${b};
98
+ var keys = primaryKey === 'xcss_cache_v1' ? [primaryKey] : [primaryKey, 'xcss_cache_v1'];
99
+ var payload = null;
100
+
101
+ for (var i = 0; i < keys.length; i++) {
102
+ var key = keys[i];
103
+ var raw = localStorage.getItem(key);
104
+ if (!raw) continue;
105
+ payload = await parseCache(raw);
106
+ if (!payload) {
107
+ localStorage.removeItem(key);
108
+ continue;
109
+ }
110
+ if (payload) break;
111
+ }
112
+
113
+ if (!payload) return;
114
+
115
+ var styleEl = document.getElementById(styleId);
116
+ if (!styleEl) {
117
+ styleEl = document.createElement('style');
118
+ styleEl.id = styleId;
119
+ document.head.appendChild(styleEl);
120
+ }
121
+
122
+ var css = '';
123
+ if (payload.cssText.root) css += payload.cssText.root + '\\n';
124
+ for (var k in payload.cssText) {
125
+ if (k !== 'root') css += (payload.cssText[k] || '') + '\\n';
126
+ }
127
+ styleEl.textContent = css;
128
+ } catch (_error) {}
129
+ })();
130
+ `.trim();return n?.compact?w.replace(/\s+/g," ").trim():w};var Te="__FWXCSS_SHARED__",Ot=()=>{let e=new WeakMap,t=null,n=typeof document<"u"?document:null,s=R=>{if(!R)return!1;let A=typeof Document<"u",x=typeof ShadowRoot<"u",X=A&&R instanceof Document,Z=x&&R instanceof ShadowRoot;return X||Z},i=()=>(t||(t=le.css().buildCss(void 0)),t),u=R=>le.css({base:"html,body{font-size:16px;padding:0;margin:0;}"}).buildCss(R),b=R=>{if(!R)return i();let A=e.get(R);return A||(A=u(R),e.set(R,A)),A};return{clsx:(...R)=>{let A,x=R[R.length-1];s(x)&&(A=x,R=R.slice(0,-1));let X=[],Z=K=>{if(K){if(typeof K=="string"||typeof K=="number"){X.push(String(K));return}if(Array.isArray(K)){K.forEach(Z);return}typeof K=="object"&&Object.keys(K).forEach(re=>{K[re]&&X.push(re)})}};return R.forEach(Z),b(A||n).clsx(X.join(" "))},setClsxRoot:R=>{n=R||(typeof document<"u"?document:null)},getCss:()=>i().getCssString()}},_e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:global,de=_e[Te]||Ot();_e[Te]||(_e[Te]=de);var Pt=de.clsx,$t=de.setClsxRoot,Xt=de.getCss;var Ae=le;typeof document<"u"&&(Ae.cssObserve(document),console.log("\u{1F680} fwxcss Auto-Observer Activated"));var Kt=Ae;0&&(module.exports={clsx,getBootloaderScript,getCss,setClsxRoot});
12
131
  //# sourceMappingURL=index-auto.js.map