"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var allSvgElementNames_1 = require("./../../helpers/allSvgElementNames");
var createSvgElement_1 = require("./createSvgElement");
var getFlexId_1 = require("./getFlexId");
var getTypeAsString_1 = require("./getTypeAsString");
var normalizeName_1 = require("./normalizeName");
var updateElement_1 = require("./updateElement");
function createTagNode(domElement, virtualElement, parentVirtualElement, component) {
    var tagName = normalizeName_1.default(getTypeAsString_1.default(virtualElement));
    var flexId = getFlexId_1.default(virtualElement);
    var newDomElement;
    if (allSvgElementNames_1.default[tagName]) {
        newDomElement = createSvgElement_1.default(domElement, tagName);
    }
    else {
        newDomElement = domElement.ownerDocument.createElement(tagName);
    }
    if (!newDomElement.haiku) {
        newDomElement.haiku = {
            component: component,
        };
    }
    component.subcacheEnsure(flexId);
    var incomingKey = virtualElement.key ||
        (virtualElement.attributes && virtualElement.attributes.key);
    if (incomingKey !== undefined && incomingKey !== null) {
        newDomElement.haiku.key = incomingKey;
    }
    updateElement_1.default(newDomElement, virtualElement, domElement, parentVirtualElement, component, null);
    return newDomElement;
}
exports.default = createTagNode;
//# sourceMappingURL=createTagNode.js.map