"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAttributes = getAttributes;
exports.getSvgContent = getSvgContent;
exports.initState = initState;
exports.stringToHTML = stringToHTML;
/** 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;
    }, {});
}
/** 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, '');
}
/** Returns object with initial state values. */
function initState() {
    return { content: '', svgAttributes: {} };
}
/** Returns given HTML string as an HTML element. */
function stringToHTML(html) {
    const container = document.createElement('div');
    container.innerHTML = html;
    return container.firstElementChild;
}
//# sourceMappingURL=helpers.js.map