"use strict";
/**
 * Project Caffeine v0.1.1
 * Copyright (c) 2025-2026 Gitconomy Research
 *
 * SPDX-License-Identifier: MIT
 *
 * Contributors:
 * - 郭晧 <guohao@gitconomy.org> (Initial Author)
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateYamlFrontmatter = generateYamlFrontmatter;
const yaml_1 = __importDefault(require("yaml"));
/**
 * 根据文献对象和附加标签生成 YAML Frontmatter 字符串。
 * @param literature 文献对象
 * @param additionalTags 附加标签
 * @returns 包含 YAML 文档的字符串（以 "---\n" 包围）
 */
function generateYamlFrontmatter(literature, additionalTags = []) {
    const frontmatter = {
        title: literature.title,
        authors: literature.authors,
        abstract: literature.abstract,
        publication_year: literature.publication_year,
        citation_count: literature.citation_count,
        source: literature.source,
        doi: literature.doi,
        date_saved: new Date().toISOString().split('T')[0],
    };
    const tags = [...(literature.keywords || []), ...additionalTags];
    if (tags.length > 0) {
        frontmatter.tags = tags;
    }
    const cleanFrontmatter = Object.fromEntries(Object.entries(frontmatter).filter(([_, v]) => v !== undefined && v !== null));
    const yamlStr = yaml_1.default.stringify(cleanFrontmatter, { indent: 2 });
    return `---\n${yamlStr}---`;
}
//# sourceMappingURL=yamlHelper.js.map