'use strict';

if (typeof window === 'undefined') {
    module.exports.window     = undefined;
    module.exports.realWindow = undefined;
}
else {
    // get wrapped window if using Shadow DOM polyfill

    module.exports.realWindow = window;

    // create a TextNode
    var el = window.document.createTextNode('');

    // check if it's wrapped by a polyfill
    if (el.ownerDocument !== window.document
        && typeof window.wrap === 'function'
        && window.wrap(el) === el) {
        // return wrapped window
        module.exports.window = window.wrap(window);
    }

    // no Shadow DOM polyfil or native implementation
    module.exports.window = window;
}

var isWindow = require('./isType').isWindow;

module.exports.getWindow = function getWindow (node) {
    if (isWindow(node)) {
        return node;
    }

    var rootNode = (node.ownerDocument || node);

    return rootNode.defaultView || rootNode.parentWindow || module.exports.window;
};

@@ -12,236 +12,84 @@
 ';%0A%0A
-if (typeof window === 'undefined') %7B%0A    module.exports.window     = undefined;%0A    module.exports.realWindow = undefined;%0A%7D%0Aelse %7B%0A    // get wrapped window if using Shadow DOM polyfill%0A%0A    module.exports.realWindow = window;%0A
+var isWindow = require('./isType').isWindow;%0A%0Avar isShadowDom = function() %7B
 %0A   
@@ -207,20 +207,23 @@
 ill%0A    
-if (
+return 
 el.owner
@@ -333,259 +333,80 @@
 = el
-) %7B%0A        // return wrapped window%0A        module.exports.window = window.wrap(window);%0A    %7D%0A%0A    // no Shadow DOM polyfil or native implementation%0A    module.exports.w
+;%0A%7D;%0A%0Avar win = %7B%0A%0A    window: undefined,%0A%0A    realW
 indow
- =
+:
  window
-;%0A%7D%0A%0Avar isWindow = require('./isType').isWindow;%0A%0Amodule.exports.
+,%0A%0A    
 getW
@@ -410,18 +410,17 @@
 etWindow
- =
+:
  functio
@@ -436,24 +436,28 @@
 ow (node) %7B%0A
+    
     if (isWi
@@ -474,24 +474,28 @@
 ) %7B%0A        
+    
 return node;
@@ -495,16 +495,20 @@
 n node;%0A
+    
     %7D%0A%0A 
@@ -506,24 +506,28 @@
      %7D%0A%0A    
+  
+  
 var rootNode
@@ -556,24 +556,28 @@
  %7C%7C node);%0A%0A
+    
     return r
@@ -628,30 +628,202 @@
  %7C%7C 
-module.exports.window;%0A%7D;%0A
+win.window;%0A    %7D%0A%7D;%0A%0Aif (typeof window !== 'undefined') %7B%0A    if (isShadowDom()) %7B%0A        win.window = window.wrap(window);%0A    %7D else %7B%0A        win.window = window;%0A    %7D%0A%7D%0A%0Amodule.exports = win;

clean up module implementation by removing conditional exports