System.register(['./lively-halo-grab-item.js', 'src/client/morphic/node-helpers.js', 'src/client/morphic/event-helpers.js', 'src/client/graphics.js', 'src/client/script-manager.js', 'src/client/persistence.js'], function (_export, _context) {
  "use strict";

  var HaloGrabItem, nodes, events, pt, scriptManager, persistence;
  return {
    setters: [function (_livelyHaloGrabItemJs) {
      HaloGrabItem = _livelyHaloGrabItemJs.default;
    }, function (_srcClientMorphicNodeHelpersJs) {
      nodes = _srcClientMorphicNodeHelpersJs;
    }, function (_srcClientMorphicEventHelpersJs) {
      events = _srcClientMorphicEventHelpersJs;
    }, function (_srcClientGraphicsJs) {
      pt = _srcClientGraphicsJs.pt;
    }, function (_srcClientScriptManagerJs) {
      scriptManager = _srcClientScriptManagerJs.default;
    }, function (_srcClientPersistenceJs) {
      persistence = _srcClientPersistenceJs.default;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_components_halo_lively_halo_copy_item_js = _recorder_._src_components_halo_lively_halo_copy_item_js || {};
      Object.defineProperty(_recorder_._src_components_halo_lively_halo_copy_item_js, 'HaloGrabItem', {
        get() {
          return HaloGrabItem;
        },

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

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

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

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

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

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

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

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

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

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

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

        enumerable: true,
        configurable: true
      });


      var copyBlacklist = ["body", "html"];

      Object.defineProperty(_recorder_._src_components_halo_lively_halo_copy_item_js, 'copyBlacklist', {
        get() {
          return copyBlacklist;
        },

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

        enumerable: true,
        configurable: true
      });
      class HaloCopyItem extends HaloGrabItem {

        get isCopyItem() {
          return true;
        }

        onClick() {
          if (!this.copiedObject) {
            this.copyObject(window.that);
            this.copiedObject.style.position = 'absolute';
            nodes.setPosition(this.copiedObject, nodes.getPosition(this.copyTarget).addPt(pt(10, 10)));
            window.that = this.copiedObject;
            window.HaloService.showHalos(that);
          }
          this.copiedObject = null;
        }

        cloneObject(obj) {
          var html = lively.clipboard.nodesToHTML([obj]);
          lively.clipboard.lastClickPos = lively.getGlobalPosition(obj // used in pasted as offset
          );var result = lively.clipboard.pasteHTMLDataInto(html, obj.parentElement, true);
          return result[0];
        }

        copyObject(el) {
          this.copyTarget = el;
          if (el.haloCopyObject) {
            this.copiedObject = el.haloCopyObject(this); // copy selection etc...
          } else {
            if (this.isAllowedToBeCopied(this.copyTarget)) {
              this.copiedObject = this.cloneObject(this.copyTarget);
              this.copyTarget.parentNode.appendChild(this.copiedObject);
            } else {
              lively.notify("Could not copy " + sourceObj);
            }
          }
          return this.copiedObject;
        }

        isAllowedToBeCopied(element) {
          return copyBlacklist.indexOf(element.tagName.toLowerCase()) < 0;
        }

        // DRAG API
        prepareGrabTarget() {
          this.grabTarget = this.copyObject(this.grabTarget);
          window.that = this.grabTarget;
          HaloService.showHalos(this.grabTarget);

          super.prepareGrabTarget();
        }
      }

      _export('default', HaloCopyItem);

      Object.defineProperty(_recorder_._src_components_halo_lively_halo_copy_item_js, 'HaloCopyItem', {
        get() {
          return HaloCopyItem;
        },

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

          return true;
        },

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