"enable aexpr";

/*MD # Import Widget 
 #Prototype #Unfinished #Witzig #AST #Sandblocks

![](lively-code-mirror-widget-import.png){width=400px}

MD*/
System.register(["active-expression-rewriting", "reactive-jsx", "src/components/widgets/lively-morph.js", "src/external/babel/babel7default.js", "utils"], function (_export, _context) {
  "use strict";

  var _setMember, _getAndCallMember, _setLocal, _getLocal, _getMember, _getGlobal, _traceMember, _children, _attributeExpression, _attributes, _element, _addSourceLocation, Morph, babelDefault, promisedEvent, through, generateUUID, LivelyCodeMirrorWidgetImport, __SystemJSRewritingHack, _scope, babel, filesPromise;
  _export("default", void 0);
  return {
    setters: [function (_activeExpressionRewriting) {
      _setMember = _activeExpressionRewriting.setMember;
      _getAndCallMember = _activeExpressionRewriting.getAndCallMember;
      _setLocal = _activeExpressionRewriting.setLocal;
      _getLocal = _activeExpressionRewriting.getLocal;
      _getMember = _activeExpressionRewriting.getMember;
      _getGlobal = _activeExpressionRewriting.getGlobal;
      _traceMember = _activeExpressionRewriting.traceMember;
    }, function (_reactiveJsx) {
      _children = _reactiveJsx.children;
      _attributeExpression = _reactiveJsx.attributeExpression;
      _attributes = _reactiveJsx.attributes;
      _element = _reactiveJsx.element;
      _addSourceLocation = _reactiveJsx.addSourceLocation;
    }, function (_srcComponentsWidgetsLivelyMorphJs) {
      Morph = _srcComponentsWidgetsLivelyMorphJs.default;
    }, function (_srcExternalBabelBabel7defaultJs) {
      babelDefault = _srcExternalBabelBabel7defaultJs.default;
    }, function (_utils) {
      promisedEvent = _utils.promisedEvent;
      through = _utils.through;
      generateUUID = _utils.uuid;
    }],
    execute: function () {
      __SystemJSRewritingHack = {};
      _recorder_._src_components_widgets_lively_code_mirror_widget_import_js = _recorder_._src_components_widgets_lively_code_mirror_widget_import_js || {};
      _scope = {
        isScope: true
      };
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "Morph", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "Morph", Morph) : void 0, Morph;
        },
        set(thisIsVererySecretVariableName) {
          let _scope2 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          Morph = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope2, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, "Morph", Morph, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 12,
              line: 11
            },
            start: {
              column: 7,
              line: 11
            },
            source: ''
          }) : void 0, Morph;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "babelDefault", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "babelDefault", babelDefault) : void 0, babelDefault;
        },
        set(thisIsVererySecretVariableName) {
          let _scope3 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          babelDefault = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope3, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, "babelDefault", babelDefault, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 19,
              line: 12
            },
            start: {
              column: 7,
              line: 12
            },
            source: ''
          }) : void 0, babelDefault;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      babel = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope, "babelDefault", babelDefault) : void 0, babelDefault), "babel");
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "babel", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "babel", babel) : void 0, babel;
        },
        set(thisIsVererySecretVariableName) {
          let _scope4 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          babel = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope4, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, "babel", babel, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 11,
              line: 13
            },
            start: {
              column: 6,
              line: 13
            },
            source: ''
          }) : void 0, babel;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "generateUUID", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "generateUUID", generateUUID) : void 0, generateUUID;
        },
        set(thisIsVererySecretVariableName) {
          let _scope5 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          generateUUID = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope5, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, "generateUUID", generateUUID, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 53,
              line: 16
            },
            start: {
              column: 41,
              line: 16
            },
            source: ''
          }) : void 0, generateUUID;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "through", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "through", through) : void 0, through;
        },
        set(thisIsVererySecretVariableName) {
          let _scope6 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          through = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope6, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, "through", through, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 31,
              line: 16
            },
            start: {
              column: 24,
              line: 16
            },
            source: ''
          }) : void 0, through;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "promisedEvent", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "promisedEvent", promisedEvent) : void 0, promisedEvent;
        },
        set(thisIsVererySecretVariableName) {
          let _scope7 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          promisedEvent = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope7, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, "promisedEvent", promisedEvent, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 22,
              line: 16
            },
            start: {
              column: 9,
              line: 16
            },
            source: ''
          }) : void 0, promisedEvent;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      filesPromise = new (self.__expressionAnalysisMode__ ? _getGlobal("Promise") : void 0, Promise)(resolve => {
        let _scope11 = {
          isScope: true
        };
        globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
        return _getAndCallMember(_getAndCallMember(_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively), "files"), "walkDir", [(self.__expressionAnalysisMode__ ? _getGlobal("lively4url") : void 0, lively4url)]), "then", [files => {
          let _scope8 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(Object, "keys") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).keys(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("SystemJS") : void 0, SystemJS), '@@loader-config'), "map"))), "concat", [_getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(files, "filter") : void 0, (files === Object(files) ? self.__expressionAnalysisMode__ ? _getLocal(_scope8, "files", files) : void 0 : files, files).filter(file => {
            let _scope9 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return self.__expressionAnalysisMode__ ? _traceMember(file, "endsWith") : void 0, (file === Object(file) ? self.__expressionAnalysisMode__ ? _getLocal(_scope9, "file", file) : void 0 : file, file).endsWith('.js');
          })), "map", [file => {
            let _scope10 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return self.__expressionAnalysisMode__ ? _traceMember(file, "replace") : void 0, (file === Object(file) ? self.__expressionAnalysisMode__ ? _getLocal(_scope10, "file", file) : void 0 : file, file).replace((self.__expressionAnalysisMode__ ? _getGlobal("lively4url") : void 0, lively4url), '');
          }])]);
        }]), "then", [(resolve === Object(resolve) ? self.__expressionAnalysisMode__ ? _getLocal(_scope11, "resolve", resolve) : void 0 : resolve, resolve)]);
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "filesPromise", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "filesPromise", filesPromise) : void 0, filesPromise;
        },
        set(thisIsVererySecretVariableName) {
          let _scope12 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          filesPromise = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope12, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName), true ? _setLocal(_scope, "filesPromise", filesPromise, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 18,
              line: 18
            },
            start: {
              column: 6,
              line: 18
            },
            source: ''
          }) : void 0, filesPromise;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      _export("default", LivelyCodeMirrorWidgetImport = class LivelyCodeMirrorWidgetImport extends Morph {
        static getAST(src) {
          let _scope13 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          try {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            const filename = "tempfile.js";
            // get pure ast
            return _getMember((self.__expressionAnalysisMode__ ? _traceMember(babel, "transform") : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, "babel", babel) : void 0, babel).transform((src === Object(src) ? self.__expressionAnalysisMode__ ? _getLocal(_scope13, "src", src) : void 0 : src, src), {
              babelrc: false,
              plugins: [],
              // no need for any syntax plugins (other than the SystemJS internal) as we only parse import statements
              presets: [],
              filename: filename,
              sourceFileName: filename,
              moduleIds: false,
              sourceMaps: false,
              // inputSourceMap: load.metadata.sourceMap,
              compact: false,
              comments: false,
              code: false,
              ast: true
            })), "ast");
          } catch (e) {
            let _scope14 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            if (self.__expressionAnalysisMode__) _traceMember(lively, "warn");
            (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).warn('could not get ast for import statement', (e === Object(e) ? self.__expressionAnalysisMode__ ? _getLocal(_scope14, "e", e) : void 0 : e, e));
          }
        }
        static createWidgetContainer() {
          let _scope15 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          var widget = _addSourceLocation((self.__expressionAnalysisMode__ ? _traceMember(document, "createElement") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("document") : void 0, document).createElement("span")), {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 47,
              line: 56
            },
            start: {
              column: 17,
              line: 56
            }
          });
          if (self.__expressionAnalysisMode__) _traceMember(Object, "assign");
          (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).assign(_getMember((widget === Object(widget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope15, "widget", widget) : void 0 : widget, widget), "style"), {
            whiteSpace: "normal"
          });
          return widget === Object(widget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope15, "widget", widget) : void 0 : widget, widget;
        }
        static async importWidgetForRange(cm, m) {
          let _scope16 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          const ast = (self.__expressionAnalysisMode__ ? _traceMember(this, "getAST") : void 0, this.getAST(_getMember((m === Object(m) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "m", m) : void 0 : m, m), 0)));
          if (!(ast === Object(ast) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "ast", ast) : void 0 : ast, ast)) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return;
          }
          const from = _getAndCallMember(_getMember((cm === Object(cm) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "cm", cm) : void 0 : cm, cm), "editor"), "posFromIndex", [_getMember((m === Object(m) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "m", m) : void 0 : m, m), "index")]);
          const to = _getAndCallMember(_getMember((cm === Object(cm) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "cm", cm) : void 0 : cm, cm), "editor"), "posFromIndex", [_getMember((m === Object(m) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "m", m) : void 0 : m, m), "index") + _getMember(_getMember((m === Object(m) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "m", m) : void 0 : m, m), 0), "length")]);
          let marks = _getAndCallMember(_getMember((cm === Object(cm) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "cm", cm) : void 0 : cm, cm), "editor"), "findMarks", [(from === Object(from) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "from", from) : void 0 : from, from), (to === Object(to) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "to", to) : void 0 : to, to)]);
          let existingMarker = (self.__expressionAnalysisMode__ ? _traceMember(marks, "find") : void 0, (marks === Object(marks) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "marks", marks) : void 0 : marks, marks).find(ea => {
            let _scope17 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return _getMember((ea === Object(ea) ? self.__expressionAnalysisMode__ ? _getLocal(_scope17, "ea", ea) : void 0 : ea, ea), "importWidget");
          }));
          if (existingMarker === Object(existingMarker) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "existingMarker", existingMarker) : void 0 : existingMarker, existingMarker) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            if (self.__expressionAnalysisMode__) _traceMember(lively, "notify");
            (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).notify("found import widget");
            // do we have to update it?
            return;
          }
          var container = (self.__expressionAnalysisMode__ ? _traceMember(this, "createWidgetContainer") : void 0, this.createWidgetContainer());
          // #TODO, we assume that it will keep the first widget, and further replacements do not work.... and get therefore thrown away
          var marker = _getAndCallMember(_getMember(_getMember((cm === Object(cm) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "cm", cm) : void 0 : cm, cm), "editor"), "doc"), "markText", [(from === Object(from) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "from", from) : void 0 : from, from), (to === Object(to) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "to", to) : void 0 : to, to), {
            replacedWith: container
          }]);
          _setMember((marker === Object(marker) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "marker", marker) : void 0 : marker, marker), "importWidget", (container === Object(container) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "container", container) : void 0 : container, container), {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 35,
              line: 83
            },
            start: {
              column: 4,
              line: 83
            },
            source: ''
          });
          // lively.warn('return after container replacement')
          // return;
          await _getAndCallMember(_addSourceLocation((self.__expressionAnalysisMode__ ? _traceMember(lively, "create") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).create('lively-code-mirror-widget-import', (container === Object(container) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "container", container) : void 0 : container, container))), {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 70,
              line: 86
            },
            start: {
              column: 10,
              line: 86
            }
          }), "then", [importWidget => {
            let _scope18 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return self.__expressionAnalysisMode__ ? _traceMember(importWidget, "initWidget") : void 0, (importWidget === Object(importWidget) ? self.__expressionAnalysisMode__ ? _getLocal(_scope18, "importWidget", importWidget) : void 0 : importWidget, importWidget).initWidget((cm === Object(cm) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "cm", cm) : void 0 : cm, cm), (m === Object(m) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "m", m) : void 0 : m, m), (ast === Object(ast) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "ast", ast) : void 0 : ast, ast), (marker === Object(marker) ? self.__expressionAnalysisMode__ ? _getLocal(_scope16, "marker", marker) : void 0 : marker, marker));
          }]);
        }
        async initialize() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          _setMember(this, "windowTitle", "LivelyCodeMirrorWidgetImport", {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 53,
              line: 91
            },
            start: {
              column: 4,
              line: 91
            },
            source: ''
          });
          _getAndCallMember(_getMember(this, "modulePath"), "addEventListener", ["keydown", evt => {
            let _scope19 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return self.__expressionAnalysisMode__ ? _traceMember(this, "onModulePathKeyDown") : void 0, this.onModulePathKeyDown((evt === Object(evt) ? self.__expressionAnalysisMode__ ? _getLocal(_scope19, "evt", evt) : void 0 : evt, evt));
          }]);
          _setMember(this, "__classFilePath__", "https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js", undefined);
        }
        get fileList() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get('#fileList');
        }
        get modulePath() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _traceMember(this, "get") : void 0, this.get('#modulePath');
        }
        prepareFileList() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          if (self.__expressionAnalysisMode__) _traceMember(filesPromise, "then");
          (self.__expressionAnalysisMode__ ? _getLocal(_scope, "filesPromise", filesPromise) : void 0, filesPromise).then(files => {
            let _scope20 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            const fileList = _getMember(this, "fileList");
            if (self.__expressionAnalysisMode__) _traceMember(files, "forEach");
            (files === Object(files) ? self.__expressionAnalysisMode__ ? _getLocal(_scope20, "files", files) : void 0 : files, files).forEach(file => {
              let _scope21 = {
                isScope: true
              };
              globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
              if (self.__expressionAnalysisMode__) _traceMember(fileList, "appendChild");
              (fileList === Object(fileList) ? self.__expressionAnalysisMode__ ? _getLocal(_scope20, "fileList", fileList) : void 0 : fileList, fileList).appendChild(_element("option", _attributes(_attributeExpression("value", (file === Object(file) ? self.__expressionAnalysisMode__ ? _getLocal(_scope21, "file", file) : void 0 : file, file))), _children(), {
                file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
                end: {
                  column: 59,
                  line: 104
                },
                start: {
                  column: 29,
                  line: 104
                }
              }));
            });
          });
        }
        onFileChanged() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          if (self.__expressionAnalysisMode__) _traceMember(lively, "success");
          (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).success('file changed to', _getMember(_getMember(this, "modulePath"), "value"));
        }
        onModulePathKeyDown(evt) {
          let _scope22 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          var input = _getMember(this, "modulePath");
          var range = _getAndCallMember(_getMember(this, "marker"), "find", []);
          if (_getMember((evt === Object(evt) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "evt", evt) : void 0 : evt, evt), "keyCode") == 13) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          } // ENTER
          // #TODO how to replace // update text without replacing widgets
          // this.cm.editor.replaceRange(input.value, range.from, range.to) // @Stefan, your welcome! ;-)
          // this.wrapLinks() // don't wait and do what you can now

          if (_getMember((evt === Object(evt) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "evt", evt) : void 0 : evt, evt), "keyCode") == 37) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            // Left
            if (_getMember((input === Object(input) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "input", input) : void 0 : input, input), "selectionStart") == 0) {
              globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
              _getAndCallMember(_getMember(_getMember(this, "cm"), "editor"), "setSelection", [_getMember((range === Object(range) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "range", range) : void 0 : range, range), "from"), _getMember((range === Object(range) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "range", range) : void 0 : range, range), "from")]);
              _getAndCallMember(_getMember(this, "cm"), "focus", []);
            }
          }
          if (_getMember((evt === Object(evt) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "evt", evt) : void 0 : evt, evt), "keyCode") == 39) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            // Right
            if (_getMember((input === Object(input) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "input", input) : void 0 : input, input), "selectionStart") == _getMember(_getMember((input === Object(input) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "input", input) : void 0 : input, input), "value"), "length")) {
              globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
              _getAndCallMember(_getMember(_getMember(this, "cm"), "editor"), "setSelection", [_getMember((range === Object(range) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "range", range) : void 0 : range, range), "to"), _getMember((range === Object(range) ? self.__expressionAnalysisMode__ ? _getLocal(_scope22, "range", range) : void 0 : range, range), "to")]);
              _getAndCallMember(_getMember(this, "cm"), "focus", []);
            }
          }
        }
        async initWidget(cm, m, ast, marker) {
          let _scope23 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          _setMember(this, "cm", (cm === Object(cm) ? self.__expressionAnalysisMode__ ? _getLocal(_scope23, "cm", cm) : void 0 : cm, cm), {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 16,
              line: 137
            },
            start: {
              column: 4,
              line: 137
            },
            source: ''
          });
          _setMember(this, "ast", (ast === Object(ast) ? self.__expressionAnalysisMode__ ? _getLocal(_scope23, "ast", ast) : void 0 : ast, ast), {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 18,
              line: 138
            },
            start: {
              column: 4,
              line: 138
            },
            source: ''
          });
          _setMember(this, "marker", (marker === Object(marker) ? self.__expressionAnalysisMode__ ? _getLocal(_scope23, "marker", marker) : void 0 : marker, marker), {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 24,
              line: 139
            },
            start: {
              column: 4,
              line: 139
            },
            source: ''
          });

          // this.modulePath.onfocus= e => lively.notify('FOCUSSED')
          // this.modulePath.onblur = e =>{
          //   lively.notify('BLURRED')
          // } 
          if (self.__expressionAnalysisMode__) _traceMember(this, "prepareFileList");
          this.prepareFileList();
          if (self.__expressionAnalysisMode__) _traceMember(CodeMirror, "on");
          (self.__expressionAnalysisMode__ ? _getGlobal("CodeMirror") : void 0, CodeMirror).on((marker === Object(marker) ? self.__expressionAnalysisMode__ ? _getLocal(_scope23, "marker", marker) : void 0 : marker, marker), "beforeCursorEnter", e => {
            let _scope25 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            function posEq(a, b) {
              let _scope24 = {
                isScope: true
              };
              globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
              return _getMember((a === Object(a) ? self.__expressionAnalysisMode__ ? _getLocal(_scope24, "a", a) : void 0 : a, a), "line") == _getMember((b === Object(b) ? self.__expressionAnalysisMode__ ? _getLocal(_scope24, "b", b) : void 0 : b, b), "line") && _getMember((a === Object(a) ? self.__expressionAnalysisMode__ ? _getLocal(_scope24, "a", a) : void 0 : a, a), "ch") == _getMember((b === Object(b) ? self.__expressionAnalysisMode__ ? _getLocal(_scope24, "b", b) : void 0 : b, b), "ch");
            }
            var direction = (posEq === Object(posEq) ? self.__expressionAnalysisMode__ ? _getLocal(_scope25, "posEq", posEq) : void 0 : posEq, posEq)(_getAndCallMember(_getMember(_getMember(this, "cm"), "editor"), "getCursor", []), _getMember(_getAndCallMember(_getMember(this, "marker"), "find", []), "from")) ? 'left' : 'right';
            _setMember(_getMember(_getMember(this, "cm"), "editor"), "widgetEnter", () => {
              globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
              return self.__expressionAnalysisMode__ ? _traceMember(this, "onEnter") : void 0, this.onEnter((direction === Object(direction) ? self.__expressionAnalysisMode__ ? _getLocal(_scope25, "direction", direction) : void 0 : direction, direction));
            }, {
              file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
              end: {
                column: 64,
                line: 151
              },
              start: {
                column: 6,
                line: 151
              },
              source: ''
            });
          });
          await _getAndCallMember(_getAndCallMember(_addSourceLocation((self.__expressionAnalysisMode__ ? _traceMember(lively, "create") : void 0, (self.__expressionAnalysisMode__ ? _getGlobal("lively") : void 0, lively).create('lively-inspector', this)), {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 49,
              line: 154
            },
            start: {
              column: 10,
              line: 154
            }
          }), "through", [inspector => {
            let _scope26 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return self.__expressionAnalysisMode__ ? _traceMember(inspector, "inspect") : void 0, (inspector === Object(inspector) ? self.__expressionAnalysisMode__ ? _getLocal(_scope26, "inspector", inspector) : void 0 : inspector, inspector).inspect((ast === Object(ast) ? self.__expressionAnalysisMode__ ? _getLocal(_scope23, "ast", ast) : void 0 : ast, ast));
          }]), "through", [inspector => {
            let _scope27 = {
              isScope: true
            };
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            return self.__expressionAnalysisMode__ ? _traceMember(inspector, "hideWorkspace") : void 0, (inspector === Object(inspector) ? self.__expressionAnalysisMode__ ? _getLocal(_scope27, "inspector", inspector) : void 0 : inspector, inspector).hideWorkspace();
          }]);
          _getAndCallMember(_getMember(_getMember(this, "cm"), "editor"), "refresh", []);
        }
        onEnter(direction) {
          let _scope28 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          // lively.success('ENTER FROM ' + direction)
          if (!_getAndCallMember(_getMember(this, "marker"), "find", [])) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            _getAndCallMember(_getMember(_getMember(this, "cm"), "editor"), "refresh", []);
          } else {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            if (self.__expressionAnalysisMode__) _traceMember(this, "enter");
            // setTimeout(() => {
            this.enter((direction === Object(direction) ? self.__expressionAnalysisMode__ ? _getLocal(_scope28, "direction", direction) : void 0 : direction, direction));
            // }, 50);
          }
        }

        enter(direction) {
          let _scope29 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          var module = _getMember(this, "modulePath");
          // this.focus()
          if (self.__expressionAnalysisMode__) _traceMember(module, "focus");
          (module === Object(module) ? self.__expressionAnalysisMode__ ? _getLocal(_scope29, "module", module) : void 0 : module, module).focus();
          (self.__expressionAnalysisMode__ ? _getGlobal("setTimeout") : void 0, setTimeout)(() => {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
            if (self.__expressionAnalysisMode__) _traceMember(module, "focus");
            (module === Object(module) ? self.__expressionAnalysisMode__ ? _getLocal(_scope29, "module", module) : void 0 : module, module).focus(); // #Hack, code mirror itself (match-highlighter, etc will snatch the focus... ok, make thatt that the body has it
          }, 101);
          // const position = direction === 'left' ? 0 : module.value.length;
          // module.setSelectionRange(position, position);
        }
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, "defineProperty");
      (self.__expressionAnalysisMode__ ? _getGlobal("Object") : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal("_recorder_") : void 0, _recorder_), "_src_components_widgets_lively_code_mirror_widget_import_js"), "LivelyCodeMirrorWidgetImport", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, "LivelyCodeMirrorWidgetImport", LivelyCodeMirrorWidgetImport) : void 0, LivelyCodeMirrorWidgetImport;
        },
        set(thisIsVererySecretVariableName) {
          let _scope30 = {
            isScope: true
          };
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js"]++;
          _export("default", LivelyCodeMirrorWidgetImport = (thisIsVererySecretVariableName === Object(thisIsVererySecretVariableName) ? self.__expressionAnalysisMode__ ? _getLocal(_scope30, "thisIsVererySecretVariableName", thisIsVererySecretVariableName) : void 0 : thisIsVererySecretVariableName, thisIsVererySecretVariableName)), true ? _setLocal(_scope, "LivelyCodeMirrorWidgetImport", LivelyCodeMirrorWidgetImport, {
            file: 'https://lively-kernel.org/lively4/lively4-ansgar/src/components/widgets/lively-code-mirror-widget-import.js',
            end: {
              column: 49,
              line: 29
            },
            start: {
              column: 21,
              line: 29
            },
            source: ''
          }) : void 0, LivelyCodeMirrorWidgetImport;
          return true;
        },
        enumerable: true,
        configurable: true
      });
    }
  };
});