"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.insertAt = exports.removeChildren = exports.prepend = exports.removeChild = exports.insertBeforeAt = exports.insertBefore = exports.appendChild = void 0;
function appendChild(node, newChild) {
    return node.appendChild(newChild);
}
exports.appendChild = appendChild;
function insertBefore(node, newChild, refChild) {
    return node.insertBefore(newChild, refChild);
}
exports.insertBefore = insertBefore;
function insertBeforeAt(node, newChild, at) {
    const nextChild = node.childNodes.item(at);
    return insertBefore(node, newChild, nextChild);
}
exports.insertBeforeAt = insertBeforeAt;
function removeChild(node, oldChild) {
    return node.removeChild(oldChild);
}
exports.removeChild = removeChild;
function prepend(node, newChild) {
    if (node instanceof Text) {
        return;
    }
    return node.prepend(newChild);
}
exports.prepend = prepend;
function removeChildren(element) {
    while (element.firstChild) {
        element.removeChild(element.lastChild);
    }
}
exports.removeChildren = removeChildren;
function insertAt(node, newChild, at) {
    const currentChild = node.childNodes.item(at);
    if (currentChild) {
        return insertBefore(node, newChild, currentChild);
    }
    else {
        return appendChild(node, newChild);
    }
}
exports.insertAt = insertAt;
//# sourceMappingURL=element.js.map