"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get html () {
        return html;
    },
    get toSingleLine () {
        return toSingleLine;
    }
});
const _array = require("../helpers/array");
function toSingleLine(strings, ...expressions) {
    const result = (0, _array.arrayReduce)(strings, (previousValue, currentValue, index)=>{
        const valueWithoutWhiteSpaces = currentValue.replace(/\r?\n\s*/g, '');
        const expressionForIndex = expressions[index] ? expressions[index] : '';
        return previousValue + valueWithoutWhiteSpaces + expressionForIndex;
    }, '');
    return result.trim();
}
function html(strings, ...values) {
    // eslint-disable-next-line no-restricted-globals
    const template = document.createElement('template');
    template.innerHTML = strings.reduce((acc, string, i)=>{
        return acc + string + (values[i] ?? '');
    }, '');
    const fragment = template.content.cloneNode(true);
    const refs = {};
    fragment.querySelectorAll('[data-ref]').forEach((element)=>{
        const name = element.getAttribute('data-ref');
        element.removeAttribute('data-ref');
        refs[name] = element;
    });
    return {
        fragment,
        refs
    };
} /* eslint-enable jsdoc/require-description-complete-sentence */ 
