/*
Explenation:
DOM port of E4XasSAX
use the document root to initialise it
338016
function saxParser(elem, callbacks){
	if(typeof callbacks !== 'object')
		throw 'please provide callbacks!';

	//todo: support further events, options for trim & space normalisation
	
	function parse(node){
		var name = node.tagName.toLowerCase(),
		    attributeNodes = node.attributes;
		
		callbacks.onopentagname(name);
		
		for(var i = 0, j = attributeNodes.length; i < j; i++){
			callbacks.onattribute(attributeNodes[i].name+'', attributeNodes[i].value);
		}
		
		var childs = node.childNodes,
		    num = childs.length, nodeType;
		
		for(var i = 0; i < num; i++){
			nodeType = childs[i].nodeType;
			if(nodeType === 3 /*text*/)
				callbacks.ontext(childs[i].textContent);
			else if(nodeType === 1 /*element*/) parse(childs[i]);
			/*else if(nodeType === 8) //comment
				if(callbacks.oncomment) callbacks.oncomment(childs[i].toString());
			[...]
			*/
		}
		callbacks.onclosetag(name);
	}
	
	parse(elem);
}
542130
protected void initTemplates(Element root, CmsXmlContentDefinition contentDefinition) {

        String strEnabledByDefault = root.attributeValue(ATTR_ENABLED_BY_DEFAULT);
        m_allowedTemplates.setDefaultMembership(safeParseBoolean(strEnabledByDefault, true));
        List<Node> elements = root.selectNodes(APPINFO_TEMPLATE);
        for (Node elem : elements) {
            boolean enabled = safeParseBoolean(((Element)elem).attributeValue(ATTR_ENABLED), true);
            String templateName = elem.getText().trim();
            m_allowedTemplates.setContains(templateName, enabled);
        }
        m_allowedTemplates.freeze();
    }
222672
def load_dom(self, domtree, initialize=True):
        
        if domtree.nodeType == Node.DOCUMENT_NODE:
            rootElement = domtree.documentElement
        elif domtree.nodeType == Node.ELEMENT_NODE:
            rootElement = domtree
        else:
            raise InvalidManifestError("Invalid root element node type " + 
                                       str(rootElement.nodeType) + 
                                       " - has to be one of (DOCUMENT_NODE, "
                                       "ELEMENT_NODE)")
        allowed_names = ("assembly", "assemblyBinding", "configuration", 
                         "dependentAssembly")
        if rootElement.tagName not in allowed_names:
            raise InvalidManifestError(
                "Invalid root element <%s> - has to be one of <%s>" % 
                (rootElement.tagName, ">, <".join(allowed_names)))
        # logger.info("loading manifest metadata from element <%s>", rootElement.tagName)
        if rootElement.tagName == "configuration":
            for windows in rootElement.getCEByTN("windows"):
                for assemblyBinding in windows.getCEByTN("assemblyBinding"):
                    self.load_dom(assemblyBinding, initialize)
        else:
            if initialize:
                self.__init__()
            self.manifestType = rootElement.tagName
            self.manifestVersion = [int(i) 
                                    for i in 
                                    (rootElement.getA("manifestVersion") or 
                                     "1.0").split(".")]
            self.noInheritable = bool(rootElement.getFCEByTN("noInheritable"))
            self.noInherit = bool(rootElement.getFCEByTN("noInherit"))
            for assemblyIdentity in rootElement.getCEByTN("assemblyIdentity"):
                self.type = assemblyIdentity.getA("type") or None
                self.name = assemblyIdentity.getA("name") or None
                self.language = assemblyIdentity.getA("language") or None
                self.processorArchitecture = assemblyIdentity.getA(
                    "processorArchitecture") or None
                version = assemblyIdentity.getA("version")
                if version:
                    self.version = [int(i) for i in version.split(".")]
                self.publicKeyToken = assemblyIdentity.getA("publicKeyToken") or None
            for publisherPolicy in rootElement.getCEByTN("publisherPolicy"):
                self.applyPublisherPolicy = (publisherPolicy.getA("apply") or 
                                             "").lower() == "yes"
            for description in rootElement.getCEByTN("description"):
                if description.firstChild:
                    self.description = description.firstChild.wholeText
            for trustInfo in rootElement.getCEByTN("trustInfo"):
                for security in trustInfo.getCEByTN("security"):
                    for reqPriv in security.getCEByTN("requestedPrivileges"):
                        for reqExeLev in reqPriv.getCEByTN("requestedExecutionLevel"):
                            self.requestedExecutionLevel = reqExeLev.getA("level")
                            self.uiAccess = (reqExeLev.getA("uiAccess") or 
                                             "").lower() == "true"
            if rootElement.tagName == "assemblyBinding":
                dependencies = [rootElement]
            else:
                dependencies = rootElement.getCEByTN("dependency")
            for dependency in dependencies:
                for dependentAssembly in dependency.getCEByTN(
                    "dependentAssembly"):
                    manifest = ManifestFromDOM(dependentAssembly)
                    if not manifest.name:
                        # invalid, skip
                        continue
                    manifest.optional = (dependency.getA("optional") or 
                                         "").lower() == "yes"
                    self.dependentAssemblies.append(manifest)
                    if self.filename:
                        # Enable search for private assembly by assigning bogus 
                        # filename (only the directory has to be correct)
                        self.dependentAssemblies[-1].filename = ":".join(
                            (self.filename, manifest.name))
            for bindingRedirect in rootElement.getCEByTN("bindingRedirect"):
                oldVersion = [[int(i) for i in part.split(".")] 
                              for part in 
                              bindingRedirect.getA("oldVersion").split("-")]
                newVersion = [int(i) 
                              for i in 
                              bindingRedirect.getA("newVersion").split(".")]
                self.bindingRedirects.append((oldVersion, newVersion))
            for file_ in rootElement.getCEByTN("file"):
                self.add_file(name=file_.getA("name"),
                              hashalg=file_.getA("hashalg"),
                              hash=file_.getA("hash"))
