text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = void 0;
  
  var _generated = require("../validators/generated");
  
  var _generated2 = require("../builders/generated");
  
  var _default = toStatement;
  exports.default = _default;
  
  function toStatement(node, ignore) {
    if ((0, _generated.isStatement)(node)) {
      return node;
    }
  
    let mustHaveId = false;
    let newType;
  
    if ((0, _generated.isClass)(node)) {
      mustHaveId = true;
      newType = "ClassDeclaration";
    } else if ((0, _generated.isFunction)(node)) {
      mustHaveId = true;
      newType = "FunctionDeclaration";
    } else if ((0, _generated.isAssignmentExpression)(node)) {
      return (0, _generated2.expressionStatement)(node);
    }
  
    if (mustHaveId && !node.id) {
      newType = false;
    }
  
    if (!newType) {
      if (ignore) {
        return false;
      } else {
        throw new Error(`cannot turn ${node.type} to a statement`);
      }
    }
  
    node.type = newType;
    return node;
  }