import MapEditTool from './map-edit-tool';

export default class MapMergeTool extends MapEditTool {
  startPoint: any;

  constructor(mapEditLayer) {
    super(mapEditLayer, 'map-edit-merge',
      'url("/static/cursor/cursor-link.png") 24 24, default');
    this.startPoint = null;
  }

  override onmousedown(evt: MouseEvent) {
    console.log('MapMergeTool@onmousedown()');
    this.startPoint = evt._contentPoint;
  }


  override onDragStart(evt: MouseEvent) {
    if (!this.mapEditLayer)
      return;
    console.log('MapMergeTool@onDragStart()', evt._contentPoint);
  }

  override onDragMove(evt: MouseEvent) { }

  override onDragEnd(evt: MouseEvent) {
    if (!this.mapEditLayer || !this.startPoint)
      return;
    console.log('MapMergeTool@onDragEnd()', evt);
    console.log('do merge: ', this.startPoint, evt._contentPoint);
    this.mapEditLayer.merge(this.startPoint, evt._contentPoint);
  }
}
