UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.

1,370 lines 6.41 MB
(function(global2, factory) { typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.mermaid = factory()); })(this, function() { "use strict"; function dedent(templ) { var values2 = []; for (var _i = 1; _i < arguments.length; _i++) { values2[_i - 1] = arguments[_i]; } var strings = Array.from(typeof templ === "string" ? [templ] : templ); strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, ""); var indentLengths = strings.reduce(function(arr, str2) { var matches = str2.match(/\n([\t ]+|(?!\s).)/g); if (matches) { return arr.concat(matches.map(function(match) { var _a, _b; return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0; })); } return arr; }, []); if (indentLengths.length) { var pattern_1 = new RegExp("\n[ ]{" + Math.min.apply(Math, indentLengths) + "}", "g"); strings = strings.map(function(str2) { return str2.replace(pattern_1, "\n"); }); } strings[0] = strings[0].replace(/^\r?\n/, ""); var string2 = strings[0]; values2.forEach(function(value, i2) { var endentations = string2.match(/(?:^|\n)( *)$/); var endentation = endentations ? endentations[1] : ""; var indentedValue = value; if (typeof value === "string" && value.includes("\n")) { indentedValue = String(value).split("\n").map(function(str2, i3) { return i3 === 0 ? str2 : "" + endentation + str2; }).join("\n"); } string2 += indentedValue + strings[i2 + 1]; }); return string2; } var SECONDS_A_MINUTE = 60; var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60; var SECONDS_A_DAY = SECONDS_A_HOUR * 24; var SECONDS_A_WEEK = SECONDS_A_DAY * 7; var MILLISECONDS_A_SECOND = 1e3; var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND; var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND; var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND; var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND; var MS = "millisecond"; var S = "second"; var MIN = "minute"; var H = "hour"; var D = "day"; var W = "week"; var M = "month"; var Q = "quarter"; var Y = "year"; var DATE = "date"; var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ"; var INVALID_DATE_STRING = "Invalid Date"; var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/; var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g; const en = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function ordinal2(n) { var s = ["th", "st", "nd", "rd"]; var v = n % 100; return "[" + n + (s[(v - 20) % 10] || s[v] || s[0]) + "]"; } }; var padStart$1 = function padStart2(string2, length2, pad2) { var s = String(string2); if (!s || s.length >= length2) return string2; return "" + Array(length2 + 1 - s.length).join(pad2) + string2; }; var padZoneStr = function padZoneStr2(instance2) { var negMinutes = -instance2.utcOffset(); var minutes = Math.abs(negMinutes); var hourOffset = Math.floor(minutes / 60); var minuteOffset = minutes % 60; return (negMinutes <= 0 ? "+" : "-") + padStart$1(hourOffset, 2, "0") + ":" + padStart$1(minuteOffset, 2, "0"); }; var monthDiff = function monthDiff2(a, b) { if (a.date() < b.date()) return -monthDiff2(b, a); var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()); var anchor = a.clone().add(wholeMonthDiff, M); var c2 = b - anchor < 0; var anchor2 = a.clone().add(wholeMonthDiff + (c2 ? -1 : 1), M); return +(-(wholeMonthDiff + (b - anchor) / (c2 ? anchor - anchor2 : anchor2 - anchor)) || 0); }; var absFloor = function absFloor2(n) { return n < 0 ? Math.ceil(n) || 0 : Math.floor(n); }; var prettyUnit = function prettyUnit2(u2) { var special = { M, y: Y, w: W, d: D, D: DATE, h: H, m: MIN, s: S, ms: MS, Q }; return special[u2] || String(u2 || "").toLowerCase().replace(/s$/, ""); }; var isUndefined$1 = function isUndefined2(s) { return s === void 0; }; const U = { s: padStart$1, z: padZoneStr, m: monthDiff, a: absFloor, p: prettyUnit, u: isUndefined$1 }; var L = "en"; var Ls = {}; Ls[L] = en; var isDayjs = function isDayjs2(d) { return d instanceof Dayjs; }; var parseLocale = function parseLocale2(preset, object2, isLocal) { var l; if (!preset) return L; if (typeof preset === "string") { var presetLower = preset.toLowerCase(); if (Ls[presetLower]) { l = presetLower; } if (object2) { Ls[presetLower] = object2; l = presetLower; } var presetSplit = preset.split("-"); if (!l && presetSplit.length > 1) { return parseLocale2(presetSplit[0]); } } else { var name2 = preset.name; Ls[name2] = preset; l = name2; } if (!isLocal && l) L = l; return l || !isLocal && L; }; var dayjs = function dayjs2(date2, c2) { if (isDayjs(date2)) { return date2.clone(); } var cfg = typeof c2 === "object" ? c2 : {}; cfg.date = date2; cfg.args = arguments; return new Dayjs(cfg); }; var wrapper = function wrapper2(date2, instance2) { return dayjs(date2, { locale: instance2.$L, utc: instance2.$u, x: instance2.$x, $offset: instance2.$offset // todo: refactor; do not use this.$offset in you code }); }; var Utils$1 = U; Utils$1.l = parseLocale; Utils$1.i = isDayjs; Utils$1.w = wrapper; var parseDate = function parseDate2(cfg) { var date2 = cfg.date, utc = cfg.utc; if (date2 === null) return /* @__PURE__ */ new Date(NaN); if (Utils$1.u(date2)) return /* @__PURE__ */ new Date(); if (date2 instanceof Date) return new Date(date2); if (typeof date2 === "string" && !/Z$/i.test(date2)) { var d = date2.match(REGEX_PARSE); if (d) { var m = d[2] - 1 || 0; var ms = (d[7] || "0").substring(0, 3); if (utc) { return new Date(Date.UTC(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms)); } return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms); } } return new Date(date2); }; var Dayjs = /* @__PURE__ */ function() { function Dayjs2(cfg) { this.$L = parseLocale(cfg.locale, null, true); this.parse(cfg); } var _proto = Dayjs2.prototype; _proto.parse = function parse2(cfg) { this.$d = parseDate(cfg); this.$x = cfg.x || {}; this.init(); }; _proto.init = function init2() { var $d = this.$d; this.$y = $d.getFullYear(); this.$M = $d.getMonth(); this.$D = $d.getDate(); this.$W = $d.getDay(); this.$H = $d.getHours(); this.$m = $d.getMinutes(); this.$s = $d.getSeconds(); this.$ms = $d.getMilliseconds(); }; _proto.$utils = function $utils() { return Utils$1; }; _proto.isValid = function isValid() { return !(this.$d.toString() === INVALID_DATE_STRING); }; _proto.isSame = function isSame(that, units) { var other = dayjs(that); return this.startOf(units) <= other && other <= this.endOf(units); }; _proto.isAfter = function isAfter(that, units) { return dayjs(that) < this.startOf(units); }; _proto.isBefore = function isBefore(that, units) { return this.endOf(units) < dayjs(that); }; _proto.$g = function $g(input, get2, set2) { if (Utils$1.u(input)) return this[get2]; return this.set(set2, input); }; _proto.unix = function unix() { return Math.floor(this.valueOf() / 1e3); }; _proto.valueOf = function valueOf() { return this.$d.getTime(); }; _proto.startOf = function startOf(units, _startOf) { var _this = this; var isStartOf = !Utils$1.u(_startOf) ? _startOf : true; var unit2 = Utils$1.p(units); var instanceFactory = function instanceFactory2(d, m) { var ins = Utils$1.w(_this.$u ? Date.UTC(_this.$y, m, d) : new Date(_this.$y, m, d), _this); return isStartOf ? ins : ins.endOf(D); }; var instanceFactorySet = function instanceFactorySet2(method, slice2) { var argumentStart = [0, 0, 0, 0]; var argumentEnd = [23, 59, 59, 999]; return Utils$1.w(_this.toDate()[method].apply( // eslint-disable-line prefer-spread _this.toDate("s"), (isStartOf ? argumentStart : argumentEnd).slice(slice2) ), _this); }; var $W = this.$W, $M = this.$M, $D = this.$D; var utcPad = "set" + (this.$u ? "UTC" : ""); switch (unit2) { case Y: return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11); case M: return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1); case W: { var weekStart = this.$locale().weekStart || 0; var gap = ($W < weekStart ? $W + 7 : $W) - weekStart; return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M); } case D: case DATE: return instanceFactorySet(utcPad + "Hours", 0); case H: return instanceFactorySet(utcPad + "Minutes", 1); case MIN: return instanceFactorySet(utcPad + "Seconds", 2); case S: return instanceFactorySet(utcPad + "Milliseconds", 3); default: return this.clone(); } }; _proto.endOf = function endOf(arg) { return this.startOf(arg, false); }; _proto.$set = function $set(units, _int) { var _C$D$C$DATE$C$M$C$Y$C; var unit2 = Utils$1.p(units); var utcPad = "set" + (this.$u ? "UTC" : ""); var name2 = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit2]; var arg = unit2 === D ? this.$D + (_int - this.$W) : _int; if (unit2 === M || unit2 === Y) { var date2 = this.clone().set(DATE, 1); date2.$d[name2](arg); date2.init(); this.$d = date2.set(DATE, Math.min(this.$D, date2.daysInMonth())).$d; } else if (name2) this.$d[name2](arg); this.init(); return this; }; _proto.set = function set2(string2, _int2) { return this.clone().$set(string2, _int2); }; _proto.get = function get2(unit2) { return this[Utils$1.p(unit2)](); }; _proto.add = function add(number2, units) { var _this2 = this, _C$MIN$C$H$C$S$unit; number2 = Number(number2); var unit2 = Utils$1.p(units); var instanceFactorySet = function instanceFactorySet2(n) { var d = dayjs(_this2); return Utils$1.w(d.date(d.date() + Math.round(n * number2)), _this2); }; if (unit2 === M) { return this.set(M, this.$M + number2); } if (unit2 === Y) { return this.set(Y, this.$y + number2); } if (unit2 === D) { return instanceFactorySet(1); } if (unit2 === W) { return instanceFactorySet(7); } var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit2] || 1; var nextTimeStamp = this.$d.getTime() + number2 * step; return Utils$1.w(nextTimeStamp, this); }; _proto.subtract = function subtract(number2, string2) { return this.add(number2 * -1, string2); }; _proto.format = function format2(formatStr) { var _this3 = this; var locale2 = this.$locale(); if (!this.isValid()) return locale2.invalidDate || INVALID_DATE_STRING; var str2 = formatStr || FORMAT_DEFAULT; var zoneStr = Utils$1.z(this); var $H = this.$H, $m = this.$m, $M = this.$M; var weekdays = locale2.weekdays, months = locale2.months, meridiem = locale2.meridiem; var getShort = function getShort2(arr, index2, full, length2) { return arr && (arr[index2] || arr(_this3, str2)) || full[index2].slice(0, length2); }; var get$H = function get$H2(num) { return Utils$1.s($H % 12 || 12, num, "0"); }; var meridiemFunc = meridiem || function(hour2, minute2, isLowercase) { var m = hour2 < 12 ? "AM" : "PM"; return isLowercase ? m.toLowerCase() : m; }; var matches = { YY: String(this.$y).slice(-2), YYYY: this.$y, M: $M + 1, MM: Utils$1.s($M + 1, 2, "0"), MMM: getShort(locale2.monthsShort, $M, months, 3), MMMM: getShort(months, $M), D: this.$D, DD: Utils$1.s(this.$D, 2, "0"), d: String(this.$W), dd: getShort(locale2.weekdaysMin, this.$W, weekdays, 2), ddd: getShort(locale2.weekdaysShort, this.$W, weekdays, 3), dddd: weekdays[this.$W], H: String($H), HH: Utils$1.s($H, 2, "0"), h: get$H(1), hh: get$H(2), a: meridiemFunc($H, $m, true), A: meridiemFunc($H, $m, false), m: String($m), mm: Utils$1.s($m, 2, "0"), s: String(this.$s), ss: Utils$1.s(this.$s, 2, "0"), SSS: Utils$1.s(this.$ms, 3, "0"), Z: zoneStr // 'ZZ' logic below }; return str2.replace(REGEX_FORMAT, function(match, $1) { return $1 || matches[match] || zoneStr.replace(":", ""); }); }; _proto.utcOffset = function utcOffset() { return -Math.round(this.$d.getTimezoneOffset() / 15) * 15; }; _proto.diff = function diff(input, units, _float) { var _C$Y$C$M$C$Q$C$W$C$D$; var unit2 = Utils$1.p(units); var that = dayjs(input); var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE; var diff2 = this - that; var result = Utils$1.m(this, that); result = (_C$Y$C$M$C$Q$C$W$C$D$ = {}, _C$Y$C$M$C$Q$C$W$C$D$[Y] = result / 12, _C$Y$C$M$C$Q$C$W$C$D$[M] = result, _C$Y$C$M$C$Q$C$W$C$D$[Q] = result / 3, _C$Y$C$M$C$Q$C$W$C$D$[W] = (diff2 - zoneDelta) / MILLISECONDS_A_WEEK, _C$Y$C$M$C$Q$C$W$C$D$[D] = (diff2 - zoneDelta) / MILLISECONDS_A_DAY, _C$Y$C$M$C$Q$C$W$C$D$[H] = diff2 / MILLISECONDS_A_HOUR, _C$Y$C$M$C$Q$C$W$C$D$[MIN] = diff2 / MILLISECONDS_A_MINUTE, _C$Y$C$M$C$Q$C$W$C$D$[S] = diff2 / MILLISECONDS_A_SECOND, _C$Y$C$M$C$Q$C$W$C$D$)[unit2] || diff2; return _float ? result : Utils$1.a(result); }; _proto.daysInMonth = function daysInMonth() { return this.endOf(M).$D; }; _proto.$locale = function $locale() { return Ls[this.$L]; }; _proto.locale = function locale2(preset, object2) { if (!preset) return this.$L; var that = this.clone(); var nextLocaleName = parseLocale(preset, object2, true); if (nextLocaleName) that.$L = nextLocaleName; return that; }; _proto.clone = function clone2() { return Utils$1.w(this.$d, this); }; _proto.toDate = function toDate() { return new Date(this.valueOf()); }; _proto.toJSON = function toJSON() { return this.isValid() ? this.toISOString() : null; }; _proto.toISOString = function toISOString() { return this.$d.toISOString(); }; _proto.toString = function toString2() { return this.$d.toUTCString(); }; return Dayjs2; }(); var proto = Dayjs.prototype; dayjs.prototype = proto; [["$ms", MS], ["$s", S], ["$m", MIN], ["$H", H], ["$W", D], ["$M", M], ["$y", Y], ["$D", DATE]].forEach(function(g) { proto[g[1]] = function(input) { return this.$g(input, g[0], g[1]); }; }); dayjs.extend = function(plugin2, option) { if (!plugin2.$i) { plugin2(option, Dayjs, dayjs); plugin2.$i = true; } return dayjs; }; dayjs.locale = parseLocale; dayjs.isDayjs = isDayjs; dayjs.unix = function(timestamp2) { return dayjs(timestamp2 * 1e3); }; dayjs.en = Ls[L]; dayjs.Ls = Ls; dayjs.p = {}; const LEVELS = { trace: 0, debug: 1, info: 2, warn: 3, error: 4, fatal: 5 }; const log$1 = { trace: (..._args) => { }, debug: (..._args) => { }, info: (..._args) => { }, warn: (..._args) => { }, error: (..._args) => { }, fatal: (..._args) => { } }; const setLogLevel$1 = function(level = "fatal") { let numericLevel = LEVELS.fatal; if (typeof level === "string") { level = level.toLowerCase(); if (level in LEVELS) { numericLevel = LEVELS[level]; } } else if (typeof level === "number") { numericLevel = level; } log$1.trace = () => { }; log$1.debug = () => { }; log$1.info = () => { }; log$1.warn = () => { }; log$1.error = () => { }; log$1.fatal = () => { }; if (numericLevel <= LEVELS.fatal) { log$1.fatal = console.error ? console.error.bind(console, format$1("FATAL"), "color: orange") : console.log.bind(console, "\x1B[35m", format$1("FATAL")); } if (numericLevel <= LEVELS.error) { log$1.error = console.error ? console.error.bind(console, format$1("ERROR"), "color: orange") : console.log.bind(console, "\x1B[31m", format$1("ERROR")); } if (numericLevel <= LEVELS.warn) { log$1.warn = console.warn ? console.warn.bind(console, format$1("WARN"), "color: orange") : console.log.bind(console, `\x1B[33m`, format$1("WARN")); } if (numericLevel <= LEVELS.info) { log$1.info = console.info ? console.info.bind(console, format$1("INFO"), "color: lightblue") : console.log.bind(console, "\x1B[34m", format$1("INFO")); } if (numericLevel <= LEVELS.debug) { log$1.debug = console.debug ? console.debug.bind(console, format$1("DEBUG"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format$1("DEBUG")); } if (numericLevel <= LEVELS.trace) { log$1.trace = console.debug ? console.debug.bind(console, format$1("TRACE"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format$1("TRACE")); } }; const format$1 = (level) => { const time2 = dayjs().format("ss.SSS"); return `%c${time2} : ${level} : `; }; var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x2) { return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; } var dist = {}; Object.defineProperty(dist, "__esModule", { value: true }); var sanitizeUrl_1 = dist.sanitizeUrl = void 0; var invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im; var htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g; var htmlCtrlEntityRegex = /&(newline|tab);/gi; var ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim; var urlSchemeRegex = /^.+(:|&colon;)/gim; var relativeFirstCharacters = [".", "/"]; function isRelativeUrlWithoutProtocol(url) { return relativeFirstCharacters.indexOf(url[0]) > -1; } function decodeHtmlCharacters(str2) { return str2.replace(htmlEntitiesRegex, function(match, dec) { return String.fromCharCode(dec); }); } function sanitizeUrl(url) { var sanitizedUrl = decodeHtmlCharacters(url || "").replace(htmlCtrlEntityRegex, "").replace(ctrlCharactersRegex, "").trim(); if (!sanitizedUrl) { return "about:blank"; } if (isRelativeUrlWithoutProtocol(sanitizedUrl)) { return sanitizedUrl; } var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex); if (!urlSchemeParseResults) { return sanitizedUrl; } var urlScheme = urlSchemeParseResults[0]; if (invalidProtocolRegex.test(urlScheme)) { return "about:blank"; } return sanitizedUrl; } sanitizeUrl_1 = dist.sanitizeUrl = sanitizeUrl; function ascending$1(a, b) { return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; } function descending$1(a, b) { return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; } function bisector(f2) { let compare1, compare2, delta; if (f2.length !== 2) { compare1 = ascending$1; compare2 = (d, x2) => ascending$1(f2(d), x2); delta = (d, x2) => f2(d) - x2; } else { compare1 = f2 === ascending$1 || f2 === descending$1 ? f2 : zero$1; compare2 = f2; delta = f2; } function left2(a, x2, lo = 0, hi = a.length) { if (lo < hi) { if (compare1(x2, x2) !== 0) return hi; do { const mid = lo + hi >>> 1; if (compare2(a[mid], x2) < 0) lo = mid + 1; else hi = mid; } while (lo < hi); } return lo; } function right2(a, x2, lo = 0, hi = a.length) { if (lo < hi) { if (compare1(x2, x2) !== 0) return hi; do { const mid = lo + hi >>> 1; if (compare2(a[mid], x2) <= 0) lo = mid + 1; else hi = mid; } while (lo < hi); } return lo; } function center2(a, x2, lo = 0, hi = a.length) { const i2 = left2(a, x2, lo, hi - 1); return i2 > lo && delta(a[i2 - 1], x2) > -delta(a[i2], x2) ? i2 - 1 : i2; } return { left: left2, center: center2, right: right2 }; } function zero$1() { return 0; } function number$3(x2) { return x2 === null ? NaN : +x2; } const ascendingBisect = bisector(ascending$1); const bisectRight = ascendingBisect.right; bisector(number$3).center; const bisect = bisectRight; class InternMap extends Map { constructor(entries2, key = keyof) { super(); Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } }); if (entries2 != null) for (const [key2, value] of entries2) 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; } var e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2); function ticks(start2, stop, count) { var reverse, i2 = -1, n, ticks2, step; stop = +stop, start2 = +start2, count = +count; if (start2 === stop && count > 0) return [start2]; if (reverse = stop < start2) n = start2, start2 = stop, stop = n; if ((step = tickIncrement(start2, stop, count)) === 0 || !isFinite(step)) return []; if (step > 0) { let r0 = Math.round(start2 / step), r1 = Math.round(stop / step); if (r0 * step < start2) ++r0; if (r1 * step > stop) --r1; ticks2 = new Array(n = r1 - r0 + 1); while (++i2 < n) ticks2[i2] = (r0 + i2) * step; } else { step = -step; let r0 = Math.round(start2 * step), r1 = Math.round(stop * step); if (r0 / step < start2) ++r0; if (r1 / step > stop) --r1; ticks2 = new Array(n = r1 - r0 + 1); while (++i2 < n) ticks2[i2] = (r0 + i2) / step; } if (reverse) ticks2.reverse(); return ticks2; } function tickIncrement(start2, stop, count) { var step = (stop - start2) / Math.max(0, count), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power); return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1); } function tickStep(start2, stop, count) { var step0 = Math.abs(stop - start2) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1; if (error >= e10) step1 *= 10; else if (error >= e5) step1 *= 5; else if (error >= e2) step1 *= 2; return stop < start2 ? -step1 : step1; } function max$2(values2, valueof) { let max2; if (valueof === void 0) { for (const value of values2) { if (value != null && (max2 < value || max2 === void 0 && value >= value)) { max2 = value; } } } else { let index2 = -1; for (let value of values2) { if ((value = valueof(value, ++index2, values2)) != null && (max2 < value || max2 === void 0 && value >= value)) { max2 = value; } } } return max2; } function min$2(values2, valueof) { let min2; if (valueof === void 0) { for (const value of values2) { if (value != null && (min2 > value || min2 === void 0 && value >= value)) { min2 = value; } } } else { let index2 = -1; for (let value of values2) { if ((value = valueof(value, ++index2, values2)) != null && (min2 > value || min2 === void 0 && value >= value)) { min2 = value; } } } return min2; } function identity$5(x2) { return x2; } var top = 1, right = 2, bottom = 3, left = 4, epsilon$2 = 1e-6; function translateX(x2) { return "translate(" + x2 + ",0)"; } function translateY(y2) { return "translate(0," + y2 + ")"; } function number$2(scale) { return (d) => +scale(d); } function center(scale, offset) { offset = Math.max(0, scale.bandwidth() - offset * 2) / 2; if (scale.round()) offset = Math.round(offset); return (d) => +scale(d) + offset; } function entering() { return !this.__axis; } function axis(orient, scale) { var tickArguments = [], tickValues = null, tickFormat2 = null, tickSizeInner = 6, tickSizeOuter = 6, tickPadding = 3, offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, k = orient === top || orient === left ? -1 : 1, x2 = orient === left || orient === right ? "x" : "y", transform = orient === top || orient === bottom ? translateX : translateY; function axis2(context) { var values2 = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain() : tickValues, format2 = tickFormat2 == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$5 : tickFormat2, spacing = Math.max(tickSizeInner, 0) + tickPadding, range2 = scale.range(), range0 = +range2[0] + offset, range1 = +range2[range2.length - 1] + offset, position2 = (scale.bandwidth ? center : number$2)(scale.copy(), offset), selection2 = context.selection ? context.selection() : context, path2 = selection2.selectAll(".domain").data([null]), tick = selection2.selectAll(".tick").data(values2, scale).order(), tickExit = tick.exit(), tickEnter = tick.enter().append("g").attr("class", "tick"), line2 = tick.select("line"), text2 = tick.select("text"); path2 = path2.merge(path2.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")); tick = tick.merge(tickEnter); line2 = line2.merge(tickEnter.append("line").attr("stroke", "currentColor").attr(x2 + "2", k * tickSizeInner)); text2 = text2.merge(tickEnter.append("text").attr("fill", "currentColor").attr(x2, k * spacing).attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em")); if (context !== selection2) { path2 = path2.transition(context); tick = tick.transition(context); line2 = line2.transition(context); text2 = text2.transition(context); tickExit = tickExit.transition(context).attr("opacity", epsilon$2).attr("transform", function(d) { return isFinite(d = position2(d)) ? transform(d + offset) : this.getAttribute("transform"); }); tickEnter.attr("opacity", epsilon$2).attr("transform", function(d) { var p = this.parentNode.__axis; return transform((p && isFinite(p = p(d)) ? p : position2(d)) + offset); }); } tickExit.remove(); path2.attr("d", orient === left || orient === right ? tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1 : tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1); tick.attr("opacity", 1).attr("transform", function(d) { return transform(position2(d) + offset); }); line2.attr(x2 + "2", k * tickSizeInner); text2.attr(x2, k * spacing).text(format2); selection2.filter(entering).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle"); selection2.each(function() { this.__axis = position2; }); } axis2.scale = function(_2) { return arguments.length ? (scale = _2, axis2) : scale; }; axis2.ticks = function() { return tickArguments = Array.from(arguments), axis2; }; axis2.tickArguments = function(_2) { return arguments.length ? (tickArguments = _2 == null ? [] : Array.from(_2), axis2) : tickArguments.slice(); }; axis2.tickValues = function(_2) { return arguments.length ? (tickValues = _2 == null ? null : Array.from(_2), axis2) : tickValues && tickValues.slice(); }; axis2.tickFormat = function(_2) { return arguments.length ? (tickFormat2 = _2, axis2) : tickFormat2; }; axis2.tickSize = function(_2) { return arguments.length ? (tickSizeInner = tickSizeOuter = +_2, axis2) : tickSizeInner; }; axis2.tickSizeInner = function(_2) { return arguments.length ? (tickSizeInner = +_2, axis2) : tickSizeInner; }; axis2.tickSizeOuter = function(_2) { return arguments.length ? (tickSizeOuter = +_2, axis2) : tickSizeOuter; }; axis2.tickPadding = function(_2) { return arguments.length ? (tickPadding = +_2, axis2) : tickPadding; }; axis2.offset = function(_2) { return arguments.length ? (offset = +_2, axis2) : offset; }; return axis2; } function axisTop(scale) { return axis(top, scale); } function axisBottom(scale) { return axis(bottom, scale); } var noop$2 = { value: () => { } }; function dispatch() { for (var i2 = 0, n = arguments.length, _2 = {}, t4; i2 < n; ++i2) { if (!(t4 = arguments[i2] + "") || t4 in _2 || /[\s.]/.test(t4)) throw new Error("illegal type: " + t4); _2[t4] = []; } return new Dispatch(_2); } function Dispatch(_2) { this._ = _2; } function parseTypenames$1(typenames, types) { return typenames.trim().split(/^|\s+/).map(function(t4) { var name2 = "", i2 = t4.indexOf("."); if (i2 >= 0) name2 = t4.slice(i2 + 1), t4 = t4.slice(0, i2); if (t4 && !types.hasOwnProperty(t4)) throw new Error("unknown type: " + t4); return { type: t4, name: name2 }; }); } Dispatch.prototype = dispatch.prototype = { constructor: Dispatch, on: function(typename, callback) { var _2 = this._, T = parseTypenames$1(typename + "", _2), t4, i2 = -1, n = T.length; if (arguments.length < 2) { while (++i2 < n) if ((t4 = (typename = T[i2]).type) && (t4 = get$3(_2[t4], typename.name))) return t4; return; } if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback); while (++i2 < n) { if (t4 = (typename = T[i2]).type) _2[t4] = set$3(_2[t4], typename.name, callback); else if (callback == null) for (t4 in _2) _2[t4] = set$3(_2[t4], typename.name, null); } return this; }, copy: function() { var copy2 = {}, _2 = this._; for (var t4 in _2) copy2[t4] = _2[t4].slice(); return new Dispatch(copy2); }, call: function(type2, that) { if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i2 = 0, n, t4; i2 < n; ++i2) args[i2] = arguments[i2 + 2]; if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2); for (t4 = this._[type2], i2 = 0, n = t4.length; i2 < n; ++i2) t4[i2].value.apply(that, args); }, apply: function(type2, that, args) { if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2); for (var t4 = this._[type2], i2 = 0, n = t4.length; i2 < n; ++i2) t4[i2].value.apply(that, args); } }; function get$3(type2, name2) { for (var i2 = 0, n = type2.length, c2; i2 < n; ++i2) { if ((c2 = type2[i2]).name === name2) { return c2.value; } } } function set$3(type2, name2, callback) { for (var i2 = 0, n = type2.length; i2 < n; ++i2) { if (type2[i2].name === name2) { type2[i2] = noop$2, type2 = type2.slice(0, i2).concat(type2.slice(i2 + 1)); break; } } if (callback != null) type2.push({ name: name2, value: callback }); return type2; } var xhtml = "http://www.w3.org/1999/xhtml"; const namespaces$1 = { svg: "http://www.w3.org/2000/svg", xhtml, xlink: "http://www.w3.org/1999/xlink", xml: "http://www.w3.org/XML/1998/namespace", xmlns: "http://www.w3.org/2000/xmlns/" }; function namespace(name2) { var prefix = name2 += "", i2 = prefix.indexOf(":"); if (i2 >= 0 && (prefix = name2.slice(0, i2)) !== "xmlns") name2 = name2.slice(i2 + 1); return namespaces$1.hasOwnProperty(prefix) ? { space: namespaces$1[prefix], local: name2 } : name2; } function creatorInherit(name2) { return function() { var document2 = this.ownerDocument, uri = this.namespaceURI; return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name2) : document2.createElementNS(uri, name2); }; } function creatorFixed(fullname) { return function() { return this.ownerDocument.createElementNS(fullname.space, fullname.local); }; } function creator(name2) { var fullname = namespace(name2); return (fullname.local ? creatorFixed : creatorInherit)(fullname); } function none() { } function selector(selector2) { return selector2 == null ? none : function() { return this.querySelector(selector2); }; } function selection_select(select2) { if (typeof select2 !== "function") select2 = selector(select2); for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node2, subnode, i2 = 0; i2 < n; ++i2) { if ((node2 = group[i2]) && (subnode = select2.call(node2, node2.__data__, i2, group))) { if ("__data__" in node2) subnode.__data__ = node2.__data__; subgroup[i2] = subnode; } } } return new Selection$1(subgroups, this._parents); } function array$1(x2) { return x2 == null ? [] : Array.isArray(x2) ? x2 : Array.from(x2); } function empty() { return []; } function selectorAll(selector2) { return selector2 == null ? empty : function() { return this.querySelectorAll(selector2); }; } function arrayAll(select2) { return function() { return array$1(select2.apply(this, arguments)); }; } function selection_selectAll(select2) { if (typeof select2 === "function") select2 = arrayAll(select2); else select2 = selectorAll(select2); for (var groups = this._groups, m = groups.length, subgroups = [], parents2 = [], j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, node2, i2 = 0; i2 < n; ++i2) { if (node2 = group[i2]) { subgroups.push(select2.call(node2, node2.__data__, i2, group)); parents2.push(node2); } } } return new Selection$1(subgroups, parents2); } function matcher(selector2) { return function() { return this.matches(selector2); }; } function childMatcher(selector2) { return function(node2) { return node2.matches(selector2); }; } var find$2 = Array.prototype.find; function childFind(match) { return function() { return find$2.call(this.children, match); }; } function childFirst() { return this.firstElementChild; } function selection_selectChild(match) { return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match))); } var filter$1 = Array.prototype.filter; function children() { return Array.from(this.children); } function childrenFilter(match) { return function() { return filter$1.call(this.children, match); }; } function selection_selectChildren(match) { return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match))); } function selection_filter(match) { if (typeof match !== "function") match = matcher(match); for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node2, i2 = 0; i2 < n; ++i2) { if ((node2 = group[i2]) && match.call(node2, node2.__data__, i2, group)) { subgroup.push(node2); } } } return new Selection$1(subgroups, this._parents); } function sparse(update2) { return new Array(update2.length); } function selection_enter() { return new Selection$1(this._enter || this._groups.map(sparse), this._parents); } function EnterNode(parent, datum2) { this.ownerDocument = parent.ownerDocument; this.namespaceURI = parent.namespaceURI; this._next = null; this._parent = parent; this.__data__ = datum2; } EnterNode.prototype = { constructor: EnterNode, appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, insertBefore: function(child, next2) { return this._parent.insertBefore(child, next2); }, querySelector: function(selector2) { return this._parent.querySelector(selector2); }, querySelectorAll: function(selector2) { return this._parent.querySelectorAll(selector2); } }; function constant$3(x2) { return function() { return x2; }; } function bindIndex(parent, group, enter2, update2, exit2, data) { var i2 = 0, node2, groupLength = group.length, dataLength = data.length; for (; i2 < dataLength; ++i2) { if (node2 = group[i2]) { node2.__data__ = data[i2]; update2[i2] = node2; } else { enter2[i2] = new EnterNode(parent, data[i2]); } } for (; i2 < groupLength; ++i2) { if (node2 = group[i2]) { exit2[i2] = node2; } } } function bindKey(parent, group, enter2, update2, exit2, data, key) { var i2, node2, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue; for (i2 = 0; i2 < groupLength; ++i2) { if (node2 = group[i2]) { keyValues[i2] = keyValue = key.call(node2, node2.__data__, i2, group) + ""; if (nodeByKeyValue.has(keyValue)) { exit2[i2] = node2; } else { nodeByKeyValue.set(keyValue, node2); } } } for (i2 = 0; i2 < dataLength; ++i2) { keyValue = key.call(parent, data[i2], i2, data) + ""; if (node2 = nodeByKeyValue.get(keyValue)) { update2[i2] = node2; node2.__data__ = data[i2]; nodeByKeyValue.delete(keyValue); } else { enter2[i2] = new EnterNode(parent, data[i2]); } } for (i2 = 0; i2 < groupLength; ++i2) { if ((node2 = group[i2]) && nodeByKeyValue.get(keyValues[i2]) === node2) { exit2[i2] = node2; } } } function datum(node2) { return node2.__data__; } function selection_data(value, key) { if (!arguments.length) return Array.from(this, datum); var bind = key ? bindKey : bindIndex, parents2 = this._parents, groups = this._groups; if (typeof value !== "function") value = constant$3(value); for (var m = groups.length, update2 = new Array(m), enter2 = new Array(m), exit2 = new Array(m), j = 0; j < m; ++j) { var parent = parents2[j], group = groups[j], groupLength = group.length, data = arraylike(value.call(parent, parent && parent.__data__, j, parents2)), dataLength = data.length, enterGroup = enter2[j] = new Array(dataLength), updateGroup = update2[j] = new Array(dataLength), exitGroup = exit2[j] = new Array(groupLength); bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); for (var i0 = 0, i1 = 0, previous2, next2; i0 < dataLength; ++i0) { if (previous2 = enterGroup[i0]) { if (i0 >= i1) i1 = i0 + 1; while (!(next2 = updateGroup[i1]) && ++i1 < dataLength) ; previous2._next = next2 || null; } } } update2 = new Selection$1(update2, parents2); update2._enter = enter2; update2._exit = exit2; return update2; } function arraylike(data) { return typeof data === "object" && "length" in data ? data : Array.from(data); } function selection_exit() { return new Selection$1(this._exit || this._groups.map(sparse), this._parents); } function selection_join(onenter, onupdate, onexit) { var enter2 = this.enter(), update2 = this, exit2 = this.exit(); if (typeof onenter === "function") { enter2 = onenter(enter2); if (enter2) enter2 = enter2.selection(); } else { enter2 = enter2.append(onenter + ""); } if (onupdate != null) { update2 = onupdate(update2); if (update2) update2 = update2.selection(); } if (onexit == null) exit2.remove(); else onexit(exit2); return enter2 && update2 ? enter2.merge(update2).order() : update2; } function selection_merge(context) { var selection2 = context.selection ? context.selection() : context; for (var groups0 = this._groups, groups1 = selection2._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge2 = merges[j] = new Array(n), node2, i2 = 0; i2 < n; ++i2) { if (node2 = group0[i2] || group1[i2]) { merge2[i2] = node2; } } } for (; j < m0; ++j) { merges[j] = groups0[j]; } return new Selection$1(merges, this._parents); } function selection_order() { for (var groups = this._groups, j = -1, m = groups.length; ++j < m; ) { for (var group = groups[j], i2 = group.length - 1, next2 = group[i2], node2; --i2 >= 0; ) { if (node2 = group[i2]) { if (next2 && node2.compareDocumentPosition(next2) ^ 4) next2.parentNode.insertBefore(node2, next2); next2 = node2; } } } return this; } function selection_sort(compare) { if (!compare) compare = ascending; function compareNode(a, b) { return a && b ? compare(a.__data__, b.__data__) : !a - !b; } for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node2, i2 = 0; i2 < n; ++i2) { if (node2 = group[i2]) { sortgroup[i2] = node2; } } sortgroup.sort(compareNode); } return new Selection$1(sortgroups, this._parents).order(); } function ascending(a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; } function selection_call() { var callback = arguments[0]; arguments[0] = this; callback.apply(null, arguments); return this; } function selection_nodes() { return Array.from(this); } function selection_node() { for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { for (var group = groups[j], i2 = 0, n = group.length; i2 < n; ++i2) { var node2 = group[i2]; if (node2) return node2; } } return null; } function selection_size() { let size2 = 0; for (const node2 of this) ++size2; return size2; } function selection_empty() { return !this.node(); } function selection_each(callback) { for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { for (var group = groups[j], i2 = 0, n = group.length, node2; i2 < n; ++i2) { if (node2 = group[i2]) callback.call(node2, node2.__data__, i2, group); } } return this; } function attrRemove$1(name2) { return function() { this.removeAttribute(name2); }; } function attrRemoveNS$1(fullname) { return function() { this.removeAttributeNS(fullname.space, fullname.local); }; } function attrConstant$1(name2, value) { return function() { this.setAttribute(name2, value); }; } function attrConstantNS$1(fullname, value) { return function() { this.setAttributeNS(fullname.space, fullname.local, value); }; } function attrFunction$1(name2, value) { return function() { var v = value.apply(this, arguments); if (v == null) this.removeAttribute(name2); else this.setAttribute(name2, v); }; } function attrFunctionNS$1(fullname, value) { return function() { var v = value.apply(this, arguments); if (v == null) this.removeAttributeNS(fullname.space, fullname.local); else this.setAttributeNS(fullname.space, fullname.local, v); }; } function selection_attr(name2, value) { var fullname = namespace(name2); if (arguments.length < 2) { var node2 = this.node(); return fullname.local ? node2.getAttributeNS(fullname.space, fullname.local) : node2.getAttribute(fullname); } return this.each((value == null ? fullname.local ? attrRemoveNS$1 : attrRemove$1 : typeof value === "function" ? fullname.local ? attrFunctionNS$1 : attrFunction$1 : fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, value)); } function defaultView(node2) { return node2.ownerDocument && node2.ownerDocument.defaultView || node2.document && node2 || node2.defaultView; } function styleRemove$1(name2) { return function() { this.style.removeProperty(name2); }; } function styleConstant$1(name2, value, priority) { return function() { this.style.setProperty(name2, value, priority); }; } function styleFunction$1(name2, value, priority) { return function() { var v = value.apply(this, arguments); if (v == null) this.style.removeProperty(name2); else this.style.setProperty(name2, v, priority); }; } function selection_style(name2, value, priority) { return arguments.length > 1 ? this.each((value == null ? styleRemove$1 : typeof value === "function" ? styleFunction$1 : styleConstant$1)(name2, value, priority == null ? "" : priority)) : styleValue(this.node(), name2); } function styleValue(node2, name2) { return node2.style.getPropertyValue(name2) || defaultView(node2).getComputedStyle(node2, null).getPropertyValue(name2); } function propertyRemove(name2) { return function() { delete this[name2]; }; } function propertyConstant(name2, value) { return function() { this[name2] = value; }; } function propertyFunction(name2, value) { return function() { var v = value.apply(this, arguments); if (v == null) delete this[name2]; else this[name2] = v; }; } function selection_property(name2, value) { return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name2, value)) : this.node()[name2]; } function classArray(string2) { return string2.trim().split