function hull(data, { curve, tension, alpha, ...options }) {
const L = Plot.line(data, options);
const render = L.render;
const line = d3.line().curve(maybeClosedCurve(curve, { tension, alpha }));
L.render = function () {
const g = render.apply(this, arguments);
d3.select(g)
.selectAll("path")
.each(function () {
const points = this.getAttribute("d")
.replace(/[MZ]/g, "L")
.split("L")
.map((d) => d.split(",").map(Number))
.filter((d) => d.length === 2);
if (points.length > 3) {
const hull = d3.polygonHull(points);
this.setAttribute("d", line(hull));
} else this.setAttribute("d", null);
});
return g;
};
return L;
}