System.register([], function (_export, _context) {
  "use strict";

  return {
    setters: [],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_worker_systemjs_worker_js = _recorder_._src_worker_systemjs_worker_js || {};
      /* client side worker loading with SystemJS modules...*/

      var workers = _recorder_._src_worker_systemjs_worker_js.workers;

      _export("workers", workers);

      Object.defineProperty(_recorder_._src_worker_systemjs_worker_js, "workers", {
        get() {
          return workers;
        },

        set(thisIsVererySecretVariableName) {
          _export("workers", workers = thisIsVererySecretVariableName);

          return true;
        },

        enumerable: true,
        configurable: true
      });
      class SystemjsWorker {

        static get workers() {
          if (!workers) _recorder_._src_worker_systemjs_worker_js.workers = new Set();
          return workers;
        }

        constructor(url) {
          this.metaworker = new Worker("src/worker/meta-worker.js");
          // bootstrap onmessage
          this.loaded = new Promise(resolve => {
            this.metaworker.onmessage = evt => {
              var msg = evt.data;
              console.log("bootstrap onmessage", msg);
              if (msg.message == "error") {
                lively.error("[systemjs-worker]", msg.error || msg.value);
              }
              if (msg.message == "loaded") {
                console.log("worker loaded", url);
                this.metaworker.onmessage = msg => {
                  console.log("new onmessage");
                  this.onmessage(msg);
                };
                resolve // worker should accept postMessages now...
                ();
              }
            };
          });
          this.metaworker.postMessage({ message: "load", url: url });
          SystemjsWorker.workers.add(this);
        }

        onmessage(evt) {
          // do nothing
        }

        terminate() {
          this.metaworker.terminate();
          SystemjsWorker.workers.delete(this);
        }

        async postMessage(msg) {
          await this.loaded;
          this.metaworker.postMessage(msg);
        }

      }

      _export("default", SystemjsWorker);

      Object.defineProperty(_recorder_._src_worker_systemjs_worker_js, "SystemjsWorker", {
        get() {
          return SystemjsWorker;
        },

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

          return true;
        },

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