'use strict';

var _commonjsHelpers = require('../../../_virtual/_commonjsHelpers.js');
var index = require('../../../_virtual/index15.js');
var Utility = require('./Utility.js');
var XMLDOMImplementation = require('./XMLDOMImplementation.js');
var XMLDocument = require('./XMLDocument.js');
var XMLDocumentCB = require('./XMLDocumentCB.js');
var XMLStringWriter = require('./XMLStringWriter.js');
var XMLStreamWriter = require('./XMLStreamWriter.js');
var NodeType = require('./NodeType.js');
var WriterState = require('./WriterState.js');

var hasRequiredLib;

function requireLib () {
	if (hasRequiredLib) return index.__exports;
	hasRequiredLib = 1;
	// Generated by CoffeeScript 1.12.7
	(function() {
	  var NodeType$1, WriterState$1, XMLDOMImplementation$1, XMLDocument$1, XMLDocumentCB$1, XMLStreamWriter$1, XMLStringWriter$1, assign, isFunction, ref;

	  ref = Utility.__require(), assign = ref.assign, isFunction = ref.isFunction;

	  XMLDOMImplementation$1 = XMLDOMImplementation.__require();

	  XMLDocument$1 = XMLDocument.__require();

	  XMLDocumentCB$1 = XMLDocumentCB.__require();

	  XMLStringWriter$1 = XMLStringWriter.__require();

	  XMLStreamWriter$1 = XMLStreamWriter.__require();

	  NodeType$1 = NodeType.__require();

	  WriterState$1 = WriterState.__require();

	  index.__exports.create = function(name, xmldec, doctype, options) {
	    var doc, root;
	    if (name == null) {
	      throw new Error("Root element needs a name.");
	    }
	    options = assign({}, xmldec, doctype, options);
	    doc = new XMLDocument$1(options);
	    root = doc.element(name);
	    if (!options.headless) {
	      doc.declaration(options);
	      if ((options.pubID != null) || (options.sysID != null)) {
	        doc.dtd(options);
	      }
	    }
	    return root;
	  };

	  index.__exports.begin = function(options, onData, onEnd) {
	    var ref1;
	    if (isFunction(options)) {
	      ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
	      options = {};
	    }
	    if (onData) {
	      return new XMLDocumentCB$1(options, onData, onEnd);
	    } else {
	      return new XMLDocument$1(options);
	    }
	  };

	  index.__exports.stringWriter = function(options) {
	    return new XMLStringWriter$1(options);
	  };

	  index.__exports.streamWriter = function(stream, options) {
	    return new XMLStreamWriter$1(stream, options);
	  };

	  index.__exports.implementation = new XMLDOMImplementation$1();

	  index.__exports.nodeType = NodeType$1;

	  index.__exports.writerState = WriterState$1;

	}).call(_commonjsHelpers.commonjsGlobal);
	return index.__exports;
}

exports.__require = requireLib;
