"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildLinkObject = buildLinkObject;
const constants_1 = require("./constants.js");
function buildLinkObject(elem) {
    let obj = null;
    if (elem.tagName === 'IMG') {
        obj = {
            type: 'image',
            name: elem.getAttribute('alt'),
            link: elem.getAttribute('src') ?? '',
        };
    }
    else if (elem.tagName === 'A') {
        obj = {
            type: 'link',
            name: elem.getAttribute('title'),
            link: elem.getAttribute('href') ?? '',
        };
        if (elem.classList.contains(constants_1.YfmFileClassname)) {
            obj.type = 'file';
            obj.name = elem.getAttribute(constants_1.YfmFileAttrs.Download);
            obj.mimetype = elem.getAttribute(constants_1.YfmFileAttrs.Type);
        }
    }
    return obj;
}
//# sourceMappingURL=helpers.js.map
