var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Bound, getBoundFromPoints, inflateBound, transformPointsToNewBound, } from '../utils/bound.js';
import {} from '../utils/xywh.js';
import { ElementModel } from './base.js';
import { derive, yfield } from './decorators.js';
export class BrushElementModel extends ElementModel {
    constructor() {
        super(...arguments);
        this.points = [];
        this.xywh = '[0,0,0,0]';
        this.rotate = 0;
        this.color = '#000000';
        this.lineWidth = 4;
    }
    get type() {
        return 'brush';
    }
}
__decorate([
    derive((instance) => {
        const lineWidth = instance.lineWidth;
        const bound = getBoundFromPoints(instance.points);
        const boundWidthLineWidth = inflateBound(bound, lineWidth);
        return {
            xywh: boundWidthLineWidth.serialize(),
        };
    }),
    yfield()
], BrushElementModel.prototype, "points", void 0);
__decorate([
    derive((instance) => {
        const bound = Bound.deserialize(instance.xywh);
        const { lineWidth } = instance;
        const transformed = transformPointsToNewBound(instance.points.map(([x, y]) => ({ x, y })), instance, lineWidth / 2, bound, lineWidth / 2);
        return {
            points: transformed.points.map(p => [p.x, p.y]),
        };
    }),
    yfield()
], BrushElementModel.prototype, "xywh", void 0);
__decorate([
    yfield()
], BrushElementModel.prototype, "rotate", void 0);
__decorate([
    yfield()
], BrushElementModel.prototype, "color", void 0);
__decorate([
    yfield()
], BrushElementModel.prototype, "lineWidth", void 0);
//# sourceMappingURL=brush.js.map