import { wrapMinimal } from '../utils.js';
export function parseComHtmlFunc(codigo) {
    try {
        if (!codigo || !codigo.trim())
            return null;
        const tagRegex = /<(\/?)([A-Za-z][A-Za-z0-9]*)\b[^>]*>/g;
        const tags = {};
        let match;
        while ((match = tagRegex.exec(codigo)) !== null) {
            if (match[1] !== '/') {
                const name = match[2].toLowerCase();
                tags[name] = (tags[name] || 0) + 1;
            }
        }
        if (Object.keys(tags).length === 0)
            return null;
        const totalElements = Object.values(tags).reduce((a, b) => a + b, 0);
        return wrapMinimal('html', {
            tags,
            links: tags['a'] || 0,
            images: tags['img'] || 0,
            scripts: tags['script'] || 0,
            forms: tags['form'] || 0,
            inputs: tags['input'] || 0,
            totalElements,
            uniqueTags: Object.keys(tags).length,
            hasDoctype: /^<!DOCTYPE\s+/i.test(codigo.trim()),
            hasComments: /<!--[\s\S]*?-->/g.test(codigo),
            charset: (codigo.match(/charset=["']?([A-Za-z0-9-]+)/i) || [])[1] || null,
            lang: (codigo.match(/lang=["']([A-Za-z-]+)["']/i) || [])[1] || null,
        });
    }
    catch {
        return null;
    }
}
//# sourceMappingURL=html.js.map