// Generated by IcedCoffeeScript 1.7.1-c
(function() {
  var db, env, iced, make_esc, session, __iced_k, __iced_k_noop;

  iced = require('iced-runtime').iced;
  __iced_k = __iced_k_noop = function() {};

  env = require('./env').env;

  db = require('./db').db;

  session = require('./session').session;

  make_esc = require('iced-error').make_esc;

  exports.reset = function(_arg, cb) {
    var c, esc, new_username, ___iced_passed_deferral, __iced_deferrals, __iced_k;
    __iced_k = __iced_k_noop;
    ___iced_passed_deferral = iced.findDeferral(arguments);
    new_username = _arg.new_username;
    esc = make_esc(cb, "setup.reset");
    (function(_this) {
      return (function(__iced_k) {
        __iced_deferrals = new iced.Deferrals(__iced_k, {
          parent: ___iced_passed_deferral,
          filename: "/Users/max/src/keybase/node-client/src/setup.iced",
          funcname: "reset"
        });
        session.logout(esc(__iced_deferrals.defer({
          lineno: 20
        })));
        __iced_deferrals._fulfill();
      });
    })(this)((function(_this) {
      return function() {
        (function(__iced_k) {
          __iced_deferrals = new iced.Deferrals(__iced_k, {
            parent: ___iced_passed_deferral,
            filename: "/Users/max/src/keybase/node-client/src/setup.iced",
            funcname: "reset"
          });
          db.unlink(esc(__iced_deferrals.defer({
            lineno: 21
          })));
          __iced_deferrals._fulfill();
        })(function() {
          c = env().config;
          c.set('user', null);
          if (new_username != null) {
            c.set('user.name', new_username);
          }
          (function(__iced_k) {
            __iced_deferrals = new iced.Deferrals(__iced_k, {
              parent: ___iced_passed_deferral,
              filename: "/Users/max/src/keybase/node-client/src/setup.iced",
              funcname: "reset"
            });
            c.write(esc(__iced_deferrals.defer({
              lineno: 25
            })));
            __iced_deferrals._fulfill();
          })(function() {
            return cb(null);
          });
        });
      };
    })(this));
  };

}).call(this);
