System.register(["src/components/widgets/lively-morph.js"], function (_export, _context) {
  "use strict";

  var Morph;
  return {
    setters: [function (_srcComponentsWidgetsLivelyMorphJs) {
      Morph = _srcComponentsWidgetsLivelyMorphJs.default;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_components_widgets_lively_import_js = _recorder_._src_components_widgets_lively_import_js || {};
      Object.defineProperty(_recorder_._src_components_widgets_lively_import_js, "Morph", {
        get() {
          return Morph;
        },

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

        enumerable: true,
        configurable: true
      });
      class LivelyImport extends Morph {
        async initialize() {
          lively.html.registerAttributeObservers(this);
          this.update();
        }

        async onSrcChanged() {
          this.update();
        }

        async update() {
          let url = this.getAttribute("src");
          if (!url) return;
          let src = await fetch("cached:" + url).then(r => r.text());

          if (url !== this.getAttribute("src")) return; // check if we are still on the same url...

          /*MD ## #TODO support markdown beside HTML    
          see [appendMarkdown](edit://src/components/tools/lively-container.js#appendMarkdown)
          MD*/
          this.shadowRoot.innerHTML = "" + src;
          let container = lively.query(this, "lively-container");
          if (container) {
            let dir = url.replace(/[^/]*$/, "");
            lively.html.fixLinks(this.shadowRoot.childNodes, dir, path => container.followPath(path));
          }
          await lively.components.loadUnresolved(this.shadowRoot, false, "lively-import", true);
        }

      }

      _export("default", LivelyImport);

      Object.defineProperty(_recorder_._src_components_widgets_lively_import_js, "LivelyImport", {
        get() {
          return LivelyImport;
        },

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

          return true;
        },

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