import { z as Logger } from "./util-CsmUMRtR.js";
import { E as VivliostyleInlineConfig } from "./schema-DFj2EinN.js";
import { c as warnDeprecatedConfig, o as loadVivliostyleConfig, u as setupConfigFromFlags } from "./asset-DBj3nifv.js";
import { a as vsViewerPlugin, f as vsBrowserPlugin, g as resolveTaskConfig, o as vsStaticServePlugin, s as vsDevServerPlugin, v as mergeInlineConfig } from "./server-CbkA4XCo.js";
import * as v from "valibot";
import * as vite from "vite";
//#region src/vite-adapter.ts
async function createVitePlugin(inlineConfig = {}) {
	const parsedInlineConfig = v.parse(VivliostyleInlineConfig, inlineConfig);
	const viteLogger = vite.createLogger("info", { prefix: "[vivliostyle]" });
	Logger.setLogOptions({
		...parsedInlineConfig,
		logger: parsedInlineConfig.logger ?? {
			info: (msg) => viteLogger.info(msg, { timestamp: true }),
			warn: (msg) => viteLogger.warn(msg, { timestamp: true }),
			error: (msg) => viteLogger.error(msg, { timestamp: true })
		}
	});
	Logger.debug("inlineConfig %O", parsedInlineConfig);
	const vivliostyleConfig = await loadVivliostyleConfig(parsedInlineConfig) ?? setupConfigFromFlags(parsedInlineConfig);
	warnDeprecatedConfig(vivliostyleConfig);
	const { tasks, inlineOptions } = mergeInlineConfig(vivliostyleConfig, parsedInlineConfig);
	const config = resolveTaskConfig(tasks[0], inlineOptions);
	Logger.debug("config %O", config);
	return [
		vsDevServerPlugin({
			config,
			inlineConfig: parsedInlineConfig
		}),
		vsViewerPlugin({
			config,
			inlineConfig: parsedInlineConfig
		}),
		vsBrowserPlugin({
			config,
			inlineConfig: parsedInlineConfig
		}),
		vsStaticServePlugin({
			config,
			inlineConfig: parsedInlineConfig
		})
	];
}
//#endregion
export { createVitePlugin as t };

//# sourceMappingURL=vite-adapter-On_L0LUL.js.map