import { MarkupEntity } from './MarkupEntity';
import { equalsWithEpsilonVertex3 } from '../../math/index';
import { MergableObjectEventSource } from '../../MergableSet';
import { Color3, Color4 } from '../../loader/babylonjs-import';
/**
 * Class representing a markup circle in the markup API.
 */
export class MarkupCircle extends MarkupEntity {
    circlePoint;
    radiusPoint;
    lineThickness;
    style = { backgroundColor: new Color4(...Color3.Teal().asArray(), 1.0) };
    /**
     * Do not use. Use {@link MarkupSheet2D.add} instead.
     * @hidden
     */
    constructor({ id, sheet, properties, circlePoint, radiusPoint, lineThickness, style }) {
        super(id, sheet, properties);
        this.style = style;
        this.circlePoint = circlePoint;
        this.radiusPoint = radiusPoint;
        this.lineThickness = lineThickness;
    }
    /**
     * Copy the circle to another markup sheet.
     * @param sheet Markup sheet to copy the circle to.
     * @returns The new markup circle entity.
     */
    copyTo(sheet) {
        const deepCopyCirclePoint = { x: this.circlePoint.x, y: this.circlePoint.y, z: this.circlePoint.z };
        const deepCopyRadiusPoint = { x: this.radiusPoint.x, y: this.radiusPoint.y, z: this.radiusPoint.z };
        return sheet.add(MarkupCircle, {
            circlePoint: deepCopyCirclePoint,
            radiusPoint: deepCopyRadiusPoint,
            lineThickness: this.lineThickness,
            style: { backgroundColor: this.style.backgroundColor.clone() }
        }, new Map(this.properties));
    }
    onUpdate(o) {
        if (o.eventSource === MergableObjectEventSource.Remote && !o.conflictReason && o.remote) {
            this.copyFrom(o.remote);
        }
        super.onUpdate(o);
    }
    copyFrom(circle) {
        this.circlePoint = { x: circle.circlePoint.x, y: circle.circlePoint.y, z: circle.circlePoint.z };
        this.radiusPoint = { x: circle.radiusPoint.x, y: circle.radiusPoint.y, z: circle.radiusPoint.z };
        this.lineThickness = circle.lineThickness;
        this.properties.clear();
        for (const [key, value] of circle.properties) {
            this.properties.set(key, value);
        }
    }
    isEqual(o) {
        return (o.id === this.id &&
            o.sheet.isEqual(this.sheet) &&
            o.properties.size === this.properties.size &&
            [...this.properties].every(([key, value]) => value === o.properties.get(key)) &&
            equalsWithEpsilonVertex3(this.circlePoint, o.circlePoint) &&
            equalsWithEpsilonVertex3(this.radiusPoint, o.radiusPoint) &&
            this.lineThickness === o.lineThickness);
    }
    clone() {
        const circle = new MarkupCircle({
            id: this.id,
            sheet: this.sheet,
            properties: new Map(this.properties),
            style: { backgroundColor: this.style.backgroundColor.clone() },
            circlePoint: { x: this.circlePoint.x, y: this.circlePoint.y, z: this.circlePoint.z },
            radiusPoint: { x: this.radiusPoint.x, y: this.radiusPoint.y, z: this.radiusPoint.z },
            lineThickness: this.lineThickness
        });
        return circle;
    }
}
//# sourceMappingURL=MarkupCircle.js.map