System.register(["src/client/lively.js", "src/client/morphic/node-helpers.js", "src/client/morphic/event-helpers.js", "src/client/graphics.js", "src/components/halo/lively-halo-item.js", "src/client/preferences.js", "src/client/morphic/snapping.js", "src/client/vivide/components/vivide-view.js", "src/client/svg.js", "utils"], function (_export, _context) {
  "use strict";

  var lively, nodes, events, pt, HaloItem, Preferences, Snapping, Grid, VivideView, svg, cancelEvent, HaloVivideInportConnectionItem, __SystemJSRewritingHack;
  _export("default", void 0);
  return {
    setters: [function (_srcClientLivelyJs) {
      lively = _srcClientLivelyJs.default;
    }, function (_srcClientMorphicNodeHelpersJs) {
      nodes = _srcClientMorphicNodeHelpersJs;
    }, function (_srcClientMorphicEventHelpersJs) {
      events = _srcClientMorphicEventHelpersJs;
    }, function (_srcClientGraphicsJs) {
      pt = _srcClientGraphicsJs.pt;
    }, function (_srcComponentsHaloLivelyHaloItemJs) {
      HaloItem = _srcComponentsHaloLivelyHaloItemJs.default;
    }, function (_srcClientPreferencesJs) {
      Preferences = _srcClientPreferencesJs.default;
    }, function (_srcClientMorphicSnappingJs) {
      Snapping = _srcClientMorphicSnappingJs.default;
      Grid = _srcClientMorphicSnappingJs.Grid;
    }, function (_srcClientVivideComponentsVivideViewJs) {
      VivideView = _srcClientVivideComponentsVivideViewJs.default;
    }, function (_srcClientSvgJs) {
      svg = _srcClientSvgJs.default;
    }, function (_utils) {
      cancelEvent = _utils.cancelEvent;
    }],
    execute: function () {
      __SystemJSRewritingHack = {};
      _recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js = _recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js || {};
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "lively", {
        get() {
          return lively;
        },
        set(thisIsVererySecretVariableName) {
          lively = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "nodes", {
        get() {
          return nodes;
        },
        set(thisIsVererySecretVariableName) {
          nodes = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "events", {
        get() {
          return events;
        },
        set(thisIsVererySecretVariableName) {
          events = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "pt", {
        get() {
          return pt;
        },
        set(thisIsVererySecretVariableName) {
          pt = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "HaloItem", {
        get() {
          return HaloItem;
        },
        set(thisIsVererySecretVariableName) {
          HaloItem = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "Preferences", {
        get() {
          return Preferences;
        },
        set(thisIsVererySecretVariableName) {
          Preferences = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "Snapping", {
        get() {
          return Snapping;
        },
        set(thisIsVererySecretVariableName) {
          Snapping = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "Grid", {
        get() {
          return Grid;
        },
        set(thisIsVererySecretVariableName) {
          Grid = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "VivideView", {
        get() {
          return VivideView;
        },
        set(thisIsVererySecretVariableName) {
          VivideView = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "svg", {
        get() {
          return svg;
        },
        set(thisIsVererySecretVariableName) {
          svg = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "cancelEvent", {
        get() {
          return cancelEvent;
        },
        set(thisIsVererySecretVariableName) {
          cancelEvent = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      _export("default", HaloVivideInportConnectionItem = class HaloVivideInportConnectionItem extends HaloItem {
        get path() {
          return this.get('#path-to-target');
        }
        get overlay() {
          return this.get('#overlay-target');
        }
        initialize() {
          this.addEventListener('click', evt => this.removeConnection(evt));
          this.path.addEventListener('click', cancelEvent);
          this.overlay.addEventListener('click', cancelEvent);
        }
        setSource(source) {
          this._source = source;
        }
        updateTarget(view) {
          this._view = view;
          if (!this._source) {
            this.classList.add('broken');
            return;
          }
          let offset = lively.getClientPosition(this.get('svg'));
          let startPoint = lively.getClientBounds(this).leftCenter().subPt(offset);
          let startOffsetPoint = startPoint.addPt(pt(-20, 0));
          let sourceCenterPoint = lively.getClientCenter(this._source).subPt(offset);
          svg.setPathVertices(this.path, [{
            c: 'M',
            x1: startPoint.x,
            y1: startPoint.y
          }, {
            c: 'L',
            x1: startOffsetPoint.x,
            y1: startOffsetPoint.y
          }, {
            c: 'L',
            x1: startOffsetPoint.x,
            y1: sourceCenterPoint.y
          }, {
            c: 'L',
            x1: sourceCenterPoint.x,
            y1: sourceCenterPoint.y
          }]);
          lively.setClientPosition(this.overlay, lively.getClientPosition(this._source));
          lively.setExtent(this.overlay, lively.getClientBounds(this._source).extent());
        }
        removeConnection(evt) {
          lively.notify('target', evt.target);
          if (this._view && this._source) {
            this._source.removeOutportTarget(this._view);
            lively.haloService.showHalos(window.that);
            cancelEvent(evt);
          }
        }
      });
      Object.defineProperty(_recorder_._https__lively_kernel_org_lively4_lively4_ansgar_src_components_halo_lively_halo_vivide_inport_connection_item_js, "HaloVivideInportConnectionItem", {
        get() {
          return HaloVivideInportConnectionItem;
        },
        set(thisIsVererySecretVariableName) {
          _export("default", HaloVivideInportConnectionItem = thisIsVererySecretVariableName);
          return true;
        },
        enumerable: true,
        configurable: true
      });
    }
  };
});