@rzl-zone/build-tools 0.0.5

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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/dist/.references/index.d.cts +18 -0
  3. package/dist/.references/index.d.ts +18 -0
  4. package/dist/bundler/rolldown.cjs +32 -0
  5. package/dist/bundler/rolldown.cjs.map +1 -0
  6. package/dist/bundler/rolldown.d.cts +162 -0
  7. package/dist/bundler/rolldown.d.ts +162 -0
  8. package/dist/bundler/rolldown.js +25 -0
  9. package/dist/bundler/rolldown.js.map +1 -0
  10. package/dist/bundler/tsdown.cjs +132 -0
  11. package/dist/bundler/tsdown.cjs.map +1 -0
  12. package/dist/bundler/tsdown.d.cts +1165 -0
  13. package/dist/bundler/tsdown.d.ts +1165 -0
  14. package/dist/bundler/tsdown.js +124 -0
  15. package/dist/bundler/tsdown.js.map +1 -0
  16. package/dist/bundler/utils.cjs +24 -0
  17. package/dist/bundler/utils.cjs.map +1 -0
  18. package/dist/bundler/utils.d.cts +40 -0
  19. package/dist/bundler/utils.d.ts +40 -0
  20. package/dist/bundler/utils.js +21 -0
  21. package/dist/bundler/utils.js.map +1 -0
  22. package/dist/client-XhkdKJ4d.js +160 -0
  23. package/dist/client-XhkdKJ4d.js.map +1 -0
  24. package/dist/client-u8yLSxEI.cjs +221 -0
  25. package/dist/client-u8yLSxEI.cjs.map +1 -0
  26. package/dist/commander-kit/index.cjs +569 -0
  27. package/dist/commander-kit/index.cjs.map +1 -0
  28. package/dist/commander-kit/index.d.cts +1383 -0
  29. package/dist/commander-kit/index.d.ts +1383 -0
  30. package/dist/commander-kit/index.js +550 -0
  31. package/dist/commander-kit/index.js.map +1 -0
  32. package/dist/extra-CVuXMpEw.d.ts +994 -0
  33. package/dist/extra-CxDwtQEy.d.cts +994 -0
  34. package/dist/fast-globe-options-6r2aj6UC.d.ts +126 -0
  35. package/dist/fast-globe-options-BFt__e__.d.cts +126 -0
  36. package/dist/helper-BdjaR8Yv.js +215 -0
  37. package/dist/helper-BdjaR8Yv.js.map +1 -0
  38. package/dist/helper-DorgNsB9.cjs +377 -0
  39. package/dist/helper-DorgNsB9.cjs.map +1 -0
  40. package/dist/identity-BJ0QX7AJ.js +88 -0
  41. package/dist/identity-BJ0QX7AJ.js.map +1 -0
  42. package/dist/identity-CxR9DRMh.cjs +100 -0
  43. package/dist/identity-CxR9DRMh.cjs.map +1 -0
  44. package/dist/index-B-NeF7PU.d.cts +670 -0
  45. package/dist/index-CzxZta4Z.d.ts +356 -0
  46. package/dist/index-Idak1iwg.d.cts +356 -0
  47. package/dist/index-PXsb85LI.d.ts +670 -0
  48. package/dist/index.cjs +1689 -0
  49. package/dist/index.cjs.map +1 -0
  50. package/dist/index.d.cts +2193 -0
  51. package/dist/index.d.ts +2193 -0
  52. package/dist/index.js +1641 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/package-banner-6RzEf-mV.cjs +54 -0
  55. package/dist/package-banner-6RzEf-mV.cjs.map +1 -0
  56. package/dist/package-banner-BzheZbxy.js +41 -0
  57. package/dist/package-banner-BzheZbxy.js.map +1 -0
  58. package/dist/server-B2hBoGDR.cjs +181 -0
  59. package/dist/server-B2hBoGDR.cjs.map +1 -0
  60. package/dist/server-CWrDd29Y.js +142 -0
  61. package/dist/server-CWrDd29Y.js.map +1 -0
  62. package/dist/utils/client.cjs +23 -0
  63. package/dist/utils/client.d.cts +887 -0
  64. package/dist/utils/client.d.ts +887 -0
  65. package/dist/utils/client.js +12 -0
  66. package/dist/utils/server.cjs +17 -0
  67. package/dist/utils/server.d.cts +124 -0
  68. package/dist/utils/server.d.ts +124 -0
  69. package/dist/utils/server.js +12 -0
  70. package/package.json +151 -0
