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

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

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

        enumerable: true,
        configurable: true
      });
      class HalloNameItem extends HaloItem {

        initialize() {
          lively.html.registerKeys(this.get("#name"), "Halo", this);
          this.draggable = true;
          this.addEventListener("dragstart", evt => this.onCustomDragStart(evt));
          this.addEventListener("drag", evt => this.onCustomDrag(evt));
        }

        async onCustomDragStart(evt) {
          // lively.notify("drag2")
          var target = that;
          let url = lively.files.tempfile(),
              name = (target.id || "unnamed") + ".html",
              mimetype = "text/html";
          lively.files.saveFile(url, target.outerHTML
          // there can be a race condition, when the url is faster requested 
          // than it is actually loaded #Hack 
          // This is a #Problem, but we cannot wait after until after we told the server, because the dataTransfer have to be intialized syncronously 
          // so we hope fore the best!
          );evt.dataTransfer.setData("DownloadURL", `${mimetype}:${name}:${url}`);

          evt.dataTransfer.setData("text/html", target.outerHTML);
          evt.dataTransfer.setData("text/plain", target.textContent);
        }

        onCustomDrag(evt) {
          evt.stopPropagation();
        }

        onEnterDown(evt) {
          evt.stopPropagation();
          evt.preventDefault();
          this.target.id = this.get("#name").textContent;
          lively.focusWithoutScroll(document.body);
        }

        onLeftDown(evt) {
          evt.stopPropagation(); // don't move halo, but text cursor
        }

        onRightDown(evt) {
          evt.stopPropagation(); // don't move halo, but text cursor
        }

        updateTarget(target) {
          this.target = target;
          if (target.id) {
            this.get("#name").textContent = target.id;
          } else {
            this.get("#name").textContent = "";
          }

          this.get("#classname").textContent = this.target.tagName.toLowerCase() + (this.target.classList.length > 0 ? "." + Array.from(this.target.classList).join(".") : "");
        }
      }

      _export("default", HalloNameItem);

      Object.defineProperty(_recorder_._src_components_halo_lively_halo_name_item_js, "HalloNameItem", {
        get() {
          return HalloNameItem;
        },

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

          return true;
        },

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