182317
private void internalizeDocument(Document document) throws ParseException {
    init();

    // temporarily remove the database listeners
    List<IDatabaseListener> tmpListeners = new ArrayList<>(listeners);
    listeners.clear();

    Hashtable<String, String> keyMap = new Hashtable<>();

    try {
      Element rootElement = document.getRootElement();
      List<Attribute> rootAttrs = rootElement.getAttributes();

      // extract the master language and put all other root element
      // attributes aside
      for (Attribute attribute : rootAttrs) {
        if (MASTER_LANGUAGE_ATTRIBUTE_NAME.equals(attribute.getName())) {
          masterLanguage = attribute.getValue();
        } else {
          additionalRootAttrs.add(attribute);
        }
      }

      // store additional namespaces. the xsi namespace is used for the attribute xsi:noSchemaNamespaceLocation
      for (Object namespace : rootElement.getAdditionalNamespaces()) {
        // The list is not type save, therefore a cast is done
        if (namespace instanceof Namespace) {
          additionalNamespaces.add((Namespace) namespace);
        } else {
          throw new RuntimeException("Namespace List contains Objects that are not of type Namespace");
        }
      }

      if (masterLanguage == null) {
        // since we cannot determine the line numbers in this methods
        // we pass 0 to occuring ParseExceptions
        throw new ParseException("Master language missing.", 0);
      }

      List<Element> textList = rootElement.getChildren(TEXT_ELEMENT_NAME);

      // the validation in here is kind of unnecessary when the xsd is used for validation.
      // however the xsd validation was added later and it cant hurt to doublecheck some things, there might be cases
      // where the xsd cannot be used
      for (Element textElement : textList) {
        String key = textElement.getAttributeValue(KEY_ATTRIBUTE_NAME);
        if (key == null) {
          throw new ParseException("No key found for text.",
              ((LineNumberElement) textElement).getStartLine());
        }

        if (keyMap.containsKey(key)) {
          parseWarnings.add(new ParseWarning("Duplicate key: " + key,
              ((LineNumberElement) textElement).getStartLine()));
        } else {
          keyMap.put(key, "");
        }

        String context = textElement.getChildText(CONTEXT_ELEMENT_NAME);
        if (context == null) {
          throw new ParseException("No context found for key \"" + key + "\".",
              ((LineNumberElement) textElement).getStartLine());
        }

        ITextNode textNode = new XMLTextNode(key, context);
        addTextNode(textNode);

        List<Element> valueList = textElement.getChildren(VALUE_ELEMENT_NAME);
        for (Element valueElement : valueList) {
          String language = valueElement.getAttributeValue(LANGUAGE_ATTRIBUTE_NAME);
          if (language == null) {
            throw new ParseException("No language found for value of key \"" + key + "\".",
                ((LineNumberElement) valueElement).getStartLine());
          }
          String statusName = valueElement.getAttributeValue(STATUS_ATTRIBUTE_NAME);
          Status status = Status.valueOf(statusName);
          if (status == null) {
            throw new ParseException("Invalid status for key \"" + key + "\": " + statusName,
                ((LineNumberElement) valueElement).getStartLine());
          }
          String value = valueElement.getText();
          textNode.addValueNode(new XMLValueNode(language, status, value));
        }
      }
    } finally {
      listeners.addAll(tmpListeners);
    }
  }
