cerebrate/webroot/js/node_modules/mermaid/dist/ordinal-475e0c0c.js

83 lines
2.2 KiB
JavaScript

import { i as initRange } from "./init-cc95ec8e.js";
class InternMap extends Map {
constructor(entries, key = keyof) {
super();
Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
if (entries != null)
for (const [key2, value] of entries)
this.set(key2, value);
}
get(key) {
return super.get(intern_get(this, key));
}
has(key) {
return super.has(intern_get(this, key));
}
set(key, value) {
return super.set(intern_set(this, key), value);
}
delete(key) {
return super.delete(intern_delete(this, key));
}
}
function intern_get({ _intern, _key }, value) {
const key = _key(value);
return _intern.has(key) ? _intern.get(key) : value;
}
function intern_set({ _intern, _key }, value) {
const key = _key(value);
if (_intern.has(key))
return _intern.get(key);
_intern.set(key, value);
return value;
}
function intern_delete({ _intern, _key }, value) {
const key = _key(value);
if (_intern.has(key)) {
value = _intern.get(key);
_intern.delete(key);
}
return value;
}
function keyof(value) {
return value !== null && typeof value === "object" ? value.valueOf() : value;
}
const implicit = Symbol("implicit");
function ordinal() {
var index = new InternMap(), domain = [], range = [], unknown = implicit;
function scale(d) {
let i = index.get(d);
if (i === void 0) {
if (unknown !== implicit)
return unknown;
index.set(d, i = domain.push(d) - 1);
}
return range[i % range.length];
}
scale.domain = function(_) {
if (!arguments.length)
return domain.slice();
domain = [], index = new InternMap();
for (const value of _) {
if (index.has(value))
continue;
index.set(value, domain.push(value) - 1);
}
return scale;
};
scale.range = function(_) {
return arguments.length ? (range = Array.from(_), scale) : range.slice();
};
scale.unknown = function(_) {
return arguments.length ? (unknown = _, scale) : unknown;
};
scale.copy = function() {
return ordinal(domain, range).unknown(unknown);
};
initRange.apply(scale, arguments);
return scale;
}
export {
ordinal as o
};