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

  var _addSourceLocation, Morph, Files;

  return {
    setters: [function (_reactiveJsx) {
      _addSourceLocation = _reactiveJsx.addSourceLocation;
    }, function (_srcComponentsWidgetsLivelyMorphJs) {
      Morph = _srcComponentsWidgetsLivelyMorphJs.default;
    }, function (_srcClientFilesJs) {
      Files = _srcClientFilesJs.default;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_components_widgets_lively_error_js = _recorder_._src_components_widgets_lively_error_js || {};
      Object.defineProperty(_recorder_._src_components_widgets_lively_error_js, 'Morph', {
        get() {
          return Morph;
        },

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

        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._src_components_widgets_lively_error_js, 'Files', {
        get() {
          return Files;
        },

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

        enumerable: true,
        configurable: true
      });
      class LivelyError extends Morph {

        initialize() {
          this.update();
        }

        set stack(s) {
          this.setAttribute("stack", s);
          this.update();
        }

        get stack() {
          return this.getAttribute("stack");
        }

        update() {
          var stack = this.getAttribute("stack");
          if (!stack) return;

          stack.split("\n").forEach(line => {
            let lineSpan = _addSourceLocation(document.createElement("span"), {
              file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/widgets/lively-error.js',
              end: {
                column: 51,
                line: 24
              },
              start: {
                column: 21,
                line: 24
              }
            });
            var m = line.match(/(.*?)\(?(https?:\/\/.*:[0-9]+:[0-9]+)/);
            if (m) {
              var call = m[1];
              var ref = Files.parseSourceReference(m[2]);
              lineSpan.textContent = call;
              var link = _addSourceLocation(document.createElement("a"), {
                file: 'https://lively-kernel.org/lively4/lively4-leo/src/components/widgets/lively-error.js',
                end: {
                  column: 46,
                  line: 30
                },
                start: {
                  column: 19,
                  line: 30
                }
              });
              link.textContent = ref.url.replace(lively4url, "") + "\n";
              link.href = ref.url;
              link.addEventListener("click", evt => {
                evt.preventDefault();
                lively.openBrowser(ref.url, true, ref);
                return true;
              });

              lineSpan.appendChild(link);
            } else {
              lineSpan.textContent = "" + line + "\n";
            }
            this.get("#stack").appendChild(lineSpan);
          });
        }

        livelyExample() {
          try {
            var foo = {};
            foo.bar();
          } catch (e) {
            this.stack = e.stack;
          }
        }
      }

      _export('default', LivelyError);

      Object.defineProperty(_recorder_._src_components_widgets_lively_error_js, 'LivelyError', {
        get() {
          return LivelyError;
        },

        set(thisIsVererySecretVariableName) {
          _export('default', LivelyError = thisIsVererySecretVariableName);

          return true;
        },

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