//#region src/config.d.ts
type ConfigErrorCode = 'missing' | 'invalid';
declare class ConfigError extends Error {
  readonly key: string;
  readonly code: ConfigErrorCode;
  constructor(key: string, code: ConfigErrorCode);
}
interface ConfigField<T> {
  parse(raw: string): T;
  optional?: boolean;
  default?: T;
}
type ConfigSchema = Record<string, ConfigField<unknown>>;
type FieldValue<F> = F extends ConfigField<infer T> ? F extends {
  optional: true;
} ? T | undefined : T : never;
type ConfigResult<S extends ConfigSchema> = { [K in keyof S]: FieldValue<S[K]>; };
declare function defineConfig<S extends ConfigSchema>(schema: S): S;
declare function readConfig<S extends ConfigSchema>(schema: S, env: Record<string, string | undefined>): ConfigResult<S>;
interface ConfigFieldOptions<T> {
  optional?: boolean;
  default?: T;
}
declare const configField: {
  string<O extends ConfigFieldOptions<string> | undefined = undefined>(options?: O): ConfigField<string> & (O extends {
    optional: true;
  } ? {
    optional: true;
  } : object);
  number<O extends ConfigFieldOptions<number> | undefined = undefined>(options?: O): ConfigField<number> & (O extends {
    optional: true;
  } ? {
    optional: true;
  } : object);
  boolean<O extends ConfigFieldOptions<boolean> | undefined = undefined>(options?: O): ConfigField<boolean> & (O extends {
    optional: true;
  } ? {
    optional: true;
  } : object);
  url<O extends ConfigFieldOptions<string> | undefined = undefined>(options?: O): ConfigField<string> & (O extends {
    optional: true;
  } ? {
    optional: true;
  } : object);
};
//#endregion
export { ConfigError, ConfigErrorCode, ConfigField, ConfigFieldOptions, ConfigResult, ConfigSchema, configField, defineConfig, readConfig };