@stealthscale/component-graphs 0.2.1 → 0.2.2

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.
@@ -0,0 +1,1542 @@
1
+ import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
2
+ import { a as ZoomLevel, c as Controls, l as Control, s as MiniMap, t as NetworkGraph } from "../../shared-DOF4V8-Q.js";
3
+ import { useState } from "react";
4
+ import { c } from "react/compiler-runtime";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Room, specimen, useWords } from "@stealthscale/specimen";
7
+ import { ChevronDownIcon, ClockIcon, DatabaseIcon, FactoryIcon, GlobeIcon, MaximizeIcon, MinusIcon, PlusIcon, ServerIcon, WarehouseIcon } from "lucide-react";
8
+ import { NativeSelect } from "@stealthscale/component-forms";
9
+ import { Stack } from "@stealthscale/component-layout";
10
+ //#region src/network-graph/examples/controlled.example.tsx
11
+ var controlled_example_exports = /* @__PURE__ */ __exportAll({
12
+ Controlled: () => Controlled,
13
+ source: () => source$6
14
+ });
15
+ const DEPARTMENTS = [
16
+ {
17
+ id: "emergency",
18
+ weight: 8
19
+ },
20
+ {
21
+ id: "radiology",
22
+ weight: 7
23
+ },
24
+ {
25
+ id: "cardiology",
26
+ weight: 5
27
+ },
28
+ {
29
+ id: "neurology",
30
+ weight: 4
31
+ },
32
+ {
33
+ id: "oncology",
34
+ weight: 4
35
+ },
36
+ {
37
+ id: "paediatrics",
38
+ weight: 3
39
+ },
40
+ {
41
+ id: "pharmacy",
42
+ weight: 2
43
+ }
44
+ ];
45
+ const REFERRALS = [
46
+ {
47
+ source: "emergency",
48
+ strength: 2,
49
+ target: "cardiology"
50
+ },
51
+ {
52
+ source: "emergency",
53
+ strength: 2,
54
+ target: "radiology"
55
+ },
56
+ {
57
+ source: "emergency",
58
+ target: "neurology"
59
+ },
60
+ {
61
+ source: "oncology",
62
+ strength: 2,
63
+ target: "radiology"
64
+ },
65
+ {
66
+ source: "oncology",
67
+ target: "pharmacy"
68
+ },
69
+ {
70
+ source: "paediatrics",
71
+ target: "emergency"
72
+ },
73
+ {
74
+ source: "neurology",
75
+ target: "radiology"
76
+ }
77
+ ];
78
+ function Controlled() {
79
+ const $ = c(59);
80
+ const { t } = useWords("network-graph");
81
+ const [focus, setFocus] = useState("radiology");
82
+ let T0;
83
+ let T1;
84
+ let T2;
85
+ let nodes;
86
+ let t0;
87
+ let t1;
88
+ let t2;
89
+ let t3;
90
+ let t4;
91
+ let t5;
92
+ if ($[0] !== focus || $[1] !== t) {
93
+ let t6;
94
+ if ($[12] !== t) {
95
+ t6 = (t7) => {
96
+ const { id, weight } = t7;
97
+ return {
98
+ id,
99
+ label: t(`departments.${id}`),
100
+ weight
101
+ };
102
+ };
103
+ $[12] = t;
104
+ $[13] = t6;
105
+ } else t6 = $[13];
106
+ nodes = DEPARTMENTS.map(t6);
107
+ T2 = Stack;
108
+ t5 = "flex-start";
109
+ T1 = NativeSelect.Root;
110
+ T0 = NativeSelect.Field;
111
+ if ($[14] !== t) {
112
+ t0 = t("controlled.pick");
113
+ $[14] = t;
114
+ $[15] = t0;
115
+ } else t0 = $[15];
116
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
117
+ t1 = (event) => {
118
+ setFocus(event.target.value === "" ? null : event.target.value);
119
+ };
120
+ $[16] = t1;
121
+ } else t1 = $[16];
122
+ if ($[17] !== t) {
123
+ t2 = t("controlled.none");
124
+ $[17] = t;
125
+ $[18] = t2;
126
+ } else t2 = $[18];
127
+ t3 = focus ?? "";
128
+ t4 = nodes.map(_temp$1);
129
+ $[0] = focus;
130
+ $[1] = t;
131
+ $[2] = T0;
132
+ $[3] = T1;
133
+ $[4] = T2;
134
+ $[5] = nodes;
135
+ $[6] = t0;
136
+ $[7] = t1;
137
+ $[8] = t2;
138
+ $[9] = t3;
139
+ $[10] = t4;
140
+ $[11] = t5;
141
+ } else {
142
+ T0 = $[2];
143
+ T1 = $[3];
144
+ T2 = $[4];
145
+ nodes = $[5];
146
+ t0 = $[6];
147
+ t1 = $[7];
148
+ t2 = $[8];
149
+ t3 = $[9];
150
+ t4 = $[10];
151
+ t5 = $[11];
152
+ }
153
+ let t6;
154
+ if ($[19] !== T0 || $[20] !== t0 || $[21] !== t1 || $[22] !== t2 || $[23] !== t3 || $[24] !== t4) {
155
+ t6 = /* @__PURE__ */ jsx(T0, {
156
+ "aria-label": t0,
157
+ onChange: t1,
158
+ placeholder: t2,
159
+ value: t3,
160
+ children: t4
161
+ });
162
+ $[19] = T0;
163
+ $[20] = t0;
164
+ $[21] = t1;
165
+ $[22] = t2;
166
+ $[23] = t3;
167
+ $[24] = t4;
168
+ $[25] = t6;
169
+ } else t6 = $[25];
170
+ let t7;
171
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
172
+ t7 = /* @__PURE__ */ jsx(NativeSelect.Indicator, { children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) });
173
+ $[26] = t7;
174
+ } else t7 = $[26];
175
+ let t8;
176
+ if ($[27] !== T1 || $[28] !== t6) {
177
+ t8 = /* @__PURE__ */ jsxs(T1, { children: [t6, t7] });
178
+ $[27] = T1;
179
+ $[28] = t6;
180
+ $[29] = t8;
181
+ } else t8 = $[29];
182
+ let t9;
183
+ if ($[30] !== t) {
184
+ t9 = t("words.clear");
185
+ $[30] = t;
186
+ $[31] = t9;
187
+ } else t9 = $[31];
188
+ let t10;
189
+ if ($[32] !== t) {
190
+ t10 = (t11) => {
191
+ const { source, target } = t11;
192
+ return t("words.edge", {
193
+ source,
194
+ target
195
+ });
196
+ };
197
+ $[32] = t;
198
+ $[33] = t10;
199
+ } else t10 = $[33];
200
+ let t11;
201
+ if ($[34] !== t) {
202
+ t11 = t("words.focus");
203
+ $[34] = t;
204
+ $[35] = t11;
205
+ } else t11 = $[35];
206
+ let t12;
207
+ if ($[36] !== t) {
208
+ t12 = t("controlled.label");
209
+ $[36] = t;
210
+ $[37] = t12;
211
+ } else t12 = $[37];
212
+ let t13;
213
+ if ($[38] !== t) {
214
+ t13 = t("words.connected");
215
+ $[38] = t;
216
+ $[39] = t13;
217
+ } else t13 = $[39];
218
+ let t14;
219
+ if ($[40] !== t) {
220
+ t14 = t("words.description");
221
+ $[40] = t;
222
+ $[41] = t14;
223
+ } else t14 = $[41];
224
+ let t15;
225
+ if ($[42] !== t) {
226
+ t15 = (t16) => {
227
+ const { count, name } = t16;
228
+ return t("controlled.summary", {
229
+ count,
230
+ name
231
+ });
232
+ };
233
+ $[42] = t;
234
+ $[43] = t15;
235
+ } else t15 = $[43];
236
+ let t16;
237
+ if ($[44] !== focus || $[45] !== nodes || $[46] !== t10 || $[47] !== t11 || $[48] !== t12 || $[49] !== t13 || $[50] !== t14 || $[51] !== t15 || $[52] !== t9) {
238
+ t16 = /* @__PURE__ */ jsx(NetworkGraph, {
239
+ clearLabel: t9,
240
+ edgeName: t10,
241
+ focus,
242
+ focusLabel: t11,
243
+ label: t12,
244
+ links: REFERRALS,
245
+ neighborLabel: t13,
246
+ nodeDescription: t14,
247
+ nodes,
248
+ onFocusChange: setFocus,
249
+ summary: t15
250
+ });
251
+ $[44] = focus;
252
+ $[45] = nodes;
253
+ $[46] = t10;
254
+ $[47] = t11;
255
+ $[48] = t12;
256
+ $[49] = t13;
257
+ $[50] = t14;
258
+ $[51] = t15;
259
+ $[52] = t9;
260
+ $[53] = t16;
261
+ } else t16 = $[53];
262
+ let t17;
263
+ if ($[54] !== T2 || $[55] !== t16 || $[56] !== t5 || $[57] !== t8) {
264
+ t17 = /* @__PURE__ */ jsxs(T2, {
265
+ align: t5,
266
+ children: [t8, t16]
267
+ });
268
+ $[54] = T2;
269
+ $[55] = t16;
270
+ $[56] = t5;
271
+ $[57] = t8;
272
+ $[58] = t17;
273
+ } else t17 = $[58];
274
+ return t17;
275
+ }
276
+ function _temp$1(node) {
277
+ return /* @__PURE__ */ jsx("option", {
278
+ value: node.id,
279
+ children: node.label
280
+ }, node.id);
281
+ }
282
+ const source$6 = "import { type ReactElement, useState } from \"react\";\n\nimport { ChevronDownIcon } from \"lucide-react\";\n\nimport { NativeSelect } from \"@stealthscale/component-forms\";\nimport { Stack } from \"@stealthscale/component-layout\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { NetworkGraph } from \"@stealthscale/component-graphs\";\n\nconst DEPARTMENTS = [\n { id: \"emergency\", weight: 8 },\n { id: \"radiology\", weight: 7 },\n { id: \"cardiology\", weight: 5 },\n { id: \"neurology\", weight: 4 },\n { id: \"oncology\", weight: 4 },\n { id: \"paediatrics\", weight: 3 },\n { id: \"pharmacy\", weight: 2 },\n] as const;\n\nconst REFERRALS = [\n { source: \"emergency\", strength: 2, target: \"cardiology\" },\n { source: \"emergency\", strength: 2, target: \"radiology\" },\n { source: \"emergency\", target: \"neurology\" },\n { source: \"oncology\", strength: 2, target: \"radiology\" },\n { source: \"oncology\", target: \"pharmacy\" },\n { source: \"paediatrics\", target: \"emergency\" },\n { source: \"neurology\", target: \"radiology\" },\n];\n\nexport function Controlled(): ReactElement {\n const { t } = useWords(\"network-graph\");\n const [focus, setFocus] = useState<null | string>(\"radiology\");\n const nodes = DEPARTMENTS.map(({ id, weight }) => ({\n id,\n label: t(`departments.${id}`),\n weight,\n }));\n\n return (\n <Stack align=\"flex-start\">\n <NativeSelect.Root>\n <NativeSelect.Field\n aria-label={t(\"controlled.pick\")}\n onChange={(event) => {\n setFocus(event.target.value === \"\" ? null : event.target.value);\n }}\n placeholder={t(\"controlled.none\")}\n value={focus ?? \"\"}\n >\n {nodes.map((node) => (\n <option key={node.id} value={node.id}>\n {node.label}\n </option>\n ))}\n </NativeSelect.Field>\n <NativeSelect.Indicator>\n <ChevronDownIcon />\n </NativeSelect.Indicator>\n </NativeSelect.Root>\n <NetworkGraph\n clearLabel={t(\"words.clear\")}\n edgeName={({ source, target }) => t(\"words.edge\", { source, target })}\n focus={focus}\n focusLabel={t(\"words.focus\")}\n label={t(\"controlled.label\")}\n links={REFERRALS}\n neighborLabel={t(\"words.connected\")}\n nodeDescription={t(\"words.description\")}\n nodes={nodes}\n onFocusChange={setFocus}\n summary={({ count, name }) => t(\"controlled.summary\", { count, name })}\n />\n </Stack>\n );\n}\n";
283
+ //#endregion
284
+ //#region src/network-graph/examples/empty.example.tsx
285
+ var empty_example_exports = /* @__PURE__ */ __exportAll({
286
+ Empty: () => Empty,
287
+ source: () => source$5
288
+ });
289
+ function Empty() {
290
+ const $ = c(9);
291
+ const { t } = useWords("network-graph");
292
+ let t0;
293
+ if ($[0] !== t) {
294
+ t0 = t("empty.message");
295
+ $[0] = t;
296
+ $[1] = t0;
297
+ } else t0 = $[1];
298
+ let t1;
299
+ if ($[2] !== t) {
300
+ t1 = t("empty.label");
301
+ $[2] = t;
302
+ $[3] = t1;
303
+ } else t1 = $[3];
304
+ let t2;
305
+ let t3;
306
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
307
+ t2 = [];
308
+ t3 = [];
309
+ $[4] = t2;
310
+ $[5] = t3;
311
+ } else {
312
+ t2 = $[4];
313
+ t3 = $[5];
314
+ }
315
+ let t4;
316
+ if ($[6] !== t0 || $[7] !== t1) {
317
+ t4 = /* @__PURE__ */ jsx(NetworkGraph, {
318
+ emptyLabel: t0,
319
+ label: t1,
320
+ links: t2,
321
+ nodes: t3
322
+ });
323
+ $[6] = t0;
324
+ $[7] = t1;
325
+ $[8] = t4;
326
+ } else t4 = $[8];
327
+ return t4;
328
+ }
329
+ const source$5 = "import { type ReactElement } from \"react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { NetworkGraph } from \"@stealthscale/component-graphs\";\n\nexport function Empty(): ReactElement {\n const { t } = useWords(\"network-graph\");\n\n return (\n <NetworkGraph emptyLabel={t(\"empty.message\")} label={t(\"empty.label\")} links={[]} nodes={[]} />\n );\n}\n";
330
+ //#endregion
331
+ //#region src/network-graph/examples/mentoring.example.tsx
332
+ var mentoring_example_exports = /* @__PURE__ */ __exportAll({
333
+ Mentoring: () => Mentoring,
334
+ source: () => source$4
335
+ });
336
+ const PEOPLE = [
337
+ {
338
+ id: "elena",
339
+ label: "Elena Fischer"
340
+ },
341
+ {
342
+ id: "priya",
343
+ label: "Priya Raman"
344
+ },
345
+ {
346
+ id: "tomas",
347
+ label: "Tomás Ferreira"
348
+ },
349
+ {
350
+ id: "mateusz",
351
+ label: "Mateusz Nowak"
352
+ },
353
+ {
354
+ id: "ayse",
355
+ label: "Ayşe Demir"
356
+ },
357
+ {
358
+ id: "sofia",
359
+ label: "Sofia Rossi"
360
+ },
361
+ {
362
+ id: "kwame",
363
+ label: "Kwame Mensah"
364
+ },
365
+ {
366
+ id: "jonas",
367
+ label: "Jonas Lindqvist"
368
+ }
369
+ ];
370
+ const MENTORING = [
371
+ {
372
+ source: "priya",
373
+ target: "elena"
374
+ },
375
+ {
376
+ source: "elena",
377
+ target: "tomas"
378
+ },
379
+ {
380
+ source: "elena",
381
+ target: "mateusz"
382
+ },
383
+ {
384
+ source: "tomas",
385
+ target: "ayse"
386
+ },
387
+ {
388
+ source: "tomas",
389
+ target: "sofia"
390
+ },
391
+ {
392
+ source: "priya",
393
+ target: "mateusz"
394
+ },
395
+ {
396
+ source: "mateusz",
397
+ target: "kwame"
398
+ },
399
+ {
400
+ source: "sofia",
401
+ target: "jonas"
402
+ }
403
+ ];
404
+ function Mentoring() {
405
+ const $ = c(24);
406
+ const { t } = useWords("network-graph");
407
+ let t0;
408
+ if ($[0] !== t) {
409
+ t0 = t("words.clear");
410
+ $[0] = t;
411
+ $[1] = t0;
412
+ } else t0 = $[1];
413
+ let t1;
414
+ let t2;
415
+ if ($[2] !== t) {
416
+ t1 = (t3) => {
417
+ const { source, target } = t3;
418
+ return t("words.edge", {
419
+ source,
420
+ target
421
+ });
422
+ };
423
+ t2 = t("words.focus");
424
+ $[2] = t;
425
+ $[3] = t1;
426
+ $[4] = t2;
427
+ } else {
428
+ t1 = $[3];
429
+ t2 = $[4];
430
+ }
431
+ let t3;
432
+ if ($[5] !== t) {
433
+ t3 = t("mentoring.label");
434
+ $[5] = t;
435
+ $[6] = t3;
436
+ } else t3 = $[6];
437
+ let t4;
438
+ if ($[7] !== t) {
439
+ t4 = t("words.connected");
440
+ $[7] = t;
441
+ $[8] = t4;
442
+ } else t4 = $[8];
443
+ let t5;
444
+ if ($[9] !== t) {
445
+ t5 = t("words.description");
446
+ $[9] = t;
447
+ $[10] = t5;
448
+ } else t5 = $[10];
449
+ let t6;
450
+ if ($[11] !== t) {
451
+ t6 = t("mentoring.prompt");
452
+ $[11] = t;
453
+ $[12] = t6;
454
+ } else t6 = $[12];
455
+ let t7;
456
+ if ($[13] !== t) {
457
+ t7 = (t8) => {
458
+ const { count, name } = t8;
459
+ return t("mentoring.summary", {
460
+ count,
461
+ name
462
+ });
463
+ };
464
+ $[13] = t;
465
+ $[14] = t7;
466
+ } else t7 = $[14];
467
+ let t8;
468
+ if ($[15] !== t0 || $[16] !== t1 || $[17] !== t2 || $[18] !== t3 || $[19] !== t4 || $[20] !== t5 || $[21] !== t6 || $[22] !== t7) {
469
+ t8 = /* @__PURE__ */ jsx(NetworkGraph, {
470
+ clearLabel: t0,
471
+ defaultFocus: "elena",
472
+ depth: 2,
473
+ edgeName: t1,
474
+ focusLabel: t2,
475
+ label: t3,
476
+ links: MENTORING,
477
+ neighborLabel: t4,
478
+ nodeDescription: t5,
479
+ nodes: PEOPLE,
480
+ promptLabel: t6,
481
+ summary: t7
482
+ });
483
+ $[15] = t0;
484
+ $[16] = t1;
485
+ $[17] = t2;
486
+ $[18] = t3;
487
+ $[19] = t4;
488
+ $[20] = t5;
489
+ $[21] = t6;
490
+ $[22] = t7;
491
+ $[23] = t8;
492
+ } else t8 = $[23];
493
+ return t8;
494
+ }
495
+ const source$4 = "import { type ReactElement } from \"react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { NetworkGraph } from \"@stealthscale/component-graphs\";\n\nconst PEOPLE = [\n { id: \"elena\", label: \"Elena Fischer\" },\n { id: \"priya\", label: \"Priya Raman\" },\n { id: \"tomas\", label: \"Tomás Ferreira\" },\n { id: \"mateusz\", label: \"Mateusz Nowak\" },\n { id: \"ayse\", label: \"Ayşe Demir\" },\n { id: \"sofia\", label: \"Sofia Rossi\" },\n { id: \"kwame\", label: \"Kwame Mensah\" },\n { id: \"jonas\", label: \"Jonas Lindqvist\" },\n];\n\nconst MENTORING = [\n { source: \"priya\", target: \"elena\" },\n { source: \"elena\", target: \"tomas\" },\n { source: \"elena\", target: \"mateusz\" },\n { source: \"tomas\", target: \"ayse\" },\n { source: \"tomas\", target: \"sofia\" },\n { source: \"priya\", target: \"mateusz\" },\n { source: \"mateusz\", target: \"kwame\" },\n { source: \"sofia\", target: \"jonas\" },\n];\n\nexport function Mentoring(): ReactElement {\n const { t } = useWords(\"network-graph\");\n\n return (\n <NetworkGraph\n clearLabel={t(\"words.clear\")}\n defaultFocus=\"elena\"\n depth={2}\n edgeName={({ source, target }) => t(\"words.edge\", { source, target })}\n focusLabel={t(\"words.focus\")}\n label={t(\"mentoring.label\")}\n links={MENTORING}\n neighborLabel={t(\"words.connected\")}\n nodeDescription={t(\"words.description\")}\n nodes={PEOPLE}\n promptLabel={t(\"mentoring.prompt\")}\n summary={({ count, name }) => t(\"mentoring.summary\", { count, name })}\n />\n );\n}\n";
496
+ //#endregion
497
+ //#region src/network-graph/examples/modules.example.tsx
498
+ var modules_example_exports = /* @__PURE__ */ __exportAll({
499
+ Modules: () => Modules,
500
+ source: () => source$3
501
+ });
502
+ const MODULES = [
503
+ "stats",
504
+ "linear",
505
+ "calculus",
506
+ "structures",
507
+ "econometrics",
508
+ "ethics"
509
+ ];
510
+ const TAKEN_TOGETHER = [
511
+ {
512
+ source: "stats",
513
+ target: "linear"
514
+ },
515
+ {
516
+ source: "stats",
517
+ target: "calculus"
518
+ },
519
+ {
520
+ source: "stats",
521
+ target: "structures"
522
+ },
523
+ {
524
+ source: "stats",
525
+ target: "econometrics"
526
+ },
527
+ {
528
+ source: "stats",
529
+ target: "ethics"
530
+ },
531
+ {
532
+ source: "econometrics",
533
+ target: "calculus"
534
+ },
535
+ {
536
+ source: "structures",
537
+ target: "linear"
538
+ }
539
+ ];
540
+ function Modules() {
541
+ const $ = c(27);
542
+ const { t } = useWords("network-graph");
543
+ let t0;
544
+ if ($[0] !== t) {
545
+ t0 = MODULES.map((id) => ({
546
+ id,
547
+ label: t(`modules.names.${id}`)
548
+ }));
549
+ $[0] = t;
550
+ $[1] = t0;
551
+ } else t0 = $[1];
552
+ const nodes = t0;
553
+ let t1;
554
+ if ($[2] !== t) {
555
+ t1 = t("words.clear");
556
+ $[2] = t;
557
+ $[3] = t1;
558
+ } else t1 = $[3];
559
+ let t2;
560
+ let t3;
561
+ if ($[4] !== t) {
562
+ t2 = (t4) => {
563
+ const { source, target } = t4;
564
+ return t("words.edge", {
565
+ source,
566
+ target
567
+ });
568
+ };
569
+ t3 = t("words.focus");
570
+ $[4] = t;
571
+ $[5] = t2;
572
+ $[6] = t3;
573
+ } else {
574
+ t2 = $[5];
575
+ t3 = $[6];
576
+ }
577
+ let t4;
578
+ if ($[7] !== t) {
579
+ t4 = t("modules.label");
580
+ $[7] = t;
581
+ $[8] = t4;
582
+ } else t4 = $[8];
583
+ let t5;
584
+ if ($[9] !== t) {
585
+ t5 = t("words.connected");
586
+ $[9] = t;
587
+ $[10] = t5;
588
+ } else t5 = $[10];
589
+ let t6;
590
+ if ($[11] !== t) {
591
+ t6 = t("words.description");
592
+ $[11] = t;
593
+ $[12] = t6;
594
+ } else t6 = $[12];
595
+ let t7;
596
+ if ($[13] !== t) {
597
+ t7 = t("modules.prompt");
598
+ $[13] = t;
599
+ $[14] = t7;
600
+ } else t7 = $[14];
601
+ let t8;
602
+ if ($[15] !== t) {
603
+ t8 = (t9) => {
604
+ const { count, name } = t9;
605
+ return t("modules.summary", {
606
+ count,
607
+ name
608
+ });
609
+ };
610
+ $[15] = t;
611
+ $[16] = t8;
612
+ } else t8 = $[16];
613
+ let t9;
614
+ if ($[17] !== nodes || $[18] !== t1 || $[19] !== t2 || $[20] !== t3 || $[21] !== t4 || $[22] !== t5 || $[23] !== t6 || $[24] !== t7 || $[25] !== t8) {
615
+ t9 = /* @__PURE__ */ jsx(NetworkGraph, {
616
+ clearLabel: t1,
617
+ edgeName: t2,
618
+ focusLabel: t3,
619
+ label: t4,
620
+ links: TAKEN_TOGETHER,
621
+ neighborLabel: t5,
622
+ nodeDescription: t6,
623
+ nodes,
624
+ promptLabel: t7,
625
+ summary: t8
626
+ });
627
+ $[17] = nodes;
628
+ $[18] = t1;
629
+ $[19] = t2;
630
+ $[20] = t3;
631
+ $[21] = t4;
632
+ $[22] = t5;
633
+ $[23] = t6;
634
+ $[24] = t7;
635
+ $[25] = t8;
636
+ $[26] = t9;
637
+ } else t9 = $[26];
638
+ return t9;
639
+ }
640
+ const source$3 = "import { type ReactElement } from \"react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { NetworkGraph } from \"@stealthscale/component-graphs\";\n\nconst MODULES = [\"stats\", \"linear\", \"calculus\", \"structures\", \"econometrics\", \"ethics\"] as const;\n\nconst TAKEN_TOGETHER = [\n { source: \"stats\", target: \"linear\" },\n { source: \"stats\", target: \"calculus\" },\n { source: \"stats\", target: \"structures\" },\n { source: \"stats\", target: \"econometrics\" },\n { source: \"stats\", target: \"ethics\" },\n { source: \"econometrics\", target: \"calculus\" },\n { source: \"structures\", target: \"linear\" },\n];\n\nexport function Modules(): ReactElement {\n const { t } = useWords(\"network-graph\");\n const nodes = MODULES.map((id) => ({ id, label: t(`modules.names.${id}`) }));\n\n return (\n <NetworkGraph\n clearLabel={t(\"words.clear\")}\n edgeName={({ source, target }) => t(\"words.edge\", { source, target })}\n focusLabel={t(\"words.focus\")}\n label={t(\"modules.label\")}\n links={TAKEN_TOGETHER}\n neighborLabel={t(\"words.connected\")}\n nodeDescription={t(\"words.description\")}\n nodes={nodes}\n promptLabel={t(\"modules.prompt\")}\n summary={({ count, name }) => t(\"modules.summary\", { count, name })}\n />\n );\n}\n";
641
+ //#endregion
642
+ //#region src/network-graph/examples/pinned.example.tsx
643
+ var pinned_example_exports = /* @__PURE__ */ __exportAll({
644
+ Pinned: () => Pinned,
645
+ source: () => source$2
646
+ });
647
+ const SITES = [
648
+ {
649
+ icon: /* @__PURE__ */ jsx(FactoryIcon, {}),
650
+ id: "eindhoven",
651
+ weight: 9
652
+ },
653
+ {
654
+ icon: /* @__PURE__ */ jsx(WarehouseIcon, {}),
655
+ id: "venlo",
656
+ weight: 6
657
+ },
658
+ {
659
+ icon: /* @__PURE__ */ jsx(FactoryIcon, {}),
660
+ id: "genk",
661
+ weight: 5
662
+ },
663
+ {
664
+ icon: /* @__PURE__ */ jsx(FactoryIcon, {}),
665
+ id: "kortrijk",
666
+ weight: 4
667
+ },
668
+ {
669
+ icon: /* @__PURE__ */ jsx(FactoryIcon, {}),
670
+ id: "timisoara",
671
+ weight: 4
672
+ },
673
+ {
674
+ icon: /* @__PURE__ */ jsx(FactoryIcon, {}),
675
+ id: "bochum",
676
+ weight: 3
677
+ }
678
+ ];
679
+ const DELIVERIES = [
680
+ {
681
+ source: "eindhoven",
682
+ strength: 2,
683
+ target: "venlo"
684
+ },
685
+ {
686
+ source: "venlo",
687
+ strength: 2,
688
+ target: "genk"
689
+ },
690
+ {
691
+ source: "venlo",
692
+ target: "kortrijk"
693
+ },
694
+ {
695
+ source: "venlo",
696
+ target: "timisoara"
697
+ },
698
+ {
699
+ source: "genk",
700
+ target: "bochum"
701
+ },
702
+ {
703
+ source: "eindhoven",
704
+ target: "genk"
705
+ }
706
+ ];
707
+ function Pinned() {
708
+ const $ = c(27);
709
+ const { t } = useWords("network-graph");
710
+ let t0;
711
+ if ($[0] !== t) {
712
+ t0 = SITES.map((t1) => {
713
+ const { icon, id, weight } = t1;
714
+ return {
715
+ icon,
716
+ id,
717
+ label: t(`pinned.sites.${id}`),
718
+ weight
719
+ };
720
+ });
721
+ $[0] = t;
722
+ $[1] = t0;
723
+ } else t0 = $[1];
724
+ const nodes = t0;
725
+ let t1;
726
+ if ($[2] !== t) {
727
+ t1 = t("words.clear");
728
+ $[2] = t;
729
+ $[3] = t1;
730
+ } else t1 = $[3];
731
+ let t2;
732
+ let t3;
733
+ if ($[4] !== t) {
734
+ t2 = (t4) => {
735
+ const { source, target } = t4;
736
+ return t("words.edge", {
737
+ source,
738
+ target
739
+ });
740
+ };
741
+ t3 = t("words.focus");
742
+ $[4] = t;
743
+ $[5] = t2;
744
+ $[6] = t3;
745
+ } else {
746
+ t2 = $[5];
747
+ t3 = $[6];
748
+ }
749
+ let t4;
750
+ if ($[7] !== t) {
751
+ t4 = t("pinned.label");
752
+ $[7] = t;
753
+ $[8] = t4;
754
+ } else t4 = $[8];
755
+ let t5;
756
+ if ($[9] !== t) {
757
+ t5 = t("words.connected");
758
+ $[9] = t;
759
+ $[10] = t5;
760
+ } else t5 = $[10];
761
+ let t6;
762
+ if ($[11] !== t) {
763
+ t6 = t("words.fixed");
764
+ $[11] = t;
765
+ $[12] = t6;
766
+ } else t6 = $[12];
767
+ let t7;
768
+ if ($[13] !== t) {
769
+ t7 = t("pinned.prompt");
770
+ $[13] = t;
771
+ $[14] = t7;
772
+ } else t7 = $[14];
773
+ let t8;
774
+ if ($[15] !== t) {
775
+ t8 = (t9) => {
776
+ const { count, name } = t9;
777
+ return t("pinned.summary", {
778
+ count,
779
+ name
780
+ });
781
+ };
782
+ $[15] = t;
783
+ $[16] = t8;
784
+ } else t8 = $[16];
785
+ let t9;
786
+ if ($[17] !== nodes || $[18] !== t1 || $[19] !== t2 || $[20] !== t3 || $[21] !== t4 || $[22] !== t5 || $[23] !== t6 || $[24] !== t7 || $[25] !== t8) {
787
+ t9 = /* @__PURE__ */ jsx(NetworkGraph, {
788
+ clearLabel: t1,
789
+ draggable: false,
790
+ edgeName: t2,
791
+ focusLabel: t3,
792
+ label: t4,
793
+ links: DELIVERIES,
794
+ neighborLabel: t5,
795
+ nodeDescription: t6,
796
+ nodes,
797
+ promptLabel: t7,
798
+ summary: t8
799
+ });
800
+ $[17] = nodes;
801
+ $[18] = t1;
802
+ $[19] = t2;
803
+ $[20] = t3;
804
+ $[21] = t4;
805
+ $[22] = t5;
806
+ $[23] = t6;
807
+ $[24] = t7;
808
+ $[25] = t8;
809
+ $[26] = t9;
810
+ } else t9 = $[26];
811
+ return t9;
812
+ }
813
+ const source$2 = "import { type ReactElement } from \"react\";\n\nimport { FactoryIcon, WarehouseIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { NetworkGraph } from \"@stealthscale/component-graphs\";\n\nconst SITES = [\n { icon: <FactoryIcon />, id: \"eindhoven\", weight: 9 },\n { icon: <WarehouseIcon />, id: \"venlo\", weight: 6 },\n { icon: <FactoryIcon />, id: \"genk\", weight: 5 },\n { icon: <FactoryIcon />, id: \"kortrijk\", weight: 4 },\n { icon: <FactoryIcon />, id: \"timisoara\", weight: 4 },\n { icon: <FactoryIcon />, id: \"bochum\", weight: 3 },\n] as const;\n\nconst DELIVERIES = [\n { source: \"eindhoven\", strength: 2, target: \"venlo\" },\n { source: \"venlo\", strength: 2, target: \"genk\" },\n { source: \"venlo\", target: \"kortrijk\" },\n { source: \"venlo\", target: \"timisoara\" },\n { source: \"genk\", target: \"bochum\" },\n { source: \"eindhoven\", target: \"genk\" },\n];\n\nexport function Pinned(): ReactElement {\n const { t } = useWords(\"network-graph\");\n const nodes = SITES.map(({ icon, id, weight }) => ({\n icon,\n id,\n label: t(`pinned.sites.${id}`),\n weight,\n }));\n\n return (\n <NetworkGraph\n clearLabel={t(\"words.clear\")}\n draggable={false}\n edgeName={({ source, target }) => t(\"words.edge\", { source, target })}\n focusLabel={t(\"words.focus\")}\n label={t(\"pinned.label\")}\n links={DELIVERIES}\n neighborLabel={t(\"words.connected\")}\n nodeDescription={t(\"words.fixed\")}\n nodes={nodes}\n promptLabel={t(\"pinned.prompt\")}\n summary={({ count, name }) => t(\"pinned.summary\", { count, name })}\n />\n );\n}\n";
814
+ //#endregion
815
+ //#region src/network-graph/examples/rail.example.tsx
816
+ var rail_example_exports = /* @__PURE__ */ __exportAll({
817
+ Rail: () => Rail,
818
+ source: () => source$1
819
+ });
820
+ const CITIES = [
821
+ "Amsterdam",
822
+ "Athens",
823
+ "Barcelona",
824
+ "Berlin",
825
+ "Bern",
826
+ "Bratislava",
827
+ "Brussels",
828
+ "Bucharest",
829
+ "Budapest",
830
+ "Copenhagen",
831
+ "Dublin",
832
+ "Düsseldorf",
833
+ "Frankfurt",
834
+ "Geneva",
835
+ "Gothenburg",
836
+ "Hamburg",
837
+ "Helsinki",
838
+ "Kraków",
839
+ "Lisbon",
840
+ "Ljubljana",
841
+ "London",
842
+ "Lyon",
843
+ "Madrid",
844
+ "Marseille",
845
+ "Milan",
846
+ "Munich",
847
+ "Oslo",
848
+ "Paris",
849
+ "Porto",
850
+ "Prague",
851
+ "Riga",
852
+ "Rome",
853
+ "Sofia",
854
+ "Stockholm",
855
+ "Tallinn",
856
+ "Vienna",
857
+ "Vilnius",
858
+ "Warsaw",
859
+ "Zagreb",
860
+ "Zürich"
861
+ ];
862
+ const STATIONS = CITIES.map((label) => ({
863
+ id: label,
864
+ label
865
+ }));
866
+ const SERVICES$1 = CITIES.flatMap((city, at) => [1, 11].map((step) => ({
867
+ source: city,
868
+ target: CITIES[(at + step) % CITIES.length] ?? city
869
+ })));
870
+ function Rail() {
871
+ const $ = c(53);
872
+ const { t } = useWords("network-graph");
873
+ let t0;
874
+ if ($[0] !== t) {
875
+ t0 = t("words.clear");
876
+ $[0] = t;
877
+ $[1] = t0;
878
+ } else t0 = $[1];
879
+ let t1;
880
+ if ($[2] !== t) {
881
+ t1 = t("controls");
882
+ $[2] = t;
883
+ $[3] = t1;
884
+ } else t1 = $[3];
885
+ let t2;
886
+ if ($[4] !== t) {
887
+ t2 = t("zoomIn");
888
+ $[4] = t;
889
+ $[5] = t2;
890
+ } else t2 = $[5];
891
+ let t3;
892
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
893
+ t3 = /* @__PURE__ */ jsx(PlusIcon, {});
894
+ $[6] = t3;
895
+ } else t3 = $[6];
896
+ let t4;
897
+ if ($[7] !== t2) {
898
+ t4 = /* @__PURE__ */ jsx(Control, {
899
+ action: "zoomIn",
900
+ label: t2,
901
+ children: t3
902
+ });
903
+ $[7] = t2;
904
+ $[8] = t4;
905
+ } else t4 = $[8];
906
+ let t5;
907
+ if ($[9] !== t) {
908
+ t5 = t("zoomOut");
909
+ $[9] = t;
910
+ $[10] = t5;
911
+ } else t5 = $[10];
912
+ let t6;
913
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
914
+ t6 = /* @__PURE__ */ jsx(MinusIcon, {});
915
+ $[11] = t6;
916
+ } else t6 = $[11];
917
+ let t7;
918
+ if ($[12] !== t5) {
919
+ t7 = /* @__PURE__ */ jsx(Control, {
920
+ action: "zoomOut",
921
+ label: t5,
922
+ children: t6
923
+ });
924
+ $[12] = t5;
925
+ $[13] = t7;
926
+ } else t7 = $[13];
927
+ let t8;
928
+ if ($[14] !== t) {
929
+ t8 = t("fit");
930
+ $[14] = t;
931
+ $[15] = t8;
932
+ } else t8 = $[15];
933
+ let t9;
934
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
935
+ t9 = /* @__PURE__ */ jsx(MaximizeIcon, {});
936
+ $[16] = t9;
937
+ } else t9 = $[16];
938
+ let t10;
939
+ if ($[17] !== t8) {
940
+ t10 = /* @__PURE__ */ jsx(Control, {
941
+ action: "fit",
942
+ label: t8,
943
+ children: t9
944
+ });
945
+ $[17] = t8;
946
+ $[18] = t10;
947
+ } else t10 = $[18];
948
+ let t11;
949
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
950
+ t11 = /* @__PURE__ */ jsx(ZoomLevel, {});
951
+ $[19] = t11;
952
+ } else t11 = $[19];
953
+ let t12;
954
+ if ($[20] !== t1 || $[21] !== t10 || $[22] !== t4 || $[23] !== t7) {
955
+ t12 = /* @__PURE__ */ jsxs(Controls, {
956
+ label: t1,
957
+ children: [
958
+ t4,
959
+ t7,
960
+ t10,
961
+ t11
962
+ ]
963
+ });
964
+ $[20] = t1;
965
+ $[21] = t10;
966
+ $[22] = t4;
967
+ $[23] = t7;
968
+ $[24] = t12;
969
+ } else t12 = $[24];
970
+ let t13;
971
+ let t14;
972
+ if ($[25] !== t) {
973
+ t13 = (t15) => {
974
+ const { source, target } = t15;
975
+ return t("words.edge", {
976
+ source,
977
+ target
978
+ });
979
+ };
980
+ t14 = t("words.focus");
981
+ $[25] = t;
982
+ $[26] = t13;
983
+ $[27] = t14;
984
+ } else {
985
+ t13 = $[26];
986
+ t14 = $[27];
987
+ }
988
+ let t15;
989
+ if ($[28] !== t) {
990
+ t15 = t("rail.label");
991
+ $[28] = t;
992
+ $[29] = t15;
993
+ } else t15 = $[29];
994
+ let t16;
995
+ if ($[30] !== t) {
996
+ t16 = t("words.connected");
997
+ $[30] = t;
998
+ $[31] = t16;
999
+ } else t16 = $[31];
1000
+ let t17;
1001
+ if ($[32] !== t) {
1002
+ t17 = t("words.description");
1003
+ $[32] = t;
1004
+ $[33] = t17;
1005
+ } else t17 = $[33];
1006
+ let t18;
1007
+ if ($[34] !== t) {
1008
+ t18 = t("rail.overview");
1009
+ $[34] = t;
1010
+ $[35] = t18;
1011
+ } else t18 = $[35];
1012
+ let t19;
1013
+ if ($[36] !== t18) {
1014
+ t19 = /* @__PURE__ */ jsx(MiniMap, { label: t18 });
1015
+ $[36] = t18;
1016
+ $[37] = t19;
1017
+ } else t19 = $[37];
1018
+ let t20;
1019
+ if ($[38] !== t) {
1020
+ t20 = t("rail.prompt");
1021
+ $[38] = t;
1022
+ $[39] = t20;
1023
+ } else t20 = $[39];
1024
+ let t21;
1025
+ if ($[40] !== t) {
1026
+ t21 = (t22) => {
1027
+ const { count, name } = t22;
1028
+ return t("rail.summary", {
1029
+ count,
1030
+ name
1031
+ });
1032
+ };
1033
+ $[40] = t;
1034
+ $[41] = t21;
1035
+ } else t21 = $[41];
1036
+ let t22;
1037
+ if ($[42] !== t0 || $[43] !== t12 || $[44] !== t13 || $[45] !== t14 || $[46] !== t15 || $[47] !== t16 || $[48] !== t17 || $[49] !== t19 || $[50] !== t20 || $[51] !== t21) {
1038
+ t22 = /* @__PURE__ */ jsx(NetworkGraph, {
1039
+ clearLabel: t0,
1040
+ controls: t12,
1041
+ edgeName: t13,
1042
+ focusLabel: t14,
1043
+ label: t15,
1044
+ links: SERVICES$1,
1045
+ neighborLabel: t16,
1046
+ nodeDescription: t17,
1047
+ nodes: STATIONS,
1048
+ overview: t19,
1049
+ promptLabel: t20,
1050
+ ratio: "wide",
1051
+ seed: 6,
1052
+ summary: t21
1053
+ });
1054
+ $[42] = t0;
1055
+ $[43] = t12;
1056
+ $[44] = t13;
1057
+ $[45] = t14;
1058
+ $[46] = t15;
1059
+ $[47] = t16;
1060
+ $[48] = t17;
1061
+ $[49] = t19;
1062
+ $[50] = t20;
1063
+ $[51] = t21;
1064
+ $[52] = t22;
1065
+ } else t22 = $[52];
1066
+ return t22;
1067
+ }
1068
+ const source$1 = "import { type ReactElement } from \"react\";\n\nimport { MaximizeIcon, MinusIcon, PlusIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Graph, NetworkGraph } from \"@stealthscale/component-graphs\";\n\nconst CITIES = [\n \"Amsterdam\",\n \"Athens\",\n \"Barcelona\",\n \"Berlin\",\n \"Bern\",\n \"Bratislava\",\n \"Brussels\",\n \"Bucharest\",\n \"Budapest\",\n \"Copenhagen\",\n \"Dublin\",\n \"Düsseldorf\",\n \"Frankfurt\",\n \"Geneva\",\n \"Gothenburg\",\n \"Hamburg\",\n \"Helsinki\",\n \"Kraków\",\n \"Lisbon\",\n \"Ljubljana\",\n \"London\",\n \"Lyon\",\n \"Madrid\",\n \"Marseille\",\n \"Milan\",\n \"Munich\",\n \"Oslo\",\n \"Paris\",\n \"Porto\",\n \"Prague\",\n \"Riga\",\n \"Rome\",\n \"Sofia\",\n \"Stockholm\",\n \"Tallinn\",\n \"Vienna\",\n \"Vilnius\",\n \"Warsaw\",\n \"Zagreb\",\n \"Zürich\",\n];\n\nconst STATIONS = CITIES.map((label) => ({ id: label, label }));\n\nconst SERVICES = CITIES.flatMap((city, at) =>\n [1, 11].map((step) => ({ source: city, target: CITIES[(at + step) % CITIES.length] ?? city })),\n);\n\nexport function Rail(): ReactElement {\n const { t } = useWords(\"network-graph\");\n\n return (\n <NetworkGraph\n clearLabel={t(\"words.clear\")}\n controls={\n <Graph.Controls label={t(\"controls\")}>\n <Graph.Control action=\"zoomIn\" label={t(\"zoomIn\")}>\n <PlusIcon />\n </Graph.Control>\n <Graph.Control action=\"zoomOut\" label={t(\"zoomOut\")}>\n <MinusIcon />\n </Graph.Control>\n <Graph.Control action=\"fit\" label={t(\"fit\")}>\n <MaximizeIcon />\n </Graph.Control>\n <Graph.ZoomLevel />\n </Graph.Controls>\n }\n edgeName={({ source, target }) => t(\"words.edge\", { source, target })}\n focusLabel={t(\"words.focus\")}\n label={t(\"rail.label\")}\n links={SERVICES}\n neighborLabel={t(\"words.connected\")}\n nodeDescription={t(\"words.description\")}\n nodes={STATIONS}\n overview={<Graph.MiniMap label={t(\"rail.overview\")} />}\n promptLabel={t(\"rail.prompt\")}\n ratio=\"wide\"\n seed={6}\n summary={({ count, name }) => t(\"rail.summary\", { count, name })}\n />\n );\n}\n";
1069
+ //#endregion
1070
+ //#region src/network-graph/examples/topology.example.tsx
1071
+ var topology_example_exports = /* @__PURE__ */ __exportAll({
1072
+ Topology: () => Topology,
1073
+ source: () => source
1074
+ });
1075
+ const ICONS = {
1076
+ core: /* @__PURE__ */ jsx(ServerIcon, {}),
1077
+ data: /* @__PURE__ */ jsx(DatabaseIcon, {}),
1078
+ edge: /* @__PURE__ */ jsx(GlobeIcon, {}),
1079
+ ops: /* @__PURE__ */ jsx(ClockIcon, {})
1080
+ };
1081
+ const SERVICES = [
1082
+ {
1083
+ group: "edge",
1084
+ id: "api-gateway",
1085
+ weight: 9
1086
+ },
1087
+ {
1088
+ group: "edge",
1089
+ id: "cdn-edge",
1090
+ weight: 3
1091
+ },
1092
+ {
1093
+ group: "core",
1094
+ id: "auth-service",
1095
+ weight: 7
1096
+ },
1097
+ {
1098
+ group: "core",
1099
+ id: "checkout-api",
1100
+ weight: 8
1101
+ },
1102
+ {
1103
+ group: "core",
1104
+ id: "ledger-worker",
1105
+ weight: 6
1106
+ },
1107
+ {
1108
+ group: "core",
1109
+ id: "payout-service",
1110
+ weight: 4
1111
+ },
1112
+ {
1113
+ group: "data",
1114
+ id: "postgres-primary",
1115
+ weight: 8
1116
+ },
1117
+ {
1118
+ group: "data",
1119
+ id: "redis-sessions",
1120
+ weight: 5
1121
+ },
1122
+ {
1123
+ group: "data",
1124
+ id: "kafka-events",
1125
+ weight: 7
1126
+ },
1127
+ {
1128
+ group: "data",
1129
+ id: "search-index",
1130
+ weight: 3
1131
+ },
1132
+ {
1133
+ group: "ops",
1134
+ id: "cron-scheduler",
1135
+ weight: 2
1136
+ },
1137
+ {
1138
+ group: "ops",
1139
+ id: "fax-gateway",
1140
+ weight: 1
1141
+ }
1142
+ ];
1143
+ const CALLS = [
1144
+ {
1145
+ source: "cdn-edge",
1146
+ target: "api-gateway"
1147
+ },
1148
+ {
1149
+ source: "api-gateway",
1150
+ strength: 2,
1151
+ target: "auth-service"
1152
+ },
1153
+ {
1154
+ source: "api-gateway",
1155
+ strength: 2,
1156
+ target: "checkout-api"
1157
+ },
1158
+ {
1159
+ source: "api-gateway",
1160
+ target: "search-index"
1161
+ },
1162
+ {
1163
+ source: "auth-service",
1164
+ strength: 2,
1165
+ target: "redis-sessions"
1166
+ },
1167
+ {
1168
+ source: "auth-service",
1169
+ target: "postgres-primary"
1170
+ },
1171
+ {
1172
+ source: "checkout-api",
1173
+ strength: 2,
1174
+ target: "postgres-primary"
1175
+ },
1176
+ {
1177
+ source: "checkout-api",
1178
+ strength: 2,
1179
+ target: "kafka-events"
1180
+ },
1181
+ {
1182
+ source: "ledger-worker",
1183
+ strength: 2,
1184
+ target: "kafka-events"
1185
+ },
1186
+ {
1187
+ source: "ledger-worker",
1188
+ target: "postgres-primary"
1189
+ },
1190
+ {
1191
+ source: "payout-service",
1192
+ target: "ledger-worker"
1193
+ },
1194
+ {
1195
+ source: "payout-service",
1196
+ target: "kafka-events"
1197
+ },
1198
+ {
1199
+ source: "cron-scheduler",
1200
+ target: "payout-service"
1201
+ },
1202
+ {
1203
+ source: "kafka-events",
1204
+ target: "search-index"
1205
+ }
1206
+ ];
1207
+ function Topology() {
1208
+ const $ = c(57);
1209
+ const { t } = useWords("network-graph");
1210
+ let t0;
1211
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1212
+ t0 = SERVICES.map(_temp);
1213
+ $[0] = t0;
1214
+ } else t0 = $[0];
1215
+ const nodes = t0;
1216
+ let t1;
1217
+ if ($[1] !== t) {
1218
+ t1 = t("topology.caption");
1219
+ $[1] = t;
1220
+ $[2] = t1;
1221
+ } else t1 = $[2];
1222
+ let t2;
1223
+ if ($[3] !== t) {
1224
+ t2 = t("words.clear");
1225
+ $[3] = t;
1226
+ $[4] = t2;
1227
+ } else t2 = $[4];
1228
+ let t3;
1229
+ if ($[5] !== t) {
1230
+ t3 = t("controls");
1231
+ $[5] = t;
1232
+ $[6] = t3;
1233
+ } else t3 = $[6];
1234
+ let t4;
1235
+ if ($[7] !== t) {
1236
+ t4 = t("zoomIn");
1237
+ $[7] = t;
1238
+ $[8] = t4;
1239
+ } else t4 = $[8];
1240
+ let t5;
1241
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
1242
+ t5 = /* @__PURE__ */ jsx(PlusIcon, {});
1243
+ $[9] = t5;
1244
+ } else t5 = $[9];
1245
+ let t6;
1246
+ if ($[10] !== t4) {
1247
+ t6 = /* @__PURE__ */ jsx(Control, {
1248
+ action: "zoomIn",
1249
+ label: t4,
1250
+ children: t5
1251
+ });
1252
+ $[10] = t4;
1253
+ $[11] = t6;
1254
+ } else t6 = $[11];
1255
+ let t7;
1256
+ if ($[12] !== t) {
1257
+ t7 = t("zoomOut");
1258
+ $[12] = t;
1259
+ $[13] = t7;
1260
+ } else t7 = $[13];
1261
+ let t8;
1262
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
1263
+ t8 = /* @__PURE__ */ jsx(MinusIcon, {});
1264
+ $[14] = t8;
1265
+ } else t8 = $[14];
1266
+ let t9;
1267
+ if ($[15] !== t7) {
1268
+ t9 = /* @__PURE__ */ jsx(Control, {
1269
+ action: "zoomOut",
1270
+ label: t7,
1271
+ children: t8
1272
+ });
1273
+ $[15] = t7;
1274
+ $[16] = t9;
1275
+ } else t9 = $[16];
1276
+ let t10;
1277
+ if ($[17] !== t) {
1278
+ t10 = t("fit");
1279
+ $[17] = t;
1280
+ $[18] = t10;
1281
+ } else t10 = $[18];
1282
+ let t11;
1283
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
1284
+ t11 = /* @__PURE__ */ jsx(MaximizeIcon, {});
1285
+ $[19] = t11;
1286
+ } else t11 = $[19];
1287
+ let t12;
1288
+ if ($[20] !== t10) {
1289
+ t12 = /* @__PURE__ */ jsx(Control, {
1290
+ action: "fit",
1291
+ label: t10,
1292
+ children: t11
1293
+ });
1294
+ $[20] = t10;
1295
+ $[21] = t12;
1296
+ } else t12 = $[21];
1297
+ let t13;
1298
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
1299
+ t13 = /* @__PURE__ */ jsx(ZoomLevel, {});
1300
+ $[22] = t13;
1301
+ } else t13 = $[22];
1302
+ let t14;
1303
+ if ($[23] !== t12 || $[24] !== t3 || $[25] !== t6 || $[26] !== t9) {
1304
+ t14 = /* @__PURE__ */ jsxs(Controls, {
1305
+ label: t3,
1306
+ children: [
1307
+ t6,
1308
+ t9,
1309
+ t12,
1310
+ t13
1311
+ ]
1312
+ });
1313
+ $[23] = t12;
1314
+ $[24] = t3;
1315
+ $[25] = t6;
1316
+ $[26] = t9;
1317
+ $[27] = t14;
1318
+ } else t14 = $[27];
1319
+ let t15;
1320
+ let t16;
1321
+ if ($[28] !== t) {
1322
+ t15 = (t17) => {
1323
+ const { source, target } = t17;
1324
+ return t("words.edge", {
1325
+ source,
1326
+ target
1327
+ });
1328
+ };
1329
+ t16 = t("words.focus");
1330
+ $[28] = t;
1331
+ $[29] = t15;
1332
+ $[30] = t16;
1333
+ } else {
1334
+ t15 = $[29];
1335
+ t16 = $[30];
1336
+ }
1337
+ let t17;
1338
+ if ($[31] !== t) {
1339
+ t17 = t("topology.label");
1340
+ $[31] = t;
1341
+ $[32] = t17;
1342
+ } else t17 = $[32];
1343
+ let t18;
1344
+ if ($[33] !== t) {
1345
+ t18 = t("words.connected");
1346
+ $[33] = t;
1347
+ $[34] = t18;
1348
+ } else t18 = $[34];
1349
+ let t19;
1350
+ if ($[35] !== t) {
1351
+ t19 = t("words.description");
1352
+ $[35] = t;
1353
+ $[36] = t19;
1354
+ } else t19 = $[36];
1355
+ let t20;
1356
+ if ($[37] !== t) {
1357
+ t20 = t("topology.overview");
1358
+ $[37] = t;
1359
+ $[38] = t20;
1360
+ } else t20 = $[38];
1361
+ let t21;
1362
+ if ($[39] !== t20) {
1363
+ t21 = /* @__PURE__ */ jsx(MiniMap, { label: t20 });
1364
+ $[39] = t20;
1365
+ $[40] = t21;
1366
+ } else t21 = $[40];
1367
+ let t22;
1368
+ if ($[41] !== t) {
1369
+ t22 = t("topology.prompt");
1370
+ $[41] = t;
1371
+ $[42] = t22;
1372
+ } else t22 = $[42];
1373
+ let t23;
1374
+ if ($[43] !== t) {
1375
+ t23 = (t24) => {
1376
+ const { count, name } = t24;
1377
+ return t("topology.summary", {
1378
+ count,
1379
+ name
1380
+ });
1381
+ };
1382
+ $[43] = t;
1383
+ $[44] = t23;
1384
+ } else t23 = $[44];
1385
+ let t24;
1386
+ if ($[45] !== t1 || $[46] !== t14 || $[47] !== t15 || $[48] !== t16 || $[49] !== t17 || $[50] !== t18 || $[51] !== t19 || $[52] !== t2 || $[53] !== t21 || $[54] !== t22 || $[55] !== t23) {
1387
+ t24 = /* @__PURE__ */ jsx(NetworkGraph, {
1388
+ caption: t1,
1389
+ clearLabel: t2,
1390
+ controls: t14,
1391
+ defaultFocus: "checkout-api",
1392
+ edgeName: t15,
1393
+ focusLabel: t16,
1394
+ label: t17,
1395
+ links: CALLS,
1396
+ neighborLabel: t18,
1397
+ nodeDescription: t19,
1398
+ nodes,
1399
+ overview: t21,
1400
+ promptLabel: t22,
1401
+ ratio: "wide",
1402
+ summary: t23
1403
+ });
1404
+ $[45] = t1;
1405
+ $[46] = t14;
1406
+ $[47] = t15;
1407
+ $[48] = t16;
1408
+ $[49] = t17;
1409
+ $[50] = t18;
1410
+ $[51] = t19;
1411
+ $[52] = t2;
1412
+ $[53] = t21;
1413
+ $[54] = t22;
1414
+ $[55] = t23;
1415
+ $[56] = t24;
1416
+ } else t24 = $[56];
1417
+ return t24;
1418
+ }
1419
+ function _temp(t0) {
1420
+ const { group, id, weight } = t0;
1421
+ return {
1422
+ icon: ICONS[group],
1423
+ id,
1424
+ label: id,
1425
+ weight
1426
+ };
1427
+ }
1428
+ const source = "import { type ReactElement } from \"react\";\n\nimport {\n ClockIcon,\n DatabaseIcon,\n GlobeIcon,\n MaximizeIcon,\n MinusIcon,\n PlusIcon,\n ServerIcon,\n} from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Graph, NetworkGraph } from \"@stealthscale/component-graphs\";\n\nconst ICONS = {\n core: <ServerIcon />,\n data: <DatabaseIcon />,\n edge: <GlobeIcon />,\n ops: <ClockIcon />,\n};\n\nconst SERVICES = [\n { group: \"edge\", id: \"api-gateway\", weight: 9 },\n { group: \"edge\", id: \"cdn-edge\", weight: 3 },\n { group: \"core\", id: \"auth-service\", weight: 7 },\n { group: \"core\", id: \"checkout-api\", weight: 8 },\n { group: \"core\", id: \"ledger-worker\", weight: 6 },\n { group: \"core\", id: \"payout-service\", weight: 4 },\n { group: \"data\", id: \"postgres-primary\", weight: 8 },\n { group: \"data\", id: \"redis-sessions\", weight: 5 },\n { group: \"data\", id: \"kafka-events\", weight: 7 },\n { group: \"data\", id: \"search-index\", weight: 3 },\n { group: \"ops\", id: \"cron-scheduler\", weight: 2 },\n { group: \"ops\", id: \"fax-gateway\", weight: 1 },\n] as const;\n\nconst CALLS = [\n { source: \"cdn-edge\", target: \"api-gateway\" },\n { source: \"api-gateway\", strength: 2, target: \"auth-service\" },\n { source: \"api-gateway\", strength: 2, target: \"checkout-api\" },\n { source: \"api-gateway\", target: \"search-index\" },\n { source: \"auth-service\", strength: 2, target: \"redis-sessions\" },\n { source: \"auth-service\", target: \"postgres-primary\" },\n { source: \"checkout-api\", strength: 2, target: \"postgres-primary\" },\n { source: \"checkout-api\", strength: 2, target: \"kafka-events\" },\n { source: \"ledger-worker\", strength: 2, target: \"kafka-events\" },\n { source: \"ledger-worker\", target: \"postgres-primary\" },\n { source: \"payout-service\", target: \"ledger-worker\" },\n { source: \"payout-service\", target: \"kafka-events\" },\n { source: \"cron-scheduler\", target: \"payout-service\" },\n { source: \"kafka-events\", target: \"search-index\" },\n];\n\nexport function Topology(): ReactElement {\n const { t } = useWords(\"network-graph\");\n const nodes = SERVICES.map(({ group, id, weight }) => ({\n icon: ICONS[group],\n id,\n label: id,\n weight,\n }));\n\n return (\n <NetworkGraph\n caption={t(\"topology.caption\")}\n clearLabel={t(\"words.clear\")}\n controls={\n <Graph.Controls label={t(\"controls\")}>\n <Graph.Control action=\"zoomIn\" label={t(\"zoomIn\")}>\n <PlusIcon />\n </Graph.Control>\n <Graph.Control action=\"zoomOut\" label={t(\"zoomOut\")}>\n <MinusIcon />\n </Graph.Control>\n <Graph.Control action=\"fit\" label={t(\"fit\")}>\n <MaximizeIcon />\n </Graph.Control>\n <Graph.ZoomLevel />\n </Graph.Controls>\n }\n defaultFocus=\"checkout-api\"\n edgeName={({ source, target }) => t(\"words.edge\", { source, target })}\n focusLabel={t(\"words.focus\")}\n label={t(\"topology.label\")}\n links={CALLS}\n neighborLabel={t(\"words.connected\")}\n nodeDescription={t(\"words.description\")}\n nodes={nodes}\n overview={<Graph.MiniMap label={t(\"topology.overview\")} />}\n promptLabel={t(\"topology.prompt\")}\n ratio=\"wide\"\n summary={({ count, name }) => t(\"topology.summary\", { count, name })}\n />\n );\n}\n";
1429
+ //#endregion
1430
+ //#region src/network-graph/network-graph.specimen.tsx
1431
+ /**
1432
+ * Catalogue page for the network graph.
1433
+ *
1434
+ * @remarks
1435
+ * Every scene is hand-written, because the network graph has no recipe of its own: a service
1436
+ * topology focused on one service with the controls and the overview map, a mentoring network
1437
+ * lit two hops deep, modules sized by their links, a focus kept in the caller's state, a supply
1438
+ * network pinned for a report, forty rail stations, and a network without a node. Every scene
1439
+ * renders a component from `examples/` and shows that file as its source. The words are keys
1440
+ * under `network-graph` in `locales/en/specimen/network-graph.json`.
1441
+ */
1442
+ /**
1443
+ * Hand-written scene for a service topology focused on one service.
1444
+ */
1445
+ const services = {
1446
+ about: "network-graph.topology.about",
1447
+ draw: () => /* @__PURE__ */ jsx(Room, {
1448
+ size: "4xl",
1449
+ children: /* @__PURE__ */ jsx(Topology, {})
1450
+ }),
1451
+ example: topology_example_exports,
1452
+ title: "network-graph.topology.title"
1453
+ };
1454
+ /**
1455
+ * Hand-written scene for a network lit two hops deep.
1456
+ */
1457
+ const deep = {
1458
+ about: "network-graph.mentoring.about",
1459
+ draw: () => /* @__PURE__ */ jsx(Room, {
1460
+ size: "2xl",
1461
+ children: /* @__PURE__ */ jsx(Mentoring, {})
1462
+ }),
1463
+ example: mentoring_example_exports,
1464
+ title: "network-graph.mentoring.title"
1465
+ };
1466
+ /**
1467
+ * Hand-written scene for discs sized by the number of their links.
1468
+ */
1469
+ const linked = {
1470
+ about: "network-graph.modules.about",
1471
+ draw: () => /* @__PURE__ */ jsx(Room, {
1472
+ size: "2xl",
1473
+ children: /* @__PURE__ */ jsx(Modules, {})
1474
+ }),
1475
+ example: modules_example_exports,
1476
+ title: "network-graph.modules.title"
1477
+ };
1478
+ /**
1479
+ * Hand-written scene for a focus kept in the caller's state.
1480
+ */
1481
+ const kept = {
1482
+ about: "network-graph.controlled.about",
1483
+ draw: () => /* @__PURE__ */ jsx(Room, {
1484
+ size: "2xl",
1485
+ children: /* @__PURE__ */ jsx(Controlled, {})
1486
+ }),
1487
+ example: controlled_example_exports,
1488
+ title: "network-graph.controlled.title"
1489
+ };
1490
+ /**
1491
+ * Hand-written scene for nodes pinned where the layout put them.
1492
+ */
1493
+ const fixed = {
1494
+ about: "network-graph.pinned.about",
1495
+ draw: () => /* @__PURE__ */ jsx(Room, {
1496
+ size: "2xl",
1497
+ children: /* @__PURE__ */ jsx(Pinned, {})
1498
+ }),
1499
+ example: pinned_example_exports,
1500
+ title: "network-graph.pinned.title"
1501
+ };
1502
+ /**
1503
+ * Hand-written scene for forty stations with the overview map.
1504
+ */
1505
+ const large = {
1506
+ about: "network-graph.rail.about",
1507
+ draw: () => /* @__PURE__ */ jsx(Room, {
1508
+ size: "4xl",
1509
+ children: /* @__PURE__ */ jsx(Rail, {})
1510
+ }),
1511
+ example: rail_example_exports,
1512
+ title: "network-graph.rail.title"
1513
+ };
1514
+ /**
1515
+ * Hand-written scene for a network without a node.
1516
+ */
1517
+ const none = {
1518
+ about: "network-graph.empty.about",
1519
+ draw: () => /* @__PURE__ */ jsx(Room, {
1520
+ size: "2xl",
1521
+ children: /* @__PURE__ */ jsx(Empty, {})
1522
+ }),
1523
+ example: empty_example_exports,
1524
+ title: "network-graph.empty.title"
1525
+ };
1526
+ var network_graph_specimen_default = specimen({
1527
+ about: "network-graph.about",
1528
+ id: "components/graphs/network-graph",
1529
+ imports: "import { Graph, NetworkGraph } from \"@stealthscale/component-graphs\";",
1530
+ scenes: [
1531
+ services,
1532
+ deep,
1533
+ linked,
1534
+ kept,
1535
+ fixed,
1536
+ large,
1537
+ none
1538
+ ],
1539
+ title: "network-graph.title"
1540
+ });
1541
+ //#endregion
1542
+ export { deep, network_graph_specimen_default as default, fixed, kept, large, linked, none, services };