import { Plugin as Plugin_2 } from 'vite';

export declare type Arrayable<T> = T | T[];

export declare interface CompileOptions {
    format?: ModuleFormat;
    name?: string;
    filename?: string;
    generate?: 'dom' | 'ssr' | false;
    sourcemap?: object | string;
    outputFilename?: string;
    cssOutputFilename?: string;
    sveltePath?: string;
    dev?: boolean;
    accessors?: boolean;
    immutable?: boolean;
    hydratable?: boolean;
    legacy?: boolean;
    customElement?: boolean;
    tag?: string;
    css?: boolean;
    loopGuardTimeout?: number;
    namespace?: string;
    preserveComments?: boolean;
    preserveWhitespace?: boolean;
    cssHash?: CssHashGetter;
}

export declare type CssHashGetter = (args: {
    name: string;
    filename: string | undefined;
    css: string;
    hash: (input: string) => string;
}) => string;

export declare type MarkupPreprocessor = (options: {
    content: string;
    filename: string;
}) => Processed | Promise<Processed>;

export declare type ModuleFormat = 'esm' | 'cjs';

export declare interface Options {
    /** One or more minimatch patterns */
    include?: Arrayable<string>;
    /** One or more minimatch patterns */
    exclude?: Arrayable<string>;
    /**
     * By default, all ".svelte" files are compiled
     * @default ['.svelte']
     */
    extensions?: string[];
    /**
     * Optionally, preprocess components with svelte.preprocess:
     * \@see https://svelte.dev/docs#svelte_preprocess
     */
    preprocess?: Arrayable<PreprocessorGroup>;
    /** Emit Svelte styles as virtual CSS files for other plugins to process.
     * @default true
     */
    emitCss?: boolean;
    /** Options passed to `svelte.compile` method. */
    compilerOptions: Partial<CompileOptions>;
    onwarn?: undefined | false | ((warning: any, defaultHandler?: any) => void);
    /**
     * enable/disable hmr. You want this enabled.
     *
     * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     * DO NOT CUSTOMIZE SVELTE-HMR OPTIONS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING
     *
     *                             YOU HAVE BEEN WARNED
     * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     *
     * @default true for development, always false for production
     */
    hot?: undefined | boolean | {
        /**
         * preserve all local state
         * @default false
         */
        preserveLocalState?: boolean;
        /**
         * escape hatchs from preservation of local state
         * disable preservation of state for this component
         *
         * @default ['\@hmr:reset', '\@!hmr']
         */
        noPreserveStateKey?: string[];
        /**
         * enable preservation of state for all variables in this component
         *
         * @default '\@hmr:keep-all'
         */
        preserveAllLocalStateKey?: string;
        /**
         * enable preservation of state for a given variable (must be inline or
         * above the target variable or variables; can be repeated)
         *
         * @default '\@hmr:keep'
         */
        preserveLocalStateKey?: string;
        /**
         * don't reload on fatal error
         *
         * @default false
         */
        noReload?: boolean;
        /**
         * try to recover after runtime errors during component init
         *
         * @default true
         */
        optimistic?: boolean;
        /**
         * auto accept modules of components that have named exports (i.e. exports
         * from context="module")
         *
         * @default true
         */
        acceptNamedExports?: boolean;
        /**
         * auto accept modules of components have accessors (either accessors compile
         * option, or \<svelte:option accessors=\{true\} /\>) -- this means that if you
         * set accessors compile option globally, you must also set this option to
         * true, or no component will be hot reloaded (but there are a lot of edge
         * cases that HMR can't support correctly with accessors)
         *
         * @default true
         */
        acceptAccessors?: boolean;
        /**
         * only inject CSS instead of recreating components when only CSS changes
         *
         * @default true, but vite-plugin-svelte configures this automatically according to emitCss requirements
         */
        injectCss?: boolean;
        /**
         * to mitigate FOUC between dispose (remove stylesheet) and accept
         *
         * note: has no effect when emitCss is true (vite-plugin-svelte default)
         * @default 100
         */
        cssEjectDelay?: number;
        /**
         * Svelte Native mode
         *
         * @default false
         */
        native?: boolean;
        /**
         * name of the adapter import binding
         *
         * @default '___SVELTE_HMR_HOT_API_PROXY_ADAPTER'
         */
        importAdapterName?: string;
        /**
         * use absolute file paths to import runtime deps of svelte-hmr
         * (see https://github.com/rixo/svelte-hmr/issues/11)
         *
         * @default true
         */
        absoluteImports?: boolean;
        /**
         * disable runtime error overlay
         *
         * @default false
         */
        noOverlay?: boolean;
        /**
         * custom import path for hotApi
         */
        hotApi?: string;
        /**
         * custom path for adapter
         */
        adapter?: string;
    };
    /**
     * disable separate hmr update for css files via vite
     * @default false
     */
    disableCssHmr?: boolean;
    /**
     * do not return cached transform data
     * @default false
     */
    disableTransformCache?: boolean;
    /**
     * use vite as extra css preprocessor EXPERIMENTAL!
     * @default false
     */
    useVitePreprocess?: boolean;
}

export declare type Preprocessor = (options: {
    content: string;
    attributes: Record<string, string | boolean>;
    filename?: string;
}) => Processed | Promise<Processed>;

export declare interface PreprocessorGroup {
    markup?: MarkupPreprocessor;
    style?: Preprocessor;
    script?: Preprocessor;
}

export declare interface Processed {
    code: string;
    map?: string | object;
    dependencies?: string[];
    toString?: () => string;
}

declare function vitePluginSvelte(inlineOptions?: Partial<Options>): Plugin_2;
export default vitePluginSvelte;

export { }
