import { resolve } from 'node:path';
import { access, readFile } from 'node:fs/promises';
import { createJiti } from 'jiti';
import { seoConfigSchema } from '@ew53/seo-core';
/**
 * Load and validate seo.config.ts from the current working directory.
 */
export async function loadConfig(path = 'seo.config.ts') {
    const resolved = resolve(process.cwd(), path);
    try {
        await access(resolved);
    }
    catch {
        throw new Error(`Config not found at ${resolved}. Run \`seo-toolkit init\` first.`);
    }
    const jiti = createJiti(import.meta.url, { interopDefault: true });
    const mod = (await jiti.import(resolved));
    const raw = mod.default ?? mod;
    return seoConfigSchema.parse(raw);
}
/**
 * Load SEO_PLAYBOOK.md as a string.
 */
export async function loadPlaybook(path = 'SEO_PLAYBOOK.md') {
    const resolved = resolve(process.cwd(), path);
    return readFile(resolved, 'utf8');
}
//# sourceMappingURL=config-loader.js.map