import type { AllKeys, IsAny, MergeUnion } from './utils.js'; export declare function splitPath(path: string): string[]; export declare function mergePath(path: (string | number | symbol)[]): string; type DictOrArray = Record | unknown[]; /** * Lists all paths in an object as string accessors. */ export type FormPath = string & StringPath; /** * List paths in an object as string accessors, but only with non-objects as accessible properties. * Similar to the leaves in a node tree, if you look at the object as a tree structure. */ export type FormPathLeaves = string & StringPath; /** * List paths in an object as string accessors, but only with non-objects as accessible properties. * Also includes the _errors field for objects and arrays. */ export type FormPathLeavesWithErrors = string & StringPath; /** * List all arrays in an object as string accessors. */ export type FormPathArrays = string & StringPath; type Concat = `${Path}${Path extends '' ? '' : '.'}${Next}`; type StringPathOptions = { filter: 'arrays' | 'leaves' | 'all'; objAppend: string | never; path: string; type: any; }; type If = Options[Pred] extends Subj ? Options['type'] extends never ? Then : Value extends Options['type'] ? Then : never : Else; type StringPath = T extends (infer U)[] ? If, never, T> | If | (NonNullable extends DictOrArray ? StringPath, { filter: Options['filter']; objAppend: Options['objAppend']; path: `${Options['path']}[${number}]`; type: Options['type']; }> : If) : { [K in Extract, string>]: NonNullable extends DictOrArray ? If, never, T[K]> | NonNullable extends (infer U)[] ? If, never, T[K]> | (NonNullable extends unknown[] ? If, never, T[K]> : NonNullable extends DictOrArray ? IsAny extends true ? Concat : If, never, U> : If, never, U>) | (NonNullable extends DictOrArray ? StringPath, { filter: Options['filter']; objAppend: Options['objAppend']; path: Concat; type: Options['type']; }> : never) : IsAny extends true ? Concat : If, unknown extends T[K] ? Concat : never, T[K]> | StringPath, { filter: Options['filter']; objAppend: Options['objAppend']; path: Concat; type: Options['type']; }> : If, never, T[K]>; }[Extract, string>]; export type FormPathType = P extends keyof T ? T[P] : P extends number ? T : P extends `.${infer Rest}` ? FormPathType, Rest> : P extends `${number}]${infer Rest}` ? NonNullable extends (infer U)[] ? FormPathType : { invalid_path1: P; Type: T; } : P extends `${infer K}[${infer Rest}` ? K extends keyof NonNullable ? FormPathType[K], Rest> : FormPathType : P extends `${infer K}.${infer Rest}` ? K extends keyof NonNullable ? FormPathType[K], Rest> : NonNullable extends (infer U)[] ? FormPathType : { invalid_path2: P; Type: T; } : P extends `[${infer K}].${infer Rest}` ? K extends number ? T extends (infer U)[] ? FormPathType : { invalid_path3: P; Type: T; } : P extends `${number}` ? NonNullable extends (infer U)[] ? U : { invalid_path4: P; Type: T; } : P extends keyof NonNullable ? NonNullable[P] : P extends `${number}` ? NonNullable extends (infer U)[] ? U : { invalid_path5: P; Type: T; } : { invalid_path6: P; Type: T; } : P extends '' ? T : P extends AllKeys ? MergeUnion[P] : { invalid_path7: P; Type: T; }; export {};