"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.seedTemplates = seedTemplates;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const COLORING_MANIFEST_PATH = path_1.default.resolve(__dirname, "../../../../templates/coloring/manifest.json");
function seedTemplates(db) {
    // 检查 coloring 模板是否已注册
    const existing = db
        .prepare("SELECT id FROM templates WHERE id = ?")
        .get("coloring");
    if (existing) {
        // 更新 manifest（开发阶段可能频繁变更）
        const manifest = fs_1.default.readFileSync(COLORING_MANIFEST_PATH, "utf-8");
        const manifestJson = JSON.parse(manifest);
        db.prepare("UPDATE templates SET manifest = ?, name = ?, updated_at = datetime('now') WHERE id = ?").run(manifest, manifestJson.name, "coloring");
        console.log("[db] Template 'coloring' updated");
        return;
    }
    // 首次注册
    const manifest = fs_1.default.readFileSync(COLORING_MANIFEST_PATH, "utf-8");
    const manifestJson = JSON.parse(manifest);
    db.prepare("INSERT INTO templates (id, name, manifest) VALUES (?, ?, ?)").run("coloring", manifestJson.name, manifest);
    console.log("[db] Template 'coloring' seeded");
}
//# sourceMappingURL=seed.js.map