_uiReplace(ui) {
    _a.log("trace", "Ui:_uiReplace", "Starting")();
    ui.components.forEach((compToReplace, i) => {
      _a.log("trace", `Ui:_uiReplace:components-forEach:${i}`, "Component to replace: ", compToReplace)();
      let elToReplace;
      if (compToReplace.id) {
        elToReplace = _a.doc.getElementById(compToReplace.id);
      } else if (compToReplace.selector || compToReplace.select) {
        elToReplace = _a.doc.querySelector(compToReplace.selector);
      } else if (compToReplace.name) {
        elToReplace = _a.doc.querySelector(`[name="${compToReplace.name}"]`);
      } else if (compToReplace.type) {
        elToReplace = _a.doc.querySelector(compToReplace.type);
      }
      _a.log("trace", `Ui:_uiReplace:components-forEach:${i}`, "Element to replace: ", elToReplace)();
      if (elToReplace === void 0 || elToReplace === null) {
        _a.log("trace", `Ui:_uiReplace:components-forEach:${i}:noReplace`, "Cannot find the DOM element. Adding instead.", compToReplace)();
        this._uiAdd({ components: [compToReplace] }, false);
        return;
      }
      let newEl;
      switch (compToReplace.type) {
        // If trying to insert raw html, wrap in a div
        case "html": {
          compToReplace.ns = "html";
          newEl = _a.doc.createElement("div");
          break;
        }
        // If trying to insert raw svg, need to create in namespace
        case "svg": {
          compToReplace.ns = "svg";
          newEl = _a.doc.createElementNS("http://www.w3.org/2000/svg", "svg");
          break;
        }
        default: {
          compToReplace.ns = "dom";
          newEl = _a.doc.createElement(compToReplace.type);
          break;
        }
      }
      this._uiComposeComponent(newEl, compToReplace);
      elToReplace.replaceWith(newEl);
      if (compToReplace.components) {
        this._uiExtendEl(newEl, compToReplace.components, compToReplace.ns);
      }
    });
  }
Handle incoming _ui replace requests
@param {*} ui Standardised msg._ui property object. Note that payload and topic are appended to this object