"enable aexpr";

System.register(['active-expression-rewriting', 'reactive-jsx', 'lang', 'src/external/focalStorage.js', './../contextmenu.js', 'utils', 'active-group'], function (_export, _context) {
  "use strict";

  var _setMember, _getAndCallMember, _setLocal, _getLocal, _getMember, _getGlobal, _traceMember, _childText, _childExpression, _children, _attributeStringLiteral, _attributes, _element, focalStorage, ContextMenu, through, uuid, fileName, hintForLabel, getTempKeyFor, asDragImageFor, trackInstance;

  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) {
      _childText = _reactiveJsx.childText;
      _childExpression = _reactiveJsx.childExpression;
      _children = _reactiveJsx.children;
      _attributeStringLiteral = _reactiveJsx.attributeStringLiteral;
      _attributes = _reactiveJsx.attributes;
      _element = _reactiveJsx.element;
    }, function (_lang) {}, function (_srcExternalFocalStorageJs) {
      focalStorage = _srcExternalFocalStorageJs.default;
    }, function (_contextmenuJs) {
      ContextMenu = _contextmenuJs.default;
    }, function (_utils) {
      through = _utils.through;
      uuid = _utils.uuid;
      fileName = _utils.fileName;
      hintForLabel = _utils.hintForLabel;
      getTempKeyFor = _utils.getTempKeyFor;
      asDragImageFor = _utils.asDragImageFor;
    }, function (_activeGroup) {
      trackInstance = _activeGroup.trackInstance;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_client_triples_triples_js = _recorder_._src_client_triples_triples_js || {};
      let _scope = {},
          _scope20 = {},
          _scope55 = {};
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      (self.__expressionAnalysisMode__ ? _getGlobal('Object') : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_client_triples_triples_js'), 'isExternalURL', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'isExternalURL', isExternalURL) : void 0, isExternalURL;
        },

        set(thisIsVererySecretVariableName) {
          let _scope2 = {};
          isExternalURL = (self.__expressionAnalysisMode__ ? _getLocal(_scope2, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'isExternalURL', isExternalURL) : void 0, isExternalURL;
          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_client_triples_triples_js'), 'isInternalURL', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'isInternalURL', isInternalURL) : void 0, isInternalURL;
        },

        set(thisIsVererySecretVariableName) {
          let _scope3 = {};
          isInternalURL = (self.__expressionAnalysisMode__ ? _getLocal(_scope3, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'isInternalURL', isInternalURL) : void 0, isInternalURL;
          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_client_triples_triples_js'), 'parseMarkdown', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'parseMarkdown', parseMarkdown) : void 0, parseMarkdown;
        },

        set(thisIsVererySecretVariableName) {
          let _scope4 = {};
          parseMarkdown = (self.__expressionAnalysisMode__ ? _getLocal(_scope4, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'parseMarkdown', parseMarkdown) : void 0, parseMarkdown;
          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_client_triples_triples_js'), 'getJSYaml', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getJSYaml', getJSYaml) : void 0, getJSYaml;
        },

        set(thisIsVererySecretVariableName) {
          let _scope5 = {};
          getJSYaml = (self.__expressionAnalysisMode__ ? _getLocal(_scope5, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'getJSYaml', getJSYaml) : void 0, getJSYaml;
          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_client_triples_triples_js'), 'focalStorage', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'focalStorage', focalStorage) : void 0, focalStorage;
        },

        set(thisIsVererySecretVariableName) {
          let _scope6 = {};
          focalStorage = (self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'focalStorage', focalStorage) : void 0, focalStorage;
          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_client_triples_triples_js'), 'ContextMenu', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ContextMenu', ContextMenu) : void 0, ContextMenu;
        },

        set(thisIsVererySecretVariableName) {
          let _scope7 = {};
          ContextMenu = (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'ContextMenu', ContextMenu) : void 0, ContextMenu;
          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_client_triples_triples_js'), 'asDragImageFor', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'asDragImageFor', asDragImageFor) : void 0, asDragImageFor;
        },

        set(thisIsVererySecretVariableName) {
          let _scope8 = {};
          asDragImageFor = (self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'asDragImageFor', asDragImageFor) : void 0, asDragImageFor;
          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_client_triples_triples_js'), 'getTempKeyFor', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getTempKeyFor', getTempKeyFor) : void 0, getTempKeyFor;
        },

        set(thisIsVererySecretVariableName) {
          let _scope9 = {};
          getTempKeyFor = (self.__expressionAnalysisMode__ ? _getLocal(_scope9, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'getTempKeyFor', getTempKeyFor) : void 0, getTempKeyFor;
          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_client_triples_triples_js'), 'hintForLabel', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'hintForLabel', hintForLabel) : void 0, hintForLabel;
        },

        set(thisIsVererySecretVariableName) {
          let _scope10 = {};
          hintForLabel = (self.__expressionAnalysisMode__ ? _getLocal(_scope10, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'hintForLabel', hintForLabel) : void 0, hintForLabel;
          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_client_triples_triples_js'), 'fileName', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'fileName', fileName) : void 0, fileName;
        },

        set(thisIsVererySecretVariableName) {
          let _scope11 = {};
          fileName = (self.__expressionAnalysisMode__ ? _getLocal(_scope11, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'fileName', fileName) : void 0, fileName;
          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_client_triples_triples_js'), 'uuid', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'uuid', uuid) : void 0, uuid;
        },

        set(thisIsVererySecretVariableName) {
          let _scope12 = {};
          uuid = (self.__expressionAnalysisMode__ ? _getLocal(_scope12, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'uuid', uuid) : void 0, uuid;
          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_client_triples_triples_js'), 'through', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'through', through) : void 0, through;
        },

        set(thisIsVererySecretVariableName) {
          let _scope13 = {};
          through = (self.__expressionAnalysisMode__ ? _getLocal(_scope13, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'through', through) : 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_client_triples_triples_js'), 'trackInstance', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'trackInstance', trackInstance) : void 0, trackInstance;
        },

        set(thisIsVererySecretVariableName) {
          let _scope14 = {};
          trackInstance = (self.__expressionAnalysisMode__ ? _getLocal(_scope14, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'trackInstance', trackInstance) : void 0, trackInstance;
          return true;
        },

        enumerable: true,
        configurable: true
      });


      async function getJSYaml() {
        await (self.__expressionAnalysisMode__ ? _traceMember(lively, 'loadJavaScriptThroughDOM') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).loadJavaScriptThroughDOM("esprima", "https://lively-kernel.org/lively4/foo/src/external/esprima.js"));
        await (self.__expressionAnalysisMode__ ? _traceMember(lively, 'loadJavaScriptThroughDOM') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).loadJavaScriptThroughDOM("js-yaml", "https://lively-kernel.org/lively4/foo/src/external/js-yaml.js"));
        return self.__expressionAnalysisMode__ ? _getGlobal('jsyaml') : void 0, jsyaml;
      }

      // #TODO: unused
      async function parseMarkdown(markdown, filename) {
        let _scope15 = {};

        try {
          let _scope16 = {};

          const frontmatterSeparator = "---\r\n";
          if (self.__expressionAnalysisMode__ ? _traceMember(markdown, 'startsWith') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope15, 'markdown', markdown) : void 0, markdown).startsWith((self.__expressionAnalysisMode__ ? _getLocal(_scope16, 'frontmatterSeparator', frontmatterSeparator) : void 0, frontmatterSeparator))) {
            let _scope17 = {};

            const parts = (self.__expressionAnalysisMode__ ? _traceMember(markdown, 'split') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope15, 'markdown', markdown) : void 0, markdown).split((self.__expressionAnalysisMode__ ? _getLocal(_scope16, 'frontmatterSeparator', frontmatterSeparator) : void 0, frontmatterSeparator)));
            if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope17, 'parts', parts) : void 0, parts), 'length') >= 3) {
              let _scope18 = {};
              if (self.__expressionAnalysisMode__) _traceMember(parts, 'shift');

              (self.__expressionAnalysisMode__ ? _getLocal(_scope17, 'parts', parts) : void 0, parts).shift(); // empty
              const frontmatterString = (self.__expressionAnalysisMode__ ? _traceMember(parts, 'shift') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope17, 'parts', parts) : void 0, parts).shift());
              return {
                textContent: (self.__expressionAnalysisMode__ ? _traceMember(parts, 'join') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope17, 'parts', parts) : void 0, parts).join((self.__expressionAnalysisMode__ ? _getLocal(_scope16, 'frontmatterSeparator', frontmatterSeparator) : void 0, frontmatterSeparator))),
                metadata: _getAndCallMember((await (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getJSYaml', getJSYaml) : void 0, getJSYaml)()), 'load', [(self.__expressionAnalysisMode__ ? _getLocal(_scope18, 'frontmatterString', frontmatterString) : void 0, frontmatterString)])
              };
            }
          }
        } catch (e) {
          if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');

          (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify("failed frontmatter parsing", "", (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined), (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined), "red");
        }
        return {
          textContent: markdown,
          metadata: {}
        };
      }

      class Knot {
        constructor(fileName, content) {
          let _scope19 = {};

          _setMember(this, 'fileName', (self.__expressionAnalysisMode__ ? _getLocal(_scope19, 'fileName', fileName) : void 0, fileName));
          _setMember(this, 'content', (self.__expressionAnalysisMode__ ? _getLocal(_scope19, 'content', content) : void 0, content));

          if (new.target === (self.__expressionAnalysisMode__ ? _getLocal(_scope20, 'Knot', Knot) : void 0, Knot)) {
            if (self.__expressionAnalysisMode__) _traceMember(trackInstance, 'call');

            (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'trackInstance', trackInstance) : void 0, trackInstance).call((self.__expressionAnalysisMode__ ? _getLocal(_scope20, 'Knot', Knot) : void 0, Knot), this);
          }
        }
        get url() {
          return _getMember(this, 'fileName');
        }
        getMetadata() {
          return _getMember(this, 'metadata');
        }
        label() {
          if (_getAndCallMember(_getMember(this, 'fileName'), 'endsWith', ['.md'])) {
            let _scope21 = {};

            const firstLine = _getMember(_getAndCallMember(_getMember(this, 'content'), 'split', ['\n']), 0);
            return self.__expressionAnalysisMode__ ? _traceMember(firstLine, 'replace') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope21, 'firstLine', firstLine) : void 0, firstLine).replace(/^#\s/, '');
          }
          return _getMember(this, 'fileName');
        }
        isTriple() {
          return false;
        }
        async save(newContent) {
          let _scope22 = {};

          _setMember(this, 'content', (self.__expressionAnalysisMode__ ? _getLocal(_scope22, 'newContent', newContent) : void 0, newContent));
          await _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively), 'files'), 'saveFile', [_getMember(this, 'url'), (self.__expressionAnalysisMode__ ? _getLocal(_scope22, 'newContent', newContent) : void 0, newContent)]);
        }
        async openViewInWindow() {
          let _scope23 = {};

          const knotView = await (self.__expressionAnalysisMode__ ? _traceMember(lively, 'openComponentInWindow') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).openComponentInWindow("knot-view"));
          if (self.__expressionAnalysisMode__) _traceMember(knotView, 'loadKnotForURL');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope23, 'knotView', knotView) : void 0, knotView).loadKnotForURL(_getMember(this, 'url'));
        }
        collectContextMenuItems() {
          return [["Knot View", evt => {
            if (self.__expressionAnalysisMode__) _traceMember(ContextMenu, 'hide');

            (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ContextMenu', ContextMenu) : void 0, ContextMenu).hide();
            if (self.__expressionAnalysisMode__) _traceMember(this, 'openViewInWindow');
            this.openViewInWindow();
          }, "", '<i class="fa fa-window-maximize" aria-hidden="true"></i>'], ["Danger Zone", [["Delete", async evt => {
            let _scope24 = {};
            if (self.__expressionAnalysisMode__) _traceMember(ContextMenu, 'hide');

            (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ContextMenu', ContextMenu) : void 0, ContextMenu).hide();
            const graph = await (self.__expressionAnalysisMode__ ? _traceMember(Graph, 'getInstance') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'Graph', Graph) : void 0, Graph).getInstance());

            const label = (self.__expressionAnalysisMode__ ? _traceMember(this, 'label') : void 0, this.label());
            if (await (self.__expressionAnalysisMode__ ? _traceMember(graph, 'deleteKnot') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope24, 'graph', graph) : void 0, graph).deleteKnot(this))) {
              if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');

              // #TODO: use reactivity to update views and search results
              (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify(`${(self.__expressionAnalysisMode__ ? _getLocal(_scope24, 'label', label) : void 0, label)} deleted!`, null, 4, null, "red");
            } else {
              if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');

              (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify('did not delete knot ' + (self.__expressionAnalysisMode__ ? _getLocal(_scope24, 'label', label) : void 0, label), _getMember(this, 'url'));
            }
          }, "Delete for good", '<i class="fa fa-trash" aria-hidden="true"></i>']]]];
        }

        toListItem() {
          let _scope25 = {};

          const listItem = _element('li', _attributes(_attributeStringLiteral('tabindex', '1'), _attributeStringLiteral('draggable', 'true')), _children(_childExpression((self.__expressionAnalysisMode__ ? _traceMember(this, 'label') : void 0, this.label()))), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/client/triples/triples.js',
            end: {
              column: 74,
              line: 90
            },
            start: {
              column: 21,
              line: 90
            }
          });
          _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope25, 'listItem', listItem) : void 0, listItem), 'knot', this);

          if (self.__expressionAnalysisMode__) _traceMember(listItem, 'addEventListener');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope25, 'listItem', listItem) : void 0, listItem).addEventListener('keydown', event => {
            let _scope26 = {};

            if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope26, 'event', event) : void 0, event), 'keyCode') == 13) {
              if (self.__expressionAnalysisMode__) _traceMember(this, 'openViewInWindow');
              // ENTER
              this.openViewInWindow();
              if (self.__expressionAnalysisMode__) _traceMember(event, 'stopPropagation');
              (self.__expressionAnalysisMode__ ? _getLocal(_scope26, 'event', event) : void 0, event).stopPropagation();
              if (self.__expressionAnalysisMode__) _traceMember(event, 'preventDefault');
              (self.__expressionAnalysisMode__ ? _getLocal(_scope26, 'event', event) : void 0, event).preventDefault();
            }
          });
          if (self.__expressionAnalysisMode__) _traceMember(listItem, 'addEventListener');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope25, 'listItem', listItem) : void 0, listItem).addEventListener("dblclick", event => {
            let _scope27 = {};
            if (self.__expressionAnalysisMode__) _traceMember(this, 'openViewInWindow');

            this.openViewInWindow();
            if (self.__expressionAnalysisMode__) _traceMember(event, 'stopPropagation');
            (self.__expressionAnalysisMode__ ? _getLocal(_scope27, 'event', event) : void 0, event).stopPropagation();
            if (self.__expressionAnalysisMode__) _traceMember(event, 'preventDefault');
            (self.__expressionAnalysisMode__ ? _getLocal(_scope27, 'event', event) : void 0, event).preventDefault();
          });
          if (self.__expressionAnalysisMode__) _traceMember(listItem, 'addEventListener');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope25, 'listItem', listItem) : void 0, listItem).addEventListener("contextmenu", event => {
            let _scope28 = {};
            if (self.__expressionAnalysisMode__) _traceMember(ContextMenu, 'openIn');

            (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ContextMenu', ContextMenu) : void 0, ContextMenu).openIn(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('document') : void 0, document), 'body'), (self.__expressionAnalysisMode__ ? _getLocal(_scope28, 'event', event) : void 0, event), this, (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined), (self.__expressionAnalysisMode__ ? _traceMember(this, 'collectContextMenuItems') : void 0, this.collectContextMenuItems()));
            if (self.__expressionAnalysisMode__) _traceMember(event, 'stopPropagation');
            (self.__expressionAnalysisMode__ ? _getLocal(_scope28, 'event', event) : void 0, event).stopPropagation();
            if (self.__expressionAnalysisMode__) _traceMember(event, 'preventDefault');
            (self.__expressionAnalysisMode__ ? _getLocal(_scope28, 'event', event) : void 0, event).preventDefault();
          });

          return self.__expressionAnalysisMode__ ? _getLocal(_scope25, 'listItem', listItem) : void 0, listItem;
        }

        asDataForDrag(evt) {
          var _context2;

          let _scope29 = {};

          const dt = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'evt', evt) : void 0, evt), 'dataTransfer');
          //listItem.style.color = "blue";
          if (self.__expressionAnalysisMode__) _traceMember(dt, 'setData');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'dt', dt) : void 0, dt).setData("knot/url", _getMember(this, 'url'));
          if (self.__expressionAnalysisMode__) _traceMember(dt, 'setData');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'dt', dt) : void 0, dt).setData("text/uri-list", _getMember(this, 'url'));
          if (self.__expressionAnalysisMode__) _traceMember(dt, 'setData');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'dt', dt) : void 0, dt).setData("text/plain", _getMember(this, 'url'));
          if (self.__expressionAnalysisMode__) _traceMember(dt, 'setData');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'dt', dt) : void 0, dt).setData("javascript/object", (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getTempKeyFor', getTempKeyFor) : void 0, getTempKeyFor)(this));
          const mimeType = 'text/plain';
          const filename = (_context2 = _getMember(this, 'url'), (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'fileName', fileName) : void 0, fileName)).call(_context2);
          const url = _getMember(this, 'url');
          if (self.__expressionAnalysisMode__) _traceMember(dt, 'setData');
          (self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'dt', dt) : void 0, dt).setData("DownloadURL", `${(self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'mimeType', mimeType) : void 0, mimeType)}:${(self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'filename', filename) : void 0, filename)}:${(self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'url', url) : void 0, url)}`);

          // #TODO: remove duplication
          const dragInfo = _element('div', _attributes(_attributeStringLiteral('style', 'width: 150px;')), _children(_childText('\n      '), _childExpression((self.__expressionAnalysisMode__ ? _getLocal(_scope, 'hintForLabel', hintForLabel) : void 0, hintForLabel)((self.__expressionAnalysisMode__ ? _traceMember(this, 'label') : void 0, this.label()))), _childText('\n    ')), {
            file: 'https://lively-kernel.org/lively4/lively4-leo/src/client/triples/triples.js',
            end: {
              column: 10,
              line: 129
            },
            start: {
              column: 21,
              line: 127
            }
          });
          (_context2 = (self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'dragInfo', dragInfo) : void 0, dragInfo), (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'asDragImageFor', asDragImageFor) : void 0, asDragImageFor)).call(_context2, (self.__expressionAnalysisMode__ ? _getLocal(_scope29, 'evt', evt) : void 0, evt), 50, 60);
        }
      }

      _export('Knot', Knot);

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

        set(thisIsVererySecretVariableName) {
          let _scope30 = {};
          _export('Knot', Knot = (self.__expressionAnalysisMode__ ? _getLocal(_scope30, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'Knot', Knot) : void 0, Knot;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      class Triple extends Knot {
        constructor(fileName, content) {
          let _scope31 = {};

          try {
            if (self.__expressionAnalysisMode__) _traceMember(JSON, 'parse');

            (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).parse((self.__expressionAnalysisMode__ ? _getLocal(_scope31, 'content', content) : void 0, content));
          } catch (e) {
            debugger;
            if (self.__expressionAnalysisMode__) _traceMember(console, 'log');
            (self.__expressionAnalysisMode__ ? _getGlobal('console') : void 0, console).log((self.__expressionAnalysisMode__ ? _getLocal(_scope31, 'fileName', fileName) : void 0, fileName));
          }

          super((self.__expressionAnalysisMode__ ? _getLocal(_scope31, 'fileName', fileName) : void 0, fileName), (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'parse') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).parse((self.__expressionAnalysisMode__ ? _getLocal(_scope31, 'content', content) : void 0, content))));

          // track this Triple for ROQs after full initialization
        }

        label() {
          if (_getMember(this, 'predicate')) {
            return 't: ' + _getAndCallMember(_getMember(this, 'predicate'), 'label', []);
          }
          return _getAndCallMember(_getMember(this, 'filename'), 'replace', ['.triple.json', '']);
        }
        isTriple() {
          return true;
        }
      }

      _export('Triple', Triple);

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

        set(thisIsVererySecretVariableName) {
          let _scope32 = {};
          _export('Triple', Triple = (self.__expressionAnalysisMode__ ? _getLocal(_scope32, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'Triple', Triple) : void 0, Triple;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const DEFAULT_FOLDER_URL = 'https://lively4/notes/';

      _export('DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL);

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

        set(thisIsVererySecretVariableName) {
          let _scope33 = {};
          _export('DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope33, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const TAG_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL) + 'tag.md';

      _export('TAG_URL', TAG_URL);

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

        set(thisIsVererySecretVariableName) {
          let _scope34 = {};
          _export('TAG_URL', TAG_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope34, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'TAG_URL', TAG_URL) : void 0, TAG_URL;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const IS_A_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL) + 'is_a.md';

      _export('IS_A_URL', IS_A_URL);

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

        set(thisIsVererySecretVariableName) {
          let _scope35 = {};
          _export('IS_A_URL', IS_A_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope35, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'IS_A_URL', IS_A_URL) : void 0, IS_A_URL;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const SAME_AS_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL) + 'same_as.md';

      _export('SAME_AS_URL', SAME_AS_URL);

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

        set(thisIsVererySecretVariableName) {
          let _scope36 = {};
          _export('SAME_AS_URL', SAME_AS_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope36, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'SAME_AS_URL', SAME_AS_URL) : void 0, SAME_AS_URL;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const CONTAINS_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL) + 'contains.md';

      _export('CONTAINS_URL', CONTAINS_URL);

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

        set(thisIsVererySecretVariableName) {
          let _scope37 = {};
          _export('CONTAINS_URL', CONTAINS_URL = (self.__expressionAnalysisMode__ ? _getLocal(_scope37, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'CONTAINS_URL', CONTAINS_URL) : void 0, CONTAINS_URL;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const ROOT_KNOWLEDGE_BASES_KEY = 'triple-notes-root-knowledge-bases';
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      (self.__expressionAnalysisMode__ ? _getGlobal('Object') : void 0, Object).defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_client_triples_triples_js'), 'ROOT_KNOWLEDGE_BASES_KEY', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ROOT_KNOWLEDGE_BASES_KEY', ROOT_KNOWLEDGE_BASES_KEY) : void 0, ROOT_KNOWLEDGE_BASES_KEY;
        },

        set(thisIsVererySecretVariableName) {
          let _scope38 = {};
          ROOT_KNOWLEDGE_BASES_KEY = (self.__expressionAnalysisMode__ ? _getLocal(_scope38, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'ROOT_KNOWLEDGE_BASES_KEY', ROOT_KNOWLEDGE_BASES_KEY) : void 0, ROOT_KNOWLEDGE_BASES_KEY;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const PREFERRED_KNOWLEDGE_BASE_KEY = 'triple-notes-preferred-knowledge-base';

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

        set(thisIsVererySecretVariableName) {
          let _scope39 = {};
          PREFERRED_KNOWLEDGE_BASE_KEY = (self.__expressionAnalysisMode__ ? _getLocal(_scope39, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'PREFERRED_KNOWLEDGE_BASE_KEY', PREFERRED_KNOWLEDGE_BASE_KEY) : void 0, PREFERRED_KNOWLEDGE_BASE_KEY;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      function isInternalURL(url) {
        let _scope40 = {};

        const origin = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope40, 'url', url) : void 0, url), 'origin');
        return (self.__expressionAnalysisMode__ ? _getLocal(_scope40, 'origin', origin) : void 0, origin) === 'https://lively4' || (self.__expressionAnalysisMode__ ? _getLocal(_scope40, 'origin', origin) : void 0, origin) === 'https://localhost:8800';
      }
      function isExternalURL(url) {
        let _scope41 = {};
        return !(self.__expressionAnalysisMode__ ? _getLocal(_scope, 'isInternalURL', isInternalURL) : void 0, isInternalURL)((self.__expressionAnalysisMode__ ? _getLocal(_scope41, 'url', url) : void 0, url));
      }

      class Graph {
        constructor() {
          _setMember(this, 'knots', []);
          _setMember(this, 'loadedDirectoryPromises', new (self.__expressionAnalysisMode__ ? _getGlobal('Map') : void 0, Map)());
          // url string -> Promise for Knot
          _setMember(this, 'requestedKnots', new (self.__expressionAnalysisMode__ ? _getGlobal('Map') : void 0, Map)());
        }
        async prepare() {
          let _scope42 = {};

          const rootKnowledgeBases = await (self.__expressionAnalysisMode__ ? _traceMember(this, 'getRootKnowledgeBases') : void 0, this.getRootKnowledgeBases());
          return self.__expressionAnalysisMode__ ? _traceMember(Promise, 'all') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('Promise') : void 0, Promise).all((self.__expressionAnalysisMode__ ? _traceMember(rootKnowledgeBases, 'map') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope42, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases).map(this.loadFromDir.bind(this))));
        }

        async getRootKnowledgeBases() {
          return (await (self.__expressionAnalysisMode__ ? _traceMember(focalStorage, 'getItem') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'focalStorage', focalStorage) : void 0, focalStorage).getItem((self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ROOT_KNOWLEDGE_BASES_KEY', ROOT_KNOWLEDGE_BASES_KEY) : void 0, ROOT_KNOWLEDGE_BASES_KEY)))) || [(self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL)];
        }

        async addRootKnowledgeBase(urlString) {
          let _scope43 = {},
              _scope45 = {};

          try {
            let _scope44 = {};

            new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)((self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'urlString', urlString) : void 0, urlString));
            const stats = (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'parse') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).parse((await _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively), 'files'), 'statFile', [(self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'urlString', urlString) : void 0, urlString)]))));
            if (!(self.__expressionAnalysisMode__ ? _getLocal(_scope44, 'stats', stats) : void 0, stats) || _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope44, 'stats', stats) : void 0, stats), 'type') !== "directory") {
              throw new (self.__expressionAnalysisMode__ ? _getGlobal('Error') : void 0, Error)((self.__expressionAnalysisMode__ ? _getLocal(_scope44, 'stats', stats) : void 0, stats));
            }
          } catch (e) {
            if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');

            (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify(`Knowledge base ${(self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'urlString', urlString) : void 0, urlString)} not valid.`, _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope45, 'e', e) : void 0, e), 'message'), (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined), (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined), "red");
            return;
          }

          const rootKnowledgeBases = (await (self.__expressionAnalysisMode__ ? _traceMember(this, 'getRootKnowledgeBases') : void 0, this.getRootKnowledgeBases())) || [];
          if (!(self.__expressionAnalysisMode__ ? _traceMember(rootKnowledgeBases, 'includes') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases).includes((self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'urlString', urlString) : void 0, urlString)))) {
            if (self.__expressionAnalysisMode__) _traceMember(rootKnowledgeBases, 'push');

            (self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases).push((self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'urlString', urlString) : void 0, urlString));
            await (self.__expressionAnalysisMode__ ? _traceMember(focalStorage, 'setItem') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'focalStorage', focalStorage) : void 0, focalStorage).setItem((self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ROOT_KNOWLEDGE_BASES_KEY', ROOT_KNOWLEDGE_BASES_KEY) : void 0, ROOT_KNOWLEDGE_BASES_KEY), (self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases)));
            return await (self.__expressionAnalysisMode__ ? _traceMember(this, 'loadFromDir') : void 0, this.loadFromDir((self.__expressionAnalysisMode__ ? _getLocal(_scope43, 'urlString', urlString) : void 0, urlString)));
          }
        }

        async removeRootKnowledgeBase(urlString) {
          let _scope46 = {};

          let rootKnowledgeBases = (await (self.__expressionAnalysisMode__ ? _traceMember(this, 'getRootKnowledgeBases') : void 0, this.getRootKnowledgeBases())) || [];
          if (self.__expressionAnalysisMode__ ? _traceMember(rootKnowledgeBases, 'includes') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope46, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases).includes((self.__expressionAnalysisMode__ ? _getLocal(_scope46, 'urlString', urlString) : void 0, urlString))) {
            // remove via filter
            rootKnowledgeBases = (self.__expressionAnalysisMode__ ? _traceMember(rootKnowledgeBases, 'filter') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope46, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases).filter(rootBase => {
              let _scope47 = {};
              return (self.__expressionAnalysisMode__ ? _getLocal(_scope47, 'rootBase', rootBase) : void 0, rootBase) !== (self.__expressionAnalysisMode__ ? _getLocal(_scope46, 'urlString', urlString) : void 0, urlString);
            })), true ? _setLocal(_scope46, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases;
            await (self.__expressionAnalysisMode__ ? _traceMember(focalStorage, 'setItem') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'focalStorage', focalStorage) : void 0, focalStorage).setItem((self.__expressionAnalysisMode__ ? _getLocal(_scope, 'ROOT_KNOWLEDGE_BASES_KEY', ROOT_KNOWLEDGE_BASES_KEY) : void 0, ROOT_KNOWLEDGE_BASES_KEY), (self.__expressionAnalysisMode__ ? _getLocal(_scope46, 'rootKnowledgeBases', rootKnowledgeBases) : void 0, rootKnowledgeBases)));
            return true;
          } else {
            return false;
          }
        }

        getKnots() {
          return _getMember(this, 'knots');
        }
        hasKnotWithURL(url) {
          let _scope49 = {};

          return !!_getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, 'getKnots') : void 0, this.getKnots()), 'find', [knot => {
            let _scope48 = {};
            return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope48, 'knot', knot) : void 0, knot), 'url') === (self.__expressionAnalysisMode__ ? _getLocal(_scope49, 'url', url) : void 0, url);
          }]);
        }
        get triples() {
          return _getAndCallMember(_getMember(this, 'knots'), 'filter', [knot => {
            let _scope50 = {};
            return self.__expressionAnalysisMode__ ? _traceMember(knot, 'isTriple') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope50, 'knot', knot) : void 0, knot).isTriple();
          }]);
        }
        async deleteKnot(knot) {
          let _scope51 = {};

          // check for triples on top of the knot
          const referingTriples = _getAndCallMember(_getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, 'query') : void 0, this.query((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'knot', knot) : void 0, knot), (self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _), (self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _))), 'concat', [(self.__expressionAnalysisMode__ ? _traceMember(this, 'query') : void 0, this.query((self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _), (self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'knot', knot) : void 0, knot), (self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _)))]), 'concat', [(self.__expressionAnalysisMode__ ? _traceMember(this, 'query') : void 0, this.query((self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _), (self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _), (self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'knot', knot) : void 0, knot)))]);
          if (_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'referingTriples', referingTriples) : void 0, referingTriples), 'length') > 0) {
            if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');

            (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify('Deletion aborted!', `${_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'referingTriples', referingTriples) : void 0, referingTriples), 'length')} triples refer to this knot.`);
            return false;
          }

          let url = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'knot', knot) : void 0, knot), 'url');
          if (!(self.__expressionAnalysisMode__ ? _traceMember(window, 'confirm') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('window') : void 0, window).confirm("delete knot " + (self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'url', url) : void 0, url)))) {
            return false;
          }

          let index = _getAndCallMember(_getMember(this, 'knots'), 'indexOf', [(self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'knot', knot) : void 0, knot)]);
          if ((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'index', index) : void 0, index) > -1) {
            _getAndCallMember(_getMember(this, 'knots'), 'splice', [(self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'index', index) : void 0, index), 1]);
            if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');
            (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify(`Removed knot ${(self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'url', url) : void 0, url)} in local graph instance.`);
          } else {
            if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');

            (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify(`Did not find knot ${(self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'url', url) : void 0, url)} in local graph instance.`);
          }

          let urlURL = new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'url', url) : void 0, url));
          if (!(self.__expressionAnalysisMode__ ? _getLocal(_scope, 'isInternalURL', isInternalURL) : void 0, isInternalURL)((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'urlURL', urlURL) : void 0, urlURL))) {
            var result = await _getAndCallMember((self.__expressionAnalysisMode__ ? _getGlobal('fetch') : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'url', url) : void 0, url), { method: 'DELETE' }), 'then', [r => {
              let _scope52 = {};
              return self.__expressionAnalysisMode__ ? _traceMember(r, 'text') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope52, 'r', r) : void 0, r).text();
            }]);
            if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');
            (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify(`Deleted knot ${(self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'url', url) : void 0, url)} in remote storage`, (self.__expressionAnalysisMode__ ? _getLocal(_scope51, 'result', result) : void 0, result));
          }

          if (self.__expressionAnalysisMode__) _traceMember(lively, 'notify');
          (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).notify('Knot removed from graph.');

          return true;
        }

        async createReferree(triple, propName) {
          let _scope53 = {};

          let subjectUrlString = _getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'triple', triple) : void 0, triple), 'content'), (self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'propName', propName) : void 0, propName));
          let subjectUrl = new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)((self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'subjectUrlString', subjectUrlString) : void 0, subjectUrlString), _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'triple', triple) : void 0, triple), 'fileName'));
          let searchString = (self.__expressionAnalysisMode__ ? _traceMember(subjectUrl, 'toString') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'subjectUrl', subjectUrl) : void 0, subjectUrl).toString());

          let subject = await (self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'subjectUrl', subjectUrl) : void 0, subjectUrl)));
          //let subject = this.knots.find(knot => knot.fileName === searchString);
          if (self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'subject', subject) : void 0, subject) {
            _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'triple', triple) : void 0, triple), (self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'propName', propName) : void 0, propName), (self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'subject', subject) : void 0, subject));
          } else {
            throw new (self.__expressionAnalysisMode__ ? _getGlobal('Error') : void 0, Error)(`${(self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'searchString', searchString) : void 0, searchString)} ${_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope53, 'triple', triple) : void 0, triple), 'fileName')} external referrees not yet implemented!`);
          }
        }
        async linkUpTriple(triple) {
          let _scope54 = {};

          return self.__expressionAnalysisMode__ ? _traceMember(Promise, 'all') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('Promise') : void 0, Promise).all([(self.__expressionAnalysisMode__ ? _traceMember(this, 'createReferree') : void 0, this.createReferree((self.__expressionAnalysisMode__ ? _getLocal(_scope54, 'triple', triple) : void 0, triple), 'subject')), (self.__expressionAnalysisMode__ ? _traceMember(this, 'createReferree') : void 0, this.createReferree((self.__expressionAnalysisMode__ ? _getLocal(_scope54, 'triple', triple) : void 0, triple), 'predicate')), (self.__expressionAnalysisMode__ ? _traceMember(this, 'createReferree') : void 0, this.createReferree((self.__expressionAnalysisMode__ ? _getLocal(_scope54, 'triple', triple) : void 0, triple), 'object'))]);
        }

        static async getInstance() {
          if (!_getMember(this, 'instance')) {
            _setMember(this, 'instance', new (self.__expressionAnalysisMode__ ? _getLocal(_scope55, 'Graph', Graph) : void 0, Graph)());
          }

          await _getAndCallMember(_getMember(this, 'instance'), 'prepare', []);

          return _getMember(this, 'instance');
        }
        static clearInstance() {
          _setMember(this, 'instance', (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined));
        }

        query(s, p, o) {
          let _scope56 = {};

          return _getAndCallMember(_getAndCallMember(_getAndCallMember(_getMember(this, 'triples'), 'filter', [triple => {
            let _scope57 = {};
            return (self.__expressionAnalysisMode__ ? _getLocal(_scope56, 's', s) : void 0, s) === (self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _) || _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope57, 'triple', triple) : void 0, triple), 'subject') === (self.__expressionAnalysisMode__ ? _getLocal(_scope56, 's', s) : void 0, s);
          }]), 'filter', [triple => {
            let _scope58 = {};
            return (self.__expressionAnalysisMode__ ? _getLocal(_scope56, 'p', p) : void 0, p) === (self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _) || _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope58, 'triple', triple) : void 0, triple), 'predicate') === (self.__expressionAnalysisMode__ ? _getLocal(_scope56, 'p', p) : void 0, p);
          }]), 'filter', [triple => {
            let _scope59 = {};
            return (self.__expressionAnalysisMode__ ? _getLocal(_scope56, 'o', o) : void 0, o) === (self.__expressionAnalysisMode__ ? _getLocal(_scope, '_', _) : void 0, _) || _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope59, 'triple', triple) : void 0, triple), 'object') === (self.__expressionAnalysisMode__ ? _getLocal(_scope56, 'o', o) : void 0, o);
          }]);
        }

        getUrlsByKnot(knot) {
          let _scope60 = {};

          // TODO: we simply return the single reference url for now
          return [_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope60, 'knot', knot) : void 0, knot), 'fileName')];
        }

        // returns a promise for the Knot
        async requestKnot(url) {
          let _scope61 = {};

          const filePath = (self.__expressionAnalysisMode__ ? _traceMember(url, 'toString') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope61, 'url', url) : void 0, url).toString());
          if (!_getAndCallMember(_getMember(this, 'requestedKnots'), 'has', [(self.__expressionAnalysisMode__ ? _getLocal(_scope61, 'filePath', filePath) : void 0, filePath)])) {
            _getAndCallMember(_getMember(this, 'requestedKnots'), 'set', [(self.__expressionAnalysisMode__ ? _getLocal(_scope61, 'filePath', filePath) : void 0, filePath), (self.__expressionAnalysisMode__ ? _traceMember(this, 'loadSingleKnot') : void 0, this.loadSingleKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope61, 'url', url) : void 0, url)))]);
          }
          return _getAndCallMember(_getMember(this, 'requestedKnots'), 'get', [(self.__expressionAnalysisMode__ ? _getLocal(_scope61, 'filePath', filePath) : void 0, filePath)]);
        }

        async loadSingleKnot(urlOrString) {
          let _scope62 = {};

          const url = new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'urlOrString', urlOrString) : void 0, urlOrString));

          let fileName = (self.__expressionAnalysisMode__ ? _traceMember(url, 'toString') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'url', url) : void 0, url).toString());
          let text = (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'isExternalURL', isExternalURL) : void 0, isExternalURL)((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'url', url) : void 0, url)) ? _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'url', url) : void 0, url), 'hostname') + _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'url', url) : void 0, url), 'pathname') : await _getAndCallMember(_getAndCallMember((self.__expressionAnalysisMode__ ? _getGlobal('fetch') : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'url', url) : void 0, url)), 'then', [r => {
            let _scope63 = {};
            return self.__expressionAnalysisMode__ ? _traceMember(r, 'text') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope63, 'r', r) : void 0, r).text();
          }]), 'catch', [err => {
            let _scope64 = {};
            return `ERROR loading this knot: ${(self.__expressionAnalysisMode__ ? _getLocal(_scope64, 'err', err) : void 0, err)}`;
          }]);

          // deserializeKnot
          const isTriple = (self.__expressionAnalysisMode__ ? _traceMember(fileName, 'endsWith') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'fileName', fileName) : void 0, fileName).endsWith(".triple.json"));

          let knot;
          if (self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'isTriple', isTriple) : void 0, isTriple) {
            knot = new (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'Triple', Triple) : void 0, Triple)((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'fileName', fileName) : void 0, fileName), (self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'text', text) : void 0, text)), true ? _setLocal(_scope62, 'knot', knot) : void 0, knot;
            await (self.__expressionAnalysisMode__ ? _traceMember(this, 'linkUpTriple') : void 0, this.linkUpTriple((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'knot', knot) : void 0, knot)));
            if (self.__expressionAnalysisMode__) _traceMember(trackInstance, 'call');
            (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'trackInstance', trackInstance) : void 0, trackInstance).call((self.__expressionAnalysisMode__ ? _getLocal(_scope, 'Triple', Triple) : void 0, Triple), (self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'knot', knot) : void 0, knot));
          } else {
            knot = new (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'Knot', Knot) : void 0, Knot)((self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'fileName', fileName) : void 0, fileName), (self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'text', text) : void 0, text)), true ? _setLocal(_scope62, 'knot', knot) : void 0, knot;
          }

          _getAndCallMember(_getMember(this, 'knots'), 'push', [(self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'knot', knot) : void 0, knot)]);

          return self.__expressionAnalysisMode__ ? _getLocal(_scope62, 'knot', knot) : void 0, knot;
        }

        async loadFromDir(directory) {
          let _scope65 = {};

          if (!_getAndCallMember(_getMember(this, 'loadedDirectoryPromises'), 'has', [(self.__expressionAnalysisMode__ ? _getLocal(_scope65, 'directory', directory) : void 0, directory)])) {
            _getAndCallMember(_getMember(this, 'loadedDirectoryPromises'), 'set', [(self.__expressionAnalysisMode__ ? _getLocal(_scope65, 'directory', directory) : void 0, directory), new (self.__expressionAnalysisMode__ ? _getGlobal('Promise') : void 0, Promise)(async resolve => {
              let _scope66 = {};

              const progress = await (self.__expressionAnalysisMode__ ? _traceMember(lively, 'showProgress') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).showProgress(`loading dir ${(self.__expressionAnalysisMode__ ? _getLocal(_scope65, 'directory', directory) : void 0, directory)}`));
              _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'progress', progress) : void 0, progress), 'value', 0);

              const directoryURL = new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)((self.__expressionAnalysisMode__ ? _getLocal(_scope65, 'directory', directory) : void 0, directory));
              const json = await _getAndCallMember((self.__expressionAnalysisMode__ ? _getGlobal('fetch') : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope65, 'directory', directory) : void 0, directory), { method: 'OPTIONS' }), 'then', [r => {
                let _scope67 = {};
                return self.__expressionAnalysisMode__ ? _traceMember(r, 'json') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope67, 'r', r) : void 0, r).json();
              }]);
              const fileNames = _getAndCallMember(_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'json', json) : void 0, json), 'contents'), 'filter', [desc => {
                let _scope68 = {};
                return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope68, 'desc', desc) : void 0, desc), 'type') === "file";
              }]), 'map', [desc => {
                let _scope69 = {};
                return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope69, 'desc', desc) : void 0, desc), 'name');
              }]);

              const total = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'fileNames', fileNames) : void 0, fileNames), 'length');
              let i = 0;
              const pool = new (self.__expressionAnalysisMode__ ? _getGlobal('Set') : void 0, Set)();
              const limit = 100;
              const arr = [1, 2, 3, 4, 5, 6];
              let ii = 0;
              const groups = (self.__expressionAnalysisMode__ ? _traceMember(fileNames, 'groupBy') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'fileNames', fileNames) : void 0, fileNames).groupBy((...args) => {
                return _getAndCallMember(((ii += 1, true ? _setLocal(_scope66, 'ii', ii) : void 0, ii) - 1) / (self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'limit', limit) : void 0, limit), 'floor', []);
              }));
              for (let group of (self.__expressionAnalysisMode__ ? _traceMember(Object, 'values') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('Object') : void 0, Object).values((self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'groups', groups) : void 0, groups)))) {
                let _scope70 = {};

                await (self.__expressionAnalysisMode__ ? _traceMember(Promise, 'all') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('Promise') : void 0, Promise).all((self.__expressionAnalysisMode__ ? _traceMember(group, 'map') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope70, 'group', group) : void 0, group).map(fileName => {
                  let _scope71 = {};

                  const knotURL = new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)((self.__expressionAnalysisMode__ ? _getLocal(_scope71, 'fileName', fileName) : void 0, fileName), (self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'directoryURL', directoryURL) : void 0, directoryURL));
                  const prom = (self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope71, 'knotURL', knotURL) : void 0, knotURL)));
                  _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'progress', progress) : void 0, progress), 'value', ((i += 1, true ? _setLocal(_scope66, 'i', i) : void 0, i) - 1) / (self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'total', total) : void 0, total));
                  return self.__expressionAnalysisMode__ ? _getLocal(_scope71, 'prom', prom) : void 0, prom;
                }))));
              }

              await (self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'resolve', resolve) : void 0, resolve)();
              await (self.__expressionAnalysisMode__ ? _traceMember(progress, 'remove') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope66, 'progress', progress) : void 0, progress).remove());
            })]);
          }
          return _getAndCallMember(_getMember(this, 'loadedDirectoryPromises'), 'get', [(self.__expressionAnalysisMode__ ? _getLocal(_scope65, 'directory', directory) : void 0, directory)]);
        }

        escapeSpecialCharacters(str) {
          let _scope72 = {};

          return self.__expressionAnalysisMode__ ? _traceMember(str, 'replace') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope72, 'str', str) : void 0, str).replace(/[^A-Za-z0-9-]/g, '_');
        }

        async fileForNameExists(name) {
          let _scope73 = {};

          const url = new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)(`${(self.__expressionAnalysisMode__ ? _traceMember(this, 'escapeSpecialCharacters') : void 0, this.escapeSpecialCharacters((self.__expressionAnalysisMode__ ? _getGlobal('str') : void 0, str)))}.md`, (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL));
          return _getMember((await (self.__expressionAnalysisMode__ ? _getGlobal('fetch') : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope73, 'url', url) : void 0, url))), 'status') === 200;
        }

        async getOrCreateKnotForTitle(name, defaultText = '# Default Text') {
          let _scope74 = {};

          const escapedName = (self.__expressionAnalysisMode__ ? _traceMember(this, 'escapeSpecialCharacters') : void 0, this.escapeSpecialCharacters((self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'name', name) : void 0, name)));
          const proposedURL = `${(self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL)}${(self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'escapedName', escapedName) : void 0, escapedName)}.md`;

          const existingKnot = _getAndCallMember((self.__expressionAnalysisMode__ ? _traceMember(this, 'getKnots') : void 0, this.getKnots()), 'find', [knot => {
            let _scope75 = {};

            return _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope75, 'knot', knot) : void 0, knot), 'url') === (self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'proposedURL', proposedURL) : void 0, proposedURL);
          }]);
          if (self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'existingKnot', existingKnot) : void 0, existingKnot) {
            if (self.__expressionAnalysisMode__) _traceMember(lively, 'success');

            (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).success('EXISTS IN MEMORY');
            return self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'existingKnot', existingKnot) : void 0, existingKnot;
          }

          const fileExists = _getMember((await (self.__expressionAnalysisMode__ ? _getGlobal('fetch') : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'proposedURL', proposedURL) : void 0, proposedURL))), 'status') === 200;
          if (self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'fileExists', fileExists) : void 0, fileExists) {
            if (self.__expressionAnalysisMode__) _traceMember(lively, 'success');

            (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).success('EXISTS REMOTELY');
            return self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'proposedURL', proposedURL) : void 0, proposedURL));
          }

          if (self.__expressionAnalysisMode__) _traceMember(lively, 'warn');
          (self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively).warn('NON EXISTENT');
          return self.__expressionAnalysisMode__ ? _traceMember(this, 'createKnot') : void 0, this.createKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope, 'DEFAULT_FOLDER_URL', DEFAULT_FOLDER_URL) : void 0, DEFAULT_FOLDER_URL), (self.__expressionAnalysisMode__ ? _getLocal(_scope74, 'name', name) : void 0, name), 'md');
        }

        async getNonCollidableURL(directory, name, fileEnding) {
          let _scope76 = {};

          const maxTries = 10;
          const fileName = (self.__expressionAnalysisMode__ ? _traceMember(this, 'escapeSpecialCharacters') : void 0, this.escapeSpecialCharacters((self.__expressionAnalysisMode__ ? _getLocal(_scope76, 'name', name) : void 0, name)));
          let offset = 0;
          let i = 0;

          for (; i < maxTries; i++) {
            let _scope77 = {};

            let bust = (self.__expressionAnalysisMode__ ? _getLocal(_scope76, 'offset', offset) : void 0, offset) === 0 ? '' : (self.__expressionAnalysisMode__ ? _getLocal(_scope76, 'offset', offset) : void 0, offset);
            let url = new (self.__expressionAnalysisMode__ ? _getGlobal('URL') : void 0, URL)(`${(self.__expressionAnalysisMode__ ? _getLocal(_scope76, 'fileName', fileName) : void 0, fileName)}${(self.__expressionAnalysisMode__ ? _getLocal(_scope77, 'bust', bust) : void 0, bust)}.${(self.__expressionAnalysisMode__ ? _getLocal(_scope76, 'fileEnding', fileEnding) : void 0, fileEnding)}`, (self.__expressionAnalysisMode__ ? _getLocal(_scope76, 'directory', directory) : void 0, directory));
            let fileExists = _getMember((await (self.__expressionAnalysisMode__ ? _getGlobal('fetch') : void 0, fetch)((self.__expressionAnalysisMode__ ? _getLocal(_scope77, 'url', url) : void 0, url))), 'status') === 200;
            if (self.__expressionAnalysisMode__ ? _getLocal(_scope77, 'fileExists', fileExists) : void 0, fileExists) {
              (offset += 1, true ? _setLocal(_scope76, 'offset', offset) : void 0, offset) - 1;
            } else {
              return self.__expressionAnalysisMode__ ? _getLocal(_scope77, 'url', url) : void 0, url;
            }
          }
          throw new (self.__expressionAnalysisMode__ ? _getGlobal('Error') : void 0, Error)('too many tries for '); // TODO: improve error message
        }
        async createKnot(directory, name, fileEnding) {
          let _scope78 = {};

          if ((self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'fileEnding', fileEnding) : void 0, fileEnding) !== 'md') {
            throw new (self.__expressionAnalysisMode__ ? _getGlobal('Error') : void 0, Error)('only .md files supported by now, instead found ', +(self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'fileEnding', fileEnding) : void 0, fileEnding));
          }

          let url = await (self.__expressionAnalysisMode__ ? _traceMember(this, 'getNonCollidableURL') : void 0, this.getNonCollidableURL((self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'directory', directory) : void 0, directory), (self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'name', name) : void 0, name), (self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'fileEnding', fileEnding) : void 0, fileEnding)));
          let content = `# ${(self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'name', name) : void 0, name)}

`;
          await _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively), 'files'), 'saveFile', [(self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'url', url) : void 0, url), (self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'content', content) : void 0, content)]);

          return self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope78, 'url', url) : void 0, url));
        }
        async createTriple(subjectUrlString, predicateURLString, objectURLString, knowledgeBaseURLString) {
          let _scope79 = {};

          await (self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope79, 'subjectUrlString', subjectUrlString) : void 0, subjectUrlString)));
          await (self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope79, 'predicateURLString', predicateURLString) : void 0, predicateURLString)));
          await (self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope79, 'objectURLString', objectURLString) : void 0, objectURLString)));

          const url = await (self.__expressionAnalysisMode__ ? _traceMember(this, 'getNonCollidableURL') : void 0, this.getNonCollidableURL((self.__expressionAnalysisMode__ ? _getLocal(_scope79, 'knowledgeBaseURLString', knowledgeBaseURLString) : void 0, knowledgeBaseURLString), 'triple-' + (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'uuid', uuid) : void 0, uuid)(), 'triple.json'));
          const content = (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'stringify') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).stringify({
            subject: subjectUrlString,
            predicate: predicateURLString,
            object: objectURLString
          }));
          await _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('lively') : void 0, lively), 'files'), 'saveFile', [(self.__expressionAnalysisMode__ ? _getLocal(_scope79, 'url', url) : void 0, url), (self.__expressionAnalysisMode__ ? _getLocal(_scope79, 'content', content) : void 0, content)]);

          //await invalidateFetchCache(knowledgeBaseURLString);

          return self.__expressionAnalysisMode__ ? _traceMember(this, 'requestKnot') : void 0, this.requestKnot((self.__expressionAnalysisMode__ ? _getLocal(_scope79, 'url', url) : void 0, url));
        }

      }

      // wild card for querying

      _export('Graph', Graph);

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

        set(thisIsVererySecretVariableName) {
          let _scope80 = {};
          _export('Graph', Graph = (self.__expressionAnalysisMode__ ? _getLocal(_scope80, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'Graph', Graph) : void 0, Graph;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      const _ = {};

      _export('_', _);

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

        set(thisIsVererySecretVariableName) {
          let _scope81 = {};
          _export('_', _ = (self.__expressionAnalysisMode__ ? _getLocal(_scope81, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, '_', _) : void 0, _;
          return true;
        },

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