chiltepin-render 0.33.3 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2237 -2210
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4011,2468 +4011,2495 @@ function nodeCellAttrs(col, row, w2) {
|
|
|
4011
4011
|
return ` data-col="${col}" data-row="${row}"${w2 !== void 0 ? ` data-w="${w2}"` : ""}`;
|
|
4012
4012
|
}
|
|
4013
4013
|
|
|
4014
|
-
//
|
|
4015
|
-
var
|
|
4016
|
-
var
|
|
4017
|
-
|
|
4018
|
-
|
|
4014
|
+
// src/svg/glyphs.ts
|
|
4015
|
+
var GENERIC_BOX = "box";
|
|
4016
|
+
var PATHS = {
|
|
4017
|
+
// λ
|
|
4018
|
+
function: "M3 2 H5 L10.5 12 M7.6 7 L3.5 12",
|
|
4019
|
+
// pail: elliptical rim, tapered sides
|
|
4020
|
+
bucket: "M2 3.5 a5 1.6 0 0 0 10 0 a5 1.6 0 0 0 -10 0 M2 3.5 L3.5 12.5 H10.5 L12 3.5",
|
|
4021
|
+
// three message bars
|
|
4022
|
+
queue: "M3 1.5 V12.5 M7 1.5 V12.5 M11 1.5 V12.5",
|
|
4023
|
+
// one in, fan out to three
|
|
4024
|
+
topic: "M1.5 7 H5.5 M5.5 7 L11.5 2.5 M5.5 7 H12 M5.5 7 L11.5 11.5",
|
|
4025
|
+
// stacked memory slabs
|
|
4026
|
+
cache: "M1.5 4.5 L7 2 L12.5 4.5 L7 7 Z M1.5 8 L7 10.5 L12.5 8 M1.5 11 L7 13.5 L12.5 11",
|
|
4027
|
+
// the cylinder
|
|
4028
|
+
db: "M1.5 3 a5.5 2.2 0 0 0 11 0 a5.5 2.2 0 0 0 -11 0 V11 a5.5 2.2 0 0 0 11 0 V3",
|
|
4029
|
+
// cloud
|
|
4030
|
+
cdn: "M3.5 12 a3 3 0 0 1 0.3 -6 a4 4 0 0 1 7.6 1 a2.5 2.5 0 0 1 0.6 5 Z",
|
|
4031
|
+
// splitter: one lane in, three out
|
|
4032
|
+
lb: "M1.5 7 H5 M5 7 L9 3 H12.5 M5 7 H12.5 M5 7 L9 11 H12.5",
|
|
4033
|
+
// double chevron
|
|
4034
|
+
gateway: "M2 1.5 L7 7 L2 12.5 M7.5 1.5 L12.5 7 L7.5 12.5",
|
|
4035
|
+
// hexagon with a core
|
|
4036
|
+
pod: "M7 1.2 L12.2 4.1 V9.9 L7 12.8 L1.8 9.9 V4.1 Z M5.2 7 a1.8 1.8 0 1 0 3.6 0 a1.8 1.8 0 1 0 -3.6 0",
|
|
4037
|
+
// wheel: ring + four spokes
|
|
4038
|
+
cluster: "M1.5 7 a5.5 5.5 0 1 0 11 0 a5.5 5.5 0 1 0 -11 0 M7 1.5 V4.5 M7 9.5 V12.5 M1.5 7 H4.5 M9.5 7 H12.5",
|
|
4039
|
+
// head + shoulders
|
|
4040
|
+
user: "M4.5 4.5 a2.5 2.5 0 1 0 5 0 a2.5 2.5 0 1 0 -5 0 M2.5 13 a4.5 4.5 0 0 1 9 0",
|
|
4041
|
+
// window with a header band
|
|
4042
|
+
browser: "M1.5 2.5 H12.5 V11.5 H1.5 Z M1.5 5.5 H12.5",
|
|
4043
|
+
// phone
|
|
4044
|
+
mobile: "M4 1.5 H10 a1 1 0 0 1 1 1 V11.5 a1 1 0 0 1 -1 1 H4 a1 1 0 0 1 -1 -1 V2.5 a1 1 0 0 1 1 -1 Z M6 11 H8",
|
|
4045
|
+
// clock
|
|
4046
|
+
cron: "M1.5 7 a5.5 5.5 0 1 0 11 0 a5.5 5.5 0 1 0 -11 0 M7 3.5 V7 L9.5 8.5",
|
|
4047
|
+
// four-point spark
|
|
4048
|
+
ml: "M7 1.5 L8.4 5.6 L12.5 7 L8.4 8.4 L7 12.5 L5.6 8.4 L1.5 7 L5.6 5.6 Z",
|
|
4049
|
+
// padlock
|
|
4050
|
+
secret: "M3 6.5 H11 V13 H3 Z M4.5 6.5 V4.5 a2.5 2.5 0 0 1 5 0 V6.5",
|
|
4051
|
+
// three sliders
|
|
4052
|
+
config: "M1.5 3.5 H12.5 M1.5 7 H12.5 M1.5 10.5 H12.5 M4.5 2 V5 M9.5 5.5 V8.5 M6 9 V12",
|
|
4053
|
+
// replica set: two overlapping squares
|
|
4054
|
+
deployment: "M1.5 5 H9 V12.5 H1.5 Z M4 5 V2.5 H11.5 V10 H9",
|
|
4055
|
+
// arrow into a door
|
|
4056
|
+
ingress: "M1.5 7 H8 M5.5 4.5 L8 7 L5.5 9.5 M10 1.5 H12.5 V12.5 H10",
|
|
4057
|
+
// two rack slabs
|
|
4058
|
+
node: "M2 2 H12 V6 H2 Z M2 8 H12 V12 H2 Z M4.5 4 H6.5 M4.5 10 H6.5",
|
|
4059
|
+
// folder tab
|
|
4060
|
+
namespace: "M1.5 3.5 H5.5 L7 5 H12.5 V12 H1.5 Z",
|
|
4061
|
+
box: "M2 2 H12 V12 H2 Z"
|
|
4019
4062
|
};
|
|
4020
|
-
var
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4063
|
+
var ALIAS = {
|
|
4064
|
+
function: "function",
|
|
4065
|
+
lambda: "function",
|
|
4066
|
+
bucket: "bucket",
|
|
4067
|
+
s3: "bucket",
|
|
4068
|
+
blob: "bucket",
|
|
4069
|
+
object: "bucket",
|
|
4070
|
+
queue: "queue",
|
|
4071
|
+
sqs: "queue",
|
|
4072
|
+
mq: "queue",
|
|
4073
|
+
broker: "queue",
|
|
4074
|
+
rabbitmq: "queue",
|
|
4075
|
+
topic: "topic",
|
|
4076
|
+
sns: "topic",
|
|
4077
|
+
kafka: "topic",
|
|
4078
|
+
kinesis: "topic",
|
|
4079
|
+
stream: "topic",
|
|
4080
|
+
cache: "cache",
|
|
4081
|
+
redis: "cache",
|
|
4082
|
+
memcached: "cache",
|
|
4083
|
+
db: "db",
|
|
4084
|
+
database: "db",
|
|
4085
|
+
store: "db",
|
|
4086
|
+
postgres: "db",
|
|
4087
|
+
mysql: "db",
|
|
4088
|
+
mongo: "db",
|
|
4089
|
+
mongodb: "db",
|
|
4090
|
+
dynamo: "db",
|
|
4091
|
+
cdn: "cdn",
|
|
4092
|
+
lb: "lb",
|
|
4093
|
+
gateway: "gateway",
|
|
4094
|
+
proxy: "gateway",
|
|
4095
|
+
pod: "pod",
|
|
4096
|
+
cluster: "cluster",
|
|
4097
|
+
user: "user",
|
|
4098
|
+
person: "user",
|
|
4099
|
+
actor: "user",
|
|
4100
|
+
browser: "browser",
|
|
4101
|
+
web: "browser",
|
|
4102
|
+
mobile: "mobile",
|
|
4103
|
+
cron: "cron",
|
|
4104
|
+
scheduler: "cron",
|
|
4105
|
+
job: "cron",
|
|
4106
|
+
cronjob: "cron",
|
|
4107
|
+
ml: "ml",
|
|
4108
|
+
model: "ml",
|
|
4109
|
+
llm: "ml",
|
|
4110
|
+
agent: "ml",
|
|
4111
|
+
ai: "ml",
|
|
4112
|
+
secret: "secret",
|
|
4113
|
+
secrets: "secret",
|
|
4114
|
+
vault: "secret",
|
|
4115
|
+
kms: "secret",
|
|
4116
|
+
config: "config",
|
|
4117
|
+
configmap: "config",
|
|
4118
|
+
settings: "config",
|
|
4119
|
+
deployment: "deployment",
|
|
4120
|
+
ingress: "ingress",
|
|
4121
|
+
node: "node",
|
|
4122
|
+
vm: "node",
|
|
4123
|
+
server: "node",
|
|
4124
|
+
host: "node",
|
|
4125
|
+
namespace: "namespace"
|
|
4026
4126
|
};
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
}
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4127
|
+
function glyphNameFor(kind) {
|
|
4128
|
+
return ALIAS[(kind ?? "").trim().toLowerCase()] ?? GENERIC_BOX;
|
|
4129
|
+
}
|
|
4130
|
+
function hasGlyph(kind) {
|
|
4131
|
+
return (kind ?? "").trim().toLowerCase() in ALIAS;
|
|
4132
|
+
}
|
|
4133
|
+
function cloudGlyph(kind, x2, y, c = "var(--muted)") {
|
|
4134
|
+
const d = PATHS[glyphNameFor(kind)];
|
|
4135
|
+
return `<path d="${d}" transform="translate(${x2} ${y})" fill="none" stroke="${c}" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>`;
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
// src/svg/blockStyle.ts
|
|
4139
|
+
var KNOWN_NODE_KINDS = [
|
|
4140
|
+
"client",
|
|
4141
|
+
"service",
|
|
4142
|
+
"microservice",
|
|
4143
|
+
"compute",
|
|
4144
|
+
"container",
|
|
4145
|
+
"data",
|
|
4146
|
+
"store",
|
|
4147
|
+
"db",
|
|
4148
|
+
"database",
|
|
4149
|
+
"postgres",
|
|
4150
|
+
"mysql",
|
|
4151
|
+
"mongo",
|
|
4152
|
+
"mongodb",
|
|
4153
|
+
"dynamo",
|
|
4154
|
+
"bucket",
|
|
4155
|
+
"blob",
|
|
4156
|
+
"object",
|
|
4157
|
+
"s3",
|
|
4158
|
+
"queue",
|
|
4159
|
+
"mq",
|
|
4160
|
+
"broker",
|
|
4161
|
+
"sqs",
|
|
4162
|
+
"rabbitmq",
|
|
4163
|
+
"cache",
|
|
4164
|
+
"redis",
|
|
4165
|
+
"memcached",
|
|
4166
|
+
"gateway",
|
|
4167
|
+
"lb",
|
|
4168
|
+
"proxy",
|
|
4169
|
+
"function",
|
|
4170
|
+
"lambda",
|
|
4171
|
+
"cdn",
|
|
4172
|
+
"external",
|
|
4173
|
+
"producer",
|
|
4174
|
+
"topic",
|
|
4175
|
+
"consumer",
|
|
4176
|
+
"context",
|
|
4177
|
+
"firewall",
|
|
4178
|
+
"waf",
|
|
4179
|
+
"shield",
|
|
4180
|
+
"dns",
|
|
4181
|
+
"auth",
|
|
4182
|
+
"identity",
|
|
4183
|
+
"idp",
|
|
4184
|
+
"iam",
|
|
4185
|
+
"oauth",
|
|
4186
|
+
"sso",
|
|
4187
|
+
"monitor",
|
|
4188
|
+
"observability",
|
|
4189
|
+
"metrics",
|
|
4190
|
+
"logs",
|
|
4191
|
+
"tracing",
|
|
4192
|
+
"apm",
|
|
4193
|
+
"scheduler",
|
|
4194
|
+
"cron",
|
|
4195
|
+
"job",
|
|
4196
|
+
"stream",
|
|
4197
|
+
"kafka",
|
|
4198
|
+
"kinesis",
|
|
4199
|
+
"warehouse",
|
|
4200
|
+
"lake",
|
|
4201
|
+
"analytics",
|
|
4202
|
+
"bi",
|
|
4203
|
+
"search",
|
|
4204
|
+
"index",
|
|
4205
|
+
"elasticsearch",
|
|
4206
|
+
"opensearch",
|
|
4207
|
+
"registry",
|
|
4208
|
+
"ci",
|
|
4209
|
+
"cicd",
|
|
4210
|
+
"pipeline",
|
|
4211
|
+
"git",
|
|
4212
|
+
"repo",
|
|
4213
|
+
"scm",
|
|
4214
|
+
"device",
|
|
4215
|
+
"iot",
|
|
4216
|
+
"email",
|
|
4217
|
+
"sms",
|
|
4218
|
+
"config",
|
|
4219
|
+
"settings",
|
|
4220
|
+
"ml",
|
|
4221
|
+
"model",
|
|
4222
|
+
"llm",
|
|
4223
|
+
"agent",
|
|
4224
|
+
"ai",
|
|
4225
|
+
"user",
|
|
4226
|
+
"person",
|
|
4227
|
+
"actor",
|
|
4228
|
+
"browser",
|
|
4229
|
+
"web",
|
|
4230
|
+
"mobile",
|
|
4231
|
+
"vm",
|
|
4232
|
+
"server",
|
|
4233
|
+
"host",
|
|
4234
|
+
"secrets",
|
|
4235
|
+
"vault",
|
|
4236
|
+
"kms",
|
|
4237
|
+
"notification",
|
|
4238
|
+
"webhook",
|
|
4239
|
+
"worker",
|
|
4240
|
+
"etl",
|
|
4241
|
+
"shard",
|
|
4242
|
+
"shards",
|
|
4243
|
+
"sharded",
|
|
4244
|
+
"replica",
|
|
4245
|
+
"replicas",
|
|
4246
|
+
"replicaset",
|
|
4247
|
+
"users",
|
|
4248
|
+
"crowd",
|
|
4249
|
+
"region",
|
|
4250
|
+
"geo",
|
|
4251
|
+
"globe",
|
|
4252
|
+
// `preset: k8s` vocabulary (namespaces are groups; these are the node kinds).
|
|
4253
|
+
"deployment",
|
|
4254
|
+
"pod",
|
|
4255
|
+
"ingress",
|
|
4256
|
+
"configmap",
|
|
4257
|
+
"secret",
|
|
4258
|
+
"cronjob",
|
|
4259
|
+
"node",
|
|
4260
|
+
"namespace",
|
|
4261
|
+
"cluster",
|
|
4262
|
+
"sns"
|
|
4263
|
+
];
|
|
4264
|
+
var SKIN = {};
|
|
4265
|
+
var def = (kinds, skin) => {
|
|
4266
|
+
for (const k2 of kinds) SKIN[k2] = skin;
|
|
4267
|
+
};
|
|
4268
|
+
var primary = (chip3) => ({ chip: chip3, primary: true, fill: "paper", dashed: false });
|
|
4269
|
+
var secondary = (chip3) => ({ chip: chip3, primary: false, fill: "paper-2", dashed: false });
|
|
4270
|
+
var external = (chip3) => ({ chip: chip3, primary: true, fill: "paper", dashed: true });
|
|
4271
|
+
def(["client", "user", "person", "actor", "users", "crowd", "browser", "web", "mobile", "device", "iot"], primary("CLIENT"));
|
|
4272
|
+
def(["service", "microservice", "compute", "container", "worker", "etl"], primary("SVC"));
|
|
4273
|
+
def(["data"], primary("DATA"));
|
|
4274
|
+
def(["store", "db", "database", "postgres", "mysql", "mongo", "mongodb", "dynamo"], secondary("DB"));
|
|
4275
|
+
def(["shard", "shards", "sharded", "replica", "replicas", "replicaset"], secondary("DB"));
|
|
4276
|
+
def(["bucket", "blob", "object", "s3"], secondary("BUCKET"));
|
|
4277
|
+
def(["warehouse", "lake"], secondary("WAREHOUSE"));
|
|
4278
|
+
def(["queue", "mq", "broker", "sqs", "rabbitmq"], secondary("QUEUE"));
|
|
4279
|
+
def(["topic"], secondary("TOPIC"));
|
|
4280
|
+
def(["stream", "kafka", "kinesis"], secondary("BUS"));
|
|
4281
|
+
def(["cache", "redis", "memcached"], secondary("CACHE"));
|
|
4282
|
+
def(["search", "index", "elasticsearch", "opensearch"], secondary("SEARCH"));
|
|
4283
|
+
def(["registry"], secondary("REGISTRY"));
|
|
4284
|
+
def(["gateway", "proxy"], primary("GATEWAY"));
|
|
4285
|
+
def(["lb"], primary("LB"));
|
|
4286
|
+
def(["function", "lambda"], primary("FN"));
|
|
4287
|
+
def(["cdn"], external("EDGE"));
|
|
4288
|
+
def(["external"], external("EXT"));
|
|
4289
|
+
def(["producer"], primary("PRODUCER"));
|
|
4290
|
+
def(["consumer"], primary("CONSUMER"));
|
|
4291
|
+
def(["context"], primary("CONTEXT"));
|
|
4292
|
+
def(["firewall", "waf", "shield"], primary("WAF"));
|
|
4293
|
+
def(["dns"], external("DNS"));
|
|
4294
|
+
def(["auth", "identity", "idp", "iam", "oauth", "sso"], primary("AUTH"));
|
|
4295
|
+
def(["monitor", "observability", "metrics", "logs", "tracing", "apm"], primary("OBS"));
|
|
4296
|
+
def(["scheduler", "cron", "job"], primary("CRON"));
|
|
4297
|
+
def(["analytics", "bi"], primary("ANALYTICS"));
|
|
4298
|
+
def(["ci", "cicd", "pipeline"], primary("CI"));
|
|
4299
|
+
def(["git", "repo", "scm"], secondary("GIT"));
|
|
4300
|
+
def(["email", "sms"], external("EMAIL"));
|
|
4301
|
+
def(["config", "settings"], secondary("CONFIG"));
|
|
4302
|
+
def(["ml", "model", "llm", "agent", "ai"], primary("AI"));
|
|
4303
|
+
def(["vm", "server", "host"], primary("HOST"));
|
|
4304
|
+
def(["secrets", "vault", "kms"], secondary("SECRETS"));
|
|
4305
|
+
def(["notification", "webhook"], external("WEBHOOK"));
|
|
4306
|
+
def(["region", "geo", "globe"], external("REGION"));
|
|
4307
|
+
def(["deployment"], primary("DEPLOY"));
|
|
4308
|
+
def(["pod"], primary("POD"));
|
|
4309
|
+
def(["ingress"], primary("INGRESS"));
|
|
4310
|
+
def(["configmap"], secondary("CONFIG"));
|
|
4311
|
+
def(["secret"], secondary("SECRETS"));
|
|
4312
|
+
def(["cronjob"], primary("CRON"));
|
|
4313
|
+
def(["node"], primary("NODE"));
|
|
4314
|
+
def(["namespace"], secondary("NS"));
|
|
4315
|
+
def(["cluster"], primary("CLUSTER"));
|
|
4316
|
+
def(["sns"], secondary("TOPIC"));
|
|
4317
|
+
function nodeSkin(kind) {
|
|
4318
|
+
const k2 = (kind ?? "").trim().toLowerCase();
|
|
4319
|
+
if (k2 === "") return { chip: "", primary: true, fill: "paper", dashed: false };
|
|
4320
|
+
return SKIN[k2] ?? primary(k2.toUpperCase());
|
|
4321
|
+
}
|
|
4322
|
+
function skinFill(sk, accent = false) {
|
|
4323
|
+
if (accent) return "var(--accent-tint)";
|
|
4324
|
+
return sk.fill === "paper-2" ? "var(--paper-2)" : "var(--paper)";
|
|
4325
|
+
}
|
|
4326
|
+
function nodeGlyph(kind, x2, y, c) {
|
|
4327
|
+
const k2 = (kind ?? "").toLowerCase();
|
|
4328
|
+
if (k2 === "store" || k2 === "db" || k2 === "database" || k2 === "postgres" || k2 === "mysql" || k2 === "mongo" || k2 === "mongodb" || k2 === "dynamo") {
|
|
4329
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x2 + 8}" cy="${y + 3}" rx="7" ry="3"/><path d="M${x2 + 1} ${y + 3} V ${y + 13}"/><path d="M${x2 + 15} ${y + 3} V ${y + 13}"/><path d="M${x2 + 1} ${y + 13} a 7 3 0 0 0 14 0"/></g>`;
|
|
4050
4330
|
}
|
|
4051
|
-
|
|
4052
|
-
return
|
|
4331
|
+
if (k2 === "bucket" || k2 === "blob" || k2 === "object" || k2 === "s3") {
|
|
4332
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x2 + 8}" cy="${y + 3}" rx="7" ry="2.5"/><path d="M${x2 + 1.5} ${y + 3} L ${x2 + 3.5} ${y + 14} L ${x2 + 12.5} ${y + 14} L ${x2 + 14.5} ${y + 3}"/></g>`;
|
|
4053
4333
|
}
|
|
4054
|
-
|
|
4055
|
-
return
|
|
4334
|
+
if (k2 === "queue" || k2 === "topic" || k2 === "mq" || k2 === "broker" || k2 === "sqs" || k2 === "rabbitmq") {
|
|
4335
|
+
return `<g stroke="${c}" stroke-width="1.6"><path d="M${x2 + 2} ${y + 1} V ${y + 14}"/><path d="M${x2 + 8} ${y + 1} V ${y + 14}"/><path d="M${x2 + 14} ${y + 1} V ${y + 14}"/></g>`;
|
|
4056
4336
|
}
|
|
4057
|
-
|
|
4058
|
-
return
|
|
4337
|
+
if (k2 === "firewall" || k2 === "waf" || k2 === "shield") {
|
|
4338
|
+
return `<path d="M${x2 + 8} ${y} L ${x2 + 15} ${y + 3} V ${y + 9} Q ${x2 + 15} ${y + 14} ${x2 + 8} ${y + 16} Q ${x2 + 1} ${y + 14} ${x2 + 1} ${y + 9} V ${y + 3} Z" fill="none" stroke="${c}" stroke-width="1.3"/>`;
|
|
4059
4339
|
}
|
|
4060
|
-
|
|
4061
|
-
return
|
|
4340
|
+
if (k2 === "dns") {
|
|
4341
|
+
return `<g stroke="${c}" stroke-width="1.2" fill="none"><circle cx="${x2 + 8}" cy="${y + 8}" r="7"/><ellipse cx="${x2 + 8}" cy="${y + 8}" rx="3" ry="7"/><path d="M${x2 + 1.5} ${y + 8} H ${x2 + 14.5}"/></g>`;
|
|
4062
4342
|
}
|
|
4063
|
-
|
|
4064
|
-
return
|
|
4065
|
-
n !== void 0 ? this.setNode(t, n) : this.setNode(t);
|
|
4066
|
-
}), this;
|
|
4343
|
+
if (k2 === "auth" || k2 === "identity" || k2 === "idp" || k2 === "iam" || k2 === "oauth" || k2 === "sso") {
|
|
4344
|
+
return `<g stroke="${c}" stroke-width="1.4" fill="none"><circle cx="${x2 + 5}" cy="${y + 8}" r="3.5"/><path d="M${x2 + 8.5} ${y + 8} H ${x2 + 15} M${x2 + 12.5} ${y + 8} V ${y + 11.5} M${x2 + 15} ${y + 8} V ${y + 10.5}"/></g>`;
|
|
4067
4345
|
}
|
|
4068
|
-
|
|
4069
|
-
return
|
|
4346
|
+
if (k2 === "monitor" || k2 === "observability" || k2 === "metrics" || k2 === "logs" || k2 === "tracing" || k2 === "apm") {
|
|
4347
|
+
return `<path d="M${x2} ${y + 9} H ${x2 + 4} L ${x2 + 6.5} ${y + 3} L ${x2 + 9.5} ${y + 13} L ${x2 + 12} ${y + 9} H ${x2 + 16}" fill="none" stroke="${c}" stroke-width="1.5" stroke-linejoin="round"/>`;
|
|
4070
4348
|
}
|
|
4071
|
-
|
|
4072
|
-
return
|
|
4349
|
+
if (k2 === "scheduler" || k2 === "cron" || k2 === "job") {
|
|
4350
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><circle cx="${x2 + 8}" cy="${y + 8}" r="7"/><path d="M${x2 + 8} ${y + 4} V ${y + 8} L ${x2 + 11.5} ${y + 10}"/></g>`;
|
|
4073
4351
|
}
|
|
4074
|
-
|
|
4075
|
-
|
|
4352
|
+
if (k2 === "stream" || k2 === "kafka" || k2 === "kinesis") {
|
|
4353
|
+
const wave = (dy) => `<path d="M${x2 + 1} ${y + 4 + dy} q 3.5 -3 7 0 t 7 0" fill="none" stroke="${c}" stroke-width="1.4"/>`;
|
|
4354
|
+
return `<g>${wave(0)}${wave(4.5)}${wave(9)}</g>`;
|
|
4076
4355
|
}
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
let n = (t) => this.removeEdge(this._edgeObjs[t]);
|
|
4080
|
-
delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((t) => {
|
|
4081
|
-
this.setParent(t);
|
|
4082
|
-
}), delete this._children[e]), Object.keys(this._in[e]).forEach(n), delete this._in[e], delete this._preds[e], Object.keys(this._out[e]).forEach(n), delete this._out[e], delete this._sucs[e], --this._nodeCount;
|
|
4083
|
-
}
|
|
4084
|
-
return this;
|
|
4356
|
+
if (k2 === "warehouse" || k2 === "lake") {
|
|
4357
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x2 + 8}" cy="${y + 3}" rx="7" ry="3"/><path d="M${x2 + 1} ${y + 3} V ${y + 13}"/><path d="M${x2 + 15} ${y + 3} V ${y + 13}"/><path d="M${x2 + 1} ${y + 8} a 7 3 0 0 0 14 0"/><path d="M${x2 + 1} ${y + 13} a 7 3 0 0 0 14 0"/></g>`;
|
|
4085
4358
|
}
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
if (n === void 0) n = "\0";
|
|
4089
|
-
else {
|
|
4090
|
-
n += "";
|
|
4091
|
-
for (let t = n; t !== void 0; t = this.parent(t)) if (t === e) throw new Error("Setting " + n + " as parent of " + e + " would create a cycle");
|
|
4092
|
-
this.setNode(n);
|
|
4093
|
-
}
|
|
4094
|
-
return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = n, this._children[n][e] = true, this;
|
|
4359
|
+
if (k2 === "search" || k2 === "index") {
|
|
4360
|
+
return `<g stroke="${c}" stroke-width="1.4" fill="none"><circle cx="${x2 + 6.5}" cy="${y + 6.5}" r="5"/><path d="M${x2 + 10.5} ${y + 10.5} L ${x2 + 15} ${y + 15}"/></g>`;
|
|
4095
4361
|
}
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
let n = this._parent[e];
|
|
4099
|
-
if (n !== "\0") return n;
|
|
4100
|
-
}
|
|
4362
|
+
if (k2 === "ml" || k2 === "model" || k2 === "llm" || k2 === "agent" || k2 === "ai") {
|
|
4363
|
+
return `<path d="M${x2 + 8} ${y + 1} L ${x2 + 9.8} ${y + 6.2} L ${x2 + 15} ${y + 8} L ${x2 + 9.8} ${y + 9.8} L ${x2 + 8} ${y + 15} L ${x2 + 6.2} ${y + 9.8} L ${x2 + 1} ${y + 8} L ${x2 + 6.2} ${y + 6.2} Z" fill="${c}"/>`;
|
|
4101
4364
|
}
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
let n = this._children[e];
|
|
4105
|
-
if (n) return Object.keys(n);
|
|
4106
|
-
} else {
|
|
4107
|
-
if (e === "\0") return this.nodes();
|
|
4108
|
-
if (this.hasNode(e)) return [];
|
|
4109
|
-
}
|
|
4110
|
-
return [];
|
|
4365
|
+
if (k2 === "user" || k2 === "person" || k2 === "actor") {
|
|
4366
|
+
return `<g fill="${c}"><circle cx="${x2 + 8}" cy="${y + 4.5}" r="3.5"/><path d="M ${x2 + 2} ${y + 15} a 6 6.5 0 0 1 12 0 z"/></g>`;
|
|
4111
4367
|
}
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
if (n) return Object.keys(n);
|
|
4368
|
+
if (k2 === "browser" || k2 === "web") {
|
|
4369
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 1}" y="${y + 2}" width="14" height="12" rx="2"/><path d="M${x2 + 1} ${y + 6} H ${x2 + 15}"/></g>`;
|
|
4115
4370
|
}
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
if (n) return Object.keys(n);
|
|
4371
|
+
if (k2 === "mobile") {
|
|
4372
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 4}" y="${y + 1}" width="8" height="14" rx="2"/><path d="M${x2 + 7} ${y + 12.5} H ${x2 + 9}"/></g>`;
|
|
4119
4373
|
}
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
if (n) {
|
|
4123
|
-
let t = new Set(n);
|
|
4124
|
-
for (let r5 of this.successors(e)) t.add(r5);
|
|
4125
|
-
return Array.from(t.values());
|
|
4126
|
-
}
|
|
4374
|
+
if (k2 === "vm" || k2 === "server" || k2 === "host") {
|
|
4375
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 2}" y="${y + 2}" width="12" height="5" rx="1.2"/><rect x="${x2 + 2}" y="${y + 9}" width="12" height="5" rx="1.2"/><path d="M${x2 + 4.5} ${y + 4.5} H ${x2 + 7} M${x2 + 4.5} ${y + 11.5} H ${x2 + 7}"/></g>`;
|
|
4127
4376
|
}
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
return this.isDirected() ? n = this.successors(e) : n = this.neighbors(e), n.length === 0;
|
|
4377
|
+
if (k2 === "secrets" || k2 === "vault" || k2 === "kms") {
|
|
4378
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 3}" y="${y + 7}" width="10" height="8" rx="1.5"/><path d="M${x2 + 5} ${y + 7} V ${y + 5} a 3 3 0 0 1 6 0 V ${y + 7}"/></g>`;
|
|
4131
4379
|
}
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
n.setGraph(this.graph()), Object.entries(this._nodes).forEach(([o, i]) => {
|
|
4135
|
-
e(o) && n.setNode(o, i);
|
|
4136
|
-
}), Object.values(this._edgeObjs).forEach((o) => {
|
|
4137
|
-
n.hasNode(o.v) && n.hasNode(o.w) && n.setEdge(o, this.edge(o));
|
|
4138
|
-
});
|
|
4139
|
-
let t = {}, r5 = (o) => {
|
|
4140
|
-
let i = this.parent(o);
|
|
4141
|
-
return !i || n.hasNode(i) ? (t[o] = i != null ? i : void 0, i != null ? i : void 0) : i in t ? t[i] : r5(i);
|
|
4142
|
-
};
|
|
4143
|
-
return this._isCompound && n.nodes().forEach((o) => n.setParent(o, r5(o))), n;
|
|
4380
|
+
if (k2 === "notification" || k2 === "webhook") {
|
|
4381
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><path d="M${x2 + 3} ${y + 11} a 5 5 0 0 1 1.6 -3.6 V ${y + 5} a 3.4 3.4 0 0 1 6.8 0 v 2.4 a 5 5 0 0 1 1.6 3.6 z"/><path d="M${x2 + 6.5} ${y + 13.5} a 1.5 1.5 0 0 0 3 0"/></g>`;
|
|
4144
4382
|
}
|
|
4145
|
-
|
|
4146
|
-
return
|
|
4383
|
+
if (k2 === "email" || k2 === "sms") {
|
|
4384
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 1}" y="${y + 3}" width="14" height="10" rx="1.5"/><path d="M${x2 + 1.5} ${y + 4} L ${x2 + 8} ${y + 9} L ${x2 + 14.5} ${y + 4}"/></g>`;
|
|
4147
4385
|
}
|
|
4148
|
-
|
|
4149
|
-
return
|
|
4386
|
+
if (k2 === "registry") {
|
|
4387
|
+
return `<g stroke="${c}" stroke-width="1.2" fill="none"><rect x="${x2 + 1}" y="${y + 8}" width="6" height="6" rx="1"/><rect x="${x2 + 9}" y="${y + 8}" width="6" height="6" rx="1"/><rect x="${x2 + 5}" y="${y + 1}" width="6" height="6" rx="1"/></g>`;
|
|
4150
4388
|
}
|
|
4151
|
-
|
|
4152
|
-
return
|
|
4389
|
+
if (k2 === "ci" || k2 === "cicd" || k2 === "pipeline") {
|
|
4390
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><circle cx="${x2 + 8}" cy="${y + 8}" r="7"/><path d="M${x2 + 6} ${y + 5} L ${x2 + 11.5} ${y + 8} L ${x2 + 6} ${y + 11} Z" fill="${c}" stroke="none"/></g>`;
|
|
4153
4391
|
}
|
|
4154
|
-
|
|
4155
|
-
return
|
|
4392
|
+
if (k2 === "git" || k2 === "repo" || k2 === "scm") {
|
|
4393
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><circle cx="${x2 + 4}" cy="${y + 3.5}" r="2.5"/><circle cx="${x2 + 4}" cy="${y + 12.5}" r="2.5"/><circle cx="${x2 + 12}" cy="${y + 6}" r="2.5"/><path d="M${x2 + 4} ${y + 6} V ${y + 10} M${x2 + 4} ${y + 8} q 0 -2 3 -2 h 2.5"/></g>`;
|
|
4156
4394
|
}
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
typeof e == "object" && e !== null && "v" in e ? (o = e.v, i = e.w, s = e.name, arguments.length === 2 && (a = n, d = true)) : (o = e, i = n, s = r5, arguments.length > 2 && (a = t, d = true)), o = "" + o, i = "" + i, s !== void 0 && (s = "" + s);
|
|
4160
|
-
let l = C(this._isDirected, o, i, s);
|
|
4161
|
-
if (l in this._edgeLabels) return d && (this._edgeLabels[l] = a), this;
|
|
4162
|
-
if (s !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
|
|
4163
|
-
this.setNode(o), this.setNode(i), this._edgeLabels[l] = d ? a : this._defaultEdgeLabelFn(o, i, s);
|
|
4164
|
-
let u = gn(this._isDirected, o, i, s);
|
|
4165
|
-
return o = u.v, i = u.w, Object.freeze(u), this._edgeObjs[l] = u, me(this._preds[i], o), me(this._sucs[o], i), this._in[i][l] = u, this._out[o][l] = u, this._edgeCount++, this;
|
|
4395
|
+
if (k2 === "device" || k2 === "iot") {
|
|
4396
|
+
return `<g stroke="${c}" stroke-width="1.2" fill="none"><rect x="${x2 + 4}" y="${y + 4}" width="8" height="8" rx="1.5"/><path d="M${x2 + 6} ${y + 4} V ${y + 1} M${x2 + 10} ${y + 4} V ${y + 1} M${x2 + 6} ${y + 15} V ${y + 12} M${x2 + 10} ${y + 15} V ${y + 12} M${x2 + 4} ${y + 6} H ${x2 + 1} M${x2 + 4} ${y + 10} H ${x2 + 1} M${x2 + 15} ${y + 6} H ${x2 + 12} M${x2 + 15} ${y + 10} H ${x2 + 12}"/></g>`;
|
|
4166
4397
|
}
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
return this._edgeLabels[r5];
|
|
4398
|
+
if (k2 === "analytics" || k2 === "bi") {
|
|
4399
|
+
return `<g fill="${c}"><rect x="${x2 + 1}" y="${y + 9}" width="3.4" height="6" rx="0.8"/><rect x="${x2 + 6.3}" y="${y + 5}" width="3.4" height="10" rx="0.8"/><rect x="${x2 + 11.6}" y="${y + 1}" width="3.4" height="14" rx="0.8"/></g>`;
|
|
4170
4400
|
}
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
return typeof r5 != "object" ? { label: r5 } : r5;
|
|
4401
|
+
if (k2 === "config" || k2 === "settings") {
|
|
4402
|
+
return `<g stroke="${c}" stroke-width="1.3" fill="none"><circle cx="${x2 + 8}" cy="${y + 8}" r="4"/><path d="M${x2 + 8} ${y + 1} V ${y + 3.5} M${x2 + 8} ${y + 12.5} V ${y + 15} M${x2 + 1} ${y + 8} H ${x2 + 3.5} M${x2 + 12.5} ${y + 8} H ${x2 + 15} M${x2 + 3} ${y + 3} L ${x2 + 5} ${y + 5} M${x2 + 11} ${y + 11} L ${x2 + 13} ${y + 13} M${x2 + 13} ${y + 3} L ${x2 + 11} ${y + 5} M${x2 + 5} ${y + 11} L ${x2 + 3} ${y + 13}"/></g>`;
|
|
4174
4403
|
}
|
|
4175
|
-
|
|
4176
|
-
|
|
4404
|
+
if (k2 === "cache" || k2 === "redis" || k2 === "memcached") {
|
|
4405
|
+
const slab = (dy) => `<path d="M${x2 + 1} ${y + 5 + dy} L${x2 + 8} ${y + 2 + dy} L${x2 + 15} ${y + 5 + dy} L${x2 + 8} ${y + 8 + dy} Z" fill="none" stroke="${c}" stroke-width="1.2"/>`;
|
|
4406
|
+
return `<g>${slab(0)}${slab(3.5)}${slab(7)}</g>`;
|
|
4177
4407
|
}
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
if (o) {
|
|
4181
|
-
let i = o.v, s = o.w;
|
|
4182
|
-
delete this._edgeLabels[r5], delete this._edgeObjs[r5], Ee(this._preds[s], i), Ee(this._sucs[i], s), delete this._in[s][r5], delete this._out[i][r5], this._edgeCount--;
|
|
4183
|
-
}
|
|
4184
|
-
return this;
|
|
4408
|
+
if (k2 === "function" || k2 === "lambda") {
|
|
4409
|
+
return `<text x="${x2 + 7}" y="${y + 14}" font-family="Georgia, serif" font-size="17" font-style="italic" font-weight="700" fill="${c}" text-anchor="middle">\u0192</text>`;
|
|
4185
4410
|
}
|
|
4186
|
-
|
|
4187
|
-
return
|
|
4411
|
+
if (k2 === "cdn" || k2 === "external") {
|
|
4412
|
+
return `<path d="M${x2 + 3} ${y + 13} a 4 4 0 0 1 0.5 -8 a 5 5 0 0 1 9.5 1.2 a 3 3 0 0 1 1 6.8 z" fill="none" stroke="${c}" stroke-width="1.3"/>`;
|
|
4188
4413
|
}
|
|
4189
|
-
|
|
4190
|
-
return
|
|
4414
|
+
if (k2 === "gateway" || k2 === "lb" || k2 === "proxy") {
|
|
4415
|
+
return `<g stroke="${c}" stroke-width="1.5" fill="none"><path d="M${x2 + 2} ${y + 1} L ${x2 + 8} ${y + 7} L ${x2 + 2} ${y + 13}"/><path d="M${x2 + 8} ${y + 1} L ${x2 + 14} ${y + 7} L ${x2 + 8} ${y + 13}"/></g>`;
|
|
4191
4416
|
}
|
|
4192
|
-
|
|
4193
|
-
|
|
4417
|
+
if (k2 === "service" || k2 === "microservice" || k2 === "compute" || k2 === "container" || k2 === "worker" || k2 === "etl") {
|
|
4418
|
+
return `<g stroke="${c}" stroke-width="1.3"><rect x="${x2 + 4}" y="${y + 1}" width="11" height="11" rx="1.5" fill="none"/><rect x="${x2 + 1}" y="${y + 4}" width="11" height="11" rx="1.5" fill="var(--paper)"/></g>`;
|
|
4194
4419
|
}
|
|
4195
|
-
|
|
4196
|
-
|
|
4420
|
+
return hasGlyph(k2) ? cloudGlyph(k2, x2, y, c) : "";
|
|
4421
|
+
}
|
|
4422
|
+
var SKIN_EDGE = {
|
|
4423
|
+
solid: { stroke: "var(--muted)", sw: 1.5, dash: "", marker: "skArrow", err: false },
|
|
4424
|
+
dashed: { stroke: "var(--muted)", sw: 1.5, dash: "5 4", marker: "skOpen", err: false },
|
|
4425
|
+
forbidden: { stroke: "var(--negative)", sw: 1.5, dash: "4 3", marker: "skErr", err: true },
|
|
4426
|
+
error: { stroke: "var(--negative)", sw: 1.5, dash: "", marker: "skErr", err: true }
|
|
4427
|
+
};
|
|
4428
|
+
|
|
4429
|
+
// ../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/dist/dagre.esm.js
|
|
4430
|
+
var ge = Object.defineProperty;
|
|
4431
|
+
var hn = (e, n, t) => n in e ? ge(e, n, { enumerable: true, configurable: true, writable: true, value: t }) : e[n] = t;
|
|
4432
|
+
var fn = (e, n) => {
|
|
4433
|
+
for (var t in n) ge(e, t, { get: n[t], enumerable: true });
|
|
4434
|
+
};
|
|
4435
|
+
var pe = (e, n, t) => hn(e, n + "" , t);
|
|
4436
|
+
var z = {};
|
|
4437
|
+
fn(z, { Graph: () => p, alg: () => R, json: () => ye, version: () => pn });
|
|
4438
|
+
var bn = Object.defineProperty;
|
|
4439
|
+
var Le = (e, n) => {
|
|
4440
|
+
for (var t in n) bn(e, t, { get: n[t], enumerable: true });
|
|
4441
|
+
};
|
|
4442
|
+
var p = class {
|
|
4443
|
+
constructor(e) {
|
|
4444
|
+
this._isDirected = true, this._isMultigraph = false, this._isCompound = false, this._nodes = {}, this._in = {}, this._preds = {}, this._out = {}, this._sucs = {}, this._edgeObjs = {}, this._edgeLabels = {}, this._nodeCount = 0, this._edgeCount = 0, this._defaultNodeLabelFn = () => {
|
|
4445
|
+
}, this._defaultEdgeLabelFn = () => {
|
|
4446
|
+
}, e && (this._isDirected = "directed" in e ? e.directed : true, this._isMultigraph = "multigraph" in e ? e.multigraph : false, this._isCompound = "compound" in e ? e.compound : false), this._isCompound && (this._parent = {}, this._children = {}, this._children["\0"] = {});
|
|
4197
4447
|
}
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
let r5 = Object.values(e);
|
|
4201
|
-
return t ? r5.filter((o) => o.v === n && o.w === t || o.v === t && o.w === n) : r5;
|
|
4448
|
+
isDirected() {
|
|
4449
|
+
return this._isDirected;
|
|
4202
4450
|
}
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
e[n] ? e[n]++ : e[n] = 1;
|
|
4206
|
-
}
|
|
4207
|
-
function Ee(e, n) {
|
|
4208
|
-
e[n] !== void 0 && !--e[n] && delete e[n];
|
|
4209
|
-
}
|
|
4210
|
-
function C(e, n, t, r5) {
|
|
4211
|
-
let o = "" + n, i = "" + t;
|
|
4212
|
-
if (!e && o > i) {
|
|
4213
|
-
let s = o;
|
|
4214
|
-
o = i, i = s;
|
|
4451
|
+
isMultigraph() {
|
|
4452
|
+
return this._isMultigraph;
|
|
4215
4453
|
}
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
function gn(e, n, t, r5) {
|
|
4219
|
-
let o = "" + n, i = "" + t;
|
|
4220
|
-
if (!e && o > i) {
|
|
4221
|
-
let a = o;
|
|
4222
|
-
o = i, i = a;
|
|
4454
|
+
isCompound() {
|
|
4455
|
+
return this._isCompound;
|
|
4223
4456
|
}
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
}
|
|
4227
|
-
function Y(e, n) {
|
|
4228
|
-
return C(e, n.v, n.w, n.name);
|
|
4229
|
-
}
|
|
4230
|
-
var pn = "4.0.1";
|
|
4231
|
-
var ye = {};
|
|
4232
|
-
Le(ye, { read: () => yn, write: () => mn });
|
|
4233
|
-
function mn(e) {
|
|
4234
|
-
let n = { options: { directed: e.isDirected(), multigraph: e.isMultigraph(), compound: e.isCompound() }, nodes: En(e), edges: Ln(e) }, t = e.graph();
|
|
4235
|
-
return t !== void 0 && (n.value = structuredClone(t)), n;
|
|
4236
|
-
}
|
|
4237
|
-
function En(e) {
|
|
4238
|
-
return e.nodes().map((n) => {
|
|
4239
|
-
let t = e.node(n), r5 = e.parent(n), o = { v: n };
|
|
4240
|
-
return t !== void 0 && (o.value = t), r5 !== void 0 && (o.parent = r5), o;
|
|
4241
|
-
});
|
|
4242
|
-
}
|
|
4243
|
-
function Ln(e) {
|
|
4244
|
-
return e.edges().map((n) => {
|
|
4245
|
-
let t = e.edge(n), r5 = { v: n.v, w: n.w };
|
|
4246
|
-
return n.name !== void 0 && (r5.name = n.name), t !== void 0 && (r5.value = t), r5;
|
|
4247
|
-
});
|
|
4248
|
-
}
|
|
4249
|
-
function yn(e) {
|
|
4250
|
-
let n = new p(e.options);
|
|
4251
|
-
return e.value !== void 0 && n.setGraph(e.value), e.nodes.forEach((t) => {
|
|
4252
|
-
n.setNode(t.v, t.value), t.parent && n.setParent(t.v, t.parent);
|
|
4253
|
-
}), e.edges.forEach((t) => {
|
|
4254
|
-
n.setEdge({ v: t.v, w: t.w, name: t.name }, t.value);
|
|
4255
|
-
}), n;
|
|
4256
|
-
}
|
|
4257
|
-
var R = {};
|
|
4258
|
-
Le(R, { CycleException: () => D, bellmanFord: () => we, components: () => Gn, dijkstra: () => F, dijkstraAll: () => _n, findCycles: () => xn, floydWarshall: () => On, isAcyclic: () => Cn, postorder: () => Pn, preorder: () => Mn, prim: () => jn, shortestPaths: () => Sn, tarjan: () => Ge, topsort: () => ke });
|
|
4259
|
-
var wn = () => 1;
|
|
4260
|
-
function we(e, n, t, r5) {
|
|
4261
|
-
return Nn(e, String(n), t || wn, r5 || function(o) {
|
|
4262
|
-
return e.outEdges(o);
|
|
4263
|
-
});
|
|
4264
|
-
}
|
|
4265
|
-
function Nn(e, n, t, r5) {
|
|
4266
|
-
let o = {}, i, s = 0, a = e.nodes(), d = function(c) {
|
|
4267
|
-
let h = t(c);
|
|
4268
|
-
o[c.v].distance + h < o[c.w].distance && (o[c.w] = { distance: o[c.v].distance + h, predecessor: c.v }, i = true);
|
|
4269
|
-
}, l = function() {
|
|
4270
|
-
a.forEach(function(c) {
|
|
4271
|
-
r5(c).forEach(function(h) {
|
|
4272
|
-
let f = h.v === c ? h.v : h.w, g = f === h.v ? h.w : h.v;
|
|
4273
|
-
d({ v: f, w: g });
|
|
4274
|
-
});
|
|
4275
|
-
});
|
|
4276
|
-
};
|
|
4277
|
-
a.forEach(function(c) {
|
|
4278
|
-
let h = c === n ? 0 : Number.POSITIVE_INFINITY;
|
|
4279
|
-
o[c] = { distance: h, predecessor: "" };
|
|
4280
|
-
});
|
|
4281
|
-
let u = a.length;
|
|
4282
|
-
for (let c = 1; c < u && (i = false, s++, l(), !!i); c++) ;
|
|
4283
|
-
if (s === u - 1 && (i = false, l(), i)) throw new Error("The graph contains a negative weight cycle");
|
|
4284
|
-
return o;
|
|
4285
|
-
}
|
|
4286
|
-
function Gn(e) {
|
|
4287
|
-
let n = {}, t = [], r5;
|
|
4288
|
-
function o(i) {
|
|
4289
|
-
i in n || (n[i] = true, r5.push(i), e.successors(i).forEach(o), e.predecessors(i).forEach(o));
|
|
4457
|
+
setGraph(e) {
|
|
4458
|
+
return this._label = e, this;
|
|
4290
4459
|
}
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
}), t;
|
|
4294
|
-
}
|
|
4295
|
-
var Ne = class {
|
|
4296
|
-
constructor() {
|
|
4297
|
-
this._arr = [], this._keyIndices = {};
|
|
4460
|
+
graph() {
|
|
4461
|
+
return this._label;
|
|
4298
4462
|
}
|
|
4299
|
-
|
|
4300
|
-
return this.
|
|
4463
|
+
setDefaultNodeLabel(e) {
|
|
4464
|
+
return typeof e != "function" ? this._defaultNodeLabelFn = () => e : this._defaultNodeLabelFn = e, this;
|
|
4301
4465
|
}
|
|
4302
|
-
|
|
4303
|
-
return this.
|
|
4466
|
+
nodeCount() {
|
|
4467
|
+
return this._nodeCount;
|
|
4304
4468
|
}
|
|
4305
|
-
|
|
4306
|
-
return
|
|
4469
|
+
nodes() {
|
|
4470
|
+
return Object.keys(this._nodes);
|
|
4307
4471
|
}
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
if (n !== void 0) return this._arr[n].priority;
|
|
4472
|
+
sources() {
|
|
4473
|
+
return this.nodes().filter((e) => Object.keys(this._in[e]).length === 0);
|
|
4311
4474
|
}
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
return this._arr[0].key;
|
|
4475
|
+
sinks() {
|
|
4476
|
+
return this.nodes().filter((e) => Object.keys(this._out[e]).length === 0);
|
|
4315
4477
|
}
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
return t[r5] = i, o.push({ key: r5, priority: n }), this._decrease(i), true;
|
|
4321
|
-
}
|
|
4322
|
-
return false;
|
|
4478
|
+
setNodes(e, n) {
|
|
4479
|
+
return e.forEach((t) => {
|
|
4480
|
+
n !== void 0 ? this.setNode(t, n) : this.setNode(t);
|
|
4481
|
+
}), this;
|
|
4323
4482
|
}
|
|
4324
|
-
|
|
4325
|
-
this.
|
|
4326
|
-
let e = this._arr.pop();
|
|
4327
|
-
return delete this._keyIndices[e.key], this._heapify(0), e.key;
|
|
4483
|
+
setNode(e, n) {
|
|
4484
|
+
return e in this._nodes ? (arguments.length > 1 && (this._nodes[e] = n), this) : (this._nodes[e] = arguments.length > 1 ? n : this._defaultNodeLabelFn(e), this._isCompound && (this._parent[e] = "\0", this._children[e] = {}, this._children["\0"][e] = true), this._in[e] = {}, this._preds[e] = {}, this._out[e] = {}, this._sucs[e] = {}, ++this._nodeCount, this);
|
|
4328
4485
|
}
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
if (t === void 0) throw new Error(`Key not found: ${e}`);
|
|
4332
|
-
let r5 = this._arr[t].priority;
|
|
4333
|
-
if (n > r5) throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r5} New: ${n}`);
|
|
4334
|
-
this._arr[t].priority = n, this._decrease(t);
|
|
4486
|
+
node(e) {
|
|
4487
|
+
return this._nodes[e];
|
|
4335
4488
|
}
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
t < n.length && (o = n[t].priority < n[o].priority ? t : o, r5 < n.length && (o = n[r5].priority < n[o].priority ? r5 : o), o !== e && (this._swap(e, o), this._heapify(o)));
|
|
4489
|
+
hasNode(e) {
|
|
4490
|
+
return e in this._nodes;
|
|
4339
4491
|
}
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4492
|
+
removeNode(e) {
|
|
4493
|
+
if (e in this._nodes) {
|
|
4494
|
+
let n = (t) => this.removeEdge(this._edgeObjs[t]);
|
|
4495
|
+
delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((t) => {
|
|
4496
|
+
this.setParent(t);
|
|
4497
|
+
}), delete this._children[e]), Object.keys(this._in[e]).forEach(n), delete this._in[e], delete this._preds[e], Object.keys(this._out[e]).forEach(n), delete this._out[e], delete this._sucs[e], --this._nodeCount;
|
|
4498
|
+
}
|
|
4499
|
+
return this;
|
|
4343
4500
|
}
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4501
|
+
setParent(e, n) {
|
|
4502
|
+
if (!this._isCompound) throw new Error("Cannot set parent in a non-compound graph");
|
|
4503
|
+
if (n === void 0) n = "\0";
|
|
4504
|
+
else {
|
|
4505
|
+
n += "";
|
|
4506
|
+
for (let t = n; t !== void 0; t = this.parent(t)) if (t === e) throw new Error("Setting " + n + " as parent of " + e + " would create a cycle");
|
|
4507
|
+
this.setNode(n);
|
|
4508
|
+
}
|
|
4509
|
+
return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = n, this._children[n][e] = true, this;
|
|
4347
4510
|
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
return e.outEdges(i);
|
|
4353
|
-
};
|
|
4354
|
-
return vn(e, String(n), t || kn, r5 || o);
|
|
4355
|
-
}
|
|
4356
|
-
function vn(e, n, t, r5) {
|
|
4357
|
-
let o = {}, i = new Ne(), s, a, d = function(l) {
|
|
4358
|
-
let u = l.v !== s ? l.v : l.w, c = o[u], h = t(l), f = a.distance + h;
|
|
4359
|
-
if (h < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + l + " Weight: " + h);
|
|
4360
|
-
f < c.distance && (c.distance = f, c.predecessor = s, i.decrease(u, f));
|
|
4361
|
-
};
|
|
4362
|
-
for (e.nodes().forEach(function(l) {
|
|
4363
|
-
let u = l === n ? 0 : Number.POSITIVE_INFINITY;
|
|
4364
|
-
o[l] = { distance: u, predecessor: "" }, i.add(l, u);
|
|
4365
|
-
}); i.size() > 0 && (s = i.removeMin(), a = o[s], a.distance !== Number.POSITIVE_INFINITY); ) r5(s).forEach(d);
|
|
4366
|
-
return o;
|
|
4367
|
-
}
|
|
4368
|
-
function _n(e, n, t) {
|
|
4369
|
-
return e.nodes().reduce(function(r5, o) {
|
|
4370
|
-
return r5[o] = F(e, o, n, t), r5;
|
|
4371
|
-
}, {});
|
|
4372
|
-
}
|
|
4373
|
-
function Ge(e) {
|
|
4374
|
-
let n = 0, t = [], r5 = {}, o = [];
|
|
4375
|
-
function i(s) {
|
|
4376
|
-
let a = r5[s] = { onStack: true, lowlink: n, index: n++ };
|
|
4377
|
-
if (t.push(s), e.successors(s).forEach(function(d) {
|
|
4378
|
-
d in r5 ? r5[d].onStack && (a.lowlink = Math.min(a.lowlink, r5[d].index)) : (i(d), a.lowlink = Math.min(a.lowlink, r5[d].lowlink));
|
|
4379
|
-
}), a.lowlink === a.index) {
|
|
4380
|
-
let d = [], l;
|
|
4381
|
-
do
|
|
4382
|
-
l = t.pop(), r5[l].onStack = false, d.push(l);
|
|
4383
|
-
while (s !== l);
|
|
4384
|
-
o.push(d);
|
|
4511
|
+
parent(e) {
|
|
4512
|
+
if (this._isCompound) {
|
|
4513
|
+
let n = this._parent[e];
|
|
4514
|
+
if (n !== "\0") return n;
|
|
4385
4515
|
}
|
|
4386
4516
|
}
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
return
|
|
4400
|
-
}
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
let
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4517
|
+
children(e = "\0") {
|
|
4518
|
+
if (this._isCompound) {
|
|
4519
|
+
let n = this._children[e];
|
|
4520
|
+
if (n) return Object.keys(n);
|
|
4521
|
+
} else {
|
|
4522
|
+
if (e === "\0") return this.nodes();
|
|
4523
|
+
if (this.hasNode(e)) return [];
|
|
4524
|
+
}
|
|
4525
|
+
return [];
|
|
4526
|
+
}
|
|
4527
|
+
predecessors(e) {
|
|
4528
|
+
let n = this._preds[e];
|
|
4529
|
+
if (n) return Object.keys(n);
|
|
4530
|
+
}
|
|
4531
|
+
successors(e) {
|
|
4532
|
+
let n = this._sucs[e];
|
|
4533
|
+
if (n) return Object.keys(n);
|
|
4534
|
+
}
|
|
4535
|
+
neighbors(e) {
|
|
4536
|
+
let n = this.predecessors(e);
|
|
4537
|
+
if (n) {
|
|
4538
|
+
let t = new Set(n);
|
|
4539
|
+
for (let r5 of this.successors(e)) t.add(r5);
|
|
4540
|
+
return Array.from(t.values());
|
|
4541
|
+
}
|
|
4542
|
+
}
|
|
4543
|
+
isLeaf(e) {
|
|
4544
|
+
let n;
|
|
4545
|
+
return this.isDirected() ? n = this.successors(e) : n = this.neighbors(e), n.length === 0;
|
|
4546
|
+
}
|
|
4547
|
+
filterNodes(e) {
|
|
4548
|
+
let n = new this.constructor({ directed: this._isDirected, multigraph: this._isMultigraph, compound: this._isCompound });
|
|
4549
|
+
n.setGraph(this.graph()), Object.entries(this._nodes).forEach(([o, i]) => {
|
|
4550
|
+
e(o) && n.setNode(o, i);
|
|
4551
|
+
}), Object.values(this._edgeObjs).forEach((o) => {
|
|
4552
|
+
n.hasNode(o.v) && n.hasNode(o.w) && n.setEdge(o, this.edge(o));
|
|
4419
4553
|
});
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4554
|
+
let t = {}, r5 = (o) => {
|
|
4555
|
+
let i = this.parent(o);
|
|
4556
|
+
return !i || n.hasNode(i) ? (t[o] = i != null ? i : void 0, i != null ? i : void 0) : i in t ? t[i] : r5(i);
|
|
4557
|
+
};
|
|
4558
|
+
return this._isCompound && n.nodes().forEach((o) => n.setParent(o, r5(o))), n;
|
|
4425
4559
|
}
|
|
4426
|
-
|
|
4427
|
-
function
|
|
4428
|
-
let n = {}, t = {}, r5 = [];
|
|
4429
|
-
function o(i) {
|
|
4430
|
-
if (i in t) throw new D();
|
|
4431
|
-
i in n || (t[i] = true, n[i] = true, e.predecessors(i).forEach(o), delete t[i], r5.push(i));
|
|
4560
|
+
setDefaultEdgeLabel(e) {
|
|
4561
|
+
return typeof e != "function" ? this._defaultEdgeLabelFn = () => e : this._defaultEdgeLabelFn = e, this;
|
|
4432
4562
|
}
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
}
|
|
4436
|
-
function Cn(e) {
|
|
4437
|
-
try {
|
|
4438
|
-
ke(e);
|
|
4439
|
-
} catch (n) {
|
|
4440
|
-
if (n instanceof D) return false;
|
|
4441
|
-
throw n;
|
|
4563
|
+
edgeCount() {
|
|
4564
|
+
return this._edgeCount;
|
|
4442
4565
|
}
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
function Rn(e, n, t, r5, o) {
|
|
4446
|
-
Array.isArray(n) || (n = [n]);
|
|
4447
|
-
let i = ((a) => {
|
|
4448
|
-
var d;
|
|
4449
|
-
return (d = e.isDirected() ? e.successors(a) : e.neighbors(a)) != null ? d : [];
|
|
4450
|
-
}), s = {};
|
|
4451
|
-
return n.forEach(function(a) {
|
|
4452
|
-
if (!e.hasNode(a)) throw new Error("Graph does not have node: " + a);
|
|
4453
|
-
o = ve(e, a, t === "post", s, i, r5, o);
|
|
4454
|
-
}), o;
|
|
4455
|
-
}
|
|
4456
|
-
function ve(e, n, t, r5, o, i, s) {
|
|
4457
|
-
return n in r5 || (r5[n] = true, t || (s = i(s, n)), o(n).forEach(function(a) {
|
|
4458
|
-
s = ve(e, a, t, r5, o, i, s);
|
|
4459
|
-
}), t && (s = i(s, n))), s;
|
|
4460
|
-
}
|
|
4461
|
-
function _e(e, n, t) {
|
|
4462
|
-
return Rn(e, n, t, function(r5, o) {
|
|
4463
|
-
return r5.push(o), r5;
|
|
4464
|
-
}, []);
|
|
4465
|
-
}
|
|
4466
|
-
function Pn(e, n) {
|
|
4467
|
-
return _e(e, n, "post");
|
|
4468
|
-
}
|
|
4469
|
-
function Mn(e, n) {
|
|
4470
|
-
return _e(e, n, "pre");
|
|
4471
|
-
}
|
|
4472
|
-
function jn(e, n) {
|
|
4473
|
-
let t = new p(), r5 = {}, o = new Ne(), i;
|
|
4474
|
-
function s(d) {
|
|
4475
|
-
let l = d.v === i ? d.w : d.v, u = o.priority(l);
|
|
4476
|
-
if (u !== void 0) {
|
|
4477
|
-
let c = n(d);
|
|
4478
|
-
c < u && (r5[l] = i, o.decrease(l, c));
|
|
4479
|
-
}
|
|
4566
|
+
edges() {
|
|
4567
|
+
return Object.values(this._edgeObjs);
|
|
4480
4568
|
}
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
o.add(d, Number.POSITIVE_INFINITY), t.setNode(d);
|
|
4484
|
-
}), o.decrease(e.nodes()[0], 0);
|
|
4485
|
-
let a = false;
|
|
4486
|
-
for (; o.size() > 0; ) {
|
|
4487
|
-
if (i = o.removeMin(), i in r5) t.setEdge(i, r5[i]);
|
|
4488
|
-
else {
|
|
4489
|
-
if (a) throw new Error("Input graph is not connected: " + e);
|
|
4490
|
-
a = true;
|
|
4491
|
-
}
|
|
4492
|
-
e.nodeEdges(i).forEach(s);
|
|
4569
|
+
setPath(e, n) {
|
|
4570
|
+
return e.reduce((t, r5) => (n !== void 0 ? this.setEdge(t, r5, n) : this.setEdge(t, r5), r5)), this;
|
|
4493
4571
|
}
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4572
|
+
setEdge(e, n, t, r5) {
|
|
4573
|
+
let o, i, s, a, d = false;
|
|
4574
|
+
typeof e == "object" && e !== null && "v" in e ? (o = e.v, i = e.w, s = e.name, arguments.length === 2 && (a = n, d = true)) : (o = e, i = n, s = r5, arguments.length > 2 && (a = t, d = true)), o = "" + o, i = "" + i, s !== void 0 && (s = "" + s);
|
|
4575
|
+
let l = C(this._isDirected, o, i, s);
|
|
4576
|
+
if (l in this._edgeLabels) return d && (this._edgeLabels[l] = a), this;
|
|
4577
|
+
if (s !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
|
|
4578
|
+
this.setNode(o), this.setNode(i), this._edgeLabels[l] = d ? a : this._defaultEdgeLabelFn(o, i, s);
|
|
4579
|
+
let u = gn(this._isDirected, o, i, s);
|
|
4580
|
+
return o = u.v, i = u.w, Object.freeze(u), this._edgeObjs[l] = u, me(this._preds[i], o), me(this._sucs[o], i), this._in[i][l] = u, this._out[o][l] = u, this._edgeCount++, this;
|
|
4581
|
+
}
|
|
4582
|
+
edge(e, n, t) {
|
|
4583
|
+
let r5 = arguments.length === 1 ? Y(this._isDirected, e) : C(this._isDirected, e, n, t);
|
|
4584
|
+
return this._edgeLabels[r5];
|
|
4585
|
+
}
|
|
4586
|
+
edgeAsObj(e, n, t) {
|
|
4587
|
+
let r5 = arguments.length === 1 ? this.edge(e) : this.edge(e, n, t);
|
|
4588
|
+
return typeof r5 != "object" ? { label: r5 } : r5;
|
|
4589
|
+
}
|
|
4590
|
+
hasEdge(e, n, t) {
|
|
4591
|
+
return (arguments.length === 1 ? Y(this._isDirected, e) : C(this._isDirected, e, n, t)) in this._edgeLabels;
|
|
4592
|
+
}
|
|
4593
|
+
removeEdge(e, n, t) {
|
|
4594
|
+
let r5 = arguments.length === 1 ? Y(this._isDirected, e) : C(this._isDirected, e, n, t), o = this._edgeObjs[r5];
|
|
4595
|
+
if (o) {
|
|
4596
|
+
let i = o.v, s = o.w;
|
|
4597
|
+
delete this._edgeLabels[r5], delete this._edgeObjs[r5], Ee(this._preds[s], i), Ee(this._sucs[i], s), delete this._in[s][r5], delete this._out[i][r5], this._edgeCount--;
|
|
4510
4598
|
}
|
|
4511
|
-
|
|
4599
|
+
return this;
|
|
4512
4600
|
}
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
}), n;
|
|
4534
|
-
}
|
|
4535
|
-
function H(e, n) {
|
|
4536
|
-
let t = e.x, r5 = e.y, o = n.x - t, i = n.y - r5, s = e.width / 2, a = e.height / 2;
|
|
4537
|
-
if (!o && !i) throw new Error("Not possible to find intersection inside of the rectangle");
|
|
4538
|
-
let d, l;
|
|
4539
|
-
return Math.abs(i) * s > Math.abs(o) * a ? (i < 0 && (a = -a), d = a * o / i, l = a) : (o < 0 && (s = -s), d = s, l = s * i / o), { x: t + d, y: r5 + l };
|
|
4540
|
-
}
|
|
4541
|
-
function N(e) {
|
|
4542
|
-
let n = k(X(e) + 1).map(() => []);
|
|
4543
|
-
return e.nodes().forEach((t) => {
|
|
4544
|
-
let r5 = e.node(t), o = r5.rank;
|
|
4545
|
-
o !== void 0 && (n[o] || (n[o] = []), n[o][r5.order] = t);
|
|
4546
|
-
}), n;
|
|
4547
|
-
}
|
|
4548
|
-
function Te(e) {
|
|
4549
|
-
let n = e.nodes().map((r5) => {
|
|
4550
|
-
let o = e.node(r5).rank;
|
|
4551
|
-
return o === void 0 ? Number.MAX_VALUE : o;
|
|
4552
|
-
}), t = L(Math.min, n);
|
|
4553
|
-
e.nodes().forEach((r5) => {
|
|
4554
|
-
let o = e.node(r5);
|
|
4555
|
-
Object.hasOwn(o, "rank") && (o.rank -= t);
|
|
4556
|
-
});
|
|
4601
|
+
inEdges(e, n) {
|
|
4602
|
+
return this.isDirected() ? this.filterEdges(this._in[e], e, n) : this.nodeEdges(e, n);
|
|
4603
|
+
}
|
|
4604
|
+
outEdges(e, n) {
|
|
4605
|
+
return this.isDirected() ? this.filterEdges(this._out[e], e, n) : this.nodeEdges(e, n);
|
|
4606
|
+
}
|
|
4607
|
+
nodeEdges(e, n) {
|
|
4608
|
+
if (e in this._nodes) return this.filterEdges({ ...this._in[e], ...this._out[e] }, e, n);
|
|
4609
|
+
}
|
|
4610
|
+
_removeFromParentsChildList(e) {
|
|
4611
|
+
delete this._children[this._parent[e]][e];
|
|
4612
|
+
}
|
|
4613
|
+
filterEdges(e, n, t) {
|
|
4614
|
+
if (!e) return;
|
|
4615
|
+
let r5 = Object.values(e);
|
|
4616
|
+
return t ? r5.filter((o) => o.v === n && o.w === t || o.v === t && o.w === n) : r5;
|
|
4617
|
+
}
|
|
4618
|
+
};
|
|
4619
|
+
function me(e, n) {
|
|
4620
|
+
e[n] ? e[n]++ : e[n] = 1;
|
|
4557
4621
|
}
|
|
4558
|
-
function
|
|
4559
|
-
|
|
4560
|
-
e.nodes().forEach((s) => {
|
|
4561
|
-
let a = e.node(s).rank - t;
|
|
4562
|
-
r5[a] || (r5[a] = []), r5[a].push(s);
|
|
4563
|
-
});
|
|
4564
|
-
let o = 0, i = e.graph().nodeRankFactor;
|
|
4565
|
-
Array.from(r5).forEach((s, a) => {
|
|
4566
|
-
s === void 0 && a % i !== 0 ? --o : s !== void 0 && o && s.forEach((d) => e.node(d).rank += o);
|
|
4567
|
-
});
|
|
4622
|
+
function Ee(e, n) {
|
|
4623
|
+
e[n] !== void 0 && !--e[n] && delete e[n];
|
|
4568
4624
|
}
|
|
4569
|
-
function
|
|
4570
|
-
let o =
|
|
4571
|
-
|
|
4625
|
+
function C(e, n, t, r5) {
|
|
4626
|
+
let o = "" + n, i = "" + t;
|
|
4627
|
+
if (!e && o > i) {
|
|
4628
|
+
let s = o;
|
|
4629
|
+
o = i, i = s;
|
|
4630
|
+
}
|
|
4631
|
+
return o + "" + i + "" + (r5 === void 0 ? "\0" : r5);
|
|
4572
4632
|
}
|
|
4573
|
-
function
|
|
4574
|
-
let
|
|
4575
|
-
|
|
4576
|
-
let
|
|
4577
|
-
|
|
4633
|
+
function gn(e, n, t, r5) {
|
|
4634
|
+
let o = "" + n, i = "" + t;
|
|
4635
|
+
if (!e && o > i) {
|
|
4636
|
+
let a = o;
|
|
4637
|
+
o = i, i = a;
|
|
4578
4638
|
}
|
|
4579
|
-
|
|
4639
|
+
let s = { v: o, w: i };
|
|
4640
|
+
return r5 && (s.name = r5), s;
|
|
4580
4641
|
}
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4642
|
+
function Y(e, n) {
|
|
4643
|
+
return C(e, n.v, n.w, n.name);
|
|
4644
|
+
}
|
|
4645
|
+
var pn = "4.0.1";
|
|
4646
|
+
var ye = {};
|
|
4647
|
+
Le(ye, { read: () => yn, write: () => mn });
|
|
4648
|
+
function mn(e) {
|
|
4649
|
+
let n = { options: { directed: e.isDirected(), multigraph: e.isMultigraph(), compound: e.isCompound() }, nodes: En(e), edges: Ln(e) }, t = e.graph();
|
|
4650
|
+
return t !== void 0 && (n.value = structuredClone(t)), n;
|
|
4587
4651
|
}
|
|
4588
|
-
function
|
|
4589
|
-
|
|
4590
|
-
let
|
|
4591
|
-
return o
|
|
4652
|
+
function En(e) {
|
|
4653
|
+
return e.nodes().map((n) => {
|
|
4654
|
+
let t = e.node(n), r5 = e.parent(n), o = { v: n };
|
|
4655
|
+
return t !== void 0 && (o.value = t), r5 !== void 0 && (o.parent = r5), o;
|
|
4592
4656
|
});
|
|
4593
|
-
return L(Math.max, t);
|
|
4594
|
-
}
|
|
4595
|
-
function Ce(e, n) {
|
|
4596
|
-
let t = { lhs: [], rhs: [] };
|
|
4597
|
-
return e.forEach((r5) => {
|
|
4598
|
-
n(r5) ? t.lhs.push(r5) : t.rhs.push(r5);
|
|
4599
|
-
}), t;
|
|
4600
4657
|
}
|
|
4601
|
-
function
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
return n();
|
|
4605
|
-
}
|
|
4606
|
-
console.log(e + " time: " + (Date.now() - t) + "ms");
|
|
4607
|
-
}
|
|
4658
|
+
function Ln(e) {
|
|
4659
|
+
return e.edges().map((n) => {
|
|
4660
|
+
let t = e.edge(n), r5 = { v: n.v, w: n.w };
|
|
4661
|
+
return n.name !== void 0 && (r5.name = n.name), t !== void 0 && (r5.value = t), r5;
|
|
4662
|
+
});
|
|
4608
4663
|
}
|
|
4609
|
-
function
|
|
4610
|
-
|
|
4664
|
+
function yn(e) {
|
|
4665
|
+
let n = new p(e.options);
|
|
4666
|
+
return e.value !== void 0 && n.setGraph(e.value), e.nodes.forEach((t) => {
|
|
4667
|
+
n.setNode(t.v, t.value), t.parent && n.setParent(t.v, t.parent);
|
|
4668
|
+
}), e.edges.forEach((t) => {
|
|
4669
|
+
n.setEdge({ v: t.v, w: t.w, name: t.name }, t.value);
|
|
4670
|
+
}), n;
|
|
4611
4671
|
}
|
|
4612
|
-
var
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4672
|
+
var R = {};
|
|
4673
|
+
Le(R, { CycleException: () => D, bellmanFord: () => we, components: () => Gn, dijkstra: () => F, dijkstraAll: () => _n, findCycles: () => xn, floydWarshall: () => On, isAcyclic: () => Cn, postorder: () => Pn, preorder: () => Mn, prim: () => jn, shortestPaths: () => Sn, tarjan: () => Ge, topsort: () => ke });
|
|
4674
|
+
var wn = () => 1;
|
|
4675
|
+
function we(e, n, t, r5) {
|
|
4676
|
+
return Nn(e, String(n), t || wn, r5 || function(o) {
|
|
4677
|
+
return e.outEdges(o);
|
|
4678
|
+
});
|
|
4616
4679
|
}
|
|
4617
|
-
function
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4680
|
+
function Nn(e, n, t, r5) {
|
|
4681
|
+
let o = {}, i, s = 0, a = e.nodes(), d = function(c) {
|
|
4682
|
+
let h = t(c);
|
|
4683
|
+
o[c.v].distance + h < o[c.w].distance && (o[c.w] = { distance: o[c.v].distance + h, predecessor: c.v }, i = true);
|
|
4684
|
+
}, l = function() {
|
|
4685
|
+
a.forEach(function(c) {
|
|
4686
|
+
r5(c).forEach(function(h) {
|
|
4687
|
+
let f = h.v === c ? h.v : h.w, g = f === h.v ? h.w : h.v;
|
|
4688
|
+
d({ v: f, w: g });
|
|
4689
|
+
});
|
|
4690
|
+
});
|
|
4691
|
+
};
|
|
4692
|
+
a.forEach(function(c) {
|
|
4693
|
+
let h = c === n ? 0 : Number.POSITIVE_INFINITY;
|
|
4694
|
+
o[c] = { distance: h, predecessor: "" };
|
|
4695
|
+
});
|
|
4696
|
+
let u = a.length;
|
|
4697
|
+
for (let c = 1; c < u && (i = false, s++, l(), !!i); c++) ;
|
|
4698
|
+
if (s === u - 1 && (i = false, l(), i)) throw new Error("The graph contains a negative weight cycle");
|
|
4623
4699
|
return o;
|
|
4624
4700
|
}
|
|
4625
|
-
function
|
|
4626
|
-
let
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
}
|
|
4634
|
-
function Re(e, n) {
|
|
4635
|
-
return e.reduce((t, r5, o) => (t[r5] = n[o], t), {});
|
|
4701
|
+
function Gn(e) {
|
|
4702
|
+
let n = {}, t = [], r5;
|
|
4703
|
+
function o(i) {
|
|
4704
|
+
i in n || (n[i] = true, r5.push(i), e.successors(i).forEach(o), e.predecessors(i).forEach(o));
|
|
4705
|
+
}
|
|
4706
|
+
return e.nodes().forEach(function(i) {
|
|
4707
|
+
r5 = [], o(i), r5.length && t.push(r5);
|
|
4708
|
+
}), t;
|
|
4636
4709
|
}
|
|
4637
|
-
var
|
|
4638
|
-
var U = "3.0.0";
|
|
4639
|
-
var K = class {
|
|
4710
|
+
var Ne = class {
|
|
4640
4711
|
constructor() {
|
|
4641
|
-
|
|
4642
|
-
let n = {};
|
|
4643
|
-
n._next = n._prev = n, this._sentinel = n;
|
|
4712
|
+
this._arr = [], this._keyIndices = {};
|
|
4644
4713
|
}
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
if (t !== n) return Pe(t), t;
|
|
4714
|
+
size() {
|
|
4715
|
+
return this._arr.length;
|
|
4648
4716
|
}
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
n._prev && n._next && Pe(n), n._next = t._next, t._next._prev = n, t._next = n, n._prev = t;
|
|
4717
|
+
keys() {
|
|
4718
|
+
return this._arr.map((e) => e.key);
|
|
4652
4719
|
}
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4720
|
+
has(e) {
|
|
4721
|
+
return e in this._keyIndices;
|
|
4722
|
+
}
|
|
4723
|
+
priority(e) {
|
|
4724
|
+
let n = this._keyIndices[e];
|
|
4725
|
+
if (n !== void 0) return this._arr[n].priority;
|
|
4726
|
+
}
|
|
4727
|
+
min() {
|
|
4728
|
+
if (this.size() === 0) throw new Error("Queue underflow");
|
|
4729
|
+
return this._arr[0].key;
|
|
4730
|
+
}
|
|
4731
|
+
add(e, n) {
|
|
4732
|
+
let t = this._keyIndices, r5 = String(e);
|
|
4733
|
+
if (!(r5 in t)) {
|
|
4734
|
+
let o = this._arr, i = o.length;
|
|
4735
|
+
return t[r5] = i, o.push({ key: r5, priority: n }), this._decrease(i), true;
|
|
4736
|
+
}
|
|
4737
|
+
return false;
|
|
4738
|
+
}
|
|
4739
|
+
removeMin() {
|
|
4740
|
+
this._swap(0, this._arr.length - 1);
|
|
4741
|
+
let e = this._arr.pop();
|
|
4742
|
+
return delete this._keyIndices[e.key], this._heapify(0), e.key;
|
|
4743
|
+
}
|
|
4744
|
+
decrease(e, n) {
|
|
4745
|
+
let t = this._keyIndices[e];
|
|
4746
|
+
if (t === void 0) throw new Error(`Key not found: ${e}`);
|
|
4747
|
+
let r5 = this._arr[t].priority;
|
|
4748
|
+
if (n > r5) throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r5} New: ${n}`);
|
|
4749
|
+
this._arr[t].priority = n, this._decrease(t);
|
|
4750
|
+
}
|
|
4751
|
+
_heapify(e) {
|
|
4752
|
+
let n = this._arr, t = 2 * e, r5 = t + 1, o = e;
|
|
4753
|
+
t < n.length && (o = n[t].priority < n[o].priority ? t : o, r5 < n.length && (o = n[r5].priority < n[o].priority ? r5 : o), o !== e && (this._swap(e, o), this._heapify(o)));
|
|
4754
|
+
}
|
|
4755
|
+
_decrease(e) {
|
|
4756
|
+
let n = this._arr, t = n[e].priority, r5;
|
|
4757
|
+
for (; e !== 0 && (r5 = e >> 1, !(n[r5].priority < t)); ) this._swap(e, r5), e = r5;
|
|
4758
|
+
}
|
|
4759
|
+
_swap(e, n) {
|
|
4760
|
+
let t = this._arr, r5 = this._keyIndices, o = t[e], i = t[n];
|
|
4761
|
+
t[e] = i, t[n] = o, r5[i.key] = e, r5[o.key] = n;
|
|
4657
4762
|
}
|
|
4658
4763
|
};
|
|
4659
|
-
|
|
4660
|
-
|
|
4764
|
+
var kn = () => 1;
|
|
4765
|
+
function F(e, n, t, r5) {
|
|
4766
|
+
let o = function(i) {
|
|
4767
|
+
return e.outEdges(i);
|
|
4768
|
+
};
|
|
4769
|
+
return vn(e, String(n), t || kn, r5 || o);
|
|
4661
4770
|
}
|
|
4662
|
-
function
|
|
4663
|
-
|
|
4771
|
+
function vn(e, n, t, r5) {
|
|
4772
|
+
let o = {}, i = new Ne(), s, a, d = function(l) {
|
|
4773
|
+
let u = l.v !== s ? l.v : l.w, c = o[u], h = t(l), f = a.distance + h;
|
|
4774
|
+
if (h < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + l + " Weight: " + h);
|
|
4775
|
+
f < c.distance && (c.distance = f, c.predecessor = s, i.decrease(u, f));
|
|
4776
|
+
};
|
|
4777
|
+
for (e.nodes().forEach(function(l) {
|
|
4778
|
+
let u = l === n ? 0 : Number.POSITIVE_INFINITY;
|
|
4779
|
+
o[l] = { distance: u, predecessor: "" }, i.add(l, u);
|
|
4780
|
+
}); i.size() > 0 && (s = i.removeMin(), a = o[s], a.distance !== Number.POSITIVE_INFINITY); ) r5(s).forEach(d);
|
|
4781
|
+
return o;
|
|
4664
4782
|
}
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
let t = Yn(e, n || Wn);
|
|
4670
|
-
return Bn(t.graph, t.buckets, t.zeroIdx).flatMap((o) => e.outEdges(o.v, o.w) || []);
|
|
4783
|
+
function _n(e, n, t) {
|
|
4784
|
+
return e.nodes().reduce(function(r5, o) {
|
|
4785
|
+
return r5[o] = F(e, o, n, t), r5;
|
|
4786
|
+
}, {});
|
|
4671
4787
|
}
|
|
4672
|
-
function
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4788
|
+
function Ge(e) {
|
|
4789
|
+
let n = 0, t = [], r5 = {}, o = [];
|
|
4790
|
+
function i(s) {
|
|
4791
|
+
let a = r5[s] = { onStack: true, lowlink: n, index: n++ };
|
|
4792
|
+
if (t.push(s), e.successors(s).forEach(function(d) {
|
|
4793
|
+
d in r5 ? r5[d].onStack && (a.lowlink = Math.min(a.lowlink, r5[d].index)) : (i(d), a.lowlink = Math.min(a.lowlink, r5[d].lowlink));
|
|
4794
|
+
}), a.lowlink === a.index) {
|
|
4795
|
+
let d = [], l;
|
|
4796
|
+
do
|
|
4797
|
+
l = t.pop(), r5[l].onStack = false, d.push(l);
|
|
4798
|
+
while (s !== l);
|
|
4799
|
+
o.push(d);
|
|
4683
4800
|
}
|
|
4684
4801
|
}
|
|
4685
|
-
return
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
let i = [], s = o ? i : void 0;
|
|
4689
|
-
return (e.inEdges(r5.v) || []).forEach((a) => {
|
|
4690
|
-
let d = e.edge(a), l = e.node(a.v);
|
|
4691
|
-
o && i.push({ v: a.v, w: a.w }), l.out -= d, J(n, t, l);
|
|
4692
|
-
}), (e.outEdges(r5.v) || []).forEach((a) => {
|
|
4693
|
-
let d = e.edge(a), l = a.w, u = e.node(l);
|
|
4694
|
-
u.in -= d, J(n, t, u);
|
|
4695
|
-
}), e.removeNode(r5.v), s;
|
|
4802
|
+
return e.nodes().forEach(function(s) {
|
|
4803
|
+
s in r5 || i(s);
|
|
4804
|
+
}), o;
|
|
4696
4805
|
}
|
|
4697
|
-
function
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
t.setNode(a, { v: a, in: 0, out: 0 });
|
|
4701
|
-
}), e.edges().forEach((a) => {
|
|
4702
|
-
let d = t.edge(a.v, a.w) || 0, l = n(a), u = d + l;
|
|
4703
|
-
t.setEdge(a.v, a.w, u);
|
|
4704
|
-
let c = t.node(a.v), h = t.node(a.w);
|
|
4705
|
-
o = Math.max(o, c.out += l), r5 = Math.max(r5, h.in += l);
|
|
4806
|
+
function xn(e) {
|
|
4807
|
+
return Ge(e).filter(function(n) {
|
|
4808
|
+
return n.length > 1 || n.length === 1 && e.hasEdge(n[0], n[0]);
|
|
4706
4809
|
});
|
|
4707
|
-
let i = zn(o + r5 + 3).map(() => new Me()), s = r5 + 1;
|
|
4708
|
-
return t.nodes().forEach((a) => {
|
|
4709
|
-
J(i, s, t.node(a));
|
|
4710
|
-
}), { graph: t, buckets: i, zeroIdx: s };
|
|
4711
|
-
}
|
|
4712
|
-
function J(e, n, t) {
|
|
4713
|
-
var r5, o, i;
|
|
4714
|
-
t.out ? t.in ? (i = e[t.out - t.in + n]) == null || i.enqueue(t) : (o = e[e.length - 1]) == null || o.enqueue(t) : (r5 = e[0]) == null || r5.enqueue(t);
|
|
4715
|
-
}
|
|
4716
|
-
function zn(e) {
|
|
4717
|
-
let n = [];
|
|
4718
|
-
for (let t = 0; t < e; t++) n.push(t);
|
|
4719
|
-
return n;
|
|
4720
4810
|
}
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4811
|
+
var Tn = () => 1;
|
|
4812
|
+
function On(e, n, t) {
|
|
4813
|
+
return In(e, n || Tn, t || function(r5) {
|
|
4814
|
+
return e.outEdges(r5);
|
|
4725
4815
|
});
|
|
4726
|
-
function t(r5) {
|
|
4727
|
-
return (o) => r5.edge(o).weight;
|
|
4728
|
-
}
|
|
4729
4816
|
}
|
|
4730
|
-
function
|
|
4731
|
-
let
|
|
4817
|
+
function In(e, n, t) {
|
|
4818
|
+
let r5 = {}, o = e.nodes();
|
|
4819
|
+
return o.forEach(function(i) {
|
|
4820
|
+
r5[i] = {}, r5[i][i] = { distance: 0, predecessor: "" }, o.forEach(function(s) {
|
|
4821
|
+
i !== s && (r5[i][s] = { distance: Number.POSITIVE_INFINITY, predecessor: "" });
|
|
4822
|
+
}), t(i).forEach(function(s) {
|
|
4823
|
+
let a = s.v === i ? s.w : s.v, d = n(s);
|
|
4824
|
+
r5[i][a] = { distance: d, predecessor: i };
|
|
4825
|
+
});
|
|
4826
|
+
}), o.forEach(function(i) {
|
|
4827
|
+
let s = r5[i];
|
|
4828
|
+
o.forEach(function(a) {
|
|
4829
|
+
let d = r5[a];
|
|
4830
|
+
o.forEach(function(l) {
|
|
4831
|
+
let u = d[i], c = s[l], h = d[l], f = u.distance + c.distance;
|
|
4832
|
+
f < h.distance && (h.distance = f, h.predecessor = c.predecessor);
|
|
4833
|
+
});
|
|
4834
|
+
});
|
|
4835
|
+
}), r5;
|
|
4836
|
+
}
|
|
4837
|
+
var D = class extends Error {
|
|
4838
|
+
constructor(...e) {
|
|
4839
|
+
super(...e);
|
|
4840
|
+
}
|
|
4841
|
+
};
|
|
4842
|
+
function ke(e) {
|
|
4843
|
+
let n = {}, t = {}, r5 = [];
|
|
4732
4844
|
function o(i) {
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
}), delete t[i]);
|
|
4845
|
+
if (i in t) throw new D();
|
|
4846
|
+
i in n || (t[i] = true, n[i] = true, e.predecessors(i).forEach(o), delete t[i], r5.push(i));
|
|
4736
4847
|
}
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
function Se(e) {
|
|
4740
|
-
e.edges().forEach((n) => {
|
|
4741
|
-
let t = e.edge(n);
|
|
4742
|
-
if (t.reversed) {
|
|
4743
|
-
e.removeEdge(n);
|
|
4744
|
-
let r5 = t.forwardName;
|
|
4745
|
-
delete t.reversed, delete t.forwardName, e.setEdge(n.w, n.v, t, r5);
|
|
4746
|
-
}
|
|
4747
|
-
});
|
|
4848
|
+
if (e.sinks().forEach(o), Object.keys(n).length !== e.nodeCount()) throw new D();
|
|
4849
|
+
return r5;
|
|
4748
4850
|
}
|
|
4749
|
-
function
|
|
4750
|
-
|
|
4851
|
+
function Cn(e) {
|
|
4852
|
+
try {
|
|
4853
|
+
ke(e);
|
|
4854
|
+
} catch (n) {
|
|
4855
|
+
if (n instanceof D) return false;
|
|
4856
|
+
throw n;
|
|
4857
|
+
}
|
|
4858
|
+
return true;
|
|
4751
4859
|
}
|
|
4752
|
-
function
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4860
|
+
function Rn(e, n, t, r5, o) {
|
|
4861
|
+
Array.isArray(n) || (n = [n]);
|
|
4862
|
+
let i = ((a) => {
|
|
4863
|
+
var d;
|
|
4864
|
+
return (d = e.isDirected() ? e.successors(a) : e.neighbors(a)) != null ? d : [];
|
|
4865
|
+
}), s = {};
|
|
4866
|
+
return n.forEach(function(a) {
|
|
4867
|
+
if (!e.hasNode(a)) throw new Error("Graph does not have node: " + a);
|
|
4868
|
+
o = ve(e, a, t === "post", s, i, r5, o);
|
|
4869
|
+
}), o;
|
|
4759
4870
|
}
|
|
4760
|
-
function
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
});
|
|
4871
|
+
function ve(e, n, t, r5, o, i, s) {
|
|
4872
|
+
return n in r5 || (r5[n] = true, t || (s = i(s, n)), o(n).forEach(function(a) {
|
|
4873
|
+
s = ve(e, a, t, r5, o, i, s);
|
|
4874
|
+
}), t && (s = i(s, n))), s;
|
|
4765
4875
|
}
|
|
4766
|
-
function
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
if (Object.hasOwn(n, r5)) return o.rank;
|
|
4771
|
-
n[r5] = true;
|
|
4772
|
-
let i = e.outEdges(r5), s = i ? i.map((d) => d == null ? Number.POSITIVE_INFINITY : t(d.w) - e.edge(d).minlen) : [], a = L(Math.min, s);
|
|
4773
|
-
return a === Number.POSITIVE_INFINITY && (a = 0), o.rank = a;
|
|
4774
|
-
}
|
|
4775
|
-
e.sources().forEach(t);
|
|
4876
|
+
function _e(e, n, t) {
|
|
4877
|
+
return Rn(e, n, t, function(r5, o) {
|
|
4878
|
+
return r5.push(o), r5;
|
|
4879
|
+
}, []);
|
|
4776
4880
|
}
|
|
4777
|
-
function
|
|
4778
|
-
return e
|
|
4881
|
+
function Pn(e, n) {
|
|
4882
|
+
return _e(e, n, "post");
|
|
4779
4883
|
}
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
let n = new p({ directed: false }), t = e.nodes();
|
|
4783
|
-
if (t.length === 0) throw new Error("Graph must have at least one node");
|
|
4784
|
-
let r5 = t[0], o = e.nodeCount();
|
|
4785
|
-
n.setNode(r5, {});
|
|
4786
|
-
let i, s;
|
|
4787
|
-
for (; $n(n, e) < o && (i = Jn(n, e), !!i); ) s = n.hasNode(i.v) ? v(e, i) : -v(e, i), Qn(n, e, s);
|
|
4788
|
-
return n;
|
|
4884
|
+
function Mn(e, n) {
|
|
4885
|
+
return _e(e, n, "pre");
|
|
4789
4886
|
}
|
|
4790
|
-
function
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4887
|
+
function jn(e, n) {
|
|
4888
|
+
let t = new p(), r5 = {}, o = new Ne(), i;
|
|
4889
|
+
function s(d) {
|
|
4890
|
+
let l = d.v === i ? d.w : d.v, u = o.priority(l);
|
|
4891
|
+
if (u !== void 0) {
|
|
4892
|
+
let c = n(d);
|
|
4893
|
+
c < u && (r5[l] = i, o.decrease(l, c));
|
|
4894
|
+
}
|
|
4797
4895
|
}
|
|
4798
|
-
|
|
4896
|
+
if (e.nodeCount() === 0) return t;
|
|
4897
|
+
e.nodes().forEach(function(d) {
|
|
4898
|
+
o.add(d, Number.POSITIVE_INFINITY), t.setNode(d);
|
|
4899
|
+
}), o.decrease(e.nodes()[0], 0);
|
|
4900
|
+
let a = false;
|
|
4901
|
+
for (; o.size() > 0; ) {
|
|
4902
|
+
if (i = o.removeMin(), i in r5) t.setEdge(i, r5[i]);
|
|
4903
|
+
else {
|
|
4904
|
+
if (a) throw new Error("Input graph is not connected: " + e);
|
|
4905
|
+
a = true;
|
|
4906
|
+
}
|
|
4907
|
+
e.nodeEdges(i).forEach(s);
|
|
4908
|
+
}
|
|
4909
|
+
return t;
|
|
4799
4910
|
}
|
|
4800
|
-
function
|
|
4801
|
-
return n
|
|
4802
|
-
let i =
|
|
4803
|
-
return
|
|
4804
|
-
}
|
|
4911
|
+
function Sn(e, n, t, r5) {
|
|
4912
|
+
return Fn(e, n, t, r5 != null ? r5 : ((o) => {
|
|
4913
|
+
let i = e.outEdges(o);
|
|
4914
|
+
return i != null ? i : [];
|
|
4915
|
+
}));
|
|
4805
4916
|
}
|
|
4806
|
-
function
|
|
4807
|
-
|
|
4917
|
+
function Fn(e, n, t, r5) {
|
|
4918
|
+
if (t === void 0) return F(e, n, t, r5);
|
|
4919
|
+
let o = false, i = e.nodes();
|
|
4920
|
+
for (let s = 0; s < i.length; s++) {
|
|
4921
|
+
let a = r5(i[s]);
|
|
4922
|
+
for (let d = 0; d < a.length; d++) {
|
|
4923
|
+
let l = a[d], u = l.v === i[s] ? l.v : l.w, c = u === l.v ? l.w : l.v;
|
|
4924
|
+
t({ v: u, w: c }) < 0 && (o = true);
|
|
4925
|
+
}
|
|
4926
|
+
if (o) return we(e, n, t, r5);
|
|
4927
|
+
}
|
|
4928
|
+
return F(e, n, t, r5);
|
|
4808
4929
|
}
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
x.calcCutValue = We;
|
|
4814
|
-
x.leaveEdge = Ye;
|
|
4815
|
-
x.enterEdge = ze;
|
|
4816
|
-
x.exchangeEdges = He;
|
|
4817
|
-
function x(e) {
|
|
4818
|
-
e = xe(e), S(e);
|
|
4819
|
-
let n = V(e);
|
|
4820
|
-
ee(n), Z(n, e);
|
|
4821
|
-
let t, r5;
|
|
4822
|
-
for (; t = Ye(n); ) r5 = ze(n, e, t), He(n, e, t, r5);
|
|
4930
|
+
function w(e, n, t, r5) {
|
|
4931
|
+
let o = r5;
|
|
4932
|
+
for (; e.hasNode(o); ) o = j(r5);
|
|
4933
|
+
return t.dummy = n, e.setNode(o, t), o;
|
|
4823
4934
|
}
|
|
4824
|
-
function
|
|
4825
|
-
let
|
|
4826
|
-
t
|
|
4935
|
+
function xe(e) {
|
|
4936
|
+
let n = new p().setGraph(e.graph());
|
|
4937
|
+
return e.nodes().forEach((t) => n.setNode(t, e.node(t))), e.edges().forEach((t) => {
|
|
4938
|
+
let r5 = n.edge(t.v, t.w) || { weight: 0, minlen: 1 }, o = e.edge(t);
|
|
4939
|
+
n.setEdge(t.v, t.w, { weight: r5.weight + o.weight, minlen: Math.max(r5.minlen, o.minlen) });
|
|
4940
|
+
}), n;
|
|
4827
4941
|
}
|
|
4828
|
-
function
|
|
4829
|
-
let
|
|
4830
|
-
|
|
4942
|
+
function A(e) {
|
|
4943
|
+
let n = new p({ multigraph: e.isMultigraph() }).setGraph(e.graph());
|
|
4944
|
+
return e.nodes().forEach((t) => {
|
|
4945
|
+
e.children(t).length || n.setNode(t, e.node(t));
|
|
4946
|
+
}), e.edges().forEach((t) => {
|
|
4947
|
+
n.setEdge(t, e.edge(t));
|
|
4948
|
+
}), n;
|
|
4831
4949
|
}
|
|
4832
|
-
function
|
|
4833
|
-
let
|
|
4834
|
-
|
|
4835
|
-
let d
|
|
4836
|
-
return
|
|
4837
|
-
let u = l.v === t, c = u ? l.w : l.v;
|
|
4838
|
-
if (c !== o) {
|
|
4839
|
-
let h = u === i, f = n.edge(l).weight;
|
|
4840
|
-
if (a += h ? f : -f, rt(e, t, c)) {
|
|
4841
|
-
let b = e.edge(t, c).cutvalue;
|
|
4842
|
-
a += h ? -b : b;
|
|
4843
|
-
}
|
|
4844
|
-
}
|
|
4845
|
-
}), a;
|
|
4950
|
+
function H(e, n) {
|
|
4951
|
+
let t = e.x, r5 = e.y, o = n.x - t, i = n.y - r5, s = e.width / 2, a = e.height / 2;
|
|
4952
|
+
if (!o && !i) throw new Error("Not possible to find intersection inside of the rectangle");
|
|
4953
|
+
let d, l;
|
|
4954
|
+
return Math.abs(i) * s > Math.abs(o) * a ? (i < 0 && (a = -a), d = a * o / i, l = a) : (o < 0 && (s = -s), d = s, l = s * i / o), { x: t + d, y: r5 + l };
|
|
4846
4955
|
}
|
|
4847
|
-
function
|
|
4848
|
-
|
|
4956
|
+
function N(e) {
|
|
4957
|
+
let n = k(X(e) + 1).map(() => []);
|
|
4958
|
+
return e.nodes().forEach((t) => {
|
|
4959
|
+
let r5 = e.node(t), o = r5.rank;
|
|
4960
|
+
o !== void 0 && (n[o] || (n[o] = []), n[o][r5.order] = t);
|
|
4961
|
+
}), n;
|
|
4849
4962
|
}
|
|
4850
|
-
function
|
|
4851
|
-
let
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4963
|
+
function Te(e) {
|
|
4964
|
+
let n = e.nodes().map((r5) => {
|
|
4965
|
+
let o = e.node(r5).rank;
|
|
4966
|
+
return o === void 0 ? Number.MAX_VALUE : o;
|
|
4967
|
+
}), t = L(Math.min, n);
|
|
4968
|
+
e.nodes().forEach((r5) => {
|
|
4969
|
+
let o = e.node(r5);
|
|
4970
|
+
Object.hasOwn(o, "rank") && (o.rank -= t);
|
|
4971
|
+
});
|
|
4972
|
+
}
|
|
4973
|
+
function Oe(e) {
|
|
4974
|
+
let n = e.nodes().map((s) => e.node(s).rank).filter((s) => s !== void 0), t = L(Math.min, n), r5 = [];
|
|
4975
|
+
e.nodes().forEach((s) => {
|
|
4976
|
+
let a = e.node(s).rank - t;
|
|
4977
|
+
r5[a] || (r5[a] = []), r5[a].push(s);
|
|
4978
|
+
});
|
|
4979
|
+
let o = 0, i = e.graph().nodeRankFactor;
|
|
4980
|
+
Array.from(r5).forEach((s, a) => {
|
|
4981
|
+
s === void 0 && a % i !== 0 ? --o : s !== void 0 && o && s.forEach((d) => e.node(d).rank += o);
|
|
4982
|
+
});
|
|
4857
4983
|
}
|
|
4858
|
-
function
|
|
4859
|
-
|
|
4984
|
+
function q(e, n, t, r5) {
|
|
4985
|
+
let o = { width: 0, height: 0 };
|
|
4986
|
+
return arguments.length >= 4 && (o.rank = t, o.order = r5), w(e, "border", o, n);
|
|
4860
4987
|
}
|
|
4861
|
-
function
|
|
4862
|
-
let
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4988
|
+
function Dn(e, n = Ie) {
|
|
4989
|
+
let t = [];
|
|
4990
|
+
for (let r5 = 0; r5 < e.length; r5 += n) {
|
|
4991
|
+
let o = e.slice(r5, r5 + n);
|
|
4992
|
+
t.push(o);
|
|
4993
|
+
}
|
|
4994
|
+
return t;
|
|
4866
4995
|
}
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4996
|
+
var Ie = 65535;
|
|
4997
|
+
function L(e, n) {
|
|
4998
|
+
if (n.length > Ie) {
|
|
4999
|
+
let t = Dn(n);
|
|
5000
|
+
return e(...t.map((r5) => e(...r5)));
|
|
5001
|
+
} else return e(...n);
|
|
4870
5002
|
}
|
|
4871
|
-
function
|
|
4872
|
-
let t = e.nodes().
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
r5 = r5.slice(1), r5.forEach((o) => {
|
|
4876
|
-
let s = e.node(o).parent, a = n.edge(o, s), d = false;
|
|
4877
|
-
a || (a = n.edge(s, o), d = true), n.node(o).rank = n.node(s).rank + (d ? a.minlen : -a.minlen);
|
|
5003
|
+
function X(e) {
|
|
5004
|
+
let t = e.nodes().map((r5) => {
|
|
5005
|
+
let o = e.node(r5).rank;
|
|
5006
|
+
return o === void 0 ? Number.MIN_VALUE : o;
|
|
4878
5007
|
});
|
|
5008
|
+
return L(Math.max, t);
|
|
4879
5009
|
}
|
|
4880
|
-
function
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
5010
|
+
function Ce(e, n) {
|
|
5011
|
+
let t = { lhs: [], rhs: [] };
|
|
5012
|
+
return e.forEach((r5) => {
|
|
5013
|
+
n(r5) ? t.lhs.push(r5) : t.rhs.push(r5);
|
|
5014
|
+
}), t;
|
|
4885
5015
|
}
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
qe(e);
|
|
4893
|
-
break;
|
|
4894
|
-
case "tight-tree":
|
|
4895
|
-
st(e);
|
|
4896
|
-
break;
|
|
4897
|
-
case "longest-path":
|
|
4898
|
-
it(e);
|
|
4899
|
-
break;
|
|
4900
|
-
case "none":
|
|
4901
|
-
break;
|
|
4902
|
-
default:
|
|
4903
|
-
qe(e);
|
|
5016
|
+
function P(e, n) {
|
|
5017
|
+
let t = Date.now();
|
|
5018
|
+
try {
|
|
5019
|
+
return n();
|
|
5020
|
+
} finally {
|
|
5021
|
+
console.log(e + " time: " + (Date.now() - t) + "ms");
|
|
4904
5022
|
}
|
|
4905
5023
|
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
S(e), V(e);
|
|
5024
|
+
function M(e, n) {
|
|
5025
|
+
return n();
|
|
4909
5026
|
}
|
|
4910
|
-
|
|
4911
|
-
|
|
5027
|
+
var An = 0;
|
|
5028
|
+
function j(e) {
|
|
5029
|
+
let n = ++An;
|
|
5030
|
+
return e + ("" + n);
|
|
4912
5031
|
}
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
let
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
for (; (l = s[d]) !== a && e.node(l).maxRank < r5.rank; ) d++;
|
|
4921
|
-
l === a && (u = false);
|
|
4922
|
-
}
|
|
4923
|
-
if (!u) {
|
|
4924
|
-
for (; d < s.length - 1 && e.node(s[d + 1]).minRank <= r5.rank; ) d++;
|
|
4925
|
-
l = s[d];
|
|
4926
|
-
}
|
|
4927
|
-
l !== void 0 && e.setParent(t, l), t = e.successors(t)[0];
|
|
4928
|
-
}
|
|
4929
|
-
});
|
|
5032
|
+
function k(e, n, t = 1) {
|
|
5033
|
+
n == null && (n = e, e = 0);
|
|
5034
|
+
let r5 = (i) => i < n;
|
|
5035
|
+
t < 0 && (r5 = (i) => n < i);
|
|
5036
|
+
let o = [];
|
|
5037
|
+
for (let i = e; r5(i); i += t) o.push(i);
|
|
5038
|
+
return o;
|
|
4930
5039
|
}
|
|
4931
|
-
function
|
|
4932
|
-
let
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
d = e.parent(d), o.push(d);
|
|
4936
|
-
while (d && (n[d].low > s || a > n[d].lim));
|
|
4937
|
-
let l = d, u = r5;
|
|
4938
|
-
for (; (u = e.parent(u)) !== l; ) i.push(u);
|
|
4939
|
-
return { path: o.concat(i.reverse()), lca: l };
|
|
5040
|
+
function T(e, n) {
|
|
5041
|
+
let t = {};
|
|
5042
|
+
for (let r5 of n) e[r5] !== void 0 && (t[r5] = e[r5]);
|
|
5043
|
+
return t;
|
|
4940
5044
|
}
|
|
4941
|
-
function
|
|
4942
|
-
let
|
|
4943
|
-
|
|
4944
|
-
let i = t;
|
|
4945
|
-
e.children(o).forEach(r5), n[o] = { low: i, lim: t++ };
|
|
4946
|
-
}
|
|
4947
|
-
return e.children(_).forEach(r5), n;
|
|
5045
|
+
function O(e, n) {
|
|
5046
|
+
let t;
|
|
5047
|
+
return typeof n == "string" ? t = (r5) => r5[n] : t = n, Object.entries(e).reduce((r5, [o, i]) => (r5[o] = t(i, o), r5), {});
|
|
4948
5048
|
}
|
|
4949
|
-
function
|
|
4950
|
-
|
|
4951
|
-
e.graph().nestingRoot = n, e.edges().forEach((a) => e.edge(a).minlen *= i);
|
|
4952
|
-
let s = ct(e) + 1;
|
|
4953
|
-
e.children(_).forEach((a) => $e(e, n, i, s, o, t, a)), e.graph().nodeRankFactor = i;
|
|
5049
|
+
function Re(e, n) {
|
|
5050
|
+
return e.reduce((t, r5, o) => (t[r5] = n[o], t), {});
|
|
4954
5051
|
}
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
5052
|
+
var _ = "\0";
|
|
5053
|
+
var U = "3.0.0";
|
|
5054
|
+
var K = class {
|
|
5055
|
+
constructor() {
|
|
5056
|
+
pe(this, "_sentinel");
|
|
5057
|
+
let n = {};
|
|
5058
|
+
n._next = n._prev = n, this._sentinel = n;
|
|
4961
5059
|
}
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
$e(e, n, t, r5, o, i, h);
|
|
4966
|
-
let f = e.node(h), g = f.borderTop ? f.borderTop : h, b = f.borderBottom ? f.borderBottom : h, m = f.borderTop ? r5 : 2 * r5, E = g !== b ? 1 : o - ((y = i[s]) != null ? y : 0) + 1;
|
|
4967
|
-
e.setEdge(d, g, { weight: m, minlen: E, nestingEdge: true }), e.setEdge(b, l, { weight: m, minlen: E, nestingEdge: true });
|
|
4968
|
-
}), e.parent(s) || e.setEdge(n, d, { weight: 0, minlen: o + ((c = i[s]) != null ? c : 0) });
|
|
4969
|
-
}
|
|
4970
|
-
function ut(e) {
|
|
4971
|
-
let n = {};
|
|
4972
|
-
function t(r5, o) {
|
|
4973
|
-
let i = e.children(r5);
|
|
4974
|
-
i && i.length && i.forEach((s) => t(s, o + 1)), n[r5] = o;
|
|
5060
|
+
dequeue() {
|
|
5061
|
+
let n = this._sentinel, t = n._prev;
|
|
5062
|
+
if (t !== n) return Pe(t), t;
|
|
4975
5063
|
}
|
|
4976
|
-
|
|
5064
|
+
enqueue(n) {
|
|
5065
|
+
let t = this._sentinel;
|
|
5066
|
+
n._prev && n._next && Pe(n), n._next = t._next, t._next._prev = n, t._next = n, n._prev = t;
|
|
5067
|
+
}
|
|
5068
|
+
toString() {
|
|
5069
|
+
let n = [], t = this._sentinel, r5 = t._prev;
|
|
5070
|
+
for (; r5 !== t; ) n.push(JSON.stringify(r5, Vn)), r5 = r5._prev;
|
|
5071
|
+
return "[" + n.join(", ") + "]";
|
|
5072
|
+
}
|
|
5073
|
+
};
|
|
5074
|
+
function Pe(e) {
|
|
5075
|
+
e._prev._next = e._next, e._next._prev = e._prev, delete e._next, delete e._prev;
|
|
4977
5076
|
}
|
|
4978
|
-
function
|
|
4979
|
-
|
|
5077
|
+
function Vn(e, n) {
|
|
5078
|
+
if (e !== "_next" && e !== "_prev") return n;
|
|
4980
5079
|
}
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
5080
|
+
var Me = K;
|
|
5081
|
+
var Wn = () => 1;
|
|
5082
|
+
function Q(e, n) {
|
|
5083
|
+
if (e.nodeCount() <= 1) return [];
|
|
5084
|
+
let t = Yn(e, n || Wn);
|
|
5085
|
+
return Bn(t.graph, t.buckets, t.zeroIdx).flatMap((o) => e.outEdges(o.v, o.w) || []);
|
|
4986
5086
|
}
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
5087
|
+
function Bn(e, n, t) {
|
|
5088
|
+
var a;
|
|
5089
|
+
let r5 = [], o = n[n.length - 1], i = n[0], s;
|
|
5090
|
+
for (; e.nodeCount(); ) {
|
|
5091
|
+
for (; s = i.dequeue(); ) $(e, n, t, s);
|
|
5092
|
+
for (; s = o.dequeue(); ) $(e, n, t, s);
|
|
5093
|
+
if (e.nodeCount()) {
|
|
5094
|
+
for (let d = n.length - 2; d > 0; --d) if (s = (a = n[d]) == null ? void 0 : a.dequeue(), s) {
|
|
5095
|
+
r5 = r5.concat($(e, n, t, s, true) || []);
|
|
5096
|
+
break;
|
|
5097
|
+
}
|
|
4994
5098
|
}
|
|
4995
5099
|
}
|
|
4996
|
-
|
|
4997
|
-
}
|
|
4998
|
-
function Qe(e, n, t, r5, o, i) {
|
|
4999
|
-
let s = { width: 0, height: 0, rank: i, borderType: n }, a = o[n][i - 1], d = w(e, "border", s, t);
|
|
5000
|
-
o[n][i] = d, e.setParent(d, r5), a && e.setEdge(a, d, { weight: 1 });
|
|
5001
|
-
}
|
|
5002
|
-
function nn(e) {
|
|
5003
|
-
var t;
|
|
5004
|
-
let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
|
|
5005
|
-
(n === "lr" || n === "rl") && rn(e);
|
|
5006
|
-
}
|
|
5007
|
-
function tn(e) {
|
|
5008
|
-
var t;
|
|
5009
|
-
let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
|
|
5010
|
-
(n === "bt" || n === "rl") && bt(e), (n === "lr" || n === "rl") && (gt(e), rn(e));
|
|
5011
|
-
}
|
|
5012
|
-
function rn(e) {
|
|
5013
|
-
e.nodes().forEach((n) => en(e.node(n))), e.edges().forEach((n) => en(e.edge(n)));
|
|
5100
|
+
return r5;
|
|
5014
5101
|
}
|
|
5015
|
-
function
|
|
5016
|
-
let
|
|
5017
|
-
e.
|
|
5102
|
+
function $(e, n, t, r5, o) {
|
|
5103
|
+
let i = [], s = o ? i : void 0;
|
|
5104
|
+
return (e.inEdges(r5.v) || []).forEach((a) => {
|
|
5105
|
+
let d = e.edge(a), l = e.node(a.v);
|
|
5106
|
+
o && i.push({ v: a.v, w: a.w }), l.out -= d, J(n, t, l);
|
|
5107
|
+
}), (e.outEdges(r5.v) || []).forEach((a) => {
|
|
5108
|
+
let d = e.edge(a), l = a.w, u = e.node(l);
|
|
5109
|
+
u.in -= d, J(n, t, u);
|
|
5110
|
+
}), e.removeNode(r5.v), s;
|
|
5018
5111
|
}
|
|
5019
|
-
function
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5112
|
+
function Yn(e, n) {
|
|
5113
|
+
let t = new p(), r5 = 0, o = 0;
|
|
5114
|
+
e.nodes().forEach((a) => {
|
|
5115
|
+
t.setNode(a, { v: a, in: 0, out: 0 });
|
|
5116
|
+
}), e.edges().forEach((a) => {
|
|
5117
|
+
let d = t.edge(a.v, a.w) || 0, l = n(a), u = d + l;
|
|
5118
|
+
t.setEdge(a.v, a.w, u);
|
|
5119
|
+
let c = t.node(a.v), h = t.node(a.w);
|
|
5120
|
+
o = Math.max(o, c.out += l), r5 = Math.max(r5, h.in += l);
|
|
5024
5121
|
});
|
|
5122
|
+
let i = zn(o + r5 + 3).map(() => new Me()), s = r5 + 1;
|
|
5123
|
+
return t.nodes().forEach((a) => {
|
|
5124
|
+
J(i, s, t.node(a));
|
|
5125
|
+
}), { graph: t, buckets: i, zeroIdx: s };
|
|
5025
5126
|
}
|
|
5026
|
-
function
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
function gt(e) {
|
|
5030
|
-
e.nodes().forEach((n) => te(e.node(n))), e.edges().forEach((n) => {
|
|
5031
|
-
var r5;
|
|
5032
|
-
let t = e.edge(n);
|
|
5033
|
-
(r5 = t.points) == null || r5.forEach(te), Object.hasOwn(t, "x") && te(t);
|
|
5034
|
-
});
|
|
5127
|
+
function J(e, n, t) {
|
|
5128
|
+
var r5, o, i;
|
|
5129
|
+
t.out ? t.in ? (i = e[t.out - t.in + n]) == null || i.enqueue(t) : (o = e[e.length - 1]) == null || o.enqueue(t) : (r5 = e[0]) == null || r5.enqueue(t);
|
|
5035
5130
|
}
|
|
5036
|
-
function
|
|
5037
|
-
let n =
|
|
5038
|
-
|
|
5131
|
+
function zn(e) {
|
|
5132
|
+
let n = [];
|
|
5133
|
+
for (let t = 0; t < e; t++) n.push(t);
|
|
5134
|
+
return n;
|
|
5039
5135
|
}
|
|
5040
|
-
function
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
let u = e.successors(d);
|
|
5048
|
-
u && u.forEach(s);
|
|
5136
|
+
function je(e) {
|
|
5137
|
+
(e.graph().acyclicer === "greedy" ? Q(e, t(e)) : Hn(e)).forEach((r5) => {
|
|
5138
|
+
let o = e.edge(r5);
|
|
5139
|
+
e.removeEdge(r5), o.forwardName = r5.name, o.reversed = true, e.setEdge(r5.w, r5.v, o, j("rev"));
|
|
5140
|
+
});
|
|
5141
|
+
function t(r5) {
|
|
5142
|
+
return (o) => r5.edge(o).weight;
|
|
5049
5143
|
}
|
|
5050
|
-
return t.sort((d, l) => e.node(d).rank - e.node(l).rank).forEach(s), i;
|
|
5051
|
-
}
|
|
5052
|
-
function oe(e, n) {
|
|
5053
|
-
let t = 0;
|
|
5054
|
-
for (let r5 = 1; r5 < n.length; ++r5) t += mt(e, n[r5 - 1], n[r5]);
|
|
5055
|
-
return t;
|
|
5056
5144
|
}
|
|
5057
|
-
function
|
|
5058
|
-
let
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
let a = new Array(s).fill(0), d = 0;
|
|
5066
|
-
return o.forEach((l) => {
|
|
5067
|
-
let u = l.pos + i;
|
|
5068
|
-
a[u] += l.weight;
|
|
5069
|
-
let c = 0;
|
|
5070
|
-
for (; u > 0; ) u % 2 && (c += a[u + 1]), u = u - 1 >> 1, a[u] += l.weight;
|
|
5071
|
-
d += l.weight * c;
|
|
5072
|
-
}), d;
|
|
5145
|
+
function Hn(e) {
|
|
5146
|
+
let n = [], t = {}, r5 = {};
|
|
5147
|
+
function o(i) {
|
|
5148
|
+
Object.hasOwn(r5, i) || (r5[i] = true, t[i] = true, e.outEdges(i).forEach((s) => {
|
|
5149
|
+
Object.hasOwn(t, s.w) ? n.push(s) : o(s.w);
|
|
5150
|
+
}), delete t[i]);
|
|
5151
|
+
}
|
|
5152
|
+
return e.nodes().forEach(o), n;
|
|
5073
5153
|
}
|
|
5074
|
-
function
|
|
5075
|
-
|
|
5076
|
-
let
|
|
5077
|
-
if (
|
|
5078
|
-
|
|
5079
|
-
let
|
|
5080
|
-
|
|
5081
|
-
return { sum: i.sum + a.weight * d.order, weight: i.weight + a.weight };
|
|
5082
|
-
}, { sum: 0, weight: 0 });
|
|
5083
|
-
return { v: t, barycenter: o.sum / o.weight, weight: o.weight };
|
|
5154
|
+
function Se(e) {
|
|
5155
|
+
e.edges().forEach((n) => {
|
|
5156
|
+
let t = e.edge(n);
|
|
5157
|
+
if (t.reversed) {
|
|
5158
|
+
e.removeEdge(n);
|
|
5159
|
+
let r5 = t.forwardName;
|
|
5160
|
+
delete t.reversed, delete t.forwardName, e.setEdge(n.w, n.v, t, r5);
|
|
5084
5161
|
}
|
|
5085
5162
|
});
|
|
5086
5163
|
}
|
|
5087
|
-
function
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5164
|
+
function Fe(e) {
|
|
5165
|
+
e.graph().dummyChains = [], e.edges().forEach((n) => Xn(e, n));
|
|
5166
|
+
}
|
|
5167
|
+
function Xn(e, n) {
|
|
5168
|
+
let t = n.v, r5 = e.node(t).rank, o = n.w, i = e.node(o).rank, s = n.name, a = e.edge(n), d = a.labelRank;
|
|
5169
|
+
if (i === r5 + 1) return;
|
|
5170
|
+
e.removeEdge(n);
|
|
5171
|
+
let l, u, c;
|
|
5172
|
+
for (c = 0, ++r5; r5 < i; ++c, ++r5) a.points = [], u = { width: 0, height: 0, edgeLabel: a, edgeObj: n, rank: r5 }, l = w(e, "edge", u, "_d"), r5 === d && (u.width = a.width, u.height = a.height, u.dummy = "edge-label", u.labelpos = a.labelpos), e.setEdge(t, l, { weight: a.weight }, s), c === 0 && e.graph().dummyChains.push(l), t = l;
|
|
5173
|
+
e.setEdge(t, o, { weight: a.weight }, s);
|
|
5174
|
+
}
|
|
5175
|
+
function De(e) {
|
|
5176
|
+
e.graph().dummyChains.forEach((n) => {
|
|
5177
|
+
let t = e.node(n), r5 = t.edgeLabel, o;
|
|
5178
|
+
for (e.setEdge(t.edgeObj, r5); t.dummy; ) o = e.successors(n)[0], e.removeNode(n), r5.points.push({ x: t.x, y: t.y }), t.dummy === "edge-label" && (r5.x = t.x, r5.y = t.y, r5.width = t.width, r5.height = t.height), n = o, t = e.node(n);
|
|
5095
5179
|
});
|
|
5096
|
-
let r5 = Object.values(t).filter((o) => !o.indegree);
|
|
5097
|
-
return Et(r5);
|
|
5098
5180
|
}
|
|
5099
|
-
function
|
|
5100
|
-
let n =
|
|
5101
|
-
function t(
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
return (i) => {
|
|
5108
|
-
i.in.push(o), --i.indegree === 0 && e.push(i);
|
|
5109
|
-
};
|
|
5110
|
-
}
|
|
5111
|
-
for (; e.length; ) {
|
|
5112
|
-
let o = e.pop();
|
|
5113
|
-
n.push(o), o.in.reverse().forEach(t(o)), o.out.forEach(r5(o));
|
|
5181
|
+
function S(e) {
|
|
5182
|
+
let n = {};
|
|
5183
|
+
function t(r5) {
|
|
5184
|
+
let o = e.node(r5);
|
|
5185
|
+
if (Object.hasOwn(n, r5)) return o.rank;
|
|
5186
|
+
n[r5] = true;
|
|
5187
|
+
let i = e.outEdges(r5), s = i ? i.map((d) => d == null ? Number.POSITIVE_INFINITY : t(d.w) - e.edge(d).minlen) : [], a = L(Math.min, s);
|
|
5188
|
+
return a === Number.POSITIVE_INFINITY && (a = 0), o.rank = a;
|
|
5114
5189
|
}
|
|
5115
|
-
|
|
5190
|
+
e.sources().forEach(t);
|
|
5116
5191
|
}
|
|
5117
|
-
function
|
|
5118
|
-
|
|
5119
|
-
e.weight && (t += e.barycenter * e.weight, r5 += e.weight), n.weight && (t += n.barycenter * n.weight, r5 += n.weight), e.vs = n.vs.concat(e.vs), e.barycenter = t / r5, e.weight = r5, e.i = Math.min(n.i, e.i), n.merged = true;
|
|
5192
|
+
function v(e, n) {
|
|
5193
|
+
return e.node(n.w).rank - e.node(n.v).rank - e.edge(n).minlen;
|
|
5120
5194
|
}
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5195
|
+
var V = Kn;
|
|
5196
|
+
function Kn(e) {
|
|
5197
|
+
let n = new p({ directed: false }), t = e.nodes();
|
|
5198
|
+
if (t.length === 0) throw new Error("Graph must have at least one node");
|
|
5199
|
+
let r5 = t[0], o = e.nodeCount();
|
|
5200
|
+
n.setNode(r5, {});
|
|
5201
|
+
let i, s;
|
|
5202
|
+
for (; $n(n, e) < o && (i = Jn(n, e), !!i); ) s = n.hasNode(i.v) ? v(e, i) : -v(e, i), Qn(n, e, s);
|
|
5203
|
+
return n;
|
|
5128
5204
|
}
|
|
5129
|
-
function
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5205
|
+
function $n(e, n) {
|
|
5206
|
+
function t(r5) {
|
|
5207
|
+
let o = n.nodeEdges(r5);
|
|
5208
|
+
o && o.forEach((i) => {
|
|
5209
|
+
let s = i.v, a = r5 === s ? i.w : s;
|
|
5210
|
+
!e.hasNode(a) && !v(n, i) && (e.setNode(a, {}), e.setEdge(r5, a, {}), t(a));
|
|
5211
|
+
});
|
|
5212
|
+
}
|
|
5213
|
+
return e.nodes().forEach(t), e.nodeCount();
|
|
5133
5214
|
}
|
|
5134
|
-
function
|
|
5135
|
-
return (
|
|
5215
|
+
function Jn(e, n) {
|
|
5216
|
+
return n.edges().reduce((r5, o) => {
|
|
5217
|
+
let i = Number.POSITIVE_INFINITY;
|
|
5218
|
+
return e.hasNode(o.v) !== e.hasNode(o.w) && (i = v(n, o)), i < r5[0] ? [i, o] : r5;
|
|
5219
|
+
}, [Number.POSITIVE_INFINITY, null])[1];
|
|
5136
5220
|
}
|
|
5137
|
-
function
|
|
5138
|
-
|
|
5139
|
-
s && (o = o.filter((h) => h !== s && h !== a));
|
|
5140
|
-
let l = ie(e, o);
|
|
5141
|
-
l.forEach((h) => {
|
|
5142
|
-
if (e.children(h.v).length) {
|
|
5143
|
-
let f = W(e, h.v, t, r5);
|
|
5144
|
-
d[h.v] = f, Object.hasOwn(f, "barycenter") && Nt(h, f);
|
|
5145
|
-
}
|
|
5146
|
-
});
|
|
5147
|
-
let u = se(l, t);
|
|
5148
|
-
wt(u, d);
|
|
5149
|
-
let c = ae(u, r5);
|
|
5150
|
-
if (s && a) {
|
|
5151
|
-
c.vs = [s, c.vs, a].flat(1);
|
|
5152
|
-
let h = e.predecessors(s);
|
|
5153
|
-
if (h && h.length) {
|
|
5154
|
-
let f = e.node(h[0]), g = e.predecessors(a), b = e.node(g[0]);
|
|
5155
|
-
Object.hasOwn(c, "barycenter") || (c.barycenter = 0, c.weight = 0), c.barycenter = (c.barycenter * c.weight + f.order + b.order) / (c.weight + 2), c.weight += 2;
|
|
5156
|
-
}
|
|
5157
|
-
}
|
|
5158
|
-
return c;
|
|
5221
|
+
function Qn(e, n, t) {
|
|
5222
|
+
e.nodes().forEach((r5) => n.node(r5).rank += t);
|
|
5159
5223
|
}
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5224
|
+
var { preorder: Zn, postorder: et } = R;
|
|
5225
|
+
var Ve = x;
|
|
5226
|
+
x.initLowLimValues = ee;
|
|
5227
|
+
x.initCutValues = Z;
|
|
5228
|
+
x.calcCutValue = We;
|
|
5229
|
+
x.leaveEdge = Ye;
|
|
5230
|
+
x.enterEdge = ze;
|
|
5231
|
+
x.exchangeEdges = He;
|
|
5232
|
+
function x(e) {
|
|
5233
|
+
e = xe(e), S(e);
|
|
5234
|
+
let n = V(e);
|
|
5235
|
+
ee(n), Z(n, e);
|
|
5236
|
+
let t, r5;
|
|
5237
|
+
for (; t = Ye(n); ) r5 = ze(n, e, t), He(n, e, t, r5);
|
|
5164
5238
|
}
|
|
5165
|
-
function
|
|
5166
|
-
|
|
5239
|
+
function Z(e, n) {
|
|
5240
|
+
let t = et(e, e.nodes());
|
|
5241
|
+
t = t.slice(0, t.length - 1), t.forEach((r5) => nt(e, n, r5));
|
|
5167
5242
|
}
|
|
5168
|
-
function
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5243
|
+
function nt(e, n, t) {
|
|
5244
|
+
let o = e.node(t).parent, i = e.edge(t, o);
|
|
5245
|
+
i.cutvalue = We(e, n, t);
|
|
5246
|
+
}
|
|
5247
|
+
function We(e, n, t) {
|
|
5248
|
+
let o = e.node(t).parent, i = true, s = n.edge(t, o), a = 0;
|
|
5249
|
+
s || (i = false, s = n.edge(o, t)), a = s.weight;
|
|
5250
|
+
let d = n.nodeEdges(t);
|
|
5251
|
+
return d && d.forEach((l) => {
|
|
5252
|
+
let u = l.v === t, c = u ? l.w : l.v;
|
|
5253
|
+
if (c !== o) {
|
|
5254
|
+
let h = u === i, f = n.edge(l).weight;
|
|
5255
|
+
if (a += h ? f : -f, rt(e, t, c)) {
|
|
5256
|
+
let b = e.edge(t, c).cutvalue;
|
|
5257
|
+
a += h ? -b : b;
|
|
5258
|
+
}
|
|
5180
5259
|
}
|
|
5181
|
-
}),
|
|
5260
|
+
}), a;
|
|
5182
5261
|
}
|
|
5183
|
-
function
|
|
5184
|
-
|
|
5185
|
-
for (; e.hasNode(n = j("_root")); ) ;
|
|
5186
|
-
return n;
|
|
5262
|
+
function ee(e, n) {
|
|
5263
|
+
arguments.length < 2 && (n = e.nodes()[0]), Be(e, {}, 1, n);
|
|
5187
5264
|
}
|
|
5188
|
-
function
|
|
5189
|
-
let
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
return;
|
|
5196
|
-
}
|
|
5197
|
-
s = a;
|
|
5198
|
-
}
|
|
5199
|
-
});
|
|
5265
|
+
function Be(e, n, t, r5, o) {
|
|
5266
|
+
let i = t, s = e.node(r5);
|
|
5267
|
+
n[r5] = true;
|
|
5268
|
+
let a = e.neighbors(r5);
|
|
5269
|
+
return a && a.forEach((d) => {
|
|
5270
|
+
Object.hasOwn(n, d) || (t = Be(e, n, t, d, r5));
|
|
5271
|
+
}), s.low = i, s.lim = t++, o ? s.parent = o : delete s.parent, t;
|
|
5200
5272
|
}
|
|
5201
|
-
function
|
|
5202
|
-
|
|
5203
|
-
n.customOrder(e, B);
|
|
5204
|
-
return;
|
|
5205
|
-
}
|
|
5206
|
-
let t = X(e), r5 = sn(e, k(1, t + 1), "inEdges"), o = sn(e, k(t - 1, -1, -1), "outEdges"), i = re(e);
|
|
5207
|
-
if (an(e, i), n.disableOptimalOrderHeuristic) return;
|
|
5208
|
-
let s = Number.POSITIVE_INFINITY, a, d = n.constraints || [];
|
|
5209
|
-
for (let l = 0, u = 0; u < 4; ++l, ++u) {
|
|
5210
|
-
kt(l % 2 ? r5 : o, l % 4 >= 2, d), i = N(e);
|
|
5211
|
-
let c = oe(e, i);
|
|
5212
|
-
c < s ? (u = 0, a = Object.assign({}, i), s = c) : c === s && (a = structuredClone(i));
|
|
5213
|
-
}
|
|
5214
|
-
an(e, a);
|
|
5273
|
+
function Ye(e) {
|
|
5274
|
+
return e.edges().find((n) => e.edge(n).cutvalue < 0);
|
|
5215
5275
|
}
|
|
5216
|
-
function
|
|
5217
|
-
let r5 =
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
let s = e.node(i);
|
|
5222
|
-
if (typeof s.rank == "number" && o(s.rank, i), typeof s.minRank == "number" && typeof s.maxRank == "number") for (let a = s.minRank; a <= s.maxRank; a++) a !== s.rank && o(a, i);
|
|
5223
|
-
}
|
|
5224
|
-
return n.map(function(i) {
|
|
5225
|
-
return de(e, i, t, r5.get(i) || []);
|
|
5226
|
-
});
|
|
5276
|
+
function ze(e, n, t) {
|
|
5277
|
+
let r5 = t.v, o = t.w;
|
|
5278
|
+
n.hasEdge(r5, o) || (r5 = t.w, o = t.v);
|
|
5279
|
+
let i = e.node(r5), s = e.node(o), a = i, d = false;
|
|
5280
|
+
return i.lim > s.lim && (a = s, d = true), n.edges().filter((u) => d === Ae(e, e.node(u.v), a) && d !== Ae(e, e.node(u.w), a)).reduce((u, c) => v(n, c) < v(n, u) ? c : u);
|
|
5227
5281
|
}
|
|
5228
|
-
function
|
|
5229
|
-
let
|
|
5230
|
-
e.
|
|
5231
|
-
t.forEach((a) => r5.setEdge(a.left, a.right));
|
|
5232
|
-
let i = o.graph().root, s = W(o, i, r5, n);
|
|
5233
|
-
s.vs.forEach((a, d) => o.node(a).order = d), le(o, r5, s.vs);
|
|
5234
|
-
});
|
|
5282
|
+
function He(e, n, t, r5) {
|
|
5283
|
+
let o = t.v, i = t.w;
|
|
5284
|
+
e.removeEdge(o, i), e.setEdge(r5.v, r5.w, {}), ee(e), Z(e, n), tt(e, n);
|
|
5235
5285
|
}
|
|
5236
|
-
function
|
|
5237
|
-
|
|
5286
|
+
function tt(e, n) {
|
|
5287
|
+
let t = e.nodes().find((o) => !e.node(o).parent);
|
|
5288
|
+
if (!t) return;
|
|
5289
|
+
let r5 = Zn(e, [t]);
|
|
5290
|
+
r5 = r5.slice(1), r5.forEach((o) => {
|
|
5291
|
+
let s = e.node(o).parent, a = n.edge(o, s), d = false;
|
|
5292
|
+
a || (a = n.edge(s, o), d = true), n.node(o).rank = n.node(s).rank + (d ? a.minlen : -a.minlen);
|
|
5293
|
+
});
|
|
5238
5294
|
}
|
|
5239
|
-
function
|
|
5240
|
-
|
|
5241
|
-
function r5(o, i) {
|
|
5242
|
-
let s = 0, a = 0, d = o.length, l = i[i.length - 1];
|
|
5243
|
-
return i.forEach((u, c) => {
|
|
5244
|
-
let h = xt(e, u), f = h ? e.node(h).order : d;
|
|
5245
|
-
(h || u === l) && (i.slice(a, c + 1).forEach((g) => {
|
|
5246
|
-
let b = e.predecessors(g);
|
|
5247
|
-
b && b.forEach((m) => {
|
|
5248
|
-
let E = e.node(m), y = E.order;
|
|
5249
|
-
(y < s || f < y) && !(E.dummy && e.node(g).dummy) && dn(t, m, g);
|
|
5250
|
-
});
|
|
5251
|
-
}), a = c + 1, s = f);
|
|
5252
|
-
}), i;
|
|
5253
|
-
}
|
|
5254
|
-
return n.length && n.reduce(r5), t;
|
|
5295
|
+
function rt(e, n, t) {
|
|
5296
|
+
return e.hasEdge(n, t);
|
|
5255
5297
|
}
|
|
5256
|
-
function
|
|
5257
|
-
|
|
5258
|
-
function r5(i, s, a, d, l) {
|
|
5259
|
-
k(s, a).forEach((u) => {
|
|
5260
|
-
let c = i[u];
|
|
5261
|
-
if (c !== void 0 && e.node(c).dummy) {
|
|
5262
|
-
let h = e.predecessors(c);
|
|
5263
|
-
h && h.forEach((f) => {
|
|
5264
|
-
if (f === void 0) return;
|
|
5265
|
-
let g = e.node(f);
|
|
5266
|
-
g.dummy && (g.order < d || g.order > l) && dn(t, f, c);
|
|
5267
|
-
});
|
|
5268
|
-
}
|
|
5269
|
-
});
|
|
5270
|
-
}
|
|
5271
|
-
function o(i, s) {
|
|
5272
|
-
let a = -1, d = -1, l = 0;
|
|
5273
|
-
return s.forEach((u, c) => {
|
|
5274
|
-
if (e.node(u).dummy === "border") {
|
|
5275
|
-
let h = e.predecessors(u);
|
|
5276
|
-
if (h && h.length) {
|
|
5277
|
-
let f = h[0];
|
|
5278
|
-
if (f === void 0) return;
|
|
5279
|
-
d = e.node(f).order, r5(s, l, c, a, d), l = c, a = d;
|
|
5280
|
-
}
|
|
5281
|
-
}
|
|
5282
|
-
r5(s, l, s.length, d, i.length);
|
|
5283
|
-
}), s;
|
|
5284
|
-
}
|
|
5285
|
-
return n.length && n.reduce(o), t;
|
|
5298
|
+
function Ae(e, n, t) {
|
|
5299
|
+
return t.low <= n.lim && n.lim <= t.lim;
|
|
5286
5300
|
}
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5301
|
+
var Xe = ot;
|
|
5302
|
+
function ot(e) {
|
|
5303
|
+
let n = e.graph().ranker;
|
|
5304
|
+
if (typeof n == "function") return n(e);
|
|
5305
|
+
switch (n) {
|
|
5306
|
+
case "network-simplex":
|
|
5307
|
+
qe(e);
|
|
5308
|
+
break;
|
|
5309
|
+
case "tight-tree":
|
|
5310
|
+
st(e);
|
|
5311
|
+
break;
|
|
5312
|
+
case "longest-path":
|
|
5313
|
+
it(e);
|
|
5314
|
+
break;
|
|
5315
|
+
case "none":
|
|
5316
|
+
break;
|
|
5317
|
+
default:
|
|
5318
|
+
qe(e);
|
|
5291
5319
|
}
|
|
5292
5320
|
}
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
n = t, t = o;
|
|
5297
|
-
}
|
|
5298
|
-
let r5 = e[n];
|
|
5299
|
-
r5 || (e[n] = r5 = {}), r5[t] = true;
|
|
5321
|
+
var it = S;
|
|
5322
|
+
function st(e) {
|
|
5323
|
+
S(e), V(e);
|
|
5300
5324
|
}
|
|
5301
|
-
function
|
|
5302
|
-
|
|
5303
|
-
let o = n;
|
|
5304
|
-
n = t, t = o;
|
|
5305
|
-
}
|
|
5306
|
-
let r5 = e[n];
|
|
5307
|
-
return r5 !== void 0 && Object.hasOwn(r5, t);
|
|
5325
|
+
function qe(e) {
|
|
5326
|
+
Ve(e);
|
|
5308
5327
|
}
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
let u = r5(l);
|
|
5319
|
-
if (u && u.length) {
|
|
5320
|
-
let c = u.sort((f, g) => {
|
|
5321
|
-
let b = s[f], m = s[g];
|
|
5322
|
-
return (b !== void 0 ? b : 0) - (m !== void 0 ? m : 0);
|
|
5323
|
-
}), h = (c.length - 1) / 2;
|
|
5324
|
-
for (let f = Math.floor(h), g = Math.ceil(h); f <= g; ++f) {
|
|
5325
|
-
let b = c[f];
|
|
5326
|
-
if (b === void 0) continue;
|
|
5327
|
-
let m = s[b];
|
|
5328
|
-
if (m !== void 0 && i[l] === l && d < m && !Tt(t, l, b)) {
|
|
5329
|
-
let E = o[b];
|
|
5330
|
-
E !== void 0 && (i[b] = l, i[l] = o[l] = E, d = m);
|
|
5331
|
-
}
|
|
5332
|
-
}
|
|
5328
|
+
var Ue = at;
|
|
5329
|
+
function at(e) {
|
|
5330
|
+
let n = lt(e);
|
|
5331
|
+
e.graph().dummyChains.forEach((t) => {
|
|
5332
|
+
let r5 = e.node(t), o = r5.edgeObj, i = dt(e, n, o.v, o.w), s = i.path, a = i.lca, d = 0, l = s[d], u = true;
|
|
5333
|
+
for (; t !== o.w; ) {
|
|
5334
|
+
if (r5 = e.node(t), u) {
|
|
5335
|
+
for (; (l = s[d]) !== a && e.node(l).maxRank < r5.rank; ) d++;
|
|
5336
|
+
l === a && (u = false);
|
|
5333
5337
|
}
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
function It(e, n, t, r5, o = false) {
|
|
5338
|
-
let i = {}, s = Ct(e, n, t, o), a = o ? "borderLeft" : "borderRight";
|
|
5339
|
-
function d(f, g) {
|
|
5340
|
-
let b = s.nodes().slice(), m = {}, E = b.pop();
|
|
5341
|
-
for (; E; ) {
|
|
5342
|
-
if (m[E]) f(E);
|
|
5343
|
-
else {
|
|
5344
|
-
m[E] = true, b.push(E);
|
|
5345
|
-
for (let y of g(E)) b.push(y);
|
|
5338
|
+
if (!u) {
|
|
5339
|
+
for (; d < s.length - 1 && e.node(s[d + 1]).minRank <= r5.rank; ) d++;
|
|
5340
|
+
l = s[d];
|
|
5346
5341
|
}
|
|
5347
|
-
|
|
5342
|
+
l !== void 0 && e.setParent(t, l), t = e.successors(t)[0];
|
|
5348
5343
|
}
|
|
5344
|
+
});
|
|
5345
|
+
}
|
|
5346
|
+
function dt(e, n, t, r5) {
|
|
5347
|
+
let o = [], i = [], s = Math.min(n[t].low, n[r5].low), a = Math.max(n[t].lim, n[r5].lim), d;
|
|
5348
|
+
d = t;
|
|
5349
|
+
do
|
|
5350
|
+
d = e.parent(d), o.push(d);
|
|
5351
|
+
while (d && (n[d].low > s || a > n[d].lim));
|
|
5352
|
+
let l = d, u = r5;
|
|
5353
|
+
for (; (u = e.parent(u)) !== l; ) i.push(u);
|
|
5354
|
+
return { path: o.concat(i.reverse()), lca: l };
|
|
5355
|
+
}
|
|
5356
|
+
function lt(e) {
|
|
5357
|
+
let n = {}, t = 0;
|
|
5358
|
+
function r5(o) {
|
|
5359
|
+
let i = t;
|
|
5360
|
+
e.children(o).forEach(r5), n[o] = { low: i, lim: t++ };
|
|
5349
5361
|
}
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
let m = e.node(f);
|
|
5365
|
-
b !== Number.POSITIVE_INFINITY && m.borderType !== a && (i[f] = Math.max(i[f] !== void 0 ? i[f] : 0, b));
|
|
5366
|
-
}
|
|
5367
|
-
function c(f) {
|
|
5368
|
-
return s.predecessors(f) || [];
|
|
5369
|
-
}
|
|
5370
|
-
function h(f) {
|
|
5371
|
-
return s.successors(f) || [];
|
|
5362
|
+
return e.children(_).forEach(r5), n;
|
|
5363
|
+
}
|
|
5364
|
+
function Ke(e) {
|
|
5365
|
+
let n = w(e, "root", {}, "_root"), t = ut(e), r5 = Object.values(t), o = L(Math.max, r5) - 1, i = 2 * o + 1;
|
|
5366
|
+
e.graph().nestingRoot = n, e.edges().forEach((a) => e.edge(a).minlen *= i);
|
|
5367
|
+
let s = ct(e) + 1;
|
|
5368
|
+
e.children(_).forEach((a) => $e(e, n, i, s, o, t, a)), e.graph().nodeRankFactor = i;
|
|
5369
|
+
}
|
|
5370
|
+
function $e(e, n, t, r5, o, i, s) {
|
|
5371
|
+
var c;
|
|
5372
|
+
let a = e.children(s);
|
|
5373
|
+
if (!a.length) {
|
|
5374
|
+
s !== n && e.setEdge(n, s, { weight: 0, minlen: t });
|
|
5375
|
+
return;
|
|
5372
5376
|
}
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5377
|
+
let d = q(e, "_bt"), l = q(e, "_bb"), u = e.node(s);
|
|
5378
|
+
e.setParent(d, s), u.borderTop = d, e.setParent(l, s), u.borderBottom = l, a.forEach((h) => {
|
|
5379
|
+
var y;
|
|
5380
|
+
$e(e, n, t, r5, o, i, h);
|
|
5381
|
+
let f = e.node(h), g = f.borderTop ? f.borderTop : h, b = f.borderBottom ? f.borderBottom : h, m = f.borderTop ? r5 : 2 * r5, E = g !== b ? 1 : o - ((y = i[s]) != null ? y : 0) + 1;
|
|
5382
|
+
e.setEdge(d, g, { weight: m, minlen: E, nestingEdge: true }), e.setEdge(b, l, { weight: m, minlen: E, nestingEdge: true });
|
|
5383
|
+
}), e.parent(s) || e.setEdge(n, d, { weight: 0, minlen: o + ((c = i[s]) != null ? c : 0) });
|
|
5378
5384
|
}
|
|
5379
|
-
function
|
|
5380
|
-
let
|
|
5381
|
-
|
|
5382
|
-
let
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
if (o.setNode(u), d !== void 0) {
|
|
5387
|
-
let c = t[d];
|
|
5388
|
-
if (c !== void 0) {
|
|
5389
|
-
let h = o.edge(c, u);
|
|
5390
|
-
o.setEdge(c, u, Math.max(s(e, l, d), h || 0));
|
|
5391
|
-
}
|
|
5392
|
-
}
|
|
5393
|
-
d = l;
|
|
5394
|
-
}
|
|
5395
|
-
});
|
|
5396
|
-
}), o;
|
|
5385
|
+
function ut(e) {
|
|
5386
|
+
let n = {};
|
|
5387
|
+
function t(r5, o) {
|
|
5388
|
+
let i = e.children(r5);
|
|
5389
|
+
i && i.length && i.forEach((s) => t(s, o + 1)), n[r5] = o;
|
|
5390
|
+
}
|
|
5391
|
+
return e.children(_).forEach((r5) => t(r5, 1)), n;
|
|
5397
5392
|
}
|
|
5398
|
-
function
|
|
5399
|
-
return
|
|
5400
|
-
let o = Number.NEGATIVE_INFINITY, i = Number.POSITIVE_INFINITY;
|
|
5401
|
-
Object.entries(r5).forEach(([a, d]) => {
|
|
5402
|
-
let l = St(e, a) / 2;
|
|
5403
|
-
o = Math.max(d + l, o), i = Math.min(d - l, i);
|
|
5404
|
-
});
|
|
5405
|
-
let s = o - i;
|
|
5406
|
-
return s < t[0] && (t = [s, r5]), t;
|
|
5407
|
-
}, [Number.POSITIVE_INFINITY, null])[1];
|
|
5393
|
+
function ct(e) {
|
|
5394
|
+
return e.edges().reduce((n, t) => n + e.edge(t).weight, 0);
|
|
5408
5395
|
}
|
|
5409
|
-
function
|
|
5410
|
-
let
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
let a = i + s, d = e[a];
|
|
5414
|
-
if (!d || d === n) return;
|
|
5415
|
-
let l = Object.values(d), u = r5 - L(Math.min, l);
|
|
5416
|
-
s !== "l" && (u = o - L(Math.max, l)), u && (e[a] = O(d, (c) => c + u));
|
|
5417
|
-
});
|
|
5396
|
+
function Je(e) {
|
|
5397
|
+
let n = e.graph();
|
|
5398
|
+
e.removeNode(n.nestingRoot), delete n.nestingRoot, e.edges().forEach((t) => {
|
|
5399
|
+
e.edge(t).nestingEdge && e.removeEdge(t);
|
|
5418
5400
|
});
|
|
5419
5401
|
}
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
if (n) {
|
|
5425
|
-
|
|
5426
|
-
|
|
5402
|
+
var Ze = ft;
|
|
5403
|
+
function ft(e) {
|
|
5404
|
+
function n(t) {
|
|
5405
|
+
let r5 = e.children(t), o = e.node(t);
|
|
5406
|
+
if (r5.length && r5.forEach(n), Object.hasOwn(o, "minRank")) {
|
|
5407
|
+
o.borderLeft = [], o.borderRight = [];
|
|
5408
|
+
for (let i = o.minRank, s = o.maxRank + 1; i < s; ++i) Qe(e, "borderLeft", "_bl", t, o, i), Qe(e, "borderRight", "_br", t, o, i);
|
|
5427
5409
|
}
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
return l !== void 0 ? l : 0;
|
|
5431
|
-
}).sort((d, l) => d - l);
|
|
5432
|
-
return (((s = i[1]) != null ? s : 0) + ((a = i[2]) != null ? a : 0)) / 2;
|
|
5433
|
-
}) : {};
|
|
5410
|
+
}
|
|
5411
|
+
e.children(_).forEach(n);
|
|
5434
5412
|
}
|
|
5435
|
-
function
|
|
5436
|
-
let
|
|
5437
|
-
[
|
|
5438
|
-
o = s === "u" ? n : Object.values(n).reverse(), ["l", "r"].forEach((a) => {
|
|
5439
|
-
a === "r" && (o = o.map((c) => Object.values(c).reverse()));
|
|
5440
|
-
let l = Ot(e, o, t, (c) => (s === "u" ? e.predecessors(c) : e.successors(c)) || []), u = It(e, o, l.root, l.align, a === "r");
|
|
5441
|
-
a === "r" && (u = O(u, (c) => -c)), r5[s + a] = u;
|
|
5442
|
-
});
|
|
5443
|
-
});
|
|
5444
|
-
let i = Rt(e, r5);
|
|
5445
|
-
return Pt(r5, i), Mt(r5, e.graph().align);
|
|
5413
|
+
function Qe(e, n, t, r5, o, i) {
|
|
5414
|
+
let s = { width: 0, height: 0, rank: i, borderType: n }, a = o[n][i - 1], d = w(e, "border", s, t);
|
|
5415
|
+
o[n][i] = d, e.setParent(d, r5), a && e.setEdge(a, d, { weight: 1 });
|
|
5446
5416
|
}
|
|
5447
|
-
function
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
case "l":
|
|
5452
|
-
l = -s.width / 2;
|
|
5453
|
-
break;
|
|
5454
|
-
case "r":
|
|
5455
|
-
l = s.width / 2;
|
|
5456
|
-
break;
|
|
5457
|
-
}
|
|
5458
|
-
if (l && (d += t ? l : -l), l = void 0, d += (s.dummy ? n : e) / 2, d += (a.dummy ? n : e) / 2, d += a.width / 2, Object.hasOwn(a, "labelpos")) switch (a.labelpos.toLowerCase()) {
|
|
5459
|
-
case "l":
|
|
5460
|
-
l = a.width / 2;
|
|
5461
|
-
break;
|
|
5462
|
-
case "r":
|
|
5463
|
-
l = -a.width / 2;
|
|
5464
|
-
break;
|
|
5465
|
-
}
|
|
5466
|
-
return l && (d += t ? l : -l), d;
|
|
5467
|
-
};
|
|
5417
|
+
function nn(e) {
|
|
5418
|
+
var t;
|
|
5419
|
+
let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
|
|
5420
|
+
(n === "lr" || n === "rl") && rn(e);
|
|
5468
5421
|
}
|
|
5469
|
-
function
|
|
5470
|
-
|
|
5422
|
+
function tn(e) {
|
|
5423
|
+
var t;
|
|
5424
|
+
let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
|
|
5425
|
+
(n === "bt" || n === "rl") && bt(e), (n === "lr" || n === "rl") && (gt(e), rn(e));
|
|
5471
5426
|
}
|
|
5472
|
-
function
|
|
5473
|
-
e
|
|
5427
|
+
function rn(e) {
|
|
5428
|
+
e.nodes().forEach((n) => en(e.node(n))), e.edges().forEach((n) => en(e.edge(n)));
|
|
5474
5429
|
}
|
|
5475
|
-
function
|
|
5476
|
-
let n =
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
let l = e.node(d);
|
|
5485
|
-
o === "top" ? l.y = i + l.height / 2 : o === "bottom" ? l.y = i + a - l.height / 2 : l.y = i + a / 2;
|
|
5486
|
-
}), i += a + r5;
|
|
5430
|
+
function en(e) {
|
|
5431
|
+
let n = e.width;
|
|
5432
|
+
e.width = e.height, e.height = n;
|
|
5433
|
+
}
|
|
5434
|
+
function bt(e) {
|
|
5435
|
+
e.nodes().forEach((n) => ne(e.node(n))), e.edges().forEach((n) => {
|
|
5436
|
+
var r5;
|
|
5437
|
+
let t = e.edge(n);
|
|
5438
|
+
(r5 = t.points) == null || r5.forEach(ne), Object.hasOwn(t, "y") && ne(t);
|
|
5487
5439
|
});
|
|
5488
5440
|
}
|
|
5489
|
-
function
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5441
|
+
function ne(e) {
|
|
5442
|
+
e.y = -e.y;
|
|
5443
|
+
}
|
|
5444
|
+
function gt(e) {
|
|
5445
|
+
e.nodes().forEach((n) => te(e.node(n))), e.edges().forEach((n) => {
|
|
5446
|
+
var r5;
|
|
5447
|
+
let t = e.edge(n);
|
|
5448
|
+
(r5 = t.points) == null || r5.forEach(te), Object.hasOwn(t, "x") && te(t);
|
|
5494
5449
|
});
|
|
5495
5450
|
}
|
|
5496
|
-
function
|
|
5497
|
-
|
|
5451
|
+
function te(e) {
|
|
5452
|
+
let n = e.x;
|
|
5453
|
+
e.x = e.y, e.y = n;
|
|
5498
5454
|
}
|
|
5499
|
-
function
|
|
5500
|
-
e.nodes().
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
let
|
|
5505
|
-
|
|
5506
|
-
|
|
5455
|
+
function re(e) {
|
|
5456
|
+
let n = {}, t = e.nodes().filter((d) => !e.children(d).length), r5 = t.map((d) => e.node(d).rank), o = L(Math.max, r5), i = k(o + 1).map(() => []);
|
|
5457
|
+
function s(d) {
|
|
5458
|
+
if (n[d]) return;
|
|
5459
|
+
n[d] = true;
|
|
5460
|
+
let l = e.node(d);
|
|
5461
|
+
i[l.rank].push(d);
|
|
5462
|
+
let u = e.successors(d);
|
|
5463
|
+
u && u.forEach(s);
|
|
5464
|
+
}
|
|
5465
|
+
return t.sort((d, l) => e.node(d).rank - e.node(l).rank).forEach(s), i;
|
|
5507
5466
|
}
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
var cn = { width: 0, height: 0 };
|
|
5513
|
-
var zt = ["minlen", "weight", "width", "height", "labeloffset"];
|
|
5514
|
-
var Ht = { minlen: 1, weight: 1, width: 0, height: 0, labeloffset: 10, labelpos: "r" };
|
|
5515
|
-
var qt = ["labelpos"];
|
|
5516
|
-
function Xt(e) {
|
|
5517
|
-
let n = new p({ multigraph: true, compound: true }), t = ce(e.graph());
|
|
5518
|
-
return n.setGraph(Object.assign({}, Wt, ue(t, Vt), T(t, Bt))), e.nodes().forEach((r5) => {
|
|
5519
|
-
let o = ce(e.node(r5)), i = ue(o, Yt);
|
|
5520
|
-
Object.keys(cn).forEach((a) => {
|
|
5521
|
-
i[a] === void 0 && (i[a] = cn[a]);
|
|
5522
|
-
}), n.setNode(r5, i);
|
|
5523
|
-
let s = e.parent(r5);
|
|
5524
|
-
s !== void 0 && n.setParent(r5, s);
|
|
5525
|
-
}), e.edges().forEach((r5) => {
|
|
5526
|
-
let o = ce(e.edge(r5));
|
|
5527
|
-
n.setEdge(r5, Object.assign({}, Ht, ue(o, zt), T(o, qt)));
|
|
5528
|
-
}), n;
|
|
5467
|
+
function oe(e, n) {
|
|
5468
|
+
let t = 0;
|
|
5469
|
+
for (let r5 = 1; r5 < n.length; ++r5) t += mt(e, n[r5 - 1], n[r5]);
|
|
5470
|
+
return t;
|
|
5529
5471
|
}
|
|
5530
|
-
function
|
|
5531
|
-
let
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5472
|
+
function mt(e, n, t) {
|
|
5473
|
+
let r5 = Re(t, t.map((l, u) => u)), o = n.flatMap((l) => {
|
|
5474
|
+
let u = e.outEdges(l);
|
|
5475
|
+
return u ? u.map((c) => ({ pos: r5[c.w], weight: e.edge(c).weight })).sort((c, h) => c.pos - h.pos) : [];
|
|
5476
|
+
}), i = 1;
|
|
5477
|
+
for (; i < t.length; ) i <<= 1;
|
|
5478
|
+
let s = 2 * i - 1;
|
|
5479
|
+
i -= 1;
|
|
5480
|
+
let a = new Array(s).fill(0), d = 0;
|
|
5481
|
+
return o.forEach((l) => {
|
|
5482
|
+
let u = l.pos + i;
|
|
5483
|
+
a[u] += l.weight;
|
|
5484
|
+
let c = 0;
|
|
5485
|
+
for (; u > 0; ) u % 2 && (c += a[u + 1]), u = u - 1 >> 1, a[u] += l.weight;
|
|
5486
|
+
d += l.weight * c;
|
|
5487
|
+
}), d;
|
|
5536
5488
|
}
|
|
5537
|
-
function
|
|
5538
|
-
|
|
5539
|
-
let
|
|
5540
|
-
if (
|
|
5541
|
-
|
|
5542
|
-
|
|
5489
|
+
function ie(e, n = []) {
|
|
5490
|
+
return n.map((t) => {
|
|
5491
|
+
let r5 = e.inEdges(t);
|
|
5492
|
+
if (!r5 || !r5.length) return { v: t };
|
|
5493
|
+
{
|
|
5494
|
+
let o = r5.reduce((i, s) => {
|
|
5495
|
+
let a = e.edge(s), d = e.node(s.v);
|
|
5496
|
+
return { sum: i.sum + a.weight * d.order, weight: i.weight + a.weight };
|
|
5497
|
+
}, { sum: 0, weight: 0 });
|
|
5498
|
+
return { v: t, barycenter: o.sum / o.weight, weight: o.weight };
|
|
5543
5499
|
}
|
|
5544
5500
|
});
|
|
5545
5501
|
}
|
|
5546
|
-
function
|
|
5547
|
-
let
|
|
5548
|
-
e.
|
|
5549
|
-
let
|
|
5550
|
-
|
|
5551
|
-
}),
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
e.nodes().forEach((n) => {
|
|
5555
|
-
let t = e.node(n);
|
|
5556
|
-
if (t.dummy === "edge-proxy") {
|
|
5557
|
-
let r5 = t;
|
|
5558
|
-
e.edge(r5.e).labelRank = t.rank, e.removeNode(n);
|
|
5559
|
-
}
|
|
5502
|
+
function se(e, n) {
|
|
5503
|
+
let t = {};
|
|
5504
|
+
e.forEach((o, i) => {
|
|
5505
|
+
let s = { indegree: 0, in: [], out: [], vs: [o.v], i };
|
|
5506
|
+
o.barycenter !== void 0 && (s.barycenter = o.barycenter, s.weight = o.weight), t[o.v] = s;
|
|
5507
|
+
}), n.edges().forEach((o) => {
|
|
5508
|
+
let i = t[o.v], s = t[o.w];
|
|
5509
|
+
i !== void 0 && s !== void 0 && (s.indegree++, i.out.push(s));
|
|
5560
5510
|
});
|
|
5511
|
+
let r5 = Object.values(t).filter((o) => !o.indegree);
|
|
5512
|
+
return Et(r5);
|
|
5561
5513
|
}
|
|
5562
|
-
function
|
|
5563
|
-
let n =
|
|
5564
|
-
function
|
|
5565
|
-
|
|
5566
|
-
|
|
5514
|
+
function Et(e) {
|
|
5515
|
+
let n = [];
|
|
5516
|
+
function t(o) {
|
|
5517
|
+
return (i) => {
|
|
5518
|
+
i.merged || (i.barycenter === void 0 || o.barycenter === void 0 || i.barycenter >= o.barycenter) && Lt(o, i);
|
|
5519
|
+
};
|
|
5567
5520
|
}
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
}), Object.hasOwn(u, "x") && (u.x -= n), Object.hasOwn(u, "y") && (u.y -= r5);
|
|
5579
|
-
}), i.width = t - n + s, i.height = o - r5 + a;
|
|
5521
|
+
function r5(o) {
|
|
5522
|
+
return (i) => {
|
|
5523
|
+
i.in.push(o), --i.indegree === 0 && e.push(i);
|
|
5524
|
+
};
|
|
5525
|
+
}
|
|
5526
|
+
for (; e.length; ) {
|
|
5527
|
+
let o = e.pop();
|
|
5528
|
+
n.push(o), o.in.reverse().forEach(t(o)), o.out.forEach(r5(o));
|
|
5529
|
+
}
|
|
5530
|
+
return n.filter((o) => !o.merged).map((o) => T(o, ["vs", "i", "barycenter", "weight"]));
|
|
5580
5531
|
}
|
|
5581
|
-
function
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
t.points ? (i = t.points[0], s = t.points[t.points.length - 1]) : (t.points = [], i = o, s = r5), t.points.unshift(H(r5, i)), t.points.push(H(o, s));
|
|
5585
|
-
});
|
|
5532
|
+
function Lt(e, n) {
|
|
5533
|
+
let t = 0, r5 = 0;
|
|
5534
|
+
e.weight && (t += e.barycenter * e.weight, r5 += e.weight), n.weight && (t += n.barycenter * n.weight, r5 += n.weight), e.vs = n.vs.concat(e.vs), e.barycenter = t / r5, e.weight = r5, e.i = Math.min(n.i, e.i), n.merged = true;
|
|
5586
5535
|
}
|
|
5587
|
-
function
|
|
5588
|
-
e.
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
case "l":
|
|
5592
|
-
t.x -= t.width / 2 + t.labeloffset;
|
|
5593
|
-
break;
|
|
5594
|
-
case "r":
|
|
5595
|
-
t.x += t.width / 2 + t.labeloffset;
|
|
5596
|
-
break;
|
|
5597
|
-
}
|
|
5536
|
+
function ae(e, n) {
|
|
5537
|
+
let t = Ce(e, (u) => Object.hasOwn(u, "barycenter")), r5 = t.lhs, o = t.rhs.sort((u, c) => c.i - u.i), i = [], s = 0, a = 0, d = 0;
|
|
5538
|
+
r5.sort(yt(!!n)), d = on(i, o, d), r5.forEach((u) => {
|
|
5539
|
+
d += u.vs.length, i.push(u.vs), s += u.barycenter * u.weight, a += u.weight, d = on(i, o, d);
|
|
5598
5540
|
});
|
|
5541
|
+
let l = { vs: i.flat(1) };
|
|
5542
|
+
return a && (l.barycenter = s / a, l.weight = a), l;
|
|
5599
5543
|
}
|
|
5600
|
-
function
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
});
|
|
5544
|
+
function on(e, n, t) {
|
|
5545
|
+
let r5;
|
|
5546
|
+
for (; n.length && (r5 = n[n.length - 1]).i <= t; ) n.pop(), e.push(r5.vs), t++;
|
|
5547
|
+
return t;
|
|
5605
5548
|
}
|
|
5606
|
-
function
|
|
5607
|
-
|
|
5608
|
-
if (e.children(n).length) {
|
|
5609
|
-
let t = e.node(n), r5 = e.node(t.borderTop), o = e.node(t.borderBottom), i = e.node(t.borderLeft[t.borderLeft.length - 1]), s = e.node(t.borderRight[t.borderRight.length - 1]);
|
|
5610
|
-
t.width = Math.abs(s.x - i.x), t.height = Math.abs(o.y - r5.y), t.x = i.x + t.width / 2, t.y = r5.y + t.height / 2;
|
|
5611
|
-
}
|
|
5612
|
-
}), e.nodes().forEach((n) => {
|
|
5613
|
-
e.node(n).dummy === "border" && e.removeNode(n);
|
|
5614
|
-
});
|
|
5549
|
+
function yt(e) {
|
|
5550
|
+
return (n, t) => n.barycenter < t.barycenter ? -1 : n.barycenter > t.barycenter ? 1 : e ? t.i - n.i : n.i - t.i;
|
|
5615
5551
|
}
|
|
5616
|
-
function
|
|
5617
|
-
e.
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5552
|
+
function W(e, n, t, r5) {
|
|
5553
|
+
let o = e.children(n), i = e.node(n), s = i ? i.borderLeft : void 0, a = i ? i.borderRight : void 0, d = {};
|
|
5554
|
+
s && (o = o.filter((h) => h !== s && h !== a));
|
|
5555
|
+
let l = ie(e, o);
|
|
5556
|
+
l.forEach((h) => {
|
|
5557
|
+
if (e.children(h.v).length) {
|
|
5558
|
+
let f = W(e, h.v, t, r5);
|
|
5559
|
+
d[h.v] = f, Object.hasOwn(f, "barycenter") && Nt(h, f);
|
|
5621
5560
|
}
|
|
5622
5561
|
});
|
|
5562
|
+
let u = se(l, t);
|
|
5563
|
+
wt(u, d);
|
|
5564
|
+
let c = ae(u, r5);
|
|
5565
|
+
if (s && a) {
|
|
5566
|
+
c.vs = [s, c.vs, a].flat(1);
|
|
5567
|
+
let h = e.predecessors(s);
|
|
5568
|
+
if (h && h.length) {
|
|
5569
|
+
let f = e.node(h[0]), g = e.predecessors(a), b = e.node(g[0]);
|
|
5570
|
+
Object.hasOwn(c, "barycenter") || (c.barycenter = 0, c.weight = 0), c.barycenter = (c.barycenter * c.weight + f.order + b.order) / (c.weight + 2), c.weight += 2;
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5573
|
+
return c;
|
|
5623
5574
|
}
|
|
5624
|
-
function
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
t.forEach((o, i) => {
|
|
5628
|
-
let s = e.node(o);
|
|
5629
|
-
s.order = i + r5, (s.selfEdges || []).forEach((a) => {
|
|
5630
|
-
w(e, "selfedge", { width: a.label.width, height: a.label.height, rank: s.rank, order: i + ++r5, e: a.e, label: a.label }, "_se");
|
|
5631
|
-
}), delete s.selfEdges;
|
|
5632
|
-
});
|
|
5575
|
+
function wt(e, n) {
|
|
5576
|
+
e.forEach((t) => {
|
|
5577
|
+
t.vs = t.vs.flatMap((r5) => n[r5] ? n[r5].vs : r5);
|
|
5633
5578
|
});
|
|
5634
5579
|
}
|
|
5635
|
-
function
|
|
5636
|
-
e.
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5580
|
+
function Nt(e, n) {
|
|
5581
|
+
e.barycenter !== void 0 ? (e.barycenter = (e.barycenter * e.weight + n.barycenter * n.weight) / (e.weight + n.weight), e.weight += n.weight) : (e.barycenter = n.barycenter, e.weight = n.weight);
|
|
5582
|
+
}
|
|
5583
|
+
function de(e, n, t, r5) {
|
|
5584
|
+
r5 || (r5 = e.nodes());
|
|
5585
|
+
let o = Gt(e), i = new p({ compound: true }).setGraph({ root: o }).setDefaultNodeLabel((s) => e.node(s));
|
|
5586
|
+
return r5.forEach((s) => {
|
|
5587
|
+
let a = e.node(s), d = e.parent(s);
|
|
5588
|
+
if (a.rank === n || a.minRank <= n && n <= a.maxRank) {
|
|
5589
|
+
i.setNode(s), i.setParent(s, d || o);
|
|
5590
|
+
let l = e[t](s);
|
|
5591
|
+
l && l.forEach((u) => {
|
|
5592
|
+
let c = u.v === s ? u.w : u.v, h = i.edge(c, s), f = h !== void 0 ? h.weight : 0;
|
|
5593
|
+
i.setEdge(c, s, { weight: e.edge(u).weight + f });
|
|
5594
|
+
}), Object.hasOwn(a, "minRank") && i.setNode(s, { borderLeft: a.borderLeft[n], borderRight: a.borderRight[n] });
|
|
5641
5595
|
}
|
|
5642
|
-
});
|
|
5596
|
+
}), i;
|
|
5643
5597
|
}
|
|
5644
|
-
function
|
|
5645
|
-
|
|
5598
|
+
function Gt(e) {
|
|
5599
|
+
let n;
|
|
5600
|
+
for (; e.hasNode(n = j("_root")); ) ;
|
|
5601
|
+
return n;
|
|
5646
5602
|
}
|
|
5647
|
-
function
|
|
5648
|
-
let
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5603
|
+
function le(e, n, t) {
|
|
5604
|
+
let r5 = {}, o;
|
|
5605
|
+
t.forEach((i) => {
|
|
5606
|
+
let s = e.parent(i), a, d;
|
|
5607
|
+
for (; s; ) {
|
|
5608
|
+
if (a = e.parent(s), a ? (d = r5[a], r5[a] = s) : (d = o, o = s), d && d !== s) {
|
|
5609
|
+
n.setEdge(d, s);
|
|
5610
|
+
return;
|
|
5611
|
+
}
|
|
5612
|
+
s = a;
|
|
5613
|
+
}
|
|
5614
|
+
});
|
|
5652
5615
|
}
|
|
5653
|
-
function
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
}
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5616
|
+
function B(e, n = {}) {
|
|
5617
|
+
if (typeof n.customOrder == "function") {
|
|
5618
|
+
n.customOrder(e, B);
|
|
5619
|
+
return;
|
|
5620
|
+
}
|
|
5621
|
+
let t = X(e), r5 = sn(e, k(1, t + 1), "inEdges"), o = sn(e, k(t - 1, -1, -1), "outEdges"), i = re(e);
|
|
5622
|
+
if (an(e, i), n.disableOptimalOrderHeuristic) return;
|
|
5623
|
+
let s = Number.POSITIVE_INFINITY, a, d = n.constraints || [];
|
|
5624
|
+
for (let l = 0, u = 0; u < 4; ++l, ++u) {
|
|
5625
|
+
kt(l % 2 ? r5 : o, l % 4 >= 2, d), i = N(e);
|
|
5626
|
+
let c = oe(e, i);
|
|
5627
|
+
c < s ? (u = 0, a = Object.assign({}, i), s = c) : c === s && (a = structuredClone(i));
|
|
5628
|
+
}
|
|
5629
|
+
an(e, a);
|
|
5661
5630
|
}
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
return items.map((n) => ({ ...n, col: n.col, row: n.row }));
|
|
5631
|
+
function sn(e, n, t) {
|
|
5632
|
+
let r5 = /* @__PURE__ */ new Map(), o = (i, s) => {
|
|
5633
|
+
r5.has(i) || r5.set(i, []), r5.get(i).push(s);
|
|
5634
|
+
};
|
|
5635
|
+
for (let i of e.nodes()) {
|
|
5636
|
+
let s = e.node(i);
|
|
5637
|
+
if (typeof s.rank == "number" && o(s.rank, i), typeof s.minRank == "number" && typeof s.maxRank == "number") for (let a = s.minRank; a <= s.maxRank; a++) a !== s.rank && o(a, i);
|
|
5670
5638
|
}
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5639
|
+
return n.map(function(i) {
|
|
5640
|
+
return de(e, i, t, r5.get(i) || []);
|
|
5641
|
+
});
|
|
5642
|
+
}
|
|
5643
|
+
function kt(e, n, t) {
|
|
5644
|
+
let r5 = new p();
|
|
5645
|
+
e.forEach(function(o) {
|
|
5646
|
+
t.forEach((a) => r5.setEdge(a.left, a.right));
|
|
5647
|
+
let i = o.graph().root, s = W(o, i, r5, n);
|
|
5648
|
+
s.vs.forEach((a, d) => o.node(a).order = d), le(o, r5, s.vs);
|
|
5679
5649
|
});
|
|
5680
5650
|
}
|
|
5681
|
-
function
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5651
|
+
function an(e, n) {
|
|
5652
|
+
Object.values(n).forEach((t) => t.forEach((r5, o) => e.node(r5).order = o));
|
|
5653
|
+
}
|
|
5654
|
+
function vt(e, n) {
|
|
5655
|
+
let t = {};
|
|
5656
|
+
function r5(o, i) {
|
|
5657
|
+
let s = 0, a = 0, d = o.length, l = i[i.length - 1];
|
|
5658
|
+
return i.forEach((u, c) => {
|
|
5659
|
+
let h = xt(e, u), f = h ? e.node(h).order : d;
|
|
5660
|
+
(h || u === l) && (i.slice(a, c + 1).forEach((g) => {
|
|
5661
|
+
let b = e.predecessors(g);
|
|
5662
|
+
b && b.forEach((m) => {
|
|
5663
|
+
let E = e.node(m), y = E.order;
|
|
5664
|
+
(y < s || f < y) && !(E.dummy && e.node(g).dummy) && dn(t, m, g);
|
|
5665
|
+
});
|
|
5666
|
+
}), a = c + 1, s = f);
|
|
5667
|
+
}), i;
|
|
5689
5668
|
}
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5669
|
+
return n.length && n.reduce(r5), t;
|
|
5670
|
+
}
|
|
5671
|
+
function _t(e, n) {
|
|
5672
|
+
let t = {};
|
|
5673
|
+
function r5(i, s, a, d, l) {
|
|
5674
|
+
k(s, a).forEach((u) => {
|
|
5675
|
+
let c = i[u];
|
|
5676
|
+
if (c !== void 0 && e.node(c).dummy) {
|
|
5677
|
+
let h = e.predecessors(c);
|
|
5678
|
+
h && h.forEach((f) => {
|
|
5679
|
+
if (f === void 0) return;
|
|
5680
|
+
let g = e.node(f);
|
|
5681
|
+
g.dummy && (g.order < d || g.order > l) && dn(t, f, c);
|
|
5682
|
+
});
|
|
5683
|
+
}
|
|
5705
5684
|
});
|
|
5706
5685
|
}
|
|
5707
|
-
|
|
5686
|
+
function o(i, s) {
|
|
5687
|
+
let a = -1, d = -1, l = 0;
|
|
5688
|
+
return s.forEach((u, c) => {
|
|
5689
|
+
if (e.node(u).dummy === "border") {
|
|
5690
|
+
let h = e.predecessors(u);
|
|
5691
|
+
if (h && h.length) {
|
|
5692
|
+
let f = h[0];
|
|
5693
|
+
if (f === void 0) return;
|
|
5694
|
+
d = e.node(f).order, r5(s, l, c, a, d), l = c, a = d;
|
|
5695
|
+
}
|
|
5696
|
+
}
|
|
5697
|
+
r5(s, l, s.length, d, i.length);
|
|
5698
|
+
}), s;
|
|
5699
|
+
}
|
|
5700
|
+
return n.length && n.reduce(o), t;
|
|
5708
5701
|
}
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
const indeg = /* @__PURE__ */ new Map();
|
|
5714
|
-
const outs = /* @__PURE__ */ new Map();
|
|
5715
|
-
for (const n of nodes) {
|
|
5716
|
-
indeg.set(n.id, 0);
|
|
5717
|
-
outs.set(n.id, []);
|
|
5702
|
+
function xt(e, n) {
|
|
5703
|
+
if (e.node(n).dummy) {
|
|
5704
|
+
let t = e.predecessors(n);
|
|
5705
|
+
if (t) return t.find((r5) => e.node(r5).dummy);
|
|
5718
5706
|
}
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5707
|
+
}
|
|
5708
|
+
function dn(e, n, t) {
|
|
5709
|
+
if (n > t) {
|
|
5710
|
+
let o = n;
|
|
5711
|
+
n = t, t = o;
|
|
5723
5712
|
}
|
|
5724
|
-
let
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
if (order.has(id)) continue;
|
|
5732
|
-
order.set(id, order.size);
|
|
5733
|
-
for (const to of outs.get(id) ?? []) {
|
|
5734
|
-
const d = (indeg.get(to) ?? 0) - 1;
|
|
5735
|
-
indeg.set(to, d);
|
|
5736
|
-
if (d <= 0 && !order.has(to)) queue.push(to);
|
|
5737
|
-
}
|
|
5713
|
+
let r5 = e[n];
|
|
5714
|
+
r5 || (e[n] = r5 = {}), r5[t] = true;
|
|
5715
|
+
}
|
|
5716
|
+
function Tt(e, n, t) {
|
|
5717
|
+
if (n > t) {
|
|
5718
|
+
let o = n;
|
|
5719
|
+
n = t, t = o;
|
|
5738
5720
|
}
|
|
5739
|
-
|
|
5740
|
-
return
|
|
5721
|
+
let r5 = e[n];
|
|
5722
|
+
return r5 !== void 0 && Object.hasOwn(r5, t);
|
|
5741
5723
|
}
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
function renderFlowSvg(data) {
|
|
5748
|
-
const edges = data.edges ?? [];
|
|
5749
|
-
const groups = data.groups ?? [];
|
|
5750
|
-
const rawNodes = data.nodes ?? [];
|
|
5751
|
-
const quick = !(rawNodes.length > 0 && rawNodes.every((n) => n.col !== void 0 && n.row !== void 0));
|
|
5752
|
-
const nodes = ensureGrid(rawNodes, edges, data.dir ?? "LR");
|
|
5753
|
-
const cellW = CELL_W;
|
|
5754
|
-
const cellH = CELL_H;
|
|
5755
|
-
const gapX = 56;
|
|
5756
|
-
const gapY = 48;
|
|
5757
|
-
const nestPad = nestingPads(groups);
|
|
5758
|
-
const padX = (groups.length > 0 ? GROUP_PADS.padX : 22) + nestPad.padX;
|
|
5759
|
-
const padTop = (groups.length > 0 ? GROUP_PADS.padTop : 22) + nestPad.padTop;
|
|
5760
|
-
const padBot = (groups.length > 0 ? GROUP_PADS.padBot : 18) + nestPad.padBot;
|
|
5761
|
-
const gx = groupExtent(groups);
|
|
5762
|
-
const cols = Math.max(1, ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)), gx.cols);
|
|
5763
|
-
const rows = Math.max(1, ...nodes.map((n) => n.row), gx.rows);
|
|
5764
|
-
const xOf = (c) => padX + (c - 1) * (cellW + gapX);
|
|
5765
|
-
const yOf = (r5) => padTop + (r5 - 1) * (cellH + gapY);
|
|
5766
|
-
const cellFor = (n) => ({
|
|
5767
|
-
x: xOf(n.col),
|
|
5768
|
-
y: yOf(n.row),
|
|
5769
|
-
w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,
|
|
5770
|
-
h: cellH
|
|
5771
|
-
});
|
|
5772
|
-
const boxFor = (n) => {
|
|
5773
|
-
const c = cellFor(n);
|
|
5774
|
-
if ((n.kind ?? "process") === "decision") return c;
|
|
5775
|
-
const dx = (cellW - NODE_W) / 2;
|
|
5776
|
-
const dy = (cellH - NODE_H) / 2;
|
|
5777
|
-
return { x: c.x + dx, y: c.y + dy, w: c.w - dx * 2, h: NODE_H };
|
|
5778
|
-
};
|
|
5779
|
-
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
5780
|
-
const width = padX * 2 + cols * cellW + (cols - 1) * gapX;
|
|
5781
|
-
const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;
|
|
5782
|
-
const isErrEdge = (e) => e.kind === "error" || ERR_LABEL_RE.test(e.label ?? "");
|
|
5783
|
-
const errTargets = new Set(edges.filter(isErrEdge).map((e) => e.to));
|
|
5784
|
-
const accentIds = new Set(
|
|
5785
|
-
nodes.filter((n) => n.kind === "end" && !errTargets.has(n.id) && !ERR_LABEL_RE.test(n.label)).map((n) => n.id)
|
|
5786
|
-
);
|
|
5787
|
-
const gridMeta = gridMetaAttrs({ quick, cols, rows, cellW, cellH, gapX, gapY, padX, padTop });
|
|
5788
|
-
const a11y = svgName("Flowchart", data.title, [countPhrase(nodes.length, "step")]);
|
|
5789
|
-
let s = `<svg viewBox="0 0 ${width} ${height}"${a11y.attrs}${gridMeta}>${a11y.title}`;
|
|
5790
|
-
if (groups.length > 0) s += gridGroupsSvg(groups, { xOf, yOf, cellW, cellH, gapX, gapY, skin: true });
|
|
5791
|
-
const used = { plain: false, dashed: false, error: false, accent: false };
|
|
5792
|
-
const pending = [];
|
|
5793
|
-
const lanes = edgeLanes(edges);
|
|
5794
|
-
const order = flowRevealOrder(nodes, edges);
|
|
5795
|
-
const stepOf = (id) => order.get(id) ?? 0;
|
|
5796
|
-
const entries = entryPortOffsets(edges, (id) => {
|
|
5797
|
-
const n = byId.get(id);
|
|
5798
|
-
return n !== void 0 ? boxFor(n) : void 0;
|
|
5799
|
-
});
|
|
5800
|
-
s += `<g${bl("edges")}>`;
|
|
5801
|
-
edges.forEach((e, ei) => {
|
|
5802
|
-
const A2 = byId.get(e.from);
|
|
5803
|
-
const B3 = byId.get(e.to);
|
|
5804
|
-
if (!A2 || !B3) return;
|
|
5805
|
-
const p2 = ortho(boxFor(A2), boxFor(B3), lanes[ei] ?? 0, entries[ei] ?? 0);
|
|
5806
|
-
const isErr = isErrEdge(e);
|
|
5807
|
-
const isAccent = !isErr && accentIds.has(e.to);
|
|
5808
|
-
const isDashed = !isErr && e.kind === "dashed";
|
|
5809
|
-
const stroke = isErr ? "var(--negative)" : isAccent ? "var(--accent)" : "var(--muted)";
|
|
5810
|
-
const marker2 = isErr ? "skErr" : isAccent ? "skAccent" : isDashed ? "skOpen" : "skArrow";
|
|
5811
|
-
const sw = isAccent ? 1.75 : 1.5;
|
|
5812
|
-
const dash = isDashed ? ' stroke-dasharray="5 4"' : "";
|
|
5813
|
-
if (isErr) used.error = true;
|
|
5814
|
-
else if (isAccent) used.accent = true;
|
|
5815
|
-
else if (isDashed) used.dashed = true;
|
|
5816
|
-
else used.plain = true;
|
|
5817
|
-
const reveal = Math.max(stepOf(e.from), stepOf(e.to));
|
|
5818
|
-
s += `<path d="${p2.d}" fill="none" stroke="${stroke}" stroke-width="${sw}"${dash} marker-end="url(#${marker2})"${bp(`edges.${ei}`)}${revealAttr(reveal)}/>`;
|
|
5819
|
-
pending.push({
|
|
5820
|
-
lx: p2.lx,
|
|
5821
|
-
ly: p2.ly,
|
|
5822
|
-
...e.label !== void 0 ? { label: e.label } : {},
|
|
5823
|
-
err: isErr,
|
|
5824
|
-
accent: isAccent,
|
|
5825
|
-
path: `edges.${ei}`,
|
|
5826
|
-
reveal
|
|
5724
|
+
function Ot(e, n, t, r5) {
|
|
5725
|
+
let o = {}, i = {}, s = {};
|
|
5726
|
+
return n.forEach((a) => {
|
|
5727
|
+
a.forEach((d, l) => {
|
|
5728
|
+
o[d] = d, i[d] = d, s[d] = l;
|
|
5827
5729
|
});
|
|
5828
|
-
})
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
}
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
(ln2, j2) => `<text x="${cx}" y="${cy + 4.5 - (lines.length - 1) * 7.5 + j2 * 15}" class="fc-label t-name${tone}">${escapeHtml(ln2)}</text>`
|
|
5862
|
-
).join("");
|
|
5730
|
+
}), n.forEach((a) => {
|
|
5731
|
+
let d = -1;
|
|
5732
|
+
a.forEach((l) => {
|
|
5733
|
+
let u = r5(l);
|
|
5734
|
+
if (u && u.length) {
|
|
5735
|
+
let c = u.sort((f, g) => {
|
|
5736
|
+
let b = s[f], m = s[g];
|
|
5737
|
+
return (b !== void 0 ? b : 0) - (m !== void 0 ? m : 0);
|
|
5738
|
+
}), h = (c.length - 1) / 2;
|
|
5739
|
+
for (let f = Math.floor(h), g = Math.ceil(h); f <= g; ++f) {
|
|
5740
|
+
let b = c[f];
|
|
5741
|
+
if (b === void 0) continue;
|
|
5742
|
+
let m = s[b];
|
|
5743
|
+
if (m !== void 0 && i[l] === l && d < m && !Tt(t, l, b)) {
|
|
5744
|
+
let E = o[b];
|
|
5745
|
+
E !== void 0 && (i[b] = l, i[l] = o[l] = E, d = m);
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
}
|
|
5749
|
+
});
|
|
5750
|
+
}), { root: o, align: i };
|
|
5751
|
+
}
|
|
5752
|
+
function It(e, n, t, r5, o = false) {
|
|
5753
|
+
let i = {}, s = Ct(e, n, t, o), a = o ? "borderLeft" : "borderRight";
|
|
5754
|
+
function d(f, g) {
|
|
5755
|
+
let b = s.nodes().slice(), m = {}, E = b.pop();
|
|
5756
|
+
for (; E; ) {
|
|
5757
|
+
if (m[E]) f(E);
|
|
5758
|
+
else {
|
|
5759
|
+
m[E] = true, b.push(E);
|
|
5760
|
+
for (let y of g(E)) b.push(y);
|
|
5761
|
+
}
|
|
5762
|
+
E = b.pop();
|
|
5863
5763
|
}
|
|
5864
|
-
s += `<g${bp(`nodes.${ni}`)}${nodeCellAttrs(n.col, n.row, n.w ?? 1)}${revealAttr(stepOf(n.id))}>${shape}${texts}</g>`;
|
|
5865
|
-
});
|
|
5866
|
-
s += `</g>`;
|
|
5867
|
-
const { overlay, legend: steps } = edgeLabelLayer(pending, nodes.map((n) => boxFor(n)), { skin: true });
|
|
5868
|
-
s += overlay;
|
|
5869
|
-
s += `</svg>`;
|
|
5870
|
-
const items = [];
|
|
5871
|
-
if (kindsUsed.has("start")) items.push({ swatch: "node-fill2", label: "start" });
|
|
5872
|
-
if (kindsUsed.has("process")) items.push({ swatch: "node", label: "step" });
|
|
5873
|
-
if (kindsUsed.has("decision")) items.push({ swatch: "node", label: "decision (diamond)" });
|
|
5874
|
-
if (kindsUsed.has("end") && [...accentIds].length < nodes.filter((n) => n.kind === "end").length) {
|
|
5875
|
-
items.push({ swatch: "node", label: "exit" });
|
|
5876
5764
|
}
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5765
|
+
function l(f) {
|
|
5766
|
+
let g = s.inEdges(f);
|
|
5767
|
+
g ? i[f] = g.reduce((b, m) => {
|
|
5768
|
+
var I;
|
|
5769
|
+
let E = (I = i[m.v]) != null ? I : 0, y = s.edge(m);
|
|
5770
|
+
return Math.max(b, E + (y !== void 0 ? y : 0));
|
|
5771
|
+
}, 0) : i[f] = 0;
|
|
5772
|
+
}
|
|
5773
|
+
function u(f) {
|
|
5774
|
+
let g = s.outEdges(f), b = Number.POSITIVE_INFINITY;
|
|
5775
|
+
g && (b = g.reduce((E, y) => {
|
|
5776
|
+
let I = i[y.w], be = s.edge(y);
|
|
5777
|
+
return Math.min(E, (I !== void 0 ? I : 0) - (be !== void 0 ? be : 0));
|
|
5778
|
+
}, Number.POSITIVE_INFINITY));
|
|
5779
|
+
let m = e.node(f);
|
|
5780
|
+
b !== Number.POSITIVE_INFINITY && m.borderType !== a && (i[f] = Math.max(i[f] !== void 0 ? i[f] : 0, b));
|
|
5781
|
+
}
|
|
5782
|
+
function c(f) {
|
|
5783
|
+
return s.predecessors(f) || [];
|
|
5784
|
+
}
|
|
5785
|
+
function h(f) {
|
|
5786
|
+
return s.successors(f) || [];
|
|
5787
|
+
}
|
|
5788
|
+
return d(l, c), d(u, h), Object.keys(r5).forEach((f) => {
|
|
5789
|
+
var b;
|
|
5790
|
+
let g = t[f];
|
|
5791
|
+
g !== void 0 && (i[f] = (b = i[g]) != null ? b : 0);
|
|
5792
|
+
}), i;
|
|
5894
5793
|
}
|
|
5895
|
-
function
|
|
5896
|
-
|
|
5794
|
+
function Ct(e, n, t, r5) {
|
|
5795
|
+
let o = new p(), i = e.graph(), s = jt(i.nodesep, i.edgesep, r5);
|
|
5796
|
+
return n.forEach((a) => {
|
|
5797
|
+
let d;
|
|
5798
|
+
a.forEach((l) => {
|
|
5799
|
+
let u = t[l];
|
|
5800
|
+
if (u !== void 0) {
|
|
5801
|
+
if (o.setNode(u), d !== void 0) {
|
|
5802
|
+
let c = t[d];
|
|
5803
|
+
if (c !== void 0) {
|
|
5804
|
+
let h = o.edge(c, u);
|
|
5805
|
+
o.setEdge(c, u, Math.max(s(e, l, d), h || 0));
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
d = l;
|
|
5809
|
+
}
|
|
5810
|
+
});
|
|
5811
|
+
}), o;
|
|
5897
5812
|
}
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5813
|
+
function Rt(e, n) {
|
|
5814
|
+
return Object.values(n).reduce((t, r5) => {
|
|
5815
|
+
let o = Number.NEGATIVE_INFINITY, i = Number.POSITIVE_INFINITY;
|
|
5816
|
+
Object.entries(r5).forEach(([a, d]) => {
|
|
5817
|
+
let l = St(e, a) / 2;
|
|
5818
|
+
o = Math.max(d + l, o), i = Math.min(d - l, i);
|
|
5819
|
+
});
|
|
5820
|
+
let s = o - i;
|
|
5821
|
+
return s < t[0] && (t = [s, r5]), t;
|
|
5822
|
+
}, [Number.POSITIVE_INFINITY, null])[1];
|
|
5903
5823
|
}
|
|
5904
|
-
function
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
return { x: cx - pw / 2, y: cy - ph / 2, w: pw, h: ph, cx, cy };
|
|
5824
|
+
function Pt(e, n) {
|
|
5825
|
+
let t = Object.values(n), r5 = L(Math.min, t), o = L(Math.max, t);
|
|
5826
|
+
["u", "d"].forEach((i) => {
|
|
5827
|
+
["l", "r"].forEach((s) => {
|
|
5828
|
+
let a = i + s, d = e[a];
|
|
5829
|
+
if (!d || d === n) return;
|
|
5830
|
+
let l = Object.values(d), u = r5 - L(Math.min, l);
|
|
5831
|
+
s !== "l" && (u = o - L(Math.max, l)), u && (e[a] = O(d, (c) => c + u));
|
|
5832
|
+
});
|
|
5833
|
+
});
|
|
5915
5834
|
}
|
|
5916
|
-
function
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5835
|
+
function Mt(e, n = void 0) {
|
|
5836
|
+
let t = e.ul;
|
|
5837
|
+
return t ? O(t, (r5, o) => {
|
|
5838
|
+
var s, a;
|
|
5839
|
+
if (n) {
|
|
5840
|
+
let d = n.toLowerCase(), l = e[d];
|
|
5841
|
+
if (l && l[o] !== void 0) return l[o];
|
|
5842
|
+
}
|
|
5843
|
+
let i = Object.values(e).map((d) => {
|
|
5844
|
+
let l = d[o];
|
|
5845
|
+
return l !== void 0 ? l : 0;
|
|
5846
|
+
}).sort((d, l) => d - l);
|
|
5847
|
+
return (((s = i[1]) != null ? s : 0) + ((a = i[2]) != null ? a : 0)) / 2;
|
|
5848
|
+
}) : {};
|
|
5921
5849
|
}
|
|
5922
|
-
function
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
const gapY = 60;
|
|
5931
|
-
const groups = data.groups ?? [];
|
|
5932
|
-
const nestPad = nestingPads(groups);
|
|
5933
|
-
const padX = (groups.length > 0 ? GROUP_PADS.padX : 30) + nestPad.padX;
|
|
5934
|
-
const padTop = (groups.length > 0 ? GROUP_PADS.padTop : 30) + nestPad.padTop;
|
|
5935
|
-
const padBot = (groups.length > 0 ? GROUP_PADS.padBot : 20) + nestPad.padBot;
|
|
5936
|
-
const gx = groupExtent(groups);
|
|
5937
|
-
const cols = Math.max(1, ...states.map((s2) => s2.col), gx.cols);
|
|
5938
|
-
const rows = Math.max(1, ...states.map((s2) => s2.row), gx.rows);
|
|
5939
|
-
const width = padX * 2 + cols * cellW + (cols - 1) * gapX;
|
|
5940
|
-
const height = padTop * 2 + rows * cellH + (rows - 1) * gapY + padBot;
|
|
5941
|
-
const byId = new Map(states.map((s2) => [s2.id, s2]));
|
|
5942
|
-
const isErrTerminal = (s2) => s2 !== void 0 && s2.kind === "terminal" && (ERR_RE.test(s2.name ?? "") || ERR_RE.test(s2.id));
|
|
5943
|
-
const successExits = states.filter((s2) => s2.kind === "terminal" && !isErrTerminal(s2));
|
|
5944
|
-
const accentId = successExits.length === 1 ? successExits[0]?.id : void 0;
|
|
5945
|
-
const gridMeta = gridMetaAttrs({ quick, cols, rows, cellW, cellH, gapX, gapY, padX, padTop });
|
|
5946
|
-
const a11y = svgName("State machine", data.title, [
|
|
5947
|
-
countPhrase(states.length, "state"),
|
|
5948
|
-
countPhrase(trans.length, "transition")
|
|
5949
|
-
]);
|
|
5950
|
-
let s = `<svg viewBox="0 0 ${width} ${height}"${a11y.attrs}${gridMeta}>${a11y.title}`;
|
|
5951
|
-
if (groups.length > 0) {
|
|
5952
|
-
const xOf = (c) => padX + (c - 1) * (cellW + gapX);
|
|
5953
|
-
const yOf = (r5) => padTop + (r5 - 1) * (cellH + gapY);
|
|
5954
|
-
s += gridGroupsSvg(groups, { xOf, yOf, cellW, cellH, gapX, gapY, skin: true });
|
|
5955
|
-
}
|
|
5956
|
-
const numbered = trans.length >= 4;
|
|
5957
|
-
const labels = [];
|
|
5958
|
-
const used = { plain: false, error: false, accent: false };
|
|
5959
|
-
const lanes = edgeLanes(trans);
|
|
5960
|
-
const avoid = states.map((st2) => {
|
|
5961
|
-
const r5 = rectFor(st2, cellW, cellH, gapX, gapY, padX, padTop);
|
|
5962
|
-
return { x: r5.x, y: r5.y, w: r5.w, h: r5.h };
|
|
5963
|
-
});
|
|
5964
|
-
const entries = entryPortOffsets(trans, (id) => {
|
|
5965
|
-
const n = byId.get(id);
|
|
5966
|
-
return n !== void 0 ? rectFor(n, cellW, cellH, gapX, gapY, padX, padTop) : void 0;
|
|
5850
|
+
function ln(e) {
|
|
5851
|
+
let n = N(e), t = Object.assign(vt(e, n), _t(e, n)), r5 = {}, o;
|
|
5852
|
+
["u", "d"].forEach((s) => {
|
|
5853
|
+
o = s === "u" ? n : Object.values(n).reverse(), ["l", "r"].forEach((a) => {
|
|
5854
|
+
a === "r" && (o = o.map((c) => Object.values(c).reverse()));
|
|
5855
|
+
let l = Ot(e, o, t, (c) => (s === "u" ? e.predecessors(c) : e.successors(c)) || []), u = It(e, o, l.root, l.align, a === "r");
|
|
5856
|
+
a === "r" && (u = O(u, (c) => -c)), r5[s + a] = u;
|
|
5857
|
+
});
|
|
5967
5858
|
});
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
else used.plain = true;
|
|
5982
|
-
const tAttrs = bp(`transitions.${ti}`) + revealAttr(ti);
|
|
5983
|
-
if (t.from === t.to) {
|
|
5984
|
-
const r5 = rectFor(A2, cellW, cellH, gapX, gapY, padX, padTop);
|
|
5985
|
-
s += `<path d="M ${r5.cx - 12} ${r5.y} C ${r5.cx - 30} ${r5.y - 32}, ${r5.cx + 30} ${r5.y - 32}, ${r5.cx + 12} ${r5.y}" fill="none" stroke="${stroke}" stroke-width="${sw}" marker-end="url(#${marker2})"${tAttrs}/>`;
|
|
5986
|
-
const at2 = { lx: r5.cx, ly: r5.y - 28 };
|
|
5987
|
-
const mark2 = numbered ? edgeStep(at2, ti + 1, isErr, true) : edgeMask(at2, label, tone);
|
|
5988
|
-
labels.push(`<g${tAttrs}>${mark2}</g>`);
|
|
5989
|
-
return;
|
|
5859
|
+
let i = Rt(e, r5);
|
|
5860
|
+
return Pt(r5, i), Mt(r5, e.graph().align);
|
|
5861
|
+
}
|
|
5862
|
+
function jt(e, n, t) {
|
|
5863
|
+
return (r5, o, i) => {
|
|
5864
|
+
let s = r5.node(o), a = r5.node(i), d = 0, l;
|
|
5865
|
+
if (d += s.width / 2, Object.hasOwn(s, "labelpos")) switch (s.labelpos.toLowerCase()) {
|
|
5866
|
+
case "l":
|
|
5867
|
+
l = -s.width / 2;
|
|
5868
|
+
break;
|
|
5869
|
+
case "r":
|
|
5870
|
+
l = s.width / 2;
|
|
5871
|
+
break;
|
|
5990
5872
|
}
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
5873
|
+
if (l && (d += t ? l : -l), l = void 0, d += (s.dummy ? n : e) / 2, d += (a.dummy ? n : e) / 2, d += a.width / 2, Object.hasOwn(a, "labelpos")) switch (a.labelpos.toLowerCase()) {
|
|
5874
|
+
case "l":
|
|
5875
|
+
l = a.width / 2;
|
|
5876
|
+
break;
|
|
5877
|
+
case "r":
|
|
5878
|
+
l = -a.width / 2;
|
|
5879
|
+
break;
|
|
5880
|
+
}
|
|
5881
|
+
return l && (d += t ? l : -l), d;
|
|
5882
|
+
};
|
|
5883
|
+
}
|
|
5884
|
+
function St(e, n) {
|
|
5885
|
+
return e.node(n).width;
|
|
5886
|
+
}
|
|
5887
|
+
function un(e) {
|
|
5888
|
+
e = A(e), Ft(e), Object.entries(ln(e)).forEach(([n, t]) => e.node(n).x = t);
|
|
5889
|
+
}
|
|
5890
|
+
function Ft(e) {
|
|
5891
|
+
let n = N(e), t = e.graph(), r5 = t.ranksep, o = t.rankalign, i = 0;
|
|
5892
|
+
n.forEach((s) => {
|
|
5893
|
+
let a = s.reduce((d, l) => {
|
|
5894
|
+
var c;
|
|
5895
|
+
let u = (c = e.node(l).height) != null ? c : 0;
|
|
5896
|
+
return d > u ? d : u;
|
|
5897
|
+
}, 0);
|
|
5898
|
+
s.forEach((d) => {
|
|
5899
|
+
let l = e.node(d);
|
|
5900
|
+
o === "top" ? l.y = i + l.height / 2 : o === "bottom" ? l.y = i + a - l.height / 2 : l.y = i + a / 2;
|
|
5901
|
+
}), i += a + r5;
|
|
6000
5902
|
});
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
5903
|
+
}
|
|
5904
|
+
function he(e, n = {}) {
|
|
5905
|
+
let t = n.debugTiming ? P : M;
|
|
5906
|
+
return t("layout", () => {
|
|
5907
|
+
let r5 = t(" buildLayoutGraph", () => Xt(e));
|
|
5908
|
+
return t(" runLayout", () => Dt(r5, t, n)), t(" updateInputGraph", () => At(e, r5)), r5;
|
|
5909
|
+
});
|
|
5910
|
+
}
|
|
5911
|
+
function Dt(e, n, t) {
|
|
5912
|
+
n(" makeSpaceForEdgeLabels", () => Ut(e)), n(" removeSelfEdges", () => rr(e)), n(" acyclic", () => je(e)), n(" nestingGraph.run", () => Ke(e)), n(" rank", () => Xe(A(e))), n(" injectEdgeLabelProxies", () => Kt(e)), n(" removeEmptyRanks", () => Oe(e)), n(" nestingGraph.cleanup", () => Je(e)), n(" normalizeRanks", () => Te(e)), n(" assignRankMinMax", () => $t(e)), n(" removeEdgeLabelProxies", () => Jt(e)), n(" normalize.run", () => Fe(e)), n(" parentDummyChains", () => Ue(e)), n(" addBorderSegments", () => Ze(e)), n(" order", () => B(e, t)), n(" insertSelfEdges", () => or(e)), n(" adjustCoordinateSystem", () => nn(e)), n(" position", () => un(e)), n(" positionSelfEdges", () => ir(e)), n(" removeBorderNodes", () => tr(e)), n(" normalize.undo", () => De(e)), n(" fixupEdgeLabelCoords", () => er(e)), n(" undoCoordinateSystem", () => tn(e)), n(" translateGraph", () => Qt(e)), n(" assignNodeIntersects", () => Zt(e)), n(" reversePoints", () => nr(e)), n(" acyclic.undo", () => Se(e));
|
|
5913
|
+
}
|
|
5914
|
+
function At(e, n) {
|
|
5915
|
+
e.nodes().forEach((t) => {
|
|
5916
|
+
let r5 = e.node(t), o = n.node(t);
|
|
5917
|
+
r5 && (r5.x = o.x, r5.y = o.y, r5.order = o.order, r5.rank = o.rank, n.children(t).length && (r5.width = o.width, r5.height = o.height));
|
|
5918
|
+
}), e.edges().forEach((t) => {
|
|
5919
|
+
let r5 = e.edge(t), o = n.edge(t);
|
|
5920
|
+
r5.points = o.points, Object.hasOwn(o, "x") && (r5.x = o.x, r5.y = o.y);
|
|
5921
|
+
}), e.graph().width = n.graph().width, e.graph().height = n.graph().height;
|
|
5922
|
+
}
|
|
5923
|
+
var Vt = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
|
|
5924
|
+
var Wt = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "TB", rankalign: "center" };
|
|
5925
|
+
var Bt = ["acyclicer", "ranker", "rankdir", "align", "rankalign"];
|
|
5926
|
+
var Yt = ["width", "height", "rank"];
|
|
5927
|
+
var cn = { width: 0, height: 0 };
|
|
5928
|
+
var zt = ["minlen", "weight", "width", "height", "labeloffset"];
|
|
5929
|
+
var Ht = { minlen: 1, weight: 1, width: 0, height: 0, labeloffset: 10, labelpos: "r" };
|
|
5930
|
+
var qt = ["labelpos"];
|
|
5931
|
+
function Xt(e) {
|
|
5932
|
+
let n = new p({ multigraph: true, compound: true }), t = ce(e.graph());
|
|
5933
|
+
return n.setGraph(Object.assign({}, Wt, ue(t, Vt), T(t, Bt))), e.nodes().forEach((r5) => {
|
|
5934
|
+
let o = ce(e.node(r5)), i = ue(o, Yt);
|
|
5935
|
+
Object.keys(cn).forEach((a) => {
|
|
5936
|
+
i[a] === void 0 && (i[a] = cn[a]);
|
|
5937
|
+
}), n.setNode(r5, i);
|
|
5938
|
+
let s = e.parent(r5);
|
|
5939
|
+
s !== void 0 && n.setParent(r5, s);
|
|
5940
|
+
}), e.edges().forEach((r5) => {
|
|
5941
|
+
let o = ce(e.edge(r5));
|
|
5942
|
+
n.setEdge(r5, Object.assign({}, Ht, ue(o, zt), T(o, qt)));
|
|
5943
|
+
}), n;
|
|
5944
|
+
}
|
|
5945
|
+
function Ut(e) {
|
|
5946
|
+
let n = e.graph();
|
|
5947
|
+
n.ranksep /= 2, e.edges().forEach((t) => {
|
|
5948
|
+
let r5 = e.edge(t);
|
|
5949
|
+
r5.minlen *= 2, r5.labelpos.toLowerCase() !== "c" && (n.rankdir === "TB" || n.rankdir === "BT" ? r5.width += r5.labeloffset : r5.height += r5.labeloffset);
|
|
5950
|
+
});
|
|
5951
|
+
}
|
|
5952
|
+
function Kt(e) {
|
|
5953
|
+
e.edges().forEach((n) => {
|
|
5954
|
+
let t = e.edge(n);
|
|
5955
|
+
if (t.width && t.height) {
|
|
5956
|
+
let r5 = e.node(n.v), i = { rank: (e.node(n.w).rank - r5.rank) / 2 + r5.rank, e: n };
|
|
5957
|
+
w(e, "edge-proxy", i, "_ep");
|
|
6029
5958
|
}
|
|
6030
5959
|
});
|
|
6031
|
-
s += `</g>`;
|
|
6032
|
-
s += labels.join("");
|
|
6033
|
-
s += `</svg>`;
|
|
6034
|
-
const name = (id) => byId.get(id)?.name ?? id;
|
|
6035
|
-
const numCell = (ti) => numbered ? `<td class="t-num"><span class="edge-step"><b>${ti + 1}</b></span></td>` : "";
|
|
6036
|
-
const rows2 = trans.map(
|
|
6037
|
-
(t, ti) => `<tr${bp(`transitions.${ti}`)}${revealAttr(ti)}>` + numCell(ti) + `<td><span class="${pillCls(byId.get(t.from)?.kind)}">${escapeHtml(name(t.from))}</span></td><td style="font-family:var(--font-mono);font-size:11px"${bp(`transitions.${ti}.event`)}>${escapeHtml(t.event)}</td><td class="c-soft" style="font-size:11px"${bp(`transitions.${ti}.guard`)}>${escapeHtml(t.guard ?? "\u2014")}</td><td><span class="${pillCls(byId.get(t.to)?.kind)}">${escapeHtml(name(t.to))}</span></td></tr>`
|
|
6038
|
-
).join("");
|
|
6039
|
-
const table = trans.length > 0 ? `<table class="transition-table"><thead><tr>${numbered ? "<th>\u2116</th>" : ""}<th>From</th><th>Event</th><th>Guard</th><th>To</th></tr></thead><tbody${bl("transitions")}>${rows2}</tbody></table>` : "";
|
|
6040
|
-
const items = [];
|
|
6041
|
-
if (kinds.start) items.push({ swatch: "chip", chip: "\u25CF", label: "start" });
|
|
6042
|
-
if (kinds.active) items.push({ swatch: "node", label: "state" });
|
|
6043
|
-
if (kinds.wait) items.push({ swatch: "node-fill2", label: "waiting" });
|
|
6044
|
-
if (kinds.end) items.push({ swatch: "chip", chip: "\u25C9", label: "end" });
|
|
6045
|
-
if (used.plain) items.push({ swatch: "edge", label: "transition" });
|
|
6046
|
-
if (kinds.errEnd) items.push({ swatch: "node-negative", label: "error exit" });
|
|
6047
|
-
if (used.error) items.push({ swatch: "edge-error", label: "error transition" });
|
|
6048
|
-
if (accentId !== void 0) items.push({ swatch: "node-accent", label: "success exit" });
|
|
6049
|
-
const legend = renderLegend(items);
|
|
6050
|
-
return diagramFrame(
|
|
6051
|
-
{
|
|
6052
|
-
tag: "STATE",
|
|
6053
|
-
...data.title !== void 0 ? { title: data.title } : {},
|
|
6054
|
-
...data.description !== void 0 ? { desc: data.description } : {},
|
|
6055
|
-
...legend.length > 0 ? { legendHtml: legend } : {},
|
|
6056
|
-
...table.length > 0 ? { footerHtml: table } : {}
|
|
6057
|
-
},
|
|
6058
|
-
s
|
|
6059
|
-
);
|
|
6060
5960
|
}
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
db: "M1.5 3 a5.5 2.2 0 0 0 11 0 a5.5 2.2 0 0 0 -11 0 V11 a5.5 2.2 0 0 0 11 0 V3",
|
|
6077
|
-
// cloud
|
|
6078
|
-
cdn: "M3.5 12 a3 3 0 0 1 0.3 -6 a4 4 0 0 1 7.6 1 a2.5 2.5 0 0 1 0.6 5 Z",
|
|
6079
|
-
// splitter: one lane in, three out
|
|
6080
|
-
lb: "M1.5 7 H5 M5 7 L9 3 H12.5 M5 7 H12.5 M5 7 L9 11 H12.5",
|
|
6081
|
-
// double chevron
|
|
6082
|
-
gateway: "M2 1.5 L7 7 L2 12.5 M7.5 1.5 L12.5 7 L7.5 12.5",
|
|
6083
|
-
// hexagon with a core
|
|
6084
|
-
pod: "M7 1.2 L12.2 4.1 V9.9 L7 12.8 L1.8 9.9 V4.1 Z M5.2 7 a1.8 1.8 0 1 0 3.6 0 a1.8 1.8 0 1 0 -3.6 0",
|
|
6085
|
-
// wheel: ring + four spokes
|
|
6086
|
-
cluster: "M1.5 7 a5.5 5.5 0 1 0 11 0 a5.5 5.5 0 1 0 -11 0 M7 1.5 V4.5 M7 9.5 V12.5 M1.5 7 H4.5 M9.5 7 H12.5",
|
|
6087
|
-
// head + shoulders
|
|
6088
|
-
user: "M4.5 4.5 a2.5 2.5 0 1 0 5 0 a2.5 2.5 0 1 0 -5 0 M2.5 13 a4.5 4.5 0 0 1 9 0",
|
|
6089
|
-
// window with a header band
|
|
6090
|
-
browser: "M1.5 2.5 H12.5 V11.5 H1.5 Z M1.5 5.5 H12.5",
|
|
6091
|
-
// phone
|
|
6092
|
-
mobile: "M4 1.5 H10 a1 1 0 0 1 1 1 V11.5 a1 1 0 0 1 -1 1 H4 a1 1 0 0 1 -1 -1 V2.5 a1 1 0 0 1 1 -1 Z M6 11 H8",
|
|
6093
|
-
// clock
|
|
6094
|
-
cron: "M1.5 7 a5.5 5.5 0 1 0 11 0 a5.5 5.5 0 1 0 -11 0 M7 3.5 V7 L9.5 8.5",
|
|
6095
|
-
// four-point spark
|
|
6096
|
-
ml: "M7 1.5 L8.4 5.6 L12.5 7 L8.4 8.4 L7 12.5 L5.6 8.4 L1.5 7 L5.6 5.6 Z",
|
|
6097
|
-
// padlock
|
|
6098
|
-
secret: "M3 6.5 H11 V13 H3 Z M4.5 6.5 V4.5 a2.5 2.5 0 0 1 5 0 V6.5",
|
|
6099
|
-
// three sliders
|
|
6100
|
-
config: "M1.5 3.5 H12.5 M1.5 7 H12.5 M1.5 10.5 H12.5 M4.5 2 V5 M9.5 5.5 V8.5 M6 9 V12",
|
|
6101
|
-
// replica set: two overlapping squares
|
|
6102
|
-
deployment: "M1.5 5 H9 V12.5 H1.5 Z M4 5 V2.5 H11.5 V10 H9",
|
|
6103
|
-
// arrow into a door
|
|
6104
|
-
ingress: "M1.5 7 H8 M5.5 4.5 L8 7 L5.5 9.5 M10 1.5 H12.5 V12.5 H10",
|
|
6105
|
-
// two rack slabs
|
|
6106
|
-
node: "M2 2 H12 V6 H2 Z M2 8 H12 V12 H2 Z M4.5 4 H6.5 M4.5 10 H6.5",
|
|
6107
|
-
// folder tab
|
|
6108
|
-
namespace: "M1.5 3.5 H5.5 L7 5 H12.5 V12 H1.5 Z",
|
|
6109
|
-
box: "M2 2 H12 V12 H2 Z"
|
|
6110
|
-
};
|
|
6111
|
-
var ALIAS = {
|
|
6112
|
-
function: "function",
|
|
6113
|
-
lambda: "function",
|
|
6114
|
-
bucket: "bucket",
|
|
6115
|
-
s3: "bucket",
|
|
6116
|
-
blob: "bucket",
|
|
6117
|
-
object: "bucket",
|
|
6118
|
-
queue: "queue",
|
|
6119
|
-
sqs: "queue",
|
|
6120
|
-
mq: "queue",
|
|
6121
|
-
broker: "queue",
|
|
6122
|
-
rabbitmq: "queue",
|
|
6123
|
-
topic: "topic",
|
|
6124
|
-
sns: "topic",
|
|
6125
|
-
kafka: "topic",
|
|
6126
|
-
kinesis: "topic",
|
|
6127
|
-
stream: "topic",
|
|
6128
|
-
cache: "cache",
|
|
6129
|
-
redis: "cache",
|
|
6130
|
-
memcached: "cache",
|
|
6131
|
-
db: "db",
|
|
6132
|
-
database: "db",
|
|
6133
|
-
store: "db",
|
|
6134
|
-
postgres: "db",
|
|
6135
|
-
mysql: "db",
|
|
6136
|
-
mongo: "db",
|
|
6137
|
-
mongodb: "db",
|
|
6138
|
-
dynamo: "db",
|
|
6139
|
-
cdn: "cdn",
|
|
6140
|
-
lb: "lb",
|
|
6141
|
-
gateway: "gateway",
|
|
6142
|
-
proxy: "gateway",
|
|
6143
|
-
pod: "pod",
|
|
6144
|
-
cluster: "cluster",
|
|
6145
|
-
user: "user",
|
|
6146
|
-
person: "user",
|
|
6147
|
-
actor: "user",
|
|
6148
|
-
browser: "browser",
|
|
6149
|
-
web: "browser",
|
|
6150
|
-
mobile: "mobile",
|
|
6151
|
-
cron: "cron",
|
|
6152
|
-
scheduler: "cron",
|
|
6153
|
-
job: "cron",
|
|
6154
|
-
cronjob: "cron",
|
|
6155
|
-
ml: "ml",
|
|
6156
|
-
model: "ml",
|
|
6157
|
-
llm: "ml",
|
|
6158
|
-
agent: "ml",
|
|
6159
|
-
ai: "ml",
|
|
6160
|
-
secret: "secret",
|
|
6161
|
-
secrets: "secret",
|
|
6162
|
-
vault: "secret",
|
|
6163
|
-
kms: "secret",
|
|
6164
|
-
config: "config",
|
|
6165
|
-
configmap: "config",
|
|
6166
|
-
settings: "config",
|
|
6167
|
-
deployment: "deployment",
|
|
6168
|
-
ingress: "ingress",
|
|
6169
|
-
node: "node",
|
|
6170
|
-
vm: "node",
|
|
6171
|
-
server: "node",
|
|
6172
|
-
host: "node",
|
|
6173
|
-
namespace: "namespace"
|
|
6174
|
-
};
|
|
6175
|
-
function glyphNameFor(kind) {
|
|
6176
|
-
return ALIAS[(kind ?? "").trim().toLowerCase()] ?? GENERIC_BOX;
|
|
5961
|
+
function $t(e) {
|
|
5962
|
+
let n = 0;
|
|
5963
|
+
e.nodes().forEach((t) => {
|
|
5964
|
+
let r5 = e.node(t);
|
|
5965
|
+
r5.borderTop && (r5.minRank = e.node(r5.borderTop).rank, r5.maxRank = e.node(r5.borderBottom).rank, n = Math.max(n, r5.maxRank));
|
|
5966
|
+
}), e.graph().maxRank = n;
|
|
5967
|
+
}
|
|
5968
|
+
function Jt(e) {
|
|
5969
|
+
e.nodes().forEach((n) => {
|
|
5970
|
+
let t = e.node(n);
|
|
5971
|
+
if (t.dummy === "edge-proxy") {
|
|
5972
|
+
let r5 = t;
|
|
5973
|
+
e.edge(r5.e).labelRank = t.rank, e.removeNode(n);
|
|
5974
|
+
}
|
|
5975
|
+
});
|
|
6177
5976
|
}
|
|
6178
|
-
function
|
|
6179
|
-
|
|
5977
|
+
function Qt(e) {
|
|
5978
|
+
let n = Number.POSITIVE_INFINITY, t = 0, r5 = Number.POSITIVE_INFINITY, o = 0, i = e.graph(), s = i.marginx || 0, a = i.marginy || 0;
|
|
5979
|
+
function d(l) {
|
|
5980
|
+
let u = l.x, c = l.y, h = l.width, f = l.height;
|
|
5981
|
+
n = Math.min(n, u - h / 2), t = Math.max(t, u + h / 2), r5 = Math.min(r5, c - f / 2), o = Math.max(o, c + f / 2);
|
|
5982
|
+
}
|
|
5983
|
+
e.nodes().forEach((l) => d(e.node(l))), e.edges().forEach((l) => {
|
|
5984
|
+
let u = e.edge(l);
|
|
5985
|
+
Object.hasOwn(u, "x") && d(u);
|
|
5986
|
+
}), n -= s, r5 -= a, e.nodes().forEach((l) => {
|
|
5987
|
+
let u = e.node(l);
|
|
5988
|
+
u.x -= n, u.y -= r5;
|
|
5989
|
+
}), e.edges().forEach((l) => {
|
|
5990
|
+
let u = e.edge(l);
|
|
5991
|
+
u.points.forEach((c) => {
|
|
5992
|
+
c.x -= n, c.y -= r5;
|
|
5993
|
+
}), Object.hasOwn(u, "x") && (u.x -= n), Object.hasOwn(u, "y") && (u.y -= r5);
|
|
5994
|
+
}), i.width = t - n + s, i.height = o - r5 + a;
|
|
6180
5995
|
}
|
|
6181
|
-
function
|
|
6182
|
-
|
|
6183
|
-
|
|
5996
|
+
function Zt(e) {
|
|
5997
|
+
e.edges().forEach((n) => {
|
|
5998
|
+
let t = e.edge(n), r5 = e.node(n.v), o = e.node(n.w), i, s;
|
|
5999
|
+
t.points ? (i = t.points[0], s = t.points[t.points.length - 1]) : (t.points = [], i = o, s = r5), t.points.unshift(H(r5, i)), t.points.push(H(o, s));
|
|
6000
|
+
});
|
|
6184
6001
|
}
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
"iam",
|
|
6233
|
-
"oauth",
|
|
6234
|
-
"sso",
|
|
6235
|
-
"monitor",
|
|
6236
|
-
"observability",
|
|
6237
|
-
"metrics",
|
|
6238
|
-
"logs",
|
|
6239
|
-
"tracing",
|
|
6240
|
-
"apm",
|
|
6241
|
-
"scheduler",
|
|
6242
|
-
"cron",
|
|
6243
|
-
"job",
|
|
6244
|
-
"stream",
|
|
6245
|
-
"kafka",
|
|
6246
|
-
"kinesis",
|
|
6247
|
-
"warehouse",
|
|
6248
|
-
"lake",
|
|
6249
|
-
"analytics",
|
|
6250
|
-
"bi",
|
|
6251
|
-
"search",
|
|
6252
|
-
"index",
|
|
6253
|
-
"elasticsearch",
|
|
6254
|
-
"opensearch",
|
|
6255
|
-
"registry",
|
|
6256
|
-
"ci",
|
|
6257
|
-
"cicd",
|
|
6258
|
-
"pipeline",
|
|
6259
|
-
"git",
|
|
6260
|
-
"repo",
|
|
6261
|
-
"scm",
|
|
6262
|
-
"device",
|
|
6263
|
-
"iot",
|
|
6264
|
-
"email",
|
|
6265
|
-
"sms",
|
|
6266
|
-
"config",
|
|
6267
|
-
"settings",
|
|
6268
|
-
"ml",
|
|
6269
|
-
"model",
|
|
6270
|
-
"llm",
|
|
6271
|
-
"agent",
|
|
6272
|
-
"ai",
|
|
6273
|
-
"user",
|
|
6274
|
-
"person",
|
|
6275
|
-
"actor",
|
|
6276
|
-
"browser",
|
|
6277
|
-
"web",
|
|
6278
|
-
"mobile",
|
|
6279
|
-
"vm",
|
|
6280
|
-
"server",
|
|
6281
|
-
"host",
|
|
6282
|
-
"secrets",
|
|
6283
|
-
"vault",
|
|
6284
|
-
"kms",
|
|
6285
|
-
"notification",
|
|
6286
|
-
"webhook",
|
|
6287
|
-
"worker",
|
|
6288
|
-
"etl",
|
|
6289
|
-
"shard",
|
|
6290
|
-
"shards",
|
|
6291
|
-
"sharded",
|
|
6292
|
-
"replica",
|
|
6293
|
-
"replicas",
|
|
6294
|
-
"replicaset",
|
|
6295
|
-
"users",
|
|
6296
|
-
"crowd",
|
|
6297
|
-
"region",
|
|
6298
|
-
"geo",
|
|
6299
|
-
"globe",
|
|
6300
|
-
// `preset: k8s` vocabulary (namespaces are groups; these are the node kinds).
|
|
6301
|
-
"deployment",
|
|
6302
|
-
"pod",
|
|
6303
|
-
"ingress",
|
|
6304
|
-
"configmap",
|
|
6305
|
-
"secret",
|
|
6306
|
-
"cronjob",
|
|
6307
|
-
"node",
|
|
6308
|
-
"namespace",
|
|
6309
|
-
"cluster",
|
|
6310
|
-
"sns"
|
|
6311
|
-
];
|
|
6312
|
-
var SKIN = {};
|
|
6313
|
-
var def = (kinds, skin) => {
|
|
6314
|
-
for (const k2 of kinds) SKIN[k2] = skin;
|
|
6315
|
-
};
|
|
6316
|
-
var primary = (chip3) => ({ chip: chip3, primary: true, fill: "paper", dashed: false });
|
|
6317
|
-
var secondary = (chip3) => ({ chip: chip3, primary: false, fill: "paper-2", dashed: false });
|
|
6318
|
-
var external = (chip3) => ({ chip: chip3, primary: true, fill: "paper", dashed: true });
|
|
6319
|
-
def(["client", "user", "person", "actor", "users", "crowd", "browser", "web", "mobile", "device", "iot"], primary("CLIENT"));
|
|
6320
|
-
def(["service", "microservice", "compute", "container", "worker", "etl"], primary("SVC"));
|
|
6321
|
-
def(["data"], primary("DATA"));
|
|
6322
|
-
def(["store", "db", "database", "postgres", "mysql", "mongo", "mongodb", "dynamo"], secondary("DB"));
|
|
6323
|
-
def(["shard", "shards", "sharded", "replica", "replicas", "replicaset"], secondary("DB"));
|
|
6324
|
-
def(["bucket", "blob", "object", "s3"], secondary("BUCKET"));
|
|
6325
|
-
def(["warehouse", "lake"], secondary("WAREHOUSE"));
|
|
6326
|
-
def(["queue", "mq", "broker", "sqs", "rabbitmq"], secondary("QUEUE"));
|
|
6327
|
-
def(["topic"], secondary("TOPIC"));
|
|
6328
|
-
def(["stream", "kafka", "kinesis"], secondary("BUS"));
|
|
6329
|
-
def(["cache", "redis", "memcached"], secondary("CACHE"));
|
|
6330
|
-
def(["search", "index", "elasticsearch", "opensearch"], secondary("SEARCH"));
|
|
6331
|
-
def(["registry"], secondary("REGISTRY"));
|
|
6332
|
-
def(["gateway", "proxy"], primary("GATEWAY"));
|
|
6333
|
-
def(["lb"], primary("LB"));
|
|
6334
|
-
def(["function", "lambda"], primary("FN"));
|
|
6335
|
-
def(["cdn"], external("EDGE"));
|
|
6336
|
-
def(["external"], external("EXT"));
|
|
6337
|
-
def(["producer"], primary("PRODUCER"));
|
|
6338
|
-
def(["consumer"], primary("CONSUMER"));
|
|
6339
|
-
def(["context"], primary("CONTEXT"));
|
|
6340
|
-
def(["firewall", "waf", "shield"], primary("WAF"));
|
|
6341
|
-
def(["dns"], external("DNS"));
|
|
6342
|
-
def(["auth", "identity", "idp", "iam", "oauth", "sso"], primary("AUTH"));
|
|
6343
|
-
def(["monitor", "observability", "metrics", "logs", "tracing", "apm"], primary("OBS"));
|
|
6344
|
-
def(["scheduler", "cron", "job"], primary("CRON"));
|
|
6345
|
-
def(["analytics", "bi"], primary("ANALYTICS"));
|
|
6346
|
-
def(["ci", "cicd", "pipeline"], primary("CI"));
|
|
6347
|
-
def(["git", "repo", "scm"], secondary("GIT"));
|
|
6348
|
-
def(["email", "sms"], external("EMAIL"));
|
|
6349
|
-
def(["config", "settings"], secondary("CONFIG"));
|
|
6350
|
-
def(["ml", "model", "llm", "agent", "ai"], primary("AI"));
|
|
6351
|
-
def(["vm", "server", "host"], primary("HOST"));
|
|
6352
|
-
def(["secrets", "vault", "kms"], secondary("SECRETS"));
|
|
6353
|
-
def(["notification", "webhook"], external("WEBHOOK"));
|
|
6354
|
-
def(["region", "geo", "globe"], external("REGION"));
|
|
6355
|
-
def(["deployment"], primary("DEPLOY"));
|
|
6356
|
-
def(["pod"], primary("POD"));
|
|
6357
|
-
def(["ingress"], primary("INGRESS"));
|
|
6358
|
-
def(["configmap"], secondary("CONFIG"));
|
|
6359
|
-
def(["secret"], secondary("SECRETS"));
|
|
6360
|
-
def(["cronjob"], primary("CRON"));
|
|
6361
|
-
def(["node"], primary("NODE"));
|
|
6362
|
-
def(["namespace"], secondary("NS"));
|
|
6363
|
-
def(["cluster"], primary("CLUSTER"));
|
|
6364
|
-
def(["sns"], secondary("TOPIC"));
|
|
6365
|
-
function nodeSkin(kind) {
|
|
6366
|
-
const k2 = (kind ?? "").trim().toLowerCase();
|
|
6367
|
-
if (k2 === "") return { chip: "", primary: true, fill: "paper", dashed: false };
|
|
6368
|
-
return SKIN[k2] ?? primary(k2.toUpperCase());
|
|
6002
|
+
function er(e) {
|
|
6003
|
+
e.edges().forEach((n) => {
|
|
6004
|
+
let t = e.edge(n);
|
|
6005
|
+
if (Object.hasOwn(t, "x")) switch ((t.labelpos === "l" || t.labelpos === "r") && (t.width -= t.labeloffset), t.labelpos) {
|
|
6006
|
+
case "l":
|
|
6007
|
+
t.x -= t.width / 2 + t.labeloffset;
|
|
6008
|
+
break;
|
|
6009
|
+
case "r":
|
|
6010
|
+
t.x += t.width / 2 + t.labeloffset;
|
|
6011
|
+
break;
|
|
6012
|
+
}
|
|
6013
|
+
});
|
|
6014
|
+
}
|
|
6015
|
+
function nr(e) {
|
|
6016
|
+
e.edges().forEach((n) => {
|
|
6017
|
+
let t = e.edge(n);
|
|
6018
|
+
t.reversed && t.points.reverse();
|
|
6019
|
+
});
|
|
6020
|
+
}
|
|
6021
|
+
function tr(e) {
|
|
6022
|
+
e.nodes().forEach((n) => {
|
|
6023
|
+
if (e.children(n).length) {
|
|
6024
|
+
let t = e.node(n), r5 = e.node(t.borderTop), o = e.node(t.borderBottom), i = e.node(t.borderLeft[t.borderLeft.length - 1]), s = e.node(t.borderRight[t.borderRight.length - 1]);
|
|
6025
|
+
t.width = Math.abs(s.x - i.x), t.height = Math.abs(o.y - r5.y), t.x = i.x + t.width / 2, t.y = r5.y + t.height / 2;
|
|
6026
|
+
}
|
|
6027
|
+
}), e.nodes().forEach((n) => {
|
|
6028
|
+
e.node(n).dummy === "border" && e.removeNode(n);
|
|
6029
|
+
});
|
|
6030
|
+
}
|
|
6031
|
+
function rr(e) {
|
|
6032
|
+
e.edges().forEach((n) => {
|
|
6033
|
+
if (n.v === n.w) {
|
|
6034
|
+
let t = e.node(n.v);
|
|
6035
|
+
t.selfEdges || (t.selfEdges = []), t.selfEdges.push({ e: n, label: e.edge(n) }), e.removeEdge(n);
|
|
6036
|
+
}
|
|
6037
|
+
});
|
|
6038
|
+
}
|
|
6039
|
+
function or(e) {
|
|
6040
|
+
N(e).forEach((t) => {
|
|
6041
|
+
let r5 = 0;
|
|
6042
|
+
t.forEach((o, i) => {
|
|
6043
|
+
let s = e.node(o);
|
|
6044
|
+
s.order = i + r5, (s.selfEdges || []).forEach((a) => {
|
|
6045
|
+
w(e, "selfedge", { width: a.label.width, height: a.label.height, rank: s.rank, order: i + ++r5, e: a.e, label: a.label }, "_se");
|
|
6046
|
+
}), delete s.selfEdges;
|
|
6047
|
+
});
|
|
6048
|
+
});
|
|
6369
6049
|
}
|
|
6370
|
-
function
|
|
6371
|
-
|
|
6372
|
-
|
|
6050
|
+
function ir(e) {
|
|
6051
|
+
e.nodes().forEach((n) => {
|
|
6052
|
+
let t = e.node(n);
|
|
6053
|
+
if (t.dummy === "selfedge") {
|
|
6054
|
+
let r5 = t, o = e.node(r5.e.v), i = o.x + o.width / 2, s = o.y, a = t.x - i, d = o.height / 2;
|
|
6055
|
+
e.setEdge(r5.e, r5.label), e.removeNode(n), r5.label.points = [{ x: i + 2 * a / 3, y: s - d }, { x: i + 5 * a / 6, y: s - d }, { x: i + a, y: s }, { x: i + 5 * a / 6, y: s + d }, { x: i + 2 * a / 3, y: s + d }], r5.label.x = t.x, r5.label.y = t.y;
|
|
6056
|
+
}
|
|
6057
|
+
});
|
|
6373
6058
|
}
|
|
6374
|
-
function
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
}
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
}
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
}
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
}
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
}
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
if (k2 === "stream" || k2 === "kafka" || k2 === "kinesis") {
|
|
6401
|
-
const wave = (dy) => `<path d="M${x2 + 1} ${y + 4 + dy} q 3.5 -3 7 0 t 7 0" fill="none" stroke="${c}" stroke-width="1.4"/>`;
|
|
6402
|
-
return `<g>${wave(0)}${wave(4.5)}${wave(9)}</g>`;
|
|
6403
|
-
}
|
|
6404
|
-
if (k2 === "warehouse" || k2 === "lake") {
|
|
6405
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x2 + 8}" cy="${y + 3}" rx="7" ry="3"/><path d="M${x2 + 1} ${y + 3} V ${y + 13}"/><path d="M${x2 + 15} ${y + 3} V ${y + 13}"/><path d="M${x2 + 1} ${y + 8} a 7 3 0 0 0 14 0"/><path d="M${x2 + 1} ${y + 13} a 7 3 0 0 0 14 0"/></g>`;
|
|
6406
|
-
}
|
|
6407
|
-
if (k2 === "search" || k2 === "index") {
|
|
6408
|
-
return `<g stroke="${c}" stroke-width="1.4" fill="none"><circle cx="${x2 + 6.5}" cy="${y + 6.5}" r="5"/><path d="M${x2 + 10.5} ${y + 10.5} L ${x2 + 15} ${y + 15}"/></g>`;
|
|
6409
|
-
}
|
|
6410
|
-
if (k2 === "ml" || k2 === "model" || k2 === "llm" || k2 === "agent" || k2 === "ai") {
|
|
6411
|
-
return `<path d="M${x2 + 8} ${y + 1} L ${x2 + 9.8} ${y + 6.2} L ${x2 + 15} ${y + 8} L ${x2 + 9.8} ${y + 9.8} L ${x2 + 8} ${y + 15} L ${x2 + 6.2} ${y + 9.8} L ${x2 + 1} ${y + 8} L ${x2 + 6.2} ${y + 6.2} Z" fill="${c}"/>`;
|
|
6412
|
-
}
|
|
6413
|
-
if (k2 === "user" || k2 === "person" || k2 === "actor") {
|
|
6414
|
-
return `<g fill="${c}"><circle cx="${x2 + 8}" cy="${y + 4.5}" r="3.5"/><path d="M ${x2 + 2} ${y + 15} a 6 6.5 0 0 1 12 0 z"/></g>`;
|
|
6415
|
-
}
|
|
6416
|
-
if (k2 === "browser" || k2 === "web") {
|
|
6417
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 1}" y="${y + 2}" width="14" height="12" rx="2"/><path d="M${x2 + 1} ${y + 6} H ${x2 + 15}"/></g>`;
|
|
6418
|
-
}
|
|
6419
|
-
if (k2 === "mobile") {
|
|
6420
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 4}" y="${y + 1}" width="8" height="14" rx="2"/><path d="M${x2 + 7} ${y + 12.5} H ${x2 + 9}"/></g>`;
|
|
6421
|
-
}
|
|
6422
|
-
if (k2 === "vm" || k2 === "server" || k2 === "host") {
|
|
6423
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 2}" y="${y + 2}" width="12" height="5" rx="1.2"/><rect x="${x2 + 2}" y="${y + 9}" width="12" height="5" rx="1.2"/><path d="M${x2 + 4.5} ${y + 4.5} H ${x2 + 7} M${x2 + 4.5} ${y + 11.5} H ${x2 + 7}"/></g>`;
|
|
6424
|
-
}
|
|
6425
|
-
if (k2 === "secrets" || k2 === "vault" || k2 === "kms") {
|
|
6426
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 3}" y="${y + 7}" width="10" height="8" rx="1.5"/><path d="M${x2 + 5} ${y + 7} V ${y + 5} a 3 3 0 0 1 6 0 V ${y + 7}"/></g>`;
|
|
6427
|
-
}
|
|
6428
|
-
if (k2 === "notification" || k2 === "webhook") {
|
|
6429
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><path d="M${x2 + 3} ${y + 11} a 5 5 0 0 1 1.6 -3.6 V ${y + 5} a 3.4 3.4 0 0 1 6.8 0 v 2.4 a 5 5 0 0 1 1.6 3.6 z"/><path d="M${x2 + 6.5} ${y + 13.5} a 1.5 1.5 0 0 0 3 0"/></g>`;
|
|
6430
|
-
}
|
|
6431
|
-
if (k2 === "email" || k2 === "sms") {
|
|
6432
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><rect x="${x2 + 1}" y="${y + 3}" width="14" height="10" rx="1.5"/><path d="M${x2 + 1.5} ${y + 4} L ${x2 + 8} ${y + 9} L ${x2 + 14.5} ${y + 4}"/></g>`;
|
|
6433
|
-
}
|
|
6434
|
-
if (k2 === "registry") {
|
|
6435
|
-
return `<g stroke="${c}" stroke-width="1.2" fill="none"><rect x="${x2 + 1}" y="${y + 8}" width="6" height="6" rx="1"/><rect x="${x2 + 9}" y="${y + 8}" width="6" height="6" rx="1"/><rect x="${x2 + 5}" y="${y + 1}" width="6" height="6" rx="1"/></g>`;
|
|
6436
|
-
}
|
|
6437
|
-
if (k2 === "ci" || k2 === "cicd" || k2 === "pipeline") {
|
|
6438
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><circle cx="${x2 + 8}" cy="${y + 8}" r="7"/><path d="M${x2 + 6} ${y + 5} L ${x2 + 11.5} ${y + 8} L ${x2 + 6} ${y + 11} Z" fill="${c}" stroke="none"/></g>`;
|
|
6439
|
-
}
|
|
6440
|
-
if (k2 === "git" || k2 === "repo" || k2 === "scm") {
|
|
6441
|
-
return `<g stroke="${c}" stroke-width="1.3" fill="none"><circle cx="${x2 + 4}" cy="${y + 3.5}" r="2.5"/><circle cx="${x2 + 4}" cy="${y + 12.5}" r="2.5"/><circle cx="${x2 + 12}" cy="${y + 6}" r="2.5"/><path d="M${x2 + 4} ${y + 6} V ${y + 10} M${x2 + 4} ${y + 8} q 0 -2 3 -2 h 2.5"/></g>`;
|
|
6059
|
+
function ue(e, n) {
|
|
6060
|
+
return O(T(e, n), Number);
|
|
6061
|
+
}
|
|
6062
|
+
function ce(e) {
|
|
6063
|
+
let n = {};
|
|
6064
|
+
return e && Object.entries(e).forEach(([t, r5]) => {
|
|
6065
|
+
typeof t == "string" && (t = t.toLowerCase()), n[t] = r5;
|
|
6066
|
+
}), n;
|
|
6067
|
+
}
|
|
6068
|
+
function fe(e) {
|
|
6069
|
+
let n = N(e), t = new p({ compound: true, multigraph: true }).setGraph({});
|
|
6070
|
+
return e.nodes().forEach((r5) => {
|
|
6071
|
+
t.setNode(r5, { label: r5 }), t.setParent(r5, "layer" + e.node(r5).rank);
|
|
6072
|
+
}), e.edges().forEach((r5) => t.setEdge(r5.v, r5.w, {}, r5.name)), n.forEach((r5, o) => {
|
|
6073
|
+
let i = "layer" + o;
|
|
6074
|
+
t.setNode(i, { rank: "same" }), r5.reduce((s, a) => (t.setEdge(s, a, { style: "invis" }), a));
|
|
6075
|
+
}), t;
|
|
6076
|
+
}
|
|
6077
|
+
var sr = { graphlib: z, version: U, layout: he, debug: fe, util: { time: P, notime: M } };
|
|
6078
|
+
var To = sr;
|
|
6079
|
+
|
|
6080
|
+
// src/blocks/autoLayout.ts
|
|
6081
|
+
function ensureGrid(items, edges, rankdir) {
|
|
6082
|
+
const allPlaced = items.length > 0 && items.every((n) => n.col !== void 0 && n.row !== void 0);
|
|
6083
|
+
if (allPlaced) {
|
|
6084
|
+
return items.map((n) => ({ ...n, col: n.col, row: n.row }));
|
|
6442
6085
|
}
|
|
6443
|
-
|
|
6444
|
-
|
|
6086
|
+
const grid = autoGrid(
|
|
6087
|
+
items.map((n) => n.id),
|
|
6088
|
+
edges,
|
|
6089
|
+
rankdir
|
|
6090
|
+
);
|
|
6091
|
+
return items.map((n) => {
|
|
6092
|
+
const g = grid.get(n.id) ?? { col: 1, row: 1 };
|
|
6093
|
+
return { ...n, col: g.col, row: g.row };
|
|
6094
|
+
});
|
|
6095
|
+
}
|
|
6096
|
+
function autoGrid(ids, edges, rankdir) {
|
|
6097
|
+
const idSet = new Set(ids);
|
|
6098
|
+
const g = new To.graphlib.Graph();
|
|
6099
|
+
g.setGraph({ rankdir, nodesep: 16, ranksep: 16, marginx: 0, marginy: 0 });
|
|
6100
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
6101
|
+
for (const id of ids) g.setNode(id, { width: 10, height: 10 });
|
|
6102
|
+
for (const e of edges) {
|
|
6103
|
+
if (e.from !== e.to && idSet.has(e.from) && idSet.has(e.to)) g.setEdge(e.from, e.to);
|
|
6445
6104
|
}
|
|
6446
|
-
|
|
6447
|
-
|
|
6105
|
+
To.layout(g);
|
|
6106
|
+
const pos3 = ids.map((id) => {
|
|
6107
|
+
const n = g.node(id);
|
|
6108
|
+
return { id, x: Math.round(n?.x ?? 0), y: Math.round(n?.y ?? 0) };
|
|
6109
|
+
});
|
|
6110
|
+
const out = /* @__PURE__ */ new Map();
|
|
6111
|
+
if (rankdir === "TB") {
|
|
6112
|
+
const ranks = [...new Set(pos3.map((p2) => p2.y))].sort((a, b) => a - b);
|
|
6113
|
+
ranks.forEach((yv, ri) => {
|
|
6114
|
+
pos3.filter((p2) => p2.y === yv).sort((a, b) => a.x - b.x).forEach((p2, ci) => out.set(p2.id, { col: ci + 1, row: ri + 1 }));
|
|
6115
|
+
});
|
|
6116
|
+
} else {
|
|
6117
|
+
const ranks = [...new Set(pos3.map((p2) => p2.x))].sort((a, b) => a - b);
|
|
6118
|
+
ranks.forEach((xv, ci) => {
|
|
6119
|
+
pos3.filter((p2) => p2.x === xv).sort((a, b) => a.y - b.y).forEach((p2, ri) => out.set(p2.id, { col: ci + 1, row: ri + 1 }));
|
|
6120
|
+
});
|
|
6448
6121
|
}
|
|
6449
|
-
|
|
6450
|
-
|
|
6122
|
+
return out;
|
|
6123
|
+
}
|
|
6124
|
+
|
|
6125
|
+
// src/blocks/flow.ts
|
|
6126
|
+
var AI_CHIP = {
|
|
6127
|
+
agent: "AGENT",
|
|
6128
|
+
llm: "LLM",
|
|
6129
|
+
tool: "TOOL",
|
|
6130
|
+
human: "HUMAN",
|
|
6131
|
+
memory: "MEMORY"
|
|
6132
|
+
};
|
|
6133
|
+
function flowRevealOrder(nodes, edges) {
|
|
6134
|
+
const ids = new Set(nodes.map((n) => n.id));
|
|
6135
|
+
const indeg = /* @__PURE__ */ new Map();
|
|
6136
|
+
const outs = /* @__PURE__ */ new Map();
|
|
6137
|
+
for (const n of nodes) {
|
|
6138
|
+
indeg.set(n.id, 0);
|
|
6139
|
+
outs.set(n.id, []);
|
|
6451
6140
|
}
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6141
|
+
for (const e of edges) {
|
|
6142
|
+
if (!ids.has(e.from) || !ids.has(e.to) || e.from === e.to) continue;
|
|
6143
|
+
indeg.set(e.to, (indeg.get(e.to) ?? 0) + 1);
|
|
6144
|
+
outs.get(e.from)?.push(e.to);
|
|
6455
6145
|
}
|
|
6456
|
-
|
|
6457
|
-
|
|
6146
|
+
let roots = nodes.filter((n) => n.kind === "start").map((n) => n.id);
|
|
6147
|
+
if (roots.length === 0) roots = nodes.filter((n) => (indeg.get(n.id) ?? 0) === 0).map((n) => n.id);
|
|
6148
|
+
if (roots.length === 0 && nodes[0] !== void 0) roots = [nodes[0].id];
|
|
6149
|
+
const order = /* @__PURE__ */ new Map();
|
|
6150
|
+
const queue = [...roots];
|
|
6151
|
+
while (queue.length > 0) {
|
|
6152
|
+
const id = queue.shift();
|
|
6153
|
+
if (order.has(id)) continue;
|
|
6154
|
+
order.set(id, order.size);
|
|
6155
|
+
for (const to of outs.get(id) ?? []) {
|
|
6156
|
+
const d = (indeg.get(to) ?? 0) - 1;
|
|
6157
|
+
indeg.set(to, d);
|
|
6158
|
+
if (d <= 0 && !order.has(to)) queue.push(to);
|
|
6159
|
+
}
|
|
6458
6160
|
}
|
|
6459
|
-
|
|
6460
|
-
|
|
6161
|
+
for (const n of nodes) if (!order.has(n.id)) order.set(n.id, order.size);
|
|
6162
|
+
return order;
|
|
6163
|
+
}
|
|
6164
|
+
var ERR_LABEL_RE = /^(no|fail|failed|error|reject|rejected)\b/i;
|
|
6165
|
+
var CELL_W = 160;
|
|
6166
|
+
var CELL_H = 64;
|
|
6167
|
+
var NODE_W = 150;
|
|
6168
|
+
var NODE_H = 52;
|
|
6169
|
+
function renderFlowSvg(data) {
|
|
6170
|
+
const edges = data.edges ?? [];
|
|
6171
|
+
const groups = data.groups ?? [];
|
|
6172
|
+
const rawNodes = data.nodes ?? [];
|
|
6173
|
+
const quick = !(rawNodes.length > 0 && rawNodes.every((n) => n.col !== void 0 && n.row !== void 0));
|
|
6174
|
+
const nodes = ensureGrid(rawNodes, edges, data.dir ?? "LR");
|
|
6175
|
+
const cellW = CELL_W;
|
|
6176
|
+
const cellH = CELL_H;
|
|
6177
|
+
const gapX = 56;
|
|
6178
|
+
const gapY = 48;
|
|
6179
|
+
const nestPad = nestingPads(groups);
|
|
6180
|
+
const padX = (groups.length > 0 ? GROUP_PADS.padX : 22) + nestPad.padX;
|
|
6181
|
+
const padTop = (groups.length > 0 ? GROUP_PADS.padTop : 22) + nestPad.padTop;
|
|
6182
|
+
const padBot = (groups.length > 0 ? GROUP_PADS.padBot : 18) + nestPad.padBot;
|
|
6183
|
+
const gx = groupExtent(groups);
|
|
6184
|
+
const cols = Math.max(1, ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)), gx.cols);
|
|
6185
|
+
const rows = Math.max(1, ...nodes.map((n) => n.row), gx.rows);
|
|
6186
|
+
const xOf = (c) => padX + (c - 1) * (cellW + gapX);
|
|
6187
|
+
const yOf = (r5) => padTop + (r5 - 1) * (cellH + gapY);
|
|
6188
|
+
const cellFor = (n) => ({
|
|
6189
|
+
x: xOf(n.col),
|
|
6190
|
+
y: yOf(n.row),
|
|
6191
|
+
w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,
|
|
6192
|
+
h: cellH
|
|
6193
|
+
});
|
|
6194
|
+
const boxFor = (n) => {
|
|
6195
|
+
const c = cellFor(n);
|
|
6196
|
+
if ((n.kind ?? "process") === "decision") return c;
|
|
6197
|
+
const dx = (cellW - NODE_W) / 2;
|
|
6198
|
+
const dy = (cellH - NODE_H) / 2;
|
|
6199
|
+
return { x: c.x + dx, y: c.y + dy, w: c.w - dx * 2, h: NODE_H };
|
|
6200
|
+
};
|
|
6201
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
6202
|
+
const width = padX * 2 + cols * cellW + (cols - 1) * gapX;
|
|
6203
|
+
const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;
|
|
6204
|
+
const isErrEdge = (e) => e.kind === "error" || ERR_LABEL_RE.test(e.label ?? "");
|
|
6205
|
+
const errTargets = new Set(edges.filter(isErrEdge).map((e) => e.to));
|
|
6206
|
+
const accentIds = new Set(
|
|
6207
|
+
nodes.filter((n) => n.kind === "end" && !errTargets.has(n.id) && !ERR_LABEL_RE.test(n.label)).map((n) => n.id)
|
|
6208
|
+
);
|
|
6209
|
+
const gridMeta = gridMetaAttrs({ quick, cols, rows, cellW, cellH, gapX, gapY, padX, padTop });
|
|
6210
|
+
const a11y = svgName("Flowchart", data.title, [countPhrase(nodes.length, "step")]);
|
|
6211
|
+
let s = `<svg viewBox="0 0 ${width} ${height}"${a11y.attrs}${gridMeta}>${a11y.title}`;
|
|
6212
|
+
if (groups.length > 0) s += gridGroupsSvg(groups, { xOf, yOf, cellW, cellH, gapX, gapY, skin: true });
|
|
6213
|
+
const used = { plain: false, dashed: false, error: false, accent: false };
|
|
6214
|
+
const pending = [];
|
|
6215
|
+
const lanes = edgeLanes(edges);
|
|
6216
|
+
const order = flowRevealOrder(nodes, edges);
|
|
6217
|
+
const stepOf = (id) => order.get(id) ?? 0;
|
|
6218
|
+
const entries = entryPortOffsets(edges, (id) => {
|
|
6219
|
+
const n = byId.get(id);
|
|
6220
|
+
return n !== void 0 ? boxFor(n) : void 0;
|
|
6221
|
+
});
|
|
6222
|
+
s += `<g${bl("edges")}>`;
|
|
6223
|
+
edges.forEach((e, ei) => {
|
|
6224
|
+
const A2 = byId.get(e.from);
|
|
6225
|
+
const B3 = byId.get(e.to);
|
|
6226
|
+
if (!A2 || !B3) return;
|
|
6227
|
+
const p2 = ortho(boxFor(A2), boxFor(B3), lanes[ei] ?? 0, entries[ei] ?? 0);
|
|
6228
|
+
const isErr = isErrEdge(e);
|
|
6229
|
+
const isAccent = !isErr && accentIds.has(e.to);
|
|
6230
|
+
const isDashed = !isErr && e.kind === "dashed";
|
|
6231
|
+
const stroke = isErr ? "var(--negative)" : isAccent ? "var(--accent)" : "var(--muted)";
|
|
6232
|
+
const marker2 = isErr ? "skErr" : isAccent ? "skAccent" : isDashed ? "skOpen" : "skArrow";
|
|
6233
|
+
const sw = isAccent ? 1.75 : 1.5;
|
|
6234
|
+
const dash = isDashed ? ' stroke-dasharray="5 4"' : "";
|
|
6235
|
+
if (isErr) used.error = true;
|
|
6236
|
+
else if (isAccent) used.accent = true;
|
|
6237
|
+
else if (isDashed) used.dashed = true;
|
|
6238
|
+
else used.plain = true;
|
|
6239
|
+
const reveal = Math.max(stepOf(e.from), stepOf(e.to));
|
|
6240
|
+
s += `<path d="${p2.d}" fill="none" stroke="${stroke}" stroke-width="${sw}"${dash} marker-end="url(#${marker2})"${bp(`edges.${ei}`)}${revealAttr(reveal)}/>`;
|
|
6241
|
+
pending.push({
|
|
6242
|
+
lx: p2.lx,
|
|
6243
|
+
ly: p2.ly,
|
|
6244
|
+
...e.label !== void 0 ? { label: e.label } : {},
|
|
6245
|
+
err: isErr,
|
|
6246
|
+
accent: isAccent,
|
|
6247
|
+
path: `edges.${ei}`,
|
|
6248
|
+
reveal
|
|
6249
|
+
});
|
|
6250
|
+
});
|
|
6251
|
+
s += `</g>`;
|
|
6252
|
+
const kindsUsed = /* @__PURE__ */ new Set();
|
|
6253
|
+
s += `<g${bl("nodes")}>`;
|
|
6254
|
+
nodes.forEach((n, ni) => {
|
|
6255
|
+
const kind = n.kind ?? "process";
|
|
6256
|
+
kindsUsed.add(kind);
|
|
6257
|
+
const r5 = boxFor(n);
|
|
6258
|
+
const cx = r5.x + r5.w / 2;
|
|
6259
|
+
const cy = r5.y + r5.h / 2;
|
|
6260
|
+
const accent = accentIds.has(n.id);
|
|
6261
|
+
const chip3 = AI_CHIP[kind];
|
|
6262
|
+
const secondary2 = kind === "start" || kind === "memory";
|
|
6263
|
+
const stroke = accent ? "var(--accent)" : secondary2 ? "var(--rule-solid)" : "var(--ink)";
|
|
6264
|
+
const sw = accent ? 1.5 : secondary2 ? 1 : 1.5;
|
|
6265
|
+
const fill = accent ? "var(--accent-tint)" : secondary2 ? "var(--paper-2)" : "var(--paper)";
|
|
6266
|
+
const dash = kind === "human" ? ' stroke-dasharray="4 3"' : "";
|
|
6267
|
+
let shape;
|
|
6268
|
+
if (kind === "decision") {
|
|
6269
|
+
shape = `<polygon points="${cx},${r5.y} ${r5.x + r5.w},${cy} ${cx},${r5.y + r5.h} ${r5.x},${cy}" fill="${fill}" stroke="${stroke}" stroke-width="${sw}" stroke-linejoin="round"/>`;
|
|
6270
|
+
} else if (kind === "start" || kind === "end") {
|
|
6271
|
+
shape = `<rect x="${r5.x}" y="${r5.y}" width="${r5.w}" height="${r5.h}" rx="${r5.h / 2}" fill="${fill}" stroke="${stroke}" stroke-width="${sw}"/>`;
|
|
6272
|
+
} else {
|
|
6273
|
+
shape = `<rect x="${r5.x}" y="${r5.y}" width="${r5.w}" height="${r5.h}" rx="4" fill="${fill}" stroke="${stroke}" stroke-width="${sw}"${dash}/>`;
|
|
6274
|
+
}
|
|
6275
|
+
if (chip3 !== void 0) {
|
|
6276
|
+
shape += `<text x="${r5.x + 8}" y="${r5.y + 11}" class="blk-chip t-sub">${chip3}</text>`;
|
|
6277
|
+
}
|
|
6278
|
+
const nl = n.label.indexOf("\n");
|
|
6279
|
+
const name = nl >= 0 ? n.label.slice(0, nl) : n.label;
|
|
6280
|
+
const sub = nl >= 0 ? n.label.slice(nl + 1).replace(/\s+/g, " ").trim() : "";
|
|
6281
|
+
const maxChars = kind === "decision" ? 18 : 20;
|
|
6282
|
+
const lines = sub.length > 0 ? wrapText(name, maxChars, 1) : wrapText(name, maxChars, 2);
|
|
6283
|
+
const tone = accent ? " c-accent" : "";
|
|
6284
|
+
const dy = chip3 !== void 0 ? 4 : 0;
|
|
6285
|
+
let texts = "";
|
|
6286
|
+
if (kind === "agent" || kind === "llm") {
|
|
6287
|
+
const nm = wrapText(name, 17, 1)[0] ?? name;
|
|
6288
|
+
texts = nodeGlyph("agent", r5.x + 10, r5.y + 19, accent ? "var(--accent)" : "var(--ink)");
|
|
6289
|
+
texts += `<text x="${r5.x + 30}" y="${r5.y + 30}" class="al-name${tone}">${escapeHtml(nm)}</text>`;
|
|
6290
|
+
if (sub.length > 0) {
|
|
6291
|
+
const chipW = Math.min(r5.w - 20, 12 + sub.length * 5.6);
|
|
6292
|
+
texts += `<rect x="${r5.x + 10}" y="${r5.y + 36}" width="${chipW.toFixed(1)}" height="13" rx="3" fill="var(--paper)" stroke="var(--rule-solid)" stroke-width="1"/><text x="${(r5.x + 10 + chipW / 2).toFixed(1)}" y="${r5.y + 45.5}" text-anchor="middle" class="al-chip">${escapeHtml(sub)}</text>`;
|
|
6293
|
+
}
|
|
6294
|
+
} else if (sub.length > 0) {
|
|
6295
|
+
texts = `<text x="${cx}" y="${cy - 1 + dy}" class="fc-label t-name${tone}">${escapeHtml(lines[0] ?? name)}</text><text x="${cx}" y="${cy + 12 + dy}" class="fc-sub t-sub" text-anchor="middle">${escapeHtml(sub)}</text>`;
|
|
6296
|
+
} else {
|
|
6297
|
+
texts = lines.map(
|
|
6298
|
+
(ln2, j2) => `<text x="${cx}" y="${cy + 4.5 + dy - (lines.length - 1) * 7.5 + j2 * 15}" class="fc-label t-name${tone}">${escapeHtml(ln2)}</text>`
|
|
6299
|
+
).join("");
|
|
6300
|
+
}
|
|
6301
|
+
s += `<g${bp(`nodes.${ni}`)}${nodeCellAttrs(n.col, n.row, n.w ?? 1)}${revealAttr(stepOf(n.id))}>${shape}${texts}</g>`;
|
|
6302
|
+
});
|
|
6303
|
+
s += `</g>`;
|
|
6304
|
+
const { overlay, legend: steps } = edgeLabelLayer(pending, nodes.map((n) => boxFor(n)), { skin: true });
|
|
6305
|
+
s += overlay;
|
|
6306
|
+
s += `</svg>`;
|
|
6307
|
+
const items = [];
|
|
6308
|
+
if (kindsUsed.has("start")) items.push({ swatch: "node-fill2", label: "start" });
|
|
6309
|
+
if (kindsUsed.has("process")) items.push({ swatch: "node", label: "step" });
|
|
6310
|
+
if (kindsUsed.has("decision")) items.push({ swatch: "node", label: "decision (diamond)" });
|
|
6311
|
+
if (kindsUsed.has("agent")) items.push({ swatch: "node", label: "AGENT \xB7 autonomous step" });
|
|
6312
|
+
if (kindsUsed.has("llm")) items.push({ swatch: "node", label: "LLM \xB7 model call" });
|
|
6313
|
+
if (kindsUsed.has("tool")) items.push({ swatch: "node", label: "TOOL \xB7 retrieval / API / code" });
|
|
6314
|
+
if (kindsUsed.has("human")) items.push({ swatch: "node-dashed", label: "HUMAN \xB7 review gate" });
|
|
6315
|
+
if (kindsUsed.has("memory")) items.push({ swatch: "node-fill2", label: "MEMORY \xB7 store" });
|
|
6316
|
+
if (kindsUsed.has("end") && [...accentIds].length < nodes.filter((n) => n.kind === "end").length) {
|
|
6317
|
+
items.push({ swatch: "node", label: "exit" });
|
|
6461
6318
|
}
|
|
6462
|
-
if (
|
|
6463
|
-
|
|
6319
|
+
if (used.plain) items.push({ swatch: "edge", label: "next" });
|
|
6320
|
+
if (used.dashed) items.push({ swatch: "edge-dashed", label: "optional" });
|
|
6321
|
+
if (used.error) items.push({ swatch: "edge-error", label: "error path" });
|
|
6322
|
+
if (accentIds.size > 0) items.push({ swatch: "node-accent", label: "happy path" });
|
|
6323
|
+
return { svg: s + steps, legend: renderLegend(items) };
|
|
6324
|
+
}
|
|
6325
|
+
function renderFlowFrame(data, tag) {
|
|
6326
|
+
const { svg, legend } = renderFlowSvg(data);
|
|
6327
|
+
return diagramFrame(
|
|
6328
|
+
{
|
|
6329
|
+
tag,
|
|
6330
|
+
...data.title !== void 0 ? { title: data.title } : {},
|
|
6331
|
+
...data.description !== void 0 ? { desc: data.description } : {},
|
|
6332
|
+
...legend.length > 0 ? { legendHtml: legend } : {}
|
|
6333
|
+
},
|
|
6334
|
+
svg
|
|
6335
|
+
);
|
|
6336
|
+
}
|
|
6337
|
+
function renderFlow(data) {
|
|
6338
|
+
return renderFlowFrame(data, data.variant === "dag" ? "DAG" : "FLOW");
|
|
6339
|
+
}
|
|
6340
|
+
|
|
6341
|
+
// src/blocks/state.ts
|
|
6342
|
+
var ERR_RE = /\b(error|fail|failed|failure|reject|rejected|cancel|cancelled|canceled|abort|aborted|timeout|timed out|expired|dead)\b/i;
|
|
6343
|
+
function nameLines(s) {
|
|
6344
|
+
return wrapText(s.name ?? "", 23, 3);
|
|
6345
|
+
}
|
|
6346
|
+
function rectFor(s, cellW, cellH, gapX, gapY, padX, padTop) {
|
|
6347
|
+
const cx = padX + (s.col - 1) * (cellW + gapX) + cellW / 2;
|
|
6348
|
+
const cy = padTop + (s.row - 1) * (cellH + gapY) + cellH / 2;
|
|
6349
|
+
if (s.kind === "start" || s.kind === "terminal") {
|
|
6350
|
+
return { x: cx - 13, y: cy - 13, w: 26, h: 26, cx, cy };
|
|
6464
6351
|
}
|
|
6465
|
-
|
|
6466
|
-
|
|
6352
|
+
const lines = nameLines(s);
|
|
6353
|
+
const longest2 = Math.max(0, ...lines.map((ln2) => ln2.length));
|
|
6354
|
+
const pw = Math.max(96, Math.min(longest2 * 8 + 26, cellW + gapX - 26));
|
|
6355
|
+
const ph = 46 + (Math.max(1, lines.length) - 1) * 15;
|
|
6356
|
+
return { x: cx - pw / 2, y: cy - ph / 2, w: pw, h: ph, cx, cy };
|
|
6357
|
+
}
|
|
6358
|
+
function pillCls(kind) {
|
|
6359
|
+
if (kind === "terminal") return "pill pill-end";
|
|
6360
|
+
if (kind === "wait") return "pill pill-wait";
|
|
6361
|
+
if (kind === "start") return "pill pill-init";
|
|
6362
|
+
return "pill pill-active";
|
|
6363
|
+
}
|
|
6364
|
+
function renderState(data) {
|
|
6365
|
+
const trans = data.transitions ?? [];
|
|
6366
|
+
const rawStates = data.states ?? [];
|
|
6367
|
+
const quick = !(rawStates.length > 0 && rawStates.every((n) => n.col !== void 0 && n.row !== void 0));
|
|
6368
|
+
const states = ensureGrid(rawStates, trans, data.dir ?? "LR");
|
|
6369
|
+
const cellW = 168;
|
|
6370
|
+
const cellH = 64;
|
|
6371
|
+
const gapX = 74;
|
|
6372
|
+
const gapY = 60;
|
|
6373
|
+
const groups = data.groups ?? [];
|
|
6374
|
+
const nestPad = nestingPads(groups);
|
|
6375
|
+
const padX = (groups.length > 0 ? GROUP_PADS.padX : 30) + nestPad.padX;
|
|
6376
|
+
const padTop = (groups.length > 0 ? GROUP_PADS.padTop : 30) + nestPad.padTop;
|
|
6377
|
+
const padBot = (groups.length > 0 ? GROUP_PADS.padBot : 20) + nestPad.padBot;
|
|
6378
|
+
const gx = groupExtent(groups);
|
|
6379
|
+
const cols = Math.max(1, ...states.map((s2) => s2.col), gx.cols);
|
|
6380
|
+
const rows = Math.max(1, ...states.map((s2) => s2.row), gx.rows);
|
|
6381
|
+
const width = padX * 2 + cols * cellW + (cols - 1) * gapX;
|
|
6382
|
+
const height = padTop * 2 + rows * cellH + (rows - 1) * gapY + padBot;
|
|
6383
|
+
const byId = new Map(states.map((s2) => [s2.id, s2]));
|
|
6384
|
+
const isErrTerminal = (s2) => s2 !== void 0 && s2.kind === "terminal" && (ERR_RE.test(s2.name ?? "") || ERR_RE.test(s2.id));
|
|
6385
|
+
const successExits = states.filter((s2) => s2.kind === "terminal" && !isErrTerminal(s2));
|
|
6386
|
+
const accentId = successExits.length === 1 ? successExits[0]?.id : void 0;
|
|
6387
|
+
const gridMeta = gridMetaAttrs({ quick, cols, rows, cellW, cellH, gapX, gapY, padX, padTop });
|
|
6388
|
+
const a11y = svgName("State machine", data.title, [
|
|
6389
|
+
countPhrase(states.length, "state"),
|
|
6390
|
+
countPhrase(trans.length, "transition")
|
|
6391
|
+
]);
|
|
6392
|
+
let s = `<svg viewBox="0 0 ${width} ${height}"${a11y.attrs}${gridMeta}>${a11y.title}`;
|
|
6393
|
+
if (groups.length > 0) {
|
|
6394
|
+
const xOf = (c) => padX + (c - 1) * (cellW + gapX);
|
|
6395
|
+
const yOf = (r5) => padTop + (r5 - 1) * (cellH + gapY);
|
|
6396
|
+
s += gridGroupsSvg(groups, { xOf, yOf, cellW, cellH, gapX, gapY, skin: true });
|
|
6467
6397
|
}
|
|
6468
|
-
|
|
6398
|
+
const numbered = trans.length >= 4;
|
|
6399
|
+
const labels = [];
|
|
6400
|
+
const used = { plain: false, error: false, accent: false };
|
|
6401
|
+
const lanes = edgeLanes(trans);
|
|
6402
|
+
const avoid = states.map((st2) => {
|
|
6403
|
+
const r5 = rectFor(st2, cellW, cellH, gapX, gapY, padX, padTop);
|
|
6404
|
+
return { x: r5.x, y: r5.y, w: r5.w, h: r5.h };
|
|
6405
|
+
});
|
|
6406
|
+
const entries = entryPortOffsets(trans, (id) => {
|
|
6407
|
+
const n = byId.get(id);
|
|
6408
|
+
return n !== void 0 ? rectFor(n, cellW, cellH, gapX, gapY, padX, padTop) : void 0;
|
|
6409
|
+
});
|
|
6410
|
+
trans.forEach((t, ti) => {
|
|
6411
|
+
const A2 = byId.get(t.from);
|
|
6412
|
+
const B3 = byId.get(t.to);
|
|
6413
|
+
if (!A2 || !B3) return;
|
|
6414
|
+
const label = t.event + (t.guard !== void 0 ? ` ${t.guard}` : "");
|
|
6415
|
+
const isErr = isErrTerminal(B3);
|
|
6416
|
+
const isAccent = !isErr && accentId !== void 0 && t.to === accentId;
|
|
6417
|
+
const stroke = isErr ? "var(--negative)" : isAccent ? "var(--accent)" : "var(--muted)";
|
|
6418
|
+
const marker2 = isErr ? "skErr" : isAccent ? "skAccent" : "skArrow";
|
|
6419
|
+
const sw = isAccent ? 1.75 : 1.5;
|
|
6420
|
+
const tone = isErr ? "error" : isAccent ? "accent" : "muted";
|
|
6421
|
+
if (isErr) used.error = true;
|
|
6422
|
+
else if (isAccent) used.accent = true;
|
|
6423
|
+
else used.plain = true;
|
|
6424
|
+
const tAttrs = bp(`transitions.${ti}`) + revealAttr(ti);
|
|
6425
|
+
if (t.from === t.to) {
|
|
6426
|
+
const r5 = rectFor(A2, cellW, cellH, gapX, gapY, padX, padTop);
|
|
6427
|
+
s += `<path d="M ${r5.cx - 12} ${r5.y} C ${r5.cx - 30} ${r5.y - 32}, ${r5.cx + 30} ${r5.y - 32}, ${r5.cx + 12} ${r5.y}" fill="none" stroke="${stroke}" stroke-width="${sw}" marker-end="url(#${marker2})"${tAttrs}/>`;
|
|
6428
|
+
const at2 = { lx: r5.cx, ly: r5.y - 28 };
|
|
6429
|
+
const mark2 = numbered ? edgeStep(at2, ti + 1, isErr, true) : edgeMask(at2, label, tone);
|
|
6430
|
+
labels.push(`<g${tAttrs}>${mark2}</g>`);
|
|
6431
|
+
return;
|
|
6432
|
+
}
|
|
6433
|
+
const p2 = ortho(
|
|
6434
|
+
rectFor(A2, cellW, cellH, gapX, gapY, padX, padTop),
|
|
6435
|
+
rectFor(B3, cellW, cellH, gapX, gapY, padX, padTop),
|
|
6436
|
+
lanes[ti] ?? 0,
|
|
6437
|
+
entries[ti] ?? 0
|
|
6438
|
+
);
|
|
6439
|
+
s += `<path d="${p2.d}" fill="none" stroke="${stroke}" stroke-width="${sw}" marker-end="url(#${marker2})"${tAttrs}/>`;
|
|
6440
|
+
const mark = numbered ? edgeStep(dodge(p2.lx, p2.ly, avoid), ti + 1, isErr, true) : edgeMask(p2, label, tone);
|
|
6441
|
+
labels.push(`<g${tAttrs}>${mark}</g>`);
|
|
6442
|
+
});
|
|
6443
|
+
const kinds = { active: false, wait: false, start: false, end: false, errEnd: false };
|
|
6444
|
+
s += `<g${bl("states")}>`;
|
|
6445
|
+
states.forEach((st2, si) => {
|
|
6446
|
+
const r5 = rectFor(st2, cellW, cellH, gapX, gapY, padX, padTop);
|
|
6447
|
+
const place = nodeCellAttrs(st2.col, st2.row);
|
|
6448
|
+
if (st2.kind === "start") {
|
|
6449
|
+
kinds.start = true;
|
|
6450
|
+
s += `<circle cx="${r5.cx}" cy="${r5.cy}" r="10" fill="var(--ink)"${bp(`states.${si}`)}${place}/>`;
|
|
6451
|
+
} else if (st2.kind === "terminal") {
|
|
6452
|
+
const accent = st2.id === accentId;
|
|
6453
|
+
const err = isErrTerminal(st2);
|
|
6454
|
+
if (err) kinds.errEnd = true;
|
|
6455
|
+
else if (!accent) kinds.end = true;
|
|
6456
|
+
const tone = accent ? "var(--accent)" : err ? "var(--negative)" : "var(--ink)";
|
|
6457
|
+
const fill = accent ? "var(--accent-tint)" : err ? "var(--negative-tint)" : "var(--paper)";
|
|
6458
|
+
s += `<g${bp(`states.${si}`)}${place}><circle cx="${r5.cx}" cy="${r5.cy}" r="12" fill="${fill}" stroke="${tone}" stroke-width="1.5"/><circle cx="${r5.cx}" cy="${r5.cy}" r="6" fill="${tone}"/></g>`;
|
|
6459
|
+
} else {
|
|
6460
|
+
const wait = st2.kind === "wait";
|
|
6461
|
+
if (wait) kinds.wait = true;
|
|
6462
|
+
else kinds.active = true;
|
|
6463
|
+
const fill = wait ? "var(--paper-2)" : "var(--paper)";
|
|
6464
|
+
const stroke = wait ? "var(--rule-solid)" : "var(--ink)";
|
|
6465
|
+
const sw = wait ? 1 : 1.5;
|
|
6466
|
+
const lines = nameLines(st2);
|
|
6467
|
+
const nameText = lines.length <= 1 ? `<text x="${r5.cx}" y="${r5.cy + 4.5}" class="t-name" text-anchor="middle"${bp(`states.${si}.name`)}>${escapeHtml(st2.name ?? "")}</text>` : `<g${bp(`states.${si}.name`)}>` + lines.map(
|
|
6468
|
+
(ln2, j2) => `<text x="${r5.cx}" y="${r5.cy + 4.5 - (lines.length - 1) * 7.5 + j2 * 15}" class="t-name" text-anchor="middle">${escapeHtml(ln2)}</text>`
|
|
6469
|
+
).join("") + `</g>`;
|
|
6470
|
+
s += `<g${bp(`states.${si}`)}${place}><rect x="${r5.x}" y="${r5.y}" width="${r5.w}" height="${r5.h}" rx="23" fill="${fill}" stroke="${stroke}" stroke-width="${sw}"/>` + nameText + `</g>`;
|
|
6471
|
+
}
|
|
6472
|
+
});
|
|
6473
|
+
s += `</g>`;
|
|
6474
|
+
s += labels.join("");
|
|
6475
|
+
s += `</svg>`;
|
|
6476
|
+
const name = (id) => byId.get(id)?.name ?? id;
|
|
6477
|
+
const numCell = (ti) => numbered ? `<td class="t-num"><span class="edge-step"><b>${ti + 1}</b></span></td>` : "";
|
|
6478
|
+
const rows2 = trans.map(
|
|
6479
|
+
(t, ti) => `<tr${bp(`transitions.${ti}`)}${revealAttr(ti)}>` + numCell(ti) + `<td><span class="${pillCls(byId.get(t.from)?.kind)}">${escapeHtml(name(t.from))}</span></td><td style="font-family:var(--font-mono);font-size:11px"${bp(`transitions.${ti}.event`)}>${escapeHtml(t.event)}</td><td class="c-soft" style="font-size:11px"${bp(`transitions.${ti}.guard`)}>${escapeHtml(t.guard ?? "\u2014")}</td><td><span class="${pillCls(byId.get(t.to)?.kind)}">${escapeHtml(name(t.to))}</span></td></tr>`
|
|
6480
|
+
).join("");
|
|
6481
|
+
const table = trans.length > 0 ? `<table class="transition-table"><thead><tr>${numbered ? "<th>\u2116</th>" : ""}<th>From</th><th>Event</th><th>Guard</th><th>To</th></tr></thead><tbody${bl("transitions")}>${rows2}</tbody></table>` : "";
|
|
6482
|
+
const items = [];
|
|
6483
|
+
if (kinds.start) items.push({ swatch: "chip", chip: "\u25CF", label: "start" });
|
|
6484
|
+
if (kinds.active) items.push({ swatch: "node", label: "state" });
|
|
6485
|
+
if (kinds.wait) items.push({ swatch: "node-fill2", label: "waiting" });
|
|
6486
|
+
if (kinds.end) items.push({ swatch: "chip", chip: "\u25C9", label: "end" });
|
|
6487
|
+
if (used.plain) items.push({ swatch: "edge", label: "transition" });
|
|
6488
|
+
if (kinds.errEnd) items.push({ swatch: "node-negative", label: "error exit" });
|
|
6489
|
+
if (used.error) items.push({ swatch: "edge-error", label: "error transition" });
|
|
6490
|
+
if (accentId !== void 0) items.push({ swatch: "node-accent", label: "success exit" });
|
|
6491
|
+
const legend = renderLegend(items);
|
|
6492
|
+
return diagramFrame(
|
|
6493
|
+
{
|
|
6494
|
+
tag: "STATE",
|
|
6495
|
+
...data.title !== void 0 ? { title: data.title } : {},
|
|
6496
|
+
...data.description !== void 0 ? { desc: data.description } : {},
|
|
6497
|
+
...legend.length > 0 ? { legendHtml: legend } : {},
|
|
6498
|
+
...table.length > 0 ? { footerHtml: table } : {}
|
|
6499
|
+
},
|
|
6500
|
+
s
|
|
6501
|
+
);
|
|
6469
6502
|
}
|
|
6470
|
-
var SKIN_EDGE = {
|
|
6471
|
-
solid: { stroke: "var(--muted)", sw: 1.5, dash: "", marker: "skArrow", err: false },
|
|
6472
|
-
dashed: { stroke: "var(--muted)", sw: 1.5, dash: "5 4", marker: "skOpen", err: false },
|
|
6473
|
-
forbidden: { stroke: "var(--negative)", sw: 1.5, dash: "4 3", marker: "skErr", err: true },
|
|
6474
|
-
error: { stroke: "var(--negative)", sw: 1.5, dash: "", marker: "skErr", err: true }
|
|
6475
|
-
};
|
|
6476
6503
|
|
|
6477
6504
|
// src/svg/dfdShapes.ts
|
|
6478
6505
|
function dfdKindOf(kind) {
|