constructor (svgElem, optIdPrefix) {
    if (
      !svgElem ||
      !svgElem.tagName ||
      !svgElem.namespaceURI ||
      svgElem.tagName !== 'svg' ||
      svgElem.namespaceURI !== NS.SVG
    ) {
      throw new Error(
        'Error: svgedit.draw.Drawing instance initialized without a <svg> element'
      )
    }

    /**
     * The SVG DOM Element that represents this drawing.
     * @type {SVGSVGElement}
     */
    this.svgElem_ = svgElem

    /**
     * The latest object number used in this drawing.
     * @type {Integer}
     */
    this.obj_num = 0

    /**
     * The prefix to prepend to each element id in the drawing.
     * @type {string}
     */
    this.idPrefix = optIdPrefix || 'svg_'

    /**
     * An array of released element ids to immediately reuse.
     * @type {Integer[]}
     */
    this.releasedNums = []

    /**
     * The z-ordered array of Layer objects. Each layer has a name
     * and group element.
     * The first layer is the one at the bottom of the rendering.
     * @type {Layer[]}
     */
    this.all_layers = []

    /**
     * Map of all_layers by name.
     *
     * Note: Layers are ordered, but referenced externally by name; so, we need both container
     * types depending on which function is called (i.e. all_layers and layer_map).
     *
     * @type {PlainObject<string, Layer>}
     */
    this.layer_map = {}

    /**
     * The current layer being used.
     * @type {Layer}
     */
    this.current_layer = null

    /**
     * The nonce to use to uniquely identify elements across drawings.
     * @type {!string}
     */
    this.nonce_ = ''
    const n = this.svgElem_.getAttributeNS(NS.SE, 'nonce')
    // If already set in the DOM, use the nonce throughout the document
    // else, if randomizeIds(true) has been called, create and set the nonce.
    if (n && randIds !== RandomizeModes.NEVER_RANDOMIZE) {
      this.nonce_ = n
    } else if (randIds === RandomizeModes.ALWAYS_RANDOMIZE) {
      this.setNonce(Math.floor(Math.random() * 100001))
    }
  }
@param {SVGSVGElement} svgElem - The SVG DOM Element that this JS object
    encapsulates.  If the svgElem has a se:nonce attribute on it, then
    IDs will use the nonce as they are generated.
@param {string} [optIdPrefix=svg_] - The ID prefix to use.
@throws {Error} If not initialized with an SVG element