import { HasRequiredKeys, IsAny, Prettify as Prettify$1, UnionToIntersection } from "../types/helper.mjs"; import { InferAdditionalFromClient, InferSessionFromClient, InferUserFromClient } from "./types.mjs"; import { BetterAuthClientOptions, ClientFetchOption } from "@better-auth/core"; import { Endpoint, InputContext, StandardSchemaV1 } from "better-call"; import { BetterFetchResponse } from "@better-fetch/fetch"; //#region src/client/path-to-object.d.ts type KeepNullishFromOriginal = Replaced | (undefined extends Original ? undefined : never) | (null extends Original ? null : never); type ReplaceTopLevelField = Data extends object ? Field extends keyof Data ? Omit & { [K in Field]: KeepNullishFromOriginal } : Data : Data; type ReplaceAuthUserAndSession = ReplaceTopLevelField>, "session", InferSessionFromClient>; type MergeCustomSessionField = Field extends keyof R ? { [K in Field]: KeepNullishFromOriginal & InferType> } : {}; type MergeCustomSessionWithInferred = R extends object ? Omit & MergeCustomSessionField> & MergeCustomSessionField> : never; type RefineAuthResponse = Data extends { token: unknown; } | { redirect: unknown; } ? ReplaceAuthUserAndSession : Data; type CamelCase = S extends `${infer P1}-${infer P2}${infer P3}` ? `${Lowercase}${Uppercase}${CamelCase}` : Lowercase; type PathToObject any> = T extends `/${infer Segment}/${infer Rest}` ? { [K in CamelCase]: PathToObject<`/${Rest}`, Fn> } : T extends `/${infer Segment}` ? { [K in CamelCase]: Fn } : never; type InferSignUpEmailCtx = { email: string; name: string; password: string; image?: string | undefined; callbackURL?: string | undefined; fetchOptions?: FetchOptions | undefined; } & UnionToIntersection>; type InferUserUpdateCtx = { image?: (string | null) | undefined; name?: string | undefined; fetchOptions?: FetchOptions | undefined; } & Partial>>; type InferSessionUpdateCtx = { fetchOptions?: FetchOptions | undefined; } & Partial>>; type InferCtxQuery, FetchOptions extends ClientFetchOption> = C["query"] extends Record ? { query: C["query"]; fetchOptions?: FetchOptions | undefined; } : C["query"] extends Record | undefined ? { query?: C["query"] | undefined; fetchOptions?: FetchOptions | undefined; } : { fetchOptions?: FetchOptions | undefined; }; type InferCtx, FetchOptions extends ClientFetchOption> = IsAny extends true ? InferCtxQuery : C["body"] extends Record ? C["body"] & { fetchOptions?: FetchOptions | undefined; } : InferCtxQuery; type MergeRoutes = UnionToIntersection; type InferRoute = API extends Record ? T extends Endpoint ? T["options"]["metadata"] extends { isAction: false; } | { SERVER_ONLY: true; } | { scope: "http"; } | { scope: "server"; } ? {} : PathToObject infer R) ? C extends InputContext ? & Record, Partial & Record, C["params"]>>(...data: HasRequiredKeys> extends true ? [Prettify$1 : InferCtx>, FetchOptions?] : [Prettify$1 : T["path"] extends `/update-session` ? InferSessionUpdateCtx : InferCtx>?, FetchOptions?]) => Promise>, COpts> : T["path"] extends "/get-session" ? { user: InferUserFromClient; session: InferSessionFromClient; } | null : RefineAuthResponse>, COpts>, T["options"]["error"] extends StandardSchemaV1 ? NonNullable["output"] : { code?: string | undefined; message?: string | undefined; }, FetchOptions["throw"] extends true ? true : COpts["fetchOptions"] extends { throw: true; } ? true : false>> : never : never> : {} : never; type InferRoutes, ClientOpts extends BetterAuthClientOptions> = MergeRoutes>; type ProxyRequest = { options?: ClientFetchOption | undefined; query?: any | undefined; [key: string]: any; }; //#endregion export { CamelCase, InferCtx, InferRoute, InferRoutes, InferSessionUpdateCtx, InferSignUpEmailCtx, InferUserUpdateCtx, MergeRoutes, PathToObject, ProxyRequest };