"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActiveShape = void 0;
var react_1 = __importDefault(require("react"));
var recharts_1 = require("recharts");
var ActiveShape = function (_a) {
    var cx = _a.cx, cy = _a.cy, midAngle = _a.midAngle, innerRadius = _a.innerRadius, outerRadius = _a.outerRadius, startAngle = _a.startAngle, endAngle = _a.endAngle, fill = _a.fill, percent = _a.percent, value = _a.value, label = _a.label;
    var RADIAN = Math.PI / 180;
    var sin = Math.sin(-RADIAN * midAngle);
    var cos = Math.cos(-RADIAN * midAngle);
    var sx = cx + (outerRadius + 10) * cos;
    var sy = cy + (outerRadius + 10) * sin;
    var mx = cx + (outerRadius + 30) * cos;
    var my = cy + (outerRadius + 30) * sin;
    var circleX = mx + (cos >= 0 ? 1 : -1) * 20;
    var circleY = my;
    var textX = circleX + (cos >= 0 ? 1 : -1) * 12;
    var textAnchor = cos >= 0 ? 'start' : 'end';
    var linePath = "M".concat(sx, ",").concat(sy, "L").concat(mx, ",").concat(my, "L").concat(circleX, ",").concat(circleY);
    var sectorProps = {
        cx: cx,
        cy: cy,
        innerRadius: innerRadius,
        outerRadius: outerRadius,
        startAngle: startAngle,
        endAngle: endAngle,
        fill: fill
    };
    return (react_1.default.createElement("g", null,
        react_1.default.createElement(recharts_1.Sector, __assign({}, sectorProps)),
        react_1.default.createElement(recharts_1.Sector, __assign({}, sectorProps, { innerRadius: outerRadius + 6, outerRadius: outerRadius + 10 })),
        react_1.default.createElement("path", { d: linePath, stroke: fill, fill: "none" }),
        react_1.default.createElement("circle", { cx: circleX, cy: circleY, r: 2, fill: fill }),
        react_1.default.createElement("text", { x: textX, y: circleY, textAnchor: textAnchor, fill: "#444", fontSize: 12, fontWeight: 500 }, label),
        react_1.default.createElement("text", { x: textX, y: circleY, dy: 14, textAnchor: textAnchor, fill: "#000", opacity: 0.6, fontSize: 12 },
            react_1.default.createElement("tspan", { fontWeight: 500 }, value),
            react_1.default.createElement("tspan", { fontWeight: 400 }, " (".concat(percent, "%)")))));
};
exports.ActiveShape = ActiveShape;
