@movk/core 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  [![Movk Core](https://core.mhaibaraai.cn/og-image.png)](https://core.mhaibaraai.cn/)
2
2
 
3
+ [![Install MCP in Cursor](https://core.mhaibaraai.cn/mcp/badge.svg)](https://core.mhaibaraai.cn/mcp/deeplink)
4
+ [![Install MCP in VS Code](https://core.mhaibaraai.cn/mcp/badge.svg?ide=vscode)](https://core.mhaibaraai.cn/mcp/deeplink?ide=vscode)
5
+
3
6
  > `@movk/core` 是一个为 TypeScript 项目设计的现代化、支持 Tree-Shaking 的工具函数库,涵盖了数组、对象、字符串、异步操作等多个方面。
4
7
 
5
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
@@ -67,7 +70,7 @@ Vue 组合式函数,用于状态管理、剪贴板操作等常见场景。
67
70
 
68
71
  ## 📁 目录结构
69
72
 
70
- ```
73
+ ```text
71
74
  src/
72
75
  ├── composables/ # Vue 组合式函数
73
76
  │ ├── useAppStorage # 应用存储管理
package/bin/clean.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { rm } from 'node:fs/promises'
3
3
  import { relative, resolve } from 'node:path'
4
4
  import process from 'node:process'
5
- import fg from 'fast-glob'
5
+ import { glob } from 'tinyglobby'
6
6
 
7
7
  const DEFAULT_TARGETS = [
8
8
  'node_modules',
@@ -44,13 +44,12 @@ async function clean() {
44
44
 
45
45
  let paths
46
46
  try {
47
- paths = await fg(targets.map(t => `**/${t}`), {
47
+ paths = await glob(targets.map(t => `**/${t}`), {
48
48
  cwd: root,
49
49
  onlyFiles: false,
50
50
  dot: true,
51
51
  absolute: true,
52
52
  ignore: ['**/node_modules/**/node_modules/**'],
53
- suppressErrors: true
54
53
  })
55
54
  }
56
55
  catch (e) {
@@ -63,7 +62,7 @@ async function clean() {
63
62
  return
64
63
  }
65
64
 
66
- paths = [...new Set(paths)].sort((a, b) => b.length - a.length)
65
+ paths = new Set(paths).toSorted((a, b) => b.length - a.length)
67
66
 
68
67
  const results = await processBatch(paths)
69
68
  const removed = results.filter(r => r.success).length
package/dist/index.d.mts CHANGED
@@ -295,6 +295,27 @@ type IsPlainObject<T> = NonNullable<T> extends Record<string, any> ? NonNullable
295
295
  type DeepPartial<T> = {
296
296
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] | undefined;
297
297
  };
298
+ /** 递归深度计数器,用于限制类型递归层数 */
299
+ type MergeDepth = [never, 0, 1, 2, 3, 4];
300
+ /**
301
+ * 递归合并两个对象类型,`U` 中的属性优先级高于 `T`。
302
+ * 仅对双方都是纯对象的属性做深度递归,其余类型直接取 `U` 的值。
303
+ *
304
+ * @typeParam T - 基础对象类型
305
+ * @typeParam U - 覆盖对象类型
306
+ * @typeParam D - 递归深度限制,默认为 4
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * type A = { a: { b: number; c: string }; d: boolean }
311
+ * type B = { a: { b: string; e: number }; f: Date }
312
+ * type R = DeepMerge<A, B>
313
+ * // { a: { b: string; c: string; e: number }; d: boolean; f: Date }
314
+ * ```
315
+ */
316
+ type DeepMerge<T, U, D extends number = 4> = [D] extends [never] ? T & U : {
317
+ [K in keyof T | keyof U]: K extends keyof U ? K extends keyof T ? IsPlainObject<T[K]> extends true ? IsPlainObject<U[K]> extends true ? DeepMerge<NonNullable<T[K]>, NonNullable<U[K]>, MergeDepth[D]> : U[K] : U[K] : U[K] : K extends keyof T ? T[K] : never;
318
+ };
298
319
 
299
320
  /**
300
321
  * 深度控制类型,用于限制类型递归的深度
@@ -517,6 +538,128 @@ type FirstParam<T, K extends keyof T> = T[K] extends [infer P, ...any[]] ? P : n
517
538
  * // 结果: R 为 number; 若 T 非函数,则为 undefined
518
539
  */
519
540
  type FirstParameter<T> = T extends (arg: infer P, ...args: any[]) => any ? P : undefined;
541
+ /**
542
+ * 强制 TypeScript 展平类型别名,使 IntelliSense 能完整枚举对象的所有属性。
543
+ *
544
+ * 常用于消除交叉类型(`A & B`)的「折叠」显示,让 IDE 悬停时直接展示合并后的属性列表。
545
+ *
546
+ * @typeParam T - 要展平的对象类型
547
+ * @example
548
+ * ```ts
549
+ * type A = { a: number } & { b: string }
550
+ * // IDE hover 显示 "{ a: number } & { b: string }"
551
+ *
552
+ * type B = Prettify<A>
553
+ * // IDE hover 显示 "{ a: number; b: string }"
554
+ * ```
555
+ */
556
+ type Prettify<T> = {
557
+ [K in keyof T]: T[K];
558
+ } & {};
559
+ /**
560
+ * 从对象类型中提取所有字面量键,过滤掉索引签名(`string`、`number`、`symbol`)。
561
+ *
562
+ * 用于需要精确枚举已知属性而不被索引签名污染 IntelliSense 的场景。
563
+ *
564
+ * @typeParam T - 可能含索引签名的对象类型
565
+ * @example
566
+ * ```ts
567
+ * interface Config {
568
+ * debug: boolean
569
+ * timeout: number
570
+ * [key: string]: unknown
571
+ * }
572
+ * // K = 'debug' | 'timeout'(索引签名 string 被过滤掉)
573
+ * type K = KnownKeys<Config>
574
+ * ```
575
+ */
576
+ type KnownKeys<T> = {
577
+ [K in keyof T]-?: string extends K ? never : number extends K ? never : symbol extends K ? never : K;
578
+ }[keyof T];
579
+
580
+ /**
581
+ * 数组合并策略
582
+ * - `'concat'` : 将 source 数组拼接在 target 数组之后(默认)
583
+ * - `'replace'` : 用 source 数组整体替换 target 数组
584
+ * - `'unique'` : 拼接后去重(基于 SameValueZero 比较)
585
+ */
586
+ type ArrayMergeStrategy = 'concat' | 'replace' | 'unique';
587
+ /**
588
+ * null/undefined 处理策略
589
+ * - `'skip'` : 忽略 source 中的 null/undefined,保留 target 中的值(默认)
590
+ * - `'override'` : 允许 source 中的 null/undefined 覆盖 target 中的值
591
+ */
592
+ type NullHandlingStrategy = 'skip' | 'override';
593
+ /**
594
+ * 自定义合并函数。
595
+ *
596
+ * @param key 当前正在处理的键(string 或 Symbol)
597
+ * @param targetVal target 中该键的当前值
598
+ * @param sourceVal source 中该键的值
599
+ * @param path 从根对象到当前层级的键路径
600
+ * @returns 返回合并结果;返回 `undefined` 则交由默认逻辑处理
601
+ */
602
+ type CustomMerger = (key: string | symbol, targetVal: unknown, sourceVal: unknown, path: ReadonlyArray<string | symbol>) => unknown;
603
+ /**
604
+ * deepMerge 配置选项
605
+ */
606
+ interface DeepMergeOptions {
607
+ /** 数组合并策略,默认 `'concat'` */
608
+ arrayStrategy?: ArrayMergeStrategy;
609
+ /** null/undefined 处理策略,默认 `'skip'` */
610
+ nullHandling?: NullHandlingStrategy;
611
+ /** 自定义合并函数,返回 `undefined` 则交由默认逻辑处理 */
612
+ customMerger?: CustomMerger;
613
+ }
614
+ /**
615
+ * 递归地将多个 source 对象深度合并为一个新对象。
616
+ *
617
+ * - 后面的 source 优先级更高,会覆盖前面的同名属性
618
+ * - 双方都是纯对象的属性会递归合并,而非覆盖
619
+ * - 数组合并策略、null 处理和自定义合并函数均可配置
620
+ * - 支持 Symbol 键,防止原型污染(跳过 `__proto__` 和 `constructor`)
621
+ * - 不修改任何输入对象
622
+ *
623
+ * @category Object
624
+ * @typeParam T 合并结果的对象类型
625
+ * @param sources 要合并的源对象数组,后面的对象优先级更高
626
+ * @param options 合并行为配置项(可选)
627
+ * @returns 合并后的新对象
628
+ *
629
+ * @example
630
+ * ```ts
631
+ * const defaults = { theme: 'light', pagination: { page: 1, size: 10 } }
632
+ * const userConfig = { pagination: { size: 20 }, debug: true }
633
+ * const result = deepMerge([defaults, userConfig])
634
+ * // => { theme: 'light', pagination: { page: 1, size: 20 }, debug: true }
635
+ * ```
636
+ *
637
+ * @example
638
+ * ```ts
639
+ * // 数组去重合并
640
+ * const result = deepMerge(
641
+ * [{ tags: ['a', 'b'] }, { tags: ['b', 'c'] }],
642
+ * { arrayStrategy: 'unique' },
643
+ * )
644
+ * // => { tags: ['a', 'b', 'c'] }
645
+ * ```
646
+ */
647
+ declare function deepMerge<T extends AnyObject>(sources: T[], options?: DeepMergeOptions): T;
648
+ /**
649
+ * 创建一个预绑定配置的 deepMerge 函数。
650
+ *
651
+ * @category Object
652
+ * @param options 合并行为配置项
653
+ * @returns 预配置的 deepMerge 函数
654
+ *
655
+ * @example
656
+ * ```ts
657
+ * const mergeReplace = createDeepMerge({ arrayStrategy: 'replace' })
658
+ * const result = mergeReplace([{ tags: ['a'] }, { tags: ['b'] }])
659
+ * // => { tags: ['b'] }
660
+ * ```
661
+ */
662
+ declare function createDeepMerge(options: DeepMergeOptions): <T extends AnyObject>(sources: T[]) => T;
520
663
 
521
664
  /**
522
665
  * 从对象中排除指定的键,返回新对象
@@ -1618,6 +1761,40 @@ type Suggest<T extends string> = T | (string & {});
1618
1761
  */
1619
1762
  type ReactiveValue<T, CTX = never> = [CTX] extends [never] ? MaybeRefOrGetter<T> : MaybeRefOrGetter<T> | ((ctx: CTX) => T);
1620
1763
  type StripNullable<T> = T extends null | undefined ? never : T;
1764
+ /**
1765
+ * 检测类型 T 是否为 `any`
1766
+ *
1767
+ * 利用 `any` 会穿透类型运算的特性(`1 & any` 为 `any`,`0 extends any` 为 `true`)实现检测。
1768
+ *
1769
+ * @example
1770
+ * ```ts
1771
+ * type A = IsAny<any> // true
1772
+ * type B = IsAny<string> // false
1773
+ * type C = IsAny<never> // false
1774
+ * type D = IsAny<unknown> // false
1775
+ * ```
1776
+ */
1777
+ type IsAny<T> = 0 extends (1 & T) ? true : false;
1778
+ /**
1779
+ * 将字面量类型宽化为其对应的基础类型,同时保留可选性(`undefined`)。
1780
+ *
1781
+ * - `any` → 保持原样
1782
+ * - `undefined | never` → `unknown`
1783
+ * - `boolean` 字面量 → `boolean`
1784
+ * - `string` 字面量 → `string`
1785
+ * - 其他类型 → 保持原样
1786
+ *
1787
+ * 主要用于工厂方法的 props 推断,防止 SFC 泛型默认参数产生的字面量类型污染调用签名。
1788
+ *
1789
+ * @example
1790
+ * ```ts
1791
+ * type A = WidenLiteral<'hello'> // string
1792
+ * type B = WidenLiteral<true> // boolean
1793
+ * type C = WidenLiteral<'foo' | undefined> // string | undefined
1794
+ * type D = WidenLiteral<number> // number
1795
+ * ```
1796
+ */
1797
+ type WidenLiteral<T> = IsAny<T> extends true ? T : [NonNullable<T>] extends [never] ? unknown : NonNullable<T> extends boolean ? boolean | Extract<T, undefined> : NonNullable<T> extends string ? string | Extract<T, undefined> : T;
1621
1798
 
1622
1799
  interface ParsedUrl {
1623
1800
  /** 完整的原始 URL */
@@ -1651,35 +1828,67 @@ type QueryParamValue = string | number | boolean | null | undefined;
1651
1828
  type QueryParams = Record<string, QueryParamValue | QueryParamValue[]>;
1652
1829
 
1653
1830
  /**
1654
- * vue-component-type-helpers
1655
- * Copy from https://github.com/vuejs/language-tools/tree/master/packages/component-type-helpers
1831
+ * 增强版组件类型提取,支持泛型 SFC 的三种 vue-tsc 编译签名模式:
1832
+ * - 模式 A:函数参数可直接解析 → Parameters<T>[0]
1833
+ * - 模式 A':参数自引用(返回 any)→ 返回值 __ctx 成员
1834
+ * - 模式 B:DefineComponent 包装 → InstanceType<T>['$props']
1656
1835
  */
1657
1836
  type IsComponent = StringOrVNode | Component | DefineComponent | ((...args: any[]) => any);
1658
1837
  type ComponentType<T> = T extends new (...args: any) => {} ? 1 : T extends (...args: any) => any ? 2 : 0;
1659
- type ComponentProps<T> = T extends new (...args: any) => {
1660
- $props: infer P;
1661
- } ? NonNullable<P> : T extends (props: infer P, ...args: any) => any ? P : {};
1662
- type ComponentSlots<T> = T extends new (...args: any) => {
1663
- $slots: infer S;
1664
- } ? NonNullable<S> : T extends (props: any, ctx: {
1665
- slots: infer S;
1666
- attrs: any;
1667
- emit: any;
1668
- }, ...args: any) => any ? NonNullable<S> : {};
1669
- type ComponentAttrs<T> = T extends new (...args: any) => {
1670
- $attrs: infer A;
1671
- } ? NonNullable<A> : T extends (props: any, ctx: {
1672
- slots: any;
1673
- attrs: infer A;
1674
- emit: any;
1675
- }, ...args: any) => any ? NonNullable<A> : {};
1676
- type ComponentEmit<T> = T extends new (...args: any) => {
1677
- $emit: infer E;
1678
- } ? NonNullable<E> : T extends (props: any, ctx: {
1679
- slots: any;
1680
- attrs: any;
1681
- emit: infer E;
1682
- }, ...args: any) => any ? NonNullable<E> : {};
1838
+ /** 检测 any 类型 */
1839
+ type _IsAny<T> = 0 extends (1 & T) ? true : false;
1840
+ /** 从构造器组件提取 InstanceType 成员,映射展平避免 TS 延迟求值 */
1841
+ type _InstanceTypeMember<T, K extends string> = T extends abstract new (...args: any) => infer I ? K extends keyof I ? {
1842
+ [P in keyof I[K]]: I[K][P];
1843
+ } : never : never;
1844
+ /** 从可调用组件提取第一个参数(props),排除 any/never */
1845
+ type _FnParam<T> = T extends (...args: any) => any ? [Parameters<T>[0]] extends [never] ? never : _IsAny<Parameters<T>[0]> extends true ? never : Parameters<T>[0] : never;
1846
+ /** 从可调用组件的 ctx 参数提取指定成员(slots/attrs/emit */
1847
+ type _FnCtxMember<T, K extends string> = T extends (props: any, ctx: infer Ctx, ...args: any) => any ? Ctx extends Record<K, infer M> ? NonNullable<M> : never : never;
1848
+ /** 从返回值 __ctx 提取指定字段(模式 A':参数自引用时 __ctx 仍可解析) */
1849
+ type _ReturnCtxMember<T, K extends string> = T extends (...args: any) => infer R ? R extends {
1850
+ __ctx?: infer Ctx;
1851
+ } ? Ctx extends Record<K, infer M> ? _IsAny<M> extends true ? never : {
1852
+ [P in keyof M]: M[P];
1853
+ } : never : never : never;
1854
+ /**
1855
+ * 组件 Props 提取
1856
+ * - 模式 A → Parameters[0]
1857
+ * - 模式 A' __ctx.props
1858
+ * - 模式 B → $props
1859
+ * - 回退 {}
1860
+ */
1861
+ type ComponentProps<T> = _FnParam<T> extends never ? _ReturnCtxMember<T, 'props'> extends never ? _InstanceTypeMember<T, '$props'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$props'>> : NonNullable<_ReturnCtxMember<T, 'props'>> : _FnParam<T>;
1862
+ /**
1863
+ * 组件 Slots 提取
1864
+ * - 模式 A → ctx.slots
1865
+ * - 模式 A' → __ctx.slots
1866
+ * - 模式 B → $slots
1867
+ * - 回退 → {}
1868
+ */
1869
+ type ComponentSlots<T> = _IsAny<_FnCtxMember<T, 'slots'>> extends true ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : [_FnCtxMember<T, 'slots'>] extends [never] ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : _FnCtxMember<T, 'slots'>;
1870
+ /**
1871
+ * 组件 Attrs 提取
1872
+ * - 模式 A → ctx.attrs
1873
+ * - 模式 A' → __ctx.attrs
1874
+ * - 模式 B → $attrs
1875
+ * - 回退 → {}
1876
+ */
1877
+ type ComponentAttrs<T> = _IsAny<_FnCtxMember<T, 'attrs'>> extends true ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : [_FnCtxMember<T, 'attrs'>] extends [never] ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : _FnCtxMember<T, 'attrs'>;
1878
+ /**
1879
+ * 组件 Emit 提取
1880
+ * - 模式 A → ctx.emit
1881
+ * - 模式 A' → __ctx.emit
1882
+ * - 模式 B → $emit
1883
+ * - 回退 → {}
1884
+ */
1885
+ type ComponentEmit<T> = _IsAny<_FnCtxMember<T, 'emit'>> extends true ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : [_FnCtxMember<T, 'emit'>] extends [never] ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : _FnCtxMember<T, 'emit'>;
1886
+ /**
1887
+ * 组件 Exposed 提取
1888
+ * - 构造器 → InstanceType<T>
1889
+ * - 可调用 → expose 参数
1890
+ * - 回退 → {}
1891
+ */
1683
1892
  type ComponentExposed<T> = T extends new (...args: any) => infer E ? E : T extends (props: any, ctx: any, expose: (exposed: infer E) => any, ...args: any) => any ? NonNullable<E> : {};
1684
1893
 
1685
1894
  /**
@@ -2470,5 +2679,5 @@ declare function isString(value: any): value is string;
2470
2679
  */
2471
2680
  declare function isValidContainer(value: any): boolean;
2472
2681
 
2473
- export { Tree, appendQueryParam, buildUrl, camelCase, capitalize, chunk, convertSvgToPng, convertToKebabCase, debounce, deepClone, ensureLeadingSlash, ensureTrailingSlash, extractFilename, flatten, formatFileSize, getDomain, getPath, getQueryParam, getQueryParams, getRandomUUID, getRelativePath, getRootDomain, getUrlExtension, getUrlFilename, hasQueryParam, isAbsoluteUrl, isArray, isEmpty, isFunction, isNumber, isObject, isPlainObject, isRelativeUrl, isSameOrigin, isString, isValidContainer, isValidUrl, joinPath, joinUrl, kebabCase, lowerCase, lowerFirst, normalizeUrl, omit, omitUndefined, parseQuery, parseUrl, pascalCase, pick, removeLeadingSlash, removeQueryParam, removeTrailingSlash, replaceCurrentColor, safeDecodeURIComponent, safeEncodeURIComponent, separate, separateMany, setPath, setQueryParam, setQueryParams, simpleHash, sleep, sleepWithCancel, snakeCase, startCase, stringifyQuery, throttle, toAbsoluteUrl, toPath, triggerDownload, unique, upperCase, upperFirst, useAppStorage, useCopyCode, words };
2474
- export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsComponent, IsPlainObject, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject };
2682
+ export { Tree, appendQueryParam, buildUrl, camelCase, capitalize, chunk, convertSvgToPng, convertToKebabCase, createDeepMerge, debounce, deepClone, deepMerge, ensureLeadingSlash, ensureTrailingSlash, extractFilename, flatten, formatFileSize, getDomain, getPath, getQueryParam, getQueryParams, getRandomUUID, getRelativePath, getRootDomain, getUrlExtension, getUrlFilename, hasQueryParam, isAbsoluteUrl, isArray, isEmpty, isFunction, isNumber, isObject, isPlainObject, isRelativeUrl, isSameOrigin, isString, isValidContainer, isValidUrl, joinPath, joinUrl, kebabCase, lowerCase, lowerFirst, normalizeUrl, omit, omitUndefined, parseQuery, parseUrl, pascalCase, pick, removeLeadingSlash, removeQueryParam, removeTrailingSlash, replaceCurrentColor, safeDecodeURIComponent, safeEncodeURIComponent, separate, separateMany, setPath, setQueryParam, setQueryParams, simpleHash, sleep, sleepWithCancel, snakeCase, startCase, stringifyQuery, throttle, toAbsoluteUrl, toPath, triggerDownload, unique, upperCase, upperFirst, useAppStorage, useCopyCode, words };
2683
+ export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ArrayMergeStrategy, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, CustomMerger, DeepMerge, DeepMergeOptions, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsAny, IsComponent, IsPlainObject, KnownKeys, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, NullHandlingStrategy, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, Prettify, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject, WidenLiteral };
package/dist/index.d.ts CHANGED
@@ -295,6 +295,27 @@ type IsPlainObject<T> = NonNullable<T> extends Record<string, any> ? NonNullable
295
295
  type DeepPartial<T> = {
296
296
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] | undefined;
297
297
  };
298
+ /** 递归深度计数器,用于限制类型递归层数 */
299
+ type MergeDepth = [never, 0, 1, 2, 3, 4];
300
+ /**
301
+ * 递归合并两个对象类型,`U` 中的属性优先级高于 `T`。
302
+ * 仅对双方都是纯对象的属性做深度递归,其余类型直接取 `U` 的值。
303
+ *
304
+ * @typeParam T - 基础对象类型
305
+ * @typeParam U - 覆盖对象类型
306
+ * @typeParam D - 递归深度限制,默认为 4
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * type A = { a: { b: number; c: string }; d: boolean }
311
+ * type B = { a: { b: string; e: number }; f: Date }
312
+ * type R = DeepMerge<A, B>
313
+ * // { a: { b: string; c: string; e: number }; d: boolean; f: Date }
314
+ * ```
315
+ */
316
+ type DeepMerge<T, U, D extends number = 4> = [D] extends [never] ? T & U : {
317
+ [K in keyof T | keyof U]: K extends keyof U ? K extends keyof T ? IsPlainObject<T[K]> extends true ? IsPlainObject<U[K]> extends true ? DeepMerge<NonNullable<T[K]>, NonNullable<U[K]>, MergeDepth[D]> : U[K] : U[K] : U[K] : K extends keyof T ? T[K] : never;
318
+ };
298
319
 
299
320
  /**
300
321
  * 深度控制类型,用于限制类型递归的深度
@@ -517,6 +538,128 @@ type FirstParam<T, K extends keyof T> = T[K] extends [infer P, ...any[]] ? P : n
517
538
  * // 结果: R 为 number; 若 T 非函数,则为 undefined
518
539
  */
519
540
  type FirstParameter<T> = T extends (arg: infer P, ...args: any[]) => any ? P : undefined;
541
+ /**
542
+ * 强制 TypeScript 展平类型别名,使 IntelliSense 能完整枚举对象的所有属性。
543
+ *
544
+ * 常用于消除交叉类型(`A & B`)的「折叠」显示,让 IDE 悬停时直接展示合并后的属性列表。
545
+ *
546
+ * @typeParam T - 要展平的对象类型
547
+ * @example
548
+ * ```ts
549
+ * type A = { a: number } & { b: string }
550
+ * // IDE hover 显示 "{ a: number } & { b: string }"
551
+ *
552
+ * type B = Prettify<A>
553
+ * // IDE hover 显示 "{ a: number; b: string }"
554
+ * ```
555
+ */
556
+ type Prettify<T> = {
557
+ [K in keyof T]: T[K];
558
+ } & {};
559
+ /**
560
+ * 从对象类型中提取所有字面量键,过滤掉索引签名(`string`、`number`、`symbol`)。
561
+ *
562
+ * 用于需要精确枚举已知属性而不被索引签名污染 IntelliSense 的场景。
563
+ *
564
+ * @typeParam T - 可能含索引签名的对象类型
565
+ * @example
566
+ * ```ts
567
+ * interface Config {
568
+ * debug: boolean
569
+ * timeout: number
570
+ * [key: string]: unknown
571
+ * }
572
+ * // K = 'debug' | 'timeout'(索引签名 string 被过滤掉)
573
+ * type K = KnownKeys<Config>
574
+ * ```
575
+ */
576
+ type KnownKeys<T> = {
577
+ [K in keyof T]-?: string extends K ? never : number extends K ? never : symbol extends K ? never : K;
578
+ }[keyof T];
579
+
580
+ /**
581
+ * 数组合并策略
582
+ * - `'concat'` : 将 source 数组拼接在 target 数组之后(默认)
583
+ * - `'replace'` : 用 source 数组整体替换 target 数组
584
+ * - `'unique'` : 拼接后去重(基于 SameValueZero 比较)
585
+ */
586
+ type ArrayMergeStrategy = 'concat' | 'replace' | 'unique';
587
+ /**
588
+ * null/undefined 处理策略
589
+ * - `'skip'` : 忽略 source 中的 null/undefined,保留 target 中的值(默认)
590
+ * - `'override'` : 允许 source 中的 null/undefined 覆盖 target 中的值
591
+ */
592
+ type NullHandlingStrategy = 'skip' | 'override';
593
+ /**
594
+ * 自定义合并函数。
595
+ *
596
+ * @param key 当前正在处理的键(string 或 Symbol)
597
+ * @param targetVal target 中该键的当前值
598
+ * @param sourceVal source 中该键的值
599
+ * @param path 从根对象到当前层级的键路径
600
+ * @returns 返回合并结果;返回 `undefined` 则交由默认逻辑处理
601
+ */
602
+ type CustomMerger = (key: string | symbol, targetVal: unknown, sourceVal: unknown, path: ReadonlyArray<string | symbol>) => unknown;
603
+ /**
604
+ * deepMerge 配置选项
605
+ */
606
+ interface DeepMergeOptions {
607
+ /** 数组合并策略,默认 `'concat'` */
608
+ arrayStrategy?: ArrayMergeStrategy;
609
+ /** null/undefined 处理策略,默认 `'skip'` */
610
+ nullHandling?: NullHandlingStrategy;
611
+ /** 自定义合并函数,返回 `undefined` 则交由默认逻辑处理 */
612
+ customMerger?: CustomMerger;
613
+ }
614
+ /**
615
+ * 递归地将多个 source 对象深度合并为一个新对象。
616
+ *
617
+ * - 后面的 source 优先级更高,会覆盖前面的同名属性
618
+ * - 双方都是纯对象的属性会递归合并,而非覆盖
619
+ * - 数组合并策略、null 处理和自定义合并函数均可配置
620
+ * - 支持 Symbol 键,防止原型污染(跳过 `__proto__` 和 `constructor`)
621
+ * - 不修改任何输入对象
622
+ *
623
+ * @category Object
624
+ * @typeParam T 合并结果的对象类型
625
+ * @param sources 要合并的源对象数组,后面的对象优先级更高
626
+ * @param options 合并行为配置项(可选)
627
+ * @returns 合并后的新对象
628
+ *
629
+ * @example
630
+ * ```ts
631
+ * const defaults = { theme: 'light', pagination: { page: 1, size: 10 } }
632
+ * const userConfig = { pagination: { size: 20 }, debug: true }
633
+ * const result = deepMerge([defaults, userConfig])
634
+ * // => { theme: 'light', pagination: { page: 1, size: 20 }, debug: true }
635
+ * ```
636
+ *
637
+ * @example
638
+ * ```ts
639
+ * // 数组去重合并
640
+ * const result = deepMerge(
641
+ * [{ tags: ['a', 'b'] }, { tags: ['b', 'c'] }],
642
+ * { arrayStrategy: 'unique' },
643
+ * )
644
+ * // => { tags: ['a', 'b', 'c'] }
645
+ * ```
646
+ */
647
+ declare function deepMerge<T extends AnyObject>(sources: T[], options?: DeepMergeOptions): T;
648
+ /**
649
+ * 创建一个预绑定配置的 deepMerge 函数。
650
+ *
651
+ * @category Object
652
+ * @param options 合并行为配置项
653
+ * @returns 预配置的 deepMerge 函数
654
+ *
655
+ * @example
656
+ * ```ts
657
+ * const mergeReplace = createDeepMerge({ arrayStrategy: 'replace' })
658
+ * const result = mergeReplace([{ tags: ['a'] }, { tags: ['b'] }])
659
+ * // => { tags: ['b'] }
660
+ * ```
661
+ */
662
+ declare function createDeepMerge(options: DeepMergeOptions): <T extends AnyObject>(sources: T[]) => T;
520
663
 
521
664
  /**
522
665
  * 从对象中排除指定的键,返回新对象
@@ -1618,6 +1761,40 @@ type Suggest<T extends string> = T | (string & {});
1618
1761
  */
1619
1762
  type ReactiveValue<T, CTX = never> = [CTX] extends [never] ? MaybeRefOrGetter<T> : MaybeRefOrGetter<T> | ((ctx: CTX) => T);
1620
1763
  type StripNullable<T> = T extends null | undefined ? never : T;
1764
+ /**
1765
+ * 检测类型 T 是否为 `any`
1766
+ *
1767
+ * 利用 `any` 会穿透类型运算的特性(`1 & any` 为 `any`,`0 extends any` 为 `true`)实现检测。
1768
+ *
1769
+ * @example
1770
+ * ```ts
1771
+ * type A = IsAny<any> // true
1772
+ * type B = IsAny<string> // false
1773
+ * type C = IsAny<never> // false
1774
+ * type D = IsAny<unknown> // false
1775
+ * ```
1776
+ */
1777
+ type IsAny<T> = 0 extends (1 & T) ? true : false;
1778
+ /**
1779
+ * 将字面量类型宽化为其对应的基础类型,同时保留可选性(`undefined`)。
1780
+ *
1781
+ * - `any` → 保持原样
1782
+ * - `undefined | never` → `unknown`
1783
+ * - `boolean` 字面量 → `boolean`
1784
+ * - `string` 字面量 → `string`
1785
+ * - 其他类型 → 保持原样
1786
+ *
1787
+ * 主要用于工厂方法的 props 推断,防止 SFC 泛型默认参数产生的字面量类型污染调用签名。
1788
+ *
1789
+ * @example
1790
+ * ```ts
1791
+ * type A = WidenLiteral<'hello'> // string
1792
+ * type B = WidenLiteral<true> // boolean
1793
+ * type C = WidenLiteral<'foo' | undefined> // string | undefined
1794
+ * type D = WidenLiteral<number> // number
1795
+ * ```
1796
+ */
1797
+ type WidenLiteral<T> = IsAny<T> extends true ? T : [NonNullable<T>] extends [never] ? unknown : NonNullable<T> extends boolean ? boolean | Extract<T, undefined> : NonNullable<T> extends string ? string | Extract<T, undefined> : T;
1621
1798
 
1622
1799
  interface ParsedUrl {
1623
1800
  /** 完整的原始 URL */
@@ -1651,35 +1828,67 @@ type QueryParamValue = string | number | boolean | null | undefined;
1651
1828
  type QueryParams = Record<string, QueryParamValue | QueryParamValue[]>;
1652
1829
 
1653
1830
  /**
1654
- * vue-component-type-helpers
1655
- * Copy from https://github.com/vuejs/language-tools/tree/master/packages/component-type-helpers
1831
+ * 增强版组件类型提取,支持泛型 SFC 的三种 vue-tsc 编译签名模式:
1832
+ * - 模式 A:函数参数可直接解析 → Parameters<T>[0]
1833
+ * - 模式 A':参数自引用(返回 any)→ 返回值 __ctx 成员
1834
+ * - 模式 B:DefineComponent 包装 → InstanceType<T>['$props']
1656
1835
  */
1657
1836
  type IsComponent = StringOrVNode | Component | DefineComponent | ((...args: any[]) => any);
1658
1837
  type ComponentType<T> = T extends new (...args: any) => {} ? 1 : T extends (...args: any) => any ? 2 : 0;
1659
- type ComponentProps<T> = T extends new (...args: any) => {
1660
- $props: infer P;
1661
- } ? NonNullable<P> : T extends (props: infer P, ...args: any) => any ? P : {};
1662
- type ComponentSlots<T> = T extends new (...args: any) => {
1663
- $slots: infer S;
1664
- } ? NonNullable<S> : T extends (props: any, ctx: {
1665
- slots: infer S;
1666
- attrs: any;
1667
- emit: any;
1668
- }, ...args: any) => any ? NonNullable<S> : {};
1669
- type ComponentAttrs<T> = T extends new (...args: any) => {
1670
- $attrs: infer A;
1671
- } ? NonNullable<A> : T extends (props: any, ctx: {
1672
- slots: any;
1673
- attrs: infer A;
1674
- emit: any;
1675
- }, ...args: any) => any ? NonNullable<A> : {};
1676
- type ComponentEmit<T> = T extends new (...args: any) => {
1677
- $emit: infer E;
1678
- } ? NonNullable<E> : T extends (props: any, ctx: {
1679
- slots: any;
1680
- attrs: any;
1681
- emit: infer E;
1682
- }, ...args: any) => any ? NonNullable<E> : {};
1838
+ /** 检测 any 类型 */
1839
+ type _IsAny<T> = 0 extends (1 & T) ? true : false;
1840
+ /** 从构造器组件提取 InstanceType 成员,映射展平避免 TS 延迟求值 */
1841
+ type _InstanceTypeMember<T, K extends string> = T extends abstract new (...args: any) => infer I ? K extends keyof I ? {
1842
+ [P in keyof I[K]]: I[K][P];
1843
+ } : never : never;
1844
+ /** 从可调用组件提取第一个参数(props),排除 any/never */
1845
+ type _FnParam<T> = T extends (...args: any) => any ? [Parameters<T>[0]] extends [never] ? never : _IsAny<Parameters<T>[0]> extends true ? never : Parameters<T>[0] : never;
1846
+ /** 从可调用组件的 ctx 参数提取指定成员(slots/attrs/emit */
1847
+ type _FnCtxMember<T, K extends string> = T extends (props: any, ctx: infer Ctx, ...args: any) => any ? Ctx extends Record<K, infer M> ? NonNullable<M> : never : never;
1848
+ /** 从返回值 __ctx 提取指定字段(模式 A':参数自引用时 __ctx 仍可解析) */
1849
+ type _ReturnCtxMember<T, K extends string> = T extends (...args: any) => infer R ? R extends {
1850
+ __ctx?: infer Ctx;
1851
+ } ? Ctx extends Record<K, infer M> ? _IsAny<M> extends true ? never : {
1852
+ [P in keyof M]: M[P];
1853
+ } : never : never : never;
1854
+ /**
1855
+ * 组件 Props 提取
1856
+ * - 模式 A → Parameters[0]
1857
+ * - 模式 A' __ctx.props
1858
+ * - 模式 B → $props
1859
+ * - 回退 {}
1860
+ */
1861
+ type ComponentProps<T> = _FnParam<T> extends never ? _ReturnCtxMember<T, 'props'> extends never ? _InstanceTypeMember<T, '$props'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$props'>> : NonNullable<_ReturnCtxMember<T, 'props'>> : _FnParam<T>;
1862
+ /**
1863
+ * 组件 Slots 提取
1864
+ * - 模式 A → ctx.slots
1865
+ * - 模式 A' → __ctx.slots
1866
+ * - 模式 B → $slots
1867
+ * - 回退 → {}
1868
+ */
1869
+ type ComponentSlots<T> = _IsAny<_FnCtxMember<T, 'slots'>> extends true ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : [_FnCtxMember<T, 'slots'>] extends [never] ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : _FnCtxMember<T, 'slots'>;
1870
+ /**
1871
+ * 组件 Attrs 提取
1872
+ * - 模式 A → ctx.attrs
1873
+ * - 模式 A' → __ctx.attrs
1874
+ * - 模式 B → $attrs
1875
+ * - 回退 → {}
1876
+ */
1877
+ type ComponentAttrs<T> = _IsAny<_FnCtxMember<T, 'attrs'>> extends true ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : [_FnCtxMember<T, 'attrs'>] extends [never] ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : _FnCtxMember<T, 'attrs'>;
1878
+ /**
1879
+ * 组件 Emit 提取
1880
+ * - 模式 A → ctx.emit
1881
+ * - 模式 A' → __ctx.emit
1882
+ * - 模式 B → $emit
1883
+ * - 回退 → {}
1884
+ */
1885
+ type ComponentEmit<T> = _IsAny<_FnCtxMember<T, 'emit'>> extends true ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : [_FnCtxMember<T, 'emit'>] extends [never] ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : _FnCtxMember<T, 'emit'>;
1886
+ /**
1887
+ * 组件 Exposed 提取
1888
+ * - 构造器 → InstanceType<T>
1889
+ * - 可调用 → expose 参数
1890
+ * - 回退 → {}
1891
+ */
1683
1892
  type ComponentExposed<T> = T extends new (...args: any) => infer E ? E : T extends (props: any, ctx: any, expose: (exposed: infer E) => any, ...args: any) => any ? NonNullable<E> : {};
1684
1893
 
1685
1894
  /**
@@ -2470,5 +2679,5 @@ declare function isString(value: any): value is string;
2470
2679
  */
2471
2680
  declare function isValidContainer(value: any): boolean;
2472
2681
 
2473
- export { Tree, appendQueryParam, buildUrl, camelCase, capitalize, chunk, convertSvgToPng, convertToKebabCase, debounce, deepClone, ensureLeadingSlash, ensureTrailingSlash, extractFilename, flatten, formatFileSize, getDomain, getPath, getQueryParam, getQueryParams, getRandomUUID, getRelativePath, getRootDomain, getUrlExtension, getUrlFilename, hasQueryParam, isAbsoluteUrl, isArray, isEmpty, isFunction, isNumber, isObject, isPlainObject, isRelativeUrl, isSameOrigin, isString, isValidContainer, isValidUrl, joinPath, joinUrl, kebabCase, lowerCase, lowerFirst, normalizeUrl, omit, omitUndefined, parseQuery, parseUrl, pascalCase, pick, removeLeadingSlash, removeQueryParam, removeTrailingSlash, replaceCurrentColor, safeDecodeURIComponent, safeEncodeURIComponent, separate, separateMany, setPath, setQueryParam, setQueryParams, simpleHash, sleep, sleepWithCancel, snakeCase, startCase, stringifyQuery, throttle, toAbsoluteUrl, toPath, triggerDownload, unique, upperCase, upperFirst, useAppStorage, useCopyCode, words };
2474
- export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsComponent, IsPlainObject, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject };
2682
+ export { Tree, appendQueryParam, buildUrl, camelCase, capitalize, chunk, convertSvgToPng, convertToKebabCase, createDeepMerge, debounce, deepClone, deepMerge, ensureLeadingSlash, ensureTrailingSlash, extractFilename, flatten, formatFileSize, getDomain, getPath, getQueryParam, getQueryParams, getRandomUUID, getRelativePath, getRootDomain, getUrlExtension, getUrlFilename, hasQueryParam, isAbsoluteUrl, isArray, isEmpty, isFunction, isNumber, isObject, isPlainObject, isRelativeUrl, isSameOrigin, isString, isValidContainer, isValidUrl, joinPath, joinUrl, kebabCase, lowerCase, lowerFirst, normalizeUrl, omit, omitUndefined, parseQuery, parseUrl, pascalCase, pick, removeLeadingSlash, removeQueryParam, removeTrailingSlash, replaceCurrentColor, safeDecodeURIComponent, safeEncodeURIComponent, separate, separateMany, setPath, setQueryParam, setQueryParams, simpleHash, sleep, sleepWithCancel, snakeCase, startCase, stringifyQuery, throttle, toAbsoluteUrl, toPath, triggerDownload, unique, upperCase, upperFirst, useAppStorage, useCopyCode, words };
2683
+ export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ArrayMergeStrategy, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, CustomMerger, DeepMerge, DeepMergeOptions, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsAny, IsComponent, IsPlainObject, KnownKeys, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, NullHandlingStrategy, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, Prettify, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject, WidenLiteral };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{useStorage as Q}from"@vueuse/core";function Z(e){const{key:n,defaultValue:r,storage:t="localStorage",prefix:i="movk"}=e,o=`${i}:${n}`,a=(()=>{if(!(typeof window>"u"))return t==="localStorage"?localStorage:sessionStorage})();function s(f){if(f===null)return r;try{return JSON.parse(f)}catch(p){return console.warn(`[AppStorage] Failed to parse value for key "${o}". Using default value.`,p),r}}const c=Q(o,r,a,{mergeDefaults:!0,serializer:{read:s,write:f=>JSON.stringify(f)}});function u(){if(!a)return r;const f=a.getItem(o);return s(f)}function l(f){c.value=f}function h(){a&&(c.value=null)}return{state:c,getItem:u,setItem:l,removeItem:h}}async function q(e){if(typeof e!="string")throw new TypeError("Text must be a string");if(typeof window>"u")return console.warn("useCopyCode: Not available in server environment"),!1;if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(e),!0}catch(n){console.warn("Clipboard API failed, falling back to legacy method:",n)}try{return K(e)}catch(n){return console.error("Failed to copy text:",n),!1}}function K(e){if(typeof document>"u")return console.warn("copyTextLegacy: Document not available"),!1;const n=document.createElement("textarea"),r=document.activeElement,t=document.getSelection(),i=t&&t.rangeCount>0?t.getRangeAt(0):null;try{return n.value=e,n.setAttribute("readonly",""),n.setAttribute("contenteditable","true"),Object.assign(n.style,{contain:"strict",position:"absolute",left:"-9999px",top:"-9999px",fontSize:"12pt",border:"0",padding:"0",margin:"0",outline:"none",boxShadow:"none",background:"transparent"}),document.body.appendChild(n),n.focus(),n.select(),n.setSelectionRange&&n.setSelectionRange(0,e.length),document.execCommand("copy")}catch(o){return console.error("Legacy copy method failed:",o),!1}finally{n.parentNode&&document.body.removeChild(n),i&&t&&(t.removeAllRanges(),t.addRange(i)),r instanceof HTMLElement&&r.focus()}}async function _(e){if(!e||typeof e!="string")throw new Error("Invalid SVG string provided");if(typeof window>"u"||typeof document>"u")throw new TypeError("convertSvgToPng is only available in browser environment");return new Promise((n,r)=>{const t=new Image,i=document.createElement("canvas"),o=i.getContext("2d");if(!o){r(new Error("Canvas context not available"));return}t.onload=()=>{try{i.width=t.width,i.height=t.height,o.drawImage(t,0,0),i.toBlob(a=>{a?n(a):r(new Error("Failed to convert canvas to Blob"))},"image/png")}catch(a){r(new Error(`Error during canvas conversion: ${a}`))}},t.onerror=()=>{r(new Error("Failed to load SVG image"))};try{t.src=`data:image/svg+xml;base64,${btoa(e)}`}catch(a){r(new Error(`Failed to encode SVG: ${a}`))}})}function H(e,n="file"){if(!e)return n;const r=e.get("content-disposition");if(r){const t=r.match(/filename\*?=(?:"([^"]+)"|([^;]+))/i);if(t){let i=t[1]??t[2];if(!i)return n;if(i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1)),r.includes("filename*=")){const o=i.split("''");if(o.length===2&&o[1])try{i=decodeURIComponent(o[1])}catch{return n}}return i}}return n}function J(e){if(!Number.isFinite(e)||e<0||e===0)return"0 Bytes";const n=1024,r=["Bytes","KB","MB","GB","TB","PB"],t=Math.floor(Math.log(e)/Math.log(n));return t>=r.length?`${Number.parseFloat((e/n**(r.length-1)).toFixed(2))} ${r[r.length-1]}`:`${Number.parseFloat((e/n**t).toFixed(2))} ${r[t]}`}async function X(e,n){if(!e||typeof e!="string")throw new Error("Invalid SVG path provided");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch SVG file: ${r.status} ${r.statusText}`);const t=await r.text();if(!n)return t;if(typeof window>"u"||typeof DOMParser>"u")return console.warn("replaceCurrentColor: DOM manipulation not available in server environment, returning original SVG"),t;const i=new DOMParser().parseFromString(t,"image/svg+xml");if(i.querySelector("parsererror"))throw new Error("Invalid SVG content");const o=i.querySelector("svg");if(!o)throw new Error("No SVG element found in the document");o.hasAttribute("fill")||o.setAttribute("fill","currentColor");const a=s=>{s.getAttribute("fill")==="currentColor"&&s.setAttribute("fill",n),s.getAttribute("stroke")==="currentColor"&&s.setAttribute("stroke",n),Array.from(s.children).forEach(c=>{a(c)})};return a(o),new XMLSerializer().serializeToString(i)}catch(r){throw r instanceof Error?r:new Error(`Unexpected error occurred: ${r}`)}}function Y(e,n){if(typeof window>"u"||typeof document>"u"){console.warn("triggerDownload: Not available in server environment");return}const r=URL.createObjectURL(e),t=document.createElement("a");t.href=r,t.download=n,t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(r)}function w(e,n=new WeakMap){if(e===null||typeof e!="object")return e;try{const s=globalThis.structuredClone;if(typeof s=="function")return s(e)}catch(s){console.error("Error occurred while cloning:",s)}const r=e,t=n.get(r);if(t)return t;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const s=new Map;n.set(r,s);for(const[c,u]of e.entries())s.set(w(c,n),w(u,n));return s}if(e instanceof Set){const s=new Set;n.set(r,s);for(const c of e.values())s.add(w(c,n));return s}if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e)){const s=e.constructor;return new s(e)}if(e instanceof URL)return new URL(e.toString());if(e instanceof Error){const s=new e.constructor(e.message);return s.name=e.name,s.stack=e.stack,s}if(Array.isArray(e)){const s=[];n.set(r,s);for(const c of e)s.push(w(c,n));return s}const i=Object.getPrototypeOf(e),o=Object.create(i);n.set(r,o);const a=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of a){const c=Object.getOwnPropertyDescriptor(e,s);c&&("value"in c&&(c.value=w(e[s],n)),Object.defineProperty(o,s,c))}return o}function ee(e,n){if(!e||typeof e!="object")return{};const r=new Set(n),t={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&!r.has(i)&&(t[i]=e[i]);return t}function te(e){return!e||typeof e!="object"||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function ne(e,n){if(!e||typeof e!="object")return{};const r={};for(const t of n)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r}function re(e,n){if(!e||typeof e!="object")return{picked:{},omitted:{}};if(n.length===0)return{picked:{},omitted:{...e}};const r=new Set(n),t={},i={};for(const o in e)if(Object.hasOwn(e,o)){const a=o;r.has(a)?t[o]=e[a]:i[o]=e[a]}return{picked:t,omitted:i}}function oe(e,n){if(!e||typeof e!="object")return{...Object.fromEntries(Object.keys(n).map(o=>[o,{}])),others:{}};const r=Object.keys(n),t=new Map;for(const o of r){const a=new Set(n[o]);t.set(o,a)}const i=Object.create(null);for(const o of r)i[o]={};i.others={};for(const o in e)if(Object.hasOwn(e,o)){const a=o;let s=!1;for(const c of r)if(t.get(c).has(a)){i[c][o]=e[a],s=!0;break}s||(i.others[o]=e[a])}return i}function S(e){if(Array.isArray(e))return e.slice();const n=[];if(e==="")return n;let r=0;const t=e,i=t.length;function o(s){let c="",u=s;for(;u<i;){const l=t.charCodeAt(u);if(l===46)break;if(l===92){u++,u<i&&(c+=t[u]),u++;continue}if(l===91)break;c+=t[u],u++}return{value:c,next:u}}function a(s){let c=s+1;for(;c<i&&/\s/.test(t[c]);)c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const u=t[c];if(u==='"'||u==="'"){const f=u;c++;let p="",d=!1;for(;c<i;){if(t.charCodeAt(c)===92){c++,c<i&&(p+=t[c]),c++;continue}if(t[c]===f){d=!0,c++;break}p+=t[c],c++}if(!d)throw new Error("Invalid path: missing closing quote in bracket");for(;c<i&&/\s/.test(t[c]);)c++;if(c>=i||t[c]!=="]")throw new Error('Invalid path: missing closing "]"');return c++,{segment:p,next:c}}let l="";for(;c<i&&t[c]!=="]";)l+=t[c],c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const h=l.trim();return/^(?:0|[1-9]\d*)$/.test(h)?(c++,{segment:Number(h),next:c}):(c++,{segment:h,next:c})}for(;r<i;){const s=t.charCodeAt(r);if(s===46){r++;continue}if(s===91){const{segment:l,next:h}=a(r);l!==null&&n.push(l),r=h;continue}const{value:c,next:u}=o(r);(c.length>0||u<i&&t[u]===".")&&n.push(c),r=u}return n}function ie(e,n,r){const t=S(n);if(t.length===0)return e;let i=e;for(let o=0;o<t.length;o++){if(i==null)return r;const a=t[o];i=i[a]}return i===void 0?r:i}function se(e){let n="";for(let r=0;r<e.length;r++){const t=e[r];if(typeof t=="number"&&Number.isInteger(t)&&t>=0){n+=`[${t}]`;continue}const i=String(t),o=/^[A-Z_$][\w$]*$/i.test(i);if(n.length===0&&o){n+=i;continue}if(o){n+=`.${i}`;continue}const a=i.replace(/\\/g,"\\\\").replace(/'/g,"\\'");n+=`['${a}']`}return n}function O(e){return e!==null&&typeof e=="object"}function ce(e,n,r){const t=S(n);if(t.length===0)return e;let i=e;for(let o=0;o<t.length;o++){const a=t[o];if(o===t.length-1){i[a]=r;break}const s=t[o+1];let c=i[a];const u=typeof s=="number";if(O(c)?u&&!Array.isArray(c)&&(c=[],i[a]=c):(c=u?[]:{},i[a]=c),u&&Array.isArray(c)){const l=Number(s);Number.isInteger(l)&&l>=0&&c.length<=l&&(c.length=l+1)}i=c}return e}function ae(e){let n=0;for(let r=0;r<e.length;r++){const t=e.charCodeAt(r);n=(n<<5)-n+t,n=n&n}return Math.abs(n).toString(36)}function ue(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const n=Math.random()*16|0;return(e==="x"?n:n&3|8).toString(16)})}function R(e,n=!1){if(!e||typeof e!="object"||Array.isArray(e))return e;const r=i=>i.replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase(),t={};for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const o=r(i),a=e[i];n&&a&&typeof a=="object"&&!Array.isArray(a)?t[o]=R(a,!0):t[o]=a}return t}function $(e){return e?e.replace(/[_-]/g," ").match(/[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|\d+/g)||[]:[]}function b(e,n){if(!e)return"";const r=$(e);return r.length===0?"":r.map((t,i)=>{const o=t.toLowerCase(),a=t.toUpperCase();if(n.transform)return n.transform(t,i,o,a);switch(n.casing){case"lower":return o;case"upper":return a;case"capitalize":return o.charAt(0).toUpperCase()+o.slice(1);default:return t}}).join(n.separator??"")}function k(e,n){if(!e)return"";const r=e.charAt(0);return(n?r.toUpperCase():r.toLowerCase())+e.slice(1)}function le(e){return b(e,{separator:"",transform:(n,r,t)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)})}function fe(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():""}function he(e){return b(e,{separator:"-",casing:"lower"})}function pe(e){return b(e,{separator:" ",casing:"lower"})}function de(e){return k(e,!1)}function ge(e){return b(e,{separator:"",casing:"capitalize"})}function me(e){return b(e,{separator:"_",casing:"lower"})}function ye(e){return e?$(e).map(n=>n.toUpperCase()===n&&n.length>1?n:n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function we(e){return b(e,{separator:" ",casing:"upper"})}function be(e){return k(e,!0)}const U={id:"id",pid:"pid",children:"children"};function g(e={}){return{id:e.id??U.id,pid:e.pid??U.pid,children:e.children??U.children}}function*v(e,n={},r=[]){const{children:t}=g(n);let i=0;for(const o of e){const a=[...r,o];yield{node:o,path:a,depth:r.length,index:i++};const s=o[t];s&&s.length>0&&(yield*v(s,n,a))}}function*E(e,n={}){const{children:r}=g(n),t=e.map((o,a)=>({node:o,path:[o],depth:0,index:a}));let i=e.length;for(;t.length>0;){const o=t.shift();yield o;const a=o.node[r];a&&a.length>0&&a.forEach(s=>{const c=[...o.path,s];t.push({node:s,path:c,depth:o.depth+1,index:i++})})}}function j(e){switch(e){case"find":case"findAll":case"filter":case"transform":case"forEach":case"stats":case"validate":return"dfs";default:return"dfs"}}function Ae(e,n={}){const{id:r,pid:t,children:i}=g(n);if(!Array.isArray(e)||e.length===0)return[];const o=new Map,a=[];return e.forEach(s=>{const{[i]:c,...u}=s,l={...u,[i]:[]};o.set(s[r],l)}),e.forEach(s=>{const c=o.get(s[r]),u=s[t];u&&o.has(u)?o.get(u)[i].push(c):a.push(c)}),a}function xe(e,n={}){const{children:r}=g(n),t=[],i=Array.isArray(e)?e:[e],o=a=>{const{[r]:s,...c}=a;t.push(c),s&&s.length>0&&s.forEach(o)};return i.forEach(o),t}function ve(e,n={}){const{children:r}=g(n),t=Array.isArray(e)?e:[e];let i=0;const o=a=>{i++;const s=a[r];s&&s.length>0&&s.forEach(o)};return t.forEach(o),i}function Ce(e,n,r,t={}){const{id:i,children:o}=g(t),{[o]:a,...s}=r,c={...s,[o]:[]},u=(l,h)=>{for(let f=0;f<l.length;f++){const p=l[f];if(!p)continue;if(p[i]===n)return l.splice(f,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...h,p];if(u(d,y))return!0}}return!1};return u(e,[])}function Se(e,n,r,t={}){const{id:i,children:o}=g(t),{[o]:a,...s}=r,c={...s,[o]:[]},u=(l,h)=>{for(let f=0;f<l.length;f++){const p=l[f];if(!p)continue;if(p[i]===n)return l.splice(f+1,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...h,p];if(u(d,y))return!0}}return!1};return u(e,[])}function $e(e,n,r={}){const{id:t,children:i}=g(r),o=a=>{for(let s=0;s<a.length;s++){const c=a[s];if(!c)continue;if(c[t]===n)return a.splice(s,1)[0];const u=c[i];if(u&&u.length>0){const l=o(u);if(l)return l}}};return o(e)}function I(e,n,r={}){const t=Array.isArray(e)?e:[e],i=j("find")==="dfs"?v(t,r):E(t,r);for(const o of i)if(n({node:o.node,depth:o.depth,path:o.path,index:o.index}))return o.node}function Ue(e,n,r={}){const t=Array.isArray(e)?e:[e],i=j("findAll"),o=[],a=i==="dfs"?v(t,r):E(t,r);for(const s of a)n({node:s.node,depth:s.depth,path:s.path,index:s.index})&&o.push(s.node);return o}function Ee(e,n,r={}){const{id:t}=g(r);return I(e,({node:i})=>i[t]===n,r)}function je(e,n,r={}){const{children:t}=g(r),i=Array.isArray(e)?e:[e],o=[],a=(s,c,u,l=0)=>{const h=s[t],f=[];if(h&&h.length>0){const p=[...u,s];h.forEach((d,y)=>{const x=a(d,c+1,p,y);x&&f.push(x)})}if(n({node:s,depth:c,path:u,index:l})||f.length>0){const{[t]:p,...d}=s;return{...d,[t]:f}}return null};return i.forEach((s,c)=>{const u=a(s,0,[s],c);u&&o.push(u)}),o}function Oe(e,n,r={}){const{children:t}=g(r),i=Array.isArray(e)?e:[e],o=[],a=(s,c,u,l=0)=>{const h=s[t],f=[];if(h&&h.length>0){const x=[...u,s];h.forEach((V,G)=>{f.push(a(V,c+1,x,G))})}const p=n({node:s,depth:c,path:u,index:l}),{[t]:d,...y}=p;return{...y,[t]:f}};return i.forEach((s,c)=>{o.push(a(s,0,[s],c))}),o}function Re(e,n,r={}){const t=Array.isArray(e)?e:[e],i=j("forEach")==="dfs"?v(t,r):E(t,r);for(const o of i)if(n({node:o.node,depth:o.depth,path:o.path,index:o.index})===!1)break}function ke(e,n={}){const{children:r}=g(n),t=Array.isArray(e)?e:[e];let i=0,o=0,a=0,s=0;const c=(u,l)=>{i++,a=Math.max(a,l);const h=u[r];h&&h.length>0?(s++,h.forEach(f=>c(f,l+1))):o++};return t.forEach(u=>c(u,1)),{total:i,leaves:o,depth:a,branches:s}}function Ie(e,n={}){const{id:r,children:t}=g(n),i=Array.isArray(e)?e:[e],o=[],a=new Set,s=(c,u,l)=>{const h=c[r];if(!h||typeof h!="string"){o.push(`Node at depth ${u} has invalid or missing ID`);return}if(a.has(h)){o.push(`Duplicate ID found: ${h}`);return}if(a.add(h),l.some(p=>p[r]===h)){o.push(`Circular reference detected for ID: ${h}`);return}const f=c[t];if(f!==void 0&&!Array.isArray(f)){o.push(`Node ${h} has invalid children property (not an array)`);return}if(f&&f.length>0){const p=[...l,c];f.forEach(d=>{s(d,u+1,p)})}};return i.forEach(c=>s(c,0,[])),{isValid:o.length===0,errors:o}}class Pe{static fromList=Ae;static toList=xe;static estimateSize=ve;static find=I;static findAll=Ue;static findById=Ee;static insertBefore=Ce;static insertAfter=Se;static remove=$e;static filter=je;static transform=Oe;static forEach=Re;static getStats=ke;static validate=Ie}function Le(e,n){const r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function Te(e,n=1){return n===1?e.flat():e.flat(n)}function Ne(e){return[...new Set(e)]}function Fe(e,n){let r;return(...t)=>{clearTimeout(r),r=setTimeout(()=>e(...t),n)}}function Me(e){return new Promise(n=>setTimeout(n,e))}function ze(e){let n,r;return{promise:new Promise((t,i)=>{r=i,n=setTimeout(t,e)}),cancel:()=>{clearTimeout(n),r(new Error("Sleep was cancelled"))}}}function Be(e,n){let r=!1;return function(...t){r||(e.apply(this,t),r=!0,setTimeout(()=>{r=!1},n))}}function m(e,n){if(!e)return null;try{const r=n?new URL(e,n):new URL(e);return{href:r.href,protocol:r.protocol,host:r.host,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search,hash:r.hash,auth:r.username?`${r.username}${r.password?`:${r.password}`:""}`:"",origin:r.origin}}catch{return null}}function De(e){if(!e)return!1;try{return!!new URL(e)}catch{return!1}}function P(e){return e?e.startsWith("//")?!0:/^[a-z][a-z0-9+.-]*:/i.test(e):!1}function We(e){return e?!P(e):!1}function L(e){return m(e)?.hostname??""}function Ve(e){const n=L(e);if(!n)return"";const r=["co.uk","co.jp","co.kr","co.nz","co.za","co.in","com.au","com.br","com.cn","com.tw","com.hk","com.sg","org.uk","org.au","net.au","net.cn","gov.uk","gov.au","edu.au","edu.cn","ac.uk","ac.jp"],t=n.split(".");if(t.length>=3){const i=t.slice(-2).join(".");if(r.includes(i))return t.slice(-3).join(".")}return t.length>=2?t.slice(-2).join("."):n}function Ge(e){const n=m(e);if(!n)return"";const r=n.pathname.split("/").pop()||"",t=r.lastIndexOf(".");return t===-1||t===0?"":r.slice(t+1).toLowerCase()}function Qe(e,n=!0){const r=m(e);if(!r)return"";const t=r.pathname.split("/").pop()||"";if(!t||t==="/")return"";if(n)return t;const i=t.lastIndexOf(".");return i>0?t.slice(0,i):t}function A(e){if(!e)return{};const n=e.startsWith("?")?e.slice(1):e;if(!n)return{};const r={},t=new URLSearchParams(n);for(const[i,o]of t.entries()){const a=r[i];a!==void 0?Array.isArray(a)?a.push(o):r[i]=[a,o]:r[i]=o}return r}function C(e,n={}){const{skipNull:r=!1,skipEmpty:t=!1,arrayFormat:i="repeat"}=n,o=[];for(const[a,s]of Object.entries(e)){if(s==null){if(r)continue;o.push(`${encodeURIComponent(a)}=`);continue}if(Array.isArray(s)){const u=s.filter(l=>l==null?!r:l===""?!t:!0);if(u.length===0)continue;switch(i){case"bracket":for(const l of u)o.push(`${encodeURIComponent(a)}[]=${encodeURIComponent(String(l??""))}`);break;case"index":u.forEach((l,h)=>{o.push(`${encodeURIComponent(a)}[${h}]=${encodeURIComponent(String(l??""))}`)});break;case"comma":o.push(`${encodeURIComponent(a)}=${u.map(l=>encodeURIComponent(String(l??""))).join(",")}`);break;default:for(const l of u)o.push(`${encodeURIComponent(a)}=${encodeURIComponent(String(l??""))}`)}continue}const c=String(s);c===""&&t||o.push(`${encodeURIComponent(a)}=${encodeURIComponent(c)}`)}return o.join("&")}function Ze(e,n){if(!e||!n)return null;try{return new URL(e,"http://localhost").searchParams.get(n)}catch{const r=e.indexOf("?");if(r===-1)return null;const t=A(e.slice(r))[n];return Array.isArray(t)?t[0]??null:t??null}}function qe(e,n){if(!e||!n)return[];try{return new URL(e,"http://localhost").searchParams.getAll(n)}catch{const r=e.indexOf("?");if(r===-1)return[];const t=A(e.slice(r))[n];return t?Array.isArray(t)?t:[t]:[]}}function T(e,n,r){if(!e||!n)return e;try{const t=new URL(e);return r==null?t.searchParams.delete(n):t.searchParams.set(n,String(r)),t.toString()}catch{const t=e.indexOf("#"),i=t!==-1?e.slice(t+1):"",o=t!==-1?e.slice(0,t):e,a=o.indexOf("?"),s=a!==-1?o.slice(0,a):o,c=a!==-1?o.slice(a+1):"",u=A(c);r==null?delete u[n]:u[n]=String(r);const l=C(u);let h=s;return l&&(h+=`?${l}`),i&&(h+=`#${i}`),h}}function Ke(e,n){let r=e;for(const[t,i]of Object.entries(n))if(Array.isArray(i)){r=F(r,t);for(const o of i)r=N(r,t,o)}else r=T(r,t,i);return r}function N(e,n,r){if(!e||!n||r===null||r===void 0)return e;try{const t=new URL(e);return t.searchParams.append(n,String(r)),t.toString()}catch{const[t,i]=e.split("?"),[o,a]=(i||"").split("#"),s=o?"&":"",c=`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`;let u=t||"";return u+=`?${o||""}${s}${c}`,a&&(u+=`#${a}`),u}}function F(e,n){if(!e||!n)return e;try{const r=new URL(e);return r.searchParams.delete(n),r.toString()}catch{const[r,t]=e.split("?"),[i,o]=(t||"").split("#"),a=A(i||"");delete a[n];const s=C(a);let c=r||"";return s&&(c+=`?${s}`),o&&(c+=`#${o}`),c}}function _e(e,n){if(!e||!n)return!1;try{return new URL(e,"http://localhost").searchParams.has(n)}catch{const r=e.indexOf("?");if(r===-1)return!1;const t=A(e.slice(r));return n in t}}function M(...e){if(e.length===0)return"";const n=e.filter(t=>t!=null&&t!=="");if(n.length===0)return"";let r=n[0];for(let t=1;t<n.length;t++){const i=n[t],o=r.endsWith("/"),a=i.startsWith("/");o&&a?r+=i.slice(1):!o&&!a?r+=`/${i}`:r+=i}return r}function He(e){if(!e)return"";const n=m(e);if(n){const i=z(n.pathname);return`${n.origin}${i}${n.search}${n.hash}`}const[r,t]=e.split(/(?=[?#])/);return z(r||"")+(t||"")}function z(e){if(!e)return"";const n=e.startsWith("/"),r=e.endsWith("/")&&e.length>1,t=e.split("/").filter(Boolean),i=[];for(const a of t)if(a!=="."){if(a===".."){i.pop();continue}i.push(a)}let o=i.join("/");return n&&(o=`/${o}`),r&&o!=="/"&&(o+="/"),o||(n?"/":"")}function Je(e){if(!e)return"";const[n,...r]=e.split(/(?=[?#])/);return n?(n.length>1&&n.endsWith("/")?n.slice(0,-1):n)+r.join(""):e}function Xe(e){if(!e)return"/";const n=e.search(/[?#]/),r=n===-1?e:e.slice(0,n),t=n===-1?"":e.slice(n);return r?(r.endsWith("/")?r:`${r}/`)+t:`/${t}`}function Ye(e){return e?e.replace(/^\/+/,""):""}function et(e){return e?e.startsWith("/")?e:`/${e}`:"/"}function tt(e,n,r,t){let i=e;if(n&&(i=M(i,n)),r&&Object.keys(r).length>0){const o=C(r);o&&(i+=(i.includes("?")?"&":"?")+o)}if(t){const o=t.startsWith("#")?t:`#${t}`;i+=o}return i}function nt(e){if(!e)return"";try{return decodeURIComponent(e)}catch{return e}}function rt(e){if(!e)return"";try{return encodeURIComponent(e)}catch{return e}}function ot(e,n){const r=m(e),t=m(n);return!r||!t?!1:r.origin===t.origin}function it(e,n){if(!e)return n;try{return new URL(e,n).href}catch{return e}}function st(e,n){const r=m(e),t=m(n);if(!r||!t||r.origin!==t.origin)return n;const i=r.pathname.split("/").filter(Boolean),o=t.pathname.split("/").filter(Boolean);let a=0;const s=Math.min(i.length,o.length);for(let f=0;f<s&&i[f]===o[f];f++)a++;const c=i.length-a,u=o.slice(a),l=[];for(let f=0;f<c;f++)l.push("..");l.push(...u);let h=l.join("/")||".";return t.search&&(h+=t.search),t.hash&&(h+=t.hash),h}function B(e){return Array.isArray(e)}function D(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function W(e){return typeof e=="string"}function ct(e){return e==null?!0:B(e)||W(e)?e.length===0:D(e)?Object.keys(e).length===0:!1}function at(e){return typeof e=="function"}function ut(e){return typeof e=="number"&&!Number.isNaN(e)}function lt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.prototype.toString.call(e)==="[object Object]"}export{Pe as Tree,N as appendQueryParam,tt as buildUrl,le as camelCase,fe as capitalize,Le as chunk,_ as convertSvgToPng,R as convertToKebabCase,Fe as debounce,w as deepClone,et as ensureLeadingSlash,Xe as ensureTrailingSlash,H as extractFilename,Te as flatten,J as formatFileSize,L as getDomain,ie as getPath,Ze as getQueryParam,qe as getQueryParams,ue as getRandomUUID,st as getRelativePath,Ve as getRootDomain,Ge as getUrlExtension,Qe as getUrlFilename,_e as hasQueryParam,P as isAbsoluteUrl,B as isArray,ct as isEmpty,at as isFunction,ut as isNumber,D as isObject,lt as isPlainObject,We as isRelativeUrl,ot as isSameOrigin,W as isString,O as isValidContainer,De as isValidUrl,se as joinPath,M as joinUrl,he as kebabCase,pe as lowerCase,de as lowerFirst,He as normalizeUrl,ee as omit,te as omitUndefined,A as parseQuery,m as parseUrl,ge as pascalCase,ne as pick,Ye as removeLeadingSlash,F as removeQueryParam,Je as removeTrailingSlash,X as replaceCurrentColor,nt as safeDecodeURIComponent,rt as safeEncodeURIComponent,re as separate,oe as separateMany,ce as setPath,T as setQueryParam,Ke as setQueryParams,ae as simpleHash,Me as sleep,ze as sleepWithCancel,me as snakeCase,ye as startCase,C as stringifyQuery,Be as throttle,it as toAbsoluteUrl,S as toPath,Y as triggerDownload,Ne as unique,we as upperCase,be as upperFirst,Z as useAppStorage,q as useCopyCode,$ as words};
1
+ import{useStorage as K}from"@vueuse/core";function J(e){const{key:t,defaultValue:r,storage:n="localStorage",prefix:i="movk"}=e,o=`${i}:${t}`,s=(()=>{if(!(typeof window>"u"))return n==="localStorage"?localStorage:sessionStorage})();function a(h){if(h===null)return r;try{return JSON.parse(h)}catch(p){return console.warn(`[AppStorage] Failed to parse value for key "${o}". Using default value.`,p),r}}const c=K(o,r,s,{mergeDefaults:!0,serializer:{read:a,write:h=>JSON.stringify(h)}});function u(){if(!s)return r;const h=s.getItem(o);return a(h)}function f(h){c.value=h}function l(){s&&(c.value=null)}return{state:c,getItem:u,setItem:f,removeItem:l}}async function X(e){if(typeof e!="string")throw new TypeError("Text must be a string");if(typeof window>"u")return console.warn("useCopyCode: Not available in server environment"),!1;if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard API failed, falling back to legacy method:",t)}try{return Y(e)}catch(t){return console.error("Failed to copy text:",t),!1}}function Y(e){if(typeof document>"u")return console.warn("copyTextLegacy: Document not available"),!1;const t=document.createElement("textarea"),r=document.activeElement,n=document.getSelection(),i=n&&n.rangeCount>0?n.getRangeAt(0):null;try{return t.value=e,t.setAttribute("readonly",""),t.setAttribute("contenteditable","true"),Object.assign(t.style,{contain:"strict",position:"absolute",left:"-9999px",top:"-9999px",fontSize:"12pt",border:"0",padding:"0",margin:"0",outline:"none",boxShadow:"none",background:"transparent"}),document.body.appendChild(t),t.focus(),t.select(),t.setSelectionRange&&t.setSelectionRange(0,e.length),document.execCommand("copy")}catch(o){return console.error("Legacy copy method failed:",o),!1}finally{t.parentNode&&document.body.removeChild(t),i&&n&&(n.removeAllRanges(),n.addRange(i)),r instanceof HTMLElement&&r.focus()}}async function ee(e){if(!e||typeof e!="string")throw new Error("Invalid SVG string provided");if(typeof window>"u"||typeof document>"u")throw new TypeError("convertSvgToPng is only available in browser environment");return new Promise((t,r)=>{const n=new Image,i=document.createElement("canvas"),o=i.getContext("2d");if(!o){r(new Error("Canvas context not available"));return}n.onload=()=>{try{i.width=n.width,i.height=n.height,o.drawImage(n,0,0),i.toBlob(s=>{s?t(s):r(new Error("Failed to convert canvas to Blob"))},"image/png")}catch(s){r(new Error(`Error during canvas conversion: ${s}`))}},n.onerror=()=>{r(new Error("Failed to load SVG image"))};try{n.src=`data:image/svg+xml;base64,${btoa(e)}`}catch(s){r(new Error(`Failed to encode SVG: ${s}`))}})}const te=/filename\*?=(?:"([^"]+)"|([^;]+))/i;function ne(e,t="file"){if(!e)return t;const r=e.get("content-disposition");if(r){const n=r.match(te);if(n){let i=n[1]??n[2];if(!i)return t;if(i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1)),r.includes("filename*=")){const o=i.split("''");if(o.length===2&&o[1])try{i=decodeURIComponent(o[1])}catch{return t}}return i}}return t}function re(e){if(!Number.isFinite(e)||e<0||e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB","TB","PB"],n=Math.floor(Math.log(e)/Math.log(t));return n>=r.length?`${Number.parseFloat((e/t**(r.length-1)).toFixed(2))} ${r.at(-1)}`:`${Number.parseFloat((e/t**n).toFixed(2))} ${r[n]}`}async function oe(e,t){if(!e||typeof e!="string")throw new Error("Invalid SVG path provided");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch SVG file: ${r.status} ${r.statusText}`);const n=await r.text();if(!t)return n;if(typeof window>"u"||typeof DOMParser>"u")return console.warn("replaceCurrentColor: DOM manipulation not available in server environment, returning original SVG"),n;const i=new DOMParser().parseFromString(n,"image/svg+xml");if(i.querySelector("parsererror"))throw new Error("Invalid SVG content");const o=i.querySelector("svg");if(!o)throw new Error("No SVG element found in the document");o.hasAttribute("fill")||o.setAttribute("fill","currentColor");const s=a=>{a.getAttribute("fill")==="currentColor"&&a.setAttribute("fill",t),a.getAttribute("stroke")==="currentColor"&&a.setAttribute("stroke",t),[...a.children].forEach(c=>{s(c)})};return s(o),new XMLSerializer().serializeToString(i)}catch(r){throw r instanceof Error?r:new Error(`Unexpected error occurred: ${r}`)}}function ie(e,t){if(typeof window>"u"||typeof document>"u"){console.warn("triggerDownload: Not available in server environment");return}const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function w(e,t=new WeakMap){if(e===null||typeof e!="object")return e;try{const a=globalThis.structuredClone;if(typeof a=="function")return a(e)}catch(a){console.error("Error occurred while cloning:",a)}const r=e,n=t.get(r);if(n)return n;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const a=new Map;t.set(r,a);for(const[c,u]of e.entries())a.set(w(c,t),w(u,t));return a}if(e instanceof Set){const a=new Set;t.set(r,a);for(const c of e.values())a.add(w(c,t));return a}if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e)){const a=e.constructor;return new a(e)}if(e instanceof URL)return new URL(e.toString());if(e instanceof Error){const a=new e.constructor(e.message);return a.name=e.name,a.stack=e.stack,a}if(Array.isArray(e)){const a=[];t.set(r,a);for(const c of e)a.push(w(c,t));return a}const i=Object.getPrototypeOf(e),o=Object.create(i);t.set(r,o);const s=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const a of s){const c=Object.getOwnPropertyDescriptor(e,a);c&&("value"in c&&(c.value=w(e[a],t)),Object.defineProperty(o,a,c))}return o}function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.prototype.toString.call(e)==="[object Object]"}const se=new Set(["__proto__","constructor"]);function ce(e){return{arrayStrategy:e?.arrayStrategy??"concat",nullHandling:e?.nullHandling??"skip",customMerger:e?.customMerger}}function ae(e){return[...Object.keys(e),...Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))]}function C(e,t,r,n,i){const o={...e};for(const s of ae(t)){if(typeof s=="string"&&se.has(s))continue;const a=o[s],c=t[s];if(r.customMerger){const u=r.customMerger(s,a,c,n);if(u!==void 0){o[s]=u;continue}}if(c==null){if(r.nullHandling==="skip"&&s in o)continue;o[s]=c;continue}if(Array.isArray(c)){if(Array.isArray(a))switch(r.arrayStrategy){case"replace":o[s]=[...c];break;case"unique":o[s]=[...new Set([...a,...c])];break;case"concat":default:o[s]=[...a,...c];break}else o[s]=[...c];continue}if(v(c)){if(i.has(c)){o[s]=i.get(c);continue}const u=[...n,s],f={};if(i.set(c,f),v(a)){const l=C(a,c,r,u,i);Object.assign(f,l),o[s]=f}else{const l=C({},c,r,u,i);Object.assign(f,l),o[s]=f}continue}o[s]=c}return o}function R(e,t){if(!Array.isArray(e))return{};const r=ce(t),n=e.filter(v);if(n.length===0)return{};const i=new WeakMap;return n.reduce((o,s)=>C(o,s,r,[],i),{})}function ue(e){return t=>R(t,e)}function fe(e,t){if(!e||typeof e!="object")return{};const r=new Set(t),n={};for(const i in e)Object.hasOwn(e,i)&&!r.has(i)&&(n[i]=e[i]);return n}function le(e){return!e||typeof e!="object"||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function he(e,t){if(!e||typeof e!="object")return{};const r={};for(const n of t)Object.hasOwn(e,n)&&(r[n]=e[n]);return r}function pe(e,t){if(!e||typeof e!="object")return{picked:{},omitted:{}};if(t.length===0)return{picked:{},omitted:{...e}};const r=new Set(t),n={},i={};for(const o in e)if(Object.hasOwn(e,o)){const s=o;r.has(s)?n[o]=e[s]:i[o]=e[s]}return{picked:n,omitted:i}}function de(e,t){if(!e||typeof e!="object")return{...Object.fromEntries(Object.keys(t).map(o=>[o,{}])),others:{}};const r=Object.keys(t),n=new Map;for(const o of r){const s=new Set(t[o]);n.set(o,s)}const i=Object.create(null);for(const o of r)i[o]={};i.others={};for(const o in e)if(Object.hasOwn(e,o)){const s=o;let a=!1;for(const c of r)if(n.get(c).has(s)){i[c][o]=e[s],a=!0;break}a||(i.others[o]=e[s])}return i}const I=/\s/,ge=/^(?:0|[1-9]\d*)$/;function j(e){if(Array.isArray(e))return e.slice();const t=[];if(e==="")return t;let r=0;const n=e,i=n.length;function o(a){let c="",u=a;for(;u<i;){const f=n.charCodeAt(u);if(f===46)break;if(f===92){u++,u<i&&(c+=n[u]),u++;continue}if(f===91)break;c+=n[u],u++}return{value:c,next:u}}function s(a){let c=a+1;for(;c<i&&I.test(n[c]);)c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const u=n[c];if(u==='"'||u==="'"){const h=u;c++;let p="",d=!1;for(;c<i;){if(n.charCodeAt(c)===92){c++,c<i&&(p+=n[c]),c++;continue}if(n[c]===h){d=!0,c++;break}p+=n[c],c++}if(!d)throw new Error("Invalid path: missing closing quote in bracket");for(;c<i&&I.test(n[c]);)c++;if(c>=i||n[c]!=="]")throw new Error('Invalid path: missing closing "]"');return c++,{segment:p,next:c}}let f="";for(;c<i&&n[c]!=="]";)f+=n[c],c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const l=f.trim();return ge.test(l)?(c++,{segment:Number(l),next:c}):(c++,{segment:l,next:c})}for(;r<i;){const a=n.charCodeAt(r);if(a===46){r++;continue}if(a===91){const{segment:f,next:l}=s(r);f!==null&&t.push(f),r=l;continue}const{value:c,next:u}=o(r);(c.length>0||u<i&&n[u]===".")&&t.push(c),r=u}return t}function me(e,t,r){const n=j(t);if(n.length===0)return e;let i=e;for(let o=0;o<n.length;o++){if(i==null)return r;const s=n[o];i=i[s]}return i===void 0?r:i}const ye=/^[A-Z_$][\w$]*$/i,we=/\\/g,be=/'/g;function Ae(e){let t="";for(let r=0;r<e.length;r++){const n=e[r];if(typeof n=="number"&&Number.isInteger(n)&&n>=0){t+=`[${n}]`;continue}const i=String(n),o=ye.test(i);if(t.length===0&&o){t+=i;continue}if(o){t+=`.${i}`;continue}const s=i.replace(we,"\\\\").replace(be,"\\'");t+=`['${s}']`}return t}function P(e){return e!==null&&typeof e=="object"}function xe(e,t,r){const n=j(t);if(n.length===0)return e;let i=e;for(let o=0;o<n.length;o++){const s=n[o];if(o===n.length-1){i[s]=r;break}const a=n[o+1];let c=i[s];const u=typeof a=="number";if(P(c)?u&&!Array.isArray(c)&&(c=[],i[s]=c):(c=u?[]:{},i[s]=c),u&&Array.isArray(c)){const f=Number(a);Number.isInteger(f)&&f>=0&&c.length<=f&&(c.length=f+1)}i=c}return e}function ve(e){let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return Math.abs(t).toString(36)}const $e=/[xy]/g;function Se(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace($e,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}const Ce=/([a-z\d])([A-Z])/g;function L(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return e;const r=i=>i.replace(Ce,"$1-$2").toLowerCase(),n={};for(const i in e)if(Object.hasOwn(e,i)){const o=r(i),s=e[i];t&&s&&typeof s=="object"&&!Array.isArray(s)?n[o]=L(s,!0):n[o]=s}return n}const je=/[_-]/g,Ee=/[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|\d+/g;function E(e){return e?e.replace(je," ").match(Ee)||[]:[]}function b(e,t){if(!e)return"";const r=E(e);return r.length===0?"":r.map((n,i)=>{const o=n.toLowerCase(),s=n.toUpperCase();if(t.transform)return t.transform(n,i,o,s);switch(t.casing){case"lower":return o;case"upper":return s;case"capitalize":return o.charAt(0).toUpperCase()+o.slice(1);default:return n}}).join(t.separator??"")}function T(e,t){if(!e)return"";const r=e.charAt(0);return(t?r.toUpperCase():r.toLowerCase())+e.slice(1)}function Ue(e){return b(e,{separator:"",transform:(t,r,n)=>r===0?n:n.charAt(0).toUpperCase()+n.slice(1)})}function Oe(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():""}function ke(e){return b(e,{separator:"-",casing:"lower"})}function Re(e){return b(e,{separator:" ",casing:"lower"})}function Ie(e){return T(e,!1)}function Pe(e){return b(e,{separator:"",casing:"capitalize"})}function Le(e){return b(e,{separator:"_",casing:"lower"})}function Te(e){return e?E(e).map(t=>t.toUpperCase()===t&&t.length>1?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" "):""}function Me(e){return b(e,{separator:" ",casing:"upper"})}function Ne(e){return T(e,!0)}const U={id:"id",pid:"pid",children:"children"};function g(e={}){return{id:e.id??U.id,pid:e.pid??U.pid,children:e.children??U.children}}function*$(e,t={},r=[]){const{children:n}=g(t);let i=0;for(const o of e){const s=[...r,o];yield{node:o,path:s,depth:r.length,index:i++};const a=o[n];a&&a.length>0&&(yield*$(a,t,s))}}function*O(e,t={}){const{children:r}=g(t),n=e.map((o,s)=>({node:o,path:[o],depth:0,index:s}));let i=e.length;for(;n.length>0;){const o=n.shift();yield o;const s=o.node[r];s&&s.length>0&&s.forEach(a=>{const c=[...o.path,a];n.push({node:a,path:c,depth:o.depth+1,index:i++})})}}function k(e){switch(e){case"find":case"findAll":case"filter":case"transform":case"forEach":case"stats":case"validate":return"dfs";default:return"dfs"}}function Fe(e,t={}){const{id:r,pid:n,children:i}=g(t);if(!Array.isArray(e)||e.length===0)return[];const o=new Map,s=[];return e.forEach(a=>{const{[i]:c,...u}=a,f={...u,[i]:[]};o.set(a[r],f)}),e.forEach(a=>{const c=o.get(a[r]),u=a[n];u&&o.has(u)?o.get(u)[i].push(c):s.push(c)}),s}function De(e,t={}){const{children:r}=g(t),n=[],i=Array.isArray(e)?e:[e],o=s=>{const{[r]:a,...c}=s;n.push(c),a&&a.length>0&&a.forEach(o)};return i.forEach(o),n}function ze(e,t={}){const{children:r}=g(t),n=Array.isArray(e)?e:[e];let i=0;const o=s=>{i++;const a=s[r];a&&a.length>0&&a.forEach(o)};return n.forEach(o),i}function Be(e,t,r,n={}){const{id:i,children:o}=g(n),{[o]:s,...a}=r,c={...a,[o]:[]},u=(f,l)=>{for(let h=0;h<f.length;h++){const p=f[h];if(!p)continue;if(p[i]===t)return f.splice(h,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...l,p];if(u(d,y))return!0}}return!1};return u(e,[])}function We(e,t,r,n={}){const{id:i,children:o}=g(n),{[o]:s,...a}=r,c={...a,[o]:[]},u=(f,l)=>{for(let h=0;h<f.length;h++){const p=f[h];if(!p)continue;if(p[i]===t)return f.splice(h+1,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...l,p];if(u(d,y))return!0}}return!1};return u(e,[])}function Ve(e,t,r={}){const{id:n,children:i}=g(r),o=s=>{for(let a=0;a<s.length;a++){const c=s[a];if(!c)continue;if(c[n]===t)return s.splice(a,1)[0];const u=c[i];if(u&&u.length>0){const f=o(u);if(f)return f}}};return o(e)}function M(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("find")==="dfs"?$(n,r):O(n,r);for(const o of i)if(t({node:o.node,depth:o.depth,path:o.path,index:o.index}))return o.node}function Ge(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("findAll"),o=[],s=i==="dfs"?$(n,r):O(n,r);for(const a of s)t({node:a.node,depth:a.depth,path:a.path,index:a.index})&&o.push(a.node);return o}function Qe(e,t,r={}){const{id:n}=g(r);return M(e,({node:i})=>i[n]===t,r)}function _e(e,t,r={}){const{children:n}=g(r),i=Array.isArray(e)?e:[e],o=[],s=(a,c,u,f=0)=>{const l=a[n],h=[];if(l&&l.length>0){const p=[...u,a];l.forEach((d,y)=>{const x=s(d,c+1,p,y);x&&h.push(x)})}if(t({node:a,depth:c,path:u,index:f})||h.length>0){const{[n]:p,...d}=a;return{...d,[n]:h}}return null};return i.forEach((a,c)=>{const u=s(a,0,[a],c);u&&o.push(u)}),o}function qe(e,t,r={}){const{children:n}=g(r),i=Array.isArray(e)?e:[e],o=[],s=(a,c,u,f=0)=>{const l=a[n],h=[];if(l&&l.length>0){const x=[...u,a];l.forEach((H,Z)=>{h.push(s(H,c+1,x,Z))})}const p=t({node:a,depth:c,path:u,index:f}),{[n]:d,...y}=p;return{...y,[n]:h}};return i.forEach((a,c)=>{o.push(s(a,0,[a],c))}),o}function He(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("forEach")==="dfs"?$(n,r):O(n,r);for(const o of i)if(t({node:o.node,depth:o.depth,path:o.path,index:o.index})===!1)break}function Ze(e,t={}){const{children:r}=g(t),n=Array.isArray(e)?e:[e];let i=0,o=0,s=0,a=0;const c=(u,f)=>{i++,s=Math.max(s,f);const l=u[r];l&&l.length>0?(a++,l.forEach(h=>c(h,f+1))):o++};return n.forEach(u=>c(u,1)),{total:i,leaves:o,depth:s,branches:a}}function Ke(e,t={}){const{id:r,children:n}=g(t),i=Array.isArray(e)?e:[e],o=[],s=new Set,a=(c,u,f)=>{const l=c[r];if(!l||typeof l!="string"){o.push(`Node at depth ${u} has invalid or missing ID`);return}if(s.has(l)){o.push(`Duplicate ID found: ${l}`);return}if(s.add(l),f.some(p=>p[r]===l)){o.push(`Circular reference detected for ID: ${l}`);return}const h=c[n];if(h!==void 0&&!Array.isArray(h)){o.push(`Node ${l} has invalid children property (not an array)`);return}if(h&&h.length>0){const p=[...f,c];h.forEach(d=>{a(d,u+1,p)})}};return i.forEach(c=>a(c,0,[])),{isValid:o.length===0,errors:o}}class Je{static fromList=Fe;static toList=De;static estimateSize=ze;static find=M;static findAll=Ge;static findById=Qe;static insertBefore=Be;static insertAfter=We;static remove=Ve;static filter=_e;static transform=qe;static forEach=He;static getStats=Ze;static validate=Ke}function Xe(e,t){const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function Ye(e,t=1){return t===1?e.flat():e.flat(t)}function et(e){return[...new Set(e)]}function tt(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout(e,t,...n)}}function nt(e){return new Promise(t=>setTimeout(t,e))}function rt(e){let t,r;return{promise:new Promise((n,i)=>{r=i,t=setTimeout(n,e)}),cancel:()=>{clearTimeout(t),r(new Error("Sleep was cancelled"))}}}function ot(e,t){let r=!1;return function(...n){r||(e.apply(this,n),r=!0,setTimeout(()=>{r=!1},t))}}const it=/^[a-z][a-z0-9+.-]*:/i;function m(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);return{href:r.href,protocol:r.protocol,host:r.host,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search,hash:r.hash,auth:r.username?`${r.username}${r.password?`:${r.password}`:""}`:"",origin:r.origin}}catch{return null}}function st(e){if(!e)return!1;try{return!!new URL(e)}catch{return!1}}function N(e){return e?e.startsWith("//")?!0:it.test(e):!1}function ct(e){return e?!N(e):!1}function F(e){return m(e)?.hostname??""}function at(e){const t=F(e);if(!t)return"";const r=["co.uk","co.jp","co.kr","co.nz","co.za","co.in","com.au","com.br","com.cn","com.tw","com.hk","com.sg","org.uk","org.au","net.au","net.cn","gov.uk","gov.au","edu.au","edu.cn","ac.uk","ac.jp"],n=t.split(".");if(n.length>=3){const i=n.slice(-2).join(".");if(r.includes(i))return n.slice(-3).join(".")}return n.length>=2?n.slice(-2).join("."):t}function ut(e){const t=m(e);if(!t)return"";const r=t.pathname.split("/").pop()||"",n=r.lastIndexOf(".");return n===-1||n===0?"":r.slice(n+1).toLowerCase()}function ft(e,t=!0){const r=m(e);if(!r)return"";const n=r.pathname.split("/").pop()||"";if(!n||n==="/")return"";if(t)return n;const i=n.lastIndexOf(".");return i>0?n.slice(0,i):n}function A(e){if(!e)return{};const t=e.startsWith("?")?e.slice(1):e;if(!t)return{};const r={},n=new URLSearchParams(t);for(const[i,o]of n.entries()){const s=r[i];s!==void 0?Array.isArray(s)?s.push(o):r[i]=[s,o]:r[i]=o}return r}function S(e,t={}){const{skipNull:r=!1,skipEmpty:n=!1,arrayFormat:i="repeat"}=t,o=[];for(const[s,a]of Object.entries(e)){if(a==null){if(r)continue;o.push(`${encodeURIComponent(s)}=`);continue}if(Array.isArray(a)){const u=a.filter(f=>f==null?!r:f===""?!n:!0);if(u.length===0)continue;switch(i){case"bracket":for(const f of u)o.push(`${encodeURIComponent(s)}[]=${encodeURIComponent(String(f??""))}`);break;case"index":u.forEach((f,l)=>{o.push(`${encodeURIComponent(s)}[${l}]=${encodeURIComponent(String(f??""))}`)});break;case"comma":o.push(`${encodeURIComponent(s)}=${u.map(f=>encodeURIComponent(String(f??""))).join(",")}`);break;default:for(const f of u)o.push(`${encodeURIComponent(s)}=${encodeURIComponent(String(f??""))}`)}continue}const c=String(a);c===""&&n||o.push(`${encodeURIComponent(s)}=${encodeURIComponent(c)}`)}return o.join("&")}function lt(e,t){if(!e||!t)return null;try{return new URL(e,"http://localhost").searchParams.get(t)}catch{const r=e.indexOf("?");if(r===-1)return null;const n=A(e.slice(r))[t];return Array.isArray(n)?n[0]??null:n??null}}function ht(e,t){if(!e||!t)return[];try{return new URL(e,"http://localhost").searchParams.getAll(t)}catch{const r=e.indexOf("?");if(r===-1)return[];const n=A(e.slice(r))[t];return n?Array.isArray(n)?n:[n]:[]}}function D(e,t,r){if(!e||!t)return e;try{const n=new URL(e);return r==null?n.searchParams.delete(t):n.searchParams.set(t,String(r)),n.toString()}catch{const n=e.indexOf("#"),i=n!==-1?e.slice(n+1):"",o=n!==-1?e.slice(0,n):e,s=o.indexOf("?"),a=s!==-1?o.slice(0,s):o,c=s!==-1?o.slice(s+1):"",u=A(c);r==null?delete u[t]:u[t]=String(r);const f=S(u);let l=a;return f&&(l+=`?${f}`),i&&(l+=`#${i}`),l}}function pt(e,t){let r=e;for(const[n,i]of Object.entries(t))if(Array.isArray(i)){r=B(r,n);for(const o of i)r=z(r,n,o)}else r=D(r,n,i);return r}function z(e,t,r){if(!e||!t||r===null||r===void 0)return e;try{const n=new URL(e);return n.searchParams.append(t,String(r)),n.toString()}catch{const[n,i]=e.split("?"),[o,s]=(i||"").split("#"),a=o?"&":"",c=`${encodeURIComponent(t)}=${encodeURIComponent(String(r))}`;let u=n||"";return u+=`?${o||""}${a}${c}`,s&&(u+=`#${s}`),u}}function B(e,t){if(!e||!t)return e;try{const r=new URL(e);return r.searchParams.delete(t),r.toString()}catch{const[r,n]=e.split("?"),[i,o]=(n||"").split("#"),s=A(i||"");delete s[t];const a=S(s);let c=r||"";return a&&(c+=`?${a}`),o&&(c+=`#${o}`),c}}function dt(e,t){if(!e||!t)return!1;try{return new URL(e,"http://localhost").searchParams.has(t)}catch{const r=e.indexOf("?");if(r===-1)return!1;const n=A(e.slice(r));return t in n}}const W=/(?=[?#])/,gt=/[?#]/,mt=/^\/+/;function V(...e){if(e.length===0)return"";const t=e.filter(n=>n!=null&&n!=="");if(t.length===0)return"";let r=t[0];for(let n=1;n<t.length;n++){const i=t[n],o=r.endsWith("/"),s=i.startsWith("/");o&&s?r+=i.slice(1):!o&&!s?r+=`/${i}`:r+=i}return r}function yt(e){if(!e)return"";const t=m(e);if(t){const i=G(t.pathname);return`${t.origin}${i}${t.search}${t.hash}`}const[r,n]=e.split(W);return G(r||"")+(n||"")}function G(e){if(!e)return"";const t=e.startsWith("/"),r=e.endsWith("/")&&e.length>1,n=e.split("/").filter(Boolean),i=[];for(const s of n)if(s!=="."){if(s===".."){i.pop();continue}i.push(s)}let o=i.join("/");return t&&(o=`/${o}`),r&&o!=="/"&&(o+="/"),o||(t?"/":"")}function wt(e){if(!e)return"";const[t,...r]=e.split(W);return t?(t.length>1&&t.endsWith("/")?t.slice(0,-1):t)+r.join(""):e}function bt(e){if(!e)return"/";const t=e.search(gt),r=t===-1?e:e.slice(0,t),n=t===-1?"":e.slice(t);return r?(r.endsWith("/")?r:`${r}/`)+n:`/${n}`}function At(e){return e?e.replace(mt,""):""}function xt(e){return e?e.startsWith("/")?e:`/${e}`:"/"}function vt(e,t,r,n){let i=e;if(t&&(i=V(i,t)),r&&Object.keys(r).length>0){const o=S(r);o&&(i+=(i.includes("?")?"&":"?")+o)}if(n){const o=n.startsWith("#")?n:`#${n}`;i+=o}return i}function $t(e){if(!e)return"";try{return decodeURIComponent(e)}catch{return e}}function St(e){if(!e)return"";try{return encodeURIComponent(e)}catch{return e}}function Ct(e,t){const r=m(e),n=m(t);return!r||!n?!1:r.origin===n.origin}function jt(e,t){if(!e)return t;try{return new URL(e,t).href}catch{return e}}function Et(e,t){const r=m(e),n=m(t);if(!r||!n||r.origin!==n.origin)return t;const i=r.pathname.split("/").filter(Boolean),o=n.pathname.split("/").filter(Boolean);let s=0;const a=Math.min(i.length,o.length);for(let h=0;h<a&&i[h]===o[h];h++)s++;const c=i.length-s,u=o.slice(s),f=[];for(let h=0;h<c;h++)f.push("..");f.push(...u);let l=f.join("/")||".";return n.search&&(l+=n.search),n.hash&&(l+=n.hash),l}function Q(e){return Array.isArray(e)}function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function q(e){return typeof e=="string"}function Ut(e){return e==null?!0:Q(e)||q(e)?e.length===0:_(e)?Object.keys(e).length===0:!1}function Ot(e){return typeof e=="function"}function kt(e){return typeof e=="number"&&!Number.isNaN(e)}export{Je as Tree,z as appendQueryParam,vt as buildUrl,Ue as camelCase,Oe as capitalize,Xe as chunk,ee as convertSvgToPng,L as convertToKebabCase,ue as createDeepMerge,tt as debounce,w as deepClone,R as deepMerge,xt as ensureLeadingSlash,bt as ensureTrailingSlash,ne as extractFilename,Ye as flatten,re as formatFileSize,F as getDomain,me as getPath,lt as getQueryParam,ht as getQueryParams,Se as getRandomUUID,Et as getRelativePath,at as getRootDomain,ut as getUrlExtension,ft as getUrlFilename,dt as hasQueryParam,N as isAbsoluteUrl,Q as isArray,Ut as isEmpty,Ot as isFunction,kt as isNumber,_ as isObject,v as isPlainObject,ct as isRelativeUrl,Ct as isSameOrigin,q as isString,P as isValidContainer,st as isValidUrl,Ae as joinPath,V as joinUrl,ke as kebabCase,Re as lowerCase,Ie as lowerFirst,yt as normalizeUrl,fe as omit,le as omitUndefined,A as parseQuery,m as parseUrl,Pe as pascalCase,he as pick,At as removeLeadingSlash,B as removeQueryParam,wt as removeTrailingSlash,oe as replaceCurrentColor,$t as safeDecodeURIComponent,St as safeEncodeURIComponent,pe as separate,de as separateMany,xe as setPath,D as setQueryParam,pt as setQueryParams,ve as simpleHash,nt as sleep,rt as sleepWithCancel,Le as snakeCase,Te as startCase,S as stringifyQuery,ot as throttle,jt as toAbsoluteUrl,j as toPath,ie as triggerDownload,et as unique,Me as upperCase,Ne as upperFirst,J as useAppStorage,X as useCopyCode,E as words};
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@movk/core",
3
3
  "type": "module",
4
- "version": "1.1.0",
5
- "packageManager": "pnpm@10.26.2",
4
+ "version": "1.2.1",
5
+ "packageManager": "pnpm@10.32.0",
6
6
  "description": "为 TypeScript 项目设计的现代化、支持 Tree-Shaking 的工具函数库。",
7
7
  "author": "YiXuan <mhaibaraai@gmail.com>",
8
8
  "license": "MIT",
@@ -52,17 +52,17 @@
52
52
  "vue": "^3.5.25"
53
53
  },
54
54
  "dependencies": {
55
- "@vueuse/core": "^14.1.0",
56
- "fast-glob": "^3.3.3"
55
+ "@vueuse/core": "^14.2.1",
56
+ "tinyglobby": "^0.2.15"
57
57
  },
58
58
  "devDependencies": {
59
- "@antfu/eslint-config": "^6.7.3",
60
- "@release-it/conventional-changelog": "^10.0.4",
61
- "@types/node": "^24.10.4",
62
- "eslint": "^9.39.2",
63
- "release-it": "^19.2.2",
59
+ "@antfu/eslint-config": "^7.7.0",
60
+ "@release-it/conventional-changelog": "^10.0.5",
61
+ "@types/node": "^25.4.0",
62
+ "eslint": "^10.0.3",
63
+ "release-it": "^19.2.4",
64
64
  "typescript": "^5.9.3",
65
65
  "unbuild": "^3.6.1",
66
- "vitest": "^4.0.16"
66
+ "vitest": "^4.0.18"
67
67
  }
68
68
  }