@bamboocss/shared 1.11.1 → 1.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,1357 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/arbitrary-value.ts
3
+ const getArbitraryValue = (_value) => {
4
+ if (!_value || typeof _value !== "string") return _value;
5
+ const value = _value.trim();
6
+ if (value[0] === "[" && value[value.length - 1] === "]") {
7
+ const innerValue = value.slice(1, -1);
8
+ let bracketCount = 0;
9
+ for (let i = 0; i < innerValue.length; i++) if (innerValue[i] === "[") bracketCount++;
10
+ else if (innerValue[i] === "]") {
11
+ if (bracketCount === 0) return value;
12
+ bracketCount--;
13
+ }
14
+ if (bracketCount === 0) return innerValue.trim();
15
+ }
16
+ return value;
17
+ };
18
+ //#endregion
19
+ //#region src/assert.ts
20
+ const isString = (v) => typeof v === "string";
21
+ const isBoolean = (v) => typeof v === "boolean";
22
+ const isFunction = (v) => typeof v === "function";
23
+ function isObject(value) {
24
+ return typeof value === "object" && value != null && !Array.isArray(value);
25
+ }
26
+ const isSymbol = (v) => typeof v === "symbol";
27
+ const isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
28
+ //#endregion
29
+ //#region src/assign.ts
30
+ function assign(target, ...sources) {
31
+ for (const source of sources) for (const key in source) if (!target?.hasOwnProperty?.(key)) target[key] = source[key];
32
+ return target;
33
+ }
34
+ //#endregion
35
+ //#region src/astish.ts
36
+ const newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
37
+ const ruleClean = /\/\*[^]*?\*\/| +/g;
38
+ const ruleNewline = /\n+/g;
39
+ const empty = " ";
40
+ const astish = (val, tree = [{}]) => {
41
+ if (!val) return tree[0];
42
+ let block, left;
43
+ while (block = newRule.exec(val.replace(ruleClean, ""))) if (block[4]) tree.shift();
44
+ else if (block[3]) {
45
+ left = block[3].replace(ruleNewline, empty).trim();
46
+ if (!left.includes("&") && !left.startsWith("@")) left = "& " + left;
47
+ tree.unshift(tree[0][left] = tree[0][left] || {});
48
+ } else tree[0][block[1]] = block[2].replace(ruleNewline, empty).trim();
49
+ return tree[0];
50
+ };
51
+ //#endregion
52
+ //#region src/cache-map.ts
53
+ var CacheMap = class {
54
+ cache;
55
+ keysInUse;
56
+ maxCacheSize;
57
+ constructor(maxCacheSize = 1e3) {
58
+ this.maxCacheSize = maxCacheSize;
59
+ this.cache = /* @__PURE__ */ new Map();
60
+ this.keysInUse = [];
61
+ }
62
+ get(key) {
63
+ if (!this.cache.has(key)) return;
64
+ this.updateKeyUsage(key);
65
+ return this.cache.get(key);
66
+ }
67
+ set(key, value) {
68
+ if (!this.cache.has(key) && this.cache.size === this.maxCacheSize) this.evictLeastRecentlyUsed();
69
+ this.cache.set(key, value);
70
+ this.updateKeyUsage(key);
71
+ return this;
72
+ }
73
+ delete(key) {
74
+ const result = this.cache.delete(key);
75
+ if (result) {
76
+ const index = this.keysInUse.indexOf(key);
77
+ if (index !== -1) this.keysInUse.splice(index, 1);
78
+ }
79
+ return result;
80
+ }
81
+ updateKeyUsage(key) {
82
+ const index = this.keysInUse.indexOf(key);
83
+ if (index !== -1) this.keysInUse.splice(index, 1);
84
+ this.keysInUse.push(key);
85
+ }
86
+ evictLeastRecentlyUsed() {
87
+ const keyToEvict = this.keysInUse.shift();
88
+ if (keyToEvict !== void 0) this.cache.delete(keyToEvict);
89
+ }
90
+ clear() {
91
+ this.cache.clear();
92
+ this.keysInUse = [];
93
+ }
94
+ has(key) {
95
+ return this.cache.has(key);
96
+ }
97
+ get size() {
98
+ return this.cache.size;
99
+ }
100
+ forEach(callback, thisArg) {
101
+ this.cache.forEach(callback, thisArg);
102
+ }
103
+ keys() {
104
+ return this.cache.keys();
105
+ }
106
+ values() {
107
+ return this.cache.values();
108
+ }
109
+ entries() {
110
+ return this.cache.entries();
111
+ }
112
+ getOrInsert(key, defaultValue) {
113
+ if (this.cache.has(key)) {
114
+ this.updateKeyUsage(key);
115
+ return this.cache.get(key);
116
+ }
117
+ this.set(key, defaultValue);
118
+ return defaultValue;
119
+ }
120
+ getOrInsertComputed(key, callback) {
121
+ if (this.cache.has(key)) {
122
+ this.updateKeyUsage(key);
123
+ return this.cache.get(key);
124
+ }
125
+ const value = callback(key);
126
+ this.set(key, value);
127
+ return value;
128
+ }
129
+ [Symbol.iterator]() {
130
+ return this.cache[Symbol.iterator]();
131
+ }
132
+ [Symbol.toStringTag] = "CacheMap";
133
+ toJSON = () => {
134
+ return this.cache;
135
+ };
136
+ };
137
+ //#endregion
138
+ //#region src/calc.ts
139
+ function isCssVar$1(value) {
140
+ return isObject(value) && "ref" in value;
141
+ }
142
+ function getRef(operand) {
143
+ return isCssVar$1(operand) ? operand.ref : operand.toString();
144
+ }
145
+ const calcRegex = /calc/g;
146
+ const toExpression = (operator, ...operands) => operands.map(getRef).join(` ${operator} `).replace(calcRegex, "");
147
+ const multiply = (...operands) => `calc(${toExpression("*", ...operands)})`;
148
+ const calc = { negate(x) {
149
+ const value = getRef(x);
150
+ if (value != null && !Number.isNaN(parseFloat(value))) return String(value).startsWith("-") ? String(value).slice(1) : `-${value}`;
151
+ return multiply(value, -1);
152
+ } };
153
+ //#endregion
154
+ //#region src/memo.ts
155
+ const memo = (fn) => {
156
+ const cache = /* @__PURE__ */ new Map();
157
+ const get = (...args) => {
158
+ const key = JSON.stringify(args);
159
+ if (cache.has(key)) return cache.get(key);
160
+ const result = fn(...args);
161
+ cache.set(key, result);
162
+ return result;
163
+ };
164
+ return get;
165
+ };
166
+ //#endregion
167
+ //#region src/camelcase-property.ts
168
+ const regex = /-(\w|$)/g;
169
+ const callback = (_dashChar, char) => char.toUpperCase();
170
+ const camelCaseProperty = memo((property) => {
171
+ if (property.startsWith("--")) return property;
172
+ let str = property.toLowerCase();
173
+ str = str.startsWith("-ms-") ? str.substring(1) : str;
174
+ return str.replace(regex, callback);
175
+ });
176
+ //#endregion
177
+ //#region src/capitalize.ts
178
+ const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
179
+ const camelCaseRegex = /([a-z])([A-Z])/g;
180
+ const dashCase = (s) => s.replace(camelCaseRegex, "$1-$2").toLowerCase();
181
+ const uncapitalize = (s) => s.charAt(0).toLowerCase() + s.slice(1);
182
+ //#endregion
183
+ //#region src/compact.ts
184
+ function compact(value) {
185
+ return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value]) => value !== void 0));
186
+ }
187
+ //#endregion
188
+ //#region src/condition.ts
189
+ const isBaseCondition = (v) => v === "base";
190
+ function filterBaseConditions(c) {
191
+ return c.slice().filter((v) => !isBaseCondition(v));
192
+ }
193
+ //#endregion
194
+ //#region src/hash.ts
195
+ function toChar(code) {
196
+ return String.fromCharCode(code + (code > 25 ? 39 : 97));
197
+ }
198
+ function toName(code) {
199
+ let name = "";
200
+ let x;
201
+ for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
202
+ return toChar(x % 52) + name;
203
+ }
204
+ function toPhash(h, x) {
205
+ let i = x.length;
206
+ while (i) h = h * 33 ^ x.charCodeAt(--i);
207
+ return h;
208
+ }
209
+ function toHash(value) {
210
+ return toName(toPhash(5381, value) >>> 0);
211
+ }
212
+ //#endregion
213
+ //#region src/important.ts
214
+ const importantRegex = /\s*!(important)?/i;
215
+ function isImportant(value) {
216
+ return typeof value === "string" ? importantRegex.test(value) : false;
217
+ }
218
+ function withoutImportant(value) {
219
+ return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;
220
+ }
221
+ function withoutSpace(str) {
222
+ return typeof str === "string" ? str.replaceAll(" ", "_") : str;
223
+ }
224
+ function markImportant(obj) {
225
+ if (typeof obj !== "object" || obj === null) return obj;
226
+ const result = Array.isArray(obj) ? [] : {};
227
+ const stack = [{
228
+ obj,
229
+ result
230
+ }];
231
+ while (stack.length > 0) {
232
+ const { obj, result } = stack.pop();
233
+ for (const [key, value] of Object.entries(obj)) if (typeof value === "string" || typeof value === "number") result[key] = `${value} !important`;
234
+ else if (typeof value === "object" && value !== null) {
235
+ const next = Array.isArray(value) ? [] : {};
236
+ result[key] = next;
237
+ stack.push({
238
+ obj: value,
239
+ result: next
240
+ });
241
+ } else result[key] = value;
242
+ }
243
+ return result;
244
+ }
245
+ //#endregion
246
+ //#region src/merge-props.ts
247
+ const MERGE_OMIT$2 = new Set([
248
+ "__proto__",
249
+ "constructor",
250
+ "prototype"
251
+ ]);
252
+ function mergeProps(...sources) {
253
+ return sources.reduce((prev, obj) => {
254
+ if (!obj) return prev;
255
+ Object.keys(obj).forEach((key) => {
256
+ if (MERGE_OMIT$2.has(key)) return;
257
+ const prevValue = prev[key];
258
+ const value = obj[key];
259
+ if (isObject(prevValue) && isObject(value)) prev[key] = mergeProps(prevValue, value);
260
+ else prev[key] = value;
261
+ });
262
+ return prev;
263
+ }, {});
264
+ }
265
+ //#endregion
266
+ //#region src/walk-object.ts
267
+ const isNotNullish = (element) => element != null;
268
+ function walkObject(target, predicate, options = {}) {
269
+ const { stop, getKey } = options;
270
+ function inner(value, path = []) {
271
+ if (isObjectOrArray(value)) {
272
+ const result = {};
273
+ for (const [prop, child] of Object.entries(value)) {
274
+ const key = getKey?.(prop, child) ?? prop;
275
+ const childPath = [...path, key];
276
+ if (stop?.(value, childPath)) return predicate(value, path);
277
+ const next = inner(child, childPath);
278
+ if (isNotNullish(next)) result[key] = next;
279
+ }
280
+ return result;
281
+ }
282
+ return predicate(value, path);
283
+ }
284
+ return inner(target);
285
+ }
286
+ function mapObject(obj, fn) {
287
+ if (Array.isArray(obj)) return obj.map((value) => fn(value));
288
+ if (!isObject(obj)) return fn(obj);
289
+ return walkObject(obj, (value) => fn(value));
290
+ }
291
+ //#endregion
292
+ //#region src/normalize-style-object.ts
293
+ function toResponsiveObject(values, breakpoints) {
294
+ return values.reduce((acc, current, index) => {
295
+ const key = breakpoints[index];
296
+ if (current != null) acc[key] = current;
297
+ return acc;
298
+ }, {});
299
+ }
300
+ function normalizeStyleObject(styles, context, shorthand = true) {
301
+ const { utility, conditions } = context;
302
+ const { hasShorthand, resolveShorthand } = utility;
303
+ return walkObject(styles, (value) => {
304
+ return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
305
+ }, {
306
+ stop: (value) => Array.isArray(value),
307
+ getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0
308
+ });
309
+ }
310
+ //#endregion
311
+ //#region src/classname.ts
312
+ const fallbackCondition = {
313
+ shift: (v) => v,
314
+ finalize: (v) => v,
315
+ breakpoints: { keys: [] }
316
+ };
317
+ const sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
318
+ const ENTRY_SEP = "]___[";
319
+ const COND_SEP = "<___>";
320
+ function createCss(context) {
321
+ const { utility, hash, grouped, conditions: conds = fallbackCondition } = context;
322
+ const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
323
+ const hashFn = (conditions, className) => {
324
+ let result;
325
+ if (hash) {
326
+ const baseArray = [...conds.finalize(conditions), className];
327
+ result = formatClassName(utility.toHash(baseArray, toHash));
328
+ } else result = [...conds.finalize(conditions), formatClassName(className)].join(":");
329
+ return result;
330
+ };
331
+ if (grouped) return memo(({ base, ...styles } = {}) => {
332
+ const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);
333
+ const hashes = [];
334
+ walkObject(normalizedObject, (value, paths) => {
335
+ if (value == null) return;
336
+ const [prop, ...allConditions] = conds.shift(paths);
337
+ const conditions = filterBaseConditions(allConditions);
338
+ const parts = [`${prop}${ENTRY_SEP}value:${value}`];
339
+ if (conditions.length) parts.push(`cond:${conditions.join(COND_SEP)}`);
340
+ hashes.push(parts.join(ENTRY_SEP));
341
+ });
342
+ if (hashes.length === 0) return "";
343
+ hashes.sort();
344
+ const groupId = hashes.join("|");
345
+ return formatClassName(utility.toHash(["grouped", groupId], toHash));
346
+ });
347
+ return memo(({ base, ...styles } = {}) => {
348
+ const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);
349
+ const classNames = /* @__PURE__ */ new Set();
350
+ walkObject(normalizedObject, (value, paths) => {
351
+ if (value == null) return;
352
+ const important = isImportant(value);
353
+ const [prop, ...allConditions] = conds.shift(paths);
354
+ let className = hashFn(filterBaseConditions(allConditions), utility.transform(prop, withoutImportant(sanitize(value))).className);
355
+ if (important) className = `${className}!`;
356
+ classNames.add(className);
357
+ });
358
+ return Array.from(classNames).join(" ");
359
+ });
360
+ }
361
+ function compactStyles(...styles) {
362
+ return styles.flat().filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);
363
+ }
364
+ function createMergeCss(context) {
365
+ function resolve(styles) {
366
+ const allStyles = compactStyles(...styles);
367
+ if (allStyles.length === 1) return allStyles;
368
+ return allStyles.map((style) => normalizeStyleObject(style, context));
369
+ }
370
+ function mergeCss(...styles) {
371
+ return mergeProps(...resolve(styles));
372
+ }
373
+ function assignCss(...styles) {
374
+ return Object.assign({}, ...resolve(styles));
375
+ }
376
+ return {
377
+ mergeCss: memo(mergeCss),
378
+ assignCss
379
+ };
380
+ }
381
+ //#endregion
382
+ //#region src/css-var.ts
383
+ const escRegex = /[^a-zA-Z0-9_\u0081-\uffff-]/g;
384
+ function esc$1(string) {
385
+ return `${string}`.replace(escRegex, (s) => `\\${s}`);
386
+ }
387
+ const dashCaseRegex = /[A-Z]/g;
388
+ function dashCase$1(string) {
389
+ return string.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
390
+ }
391
+ function cssVar(name, options = {}) {
392
+ const { fallback = "", prefix = "", hash } = options;
393
+ const variable = hash ? [
394
+ "-",
395
+ prefix,
396
+ toHash(name)
397
+ ].filter(Boolean).join("-") : dashCase$1([
398
+ "-",
399
+ prefix,
400
+ esc$1(name)
401
+ ].filter(Boolean).join("-"));
402
+ return {
403
+ var: variable,
404
+ ref: `var(${variable}${fallback ? `, ${fallback}` : ""})`
405
+ };
406
+ }
407
+ //#endregion
408
+ //#region src/deep-set.ts
409
+ const deepSet = (target, path, value) => {
410
+ const isValueObject = isObject(value);
411
+ if (!path.length && isValueObject) return mergeProps(target, value);
412
+ let current = target;
413
+ for (let i = 0; i < path.length; i++) {
414
+ const key = path[i];
415
+ current[key] ||= {};
416
+ if (i === path.length - 1) if (isValueObject && isObject(current[key])) current[key] = mergeProps(current[key], value);
417
+ else current[key] = value;
418
+ else current = current[key];
419
+ }
420
+ return target;
421
+ };
422
+ //#endregion
423
+ //#region src/entries.ts
424
+ function fromEntries(entries) {
425
+ const result = {};
426
+ entries.forEach((kv) => {
427
+ result[kv[0]] = kv[1];
428
+ });
429
+ return result;
430
+ }
431
+ function entries(obj) {
432
+ const result = [];
433
+ for (const key in obj) result.push([key, obj[key]]);
434
+ return result;
435
+ }
436
+ function mapEntries(obj, f) {
437
+ const result = {};
438
+ for (const key in obj) {
439
+ const kv = f(key, obj[key]);
440
+ result[kv[0]] = kv[1];
441
+ }
442
+ return result;
443
+ }
444
+ //#endregion
445
+ //#region src/error.ts
446
+ var BambooError = class extends Error {
447
+ code;
448
+ hint;
449
+ constructor(code, message, opts) {
450
+ super(message, { cause: opts?.cause });
451
+ this.code = `ERR_BAMBOO_${code}`;
452
+ this.hint = opts?.hint;
453
+ }
454
+ };
455
+ //#endregion
456
+ //#region src/esc.ts
457
+ const rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g;
458
+ const fcssescape = function(ch, asCodePoint) {
459
+ if (!asCodePoint) return "\\" + ch;
460
+ if (ch === "\0") return "�";
461
+ if (ch === "-" && ch.length === 1) return "\\-";
462
+ return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16);
463
+ };
464
+ const esc = (sel) => {
465
+ return (sel + "").replace(rcssescape, fcssescape);
466
+ };
467
+ //#endregion
468
+ //#region src/flatten.ts
469
+ function filterDefault(path) {
470
+ if (path[0] === "DEFAULT") return path;
471
+ return path.filter((item) => item !== "DEFAULT");
472
+ }
473
+ function flatten(values, stop) {
474
+ const result = {};
475
+ walkObject(values, (token, paths) => {
476
+ paths = filterDefault(paths);
477
+ if (token) result[paths.join(".")] = token.value;
478
+ }, { stop: stop ?? ((v) => {
479
+ return isObject(v) && "value" in v;
480
+ }) });
481
+ return result;
482
+ }
483
+ //#endregion
484
+ //#region src/get-or-create-set.ts
485
+ function getOrCreateSet(map, key) {
486
+ let set = map.get(key);
487
+ if (!set) {
488
+ map.set(key, /* @__PURE__ */ new Set());
489
+ set = map.get(key);
490
+ }
491
+ return set;
492
+ }
493
+ //#endregion
494
+ //#region src/hypenate-property.ts
495
+ const wordRegex = /([A-Z])/g;
496
+ const msRegex = /^ms-/;
497
+ const hypenateProperty = memo((property) => {
498
+ if (property.startsWith("--")) return property;
499
+ return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
500
+ });
501
+ //#endregion
502
+ //#region src/is-css-function.ts
503
+ const fnRegExp = new RegExp(`^(${[
504
+ "min",
505
+ "max",
506
+ "clamp",
507
+ "calc"
508
+ ].join("|")})\\(.*\\)`);
509
+ const isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);
510
+ //#endregion
511
+ //#region src/is-css-unit.ts
512
+ const lengthUnitsPattern = `(?:${"cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%".split(",").join("|")})`;
513
+ const lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);
514
+ const isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
515
+ //#endregion
516
+ //#region src/is-css-var.ts
517
+ const isCssVar = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
518
+ //#endregion
519
+ //#region src/merge-anything.ts
520
+ /**
521
+ * Credits: https://github.com/mesqueeb/merge-anything
522
+ */
523
+ const MERGE_OMIT$1 = new Set([
524
+ "__proto__",
525
+ "constructor",
526
+ "prototype"
527
+ ]);
528
+ function concatArrays(originVal, newVal) {
529
+ if (Array.isArray(originVal) && Array.isArray(newVal)) return originVal.concat(newVal);
530
+ return newVal;
531
+ }
532
+ function assignProp(carry, key, newVal, originalObject) {
533
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
534
+ if (propType === "enumerable") carry[key] = newVal;
535
+ if (propType === "nonenumerable") Object.defineProperty(carry, key, {
536
+ value: newVal,
537
+ enumerable: false,
538
+ writable: true,
539
+ configurable: true
540
+ });
541
+ }
542
+ function mergeRecursively(origin, newComer, compareFn) {
543
+ if (!isObject(newComer)) return newComer;
544
+ let newObject = {};
545
+ if (isObject(origin)) {
546
+ const props = Object.getOwnPropertyNames(origin);
547
+ const symbols = Object.getOwnPropertySymbols(origin);
548
+ newObject = [...props, ...symbols].reduce((carry, key) => {
549
+ if (isString(key) && MERGE_OMIT$1.has(key)) return carry;
550
+ const targetVal = origin[key];
551
+ if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) assignProp(carry, key, targetVal, origin);
552
+ return carry;
553
+ }, {});
554
+ }
555
+ const props = Object.getOwnPropertyNames(newComer);
556
+ const symbols = Object.getOwnPropertySymbols(newComer);
557
+ return [...props, ...symbols].reduce((carry, key) => {
558
+ if (isString(key) && MERGE_OMIT$1.has(key)) return carry;
559
+ let newVal = newComer[key];
560
+ const targetVal = isObject(origin) ? origin[key] : void 0;
561
+ if (targetVal !== void 0 && isObject(newVal)) newVal = mergeRecursively(targetVal, newVal, compareFn);
562
+ assignProp(carry, key, compareFn ? compareFn(targetVal, newVal, key) : newVal, newComer);
563
+ return carry;
564
+ }, newObject);
565
+ }
566
+ function mergeAndConcat(object, ...otherObjects) {
567
+ return otherObjects.reduce((result, newComer) => {
568
+ return mergeRecursively(result, newComer, concatArrays);
569
+ }, object);
570
+ }
571
+ //#endregion
572
+ //#region src/merge-with.ts
573
+ const MERGE_OMIT = new Set([
574
+ "__proto__",
575
+ "constructor",
576
+ "prototype"
577
+ ]);
578
+ function mergeWith(target, ...sources) {
579
+ const customizer = sources.pop();
580
+ for (const source of sources) for (const key in source) {
581
+ if (isString(key) && MERGE_OMIT.has(key)) continue;
582
+ const merged = customizer(target[key], source[key]);
583
+ if (merged === void 0) if (isObject(target[key]) && isObject(source[key])) target[key] = mergeWith({}, target[key], source[key], customizer);
584
+ else target[key] = source[key];
585
+ else target[key] = merged;
586
+ }
587
+ return target;
588
+ }
589
+ //#endregion
590
+ //#region src/traverse.ts
591
+ const defaultOptions = {
592
+ separator: ".",
593
+ maxDepth: Infinity
594
+ };
595
+ function traverse(obj, callback, options = defaultOptions) {
596
+ const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
597
+ const separator = options.separator ?? defaultOptions.separator;
598
+ const stack = [{
599
+ value: obj,
600
+ path: "",
601
+ paths: [],
602
+ depth: -1,
603
+ parent: null,
604
+ key: ""
605
+ }];
606
+ while (stack.length > 0) {
607
+ const currentItem = stack.pop();
608
+ if (currentItem.parent !== null) callback(currentItem);
609
+ if (options.stop?.(currentItem)) continue;
610
+ if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
611
+ const keys = Object.keys(currentItem.value);
612
+ for (let i = keys.length - 1; i >= 0; i--) {
613
+ const key = keys[i];
614
+ const value = currentItem.value[key];
615
+ const path = currentItem.path ? currentItem.path + separator + key : key;
616
+ const paths = currentItem.paths.concat(key);
617
+ stack.push({
618
+ value,
619
+ path,
620
+ paths,
621
+ depth: currentItem.depth + 1,
622
+ parent: currentItem.value,
623
+ key
624
+ });
625
+ }
626
+ }
627
+ }
628
+ }
629
+ //#endregion
630
+ //#region src/omit.ts
631
+ const omit = (obj, paths) => {
632
+ const result = { ...obj };
633
+ traverse(result, ({ path, parent, key }) => {
634
+ if (paths.includes(path)) delete parent[key];
635
+ });
636
+ return result;
637
+ };
638
+ //#endregion
639
+ //#region src/bamboo-config-name.ts
640
+ const BAMBOO_CONFIG_NAME = "__bamboo.config__";
641
+ //#endregion
642
+ //#region src/pattern-fns.ts
643
+ const patternFns = {
644
+ map: mapObject,
645
+ isCssFunction,
646
+ isCssVar,
647
+ isCssUnit
648
+ };
649
+ const getPatternStyles = (pattern, styles) => {
650
+ if (!pattern?.defaultValues) return styles;
651
+ const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;
652
+ return Object.assign({}, defaults, compact(styles));
653
+ };
654
+ //#endregion
655
+ //#region src/split.ts
656
+ function splitBy(value, separator = ",") {
657
+ const result = [];
658
+ let current = "";
659
+ let depth = 0;
660
+ for (let i = 0; i < value.length; i++) {
661
+ const char = value[i];
662
+ if (char === "(") depth++;
663
+ else if (char === ")") depth--;
664
+ else if (char === separator && depth === 0) {
665
+ result.push(current);
666
+ current = "";
667
+ continue;
668
+ }
669
+ current += char;
670
+ }
671
+ result.push(current);
672
+ return result;
673
+ }
674
+ function splitDotPath(path) {
675
+ return path.split(".").reduce((acc, curr) => {
676
+ const last = acc[acc.length - 1];
677
+ if (last != null && !isNaN(Number(last)) && !isNaN(Number(curr))) acc[acc.length - 1] = `${last}.${curr}`;
678
+ else acc.push(curr);
679
+ return acc;
680
+ }, []);
681
+ }
682
+ function getNegativePath(path) {
683
+ return path.slice(0, -1).concat(`-${path.at(-1)}`);
684
+ }
685
+ function getDotPath(obj, path, fallback) {
686
+ if (typeof path !== "string") return fallback;
687
+ const idx = path.indexOf(".");
688
+ if (idx === -1) return obj?.[path] ?? fallback;
689
+ const key = path.slice(0, idx);
690
+ const nextPath = path.slice(idx + 1);
691
+ const checkValue = obj?.[key]?.[nextPath];
692
+ if (checkValue) return checkValue;
693
+ return getDotPath(obj?.[key], nextPath, fallback) ?? fallback;
694
+ }
695
+ //#endregion
696
+ //#region src/pick.ts
697
+ const pick = (obj, paths) => {
698
+ const result = {};
699
+ traverse(obj, ({ path, value }) => {
700
+ if (paths.includes(path)) deepSet(result, splitDotPath(path), value);
701
+ });
702
+ return result;
703
+ };
704
+ //#endregion
705
+ //#region src/property-priority.ts
706
+ /**
707
+ * Slightly modified from https://github.com/facebook/stylex/blob/main/packages/%40stylexjs/babel-plugin/src/shared/utils/property-priorities.js
708
+ * License: MIT
709
+ */
710
+ const longHandPhysical = /* @__PURE__ */ new Set();
711
+ const longHandLogical = /* @__PURE__ */ new Set();
712
+ const shorthandsOfLonghands = /* @__PURE__ */ new Set();
713
+ const shorthandsOfShorthands = /* @__PURE__ */ new Set();
714
+ longHandLogical.add("backgroundBlendMode");
715
+ longHandLogical.add("isolation");
716
+ longHandLogical.add("mixBlendMode");
717
+ shorthandsOfShorthands.add("animation");
718
+ longHandLogical.add("animationComposition");
719
+ longHandLogical.add("animationDelay");
720
+ longHandLogical.add("animationDirection");
721
+ longHandLogical.add("animationDuration");
722
+ longHandLogical.add("animationFillMode");
723
+ longHandLogical.add("animationIterationCount");
724
+ longHandLogical.add("animationName");
725
+ longHandLogical.add("animationPlayState");
726
+ shorthandsOfLonghands.add("animationRange");
727
+ longHandLogical.add("animationRangeEnd");
728
+ longHandLogical.add("animationRangeStart");
729
+ longHandLogical.add("animationTimingFunction");
730
+ longHandLogical.add("animationTimeline");
731
+ shorthandsOfLonghands.add("scrollTimeline");
732
+ longHandLogical.add("scrollTimelineAxis");
733
+ longHandLogical.add("scrollTimelineName");
734
+ longHandLogical.add("timelineScope");
735
+ shorthandsOfLonghands.add("viewTimeline");
736
+ longHandLogical.add("viewTimelineAxis");
737
+ longHandLogical.add("viewTimelineInset");
738
+ longHandLogical.add("viewTimelineName");
739
+ shorthandsOfShorthands.add("background");
740
+ longHandLogical.add("backgroundAttachment");
741
+ longHandLogical.add("backgroundClip");
742
+ longHandLogical.add("backgroundColor");
743
+ longHandLogical.add("backgroundImage");
744
+ longHandLogical.add("backgroundOrigin");
745
+ longHandLogical.add("backgroundRepeat");
746
+ longHandLogical.add("backgroundSize");
747
+ shorthandsOfLonghands.add("backgroundPosition");
748
+ longHandLogical.add("backgroundPositionX");
749
+ longHandLogical.add("backgroundPositionY");
750
+ shorthandsOfShorthands.add("border");
751
+ shorthandsOfLonghands.add("borderColor");
752
+ shorthandsOfLonghands.add("borderStyle");
753
+ shorthandsOfLonghands.add("borderWidth");
754
+ shorthandsOfShorthands.add("borderBlock");
755
+ longHandLogical.add("borderBlockColor");
756
+ longHandLogical.add("borderBlockStyle");
757
+ longHandLogical.add("borderBlockWidth");
758
+ shorthandsOfLonghands.add("borderBlockStart");
759
+ shorthandsOfLonghands.add("borderTop");
760
+ longHandLogical.add("borderBlockStartColor");
761
+ longHandPhysical.add("borderTopColor");
762
+ longHandLogical.add("borderBlockStartStyle");
763
+ longHandPhysical.add("borderTopStyle");
764
+ longHandLogical.add("borderBlockStartWidth");
765
+ longHandPhysical.add("borderTopWidth");
766
+ shorthandsOfLonghands.add("borderBlockEnd");
767
+ shorthandsOfLonghands.add("borderBottom");
768
+ longHandLogical.add("borderBlockEndColor");
769
+ longHandPhysical.add("borderBottomColor");
770
+ longHandLogical.add("borderBlockEndStyle");
771
+ longHandPhysical.add("borderBottomStyle");
772
+ longHandLogical.add("borderBlockEndWidth");
773
+ longHandPhysical.add("borderBottomWidth");
774
+ shorthandsOfShorthands.add("borderInline");
775
+ shorthandsOfLonghands.add("borderInlineColor");
776
+ shorthandsOfLonghands.add("borderInlineStyle");
777
+ shorthandsOfLonghands.add("borderInlineWidth");
778
+ shorthandsOfLonghands.add("borderInlineStart");
779
+ shorthandsOfLonghands.add("borderLeft");
780
+ longHandLogical.add("borderInlineStartColor");
781
+ longHandPhysical.add("borderLeftColor");
782
+ longHandLogical.add("borderInlineStartStyle");
783
+ longHandPhysical.add("borderLeftStyle");
784
+ longHandLogical.add("borderInlineStartWidth");
785
+ longHandPhysical.add("borderLeftWidth");
786
+ shorthandsOfLonghands.add("borderInlineEnd");
787
+ shorthandsOfLonghands.add("borderRight");
788
+ longHandLogical.add("borderInlineEndColor");
789
+ longHandPhysical.add("borderRightColor");
790
+ longHandLogical.add("borderInlineEndStyle");
791
+ longHandPhysical.add("borderRightStyle");
792
+ longHandLogical.add("borderInlineEndWidth");
793
+ longHandPhysical.add("borderRightWidth");
794
+ shorthandsOfLonghands.add("borderImage");
795
+ longHandLogical.add("borderImageOutset");
796
+ longHandLogical.add("borderImageRepeat");
797
+ longHandLogical.add("borderImageSlice");
798
+ longHandLogical.add("borderImageSource");
799
+ longHandLogical.add("borderImageWidth");
800
+ shorthandsOfLonghands.add("borderRadius");
801
+ longHandLogical.add("borderStartEndRadius");
802
+ longHandLogical.add("borderStartStartRadius");
803
+ longHandLogical.add("borderEndEndRadius");
804
+ longHandLogical.add("borderEndStartRadius");
805
+ longHandPhysical.add("borderTopLeftRadius");
806
+ longHandPhysical.add("borderTopRightRadius");
807
+ longHandPhysical.add("borderBottomLeftRadius");
808
+ longHandPhysical.add("borderBottomRightRadius");
809
+ longHandLogical.add("boxShadow");
810
+ longHandLogical.add("accentColor");
811
+ longHandLogical.add("appearance");
812
+ longHandLogical.add("aspectRatio");
813
+ shorthandsOfLonghands.add("caret");
814
+ longHandLogical.add("caretColor");
815
+ longHandLogical.add("caretShape");
816
+ longHandLogical.add("cursor");
817
+ longHandLogical.add("imeMode");
818
+ longHandLogical.add("inputSecurity");
819
+ shorthandsOfLonghands.add("outline");
820
+ longHandLogical.add("outlineColor");
821
+ longHandLogical.add("outlineOffset");
822
+ longHandLogical.add("outlineStyle");
823
+ longHandLogical.add("outlineWidth");
824
+ longHandLogical.add("pointerEvents");
825
+ longHandLogical.add("resize");
826
+ longHandLogical.add("textOverflow");
827
+ longHandLogical.add("userSelect");
828
+ shorthandsOfLonghands.add("gridGap");
829
+ shorthandsOfLonghands.add("gap");
830
+ longHandLogical.add("gridRowGap");
831
+ longHandLogical.add("rowGap");
832
+ longHandLogical.add("gridColumnGap");
833
+ longHandLogical.add("columnGap");
834
+ shorthandsOfLonghands.add("placeContent");
835
+ longHandLogical.add("alignContent");
836
+ longHandLogical.add("justifyContent");
837
+ shorthandsOfLonghands.add("placeItems");
838
+ longHandLogical.add("alignItems");
839
+ longHandLogical.add("justifyItems");
840
+ shorthandsOfLonghands.add("placeSelf");
841
+ longHandLogical.add("alignSelf");
842
+ longHandLogical.add("justifySelf");
843
+ longHandLogical.add("boxSizing");
844
+ longHandLogical.add("fieldSizing");
845
+ longHandLogical.add("blockSize");
846
+ longHandPhysical.add("height");
847
+ longHandLogical.add("inlineSize");
848
+ longHandPhysical.add("width");
849
+ longHandLogical.add("maxBlockSize");
850
+ longHandPhysical.add("maxHeight");
851
+ longHandLogical.add("maxInlineSize");
852
+ longHandPhysical.add("maxWidth");
853
+ longHandLogical.add("minBlockSize");
854
+ longHandPhysical.add("minHeight");
855
+ longHandLogical.add("minInlineSize");
856
+ longHandPhysical.add("minWidth");
857
+ shorthandsOfShorthands.add("margin");
858
+ shorthandsOfLonghands.add("marginBlock");
859
+ longHandLogical.add("marginBlockStart");
860
+ longHandPhysical.add("marginTop");
861
+ longHandLogical.add("marginBlockEnd");
862
+ longHandPhysical.add("marginBottom");
863
+ shorthandsOfLonghands.add("marginInline");
864
+ longHandLogical.add("marginInlineStart");
865
+ longHandPhysical.add("marginLeft");
866
+ longHandLogical.add("marginInlineEnd");
867
+ longHandPhysical.add("marginRight");
868
+ longHandLogical.add("marginTrim");
869
+ shorthandsOfLonghands.add("overscrollBehavior");
870
+ longHandLogical.add("overscrollBehaviorBlock");
871
+ longHandPhysical.add("overscrollBehaviorY");
872
+ longHandLogical.add("overscrollBehaviorInline");
873
+ longHandPhysical.add("overscrollBehaviorX");
874
+ shorthandsOfShorthands.add("padding");
875
+ shorthandsOfLonghands.add("paddingBlock");
876
+ longHandLogical.add("paddingBlockStart");
877
+ longHandPhysical.add("paddingTop");
878
+ longHandLogical.add("paddingBlockEnd");
879
+ longHandPhysical.add("paddingBottom");
880
+ shorthandsOfLonghands.add("paddingInline");
881
+ longHandLogical.add("paddingInlineStart");
882
+ longHandPhysical.add("paddingLeft");
883
+ longHandLogical.add("paddingInlineEnd");
884
+ longHandPhysical.add("paddingRight");
885
+ longHandLogical.add("visibility");
886
+ longHandLogical.add("color");
887
+ longHandLogical.add("colorScheme");
888
+ longHandLogical.add("forcedColorAdjust");
889
+ longHandLogical.add("opacity");
890
+ longHandLogical.add("printColorAdjust");
891
+ shorthandsOfLonghands.add("columns");
892
+ longHandLogical.add("columnCount");
893
+ longHandLogical.add("columnWidth");
894
+ longHandLogical.add("columnFill");
895
+ longHandLogical.add("columnSpan");
896
+ shorthandsOfLonghands.add("columnRule");
897
+ longHandLogical.add("columnRuleColor");
898
+ longHandLogical.add("columnRuleStyle");
899
+ longHandLogical.add("columnRuleWidth");
900
+ longHandLogical.add("contain");
901
+ shorthandsOfLonghands.add("containIntrinsicSize");
902
+ longHandLogical.add("containIntrinsicBlockSize");
903
+ longHandLogical.add("containIntrinsicWidth");
904
+ longHandLogical.add("containIntrinsicHeight");
905
+ longHandLogical.add("containIntrinsicInlineSize");
906
+ shorthandsOfLonghands.add("container");
907
+ longHandLogical.add("containerName");
908
+ longHandLogical.add("containerType");
909
+ longHandLogical.add("contentVisibility");
910
+ longHandLogical.add("counterIncrement");
911
+ longHandLogical.add("counterReset");
912
+ longHandLogical.add("counterSet");
913
+ longHandLogical.add("display");
914
+ shorthandsOfLonghands.add("flex");
915
+ longHandLogical.add("flexBasis");
916
+ longHandLogical.add("flexGrow");
917
+ longHandLogical.add("flexShrink");
918
+ shorthandsOfLonghands.add("flexFlow");
919
+ longHandLogical.add("flexDirection");
920
+ longHandLogical.add("flexWrap");
921
+ longHandLogical.add("order");
922
+ shorthandsOfShorthands.add("font");
923
+ longHandLogical.add("fontFamily");
924
+ longHandLogical.add("fontSize");
925
+ longHandLogical.add("fontStretch");
926
+ longHandLogical.add("fontStyle");
927
+ longHandLogical.add("fontWeight");
928
+ longHandLogical.add("lineHeight");
929
+ shorthandsOfLonghands.add("fontVariant");
930
+ longHandLogical.add("fontVariantAlternates");
931
+ longHandLogical.add("fontVariantCaps");
932
+ longHandLogical.add("fontVariantEastAsian");
933
+ longHandLogical.add("fontVariantEmoji");
934
+ longHandLogical.add("fontVariantLigatures");
935
+ longHandLogical.add("fontVariantNumeric");
936
+ longHandLogical.add("fontVariantPosition");
937
+ longHandLogical.add("fontFeatureSettings");
938
+ longHandLogical.add("fontKerning");
939
+ longHandLogical.add("fontLanguageOverride");
940
+ longHandLogical.add("fontOpticalSizing");
941
+ longHandLogical.add("fontPalette");
942
+ longHandLogical.add("fontVariationSettings");
943
+ longHandLogical.add("fontSizeAdjust");
944
+ longHandLogical.add("fontSmooth");
945
+ longHandLogical.add("fontSynthesisPosition");
946
+ longHandLogical.add("fontSynthesisSmallCaps");
947
+ longHandLogical.add("fontSynthesisStyle");
948
+ longHandLogical.add("fontSynthesisWeight");
949
+ shorthandsOfLonghands.add("fontSynthesis");
950
+ longHandLogical.add("lineHeightStep");
951
+ longHandLogical.add("boxDecorationBreak");
952
+ longHandLogical.add("breakAfter");
953
+ longHandLogical.add("breakBefore");
954
+ longHandLogical.add("breakInside");
955
+ longHandLogical.add("orphans");
956
+ longHandLogical.add("widows");
957
+ longHandLogical.add("content");
958
+ longHandLogical.add("quotes");
959
+ shorthandsOfShorthands.add("grid");
960
+ longHandLogical.add("gridAutoFlow");
961
+ longHandLogical.add("gridAutoRows");
962
+ longHandLogical.add("gridAutoColumns");
963
+ shorthandsOfShorthands.add("gridTemplate");
964
+ shorthandsOfLonghands.add("gridTemplateAreas");
965
+ longHandLogical.add("gridTemplateColumns");
966
+ longHandLogical.add("gridTemplateRows");
967
+ shorthandsOfShorthands.add("gridArea");
968
+ shorthandsOfLonghands.add("gridRow");
969
+ longHandLogical.add("gridRowStart");
970
+ longHandLogical.add("gridRowEnd");
971
+ shorthandsOfLonghands.add("gridColumn");
972
+ longHandLogical.add("gridColumnStart");
973
+ longHandLogical.add("gridColumnEnd");
974
+ longHandLogical.add("alignTracks");
975
+ longHandLogical.add("justifyTracks");
976
+ longHandLogical.add("masonryAutoFlow");
977
+ longHandLogical.add("imageOrientation");
978
+ longHandLogical.add("imageRendering");
979
+ longHandLogical.add("imageResolution");
980
+ longHandLogical.add("objectFit");
981
+ longHandLogical.add("objectPosition");
982
+ longHandLogical.add("initialLetter");
983
+ longHandLogical.add("initialLetterAlign");
984
+ shorthandsOfLonghands.add("listStyle");
985
+ longHandLogical.add("listStyleImage");
986
+ longHandLogical.add("listStylePosition");
987
+ longHandLogical.add("listStyleType");
988
+ longHandLogical.add("clip");
989
+ longHandLogical.add("clipPath");
990
+ shorthandsOfLonghands.add("mask");
991
+ longHandLogical.add("maskClip");
992
+ longHandLogical.add("maskComposite");
993
+ longHandLogical.add("maskImage");
994
+ longHandLogical.add("maskMode");
995
+ longHandLogical.add("maskOrigin");
996
+ longHandLogical.add("maskPosition");
997
+ longHandLogical.add("maskRepeat");
998
+ longHandLogical.add("maskSize");
999
+ longHandLogical.add("maskType");
1000
+ shorthandsOfLonghands.add("maskBorder");
1001
+ longHandLogical.add("maskBorderMode");
1002
+ longHandLogical.add("maskBorderOutset");
1003
+ longHandLogical.add("maskBorderRepeat");
1004
+ longHandLogical.add("maskBorderSlice");
1005
+ longHandLogical.add("maskBorderSource");
1006
+ longHandLogical.add("maskBorderWidth");
1007
+ shorthandsOfShorthands.add("all");
1008
+ longHandLogical.add("textRendering");
1009
+ longHandLogical.add("zoom");
1010
+ shorthandsOfLonghands.add("offset");
1011
+ longHandLogical.add("offsetAnchor");
1012
+ longHandLogical.add("offsetDistance");
1013
+ longHandLogical.add("offsetPath");
1014
+ longHandLogical.add("offsetPosition");
1015
+ longHandLogical.add("offsetRotate");
1016
+ longHandLogical.add("WebkitBoxOrient");
1017
+ longHandLogical.add("WebkitLineClamp");
1018
+ longHandPhysical.add("lineClamp");
1019
+ longHandPhysical.add("maxLines");
1020
+ longHandLogical.add("blockOverflow");
1021
+ shorthandsOfLonghands.add("overflow");
1022
+ longHandLogical.add("overflowBlock");
1023
+ longHandPhysical.add("overflowY");
1024
+ longHandLogical.add("overflowInline");
1025
+ longHandPhysical.add("overflowX");
1026
+ longHandLogical.add("overflowClipMargin");
1027
+ longHandLogical.add("scrollGutter");
1028
+ longHandLogical.add("scrollBehavior");
1029
+ longHandLogical.add("page");
1030
+ longHandLogical.add("pageBreakAfter");
1031
+ longHandLogical.add("pageBreakBefore");
1032
+ longHandLogical.add("pageBreakInside");
1033
+ shorthandsOfShorthands.add("inset");
1034
+ shorthandsOfLonghands.add("insetBlock");
1035
+ longHandLogical.add("insetBlockStart");
1036
+ longHandPhysical.add("top");
1037
+ longHandLogical.add("insetBlockEnd");
1038
+ longHandPhysical.add("bottom");
1039
+ shorthandsOfLonghands.add("insetInline");
1040
+ longHandLogical.add("insetInlineStart");
1041
+ longHandPhysical.add("left");
1042
+ longHandLogical.add("insetInlineEnd");
1043
+ longHandPhysical.add("right");
1044
+ longHandLogical.add("clear");
1045
+ longHandLogical.add("float");
1046
+ longHandLogical.add("overlay");
1047
+ longHandLogical.add("position");
1048
+ longHandLogical.add("zIndex");
1049
+ longHandLogical.add("rubyAlign");
1050
+ longHandLogical.add("rubyMerge");
1051
+ longHandLogical.add("rubyPosition");
1052
+ longHandLogical.add("overflowAnchor");
1053
+ shorthandsOfShorthands.add("scrollMargin");
1054
+ shorthandsOfLonghands.add("scrollMarginBlock");
1055
+ longHandLogical.add("scrollMarginBlockStart");
1056
+ longHandPhysical.add("scrollMarginTop");
1057
+ longHandLogical.add("scrollMarginBlockEnd");
1058
+ longHandPhysical.add("scrollMarginBottom");
1059
+ shorthandsOfLonghands.add("scrollMarginInline");
1060
+ longHandLogical.add("scrollMarginInlineStart");
1061
+ longHandPhysical.add("scrollMarginLeft");
1062
+ longHandLogical.add("scrollMarginInlineEnd");
1063
+ longHandPhysical.add("scrollMarginRight");
1064
+ shorthandsOfShorthands.add("scrollPadding");
1065
+ shorthandsOfLonghands.add("scrollPaddingBlock");
1066
+ longHandLogical.add("scrollPaddingBlockStart");
1067
+ longHandPhysical.add("scrollPaddingTop");
1068
+ longHandLogical.add("scrollPaddingBlockEnd");
1069
+ longHandPhysical.add("scrollPaddingBottom");
1070
+ shorthandsOfLonghands.add("scrollPaddingInline");
1071
+ longHandLogical.add("scrollPaddingInlineStart");
1072
+ longHandPhysical.add("scrollPaddingLeft");
1073
+ longHandLogical.add("scrollPaddingInlineEnd");
1074
+ longHandPhysical.add("scrollPaddingRight");
1075
+ longHandLogical.add("scrollSnapAlign");
1076
+ longHandLogical.add("scrollSnapStop");
1077
+ shorthandsOfLonghands.add("scrollSnapType");
1078
+ longHandLogical.add("scrollbarColor");
1079
+ longHandLogical.add("scrollbarWidth");
1080
+ longHandLogical.add("shapeImageThreshold");
1081
+ longHandLogical.add("shapeMargin");
1082
+ longHandLogical.add("shapeOutside");
1083
+ longHandLogical.add("azimuth");
1084
+ longHandLogical.add("borderCollapse");
1085
+ longHandLogical.add("borderSpacing");
1086
+ longHandLogical.add("captionSide");
1087
+ longHandLogical.add("emptyCells");
1088
+ longHandLogical.add("tableLayout");
1089
+ longHandLogical.add("verticalAlign");
1090
+ shorthandsOfLonghands.add("textDecoration");
1091
+ longHandLogical.add("textDecorationColor");
1092
+ longHandLogical.add("textDecorationLine");
1093
+ longHandLogical.add("textDecorationSkip");
1094
+ longHandLogical.add("textDecorationSkipInk");
1095
+ longHandLogical.add("textDecorationStyle");
1096
+ longHandLogical.add("textDecorationThickness");
1097
+ shorthandsOfLonghands.add("WebkitTextStroke");
1098
+ longHandLogical.add("WebkitTextStrokeColor");
1099
+ longHandLogical.add("WebkitTextStrokeWidth");
1100
+ longHandLogical.add("WebkitTextFillColor");
1101
+ shorthandsOfLonghands.add("textEmphasis");
1102
+ longHandLogical.add("textEmphasisColor");
1103
+ longHandLogical.add("textEmphasisPosition");
1104
+ longHandLogical.add("textEmphasisStyle");
1105
+ longHandLogical.add("textShadow");
1106
+ longHandLogical.add("textUnderlineOffset");
1107
+ longHandLogical.add("textUnderlinePosition");
1108
+ longHandLogical.add("hangingPunctuation");
1109
+ longHandLogical.add("hyphenateCharacter");
1110
+ longHandLogical.add("hyphenateLimitChars");
1111
+ longHandLogical.add("hyphens");
1112
+ longHandLogical.add("letterSpacing");
1113
+ longHandLogical.add("lineBreak");
1114
+ longHandLogical.add("overflowWrap");
1115
+ longHandLogical.add("paintOrder");
1116
+ longHandLogical.add("tabSize");
1117
+ longHandLogical.add("textAlign");
1118
+ longHandLogical.add("textAlignLast");
1119
+ longHandLogical.add("textIndent");
1120
+ longHandLogical.add("textJustify");
1121
+ longHandLogical.add("textSizeAdjust");
1122
+ longHandLogical.add("textTransform");
1123
+ shorthandsOfLonghands.add("textWrap");
1124
+ longHandLogical.add("textWrapMode");
1125
+ longHandLogical.add("textWrapStyle");
1126
+ longHandLogical.add("whiteSpace");
1127
+ longHandLogical.add("whiteSpaceCollapse");
1128
+ longHandLogical.add("whiteSpaceTrim");
1129
+ longHandLogical.add("wordBreak");
1130
+ longHandLogical.add("wordSpacing");
1131
+ longHandLogical.add("wordWrap");
1132
+ longHandLogical.add("backfaceVisibility");
1133
+ longHandLogical.add("perspective");
1134
+ longHandLogical.add("perspectiveOrigin");
1135
+ longHandLogical.add("rotate");
1136
+ longHandLogical.add("scale");
1137
+ longHandLogical.add("transform");
1138
+ longHandLogical.add("transformBox");
1139
+ longHandLogical.add("transformOrigin");
1140
+ longHandLogical.add("transformStyle");
1141
+ longHandLogical.add("translate");
1142
+ shorthandsOfLonghands.add("transition");
1143
+ longHandLogical.add("transitionBehavior");
1144
+ longHandLogical.add("transitionDelay");
1145
+ longHandLogical.add("transitionDuration");
1146
+ longHandLogical.add("transitionProperty");
1147
+ longHandLogical.add("transitionTimingFunction");
1148
+ longHandLogical.add("viewTransitionName");
1149
+ longHandLogical.add("willChange");
1150
+ longHandLogical.add("direction");
1151
+ longHandLogical.add("textCombineUpright");
1152
+ longHandLogical.add("textOrientation");
1153
+ longHandLogical.add("unicodeBidi");
1154
+ longHandLogical.add("writingMode");
1155
+ longHandLogical.add("backdropFilter");
1156
+ longHandLogical.add("filter");
1157
+ longHandLogical.add("mathDepth");
1158
+ longHandLogical.add("mathShift");
1159
+ longHandLogical.add("mathStyle");
1160
+ longHandLogical.add("touchAction");
1161
+ function getPropertyPriority(key) {
1162
+ if (key === "all") return 0;
1163
+ if (key.startsWith("--")) return 1;
1164
+ if (longHandPhysical.has(key)) return 4e3;
1165
+ if (longHandLogical.has(key)) return 3e3;
1166
+ if (shorthandsOfLonghands.has(key)) return 2e3;
1167
+ if (shorthandsOfShorthands.has(key)) return 1e3;
1168
+ return 3e3;
1169
+ }
1170
+ //#endregion
1171
+ //#region src/regex.ts
1172
+ const createRegex = (item) => {
1173
+ const regex = item.map((item) => typeof item === "string" ? `^${item}$` : item.source).join("|");
1174
+ return new RegExp(regex);
1175
+ };
1176
+ //#endregion
1177
+ //#region src/serialize.ts
1178
+ const stringifyJson = (config) => {
1179
+ return JSON.stringify(config, (_key, value) => {
1180
+ if (typeof value === "function") return value.toString();
1181
+ return value;
1182
+ });
1183
+ };
1184
+ const parseJson = (config) => {
1185
+ return JSON.parse(config);
1186
+ };
1187
+ //#endregion
1188
+ //#region src/slot.ts
1189
+ const getSlotRecipes = (recipe = {}) => {
1190
+ const init = (slot) => ({
1191
+ className: [recipe.className, slot].filter(Boolean).join("__"),
1192
+ base: recipe.base?.[slot] ?? {},
1193
+ variants: {},
1194
+ defaultVariants: recipe.defaultVariants ?? {},
1195
+ compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
1196
+ });
1197
+ const recipeParts = (recipe.slots ?? []).map((slot) => [slot, init(slot)]);
1198
+ for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) recipeParts.forEach(([slot, slotRecipe]) => {
1199
+ slotRecipe.variants[variantsKey] ??= {};
1200
+ slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
1201
+ });
1202
+ return Object.fromEntries(recipeParts);
1203
+ };
1204
+ const getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({
1205
+ ...compoundVariant,
1206
+ css: compoundVariant.css[slotName]
1207
+ }));
1208
+ //#endregion
1209
+ //#region src/split-props.ts
1210
+ function splitProps(props, ...keys) {
1211
+ const descriptors = Object.getOwnPropertyDescriptors(props);
1212
+ const dKeys = Object.keys(descriptors);
1213
+ const split = (k) => {
1214
+ const clone = {};
1215
+ for (let i = 0; i < k.length; i++) {
1216
+ const key = k[i];
1217
+ if (descriptors[key]) {
1218
+ Object.defineProperty(clone, key, descriptors[key]);
1219
+ delete descriptors[key];
1220
+ }
1221
+ }
1222
+ return clone;
1223
+ };
1224
+ const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
1225
+ return keys.map(fn).concat(split(dKeys));
1226
+ }
1227
+ //#endregion
1228
+ //#region src/to-json.ts
1229
+ function mapToJson(map) {
1230
+ const obj = {};
1231
+ map.forEach((value, key) => {
1232
+ if (value instanceof Map) obj[key] = Object.fromEntries(value);
1233
+ else obj[key] = value;
1234
+ });
1235
+ return obj;
1236
+ }
1237
+ //#endregion
1238
+ //#region src/typegen.ts
1239
+ function unionType(values, opts = {}) {
1240
+ const { fallback, stringify = JSON.stringify } = opts;
1241
+ const arr = Array.from(values);
1242
+ if (fallback != null && !arr.length) return fallback;
1243
+ return arr.map((v) => stringify(v)).join(" | ");
1244
+ }
1245
+ //#endregion
1246
+ //#region src/uniq.ts
1247
+ const uniq = (...items) => {
1248
+ const set = items.reduce((acc, currItems) => {
1249
+ if (currItems) currItems.forEach((item) => acc.add(item));
1250
+ return acc;
1251
+ }, /* @__PURE__ */ new Set([]));
1252
+ return Array.from(set);
1253
+ };
1254
+ //#endregion
1255
+ //#region src/unit-conversion.ts
1256
+ const BASE_FONT_SIZE = 16;
1257
+ const UNIT_PX = "px";
1258
+ const UNIT_EM = "em";
1259
+ const UNIT_REM = "rem";
1260
+ const DIGIT_REGEX = new RegExp(String.raw`-?\d+(?:\.\d+|\d*)`);
1261
+ const UNIT_REGEX = new RegExp(`${UNIT_PX}|${UNIT_EM}|${UNIT_REM}`);
1262
+ const VALUE_REGEX = new RegExp(`${DIGIT_REGEX.source}(${UNIT_REGEX.source})`);
1263
+ function getUnit(value = "") {
1264
+ return value.match(VALUE_REGEX)?.[1];
1265
+ }
1266
+ function toPx(value = "") {
1267
+ if (typeof value === "number") return `${value}px`;
1268
+ const unit = getUnit(value);
1269
+ if (!unit) return value;
1270
+ if (unit === UNIT_PX) return value;
1271
+ if (unit === UNIT_EM || unit === UNIT_REM) return `${parseFloat(value) * BASE_FONT_SIZE}${UNIT_PX}`;
1272
+ }
1273
+ function toEm(value = "", fontSize = BASE_FONT_SIZE) {
1274
+ const unit = getUnit(value);
1275
+ if (!unit) return value;
1276
+ if (unit === UNIT_EM) return value;
1277
+ if (unit === UNIT_PX) return `${parseFloat(value) / fontSize}${UNIT_EM}`;
1278
+ if (unit === UNIT_REM) return `${parseFloat(value) * BASE_FONT_SIZE / fontSize}${UNIT_EM}`;
1279
+ }
1280
+ function toRem(value = "") {
1281
+ const unit = getUnit(value);
1282
+ if (!unit) return value;
1283
+ if (unit === UNIT_REM) return value;
1284
+ if (unit === UNIT_EM) return `${parseFloat(value)}${UNIT_REM}`;
1285
+ if (unit === UNIT_PX) return `${parseFloat(value) / BASE_FONT_SIZE}${UNIT_REM}`;
1286
+ }
1287
+ //#endregion
1288
+ exports.BAMBOO_CONFIG_NAME = BAMBOO_CONFIG_NAME;
1289
+ exports.BambooError = BambooError;
1290
+ exports.CacheMap = CacheMap;
1291
+ exports.assign = assign;
1292
+ exports.astish = astish;
1293
+ exports.calc = calc;
1294
+ exports.camelCaseProperty = camelCaseProperty;
1295
+ exports.capitalize = capitalize;
1296
+ exports.compact = compact;
1297
+ exports.createCss = createCss;
1298
+ exports.createMergeCss = createMergeCss;
1299
+ exports.createRegex = createRegex;
1300
+ exports.cssVar = cssVar;
1301
+ exports.dashCase = dashCase;
1302
+ exports.deepSet = deepSet;
1303
+ exports.entries = entries;
1304
+ exports.esc = esc;
1305
+ exports.filterBaseConditions = filterBaseConditions;
1306
+ exports.flatten = flatten;
1307
+ exports.fromEntries = fromEntries;
1308
+ exports.getArbitraryValue = getArbitraryValue;
1309
+ exports.getDotPath = getDotPath;
1310
+ exports.getNegativePath = getNegativePath;
1311
+ exports.getOrCreateSet = getOrCreateSet;
1312
+ exports.getPatternStyles = getPatternStyles;
1313
+ exports.getPropertyPriority = getPropertyPriority;
1314
+ exports.getSlotCompoundVariant = getSlotCompoundVariant;
1315
+ exports.getSlotRecipes = getSlotRecipes;
1316
+ exports.getUnit = getUnit;
1317
+ exports.hypenateProperty = hypenateProperty;
1318
+ exports.isBaseCondition = isBaseCondition;
1319
+ exports.isBoolean = isBoolean;
1320
+ exports.isCssFunction = isCssFunction;
1321
+ exports.isCssUnit = isCssUnit;
1322
+ exports.isCssVar = isCssVar;
1323
+ exports.isFunction = isFunction;
1324
+ exports.isImportant = isImportant;
1325
+ exports.isObject = isObject;
1326
+ exports.isObjectOrArray = isObjectOrArray;
1327
+ exports.isString = isString;
1328
+ exports.isSymbol = isSymbol;
1329
+ exports.mapEntries = mapEntries;
1330
+ exports.mapObject = mapObject;
1331
+ exports.mapToJson = mapToJson;
1332
+ exports.markImportant = markImportant;
1333
+ exports.memo = memo;
1334
+ exports.mergeAndConcat = mergeAndConcat;
1335
+ exports.mergeProps = mergeProps;
1336
+ exports.mergeWith = mergeWith;
1337
+ exports.normalizeStyleObject = normalizeStyleObject;
1338
+ exports.omit = omit;
1339
+ exports.parseJson = parseJson;
1340
+ exports.patternFns = patternFns;
1341
+ exports.pick = pick;
1342
+ exports.splitBy = splitBy;
1343
+ exports.splitDotPath = splitDotPath;
1344
+ exports.splitProps = splitProps;
1345
+ exports.stringifyJson = stringifyJson;
1346
+ exports.toEm = toEm;
1347
+ exports.toHash = toHash;
1348
+ exports.toPx = toPx;
1349
+ exports.toRem = toRem;
1350
+ exports.toResponsiveObject = toResponsiveObject;
1351
+ exports.traverse = traverse;
1352
+ exports.uncapitalize = uncapitalize;
1353
+ exports.unionType = unionType;
1354
+ exports.uniq = uniq;
1355
+ exports.walkObject = walkObject;
1356
+ exports.withoutImportant = withoutImportant;
1357
+ exports.withoutSpace = withoutSpace;