System.register(["src/external/lodash/lodash.js", "src/client/fileindex.js"], function (_export, _context) {
  "use strict";

  var _, FileIndex;

  return {
    setters: [function (_srcExternalLodashLodashJs) {
      _ = _srcExternalLodashLodashJs.default;
    }, function (_srcClientFileindexJs) {
      FileIndex = _srcClientFileindexJs.default;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_client_search_roots_js = _recorder_._src_client_search_roots_js || {};
      Object.defineProperty(_recorder_._src_client_search_roots_js, "_", {
        get() {
          return _;
        },

        set(thisIsVererySecretVariableName) {
          _ = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._src_client_search_roots_js, "FileIndex", {
        get() {
          return FileIndex;
        },

        set(thisIsVererySecretVariableName) {
          FileIndex = thisIsVererySecretVariableName;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      class SearchRoots {

        static getSearchRoots() {
          return lively.preferences.get("ExtraSearchRoots");
        }

        static setSearchRoots(roots) {
          return lively.preferences.set("ExtraSearchRoots", roots);
        }

        /*
         * add url to local file index rember to search there  
         */
        static addSearchRoot(url) {
          var roots = this.getSearchRoots();
          roots = _.uniq(roots.concat([url]));
          this.setSearchRoots(roots);
          return this.updateSearchRoot(url);
        }

        static updateSearchRoot(url) {
          return FileIndex.current().addDirectory(url);
        }

        static removeSearchRoot(url) {
          var roots = this.getSearchRoots();
          roots = roots.filter(ea => ea != url);
          this.setSearchRoots(roots);
          FileIndex.current().removeDirectory(url);
        }

        static isSearchRoot(url) {
          return this.getSearchRoots().find(ea => ea == url);
        }

        static async updateAllSearchRoots() {

          for (var ea of this.getSearchRoots()) {
            await this.updateSearchRoot(ea);
          }
        }
      }

      _export("default", SearchRoots);

      Object.defineProperty(_recorder_._src_client_search_roots_js, "SearchRoots", {
        get() {
          return SearchRoots;
        },

        set(thisIsVererySecretVariableName) {
          _export("default", SearchRoots = thisIsVererySecretVariableName);

          return true;
        },

        enumerable: true,
        configurable: true
      });
    }
  };
});