import { omit } from 'lodash-es';
import { ATTRIBUTE_CDATA, ATTRIBUTE_COMMENT, ATTRIBUTE_GROUP_KEY, ATTRIBUTE_TEXT, DECLARATION_TAG, TAG, } from '../constants';
export function getIndentationString(size, level) {
    return new Array(level * size + 1).join(' ');
}
export function hasBreakLines(elements) {
    return typeof elements === 'string' && elements.includes('\n');
}
export function isInlineTextElement(elements) {
    if (typeof elements === 'string') {
        return false;
    }
    return (elements.length === 1 &&
        ATTRIBUTE_TEXT in elements[0] &&
        !hasBreakLines(elements[0][ATTRIBUTE_TEXT]));
}
export function getTagType(tagKey) {
    switch (tagKey) {
        case ATTRIBUTE_TEXT:
        case ATTRIBUTE_CDATA:
        case ATTRIBUTE_COMMENT:
            return tagKey;
        default:
            return tagKey.startsWith('?') ? DECLARATION_TAG : TAG;
    }
}
export function getTagProps(element) {
    const attributes = element[ATTRIBUTE_GROUP_KEY];
    const elementWithoutAttributes = omit(element, ATTRIBUTE_GROUP_KEY);
    const [[tagKey, subElements]] = Object.entries(elementWithoutAttributes);
    const type = getTagType(tagKey);
    return { attributes, tagKey, subElements, type };
}
export function hasAttributes(attributes) {
    if (!attributes) {
        return false;
    }
    return Object.keys(attributes).length > 0;
}
//# sourceMappingURL=index.js.map