281335
function(e) {
		var win = null,
			doc = null,
			target = e.target,
			type = target.nodeType;
		if (gui.Type.isDefined(type)) {
			doc = (type === Node.DOCUMENT_NODE ? target : target.ownerDocument);
			win = doc.defaultView;
		} else {
			win = target;
			doc = win.document;
		}
		this.event = e;
		this.window = win;
		this.document = doc;
		this.documentspirit = doc.documentElement.spirit;
	}
135043
function () {

	var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];

	function xhr () {
		if (typeof XMLHttpRequest !== "undefined") {
			// rewrite the getXhr method to always return the native implementation
			xhr = function () { return new XMLHttpRequest(); };
		}
		else {
			// keep trying progIds until we find the correct one, then rewrite the getXhr method
			// to always return that one.
			var noXhr = xhr = function () {
					throw new Error("getXhr(): XMLHttpRequest not available");
				};
			while (progIds.length > 0 && xhr === noXhr) (function (id) {
				try {
					new ActiveXObject(id);
					xhr = function () { return new ActiveXObject(id); };
				}
				catch (ex) {}
			}(progIds.shift()));
		}
		return xhr();
	}

	function fetchText (url, callback, errback) {
		var x = xhr();
		x.open('GET', url, true);
		x.onreadystatechange = function (e) {
			if (x.readyState === 4) {
				if (x.status < 400) {
					callback(x.responseText);
				}
				else {
					errback(new Error('fetchText() failed. status: ' + x.statusText));
				}
			}
		};
		x.send(null);
	}

	function error (ex) {
		throw ex;
	}

	return {

//		'normalize': function (resourceId, toAbsId) {
//			// remove options
//			return resourceId ? toAbsId(resourceId.split("!")[0]) : resourceId;
//		},

		load: function (resourceName, req, callback, config) {
			// remove suffixes (future)
			// get the text
			fetchText(req['toUrl'](resourceName), callback, callback['error'] || error);
		},

		'plugin-builder': './builder/text'

	};

}
1192729
function Document(options) {
	Node.call(this, {
		nodeName: '#document',
		nodeType: 9,
		parseOptions: options
	});

	this.documentElement = new Element({
		nodeName: 'HTML',
		ownerDocument: this,
		parseOptions: options
	});

	this.defaultView = options && options.defaultView || null;
	this.childNodes = [this.documentElement];
}
319595
function getXmlElementFromRawIndexes(root, indexInfo) {
  let parentPackage = root;
  for (let j = 0; j < indexInfo.path.length; j++) {
    parentPackage = parentPackage.packagedElement[indexInfo.path[j]];
  }
  return parentPackage.packagedElement[indexInfo.index];
}
492421
function $E(tag, props) {
    var elem = document.createElement(tag);
    for(var p in props) {
      if(typeof props[p] == "object") {
        $.extend(elem[p], props[p]);
      } else {
        elem[p] = props[p];
      }
    }
    if (tag == "canvas" && !supportsCanvas && G_vmlCanvasManager) {
      elem = G_vmlCanvasManager.initElement(document.body.appendChild(elem));
    }
    return elem;
  }
888646
function componentMount(tag$$1, dom, expressions, opts) {
      var __ = tag$$1.__;
      var root = __.root;
      root._tag = tag$$1; // keep a reference to the tag just created

      // Read all the attrs on this instance. This give us the info we need for updateOpts
      parseAttributes.apply(__.parent, [root, root.attributes, function (attr, expr) {
        if (!__.isAnonymous && RefExpr.isPrototypeOf(expr)) { expr.tag = tag$$1; }
        attr.expr = expr;
        __.instAttrs.push(attr);
      }]);

      // update the root adding custom attributes coming from the compiler
      walkAttributes(__.impl.attrs, function (k, v) { __.implAttrs.push({name: k, value: v}); });
      parseAttributes.apply(tag$$1, [root, __.implAttrs, function (attr, expr) {
        if (expr) { expressions.push(expr); }
        else { setAttribute(root, attr.name, attr.value); }
      }]);

      // initialiation
      updateOpts.apply(tag$$1, [__.isLoop, __.parent, __.isAnonymous, opts, __.instAttrs]);

      // add global mixins
      var globalMixin = mixin(GLOBAL_MIXIN);

      if (globalMixin && !__.skipAnonymous) {
        for (var i in globalMixin) {
          if (globalMixin.hasOwnProperty(i)) {
            tag$$1.mixin(globalMixin[i]);
          }
        }
      }

      if (__.impl.fn) { __.impl.fn.call(tag$$1, opts); }

      if (!__.skipAnonymous) { tag$$1.trigger('before-mount'); }

      // parse layout after init. fn may calculate args for nested custom tags
      each(parseExpressions.apply(tag$$1, [dom, __.isAnonymous]), function (e) { return expressions.push(e); });

      tag$$1.update(__.item);

      if (!__.isAnonymous && !__.isInline) {
        while (dom.firstChild) { root.appendChild(dom.firstChild); }
      }

      define(tag$$1, 'root', root);

      // if we need to wait that the parent "mount" or "updated" event gets triggered
      if (!__.skipAnonymous && tag$$1.parent) {
        var p = getImmediateCustomParent(tag$$1.parent);
        p.one(!p.isMounted ? 'mount' : 'updated', function () {
          setMountState.call(tag$$1, true);
        });
      } else {
        // otherwise it's not a child tag we can trigger its mount event
        setMountState.call(tag$$1, true);
      }

      tag$$1.__.wasCreated = true;

      return tag$$1
    }
