ag-charts-community
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
1,647 lines (1,623 loc) • 1.76 MB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __decorateClass = (decorators, target, key, kind) => {
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i = decorators.length - 1, decorator; i >= 0; i--)
if (decorator = decorators[i])
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result)
__defProp(target, key, result);
return result;
};
// packages/ag-charts-community/src/api/agCharts.ts
import { ModuleRegistry as ModuleRegistry4 } from "ag-charts-core";
// packages/ag-charts-community/src/chart/chart.ts
import {
AsyncAwaitQueue,
Logger as Logger31,
createId as createId9,
entries as entries5,
groupBy,
isFiniteNumber as isFiniteNumber3,
isFunction as isFunction2,
pause
} from "ag-charts-core";
// packages/ag-charts-community/src/module/module.ts
var BaseModuleInstance = class {
constructor() {
this.destroyFns = [];
}
destroy() {
for (const destroyFn of this.destroyFns) {
destroyFn();
}
}
};
var ModuleRegistry = class {
constructor() {
this.modules = [];
this.dependencies = /* @__PURE__ */ new Map();
this.modulesByOptionKey = /* @__PURE__ */ new Map();
}
register(...modules) {
for (const module of modules) {
this.registerDependencies(module);
const otherModule = this.modules.find(
(other) => module.type === other.type && ("optionsKey" in module && "optionsKey" in other ? module.optionsKey === other.optionsKey : true) && module.identifier === other.identifier
);
if (otherModule) {
if (module.packageType === "enterprise" && otherModule.packageType === "community") {
const index = this.modules.indexOf(otherModule);
this.modules.splice(index, 1, module);
if ("optionsKey" in module) {
this.modulesByOptionKey.set(module.optionsKey, module);
}
}
} else {
this.modules.push(module);
if ("optionsKey" in module) {
this.modulesByOptionKey.set(module.optionsKey, module);
}
}
}
}
hasEnterpriseModules() {
return this.modules.some((m) => m.packageType === "enterprise");
}
*byType(...types) {
const yielded = /* @__PURE__ */ new Set();
const modulesByType = this.modules.filter((module) => types.includes(module.type));
const calculateDependencies = (module) => {
const deps = this.dependencies.get(module);
return deps?.flatMap(calculateDependencies).concat(deps) ?? [];
};
const unresolvable = [];
for (const module of modulesByType) {
const uniqueKey = "optionsKey" in module ? module.optionsKey : module.contextKey;
if (yielded.has(uniqueKey))
continue;
for (const dependency of calculateDependencies(uniqueKey)) {
if (yielded.has(dependency))
continue;
const dependencyModule = this.modulesByOptionKey.get(dependency);
if (!dependencyModule) {
unresolvable.push(dependency);
continue;
}
if (!types.includes(dependencyModule.type))
continue;
yield dependencyModule;
yielded.add(dependency);
}
yield module;
yielded.add(uniqueKey);
}
if (unresolvable.length > 0) {
throw new Error(`Could not resolve module dependencies: ${unresolvable}`);
}
}
registerDependencies(module) {
if (module.dependencies == null || module.dependencies.length === 0)
return;
const uniqueKey = "optionsKey" in module ? module.optionsKey : module.contextKey;
this.dependencies.set(uniqueKey, module.dependencies);
}
};
var moduleRegistry = new ModuleRegistry();
// packages/ag-charts-community/src/scene/bbox.ts
import { clamp } from "ag-charts-core";
// packages/ag-charts-community/src/util/bboxinterface.ts
var BBoxValues = { containsPoint, equals, isEmpty, normalize };
function containsPoint(bbox, x, y) {
return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
}
function equals(lhs, rhs) {
return lhs.x === rhs.x && lhs.y === rhs.y && lhs.width === rhs.width && lhs.height === rhs.height;
}
function isEmpty(bbox) {
return bbox == null || bbox.height === 0 || bbox.width === 0 || isNaN(bbox.height) || isNaN(bbox.width);
}
function normalize(bbox) {
let { x, y, width: width2, height: height2 } = bbox;
if ((width2 == null || width2 > 0) && (height2 == null || height2 > 0))
return bbox;
if (x != null && width2 != null && width2 < 0) {
width2 = -width2;
x = x - width2;
}
if (y != null && height2 != null && height2 < 0) {
height2 = -height2;
y = y - height2;
}
return { x, y, width: width2, height: height2 };
}
// packages/ag-charts-community/src/util/interpolating.ts
var interpolate = Symbol("interpolate");
var isInterpolating = (x) => x[interpolate] != null;
// packages/ag-charts-community/src/util/nearest.ts
function nearestSquared(x, y, objects, maxDistanceSquared = Infinity) {
const result = { nearest: void 0, distanceSquared: maxDistanceSquared };
for (const obj of objects) {
const thisDistance = obj.distanceSquared(x, y);
if (thisDistance === 0) {
return { nearest: obj, distanceSquared: 0 };
} else if (thisDistance < result.distanceSquared) {
result.nearest = obj;
result.distanceSquared = thisDistance;
}
}
return result;
}
function nearestSquaredInContainer(x, y, container, maxDistanceSquared = Infinity) {
const { x: tx = x, y: ty = y } = container.transformPoint?.(x, y) ?? {};
const result = { nearest: void 0, distanceSquared: maxDistanceSquared };
for (const child of container.children) {
const { nearest, distanceSquared: distanceSquared2 } = child.nearestSquared(tx, ty, result.distanceSquared);
if (distanceSquared2 === 0) {
return { nearest, distanceSquared: distanceSquared2 };
} else if (distanceSquared2 < result.distanceSquared) {
result.nearest = nearest;
result.distanceSquared = distanceSquared2;
}
}
return result;
}
// packages/ag-charts-community/src/scene/bbox.ts
var _BBox = class _BBox {
constructor(x, y, width2, height2) {
this.x = x;
this.y = y;
this.width = width2;
this.height = height2;
}
static fromDOMRect({ x, y, width: width2, height: height2 }) {
return new _BBox(x, y, width2, height2);
}
static merge(boxes) {
let left = Infinity;
let top = Infinity;
let right = -Infinity;
let bottom = -Infinity;
for (const box of boxes) {
if (box.x < left) {
left = box.x;
}
if (box.y < top) {
top = box.y;
}
if (box.x + box.width > right) {
right = box.x + box.width;
}
if (box.y + box.height > bottom) {
bottom = box.y + box.height;
}
}
return new _BBox(left, top, right - left, bottom - top);
}
static nearestBox(x, y, boxes) {
return nearestSquared(x, y, boxes);
}
toDOMRect() {
return {
x: this.x,
y: this.y,
width: this.width,
height: this.height,
top: this.y,
left: this.x,
right: this.x + this.width,
bottom: this.y + this.height,
toJSON() {
return {};
}
};
}
clone() {
const { x, y, width: width2, height: height2 } = this;
return new _BBox(x, y, width2, height2);
}
equals(other) {
return BBoxValues.equals(this, other);
}
containsPoint(x, y) {
return BBoxValues.containsPoint(this, x, y);
}
intersection(other) {
if (!this.collidesBBox(other))
return;
const newX1 = clamp(other.x, this.x, other.x + other.width);
const newY1 = clamp(other.y, this.y, other.y + other.height);
const newX2 = clamp(other.x, this.x + this.width, other.x + other.width);
const newY2 = clamp(other.y, this.y + this.height, other.y + other.height);
return new _BBox(newX1, newY1, newX2 - newX1, newY2 - newY1);
}
collidesBBox(other) {
return this.x < other.x + other.width && this.x + this.width > other.x && this.y < other.y + other.height && this.y + this.height > other.y;
}
computeCenter() {
return { x: this.x + this.width / 2, y: this.y + this.height / 2 };
}
isFinite() {
return Number.isFinite(this.x) && Number.isFinite(this.y) && Number.isFinite(this.width) && Number.isFinite(this.height);
}
distanceSquared(x, y) {
if (this.containsPoint(x, y)) {
return 0;
}
const dx = x - clamp(this.x, x, this.x + this.width);
const dy = y - clamp(this.y, y, this.y + this.height);
return dx * dx + dy * dy;
}
shrink(amount, position) {
if (typeof amount === "number") {
this.applyMargin(amount, position);
} else {
for (const key of Object.keys(amount)) {
const value = amount[key];
if (typeof value === "number") {
this.applyMargin(value, key);
}
}
}
if (this.width < 0) {
this.width = 0;
}
if (this.height < 0) {
this.height = 0;
}
return this;
}
grow(amount, position) {
if (typeof amount === "number") {
this.applyMargin(-amount, position);
} else {
for (const key of Object.keys(amount)) {
const value = amount[key];
if (typeof value === "number") {
this.applyMargin(-value, key);
}
}
}
return this;
}
applyMargin(value, position) {
switch (position) {
case "top":
this.y += value;
case "bottom":
this.height -= value;
break;
case "left":
this.x += value;
case "right":
this.width -= value;
break;
case "vertical":
this.y += value;
this.height -= value * 2;
break;
case "horizontal":
this.x += value;
this.width -= value * 2;
break;
case void 0:
this.x += value;
this.y += value;
this.width -= value * 2;
this.height -= value * 2;
break;
}
}
translate(x, y) {
this.x += x;
this.y += y;
return this;
}
[interpolate](other, d) {
return new _BBox(
this.x * (1 - d) + other.x * d,
this.y * (1 - d) + other.y * d,
this.width * (1 - d) + other.width * d,
this.height * (1 - d) + other.height * d
);
}
};
_BBox.zero = Object.freeze(new _BBox(0, 0, 0, 0));
_BBox.NaN = Object.freeze(new _BBox(NaN, NaN, NaN, NaN));
var BBox = _BBox;
// packages/ag-charts-community/src/scene/group.ts
import { clamp as clamp5 } from "ag-charts-core";
// packages/ag-charts-community/src/util/debug.ts
import { Logger, getWindow, toArray } from "ag-charts-core";
var LONG_TIME_PERIOD_THRESHOLD = 2e3;
var timeOfLastLog = Date.now();
var logTimeGap = () => {
const timeSinceLastLog = Date.now() - timeOfLastLog;
if (timeSinceLastLog > LONG_TIME_PERIOD_THRESHOLD) {
const prettyDuration = (Math.floor(timeSinceLastLog / 100) / 10).toFixed(1);
Logger.log(`**** ${prettyDuration}s since last log message ****`);
}
timeOfLastLog = Date.now();
};
var Debug = {
create(...debugSelectors) {
const resultFn = (...logContent) => {
if (Debug.check(...debugSelectors)) {
if (typeof logContent[0] === "function") {
logContent = toArray(logContent[0]());
}
logTimeGap();
Logger.log(...logContent);
}
};
return Object.assign(resultFn, {
check: () => Debug.check(...debugSelectors),
group: (name, cb) => {
if (Debug.check(...debugSelectors)) {
return Logger.logGroup(name, cb);
}
return cb();
}
});
},
check(...debugSelectors) {
if (debugSelectors.length === 0) {
debugSelectors.push(true);
}
const chartDebug = toArray(getWindow("agChartsDebug"));
return chartDebug.some((selector) => debugSelectors.includes(selector));
},
inDevelopmentMode(fn) {
if (Debug.check("dev")) {
return fn();
}
}
};
// packages/ag-charts-community/src/scene/canvas/canvasUtil.ts
function clearContext({
context,
pixelRatio,
width: width2,
height: height2
}) {
context.save();
context.resetTransform();
context.clearRect(0, 0, Math.ceil(width2 * pixelRatio), Math.ceil(height2 * pixelRatio));
context.restore();
}
function debugContext(ctx) {
if (Debug.check("canvas")) {
const save = ctx.save.bind(ctx);
const restore = ctx.restore.bind(ctx);
let depth = 0;
Object.assign(ctx, {
save() {
save();
depth++;
},
restore() {
if (depth === 0) {
throw new Error("AG Charts - Unable to restore() past depth 0");
}
restore();
depth--;
},
verifyDepthZero() {
if (depth !== 0) {
throw new Error(`AG Charts - Save/restore depth is non-zero: ${depth}`);
}
}
});
}
}
// packages/ag-charts-community/src/scene/canvas/hdpiOffscreenCanvas.ts
function canvasDimensions(width2, height2, pixelRatio) {
return [Math.floor(width2 * pixelRatio), Math.floor(height2 * pixelRatio)];
}
var HdpiOffscreenCanvas = class {
constructor(options) {
const { width: width2, height: height2, pixelRatio, willReadFrequently = false } = options;
this.width = width2;
this.height = height2;
this.pixelRatio = pixelRatio;
const [canvasWidth, canvasHeight] = canvasDimensions(width2, height2, pixelRatio);
this.canvas = new OffscreenCanvas(canvasWidth, canvasHeight);
this.context = this.canvas.getContext("2d", { willReadFrequently });
this.context.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
debugContext(this.context);
}
drawImage(context, dx = 0, dy = 0) {
return context.drawImage(this.canvas, dx, dy);
}
transferToImageBitmap() {
return this.canvas.transferToImageBitmap();
}
resize(width2, height2, pixelRatio) {
if (!(width2 > 0 && height2 > 0))
return;
const { canvas, context } = this;
if (width2 !== this.width || height2 !== this.height || pixelRatio !== this.pixelRatio) {
const [canvasWidth, canvasHeight] = canvasDimensions(width2, height2, pixelRatio);
canvas.width = canvasWidth;
canvas.height = canvasHeight;
}
context.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
this.width = width2;
this.height = height2;
this.pixelRatio = pixelRatio;
}
clear() {
clearContext(this);
}
destroy() {
this.canvas.width = 0;
this.canvas.height = 0;
this.context.clearRect(0, 0, 0, 0);
this.canvas = null;
this.context = null;
Object.freeze(this);
}
};
// packages/ag-charts-community/src/scene/node.ts
import { createId, createSvgElement, toIterable } from "ag-charts-core";
// packages/ag-charts-community/src/util/object.ts
import { entries, isArray, isObject, isPlainObject } from "ag-charts-core";
// packages/ag-charts-community/src/util/decorator.ts
var BREAK_TRANSFORM_CHAIN = Symbol("BREAK");
var CONFIG_KEY = "__decorator_config";
var ACCESSORS_KEY = "__decorator_accessors";
function addFakeTransformToInstanceProperty(target, propertyKeyOrSymbol) {
initialiseConfig(target, propertyKeyOrSymbol).optional = true;
}
function initialiseConfig(target, propertyKeyOrSymbol) {
if (Object.getOwnPropertyDescriptor(target, CONFIG_KEY) == null) {
Object.defineProperty(target, CONFIG_KEY, { value: {} });
}
if (Object.getOwnPropertyDescriptor(target, ACCESSORS_KEY) == null) {
const parentAccessors = Object.getPrototypeOf(target)?.[ACCESSORS_KEY];
const accessors = parentAccessors?.slice() ?? [];
Object.defineProperty(target, ACCESSORS_KEY, { value: accessors });
}
const config = target[CONFIG_KEY];
const propertyKey = propertyKeyOrSymbol.toString();
if (config[propertyKey] != null) {
return config[propertyKey];
}
config[propertyKey] = { setters: [], getters: [], observers: [] };
const descriptor = Object.getOwnPropertyDescriptor(target, propertyKeyOrSymbol);
let prevGet = descriptor?.get;
let prevSet = descriptor?.set;
if (prevGet == null || prevSet == null) {
const accessors = target[ACCESSORS_KEY];
let index = accessors.indexOf(propertyKeyOrSymbol);
if (index === -1) {
index = accessors.push(propertyKeyOrSymbol) - 1;
}
prevGet ?? (prevGet = function() {
let accessorValues = this.__accessors;
if (accessorValues == null) {
accessorValues = accessors.slice().fill(void 0);
Object.defineProperty(this, "__accessors", { value: accessorValues });
}
return accessorValues[index];
});
prevSet ?? (prevSet = function(value) {
let accessorValues = this.__accessors;
if (accessorValues == null) {
accessorValues = accessors.slice().fill(void 0);
Object.defineProperty(this, "__accessors", { value: accessorValues });
}
accessorValues[index] = value;
});
}
const getter = function() {
let value = prevGet.call(this);
for (const transformFn of config[propertyKey].getters) {
value = transformFn(this, propertyKeyOrSymbol, value);
if (value === BREAK_TRANSFORM_CHAIN) {
return;
}
}
return value;
};
const setter = function(value) {
const { setters, observers } = config[propertyKey];
let oldValue;
if (setters.some((f) => f.length > 2)) {
oldValue = prevGet.call(this);
}
for (const transformFn of setters) {
value = transformFn(this, propertyKeyOrSymbol, value, oldValue);
if (value === BREAK_TRANSFORM_CHAIN) {
return;
}
}
prevSet.call(this, value);
for (const observerFn of observers) {
observerFn(this, value, oldValue);
}
};
Object.defineProperty(target, propertyKeyOrSymbol, {
set: setter,
get: getter,
enumerable: true,
configurable: false
});
return config[propertyKey];
}
function addTransformToInstanceProperty(setTransform, getTransform, configMetadata) {
return (target, propertyKeyOrSymbol) => {
const config = initialiseConfig(target, propertyKeyOrSymbol);
config.setters.push(setTransform);
if (getTransform) {
config.getters.unshift(getTransform);
}
if (configMetadata) {
Object.assign(config, configMetadata);
}
};
}
function addObserverToInstanceProperty(setObserver) {
return (target, propertyKeyOrSymbol) => {
initialiseConfig(target, propertyKeyOrSymbol).observers.push(setObserver);
};
}
function isDecoratedObject(target) {
return typeof target !== "undefined" && CONFIG_KEY in target;
}
function listDecoratedProperties(target) {
const targets = /* @__PURE__ */ new Set();
while (isDecoratedObject(target)) {
targets.add(target?.[CONFIG_KEY]);
target = Object.getPrototypeOf(target);
}
return Array.from(targets).flatMap((configMap) => Object.keys(configMap));
}
function extractDecoratedProperties(target) {
return listDecoratedProperties(target).reduce((result, key) => {
result[key] = target[key] ?? null;
return result;
}, {});
}
// packages/ag-charts-community/src/util/object.ts
function objectsEqual(a, b) {
if (Array.isArray(a)) {
if (!Array.isArray(b))
return false;
if (a.length !== b.length)
return false;
return a.every((av, i) => objectsEqual(av, b[i]));
} else if (isPlainObject(a)) {
if (!isPlainObject(b))
return false;
return objectsEqualWith(a, b, objectsEqual);
}
return a === b;
}
function objectsEqualWith(a, b, cmp2) {
if (Object.is(a, b))
return true;
for (const key of Object.keys(b)) {
if (!(key in a))
return false;
}
for (const key of Object.keys(a)) {
if (!(key in b))
return false;
if (!cmp2(a[key], b[key]))
return false;
}
return true;
}
function mergeDefaults(...sources) {
const target = {};
for (const source of sources) {
if (!isObject(source))
continue;
const keys = isDecoratedObject(source) ? listDecoratedProperties(source) : Object.keys(source);
for (const key of keys) {
if (isPlainObject(target[key]) && isPlainObject(source[key])) {
target[key] = mergeDefaults(target[key], source[key]);
} else {
target[key] ?? (target[key] = source[key]);
}
}
}
return target;
}
function merge(...sources) {
const target = {};
for (const source of sources) {
if (!isObject(source))
continue;
const keys = isDecoratedObject(source) ? listDecoratedProperties(source) : Object.keys(source);
for (const key of keys) {
if (isPlainObject(target[key]) && isPlainObject(source[key])) {
target[key] = merge(target[key], source[key]);
} else if (!(key in target)) {
target[key] ?? (target[key] = source[key]);
}
}
}
return target;
}
function mergeArrayDefaults(dataArray, ...itemDefaults) {
if (itemDefaults && isArray(dataArray)) {
return dataArray.map((item) => mergeDefaults(item, ...itemDefaults));
}
return dataArray;
}
function mapValues(object4, mapper) {
const result = {};
for (const [key, value] of entries(object4)) {
result[key] = mapper(value, key, object4);
}
return result;
}
function without(object4, keys) {
const clone2 = { ...object4 };
for (const key of keys) {
delete clone2[key];
}
return clone2;
}
function getPath(object4, path) {
const pathArray = isArray(path) ? path : path.split(".");
return pathArray.reduce((value, pathKey) => value[pathKey], object4);
}
var SKIP_JS_BUILTINS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
function setPath(object4, path, newValue) {
const pathArray = isArray(path) ? path.slice() : path.split(".");
const lastKey = pathArray.pop();
if (pathArray.some((p) => SKIP_JS_BUILTINS.has(p)))
return;
const lastObject = pathArray.reduce((value, pathKey) => value[pathKey], object4);
lastObject[lastKey] = newValue;
return lastObject[lastKey];
}
function partialAssign(keysToCopy, target, source) {
if (source === void 0) {
return target;
}
for (const key of keysToCopy) {
const value = source[key];
if (value !== void 0) {
target[key] = value;
}
}
return target;
}
function deepFreeze(obj) {
if (obj == null || typeof obj !== "object" || !isPlainObject(obj)) {
return obj;
}
Object.freeze(obj);
Object.getOwnPropertyNames(obj).forEach((prop) => {
const value = obj[prop];
if (value !== null && (typeof value === "object" || typeof value === "function") && !Object.isFrozen(value)) {
deepFreeze(value);
}
});
return obj;
}
function isObjectWithProperty(obj, key) {
return isPlainObject(obj) && key in obj;
}
function isObjectWithStringProperty(obj, key) {
return isObjectWithProperty(obj, key) && typeof obj[key] === "string";
}
// packages/ag-charts-community/src/scene/changeDetectable.ts
import { arraysEqual } from "ag-charts-core";
var TRIPLE_EQ = (lhs, rhs) => lhs === rhs;
function SceneChangeDetection(opts) {
return function(target, key) {
const privateKey = `__${key}`;
if (target[key]) {
return;
}
prepareGetSet(target, key, privateKey, opts);
};
}
function SceneObjectChangeDetection(opts) {
return SceneChangeDetection(opts);
}
function SceneArrayChangeDetection(opts) {
const baseOpts = opts ?? {};
baseOpts.equals = arraysEqual;
return SceneChangeDetection(opts);
}
function prepareGetSet(target, key, privateKey, opts) {
const { changeCb, convertor, checkDirtyOnAssignment = false } = opts ?? {};
const requiredOpts = { changeCb, checkDirtyOnAssignment, convertor };
const setter = buildCheckDirtyChain(
privateKey,
buildChangeCallbackChain(
buildConvertorChain(buildSetter(privateKey, requiredOpts), requiredOpts),
requiredOpts
),
requiredOpts
);
const getter = function() {
return this[privateKey];
};
Object.defineProperty(target, key, {
set: setter,
get: getter,
enumerable: true,
configurable: true
});
}
function buildConvertorChain(setterFn, opts) {
const { convertor } = opts;
if (convertor) {
return function(value) {
setterFn.call(this, convertor(value));
};
}
return setterFn;
}
var NO_CHANGE = Symbol("no-change");
function buildChangeCallbackChain(setterFn, opts) {
const { changeCb } = opts;
if (changeCb) {
return function(value) {
const change = setterFn.call(this, value);
if (change !== NO_CHANGE) {
changeCb.call(this, this);
}
return change;
};
}
return setterFn;
}
function buildCheckDirtyChain(privateKey, setterFn, opts) {
const { checkDirtyOnAssignment } = opts;
if (checkDirtyOnAssignment) {
return function(value) {
const change = setterFn.call(this, value);
if (value?._dirty === true) {
this.markDirty(privateKey);
}
return change;
};
}
return setterFn;
}
function buildSetter(privateKey, opts) {
const { equals: equals2 = TRIPLE_EQ } = opts;
return function(value) {
const oldValue = this[privateKey];
if (!equals2(value, oldValue)) {
this[privateKey] = value;
this.onChangeDetection(privateKey);
return value;
}
return NO_CHANGE;
};
}
// packages/ag-charts-community/src/scene/node.ts
var PointerEvents = /* @__PURE__ */ ((PointerEvents2) => {
PointerEvents2[PointerEvents2["All"] = 0] = "All";
PointerEvents2[PointerEvents2["None"] = 1] = "None";
return PointerEvents2;
})(PointerEvents || {});
var _Node = class _Node {
constructor(options) {
/** Unique number to allow creation order to be easily determined. */
this.serialNumber = _Node._nextSerialNumber++;
this.childNodeCounts = { groups: 0, nonGroups: 0, thisComplexity: 0, complexity: 0 };
/** Unique node ID in the form `ClassName-NaturalNumber`. */
this.id = createId(this);
this.pointerEvents = 0 /* All */;
this.scene = void 0;
this._dirty = true;
this.dirtyZIndex = false;
/**
* To simplify the type system (especially in Selections) we don't have the `Parent` node
* (one that has children). Instead, we mimic HTML DOM, where any node can have children.
* But we still need to distinguish regular leaf nodes from container leafs somehow.
*/
this.isContainerNode = false;
this.visible = true;
this.zIndex = 0;
this.name = options?.name;
this.tag = options?.tag ?? NaN;
this.zIndex = options?.zIndex ?? 0;
if (options?.debugDirty ?? _Node._debugEnabled) {
this._debugDirtyProperties = /* @__PURE__ */ new Map([["__first__", []]]);
}
}
static toSVG(node, width2, height2) {
const svg = node?.toSVG();
if (svg == null || !svg.elements.length && !svg.defs?.length)
return;
const root = createSvgElement("svg");
root.setAttribute("width", String(width2));
root.setAttribute("height", String(height2));
root.setAttribute("viewBox", `0 0 ${width2} ${height2}`);
if (svg.defs?.length) {
const defs = createSvgElement("defs");
defs.append(...svg.defs);
root.append(defs);
}
root.append(...svg.elements);
return root.outerHTML;
}
static *extractBBoxes(nodes, skipInvisible) {
for (const n of nodes) {
if (!skipInvisible || n.visible && !n.transitionOut) {
const bbox = n.getBBox();
if (bbox)
yield bbox;
}
}
}
/**
* Some arbitrary data bound to the node.
*/
get datum() {
return this._datum;
}
set datum(datum) {
if (this._datum !== datum) {
this._previousDatum = this._datum;
this._datum = datum;
}
}
get previousDatum() {
return this._previousDatum;
}
get layerManager() {
return this.scene?.layersManager;
}
get imageLoader() {
return this.scene?.imageLoader;
}
get dirty() {
return this._dirty;
}
closestDatum() {
for (const { datum } of this.traverseUp(true)) {
if (datum != null) {
return datum;
}
}
}
/** Perform any pre-rendering initialization. */
preRender(renderCtx, thisComplexity = 1) {
this.childNodeCounts.groups = 0;
this.childNodeCounts.nonGroups = 1;
this.childNodeCounts.complexity = thisComplexity;
this.childNodeCounts.thisComplexity = thisComplexity;
for (const child of this.children()) {
const childCounts = child.preRender(renderCtx);
this.childNodeCounts.groups += childCounts.groups;
this.childNodeCounts.nonGroups += childCounts.nonGroups;
this.childNodeCounts.complexity += childCounts.complexity;
}
return this.childNodeCounts;
}
render(renderCtx) {
const { stats } = renderCtx;
this._dirty = false;
this.debugDirtyProperties();
if (renderCtx.debugNodeSearch) {
const idOrName = this.name ?? this.id;
if (renderCtx.debugNodeSearch.some((v) => typeof v === "string" ? v === idOrName : v.test(idOrName))) {
renderCtx.debugNodes[this.name ?? this.id] = this;
}
}
if (stats) {
stats.nodesRendered++;
stats.opsPerformed += this.childNodeCounts.thisComplexity;
}
}
setScene(scene) {
this.scene = scene;
this._debug = scene?.layersManager?.debug;
for (const child of this.children()) {
child.setScene(scene);
}
}
sortChildren(compareFn) {
this.dirtyZIndex = false;
if (!this.childNodes)
return;
const sortedChildren = [...this.childNodes].sort(compareFn);
this.childNodes.clear();
for (const child of sortedChildren) {
this.childNodes.add(child);
}
}
*traverseUp(includeSelf) {
let node = this;
if (includeSelf) {
yield node;
}
while (node = node.parentNode) {
yield node;
}
}
*children() {
if (!this.childNodes)
return;
for (const child of this.childNodes) {
yield child;
}
}
*descendants() {
for (const child of this.children()) {
yield child;
yield* child.descendants();
}
}
/**
* Checks if the node is a leaf (has no children).
*/
isLeaf() {
return !this.childNodes?.size;
}
/**
* Checks if the node is the root (has no parent).
*/
isRoot() {
return !this.parentNode;
}
/**
* Appends one or more new node instances to this parent.
* If one needs to:
* - move a child to the end of the list of children
* - move a child from one parent to another (including parents in other scenes)
* one should use the {@link insertBefore} method instead.
* @param nodes A node or nodes to append.
*/
append(nodes) {
this.childNodes ?? (this.childNodes = /* @__PURE__ */ new Set());
for (const node of toIterable(nodes)) {
node.parentNode?.removeChild(node);
this.childNodes.add(node);
node.parentNode = this;
node.setScene(this.scene);
}
this.invalidateCachedBBox();
this.dirtyZIndex = true;
this.markDirty();
}
appendChild(node) {
this.append(node);
return node;
}
removeChild(node) {
if (!this.childNodes?.delete(node)) {
throw new Error(
`AG Charts - internal error, unknown child node ${node.name ?? node.id} in $${this.name ?? this.id}`
);
}
delete node.parentNode;
node.setScene();
this.invalidateCachedBBox();
this.dirtyZIndex = true;
this.markDirty();
}
remove() {
this.parentNode?.removeChild(this);
}
clear() {
for (const child of this.children()) {
delete child.parentNode;
child.setScene();
}
this.childNodes?.clear();
this.invalidateCachedBBox();
}
destroy() {
this.parentNode?.removeChild(this);
}
setProperties(styles, pickKeys) {
if (pickKeys) {
for (const key of pickKeys) {
this[key] = styles[key];
}
} else {
Object.assign(this, styles);
}
return this;
}
containsPoint(_x, _y) {
return false;
}
/**
* Hit testing method.
* Recursively checks if the given point is inside this node or any of its children.
* Returns the first matching node or `undefined`.
* Nodes that render later (show on top) are hit tested first.
*/
pickNode(x, y) {
if (!this.visible || this.pointerEvents === 1 /* None */ || !this.containsPoint(x, y)) {
return;
}
if (this.childNodes != null && this.childNodes.size !== 0) {
const children = [...this.children()];
for (let i = children.length - 1; i >= 0; i--) {
const hit = children[i].pickNode(x, y);
if (hit) {
return hit;
}
}
} else if (!this.isContainerNode) {
return this;
}
}
pickNodes(x, y, into = []) {
if (!this.visible || this.pointerEvents === 1 /* None */ || !this.containsPoint(x, y)) {
return into;
}
if (!this.isContainerNode) {
into.push(this);
}
for (const child of this.children()) {
child.pickNodes(x, y, into);
}
return into;
}
invalidateCachedBBox() {
if (this.cachedBBox != null) {
this.cachedBBox = void 0;
this.parentNode?.invalidateCachedBBox();
}
}
getBBox() {
if (this.cachedBBox == null) {
this.cachedBBox = Object.freeze(this.computeBBox());
}
return this.cachedBBox;
}
computeBBox() {
return;
}
onChangeDetection(property) {
this.markDirty(property);
}
markDirty(property) {
const { _dirty } = this;
if (property != null && this._debugDirtyProperties) {
this.markDebugProperties(property);
}
const noParentCachedBBox = this.cachedBBox == null;
if (noParentCachedBBox && _dirty)
return;
this.invalidateCachedBBox();
this._dirty = true;
if (this.parentNode) {
this.parentNode.markDirty();
}
}
markClean() {
if (!this._dirty)
return;
this._dirty = false;
this.debugDirtyProperties();
for (const child of this.children()) {
child.markClean();
}
}
markDebugProperties(property) {
const sources = this._debugDirtyProperties?.get(property) ?? [];
const caller = new Error().stack?.split("\n").filter((line) => {
return line !== "Error" && !line.includes(".markDebugProperties") && !line.includes(".markDirty") && !line.includes("Object.assign ") && !line.includes(`${this.constructor.name}.`);
}) ?? "unknown";
sources.push(caller[0].replace(" at ", "").trim());
this._debugDirtyProperties?.set(property, sources);
}
debugDirtyProperties() {
if (this._debugDirtyProperties == null)
return;
if (!this._debugDirtyProperties.has("__first__")) {
this._debugDirtyProperties.forEach((sources, property) => {
if (sources.length > 1) {
console.groupCollapsed(
`Property changed multiple times before render: ${this.constructor.name}.${property} (${sources.length}x)`
);
sources.forEach((source) => console.log(source));
console.groupEnd();
}
});
}
this._debugDirtyProperties.clear();
}
onZIndexChange() {
const { parentNode } = this;
if (parentNode) {
parentNode.dirtyZIndex = true;
}
}
toSVG() {
return;
}
};
_Node._nextSerialNumber = 0;
// eslint-disable-next-line sonarjs/public-static-readonly
_Node._debugEnabled = false;
__decorateClass([
SceneChangeDetection()
], _Node.prototype, "visible", 2);
__decorateClass([
SceneObjectChangeDetection({
equals: objectsEqual,
changeCb: (target) => target.onZIndexChange()
})
], _Node.prototype, "zIndex", 2);
var Node2 = _Node;
// packages/ag-charts-community/src/scene/shape/shape.ts
import { clamp as clamp4, generateUUID } from "ag-charts-core";
// packages/ag-charts-community/src/scene/gradient/conicGradient.ts
import { createSvgElement as createSvgElement3 } from "ag-charts-core";
// packages/ag-charts-community/src/util/angle.ts
var twoPi = Math.PI * 2;
var halfPi = Math.PI / 2;
function normalizeAngle360(radians) {
radians %= twoPi;
radians += twoPi;
radians %= twoPi;
return radians;
}
function normalizeAngle360Inclusive(radians) {
radians %= twoPi;
radians += twoPi;
if (radians !== twoPi) {
radians %= twoPi;
}
return radians;
}
function normalizeAngle180(radians) {
radians %= twoPi;
if (radians < -Math.PI) {
radians += twoPi;
} else if (radians >= Math.PI) {
radians -= twoPi;
}
return radians;
}
function isBetweenAngles(targetAngle, startAngle, endAngle) {
const t = normalizeAngle360(targetAngle);
const a0 = normalizeAngle360(startAngle);
const a1 = normalizeAngle360(endAngle);
if (a0 < a1) {
return a0 <= t && t <= a1;
} else if (a0 > a1) {
return a0 <= t || t <= a1;
} else {
return true;
}
}
function toRadians(degrees) {
return degrees / 180 * Math.PI;
}
function toDegrees(radians) {
return radians / Math.PI * 180;
}
function angleBetween(angle0, angle1) {
angle0 = normalizeAngle360(angle0);
angle1 = normalizeAngle360(angle1);
return angle1 - angle0 + (angle0 > angle1 ? twoPi : 0);
}
function getAngleRatioRadians(angle2) {
const normalizedAngle = normalizeAngle360(angle2);
if (normalizedAngle <= halfPi) {
return normalizedAngle / halfPi;
} else if (normalizedAngle <= Math.PI) {
return (Math.PI - normalizedAngle) / halfPi;
} else if (normalizedAngle <= 1.5 * Math.PI) {
return (normalizedAngle - Math.PI) / halfPi;
} else {
return (twoPi - normalizedAngle) / halfPi;
}
}
function angularPadding(hPadding, vPadding, angle2) {
const angleRatio = getAngleRatioRadians(angle2);
return hPadding * angleRatio + vPadding * Math.abs(1 - angleRatio);
}
function normalizeAngle360FromDegrees(degrees) {
return degrees ? normalizeAngle360(toRadians(degrees)) : 0;
}
// packages/ag-charts-community/src/scene/gradient/gradient.ts
import { createSvgElement as createSvgElement2 } from "ag-charts-core";
// packages/ag-charts-community/src/scale/colorScale.ts
import { Logger as Logger2, clamp as clamp3 } from "ag-charts-core";
// packages/ag-charts-community/src/util/color.ts
import { clamp as clamp2 } from "ag-charts-core";
var lerp = (x, y, t) => x * (1 - t) + y * t;
var srgbToLinear = (value) => {
const sign = value < 0 ? -1 : 1;
const abs = Math.abs(value);
if (abs <= 0.04045)
return value / 12.92;
return sign * ((abs + 0.055) / 1.055) ** 2.4;
};
var srgbFromLinear = (value) => {
const sign = value < 0 ? -1 : 1;
const abs = Math.abs(value);
if (abs > 31308e-7) {
return sign * (1.055 * abs ** (1 / 2.4) - 0.055);
}
return 12.92 * value;
};
var _Color = class _Color {
/**
* Every color component should be in the [0, 1] range.
* Some easing functions (such as elastic easing) can overshoot the target value by some amount.
* So, when animating colors, if the source or target color components are already near
* or at the edge of the allowed [0, 1] range, it is possible for the intermediate color
* component value to end up outside of that range mid-animation. For this reason the constructor
* performs range checking/constraining.
* @param r Red component.
* @param g Green component.
* @param b Blue component.
* @param a Alpha (opacity) component.
*/
constructor(r, g, b, a = 1) {
this.r = clamp2(0, r || 0, 1);
this.g = clamp2(0, g || 0, 1);
this.b = clamp2(0, b || 0, 1);
this.a = clamp2(0, a || 0, 1);
}
/**
* A color string can be in one of the following formats to be valid:
* - #rgb
* - #rrggbb
* - rgb(r, g, b)
* - rgba(r, g, b, a)
* - CSS color name such as 'white', 'orange', 'cyan', etc.
*/
static validColorString(str) {
if (str.indexOf("#") >= 0) {
return !!_Color.parseHex(str);
}
if (str.indexOf("rgb") >= 0) {
return !!_Color.stringToRgba(str);
}
return _Color.nameToHex.has(str.toLowerCase());
}
/**
* The given string can be in one of the following formats:
* - #rgb
* - #rrggbb
* - rgb(r, g, b)
* - rgba(r, g, b, a)
* - CSS color name such as 'white', 'orange', 'cyan', etc.
* @param str
*/
static fromString(str) {
if (str.indexOf("#") >= 0) {
return _Color.fromHexString(str);
}
const hex = _Color.nameToHex.get(str.toLowerCase());
if (hex) {
return _Color.fromHexString(hex);
}
if (str.indexOf("rgb") >= 0) {
return _Color.fromRgbaString(str);
}
throw new Error(`Invalid color string: '${str}'`);
}
// See https://drafts.csswg.org/css-color/#hex-notation
static parseHex(input) {
input = input.replace(/ /g, "").slice(1);
let parts;
switch (input.length) {
case 6:
case 8:
parts = [];
for (let i = 0; i < input.length; i += 2) {
parts.push(parseInt(`${input[i]}${input[i + 1]}`, 16));
}
break;
case 3:
case 4:
parts = input.split("").map((p) => parseInt(p, 16)).map((p) => p + p * 16);
break;
}
if (parts?.length >= 3 && parts.every((p) => p >= 0)) {
if (parts.length === 3) {
parts.push(255);
}
return parts;
}
}
static fromHexString(str) {
const values = _Color.parseHex(str);
if (values) {
const [r, g, b, a] = values;
return new _Color(r / 255, g / 255, b / 255, a / 255);
}
throw new Error(`Malformed hexadecimal color string: '${str}'`);
}
static stringToRgba(str) {
let po = -1;
let pc = -1;
for (let i = 0; i < str.length; i++) {
const c = str[i];
if (po === -1 && c === "(") {
po = i;
} else if (c === ")") {
pc = i;
break;
}
}
if (po === -1 || pc === -1)
return;
const contents = str.substring(po + 1, pc);
const parts = contents.split(",");
const rgba = [];
for (let i = 0; i < parts.length; i++) {
const part = parts[i];
let value = parseFloat(part);
if (!Number.isFinite(value)) {
return;
}
if (part.indexOf("%") >= 0) {
value = clamp2(0, value, 100);
value /= 100;
} else if (i === 3) {
value = clamp2(0, value, 1);
} else {
value = clamp2(0, value, 255);
value /= 255;
}
rgba.push(value);
}
return rgba;
}
static fromRgbaString(str) {
const rgba = _Color.stringToRgba(str);
if (rgba) {
if (rgba.length === 3) {
return new _Color(rgba[0], rgba[1], rgba[2]);
} else if (rgba.length === 4) {
return new _Color(rgba[0], rgba[1], rgba[2], rgba[3]);
}
}
throw new Error(`Malformed rgb/rgba color string: '${str}'`);
}
static fromArray(arr) {
if (arr.length === 4) {
return new _Color(arr[0], arr[1], arr[2], arr[3]);
}
if (arr.length === 3) {
return new _Color(arr[0], arr[1], arr[2]);
}
throw new Error("The given array should contain 3 or 4 color components (numbers).");
}
static fromHSB(h, s, b, alpha = 1) {
const rgb = _Color.HSBtoRGB(h, s, b);
return new _Color(rgb[0], rgb[1], rgb[2], alpha);
}
static fromHSL(h, s, l, alpha = 1) {
const rgb = _Color.HSLtoRGB(h, s, l);
return new _Color(rgb[0], rgb[1], rgb[2], alpha);
}
static fromOKLCH(l, c, h, alpha = 1) {
const rgb = _Color.OKLCHtoRGB(l, c, h);
return new _Color(rgb[0], rgb[1], rgb[2], alpha);
}
static padHex(str) {
return str.length === 1 ? "0" + str : str;
}
toHexString() {
let hex = "#" + _Color.padHex(Math.round(this.r * 255).toString(16)) + _Color.padHex(Math.round(this.g * 255).toString(16)) + _Color.padHex(Math.round(this.b * 255).toString(16));
if (this.a < 1) {
hex += _Color.padHex(Math.round(this.a * 255).toString(16));
}
return hex;
}
toRgbaString(fractionDigits = 3) {
const components = [Math.round(this.r * 255), Math.round(this.g * 255), Math.round(this.b * 255)];
const k = Math.pow(10, fractionDigits);
if (this.a !== 1) {
components.push(Math.round(this.a * k) / k);
return `rgba(${components.join(", ")})`;
}
return `rgb(${components.join(", ")})`;
}
toString() {
if (this.a === 1) {
return this.toHexString();
}
return this.toRgbaString();
}
toHSB() {
return _Color.RGBtoHSB(this.r, this.g, this.b);
}
static RGBtoOKLCH(r, g, b) {
const LSRGB0 = srgbToLinear(r);
const LSRGB1 = srgbToLinear(g);
const LSRGB2 = srgbToLinear(b);
const LMS0 = Math.cbrt(0.4122214708 * LSRGB0 + 0.5363325363 * LSRGB1 + 0.0514459929 * LSRGB2);
const LMS1 = Math.cbrt(0.2119034982 * LSRGB0 + 0.6806995451 * LSRGB1 + 0.1073969566 * LSRGB2);
const LMS2 = Math.cbrt(0.0883024619 * LSRGB0 + 0.2817188376 * LSRGB1 + 0.6299787005 * LSRGB2);
const OKLAB0 = 0.2104542553 * LMS0 + 0.793617785 * LMS1 - 0.0040720468 * LMS2;
const OKLAB1 = 1.9779984951 * LMS0 - 2.428592205 * LMS1 + 0.4505937099 * LMS2;
const OKLAB2 = 0.0259040371 * LMS0 + 0.7827717662 * LMS1 - 0.808675766 * LMS2;
const hue = Math.atan2(OKLAB2, OKLAB1) * 180 / Math.PI;
const OKLCH0 = OKLAB0;
const OKLCH1 = Math.hypot(OKLAB1, OKLAB2);
const OKLCH2 = hue >= 0 ? hue : hue + 360;
return [OKLCH0, OKLCH1, OKLCH2];
}
static OKLCHtoRGB(l, c, h) {
const OKLAB0 = l;
const OKLAB1 = c * Math.cos(h * Math.PI / 180);
const OKLAB2 = c * Math.sin(h * Math.PI / 180);
const LMS0 = (OKLAB0 + 0.3963377774 * OKLAB1 + 0.2158037573 * OKLAB2) ** 3;
const LMS1 = (OKLAB0 - 0.1055613458 * OKLAB1 - 0.0638541728 * OKLAB2) ** 3;
const LMS2 = (OKLAB0 - 0.0894841775 * OKLAB1 - 1.291485548 * OKLAB2) ** 3;
const LSRGB0 = 4.0767416621 * LMS0 - 3.3077115913 * LMS1 + 0.2309699292 * LMS2;
const LSRGB1 = -1.2684380046 * LMS0 + 2.6097574011 * LMS1 - 0.3413193965 * LMS2;
const LSRGB2 = -0.0041960863 * LMS0 - 0.7034186147 * LMS1 + 1.707614701 * LMS2;
const SRGB0 = srgbFromLinear(LSRGB0);
const SRGB1 = srgbFromLinear(LSRGB1);
const SRGB2 = srgbFromLinear(LSRGB2);
return [SRGB0, SRGB1, SRGB2];
}
static RGBtoHSL(r, g, b) {
const min = Math.min(r, g, b);
const max = Math.max(r, g, b);
const l = (max + min) / 2;
let h;
let s;
if (max === min) {
h = 0;
s = 0;
} else {
const delta3 = max - min;
s = l > 0.5 ? delta3 / (2 - max - min) : delta3 / (max + min);
if (max === r) {
h = (g - b) / delta3 + (g < b ? 6 : 0);
} else if (max === g) {
h = (b - r) / delta3 + 2;
} else {
h = (r - g) / delta3 + 4;
}
h *= 360 / 6;
}
return [h, s, l];
}
static HSLtoRGB(h, s, l) {
h = (h % 360 + 360) % 360;
if (s === 0) {
return [l, l, l];
}
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;
function hueToRgb(t) {
if (t < 0)
t += 1;
if (t > 1)
t -= 1;
if (t < 1 / 6)
return p + (q - p) * 6 * t;
if (t < 1 / 2)
return q;
if (t < 2 / 3)
return p + (q - p) * (2 / 3 - t) * 6;
return p;
}
const r = hueToRgb(h / 360 + 1 / 3);
const g = hueToRgb(h / 360);
const b = hueToRgb(h / 360 - 1 / 3);
return [r, g, b];
}
/**
* Converts the given RGB triple to an array of HSB (HSV) components.
*/
static RGBtoHSB(r, g, b) {
const min = Math.min(r, g, b);
const max = Math.max(r, g, b);
const S = max === 0 ? 0 : (max - min) / max;
let H = 0;
if (min !== max) {
const delta3 = max - min;
const rc = (max - r) / delta3;
const gc = (max - g) / delta3;
const bc = (max - b) / delta3;
if (r === max) {
H = bc - gc;
} else if (g === max) {
H = 2 + rc - bc;
} else {
H = 4 + gc - rc;
}
H /= 6;
if (H < 0) {
H = H + 1;
}
}
return [H * 360, S, max];
}
/**
* Converts the given HSB (HSV) triple to an array of RGB components.
*/
static HSBtoRGB(H, S, B) {
H = (H % 360 + 360) % 360 / 360;
let r = 0;
let g = 0;
let b = 0;
if (S === 0) {
r = g = b = B;
} else {
const h = (H - Math.floor(H)) * 6;
const f = h - Math.floor(h);
const p = B * (1 - S);
const q = B * (1 - S * f);
const t = B * (1 - S * (1 - f));
switch (h >> 0) {
case 0:
r = B;
g = t;
b = p;
break;
case 1:
r = q;
g = B;
b = p;
break;
case 2:
r = p;
g = B;
b = t;
break;
case 3:
r = p;
g = q;
b = B;
break;
case 4:
r = t;
g = p;
b = B;
break;
case 5:
r = B;
g = p;
b = q;
break;
}
}
return [r, g, b];
}
static mix(c0, c1, t) {
return new _Color(lerp(c0.r, c1.r, t), lerp(c0.g, c1.g, t), lerp(c0.b, c1.b, t), lerp(c0.a, c1.a, t));
}
static lighten(c, t) {
const oklch = _Color.RGBtoOKLCH(c.r, c.g, c.b);
return _Color.fromOKLCH(clamp2(0, oklch[0] + t, 1), oklch[1], oklch[2]);
}
static darken(c, t) {
const oklch = _Color.RGBtoOKLCH(c.r, c.g, c.b);
return _Color.fromOKLCH(clamp2(0, oklch[0] - t, 1), oklch[1], oklch[2]);
}
static interpolate(colors, count) {
const step = 1 / (colors.length - 1);
const oklchColors = colors.map((c) => _Color.RGBtoOKLCH(c.r, c.g, c.b));
return Array.from({ length: count }, (_, i) => {
const t = i / (count - 1);
const index = colors.length <= 2 ? 0 : Math.min(Math.floor(t * (colors.length - 1)), colors.length - 2);
const q = (t - index * step) / step;
const c0 = oklchColors[index];
const c1 = oklchColors[index + 1];
return _Color.fromOKLCH(lerp(c0[0], c1[0], q), lerp(c0[1], c1[1], q), lerp(c0[2], c1[2], q));
});
}
};
/**
* CSS Color Module Level 4:
* https://drafts.csswg.org/css-color/#named-colors
*/
_Color.nameToHex = /* @__PURE__ */ new Map([
["aliceblue", "#F0F8FF"],
["antiquewhite", "#FAEBD7"],
[