laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
93 lines (92 loc) • 2.22 kB
JavaScript
"use client";
import { MIN_VALUE_REG as N, MAX_VALUE_REG as E } from "./ChartUtils.js";
import { isNumber as R } from "./DataUtils.js";
import { isWellBehavedNumber as y } from "./isWellBehavedNumber.js";
function h(u) {
if (Array.isArray(u) && u.length === 2) {
var [e, f] = u;
if (y(e) && y(f))
return !0;
}
return !1;
}
function U(u, e, f) {
return f ? u : [Math.min(u[0], e[0]), Math.max(u[1], e[1])];
}
function q(u, e) {
if (e && typeof u != "function" && Array.isArray(u) && u.length === 2) {
var [f, c] = u, r, l;
if (y(f))
r = f;
else if (typeof f == "function")
return;
if (y(c))
l = c;
else if (typeof c == "function")
return;
var t = [r, l];
if (h(t))
return t;
}
}
function B(u, e, f) {
if (!(!f && e == null)) {
if (typeof u == "function" && e != null)
try {
var c = u(e, f);
if (h(c))
return U(c, e, f);
} catch {
}
if (Array.isArray(u) && u.length === 2) {
var [r, l] = u, t, s;
if (r === "auto")
e != null && (t = Math.min(...e));
else if (R(r))
t = r;
else if (typeof r == "function")
try {
e != null && (t = r(e?.[0]));
} catch {
}
else if (typeof r == "string" && N.test(r)) {
var A = N.exec(r);
if (A == null || e == null)
t = void 0;
else {
var W = +A[1];
t = e[0] - W;
}
} else
t = e?.[0];
if (l === "auto")
e != null && (s = Math.max(...e));
else if (R(l))
s = l;
else if (typeof l == "function")
try {
e != null && (s = l(e?.[1]));
} catch {
}
else if (typeof l == "string" && E.test(l)) {
var g = E.exec(l);
if (g == null || e == null)
s = void 0;
else {
var b = +g[1];
s = e[1] + b;
}
} else
s = e?.[1];
var n = [t, s];
if (h(n))
return e == null ? n : U(n, e, f);
}
}
}
export {
U as extendDomain,
h as isWellFormedNumberDomain,
q as numericalDomainSpecifiedWithoutRequiringData,
B as parseNumericalUserDomain
};