define(function(require, exports, module) {
    window.require('babel-polyfill');
	var gui = window.require('nw.gui');
	var win = gui.Window.get();
	var fs = window.require("fs");
	var nwPath = window.require('path');
	var jsUtil = window.require('../../common/js/jsUtil');
	var moment = window.require("moment");
	var transliteration = window.require('transliteration');
	var Q = window.require("q");
	var linkParser = window.require("../../common/js/linkParser");
	var schedule = window.require("node-schedule");
	
	var hotfixMgr = window.require('../../common/js/hotfixMgr');
	
	var devices = window.require("../../common/js/deviceLinkMgr");
	var devicesIns = new devices();
    var dbIns = devicesIns.getDbInstance();
	//请求协助建立通道的类
	var remoteAssistant = window.require("../../common/js/remoteAssistant");
    
    // 所有TFTP服务器的操作，都调用下面的类
    //var tftpServer = window.require('../../common/js/tftpServer');
    //var tftpServerIns = new tftpServer();
    
    //// 所有ftp服务器的操作，都调用下面的类
    //var ftpServer = window.require('../../common/js/ftpServer');
    //var ftpServiceIns = new ftpServer();
    
    var runningEnv = window.require("../../common/js/runningEnv");
    var envIns = new runningEnv();
	
	var tftpOperate = window.require("../../common/js/OneCollect");
	var tftpOperateInstance = new tftpOperate(devicesIns, dbIns, statInfoIns);
	
	var diagDirector = window.require("../../common/js/diagDirector");
	var diagDirectorIns = undefined;

	var deviceConf= window.require("../../common/js/deviceConf");   //动态调用，不需要静态包含
	var deviceConfIns = new deviceConf();

	var diagnosis = window.require("../../common/js/diagnosis");
	var diagnosisIns = new diagnosis();

	var diagFixer = window.require("../../common/js/diagFixer");
	var diagFixerIns = undefined;

	var diaRollbacker = window.require("../../common/js/diaRollbacker");
	var diaRollbackerIns = undefined;
	
	//var logDb = window.require("../../common/js/diagLogDb"); 
	//var logDbIns = new logDb(dbIns);
	
	//var logUploadDb = window.require("../../common/js/diagUploadLogDb"); 
 //   var logUploadDbIns = new logUploadDb(dbIns);

    var operDb = window.require('../../common/js/operDb');
    var operDbIns = new operDb(dbIns);
    
    var noticeDb = window.require('../../common/js/noticeDb');
    var noticeDbIns = new noticeDb(dbIns);
    
    var offlineDbMgr = window.require('../../common/js/offlineDbMgr');

	var logger = window.require('../../common/js/Logger');
	var log = logger.getLogger('oneUpgrade');
	var uuid = window.require('node-uuid');
	var childProcess = window.require('child_process');
	
	var oneUpgrade = window.require("../../common/js/oneUpgrade");
	var oneUpgradeIns = new oneUpgrade(devicesIns);
	
//	var hotFixUpgrade = window.require("../../common/js/hotFixUpgrade");
//	var hotFixUpgradeIns = new hotFixUpgrade(devicesIns);

	var cmdMigration = window.require("../../common/js/cmdMigration");
	var cmdMigrationIns = new cmdMigration();

	var configMgr = window.require("../../common/js/ConfigMgr");
	var configMgrIns = new configMgr();
	
	var childToolMgr = window.require("../../common/js/childToolMgr");
	var childToolMgrIns = new childToolMgr();
	
//	var restoreConnect = window.require('../../common/js/restoreConnect');
//    var restoreConnectIns = new restoreConnect();
	
	var restore = window.require('../../common/js/restore');
    var restoreIns = new restore(devicesIns);
	var PingTools=window.require('../../common/js/PingTools');
	var pingToolIns=new PingTools();
	
	var TopoTools=window.require('../../common/js/topologyDiscovery');
	var TopoToolIns=new TopoTools();
	
    var userMgr = window.require('../../common/js/userMgr');
    var userMgrIns = new userMgr(jsUtil.getDataPath(), jsUtil.getPkgInfo().spec.info.cloudUrl + '/api',
        jsUtil.getPkgInfo().spec.info.maccHost, jsUtil.getPkgInfo().needAccount);
    //var userMgrIns = new userMgr(jsUtil.getDataPath(), 'http://192.168.23.124:8080/cloud/api');

    exports.syncer = window.require('../../common/js/syncer');

    exports.hzLauncher = window.require('../../common/js/hzLauncher');

    exports.qrcodeBuilder = window.require('../../common/js/qrcodeBuilder');
       
    var isLoadOnUpgrading = false; //正在升级的标志，该变量为true则菜单点击没有反应
	
	//当前点击的菜单id
	var curClickPageId = null;
	var pageIdToUrl = {
			".main_content" : {
				"#deviceManageMenu"  : "./deviceManage/html/deviceManage.html",
				"#faultDiagMenu"     : "./faultDiagMenu/html/faultDiagMenu.html",
				"#logDiagMenu"       : "./logDiag/html/logDiag.html",
				"#oneUpgradeMenu"    : "./oneUpgrade/html/oneUpgradeMenu.html",
				"#softCenterMenu"    : "./softCenter/html/softCenter.html",
				"#requestAssistance" : "./remoteAssistance/html/requestAssistance.html",
				"#acceptAssistance"  : "./remoteAssistance/html/acceptAssistance.html"
			},
			".selectDeviceContent" : {
				"#intelligentDiag"  : "./faultDiagMenu/html/selectDevice.html",
				"#diagLog"          : "./faultDiagMenu/html/diagLog.html",
				"#uploadLog"        : "./faultDiagMenu/html/uploadLog.html",
				"#diagLegend"       : "./faultDiagMenu/html/diagLegend.html",
				"#definedCollect"   : "./faultDiagMenu/html/selectDevice.html",
				"#logDownload"      : "./faultDiagMenu/html/logDownload.html"
			}
	};
	
	//在select中添加option
	function addOption(val, text, id) {
	    var $option = $("<option>");
	    if (val !== undefined) {
	    	$option.val(val);
	    }
	    $option.text(text);
	    $("#" + id).append($option);
	}
	
	var exitPageCallback = {};
	function enterPageCallback(curElement, nextPageUrl) {
		var permitExit = true;
		if (exitPageCallback.exitFun != undefined) {
			permitExit = exitPageCallback.exitFun();
		}
		if (permitExit) {
			$(curElement).load(nextPageUrl,function(){
				if($("#definedCollect").hasClass("curSelectItem")){
					$(".curStep .curStepText .curStepDiv").eq(1).text("配置收集参数");
					$(".curStep .curStepText .curStepDiv").eq(2).text("收集中");
					$(".curStep .curStepText .curStepDiv").eq(3).text("收集完成");
				}
			});
		}
	}
	
    exports.devicesIns = devicesIns;
    //exports.tftpServerIns = tftpServerIns;
    //exports.ftpServiceIns = ftpServiceIns;
    
    exports.envIns = envIns;

	exports.tftpOperateInstance = tftpOperateInstance;
	exports.fs = fs;
	exports.nwPath = nwPath;
    exports.jsUtil = jsUtil;
	exports.moment = moment;
	exports.schedule = schedule;
	exports.transliteration = transliteration;
	exports.diagDirector = diagDirector;
	exports.diagDirectorIns = diagDirectorIns;
	exports.deviceConfIns = deviceConfIns;
	exports.diagnosisIns = diagnosisIns;
	exports.diagFixer = diagFixer;
	exports.diagFixerIns = diagFixerIns;
	exports.diaRollbacker = diaRollbacker;
	exports.diaRollbackerIns = diaRollbackerIns;

	//exports.logDbIns = logDbIns;
 //   exports.logUploadDbIns = logUploadDbIns;

    exports.operDbIns = operDbIns;
    exports.noticeDbIns = noticeDbIns;
	exports.remoteAssistant = remoteAssistant;
	
	exports.log = log;
	exports.uuid = uuid;
	exports.childProcess = childProcess;
	exports.oneUpgradeIns = oneUpgradeIns;
//	exports.hotFixUpgradeIns = hotFixUpgradeIns;
	
	exports.linkParser = linkParser;
	
	exports.win = win;
	exports.cmdMigrationIns = cmdMigrationIns;
	exports.configMgrIns = configMgrIns;
    exports.offlineDbMgr = offlineDbMgr;
	
	exports.childToolMgrIns = childToolMgrIns;
	
	exports.addOption = addOption;
	
	exports.exitPageCallback = exitPageCallback;
	exports.enterPageCallback = enterPageCallback;
	
	exports.curClickPageId = curClickPageId;
	exports.pageIdToUrl = pageIdToUrl;
	
	exports.Q = Q;
    exports.restoreIns = restoreIns;
    exports.userMgrIns = userMgrIns;
	exports.pingToolIns=pingToolIns;
	exports.TopoToolIns=TopoToolIns;
	
	exports.isLoadOnUpgrading = isLoadOnUpgrading;
	
    exports.hotfixMgr = hotfixMgr;

    exports.hotFixUpgrade = window.require("../../common/js/hotFixUpgrade");
	
	exports.guide = false;
	
	exports.haveNerVersion = false;
});