277574
function initPjax() {
    $(document).pjax('a', '#pjax-container');

    $(document).on('pjax:start', function() {
        NProgress.start();
    });

    $(document).on('pjax:end', function() {
        NProgress.done();
    });
}
1248570
function ( evt ) {
                if ( $B.ua.DOC_MODE_IE9_LT ) {
                    this.pageX = function ( evt ) {
                        var eDoc = evt.target.ownerDocument || document,
                            docEl = eDoc.documentElement,
                            body = eDoc.body;
    
                        return evt.clientX + ( docEl && docEl.scrollLeft || body && body.scrollLeft || 0 );
                    };
                } else {
                    this.pageX = function ( evt ) { return evt.pageX; };
                }
                return this.pageX( evt );
            }
75885
function (ui, opts) {
    
		log("xxmlmirror.init");

		var $el = $(ui);
		var state = ($("div.xmlmirrorstate:first", $el).html() || "").trim();
		opts = $.extend({ defaultScript: state }, opts);

		$el.html(template.trim());

		var editor = null;
		(function iframeImplementation() {
			var iframe = $("iframe", ui);

			editor = ns.widgets.xmleditorInitIframe(iframe);

		})();

		if (opts.defaultScript) {
			editor.set(ns.modules.string.htmlDecode(opts.defaultScript));
		}

		var me = {};
		me.refresh = function () { editor.refresh(); };
		me.getXml = function () {
			var code = editor.get();
			return code;
		};
		me.setXml = function (xml) {
			editor.set(xml);
		};

		return me;
	}
510867
protected function initRootElement()
    {
        if ($this->domDocument->hasChildNodes()) {
            foreach ($this->domDocument->childNodes as $node) {
                if ($node instanceof \DOMElement) {
                    $this->rootElement = $this->getElementHandler($node, $this);
                    break;
                }
            }
        } else {
            throw new \InvalidArgumentException('Document seems to be invalid', __LINE__);
        }
    }
1205006
function initBBox(props, eventType) {
  // eslint-disable-line no-unused-vars
  var docBBox = getBBox(document.documentElement),
      elementBBox = props.elementBBox = props.initElm(props),
      // reset offset etc.
  containmentBBox = props.containmentBBox = props.containmentIsBBox ? resolvePPBBox(props.options.containment, docBBox) || docBBox : getBBox(props.options.containment, true);
  props.minLeft = containmentBBox.left;
  props.maxLeft = containmentBBox.right - elementBBox.width;
  props.minTop = containmentBBox.top;
  props.maxTop = containmentBBox.bottom - elementBBox.height;
  // Adjust position
  move(props, { left: elementBBox.left, top: elementBBox.top });
}
934482
function execObjectBindingHandlerOnNode(bindingKeyAndHandler, node, getValueAccessor, allBindings, bindingContext, reportBindingError) {
      var handlerInitFn = bindingKeyAndHandler.handler["init"],
          handlerUpdateFn = bindingKeyAndHandler.handler["update"],
          bindingKey = bindingKeyAndHandler.key,
          controlsDescendantBindings = false;

      // Run init, ignoring any dependencies
      if (typeof handlerInitFn === "function") {
          try {
              ignore(function() {
                  var initResult = handlerInitFn(node, getValueAccessor(bindingKey), allBindings, bindingContext.$data, bindingContext);

                  // If this binding handler claims to control descendant bindings, make a note of this
                  if (initResult && initResult.controlsDescendantBindings) {
                      controlsDescendantBindings = true;
                  }
              });
          } catch(ex) {
              reportBindingError('init', ex);
          }
      }

      // Run update in its own computed wrapper
      if (typeof handlerUpdateFn === "function") {
          computed(
              function() {
                  try {
                      handlerUpdateFn(node, getValueAccessor(bindingKey), allBindings, bindingContext.$data, bindingContext);
                  } catch (ex) {
                      reportBindingError('update', ex);
                  }
              },
              null,
              { disposeWhenNodeIsRemoved: node }
          );
      }
      return controlsDescendantBindings;
  }
375133
function _onGetDocument(event, res) {
        Inspector.DOMDebugger.setDOMBreakpoint(res.root.nodeId, "subtree-modified");
        _load.resolve();
    }