'use strict';

import React from "react";
import ReactDOM from "react-dom";
import ReactDOMServer from "react-dom/server";
import * as ReactRedux from "react-redux";
import * as Redux from "redux";
import undoable, {ActionCreators} from "redux-undo";
import * as ReactRouter from "react-router";
import * as MobX from "mobx";

//If you don't need rendering to strings comment out the following line

//If you don't use Redux comment out the following lines

//If you don't use React Router comment out the following line

//If you don't MobX comment out the following line

//Export the base React packages to the Window object for GWT to access
window.React = React;
window.ReactDOM = ReactDOM;

//If you don't need rendering to strings comment out the following line
window.ReactDOMServer = ReactDOMServer;

//If you don't use Redux comment out the following lines
window.Redux = Redux;
window.ReactRedux = ReactRedux;
window.ReduxUndo = {"ActionCreators": ActionCreators, "undoable": undoable};

//If you don't use React Router comment out the following line
window.ReactRouter = ReactRouter;

//If you don't use MobX comment out the following line
window.MobX = MobX;

//*****************************************************************************
// Support JS required for GWT React
//*****************************************************************************

var GWTReact = {};

GWTReact.makeSpec = function(componentObj) {
    var prototype = componentObj.__proto__;
    var spec = {
        getState: function() {
            return this.state;
        }
        ,getProps: function() {
            return this.props;
        },
        getRef: function(refId) {
            return this.refs[refId];
        }
    };

    for (var p in prototype) {
        if (p != 'constructor' && prototype.hasOwnProperty(p)) {
            spec[p] = prototype[p];
            // console.log("proto fn " + p);
        }
    }

    for (p in componentObj) {
        if (p != 'constructor' && componentObj.hasOwnProperty(p)) {
            spec[p] = componentObj[p];
            //console.log("obj prop " + p);
        }
    }
    //console.log("");
    return spec;
};

GWTReact.g = function(obj, field) {
    return obj[field];
};

GWTReact.s = function(obj, field, val) {
    obj[field] = val;
};

GWTReact.ca = function() {
    return [];
}

GWTReact.hasProp = function (obj, key) {
    return obj[key] !== undefined;
};

GWTReact.remProp = function (obj, key) {
    delete  obj[key] !== undefined;
};

GWTReact.props = function (obj) {
    var o = [];

    for (var prop in obj) {
        if (obj.hasOwnProperty(prop)) o.push(prop);
    }

    return o;
};

GWTReact.values = function (obj) {
    var o = [];
    for (var prop in obj) {
        if (obj.hasOwnProperty(prop)) {
            o.push(this[prop]);
        }
    }
    return o;
};

GWTReact.cast = function(obj) {
    return obj;
};

GWTReact.merge = function(obj1, obj2) {
    return Object.assign({}, obj1, obj2);
};

GWTReact.except = function(obj, exclude) {
    var out = {};
    var exludeMap = {};

    for(var i = 0; i < exclude.length; i++) {
        exludeMap[exclude[i]] = true;
    }

    for (var p in obj) {
        if (!exludeMap[p] && obj.hasOwnProperty(p)) {
            out[p] = obj[p];
        }
    }

    return out;
};

window.GWTReact = GWTReact;



@@ -72,258 +72,8 @@
 om%22;
-%0Aimport ReactDOMServer from %22react-dom/server%22;%0Aimport * as ReactRedux from %22react-redux%22;%0Aimport * as Redux from %22redux%22;%0Aimport undoable, %7BActionCreators%7D from %22redux-undo%22;%0Aimport * as ReactRouter from %22react-router%22;%0Aimport * as MobX from %22mobx%22;
 %0A%0A//
@@ -133,32 +133,79 @@
 e following line
+%0Aimport ReactDOMServer from %22react-dom/server%22;
 %0A%0A//If you don't
@@ -246,16 +246,144 @@
 ng lines
+%0Aimport * as ReactRedux from %22react-redux%22;%0Aimport * as Redux from %22redux%22;%0Aimport undoable, %7BActionCreators%7D from %22redux-undo%22;
 %0A%0A//If y
@@ -434,24 +434,69 @@
 llowing line
+%0Aimport * as ReactRouter from %22react-router%22;
 %0A%0A//If you d
@@ -535,16 +535,46 @@
 ing line
+%0Aimport * as MobX from %22mobx%22;
 %0A%0A//Expo
@@ -2333,16 +2333,17 @@
 rn %5B%5D;%0A%7D
+;
 %0A%0AGWTRea
@@ -2468,25 +2468,24 @@
  delete 
- 
 obj%5Bkey%5D
  !== und
@@ -2472,38 +2472,24 @@
 ete obj%5Bkey%5D
- !== undefined
 ;%0A%7D;%0A%0AGWTRea

Fix format caused by optimize imports