ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
743 lines (731 loc) • 25.6 kB
JavaScript
import { n as l } from "./chunk-Y2CYZVJY-0JxdZxki.js";
import "./src-DtRLxcYO.js";
import { H as ut, K as et, U as dt, a as yt, c as ft, s as pt, v as gt, w as kt, x as lt, y as mt } from "./chunk-WYO6CB5R-DDHkKowO.js";
import { p as wt } from "./chunk-ICXQ74PX-DR8rL-xF.js";
import { t as _t } from "./chunk-VAUOI2AC-izt0o4id.js";
import { t as bt } from "./rough.esm-BWe9E0Nz.js";
var Q = (function() {
var t = /* @__PURE__ */ l(function(e, s, c, i) {
for (c = c || {}, i = e.length; i--; c[e[i]] = s) ;
return c;
}, "o"), u = [1, 4], n = [1, 14], a = [1, 12], r = [1, 13], o = [
6,
7,
8
], k = [1, 20], h = [1, 18], p = [1, 19], y = [
6,
7,
11
], _ = [
1,
6,
13,
14
], m = [1, 23], $ = [1, 24], v = [
1,
6,
7,
11,
13,
14
], P = {
trace: /* @__PURE__ */ l(function() {
}, "trace"),
yy: {},
symbols_: {
error: 2,
start: 3,
ishikawa: 4,
spaceLines: 5,
SPACELINE: 6,
NL: 7,
ISHIKAWA: 8,
document: 9,
stop: 10,
EOF: 11,
statement: 12,
SPACELIST: 13,
TEXT: 14,
$accept: 0,
$end: 1
},
terminals_: {
2: "error",
6: "SPACELINE",
7: "NL",
8: "ISHIKAWA",
11: "EOF",
13: "SPACELIST",
14: "TEXT"
},
productions_: [
0,
[3, 1],
[3, 2],
[5, 1],
[5, 2],
[5, 2],
[4, 2],
[4, 3],
[10, 1],
[10, 1],
[10, 1],
[10, 2],
[10, 2],
[9, 3],
[9, 2],
[12, 2],
[12, 1],
[12, 1],
[12, 1]
],
performAction: /* @__PURE__ */ l(function(s, c, i, d, w, f, E) {
var b = f.length - 1;
switch (w) {
case 6:
case 7:
return d;
case 15:
d.addNode(f[b - 1].length, f[b].trim());
break;
case 16:
d.addNode(0, f[b].trim());
break;
}
}, "anonymous"),
table: [
{
3: 1,
4: 2,
5: 3,
6: [1, 5],
8: u
},
{ 1: [3] },
{ 1: [2, 1] },
{
4: 6,
6: [1, 7],
7: [1, 8],
8: u
},
{
6: n,
7: [1, 10],
9: 9,
12: 11,
13: a,
14: r
},
t(o, [2, 3]),
{ 1: [2, 2] },
t(o, [2, 4]),
t(o, [2, 5]),
{
1: [2, 6],
6: n,
12: 15,
13: a,
14: r
},
{
6: n,
9: 16,
12: 11,
13: a,
14: r
},
{
6: k,
7: h,
10: 17,
11: p
},
t(y, [2, 18], { 14: [1, 21] }),
t(y, [2, 16]),
t(y, [2, 17]),
{
6: k,
7: h,
10: 22,
11: p
},
{
1: [2, 7],
6: n,
12: 15,
13: a,
14: r
},
t(_, [2, 14], {
7: m,
11: $
}),
t(v, [2, 8]),
t(v, [2, 9]),
t(v, [2, 10]),
t(y, [2, 15]),
t(_, [2, 13], {
7: m,
11: $
}),
t(v, [2, 11]),
t(v, [2, 12])
],
defaultActions: {
2: [2, 1],
6: [2, 2]
},
parseError: /* @__PURE__ */ l(function(s, c) {
if (c.recoverable) this.trace(s);
else {
var i = new Error(s);
throw i.hash = c, i;
}
}, "parseError"),
parse: /* @__PURE__ */ l(function(s) {
var c = this, i = [0], d = [], w = [null], f = [], E = this.table, b = "", x = 0, B = 0, S = 0, T = 2, M = 1, C = f.slice.call(arguments, 1), g = Object.create(this.lexer), I = { yy: {} };
for (var V in this.yy) Object.prototype.hasOwnProperty.call(this.yy, V) && (I.yy[V] = this.yy[V]);
g.setInput(s, I.yy), I.yy.lexer = g, I.yy.parser = this, typeof g.yylloc > "u" && (g.yylloc = {});
var R = g.yylloc;
f.push(R);
var Z = g.options && g.options.ranges;
typeof I.yy.parseError == "function" ? this.parseError = I.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
function ct(D) {
i.length = i.length - 2 * D, w.length = w.length - D, f.length = f.length - D;
}
l(ct, "popStack");
function J() {
var D = d.pop() || g.lex() || M;
return typeof D != "number" && (D instanceof Array && (d = D, D = d.pop()), D = c.symbols_[D] || D), D;
}
l(J, "lex");
for (var L, K, W, N, X, F = {}, H, O, tt, U; ; ) {
if (W = i[i.length - 1], this.defaultActions[W] ? N = this.defaultActions[W] : ((L === null || typeof L > "u") && (L = J()), N = E[W] && E[W][L]), typeof N > "u" || !N.length || !N[0]) {
var Y = "";
U = [];
for (H in E[W]) this.terminals_[H] && H > T && U.push("'" + this.terminals_[H] + "'");
g.showPosition ? Y = "Parse error on line " + (x + 1) + `:
` + g.showPosition() + `
Expecting ` + U.join(", ") + ", got '" + (this.terminals_[L] || L) + "'" : Y = "Parse error on line " + (x + 1) + ": Unexpected " + (L == M ? "end of input" : "'" + (this.terminals_[L] || L) + "'"), this.parseError(Y, {
text: g.match,
token: this.terminals_[L] || L,
line: g.yylineno,
loc: R,
expected: U
});
}
if (N[0] instanceof Array && N.length > 1) throw new Error("Parse Error: multiple actions possible at state: " + W + ", token: " + L);
switch (N[0]) {
case 1:
i.push(L), w.push(g.yytext), f.push(g.yylloc), i.push(N[1]), L = null, K ? (L = K, K = null) : (B = g.yyleng, b = g.yytext, x = g.yylineno, R = g.yylloc, S > 0 && S--);
break;
case 2:
if (O = this.productions_[N[1]][1], F.$ = w[w.length - O], F._$ = {
first_line: f[f.length - (O || 1)].first_line,
last_line: f[f.length - 1].last_line,
first_column: f[f.length - (O || 1)].first_column,
last_column: f[f.length - 1].last_column
}, Z && (F._$.range = [f[f.length - (O || 1)].range[0], f[f.length - 1].range[1]]), X = this.performAction.apply(F, [
b,
B,
x,
I.yy,
N[1],
w,
f
].concat(C)), typeof X < "u") return X;
O && (i = i.slice(0, -1 * O * 2), w = w.slice(0, -1 * O), f = f.slice(0, -1 * O)), i.push(this.productions_[N[1]][0]), w.push(F.$), f.push(F._$), tt = E[i[i.length - 2]][i[i.length - 1]], i.push(tt);
break;
case 3:
return !0;
}
}
return !0;
}, "parse")
};
P.lexer = /* @__PURE__ */ (function() {
return {
EOF: 1,
parseError: /* @__PURE__ */ l(function(s, c) {
if (this.yy.parser) this.yy.parser.parseError(s, c);
else throw new Error(s);
}, "parseError"),
setInput: /* @__PURE__ */ l(function(e, s) {
return this.yy = s || this.yy || {}, this._input = e, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0
}, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
}, "setInput"),
input: /* @__PURE__ */ l(function() {
var e = this._input[0];
return this.yytext += e, this.yyleng++, this.offset++, this.match += e, this.matched += e, e.match(/(?:\r\n?|\n).*/g) ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), e;
}, "input"),
unput: /* @__PURE__ */ l(function(e) {
var s = e.length, c = e.split(/(?:\r\n?|\n)/g);
this._input = e + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - s), this.offset -= s;
var i = this.match.split(/(?:\r\n?|\n)/g);
this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), c.length - 1 && (this.yylineno -= c.length - 1);
var d = this.yylloc.range;
return this.yylloc = {
first_line: this.yylloc.first_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.first_column,
last_column: c ? (c.length === i.length ? this.yylloc.first_column : 0) + i[i.length - c.length].length - c[0].length : this.yylloc.first_column - s
}, this.options.ranges && (this.yylloc.range = [d[0], d[0] + this.yyleng - s]), this.yyleng = this.yytext.length, this;
}, "unput"),
more: /* @__PURE__ */ l(function() {
return this._more = !0, this;
}, "more"),
reject: /* @__PURE__ */ l(function() {
if (this.options.backtrack_lexer) this._backtrack = !0;
else return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
return this;
}, "reject"),
less: /* @__PURE__ */ l(function(e) {
this.unput(this.match.slice(e));
}, "less"),
pastInput: /* @__PURE__ */ l(function() {
var e = this.matched.substr(0, this.matched.length - this.match.length);
return (e.length > 20 ? "..." : "") + e.substr(-20).replace(/\n/g, "");
}, "pastInput"),
upcomingInput: /* @__PURE__ */ l(function() {
var e = this.match;
return e.length < 20 && (e += this._input.substr(0, 20 - e.length)), (e.substr(0, 20) + (e.length > 20 ? "..." : "")).replace(/\n/g, "");
}, "upcomingInput"),
showPosition: /* @__PURE__ */ l(function() {
var e = this.pastInput(), s = new Array(e.length + 1).join("-");
return e + this.upcomingInput() + `
` + s + "^";
}, "showPosition"),
test_match: /* @__PURE__ */ l(function(e, s) {
var c, i, d;
if (this.options.backtrack_lexer && (d = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
}, this.options.ranges && (d.yylloc.range = this.yylloc.range.slice(0))), i = e[0].match(/(?:\r\n?|\n).*/g), i && (this.yylineno += i.length), this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: i ? i[i.length - 1].length - i[i.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + e[0].length
}, this.yytext += e[0], this.match += e[0], this.matches = e, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(e[0].length), this.matched += e[0], c = this.performAction.call(this, this.yy, this, s, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), c) return c;
if (this._backtrack) {
for (var w in d) this[w] = d[w];
return !1;
}
return !1;
}, "test_match"),
next: /* @__PURE__ */ l(function() {
if (this.done) return this.EOF;
this._input || (this.done = !0);
var e, s, c, i;
this._more || (this.yytext = "", this.match = "");
for (var d = this._currentRules(), w = 0; w < d.length; w++)
if (c = this._input.match(this.rules[d[w]]), c && (!s || c[0].length > s[0].length)) {
if (s = c, i = w, this.options.backtrack_lexer) {
if (e = this.test_match(c, d[w]), e !== !1) return e;
if (this._backtrack) {
s = !1;
continue;
} else return !1;
} else if (!this.options.flex) break;
}
return s ? (e = this.test_match(s, d[i]), e !== !1 ? e : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}, "next"),
lex: /* @__PURE__ */ l(function() {
var s = this.next();
return s || this.lex();
}, "lex"),
begin: /* @__PURE__ */ l(function(s) {
this.conditionStack.push(s);
}, "begin"),
popState: /* @__PURE__ */ l(function() {
return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
}, "popState"),
_currentRules: /* @__PURE__ */ l(function() {
return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
}, "_currentRules"),
topState: /* @__PURE__ */ l(function(s) {
return s = this.conditionStack.length - 1 - Math.abs(s || 0), s >= 0 ? this.conditionStack[s] : "INITIAL";
}, "topState"),
pushState: /* @__PURE__ */ l(function(s) {
this.begin(s);
}, "pushState"),
stateStackSize: /* @__PURE__ */ l(function() {
return this.conditionStack.length;
}, "stateStackSize"),
options: { "case-insensitive": !0 },
performAction: /* @__PURE__ */ l(function(s, c, i, d) {
switch (i) {
case 0:
return 6;
case 1:
return 8;
case 2:
return 8;
case 3:
return 6;
case 4:
return 7;
case 5:
return 13;
case 6:
return 14;
case 7:
return 11;
}
}, "anonymous"),
rules: [
/^(?:\s*%%.*)/i,
/^(?:ishikawa-beta\b)/i,
/^(?:ishikawa\b)/i,
/^(?:[\s]+[\n])/i,
/^(?:[\n]+)/i,
/^(?:[\s]+)/i,
/^(?:[^\n]+)/i,
/^(?:$)/i
],
conditions: { INITIAL: {
rules: [
0,
1,
2,
3,
4,
5,
6,
7
],
inclusive: !0
} }
};
})();
function A() {
this.yy = {};
}
return l(A, "Parser"), A.prototype = P, P.Parser = A, new A();
})();
Q.parser = Q;
var xt = Q, vt = class {
constructor() {
this.stack = [], this.clear = this.clear.bind(this), this.addNode = this.addNode.bind(this), this.getRoot = this.getRoot.bind(this);
}
static {
l(this, "IshikawaDB");
}
clear() {
this.root = void 0, this.stack = [], this.baseLevel = void 0, yt();
}
getRoot() {
return this.root;
}
addNode(t, u) {
const n = pt.sanitizeText(u, lt());
if (!this.root) {
this.root = {
text: n,
children: []
}, this.stack = [{
level: 0,
node: this.root
}], et(n);
return;
}
this.baseLevel ??= t;
let a = t - this.baseLevel + 1;
for (a <= 0 && (a = 1); this.stack.length > 1 && this.stack[this.stack.length - 1].level >= a; ) this.stack.pop();
const r = this.stack[this.stack.length - 1].node, o = {
text: n,
children: []
};
r.children.push(o), this.stack.push({
level: a,
node: o
});
}
getAccTitle() {
return mt();
}
setAccTitle(t) {
dt(t);
}
getAccDescription() {
return gt();
}
setAccDescription(t) {
ut(t);
}
getDiagramTitle() {
return kt();
}
setDiagramTitle(t) {
et(t);
}
}, St = 14, j = 250, Et = 30, $t = 60, At = 5, ot = 82 * Math.PI / 180, it = Math.cos(ot), st = Math.sin(ot), nt = /* @__PURE__ */ l((t, u, n) => {
const a = t.node().getBBox(), r = a.width + u * 2, o = a.height + u * 2;
ft(t, o, r, n), t.attr("viewBox", `${a.x - u} ${a.y - u} ${r} ${o}`);
}, "applyPaddedViewBox"), It = /* @__PURE__ */ l((t, u, n, a) => {
const r = a.db.getRoot();
if (!r) return;
const o = lt(), { look: k, handDrawnSeed: h, themeVariables: p } = o, y = wt(o.fontSize)[0] ?? St, _ = k === "handDrawn", m = r.children ?? [], $ = o.ishikawa?.diagramPadding ?? 20, v = o.ishikawa?.useMaxWidth ?? !1, P = _t(u), A = P.append("g").attr("class", "ishikawa"), e = _ ? bt.svg(P.node()) : void 0, s = e ? {
roughSvg: e,
seed: h ?? 0,
lineColor: p?.lineColor ?? "#333",
fillColor: p?.mainBkg ?? "#fff"
} : void 0, c = `ishikawa-arrow-${u}`;
_ || A.append("defs").append("marker").attr("id", c).attr("viewBox", "0 0 10 10").attr("refX", 0).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 Z").attr("class", "ishikawa-arrow");
let i = 0, d = j;
const w = _ ? void 0 : z(A, i, d, i, d, "ishikawa-spine");
if (Lt(A, i, d, r.text, y, s), !m.length) {
_ && z(A, i, d, i, d, "ishikawa-spine", s), nt(P, $, v);
return;
}
i -= 20;
const f = m.filter((g, I) => I % 2 === 0), E = m.filter((g, I) => I % 2 === 1), b = at(f), x = at(E), B = b.total + x.total;
let S = j, T = j;
if (B > 0) {
const g = j * 2, I = j * 0.3;
S = Math.max(I, g * (b.total / B)), T = Math.max(I, g * (x.total / B));
}
const M = y * 2;
S = Math.max(S, b.max * M), T = Math.max(T, x.max * M), d = Math.max(S, j), w && w.attr("y1", d).attr("y2", d), A.select(".ishikawa-head-group").attr("transform", `translate(0,${d})`);
const C = Math.ceil(m.length / 2);
for (let g = 0; g < C; g++) {
const I = A.append("g").attr("class", "ishikawa-pair");
for (const [V, R, Z] of [[
m[g * 2],
-1,
S
], [
m[g * 2 + 1],
1,
T
]]) V && Pt(I, V, i, d, R, Z, y, s);
i = I.selectAll("text").nodes().reduce((V, R) => Math.min(V, R.getBBox().x), 1 / 0);
}
if (_) z(A, i, d, 0, d, "ishikawa-spine", s);
else {
w.attr("x1", i);
const g = `url(#${c})`;
A.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start", g);
}
nt(P, $, v);
}, "draw"), at = /* @__PURE__ */ l((t) => {
const u = /* @__PURE__ */ l((n) => n.children.reduce((a, r) => a + 1 + u(r), 0), "countDescendants");
return t.reduce((n, a) => {
const r = u(a);
return n.total += r, n.max = Math.max(n.max, r), n;
}, {
total: 0,
max: 0
});
}, "sideStats"), Lt = /* @__PURE__ */ l((t, u, n, a, r, o) => {
const k = Math.max(6, Math.floor(110 / (r * 0.6))), h = t.append("g").attr("class", "ishikawa-head-group").attr("transform", `translate(${u},${n})`), p = G(h, ht(a, k), 0, 0, "ishikawa-head-label", "start", r), y = p.node().getBBox(), _ = Math.max(60, y.width + 6), m = Math.max(40, y.height * 2 + 40), $ = `M 0 ${-m / 2} L 0 ${m / 2} Q ${_ * 2.4} 0 0 ${-m / 2} Z`;
if (o) {
const v = o.roughSvg.path($, {
roughness: 1.5,
seed: o.seed,
fill: o.fillColor,
fillStyle: "hachure",
fillWeight: 2.5,
hachureGap: 5,
stroke: o.lineColor,
strokeWidth: 2
});
h.insert(() => v, ":first-child").attr("class", "ishikawa-head");
} else h.insert("path", ":first-child").attr("class", "ishikawa-head").attr("d", $);
p.attr("transform", `translate(${(_ - y.width) / 2 - y.x + 3},${-y.y - y.height / 2})`);
}, "drawHead"), Tt = /* @__PURE__ */ l((t, u) => {
const n = [], a = [], r = /* @__PURE__ */ l((o, k, h) => {
const p = u === -1 ? [...o].reverse() : o;
for (const y of p) {
const _ = n.length, m = y.children ?? [];
n.push({
depth: h,
text: ht(y.text, 15),
parentIndex: k,
childCount: m.length
}), h % 2 === 0 ? (a.push(_), m.length && r(m, _, h + 1)) : (m.length && r(m, _, h + 1), a.push(_));
}
}, "walk");
return r(t, -1, 2), {
entries: n,
yOrder: a
};
}, "flattenTree"), Mt = /* @__PURE__ */ l((t, u, n, a, r, o, k) => {
const h = t.append("g").attr("class", "ishikawa-label-group"), p = G(h, u, n, a + 11 * r, "ishikawa-label cause", "middle", o).node().getBBox();
if (k) {
const y = k.roughSvg.rectangle(p.x - 20, p.y - 2, p.width + 40, p.height + 4, {
roughness: 1.5,
seed: k.seed,
fill: k.fillColor,
fillStyle: "hachure",
fillWeight: 2.5,
hachureGap: 5,
stroke: k.lineColor,
strokeWidth: 2
});
h.insert(() => y, ":first-child").attr("class", "ishikawa-label-box");
} else h.insert("rect", ":first-child").attr("class", "ishikawa-label-box").attr("x", p.x - 20).attr("y", p.y - 2).attr("width", p.width + 40).attr("height", p.height + 4);
}, "drawCauseLabel"), q = /* @__PURE__ */ l((t, u, n, a, r, o) => {
const k = Math.sqrt(a * a + r * r);
if (k === 0) return;
const h = a / k, p = r / k, y = 6, _ = -p * y, m = h * y, $ = u, v = n, P = `M ${$} ${v} L ${$ - h * y * 2 + _} ${v - p * y * 2 + m} L ${$ - h * y * 2 - _} ${v - p * y * 2 - m} Z`, A = o.roughSvg.path(P, {
roughness: 1,
seed: o.seed,
fill: o.lineColor,
fillStyle: "solid",
stroke: o.lineColor,
strokeWidth: 1
});
t.append(() => A);
}, "drawArrowMarker"), Pt = /* @__PURE__ */ l((t, u, n, a, r, o, k, h) => {
const p = u.children ?? [], y = o * (p.length ? 1 : 0.2), _ = -it * y, m = st * y * r, $ = n + _, v = a + m;
if (z(t, n, a, $, v, "ishikawa-branch", h), h && q(t, n, a, n - $, a - v, h), Mt(t, u.text, $, v, r, k, h), !p.length) return;
const { entries: P, yOrder: A } = Tt(p, r), e = P.length, s = new Array(e);
for (const [f, E] of A.entries()) s[E] = a + m * ((f + 1) / (e + 1));
const c = /* @__PURE__ */ new Map();
c.set(-1, {
x0: n,
y0: a,
x1: $,
y1: v,
childCount: p.length,
childrenDrawn: 0
});
const i = -it, d = st * r, w = r < 0 ? "ishikawa-label up" : "ishikawa-label down";
for (const [f, E] of P.entries()) {
const b = s[f], x = c.get(E.parentIndex), B = t.append("g").attr("class", "ishikawa-sub-group");
let S = 0, T = 0, M = 0;
if (E.depth % 2 === 0) {
const C = x.y1 - x.y0;
S = rt(x.x0, x.x1, C ? (b - x.y0) / C : 0.5), T = b, M = S - (E.childCount > 0 ? $t + E.childCount * At : Et), z(B, S, b, M, b, "ishikawa-sub-branch", h), h && q(B, S, b, 1, 0, h), G(B, E.text, M, b, "ishikawa-label align", "end", k);
} else {
const C = x.childrenDrawn++;
S = rt(x.x0, x.x1, (x.childCount - C) / (x.childCount + 1)), T = x.y0, M = S + i * ((b - T) / d), z(B, S, T, M, b, "ishikawa-sub-branch", h), h && q(B, S, T, S - M, T - b, h), G(B, E.text, M, b, w, "end", k);
}
E.childCount > 0 && c.set(f, {
x0: S,
y0: T,
x1: M,
y1: b,
childCount: E.childCount,
childrenDrawn: 0
});
}
}, "drawBranch"), Bt = /* @__PURE__ */ l((t) => t.split(/<br\s*\/?>|\n/), "splitLines"), ht = /* @__PURE__ */ l((t, u) => {
if (t.length <= u) return t;
const n = [];
for (const a of t.split(/\s+/)) {
const r = n.length - 1;
r >= 0 && n[r].length + 1 + a.length <= u ? n[r] += " " + a : n.push(a);
}
return n.join(`
`);
}, "wrapText"), G = /* @__PURE__ */ l((t, u, n, a, r, o, k) => {
const h = Bt(u), p = k * 1.05, y = t.append("text").attr("class", r).attr("text-anchor", o).attr("x", n).attr("y", a - (h.length - 1) * p / 2);
for (const [_, m] of h.entries()) y.append("tspan").attr("x", n).attr("dy", _ === 0 ? 0 : p).text(m);
return y;
}, "drawMultilineText"), rt = /* @__PURE__ */ l((t, u, n) => t + (u - t) * n, "lerp"), z = /* @__PURE__ */ l((t, u, n, a, r, o, k) => {
if (k) {
const h = k.roughSvg.line(u, n, a, r, {
roughness: 1.5,
seed: k.seed,
stroke: k.lineColor,
strokeWidth: 2
});
t.append(() => h).attr("class", o);
return;
}
return t.append("line").attr("class", o).attr("x1", u).attr("y1", n).attr("x2", a).attr("y2", r);
}, "drawLine"), Wt = {
parser: xt,
get db() {
return new vt();
},
renderer: { draw: It },
styles: /* @__PURE__ */ l((t) => `
.ishikawa .ishikawa-spine,
.ishikawa .ishikawa-branch,
.ishikawa .ishikawa-sub-branch {
stroke: ${t.lineColor};
stroke-width: 2;
fill: none;
}
.ishikawa .ishikawa-sub-branch {
stroke-width: 1;
}
.ishikawa .ishikawa-arrow {
fill: ${t.lineColor};
}
.ishikawa .ishikawa-head {
fill: ${t.mainBkg};
stroke: ${t.lineColor};
stroke-width: 2;
}
.ishikawa .ishikawa-label-box {
fill: ${t.mainBkg};
stroke: ${t.lineColor};
stroke-width: 2;
}
.ishikawa text {
font-family: ${t.fontFamily};
font-size: ${t.fontSize};
fill: ${t.textColor};
}
.ishikawa .ishikawa-head-label {
font-weight: 600;
text-anchor: middle;
dominant-baseline: middle;
font-size: 14px;
}
.ishikawa .ishikawa-label {
text-anchor: end;
}
.ishikawa .ishikawa-label.cause {
text-anchor: middle;
dominant-baseline: middle;
}
.ishikawa .ishikawa-label.align {
text-anchor: end;
dominant-baseline: middle;
}
.ishikawa .ishikawa-label.up {
dominant-baseline: baseline;
}
.ishikawa .ishikawa-label.down {
dominant-baseline: hanging;
}
`, "getStyles")
};
export {
Wt as diagram
};