hexwright 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -228,6 +228,22 @@ package prefix, which is inferred automatically:
228
228
  <base>.common Shared
229
229
  ```
230
230
 
231
+ ### What a companion object contributes
232
+
233
+ Nothing. A `companion object` is a separate object with its own type, so what it
234
+ names belongs to it rather than to the class it is written inside. The graph
235
+ models types, and a companion is not one.
236
+
237
+ Attributing its contents to the enclosing class is what made a sealed root appear
238
+ to depend on its own variants — the factory naming them lives in the companion —
239
+ and made a value class wrapping a `UUID` appear to depend on an id generator.
240
+
241
+ The cost is deliberate and worth knowing: **a coupling that exists only inside a
242
+ companion is not reported.** A domain entity whose companion holds
243
+ `fun fromRow(row: JpaRow)` would otherwise be caught as a layer back-reference.
244
+ Mapping belongs in the adapter in this architecture, so it should be rare, but it
245
+ is not impossible.
246
+
231
247
  ## What it produces
232
248
 
233
249
  ```
@@ -364,6 +380,39 @@ domains 16
364
380
  Zero Ports or a domain count of 1 means the paths or the base package are not
365
381
  matching your layout yet.
366
382
 
383
+ ## Identity
384
+
385
+ A type keeping another aggregate's id — `MediaItem` holding a `BlobId`, not a
386
+ `Blob` — is referencing that aggregate, and referencing it the deliberately weaker
387
+ way. That is drawn as `REFERENCES`, pointed at the aggregate rather than at the id,
388
+ and styled lighter than a direct dependency so the two do not read alike. It never
389
+ counts as a boundary violation: pointing at another context by id is how you avoid
390
+ coupling to it, and reporting it would penalise the design that got it right.
391
+
392
+ Nothing in the source says which id belongs to what, so the profile says which
393
+ convention to read:
394
+
395
+ ```yaml
396
+ identity:
397
+ from: property # the type declaring `val id: T` owns T
398
+ property: id
399
+ ```
400
+
401
+ ```yaml
402
+ identity:
403
+ from: suffix # BlobId → Blob
404
+ suffix: Id
405
+ ```
406
+
407
+ `property` is the default because it is structural, and because it survives an
408
+ aggregate whose name is not the identifier's stem — `MediaId` identifies
409
+ `MediaItem`, and stripping the suffix would look for a `Media` that does not
410
+ exist. Use `suffix` when aggregates do not carry their own id.
411
+
412
+ Where an identifier cannot be resolved — its aggregate is outside the analysed
413
+ source, or two unrelated types claim it — the edge stays on the identifier rather
414
+ than being pointed at a guess. Remove the `identity` block and none are resolved.
415
+
367
416
  ## Boundary rules
368
417
 
369
418
  An Entity may be touched by, within the same domain: `Service`, `Port`, `Entity`,
package/dist/cli.js CHANGED
@@ -750,6 +750,10 @@ function trim(a, c, b, ab, bb) {
750
750
  }
751
751
  var EDGE = {
752
752
  DEPENDS_ON: { width: 1.9, dash: "", bow: 0, arrow: "vee", scale: 0.95 },
753
+ // Thinner and broken up than DEPENDS_ON, because it is a lighter coupling: the
754
+ // reference runs through an identifier, not the type. The distinction is only
755
+ // worth drawing if it reads as weaker at a glance.
756
+ REFERENCES: { width: 1.4, dash: "2 4", bow: 24, arrow: "vee", scale: 0.9 },
753
757
  IMPLEMENTS: { width: 2.2, dash: "9 5", bow: 42, arrow: "triangle", scale: 1.35 },
754
758
  EXTENDS: { width: 3.4, dash: "3 3", bow: 58, arrow: "triangle", scale: 1.6 }
755
759
  };
@@ -1275,7 +1279,7 @@ function collectSigs(body) {
1275
1279
  }
1276
1280
  return out;
1277
1281
  }