@@ -0,0 +1,126 @@
1
+ /*!
2
+ * ========================================================================
3
+ * @rzl-zone/build-tools
4
+ * ------------------------------------------------------------------------
5
+ * Version: `0.0.5`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
8
+ * ========================================================================
9
+ */
10
+
11
+ import { a as OmitStrict, s as Prettify } from "./extra-CVuXMpEw.js";
12
+ import * as fg from "fast-glob";
13
+
14
+ type IfTrueGeneric<T extends boolean, K> = T extends true ? K : never;
15
+ /** ----------------------------------------------------------------
16
+ * * ***Supported pattern matching options.***
17
+ * ----------------------------------------------------------------
18
+ * Defines the subset of {@link fg | `fast-glob`} options exposed by
19
+ * this module for pattern-based file resolution.
20
+ *
21
+ * This type intentionally omits several low-level or environment-
22
+ * controlled fields to ensure predictable and safe behavior.
23
+ *
24
+ * ----------------------------------------------------------------
25
+ *
26
+ * *Excluded options (managed internally):*
27
+ *
28
+ * - `fs`
29
+ * - `cwd`
30
+ * - `stats`
31
+ * - `deep`
32
+ * - `extglob`
33
+ * - `suppressErrors`
34
+ * - `braceExpansion`
35
+ *
36
+ * These fields are controlled by the runtime environment and should
37
+ * not be overridden by consumers.
38
+ *
39
+ * ----------------------------------------------------------------
40
+ * @template FilesOnly
41
+ * When `true`, directory filtering options (`onlyFiles`, `onlyDirectories`)
42
+ * are removed from the public API surface, preventing consumers from
43
+ * modifying directory matching behavior.
44
+ *
45
+ * @template ForceUnique
46
+ * When `true`, the `unique` option is removed from the public API to enforce internal uniqueness handling.
47
+ *
48
+ * This allows higher-level utilities to guarantee that matched results
49
+ * are always deduplicated.
50
+ *
51
+ * ----------------------------------------------------------------
52
+ *
53
+ * This type serves as the public configuration contract used when
54
+ * resolving glob patterns.
55
+ */
56
+ type PatternOptions<FilesOnly extends boolean = false, ForceUnique extends boolean = false> = OmitStrict<fg.Options, "fs" | "cwd" | "stats" | "deep" | "extglob" | "suppressErrors" | "braceExpansion" | "dot" | IfTrueGeneric<FilesOnly, "onlyFiles" | "onlyDirectories"> | IfTrueGeneric<ForceUnique, "unique">, {
57
+ skipPrettify: true;
58
+ }> & {
59
+ /** Allow patterns to match entries that begin with a period (`.`).
60
+ *
61
+ * @default true
62
+ */
63
+ dot?: boolean;
64
+ };
65
+ /** ----------------------------------------------------------------
66
+ * * ***Pattern configuration wrapper.***
67
+ * ----------------------------------------------------------------
68
+ *
69
+ * Provides an optional container for {@link PatternOptions | `PatternOptions`}.
70
+ *
71
+ * This wrapper allows pattern matching configuration to be composed
72
+ * within higher-level configuration objects without flattening
73
+ * the option namespace.
74
+ *
75
+ * ----------------------------------------------------------------
76
+ *
77
+ * @template FilesOnly
78
+ * When `true`, directory-related options (`onlyFiles`, `onlyDirectories`)
79
+ * are removed from the public configuration to enforce file-only matching.
80
+ *
81
+ * @template ForceUnique
82
+ * When `true`, the `unique` option is removed from the underlying
83
+ * {@link PatternOptions | `PatternOptions`} to guarantee deduplicated results.
84
+ *
85
+ * ----------------------------------------------------------------
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const config: PatternConfig = {
90
+ * patternOptions: {
91
+ * dot: true
92
+ * }
93
+ * };
94
+ * ```
95
+ */
96
+ type PatternConfig<FilesOnly extends boolean = false, ForceUnique extends boolean = false> = Prettify<{
97
+ /** ----------------------------------------------------------------
98
+ * * ***Pattern matching options.***
99
+ * ----------------------------------------------------------------
100
+ *
101
+ * Optional configuration for controlling file pattern resolution.
102
+ *
103
+ * When provided, these options are sanitized and merged with
104
+ * the internal default configuration before being passed to
105
+ * {@link fg | `fast-glob`}.
106
+ *
107
+ * @see {@link PatternOptions | `PatternOptions`} for supported fields.
108
+ */
109
+ patternOptions?: PatternOptions<FilesOnly, ForceUnique>;
110
+ }>;
111
+ /** ----------------------------------------------------------------
112
+ * * ***Default pattern matching configuration.***
113
+ * ----------------------------------------------------------------
114
+ *
115
+ * Represents the canonical baseline configuration used when
116
+ * resolving pattern options.
117
+ *
118
+ * These values are applied whenever a user does not explicitly
119
+ * provide overrides.
120
+ *
121
+ * This object also acts as the runtime source of truth for
122
+ * allowed pattern option keys.
123
+ */
124
+ declare const defaultPatternOptions: PatternOptions;
125
+ export { PatternOptions as n, defaultPatternOptions as r, PatternConfig as t };
126
+ //# sourceMappingURL=fast-globe-options-6r2aj6UC.d.ts.map
@@ -0,0 +1,126 @@
1
+ /*!
2
+ * ========================================================================
3
+ * @rzl-zone/build-tools
4
+ * ------------------------------------------------------------------------
5
+ * Version: `0.0.5`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
8
+ * ========================================================================
9
+ */
10
+
11
+ import { a as OmitStrict, s as Prettify } from "./extra-CxDwtQEy.cjs";
12
+ import * as fg from "fast-glob";
13
+
14
+ type IfTrueGeneric<T extends boolean, K> = T extends true ? K : never;
15
+ /** ----------------------------------------------------------------
16
+ * * ***Supported pattern matching options.***
17
+ * ----------------------------------------------------------------
18
+ * Defines the subset of {@link fg | `fast-glob`} options exposed by
19
+ * this module for pattern-based file resolution.
20
+ *
21
+ * This type intentionally omits several low-level or environment-
22
+ * controlled fields to ensure predictable and safe behavior.
23
+ *
24
+ * ----------------------------------------------------------------
25
+ *
26
+ * *Excluded options (managed internally):*
27
+ *
28
+ * - `fs`
29
+ * - `cwd`
30
+ * - `stats`
31
+ * - `deep`
32
+ * - `extglob`
33
+ * - `suppressErrors`
34
+ * - `braceExpansion`
35
+ *
36
+ * These fields are controlled by the runtime environment and should
37
+ * not be overridden by consumers.
38
+ *
39
+ * ----------------------------------------------------------------
40
+ * @template FilesOnly
41
+ * When `true`, directory filtering options (`onlyFiles`, `onlyDirectories`)
42
+ * are removed from the public API surface, preventing consumers from
43
+ * modifying directory matching behavior.
44
+ *
45
+ * @template ForceUnique
46
+ * When `true`, the `unique` option is removed from the public API to enforce internal uniqueness handling.
47
+ *
48
+ * This allows higher-level utilities to guarantee that matched results
49
+ * are always deduplicated.
50
+ *
51
+ * ----------------------------------------------------------------
52
+ *
53
+ * This type serves as the public configuration contract used when
54
+ * resolving glob patterns.
55
+ */
56
+ type PatternOptions<FilesOnly extends boolean = false, ForceUnique extends boolean = false> = OmitStrict<fg.Options, "fs" | "cwd" | "stats" | "deep" | "extglob" | "suppressErrors" | "braceExpansion" | "dot" | IfTrueGeneric<FilesOnly, "onlyFiles" | "onlyDirectories"> | IfTrueGeneric<ForceUnique, "unique">, {
57
+ skipPrettify: true;
58
+ }> & {
59
+ /** Allow patterns to match entries that begin with a period (`.`).
60
+ *
61
+ * @default true
62
+ */
63
+ dot?: boolean;
64
+ };
65
+ /** ----------------------------------------------------------------
66
+ * * ***Pattern configuration wrapper.***
67
+ * ----------------------------------------------------------------
68
+ *
69
+ * Provides an optional container for {@link PatternOptions | `PatternOptions`}.
70
+ *
71
+ * This wrapper allows pattern matching configuration to be composed
72
+ * within higher-level configuration objects without flattening
73
+ * the option namespace.
74
+ *
75
+ * ----------------------------------------------------------------
76
+ *
77
+ * @template FilesOnly
78
+ * When `true`, directory-related options (`onlyFiles`, `onlyDirectories`)
79
+ * are removed from the public configuration to enforce file-only matching.
80
+ *
81
+ * @template ForceUnique
82
+ * When `true`, the `unique` option is removed from the underlying
83
+ * {@link PatternOptions | `PatternOptions`} to guarantee deduplicated results.
84
+ *
85
+ * ----------------------------------------------------------------
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const config: PatternConfig = {
90
+ * patternOptions: {
91
+ * dot: true
92
+ * }
93
+ * };
94
+ * ```
95
+ */
96
+ type PatternConfig<FilesOnly extends boolean = false, ForceUnique extends boolean = false> = Prettify<{
97
+ /** ----------------------------------------------------------------
98
+ * * ***Pattern matching options.***
99
+ * ----------------------------------------------------------------
100
+ *
101
+ * Optional configuration for controlling file pattern resolution.
102
+ *
103
+ * When provided, these options are sanitized and merged with
104
+ * the internal default configuration before being passed to
105
+ * {@link fg | `fast-glob`}.
106
+ *
107
+ * @see {@link PatternOptions | `PatternOptions`} for supported fields.
108
+ */
109
+ patternOptions?: PatternOptions<FilesOnly, ForceUnique>;
110
+ }>;
111
+ /** ----------------------------------------------------------------
112
+ * * ***Default pattern matching configuration.***
113
+ * ----------------------------------------------------------------
114
+ *
115
+ * Represents the canonical baseline configuration used when
116
+ * resolving pattern options.
117
+ *
118
+ * These values are applied whenever a user does not explicitly
119
+ * provide overrides.
120
+ *
121
+ * This object also acts as the runtime source of truth for
122
+ * allowed pattern option keys.
123
+ */
124
+ declare const defaultPatternOptions: PatternOptions;
125
+ export { PatternOptions as n, defaultPatternOptions as r, PatternConfig as t };
126
+ //# sourceMappingURL=fast-globe-options-BFt__e__.d.cts.map
@@ -0,0 +1,215 @@
1
+ /*!
2
+ * ========================================================================
3
+ * @rzl-zone/build-tools
4
+ * ------------------------------------------------------------------------
5
+ * Version: `0.0.5`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
8
+ * ========================================================================
9
+ */
10
+
11
+ function deepFreeze(value) {
12
+ if (typeof value !== "object" || value === null) return value;
13
+ const seen = /* @__PURE__ */ new WeakSet();
14
+ const stack = [value];
15
+ while (stack.length) {
16
+ const obj = stack.pop();
17
+ if (seen.has(obj) || Object.isFrozen(obj)) continue;
18
+ seen.add(obj);
19
+ if (isMap(obj)) for (const [k, v] of obj) {
20
+ if (typeof k === "object" && k !== null) stack.push(k);
21
+ if (typeof v === "object" && v !== null) stack.push(v);
22
+ }
23
+ else if (isSet(obj)) {
24
+ for (const v of obj) if (typeof v === "object" && v !== null) stack.push(v);
25
+ } else if (isArray(obj)) {
26
+ for (const v of obj) if (typeof v === "object" && v !== null) stack.push(v);
27
+ } else {
28
+ const record = obj;
29
+ for (const key of Reflect.ownKeys(record)) {
30
+ const v = record[key];
31
+ if (typeof v === "object" && v !== null) stack.push(v);
32
+ }
33
+ }
34
+ Object.freeze(obj);
35
+ }
36
+ return value;
37
+ }
38
+ const isRegExp = (value) => {
39
+ return value instanceof RegExp;
40
+ };
41
+ const isString = (value) => {
42
+ return typeof value === "string";
43
+ };
44
+ function isSet(value) {
45
+ return Object.prototype.toString.call(value) === "[object Set]" || value instanceof Set;
46
+ }
47
+ function isMap(value) {
48
+ return Object.prototype.toString.call(value) === "[object Map]" || value instanceof Map;
49
+ }
50
+ function isArray(value) {
51
+ return Array.isArray(value);
52
+ }
53
+ const isNull = (val) => val === null;
54
+ function isPlainObject(value) {
55
+ if (!isObject(value)) return false;
56
+ const proto = Object.getPrototypeOf(value);
57
+ return proto === Object.prototype || proto === null;
58
+ }
59
+ function isObject(value) {
60
+ return typeof value === "object" && !isNil(value) && !isArray(value);
61
+ }
62
+ function isObjectOrArray(value) {
63
+ return isArray(value) || isObject(value);
64
+ }
65
+ const isNil = (value) => {
66
+ return value == null;
67
+ };
68
+ const isBoolean = (value) => {
69
+ return typeof value === "boolean";
70
+ };
71
+ const isUndefined = (value) => {
72
+ return typeof value === "undefined";
73
+ };
74
+ const isFunction = (value) => {
75
+ return typeof value === "function";
76
+ };
77
+ const isNumberObject = (value) => {
78
+ return isObject(value) && Object.prototype.toString.call(value) === "[object Number]";
79
+ };
80
+ const isStringObject = (value) => {
81
+ return isObject(value) && Object.prototype.toString.call(value) === "[object String]";
82
+ };
83
+ const isBooleanObject = (value) => {
84
+ return isObject(value) && Object.prototype.toString.call(value) === "[object Boolean]";
85
+ };
86
+ const isInfinityNumber = (value) => {
87
+ if (typeof value === "number" || isNumberObject(value)) {
88
+ const num = Number(value);
89
+ return num === Infinity || num === -Infinity;
90
+ }
91
+ return false;
92
+ };
93
+ const isSymbol = (value) => {
94
+ return typeof value === "symbol";
95
+ };
96
+ const isBigInt = (value) => {
97
+ return typeof value === "bigint";
98
+ };
99
+ const isNaN = (value) => {
100
+ return typeof value === "number" ? Number.isNaN(value) : isNumberObject(value) && Number.isNaN(value.valueOf());
101
+ };
102
+ const isNonEmptyString = (value, options = {}) => {
103
+ if (!isString(value)) return false;
104
+ return (options.trim ?? true ? value.trim() : value).length > 0;
105
+ };
106
+ const isNumber = (value, options = {}) => {
107
+ const includeNaN = isPlainObject(options) && isBoolean(options.includeNaN) ? options.includeNaN : false;
108
+ const aNumber = typeof value === "number";
109
+ return includeNaN ? aNumber : aNumber && !Number.isNaN(value);
110
+ };
111
+ const isError = (error) => {
112
+ return Object.prototype.toString.call(error) === "[object Error]" || error instanceof Error;
113
+ };
114
+ const isDate = (value, options = {}) => {
115
+ const skipInvalidDate = isPlainObject(options) && isBoolean(options.skipInvalidDate) ? options.skipInvalidDate : false;
116
+ const instanceDate = value instanceof Date;
117
+ if (skipInvalidDate) return instanceDate;
118
+ return instanceDate && !isNaN(value.getTime());
119
+ };
120
+ const safeStableStringify = (value, options = {}) => {
121
+ const pretty = options.pretty ?? false;
122
+ const sortKeys = options.sortKeys ?? true;
123
+ const sortArray = options.sortArray ?? false;
124
+ const keepUndefined = options.keepUndefined ?? false;
125
+ if (isUndefined(value)) return keepUndefined ? "undefined" : "null";
126
+ const seen = /* @__PURE__ */ new WeakSet();
127
+ const isPrimitive = (val) => isNull(val) || !isObjectOrArray(val) && !isFunction(val);
128
+ const deepProcess = (val) => {
129
+ if (isNumberObject(val)) {
130
+ const valOf = val.valueOf();
131
+ return isNaN(valOf) || isInfinityNumber(valOf) ? null : valOf;
132
+ }
133
+ if (isStringObject(val)) return val.valueOf();
134
+ if (isBooleanObject(val)) return val.valueOf();
135
+ if (isFunction(val) || isSymbol(val)) return void 0;
136
+ if (isBigInt(val)) return val.toString();
137
+ if (isNaN(val) || isInfinityNumber(val)) return null;
138
+ if (isUndefined(val)) return keepUndefined ? void 0 : null;
139
+ if (isObjectOrArray(val)) {
140
+ if (seen.has(val)) return "[Circular]";
141
+ seen.add(val);
142
+ if (isDate(val)) return val.toISOString();
143
+ if (isMap(val)) return { map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)]) };
144
+ if (isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };
145
+ if (isArray(val)) {
146
+ const processedArr = val.map(deepProcess);
147
+ if (sortArray) {
148
+ const primitives = [];
149
+ const nonPrimitives = [];
150
+ for (const item of processedArr) if (isPrimitive(item)) primitives.push(item);
151
+ else nonPrimitives.push(item);
152
+ primitives.sort((a, b) => {
153
+ if (isNumber(a) && isNumber(b)) return a - b;
154
+ return String(a).localeCompare(String(b));
155
+ });
156
+ return [...primitives, ...nonPrimitives];
157
+ }
158
+ return processedArr;
159
+ }
160
+ const keys = Object.keys(val);
161
+ if (sortKeys) keys.sort((a, b) => {
162
+ const na = Number(a);
163
+ const nb = Number(b);
164
+ if (!isNaN(na) && !isNaN(nb)) return na - nb;
165
+ return a.localeCompare(b);
166
+ });
167
+ const result = {};
168
+ if (isObject(val)) for (const k of keys) {
169
+ const v = deepProcess(val[k]);
170
+ if (!isUndefined(v)) result[k] = v;
171
+ }
172
+ return result;
173
+ }
174
+ return val;
175
+ };
176
+ try {
177
+ return JSON.stringify(deepProcess(value), null, pretty ? 2 : 0);
178
+ } catch (err) {
179
+ console.warn("Error in safeStableStringify:", err);
180
+ return "{}";
181
+ }
182
+ };
183
+ const normalizeSpaces = (value, options = {
184
+ withTrim: true,
185
+ trimOnly: false
186
+ }) => {
187
+ if (!isNonEmptyString(value)) return "";
188
+ if (!isPlainObject(options)) options = {};
189
+ const { trimOnly = false, withTrim = true } = options;
190
+ if (trimOnly) return value.trim();
191
+ if (withTrim) value = value.trim();
192
+ return value.replace(/\s+/g, " ");
193
+ };
194
+ const isStringArray = (v) => isArray(v) && v.every((i) => isString(i));
195
+ const isStringSet = (v) => isSet(v) && [...v].every((i) => isString(i));
196
+ const assertValidatePatternArgs = (v, parameterKey = "pattern") => {
197
+ if (!isString(v) && !isStringArray(v) && !isStringSet(v)) throw new TypeError(`The \`${parameterKey}\` argument must be a string, string[] or Set<string>.`);
198
+ };
199
+ const flattenStrings = (input) => {
200
+ return input.flat(Infinity).filter((v) => typeof v === "string");
201
+ };
202
+ const toStringSet = (pattern, options = {}) => {
203
+ const { withValidationType = true, parameterKey = "pattern" } = options;
204
+ if (withValidationType) assertValidatePatternArgs(pattern, parameterKey);
205
+ return toObjectSet(pattern);
206
+ };
207
+ const toObjectSet = (value) => {
208
+ if (isSet(value)) return value;
209
+ return new Set(isArray(value) ? value : [value]);
210
+ };
211
+ const toArray = (value) => {
212
+ return isArray(value) ? value : [value];
213
+ };
214
+ export { toStringSet as S, isUndefined as _, isError as a, toArray as b, isNil as c, isNumber as d, isObject as f, isString as g, isSet as h, isBoolean as i, isNonEmptyString as l, isRegExp as m, flattenStrings as n, isFunction as o, isPlainObject as p, isArray as r, isMap as s, deepFreeze as t, isNull as u, normalizeSpaces as v, toObjectSet as x, safeStableStringify as y };
215
+ //# sourceMappingURL=helper-BdjaR8Yv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper-BdjaR8Yv.js","names":[],"sources":["../src/_internal/utils/helper.ts"],"sourcesContent":["import type {\n AnObjectNonArray,\n AnyFunction,\n Arrayable,\n Extends,\n IsArray,\n IsNever,\n NonPlainObject,\n OrArr,\n ReadonlyDeep\n} from \"@/_internal/types/extra\";\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport function deepFreeze<T>(value: T): ReadonlyDeep<T> {\n if (typeof value !== \"object\" || value === null) {\n return value as ReadonlyDeep<T>;\n }\n\n const seen = new WeakSet<object>();\n const stack: object[] = [value as object];\n\n while (stack.length) {\n const obj = stack.pop()!;\n\n if (seen.has(obj) || Object.isFrozen(obj)) continue;\n\n seen.add(obj);\n\n // Map\n if (isMap(obj)) {\n for (const [k, v] of obj) {\n if (typeof k === \"object\" && k !== null) stack.push(k);\n if (typeof v === \"object\" && v !== null) stack.push(v);\n }\n }\n\n // Set\n else if (isSet(obj)) {\n for (const v of obj) {\n if (typeof v === \"object\" && v !== null) stack.push(v);\n }\n }\n\n // Fast path Array\n else if (isArray(obj)) {\n for (const v of obj) {\n if (typeof v === \"object\" && v !== null) stack.push(v);\n }\n } else {\n const record = obj as Record<PropertyKey, unknown>;\n\n for (const key of Reflect.ownKeys(record)) {\n const v = record[key];\n if (typeof v === \"object\" && v !== null) stack.push(v);\n }\n\n // const descriptors = Object.getOwnPropertyDescriptors(obj);\n\n // for (const key of Reflect.ownKeys(descriptors)) {\n // const desc = descriptors[key as keyof typeof descriptors];\n // if (!desc) continue;\n\n // if (\"value\" in desc) {\n // const v = desc.value;\n // if (typeof v === \"object\" && v !== null) stack.push(v);\n // }\n // }\n }\n\n Object.freeze(obj);\n }\n\n return value as ReadonlyDeep<T>;\n}\n// ----------------------------------------------------------------\n\n/** @internal */\nexport function isObjectLoose<T>(\n value: T\n): value is Extract<T, object | AnyFunction> {\n return !isNil(value) && (isObjectOrArray(value) || isFunction(value));\n}\n\nexport function isObjectLike<T>(value: T): value is Extract<T, object> {\n return !isFunction(value) && isObjectLoose(value);\n}\n// ----------------------------------------------------------------\n\n/** ----------------------------------------------------------------\n * * ***Check whether a value is thenable (Promise-like).***\n * ----------------------------------------------------------------\n *\n * Determines whether a value implements a `.then()` method and can be\n * treated as a **thenable** object.\n *\n * This includes:\n * - Native `Promise`.\n * - Promise-like objects returned by libraries.\n * - Custom objects implementing `.then()`.\n *\n * ----------------------------------------------------------------\n *\n * @typeParam T\n * The resolved value type of the thenable.\n *\n * @param v\n * The value to check.\n *\n * @returns\n * `true` if the value is thenable, otherwise `false`.\n *\n * When `true`, the value is narrowed to `PromiseLike<T>`.\n *\n * ----------------------------------------------------------------\n *\n * @example\n * ```ts\n * isThenable(Promise.resolve(1));\n * // ➔ true\n *\n * isThenable({ then: () => {} });\n * // ➔ true\n *\n * isThenable(123);\n * // ➔ false\n * ```\n *\n * @example\n * ```ts\n * async function unwrap<T>(value: T | Promise<T>) {\n * if (isThenable<T>(value)) {\n * return await value;\n * }\n *\n * return value;\n * }\n * ```\n *\n * @remarks\n * Thenables are typically resolved before function execution to support async config factories without enforcing `Promise` instances.\n * - This function checks **behavior**, not identity.\n * - The value does **not** have to be an instance of `Promise`.\n * - Useful for async utilities, lazy evaluation, and hybrid sync/async APIs.\n *\n * @internal\n */\nexport const isThenable = <T = unknown>(v: unknown): v is PromiseLike<T> =>\n v != null &&\n (typeof v === \"object\" || typeof v === \"function\") &&\n typeof (v as PromiseLike<T>).then === \"function\";\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isRegExp = (value: unknown): value is RegExp => {\n return value instanceof RegExp;\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isString = (value: unknown): value is string => {\n return typeof value === \"string\";\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport function isSet<T = unknown>(value: Set<T>): value is Set<T>;\nexport function isSet(value: unknown): value is Set<unknown>;\nexport function isSet(value: unknown): boolean {\n return (\n Object.prototype.toString.call(value) === \"[object Set]\" ||\n value instanceof Set\n );\n}\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport function isMap<K = unknown, V = unknown>(\n value: Map<K, V>\n): value is Map<K, V>;\nexport function isMap(value: unknown): value is Map<unknown, unknown>;\nexport function isMap(value: unknown): boolean {\n return (\n Object.prototype.toString.call(value) === \"[object Map]\" ||\n value instanceof Map\n );\n}\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype ArrayFallback<T> =\n IsNever<Extract<T, unknown[] | readonly unknown[]>> extends true\n ? unknown[] & T\n : Extract<T, unknown[] | readonly unknown[]>;\n\n/** @internal */\nexport function isArray<T>(value: T): value is ArrayFallback<T>;\n// export function isArray<T>(value: T): value is IsNever<Extract<T, unknown[]>> extends true ? unknown[]: Extract<T, unknown[]>;\nexport function isArray(value: unknown): value is unknown[];\nexport function isArray(value: unknown): boolean {\n return Array.isArray(value);\n}\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isNull = (val: unknown): val is null => val === null;\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype IsPlainObjectResult<T> = unknown extends T\n ? Record<PropertyKey, unknown> & T\n : T extends object\n ? T extends NonPlainObject\n ? never\n : IsHasKeysObject<T> extends false\n ? Record<PropertyKey, unknown> & T\n : T\n : Extract<T, Record<PropertyKey, unknown>>;\n\n/** @internal */\nexport function isPlainObject<T>(value: T): value is IsPlainObjectResult<T>;\nexport function isPlainObject<T>(\n value: T\n): value is NonNullable<Extract<T, Record<PropertyKey, unknown>>>;\nexport function isPlainObject(value: unknown) {\n if (!isObject(value)) return false;\n\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype IsObject<T> = unknown extends T\n ? T & Record<PropertyKey, unknown>\n : T extends object\n ? T extends AnObjectNonArray\n ? T\n : IsHasKeysObject<T> extends false\n ? T & Record<PropertyKey, unknown>\n : IsArray<T> extends true\n ? Exclude<T, unknown[]>\n : T\n : never;\n\n/** @internal */\nexport function isObject<T extends object>(value: T): value is IsObject<T>;\nexport function isObject(value: unknown): value is Record<PropertyKey, unknown>;\nexport function isObject(value: unknown): boolean {\n return typeof value === \"object\" && !isNil(value) && !isArray(value);\n}\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype IsHasKeysObject<T> = keyof T extends never ? false : true;\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype IsObjectOrArray<T> =\n OrArr<\n [IsNever<T>, Extends<T, Record<PropertyKey, unknown>>, Extends<unknown, T>]\n > extends true\n ? T & Record<PropertyKey, unknown> & unknown[]\n : T extends object\n ? T extends unknown[]\n ? T\n : T extends AnObjectNonArray\n ? T\n : IsHasKeysObject<T> extends false\n ? T & Record<PropertyKey, unknown>\n : T\n : Extract<T, Record<PropertyKey, unknown> & unknown[]>;\n\n/** @internal */\nexport function isObjectOrArray(value: []): value is [];\nexport function isObjectOrArray<T>(value: T): value is IsObjectOrArray<T>;\nexport function isObjectOrArray<T>(value: T): boolean {\n return isArray(value) || isObject(value);\n}\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isNil = (value: unknown): value is null | undefined => {\n return value == null;\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isBoolean = (value: unknown): value is boolean => {\n return typeof value === \"boolean\";\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isUndefined = (value: unknown): value is undefined => {\n return typeof value === \"undefined\";\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isFunction = (value: unknown): value is AnyFunction => {\n return typeof value === \"function\";\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nexport const isNumberObject = (value: unknown): value is Number => {\n return (\n isObject(value) &&\n Object.prototype.toString.call(value) === \"[object Number]\"\n );\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nexport const isStringObject = (value: unknown): value is String => {\n return (\n isObject(value) &&\n Object.prototype.toString.call(value) === \"[object String]\"\n );\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nexport const isBooleanObject = (value: unknown): value is Boolean => {\n return (\n isObject(value) &&\n Object.prototype.toString.call(value) === \"[object Boolean]\"\n );\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isInfinityNumber = (value: unknown): boolean => {\n if (typeof value === \"number\" || isNumberObject(value)) {\n const num = Number(value);\n return num === Infinity || num === -Infinity;\n }\n return false;\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isSymbol = (value: unknown): value is symbol => {\n return typeof value === \"symbol\";\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isBigInt = (value: unknown): value is bigint => {\n return typeof value === \"bigint\";\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isNaN = (value: unknown): boolean => {\n return typeof value === \"number\"\n ? Number.isNaN(value)\n : isNumberObject(value) && Number.isNaN(value.valueOf());\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype IsNonEmptyStringOptions = {\n /** Whether to trim the string before checking, defaultValue: `true`.\n *\n * @default true */\n trim?: boolean;\n};\n\n/** @internal */\nexport const isNonEmptyString = (\n value: unknown,\n options: IsNonEmptyStringOptions = {}\n): value is string => {\n if (!isString(value)) return false;\n\n const trim = options.trim ?? true;\n\n const str = trim ? value.trim() : value;\n\n return str.length > 0;\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype IsNumberOptions = {\n /** If set to `true`, `NaN` will be considered a valid number, defaultValue: `false`.\n *\n * @default false\n */\n includeNaN?: boolean;\n};\n\n/** @internal */\nexport const isNumber = (\n value: unknown,\n options: IsNumberOptions = {}\n): value is number => {\n const includeNaN =\n isPlainObject(options) && isBoolean(options.includeNaN)\n ? options.includeNaN\n : false;\n\n const aNumber = typeof value === \"number\";\n return includeNaN ? aNumber : aNumber && !Number.isNaN(value);\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport const isError = (error: unknown): error is Error => {\n return (\n Object.prototype.toString.call(error) === \"[object Error]\" ||\n error instanceof Error\n );\n};\n// ----------------------------------------------------------------\n\n/** @internal */\ntype isDateOptions = {\n /** * ***Skip the validity check (`!isNaN(date.getTime())`).***\n *\n * When `true`, the function only checks that the value is an\n * instance of `Date` without verifying that it represents a valid\n * date value, default: `false`.\n *\n * @default false\n */\n skipInvalidDate?: boolean;\n};\n\n/** @internal */\nexport const isDate = (\n value: unknown,\n options: isDateOptions = {}\n): value is Date => {\n const skipInvalidDate =\n isPlainObject(options) && isBoolean(options.skipInvalidDate)\n ? options.skipInvalidDate\n : false;\n\n const instanceDate = value instanceof Date;\n\n if (skipInvalidDate) return instanceDate;\n return instanceDate && !isNaN(value.getTime());\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\nexport type SafeStableStringifyOptions = {\n /** -------------------------------------------------\n * * ***Whether to sort **object keys** alphabetically (recursively).***\n * -------------------------------------------------\n *\n * - `true` (default): object keys are sorted to ensure stable output.\n * - `false`: preserves original insertion order of keys.\n *\n * @default true\n */\n sortKeys?: boolean;\n /** -------------------------------------------------\n * * ***Whether to sort **primitive values inside arrays**.***\n * -------------------------------------------------\n *\n * - `true`: primitive values in arrays are sorted to ensure stable output.\n * - `false` (default): arrays retain their original order; objects and nested arrays are not reordered.\n *\n * @default false\n */\n sortArray?: boolean;\n /** -------------------------------------------------\n * * ***Whether to pretty-print JSON output with 2-space indentation.***\n * -------------------------------------------------\n *\n * - `true`: output is formatted with indentation and newlines.\n * - `false` (default): produces compact single-line JSON.\n *\n * @default false\n */\n pretty?: boolean;\n /** -------------------------------------------------\n * * ***Preserve `undefined` values instead of converting them to `null`.***\n * -------------------------------------------------\n * **Controls how the internal `deepProcess` step rewrites values\n * **before** the final `JSON.stringify` call.**\n * - **Default (`false`):**\n * * Every `undefined` value (object properties **and** array elements)\n * is replaced with `null` **before** serialization, because this happens\n * first, the key is **not removed** by `JSON.stringify`.\n * - **`true`** – Leaves `undefined` untouched so the final\n * `JSON.stringify` call behaves natively:\n * * Object properties with `undefined` are **removed**.\n * * Array elements that are `undefined` become `null`.\n * @default false\n * @example\n * // ✅ keepUndefined = true: behaves like native JSON.stringify\n * safeStableStringify({ a: undefined }, { keepUndefined: true });\n * // ➔ '{}' // key removed\n *\n * // ✅ Default (false): convert undefined to null, key kept\n * safeStableStringify({ a: undefined });\n * // ➔ '{\"a\":null}' // key present, value null\n *\n * // Arrays\n * safeStableStringify([undefined]);\n * // ➔ '[null]' // same, but via pre-replacement\n * safeStableStringify([undefined], { keepUndefined: true });\n * // ➔ '[null]' // element becomes null\n */\n keepUndefined?: boolean;\n};\n\n/** @internal */\nexport const safeStableStringify = (\n value: unknown,\n options: SafeStableStringifyOptions = {}\n): string => {\n const pretty = options.pretty ?? false;\n const sortKeys = options.sortKeys ?? true;\n const sortArray = options.sortArray ?? false;\n const keepUndefined = options.keepUndefined ?? false;\n\n if (isUndefined(value)) {\n return keepUndefined ? \"undefined\" : \"null\";\n }\n\n const seen = new WeakSet();\n\n const isPrimitive = (val: unknown): boolean =>\n isNull(val) || (!isObjectOrArray(val) && !isFunction(val));\n\n const deepProcess = (val: unknown): unknown => {\n if (isNumberObject(val)) {\n const valOf = val.valueOf();\n return isNaN(valOf) || isInfinityNumber(valOf) ? null : valOf;\n }\n if (isStringObject(val)) return val.valueOf();\n if (isBooleanObject(val)) return val.valueOf();\n if (isFunction(val) || isSymbol(val)) return undefined;\n if (isBigInt(val)) return val.toString();\n if (isNaN(val) || isInfinityNumber(val)) return null;\n if (isUndefined(val)) {\n return keepUndefined ? undefined : null;\n }\n\n if (isObjectOrArray(val)) {\n if (seen.has(val)) return \"[Circular]\";\n seen.add(val);\n\n if (isDate(val)) return val.toISOString();\n if (isMap(val)) {\n return {\n map: Array.from(val.entries()).map(([k, v]) => [k, deepProcess(v)])\n };\n }\n if (isSet(val)) return { set: Array.from(val.values()).map(deepProcess) };\n\n if (isArray(val)) {\n const processedArr = val.map(deepProcess);\n if (sortArray) {\n const primitives: unknown[] = [];\n const nonPrimitives: unknown[] = [];\n\n for (const item of processedArr) {\n if (isPrimitive(item)) primitives.push(item);\n else nonPrimitives.push(item);\n }\n primitives.sort((a, b) => {\n if (isNumber(a) && isNumber(b)) return a - b;\n return String(a).localeCompare(String(b));\n });\n return [...primitives, ...nonPrimitives];\n }\n return processedArr;\n }\n\n const keys = Object.keys(val);\n if (sortKeys) {\n keys.sort((a, b) => {\n const na = Number(a);\n const nb = Number(b);\n if (!isNaN(na) && !isNaN(nb)) return na - nb;\n return a.localeCompare(b);\n });\n }\n\n const result: Record<string, unknown> = {};\n\n if (isObject(val)) {\n for (const k of keys) {\n const v = deepProcess(val[k]);\n if (!isUndefined(v)) result[k] = v;\n }\n }\n\n return result;\n }\n\n return val;\n };\n\n try {\n return JSON.stringify(deepProcess(value), null, pretty ? 2 : 0);\n } catch (err) {\n console.warn(\"Error in safeStableStringify:\", err);\n return \"{}\";\n }\n};\n\n// ----------------------------------------------------------------\n\n/** @internal */\ntype NormalizeSpacesOptions = {\n /** If `true`, skips normalization and only trims whitespace from start & end, defaultValue: `false`.\n *\n * @default false\n */\n trimOnly?: boolean;\n /** If `false`, skips trimming value, defaultValue: `true`.\n *\n * @default true\n */\n withTrim?: boolean;\n};\n\n/** @internal */\nexport const normalizeSpaces = (\n value: string | null | undefined,\n options: NormalizeSpacesOptions = {\n withTrim: true,\n trimOnly: false\n }\n): string => {\n if (!isNonEmptyString(value)) return \"\";\n\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const { trimOnly = false, withTrim = true } = options;\n\n if (trimOnly) return value.trim();\n\n if (withTrim) {\n value = value.trim();\n }\n\n // Remove all duplicate spaces (including tabs, newlines, etc.)\n return value.replace(/\\s+/g, \" \");\n};\n\n// ----------------------------------------------------------------\n\n/** ----------------------------------------------------------------\n * * ***Checks whether a value is an array of strings.***\n * ----------------------------------------------------------------\n *\n * Type guard that validates the input is an `Array` where **all**\n * elements are strings.\n *\n * @param {unknown} v - The value to test.\n *\n * @returns {boolean} `true` if the value is a `string[]`.\n *\n * @internal\n */\nexport const isStringArray = (v: unknown): v is string[] =>\n isArray(v) && v.every((i) => isString(i));\n\n/** ----------------------------------------------------------------\n * * ***Checks whether a value is a Set of strings.***\n * ----------------------------------------------------------------\n *\n * Type guard that validates the input is a `Set` where **all**\n * entries are strings.\n *\n * @param {unknown} v - The value to test.\n *\n * @returns {boolean} `true` if the value is a `Set<string>`.\n *\n * @internal\n */\nexport const isStringSet = (v: unknown): v is Set<string> =>\n isSet(v) && [...v].every((i) => isString(i));\n\n/** ----------------------------------------------------------------\n * * ***Asserts that a value is a valid pattern input.***\n * ----------------------------------------------------------------\n *\n * Runtime assertion that validates the provided value is one of the\n * supported pattern types:\n * - `string`.\n * - `string[]`.\n * - `Set<string>`.\n *\n * This function is intended to be used at API boundaries to ensure\n * type safety before further processing.\n *\n * @param {unknown} v - The value to validate.\n * @param {string|undefined} parameterKey - The key parameter to identity which is invalid, default `\"pattern\"`.\n *\n * @throws {TypeError} If the value is not a valid pattern input.\n *\n * @example\n * ```ts\n * assertValidatePatternArgs(pattern);\n * // pattern is now typed as:\n * // string | string[] | Set<string>\n * ```\n *\n * @internal\n */\nexport const assertValidatePatternArgs: (\n v: unknown,\n parameterKey?: string\n) => asserts v is string | string[] | Set<string> = (\n v: unknown,\n parameterKey: string = \"pattern\"\n) => {\n if (!isString(v) && !isStringArray(v) && !isStringSet(v)) {\n throw new TypeError(\n `The \\`${parameterKey}\\` argument must be a string, string[] or Set<string>.`\n );\n }\n};\n\n/** ----------------------------------------------------------------\n * * ***Flattens nested arrays and extracts string values only.***\n * ----------------------------------------------------------------\n *\n * Recursively flattens an input array to **infinite depth** and\n * filters out all non-string values.\n *\n * - *Normalization rules:*\n * - Nested arrays are flattened using `Array.prototype.flat(Infinity)`.\n * - Only values with `typeof === \"string\"` are kept.\n * - Non-string values are discarded.\n *\n * The returned array is always a **new instance** and does not mutate\n * the original input.\n *\n * @param {readonly unknown[]} input - Arbitrary nested array input.\n *\n * @returns {string[]} A flat array containing only string values.\n *\n * @example\n * ```ts\n * flattenStrings([\"a\", [\"b\", [\"c\"]], 1, null]);\n * // ➔ [\"a\", \"b\", \"c\"]\n * ```\n *\n * @internal\n */\nexport const flattenStrings = (input: readonly unknown[]): string[] => {\n return input.flat(Infinity).filter((v): v is string => typeof v === \"string\");\n};\n\n/** ----------------------------------------------------------------\n * * ***Normalizes pattern input into a new `Set<string>` instance.***\n * ----------------------------------------------------------------\n *\n * Converts a pattern value into a deduplicated `Set<string>` for\n * consistent internal handling.\n *\n * #### Normalization behavior\n * - `string` ➔ wrapped into a `Set`.\n * - `string[]` ➔ converted into a `Set` (duplicates removed).\n * - `Set<string>` ➔ cloned into a new `Set`.\n *\n * The returned set is **always a new instance** and the original\n * input is never mutated.\n *\n * #### Validation\n * When `withValidationType` is `true` (default), the input will be\n * validated before normalization.\n *\n * If the provided `pattern` is not one of the supported types,\n * a `TypeError` will be thrown.\n *\n * @param pattern - Pattern value to normalize.\n * @param options - Optional configuration object.\n * @param options.withValidationType - Whether to validate the input\n * before normalization. Defaults to `true`.\n * @param options.parameterKey - The key parameter to identity which is invalid, default `\"pattern\"`.\n *\n * @returns A new deduplicated `Set<string>` instance.\n *\n * @throws {TypeError}\n * Thrown when `pattern` is not a `string`, `string[]`, or `Set<string>`\n * and validation is enabled.\n *\n * @example\n * ```ts\n * toStringSet(\"a\");\n * // ➔ Set { \"a\" }\n * ```\n *\n * @example\n * ```ts\n * toStringSet([\"a\", \"b\", \"a\"]);\n * // ➔ Set { \"a\", \"b\" }\n * ```\n *\n * @example\n * ```ts\n * toStringSet(new Set([\"x\", \"y\"]));\n * // ➔ Set { \"x\", \"y\" }\n * ```\n *\n * @example\n * ```ts\n * toStringSet(123 as any);\n * // ❌ Throws TypeError\n * ```\n *\n * @example\n * ```ts\n * // Disable validation (use cautiously)\n * toStringSet(\"a\", { withValidationType: false });\n * toStringSet(123 as any, { withValidationType: false });\n * ```\n *\n * @internal\n */\nexport const toStringSet = (\n pattern: string | string[] | Set<string>,\n options: {\n withValidationType?: boolean;\n /**\n * The key parameter to identity which is invalid.\n *\n * @default \"pattern\"\n */\n parameterKey?: string;\n } = {}\n): Set<string> => {\n const { withValidationType = true, parameterKey = \"pattern\" } = options;\n if (withValidationType) assertValidatePatternArgs(pattern, parameterKey);\n\n return toObjectSet(pattern);\n};\n\n/** ----------------------------------------------------------------\n * * ***Normalizes a value into a deduplicated `Set`.***\n * ----------------------------------------------------------------\n *\n * Converts a single value, array, or existing `Set` into a `Set<T>`\n * for consistent internal handling.\n *\n * - *Normalization rules:*\n * - `T` ➔ wrapped in a `Set`.\n * - `T[]` ➔ converted to a `Set` (duplicates removed).\n * - `Set<T>` ➔ returned as-is.\n *\n * The returned `Set` is **not mutated** internally by this function.\n * If an existing `Set` is provided, it will be reused.\n *\n * @typeParam T - Value type stored in the set.\n *\n * @param {T | T[] | Set<T>} value - Value to normalize.\n *\n * @returns {Set<T>} A deduplicated set of values.\n *\n * @example\n * ```ts\n * toObjectSet(1);\n * // ➔ Set { 1 }\n * ```\n *\n * @example\n * ```ts\n * toObjectSet([1, 2, 1]);\n * // ➔ Set { 1, 2 }\n * ```\n *\n * @example\n * ```ts\n * toObjectSet(new Set([1, 2]));\n * // ➔ Set { 1, 2 }\n * ```\n *\n * @internal\n */\nexport const toObjectSet = <T>(value: T | T[] | Set<T>): Set<T> => {\n if (isSet(value)) return value;\n\n return new Set(isArray(value) ? value : [value]);\n};\n\n/** ----------------------------------------------------------------\n * * ***Normalize a value into an array.***\n * ----------------------------------------------------------------\n *\n * Converts a single value or an array-like value into a **new array**\n * with consistent typing.\n *\n * - If `value` is already an array ➔ returned as-is.\n * - If `value` is a single item ➔ wrapped in an array.\n *\n * This utility is useful for APIs or configs that accept\n * either a single value or multiple values.\n *\n * ----------------------------------------------------------------\n *\n * @typeParam T\n * The element type of the resulting array.\n *\n * @param value\n * A value or array of values.\n *\n * @returns\n * A normalized array of type `T[]`.\n *\n * ----------------------------------------------------------------\n *\n * @example\n * ```ts\n * toArray(1);\n * // ➔ [1]\n *\n * toArray(\"hello\");\n * // ➔ [\"hello\"]\n *\n * toArray([1, 2, 3]);\n * // ➔ [1, 2, 3]\n * ```\n *\n * @example\n * ```ts\n * type User = { id: number };\n *\n * toArray<User>({ id: 1 });\n * // ➔ [{ id: 1 }]\n *\n * toArray<User>([{ id: 1 }, { id: 2 }]);\n * // ➔ [{ id: 1 }, { id: 2 }]\n * ```\n *\n * @remarks\n * This function does **not** flatten nested arrays.\n * If `value` is already an array, the original reference is preserved.\n *\n * @internal\n */\nexport const toArray = <T>(value: Arrayable<T>): T[] => {\n return isArray(value) ? value : [value];\n};\n"],"mappings":";;;;;;;;;;;;AAeA,SAAgB,WAAc,OAA2B;AACvD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;CAGT,MAAM,uBAAO,IAAI,SAAiB;CAClC,MAAM,QAAkB,CAAC,MAAgB;AAEzC,QAAO,MAAM,QAAQ;EACnB,MAAM,MAAM,MAAM,KAAK;AAEvB,MAAI,KAAK,IAAI,IAAI,IAAI,OAAO,SAAS,IAAI,CAAE;AAE3C,OAAK,IAAI,IAAI;AAGb,MAAI,MAAM,IAAI,CACZ,MAAK,MAAM,CAAC,GAAG,MAAM,KAAK;AACxB,OAAI,OAAO,MAAM,YAAY,MAAM,KAAM,OAAM,KAAK,EAAE;AACtD,OAAI,OAAO,MAAM,YA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