diff --git a/README.md b/README.md index ed5e5cfc..d4b0c309 100644 --- a/README.md +++ b/README.md @@ -271,7 +271,7 @@ provided by other plugins are controlled by those plugins instead. The defaults are: -* Low and medium trust: `calculate`, `remaining_bot_quota`, and `local_forum_search`. +* Low and medium trust: `calculate`, `plot_function`, `remaining_bot_quota`, and `local_forum_search`. * High trust: those tools plus `wikipedia`, `news`, `web_crawler`, `web_search`, and `stock_data`. Runtime requirements still take precedence over these defaults. For example, @@ -371,6 +371,98 @@ Filtering adds an evaluation call and can change prompt-cache reuse; reduced too guarantee lower total cost or better answers. Thresholds and guidance should be evaluated against your community's requests. +### Mathematical graphs + +Chatbot bundles function-plot 1.26.0 for interactive 2D graphs rendered in the +reader's browser. The library loads only when a graph is present, with no external +rendering API or notional tool quota charge. `chatbot_function_plot_enabled` +defaults to `true`; `plot_function` is included in all `chatbot_tools_*_trust` +defaults. Add it to any customised tool lists to make it available. System One +selection evaluates it like the other eligible tools. + +A single `plot_function` tool accepts an optional `plot_type` (default `function`), +`expressions`, `title`, paired `x_min`/`x_max` and `y_min`/`y_max` bounds, and paired +`parameter_min`/`parameter_max` for parametric/polar curves. Unused parameter bounds +are ignored, including placeholders supplied by strict tool schemas. Each graph +uses one family; an answer can include multiple graphs alongside explanations and +the usual MathJax/LaTeX output when Discourse Math is enabled. + +| Plot type | Tool `expressions` format (one entry per line) | Limit | +| --- | --- | --- | +| `function` | `sin(x)` or `cbrt((3-4*x^3)/2)` | 4 curves | +| `implicit` | `x^2+y^2-4` for the equation F(x,y)=0 | 2 curves | +| `parametric` | `cos(t); sin(t)` for x(t); y(t) | 4 curves | +| `polar` | `2*cos(3*theta)` for r(theta) | 4 curves | +| `points` | `1,2` for x,y scatter points | 150 points | +| `polyline` | `1,2` for connected x,y points in supplied order | 150 points | +| `vector` | `3,2` for dx,dy from the origin, or `1,1,3,2` for x0,y0,dx,dy | 16 vectors | + +Axes default to `[-10,10]`; t/theta defaults to `[0,2*pi]`. Custom bounds must be +finite, increasing pairs within `[-1000000,1000000]`, spanning at least `0.000001`. +Coordinates and vector components share that numeric limit. Titles are plain text +up to 120 characters. Inputs are limited to 6000 characters; rendered JSON to 8192. + +Human-authored posts, PMs and Chat can use the same `function-plot` fenced JSON. +Existing 2D `functions` blocks retain their format. These examples show the fields +for each additional family; `title`, `x_domain` and `y_domain` are optional: + +````markdown +The curves intersect where $\sin(x)=\cos(x)$. + +```function-plot +{"functions":["sin(x)","cos(x)"],"title":"Sine and cosine","x_domain":[-7,7],"y_domain":[-2,2]} +``` + +```function-plot +{"plot_type":"implicit","functions":["x^2+y^2-4"],"x_domain":[-3,3],"y_domain":[-3,3]} +``` + +```function-plot +{"plot_type":"parametric","functions":[["cos(t)","sin(t)"]],"parameter_range":[0,6.283185307179586]} +``` + +```function-plot +{"plot_type":"polar","functions":["2*cos(3*theta)"]} +``` + +```function-plot +{"plot_type":"points","points":[[0,0],[1,2],[2,1]]} +``` + +```function-plot +{"plot_type":"polyline","points":[[0,0],[1,2],[2,1]]} +``` + +```function-plot +{"plot_type":"vector","vectors":[[0,0,3,2],[1,1,-2,1]]} +``` +```` + +Readers drag to pan and scroll or pinch to zoom. Wheel zoom inside a graph does +not scroll the page. For ordinary `function` curves, moving the pointer shows a +coloured marker and live x/y coordinates on each visible curve. Tracing snaps +within six screen pixels of axis intercepts and series intersections. Intersecting +series share coordinates; undefined/off-screen values and pointer exit hide the +markers. Crossings are numerical; poles, jumps and coincident series do not create +false snapping targets. Tangencies can be missed. Other plot types support pan and +zoom without the function-specific trace overlay. + +The restricted interpreter accepts numeric literals, `pi`, `e`, `+ - * / ^`, +parentheses and `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `sqrt`, `cbrt`, `abs`, +`exp`, `log`, `log10`, `floor`, `ceil`. Variables depend on the selected family. +Expressions are limited to 256 characters each, 128 tokens and bounded nesting; +assignments, JavaScript and arbitrary library options are rejected on both sides. +Use `cbrt(...)` for real cube roots; `log` is natural and angles are radians. + +Trusted callbacks preserve Discourse's CSP without evaluating post text as code. +Ordinary curves use 1000 samples and preserve undefined domain gaps. Implicit +curves use the library's interval sampler and a shared limit of 40000 evaluations +per redraw; over-budget graphs show an error with the original definition. +Graphs are numerical visualisations, not symbolic solutions or proofs. 3D surfaces +are unsupported. Definitions remain available below each plot and as ordinary +code in email, exports, disabled rendering, and clients without JavaScript. +Vendor build instructions and checksums are in `public/function-plot/README.md`. + ### Tool extensions Other plugins can add tools by loading zero-argument subclasses of diff --git a/assets/javascripts/discourse/components/function-plot-block.gjs b/assets/javascripts/discourse/components/function-plot-block.gjs new file mode 100644 index 00000000..907e77fd --- /dev/null +++ b/assets/javascripts/discourse/components/function-plot-block.gjs @@ -0,0 +1,183 @@ +import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; +import { get } from "@ember/helper"; +import { modifier } from "ember-modifier"; +import loadScript from "discourse/lib/load-script"; +import { eq } from "discourse/truth-helpers"; +import { i18n } from "discourse-i18n"; +import { parseGraph } from "../lib/function-plot-expression"; +import { + createCurveTrace, + createGraphChart, +} from "../lib/function-plot-renderer"; + +export default class FunctionPlotBlock extends Component { + @tracked failed = false; + @tracked graph = null; + @tracked loading = true; + @tracked traceValues = []; + + renderPlot = modifier((element, [raw]) => { + let disposed = false; + let chart; + let observer; + let previousWidth; + let trace; + const locale = document.documentElement.lang || undefined; + const formatter = new Intl.NumberFormat(locale, { + maximumSignificantDigits: 6, + }); + const scientificFormatter = new Intl.NumberFormat(locale, { + maximumSignificantDigits: 6, + notation: "scientific", + }); + const formatNumber = (value) => { + const magnitude = Math.abs(value); + return ( + magnitude !== 0 && (magnitude < 0.0001 || magnitude >= 1000000) + ? scientificFormatter + : formatter + ).format(value === 0 ? 0 : value); + }; + + const onWheel = (event) => { + event.preventDefault(); + event.stopPropagation(); + }; + + const resize = () => { + const width = Math.max(240, Math.min(element.clientWidth || 640, 1000)); + const height = Math.max(260, Math.min(width * 0.7, 480)); + if (width !== previousWidth) { + previousWidth = width; + trace?.clear(); + element.style.height = `${height}px`; + if (chart) { + chart.options.width = width; + chart.options.height = height; + chart.build(); + } + } + }; + + const initialize = async () => { + try { + const graph = parseGraph(raw); + await loadScript( + "/plugins/discourse-chatbot/function-plot/1.26.0/function-plot.js" + ); + if (disposed) { + return; + } + this.graph = graph; + chart = createGraphChart(element, graph, () => { + if (!disposed) { + this.failed = true; + } + }); + resize(); + if (graph.plotType === "function") { + trace = createCurveTrace(chart, graph, (values) => { + if (!disposed) { + this.traceValues = values.map((value) => + value + ? i18n("chatbot.function_plot.trace_values", { + x: formatNumber(value.x), + y: formatNumber(value.y), + }) + : null + ); + } + }); + element.addEventListener("pointermove", trace.move); + element.addEventListener("pointerleave", trace.clear); + } + element.addEventListener("wheel", onWheel, { passive: false }); + observer = new ResizeObserver(() => { + if (!disposed) { + resize(); + } + }); + observer.observe(element); + } catch { + if (!disposed) { + this.failed = true; + } + } finally { + if (!disposed) { + this.loading = false; + } + } + }; + initialize(); + + return () => { + disposed = true; + element.removeEventListener("wheel", onWheel); + if (trace) { + element.removeEventListener("pointermove", trace.move); + element.removeEventListener("pointerleave", trace.clear); + trace.destroy(); + } + observer?.disconnect(); + if (chart) { + chart.removeAllListeners(); + // Upstream retains detached charts in a static cache. + delete chart.constructor.cache[chart.id]; + } + }; + }); + + +} diff --git a/assets/javascripts/discourse/initializers/function-plot.js b/assets/javascripts/discourse/initializers/function-plot.js new file mode 100644 index 00000000..ceb7416b --- /dev/null +++ b/assets/javascripts/discourse/initializers/function-plot.js @@ -0,0 +1,23 @@ +import { apiInitializer } from "discourse/lib/api"; +import FunctionPlotBlock from "../components/function-plot-block"; + +export function decorateFunctionPlots(element, helper) { + element.querySelectorAll("pre > code.lang-function-plot").forEach((code) => { + const raw = code.textContent; + const container = document.createElement("div"); + container.className = "chatbot-function-plot-container"; + code.parentElement.replaceWith(container); + helper.renderGlimmer(container, FunctionPlotBlock, { raw }); + }); +} + +export default apiInitializer((api) => { + const settings = api.container.lookup("service:site-settings"); + if (!settings.chatbot_enabled || !settings.chatbot_function_plot_enabled) { + return; + } + api.decorateCookedElement(decorateFunctionPlots, { + id: "chatbot-function-plot", + }); + api.decorateChatMessage?.(decorateFunctionPlots); +}); diff --git a/assets/javascripts/discourse/lib/function-plot-expression.js b/assets/javascripts/discourse/lib/function-plot-expression.js new file mode 100644 index 00000000..7feddc23 --- /dev/null +++ b/assets/javascripts/discourse/lib/function-plot-expression.js @@ -0,0 +1,297 @@ +const FUNCTIONS = Object.freeze({ + sin: Math.sin, + cos: Math.cos, + tan: Math.tan, + asin: Math.asin, + acos: Math.acos, + atan: Math.atan, + sqrt: Math.sqrt, + cbrt: Math.cbrt, + abs: Math.abs, + exp: Math.exp, + log: Math.log, + log10: Math.log10, + floor: Math.floor, + ceil: Math.ceil, +}); +const PRECEDENCE = { "+": 1, "-": 1, "*": 2, "/": 2, "^": 4 }; +const OPERATORS = { + "+": (left, right) => left + right, + "-": (left, right) => left - right, + "*": (left, right) => left * right, + "/": (left, right) => left / right, + "^": (left, right) => Math.pow(left, right), +}; + +// Interpret a small maths grammar; never pass post text to the library's code generator. +export function compileExpression( + expression, + { variables = ["x"], arithmetic } = {} +) { + const functions = arithmetic?.functions ?? FUNCTIONS; + const operators = arithmetic?.operators ?? OPERATORS; + const literal = arithmetic?.literal ?? ((value) => value); + if ( + typeof expression !== "string" || + !expression.trim() || + expression.length > 256 + ) { + throw new Error("Invalid expression"); + } + const source = expression.trim().toLowerCase(); + const pattern = + /(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|[a-z][a-z0-9]*|[()+\-*/^]/y; + const tokens = []; + let offset = 0; + while (offset < source.length) { + if (/\s/.test(source[offset])) { + offset++; + continue; + } + pattern.lastIndex = offset; + const match = pattern.exec(source); + if (!match || tokens.length >= 128) { + throw new Error("Invalid expression"); + } + tokens.push(match[0]); + offset = pattern.lastIndex; + } + + let index = 0; + function parse(minimum = 1, depth = 0) { + if (depth > 32) { + throw new Error("Expression too complex"); + } + const token = tokens[index++]; + let left; + if (token === "+" || token === "-") { + const operand = parse(3, depth + 1); + left = + token === "-" + ? (x, y) => + arithmetic ? arithmetic.negative(operand(x, y)) : -operand(x, y) + : operand; + } else if (token === "(") { + left = parse(1, depth + 1); + if (tokens[index++] !== ")") { + throw new Error("Unclosed group"); + } + } else if (variables.includes(token)) { + left = variables.indexOf(token) === 0 ? (x) => x : (_x, y) => y; + } else if (token === "pi" || token === "e") { + const constant = literal(token === "pi" ? Math.PI : Math.E); + left = () => constant; + } else if (Object.hasOwn(FUNCTIONS, token)) { + if (tokens[index++] !== "(") { + throw new Error("Missing function argument"); + } + const argument = parse(1, depth + 1); + if (tokens[index++] !== ")") { + throw new Error("Invalid function argument"); + } + left = (x, y) => functions[token](argument(x, y)); + } else if (token && Number.isFinite(Number(token))) { + const number = literal(Number(token)); + left = () => number; + } else { + throw new Error("Unsupported expression"); + } + + while ( + Object.hasOwn(PRECEDENCE, tokens[index]) && + PRECEDENCE[tokens[index]] >= minimum + ) { + const operator = tokens[index++]; + const right = parse( + PRECEDENCE[operator] + (operator === "^" ? 0 : 1), + depth + 1 + ); + const previous = left; + left = (x, y) => operators[operator](previous(x, y), right(x, y)); + } + return left; + } + + const evaluate = parse(); + if (index !== tokens.length) { + throw new Error("Unexpected expression input"); + } + return (x, y) => { + const result = evaluate(x, y); + return arithmetic ? result : Number.isFinite(result) ? result : NaN; + }; +} + +function domain(value) { + if ( + !Array.isArray(value) || + value.length !== 2 || + !value.every( + (bound) => + typeof bound === "number" && + Number.isFinite(bound) && + Math.abs(bound) <= 1000000 + ) || + value[1] - value[0] < 0.000001 + ) { + throw new Error("Invalid graph bounds"); + } + return [...value]; +} + +const PLOT_TYPES = [ + "function", + "implicit", + "parametric", + "polar", + "points", + "polyline", + "vector", +]; + +function tuples(value, size, limit) { + if ( + !Array.isArray(value) || + !value.length || + value.length > limit || + value.some( + (tuple) => + !Array.isArray(tuple) || + tuple.length !== size || + tuple.some( + (number) => + typeof number !== "number" || + !Number.isFinite(number) || + Math.abs(number) > 1000000 + ) + ) + ) { + throw new Error("Invalid graph data"); + } + return value; +} + +export function parseGraph(raw) { + if (typeof raw !== "string" || raw.length > 8192) { + throw new Error("Graph too large"); + } + const graph = JSON.parse(raw); + const plotType = graph?.plot_type ?? "function"; + const dataKey = + plotType === "vector" + ? "vectors" + : ["points", "polyline"].includes(plotType) + ? "points" + : "functions"; + const parameterized = ["parametric", "polar"].includes(plotType); + const allowedKeys = [ + dataKey, + "plot_type", + "title", + "x_domain", + "y_domain", + "dimensions", + ]; + if (parameterized) { + allowedKeys.push("parameter_range"); + } + if ( + !graph || + !PLOT_TYPES.includes(plotType) || + (graph.dimensions !== undefined && graph.dimensions !== 2) || + Object.keys(graph).some((key) => !allowedKeys.includes(key)) + ) { + throw new Error("Invalid graph"); + } + const title = graph.title ?? ""; + if (typeof title !== "string" || title.length > 120 || /[\r\n]/.test(title)) { + throw new Error("Invalid title"); + } + const result = { + plotType, + title, + xDomain: domain(graph.x_domain ?? [-10, 10]), + yDomain: domain(graph.y_domain ?? [-10, 10]), + parameterRange: parameterized + ? domain(graph.parameter_range ?? [0, 2 * Math.PI]) + : null, + series: [], + }; + if (dataKey !== "functions") { + const data = tuples( + graph[dataKey], + plotType === "vector" ? 4 : 2, + plotType === "vector" ? 16 : 150 + ); + result.series = + plotType === "vector" + ? data.map((vector) => ({ expression: vector.join(", "), vector })) + : [{ expression: "", points: data }]; + return result; + } + if ( + !Array.isArray(graph.functions) || + !graph.functions.length || + graph.functions.length > (plotType === "implicit" ? 2 : 4) + ) { + throw new Error("Invalid graph functions"); + } + result.series = graph.functions.map((expression) => { + if (plotType === "parametric") { + if (!Array.isArray(expression) || expression.length !== 2) { + throw new Error("Invalid parametric pair"); + } + return { + expression: expression.join("; "), + evaluateX: compileExpression(expression[0], { variables: ["t"] }), + evaluateY: compileExpression(expression[1], { variables: ["t"] }), + }; + } + const variables = + plotType === "implicit" + ? ["x", "y"] + : plotType === "polar" + ? ["theta"] + : ["x"]; + return { + expression, + evaluate: compileExpression(expression, { variables }), + }; + }); + return result; +} + +// The upstream sampler drops undefined points, which can otherwise bridge domain gaps. +export function splitUndefinedSegments( + segments, + evaluate = () => 0, + step = Infinity +) { + const result = []; + for (const segment of segments) { + let current = []; + for (const point of segment) { + if (!point || !point.every(Number.isFinite)) { + if (current.length) { + result.push(current); + current = []; + } + continue; + } + const previous = current.at(-1); + if ( + previous && + (point[0] - previous[0] > step * 1.5 || + !Number.isFinite(evaluate((point[0] + previous[0]) / 2))) + ) { + result.push(current); + current = []; + } + current.push(point); + } + if (current.length) { + result.push(current); + } + } + return result; +} diff --git a/assets/javascripts/discourse/lib/function-plot-renderer.js b/assets/javascripts/discourse/lib/function-plot-renderer.js new file mode 100644 index 00000000..e25c7f63 --- /dev/null +++ b/assets/javascripts/discourse/lib/function-plot-renderer.js @@ -0,0 +1,214 @@ +import { + compileExpression, + splitUndefinedSegments, +} from "./function-plot-expression"; +import { traceSeriesCoordinates } from "./function-plot-trace"; + +const COLORS = ["#0088cc", "#e4572e", "#32a66a", "#b279a2"]; + +export function compileIntervalExpression(expression, interval) { + const monotonic = (fn) => (value) => + interval.isEmpty(value) + ? interval.EMPTY + : interval.factory(fn(value.lo), fn(value.hi)); + return compileExpression(expression, { + variables: ["x", "y"], + arithmetic: { + literal: (value) => interval.factory(value), + negative: interval.negative, + functions: { + ...interval, + cbrt: monotonic(Math.cbrt), + floor: monotonic(Math.floor), + ceil: monotonic(Math.ceil), + }, + operators: { + "+": interval.add, + "-": interval.sub, + "*": interval.mul, + "/": interval.div, + "^": (base, exponent) => { + if (interval.isSingleton(exponent) && Number.isInteger(exponent.lo)) { + return interval.pow(base, exponent); + } + if (base.lo < 0) { + return interval.WHOLE; + } + return interval.exp(interval.mul(interval.log(base), exponent)); + }, + }, + }, + }); +} + +export function createGraphChart(element, graph, onError) { + const library = window.functionPlot; + const options = { + target: element, + width: 640, + height: 420, + grid: true, + xAxis: { domain: graph.xDomain }, + yAxis: { domain: graph.yDomain }, + tip: { renderer: () => "" }, + data: [], + }; + const chart = library(options); + let evaluations = 0; + chart.on("before:draw", () => (evaluations = 0)); + chart.on("eval", (segments, index, isHelper) => { + if (isHelper || graph.plotType === "implicit") { + return; + } + const [minimum, maximum] = chart.meta.xScale.domain(); + const separated = + graph.plotType === "function" + ? splitUndefinedSegments( + segments, + graph.series[index].evaluate, + (maximum - minimum) / 999 + ) + : splitUndefinedSegments(segments); + segments.splice(0, segments.length, ...separated); + }); + options.data = graph.series.map((series, index) => { + const datum = { + color: COLORS[index % COLORS.length], + sampler: "builtIn", + graphType: "polyline", + nSamples: 1000, + skipTip: true, + }; + switch (graph.plotType) { + case "implicit": { + const evaluate = compileIntervalExpression( + series.expression, + library.intervalMath + ); + return { + ...datum, + fnType: "implicit", + sampler: "interval", + graphType: "interval", + fn: ({ x, y }) => { + if (++evaluations > 40000) { + throw new Error("Implicit plot exceeded the evaluation budget"); + } + return evaluate(x, y); + }, + }; + } + case "parametric": + return { + ...datum, + fnType: "parametric", + x: ({ t }) => series.evaluateX(t), + y: ({ t }) => series.evaluateY(t), + range: graph.parameterRange, + }; + case "polar": + return { + ...datum, + fnType: "polar", + r: ({ theta }) => series.evaluate(theta), + range: graph.parameterRange, + }; + case "points": + case "polyline": + return { + ...datum, + fnType: "points", + points: series.points, + graphType: graph.plotType === "points" ? "scatter" : "polyline", + }; + case "vector": + return { + ...datum, + fnType: "vector", + offset: series.vector.slice(0, 2), + vector: series.vector.slice(2), + }; + default: + return { + ...datum, + fnType: "linear", + fn: ({ x }) => series.evaluate(x), + }; + } + }); + + // Zoom redraws happen inside the library's event handlers, outside the component's initializer. + const draw = chart.draw.bind(chart); + chart.draw = () => { + try { + draw(); + } catch { + options.data = []; + onError(); + } + }; + chart.build(); + return chart; +} + +export function createCurveTrace(chart, graph, onValues) { + const canvas = chart.canvas.merge(chart.canvas.enter); + const overlay = canvas.append("g").attr("pointer-events", "none"); + const points = graph.series.map((_series, index) => + overlay + .append("circle") + .attr("class", "chatbot-function-plot__trace-point") + .attr("r", 4) + .attr("fill", COLORS[index]) + .attr("display", "none") + ); + let frame; + let pointer; + const clear = () => { + cancelAnimationFrame(frame); + frame = null; + points.forEach((point) => point.attr("display", "none")); + onValues([]); + }; + const update = () => { + frame = null; + const box = chart.draggable.node().getBoundingClientRect(); + const pixelX = pointer.clientX - box.left; + const pixelY = pointer.clientY - box.top; + if (pixelX < 0 || pixelX > box.width || pixelY < 0 || pixelY > box.height) { + clear(); + return; + } + const [minX, maxX] = chart.meta.xScale.domain(); + const [minY, maxY] = chart.meta.yScale.domain(); + const values = traceSeriesCoordinates( + graph.series.map((series) => series.evaluate), + chart.meta.xScale.invert(pixelX), + [minX, maxY, maxX, minY], + box.width + ); + points.forEach((point, index) => { + const value = values[index]; + point.attr("display", value ? null : "none"); + if (value) { + point + .attr("cx", chart.meta.xScale(value.x)) + .attr("cy", chart.meta.yScale(value.y)); + } + }); + onValues(values); + }; + chart.on("before:draw", clear); + return { + move(event) { + pointer = { clientX: event.clientX, clientY: event.clientY }; + frame ??= requestAnimationFrame(update); + }, + clear, + destroy() { + clear(); + chart.removeListener("before:draw", clear); + overlay.remove(); + }, + }; +} diff --git a/assets/javascripts/discourse/lib/function-plot-trace.js b/assets/javascripts/discourse/lib/function-plot-trace.js new file mode 100644 index 00000000..58994713 --- /dev/null +++ b/assets/javascripts/discourse/lib/function-plot-trace.js @@ -0,0 +1,122 @@ +function crossing(evaluate, left, right) { + let leftValue = evaluate(left); + let rightValue = evaluate(right); + if (!Number.isFinite(leftValue) || !Number.isFinite(rightValue)) { + return null; + } + if (leftValue === 0 && rightValue === 0) { + return null; + } + if (leftValue === 0) { + return left; + } + if (rightValue === 0) { + return right; + } + if (Math.sign(leftValue) === Math.sign(rightValue)) { + return null; + } + const initialLeft = Math.abs(leftValue); + const initialRight = Math.abs(rightValue); + for (let iteration = 0; iteration < 48; iteration++) { + const middle = left + (right - left) / 2; + if (middle === left || middle === right) { + break; + } + const value = evaluate(middle); + if (!Number.isFinite(value)) { + return null; + } + if (value === 0) { + return middle; + } + if (Math.sign(value) === Math.sign(leftValue)) { + left = middle; + leftValue = value; + } else { + right = middle; + rightValue = value; + } + } + // Both sides must approach zero: sign changes alone also occur at poles and jumps. + if ( + Math.abs(leftValue) < initialLeft * 0.001 && + Math.abs(rightValue) < initialRight * 0.001 + ) { + return left + (right - left) / 2; + } + return null; +} + +export function traceSeriesCoordinates(evaluators, x, bounds, width) { + const [minimumX, maximumY, maximumX, minimumY] = bounds; + const tolerance = ((maximumX - minimumX) * 6) / width; + const candidates = []; + const samples = [ + Math.max(minimumX, x - tolerance), + x, + Math.min(maximumX, x + tolerance), + ]; + const roots = (evaluate) => { + const result = []; + for (let index = 1; index < samples.length; index++) { + const root = crossing(evaluate, samples[index - 1], samples[index]); + if (root !== null) { + result.push(root); + } + } + return result; + }; + const visible = (value) => + Number.isFinite(value.x) && + Number.isFinite(value.y) && + value.y >= minimumY && + value.y <= maximumY; + evaluators.forEach((evaluate, index) => { + if (minimumX <= 0 && maximumX >= 0 && Math.abs(x) <= tolerance) { + candidates.push({ x: 0, y: evaluate(0), indices: [index] }); + } + if (minimumY <= 0 && maximumY >= 0) { + roots(evaluate).forEach((root) => + candidates.push({ x: root, y: 0, indices: [index] }) + ); + } + for (let other = index + 1; other < evaluators.length; other++) { + roots((value) => evaluate(value) - evaluators[other](value)).forEach( + (root) => { + const firstY = evaluate(root); + const secondY = evaluators[other](root); + if ( + visible({ x: root, y: firstY }) && + visible({ x: root, y: secondY }) + ) { + candidates.push({ + x: root, + y: firstY + (secondY - firstY) / 2, + indices: [index, other], + }); + } + } + ); + } + }); + const snapped = candidates + .filter(visible) + .sort( + (first, second) => + Math.abs(first.x - x) - Math.abs(second.x - x) || + second.indices.length - first.indices.length + )[0]; + const traceX = snapped?.x ?? x; + return evaluators.map((evaluate, index) => { + const value = { + x: traceX, + y: snapped?.indices.includes(index) ? snapped.y : evaluate(traceX), + }; + return visible(value) ? value : null; + }); +} + +export function traceCoordinates(evaluate, x, bounds, width) { + return traceSeriesCoordinates([evaluate], x, bounds, width)[0]; +} diff --git a/assets/stylesheets/common/chatbot_common.scss b/assets/stylesheets/common/chatbot_common.scss index 47bd3dd4..3c524624 100644 --- a/assets/stylesheets/common/chatbot_common.scss +++ b/assets/stylesheets/common/chatbot_common.scss @@ -104,3 +104,82 @@ opacity: 100%; } } + +.chatbot-function-plot { + margin: 1em 0; + padding: 0.5em; + border: 1px solid var(--primary-low); + border-radius: var(--d-border-radius); + background: var(--secondary); + + &__canvas { + position: relative; + width: 100%; + min-height: 260px; + overflow: hidden; + + svg { + display: block; + max-width: 100%; + } + + svg text { + fill: var(--primary); + } + + .axis path, + .axis line { + stroke: var(--primary-medium); + } + } + + figcaption { + color: var(--primary-high); + font-size: var(--font-down-1); + } + + &__legend { + display: flex; + flex-wrap: wrap; + gap: 0.5em 1.5em; + margin: 0.5em 0; + padding-left: 1.5em; + font-family: monospace; + + li { + display: flex; + flex-direction: column; + } + + li:nth-child(4n + 1) { + color: #08c; + } + + li:nth-child(4n + 2) { + color: #e4572e; + } + + li:nth-child(4n + 3) { + color: #32a66a; + } + + li:nth-child(4n + 4) { + color: #b279a2; + } + } + + &__coordinates { + min-height: 1.4em; + font-size: var(--font-down-1); + white-space: nowrap; + } + + &__definition { + margin-top: 0.5em; + font-size: var(--font-down-1); + } + + &__error { + color: var(--danger); + } +} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 5ef0c623..a0ddecc8 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3,6 +3,14 @@ en: discourse_chatbot: title: "Chatbot" chatbot: + function_plot: + loading: "Loading graph…" + error: "This graph could not be rendered. Check its expressions and bounds, or simplify an expensive implicit equation." + fallback: "Graph definition" + label: "Interactive function graph" + help: "Move the pointer to trace values, snapping near axes and series intersections; drag to pan; scroll or pinch to zoom. Angles are in radians." + trace_values: "x = %{x}, y = %{y}" + help_other: "Drag to pan; scroll or pinch to zoom. Angles are in radians." tool_selection_mode: remove_definitions: "Remove unselected tool definitions" restrict_calls: "Restrict calls and retain tool definitions for caching" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 087e72cb..c8dc720f 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,5 +1,6 @@ en: site_settings: + chatbot_function_plot_enabled: "Render interactive 2D function, implicit, parametric, polar, point and vector plots locally with function-plot in posts, PMs and Chat. The plot_function tool is included in the defaults for every trust level; add it to customised tool lists to let Chatbot prepare graphs alongside maths explanations and MathJax output." chatbot_enabled: "Enable the chatbot plugin" chatbot_llm_provider: "Provider used for chatbot completions. OpenAI, Anthropic, Google Gemini, and xAI are supported through their OpenAI-compatible APIs." chatbot_open_ai_token: "OpenAI API key shared by every chatbot capability configured to use OpenAI. Get a key at OpenAI." @@ -196,6 +197,21 @@ en: post_analysis_before_posts: "I am now talking to only %{username} who has asked me to consider the following posts in private. The other users are now not present, but I have access to their conversation which is as follows:" post_analysis: "I am still talking to only %{username} who has asked me to consider the above posts in private. I should summarize the discussion, provide my opinion about it to %{username} and ask them what they would like to discuss about it." function: + function_plot: + description: | + Prepare an interactive 2D mathematical graph when it helps explain the answer, including roots, intersections, conics, trajectories or data. Choose plot_type and use the matching expressions format. Accompany the graph with the mathematical explanation and usual LaTeX/MathJax notation. 3D is unsupported. + Expressions use explicit multiplication (*), powers (^), parentheses, pi, e, and single-argument sin, cos, tan, asin, acos, atan, sqrt, cbrt, abs, exp, log (natural), log10, floor, ceil. Angles are radians. Use cbrt(...) for real cube roots of negative arguments. Omit assignments and LaTeX. Limit each expression to 256 characters. + Choose numeric axis bounds that show the relevant features; supply min/max pairs within [-1000000,1000000], increasing by at least 0.000001. Axes default to [-10,10]. For parametric/polar curves, parameter_min/parameter_max select t/theta (default 0 to 2*pi); ignored for other types. Copy the returned function-plot fence unchanged into the final answer outside other fences. Rendering is local; do not claim to have viewed the result. + expressions: "Newline-separated entries: function (default): y=f(x) as x^2-4; implicit: F(x,y)=0 as x^2+y^2-4 (max 2); parametric: x(t); y(t) as cos(t); sin(t); polar: r(theta) as 2*cos(3*theta). Max 4 curves except implicit. points/polyline: numeric x,y per line (max 150), scatter/connected respectively. vector: numeric dx,dy from origin or x0,y0,dx,dy per line (max 16)." + title: "Optional plain-text graph title, up to 120 characters." + plot_type: "Plot family; function is the default. One family per graph." + x_min: "Left boundary. Supply with x_max." + x_max: "Right boundary. Supply with x_min." + y_min: "Bottom boundary. Supply with y_max." + y_max: "Top boundary. Supply with y_min." + parameter_min: "Start of t/theta for parametric/polar curves. Supply with parameter_max. Ignored otherwise." + parameter_max: "End of t/theta for parametric/polar curves. Supply with parameter_min. Ignored otherwise." + error: "Unable to prepare the graph. Check plot_type and its expressions format: function in x; implicit in x,y equal to zero; parametric x(t);y(t); polar in theta; points/polyline numeric x,y; vector numeric dx,dy or x0,y0,dx,dy. Max 4 curves (2 implicit), 150 points or 16 vectors. Use supported maths only, increasing finite bounds in pairs within +/-1000000, and a title up to 120 characters. Parameter bounds apply only to parametric/polar curves. Correct the arguments before retrying." remaining_bot_quota: description: | Get the current number of tokens or queries you have left for use of the bot this week diff --git a/config/settings.yml b/config/settings.yml index c18cffef..52351dba 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,6 +2,9 @@ plugins: chatbot_enabled: default: true client: true + chatbot_function_plot_enabled: + default: true + client: true chatbot_llm_provider: client: false default: open_ai @@ -136,7 +139,7 @@ plugins: type: group_list list_type: compact chatbot_tools_high_trust: - default: "calculate|wikipedia|remaining_bot_quota|local_forum_search|news|web_crawler|web_search|stock_data" + default: "calculate|plot_function|wikipedia|remaining_bot_quota|local_forum_search|news|web_crawler|web_search|stock_data" client: false type: list list_type: compact @@ -248,7 +251,7 @@ plugins: client: false default: '' chatbot_tools_medium_trust: - default: "calculate|remaining_bot_quota|local_forum_search" + default: "calculate|plot_function|remaining_bot_quota|local_forum_search" client: false type: list list_type: compact @@ -312,7 +315,7 @@ plugins: client: false default: '' chatbot_tools_low_trust: - default: "calculate|remaining_bot_quota|local_forum_search" + default: "calculate|plot_function|remaining_bot_quota|local_forum_search" client: false type: list list_type: compact diff --git a/lib/discourse_chatbot/bot.rb b/lib/discourse_chatbot/bot.rb index b7cec26a..3c9e9a27 100644 --- a/lib/discourse_chatbot/bot.rb +++ b/lib/discourse_chatbot/bot.rb @@ -28,6 +28,7 @@ class ChainLimitError < NonRetryableError DiscourseChatbot::Tools::UserInformation DiscourseChatbot::Tools::EscalateToStaff DiscourseChatbot::Tools::Calculator + DiscourseChatbot::Tools::FunctionPlot DiscourseChatbot::Tools::RemainingQuota ] @@ -360,6 +361,9 @@ def get_system_message_suffix(opts) def merge_tools(opts) tools = [] tools << ::DiscourseChatbot::Tools::Calculator.new if tool_enabled?("calculate") + if tool_enabled?("plot_function") && SiteSetting.chatbot_function_plot_enabled + tools << ::DiscourseChatbot::Tools::FunctionPlot.new + end tools << ::DiscourseChatbot::Tools::Wikipedia.new if tool_enabled?("wikipedia") if opts[:private] && tool_enabled?("user_information") diff --git a/lib/discourse_chatbot/function_plot.rb b/lib/discourse_chatbot/function_plot.rb new file mode 100644 index 00000000..2ad099e6 --- /dev/null +++ b/lib/discourse_chatbot/function_plot.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true + +require "dentaku" + +module DiscourseChatbot + class FunctionPlot + FUNCTIONS = %w[sin cos tan asin acos atan sqrt cbrt abs exp log log10 floor ceil].freeze + PLOT_TYPES = %w[function implicit parametric polar points polyline vector].freeze + MAX_FUNCTIONS = 4 + MAX_EXPRESSION_LENGTH = 256 + MAX_TOKENS = 128 + MAX_DEPTH = 16 + MAX_BOUND = 1_000_000 + + def self.markdown(args) + plot_type = args.fetch("plot_type", "function") + raise ArgumentError if PLOT_TYPES.exclude?(plot_type) + + source = args.fetch("expressions") + raise ArgumentError if source.length > 6000 + expressions = source.split("\n").map(&:strip).reject(&:empty?) + title = args.fetch("title", "") + raise ArgumentError if title.length > 120 || title.match?(/[\r\n]/) + + graph = { + title: title, + x_domain: domain(args, "x", [-10, 10]), + y_domain: domain(args, "y", [-10, 10]), + } + graph[:plot_type] = plot_type unless plot_type == "function" + if %w[points polyline vector].include?(plot_type) + key = plot_type == "vector" ? :vectors : :points + limit = plot_type == "vector" ? 16 : 150 + raise ArgumentError if expressions.empty? || expressions.length > limit + graph[key] = expressions.map do |line| + values = line.split(",", -1).map(&:strip) + sizes = plot_type == "vector" ? [2, 4] : [2] + unless sizes.include?(values.length) && + values.all? { |value| + value.match?(/\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?\z/i) + } + raise ArgumentError + end + numbers = values.map(&:to_f) + unless numbers.all? { |value| value.finite? && value.abs <= MAX_BOUND } + raise ArgumentError + end + numbers.unshift(0, 0) if plot_type == "vector" && numbers.length == 2 + numbers + end + else + limit = plot_type == "implicit" ? 2 : MAX_FUNCTIONS + raise ArgumentError if expressions.empty? || expressions.length > limit + variables = { + "function" => %w[x], + "implicit" => %w[x y], + "parametric" => %w[t], + "polar" => %w[theta], + }.fetch(plot_type) + graph[:functions] = expressions.map do |expression| + parts = plot_type == "parametric" ? expression.split(";", -1).map(&:strip) : [expression] + raise ArgumentError if parts.length != (plot_type == "parametric" ? 2 : 1) + parts.each { |part| validate_expression!(part, variables + %w[pi e]) } + plot_type == "parametric" ? parts : expression + end + if %w[parametric polar].include?(plot_type) + graph[:parameter_range] = domain(args, "parameter", [0, 2 * Math::PI]) + end + end + "```function-plot\n#{JSON.generate(graph)}\n```" + end + + def self.validate_expression!(expression, variables) + if expression.length > MAX_EXPRESSION_LENGTH || + !expression.match?(%r{\A[0-9a-z+\-*/^().\s]+\z}i) + raise ArgumentError + end + normalized = expression.downcase + names = normalized.scan(/[a-z][a-z0-9]*/).reject { |name| name.match?(/\Ae\d+\z/) } + raise ArgumentError unless (names - FUNCTIONS - variables).empty? + + depth = 0 + normalized.each_char do |character| + depth += 1 if character == "(" + depth -= 1 if character == ")" + raise ArgumentError if depth.negative? || depth > MAX_DEPTH + end + raise ArgumentError if depth.nonzero? + + calculator = Dentaku::Calculator.new + calculator.add_function(:floor, :numeric, ->(value) { value.floor }) + calculator.add_function(:ceil, :numeric, ->(value) { value.ceil }) + calculator.add_function(:cbrt, :numeric, ->(value) { Math.cbrt(value) }) + raise ArgumentError if calculator.tokenizer.tokenize(normalized).length > MAX_TOKENS + node = calculator.ast(normalized) + raise ArgumentError unless (node.dependencies - variables).empty? + rescue Dentaku::Error + raise ArgumentError + end + + def self.domain(args, axis, default) + minimum, maximum = args.values_at("#{axis}_min", "#{axis}_max") + return default if minimum.nil? && maximum.nil? + + unless [minimum, maximum].all? { |value| + value.is_a?(Numeric) && value.finite? && value.abs <= MAX_BOUND + } && maximum - minimum >= 0.000001 + raise ArgumentError + end + [minimum, maximum] + end + private_class_method :domain, :validate_expression! + end +end diff --git a/lib/discourse_chatbot/tool.rb b/lib/discourse_chatbot/tool.rb index 043587e6..f9e828d8 100644 --- a/lib/discourse_chatbot/tool.rb +++ b/lib/discourse_chatbot/tool.rb @@ -9,6 +9,7 @@ class Tool news paint_edit_picture paint_picture + plot_function remaining_bot_quota stock_data user_information diff --git a/lib/discourse_chatbot/tools/function_plot.rb b/lib/discourse_chatbot/tools/function_plot.rb new file mode 100644 index 00000000..e9312199 --- /dev/null +++ b/lib/discourse_chatbot/tools/function_plot.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module DiscourseChatbot + module Tools + class FunctionPlot < ::DiscourseChatbot::Tool + def name + "plot_function" + end + + def description + I18n.t("chatbot.prompt.function.function_plot.description") + end + + def parameters + [ + { + name: "expressions", + type: String, + description: I18n.t("chatbot.prompt.function.function_plot.expressions"), + }, + { + name: "title", + type: String, + description: I18n.t("chatbot.prompt.function.function_plot.title"), + }, + { + name: "plot_type", + type: String, + enum: ::DiscourseChatbot::FunctionPlot::PLOT_TYPES, + description: I18n.t("chatbot.prompt.function.function_plot.plot_type"), + }, + *%w[x_min x_max y_min y_max parameter_min parameter_max].map do |name| + { + name: name, + type: Numeric, + description: I18n.t("chatbot.prompt.function.function_plot.#{name}"), + } + end, + ] + end + + def required + ["expressions"] + end + + def process(args) + super(args) + { answer: ::DiscourseChatbot::FunctionPlot.markdown(args), token_usage: 0 } + rescue ArgumentError + { answer: I18n.t("chatbot.prompt.function.function_plot.error"), token_usage: 0 } + end + end + end +end diff --git a/plugin.rb b/plugin.rb index 68aa57b0..3520cc2f 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-chatbot # about: a plugin that allows you to have a conversation with a configurable chatbot in Chat, Topics and Private Messages -# version: 3.1.8 +# version: 3.2.0 # authors: merefield # url: https://github.com/merefield/discourse-chatbot diff --git a/public/function-plot/1.26.0/LICENSE b/public/function-plot/1.26.0/LICENSE new file mode 100644 index 00000000..57bde726 --- /dev/null +++ b/public/function-plot/1.26.0/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2015 Mauricio Poppe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/public/function-plot/1.26.0/THIRD-PARTY-LICENSES.txt b/public/function-plot/1.26.0/THIRD-PARTY-LICENSES.txt new file mode 100644 index 00000000..4655caa6 --- /dev/null +++ b/public/function-plot/1.26.0/THIRD-PARTY-LICENSES.txt @@ -0,0 +1,518 @@ +built-in-math-eval@0.3.2 +MIT License + +Copyright (c) 2015 Mauricio Poppe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +d3-array@3.2.4 +Copyright 2010-2023 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-axis@3.0.0 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-color@3.1.0 +Copyright 2010-2022 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-dispatch@3.0.1 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-drag@3.0.0 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-ease@3.0.1 +Copyright 2010-2021 Mike Bostock +Copyright 2001 Robert Penner +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +d3-format@3.1.2 +Copyright 2010-2026 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-interpolate@3.0.1 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-path@3.1.0 +Copyright 2015-2022 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-scale@4.0.2 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-selection@3.0.0 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-shape@3.2.0 +Copyright 2010-2022 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-time-format@4.1.0 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-time@3.1.0 +Copyright 2010-2022 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-timer@3.0.1 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-transition@3.0.1 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +d3-zoom@3.0.0 +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +double-bits@1.1.1 +The MIT License (MIT) + +Copyright (c) 2013 Mikola Lysenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +events@3.3.0 +MIT + +Copyright Joyent, Inc. and other Node contributors. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +extend@3.0.2 +The MIT License (MIT) + +Copyright (c) 2014 Stefan Thomas + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +function-plot@1.26.0 +MIT License + +Copyright (c) 2015 Mauricio Poppe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +internmap@2.0.3 +Copyright 2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + +interval-arithmetic-eval@0.5.3 +MIT License + +Copyright (c) 2015 Mauricio Poppe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +interval-arithmetic@1.1.3 +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +math-codegen@0.4.3 +The MIT License (MIT) + +Copyright (c) 2015 Mauricio Poppe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +mr-parser@0.2.2 +MIT License + +Copyright (c) 2015 Mauricio Poppe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +nextafter@1.0.0 +The MIT License (MIT) + +Copyright (c) 2013 Mikola Lysenko + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/public/function-plot/1.26.0/function-plot.js b/public/function-plot/1.26.0/function-plot.js new file mode 100644 index 00000000..e1d3ceff --- /dev/null +++ b/public/function-plot/1.26.0/function-plot.js @@ -0,0 +1,6 @@ +(()=>{var Gv=Object.create;var Ao=Object.defineProperty;var Wv=Object.getOwnPropertyDescriptor;var Vv=Object.getOwnPropertyNames;var Zv=Object.getPrototypeOf,Qv=Object.prototype.hasOwnProperty;var p=(t,e)=>()=>(t&&(e=t(t=0)),e);var O=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),rn=(t,e)=>{for(var n in e)Ao(t,n,{get:e[n],enumerable:!0})},Mc=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Vv(e))!Qv.call(t,i)&&i!==n&&Ao(t,i,{get:()=>e[i],enumerable:!(r=Wv(e,i))||r.enumerable});return t};var Tc=(t,e,n)=>(n=t!=null?Gv(Zv(t)):{},Mc(e||!t||!t.__esModule?Ao(n,"default",{value:t,enumerable:!0}):n,t)),it=t=>Mc(Ao({},"__esModule",{value:!0}),t);var Sc=O(()=>{typeof window<"u"&&(function(t,e){try{t.querySelector(":scope body")}catch{["querySelector","querySelectorAll"].forEach(function(r){let i=e[r];e[r]=function(o){if(/(^|,)\s*:scope/.test(o)){let a=this.id;this.id="ID_"+Date.now(),o=o.replace(/((^|,)\s*):scope/g,"$1#"+this.id);let s=t[r](o);return this.id=a,s}else return i.call(this,o)}})}})(window.document,Element.prototype)});function D(t){return function(){return t}}var on=p(()=>{});function Ic(t){return t>1?0:t<-1?xe:Math.acos(t)}function fu(t){return t>=1?ei:t<=-1?-ei:Math.asin(t)}var lu,At,_e,Ec,ke,qt,$,bt,xe,ei,re,Ot=p(()=>{lu=Math.abs,At=Math.atan2,_e=Math.cos,Ec=Math.max,ke=Math.min,qt=Math.sin,$=Math.sqrt,bt=1e-12,xe=Math.PI,ei=xe/2,re=2*xe});function Ac(t){this._+=t[0];for(let e=1,n=t.length;e=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Ac;let n=10**e;return function(r){this._+=r[0];for(let i=1,o=r.length;i{cu=Math.PI,hu=2*cu,En=1e-6,Jv=hu-En;In=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?Ac:Kv(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,o,a){this._append`C${+e},${+n},${+r},${+i},${this._x1=+o},${this._y1=+a}`}arcTo(e,n,r,i,o){if(e=+e,n=+n,r=+r,i=+i,o=+o,o<0)throw new Error(`negative radius: ${o}`);let a=this._x1,s=this._y1,u=r-e,l=i-n,f=a-e,c=s-n,h=f*f+c*c;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(h>En)if(!(Math.abs(c*u-l*f)>En)||!o)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-a,g=i-s,y=u*u+l*l,M=m*m+g*g,_=Math.sqrt(y),E=Math.sqrt(h),A=o*Math.tan((cu-Math.acos((y+h-M)/(2*_*E)))/2),I=A/E,P=A/_;Math.abs(I-1)>En&&this._append`L${e+I*f},${n+I*c}`,this._append`A${o},${o},0,0,${+(c*m>f*g)},${this._x1=e+P*u},${this._y1=n+P*l}`}}arc(e,n,r,i,o,a){if(e=+e,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let s=r*Math.cos(i),u=r*Math.sin(i),l=e+s,f=n+u,c=1^a,h=a?i-o:o-i;this._x1===null?this._append`M${l},${f}`:(Math.abs(this._x1-l)>En||Math.abs(this._y1-f)>En)&&this._append`L${l},${f}`,r&&(h<0&&(h=h%hu+hu),h>Jv?this._append`A${r},${r},0,1,${c},${e-s},${n-u}A${r},${r},0,1,${c},${this._x1=l},${this._y1=f}`:h>En&&this._append`A${r},${r},0,${+(h>=cu)},${c},${this._x1=e+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}};Oc.prototype=In.prototype});var kc=p(()=>{Nc()});function Pe(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{let r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new In(e)}var rr=p(()=>{kc()});function t1(t){return t.innerRadius}function e1(t){return t.outerRadius}function n1(t){return t.startAngle}function r1(t){return t.endAngle}function i1(t){return t&&t.padAngle}function o1(t,e,n,r,i,o,a,s){var u=n-t,l=r-e,f=a-i,c=s-o,h=c*u-f*l;if(!(h*hd*d+S*S&&(z=V,tt=W),{cx:z,cy:tt,x01:-f,y01:-c,x11:z*(i/P-1),y11:tt*(i/P-1)}}function Pc(){var t=t1,e=e1,n=D(0),r=null,i=n1,o=r1,a=i1,s=null,u=Pe(l);function l(){var f,c,h=+t.apply(this,arguments),m=+e.apply(this,arguments),g=i.apply(this,arguments)-ei,y=o.apply(this,arguments)-ei,M=lu(y-g),_=y>g;if(s||(s=f=u()),mbt))s.moveTo(0,0);else if(M>re-bt)s.moveTo(m*_e(g),m*qt(g)),s.arc(0,0,m,g,y,!_),h>bt&&(s.moveTo(h*_e(y),h*qt(y)),s.arc(0,0,h,y,g,_));else{var E=g,A=y,I=g,P=y,w=M,q=M,z=a.apply(this,arguments)/2,tt=z>bt&&(r?+r.apply(this,arguments):$(h*h+m*m)),V=ke(lu(m-h)/2,+n.apply(this,arguments)),W=V,v=V,T,d;if(tt>bt){var S=fu(tt/h*qt(z)),x=fu(tt/m*qt(z));(w-=S*2)>bt?(S*=_?1:-1,I+=S,P-=S):(w=0,I=P=(g+y)/2),(q-=x*2)>bt?(x*=_?1:-1,E+=x,A-=x):(q=0,E=A=(g+y)/2)}var N=m*_e(E),C=m*qt(E),R=h*_e(P),L=h*qt(P);if(V>bt){var j=m*_e(A),Z=m*qt(A),Pt=h*_e(I),ct=h*qt(I),ht;if(Mbt?v>bt?(T=Oo(Pt,ct,N,C,m,v,_),d=Oo(j,Z,R,L,m,v,_),s.moveTo(T.cx+T.x01,T.cy+T.y01),vbt)||!(w>bt)?s.lineTo(R,L):W>bt?(T=Oo(R,L,j,Z,h,-W,_),d=Oo(N,C,Pt,ct,h,-W,_),s.lineTo(T.cx+T.x01,T.cy+T.y01),W{on();Ot();rr()});function an(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}var Cc,ir=p(()=>{Cc=Array.prototype.slice});function Lc(t){this._context=t}function sn(t){return new Lc(t)}var ni=p(()=>{Lc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}}});function or(t){return t[0]}function ar(t){return t[1]}var No=p(()=>{});function sr(t,e){var n=D(!0),r=null,i=sn,o=null,a=Pe(s);t=typeof t=="function"?t:t===void 0?or:D(t),e=typeof e=="function"?e:e===void 0?ar:D(e);function s(u){var l,f=(u=an(u)).length,c,h=!1,m;for(r==null&&(o=i(m=a())),l=0;l<=f;++l)!(l{ir();on();ni();rr();No()});function Po(t,e,n){var r=null,i=D(!0),o=null,a=sn,s=null,u=Pe(l);t=typeof t=="function"?t:t===void 0?or:D(+t),e=typeof e=="function"?e:e===void 0?D(0):D(+e),n=typeof n=="function"?n:n===void 0?ar:D(+n);function l(c){var h,m,g,y=(c=an(c)).length,M,_=!1,E,A=new Array(y),I=new Array(y);for(o==null&&(s=a(E=u())),h=0;h<=y;++h){if(!(h=m;--g)s.point(A[g],I[g]);s.lineEnd(),s.areaEnd()}_&&(A[h]=+t(M,h,c),I[h]=+e(M,h,c),s.point(r?+r(M,h,c):A[h],n?+n(M,h,c):I[h]))}if(E)return s=null,E+""||null}function f(){return sr().defined(i).curve(a).context(o)}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:D(+c),r=null,l):t},l.x0=function(c){return arguments.length?(t=typeof c=="function"?c:D(+c),l):t},l.x1=function(c){return arguments.length?(r=c==null?null:typeof c=="function"?c:D(+c),l):r},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:D(+c),n=null,l):e},l.y0=function(c){return arguments.length?(e=typeof c=="function"?c:D(+c),l):e},l.y1=function(c){return arguments.length?(n=c==null?null:typeof c=="function"?c:D(+c),l):n},l.lineX0=l.lineY0=function(){return f().x(t).y(e)},l.lineY1=function(){return f().x(t).y(n)},l.lineX1=function(){return f().x(r).y(e)},l.defined=function(c){return arguments.length?(i=typeof c=="function"?c:D(!!c),l):i},l.curve=function(c){return arguments.length?(a=c,o!=null&&(s=a(o)),l):a},l.context=function(c){return arguments.length?(c==null?o=s=null:s=a(o=c),l):o},l}var pu=p(()=>{ir();on();ni();ko();rr();No()});function Dc(t,e){return et?1:e>=t?0:NaN}var Rc=p(()=>{});function Hc(t){return t}var Fc=p(()=>{});function Yc(){var t=Hc,e=Dc,n=null,r=D(0),i=D(re),o=D(0);function a(s){var u,l=(s=an(s)).length,f,c,h=0,m=new Array(l),g=new Array(l),y=+r.apply(this,arguments),M=Math.min(re,Math.max(-re,i.apply(this,arguments)-y)),_,E=Math.min(Math.abs(M)/l,o.apply(this,arguments)),A=E*(M<0?-1:1),I;for(u=0;u0&&(h+=I);for(e!=null?m.sort(function(P,w){return e(g[P],g[w])}):n!=null&&m.sort(function(P,w){return n(s[P],s[w])}),u=0,c=h?(M-l*A)/h:0;u0?I*c:0)+A,g[f]={data:s[f],index:u,value:I,startAngle:y,endAngle:_,padAngle:E};return g}return a.value=function(s){return arguments.length?(t=typeof s=="function"?s:D(+s),a):t},a.sortValues=function(s){return arguments.length?(e=s,n=null,a):e},a.sort=function(s){return arguments.length?(n=s,e=null,a):n},a.startAngle=function(s){return arguments.length?(r=typeof s=="function"?s:D(+s),a):r},a.endAngle=function(s){return arguments.length?(i=typeof s=="function"?s:D(+s),a):i},a.padAngle=function(s){return arguments.length?(o=typeof s=="function"?s:D(+s),a):o},a}var $c=p(()=>{ir();on();Rc();Fc();Ot()});function zc(t){this._curve=t}function ur(t){function e(n){return new zc(t(n))}return e._curve=t,e}var qo,mu=p(()=>{ni();qo=ur(sn);zc.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,e){this._curve.point(e*Math.sin(t),e*-Math.cos(t))}}});function lr(t){var e=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(n){return arguments.length?e(ur(n)):e()._curve},t}function du(){return lr(sr().curve(qo))}var gu=p(()=>{mu();ko()});function yu(){var t=Po().curve(qo),e=t.curve,n=t.lineX0,r=t.lineX1,i=t.lineY0,o=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return lr(n())},delete t.lineX0,t.lineEndAngle=function(){return lr(r())},delete t.lineX1,t.lineInnerRadius=function(){return lr(i())},delete t.lineY0,t.lineOuterRadius=function(){return lr(o())},delete t.lineY1,t.curve=function(a){return arguments.length?e(ur(a)):e()._curve},t}var Uc=p(()=>{mu();pu();gu()});function An(t,e){return[(e=+e)*Math.cos(t-=Math.PI/2),e*Math.sin(t)]}var _u=p(()=>{});function Lo(t){return new Co(t,!0)}function Do(t){return new Co(t,!1)}function jc(t){return new xu(t)}var Co,xu,vu=p(()=>{_u();Co=class{constructor(e,n){this._context=e,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,n){switch(e=+e,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,n):this._context.moveTo(e,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,n,e,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,e,this._y0,e,n);break}}this._x0=e,this._y0=n}},xu=class{constructor(e){this._context=e}lineStart(){this._point=0}lineEnd(){}point(e,n){if(e=+e,n=+n,this._point===0)this._point=1;else{let r=An(this._x0,this._y0),i=An(this._x0,this._y0=(this._y0+n)/2),o=An(e,this._y0),a=An(e,n);this._context.moveTo(...r),this._context.bezierCurveTo(...i,...o,...a)}this._x0=e,this._y0=n}}});function a1(t){return t.source}function s1(t){return t.target}function ri(t){let e=a1,n=s1,r=or,i=ar,o=null,a=null,s=Pe(u);function u(){let l,f=Cc.call(arguments),c=e.apply(this,f),h=n.apply(this,f);if(o==null&&(a=t(l=s())),a.lineStart(),f[0]=c,a.point(+r.apply(this,f),+i.apply(this,f)),f[0]=h,a.point(+r.apply(this,f),+i.apply(this,f)),a.lineEnd(),l)return a=null,l+""||null}return u.source=function(l){return arguments.length?(e=l,u):e},u.target=function(l){return arguments.length?(n=l,u):n},u.x=function(l){return arguments.length?(r=typeof l=="function"?l:D(+l),u):r},u.y=function(l){return arguments.length?(i=typeof l=="function"?l:D(+l),u):i},u.context=function(l){return arguments.length?(l==null?o=a=null:a=t(o=l),u):o},u}function Bc(){return ri(Lo)}function Xc(){return ri(Do)}function Gc(){let t=ri(jc);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t}var Wc=p(()=>{ir();on();vu();rr();No()});var u1,Ro,wu=p(()=>{Ot();u1=$(3),Ro={draw(t,e){let n=$(e+ke(e/28,.75))*.59436,r=n/2,i=r*u1;t.moveTo(0,n),t.lineTo(0,-n),t.moveTo(-i,-r),t.lineTo(i,r),t.moveTo(-i,r),t.lineTo(i,-r)}}});var fr,bu=p(()=>{Ot();fr={draw(t,e){let n=$(e/xe);t.moveTo(n,0),t.arc(0,0,n,0,re)}}});var Ho,Mu=p(()=>{Ot();Ho={draw(t,e){let n=$(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}}});var Vc,l1,Fo,Tu=p(()=>{Ot();Vc=$(1/3),l1=Vc*2,Fo={draw(t,e){let n=$(e/l1),r=n*Vc;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}}});var Yo,Su=p(()=>{Ot();Yo={draw(t,e){let n=$(e)*.62625;t.moveTo(0,-n),t.lineTo(n,0),t.lineTo(0,n),t.lineTo(-n,0),t.closePath()}}});var $o,Eu=p(()=>{Ot();$o={draw(t,e){let n=$(e-ke(e/7,2))*.87559;t.moveTo(-n,0),t.lineTo(n,0),t.moveTo(0,n),t.lineTo(0,-n)}}});var zo,Iu=p(()=>{Ot();zo={draw(t,e){let n=$(e),r=-n/2;t.rect(r,r,n,n)}}});var Uo,Au=p(()=>{Ot();Uo={draw(t,e){let n=$(e)*.4431;t.moveTo(n,n),t.lineTo(n,-n),t.lineTo(-n,-n),t.lineTo(-n,n),t.closePath()}}});var f1,Zc,c1,h1,jo,Ou=p(()=>{Ot();f1=.8908130915292852,Zc=qt(xe/10)/qt(7*xe/10),c1=qt(re/10)*Zc,h1=-_e(re/10)*Zc,jo={draw(t,e){let n=$(e*f1),r=c1*n,i=h1*n;t.moveTo(0,-n),t.lineTo(r,i);for(let o=1;o<5;++o){let a=re*o/5,s=_e(a),u=qt(a);t.lineTo(u*n,-s*n),t.lineTo(s*r-u*i,u*r+s*i)}t.closePath()}}});var Nu,Bo,ku=p(()=>{Ot();Nu=$(3),Bo={draw(t,e){let n=-$(e/(Nu*3));t.moveTo(0,n*2),t.lineTo(-Nu*n,-n),t.lineTo(Nu*n,-n),t.closePath()}}});var p1,Xo,Pu=p(()=>{Ot();p1=$(3),Xo={draw(t,e){let n=$(e)*.6824,r=n/2,i=n*p1/2;t.moveTo(0,-n),t.lineTo(i,r),t.lineTo(-i,r),t.closePath()}}});var ie,oe,qu,m1,Go,Cu=p(()=>{Ot();ie=-.5,oe=$(3)/2,qu=1/$(12),m1=(qu/2+1)*3,Go={draw(t,e){let n=$(e/m1),r=n/2,i=n*qu,o=r,a=n*qu+n,s=-o,u=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(s,u),t.lineTo(ie*r-oe*i,oe*r+ie*i),t.lineTo(ie*o-oe*a,oe*o+ie*a),t.lineTo(ie*s-oe*u,oe*s+ie*u),t.lineTo(ie*r+oe*i,ie*i-oe*r),t.lineTo(ie*o+oe*a,ie*a-oe*o),t.lineTo(ie*s+oe*u,ie*u-oe*s),t.closePath()}}});var ii,Lu=p(()=>{Ot();ii={draw(t,e){let n=$(e-ke(e/6,1.7))*.6189;t.moveTo(-n,-n),t.lineTo(n,n),t.moveTo(-n,n),t.lineTo(n,-n)}}});function Ru(t,e){let n=null,r=Pe(i);t=typeof t=="function"?t:D(t||fr),e=typeof e=="function"?e:D(e===void 0?64:+e);function i(){let o;if(n||(n=o=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),o)return n=null,o+""||null}return i.type=function(o){return arguments.length?(t=typeof o=="function"?o:D(o),i):t},i.size=function(o){return arguments.length?(e=typeof o=="function"?o:D(+o),i):e},i.context=function(o){return arguments.length?(n=o??null,i):n},i}var Du,Qc,Jc=p(()=>{on();rr();wu();bu();Mu();Tu();Su();Eu();Iu();Au();Ou();ku();Pu();Cu();Lu();Du=[fr,Ho,Fo,zo,jo,Bo,Go],Qc=[fr,$o,ii,Xo,Ro,Uo,Yo]});function ae(){}var oi=p(()=>{});function cr(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function ai(t){this._context=t}function Kc(t){return new ai(t)}var si=p(()=>{ai.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:cr(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:cr(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}}});function th(t){this._context=t}function eh(t){return new th(t)}var nh=p(()=>{oi();si();th.prototype={areaStart:ae,areaEnd:ae,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:cr(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}}});function rh(t){this._context=t}function ih(t){return new rh(t)}var oh=p(()=>{si();rh.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:cr(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}}});function ah(t,e){this._basis=new ai(t),this._beta=e}var sh,uh=p(()=>{si();ah.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,e=this._y,n=t.length-1;if(n>0)for(var r=t[0],i=e[0],o=t[n]-r,a=e[n]-i,s=-1,u;++s<=n;)u=s/n,this._basis.point(this._beta*t[s]+(1-this._beta)*(r+u*o),this._beta*e[s]+(1-this._beta)*(i+u*a));this._x=this._y=null,this._basis.lineEnd()},point:function(t,e){this._x.push(+t),this._y.push(+e)}};sh=(function t(e){function n(r){return e===1?new ai(r):new ah(r,e)}return n.beta=function(r){return t(+r)},n})(.85)});function hr(t,e,n){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-e),t._y2+t._k*(t._y1-n),t._x2,t._y2)}function Wo(t,e){this._context=t,this._k=(1-e)/6}var lh,ui=p(()=>{Wo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:hr(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2,this._x1=t,this._y1=e;break;case 2:this._point=3;default:hr(this,t,e);break}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};lh=(function t(e){function n(r){return new Wo(r,e)}return n.tension=function(r){return t(+r)},n})(0)});function Vo(t,e){this._context=t,this._k=(1-e)/6}var fh,Hu=p(()=>{oi();ui();Vo.prototype={areaStart:ae,areaEnd:ae,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:hr(this,t,e);break}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};fh=(function t(e){function n(r){return new Vo(r,e)}return n.tension=function(r){return t(+r)},n})(0)});function Zo(t,e){this._context=t,this._k=(1-e)/6}var ch,Fu=p(()=>{ui();Zo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:hr(this,t,e);break}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};ch=(function t(e){function n(r){return new Zo(r,e)}return n.tension=function(r){return t(+r)},n})(0)});function li(t,e,n){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>bt){var s=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,u=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*s-t._x0*t._l12_2a+t._x2*t._l01_2a)/u,i=(i*s-t._y0*t._l12_2a+t._y2*t._l01_2a)/u}if(t._l23_a>bt){var l=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,f=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*l+t._x1*t._l23_2a-e*t._l12_2a)/f,a=(a*l+t._y1*t._l23_2a-n*t._l12_2a)/f}t._context.bezierCurveTo(r,i,o,a,t._x2,t._y2)}function hh(t,e){this._context=t,this._alpha=e}var ph,Qo=p(()=>{Ot();ui();hh.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3;default:li(this,t,e);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};ph=(function t(e){function n(r){return e?new hh(r,e):new Wo(r,0)}return n.alpha=function(r){return t(+r)},n})(.5)});function mh(t,e){this._context=t,this._alpha=e}var dh,gh=p(()=>{Hu();oi();Qo();mh.prototype={areaStart:ae,areaEnd:ae,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:li(this,t,e);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};dh=(function t(e){function n(r){return e?new mh(r,e):new Vo(r,0)}return n.alpha=function(r){return t(+r)},n})(.5)});function yh(t,e){this._context=t,this._alpha=e}var _h,xh=p(()=>{Fu();Qo();yh.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:li(this,t,e);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};_h=(function t(e){function n(r){return e?new yh(r,e):new Zo(r,0)}return n.alpha=function(r){return t(+r)},n})(.5)});function vh(t){this._context=t}function wh(t){return new vh(t)}var bh=p(()=>{oi();vh.prototype={areaStart:ae,areaEnd:ae,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}}});function Mh(t){return t<0?-1:1}function Th(t,e,n){var r=t._x1-t._x0,i=e-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(n-t._y1)/(i||r<0&&-0),s=(o*i+a*r)/(r+i);return(Mh(o)+Mh(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(s))||0}function Sh(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function Yu(t,e,n){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,s=(o-r)/3;t._context.bezierCurveTo(r+s,i+s*e,o-s,a-s*n,o,a)}function Jo(t){this._context=t}function Eh(t){this._context=new Ih(t)}function Ih(t){this._context=t}function Ah(t){return new Jo(t)}function Oh(t){return new Eh(t)}var Nh=p(()=>{Jo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Yu(this,this._t0,Sh(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(t=+t,e=+e,!(t===this._x1&&e===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,Yu(this,Sh(this,n=Th(this,t,e)),n);break;default:Yu(this,this._t0,n=Th(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};(Eh.prototype=Object.create(Jo.prototype)).point=function(t,e){Jo.prototype.point.call(this,e,t)};Ih.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,o){this._context.bezierCurveTo(e,t,r,n,o,i)}}});function Ph(t){this._context=t}function kh(t){var e,n=t.length-1,r,i=new Array(n),o=new Array(n),a=new Array(n);for(i[0]=0,o[0]=2,a[0]=t[0]+2*t[1],e=1;e=0;--e)i[e]=(a[e]-i[e+1])/o[e];for(o[n-1]=(t[n]+i[n-1])/2,e=0;e{Ph.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=kh(t),i=kh(e),o=0,a=1;a{Ko.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}break}}this._x=t,this._y=e}}});function ve(t,e){if((a=t.length)>1)for(var n=1,r,i,o=t[e[0]],a,s=o.length;n{});function we(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}var mr=p(()=>{});function d1(t,e){return t[e]}function g1(t){let e=[];return e.key=t,e}function Fh(){var t=D([]),e=we,n=ve,r=d1;function i(o){var a=Array.from(t.apply(this,arguments),g1),s,u=a.length,l=-1,f;for(let c of o)for(s=0,++l;s{ir();on();pr();mr()});function $h(t,e){if((r=t.length)>0){for(var n,r,i=0,o=t[0].length,a;i{pr()});function Uh(t,e){if((u=t.length)>0)for(var n,r=0,i,o,a,s,u,l=t[e[0]].length;r0?(i[0]=a,i[1]=a+=o):o<0?(i[1]=s,i[0]=s+=o):(i[0]=0,i[1]=o)}var jh=p(()=>{});function Bh(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,o=r.length;n{pr()});function Gh(t,e){if(!(!((a=t.length)>0)||!((o=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,o,a;r{pr()});function ta(t){var e=t.map(y1);return we(t).sort(function(n,r){return e[n]-e[r]})}function y1(t){for(var e=-1,n=0,r=t.length,i,o=-1/0;++eo&&(o=i,n=e);return n}var $u=p(()=>{mr()});function ea(t){var e=t.map(zu);return we(t).sort(function(n,r){return e[n]-e[r]})}function zu(t){for(var e=0,n=-1,r=t.length,i;++n{mr()});function Vh(t){return ea(t).reverse()}var Zh=p(()=>{na()});function Qh(t){var e=t.length,n,r,i=t.map(zu),o=ta(t),a=0,s=0,u=[],l=[];for(n=0;n{$u();na()});function Kh(t){return we(t).reverse()}var tp=p(()=>{mr()});var fi={};rn(fi,{arc:()=>Pc,area:()=>Po,areaRadial:()=>yu,curveBasis:()=>Kc,curveBasisClosed:()=>eh,curveBasisOpen:()=>ih,curveBumpX:()=>Lo,curveBumpY:()=>Do,curveBundle:()=>sh,curveCardinal:()=>lh,curveCardinalClosed:()=>fh,curveCardinalOpen:()=>ch,curveCatmullRom:()=>ph,curveCatmullRomClosed:()=>dh,curveCatmullRomOpen:()=>_h,curveLinear:()=>sn,curveLinearClosed:()=>wh,curveMonotoneX:()=>Ah,curveMonotoneY:()=>Oh,curveNatural:()=>qh,curveStep:()=>Lh,curveStepAfter:()=>Rh,curveStepBefore:()=>Dh,line:()=>sr,lineRadial:()=>du,link:()=>ri,linkHorizontal:()=>Bc,linkRadial:()=>Gc,linkVertical:()=>Xc,pie:()=>Yc,pointRadial:()=>An,radialArea:()=>yu,radialLine:()=>du,stack:()=>Fh,stackOffsetDiverging:()=>Uh,stackOffsetExpand:()=>$h,stackOffsetNone:()=>ve,stackOffsetSilhouette:()=>Bh,stackOffsetWiggle:()=>Gh,stackOrderAppearance:()=>ta,stackOrderAscending:()=>ea,stackOrderDescending:()=>Vh,stackOrderInsideOut:()=>Qh,stackOrderNone:()=>we,stackOrderReverse:()=>Kh,symbol:()=>Ru,symbolAsterisk:()=>Ro,symbolCircle:()=>fr,symbolCross:()=>Ho,symbolDiamond:()=>Fo,symbolDiamond2:()=>Yo,symbolPlus:()=>$o,symbolSquare:()=>zo,symbolSquare2:()=>Uo,symbolStar:()=>jo,symbolTimes:()=>ii,symbolTriangle:()=>Bo,symbolTriangle2:()=>Xo,symbolWye:()=>Go,symbolX:()=>ii,symbols:()=>Du,symbolsFill:()=>Du,symbolsStroke:()=>Qc});var ci=p(()=>{qc();pu();ko();$c();Uc();gu();_u();Wc();Jc();wu();bu();Mu();Tu();Su();Eu();Iu();Au();Ou();ku();Pu();Cu();Lu();nh();oh();si();vu();uh();Hu();Fu();ui();gh();xh();Qo();bh();ni();Nh();Ch();Hh();Yh();zh();jh();pr();Xh();Wh();$u();na();Zh();Jh();mr();tp()});function ep(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function On(t,e){if(!isFinite(t)||t===0)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}var hi=p(()=>{});function qe(t){return t=On(Math.abs(t)),t?t[1]:NaN}var pi=p(()=>{hi()});function np(t,e){return function(n,r){for(var i=n.length,o=[],a=0,s=t[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),o.push(n.substring(i-=s,i+s)),!((u+=s+1)>r));)s=t[a=(a+1)%t.length];return o.reverse().join(e)}}var rp=p(()=>{});function ip(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var op=p(()=>{});function be(t){if(!(e=_1.exec(t)))throw new Error("invalid format: "+t);var e;return new mi({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function mi(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}var _1,Uu=p(()=>{_1=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;be.prototype=mi.prototype;mi.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type}});function ap(t){t:for(var e=t.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var sp=p(()=>{});function up(t,e){var n=On(t,e);if(!n)return di=void 0,t.toPrecision(e);var r=n[0],i=n[1],o=i-(di=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+On(t,Math.max(0,e+o-1))[0]}var di,ju=p(()=>{hi()});function Bu(t,e){var n=On(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}var lp=p(()=>{hi()});var Xu,fp=p(()=>{hi();ju();lp();Xu={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:ep,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Bu(t*100,e),r:Bu,s:up,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)}});function Gu(t){return t}var cp=p(()=>{});function ra(t){var e=t.grouping===void 0||t.thousands===void 0?Gu:np(hp.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Gu:ip(hp.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",s=t.minus===void 0?"\u2212":t.minus+"",u=t.nan===void 0?"NaN":t.nan+"";function l(c,h){c=be(c);var m=c.fill,g=c.align,y=c.sign,M=c.symbol,_=c.zero,E=c.width,A=c.comma,I=c.precision,P=c.trim,w=c.type;w==="n"?(A=!0,w="g"):Xu[w]||(I===void 0&&(I=12),P=!0,w="g"),(_||m==="0"&&g==="=")&&(_=!0,m="0",g="=");var q=(h&&h.prefix!==void 0?h.prefix:"")+(M==="$"?n:M==="#"&&/[boxX]/.test(w)?"0"+w.toLowerCase():""),z=(M==="$"?r:/[%p]/.test(w)?a:"")+(h&&h.suffix!==void 0?h.suffix:""),tt=Xu[w],V=/[defgprs%]/.test(w);I=I===void 0?6:/[gprs]/.test(w)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function W(v){var T=q,d=z,S,x,N;if(w==="c")d=tt(v)+d,v="";else{v=+v;var C=v<0||1/v<0;if(v=isNaN(v)?u:tt(Math.abs(v),I),P&&(v=ap(v)),C&&+v==0&&y!=="+"&&(C=!1),T=(C?y==="("?y:s:y==="-"||y==="("?"":y)+T,d=(w==="s"&&!isNaN(v)&&di!==void 0?pp[8+di/3]:"")+d+(C&&y==="("?")":""),V){for(S=-1,x=v.length;++SN||N>57){d=(N===46?i+v.slice(S+1):v.slice(S))+d,v=v.slice(0,S);break}}}A&&!_&&(v=e(v,1/0));var R=T.length+v.length+d.length,L=R>1)+T+v+d+L.slice(R);break;default:v=L+T+v+d;break}return o(v)}return W.toString=function(){return c+""},W}function f(c,h){var m=Math.max(-8,Math.min(8,Math.floor(qe(h)/3)))*3,g=Math.pow(10,-m),y=l((c=be(c),c.type="f",c),{suffix:pp[8+m/3]});return function(M){return y(g*M)}}return{format:l,formatPrefix:f}}var hp,pp,Wu=p(()=>{pi();rp();op();Uu();sp();fp();ju();cp();hp=Array.prototype.map,pp=["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"]});function oa(t){return ia=ra(t),Nn=ia.format,gi=ia.formatPrefix,ia}var ia,Nn,gi,mp=p(()=>{Wu();oa({thousands:",",grouping:[3],currency:["$",""]})});function aa(t){return Math.max(0,-qe(Math.abs(t)))}var dp=p(()=>{pi()});function sa(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(qe(e)/3)))*3-qe(Math.abs(t)))}var gp=p(()=>{pi()});function ua(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,qe(e)-qe(t))+1}var yp=p(()=>{pi()});var Vu={};rn(Vu,{FormatSpecifier:()=>mi,format:()=>Nn,formatDefaultLocale:()=>oa,formatLocale:()=>ra,formatPrefix:()=>gi,formatSpecifier:()=>be,precisionFixed:()=>aa,precisionPrefix:()=>sa,precisionRound:()=>ua});var yi=p(()=>{mp();Wu();Uu();dp();gp();yp()});function Ft(t,e){return t==null||e==null?NaN:te?1:t>=e?0:NaN}var _i=p(()=>{});function Zu(t,e){return t==null||e==null?NaN:et?1:e>=t?0:NaN}var _p=p(()=>{});function kn(t){let e,n,r;t.length!==2?(e=Ft,n=(s,u)=>Ft(t(s),u),r=(s,u)=>t(s)-u):(e=t===Ft||t===Zu?t:x1,n=t,r=t);function i(s,u,l=0,f=s.length){if(l>>1;n(s[c],u)<0?l=c+1:f=c}while(l>>1;n(s[c],u)<=0?l=c+1:f=c}while(ll&&r(s[c-1],u)>-r(s[c],u)?c-1:c}return{left:i,center:a,right:o}}function x1(){return 0}var Qu=p(()=>{_i();_p()});function xi(t){return t===null?NaN:+t}function*xp(t,e){if(e===void 0)for(let n of t)n!=null&&(n=+n)>=n&&(yield n);else{let n=-1;for(let r of t)(r=e(r,++n,t))!=null&&(r=+r)>=r&&(yield r)}}var Ju=p(()=>{});var vp,wp,v1,w1,Me,bp=p(()=>{_i();Qu();Ju();vp=kn(Ft),wp=vp.right,v1=vp.left,w1=kn(xi).center,Me=wp});function Mp({_intern:t,_key:e},n){let r=e(n);return t.has(r)?t.get(r):n}function b1({_intern:t,_key:e},n){let r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function M1({_intern:t,_key:e},n){let r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function T1(t){return t!==null&&typeof t=="object"?t.valueOf():t}var dr,Tp=p(()=>{dr=class extends Map{constructor(e,n=T1){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(let[r,i]of e)this.set(r,i)}get(e){return super.get(Mp(this,e))}has(e){return super.has(Mp(this,e))}set(e,n){return super.set(b1(this,e),n)}delete(e){return super.delete(M1(this,e))}}});function Sp(t=Ft){if(t===Ft)return Ku;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{let r=t(e,n);return r||r===0?r:(t(n,n)===0)-(t(e,e)===0)}}function Ku(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(te?1:0)}var Ep=p(()=>{_i()});function la(t,e,n){let r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),a=o>=S1?10:o>=E1?5:o>=I1?2:1,s,u,l;return i<0?(l=Math.pow(10,-i)/a,s=Math.round(t*l),u=Math.round(e*l),s/le&&--u,l=-l):(l=Math.pow(10,i)*a,s=Math.round(t/l),u=Math.round(e/l),s*le&&--u),u0))return[];if(t===e)return[t];let r=e=i))return[];let s=o-i+1,u=new Array(s);if(r)if(a<0)for(let l=0;l{S1=Math.sqrt(50),E1=Math.sqrt(10),I1=Math.sqrt(2)});function fa(t,e){let n;if(e===void 0)for(let r of t)r!=null&&(n=r)&&(n=r);else{let r=-1;for(let i of t)(i=e(i,++r,t))!=null&&(n=i)&&(n=i)}return n}var Ap=p(()=>{});function ca(t,e){let n;if(e===void 0)for(let r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let i of t)(i=e(i,++r,t))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}var Op=p(()=>{});function ha(t,e,n=0,r=1/0,i){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(i=i===void 0?Ku:Sp(i);r>n;){if(r-n>600){let u=r-n+1,l=e-n+1,f=Math.log(u),c=.5*Math.exp(2*f/3),h=.5*Math.sqrt(f*c*(u-c)/u)*(l-u/2<0?-1:1),m=Math.max(n,Math.floor(e-l*c/u+h)),g=Math.min(r,Math.floor(e+(u-l)*c/u+h));ha(t,e,m,g,i)}let o=t[e],a=n,s=r;for(wi(t,n,e),i(t[r],o)>0&&wi(t,n,r);a0;)--s}i(t[n],o)===0?wi(t,n,s):(++s,wi(t,s,r)),s<=e&&(n=s+1),e<=s&&(r=s-1)}return t}function wi(t,e,n){let r=t[e];t[e]=t[n],t[n]=r}var Np=p(()=>{Ep()});function pa(t,e,n){if(t=Float64Array.from(xp(t,n)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return ca(t);if(e>=1)return fa(t);var r,i=(r-1)*e,o=Math.floor(i),a=fa(ha(t,o).subarray(0,o+1)),s=ca(t.subarray(o+1));return a+(s-a)*(i-o)}}function tl(t,e,n=xi){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,o=Math.floor(i),a=+n(t[o],o,t),s=+n(t[o+1],o+1,t);return a+(s-a)*(i-o)}}var kp=p(()=>{Ap();Op();Np();Ju()});function ma(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,o=new Array(i);++r{});var se=p(()=>{bp();_i();Qu();kp();Pp();Ip();Tp()});function ut(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function ue(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}var Ct=p(()=>{});function yr(){var t=new dr,e=[],n=[],r=da;function i(o){let a=t.get(o);if(a===void 0){if(r!==da)return r;t.set(o,a=e.push(o)-1)}return n[a%n.length]}return i.domain=function(o){if(!arguments.length)return e.slice();e=[],t=new dr;for(let a of o)t.has(a)||t.set(a,e.push(a)-1);return i},i.range=function(o){return arguments.length?(n=Array.from(o),i):n.slice()},i.unknown=function(o){return arguments.length?(r=o,i):r},i.copy=function(){return yr(e,n).unknown(r)},ut.apply(i,arguments),i}var da,el=p(()=>{se();Ct();da=Symbol("implicit")});function bi(){var t=yr().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,o,a,s=!1,u=0,l=0,f=.5;delete t.unknown;function c(){var h=e().length,m=i{se();Ct();el()});function je(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function un(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}var ga=p(()=>{});function Le(){}function Rp(){return this.rgb().formatHex()}function L1(){return this.rgb().formatHex8()}function D1(){return jp(this).formatHsl()}function Hp(){return this.rgb().formatRgb()}function le(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=A1.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Fp(e):n===3?new dt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?ya(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?ya(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=O1.exec(t))?new dt(e[1],e[2],e[3],1):(e=N1.exec(t))?new dt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=k1.exec(t))?ya(e[1],e[2],e[3],e[4]):(e=P1.exec(t))?ya(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=q1.exec(t))?zp(e[1],e[2]/100,e[3]/100,1):(e=C1.exec(t))?zp(e[1],e[2]/100,e[3]/100,e[4]):Dp.hasOwnProperty(t)?Fp(Dp[t]):t==="transparent"?new dt(NaN,NaN,NaN,0):null}function Fp(t){return new dt(t>>16&255,t>>8&255,t&255,1)}function ya(t,e,n,r){return r<=0&&(t=e=n=NaN),new dt(t,e,n,r)}function Ti(t){return t instanceof Le||(t=le(t)),t?(t=t.rgb(),new dt(t.r,t.g,t.b,t.opacity)):new dt}function Dn(t,e,n,r){return arguments.length===1?Ti(t):new dt(t,e,n,r??1)}function dt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Yp(){return`#${qn(this.r)}${qn(this.g)}${qn(this.b)}`}function R1(){return`#${qn(this.r)}${qn(this.g)}${qn(this.b)}${qn((isNaN(this.opacity)?1:this.opacity)*255)}`}function $p(){let t=xa(this.opacity);return`${t===1?"rgb(":"rgba("}${Cn(this.r)}, ${Cn(this.g)}, ${Cn(this.b)}${t===1?")":`, ${t})`}`}function xa(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Cn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function qn(t){return t=Cn(t),(t<16?"0":"")+t.toString(16)}function zp(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Te(t,e,n,r)}function jp(t){if(t instanceof Te)return new Te(t.h,t.s,t.l,t.opacity);if(t instanceof Le||(t=le(t)),!t)return new Te;if(t instanceof Te)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(e===o?a=(n-r)/s+(n0&&u<1?0:a,new Te(a,s,u,t.opacity)}function xr(t,e,n,r){return arguments.length===1?jp(t):new Te(t,e,n,r??1)}function Te(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Up(t){return t=(t||0)%360,t<0?t+360:t}function _a(t){return Math.max(0,Math.min(1,t||0))}function nl(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}var ln,Ln,_r,Mi,Ce,A1,O1,N1,k1,P1,q1,C1,Dp,va=p(()=>{ga();ln=.7,Ln=1/ln,_r="\\s*([+-]?\\d+)\\s*",Mi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ce="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",A1=/^#([0-9a-f]{3,8})$/,O1=new RegExp(`^rgb\\(${_r},${_r},${_r}\\)$`),N1=new RegExp(`^rgb\\(${Ce},${Ce},${Ce}\\)$`),k1=new RegExp(`^rgba\\(${_r},${_r},${_r},${Mi}\\)$`),P1=new RegExp(`^rgba\\(${Ce},${Ce},${Ce},${Mi}\\)$`),q1=new RegExp(`^hsl\\(${Mi},${Ce},${Ce}\\)$`),C1=new RegExp(`^hsla\\(${Mi},${Ce},${Ce},${Mi}\\)$`),Dp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};je(Le,le,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Rp,formatHex:Rp,formatHex8:L1,formatHsl:D1,formatRgb:Hp,toString:Hp});je(dt,Dn,un(Le,{brighter(t){return t=t==null?Ln:Math.pow(Ln,t),new dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ln:Math.pow(ln,t),new dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new dt(Cn(this.r),Cn(this.g),Cn(this.b),xa(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Yp,formatHex:Yp,formatHex8:R1,formatRgb:$p,toString:$p}));je(Te,xr,un(Le,{brighter(t){return t=t==null?Ln:Math.pow(Ln,t),new Te(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ln:Math.pow(ln,t),new Te(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new dt(nl(t>=240?t-240:t+120,i,r),nl(t,i,r),nl(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Te(Up(this.h),_a(this.s),_a(this.l),xa(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let t=xa(this.opacity);return`${t===1?"hsl(":"hsla("}${Up(this.h)}, ${_a(this.s)*100}%, ${_a(this.l)*100}%${t===1?")":`, ${t})`}`}}))});var wa,ba,rl=p(()=>{wa=Math.PI/180,ba=180/Math.PI});function Zp(t){if(t instanceof Se)return new Se(t.l,t.a,t.b,t.opacity);if(t instanceof De)return tm(t);t instanceof dt||(t=Ti(t));var e=sl(t.r),n=sl(t.g),r=sl(t.b),i=il((.2225045*e+.7168786*n+.0606169*r)/Xp),o,a;return e===n&&n===r?o=a=i:(o=il((.4360747*e+.3850649*n+.1430804*r)/Bp),a=il((.0139322*e+.0971045*n+.7141733*r)/Gp)),new Se(116*i-16,500*(o-i),200*(i-a),t.opacity)}function Qp(t,e){return new Se(t,0,0,e??1)}function Rn(t,e,n,r){return arguments.length===1?Zp(t):new Se(t,e,n,r??1)}function Se(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function il(t){return t>H1?Math.pow(t,1/3):t/Vp+Wp}function ol(t){return t>vr?t*t*t:Vp*(t-Wp)}function al(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function sl(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Jp(t){if(t instanceof De)return new De(t.h,t.c,t.l,t.opacity);if(t instanceof Se||(t=Zp(t)),t.a===0&&t.b===0)return new De(NaN,0{ga();va();rl();Ma=18,Bp=.96422,Xp=1,Gp=.82521,Wp=4/29,vr=6/29,Vp=3*vr*vr,H1=vr*vr*vr;je(Se,Rn,un(Le,{brighter(t){return new Se(this.l+Ma*(t??1),this.a,this.b,this.opacity)},darker(t){return new Se(this.l-Ma*(t??1),this.a,this.b,this.opacity)},rgb(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return e=Bp*ol(e),t=Xp*ol(t),n=Gp*ol(n),new dt(al(3.1338561*e-1.6168667*t-.4906146*n),al(-.9787684*e+1.9161415*t+.033454*n),al(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}}));je(De,wr,un(Le,{brighter(t){return new De(this.h,this.c,this.l+Ma*(t??1),this.opacity)},darker(t){return new De(this.h,this.c,this.l-Ma*(t??1),this.opacity)},rgb(){return tm(this).rgb()}}))});function F1(t){if(t instanceof Hn)return new Hn(t.h,t.s,t.l,t.opacity);t instanceof dt||(t=Ti(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(im*r+nm*e-rm*n)/(im+nm-rm),o=r-i,a=(Si*(n-i)-ll*o)/Ta,s=Math.sqrt(a*a+o*o)/(Si*i*(1-i)),u=s?Math.atan2(a,o)*ba-120:NaN;return new Hn(u<0?u+360:u,s,i,t.opacity)}function Fn(t,e,n,r){return arguments.length===1?F1(t):new Hn(t,e,n,r??1)}function Hn(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}var om,ul,ll,Ta,Si,nm,rm,im,am=p(()=>{ga();va();rl();om=-.14861,ul=1.78277,ll=-.29227,Ta=-.90649,Si=1.97294,nm=Si*Ta,rm=Si*ul,im=ul*ll-Ta*om;je(Hn,Fn,un(Le,{brighter(t){return t=t==null?Ln:Math.pow(Ln,t),new Hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ln:Math.pow(ln,t),new Hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*wa,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new dt(255*(e+n*(om*r+ul*i)),255*(e+n*(ll*r+Ta*i)),255*(e+n*(Si*r)),this.opacity)}}))});var Sa={};rn(Sa,{color:()=>le,cubehelix:()=>Fn,gray:()=>Qp,hcl:()=>wr,hsl:()=>xr,lab:()=>Rn,lch:()=>Kp,rgb:()=>Dn});var Ee=p(()=>{va();em();am()});function fl(t,e,n,r,i){var o=t*t,a=o*t;return((1-3*t+3*o-a)*e+(4-6*o+3*a)*n+(1+3*t+3*o-3*a)*r+a*i)/6}function Ea(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,s=r{});function Aa(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],o=t[r%e],a=t[(r+1)%e],s=t[(r+2)%e];return fl((n-r/e)*e,i,o,a,s)}}var cl=p(()=>{Ia()});var br,hl=p(()=>{br=t=>()=>t});function sm(t,e){return function(n){return t+n*e}}function Y1(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function fn(t,e){var n=e-t;return n?sm(t,n>180||n<-180?n-360*Math.round(n/360):n):br(isNaN(t)?e:t)}function um(t){return(t=+t)==1?lt:function(e,n){return n-e?Y1(e,n,t):br(isNaN(e)?n:e)}}function lt(t,e){var n=e-t;return n?sm(t,n):br(isNaN(t)?e:t)}var Yn=p(()=>{hl()});function lm(t){return function(e){var n=e.length,r=new Array(n),i=new Array(n),o=new Array(n),a,s;for(a=0;a{Ee();Ia();cl();Yn();cn=(function t(e){var n=um(e);function r(i,o){var a=n((i=Dn(i)).r,(o=Dn(o)).r),s=n(i.g,o.g),u=n(i.b,o.b),l=lt(i.opacity,o.opacity);return function(f){return i.r=a(f),i.g=s(f),i.b=u(f),i.opacity=l(f),i+""}}return r.gamma=t,r})(1);fm=lm(Ea),cm=lm(Aa)});function Mr(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(o){for(i=0;i{});function hm(t,e){return(Oa(e)?Mr:ml)(t,e)}function ml(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),o=new Array(n),a;for(a=0;a{Ei();Na()});function ka(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}var gl=p(()=>{});function Mt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var Ii=p(()=>{});function Pa(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=Bt(t[i],e[i]):r[i]=e[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var yl=p(()=>{Ei()});function $1(t){return function(){return t}}function z1(t){return function(e){return t(e)+""}}function Tr(t,e){var n=xl.lastIndex=_l.lastIndex=0,r,i,o,a=-1,s=[],u=[];for(t=t+"",e=e+"";(r=xl.exec(t))&&(i=_l.exec(e));)(o=i.index)>n&&(o=e.slice(n,o),s[a]?s[a]+=o:s[++a]=o),(r=r[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,u.push({i:a,x:Mt(r,i)})),n=_l.lastIndex;return n{Ii();xl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_l=new RegExp(xl.source,"g")});function Bt(t,e){var n=typeof e,r;return e==null||n==="boolean"?br(e):(n==="number"?Mt:n==="string"?(r=le(e))?(e=r,cn):Tr:e instanceof le?cn:e instanceof Date?ka:Oa(e)?Mr:Array.isArray(e)?ml:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Pa:Mt)(t,e)}var Ei=p(()=>{Ee();pl();dl();gl();Ii();yl();vl();hl();Na()});function pm(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))]}}var mm=p(()=>{});function dm(t,e){var n=fn(+t,+e);return function(r){var i=n(r);return i-360*Math.floor(i/360)}}var gm=p(()=>{Yn()});function hn(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var ym=p(()=>{});function wl(t,e,n,r,i,o){var a,s,u;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r{_m=180/Math.PI,qa={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1}});function vm(t){let e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?qa:wl(e.a,e.b,e.c,e.d,e.e,e.f)}function wm(t){return t==null?qa:(Ca||(Ca=document.createElementNS("http://www.w3.org/2000/svg","g")),Ca.setAttribute("transform",t),(t=Ca.transform.baseVal.consolidate())?(t=t.matrix,wl(t.a,t.b,t.c,t.d,t.e,t.f)):qa)}var Ca,bm=p(()=>{xm()});function Mm(t,e,n,r){function i(l){return l.length?l.pop()+" ":""}function o(l,f,c,h,m,g){if(l!==c||f!==h){var y=m.push("translate(",null,e,null,n);g.push({i:y-4,x:Mt(l,c)},{i:y-2,x:Mt(f,h)})}else(c||h)&&m.push("translate("+c+e+h+n)}function a(l,f,c,h){l!==f?(l-f>180?f+=360:f-l>180&&(l+=360),h.push({i:c.push(i(c)+"rotate(",null,r)-2,x:Mt(l,f)})):f&&c.push(i(c)+"rotate("+f+r)}function s(l,f,c,h){l!==f?h.push({i:c.push(i(c)+"skewX(",null,r)-2,x:Mt(l,f)}):f&&c.push(i(c)+"skewX("+f+r)}function u(l,f,c,h,m,g){if(l!==c||f!==h){var y=m.push(i(m)+"scale(",null,",",null,")");g.push({i:y-4,x:Mt(l,c)},{i:y-2,x:Mt(f,h)})}else(c!==1||h!==1)&&m.push(i(m)+"scale("+c+","+h+")")}return function(l,f){var c=[],h=[];return l=t(l),f=t(f),o(l.translateX,l.translateY,f.translateX,f.translateY,c,h),a(l.rotate,f.rotate,c,h),s(l.skewX,f.skewX,c,h),u(l.scaleX,l.scaleY,f.scaleX,f.scaleY,c,h),l=f=null,function(m){for(var g=-1,y=h.length,M;++g{Ii();bm();La=Mm(vm,"px, ","px)","deg)"),Da=Mm(wm,", ",")",")")});function Sm(t){return((t=Math.exp(t))+1/t)/2}function j1(t){return((t=Math.exp(t))-1/t)/2}function B1(t){return((t=Math.exp(2*t))-1)/(t+1)}var U1,Ra,Em=p(()=>{U1=1e-12;Ra=(function t(e,n,r){function i(o,a){var s=o[0],u=o[1],l=o[2],f=a[0],c=a[1],h=a[2],m=f-s,g=c-u,y=m*m+g*g,M,_;if(y{Ee();Yn();Am=Im(fn),Om=Im(lt)});function bl(t,e){var n=lt((t=Rn(t)).l,(e=Rn(e)).l),r=lt(t.a,e.a),i=lt(t.b,e.b),o=lt(t.opacity,e.opacity);return function(a){return t.l=n(a),t.a=r(a),t.b=i(a),t.opacity=o(a),t+""}}var km=p(()=>{Ee();Yn()});function Pm(t){return function(e,n){var r=t((e=wr(e)).h,(n=wr(n)).h),i=lt(e.c,n.c),o=lt(e.l,n.l),a=lt(e.opacity,n.opacity);return function(s){return e.h=r(s),e.c=i(s),e.l=o(s),e.opacity=a(s),e+""}}}var qm,Cm,Lm=p(()=>{Ee();Yn();qm=Pm(fn),Cm=Pm(lt)});function Dm(t){return(function e(n){n=+n;function r(i,o){var a=t((i=Fn(i)).h,(o=Fn(o)).h),s=lt(i.s,o.s),u=lt(i.l,o.l),l=lt(i.opacity,o.opacity);return function(f){return i.h=a(f),i.s=s(f),i.l=u(Math.pow(f,n)),i.opacity=l(f),i+""}}return r.gamma=e,r})(1)}var Rm,Hm,Fm=p(()=>{Ee();Yn();Rm=Dm(fn),Hm=Dm(lt)});function Ai(t,e){e===void 0&&(e=t,t=Bt);for(var n=0,r=e.length-1,i=e[0],o=new Array(r<0?0:r);n{Ei()});function $m(t,e){for(var n=new Array(e),r=0;r{});var Um={};rn(Um,{interpolate:()=>Bt,interpolateArray:()=>hm,interpolateBasis:()=>Ea,interpolateBasisClosed:()=>Aa,interpolateCubehelix:()=>Rm,interpolateCubehelixLong:()=>Hm,interpolateDate:()=>ka,interpolateDiscrete:()=>pm,interpolateHcl:()=>qm,interpolateHclLong:()=>Cm,interpolateHsl:()=>Am,interpolateHslLong:()=>Om,interpolateHue:()=>dm,interpolateLab:()=>bl,interpolateNumber:()=>Mt,interpolateNumberArray:()=>Mr,interpolateObject:()=>Pa,interpolateRgb:()=>cn,interpolateRgbBasis:()=>fm,interpolateRgbBasisClosed:()=>cm,interpolateRound:()=>hn,interpolateString:()=>Tr,interpolateTransformCss:()=>La,interpolateTransformSvg:()=>Da,interpolateZoom:()=>Ra,piecewise:()=>Ai,quantize:()=>$m});var Be=p(()=>{Ei();dl();Ia();cl();gl();mm();gm();Ii();Na();yl();ym();vl();Tm();Em();pl();Nm();km();Lm();Fm();Ym();zm()});function Ml(t){return function(){return t}}var jm=p(()=>{});function pn(t){return+t}var Ha=p(()=>{});function _t(t){return t}function Tl(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Ml(isNaN(e)?NaN:.5)}function X1(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function G1(t,e,n){var r=t[0],i=t[1],o=e[0],a=e[1];return i2?W1:G1,u=l=null,c}function c(h){return h==null||isNaN(h=+h)?o:(u||(u=s(t.map(r),e,n)))(r(a(h)))}return c.invert=function(h){return a(i((l||(l=s(e,t.map(r),Mt)))(h)))},c.domain=function(h){return arguments.length?(t=Array.from(h,pn),f()):t.slice()},c.range=function(h){return arguments.length?(e=Array.from(h),f()):e.slice()},c.rangeRound=function(h){return e=Array.from(h),n=hn,f()},c.clamp=function(h){return arguments.length?(a=h?!0:_t,f()):a!==_t},c.interpolate=function(h){return arguments.length?(n=h,f()):n},c.unknown=function(h){return arguments.length?(o=h,c):o},function(h,m){return r=h,i=m,f()}}function zn(){return $n()(_t,_t)}var Bm,He=p(()=>{se();Be();jm();Ha();Bm=[0,1]});function Oi(t,e,n,r){var i=gr(t,e,n),o;switch(r=be(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(o=sa(i,a))&&(r.precision=o),gi(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=ua(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=aa(i))&&(r.precision=o-(r.type==="%")*2);break}}return Nn(r)}var Sl=p(()=>{se();yi()});function Yt(t){var e=t.domain;return t.ticks=function(n){var r=e();return Pn(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return Oi(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,o=r.length-1,a=r[i],s=r[o],u,l,f=10;for(s0;){if(l=vi(a,s,n),l===u)return r[i]=a,r[o]=s,e(r);if(l>0)a=Math.floor(a/l)*l,s=Math.ceil(s/l)*l;else if(l<0)a=Math.ceil(a*l)/l,s=Math.floor(s*l)/l;else break;u=l}return t},t}function Fa(){var t=zn();return t.copy=function(){return Re(t,Fa())},ut.apply(t,arguments),Yt(t)}var Xe=p(()=>{se();He();Ct();Sl()});function Ya(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,pn),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return Ya(t).unknown(e)},t=arguments.length?Array.from(t,pn):[0,1],Yt(n)}var Xm=p(()=>{Xe();Ha()});function Ni(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],o=t[r],a;return o{});function Gm(t){return Math.log(t)}function Wm(t){return Math.exp(t)}function V1(t){return-Math.log(-t)}function Z1(t){return-Math.exp(-t)}function Q1(t){return isFinite(t)?+("1e"+t):t<0?0:t}function J1(t){return t===10?Q1:t===Math.E?Math.exp:e=>Math.pow(t,e)}function K1(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function Vm(t){return(e,n)=>-t(-e,n)}function ki(t){let e=t(Gm,Wm),n=e.domain,r=10,i,o;function a(){return i=K1(r),o=J1(r),n()[0]<0?(i=Vm(i),o=Vm(o),t(V1,Z1)):t(Gm,Wm),e}return e.base=function(s){return arguments.length?(r=+s,a()):r},e.domain=function(s){return arguments.length?(n(s),a()):n()},e.ticks=s=>{let u=n(),l=u[0],f=u[u.length-1],c=f0){for(;h<=m;++h)for(g=1;gf)break;_.push(y)}}else for(;h<=m;++h)for(g=r-1;g>=1;--g)if(y=h>0?g/o(-h):g*o(h),!(yf)break;_.push(y)}_.length*2{if(s==null&&(s=10),u==null&&(u=r===10?"s":","),typeof u!="function"&&(!(r%1)&&(u=be(u)).precision==null&&(u.trim=!0),u=Nn(u)),s===1/0)return u;let l=Math.max(1,r*s/e.ticks().length);return f=>{let c=f/o(Math.round(i(f)));return c*rn(Ni(n(),{floor:s=>o(Math.floor(i(s))),ceil:s=>o(Math.ceil(i(s)))})),e}function $a(){let t=ki($n()).domain([1,10]);return t.copy=()=>Re(t,$a()).base(t.base()),ut.apply(t,arguments),t}var za=p(()=>{se();yi();El();He();Ct()});function Zm(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Qm(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function Pi(t){var e=1,n=t(Zm(e),Qm(e));return n.constant=function(r){return arguments.length?t(Zm(e=+r),Qm(e)):e},Yt(n)}function Ua(){var t=Pi($n());return t.copy=function(){return Re(t,Ua()).constant(t.constant())},ut.apply(t,arguments)}var ja=p(()=>{Xe();He();Ct()});function Jm(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function tw(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function ew(t){return t<0?-t*t:t*t}function qi(t){var e=t(_t,_t),n=1;function r(){return n===1?t(_t,_t):n===.5?t(tw,ew):t(Jm(n),Jm(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Yt(e)}function Ci(){var t=qi($n());return t.copy=function(){return Re(t,Ci()).exponent(t.exponent())},ut.apply(t,arguments),t}function Km(){return Ci.apply(null,arguments).exponent(.5)}var Ba=p(()=>{Xe();He();Ct()});function td(t){return Math.sign(t)*t*t}function nw(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Xa(){var t=zn(),e=[0,1],n=!1,r;function i(o){var a=nw(t(o));return isNaN(a)?r:n?Math.round(a):a}return i.invert=function(o){return t.invert(td(o))},i.domain=function(o){return arguments.length?(t.domain(o),i):t.domain()},i.range=function(o){return arguments.length?(t.range((e=Array.from(o,pn)).map(td)),i):e.slice()},i.rangeRound=function(o){return i.range(o).round(!0)},i.round=function(o){return arguments.length?(n=!!o,i):n},i.clamp=function(o){return arguments.length?(t.clamp(o),i):t.clamp()},i.unknown=function(o){return arguments.length?(r=o,i):r},i.copy=function(){return Xa(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},ut.apply(i,arguments),Yt(i)}var ed=p(()=>{He();Ct();Xe();Ha()});function Ga(){var t=[],e=[],n=[],r;function i(){var a=0,s=Math.max(1,e.length);for(n=new Array(s-1);++a0?n[s-1]:t[0],s{se();Ct()});function Wa(){var t=0,e=1,n=1,r=[.5],i=[0,1],o;function a(u){return u!=null&&u<=u?i[Me(r,u,0,n)]:o}function s(){var u=-1;for(r=new Array(n);++u=n?[r[n-1],e]:[r[l-1],r[l]]},a.unknown=function(u){return arguments.length&&(o=u),a},a.thresholds=function(){return r.slice()},a.copy=function(){return Wa().domain([t,e]).range(i).unknown(o)},ut.apply(Yt(a),arguments)}var rd=p(()=>{se();Xe();Ct()});function Va(){var t=[.5],e=[0,1],n,r=1;function i(o){return o!=null&&o<=o?e[Me(t,o,0,r)]:n}return i.domain=function(o){return arguments.length?(t=Array.from(o),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(o){return arguments.length?(e=Array.from(o),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(o){var a=e.indexOf(o);return[t[a-1],t[a]]},i.unknown=function(o){return arguments.length?(n=o,i):n},i.copy=function(){return Va().domain(t).range(e).unknown(n)},ut.apply(i,arguments)}var id=p(()=>{se();Ct()});function et(t,e,n,r){function i(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return i.floor=o=>(t(o=new Date(+o)),o),i.ceil=o=>(t(o=new Date(o-1)),e(o,1),t(o),o),i.round=o=>{let a=i(o),s=i.ceil(o);return o-a(e(o=new Date(+o),a==null?1:Math.floor(a)),o),i.range=(o,a,s)=>{let u=[];if(o=i.ceil(o),s=s==null?1:Math.floor(s),!(o0))return u;let l;do u.push(l=new Date(+o)),e(o,s),t(o);while(let(a=>{if(a>=a)for(;t(a),!o(a);)a.setTime(a-1)},(a,s)=>{if(a>=a)if(s<0)for(;++s<=0;)for(;e(a,-1),!o(a););else for(;--s>=0;)for(;e(a,1),!o(a););}),n&&(i.count=(o,a)=>(Il.setTime(+o),Al.setTime(+a),t(Il),t(Al),Math.floor(n(Il,Al))),i.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?i.filter(r?a=>r(a)%o===0:a=>i.count(0,a)%o===0):i)),i}var Il,Al,Ge=p(()=>{Il=new Date,Al=new Date});var Li,lL,od=p(()=>{Ge();Li=et(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Li.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?et(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Li);lL=Li.range});var fe,ad,Ol=p(()=>{Ge();fe=et(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*1e3)},(t,e)=>(e-t)/1e3,t=>t.getUTCSeconds()),ad=fe.range});var Sr,rw,Er,iw,Nl=p(()=>{Ge();Sr=et(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*1e3)},(t,e)=>{t.setTime(+t+e*6e4)},(t,e)=>(e-t)/6e4,t=>t.getMinutes()),rw=Sr.range,Er=et(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*6e4)},(t,e)=>(e-t)/6e4,t=>t.getUTCMinutes()),iw=Er.range});var Ir,ow,Ar,aw,kl=p(()=>{Ge();Ir=et(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*1e3-t.getMinutes()*6e4)},(t,e)=>{t.setTime(+t+e*36e5)},(t,e)=>(e-t)/36e5,t=>t.getHours()),ow=Ir.range,Ar=et(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*36e5)},(t,e)=>(e-t)/36e5,t=>t.getUTCHours()),aw=Ar.range});var We,sw,Bn,uw,Za,lw,Pl=p(()=>{Ge();We=et(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5,t=>t.getDate()-1),sw=We.range,Bn=et(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/864e5,t=>t.getUTCDate()-1),uw=Bn.range,Za=et(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/864e5,t=>Math.floor(t/864e5)),lw=Za.range});function Xn(t){return et(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*6e4)/6048e5)}function Gn(t){return et(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/6048e5)}var Ve,Or,ud,ld,mn,fd,cd,hd,fw,cw,hw,pw,mw,dw,Ze,Nr,pd,md,dn,dd,gd,yd,gw,yw,_w,xw,vw,ww,ql=p(()=>{Ge();Ve=Xn(0),Or=Xn(1),ud=Xn(2),ld=Xn(3),mn=Xn(4),fd=Xn(5),cd=Xn(6),hd=Ve.range,fw=Or.range,cw=ud.range,hw=ld.range,pw=mn.range,mw=fd.range,dw=cd.range;Ze=Gn(0),Nr=Gn(1),pd=Gn(2),md=Gn(3),dn=Gn(4),dd=Gn(5),gd=Gn(6),yd=Ze.range,gw=Nr.range,yw=pd.range,_w=md.range,xw=dn.range,vw=dd.range,ww=gd.range});var kr,bw,Pr,Mw,Cl=p(()=>{Ge();kr=et(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth()),bw=kr.range,Pr=et(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth()),Mw=Pr.range});var Qt,Tw,Jt,Sw,Ll=p(()=>{Ge();Qt=et(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Qt.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:et(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Tw=Qt.range,Jt=et(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());Jt.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:et(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});Sw=Jt.range});function xd(t,e,n,r,i,o){let a=[[fe,1,1e3],[fe,5,5*1e3],[fe,15,15*1e3],[fe,30,30*1e3],[o,1,6e4],[o,5,5*6e4],[o,15,15*6e4],[o,30,30*6e4],[i,1,36e5],[i,3,3*36e5],[i,6,6*36e5],[i,12,12*36e5],[r,1,864e5],[r,2,2*864e5],[n,1,6048e5],[e,1,2592e6],[e,3,3*2592e6],[t,1,31536e6]];function s(l,f,c){let h=fM).right(a,h);if(m===a.length)return t.every(gr(l/31536e6,f/31536e6,c));if(m===0)return Li.every(Math.max(gr(l,f,c),1));let[g,y]=a[h/a[m-1][2]{se();od();Ol();Nl();kl();Pl();ql();Cl();Ll();[Dl,Rl]=xd(Jt,Pr,Ze,Za,Ar,Er),[Hl,Fl]=xd(Qt,kr,Ve,We,Ir,Sr)});var Qa=p(()=>{Ol();Nl();kl();Pl();ql();Cl();Ll();vd()});function Yl(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function $l(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Ri(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function zl(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,o=t.days,a=t.shortDays,s=t.months,u=t.shortMonths,l=Hi(i),f=Fi(i),c=Hi(o),h=Fi(o),m=Hi(a),g=Fi(a),y=Hi(s),M=Fi(s),_=Hi(u),E=Fi(u),A={a:N,A:C,b:R,B:L,c:null,d:Ed,e:Ed,f:Vw,g:ob,G:sb,H:Xw,I:Gw,j:Ww,L:kd,m:Zw,M:Qw,p:j,q:Z,Q:Od,s:Nd,S:Jw,u:Kw,U:tb,V:eb,w:nb,W:rb,x:null,X:null,y:ib,Y:ab,Z:ub,"%":Ad},I={a:Pt,A:ct,b:ht,B:Rt,c:null,d:Id,e:Id,f:hb,g:bb,G:Tb,H:lb,I:fb,j:cb,L:qd,m:pb,M:mb,p:It,q:Ht,Q:Od,s:Nd,S:db,u:gb,U:yb,V:_b,w:xb,W:vb,x:null,X:null,y:wb,Y:Mb,Z:Sb,"%":Ad},P={a:V,A:W,b:v,B:T,c:d,d:Td,e:Td,f:zw,g:Md,G:bd,H:Sd,I:Sd,j:Hw,L:$w,m:Rw,M:Fw,p:tt,q:Dw,Q:jw,s:Bw,S:Yw,u:kw,U:Pw,V:qw,w:Nw,W:Cw,x:S,X:x,y:Md,Y:bd,Z:Lw,"%":Uw};A.x=w(n,A),A.X=w(r,A),A.c=w(e,A),I.x=w(n,I),I.X=w(r,I),I.c=w(e,I);function w(k,Y){return function(U){var b=[],jt=-1,rt=0,Vt=k.length,Zt,Sn,bc;for(U instanceof Date||(U=new Date(+U));++jt53)return null;"w"in b||(b.w=1),"Z"in b?(rt=$l(Ri(b.y,0,1)),Vt=rt.getUTCDay(),rt=Vt>4||Vt===0?Nr.ceil(rt):Nr(rt),rt=Bn.offset(rt,(b.V-1)*7),b.y=rt.getUTCFullYear(),b.m=rt.getUTCMonth(),b.d=rt.getUTCDate()+(b.w+6)%7):(rt=Yl(Ri(b.y,0,1)),Vt=rt.getDay(),rt=Vt>4||Vt===0?Or.ceil(rt):Or(rt),rt=We.offset(rt,(b.V-1)*7),b.y=rt.getFullYear(),b.m=rt.getMonth(),b.d=rt.getDate()+(b.w+6)%7)}else("W"in b||"U"in b)&&("w"in b||(b.w="u"in b?b.u%7:"W"in b?1:0),Vt="Z"in b?$l(Ri(b.y,0,1)).getUTCDay():Yl(Ri(b.y,0,1)).getDay(),b.m=0,b.d="W"in b?(b.w+6)%7+b.W*7-(Vt+5)%7:b.w+b.U*7-(Vt+6)%7);return"Z"in b?(b.H+=b.Z/100|0,b.M+=b.Z%100,$l(b)):Yl(b)}}function z(k,Y,U,b){for(var jt=0,rt=Y.length,Vt=U.length,Zt,Sn;jt=Vt)return-1;if(Zt=Y.charCodeAt(jt++),Zt===37){if(Zt=Y.charAt(jt++),Sn=P[Zt in wd?Y.charAt(jt++):Zt],!Sn||(b=Sn(k,U,b))<0)return-1}else if(Zt!=U.charCodeAt(b++))return-1}return b}function tt(k,Y,U){var b=l.exec(Y.slice(U));return b?(k.p=f.get(b[0].toLowerCase()),U+b[0].length):-1}function V(k,Y,U){var b=m.exec(Y.slice(U));return b?(k.w=g.get(b[0].toLowerCase()),U+b[0].length):-1}function W(k,Y,U){var b=c.exec(Y.slice(U));return b?(k.w=h.get(b[0].toLowerCase()),U+b[0].length):-1}function v(k,Y,U){var b=_.exec(Y.slice(U));return b?(k.m=E.get(b[0].toLowerCase()),U+b[0].length):-1}function T(k,Y,U){var b=y.exec(Y.slice(U));return b?(k.m=M.get(b[0].toLowerCase()),U+b[0].length):-1}function d(k,Y,U){return z(k,e,Y,U)}function S(k,Y,U){return z(k,n,Y,U)}function x(k,Y,U){return z(k,r,Y,U)}function N(k){return a[k.getDay()]}function C(k){return o[k.getDay()]}function R(k){return u[k.getMonth()]}function L(k){return s[k.getMonth()]}function j(k){return i[+(k.getHours()>=12)]}function Z(k){return 1+~~(k.getMonth()/3)}function Pt(k){return a[k.getUTCDay()]}function ct(k){return o[k.getUTCDay()]}function ht(k){return u[k.getUTCMonth()]}function Rt(k){return s[k.getUTCMonth()]}function It(k){return i[+(k.getUTCHours()>=12)]}function Ht(k){return 1+~~(k.getUTCMonth()/3)}return{format:function(k){var Y=w(k+="",A);return Y.toString=function(){return k},Y},parse:function(k){var Y=q(k+="",!1);return Y.toString=function(){return k},Y},utcFormat:function(k){var Y=w(k+="",I);return Y.toString=function(){return k},Y},utcParse:function(k){var Y=q(k+="",!0);return Y.toString=function(){return k},Y}}}function B(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o[e.toLowerCase(),n]))}function Nw(t,e,n){var r=Tt.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function kw(t,e,n){var r=Tt.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Pw(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function qw(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Cw(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function bd(t,e,n){var r=Tt.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Md(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Lw(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Dw(t,e,n){var r=Tt.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Rw(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Td(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Hw(t,e,n){var r=Tt.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Sd(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Fw(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Yw(t,e,n){var r=Tt.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function $w(t,e,n){var r=Tt.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function zw(t,e,n){var r=Tt.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Uw(t,e,n){var r=Iw.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function jw(t,e,n){var r=Tt.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Bw(t,e,n){var r=Tt.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Ed(t,e){return B(t.getDate(),e,2)}function Xw(t,e){return B(t.getHours(),e,2)}function Gw(t,e){return B(t.getHours()%12||12,e,2)}function Ww(t,e){return B(1+We.count(Qt(t),t),e,3)}function kd(t,e){return B(t.getMilliseconds(),e,3)}function Vw(t,e){return kd(t,e)+"000"}function Zw(t,e){return B(t.getMonth()+1,e,2)}function Qw(t,e){return B(t.getMinutes(),e,2)}function Jw(t,e){return B(t.getSeconds(),e,2)}function Kw(t){var e=t.getDay();return e===0?7:e}function tb(t,e){return B(Ve.count(Qt(t)-1,t),e,2)}function Pd(t){var e=t.getDay();return e>=4||e===0?mn(t):mn.ceil(t)}function eb(t,e){return t=Pd(t),B(mn.count(Qt(t),t)+(Qt(t).getDay()===4),e,2)}function nb(t){return t.getDay()}function rb(t,e){return B(Or.count(Qt(t)-1,t),e,2)}function ib(t,e){return B(t.getFullYear()%100,e,2)}function ob(t,e){return t=Pd(t),B(t.getFullYear()%100,e,2)}function ab(t,e){return B(t.getFullYear()%1e4,e,4)}function sb(t,e){var n=t.getDay();return t=n>=4||n===0?mn(t):mn.ceil(t),B(t.getFullYear()%1e4,e,4)}function ub(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+B(e/60|0,"0",2)+B(e%60,"0",2)}function Id(t,e){return B(t.getUTCDate(),e,2)}function lb(t,e){return B(t.getUTCHours(),e,2)}function fb(t,e){return B(t.getUTCHours()%12||12,e,2)}function cb(t,e){return B(1+Bn.count(Jt(t),t),e,3)}function qd(t,e){return B(t.getUTCMilliseconds(),e,3)}function hb(t,e){return qd(t,e)+"000"}function pb(t,e){return B(t.getUTCMonth()+1,e,2)}function mb(t,e){return B(t.getUTCMinutes(),e,2)}function db(t,e){return B(t.getUTCSeconds(),e,2)}function gb(t){var e=t.getUTCDay();return e===0?7:e}function yb(t,e){return B(Ze.count(Jt(t)-1,t),e,2)}function Cd(t){var e=t.getUTCDay();return e>=4||e===0?dn(t):dn.ceil(t)}function _b(t,e){return t=Cd(t),B(dn.count(Jt(t),t)+(Jt(t).getUTCDay()===4),e,2)}function xb(t){return t.getUTCDay()}function vb(t,e){return B(Nr.count(Jt(t)-1,t),e,2)}function wb(t,e){return B(t.getUTCFullYear()%100,e,2)}function bb(t,e){return t=Cd(t),B(t.getUTCFullYear()%100,e,2)}function Mb(t,e){return B(t.getUTCFullYear()%1e4,e,4)}function Tb(t,e){var n=t.getUTCDay();return t=n>=4||n===0?dn(t):dn.ceil(t),B(t.getUTCFullYear()%1e4,e,4)}function Sb(){return"+0000"}function Ad(){return"%"}function Od(t){return+t}function Nd(t){return Math.floor(+t/1e3)}var wd,Tt,Iw,Aw,Ld=p(()=>{Qa();wd={"-":"",_:" ",0:"0"},Tt=/^\s*\d+/,Iw=/^%/,Aw=/[\\^$*+?|[\]().{}]/g});function Ul(t){return qr=zl(t),Ja=qr.format,Dd=qr.parse,Ka=qr.utcFormat,Rd=qr.utcParse,qr}var qr,Ja,Dd,Ka,Rd,Hd=p(()=>{Ld();Ul({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]})});var jl=p(()=>{Hd()});function Eb(t){return new Date(t)}function Ib(t){return t instanceof Date?+t:+new Date(+t)}function ts(t,e,n,r,i,o,a,s,u,l){var f=zn(),c=f.invert,h=f.domain,m=l(".%L"),g=l(":%S"),y=l("%I:%M"),M=l("%I %p"),_=l("%a %d"),E=l("%b %d"),A=l("%B"),I=l("%Y");function P(w){return(u(w){Qa();jl();He();Ct();El()});function Gl(){return ut.apply(ts(Dl,Rl,Jt,Pr,Ze,Bn,Ar,Er,fe,Ka).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}var Fd=p(()=>{Qa();jl();Xl();Ct()});function es(){var t=0,e=1,n,r,i,o,a=_t,s=!1,u;function l(c){return c==null||isNaN(c=+c)?u:a(i===0?.5:(c=(o(c)-n)*i,s?Math.max(0,Math.min(1,c)):c))}l.domain=function(c){return arguments.length?([t,e]=c,n=o(t=+t),r=o(e=+e),i=n===r?0:1/(r-n),l):[t,e]},l.clamp=function(c){return arguments.length?(s=!!c,l):s},l.interpolator=function(c){return arguments.length?(a=c,l):a};function f(c){return function(h){var m,g;return arguments.length?([m,g]=h,a=c(m,g),l):[a(0),a(1)]}}return l.range=f(Bt),l.rangeRound=f(hn),l.unknown=function(c){return arguments.length?(u=c,l):u},function(c){return o=c,n=c(t),r=c(e),i=n===r?0:1/(r-n),l}}function Qe(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function ns(){var t=Yt(es()(_t));return t.copy=function(){return Qe(t,ns())},ue.apply(t,arguments)}function Wl(){var t=ki(es()).domain([1,10]);return t.copy=function(){return Qe(t,Wl()).base(t.base())},ue.apply(t,arguments)}function Vl(){var t=Pi(es());return t.copy=function(){return Qe(t,Vl()).constant(t.constant())},ue.apply(t,arguments)}function rs(){var t=qi(es());return t.copy=function(){return Qe(t,rs()).exponent(t.exponent())},ue.apply(t,arguments)}function Yd(){return rs.apply(null,arguments).exponent(.5)}var Zl=p(()=>{Be();He();Ct();Xe();za();ja();Ba()});function is(){var t=[],e=_t;function n(r){if(r!=null&&!isNaN(r=+r))return e((Me(t,r,1)-1)/(t.length-1))}return n.domain=function(r){if(!arguments.length)return t.slice();t=[];for(let i of r)i!=null&&!isNaN(i=+i)&&t.push(i);return t.sort(Ft),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,o)=>pa(t,o/r))},n.copy=function(){return is(e).domain(t)},ue.apply(n,arguments)}var $d=p(()=>{se();He();Ct()});function os(){var t=0,e=.5,n=1,r=1,i,o,a,s,u,l=_t,f,c=!1,h;function m(y){return isNaN(y=+y)?h:(y=.5+((y=+f(y))-o)*(r*y{Be();He();Ct();Xe();za();Zl();ja();Ba()});var Kl={};rn(Kl,{scaleBand:()=>bi,scaleDiverging:()=>as,scaleDivergingLog:()=>Ql,scaleDivergingPow:()=>ss,scaleDivergingSqrt:()=>zd,scaleDivergingSymlog:()=>Jl,scaleIdentity:()=>Ya,scaleImplicit:()=>da,scaleLinear:()=>Fa,scaleLog:()=>$a,scaleOrdinal:()=>yr,scalePoint:()=>Cp,scalePow:()=>Ci,scaleQuantile:()=>Ga,scaleQuantize:()=>Wa,scaleRadial:()=>Xa,scaleSequential:()=>ns,scaleSequentialLog:()=>Wl,scaleSequentialPow:()=>rs,scaleSequentialQuantile:()=>is,scaleSequentialSqrt:()=>Yd,scaleSequentialSymlog:()=>Vl,scaleSqrt:()=>Km,scaleSymlog:()=>Ua,scaleThreshold:()=>Va,scaleTime:()=>Bl,scaleUtc:()=>Gl,tickFormat:()=>Oi});var tf=p(()=>{Lp();Xm();Xe();za();ja();el();Ba();ed();nd();rd();id();Xl();Fd();Zl();$d();Ud();Sl()});function jd(t){return t}var Bd=p(()=>{});function Ab(t){return"translate("+t+",0)"}function Ob(t){return"translate(0,"+t+")"}function Nb(t){return e=>+t(e)}function kb(t,e){return e=Math.max(0,t.bandwidth()-e*2)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function Pb(){return!this.__axis}function fs(t,e){var n=[],r=null,i=null,o=6,a=6,s=3,u=typeof window<"u"&&window.devicePixelRatio>1?0:.5,l=t===us||t===Yi?-1:1,f=t===Yi||t===ls?"x":"y",c=t===us||t===ef?Ab:Ob;function h(m){var g=r??(e.ticks?e.ticks.apply(e,n):e.domain()),y=i??(e.tickFormat?e.tickFormat.apply(e,n):jd),M=Math.max(o,0)+s,_=e.range(),E=+_[0]+u,A=+_[_.length-1]+u,I=(e.bandwidth?kb:Nb)(e.copy(),u),P=m.selection?m.selection():m,w=P.selectAll(".domain").data([null]),q=P.selectAll(".tick").data(g,e).order(),z=q.exit(),tt=q.enter().append("g").attr("class","tick"),V=q.select("line"),W=q.select("text");w=w.merge(w.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),q=q.merge(tt),V=V.merge(tt.append("line").attr("stroke","currentColor").attr(f+"2",l*o)),W=W.merge(tt.append("text").attr("fill","currentColor").attr(f,l*M).attr("dy",t===us?"0em":t===ef?"0.71em":"0.32em")),m!==P&&(w=w.transition(m),q=q.transition(m),V=V.transition(m),W=W.transition(m),z=z.transition(m).attr("opacity",Xd).attr("transform",function(v){return isFinite(v=I(v))?c(v+u):this.getAttribute("transform")}),tt.attr("opacity",Xd).attr("transform",function(v){var T=this.parentNode.__axis;return c((T&&isFinite(T=T(v))?T:I(v))+u)})),z.remove(),w.attr("d",t===Yi||t===ls?a?"M"+l*a+","+E+"H"+u+"V"+A+"H"+l*a:"M"+u+","+E+"V"+A:a?"M"+E+","+l*a+"V"+u+"H"+A+"V"+l*a:"M"+E+","+u+"H"+A),q.attr("opacity",1).attr("transform",function(v){return c(I(v)+u)}),V.attr(f+"2",l*o),W.attr(f,l*M).text(y),P.filter(Pb).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===ls?"start":t===Yi?"end":"middle"),P.each(function(){this.__axis=I})}return h.scale=function(m){return arguments.length?(e=m,h):e},h.ticks=function(){return n=Array.from(arguments),h},h.tickArguments=function(m){return arguments.length?(n=m==null?[]:Array.from(m),h):n.slice()},h.tickValues=function(m){return arguments.length?(r=m==null?null:Array.from(m),h):r&&r.slice()},h.tickFormat=function(m){return arguments.length?(i=m,h):i},h.tickSize=function(m){return arguments.length?(o=a=+m,h):o},h.tickSizeInner=function(m){return arguments.length?(o=+m,h):o},h.tickSizeOuter=function(m){return arguments.length?(a=+m,h):a},h.tickPadding=function(m){return arguments.length?(s=+m,h):s},h.offset=function(m){return arguments.length?(u=+m,h):u},h}function Gd(t){return fs(us,t)}function Wd(t){return fs(ls,t)}function Vd(t){return fs(ef,t)}function Zd(t){return fs(Yi,t)}var us,ls,ef,Yi,Xd,Qd=p(()=>{Bd();us=1,ls=2,ef=3,Yi=4,Xd=1e-6});var Jd={};rn(Jd,{axisBottom:()=>Vd,axisLeft:()=>Zd,axisRight:()=>Wd,axisTop:()=>Gd});var Kd=p(()=>{Qd()});function e0(){for(var t=0,e=arguments.length,n={},r;t=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}function Lb(t,e){for(var n=0,r=t.length,i;n{qb={value:()=>{}};cs.prototype=e0.prototype={constructor:cs,on:function(t,e){var n=this._,r=Cb(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o0)for(var n=new Array(i),r=0,i,o;r{n0()});var hs,zi,ps=p(()=>{hs="http://www.w3.org/1999/xhtml",zi={svg:"http://www.w3.org/2000/svg",xhtml:hs,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"}});function Ye(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),zi.hasOwnProperty(e)?{space:zi[e],local:t}:t}var ms=p(()=>{ps()});function Db(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===hs&&e.documentElement.namespaceURI===hs?e.createElement(t):e.createElementNS(n,t)}}function Rb(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function gn(t){var e=Ye(t);return(e.local?Rb:Db)(e)}var Ui=p(()=>{ms();ps()});function Hb(){}function yn(t){return t==null?Hb:function(){return this.querySelector(t)}}var ds=p(()=>{});function r0(t){typeof t!="function"&&(t=yn(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i{ce();ds()});function ji(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}var rf=p(()=>{});function Fb(){return[]}function Cr(t){return t==null?Fb:function(){return this.querySelectorAll(t)}}var of=p(()=>{});function Yb(t){return function(){return ji(t.apply(this,arguments))}}function o0(t){typeof t=="function"?t=Yb(t):t=Cr(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o{ce();rf();of()});function Lr(t){return function(){return this.matches(t)}}function gs(t){return function(e){return e.matches(t)}}var Bi=p(()=>{});function zb(t){return function(){return $b.call(this.children,t)}}function Ub(){return this.firstElementChild}function s0(t){return this.select(t==null?Ub:zb(typeof t=="function"?t:gs(t)))}var $b,u0=p(()=>{Bi();$b=Array.prototype.find});function Bb(){return Array.from(this.children)}function Xb(t){return function(){return jb.call(this.children,t)}}function l0(t){return this.selectAll(t==null?Bb:Xb(typeof t=="function"?t:gs(t)))}var jb,f0=p(()=>{Bi();jb=Array.prototype.filter});function c0(t){typeof t!="function"&&(t=Lr(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i{ce();Bi()});function ys(t){return new Array(t.length)}var af=p(()=>{});function p0(){return new ot(this._enter||this._groups.map(ys),this._parents)}function Xi(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}var sf=p(()=>{af();ce();Xi.prototype={constructor:Xi,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}}});function m0(t){return function(){return t}}var d0=p(()=>{});function Gb(t,e,n,r,i,o){for(var a=0,s,u=e.length,l=o.length;a=A&&(A=E+1);!(P=M[A])&&++A{ce();sf();d0()});function _0(){return new ot(this._exit||this._groups.map(ys),this._parents)}var x0=p(()=>{af();ce()});function v0(t,e,n){var r=this.enter(),i=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}var w0=p(()=>{});function b0(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,a=Math.min(i,o),s=new Array(i),u=0;u{ce()});function T0(){for(var t=this._groups,e=-1,n=t.length;++e=0;)(a=r[i])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}var S0=p(()=>{});function E0(t){t||(t=Qb);function e(c,h){return c&&h?t(c.__data__,h.__data__):!c-!h}for(var n=this._groups,r=n.length,i=new Array(r),o=0;oe?1:t>=e?0:NaN}var I0=p(()=>{ce()});function A0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}var O0=p(()=>{});function N0(){return Array.from(this)}var k0=p(()=>{});function P0(){for(var t=this._groups,e=0,n=t.length;e{});function C0(){let t=0;for(let e of this)++t;return t}var L0=p(()=>{});function D0(){return!this.node()}var R0=p(()=>{});function H0(t){for(var e=this._groups,n=0,r=e.length;n{});function Jb(t){return function(){this.removeAttribute(t)}}function Kb(t){return function(){this.removeAttributeNS(t.space,t.local)}}function tM(t,e){return function(){this.setAttribute(t,e)}}function eM(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function nM(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function rM(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Y0(t,e){var n=Ye(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?Kb:Jb:typeof e=="function"?n.local?rM:nM:n.local?eM:tM)(n,e))}var $0=p(()=>{ms()});function Dr(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}var _s=p(()=>{});function iM(t){return function(){this.style.removeProperty(t)}}function oM(t,e,n){return function(){this.style.setProperty(t,e,n)}}function aM(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function z0(t,e,n){return arguments.length>1?this.each((e==null?iM:typeof e=="function"?aM:oM)(t,e,n??"")):Je(this.node(),t)}function Je(t,e){return t.style.getPropertyValue(e)||Dr(t).getComputedStyle(t,null).getPropertyValue(e)}var uf=p(()=>{_s()});function sM(t){return function(){delete this[t]}}function uM(t,e){return function(){this[t]=e}}function lM(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function U0(t,e){return arguments.length>1?this.each((e==null?sM:typeof e=="function"?lM:uM)(t,e)):this.node()[t]}var j0=p(()=>{});function B0(t){return t.trim().split(/^|\s+/)}function lf(t){return t.classList||new X0(t)}function X0(t){this._node=t,this._names=B0(t.getAttribute("class")||"")}function G0(t,e){for(var n=lf(t),r=-1,i=e.length;++r{X0.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}}});function pM(){this.textContent=""}function mM(t){return function(){this.textContent=t}}function dM(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Q0(t){return arguments.length?this.each(t==null?pM:(typeof t=="function"?dM:mM)(t)):this.node().textContent}var J0=p(()=>{});function gM(){this.innerHTML=""}function yM(t){return function(){this.innerHTML=t}}function _M(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function K0(t){return arguments.length?this.each(t==null?gM:(typeof t=="function"?_M:yM)(t)):this.node().innerHTML}var tg=p(()=>{});function xM(){this.nextSibling&&this.parentNode.appendChild(this)}function eg(){return this.each(xM)}var ng=p(()=>{});function vM(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function rg(){return this.each(vM)}var ig=p(()=>{});function og(t){var e=typeof t=="function"?t:gn(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}var ag=p(()=>{Ui()});function wM(){return null}function sg(t,e){var n=typeof t=="function"?t:gn(t),r=e==null?wM:typeof e=="function"?e:yn(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}var ug=p(()=>{Ui();ds()});function bM(){var t=this.parentNode;t&&t.removeChild(this)}function lg(){return this.each(bM)}var fg=p(()=>{});function MM(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function TM(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function cg(t){return this.select(t?TM:MM)}var hg=p(()=>{});function pg(t){return arguments.length?this.property("__data__",t):this.node().__data__}var mg=p(()=>{});function SM(t){return function(e){t.call(this,e,this.__data__)}}function EM(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function IM(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,o;n{});function yg(t,e,n){var r=Dr(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function OM(t,e){return function(){return yg(this,t,e)}}function NM(t,e){return function(){return yg(this,t,e.apply(this,arguments))}}function _g(t,e){return this.each((typeof e=="function"?NM:OM)(t,e))}var xg=p(()=>{_s()});function*vg(){for(var t=this._groups,e=0,n=t.length;e{});function ot(t,e){this._groups=t,this._parents=e}function bg(){return new ot([[document.documentElement]],Gi)}function kM(){return this}var Gi,$e,ce=p(()=>{i0();a0();u0();f0();h0();y0();sf();x0();w0();M0();S0();I0();O0();k0();q0();L0();R0();F0();$0();uf();j0();Z0();J0();tg();ng();ig();ag();ug();fg();hg();mg();gg();xg();wg();Gi=[null];ot.prototype=bg.prototype={constructor:ot,select:r0,selectAll:o0,selectChild:s0,selectChildren:l0,filter:c0,data:g0,enter:p0,exit:_0,join:v0,merge:b0,selection:kM,order:T0,sort:E0,call:A0,nodes:N0,node:P0,size:C0,empty:D0,each:H0,attr:Y0,style:z0,property:U0,classed:V0,text:Q0,html:K0,raise:eg,lower:rg,append:og,insert:sg,remove:lg,clone:cg,datum:pg,on:dg,dispatch:_g,[Symbol.iterator]:vg};$e=bg});function Kt(t){return typeof t=="string"?new ot([[document.querySelector(t)]],[document.documentElement]):new ot([[t]],Gi)}var ff=p(()=>{ce()});function Mg(t){return Kt(gn(t).call(document.documentElement))}var Tg=p(()=>{Ui();ff()});function xs(){return new cf}function cf(){this._="@"+(++PM).toString(36)}var PM,Sg=p(()=>{PM=0;cf.prototype=xs.prototype={constructor:cf,get:function(t){for(var e=this._;!(e in t);)if(!(t=t.parentNode))return;return t[e]},set:function(t,e){return t[this._]=e},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}}});function vs(t){let e;for(;e=t.sourceEvent;)t=e;return t}var hf=p(()=>{});function he(t,e){if(t=vs(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}var pf=p(()=>{hf()});function Eg(t,e){return t.target&&(t=vs(t),e===void 0&&(e=t.currentTarget),t=t.touches||[t]),Array.from(t,n=>he(n,e))}var Ig=p(()=>{pf();hf()});function Ag(t){return typeof t=="string"?new ot([document.querySelectorAll(t)],[document.documentElement]):new ot([ji(t)],Gi)}var Og=p(()=>{rf();ce()});var pe={};rn(pe,{create:()=>Mg,creator:()=>gn,local:()=>xs,matcher:()=>Lr,namespace:()=>Ye,namespaces:()=>zi,pointer:()=>he,pointers:()=>Eg,select:()=>Kt,selectAll:()=>Ag,selection:()=>$e,selector:()=>yn,selectorAll:()=>Cr,style:()=>Je,window:()=>Dr});var pt=p(()=>{Tg();Ui();Sg();Bi();ms();ps();pf();Ig();ff();Og();ce();ds();of();uf();_s()});function bs(t){t.preventDefault(),t.stopImmediatePropagation()}var ws,Ng=p(()=>{ws={capture:!0,passive:!1}});function mf(t){var e=t.document.documentElement,n=Kt(t).on("dragstart.drag",bs,ws);"onselectstart"in e?n.on("selectstart.drag",bs,ws):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function df(t,e){var n=t.document.documentElement,r=Kt(t).on("dragstart.drag",null);e&&(r.on("click.drag",bs,ws),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var kg=p(()=>{pt();Ng()});var Pg=p(()=>{kg()});function Ki(){return Wn||(Lg(qM),Wn=Qi.now()+Ss)}function qM(){Wn=0}function Ji(){this._call=this._time=this._next=null}function Es(t,e,n){var r=new Ji;return r.restart(t,e,n),r}function Dg(){Ki(),++Rr;for(var t=Ms,e;t;)(e=Wn-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Rr}function qg(){Wn=(Ts=Qi.now())+Ss,Rr=Vi=0;try{Dg()}finally{Rr=0,LM(),Wn=0}}function CM(){var t=Qi.now(),e=t-Ts;e>Cg&&(Ss-=e,Ts=t)}function LM(){for(var t,e=Ms,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ms=n);Zi=t,gf(r)}function gf(t){if(!Rr){Vi&&(Vi=clearTimeout(Vi));var e=t-Wn;e>24?(t<1/0&&(Vi=setTimeout(qg,t-Qi.now()-Ss)),Wi&&(Wi=clearInterval(Wi))):(Wi||(Ts=Qi.now(),Wi=setInterval(CM,Cg)),Rr=1,Lg(qg))}}var Rr,Vi,Wi,Cg,Ms,Zi,Ts,Wn,Ss,Qi,Lg,yf=p(()=>{Rr=0,Vi=0,Wi=0,Cg=1e3,Ts=0,Wn=0,Ss=0,Qi=typeof performance=="object"&&performance.now?performance:Date,Lg=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};Ji.prototype=Es.prototype={constructor:Ji,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Ki():+n)+(e==null?0:+e),!this._next&&Zi!==this&&(Zi?Zi._next=this:Ms=this,Zi=this),this._call=t,this._time=n,gf()},stop:function(){this._call&&(this._call=null,this._time=1/0,gf())}}});function Is(t,e,n){var r=new Ji;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var Rg=p(()=>{yf()});var _f=p(()=>{yf();Rg()});function _n(t,e,n,r,i,o){var a=t.__transition;if(!a)t.__transition={};else if(n in a)return;HM(t,n,{name:e,index:r,group:i,on:DM,tween:RM,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Yg})}function eo(t,e){var n=xt(t,e);if(n.state>Yg)throw new Error("too late; already scheduled");return n}function Nt(t,e){var n=xt(t,e);if(n.state>As)throw new Error("too late; already running");return n}function xt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function HM(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=Es(o,0,n.time);function o(l){n.state=Hg,n.timer.restart(a,n.delay,n.time),n.delay<=l&&a(l-n.delay)}function a(l){var f,c,h,m;if(n.state!==Hg)return u();for(f in r)if(m=r[f],m.name===n.name){if(m.state===As)return Is(a);m.state===Fg?(m.state=to,m.timer.stop(),m.on.call("interrupt",t,t.__data__,m.index,m.group),delete r[f]):+f{nf();_f();DM=$i("start","end","cancel","interrupt"),RM=[],Yg=0,Hg=1,Os=2,As=3,Fg=4,Ns=5,to=6});function Vn(t,e){var n=t.__transition,r,i,o=!0,a;if(n){e=e==null?null:e+"";for(a in n){if((r=n[a]).name!==e){o=!1;continue}i=r.state>Os&&r.state{Xt()});function $g(t){return this.each(function(){Vn(this,t)})}var zg=p(()=>{xf()});function FM(t,e){var n,r;return function(){var i=Nt(this,t),o=i.tween;if(o!==n){r=n=o;for(var a=0,s=r.length;a{Xt()});function ks(t,e){var n;return(typeof e=="number"?Mt:e instanceof le?cn:(n=le(e))?(e=n,cn):Tr)(t,e)}var vf=p(()=>{Ee();Be()});function $M(t){return function(){this.removeAttribute(t)}}function zM(t){return function(){this.removeAttributeNS(t.space,t.local)}}function UM(t,e,n){var r,i=n+"",o;return function(){var a=this.getAttribute(t);return a===i?null:a===r?o:o=e(r=a,n)}}function jM(t,e,n){var r,i=n+"",o;return function(){var a=this.getAttributeNS(t.space,t.local);return a===i?null:a===r?o:o=e(r=a,n)}}function BM(t,e,n){var r,i,o;return function(){var a,s=n(this),u;return s==null?void this.removeAttribute(t):(a=this.getAttribute(t),u=s+"",a===u?null:a===r&&u===i?o:(i=u,o=e(r=a,s)))}}function XM(t,e,n){var r,i,o;return function(){var a,s=n(this),u;return s==null?void this.removeAttributeNS(t.space,t.local):(a=this.getAttributeNS(t.space,t.local),u=s+"",a===u?null:a===r&&u===i?o:(i=u,o=e(r=a,s)))}}function jg(t,e){var n=Ye(t),r=n==="transform"?Da:ks;return this.attrTween(t,typeof e=="function"?(n.local?XM:BM)(n,r,Hr(this,"attr."+t,e)):e==null?(n.local?zM:$M)(n):(n.local?jM:UM)(n,r,e))}var Bg=p(()=>{Be();pt();no();vf()});function GM(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function WM(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function VM(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&WM(t,o)),n}return i._value=e,i}function ZM(t,e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&GM(t,o)),n}return i._value=e,i}function Xg(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Ye(t);return this.tween(n,(r.local?VM:ZM)(r,e))}var Gg=p(()=>{pt()});function QM(t,e){return function(){eo(this,t).delay=+e.apply(this,arguments)}}function JM(t,e){return e=+e,function(){eo(this,t).delay=e}}function Wg(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?QM:JM)(e,t)):xt(this.node(),e).delay}var Vg=p(()=>{Xt()});function KM(t,e){return function(){Nt(this,t).duration=+e.apply(this,arguments)}}function t2(t,e){return e=+e,function(){Nt(this,t).duration=e}}function Zg(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?KM:t2)(e,t)):xt(this.node(),e).duration}var Qg=p(()=>{Xt()});function e2(t,e){if(typeof e!="function")throw new Error;return function(){Nt(this,t).ease=e}}function Jg(t){var e=this._id;return arguments.length?this.each(e2(e,t)):xt(this.node(),e).ease}var Kg=p(()=>{Xt()});function n2(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Nt(this,t).ease=n}}function ty(t){if(typeof t!="function")throw new Error;return this.each(n2(this._id,t))}var ey=p(()=>{Xt()});function ny(t){typeof t!="function"&&(t=Lr(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i{pt();Zn()});function iy(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),a=new Array(r),s=0;s{Zn()});function r2(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function i2(t,e,n){var r,i,o=r2(e)?eo:Nt;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}function ay(t,e){var n=this._id;return arguments.length<2?xt(this.node(),n).on.on(t):this.each(i2(n,t,e))}var sy=p(()=>{Xt()});function o2(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function uy(){return this.on("end.remove",o2(this._id))}var ly=p(()=>{});function fy(t){var e=this._name,n=this._id;typeof t!="function"&&(t=yn(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a{pt();Zn();Xt()});function hy(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Cr(t));for(var r=this._groups,i=r.length,o=[],a=[],s=0;s{pt();Zn();Xt()});function my(){return new a2(this._groups,this._parents)}var a2,dy=p(()=>{pt();a2=$e.prototype.constructor});function s2(t,e){var n,r,i;return function(){var o=Je(this,t),a=(this.style.removeProperty(t),Je(this,t));return o===a?null:o===n&&a===r?i:i=e(n=o,r=a)}}function gy(t){return function(){this.style.removeProperty(t)}}function u2(t,e,n){var r,i=n+"",o;return function(){var a=Je(this,t);return a===i?null:a===r?o:o=e(r=a,n)}}function l2(t,e,n){var r,i,o;return function(){var a=Je(this,t),s=n(this),u=s+"";return s==null&&(u=s=(this.style.removeProperty(t),Je(this,t))),a===u?null:a===r&&u===i?o:(i=u,o=e(r=a,s))}}function f2(t,e){var n,r,i,o="style."+e,a="end."+o,s;return function(){var u=Nt(this,t),l=u.on,f=u.value[o]==null?s||(s=gy(e)):void 0;(l!==n||i!==f)&&(r=(n=l).copy()).on(a,i=f),u.on=r}}function yy(t,e,n){var r=(t+="")=="transform"?La:ks;return e==null?this.styleTween(t,s2(t,r)).on("end.style."+t,gy(t)):typeof e=="function"?this.styleTween(t,l2(t,r,Hr(this,"style."+t,e))).each(f2(this._id,t)):this.styleTween(t,u2(t,r,e),n).on("end.style."+t,null)}var _y=p(()=>{Be();pt();Xt();no();vf()});function c2(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function h2(t,e,n){var r,i;function o(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&c2(t,a,n)),r}return o._value=e,o}function xy(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,h2(t,e,n??""))}var vy=p(()=>{});function p2(t){return function(){this.textContent=t}}function m2(t){return function(){var e=t(this);this.textContent=e??""}}function wy(t){return this.tween("text",typeof t=="function"?m2(Hr(this,"text",t)):p2(t==null?"":t+""))}var by=p(()=>{no()});function d2(t){return function(e){this.textContent=t.call(this,e)}}function g2(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&d2(i)),e}return r._value=t,r}function My(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,g2(t))}var Ty=p(()=>{});function Sy(){for(var t=this._name,e=this._id,n=Ps(),r=this._groups,i=r.length,o=0;o{Zn();Xt()});function Iy(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,a){var s={value:a},u={value:function(){--i===0&&o()}};n.each(function(){var l=Nt(this,r),f=l.on;f!==t&&(e=(t=f).copy(),e._.cancel.push(s),e._.interrupt.push(s),e._.end.push(u)),l.on=e}),i===0&&o()})}var Ay=p(()=>{Xt()});function $t(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Oy(t){return $e().transition(t)}function Ps(){return++y2}var y2,Ke,Zn=p(()=>{pt();Bg();Gg();Vg();Qg();Kg();ey();ry();oy();sy();ly();cy();py();dy();_y();vy();by();Ty();Ey();no();Ay();y2=0;Ke=$e.prototype;$t.prototype=Oy.prototype={constructor:$t,select:fy,selectAll:hy,selectChild:Ke.selectChild,selectChildren:Ke.selectChildren,filter:ny,merge:iy,selection:my,transition:Sy,call:Ke.call,nodes:Ke.nodes,node:Ke.node,size:Ke.size,empty:Ke.empty,each:Ke.each,on:ay,attr:jg,attrTween:Xg,style:yy,styleTween:xy,text:wy,textTween:My,remove:uy,tween:Ug,delay:Wg,duration:Zg,ease:Jg,easeVarying:ty,end:Iy,[Symbol.iterator]:Ke[Symbol.iterator]}});function qs(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var Ny=p(()=>{});var ky=p(()=>{Ny()});function x2(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function Py(t){var e,n;t instanceof $t?(e=t._id,t=t._name):(e=Ps(),(n=_2).time=Ki(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,o=0;o{Zn();Xt();ky();_f();_2={time:null,delay:0,duration:250,ease:qs}});var Cy=p(()=>{pt();zg();qy();$e.prototype.interrupt=$g;$e.prototype.transition=Py});var Ly=p(()=>{Cy();xf()});var ro,Dy=p(()=>{ro=t=>()=>t});function wf(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}var Ry=p(()=>{});function me(t,e,n){this.k=t,this.x=e,this.y=n}function Cs(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Fr;return t.__zoom}var Fr,bf=p(()=>{me.prototype={constructor:me,scale:function(t){return t===1?this:new me(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new me(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};Fr=new me(1,0,0);Cs.prototype=me.prototype});function Ls(t){t.stopImmediatePropagation()}function Yr(t){t.preventDefault(),t.stopImmediatePropagation()}var Hy=p(()=>{});function v2(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function w2(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Fy(){return this.__zoom||Fr}function b2(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function M2(){return navigator.maxTouchPoints||"ontouchstart"in this}function T2(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function Yy(){var t=v2,e=w2,n=T2,r=b2,i=M2,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],s=250,u=Ra,l=$i("start","zoom","end"),f,c,h,m=500,g=150,y=0,M=10;function _(d){d.property("__zoom",Fy).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",tt).on("dblclick.zoom",V).filter(i).on("touchstart.zoom",W).on("touchmove.zoom",v).on("touchend.zoom touchcancel.zoom",T).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(d,S,x,N){var C=d.selection?d.selection():d;C.property("__zoom",Fy),d!==C?P(d,S,x,N):C.interrupt().each(function(){w(this,arguments).event(N).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},_.scaleBy=function(d,S,x,N){_.scaleTo(d,function(){var C=this.__zoom.k,R=typeof S=="function"?S.apply(this,arguments):S;return C*R},x,N)},_.scaleTo=function(d,S,x,N){_.transform(d,function(){var C=e.apply(this,arguments),R=this.__zoom,L=x==null?I(C):typeof x=="function"?x.apply(this,arguments):x,j=R.invert(L),Z=typeof S=="function"?S.apply(this,arguments):S;return n(A(E(R,Z),L,j),C,a)},x,N)},_.translateBy=function(d,S,x,N){_.transform(d,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof x=="function"?x.apply(this,arguments):x),e.apply(this,arguments),a)},null,N)},_.translateTo=function(d,S,x,N,C){_.transform(d,function(){var R=e.apply(this,arguments),L=this.__zoom,j=N==null?I(R):typeof N=="function"?N.apply(this,arguments):N;return n(Fr.translate(j[0],j[1]).scale(L.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof x=="function"?-x.apply(this,arguments):-x),R,a)},N,C)};function E(d,S){return S=Math.max(o[0],Math.min(o[1],S)),S===d.k?d:new me(S,d.x,d.y)}function A(d,S,x){var N=S[0]-x[0]*d.k,C=S[1]-x[1]*d.k;return N===d.x&&C===d.y?d:new me(d.k,N,C)}function I(d){return[(+d[0][0]+ +d[1][0])/2,(+d[0][1]+ +d[1][1])/2]}function P(d,S,x,N){d.on("start.zoom",function(){w(this,arguments).event(N).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event(N).end()}).tween("zoom",function(){var C=this,R=arguments,L=w(C,R).event(N),j=e.apply(C,R),Z=x==null?I(j):typeof x=="function"?x.apply(C,R):x,Pt=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),ct=C.__zoom,ht=typeof S=="function"?S.apply(C,R):S,Rt=u(ct.invert(Z).concat(Pt/ct.k),ht.invert(Z).concat(Pt/ht.k));return function(It){if(It===1)It=ht;else{var Ht=Rt(It),k=Pt/Ht[2];It=new me(k,Z[0]-Ht[0]*k,Z[1]-Ht[1]*k)}L.zoom(null,It)}})}function w(d,S,x){return!x&&d.__zooming||new q(d,S)}function q(d,S){this.that=d,this.args=S,this.active=0,this.sourceEvent=null,this.extent=e.apply(d,S),this.taps=0}q.prototype={event:function(d){return d&&(this.sourceEvent=d),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(d,S){return this.mouse&&d!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&d!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&d!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(d){var S=Kt(this.that).datum();l.call(d,this.that,new wf(d,{sourceEvent:this.sourceEvent,target:_,type:d,transform:this.that.__zoom,dispatch:l}),S)}};function z(d,...S){if(!t.apply(this,arguments))return;var x=w(this,S).event(d),N=this.__zoom,C=Math.max(o[0],Math.min(o[1],N.k*Math.pow(2,r.apply(this,arguments)))),R=he(d);if(x.wheel)(x.mouse[0][0]!==R[0]||x.mouse[0][1]!==R[1])&&(x.mouse[1]=N.invert(x.mouse[0]=R)),clearTimeout(x.wheel);else{if(N.k===C)return;x.mouse=[R,N.invert(R)],Vn(this),x.start()}Yr(d),x.wheel=setTimeout(L,g),x.zoom("mouse",n(A(E(N,C),x.mouse[0],x.mouse[1]),x.extent,a));function L(){x.wheel=null,x.end()}}function tt(d,...S){if(h||!t.apply(this,arguments))return;var x=d.currentTarget,N=w(this,S,!0).event(d),C=Kt(d.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",Pt,!0),R=he(d,x),L=d.clientX,j=d.clientY;mf(d.view),Ls(d),N.mouse=[R,this.__zoom.invert(R)],Vn(this),N.start();function Z(ct){if(Yr(ct),!N.moved){var ht=ct.clientX-L,Rt=ct.clientY-j;N.moved=ht*ht+Rt*Rt>y}N.event(ct).zoom("mouse",n(A(N.that.__zoom,N.mouse[0]=he(ct,x),N.mouse[1]),N.extent,a))}function Pt(ct){C.on("mousemove.zoom mouseup.zoom",null),df(ct.view,N.moved),Yr(ct),N.event(ct).end()}}function V(d,...S){if(t.apply(this,arguments)){var x=this.__zoom,N=he(d.changedTouches?d.changedTouches[0]:d,this),C=x.invert(N),R=x.k*(d.shiftKey?.5:2),L=n(A(E(x,R),N,C),e.apply(this,S),a);Yr(d),s>0?Kt(this).transition().duration(s).call(P,L,N,d):Kt(this).call(_.transform,L,N,d)}}function W(d,...S){if(t.apply(this,arguments)){var x=d.touches,N=x.length,C=w(this,S,d.changedTouches.length===N).event(d),R,L,j,Z;for(Ls(d),L=0;L{nf();Pg();Be();pt();Ly();Dy();Ry();bf();Hy()});var zy={};rn(zy,{ZoomTransform:()=>me,zoom:()=>Yy,zoomIdentity:()=>Fr,zoomTransform:()=>Cs});var Uy=p(()=>{$y();bf()});var t_=O((jF,Mf)=>{"use strict";var $r=typeof Reflect=="object"?Reflect:null,jy=$r&&typeof $r.apply=="function"?$r.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},Ds;$r&&typeof $r.ownKeys=="function"?Ds=$r.ownKeys:Object.getOwnPropertySymbols?Ds=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ds=function(e){return Object.getOwnPropertyNames(e)};function S2(t){console&&console.warn&&console.warn(t)}var Xy=Number.isNaN||function(e){return e!==e};function Q(){Q.init.call(this)}Mf.exports=Q;Mf.exports.once=O2;Q.EventEmitter=Q;Q.prototype._events=void 0;Q.prototype._eventsCount=0;Q.prototype._maxListeners=void 0;var By=10;function Rs(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Q,"defaultMaxListeners",{enumerable:!0,get:function(){return By},set:function(t){if(typeof t!="number"||t<0||Xy(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");By=t}});Q.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Q.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Xy(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Gy(t){return t._maxListeners===void 0?Q.defaultMaxListeners:t._maxListeners}Q.prototype.getMaxListeners=function(){return Gy(this)};Q.prototype.emit=function(e){for(var n=[],r=1;r0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")jy(u,this,n);else for(var l=u.length,f=Jy(u,l),r=0;r0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,S2(s)}return t}Q.prototype.addListener=function(e,n){return Wy(this,e,n,!1)};Q.prototype.on=Q.prototype.addListener;Q.prototype.prependListener=function(e,n){return Wy(this,e,n,!0)};function E2(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Vy(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=E2.bind(r);return i.listener=n,r.wrapFn=i,i}Q.prototype.once=function(e,n){return Rs(n),this.on(e,Vy(this,e,n)),this};Q.prototype.prependOnceListener=function(e,n){return Rs(n),this.prependListener(e,Vy(this,e,n)),this};Q.prototype.removeListener=function(e,n){var r,i,o,a,s;if(Rs(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():I2(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};Q.prototype.off=Q.prototype.removeListener;Q.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i=0;i--)this.removeListener(e,n[i]);return this};function Zy(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?A2(i):Jy(i,i.length)}Q.prototype.listeners=function(e){return Zy(this,e,!0)};Q.prototype.rawListeners=function(e){return Zy(this,e,!1)};Q.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Qy.call(t,e)};Q.prototype.listenerCount=Qy;function Qy(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}Q.prototype.eventNames=function(){return this._eventsCount>0?Ds(this._events):[]};function Jy(t,e){for(var n=new Array(e),r=0;r{"use strict";Object.defineProperty(Tf,"__esModule",{value:!0});var k2=(ci(),it(fi)),P2=(pt(),it(pe));function q2(t){let e=t.owner.meta.xScale,n=t.owner.meta.yScale,r=(0,k2.line)().x(function(i){return i[0]}).y(function(i){return i[1]});return function(i){i.each(function(){let a=(0,P2.select)(this).selectAll("g.annotations").data(function(g){return g.annotations||[]}),s=a.enter().append("g").attr("class","annotations"),u=n.range(),l=e.range(),f=a.merge(s).selectAll("path").data(function(g){return"x"in g?[[[0,u[0]],[0,u[1]]]]:[[[l[0],0],[l[1],0]]]}),c=f.enter().append("path");f.merge(c).attr("stroke","#eee").attr("d",r),f.exit().remove();let h=a.merge(s).selectAll("text").data(function(g){return[{text:g.text||"",hasX:"x"in g}]}),m=h.enter().append("text");h.merge(m).text(function(g){return g.text}).attr("y",function(g){return g.hasX?3:0}).attr("x",function(g){return g.hasX?0:3}).attr("dy",function(g){return g.hasX?5:-5}).attr("text-anchor",function(g){return g.hasX?"end":""}).attr("transform",function(g){return g.hasX?"rotate(-90)":""}),h.exit().remove(),a.merge(s).attr("transform",function(g){return"x"in g?"translate("+e(g.x)+", 0)":"translate(0, "+n(g.y)+")"}),a.exit().remove()})}}Tf.default=q2});var zr=O(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.registerGraphType=void 0;var C2=(Ee(),it(Sa)),io={COLORS:["steelblue","red","#05b378","orange","#4040e8","yellow","brown","magenta","cyan"].map(function(t){return(0,C2.hsl)(t)}),DEFAULT_WIDTH:550,DEFAULT_HEIGHT:350,DEFAULT_ITERATIONS:null,TIP_X_EPS:1,MAX_ITERATIONS:0,graphTypes:{}};io.MAX_ITERATIONS=io.DEFAULT_WIDTH*10;function L2(t,e){if(Object.hasOwn(io.graphTypes,t))throw new Error(`registerGraphType: graphType ${t} is already registered.`);io.graphTypes[t]=e}oo.registerGraphType=L2;oo.default=io});var ze=O(ao=>{"use strict";var D2=ao&&ao.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ao,"__esModule",{value:!0});var n_=D2(zr()),R2={linspace:function(t,e,n){let r=(e-t)/(n-1);return Array.from({length:n},(i,o)=>t+r*o)},logspace:function(t,e,n){return this.linspace(t,e,n).map(r=>Math.pow(10,r))},isValidNumber:function(t){return typeof t=="number"&&!isNaN(t)},space:function(t,e,n){let r=e[0],i=e[1];return t.type==="log"?this.logspace(Math.log10(r),Math.log10(i),n):this.linspace(r,i,n)},getterSetter:function(t,e){let n=this;this[e]=function(r){return arguments.length?(t[e]=r,n):t[e]}},sgn:function(t){return t<0?-1:t>0?1:0},clamp:function(t,e,n){return tn?n:t},color:function(t,e){let n=e%n_.default.COLORS.length;return t.color||n_.default.COLORS[n].hex()},infinity:function(){return 9007199254740991}};ao.default=R2});var Sf=O((WF,r_)=>{r_.exports={EOF:0,DELIMITER:1,NUMBER:2,STRING:3,SYMBOL:4}});var If=O((VF,o_)=>{var Qn=Sf(),H2={n:` +`,f:"\f",r:"\r",t:" ",v:"\v","'":"'",'"':'"'},F2={",":!0,"(":!0,")":!0,"[":!0,"]":!0,";":!0,"~":!0,"!":!0,"+":!0,"-":!0,"*":!0,"/":!0,"%":!0,"^":!0,"**":!0,"|":!0,"&":!0,"^|":!0,"=":!0,":":!0,"?":!0,"||":!0,"&&":!0,xor:!0,"==":!0,"!=":!0,"===":!0,"!==":!0,"<":!0,">":!0,">=":!0,"<=":!0,">>>":!0,"<<":!0,">>":!0};function tn(t){return t>="0"&&t<="9"}function i_(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="$"||t==="_"}function Y2(t){return t===" "||t==="\r"||t===" "||t===` +`||t==="\v"||t==="\xA0"}function Ef(t){return F2[t]}function $2(t){return t==="'"||t==='"'}function xn(){}xn.prototype.throwError=function(t,e){e=typeof e>"u"?this.index:e;var n=new Error(t+" at index "+e);throw n.index=e,n.description=t,n};xn.prototype.lex=function(t){for(this.text=t,this.index=0,this.tokens=[];this.index=this.text.length))return this.text.charAt(this.index+t)};xn.prototype.consume=function(){var t=this.peek();return this.index+=1,t};xn.prototype.readNumber=function(){var t="";if(this.peek()===".")t+=this.consume(),tn(this.peek())||this.throwError("number expected");else{for(;tn(this.peek());)t+=this.consume();this.peek()==="."&&(t+=this.consume())}for(;tn(this.peek());)t+=this.consume();if(this.peek()==="e"||this.peek()==="E")for(t+=this.consume(),tn(this.peek())||this.peek()==="+"||this.peek()==="-"||this.throwError(),(this.peek()==="+"||this.peek()==="-")&&(t+=this.consume()),tn(this.peek())||this.throwError("number expected");tn(this.peek());)t+=this.consume();return t};xn.prototype.readIdentifier=function(){for(var t="";i_(this.peek())||tn(this.peek());)t+=this.consume();return t};xn.prototype.readString=function(){for(var t=this.consume(),e="",n;;){var r=this.consume();if(r||this.throwError("string is not closed"),n){if(r==="u"){var i=this.text.substring(this.index+1,this.index+5);i.match(/[\da-f]{4}/i)||this.throwError("invalid unicode escape"),this.index+=4,e+=String.fromCharCode(parseInt(i,16))}else{var o=H2[r];o?e+=o:e+=r}n=!1}else{if(r===t)break;r==="\\"?n=!0:e+=r}}return e};o_.exports=xn});var Ie=O((ZF,s_)=>{function a_(){}a_.prototype.type="Node";s_.exports=a_});var Of=O((QF,u_)=>{var z2=Ie(),U2={number:!0,string:!0,boolean:!0,undefined:!0,null:!0};function Af(t,e){if(!U2[e])throw Error("unsupported type '"+e+"'");this.value=t,this.valueType=e}Af.prototype=Object.create(z2.prototype);Af.prototype.type="ConstantNode";u_.exports=Af});var kf=O((JF,l_)=>{var j2=Ie();function Nf(t,e){this.op=t,this.args=e||[]}Nf.prototype=Object.create(j2.prototype);Nf.prototype.type="OperatorNode";l_.exports=Nf});var qf=O((KF,f_)=>{var B2=Ie();function Pf(t,e){this.op=t,this.argument=e}Pf.prototype=Object.create(B2.prototype);Pf.prototype.type="UnaryNode";f_.exports=Pf});var Lf=O((tY,c_)=>{var X2=Ie();function Cf(t){this.name=t}Cf.prototype=Object.create(X2.prototype);Cf.prototype.type="SymbolNode";c_.exports=Cf});var Rf=O((eY,h_)=>{var G2=Ie();function Df(t,e){this.name=t,this.args=e}Df.prototype=Object.create(G2.prototype);Df.prototype.type="FunctionNode";h_.exports=Df});var Ff=O((nY,p_)=>{var W2=Ie();function Hf(t){this.nodes=t}Hf.prototype=Object.create(W2.prototype);Hf.prototype.type="ArrayNode";p_.exports=Hf});var $f=O((rY,m_)=>{var V2=Ie();function Yf(t,e,n){this.condition=t,this.trueExpr=e,this.falseExpr=n}Yf.prototype=Object.create(V2.prototype);Yf.prototype.type="ConditionalNode";m_.exports=Yf});var Uf=O((iY,d_)=>{var Z2=Ie();function zf(t,e){this.name=t,this.expr=e}zf.prototype=Object.create(Z2.prototype);zf.prototype.type="AssignmentNode";d_.exports=zf});var Bf=O((oY,g_)=>{var Q2=Ie();function jf(t){this.blocks=t}jf.prototype=Object.create(Q2.prototype);jf.prototype.type="BlockNode";g_.exports=jf});var x_=O((aY,__)=>{var Jn=Sf(),J2=If(),Xf=Of(),te=kf(),K2=qf(),y_=Lf(),tT=Rf(),eT=Ff(),nT=$f(),rT=Uf(),iT=Bf();function G(){this.lexer=new J2,this.tokens=null}G.prototype.current=function(){return this.tokens[0]};G.prototype.next=function(){return this.tokens[1]};G.prototype.peek=function(){if(this.tokens.length){for(var t=this.tokens[0],e=0;e=","<=",">","<")){var e=this.consume(),n=this.shift();return new te(e.value,[t,n])}return t};G.prototype.shift=function(){var t=this.additive();if(this.peek(">>","<<",">>>")){var e=this.consume(),n=this.shift();return new te(e.value,[t,n])}return t};G.prototype.additive=function(){for(var t=this.multiplicative();this.peek("+","-");){var e=this.consume();t=new te(e.value,[t,this.multiplicative()])}return t};G.prototype.multiplicative=function(){for(var t,e,n=this.unary();this.peek("*","/","%");)t=this.consume(),n=new te(t.value,[n,this.unary()]);return this.current().type===Jn.SYMBOL||this.peek("(")||!(n.type instanceof Xf)&&this.current().type===Jn.NUMBER?(e=this.multiplicative(),new te("*",[n,e])):n};G.prototype.unary=function(){if(this.peek("-","+","~")){var t=this.consume(),e=this.unary();return new K2(t.value,e)}return this.pow()};G.prototype.pow=function(){var t=this.factorial();if(this.peek("^","**")){var e=this.consume(),n=this.unary();return new te(e.value,[t,n])}return t};G.prototype.factorial=function(){var t=this.symbol();if(this.peek("!")){var e=this.consume();return new te(e.value,[t])}return t};G.prototype.symbol=function(){var t=this.current();if(t.type===Jn.SYMBOL){var e=this.consume(),n=this.functionCall(e);return n}return this.string()};G.prototype.functionCall=function(t){var e=t.value;if(this.peek("(")){this.consume();for(var n=[];!this.peek(")")&&!this.isEOF();)n.push(this.assignment()),this.peek(",")&&this.consume();return this.expect(")"),new tT(e,n)}return new y_(e)};G.prototype.string=function(){return this.current().type===Jn.STRING?new Xf(this.consume().value,"string"):this.array()};G.prototype.array=function(){if(this.peek("[")){this.consume();for(var t=[];!this.peek("]")&&!this.isEOF();)t.push(this.assignment()),this.peek(",")&&this.consume();return this.expect("]"),new eT(t)}return this.number()};G.prototype.number=function(){var t=this.current();return t.type===Jn.NUMBER?new Xf(this.consume().value,"number"):this.parentheses()};G.prototype.parentheses=function(){var t=this.current();if(t.value==="("){this.consume();var e=this.assignment();return this.expect(")"),e}return this.end()};G.prototype.end=function(){var t=this.current();if(t.type!==Jn.EOF)throw Error("unexpected end of expression")};__.exports=G});var w_=O((sY,v_)=>{v_.exports={ArrayNode:Ff(),AssignmentNode:Uf(),BlockNode:Bf(),ConditionalNode:$f(),ConstantNode:Of(),FunctionNode:Rf(),Node:Ie(),OperatorNode:kf(),SymbolNode:Lf(),UnaryNode:qf()}});var Gf=O((uY,Hs)=>{"use strict";Hs.exports.Lexer=If();Hs.exports.Parser=x_();Hs.exports.nodeTypes=w_()});var Wf=O((lY,O_)=>{"use strict";var Fs=Object.prototype.hasOwnProperty,A_=Object.prototype.toString,b_=Object.defineProperty,M_=Object.getOwnPropertyDescriptor,T_=function(e){return typeof Array.isArray=="function"?Array.isArray(e):A_.call(e)==="[object Array]"},S_=function(e){if(!e||A_.call(e)!=="[object Object]")return!1;var n=Fs.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&Fs.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!r)return!1;var i;for(i in e);return typeof i>"u"||Fs.call(e,i)},E_=function(e,n){b_&&n.name==="__proto__"?b_(e,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):e[n.name]=n.newValue},I_=function(e,n){if(n==="__proto__")if(Fs.call(e,n)){if(M_)return M_(e,n).value}else return;return e[n]};O_.exports=function t(){var e,n,r,i,o,a,s=arguments[0],u=1,l=arguments.length,f=!1;for(typeof s=="boolean"&&(f=s,s=arguments[1]||{},u=2),(s==null||typeof s!="object"&&typeof s!="function")&&(s={});u{"use strict";N_.exports=function(t){let e=this,n=[];this.rawify(this.options.rawArrayExpressionElements,function(){n=t.nodes.map(function(i){return e.next(i)})});let r="["+n.join(",")+"]";return this.options.raw?r:this.options.factory+"("+r+")"}});var q_=O((cY,P_)=>{"use strict";P_.exports=function(t){return"scope["+JSON.stringify(t.name)+"] = "+this.next(t.expr)}});var L_=O((hY,C_)=>{"use strict";C_.exports=function(t){let e="!!("+this.next(t.condition)+")",n=this.next(t.trueExpr),r=this.next(t.falseExpr);return"("+e+" ? ("+n+") : ("+r+") )"}});var R_=O((pY,D_)=>{"use strict";D_.exports=function(t){if(this.options.raw)return t.value;let e=t.valueType==="string"?JSON.stringify(t.value):t.value;return this.options.factory+"("+e+")"}});var F_=O((mY,Vf)=>{"use strict";var oT=Gf().nodeTypes.SymbolNode,H_=function(t){return"$$mathCodegen.functionProxy("+this.next(new oT(t.name))+", "+JSON.stringify(t.name)+")"};Vf.exports=function(t){let e=this,n=H_.call(this,t),r=[];return this.rawify(this.options.rawCallExpressionElements,function(){r=t.args.map(function(i){return e.next(i)})}),n+"("+r.join(", ")+")"};Vf.exports.functionProxy=H_});var $_=O((dY,Y_)=>{"use strict";Y_.exports={"+":"add","-":"sub","*":"mul","/":"div","^":"pow","%":"mod","!":"factorial","|":"bitwiseOR","^|":"bitwiseXOR","&":"bitwiseAND","||":"logicalOR",xor:"logicalXOR","&&":"logicalAND","<":"lessThan",">":"greaterThan","<=":"lessEqualThan",">=":"greaterEqualThan","===":"strictlyEqual","==":"equal","!==":"strictlyNotEqual","!=":"notEqual",">>":"shiftRight","<<":"shiftLeft",">>>":"unsignedRightShift"}});var U_=O((gY,z_)=>{"use strict";var aT=$_();z_.exports=function(t){if(this.options.raw)return["("+this.next(t.args[0]),t.op,this.next(t.args[1])+")"].join(" ");let e=aT[t.op];if(!e)throw TypeError("unidentified operator");return this.FunctionNode({name:e,args:t.args})}});var B_=O((yY,j_)=>{"use strict";j_.exports=function(t){let e=t.name;return"$$mathCodegen.getProperty("+JSON.stringify(e)+", scope, ns)"}});var G_=O((_Y,X_)=>{"use strict";X_.exports={"+":"positive","-":"negative","~":"oneComplement"}});var Z_=O((xY,V_)=>{"use strict";var W_=G_();V_.exports=function(t){if(this.options.raw)return t.op+this.next(t.argument);if(!(t.op in W_))throw new SyntaxError(t.op+" not implemented");let e=W_[t.op];return this.FunctionNode({name:e,args:[t.argument]})}});var K_=O((vY,J_)=>{"use strict";var Q_=Wf(),sT={ArrayNode:k_(),AssignmentNode:q_(),ConditionalNode:L_(),ConstantNode:R_(),FunctionNode:F_(),OperatorNode:U_(),SymbolNode:B_(),UnaryNode:Z_()},Ys=function(t,e){this.owner=t,this.options=Q_({factory:"ns.factory",raw:!1,rawArrayExpressionElements:!0,rawCallExpressionElements:!1,applyFactoryToScope:!1},e);let n=this.options.factory;if(typeof n!="string"||!/^[a-zA-Z_$][a-zA-Z0-9_$]*(\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$/.test(n))throw new Error('factory must be a valid JS property access path (e.g. "ns.factory")')};Q_(Ys.prototype,sT);Ys.prototype.next=function(t){if(!(t.type in this))throw new TypeError("the node type "+t.type+" is not implemented");return this[t.type](t)};Ys.prototype.rawify=function(t,e){let n=this.options.raw;t&&(this.options.raw=!0),e(),t&&(this.options.raw=n)};J_.exports=Ys});var ex=O((wY,tx)=>{"use strict";var uT=Gf().Parser,lT=K_(),fT=Wf();function $s(t,e){this.statements=[],this.defs=e||{},this.interpreter=new lT(this,t)}$s.prototype.setDefs=function(t){return this.defs=fT(this.defs,t),this};$s.prototype.compile=function(t){let e=this;if(!t||!(typeof t=="object"||typeof t=="function"))throw TypeError("namespace must be an object");if(typeof t.factory!="function")throw TypeError("namespace.factory must be a function");this.defs.ns=t,this.defs.$$mathCodegen={getProperty:function(a,s,u){function l(f){return e.interpreter.options.applyFactoryToScope&&typeof f!="function"?u.factory(f):f}if(a in s)return l(s[a]);if(a in u)return l(u[a]);throw SyntaxError('symbol "'+a+'" is undefined')},functionProxy:function(a,s){if(typeof a!="function")throw SyntaxError('symbol "'+s+'" must be a function');return a}},this.defs.$$processScope=this.defs.$$processScope||function(){};let n=Object.keys(this.defs).map(function(a){return"var "+a+' = defs["'+a+'"]'});if(!this.statements.length)throw Error("there are no statements saved in this generator, make sure you parse an expression before compiling it");this.statements[this.statements.length-1]="return "+this.statements[this.statements.length-1];let r=this.statements.join(";"),i=n.join(` +`)+` +`+["return {"," eval: function (scope) {"," scope = scope || {}"," $$processScope(scope)"," "+r," },"," code: "+JSON.stringify(r),"}"].join(` +`);var o=new Function("defs",i);return o(this.defs)};$s.prototype.parse=function(t){let e=this,n=new uT().parse(t);return this.statements=n.blocks.map(function(r){return e.interpreter.next(r)}),this};tx.exports=$s});var Zf=O((bY,nx)=>{"use strict";nx.exports=ex()});var ix=O((MY,rx)=>{"use strict";rx.exports=function(){let t=Object.create(Math);return t.factory=function(e){if(typeof e!="number")throw new TypeError("built-in math factory only accepts numbers");return Number(e)},t.add=function(e,n){return e+n},t.sub=function(e,n){return e-n},t.mul=function(e,n){return e*n},t.div=function(e,n){return e/n},t.mod=function(e,n){return e%n},t.factorial=function(e){let n=1;for(let r=2;r<=e;r+=1)n*=r;return n},t.nthRoot=function(e,n){let r=n<0;if(r&&(n=-n),n===0)throw new Error("Root must be non-zero");if(e<0&&Math.abs(n)%2!==1)throw new Error("Root must be odd when a is negative.");if(e===0)return 0;if(!isFinite(e))return r?0:e;let i=Math.pow(Math.abs(e),1/n);return i=e<0?-i:i,r?1/i:i},t.logicalOR=function(e,n){return e||n},t.logicalXOR=function(e,n){return e!=n},t.logicalAND=function(e,n){return e&&n},t.bitwiseOR=function(e,n){return e|n},t.bitwiseXOR=function(e,n){return e^n},t.bitwiseAND=function(e,n){return e&n},t.lessThan=function(e,n){return en},t.greaterEqualThan=function(e,n){return e>=n},t.equal=function(e,n){return e==n},t.strictlyEqual=function(e,n){return e===n},t.notEqual=function(e,n){return e!=n},t.strictlyNotEqual=function(e,n){return e!==n},t.shiftRight=function(e,n){return e>>n},t.shiftLeft=function(e,n){return e<>>n},t.negative=function(e){return-e},t.positive=function(e){return e},t}});var ox=O((TY,Jf)=>{"use strict";var cT=Zf(),Qf=ix()();function hT(t){Object.keys(t).forEach(function(e){let n=t[e];t[e]=Qf.factory(n)})}Jf.exports=function(t){return new cT().setDefs({$$processScope:hT}).parse(t).compile(Qf)};Jf.exports.math=Qf});var sx=O((SY,ax)=>{"use strict";ax.exports=ox()});var Ue=O(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.intervalsOverlap=St.hasInterval=St.hasValue=St.zeroIn=St.isSingleton=St.isWhole=St.isEmpty=St.isInterval=void 0;function pT(t){return typeof t=="object"&&typeof t.lo=="number"&&typeof t.hi=="number"}St.isInterval=pT;function Ur(t){return t.lo>t.hi}St.isEmpty=Ur;function mT(t){return t.lo===-1/0&&t.hi===1/0}St.isWhole=mT;function dT(t){return t.lo===t.hi}St.isSingleton=dT;function gT(t){return ux(t,0)}St.zeroIn=gT;function ux(t,e){return Ur(t)?!1:t.lo<=e&&e<=t.hi}St.hasValue=ux;function yT(t,e){return Ur(t)?!0:!Ur(e)&&e.lo<=t.lo&&t.hi<=e.hi}St.hasInterval=yT;function _T(t,e){return Ur(t)||Ur(e)?!1:t.lo<=e.lo&&e.lo<=t.hi||e.lo<=t.lo&&t.lo<=e.hi}St.intervalsOverlap=_T});var lx=O((IY,mt)=>{var Kf=!1;if(typeof Float64Array<"u")if(Ae=new Float64Array(1),zt=new Uint32Array(Ae.buffer),Ae[0]=1,Kf=!0,zt[1]===1072693248){let t=function(r,i){return zt[0]=r,zt[1]=i,Ae[0]},e=function(r){return Ae[0]=r,zt[0]},n=function(r){return Ae[0]=r,zt[1]};xT=t,vT=e,wT=n,mt.exports=function(i){return Ae[0]=i,[zt[0],zt[1]]},mt.exports.pack=t,mt.exports.lo=e,mt.exports.hi=n}else if(zt[0]===1072693248){let t=function(r,i){return zt[1]=r,zt[0]=i,Ae[0]},e=function(r){return Ae[0]=r,zt[1]},n=function(r){return Ae[0]=r,zt[0]};bT=t,MT=e,TT=n,mt.exports=function(i){return Ae[0]=i,[zt[1],zt[0]]},mt.exports.pack=t,mt.exports.lo=e,mt.exports.hi=n}else Kf=!1;var Ae,zt,xT,vT,wT,bT,MT,TT;if(!Kf){let t=function(r,i){return Oe.writeUInt32LE(r,0,!0),Oe.writeUInt32LE(i,4,!0),Oe.readDoubleLE(0,!0)},e=function(r){return Oe.writeDoubleLE(r,0,!0),Oe.readUInt32LE(0,!0)},n=function(r){return Oe.writeDoubleLE(r,0,!0),Oe.readUInt32LE(4,!0)};ST=t,ET=e,IT=n,Oe=new Buffer(8),mt.exports=function(i){return Oe.writeDoubleLE(i,0,!0),[Oe.readUInt32LE(0,!0),Oe.readUInt32LE(4,!0)]},mt.exports.pack=t,mt.exports.lo=e,mt.exports.hi=n}var Oe,ST,ET,IT;mt.exports.sign=function(t){return mt.exports.hi(t)>>>31};mt.exports.exponent=function(t){var e=mt.exports.hi(t);return(e<<1>>>21)-1023};mt.exports.fraction=function(t){var e=mt.exports.lo(t),n=mt.exports.hi(t),r=n&(1<<20)-1;return n&2146435072&&(r+=1<<20),[e,r]};mt.exports.denormalized=function(t){var e=mt.exports.hi(t);return!(e&2146435072)}});var px=O((AY,hx)=>{"use strict";var tc=lx(),fx=Math.pow(2,-1074),cx=-1>>>0;hx.exports=AT;function AT(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(t===0)return e<0?-fx:fx;var n=tc.hi(t),r=tc.lo(t);return e>t==t>0?r===cx?(n+=1,r=0):r+=1:r===0?(r=cx,n-=1):r-=1,tc.pack(r,n)}});var en=O(so=>{"use strict";var OT=so&&so.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(so,"__esModule",{value:!0});var dx=OT(px());function NT(t){return t}function ec(t){return t===1/0?t:(0,dx.default)(t,-1/0)}function nc(t){return t===-1/0?t:(0,dx.default)(t,1/0)}function mx(t){return t<0?Math.ceil(t):Math.floor(t)}var jr={prev:ec,next:nc},F={safePrev:ec,safeNext:nc,prev(t){return jr.prev(t)},next(t){return jr.next(t)},addLo(t,e){return F.prev(t+e)},addHi(t,e){return F.next(t+e)},subLo(t,e){return F.prev(t-e)},subHi(t,e){return F.next(t-e)},mulLo(t,e){return F.prev(t*e)},mulHi(t,e){return F.next(t*e)},divLo(t,e){return F.prev(t/e)},divHi(t,e){return F.next(t/e)},intLo(t){return mx(F.prev(t))},intHi(t){return mx(F.next(t))},logLo(t){return F.prev(Math.log(t))},logHi(t){return F.next(Math.log(t))},expLo(t){return F.prev(Math.exp(t))},expHi(t){return F.next(Math.exp(t))},sinLo(t){return F.prev(Math.sin(t))},sinHi(t){return F.next(Math.sin(t))},cosLo(t){return F.prev(Math.cos(t))},cosHi(t){return F.next(Math.cos(t))},tanLo(t){return F.prev(Math.tan(t))},tanHi(t){return F.next(Math.tan(t))},asinLo(t){return F.prev(Math.asin(t))},asinHi(t){return F.next(Math.asin(t))},acosLo(t){return F.prev(Math.acos(t))},acosHi(t){return F.next(Math.acos(t))},atanLo(t){return F.prev(Math.atan(t))},atanHi(t){return F.next(Math.atan(t))},sinhLo(t){return F.prev(Math.sinh(t))},sinhHi(t){return F.next(Math.sinh(t))},coshLo(t){return F.prev(Math.cosh(t))},coshHi(t){return F.next(Math.cosh(t))},tanhLo(t){return F.prev(Math.tanh(t))},tanhHi(t){return F.next(Math.tanh(t))},powLo(t,e){if(e%1!==0)return F.prev(Math.pow(t,e));let n=(e&1)===1?t:1;for(e>>=1;e>0;)t=F.mulLo(t,t),(e&1)===1&&(n=F.mulLo(t,n)),e>>=1;return n},powHi(t,e){if(e%1!==0)return F.next(Math.pow(t,e));let n=(e&1)===1?t:1;for(e>>=1;e>0;)t=F.mulHi(t,t),(e&1)===1&&(n=F.mulHi(t,n)),e>>=1;return n},sqrtLo(t){return F.prev(Math.sqrt(t))},sqrtHi(t){return F.next(Math.sqrt(t))},disable(){jr.next=jr.prev=NT},enable(){jr.next=nc,jr.prev=ec}};so.default=F});var vn=O(Gt=>{"use strict";var kT=Gt&&Gt.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),PT=Gt&&Gt.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),qT=Gt&&Gt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&kT(e,t,n);return PT(e,t),e},CT=Gt&&Gt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Interval=Gt._Interval=void 0;var zs=qT(Ue()),Br=CT(en()),Us=class t{constructor(e,n){if(this.lo=0,this.hi=0,!(this instanceof t))return console.log("calling with new"),console.log(e,n),new t(e,n);if(typeof e<"u"&&typeof n<"u"){if(zs.isInterval(e)){if(!zs.isSingleton(e))throw new TypeError("Interval: interval `lo` must be a singleton");e=e.lo}if(zs.isInterval(n)){if(!zs.isSingleton(n))throw TypeError("Interval: interval `hi` must be a singleton");n=n.hi}}else{if(typeof e<"u")return Array.isArray(e)?new Xr(e[0],e[1]):new Xr(e,e);e=n=0}this.assign(e,n)}singleton(e){return this.set(e,e)}bounded(e,n){return this.set(Br.default.prev(e),Br.default.next(n))}boundedSingleton(e){return this.bounded(e,e)}set(e,n){return this.lo=e,this.hi=n,this}assign(e,n){if(typeof e!="number"||typeof n!="number")throw TypeError("Interval#assign: arguments must be numbers");return isNaN(e)||isNaN(n)||e>n?this.setEmpty():this.set(e,n)}setEmpty(){return this.set(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)}setWhole(){return this.set(Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY)}open(e,n){return this.assign(Br.default.safeNext(e),Br.default.safePrev(n))}halfOpenLeft(e,n){return this.assign(Br.default.safeNext(e),n)}halfOpenRight(e,n){return this.assign(e,Br.default.safePrev(n))}toArray(){return[this.lo,this.hi]}clone(){return new Xr().set(this.lo,this.hi)}};Gt._Interval=Us;function LT(t){function e(){for(var n=arguments.length,r=Array(n),i=0;i{"use strict";var DT=lo&&lo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(lo,"__esModule",{value:!0});var wn=vn(),gx=DT(en()),js=(3373259426+273688/(1<<21))/(1<<30),Bs=(3373259426+273689/(1<<21))/(1<<30),uo={PI_LOW:js,PI_HIGH:Bs,PI_HALF_LOW:js/2,PI_HALF_HIGH:Bs/2,PI_TWICE_LOW:js*2,PI_TWICE_HIGH:Bs*2,get E(){return new wn.Interval(gx.default.prev(Math.E),gx.default.next(Math.E))},get PI(){return new wn.Interval(js,Bs)},get PI_HALF(){return new wn.Interval(uo.PI_HALF_LOW,uo.PI_HALF_HIGH)},get PI_TWICE(){return new wn.Interval(uo.PI_TWICE_LOW,uo.PI_TWICE_HIGH)},get ZERO(){return new wn.Interval(0)},get ONE(){return new wn.Interval(1)},get WHOLE(){return new wn.Interval().setWhole()},get EMPTY(){return new wn.Interval().setEmpty()}};lo.default=uo});var rc=O(X=>{"use strict";var RT=X&&X.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),HT=X&&X.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),FT=X&&X.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&RT(e,t,n);return HT(e,t),e};Object.defineProperty(X,"__esModule",{value:!0});X.geq=X.greaterEqualThan=X.leq=X.lessEqualThan=X.gt=X.greaterThan=X.lt=X.lessThan=X.notEqual=X.assertIncludes=X.almostEqual=X.equal=void 0;var Wt=FT(Ue());function YT(t,e){return Wt.isEmpty(t)?Wt.isEmpty(e):!Wt.isEmpty(e)&&t.lo===e.lo&&t.hi===e.hi}X.equal=YT;var $T=1e-7;function Xs(t,e){if(!t)throw new Error(e||"assertion failed")}function yx(t,e){if(!isFinite(t))return Xs(t===e,`[Infinity] expected ${t} to be ${e}`);Xs(Math.abs(t-e)<$T,`expected ${t} to be close to ${e}`)}function _x(t,e){t=Array.isArray(t)?t:t.toArray(),e=Array.isArray(e)?e:e.toArray(),yx(t[0],e[0]),yx(t[1],e[1])}X.almostEqual=_x;function zT(t,e){_x(t,e),t=Array.isArray(t)?t:t.toArray(),e=Array.isArray(e)?e:e.toArray(),Xs(t[0]<=e[0],`${t[0]} should be less/equal than ${e[0]}`),Xs(e[1]<=t[1],`${e[1]} should be less/equal than ${t[1]}`)}X.assertIncludes=zT;function UT(t,e){return Wt.isEmpty(t)?!Wt.isEmpty(e):Wt.isEmpty(e)||t.hie.hi}X.notEqual=UT;function xx(t,e){return Wt.isEmpty(t)||Wt.isEmpty(e)?!1:t.hie.hi}X.greaterThan=vx;X.gt=vx;function wx(t,e){return Wt.isEmpty(t)||Wt.isEmpty(e)?!1:t.hi<=e.lo}X.lessEqualThan=wx;X.leq=wx;function bx(t,e){return Wt.isEmpty(t)||Wt.isEmpty(e)?!1:t.lo>=e.hi}X.greaterEqualThan=bx;X.geq=bx});var Sx=O(Et=>{"use strict";var jT=Et&&Et.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),BT=Et&&Et.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),XT=Et&&Et.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&jT(e,t,n);return BT(e,t),e},Mx=Et&&Et.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Et,"__esModule",{value:!0});Et.zero=Et.negative=Et.positive=Et.nonZero=void 0;var fo=vn(),Lt=Mx(en()),Tx=XT(Ue()),ic=Mx(Kn());function GT(t,e){let n=t.lo,r=t.hi,i=e.lo,o=e.hi,a=new fo.Interval;return r<0?o<0?(a.lo=Lt.default.divLo(r,i),a.hi=Lt.default.divHi(n,o)):(a.lo=Lt.default.divLo(n,i),a.hi=Lt.default.divHi(r,o)):n<0?o<0?(a.lo=Lt.default.divLo(r,o),a.hi=Lt.default.divHi(n,o)):(a.lo=Lt.default.divLo(n,i),a.hi=Lt.default.divHi(r,i)):o<0?(a.lo=Lt.default.divLo(r,o),a.hi=Lt.default.divHi(n,i)):(a.lo=Lt.default.divLo(n,o),a.hi=Lt.default.divHi(r,i)),a}Et.nonZero=GT;function WT(t,e){return t.lo===0&&t.hi===0?t:Tx.zeroIn(t)?ic.default.WHOLE:t.hi<0?new fo.Interval(Number.NEGATIVE_INFINITY,Lt.default.divHi(t.hi,e)):new fo.Interval(Lt.default.divLo(t.lo,e),Number.POSITIVE_INFINITY)}Et.positive=WT;function VT(t,e){return t.lo===0&&t.hi===0?t:Tx.zeroIn(t)?ic.default.WHOLE:t.hi<0?new fo.Interval(Lt.default.divLo(t.hi,e),Number.POSITIVE_INFINITY):new fo.Interval(Number.NEGATIVE_INFINITY,Lt.default.divHi(t.lo,e))}Et.negative=VT;function ZT(t){return t.lo===0&&t.hi===0?t:ic.default.WHOLE}Et.zero=ZT});var Gr=O(J=>{"use strict";var QT=J&&J.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),JT=J&&J.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Ex=J&&J.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&QT(e,t,n);return JT(e,t),e},Ix=J&&J.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(J,"__esModule",{value:!0});J.negative=J.positive=J.div=J.divide=J.mul=J.multiply=J.sub=J.subtract=J.add=void 0;var ho=vn(),ft=Ix(en()),oc=Ix(Kn()),co=Ex(Ue()),Gs=Ex(Sx());function KT(t,e){return new ho.Interval(ft.default.addLo(t.lo,e.lo),ft.default.addHi(t.hi,e.hi))}J.add=KT;function Ax(t,e){return new ho.Interval(ft.default.subLo(t.lo,e.hi),ft.default.subHi(t.hi,e.lo))}J.subtract=Ax;J.sub=Ax;function Ox(t,e){if(co.isEmpty(t)||co.isEmpty(e))return oc.default.EMPTY;let n=t.lo,r=t.hi,i=e.lo,o=e.hi,a=new ho.Interval;return n<0?r>0?i<0?o>0?(a.lo=Math.min(ft.default.mulLo(n,o),ft.default.mulLo(r,i)),a.hi=Math.max(ft.default.mulHi(n,i),ft.default.mulHi(r,o))):(a.lo=ft.default.mulLo(r,i),a.hi=ft.default.mulHi(n,i)):o>0?(a.lo=ft.default.mulLo(n,o),a.hi=ft.default.mulHi(r,o)):(a.lo=0,a.hi=0):i<0?o>0?(a.lo=ft.default.mulLo(n,o),a.hi=ft.default.mulHi(n,i)):(a.lo=ft.default.mulLo(r,o),a.hi=ft.default.mulHi(n,i)):o>0?(a.lo=ft.default.mulLo(n,o),a.hi=ft.default.mulHi(r,i)):(a.lo=0,a.hi=0):r>0?i<0?o>0?(a.lo=ft.default.mulLo(r,i),a.hi=ft.default.mulHi(r,o)):(a.lo=ft.default.mulLo(r,i),a.hi=ft.default.mulHi(n,o)):o>0?(a.lo=ft.default.mulLo(n,i),a.hi=ft.default.mulHi(r,o)):(a.lo=0,a.hi=0):(a.lo=0,a.hi=0),a}J.multiply=Ox;J.mul=Ox;function Nx(t,e){return co.isEmpty(t)||co.isEmpty(e)?oc.default.EMPTY:co.zeroIn(e)?e.lo!==0?e.hi!==0?Gs.zero(t):Gs.negative(t,e.lo):e.hi!==0?Gs.positive(t,e.hi):oc.default.EMPTY:Gs.nonZero(t,e)}J.divide=Nx;J.div=Nx;function tS(t){return new ho.Interval(t.lo,t.hi)}J.positive=tS;function eS(t){return new ho.Interval(-t.hi,-t.lo)}J.negative=eS});var Ws=O(gt=>{"use strict";var nS=gt&>.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),rS=gt&>.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Px=gt&>.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&nS(e,t,n);return rS(e,t),e},qx=gt&>.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(gt,"__esModule",{value:!0});gt.nthRoot=gt.sqrt=gt.pow=gt.multiplicativeInverse=gt.fmod=void 0;var ee=vn(),kt=qx(en()),de=qx(Kn()),bn=Px(Ue()),kx=Px(Gr());function iS(t,e){if(bn.isEmpty(t)||bn.isEmpty(e))return de.default.EMPTY;let n=t.lo<0?e.lo:e.hi,r=t.lo/n;return r<0?r=Math.ceil(r):r=Math.floor(r),kx.sub(t,kx.mul(e,new ee.Interval(r)))}gt.fmod=iS;function Cx(t){return bn.isEmpty(t)?de.default.EMPTY:bn.zeroIn(t)?t.lo!==0?t.hi!==0?de.default.WHOLE:new ee.Interval(Number.NEGATIVE_INFINITY,kt.default.divHi(1,t.lo)):t.hi!==0?new ee.Interval(kt.default.divLo(1,t.hi),Number.POSITIVE_INFINITY):de.default.EMPTY:new ee.Interval(kt.default.divLo(1,t.hi),kt.default.divHi(1,t.lo))}gt.multiplicativeInverse=Cx;function Lx(t,e){if(bn.isEmpty(t))return de.default.EMPTY;if(typeof e=="object"){if(!bn.isSingleton(e))return de.default.EMPTY;e=e.lo}if(e===0)return t.lo===0&&t.hi===0?de.default.EMPTY:de.default.ONE;if(e<0)return Lx(Cx(t),-e);if(Number.isSafeInteger(e))if(t.hi<0){let n=kt.default.powLo(-t.hi,e),r=kt.default.powHi(-t.lo,e);return(e&1)===1?new ee.Interval(-r,-n):new ee.Interval(n,r)}else return t.lo<0?(e&1)===1?new ee.Interval(-kt.default.powLo(-t.lo,e),kt.default.powHi(t.hi,e)):new ee.Interval(0,kt.default.powHi(Math.max(-t.lo,t.hi),e)):new ee.Interval(kt.default.powLo(t.lo,e),kt.default.powHi(t.hi,e));else return console.warn("power is not an integer, you should use nth-root instead, returning an empty interval"),de.default.EMPTY}gt.pow=Lx;function oS(t){return Dx(t,2)}gt.sqrt=oS;function Dx(t,e){if(bn.isEmpty(t)||e<0)return de.default.EMPTY;if(typeof e=="object"){if(!bn.isSingleton(e))return de.default.EMPTY;e=e.lo}let n=1/e;if(t.hi<0){if(Number.isSafeInteger(e)&&(e&1)===1){let r=kt.default.powHi(-t.lo,n),i=kt.default.powLo(-t.hi,n);return new ee.Interval(-r,-i)}return de.default.EMPTY}else if(t.lo<0){let r=kt.default.powHi(t.hi,n);if(Number.isSafeInteger(e)&&(e&1)===1){let i=-kt.default.powHi(-t.lo,n);return new ee.Interval(i,r)}return new ee.Interval(0,r)}else return new ee.Interval(kt.default.powLo(t.lo,n),kt.default.powHi(t.hi,n))}gt.nthRoot=Dx});var Vs=O(H=>{"use strict";var aS=H&&H.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),sS=H&&H.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Rx=H&&H.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&aS(e,t,n);return sS(e,t),e},Hx=H&&H.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(H,"__esModule",{value:!0});H.clone=H.min=H.max=H.abs=H.wid=H.width=H.difference=H.union=H.intersection=H.hull=H.log2=H.LOG_EXP_2=H.log10=H.LOG_EXP_10=H.ln=H.log=H.exp=void 0;var ne=vn(),po=Hx(en()),ge=Hx(Kn()),vt=Rx(Ue()),ac=Rx(Gr());function uS(t){return vt.isEmpty(t)?ge.default.EMPTY:new ne.Interval(po.default.expLo(t.lo),po.default.expHi(t.hi))}H.exp=uS;function Wr(t){if(vt.isEmpty(t))return ge.default.EMPTY;let e=t.lo<=0?Number.NEGATIVE_INFINITY:po.default.logLo(t.lo);return new ne.Interval(e,po.default.logHi(t.hi))}H.log=Wr;H.ln=Wr;H.LOG_EXP_10=Wr(new ne.Interval(10,10));function lS(t){return vt.isEmpty(t)?ge.default.EMPTY:ac.div(Wr(t),H.LOG_EXP_10)}H.log10=lS;H.LOG_EXP_2=Wr(new ne.Interval(2,2));function fS(t){return vt.isEmpty(t)?ge.default.EMPTY:ac.div(Wr(t),H.LOG_EXP_2)}H.log2=fS;function cS(t,e){let n=vt.isEmpty(t),r=vt.isEmpty(e);return n&&r?ge.default.EMPTY:n?e.clone():r?t.clone():new ne.Interval(Math.min(t.lo,e.lo),Math.max(t.hi,e.hi))}H.hull=cS;function hS(t,e){if(vt.isEmpty(t)||vt.isEmpty(e))return ge.default.EMPTY;let n=Math.max(t.lo,e.lo),r=Math.min(t.hi,e.hi);return n<=r?new ne.Interval(n,r):ge.default.EMPTY}H.intersection=hS;function pS(t,e){if(!vt.intervalsOverlap(t,e))throw Error("Interval#union: intervals do not overlap");return new ne.Interval(Math.min(t.lo,e.lo),Math.max(t.hi,e.hi))}H.union=pS;function mS(t,e){if(vt.isEmpty(t)||vt.isWhole(e))return ge.default.EMPTY;if(vt.intervalsOverlap(t,e)){if(t.lo=t.hi&&e.lo===-1/0?ge.default.EMPTY:e.lo<=t.lo?new ne.Interval().halfOpenLeft(e.hi,t.hi):new ne.Interval().halfOpenRight(t.lo,e.lo)}return t.clone()}H.difference=mS;function Fx(t){return vt.isEmpty(t)?0:po.default.subHi(t.hi,t.lo)}H.width=Fx;H.wid=Fx;function dS(t){return vt.isEmpty(t)||vt.isWhole(t)?ge.default.EMPTY:t.lo>=0?t.clone():t.hi<=0?ac.negative(t):new ne.Interval(0,Math.max(-t.lo,t.hi))}H.abs=dS;function gS(t,e){let n=vt.isEmpty(t),r=vt.isEmpty(e);return n&&r?ge.default.EMPTY:n?e.clone():r?t.clone():new ne.Interval(Math.max(t.lo,e.lo),Math.max(t.hi,e.hi))}H.max=gS;function yS(t,e){let n=vt.isEmpty(t),r=vt.isEmpty(e);return n&&r?ge.default.EMPTY:n?e.clone():r?t.clone():new ne.Interval(Math.min(t.lo,e.lo),Math.min(t.hi,e.hi))}H.min=yS;function _S(t){return new ne.Interval().set(t.lo,t.hi)}H.clone=_S});var lc=O(K=>{"use strict";var xS=K&&K.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),vS=K&&K.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Qs=K&&K.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&xS(e,t,n);return vS(e,t),e},Yx=K&&K.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(K,"__esModule",{value:!0});K.tanh=K.cosh=K.sinh=K.atan=K.acos=K.asin=K.tan=K.sin=K.cos=void 0;var Ut=vn(),wt=Yx(en()),at=Yx(Kn()),nn=Qs(Ue()),Zs=Qs(Gr()),$x=Qs(Ws()),wS=Qs(Vs());function sc(t){return!isFinite(t.lo)&&t.lo===t.hi}function zx(t){if(t.lo<0)if(t.lo===-1/0)t.lo=0,t.hi=1/0;else{let e=Math.ceil(-t.lo/at.default.PI_TWICE_LOW);t.lo+=at.default.PI_TWICE_LOW*e,t.hi+=at.default.PI_TWICE_LOW*e}return t}function uc(t){if(nn.isEmpty(t)||sc(t))return at.default.EMPTY;let e=new Ut.Interval().set(t.lo,t.hi);zx(e);let n=at.default.PI_TWICE,r=$x.fmod(e,n);if(wS.width(r)>=n.lo)return new Ut.Interval(-1,1);if(r.lo>=at.default.PI_HIGH){let u=uc(Zs.sub(r,at.default.PI));return Zs.negative(u)}let i=r.lo,o=r.hi,a=wt.default.cosLo(o),s=wt.default.cosHi(i);return o<=at.default.PI_LOW?new Ut.Interval(a,s):o<=n.lo?new Ut.Interval(-1,Math.max(a,s)):new Ut.Interval(-1,1)}K.cos=uc;function bS(t){return nn.isEmpty(t)||sc(t)?at.default.EMPTY:uc(Zs.sub(t,at.default.PI_HALF))}K.sin=bS;function MS(t){if(nn.isEmpty(t)||sc(t))return at.default.EMPTY;let e=new Ut.Interval().set(t.lo,t.hi);zx(e);let n=at.default.PI,r=$x.fmod(e,n);return r.lo>=at.default.PI_HALF_LOW&&(r=Zs.sub(r,n)),r.lo<=-at.default.PI_HALF_LOW||r.hi>=at.default.PI_HALF_LOW?at.default.WHOLE:new Ut.Interval(wt.default.tanLo(r.lo),wt.default.tanHi(r.hi))}K.tan=MS;function TS(t){if(nn.isEmpty(t)||t.hi<-1||t.lo>1)return at.default.EMPTY;let e=t.lo<=-1?-at.default.PI_HALF_HIGH:wt.default.asinLo(t.lo),n=t.hi>=1?at.default.PI_HALF_HIGH:wt.default.asinHi(t.hi);return new Ut.Interval(e,n)}K.asin=TS;function SS(t){if(nn.isEmpty(t)||t.hi<-1||t.lo>1)return at.default.EMPTY;let e=t.hi>=1?0:wt.default.acosLo(t.hi),n=t.lo<=-1?at.default.PI_HIGH:wt.default.acosHi(t.lo);return new Ut.Interval(e,n)}K.acos=SS;function ES(t){return nn.isEmpty(t)?at.default.EMPTY:new Ut.Interval(wt.default.atanLo(t.lo),wt.default.atanHi(t.hi))}K.atan=ES;function IS(t){return nn.isEmpty(t)?at.default.EMPTY:new Ut.Interval(wt.default.sinhLo(t.lo),wt.default.sinhHi(t.hi))}K.sinh=IS;function AS(t){return nn.isEmpty(t)?at.default.EMPTY:t.hi<0?new Ut.Interval(wt.default.coshLo(t.hi),wt.default.coshHi(t.lo)):t.lo>=0?new Ut.Interval(wt.default.coshLo(t.lo),wt.default.coshHi(t.hi)):new Ut.Interval(1,wt.default.coshHi(-t.lo>t.hi?t.lo:t.hi))}K.cosh=AS;function OS(t){return nn.isEmpty(t)?at.default.EMPTY:new Ut.Interval(wt.default.tanhLo(t.lo),wt.default.tanhHi(t.hi))}K.tanh=OS});var Gx=O(st=>{"use strict";var Ux=st&&st.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),NS=st&&st.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),Vr=st&&st.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Ux(e,t,n);return NS(e,t),e},Zr=st&&st.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Ux(e,t,n)},jx=st&&st.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(st,"__esModule",{value:!0});st.constants=st.round=st.Interval=void 0;var Bx=vn();Object.defineProperty(st,"Interval",{enumerable:!0,get:function(){return Bx._Interval}});var fc=jx(en());st.round=fc.default;var Xx=jx(Kn());st.constants=Xx.default;var kS=Vr(rc()),PS=Vr(Gr()),qS=Vr(Ws()),CS=Vr(lc()),LS=Vr(Vs()),DS=Vr(Ue()),RS=Object.assign(Bx.Interval,Xx.default,fc.default,LS,DS,kS,PS,qS,CS,{round:fc.default});st.default=RS;Zr(rc(),st);Zr(Gr(),st);Zr(Ws(),st);Zr(lc(),st);Zr(Vs(),st);Zr(Ue(),st)});var Vx=O((FY,Wx)=>{"use strict";Wx.exports=function(t){t.mod=t.fmod,t.lessThan=t.lt,t.lessEqualThan=t.leq,t.greaterThan=t.gt,t.greaterEqualThan=t.geq,t.strictlyEqual=t.equal,t.strictlyNotEqual=t.notEqual,t.logicalAND=function(e,n){return e&&n},t.logicalXOR=function(e,n){return e^n},t.logicalOR=function(e,n){return e||n}}});var Qx=O((YY,Zx)=>{"use strict";Zx.exports=function(t){return{disableRounding:function(){t.round.disable()},enableRounding:function(){t.round.enable()}}}});var Jx=O(($Y,Js)=>{"use strict";var HS=Zf(),Qr=Gx().default;Vx()(Qr);function FS(t){Object.keys(t).forEach(function(e){let n=t[e];typeof n=="number"||Array.isArray(n)?t[e]=Qr.factory(n):typeof n=="object"&&"lo"in n&&"hi"in n&&(t[e]=Qr.factory(n.lo,n.hi))})}Js.exports=function(t){return new HS().setDefs({$$processScope:FS}).parse(t).compile(Qr)};Js.exports.policies=Qx()(Qr);Js.exports.Interval=Qr});var Ks=O((zY,Kx)=>{"use strict";Kx.exports=Jx()});var Tn=O(Mn=>{"use strict";var tv=Mn&&Mn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.interval=Mn.builtIn=void 0;var YS=tv(sx()),$S=tv(Ks()),ev={interval:$S.default,builtIn:YS.default};function zS(){return typeof global=="object"&&"math"in global?global.math:typeof window=="object"&&"math"in window?window.math:null}var cc=zS();cc&&(ev.builtIn=cc.compile);function nv(t){function e(o){if(typeof o=="string"){let a=ev[t](o);return cc&&t==="builtIn"?{eval:a.evaluate||a.eval}:a}else{if(typeof o=="function")return{eval:o};throw Error("expression must be a string or a function")}}function n(o,a){let s=o[a],u=t+"_Expression_"+a,l=t+"_Compiled_"+a;s!==o[u]&&(o[u]=s,o[l]=e(s))}function r(o,a){return o[t+"_Compiled_"+a]}function i(o,a,s){return n(o,a),r(o,a).eval(Object.assign({},o.scope||{},s))}return i}var US=nv("builtIn");Mn.builtIn=US;var jS=nv("interval");Mn.interval=jS});var av=O(mo=>{"use strict";var ov=mo&&mo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(mo,"__esModule",{value:!0});var BS=(ci(),it(fi)),XS=(pt(),it(pe)),tr=ov(ze()),rv=ov(zr()),iv=Tn();function GS(t){t=Object.assign({xLine:!1,yLine:!1,renderer:function(s,u){return"("+s.toFixed(3)+", "+u.toFixed(3)+")"},owner:null},t);let e=20,n=(0,BS.line)().x(function(s){return s[0]}).y(function(s){return s[1]});function r(s,u){return s.append("path").datum(u).attr("stroke","grey").attr("stroke-dasharray","5,5").attr("opacity",.5).attr("d",n)}let i,o;function a(s){let u=s.selectAll("g.tip").data(function(f){return[f]}),l=u.enter().append("g").attr("class","tip").attr("clip-path","url(#function-plot-clip-"+t.owner.id+")");i=u.merge(l).selectAll("g.inner-tip").data(function(f){return[f]}),o=i.enter().append("g").attr("class","inner-tip").style("display","none").each(function(){let f=(0,XS.select)(this);r(f,[[0,-t.owner.meta.height-e],[0,t.owner.meta.height+e]]).attr("class","tip-x-line").style("display","none"),r(f,[[-t.owner.meta.width-e,0],[t.owner.meta.width+e,0]]).attr("class","tip-y-line").style("display","none"),f.append("circle").attr("r",3),f.append("text").attr("transform","translate(5,-5)")}),i.merge(o).selectAll(".tip-x-line").style("display",t.xLine?null:"none"),i.merge(o).selectAll(".tip-y-line").style("display",t.yLine?null:"none")}return a.move=function(s){let u,l=1/0,f=-1,c,h,m=i.merge(o),g=t.owner.meta,y=m.datum().data,M=g.xScale,_=g.yScale,E=g.width,A=g.height,I=s.x,P=s.y;for(u=0;uw[0]-rv.default.TIP_X_EPS&&I{"use strict";var WS=Ne&&Ne.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),VS=Ne&&Ne.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),ZS=Ne&&Ne.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&WS(e,t,n);return VS(e,t),e},QS=Ne&&Ne.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ne,"__esModule",{value:!0});var er=ZS(Ks()),sv=Tn(),JS=QS(ze());er.default.policies.disableRounding();function KS(t){let e=JS.default.space(t.xAxis,t.range,t.nSamples),n=t.xScale,r=t.yScale,i=r.domain()[0],o=r.domain()[1],a=[],s;for(s=0;sl[1].hi&&(u[1].hi=Math.max(o,u[1].hi),l[1].lo=Math.min(i,l[1].lo)),u[1].hi{"use strict";var rE=_o&&_o.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(_o,"__esModule",{value:!0});var Dt=rE(ze()),yo=Tn();function fv(t,e,n,r,i){if(!i)return{asymptote:!0,d0:t,d1:e};let o=10,a=t[0],s=e[0],u=Dt.default.linspace(a,s,o),l,f;for(let c=0;c=2&&r!==m&&Math.abs(h/l)>1){let g=fv(e[u-1],e[u],t,m,3);g.asymptote?(e[u-1][0]=g.d0[0],e[u-1][1]=Dt.default.clamp(g.d0[1],o,a),i.push(s),e[u][0]=g.d1[0],e[u][1]=Dt.default.clamp(g.d1[1],o,a),s=[e[u]]):s.push(e[u])}else s.push(e[u]);s.length>1&&(l=s[s.length-1][0]-s[s.length-2][0],r=m),++u}return s.length&&i.push(s),i}function oE(t){let e=Dt.default.space(t.xAxis,t.range,t.nSamples),n=t.yScale.domain(),r=n[0]-Dt.default.infinity(),i=n[1]+Dt.default.infinity(),o=[];for(let s=0;s{"use strict";var hc=xo&&xo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(xo,"__esModule",{value:!0});var hv=hc(zr()),cE=hc(lv()),hE=hc(cv());function pE(t,e){let n=e.range||[-1/0,1/0],r=Math.max(t.domain()[0],n[0]),i=Math.min(t.domain()[1],n[1]);return[r,i]}function mE(t,e){let n=pE(t.meta.xScale,e),r;if(e.sampler==="builtIn")r=hE.default;else if(e.sampler==="interval")r=cE.default;else throw new Error(`Invalid sampler function ${e.sampler}`);let i=e.nSamples||Math.min(hv.default.MAX_ITERATIONS,hv.default.DEFAULT_ITERATIONS||t.meta.width*2),o=r({d:e,range:n,xScale:t.meta.xScale,yScale:t.meta.yScale,xAxis:t.options.xAxis,yAxis:t.options.yAxis,nSamples:i});return t.emit("eval",o,e.index,e.isHelper),o}xo.default=mE});var dv=O(vo=>{"use strict";var mv=vo&&vo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(vo,"__esModule",{value:!0});var pv=(pt(),it(pe)),pc=(ci(),it(fi)),eu=mv(ze()),dE=mv(tu());function gE(t){function e(n){n.each(function(r){let i=e.el=(0,pv.select)(this),o=r.index,a=(0,dE.default)(t,r),s=eu.default.color(r,o),u=i.selectAll(":scope > path.line").data(a),l=t.meta.yScale.range(),f=l[0],c=l[1],h=f-c;f+=h*1e6,c-=h*1e6,r.skipBoundsCheck&&(f=eu.default.infinity(),c=-eu.default.infinity());function m(E){return eu.default.clamp(t.meta.yScale(E[1]),c,f)}let g=(0,pc.line)().curve(pc.curveLinear).x(function(E){return t.meta.xScale(E[0])}).y(m),y=(0,pc.area)().x(function(E){return t.meta.xScale(E[0])}).y0(t.meta.yScale(0)).y1(m),M=`line line-${o}`,_=u.enter().append("path").attr("class",M).attr("stroke-width",1).attr("stroke-linecap","round");u.merge(_).each(function(){let E=(0,pv.select)(this),A;if(r.closed?(E.attr("fill",s),E.attr("fill-opacity",.3),A=y):(E.attr("fill","none"),A=g),E.attr("stroke",s).attr("marker-end",function(){return r.fnType==="vector"?"url(#"+t.markerId+")":null}).attr("d",A),r.attr)for(let I in r.attr){let P=r.attr[I];I==="class"&&(P=`${M} ${r.attr[I]}`),E.attr(I,P)}}),u.exit().remove()})}return e}vo.default=gE});var yv=O(wo=>{"use strict";var gv=wo&&wo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(wo,"__esModule",{value:!0});var yE=(pt(),it(pe)),_E=gv(tu()),xE=gv(ze());function vE(t){let e,n=t.meta.xScale,r=t.meta.yScale;function i(s,u,l,f){if(l>f){let m=l;l=f,f=m}let c=Math.min(u,f),h=Math.max(s,l);return h>c?[-e,0]:[h,c]}let o=function(s,u){let l="",f=r.range(),c=Math.min.apply(Math,f),h=Math.max.apply(Math,f);for(let m=0,g=s.length;m path.line").data(h);e=Math.max(h[0].scaledDx,1);let g=`line line-${f}`,y=m.enter().append("path").attr("class",g).attr("fill","none"),M=m.merge(y).attr("stroke-width",e).attr("stroke",xE.default.color(u,f)).attr("opacity",c?.5:1).attr("d",function(_){return o(_,c)});if(u.attr)for(let _ in u.attr){let E=u.attr[_];_==="class"&&(E=`${g} ${u.attr[_]}`),M.attr(_,E)}m.exit().remove()})}return a}wo.default=vE});var xv=O(bo=>{"use strict";var _v=bo&&bo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bo,"__esModule",{value:!0});var wE=(pt(),it(pe)),bE=(Ee(),it(Sa)),ME=_v(ze()),TE=_v(tu());function SE(t){let e=t.meta.xScale,n=t.meta.yScale;function r(i){i.each(function(o){let a,s,u=o.index,l=ME.default.color(o,u),f=(0,TE.default)(t,o),c=[];for(a=0;a circle.scatter").data(c),m=`scatter scatter-${u}`,g=h.enter().append("circle").attr("class",m),y=h.merge(g).attr("fill",(0,bE.hsl)(l.toString()).brighter(1.5).formatHex()).attr("stroke",l).attr("opacity",.7).attr("r",1).attr("cx",function(M){return e(M[0])}).attr("cy",function(M){return n(M[1])});if(o.attr)for(let M in o.attr){let _=o.attr[M];M==="class"&&(_=`${m} ${o.attr[M]}`),y.attr(M,_)}h.exit().remove()})}return r}bo.default=SE});var vv=O(Mo=>{"use strict";var EE=Mo&&Mo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Mo,"__esModule",{value:!0});var IE=(pt(),it(pe)),AE=(Ee(),it(Sa)),OE=EE(ze());function NE(t){let e=t.meta.xScale,n=t.meta.yScale;function r(i){i.each(function(o){o.sampler="builtIn",o.fnType="vector";let a=(0,IE.select)(this).selectAll(":scope > text.fn-text").data([o.location]),s=a.enter().append("text").attr("class",`fn-text fn-text-${o.index}`),u=OE.default.color(o,o.index),l=a.merge(s).attr("fill",(0,AE.hsl)(u.toString()).brighter(1.5).formatHex()).attr("x",f=>e(f[0])).attr("y",f=>n(f[1])).text(()=>o.text);if(o.attr)for(let f in o.attr)l.attr(f,o.attr[f]);a.exit().remove()})}return r}Mo.default=NE});var To=O(ye=>{"use strict";var nu=ye&&ye.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ye,"__esModule",{value:!0});ye.text=ye.scatter=ye.interval=ye.polyline=void 0;var kE=nu(dv());ye.polyline=kE.default;var PE=nu(yv());ye.interval=PE.default;var qE=nu(xv());ye.scatter=qE.default;var CE=nu(vv());ye.text=CE.default});var ru=O(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});function LE(t){return"graphType"in t||(t.graphType="interval"),"sampler"in t||(t.sampler=t.graphType!=="interval"?"builtIn":"interval"),"fnType"in t||(t.fnType="linear"),t}mc.default=LE});var Mv=O(So=>{"use strict";var bv=So&&So.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(So,"__esModule",{value:!0});var DE=(pt(),it(pe)),RE=To(),wv=Tn(),HE=bv(ru()),FE=bv(ze());function YE(t){let e=(0,HE.default)({isHelper:!0,skipTip:!0,skipBoundsCheck:!0,nSamples:2,graphType:"polyline"});function n(o){if(!o.derivative)return[];let a=typeof o.derivative.x0=="number"?o.derivative.x0:FE.default.infinity();return e.index=o.index,e.scope={m:(0,wv.builtIn)(o.derivative,"fn",{x:a}),x0:a,y0:(0,wv.builtIn)(o,"fn",{x:a})},e.fn="m * (x - x0) + y0",[e]}function r(o){let a=this;o.derivative&&o.derivative.updateOnMouseMove&&!o.derivative.$$mouseListener&&(o.derivative.$$mouseListener=function({x:s}){o.derivative&&(o.derivative.x0=s),i(a)},t.on("tip:update",o.derivative.$$mouseListener))}let i=function(o){o.each(function(a){let s=(0,DE.select)(this),u=n.call(o,a);r.call(o,a);let l=s.selectAll("g.derivative").data(u),f=l.enter().append("g").attr("class","derivative");l.merge(f).call((0,RE.polyline)(t)),l.merge(f).selectAll("path").attr("opacity",.5),l.exit().remove()})};return i}So.default=YE});var Ev=O(Eo=>{"use strict";var Sv=Eo&&Eo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Eo,"__esModule",{value:!0});var $E=(pt(),it(pe)),Tv=Tn(),zE=Sv(ru()),UE=To(),jE=Sv(ze());function BE(t){let e=(0,zE.default)({isHelper:!0,skipTip:!0,skipBoundsCheck:!0,nSamples:2,graphType:"polyline"});function n(u){u.m=(u.y1-u.y0)/(u.x1-u.x0)}function r(u,l){if(!("x0"in l))throw Error("secant must have the property `x0` defined");l.scope=l.scope||{};let f=l.x0,c=typeof l.x1=="number"?l.x1:jE.default.infinity();Object.assign(l.scope,{x0:f,x1:c,y0:(0,Tv.builtIn)(u,"fn",{x:f}),y1:(0,Tv.builtIn)(u,"fn",{x:c})}),n(l.scope)}function i(u,l){r(u,l),l.fn="m * (x - x0) + y0"}function o(u,l){let f=this;l.updateOnMouseMove&&!l.$$mouseListener&&(l.$$mouseListener=function({x:c}){l.x1=c,r(u,l),s(f)},t.on("tip:update",l.$$mouseListener))}function a(u){let l=this,f=[];u.secants=u.secants||[];for(let c=0;c{"use strict";var Iv=Io&&Io.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Io,"__esModule",{value:!0});var XE=(pt(),it(pe)),GE=Iv(Mv()),WE=Iv(Ev());function VE(t){function e(n){n.each(function(){let r=(0,XE.select)(this);r.call((0,GE.default)(t)),r.call((0,WE.default)(t))})}return e}Io.default=VE});var qv=O(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.renderPolarGrid=yt.getPolarLabelLayout=yt.getPolarRayInterval=yt.formatPolarAngle=yt.getPolarAngles=yt.getPolarRadii=yt.getPolarRadiusDomain=yt.getPolarDomains=yt.validatePolarOptions=void 0;var ZE=(yi(),it(Vu)),QE=(tf(),it(Kl)),JE=(pt(),it(pe)),iu=2*Math.PI,KE="radians";function tI(t){var e,n;if(t.xAxis.type!=="linear"||t.yAxis.type!=="linear")throw new Error("polar coordinate system only supports linear axes");for(let i of[t.xAxis.domain,t.yAxis.domain,(e=t.polar)===null||e===void 0?void 0:e.radiusDomain])if(i&&(i.length!==2||i.some(o=>!Number.isFinite(o))||i[0]>=i[1]))throw new Error("polar domains must contain two finite ascending values");let r=t.polar;if(((n=r?.radiusDomain)===null||n===void 0?void 0:n[0])<0)throw new Error("polar radiusDomain must be non-negative");for(let i of[r?.radialTicks,r?.angularTicks]){if(i!==void 0&&!Array.isArray(i)&&(!Number.isInteger(i)||i<1))throw new Error("polar tick counts must be positive integers");if(Array.isArray(i)&&i.some(o=>!Number.isFinite(o)))throw new Error("polar tick values must be finite numbers")}if(Array.isArray(r?.radialTicks)&&r.radialTicks.some(i=>i<0))throw new Error("polar radial ticks must be non-negative");if(r?.angleUnit&&r.angleUnit!=="radians"&&r.angleUnit!=="degrees")throw new Error(`unsupported polar angle unit ${r.angleUnit}`)}yt.validatePolarOptions=tI;function eI(t,e,n,r){let i=Math.max((t[1]-t[0])/n,(e[1]-e[0])/r),o=(t[0]+t[1])/2,a=(e[0]+e[1])/2;return{xDomain:[o-n*i/2,o+n*i/2],yDomain:[a-r*i/2,a+r*i/2]}}yt.getPolarDomains=eI;function Av(t,e){let n=Math.min(...t),r=Math.max(...t),i=Math.min(...e),o=Math.max(...e),a=Math.max(n,Math.min(0,r)),s=Math.max(i,Math.min(0,o));return[Math.hypot(a,s),Math.hypot(Math.max(Math.abs(n),Math.abs(r)),Math.max(Math.abs(i),Math.abs(o)))]}yt.getPolarRadiusDomain=Av;function Ov(t,e,n){let r=t.radiusDomain||e,i=Math.max(r[0],e[0]),o=Math.min(r[1],e[1]);if(i>o)return[];let a;if(Array.isArray(t.radialTicks))a=t.radialTicks;else{let s=t.radialTicks||5;if(t.radialTicks===void 0&&n!==void 0){let u=(o-i)*n;s=Math.max(1,Math.round(u/50))}a=(0,QE.scaleLinear)().domain([i,o]).ticks(s)}return Array.from(new Set(a)).filter(s=>s>0&&s>=i&&s<=o).sort((s,u)=>s-u)}yt.getPolarRadii=Ov;function Nv(t){if(Array.isArray(t.angularTicks)){let n=t.angularTicks.map(r=>(r%iu+iu)%iu);return n.filter((r,i)=>n.findIndex(o=>Math.abs(o-r)<1e-10)===i)}let e=t.angularTicks||12;return Array.from({length:e},(n,r)=>r*iu/e)}yt.getPolarAngles=Nv;function kv(t,e){if(e==="degrees")return`${Number((t*180/Math.PI).toFixed(2))}\xB0`;for(let n of[1,2,3,4,6,8,12,16]){let r=Math.round(t/Math.PI*n);if(Math.abs(t/Math.PI-r/n)<1e-10)return r===0?"0":`${r===1?"":r===-1?"-":String(r)}\u03C0${n===1?"":`/${n}`}`}return Number(t.toFixed(3)).toString()}yt.formatPolarAngle=kv;function gc(t,e,n,r){let i=-1/0,o=1/0;for(let[s,u,l]of[[t[0],e[0],n],[t[1],e[1],r]]){if(Math.abs(u)<1e-10){if(s<0||s>l)return;continue}let f=(0-s)/u,c=(l-s)/u;i=Math.max(i,Math.min(f,c)),o=Math.min(o,Math.max(f,c))}let a=Math.max(0,i);return o>a?[a,o]:void 0}yt.getPolarRayInterval=gc;function Pv(t,e,n,r,i){let o=gc(t,e,r,i);if(!o)return;let a=n.filter(l=>l>=o[0]&&l<=o[1]).pop();if(a===void 0)return;let s=[t[0]+e[0]*a,t[1]+e[1]*a],u=e[0]>1e-10?"start":e[0]<-1e-10?"end":"middle";return{position:s,textAnchor:u}}yt.getPolarLabelLayout=Pv;function nI(t,e,n){var r;if(!(n.coordinateSystem==="polar"&&((r=n.polar)===null||r===void 0?void 0:r.grid)!==!1)){t.selectAll("g.polar-grid").remove();return}let o=t.selectAll("g.polar-grid").data([n.polar||{}]),a=o.merge(o.enter().insert("g",".content, .zoom-and-drag").attr("class","polar-grid")).attr("clip-path",null).attr("pointer-events","none"),s=a.selectAll(":scope > g.polar-grid-lines").data([0]),u=s.enter().append("g").attr("class","polar-grid-lines"),l=t.select("clipPath[id]").attr("id"),f=s.merge(u).attr("clip-path","url(#"+l+")"),c=n.polar||{},h=e.xScale,m=e.yScale,g=Av(h.domain(),m.domain()),y=[h(0),m(0)],M=h(1)-y[0],_=m(1)-y[1],E=Math.abs(M),A=Ov(c,g,E),I=Nv(c),P=v=>{var T;let d=((T=c.radiusDomain)===null||T===void 0?void 0:T[1])===void 0?void 0:Math.min(c.radiusDomain[1],g[1]),S=[Math.cos(v)*Math.sign(M),Math.sin(v)*Math.sign(_)],x=gc(y,S,e.width,e.height);if(!x)return;let N=d===void 0?x[1]:Math.min(d*E,x[1]);return N>x[0]?{direction:S,rayLength:N}:void 0},w=I.filter(v=>P(v)),q=f.selectAll("circle.polar-grid-circle").data(A,v=>v);q.exit().remove(),q.merge(q.enter().append("circle").attr("class","polar-grid-circle")).attr("cx",y[0]).attr("cy",y[1]).attr("r",v=>v*E).attr("fill","none").attr("stroke","currentColor").attr("opacity",.2);let z=f.selectAll("line.polar-grid-ray").data(w,v=>v);z.exit().remove(),z.merge(z.enter().append("line").attr("class","polar-grid-ray")).attr("x1",y[0]).attr("y1",y[1]).attr("x2",v=>{let T=P(v);return y[0]+T.direction[0]*T.rayLength}).attr("y2",v=>{let T=P(v);return y[1]+T.direction[1]*T.rayLength}).attr("stroke","currentColor").attr("opacity",.2);let tt=a.selectAll("text.polar-radius-label").data(A,v=>v);tt.exit().remove(),tt.merge(tt.enter().append("text").attr("class","polar-radius-label")).attr("x",v=>h(v)).attr("y",y[1]).attr("text-anchor","middle").attr("dy","-0.8em").attr("fill","currentColor").text(c.radiusTickFormat||(0,ZE.format)("~g"));let V=[];if(c.angularLabels&&A.length){let v=A.map(T=>T*E);for(let T of w){let d=[Math.cos(T)*Math.sign(M),Math.sin(T)*Math.sign(_)],S=Pv(y,d,v,e.width,e.height);S&&V.push(Object.assign({angle:T,direction:d},S))}}let W=a.selectAll("text.polar-angle-label").data(V,v=>v.angle);W.exit().remove(),W.merge(W.enter().append("text").attr("class","polar-angle-label")).attr("x",v=>v.position[0]).attr("y",v=>v.position[1]).attr("dx",v=>v.direction[0]*8).attr("dy",v=>v.direction[1]*8).attr("text-anchor",v=>v.textAnchor).attr("dominant-baseline","middle").attr("fill","currentColor").text(v=>{let T=c.angleUnit||KE,d=T==="degrees"?v.angle*180/Math.PI:v.angle;return c.angleTickFormat?c.angleTickFormat(d):kv(v.angle,T)}).each(function(v){let T=this.getBBox(),d=Math.max(0,-T.x)-Math.max(0,T.x+T.width-e.width),S=Math.max(0,-T.y)-Math.max(0,T.y+T.height-e.height);(0,JE.select)(this).attr("dx",v.direction[0]*8+d).attr("dy",v.direction[1]*8+S)})}yt.renderPolarGrid=nI});var Hv=O(Jr=>{"use strict";var Kr=Jr&&Jr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Jr,"__esModule",{value:!0});Jr.Chart=void 0;var rI=(ci(),it(fi)),iI=(yi(),it(Vu)),Cv=(tf(),it(Kl)),Lv=(Kd(),it(Jd)),yc=(Uy(),it(zy)),ou=(pt(),it(pe)),Dv=(Be(),it(Um)),oI=Kr(t_()),aI=Kr(e_()),sI=Kr(av()),uI=Kr(dc()),lI=Kr(ru()),au=Kr(zr()),_c=qv();function Rv(t){return t==="linear"?Cv.scaleLinear:Cv.scaleLog}function fI(t,e,n){var r,i;let o=f=>{let c=f[1]-f[0];return n*c/e},a=t.coordinateSystem==="polar"?(i=(r=t.polar)===null||r===void 0?void 0:r.radiusDomain)===null||i===void 0?void 0:i[1]:void 0,s=a===void 0?void 0:a*1.2,u=(()=>{if(t.xAxis.domain)return t.xAxis.domain;if(t.xAxis.type==="log")return[1,10];if(t.xAxis.type==="linear")return s===void 0?[-6,6]:[-s,s];throw new Error(`axis type ${t.xAxis.type} unsupported`)})(),l=(()=>{if(t.yAxis.domain)return t.yAxis.domain;if(t.yAxis.type==="log")return[1,10];if(t.yAxis.type==="linear"){if(s!==void 0)return[-s,s];let f=o(u);return[-f/2,f/2]}throw new Error(`axis type ${t.yAxis.type} unsupported`)})();return t.coordinateSystem==="polar"?(0,_c.getPolarDomains)(u,l,e,n):{xDomain:u,yDomain:l}}var su=class t extends oI.default.EventEmitter{constructor(e){super();let n=Math.random(),r=String.fromCharCode(Math.floor(n*26)+97);this.options=e,this.id=r+n.toString(16).substr(2),this.options.id=this.id,this.markerId=this.id+"-marker",t.cache[this.id]=this,this.linkedGraphs=[this],this.meta={},this.setUpEventListeners()}build(){return this.internalVars(),this.drawGraphWrapper(),this}getDraggableNode(){return(0,ou.select)(this.options.target).select(".zoom-and-drag").node()}getEmitInstance(){let e=this,n=this.getDraggableNode();return n&&(e=n.instance),e}internalVars(){let e=this.meta.margin=this.isPolarCoordinateSystem()?{left:0,right:0,top:0,bottom:0}:{left:40,right:20,top:20,bottom:20};this.options.title&&!this.isPolarCoordinateSystem()&&(this.meta.margin.top=40),this.meta.width=(this.options.width||au.default.DEFAULT_WIDTH)-e.left-e.right,this.meta.height=(this.options.height||au.default.DEFAULT_HEIGHT)-e.top-e.bottom,this.initializeAxes()}initializeAxes(){let e=this,n=(0,iI.format)("~s");function r(a){return Math.abs(a)-Math.floor(Math.abs(a))>0?a.toString():n(a)}if(this.options.coordinateSystem=this.options.coordinateSystem||"cartesian",this.options.xAxis=this.options.xAxis||{},this.options.xAxis.type=this.options.xAxis.type||"linear",this.options.yAxis=this.options.yAxis||{},this.options.yAxis.type=this.options.yAxis.type||"linear",this.options.coordinateSystem!=="cartesian"&&this.options.coordinateSystem!=="polar")throw new Error(`unsupported coordinate system ${this.options.coordinateSystem}`);this.options.coordinateSystem==="polar"&&(0,_c.validatePolarOptions)(this.options);let{xDomain:i,yDomain:o}=fI(this.options,this.meta.width,this.meta.height);this.meta.xDomain=i,this.meta.yDomain=o,this.meta.xScale||(this.meta.xScale=Rv(this.options.xAxis.type)()),this.meta.xScale.domain(i).range(this.options.xAxis.invert?[this.meta.width,0]:[0,this.meta.width]),this.meta.yScale||(this.meta.yScale=Rv(this.options.yAxis.type)()),this.meta.yScale.domain(o).range(this.options.yAxis.invert?[0,this.meta.height]:[this.meta.height,0]),this.meta.xAxis||(this.meta.xAxis=(0,Lv.axisBottom)(this.meta.xScale)),this.meta.xAxis.scale(this.meta.xScale).tickSize(this.options.grid?-this.meta.height:0).tickFormat(r),this.meta.yAxis||(this.meta.yAxis=(0,Lv.axisLeft)(this.meta.yScale)),this.meta.yAxis.scale(this.meta.yScale).tickSize(this.options.grid?-this.meta.width:0).tickFormat(r),this.line=(0,rI.line)().x(function(a){return e.meta.xScale(a[0])}).y(function(a){return e.meta.yScale(a[1])})}drawGraphWrapper(){let e=this.root=(0,ou.select)(this.options.target).selectAll("svg").data([this.options]);this.root.enter=e.enter().append("svg").attr("class","function-plot").attr("font-size",this.getFontSize()),e.merge(this.root.enter).attr("width",this.meta.width+this.meta.margin.left+this.meta.margin.right).attr("height",this.meta.height+this.meta.margin.top+this.meta.margin.bottom),this.buildTitle(),this.buildLegend(),this.buildCanvas(),this.buildClip(),this.buildAxis(),this.buildAxisLabel();let n=this.tip=(0,sI.default)(Object.assign(this.options.tip||{},{owner:this}));this.canvas.merge(this.canvas.enter).call(n),this.setUpPlugins(),this.draw(),this.buildZoomHelper()}buildTitle(){let e=this.root.merge(this.root.enter).selectAll("text.title").data(function(r){return[r.title].filter(Boolean)});e.enter().append("text").merge(e).attr("class","title").attr("y",this.isPolarCoordinateSystem()?20:this.meta.margin.top/2).attr("x",this.meta.margin.left+this.meta.width/2).attr("font-size",25).attr("text-anchor","middle").attr("alignment-baseline","middle").text(this.options.title),e.exit().remove()}buildLegend(){this.root.enter.append("text").attr("class","top-right-legend").attr("text-anchor","end"),this.root.merge(this.root.enter).select(".top-right-legend").attr("y",this.isPolarCoordinateSystem()?8:this.meta.margin.top/2).attr("x",this.meta.width+this.meta.margin.left-(this.isPolarCoordinateSystem()?8:0)).attr("dominant-baseline",this.isPolarCoordinateSystem()?"hanging":null)}buildCanvas(){let e=this.canvas=this.root.merge(this.root.enter).selectAll(".canvas").data(function(n){return[n]});this.canvas.enter=e.enter().append("g").attr("class","canvas")}buildClip(){let e=this.id,n=this.canvas.enter.append("defs");n.append("clipPath").attr("id","function-plot-clip-"+e).append("rect").attr("class","clip static-clip"),this.canvas.merge(this.canvas.enter).selectAll(".clip").attr("width",this.meta.width).attr("height",this.meta.height),n.append("clipPath").append("marker").attr("id",this.markerId).attr("viewBox","0 -5 10 10").attr("refX",10).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("svg:path").attr("d","M0,-5L10,0L0,5L0,0").attr("stroke-width","0px").attr("fill-opacity",1).attr("fill","#777")}buildAxis(){let e=this.canvas.enter;e.append("g").attr("class","x axis"),e.append("g").attr("class","y axis"),this.canvas.merge(this.canvas.enter).select(".x.axis").attr("transform","translate(0,"+this.meta.height+")").style("display",this.isPolarCoordinateSystem()?"none":null).call(this.meta.xAxis),this.canvas.merge(this.canvas.enter).select(".y.axis").style("display",this.isPolarCoordinateSystem()?"none":null).call(this.meta.yAxis)}buildAxisLabel(){let e=this.canvas,n=this,r=e.merge(e.enter).selectAll("text.x.axis-label").data(function(s){return n.isPolarCoordinateSystem()?[]:[s.xAxis.label].filter(Boolean)}),i=r.enter().append("text").attr("class","x axis-label").attr("text-anchor","end");r.merge(i).attr("x",this.meta.width).attr("y",this.meta.height-6).text(function(s){return s}),r.exit().remove();let o=e.merge(e.enter).selectAll("text.y.axis-label").data(function(s){return n.isPolarCoordinateSystem()?[]:[s.yAxis.label].filter(Boolean)}),a=o.enter().append("text").attr("class","y axis-label").attr("y",6).attr("dy",".75em").attr("text-anchor","end").attr("transform","rotate(-90)");o.merge(a).text(function(s){return s}),o.exit().remove()}buildContent(){let e=this,n=this.canvas;n.merge(n.enter).attr("transform","translate("+this.meta.margin.left+","+this.meta.margin.top+")");let r=this.content=n.merge(n.enter).selectAll(":scope > g.content").data(function(s){return[s]}),i=r.enter().append("g").attr("clip-path","url(#function-plot-clip-"+this.id+")").attr("class","content");if(this.options.xAxis.type==="linear"){let s=r.merge(i).selectAll(":scope > path.y.origin").data(this.isPolarCoordinateSystem()?[]:[[[0,this.meta.yScale.domain()[0]],[0,this.meta.yScale.domain()[1]]]]),u=s.enter().append("path").attr("class","y origin").attr("stroke","black").attr("opacity",.2);s.merge(u).attr("d",this.line),s.exit().remove()}if(this.options.yAxis.type==="linear"){let s=r.merge(i).selectAll(":scope > path.x.origin").data(this.isPolarCoordinateSystem()?[]:[[[this.meta.xScale.domain()[0],0],[this.meta.xScale.domain()[1],0]]]),u=s.enter().append("path").attr("class","x origin").attr("stroke","black").attr("opacity",.2);s.merge(u).attr("d",this.line),s.exit().remove()}r.merge(i).call((0,aI.default)({owner:e}));let o=r.merge(i).selectAll(":scope > g.graph").data(s=>s.data.map(lI.default),s=>s.fn||s.r||s.x||s.text);o.exit().remove();let a=o.enter().append("g").attr("class","graph");o.merge(a).each(function(s,u){s.index=u;let l=(0,ou.select)(this);l.call(au.default.graphTypes[s.graphType](e)),l.call((0,uI.default)(e))})}buildZoomHelper(){var e;let n=this;if(this.meta.zoomBehavior||(this.meta.zoomBehavior=(0,yc.zoom)().on("zoom",function(i){n.getEmitInstance().emit("all:zoom",i)})),this.isPolarCoordinateSystem()||this.getEmitInstance().options.lastCoordinateSystem==="polar"){let r=((e=this.getDraggableNode())===null||e===void 0?void 0:e.__zoom)||yc.zoomIdentity,i=yc.zoomIdentity.scale(1/r.k).translate(-r.x,-r.y);n.meta.zoomBehavior.xScale=i.rescaleX(n.meta.xScale),n.meta.zoomBehavior.yScale=i.rescaleY(n.meta.yScale)}else n.meta.zoomBehavior.xScale=n.meta.zoomBehavior.xScale||n.meta.xScale.copy(),n.meta.zoomBehavior.yScale=n.meta.zoomBehavior.yScale||n.meta.yScale.copy(),n.meta.zoomBehavior.xScale.range(n.meta.xScale.range()),n.meta.zoomBehavior.yScale.range(n.meta.yScale.range());this.canvas.enter.append("rect").call(this.meta.zoomBehavior).attr("class","zoom-and-drag").style("fill","none").style("pointer-events","all").on("mouseover",function(r){n.getEmitInstance().emit("all:mouseover",r)}).on("mouseout",function(r){n.getEmitInstance().emit("all:mouseout",r)}).on("mousemove",function(r){n.getEmitInstance().emit("all:mousemove",r)}),this.draggable=this.canvas.merge(this.canvas.enter).select(".zoom-and-drag").call(r=>{r.node()&&(r.node().instance=n)}).attr("width",this.meta.width).attr("height",this.meta.height),this.options.lastCoordinateSystem=this.options.coordinateSystem}setUpPlugins(){let e=this.options.plugins||[],n=this;e.forEach(function(r){r(n)})}addLink(){for(let e=0;ethis.meta.height?this.meta.height:s,n.select(".x.axis").attr("transform","translate(0,"+s+")"),n.selectAll(".x.axis path, .x.axis line").attr("transform","translate(0,"+(this.meta.height/2-s+this.meta.height/2)+")")}if(n.select(".y.axis").call(e.meta.yAxis),n.select(".y.axis").style("display",null),this.options.yAxis.position==="sticky"){let r=this.meta.xScale.domain()[0],i=this.meta.xScale.domain()[1],o=(i+r)/2,s=this.meta.width/(r-i)*o+this.meta.width/2;s=s<0?0:s,s=s>this.meta.width?this.meta.width:s,n.select(".y.axis").attr("transform","translate("+s+",0)"),n.selectAll(".y.axis path, .y.axis line").attr("transform","translate("+-s+",0)")}n.selectAll(".axis path, .axis line").attr("fill","none").attr("stroke","black").attr("shape-rendering","crispedges").attr("opacity",.1)}syncOptions(){this.options.xAxis.domain=this.meta.xScale.domain(),this.options.yAxis.domain=this.meta.yScale.domain()}getFontSize(){return Math.max(Math.max(this.meta.width,this.meta.height)/50,8)}draw(){let e=this;e.emit("before:draw"),e.syncOptions(),e.updateAxes(),e.buildContent(),e.emit("after:draw")}isPolarCoordinateSystem(){return this.options.coordinateSystem==="polar"}setUpEventListeners(){let e=this,n=this.getEmitInstance();n&&n.removeAllListeners();let r={mousemove:function(o){e.tip.move(o)},mouseover:function(){e.tip.show()},mouseout:function(){e.tip.hide()},zoom:function({transform:a}){if(e.options.disableZoom)return;let s=a.rescaleX(e.meta.zoomBehavior.xScale).interpolate(Dv.interpolateRound),u=a.rescaleY(e.meta.zoomBehavior.yScale).interpolate(Dv.interpolateRound);e.meta.xScale.domain(s.domain()).range(s.range()),e.meta.yScale.domain(u.domain()).range(u.range())},"tip:update":function({x:o,y:a,index:s}){let u=e.root.merge(e.root.enter).datum().data[s],l=u.title||"",f=u.renderer||function(h,m){return h.toFixed(3)+", "+m.toFixed(3)},c=[];l&&c.push(l),c.push(f(o,a)),e.root.select(".top-right-legend").attr("fill",au.default.COLORS[s]).text(c.join(" "))}},i={mousemove:function(o){let a=(0,ou.pointer)(o,e.draggable.node()),s={x:e.meta.xScale.invert(a[0]),y:e.meta.yScale.invert(a[1])};e.linkedGraphs.forEach(function(u){u.emit("before:mousemove",s),u.emit("mousemove",s)})},zoom:function(o){e.linkedGraphs.forEach(function(a){a.draggable.node().__zoom=e.draggable.node().__zoom,a.emit("zoom",o),a.draw()}),e.emit("all:mousemove",o)}};Object.keys(r).forEach(function(o){!i[o]&&e.on("all:"+o,function(){let a=Array.prototype.slice.call(arguments);e.linkedGraphs.forEach(function(s){let u=a.slice();u.unshift(o),s.emit.apply(s,u)})}),e.on(o,r[o])}),Object.keys(i).forEach(function(o){e.on("all:"+o,i[o])})}};Jr.Chart=su;su.cache={}});var Yv=O(Fv=>{"use strict";Object.defineProperty(Fv,"__esModule",{value:!0})});var Bv=O(nt=>{"use strict";var $v=nt&&nt.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),cI=nt&&nt.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),zv=nt&&nt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&$v(e,t,n);return cI(e,t),e},Uv=nt&&nt.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&$v(e,t,n)};Object.defineProperty(nt,"__esModule",{value:!0});nt.GraphTypeScatter=nt.GraphTypePolyline=nt.GraphTypeInterval=nt.EvalInterval=nt.EvalBuiltIn=nt.registerGraphType=nt.Chart=void 0;Sc();var xc=Hv();Object.defineProperty(nt,"Chart",{enumerable:!0,get:function(){return xc.Chart}});var ti=zv(zr());Object.defineProperty(nt,"registerGraphType",{enumerable:!0,get:function(){return ti.registerGraphType}});var nr=To(),hI=zv(Tn());(0,ti.registerGraphType)("polyline",nr.polyline);(0,ti.registerGraphType)("interval",nr.interval);(0,ti.registerGraphType)("scatter",nr.scatter);(0,ti.registerGraphType)("text",nr.text);function uu(t){t.data=t.data||[];let e=xc.Chart.cache[t.id];return e||(e=new xc.Chart(t)),e.build()}nt.default=uu;uu.globals=ti.default;uu.$eval=hI;uu.graphTypes={interval:nr.interval,polyline:nr.polyline,scatter:nr.scatter};Uv(Yv(),nt);var jv=Tn();Object.defineProperty(nt,"EvalBuiltIn",{enumerable:!0,get:function(){return jv.builtIn}});Object.defineProperty(nt,"EvalInterval",{enumerable:!0,get:function(){return jv.interval}});var vc=To();Object.defineProperty(nt,"GraphTypeInterval",{enumerable:!0,get:function(){return vc.interval}});Object.defineProperty(nt,"GraphTypePolyline",{enumerable:!0,get:function(){return vc.polyline}});Object.defineProperty(nt,"GraphTypeScatter",{enumerable:!0,get:function(){return vc.scatter}});Uv(dc(),nt)});var wc=Tc(Bv()),Xv=Tc(Ks());wc.default.intervalMath=Xv.Interval;window.functionPlot=wc.default;})(); diff --git a/public/function-plot/README.md b/public/function-plot/README.md new file mode 100644 index 00000000..40ede3ea --- /dev/null +++ b/public/function-plot/README.md @@ -0,0 +1,34 @@ +# function-plot vendor bundle + +Pinned upstream: [function-plot 1.26.0](https://github.com/mauriciopoppe/function-plot/tree/v1.26.0) +(MIT). The bundle and bundled dependencies' licence notices live in `1.26.0/`. + +This browser build exposes `window.functionPlot` and the interval arithmetic +already used by function-plot as `functionPlot.intervalMath`. The application +passes trusted numeric/interval callbacks; it never calls the library's expression +code generators with post content. No second plotting library is bundled. + +Rebuild from this directory: + +```sh +cd build +pnpm install --frozen-lockfile +pnpm build +``` + +`build/entry.js`, the pinned manifest and pnpm lockfile document the inputs. +`build/build.mjs` bundles the library and writes `THIRD-PARTY-LICENSES.txt` from +the packages actually included. Some upstream MIT packages omit their LICENSE +file from npm; the build preserves their published copyright notices with the MIT +licence text. esbuild's optional native binary is installed by pnpm; no postinstall +approval is required to run this build. + +The current artifact is 228,019 bytes (68,442 bytes with gzip). +SHA-256 of `1.26.0/function-plot.js`: + +```text +85a5b7eeb2827bfd3194c7f7684465b5dff5b48a8b432682b820dd4e5794009e +``` + +After dependency/build changes, regenerate the notices, update this checksum and +rerun the expression/interval tests and browser graph tests under Discourse's CSP. diff --git a/public/function-plot/build/build.mjs b/public/function-plot/build/build.mjs new file mode 100644 index 00000000..1d31cb76 --- /dev/null +++ b/public/function-plot/build/build.mjs @@ -0,0 +1,53 @@ +import fs from "node:fs"; +import path from "node:path"; +import { build } from "esbuild"; + +const output = "../1.26.0"; +const result = await build({ + entryPoints: ["entry.js"], + outfile: `${output}/function-plot.js`, + bundle: true, + minify: true, + format: "iife", + target: "es2022", + legalComments: "inline", + metafile: true, +}); + +const packages = new Map(); +for (const input of Object.keys(result.metafile.inputs)) { + let directory = path.dirname(fs.realpathSync(input)); + while (!fs.existsSync(path.join(directory, "package.json"))) { + directory = path.dirname(directory); + } + const metadata = JSON.parse( + fs.readFileSync(path.join(directory, "package.json")) + ); + if (metadata.name === "chatbot-function-plot-vendor") { + continue; + } + const license = fs + .readdirSync(directory) + .find((name) => /^license(?:\..*)?$/i.test(name)); + let text; + if (license) { + text = fs.readFileSync(path.join(directory, license), "utf8"); + } else if ( + ["built-in-math-eval", "interval-arithmetic-eval", "mr-parser"].includes( + metadata.name + ) + ) { + // These published packages omit LICENSE but retain this notice in index.js. + text = fs + .readFileSync(path.join(output, "LICENSE"), "utf8") + .replace(/Copyright[^\n]*/, "Copyright (c) 2015 Mauricio Poppe"); + } else { + throw new Error(`Missing license for ${metadata.name}`); + } + packages.set(`${metadata.name}@${metadata.version}`, text.trim()); +} +const notices = [...packages] + .sort(([left], [right]) => left.localeCompare(right)) + .map(([name, text]) => `${name}\n${text}`) + .join("\n\n"); +fs.writeFileSync(`${output}/THIRD-PARTY-LICENSES.txt`, `${notices}\n`); diff --git a/public/function-plot/build/entry.js b/public/function-plot/build/entry.js new file mode 100644 index 00000000..41f73386 --- /dev/null +++ b/public/function-plot/build/entry.js @@ -0,0 +1,6 @@ +import functionPlot from "function-plot"; +import { Interval } from "interval-arithmetic-eval"; + +// Expose the interval arithmetic already used by the sampler for trusted callbacks. +functionPlot.intervalMath = Interval; +window.functionPlot = functionPlot; diff --git a/public/function-plot/build/package.json b/public/function-plot/build/package.json new file mode 100644 index 00000000..ed3bc1bf --- /dev/null +++ b/public/function-plot/build/package.json @@ -0,0 +1,12 @@ +{ + "dependencies": { + "esbuild": "0.25.10", + "function-plot": "1.26.0", + "interval-arithmetic-eval": "0.5.3" + }, + "name": "chatbot-function-plot-vendor", + "private": true, + "scripts": { + "build": "node build.mjs" + } +} diff --git a/public/function-plot/build/pnpm-lock.yaml b/public/function-plot/build/pnpm-lock.yaml new file mode 100644 index 00000000..1d71ab19 --- /dev/null +++ b/public/function-plot/build/pnpm-lock.yaml @@ -0,0 +1,508 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + esbuild: + specifier: 0.25.10 + version: 0.25.10 + function-plot: + specifier: 1.26.0 + version: 1.26.0 + interval-arithmetic-eval: + specifier: 0.5.3 + version: 0.5.3 + +packages: + + '@esbuild/aix-ppc64@0.25.10': + resolution: {integrity: sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.25.10': + resolution: {integrity: sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.25.10': + resolution: {integrity: sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.25.10': + resolution: {integrity: sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.25.10': + resolution: {integrity: sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.25.10': + resolution: {integrity: sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.25.10': + resolution: {integrity: sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.25.10': + resolution: {integrity: sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.25.10': + resolution: {integrity: sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.25.10': + resolution: {integrity: sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.25.10': + resolution: {integrity: sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.25.10': + resolution: {integrity: sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.25.10': + resolution: {integrity: sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.25.10': + resolution: {integrity: sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.25.10': + resolution: {integrity: sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.25.10': + resolution: {integrity: sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.25.10': + resolution: {integrity: sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.25.10': + resolution: {integrity: sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.25.10': + resolution: {integrity: sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.25.10': + resolution: {integrity: sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.25.10': + resolution: {integrity: sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.25.10': + resolution: {integrity: sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.25.10': + resolution: {integrity: sha512-fswk3XT0Uf2pGJmOpDB7yknqhVkJQkAQOcW/ccVOtfx05LkbWOaRAtn5SaqXypeKQra1QaEa841PgrSL9ubSPQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.25.10': + resolution: {integrity: sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.25.10': + resolution: {integrity: sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.25.10': + resolution: {integrity: sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + built-in-math-eval@0.3.2: + resolution: {integrity: sha512-YUEswPdQJYtAP0E9pMq7va05M6iA/8U3Pthnlx+fwbej1G16hy/ZBxyLw+gZpxdijjGGqiwxm7vs3tW7IQuUnw==} + + d3-array@3.2.4: + resolution: {integrity: sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==} + engines: {node: '>=12'} + + d3-axis@3.0.0: + resolution: {integrity: sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==} + engines: {node: '>=12'} + + d3-color@3.1.0: + resolution: {integrity: sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==} + engines: {node: '>=12'} + + d3-dispatch@3.0.1: + resolution: {integrity: sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==} + engines: {node: '>=12'} + + d3-drag@3.0.0: + resolution: {integrity: sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==} + engines: {node: '>=12'} + + d3-ease@3.0.1: + resolution: {integrity: sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==} + engines: {node: '>=12'} + + d3-format@3.1.2: + resolution: {integrity: sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==} + engines: {node: '>=12'} + + d3-interpolate@3.0.1: + resolution: {integrity: sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==} + engines: {node: '>=12'} + + d3-path@3.1.0: + resolution: {integrity: sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==} + engines: {node: '>=12'} + + d3-scale@4.0.2: + resolution: {integrity: sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==} + engines: {node: '>=12'} + + d3-selection@3.0.0: + resolution: {integrity: sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==} + engines: {node: '>=12'} + + d3-shape@3.2.0: + resolution: {integrity: sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==} + engines: {node: '>=12'} + + d3-time-format@4.1.0: + resolution: {integrity: sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==} + engines: {node: '>=12'} + + d3-time@3.1.0: + resolution: {integrity: sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==} + engines: {node: '>=12'} + + d3-timer@3.0.1: + resolution: {integrity: sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==} + engines: {node: '>=12'} + + d3-transition@3.0.1: + resolution: {integrity: sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==} + engines: {node: '>=12'} + peerDependencies: + d3-selection: 2 - 3 + + d3-zoom@3.0.0: + resolution: {integrity: sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==} + engines: {node: '>=12'} + + double-bits@1.1.1: + resolution: {integrity: sha512-BCLEIBq0O/DWoA7BsCu/R+RP0ZXiowP8BhtJT3qeuuQEBpnS8LK/Wo6UTJQv6v8mK1fj8n90YziHLwGdM5whSg==} + + esbuild@0.25.10: + resolution: {integrity: sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==} + engines: {node: '>=18'} + hasBin: true + + events@3.3.0: + resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} + engines: {node: '>=0.8.x'} + + extend@3.0.2: + resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} + + function-plot@1.26.0: + resolution: {integrity: sha512-cCtvNF7n3UOw883Z0tYGG5zElLDLPFI2mlq7Gg3YDToPvSBFEvU4IIPZTuYIU+1BcbeBSpmlCdrYbmkWf12pGg==} + + internmap@2.0.3: + resolution: {integrity: sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==} + engines: {node: '>=12'} + + interval-arithmetic-eval@0.5.3: + resolution: {integrity: sha512-8cR5Uerz+h1yDpb8Y2z3XfnI0XOnmWapI1CP/j84EKVocr6m6/rziLU558Vi7VGh4Bgfv9VeoOQAjDV4And+tg==} + + interval-arithmetic@1.1.3: + resolution: {integrity: sha512-RdEKOQPUky8ShFdKnsOzXXO7LMaCfZtW9Z6t6LugIWgxU1pty4KEo7hpcIDcg3CYZ2iso9fPUiQPPdhsAhaLSQ==} + + math-codegen@0.4.3: + resolution: {integrity: sha512-wDPK9BputFrirD7dXgpeIa1nkTy08Gh+nCALwEmmHSmKoCJtTYu1PjGC6Z08FmCjkHzVkhvep2mzyJWRgtOe5A==} + + mr-parser@0.2.2: + resolution: {integrity: sha512-9pMgttJp8pZtiYfoHkhBc9ncOHKmEwLMNBQpS/ZXgj4ORnPMKznYR0lZ1We3ZrD71RevQ34hKyKzDV1p/agXuw==} + + nextafter@1.0.0: + resolution: {integrity: sha512-7PO+A89Tll2rSEfyrjtqO0MaI37+nnxBdnQcPypfbEYYuGaJxWGCqaOwQX4a3GHNTS08l1kazuiLEWZniZjMUQ==} + +snapshots: + + '@esbuild/aix-ppc64@0.25.10': + optional: true + + '@esbuild/android-arm64@0.25.10': + optional: true + + '@esbuild/android-arm@0.25.10': + optional: true + + '@esbuild/android-x64@0.25.10': + optional: true + + '@esbuild/darwin-arm64@0.25.10': + optional: true + + '@esbuild/darwin-x64@0.25.10': + optional: true + + '@esbuild/freebsd-arm64@0.25.10': + optional: true + + '@esbuild/freebsd-x64@0.25.10': + optional: true + + '@esbuild/linux-arm64@0.25.10': + optional: true + + '@esbuild/linux-arm@0.25.10': + optional: true + + '@esbuild/linux-ia32@0.25.10': + optional: true + + '@esbuild/linux-loong64@0.25.10': + optional: true + + '@esbuild/linux-mips64el@0.25.10': + optional: true + + '@esbuild/linux-ppc64@0.25.10': + optional: true + + '@esbuild/linux-riscv64@0.25.10': + optional: true + + '@esbuild/linux-s390x@0.25.10': + optional: true + + '@esbuild/linux-x64@0.25.10': + optional: true + + '@esbuild/netbsd-arm64@0.25.10': + optional: true + + '@esbuild/netbsd-x64@0.25.10': + optional: true + + '@esbuild/openbsd-arm64@0.25.10': + optional: true + + '@esbuild/openbsd-x64@0.25.10': + optional: true + + '@esbuild/openharmony-arm64@0.25.10': + optional: true + + '@esbuild/sunos-x64@0.25.10': + optional: true + + '@esbuild/win32-arm64@0.25.10': + optional: true + + '@esbuild/win32-ia32@0.25.10': + optional: true + + '@esbuild/win32-x64@0.25.10': + optional: true + + built-in-math-eval@0.3.2: + dependencies: + math-codegen: 0.4.3 + + d3-array@3.2.4: + dependencies: + internmap: 2.0.3 + + d3-axis@3.0.0: {} + + d3-color@3.1.0: {} + + d3-dispatch@3.0.1: {} + + d3-drag@3.0.0: + dependencies: + d3-dispatch: 3.0.1 + d3-selection: 3.0.0 + + d3-ease@3.0.1: {} + + d3-format@3.1.2: {} + + d3-interpolate@3.0.1: + dependencies: + d3-color: 3.1.0 + + d3-path@3.1.0: {} + + d3-scale@4.0.2: + dependencies: + d3-array: 3.2.4 + d3-format: 3.1.2 + d3-interpolate: 3.0.1 + d3-time: 3.1.0 + d3-time-format: 4.1.0 + + d3-selection@3.0.0: {} + + d3-shape@3.2.0: + dependencies: + d3-path: 3.1.0 + + d3-time-format@4.1.0: + dependencies: + d3-time: 3.1.0 + + d3-time@3.1.0: + dependencies: + d3-array: 3.2.4 + + d3-timer@3.0.1: {} + + d3-transition@3.0.1(d3-selection@3.0.0): + dependencies: + d3-color: 3.1.0 + d3-dispatch: 3.0.1 + d3-ease: 3.0.1 + d3-interpolate: 3.0.1 + d3-selection: 3.0.0 + d3-timer: 3.0.1 + + d3-zoom@3.0.0: + dependencies: + d3-dispatch: 3.0.1 + d3-drag: 3.0.0 + d3-interpolate: 3.0.1 + d3-selection: 3.0.0 + d3-transition: 3.0.1(d3-selection@3.0.0) + + double-bits@1.1.1: {} + + esbuild@0.25.10: + optionalDependencies: + '@esbuild/aix-ppc64': 0.25.10 + '@esbuild/android-arm': 0.25.10 + '@esbuild/android-arm64': 0.25.10 + '@esbuild/android-x64': 0.25.10 + '@esbuild/darwin-arm64': 0.25.10 + '@esbuild/darwin-x64': 0.25.10 + '@esbuild/freebsd-arm64': 0.25.10 + '@esbuild/freebsd-x64': 0.25.10 + '@esbuild/linux-arm': 0.25.10 + '@esbuild/linux-arm64': 0.25.10 + '@esbuild/linux-ia32': 0.25.10 + '@esbuild/linux-loong64': 0.25.10 + '@esbuild/linux-mips64el': 0.25.10 + '@esbuild/linux-ppc64': 0.25.10 + '@esbuild/linux-riscv64': 0.25.10 + '@esbuild/linux-s390x': 0.25.10 + '@esbuild/linux-x64': 0.25.10 + '@esbuild/netbsd-arm64': 0.25.10 + '@esbuild/netbsd-x64': 0.25.10 + '@esbuild/openbsd-arm64': 0.25.10 + '@esbuild/openbsd-x64': 0.25.10 + '@esbuild/openharmony-arm64': 0.25.10 + '@esbuild/sunos-x64': 0.25.10 + '@esbuild/win32-arm64': 0.25.10 + '@esbuild/win32-ia32': 0.25.10 + '@esbuild/win32-x64': 0.25.10 + + events@3.3.0: {} + + extend@3.0.2: {} + + function-plot@1.26.0: + dependencies: + built-in-math-eval: 0.3.2 + d3-axis: 3.0.0 + d3-color: 3.1.0 + d3-format: 3.1.2 + d3-interpolate: 3.0.1 + d3-scale: 4.0.2 + d3-selection: 3.0.0 + d3-shape: 3.2.0 + d3-zoom: 3.0.0 + events: 3.3.0 + interval-arithmetic-eval: 0.5.3 + + internmap@2.0.3: {} + + interval-arithmetic-eval@0.5.3: + dependencies: + interval-arithmetic: 1.1.3 + math-codegen: 0.4.3 + + interval-arithmetic@1.1.3: + dependencies: + nextafter: 1.0.0 + + math-codegen@0.4.3: + dependencies: + extend: 3.0.2 + mr-parser: 0.2.2 + + mr-parser@0.2.2: {} + + nextafter@1.0.0: + dependencies: + double-bits: 1.1.1 diff --git a/spec/lib/bot_function_plot_spec.rb b/spec/lib/bot_function_plot_spec.rb new file mode 100644 index 00000000..a83f9734 --- /dev/null +++ b/spec/lib/bot_function_plot_spec.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +require_relative "../plugin_helper" +require "openai" + +describe DiscourseChatbot::Bot do + let(:client) { mock } + let(:requests) { [] } + + before do + SiteSetting.chatbot_tools_low_trust = "plot_function" + SiteSetting.chatbot_open_ai_model_low_trust = "gpt-4.1-mini" + OpenAI::Client.stubs(:new).returns(client) + end + + it "uses the graph tool and returns a maths explanation accompanied by the prepared block" do + graph = DiscourseChatbot::FunctionPlot.markdown("expressions" => "x^2-4") + answer = "The roots of $x^2-4=0$ are $x=\\pm2$.\n\n#{graph}" + client + .expects(:chat) + .twice + .with do |parameters:| + requests << parameters.deep_dup + true + end + .returns( + { + "choices" => [ + { + "finish_reason" => "tool_calls", + "message" => { + "content" => "", + "tool_calls" => [ + { + "id" => "call_graph", + "type" => "function", + "function" => { + "name" => "plot_function", + "arguments" => '{"expressions":"x^2-4"}', + }, + }, + ], + }, + }, + ], + "usage" => { + "total_tokens" => 10, + }, + }, + { + "choices" => [{ "finish_reason" => "stop", "message" => { "content" => answer } }], + "usage" => { + "total_tokens" => 10, + }, + }, + ) + + result = + described_class.new({}).get_response( + [{ role: "user", content: "Explain the roots of x squared minus four" }], + {}, + ) + + expect(requests.first[:tools].map { |tool| tool[:function]["name"] }).to eq(["plot_function"]) + expect(requests.last[:messages].find { |message| message[:role] == "tool" }[:content]).to eq( + graph, + ) + expect(result[:reply]).to eq(answer) + expect(result[:inner_thoughts].find { |entry| entry[:role] == "tool" }[:content]).to eq(graph) + end + + it "exposes the graph tool only when rendering is enabled and the trust level permits it" do + tool_sets = [] + client + .expects(:chat) + .times(3) + .with do |parameters:| + tool_sets << Array(parameters[:tools]).map { |tool| tool[:function]["name"] } + true + end + .returns( + "choices" => [{ "finish_reason" => "stop", "message" => { "content" => "Done." } }], + "usage" => { + "total_tokens" => 10, + }, + ) + + described_class.new({}).get_response([{ role: "user", content: "Plot x" }], {}) + SiteSetting.chatbot_function_plot_enabled = false + described_class.new({}).get_response([{ role: "user", content: "Plot x" }], {}) + SiteSetting.chatbot_function_plot_enabled = true + SiteSetting.chatbot_tools_low_trust = "calculate" + described_class.new({}).get_response([{ role: "user", content: "Plot x" }], {}) + + expect(tool_sets).to eq([["plot_function"], [], ["calculate"]]) + end +end diff --git a/spec/lib/site_setting_dependencies_spec.rb b/spec/lib/site_setting_dependencies_spec.rb index fae5bc10..f375156b 100644 --- a/spec/lib/site_setting_dependencies_spec.rb +++ b/spec/lib/site_setting_dependencies_spec.rb @@ -178,7 +178,7 @@ end it "selects the core tools by default at every trust level" do - expected_tools = %w[calculate remaining_bot_quota local_forum_search] + expected_tools = %w[calculate plot_function remaining_bot_quota local_forum_search] configured_settings = YAML.safe_load_file( File.expand_path("../../config/settings.yml", __dir__), diff --git a/spec/lib/tools/function_plot_spec.rb b/spec/lib/tools/function_plot_spec.rb new file mode 100644 index 00000000..d6e026ef --- /dev/null +++ b/spec/lib/tools/function_plot_spec.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true + +require_relative "../../plugin_helper" + +describe DiscourseChatbot::Tools::FunctionPlot do + let(:tool) { described_class.new } + + it "returns a renderable graph block for multiple curves at no external API quota cost" do + result = + tool.process( + "expressions" => "sin(x)\ncos(x)", + "title" => "Sine and cosine", + "x_min" => -7, + "x_max" => 7, + "y_min" => -1.5, + "y_max" => 1.5, + ) + + expect(result[:token_usage]).to eq(0) + expect(result[:answer]).to start_with("```function-plot\n") + expect(result[:answer]).to end_with("\n```") + expect(JSON.parse(result[:answer].lines[1])).to eq( + "functions" => %w[sin(x) cos(x)], + "title" => "Sine and cosine", + "x_domain" => [-7, 7], + "y_domain" => [-1.5, 1.5], + ) + end + + it "accepts supported mathematical functions, powers and constants without evaluating a domain" do + %w[ + x^2-4 + -x^2 + 2^-x + 1/x + sqrt(x) + cbrt(x) + log(x) + log10(x) + exp(x) + abs(x) + floor(x) + ceil(x) + asin(x) + acos(x) + atan(x) + tan(x) + pi*x + e^x + 1e3*x + ].each do |expression| + result = tool.process("expressions" => expression) + expect(result[:answer]).to start_with("```function-plot\n"), expression + end + end + + it "prepares each additional 2D family through the same compact tool" do + cases = [ + ["implicit", "x^2+y^2-4", "functions", ["x^2+y^2-4"]], + ["parametric", "cos(t); sin(t)", "functions", [%w[cos(t) sin(t)]]], + ["polar", "2*cos(3*theta)", "functions", ["2*cos(3*theta)"]], + ["points", "0,1\n2,3", "points", [[0, 1], [2, 3]]], + ["polyline", "0,1\n2,3", "points", [[0, 1], [2, 3]]], + ["vector", "3,2\n1,1,-2,1", "vectors", [[0, 0, 3, 2], [1, 1, -2, 1]]], + ] + cases.each do |type, expressions, key, expected| + result = tool.process("plot_type" => type, "expressions" => expressions) + graph = JSON.parse(result[:answer].lines[1]) + expect(graph).to include("plot_type" => type, key => expected) + if %w[parametric polar].include?(type) + expect(graph["parameter_range"]).to eq([0, 2 * Math::PI]) + end + expect(result[:token_usage]).to eq(0) + end + expect(tool.parameters.map { |parameter| parameter[:name] }).to eq( + %w[expressions title plot_type x_min x_max y_min y_max parameter_min parameter_max], + ) + end + + it "uses parameter bounds for trajectories and ignores placeholders for ordinary functions" do + args = { + "expressions" => "exp(-0.15*x)*sin(3*x)\nexp(-0.15*x)\n-exp(-0.15*x)", + "parameter_min" => 0, + "parameter_max" => 0, + } + graph = JSON.parse(tool.process(args)[:answer].lines[1]) + expect(graph["functions"].length).to eq(3) + expect(graph).not_to have_key("parameter_range") + + graph = + JSON.parse( + tool.process( + "plot_type" => "polar", + "expressions" => "theta", + "parameter_min" => -2, + "parameter_max" => 4, + )[ + :answer + ].lines[ + 1 + ], + ) + expect(graph["parameter_range"]).to eq([-2, 4]) + end + + it "rejects unsafe, malformed and oversized graph requests with correction guidance" do + invalid = [ + {}, + { "expressions" => "" }, + { "expressions" => "x\nx\nx\nx\nx" }, + { "expressions" => "x" * 257 }, + { "expressions" => "(" * 17 + "x" + ")" * 17 }, + { "expressions" => "window.alert(1)" }, + { "expressions" => "x;alert(1)" }, + { "expressions" => "constructor(x)" }, + { "expressions" => "x=1" }, + { "expressions" => "y=x^2" }, + { "expressions" => "sin(" }, + { "expressions" => "x", "x_min" => 0 }, + { "expressions" => "x", "x_min" => 10, "x_max" => 0 }, + { "expressions" => "x", "y_min" => -Float::INFINITY, "y_max" => 10 }, + { "expressions" => "x", "x_min" => -10, "x_max" => 1_000_001 }, + { "expressions" => "x", "title" => "a" * 121 }, + { "expressions" => "x", "unexpected" => "value" }, + { "expressions" => "y" }, + { "expressions" => "x", "plot_type" => "surface" }, + { "expressions" => "x", "plot_type" => "polar" }, + { "expressions" => "t", "plot_type" => "parametric" }, + { "expressions" => "t; t; t", "plot_type" => "parametric" }, + { "expressions" => "t; y", "plot_type" => "parametric" }, + { "expressions" => "x\ny\nx+y", "plot_type" => "implicit" }, + { "expressions" => "theta", "plot_type" => "polar", "parameter_min" => 0 }, + { + "expressions" => "theta", + "plot_type" => "polar", + "parameter_min" => 0, + "parameter_max" => 0, + }, + { "expressions" => "0,NaN", "plot_type" => "points" }, + { "expressions" => "0,1e309", "plot_type" => "points" }, + { "expressions" => "0,1000001", "plot_type" => "points" }, + { "expressions" => "0,1,2", "plot_type" => "polyline" }, + { "expressions" => "0,1,2", "plot_type" => "vector" }, + { "expressions" => "0,", "plot_type" => "points" }, + { "expressions" => "0,2*x", "plot_type" => "points" }, + { "expressions" => "0,1\n" * 151, "plot_type" => "points" }, + { "expressions" => "0,1\n" * 17, "plot_type" => "vector" }, + ] + invalid.each do |arguments| + expect(tool.process(arguments)).to eq( + answer: I18n.t("chatbot.prompt.function.function_plot.error"), + token_usage: 0, + ), + arguments.inspect + end + end + + it "escapes graph contents during cooking and preserves the fallback definition" do + result = tool.process("expressions" => "x^2", "title" => "") + cooked = Nokogiri::HTML5.fragment(PrettyText.cook(result[:answer])) + + expect(cooked.css("script")).to be_empty + expect(cooked.at_css("pre code.lang-function-plot").text).to include( + '"functions":["x^2"]', + "", + ) + end +end diff --git a/spec/system/page_objects/components/function_plots.rb b/spec/system/page_objects/components/function_plots.rb new file mode 100644 index 00000000..879ace25 --- /dev/null +++ b/spec/system/page_objects/components/function_plots.rb @@ -0,0 +1,129 @@ +# frozen_string_literal: true + +module PageObjects + module Components + class FunctionPlots < PageObjects::Components::Base + def has_rendered_graphs?(count:) + page.has_css?(".chatbot-function-plot__canvas svg", count: count) && + page.has_css?(".chatbot-function-plot__canvas .graph", minimum: count) + end + + def has_error? + page.has_css?( + ".chatbot-function-plot__error", + text: I18n.t("js.chatbot.function_plot.error"), + ) + end + + def has_no_error? + page.has_no_css?(".chatbot-function-plot__error") + end + + def has_separate_domain_segments? + page.has_css?(".chatbot-function-plot__canvas .graph path.line-0", count: 2) + end + + def move_over_2d_plot(relative_x:) + page.driver.with_playwright_page do |browser_page| + canvas = browser_page.locator(".chatbot-function-plot__canvas .zoom-and-drag").first + canvas.scroll_into_view_if_needed + box = canvas.bounding_box + browser_page.mouse.move( + box["x"] + box["width"] * relative_x, + box["y"] + box["height"] / 2, + ) + end + end + + def leave_plot + page.driver.with_playwright_page do |browser_page| + browser_page.mouse.move(browser_page.evaluate("window.innerWidth") - 40, 500) + end + end + + def has_trace_points?(count:) + page.has_css?(".chatbot-function-plot__trace-point", count: count) + end + + def has_trace_values?(count:) + page.has_css?(".chatbot-function-plot__coordinates:not(:empty)", count: count) + end + + def trace_coordinates + all(".chatbot-function-plot__coordinates", visible: :all).map do |readout| + readout + .text + .match(/x = ([+-]?\d+(?:\.\d+)?), y = ([+-]?\d+(?:\.\d+)?)/) + &.captures + &.map(&:to_f) + end + end + + def trace_point_positions + all(".chatbot-function-plot__trace-point").map { |point| [point[:cx], point[:cy]] } + end + + def has_implicit_curve? + page.has_css?("[data-plot-type='implicit'] .graph path", minimum: 1) + end + + def has_scatter_points?(count:) + page.has_css?("[data-plot-type='points'] .graph circle", count: count) + end + + def has_vector_arrows?(count:) + page.has_css?("[data-plot-type='vector'] .graph path[marker-end^='url']", count: count) + end + + def has_finite_paths? + all(".chatbot-function-plot__canvas .graph path").all? do |path| + path[:d].present? && !path[:d].match?(/NaN|Infinity/) + end + end + + def has_no_visible_canvas? + page.has_no_css?(".chatbot-function-plot__canvas") + end + + def pan_plot + page.driver.with_playwright_page do |browser_page| + canvas = browser_page.locator(".chatbot-function-plot__canvas .zoom-and-drag").first + canvas.scroll_into_view_if_needed + box = canvas.bounding_box + browser_page.mouse.move(box["x"] + 200, box["y"] + 150) + browser_page.mouse.down + browser_page.mouse.move(box["x"] + 280, box["y"] + 190, steps: 10) + browser_page.mouse.up + end + end + + def curve_path + find(".chatbot-function-plot__canvas .graph path.line", match: :first)[:d] + end + + def zoom_plot(delta_y: -300) + page.driver.with_playwright_page do |browser_page| + canvas = browser_page.locator(".chatbot-function-plot__canvas .zoom-and-drag").first + box = canvas.bounding_box + browser_page.mouse.move(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2) + browser_page.mouse.wheel(0, delta_y) + end + end + + def page_scroll_position + page.evaluate_async_script(<<~JS) + const done = arguments[0]; + requestAnimationFrame(() => requestAnimationFrame(() => done(window.scrollY))); + JS + end + + def scroll_outside_plot + page.driver.with_playwright_page do |browser_page| + viewport_width = browser_page.evaluate("window.innerWidth") + browser_page.mouse.move(viewport_width - 40, 500) + browser_page.mouse.wheel(0, 300) + end + end + end + end +end diff --git a/spec/system/read_function_plots_spec.rb b/spec/system/read_function_plots_spec.rb new file mode 100644 index 00000000..da4970ed --- /dev/null +++ b/spec/system/read_function_plots_spec.rb @@ -0,0 +1,174 @@ +# frozen_string_literal: true + +require_relative "page_objects/components/function_plots" + +RSpec.describe "Read function plots" do + fab!(:user) + fab!(:topic) + + let(:topic_page) { PageObjects::Pages::Topic.new } + let(:graphs) { PageObjects::Components::FunctionPlots.new } + + before do + enable_current_plugin + SiteSetting.chatbot_enabled = true + SiteSetting.chatbot_function_plot_enabled = true + sign_in(user) + end + + it "lets readers see mathematical explanations with multiple locally rendered curves" do + polynomial = + DiscourseChatbot::FunctionPlot.markdown( + "expressions" => "x^2-4", + "title" => "Roots of a quadratic", + ) + trig = + DiscourseChatbot::FunctionPlot.markdown( + "expressions" => "sin(x)\ncos(x)", + "y_min" => -2, + "y_max" => 2, + ) + Fabricate( + :post, + topic: topic, + raw: "The roots of $x^2-4=0$ are $x=\\pm2$.\n\n#{polynomial}\n\n#{trig}", + ) + + topic_page.visit_topic(topic) + + expect(topic_page).to have_content("The roots of") + expect(graphs).to have_rendered_graphs(count: 2) + expect(topic_page).to have_content("Roots of a quadratic") + + page.refresh + expect(graphs).to have_rendered_graphs(count: 2) + end + + it "shows a useful fallback for an unsupported expression without executing it" do + Fabricate( + :post, + topic: topic, + raw: "```function-plot\n{\"functions\":[\"window.alert(1)\"]}\n```", + ) + + topic_page.visit_topic(topic) + + expect(graphs).to have_error + expect(topic_page).to have_content(I18n.t("js.chatbot.function_plot.fallback")) + end + + it "traces visible curves and snaps to axes and series intersections" do + graph = + DiscourseChatbot::FunctionPlot.markdown( + "expressions" => "x^2\nsqrt(x)", + "x_min" => -2, + "x_max" => 2, + "y_min" => -1, + "y_max" => 5, + ) + Fabricate(:post, topic: topic, raw: graph) + topic_page.visit_topic(topic) + + expect(graphs).to have_rendered_graphs(count: 1) + graphs.move_over_2d_plot(relative_x: 0.755) + expect(graphs).to have_trace_points(count: 2) + expect(graphs).to have_trace_values(count: 2) + expect(graphs.trace_coordinates).to eq([[1, 1], [1, 1]]) + expect(graphs.trace_point_positions.uniq.length).to eq(1) + initial_positions = graphs.trace_point_positions + + graphs.move_over_2d_plot(relative_x: 0.875) + try_until_success { expect(graphs.trace_coordinates.first[0]).to be_within(0.03).of(1.5) } + expect(graphs.trace_coordinates.first[1]).to be_within(0.04).of(2.25) + expect(graphs.trace_point_positions).not_to eq(initial_positions) + + graphs.move_over_2d_plot(relative_x: 0.25) + expect(graphs).to have_trace_points(count: 1) + expect(graphs).to have_trace_values(count: 1) + expect(graphs.trace_coordinates.last).to be_nil + + graphs.move_over_2d_plot(relative_x: 0.502) + expect(graphs).to have_trace_points(count: 2) + expect(graphs).to have_trace_values(count: 2) + expect(graphs.trace_coordinates.first).to eq([0, 0]) + expect(graphs.trace_coordinates[1]).to eq([0, 0]) + + graphs.leave_plot + expect(graphs).to have_trace_points(count: 0) + expect(graphs).to have_trace_values(count: 0) + end + + it "preserves gaps in the domain and handles an entirely undefined curve" do + graph = DiscourseChatbot::FunctionPlot.markdown("expressions" => "sqrt(x^2-1)\nsqrt(-1)") + Fabricate(:post, topic: topic, raw: graph) + + topic_page.visit_topic(topic) + + expect(graphs).to have_separate_domain_segments + expect(graphs).to have_no_error + end + + it "renders the additional plot families locally" do + definitions = [ + { "plot_type" => "implicit", "expressions" => "x^2+y^2-4", "title" => "Circle" }, + { + "plot_type" => "parametric", + "expressions" => "cos(t); sin(t)", + "title" => "Parametric circle", + }, + { "plot_type" => "polar", "expressions" => "2*cos(3*theta)", "title" => "Rose" }, + { "plot_type" => "points", "expressions" => "0,1\n2,3\n3,2", "title" => "Scatter" }, + { + "plot_type" => "polyline", + "expressions" => "0,1\n2,3\n3,2", + "title" => "Connected points", + }, + { "plot_type" => "vector", "expressions" => "3,2\n1,1,-2,1", "title" => "Vectors" }, + ] + raw = definitions.map { |args| DiscourseChatbot::FunctionPlot.markdown(args) }.join("\n\n") + Fabricate(:post, topic: topic, raw: raw) + + topic_page.visit_topic(topic) + + expect(graphs).to have_rendered_graphs(count: 6) + expect(graphs).to have_implicit_curve + expect(graphs).to have_scatter_points(count: 3) + expect(graphs).to have_vector_arrows(count: 2) + expect(graphs).to have_no_error + expect(graphs).to have_finite_paths + end + + it "stops an expensive implicit definition with a useful fallback" do + graph = + DiscourseChatbot::FunctionPlot.markdown("plot_type" => "implicit", "expressions" => "x-x+y-y") + Fabricate(:post, topic: topic, raw: graph) + + topic_page.visit_topic(topic) + + expect(graphs).to have_error + expect(graphs).to have_no_visible_canvas + expect(topic_page).to have_content(I18n.t("js.chatbot.function_plot.fallback")) + end + + it "lets readers pan and zoom a curve without scrolling the page" do + graph = DiscourseChatbot::FunctionPlot.markdown("expressions" => "sin(x)") + Fabricate(:post, topic: topic, raw: graph + "\n\n" + ("More about the graph.\n\n" * 30)) + topic_page.visit_topic(topic) + + expect(graphs).to have_rendered_graphs(count: 1) + original_path = graphs.curve_path + graphs.pan_plot + try_until_success { expect(graphs.curve_path).not_to eq(original_path) } + panned_path = graphs.curve_path + graphs.zoom_plot + try_until_success { expect(graphs.curve_path).not_to eq(panned_path) } + zoomed_path = graphs.curve_path + scroll_position = graphs.page_scroll_position + graphs.zoom_plot(delta_y: 300) + try_until_success { expect(graphs.curve_path).not_to eq(zoomed_path) } + expect(graphs.page_scroll_position).to eq(scroll_position) + expect(graphs).to have_no_error + graphs.scroll_outside_plot + try_until_success { expect(graphs.page_scroll_position).to be > scroll_position } + end +end diff --git a/test/javascripts/unit/function-plot-expression-test.js b/test/javascripts/unit/function-plot-expression-test.js new file mode 100644 index 00000000..02b53a8f --- /dev/null +++ b/test/javascripts/unit/function-plot-expression-test.js @@ -0,0 +1,139 @@ +import { module, test } from "qunit"; +import { + compileExpression, + parseGraph, +} from "discourse/plugins/discourse-chatbot/discourse/lib/function-plot-expression"; + +module("Chatbot | function plot expressions", function () { + test("interprets curve expressions with mathematical operator precedence", function (assert) { + [ + ["x^2-4", 3, 5], + ["-x^2", 3, -9], + ["2^-x", 3, 0.125], + ["2^3^2", 0, 512], + ["sin(pi/2)+cos(0)", 0, 2], + ["exp(log(e))", 0, Math.E], + ["log10(1000)", 0, 3], + ["sqrt(abs(x))", -4, 2], + ["cbrt(x)", -8, -2], + ["cbrt((3-4*x^3)/2)", 1, Math.cbrt(-0.5)], + ["1e3*x", 2, 2000], + ].forEach(([expression, x, expected]) => { + assert.true( + Math.abs(compileExpression(expression)(x) - expected) < 1e-10, + expression + ); + }); + assert.true(Number.isNaN(compileExpression("1/x")(0)), "pole is a gap"); + assert.true( + Number.isNaN(compileExpression("sqrt(x)")(-1)), + "undefined domain is a gap" + ); + }); + + test("rejects code, property access, unknown symbols and excessive complexity", function (assert) { + [ + "window.alert(1)", + "constructor(x)", + "x=1", + "x;alert(1)", + "x[0]", + "sin(", + "sin(x,2)", + "x y", + "", + "x".repeat(257), + "(".repeat(40) + "x" + ")".repeat(40), + ].forEach((expression) => { + assert.throws(() => compileExpression(expression), undefined, expression); + }); + }); + + test("accepts bounded graph definitions and rejects arbitrary library options", function (assert) { + const graph = parseGraph( + JSON.stringify({ + functions: ["sin(x)", "cos(x)"], + x_domain: [-7, 7], + y_domain: [-2, 2], + title: "Two curves", + }) + ); + assert.strictEqual(graph.series.length, 2); + assert.deepEqual(graph.xDomain, [-7, 7]); + assert.deepEqual(graph.yDomain, [-2, 2]); + assert.strictEqual(graph.series[0].evaluate(0), 0); + [ + { functions: [] }, + { functions: ["x", "x", "x", "x", "x"] }, + { functions: ["x"], target: "body" }, + { functions: ["x"], title: "a".repeat(121) }, + { functions: ["x"], x_domain: [0, 0] }, + { functions: ["x"], x_domain: [-1e7, 1e7] }, + { functions: ["x"], y_domain: [10, -10] }, + ].forEach((value) => + assert.throws(() => parseGraph(JSON.stringify(value))) + ); + assert.throws(() => parseGraph("x".repeat(8193))); + }); + + test("uses the variables and data format for each selected family", function (assert) { + const parse = (value) => parseGraph(JSON.stringify(value)); + const implicit = parse({ plot_type: "implicit", functions: ["x^2+y^2-4"] }); + assert.strictEqual(implicit.series[0].evaluate(0, 2), 0); + const parametric = parse({ + plot_type: "parametric", + functions: [["cos(t)", "sin(t)"]], + }); + assert.strictEqual(parametric.series[0].evaluateX(0), 1); + assert.strictEqual(parametric.series[0].evaluateY(0), 0); + assert.deepEqual(parametric.parameterRange, [0, 2 * Math.PI]); + const polar = parse({ + plot_type: "polar", + functions: ["theta"], + parameter_range: [0, 8], + }); + assert.strictEqual(polar.series[0].evaluate(3), 3); + assert.deepEqual(polar.parameterRange, [0, 8]); + for (const plot_type of ["points", "polyline"]) { + assert.deepEqual( + parse({ + plot_type, + points: [ + [1, 2], + [3, 4], + ], + }).series[0].points, + [ + [1, 2], + [3, 4], + ] + ); + } + assert.deepEqual( + parse({ plot_type: "vector", vectors: [[1, 2, 3, 4]] }).series[0].vector, + [1, 2, 3, 4] + ); + assert.strictEqual( + parse({ dimensions: 2, functions: ["x"] }).plotType, + "function" + ); + [ + { functions: ["y"] }, + { functions: ["x"], dimensions: 3 }, + { functions: ["x"], z_domain: [-1, 1] }, + { functions: ["x"], parameter_range: [0, 1] }, + { plot_type: "polar", functions: ["x"] }, + { plot_type: "parametric", functions: [["t", "y"]] }, + { plot_type: "parametric", functions: ["cos(t);sin(t)"] }, + { plot_type: "implicit", functions: ["x", "y", "x+y"] }, + { plot_type: "points", points: [[1, null]] }, + { plot_type: "points", points: Array(151).fill([0, 1]) }, + { plot_type: "polyline", points: [[1, "2"]] }, + { plot_type: "vector", vectors: [[1, 2]] }, + { plot_type: "polar", functions: ["theta"], parameter_range: [1, 0] }, + { plot_type: "points", points: [[0, 0]], functions: ["x"] }, + ].forEach((value) => + assert.throws(() => parse(value), undefined, JSON.stringify(value)) + ); + }); +}); diff --git a/test/javascripts/unit/function-plot-renderer-test.js b/test/javascripts/unit/function-plot-renderer-test.js new file mode 100644 index 00000000..6ea3b2aa --- /dev/null +++ b/test/javascripts/unit/function-plot-renderer-test.js @@ -0,0 +1,73 @@ +import { module, test } from "qunit"; +import loadScript from "discourse/lib/load-script"; +import { splitUndefinedSegments } from "discourse/plugins/discourse-chatbot/discourse/lib/function-plot-expression"; +import { compileIntervalExpression } from "discourse/plugins/discourse-chatbot/discourse/lib/function-plot-renderer"; + +module("Chatbot | function plot renderer", function () { + test("evaluates implicit expressions with conservative intervals without code generation", async function (assert) { + await loadScript( + "/plugins/discourse-chatbot/function-plot/1.26.0/function-plot.js" + ); + const interval = window.functionPlot.intervalMath; + const factory = interval.factory; + const cases = [ + ["x^2+y^2-4", factory(-1, 1), factory(1, 2), [-3, 1]], + ["sin(x)+cos(y)", factory(0, Math.PI / 2), factory(0), [1, 2]], + ["cbrt(x)-y", factory(-8, 8), factory(0), [-2, 2]], + ["floor(x)+ceil(y)", factory(1.1, 1.9), factory(1.1, 1.9), [3, 3]], + ["x^0.5", factory(1, 4), factory(0), [1, 2]], + ["x^y", factory(-2, 2), factory(1, 2), [-4, 4]], + ["log10(x)", factory(1, 100), factory(0), [0, 2]], + ]; + for (const [expression, x, y, expected] of cases) { + const actual = compileIntervalExpression(expression, interval)(x, y); + assert.true( + actual.lo <= expected[0] + 1e-12, + `${expression}: lower bound` + ); + assert.true( + actual.hi >= expected[1] - 1e-12, + `${expression}: upper bound` + ); + } + assert.throws(() => compileIntervalExpression("window.alert(1)", interval)); + }); + + test("keeps undefined curve domains and trajectory samples as separate segments", function (assert) { + assert.deepEqual( + splitUndefinedSegments( + [ + [ + [0, 2], + [1, 1], + [3, 1], + [4, 2], + ], + ], + (x) => Math.sqrt((x - 1) * (x - 3)), + 1 + ), + [ + [ + [0, 2], + [1, 1], + ], + [ + [3, 1], + [4, 2], + ], + ] + ); + assert.deepEqual( + splitUndefinedSegments([ + [ + [0, 0], + [NaN, 1], + [2, 2], + ], + ]), + [[[0, 0]], [[2, 2]]] + ); + assert.deepEqual(splitUndefinedSegments([[undefined]]), []); + }); +}); diff --git a/test/javascripts/unit/function-plot-trace-test.js b/test/javascripts/unit/function-plot-trace-test.js new file mode 100644 index 00000000..c992aa83 --- /dev/null +++ b/test/javascripts/unit/function-plot-trace-test.js @@ -0,0 +1,105 @@ +import { module, test } from "qunit"; +import { + traceCoordinates, + traceSeriesCoordinates, +} from "discourse/plugins/discourse-chatbot/discourse/lib/function-plot-trace"; + +module("Chatbot | curve tracing", function () { + test("snaps intersecting series to a shared point", function (assert) { + const values = traceSeriesCoordinates( + [(x) => x + 1, (x) => 3 - x], + 1.03, + [-5, 5, 5, -5], + 500 + ); + assert.true(Math.abs(values[0].x - 1) < 1e-10); + assert.strictEqual(values[0].y, 2); + assert.deepEqual(values[0], values[1]); + }); + test("chooses the closest of nearby series crossings", function (assert) { + const values = traceSeriesCoordinates( + [(x) => x + 1, (x) => 3 - x, (x) => 4.2 - 2 * x], + 1.04, + [-5, 5, 5, -5], + 500 + ); + assert.true(Math.abs(values[0].x - 3.2 / 3) < 1e-10); + assert.deepEqual(values[0], values[2]); + }); + test("ignores coincident series, poles and offscreen intersections", function (assert) { + const overlap = traceSeriesCoordinates( + [() => 2, () => 2], + 1.03, + [-5, 5, 5, -5], + 500 + ); + assert.deepEqual(overlap, [ + { x: 1.03, y: 2 }, + { x: 1.03, y: 2 }, + ]); + const pole = traceSeriesCoordinates( + [(x) => 1 / (x - 1), () => 0], + 1.02, + [-5, 100, 5, -100], + 500 + ); + assert.strictEqual(pole[0].x, 1.02); + assert.true(Math.abs(pole[0].y - 50) < 1e-8); + assert.deepEqual( + traceSeriesCoordinates( + [(x) => x + 100, (x) => 102 - x], + 1.03, + [-5, 5, 5, -5], + 500 + ), + [null, null] + ); + }); + test("snaps to a visible y-axis intercept within six pixels", function (assert) { + assert.deepEqual( + traceCoordinates((x) => x * x + 2, 0.02, [-5, 5, 5, -5], 500), + { x: 0, y: 2 } + ); + assert.deepEqual( + traceCoordinates((x) => x * x + 2, 0.2, [-5, 5, 5, -5], 500), + { x: 0.2, y: 2.04 } + ); + }); + test("snaps to nearby zeros including cubic roots with steep slopes", function (assert) { + const quadratic = traceCoordinates( + (x) => x * x - 4, + 2.03, + [-5, 5, 5, -5], + 500 + ); + assert.true(Math.abs(quadratic.x - 2) < 1e-10); + assert.strictEqual(quadratic.y, 0); + const cubic = traceCoordinates( + (x) => Math.cbrt((3 - 4 * x * x * x) / 2), + 0.92, + [-2, 5, 2, -5], + 500 + ); + assert.true(Math.abs(cubic.x - Math.cbrt(0.75)) < 1e-10); + assert.strictEqual(cubic.y, 0); + }); + test("keeps poles, jumps and undefined values from becoming false intercepts", function (assert) { + const pole = traceCoordinates((x) => 1 / x, 0.02, [-1, 100, 1, -100], 500); + assert.deepEqual(pole, { x: 0.02, y: 50 }); + const jump = traceCoordinates( + (x) => Math.floor(x) * 2 + 1, + 0.02, + [-1, 5, 1, -5], + 500 + ); + assert.deepEqual(jump, { x: 0, y: 1 }); + assert.strictEqual( + traceCoordinates((x) => Math.sqrt(x), -1, [-2, 5, 2, -5], 500), + null + ); + assert.strictEqual( + traceCoordinates((x) => x * x + 10, 1, [-2, 5, 2, -5], 500), + null + ); + }); +});