var PADDING = 2;
export var drawLabelBackground = function (context, data, settings, _a) {
    var _b = _a === void 0 ? {} : _a, _c = _b.backgroundColor, backgroundColor = _c === void 0 ? 'rgba(245, 245, 245, 0.9)' : _c, _d = _b.marginLeft, marginLeft = _d === void 0 ? 2 : _d, borderColor = _b.borderColor, lineHeight = _b.lineHeight;
    context.fillStyle = backgroundColor;
    if (borderColor) {
        context.strokeStyle = borderColor;
    }
    var path = new Path2D();
    if (typeof data.label === 'string') {
        var secondLineHeight = data.secondaryLabel ? lineHeight : 0;
        var size = settings.labelSize + secondLineHeight + 2;
        var borderRadius = 2;
        var textWidth = Math.max(context.measureText(data.label).width, context.measureText(data.secondaryLabel || '').width), boxWidth = Math.round(textWidth + 14), boxHeight = Math.round(size + 2 * PADDING), radius = data.size + PADDING;
        var top_1 = data.y - boxHeight / 2;
        var bottom = data.y + boxHeight / 2;
        var left = data.x + radius + marginLeft;
        var right = left + boxWidth;
        path.moveTo(left, bottom - borderRadius);
        path.quadraticCurveTo(left, bottom, left + borderRadius, bottom);
        path.lineTo(right - borderRadius, bottom);
        path.quadraticCurveTo(right, bottom, right, bottom - borderRadius);
        path.lineTo(right, top_1 + borderRadius);
        path.quadraticCurveTo(right, top_1, right - borderRadius, top_1);
        path.lineTo(left + borderRadius, top_1);
        path.quadraticCurveTo(left, top_1, left, top_1 + borderRadius);
        path.closePath();
        context.fill(path);
        if (borderColor) {
            context.stroke(path);
        }
    }
    return path;
};
