import { BaseName, Extname, File, Mode, OptionalPath, Path, ResolvedFile } from "./index-CGJ3tdk-.js";
import { EventEmitter, Logger } from "./logger-B-4AXUmB.js";

//#region src/utils/types.d.ts
type PossiblePromise<T> = Promise<T> | T;
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
//#endregion
//#region src/types.d.ts
/**
 * Config used in `kubb.config.ts`
 *
 * @example
 * import { defineConfig } from '@kubb/core'
 * export default defineConfig({
 * ...
 * })
 */
type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
  /**
   * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
   * @default process.cwd()
   */
  root?: string;
  /**
   * An array of Kubb plugins used for generation. Each plugin may have additional configurable options (defined within the plugin itself). If a plugin relies on another plugin, an error will occur if the required dependency is missing. Refer to “pre” for more details.
   */
  plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
};
type InputPath = {
  /**
   * Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
   */
  path: string;
};
type InputData = {
  /**
   * A `string` or `object` that contains your Swagger/OpenAPI data.
   */
  data: string | unknown;
};
type Input = InputPath | InputData | Array<InputPath>;
type BarrelType = 'all' | 'named' | 'propagate';
/**
 * @private
 */
type Config<TInput = Input> = {
  /**
   * The name to display in the CLI output.
   */
  name?: string;
  /**
   * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
   * @default process.cwd()
   */
  root: string;
  /**
   * You can use either `input.path` or `input.data`, depending on your specific needs.
   */
  input: TInput;
  output: {
    /**
     * The path where all generated files will be exported.
     * This can be an absolute path or a path relative to the specified root option.
     */
    path: string;
    /**
     * Clean the output directory before each build.
     */
    clean?: boolean;
    /**
     * Save files to the file system.
     * @default true
     */
    write?: boolean;
    /**
     * Specifies the formatting tool to be used.
     * @default prettier
     *
     * Possible values:
     * - 'prettier': Uses Prettier for code formatting.
     * - 'biome': Uses Biome for code formatting.
     *
     */
    format?: 'prettier' | 'biome' | false;
    /**
     * Specifies the linter that should be used to analyze the code.
     * The accepted values indicate different linting tools.
     *
     * Possible values:
     * - 'eslint': Represents the use of ESLint, a widely used JavaScript linter.
     * - 'biome': Represents the Biome linter, a modern tool for code scanning.
     * - 'oxlint': Represents the Oxlint tool for linting purposes.
     *
     */
    lint?: 'eslint' | 'biome' | 'oxlint' | false;
    /**
     * Override the extension to the generated imports and exports, by default each plugin will add an extension
     * @default { '.ts': '.ts'}
     */
    extension?: Record<Extname, Extname | ''>;
    /**
     * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
     * @default 'named'
     */
    barrelType?: Exclude<BarrelType, 'propagate'> | false;
    /**
     * Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
     * - 'simple': will only add banner with link to Kubb
     * - 'full': will add source, title, description and the OpenAPI version used
     * @default 'simple'
     */
    defaultBanner?: 'simple' | 'full' | false;
  };
  /**
   * An array of Kubb plugins that will be used in the generation.
   * Each plugin may include additional configurable options(defined in the plugin itself).
   * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
   */
  plugins?: Array<Plugin>;
  /**
   * Hooks that will be called when a specific action is triggered in Kubb.
   */
  hooks?: {
    /**
     * Hook that will be triggered at the end of all executions.
     * Useful for running Prettier or ESLint to format/lint your code.
     */
    done?: string | Array<string>;
  };
};
type PluginFactoryOptions<
/**
 * Name to be used for the plugin, this will also be used for they key.
 */
TName extends string = string,
/**
 * Options of the plugin.
 */
TOptions extends object = object,
/**
 * Options of the plugin that can be used later on, see `options` inside your plugin config.
 */
TResolvedOptions extends object = TOptions,
/**
 * Context that you want to expose to other plugins.
 */
TContext = any,
/**
 * When calling `resolvePath` you can specify better types.
 */
