import { Directive, ElementRef, HostBinding, Input } from '@angular/core';
import { RelationsNodeManager } from '../services';
import { RelationsCanvasSAComponent } from './relationsCanvas/relationsCanvas.component';
import * as i0 from "@angular/core";
import * as i1 from "../services";
import * as i2 from "./relationsCanvas/relationsCanvas.component";
/**
 * Base class for relations node endpoints (inputs/outputs)
 */
export class RelationNodeEndpointBase {
    /**
     * @inheritdoc
     */
    get parentId() {
        return this.parent?.id ?? '';
    }
    //######################### constructor #########################
    constructor(element, relationManager, canvas) {
        this.element = element;
        this.relationManager = relationManager;
        this.canvas = canvas;
        /**
         * Indication whether component is dragging
         */
        this.isDragging = false;
        /**
         * Indication whether node endpoint is highlighted
         */
        this.isHighlighted = false;
        /**
         * Last mouse down position
         */
        this.lastMouseDownPosition = {
            x: 0,
            y: 0
        };
        //######################### public properties - inputs #########################
        /**
         * Parent zoom level
         */
        this.zoomLevel = 1;
        /**
         * Parent node coordinates
         */
        this.parentCoordiantes = {
            x: 0,
            y: 0
        };
    }
    //######################### public methods - implementation of OnInit #########################
    /**
     * Initialize component
     */
    ngOnInit() {
        if (!this.parent) {
            throw new Error('Every input or output endpoint must have parent specified');
        }
    }
    //######################### public methods #########################
    /**
     * @inheritdoc
     */
    getCoordinates() {
        return {
            x: this.parentCoordiantes.x + this.element.nativeElement.offsetLeft + this.element.nativeElement.offsetWidth / 2,
            y: this.parentCoordiantes.y + this.element.nativeElement.offsetTop + this.element.nativeElement.offsetHeight / 2
        };
    }
    /**
     * Highlight node endpoit
     */
    highlight() {
        this.isHighlighted = true;
    }
    /**
     * Cancel highlight for node endpoint
     */
    cancelHighlight() {
        this.isHighlighted = false;
    }
}
RelationNodeEndpointBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: RelationNodeEndpointBase, deps: [{ token: i0.ElementRef }, { token: i1.RelationsNodeManager }, { token: i2.RelationsCanvasSAComponent }], target: i0.ɵɵFactoryTarget.Directive });
RelationNodeEndpointBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.4", type: RelationNodeEndpointBase, inputs: { name: "name", zoomLevel: "zoomLevel", parentCoordiantes: "parentCoordiantes", parent: "parent" }, host: { properties: { "class.highlighted": "this.isHighlighted" } }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: RelationNodeEndpointBase, decorators: [{
            type: Directive
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.RelationsNodeManager }, { type: i2.RelationsCanvasSAComponent }], propDecorators: { isHighlighted: [{
                type: HostBinding,
                args: ['class.highlighted']
            }], name: [{
                type: Input
            }], zoomLevel: [{
                type: Input
            }], parentCoordiantes: [{
                type: Input
            }], parent: [{
                type: Input
            }] } });
//# sourceMappingURL=relationsNodeEndpointBase.js.map