import { otimizarSvgLikeSvgo } from '../engines/svgs.js';
import { corrigirPontuacaoECodigo, normalizarNewlinesFinais } from './commons.js';
export function formatarSvgMinimo(code) {
    try {
        if (!/<svg\b/i.test(code)) {
            return {
                ok: true,
                parser: 'svg',
                formatted: code,
                changed: false,
                reason: 'ignorado-conteudo-invalido'
            };
        }
        const opt = otimizarSvgLikeSvgo({
            svg: code,
            pretty: true
        });
        const { text: comPontuacao, stats } = corrigirPontuacaoECodigo(opt.data);
        const formatted = normalizarNewlinesFinais(comPontuacao);
        const baseline = normalizarNewlinesFinais(opt.data);
        const anyChanged = formatted !== baseline;
        return {
            ok: true,
            parser: 'svg',
            formatted,
            changed: anyChanged,
            reason: anyChanged ? `estilo-tutanus-svg(punct:${stats.pontuacaoRepetida},space:${stats.espacamentoIncorreto},ops:${stats.operadoresRelacionais})` : 'normalizacao-basica'
        };
    }
    catch {
        return {
            ok: true,
            parser: 'svg',
            formatted: code,
            changed: false,
            reason: 'ignorado-erro-parsing-use-otimizar-svg'
        };
    }
}
//# sourceMappingURL=svg.js.map