TResolvePathOptions extends object = object> = {
  name: TName;
  /**
   * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
   */
  key: PluginKey<TName | string>;
  options: TOptions;
  resolvedOptions: TResolvedOptions;
  context: TContext;
  resolvePathOptions: TResolvePathOptions;
};
type PluginKey<TName> = [name: TName, identifier?: string | number];
type GetPluginFactoryOptions<TPlugin extends UserPlugin> = TPlugin extends UserPlugin<infer X> ? X : never;
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
  /**
   * Unique name used for the plugin
   * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
   * @example @kubb/typescript
   */
  name: TOptions['name'];
  /**
   * Options set for a specific plugin(see kubb.config.js), passthrough of options.
   */
  options: TOptions['resolvedOptions'];
  /**
   * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
   * Can be used to validate dependent plugins.
   */
  pre?: Array<string>;
  /**
   * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
   */
  post?: Array<string>;
} & (TOptions['context'] extends never ? {
  context?: never;
} : {
  context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
});
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
  /**
   * Unique name used for the plugin
   * @example @kubb/typescript
   */
  name: TOptions['name'];
  /**
   * Internal key used when a developer uses more than one of the same plugin
   * @private
   */
  key: TOptions['key'];
  /**
   * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
   * Can be used to validate dependent plugins.
   */
  pre?: Array<string>;
  /**
   * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
   */
  post?: Array<string>;
  /**
   * Options set for a specific plugin(see kubb.config.js), passthrough of options.
   */
  options: TOptions['resolvedOptions'];
} & (TOptions['context'] extends never ? {
  context?: never;
} : {
  context: TOptions['context'];
});
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
  /**
   * Start of the lifecycle of a plugin.
   * @type hookParallel
   */
  buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
  /**
   * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
   * Options can als be included.
   * @type hookFirst
   * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
   */
  resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
  /**
   * Resolve to a name based on a string.
   * Useful when converting to PascalCase or camelCase.
   * @type hookFirst
   * @example ('pet') => 'Pet'
   */
  resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
  /**
   * End of the plugin lifecycle.
   * @type hookParallel
   */
  buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
};
type PluginLifecycleHooks = keyof PluginLifecycle;
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
type ResolvePathParams<TOptions = object> = {
  pluginKey?: Plugin['key'];
  baseName: BaseName;
  mode?: Mode;
  /**
   * Options to be passed to 'resolvePath' 3th parameter
   */
  options?: TOptions;
};
type ResolveNameParams = {
  name: string;
  pluginKey?: Plugin['key'];
  /**
   * `file` will be used to customize the name of the created file(use of camelCase)
   * `function` can be used to customize the exported functions(use of camelCase)
   * `type` is a special type for TypeScript(use of PascalCase)
   * `const` can be used for variables(use of camelCase)
   */
  type?: 'file' | 'function' | 'type' | 'const';
};
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
  config: Config;
  fileManager: FileManager;
  pluginManager: PluginManager;
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
  resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
  resolveName: (params: ResolveNameParams) => string;
  logger: Logger;
  /**
   * All plugins
   */
  plugins: Plugin[];
  /**
   * Current plugin
   */
  plugin: Plugin<TOptions>;
};
/**
 * Specify the export location for the files and define the behavior of the output
 */
