"enable aexpr";

System.register(["active-expression-rewriting", "reactive-jsx", "src/components/widgets/lively-morph.js", "src/client/fileindex.js", "src/external/lodash/lodash.js", "src/client/strings.js", "src/client/bindings.js"], function (_export, _context) {
  "use strict";

  var _getAndCallMember, _setMember, _setLocal, _getLocal, _getGlobal, _getMember, _traceMember, _childSpread, _attributeEmpty, _childText, _childExpression, _attributeExpression, _childElement, _children, _attributeStringLiteral, _attributes, _element, Morph, FileIndex, _, Strings, Bindings;

  return {
    setters: [function (_activeExpressionRewriting) {
      _getAndCallMember = _activeExpressionRewriting.getAndCallMember;
      _setMember = _activeExpressionRewriting.setMember;
      _setLocal = _activeExpressionRewriting.setLocal;
      _getLocal = _activeExpressionRewriting.getLocal;
      _getGlobal = _activeExpressionRewriting.getGlobal;
      _getMember = _activeExpressionRewriting.getMember;
      _traceMember = _activeExpressionRewriting.traceMember;
    }, function (_reactiveJsx) {
      _childSpread = _reactiveJsx.childSpread;
      _attributeEmpty = _reactiveJsx.attributeEmpty;
      _childText = _reactiveJsx.childText;
      _childExpression = _reactiveJsx.childExpression;
      _attributeExpression = _reactiveJsx.attributeExpression;
      _childElement = _reactiveJsx.childElement;
      _children = _reactiveJsx.children;
      _attributeStringLiteral = _reactiveJsx.attributeStringLiteral;
      _attributes = _reactiveJsx.attributes;
      _element = _reactiveJsx.element;
    }, function (_srcComponentsWidgetsLivelyMorphJs) {
      Morph = _srcComponentsWidgetsLivelyMorphJs.default;
    }, function (_srcClientFileindexJs) {
      FileIndex = _srcClientFileindexJs.default;
    }, function (_srcExternalLodashLodashJs) {
      _ = _srcExternalLodashLodashJs.default;
    }, function (_srcClientStringsJs) {
      Strings = _srcClientStringsJs.default;
    }, function (_srcClientBindingsJs) {
      Bindings = _srcClientBindingsJs.default;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_components_tools_lively_index_search_js = _recorder_._src_components_tools_lively_index_search_js || {};
      let _scope = {};
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_tools_lively_index_search_js"), "Morph", {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "Morph", Morph) : void 0, Morph;
        },

        set(thisIsVererySecretVariableName) {
          let _scope2 = {};
          Morph = (self.__expressionAnalysisMode__ ? _getLocal(_scope2, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, "Morph", Morph, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 12,
              line: 3
            },
            start: {
              column: 7,
              line: 3
            },
            source: ''
          }) : void 0, Morph;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_tools_lively_index_search_js"), "FileIndex", {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "FileIndex", FileIndex) : void 0, FileIndex;
        },

        set(thisIsVererySecretVariableName) {
          let _scope3 = {};
          FileIndex = (self.__expressionAnalysisMode__ ? _getLocal(_scope3, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, "FileIndex", FileIndex, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 16,
              line: 4
            },
            start: {
              column: 7,
              line: 4
            },
            source: ''
          }) : void 0, FileIndex;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_tools_lively_index_search_js"), "_", {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "_", _) : void 0, _;
        },

        set(thisIsVererySecretVariableName) {
          let _scope4 = {};
          _ = (self.__expressionAnalysisMode__ ? _getLocal(_scope4, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, "_", _, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 8,
              line: 5
            },
            start: {
              column: 7,
              line: 5
            },
            source: ''
          }) : void 0, _;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_tools_lively_index_search_js"), "Strings", {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "Strings", Strings) : void 0, Strings;
        },

        set(thisIsVererySecretVariableName) {
          let _scope5 = {};
          Strings = (self.__expressionAnalysisMode__ ? _getLocal(_scope5, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, "Strings", Strings, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 14,
              line: 6
            },
            start: {
              column: 7,
              line: 6
            },
            source: ''
          }) : void 0, Strings;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_tools_lively_index_search_js"), "Bindings", {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "Bindings", Bindings) : void 0, Bindings;
        },

        set(thisIsVererySecretVariableName) {
          let _scope6 = {};
          Bindings = (self.__expressionAnalysisMode__ ? _getLocal(_scope6, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, "Bindings", Bindings, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 15,
              line: 7
            },
            start: {
              column: 7,
              line: 7
            },
            source: ''
          }) : void 0, Bindings;
          return true;
        },

        enumerable: true,
        configurable: true
      });


      /*MD # Search (and Replace) Tool MD*/

      class IndexSearch extends Morph {
        async initialize() {
          if (self.__expressionAnalysisMode__) _traceMember(this, "registerAttributes");

          this.registerAttributes(["pattern", "mode", "scope", "replace"]);
          _setMember(this, "windowTitle", "Search", {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 31,
              line: 14
            },
            start: {
              column: 4,
              line: 14
            },
            source: ''
          });
          if (self.__expressionAnalysisMode__) _traceMember(this, "registerButtons");
          this.registerButtons();
          _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("lively-separator")), "toggleCollapse", []);
          // this.get("lively-editor").hideToolbar();

          _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively), "html"), "registerInputs", [this]);

          if (self.__expressionAnalysisMode__) _traceMember(Bindings, "connect");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope, "Bindings", Bindings) : void 0, Bindings).connect(this, "scope", (self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#scopeInput")), "value");
          if (self.__expressionAnalysisMode__) _traceMember(Bindings, "connect");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope, "Bindings", Bindings) : void 0, Bindings).connect(this, "pattern", (self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchInput")), "value");
          if (self.__expressionAnalysisMode__) _traceMember(Bindings, "connect");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope, "Bindings", Bindings) : void 0, Bindings).connect(this, "replace", (self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#replaceInput")), "value");

          if (self.__expressionAnalysisMode__) _traceMember(this, "registerSignalEnter");
          this.registerSignalEnter(_getMember(this, "shadowRoot"));
          _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#replaceInput")), "addEventListener", ["enter-pressed", () => {
            return self.__expressionAnalysisMode__ ? _traceMember(this, "updateReplacePreview") : void 0, this.updateReplacePreview();
          }]);
          _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchInput")), "addEventListener", ["enter-pressed", () => {
            return self.__expressionAnalysisMode__ ? _traceMember(this, "onSearchButton") : void 0, this.onSearchButton();
          }]);
          _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#scopeInput")), "addEventListener", ["enter-pressed", () => {
            return self.__expressionAnalysisMode__ ? _traceMember(this, "onSearchButton") : void 0, this.onSearchButton();
          }]);

          // kick off search...
          if (_getMember(this, "pattern")) {
            await (self.__expressionAnalysisMode__ ? _traceMember(this, "search") : void 0, this.search());
          }

          _setMember(this, "__classFilePath__", "https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js", (self.__expressionAnalysisMode__ ? _getGlobal("undefined") : void 0, undefined));
        }

        /*MD ## HTML Element MD*/

        focus() {
          _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchInput")), "focus", []);
        }
        /*MD ## Events MD*/

        onScopeModeButton() {
          if (_getMember(this, "scope")) {
            if (self.__expressionAnalysisMode__) _traceMember(this, "removeAttribute");

            this.removeAttribute("scope");
          } else {
            _setMember(this, "scope", (self.__expressionAnalysisMode__ ? _getGlobal("lively4url") : void 0, lively4url), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 29,
                line: 47
              },
              start: {
                column: 6,
                line: 47
              },
              source: ''
            });
          }
        }

        onSearchButton() {
          if (self.__expressionAnalysisMode__) _traceMember(this, "search");

          this.search();
        }

        onReplaceModeButton() {
          if (_getMember(this, "mode") == "replace") {
            _setMember(this, "mode", (self.__expressionAnalysisMode__ ? _getGlobal("undefined") : void 0, undefined), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 27,
                line: 57
              },
              start: {
                column: 6,
                line: 57
              },
              source: ''
            });
          } else {
            _setMember(this, "mode", "replace", {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 27,
                line: 59
              },
              start: {
                column: 6,
                line: 59
              },
              source: ''
            });
          }
          if (self.__expressionAnalysisMode__) _traceMember(this, "search");
          this.search();
        }

        onReplaceInputEnter() {
          if (self.__expressionAnalysisMode__) _traceMember(this, "updateReplacePreview");

          this.updateReplacePreview();
        }

        async onReplaceButton() {
          if (self.__expressionAnalysisMode__) _traceMember(this, "replaceInFiles");


          this.replaceInFiles();
        }
        /*MD ## Search MD*/

        async search(text) {
          let _scope7 = {},
              _scope8 = {};
          if (self.__expressionAnalysisMode__) _traceMember(this, "clearLog");

          this.clearLog();
          if (self.__expressionAnalysisMode__ ? _getLocal(_scope7, "text", text) : void 0, text) {
            _setMember(this, "pattern", (self.__expressionAnalysisMode__ ? _getLocal(_scope7, "text", text) : void 0, text), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 25,
                line: 77
              },
              start: {
                column: 6,
                line: 77
              },
              source: ''
            });
          }

          if (!_getMember(this, "pattern") || _getMember(_getMember(this, "pattern"), "length") < 2) {
            if (self.__expressionAnalysisMode__) _traceMember(this, "log");

            this.log("please enter a longer search string");
            _setMember(this, "searchInProgres", false, {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 34,
                line: 82
              },
              start: {
                column: 6,
                line: 82
              },
              source: ''
            });
            return;
          }
          if (self.__expressionAnalysisMode__) _traceMember(this, "clearLog");
          this.clearLog();

          // check regular expression syntax
          try {
            new (self.__expressionAnalysisMode__ ? _getGlobal("RegExp") : void 0, RegExp)(_getMember(this, "pattern"));
          } catch (e) {
            if (self.__expressionAnalysisMode__) _traceMember(this, "log");

            this.log("" + (self.__expressionAnalysisMode__ ? _getLocal(_scope8, "e", e) : void 0, e));
            return;
          }

          _setMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchResults")), "innerHTML", "searching ..." + (self.__expressionAnalysisMode__ ? _traceMember(JSON, "stringify") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("JSON") : void 0, JSON).stringify(_getMember(this, "pattern"))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 89,
              line: 95
            },
            start: {
              column: 4,
              line: 95
            },
            source: ''
          });
          let start = (self.__expressionAnalysisMode__ ? _traceMember(Date, "now") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("Date") : void 0, Date).now());
          await (self.__expressionAnalysisMode__ ? _traceMember(this, "searchFilesList") : void 0, this.searchFilesList());
          _setMember(this, "searchInProgres", false, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 32,
              line: 98
            },
            start: {
              column: 4,
              line: 98
            },
            source: ''
          });
          if (self.__expressionAnalysisMode__) _traceMember(this, "clearLog");
          this.clearLog();
          //this.log('found');
          if (self.__expressionAnalysisMode__) _traceMember(this, "log");
          this.log(`finished in ${(self.__expressionAnalysisMode__ ? _traceMember(Date, "now") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("Date") : void 0, Date).now()) - (self.__expressionAnalysisMode__ ? _getLocal(_scope7, "start", start) : void 0, start)}ms`);
          await (self.__expressionAnalysisMode__ ? _traceMember(this, "updateSearchResults") : void 0, this.updateSearchResults());
        }

        /*
         * find all root directories/repositories that should be search by looking, what browsers/editors the user has opened
         */
        findRootsInBrowsers() {
          let _scope9 = {};

          var browsers = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("document") : void 0, document), "body"), "querySelectorAll", ["lively-container"]);
          var urls = (self.__expressionAnalysisMode__ ? _traceMember(browsers, "map") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope9, "browsers", browsers) : void 0, browsers).map(ea => {
            let _scope10 = {};
            return self.__expressionAnalysisMode__ ? _traceMember(ea, "getPath") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope10, "ea", ea) : void 0, ea).getPath();
          }));
          var serverURL = (self.__expressionAnalysisMode__ ? _traceMember(this, "serverURL") : void 0, this.serverURL());
          var rootURLs = _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(urls, "filter") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope9, "urls", urls) : void 0, urls).filter(ea => {
            let _scope11 = {};
            return self.__expressionAnalysisMode__ ? _traceMember(ea, "match") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope11, "ea", ea) : void 0, ea).match((self.__expressionAnalysisMode__ ? _getLocal(_scope9, "serverURL", serverURL) : void 0, serverURL));
          })), "map", [ea => {
            let _scope12 = {};

            var m = (self.__expressionAnalysisMode__ ? _traceMember(ea, "match") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope12, "ea", ea) : void 0, ea).match(new (self.__expressionAnalysisMode__ ? _getGlobal("RegExp") : void 0, RegExp)("(" + (self.__expressionAnalysisMode__ ? _getLocal(_scope9, "serverURL", serverURL) : void 0, serverURL) + "[^/]*/).*")));
            return (self.__expressionAnalysisMode__ ? _getLocal(_scope12, "m", m) : void 0, m) && _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope12, "m", m) : void 0, m), 1);
          }]);
          return self.__expressionAnalysisMode__ ? _traceMember(_, "uniq") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, "_", _) : void 0, _).uniq((self.__expressionAnalysisMode__ ? _getLocal(_scope9, "rootURLs", rootURLs) : void 0, rootURLs));
        }

        async searchFilesList(pattern = this.pattern) {
          let _scope13 = {};

          _setMember(this, "searchInProgres", true, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 31,
              line: 123
            },
            start: {
              column: 4,
              line: 123
            },
            source: ''
          });

          var search = new (self.__expressionAnalysisMode__ ? _getGlobal("RegExp") : void 0, RegExp)((self.__expressionAnalysisMode__ ? _getLocal(_scope13, "pattern", pattern) : void 0, pattern));
          var result = [];
          var scope = _getMember(this, "scope");
          var searchTime = await (self.__expressionAnalysisMode__ ? _traceMember(lively, "time") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).time(async () => {
            let _scope14 = {};

            var root = (self.__expressionAnalysisMode__ ? _getGlobal("lively4url") : void 0, lively4url); // there are other files in our cache... too 
            var roots = _getAndCallMember(_getAndCallMember([(self.__expressionAnalysisMode__ ? _getLocal(_scope14, "root", root) : void 0, root)], "concat", [_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively), "preferences"), "get", ["ExtraSearchRoots"])]), "concat", [(self.__expressionAnalysisMode__ ? _traceMember(this, "findRootsInBrowsers") : void 0, this.findRootsInBrowsers())]);
            return _getAndCallMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _traceMember(FileIndex, "current") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, "FileIndex", FileIndex) : void 0, FileIndex).current()), "db"), "files"), "each", [file => {
              let _scope15 = {};

              if ((self.__expressionAnalysisMode__ ? _traceMember(roots, "find") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope14, "roots", roots) : void 0, roots).find(eaRoot => {
                let _scope16 = {};
                return _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope15, "file", file) : void 0, file), "url"), "startsWith", [(self.__expressionAnalysisMode__ ? _getLocal(_scope16, "eaRoot", eaRoot) : void 0, eaRoot)]);
              })) && _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope15, "file", file) : void 0, file), "content") && (!(self.__expressionAnalysisMode__ ? _getLocal(_scope13, "scope", scope) : void 0, scope) || _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope15, "file", file) : void 0, file), "url"), "match", [(self.__expressionAnalysisMode__ ? _getLocal(_scope13, "scope", scope) : void 0, scope)]))) {
                var m = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope15, "file", file) : void 0, file), "content"), "match", [(self.__expressionAnalysisMode__ ? _getLocal(_scope13, "search", search) : void 0, search)]);
                if (self.__expressionAnalysisMode__ ? _getLocal(_scope15, "m", m) : void 0, m) {
                  if (self.__expressionAnalysisMode__) _traceMember(result, "push");

                  (self.__expressionAnalysisMode__ ? _getLocal(_scope13, "result", result) : void 0, result).push({ file: file, match: m });
                }
              }
            }]);
          }));

          var list = [];
          if (self.__expressionAnalysisMode__) _traceMember(result, "forEach");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope13, "result", result) : void 0, result).forEach(ea => {
            let _scope17 = {};
            if (self.__expressionAnalysisMode__) _traceMember(console, "log");

            (self.__expressionAnalysisMode__ ? _getGlobal("console") : void 0, console).log("found " + _getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope17, "ea", ea) : void 0, ea), "file"), "url"));
            var lines = _getAndCallMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope17, "ea", ea) : void 0, ea), "file"), "content"), "split", ["\n"]);
            if (self.__expressionAnalysisMode__) _traceMember(lines, "forEach");
            (self.__expressionAnalysisMode__ ? _getLocal(_scope17, "lines", lines) : void 0, lines).forEach((eaLine, index) => {
              let _scope18 = {};

              var m = (self.__expressionAnalysisMode__ ? _traceMember(eaLine, "match") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope18, "eaLine", eaLine) : void 0, eaLine).match((self.__expressionAnalysisMode__ ? _getLocal(_scope13, "pattern", pattern) : void 0, pattern)));
              if (self.__expressionAnalysisMode__ ? _getLocal(_scope18, "m", m) : void 0, m) {
                var lineNumber = (self.__expressionAnalysisMode__ ? _getLocal(_scope18, "index", index) : void 0, index);
                // var lineNumber = index + 1 // first line is "1"
                if (self.__expressionAnalysisMode__) _traceMember(list, "push");
                (self.__expressionAnalysisMode__ ? _getLocal(_scope13, "list", list) : void 0, list).push({
                  file: _getAndCallMember(_getAndCallMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope17, "ea", ea) : void 0, ea), "file"), "url"), "toString", []), "replace", [/[.*\/]/, ""]),
                  url: _getAndCallMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope17, "ea", ea) : void 0, ea), "file"), "url"), "toString", []),
                  line: lineNumber,
                  column: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope18, "m", m) : void 0, m), "index"),
                  text: eaLine,
                  indexed: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope17, "ea", ea) : void 0, ea), "file"),
                  selection: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope18, "m", m) : void 0, m), 0)
                });
              }
            });
          });
          _setMember(this, "files", (self.__expressionAnalysisMode__ ? _getLocal(_scope13, "list", list) : void 0, list), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 21,
              line: 162
            },
            start: {
              column: 4,
              line: 162
            },
            source: ''
          });
          _setMember(this, "searchInProgres", false, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 32,
              line: 163
            },
            start: {
              column: 4,
              line: 163
            },
            source: ''
          });
          return self.__expressionAnalysisMode__ ? _getLocal(_scope13, "list", list) : void 0, list;
        }

        async showSearchResult(url, lineAndColumn) {
          let _scope19 = {};

          var editor = (self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#editor"

          // unhide editor, when it is needed
          ));if (_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "editor", editor) : void 0, editor), "style"), "flexGrow") < 0.01) {
            // #Hack
            _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("lively-separator")), "toggleCollapse", []);
          }

          if (self.__expressionAnalysisMode__) _traceMember(editor, "setURL");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope19, "editor", editor) : void 0, editor).setURL((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "url", url) : void 0, url));
          await (self.__expressionAnalysisMode__ ? _traceMember(editor, "loadFile") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope19, "editor", editor) : void 0, editor).loadFile());

          var codeMirror = await (self.__expressionAnalysisMode__ ? _traceMember(editor, "awaitEditor") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope19, "editor", editor) : void 0, editor).awaitEditor());
          if (self.__expressionAnalysisMode__) _traceMember(codeMirror, "setSelection");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope19, "codeMirror", codeMirror) : void 0, codeMirror).setSelection({ line: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn), "line"), ch: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn), "column") }, { line: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn), "line"), ch: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn), "column") + (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn), "selection") ? +_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope19, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn), "selection"), "length") : 0) });
          if (self.__expressionAnalysisMode__) _traceMember(codeMirror, "focus");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope19, "codeMirror", codeMirror) : void 0, codeMirror).focus();
          if (self.__expressionAnalysisMode__) _traceMember(codeMirror, "scrollIntoView");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope19, "codeMirror", codeMirror) : void 0, codeMirror).scrollIntoView((self.__expressionAnalysisMode__ ? _traceMember(codeMirror, "getCursor") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope19, "codeMirror", codeMirror) : void 0, codeMirror).getCursor()), 200);
        }

        browseSearchResult(url, pattern) {
          let _scope20 = {};

          return self.__expressionAnalysisMode__ ? _traceMember(lively, "openBrowser") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).openBrowser((self.__expressionAnalysisMode__ ? _getLocal(_scope20, "url", url) : void 0, url), true, (self.__expressionAnalysisMode__ ? _getLocal(_scope20, "pattern", pattern) : void 0, pattern), (self.__expressionAnalysisMode__ ? _getGlobal("undefined") : void 0, undefined));
        }

        // #important
        async updateSearchResults(search = this.pattern) {
          let _scope22 = {};

          var list = (self.__expressionAnalysisMode__ ? _traceMember(_, "sortBy") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, "_", _) : void 0, _).sortBy(_getMember(this, "files"), ea => {
            let _scope21 = {};
            return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope21, "ea", ea) : void 0, ea), "url");
          }));
          let lastPrefix;
          for (var ea of (self.__expressionAnalysisMode__ ? _getLocal(_scope22, "list", list) : void 0, list)) {
            let _scope23 = {};

            let text = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "text");
            let url = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "url");
            let filename = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "file"), "replace", [/.*\//, ""]);
            let dirAndFilename = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "url"), "replace", [/.*\/([^/]+\/[^/]+$)/, "$1"]);
            let prefix = (self.__expressionAnalysisMode__ ? _traceMember(url, "replace") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "url", url) : void 0, url).replace((self.__expressionAnalysisMode__ ? _getLocal(_scope23, "dirAndFilename", dirAndFilename) : void 0, dirAndFilename), ""));
            if ((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "lastPrefix", lastPrefix) : void 0, lastPrefix) != (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "prefix", prefix) : void 0, prefix)) {
              _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchResults")), "appendChild", [_element("tr", _attributes(_attributeStringLiteral("class", "prefix")), _children(_childElement(_element("td", _attributes(_attributeStringLiteral("colspan", "3"), _attributeExpression("click", () => {
                _setMember(this, "scope", (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "prefix", prefix) : void 0, prefix), {
                  file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                  end: {
                    column: 36,
                    line: 203
                  },
                  start: {
                    column: 17,
                    line: 203
                  },
                  source: ''
                });
                if (self.__expressionAnalysisMode__) _traceMember(this, "search");
                this.search();
              })), _children(_childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope23, "prefix", prefix) : void 0, prefix))), {
                file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                end: {
                  column: 31,
                  line: 205
                },
                start: {
                  column: 67,
                  line: 202
                }
              }))), {
                file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                end: {
                  column: 36,
                  line: 205
                },
                start: {
                  column: 48,
                  line: 202
                }
              })]);
            }
            lastPrefix = (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "prefix", prefix) : void 0, prefix), true ? _setLocal(_scope22, "lastPrefix", lastPrefix, {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 25,
                line: 207
              },
              start: {
                column: 6,
                line: 207
              },
              source: ''
            }) : void 0, lastPrefix;
            let path = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "url"), "replace", [(self.__expressionAnalysisMode__ ? _traceMember(this, "serverURL") : void 0, this.serverURL()), ""]);
            let lineAndColumn = {
              line: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "line"),
              column: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "column"),
              selection: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "selection") };

            let link = _element("a", _attributes(_attributeExpression("href", _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "url")), _attributeExpression("title", _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "file")), _attributeExpression("click", evt => {
              let _scope24 = {};

              if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope24, "evt", evt) : void 0, evt), "shiftKey") || _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope24, "evt", evt) : void 0, evt), "ctrlKey")) {
                if (self.__expressionAnalysisMode__) _traceMember(this, "browseSearchResult");

                this.browseSearchResult((self.__expressionAnalysisMode__ ? _getLocal(_scope23, "url", url) : void 0, url), (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn));
              } else {
                if (self.__expressionAnalysisMode__) _traceMember(this, "showSearchResult");

                this.showSearchResult((self.__expressionAnalysisMode__ ? _getLocal(_scope23, "url", url) : void 0, url), (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "lineAndColumn", lineAndColumn) : void 0, lineAndColumn));
              }
              return false;
            })), _children(_childExpression((self.__expressionAnalysisMode__ ? _traceMember(dirAndFilename, "slice") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "dirAndFilename", dirAndFilename) : void 0, dirAndFilename).slice(0, 60)))), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 43,
                line: 221
              },
              start: {
                column: 17,
                line: 214
              }
            });

            let item = _element("tr", _attributes(), _children(_childText("\n          "), _childElement(_element("td", _attributes(_attributeStringLiteral("class", "filename")), _children(_childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope23, "link", link) : void 0, link))), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 42,
                line: 224
              },
              start: {
                column: 10,
                line: 224
              }
            })), _childText("\n          "), _childElement(_element("td", _attributes(_attributeStringLiteral("class", "line")), _children(_childExpression(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "line") + 1), _childText(":")), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 46,
                line: 225
              },
              start: {
                column: 10,
                line: 225
              }
            })), _childText("\n          "), _childElement(_element("td", _attributes(), _children(_childText("\n            "), _childExpression((self.__expressionAnalysisMode__ ? _traceMember(this, "hightlightPattern") : void 0, this.hightlightPattern((self.__expressionAnalysisMode__ ? _getLocal(_scope23, "text", text) : void 0, text), _getMember(this, "pattern")))), _childText("\n          ")), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 15,
                line: 228
              },
              start: {
                column: 10,
                line: 226
              }
            })), _childText("\n        ")), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 13,
                line: 229
              },
              start: {
                column: 17,
                line: 223
              }
            });
            _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope22, "ea", ea) : void 0, ea), "item", (self.__expressionAnalysisMode__ ? _getLocal(_scope23, "item", item) : void 0, item), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 20,
                line: 230
              },
              start: {
                column: 6,
                line: 230
              },
              source: ''
            });

            _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchResults")), "appendChild", [(self.__expressionAnalysisMode__ ? _getLocal(_scope23, "item", item) : void 0, item)]);
          }

          if (_getMember(this, "replace")) {
            await (self.__expressionAnalysisMode__ ? _traceMember(this, "updateReplacePreview") : void 0, this.updateReplacePreview());
          }
        }

        hightlightPattern(text, pattern) {
          let _scope25 = {};

          let textSpan = _element("span", _attributes(), _children(), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 32,
              line: 241
            },
            start: {
              column: 19,
              line: 241
            }
          });
          _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope25, "textSpan", textSpan) : void 0, textSpan), "innerHTML", _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(text, "replace") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope25, "text", text) : void 0, text).replace(/</g, "&lt;")), "replace", [new (self.__expressionAnalysisMode__ ? _getGlobal("RegExp") : void 0, RegExp)("(" + (self.__expressionAnalysisMode__ ? _traceMember(pattern, "replace") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope25, "pattern", pattern) : void 0, pattern).replace(/</g, "&lt;")) + ")", "g"), "<b>$1</b>"]), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 87,
              line: 244
            },
            start: {
              column: 4,
              line: 242
            },
            source: ''
          });
          return self.__expressionAnalysisMode__ ? _getLocal(_scope25, "textSpan", textSpan) : void 0, textSpan;
        }

        /*MD ## Search and Replace MD*/

        async searchAndReplace(pattern, replace) {
          let _scope26 = {};

          _setMember(this, "mode", "replace", {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 25,
              line: 252
            },
            start: {
              column: 4,
              line: 252
            },
            source: ''
          });
          _setMember(this, "pattern", (self.__expressionAnalysisMode__ ? _getLocal(_scope26, "pattern", pattern) : void 0, pattern), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 26,
              line: 253
            },
            start: {
              column: 4,
              line: 253
            },
            source: ''
          });
          _setMember(this, "replace", (self.__expressionAnalysisMode__ ? _getLocal(_scope26, "replace", replace) : void 0, replace), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 26,
              line: 254
            },
            start: {
              column: 4,
              line: 254
            },
            source: ''
          });

          await (self.__expressionAnalysisMode__ ? _traceMember(this, "search") : void 0, this.search());
          await (self.__expressionAnalysisMode__ ? _traceMember(this, "updateReplacePreview") : void 0, this.updateReplacePreview());
          await (self.__expressionAnalysisMode__ ? _traceMember(this, "replaceInFiles") : void 0, this.replaceInFiles());
        }

        hasPreview() {
          return _getMember(this, "files") && _getMember(_getMember(this, "files"), "length") > 0 && _getAndCallMember(_getMember(_getMember(_getMember(this, "files"), 0), "item"), "querySelector", ["td#replace"]);
        }

        updateReplacePreview() {
          let _scope27 = {};

          if (_getMember(this, "mode") != "replace") {
            return;
          }for (var file of _getMember(this, "files")) {
            if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "item")) {
              _getAndCallMember(_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "item"), "querySelectorAll", ["#replace"]), "forEach", [td => {
                let _scope28 = {};
                return self.__expressionAnalysisMode__ ? _traceMember(td, "remove") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope28, "td", td) : void 0, td).remove();
              }]);

              var newText = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "text"), "replace", [new (self.__expressionAnalysisMode__ ? _getGlobal("RegExp") : void 0, RegExp)(_getMember(this, "pattern"), "g"), _getMember(this, "replace")]);
              _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "replaced", (self.__expressionAnalysisMode__ ? _getLocal(_scope27, "newText", newText) : void 0, newText), {
                file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                end: {
                  column: 31,
                  line: 273
                },
                start: {
                  column: 8,
                  line: 273
                },
                source: ''
              });
              var replacedText = (self.__expressionAnalysisMode__ ? _traceMember(this, "hightlightPattern") : void 0, this.hightlightPattern((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "newText", newText) : void 0, newText), (self.__expressionAnalysisMode__ ? _traceMember(_, "escapeRegExp") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, "_", _) : void 0, _).escapeRegExp(_getMember(this, "replace")))));
              var replacePreviewColumn = _element("td", _attributes(_attributeStringLiteral("id", "replace")), _children(_childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "replacedText", replacedText) : void 0, replacedText))), {
                file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                end: {
                  column: 71,
                  line: 275
                },
                start: {
                  column: 35,
                  line: 275
                }
              });
              _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "item"), "appendChild", [(self.__expressionAnalysisMode__ ? _getLocal(_scope27, "replacePreviewColumn", replacePreviewColumn) : void 0, replacePreviewColumn)]);

              _getAndCallMember(_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "item"), "querySelectorAll", ["#select"]), "forEach", [td => {
                let _scope29 = {};
                return self.__expressionAnalysisMode__ ? _traceMember(td, "remove") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope29, "td", td) : void 0, td).remove();
              }]);
              var selectColumn = _element("td", _attributes(_attributeStringLiteral("id", "select")), _children(_childElement(_element("input", _attributes(_attributeStringLiteral("type", "checkbox"), _attributeEmpty("checked")), _children(), {
                file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                end: {
                  column: 82,
                  line: 280
                },
                start: {
                  column: 43,
                  line: 280
                }
              }))), {
                file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                end: {
                  column: 87,
                  line: 280
                },
                start: {
                  column: 27,
                  line: 280
                }
              });
              _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "item"), "insertBefore", [(self.__expressionAnalysisMode__ ? _getLocal(_scope27, "selectColumn", selectColumn) : void 0, selectColumn), _getMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope27, "file", file) : void 0, file), "item"), "childNodes"), 0)]);
            }
          }
        }

        // #important #refactor
        async replaceInFiles(pattern = this.pattern, replace = this.replace) {
          let _scope30 = {};

          if (_getMember(this, "searchInProgres") || !_getMember(this, "files")) {
            if (self.__expressionAnalysisMode__) _traceMember(this, "log");

            this.log("please search files first");
            return;
          }

          if (!(self.__expressionAnalysisMode__ ? _traceMember(this, "hasPreview") : void 0, this.hasPreview())) {
            await (self.__expressionAnalysisMode__ ? _traceMember(this, "updateReplacePreview") : void 0, this.updateReplacePreview());
          }

          let toReplace = [];
          let regex = new (self.__expressionAnalysisMode__ ? _getGlobal("RegExp") : void 0, RegExp)((self.__expressionAnalysisMode__ ? _getLocal(_scope30, "pattern", pattern) : void 0, pattern), "g");
          var selectedFilesLines = _getAndCallMember(_getMember(this, "files"), "filter", [ea => {
            let _scope31 = {};
            return _getMember(_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope31, "ea", ea) : void 0, ea), "item"), "querySelector", ["td#select input"]), "checked");
          }]);

          var warnings = [];
          var selectedFiles = _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(selectedFilesLines, "map") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "selectedFilesLines", selectedFilesLines) : void 0, selectedFilesLines).map(ea => {
            let _scope32 = {};
            return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope32, "ea", ea) : void 0, ea), "url");
          })), "uniq", []);
          for (let url of (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "selectedFiles", selectedFiles) : void 0, selectedFiles)) {
            let _scope33 = {},
                _scope34 = {};

            let getRequest = await (self.__expressionAnalysisMode__ ? _getGlobal("fetch") : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope33, "url", url) : void 0, url));
            let lastVersion = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope34, "getRequest", getRequest) : void 0, getRequest), "headers"), "get", ["fileversion"]);
            let contents = await (self.__expressionAnalysisMode__ ? _traceMember(getRequest, "text") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope34, "getRequest", getRequest) : void 0, getRequest).text());

            var lines = (self.__expressionAnalysisMode__ ? _traceMember(selectedFilesLines, "filter") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "selectedFilesLines", selectedFilesLines) : void 0, selectedFilesLines).filter(ea => {
              let _scope35 = {};
              return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope35, "ea", ea) : void 0, ea), "url") == (self.__expressionAnalysisMode__ ? _getLocal(_scope33, "url", url) : void 0, url);
            }));

            if ((self.__expressionAnalysisMode__ ? _getLocal(_scope34, "contents", contents) : void 0, contents) === _getMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope30, "lines", lines) : void 0, lines), 0), "indexed"), "content")) {
              let _scope38 = {};

              // #TODO instead of replacing everthing, we should honor the selection?

              let newcontents = _getAndCallMember(_getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(contents, "split") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope34, "contents", contents) : void 0, contents).split("\n")), "map", [(ea, index) => {
                let _scope37 = {};

                var line = (self.__expressionAnalysisMode__ ? _traceMember(lines, "find") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "lines", lines) : void 0, lines).find(ea => {
                  let _scope36 = {};
                  return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope36, "ea", ea) : void 0, ea), "line") == (self.__expressionAnalysisMode__ ? _getLocal(_scope37, "index", index) : void 0, index);
                }));
                if (self.__expressionAnalysisMode__ ? _getLocal(_scope37, "line", line) : void 0, line) {
                  if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope37, "line", line) : void 0, line), "text") != (self.__expressionAnalysisMode__ ? _getLocal(_scope37, "ea", ea) : void 0, ea)) {
                    throw new (self.__expressionAnalysisMode__ ? _getGlobal("Error") : void 0, Error)("original line changed!");
                  }

                  return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope37, "line", line) : void 0, line), "replaced"); // our replacement 
                } else {
                  return self.__expressionAnalysisMode__ ? _getLocal(_scope37, "ea", ea) : void 0, ea;
                }
              }]), "join", ["\n"

              //  let oldnewcontents = contents.replace(regex, replace)
              // if (oldnewcontents !== newcontents) {
              //   throw new Error("Upsi!")
              // }

              ]);if ((self.__expressionAnalysisMode__ ? _getLocal(_scope34, "contents", contents) : void 0, contents) == (self.__expressionAnalysisMode__ ? _getLocal(_scope38, "newcontents", newcontents) : void 0, newcontents)) {
                if (self.__expressionAnalysisMode__) _traceMember(this, "log");

                this.log("pattern did not match " + (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "pattern", pattern) : void 0, pattern));
              }
              if (self.__expressionAnalysisMode__) _traceMember(toReplace, "push");
              (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "toReplace", toReplace) : void 0, toReplace).push({ url: url, lastversion: lastVersion, oldcontent: contents, newcontent: newcontents });
            } else {
              if (self.__expressionAnalysisMode__) _traceMember(lines, "forEach");

              (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "lines", lines) : void 0, lines).forEach(line => {
                let _scope39 = {};
                return _setMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope39, "line", line) : void 0, line), "item"), "style"), "outline", "1px solid red", {
                  file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
                  end: {
                    column: 71,
                    line: 336
                  },
                  start: {
                    column: 30,
                    line: 336
                  },
                  source: ''
                });
              });
              if (self.__expressionAnalysisMode__) _traceMember(warnings, "push");
              (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "warnings", warnings) : void 0, warnings).push("WARNING: skip " + (self.__expressionAnalysisMode__ ? _getLocal(_scope33, "url", url) : void 0, url) + ", because content changed!");
            }
          }

          if (!(await (self.__expressionAnalysisMode__ ? _traceMember(this, "confirmReplaceDialog") : void 0, this.confirmReplaceDialog((self.__expressionAnalysisMode__ ? _getLocal(_scope30, "toReplace", toReplace) : void 0, toReplace), (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "regex", regex) : void 0, regex), (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "warnings", warnings) : void 0, warnings))))) {
            if (self.__expressionAnalysisMode__) _traceMember(lively, "warn");

            (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).warn("replacing files canceled");
            return;
          }
          if (self.__expressionAnalysisMode__) _traceMember(this, "clearLog");
          this.clearLog();
          for (let ea of (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "toReplace", toReplace) : void 0, toReplace)) {
            let _scope40 = {};

            await (self.__expressionAnalysisMode__ ? _traceMember(this, "replaceFile") : void 0, this.replaceFile((self.__expressionAnalysisMode__ ? _getLocal(_scope40, "ea", ea) : void 0, ea), (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "replace", replace) : void 0, replace), (self.__expressionAnalysisMode__ ? _getLocal(_scope30, "pattern", pattern) : void 0, pattern)));
          }
        }

        async replaceFile(file, replace, pattern) {
          let _scope41 = {};

          let url = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "file", file) : void 0, file), "url");
          let headers = {};

          if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "file", file) : void 0, file), "lastVersion")) {
            _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "headers", headers) : void 0, headers), "lastversion", _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "file", file) : void 0, file), "lastVersion"), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 44,
                line: 356
              },
              start: {
                column: 6,
                line: 356
              },
              source: ''
            });
          }

          let putRequest = await (self.__expressionAnalysisMode__ ? _getGlobal("fetch") : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "url", url) : void 0, url), {
            method: "PUT",
            body: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "file", file) : void 0, file), "newcontent"),
            headers: headers
          });
          var item = _element("tr", _attributes(), _children(_childText("\n      "), _childElement(_element("td", _attributes(), _children(_childText("replaced")), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 23,
              line: 365
            },
            start: {
              column: 6,
              line: 365
            }
          })), _childText("\n      "), _childElement(_element("td", _attributes(_attributeStringLiteral("class", "filename")), _children(_childText("\n        "), _childElement(_element("a", _attributes(_attributeExpression("click", evt => {
            let _scope42 = {};
            if (self.__expressionAnalysisMode__) _traceMember(evt, "preventDefault");

            (self.__expressionAnalysisMode__ ? _getLocal(_scope42, "evt", evt) : void 0, evt).preventDefault();
            if (self.__expressionAnalysisMode__) _traceMember(this, "browseSearchResult");
            this.browseSearchResult((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "url", url) : void 0, url), (self.__expressionAnalysisMode__ ? _getLocal(_scope41, "replace", replace) : void 0, replace));
          }), _attributeExpression("href", (self.__expressionAnalysisMode__ ? _getLocal(_scope41, "url", url) : void 0, url))), _children(_childExpression((self.__expressionAnalysisMode__ ? _traceMember(url, "replace") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope41, "url", url) : void 0, url).replace(/.*\//, ""))), _childText("\n        ")), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 12,
              line: 372
            },
            start: {
              column: 8,
              line: 367
            }
          })), _childText("\n      ")), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 11,
              line: 373
            },
            start: {
              column: 6,
              line: 366
            }
          })), _childText("\n      "), _childElement(_element("td", _attributes(), _children(_childElement(_element("b", _attributes(), _children(_childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "pattern", pattern) : void 0, pattern))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 26,
              line: 374
            },
            start: {
              column: 10,
              line: 374
            }
          }))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 31,
              line: 374
            },
            start: {
              column: 6,
              line: 374
            }
          })), _childText("\n      "), _childElement(_element("td", _attributes(), _children(_childText("with")), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 19,
              line: 375
            },
            start: {
              column: 6,
              line: 375
            }
          })), _childText("\n      "), _childElement(_element("td", _attributes(), _children(_childElement(_element("b", _attributes(), _children(_childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "replace", replace) : void 0, replace))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 26,
              line: 376
            },
            start: {
              column: 10,
              line: 376
            }
          }))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 31,
              line: 376
            },
            start: {
              column: 6,
              line: 376
            }
          })), _childText("\n    ")), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 9,
              line: 377
            },
            start: {
              column: 15,
              line: 364
            }
          });
          _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchResults")), "appendChild", [(self.__expressionAnalysisMode__ ? _getLocal(_scope41, "item", item) : void 0, item)]);

          if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope41, "putRequest", putRequest) : void 0, putRequest), "status") == 200) {
            if (self.__expressionAnalysisMode__) _traceMember(lively, "notify");

            // #Idea: show diff?
            (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).notify("Replaced in " + (self.__expressionAnalysisMode__ ? _getLocal(_scope41, "url", url) : void 0, url));
          } else {
            if (self.__expressionAnalysisMode__) _traceMember(lively, "warn");

            (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).warn("could not change " + (self.__expressionAnalysisMode__ ? _getLocal(_scope41, "url", url) : void 0, url) + ", because " + (self.__expressionAnalysisMode__ ? _getLocal(_scope41, "putRequest", putRequest) : void 0, putRequest));
          }
        }

        confirmReplaceDialog(toReplace, regex, warnings) {
          let _scope43 = {};

          const list = (self.__expressionAnalysisMode__ ? _traceMember(toReplace, "map") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope43, "toReplace", toReplace) : void 0, toReplace).map(ea => {
            let _scope44 = {};

            var filename = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope44, "ea", ea) : void 0, ea), "url"), "replace", [/.*\//, ""]);
            return _element("li", _attributes(), _children(_childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope44, "filename", filename) : void 0, filename))), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
              end: {
                column: 32,
                line: 391
              },
              start: {
                column: 13,
                line: 391
              }
            });
          }));
          warnings = (self.__expressionAnalysisMode__ ? _getLocal(_scope43, "warnings", warnings) : void 0, warnings), true ? _setLocal(_scope43, "warnings", warnings, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 23,
              line: 393
            },
            start: {
              column: 4,
              line: 393
            },
            source: ''
          }) : void 0, warnings;
          var msg = _element("div", _attributes(), _children(_childText("Replace \n                "), _childElement(_element("b", _attributes(), _children(_childExpression(_getMember(this, "pattern"))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 37,
              line: 395
            },
            start: {
              column: 16,
              line: 395
            }
          })), _childText(" with "), _childElement(_element("b", _attributes(), _children(_childExpression(_getMember(this, "replace"))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 64,
              line: 395
            },
            start: {
              column: 43,
              line: 395
            }
          })), _childText(" \n                in "), _childExpression(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope43, "toReplace", toReplace) : void 0, toReplace), "length")), _childText(" files?\n                "), _childElement(_element("div", _attributes(_attributeStringLiteral("style", "color: red; white-space: pre;")), _children(_childExpression((self.__expressionAnalysisMode__ ? _traceMember(warnings, "join") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope43, "warnings", warnings) : void 0, warnings).join("\n")))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 86,
              line: 397
            },
            start: {
              column: 16,
              line: 397
            }
          })), _childText("\n                "), _childElement(_element("ul", _attributes(_attributeStringLiteral("style", "font-size: 10pt")), _children(_childText("\n                  "), _childSpread((self.__expressionAnalysisMode__ ? _getLocal(_scope43, "list", list) : void 0, list)), _childText("\n                ")), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 21,
              line: 400
            },
            start: {
              column: 16,
              line: 398
            }
          })), _childText("\n              ")), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 20,
              line: 401
            },
            start: {
              column: 14,
              line: 394
            }
          });
          return self.__expressionAnalysisMode__ ? _traceMember(lively, "confirm") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).confirm((self.__expressionAnalysisMode__ ? _getLocal(_scope43, "msg", msg) : void 0, msg));
        }

        /*MD ## Helper MD*/
        // #private
        log(s) {
          let _scope45 = {};

          var entry = _element("tr", _attributes(), _children(_childElement(_element("td", _attributes(_attributeStringLiteral("class", "logentry"), _attributeStringLiteral("colspan", "2")), _children(_childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope45, "s", s) : void 0, s))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 61,
              line: 409
            },
            start: {
              column: 20,
              line: 409
            }
          }))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 66,
              line: 409
            },
            start: {
              column: 16,
              line: 409
            }
          });
          _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchResults")), "appendChild", [(self.__expressionAnalysisMode__ ? _getLocal(_scope45, "entry", entry) : void 0, entry)]);
        }

        clearLog(s) {
          _setMember((self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get("#searchResults")), "innerHTML", "", {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 43,
              line: 414
            },
            start: {
              column: 4,
              line: 414
            },
            source: ''
          });
        }

        // #private
        serverURL() {
          return self.__expressionAnalysisMode__ ? _traceMember(lively4url, "replace") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("lively4url") : void 0, lively4url).replace(/[^/]*$/, "");
        }

        /*MD ## Lively API MD*/
        livelyMigrate(other) {}

      }

      _export("default", IndexSearch);

      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_tools_lively_index_search_js"), "IndexSearch", {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "IndexSearch", IndexSearch) : void 0, IndexSearch;
        },

        set(thisIsVererySecretVariableName) {
          let _scope46 = {};
          _export("default", IndexSearch = (self.__expressionAnalysisMode__ ? _getLocal(_scope46, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, "IndexSearch", IndexSearch, {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/tools/lively-index-search.js',
            end: {
              column: 32,
              line: 11
            },
            start: {
              column: 21,
              line: 11
            },
            source: ''
          }) : void 0, IndexSearch;
          return true;
        },

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