(function () {
  "use strict";

  angular
    .module('mnWizard')
    .controller('mnTermsAndConditionsController', mnTermsAndConditionsController);

  function mnTermsAndConditionsController($scope, $state, mnWizardService, pools, mnPromiseHelper, mnClusterConfigurationService, mnSettingsClusterService, mnAuthService, mnServersService ) {
    var vm = this;

    vm.isEnterprise = pools.isEnterprise;
    vm.onSubmit = onSubmit;
    vm.finishWithDefault = finishWithDefault;


    mnWizardService.getTermsAndConditionsState().version = (pools.implementationVersion || 'unknown');
    vm.register = mnWizardService.getTermsAndConditionsState();
    activate();
    function activate() {
      var promise;
      if (vm.isEnterprise) {
        promise = mnWizardService.getEELicense();
      } else {
        promise = mnWizardService.getEELicense();
      }

      mnPromiseHelper(vm, promise)
        .showSpinner()
        .applyToScope("license");

    }

    function finishWithDefault() {
      vm.form.agree.$setValidity('required', !!vm.agree);

      if (vm.form.$invalid) {
        return;
      }

      var index_settings = mnSettingsClusterService.getIndexSettings()
      index_settings.storageMode = 'forestdb'

      mnClusterConfigurationService
        .postStats(vm.register, true).then(function () {
          mnSettingsClusterService
            .postIndexSettings(index_settings).then(function () {
              mnServersService
                .setupServices({services: 'kv,index,fts,n1ql'}).then(function () {
                  var newClusterState = mnWizardService.getNewClusterState();
                  var data = mnClusterConfigurationService.getNewClusterConfig();
                  mnSettingsClusterService
                    .postPoolsDefault(data, false, newClusterState.clusterName).then(function () {
                      mnClusterConfigurationService
                        .postAuth(newClusterState.user).then(function () {
                          return mnAuthService
                            .login(newClusterState.user).then(function () {
                              return $state.go('app.admin.overview');
                            })
                        });
                    })
                });
            });
        });
    }

    function onSubmit() {
      vm.form.agree.$setValidity('required', !!vm.agree);

      if (vm.form.$invalid) {
        return;
      }
      $state.go('app.wizard.clusterConfiguration');
    }
  }
})();

@@ -1113,318 +1113,95 @@
     
-var index_settings = mnSettingsClusterService.getIndexSettings()%0A      index_settings.storageMode = 'forestdb'%0A%0A      mnClusterConfigurationService%0A        .postStats(vm.register, true).then(function () %7B%0A          mnSettingsClusterService%0A            .postIndexSettings(index_settings).then(function () %7B%0A    
+mnClusterConfigurationService%0A        .postStats(vm.register, true).then(function () %7B%0A
     
@@ -1215,36 +1215,32 @@
 nServersService%0A
-    
             .set
@@ -1312,28 +1312,24 @@
             
-    
 var newClust
@@ -1394,20 +1394,28 @@
     
- 
-   
 var 
-data
+newClusterConfig
  = m
@@ -1476,28 +1476,24 @@
             
-    
 mnSettingsCl
@@ -1500,29 +1500,115 @@
 usterService
-%0A    
+.postIndexSettings(newClusterConfig.indexSettings);%0A              mnSettingsClusterService%0A
             
@@ -1633,12 +1633,24 @@
 ult(
-data
+newClusterConfig
 , fa
@@ -1720,20 +1720,16 @@
         
-    
 mnCluste
@@ -1742,36 +1742,32 @@
 gurationService%0A
-    
                 
@@ -1839,28 +1839,24 @@
             
-    
 return mnAut
@@ -1888,20 +1888,16 @@
         
- 
-   
 .login(n
@@ -1958,28 +1958,24 @@
             
-    
 return $stat
@@ -2006,39 +2006,8 @@
 ');%0A
-                            %7D)%0A
     
@@ -2052,16 +2052,17 @@
       %7D)
+;
 %0A       

send storageMode correctly when setting up with the default settings