"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringToHTML = exports.initState = exports.getSvgContent = exports.getAttributes = void 0;
/** Returns an object with given element's HTML attributes. */
function getAttributes(element) {
    if (!element)
        return {};
    const attrs = Array.from(element.attributes);
    return attrs.reduce((props, attr) => {
        const { name, value } = attr;
        props[name] = value;
        return props;
    }, {});
}
exports.getAttributes = getAttributes;
/** Returns content of the SVG HTML string by stripping the svg tag. */
function getSvgContent(html = '') {
    return html.replace(/(<\/?svg(?:.|\n)*?>)|(\r\n|\n|\r)/gm, '');
}
exports.getSvgContent = getSvgContent;
/** Returns object with initial state values. */
function initState() {
    return { content: '', svgAttributes: {} };
}
exports.initState = initState;
/** Returns given HTML string as an HTML element. */
function stringToHTML(html) {
    const container = document.createElement('div');
    container.innerHTML = html;
    return container.firstElementChild;
}
exports.stringToHTML = stringToHTML;
//# sourceMappingURL=helpers.js.map