type Output<TOptions> = {
  /**
   * Path to the output folder or file that will contain the generated code
   */
  path: string;
  /**
   * Define what needs to be exported, here you can also disable the export of barrel files
   * @default 'named'
   */
  barrelType?: BarrelType | false;
  /**
   * Add a banner text in the beginning of every file
   */
  banner?: string | ((options: TOptions) => string);
  /**
   * Add a footer text in the beginning of every file
   */
  footer?: string | ((options: TOptions) => string);
};
type GroupContext = {
  group: string;
};
type Group = {
  /**
   * Define a type where to group the files on
   */
  type: 'tag' | 'path';
  /**
   * Return the name of a group based on the group name, this will be used for the file and name generation
   */
  name?: (context: GroupContext) => string;
};
//#endregion
//#region src/FileManager.d.ts
type FileMetaBase = {
  pluginKey?: Plugin['key'];
};
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
type AddIndexesProps = {
  type: BarrelType | false | undefined;
  /**
   * Root based on root and output.path specified in the config
   */
  root: string;
  /**
   * Output for plugin
   */
  output: {
    path: string;
  };
  group?: {
    output: string;
    exportAs: string;
  };
  logger?: Logger;
  meta?: FileMetaBase;
};
type WriteFilesProps = {
  root: Config['root'];
  extension?: Record<Extname, Extname | ''>;
  logger?: Logger;
  dryRun?: boolean;
};
declare class FileManager {
  #private;
  constructor();
  add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
  getByPath(path: Path): Promise<ResolvedFile | null>;
  deleteByPath(path: Path): Promise<void>;
  clear(): Promise<void>;
  getFiles(): Promise<Array<ResolvedFile>>;
  processFiles({
    dryRun,
    root,
    extension,
    logger
  }: WriteFilesProps): Promise<Array<ResolvedFile>>;
  getBarrelFiles({
    type,
    meta,
    root,
    output,
    logger
  }: AddIndexesProps): Promise<File[]>;
  static getMode(path: string | undefined | null): Mode;
}
type GetSourceOptions = {
  extname?: Extname;
  logger?: Logger;
};
declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, {
  logger,
  extname
}?: GetSourceOptions): Promise<string>;
//#endregion
//#region src/PluginManager.d.ts
type RequiredPluginLifecycle = Required<PluginLifecycle>;
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
  message: string;
  strategy: Strategy;
  hookName: H;
  plugin: Plugin;
  parameters?: unknown[] | undefined;
  output?: unknown;
};
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
  result: Result;
  plugin: Plugin;
};
type Options = {
  logger: Logger;
  /**
   * @default Number.POSITIVE_INFINITY
   */
  concurrency?: number;
};
type Events = {
  executing: [executer: Executer];
  executed: [executer: Executer];
  error: [error: Error];
};
type GetFileProps<TOptions = object> = {
  name: string;
  mode?: Mode;
  extname: Extname;
  pluginKey: Plugin['key'];
  options?: TOptions;
};
declare class PluginManager {
  #private;
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
  readonly fileManager: FileManager;
  readonly events: EventEmitter<Events>;
  readonly config: Config;
  readonly executed: Array<Executer>;
  readonly logger: Logger;
  readonly options: Options;
  constructor(config: Config, options: Options);
  getFile<TOptions = object>({
    name,
    mode,
    extname,
    pluginKey,
    options
  }: GetFileProps<TOptions>): File<{
    pluginKey: Plugin['key'];
  }>;
  resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
  resolveName: (params: ResolveNameParams) => string;
  /**
   * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
   */
  on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
  /**
   * Run a specific hookName for plugin x.
   */
  hookForPlugin<H extends PluginLifecycleHooks>({
    pluginKey,
    hookName,
    parameters,
    message
  }: {
    pluginKey: Plugin['key'];
    hookName: H;
    parameters: PluginParameter<H>;
    message: string;
  }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
  /**
   * Run a specific hookName for plugin x.
   */
  hookForPluginSync<H extends PluginLifecycleHooks>({
    pluginKey,
    hookName,
    parameters,
    message
  }: {
    pluginKey: Plugin['key'];
    hookName: H;
    parameters: PluginParameter<H>;
    message: string;
  }): Array<ReturnType<ParseResult<H>>> | null;
  /**
   * First non-null result stops and will return it's value.
   */
  hookFirst<H extends PluginLifecycleHooks>({
    hookName,
    parameters,
    skipped,
    message
  }: {
    hookName: H;
    parameters: PluginParameter<H>;
    skipped?: ReadonlySet<Plugin> | null;
    message: string;
  }): Promise<SafeParseResult<H>>;
  /**
   * First non-null result stops and will return it's value.
   */
  hookFirstSync<H extends PluginLifecycleHooks>({
    hookName,
    parameters,
    skipped,
    message
  }: {
    hookName: H;
    parameters: PluginParameter<H>;
    skipped?: ReadonlySet<Plugin> | null;
    message: string;
  }): SafeParseResult<H>;
  /**
   * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
   */
  hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
    hookName,
    parameters,
    message
  }: {
    hookName: H;
    parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
    message: string;
  }): Promise<Awaited<TOuput>[]>;
  /**
   * Chains plugins
   */
  hookSeq<H extends PluginLifecycleHooks>({
    hookName,
    parameters,
    message
  }: {
    hookName: H;
    parameters?: PluginParameter<H>;
    message: string;
  }): Promise<void>;
  getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
  getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
  static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
}
//#endregion
export { BarrelType, Config, FileManager, FileMetaBase, GetPluginFactoryOptions, Group, InputData, InputPath, Output, Plugin, PluginContext, PluginFactoryOptions, PluginKey, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, PossiblePromise, ResolveNameParams, ResolvePathParams, UserConfig, UserPlugin, UserPluginWithLifeCycle, getSource };
//# sourceMappingURL=PluginManager-BSUDeUfP.d.ts.map