"use strict";
// Generated by CoffeeScript 1.8.0
(typeof exports !== "undefined" && exports !== null ? exports : window).Settings = {
  _buffer: {},
  get: function(key) {
    if (! (key in this._buffer)) {
      return this._buffer[key] = (key in localStorage) ? JSON.parse(localStorage[key]) : this.defaults[key];
    }
    return this._buffer[key];
  },
  set: function(key, value) {
    this._buffer[key] = value;
    if (value === this.defaults[key]) {
      if (key in localStorage) {
        delete localStorage[key];
      }
      Sync.clear(key);
    } else {
      localStorage[key] = JSON.stringify(value);
      Sync.set(key, localStorage[key]);
    }
    if (key = this.postUpdateHooks[key]) {
      key.call(this, value);
    }
  },
  clear: function(key) {
    this.set(key, this.defaults[key]);
  },
  has: function(key) {
    return key in localStorage;
  },
  postUpdateHooks: {
    keyMappings: function(value) {
      Commands.clearKeyMappingsAndSetDefaults();
      Commands.parseCustomKeyMappings(value);
      refreshCompletionKeysAfterMappingSave();
    },
    searchEngines: function(value) {
      this.parseSearchEngines(value);
    },
    exclusionRules: function(value) {
      Exclusions.postUpdateHook(value);
    },
    showActionIcon: function(value) {
      setShouldShowActionIcon(value);
    },
    settingsVersion: function(value) {
      var key = "settingsVersion";
      this._buffer[key] = this.defaults[key];
      if (key in localStorage) {
        delete localStorage[key];
      }
      Sync.clear(key);
    }
  },
  _searchEnginesMap: undefined,
  parseSearchEngines: function(searchEnginesText) {
    var a, pairs, key, val, name, _i, _j, _k, _len, rColon = /:\s*(.+)/;
    var titles = {}, map = this._searchEnginesMap = { ":": titles };
    a = searchEnginesText.replace(/\\\n/g, '').split('\n');
    for (_i = 0, _len = a.length; _i < _len; _i++) {
      val = a[_i].trim();
      if (!val || val[0] === '#') continue;
      pairs = val.split(rColon, 4);
      if (pairs.length !== 3 || !(key = pairs[0].trimRight()) || !(val = pairs[1])) continue;
      pairs = key.split('|');
      _j = pairs.length;
      while (0 <= --_j) {
        if (!(key = pairs[_j].trim())) continue;
        _k = key.indexOf('=');
        if (_k > 0) {
          name = key.substring(_k + 1);
          key = key.substring(0, _k).trimRight();
          if (!key) continue;
          name = name.trimLeft() || key;
        } else if (_k < 0) {
          name = key;
        } else {
          continue;
        }
        map[key] = val;
        titles[key] = name;
      }
    }
  },
  getSearchEngines: function() {
    return this._searchEnginesMap;
  },
  defaults: {
    UILanguage: null,
    helpDialog_showAdvancedCommands: false,
    showActionIcon: false,
    vimSync: false,
    showOmniRelevancy: false,
    scrollStepSize: 100,
    smoothScroll: true,
    keyMappings: "# Insert your preferred key mappings here.",
    linkHintCharacters: "asdqwerzxcv",
    linkHintNumbers: "1234567890",
    filterLinkHints: false,
    hideHud: false,
    regexFindMode: false,
    findModeRawQuery: "",
    userDefinedCss: "",
    exclusionRules: [
      {
        pattern: "http*://mail.google.com/*",
        passKeys: ""
      }
    ],
    previousPatterns: "prev,previous,back,<,\u2190,\xab,\u226a,<<",
    nextPatterns: "next,more,>,\u2192,\xbb,\u226b,>>",
    searchUrl: "http://www.baidu.com/s?ie=utf-8&wd=%s",
    searchEngines: "w = Wikipedia (en-US):\\\n  http://www.wikipedia.org/w/index.php?search=%s\nba=Baidu|baidu=Baidu:\\\n  www.baidu.com/s?ie=utf-8&wd=%s",
    newTabUrl: "/index.html", // note: if changed, /pages/newtab.html also needs change.
    settingsVersion: Utils.getCurrentVersion()
  },
  ChromeInnerNewTab: "chrome-search://local-ntp/local-ntp.html"
};

@@ -388,75 +388,160 @@
     
-this._buffer%5Bkey%5D = value;%0A    if (value === this.defaults
+var ref = this.defaults%5Bkey%5D;%0A    if (value === ref %7C%7C (key in this.forceBoolean && value !== this.forceBoolean
 %5Bkey%5D)
+)
  %7B%0A
+      this._buffer%5Bkey%5D = ref;%0A
     
@@ -642,24 +642,58 @@
     %7D else %7B
+%0D%0A      this._buffer%5Bkey%5D = value;
 %0A      local
@@ -706,16 +706,22 @@
 e%5Bkey%5D =
+ ref =
  JSON.st
@@ -756,33 +756,19 @@
 et(key, 
-localStorage%5Bkey%5D
+ref
 );%0A    %7D
@@ -776,19 +776,19 @@
     if (
-key
+ref
  = this.
@@ -817,19 +817,19 @@
 %7B%0A      
-key
+ref
 .call(th
@@ -833,24 +833,29 @@
 (this, value
+, key
 );%0A    %7D%0A  %7D
@@ -1438,233 +1438,8 @@
 );%0D%0A
-    %7D,%0A    settingsVersion: function(value) %7B%0A      var key = %22settingsVersion%22;%0A      this._buffer%5Bkey%5D = this.defaults%5Bkey%5D;%0A      if (key in localStorage) %7B%0A        delete localStorage%5Bkey%5D;%0A      %7D%0A      Sync.clear(key);%0A
     
@@ -3625,16 +3625,192 @@
 ()%0A  %7D,%0A
+  // accept only if value === @forceBoolean%5Bkey%5D, so that we get boolean options%0A  forceBoolean: %7B%0A    settingsVersion: %22++%22,%0A    showActionIcon: true,%0A    vimSync: true%0D%0A  %7D,%0A
   Chrome

add a dict @forceBoolean to filter out error options