1278
- function ctorParams(header2) {
1282
+ function ctorParts(header2) {
1279
1283
  const i = header2.indexOf("(");
1280
1284
  if (i < 0) return [];
1281
1285
  let depth = 0;
@@ -1301,6 +1305,22 @@ function ctorParams(header2) {
1301
1305
  } else cur.push(ch);
1302
1306
  }
1303
1307
  parts.push(cur.join(""));
1308
+ return parts;
1309
+ }
1310
+ function ctorDeclared(header2) {
1311
+ const out = [];
1312
+ for (let p of ctorParts(header2)) {
1313
+ p = (p.split("=")[0] ?? "").replace(/\s+/g, " ").trim();
1314
+ p = p.replace(/^(?:@\w+(?:\([^)]*\))?\s*)*/, "");
1315
+ const m = /^(?:private |internal |protected |override )*(?:val|var)\s+(\w+)\s*:\s*(.+)$/.exec(
1316
+ p
1317
+ );
1318
+ if (m) out.push({ name: m[1], type: m[2].trim() });
1319
+ }
1320
+ return out;
1321
+ }
1322
+ function ctorParams(header2) {
1323
+ const parts = ctorParts(header2);
1304
1324
  const res = [];
1305
1325
  for (let p of parts) {
1306
1326
  p = (p.split("=")[0] ?? "").replace(/\s+/g, " ").trim();
@@ -1407,6 +1427,41 @@ function bodyEnd(fi, di) {
1407
1427
  for (const s of fi.stops) if (s > d.line && s < end) end = s;
1408
1428
  return end;
1409
1429
  }
1430
+ var COMPANION = /^\s+(?:public |internal |private |protected )*companion\s+object\b/;
1431
+ function bodyOf(fi, di) {
1432
+ const d = fi.decls[di];
1433
+ const lines = fi.lines.slice(d.line, bodyEnd(fi, di));
1434
+ for (let i = 0; i < lines.length; i++) {
1435
+ if (!COMPANION.test(lines[i])) continue;
1436
+ let open = lines[i].includes("{") ? i : -1;
1437
+ if (open < 0) {
1438
+ for (let k = i + 1; k < lines.length; k++) {
1439
+ const t = lines[k].trim();
1440
+ if (!t) continue;
1441
+ if (t.startsWith("{")) open = k;
1442
+ break;
1443
+ }
1444
+ }
1445
+ if (open < 0) {
1446
+ lines[i] = "";
1447
+ continue;
1448
+ }
1449
+ let depth = 0;
1450
+ let j = i;
1451
+ for (; j < lines.length; j++) {
1452
+ if (j >= open) {
1453
+ for (const ch of lines[j]) {
1454
+ if (ch === "{") depth++;
1455
+ else if (ch === "}") depth--;
1456
+ }
1457
+ }
1458
+ lines[j] = "";
1459
+ if (j >= open && depth <= 0) break;
1460
+ }
1461
+ i = j;
1462
+ }
1463
+ return lines;
1464
+ }
1410
1465
  function walk(dir, out = []) {
1411
1466
  for (const e of readdirSync2(dir)) {
1412
1467
  const p = join2(dir, e);
@@ -1529,8 +1584,7 @@ function extractKotlin(srcRoot, profile, project, ref) {
1529
1584
  const domain = domainOf(fi.pkg);
1530
1585
  for (let di = 0; di < fi.decls.length; di++) {
1531
1586
  const d = fi.decls[di];
1532
- const end = bodyEnd(fi, di);
1533
- const body = fi.lines.slice(d.line, end);
1587
+ const body = bodyOf(fi, di);
1534
1588
  const struct = structOf(d.kind);
1535
1589
  const sigs = collectSigs(body);
1536
1590
  const api = [];
@@ -1539,13 +1593,18 @@ function extractKotlin(srcRoot, profile, project, ref) {
1539
1593
  const braceAt = headerFull.indexOf("{");
1540
1594
  const header2 = braceAt >= 0 ? headerFull.slice(0, braceAt) : headerFull;
1541
1595
  const props = ctorParams(header2);
1596
+ const declared = /* @__PURE__ */ new Map();
1597
+ for (const p of ctorDeclared(header2)) declared.set(p.name, p.type);
1542
1598
  if (braceAt >= 0) {
1543
1599
  const rest = body.slice(header2.split("\n").length - 1);
1544
1600
  const first = rest[0];
1545
1601
  if (first !== void 0) rest[0] = first.slice(first.indexOf("{") + 1);
1546
1602
  for (const ln of rest) {
1547
1603
  const pm = PROP.exec(ln);
1548
- if (pm) props.push(`${pm[1]}: ${pm[2].trim().replace(/,$/, "")}`);
1604
+ if (!pm) continue;
1605
+ const type = pm[2].trim().replace(/,$/, "");
1606
+ props.push(`${pm[1]}: ${type}`);
1607
+ declared.set(pm[1], type);
1549
1608
  }
1550
1609
  }
1551
1610
  if (d.kind.includes("enum")) props.push(...enumEntries(body.join("\n")));
@@ -1564,7 +1623,8 @@ function extractKotlin(srcRoot, profile, project, ref) {
1564
1623
  file: fi.rel,
1565
1624
  line: d.line + 1,
1566
1625
  struct,
1567
- sigs
1626
+ sigs,
1627
+ declared
1568
1628
  });
1569
1629
  byPkg.set(fi.pkg, [...byPkg.get(fi.pkg) ?? [], id]);
1570
1630
  }
@@ -1589,8 +1649,7 @@ function extractKotlin(srcRoot, profile, project, ref) {
1589
1649
  for (let di = 0; di < fi.decls.length; di++) {
1590
1650
  const d = fi.decls[di];
1591
1651
  const id = `${fi.pkg}.${d.name}`;
1592
- const end = bodyEnd(fi, di);
1593
- const body = fi.lines.slice(d.line, end).join("\n");
1652
+ const body = bodyOf(fi, di).join("\n");
1594
1653
  for (const sup of parseSupertypes(fi.lines, d.line)) {
1595
1654
  const tgt = visible.get(sup);
1596
1655
  if (tgt) supers.push([id, tgt]);
@@ -1634,8 +1693,7 @@ function extractKotlin(srcRoot, profile, project, ref) {
1634
1693
  for (let di = 0; di < fi.decls.length; di++) {
1635
1694
  const d = fi.decls[di];
1636
1695
  const id = `${fi.pkg}.${d.name}`;
1637
- const end = bodyEnd(fi, di);
1638
- const body = fi.lines.slice(d.line, end).join("\n");
1696
+ const body = bodyOf(fi, di).join("\n");
1639
1697
  const bind = /* @__PURE__ */ new Map();
1640
1698
  for (const m of body.matchAll(FIELD)) {
1641
1699
  const tgt = visible.get(m[2]);
@@ -1674,6 +1732,51 @@ function extractKotlin(srcRoot, profile, project, ref) {
1674
1732
  }
1675
1733
  }
1676
1734
  const supSet = new Set(supers.map(([c, p]) => key(c, p)));
1735
+ const parentsOf = /* @__PURE__ */ new Map();
1736
+ for (const [c, p] of supers) parentsOf.set(c, [...parentsOf.get(c) ?? [], p]);
1737
+ const inherits = (child, ancestor) => {
1738
+ const seen = /* @__PURE__ */ new Set();
1739
+ const walk2 = [child];
1740
+ while (walk2.length) {
1741
+ const cur = walk2.pop();
1742
+ if (cur === ancestor && cur !== child) return true;
1743
+ if (seen.has(cur)) continue;
1744
+ seen.add(cur);
1745
+ walk2.push(...parentsOf.get(cur) ?? []);
1746
+ }
1747
+ return false;
1748
+ };
1749
+ const aggregateOf = /* @__PURE__ */ new Map();
1750
+ const ambiguous = [];
1751
+ const identity = profile.identity;
1752
+ if (identity?.from === "property") {
1753
+ const want = identity.property ?? "id";
1754
+ const claims = /* @__PURE__ */ new Map();
1755
+ for (const [id, t] of types) {
1756
+ const written = t.declared.get(want);
1757
+ if (written === void 0) continue;
1758
+ const bare = written.replace(/[?\s]/g, "");
1759
+ const target = (visCache.get(t.file) ?? /* @__PURE__ */ new Map()).get(bare);
1760
+ if (target) claims.set(target, [...claims.get(target) ?? [], id]);
1761
+ }
1762
+ for (const [idType, holders] of claims) {
1763
+ const roots = holders.filter((h) => !holders.some((o) => o !== h && inherits(h, o)));
1764
+ if (roots.length === 1) aggregateOf.set(idType, roots[0]);
1765
+ else ambiguous.push(idType);
1766
+ }
1767
+ } else if (identity?.from === "suffix") {
1768
+ const suffix = identity.suffix ?? "Id";
1769
+ for (const [id, t] of types) {
1770
+ if (!t.name.endsWith(suffix) || t.name === suffix) continue;
1771
+ const stem = t.name.slice(0, -suffix.length);
1772
+ const pkg = id.slice(0, id.length - t.name.length - 1);
1773
+ const here = (byPkg.get(pkg) ?? []).filter((x) => types.get(x)?.name === stem);
1774
+ const anywhere = [...types.values()].filter((x) => x.name === stem).map((x) => x.id);
1775
+ const hit = here.length === 1 ? here : anywhere;
1776
+ if (hit.length === 1) aggregateOf.set(id, hit[0]);
1777
+ else if (hit.length > 1) ambiguous.push(id);
1778
+ }
1779
+ }
1677
1780
  const edges = [];
1678
1781
  const push2 = (src, dst, rel, weight) => {
1679
1782
  const s = types.get(src);
@@ -1690,20 +1793,47 @@ function extractKotlin(srcRoot, profile, project, ref) {
1690
1793
  rel,
1691
1794
  weight,
1692
1795
  crossDomain: s.domain !== d.domain,
1796
+ // Not "this edge is an identifier reference" — those became REFERENCES and
1797
+ // point at the aggregate. This says the destination is a value type in the
1798
+ // domain model, which nearly everything touches, so the picture folds them
1799
+ // away by default. What lands here is value objects, enums, and identifiers
1800
+ // whose aggregate is outside the analysed source.
1693
1801
  identifierOnly: d.component === "VO" && d.sublayer === "model",
1694
1802
  viaSignature: viaSig.has(k),
1695
1803
  contracts: rel === "DEPENDS_ON" ? contracts : [],
1696
- violation: violationOf(profile, s, d, layerViol.has(k))
1804
+ // Referencing another context's aggregate by id is how you avoid coupling to
1805
+ // it. Reporting that as a breach would penalise the design that got it right,
1806
+ // so REFERENCES carries no verdict — `crossDomain` still marks where it runs.
1807
+ violation: rel === "REFERENCES" ? "" : violationOf(profile, s, d, layerViol.has(k))
1697
1808
  });
1698
1809
  };
1699
1810
  for (const [c, p] of supSet.size ? [...supSet].map((k) => k.split("\0")) : []) {
1700
1811
  const parent = types.get(p);
1701
1812
  push2(c, p, parent.struct === "Interface" ? "IMPLEMENTS" : "EXTENDS", 1);
1702
1813
  }
1814
+ const refs = /* @__PURE__ */ new Map();
1703
1815
  for (const [k, w] of dep) {
1704
1816
  if (supSet.has(k)) continue;
1705
1817
  const [s, d] = k.split("\0");
1706
- push2(s, d, "DEPENDS_ON", w);
1818
+ const g = aggregateOf.get(d);
1819
+ if (g === void 0) {
1820
+ push2(s, d, "DEPENDS_ON", w);
1821
+ continue;
1822
+ }
1823
+ if (g === s || inherits(s, g)) continue;
1824
+ if (dep.has(key(s, g))) continue;
1825
+ const rk = key(s, g);
1826
+ refs.set(rk, (refs.get(rk) ?? 0) + w);
1827
+ }
1828
+ for (const [k, w] of refs) {
1829
+ const [s, d] = k.split("\0");
1830
+ push2(s, d, "REFERENCES", w);
1831
+ }
1832
+ if (ambiguous.length) {
1833
+ process.stderr.write(
1834
+ `warning: cannot tell what these identifiers identify \u2014 ${ambiguous.map((x) => x.split(".").pop()).sort().join(", ")}
1835
+ `
1836
+ );
1707
1837
  }
1708
1838
  const nodes = [...types.values()].map(({ struct: _s, sigs: _g, ...n }) => n);
1709
1839
  nodes.sort((a, b) => a.id.localeCompare(b.id));
@@ -2045,7 +2175,7 @@ var shell = () => `<!doctype html>
2045
2175
  Off = keep the fixed coordinates above.</div></div>
2046
2176
 
2047
2177
  <h2>Edges</h2>
2048
- <label><input type=checkbox id="showId">Show identifier edges</label>
2178
+ <label><input type=checkbox id="showId">Show value-type edges</label>
2049
2179
  <label><input type=checkbox id="crossOnly">Cross-domain edges only</label>
2050
2180
  <div class="sub" style="margin:6px 0 0"><b>Identifier edges</b><div class="d">references like
2051
2181
  FamilyId\xB7UserId \u2014 a shared coordinate system, not coupling. Hidden by default.</div></div>
@@ -2053,6 +2183,8 @@ var shell = () => `<!doctype html>
2053
2183
  <h2>Edge types</h2>
2054
2184
  <label><input type=checkbox class=rf value="DEPENDS_ON" checked>
2055
2185
  <i></i>DEPENDS_ON <span class="mut">straight \xB7 open V</span><span class="n" id="cDEPENDS_ON"></span></label>
2186
+ <label><input type=checkbox class=rf value="REFERENCES" checked>
2187
+ <i class="d"></i>REFERENCES <span class="mut">by id \xB7 fine dots</span><span class="n" id="cREFERENCES"></span></label>
2056
2188
  <label><input type=checkbox class=rf value="IMPLEMENTS" checked>
2057
2189
  <i class="d"></i>IMPLEMENTS <span class="mut">curved \xB7 long dash</span><span class="n" id="cIMPLEMENTS"></span></label>
2058
2190
  <label><input type=checkbox class=rf value="EXTENDS" checked>
@@ -2164,7 +2296,11 @@ render only
2164
2296
  --layout <l> organic | grid | hex
2165
2297
  [organic for delta\xB7domain\xB7violations, hex for core\xB7all]
2166
2298
  --image <file> output path; .svg, or .png to rasterize [graph.svg]
2167
- --identifiers include identifier-only references (FamilyId\xB7UserId)
2299
+ --identifiers include references to domain value types \u2014 value objects,
2300
+ enums, and identifiers whose aggregate is out of scope.
2301
+ A resolved identifier is drawn as REFERENCES at the
2302
+ aggregate instead and is not folded away. Flag name kept
2303
+ for compatibility.
2168
2304
 
2169
2305
  Nothing to draw \u2014 no violations, or a branch that only adds types and so has
2170
2306
  no before state \u2014 is reported on stdout and exits 0.
package/dist/client.js CHANGED
@@ -318,7 +318,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
318
318
  `).concat(r.picking?`if(outColor.a == 0.0) discard;
319
319
  else outColor = vIndex;`:"",`
320
320
  }
321
- `),s=Jm(a,n,o);s.aPosition=a.getAttribLocation(s,"aPosition"),s.aIndex=a.getAttribLocation(s,"aIndex"),s.aVertType=a.getAttribLocation(s,"aVertType"),s.aTransform=a.getAttribLocation(s,"aTransform"),s.aAtlasId=a.getAttribLocation(s,"aAtlasId"),s.aTex=a.getAttribLocation(s,"aTex"),s.aPointAPointB=a.getAttribLocation(s,"aPointAPointB"),s.aPointCPointD=a.getAttribLocation(s,"aPointCPointD"),s.aLineWidth=a.getAttribLocation(s,"aLineWidth"),s.aColor=a.getAttribLocation(s,"aColor"),s.aCornerRadius=a.getAttribLocation(s,"aCornerRadius"),s.aBorderColor=a.getAttribLocation(s,"aBorderColor"),s.uPanZoomMatrix=a.getUniformLocation(s,"uPanZoomMatrix"),s.uAtlasSize=a.getUniformLocation(s,"uAtlasSize"),s.uBGColor=a.getUniformLocation(s,"uBGColor"),s.uZoom=a.getUniformLocation(s,"uZoom"),s.uTextures=[];for(var u=0;u<this.batchManager.getMaxAtlasesPerBatch();u++)s.uTextures.push(a.getUniformLocation(s,"uTexture".concat(u)));return s}},{key:"_createVAO",value:function(){var r=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=r.length/2;var a=this.maxInstances,n=this.gl,i=this.program,o=n.createVertexArray();return n.bindVertexArray(o),s0(n,"vec2",i.aPosition,r),this.transformBuffer=l0(n,a,i.aTransform),this.indexBuffer=Zt(n,a,"vec4",i.aIndex),this.vertTypeBuffer=Zt(n,a,"int",i.aVertType),this.atlasIdBuffer=Zt(n,a,"int",i.aAtlasId),this.texBuffer=Zt(n,a,"vec4",i.aTex),this.pointAPointBBuffer=Zt(n,a,"vec4",i.aPointAPointB),this.pointCPointDBuffer=Zt(n,a,"vec4",i.aPointCPointD),this.lineWidthBuffer=Zt(n,a,"vec2",i.aLineWidth),this.colorBuffer=Zt(n,a,"vec4",i.aColor),this.cornerRadiusBuffer=Zt(n,a,"vec4",i.aCornerRadius),this.borderColorBuffer=Zt(n,a,"vec4",i.aBorderColor),n.bindVertexArray(null),o}},{key:"buffers",get:function(){var r=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(a){return yr(a,"Buffer")}).map(function(a){return r[a]})),this._buffers}},{key:"startFrame",value:function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xa.SCREEN;this.panZoomMatrix=r,this.renderTarget=a,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"_isVisible",value:function(r,a){return r.visible()?a&&a.isVisible?a.isVisible(r):!0:!1}},{key:"drawTexture",value:function(r,a,n){var i=this.atlasManager,o=this.batchManager,s=i.getRenderTypeOpts(n);if(this._isVisible(r,s)&&!(r.isEdge()&&!this._isValidEdge(r))){if(this.renderTarget.picking&&s.getTexPickingMode){var u=s.getTexPickingMode(r);if(u===oi.IGNORE)return;if(u==oi.USE_BB){this.drawPickingRectangle(r,a,n);return}}var l=i.getAtlasInfo(r,n),f=zt(l),v;try{for(f.s();!(v=f.n()).done;){var c=v.value,h=c.atlas,d=c.tex1,g=c.tex2;o.canAddToCurrentBatch(h)||this.endBatch();for(var m=o.getAtlasIndexForBatch(h),p=0,y=[[d,!0],[g,!1]];p<y.length;p++){var b=dt(y[p],2),E=b[0],C=b[1];if(E.w!=0){var A=this.instanceCount;this.vertTypeBuffer.getView(A)[0]=is;var D=this.indexBuffer.getView(A);sa(a,D);var N=this.atlasIdBuffer.getView(A);N[0]=m;var O=this.texBuffer.getView(A);O[0]=E.x,O[1]=E.y,O[2]=E.w,O[3]=E.h;var R=this.transformBuffer.getMatrixView(A);this.setTransformMatrix(r,R,s,c,C),this.instanceCount++,C||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(P){f.e(P)}finally{f.f()}}}},{key:"setTransformMatrix",value:function(r,a,n,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=0;if(n.shapeProps&&n.shapeProps.padding&&(s=r.pstyle(n.shapeProps.padding).pfValue),i){var u=i.bb,l=i.tex1,f=i.tex2,v=l.w/(l.w+f.w);o||(v=1-v);var c=this._getAdjustedBB(u,s,o,v);this._applyTransformMatrix(a,c,n,r)}else{var h=n.getBoundingBox(r),d=this._getAdjustedBB(h,s,!0,1);this._applyTransformMatrix(a,d,n,r)}}},{key:"_applyTransformMatrix",value:function(r,a,n,i){var o,s;Uf(r);var u=n.getRotation?n.getRotation(i):0;if(u!==0){var l=n.getRotationPoint(i),f=l.x,v=l.y;$n(r,r,[f,v]),Hf(r,r,u);var c=n.getRotationOffset(i);o=c.x+(a.xOffset||0),s=c.y+(a.yOffset||0)}else o=a.x1,s=a.y1;$n(r,r,[o,s]),Ds(r,r,[a.w,a.h])}},{key:"_getAdjustedBB",value:function(r,a,n,i){var o=r.x1,s=r.y1,u=r.w,l=r.h,f=r.yOffset;a&&(o-=a,s-=a,u+=2*a,l+=2*a);var v=0,c=u*i;return n&&i<1?u=c:!n&&i<1&&(v=u-c,o+=v,u=c),{x1:o,y1:s,w:u,h:l,xOffset:v,yOffset:f}}},{key:"drawPickingRectangle",value:function(r,a,n){var i=this.atlasManager.getRenderTypeOpts(n),o=this.instanceCount;this.vertTypeBuffer.getView(o)[0]=la;var s=this.indexBuffer.getView(o);sa(a,s);var u=this.colorBuffer.getView(o);zr([0,0,0],1,u);var l=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(r,l,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:"drawNode",value:function(r,a,n){var i=this.simpleShapeOptions.get(n);if(this._isVisible(r,i)){var o=i.shapeProps,s=this._getVertTypeForShape(r,o.shape);if(s===void 0||i.isSimple&&!i.isSimple(r,this.renderTarget)){this.drawTexture(r,a,n);return}var u=this.instanceCount;if(this.vertTypeBuffer.getView(u)[0]=s,s===kn||s===Va){var l=i.getBoundingBox(r),f=this._getCornerRadius(r,o.radius,l),v=this.cornerRadiusBuffer.getView(u);v[0]=f,v[1]=f,v[2]=f,v[3]=f,s===Va&&(v[0]=0,v[2]=0)}var c=this.indexBuffer.getView(u);sa(a,c);var h=this.renderTarget.picking?1:n==="node-body"?r.effectiveOpacity():1,d=this.renderTarget.picking?1:r.pstyle(o.opacity).value*h,g=r.pstyle(o.color).value,m=this.colorBuffer.getView(u);zr(g,d,m);var p=this.lineWidthBuffer.getView(u);if(p[0]=0,p[1]=0,o.border){var y=r.pstyle("border-width").value;if(y>0){var b=r.pstyle("border-color").value,E=h*r.pstyle("border-opacity").value,C=this.borderColorBuffer.getView(u);zr(b,E,C);var A=r.pstyle("border-position").value;if(A==="inside")p[0]=0,p[1]=-y;else if(A==="outside")p[0]=y,p[1]=0;else{var D=y/2;p[0]=D,p[1]=-D}}}var N=this.transformBuffer.getMatrixView(u);this.setTransformMatrix(r,N,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"_getVertTypeForShape",value:function(r,a){var n=r.pstyle(a).value;switch(n){case"rectangle":return la;case"ellipse":return Ga;case"roundrectangle":case"round-rectangle":return kn;case"bottom-round-rectangle":return Va;default:return}}},{key:"_getCornerRadius",value:function(r,a,n){var i=n.w,o=n.h;if(r.pstyle(a).value==="auto")return Cr(i,o);var s=r.pstyle(a).pfValue,u=i/2,l=o/2;return Math.min(s,l,u)}},{key:"drawEdgeArrow",value:function(r,a,n){if(r.visible()){var i=r._private.rscratch,o,s,u;if(n==="source"?(o=i.arrowStartX,s=i.arrowStartY,u=i.srcArrowAngle):(o=i.arrowEndX,s=i.arrowEndY,u=i.tgtArrowAngle),!(isNaN(o)||o==null||isNaN(s)||s==null||isNaN(u)||u==null)){var l=r.pstyle(n+"-arrow-shape").value;if(l!=="none"){var f=r.pstyle(n+"-arrow-color").value,v=r.pstyle("opacity").value,c=r.pstyle("line-opacity").value,h=v*c,d=r.pstyle("width").pfValue,g=r.pstyle("arrow-scale").value,m=this.r.getArrowWidth(d,g),p=this.instanceCount,y=this.transformBuffer.getMatrixView(p);Uf(y),$n(y,y,[o,s]),Ds(y,y,[m,m]),Hf(y,y,u),this.vertTypeBuffer.getView(p)[0]=os;var b=this.indexBuffer.getView(p);sa(a,b);var E=this.colorBuffer.getView(p);zr(f,h,E),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"drawEdgeLine",value:function(r,a){if(r.visible()){var n=this._getEdgePoints(r);if(n){var i=r.pstyle("opacity").value,o=r.pstyle("line-opacity").value,s=r.pstyle("width").pfValue,u=r.pstyle("line-color").value,l=i*o;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=qf;var v=this.indexBuffer.getView(f);sa(a,v);var c=this.colorBuffer.getView(f);zr(u,l,c);var h=this.lineWidthBuffer.getView(f);h[0]=s;var d=this.pointAPointBBuffer.getView(f);d[0]=n[0],d[1]=n[1],d[2]=n[2],d[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var g=0;g<n.length-2;g+=2){var m=this.instanceCount;this.vertTypeBuffer.getView(m)[0]=Yf;var p=this.indexBuffer.getView(m);sa(a,p);var y=this.colorBuffer.getView(m);zr(u,l,y);var b=this.lineWidthBuffer.getView(m);b[0]=s;var E=n[g-2],C=n[g-1],A=n[g],D=n[g+1],N=n[g+2],O=n[g+3],R=n[g+4],P=n[g+5];g==0&&(E=2*A-N+.001,C=2*D-O+.001),g==n.length-4&&(R=2*N-A+.001,P=2*O-D+.001);var w=this.pointAPointBBuffer.getView(m);w[0]=E,w[1]=C,w[2]=A,w[3]=D;var x=this.pointCPointDBuffer.getView(m);x[0]=N,x[1]=O,x[2]=R,x[3]=P,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"_isValidEdge",value:function(r){var a=r._private.rscratch;return!(a.badLine||a.allpts==null||isNaN(a.allpts[0]))}},{key:"_getEdgePoints",value:function(r){var a=r._private.rscratch;if(this._isValidEdge(r)){var n=a.allpts;if(n.length==4)return n;var i=this._getNumSegments(r);return this._getCurveSegmentPoints(n,i)}}},{key:"_getNumSegments",value:function(r){var a=15;return Math.min(Math.max(a,5),this.maxInstances)}},{key:"_getCurveSegmentPoints",value:function(r,a){if(r.length==4)return r;for(var n=Array((a+1)*2),i=0;i<=a;i++)if(i==0)n[0]=r[0],n[1]=r[1];else if(i==a)n[i*2]=r[r.length-2],n[i*2+1]=r[r.length-1];else{var o=i/a;this._setCurvePoint(r,o,n,i*2)}return n}},{key:"_setCurvePoint",value:function(r,a,n,i){if(r.length<=2)n[i]=r[0],n[i+1]=r[1];else{for(var o=Array(r.length-2),s=0;s<o.length;s+=2){var u=(1-a)*r[s]+a*r[s+2],l=(1-a)*r[s+1]+a*r[s+3];o[s]=u,o[s+1]=l}return this._setCurvePoint(o,a,n,i)}}},{key:"endBatch",value:function(){var r=this.gl,a=this.vao,n=this.vertexCount,i=this.instanceCount;if(i!==0){var o=this.renderTarget.picking?this.pickingProgram:this.program;r.useProgram(o),r.bindVertexArray(a);var s=zt(this.buffers),u;try{for(s.s();!(u=s.n()).done;){var l=u.value;l.bufferSubData(i)}}catch(d){s.e(d)}finally{s.f()}for(var f=this.batchManager.getAtlases(),v=0;v<f.length;v++)f[v].bufferIfNeeded(r);for(var c=0;c<f.length;c++)r.activeTexture(r.TEXTURE0+c),r.bindTexture(r.TEXTURE_2D,f[c].texture),r.uniform1i(o.uTextures[c],c);r.uniform1f(o.uZoom,e0(this.r)),r.uniformMatrix3fv(o.uPanZoomMatrix,!1,this.panZoomMatrix),r.uniform1i(o.uAtlasSize,this.batchManager.getAtlasSize());var h=zr(this.bgColor,1);r.uniform4fv(o.uBGColor,h),r.drawArraysInstanced(r.TRIANGLES,0,n,i),r.bindVertexArray(null),r.bindTexture(r.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:i,atlasCount:f.length}),this.startBatch()}}},{key:"getDebugInfo",value:function(){var r=this.atlasManager.getDebugInfo(),a=r.reduce(function(o,s){return o+s.atlasCount},0),n=this.batchDebugInfo,i=n.reduce(function(o,s){return o+s.count},0);return{atlasInfo:r,totalAtlases:a,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:i}}}])})(),Mc={};Mc.initWebgl=function(t,e){var r=this,a=r.data.contexts[r.WEBGL];t.bgColor=x0(r),t.webglTexSize=Math.min(t.webglTexSize,a.getParameter(a.MAX_TEXTURE_SIZE)),t.webglTexRows=Math.min(t.webglTexRows,54),t.webglTexRowsNodes=Math.min(t.webglTexRowsNodes,54),t.webglBatchSize=Math.min(t.webglBatchSize,16384),t.webglTexPerBatch=Math.min(t.webglTexPerBatch,a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)),r.webglDebug=t.webglDebug,r.webglDebugShowAtlases=t.webglDebugShowAtlases,r.pickingFrameBuffer=u0(a),r.pickingFrameBuffer.needsDraw=!0,r.drawing=new E0(r,a,t);var n=function(v){return function(c){return r.getTextAngle(c,v)}},i=function(v){return function(c){var h=c.pstyle(v);return h&&h.value}},o=function(v){return function(c){return c.pstyle("".concat(v,"-opacity")).value>0}},s=function(v){var c=v.pstyle("text-events").strValue==="yes";return c?oi.USE_BB:oi.IGNORE},u=function(v){var c=v.position(),h=c.x,d=c.y,g=v.outerWidth(),m=v.outerHeight();return{w:g,h:m,x1:h-g/2,y1:d-m/2}};r.drawing.addAtlasCollection("node",{texRows:t.webglTexRowsNodes}),r.drawing.addAtlasCollection("label",{texRows:t.webglTexRows}),r.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:e.getStyleKey,getBoundingBox:e.getElementBox,drawElement:e.drawElement}),r.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:u,isSimple:r0,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),r.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:u,isVisible:o("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),r.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:u,isVisible:o("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),r.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:s,getKey:ss(e.getLabelKey,null),getBoundingBox:ls(e.getLabelBox,null),drawClipped:!0,drawElement:e.drawLabel,getRotation:n(null),getRotationPoint:e.getLabelRotationPoint,getRotationOffset:e.getLabelRotationOffset,isVisible:i("label")}),r.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:s,getKey:ss(e.getSourceLabelKey,"source"),getBoundingBox:ls(e.getSourceLabelBox,"source"),drawClipped:!0,drawElement:e.drawSourceLabel,getRotation:n("source"),getRotationPoint:e.getSourceLabelRotationPoint,getRotationOffset:e.getSourceLabelRotationOffset,isVisible:i("source-label")}),r.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:s,getKey:ss(e.getTargetLabelKey,"target"),getBoundingBox:ls(e.getTargetLabelBox,"target"),drawClipped:!0,drawElement:e.drawTargetLabel,getRotation:n("target"),getRotationPoint:e.getTargetLabelRotationPoint,getRotationOffset:e.getTargetLabelRotationOffset,isVisible:i("target-label")});var l=un(function(){console.log("garbage collect flag set"),r.data.gc=!0},1e4);r.onUpdateEleCalcs(function(f,v){var c=!1;v&&v.length>0&&(c|=r.drawing.invalidate(v)),c&&l()}),T0(r)};function x0(t){var e=t.cy.container(),r=e&&e.style&&e.style.backgroundColor||"white";return tv(r)}function Lc(t,e){var r=t._private.rscratch;return It(r,"labelWrapCachedLines",e)||[]}var ss=function(e,r){return function(a){var n=e(a),i=Lc(a,r);return i.length>1?i.map(function(o,s){return"".concat(n,"_").concat(s)}):n}},ls=function(e,r){return function(a,n){var i=e(a);if(typeof n=="string"){var o=n.indexOf("_");if(o>0){var s=Number(n.substring(o+1)),u=Lc(a,r),l=i.h/u.length,f=l*s,v=i.y1+f;return{x1:i.x1,w:i.w,y1:v,h:l,yOffset:f}}}return i}};function T0(t){{var e=t.render;t.render=function(i){i=i||{};var o=t.cy;t.webgl&&(o.zoom()>Ec?(C0(t),e.call(t,i)):(S0(t),Rc(t,i,Xa.SCREEN)))}}{var r=t.matchCanvasSize;t.matchCanvasSize=function(i){r.call(t,i),t.pickingFrameBuffer.setFramebufferAttachmentSizes(t.canvasWidth,t.canvasHeight),t.pickingFrameBuffer.needsDraw=!0}}t.findNearestElements=function(i,o,s,u){return R0(t,i,o)};{var a=t.invalidateCachedZSortedEles;t.invalidateCachedZSortedEles=function(){a.call(t),t.pickingFrameBuffer.needsDraw=!0}}{var n=t.notify;t.notify=function(i,o){n.call(t,i,o),i==="viewport"||i==="bounds"?t.pickingFrameBuffer.needsDraw=!0:i==="background"&&t.drawing.invalidate(o,{type:"node-body"})}}}function C0(t){var e=t.data.contexts[t.WEBGL];e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}function S0(t){var e=function(a){a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,t.canvasWidth,t.canvasHeight),a.restore()};e(t.data.contexts[t.NODE]),e(t.data.contexts[t.DRAG])}function D0(t){var e=t.canvasWidth,r=t.canvasHeight,a=el(t),n=a.pan,i=a.zoom,o=ns();$n(o,o,[n.x,n.y]),Ds(o,o,[i,i]);var s=ns();v0(s,e,r);var u=ns();return f0(u,s,o),u}function Nc(t,e){var r=t.canvasWidth,a=t.canvasHeight,n=el(t),i=n.pan,o=n.zoom;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r,a),e.translate(i.x,i.y),e.scale(o,o)}function A0(t,e){t.drawSelectionRectangle(e,function(r){return Nc(t,r)})}function M0(t){var e=t.data.contexts[t.NODE];e.save(),Nc(t,e),e.strokeStyle="rgba(0, 0, 0, 0.3)",e.beginPath(),e.moveTo(-1e3,0),e.lineTo(1e3,0),e.stroke(),e.beginPath(),e.moveTo(0,-1e3),e.lineTo(0,1e3),e.stroke(),e.restore()}function L0(t){var e=function(n,i,o){for(var s=n.atlasManager.getAtlasCollection(i),u=t.data.contexts[t.NODE],l=s.atlases,f=0;f<l.length;f++){var v=l[f],c=v.canvas;if(c){var h=c.width,d=c.height,g=h*f,m=c.height*o,p=.4;u.save(),u.scale(p,p),u.drawImage(c,g,m),u.strokeStyle="black",u.rect(g,m,h,d),u.stroke(),u.restore()}}},r=0;e(t.drawing,"node",r++),e(t.drawing,"label",r++)}function N0(t,e,r,a,n){var i,o,s,u,l=el(t),f=l.pan,v=l.zoom;{var c=t0(t,f,v,e,r),h=dt(c,2),d=h[0],g=h[1],m=6;i=d-m/2,o=g-m/2,s=m,u=m}if(s===0||u===0)return[];var p=t.data.contexts[t.WEBGL];p.bindFramebuffer(p.FRAMEBUFFER,t.pickingFrameBuffer),t.pickingFrameBuffer.needsDraw&&(p.viewport(0,0,p.canvas.width,p.canvas.height),Rc(t,null,Xa.PICKING),t.pickingFrameBuffer.needsDraw=!1);var y=s*u,b=new Uint8Array(y*4);p.readPixels(i,o,s,u,p.RGBA,p.UNSIGNED_BYTE,b),p.bindFramebuffer(p.FRAMEBUFFER,null);for(var E=new Set,C=0;C<y;C++){var A=b.slice(C*4,C*4+4),D=n0(A)-1;D>=0&&E.add(D)}return E}function R0(t,e,r){var a=N0(t,e,r),n=t.getCachedZSortedEles(),i,o,s=zt(a),u;try{for(s.s();!(u=s.n()).done;){var l=u.value,f=n[l];if(!i&&f.isNode()&&(i=f),!o&&f.isEdge()&&(o=f),i&&o)break}}catch(v){s.e(v)}finally{s.f()}return[i,o].filter(Boolean)}function us(t,e,r){var a=t.drawing;e+=1,r.isNode()?(a.drawNode(r,e,"node-underlay"),a.drawNode(r,e,"node-body"),a.drawTexture(r,e,"label"),a.drawNode(r,e,"node-overlay")):(a.drawEdgeLine(r,e),a.drawEdgeArrow(r,e,"source"),a.drawEdgeArrow(r,e,"target"),a.drawTexture(r,e,"label"),a.drawTexture(r,e,"edge-source-label"),a.drawTexture(r,e,"edge-target-label"))}function Rc(t,e,r){var a;t.webglDebug&&(a=performance.now());var n=t.drawing,i=0;if(r.screen&&t.data.canvasNeedsRedraw[t.SELECT_BOX]&&A0(t,e),t.data.canvasNeedsRedraw[t.NODE]||r.picking){var o=t.data.contexts[t.WEBGL];r.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var s=D0(t),u=t.getCachedZSortedEles();if(i=u.length,n.startFrame(s,r),r.screen){for(var l=0;l<u.nondrag.length;l++)us(t,l,u.nondrag[l]);for(var f=0;f<u.drag.length;f++)us(t,f,u.drag[f])}else if(r.picking)for(var v=0;v<u.length;v++)us(t,v,u[v]);n.endFrame(),r.screen&&t.webglDebugShowAtlases&&(M0(t),L0(t)),t.data.canvasNeedsRedraw[t.NODE]=!1,t.data.canvasNeedsRedraw[t.DRAG]=!1}if(t.webglDebug){var c=performance.now(),h=!1,d=Math.ceil(c-a),g=n.getDebugInfo(),m=["".concat(i," elements"),"".concat(g.totalInstances," instances"),"".concat(g.batchCount," batches"),"".concat(g.totalAtlases," atlases"),"".concat(g.wrappedCount," wrapped textures"),"".concat(g.simpleCount," simple shapes")].join(", ");if(h)console.log("WebGL (".concat(r.name,") - time ").concat(d,"ms, ").concat(m));else{console.log("WebGL (".concat(r.name,") - frame time ").concat(d,"ms")),console.log("Totals:"),console.log(" ".concat(m)),console.log("Texture Atlases Used:");var p=g.atlasInfo,y=zt(p),b;try{for(y.s();!(b=y.n()).done;){var E=b.value;console.log(" ".concat(E.type,": ").concat(E.keyCount," keys, ").concat(E.atlasCount," atlases"))}}catch(C){y.e(C)}finally{y.f()}console.log("")}}t.data.gc&&(console.log("Garbage Collect!"),t.data.gc=!1,n.gc())}var Pr={};Pr.drawPolygonPath=function(t,e,r,a,n,i){var o=a/2,s=n/2;t.beginPath&&t.beginPath(),t.moveTo(e+o*i[0],r+s*i[1]);for(var u=1;u<i.length/2;u++)t.lineTo(e+o*i[u*2],r+s*i[u*2+1]);t.closePath()};Pr.drawRoundPolygonPath=function(t,e,r,a,n,i,o){o.forEach(function(s){return vc(t,s)}),t.closePath()};Pr.drawRoundRectanglePath=function(t,e,r,a,n,i){var o=a/2,s=n/2,u=i==="auto"?Cr(a,n):Math.min(i,s,o);t.beginPath&&t.beginPath(),t.moveTo(e,r-s),t.arcTo(e+o,r-s,e+o,r,u),t.arcTo(e+o,r+s,e,r+s,u),t.arcTo(e-o,r+s,e-o,r,u),t.arcTo(e-o,r-s,e,r-s,u),t.lineTo(e,r-s),t.closePath()};Pr.drawBottomRoundRectanglePath=function(t,e,r,a,n,i){var o=a/2,s=n/2,u=i==="auto"?Cr(a,n):i;t.beginPath&&t.beginPath(),t.moveTo(e,r-s),t.lineTo(e+o,r-s),t.lineTo(e+o,r),t.arcTo(e+o,r+s,e,r+s,u),t.arcTo(e-o,r+s,e-o,r,u),t.lineTo(e-o,r-s),t.lineTo(e,r-s),t.closePath()};Pr.drawCutRectanglePath=function(t,e,r,a,n,i,o){var s=a/2,u=n/2,l=o==="auto"?Gs():o;t.beginPath&&t.beginPath(),t.moveTo(e-s+l,r-u),t.lineTo(e+s-l,r-u),t.lineTo(e+s,r-u+l),t.lineTo(e+s,r+u-l),t.lineTo(e+s-l,r+u),t.lineTo(e-s+l,r+u),t.lineTo(e-s,r+u-l),t.lineTo(e-s,r-u+l),t.closePath()};Pr.drawBarrelPath=function(t,e,r,a,n){var i=a/2,o=n/2,s=e-i,u=e+i,l=r-o,f=r+o,v=cs(a,n),c=v.widthOffset,h=v.heightOffset,d=v.ctrlPtOffsetPct*c;t.beginPath&&t.beginPath(),t.moveTo(s,l+h),t.lineTo(s,f-h),t.quadraticCurveTo(s+d,f,s+c,f),t.lineTo(u-c,f),t.quadraticCurveTo(u-d,f,u,f-h),t.lineTo(u,l+h),t.quadraticCurveTo(u-d,l,u-c,l),t.lineTo(s+c,l),t.quadraticCurveTo(s+d,l,s,l+h),t.closePath()};var Wf=Math.sin(0),Xf=Math.cos(0),As={},Ms={},Pc=Math.PI/40;for(Vr=0*Math.PI;Vr<2*Math.PI;Vr+=Pc)As[Vr]=Math.sin(Vr),Ms[Vr]=Math.cos(Vr);var Vr;Pr.drawEllipsePath=function(t,e,r,a,n){if(t.beginPath&&t.beginPath(),t.ellipse)t.ellipse(e,r,a/2,n/2,0,0,2*Math.PI);else for(var i,o,s=a/2,u=n/2,l=0*Math.PI;l<2*Math.PI;l+=Pc)i=e-s*As[l]*Wf+s*Ms[l]*Xf,o=r+u*Ms[l]*Wf+u*As[l]*Xf,l===0?t.moveTo(i,o):t.lineTo(i,o);t.closePath()};var gn={};gn.createBuffer=function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,[r,r.getContext("2d")]};gn.bufferCanvasImage=function(t){var e=this.cy,r=e.mutableElements(),a=r.boundingBox(),n=this.findContainerClientCoords(),i=t.full?Math.ceil(a.w):n[2],o=t.full?Math.ceil(a.h):n[3],s=we(t.maxWidth)||we(t.maxHeight),u=this.getPixelRatio(),l=1;if(t.scale!==void 0)i*=t.scale,o*=t.scale,l=t.scale;else if(s){var f=1/0,v=1/0;we(t.maxWidth)&&(f=l*t.maxWidth/i),we(t.maxHeight)&&(v=l*t.maxHeight/o),l=Math.min(f,v),i*=l,o*=l}s||(i*=u,o*=u,l*=u);var c=document.createElement("canvas");c.width=i,c.height=o,c.style.width=i+"px",c.style.height=o+"px";var h=c.getContext("2d");if(i>0&&o>0){h.clearRect(0,0,i,o),h.globalCompositeOperation="source-over";var d=this.getCachedZSortedEles();if(t.full)h.translate(-a.x1*l,-a.y1*l),h.scale(l,l),this.drawElements(h,d),h.scale(1/l,1/l),h.translate(a.x1*l,a.y1*l);else{var g=e.pan(),m={x:g.x*l,y:g.y*l};l*=e.zoom(),h.translate(m.x,m.y),h.scale(l,l),this.drawElements(h,d),h.scale(1/l,1/l),h.translate(-m.x,-m.y)}t.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=t.bg,h.rect(0,0,i,o),h.fill())}return c};function P0(t,e){for(var r=atob(t),a=new ArrayBuffer(r.length),n=new Uint8Array(a),i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new Blob([a],{type:e})}function $f(t){var e=t.indexOf(",");return t.substr(e+1)}function Oc(t,e,r){var a=function(){return e.toDataURL(r,t.quality)};switch(t.output){case"blob-promise":return new Ta(function(n,i){try{e.toBlob(function(o){o!=null?n(o):i(new Error("`canvas.toBlob()` sent a null value in its callback"))},r,t.quality)}catch(o){i(o)}});case"blob":return P0($f(a()),r);case"base64":return $f(a());default:return a()}}gn.png=function(t){return Oc(t,this.bufferCanvasImage(t),"image/png")};gn.jpg=function(t){return Oc(t,this.bufferCanvasImage(t),"image/jpeg")};var Ic={};Ic.nodeShapeImpl=function(t,e,r,a,n,i,o,s){switch(t){case"ellipse":return this.drawEllipsePath(e,r,a,n,i);case"polygon":return this.drawPolygonPath(e,r,a,n,i,o);case"round-polygon":return this.drawRoundPolygonPath(e,r,a,n,i,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(e,r,a,n,i,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(e,r,a,n,i,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(e,r,a,n,i,s);case"barrel":return this.drawBarrelPath(e,r,a,n,i)}};var O0=Bc,Ge=Bc.prototype;Ge.CANVAS_LAYERS=3;Ge.SELECT_BOX=0;Ge.DRAG=1;Ge.NODE=2;Ge.WEBGL=3;Ge.CANVAS_TYPES=["2d","2d","2d","webgl2"];Ge.BUFFER_COUNT=3;Ge.TEXTURE_BUFFER=0;Ge.MOTIONBLUR_BUFFER_NODE=1;Ge.MOTIONBLUR_BUFFER_DRAG=2;function Bc(t){var e=this,r=e.cy.window(),a=r.document;t.webgl&&(Ge.CANVAS_LAYERS=e.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),e.data={canvases:new Array(Ge.CANVAS_LAYERS),contexts:new Array(Ge.CANVAS_LAYERS),canvasNeedsRedraw:new Array(Ge.CANVAS_LAYERS),bufferCanvases:new Array(Ge.BUFFER_COUNT),bufferContexts:new Array(Ge.CANVAS_LAYERS)};var n="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";e.data.canvasContainer=a.createElement("div");var o=e.data.canvasContainer.style;e.data.canvasContainer.style[n]=i,o.position="relative",o.zIndex="0",o.overflow="hidden";var s=t.cy.container();s.appendChild(e.data.canvasContainer),s.style[n]=i;var u={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};Ch()&&(u["-ms-touch-action"]="none",u["touch-action"]="none");for(var l=0;l<Ge.CANVAS_LAYERS;l++){var f=e.data.canvases[l]=a.createElement("canvas"),v=Ge.CANVAS_TYPES[l];e.data.contexts[l]=f.getContext(v),e.data.contexts[l]||nt("Could not create canvas of type "+v),Object.keys(u).forEach(function($){f.style[$]=u[$]}),f.style.position="absolute",f.setAttribute("data-id","layer"+l),f.style.zIndex=String(Ge.CANVAS_LAYERS-l),e.data.canvasContainer.appendChild(f),e.data.canvasNeedsRedraw[l]=!1}e.data.topCanvas=e.data.canvases[0],e.data.canvases[Ge.NODE].setAttribute("data-id","layer"+Ge.NODE+"-node"),e.data.canvases[Ge.SELECT_BOX].setAttribute("data-id","layer"+Ge.SELECT_BOX+"-selectbox"),e.data.canvases[Ge.DRAG].setAttribute("data-id","layer"+Ge.DRAG+"-drag"),e.data.canvases[Ge.WEBGL]&&e.data.canvases[Ge.WEBGL].setAttribute("data-id","layer"+Ge.WEBGL+"-webgl");for(var l=0;l<Ge.BUFFER_COUNT;l++)e.data.bufferCanvases[l]=a.createElement("canvas"),e.data.bufferContexts[l]=e.data.bufferCanvases[l].getContext("2d"),e.data.bufferCanvases[l].style.position="absolute",e.data.bufferCanvases[l].setAttribute("data-id","buffer"+l),e.data.bufferCanvases[l].style.zIndex=String(-l-1),e.data.bufferCanvases[l].style.visibility="hidden";e.pathsEnabled=!0;var c=Bt(),h=function(q){return{x:(q.x1+q.x2)/2,y:(q.y1+q.y2)/2}},d=function(q){return{x:-q.w/2,y:-q.h/2}},g=function(q){var K=q[0]._private,ee=K.oldBackgroundTimestamp===K.backgroundTimestamp;return!ee},m=function(q){return q[0]._private.nodeKey},p=function(q){return q[0]._private.labelStyleKey},y=function(q){return q[0]._private.sourceLabelStyleKey},b=function(q){return q[0]._private.targetLabelStyleKey},E=function(q,K,ee,ne,te){return e.drawElement(q,K,ee,!1,!1,te)},C=function(q,K,ee,ne,te){return e.drawElementText(q,K,ee,ne,"main",te)},A=function(q,K,ee,ne,te){return e.drawElementText(q,K,ee,ne,"source",te)},D=function(q,K,ee,ne,te){return e.drawElementText(q,K,ee,ne,"target",te)},N=function(q){return q.boundingBox(),q[0]._private.bodyBounds},O=function(q){return q.boundingBox(),q[0]._private.labelBounds.main||c},R=function(q){return q.boundingBox(),q[0]._private.labelBounds.source||c},P=function(q){return q.boundingBox(),q[0]._private.labelBounds.target||c},w=function(q,K){return K},x=function(q){return h(N(q))},T=function(q,K,ee){var ne=q?q+"-":"";return{x:K.x+ee.pstyle(ne+"text-margin-x").pfValue,y:K.y+ee.pstyle(ne+"text-margin-y").pfValue}},M=function(q,K,ee){var ne=q[0]._private.rscratch;return{x:ne[K],y:ne[ee]}},S=function(q){return T("",M(q,"labelX","labelY"),q)},I=function(q){return T("source",M(q,"sourceLabelX","sourceLabelY"),q)},B=function(q){return T("target",M(q,"targetLabelX","targetLabelY"),q)},V=function(q){return d(N(q))},F=function(q){return d(R(q))},k=function(q){return d(P(q))},U=function(q){var K=O(q),ee=d(O(q));if(q.isNode()){switch(wa(q.pstyle("text-halign").value)){case"left":ee.x=-K.w-(K.leftPad||0);break;case"right":ee.x=-(K.rightPad||0);break}switch(Ea(q.pstyle("text-valign").value)){case"top":ee.y=-K.h-(K.topPad||0);break;case"bottom":ee.y=-(K.botPad||0);break}}return ee},J=e.data.eleTxrCache=new qa(e,{getKey:m,doesEleInvalidateKey:g,drawElement:E,getBoundingBox:N,getRotationPoint:x,getRotationOffset:V,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),W=e.data.lblTxrCache=new qa(e,{getKey:p,drawElement:C,getBoundingBox:O,getRotationPoint:S,getRotationOffset:U,isVisible:w}),Q=e.data.slbTxrCache=new qa(e,{getKey:y,drawElement:A,getBoundingBox:R,getRotationPoint:I,getRotationOffset:F,isVisible:w}),Z=e.data.tlbTxrCache=new qa(e,{getKey:b,drawElement:D,getBoundingBox:P,getRotationPoint:B,getRotationOffset:k,isVisible:w}),H=e.data.lyrTxrCache=new xc(e);e.onUpdateEleCalcs(function(q,K){J.invalidateElements(K),W.invalidateElements(K),Q.invalidateElements(K),Z.invalidateElements(K),H.invalidateElements(K);for(var ee=0;ee<K.length;ee++){var ne=K[ee]._private;ne.oldBackgroundTimestamp=ne.backgroundTimestamp}});var j=function(q){for(var K=0;K<q.length;K++)H.enqueueElementRefinement(q[K].ele)};J.onDequeue(j),W.onDequeue(j),Q.onDequeue(j),Z.onDequeue(j),t.webgl&&e.initWebgl(t,{getStyleKey:m,getLabelKey:p,getSourceLabelKey:y,getTargetLabelKey:b,drawElement:E,drawLabel:C,drawSourceLabel:A,drawTargetLabel:D,getElementBox:N,getLabelBox:O,getSourceLabelBox:R,getTargetLabelBox:P,getElementRotationPoint:x,getElementRotationOffset:V,getLabelRotationPoint:S,getSourceLabelRotationPoint:I,getTargetLabelRotationPoint:B,getLabelRotationOffset:U,getSourceLabelRotationOffset:F,getTargetLabelRotationOffset:k})}Ge.redrawHint=function(t,e){var r=this;switch(t){case"eles":r.data.canvasNeedsRedraw[Ge.NODE]=e;break;case"drag":r.data.canvasNeedsRedraw[Ge.DRAG]=e;break;case"select":r.data.canvasNeedsRedraw[Ge.SELECT_BOX]=e;break;case"gc":r.data.gc=!0;break}};var I0=typeof Path2D<"u";Ge.path2dEnabled=function(t){if(t===void 0)return this.pathsEnabled;this.pathsEnabled=!!t};Ge.usePaths=function(){return I0&&this.pathsEnabled};Ge.setImgSmoothing=function(t,e){t.imageSmoothingEnabled!=null?t.imageSmoothingEnabled=e:(t.webkitImageSmoothingEnabled=e,t.mozImageSmoothingEnabled=e,t.msImageSmoothingEnabled=e)};Ge.getImgSmoothing=function(t){return t.imageSmoothingEnabled!=null?t.imageSmoothingEnabled:t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled};Ge.makeOffscreenCanvas=function(t,e){var r;if((typeof OffscreenCanvas>"u"?"undefined":mt(OffscreenCanvas))!=="undefined")r=new OffscreenCanvas(t,e);else{var a=this.cy.window(),n=a.document;r=n.createElement("canvas"),r.width=t,r.height=e}return r};[Tc,rr,fr,js,Qr,Rr,kt,Mc,Pr,gn,Ic].forEach(function(t){Re(Ge,t)});var B0=[{name:"null",impl:lc},{name:"base",impl:bc},{name:"canvas",impl:O0}],k0=[{type:"layout",extensions:im},{type:"renderer",extensions:B0}],kc={},Fc={};function zc(t,e,r){var a=r,n=function(N){Qe("Can not register `"+e+"` for `"+t+"` since `"+N+"` already exists in the prototype and can not be overridden")};if(t==="core"){if(tn.prototype[e])return n(e);tn.prototype[e]=r}else if(t==="collection"){if(St.prototype[e])return n(e);St.prototype[e]=r}else if(t==="layout"){for(var i=function(N){this.options=N,r.call(this,N),$e(this._private)||(this._private={}),this._private.cy=N.cy,this._private.listeners=[],this.createEmitter()},o=i.prototype=Object.create(r.prototype),s=[],u=0;u<s.length;u++){var l=s[u];o[l]=o[l]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var f=r.prototype.stop;o.stop=function(){var D=this.options;if(D&&D.animate){var N=this.animations;if(N)for(var O=0;O<N.length;O++)N[O].stop()}return f?f.call(this):this.emit("layoutstop"),this},o.destroy||(o.destroy=function(){return this}),o.cy=function(){return this._private.cy};var v=function(N){return N._private.cy},c={addEventFields:function(N,O){O.layout=N,O.cy=v(N),O.target=N},bubble:function(){return!0},parent:function(N){return v(N)}};Re(o,{createEmitter:function(){return this._private.emitter=new mi(c,this),this},emitter:function(){return this._private.emitter},on:function(N,O){return this.emitter().on(N,O),this},one:function(N,O){return this.emitter().one(N,O),this},once:function(N,O){return this.emitter().one(N,O),this},removeListener:function(N,O){return this.emitter().removeListener(N,O),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(N,O){return this.emitter().emit(N,O),this}}),Ze.eventAliasesOn(o),a=i}else if(t==="renderer"&&e!=="null"&&e!=="base"){var h=Vc("renderer","base"),d=h.prototype,g=r,m=r.prototype,p=function(){h.apply(this,arguments),g.apply(this,arguments)},y=p.prototype;for(var b in d){var E=d[b],C=m[b]!=null;if(C)return n(b);y[b]=E}for(var A in m)y[A]=m[A];d.clientFunctions.forEach(function(D){y[D]=y[D]||function(){nt("Renderer does not implement `renderer."+D+"()` on its prototype")}}),a=p}else if(t==="__proto__"||t==="constructor"||t==="prototype")return nt(t+" is an illegal type to be registered, possibly lead to prototype pollutions");return rv({map:kc,keys:[t,e],value:a})}function Vc(t,e){return av({map:kc,keys:[t,e]})}function F0(t,e,r,a,n){return rv({map:Fc,keys:[t,e,r,a],value:n})}function z0(t,e,r,a){return av({map:Fc,keys:[t,e,r,a]})}var Ls=function(){if(arguments.length===2)return Vc.apply(null,arguments);if(arguments.length===3)return zc.apply(null,arguments);if(arguments.length===4)return z0.apply(null,arguments);if(arguments.length===5)return F0.apply(null,arguments);nt("Invalid extension access syntax")};tn.prototype.extension=Ls;k0.forEach(function(t){t.extensions.forEach(function(e){zc(t.type,e.name,e.impl)})});var si=function(){if(!(this instanceof si))return new si;this.length=0},_r=si.prototype;_r.instanceString=function(){return"stylesheet"};_r.selector=function(t){var e=this.length++;return this[e]={selector:t,properties:[]},this};_r.css=function(t,e){var r=this.length-1;if(Le(t))this[r].properties.push({name:t,value:e});else if($e(t))for(var a=t,n=Object.keys(a),i=0;i<n.length;i++){var o=n[i],s=a[o];if(s!=null){var u=xt.properties[o]||xt.properties[li(o)];if(u!=null){var l=u.name,f=s;this[r].properties.push({name:l,value:f})}}}return this};_r.style=_r.css;_r.generateStyle=function(t){var e=new xt(t);return this.appendToStyle(e)};_r.appendToStyle=function(t){for(var e=0;e<this.length;e++){var r=this[e],a=r.selector,n=r.properties;t.selector(a);for(var i=0;i<n.length;i++){var o=n[i];t.css(o.name,o.value)}}return t};var V0="3.34.0",lr=function(e){if(e===void 0&&(e={}),$e(e))return new tn(e);if(Le(e))return Ls.apply(Ls,arguments)};lr.use=function(t){var e=Array.prototype.slice.call(arguments,1);return e.unshift(lr),t.apply(null,e),this};lr.warnings=function(t){return fv(t)};lr.version=V0;lr.stylesheet=lr.Stylesheet=si;var _c=oh(Gc(),1);var Ma={Entity:0,Service:1,Event:1,UseCase:2,Port:3,DTO:4,VO:4,Error:4,Shared:4,Adapter:5},qc={Entity:95,Service:72,Event:60,UseCase:48,Port:30,DTO:0,VO:0,Error:0,Shared:22,Adapter:18},Yc={Entity:"barrel",Service:"rectangle",UseCase:"round-rectangle",Port:"cut-rectangle",Event:"rhomboid",DTO:"round-rectangle",VO:"round-rectangle",Error:"round-rectangle",Shared:"round-rectangle",Adapter:"round-rectangle"},ol=["Entity","Service","UseCase","Port","Event"],sl=["DTO","VO","Error"],bn=42,Wc=338,G0=15;function Uc(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)|0;let r=Math.abs(e*.6180339887%1);return Math.round(bn+r*(Wc-bn))}var U0=(t,e)=>{let r=Math.abs(t-e)%360;return Math.min(r,360-r)};function Xc(t){let e=[...new Set(t)].filter(i=>!La(i)).sort(),r=[],a=new Map,n=Wc-bn;for(let i of e){let o=Uc(i),s=o;for(let u=0;u<n;u++){let l=bn+(o-bn+u)%n;if(r.every(f=>U0(f,l)>=G0)){s=l;break}}r.push(s),a.set(i,s)}return i=>La(i)?0:a.get(i)??Uc(i)}var La=t=>t==="common"||t==="shared",Di=190,H0=40,q0=230,Y0=268,W0=130,Hc=34,X0=30;function $0(t){let e=new Map;for(let o of t){let s=Ma[o.component];e.set(s,[...e.get(s)??[],o])}let r=new Map,a=0;for(let o of[...e.keys()].sort((s,u)=>s-u)){let s=e.get(o),u=s.length*Y0/(2*Math.PI),l=o===0&&s.length===1?0:Math.max(a+q0,u,170);s.forEach((f,v)=>{if(l===0)r.set(f.id,[0,0]);else{let c=2*Math.PI*v/s.length-Math.PI/2;r.set(f.id,[l*Math.cos(c),l*Math.sin(c)])}}),a=l}let n=0,i=0;for(let[o,s]of r.values())n=Math.max(n,Math.abs(o)),i=Math.max(i,Math.abs(s));return{pos:r,hw:n+Di/2+Hc,hh:i+H0/2+Hc+X0/2}}function K0(t,e,r=W0){let a=new Map(t.nodes.map(c=>[c.id,c])),n=new Map;for(let c of t.edges){let h=a.get(c.src)?.domain,d=a.get(c.dst)?.domain;if(!h||!d||h===d)continue;let g=h<d?`${h}|${d}`:`${d}|${h}`;n.set(g,(n.get(g)??0)+1)}let i=c=>e.get(c)??{hw:0,hh:0},o=c=>i(c).hw*i(c).hh,s=[...e.keys()].sort((c,h)=>o(h)-o(c)),u=new Map,l=0,f=0;s.forEach((c,h)=>{if(h===0){u.set(c,[0,0]);return}l+=Math.hypot(i(c).hw,i(c).hh)*.95,f+=2.399963,u.set(c,[l*Math.cos(f),l*Math.sin(f)])});let v=c=>{let h=0;for(let d=0;d<s.length;d++){let g=s[d];for(let m=d+1;m<s.length;m++){let p=s[m],y=u.get(g),b=u.get(p),E=b[0]-y[0],C=b[1]-y[1],A=i(g).hw+i(p).hw+r-Math.abs(E),D=i(g).hh+i(p).hh+r-Math.abs(C);if(A<=0||D<=0)continue;h=Math.max(h,Math.min(A,D));let N=Math.min(A,D)*c;if(A<D){let O=E>=0?1:-1;y[0]-=O*N,b[0]+=O*N}else{let O=C>=0?1:-1;y[1]-=O*N,b[1]+=O*N}}}return h};for(let c=0;c<400;c++){for(let h=0;h<s.length;h++){let d=s[h];for(let g=h+1;g<s.length;g++){let m=s[g],p=n.get(d<m?`${d}|${m}`:`${m}|${d}`)??0,y=u.get(d),b=u.get(m),E=b[0]-y[0],C=b[1]-y[1],A=Math.hypot(E,C)||1,D=i(d).hw+i(m).hw+r-Math.abs(E),N=i(d).hh+i(m).hh+r-Math.abs(C);if(D>0&&N>0)continue;let O=-Math.min(D,N),R=Math.min(O*(p?.06*Math.log1p(p):.006),90);u.set(d,[y[0]+E/A*R,y[1]+C/A*R]),u.set(m,[b[0]-E/A*R,b[1]-C/A*R])}}v(.5);for(let h of s){let d=u.get(h);d[0]-=d[0]*.004,d[1]-=d[1]*.004}}for(let c=0;c<600&&v(.5)>.5;c++);return u}function ll(t){let e=new Map;for(let o of t.nodes)e.set(o.domain,[...e.get(o.domain)??[],o]);let r=new Map,a=new Map;for(let[o,s]of e){let u=$0(s);r.set(o,u.pos),a.set(o,{hw:u.hw,hh:u.hh})}let n=K0(t,a),i=[];for(let[o,s]of r){let[u,l]=n.get(o)??[0,0];for(let[f,[v,c]]of s)i.push({id:f,x:Math.round(u+v),y:Math.round(l+c)})}return i}var _0=Di+54,Z0=74;function Q0(t,e){let r=[...e].sort((i,o)=>Ma[i.component]-Ma[o.component]||i.name.localeCompare(o.name)),a=Math.max(1,Math.min(5,Math.ceil(Math.sqrt(r.length/2.2)))),n=Math.ceil(r.length/a);return{d:t,items:r,cols:a,w:a*_0+80,h:n*Z0+92}}function $c(t,e=3e3){let r=new Map;for(let l of t.nodes)r.set(l.domain,[...r.get(l.domain)??[],l]);let a=[...r.entries()].map(([l,f])=>Q0(l,f)).sort((l,f)=>f.items.length-l.items.length),n=e,i=[],o=0,s=0,u=0;for(let l of a)s+l.w>n&&s>0&&(o+=u+90,s=0,u=0),l.items.forEach((f,v)=>{i.push({id:f.id,x:Math.round(s+40+v%l.cols*(Di+54)+Di/2),y:Math.round(o+52+Math.floor(v/l.cols)*74)})}),s+=l.w+70,u=Math.max(u,l.h);return i}lr.use(_c.default);var vr=(t,e,r)=>`hsl(${t},${e}%,${r}%)`,He=t=>document.getElementById(t),ea=t=>Array.from(document.querySelectorAll(t)),Ue,wt,pl,Li="hex",Or=!1,jr=!1,Ai,ta=null,Jr="both",Kc,Ni,wn=()=>0;async function J0(){wt=await(await fetch("/api/graph")).json();let t=[...new Set(wt.nodes.map(a=>a.domain))];wn=Xc(t);let e=[...new Set(wt.nodes.map(a=>a.component))].sort((a,n)=>Ma[a]-Ma[n]);pl={hex:new Map(ll(wt).map(a=>[a.id,{x:a.x,y:a.y}])),grid:new Map($c(wt).map(a=>[a.id,{x:a.x,y:a.y}]))},document.title=`${wt.project} \u2014 hexwright`,He("title").textContent=wt.project,He("ref").textContent=wt.ref;let r={added:wt.nodes.filter(a=>a.status==="added").length,modified:wt.nodes.filter(a=>a.status==="modified").length,addedEdges:wt.edges.filter(a=>a.status==="added").length};(r.added||r.modified)&&(He("delta").innerHTML=`<span class="k"></span>added ${r.added} nodes \xB7 ${r.addedEdges} edges<br><span class="k2"></span>modified ${r.modified} nodes`,He("deltaBox").style.display="block"),j0(t,e),tb(),cl("bhex"),gl("core")}function j0(t,e){let r=new Map;for(let a of wt.nodes)r.set(`c:${a.component}`,(r.get(`c:${a.component}`)??0)+1),r.set(`d:${a.domain}`,(r.get(`d:${a.domain}`)??0)+1);He("comps").innerHTML=e.map(a=>`<label><span class="sw" style="${eb(a)}"></span><input type=checkbox class=cf value="${a}" ${ol.includes(a)?"checked":""}>${a}<span class="n">${r.get(`c:${a}`)??0}</span></label>`).join(""),He("doms").innerHTML=t.sort((a,n)=>(r.get(`d:${n}`)??0)-(r.get(`d:${a}`)??0)).map(a=>{let n=wn(a);return`<label><span class="sw" style="background:${vr(n,La(a)?0:60,50)}"></span><input type=checkbox class=df value="${a}" checked>${a}<span class="n">${r.get(`d:${a}`)??0}</span></label>`}).join("");for(let a of ea(".cf,.df,.rf"))a.onchange=()=>Ir();He("showId").onchange=()=>Ir(),He("crossOnly").onchange=()=>Ir(),He("deltaOnly").onchange=()=>Ir()}function eb(t){let e="#8b949e";return sl.includes(t)?`border:1.4px dashed ${e};border-radius:5px`:`background:${e};${{Entity:"border-radius:6px/50%",Service:"border-radius:0",Port:"clip-path:polygon(22% 0,100% 0,100% 78%,78% 100%,0 100%,0 22%)",Event:"transform:skewX(-16deg)"}[t]??"border-radius:5px"}`}function tb(){let t=[...new Set(wt.nodes.map(n=>n.domain))].map(n=>({data:{id:`dom::${n}`,label:n,kind:"domain",hue:wn(n),sat:La(n)?0:26}})),e=wt.nodes.map(n=>({data:{...n,parent:`dom::${n.domain}`,kind:"type",hue:wn(n.domain),sat:La(n.domain)?0:qc[n.component],shape:Yc[n.component],outline:sl.includes(n.component),label:n.name},position:{...pl.hex.get(n.id)??{x:0,y:0}}})),r=wt.edges.map((n,i)=>({data:{...n,id:`e${i}`,source:n.src,target:n.dst,hue:wn(vl(n.src)?.domain??"")}}));Ue=lr({container:He("cy"),elements:[...t,...e,...r],layout:{name:"preset"},minZoom:.05,maxZoom:3,wheelSensitivity:.25,style:[{selector:'node[kind="domain"]',style:{"background-color":n=>vr(n.data("hue"),n.data("sat"),13),"background-opacity":.5,"border-width":1.5,"border-color":n=>vr(n.data("hue"),n.data("sat")+19,42),shape:"round-rectangle",label:"data(label)","text-valign":"top","font-size":21,"font-weight":"bold",color:n=>vr(n.data("hue"),n.data("sat")+29,62),"text-margin-y":-7,padding:"16px"}},{selector:'node[kind="type"]',style:{shape:"data(shape)",width:"182px",height:"32px","background-color":n=>vr(n.data("hue"),n.data("sat"),46-n.data("sat")*.07),"background-opacity":n=>n.data("outline")?0:1,label:"data(label)","font-size":11,"text-valign":"center","text-wrap":"ellipsis","text-max-width":"160px",color:n=>n.data("outline")?vr(n.data("hue"),n.data("hue")?52:0,72):"#fff","border-width":n=>n.data("outline")?1.4:1,"border-color":n=>vr(n.data("hue"),n.data("outline")?48:n.data("sat"),n.data("outline")?52:70),"border-style":n=>n.data("outline")?"dashed":"solid"}},{selector:'node[component="Entity"]',style:{"border-width":2.6,width:"190px",height:"36px","font-weight":"bold","font-size":12}},{selector:'node[component="Service"]',style:{"border-width":1.8}},{selector:"edge",style:{width:1.9,"line-color":n=>vr(n.data("hue"),n.data("crossDomain")?62:22,n.data("crossDomain")?58:46),opacity:n=>n.data("crossDomain")?.8:.62,"target-arrow-color":n=>vr(n.data("hue"),n.data("crossDomain")?62:22,n.data("crossDomain")?58:46)}},{selector:'edge[rel="DEPENDS_ON"]',style:{"line-style":"solid","curve-style":"straight","target-arrow-shape":"vee","arrow-scale":.95}},{selector:'edge[rel="IMPLEMENTS"]',style:{"line-style":"dashed","line-dash-pattern":[9,5],width:2.2,"curve-style":"unbundled-bezier","control-point-distances":[42],"control-point-weights":[.5],"target-arrow-shape":"triangle","target-arrow-fill":"hollow","arrow-scale":1.35}},{selector:'edge[rel="EXTENDS"]',style:{"line-style":"dashed","line-dash-pattern":[3,3],width:3.4,"curve-style":"unbundled-bezier","control-point-distances":[58],"control-point-weights":[.5],"target-arrow-shape":"triangle","target-arrow-fill":"hollow","arrow-scale":1.6}},{selector:"edge[?identifierOnly]",style:{"line-style":"dotted",opacity:.4}},{selector:'edge[violation != ""]',style:{"line-color":"#f85149","target-arrow-color":"#f85149",width:3.4,opacity:1,"z-index":90,label:"data(violation)","font-size":10,color:"#f85149","text-background-color":"#0e1116","text-background-opacity":.85,"text-background-padding":"3px"}},{selector:'edge[status="added"]',style:{opacity:1,"line-color":"#f0883e","target-arrow-color":"#f0883e","z-index":80}},{selector:".dim",style:{opacity:.035,"text-opacity":0}},{selector:".nb",style:{"border-width":2.4,"border-color":"#58a6ff","z-index":50}},{selector:".hi",style:{"border-width":5,"border-color":"#58a6ff","z-index":100}},{selector:"edge.sel",style:{width:5,opacity:1,"line-color":"#58a6ff","target-arrow-color":"#58a6ff","z-index":99}}]}),window.cy=Ue,new ResizeObserver(()=>{Ue.resize();let n=Ue.nodes('[kind="type"]').filter(i=>i.style("display")==="element");n.length&&Ue.fit(n,40)}).observe(He("cy")),Ue.on("tap",'node[kind="type"]',n=>dl(n.target)),Ue.on("tap","edge",n=>sb(n.target)),Ue.on("tap",n=>{let i=n.target;(n.target===Ue||i.data?.("kind")==="domain")&&hl()}),document.addEventListener("keydown",n=>{n.key==="Escape"&&hl()})}var vl=t=>wt.nodes.find(e=>e.id===t);function Ir(){let t=new Set(ea(".cf:checked").map(u=>u.value)),e=new Set(ea(".df:checked").map(u=>u.value)),r=new Set(ea(".rf:checked").map(u=>u.value)),a=He("showId").checked,n=He("crossOnly").checked,i=He("deltaOnly").checked,o=new Set;if(jr)for(let u of Ue.edges())u.data("violation")&&(o.add(u.data("source")),o.add(u.data("target")));Ue.batch(()=>{for(let l of Ue.nodes('[kind="type"]')){let f=l.data(),v=t.has(f.component)&&e.has(f.domain);v&&i&&f.status==="existing"&&(v=!1),v&&jr&&!o.has(f.id)&&(v=!1),l.style("display",v?"element":"none")}let u=l=>l.style("display")==="element";for(let l of Ue.nodes('[kind="domain"]'))l.style("display",l.children().filter(f=>u(f)).length?"element":"none");for(let l of Ue.edges()){let f=u(l.source())&&u(l.target())&&r.has(l.data("rel"));f&&!a&&l.data("identifierOnly")&&(f=!1),f&&n&&!l.data("crossDomain")&&(f=!1),f&&jr&&!l.data("violation")&&(f=!1),l.style("display",f?"element":"none")}}),rb(),Ue.nodes('[kind="type"]').filter(u=>u.style("display")==="element").length&&ab()}function rb(){let t=n=>n.style("display")==="element",e=Ue.nodes('[kind="type"]').filter(n=>t(n)).length,r=Ue.edges().filter(n=>t(n)).length,a=Ue.edges().filter(n=>t(n)&&n.data("violation")).length;He("stat").innerHTML=`Nodes <b>${e}</b>/${Ue.nodes('[kind="type"]').length} \xB7 Edges <b>${r}</b>/${Ue.edges().length}`,He("cviol").textContent=String(a);for(let n of["DEPENDS_ON","IMPLEMENTS","EXTENDS"]){let i=document.getElementById(`c${n}`);i&&(i.textContent=String(Ue.edges(`[rel="${n}"]`).filter(o=>t(o)).length))}}function ab(){clearTimeout(Kc),Kc=setTimeout(Mi,110)}function Mi(){Ni?.stop(),Ni=void 0,Or?Li==="hex"?nb():ob():ib()}var ul=t=>t.style("display")==="element";function nb(){let t=new Set(Ue.nodes('[kind="type"]').filter(i=>ul(i)).map(i=>i.id())),e=new Set(Ue.edges().filter(i=>ul(i)).map(i=>i.id())),r={...wt,nodes:wt.nodes.filter(i=>t.has(i.id)),edges:wt.edges.filter((i,o)=>e.has(`e${o}`))},a=new Map(ll(r).map(i=>[i.id,i]));Ue.batch(()=>{for(let i of Ue.nodes('[kind="type"]')){let o=a.get(i.id());o&&i.position({x:o.x,y:o.y})}});let n=Ue.nodes('[kind="type"]').filter(i=>ul(i));n.length&&Ue.fit(n,40)}function ib(){let t=pl[Li];Ue.batch(()=>{for(let r of Ue.nodes('[kind="type"]')){let a=t.get(r.id());a&&r.position({x:a.x,y:a.y})}});let e=Ue.nodes('[kind="type"]').filter(r=>r.style("display")==="element");e.length&&Ue.fit(e,40)}function ob(){let t=Ue.elements().filter(r=>r.style("display")==="element"),e=t.nodes().length;e&&(Ni=t.layout({name:"fcose",quality:e<=150?"proof":e<=400?"default":"draft",numIter:e<=150?1600:e<=400?900:500,randomize:e<=150,animate:e<=250,animationDuration:400,nodeSeparation:210,idealEdgeLength:r=>r.data("crossDomain")?300:130,nodeRepulsion:34e3,gravity:.12,gravityCompound:.9,gravityRangeCompound:2.2,packComponents:!0,tile:!0,nodeDimensionsIncludeLabels:!0,stop:()=>Ue.fit(t.nodes(),60)}),Ni.run())}var cl=t=>{for(let e of["bhex","bgrid"])He(e).classList.toggle("on",e===t)};function hl(){Ue.elements().removeClass("hi dim sel nb"),He("info").style.display="none",ta=null,Jr="both"}var Vt=(t,e)=>`<tr><td>${t}</td><td>${e}</td></tr>`,fl=t=>t?'<span style="color:#f0883e">yes</span>':"no",Zc=t=>t==="added"?'<span style="color:#f0883e">added</span>':t==="modified"?'<span style="color:#a371f7">modified</span>':"existing";function dl(t){ta=t.id();let e=t.data(),r=c=>c.style("display")==="element",a=t.connectedEdges().filter(c=>r(c)),n=a.filter(c=>c.target().id()===ta),i=a.filter(c=>c.source().id()===ta),o=Jr==="in"?n:Jr==="out"?i:a,s=o.connectedNodes().difference(t);Ue.elements().removeClass("hi dim sel nb").addClass("dim"),t.removeClass("dim").addClass("hi"),s.removeClass("dim").addClass("nb"),o.removeClass("dim").addClass("sel"),s.parent().removeClass("dim"),t.parent().removeClass("dim");let u=(c,h,d)=>`<button class="dirb ${Jr===c?"on":""}" data-dir="${c}">${h} ${d}</button>`,l=(c,h,d)=>{let g=d.data();return`<div class="lk" data-goto="${g.id}"><span class="ar">${h}</span>${g.name}<span class="mut"> ${g.domain}\xB7${g.component}</span><span class="rel">${c.data("rel")==="DEPENDS_ON"?"":c.data("rel")}</span></div>`},f="";if(Jr!=="out")for(let c of n)f+=l(c,"\u2190",c.source());if(Jr!=="in")for(let c of i)f+=l(c,"\u2192",c.target());let v=e.api.length||e.props.length?`<div class="dirbar" style="display:block"><b>Public contract</b><span class="mut"> ${e.api.length} fn${e.props.length?` \xB7 ${e.props.length} prop`:""}</span></div><div class="lks">${e.api.map(c=>{let h=c.indexOf("(");return`<div class="lk"><span class="sig"><b>${c.slice(0,h)}</b>${c.slice(h)}</span></div>`}).join("")}${e.props.map(c=>`<div class="lk"><span class="sig" style="color:#6e7681">${c}</span></div>`).join("")}</div>`:"";He("info").style.display="block",He("info").innerHTML=`<div class="ih">${e.name}<span class="x">\xD7</span></div><table>${Vt("Domain",e.domain)}${Vt("Component",`${e.component} <span class="mut">${e.layer}${e.sublayer?`/${e.sublayer}`:""}</span>`)}${Vt("Kind",e.kind)}${Vt("Status",Zc(e.status))}${Vt("File",`<span class="mut">${e.file}:${e.line}</span>`)}${Vt("Id",`<span class="mut" style="word-break:break-all">${e.id}</span>`)}</table>${v}<div class="dirbar">${u("both","Both",a.length)}${u("in","\u2190 In",n.length)}${u("out","Out \u2192",i.length)}</div><div class="lks">${f||'<span class="mut">No visible connections</span>'}</div><div class="hint">Click an item to focus it \xB7 Esc to clear</div>`,Qc()}function sb(t){ta=null;let e=t.data(),r=vl(e.src),a=vl(e.dst);Ue.elements().removeClass("hi dim sel nb").addClass("dim"),t.removeClass("dim").addClass("sel"),t.connectedNodes().removeClass("dim").addClass("nb").parent().removeClass("dim");let n=e.contracts.length?`<div class="dirbar" style="display:block"><b>Contracts used</b><span class="mut"> ${e.contracts.length}/${a?.api.length??0}</span></div><div class="lks">${e.contracts.map(i=>{let o=i.indexOf("(");return`<div class="lk"><span class="sig"><b>${o>0?i.slice(0,o):i}</b>${o>0?i.slice(o):""}</span></div>`}).join("")}</div>`:'<div class="hint">No method calls \u2014 type reference only</div>';He("info").style.display="block",He("info").innerHTML=`<div class="ih">${e.rel}<span class="x">\xD7</span></div><table>${Vt("Source",`${r?.name} <span class="mut">${r?.domain}\xB7${r?.component}</span>`)}${Vt("Target",`${a?.name} <span class="mut">${a?.domain}\xB7${a?.component}</span>`)}${e.rel==="DEPENDS_ON"?Vt("Weight",`${e.weight} <span class="mut">occurrences</span>`):""}${Vt("Cross-domain",fl(e.crossDomain))}${Vt("Identifier only",fl(e.identifierOnly))}${Vt("Via signature",fl(e.viaSignature))}${e.violation?Vt("Violation",`<span style="color:#f85149">${e.violation}</span>`):""}${Vt("Status",Zc(e.status))}</table>${n}`,Qc()}function Qc(){let t=He("info").querySelector(".x");t&&(t.onclick=()=>hl());for(let e of Array.from(He("info").querySelectorAll(".dirb")))e.onclick=()=>{Jr=e.dataset.dir,ta&&dl(Ue.getElementById(ta))};for(let e of Array.from(He("info").querySelectorAll("[data-goto]")))e.onclick=()=>dl(Ue.getElementById(e.dataset.goto))}function gl(t){for(let e of ea(".cf"))e.checked=t==="core"?ol.includes(e.value):!0;for(let e of["pcore","pall"])He(e).classList.toggle("on",e===`p${t}`);Ir()}function lb(){He("pcore").onclick=()=>gl("core"),He("pall").onclick=()=>gl("all"),He("bhex").onclick=()=>{Li="hex",cl("bhex"),Mi()},He("bgrid").onclick=()=>{Li="grid",cl("bgrid"),Mi()},He("borg").onclick=()=>{Or=!Or,He("borg").classList.toggle("on",Or),Mi()},He("bviol").onclick=()=>{jr=!jr,He("bviol").classList.toggle("on",jr),jr?(Ai=Or,Or=!0):Ai!==void 0&&(Or=Ai,Ai=void 0),He("borg").classList.toggle("on",Or),Ir()},He("allDomOn").onclick=()=>{for(let t of ea(".df"))t.checked=!0;Ir()},He("allDomOff").onclick=()=>{for(let t of ea(".df"))t.checked=!1;Ir()},J0()}lb();})();
321
+ `),s=Jm(a,n,o);s.aPosition=a.getAttribLocation(s,"aPosition"),s.aIndex=a.getAttribLocation(s,"aIndex"),s.aVertType=a.getAttribLocation(s,"aVertType"),s.aTransform=a.getAttribLocation(s,"aTransform"),s.aAtlasId=a.getAttribLocation(s,"aAtlasId"),s.aTex=a.getAttribLocation(s,"aTex"),s.aPointAPointB=a.getAttribLocation(s,"aPointAPointB"),s.aPointCPointD=a.getAttribLocation(s,"aPointCPointD"),s.aLineWidth=a.getAttribLocation(s,"aLineWidth"),s.aColor=a.getAttribLocation(s,"aColor"),s.aCornerRadius=a.getAttribLocation(s,"aCornerRadius"),s.aBorderColor=a.getAttribLocation(s,"aBorderColor"),s.uPanZoomMatrix=a.getUniformLocation(s,"uPanZoomMatrix"),s.uAtlasSize=a.getUniformLocation(s,"uAtlasSize"),s.uBGColor=a.getUniformLocation(s,"uBGColor"),s.uZoom=a.getUniformLocation(s,"uZoom"),s.uTextures=[];for(var u=0;u<this.batchManager.getMaxAtlasesPerBatch();u++)s.uTextures.push(a.getUniformLocation(s,"uTexture".concat(u)));return s}},{key:"_createVAO",value:function(){var r=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=r.length/2;var a=this.maxInstances,n=this.gl,i=this.program,o=n.createVertexArray();return n.bindVertexArray(o),s0(n,"vec2",i.aPosition,r),this.transformBuffer=l0(n,a,i.aTransform),this.indexBuffer=Zt(n,a,"vec4",i.aIndex),this.vertTypeBuffer=Zt(n,a,"int",i.aVertType),this.atlasIdBuffer=Zt(n,a,"int",i.aAtlasId),this.texBuffer=Zt(n,a,"vec4",i.aTex),this.pointAPointBBuffer=Zt(n,a,"vec4",i.aPointAPointB),this.pointCPointDBuffer=Zt(n,a,"vec4",i.aPointCPointD),this.lineWidthBuffer=Zt(n,a,"vec2",i.aLineWidth),this.colorBuffer=Zt(n,a,"vec4",i.aColor),this.cornerRadiusBuffer=Zt(n,a,"vec4",i.aCornerRadius),this.borderColorBuffer=Zt(n,a,"vec4",i.aBorderColor),n.bindVertexArray(null),o}},{key:"buffers",get:function(){var r=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(a){return yr(a,"Buffer")}).map(function(a){return r[a]})),this._buffers}},{key:"startFrame",value:function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xa.SCREEN;this.panZoomMatrix=r,this.renderTarget=a,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"_isVisible",value:function(r,a){return r.visible()?a&&a.isVisible?a.isVisible(r):!0:!1}},{key:"drawTexture",value:function(r,a,n){var i=this.atlasManager,o=this.batchManager,s=i.getRenderTypeOpts(n);if(this._isVisible(r,s)&&!(r.isEdge()&&!this._isValidEdge(r))){if(this.renderTarget.picking&&s.getTexPickingMode){var u=s.getTexPickingMode(r);if(u===oi.IGNORE)return;if(u==oi.USE_BB){this.drawPickingRectangle(r,a,n);return}}var l=i.getAtlasInfo(r,n),f=zt(l),v;try{for(f.s();!(v=f.n()).done;){var c=v.value,h=c.atlas,d=c.tex1,g=c.tex2;o.canAddToCurrentBatch(h)||this.endBatch();for(var m=o.getAtlasIndexForBatch(h),p=0,y=[[d,!0],[g,!1]];p<y.length;p++){var b=dt(y[p],2),E=b[0],C=b[1];if(E.w!=0){var A=this.instanceCount;this.vertTypeBuffer.getView(A)[0]=is;var D=this.indexBuffer.getView(A);sa(a,D);var N=this.atlasIdBuffer.getView(A);N[0]=m;var O=this.texBuffer.getView(A);O[0]=E.x,O[1]=E.y,O[2]=E.w,O[3]=E.h;var R=this.transformBuffer.getMatrixView(A);this.setTransformMatrix(r,R,s,c,C),this.instanceCount++,C||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(P){f.e(P)}finally{f.f()}}}},{key:"setTransformMatrix",value:function(r,a,n,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=0;if(n.shapeProps&&n.shapeProps.padding&&(s=r.pstyle(n.shapeProps.padding).pfValue),i){var u=i.bb,l=i.tex1,f=i.tex2,v=l.w/(l.w+f.w);o||(v=1-v);var c=this._getAdjustedBB(u,s,o,v);this._applyTransformMatrix(a,c,n,r)}else{var h=n.getBoundingBox(r),d=this._getAdjustedBB(h,s,!0,1);this._applyTransformMatrix(a,d,n,r)}}},{key:"_applyTransformMatrix",value:function(r,a,n,i){var o,s;Uf(r);var u=n.getRotation?n.getRotation(i):0;if(u!==0){var l=n.getRotationPoint(i),f=l.x,v=l.y;$n(r,r,[f,v]),Hf(r,r,u);var c=n.getRotationOffset(i);o=c.x+(a.xOffset||0),s=c.y+(a.yOffset||0)}else o=a.x1,s=a.y1;$n(r,r,[o,s]),Ds(r,r,[a.w,a.h])}},{key:"_getAdjustedBB",value:function(r,a,n,i){var o=r.x1,s=r.y1,u=r.w,l=r.h,f=r.yOffset;a&&(o-=a,s-=a,u+=2*a,l+=2*a);var v=0,c=u*i;return n&&i<1?u=c:!n&&i<1&&(v=u-c,o+=v,u=c),{x1:o,y1:s,w:u,h:l,xOffset:v,yOffset:f}}},{key:"drawPickingRectangle",value:function(r,a,n){var i=this.atlasManager.getRenderTypeOpts(n),o=this.instanceCount;this.vertTypeBuffer.getView(o)[0]=la;var s=this.indexBuffer.getView(o);sa(a,s);var u=this.colorBuffer.getView(o);zr([0,0,0],1,u);var l=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(r,l,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:"drawNode",value:function(r,a,n){var i=this.simpleShapeOptions.get(n);if(this._isVisible(r,i)){var o=i.shapeProps,s=this._getVertTypeForShape(r,o.shape);if(s===void 0||i.isSimple&&!i.isSimple(r,this.renderTarget)){this.drawTexture(r,a,n);return}var u=this.instanceCount;if(this.vertTypeBuffer.getView(u)[0]=s,s===kn||s===Va){var l=i.getBoundingBox(r),f=this._getCornerRadius(r,o.radius,l),v=this.cornerRadiusBuffer.getView(u);v[0]=f,v[1]=f,v[2]=f,v[3]=f,s===Va&&(v[0]=0,v[2]=0)}var c=this.indexBuffer.getView(u);sa(a,c);var h=this.renderTarget.picking?1:n==="node-body"?r.effectiveOpacity():1,d=this.renderTarget.picking?1:r.pstyle(o.opacity).value*h,g=r.pstyle(o.color).value,m=this.colorBuffer.getView(u);zr(g,d,m);var p=this.lineWidthBuffer.getView(u);if(p[0]=0,p[1]=0,o.border){var y=r.pstyle("border-width").value;if(y>0){var b=r.pstyle("border-color").value,E=h*r.pstyle("border-opacity").value,C=this.borderColorBuffer.getView(u);zr(b,E,C);var A=r.pstyle("border-position").value;if(A==="inside")p[0]=0,p[1]=-y;else if(A==="outside")p[0]=y,p[1]=0;else{var D=y/2;p[0]=D,p[1]=-D}}}var N=this.transformBuffer.getMatrixView(u);this.setTransformMatrix(r,N,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"_getVertTypeForShape",value:function(r,a){var n=r.pstyle(a).value;switch(n){case"rectangle":return la;case"ellipse":return Ga;case"roundrectangle":case"round-rectangle":return kn;case"bottom-round-rectangle":return Va;default:return}}},{key:"_getCornerRadius",value:function(r,a,n){var i=n.w,o=n.h;if(r.pstyle(a).value==="auto")return Cr(i,o);var s=r.pstyle(a).pfValue,u=i/2,l=o/2;return Math.min(s,l,u)}},{key:"drawEdgeArrow",value:function(r,a,n){if(r.visible()){var i=r._private.rscratch,o,s,u;if(n==="source"?(o=i.arrowStartX,s=i.arrowStartY,u=i.srcArrowAngle):(o=i.arrowEndX,s=i.arrowEndY,u=i.tgtArrowAngle),!(isNaN(o)||o==null||isNaN(s)||s==null||isNaN(u)||u==null)){var l=r.pstyle(n+"-arrow-shape").value;if(l!=="none"){var f=r.pstyle(n+"-arrow-color").value,v=r.pstyle("opacity").value,c=r.pstyle("line-opacity").value,h=v*c,d=r.pstyle("width").pfValue,g=r.pstyle("arrow-scale").value,m=this.r.getArrowWidth(d,g),p=this.instanceCount,y=this.transformBuffer.getMatrixView(p);Uf(y),$n(y,y,[o,s]),Ds(y,y,[m,m]),Hf(y,y,u),this.vertTypeBuffer.getView(p)[0]=os;var b=this.indexBuffer.getView(p);sa(a,b);var E=this.colorBuffer.getView(p);zr(f,h,E),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"drawEdgeLine",value:function(r,a){if(r.visible()){var n=this._getEdgePoints(r);if(n){var i=r.pstyle("opacity").value,o=r.pstyle("line-opacity").value,s=r.pstyle("width").pfValue,u=r.pstyle("line-color").value,l=i*o;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=qf;var v=this.indexBuffer.getView(f);sa(a,v);var c=this.colorBuffer.getView(f);zr(u,l,c);var h=this.lineWidthBuffer.getView(f);h[0]=s;var d=this.pointAPointBBuffer.getView(f);d[0]=n[0],d[1]=n[1],d[2]=n[2],d[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var g=0;g<n.length-2;g+=2){var m=this.instanceCount;this.vertTypeBuffer.getView(m)[0]=Yf;var p=this.indexBuffer.getView(m);sa(a,p);var y=this.colorBuffer.getView(m);zr(u,l,y);var b=this.lineWidthBuffer.getView(m);b[0]=s;var E=n[g-2],C=n[g-1],A=n[g],D=n[g+1],N=n[g+2],O=n[g+3],R=n[g+4],P=n[g+5];g==0&&(E=2*A-N+.001,C=2*D-O+.001),g==n.length-4&&(R=2*N-A+.001,P=2*O-D+.001);var w=this.pointAPointBBuffer.getView(m);w[0]=E,w[1]=C,w[2]=A,w[3]=D;var x=this.pointCPointDBuffer.getView(m);x[0]=N,x[1]=O,x[2]=R,x[3]=P,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"_isValidEdge",value:function(r){var a=r._private.rscratch;return!(a.badLine||a.allpts==null||isNaN(a.allpts[0]))}},{key:"_getEdgePoints",value:function(r){var a=r._private.rscratch;if(this._isValidEdge(r)){var n=a.allpts;if(n.length==4)return n;var i=this._getNumSegments(r);return this._getCurveSegmentPoints(n,i)}}},{key:"_getNumSegments",value:function(r){var a=15;return Math.min(Math.max(a,5),this.maxInstances)}},{key:"_getCurveSegmentPoints",value:function(r,a){if(r.length==4)return r;for(var n=Array((a+1)*2),i=0;i<=a;i++)if(i==0)n[0]=r[0],n[1]=r[1];else if(i==a)n[i*2]=r[r.length-2],n[i*2+1]=r[r.length-1];else{var o=i/a;this._setCurvePoint(r,o,n,i*2)}return n}},{key:"_setCurvePoint",value:function(r,a,n,i){if(r.length<=2)n[i]=r[0],n[i+1]=r[1];else{for(var o=Array(r.length-2),s=0;s<o.length;s+=2){var u=(1-a)*r[s]+a*r[s+2],l=(1-a)*r[s+1]+a*r[s+3];o[s]=u,o[s+1]=l}return this._setCurvePoint(o,a,n,i)}}},{key:"endBatch",value:function(){var r=this.gl,a=this.vao,n=this.vertexCount,i=this.instanceCount;if(i!==0){var o=this.renderTarget.picking?this.pickingProgram:this.program;r.useProgram(o),r.bindVertexArray(a);var s=zt(this.buffers),u;try{for(s.s();!(u=s.n()).done;){var l=u.value;l.bufferSubData(i)}}catch(d){s.e(d)}finally{s.f()}for(var f=this.batchManager.getAtlases(),v=0;v<f.length;v++)f[v].bufferIfNeeded(r);for(var c=0;c<f.length;c++)r.activeTexture(r.TEXTURE0+c),r.bindTexture(r.TEXTURE_2D,f[c].texture),r.uniform1i(o.uTextures[c],c);r.uniform1f(o.uZoom,e0(this.r)),r.uniformMatrix3fv(o.uPanZoomMatrix,!1,this.panZoomMatrix),r.uniform1i(o.uAtlasSize,this.batchManager.getAtlasSize());var h=zr(this.bgColor,1);r.uniform4fv(o.uBGColor,h),r.drawArraysInstanced(r.TRIANGLES,0,n,i),r.bindVertexArray(null),r.bindTexture(r.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:i,atlasCount:f.length}),this.startBatch()}}},{key:"getDebugInfo",value:function(){var r=this.atlasManager.getDebugInfo(),a=r.reduce(function(o,s){return o+s.atlasCount},0),n=this.batchDebugInfo,i=n.reduce(function(o,s){return o+s.count},0);return{atlasInfo:r,totalAtlases:a,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:i}}}])})(),Mc={};Mc.initWebgl=function(t,e){var r=this,a=r.data.contexts[r.WEBGL];t.bgColor=x0(r),t.webglTexSize=Math.min(t.webglTexSize,a.getParameter(a.MAX_TEXTURE_SIZE)),t.webglTexRows=Math.min(t.webglTexRows,54),t.webglTexRowsNodes=Math.min(t.webglTexRowsNodes,54),t.webglBatchSize=Math.min(t.webglBatchSize,16384),t.webglTexPerBatch=Math.min(t.webglTexPerBatch,a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)),r.webglDebug=t.webglDebug,r.webglDebugShowAtlases=t.webglDebugShowAtlases,r.pickingFrameBuffer=u0(a),r.pickingFrameBuffer.needsDraw=!0,r.drawing=new E0(r,a,t);var n=function(v){return function(c){return r.getTextAngle(c,v)}},i=function(v){return function(c){var h=c.pstyle(v);return h&&h.value}},o=function(v){return function(c){return c.pstyle("".concat(v,"-opacity")).value>0}},s=function(v){var c=v.pstyle("text-events").strValue==="yes";return c?oi.USE_BB:oi.IGNORE},u=function(v){var c=v.position(),h=c.x,d=c.y,g=v.outerWidth(),m=v.outerHeight();return{w:g,h:m,x1:h-g/2,y1:d-m/2}};r.drawing.addAtlasCollection("node",{texRows:t.webglTexRowsNodes}),r.drawing.addAtlasCollection("label",{texRows:t.webglTexRows}),r.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:e.getStyleKey,getBoundingBox:e.getElementBox,drawElement:e.drawElement}),r.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:u,isSimple:r0,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),r.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:u,isVisible:o("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),r.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:u,isVisible:o("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),r.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:s,getKey:ss(e.getLabelKey,null),getBoundingBox:ls(e.getLabelBox,null),drawClipped:!0,drawElement:e.drawLabel,getRotation:n(null),getRotationPoint:e.getLabelRotationPoint,getRotationOffset:e.getLabelRotationOffset,isVisible:i("label")}),r.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:s,getKey:ss(e.getSourceLabelKey,"source"),getBoundingBox:ls(e.getSourceLabelBox,"source"),drawClipped:!0,drawElement:e.drawSourceLabel,getRotation:n("source"),getRotationPoint:e.getSourceLabelRotationPoint,getRotationOffset:e.getSourceLabelRotationOffset,isVisible:i("source-label")}),r.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:s,getKey:ss(e.getTargetLabelKey,"target"),getBoundingBox:ls(e.getTargetLabelBox,"target"),drawClipped:!0,drawElement:e.drawTargetLabel,getRotation:n("target"),getRotationPoint:e.getTargetLabelRotationPoint,getRotationOffset:e.getTargetLabelRotationOffset,isVisible:i("target-label")});var l=un(function(){console.log("garbage collect flag set"),r.data.gc=!0},1e4);r.onUpdateEleCalcs(function(f,v){var c=!1;v&&v.length>0&&(c|=r.drawing.invalidate(v)),c&&l()}),T0(r)};function x0(t){var e=t.cy.container(),r=e&&e.style&&e.style.backgroundColor||"white";return tv(r)}function Lc(t,e){var r=t._private.rscratch;return It(r,"labelWrapCachedLines",e)||[]}var ss=function(e,r){return function(a){var n=e(a),i=Lc(a,r);return i.length>1?i.map(function(o,s){return"".concat(n,"_").concat(s)}):n}},ls=function(e,r){return function(a,n){var i=e(a);if(typeof n=="string"){var o=n.indexOf("_");if(o>0){var s=Number(n.substring(o+1)),u=Lc(a,r),l=i.h/u.length,f=l*s,v=i.y1+f;return{x1:i.x1,w:i.w,y1:v,h:l,yOffset:f}}}return i}};function T0(t){{var e=t.render;t.render=function(i){i=i||{};var o=t.cy;t.webgl&&(o.zoom()>Ec?(C0(t),e.call(t,i)):(S0(t),Rc(t,i,Xa.SCREEN)))}}{var r=t.matchCanvasSize;t.matchCanvasSize=function(i){r.call(t,i),t.pickingFrameBuffer.setFramebufferAttachmentSizes(t.canvasWidth,t.canvasHeight),t.pickingFrameBuffer.needsDraw=!0}}t.findNearestElements=function(i,o,s,u){return R0(t,i,o)};{var a=t.invalidateCachedZSortedEles;t.invalidateCachedZSortedEles=function(){a.call(t),t.pickingFrameBuffer.needsDraw=!0}}{var n=t.notify;t.notify=function(i,o){n.call(t,i,o),i==="viewport"||i==="bounds"?t.pickingFrameBuffer.needsDraw=!0:i==="background"&&t.drawing.invalidate(o,{type:"node-body"})}}}function C0(t){var e=t.data.contexts[t.WEBGL];e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}function S0(t){var e=function(a){a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,t.canvasWidth,t.canvasHeight),a.restore()};e(t.data.contexts[t.NODE]),e(t.data.contexts[t.DRAG])}function D0(t){var e=t.canvasWidth,r=t.canvasHeight,a=el(t),n=a.pan,i=a.zoom,o=ns();$n(o,o,[n.x,n.y]),Ds(o,o,[i,i]);var s=ns();v0(s,e,r);var u=ns();return f0(u,s,o),u}function Nc(t,e){var r=t.canvasWidth,a=t.canvasHeight,n=el(t),i=n.pan,o=n.zoom;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r,a),e.translate(i.x,i.y),e.scale(o,o)}function A0(t,e){t.drawSelectionRectangle(e,function(r){return Nc(t,r)})}function M0(t){var e=t.data.contexts[t.NODE];e.save(),Nc(t,e),e.strokeStyle="rgba(0, 0, 0, 0.3)",e.beginPath(),e.moveTo(-1e3,0),e.lineTo(1e3,0),e.stroke(),e.beginPath(),e.moveTo(0,-1e3),e.lineTo(0,1e3),e.stroke(),e.restore()}function L0(t){var e=function(n,i,o){for(var s=n.atlasManager.getAtlasCollection(i),u=t.data.contexts[t.NODE],l=s.atlases,f=0;f<l.length;f++){var v=l[f],c=v.canvas;if(c){var h=c.width,d=c.height,g=h*f,m=c.height*o,p=.4;u.save(),u.scale(p,p),u.drawImage(c,g,m),u.strokeStyle="black",u.rect(g,m,h,d),u.stroke(),u.restore()}}},r=0;e(t.drawing,"node",r++),e(t.drawing,"label",r++)}function N0(t,e,r,a,n){var i,o,s,u,l=el(t),f=l.pan,v=l.zoom;{var c=t0(t,f,v,e,r),h=dt(c,2),d=h[0],g=h[1],m=6;i=d-m/2,o=g-m/2,s=m,u=m}if(s===0||u===0)return[];var p=t.data.contexts[t.WEBGL];p.bindFramebuffer(p.FRAMEBUFFER,t.pickingFrameBuffer),t.pickingFrameBuffer.needsDraw&&(p.viewport(0,0,p.canvas.width,p.canvas.height),Rc(t,null,Xa.PICKING),t.pickingFrameBuffer.needsDraw=!1);var y=s*u,b=new Uint8Array(y*4);p.readPixels(i,o,s,u,p.RGBA,p.UNSIGNED_BYTE,b),p.bindFramebuffer(p.FRAMEBUFFER,null);for(var E=new Set,C=0;C<y;C++){var A=b.slice(C*4,C*4+4),D=n0(A)-1;D>=0&&E.add(D)}return E}function R0(t,e,r){var a=N0(t,e,r),n=t.getCachedZSortedEles(),i,o,s=zt(a),u;try{for(s.s();!(u=s.n()).done;){var l=u.value,f=n[l];if(!i&&f.isNode()&&(i=f),!o&&f.isEdge()&&(o=f),i&&o)break}}catch(v){s.e(v)}finally{s.f()}return[i,o].filter(Boolean)}function us(t,e,r){var a=t.drawing;e+=1,r.isNode()?(a.drawNode(r,e,"node-underlay"),a.drawNode(r,e,"node-body"),a.drawTexture(r,e,"label"),a.drawNode(r,e,"node-overlay")):(a.drawEdgeLine(r,e),a.drawEdgeArrow(r,e,"source"),a.drawEdgeArrow(r,e,"target"),a.drawTexture(r,e,"label"),a.drawTexture(r,e,"edge-source-label"),a.drawTexture(r,e,"edge-target-label"))}function Rc(t,e,r){var a;t.webglDebug&&(a=performance.now());var n=t.drawing,i=0;if(r.screen&&t.data.canvasNeedsRedraw[t.SELECT_BOX]&&A0(t,e),t.data.canvasNeedsRedraw[t.NODE]||r.picking){var o=t.data.contexts[t.WEBGL];r.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var s=D0(t),u=t.getCachedZSortedEles();if(i=u.length,n.startFrame(s,r),r.screen){for(var l=0;l<u.nondrag.length;l++)us(t,l,u.nondrag[l]);for(var f=0;f<u.drag.length;f++)us(t,f,u.drag[f])}else if(r.picking)for(var v=0;v<u.length;v++)us(t,v,u[v]);n.endFrame(),r.screen&&t.webglDebugShowAtlases&&(M0(t),L0(t)),t.data.canvasNeedsRedraw[t.NODE]=!1,t.data.canvasNeedsRedraw[t.DRAG]=!1}if(t.webglDebug){var c=performance.now(),h=!1,d=Math.ceil(c-a),g=n.getDebugInfo(),m=["".concat(i," elements"),"".concat(g.totalInstances," instances"),"".concat(g.batchCount," batches"),"".concat(g.totalAtlases," atlases"),"".concat(g.wrappedCount," wrapped textures"),"".concat(g.simpleCount," simple shapes")].join(", ");if(h)console.log("WebGL (".concat(r.name,") - time ").concat(d,"ms, ").concat(m));else{console.log("WebGL (".concat(r.name,") - frame time ").concat(d,"ms")),console.log("Totals:"),console.log(" ".concat(m)),console.log("Texture Atlases Used:");var p=g.atlasInfo,y=zt(p),b;try{for(y.s();!(b=y.n()).done;){var E=b.value;console.log(" ".concat(E.type,": ").concat(E.keyCount," keys, ").concat(E.atlasCount," atlases"))}}catch(C){y.e(C)}finally{y.f()}console.log("")}}t.data.gc&&(console.log("Garbage Collect!"),t.data.gc=!1,n.gc())}var Pr={};Pr.drawPolygonPath=function(t,e,r,a,n,i){var o=a/2,s=n/2;t.beginPath&&t.beginPath(),t.moveTo(e+o*i[0],r+s*i[1]);for(var u=1;u<i.length/2;u++)t.lineTo(e+o*i[u*2],r+s*i[u*2+1]);t.closePath()};Pr.drawRoundPolygonPath=function(t,e,r,a,n,i,o){o.forEach(function(s){return vc(t,s)}),t.closePath()};Pr.drawRoundRectanglePath=function(t,e,r,a,n,i){var o=a/2,s=n/2,u=i==="auto"?Cr(a,n):Math.min(i,s,o);t.beginPath&&t.beginPath(),t.moveTo(e,r-s),t.arcTo(e+o,r-s,e+o,r,u),t.arcTo(e+o,r+s,e,r+s,u),t.arcTo(e-o,r+s,e-o,r,u),t.arcTo(e-o,r-s,e,r-s,u),t.lineTo(e,r-s),t.closePath()};Pr.drawBottomRoundRectanglePath=function(t,e,r,a,n,i){var o=a/2,s=n/2,u=i==="auto"?Cr(a,n):i;t.beginPath&&t.beginPath(),t.moveTo(e,r-s),t.lineTo(e+o,r-s),t.lineTo(e+o,r),t.arcTo(e+o,r+s,e,r+s,u),t.arcTo(e-o,r+s,e-o,r,u),t.lineTo(e-o,r-s),t.lineTo(e,r-s),t.closePath()};Pr.drawCutRectanglePath=function(t,e,r,a,n,i,o){var s=a/2,u=n/2,l=o==="auto"?Gs():o;t.beginPath&&t.beginPath(),t.moveTo(e-s+l,r-u),t.lineTo(e+s-l,r-u),t.lineTo(e+s,r-u+l),t.lineTo(e+s,r+u-l),t.lineTo(e+s-l,r+u),t.lineTo(e-s+l,r+u),t.lineTo(e-s,r+u-l),t.lineTo(e-s,r-u+l),t.closePath()};Pr.drawBarrelPath=function(t,e,r,a,n){var i=a/2,o=n/2,s=e-i,u=e+i,l=r-o,f=r+o,v=cs(a,n),c=v.widthOffset,h=v.heightOffset,d=v.ctrlPtOffsetPct*c;t.beginPath&&t.beginPath(),t.moveTo(s,l+h),t.lineTo(s,f-h),t.quadraticCurveTo(s+d,f,s+c,f),t.lineTo(u-c,f),t.quadraticCurveTo(u-d,f,u,f-h),t.lineTo(u,l+h),t.quadraticCurveTo(u-d,l,u-c,l),t.lineTo(s+c,l),t.quadraticCurveTo(s+d,l,s,l+h),t.closePath()};var Wf=Math.sin(0),Xf=Math.cos(0),As={},Ms={},Pc=Math.PI/40;for(Vr=0*Math.PI;Vr<2*Math.PI;Vr+=Pc)As[Vr]=Math.sin(Vr),Ms[Vr]=Math.cos(Vr);var Vr;Pr.drawEllipsePath=function(t,e,r,a,n){if(t.beginPath&&t.beginPath(),t.ellipse)t.ellipse(e,r,a/2,n/2,0,0,2*Math.PI);else for(var i,o,s=a/2,u=n/2,l=0*Math.PI;l<2*Math.PI;l+=Pc)i=e-s*As[l]*Wf+s*Ms[l]*Xf,o=r+u*Ms[l]*Wf+u*As[l]*Xf,l===0?t.moveTo(i,o):t.lineTo(i,o);t.closePath()};var gn={};gn.createBuffer=function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,[r,r.getContext("2d")]};gn.bufferCanvasImage=function(t){var e=this.cy,r=e.mutableElements(),a=r.boundingBox(),n=this.findContainerClientCoords(),i=t.full?Math.ceil(a.w):n[2],o=t.full?Math.ceil(a.h):n[3],s=we(t.maxWidth)||we(t.maxHeight),u=this.getPixelRatio(),l=1;if(t.scale!==void 0)i*=t.scale,o*=t.scale,l=t.scale;else if(s){var f=1/0,v=1/0;we(t.maxWidth)&&(f=l*t.maxWidth/i),we(t.maxHeight)&&(v=l*t.maxHeight/o),l=Math.min(f,v),i*=l,o*=l}s||(i*=u,o*=u,l*=u);var c=document.createElement("canvas");c.width=i,c.height=o,c.style.width=i+"px",c.style.height=o+"px";var h=c.getContext("2d");if(i>0&&o>0){h.clearRect(0,0,i,o),h.globalCompositeOperation="source-over";var d=this.getCachedZSortedEles();if(t.full)h.translate(-a.x1*l,-a.y1*l),h.scale(l,l),this.drawElements(h,d),h.scale(1/l,1/l),h.translate(a.x1*l,a.y1*l);else{var g=e.pan(),m={x:g.x*l,y:g.y*l};l*=e.zoom(),h.translate(m.x,m.y),h.scale(l,l),this.drawElements(h,d),h.scale(1/l,1/l),h.translate(-m.x,-m.y)}t.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=t.bg,h.rect(0,0,i,o),h.fill())}return c};function P0(t,e){for(var r=atob(t),a=new ArrayBuffer(r.length),n=new Uint8Array(a),i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new Blob([a],{type:e})}function $f(t){var e=t.indexOf(",");return t.substr(e+1)}function Oc(t,e,r){var a=function(){return e.toDataURL(r,t.quality)};switch(t.output){case"blob-promise":return new Ta(function(n,i){try{e.toBlob(function(o){o!=null?n(o):i(new Error("`canvas.toBlob()` sent a null value in its callback"))},r,t.quality)}catch(o){i(o)}});case"blob":return P0($f(a()),r);case"base64":return $f(a());default:return a()}}gn.png=function(t){return Oc(t,this.bufferCanvasImage(t),"image/png")};gn.jpg=function(t){return Oc(t,this.bufferCanvasImage(t),"image/jpeg")};var Ic={};Ic.nodeShapeImpl=function(t,e,r,a,n,i,o,s){switch(t){case"ellipse":return this.drawEllipsePath(e,r,a,n,i);case"polygon":return this.drawPolygonPath(e,r,a,n,i,o);case"round-polygon":return this.drawRoundPolygonPath(e,r,a,n,i,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(e,r,a,n,i,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(e,r,a,n,i,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(e,r,a,n,i,s);case"barrel":return this.drawBarrelPath(e,r,a,n,i)}};var O0=Bc,Ge=Bc.prototype;Ge.CANVAS_LAYERS=3;Ge.SELECT_BOX=0;Ge.DRAG=1;Ge.NODE=2;Ge.WEBGL=3;Ge.CANVAS_TYPES=["2d","2d","2d","webgl2"];Ge.BUFFER_COUNT=3;Ge.TEXTURE_BUFFER=0;Ge.MOTIONBLUR_BUFFER_NODE=1;Ge.MOTIONBLUR_BUFFER_DRAG=2;function Bc(t){var e=this,r=e.cy.window(),a=r.document;t.webgl&&(Ge.CANVAS_LAYERS=e.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),e.data={canvases:new Array(Ge.CANVAS_LAYERS),contexts:new Array(Ge.CANVAS_LAYERS),canvasNeedsRedraw:new Array(Ge.CANVAS_LAYERS),bufferCanvases:new Array(Ge.BUFFER_COUNT),bufferContexts:new Array(Ge.CANVAS_LAYERS)};var n="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";e.data.canvasContainer=a.createElement("div");var o=e.data.canvasContainer.style;e.data.canvasContainer.style[n]=i,o.position="relative",o.zIndex="0",o.overflow="hidden";var s=t.cy.container();s.appendChild(e.data.canvasContainer),s.style[n]=i;var u={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};Ch()&&(u["-ms-touch-action"]="none",u["touch-action"]="none");for(var l=0;l<Ge.CANVAS_LAYERS;l++){var f=e.data.canvases[l]=a.createElement("canvas"),v=Ge.CANVAS_TYPES[l];e.data.contexts[l]=f.getContext(v),e.data.contexts[l]||nt("Could not create canvas of type "+v),Object.keys(u).forEach(function($){f.style[$]=u[$]}),f.style.position="absolute",f.setAttribute("data-id","layer"+l),f.style.zIndex=String(Ge.CANVAS_LAYERS-l),e.data.canvasContainer.appendChild(f),e.data.canvasNeedsRedraw[l]=!1}e.data.topCanvas=e.data.canvases[0],e.data.canvases[Ge.NODE].setAttribute("data-id","layer"+Ge.NODE+"-node"),e.data.canvases[Ge.SELECT_BOX].setAttribute("data-id","layer"+Ge.SELECT_BOX+"-selectbox"),e.data.canvases[Ge.DRAG].setAttribute("data-id","layer"+Ge.DRAG+"-drag"),e.data.canvases[Ge.WEBGL]&&e.data.canvases[Ge.WEBGL].setAttribute("data-id","layer"+Ge.WEBGL+"-webgl");for(var l=0;l<Ge.BUFFER_COUNT;l++)e.data.bufferCanvases[l]=a.createElement("canvas"),e.data.bufferContexts[l]=e.data.bufferCanvases[l].getContext("2d"),e.data.bufferCanvases[l].style.position="absolute",e.data.bufferCanvases[l].setAttribute("data-id","buffer"+l),e.data.bufferCanvases[l].style.zIndex=String(-l-1),e.data.bufferCanvases[l].style.visibility="hidden";e.pathsEnabled=!0;var c=Bt(),h=function(q){return{x:(q.x1+q.x2)/2,y:(q.y1+q.y2)/2}},d=function(q){return{x:-q.w/2,y:-q.h/2}},g=function(q){var K=q[0]._private,ee=K.oldBackgroundTimestamp===K.backgroundTimestamp;return!ee},m=function(q){return q[0]._private.nodeKey},p=function(q){return q[0]._private.labelStyleKey},y=function(q){return q[0]._private.sourceLabelStyleKey},b=function(q){return q[0]._private.targetLabelStyleKey},E=function(q,K,ee,ne,te){return e.drawElement(q,K,ee,!1,!1,te)},C=function(q,K,ee,ne,te){return e.drawElementText(q,K,ee,ne,"main",te)},A=function(q,K,ee,ne,te){return e.drawElementText(q,K,ee,ne,"source",te)},D=function(q,K,ee,ne,te){return e.drawElementText(q,K,ee,ne,"target",te)},N=function(q){return q.boundingBox(),q[0]._private.bodyBounds},O=function(q){return q.boundingBox(),q[0]._private.labelBounds.main||c},R=function(q){return q.boundingBox(),q[0]._private.labelBounds.source||c},P=function(q){return q.boundingBox(),q[0]._private.labelBounds.target||c},w=function(q,K){return K},x=function(q){return h(N(q))},T=function(q,K,ee){var ne=q?q+"-":"";return{x:K.x+ee.pstyle(ne+"text-margin-x").pfValue,y:K.y+ee.pstyle(ne+"text-margin-y").pfValue}},M=function(q,K,ee){var ne=q[0]._private.rscratch;return{x:ne[K],y:ne[ee]}},S=function(q){return T("",M(q,"labelX","labelY"),q)},I=function(q){return T("source",M(q,"sourceLabelX","sourceLabelY"),q)},B=function(q){return T("target",M(q,"targetLabelX","targetLabelY"),q)},V=function(q){return d(N(q))},F=function(q){return d(R(q))},k=function(q){return d(P(q))},U=function(q){var K=O(q),ee=d(O(q));if(q.isNode()){switch(wa(q.pstyle("text-halign").value)){case"left":ee.x=-K.w-(K.leftPad||0);break;case"right":ee.x=-(K.rightPad||0);break}switch(Ea(q.pstyle("text-valign").value)){case"top":ee.y=-K.h-(K.topPad||0);break;case"bottom":ee.y=-(K.botPad||0);break}}return ee},J=e.data.eleTxrCache=new qa(e,{getKey:m,doesEleInvalidateKey:g,drawElement:E,getBoundingBox:N,getRotationPoint:x,getRotationOffset:V,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),W=e.data.lblTxrCache=new qa(e,{getKey:p,drawElement:C,getBoundingBox:O,getRotationPoint:S,getRotationOffset:U,isVisible:w}),Q=e.data.slbTxrCache=new qa(e,{getKey:y,drawElement:A,getBoundingBox:R,getRotationPoint:I,getRotationOffset:F,isVisible:w}),Z=e.data.tlbTxrCache=new qa(e,{getKey:b,drawElement:D,getBoundingBox:P,getRotationPoint:B,getRotationOffset:k,isVisible:w}),H=e.data.lyrTxrCache=new xc(e);e.onUpdateEleCalcs(function(q,K){J.invalidateElements(K),W.invalidateElements(K),Q.invalidateElements(K),Z.invalidateElements(K),H.invalidateElements(K);for(var ee=0;ee<K.length;ee++){var ne=K[ee]._private;ne.oldBackgroundTimestamp=ne.backgroundTimestamp}});var j=function(q){for(var K=0;K<q.length;K++)H.enqueueElementRefinement(q[K].ele)};J.onDequeue(j),W.onDequeue(j),Q.onDequeue(j),Z.onDequeue(j),t.webgl&&e.initWebgl(t,{getStyleKey:m,getLabelKey:p,getSourceLabelKey:y,getTargetLabelKey:b,drawElement:E,drawLabel:C,drawSourceLabel:A,drawTargetLabel:D,getElementBox:N,getLabelBox:O,getSourceLabelBox:R,getTargetLabelBox:P,getElementRotationPoint:x,getElementRotationOffset:V,getLabelRotationPoint:S,getSourceLabelRotationPoint:I,getTargetLabelRotationPoint:B,getLabelRotationOffset:U,getSourceLabelRotationOffset:F,getTargetLabelRotationOffset:k})}Ge.redrawHint=function(t,e){var r=this;switch(t){case"eles":r.data.canvasNeedsRedraw[Ge.NODE]=e;break;case"drag":r.data.canvasNeedsRedraw[Ge.DRAG]=e;break;case"select":r.data.canvasNeedsRedraw[Ge.SELECT_BOX]=e;break;case"gc":r.data.gc=!0;break}};var I0=typeof Path2D<"u";Ge.path2dEnabled=function(t){if(t===void 0)return this.pathsEnabled;this.pathsEnabled=!!t};Ge.usePaths=function(){return I0&&this.pathsEnabled};Ge.setImgSmoothing=function(t,e){t.imageSmoothingEnabled!=null?t.imageSmoothingEnabled=e:(t.webkitImageSmoothingEnabled=e,t.mozImageSmoothingEnabled=e,t.msImageSmoothingEnabled=e)};Ge.getImgSmoothing=function(t){return t.imageSmoothingEnabled!=null?t.imageSmoothingEnabled:t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled};Ge.makeOffscreenCanvas=function(t,e){var r;if((typeof OffscreenCanvas>"u"?"undefined":mt(OffscreenCanvas))!=="undefined")r=new OffscreenCanvas(t,e);else{var a=this.cy.window(),n=a.document;r=n.createElement("canvas"),r.width=t,r.height=e}return r};[Tc,rr,fr,js,Qr,Rr,kt,Mc,Pr,gn,Ic].forEach(function(t){Re(Ge,t)});var B0=[{name:"null",impl:lc},{name:"base",impl:bc},{name:"canvas",impl:O0}],k0=[{type:"layout",extensions:im},{type:"renderer",extensions:B0}],kc={},Fc={};function zc(t,e,r){var a=r,n=function(N){Qe("Can not register `"+e+"` for `"+t+"` since `"+N+"` already exists in the prototype and can not be overridden")};if(t==="core"){if(tn.prototype[e])return n(e);tn.prototype[e]=r}else if(t==="collection"){if(St.prototype[e])return n(e);St.prototype[e]=r}else if(t==="layout"){for(var i=function(N){this.options=N,r.call(this,N),$e(this._private)||(this._private={}),this._private.cy=N.cy,this._private.listeners=[],this.createEmitter()},o=i.prototype=Object.create(r.prototype),s=[],u=0;u<s.length;u++){var l=s[u];o[l]=o[l]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var f=r.prototype.stop;o.stop=function(){var D=this.options;if(D&&D.animate){var N=this.animations;if(N)for(var O=0;O<N.length;O++)N[O].stop()}return f?f.call(this):this.emit("layoutstop"),this},o.destroy||(o.destroy=function(){return this}),o.cy=function(){return this._private.cy};var v=function(N){return N._private.cy},c={addEventFields:function(N,O){O.layout=N,O.cy=v(N),O.target=N},bubble:function(){return!0},parent:function(N){return v(N)}};Re(o,{createEmitter:function(){return this._private.emitter=new mi(c,this),this},emitter:function(){return this._private.emitter},on:function(N,O){return this.emitter().on(N,O),this},one:function(N,O){return this.emitter().one(N,O),this},once:function(N,O){return this.emitter().one(N,O),this},removeListener:function(N,O){return this.emitter().removeListener(N,O),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(N,O){return this.emitter().emit(N,O),this}}),Ze.eventAliasesOn(o),a=i}else if(t==="renderer"&&e!=="null"&&e!=="base"){var h=Vc("renderer","base"),d=h.prototype,g=r,m=r.prototype,p=function(){h.apply(this,arguments),g.apply(this,arguments)},y=p.prototype;for(var b in d){var E=d[b],C=m[b]!=null;if(C)return n(b);y[b]=E}for(var A in m)y[A]=m[A];d.clientFunctions.forEach(function(D){y[D]=y[D]||function(){nt("Renderer does not implement `renderer."+D+"()` on its prototype")}}),a=p}else if(t==="__proto__"||t==="constructor"||t==="prototype")return nt(t+" is an illegal type to be registered, possibly lead to prototype pollutions");return rv({map:kc,keys:[t,e],value:a})}function Vc(t,e){return av({map:kc,keys:[t,e]})}function F0(t,e,r,a,n){return rv({map:Fc,keys:[t,e,r,a],value:n})}function z0(t,e,r,a){return av({map:Fc,keys:[t,e,r,a]})}var Ls=function(){if(arguments.length===2)return Vc.apply(null,arguments);if(arguments.length===3)return zc.apply(null,arguments);if(arguments.length===4)return z0.apply(null,arguments);if(arguments.length===5)return F0.apply(null,arguments);nt("Invalid extension access syntax")};tn.prototype.extension=Ls;k0.forEach(function(t){t.extensions.forEach(function(e){zc(t.type,e.name,e.impl)})});var si=function(){if(!(this instanceof si))return new si;this.length=0},_r=si.prototype;_r.instanceString=function(){return"stylesheet"};_r.selector=function(t){var e=this.length++;return this[e]={selector:t,properties:[]},this};_r.css=function(t,e){var r=this.length-1;if(Le(t))this[r].properties.push({name:t,value:e});else if($e(t))for(var a=t,n=Object.keys(a),i=0;i<n.length;i++){var o=n[i],s=a[o];if(s!=null){var u=xt.properties[o]||xt.properties[li(o)];if(u!=null){var l=u.name,f=s;this[r].properties.push({name:l,value:f})}}}return this};_r.style=_r.css;_r.generateStyle=function(t){var e=new xt(t);return this.appendToStyle(e)};_r.appendToStyle=function(t){for(var e=0;e<this.length;e++){var r=this[e],a=r.selector,n=r.properties;t.selector(a);for(var i=0;i<n.length;i++){var o=n[i];t.css(o.name,o.value)}}return t};var V0="3.34.0",lr=function(e){if(e===void 0&&(e={}),$e(e))return new tn(e);if(Le(e))return Ls.apply(Ls,arguments)};lr.use=function(t){var e=Array.prototype.slice.call(arguments,1);return e.unshift(lr),t.apply(null,e),this};lr.warnings=function(t){return fv(t)};lr.version=V0;lr.stylesheet=lr.Stylesheet=si;var _c=oh(Gc(),1);var Ma={Entity:0,Service:1,Event:1,UseCase:2,Port:3,DTO:4,VO:4,Error:4,Shared:4,Adapter:5},qc={Entity:95,Service:72,Event:60,UseCase:48,Port:30,DTO:0,VO:0,Error:0,Shared:22,Adapter:18},Yc={Entity:"barrel",Service:"rectangle",UseCase:"round-rectangle",Port:"cut-rectangle",Event:"rhomboid",DTO:"round-rectangle",VO:"round-rectangle",Error:"round-rectangle",Shared:"round-rectangle",Adapter:"round-rectangle"},ol=["Entity","Service","UseCase","Port","Event"],sl=["DTO","VO","Error"],bn=42,Wc=338,G0=15;function Uc(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)|0;let r=Math.abs(e*.6180339887%1);return Math.round(bn+r*(Wc-bn))}var U0=(t,e)=>{let r=Math.abs(t-e)%360;return Math.min(r,360-r)};function Xc(t){let e=[...new Set(t)].filter(i=>!La(i)).sort(),r=[],a=new Map,n=Wc-bn;for(let i of e){let o=Uc(i),s=o;for(let u=0;u<n;u++){let l=bn+(o-bn+u)%n;if(r.every(f=>U0(f,l)>=G0)){s=l;break}}r.push(s),a.set(i,s)}return i=>La(i)?0:a.get(i)??Uc(i)}var La=t=>t==="common"||t==="shared",Di=190,H0=40,q0=230,Y0=268,W0=130,Hc=34,X0=30;function $0(t){let e=new Map;for(let o of t){let s=Ma[o.component];e.set(s,[...e.get(s)??[],o])}let r=new Map,a=0;for(let o of[...e.keys()].sort((s,u)=>s-u)){let s=e.get(o),u=s.length*Y0/(2*Math.PI),l=o===0&&s.length===1?0:Math.max(a+q0,u,170);s.forEach((f,v)=>{if(l===0)r.set(f.id,[0,0]);else{let c=2*Math.PI*v/s.length-Math.PI/2;r.set(f.id,[l*Math.cos(c),l*Math.sin(c)])}}),a=l}let n=0,i=0;for(let[o,s]of r.values())n=Math.max(n,Math.abs(o)),i=Math.max(i,Math.abs(s));return{pos:r,hw:n+Di/2+Hc,hh:i+H0/2+Hc+X0/2}}function K0(t,e,r=W0){let a=new Map(t.nodes.map(c=>[c.id,c])),n=new Map;for(let c of t.edges){let h=a.get(c.src)?.domain,d=a.get(c.dst)?.domain;if(!h||!d||h===d)continue;let g=h<d?`${h}|${d}`:`${d}|${h}`;n.set(g,(n.get(g)??0)+1)}let i=c=>e.get(c)??{hw:0,hh:0},o=c=>i(c).hw*i(c).hh,s=[...e.keys()].sort((c,h)=>o(h)-o(c)),u=new Map,l=0,f=0;s.forEach((c,h)=>{if(h===0){u.set(c,[0,0]);return}l+=Math.hypot(i(c).hw,i(c).hh)*.95,f+=2.399963,u.set(c,[l*Math.cos(f),l*Math.sin(f)])});let v=c=>{let h=0;for(let d=0;d<s.length;d++){let g=s[d];for(let m=d+1;m<s.length;m++){let p=s[m],y=u.get(g),b=u.get(p),E=b[0]-y[0],C=b[1]-y[1],A=i(g).hw+i(p).hw+r-Math.abs(E),D=i(g).hh+i(p).hh+r-Math.abs(C);if(A<=0||D<=0)continue;h=Math.max(h,Math.min(A,D));let N=Math.min(A,D)*c;if(A<D){let O=E>=0?1:-1;y[0]-=O*N,b[0]+=O*N}else{let O=C>=0?1:-1;y[1]-=O*N,b[1]+=O*N}}}return h};for(let c=0;c<400;c++){for(let h=0;h<s.length;h++){let d=s[h];for(let g=h+1;g<s.length;g++){let m=s[g],p=n.get(d<m?`${d}|${m}`:`${m}|${d}`)??0,y=u.get(d),b=u.get(m),E=b[0]-y[0],C=b[1]-y[1],A=Math.hypot(E,C)||1,D=i(d).hw+i(m).hw+r-Math.abs(E),N=i(d).hh+i(m).hh+r-Math.abs(C);if(D>0&&N>0)continue;let O=-Math.min(D,N),R=Math.min(O*(p?.06*Math.log1p(p):.006),90);u.set(d,[y[0]+E/A*R,y[1]+C/A*R]),u.set(m,[b[0]-E/A*R,b[1]-C/A*R])}}v(.5);for(let h of s){let d=u.get(h);d[0]-=d[0]*.004,d[1]-=d[1]*.004}}for(let c=0;c<600&&v(.5)>.5;c++);return u}function ll(t){let e=new Map;for(let o of t.nodes)e.set(o.domain,[...e.get(o.domain)??[],o]);let r=new Map,a=new Map;for(let[o,s]of e){let u=$0(s);r.set(o,u.pos),a.set(o,{hw:u.hw,hh:u.hh})}let n=K0(t,a),i=[];for(let[o,s]of r){let[u,l]=n.get(o)??[0,0];for(let[f,[v,c]]of s)i.push({id:f,x:Math.round(u+v),y:Math.round(l+c)})}return i}var _0=Di+54,Z0=74;function Q0(t,e){let r=[...e].sort((i,o)=>Ma[i.component]-Ma[o.component]||i.name.localeCompare(o.name)),a=Math.max(1,Math.min(5,Math.ceil(Math.sqrt(r.length/2.2)))),n=Math.ceil(r.length/a);return{d:t,items:r,cols:a,w:a*_0+80,h:n*Z0+92}}function $c(t,e=3e3){let r=new Map;for(let l of t.nodes)r.set(l.domain,[...r.get(l.domain)??[],l]);let a=[...r.entries()].map(([l,f])=>Q0(l,f)).sort((l,f)=>f.items.length-l.items.length),n=e,i=[],o=0,s=0,u=0;for(let l of a)s+l.w>n&&s>0&&(o+=u+90,s=0,u=0),l.items.forEach((f,v)=>{i.push({id:f.id,x:Math.round(s+40+v%l.cols*(Di+54)+Di/2),y:Math.round(o+52+Math.floor(v/l.cols)*74)})}),s+=l.w+70,u=Math.max(u,l.h);return i}lr.use(_c.default);var vr=(t,e,r)=>`hsl(${t},${e}%,${r}%)`,He=t=>document.getElementById(t),ea=t=>Array.from(document.querySelectorAll(t)),Ue,wt,pl,Li="hex",Or=!1,jr=!1,Ai,ta=null,Jr="both",Kc,Ni,wn=()=>0;async function J0(){wt=await(await fetch("/api/graph")).json();let t=[...new Set(wt.nodes.map(a=>a.domain))];wn=Xc(t);let e=[...new Set(wt.nodes.map(a=>a.component))].sort((a,n)=>Ma[a]-Ma[n]);pl={hex:new Map(ll(wt).map(a=>[a.id,{x:a.x,y:a.y}])),grid:new Map($c(wt).map(a=>[a.id,{x:a.x,y:a.y}]))},document.title=`${wt.project} \u2014 hexwright`,He("title").textContent=wt.project,He("ref").textContent=wt.ref;let r={added:wt.nodes.filter(a=>a.status==="added").length,modified:wt.nodes.filter(a=>a.status==="modified").length,addedEdges:wt.edges.filter(a=>a.status==="added").length};(r.added||r.modified)&&(He("delta").innerHTML=`<span class="k"></span>added ${r.added} nodes \xB7 ${r.addedEdges} edges<br><span class="k2"></span>modified ${r.modified} nodes`,He("deltaBox").style.display="block"),j0(t,e),tb(),cl("bhex"),gl("core")}function j0(t,e){let r=new Map;for(let a of wt.nodes)r.set(`c:${a.component}`,(r.get(`c:${a.component}`)??0)+1),r.set(`d:${a.domain}`,(r.get(`d:${a.domain}`)??0)+1);He("comps").innerHTML=e.map(a=>`<label><span class="sw" style="${eb(a)}"></span><input type=checkbox class=cf value="${a}" ${ol.includes(a)?"checked":""}>${a}<span class="n">${r.get(`c:${a}`)??0}</span></label>`).join(""),He("doms").innerHTML=t.sort((a,n)=>(r.get(`d:${n}`)??0)-(r.get(`d:${a}`)??0)).map(a=>{let n=wn(a);return`<label><span class="sw" style="background:${vr(n,La(a)?0:60,50)}"></span><input type=checkbox class=df value="${a}" checked>${a}<span class="n">${r.get(`d:${a}`)??0}</span></label>`}).join("");for(let a of ea(".cf,.df,.rf"))a.onchange=()=>Ir();He("showId").onchange=()=>Ir(),He("crossOnly").onchange=()=>Ir(),He("deltaOnly").onchange=()=>Ir()}function eb(t){let e="#8b949e";return sl.includes(t)?`border:1.4px dashed ${e};border-radius:5px`:`background:${e};${{Entity:"border-radius:6px/50%",Service:"border-radius:0",Port:"clip-path:polygon(22% 0,100% 0,100% 78%,78% 100%,0 100%,0 22%)",Event:"transform:skewX(-16deg)"}[t]??"border-radius:5px"}`}function tb(){let t=[...new Set(wt.nodes.map(n=>n.domain))].map(n=>({data:{id:`dom::${n}`,label:n,kind:"domain",hue:wn(n),sat:La(n)?0:26}})),e=wt.nodes.map(n=>({data:{...n,parent:`dom::${n.domain}`,kind:"type",hue:wn(n.domain),sat:La(n.domain)?0:qc[n.component],shape:Yc[n.component],outline:sl.includes(n.component),label:n.name},position:{...pl.hex.get(n.id)??{x:0,y:0}}})),r=wt.edges.map((n,i)=>({data:{...n,id:`e${i}`,source:n.src,target:n.dst,hue:wn(vl(n.src)?.domain??"")}}));Ue=lr({container:He("cy"),elements:[...t,...e,...r],layout:{name:"preset"},minZoom:.05,maxZoom:3,wheelSensitivity:.25,style:[{selector:'node[kind="domain"]',style:{"background-color":n=>vr(n.data("hue"),n.data("sat"),13),"background-opacity":.5,"border-width":1.5,"border-color":n=>vr(n.data("hue"),n.data("sat")+19,42),shape:"round-rectangle",label:"data(label)","text-valign":"top","font-size":21,"font-weight":"bold",color:n=>vr(n.data("hue"),n.data("sat")+29,62),"text-margin-y":-7,padding:"16px"}},{selector:'node[kind="type"]',style:{shape:"data(shape)",width:"182px",height:"32px","background-color":n=>vr(n.data("hue"),n.data("sat"),46-n.data("sat")*.07),"background-opacity":n=>n.data("outline")?0:1,label:"data(label)","font-size":11,"text-valign":"center","text-wrap":"ellipsis","text-max-width":"160px",color:n=>n.data("outline")?vr(n.data("hue"),n.data("hue")?52:0,72):"#fff","border-width":n=>n.data("outline")?1.4:1,"border-color":n=>vr(n.data("hue"),n.data("outline")?48:n.data("sat"),n.data("outline")?52:70),"border-style":n=>n.data("outline")?"dashed":"solid"}},{selector:'node[component="Entity"]',style:{"border-width":2.6,width:"190px",height:"36px","font-weight":"bold","font-size":12}},{selector:'node[component="Service"]',style:{"border-width":1.8}},{selector:"edge",style:{width:1.9,"line-color":n=>vr(n.data("hue"),n.data("crossDomain")?62:22,n.data("crossDomain")?58:46),opacity:n=>n.data("crossDomain")?.8:.62,"target-arrow-color":n=>vr(n.data("hue"),n.data("crossDomain")?62:22,n.data("crossDomain")?58:46)}},{selector:'edge[rel="DEPENDS_ON"]',style:{"line-style":"solid","curve-style":"straight","target-arrow-shape":"vee","arrow-scale":.95}},{selector:'edge[rel="REFERENCES"]',style:{"line-style":"dashed","line-dash-pattern":[2,4],width:1.4,"curve-style":"unbundled-bezier","control-point-distances":[24],"control-point-weights":[.5],"target-arrow-shape":"vee","arrow-scale":.9}},{selector:'edge[rel="IMPLEMENTS"]',style:{"line-style":"dashed","line-dash-pattern":[9,5],width:2.2,"curve-style":"unbundled-bezier","control-point-distances":[42],"control-point-weights":[.5],"target-arrow-shape":"triangle","target-arrow-fill":"hollow","arrow-scale":1.35}},{selector:'edge[rel="EXTENDS"]',style:{"line-style":"dashed","line-dash-pattern":[3,3],width:3.4,"curve-style":"unbundled-bezier","control-point-distances":[58],"control-point-weights":[.5],"target-arrow-shape":"triangle","target-arrow-fill":"hollow","arrow-scale":1.6}},{selector:"edge[?identifierOnly]",style:{"line-style":"dotted",opacity:.4}},{selector:'edge[violation != ""]',style:{"line-color":"#f85149","target-arrow-color":"#f85149",width:3.4,opacity:1,"z-index":90,label:"data(violation)","font-size":10,color:"#f85149","text-background-color":"#0e1116","text-background-opacity":.85,"text-background-padding":"3px"}},{selector:'edge[status="added"]',style:{opacity:1,"line-color":"#f0883e","target-arrow-color":"#f0883e","z-index":80}},{selector:".dim",style:{opacity:.035,"text-opacity":0}},{selector:".nb",style:{"border-width":2.4,"border-color":"#58a6ff","z-index":50}},{selector:".hi",style:{"border-width":5,"border-color":"#58a6ff","z-index":100}},{selector:"edge.sel",style:{width:5,opacity:1,"line-color":"#58a6ff","target-arrow-color":"#58a6ff","z-index":99}}]}),window.cy=Ue,new ResizeObserver(()=>{Ue.resize();let n=Ue.nodes('[kind="type"]').filter(i=>i.style("display")==="element");n.length&&Ue.fit(n,40)}).observe(He("cy")),Ue.on("tap",'node[kind="type"]',n=>dl(n.target)),Ue.on("tap","edge",n=>sb(n.target)),Ue.on("tap",n=>{let i=n.target;(n.target===Ue||i.data?.("kind")==="domain")&&hl()}),document.addEventListener("keydown",n=>{n.key==="Escape"&&hl()})}var vl=t=>wt.nodes.find(e=>e.id===t);function Ir(){let t=new Set(ea(".cf:checked").map(u=>u.value)),e=new Set(ea(".df:checked").map(u=>u.value)),r=new Set(ea(".rf:checked").map(u=>u.value)),a=He("showId").checked,n=He("crossOnly").checked,i=He("deltaOnly").checked,o=new Set;if(jr)for(let u of Ue.edges())u.data("violation")&&(o.add(u.data("source")),o.add(u.data("target")));Ue.batch(()=>{for(let l of Ue.nodes('[kind="type"]')){let f=l.data(),v=t.has(f.component)&&e.has(f.domain);v&&i&&f.status==="existing"&&(v=!1),v&&jr&&!o.has(f.id)&&(v=!1),l.style("display",v?"element":"none")}let u=l=>l.style("display")==="element";for(let l of Ue.nodes('[kind="domain"]'))l.style("display",l.children().filter(f=>u(f)).length?"element":"none");for(let l of Ue.edges()){let f=u(l.source())&&u(l.target())&&r.has(l.data("rel"));f&&!a&&l.data("identifierOnly")&&(f=!1),f&&n&&!l.data("crossDomain")&&(f=!1),f&&jr&&!l.data("violation")&&(f=!1),l.style("display",f?"element":"none")}}),rb(),Ue.nodes('[kind="type"]').filter(u=>u.style("display")==="element").length&&ab()}function rb(){let t=n=>n.style("display")==="element",e=Ue.nodes('[kind="type"]').filter(n=>t(n)).length,r=Ue.edges().filter(n=>t(n)).length,a=Ue.edges().filter(n=>t(n)&&n.data("violation")).length;He("stat").innerHTML=`Nodes <b>${e}</b>/${Ue.nodes('[kind="type"]').length} \xB7 Edges <b>${r}</b>/${Ue.edges().length}`,He("cviol").textContent=String(a);for(let n of["DEPENDS_ON","REFERENCES","IMPLEMENTS","EXTENDS"]){let i=document.getElementById(`c${n}`);i&&(i.textContent=String(Ue.edges(`[rel="${n}"]`).filter(o=>t(o)).length))}}function ab(){clearTimeout(Kc),Kc=setTimeout(Mi,110)}function Mi(){Ni?.stop(),Ni=void 0,Or?Li==="hex"?nb():ob():ib()}var ul=t=>t.style("display")==="element";function nb(){let t=new Set(Ue.nodes('[kind="type"]').filter(i=>ul(i)).map(i=>i.id())),e=new Set(Ue.edges().filter(i=>ul(i)).map(i=>i.id())),r={...wt,nodes:wt.nodes.filter(i=>t.has(i.id)),edges:wt.edges.filter((i,o)=>e.has(`e${o}`))},a=new Map(ll(r).map(i=>[i.id,i]));Ue.batch(()=>{for(let i of Ue.nodes('[kind="type"]')){let o=a.get(i.id());o&&i.position({x:o.x,y:o.y})}});let n=Ue.nodes('[kind="type"]').filter(i=>ul(i));n.length&&Ue.fit(n,40)}function ib(){let t=pl[Li];Ue.batch(()=>{for(let r of Ue.nodes('[kind="type"]')){let a=t.get(r.id());a&&r.position({x:a.x,y:a.y})}});let e=Ue.nodes('[kind="type"]').filter(r=>r.style("display")==="element");e.length&&Ue.fit(e,40)}function ob(){let t=Ue.elements().filter(r=>r.style("display")==="element"),e=t.nodes().length;e&&(Ni=t.layout({name:"fcose",quality:e<=150?"proof":e<=400?"default":"draft",numIter:e<=150?1600:e<=400?900:500,randomize:e<=150,animate:e<=250,animationDuration:400,nodeSeparation:210,idealEdgeLength:r=>r.data("crossDomain")?300:130,nodeRepulsion:34e3,gravity:.12,gravityCompound:.9,gravityRangeCompound:2.2,packComponents:!0,tile:!0,nodeDimensionsIncludeLabels:!0,stop:()=>Ue.fit(t.nodes(),60)}),Ni.run())}var cl=t=>{for(let e of["bhex","bgrid"])He(e).classList.toggle("on",e===t)};function hl(){Ue.elements().removeClass("hi dim sel nb"),He("info").style.display="none",ta=null,Jr="both"}var Vt=(t,e)=>`<tr><td>${t}</td><td>${e}</td></tr>`,fl=t=>t?'<span style="color:#f0883e">yes</span>':"no",Zc=t=>t==="added"?'<span style="color:#f0883e">added</span>':t==="modified"?'<span style="color:#a371f7">modified</span>':"existing";function dl(t){ta=t.id();let e=t.data(),r=c=>c.style("display")==="element",a=t.connectedEdges().filter(c=>r(c)),n=a.filter(c=>c.target().id()===ta),i=a.filter(c=>c.source().id()===ta),o=Jr==="in"?n:Jr==="out"?i:a,s=o.connectedNodes().difference(t);Ue.elements().removeClass("hi dim sel nb").addClass("dim"),t.removeClass("dim").addClass("hi"),s.removeClass("dim").addClass("nb"),o.removeClass("dim").addClass("sel"),s.parent().removeClass("dim"),t.parent().removeClass("dim");let u=(c,h,d)=>`<button class="dirb ${Jr===c?"on":""}" data-dir="${c}">${h} ${d}</button>`,l=(c,h,d)=>{let g=d.data();return`<div class="lk" data-goto="${g.id}"><span class="ar">${h}</span>${g.name}<span class="mut"> ${g.domain}\xB7${g.component}</span><span class="rel">${c.data("rel")==="DEPENDS_ON"?"":c.data("rel")}</span></div>`},f="";if(Jr!=="out")for(let c of n)f+=l(c,"\u2190",c.source());if(Jr!=="in")for(let c of i)f+=l(c,"\u2192",c.target());let v=e.api.length||e.props.length?`<div class="dirbar" style="display:block"><b>Public contract</b><span class="mut"> ${e.api.length} fn${e.props.length?` \xB7 ${e.props.length} prop`:""}</span></div><div class="lks">${e.api.map(c=>{let h=c.indexOf("(");return`<div class="lk"><span class="sig"><b>${c.slice(0,h)}</b>${c.slice(h)}</span></div>`}).join("")}${e.props.map(c=>`<div class="lk"><span class="sig" style="color:#6e7681">${c}</span></div>`).join("")}</div>`:"";He("info").style.display="block",He("info").innerHTML=`<div class="ih">${e.name}<span class="x">\xD7</span></div><table>${Vt("Domain",e.domain)}${Vt("Component",`${e.component} <span class="mut">${e.layer}${e.sublayer?`/${e.sublayer}`:""}</span>`)}${Vt("Kind",e.kind)}${Vt("Status",Zc(e.status))}${Vt("File",`<span class="mut">${e.file}:${e.line}</span>`)}${Vt("Id",`<span class="mut" style="word-break:break-all">${e.id}</span>`)}</table>${v}<div class="dirbar">${u("both","Both",a.length)}${u("in","\u2190 In",n.length)}${u("out","Out \u2192",i.length)}</div><div class="lks">${f||'<span class="mut">No visible connections</span>'}</div><div class="hint">Click an item to focus it \xB7 Esc to clear</div>`,Qc()}function sb(t){ta=null;let e=t.data(),r=vl(e.src),a=vl(e.dst);Ue.elements().removeClass("hi dim sel nb").addClass("dim"),t.removeClass("dim").addClass("sel"),t.connectedNodes().removeClass("dim").addClass("nb").parent().removeClass("dim");let n=e.contracts.length?`<div class="dirbar" style="display:block"><b>Contracts used</b><span class="mut"> ${e.contracts.length}/${a?.api.length??0}</span></div><div class="lks">${e.contracts.map(i=>{let o=i.indexOf("(");return`<div class="lk"><span class="sig"><b>${o>0?i.slice(0,o):i}</b>${o>0?i.slice(o):""}</span></div>`}).join("")}</div>`:'<div class="hint">No method calls \u2014 type reference only</div>';He("info").style.display="block",He("info").innerHTML=`<div class="ih">${e.rel}<span class="x">\xD7</span></div><table>${Vt("Source",`${r?.name} <span class="mut">${r?.domain}\xB7${r?.component}</span>`)}${Vt("Target",`${a?.name} <span class="mut">${a?.domain}\xB7${a?.component}</span>`)}${e.rel==="DEPENDS_ON"?Vt("Weight",`${e.weight} <span class="mut">occurrences</span>`):""}${Vt("Cross-domain",fl(e.crossDomain))}${Vt("Identifier only",fl(e.identifierOnly))}${Vt("Via signature",fl(e.viaSignature))}${e.violation?Vt("Violation",`<span style="color:#f85149">${e.violation}</span>`):""}${Vt("Status",Zc(e.status))}</table>${n}`,Qc()}function Qc(){let t=He("info").querySelector(".x");t&&(t.onclick=()=>hl());for(let e of Array.from(He("info").querySelectorAll(".dirb")))e.onclick=()=>{Jr=e.dataset.dir,ta&&dl(Ue.getElementById(ta))};for(let e of Array.from(He("info").querySelectorAll("[data-goto]")))e.onclick=()=>dl(Ue.getElementById(e.dataset.goto))}function gl(t){for(let e of ea(".cf"))e.checked=t==="core"?ol.includes(e.value):!0;for(let e of["pcore","pall"])He(e).classList.toggle("on",e===`p${t}`);Ir()}function lb(){He("pcore").onclick=()=>gl("core"),He("pall").onclick=()=>gl("all"),He("bhex").onclick=()=>{Li="hex",cl("bhex"),Mi()},He("bgrid").onclick=()=>{Li="grid",cl("bgrid"),Mi()},He("borg").onclick=()=>{Or=!Or,He("borg").classList.toggle("on",Or),Mi()},He("bviol").onclick=()=>{jr=!jr,He("bviol").classList.toggle("on",jr),jr?(Ai=Or,Or=!0):Ai!==void 0&&(Or=Ai,Ai=void 0),He("borg").classList.toggle("on",Or),Ir()},He("allDomOn").onclick=()=>{for(let t of ea(".df"))t.checked=!0;Ir()},He("allDomOff").onclick=()=>{for(let t of ea(".df"))t.checked=!1;Ir()},J0()}lb();})();
322
322
  /*! Bundled license information:
323
323
 
324
324
  cytoscape/dist/cytoscape.esm.mjs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexwright",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Design graph for hexagonal-architecture codebases. Renders what a branch changed as one picture a human can confirm at a glance, and gives a coding agent boundary verdicts it can run on itself before asking for review.",
5
5
  "keywords": [
6
6
  "hexagonal-architecture",
@@ -14,6 +14,18 @@ domain:
14
14
  # which segment is the domain (0-based, after the prefix is stripped)
15
15
  at: 0
16
16
 
17
+ # How an identifier is tied to the aggregate it identifies, so that a type holding
18
+ # another aggregate's id is drawn as REFERENCES rather than as a dependency on the
19
+ # id. Remove this block and no identifier is resolved.
20
+ identity:
21
+ # property = the type declaring this property owns the identifier. Structural, and
22
+ # it survives an aggregate whose name is not the identifier's stem — MediaId
23
+ # identifies MediaItem, not Media.
24
+ # suffix = strip the suffix from the identifier's name and look for that type.
25
+ # Simpler, but resolves nothing the moment the two names diverge.
26
+ from: property
27
+ property: id
28
+
17
29
  # Path fragments to exclude from analysis
18
30
  exclude:
19
31
  - /config/