@fwkui/x-css 1.0.14 → 1.0.16
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 +168 -4
- package/dist/index-auto.d.mts +1 -1
- package/dist/index-auto.d.ts +1 -1
- package/dist/index-auto.js +130 -11
- package/dist/index-auto.js.map +1 -1
- package/dist/index-auto.mjs +130 -11
- package/dist/index-auto.mjs.map +1 -1
- package/dist/index.d.mts +34 -5
- package/dist/index.d.ts +34 -5
- package/dist/index.js +130 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
@@ -233,6 +250,48 @@ export function Button({ primary, children }) {
|
|
|
233
250
|
}
|
|
234
251
|
```
|
|
235
252
|
|
|
253
|
+
## Shared Instance (Khởi Tạo Một Lần)
|
|
254
|
+
|
|
255
|
+
Nếu bạn muốn tái sử dụng cùng một instance (giữ mapping key ổn định), dùng factory:
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
import { createSharedInstance } from '@fwkui/x-css';
|
|
259
|
+
|
|
260
|
+
export const fx = createSharedInstance({
|
|
261
|
+
prefix: 'fk-',
|
|
262
|
+
cache: {
|
|
263
|
+
styleId: 'fwkui',
|
|
264
|
+
version: 'v1',
|
|
265
|
+
compression: true,
|
|
266
|
+
debounceMs: 1000
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Browser: gọi 1 lần khi app khởi động
|
|
271
|
+
fx.observe(document);
|
|
272
|
+
|
|
273
|
+
// Dùng ở mọi nơi
|
|
274
|
+
const className = fx.clsx('fk-dF fk-aiC fk-jcC fk-p10px;16px');
|
|
275
|
+
|
|
276
|
+
// Nếu dictionaryImport là true/string và cần chắc chắn CSS đã sẵn sàng:
|
|
277
|
+
await fx.ready();
|
|
278
|
+
|
|
279
|
+
// SSR / debug
|
|
280
|
+
const cssText = fx.getCss();
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Alias tương đương:
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import { createSharedClsx } from '@fwkui/x-css';
|
|
287
|
+
const fx = createSharedClsx({ prefix: 'fk-' });
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Quy tắc dùng ổn định:
|
|
291
|
+
1. Tạo shared instance đúng 1 lần ở bootstrap.
|
|
292
|
+
2. Không khởi tạo lại instance ở mỗi lần render component.
|
|
293
|
+
3. Giữ nguyên `prefix/cache` trong suốt vòng đời app để key hash ổn định.
|
|
294
|
+
|
|
236
295
|
## Cấu Hình
|
|
237
296
|
|
|
238
297
|
```js
|
|
@@ -250,7 +309,13 @@ xcss.cssObserve(document, {
|
|
|
250
309
|
prefix: 'fk-',
|
|
251
310
|
excludePrefixes: ['bs-', 'rs-'],
|
|
252
311
|
excludes: ['legacy-*'],
|
|
253
|
-
dictionaryImport: true
|
|
312
|
+
dictionaryImport: true,
|
|
313
|
+
cache: {
|
|
314
|
+
styleId: 'fwkui',
|
|
315
|
+
version: 'v1',
|
|
316
|
+
compression: true,
|
|
317
|
+
debounceMs: 1000
|
|
318
|
+
}
|
|
254
319
|
});
|
|
255
320
|
```
|
|
256
321
|
|
|
@@ -286,9 +351,9 @@ Lưu ý format output:
|
|
|
286
351
|
2. Token không parse được hoặc bị exclude sẽ giữ nguyên ở output.
|
|
287
352
|
|
|
288
353
|
Lưu ý khi dùng cùng `prefix`:
|
|
289
|
-
1. Engine kiểm tra `
|
|
290
|
-
2. Nếu
|
|
291
|
-
3.
|
|
354
|
+
1. Engine kiểm tra `excludes`/`excludePrefixes` trước, sau đó mới kiểm tra `prefix`.
|
|
355
|
+
2. Nếu token match exclude thì giữ nguyên class gốc và không parse tiếp.
|
|
356
|
+
3. Nếu có `prefix: 'fk-'`, token không bắt đầu bằng `fk-` sẽ giữ nguyên class gốc.
|
|
292
357
|
4. `exclude` vẫn được hỗ trợ để tương thích ngược, nhưng key khuyến nghị là `excludes`.
|
|
293
358
|
|
|
294
359
|
`dictionaryImport`:
|
|
@@ -300,6 +365,23 @@ Lưu ý:
|
|
|
300
365
|
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
366
|
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
367
|
|
|
368
|
+
`cache`:
|
|
369
|
+
1. `styleId` (mặc định `fwkui`): id thẻ `<style>` runtime.
|
|
370
|
+
2. `version` (mặc định `v1`): tham gia vào cache key để chủ động invalidate.
|
|
371
|
+
3. `compression` (mặc định `true`): nén cache trước khi lưu `localStorage`.
|
|
372
|
+
4. `debounceMs` (mặc định `1000`): debounce chu kỳ nén + lưu cache.
|
|
373
|
+
|
|
374
|
+
Khi `compression: true`:
|
|
375
|
+
1. Ưu tiên `CompressionStream` (deflate-raw + base64) nếu runtime hỗ trợ.
|
|
376
|
+
2. Tự động fallback về LZW để tương thích ngược.
|
|
377
|
+
3. Đọc cache vẫn hỗ trợ key cũ `xcss_cache_v1` để migrate dần.
|
|
378
|
+
|
|
379
|
+
Quy tắc cache key:
|
|
380
|
+
`cacheKey = styleId + "_cache_" + version`
|
|
381
|
+
|
|
382
|
+
Ví dụ mặc định:
|
|
383
|
+
`fwkui_cache_v1`
|
|
384
|
+
|
|
303
385
|
Nếu import dictionary ngoài:
|
|
304
386
|
|
|
305
387
|
```js
|
|
@@ -368,6 +450,88 @@ Quy trình thay link:
|
|
|
368
450
|
3. Thay `dictionaryImport` bằng URL thật.
|
|
369
451
|
4. Chờ `await engine.ready` trước khi render class.
|
|
370
452
|
|
|
453
|
+
## Bootloader Từ Cache (Khuyến nghị)
|
|
454
|
+
|
|
455
|
+
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.
|
|
456
|
+
|
|
457
|
+
### Dùng helper `getBootloaderScript`
|
|
458
|
+
|
|
459
|
+
```js
|
|
460
|
+
import { getBootloaderScript } from '@fwkui/x-css';
|
|
461
|
+
|
|
462
|
+
const styleId = 'fwkui';
|
|
463
|
+
const version = 'v1';
|
|
464
|
+
|
|
465
|
+
const bootloaderScript = getBootloaderScript(styleId, version);
|
|
466
|
+
const bootloaderScriptCompact = getBootloaderScript(styleId, version, { compact: true });
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### Cấu trúc chèn vào `<head>` (khuyến nghị)
|
|
470
|
+
|
|
471
|
+
```html
|
|
472
|
+
<head>
|
|
473
|
+
<!-- 1) Bootloader từ cache: chạy sớm nhất để giảm FOUC -->
|
|
474
|
+
<script>
|
|
475
|
+
/* nội dung từ getBootloaderScript(styleId, version) */
|
|
476
|
+
</script>
|
|
477
|
+
|
|
478
|
+
<!-- 2) Bundle/module của app -->
|
|
479
|
+
<script type="module" src="/assets/main.js"></script>
|
|
480
|
+
</head>
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Đoạn dán thủ công vào `<head>` (copy/paste)
|
|
484
|
+
|
|
485
|
+
Thay 2 biến ngay đầu script nếu cần:
|
|
486
|
+
1. `sid = 'fwkui'` -> đổi theo `cache.styleId`.
|
|
487
|
+
2. `ver = 'v1'` -> đổi theo `cache.version`.
|
|
488
|
+
|
|
489
|
+
```html
|
|
490
|
+
<script>
|
|
491
|
+
(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{}})();
|
|
492
|
+
</script>
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
Ví dụ render HTML từ server:
|
|
496
|
+
|
|
497
|
+
```js
|
|
498
|
+
import { getBootloaderScript } from '@fwkui/x-css';
|
|
499
|
+
|
|
500
|
+
const styleId = 'fwkui';
|
|
501
|
+
const version = 'v1';
|
|
502
|
+
const bootloaderScript = getBootloaderScript(styleId, version, { compact: true });
|
|
503
|
+
|
|
504
|
+
const html = `
|
|
505
|
+
<!doctype html>
|
|
506
|
+
<html>
|
|
507
|
+
<head>
|
|
508
|
+
<meta charset="UTF-8" />
|
|
509
|
+
<script>${bootloaderScript}</script>
|
|
510
|
+
<script type="module" src="/assets/main.js"></script>
|
|
511
|
+
</head>
|
|
512
|
+
<body><div id="app"></div></body>
|
|
513
|
+
</html>`;
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Lưu ý:
|
|
517
|
+
1. Đồng bộ `styleId` + `version` giữa bootloader và cấu hình `xcss.css(...)`.
|
|
518
|
+
2. Script tạo từ `getBootloaderScript` ưu tiên `DecompressionStream` (cache deflate-raw) và fallback LZW/legacy.
|
|
519
|
+
3. Sau bootloader vẫn cần gọi `xcss.cssObserve(...)` như bình thường.
|
|
520
|
+
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 đó.
|
|
521
|
+
5. Dùng `{ compact: true }` khi muốn script trả về ở dạng nén gọn để nhúng HTML.
|
|
522
|
+
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.
|
|
523
|
+
|
|
524
|
+
### Khi nào nên dùng `getBootloaderScript`
|
|
525
|
+
|
|
526
|
+
1. SSR/MPA hoặc trang tĩnh cần giảm FOUC ngay từ first paint.
|
|
527
|
+
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.
|
|
528
|
+
3. Khi bạn chủ động kiểm soát thứ tự script trong `<head>`.
|
|
529
|
+
|
|
530
|
+
Không bắt buộc dùng khi:
|
|
531
|
+
1. Trang không cần tối ưu first paint.
|
|
532
|
+
2. Không dùng cache runtime.
|
|
533
|
+
3. CSP không cho inline script (trừ khi đã cấu hình nonce/hash phù hợp).
|
|
534
|
+
|
|
371
535
|
## SSR Và Static Extraction
|
|
372
536
|
|
|
373
537
|
SSR:
|
package/dist/index-auto.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _default from './index.mjs';
|
|
2
|
-
export { XCSSConfig, clsx, getCss, setClsxRoot } from './index.mjs';
|
|
2
|
+
export { BootloaderScriptOptions, SharedXCSSInstance, XCSSConfig, clsx, createSharedClsx, createSharedInstance, getBootloaderScript, getCss, observe, ready, setClsxRoot } from './index.mjs';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
package/dist/index-auto.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _default from './index.js';
|
|
2
|
-
export { XCSSConfig, clsx, getCss, setClsxRoot } from './index.js';
|
|
2
|
+
export { BootloaderScriptOptions, SharedXCSSInstance, XCSSConfig, clsx, createSharedClsx, createSharedInstance, getBootloaderScript, getCss, observe, ready, setClsxRoot } from './index.js';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
package/dist/index-auto.js
CHANGED
|
@@ -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
|
-
${
|
|
3
|
-
}`:
|
|
4
|
-
`),
|
|
5
|
-
`:"")+
|
|
6
|
-
`),
|
|
7
|
-
`:"")+
|
|
8
|
-
`),
|
|
9
|
-
${
|
|
10
|
-
}`:
|
|
11
|
-
`)}};function
|
|
1
|
+
"use strict";var xe=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var lt=Object.prototype.hasOwnProperty;var dt=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ct(t))!lt.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(s=at(t,o))||s.enumerable});return e};var ft=e=>ut(xe({},"__esModule",{value:!0}),e);var Vt={};dt(Vt,{clsx:()=>Lt,createSharedClsx:()=>Mt,createSharedInstance:()=>Kt,default:()=>Ut,getBootloaderScript:()=>Je,getCss:()=>Ht,observe:()=>jt,ready:()=>Wt,setClsxRoot:()=>Bt});module.exports=ft(Vt);var Be=e=>(e=e||new Map,{all:e,on(t,r){let s=e.get(t);s?s.push(r):e.set(t,[r])},off(t,r){let s=e.get(t);s&&(r?s.splice(s.indexOf(r)>>>0,1):e.set(t,[]))},emit(t,r){let s=e.get(t);s&&s.slice().forEach(d=>{d(r)});let o=e.get("*");o&&o.slice().forEach(d=>{d(t,r)})}});function pt(e,t,r){let s=0;for(let o=t;o<r;o++){let d=e.charCodeAt(o);if(d===91){s++;continue}if(d===93){s>0&&s--;continue}if(d===58&&s===0)return o}return-1}function yt(e,t,r){let s=0;for(let o=r-1;o>=t;o--){let d=e.charCodeAt(o);if(d===93){s++;continue}if(d===91){s>0&&s--;continue}if(d===64&&s===0)return o}return-1}function gt(e,t,r){let s=0;for(let o=t;o<r;o++){let d=e.charCodeAt(o);if(d===91){s++;continue}if(d===93){if(s===0)return!1;s--}}return s===0}function St(e){return e>=97&&e<=122}function ce(e){if(!e||e.length<2||!gt(e,0,e.length))return null;let t=0,r=e.length,s="",o=yt(e,t,r);o>t&&(s=e.substring(o+1,r),r=o);let d="",C="",g=pt(e,t,r);if(g>0&&g<r){let R=e.substring(t,g);t=g+1,d=R}let _=t;for(;_<r;){let R=e.charCodeAt(_);if(R>=48&&R<=57)_++;else break}if(_>t&&(C=e.substring(t,_),t=_),t>=r||e.charCodeAt(t)===38)return null;if(e.charCodeAt(t)===91){let R=e.indexOf("]",t);if(R>t)return{mq:d,layer:C,prop:e.substring(t,R+1),val:"",selector:s}}let E=t;for(;E<r;){let R=e.charCodeAt(E);if(R===45||R===46){if(E+1<r){let w=e.charCodeAt(E+1);if(R===45&&w===45&&E>t||w>=48&&w<=57)break}E++;continue}if(!St(R))break;E++}if(E===t)return null;let re=e.substring(t,E),B=e.substring(E,r);return{mq:d,layer:C,prop:re,val:B,selector:s}}var N="xcss_cache_v1",We=e=>{let t=typeof e?.styleId=="string"&&e.styleId.trim()?e.styleId.trim():"fwkui",r=typeof e?.version=="string"&&e.version.trim()?e.version.trim():"v1",s=e?.compression??!0,o=typeof e?.debounceMs=="number"&&e.debounceMs>=0?e.debounceMs:1e3;return{styleId:t,version:r,compression:s,debounceMs:o}},ht=e=>`${e.styleId}_cache_${e.version}`,Ue=e=>{if(!e||typeof e!="object")return!1;let t=e;return t.__xcss_cache_v===2&&t.compressed===!0&&typeof t.payload=="string"},ve=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"},Ve=()=>typeof CompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u",Ne=()=>typeof DecompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u",mt=e=>{if(typeof btoa=="function"){let r="";for(let o=0;o<e.length;o+=32768){let d=e.subarray(o,o+32768);for(let C=0;C<d.length;C++)r+=String.fromCharCode(d[C])}return btoa(r)}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")},Ct=e=>{if(typeof atob=="function"){let r=atob(e),s=new Uint8Array(r.length);for(let o=0;o<r.length;o++)s[o]=r.charCodeAt(o);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")},bt=async e=>{if(!Ve())throw new Error("XCSS: CompressionStream is not supported");let t=new Blob([e]).stream().pipeThrough(new CompressionStream("deflate-raw")),r=await new Response(t).arrayBuffer();return mt(new Uint8Array(r))},xt=async e=>{if(!Ne())throw new Error("XCSS: DecompressionStream is not supported");let t=Ct(e),r=new Uint8Array(t.length);r.set(t);let s=new Blob([r.buffer]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return await new Response(s).text()},wt=e=>{try{let t=JSON.parse(e);return ve(t)}catch{return!1}},vt=e=>{if(!e)return"";let t=new Map,r=[],s=256;for(let d=0;d<256;d++)t.set(String.fromCharCode(d),d);let o=e[0];for(let d=1;d<e.length;d++){let C=e[d],g=o+C;t.has(g)?o=g:(r.push(t.get(o)),t.set(g,s++),o=C)}return r.push(t.get(o)),r.map(d=>String.fromCharCode(d)).join("")},qe=e=>{if(!e)return"";let t=new Map,r=256,s="";for(let g=0;g<256;g++)t.set(g,String.fromCharCode(g));let o=e.split("").map(g=>g.charCodeAt(0)),d=o[0],C=t.get(d)||"";s=C;for(let g=1;g<o.length;g++){let _=o[g],E=t.get(_);E||(E=_===r?C+C[0]:""),s+=E,t.set(r++,C+E[0]),C=E}return s},Ee=e=>{if(!e||typeof e!="object")return null;let t=e,r=t.default&&typeof t.default=="object"?t.default:t,s=r.SHORT_PROPERTIES,o=r.COMMON_VALUES,d=r.SPECIFIC_VALUES;return!s||!o||!d||typeof s!="object"||typeof o!="object"||typeof d!="object"?null:{SHORT_PROPERTIES:s,COMMON_VALUES:o,SPECIFIC_VALUES:d}},Et=async e=>{let t=await import(e),r=Ee(t);if(!r)throw new Error(Fe);return r},Fe="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 r=e(t),s=Ee(r);if(s)return s}catch{}return null},Rt=async()=>{let e=Ze();if(e)return e;let t=["./dictionary.mjs","./dictionary.js","./dictionary"],r=null;for(let s of t)try{let o=await import(s),d=Ee(o);if(d)return d}catch(o){r=o}throw r||new Error(Fe)},Tt=(e,t)=>{if(!e||typeof document>"u")return;t=t||"fwkui";let r=Array.from({length:24},(s,o)=>"l"+o);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 o=`@layer ${r.join(", ")};`,d=setInterval(()=>{if(s.sheet){clearInterval(d);try{s.sheet.insertRule(o,s.sheet.cssRules.length)}catch{}}},10)}},_t=e=>{let t=Array.isArray(e.excludes)?e.excludes:Array.isArray(e.exclude)?e.exclude:[],r=We(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:r}),o=0;if(s.length===0)return o.toString();for(let d=0;d<s.length;d++){let C=s.charCodeAt(d);o=(o<<5)-o+C,o|=0}return o.toString()},we=e=>{if(!e)return null;try{let t=JSON.parse(e);if(Ue(t)){let r=qe(t.payload);return r?JSON.parse(r):null}return ve(t)?null:t}catch{return null}},At=async e=>{if(!e)return null;try{let t=JSON.parse(e);if(Ue(t)){let r=qe(t.payload);return r?JSON.parse(r):null}if(ve(t)){let r=await xt(t.payload);return r?JSON.parse(r):null}return t}catch{return null}},He=(e,t)=>{if(e==="root")return t;let r=/@media[^{]+\{\n?([\s\S]+)\n?\}/.exec(t);return r&&r[1]?r[1].trim():t},Re=(e={base:"",aliases:{},excludes:[],excludePrefixes:[],breakpoints:[],theme:{},prefix:"",dictionaryImport:!0,cache:{styleId:"fwkui",version:"v1",compression:!0,debounceMs:1e3}})=>{let{base:t=null,breakpoints:r=[],aliases:s={},theme:o={},excludes:d=[],exclude:C=[],excludePrefixes:g=[],prefix:_="",dictionaryImport:E=!0,cache:re={}}=e||{};Array.isArray(r)||(r=[]),Array.isArray(d)||(d=[]),Array.isArray(C)||(C=[]),Array.isArray(g)||(g=[]),(!s||typeof s!="object")&&(s={}),(!o||typeof o!="object")&&(o={});let B=We(re),R=ht(B),w=[...d,...C],X=g.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0),Y=n=>{let i=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+i.replace(/\*/g,".*")+"$")},le=w.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0).map(n=>{if(n.includes("*")){let i=Y(n);return l=>i.test(l)}return i=>i===n}),ke=n=>X.some(i=>n.startsWith(i))?!0:le.some(i=>i(n)),Oe=n=>!(ke(n)||_&&!n.startsWith(_)),ze=["default","xs","sm","md","lg","xl","2xl","sma","mda","lga","xla"],Ye=r.filter(n=>!!n&&typeof n=="object"&&!Array.isArray(n)).map(n=>Object.keys(n)[0]).filter(n=>typeof n=="string"&&n.length>0),Ge=new Set([...ze,...Ye]),de=n=>!n||Ge.has(n),Qe=E!==!1,et=new Set(["mx","my","px","py","bdx","bdy"]),ue=new Set,fe=n=>n?!Qe||!U||Object.keys(U).length===0?!0:!!U[n]||et.has(n)||ue.has(n):!1,U={},ne={},pe={},ye={},Xe=()=>{ye={...pe,...o}},q=n=>{if(!n){U={},ne={},pe={},ue=new Set,Xe();return}U=n.SHORT_PROPERTIES,ne=n.SPECIFIC_VALUES,pe=n.COMMON_VALUES,ue=new Set(Object.values(U)),Xe()},F=!0,se=Promise.resolve();if(E===!1)q(null);else if(typeof E=="string")F=!1,q(null),se=Et(E).then(n=>{q(n)}).catch(n=>{console.warn("XCSS: Failed to import dictionary from URL",n)}).finally(()=>{F=!0});else{let n=Ze();n?q(n):(F=!1,q(null),se=Rt().then(i=>{q(i)}).catch(i=>{console.warn("XCSS: Failed to load built-in dictionary module",i)}).finally(()=>{F=!0}))}let G=null,tt=(n=typeof document<"u"?document:void 0)=>{let i=typeof window<"u"&&typeof document<"u",l=null,h=Array.isArray(t)?t.length>0:!!t;n&&(l="getRootNode"in n?n.getRootNode():n);let p=new Map;i&&l&&Tt(l,B.styleId);let v=Be(),A=[{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)"},...r],y=A.filter((a,u)=>A.findLastIndex(c=>Object.keys(c)[0]==Object.keys(a)[0])==u),x=y.map(a=>Object.keys(a)[0]),f={},T={},m={root:""},$={root:[]},M={root:!1},Q=_t(e),Z=null,I=0,K=!1,k=null,J=null,H=[],L=a=>{try{window.localStorage.setItem(R,a)}catch(u){console.warn("XCSS: Failed to save cache",u)}},oe=(a,u)=>{!i||!window.localStorage||typeof u=="string"&&window.localStorage.getItem(a)!==u||window.localStorage.removeItem(a)},V=a=>{if(!i||!window.localStorage)return;G=a;let u=++I;try{let c=JSON.stringify(a),S=()=>{let b={__xcss_cache_v:2,compressed:!0,payload:vt(c)};L(JSON.stringify(b))};if(!B.compression){L(c);return}if(Ve()&&Ne()){bt(c).then(b=>{if(u!==I)return;L(JSON.stringify({__xcss_cache_v:3,compressed:!0,algorithm:"deflate-raw",encoding:"base64",payload:b}))}).catch(()=>{u===I&&S()});return}S()}catch(c){console.warn("XCSS: Failed to save cache",c)}},ie=()=>{i&&(Z&&clearTimeout(Z),Z=setTimeout(()=>{let a={};for(let S in f)a[S]=Array.from(f[S]);let u={};Object.keys(m).forEach(S=>{if(S==="root")u[S]=m[S];else{let b=A.find(P=>Object.keys(P)[0]===S)?.[S];b&&m[S]?u[S]=`@media ${b} {
|
|
2
|
+
${m[S]}
|
|
3
|
+
}`:u[S]=m[S]||""}});let c={configHash:Q,cssText:u,rulesSet:a,keys:Array.from(p.entries())};V(c)},B.debounceMs))};if(i&&window.localStorage)try{let a=R===N?[R]:[R,N];for(let u of a){let c=window.localStorage.getItem(u);if(!c)continue;let S=we(c);if(!S){if(wt(c)){H.push({key:u,raw:c});continue}window.localStorage.removeItem(u);continue}if(S.configHash!==Q){window.localStorage.removeItem(u);continue}k=S,J=u,K=!0;break}if(k){if(k.keys&&k.keys.forEach(([u,c])=>p.set(u,c)),k.cssText)for(let u in k.cssText){let c=k.cssText[u];m[u]=He(u,c)}G=k}}catch(a){console.error(a)}i&&(T.root=new CSSStyleSheet),x.forEach(a=>{if(f[a]=new Set,i){let u=y.find(c=>Object.keys(c)[0]==a)?.[a]||"";T[a]=new CSSStyleSheet({media:u})}K||(m[a]=""),$[a]=[],M[a]=!1});let D=()=>{if(!l)return;let a=l.querySelector(`style[id="${B.styleId}"]`);a&&a.remove()},ae=(a,u)=>{if(a.keys&&a.keys.forEach(([c,S])=>p.set(c,S)),a.cssText)for(let c in a.cssText){if(c==="root"&&h)continue;let S=He(c,a.cssText[c]);m[c]=S,i&&T[c]&&T[c].replaceSync(S)}if(a.rulesSet)for(let c in a.rulesSet)f[c]||(f[c]=new Set),a.rulesSet[c].forEach(S=>f[c].add(S));i&&window.localStorage&&u===N&&R!==N&&(V(a),window.localStorage.removeItem(N)),G=a,D()};K&&k&&ae(k,J),t&&Array.isArray(t)?(m.root=t.join(`
|
|
4
|
+
`),i&&T.root&&T.root.replaceSync(m.root)):(m.root=t||"",i&&T.root&&T.root.replaceSync(m.root)),i&&l&&["root",...x].forEach(a=>{T[a]&&l?.adoptedStyleSheets&&(l.adoptedStyleSheets.includes(T[a])||(l.adoptedStyleSheets=[...l.adoptedStyleSheets,T[a]]))}),i&&window.localStorage&&H.length>0&&(async()=>{for(let a of H){let u=await At(a.raw);if(!u){oe(a.key,a.raw);continue}if(u.configHash!==Q){oe(a.key,a.raw);continue}if(!K){K=!0,k=u,J=a.key,ae(u,a.key);break}}})();let he=(a,u)=>{let{media:c,property:S,selector:b,layer:P,className:O}=u,W=m,j=$,Ce=M;P=Number(P)||0;let Me=p.get(a),it=Me?`.${Me}${b}`:`.${O}${b}`;var be=`@layer l${P}{${it}{${S}}}`;f[c]||(f[c]=new Set);let Le=f[c];if(!Le.has(be))if(Le.add(be),j[c]||(j[c]=[]),j[c].push(be),i)Ce[c]||(Ce[c]=!0,queueMicrotask(()=>{let te=j[c],je=T[c];te.length>0&&(W[c]+=(W[c]?`
|
|
5
|
+
`:"")+te.join(`
|
|
6
|
+
`),je&&je.replaceSync(W[c]),j[c]=[],ie()),Ce[c]=!1}));else{let te=j[c];te.length>0&&(W[c]+=(W[c]?`
|
|
7
|
+
`:"")+te.join(`
|
|
8
|
+
`),j[c]=[])}},me=a=>{a.forEach(u=>{let c=Ke(u);c&&he(u,c)})},ee=a=>{if(a.length===0)return;let u=()=>me(a);F?u():se.then(u)};return v.on("observeDom",ee),{clsx:(...a)=>{let u=a.map(b=>Array.isArray(b)?b:[b]).flat(1/0).map(b=>typeof b=="string"?b.split(/(\s|\t)+/g):[]).flat(1/0);u=u.filter(b=>typeof b=="string"&&b.trim()),u=[...new Set(u)];let c=b=>{if(!Oe(b))return!1;if(F)return!!Ke(b);let P=_?b.slice(_.length):b,O=ce(P);if(!O||!de(O.mq))return!1;let W=(O.selector||"").replace(/(';|;)/g,j=>j=="';"?";":" ");return W&&!ge(W)?!1:O.prop.startsWith("[")?!!Pe(O.prop+O.val):fe(O.prop)?(O.prop==="&",O.val.length>0):!1},S=u.map(b=>{let P=b;if(p.has(b))P=p.get(b);else if(c(b)){let O="D"+p.size.toString(32).toUpperCase();p.set(b,O),P=O,ie()}return P});return i?queueMicrotask(()=>v.emit("observeDom",u)):v.emit("observeDom",u),S.join(" ")},observe:()=>{!i||!l||ot(l,a=>{ee(a)})},getCssString:()=>Object.entries(m).map(([a,u])=>{if(!u)return"";if(a==="root"||a==="default")return u;let c=A.find(S=>Object.keys(S)[0]===a)?.[a];return c?`@media ${c} {
|
|
9
|
+
${u}
|
|
10
|
+
}`:u}).join(`
|
|
11
|
+
`)}};function Pe(n){let i=new RegExp("^(\\[(?<p>[a-zA-Z]+)\\])$"),{p:l=""}=i.exec(n)?.groups??{};if(l&&s[l]&&Array.isArray(s[l])){let h=s[l],p=[],v=!0,A=y=>{let x=y.trim();if(!x)return null;let f=x.endsWith(";")?x.slice(0,-1).trim():x,T=f.indexOf(":");if(T<=0||T>=f.length-1)return null;let m=f.slice(0,T).trim(),$=f.slice(T+1).trim();return!m||!$||!/^(?:--[a-zA-Z0-9-_]+|-?[a-zA-Z][a-zA-Z0-9-]*)$/.test(m)?null:`${m}:${$}`};for(let y of h){if(typeof y!="string"){v=!1;break}let x=A(y);if(x){if(typeof CSS<"u"&&!CSS.supports(x)){v=!1;break}p.push(x);continue}v=!1;break}if(p.length>0&&v)return p.join(";")}return null}function $e(n,i){let l=Pe(n+i);if(l)return l;if(!n||i===void 0)return null;let h=U[n],p=h||n,v=i[0],A=!1,y=i;if(v==="!"&&(A=!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 m=y[0].toLowerCase()+y.substring(1),$=ne[n]?.[m]||ye[m];if(!$){let M=y.toLowerCase();$=ne[n]?.[M]||ye[M]}y=$||y}if(y=y.replace(/(';|;)/g,m=>m=="';"?";":" "),!y)return null;let x=y+(A?" !important":""),f=[p+":"+x];switch(p){case"mx":f=[`margin-left:${x}`,`margin-right:${x}`];break;case"my":f=[`margin-top:${x}`,`margin-bottom:${x}`];break;case"px":f=[`padding-left:${x}`,`padding-right:${x}`];break;case"py":f=[`padding-top:${x}`,`padding-bottom:${x}`];break;case"bdx":f=[`border-left:${x}`,`border-right:${x}`];break;case"bdy":f=[`border-top:${x}`,`border-bottom:${x}`];break}return!(typeof CSS<"u")||f.every(m=>CSS.supports(m))?f.join(";"):null}let rt=n=>{let i=0;for(let l=n.length-1;l>=0;l--){let h=n[l];if(h==="]"){i++;continue}if(h==="["){i>0&&i--;continue}if(h==="@"&&i===0)return{body:n.slice(0,l),selector:n.slice(l+1)}}return{body:n,selector:""}},nt=n=>{let i=[],l=0,h=0;for(let p=0;p<n.length;p++){let v=n[p];if(v==="["){h++;continue}if(v==="]"){h>0&&h--;continue}v==="&"&&h===0&&(i.push(n.slice(l,p)),l=p+1)}return i.push(n.slice(l)),i},ge=n=>{if(!n)return!0;let i=n.trim();if(!i)return!0;if(/[{}]/.test(i)||i==="#"||i==="("||i===")"||i===","||i===">"||i==="+"||i==="~"||i.startsWith("(")||i.startsWith(")"))return!1;let l=0;for(let h=0;h<i.length;h++){let p=i[h];if(p==="("){l++;continue}if(p===")"){if(l===0)return!1;l--}}return l===0};function Ke(n){if(!Oe(n))return null;let i=_?n.slice(_.length):n,l=typeof CSS<"u"?CSS.escape(n):st(n);if(i.includes("&")&&!i.startsWith("&")){let{body:M,selector:Q}=rt(i),Z=nt(M).map(I=>I.trim()).filter(I=>I.length>0).map(I=>_&&I.startsWith(_)?I.slice(_.length):I);if(Z.length>1){let I="",K="",k=Q,J=!1,H=[];for(let V of Z){let ie=k?`${V}@${k}`:V,D=ce(ie);if(!D||!de(D.mq)||!D.prop.startsWith("[")&&!fe(D.prop))return null;J?(!D.mq&&I&&(D.mq=I),!D.layer&&K&&(D.layer=K)):(I=D.mq||"",K=D.layer||"",J=!0);let ae=D.mq||"",he=D.layer||"",me=D.selector||"";if(ae!==I||he!==K||me!==k)return null;let ee=$e(D.prop,D.val);if(!ee)return null;H.push(ee)}if(H.length===0)return null;let L=k.replace(/(';|;)/g,V=>V=="';"?";":" "),oe=`selector(${l}${L})`;if(L){if(typeof CSS<"u"){if(!CSS.supports(oe))return null}else if(!ge(L))return null}return{media:I||"default",layer:K||"0",className:l,property:H.join(";"),selector:L,cssRules:`.${l}${L}{${H.join(";")}}`}}}let h=ce(i);if(!h||!de(h.mq)||!h.prop.startsWith("[")&&!fe(h.prop))return null;let{mq:p="default",layer:v="0",prop:A,val:y,selector:x=""}=h,f=[],T=$e(A,y);if(T&&f.push(T),f.length===0)return null;let m=x.replace(/(';|;)/g,M=>M=="';"?";":" "),$=`selector(${l}${m})`;if(m){if(typeof CSS<"u"){if(!CSS.supports($))return null}else if(!ge(m))return null}return{media:p||"default",layer:v||"0",className:l,property:f.join(";"),selector:m,cssRules:`.${l}${m}{${f.join(";")}}`}}let st=n=>n.replace(/([^\w-])/g,"\\$1"),Se=n=>{var i=[...n?.classList||[]].filter(l=>{if(l){let h=l.charCodeAt(0)==45?l.charCodeAt(1):l.charCodeAt(0);return h>=97&&h<=122||h>=48&&h<=57}return!1});return n?.children?.length>0&&Array.from(n?.children).forEach(l=>{i.push(...Se(l))}),i.flat(1/0)},ot=(n,i)=>{if(typeof i!="function")throw new Error("Callback is not a function");if(!n)return;let l;"documentElement"in n?l=n.documentElement:(n instanceof Element||"tagName"in n||"host"in n)&&(l=n),l&&(l instanceof Element&&i(Se(l)),typeof MutationObserver<"u"&&new MutationObserver(h=>{for(let p of h)if(p.type=="attributes"&&p.attributeName=="class"){if(p.target.nodeType==1){let v=String(p.target?.className??""),A=String(p?.oldValue??"");if(v||A){let y=v.split(" ").map(f=>f.trim()).filter(f=>f),x=A.split(" ").map(f=>f.trim()).filter(f=>f);y=y.filter(f=>!x.includes(f)),typeof i=="function"&&i([...new Set(y)])}}}else if(p.type=="childList"&&p.addedNodes.length>0){let v=[...p.addedNodes].filter(A=>A.nodeType==1).map(A=>Se(A)).flat(1/0);typeof i=="function"&&i([...new Set(v)])}}).observe(l,{attributes:!0,attributeOldValue:!0,attributeFilter:["class"],childList:!0,subtree:!0}))};return{buildCss:tt,exportCache:()=>{if(typeof window>"u"||!window.localStorage)return G;let n=we(window.localStorage.getItem(R));if(n)return n;if(R!==N){let i=we(window.localStorage.getItem(N));if(i)return i}return G},ready:se}},It=(e,t)=>{Re(t).buildCss(e).observe()},Dt=(e,t)=>Re(t).buildCss(e).clsx,Te={css:Re,cssObserve:It,clsx:Dt};var kt="xcss_cache_v1",Ot=(e,t)=>{let r=String(t||"").trim();return r?r===kt||r.includes("_cache_")?r:`${e}_cache_${r}`:`${e}_cache_v1`},Je=(e="fwkui",t="v1",r)=>{let s=String(e||"").trim()||"fwkui",o=Ot(s,t),d=JSON.stringify(s),C=JSON.stringify(o),g=`
|
|
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 = ${d};
|
|
97
|
+
var primaryKey = ${C};
|
|
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 r?.compact?g.replace(/\s+/g," ").trim():g};var _e="__FWXCSS_SHARED__",Xt={base:"html,body{font-size:16px;padding:0;margin:0;}"},Pt=e=>{if(!e)return!1;let t=typeof Document<"u",r=typeof ShadowRoot<"u",s=t&&e instanceof Document,o=r&&e instanceof ShadowRoot;return s||o},$t=e=>{let t=[],r=s=>{if(s){if(typeof s=="string"||typeof s=="number"){t.push(String(s));return}if(Array.isArray(s)){s.forEach(r);return}typeof s=="object"&&Object.keys(s).forEach(o=>{s[o]&&t.push(o)})}};return e.forEach(r),t},Ie=e=>{let t=new WeakMap,r=null,s=e??Xt,o=typeof document<"u"?document:null,d=w=>{let X=Te.css(s);return{...X.buildCss(w??void 0),ready:X.ready}},C=()=>(r||(r=d(null)),r),g=w=>{if(!w)return C();let X=t.get(w);return X||(X=d(w),t.set(w,X)),X};return{clsx:(...w)=>{let X,Y=w[w.length-1];Pt(Y)&&(X=Y,w=w.slice(0,-1));let le=$t(w);return g(X||o).clsx(le.join(" "))},observe:w=>{g(w||o).observe()},setClsxRoot:w=>{o=w||(typeof document<"u"?document:null)},getCss:w=>w?g(w).getCssString():o?g(o).getCssString():C().getCssString(),ready:w=>w?g(w).ready:o?g(o).ready:C().ready}},Kt=e=>Ie(e),Mt=e=>Ie(e),Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:global,z=Ae[_e]||Ie();Ae[_e]||(Ae[_e]=z);var Lt=z.clsx,jt=z.observe,Bt=z.setClsxRoot,Ht=z.getCss,Wt=z.ready;var De=Te;typeof document<"u"&&(De.cssObserve(document),console.log("\u{1F680} fwxcss Auto-Observer Activated"));var Ut=De;0&&(module.exports={clsx,createSharedClsx,createSharedInstance,getBootloaderScript,getCss,observe,ready,setClsxRoot});
|
|
12
131
|
//# sourceMappingURL=index-auto.js.map
|