@homedev/objector 1.2.66 → 1.3.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/dist/index.d.ts +46 -311
- package/dist/index.js +22 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,58 +1,3 @@
|
|
|
1
|
-
declare const AsyncFunction_2: FunctionConstructor;
|
|
2
|
-
export { AsyncFunction_2 as AsyncFunction }
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Maps an array asynchronously using Promise.all for parallel execution
|
|
6
|
-
* @typeParam T - Type of input array items
|
|
7
|
-
* @typeParam U - Type of async result items
|
|
8
|
-
* @param arr - Array to map
|
|
9
|
-
* @param fn - Async mapping function
|
|
10
|
-
* @returns Promise of mapped array
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export declare const asyncMap: <T, U>(arr: T[], fn: (item: T, index: number, array: T[]) => Promise<U>) => Promise<U[]>;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Converts a string to camelCase (lowerCamelCase).
|
|
17
|
-
* Handles spaces, underscores, and hyphens as word separators.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* camel('hello_world') // 'helloWorld'
|
|
21
|
-
* camel('hello world') // 'helloWorld'
|
|
22
|
-
* camel('HelloWorld') // 'helloWorld'
|
|
23
|
-
*
|
|
24
|
-
* @param v - The string to convert
|
|
25
|
-
* @returns The string in camelCase
|
|
26
|
-
*/
|
|
27
|
-
export declare const camel: (v: string) => string;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Converts a string to Capital Case (each word capitalized, spaces preserved).
|
|
31
|
-
* Only capitalizes words following spaces.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* capital('hello world') // 'Hello World'
|
|
35
|
-
* capital('hello_world') // 'hello_World'
|
|
36
|
-
*
|
|
37
|
-
* @param v - The string to convert
|
|
38
|
-
* @returns The string with each space-separated word capitalized
|
|
39
|
-
*/
|
|
40
|
-
export declare const capital: (v: string) => string;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Changes the case of a string to uppercase, lowercase, or returns unchanged.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* changeCase('Hello', 'upper') // 'HELLO'
|
|
47
|
-
* changeCase('Hello', 'lower') // 'hello'
|
|
48
|
-
* changeCase('Hello') // 'Hello'
|
|
49
|
-
*
|
|
50
|
-
* @param v - The string to transform
|
|
51
|
-
* @param arg - The case type: 'upper', 'lower', or undefined to return unchanged
|
|
52
|
-
* @returns The transformed string
|
|
53
|
-
*/
|
|
54
|
-
export declare const changeCase: (v: string, arg?: string) => string;
|
|
55
|
-
|
|
56
1
|
/**
|
|
57
2
|
* @public
|
|
58
3
|
*/
|
|
@@ -63,27 +8,26 @@ export declare const decoder: (options?: DecoderOptions) => (_: any, ctx: ClassM
|
|
|
63
8
|
declare type DecoderOptions = ObjectorDecoratorOptions;
|
|
64
9
|
|
|
65
10
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
72
|
-
* @
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @throws Error if value is undefined
|
|
84
|
-
* @public
|
|
11
|
+
* Guards against undefined and null values.
|
|
12
|
+
* Throws an error if the value is nullish, otherwise returns the value.
|
|
13
|
+
*
|
|
14
|
+
* @param value - The value to check
|
|
15
|
+
* @param message - Custom error message (default: 'Value is undefined')
|
|
16
|
+
* @returns The value if it is not nullish
|
|
17
|
+
* @throws {Error} When value is undefined or null
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const value = defined(maybeUndefined, 'Required value missing')
|
|
22
|
+
* // value is guaranteed to be non-nullish here
|
|
23
|
+
*
|
|
24
|
+
* defined(0) // 0 (falsy but not nullish)
|
|
25
|
+
* defined(false) // false (falsy but not nullish)
|
|
26
|
+
* defined(null) // throws Error: Value is undefined
|
|
27
|
+
* ```
|
|
85
28
|
*/
|
|
86
|
-
|
|
29
|
+
declare function defined_2<T>(value: T | undefined | null, message?: string): T;
|
|
30
|
+
export { defined_2 as defined }
|
|
87
31
|
|
|
88
32
|
declare interface Encoder {
|
|
89
33
|
fn: (data: unknown, ...args: any[]) => string | Promise<string>;
|
|
@@ -166,23 +110,6 @@ declare interface FilePatternOptions {
|
|
|
166
110
|
map: (fileName: string, index: number, array: string[]) => Promise<any>;
|
|
167
111
|
}
|
|
168
112
|
|
|
169
|
-
/**
|
|
170
|
-
* Finds values in an object tree that match a predicate function.
|
|
171
|
-
*
|
|
172
|
-
* @public
|
|
173
|
-
* @param from - The object to search through
|
|
174
|
-
* @param cb - Predicate function that receives the path and value, returns true for matches
|
|
175
|
-
* @returns Array of matching values
|
|
176
|
-
*
|
|
177
|
-
* @example
|
|
178
|
-
* ```typescript
|
|
179
|
-
* const obj = { a: { b: 1 }, c: { d: 2 } }
|
|
180
|
-
* const results = await find(obj, (path, value) => value === 2)
|
|
181
|
-
* // results: [2]
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
export declare const find: (from: any, cb: (path: string, value: any) => boolean) => Promise<any[]>;
|
|
185
|
-
|
|
186
113
|
export declare const globMap: <T>(pattern: string | string[], options: FilePatternOptions) => Promise<T[] | T>;
|
|
187
114
|
|
|
188
115
|
/**
|
|
@@ -298,21 +225,6 @@ export declare const makeFieldProcessorMap: <T = unknown>(source: Record<keyof T
|
|
|
298
225
|
keys?: (keyof T)[];
|
|
299
226
|
}) => FieldProcessorMap;
|
|
300
227
|
|
|
301
|
-
/**
|
|
302
|
-
* @public
|
|
303
|
-
* @param source
|
|
304
|
-
* @param target
|
|
305
|
-
* @param options
|
|
306
|
-
*/
|
|
307
|
-
export declare const merge: (source: any, target: any, options?: MergeOptions) => void;
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* @public
|
|
311
|
-
* @param elements
|
|
312
|
-
* @param options
|
|
313
|
-
*/
|
|
314
|
-
export declare const mergeAll: (elements: any[], options?: MergeOptions) => any;
|
|
315
|
-
|
|
316
228
|
/**
|
|
317
229
|
* @public
|
|
318
230
|
*/
|
|
@@ -328,24 +240,6 @@ export declare interface MergeOptions {
|
|
|
328
240
|
mode?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => MergeMode | void;
|
|
329
241
|
}
|
|
330
242
|
|
|
331
|
-
/**
|
|
332
|
-
* Recursively navigates through an object tree, invoking a callback for each property.
|
|
333
|
-
* Supports various actions like replacing, deleting, or merging values during traversal.
|
|
334
|
-
* Includes circular reference detection to prevent infinite loops.
|
|
335
|
-
*
|
|
336
|
-
* Performance optimizations:
|
|
337
|
-
* - Caches static NavigateResult instances
|
|
338
|
-
* - Uses WeakSet for O(1) circular reference detection
|
|
339
|
-
* - Avoids Object.entries() to prevent array allocations
|
|
340
|
-
* - Optimizes switch statement order for common cases
|
|
341
|
-
*
|
|
342
|
-
* @public
|
|
343
|
-
* @param o - The object to navigate
|
|
344
|
-
* @param cb - Callback function invoked for each property
|
|
345
|
-
* @throws {Error} When attempting to replace the root object
|
|
346
|
-
*/
|
|
347
|
-
export declare const navigate: (o: any, cb: NavigateCallback) => Promise<void>;
|
|
348
|
-
|
|
349
243
|
/**
|
|
350
244
|
* @public
|
|
351
245
|
*/
|
|
@@ -399,18 +293,6 @@ export declare class NavigateResult {
|
|
|
399
293
|
static DeleteItem(skipSiblings?: boolean): NavigateResult;
|
|
400
294
|
}
|
|
401
295
|
|
|
402
|
-
/**
|
|
403
|
-
* Maps an array while filtering out null/undefined values (performance optimized)
|
|
404
|
-
* Combines filter and map operations to avoid double iteration
|
|
405
|
-
* @typeParam T - Type of input array items
|
|
406
|
-
* @typeParam U - Type of mapped result items
|
|
407
|
-
* @param arr - Array to map (can be undefined)
|
|
408
|
-
* @param fn - Mapping function
|
|
409
|
-
* @returns Mapped array with nulls/undefined filtered out, or empty array if input is undefined
|
|
410
|
-
* @public
|
|
411
|
-
*/
|
|
412
|
-
export declare const nonNullMap: <T, U>(arr: T[] | undefined, fn: (item: T, index: number, array: T[]) => U) => U[];
|
|
413
|
-
|
|
414
296
|
/**
|
|
415
297
|
* @public
|
|
416
298
|
*/
|
|
@@ -494,36 +376,6 @@ export declare interface Output {
|
|
|
494
376
|
class?: string;
|
|
495
377
|
}
|
|
496
378
|
|
|
497
|
-
/**
|
|
498
|
-
* Adds indentation to each line of a string.
|
|
499
|
-
* Useful for formatting multi-line text with consistent indentation.
|
|
500
|
-
*
|
|
501
|
-
* @example
|
|
502
|
-
* padBlock('hello\\nworld', 2) // ' hello\\n world'
|
|
503
|
-
* padBlock('a|b|c', 1, '|', '-') // '-a|-b|-c'
|
|
504
|
-
*
|
|
505
|
-
* @param str - The string to indent
|
|
506
|
-
* @param indent - The number of padding units to add
|
|
507
|
-
* @param separator - The separator between lines (default: '\\n')
|
|
508
|
-
* @param padder - The character to repeat for padding (default: ' ')
|
|
509
|
-
* @returns The indented string
|
|
510
|
-
*/
|
|
511
|
-
export declare const padBlock: (str: string, indent: number, separator?: string, padder?: string) => string;
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* Converts a string to PascalCase (UpperCamelCase).
|
|
515
|
-
* Handles spaces, underscores, and hyphens as word separators.
|
|
516
|
-
*
|
|
517
|
-
* @example
|
|
518
|
-
* pascal('hello_world') // 'HelloWorld'
|
|
519
|
-
* pascal('hello world') // 'HelloWorld'
|
|
520
|
-
* pascal('helloWorld') // 'HelloWorld'
|
|
521
|
-
*
|
|
522
|
-
* @param v - The string to convert
|
|
523
|
-
* @returns The string in PascalCase
|
|
524
|
-
*/
|
|
525
|
-
export declare const pascal: (v: string) => string;
|
|
526
|
-
|
|
527
379
|
/**
|
|
528
380
|
* @public
|
|
529
381
|
* @param obj
|
|
@@ -548,32 +400,6 @@ export declare const section: (options?: SectionOptions) => (_: any, ctx: ClassM
|
|
|
548
400
|
|
|
549
401
|
declare type SectionOptions = ObjectorDecoratorOptions;
|
|
550
402
|
|
|
551
|
-
/**
|
|
552
|
-
* Selects a value from a nested object using a path string with advanced querying capabilities
|
|
553
|
-
*
|
|
554
|
-
* Supports:
|
|
555
|
-
* - Dot notation: 'user.profile.name'
|
|
556
|
-
* - Array indexing: 'users.0' or 'users[0]'
|
|
557
|
-
* - Array filtering: 'users.[name=John].age'
|
|
558
|
-
* - References: 'users.\{activeUserId\}.name'
|
|
559
|
-
* - Optional paths: 'user.profile?.bio'
|
|
560
|
-
* - Default values: 'config.timeout?=5000'
|
|
561
|
-
*
|
|
562
|
-
* @public
|
|
563
|
-
* @param from - The root object to select from
|
|
564
|
-
* @param path - The path string to navigate
|
|
565
|
-
* @param options - Optional configuration
|
|
566
|
-
* @returns The selected value or undefined
|
|
567
|
-
*
|
|
568
|
-
* @example
|
|
569
|
-
* ```typescript
|
|
570
|
-
* const obj = { user: { name: 'Alice', age: 30 } }
|
|
571
|
-
* select(obj, 'user.name') // 'Alice'
|
|
572
|
-
* select(obj, 'user.email', { defaultValue: 'N/A' }) // 'N/A'
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
575
|
-
export declare const select: <T = any>(from: any, path: string, options?: SelectOptions) => T | undefined;
|
|
576
|
-
|
|
577
403
|
/**
|
|
578
404
|
* Options for configuring the select function behavior
|
|
579
405
|
* @public
|
|
@@ -595,122 +421,8 @@ export declare const sharedFunction: (options?: SharedFunctionOptions) => (_: an
|
|
|
595
421
|
|
|
596
422
|
declare type SharedFunctionOptions = ObjectorDecoratorOptions;
|
|
597
423
|
|
|
598
|
-
/**
|
|
599
|
-
* Converts a string to snake_case or custom_case.
|
|
600
|
-
* Inserts the separator between lowercase and uppercase characters.
|
|
601
|
-
*
|
|
602
|
-
* @example
|
|
603
|
-
* snake('helloWorld', '_') // 'hello_world'
|
|
604
|
-
* snake('HelloWorld', '-') // 'hello-world'
|
|
605
|
-
* snake('hello world', '_') // 'hello_world'
|
|
606
|
-
*
|
|
607
|
-
* @param v - The string to convert
|
|
608
|
-
* @param separator - The separator to use between words (default: '_')
|
|
609
|
-
* @returns The string in snake case with the specified separator
|
|
610
|
-
*/
|
|
611
|
-
export declare const snake: (v: string, separator?: string) => string;
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* Sorts an array by a selector function with custom comparison
|
|
615
|
-
* Uses a shallow copy to avoid mutating the original array
|
|
616
|
-
* @typeParam T - Type of array items
|
|
617
|
-
* @typeParam U - Type of comparison values
|
|
618
|
-
* @param arr - Array to sort
|
|
619
|
-
* @param selector - Function to extract comparison value from item
|
|
620
|
-
* @param compare - Comparison function (default: numeric comparison)
|
|
621
|
-
* @returns New sorted array
|
|
622
|
-
* @public
|
|
623
|
-
*/
|
|
624
|
-
export declare const sortBy: <T, U>(arr: T[], selector: (item: T) => U, compare?: (a: U, b: U) => number) => T[];
|
|
625
|
-
|
|
626
424
|
declare type SourceFunc = (...args: any[]) => any;
|
|
627
425
|
|
|
628
|
-
export declare const splitNested: (str: string, separator: string, open?: string, close?: string) => string[];
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* Splits a string by a separator while respecting quoted values.
|
|
632
|
-
* Quoted values can contain the separator without being split.
|
|
633
|
-
* Supports both single (') and double (") quotes.
|
|
634
|
-
*
|
|
635
|
-
* @param input - The string to split
|
|
636
|
-
* @param separator - Single or multi-character separator (default: ',')
|
|
637
|
-
* @returns Array of objects with value and quoted status
|
|
638
|
-
*
|
|
639
|
-
* @example
|
|
640
|
-
* splitWithQuotes('hello, "world", test')
|
|
641
|
-
* // Returns: [
|
|
642
|
-
* // { value: 'hello', quoted: false },
|
|
643
|
-
* // { value: 'world', quoted: true },
|
|
644
|
-
* // { value: 'test', quoted: false }
|
|
645
|
-
* // ]
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* splitWithQuotes('a:: "b:: c":: d', '::')
|
|
649
|
-
* // Returns: [
|
|
650
|
-
* // { value: 'a', quoted: false },
|
|
651
|
-
* // { value: 'b:: c', quoted: true },
|
|
652
|
-
* // { value: 'd', quoted: false }
|
|
653
|
-
* // ]
|
|
654
|
-
*/
|
|
655
|
-
export declare const splitWithQuotes: (input: string, separator?: string) => {
|
|
656
|
-
value: string;
|
|
657
|
-
quoted: boolean;
|
|
658
|
-
}[];
|
|
659
|
-
|
|
660
|
-
export declare const stripIndent: (value: string) => string;
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
* Replaces tokens in a string with values from an object.
|
|
664
|
-
* Tokens are in the format `$\{key\}`.
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* tokenize('Hello $\{name\}', { name: 'World' }) // 'Hello World'
|
|
668
|
-
* tokenize('$\{greeting\} $\{name\}!', { greeting: 'Hi', name: 'Alice' }) // 'Hi Alice!'
|
|
669
|
-
* tokenize('$\{missing\}', {}) // ''
|
|
670
|
-
*
|
|
671
|
-
* @param str - The string containing tokens
|
|
672
|
-
* @param from - An object with key-value pairs for token replacement
|
|
673
|
-
* @param tokenizer - The regex pattern for token matching (default: `/\$\{([^}]+)\}/g`)
|
|
674
|
-
* @returns The string with tokens replaced by values from the object
|
|
675
|
-
*/
|
|
676
|
-
export declare const tokenize: (str: string, from: Record<string, unknown>, tokenizer?: RegExp) => string;
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
* Converts an object's entries into an array of objects with a key property
|
|
680
|
-
* @typeParam T - The type of items in the resulting array
|
|
681
|
-
* @param from - Object to convert
|
|
682
|
-
* @param key - Property name to use for keys (default: 'name')
|
|
683
|
-
* @returns Array of objects with key properties
|
|
684
|
-
* @example
|
|
685
|
-
* toList({ a: { value: 1 }, b: { value: 2 } }) // [{ name: 'a', value: 1 }, { name: 'b', value: 2 }]
|
|
686
|
-
* @public
|
|
687
|
-
*/
|
|
688
|
-
export declare const toList: <T>(from: Record<string, unknown>, key?: string) => T[];
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Converts an array into an object indexed by a key property, excluding the key from items
|
|
692
|
-
* @typeParam T - The type of the resulting object values
|
|
693
|
-
* @param from - Array to convert
|
|
694
|
-
* @param key - Property name to use as key (default: 'name')
|
|
695
|
-
* @returns Object indexed by key values, without the key property in values
|
|
696
|
-
* @example
|
|
697
|
-
* toObject([{ name: 'a', value: 1 }]) // { a: { value: 1 } }
|
|
698
|
-
* @public
|
|
699
|
-
*/
|
|
700
|
-
export declare const toObject: <T extends Record<string, unknown>>(from: T[], key?: string) => Record<string, Omit<T, typeof key>>;
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Converts an array into an object indexed by a key property, keeping the full items
|
|
704
|
-
* @typeParam T - The type of the resulting object
|
|
705
|
-
* @param from - Array to convert
|
|
706
|
-
* @param key - Property name to use as key (default: 'name')
|
|
707
|
-
* @returns Object indexed by key values
|
|
708
|
-
* @example
|
|
709
|
-
* toObjectWithKey([{ name: 'a', value: 1 }]) // { a: { name: 'a', value: 1 } }
|
|
710
|
-
* @public
|
|
711
|
-
*/
|
|
712
|
-
export declare const toObjectWithKey: <T extends Record<string, unknown>>(from: T[], key?: string) => Record<string, T>;
|
|
713
|
-
|
|
714
426
|
export declare const variable: (options?: VariableOptions) => (_: any, ctx: ClassFieldDecoratorContext<ObjectorPlugin, any>) => void;
|
|
715
427
|
|
|
716
428
|
declare type VariableOptions = ObjectorDecoratorOptions;
|
|
@@ -750,14 +462,14 @@ export declare interface WriteOutputsOption extends WriteOutputOption {
|
|
|
750
462
|
|
|
751
463
|
export { }
|
|
752
464
|
|
|
753
|
-
|
|
754
|
-
/* Global declarations from framework */
|
|
465
|
+
/* Global declarations */
|
|
755
466
|
|
|
756
467
|
declare global {
|
|
757
468
|
type Constructor<T = any> = new (...args: any[]) => T;
|
|
758
469
|
type MaybePromise<T> = T | Promise<T>;
|
|
759
470
|
type AsyncFunction<T = any> = (...args: any[]) => Promise<T>;
|
|
760
471
|
var AsyncFunction: typeof Function;
|
|
472
|
+
var defined: <T>(value: T | undefined | null, msg?: string) => T;
|
|
761
473
|
}
|
|
762
474
|
|
|
763
475
|
declare global {
|
|
@@ -775,6 +487,7 @@ declare global {
|
|
|
775
487
|
findOrFail(predicate: (value: T, index: number, array: T[]) => boolean, message?: string, thisArg?: any): T;
|
|
776
488
|
selectFor<K>(predicate: (value: T, index: number, array: T[]) => boolean, selector: (value: T) => K, message?: string, thisArg?: any): K;
|
|
777
489
|
createInstances<TTarget>(targetConstructor: new (...args: any[]) => TTarget, ...args: any[]): TTarget[];
|
|
490
|
+
mergeAll(options?: MergeOptions): any;
|
|
778
491
|
}
|
|
779
492
|
interface ArrayConstructor {
|
|
780
493
|
flat<T>(v: T | T[] | T[][]): T[];
|
|
@@ -786,7 +499,29 @@ declare global {
|
|
|
786
499
|
mapEntries<T extends object, U>(obj: T, callback: (key: keyof T, value: T[keyof T]) => [string | number | symbol, U]): Record<string | number | symbol, U>;
|
|
787
500
|
toList<T extends object, U extends object, X extends string>(obj: T, key: X): (Record<X, string> & U)[];
|
|
788
501
|
deepClone<T extends object>(obj: T): T;
|
|
789
|
-
|
|
790
|
-
|
|
502
|
+
merge(source: any, target: any, options?: MergeOptions): void;
|
|
503
|
+
navigate(o: any, cb: NavigateCallback): Promise<void>;
|
|
504
|
+
find(from: any, cb: (path: string, value: any) => boolean): Promise<any[]>;
|
|
505
|
+
select(from: any, path: string, options?: SelectOptions): any;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
declare global {
|
|
510
|
+
interface String {
|
|
511
|
+
capitalize(): string;
|
|
512
|
+
toPascal(): string;
|
|
513
|
+
toCamel(): string;
|
|
514
|
+
toSnake(): string;
|
|
515
|
+
toKebab(): string;
|
|
516
|
+
changeCase(to: 'upper' | 'lower' | 'pascal' | 'camel' | 'snake' | 'kebab'): string;
|
|
517
|
+
splitWithQuotes(separator?: string): {
|
|
518
|
+
value: string;
|
|
519
|
+
quoted: boolean;
|
|
520
|
+
}[];
|
|
521
|
+
splitNested(separator: string, open: string, close: string): string[];
|
|
522
|
+
padBlock(indent: number, separator?: string, padder?: string): string;
|
|
523
|
+
tokenize(from: Record<string, unknown>, tokenizer?: RegExp): string;
|
|
524
|
+
stripIndent(): string;
|
|
791
525
|
}
|
|
792
526
|
}
|
|
527
|
+
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
var xr=Object.create;var{getPrototypeOf:to,defineProperty:G,getOwnPropertyNames:Fr,getOwnPropertyDescriptor:no}=Object,Ye=Object.prototype.hasOwnProperty;function Ge(e){return this[e]}var D=(e,r,t)=>{var n=Fr(r);for(let o of n)if(!Ye.call(e,o)&&o!=="default")G(e,o,{get:Ge.bind(r,o),enumerable:!0});if(t){for(let o of n)if(!Ye.call(t,o)&&o!=="default")G(t,o,{get:Ge.bind(r,o),enumerable:!0});return t}},oo,io,so=(e,r,t)=>{var n=e!=null&&typeof e==="object";if(n){var o=r?oo??=new WeakMap:io??=new WeakMap,i=o.get(e);if(i)return i}t=e!=null?xr(to(e)):{};let l=r||!e||!e.__esModule?G(t,"default",{value:e,enumerable:!0}):t;for(let a of Fr(e))if(!Ye.call(l,a))G(l,a,{get:Ge.bind(e,a),enumerable:!0});if(n)o.set(e,l);return l};var ao=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Mr=(e,r)=>{return Object.defineProperty(e,"name",{value:r,enumerable:!1,configurable:!0}),e},lo=(e)=>e;function uo(e,r){this[e]=lo.bind(null,r)}var C=(e,r)=>{for(var t in r)G(e,t,{get:r[t],enumerable:!0,configurable:!0,set:uo.bind(r,t)})};var Dr=(e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),ae=(e)=>{throw TypeError(e)},co=(e,r,t)=>(r in e)?G(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Qe=(e,r,t)=>r.has(e)||ae("Cannot "+t),fo=(e,r)=>Object(r)!==r?ae('Cannot use the "in" operator on this value'):e.has(r),Sr=(e,r,t)=>(Qe(e,r,"read from private field"),t?t.call(e):r.get(e));var kr=(e,r,t,n)=>(Qe(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t),po=(e,r,t)=>(Qe(e,r,"access private method"),t),jr=(e)=>[,,,xr(e?.[Dr("metadata")]??null)],Rr=["class","method","getter","setter","accessor","field","value","get","set"],se=(e)=>e!==void 0&&typeof e!=="function"?ae("Function expected"):e,mo=(e,r,t,n,o)=>({kind:Rr[e],name:r,metadata:n,addInitializer:(i)=>t._?ae("Already initialized"):o.push(se(i||null))}),Xe=(e,r)=>co(r,Dr("metadata"),e[3]),$r=(e,r,t,n)=>{for(var o=0,i=e[r>>1],l=i&&i.length;o<l;o++)r&1?i[o].call(t):n=i[o].call(t,n);return n},m=(e,r,t,n,o,i)=>{var l,a,c,w,O,y=r&7,u=!!(r&8),d=!!(r&16),v=y>3?e.length+1:y?u?1:2:0,g=Rr[y+5],A=y>3&&(e[v-1]=[]),f=e[v]||(e[v]=[]),S=y&&(!d&&!u&&(o=o.prototype),y<5&&(y>3||!d)&&no(y<4?o:{get[t](){return Sr(this,i)},set[t](M){kr(this,i,M)}},t));y?d&&y<4&&Mr(i,(y>2?"set ":y>1?"get ":"")+t):Mr(o,t);for(var b=n.length-1;b>=0;b--){if(w=mo(y,t,c={},e[3],f),y){if(w.static=u,w.private=d,O=w.access={has:d?(M)=>fo(o,M):(M)=>(t in M)},y^3)O.get=d?(M)=>(y^1?Sr:po)(M,o,y^4?i:S.get):(M)=>M[t];if(y>2)O.set=d?(M,k)=>kr(M,o,k,y^4?i:S.set):(M,k)=>M[t]=k}if(a=(0,n[b])(y?y<4?d?i:S[g]:y>4?void 0:{get:S.get,set:S.set}:o,w),c._=1,y^4||a===void 0)se(a)&&(y>4?A.unshift(a):y?d?i=a:S[g]=a:o=a);else if(typeof a!=="object"||a===null)ae("Object expected");else se(l=a.get)&&(S.get=l),se(l=a.set)&&(S.set=l),se(l=a.init)&&A.unshift(l)}return y||Xe(e,o),S&&G(o,t,S),d?y^4?i:S:o};var Dt=ao((ol,Ft)=>{var{defineProperty:Tr,getOwnPropertyNames:mi,getOwnPropertyDescriptor:gi}=Object,yi=Object.prototype.hasOwnProperty,kt=new WeakMap,di=(e)=>{var r=kt.get(e),t;if(r)return r;if(r=Tr({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")mi(e).map((n)=>!yi.call(r,n)&&Tr(r,n,{get:()=>e[n],enumerable:!(t=gi(e,n))||t.enumerable}));return kt.set(e,r),r},hi=(e,r)=>{for(var t in r)Tr(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(n)=>r[t]=()=>n})},xt={};hi(xt,{splitWithQuotes:()=>bi,splitNested:()=>wi});Ft.exports=di(xt);var wi=(e,r,t="(",n=")")=>{let o=0,i="",l=[];for(let a of e){if(i+=a,a===t)o++;if(a===n)o--;if(o===0&&a===r)l.push(i.slice(0,-1)),i=""}if(i)l.push(i);return l},bi=(e,r=",")=>{let t=[],n=e.length,o=r.length,i=0,l=(a)=>{if(a+o>n)return!1;for(let c=0;c<o;c++)if(e[a+c]!==r[c])return!1;return!0};while(i<n){while(i<n&&e[i]===" ")i++;if(i>=n)break;let a="",c=e[i]==='"'||e[i]==="'";if(c){let w=e[i++];while(i<n&&e[i]!==w)a+=e[i++];if(i<n)i++}else{while(i<n&&!l(i)){let w=e[i];if(w==='"'||w==="'"){a+=w,i++;while(i<n&&e[i]!==w)a+=e[i++];if(i<n)a+=e[i++]}else a+=e[i++]}a=a.trim()}if(a)t.push({value:a,quoted:c});if(l(i))i+=o}return t}});var N={};C(N,{writeOutputs:()=>me,writeOutput:()=>je,writeFormat:()=>De,variable:()=>pr,tokenize:()=>Or,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>Ar,sortBy:()=>ar,snake:()=>re,sharedFunction:()=>mr,select:()=>x,section:()=>cr,processFields:()=>$,pascal:()=>ee,padBlock:()=>_,nonNullMap:()=>ir,navigate:()=>Ce,mergeAll:()=>z,merge:()=>U,makeFieldProcessorMap:()=>B,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>ce,macro:()=>p,locate:()=>X,loadFormat:()=>fe,key:()=>fr,importList:()=>Re,importGlob:()=>tr,globMap:()=>pe,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>hr,exists:()=>q,encoder:()=>gr,defined:()=>sr,deepClone:()=>W,decoder:()=>yr,conditionPredicates:()=>K,changeCase:()=>te,capital:()=>he,camel:()=>we,asyncMap:()=>lr,ObjectorPlugin:()=>P,Objector:()=>$t,NavigateResult:()=>E,NavigateAction:()=>$e,Logger:()=>Be,AsyncFunction:()=>Er});var ze={};C(ze,{processFields:()=>$,makeFieldProcessorMap:()=>B,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>ce,getProcessor:()=>ue,getArgs:()=>Fe});var go=Object.create,{getPrototypeOf:yo,defineProperty:Cr,getOwnPropertyNames:ho}=Object,wo=Object.prototype.hasOwnProperty,bo=(e,r,t)=>{t=e!=null?go(yo(e)):{};let n=r||!e||!e.__esModule?Cr(t,"default",{value:e,enumerable:!0}):t;for(let o of ho(e))if(!wo.call(n,o))Cr(n,o,{get:()=>e[o],enumerable:!0});return n},Oo=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Ao=Oo((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),v;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(v=o(u,g))||v.enumerable}));return l.set(u,d),d},c=(u,d)=>{for(var v in d)t(u,v,{get:d[v],enumerable:!0,configurable:!0,set:(g)=>d[v]=()=>g})},w={};c(w,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(w);var O=(u,d,v="(",g=")")=>{let A=0,f="",S=[];for(let b of u){if(f+=b,b===v)A++;if(b===g)A--;if(A===0&&b===d)S.push(f.slice(0,-1)),f=""}if(f)S.push(f);return S},y=(u,d=",")=>{let v=[],g=u.length,A=d.length,f=0,S=(b)=>{if(b+A>g)return!1;for(let M=0;M<A;M++)if(u[b+M]!==d[M])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",M=u[f]==='"'||u[f]==="'";if(M){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!S(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)v.push({value:b,quoted:M});if(S(f))f+=A}return v}}),vo=bo(Ao(),1),Q;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(Q||={});class j{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new j(0);static _noExplore=new j(2);static _skipSiblings=new j(1);static _deleteParent=new j(4);static ReplaceParent(e,r){return new j(3,e,void 0,r)}static SkipSiblings(){return j._skipSiblings}static Explore(){return j._explore}static NoExplore(){return j._noExplore}static DeleteParent(){return j._deleteParent}static MergeParent(e){return new j(5,e)}static ReplaceItem(e,r){return new j(6,e,r)}static DeleteItem(e){return new j(7,void 0,e)}}var To=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,c,w)=>{let O=a===null,y=O?j.Explore():await r({key:a,value:c,path:n,parent:w,parents:o});if(c&&typeof c==="object"&&y.action===0){if(t.has(c))return y;if(t.add(c),!O)n.push(a),o.push(w);let u=c;while(await l(u,a,w))u=w[a];if(!O)o.pop(),n.pop()}return y},l=async(a,c,w)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],v=a[d],g=await i(d,v,a),A=g.action;if(A===0||A===2)continue;if(A===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(A===7){if(delete a[d],g.skipSiblings)return;continue}if(A===1)return;if(A===3){if(c===null)throw Error("Cannot replace root object");if(w[c]=g.by,g.reexplore)return!0;return}if(A===4){if(c===null)throw Error("Cannot delete root object");delete w[c];return}if(A===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},Eo=Object.create,{getPrototypeOf:Mo,defineProperty:Wr,getOwnPropertyNames:So}=Object,ko=Object.prototype.hasOwnProperty,xo=(e,r,t)=>{t=e!=null?Eo(Mo(e)):{};let n=r||!e||!e.__esModule?Wr(t,"default",{value:e,enumerable:!0}):t;for(let o of So(e))if(!ko.call(n,o))Wr(n,o,{get:()=>e[o],enumerable:!0});return n},Fo=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Do=Fo((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),v;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(v=o(u,g))||v.enumerable}));return l.set(u,d),d},c=(u,d)=>{for(var v in d)t(u,v,{get:d[v],enumerable:!0,configurable:!0,set:(g)=>d[v]=()=>g})},w={};c(w,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(w);var O=(u,d,v="(",g=")")=>{let A=0,f="",S=[];for(let b of u){if(f+=b,b===v)A++;if(b===g)A--;if(A===0&&b===d)S.push(f.slice(0,-1)),f=""}if(f)S.push(f);return S},y=(u,d=",")=>{let v=[],g=u.length,A=d.length,f=0,S=(b)=>{if(b+A>g)return!1;for(let M=0;M<A;M++)if(u[b+M]!==d[M])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",M=u[f]==='"'||u[f]==="'";if(M){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!S(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)v.push({value:b,quoted:M});if(S(f))f+=A}return v}}),jo=xo(Do(),1),Ro=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,$o=/^([^[\]]*)\[([^\]]*)]$/,Ze=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return le(r,o,t)?.toString()}return n?e:void 0},Co=(e,r,t,n)=>{let o=Ze(r,t,n);if(o)return le(e,o,n);let i=Ro.exec(r);if(i){let[,a,c,w]=i,O=Ze(a.trim(),t,n,!0),y=Ze(w.trim(),t,n,!0);if(Array.isArray(e)&&(c==="="||c==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=$o.exec(r);if(l){let[,a,c]=l;return e?.[a]?.[c]}return e?.[r]},le=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,v]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=Co(y,d,e,t);if(g===void 0){if(v||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},c=jo.splitNested(i,t?.separator??".","{","}"),w=void 0;if(c.length>0&&c[c.length-1].startsWith("?="))w=c.pop()?.substring(2);c.reverse();let O=a(e,c);if(O===void 0)return w??t?.defaultValue;return O},Nr=(e,r)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let t=e.value.slice(1,-1);if(t.trim()==="")return[];return t.split(";").map((n)=>{let o=n.trim();if(!isNaN(+o))return+o;return o})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return r(e.value)},xe=(e,r,t,n,o,i)=>{let l=n?.(e)??e,a=o(l);if(a[0])return a[1];if(!r){let c=le(t,e),w=o(c);if(w[0])return w[1]}throw Error(i)},Ur=(e,r,t,n,o)=>{let i=typeof e.types==="function"?e.types(n,r.value,o):e.types?.[n];if(!i||i==="ref")return Nr(r,(a)=>le(t,a));let l=Nr(r,()=>r.value);if(Array.isArray(i)){if(!i.includes(l))throw Error(`Argument ${n.toString()} must be one of [${i.join(", ")}]: ${l}`);return l}if(typeof i==="string"){if(i.endsWith("?")){let a=i.slice(0,-1);if(r.value==="null")return j.ReplaceItem(null);if(r.value==="undefined")return j.ReplaceItem(void 0);if(r.value==="")return"";i=a}switch(i){case"any":return l;case"array":return xe(l,r.quoted,t,null,(a)=>[Array.isArray(a),a],`Argument ${n.toString()} must be an array: ${l}`);case"object":return xe(l,r.quoted,t,null,(a)=>[typeof a==="object"&&a!==null,a],`Argument ${n.toString()} must be an object: ${l}`);case"number":return xe(l,r.quoted,t,(a)=>Number(a),(a)=>[!isNaN(a),a],`Argument ${n.toString()} must be a number: ${l}`);case"boolean":return xe(l,r.quoted,t,null,(a)=>{if([!0,"true","1",1,"yes","on"].includes(a))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(a))return[!0,!1];if([null,"null","undefined",void 0,""].includes(a))return[!0,!1];if(Array.isArray(a))return[!0,a.length>0];return[!1,!1]},`Argument ${n.toString()} must be a boolean: ${l}`);case"string":return l.toString();default:throw Error(`Unknown type for argument ${n.toString()}: ${i}`)}}return i(l,t,n,r.quoted)},ue=(e,r)=>{let t=e?.[r];if(t===void 0)throw Error(`Unhandled field processor type: ${r}`);return typeof t==="function"?{options:{},fn:t}:{options:t,fn:t.fn}},Ir=(e)=>!e.quoted&&e.value.startsWith("."),Wo=(e)=>{let r={};for(let t of e){if(!Ir(t))continue;let n=t.value.indexOf("="),o=n>-1?t.value.slice(1,n):t.value.slice(1),i=n>-1?t.value.slice(n+1):"";if(i.length>=2){let l=i[0],a=i[i.length-1];if(l==='"'&&a==='"'||l==="'"&&a==="'")i=i.slice(1,-1)}if(!r[o])r[o]=[];r[o].push(i)}return r},Fe=(e,r,t)=>{let n=vo.splitWithQuotes(e??""),o=Wo(n),i=n.filter((a)=>!Ir(a)),l=r.options.processArgs===!1?[]:i.map((a,c)=>Ur(r.options,a,t,c,i));return{rawArgs:i,parsedArgs:l,tags:o}},No=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Ko=(e,r)=>r.keys!==void 0&&e.key.startsWith(".")&&r.keys[e.key.substring(1)]!==void 0,Uo=async(e,r,t,n)=>{let{key:o,parent:i}=e,l=ue(n.keys,o.substring(1));if(l.options.processArgs!==!1&&(typeof l.options.types==="function"||l.options.types?.[0]!==void 0))e.value=Ur(l.options,{value:e.value,quoted:!1},t,0,[]);if(typeof e.value!=="string")await $(e.value,{...n,root:{...t,parent:e.parent,parents:e.parents},filters:[...n.filters??[],...l.options.filters??[]]});let a=await l.fn({path:r,root:t,parent:i,key:o,options:n,value:e.value,args:[],rawArgs:[],tags:{}});return No(a)?a:j.ReplaceParent(a)},Kr=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`).
|
|
5
|
-
`)
|
|
6
|
-
`))
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(${n})`)}}),e},ce=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),qe=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,ce(t,r?.types?.[t.name])])),B=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,ce(e[t],r?.types?.[t])]));var nr={};C(nr,{writeOutputs:()=>me,writeOutput:()=>je,writeFormat:()=>De,locate:()=>X,loadFormat:()=>fe,importList:()=>Re,importGlob:()=>tr,globMap:()=>pe,exists:()=>q});import Pr from"fs/promises";import Je from"path";import Go from"fs/promises";import Qo from"path";import Xo from"fs/promises";import Zo from"fs/promises";import Gr from"fs/promises";import Vr from"path";import Ho from"fs/promises";import er from"path";import Yr from"path";var q=async(e)=>{try{return await Pr.access(e,Pr.constants.R_OK),!0}catch{return!1}},X=async(e,r)=>{let t=!Je.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=Je.join(n,e);if(await q(o))return Je.resolve(o)}throw Error(`File not found: "${e}"`)},fe=async(e,r)=>{let t=await X(e,r?.dirs),n=await Go.readFile(t,"utf-8"),o=Qo.dirname(t),i={text:{fn:(a)=>a,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...r?.parsers},l=r?.format?i[r.format]:Object.values(i).find((a)=>a.matching?.some((c)=>new RegExp(c).test(e)));if(!l)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await l.fn(n),fullPath:t,folderPath:o}},De=async(e,r,t)=>{let n={text:{fn:(i)=>i,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...t?.encoders},o=t?.format?n[t.format]:Object.values(n).find((i)=>i.matching?.some((l)=>new RegExp(l).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await Xo.writeFile(e,await o.fn(r))},pe=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(Zo.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},me=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await Gr.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await je(t,r)},je=async(e,r)=>{let t=Vr.join(r?.targetDirectory??".",e.name),n=Vr.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await Gr.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await De(t,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},rr=(e)=>e?Yr.isAbsolute(e)?e:Yr.join(process.cwd(),e):process.cwd(),Re=async(e,r)=>{let t=[];for(let n of e)try{let o=!er.isAbsolute(n)?er.join(rr(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let i=await import(o);if(r?.resolveDefault==="only"&&!i.default)throw Error(`Module ${n} does not have a default export`);let l=r?.resolveDefault?i.default??i:i,a=r?.map?await r.map(l,n):l;if(a!==void 0)t.push(a)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},tr=async(e,r)=>{let t=[];for(let n of e){let o=(await Array.fromAsync(Ho.glob(n,{cwd:rr(r?.cwd)}))).map((i)=>er.join(rr(r?.cwd),i));t.push(...await Re(o,r))}return t};var ur={};C(ur,{toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,sortBy:()=>ar,nonNullMap:()=>ir,defined:()=>sr,deepClone:()=>W,asyncMap:()=>lr});var Z=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),or=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ge=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),ir=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},sr=(e,r="Value is undefined")=>{if(e===void 0||e===null)throw Error(r);return e},ar=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),lr=async(e,r)=>Promise.all(e.map(r)),W=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var dr={};C(dr,{variable:()=>pr,sharedFunction:()=>mr,section:()=>cr,macro:()=>p,key:()=>fr,encoder:()=>gr,decoder:()=>yr,ObjectorPlugin:()=>P});class P{o;context;constructor(e){this.o=e}}var p=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sources({[o]:(i)=>n.apply({...this,context:i},i.args)})})},cr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sections({[o]:(i)=>{return n.call({...this,context:i},i.section)}})})},fr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.keys({[o]:(i)=>n.call({...this,context:i},i.value)})})},pr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.variables({[o]:n})})},mr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.functions({[o]:n})})},gr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.encoders({[o]:{fn:n}})})},yr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.decoders({[o]:{fn:n}})})};var Mt={};C(Mt,{defaultProcessors:()=>vr});import{createHash as ne}from"crypto";import V from"path";var Qr={};C(Qr,{navigate:()=>Ce,find:()=>hr,NavigateResult:()=>E,NavigateAction:()=>$e});var $e;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})($e||={});class E{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new E(0);static _noExplore=new E(2);static _skipSiblings=new E(1);static _deleteParent=new E(4);static ReplaceParent(e,r){return new E(3,e,void 0,r)}static SkipSiblings(){return E._skipSiblings}static Explore(){return E._explore}static NoExplore(){return E._noExplore}static DeleteParent(){return E._deleteParent}static MergeParent(e){return new E(5,e)}static ReplaceItem(e,r){return new E(6,e,r)}static DeleteItem(e){return new E(7,void 0,e)}}var Ce=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,c,w)=>{let O=a===null,y=O?E.Explore():await r({key:a,value:c,path:n,parent:w,parents:o});if(c&&typeof c==="object"&&y.action===0){if(t.has(c))return y;if(t.add(c),!O)n.push(a),o.push(w);let u=c;while(await l(u,a,w))u=w[a];if(!O)o.pop(),n.pop()}return y},l=async(a,c,w)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],v=a[d],g=await i(d,v,a),A=g.action;if(A===0||A===2)continue;if(A===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(A===7){if(delete a[d],g.skipSiblings)return;continue}if(A===1)return;if(A===3){if(c===null)throw Error("Cannot replace root object");if(w[c]=g.by,g.reexplore)return!0;return}if(A===4){if(c===null)throw Error("Cannot delete root object");delete w[c];return}if(A===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},hr=async(e,r)=>{let t=[];return await Ce(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return E.Explore()}),t};var Xr=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return E.SkipSiblings()}});import qo from"path";var Zr=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&qo.dirname(t.file))}return E.DeleteItem()}});var Hr={};C(Hr,{mergeAll:()=>z,merge:()=>U});var U=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],i=e[n];if(typeof i!==typeof o||Array.isArray(i)!==Array.isArray(o)){let a=t?.mismatch?.(n,i,o,e,r);if(a!==void 0){r[n]=a;continue}throw Error(`Type mismatch: ${n}`)}let l=t?.mode?.(n,i,o,e,r)??r[".merge"]??"merge";switch(l){case"source":r[n]=i;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${l}`)}if(typeof i==="object")if(Array.isArray(i))o.push(...i);else{if(t?.navigate?.(n,i,o,e,r)===!1)continue;U(i,o,t)}else{if(i===o)continue;let a=t?.conflict?.(n,i,o,e,r);r[n]=a===void 0?o:a}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},z=(e,r)=>{let t={};for(let n of e.toReversed())U(n,t,r);return t};var qr={};C(qr,{CacheManager:()=>We});class We{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var Jr={};C(Jr,{select:()=>x});var zo=Object.create,{getPrototypeOf:Jo,defineProperty:zr,getOwnPropertyNames:ei}=Object,ri=Object.prototype.hasOwnProperty,ti=(e,r,t)=>{t=e!=null?zo(Jo(e)):{};let n=r||!e||!e.__esModule?zr(t,"default",{value:e,enumerable:!0}):t;for(let o of ei(e))if(!ri.call(n,o))zr(n,o,{get:()=>e[o],enumerable:!0});return n},ni=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),oi=ni((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),v;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(v=o(u,g))||v.enumerable}));return l.set(u,d),d},c=(u,d)=>{for(var v in d)t(u,v,{get:d[v],enumerable:!0,configurable:!0,set:(g)=>d[v]=()=>g})},w={};c(w,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(w);var O=(u,d,v="(",g=")")=>{let A=0,f="",S=[];for(let b of u){if(f+=b,b===v)A++;if(b===g)A--;if(A===0&&b===d)S.push(f.slice(0,-1)),f=""}if(f)S.push(f);return S},y=(u,d=",")=>{let v=[],g=u.length,A=d.length,f=0,S=(b)=>{if(b+A>g)return!1;for(let M=0;M<A;M++)if(u[b+M]!==d[M])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",M=u[f]==='"'||u[f]==="'";if(M){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!S(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)v.push({value:b,quoted:M});if(S(f))f+=A}return v}}),ii=ti(oi(),1),si=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,ai=/^([^[\]]*)\[([^\]]*)]$/,wr=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return x(r,o,t)?.toString()}return n?e:void 0},li=(e,r,t,n)=>{let o=wr(r,t,n);if(o)return x(e,o,n);let i=si.exec(r);if(i){let[,a,c,w]=i,O=wr(a.trim(),t,n,!0),y=wr(w.trim(),t,n,!0);if(Array.isArray(e)&&(c==="="||c==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=ai.exec(r);if(l){let[,a,c]=l;return e?.[a]?.[c]}return e?.[r]},x=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,v]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=li(y,d,e,t);if(g===void 0){if(v||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},c=ii.splitNested(i,t?.separator??".","{","}"),w=void 0;if(c.length>0&&c[c.length-1].startsWith("?="))w=c.pop()?.substring(2);c.reverse();let O=a(e,c);if(O===void 0)return w??t?.defaultValue;return O};var Ne=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return x(e.root,r);return r};var Ke=(e)=>{if(typeof e.value==="string")return x(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return x(e.root,r.from);return r.from};var Ue=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await $(n,{...e.options,root:{...e.root,result:r}}),n}return await x({...e.root,result:r},t.selector)};var et={};C(et,{PathManager:()=>H});import J from"path";class H{constructor(){}static normalize(e){return J.normalize(J.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=J.isAbsolute(e)?e:J.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(J.isAbsolute(e))return e;return J.join(r??process.cwd(),e)}}var rt={};C(rt,{conditionPredicatesTypes:()=>ye,conditionPredicates:()=>K});var K={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!K.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},ye={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var tt=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await Ke(e),n=await Ne(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=z([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let i=0;i<t.length;i++){let l=W(n);if(await $(l,{...e.options,root:{...e.root,index:i,item:t[i],instance:l}}),r.extend?.result){let a=r.extend.result;l=z([l,...Array.isArray(a)?a:[a]])}o.push(await Ue(e,l))}return o}}});var nt=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await Ke(e),t=await Ne(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let i=W(t);await $(i,{...e.options,root:{...e.root,index:o,item:r[o],instance:i}}),n.push(await Ue(e,i))}return n}}});var ot=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await x(e.root,t));return r.filter((t)=>t!==void 0)}});var it=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let i=await x(e.root,o),l=W(i);if(l[e.key])await r(l,l[e.key]);await $(l,{...e.options}),U(l,t),delete t[e.key]}};return await r(e.parent,e.value),E.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((i)=>r.push({...o,...i})),E.DeleteParent()}});var st=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?E.DeleteParent():E.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),E.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return E.DeleteItem();if(typeof o==="string")return(await $({value:o},{...r.options,root:{...r.root}})).value;return E.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return E.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return E.ReplaceParent(t.default,!0);return E.DeleteParent()}});var at=()=>({from:async({root:e,parent:r,value:t})=>{let n=await x(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return U(n,r.content),r.content}return n}});import lt from"node:vm";var ut=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=lt.createContext({console,objector:e,document:r.root}),i=new lt.SourceTextModule(n,{identifier:t,context:o});await i.link((l)=>{throw Error(`Module ${l} is not allowed`)}),await i.evaluate(),e.sources(Object.fromEntries(Object.entries(i.namespace).map(([l,a])=>[`${t}.${l}`,(c)=>a(c,...c.args)])))}return E.DeleteItem()}});var ct=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return E.DeleteItem()}}}});var ft=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),E.DeleteItem()}}});var pt=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var ui=(e,r)=>{let t=r.section.config.using,n=e.getFunctions();return t?Object.fromEntries(t.map((o)=>{if(o in n)return[o,n[o]];if(o in r.root)return[o,r.root[o]];throw Error(`Function or variable "${o}" not found for script section`)})):n},br=(e,r,t,n,o=[])=>{let i=ui(e,t),l=["section","context","config","system",...Object.keys(i),...o],a=[r,t.root,t.section.config,e,...Object.values(i)];return[new AsyncFunction(...l,n).bind(t),a]},ci=(e,r)=>{let t={write:(...n)=>{return r.push(...n),t},writeLine:(...n)=>{return r.push(...n.map((o)=>o+`
|
|
10
|
-
`)),t},clear:()=>{return r.splice(0,r.length),t},prepend:(...n)=>{return r.unshift(...n),t},prependLine:(...n)=>{return r.unshift(...n.map((o)=>o+`
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`)
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
var Lr=Object.create;var Fe=Object.defineProperty;var Wr=Object.getOwnPropertyDescriptor;var ve=(e,t)=>{return Object.defineProperty(e,"name",{value:t,enumerable:!1,configurable:!0}),e};var Pe=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),K=(e)=>{throw TypeError(e)},Br=(e,t,r)=>(t in e)?Fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var fe=(e,t,r)=>t.has(e)||K("Cannot "+r),qr=(e,t)=>Object(t)!==t?K('Cannot use the "in" operator on this value'):e.has(t),Ee=(e,t,r)=>(fe(e,t,"read from private field"),r?r.call(e):t.get(e));var ke=(e,t,r,n)=>(fe(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),Kr=(e,t,r)=>(fe(e,t,"access private method"),r),$e=(e)=>[,,,Lr(e?.[Pe("metadata")]??null)],Me=["class","method","getter","setter","accessor","field","value","get","set"],q=(e)=>e!==void 0&&typeof e!=="function"?K("Function expected"):e,Jr=(e,t,r,n,o)=>({kind:Me[e],name:t,metadata:n,addInitializer:(s)=>r._?K("Already initialized"):o.push(q(s||null))}),pe=(e,t)=>Br(t,Pe("metadata"),e[3]),Re=(e,t,r,n)=>{for(var o=0,s=e[t>>1],l=s&&s.length;o<l;o++)t&1?s[o].call(r):n=s[o].call(r,n);return n},c=(e,t,r,n,o,s)=>{var l,a,u,m,y,g=t&7,O=!!(t&8),b=!!(t&16),k=g>3?e.length+1:g?O?1:2:0,w=Me[g+5],A=g>3&&(e[k-1]=[]),M=e[k]||(e[k]=[]),v=g&&(!b&&!O&&(o=o.prototype),g<5&&(g>3||!b)&&Wr(g<4?o:{get[r](){return Ee(this,s)},set[r](E){ke(this,s,E)}},r));g?b&&g<4&&ve(s,(g>2?"set ":g>1?"get ":"")+r):ve(o,r);for(var P=n.length-1;P>=0;P--){if(m=Jr(g,r,u={},e[3],M),g){if(m.static=O,m.private=b,y=m.access={has:b?(E)=>qr(o,E):(E)=>(r in E)},g^3)y.get=b?(E)=>(g^1?Ee:Kr)(E,o,g^4?s:v.get):(E)=>E[r];if(g>2)y.set=b?(E,F)=>ke(E,o,F,g^4?s:v.set):(E,F)=>E[r]=F}if(a=(0,n[P])(g?g<4?b?s:v[w]:g>4?void 0:{get:v.get,set:v.set}:o,m),u._=1,g^4||a===void 0)q(a)&&(g>4?A.unshift(a):g?b?s=a:v[w]=a:o=a);else if(typeof a!=="object"||a===null)K("Object expected");else q(l=a.get)&&(v.get=l),q(l=a.set)&&(v.set=l),q(l=a.init)&&A.unshift(l)}return g||pe(e,o),v&&Fe(o,r,v),b?g^4?s:v:o};Array.prototype.findOrFail=function(e,t,r){let n=this.find(e,r);if(n===void 0)throw Error(t??"Element not found");return n};Array.flat=function(e){if(Array.isArray(e))return e.flat(2);else return[e]};Array.prototype.forEachAsync=async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this)};Array.prototype.groupBy=function(e){return this.reduce((t,r)=>{let n=e(r);if(!t[n])t[n]=[];return t[n].push(r),t},{})};Array.prototype.createInstances=function(e,...t){return this.map((r,n)=>new e(...t,r,n))};Array.prototype.mapAsync=async function(e){return Promise.all(this.map(e))};Array.prototype.nonNullMap=function(e){let t=[];for(let r=0;r<this.length;r++){let n=e(this[r],r,this);if(n!=null)t.push(n)}return t};Array.prototype.nonNullMapAsync=async function(e){let t=[];for(let r=0;r<this.length;r++){let n=await e(this[r],r,this);if(n!=null)t.push(n)}return t};Array.prototype.mergeAll=function(e){let t={};for(let r of this.toReversed())Object.merge(r,t,e);return t};Array.prototype.toObject=function(e,t){return Object.fromEntries(this.map((r)=>{let n=e(r),o=t?t(r):r;return[n,o]}))};Array.prototype.toObjectWithKey=function(e){return Object.fromEntries(this.map((t)=>[String(t[e]),t]))};Array.prototype.selectFor=function(e,t,r,n){let o=this.find(e,n);if(o===void 0)throw Error(r??"Element not found");return t(o)};Array.prototype.sortBy=function(e,t=!0){return this.slice().sort((r,n)=>{let o=e(r),s=e(n);if(o<s)return t?-1:1;if(o>s)return t?1:-1;return 0})};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(e){let t=new Set;return this.filter((r)=>{let n=e(r);if(t.has(n))return!1;else return t.add(n),!0})};var I;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(I||={});class j{action;by;skipSiblings;reexplore;constructor(e,t,r,n){this.action=e,this.by=t,this.skipSiblings=r,this.reexplore=n}static _explore=new j(0);static _noExplore=new j(2);static _skipSiblings=new j(1);static _deleteParent=new j(4);static ReplaceParent(e,t){return new j(3,e,void 0,t)}static SkipSiblings(){return j._skipSiblings}static Explore(){return j._explore}static NoExplore(){return j._noExplore}static DeleteParent(){return j._deleteParent}static MergeParent(e){return new j(5,e)}static ReplaceItem(e,t){return new j(6,e,t)}static DeleteItem(e){return new j(7,void 0,e)}}Object.navigate=async(e,t)=>{let r=new WeakSet,n=[],o=[],s=async(a,u,m)=>{let y=a===null,g=y?j.Explore():await t({key:a,value:u,path:n,parent:m,parents:o});if(u&&typeof u==="object"&&g.action===0){if(r.has(u))return g;if(r.add(u),!y)n.push(a),o.push(m);let O=u;while(await l(O,a,m))O=m[a];if(!y)o.pop(),n.pop()}return g},l=async(a,u,m)=>{let y=Object.keys(a),g=y.length;for(let O=0;O<g;O++){let b=y[O],k=a[b],w=await s(b,k,a),A=w.action;if(A===0||A===2)continue;if(A===6){if(a[b]=w.by,w.skipSiblings)return;continue}if(A===7){if(delete a[b],w.skipSiblings)return;continue}if(A===1)return;if(A===3){if(u===null)throw Error("Cannot replace root object");if(m[u]=w.by,w.reexplore)return!0;return}if(A===4){if(u===null)throw Error("Cannot delete root object");delete m[u];return}if(A===5)delete a[b],Object.assign(a,w.by)}};await s(null,e,null)};Object.find=async function(e,t){let r=[];return await Object.navigate(e,(n)=>{if(t([...n.path,n.key].join("."),n.value))r.push(n.value);return j.Explore()}),r};Object.merge=(e,t,r)=>{for(let n of Object.keys(t)){if(e[n]===void 0)continue;let o=t[n],s=e[n];if(typeof s!==typeof o||Array.isArray(s)!==Array.isArray(o)){let a=r?.mismatch?.(n,s,o,e,t);if(a!==void 0){t[n]=a;continue}throw Error(`Type mismatch: ${n}`)}let l=r?.mode?.(n,s,o,e,t)??t[".merge"]??"merge";switch(l){case"source":t[n]=s;continue;case"target":continue;case"skip":delete t[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${l}`)}if(typeof s==="object")if(Array.isArray(s))o.push(...s);else{if(r?.navigate?.(n,s,o,e,t)===!1)continue;Object.merge(s,o,r)}else{if(s===o)continue;let a=r?.conflict?.(n,s,o,e,t);t[n]=a===void 0?o:a}}for(let n of Object.keys(e))if(t[n]===void 0)t[n]=e[n]};var Yr=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,Tr=/^([^[\]]*)\[([^\]]*)]$/,ge=(e,t,r,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return Object.select(t,o,r)?.toString()}return n?e:void 0},Vr=(e,t,r,n)=>{let o=ge(t,r,n);if(o)return Object.select(e,o,n);let s=Yr.exec(t);if(s){let[,a,u,m]=s,y=ge(a.trim(),r,n,!0),g=ge(m.trim(),r,n,!0);if(Array.isArray(e)&&(u==="="||u==="==")&&y)return e.find((O)=>O?.[y]==g)}let l=Tr.exec(t);if(l){let[,a,u]=l;return e?.[a]?.[u]}return e?.[t]};Object.select=(e,t,r)=>{let n=void 0,o=void 0,s=t??"",l=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},a=(g,O)=>{let[b,k]=l(O.pop());if(!b){if(r?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=r.set;return g}let w=Vr(g,b,e,r);if(w===void 0){if(k||r?.optional||r?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${b}" in "${s}"`)}return n=g,o=b,a(w,O)},u=s.splitNested(r?.separator??".","{","}"),m=void 0;if(u.length>0&&u[u.length-1].startsWith("?="))m=u.pop()?.substring(2);u.reverse();let y=a(e,u);if(y===void 0)return m??r?.defaultValue;return y};Object.deepClone=function(e){if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};Object.toList=function(e,t){return Object.entries(e).map(([r,n])=>({[t]:r,...n}))};Object.mapEntries=function(e,t){let r=Object.entries(e).map(([n,o])=>t(n,o));return Object.fromEntries(r)};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;global.defined=(e,t="Value is undefined")=>{if(e===void 0||e===null)throw Error(t);return e};String.prototype.tokenize=function(e,t=/\${([^}]+)}/g){return this.replace(t,(r,n)=>{let o=e[n];if(o===null||o===void 0)return"";if(typeof o==="string")return o;if(typeof o==="number"||typeof o==="boolean")return String(o);return String(o)})};String.prototype.toPascal=function(){return this.replace(/((?:[_ ]+)\w|^\w)/g,(e,t)=>t.toUpperCase()).replace(/[_ ]/g,"")};String.prototype.capitalize=function(){return this.replace(/((?:[ ]+)\w|^\w)/g,(e,t)=>t.toUpperCase())};String.prototype.toCamel=function(){return this.toPascal().replace(/((?:[ ]+\w)|^\w)/g,(e,t)=>t.toLowerCase())};String.prototype.toSnake=function(){return this.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/\s+/g,"_")};String.prototype.toKebab=function(){return this.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-")};String.prototype.changeCase=function(e){switch(e){case"upper":return this.toUpperCase();case"lower":return this.toLowerCase();case"pascal":return this.toPascal();case"camel":return this.toCamel();case"snake":return this.toSnake();case"kebab":return this.toKebab();default:throw Error(`Unsupported case type: ${e}`)}};String.prototype.splitWithQuotes=function(e=","){let t=[],r=this.length,n=e.length,o=0,s=(l)=>{if(l+n>r)return!1;for(let a=0;a<n;a++)if(this[l+a]!==e[a])return!1;return!0};while(o<r){while(o<r&&this[o]===" ")o++;if(o>=r)break;let l="",a=this[o]==='"'||this[o]==="'";if(a){let u=this[o++];while(o<r&&this[o]!==u)l+=this[o++];if(o<r)o++}else{while(o<r&&!s(o)){let u=this[o];if(u==='"'||u==="'"){l+=u,o++;while(o<r&&this[o]!==u)l+=this[o++];if(o<r)l+=this[o++]}else l+=this[o++]}l=l.trim()}if(l)t.push({value:l,quoted:a});if(s(o))o+=n}return t};String.prototype.splitNested=function(e,t,r){let n=0,o="",s=[];for(let l of this){if(o+=l,l===t)n++;if(l===r)n--;if(n===0&&l===e)s.push(o.slice(0,-1)),o=""}if(o)s.push(o);return s};String.prototype.padBlock=function(e,t=`
|
|
2
|
+
`,r=" "){let n=r.repeat(e);return this.split(t).map((o)=>n+o).join(t)};String.prototype.stripIndent=function(){let e=this.split(/\r?\n/),t=e.filter((n)=>n.trim().length>0).map((n)=>/^[ \t]*/.exec(n)?.[0].length??0),r=t.length>0?Math.min(...t):0;if(r===0)return this;return e.map((n)=>n.slice(r)).join(`
|
|
3
|
+
`)};var Ce=(e,t)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let r=e.value.slice(1,-1);if(r.trim()==="")return[];return r.split(";").map((n)=>{let o=n.trim();if(!isNaN(+o))return+o;return o})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return t(e.value)},re=(e,t,r,n,o,s)=>{let l=n?.(e)??e,a=o(l);if(a[0])return a[1];if(!t){let u=Object.select(r,e),m=o(u);if(m[0])return m[1]}throw Error(s)},De=(e,t,r,n,o)=>{let s=typeof e.types==="function"?e.types(n,t.value,o):e.types?.[n];if(!s||s==="ref")return Ce(t,(a)=>Object.select(r,a));let l=Ce(t,()=>t.value);if(Array.isArray(s)){if(!s.includes(l))throw Error(`Argument ${n.toString()} must be one of [${s.join(", ")}]: ${l}`);return l}if(typeof s==="string"){if(s.endsWith("?")){let a=s.slice(0,-1);if(t.value==="null")return j.ReplaceItem(null);if(t.value==="undefined")return j.ReplaceItem(void 0);if(t.value==="")return"";s=a}switch(s){case"any":return l;case"array":return re(l,t.quoted,r,null,(a)=>[Array.isArray(a),a],`Argument ${n.toString()} must be an array: ${l}`);case"object":return re(l,t.quoted,r,null,(a)=>[typeof a==="object"&&a!==null,a],`Argument ${n.toString()} must be an object: ${l}`);case"number":return re(l,t.quoted,r,(a)=>Number(a),(a)=>[!isNaN(a),a],`Argument ${n.toString()} must be a number: ${l}`);case"boolean":return re(l,t.quoted,r,null,(a)=>{if([!0,"true","1",1,"yes","on"].includes(a))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(a))return[!0,!1];if([null,"null","undefined",void 0,""].includes(a))return[!0,!1];if(Array.isArray(a))return[!0,a.length>0];return[!1,!1]},`Argument ${n.toString()} must be a boolean: ${l}`);case"string":return l.toString();default:throw Error(`Unknown type for argument ${n.toString()}: ${s}`)}}return s(l,r,n,t.quoted)},Ne=(e,t)=>{let r=e?.[t];if(r===void 0)throw Error(`Unhandled field processor type: ${t}`);return typeof r==="function"?{options:{},fn:r}:{options:r,fn:r.fn}},xe=(e)=>!e.quoted&&e.value.startsWith("."),zr=(e)=>{let t={};for(let r of e){if(!xe(r))continue;let n=r.value.indexOf("="),o=n>-1?r.value.slice(1,n):r.value.slice(1),s=n>-1?r.value.slice(n+1):"";if(s.length>=2){let l=s[0],a=s[s.length-1];if(l==='"'&&a==='"'||l==="'"&&a==="'")s=s.slice(1,-1)}if(!t[o])t[o]=[];t[o].push(s)}return t},Hr=(e,t,r)=>{let n=(e??"").splitWithQuotes(),o=zr(n),s=n.filter((a)=>!xe(a)),l=t.options.processArgs===!1?[]:s.map((a,u)=>De(t.options,a,r,u,s));return{rawArgs:s,parsedArgs:l,tags:o}},Gr=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Qr=(e,t)=>t.keys!==void 0&&e.key.startsWith(".")&&t.keys[e.key.substring(1)]!==void 0,Zr=async(e,t,r,n)=>{let{key:o,parent:s}=e,l=Ne(n.keys,o.substring(1));if(l.options.processArgs!==!1&&(typeof l.options.types==="function"||l.options.types?.[0]!==void 0))e.value=De(l.options,{value:e.value,quoted:!1},r,0,[]);if(typeof e.value!=="string")await $(e.value,{...n,root:{...r,parent:e.parent,parents:e.parents},filters:[...n.filters??[],...l.options.filters??[]]});let a=await l.fn({path:t,root:r,parent:s,key:o,options:n,value:e.value,args:[],rawArgs:[],tags:{}});return Gr(a)?a:j.ReplaceParent(a)},Xr=async(e,t,r,n)=>{if(!t?.onSection&&!t?.onSectionConfig&&!t?.sections)return[e,!1];let o=/<@\s*section(?:\s*:\s*([\w-]+))?\s*@>([\s\S]*?)<@\s*\/\s*section\s*@>/g,s,l=e,a=0,u=!1,m={content:l,root:n,path:r,options:t,section:{}};while((s=o.exec(e))!==null){u=!0;let[y,g,O]=s,b=s.index,k=b+y.length,w=e[k]===`
|
|
4
|
+
`;if(w)k++;let A=b+a,M=k+a,v={},P=O,E=/(^|\r?\n)[ \t]*---[ \t]*(\r?\n|$)/m.exec(O);if(E){let W=O.slice(0,E.index),ue=E.index+E[0].length;P=O.slice(ue);let ee=W.stripIndent().trim();if(ee.length>0)try{v=t?.configParser?.(ee)??{}}catch(ce){throw Error(`Failed to parse YAML config for section: ${ce.message}`)}}else if(/^\r?\n/.test(P))P=P.replace(/^\r?\n/,"");P=P.stripIndent().replace(/(?:\r?\n[ \t]*)+$/,"").replace(/[ \t]+$/,"");let F={config:g?{...v,type:g}:v,content:P};if(m.content=l,m.section=F,Object.keys(F.config).length>0){if(await t.onSectionConfig?.(m)!==!1)await $(F.config,{...t,root:n})}let G=m.section.config.type?t.sections?.[m.section.config.type]:void 0,x;if(G)x=await G(m);else if(t.onSection)x=await t.onSection(m);if(F.trim)F.content=F.content.trim();if(F.indent)F.content=F.content.split(`
|
|
5
|
+
`).map((W)=>" ".repeat(F.indent)+W).join(`
|
|
6
|
+
`);let C="";if(x===!0||F.show)C=F.content;else if(typeof x==="string")C=x;if(w&&C!==""&&!C.endsWith(`
|
|
7
|
+
`))C+=`
|
|
8
|
+
`;let Q=l.lastIndexOf(`
|
|
9
|
+
`,A-1),Z=Q===-1?0:Q+1,X=l.slice(Z,A).trim().length===0?Z:A;l=l.slice(0,X)+C+l.slice(M),a+=C.length-(M-X),m.content=l}return[l,u]},Ie=(e)=>{let t=[],r=0;while(r<e.length)if(e[r]==="$"&&e[r+1]==="("&&(r===0||e[r-1]!=="\\")){let n=r;r+=2;let o=1;for(;r<e.length;r++)if(e[r]==="(")o++;else if(e[r]===")"){if(o--,o===0){t.push([n,r]);break}}if(o!==0)throw Error(`Unmatched opening $( at position ${n.toString()}`);r++}else r++;return t},me=Symbol.for("@homedev/fields:OverrideResult"),en=(e)=>({[me]:!0,value:e}),tn=(e)=>{return e!==null&&typeof e==="object"&&me in e&&e[me]===!0},_e=async(e,t,r)=>{for(let n=t.length-1;n>=0;n--){let[o,s]=t[n],l=e.slice(o+2,s),a=await _e(l,Ie(l),r);if(typeof a==="object")return a;let u=await r(a,e);if(tn(u))return u.value;e=e.slice(0,o)+u+e.slice(s+1)}return e},rn=async(e,t)=>_e(e,Ie(e),t),nn=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},on=/([\w\d.-_/]+):(.+)/,sn=async(e,t,r,n)=>{let o=await(async()=>{let s=on.exec(e);if(!s)return await Object.select(t,e);let[l,a,u]=s,m=Ne(n.sources,a),y=Hr(u,m,t);return await m.fn({args:y.parsedArgs,rawArgs:y.rawArgs,tags:y.tags,key:a,options:n,root:t,path:r,value:null})})();if(o===null||o===void 0)return"";if(typeof o==="object")return en(o);return o},Ue=async(e,t,r,n)=>{let o=await rn(t,(s)=>sn(s,r,e,n));if(nn(o))return o;if(o===t)return j.Explore();if(typeof o==="string"){let s=await Ue(e,o,r,n);if(s.action!==I.Explore)return s;return j.ReplaceItem(o)}return j.ReplaceItem(o)},$=async(e,t)=>{return t??={},await Object.navigate(e,async(r)=>{let n=[...r.path,r.key].join(".");if(t?.filters?.length&&t.filters.some((a)=>a.test(n)))return j.NoExplore();let o=r.path.length===0,s=r.parents.length>0?r.parents.toReversed():[];if(o){if(s.length>0)throw Error("Root object should not have a parent");s=t?.root?.parents?[t.root.parent,...t.root.parents.toReversed()]:[]}let l={...e,...t.root,this:r.parent,parent:s.length>0?s[0]:null,parents:s};try{if(r.key.startsWith("$"))return j.NoExplore();let a=j.Explore();if(typeof r.value==="string"){let u=r.value,m=!1;while(!0){let[y,g]=await Xr(u,t,n,l);if(m=m||g,a=await Ue(n,y,l,t),a.action===I.ReplaceItem&&typeof a.by==="string"){u=a.by;continue}if(a.action===I.Explore&&g&&y!==u)a=j.ReplaceItem(y);break}if(a.action===I.Explore&&u!==r.value)a=j.ReplaceItem(u);switch(a.action){case I.Explore:break;case I.ReplaceItem:r.value=a.by;break;default:return a}}if(Qr(r,t))a=await Zr(r,n,l,t);return a}catch(a){throw Error(`${a.message}
|
|
10
|
+
(${n})`)}}),e},Le=(e,t)=>t?{fn:(r)=>e(...r.args),types:t}:(r)=>e(...r.args),Fn=(e,t)=>Object.fromEntries(e.map((r)=>[r.name,Le(r,t?.types?.[r.name])])),J=(e,t)=>Object.fromEntries((t?.keys??Object.keys(e)).map((r)=>[r,Le(e[r],t?.types?.[r])]));import We from"fs/promises";import ye from"path";import an from"fs/promises";import ln from"path";import un from"fs/promises";import fn from"fs/promises";import Ye from"fs/promises";import Be from"path";import gn from"fs/promises";import he from"path";import qe from"path";var be=async(e)=>{try{return await We.access(e,We.constants.R_OK),!0}catch{return!1}},ne=async(e,t)=>{let r=!ye.isAbsolute(e)&&t?["",...t]:[""];for(let n of r){let o=ye.join(n,e);if(await be(o))return ye.resolve(o)}throw Error(`File not found: "${e}"`)},Ke=async(e,t)=>{let r=await ne(e,t?.dirs),n=await an.readFile(r,"utf-8"),o=ln.dirname(r),s={text:{fn:(a)=>a,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...t?.parsers},l=t?.format?s[t.format]:Object.values(s).find((a)=>a.matching?.some((u)=>new RegExp(u).test(e)));if(!l)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await l.fn(n),fullPath:r,folderPath:o}},cn=async(e,t,r)=>{let n={text:{fn:(s)=>s,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...r?.encoders},o=r?.format?n[r.format]:Object.values(n).find((s)=>s.matching?.some((l)=>new RegExp(l).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await un.writeFile(e,await o.fn(t))},Je=async(e,t)=>{if(typeof e==="string"&&!e.includes("*"))return await t.map(e,0,[]);let r=await Array.fromAsync(fn.glob(e,{cwd:t.cwd})),n=t.filter?r.filter(t.filter):r;return await Promise.all(n.map(t.map))},Te=async(e,t)=>{if(t?.targetDirectory&&t?.removeFirst)try{await Ye.rm(t?.targetDirectory,{recursive:!0,force:!0})}catch(r){throw Error(`Failed to clean the output directory: ${r.message}`)}for(let r of e)await pn(r,t)},pn=async(e,t)=>{let r=Be.join(t?.targetDirectory??".",e.name),n=Be.dirname(r);if(t?.classes){if(e.class!==void 0&&!t.classes.includes(e.class))return;if(t.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(t?.writing?.(e)===!1)return;try{await Ye.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${r}": ${o.message}`)}try{await cn(r,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${r}": ${o.message}`)}},de=(e)=>e?qe.isAbsolute(e)?e:qe.join(process.cwd(),e):process.cwd(),mn=async(e,t)=>{let r=[];for(let n of e)try{let o=!he.isAbsolute(n)?he.join(de(t?.cwd),n):n;if(t?.filter?.(o)===!1)continue;let s=await import(o);if(t?.resolveDefault==="only"&&!s.default)throw Error(`Module ${n} does not have a default export`);let l=t?.resolveDefault?s.default??s:s,a=t?.map?await t.map(l,n):l;if(a!==void 0)r.push(a)}catch(o){if(t?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return r},Wn=async(e,t)=>{let r=[];for(let n of e){let o=(await Array.fromAsync(gn.glob(n,{cwd:de(t?.cwd)}))).map((s)=>he.join(de(t?.cwd),s));r.push(...await mn(o,t))}return r};class Y{o;context;constructor(e){this.o=e}}var f=(e)=>(t,r)=>{r.addInitializer(function(){let n=this[r.name],o=e?.name??r.name;this.o.sources({[o]:(s)=>n.apply({...this,context:s},s.args)})})},qn=(e)=>(t,r)=>{r.addInitializer(function(){let n=this[r.name],o=e?.name??r.name;this.o.sections({[o]:(s)=>{return n.call({...this,context:s},s.section)}})})},Kn=(e)=>(t,r)=>{r.addInitializer(function(){let n=this[r.name],o=e?.name??r.name;this.o.keys({[o]:(s)=>n.call({...this,context:s},s.value)})})},Jn=(e)=>(t,r)=>{r.addInitializer(function(){let n=this[r.name],o=e?.name??r.name;this.o.variables({[o]:n})})},Yn=(e)=>(t,r)=>{r.addInitializer(function(){let n=this[r.name],o=e?.name??r.name;this.o.functions({[o]:n})})},Tn=(e)=>(t,r)=>{r.addInitializer(function(){let n=this[r.name],o=e?.name??r.name;this.o.encoders({[o]:{fn:n}})})},Vn=(e)=>(t,r)=>{r.addInitializer(function(){let n=this[r.name],o=e?.name??r.name;this.o.decoders({[o]:{fn:n}})})};import{createHash as L}from"crypto";import N from"path";var Ve=(e)=>({output:(t)=>{delete t.parent[t.key];for(let r of Array.isArray(t.value)?t.value:[t.value])if(typeof r==="string")e.output({name:r,value:t.parent});else e.output({...r,value:r.value??t.parent});return d.SkipSiblings()}});import yn from"path";var ze=(e)=>({load:async(t)=>{let r=t.options.globalContext;for(let{file:n}of Array.isArray(t.value)?t.value:[t.value]){if(!n)throw Error("File reference required");await e.load(n,r.file&&yn.dirname(r.file))}return d.DeleteItem()}});class we{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,t){this.evictIfNeeded(),this.cache.set(e,t)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,t=1/0;for(let[r,n]of this.cache.entries())if(n.timestamp<t)t=n.timestamp,e=r;if(e)this.cache.delete(e)}}}var oe=(e)=>{if(typeof e.value==="string")return e.parent;let t=e.value.model;if(!t)return e.parent;if(typeof t==="string")return Object.select(e.root,t);return t};var ie=(e)=>{if(typeof e.value==="string")return Object.select(e.root,e.value);if(Array.isArray(e.value))return e.value;let t=e.value;if(typeof t.from==="string")return Object.select(e.root,t.from);return t.from};var se=async(e,t)=>{let r=e.value;if(r.selector===void 0)return t;if(typeof r.selector!=="string"){let n=JSON.parse(JSON.stringify(r.selector));return await $(n,{...e.options,root:{...e.root,result:t}}),n}return await Object.select({...e.root,result:t},r.selector)};import _ from"path";class U{constructor(){}static normalize(e){return _.normalize(_.resolve(e))}static resolveInContext(e,t){let r=t??process.cwd(),n=_.isAbsolute(e)?e:_.join(r,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,t){if(_.isAbsolute(e))return e;return _.join(t??process.cwd(),e)}}var D={and:(...e)=>e.every((t)=>!!t),or:(...e)=>e.some((t)=>!!t),xor:(...e)=>e.filter((t)=>!!t).length===1,true:(...e)=>e.every((t)=>!!t),false:(...e)=>e.every((t)=>!t),eq:(...e)=>e.every((t)=>t===e[0]),ne:(...e)=>e.some((t)=>t!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((t)=>typeof t==="number"&&e[0]<t),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((t)=>typeof t==="number"&&e[0]<=t),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((t)=>typeof t==="number"&&e[0]>t),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((t)=>typeof t==="number"&&e[0]>=t),in:(e,t)=>{if(Array.isArray(t))return t.includes(e);if(typeof e==="string")return e.includes(t);if(Array.isArray(e))return e.includes(t);return!1},notin:(e,t)=>!D.in(e,t),contains:(e,t)=>e.includes(t),notcontains:(e,t)=>!e.includes(t),containsi:(e,t)=>e.toLowerCase().includes(t.toLowerCase()),notcontainsi:(e,t)=>!e.toLowerCase().includes(t.toLowerCase()),null:(...e)=>e.every((t)=>t===null||t===void 0),notnull:(...e)=>e.every((t)=>t!==null&&t!==void 0),empty:(...e)=>e.every((t)=>t===""),notempty:(...e)=>e.every((t)=>t!==""),nullorempty:(...e)=>e.every((t)=>t===null||t===void 0||t===""),notnullorempty:(...e)=>e.every((t)=>t!==null&&t!==void 0&&t!=="")},ae={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var He=()=>({each:{filters:[/select|model/],fn:async(e)=>{let t=e.value;delete e.parent[e.key];let r=await ie(e),n=await oe(e);if(!Array.isArray(r))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(t.extend?.model)n=[t.model,...Array.isArray(t.extend.model)?t.extend.model:[t.extend.model]].mergeAll();let o=[];for(let s=0;s<r.length;s++){let l=Object.deepClone(n);if(await $(l,{...e.options,root:{...e.root,index:s,item:r[s],instance:l}}),t.extend?.result){let a=t.extend.result;l=[l,...Array.isArray(a)?a:[a]].mergeAll()}o.push(await se(e,l))}return o}}});var Ge=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let t=await ie(e),r=await oe(e);if(!Array.isArray(t))throw Error('Key "map" requires a source list');if(r===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<t.length;o++){let s=Object.deepClone(r);await $(s,{...e.options,root:{...e.root,index:o,item:t[o],instance:s}}),n.push(await se(e,s))}return n}}});var Qe=()=>({concat:async(e)=>{let t=[];for(let r of Array.isArray(e.value)?e.value:[e.value])t.push(...await Object.select(e.root,r));return t.filter((r)=>r!==void 0)}});Array.prototype.findOrFail=function(e,t,r){let n=this.find(e,r);if(n===void 0)throw Error(t??"Element not found");return n};Array.flat=function(e){if(Array.isArray(e))return e.flat(2);else return[e]};Array.prototype.forEachAsync=async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this)};Array.prototype.groupBy=function(e){return this.reduce((t,r)=>{let n=e(r);if(!t[n])t[n]=[];return t[n].push(r),t},{})};Array.prototype.createInstances=function(e,...t){return this.map((r,n)=>new e(...t,r,n))};Array.prototype.mapAsync=async function(e){return Promise.all(this.map(e))};Array.prototype.nonNullMap=function(e){let t=[];for(let r=0;r<this.length;r++){let n=e(this[r],r,this);if(n!=null)t.push(n)}return t};Array.prototype.nonNullMapAsync=async function(e){let t=[];for(let r=0;r<this.length;r++){let n=await e(this[r],r,this);if(n!=null)t.push(n)}return t};Array.prototype.mergeAll=function(e){let t={};for(let r of this.toReversed())Object.merge(r,t,e);return t};Array.prototype.toObject=function(e,t){return Object.fromEntries(this.map((r)=>{let n=e(r),o=t?t(r):r;return[n,o]}))};Array.prototype.toObjectWithKey=function(e){return Object.fromEntries(this.map((t)=>[String(t[e]),t]))};Array.prototype.selectFor=function(e,t,r,n){let o=this.find(e,n);if(o===void 0)throw Error(r??"Element not found");return t(o)};Array.prototype.sortBy=function(e,t=!0){return this.slice().sort((r,n)=>{let o=e(r),s=e(n);if(o<s)return t?-1:1;if(o>s)return t?1:-1;return 0})};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(e){let t=new Set;return this.filter((r)=>{let n=e(r);if(t.has(n))return!1;else return t.add(n),!0})};var hn;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(hn||={});class d{action;by;skipSiblings;reexplore;constructor(e,t,r,n){this.action=e,this.by=t,this.skipSiblings=r,this.reexplore=n}static _explore=new d(0);static _noExplore=new d(2);static _skipSiblings=new d(1);static _deleteParent=new d(4);static ReplaceParent(e,t){return new d(3,e,void 0,t)}static SkipSiblings(){return d._skipSiblings}static Explore(){return d._explore}static NoExplore(){return d._noExplore}static DeleteParent(){return d._deleteParent}static MergeParent(e){return new d(5,e)}static ReplaceItem(e,t){return new d(6,e,t)}static DeleteItem(e){return new d(7,void 0,e)}}Object.navigate=async(e,t)=>{let r=new WeakSet,n=[],o=[],s=async(a,u,m)=>{let y=a===null,g=y?d.Explore():await t({key:a,value:u,path:n,parent:m,parents:o});if(u&&typeof u==="object"&&g.action===0){if(r.has(u))return g;if(r.add(u),!y)n.push(a),o.push(m);let O=u;while(await l(O,a,m))O=m[a];if(!y)o.pop(),n.pop()}return g},l=async(a,u,m)=>{let y=Object.keys(a),g=y.length;for(let O=0;O<g;O++){let b=y[O],k=a[b],w=await s(b,k,a),A=w.action;if(A===0||A===2)continue;if(A===6){if(a[b]=w.by,w.skipSiblings)return;continue}if(A===7){if(delete a[b],w.skipSiblings)return;continue}if(A===1)return;if(A===3){if(u===null)throw Error("Cannot replace root object");if(m[u]=w.by,w.reexplore)return!0;return}if(A===4){if(u===null)throw Error("Cannot delete root object");delete m[u];return}if(A===5)delete a[b],Object.assign(a,w.by)}};await s(null,e,null)};Object.find=async function(e,t){let r=[];return await Object.navigate(e,(n)=>{if(t([...n.path,n.key].join("."),n.value))r.push(n.value);return d.Explore()}),r};Object.merge=(e,t,r)=>{for(let n of Object.keys(t)){if(e[n]===void 0)continue;let o=t[n],s=e[n];if(typeof s!==typeof o||Array.isArray(s)!==Array.isArray(o)){let a=r?.mismatch?.(n,s,o,e,t);if(a!==void 0){t[n]=a;continue}throw Error(`Type mismatch: ${n}`)}let l=r?.mode?.(n,s,o,e,t)??t[".merge"]??"merge";switch(l){case"source":t[n]=s;continue;case"target":continue;case"skip":delete t[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${l}`)}if(typeof s==="object")if(Array.isArray(s))o.push(...s);else{if(r?.navigate?.(n,s,o,e,t)===!1)continue;Object.merge(s,o,r)}else{if(s===o)continue;let a=r?.conflict?.(n,s,o,e,t);t[n]=a===void 0?o:a}}for(let n of Object.keys(e))if(t[n]===void 0)t[n]=e[n]};var dn=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,bn=/^([^[\]]*)\[([^\]]*)]$/,Oe=(e,t,r,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return Object.select(t,o,r)?.toString()}return n?e:void 0},wn=(e,t,r,n)=>{let o=Oe(t,r,n);if(o)return Object.select(e,o,n);let s=dn.exec(t);if(s){let[,a,u,m]=s,y=Oe(a.trim(),r,n,!0),g=Oe(m.trim(),r,n,!0);if(Array.isArray(e)&&(u==="="||u==="==")&&y)return e.find((O)=>O?.[y]==g)}let l=bn.exec(t);if(l){let[,a,u]=l;return e?.[a]?.[u]}return e?.[t]};Object.select=(e,t,r)=>{let n=void 0,o=void 0,s=t??"",l=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},a=(g,O)=>{let[b,k]=l(O.pop());if(!b){if(r?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=r.set;return g}let w=wn(g,b,e,r);if(w===void 0){if(k||r?.optional||r?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${b}" in "${s}"`)}return n=g,o=b,a(w,O)},u=s.splitNested(r?.separator??".","{","}"),m=void 0;if(u.length>0&&u[u.length-1].startsWith("?="))m=u.pop()?.substring(2);u.reverse();let y=a(e,u);if(y===void 0)return m??r?.defaultValue;return y};Object.deepClone=function(e){if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};Object.toList=function(e,t){return Object.entries(e).map(([r,n])=>({[t]:r,...n}))};Object.mapEntries=function(e,t){let r=Object.entries(e).map(([n,o])=>t(n,o));return Object.fromEntries(r)};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;global.defined=(e,t="Value is undefined")=>{if(e===void 0||e===null)throw Error(t);return e};String.prototype.tokenize=function(e,t=/\${([^}]+)}/g){return this.replace(t,(r,n)=>{let o=e[n];if(o===null||o===void 0)return"";if(typeof o==="string")return o;if(typeof o==="number"||typeof o==="boolean")return String(o);return String(o)})};String.prototype.toPascal=function(){return this.replace(/((?:[_ ]+)\w|^\w)/g,(e,t)=>t.toUpperCase()).replace(/[_ ]/g,"")};String.prototype.capitalize=function(){return this.replace(/((?:[ ]+)\w|^\w)/g,(e,t)=>t.toUpperCase())};String.prototype.toCamel=function(){return this.toPascal().replace(/((?:[ ]+\w)|^\w)/g,(e,t)=>t.toLowerCase())};String.prototype.toSnake=function(){return this.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/\s+/g,"_")};String.prototype.toKebab=function(){return this.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-")};String.prototype.changeCase=function(e){switch(e){case"upper":return this.toUpperCase();case"lower":return this.toLowerCase();case"pascal":return this.toPascal();case"camel":return this.toCamel();case"snake":return this.toSnake();case"kebab":return this.toKebab();default:throw Error(`Unsupported case type: ${e}`)}};String.prototype.splitWithQuotes=function(e=","){let t=[],r=this.length,n=e.length,o=0,s=(l)=>{if(l+n>r)return!1;for(let a=0;a<n;a++)if(this[l+a]!==e[a])return!1;return!0};while(o<r){while(o<r&&this[o]===" ")o++;if(o>=r)break;let l="",a=this[o]==='"'||this[o]==="'";if(a){let u=this[o++];while(o<r&&this[o]!==u)l+=this[o++];if(o<r)o++}else{while(o<r&&!s(o)){let u=this[o];if(u==='"'||u==="'"){l+=u,o++;while(o<r&&this[o]!==u)l+=this[o++];if(o<r)l+=this[o++]}else l+=this[o++]}l=l.trim()}if(l)t.push({value:l,quoted:a});if(s(o))o+=n}return t};String.prototype.splitNested=function(e,t,r){let n=0,o="",s=[];for(let l of this){if(o+=l,l===t)n++;if(l===r)n--;if(n===0&&l===e)s.push(o.slice(0,-1)),o=""}if(o)s.push(o);return s};String.prototype.padBlock=function(e,t=`
|
|
11
|
+
`,r=" "){let n=r.repeat(e);return this.split(t).map((o)=>n+o).join(t)};String.prototype.stripIndent=function(){let e=this.split(/\r?\n/),t=e.filter((n)=>n.trim().length>0).map((n)=>/^[ \t]*/.exec(n)?.[0].length??0),r=t.length>0?Math.min(...t):0;if(r===0)return this;return e.map((n)=>n.slice(r)).join(`
|
|
12
|
+
`)};function Po(e,t="Value is undefined"){if(e===void 0||e===null)throw Error(t);return e}class On{options;constructor(e){this.options={level:"INFO",showClass:!1,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},logFunction:(t,...r)=>{switch(t){case"ERROR":console.error(...r);break;case"WARN":console.warn(...r);break;case"DEBUG":console.debug(...r);break;case"VERBOSE":console.log(...r);break;default:console.log(...r)}},...e}}write(e,...t){if(this.options.level){let o=this.options.levels.indexOf(this.options.level)??-1,s=this.options.levels.indexOf(e);if(s===-1)throw Error(`Unknown log level: ${e}`);if(s<o)return}let r=[],n=[];if(this.options.timeStamp)n.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)n.push(e);if(n.length>0)r.push(`[${n.join(" ")}]`);r.push(...t),this.options.logFunction(e,...r)}info(...e){this.write("INFO",...e)}error(...e){this.write("ERROR",...e)}warn(...e){this.write("WARN",...e)}debug(...e){this.write("DEBUG",...e)}verbose(...e){this.write("VERBOSE",...e)}}var Ze=()=>({extends:async(e)=>{let t=async(r,n)=>{for(let o of Array.isArray(n)?n:[n]){let s=await Object.select(e.root,o),l=Object.deepClone(s);if(l[e.key])await t(l,l[e.key]);await $(l,{...e.options}),Object.merge(l,r),delete r[e.key]}};return await t(e.parent,e.value),d.Explore()},group:(e)=>{let t=e.root.parent,r=e.value,{items:n,...o}=r;return r.items.forEach((s)=>t.push({...o,...s})),d.DeleteParent()}});var Xe=(e)=>({skip:{types:{0:"boolean"},fn:(t)=>t.value?d.DeleteParent():d.DeleteItem()},metadata:({path:t,value:r})=>{return e.metadata(t,r),d.DeleteItem()},if:{types:{0:"boolean"},fn:async(t)=>{let r=t.parent[".then"],n=t.parent[".else"];if(r!==void 0)delete t.parent[".then"];if(n!==void 0)delete t.parent[".else"];let o=t.value?r:n;if(o===void 0)return d.DeleteItem();if(typeof o==="string")return(await $({value:o},{...t.options,root:{...t.root}})).value;return d.ReplaceParent(o,!0)}},switch:(t)=>{let r=t.value;if(!r.cases)throw Error("Missing cases for switch");if(r.cases[r.from]!==void 0)return d.ReplaceParent(r.cases[r.from],!0);if(r.default!==void 0)return d.ReplaceParent(r.default,!0);return d.DeleteParent()}});var et=()=>({from:async({root:e,parent:t,value:r})=>{let n=await Object.select(e,r);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${r}`);if(t.content){if(Array.isArray(t.content)&&Array.isArray(n))return[...n,...t.content];return Object.merge(n,t.content),t.content}return n}});import tt from"node:vm";var rt=(e)=>({modules:async(t)=>{for(let[r,n]of Object.entries(t.value)){let o=tt.createContext({console,objector:e,document:t.root}),s=new tt.SourceTextModule(n,{identifier:r,context:o});await s.link((l)=>{throw Error(`Module ${l} is not allowed`)}),await s.evaluate(),e.sources(Object.fromEntries(Object.entries(s.namespace).map(([l,a])=>[`${r}.${l}`,(u)=>a(u,...u.args)])))}return d.DeleteItem()}});var nt=()=>({try:{fn:(e)=>{let t=e.parent[".catch"];if(t!==void 0)delete e.parent[".catch"];try{return e.value}catch(r){if(t!==void 0)return t;return d.DeleteItem()}}}});var ot=()=>({let:{fn:(e)=>{let t=e.value;return Object.assign(e.root,t),d.DeleteItem()}}});var it=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var An=(e,t)=>{let r=t.section.config.using,n=e.getFunctions();return r?Object.fromEntries(r.map((o)=>{if(o in n)return[o,n[o]];if(o in t.root)return[o,t.root[o]];throw Error(`Function or variable "${o}" not found for script section`)})):n},Ae=(e,t,r,n,o=[])=>{let s=An(e,r),l=["section","context","config","system",...Object.keys(s),...o],a=[t,r.root,r.section.config,e,...Object.values(s)];return[new AsyncFunction(...l,n).bind(r),a]},jn=(e,t)=>{let r={write:(...n)=>{return t.push(...n),r},writeLine:(...n)=>{return t.push(...n.map((o)=>o+`
|
|
13
|
+
`)),r},clear:()=>{return t.splice(0,t.length),r},prepend:(...n)=>{return t.unshift(...n),r},prependLine:(...n)=>{return t.unshift(...n.map((o)=>o+`
|
|
14
|
+
`)),r},setOptions:(n)=>{return Object.assign(e.section,n),r},use:(n)=>{return n(r),r},getLines:()=>t};return r},Sn=async(e,t,r)=>{let n=r.section.config.condition;if(n!==void 0){let[o,s]=Ae(e,t,r,`return (${n})`);if(!await o(...s))return!1}return!0},st=(e)=>async(t)=>{let r=[],n=jn(t,r);if(!await Sn(e,n,t))return!1;let[o,s]=Ae(e,n,t,t.section.content,["item"]),l=t.section.config.each;if(l){let[a,u]=Ae(e,n,t,`return (${l})`),m=Array.isArray(l)?l:await a(...u);if(!Array.isArray(m))throw Error('The "each" property of a script section must return an array');for(let y of m){let g=await o(...s,y);if(typeof g<"u")r.push(g)}}else{let a=await o(...s);if(typeof a<"u")return a}if(r.length===0)return!1;return r.join("")};var at=(e)=>({script:st(e)});import lt from"fs/promises";import T from"path";var ut=(e)=>({include:async(t)=>{let{file:r}=t.options.globalContext;return await Je(t.args[0],{cwd:T.dirname(r),filter:(n)=>T.basename(r)!==n,map:async(n)=>e.load(n,T.dirname(r),t.root)})},exists:async({args:[t]})=>await be(t),file:async(t)=>await lt.readFile(await ne(t.args[0],e.getIncludeDirectories())).then((r)=>r.toString()),scan:async(t)=>{let r=[],o=(()=>{let a=t.args[2]??["**/node_modules/**"],u=typeof a==="string"?a.split(",").map((m)=>m.trim()):a;if(!Array.isArray(u))throw Error("Scan exclusion must be a list");return u})(),{file:s}=t.options.globalContext,l=t.args[1]?await ne(t.args[1],e.getIncludeDirectories()):T.dirname(s);for await(let a of lt.glob(t.args[0],{cwd:l,exclude:(u)=>o.some((m)=>T.matchesGlob(u,m))}))r.push(a);return r}});var ct=(e)=>({substring:{types:{0:"ref",1:"number",2:"number"},fn:(t)=>t.args[0].substring(t.args[1],t.args[2])},repeat:{types:{0:"ref",1:"number"},fn:({args:[t,r]})=>t.repeat(r)},pad:{types:{0:"ref",1:"number",2:"string"},fn:({args:[t,r],tags:n})=>{let o=n.join?.[0]??`
|
|
15
|
+
`,s=n.padChar?.[0]??" ";return t.padBlock(r??2,o,s)}},formatAs:{fn:({args:[t,r],tags:n})=>{let o=e.getEncoder(r);if(!o)throw Error("Unsupported format: "+String(r));let s=[];if(o.options?.includeTags)s=[n];return o.fn(t,...s)}}});var le=(e,t=0,r)=>{let n=" ".repeat(t),o=" ".repeat(t+1);if(e===null||e===void 0)return"null";else if(typeof e==="boolean")return String(e);else if(typeof e==="number")return String(e);else if(typeof e==="string")return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;else if(Array.isArray(e)){if(e.length===0)return"[]";return`[
|
|
16
|
+
${e.map((l)=>`${o}${le(l,t+1)},`).join(`
|
|
16
17
|
`)}
|
|
17
|
-
${n}]`}else if(typeof e==="object"){let
|
|
18
|
-
${
|
|
18
|
+
${n}]`}else if(typeof e==="object"){let s=Object.entries(e).sort((a,u)=>r?.sortKeys?a[0].localeCompare(u[0]):0);if(s.length===0)return"{}";return`{
|
|
19
|
+
${s.map(([a,u])=>`${o}${a} = ${le(u,t+1,r)}`).join(`
|
|
19
20
|
`)}
|
|
20
|
-
${n}}`}else return String(e)},
|
|
21
|
-
`).replaceAll("\\$","$").replaceAll("\\t","\t")};var
|
|
22
|
-
`,
|
|
23
|
-
`,f):b}return y}}});var Oe=async(e,r,t)=>e.rawArgs[r].quoted?e.rawArgs[r].value:await x(e.root,e.rawArgs[r].value,{defaultValue:t}),At=()=>({switch:{processArgs:!1,fn:async(e)=>{let r=await Oe(e,0,!1),t=await Oe(e,1);if(t[r]===void 0){if(e.rawArgs.length>2)return Oe(e,2);throw Error(`Unhandled switch case: ${r}`)}return t[r]}}});var vt=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(K)},fn:(e)=>K[e.args[0]](...e.args.slice(1))},...B(K,{types:ye})});var Tt=(e)=>({default:{processArgs:!1,fn:async(r)=>{for(let t=0;t<r.rawArgs.length;t++)if(r.rawArgs[t]?.value!==void 0){let o=await Oe(r,t,null);if(o!==null)return o}if(r.tags.nullable?.length)return E.DeleteItem();if(r.tags.fail?.length)throw Error(`No valid value found for default (${r.rawArgs.map((t)=>t.value).join(", ")})`);return""}},section:{types:["string","boolean"],fn:(r)=>{let t=r.args[0];if(!(r.args[1]??!0))return null;let o=e.getSection(t);if(!o)throw Error(`Section not found: ${t}`);return o.content}}});var Et=()=>({convert:({args:[e,r,t]})=>{switch(r){case"string":return String(e);case"number":{let n=Number(e);if(!isNaN(n))return E.ReplaceItem(n);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return E.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return E.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${r}`)}if(t!==void 0)return E.ReplaceItem(t);throw Error(`Failed to convert value to ${r}`)},isType:({args:[e,r]})=>{let n=(()=>{switch(r){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${r}`)}})();return E.ReplaceItem(n)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var vr=(e)=>{var r,t,n,o,i,l,a,c,w,O,y,u,d,v,g,A,f,S,b,M,k,ve,Y,L,Te,Ee,Me,oe,Pe,Se,Ve,Ct,Wt,Nt,Kt,Ut,It,Lt,_t,Bt,Pt,Vt,Yt,Gt,Qt,Xt,Zt,Ht,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,cn,fn,pn,mn,gn,yn,dn,hn,wn,bn,On,An,vn,Tn,En,Mn,Sn,kn,xn,Fn,Dn,jn,Rn,$n,Cn,Wn,Nn,Kn,Un,In,Ln,_n,Bn,Pn,Vn,Yn,Gn,Qn,Xn,Zn,Hn,qn,zn,Jn,o,i,l,a,c,w,O,y,u,d,v,g,A,f,S,b,M,k,ve,Y,L,Te,Ee,Me,oe,Pe,Se,Ve,Ct,Wt,Nt,Kt,Ut,It,Lt,_t,Bt,Pt,Vt,Yt,Gt,Qt,Xt,Zt,Ht,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,cn,fn,pn,mn,gn,yn,dn,hn,wn,bn,On,An,vn,Tn,En,Mn,Sn,kn,xn,Fn,Dn,jn,Rn,$n,Cn,Wn,Nn,Kn,Un,In,Ln,_n,Bn,Pn,Vn,Yn,Gn,Qn,Xn,Zn,Hn,qn,zn,Jn;return e.use((n=P,o=[p()],i=[p()],l=[p()],a=[p()],c=[p()],w=[p()],O=[p()],y=[p()],u=[p()],d=[p()],v=[p()],g=[p()],A=[p()],f=[p()],S=[p()],b=[p()],M=[p()],k=[p()],ve=[p()],Y=[p()],L=[p()],Te=[p()],Ee=[p()],Me=[p()],oe=[p()],Pe=[p()],Se=[p()],Ve=[p()],Ct=[p()],Wt=[p()],Nt=[p()],Kt=[p()],Ut=[p()],It=[p()],Lt=[p()],_t=[p()],Bt=[p()],Pt=[p()],Vt=[p()],Yt=[p()],Gt=[p()],Qt=[p()],Xt=[p()],Zt=[p()],Ht=[p()],qt=[p()],zt=[p()],Jt=[p()],en=[p()],rn=[p()],tn=[p()],nn=[p()],on=[p()],sn=[p()],an=[p()],ln=[p()],un=[p()],cn=[p()],fn=[p()],pn=[p()],mn=[p()],gn=[p()],yn=[p()],dn=[p()],hn=[p()],wn=[p()],bn=[p()],On=[p()],An=[p()],vn=[p()],Tn=[p()],En=[p()],Mn=[p()],Sn=[p()],kn=[p()],xn=[p()],Fn=[p()],Dn=[p()],jn=[p()],Rn=[p()],$n=[p()],Cn=[p()],Wn=[p()],Nn=[p()],Kn=[p()],Un=[p()],In=[p()],Ln=[p()],_n=[p()],Bn=[p()],Pn=[p()],Vn=[p()],Yn=[p()],Gn=[p()],Qn=[p()],Xn=[p()],Zn=[p()],Hn=[p()],qn=[p()],zn=[p()],Jn=[p()],t=jr(n),r=class extends n{constructor(){super(...arguments);$r(t,5,this)}env(s){return process.env[s]}uuid(){return crypto.randomUUID()}pascal(s){return ee(s)}camel(s){return we(s)}capital(s){return he(s)}snake(s,h){return te(re(s,"_"),h)}kebab(s,h){return te(re(s,"-"),h)}len(s){return s.length}reverse(s){return s.split("").reverse().join("")}concat(...s){return s.join("")}trim(s){return s.trim()}ltrim(s){return s.trimStart()}rtrim(s){return s.trimEnd()}lower(s){return s.toLowerCase()}upper(s){return s.toUpperCase()}encode(s,h){return Buffer.from(s).toString(h??"base64")}decode(s,h){return Buffer.from(s,h??"base64").toString()}list(s,h){return Z(s,h)}object(s,h){return ge(s,h)}pathJoin(...s){return V.join(...s)}resolve(...s){return V.resolve(...s)}dirname(s){return V.dirname(s)}basename(s,h){return V.basename(s,h)}normalize(s){return V.normalize(s)}extname(s){return V.extname(s)}relative(s,h){return V.relative(s,h)}isAbsolute(s){return V.isAbsolute(s)}segments(s){return s.split("/").filter(Boolean)}log(...s){console.log(...s)}md5(s){return ne("md5").update(s).digest("hex")}sha1(s){return ne("sha1").update(s).digest("hex")}sha256(s){return ne("sha256").update(s).digest("hex")}sha512(s){return ne("sha512").update(s).digest("hex")}hash(s,h="sha256"){return ne(h).update(s).digest("hex")}hmac(s,h,T="sha256"){return ne(T).update(s).digest("hex")}base64Encode(s){return Buffer.from(s).toString("base64")}base64Decode(s){return Buffer.from(s,"base64").toString("utf-8")}hexEncode(s){return Buffer.from(s).toString("hex")}hexDecode(s){return Buffer.from(s,"hex").toString("utf-8")}add(...s){return s.reduce((h,T)=>h+T,0)}subtract(s,h){return s-h}multiply(...s){return s.reduce((h,T)=>h*T,1)}divide(s,h){if(h===0)throw Error("Division by zero");return s/h}modulo(s,h){return s%h}power(s,h){return Math.pow(s,h)}sqrt(s){return Math.sqrt(s)}abs(s){return Math.abs(s)}floor(s){return Math.floor(s)}ceil(s){return Math.ceil(s)}round(s,h){let T=Math.pow(10,h??0);return Math.round(s*T)/T}min(...s){return Math.min(...s)}max(...s){return Math.max(...s)}clamp(s,h,T){return Math.max(h,Math.min(T,s))}random(s,h){let T=s??0,R=h??1;return Math.random()*(R-T)+T}timestamp(s){return new Date(s).getTime()}iso(s){return new Date(s).toISOString()}utc(s){return new Date(s).toUTCString()}formatDate(s,h){let T=new Date(s),R=T.getFullYear(),I=String(T.getMonth()+1).padStart(2,"0"),ke=String(T.getDate()).padStart(2,"0"),ie=String(T.getHours()).padStart(2,"0"),eo=String(T.getMinutes()).padStart(2,"0"),ro=String(T.getSeconds()).padStart(2,"0");return h.replace("YYYY",String(R)).replace("MM",I).replace("DD",ke).replace("HH",ie).replace("mm",eo).replace("ss",ro)}parseDate(s){return new Date(s).getTime()}year(s){return new Date(s).getFullYear()}month(s){return new Date(s).getMonth()+1}day(s){return new Date(s).getDate()}dayOfWeek(s){return new Date(s).getDay()}hours(s){return new Date(s).getHours()}minutes(s){return new Date(s).getMinutes()}seconds(s){return new Date(s).getSeconds()}regexTest(s,h,T){return new RegExp(s,T).test(h)}regexMatch(s,h,T){return new RegExp(s,T).exec(h)}regexMatchAll(s,h,T){return Array.from(h.matchAll(new RegExp(s,T)))}regexReplace(s,h,T,R){return T.replace(new RegExp(s,R),h)}regexReplaceAll(s,h,T,R){return T.replace(new RegExp(s,R??"g"),h)}regexSplit(s,h,T){return h.split(new RegExp(s,T))}regexExec(s,h,T){return new RegExp(s,T).exec(h)}regexSearch(s,h,T){return h.search(new RegExp(s,T))}unique(s,h){if(!Array.isArray(s))return s;let T=new Set;return s.filter((R)=>{let I=h?R[h]:R;if(T.has(I))return!1;return T.add(I),!0})}groupBy(s,h){if(!Array.isArray(s))return s;let T={};return s.forEach((R)=>{let I=String(R[h]);if(!T[I])T[I]=[];T[I].push(R)}),T}chunk(s,h=1){if(!Array.isArray(s))return[];let T=[];for(let R=0;R<s.length;R+=h)T.push(s.slice(R,R+h));return T}flatten(s,h=1){if(!Array.isArray(s))return[s];let T=[],R=(I,ke)=>{for(let ie of I)if(Array.isArray(ie)&&ke>0)R(ie,ke-1);else T.push(ie)};return R(s,h),T}compact(s){if(!Array.isArray(s))return s;return s.filter((h)=>h!==null&&h!==void 0)}head(s,h){if(!Array.isArray(s))return s;return h?s.slice(0,h):s[0]}tail(s,h){if(!Array.isArray(s))return s;return h?s.slice(-h):s[s.length-1]}isEmail(s){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)}isUrl(s){try{return new URL(s),!0}catch{return!1}}isJson(s){try{return JSON.parse(s),!0}catch{return!1}}isUuid(s){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s)}minLength(s,h){return s?.length>=h}maxLength(s,h){return s?.length<=h}lengthEquals(s,h){return s?.length===h}isNumber(s){return typeof s==="number"&&!isNaN(s)}isString(s){return typeof s==="string"}isBoolean(s){return typeof s==="boolean"}isArray(s){return Array.isArray(s)}isObject(s){return s!==null&&typeof s==="object"&&!Array.isArray(s)}isEmpty(s){if(s===null||s===void 0)return!0;if(typeof s==="string"||Array.isArray(s))return s.length===0;if(typeof s==="object")return Object.keys(s).length===0;return!1}isTruthy(s){return!!s}isFalsy(s){return!s}inRange(s,h,T){return s>=h&&s<=T}matchesPattern(s,h){return new RegExp(h).test(s)}includes(s,h){if(typeof s==="string")return s.includes(String(h));return Array.isArray(s)&&s.includes(h)}startsWith(s,h){return s.startsWith(h)}endsWith(s,h){return s.endsWith(h)}},m(t,1,"env",o,r),m(t,1,"uuid",i,r),m(t,1,"pascal",l,r),m(t,1,"camel",a,r),m(t,1,"capital",c,r),m(t,1,"snake",w,r),m(t,1,"kebab",O,r),m(t,1,"len",y,r),m(t,1,"reverse",u,r),m(t,1,"concat",d,r),m(t,1,"trim",v,r),m(t,1,"ltrim",g,r),m(t,1,"rtrim",A,r),m(t,1,"lower",f,r),m(t,1,"upper",S,r),m(t,1,"encode",b,r),m(t,1,"decode",M,r),m(t,1,"list",k,r),m(t,1,"object",ve,r),m(t,1,"pathJoin",Y,r),m(t,1,"resolve",L,r),m(t,1,"dirname",Te,r),m(t,1,"basename",Ee,r),m(t,1,"normalize",Me,r),m(t,1,"extname",oe,r),m(t,1,"relative",Pe,r),m(t,1,"isAbsolute",Se,r),m(t,1,"segments",Ve,r),m(t,1,"log",Ct,r),m(t,1,"md5",Wt,r),m(t,1,"sha1",Nt,r),m(t,1,"sha256",Kt,r),m(t,1,"sha512",Ut,r),m(t,1,"hash",It,r),m(t,1,"hmac",Lt,r),m(t,1,"base64Encode",_t,r),m(t,1,"base64Decode",Bt,r),m(t,1,"hexEncode",Pt,r),m(t,1,"hexDecode",Vt,r),m(t,1,"add",Yt,r),m(t,1,"subtract",Gt,r),m(t,1,"multiply",Qt,r),m(t,1,"divide",Xt,r),m(t,1,"modulo",Zt,r),m(t,1,"power",Ht,r),m(t,1,"sqrt",qt,r),m(t,1,"abs",zt,r),m(t,1,"floor",Jt,r),m(t,1,"ceil",en,r),m(t,1,"round",rn,r),m(t,1,"min",tn,r),m(t,1,"max",nn,r),m(t,1,"clamp",on,r),m(t,1,"random",sn,r),m(t,1,"timestamp",an,r),m(t,1,"iso",ln,r),m(t,1,"utc",un,r),m(t,1,"formatDate",cn,r),m(t,1,"parseDate",fn,r),m(t,1,"year",pn,r),m(t,1,"month",mn,r),m(t,1,"day",gn,r),m(t,1,"dayOfWeek",yn,r),m(t,1,"hours",dn,r),m(t,1,"minutes",hn,r),m(t,1,"seconds",wn,r),m(t,1,"regexTest",bn,r),m(t,1,"regexMatch",On,r),m(t,1,"regexMatchAll",An,r),m(t,1,"regexReplace",vn,r),m(t,1,"regexReplaceAll",Tn,r),m(t,1,"regexSplit",En,r),m(t,1,"regexExec",Mn,r),m(t,1,"regexSearch",Sn,r),m(t,1,"unique",kn,r),m(t,1,"groupBy",xn,r),m(t,1,"chunk",Fn,r),m(t,1,"flatten",Dn,r),m(t,1,"compact",jn,r),m(t,1,"head",Rn,r),m(t,1,"tail",$n,r),m(t,1,"isEmail",Cn,r),m(t,1,"isUrl",Wn,r),m(t,1,"isJson",Nn,r),m(t,1,"isUuid",Kn,r),m(t,1,"minLength",Un,r),m(t,1,"maxLength",In,r),m(t,1,"lengthEquals",Ln,r),m(t,1,"isNumber",_n,r),m(t,1,"isString",Bn,r),m(t,1,"isBoolean",Pn,r),m(t,1,"isArray",Vn,r),m(t,1,"isObject",Yn,r),m(t,1,"isEmpty",Gn,r),m(t,1,"isTruthy",Qn,r),m(t,1,"isFalsy",Xn,r),m(t,1,"inRange",Zn,r),m(t,1,"matchesPattern",Hn,r),m(t,1,"includes",qn,r),m(t,1,"startsWith",zn,r),m(t,1,"endsWith",Jn,r),Xe(t,r),r)).keys({...Xr(e),...Zr(e),...tt(),...nt(),...at(),...ot(),...it(),...st(e),...ut(e),...ct(),...ft(),...pt()}).sources({...dt(e),...wt(e),...Et(),...bt(),...Ot(),...At(),...vt(),...Tt(e)}).sections(gt(e)).fieldOptions({configParser:Bun.YAML.parse,onSection:(s)=>{if(s.section.config.name)e.section(s.section)}}).decoders({yaml:{matching:["\\.yml$","\\.yaml$"],fn:Bun.YAML.parse}}).encoders({json:{fn:(s)=>JSON.stringify(s,null,2)},yaml:{fn:(s)=>Bun.YAML.stringify(s,null,2)},terraform:{options:{includeTags:!0},fn:(s,h)=>Ie(s,0,{sortKeys:!!(h?.sort?.length??h?.sortKeys?.length)})}})};var St={};C(St,{IncludeManager:()=>Le,DocumentIncludeProcessor:()=>_e});import pi from"fs/promises";import Ae from"path";class Le{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,r,t){let n=[];for(let o of e)if(H.isGlobPattern(o)){let i=(await Array.fromAsync(pi.glob(o,{cwd:r}))).map((l)=>Ae.join(r,l));for(let l of i)if(!t.included.includes(l))n.push(l)}else if(H.isDirectoryPattern(o)){let i=Ae.isAbsolute(o)?o:Ae.join(r,o);if(!this.includeDirectories.includes(i))this.includeDirectories.push(i)}else n.push(o);return n}buildSearchDirs(e){let r=e?[e]:[];return r.push(...this.includeDirectories.map((t)=>Ae.isAbsolute(t)?t:Ae.join(e??process.cwd(),t))),r}}class _e{includeManager;loadFn;constructor(e,r){this.includeManager=e;this.loadFn=r}async processIncludes(e,r,t){let n=[];if(e.content.includes)n.push(...e.content.includes),delete e.content.includes;n.push(...this.includeManager.getPendingAndClear());let o=await this.includeManager.processPatterns(n,e.folderPath,t);for(let i of o)U(await this.loadFn(i,e.folderPath,{parent:e.content,...r},!0,t),e.content)}}var F={};C(F,{writeOutputs:()=>me,writeOutput:()=>je,writeFormat:()=>De,variable:()=>pr,tokenize:()=>Or,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>Ar,sortBy:()=>ar,snake:()=>re,sharedFunction:()=>mr,select:()=>x,section:()=>cr,processFields:()=>$,pascal:()=>ee,padBlock:()=>_,nonNullMap:()=>ir,navigate:()=>Ce,mergeAll:()=>z,merge:()=>U,makeFieldProcessorMap:()=>B,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>ce,macro:()=>p,locate:()=>X,loadFormat:()=>fe,key:()=>fr,importList:()=>Re,importGlob:()=>tr,globMap:()=>pe,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>hr,exists:()=>q,encoder:()=>gr,defined:()=>sr,deepClone:()=>W,decoder:()=>yr,conditionPredicates:()=>K,changeCase:()=>te,capital:()=>he,camel:()=>we,asyncMap:()=>lr,ObjectorPlugin:()=>P,NavigateResult:()=>E,NavigateAction:()=>$e,Logger:()=>Be,AsyncFunction:()=>Er});D(F,so(Dt(),1));var jt={};C(jt,{Logger:()=>Be});class Be{options;constructor(e){this.options={level:"INFO",showClass:!1,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},logFunction:(r,...t)=>{switch(r){case"ERROR":console.error(...t);break;case"WARN":console.warn(...t);break;case"DEBUG":console.debug(...t);break;case"VERBOSE":console.log(...t);break;default:console.log(...t)}},...e}}write(e,...r){if(this.options.level){let o=this.options.levels.indexOf(this.options.level)??-1,i=this.options.levels.indexOf(e);if(i===-1)throw Error(`Unknown log level: ${e}`);if(i<o)return}let t=[],n=[];if(this.options.timeStamp)n.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)n.push(e);if(n.length>0)t.push(`[${n.join(" ")}]`);t.push(...r),this.options.logFunction(e,...t)}info(...e){this.write("INFO",...e)}error(...e){this.write("ERROR",...e)}warn(...e){this.write("WARN",...e)}debug(...e){this.write("DEBUG",...e)}verbose(...e){this.write("VERBOSE",...e)}}var Rt={};C(Rt,{AsyncFunction:()=>Er});Array.prototype.mapAsync=async function(e){let r=[];for(let t=0;t<this.length;t++)r.push(await e(this[t],t,this));return r};Array.prototype.nonNullMap=function(e){let r=[];for(let t=0;t<this.length;t++){let n=e(this[t],t,this);if(n!=null)r.push(n)}return r};Array.prototype.nonNullMapAsync=async function(e){let r=[];for(let t=0;t<this.length;t++){let n=await e(this[t],t,this);if(n!=null)r.push(n)}return r};Array.prototype.sortBy=function(e,r=!0){return this.slice().sort((t,n)=>{let o=e(t),i=e(n);if(o<i)return r?-1:1;if(o>i)return r?1:-1;return 0})};Array.prototype.forEachAsync=async function(e){for(let r=0;r<this.length;r++)await e(this[r],r,this)};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(e){let r=new Set;return this.filter((t)=>{let n=e(t);if(r.has(n))return!1;else return r.add(n),!0})};Array.prototype.groupBy=function(e){return this.reduce((r,t)=>{let n=e(t);if(!r[n])r[n]=[];return r[n].push(t),r},{})};Array.prototype.toObject=function(e,r){return Object.fromEntries(this.map((t)=>{let n=e(t),o=r?r(t):t;return[n,o]}))};Array.prototype.toObjectWithKey=function(e){return Object.fromEntries(this.map((r)=>[String(r[e]),r]))};Array.prototype.findOrFail=function(e,r,t){let n=this.find(e,t);if(n===void 0)throw Error(r??"Element not found");return n};Array.prototype.selectFor=function(e,r,t,n){let o=this.find(e,n);if(o===void 0)throw Error(t??"Element not found");return r(o)};Array.flat=function(e){if(Array.isArray(e))return e.flat(2);else return[e]};Array.prototype.createInstances=function(e,...r){return this.map((t,n)=>new e(...r,t,n))};Object.mapEntries=function(e,r){let n=Object.entries(e).map(([o,i])=>r(o,i));return Object.fromEntries(n)};Object.toList=function(e,r){return Object.entries(e).map(([t,n])=>({[r]:t,...n}))};Object.deepClone=function(e){if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};Object.find=function(e,r){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(n!==void 0&&r(n,t))return[t,n]}return};Object.findAll=function(e,r){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let o=e[n];if(o!==void 0&&r(o,n))t.push([n,o])}return t};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;var Er=global.AsyncFunction;D(N,F);class $t{includeManager=new Le;includeProcessor;cacheManager=new We(100);outputs=[];vars={};funcs={};fields={sources:{},keys:{},sections:{}};objectMetadata={};currentContext=null;storedSections={};dataEncoders={};dataDecoders={};constructor(){this.includeProcessor=new _e(this.includeManager,this.load.bind(this)),this.use(vr)}use(e){if(e.prototype instanceof P)new e(this);else e(this);return this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}sections(e){return Object.assign(this.fields.sections,{...this.fields.sections,...e}),this}variables(e){return this.vars={...this.vars,...e},this}functions(e){return this.funcs={...this.funcs,...e},this}getFunctions(){return this.funcs}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,r){return this.objectMetadata[e]=r,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.storedSections[e.config.name]=e,this}getSection(e){return this.storedSections[e]}encoders(e){return this.dataEncoders={...this.dataEncoders,...e},this}decoders(e){return this.dataDecoders={...this.dataDecoders,...e},this}getEncoder(e){return this.dataEncoders[e]}getDecoder(e){return this.dataDecoders[e]}filter(e){return this.fields.filters??=[],this.fields.filters.push(e),this}async loadObject(e,r,t){return $(e,{...this.fields,globalContext:{file:t?.fullPath??"@internal"},root:{...r,...this.fields.root,...this.vars,functions:this.funcs,context:this.currentContext,sections:this.storedSections,$document:{root:{content:e},fileName:t?.fileName??"@internal",folder:t?.folderPath??"@internal",fullPath:t?.fullPath??"@internal"}}})}async load(e,r,t,n,o){let i=this.includeManager.snapshot();try{this.includeManager.reset();let l=this.includeManager.buildSearchDirs(r);if(o)this.currentContext=o;this.currentContext??={included:[],document:null};let a=await fe(e,{dirs:l,parsers:this.dataDecoders,format:"yaml"}),c=H.normalize(a.fullPath);if(this.currentContext.included.push(c),!a.content)return null;let w=this.cacheManager.get(c),O;if(w)O=w.raw;else O=a.content,this.cacheManager.set(c,{raw:O,timestamp:Date.now()});let y=W(O);a.content=y,await this.includeProcessor.processIncludes(a,t,this.currentContext);let u;if(n!==!0)u=await this.loadObject(a.content,t,{fileName:a.fullPath,folderPath:a.folderPath,fullPath:a.fullPath});else u=a.content;return this.currentContext.document=u,u}catch(l){throw this.includeManager.restore(i),l}finally{this.includeManager.restore(i)}}async writeAll(e){await me(this.getOutputs(),e)}}export{me as writeOutputs,je as writeOutput,De as writeFormat,pr as variable,Or as tokenize,or as toObjectWithKey,ge as toObject,Z as toList,Ar as stripIndent,ar as sortBy,re as snake,mr as sharedFunction,x as select,cr as section,$ as processFields,ee as pascal,_ as padBlock,ir as nonNullMap,Ce as navigate,z as mergeAll,U as merge,B as makeFieldProcessorMap,qe as makeFieldProcessorList,ce as makeFieldProcessor,p as macro,X as locate,fe as loadFormat,fr as key,Re as importList,tr as importGlob,pe as globMap,ue as getProcessor,Fe as getArgs,hr as find,q as exists,gr as encoder,sr as defined,W as deepClone,yr as decoder,K as conditionPredicates,te as changeCase,he as capital,we as camel,lr as asyncMap,P as ObjectorPlugin,$t as Objector,E as NavigateResult,$e as NavigateAction,Be as Logger,Er as AsyncFunction};
|
|
21
|
+
${n}}`}else return String(e)},V=(e)=>{if(!e)return e;return e.replaceAll("\\n",`
|
|
22
|
+
`).replaceAll("\\$","$").replaceAll("\\t","\t")};var ft=()=>({...J({merge:(...e)=>e.flatMap((t)=>t)}),join:({args:[e],root:t,tags:r})=>{let n=r.key?.[0],o=r.separator?.[0]??r.sep?.[0],s=r.finalize?.length>0,l=V(o);if(typeof e==="string"){if(s&&e.length&&l)return e+l;return e}if(!Array.isArray(e))throw Error("Object is not a list");let a=((n?.length)?e.map((g)=>Object.select({...t,...g},n)):e).join(l),u=r.pad?.[0]??"0",m=r.padChar?.[0]??" ",y=s&&a.length&&l?a+l:a;return u?y.padBlock(parseInt(u),`
|
|
23
|
+
`,m):y},range:({args:[e,t,r]})=>{let n=parseInt(e),o=parseInt(t),s=parseInt(r)||1;if(isNaN(n))throw Error("Invalid range: start value '"+String(e)+"' is not a number");if(isNaN(o))throw Error("Invalid range: end value '"+String(t)+"' is not a number");if(s===0)throw Error("Invalid range: step cannot be zero");if((o-n)/s<0)throw Error("Invalid range: step "+String(s)+" has wrong direction for range "+String(n)+" to "+String(o));return Array.from({length:Math.floor((o-n)/s)+1},(l,a)=>n+a*s)},filter:{types:(e,t,r)=>{switch(e){case 0:return"array";case 1:return Object.keys(D)}return ae[r[1].value]?.(e-2,t,r.slice(2))},fn:({args:[e,t,r],root:n,tags:o})=>{if(e===null||e===void 0)throw Error("Filter source cannot be null or undefined");if(!Array.isArray(e))throw Error("Filter source must be an array");let s=o.key?.[0],l=D[t];if(s){let u=Array(e.length);for(let y=0;y<e.length;y++)try{u[y]=Object.select({...n,...e[y]},s)}catch{u[y]=Symbol("invalid")}let m=[];for(let y=0;y<e.length;y++){let g=u[y];if(typeof g!=="symbol"&&r===void 0?l(g):l(g,r))m.push(e[y])}return m}let a=[];for(let u of e)if(r===void 0?l(u):l(u,r))a.push(u);return a}}});var pt=()=>({each:{processArgs:!1,fn:async({rawArgs:[e,t,...r],root:n,options:o,tags:s})=>{let l=async(w)=>w.quoted?V(w.value):await Object.select(n,w.value),a=await Object.select(n,e.value),u=await l(t),m=s.key?.[0],y=Array.isArray(a)?a:Object.toList(a,"name"),g=[],O=await Promise.all(r.map(async(w)=>await l(w))),b={...n,item:void 0,index:0,params:O,instance:void 0,parent:n.this,tags:s},k={...o,root:b};for(let w=0;w<y.length;w++){let A=Object.deepClone(u),M={instance:A},v=typeof u==="string"?M:A;if(b.item=y[w],b.index=w,b.instance=A,s?.root?.[0])Object.assign(b,await Object.select(b,s.root[0]));if(await $(v,k),m!==void 0)g.push(await Object.select(M.instance,m));else g.push(M.instance)}if(s.join?.length){if(g.length===0)return"";let w=V(s.join[0]),A=s.pad?.[0]??"0",M=s.padChar?.[0]??" ",v=s.finalize?.length&&w?w:"",P=`${g.join(w)}${v}`;return A?P.padBlock(parseInt(A),`
|
|
24
|
+
`,M):P}return g}}});var z=async(e,t,r)=>e.rawArgs[t].quoted?e.rawArgs[t].value:await Object.select(e.root,e.rawArgs[t].value,{defaultValue:r}),gt=()=>({switch:{processArgs:!1,fn:async(e)=>{let t=await z(e,0,!1),r=await z(e,1);if(r[t]===void 0){if(e.rawArgs.length>2)return z(e,2);throw Error(`Unhandled switch case: ${t}`)}return r[t]}}});var mt=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(D)},fn:(e)=>D[e.args[0]](...e.args.slice(1))},...J(D,{types:ae})});var yt=(e)=>({default:{processArgs:!1,fn:async(t)=>{for(let r=0;r<t.rawArgs.length;r++)if(t.rawArgs[r]?.value!==void 0){let o=await z(t,r,null);if(o!==null)return o}if(t.tags.nullable?.length)return d.DeleteItem();if(t.tags.fail?.length)throw Error(`No valid value found for default (${t.rawArgs.map((r)=>r.value).join(", ")})`);return""}},section:{types:["string","boolean"],fn:(t)=>{let r=t.args[0];if(!(t.args[1]??!0))return null;let o=e.getSection(r);if(!o)throw Error(`Section not found: ${r}`);return o.content}}});var ht=()=>({convert:({args:[e,t,r]})=>{switch(t){case"string":return String(e);case"number":{let n=Number(e);if(!isNaN(n))return d.ReplaceItem(n);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return d.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return d.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${t}`)}if(r!==void 0)return d.ReplaceItem(r);throw Error(`Failed to convert value to ${t}`)},isType:({args:[e,t]})=>{let n=(()=>{switch(t){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${t}`)}})();return d.ReplaceItem(n)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var dt=(e)=>{var t,r,n,o,s,l,a,u,m,y,g,O,b,k,w,A,M,v,P,E,F,G,x,C,Q,Z,X,W,ue,ee,ce,bt,wt,Ot,At,jt,St,vt,Et,kt,Ft,Pt,$t,Mt,Rt,Ct,Dt,Nt,xt,It,_t,Ut,Lt,Wt,Bt,qt,Kt,Jt,Yt,Tt,Vt,zt,Ht,Gt,Qt,Zt,Xt,er,tr,rr,nr,or,ir,sr,ar,lr,ur,cr,fr,pr,gr,mr,yr,hr,dr,br,wr,Or,Ar,jr,Sr,vr,Er,kr,Fr,Pr,$r,Mr,Rr,Cr,Dr,Nr,xr,Ir,o,s,l,a,u,m,y,g,O,b,k,w,A,M,v,P,E,F,G,x,C,Q,Z,X,W,ue,ee,ce,bt,wt,Ot,At,jt,St,vt,Et,kt,Ft,Pt,$t,Mt,Rt,Ct,Dt,Nt,xt,It,_t,Ut,Lt,Wt,Bt,qt,Kt,Jt,Yt,Tt,Vt,zt,Ht,Gt,Qt,Zt,Xt,er,tr,rr,nr,or,ir,sr,ar,lr,ur,cr,fr,pr,gr,mr,yr,hr,dr,br,wr,Or,Ar,jr,Sr,vr,Er,kr,Fr,Pr,$r,Mr,Rr,Cr,Dr,Nr,xr,Ir;return e.use((n=Y,o=[f()],s=[f()],l=[f()],a=[f()],u=[f()],m=[f()],y=[f()],g=[f()],O=[f()],b=[f()],k=[f()],w=[f()],A=[f()],M=[f()],v=[f()],P=[f()],E=[f()],F=[f()],G=[f()],x=[f()],C=[f()],Q=[f()],Z=[f()],X=[f()],W=[f()],ue=[f()],ee=[f()],ce=[f()],bt=[f()],wt=[f()],Ot=[f()],At=[f()],jt=[f()],St=[f()],vt=[f()],Et=[f()],kt=[f()],Ft=[f()],Pt=[f()],$t=[f()],Mt=[f()],Rt=[f()],Ct=[f()],Dt=[f()],Nt=[f()],xt=[f()],It=[f()],_t=[f()],Ut=[f()],Lt=[f()],Wt=[f()],Bt=[f()],qt=[f()],Kt=[f()],Jt=[f()],Yt=[f()],Tt=[f()],Vt=[f()],zt=[f()],Ht=[f()],Gt=[f()],Qt=[f()],Zt=[f()],Xt=[f()],er=[f()],tr=[f()],rr=[f()],nr=[f()],or=[f()],ir=[f()],sr=[f()],ar=[f()],lr=[f()],ur=[f()],cr=[f()],fr=[f()],pr=[f()],gr=[f()],mr=[f()],yr=[f()],hr=[f()],dr=[f()],br=[f()],wr=[f()],Or=[f()],Ar=[f()],jr=[f()],Sr=[f()],vr=[f()],Er=[f()],kr=[f()],Fr=[f()],Pr=[f()],$r=[f()],Mr=[f()],Rr=[f()],Cr=[f()],Dr=[f()],Nr=[f()],xr=[f()],Ir=[f()],r=$e(n),t=class extends n{constructor(){super(...arguments);Re(r,5,this)}env(i){return process.env[i]}uuid(){return crypto.randomUUID()}pascal(i){return i.toPascal()}camel(i){return i.toCamel()}capital(i){return i.capitalize()}snake(i,p="lower"){return i.changeCase(p).toSnake()}kebab(i,p="lower"){return i.changeCase(p).toKebab()}len(i){return i.length}reverse(i){return i.split("").reverse().join("")}concat(...i){return i.join("")}trim(i){return i.trim()}ltrim(i){return i.trimStart()}rtrim(i){return i.trimEnd()}lower(i){return i.toLowerCase()}upper(i){return i.toUpperCase()}encode(i,p){return Buffer.from(i).toString(p??"base64")}decode(i,p){return Buffer.from(i,p??"base64").toString()}list(i,p="name"){return Object.toList(i,p)}object(i,p="name"){return i.toObject((h)=>h[p],(h)=>{let{[p]:S,...R}=h;return R})}pathJoin(...i){return N.join(...i)}resolve(...i){return N.resolve(...i)}dirname(i){return N.dirname(i)}basename(i,p){return N.basename(i,p)}normalize(i){return N.normalize(i)}extname(i){return N.extname(i)}relative(i,p){return N.relative(i,p)}isAbsolute(i){return N.isAbsolute(i)}segments(i){return i.split("/").filter(Boolean)}log(...i){console.log(...i)}md5(i){return L("md5").update(i).digest("hex")}sha1(i){return L("sha1").update(i).digest("hex")}sha256(i){return L("sha256").update(i).digest("hex")}sha512(i){return L("sha512").update(i).digest("hex")}hash(i,p="sha256"){return L(p).update(i).digest("hex")}hmac(i,p,h="sha256"){return L(h).update(i).digest("hex")}base64Encode(i){return Buffer.from(i).toString("base64")}base64Decode(i){return Buffer.from(i,"base64").toString("utf-8")}hexEncode(i){return Buffer.from(i).toString("hex")}hexDecode(i){return Buffer.from(i,"hex").toString("utf-8")}add(...i){return i.reduce((p,h)=>p+h,0)}subtract(i,p){return i-p}multiply(...i){return i.reduce((p,h)=>p*h,1)}divide(i,p){if(p===0)throw Error("Division by zero");return i/p}modulo(i,p){return i%p}power(i,p){return Math.pow(i,p)}sqrt(i){return Math.sqrt(i)}abs(i){return Math.abs(i)}floor(i){return Math.floor(i)}ceil(i){return Math.ceil(i)}round(i,p){let h=Math.pow(10,p??0);return Math.round(i*h)/h}min(...i){return Math.min(...i)}max(...i){return Math.max(...i)}clamp(i,p,h){return Math.max(p,Math.min(h,i))}random(i,p){let h=i??0,S=p??1;return Math.random()*(S-h)+h}timestamp(i){return new Date(i).getTime()}iso(i){return new Date(i).toISOString()}utc(i){return new Date(i).toUTCString()}formatDate(i,p){let h=new Date(i),S=h.getFullYear(),R=String(h.getMonth()+1).padStart(2,"0"),te=String(h.getDate()).padStart(2,"0"),B=String(h.getHours()).padStart(2,"0"),_r=String(h.getMinutes()).padStart(2,"0"),Ur=String(h.getSeconds()).padStart(2,"0");return p.replace("YYYY",String(S)).replace("MM",R).replace("DD",te).replace("HH",B).replace("mm",_r).replace("ss",Ur)}parseDate(i){return new Date(i).getTime()}year(i){return new Date(i).getFullYear()}month(i){return new Date(i).getMonth()+1}day(i){return new Date(i).getDate()}dayOfWeek(i){return new Date(i).getDay()}hours(i){return new Date(i).getHours()}minutes(i){return new Date(i).getMinutes()}seconds(i){return new Date(i).getSeconds()}regexTest(i,p,h){return new RegExp(i,h).test(p)}regexMatch(i,p,h){return new RegExp(i,h).exec(p)}regexMatchAll(i,p,h){return Array.from(p.matchAll(new RegExp(i,h)))}regexReplace(i,p,h,S){return h.replace(new RegExp(i,S),p)}regexReplaceAll(i,p,h,S){return h.replace(new RegExp(i,S??"g"),p)}regexSplit(i,p,h){return p.split(new RegExp(i,h))}regexExec(i,p,h){return new RegExp(i,h).exec(p)}regexSearch(i,p,h){return p.search(new RegExp(i,h))}unique(i,p){if(!Array.isArray(i))return i;let h=new Set;return i.filter((S)=>{let R=p?S[p]:S;if(h.has(R))return!1;return h.add(R),!0})}groupBy(i,p){if(!Array.isArray(i))return i;let h={};return i.forEach((S)=>{let R=String(S[p]);if(!h[R])h[R]=[];h[R].push(S)}),h}chunk(i,p=1){if(!Array.isArray(i))return[];let h=[];for(let S=0;S<i.length;S+=p)h.push(i.slice(S,S+p));return h}flatten(i,p=1){if(!Array.isArray(i))return[i];let h=[],S=(R,te)=>{for(let B of R)if(Array.isArray(B)&&te>0)S(B,te-1);else h.push(B)};return S(i,p),h}compact(i){if(!Array.isArray(i))return i;return i.filter((p)=>p!==null&&p!==void 0)}head(i,p){if(!Array.isArray(i))return i;return p?i.slice(0,p):i[0]}tail(i,p){if(!Array.isArray(i))return i;return p?i.slice(-p):i[i.length-1]}isEmail(i){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i)}isUrl(i){try{return new URL(i),!0}catch{return!1}}isJson(i){try{return JSON.parse(i),!0}catch{return!1}}isUuid(i){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i)}minLength(i,p){return i?.length>=p}maxLength(i,p){return i?.length<=p}lengthEquals(i,p){return i?.length===p}isNumber(i){return typeof i==="number"&&!isNaN(i)}isString(i){return typeof i==="string"}isBoolean(i){return typeof i==="boolean"}isArray(i){return Array.isArray(i)}isObject(i){return i!==null&&typeof i==="object"&&!Array.isArray(i)}isEmpty(i){if(i===null||i===void 0)return!0;if(typeof i==="string"||Array.isArray(i))return i.length===0;if(typeof i==="object")return Object.keys(i).length===0;return!1}isTruthy(i){return!!i}isFalsy(i){return!i}inRange(i,p,h){return i>=p&&i<=h}matchesPattern(i,p){return new RegExp(p).test(i)}includes(i,p){if(typeof i==="string")return i.includes(String(p));return Array.isArray(i)&&i.includes(p)}startsWith(i,p){return i.startsWith(p)}endsWith(i,p){return i.endsWith(p)}},c(r,1,"env",o,t),c(r,1,"uuid",s,t),c(r,1,"pascal",l,t),c(r,1,"camel",a,t),c(r,1,"capital",u,t),c(r,1,"snake",m,t),c(r,1,"kebab",y,t),c(r,1,"len",g,t),c(r,1,"reverse",O,t),c(r,1,"concat",b,t),c(r,1,"trim",k,t),c(r,1,"ltrim",w,t),c(r,1,"rtrim",A,t),c(r,1,"lower",M,t),c(r,1,"upper",v,t),c(r,1,"encode",P,t),c(r,1,"decode",E,t),c(r,1,"list",F,t),c(r,1,"object",G,t),c(r,1,"pathJoin",x,t),c(r,1,"resolve",C,t),c(r,1,"dirname",Q,t),c(r,1,"basename",Z,t),c(r,1,"normalize",X,t),c(r,1,"extname",W,t),c(r,1,"relative",ue,t),c(r,1,"isAbsolute",ee,t),c(r,1,"segments",ce,t),c(r,1,"log",bt,t),c(r,1,"md5",wt,t),c(r,1,"sha1",Ot,t),c(r,1,"sha256",At,t),c(r,1,"sha512",jt,t),c(r,1,"hash",St,t),c(r,1,"hmac",vt,t),c(r,1,"base64Encode",Et,t),c(r,1,"base64Decode",kt,t),c(r,1,"hexEncode",Ft,t),c(r,1,"hexDecode",Pt,t),c(r,1,"add",$t,t),c(r,1,"subtract",Mt,t),c(r,1,"multiply",Rt,t),c(r,1,"divide",Ct,t),c(r,1,"modulo",Dt,t),c(r,1,"power",Nt,t),c(r,1,"sqrt",xt,t),c(r,1,"abs",It,t),c(r,1,"floor",_t,t),c(r,1,"ceil",Ut,t),c(r,1,"round",Lt,t),c(r,1,"min",Wt,t),c(r,1,"max",Bt,t),c(r,1,"clamp",qt,t),c(r,1,"random",Kt,t),c(r,1,"timestamp",Jt,t),c(r,1,"iso",Yt,t),c(r,1,"utc",Tt,t),c(r,1,"formatDate",Vt,t),c(r,1,"parseDate",zt,t),c(r,1,"year",Ht,t),c(r,1,"month",Gt,t),c(r,1,"day",Qt,t),c(r,1,"dayOfWeek",Zt,t),c(r,1,"hours",Xt,t),c(r,1,"minutes",er,t),c(r,1,"seconds",tr,t),c(r,1,"regexTest",rr,t),c(r,1,"regexMatch",nr,t),c(r,1,"regexMatchAll",or,t),c(r,1,"regexReplace",ir,t),c(r,1,"regexReplaceAll",sr,t),c(r,1,"regexSplit",ar,t),c(r,1,"regexExec",lr,t),c(r,1,"regexSearch",ur,t),c(r,1,"unique",cr,t),c(r,1,"groupBy",fr,t),c(r,1,"chunk",pr,t),c(r,1,"flatten",gr,t),c(r,1,"compact",mr,t),c(r,1,"head",yr,t),c(r,1,"tail",hr,t),c(r,1,"isEmail",dr,t),c(r,1,"isUrl",br,t),c(r,1,"isJson",wr,t),c(r,1,"isUuid",Or,t),c(r,1,"minLength",Ar,t),c(r,1,"maxLength",jr,t),c(r,1,"lengthEquals",Sr,t),c(r,1,"isNumber",vr,t),c(r,1,"isString",Er,t),c(r,1,"isBoolean",kr,t),c(r,1,"isArray",Fr,t),c(r,1,"isObject",Pr,t),c(r,1,"isEmpty",$r,t),c(r,1,"isTruthy",Mr,t),c(r,1,"isFalsy",Rr,t),c(r,1,"inRange",Cr,t),c(r,1,"matchesPattern",Dr,t),c(r,1,"includes",Nr,t),c(r,1,"startsWith",xr,t),c(r,1,"endsWith",Ir,t),pe(r,t),t)).keys({...Ve(e),...ze(e),...He(),...Ge(),...et(),...Qe(),...Ze(),...Xe(e),...rt(e),...nt(),...ot(),...it()}).sources({...ut(e),...ct(e),...ht(),...ft(),...pt(),...gt(),...mt(),...yt(e)}).sections(at(e)).fieldOptions({configParser:Bun.YAML.parse,onSection:(i)=>{if(i.section.config.name)e.section(i.section)}}).decoders({yaml:{matching:["\\.yml$","\\.yaml$"],fn:Bun.YAML.parse}}).encoders({json:{fn:(i)=>JSON.stringify(i,null,2)},yaml:{fn:(i)=>Bun.YAML.stringify(i,null,2)},terraform:{options:{includeTags:!0},fn:(i,p)=>le(i,0,{sortKeys:!!(p?.sort?.length??p?.sortKeys?.length)})}})};import vn from"fs/promises";import H from"path";class je{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,t,r){let n=[];for(let o of e)if(U.isGlobPattern(o)){let s=(await Array.fromAsync(vn.glob(o,{cwd:t}))).map((l)=>H.join(t,l));for(let l of s)if(!r.included.includes(l))n.push(l)}else if(U.isDirectoryPattern(o)){let s=H.isAbsolute(o)?o:H.join(t,o);if(!this.includeDirectories.includes(s))this.includeDirectories.push(s)}else n.push(o);return n}buildSearchDirs(e){let t=e?[e]:[];return t.push(...this.includeDirectories.map((r)=>H.isAbsolute(r)?r:H.join(e??process.cwd(),r))),t}}class Se{includeManager;loadFn;constructor(e,t){this.includeManager=e;this.loadFn=t}async processIncludes(e,t,r){let n=[];if(e.content.includes)n.push(...e.content.includes),delete e.content.includes;n.push(...this.includeManager.getPendingAndClear());let o=await this.includeManager.processPatterns(n,e.folderPath,r);for(let s of o)Object.merge(await this.loadFn(s,e.folderPath,{parent:e.content,...t},!0,r),e.content)}}class En{includeManager=new je;includeProcessor;cacheManager=new we(100);outputs=[];vars={};funcs={};fields={sources:{},keys:{},sections:{}};objectMetadata={};currentContext=null;storedSections={};dataEncoders={};dataDecoders={};constructor(){this.includeProcessor=new Se(this.includeManager,this.load.bind(this)),this.use(dt)}use(e){if(e.prototype instanceof Y)new e(this);else e(this);return this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}sections(e){return Object.assign(this.fields.sections,{...this.fields.sections,...e}),this}variables(e){return this.vars={...this.vars,...e},this}functions(e){return this.funcs={...this.funcs,...e},this}getFunctions(){return this.funcs}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,t){return this.objectMetadata[e]=t,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.storedSections[e.config.name]=e,this}getSection(e){return this.storedSections[e]}encoders(e){return this.dataEncoders={...this.dataEncoders,...e},this}decoders(e){return this.dataDecoders={...this.dataDecoders,...e},this}getEncoder(e){return this.dataEncoders[e]}getDecoder(e){return this.dataDecoders[e]}filter(e){return this.fields.filters??=[],this.fields.filters.push(e),this}async loadObject(e,t,r){return $(e,{...this.fields,globalContext:{file:r?.fullPath??"@internal"},root:{...t,...this.fields.root,...this.vars,functions:this.funcs,context:this.currentContext,sections:this.storedSections,$document:{root:{content:e},fileName:r?.fileName??"@internal",folder:r?.folderPath??"@internal",fullPath:r?.fullPath??"@internal"}}})}async load(e,t,r,n,o){let s=this.includeManager.snapshot();try{this.includeManager.reset();let l=this.includeManager.buildSearchDirs(t);if(o)this.currentContext=o;this.currentContext??={included:[],document:null};let a=await Ke(e,{dirs:l,parsers:this.dataDecoders,format:"yaml"}),u=U.normalize(a.fullPath);if(this.currentContext.included.push(u),!a.content)return null;let m=this.cacheManager.get(u),y;if(m)y=m.raw;else y=a.content,this.cacheManager.set(u,{raw:y,timestamp:Date.now()});let g=Object.deepClone(y);a.content=g,await this.includeProcessor.processIncludes(a,r,this.currentContext);let O;if(n!==!0)O=await this.loadObject(a.content,r,{fileName:a.fullPath,folderPath:a.folderPath,fullPath:a.fullPath});else O=a.content;return this.currentContext.document=O,O}catch(l){throw this.includeManager.restore(s),l}finally{this.includeManager.restore(s)}}async writeAll(e){await Te(this.getOutputs(),e)}}export{Te as writeOutputs,pn as writeOutput,cn as writeFormat,Jn as variable,Yn as sharedFunction,qn as section,$ as processFields,J as makeFieldProcessorMap,Fn as makeFieldProcessorList,Le as makeFieldProcessor,f as macro,ne as locate,Ke as loadFormat,Kn as key,mn as importList,Wn as importGlob,Je as globMap,Ne as getProcessor,Hr as getArgs,be as exists,Tn as encoder,Po as defined,Vn as decoder,D as conditionPredicates,Y as ObjectorPlugin,En as Objector,d as NavigateResult,hn as NavigateAction,On as Logger};
|