@react-hive/honey-css 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -0
- package/dist/README.md +112 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.dev.cjs +259 -0
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/parse-css-declaration.d.ts +46 -0
- package/dist/resolve-css-selector.d.ts +55 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -270,6 +270,118 @@ console.log(keyOrSelector); // ".btn"
|
|
|
270
270
|
|
|
271
271
|
This helper makes it easy to implement nested rule parsing without writing complex logic.
|
|
272
272
|
|
|
273
|
+
🧱 **parseCssDeclaration**
|
|
274
|
+
|
|
275
|
+
When building a custom parser on top of the token cursor, you often need to parse a single declaration inside a rule block.
|
|
276
|
+
|
|
277
|
+
The `parseCssDeclaration` handles this safely and consistently.
|
|
278
|
+
|
|
279
|
+
It:
|
|
280
|
+
- Expects the cursor to be positioned at the `:` token
|
|
281
|
+
- Reads the value until `;` or `}`
|
|
282
|
+
- Supports missing trailing semicolons
|
|
283
|
+
- Preserves strings and nested params like `var(...)` or `url(...)`
|
|
284
|
+
|
|
285
|
+
#### Example
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
import {
|
|
289
|
+
tokenizeCss,
|
|
290
|
+
createCssTokenCursor,
|
|
291
|
+
parseCssDeclaration,
|
|
292
|
+
} from "@react-hive/honey-css";
|
|
293
|
+
|
|
294
|
+
const tokens = tokenizeCss(`
|
|
295
|
+
color: var(--primary, red);
|
|
296
|
+
`);
|
|
297
|
+
|
|
298
|
+
const cursor = createCssTokenCursor(tokens);
|
|
299
|
+
|
|
300
|
+
// Read property name
|
|
301
|
+
const prop = cursor.readUntil(["colon"]);
|
|
302
|
+
|
|
303
|
+
// Parse declaration
|
|
304
|
+
const declaration = parseCssDeclaration(cursor, prop);
|
|
305
|
+
|
|
306
|
+
console.log(declaration);
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Output:
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
{
|
|
313
|
+
type: "declaration",
|
|
314
|
+
prop: "color",
|
|
315
|
+
value: "var(--primary, red)"
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
🧩 **resolveCssSelector**
|
|
320
|
+
|
|
321
|
+
When implementing nested rules (like in CSS-in-JS engines), child selectors must be resolved against their parent selector.
|
|
322
|
+
|
|
323
|
+
The `resolveCssSelector` helper performs this safely and predictably.
|
|
324
|
+
|
|
325
|
+
It:
|
|
326
|
+
|
|
327
|
+
- Performs full Cartesian expansion of comma-separated selector lists
|
|
328
|
+
- Replaces explicit parent references (`&`)
|
|
329
|
+
- Creates descendant relationships when `&` is not present
|
|
330
|
+
- Preserves complex selectors, including:
|
|
331
|
+
- Pseudo-classes (`:hover`)
|
|
332
|
+
- Pseudo-elements (`::before`)
|
|
333
|
+
- Attribute selectors (`[data-x="a,b"]`)
|
|
334
|
+
- Nested selector functions (`:is(...)`, `:not(...)`)
|
|
335
|
+
- Combinators (`>`, `+`, `~`)
|
|
336
|
+
|
|
337
|
+
#### Basic Example
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
import { resolveCssSelector } from "@react-hive/honey-css";
|
|
341
|
+
|
|
342
|
+
resolveCssSelector(".child", ".scope");
|
|
343
|
+
// → ".scope .child"
|
|
344
|
+
|
|
345
|
+
resolveCssSelector("&:hover", ".btn");
|
|
346
|
+
// → ".btn:hover"
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
#### Comma Expansion
|
|
350
|
+
|
|
351
|
+
Both parent and child selectors may contain comma-separated lists.
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
resolveCssSelector(".a, .b", ".scope");
|
|
355
|
+
// → ".scope .a, .scope .b"
|
|
356
|
+
|
|
357
|
+
resolveCssSelector(".x, .y", ".a, .b");
|
|
358
|
+
// → ".a .x, .a .y, .b .x, .b .y"
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Parent Reference (&)
|
|
362
|
+
|
|
363
|
+
If the child selector contains `&`, it is replaced with the parent selector.
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
resolveCssSelector("& + &", ".item");
|
|
367
|
+
// → ".item + .item"
|
|
368
|
+
|
|
369
|
+
resolveCssSelector("&:hover, .icon", ".btn, .card");
|
|
370
|
+
// → ".btn:hover, .btn .icon, .card:hover, .card .icon"
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### Complex Selectors
|
|
374
|
+
|
|
375
|
+
The resolver safely handles nested commas inside functions and attribute selectors.
|
|
376
|
+
|
|
377
|
+
```ts
|
|
378
|
+
resolveCssSelector(':is(.a, .b)', '.scope');
|
|
379
|
+
// → ".scope :is(.a, .b)"
|
|
380
|
+
|
|
381
|
+
resolveCssSelector('[data-x="a,b"]', '.scope');
|
|
382
|
+
// → ".scope [data-x=\"a,b\"]"
|
|
383
|
+
```
|
|
384
|
+
|
|
273
385
|
---
|
|
274
386
|
|
|
275
387
|
## 🌳 AST Overview
|
package/dist/README.md
CHANGED
|
@@ -270,6 +270,118 @@ console.log(keyOrSelector); // ".btn"
|
|
|
270
270
|
|
|
271
271
|
This helper makes it easy to implement nested rule parsing without writing complex logic.
|
|
272
272
|
|
|
273
|
+
🧱 **parseCssDeclaration**
|
|
274
|
+
|
|
275
|
+
When building a custom parser on top of the token cursor, you often need to parse a single declaration inside a rule block.
|
|
276
|
+
|
|
277
|
+
The `parseCssDeclaration` handles this safely and consistently.
|
|
278
|
+
|
|
279
|
+
It:
|
|
280
|
+
- Expects the cursor to be positioned at the `:` token
|
|
281
|
+
- Reads the value until `;` or `}`
|
|
282
|
+
- Supports missing trailing semicolons
|
|
283
|
+
- Preserves strings and nested params like `var(...)` or `url(...)`
|
|
284
|
+
|
|
285
|
+
#### Example
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
import {
|
|
289
|
+
tokenizeCss,
|
|
290
|
+
createCssTokenCursor,
|
|
291
|
+
parseCssDeclaration,
|
|
292
|
+
} from "@react-hive/honey-css";
|
|
293
|
+
|
|
294
|
+
const tokens = tokenizeCss(`
|
|
295
|
+
color: var(--primary, red);
|
|
296
|
+
`);
|
|
297
|
+
|
|
298
|
+
const cursor = createCssTokenCursor(tokens);
|
|
299
|
+
|
|
300
|
+
// Read property name
|
|
301
|
+
const prop = cursor.readUntil(["colon"]);
|
|
302
|
+
|
|
303
|
+
// Parse declaration
|
|
304
|
+
const declaration = parseCssDeclaration(cursor, prop);
|
|
305
|
+
|
|
306
|
+
console.log(declaration);
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Output:
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
{
|
|
313
|
+
type: "declaration",
|
|
314
|
+
prop: "color",
|
|
315
|
+
value: "var(--primary, red)"
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
🧩 **resolveCssSelector**
|
|
320
|
+
|
|
321
|
+
When implementing nested rules (like in CSS-in-JS engines), child selectors must be resolved against their parent selector.
|
|
322
|
+
|
|
323
|
+
The `resolveCssSelector` helper performs this safely and predictably.
|
|
324
|
+
|
|
325
|
+
It:
|
|
326
|
+
|
|
327
|
+
- Performs full Cartesian expansion of comma-separated selector lists
|
|
328
|
+
- Replaces explicit parent references (`&`)
|
|
329
|
+
- Creates descendant relationships when `&` is not present
|
|
330
|
+
- Preserves complex selectors, including:
|
|
331
|
+
- Pseudo-classes (`:hover`)
|
|
332
|
+
- Pseudo-elements (`::before`)
|
|
333
|
+
- Attribute selectors (`[data-x="a,b"]`)
|
|
334
|
+
- Nested selector functions (`:is(...)`, `:not(...)`)
|
|
335
|
+
- Combinators (`>`, `+`, `~`)
|
|
336
|
+
|
|
337
|
+
#### Basic Example
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
import { resolveCssSelector } from "@react-hive/honey-css";
|
|
341
|
+
|
|
342
|
+
resolveCssSelector(".child", ".scope");
|
|
343
|
+
// → ".scope .child"
|
|
344
|
+
|
|
345
|
+
resolveCssSelector("&:hover", ".btn");
|
|
346
|
+
// → ".btn:hover"
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
#### Comma Expansion
|
|
350
|
+
|
|
351
|
+
Both parent and child selectors may contain comma-separated lists.
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
resolveCssSelector(".a, .b", ".scope");
|
|
355
|
+
// → ".scope .a, .scope .b"
|
|
356
|
+
|
|
357
|
+
resolveCssSelector(".x, .y", ".a, .b");
|
|
358
|
+
// → ".a .x, .a .y, .b .x, .b .y"
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Parent Reference (&)
|
|
362
|
+
|
|
363
|
+
If the child selector contains `&`, it is replaced with the parent selector.
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
resolveCssSelector("& + &", ".item");
|
|
367
|
+
// → ".item + .item"
|
|
368
|
+
|
|
369
|
+
resolveCssSelector("&:hover, .icon", ".btn, .card");
|
|
370
|
+
// → ".btn:hover, .btn .icon, .card:hover, .card .icon"
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### Complex Selectors
|
|
374
|
+
|
|
375
|
+
The resolver safely handles nested commas inside functions and attribute selectors.
|
|
376
|
+
|
|
377
|
+
```ts
|
|
378
|
+
resolveCssSelector(':is(.a, .b)', '.scope');
|
|
379
|
+
// → ".scope :is(.a, .b)"
|
|
380
|
+
|
|
381
|
+
resolveCssSelector('[data-x="a,b"]', '.scope');
|
|
382
|
+
// → ".scope [data-x=\"a,b\"]"
|
|
383
|
+
```
|
|
384
|
+
|
|
273
385
|
---
|
|
274
386
|
|
|
275
387
|
## 🌳 AST Overview
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{createCssTokenCursor:()=>s,readCssKeyOrSelector:()=>
|
|
1
|
+
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{createCssTokenCursor:()=>s,parseCssDeclaration:()=>a,readCssKeyOrSelector:()=>i,readCssSelector:()=>c,resolveCssSelector:()=>l,tokenizeCss:()=>n});const r=e=>"{"===e||"}"===e||":"===e||";"===e||"@"===e||"("===e||'"'===e||"'"===e||"/"===e,n=e=>{const t=[];let n=0;const o=()=>n>=e.length,s=()=>o()?void 0:e[n],c=()=>n+1>=e.length?void 0:e[n+1],i=()=>{for(;;){const e=s();if(!e||!/\s/.test(e))return;n++}},a=()=>{if("/"!==s()||"/"!==c())return!1;for(n+=2;!o();){if("\n"===s()){n++;break}n++}return!0},u=()=>{if("/"!==s()||"*"!==c())return!1;for(n+=2;!o();){if("*"===s()&&"/"===c())return n+=2,!0;n++}return!0},l=()=>{const e=s();if(!e)return"";n++;let t="";for(;!o();){const r=s();if(!r)break;if("\\"===r){t+=r,n++;const e=s();e&&(t+=e,n++);continue}if(r===e){n++;break}t+=r,n++}return t},p=()=>{let e=0,t="";for(;!o();){const r=s();if(!r)break;if("("===r&&e++,")"===r&&e--,t+=r,n++,0===e)break}return t},f=()=>{let e="";for(;!o();){const t=s();if(!t)break;if(r(t))break;e+=t,n++}return e.trim()};for(;!o()&&(i(),!o());){if(a()||u())continue;const e=s();if(!e)break;if("{"===e){t.push({type:"braceOpen"}),n++;continue}if("}"===e){t.push({type:"braceClose"}),n++;continue}if(":"===e){t.push({type:"colon"}),n++;continue}if(";"===e){t.push({type:"semicolon"}),n++;continue}if("@"===e){t.push({type:"at"}),n++;continue}if("("===e){t.push({type:"params",value:p()});continue}if('"'===e||"'"===e){t.push({type:"string",value:l()});continue}const r=f();r?t.push({type:"text",value:r}):n++}return t};function o(e,t){if(!e)throw new Error(t)}const s=e=>{let t=0;const r=()=>t>=e.length,n=()=>r()?void 0:e[t],s=()=>r()?void 0:e[t++];return{isEof:r,peek:n,next:s,mark:()=>t,reset:e=>{t=e},expect:e=>{const t=s();return o(t,`[@react-hive/honey-css]: Expected "${e}" but reached end of input.`),o(t.type===e,`[@react-hive/honey-css]: Expected "${e}" but got "${t.type}".`),t},readUntil:e=>{let t,o="";for(;!r();){const r=n();if(!r||e.includes(r.type))break;"text"===r.type?("text"===t&&o&&(o+=" "),o+=r.value):"string"===r.type?o+=`"${r.value}"`:"params"===r.type&&(o+=r.value),t=r.type,s()}return o.trim()},skipUntil:e=>{for(;!r();){const t=n();if(!t||e.includes(t.type))break;s()}}}},c=e=>{const t=[],r=()=>t.join("").trim();for(;!e.isEof();){const n=e.peek();if(!n)break;switch(n.type){case"braceOpen":case"braceClose":default:return r();case"colon":t.push(":");break;case"text":case"params":t.push(n.value);break;case"string":t.push(`"${n.value}"`)}e.next()}return r()},i=e=>{const t=e.peek();if(!t)return"";if("colon"===t.type)return c(e);const r=e.mark(),n=c(e);return"braceOpen"===e.peek()?.type?n:(e.reset(r),e.readUntil(["colon","braceOpen","semicolon","braceClose","at"]))},a=(e,t)=>{e.expect("colon");const r=e.readUntil(["semicolon","braceClose"]);return"semicolon"===e.peek()?.type&&e.next(),{type:"declaration",prop:t,value:r}},u=(e,t)=>{let r=0,n=0,o=0,s=null,c=!1;for(let i=0;i<e.length;i++){const a=e[i];if(c)c=!1;else if("\\"!==a)if(s)a===s&&(s=null);else if('"'!==a&&"'"!==a){switch(a){case"(":n++;break;case")":n--;break;case"[":o++;break;case"]":o--}if(","===a&&0===n&&0===o){const n=e.slice(r,i).trim();n&&t(n),r=i+1}}else s=a;else c=!0}const i=e.slice(r).trim();i&&t(i)},l=(e,t)=>{const r=e.trim();if(!r)return"";const n=t.trim();if(!n)return r;const o=[];return u(n,e=>{u(r,t=>{t.includes("&")?o.push(t.replaceAll("&",e)):o.push(`${e} ${t}`)})}),o.join(", ")};module.exports=t})();
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,mHCQvD,MAAMC,EAAkBC,GACf,MAAPA,GACO,MAAPA,GACO,MAAPA,GACO,MAAPA,GACO,MAAPA,GACO,MAAPA,GACO,MAAPA,GACO,MAAPA,GACO,MAAPA,EA+CWC,EAAeC,IAC1B,MAAMC,EAA0B,GAEhC,IAAIC,EAAQ,EAEZ,MAAMC,EAAQ,IAAeD,GAASF,EAAMI,OAKtCC,EAAO,IAA2BF,SAAUG,EAAYN,EAAME,GAK9DK,EAAW,IACfL,EAAQ,GA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AS,GAGb,MAAQX,KAAS,CACf,MAAM4B,EAAQ1B,IAEd,IAAK0B,GAASE,EAAUE,SAASJ,EAAMV,MACrC,MAGiB,SAAfU,EAAMV,MAES,SAAba,GAAuBpB,IACzBA,GAAU,KAGZA,GAAUiB,EAAMnC,OAEQ,WAAfmC,EAAMV,KACfP,GAAU,IAAIiB,EAAMnC,SAEI,WAAfmC,EAAMV,OACfP,GAAUiB,EAAMnC,OAGlBsC,EAAWH,EAAMV,KACjBM,GACF,CAEA,OAAOb,EAAOK,QAuBdiB,UApBiBH,IACjB,MAAQ9B,KAAS,CACf,MAAM4B,EAAQ1B,IAEd,IAAK0B,GAASE,EAAUE,SAASJ,EAAMV,MACrC,MAGFM,GACF,KCjKSU,EAAmBC,IAC9B,MAAMC,EAAkB,GAElBC,EAAS,IAAMD,EAAME,KAAK,IAAItB,OAEpC,MAAQmB,EAAOnC,SAAS,CACtB,MAAM4B,EAAQO,EAAOjC,OACrB,IAAK0B,EACH,MAGF,OAAQA,EAAMV,MACZ,IAAK,YACL,IAAK,aAgBL,QACE,OAAOmB,IAdT,IAAK,QACHD,EAAMnB,KAAK,KACX,MAEF,IAAK,OACL,IAAK,SACHmB,EAAMnB,KAAKW,EAAMnC,OACjB,MAEF,IAAK,SACH2C,EAAMnB,KAAK,IAAIW,EAAMnC,UAOzB0C,EAAOX,MACT,CAEA,OAAOa,KCFIE,EAAwBJ,IACnC,MAAMK,EAAQL,EAAOjC,OACrB,IAAKsC,EACH,MAAO,GAIT,GAAmB,UAAfA,EAAMtB,KACR,OAAOgB,EAAgBC,GAIzB,MAAMV,EAAOU,EAAOV,OACdgB,EAAYP,EAAgBC,GAGlC,MAA4B,cAAxBA,EAAOjC,QAAQgB,KACVuB,GAITN,EAAOT,MAAMD,GAENU,EAAON,UAAU,CAAC,QAAS,YAAa,YAAa,aAAc,S","sources":["webpack://@react-hive/honey-css/webpack/bootstrap","webpack://@react-hive/honey-css/webpack/runtime/define property getters","webpack://@react-hive/honey-css/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-css/webpack/runtime/make namespace object","webpack://@react-hive/honey-css/./src/tokenize-css.ts","webpack://@react-hive/honey-css/./node_modules/.pnpm/@react-hive+honey-utils@3.23.0/node_modules/@react-hive/honey-utils/dist/index.mjs","webpack://@react-hive/honey-css/./src/create-css-token-cursor.ts","webpack://@react-hive/honey-css/./src/read-css-selector.ts","webpack://@react-hive/honey-css/./src/read-css-key-or-selector.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { HoneyCssToken } from './types';\n\n/**\n * Determines whether a character should terminate a plain text read.\n *\n * These characters represent structural boundaries in CSS:\n * - Blocks: `{` `}`\n * - Declarations: `:` `;`\n * - At-rules: `@`\n * - Params: `(`\n * - Strings: `'` `\"`\n * - Comments: `/`\n */\nconst isBoundaryChar = (ch: string): boolean =>\n ch === '{' ||\n ch === '}' ||\n ch === ':' ||\n ch === ';' ||\n ch === '@' ||\n ch === '(' ||\n ch === '\"' ||\n ch === \"'\" ||\n ch === '/';\n\n/**\n * Tokenizes a CSS-like input string into a sequence of Honey CSS tokens.\n *\n * This function is the first stage of the Honey CSS compilation pipeline.\n * It performs a single-pass lexical scan and produces a flat stream of tokens\n * that can later be consumed by the recursive-descent parser.\n *\n * Unlike a strict CSS tokenizer, this implementation is intentional:\n *\n * - Lightweight (no external dependencies)\n * - Tolerant (fails safely on malformed input)\n * - Extended for CSS-in-JS use cases\n *\n * In addition to standard CSS constructs, it supports:\n *\n * - Custom at-rules (`@honey-media`, `@honey-stack`, etc.)\n * - Nested selectors (`&:hover`, `& > .child`)\n * - CSS variables (`--color: red`)\n * - JavaScript-style single-line comments (`// comment`)\n * - Multiline block comments (`/* comment *\\/`)\n * - Nested parentheses groups (`calc(...)`, `var(...)`)\n * - Escaped characters inside strings\n *\n * The tokenizer:\n *\n * - Skips all whitespace\n * - Skips both block (`/* *\\/`) and single-line (`//`) comments\n * - Preserves balanced parentheses as a single `params` token\n * - Preserves quoted strings as `string` tokens (without quotes)\n * - Emits structural tokens (`braceOpen`, `braceClose`, `colon`, `semicolon`, `at`)\n * - Emits all other text as trimmed `text` tokens\n *\n * Safety guarantees:\n *\n * - Unterminated comments do not crash tokenization\n * - Unterminated strings do not throw\n * - Infinite loops are prevented by fallback index advancement\n *\n * The returned token stream is order-preserving and does not perform\n * semantic validation. Structural correctness is handled by the parser stage.\n *\n * @param input - Raw CSS string to tokenize.\n *\n * @returns Ordered array of {@link HoneyCssToken} objects.\n */\nexport const tokenizeCss = (input: string): HoneyCssToken[] => {\n const tokens: HoneyCssToken[] = [];\n\n let index = 0;\n\n const isEof = (): boolean => index >= input.length;\n\n /**\n * Returns the current character without consuming it.\n */\n const peek = (): string | undefined => (isEof() ? undefined : input[index]);\n\n /**\n * Returns the next character without consuming it.\n */\n const peekNext = (): string | undefined =>\n index + 1 >= input.length ? undefined : input[index + 1];\n\n /**\n * Advances the cursor past any whitespace characters.\n */\n const skipWhitespace = () => {\n while (true) {\n const ch = peek();\n\n if (!ch || !/\\s/.test(ch)) {\n return;\n }\n\n index++;\n }\n };\n\n /**\n * Skips JavaScript-style single-line comments of the form:\n *\n * ```css\n * // comment text\n * ```\n *\n * This syntax is not part of standard CSS,\n * but is commonly used in CSS-in-JS template literals.\n *\n * The comment is skipped until a newline character (`\\n`)\n * or the end of input is reached.\n *\n * If the comment is unterminated (EOF without newline),\n * tokenization safely stops at the end of the input.\n *\n * @returns `true` if a single-line comment was detected and skipped,\n * otherwise `false`.\n */\n const skipSingleLineComment = (): boolean => {\n if (peek() !== '/' || peekNext() !== '/') {\n return false;\n }\n\n index += 2; // skip \"//\"\n\n while (!isEof()) {\n const ch = peek();\n\n if (ch === '\\n') {\n index++; // consume newline\n break;\n }\n\n index++;\n }\n\n return true;\n };\n\n /**\n * Skips CSS block comments of the form:\n *\n * ```css\n * /* comment *\\/\n * ```\n *\n * If the comment is unterminated, tokenization stops safely.\n *\n * @returns `true` if a comment was skipped.\n */\n const skipMultiLineComment = (): boolean => {\n if (peek() !== '/' || peekNext() !== '*') {\n return false;\n }\n\n index += 2; // skip \"/*\"\n\n while (!isEof()) {\n if (peek() === '*' && peekNext() === '/') {\n index += 2; // skip \"*/\"\n\n return true;\n }\n\n index++;\n }\n\n return true;\n };\n\n /**\n * Reads a quoted string token.\n *\n * Supports:\n * - Double quotes: `\"text\"`\n * - Single quotes: `'text'`\n * - Escaped characters: `\"a\\\\\\\"b\"`\n *\n * @returns The unwrapped string contents.\n */\n const readString = (): string => {\n const quote = peek();\n if (!quote) {\n return '';\n }\n\n index++; // skip opening quote\n let result = '';\n\n while (!isEof()) {\n const ch = peek();\n if (!ch) {\n break;\n }\n\n // Handle escape sequences\n if (ch === '\\\\') {\n result += ch;\n index++;\n\n const escaped = peek();\n if (escaped) {\n result += escaped;\n index++;\n }\n\n continue;\n }\n\n // Closing quote\n if (ch === quote) {\n index++;\n break;\n }\n\n result += ch;\n index++;\n }\n\n return result;\n };\n\n /**\n * Reads a balanced parentheses group.\n *\n * Examples:\n * - `(sm:down)`\n * - `(min-width: calc(100% - 1px))`\n *\n * Nested parentheses are supported.\n *\n * @returns The full params string including parentheses.\n */\n const readParamsGroup = (): string => {\n let depth = 0;\n let result = '';\n\n while (!isEof()) {\n const ch = peek();\n if (!ch) {\n break;\n }\n\n if (ch === '(') {\n depth++;\n }\n\n if (ch === ')') {\n depth--;\n }\n\n result += ch;\n index++;\n\n if (depth === 0) {\n break;\n }\n }\n\n return result;\n };\n\n /**\n * Reads a contiguous plain-text segment until a structural boundary\n * character is encountered.\n *\n * This function is responsible for collecting free-form CSS text such as:\n *\n * - Selectors (`.btn`, `&:hover`, `.parent > .child`)\n * - Property names (`color`, `border-bottom-width`)\n * - Values (`red`, `12px`, `100%`, `red!important`)\n *\n * Reading stops when a boundary character is reached.\n * Boundary characters represent structural syntax in CSS and include:\n *\n * - Block delimiters: `{` `}`\n * - Declaration delimiters: `:` `;`\n * - At-rule marker: `@`\n * - Parentheses start: `(`\n * - String delimiters: `'` `\"`\n * - Comment initiator: `/`\n *\n * The boundary character itself is NOT consumed here —\n * it is handled separately by the main tokenizer loop.\n *\n * The returned value is trimmed to remove leading/trailing whitespace,\n * ensuring clean token values without altering internal spacing.\n *\n * Safety:\n * - Stops at EOF safely\n * - Never throws\n * - Prevents infinite loops via boundary checks\n *\n * @returns Trimmed text segment, or an empty string if no text was read.\n */\n const readText = (): string => {\n let result = '';\n\n while (!isEof()) {\n const ch = peek();\n if (!ch) {\n break;\n }\n\n if (isBoundaryChar(ch)) {\n break;\n }\n\n result += ch;\n index++;\n }\n\n return result.trim();\n };\n\n // ============================\n // Main Token Loop\n // ============================\n while (!isEof()) {\n skipWhitespace();\n\n if (isEof()) {\n break;\n }\n\n if (skipSingleLineComment() || skipMultiLineComment()) {\n continue;\n }\n\n const ch = peek();\n if (!ch) {\n break;\n }\n\n if (ch === '{') {\n tokens.push({\n type: 'braceOpen',\n });\n\n index++;\n continue;\n }\n\n if (ch === '}') {\n tokens.push({\n type: 'braceClose',\n });\n\n index++;\n continue;\n }\n\n if (ch === ':') {\n tokens.push({\n type: 'colon',\n });\n\n index++;\n continue;\n }\n\n if (ch === ';') {\n tokens.push({\n type: 'semicolon',\n });\n\n index++;\n continue;\n }\n\n if (ch === '@') {\n tokens.push({\n type: 'at',\n });\n\n index++;\n continue;\n }\n\n // Params group\n if (ch === '(') {\n tokens.push({\n type: 'params',\n value: readParamsGroup(),\n });\n\n continue;\n }\n\n // Strings\n if (ch === '\"' || ch === \"'\") {\n tokens.push({\n type: 'string',\n value: readString(),\n });\n\n continue;\n }\n\n // Text chunk\n const value = readText();\n if (value) {\n tokens.push({\n type: 'text',\n value,\n });\n } else {\n // Safety fallback to prevent infinite loops\n index++;\n }\n }\n\n return tokens;\n};\n","const e=e=>new Blob([e],{type:e.type}),t=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),n=e=>\"A\"===e.tagName,r=e=>\"true\"===e.getAttribute(\"contenteditable\"),a=[\"INPUT\",\"SELECT\",\"TEXTAREA\",\"BUTTON\",\"A\"],l=e=>{if(!e)return!1;const t=window.getComputedStyle(e);if(\"hidden\"===t.visibility||\"none\"===t.display)return!1;if(\"disabled\"in e&&e.disabled)return!1;const l=e.getAttribute(\"tabindex\");return\"-1\"!==l&&(a.includes(e.tagName)?!n(e)||\"\"!==e.href:!!r(e)||null!==l)},i=e=>Array.from(e.querySelectorAll(\"*\")).filter(l),o=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=t??a?.parentElement;if(!a||!l)return;const o=i(l);if(0===o.length)return;const s=o.indexOf(a);if(-1===s)return;let c;r?c=r(s,e,o):\"next\"===e?(c=s+1,c>=o.length&&(c=n?0:null)):(c=s-1,c<0&&(c=n?o.length-1:null)),null!==c&&o[c]?.focus()};function s(e,t){if(!e)throw new Error(t)}const c=e=>null===e,u=e=>null==e,h=e=>null!=e,f=e=>void 0===e,d=e=>\"number\"==typeof e,m=e=>\"boolean\"==typeof e,p=e=>\"object\"==typeof e,g=e=>p(e)&&!c(e)&&0===Object.keys(e).length,y=e=>e instanceof Date,w=e=>e instanceof Blob,b=e=>e instanceof Error,x=e=>y(e)&&!isNaN(e.getTime()),M=e=>e instanceof RegExp,S=e=>e instanceof Map,A=e=>e instanceof Set,v=e=>\"symbol\"==typeof e,C=e=>d(e)&&isFinite(e),I=e=>d(e)&&Number.isInteger(e),k=e=>C(e)&&!Number.isInteger(e),E=e=>Array.isArray(e),L=e=>E(e)&&0===e.length,P=e=>e.filter(Boolean),O=e=>[...new Set(e)],T=(e,t)=>(s(t>0,\"Chunk size must be greater than 0\"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),X=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return O(t).filter(e=>n.every(t=>t.includes(e)))},_=(e,t)=>e.filter(e=>!t.includes(e)),z=(...e)=>t=>e.reduce((e,t)=>t(e),t),Y=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),R=()=>{},N=e=>\"function\"==typeof e,$=e=>(...t)=>!e(...t),F=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},j=e=>N(e?.then),U=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},W=async(e,t)=>Promise.all(e.map(t)),H=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const a=e[r];await t(a,r,e)&&n.push(a)}return n},B=async(e,t)=>{const n=await W(e,async(e,n,r)=>!!await t(e,n,r)&&e);return P(n)},D=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},V=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},Z=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},G=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},q=e=>new Promise(t=>setTimeout(t,e)),J=async(e,t,n=\"Operation timed out\")=>{try{return await Promise.race([e,q(t).then(()=>Promise.reject(new Error(n)))])}finally{}},K=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let i;for(let o=1;o<=t;o++)try{return await e(...l)}catch(e){if(i=e,o<t){a?.(o,e);const t=r?n*2**(o-1):n;await q(t)}}throw i},Q=e=>\"string\"==typeof e,ee=(e,{fileName:t,target:n}={})=>{if(f(document))return;const r=document.createElement(\"a\");let a=null;try{const l=Q(e)?e:a=URL.createObjectURL(e);r.href=l,t&&(r.download=t),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{s(a,\"Object URL should not be null\"),URL.revokeObjectURL(a)},0)}},te=e=>e.scrollWidth>e.clientWidth,ne=e=>Math.max(0,e.scrollWidth-e.clientWidth),re=e=>e.scrollHeight>e.clientHeight,ae=e=>Math.max(0,e.scrollHeight-e.clientHeight),le=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const a=n+r/2-t/2;return-Math.max(0,Math.min(a,e))},ie=(e,t,{axis:n=\"both\"}={})=>{let r=0,a=0;\"x\"!==n&&\"both\"!==n||(r=le({overflowSize:ne(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),\"y\"!==n&&\"both\"!==n||(a=le({overflowSize:ae(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${a}px)`},oe=e=>{const t=window.getComputedStyle(e).getPropertyValue(\"transform\").match(/^matrix\\((.+)\\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,a,l,i,o]=t[1].split(\", \").map(parseFloat);return{translateX:i,translateY:o,scaleX:n,scaleY:l,skewX:a,skewY:r}},se=()=>{if(\"undefined\"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem(\"__non_existing_key__\"),!0}catch{return!1}},ce=()=>{if(!se())return{readable:!1,writable:!1};try{const e=\"__test_write__\";return window.localStorage.setItem(e,\"1\"),window.localStorage.removeItem(e),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}},ue=e=>e instanceof File,he=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},fe=(e,t)=>new File([e],t,{type:e.type}),de=async(e,{skipFiles:t=[\".DS_Store\",\"Thumbs.db\",\"desktop.ini\",\"ehthumbs.db\",\".Spotlight-V100\",\".Trashes\",\".fseventsd\",\"__MACOSX\"]}={})=>{const n=new Set(t),r=await(async e=>{const t=e.createReader(),n=async()=>new Promise((e,r)=>{t.readEntries(async t=>{if(t.length)try{const r=await n();e([...t,...r])}catch(e){r(e)}else e([])},r)});return n()})(e);return(await W(r,async e=>e.isDirectory?de(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},me=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const a=n[e];if(\"webkitGetAsEntry\"in a){const e=a.webkitGetAsEntry?.();if(e?.isDirectory){r.push(de(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const l=a.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},pe=(e,...t)=>\"function\"==typeof e?e(...t):e,ge=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const a=t+e;return e<0?t<=n?null:Math.max(a,n):e>0?t>=r?null:Math.min(a,r):null},ye=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:a,friction:l=.002,minVelocityPxMs:i=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<i)return null;const s=ge({delta:r*a,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-l*a),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<i?null:{value:s,velocityPxMs:u}},we=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,be=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top))/(t.width*t.height),xe=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(t){case\"x\":return{deltaX:a*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case\"y\":return{deltaX:0,deltaY:a*e.deltaY};default:return{deltaX:a*e.deltaX,deltaY:a*e.deltaY}}},Me=(e,t,n,r)=>{const a=n-e,l=r-t;return Math.hypot(a,l)},Se=(e,t)=>Math.abs(e/t),Ae=(e,t)=>e*t/100,ve=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Ce=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Ie=e=>e.replace(/([a-z0-9])([A-Z])/g,\"$1-$2\").toLowerCase(),ke=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Ee=e=>e.replace(/([a-z0-9])([A-Z])/g,\"$1 $2\"),Le=e=>0===e.length?[]:e.split(\" \").filter(Boolean),Pe=e=>\"\"===e||u(e),Oe=e=>{const t=e.lastIndexOf(\".\");return t<=0||t===e.length-1?[e,\"\"]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},Te=(e,t)=>{if(0===e.length)return[];const n=t.charCodeAt(0),r=[];for(let t=0;t<e.length;t++)e.charCodeAt(t)===n&&r.push(t);return r},Xe=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let a=0;a<r;a++){const l=e[a],i={charIndex:a,prevChar:a>0?e[a-1]:null,nextChar:a<r-1?e[a+1]:null};n?.(l,i)||t(l,i)}},_e=(e,t=1/0)=>0===e.length?\"\":Le(e).slice(0,t).map(e=>e[0]).join(\"\").toUpperCase(),ze=(e,t,n,r=[],a=void 0,l=0)=>(e?.forEach(e=>{const{[n]:i,...o}=e,s=e[n],c=Array.isArray(s);if(r.push({...o,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=e[t];ze(s,t,n,r,a,l+1)}}),r),Ye=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),Re=(e,t,n,r)=>{const a=Le(r.toLowerCase());if(!a.length)return e;const l=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,i)=>{const o=i[n];if(!o)return r;if(r.some(e=>e[t]===i[t]))return r;const u=Le(o.toLowerCase());if(a.every(e=>u.some(t=>t.startsWith(e))))if(f(i.parentId)){r.push(i);const n=a=>{a.childCount&&e.forEach(e=>{e.parentId===a[t]&&(r.push(e),n(e))})};n(i)}else{const t=n=>{const a=l[n.parentId],i=e[a];f(i.parentId)||t(i);const o=r.length?r[r.length-1].parentId:null;(c(o)||o!==n.parentId)&&(s(i,\"[@react-hive/honey-utils]: Parent node was not found.\"),r.push(i))};t(i),r.push(i)}return r},[])};export{a as FOCUSABLE_HTML_TAGS,ye as applyInertiaStep,s as assert,fe as blobToFile,le as calculateCenterOffset,Me as calculateEuclideanDistance,Se as calculateMovingSpeed,Ae as calculatePercentage,ke as camelToDashCase,Ee as camelToWords,ie as centerElementInContainer,T as chunk,e as cloneBlob,P as compact,Y as compose,Ce as definedProps,q as delay,_ as difference,ee as downloadFile,V as everyAsync,he as fileListToFiles,B as filterParallel,H as filterSequential,G as findAsync,Te as findCharIndices,ze as flattenTree,Xe as forEachChar,we as generateEphemeralId,be as getDOMRectIntersectionRatio,t as getElementOffsetRect,i as getFocusableHtmlElements,ce as getLocalStorageCapabilities,Ye as getTreeChildren,_e as getWordsInitials,ne as getXOverflowWidth,ae as getYOverflowHeight,te as hasXOverflow,re as hasYOverflow,ve as hashString,X as intersection,pe as invokeIfFunction,n as isAnchorHtmlElement,E as isArray,w as isBlob,m as isBool,r as isContentEditableHtmlElement,y as isDate,k as isDecimal,h as isDefined,L as isEmptyArray,g as isEmptyObject,b as isError,ue as isFile,C as isFiniteNumber,N as isFunction,l as isHtmlElementFocusable,I as isInteger,se as isLocalStorageReadable,S as isMap,u as isNil,Pe as isNilOrEmptyString,c as isNull,d as isNumber,p as isObject,j as isPromise,M as isRegExp,A as isSet,Q as isString,v as isSymbol,f as isUndefined,x as isValidDate,o as moveFocusWithinContainer,R as noop,$ as not,F as once,oe as parse2DMatrix,Oe as parseFileName,z as pipe,me as readFilesFromDataTransfer,Z as reduceAsync,xe as resolveAxisDelta,ge as resolveBoundedDelta,K as retry,W as runParallel,U as runSequential,Re as searchTree,D as someAsync,Le as splitStringIntoWords,J as timeout,Ie as toKebabCase,de as traverseFileSystemDirectory,O as unique};\n//# sourceMappingURL=index.mjs.map","import { assert } from '@react-hive/honey-utils';\n\nimport type { HoneyCssToken, HoneyCssTokenType } from './types';\n\n/**\n * A lightweight cursor abstraction over a token stream.\n *\n * This is the core navigation primitive used by the Honey CSS parser.\n * It provides safe sequential reading, lookahead, backtracking,\n * and small helper utilities for collecting selector/value text.\n */\nexport interface HoneyTokenCursor {\n /**\n * Returns `true` when the cursor has consumed all tokens.\n */\n isEof: () => boolean;\n /**\n * Returns the current token without consuming it.\n *\n * This is primarily used for lookahead decisions in the parser:\n *\n * ```ts\n * if (cursor.peek()?.type === 'braceOpen') {\n * // parse rule block\n * }\n * ```\n */\n peek: () => HoneyCssToken | undefined;\n /**\n * Consumes and returns the current token, advancing the cursor forward.\n *\n * Returns `undefined` if the cursor is already at EOF.\n *\n * ```ts\n * const token = cursor.next();\n * ```\n */\n next: () => HoneyCssToken | undefined;\n /**\n * Creates a checkpoint of the current cursor position.\n *\n * Useful for speculative parsing or backtracking:\n *\n * ```ts\n * const mark = cursor.mark();\n *\n * if (!tryParseSomething(cursor)) {\n * cursor.reset(mark);\n * }\n * ```\n */\n mark: () => number;\n /**\n * Restores the cursor back to a previously created mark.\n *\n * @param mark - Index returned from {@link mark}.\n */\n reset: (mark: number) => void;\n /**\n * Consumes the next token and asserts that it matches the expected type.\n *\n * This is the parser's main safety mechanism and helps produce\n * clear error messages during invalid input.\n *\n * Throws if:\n * - the token stream ends unexpectedly\n * - the next token has a different type\n *\n * ```ts\n * cursor.expect('braceOpen'); // must be \"{\"\n * ```\n *\n * @param type - Expected token type.\n *\n * @returns The consumed token, narrowed to the expected type.\n */\n expect: <T extends HoneyCssTokenType>(type: T) => Extract<HoneyCssToken, { type: T }>;\n /**\n * Reads and concatenates consecutive token values until one of the stop token\n * types is encountered.\n *\n * This helper is used to collect:\n * - selectors (`.btn:hover`)\n * - declaration values (`calc(100% - 1px)`)\n * - at-rule names (`media`)\n *\n * Stops **before consuming** the stop token.\n *\n * Supported token types:\n * - `text` → appended as-is\n * - `string` → wrapped in quotes\n * - `params` → appended verbatim including parentheses\n *\n * Example:\n *\n * Tokens:\n * ```\n * text(\"var\")\n * params(\"(--color)\")\n * ```\n *\n * Result:\n * ```\n * \"var(--color)\"\n * ```\n *\n * @param stopTypes - Token types that terminate reading.\n *\n * @returns Combined string value.\n */\n readUntil: (stopTypes: HoneyCssTokenType[]) => string;\n /**\n * Advances the cursor until one of the stop token types is reached.\n *\n * This is useful for error recovery and safely skipping unknown syntax.\n *\n * Stops before consuming the stop token.\n *\n * @param stopTypes - Token types that terminate skipping.\n */\n skipUntil: (stopTypes: HoneyCssTokenType[]) => void;\n}\n\n/**\n * Creates a cursor wrapper around a list of CSS tokens.\n *\n * The cursor provides a small API surface for building\n * recursive-descent parsers without needing complex parser generators.\n *\n * @param tokens - Token list produced by the Honey tokenizer.\n *\n * @returns A reusable cursor instance.\n */\nexport const createCssTokenCursor = (tokens: HoneyCssToken[]): HoneyTokenCursor => {\n let index = 0;\n\n const isEof = (): boolean => index >= tokens.length;\n\n const peek = (): HoneyCssToken | undefined => (isEof() ? undefined : tokens[index]);\n\n const next = (): HoneyCssToken | undefined => (isEof() ? undefined : tokens[index++]);\n\n const mark = (): number => index;\n\n const reset = (mark: number): void => {\n index = mark;\n };\n\n const expect = <T extends HoneyCssTokenType>(type: T): Extract<HoneyCssToken, { type: T }> => {\n const token = next();\n\n assert(token, `[@react-hive/honey-css]: Expected \"${type}\" but reached end of input.`);\n assert(\n token.type === type,\n `[@react-hive/honey-css]: Expected \"${type}\" but got \"${token.type}\".`,\n );\n\n return token as Extract<HoneyCssToken, { type: T }>;\n };\n\n const readUntil = (stopTypes: HoneyCssTokenType[]): string => {\n let result = '';\n let prevType: HoneyCssTokenType | undefined;\n\n while (!isEof()) {\n const token = peek();\n\n if (!token || stopTypes.includes(token.type)) {\n break;\n }\n\n if (token.type === 'text') {\n // Only space-join consecutive text chunks\n if (prevType === 'text' && result) {\n result += ' ';\n }\n\n result += token.value;\n //\n } else if (token.type === 'string') {\n result += `\"${token.value}\"`;\n //\n } else if (token.type === 'params') {\n result += token.value;\n }\n\n prevType = token.type;\n next();\n }\n\n return result.trim();\n };\n\n const skipUntil = (stopTypes: HoneyCssTokenType[]): void => {\n while (!isEof()) {\n const token = peek();\n\n if (!token || stopTypes.includes(token.type)) {\n break;\n }\n\n next();\n }\n };\n\n return {\n isEof,\n peek,\n next,\n mark,\n reset,\n expect,\n readUntil,\n skipUntil,\n };\n};\n","import type { HoneyTokenCursor } from './create-css-token-cursor';\n\n/**\n * Reads a CSS selector from the current token cursor position.\n *\n * The selector is reconstructed by sequentially consuming supported tokens\n * until one of the following conditions is met:\n *\n * - A `braceOpen` token (`{`) is encountered\n * - A `braceClose` token (`}`) is encountered (safety stop)\n * - An unsupported token type appears\n * - The end of the token stream is reached\n *\n * Supported token types:\n *\n * - `text` - raw selector fragments such as:\n * `.btn`, `#id`, `> .child`, `+ .item`, `&[data-open]`, `[data-id=\"x\"]`\n *\n * - `colon` - pseudo selectors and pseudo-elements:\n * `:hover`, `::before`\n *\n * - `params` - parenthesized groups used in pseudo functions or nth-expressions:\n * `(2n+1)`, `(:disabled)`\n *\n * - `string` - quoted string values (typically inside attribute selectors)\n *\n * Behavior:\n *\n * - Preserves pseudo selectors and pseudo-elements\n * - Preserves combinators (`>`, `+`, `~`)\n * - Preserves attribute selectors\n * - Preserves pseudo functions such as `:not(...)`\n * - Does **not** consume the `{` token\n *\n * This function performs no validation of selector correctness.\n * It only reconstructs the textual representation from the token stream.\n *\n * @param cursor - Token cursor positioned at the beginning of a selector.\n *\n * @returns The reconstructed selector string (trimmed).\n */\nexport const readCssSelector = (cursor: HoneyTokenCursor): string => {\n const parts: string[] = [];\n\n const finish = () => parts.join('').trim();\n\n while (!cursor.isEof()) {\n const token = cursor.peek();\n if (!token) {\n break;\n }\n\n switch (token.type) {\n case 'braceOpen':\n case 'braceClose':\n return finish();\n\n case 'colon':\n parts.push(':');\n break;\n\n case 'text':\n case 'params':\n parts.push(token.value);\n break;\n\n case 'string':\n parts.push(`\"${token.value}\"`);\n break;\n\n default:\n return finish();\n }\n\n cursor.next();\n }\n\n return finish();\n};\n","import type { HoneyTokenCursor } from './create-css-token-cursor';\nimport { readCssSelector } from './read-css-selector';\n\n/**\n * Reads either a **CSS rule selector** or a **declaration property key**\n * from the current cursor position.\n *\n * This helper is used in ambiguous grammar positions where the next token\n * could represent either:\n *\n * - A nested rule:\n * ```css\n * selector { ... }\n * ```\n *\n * - A declaration:\n * ```css\n * property: value;\n * ```\n *\n * ---------------------------------------------------------------------------\n * 🧠 Resolution Strategy\n * ---------------------------------------------------------------------------\n *\n * 1. If the first token is a `colon`, it must be a selector starting with `:`\n * (e.g. `:root`, `:hover`, `::before`). In this case, it delegates directly\n * to {@link readCssSelector}.\n *\n * 2. Otherwise, it **speculatively parses** a selector using\n * {@link readCssSelector}.\n *\n * 3. The parsed selector is accepted **only if** it is immediately followed\n * by a `braceOpen` (`{`) token.\n *\n * 4. If no `{` follows, the cursor is rewound and the input is treated as\n * a declaration key instead.\n *\n * ---------------------------------------------------------------------------\n * ⚠️ Notes & Limitations\n * ---------------------------------------------------------------------------\n *\n * - Selector-like property names such as:\n *\n * ```css\n * a:hover: 1;\n * ```\n *\n * are intentionally treated as declaration keys ending at the first `:`.\n * In this example, the key will be parsed as `\"a\"`.\n *\n * - Declaration keys are read using\n * {@link HoneyTokenCursor.readUntil}, which:\n * - Inserts spaces only between consecutive `text` tokens\n * - Keeps `params` and `string` tokens adjacent without adding spaces\n *\n * ---------------------------------------------------------------------------\n * 🔁 Cursor Behavior\n * ---------------------------------------------------------------------------\n *\n * - When a selector is returned:\n * - The `{` token is **not consumed**\n * - The cursor will still point to `braceOpen`\n *\n * - When a declaration key is returned:\n * - The delimiter token (`colon`, `braceOpen`, `semicolon`,\n * `braceClose`, or `at`) is **not consumed**\n *\n * ---------------------------------------------------------------------------\n *\n * @param cursor - Token cursor positioned at the start of either a selector\n * or a declaration key.\n *\n * @returns The parsed selector or declaration key.\n * Returns an empty string if at EOF or if the first token is unsupported.\n */\nexport const readCssKeyOrSelector = (cursor: HoneyTokenCursor): string => {\n const first = cursor.peek();\n if (!first) {\n return '';\n }\n\n // Selector starting with \":\" (:root, :hover, ::before, etc.)\n if (first.type === 'colon') {\n return readCssSelector(cursor);\n }\n\n // Speculative selector parse\n const mark = cursor.mark();\n const candidate = readCssSelector(cursor);\n\n // A rule block must follow a real selector\n if (cursor.peek()?.type === 'braceOpen') {\n return candidate;\n }\n\n // Otherwise treat it as a declaration key\n cursor.reset(mark);\n\n return cursor.readUntil(['colon', 'braceOpen', 'semicolon', 'braceClose', 'at']);\n};\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","isBoundaryChar","ch","tokenizeCss","input","tokens","index","isEof","length","peek","undefined","peekNext","skipWhitespace","test","skipSingleLineComment","skipMultiLineComment","readString","quote","result","escaped","readParamsGroup","depth","readText","trim","push","type","s","e","t","Error","createCssTokenCursor","next","mark","reset","expect","token","readUntil","stopTypes","prevType","includes","skipUntil","readCssSelector","cursor","parts","finish","join","readCssKeyOrSelector","first","candidate"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OA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wD,MAAMR,GAAO7B,OAC5BsC,GACFV,EAASU,IA0DAC,EAAqB,CAACC,EAAkBC,KACnD,MAAMC,EAAgBF,EAASxC,OAC/B,IAAK0C,EACH,MAAO,GAGT,MAAMC,EAAiBF,EAAOzC,OAC9B,IAAK2C,EACH,OAAOD,EAGT,MAAM/C,EAAmB,GAYzB,OAVAgC,EAAwBgB,EAAgBC,IACtCjB,EAAwBe,EAAeG,IACjCA,EAAU7B,SAAS,KACrBrB,EAAOM,KAAK4C,EAAUC,WAAW,IAAKF,IAEtCjD,EAAOM,KAAK,GAAG2C,KAAcC,SAK5BlD,EAAO2B,KAAK,O","sources":["webpack://@react-hive/honey-css/webpack/bootstrap","webpack://@react-hive/honey-css/webpack/runtime/define property getters","webpack://@react-hive/honey-css/webpack/runtime/hasOwnProperty shorthand","webpack://@react-hive/honey-css/webpack/runtime/make namespace object","webpack://@react-hive/honey-css/./src/tokenize-css.ts","webpack://@react-hive/honey-css/./node_modules/.pnpm/@react-hive+honey-utils@3.23.0/node_modules/@react-hive/honey-utils/dist/index.mjs","webpack://@react-hive/honey-css/./src/create-css-token-cursor.ts","webpack://@react-hive/honey-css/./src/read-css-selector.ts","webpack://@react-hive/honey-css/./src/read-css-key-or-selector.ts","webpack://@react-hive/honey-css/./src/parse-css-declaration.ts","webpack://@react-hive/honey-css/./src/resolve-css-selector.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { HoneyCssToken } from './types';\n\n/**\n * Determines whether a character should terminate a plain text read.\n *\n * These characters represent structural boundaries in CSS:\n * - Blocks: `{` `}`\n * - Declarations: `:` `;`\n * - At-rules: `@`\n * - Params: `(`\n * - Strings: `'` `\"`\n * - Comments: `/`\n */\nconst isBoundaryChar = (ch: string): boolean =>\n ch === '{' ||\n ch === '}' ||\n ch === ':' ||\n ch === ';' ||\n ch === '@' ||\n ch === '(' ||\n ch === '\"' ||\n ch === \"'\" ||\n ch === '/';\n\n/**\n * Tokenizes a CSS-like input string into a sequence of Honey CSS tokens.\n *\n * This function is the first stage of the Honey CSS compilation pipeline.\n * It performs a single-pass lexical scan and produces a flat stream of tokens\n * that can later be consumed by the recursive-descent parser.\n *\n * Unlike a strict CSS tokenizer, this implementation is intentional:\n *\n * - Lightweight (no external dependencies)\n * - Tolerant (fails safely on malformed input)\n * - Extended for CSS-in-JS use cases\n *\n * In addition to standard CSS constructs, it supports:\n *\n * - Custom at-rules (`@honey-media`, `@honey-stack`, etc.)\n * - Nested selectors (`&:hover`, `& > .child`)\n * - CSS variables (`--color: red`)\n * - JavaScript-style single-line comments (`// comment`)\n * - Multiline block comments (`/* comment *\\/`)\n * - Nested parentheses groups (`calc(...)`, `var(...)`)\n * - Escaped characters inside strings\n *\n * The tokenizer:\n *\n * - Skips all whitespace\n * - Skips both block (`/* *\\/`) and single-line (`//`) comments\n * - Preserves balanced parentheses as a single `params` token\n * - Preserves quoted strings as `string` tokens (without quotes)\n * - Emits structural tokens (`braceOpen`, `braceClose`, `colon`, `semicolon`, `at`)\n * - Emits all other text as trimmed `text` tokens\n *\n * Safety guarantees:\n *\n * - Unterminated comments do not crash tokenization\n * - Unterminated strings do not throw\n * - Infinite loops are prevented by fallback index advancement\n *\n * The returned token stream is order-preserving and does not perform\n * semantic validation. Structural correctness is handled by the parser stage.\n *\n * @param input - Raw CSS string to tokenize.\n *\n * @returns Ordered array of {@link HoneyCssToken} objects.\n */\nexport const tokenizeCss = (input: string): HoneyCssToken[] => {\n const tokens: HoneyCssToken[] = [];\n\n let index = 0;\n\n const isEof = (): boolean => index >= input.length;\n\n /**\n * Returns the current character without consuming it.\n */\n const peek = (): string | undefined => (isEof() ? undefined : input[index]);\n\n /**\n * Returns the next character without consuming it.\n */\n const peekNext = (): string | undefined =>\n index + 1 >= input.length ? undefined : input[index + 1];\n\n /**\n * Advances the cursor past any whitespace characters.\n */\n const skipWhitespace = () => {\n while (true) {\n const ch = peek();\n\n if (!ch || !/\\s/.test(ch)) {\n return;\n }\n\n index++;\n }\n };\n\n /**\n * Skips JavaScript-style single-line comments of the form:\n *\n * ```css\n * // comment text\n * ```\n *\n * This syntax is not part of standard CSS,\n * but is commonly used in CSS-in-JS template literals.\n *\n * The comment is skipped until a newline character (`\\n`)\n * or the end of input is reached.\n *\n * If the comment is unterminated (EOF without newline),\n * tokenization safely stops at the end of the input.\n *\n * @returns `true` if a single-line comment was detected and skipped,\n * otherwise `false`.\n */\n const skipSingleLineComment = (): boolean => {\n if (peek() !== '/' || peekNext() !== '/') {\n return false;\n }\n\n index += 2; // skip \"//\"\n\n while (!isEof()) {\n const ch = peek();\n\n if (ch === '\\n') {\n index++; // consume newline\n break;\n }\n\n index++;\n }\n\n return true;\n };\n\n /**\n * Skips CSS block comments of the form:\n *\n * ```css\n * /* comment *\\/\n * ```\n *\n * If the comment is unterminated, tokenization stops safely.\n *\n * @returns `true` if a comment was skipped.\n */\n const skipMultiLineComment = (): boolean => {\n if (peek() !== '/' || peekNext() !== '*') {\n return false;\n }\n\n index += 2; // skip \"/*\"\n\n while (!isEof()) {\n if (peek() === '*' && peekNext() === '/') {\n index += 2; // skip \"*/\"\n\n return true;\n }\n\n index++;\n }\n\n return true;\n };\n\n /**\n * Reads a quoted string token.\n *\n * Supports:\n * - Double quotes: `\"text\"`\n * - Single quotes: `'text'`\n * - Escaped characters: `\"a\\\\\\\"b\"`\n *\n * @returns The unwrapped string contents.\n */\n const readString = (): string => {\n const quote = peek();\n if (!quote) {\n return '';\n }\n\n index++; // skip opening quote\n let result = '';\n\n while (!isEof()) {\n const ch = peek();\n if (!ch) {\n break;\n }\n\n // Handle escape sequences\n if (ch === '\\\\') {\n result += ch;\n index++;\n\n const escaped = peek();\n if (escaped) {\n result += escaped;\n index++;\n }\n\n continue;\n }\n\n // Closing quote\n if (ch === quote) {\n index++;\n break;\n }\n\n result += ch;\n index++;\n }\n\n return result;\n };\n\n /**\n * Reads a balanced parentheses group.\n *\n * Examples:\n * - `(sm:down)`\n * - `(min-width: calc(100% - 1px))`\n *\n * Nested parentheses are supported.\n *\n * @returns The full params string including parentheses.\n */\n const readParamsGroup = (): string => {\n let depth = 0;\n let result = '';\n\n while (!isEof()) {\n const ch = peek();\n if (!ch) {\n break;\n }\n\n if (ch === '(') {\n depth++;\n }\n\n if (ch === ')') {\n depth--;\n }\n\n result += ch;\n index++;\n\n if (depth === 0) {\n break;\n }\n }\n\n return result;\n };\n\n /**\n * Reads a contiguous plain-text segment until a structural boundary\n * character is encountered.\n *\n * This function is responsible for collecting free-form CSS text such as:\n *\n * - Selectors (`.btn`, `&:hover`, `.parent > .child`)\n * - Property names (`color`, `border-bottom-width`)\n * - Values (`red`, `12px`, `100%`, `red!important`)\n *\n * Reading stops when a boundary character is reached.\n * Boundary characters represent structural syntax in CSS and include:\n *\n * - Block delimiters: `{` `}`\n * - Declaration delimiters: `:` `;`\n * - At-rule marker: `@`\n * - Parentheses start: `(`\n * - String delimiters: `'` `\"`\n * - Comment initiator: `/`\n *\n * The boundary character itself is NOT consumed here —\n * it is handled separately by the main tokenizer loop.\n *\n * The returned value is trimmed to remove leading/trailing whitespace,\n * ensuring clean token values without altering internal spacing.\n *\n * Safety:\n * - Stops at EOF safely\n * - Never throws\n * - Prevents infinite loops via boundary checks\n *\n * @returns Trimmed text segment, or an empty string if no text was read.\n */\n const readText = (): string => {\n let result = '';\n\n while (!isEof()) {\n const ch = peek();\n if (!ch) {\n break;\n }\n\n if (isBoundaryChar(ch)) {\n break;\n }\n\n result += ch;\n index++;\n }\n\n return result.trim();\n };\n\n // ============================\n // Main Token Loop\n // ============================\n while (!isEof()) {\n skipWhitespace();\n\n if (isEof()) {\n break;\n }\n\n if (skipSingleLineComment() || skipMultiLineComment()) {\n continue;\n }\n\n const ch = peek();\n if (!ch) {\n break;\n }\n\n if (ch === '{') {\n tokens.push({\n type: 'braceOpen',\n });\n\n index++;\n continue;\n }\n\n if (ch === '}') {\n tokens.push({\n type: 'braceClose',\n });\n\n index++;\n continue;\n }\n\n if (ch === ':') {\n tokens.push({\n type: 'colon',\n });\n\n index++;\n continue;\n }\n\n if (ch === ';') {\n tokens.push({\n type: 'semicolon',\n });\n\n index++;\n continue;\n }\n\n if (ch === '@') {\n tokens.push({\n type: 'at',\n });\n\n index++;\n continue;\n }\n\n // Params group\n if (ch === '(') {\n tokens.push({\n type: 'params',\n value: readParamsGroup(),\n });\n\n continue;\n }\n\n // Strings\n if (ch === '\"' || ch === \"'\") {\n tokens.push({\n type: 'string',\n value: readString(),\n });\n\n continue;\n }\n\n // Text chunk\n const value = readText();\n if (value) {\n tokens.push({\n type: 'text',\n value,\n });\n } else {\n // Safety fallback to prevent infinite loops\n index++;\n }\n }\n\n return tokens;\n};\n","const e=e=>new Blob([e],{type:e.type}),t=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),n=e=>\"A\"===e.tagName,r=e=>\"true\"===e.getAttribute(\"contenteditable\"),a=[\"INPUT\",\"SELECT\",\"TEXTAREA\",\"BUTTON\",\"A\"],l=e=>{if(!e)return!1;const t=window.getComputedStyle(e);if(\"hidden\"===t.visibility||\"none\"===t.display)return!1;if(\"disabled\"in e&&e.disabled)return!1;const l=e.getAttribute(\"tabindex\");return\"-1\"!==l&&(a.includes(e.tagName)?!n(e)||\"\"!==e.href:!!r(e)||null!==l)},i=e=>Array.from(e.querySelectorAll(\"*\")).filter(l),o=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=t??a?.parentElement;if(!a||!l)return;const o=i(l);if(0===o.length)return;const s=o.indexOf(a);if(-1===s)return;let c;r?c=r(s,e,o):\"next\"===e?(c=s+1,c>=o.length&&(c=n?0:null)):(c=s-1,c<0&&(c=n?o.length-1:null)),null!==c&&o[c]?.focus()};function s(e,t){if(!e)throw new Error(t)}const c=e=>null===e,u=e=>null==e,h=e=>null!=e,f=e=>void 0===e,d=e=>\"number\"==typeof e,m=e=>\"boolean\"==typeof e,p=e=>\"object\"==typeof e,g=e=>p(e)&&!c(e)&&0===Object.keys(e).length,y=e=>e instanceof Date,w=e=>e instanceof Blob,b=e=>e instanceof Error,x=e=>y(e)&&!isNaN(e.getTime()),M=e=>e instanceof RegExp,S=e=>e instanceof Map,A=e=>e instanceof Set,v=e=>\"symbol\"==typeof e,C=e=>d(e)&&isFinite(e),I=e=>d(e)&&Number.isInteger(e),k=e=>C(e)&&!Number.isInteger(e),E=e=>Array.isArray(e),L=e=>E(e)&&0===e.length,P=e=>e.filter(Boolean),O=e=>[...new Set(e)],T=(e,t)=>(s(t>0,\"Chunk size must be greater than 0\"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),X=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return O(t).filter(e=>n.every(t=>t.includes(e)))},_=(e,t)=>e.filter(e=>!t.includes(e)),z=(...e)=>t=>e.reduce((e,t)=>t(e),t),Y=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),R=()=>{},N=e=>\"function\"==typeof e,$=e=>(...t)=>!e(...t),F=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},j=e=>N(e?.then),U=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},W=async(e,t)=>Promise.all(e.map(t)),H=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const a=e[r];await t(a,r,e)&&n.push(a)}return n},B=async(e,t)=>{const n=await W(e,async(e,n,r)=>!!await t(e,n,r)&&e);return P(n)},D=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},V=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},Z=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},G=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},q=e=>new Promise(t=>setTimeout(t,e)),J=async(e,t,n=\"Operation timed out\")=>{try{return await Promise.race([e,q(t).then(()=>Promise.reject(new Error(n)))])}finally{}},K=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let i;for(let o=1;o<=t;o++)try{return await e(...l)}catch(e){if(i=e,o<t){a?.(o,e);const t=r?n*2**(o-1):n;await q(t)}}throw i},Q=e=>\"string\"==typeof e,ee=(e,{fileName:t,target:n}={})=>{if(f(document))return;const r=document.createElement(\"a\");let a=null;try{const l=Q(e)?e:a=URL.createObjectURL(e);r.href=l,t&&(r.download=t),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{s(a,\"Object URL should not be null\"),URL.revokeObjectURL(a)},0)}},te=e=>e.scrollWidth>e.clientWidth,ne=e=>Math.max(0,e.scrollWidth-e.clientWidth),re=e=>e.scrollHeight>e.clientHeight,ae=e=>Math.max(0,e.scrollHeight-e.clientHeight),le=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const a=n+r/2-t/2;return-Math.max(0,Math.min(a,e))},ie=(e,t,{axis:n=\"both\"}={})=>{let r=0,a=0;\"x\"!==n&&\"both\"!==n||(r=le({overflowSize:ne(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),\"y\"!==n&&\"both\"!==n||(a=le({overflowSize:ae(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${a}px)`},oe=e=>{const t=window.getComputedStyle(e).getPropertyValue(\"transform\").match(/^matrix\\((.+)\\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,a,l,i,o]=t[1].split(\", \").map(parseFloat);return{translateX:i,translateY:o,scaleX:n,scaleY:l,skewX:a,skewY:r}},se=()=>{if(\"undefined\"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem(\"__non_existing_key__\"),!0}catch{return!1}},ce=()=>{if(!se())return{readable:!1,writable:!1};try{const e=\"__test_write__\";return window.localStorage.setItem(e,\"1\"),window.localStorage.removeItem(e),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}},ue=e=>e instanceof File,he=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},fe=(e,t)=>new File([e],t,{type:e.type}),de=async(e,{skipFiles:t=[\".DS_Store\",\"Thumbs.db\",\"desktop.ini\",\"ehthumbs.db\",\".Spotlight-V100\",\".Trashes\",\".fseventsd\",\"__MACOSX\"]}={})=>{const n=new Set(t),r=await(async e=>{const t=e.createReader(),n=async()=>new Promise((e,r)=>{t.readEntries(async t=>{if(t.length)try{const r=await n();e([...t,...r])}catch(e){r(e)}else e([])},r)});return n()})(e);return(await W(r,async e=>e.isDirectory?de(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},me=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const a=n[e];if(\"webkitGetAsEntry\"in a){const e=a.webkitGetAsEntry?.();if(e?.isDirectory){r.push(de(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const l=a.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},pe=(e,...t)=>\"function\"==typeof e?e(...t):e,ge=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const a=t+e;return e<0?t<=n?null:Math.max(a,n):e>0?t>=r?null:Math.min(a,r):null},ye=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:a,friction:l=.002,minVelocityPxMs:i=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<i)return null;const s=ge({delta:r*a,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-l*a),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<i?null:{value:s,velocityPxMs:u}},we=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,be=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top))/(t.width*t.height),xe=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(t){case\"x\":return{deltaX:a*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case\"y\":return{deltaX:0,deltaY:a*e.deltaY};default:return{deltaX:a*e.deltaX,deltaY:a*e.deltaY}}},Me=(e,t,n,r)=>{const a=n-e,l=r-t;return Math.hypot(a,l)},Se=(e,t)=>Math.abs(e/t),Ae=(e,t)=>e*t/100,ve=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Ce=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Ie=e=>e.replace(/([a-z0-9])([A-Z])/g,\"$1-$2\").toLowerCase(),ke=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Ee=e=>e.replace(/([a-z0-9])([A-Z])/g,\"$1 $2\"),Le=e=>0===e.length?[]:e.split(\" \").filter(Boolean),Pe=e=>\"\"===e||u(e),Oe=e=>{const t=e.lastIndexOf(\".\");return t<=0||t===e.length-1?[e,\"\"]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},Te=(e,t)=>{if(0===e.length)return[];const n=t.charCodeAt(0),r=[];for(let t=0;t<e.length;t++)e.charCodeAt(t)===n&&r.push(t);return r},Xe=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let a=0;a<r;a++){const l=e[a],i={charIndex:a,prevChar:a>0?e[a-1]:null,nextChar:a<r-1?e[a+1]:null};n?.(l,i)||t(l,i)}},_e=(e,t=1/0)=>0===e.length?\"\":Le(e).slice(0,t).map(e=>e[0]).join(\"\").toUpperCase(),ze=(e,t,n,r=[],a=void 0,l=0)=>(e?.forEach(e=>{const{[n]:i,...o}=e,s=e[n],c=Array.isArray(s);if(r.push({...o,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=e[t];ze(s,t,n,r,a,l+1)}}),r),Ye=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),Re=(e,t,n,r)=>{const a=Le(r.toLowerCase());if(!a.length)return e;const l=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,i)=>{const o=i[n];if(!o)return r;if(r.some(e=>e[t]===i[t]))return r;const u=Le(o.toLowerCase());if(a.every(e=>u.some(t=>t.startsWith(e))))if(f(i.parentId)){r.push(i);const n=a=>{a.childCount&&e.forEach(e=>{e.parentId===a[t]&&(r.push(e),n(e))})};n(i)}else{const t=n=>{const a=l[n.parentId],i=e[a];f(i.parentId)||t(i);const o=r.length?r[r.length-1].parentId:null;(c(o)||o!==n.parentId)&&(s(i,\"[@react-hive/honey-utils]: Parent node was not found.\"),r.push(i))};t(i),r.push(i)}return r},[])};export{a as FOCUSABLE_HTML_TAGS,ye as applyInertiaStep,s as assert,fe as blobToFile,le as calculateCenterOffset,Me as calculateEuclideanDistance,Se as calculateMovingSpeed,Ae as calculatePercentage,ke as camelToDashCase,Ee as camelToWords,ie as centerElementInContainer,T as chunk,e as cloneBlob,P as compact,Y as compose,Ce as definedProps,q as delay,_ as difference,ee as downloadFile,V as everyAsync,he as fileListToFiles,B as filterParallel,H as filterSequential,G as findAsync,Te as findCharIndices,ze as flattenTree,Xe as forEachChar,we as generateEphemeralId,be as getDOMRectIntersectionRatio,t as getElementOffsetRect,i as getFocusableHtmlElements,ce as getLocalStorageCapabilities,Ye as getTreeChildren,_e as getWordsInitials,ne as getXOverflowWidth,ae as getYOverflowHeight,te as hasXOverflow,re as hasYOverflow,ve as hashString,X as intersection,pe as invokeIfFunction,n as isAnchorHtmlElement,E as isArray,w as isBlob,m as isBool,r as isContentEditableHtmlElement,y as isDate,k as isDecimal,h as isDefined,L as isEmptyArray,g as isEmptyObject,b as isError,ue as isFile,C as isFiniteNumber,N as isFunction,l as isHtmlElementFocusable,I as isInteger,se as isLocalStorageReadable,S as isMap,u as isNil,Pe as isNilOrEmptyString,c as isNull,d as isNumber,p as isObject,j as isPromise,M as isRegExp,A as isSet,Q as isString,v as isSymbol,f as isUndefined,x as isValidDate,o as moveFocusWithinContainer,R as noop,$ as not,F as once,oe as parse2DMatrix,Oe as parseFileName,z as pipe,me as readFilesFromDataTransfer,Z as reduceAsync,xe as resolveAxisDelta,ge as resolveBoundedDelta,K as retry,W as runParallel,U as runSequential,Re as searchTree,D as someAsync,Le as splitStringIntoWords,J as timeout,Ie as toKebabCase,de as traverseFileSystemDirectory,O as unique};\n//# sourceMappingURL=index.mjs.map","import { assert } from '@react-hive/honey-utils';\n\nimport type { HoneyCssToken, HoneyCssTokenType } from './types';\n\n/**\n * A lightweight cursor abstraction over a token stream.\n *\n * This is the core navigation primitive used by the Honey CSS parser.\n * It provides safe sequential reading, lookahead, backtracking,\n * and small helper utilities for collecting selector/value text.\n */\nexport interface HoneyTokenCursor {\n /**\n * Returns `true` when the cursor has consumed all tokens.\n */\n isEof: () => boolean;\n /**\n * Returns the current token without consuming it.\n *\n * This is primarily used for lookahead decisions in the parser:\n *\n * ```ts\n * if (cursor.peek()?.type === 'braceOpen') {\n * // parse rule block\n * }\n * ```\n */\n peek: () => HoneyCssToken | undefined;\n /**\n * Consumes and returns the current token, advancing the cursor forward.\n *\n * Returns `undefined` if the cursor is already at EOF.\n *\n * ```ts\n * const token = cursor.next();\n * ```\n */\n next: () => HoneyCssToken | undefined;\n /**\n * Creates a checkpoint of the current cursor position.\n *\n * Useful for speculative parsing or backtracking:\n *\n * ```ts\n * const mark = cursor.mark();\n *\n * if (!tryParseSomething(cursor)) {\n * cursor.reset(mark);\n * }\n * ```\n */\n mark: () => number;\n /**\n * Restores the cursor back to a previously created mark.\n *\n * @param mark - Index returned from {@link mark}.\n */\n reset: (mark: number) => void;\n /**\n * Consumes the next token and asserts that it matches the expected type.\n *\n * This is the parser's main safety mechanism and helps produce\n * clear error messages during invalid input.\n *\n * Throws if:\n * - the token stream ends unexpectedly\n * - the next token has a different type\n *\n * ```ts\n * cursor.expect('braceOpen'); // must be \"{\"\n * ```\n *\n * @param type - Expected token type.\n *\n * @returns The consumed token, narrowed to the expected type.\n */\n expect: <T extends HoneyCssTokenType>(type: T) => Extract<HoneyCssToken, { type: T }>;\n /**\n * Reads and concatenates consecutive token values until one of the stop token\n * types is encountered.\n *\n * This helper is used to collect:\n * - selectors (`.btn:hover`)\n * - declaration values (`calc(100% - 1px)`)\n * - at-rule names (`media`)\n *\n * Stops **before consuming** the stop token.\n *\n * Supported token types:\n * - `text` → appended as-is\n * - `string` → wrapped in quotes\n * - `params` → appended verbatim including parentheses\n *\n * Example:\n *\n * Tokens:\n * ```\n * text(\"var\")\n * params(\"(--color)\")\n * ```\n *\n * Result:\n * ```\n * \"var(--color)\"\n * ```\n *\n * @param stopTypes - Token types that terminate reading.\n *\n * @returns Combined string value.\n */\n readUntil: (stopTypes: HoneyCssTokenType[]) => string;\n /**\n * Advances the cursor until one of the stop token types is reached.\n *\n * This is useful for error recovery and safely skipping unknown syntax.\n *\n * Stops before consuming the stop token.\n *\n * @param stopTypes - Token types that terminate skipping.\n */\n skipUntil: (stopTypes: HoneyCssTokenType[]) => void;\n}\n\n/**\n * Creates a cursor wrapper around a list of CSS tokens.\n *\n * The cursor provides a small API surface for building\n * recursive-descent parsers without needing complex parser generators.\n *\n * @param tokens - Token list produced by the Honey tokenizer.\n *\n * @returns A reusable cursor instance.\n */\nexport const createCssTokenCursor = (tokens: HoneyCssToken[]): HoneyTokenCursor => {\n let index = 0;\n\n const isEof = (): boolean => index >= tokens.length;\n\n const peek = (): HoneyCssToken | undefined => (isEof() ? undefined : tokens[index]);\n\n const next = (): HoneyCssToken | undefined => (isEof() ? undefined : tokens[index++]);\n\n const mark = (): number => index;\n\n const reset = (mark: number): void => {\n index = mark;\n };\n\n const expect = <T extends HoneyCssTokenType>(type: T): Extract<HoneyCssToken, { type: T }> => {\n const token = next();\n\n assert(token, `[@react-hive/honey-css]: Expected \"${type}\" but reached end of input.`);\n assert(\n token.type === type,\n `[@react-hive/honey-css]: Expected \"${type}\" but got \"${token.type}\".`,\n );\n\n return token as Extract<HoneyCssToken, { type: T }>;\n };\n\n const readUntil = (stopTypes: HoneyCssTokenType[]): string => {\n let result = '';\n let prevType: HoneyCssTokenType | undefined;\n\n while (!isEof()) {\n const token = peek();\n\n if (!token || stopTypes.includes(token.type)) {\n break;\n }\n\n if (token.type === 'text') {\n // Only space-join consecutive text chunks\n if (prevType === 'text' && result) {\n result += ' ';\n }\n\n result += token.value;\n //\n } else if (token.type === 'string') {\n result += `\"${token.value}\"`;\n //\n } else if (token.type === 'params') {\n result += token.value;\n }\n\n prevType = token.type;\n next();\n }\n\n return result.trim();\n };\n\n const skipUntil = (stopTypes: HoneyCssTokenType[]): void => {\n while (!isEof()) {\n const token = peek();\n\n if (!token || stopTypes.includes(token.type)) {\n break;\n }\n\n next();\n }\n };\n\n return {\n isEof,\n peek,\n next,\n mark,\n reset,\n expect,\n readUntil,\n skipUntil,\n };\n};\n","import type { HoneyTokenCursor } from './create-css-token-cursor';\n\n/**\n * Reads a CSS selector from the current token cursor position.\n *\n * The selector is reconstructed by sequentially consuming supported tokens\n * until one of the following conditions is met:\n *\n * - A `braceOpen` token (`{`) is encountered\n * - A `braceClose` token (`}`) is encountered (safety stop)\n * - An unsupported token type appears\n * - The end of the token stream is reached\n *\n * Supported token types:\n *\n * - `text` - raw selector fragments such as:\n * `.btn`, `#id`, `> .child`, `+ .item`, `&[data-open]`, `[data-id=\"x\"]`\n *\n * - `colon` - pseudo selectors and pseudo-elements:\n * `:hover`, `::before`\n *\n * - `params` - parenthesized groups used in pseudo functions or nth-expressions:\n * `(2n+1)`, `(:disabled)`\n *\n * - `string` - quoted string values (typically inside attribute selectors)\n *\n * Behavior:\n *\n * - Preserves pseudo selectors and pseudo-elements\n * - Preserves combinators (`>`, `+`, `~`)\n * - Preserves attribute selectors\n * - Preserves pseudo functions such as `:not(...)`\n * - Does **not** consume the `{` token\n *\n * This function performs no validation of selector correctness.\n * It only reconstructs the textual representation from the token stream.\n *\n * @param cursor - Token cursor positioned at the beginning of a selector.\n *\n * @returns The reconstructed selector string (trimmed).\n */\nexport const readCssSelector = (cursor: HoneyTokenCursor): string => {\n const parts: string[] = [];\n\n const finish = () => parts.join('').trim();\n\n while (!cursor.isEof()) {\n const token = cursor.peek();\n if (!token) {\n break;\n }\n\n switch (token.type) {\n case 'braceOpen':\n case 'braceClose':\n return finish();\n\n case 'colon':\n parts.push(':');\n break;\n\n case 'text':\n case 'params':\n parts.push(token.value);\n break;\n\n case 'string':\n parts.push(`\"${token.value}\"`);\n break;\n\n default:\n return finish();\n }\n\n cursor.next();\n }\n\n return finish();\n};\n","import type { HoneyTokenCursor } from './create-css-token-cursor';\nimport { readCssSelector } from './read-css-selector';\n\n/**\n * Reads either a **CSS rule selector** or a **declaration property key**\n * from the current cursor position.\n *\n * This helper is used in ambiguous grammar positions where the next token\n * could represent either:\n *\n * - A nested rule:\n * ```css\n * selector { ... }\n * ```\n *\n * - A declaration:\n * ```css\n * property: value;\n * ```\n *\n * ---------------------------------------------------------------------------\n * 🧠 Resolution Strategy\n * ---------------------------------------------------------------------------\n *\n * 1. If the first token is a `colon`, it must be a selector starting with `:`\n * (e.g. `:root`, `:hover`, `::before`). In this case, it delegates directly\n * to {@link readCssSelector}.\n *\n * 2. Otherwise, it **speculatively parses** a selector using\n * {@link readCssSelector}.\n *\n * 3. The parsed selector is accepted **only if** it is immediately followed\n * by a `braceOpen` (`{`) token.\n *\n * 4. If no `{` follows, the cursor is rewound and the input is treated as\n * a declaration key instead.\n *\n * ---------------------------------------------------------------------------\n * ⚠️ Notes & Limitations\n * ---------------------------------------------------------------------------\n *\n * - Selector-like property names such as:\n *\n * ```css\n * a:hover: 1;\n * ```\n *\n * are intentionally treated as declaration keys ending at the first `:`.\n * In this example, the key will be parsed as `\"a\"`.\n *\n * - Declaration keys are read using\n * {@link HoneyTokenCursor.readUntil}, which:\n * - Inserts spaces only between consecutive `text` tokens\n * - Keeps `params` and `string` tokens adjacent without adding spaces\n *\n * ---------------------------------------------------------------------------\n * 🔁 Cursor Behavior\n * ---------------------------------------------------------------------------\n *\n * - When a selector is returned:\n * - The `{` token is **not consumed**\n * - The cursor will still point to `braceOpen`\n *\n * - When a declaration key is returned:\n * - The delimiter token (`colon`, `braceOpen`, `semicolon`,\n * `braceClose`, or `at`) is **not consumed**\n *\n * ---------------------------------------------------------------------------\n *\n * @param cursor - Token cursor positioned at the start of either a selector\n * or a declaration key.\n *\n * @returns The parsed selector or declaration key.\n * Returns an empty string if at EOF or if the first token is unsupported.\n */\nexport const readCssKeyOrSelector = (cursor: HoneyTokenCursor): string => {\n const first = cursor.peek();\n if (!first) {\n return '';\n }\n\n // Selector starting with \":\" (:root, :hover, ::before, etc.)\n if (first.type === 'colon') {\n return readCssSelector(cursor);\n }\n\n // Speculative selector parse\n const mark = cursor.mark();\n const candidate = readCssSelector(cursor);\n\n // A rule block must follow a real selector\n if (cursor.peek()?.type === 'braceOpen') {\n return candidate;\n }\n\n // Otherwise treat it as a declaration key\n cursor.reset(mark);\n\n return cursor.readUntil(['colon', 'braceOpen', 'semicolon', 'braceClose', 'at']);\n};\n","import type { HoneyCssAstDeclarationNode } from './types';\nimport type { HoneyTokenCursor } from './create-css-token-cursor';\n\n/**\n * Parses a single CSS declaration node.\n *\n * The cursor must be positioned immediately before the `colon` (`:`)\n * that separates the property name and value.\n *\n * Example:\n *\n * ```css\n * color: red;\n * ```\n *\n * Parsing behavior:\n *\n * 1. Consumes the `colon` token.\n * 2. Reads the declaration value until one of:\n * - `semicolon` (`;`)\n * - `braceClose` (`}`) — allows the last declaration in a block\n * to omit the trailing semicolon.\n * 3. If a `semicolon` is present, it is consumed.\n *\n * Supported forms:\n *\n * ```css\n * color: red;\n * color: red\n * padding: var(--x, 8px);\n * background: url(var(--img));\n * ```\n *\n * Notes:\n *\n * - The returned `value` string is reconstructed using the cursor's\n * {@link HoneyTokenCursor.readUntil} method.\n * - Spaces are inserted only between consecutive `text` tokens.\n * - `params` and `string` tokens are preserved without adding extra spaces.\n * - The closing `}` token (if encountered) is NOT consumed.\n *\n * @param cursor - Token cursor positioned at the declaration delimiter (`:`).\n * @param prop - Previously parsed property name.\n *\n * @returns A {@link HoneyCssAstDeclarationNode}.\n */\nexport const parseCssDeclaration = (\n cursor: HoneyTokenCursor,\n prop: string,\n): HoneyCssAstDeclarationNode => {\n cursor.expect('colon');\n\n const value = cursor.readUntil(['semicolon', 'braceClose']);\n\n if (cursor.peek()?.type === 'semicolon') {\n cursor.next();\n }\n\n return {\n type: 'declaration',\n prop,\n value,\n };\n};\n","/**\n * Represents a supported string delimiter in CSS.\n *\n * Only single (`'`) and double (`\"`) quotes are valid\n * string delimiters in CSS selectors and attribute values.\n */\ntype QuoteChar = '\"' | \"'\";\n\n/**\n * Iterates over a comma-separated CSS selector list and invokes\n * a callback for each **top-level selector part**.\n *\n * This function safely splits selectors by commas **only at the root level**.\n * It does NOT split when the comma appears inside:\n *\n * - Parentheses — `:is(.a, .b)`\n * - Attribute selectors — `[data-x=\"a,b\"]`\n * - Quoted strings\n * - Escape sequences\n *\n * ---\n *\n * ### Example\n *\n * ```ts\n * forEachTopLevelSelector('.a, .b', cb)\n * // → \".a\"\n * // → \".b\"\n *\n * forEachTopLevelSelector(':is(.a, .b)', cb)\n * // → \":is(.a, .b)\"\n * ```\n *\n * ---\n *\n * ### Parsing Strategy\n *\n * - Tracks nesting depth for:\n * - `()` parentheses\n * - `[]` brackets\n * - Tracks active string mode (`'` or `\"`)\n * - Handles escape sequences (`\\`)\n * - Splits only when encountering a comma at depth 0\n *\n * Empty parts are ignored and not passed to the callback.\n *\n * @param input - The selector list to process.\n * @param callback - Invoked once for each top-level selector.\n */\nconst forEachTopLevelSelector = (input: string, callback: (part: string) => void) => {\n let start = 0;\n let parenDepth = 0;\n let bracketDepth = 0;\n\n let currentQuote: QuoteChar | null = null;\n let isEscapeSeq = false;\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i];\n\n if (isEscapeSeq) {\n isEscapeSeq = false;\n continue;\n }\n\n if (char === '\\\\') {\n isEscapeSeq = true;\n continue;\n }\n\n if (currentQuote) {\n if (char === currentQuote) {\n currentQuote = null;\n }\n\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n currentQuote = char;\n continue;\n }\n\n switch (char) {\n case '(':\n parenDepth++;\n break;\n case ')':\n parenDepth--;\n break;\n case '[':\n bracketDepth++;\n break;\n case ']':\n bracketDepth--;\n break;\n }\n\n if (char === ',' && parenDepth === 0 && bracketDepth === 0) {\n const part = input.slice(start, i).trim();\n if (part) {\n callback(part);\n }\n\n start = i + 1;\n }\n }\n\n const last = input.slice(start).trim();\n if (last) {\n callback(last);\n }\n};\n\n/**\n * Resolves a nested CSS selector against a parent selector.\n *\n * Performs full cartesian expansion of comma-separated selector lists\n * and supports explicit parent references using `&`.\n *\n * ---\n *\n * ### Resolution Rules\n *\n * - If the child selector contains `&`,\n * every `&` is replaced with the parent selector.\n *\n * - Otherwise, a descendant relationship is created:\n *\n * ```\n * parent child\n * ```\n *\n * - Supports comma-separated lists on both parent and child.\n * - Preserves complex selectors including:\n * - Pseudo-classes (`:hover`)\n * - Pseudo-elements (`::before`)\n * - Attribute selectors (`[data-x=\"a,b\"]`)\n * - Nested functions (`:is(...)`, `:not(...)`)\n *\n * ---\n *\n * ### Examples\n *\n * ```ts\n * resolveCssSelector('.child', '.scope')\n * // → \".scope .child\"\n *\n * resolveCssSelector('&:hover', '.btn')\n * // → \".btn:hover\"\n *\n * resolveCssSelector('.a, .b', '.scope')\n * // → \".scope .a, .scope .b\"\n *\n * resolveCssSelector('& + &', '.item')\n * // → \".item + .item\"\n *\n * resolveCssSelector('.x, .y', '.a, .b')\n * // → \".a .x, .a .y, .b .x, .b .y\"\n * ```\n *\n * ---\n *\n * @param selector - The nested (child) selector.\n * @param parent - The parent selector used for scoping.\n *\n * @returns The fully resolved selector string.\n */\nexport const resolveCssSelector = (selector: string, parent: string): string => {\n const childSelector = selector.trim();\n if (!childSelector) {\n return '';\n }\n\n const parentSelector = parent.trim();\n if (!parentSelector) {\n return childSelector;\n }\n\n const result: string[] = [];\n\n forEachTopLevelSelector(parentSelector, parentPart => {\n forEachTopLevelSelector(childSelector, childPart => {\n if (childPart.includes('&')) {\n result.push(childPart.replaceAll('&', parentPart));\n } else {\n result.push(`${parentPart} ${childPart}`);\n }\n });\n });\n\n return result.join(', ');\n};\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","isBoundaryChar","ch","tokenizeCss","input","tokens","index","isEof","length","peek","undefined","peekNext","skipWhitespace","test","skipSingleLineComment","skipMultiLineComment","readString","quote","result","escaped","readParamsGroup","depth","readText","trim","push","type","s","e","t","Error","createCssTokenCursor","next","mark","reset","expect","token","readUntil","stopTypes","prevType","includes","skipUntil","readCssSelector","cursor","parts","finish","join","readCssKeyOrSelector","first","candidate","parseCssDeclaration","forEachTopLevelSelector","callback","start","parenDepth","bracketDepth","currentQuote","isEscapeSeq","i","char","part","slice","last","resolveCssSelector","selector","parent","childSelector","parentSelector","parentPart","childPart","replaceAll"],"sourceRoot":""}
|
package/dist/index.d.ts
CHANGED