diff --git a/docs/Organisation-Konzept.md b/docs/Organisation-Konzept.md index e3c9ce7..8400c21 100644 --- a/docs/Organisation-Konzept.md +++ b/docs/Organisation-Konzept.md @@ -1239,9 +1239,17 @@ der richtige Handgriff meist schon da. Ereignistypen mit Absender und Empfänger: Delegation, Task-Zuweisung, später Besprechung und Eskalation, jeweils mit eigener Linienart. Das Verblassen nach einigen Sekunden geschieht im Browser. -- **Bibliothek:** Cytoscape.js mit ELK-Layout. Es kann verschachtelte Container und - hierarchisches Layout und bleibt bei Hunderten Nodes flüssig, ohne React. Als Datei im - `wwwroot`, nicht über ein CDN. +- **Bibliothek:** ELK (elkjs) für das Layout, die Karten als HTML, die Linien als SVG. + Als Datei im `wwwroot`, nicht über ein CDN. Stufe 0 und 1 zeichneten mit Cytoscape.js + auf einer Canvas. Das wurde am 2026-09-24 ersetzt: Ein Canvas-Knoten kann keine + Agentenliste, keine Suchhervorhebung und nicht den Hausstil tragen. +- **Gestalt (Rückmeldung 2026-09-24):** Jede Einheit bleibt immer als Karte sichtbar, + verbunden als Baum. Zugeklappt wird nur die Agentenliste einer großen Einheit; sie + zeigt dann, wer Aufmerksamkeit braucht, und „+n weitere". Eine Linie trägt die Farbe + des dringlichsten Zustands darunter, eine rote Linie führt also von oben zum Problem. + Ohne Durchklicken durch zehn Ebenen. Links ein Strukturbaum mit Suche und Zustandsfilter, + der die Wege zu den Treffern zeigt und den Rest abblendet. Hausstil bleibt: Radius 0, + App-Akzent. - **Nur in der WebUI.** Ein zweiter Graph-Renderer in Avalonia wäre doppelte Arbeit, die auseinanderläuft. Der Desktop bettet die Ansicht ein oder verlinkt sie. - Englisch, Texte über Sprachpakete (#661). diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/app.css b/src/ClawdDotNet.Manager.Web/wwwroot/app.css index 820f13f..6792417 100644 --- a/src/ClawdDotNet.Manager.Web/wwwroot/app.css +++ b/src/ClawdDotNet.Manager.Web/wwwroot/app.css @@ -1722,7 +1722,9 @@ td.klein { font-size: 12px; } -/* ─── Team overview (#711) ─── */ +/* ─── Team overview (#711) ─── + A work surface in the blueprint style: dot grid, cards with a head, state stripes, + square ports on the lines, floating bars. Square like everything else. */ .team-ansicht { display: flex; @@ -1731,45 +1733,474 @@ td.klein { height: 100%; } +.team-kopf { + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: 16px; + flex-wrap: wrap; +} + +.team-kopf h1 { margin: 0; } +.team-kopf p { margin: 4px 0 0; max-width: 72ch; } + .team-zusammenfassung { flex-wrap: wrap; min-height: 24px; } -.team-flaeche { - display: flex; - gap: 12px; - flex: 1; - min-height: 420px; +/* Tones: every state has a colour, shared by markers, chips, lines and cards. */ +.ton-neutral { --ton: var(--gedaempft); } +.ton-aktiv { --ton: var(--accent); } +.ton-warnung { --ton: var(--warnung); } +.ton-gefahr { --ton: var(--gefahr); } + +.team-marker { + color: var(--ton, var(--gedaempft)); + font-size: 12px; + text-align: center; } -.team-graph { +.team-arbeitsflaeche { + flex: none; + /* A fixed height: the tree and the panel scroll inside it, the page does not grow. */ + height: max(520px, calc(100vh - 250px)); + display: grid; + grid-template-columns: 264px minmax(0, 1fr) auto; + grid-template-rows: minmax(0, 1fr); + border: 1px solid var(--divider); + background: var(--surface); +} + +/* The tree on the left */ + +.team-baum { + display: flex; + flex-direction: column; + min-height: 0; + border-right: 1px solid var(--divider); + background: var(--surface); +} + +.team-baum-kopf { + display: flex; + flex-direction: column; + gap: 8px; + padding: 12px; + border-bottom: 1px solid var(--divider); +} + +.team-baum-titel { + font-family: var(--schrift-titel); + font-size: 13px; + font-weight: 600; + letter-spacing: 0.12em; + text-transform: uppercase; + color: var(--gedaempft); +} + +.team-suche { + width: 100%; + padding: 7px 10px; +} + +.team-filter { + display: flex; + flex-wrap: wrap; + gap: 4px; +} + +.team-filter button { + padding: 2px 8px; + font-size: 12px; + background: transparent; + color: var(--gedaempft); +} + +.team-filter button[aria-pressed="true"] { + background: var(--accent); + border-color: var(--accent); + color: #fff; +} + +.team-treffer-info { + min-height: 16px; + font-size: 12px; + color: var(--gedaempft); +} + +.team-baum-liste { + flex: 1; + overflow: auto; + padding: 6px 0; +} + +.team-baum-liste ul { + list-style: none; + margin: 0; + padding: 0; +} + +.team-baum-eintrag { + display: flex; + justify-content: flex-start; + align-items: center; + gap: 6px; + width: 100%; + padding: 4px 10px 4px calc(8px + var(--tiefe, 0) * 14px); + background: transparent; + border: 0; + font-size: 13px; + text-align: left; +} + +.team-baum-eintrag.ausgewaehlt { + background: color-mix(in srgb, var(--accent) 18%, transparent); + box-shadow: inset 2px 0 0 var(--accent); +} + +.team-baum-eintrag.treffer .team-baum-name { + color: var(--accent); + font-weight: 600; +} + +.team-baum-eintrag.gedimmt { opacity: 0.45; } + +.team-pfeil { + flex: none; + width: 14px; + font-size: 10px; + color: var(--gedaempft); +} + +.team-baum-name { flex: 1; min-width: 0; - min-height: 420px; - background: var(--surface-subtil); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.team-zahl { + flex: none; + font-size: 11px; + color: var(--gedaempft); + font-variant-numeric: tabular-nums; +} + +.team-zahl.ton-aktiv, +.team-zahl.ton-warnung, +.team-zahl.ton-gefahr { color: var(--ton); } + +/* The canvas */ + +.team-leinwand { + position: relative; + overflow: hidden; + min-width: 0; + cursor: grab; + touch-action: none; + user-select: none; + background-color: var(--bg); + background-image: radial-gradient(circle, var(--divider) 1px, transparent 1.3px); + background-size: 20px 20px; +} + +.team-leinwand.zieht { cursor: grabbing; } + +.team-welt { + position: absolute; + left: 0; + top: 0; + transform-origin: 0 0; +} + +.team-welt.gleitend { transition: transform 0.35s ease; } + +.team-kanten, +.team-links { + position: absolute; + left: 0; + top: 0; + overflow: visible; + pointer-events: none; +} + +.team-links { z-index: 1; } + +.team-kante { + fill: none; + stroke: color-mix(in srgb, var(--ton) 55%, var(--divider)); + stroke-width: 1.5; +} + +.team-kante.ton-gefahr, +.team-kante.ton-warnung { + stroke: var(--ton); + stroke-width: 2; +} + +.team-kante.ton-gefahr { + filter: drop-shadow(0 0 4px color-mix(in srgb, var(--gefahr) 70%, transparent)); +} + +.team-port { + fill: var(--bg); + stroke: color-mix(in srgb, var(--ton) 70%, var(--divider)); + stroke-width: 1.5; +} + +.team-port.ton-gefahr, +.team-port.ton-warnung { fill: var(--ton); stroke: var(--ton); } + +.team-kante.gedimmt, +.team-port.gedimmt { opacity: 0.2; } + +.team-link { + fill: none; + stroke: var(--accent); + stroke-width: 2; + stroke-dasharray: 6 5; + animation: team-fluss 0.9s linear infinite; +} + +.team-pfeilspitze { fill: var(--accent); } + +@keyframes team-fluss { + to { stroke-dashoffset: -11; } +} + +.team-link-zahl { + font-family: var(--schrift-text); + font-size: 12px; + font-weight: 600; + fill: var(--text); + paint-order: stroke; + stroke: var(--bg); + stroke-width: 4px; +} + +/* Cards */ + +.team-karte { + position: absolute; + left: 0; + top: 0; + background: var(--surface); + border: 1px solid var(--divider); + border-left: 3px solid var(--ton, var(--divider)); + box-shadow: 0 12px 28px -16px rgba(0, 0, 0, 0.55); + transition: opacity 0.2s ease, box-shadow 0.2s ease; +} + +.team-karte.ton-neutral { border-left-color: var(--divider); } + +.team-karte.ton-gefahr { + border-color: color-mix(in srgb, var(--gefahr) 60%, var(--divider)); + border-left-color: var(--gefahr); + box-shadow: + 0 0 0 1px color-mix(in srgb, var(--gefahr) 35%, transparent), + 0 0 26px -6px color-mix(in srgb, var(--gefahr) 60%, transparent); +} + +.team-karte.ton-warnung { + border-color: color-mix(in srgb, var(--warnung) 45%, var(--divider)); + border-left-color: var(--warnung); +} + +.team-karte.wurzel .team-karte-kopf { + background: color-mix(in srgb, var(--accent) 12%, var(--surface)); +} + +.team-karte.ausgewaehlt, +.team-karte.treffer { + outline: 2px solid var(--accent); + outline-offset: 3px; +} + +.team-karte.gedimmt { opacity: 0.3; } + +.team-karte-kopf { + display: block; + width: 100%; + padding: 10px 12px 9px; + background: transparent; + border: 0; + border-bottom: 1px solid var(--divider); + text-align: left; +} + +.team-karte-titel { + display: flex; + align-items: baseline; + gap: 8px; + font-family: var(--schrift-titel); + font-size: 17px; + font-weight: 600; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +.team-karte-name { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.team-karte-unter { + margin-top: 2px; + font-size: 12px; + color: var(--gedaempft); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.team-chips { + display: flex; + flex-wrap: wrap; + gap: 4px; + margin-top: 8px; +} + +.team-chip { + padding: 1px 6px; + font-size: 11px; + font-variant-numeric: tabular-nums; + color: var(--gedaempft); border: 1px solid var(--divider); } +.team-chip.ton-aktiv, +.team-chip.ton-warnung, +.team-chip.ton-gefahr { + color: var(--ton); + border-color: color-mix(in srgb, var(--ton) 55%, transparent); + background: color-mix(in srgb, var(--ton) 12%, transparent); +} + +.team-karte-liste { padding: 4px 0; } + +.team-zeile { + display: grid; + grid-template-columns: 16px minmax(0, 1fr) auto; + gap: 8px; + align-items: center; + width: 100%; + padding: 5px 12px; + background: transparent; + border: 0; + font-size: 13px; + text-align: left; +} + +.team-zeile.ausgewaehlt { background: color-mix(in srgb, var(--accent) 16%, transparent); } +.team-zeile.treffer { box-shadow: inset 2px 0 0 var(--accent); } +.team-zeile.gedimmt { opacity: 0.4; } +.team-zeile.blinkt { animation: team-blinkt 1.4s ease; } + +@keyframes team-blinkt { + 0%, 55% { background: color-mix(in srgb, var(--accent) 35%, transparent); } + 100% { background: transparent; } +} + +.team-zeile-name { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.team-zeile-zustand { + font-size: 11px; + color: var(--gedaempft); +} + +.team-zeile.ton-aktiv .team-zeile-zustand, +.team-zeile.ton-warnung .team-zeile-zustand, +.team-zeile.ton-gefahr .team-zeile-zustand { color: var(--ton); } + +.team-mehr { + display: block; + width: 100%; + padding: 4px 12px 7px 36px; + background: transparent; + border: 0; + font-size: 12px; + text-align: left; + color: var(--accent); +} + +.team-mehr:hover:not(:disabled) { + background: transparent; + text-decoration: underline; +} + +/* Floating bars */ + +.team-leiste { + position: absolute; + z-index: 2; + display: flex; + gap: 2px; + padding: 4px; + background: var(--surface); + border: 1px solid var(--divider); + box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.6); +} + +.team-leiste button { + padding: 6px 12px; + background: transparent; + border: 0; + font-size: 13px; +} + +.team-leiste button[aria-pressed="true"] { + background: color-mix(in srgb, var(--accent) 20%, transparent); + box-shadow: inset 0 -2px 0 var(--accent); +} + +.team-leiste-mitte { + left: 50%; + bottom: 16px; + transform: translateX(-50%); +} + +.team-leiste-zoom { + right: 16px; + bottom: 16px; +} + +.team-zoomwert { + align-self: center; + min-width: 48px; + font-size: 12px; + text-align: center; + color: var(--gedaempft); + font-variant-numeric: tabular-nums; +} + +/* Side panel */ + .team-seitenleiste { width: 320px; - flex-shrink: 0; padding: 14px; - background: var(--surface); - border: 1px solid var(--divider); display: flex; flex-direction: column; gap: 8px; overflow-y: auto; + background: var(--surface); + border-left: 1px solid var(--divider); } -.team-seitenleiste-kopf { - justify-content: space-between; -} +.team-seitenleiste[hidden] { display: none; } -.team-seitenleiste h3 { - margin: 8px 0 0; -} +.team-seitenleiste-kopf { justify-content: space-between; } +.team-seitenleiste h2 { margin: 0; } +.team-seitenleiste h3 { margin: 8px 0 0; } + +.team-seitenleiste .team-zeile { padding: 5px 4px; } .team-ergebnis { white-space: pre-wrap; @@ -1786,20 +2217,28 @@ td.klein { margin-top: 8px; } +.team-eintrag { + justify-content: flex-start; + width: 100%; + text-align: left; +} + .team-legende { flex-wrap: wrap; gap: 16px; } -.team-eintrag { - text-align: left; - justify-content: flex-start; - width: 100%; +@media (prefers-reduced-motion: reduce) { + .team-link, + .team-zeile.blinkt { animation: none; } + .team-welt.gleitend { transition: none; } } -@media (max-width: 800px) { - .team-flaeche { flex-direction: column; } - .team-seitenleiste { width: auto; } +@media (max-width: 900px) { + .team-arbeitsflaeche { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; } + .team-baum { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--divider); } + .team-leinwand { min-height: 60vh; } + .team-seitenleiste { width: auto; border-left: 0; border-top: 1px solid var(--divider); } } /* ─── Organisation (#683) ─── */ diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/i18n/de.json b/src/ClawdDotNet.Manager.Web/wwwroot/i18n/de.json index 3f281ab..2fae819 100644 --- a/src/ClawdDotNet.Manager.Web/wwwroot/i18n/de.json +++ b/src/ClawdDotNet.Manager.Web/wwwroot/i18n/de.json @@ -128,10 +128,10 @@ "org.toolsLostConfirm": "Werkzeuge entfernen und übernehmen", "org.runningRefusal": "Nicht, solange {agents} läuft — ein Agent darf nicht mitten im Lauf andere Rechte bekommen.", "team.title": "Teamübersicht", - "team.subtitle": "Wer arbeitet, wer hat wen in den letzten Sekunden erreicht und wo klemmt es. Einheiten zeigen, was in ihnen passiert; ein Klick öffnet sie oder zeigt Einzelheiten.", + "team.subtitle": "Jede Einheit ist eine Karte, verbunden wie die Organisation. Eine Linie trägt die Farbe des dringlichsten Zustands darunter, eine rote Linie führt also zum Problem. Klick auf Karte oder Agent zeigt Einzelheiten.", "team.noInstance": "Keine Instanz ausgewählt. Oben eine aktive Instanz wählen.", "team.empty": "Diese Instanz hat keine Agenten.", - "team.legendLink": "hat erreicht (verblasst nach 30 s)", + "team.legendLink": "Live-Verbindung (verblasst nach 30 s)", "team.state.Idle": "bereit", "team.state.Working": "arbeitet", "team.state.Stuck": "hängt", @@ -151,14 +151,33 @@ "team.unitAgentsOne": "1 Agent", "team.unitAgents": "{n} Agenten", "team.legendLead": "Leitung der Einheit", - "team.legendUnit": "Einheit, Klick öffnet sie", "team.leads": "Leitet", "team.memberOf": "Mitglied von", "team.members": "Mitglieder", "team.subUnits": "Untereinheiten", - "team.collapse": "Einheit zuklappen", - "team.expand": "Einheit aufklappen", "team.openOrganisation": "Organisation bearbeiten", + "team.rootSubtitle": "Instanz · oberste Ebene", + "team.structure": "Struktur", + "team.searchPlaceholder": "Agenten, Einheiten, Modelle suchen…", + "team.filterLabel": "Nach Zustand filtern", + "team.filter.all": "Alle", + "team.filter.problems": "Probleme", + "team.filter.waiting": "Freigaben", + "team.filter.working": "Arbeiten", + "team.filter.budget": "Budget", + "team.needsAttention": "{n} brauchen Aufmerksamkeit", + "team.matches": "{n} Treffer", + "team.matchesOne": "1 Treffer", + "team.noMatches": "Keine Treffer", + "team.moreMembers": "+{n} weitere", + "team.showFewer": "Weniger zeigen", + "team.showAllMembers": "Alle Mitglieder zeigen", + "team.zoomIn": "Vergrößern", + "team.zoomOut": "Verkleinern", + "team.fit": "Einpassen", + "team.liveLinks": "Live-Verbindungen", + "team.subtreeHint": "Die Zahlen umfassen alle Einheiten darunter.", + "team.legendLine": "Linie = dringlichster Zustand darunter", "nav.services": "Dienste", "nav.group.analytics": "Analyse", "nav.usage": "Tokennutzung", diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/i18n/en.json b/src/ClawdDotNet.Manager.Web/wwwroot/i18n/en.json index ab33333..854dcb1 100644 --- a/src/ClawdDotNet.Manager.Web/wwwroot/i18n/en.json +++ b/src/ClawdDotNet.Manager.Web/wwwroot/i18n/en.json @@ -128,10 +128,10 @@ "org.toolsLostConfirm": "Remove the tools and apply", "org.runningRefusal": "Not while {agents} is running — an agent must not get different rights in the middle of a run.", "team.title": "Team overview", - "team.subtitle": "Who is working, who reached whom in the last seconds, and where something is stuck. Units show what happens inside them; click to open them or to see details.", + "team.subtitle": "Every unit is a card, connected as the organisation. A line takes the colour of the most urgent state below it, so a red line leads to the problem. Click a card or an agent for details.", "team.noInstance": "No instance selected. Choose an active instance in the header.", "team.empty": "No agents in this instance.", - "team.legendLink": "reached (fades after 30 s)", + "team.legendLink": "live link (fades after 30 s)", "team.state.Idle": "idle", "team.state.Working": "working", "team.state.Stuck": "stuck", @@ -151,14 +151,33 @@ "team.unitAgentsOne": "1 agent", "team.unitAgents": "{n} agents", "team.legendLead": "lead of the unit", - "team.legendUnit": "unit, click to open", "team.leads": "Leads", "team.memberOf": "Member of", "team.members": "Members", "team.subUnits": "Sub-units", - "team.collapse": "Collapse unit", - "team.expand": "Expand unit", "team.openOrganisation": "Edit organisation", + "team.rootSubtitle": "Instance · top level", + "team.structure": "Structure", + "team.searchPlaceholder": "Search agents, units, models…", + "team.filterLabel": "Filter by state", + "team.filter.all": "All", + "team.filter.problems": "Problems", + "team.filter.waiting": "Approvals", + "team.filter.working": "Working", + "team.filter.budget": "Budget", + "team.needsAttention": "{n} need attention", + "team.matches": "{n} matches", + "team.matchesOne": "1 match", + "team.noMatches": "No matches", + "team.moreMembers": "+{n} more", + "team.showFewer": "Show fewer", + "team.showAllMembers": "Show all members", + "team.zoomIn": "Zoom in", + "team.zoomOut": "Zoom out", + "team.fit": "Fit", + "team.liveLinks": "Live links", + "team.subtreeHint": "Counts include all units below.", + "team.legendLine": "line = most urgent state below", "nav.services": "Services", "nav.group.analytics": "Analytics", "nav.usage": "Token Usage", diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/README.md b/src/ClawdDotNet.Manager.Web/wwwroot/vendor/README.md index 8d77ac9..85b51a9 100644 --- a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/README.md +++ b/src/ClawdDotNet.Manager.Web/wwwroot/vendor/README.md @@ -9,15 +9,19 @@ Downloaded 2026-09-24 from the npm registry. Each tarball was checked against th | Package | Version | File | License | SHA-256 of the file | |---|---|---|---|---| -| [cytoscape](https://www.npmjs.com/package/cytoscape) | 3.34.3 | `cytoscape/cytoscape.min.js` | MIT | `5f3b5b529546d5af1fc5628590af033b74511a5b6f789f5f4682845863228b91` | | [elkjs](https://www.npmjs.com/package/elkjs) | 0.9.3 | `elkjs/elk.bundled.js` | EPL-2.0 | `b0745abd7f23cd91690a1587e377edbe19fd7233c783300290936720546216d4` | -| [cytoscape-elk](https://www.npmjs.com/package/cytoscape-elk) | 2.3.0 | `cytoscape-elk/cytoscape-elk.js` | MIT | `25acbb9dea9b0dc6fef0e79b697547ee56e579f0e1c22ae4353131e72c7e140a` | -**Why elkjs 0.9.3 and not the newest.** cytoscape-elk 2.3.0 declares `elkjs ^0.9.3`. A newer -elkjs would be untested with the adapter. +**Why elkjs 0.9.3 and not the newest.** It came in together with cytoscape-elk 2.3.0, +which declared `elkjs ^0.9.3`. Cytoscape and the adapter were removed again on 2026-09-24 +(see below); elkjs stays at the version it was checked at. Raising it is a separate change. -**How they are loaded.** All three are UMD bundles and, loaded as classic scripts in this -order, register the globals `cytoscape`, `ELK` and `cytoscapeElk`. The team overview (#711) -loads them on demand, so pages that do not draw a graph do not pay for ~2 MB of script. +**Why Cytoscape is gone.** The team overview (#711) first drew its graph with Cytoscape.js +on a canvas. A canvas node cannot hold a list of agents, a search highlight or the house +style, so the cards became plain HTML placed by ELK, with the lines in SVG. Nothing else +used Cytoscape. + +**How it is loaded.** `elk.bundled.js` is a UMD bundle and, loaded as a classic script, +registers the global `ELK`. The team overview loads it on demand, so pages that do not draw +the organisation do not pay for ~1.5 MB of script. The license texts sit next to each file. diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape-elk/LICENSE b/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape-elk/LICENSE deleted file mode 100644 index 9c401ce..0000000 --- a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape-elk/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - - -Copyright (c) 2016-2018, 2020, The Cytoscape Consortium. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the “Software”), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape-elk/cytoscape-elk.js b/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape-elk/cytoscape-elk.js deleted file mode 100644 index c003983..0000000 --- a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape-elk/cytoscape-elk.js +++ /dev/null @@ -1,356 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("elkjs/lib/elk.bundled.js")); - else if(typeof define === 'function' && define.amd) - define(["elkjs"], factory); - else if(typeof exports === 'object') - exports["cytoscapeElk"] = factory(require("elkjs/lib/elk.bundled.js")); - else - root["cytoscapeElk"] = factory(root["ELK"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE__632__) { -return /******/ (function() { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ 632: -/***/ (function(module) { - -module.exports = __WEBPACK_EXTERNAL_MODULE__632__; - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ !function() { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function() { return module['default']; } : -/******/ function() { return module; }; -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ }(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ !function() { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = function(exports, definition) { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ }(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ !function() { -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -/******/ }(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -!function() { - -// EXPORTS -__webpack_require__.d(__webpack_exports__, { - "default": function() { return /* binding */ src; } -}); - -// EXTERNAL MODULE: external {"commonjs":"elkjs/lib/elk.bundled.js","commonjs2":"elkjs/lib/elk.bundled.js","amd":"elkjs","root":"ELK"} -var elk_bundled_js_amd_elkjs_root_ELK_ = __webpack_require__(632); -var elk_bundled_js_amd_elkjs_root_ELK_default = /*#__PURE__*/__webpack_require__.n(elk_bundled_js_amd_elkjs_root_ELK_); -;// CONCATENATED MODULE: ./src/assign.js -// Simple, internal Object.assign() polyfill for options objects etc. -function assign_assign(tgt) { - for (var _len = arguments.length, srcs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - srcs[_key - 1] = arguments[_key]; - } - - srcs.forEach(function (src) { - Object.keys(src).forEach(function (k) { - return tgt[k] = src[k]; - }); - }); - return tgt; -} - -/* harmony default export */ var src_assign = (Object.assign != null ? Object.assign.bind(Object) : assign_assign); -;// CONCATENATED MODULE: ./src/defaults.js -var defaults = { - nodeDimensionsIncludeLabels: false, - // Boolean which changes whether label dimensions are included when calculating node dimensions - fit: true, - // Whether to fit - padding: 20, - // Padding on fit - animate: false, - // Whether to transition the node positions - animateFilter: function animateFilter() { - return true; - }, - // Whether to animate specific nodes when animation is on; non-animated nodes immediately go to their final positions - animationDuration: 500, - // Duration of animation in ms if enabled - animationEasing: undefined, - // Easing of animation if enabled - transform: function transform(node, pos) { - return pos; - }, - // A function that applies a transform to the final node position - ready: undefined, - // Callback on layoutready - stop: undefined, - // Callback on layoutstop - nodeLayoutOptions: undefined, - // Special options for only the nodes - elk: { - // Options to pass directly to ELK `layoutOptions`. The subsequent identifier has to be used as property key in quotes. - // E.g. for 'org.eclipse.elk.direction' use: - // 'elk.direction' - // Primary/mandatory, the elk algorithm to use - // one of 'box', 'disco', 'force', 'layered', 'mrtree', 'radial', 'random', 'stress' - // (see https://www.eclipse.org/elk/reference/algorithms.html) - algorithm: undefined - }, - priority: function priority() { - return null; - } // Edges with a non-nil value are skipped when geedy edge cycle breaking is enabled - -}; -/* harmony default export */ var src_defaults = (defaults); -;// CONCATENATED MODULE: ./src/layout.js -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } - - - - -var elkOverrides = {}; - -var getPos = function getPos(ele, options) { - var dims = ele.layoutDimensions(options); - var parent = ele.parent(); - var k = ele.scratch('elk'); - var p = { - x: k.x, - y: k.y - }; - - while (parent.nonempty()) { - var kp = parent.scratch('elk'); - p.x += kp.x; - p.y += kp.y; - parent = parent.parent(); - } // elk considers a node position to be its top-left corner, while cy is the centre - - - p.x += dims.w / 2; - p.y += dims.h / 2; - return p; -}; - -var makeNode = function makeNode(node, options) { - var k = { - _cyEle: node, - id: node.id() - }; // Apply nodeLayoutOptions per user-specified function - // e.g. nodeLayoutOptions => n.scratch('layoutOptions') - - if (options.nodeLayoutOptions) { - k.layoutOptions = options.nodeLayoutOptions(node); - } - - if (!node.isParent()) { - var dims = node.layoutDimensions(options); - var p = node.position(); // the elk position is the top-left corner, cy is the centre - - k.x = p.x - dims.w / 2; - k.y = p.y - dims.h / 2; - k.width = dims.w; - k.height = dims.h; - } - - node.scratch('elk', k); - return k; -}; - -var makeEdge = function makeEdge(edge -/*, options*/ -) { - var k = { - _cyEle: edge, - id: edge.id(), - source: edge.data('source'), - target: edge.data('target') - }; - edge.scratch('elk', k); - return k; -}; - -var makeGraph = function makeGraph(nodes, edges, options) { - var elkNodes = []; - var elkEdges = []; - var elkEleLookup = {}; - var graph = { - id: 'root', - children: [], - edges: [] - }; // map all nodes - - for (var i = 0; i < nodes.length; i++) { - var n = nodes[i]; - var k = makeNode(n, options); - elkNodes.push(k); - elkEleLookup[n.id()] = k; - } // map all edges - - - for (var _i = 0; _i < edges.length; _i++) { - var e = edges[_i]; - - var _k = makeEdge(e, options); - - elkEdges.push(_k); - elkEleLookup[e.id()] = _k; - } // make hierarchy - - - for (var _i2 = 0; _i2 < elkNodes.length; _i2++) { - var _k2 = elkNodes[_i2]; - var _n = _k2._cyEle; - - if (!_n.isChild()) { - graph.children.push(_k2); - } else { - var parent = _n.parent(); - - var parentK = elkEleLookup[parent.id()]; - var children = parentK.children = parentK.children || []; - children.push(_k2); - } - } - - for (var _i3 = 0; _i3 < elkEdges.length; _i3++) { - var _k3 = elkEdges[_i3]; // put all edges in the top level for now - // TODO does this cause issues in certain edgecases? - - /*let e = k._cyEle; - let parentSrc = e.source().parent(); - let parentTgt = e.target().parent(); - if ( false && parentSrc.nonempty() && parentTgt.nonempty() && parentSrc.same( parentTgt ) ){ - let kp = elkEleLookup[ parentSrc.id() ]; - kp.edges = kp.edges || []; - kp.edges.push( k ); - } else {*/ - - graph.edges.push(_k3); //} - } - - return graph; -}; - -var Layout = /*#__PURE__*/function () { - function Layout(options) { - _classCallCheck(this, Layout); - - var elkOptions = options.elk; - var cy = options.cy; - this.options = src_assign({}, src_defaults, options); - this.options.elk = src_assign({ - aspectRatio: cy.width() / cy.height() - }, src_defaults.elk, elkOptions, elkOverrides); - } - - _createClass(Layout, [{ - key: "run", - value: function run() { - var layout = this; - var options = this.options; - var eles = options.eles; - var nodes = eles.nodes(); - var edges = eles.edges(); - var elk = new (elk_bundled_js_amd_elkjs_root_ELK_default())(); - var graph = makeGraph(nodes, edges, options); - graph['layoutOptions'] = options.elk; - elk.layout(graph).then(function () { - nodes.filter(function (n) { - return !n.isParent(); - }).layoutPositions(layout, options, function (n) { - return getPos(n, options); - }); - }); - return this; - } - }, { - key: "stop", - value: function stop() { - return this; // chaining - } - }, { - key: "destroy", - value: function destroy() { - return this; // chaining - } - }]); - - return Layout; -}(); - -/* harmony default export */ var layout = (Layout); -;// CONCATENATED MODULE: ./src/index.js - // registers the extension on a cytoscape lib ref - -var register = function register(cytoscape) { - if (!cytoscape) { - return; - } // can't register if cytoscape unspecified - - - cytoscape('layout', 'elk', layout); // register with cytoscape.js -}; - -if (typeof cytoscape !== 'undefined') { - // expose to global cytoscape (i.e. window.cytoscape) - // eslint-disable-next-line no-undef - register(cytoscape); -} - -/* harmony default export */ var src = (register); -}(); -__webpack_exports__ = __webpack_exports__["default"]; -/******/ return __webpack_exports__; -/******/ })() -; -}); \ No newline at end of file diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape/LICENSE b/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape/LICENSE deleted file mode 100644 index aac05f2..0000000 --- a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2016-2026, The Cytoscape Consortium. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the “Software”), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape/cytoscape.min.js b/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape/cytoscape.min.js deleted file mode 100644 index bab26b7..0000000 --- a/src/ClawdDotNet.Manager.Web/wwwroot/vendor/cytoscape/cytoscape.min.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016-2026, The Cytoscape Consortium. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the “Software”), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).cytoscape=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function a(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,s=[],l=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||u(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function u(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}var c="undefined"==typeof window?null:window,d=c?c.navigator:null;c&&c.document;var h,f,p,g,v,y,m,b,x,w,E,k,T,C,P,S,B,D,_,A,M,R,I,N,L,z,O,V,F=l(""),X=l({}),j=l((function(){})),Y="undefined"==typeof HTMLElement?"undefined":l(HTMLElement),q=function(e){return e&&e.instanceString&&U(e.instanceString)?e.instanceString():null},W=function(e){return null!=e&&l(e)==F},U=function(e){return null!=e&&l(e)===j},H=function(e){return!Q(e)&&(Array.isArray?Array.isArray(e):null!=e&&e instanceof Array)},K=function(e){return null!=e&&l(e)===X&&!H(e)&&e.constructor===Object},G=function(e){return null!=e&&l(e)===l(1)&&!isNaN(e)},Z=function(e){return G(e)&&Math.floor(e)===e},$=function(e){return"undefined"===Y?void 0:null!=e&&e instanceof HTMLElement},Q=function(e){return J(e)||ee(e)},J=function(e){return"collection"===q(e)&&e._private.single},ee=function(e){return"collection"===q(e)&&!e._private.single},te=function(e){return"core"===q(e)},ne=function(e){return"stylesheet"===q(e)},re=function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},ae=function(e){return function(e){return null!=e&&l(e)===X}(e)&&U(e.then)},ie=function(e,t){t||(t=function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;tt?1:0},ye=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n255)return;t.push(Math.floor(i))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var l=n[4];if(void 0!==l){if((l=parseFloat(l))<0||l>1)return;t.push(l)}}return t}(e)||function(e){var t,n,r,a,i,o,s,l;function u(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var c=new RegExp("^"+pe+"$").exec(e);if(c){if((n=parseInt(c[1]))<0?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,(r=parseFloat(c[2]))<0||r>100)return;if(r/=100,(a=parseFloat(c[3]))<0||a>100)return;if(a/=100,void 0!==(i=c[4])&&((i=parseFloat(i))<0||i>1))return;if(0===r)o=s=l=Math.round(255*a);else{var d=a<.5?a*(1+r):a+r-a*r,h=2*a-d;o=Math.round(255*u(h,d,n+1/3)),s=Math.round(255*u(h,d,n)),l=Math.round(255*u(h,d,n-1/3))}t=[o,s,l,i]}return t}(e)},be={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},xe=function(e){for(var t=e.map,n=e.keys,r=n.length,a=0;a=o||t<0||v&&e-p>=c}function x(){var e=t();if(b(e))return w(e);h=setTimeout(x,function(e){var t=o-(e-f);return v?a(t,c-(e-p)):t}(e))}function w(e){return h=void 0,y&&l?m(e):(l=u=void 0,d)}function E(){var e=t(),n=b(e);if(l=arguments,u=this,f=e,n){if(void 0===h)return function(e){return p=e,h=setTimeout(x,o),g?m(e):d}(f);if(v)return clearTimeout(h),h=setTimeout(x,o),m(f)}return void 0===h&&(h=setTimeout(x,o)),d}return o=n(o)||0,e(s)&&(g=!!s.leading,c=(v="maxWait"in s)?r(n(s.maxWait)||0,o):c,y="trailing"in s?!!s.trailing:y),E.cancel=function(){void 0!==h&&clearTimeout(h),p=0,l=f=u=h=void 0},E.flush=function(){return void 0===h?d:w(t())},E},O}(),Ae=ke(_e),Me=c?c.performance:null,Re=Me&&Me.now?function(){return Me.now()}:function(){return Date.now()},Ie=function(){if(c){if(c.requestAnimationFrame)return function(e){c.requestAnimationFrame(e)};if(c.mozRequestAnimationFrame)return function(e){c.mozRequestAnimationFrame(e)};if(c.webkitRequestAnimationFrame)return function(e){c.webkitRequestAnimationFrame(e)};if(c.msRequestAnimationFrame)return function(e){c.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout((function(){e(Re())}),1e3/60)}}(),Ne=function(e){return Ie(e)},Le=Re,ze=9261,Oe=5381,Ve=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ze;!(t=e.next()).done;)n=65599*n+t.value|0;return n},Fe=function(e){return 65599*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:ze)+e|0},Xe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oe;return(t<<5)+t+e|0},je=function(e){return 2097152*e[0]+e[1]},Ye=function(e,t){return[Fe(e[0],t[0]),Xe(e[1],t[1])]},qe=function(e,t){var n={value:0,done:!1},r=0,a=e.length;return Ve({next:function(){return r=0;r--)e[r]===t&&e.splice(r,1)},ht=function(e){e.splice(0,e.length)},ft=function(e,t,n){return n&&(t=le(n,t)),e[t]},pt=function(e,t,n,r){n&&(t=le(n,t)),e[t]=r},gt="undefined"!=typeof Map?Map:function(){return n((function e(){t(this,e),this._obj={}}),[{key:"set",value:function(e,t){return this._obj[e]=t,this}},{key:"delete",value:function(e){return this._obj[e]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(e){return void 0!==this._obj[e]}},{key:"get",value:function(e){return this._obj[e]}}])}(),vt=function(){return n((function e(n){if(t(this,e),this._obj=Object.create(null),this.size=0,null!=n){var r;r=null!=n.instanceString&&n.instanceString()===this.instanceString()?n.toArray():n;for(var a=0;a2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&te(e)){var r=t.group;if(null==r&&(r=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"===r||"edges"===r){this.length=1,this[0]=this;var a=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:void 0===t.selectable||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:void 0===t.grabbable||!!t.grabbable,pannable:void 0===t.pannable?"edges"===r:!!t.pannable,active:!1,classes:new yt,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(null==a.position.x&&(a.position.x=0),null==a.position.y&&(a.position.y=0),t.renderedPosition){var i=t.renderedPosition,o=e.pan(),s=e.zoom();a.position={x:(i.x-o.x)/s,y:(i.y-o.y)/s}}var l=[];H(t.classes)?l=t.classes:W(t.classes)&&(l=t.classes.split(/\s+/));for(var u=0,c=l.length;ut?1:0},u=function(e,t,a,i,o){var s;if(null==a&&(a=0),null==o&&(o=n),a<0)throw new Error("lo must be non-negative");for(null==i&&(i=e.length);an;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse()).length;ig;0<=g?++h:--h)v.push(i(e,r));return v},p=function(e,t,r,a){var i,o,s;for(null==a&&(a=n),i=e[r];r>t&&a(i,o=e[s=r-1>>1])<0;)e[r]=o,r=s;return e[r]=i},g=function(e,t,r){var a,i,o,s,l;for(null==r&&(r=n),i=e.length,l=t,o=e[t],a=2*t+1;a0;){var w=y.pop(),E=g(w),k=w.id();if(d[k]=E,E!==1/0)for(var T=w.neighborhood().intersect(f),C=0;C0)for(n.unshift(t);c[a];){var i=c[a];n.unshift(i.edge),n.unshift(i.node),a=(r=i.node).id()}return o.spawn(n)}}}},At={kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,a=n.length,i=new Array(a),o=n,s=function(e){for(var t=0;t0;){if(l=g.pop(),u=l.id(),v.delete(u),w++,u===d){for(var E=[],k=a,T=d,C=m[T];E.unshift(k),null!=C&&E.unshift(C),null!=(k=y[T]);)C=m[T=k.id()];return{found:!0,distance:h[u],path:this.spawn(E),steps:w}}p[u]=!0;for(var P=l._private.edges,S=0;SP&&(f[C]=P,y[C]=T,m[C]=x),!a){var S=T*u+k;!a&&f[S]>P&&(f[S]=P,y[S]=k,m[S]=x)}}}for(var B=0;B1&&void 0!==arguments[1]?arguments[1]:i,r=[],a=m(e);;){if(null==a)return t.spawn();var o=y(a),l=o.edge,u=o.pred;if(r.unshift(a[0]),a.same(n)&&r.length>0)break;null!=l&&r.unshift(l),a=u}return s.spawn(r)},hasNegativeWeightCycle:p,negativeWeightCycles:g}}},Ot=Math.sqrt(2),Vt=function(e,t,n){0===n.length&&rt("Karger-Stein must be run on a connected (sub)graph");for(var r=n[e],a=r[1],i=r[2],o=t[a],s=t[i],l=n,u=l.length-1;u>=0;u--){var c=l[u],d=c[1],h=c[2];(t[d]===o&&t[h]===s||t[d]===s&&t[h]===o)&&l.splice(u,1)}for(var f=0;fr;){var a=Math.floor(Math.random()*t.length);t=Vt(a,e,t),n--}return t},Xt={kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,r=t.edges;r.unmergeBy((function(e){return e.isLoop()}));var a=n.length,i=r.length,o=Math.ceil(Math.pow(Math.log(a)/Math.LN2,2)),s=Math.floor(a/Ot);if(!(a<2)){for(var l=[],u=0;u0?1:e<0?-1:0},Gt=function(e,t){return Math.sqrt(Zt(e,t))},Zt=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},$t=function(e){for(var t=e.length,n=0,r=0;r=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(null!=e.w&&null!=e.h&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},nn=function(e,t,n){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},rn=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},an=function(e){var t,n,r,a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===o.length)t=n=r=a=o[0];else if(2===o.length)t=r=o[0],a=n=o[1];else if(4===o.length){var s=i(o,4);t=s[0],n=s[1],r=s[2],a=s[3]}return e.x1-=a,e.x2+=n,e.y1-=t,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},on=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},sn=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2t.y2)&&!(t.y1>e.y2)))))))},ln=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},un=function(e,t){return ln(e,t.x,t.y)},cn=function(e,t){return ln(e,t.x1,t.y1)&&ln(e,t.x2,t.y2)},dn=null!==(St=Math.hypot)&&void 0!==St?St:function(e,t){return Math.sqrt(e*e+t*t)};function hn(e,t,n,r,a,i){var o=function(e,t){if(e.length<3)throw new Error("Need at least 3 vertices");var n=function(e,t){return{x:e.x+t.x,y:e.y+t.y}},r=function(e,t){return{x:e.x-t.x,y:e.y-t.y}},a=function(e,t){return{x:e.x*t,y:e.y*t}},i=function(e,t){return e.x*t.y-e.y*t.x},o=function(e,t,o,s){var l=r(t,e),u=r(s,o),c=i(l,u);if(Math.abs(c)<1e-9)return n(e,a(l,.5));var d=i(r(o,e),u)/c;return n(e,a(l,d))},s=e.map((function(e){return{x:e.x,y:e.y}}));(function(e){for(var t=0,n=0;n7&&void 0!==arguments[7]?arguments[7]:"auto",c="auto"===u?Mn(a,i):u,d=a/2,h=i/2,f=(c=Math.min(c,d,h))!==d,p=c!==h;if(f){var g=r-h-o;if((s=Cn(e,t,n,r,n-d+c-o,g,n+d-c+o,g,!1)).length>0)return s}if(p){var v=n+d+o;if((s=Cn(e,t,n,r,v,r-h+c-o,v,r+h-c+o,!1)).length>0)return s}if(f){var y=r+h+o;if((s=Cn(e,t,n,r,n-d+c-o,y,n+d-c+o,y,!1)).length>0)return s}if(p){var m=n-d-o;if((s=Cn(e,t,n,r,m,r-h+c-o,m,r+h-c+o,!1)).length>0)return s}var b=n-d+c,x=r-h+c;if((l=kn(e,t,n,r,b,x,c+o)).length>0&&l[0]<=b&&l[1]<=x)return[l[0],l[1]];var w=n+d-c,E=r-h+c;if((l=kn(e,t,n,r,w,E,c+o)).length>0&&l[0]>=w&&l[1]<=E)return[l[0],l[1]];var k=n+d-c,T=r+h-c;if((l=kn(e,t,n,r,k,T,c+o)).length>0&&l[0]>=k&&l[1]>=T)return[l[0],l[1]];var C=n-d+c,P=r+h-c;return(l=kn(e,t,n,r,C,P,c+o)).length>0&&l[0]<=C&&l[1]>=P?[l[0],l[1]]:[]},pn=function(e,t,n,r,a,i,o){var s=o,l=Math.min(n,a),u=Math.max(n,a),c=Math.min(r,i),d=Math.max(r,i);return l-s<=e&&e<=u+s&&c-s<=t&&t<=d+s},gn=function(e,t,n,r,a,i,o,s,l){var u=Math.min(n,o,a)-l,c=Math.max(n,o,a)+l,d=Math.min(r,s,i)-l,h=Math.max(r,s,i)+l;return!(ec||th)},vn=function(e,t,n,r,a,i,o,s){var l=[];!function(e,t,n,r,a){var i,o,s,l,u,c,d,h;0===e&&(e=1e-5),s=-27*(r/=e)+(t/=e)*(9*(n/=e)-t*t*2),i=(o=(3*n-t*t)/9)*o*o+(s/=54)*s,a[1]=0,d=t/3,i>0?(u=(u=s+Math.sqrt(i))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),c=(c=s-Math.sqrt(i))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),a[0]=-d+u+c,d+=(u+c)/2,a[4]=a[2]=-d,d=Math.sqrt(3)*(-c+u)/2,a[3]=d,a[5]=-d):(a[5]=a[3]=0,0===i?(h=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),a[0]=2*h-d,a[4]=a[2]=-(h+d)):(l=(o=-o)*o*o,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(o),a[0]=-d+h*Math.cos(l/3),a[2]=-d+h*Math.cos((l+2*Math.PI)/3),a[4]=-d+h*Math.cos((l+4*Math.PI)/3)))}(1*n*n-4*n*a+2*n*o+4*a*a-4*a*o+o*o+r*r-4*r*i+2*r*s+4*i*i-4*i*s+s*s,9*n*a-3*n*n-3*n*o-6*a*a+3*a*o+9*r*i-3*r*r-3*r*s-6*i*i+3*i*s,3*n*n-6*n*a+n*o-n*e+2*a*a+2*a*e-o*e+3*r*r-6*r*i+r*s-r*t+2*i*i+2*i*t-s*t,1*n*a-n*n+n*e-a*e+r*i-r*r+r*t-i*t,l);for(var u=[],c=0;c<6;c+=2)Math.abs(l[c+1])<1e-7&&l[c]>=0&&l[c]<=1&&u.push(l[c]);u.push(1),u.push(0);for(var d,h,f,p=-1,g=0;g=0?fl?(e-a)*(e-a)+(t-i)*(t-i):u-d},mn=function(e,t,n){for(var r,a,i,o,s=0,l=0;l=e&&e>=i||r<=e&&e<=i))continue;(e-r)/(i-r)*(o-a)+a>t&&s++}return s%2!=0},bn=function(e,t,n,r,a,i,o,s,l){var u,c=new Array(n.length);null!=s[0]?(u=Math.atan(s[1]/s[0]),s[0]<0?u+=Math.PI/2:u=-u-Math.PI/2):u=s;for(var d,h=Math.cos(-u),f=Math.sin(-u),p=0;p0){var g=wn(c,-l);d=xn(g)}else d=c;return mn(e,t,d)},xn=function(e){for(var t,n,r,a,i,o,s,l,u=new Array(e.length/2),c=0;c=0&&p<=1&&v.push(p),g>=0&&g<=1&&v.push(g),0===v.length)return[];var y=v[0]*s[0]+e,m=v[0]*s[1]+t;return v.length>1?v[0]==v[1]?[y,m]:[y,m,v[1]*s[0]+e,v[1]*s[1]+t]:[y,m]},Tn=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},Cn=function(e,t,n,r,a,i,o,s,l){var u=e-a,c=n-e,d=o-a,h=t-i,f=r-t,p=s-i,g=d*h-p*u,v=c*h-f*u,y=p*c-d*f;if(0!==y){var m=g/y,b=v/y,x=-.001;return x<=m&&m<=1.001&&x<=b&&b<=1.001||l?[e+m*c,t+m*f]:[]}return 0===g||0===v?Tn(e,n,o)===o?[o,s]:Tn(e,n,a)===a?[a,i]:Tn(a,o,n)===n?[n,r]:[]:[]},Pn=function(e,t,n,r,a){var i=[],o=r/2,s=a/2,l=t,u=n;i.push({x:l+o*e[0],y:u+s*e[1]});for(var c=1;c0){var m=wn(g,-s);u=xn(m)}else u=g}else u=n;for(var b=0;bu&&(u=t)},d=function(e){return l[e]},h=0;h0?b.edgesTo(m)[0]:m.edgesTo(b)[0];var w=r(x);m=m.id(),u[m]>u[g]+w&&(u[m]=u[g]+w,h.nodes.indexOf(m)<0?h.push(m):h.updateItem(m),l[m]=0,n[m]=[]),u[m]==u[g]+w&&(l[m]=l[m]+l[g],n[m].push(g))}else for(var E=0;E0;){for(var P=t.pop(),S=0;S0&&o.push(n[s]);0!==o.length&&a.push(r.collection(o))}return a}(c,l,t,r);return b=function(e){for(var t=0;t5&&void 0!==arguments[5]?arguments[5]:er,o=r,s=0;s=2?or(e,t,n,0,rr,ar):or(e,t,n,0,nr)},squaredEuclidean:function(e,t,n){return or(e,t,n,0,rr)},manhattan:function(e,t,n){return or(e,t,n,0,nr)},max:function(e,t,n){return or(e,t,n,-1/0,ir)}};function lr(e,t,n,r,a,i){var o;return o=U(e)?e:sr[e]||sr.euclidean,0===t&&U(e)?o(a,i):o(t,n,r,a,i)}sr["squared-euclidean"]=sr.squaredEuclidean,sr.squaredeuclidean=sr.squaredEuclidean;var ur=ct({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),cr=function(e){return ur(e)},dr=function(e,t,n,r,a){var i="kMedoids"!==a?function(e){return n[e]}:function(e){return r[e](n)},o=n,s=t;return lr(e,r.length,i,(function(e){return r[e](t)}),o,s)},hr=function(e,t,n){for(var r=n.length,a=new Array(r),i=new Array(r),o=new Array(t),s=null,l=0;ln)return!1}return!0},yr=function(e,t,n){for(var r=0;ra&&(a=t[l][u],i=u);o[i].push(e[l])}for(var c=0;c=a.threshold||"dendrogram"===a.mode&&1===e.length)return!1;var f,p=t[o],g=t[r[o]];f="dendrogram"===a.mode?{left:p,right:g,key:p.key}:{value:p.value.concat(g.value),key:p.key},e[p.index]=f,e.splice(g.index,1),t[p.key]=f;for(var v=0;vn[g.key][y.key]&&(i=n[g.key][y.key])):"max"===a.linkage?(i=n[p.key][y.key],n[p.key][y.key]1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];arguments.length>3&&void 0!==arguments[3]&&!arguments[3]?(n0&&e.splice(0,t)):e=e.slice(t,n);for(var i=0,o=e.length-1;o>=0;o--){var s=e[o];a?isFinite(s)||(e[o]=-1/0,i++):e.splice(o,1)}r&&e.sort((function(e,t){return e-t}));var l=e.length,u=Math.floor(l/2);return l%2!=0?e[u+1+i]:(e[u-1+i]+e[u+i])/2}(e):"mean"===t?function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,a=0,i=t;i1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=1/0,a=t;a1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=-1/0,a=t;ao&&(i=l,o=t[a*e+l])}i>0&&r.push(i)}for(var u=0;u=P?(S=P,P=D,B=_):D>S&&(S=D);for(var A=0;A0?1:0;k[E%u.minIterations*t+z]=O,L+=O}if(L>0&&(E>=u.minIterations-1||E==u.maxIterations-1)){for(var V=0,F=0;F0&&r.push(a);return r}(t,i,o),Y=function(e,t,n){for(var r=Nr(e,t,n),a=0;al&&(s=u,l=c)}n[a]=i[s]}return Nr(e,t,n)}(t,r,j),q={},W=0;W1||o>1)&&(u=!0),c[t]=[],e.outgoers().forEach((function(e){e.isEdge()&&c[t].push(e.id())}))}else d[t]=[void 0,e.target().id()]})):l.forEach((function(e){var t=e.id();e.isNode()?(e.degree(!0)%2&&(n?r?u=!0:r=t:n=t),c[t]=[],e.connectedEdges().forEach((function(e){return c[t].push(e.id())}))):d[t]=[e.source().id(),e.target().id()]}));var h={found:!1,trail:void 0};if(u)return h;if(r&&n)if(s){if(a&&r!=a)return h;a=r}else{if(a&&r!=a&&n!=a)return h;a||(a=r)}else a||(a=l[0].id());var f=function(e){for(var t,n,r,a=e,i=[e];c[a].length;)t=c[a].shift(),n=d[t][0],a!=(r=d[t][1])?(c[r]=c[r].filter((function(e){return e!=t})),a=r):s||a==n||(c[n]=c[n].filter((function(e){return e!=t})),a=n),i.unshift(t),i.unshift(a);return i},p=[],g=[];for(g=f(a);1!=g.length;)0==c[g[0]].length?(p.unshift(l.getElementById(g.shift())),p.unshift(l.getElementById(g.shift()))):g=f(g.shift()).concat(g);for(var v in p.unshift(l.getElementById(g.shift())),c)if(c[v].length)return h;return h.found=!0,h.trail=this.spawn(p,!0),h}},Fr=function(){var e=this,t={},n=0,r=0,a=[],i=[],o={},s=function(l,u,c){l===c&&(r+=1),t[u]={id:n,low:n++,cutVertex:!1};var d,h,f,p,g=e.getElementById(u).connectedEdges().intersection(e);0===g.size()?a.push(e.spawn(e.getElementById(u))):g.forEach((function(n){d=n.source().id(),h=n.target().id(),(f=d===u?h:d)!==c&&(p=n.id(),o[p]||(o[p]=!0,i.push({x:u,y:f,edge:n})),f in t?t[u].low=Math.min(t[u].low,t[f].id):(s(l,f,u),t[u].low=Math.min(t[u].low,t[f].low),t[u].id<=t[f].low&&(t[u].cutVertex=!0,function(n,r){for(var o=i.length-1,s=[],l=e.spawn();i[o].x!=n||i[o].y!=r;)s.push(i.pop().edge),o--;s.push(i.pop().edge),s.forEach((function(n){var r=n.connectedNodes().intersection(e);l.merge(n),r.forEach((function(n){var r=n.id(),a=n.connectedEdges().intersection(e);l.merge(n),t[r].cutVertex?l.merge(a.filter((function(e){return e.isLoop()}))):l.merge(a)}))})),a.push(l)}(u,f))))}))};e.forEach((function(e){if(e.isNode()){var n=e.id();n in t||(r=0,s(n,n),t[n].cutVertex=r>1)}}));var l=Object.keys(t).filter((function(e){return t[e].cutVertex})).map((function(t){return e.getElementById(t)}));return{cut:e.spawn(l),components:a}},Xr=function(){var e=this,t={},n=0,r=[],a=[],i=e.spawn(e),o=function(s){if(a.push(s),t[s]={index:n,low:n++,explored:!1},e.getElementById(s).connectedEdges().intersection(e).forEach((function(e){var n=e.target().id();n!==s&&(n in t||o(n),t[n].explored||(t[s].low=Math.min(t[s].low,t[n].low)))})),t[s].index===t[s].low){for(var l=e.spawn();;){var u=a.pop();if(l.merge(e.getElementById(u)),t[u].low=t[s].index,t[u].explored=!0,u===s)break}var c=l.edgesWith(l),d=l.merge(c);r.push(d),i=i.difference(d)}};return e.forEach((function(e){if(e.isNode()){var n=e.id();n in t||o(n)}})),{cut:i,components:r}},jr={};[xt,_t,At,Rt,Nt,zt,Xt,zn,Vn,Xn,Yn,Jn,kr,Ar,zr,Vr,{hopcroftTarjanBiconnected:Fr,htbc:Fr,htb:Fr,hopcroftTarjanBiconnectedComponents:Fr},{tarjanStronglyConnected:Xr,tsc:Xr,tscc:Xr,tarjanStronglyConnectedComponents:Xr}].forEach((function(e){ye(jr,e)})); -/*! - Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable - Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) - Licensed under The MIT License (http://opensource.org/licenses/MIT) - */ -var Yr=function(e){if(!(this instanceof Yr))return new Yr(e);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};Yr.prototype={fulfill:function(e){return qr(this,1,"fulfillValue",e)},reject:function(e){return qr(this,2,"rejectReason",e)},then:function(e,t){var n=this,r=new Yr;return n.onFulfilled.push(Hr(e,r,"fulfill")),n.onRejected.push(Hr(t,r,"reject")),Wr(n),r.proxy}};var qr=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,Wr(e)),e},Wr=function(e){1===e.state?Ur(e,"onFulfilled",e.fulfillValue):2===e.state&&Ur(e,"onRejected",e.rejectReason)},Ur=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var a=function(){for(var e=0;e0:void 0}},clearQueue:function(){return function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return this;for(var n=0;n-1}}(),a=function(){if(Ya)return ja;Ya=1;var e=Oi();return ja=function(t,n){var r=this.__data__,a=e(r,t);return a<0?(++this.size,r.push([t,n])):r[a][1]=n,this},ja}();function i(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&t%1==0&&t0&&this.spawn(r).updateStyle().emit("class"),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){H(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=void 0===t,a=[],i=0,o=n.length;i0&&this.spawn(a).updateStyle().emit("class"),n},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(null==t)t=250;else if(0===t)return n;return n.addClass(e),setTimeout((function(){n.removeClass(e)}),t),n}};To.className=To.classNames=To.classes;var Co={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:de,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Co.variable="(?:[\\w-.]|(?:\\\\"+Co.metaChar+"))+",Co.className="(?:[\\w-]|(?:\\\\"+Co.metaChar+"))+",Co.value=Co.string+"|"+Co.number,Co.id=Co.variable,function(){var e,t,n;for(e=Co.comparatorOp.split("|"),n=0;n=0||"="!==t&&(Co.comparatorOp+="|\\!"+t)}();var Po=0,So=1,Bo=2,Do=3,_o=4,Ao=5,Mo=6,Ro=7,Io=8,No=9,Lo=10,zo=11,Oo=12,Vo=13,Fo=14,Xo=15,jo=16,Yo=17,qo=18,Wo=19,Uo=20,Ho=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort((function(e,t){return function(e,t){return-1*ve(e,t)}(e.selector,t.selector)})),Ko=function(){for(var e,t={},n=0;n0&&u.edgeCount>0)return it("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(u.edgeCount>1)return it("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===u.edgeCount&&it("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var e=function(e){return null==e?"":e},t=function(t){return W(t)?'"'+t+'"':e(t)},n=function(e){return" "+e+" "},r=function(r,i){var o=r.type,s=r.value;switch(o){case Po:var l=e(s);return l.substring(0,l.length-1);case Do:var u=r.field,c=r.operator;return"["+u+n(e(c))+t(s)+"]";case Ao:var d=r.operator,h=r.field;return"["+e(d)+h+"]";case _o:return"["+r.field+"]";case Mo:var f=r.operator;return"[["+r.field+n(e(f))+t(s)+"]]";case Ro:return s;case Io:return"#"+s;case No:return"."+s;case Yo:case Xo:return a(r.parent,i)+n(">")+a(r.child,i);case qo:case jo:return a(r.ancestor,i)+" "+a(r.descendant,i);case Wo:var p=a(r.left,i),g=a(r.subject,i),v=a(r.right,i);return p+(p.length>0?" ":"")+g+v;case Uo:return""}},a=function(e,t){return e.checks.reduce((function(n,a,i){return n+(t===e&&0===i?"$":"")+r(a,t)}),"")},i="",o=0;o1&&o=0&&(t=t.replace("!",""),c=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),u=!0),(o||l||u)&&(a=o||s?""+e:"",i=""+n),u&&(e=a=a.toLowerCase(),n=i=i.toLowerCase()),t){case"*=":r=a.indexOf(i)>=0;break;case"$=":r=a.indexOf(i,a.length-i.length)>=0;break;case"^=":r=0===a.indexOf(i);break;case"=":r=e===n;break;case">":d=!0,r=e>n;break;case">=":d=!0,r=e>=n;break;case"<":d=!0,r=e0;){var u=a.shift();t(u),i.add(u.id()),o&&r(a,i,u)}return e}function ps(e,t,n){if(n.isParent())for(var r=n._private.children,a=0;a1&&void 0!==arguments[1])||arguments[1],ps)},hs.forEachUp=function(e){return fs(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],gs)},hs.forEachUpAndDown=function(e){return fs(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],vs)},hs.ancestors=hs.parents,(us=cs={data:Eo.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:Eo.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Eo.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Eo.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Eo.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Eo.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=us.data,us.removeAttr=us.removeData;var ys,ms,bs=cs,xs={};function ws(e){return function(t){var n=this;if(void 0===t&&(t=!0),0!==n.length&&n.isNode()&&!n.removed()){for(var r=0,a=n[0],i=a._private.edges,o=0;ot})),minIndegree:Es("indegree",(function(e,t){return et})),minOutdegree:Es("outdegree",(function(e,t){return et}))}),ye(xs,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r0,c=u;u&&(l=l[0]);var d=c?l.position():{x:0,y:0};return a={x:s.x-d.x,y:s.y-d.y},void 0===e?a:a[e]}for(var h=0;h0,v=g;g&&(p=p[0]);var y=v?p.position():{x:0,y:0};void 0!==t?f.position(e,t+y[e]):void 0!==a&&f.position({x:a.x+y.x,y:a.y+y.y})}}else if(!i)return;return this}},ys.modelPosition=ys.point=ys.position,ys.modelPositions=ys.points=ys.positions,ys.renderedPoint=ys.renderedPosition,ys.relativePoint=ys.relativePosition;var Cs,Ps,Ss=ms,Bs=function(e){switch(e){case"left":case"right-inside":return"left";case"right":case"left-inside":return"right";default:return"center"}},Ds=function(e){switch(e){case"top":case"bottom-inside":return"top";case"bottom":case"top-inside":return"bottom";default:return"center"}};Cs=Ps={},Ps.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),a=n.pan(),i=t.x1*r+a.x,o=t.x2*r+a.x,s=t.y1*r+a.y,l=t.y2*r+a.y;return{x1:i,x2:o,y1:s,y2:l,w:o-i,h:l-s}},Ps.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();return t.styleEnabled()&&t.hasCompoundNodes()?(this.forEachUp((function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,e||t.emitAndNotify("bounds")}})),this):this},Ps.updateCompoundBounds=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes())return this;if(!e&&t.batching())return this;function n(e){if(e.isParent()){var t=e._private,n=e.children(),r="include"===e.pstyle("compound-sizing-wrt-labels").value,a={width:{val:e.pstyle("min-width").pfValue,left:e.pstyle("min-width-bias-left"),right:e.pstyle("min-width-bias-right")},height:{val:e.pstyle("min-height").pfValue,top:e.pstyle("min-height-bias-top"),bottom:e.pstyle("min-height-bias-bottom")}},i=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),o=t.position;0!==i.w&&0!==i.h||((i={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=o.x-i.w/2,i.x2=o.x+i.w/2,i.y1=o.y-i.h/2,i.y2=o.y+i.h/2);var s=a.width.left.value;"px"===a.width.left.units&&a.width.val>0&&(s=100*s/a.width.val);var l=a.width.right.value;"px"===a.width.right.units&&a.width.val>0&&(l=100*l/a.width.val);var u=a.height.top.value;"px"===a.height.top.units&&a.height.val>0&&(u=100*u/a.height.val);var c=a.height.bottom.value;"px"===a.height.bottom.units&&a.height.val>0&&(c=100*c/a.height.val);var d=y(a.width.val-i.w,s,l),h=d.biasDiff,f=d.biasComplementDiff,p=y(a.height.val-i.h,u,c),g=p.biasDiff,v=p.biasComplementDiff;t.autoPadding=function(e,t,n,r){if("%"!==n.units)return"px"===n.units?n.pfValue:0;switch(r){case"width":return e>0?n.pfValue*e:0;case"height":return t>0?n.pfValue*t:0;case"average":return e>0&&t>0?n.pfValue*(e+t)/2:0;case"min":return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case"max":return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}}(i.w,i.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(i.w,a.width.val),o.x=(-h+i.x1+i.x2+f)/2,t.autoHeight=Math.max(i.h,a.height.val),o.y=(-g+i.y1+i.y2+v)/2}function y(e,t,n){var r=0,a=0,i=t+n;return e>0&&i>0&&(r=t/i*e,a=n/i*e),{biasDiff:r,biasComplementDiff:a}}}for(var r=0;re.x2?r:e.x2,e.y1=ne.y2?a:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Ms=function(e,t){return null==t?e:As(e,t.x1,t.y1,t.x2,t.y2)},Rs=function(e,t,n){return ft(e,t,n)},Is=function(e,t,n){if(!t.cy().headless()){var r,a,i=t._private,o=i.rstyle,s=o.arrowWidth/2;if("none"!==t.pstyle(n+"-arrow-shape").value){"source"===n?(r=o.srcX,a=o.srcY):"target"===n?(r=o.tgtX,a=o.tgtY):(r=o.midX,a=o.midY);var l=i.arrowBounds=i.arrowBounds||{},u=l[n]=l[n]||{};u.x1=r-s,u.y1=a-s,u.x2=r+s,u.y2=a+s,u.w=u.x2-u.x1,u.h=u.y2-u.y1,rn(u,1),As(e,u.x1,u.y1,u.x2,u.y2)}}},Ns=function(e,t,n){if(!t.cy().headless()){var r;r=n?n+"-":"";var a=t._private,i=a.rstyle;if(t.pstyle(r+"label").strValue){var o,s,l,u,c=t.pstyle("text-halign"),d=t.pstyle("text-valign"),h=Rs(i,"labelWidth",n),f=Rs(i,"labelHeight",n),p=Rs(i,"labelX",n),g=Rs(i,"labelY",n),v=t.pstyle(r+"text-margin-x").pfValue,y=t.pstyle(r+"text-margin-y").pfValue,m=t.isEdge(),b=t.pstyle(r+"text-rotation"),x=t.pstyle("text-outline-width").pfValue,w=t.pstyle("text-border-width").pfValue/2,E=t.pstyle("text-background-padding").pfValue,k=f,T=h,C=T/2,P=k/2;if(m)o=p-C,s=p+C,l=g-P,u=g+P;else{switch(Bs(c.value)){case"left":o=p-T,s=p;break;case"center":o=p-C,s=p+C;break;case"right":o=p,s=p+T}switch(Ds(d.value)){case"top":l=g-k,u=g;break;case"center":l=g-P,u=g+P;break;case"bottom":l=g,u=g+k}}var S=v-Math.max(x,w)-E-2,B=v+Math.max(x,w)+E+2,D=y-Math.max(x,w)-E-2,_=y+Math.max(x,w)+E+2;o+=S,s+=B,l+=D,u+=_;var A=n||"main",M=a.labelBounds,R=M[A]=M[A]||{};R.x1=o,R.y1=l,R.x2=s,R.y2=u,R.w=s-o,R.h=u-l,R.leftPad=S,R.rightPad=B,R.topPad=D,R.botPad=_;var I=m&&"autorotate"===b.strValue,N=null!=b.pfValue&&0!==b.pfValue;if(I||N){var L=I?Rs(a.rstyle,"labelAngle",n):b.pfValue,z=Math.cos(L),O=Math.sin(L),V=(o+s)/2,F=(l+u)/2;if(!m){switch(Bs(c.value)){case"left":V=s;break;case"right":V=o}switch(Ds(d.value)){case"top":F=u;break;case"bottom":F=l}}var X=function(e,t){return{x:(e-=V)*z-(t-=F)*O+V,y:e*O+t*z+F}},j=X(o,l),Y=X(o,u),q=X(s,l),W=X(s,u);o=Math.min(j.x,Y.x,q.x,W.x),s=Math.max(j.x,Y.x,q.x,W.x),l=Math.min(j.y,Y.y,q.y,W.y),u=Math.max(j.y,Y.y,q.y,W.y)}var U=A+"Rot",H=M[U]=M[U]||{};H.x1=o,H.y1=l,H.x2=s,H.y2=u,H.w=s-o,H.h=u-l,As(e,o,l,s,u),As(a.labelBounds.all,o,l,s,u)}return e}},Ls=function(e,t){if(!t.cy().headless()){var n=t.pstyle("outline-opacity").value,r=t.pstyle("outline-width").value+t.pstyle("outline-offset").value;zs(e,t,n,r,"outside",r/2)}},zs=function(e,t,n,r,a,i){if(!(0===n||r<=0||"inside"===a)){var o=t.cy().renderer(),s=o.nodeShapes[o.getNodeShape(t)];if(s){var l=t.position(),u=l.x,c=l.y,d=t.width(),h=t.height();if(s.hasMiterBounds){"center"===a&&(r/=2);var f=s.miterBounds(u,c,d,h,r);Ms(e,f)}else null!=i&&i>0&&an(e,[i,i,i,i])}}},Os=function(e,t){var n,r,a,i,o,s,l,u=e._private.cy,c=u.styleEnabled(),d=u.headless(),h=tn(),f=e._private,p=e.isNode(),g=e.isEdge(),v=f.rstyle,y=p&&c?e.pstyle("bounds-expansion").pfValue:[0],m=function(e){return"none"!==e.pstyle("display").value},b=!c||m(e)&&(!g||m(e.source())&&m(e.target()));if(b){var x=0;c&&t.includeOverlays&&0!==e.pstyle("overlay-opacity").value&&(x=e.pstyle("overlay-padding").value);var w=0;c&&t.includeUnderlays&&0!==e.pstyle("underlay-opacity").value&&(w=e.pstyle("underlay-padding").value);var E=Math.max(x,w),k=0;if(c&&(k=e.pstyle("width").pfValue/2),p&&t.includeNodes){var T=e.position();o=T.x,s=T.y;var C=e.outerWidth()/2,P=e.outerHeight()/2;As(h,n=o-C,a=s-P,r=o+C,i=s+P),c&&Ls(h,e),c&&t.includeOutlines&&!d&&Ls(h,e),c&&function(e,t){if(!t.cy().headless()){var n=t.pstyle("border-opacity").value,r=t.pstyle("border-width").pfValue,a=t.pstyle("border-position").value;zs(e,t,n,r,a)}}(h,e)}else if(g&&t.includeEdges)if(c&&!d){var S=e.pstyle("curve-style").strValue;if(n=Math.min(v.srcX,v.midX,v.tgtX),r=Math.max(v.srcX,v.midX,v.tgtX),a=Math.min(v.srcY,v.midY,v.tgtY),i=Math.max(v.srcY,v.midY,v.tgtY),As(h,n-=k,a-=k,r+=k,i+=k),"haystack"===S){var B=v.haystackPts;if(B&&2===B.length){if(n=B[0].x,a=B[0].y,n>(r=B[1].x)){var D=n;n=r,r=D}if(a>(i=B[1].y)){var _=a;a=i,i=_}As(h,n-k,a-k,r+k,i+k)}}else if("bezier"===S||"unbundled-bezier"===S||ce(S,"segments")||ce(S,"taxi")){var A;switch(S){case"bezier":case"unbundled-bezier":A=v.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":A=v.linePts}if(null!=A)for(var M=0;M(r=N.x)){var L=n;n=r,r=L}if((a=I.y)>(i=N.y)){var z=a;a=i,i=z}As(h,n-=k,a-=k,r+=k,i+=k)}if(c&&t.includeEdges&&g&&(Is(h,e,"mid-source"),Is(h,e,"mid-target"),Is(h,e,"source"),Is(h,e,"target")),c)if("yes"===e.pstyle("ghost").value){var O=e.pstyle("ghost-offset-x").pfValue,V=e.pstyle("ghost-offset-y").pfValue;As(h,h.x1+O,h.y1+V,h.x2+O,h.y2+V)}var F=f.bodyBounds=f.bodyBounds||{};on(F,h),an(F,y),rn(F,1),c&&(n=h.x1,r=h.x2,a=h.y1,i=h.y2,As(h,n-E,a-E,r+E,i+E));var X=f.overlayBounds=f.overlayBounds||{};on(X,h),an(X,y),rn(X,1);var j=f.labelBounds=f.labelBounds||{};null!=j.all?((l=j.all).x1=1/0,l.y1=1/0,l.x2=-1/0,l.y2=-1/0,l.w=0,l.h=0):j.all=tn(),c&&t.includeLabels&&(t.includeMainLabels&&Ns(h,e,null),g&&(t.includeSourceLabels&&Ns(h,e,"source"),t.includeTargetLabels&&Ns(h,e,"target")))}return h.x1=_s(h.x1),h.y1=_s(h.y1),h.x2=_s(h.x2),h.y2=_s(h.y2),h.w=_s(h.x2-h.x1),h.h=_s(h.y2-h.y1),h.w>0&&h.h>0&&b&&(an(h,y),rn(h,1)),h},Vs=function(e){var t=0,n=function(e){return(e?1:0)<0&&void 0!==arguments[0]?arguments[0]:il,t=arguments.length>1?arguments[1]:void 0,n=0;n=0;s--)o(s);return this},sl.removeAllListeners=function(){return this.removeListener("*")},sl.emit=sl.trigger=function(e,t,n){var r=this.listeners,a=r.length;return this.emitting++,H(t)||(t=[t]),cl(this,(function(e,i){null!=n&&(r=[{event:i.event,type:i.type,namespace:i.namespace,callback:n}],a=r.length);for(var o=function(){var n=r[s];if(n.type===i.type&&(!n.namespace||n.namespace===i.namespace||".*"===n.namespace)&&e.eventMatches(e.context,n,i)){var a=[i];null!=t&&function(e,t){for(var n=0;n1&&!r){var a=this.length-1,i=this[a],o=i._private.data.id;this[a]=void 0,this[e]=i,n.set(o,{ele:i,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var a=r.index;return this.unmergeAt(a),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&W(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r=0;t--){e(this[t])&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],r=this,a=0;ar&&(r=s,n=o)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,a=this,i=0;i=0&&a1&&void 0!==arguments[1])||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n){n._private.styleDirty&&(n._private.styleDirty=!1,r.style().apply(n));var a=n._private.style[e];return null!=a?a:t?r.style().getDefaultProperty(e):null}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return void 0!==n.pfValue?n.pfValue:n.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled())return t?t.pstyle(e).units:void 0},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];return n?t.style().getRenderedStyle(n,e):void 0},style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=!1,a=n.style();if(K(e)){var i=e;a.applyBypass(this,i,r),this.emitAndNotify("style")}else if(W(e)){if(void 0===t){var o=this[0];return o?a.getStylePropertyValue(o,e):void 0}a.applyBypass(this,e,t,r),this.emitAndNotify("style")}else if(void 0===e){var s=this[0];return s?a.getRawStyle(s):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,r=t.style(),a=this;if(void 0===e)for(var i=0;i0&&t.push(c[0]),t.push(s[0])}return this.spawn(t,!0).filter(e)}),"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),Nl.neighbourhood=Nl.neighborhood,Nl.closedNeighbourhood=Nl.closedNeighborhood,Nl.openNeighbourhood=Nl.openNeighborhood,ye(Nl,{source:ds((function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t}),"source"),target:ds((function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t}),"target"),sources:Vl({attr:"source"}),targets:Vl({attr:"target"})}),ye(Nl,{edgesWith:ds(Fl(),"edgesWith"),edgesTo:ds(Fl({thisIsSrc:!0}),"edgesTo")}),ye(Nl,{connectedEdges:ds((function(e){for(var t=[],n=0;n0);return i},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),Nl.componentsOf=Nl.components;var jl=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(void 0!==e){var a=new gt,i=!1;if(t){if(t.length>0&&K(t[0])&&!J(t[0])){i=!0;for(var o=[],s=new yt,l=0,u=t.length;l0&&void 0!==arguments[0])||arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=this,i=a.cy(),o=i._private,s=[],l=[],u=0,c=a.length;u0){for(var I=e.length===a.length?a:new jl(i,e),N=0;N0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this,r=[],a={},i=n._private.cy;function o(e){var n=a[e.id()];t&&e.removed()||n||(a[e.id()]=!0,e.isNode()?(r.push(e),function(e){for(var t=e._private.edges,n=0;n0&&(e?k.emitAndNotify("remove"):t&&k.emit("remove"));for(var T=0;T=.001?function(t,r){for(var a=0;a<4;++a){var i=h(r,e,n);if(0===i)return r;r-=(d(r,e,n)-t)/i}return r}(t,o):0===l?o:function(t,r,a){var i,o,s=0;do{(i=d(o=r+(a-r)/2,e,n)-t)>0?a=o:r=o}while(Math.abs(i)>1e-7&&++s<10);return o}(t,r,r+a)}var p=!1;function g(){p=!0,e===t&&n===r||function(){for(var t=0;t<11;++t)s[t]=d(t*a,e,n)}()}var v=function(a){return p||g(),e===t&&n===r?a:0===a?0:1===a?1:d(f(a),t,r)};v.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var y="generateBezier("+[e,t,n,r]+")";return v.toString=function(){return y},v} -/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var Ul=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,n,r){var a={x:t.x+r.dx*n,v:t.v+r.dv*n,tension:t.tension,friction:t.friction};return{dx:a.v,dv:e(a)}}function n(n,r){var a={dx:n.v,dv:e(n)},i=t(n,.5*r,a),o=t(n,.5*r,i),s=t(n,r,o),l=1/6*(a.dx+2*(i.dx+o.dx)+s.dx),u=1/6*(a.dv+2*(i.dv+o.dv)+s.dv);return n.x=n.x+l*r,n.v=n.v+u*r,n}return function e(t,r,a){var i,o,s,l={x:-1,v:0,tension:null,friction:null},u=[0],c=0,d=1e-4;for(t=parseFloat(t)||500,r=parseFloat(r)||20,a=a||null,l.tension=t,l.friction=r,o=(i=null!==a)?(c=e(t,r))/a*.016:.016;s=n(s||l,o),u.push(1+s.x),c+=16,Math.abs(s.x)>d&&Math.abs(s.v)>d;);return i?function(e){return u[e*(u.length-1)|0]}:c}}(),Hl=function(e,t,n,r){var a=Wl(e,t,n,r);return function(e,t,n){return e+(t-e)*a(n)}},Kl={linear:function(e,t,n){return e+(t-e)*n},ease:Hl(.25,.1,.25,1),"ease-in":Hl(.42,0,1,1),"ease-out":Hl(0,0,.58,1),"ease-in-out":Hl(.42,0,.58,1),"ease-in-sine":Hl(.47,0,.745,.715),"ease-out-sine":Hl(.39,.575,.565,1),"ease-in-out-sine":Hl(.445,.05,.55,.95),"ease-in-quad":Hl(.55,.085,.68,.53),"ease-out-quad":Hl(.25,.46,.45,.94),"ease-in-out-quad":Hl(.455,.03,.515,.955),"ease-in-cubic":Hl(.55,.055,.675,.19),"ease-out-cubic":Hl(.215,.61,.355,1),"ease-in-out-cubic":Hl(.645,.045,.355,1),"ease-in-quart":Hl(.895,.03,.685,.22),"ease-out-quart":Hl(.165,.84,.44,1),"ease-in-out-quart":Hl(.77,0,.175,1),"ease-in-quint":Hl(.755,.05,.855,.06),"ease-out-quint":Hl(.23,1,.32,1),"ease-in-out-quint":Hl(.86,0,.07,1),"ease-in-expo":Hl(.95,.05,.795,.035),"ease-out-expo":Hl(.19,1,.22,1),"ease-in-out-expo":Hl(1,0,0,1),"ease-in-circ":Hl(.6,.04,.98,.335),"ease-out-circ":Hl(.075,.82,.165,1),"ease-in-out-circ":Hl(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return Kl.linear;var r=Ul(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":Hl};function Gl(e,t,n,r,a){if(1===r)return n;if(t===n)return n;var i=a(t,n,r);return null==e||((e.roundValue||e.color)&&(i=Math.round(i)),void 0!==e.min&&(i=Math.max(i,e.min)),void 0!==e.max&&(i=Math.min(i,e.max))),i}function Zl(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function $l(e,t,n,r,a){var i=null!=a?a.type:null;n<0?n=0:n>1&&(n=1);var o=Zl(e,a),s=Zl(t,a);if(G(o)&&G(s))return Gl(i,o,s,n,r);if(H(o)&&H(s)){for(var l=[],u=0;u0?("spring"===d&&h.push(o.duration),o.easingImpl=Kl[d].apply(null,h)):o.easingImpl=Kl[d]}var f,p=o.easingImpl;if(f=0===o.duration?1:(n-l)/o.duration,o.applying&&(f=o.progress),f<0?f=0:f>1&&(f=1),null==o.delay){var g=o.startPosition,v=o.position;if(v&&a&&!e.locked()){var y={};Jl(g.x,v.x)&&(y.x=$l(g.x,v.x,f,p)),Jl(g.y,v.y)&&(y.y=$l(g.y,v.y,f,p)),e.position(y)}var m=o.startPan,b=o.pan,x=i.pan,w=null!=b&&r;w&&(Jl(m.x,b.x)&&(x.x=$l(m.x,b.x,f,p)),Jl(m.y,b.y)&&(x.y=$l(m.y,b.y,f,p)),e.emit("pan"));var E=o.startZoom,k=o.zoom,T=null!=k&&r;T&&(Jl(E,k)&&(i.zoom=en(i.minZoom,$l(E,k,f,p),i.maxZoom)),e.emit("zoom")),(w||T)&&e.emit("viewport");var C=o.style;if(C&&C.length>0&&a){for(var P=0;P=0;t--){(0,e[t])()}e.splice(0,e.length)},c=i.length-1;c>=0;c--){var d=i[c],h=d._private;h.stopped?(i.splice(c,1),h.hooked=!1,h.playing=!1,h.started=!1,u(h.frames)):(h.playing||h.applying)&&(h.playing&&h.applying&&(h.applying=!1),h.started||eu(0,d,e),Ql(t,d,e,n),h.applying&&(h.applying=!1),u(h.frames),null!=h.step&&h.step(e),d.completed()&&(i.splice(c,1),h.hooked=!1,h.playing=!1,h.started=!1,u(h.completes)),s=!0)}return n||0!==i.length||0!==o.length||r.push(t),s}for(var i=!1,o=0;o0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var nu={animate:Eo.animate(),animation:Eo.animation(),animated:Eo.animated(),clearQueue:Eo.clearQueue(),delay:Eo.delay(),delayAnimation:Eo.delayAnimation(),stop:Eo.stop(),addToAnimationPool:function(e){this.styleEnabled()&&this._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,e.styleEnabled()){var t=e.renderer();t&&t.beforeRender?t.beforeRender((function(t,n){tu(n,e)}),t.beforeRenderPriorities.animations):function t(){e._private.animationsRunning&&Ne((function(n){tu(n,e),t()}))}()}}},ru={qualifierCompare:function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return null==r||e!==n.target&&J(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e}},au=function(e){return W(e)?new os(e):e},iu={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new ol(ru,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,au(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,au(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,au(t),n),this},once:function(e,t,n){return this.emitter().one(e,au(t),n),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};Eo.eventAliasesOn(iu);var ou={png:function(e){return e=e||{},this._private.renderer.png(e)},jpg:function(e){var t=this._private.renderer;return(e=e||{}).bg=e.bg||"#fff",t.jpg(e)}};ou.jpeg=ou.jpg;var su={layout:function(e){var t=this;if(null!=e)if(null!=e.name){var n=e.name,r=t.extension("layout",n);if(null!=r){var a;a=W(e.eles)?t.$(e.eles):null!=e.eles?e.eles:t.$();var i=new r(ye({},e,{cy:t,eles:a}));return i}rt("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?")}else rt("A `name` must be specified to make a layout");else rt("Layout options must be specified to make a layout")}};su.createLayout=su.makeLayout=su.layout;var lu={notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();null!=t&&r.merge(t)}else if(n.notificationsEnabled){var a=this.renderer();!this.destroyed()&&a&&a.notify(e,t)}},notifications:function(e){var t=this._private;return void 0===e?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return null==e.batchCount&&(e.batchCount=0),0===e.batchCount&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(0===e.batchCount)return this;if(e.batchCount--,0===e.batchCount){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach((function(n){var r=e.batchNotifications[n];r.empty()?t.notify(n):t.notify(n,r)}))}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch((function(){for(var n=Object.keys(e),r=0;r0;)t.removeChild(t.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach((function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]}))},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};cu.invalidateDimensions=cu.resize;var du={collection:function(e,t){return W(e)?this.$(e):Q(e)?e.collection():H(e)?(t||(t={}),new jl(this,e,t.unique,t.removed)):new jl(this)},nodes:function(e){var t=this.$((function(e){return e.isNode()}));return e?t.filter(e):t},edges:function(e){var t=this.$((function(e){return e.isEdge()}));return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};du.elements=du.filter=du.$;var hu={},fu="t";hu.apply=function(e){for(var t=this,n=t._private.cy.collection(),r=0;r0;if(h||d&&f){var p=void 0;h&&f||h?p=u.properties:f&&(p=u.mappedProperties);for(var g=0;g1&&(v=1),s.color){var w=a.valueMin[0],E=a.valueMax[0],k=a.valueMin[1],T=a.valueMax[1],C=a.valueMin[2],P=a.valueMax[2],S=null==a.valueMin[3]?1:a.valueMin[3],B=null==a.valueMax[3]?1:a.valueMax[3],D=[Math.round(w+(E-w)*v),Math.round(k+(T-k)*v),Math.round(C+(P-C)*v),Math.round(S+(B-S)*v)];n={bypass:a.bypass,name:a.name,value:D,strValue:"rgb("+D[0]+", "+D[1]+", "+D[2]+")"}}else{if(!s.number)return!1;var _=a.valueMin+(a.valueMax-a.valueMin)*v;n=this.parse(a.name,_,a.bypass,h)}if(!n)return g(),!1;n.mapping=a,a=n;break;case o.data:for(var A=a.field.split("."),M=d.data,R=0;R0&&i>0){for(var s={},l=!1,u=0;u0?e.delayAnimation(o).play().promise().then(t):t()})).then((function(){return e.animation({style:s,duration:i,easing:e.pstyle("transition-timing-function").value,queue:!1}).play().promise()})).then((function(){n.removeBypasses(e,a),e.emitAndNotify("style"),r.transitioning=!1}))}else r.transitioning&&(this.removeBypasses(e,a),e.emitAndNotify("style"),r.transitioning=!1)},hu.checkTrigger=function(e,t,n,r,a,i){var o=this.properties[t],s=a(o);e.removed()||null!=s&&s(n,r,e)&&i(o)},hu.checkZOrderTrigger=function(e,t,n,r){var a=this;this.checkTrigger(e,t,n,r,(function(e){return e.triggersZOrder}),(function(){a._private.cy.notify("zorder",e)}))},hu.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBounds}),(function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()}))},hu.checkConnectedEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBoundsOfConnectedEdges}),(function(t){e.connectedEdges().forEach((function(e){e.dirtyBoundingBoxCache()}))}))},hu.checkParallelEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBoundsOfParallelEdges}),(function(t){e.parallelEdges().forEach((function(e){e.dirtyBoundingBoxCache()}))}))},hu.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r),this.checkConnectedEdgesBoundsTrigger(e,t,n,r),this.checkParallelEdgesBoundsTrigger(e,t,n,r)};var pu={applyBypass:function(e,t,n,r){var a=[];if("*"===t||"**"===t){if(void 0!==n)for(var i=0;it.length?i.substr(t.length):""}function s(){n=n.length>r.length?n.substr(r.length):""}for(i=i.replace(/[/][*](\s|.)+?[*][/]/g,"");;){if(i.match(/^\s*$/))break;var l=i.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!l){it("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+i);break}t=l[0];var u=l[1];if("core"!==u)if(new os(u).invalid){it("Skipping parsing of block: Invalid selector found in string stylesheet: "+u),o();continue}var c=l[2],d=!1;n=c;for(var h=[];;){if(n.match(/^\s*$/))break;var f=n.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!f){it("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+c),d=!0;break}r=f[0];var p=f[1],g=f[2];if(this.properties[p])a.parse(p,g)?(h.push({name:p,val:g}),s()):(it("Skipping property: Invalid property definition in: "+r),s());else it("Skipping property: Invalid property name in: "+r),s()}if(d){o();break}a.selector(u);for(var v=0;v=7&&"d"===t[0]&&(u=new RegExp(s.data.regex).exec(t))){if(n)return!1;var h=s.data;return{name:e,value:u,strValue:""+t,mapped:h,field:u[1],bypass:n}}if(t.length>=10&&"m"===t[0]&&(c=new RegExp(s.mapData.regex).exec(t))){if(n)return!1;if(d.multiple)return!1;var f=s.mapData;if(!d.color&&!d.number)return!1;var p=this.parse(e,c[4]);if(!p||p.mapped)return!1;var g=this.parse(e,c[5]);if(!g||g.mapped)return!1;if(p.pfValue===g.pfValue||p.strValue===g.strValue)return it("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+p.strValue+"`"),this.parse(e,p.strValue);if(d.color){var v=p.value,y=g.value;if(!(v[0]!==y[0]||v[1]!==y[1]||v[2]!==y[2]||v[3]!==y[3]&&(null!=v[3]&&1!==v[3]||null!=y[3]&&1!==y[3])))return!1}return{name:e,value:c,strValue:""+t,mapped:f,field:c[1],fieldMin:parseFloat(c[2]),fieldMax:parseFloat(c[3]),valueMin:p.value,valueMax:g.value,bypass:n}}}if(d.multiple&&"multiple"!==r){var m;if(m=l?t.split(/\s+/):H(t)?t:[t],d.evenMultiple&&m.length%2!=0)return null;for(var b=[],x=[],w=[],E="",k=!1,T=0;T0?" ":"")+C.strValue}return d.validate&&!d.validate(b,x)?null:d.singleEnum&&k?1===b.length&&W(b[0])?{name:e,value:b[0],strValue:b[0],bypass:n}:null:{name:e,value:b,pfValue:w,strValue:E,bypass:n,units:x}}var P,S=function(){for(var r=0;rd.max||d.strictMax&&t===d.max))return null;var M={name:e,value:t,strValue:""+t+(B||""),units:B,bypass:n};return d.unitless||"px"!==B&&"em"!==B?M.pfValue=t:M.pfValue="px"!==B&&B?this.getEmSizeInPixels()*t:t,"ms"!==B&&"s"!==B||(M.pfValue="ms"===B?t:1e3*t),"deg"!==B&&"rad"!==B||(M.pfValue="rad"===B?t:(P=t,Math.PI*P/180)),"%"===B&&(M.pfValue=t/100),M}if(d.propList){var R=[],I=""+t;if("none"===I);else{for(var N=I.split(/\s*,\s*|\s+/),L=0;L0&&l>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0)return{zoom:o=(o=(o=Math.min((s-2*t)/n.w,(l-2*t)/n.h))>this._private.maxZoom?this._private.maxZoom:o)=n.minZoom&&(n.maxZoom=t),this},minZoom:function(e){return void 0===e?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return void 0===e?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var t,n,r=this._private,a=r.pan,i=r.zoom,o=!1;if(r.zoomingEnabled||(o=!0),G(e)?n=e:K(e)&&(n=e.level,null!=e.position?t=jt(e.position,i,a):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)t.maxZoom||!t.zoomingEnabled?i=!0:(t.zoom=s,a.push("zoom"))}if(r&&(!i||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;G(l.x)&&(t.pan.x=l.x,o=!1),G(l.y)&&(t.pan.y=l.y,o=!1),o||a.push("pan")}return a.length>0&&(a.push("viewport"),this.emit(a.join(" ")),this.notify("viewport")),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(W(e)){var n=e;e=this.mutableElements().filter(n)}else Q(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),a=this.width(),i=this.height();return{x:(a-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(i-t*(r.y1+r.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e,t,n=this._private,r=n.container,a=this;return n.sizeCache=n.sizeCache||(r?(e=a.window().getComputedStyle(r),t=function(t){return parseFloat(e.getPropertyValue(t))},{width:r.clientWidth-t("padding-left")-t("padding-right"),height:r.clientHeight-t("padding-top")-t("padding-bottom")}):{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,n=this.renderedExtent(),r={x1:(n.x1-e.x)/t,x2:(n.x2-e.x)/t,y1:(n.y1-e.y)/t,y2:(n.y2-e.y)/t};return r.w=r.x2-r.x1,r.h=r.y2-r.y1,r},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},multiClickDebounceTime:function(e){return e?(this._private.multiClickDebounceTime=e,this):this._private.multiClickDebounceTime}};Tu.centre=Tu.center,Tu.autolockNodes=Tu.autolock,Tu.autoungrabifyNodes=Tu.autoungrabify;var Cu={data:Eo.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Eo.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Eo.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Eo.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Cu.attr=Cu.data,Cu.removeAttr=Cu.removeData;var Pu=function(e){var t=this,n=(e=ye({},e)).container;n&&!$(n)&&$(n[0])&&(n=n[0]);var r=n?n._cyreg:null;(r=r||{})&&r.cy&&(r.cy.destroy(),r={});var a=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var i=void 0!==c&&void 0!==n&&!e.headless,o=e;o.layout=ye({name:i?"grid":"null"},o.layout),o.renderer=ye({name:i?"canvas":"null"},o.renderer);var s=function(e,t,n){return void 0!==t?t:void 0!==n?n:e},l=this._private={container:n,ready:!1,options:o,elements:new jl(this),listeners:[],aniEles:new jl(this),data:o.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:void 0===o.styleEnabled?i:o.styleEnabled,zoom:G(o.zoom)?o.zoom:1,pan:{x:K(o.pan)&&G(o.pan.x)?o.pan.x:0,y:K(o.pan)&&G(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:s(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});l.styleEnabled&&t.setStyle([]);var u=ye({},o,o.renderer);t.initRenderer(u);!function(e,t){if(e.some(ae))return Gr.all(e).then(t);t(e)}([o.style,o.elements],(function(e){var n=e[0],i=e[1];l.styleEnabled&&t.style().append(n),function(e,n,r){t.notifications(!1);var a=t.mutableElements();a.length>0&&a.remove(),null!=e&&(K(e)||H(e))&&t.add(e),t.one("layoutready",(function(e){t.notifications(!0),t.emit(e),t.one("load",n),t.emitAndNotify("load")})).one("layoutstop",(function(){t.one("done",r),t.emit("done")}));var i=ye({},t._private.options.layout);i.eles=t.elements(),t.layout(i).run()}(i,(function(){t.startAnimationLoop(),l.ready=!0,U(o.ready)&&t.on("ready",o.ready);for(var e=0;e0,l=!!t.boundingBox,u=tn(l?t.boundingBox:structuredClone(n.extent()));if(Q(t.roots))e=t.roots;else if(H(t.roots)){for(var c=[],d=0;d0;){var B=C.shift(),D=T(B,P);if(D)B.outgoers().filter((function(e){return e.isNode()&&r.has(e)})).forEach(S);else if(null===D){it("Detected double maximal shift for node `"+B.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var _=0;if(t.avoidOverlap)for(var A=0;A0&&y[0].length<=3?i/2:0),s=2*Math.PI/y[r].length*a;return 0===r&&1===y[0].length&&(o=1),{x:q+o*Math.cos(s),y:U+o*Math.sin(s)}}var c=y[r].length,d=Math.max(1===c?0:l?(u.w-2*t.padding-K.w)/((t.grid?Z:c)-1):(u.w-2*t.padding-K.w)/((t.grid?Z:c)+1),_);return{x:q+(a+1-(c+1)/2)*d,y:U+(r+1-(O+1)/2)*G}}(e),u,$[t.direction])})),this};var Ru={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function Iu(e){this.options=ye({},Ru,e)}Iu.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,a=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,i=r.nodes().not(":parent");t.sort&&(i=i.sort(t.sort));for(var o,s=tn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),l=s.x1+s.w/2,u=s.y1+s.h/2,c=(void 0===t.sweep?2*Math.PI-2*Math.PI/i.length:t.sweep)/Math.max(1,i.length-1),d=0,h=0;h1&&t.avoidOverlap){d*=1.75;var v=Math.cos(c)-Math.cos(0),y=Math.sin(c)-Math.sin(0),m=Math.sqrt(d*d/(v*v+y*y));o=Math.max(m,o)}return r.nodes().layoutPositions(this,t,(function(e,n){var r=t.startAngle+n*c*(a?1:-1),i=o*Math.cos(r),s=o*Math.sin(r);return{x:l+i,y:u+s}})),this};var Nu,Lu={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function zu(e){this.options=ye({},Lu,e)}zu.prototype.run=function(){for(var e=this.options,t=e,n=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,r=e.cy,a=t.eles,i=a.nodes().not(":parent"),o=tn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s=o.x1+o.w/2,l=o.y1+o.h/2,u=[],c=0,d=0;d0)Math.abs(m[0].value-x.value)>=v&&(m=[],y.push(m));m.push(x)}var w=c+t.minNodeSpacing;if(!t.avoidOverlap){var E=y.length>0&&y[0].length>1,k=(Math.min(o.w,o.h)/2-w)/(y.length+E?1:0);w=Math.min(w,k)}for(var T=0,C=0;C1&&t.avoidOverlap){var D=Math.cos(B)-Math.cos(0),_=Math.sin(B)-Math.sin(0),A=Math.sqrt(w*w/(D*D+_*_));T=Math.max(A,T)}P.r=T,T+=w}if(t.equidistant){for(var M=0,R=0,I=0;I=e.numIter)&&(Uu(r,e),r.temperature=r.temperature*e.coolingFactor,!(r.temperature=e.animationThreshold&&i(),Ne(c)):(ac(r,e),s())};c()}else{for(;u;)u=o(l),l++;ac(r,e),s()}return this},Vu.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},Vu.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Fu=function(e,t,n){for(var r=n.eles.edges(),a=n.eles.nodes(),i=tn(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:a.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:i.w,clientHeight:i.h,boundingBox:i},s=n.eles.components(),l={},u=0;u0){o.graphSet.push(w);for(u=0;ur.count?0:r.graph},ju=function(e,t,n,r){var a=r.graphSet[n];if(-10)var s=(u=r.nodeOverlap*o)*a/(g=Math.sqrt(a*a+i*i)),l=u*i/g;else{var u,c=$u(e,a,i),d=$u(t,-1*a,-1*i),h=d.x-c.x,f=d.y-c.y,p=h*h+f*f,g=Math.sqrt(p);s=(u=(e.nodeRepulsion+t.nodeRepulsion)/p)*h/g,l=u*f/g}e.isLocked||(e.offsetX-=s,e.offsetY-=l),t.isLocked||(t.offsetX+=s,t.offsetY+=l)}},Zu=function(e,t,n,r){if(n>0)var a=e.maxX-t.minX;else a=t.maxX-e.minX;if(r>0)var i=e.maxY-t.minY;else i=t.maxY-e.minY;return a>=0&&i>=0?Math.sqrt(a*a+i*i):0},$u=function(e,t,n){var r=e.positionX,a=e.positionY,i=e.height||1,o=e.width||1,s=n/t,l=i/o,u={};return 0===t&&0n?(u.x=r,u.y=a+i/2,u):0t&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=a-o*n/2/t,u):0=l)?(u.x=r+i*t/2/n,u.y=a+i/2,u):0>n&&(s<=-1*l||s>=l)?(u.x=r-i*t/2/n,u.y=a-i/2,u):u},Qu=function(e,t){for(var n=0;n1){var p=t.gravity*d/f,g=t.gravity*h/f;c.offsetX+=p,c.offsetY+=g}}}}},ec=function(e,t){var n=[],r=0,a=-1;for(n.push.apply(n,e.graphSet[0]),a+=e.graphSet[0].length;r<=a;){var i=n[r++],o=e.idToIndex[i],s=e.layoutNodes[o],l=s.children;if(0n)var a={x:n*e/r,y:n*t/r};else a={x:e,y:t};return a},rc=function(e,t){var n=e.parentId;if(null!=n){var r=t.layoutNodes[t.idToIndex[n]],a=!1;return(null==r.maxX||e.maxX+r.padRight>r.maxX)&&(r.maxX=e.maxX+r.padRight,a=!0),(null==r.minX||e.minX-r.padLeftr.maxY)&&(r.maxY=e.maxY+r.padBottom,a=!0),(null==r.minY||e.minY-r.padTopp&&(d+=f+t.componentSpacing,c=0,h=0,f=0)}}},ic={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function oc(e){this.options=ye({},ic,e)}oc.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,a=r.nodes().not(":parent");t.sort&&(a=a.sort(t.sort));var i=tn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(0===i.h||0===i.w)r.nodes().layoutPositions(this,t,(function(e){return{x:i.x1,y:i.y1}}));else{var o=a.size(),s=Math.sqrt(o*i.h/i.w),l=Math.round(s),u=Math.round(i.w/i.h*s),c=function(e){if(null==e)return Math.min(l,u);Math.min(l,u)==l?l=e:u=e},d=function(e){if(null==e)return Math.max(l,u);Math.max(l,u)==l?l=e:u=e},h=t.rows,f=null!=t.cols?t.cols:t.columns;if(null!=h&&null!=f)l=h,u=f;else if(null!=h&&null==f)l=h,u=Math.ceil(o/l);else if(null==h&&null!=f)u=f,l=Math.ceil(o/u);else if(u*l>o){var p=c(),g=d();(p-1)*g>=o?c(p-1):(g-1)*p>=o&&d(g-1)}else for(;u*l=o?d(y+1):c(v+1)}var m=i.w/u,b=i.h/l;if(t.condense&&(m=0,b=0),t.avoidOverlap)for(var x=0;x=u&&(A=0,_++)},R={},I=0;I(r=yn(e,t,x[w],x[w+1],x[w+2],x[w+3])))return v(n,r),!0}else if("bezier"===i.edgeType||"multibezier"===i.edgeType||"self"===i.edgeType||"compound"===i.edgeType)for(x=i.allpts,w=0;w+5(r=vn(e,t,x[w],x[w+1],x[w+2],x[w+3],x[w+4],x[w+5])))return v(n,r),!0;m=m||a.source,b=b||a.target;var E=o.getArrowWidth(l,c),k=[{name:"source",x:i.arrowStartX,y:i.arrowStartY,angle:i.srcArrowAngle},{name:"target",x:i.arrowEndX,y:i.arrowEndY,angle:i.tgtArrowAngle},{name:"mid-source",x:i.midX,y:i.midY,angle:i.midsrcArrowAngle},{name:"mid-target",x:i.midX,y:i.midY,angle:i.midtgtArrowAngle}];for(w=0;w0&&(y(m),y(b))}function b(e,t,n){return ft(e,t,n)}function x(n,r){var a,i=n._private,o=p;a=r?r+"-":"",n.boundingBox();var s=i.labelBounds[r||"main"],l=n.pstyle(a+"label").value;if("yes"===n.pstyle("text-events").strValue&&l){var u=b(i.rscratch,"labelX",r),c=b(i.rscratch,"labelY",r),d=b(i.rscratch,"labelAngle",r),h=n.pstyle(a+"text-margin-x").pfValue,f=n.pstyle(a+"text-margin-y").pfValue,g=s.x1-o-h,y=s.x2+o-h,m=s.y1-o-f,x=s.y2+o-f;if(d){var w=Math.cos(d),E=Math.sin(d),k=function(e,t){return{x:(e-=u)*w-(t-=c)*E+u,y:e*E+t*w+c}},T=k(g,m),C=k(g,x),P=k(y,m),S=k(y,x),B=[T.x+h,T.y+f,P.x+h,P.y+f,S.x+h,S.y+f,C.x+h,C.y+f];if(mn(e,t,B))return v(n),!0}else if(ln(s,e,t))return v(n),!0}}n&&(l=l.interactive);for(var w=l.length-1;w>=0;w--){var E=l[w];E.isNode()?y(E)||x(E):m(E)||x(E)||x(E,"source")||x(E,"target")}return u},getAllInBox:function(e,t,n,r){var a=this.getCachedZSortedEles().interactive,o=2/this.cy.zoom(),s=[],l=Math.min(e,n),u=Math.max(e,n),c=Math.min(t,r),d=Math.max(t,r),h=tn({x1:e=l,y1:t=c,x2:n=u,y2:r=d}),f=[{x:h.x1,y:h.y1},{x:h.x2,y:h.y1},{x:h.x2,y:h.y2},{x:h.x1,y:h.y2}],p=[[f[0],f[1]],[f[1],f[2]],[f[2],f[3]],[f[3],f[0]]];function g(e,t,n){return ft(e,t,n)}function v(e,t){var n=e._private,r=o;e.boundingBox();var a=n.labelBounds.main;if(!a)return null;var i=g(n.rscratch,"labelX",t),s=g(n.rscratch,"labelY",t),l=g(n.rscratch,"labelAngle",t),u=e.pstyle("text-margin-x").pfValue,c=e.pstyle("text-margin-y").pfValue,d=a.x1-r-u,h=a.x2+r-u,f=a.y1-r-c,p=a.y2+r-c;if(l){var v=Math.cos(l),y=Math.sin(l),m=function(e,t){return{x:(e-=i)*v-(t-=s)*y+i,y:e*y+t*v+s}};return[m(d,f),m(h,f),m(h,p),m(d,p)]}return[{x:d,y:f},{x:h,y:f},{x:h,y:p},{x:d,y:p}]}function y(e,t,n,r){function a(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return a(e,n,r)!==a(t,n,r)&&a(e,t,n)!==a(e,t,r)}for(var m=0;m0?-(Math.PI-i.ang):Math.PI+i.ang),Vc(t,n,Oc),Ec=zc.nx*Oc.ny-zc.ny*Oc.nx,kc=zc.nx*Oc.nx-zc.ny*-Oc.ny,Pc=Math.asin(Math.max(-1,Math.min(1,Ec))),Math.abs(Pc)<1e-6)return xc=t.x,wc=t.y,void(Bc=_c=0);Tc=1,Cc=!1,kc<0?Pc<0?Pc=Math.PI+Pc:(Pc=Math.PI-Pc,Tc=-1,Cc=!0):Pc>0&&(Tc=-1,Cc=!0),_c=void 0!==t.radius?t.radius:r,Sc=Pc/2,Ac=Math.min(zc.len/2,Oc.len/2),a?(Dc=Math.abs(Math.cos(Sc)*_c/Math.sin(Sc)))>Ac?(Dc=Ac,Bc=Math.abs(Dc*Math.sin(Sc)/Math.cos(Sc))):Bc=_c:(Dc=Math.min(Ac,_c),Bc=Math.abs(Dc*Math.sin(Sc)/Math.cos(Sc))),Ic=t.x+Oc.nx*Dc,Nc=t.y+Oc.ny*Dc,xc=Ic-Oc.ny*Bc*Tc,wc=Nc+Oc.nx*Bc*Tc,Mc=t.x+zc.nx*Dc,Rc=t.y+zc.ny*Dc,Lc=t};function Xc(e,t){0===t.radius?e.lineTo(t.cx,t.cy):e.arc(t.cx,t.cy,t.radius,t.startAngle,t.endAngle,t.counterClockwise)}function jc(e,t,n,r){var a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return 0===r||0===t.radius?{cx:t.x,cy:t.y,radius:0,startX:t.x,startY:t.y,stopX:t.x,stopY:t.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(Fc(e,t,n,r,a),{cx:xc,cy:wc,radius:Bc,startX:Mc,startY:Rc,stopX:Ic,stopY:Nc,startAngle:zc.ang+Math.PI/2*Tc,endAngle:Oc.ang-Math.PI/2*Tc,counterClockwise:Cc})}var Yc=.01,qc=Math.sqrt(.02),Wc={};function Uc(e){var t=[];if(null!=e){for(var n=0;n0?Math.max(e-t,0):Math.min(e+t,0)},S=P(T,E),B=P(C,k),D=!1;"auto"===v?g=Math.abs(S)>Math.abs(B)?a:r:v===l||v===s?(g=r,D=!0):v!==i&&v!==o||(g=a,D=!0);var _,A=g===r,M=A?B:S,R=A?C:T,I=Kt(R),N=!1;(D&&(m||x)||!(v===s&&R<0||v===l&&R>0||v===i&&R>0||v===o&&R<0)||(M=(I*=-1)*Math.abs(M),N=!0),m)?_=(b<0?1+b:b)*M:_=(b<0?M:0)+b*I;var L=function(e){return Math.abs(e)=Math.abs(M)},z=L(_),O=L(Math.abs(M)-Math.abs(_));if((z||O)&&!N)if(A){var V=Math.abs(R)<=d/2,F=Math.abs(T)<=h/2;if(V){var X=(u.x1+u.x2)/2,j=u.y1,Y=u.y2;n.segpts=[X,j,X,Y]}else if(F){var q=(u.y1+u.y2)/2,W=u.x1,U=u.x2;n.segpts=[W,q,U,q]}else n.segpts=[u.x1,u.y2]}else{var H=Math.abs(R)<=c/2,K=Math.abs(C)<=f/2;if(H){var G=(u.y1+u.y2)/2,Z=u.x1,$=u.x2;n.segpts=[Z,G,$,G]}else if(K){var Q=(u.x1+u.x2)/2,J=u.y1,ee=u.y2;n.segpts=[Q,J,Q,ee]}else n.segpts=[u.x2,u.y1]}else if(A){var te=u.y1+_+(p?d/2*I:0),ne=u.x1,re=u.x2;n.segpts=[ne,te,re,te]}else{var ae=u.x1+_+(p?c/2*I:0),ie=u.y1,oe=u.y2;n.segpts=[ae,ie,ae,oe]}if(n.isRound){var se=e.pstyle("taxi-radius").value,le="arc-radius"===e.pstyle("radius-type").value[0];n.radii=new Array(n.segpts.length/2).fill(se),n.isArcRadius=new Array(n.segpts.length/2).fill(le)}},Wc.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if("bezier"===n.edgeType){var r=t.srcPos,a=t.tgtPos,i=t.srcW,o=t.srcH,s=t.tgtW,l=t.tgtH,u=t.srcShape,c=t.tgtShape,d=t.srcCornerRadius,h=t.tgtCornerRadius,f=t.srcRs,p=t.tgtRs,g=!G(n.startX)||!G(n.startY),v=!G(n.arrowStartX)||!G(n.arrowStartY),y=!G(n.endX)||!G(n.endY),m=!G(n.arrowEndX)||!G(n.arrowEndY),b=3*(this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth),x=Gt({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),w=xg.poolIndex()){var v=p;p=g,g=v}var y=d.srcPos=p.position(),m=d.tgtPos=g.position(),b=d.srcW=p.outerWidth(),x=d.srcH=p.outerHeight(),E=d.tgtW=g.outerWidth(),k=d.tgtH=g.outerHeight(),T=d.srcShape=n.nodeShapes[t.getNodeShape(p)],C=d.tgtShape=n.nodeShapes[t.getNodeShape(g)],P=d.srcCornerRadius="auto"===p.pstyle("corner-radius").value?"auto":p.pstyle("corner-radius").pfValue,S=d.tgtCornerRadius="auto"===g.pstyle("corner-radius").value?"auto":g.pstyle("corner-radius").pfValue,B=d.tgtRs=g._private.rscratch,D=d.srcRs=p._private.rscratch;d.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var _=0;_=qc||(q=Math.sqrt(Math.max(Y*Y,Yc)+Math.max(j*j,Yc)));var W=d.vector={x:Y,y:j},U=d.vectorNorm={x:W.x/q,y:W.y/q},H={x:-U.y,y:U.x};d.nodesOverlap=!G(q)||C.checkPoint(L[0],L[1],0,E,k,m.x,m.y,S,B)||T.checkPoint(O[0],O[1],0,b,x,y.x,y.y,P,D),d.vectorNormInverse=H,e={nodesOverlap:d.nodesOverlap,dirCounts:d.dirCounts,calculatedIntersection:!0,hasBezier:d.hasBezier,hasUnbundled:d.hasUnbundled,eles:d.eles,srcPos:m,srcRs:B,tgtPos:y,tgtRs:D,srcW:E,srcH:k,tgtW:b,tgtH:x,srcIntn:V,tgtIntn:z,srcShape:C,tgtShape:T,posPts:{x1:X.x2,y1:X.y2,x2:X.x1,y2:X.y1},intersectionPts:{x1:F.x2,y1:F.y2,x2:F.x1,y2:F.y1},vector:{x:-W.x,y:-W.y},vectorNorm:{x:-U.x,y:-U.y},vectorNormInverse:{x:-H.x,y:-H.y}}}var K=N?e:d;M.nodesOverlap=K.nodesOverlap,M.srcIntn=K.srcIntn,M.tgtIntn=K.tgtIntn,M.isRound=R.startsWith("round"),r&&(p.isParent()||p.isChild()||g.isParent()||g.isChild())&&(p.parents().anySame(g)||g.parents().anySame(p)||p.same(g)&&p.isParent())?t.findCompoundLoopPoints(A,K,_,I):p===g?t.findLoopPoints(A,K,_,I):R.endsWith("segments")?t.findSegmentsPoints(A,K):R.endsWith("taxi")?t.findTaxiPoints(A,K):"straight"===R||!I&&d.eles.length%2==1&&_===Math.floor(d.eles.length/2)?t.findStraightEdgePoints(A):t.findBezierPoints(A,K,_,I,N),t.findEndpoints(A),t.tryToCorrectInvalidPoints(A,K),t.checkForInvalidEdgeWarning(A),t.storeAllpts(A),t.storeEdgeProjections(A),t.calculateArrowAngles(A),t.recalculateEdgeLabelProjections(A),t.calculateLabelAngles(A)}},w=0;w0){var J=f,ee=Zt(J,qt(i)),te=Zt(J,qt(Q)),ne=ee;if(te2)Zt(J,{x:Q[2],y:Q[3]})0){var ve=p,ye=Zt(ve,qt(i)),me=Zt(ve,qt(ge)),be=ye;if(me2)Zt(ve,{x:ge[2],y:ge[3]})=u||m){c={cp:g,segment:y};break}}if(c)break}var b=c.cp,x=c.segment,w=(u-h)/x.length,E=x.t1-x.t0,k=s?x.t0+E*w:x.t1-E*w;k=en(0,k,1),t=Jt(b.p0,b.p1,b.p2,k),a=function(e,t,n,r){var a=en(0,r-.001,1),i=en(0,r+.001,1),o=Jt(e,t,n,a),s=Jt(e,t,n,i);return Qc(o,s)}(b.p0,b.p1,b.p2,k);break;case"straight":case"segments":case"haystack":for(var T,C,P,S,B=0,D=r.allpts.length,_=0;_+3=u));_+=2);var A=(u-C)/T;A=en(0,A,1),t=function(e,t,n,r){var a=t.x-e.x,i=t.y-e.y,o=Gt(e,t),s=a/o,l=i/o;return n=null==n?0:n,r=null!=r?r:n*o,{x:e.x+s*r,y:e.y+l*r}}(P,S,A),a=Qc(P,S)}o("labelX",n,t.x),o("labelY",n,t.y),o("labelAutoAngle",n,a)}};u("source"),u("target"),this.applyLabelDimensions(e)}},Zc.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},Zc.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),a=We(r,e._private.labelDimsKey);if(ft(n.rscratch,"prefixedLabelDimsKey",t)!==a){pt(n.rscratch,"prefixedLabelDimsKey",t,a);var i=this.calculateLabelDimensions(e,r),o=e.pstyle("line-height").pfValue,s=e.pstyle("font-size").pfValue,l=e.pstyle("text-wrap").strValue,u=ft(n.rscratch,"labelWrapCachedLines",t)||[],c="wrap"!==l?1:Math.max(u.length,1),d=s*o,h=i.width,f=i.height+(c-1)*(o-1)*s;pt(n.rstyle,"labelWidth",t,h),pt(n.rscratch,"labelWidth",t,h),pt(n.rstyle,"labelHeight",t,f),pt(n.rscratch,"labelHeight",t,f),pt(n.rscratch,"labelLineHeight",t,d),pt(n.rscratch,"labelActualDescent",t,i.labelActualDescent)}},Zc.getLabelText=function(e,t){var n=e._private,a=t?t+"-":"",i=e.pstyle(a+"label").strValue,o=e.pstyle("text-transform").value,s=function(e,r){return r?(pt(n.rscratch,e,t,r),r):ft(n.rscratch,e,t)};if(!i)return"";"none"==o||("uppercase"==o?i=i.toUpperCase():"lowercase"==o&&(i=i.toLowerCase()));var l=e.pstyle("text-wrap").value;if("wrap"===l){var u=s("labelKey");if(null!=u&&s("labelWrapKey")===u)return s("labelWrapCachedText");for(var c=i.split("\n"),d=e.pstyle("text-max-width").pfValue,h="anywhere"===e.pstyle("text-overflow-wrap").value,f=[],p=/[\s\u200b]+|$/g,g=0;gd){var b,x="",w=0,E=r(v.matchAll(p));try{for(E.s();!(b=E.n()).done;){var k=b.value,T=k[0],C=v.substring(w,k.index);w=k.index+T.length;var P=0===x.length?C:x+C+T;this.calculateLabelDimensions(e,P).width<=d?x+=C+T:(x&&f.push(x),x=C+T)}}catch(e){E.e(e)}finally{E.f()}x.match(/^[\s\u200b]+$/)||f.push(x)}else f.push(v)}s("labelWrapCachedLines",f),i=s("labelWrapCachedText",f.join("\n")),s("labelWrapKey",u)}else if("ellipsis"===l){var S=e.pstyle("text-max-width").pfValue,B="",D=!1;if(this.calculateLabelDimensions(e,i).widthS)break;B+=i[_],_===i.length-1&&(D=!0)}return D||(B+="…"),B}return i},Zc.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;return"auto"===t?e.isNode()?function(e){switch(e){case"left":case"right-inside":return"right";case"right":case"left-inside":return"left";default:return"center"}}(n):"center":t},Zc.calculateLabelDimensions=function(e,t){var n=this.cy.window().document,r=e.pstyle("font-style").strValue,a=e.pstyle("font-size").pfValue,i=e.pstyle("font-family").strValue,o=e.pstyle("font-weight").strValue,s=e.pstyle("text-metrics").strValue||"font",l=this.labelCalcCanvas,u=this.labelCalcCanvasContext;if(!l){l=this.labelCalcCanvas=n.createElement("canvas"),u=this.labelCalcCanvasContext=l.getContext("2d");var c=l.style;c.position="absolute",c.left="-9999px",c.top="-9999px",c.zIndex="-1",c.visibility="hidden",c.pointerEvents="none"}u.font="".concat(r," ").concat(o," ").concat(a,"px ").concat(i);for(var d=0,h=0,f=t.split("\n"),p=f.length,g=0,v=0,y=0;y1&&void 0!==arguments[1])||arguments[1];if(t.merge(e),n)for(var r=0;r=e.desktopTapThreshold2}var P=a(t);v&&(e.hoverData.tapholdCancelled=!0);n=!0,r(g,["mousemove","vmousemove","tapdrag"],t,{x:c[0],y:c[1]});var S=function(e){return{originalEvent:t,type:e,position:{x:c[0],y:c[1]}}},B=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||o.emit(S("boxstart")),p[4]=1,e.hoverData.selecting=!0,e.redrawHint("select",!0),e.redraw()};if(3===e.hoverData.which){if(v){var D=S("cxtdrag");b?b.emit(D):o.emit(D),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&g===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit(S("cxtdragout")),e.hoverData.cxtOver=g,g&&g.emit(S("cxtdragover")))}}else if(e.hoverData.dragging){if(n=!0,o.panningEnabled()&&o.userPanningEnabled()){var _;if(e.hoverData.justStartedPan){var A=e.hoverData.mdownPos;_={x:(c[0]-A[0])*s,y:(c[1]-A[1])*s},e.hoverData.justStartedPan=!1}else _={x:x[0]*s,y:x[1]*s};o.panBy(_),o.emit(S("dragpan")),e.hoverData.dragged=!0}c=e.projectIntoViewport(t.clientX,t.clientY)}else if(1!=p[4]||null!=b&&!b.pannable()){if(b&&b.pannable()&&b.active()&&b.unactivate(),b&&b.grabbed()||g==y||(y&&r(y,["mouseout","tapdragout"],t,{x:c[0],y:c[1]}),g&&r(g,["mouseover","tapdragover"],t,{x:c[0],y:c[1]}),e.hoverData.last=g),b)if(v){if(o.boxSelectionEnabled()&&P)b&&b.grabbed()&&(d(w),b.emit(S("freeon")),w.emit(S("free")),e.dragData.didDrag&&(b.emit(S("dragfreeon")),w.emit(S("dragfree")))),B();else if(b&&b.grabbed()&&e.nodeIsDraggable(b)){var M=!e.dragData.didDrag;M&&e.redrawHint("eles",!0),e.dragData.didDrag=!0,e.hoverData.draggingEles||u(w,{inDragLayer:!0});var R={x:0,y:0};if(G(x[0])&&G(x[1])&&(R.x+=x[0],R.y+=x[1],M)){var I=e.hoverData.dragDelta;I&&G(I[0])&&G(I[1])&&(R.x+=I[0],R.y+=I[1])}e.hoverData.draggingEles=!0,w.silentShift(R).emit(S("position")).emit(S("drag")),e.redrawHint("drag",!0),e.redraw()}}else!function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];0===t.length?(t.push(x[0]),t.push(x[1])):(t[0]+=x[0],t[1]+=x[1])}();n=!0}else if(v){if(e.hoverData.dragging||!o.boxSelectionEnabled()||!P&&o.panningEnabled()&&o.userPanningEnabled()){if(!e.hoverData.selecting&&o.panningEnabled()&&o.userPanningEnabled()){i(b,e.hoverData.downs)&&(e.hoverData.dragging=!0,e.hoverData.justStartedPan=!0,p[4]=0,e.data.bgActivePosistion=qt(h),e.redrawHint("select",!0),e.redraw())}}else B();b&&b.pannable()&&b.active()&&b.unactivate()}return p[2]=c[0],p[3]=c[1],n?(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),!1):void 0}}),!1),e.registerBinding(t,"mouseup",(function(t){if((1!==e.hoverData.which||1===t.which||!e.hoverData.capture)&&e.hoverData.capture){e.hoverData.capture=!1;var i=e.cy,o=e.projectIntoViewport(t.clientX,t.clientY),s=e.selection,l=e.findNearestElement(o[0],o[1],!0,!1),u=e.dragData.possibleDragElements,c=e.hoverData.down,h=a(t);e.data.bgActivePosistion&&(e.redrawHint("select",!0),e.redraw()),e.hoverData.tapholdCancelled=!0,e.data.bgActivePosistion=void 0,c&&c.unactivate();var f=function(e){return{originalEvent:t,type:e,position:{x:o[0],y:o[1]}}};if(3===e.hoverData.which){var p=f("cxttapend");if(c?c.emit(p):i.emit(p),!e.hoverData.cxtDragged){var g=f("cxttap");c?c.emit(g):i.emit(g)}e.hoverData.cxtDragged=!1,e.hoverData.which=null}else if(1===e.hoverData.which){if(r(l,["mouseup","tapend","vmouseup"],t,{x:o[0],y:o[1]}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||e.hoverData.isOverThresholdDrag||(r(c,["click","tap","vclick"],t,{x:o[0],y:o[1]}),x=!1,t.timeStamp-w<=i.multiClickDebounceTime()?(b&&clearTimeout(b),x=!0,w=null,r(c,["dblclick","dbltap","vdblclick"],t,{x:o[0],y:o[1]})):(b=setTimeout((function(){x||r(c,["oneclick","onetap","voneclick"],t,{x:o[0],y:o[1]})}),i.multiClickDebounceTime()),w=t.timeStamp)),null!=c||e.dragData.didDrag||e.hoverData.selecting||e.hoverData.dragged||a(t)||(i.$(n).unselect(["tapunselect"]),u.length>0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=u=i.collection()),l!=c||e.dragData.didDrag||e.hoverData.selecting||null!=l&&l._private.selectable&&(e.hoverData.dragging||("additive"===i.selectionType()||h?l.selected()?l.unselect(["tapunselect"]):l.select(["tapselect"]):h||(i.$(n).unmerge(l).unselect(["tapunselect"]),l.select(["tapselect"]))),e.redrawHint("eles",!0)),e.hoverData.selecting){var v=i.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint("select",!0),v.length>0&&e.redrawHint("eles",!0),i.emit(f("boxend"));var y=function(e){return e.selectable()&&!e.selected()};"additive"===i.selectionType()||h||i.$(n).unmerge(v).unselect(),v.emit(f("box")).stdFilter(y).select().emit(f("boxselect")),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint("select",!0),e.redrawHint("eles",!0),e.redraw()),!s[4]){e.redrawHint("drag",!0),e.redrawHint("eles",!0);var m=c&&c.grabbed();d(u),m&&(c.emit(f("freeon")),u.emit(f("free")),e.dragData.didDrag&&(c.emit(f("dragfreeon")),u.emit(f("dragfree"))))}}s[4]=0,e.hoverData.down=null,e.hoverData.cxtStarted=!1,e.hoverData.draggingEles=!1,e.hoverData.selecting=!1,e.hoverData.isOverThresholdDrag=!1,e.dragData.didDrag=!1,e.hoverData.dragged=!1,e.hoverData.dragDelta=[],e.hoverData.mdownPos=null,e.hoverData.mdownGPos=null,e.hoverData.which=null}}),!1);var k,T,C,P,S,B,D,_,A,M,R,I,N,L,z=[],O=1e5,V=function(t){var n=!1,r=t.deltaY;if(null==r&&(null!=t.wheelDeltaY?r=t.wheelDeltaY/4:null!=t.wheelDelta&&(r=t.wheelDelta/4)),0!==r){if(null==k)if(z.length>=4){k=!1;var a,i=z;if(i[0]>=5)a=function(e){for(var t=Math.abs(e[0]),n=1;n0&&(t=Wt(t,e[n]))}return t}(i),a>1&&(k=!0,O=a)}else z.push(Math.abs(r)),n=!0;else k&&(O=Math.min(Math.abs(r),O));if(!e.scrollingPage){var o=e.cy,s=o.zoom(),l=o.pan(),u=e.projectIntoViewport(t.clientX,t.clientY),c=[u[0]*s+l.x,u[1]*s+l.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||0!==e.selection[4])t.preventDefault();else if(o.panningEnabled()&&o.userPanningEnabled()&&o.zoomingEnabled()&&o.userZoomingEnabled()){var d;t.preventDefault(),e.data.wheelZooming=!0,clearTimeout(e.data.wheelTimeout),e.data.wheelTimeout=setTimeout((function(){e.data.wheelZooming=!1,e.redrawHint("eles",!0),e.redraw()}),150),n&&Math.abs(r)>5&&(r=5*Kt(r)),d=r/-250,k&&(d/=O,d*=3),d*=e.wheelSensitivity,1===t.deltaMode&&(d*=33);var h=o.zoom()*Math.pow(10,d);"gesturechange"===t.type&&(h=e.gestureStartZoom*t.scale),o.zoom({level:h,renderedPosition:{x:c[0],y:c[1]}}),o.emit({type:"gesturechange"===t.type?"pinchzoom":"scrollzoom",originalEvent:t,position:{x:u[0],y:u[1]}})}}}};e.registerBinding(e.container,"wheel",V,!0),e.registerBinding(t,"scroll",(function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout((function(){e.scrollingPage=!1}),250)}),!0),e.registerBinding(e.container,"gesturestart",(function(t){e.gestureStartZoom=e.cy.zoom(),e.hasTouchStarted||t.preventDefault()}),!0),e.registerBinding(e.container,"gesturechange",(function(t){e.hasTouchStarted||V(t)}),!0),e.registerBinding(e.container,"mouseout",(function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseout",position:{x:n[0],y:n[1]}})}),!1),e.registerBinding(e.container,"mouseover",(function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseover",position:{x:n[0],y:n[1]}})}),!1);var F,X,j,Y,q,W,U,H=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},K=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)};if(e.registerBinding(e.container,"touchstart",F=function(t){if(e.hasTouchStarted=!0,m(t)){f(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var n=e.cy,a=e.touchData.now,i=e.touchData.earlier;if(t.touches[0]){var o=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);a[0]=o[0],a[1]=o[1]}if(t.touches[1]){o=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);a[2]=o[0],a[3]=o[1]}if(t.touches[2]){o=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);a[4]=o[0],a[5]=o[1]}var l=function(e){return{originalEvent:t,type:e,position:{x:a[0],y:a[1]}}};if(t.touches[1]){e.touchData.singleTouchMoved=!0,d(e.dragData.touchDragEles);var h=e.findContainerClientCoords();M=h[0],R=h[1],I=h[2],N=h[3],T=t.touches[0].clientX-M,C=t.touches[0].clientY-R,P=t.touches[1].clientX-M,S=t.touches[1].clientY-R,L=0<=T&&T<=I&&0<=P&&P<=I&&0<=C&&C<=N&&0<=S&&S<=N;var p=n.pan(),g=n.zoom();B=H(T,C,P,S),D=K(T,C,P,S),A=[((_=[(T+P)/2,(C+S)/2])[0]-p.x)/g,(_[1]-p.y)/g];if(D<4e4&&!t.touches[2]){var v=e.findNearestElement(a[0],a[1],!0,!0),y=e.findNearestElement(a[2],a[3],!0,!0);return v&&v.isNode()?(v.activate().emit(l("cxttapstart")),e.touchData.start=v):y&&y.isNode()?(y.activate().emit(l("cxttapstart")),e.touchData.start=y):n.emit(l("cxttapstart")),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!0,e.touchData.cxtDragged=!1,e.data.bgActivePosistion=void 0,void e.redraw()}}if(t.touches[2])n.boxSelectionEnabled()&&t.preventDefault();else if(t.touches[1]);else if(t.touches[0]){var b=e.findNearestElements(a[0],a[1],!0,!0),x=b[0];if(null!=x&&(x.activate(),e.touchData.start=x,e.touchData.starts=b,e.nodeIsGrabbable(x))){var w=e.dragData.touchDragEles=n.collection(),E=null;e.redrawHint("eles",!0),e.redrawHint("drag",!0),x.selected()?(E=n.$((function(t){return t.selected()&&e.nodeIsGrabbable(t)})),u(E,{addToList:w})):c(x,{addToList:w}),s(x),x.emit(l("grabon")),E?E.forEach((function(e){e.emit(l("grab"))})):x.emit(l("grab"))}r(x,["touchstart","tapstart","vmousedown"],t,{x:a[0],y:a[1]}),null==x&&(e.data.bgActivePosistion={x:o[0],y:o[1]},e.redrawHint("select",!0),e.redraw()),e.touchData.singleTouchMoved=!1,e.touchData.singleTouchStartTime=+new Date,clearTimeout(e.touchData.tapholdTimeout),e.touchData.tapholdTimeout=setTimeout((function(){!1!==e.touchData.singleTouchMoved||e.pinching||e.touchData.selecting||r(e.touchData.start,["taphold"],t,{x:a[0],y:a[1]})}),e.tapholdDuration)}if(t.touches.length>=1){for(var k=e.touchData.startPosition=[null,null,null,null,null,null],z=0;z=e.touchTapThreshold2}if(n&&e.touchData.cxt){t.preventDefault();var E=t.touches[0].clientX-M,k=t.touches[0].clientY-R,_=t.touches[1].clientX-M,I=t.touches[1].clientY-R,N=K(E,k,_,I);if(N/D>=2.25||N>=22500){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var z=p("cxttapend");e.touchData.start?(e.touchData.start.unactivate().emit(z),e.touchData.start=null):o.emit(z)}}if(n&&e.touchData.cxt){z=p("cxtdrag");e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.touchData.start?e.touchData.start.emit(z):o.emit(z),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var O=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&O===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit(p("cxtdragout")),e.touchData.cxtOver=O,O&&O.emit(p("cxtdragover")))}else if(n&&t.touches[2]&&o.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||o.emit(p("boxstart")),e.touchData.selecting=!0,e.touchData.didSelect=!0,a[4]=1,a&&0!==a.length&&void 0!==a[0]?(a[2]=(s[0]+s[2]+s[4])/3,a[3]=(s[1]+s[3]+s[5])/3):(a[0]=(s[0]+s[2]+s[4])/3,a[1]=(s[1]+s[3]+s[5])/3,a[2]=(s[0]+s[2]+s[4])/3+1,a[3]=(s[1]+s[3]+s[5])/3+1),e.redrawHint("select",!0),e.redraw();else if(n&&t.touches[1]&&!e.touchData.didSelect&&o.zoomingEnabled()&&o.panningEnabled()&&o.userZoomingEnabled()&&o.userPanningEnabled()){if(t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),te=e.dragData.touchDragEles){e.redrawHint("drag",!0);for(var V=0;V0&&!e.hoverData.draggingEles&&!e.swipePanning&&null!=e.data.bgActivePosistion&&(e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.redraw())}},!1),e.registerBinding(t,"touchcancel",j=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()}),e.registerBinding(t,"touchend",Y=function(t){var a=e.touchData.start;if(e.touchData.capture){0===t.touches.length&&(e.touchData.capture=!1),t.preventDefault();var i=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var o=e.cy,s=o.zoom(),l=e.touchData.now,u=e.touchData.earlier;if(t.touches[0]){var c=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);l[0]=c[0],l[1]=c[1]}if(t.touches[1]){c=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);l[2]=c[0],l[3]=c[1]}if(t.touches[2]){c=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);l[4]=c[0],l[5]=c[1]}var h,f=function(e){return{originalEvent:t,type:e,position:{x:l[0],y:l[1]}}};if(a&&a.unactivate(),e.touchData.cxt){if(h=f("cxttapend"),a?a.emit(h):o.emit(h),!e.touchData.cxtDragged){var p=f("cxttap");a?a.emit(p):o.emit(p)}return e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!1,e.touchData.start=null,void e.redraw()}if(!t.touches[2]&&o.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var g=o.collection(e.getAllInBox(i[0],i[1],i[2],i[3]));i[0]=void 0,i[1]=void 0,i[2]=void 0,i[3]=void 0,i[4]=0,e.redrawHint("select",!0),o.emit(f("boxend"));g.emit(f("box")).stdFilter((function(e){return e.selectable()&&!e.selected()})).select().emit(f("boxselect")),g.nonempty()&&e.redrawHint("eles",!0),e.redraw()}if(null!=a&&a.unactivate(),t.touches[2])e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);else if(t.touches[1]);else if(t.touches[0]);else if(!t.touches[0]){e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var v=e.dragData.touchDragEles;if(null!=a){var y=a._private.grabbed;d(v),e.redrawHint("drag",!0),e.redrawHint("eles",!0),y&&(a.emit(f("freeon")),v.emit(f("free")),e.dragData.didDrag&&(a.emit(f("dragfreeon")),v.emit(f("dragfree")))),r(a,["touchend","tapend","vmouseup","tapdragout"],t,{x:l[0],y:l[1]}),a.unactivate(),e.touchData.start=null}else{var m=e.findNearestElement(l[0],l[1],!0,!0);r(m,["touchend","tapend","vmouseup","tapdragout"],t,{x:l[0],y:l[1]})}var b=e.touchData.startPosition[0]-l[0],x=b*b,w=e.touchData.startPosition[1]-l[1],E=(x+w*w)*s*s;e.touchData.singleTouchMoved||(a||o.$(":selected").unselect(["tapunselect"]),r(a,["tap","vclick"],t,{x:l[0],y:l[1]}),q=!1,t.timeStamp-U<=o.multiClickDebounceTime()?(W&&clearTimeout(W),q=!0,U=null,r(a,["dbltap","vdblclick"],t,{x:l[0],y:l[1]})):(W=setTimeout((function(){q||r(a,["onetap","voneclick"],t,{x:l[0],y:l[1]})}),o.multiClickDebounceTime()),U=t.timeStamp)),null!=a&&!e.dragData.didDrag&&a._private.selectable&&E2){for(var f=[c[0],c[1]],p=Math.pow(f[0]-e,2)+Math.pow(f[1]-t,2),g=1;g0)return g[0]}return null},f=Object.keys(d),p=0;p0?u:fn(a,i,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,a,i,o,s){var l=2*(s="auto"===s?Mn(r,a):s);if(bn(e,t,this.points,i,o,r,a-l,[0,-1],n))return!0;if(bn(e,t,this.points,i,o,r-l,a,[0,-1],n))return!0;var u=r/2+2*n,c=a/2+2*n;return!!mn(e,t,[i-u,o-c,i-u,o,i+u,o,i+u,o-c])||(!!En(e,t,l,l,i+r/2-s,o+a/2-s,n)||!!En(e,t,l,l,i-r/2+s,o+a/2-s,n))}}},sd.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",Dn(3,0)),this.generateRoundPolygon("round-triangle",Dn(3,0)),this.generatePolygon("rectangle",Dn(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var n=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",n),this.generateRoundPolygon("round-diamond",n),this.generatePolygon("pentagon",Dn(5,0)),this.generateRoundPolygon("round-pentagon",Dn(5,0)),this.generatePolygon("hexagon",Dn(6,0)),this.generateRoundPolygon("round-hexagon",Dn(6,0)),this.generatePolygon("heptagon",Dn(7,0)),this.generateRoundPolygon("round-heptagon",Dn(7,0)),this.generatePolygon("octagon",Dn(8,0)),this.generateRoundPolygon("round-octagon",Dn(8,0));var r=new Array(20),a=An(5,0),i=An(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=e.deqFastCost*g)break}else if(a){if(f>=e.deqCost*l||f>=e.deqAvgCost*s)break}else if(p>=e.deqNoDrawCost*hd)break;var v=e.deq(t,d,c);if(!(v.length>0))break;for(var y=0;y0&&(e.onDeqd(t,u),!a&&e.shouldRedraw(t,u,d,c)&&r())}),a(t))}}},pd=function(){return n((function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;t(this,e),this.idsByKey=new gt,this.keyForId=new gt,this.cachesByLvl=new gt,this.lvls=[],this.getKey=n,this.doesEleInvalidateKey=r}),[{key:"getIdsFor",value:function(e){null==e&&rt("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new yt,t.set(e,n)),n}},{key:"addIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).add(t)}},{key:"deleteIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).delete(t)}},{key:"getNumberOfIdsForKey",value:function(e){return null==e?0:this.getIdsFor(e).size}},{key:"updateKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)}},{key:"deleteKeyMappingFor",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)}},{key:"keyHasChangedFor",value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:"isInvalid",value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:"getCachesAt",value:function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new gt,t.set(e,r),n.push(e)),r}},{key:"getCache",value:function(e,t){return this.getCachesAt(t).get(e)}},{key:"get",value:function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return null!=r&&this.updateKeyMappingFor(e),r}},{key:"getForCachedKey",value:function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)}},{key:"hasCache",value:function(e,t){return this.getCachesAt(t).has(e)}},{key:"has",value:function(e,t){var n=this.getKey(e);return this.hasCache(n,t)}},{key:"setCache",value:function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)}},{key:"set",value:function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)}},{key:"deleteCache",value:function(e,t){this.getCachesAt(t).delete(e)}},{key:"delete",value:function(e,t){var n=this.getKey(e);this.deleteCache(n,t)}},{key:"invalidateKey",value:function(e){var t=this;this.lvls.forEach((function(n){return t.deleteCache(e,n)}))}},{key:"invalidate",value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteKeyMappingFor(e);var r=this.doesEleInvalidateKey(e);return r&&this.invalidateKey(n),r||0===this.getNumberOfIdsForKey(n)}}])}(),gd=7.99,vd={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},yd=ct({getKey:null,doesEleInvalidateKey:et,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Je,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),md=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=yd(t);ye(n,r),n.lookup=new pd(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},bd=md.prototype;bd.reasons=vd,bd.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},bd.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},bd.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new Bt((function(e,t){return t.reqs-e.reqs}))},bd.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},bd.getElement=function(e,t,n,r,a){var i=this,o=this.renderer,s=o.cy.zoom(),l=this.lookup;if(!t||0===t.w||0===t.h||isNaN(t.w)||isNaN(t.h)||!e.visible()||e.removed())return null;if(!i.allowEdgeTxrCaching&&e.isEdge()||!i.allowParentTxrCaching&&e.isParent())return null;if(null==r&&(r=Math.ceil(Ht(s*n))),r<-4)r=-4;else if(s>=7.99||r>3)return null;var u=Math.pow(2,r),c=t.h*u,d=t.w*u,h=o.eleTextBiggerThanMin(e,u);if(!this.isVisible(e,h))return null;var f,p=l.get(e,r);if(p&&p.invalidated&&(p.invalidated=!1,p.texture.invalidatedWidth-=p.width),p)return p;if(f=c<=25?25:c<=50?50:50*Math.ceil(c/50),c>1024||d>1024)return null;var g=i.getTextureQueue(f),v=g[g.length-2],y=function(){return i.recycleTexture(f,d)||i.addTexture(f,d)};v||(v=g[g.length-1]),v||(v=y()),v.width-v.usedWidthr;S--)C=i.getElement(e,t,n,S,vd.downscale);P()}else{var B;if(!x&&!w&&!E)for(var D=r-1;D>=-4;D--){var _=l.get(e,D);if(_){B=_;break}}if(b(B))return i.queueElement(e,r),B;v.context.translate(v.usedWidth,0),v.context.scale(u,u),this.drawElement(v.context,e,t,h,!1),v.context.scale(1/u,1/u),v.context.translate(-v.usedWidth,0)}return p={x:v.usedWidth,texture:v,level:r,scale:u,width:d,height:c,scaledLabelShown:h},v.usedWidth+=Math.ceil(d+8),v.eleCaches.push(p),l.set(e,r,p),i.checkTextureFullness(v),p},bd.invalidateElements=function(e){for(var t=0;t=.2*e.width&&this.retireTexture(e)},bd.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?dt(t,e):e.fullnessChecks++},bd.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;dt(n,e),e.retired=!0;for(var a=e.eleCaches,i=0;i=t)return i.retired=!1,i.usedWidth=0,i.invalidatedWidth=0,i.fullnessChecks=0,ht(i.eleCaches),i.context.setTransform(1,0,0,1,0,0),i.context.clearRect(0,0,i.width,i.height),dt(r,i),n.push(i),i}},bd.queueElement=function(e,t){var n=this.getElementQueue(),r=this.getElementKeyToQueue(),a=this.getKey(e),i=r[a];if(i)i.level=Math.max(i.level,t),i.eles.merge(e),i.reqs++,n.updateItem(i);else{var o={eles:e.spawn().merge(e),level:t,reqs:1,key:a};n.push(o),r[a]=o}},bd.dequeue=function(e){for(var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),a=[],i=t.lookup,o=0;o<1&&n.size()>0;o++){var s=n.pop(),l=s.key,u=s.eles[0],c=i.hasCache(u,s.level);if(r[l]=null,!c){a.push(s);var d=t.getBoundingBox(u);t.getElement(u,d,e,s.level,vd.dequeue)}}return a},bd.removeFromQueue=function(e){var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=this.getKey(e),a=n[r];null!=a&&(1===a.eles.length?(a.reqs=Qe,t.updateItem(a),t.pop(),n[r]=null):a.eles.unmerge(e))},bd.onDequeue=function(e){this.onDequeues.push(e)},bd.offDequeue=function(e){dt(this.onDequeues,e)},bd.setupDequeueing=fd({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n=3.99||n>2)return null;r.validateLayersElesOrdering(n,e);var o,s,l=r.layersByLevel,u=Math.pow(2,n),c=l[n]=l[n]||[];if(r.levelIsComplete(n,e))return c;!function(){var t=function(t){if(r.validateLayersElesOrdering(t,e),r.levelIsComplete(t,e))return s=l[t],!0},a=function(e){if(!s)for(var r=n+e;-4<=r&&r<=2&&!t(r);r+=e);};a(1),a(-1);for(var i=c.length-1;i>=0;i--){var o=c[i];o.invalid&&dt(c,o)}}();var d=function(t){var a=(t=t||{}).after;!function(){if(!o){o=tn();for(var t=0;t32767||s>32767)return null;if(i*s>16e6)return null;var l=r.makeLayer(o,n);if(null!=a){var d=c.indexOf(a)+1;c.splice(d,0,l)}else(void 0===t.insert||t.insert)&&c.unshift(l);return l};if(r.skipping&&!i)return null;for(var h=null,f=e.length/1,p=!i,g=0;g=f||!cn(h.bb,v.boundingBox()))&&!(h=d({insert:!0,after:h})))return null;s||p?r.queueLayer(h,v):r.drawEleInLayer(h,v,n,t),h.eles.push(v),m[n]=h}}return s||(p?null:c)},wd.getEleLevelForLayerLevel=function(e,t){return e},wd.drawEleInLayer=function(e,t,n,r){var a=this.renderer,i=e.context,o=t.boundingBox();0!==o.w&&0!==o.h&&t.visible()&&(n=this.getEleLevelForLayerLevel(n,r),a.setImgSmoothing(i,!1),a.drawCachedElement(i,t,null,null,n,true),a.setImgSmoothing(i,!0))},wd.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,a=0;a0)return!1;if(i.invalid)return!1;r+=i.eles.length}return r===t.length},wd.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r0){e=!0;break}}return e},wd.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=Le(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,(function(e,n,r){t.invalidateLayer(e)})))},wd.invalidateLayer=function(e){if(this.lastInvalidationTime=Le(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];dt(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var a=0;a3&&void 0!==arguments[3])||arguments[3],a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],o=this,s=t._private.rscratch;if((!i||t.visible())&&!s.badLine&&null!=s.allpts&&!isNaN(s.allpts[0])){var l;n&&(l=n,e.translate(-l.x1,-l.y1));var u=i?t.pstyle("opacity").value:1,c=i?t.pstyle("line-opacity").value:1,d=t.pstyle("curve-style").value,h=t.pstyle("line-style").value,f=t.pstyle("width").pfValue,p=t.pstyle("line-cap").value,g=t.pstyle("line-outline-width").value,v=t.pstyle("line-outline-color").value,y=u*c,m=u*c,b=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;"straight-triangle"===d?(o.eleStrokeStyle(e,t,n),o.drawEdgeTrianglePath(t,e,s.allpts)):(e.lineWidth=f,e.lineCap=p,o.eleStrokeStyle(e,t,n),o.drawEdgePath(t,e,s.allpts,h),e.lineCap="butt")},x=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;o.drawArrowheads(e,t,n)};if(e.lineJoin="round","yes"===t.pstyle("ghost").value){var w=t.pstyle("ghost-offset-x").pfValue,E=t.pstyle("ghost-offset-y").pfValue,k=t.pstyle("ghost-opacity").value,T=y*k;e.translate(w,E),b(T),x(T),e.translate(-w,-E)}else!function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y;e.lineWidth=f+g,e.lineCap=p,g>0?(o.colorStrokeStyle(e,v[0],v[1],v[2],n),"straight-triangle"===d?o.drawEdgeTrianglePath(t,e,s.allpts):(o.drawEdgePath(t,e,s.allpts,h),e.lineCap="butt")):e.lineCap="butt"}();a&&o.drawEdgeUnderlay(e,t),b(),x(),a&&o.drawEdgeOverlay(e,t),o.drawElementText(e,t,null,r),n&&e.translate(l.x1,l.y1)}}},Vd=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n){if(n.visible()){var r=n.pstyle("".concat(e,"-opacity")).value;if(0!==r){var a=this,i=a.usePaths(),o=n._private.rscratch,s=2*n.pstyle("".concat(e,"-padding")).pfValue,l=n.pstyle("".concat(e,"-color")).value;t.lineWidth=s,"self"!==o.edgeType||i?t.lineCap="round":t.lineCap="butt",a.colorStrokeStyle(t,l[0],l[1],l[2],r),a.drawEdgePath(n,t,o.allpts,"solid")}}}};Od.drawEdgeOverlay=Vd("overlay"),Od.drawEdgeUnderlay=Vd("underlay"),Od.drawEdgePath=function(e,t,n,a){var i,o=e._private.rscratch,s=t,l=!1,u=this.usePaths(),c=e.pstyle("line-dash-pattern").pfValue,d=e.pstyle("line-dash-offset").pfValue;if(u){var h=n.join("$");o.pathCacheKey&&o.pathCacheKey===h?(i=t=o.pathCache,l=!0):(i=t=new Path2D,o.pathCacheKey=h,o.pathCache=i)}if(s.setLineDash)switch(a){case"dotted":s.setLineDash([1,1]);break;case"dashed":s.setLineDash(c),s.lineDashOffset=d;break;case"solid":s.setLineDash([])}if(!l&&!o.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),o.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var f=2;f+35&&void 0!==arguments[5]?arguments[5]:5,o=Math.min(i,r/2,a/2);e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+a-o),e.quadraticCurveTo(t+r,n+a,t+r-o,n+a),e.lineTo(t+o,n+a),e.quadraticCurveTo(t,n+a,t,n+a-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}Xd.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),a=Math.ceil(Ht(n*r));t=Math.pow(2,a)}return!(e.pstyle("font-size").pfValue*t5&&void 0!==arguments[5])||arguments[5],o=this;if(null==r){if(i&&!o.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){var s=t.pstyle("label");if(!s||!s.value)return;var l=o.getLabelJustification(t),u="glyph"===t.pstyle("text-metrics").strValue;e.textAlign=l,e.textBaseline=u?"alphabetic":"bottom"}else{var c=t.element()._private.rscratch.badLine,d=t.pstyle("label"),h=t.pstyle("source-label"),f=t.pstyle("target-label");if(c||(!d||!d.value)&&(!h||!h.value)&&(!f||!f.value))return;e.textAlign="center",e.textBaseline="bottom"}var p,g=!n;n&&(p=n,e.translate(-p.x1,-p.y1)),null==a?(o.drawText(e,t,null,g,i),t.isEdge()&&(o.drawText(e,t,"source",g,i),o.drawText(e,t,"target",g,i))):o.drawText(e,t,a,g,i),n&&e.translate(p.x1,p.y1)},Xd.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n2&&void 0!==arguments[2])||arguments[2],r=t.pstyle("font-style").strValue,a=t.pstyle("font-size").pfValue+"px",i=t.pstyle("font-family").strValue,o=t.pstyle("font-weight").strValue,s=n?t.effectiveOpacity()*t.pstyle("text-opacity").value:1,l=t.pstyle("text-outline-opacity").value*s,u=t.pstyle("color").value,c=t.pstyle("text-outline-color").value;e.font=r+" "+o+" "+a+" "+i,e.lineJoin="round",this.colorFillStyle(e,u[0],u[1],u[2],s),this.colorStrokeStyle(e,c[0],c[1],c[2],l)},Xd.getTextAngle=function(e,t){var n,r=e._private.rscratch,a=t?t+"-":"",i=e.pstyle(a+"text-rotation");if("autorotate"===i.strValue){var o=ft(r,"labelAngle",t);n=e.isEdge()?o:0}else n="none"===i.strValue?0:i.pfValue;return n},Xd.drawText=function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=t._private.rscratch,o=a?t.effectiveOpacity():1;if(!a||0!==o&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var s,l,u=ft(i,"labelX",n),c=ft(i,"labelY",n),d=this.getLabelText(t,n);if(null!=d&&""!==d&&!isNaN(u)&&!isNaN(c)){this.setupTextStyle(e,t,a);var h,f=n?n+"-":"",p=ft(i,"labelWidth",n),g=ft(i,"labelHeight",n),v=ft(i,"labelActualDescent",n),y=t.pstyle(f+"text-margin-x").pfValue,m=t.pstyle(f+"text-margin-y").pfValue,b=t.isEdge(),x=t.pstyle("text-halign").value,w=t.pstyle("text-valign").value;b&&(x="center",w="center"),u+=y,c+=m,0!==(h=r?this.getTextAngle(t,n):0)&&(s=u,l=c,e.translate(s,l),e.rotate(h),u=0,c=0);var E=Bs(x),k=Ds(w);switch(k){case"top":break;case"center":c+=g/2;break;case"bottom":c+=g}var T=t.pstyle("text-background-opacity").value,C=t.pstyle("text-border-opacity").value,P=t.pstyle("text-border-width").pfValue,S=t.pstyle("text-background-padding").pfValue,B=t.pstyle("text-background-shape").strValue,D="round-rectangle"===B||"roundrectangle"===B,_="circle"===B;if(T>0||P>0&&C>0){var A=e.fillStyle,M=e.strokeStyle,R=e.lineWidth,I=t.pstyle("text-background-color").value,N=t.pstyle("text-border-color").value,L=t.pstyle("text-border-style").value,z=T>0,O=P>0&&C>0,V=u-S;switch(E){case"left":V-=p;break;case"center":V-=p/2}var F=c-g-S,X=p+2*S,j=g+2*S;if(z&&(e.fillStyle="rgba(".concat(I[0],",").concat(I[1],",").concat(I[2],",").concat(T*o,")")),O&&(e.strokeStyle="rgba(".concat(N[0],",").concat(N[1],",").concat(N[2],",").concat(C*o,")"),e.lineWidth=P,e.setLineDash))switch(L){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=P/4,e.setLineDash([]);break;default:e.setLineDash([])}if(D?(e.beginPath(),jd(e,V,F,X,j,2)):_?(e.beginPath(),function(e,t,n,r,a){var i=Math.min(r,a)/2,o=t+r/2,s=n+a/2;e.beginPath(),e.arc(o,s,i,0,2*Math.PI),e.closePath()}(e,V,F,X,j)):(e.beginPath(),e.rect(V,F,X,j)),z&&e.fill(),O&&e.stroke(),O&&"double"===L){var Y=P/2;e.beginPath(),D?jd(e,V+Y,F+Y,X-2*Y,j-2*Y,2):e.rect(V+Y,F+Y,X-2*Y,j-2*Y),e.stroke()}e.fillStyle=A,e.strokeStyle=M,e.lineWidth=R,e.setLineDash&&e.setLineDash([])}var q=2*t.pstyle("text-outline-width").pfValue;if(q>0&&(e.lineWidth=q),c-=v,"wrap"===t.pstyle("text-wrap").value){var W=ft(i,"labelWrapCachedLines",n),U=ft(i,"labelLineHeight",n),H=p/2,K=this.getLabelJustification(t);switch("auto"===K||("left"===E?"left"===K?u+=-p:"center"===K&&(u+=-H):"center"===E?"left"===K?u+=-H:"right"===K&&(u+=H):"right"===E&&("center"===K?u+=H:"right"===K&&(u+=p))),k){case"top":case"center":case"bottom":c-=(W.length-1)*U}for(var G=0;G0&&e.strokeText(W[G],u,c),e.fillText(W[G],u,c),c+=U}else q>0&&e.strokeText(d,u,c),e.fillText(d,u,c);0!==h&&(e.rotate(-h),e.translate(-s,-l))}}};var Yd={drawNode:function(e,t,n){var r,a,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],l=this,u=t._private,c=u.rscratch,d=t.position();if(G(d.x)&&G(d.y)&&(!s||t.visible())){var h,f,p=s?t.effectiveOpacity():1,g=l.usePaths(),v=!1,y=t.padding();r=t.width()+2*y,a=t.height()+2*y,n&&(f=n,e.translate(-f.x1,-f.y1));for(var m=t.pstyle("background-image").value,b=new Array(m.length),x=new Array(m.length),w=0,E=0;E0&&void 0!==arguments[0]?arguments[0]:S;l.eleFillStyle(e,t,n)},Y=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N;l.colorStrokeStyle(e,B[0],B[1],B[2],t)},q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V;l.colorStrokeStyle(e,z[0],z[1],z[2],t)},W=function(e,t,n,r){var a,i=l.nodePathCache=l.nodePathCache||[],o=Ue("polygon"===n?n+","+r.join(","):n,""+t,""+e,""+X),s=i[o],u=!1;return null!=s?(a=s,u=!0,c.pathCache=a):(a=new Path2D,i[o]=c.pathCache=a),{path:a,cacheHit:u}},U=t.pstyle("shape").strValue,H=t.pstyle("shape-polygon-points").pfValue;if(g){e.translate(d.x,d.y);var K=W(r,a,U,H);h=K.path,v=K.cacheHit}var Z=function(){if(!v){var n=d;g&&(n={x:0,y:0}),l.nodeShapes[l.getNodeShape(t)].draw(h||e,n.x,n.y,r,a,X,c)}g?e.fill(h):e.fill()},$=function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=u.backgrounding,i=0,o=0;o0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;l.hasPie(t)&&(l.drawPie(e,t,i),n&&(g||l.nodeShapes[l.getNodeShape(t)].draw(e,d.x,d.y,r,a,X,c)))},J=function(){var n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;l.hasStripe(t)&&(e.save(),g?e.clip(c.pathCache):(l.nodeShapes[l.getNodeShape(t)].draw(e,d.x,d.y,r,a,X,c),e.clip()),l.drawStripe(e,t,i),e.restore(),n&&(g||l.nodeShapes[l.getNodeShape(t)].draw(e,d.x,d.y,r,a,X,c)))},ee=function(){var t=(C>0?C:-C)*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:p),n=C>0?0:255;0!==C&&(l.colorFillStyle(e,n,n,n,t),g?e.fill(h):e.fill())},te=function(){if(P>0){if(e.lineWidth=P,e.lineCap=A,e.lineJoin=_,e.setLineDash)switch(D){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash(R),e.lineDashOffset=I;break;case"solid":case"double":e.setLineDash([])}if("center"!==M){if(e.save(),e.lineWidth*=2,"inside"===M)g?e.clip(h):e.clip();else{var t=new Path2D;t.rect(-r/2-P,-a/2-P,r+2*P,a+2*P),t.addPath(h),e.clip(t,"evenodd")}g?e.stroke(h):e.stroke(),e.restore()}else g?e.stroke(h):e.stroke();if("double"===D){e.lineWidth=P/3;var n=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",g?e.stroke(h):e.stroke(),e.globalCompositeOperation=n}e.setLineDash&&e.setLineDash([])}},ne=function(){if(L>0){if(e.lineWidth=L,e.lineCap="butt",e.setLineDash)switch(O){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}var n=d;g&&(n={x:0,y:0});var i=l.getNodeShape(t),o=P;"inside"===M&&(o=0),"outside"===M&&(o*=2);var s,u=(r+o+(L+F))/r,c=(a+o+(L+F))/a,h=r*u,f=a*c,p=l.nodeShapes[i].points;if(g)s=W(h,f,i,p).path;if("ellipse"===i)l.drawEllipsePath(s||e,n.x,n.y,h,f);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(i)){var v=0,y=0,m=0;"round-diamond"===i?v=1.4*(o+F+L):"round-heptagon"===i?(v=1.075*(o+F+L),m=-(o/2+F+L)/35):"round-hexagon"===i?v=1.12*(o+F+L):"round-pentagon"===i?(v=1.13*(o+F+L),m=-(o/2+F+L)/15):"round-tag"===i?(v=1.12*(o+F+L),y=.07*(o/2+L+F)):"round-triangle"===i&&(v=(o+F+L)*(Math.PI/2),m=-(o+F/2+L)/Math.PI),0!==v&&(h=r*(u=(r+v)/r),["round-hexagon","round-tag"].includes(i)||(f=a*(c=(a+v)/a)));for(var b=h/2,x=f/2,w=(X="auto"===X?Rn(h,f):X)+(o+L+F)/2,E=new Array(p.length/2),k=new Array(p.length/2),T=0;T0){if(r=r||n.position(),null==a||null==i){var d=n.padding();a=n.width()+2*d,i=n.height()+2*d}this.colorFillStyle(t,l[0],l[1],l[2],s),this.nodeShapes[u].draw(t,r.x,r.y,a+2*o,i+2*o,c),t.fill()}}}};Yd.drawNodeOverlay=qd("overlay"),Yd.drawNodeUnderlay=qd("underlay"),Yd.hasPie=function(e){return(e=e[0])._private.hasPie},Yd.hasStripe=function(e){return(e=e[0])._private.hasStripe},Yd.drawPie=function(e,t,n,r){t=t[0],r=r||t.position();var a,i=t.cy().style(),o=t.pstyle("pie-size"),s=t.pstyle("pie-hole"),l=t.pstyle("pie-start-angle").pfValue,u=r.x,c=r.y,d=t.width(),h=t.height(),f=Math.min(d,h)/2,p=0;if(this.usePaths()&&(u=0,c=0),"%"===o.units?f*=o.pfValue:void 0!==o.pfValue&&(f=o.pfValue/2),"%"===s.units?a=f*s.pfValue:void 0!==s.pfValue&&(a=s.pfValue/2),!(a>=f))for(var g=1;g<=i.pieBackgroundN;g++){var v=t.pstyle("pie-"+g+"-background-size").value,y=t.pstyle("pie-"+g+"-background-color").value,m=t.pstyle("pie-"+g+"-background-opacity").value*n,b=v/100;b+p>1&&(b=1-p);var x=1.5*Math.PI+2*Math.PI*p,w=(x+=l)+2*Math.PI*b;0===v||p>=1||p+b>1||(0===a?(e.beginPath(),e.moveTo(u,c),e.arc(u,c,f,x,w),e.closePath()):(e.beginPath(),e.arc(u,c,f,x,w),e.arc(u,c,a,w,x,!0),e.closePath()),this.colorFillStyle(e,y[0],y[1],y[2],m),e.fill(),p+=b)}},Yd.drawStripe=function(e,t,n,r){t=t[0],r=r||t.position();var a=t.cy().style(),i=r.x,o=r.y,s=t.width(),l=t.height(),u=0,c=this.usePaths();e.save();var d=t.pstyle("stripe-direction").value,h=t.pstyle("stripe-size");switch(d){case"vertical":break;case"righward":e.rotate(-Math.PI/2)}var f=s,p=l;"%"===h.units?(f*=h.pfValue,p*=h.pfValue):void 0!==h.pfValue&&(f=h.pfValue,p=h.pfValue),c&&(i=0,o=0),o-=f/2,i-=p/2;for(var g=1;g<=a.stripeBackgroundN;g++){var v=t.pstyle("stripe-"+g+"-background-size").value,y=t.pstyle("stripe-"+g+"-background-color").value,m=t.pstyle("stripe-"+g+"-background-opacity").value*n,b=v/100;b+u>1&&(b=1-u),0===v||u>=1||u+b>1||(e.beginPath(),e.rect(i,o+p*u,f,p*b),e.closePath(),this.colorFillStyle(e,y[0],y[1],y[2],m),e.fill(),u+=b)}e.restore()};var Wd,Ud={};function Hd(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(r));return r}function Kd(e,t,n){void 0===n&&(n=t);var r=e.makeOffscreenCanvas(t,n),a=r.context=r.getContext("2d");return r.clear=function(){return a.clearRect(0,0,r.width,r.height)},r.clear(),r}function Gd(e){var t=e.pixelRatio,n=e.cy.zoom(),r=e.cy.pan();return{zoom:n*t,pan:{x:r.x*t,y:r.y*t}}}function Zd(e,t){return!!t.picking||"solid"===e.pstyle("background-fill").value&&("none"===e.pstyle("background-image").strValue&&(0===e.pstyle("border-width").value||(0===e.pstyle("border-opacity").value||"solid"===e.pstyle("border-style").value)))}function $d(e,t){if(e.length!==t.length)return!1;for(var n=0;n>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function eh(e){return e[0]+(e[1]<<8)+(e[2]<<16)+(e[3]<<24)}function th(e,t){switch(t){case"float":return[1,e.FLOAT,4];case"vec2":return[2,e.FLOAT,4];case"vec3":return[3,e.FLOAT,4];case"vec4":return[4,e.FLOAT,4];case"int":return[1,e.INT,4];case"ivec2":return[2,e.INT,4]}}function nh(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function rh(e,t,n,r,a,i){switch(t){case e.FLOAT:return new Float32Array(n.buffer,i*r,a);case e.INT:return new Int32Array(n.buffer,i*r,a)}}function ah(e,t,n,r){var a=i(th(e,n),3),o=a[0],s=a[1],l=a[2],u=nh(e,s,t*o),c=o*l,d=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,d),e.bufferData(e.ARRAY_BUFFER,t*c,e.DYNAMIC_DRAW),e.enableVertexAttribArray(r),s===e.FLOAT?e.vertexAttribPointer(r,o,s,!1,c,0):s===e.INT&&e.vertexAttribIPointer(r,o,s,c,0),e.vertexAttribDivisor(r,1),e.bindBuffer(e.ARRAY_BUFFER,null);for(var h=new Array(t),f=0;ft.minMbLowQualFrames&&(t.motionBlurPxRatio=t.mbPxRBlurry)),t.clearingMotionBlur&&(t.motionBlurPxRatio=1),t.textureDrawLastFrame&&!d&&(c[t.NODE]=!0,c[t.SELECT_BOX]=!0);var m=n.style(),b=n.zoom(),x=void 0!==o?o:b,w=n.pan(),E={x:w.x,y:w.y},k={zoom:b,pan:{x:w.x,y:w.y}},T=t.prevViewport;void 0===T||k.zoom!==T.zoom||k.pan.x!==T.pan.x||k.pan.y!==T.pan.y||g&&!p||(t.motionBlurPxRatio=1),s&&(E=s),x*=l,E.x*=l,E.y*=l;var C=t.getCachedZSortedEles();function P(e,n,r,a,i){var o=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",t.colorFillStyle(e,255,255,255,t.motionBlurTransparency),e.fillRect(n,r,a,i),e.globalCompositeOperation=o}function S(e,n){var i,l,c,d;t.clearingMotionBlur||e!==u.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]&&e!==u.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]?(i=E,l=x,c=t.canvasWidth,d=t.canvasHeight):(i={x:w.x*f,y:w.y*f},l=b*f,c=t.canvasWidth*f,d=t.canvasHeight*f),e.setTransform(1,0,0,1,0,0),"motionBlur"===n?P(e,0,0,c,d):r||void 0!==n&&!n||e.clearRect(0,0,c,d),a||(e.translate(i.x,i.y),e.scale(l,l)),s&&e.translate(s.x,s.y),o&&e.scale(o,o)}if(d||(t.textureDrawLastFrame=!1),d){if(t.textureDrawLastFrame=!0,!t.textureCache){t.textureCache={},t.textureCache.bb=n.mutableElements().boundingBox(),t.textureCache.texture=t.data.bufferCanvases[t.TEXTURE_BUFFER];var B=t.data.bufferContexts[t.TEXTURE_BUFFER];B.setTransform(1,0,0,1,0,0),B.clearRect(0,0,t.canvasWidth*t.textureMult,t.canvasHeight*t.textureMult),t.render({forcedContext:B,drawOnlyNodeLayer:!0,forcedPxRatio:l*t.textureMult}),(k=t.textureCache.viewport={zoom:n.zoom(),pan:n.pan(),width:t.canvasWidth,height:t.canvasHeight}).mpan={x:(0-k.pan.x)/k.zoom,y:(0-k.pan.y)/k.zoom}}c[t.DRAG]=!1,c[t.NODE]=!1;var D=u.contexts[t.NODE],_=t.textureCache.texture;k=t.textureCache.viewport;D.setTransform(1,0,0,1,0,0),h?P(D,0,0,k.width,k.height):D.clearRect(0,0,k.width,k.height);var A=m.core("outside-texture-bg-color").value,M=m.core("outside-texture-bg-opacity").value;t.colorFillStyle(D,A[0],A[1],A[2],M),D.fillRect(0,0,k.width,k.height);b=n.zoom();S(D,!1),D.clearRect(k.mpan.x,k.mpan.y,k.width/k.zoom/l,k.height/k.zoom/l),D.drawImage(_,k.mpan.x,k.mpan.y,k.width/k.zoom/l,k.height/k.zoom/l)}else t.textureOnViewport&&!r&&(t.textureCache=null);var R=n.extent(),I=t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming||t.hoverData.draggingEles||t.cy.animated(),N=t.hideEdgesOnViewport&&I,L=[];if(L[t.NODE]=!c[t.NODE]&&h&&!t.clearedForMotionBlur[t.NODE]||t.clearingMotionBlur,L[t.NODE]&&(t.clearedForMotionBlur[t.NODE]=!0),L[t.DRAG]=!c[t.DRAG]&&h&&!t.clearedForMotionBlur[t.DRAG]||t.clearingMotionBlur,L[t.DRAG]&&(t.clearedForMotionBlur[t.DRAG]=!0),c[t.NODE]||a||i||L[t.NODE]){var z=h&&!L[t.NODE]&&1!==f;S(D=r||(z?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]:u.contexts[t.NODE]),h&&!z?"motionBlur":void 0),N?t.drawCachedNodes(D,C.nondrag,l,R):t.drawLayeredElements(D,C.nondrag,l,R),t.debug&&t.drawDebugPoints(D,C.nondrag),a||h||(c[t.NODE]=!1)}if(!i&&(c[t.DRAG]||a||L[t.DRAG])){z=h&&!L[t.DRAG]&&1!==f;S(D=r||(z?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]:u.contexts[t.DRAG]),h&&!z?"motionBlur":void 0),N?t.drawCachedNodes(D,C.drag,l,R):t.drawCachedElements(D,C.drag,l,R),t.debug&&t.drawDebugPoints(D,C.drag),a||h||(c[t.DRAG]=!1)}if(this.drawSelectionRectangle(e,S),h&&1!==f){var O=u.contexts[t.NODE],V=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE],F=u.contexts[t.DRAG],X=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG],j=function(e,n,r){e.setTransform(1,0,0,1,0,0),r||!y?e.clearRect(0,0,t.canvasWidth,t.canvasHeight):P(e,0,0,t.canvasWidth,t.canvasHeight);var a=f;e.drawImage(n,0,0,t.canvasWidth*a,t.canvasHeight*a,0,0,t.canvasWidth,t.canvasHeight)};(c[t.NODE]||L[t.NODE])&&(j(O,V,L[t.NODE]),c[t.NODE]=!1),(c[t.DRAG]||L[t.DRAG])&&(j(F,X,L[t.DRAG]),c[t.DRAG]=!1)}t.prevViewport=k,t.clearingMotionBlur&&(t.clearingMotionBlur=!1,t.motionBlurCleared=!0,t.motionBlur=!0),h&&(t.motionBlurTimeout=setTimeout((function(){t.motionBlurTimeout=null,t.clearedForMotionBlur[t.NODE]=!1,t.clearedForMotionBlur[t.DRAG]=!1,t.motionBlur=!1,t.clearingMotionBlur=!d,t.mbFrames=0,c[t.NODE]=!0,c[t.DRAG]=!0,t.redraw()}),100)),r||n.emit("render")},Ud.drawSelectionRectangle=function(e,t){var n=this,r=n.cy,a=n.data,i=r.style(),o=e.drawOnlyNodeLayer,s=e.drawAllLayers,l=a.canvasNeedsRedraw,u=e.forcedContext;if(n.showFps||!o&&l[n.SELECT_BOX]&&!s){var c=u||a.contexts[n.SELECT_BOX];if(t(c),1==n.selection[4]&&(n.hoverData.selecting||n.touchData.selecting)){var d=n.cy.zoom(),h=i.core("selection-box-border-width").value/d;c.lineWidth=h,c.fillStyle="rgba("+i.core("selection-box-color").value[0]+","+i.core("selection-box-color").value[1]+","+i.core("selection-box-color").value[2]+","+i.core("selection-box-opacity").value+")",c.fillRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]),h>0&&(c.strokeStyle="rgba("+i.core("selection-box-border-color").value[0]+","+i.core("selection-box-border-color").value[1]+","+i.core("selection-box-border-color").value[2]+","+i.core("selection-box-opacity").value+")",c.strokeRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]))}if(a.bgActivePosistion&&!n.hoverData.selecting){d=n.cy.zoom();var f=a.bgActivePosistion;c.fillStyle="rgba("+i.core("active-bg-color").value[0]+","+i.core("active-bg-color").value[1]+","+i.core("active-bg-color").value[2]+","+i.core("active-bg-opacity").value+")",c.beginPath(),c.arc(f.x,f.y,i.core("active-bg-size").pfValue/d,0,2*Math.PI),c.fill()}var p=n.lastRedrawTime;if(n.showFps&&p){p=Math.round(p);var g=Math.round(1e3/p),v="1 frame = "+p+" ms = "+g+" fps";if(c.setTransform(1,0,0,1,0,0),c.fillStyle="rgba(255, 0, 0, 0.75)",c.strokeStyle="rgba(255, 0, 0, 0.75)",c.font="30px Arial",!Wd){var y=c.measureText(v);Wd=y.actualBoundingBoxAscent}c.fillText(v,0,Wd);c.strokeRect(0,Wd+10,250,20),c.fillRect(0,Wd+10,250*Math.min(g/60,1),20)}s||(l[n.SELECT_BOX]=!1)}};var ih="undefined"!=typeof Float32Array?Float32Array:Array;function oh(){var e=new ih(9);return ih!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function sh(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function lh(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=n[0],f=n[1];return e[0]=r,e[1]=a,e[2]=i,e[3]=o,e[4]=s,e[5]=l,e[6]=h*r+f*o+u,e[7]=h*a+f*s+c,e[8]=h*i+f*l+d,e}function uh(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=Math.sin(n),f=Math.cos(n);return e[0]=f*r+h*o,e[1]=f*a+h*s,e[2]=f*i+h*l,e[3]=f*o-h*r,e[4]=f*s-h*a,e[5]=f*l-h*i,e[6]=u,e[7]=c,e[8]=d,e}function ch(e,t,n){var r=n[0],a=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=a*t[3],e[4]=a*t[4],e[5]=a*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var dh=function(){return n((function e(n,r,a,i){t(this,e),this.debugID=Math.floor(1e4*Math.random()),this.r=n,this.texSize=r,this.texRows=a,this.texHeight=Math.floor(r/a),this.enableWrapping=!0,this.locked=!1,this.texture=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=i(n,r,r),this.scratch=i(n,r,this.texHeight,"scratch")}),[{key:"lock",value:function(){this.locked=!0}},{key:"getKeys",value:function(){return new Set(this.keyToLocation.keys())}},{key:"getScale",value:function(e){var t=e.w,n=e.h,r=this.texHeight,a=this.texSize,i=r/n,o=t*i,s=n*i;return o>a&&(o=t*(i=a/t),s=n*i),{scale:i,texW:o,texH:s}}},{key:"draw",value:function(e,t,n){var r=this;if(this.locked)throw new Error("can't draw, atlas is locked");var a=this.texSize,i=this.texRows,o=this.texHeight,s=this.getScale(t),l=s.scale,u=s.texW,c=s.texH,d=function(e,r){if(n&&r){var a=r.context,i=e.x,s=e.row,u=i,c=o*s;a.save(),a.translate(u,c),a.scale(l,l),n(a,t),a.restore()}},h=[null,null],f=function(){d(r.freePointer,r.canvas),h[0]={x:r.freePointer.x,y:r.freePointer.row*o,w:u,h:c},h[1]={x:r.freePointer.x+u,y:r.freePointer.row*o,w:0,h:c},r.freePointer.x+=u,r.freePointer.x==a&&(r.freePointer.x=0,r.freePointer.row++)},p=function(){r.freePointer.x=0,r.freePointer.row++};if(this.freePointer.x+u<=a)f();else{if(this.freePointer.row>=i-1)return!1;this.freePointer.x===a?(p(),f()):this.enableWrapping?function(){var e=r.scratch,t=r.canvas;e.clear(),d({x:0,row:0},e);var n=a-r.freePointer.x,i=u-n,s=o,l=r.freePointer.x,f=r.freePointer.row*o,p=n;t.context.drawImage(e,0,0,p,s,l,f,p,s),h[0]={x:l,y:f,w:p,h:c};var g=n,v=(r.freePointer.row+1)*o,y=i;t&&t.context.drawImage(e,g,0,y,s,0,v,y,s),h[1]={x:0,y:v,w:y,h:c},r.freePointer.x=i,r.freePointer.row++}():(p(),f())}return this.keyToLocation.set(e,h),this.needsBuffer=!0,h}},{key:"getOffsets",value:function(e){return this.keyToLocation.get(e)}},{key:"isEmpty",value:function(){return 0===this.freePointer.x&&0===this.freePointer.row}},{key:"canFit",value:function(e){if(this.locked)return!1;var t=this.texSize,n=this.texRows,r=this.getScale(e).texW;return!(this.freePointer.x+r>t)||this.freePointer.row1&&void 0!==arguments[1]?arguments[1]:{},i=a.forceRedraw,o=void 0!==i&&i,s=a.filterEle,l=void 0===s?function(){return!0}:s,u=a.filterType,c=void 0===u?function(){return!0}:u,d=!1,h=!1,f=r(e);try{for(f.s();!(t=f.n()).done;){var p=t.value;if(l(p)){var g,v=r(this.renderTypes.values());try{var y=function(){var e=g.value,t=e.type;if(c(t)){var r=n.collections.get(e.collection),a=e.getKey(p),i=Array.isArray(a)?a:[a];if(o)i.forEach((function(e){return r.markKeyForGC(e)})),h=!0;else{var s=e.getID?e.getID(p):p.id(),l=n._key(t,s),u=n.typeAndIdToKey.get(l);void 0===u||$d(i,u)||(d=!0,n.typeAndIdToKey.delete(l),u.forEach((function(e){return r.markKeyForGC(e)})))}}};for(v.s();!(g=v.n()).done;)y()}catch(e){v.e(e)}finally{v.f()}}}}catch(e){f.e(e)}finally{f.f()}return h&&(this.gc(),d=!1),d}},{key:"gc",value:function(){var e,t=r(this.collections.values());try{for(t.s();!(e=t.n()).done;){e.value.gc()}}catch(e){t.e(e)}finally{t.f()}}},{key:"getOrCreateAtlas",value:function(e,t,n,r){var a=this.renderTypes.get(t),i=this.collections.get(a.collection),o=!1,s=i.draw(r,n,(function(t){a.drawClipped?(t.save(),t.beginPath(),t.rect(0,0,n.w,n.h),t.clip(),a.drawElement(t,e,n,!0,!0),t.restore()):a.drawElement(t,e,n,!0,!0),o=!0}));if(o){var l=a.getID?a.getID(e):e.id(),u=this._key(t,l);this.typeAndIdToKey.has(u)?this.typeAndIdToKey.get(u).push(r):this.typeAndIdToKey.set(u,[r])}return s}},{key:"getAtlasInfo",value:function(e,t){var n=this,r=this.renderTypes.get(t),a=r.getKey(e);return(Array.isArray(a)?a:[a]).map((function(a){var o=r.getBoundingBox(e,a),s=n.getOrCreateAtlas(e,t,o,a),l=i(s.getOffsets(a),2),u=l[0];return{atlas:s,tex:u,tex1:u,tex2:l[1],bb:o}}))}},{key:"getDebugInfo",value:function(){var e,t=[],n=r(this.collections);try{for(n.s();!(e=n.n()).done;){var a=i(e.value,2),o=a[0],s=a[1].getCounts(),l=s.keyCount,u=s.atlasCount;t.push({type:o,keyCount:l,atlasCount:u})}}catch(e){n.e(e)}finally{n.f()}return t}}])}(),ph=function(){return n((function e(n){t(this,e),this.globalOptions=n,this.atlasSize=n.webglTexSize,this.maxAtlasesPerBatch=n.webglTexPerBatch,this.batchAtlases=[]}),[{key:"getMaxAtlasesPerBatch",value:function(){return this.maxAtlasesPerBatch}},{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"getIndexArray",value:function(){return Array.from({length:this.maxAtlasesPerBatch},(function(e,t){return t}))}},{key:"startBatch",value:function(){this.batchAtlases=[]}},{key:"getAtlasCount",value:function(){return this.batchAtlases.length}},{key:"getAtlases",value:function(){return this.batchAtlases}},{key:"canAddToCurrentBatch",value:function(e){return this.batchAtlases.length!==this.maxAtlasesPerBatch||this.batchAtlases.includes(e)}},{key:"getAtlasIndexForBatch",value:function(e){var t=this.batchAtlases.indexOf(e);if(t<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw new Error("cannot add more atlases to batch");this.batchAtlases.push(e),t=this.batchAtlases.length-1}return t}}])}(),gh={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},vh=1,yh=2,mh=function(){return n((function e(n,r,a){t(this,e),this.r=n,this.gl=r,this.maxInstances=a.webglBatchSize,this.atlasSize=a.webglTexSize,this.bgColor=a.bgColor,this.debug=a.webglDebug,this.batchDebugInfo=[],a.enableWrapping=!0,a.createTextureCanvas=Kd,this.atlasManager=new fh(n,a),this.batchManager=new ph(a),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(gh.SCREEN),this.pickingProgram=this._createShaderProgram(gh.PICKING),this.vao=this._createVAO()}),[{key:"addAtlasCollection",value:function(e,t){this.atlasManager.addAtlasCollection(e,t)}},{key:"addTextureAtlasRenderType",value:function(e,t){this.atlasManager.addRenderType(e,t)}},{key:"addSimpleShapeRenderType",value:function(e,t){this.simpleShapeOptions.set(e,t)}},{key:"invalidate",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).type,n=this.atlasManager;return t?n.invalidate(e,{filterType:function(e){return e===t},forceRedraw:!0}):n.invalidate(e)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"_createShaderProgram",value:function(e){var t=this.gl,n="#version 300 es\n precision highp float;\n\n uniform mat3 uPanZoomMatrix;\n uniform int uAtlasSize;\n \n // instanced\n in vec2 aPosition; // a vertex from the unit square\n \n in mat3 aTransform; // used to transform verticies, eg into a bounding box\n in int aVertType; // the type of thing we are rendering\n\n // the z-index that is output when using picking mode\n in vec4 aIndex;\n \n // For textures\n in int aAtlasId; // which shader unit/atlas to use\n in vec4 aTex; // x/y/w/h of texture in atlas\n\n // for edges\n in vec4 aPointAPointB;\n in vec4 aPointCPointD;\n in vec2 aLineWidth; // also used for node border width\n\n // simple shapes\n in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]\n in vec4 aColor; // also used for edges\n in vec4 aBorderColor; // aLineWidth is used for border width\n\n // output values passed to the fragment shader\n out vec2 vTexCoord;\n out vec4 vColor;\n out vec2 vPosition;\n // flat values are not interpolated\n flat out int vAtlasId; \n flat out int vVertType;\n flat out vec2 vTopRight;\n flat out vec2 vBotLeft;\n flat out vec4 vCornerRadius;\n flat out vec4 vBorderColor;\n flat out vec2 vBorderWidth;\n flat out vec4 vIndex;\n \n void main(void) {\n int vid = gl_VertexID;\n vec2 position = aPosition; // TODO make this a vec3, simplifies some code below\n\n if(aVertType == ".concat(0,") {\n float texX = aTex.x; // texture coordinates\n float texY = aTex.y;\n float texW = aTex.z;\n float texH = aTex.w;\n\n if(vid == 1 || vid == 2 || vid == 4) {\n texX += texW;\n }\n if(vid == 2 || vid == 4 || vid == 5) {\n texY += texH;\n }\n\n float d = float(uAtlasSize);\n vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(4," || aVertType == ").concat(7," \n || aVertType == ").concat(5," || aVertType == ").concat(6,") { // simple shapes\n\n // the bounding box is needed by the fragment shader\n vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat\n vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat\n vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated\n\n // calculations are done in the fragment shader, just pass these along\n vColor = aColor;\n vCornerRadius = aCornerRadius;\n vBorderColor = aBorderColor;\n vBorderWidth = aLineWidth;\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(1,") {\n vec2 source = aPointAPointB.xy;\n vec2 target = aPointAPointB.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n // stretch the unit square into a long skinny rectangle\n vec2 xBasis = target - source;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;\n\n gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);\n vColor = aColor;\n } \n else if(aVertType == ").concat(2,") {\n vec2 pointA = aPointAPointB.xy;\n vec2 pointB = aPointAPointB.zw;\n vec2 pointC = aPointCPointD.xy;\n vec2 pointD = aPointCPointD.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n vec2 p0, p1, p2, pos;\n if(position.x == 0.0) { // The left side of the unit square\n p0 = pointA;\n p1 = pointB;\n p2 = pointC;\n pos = position;\n } else { // The right side of the unit square, use same approach but flip the geometry upside down\n p0 = pointD;\n p1 = pointC;\n p2 = pointB;\n pos = vec2(0.0, -position.y);\n }\n\n vec2 p01 = p1 - p0;\n vec2 p12 = p2 - p1;\n vec2 p21 = p1 - p2;\n\n // Find the normal vector.\n vec2 tangent = normalize(normalize(p12) + normalize(p01));\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n // Find the vector perpendicular to p0 -> p1.\n vec2 p01Norm = normalize(vec2(-p01.y, p01.x));\n\n // Determine the bend direction.\n float sigma = sign(dot(p01 + p21, normal));\n float width = aLineWidth[0];\n\n if(sign(pos.y) == -sigma) {\n // This is an intersecting vertex. Adjust the position so that there's no overlap.\n vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n } else {\n // This is a non-intersecting vertex. Treat it like a mitre join.\n vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n }\n\n vColor = aColor;\n } \n else if(aVertType == ").concat(3," && vid < 3) {\n // massage the first triangle into an edge arrow\n if(vid == 0)\n position = vec2(-0.15, -0.3);\n if(vid == 1)\n position = vec2( 0.0, 0.0);\n if(vid == 2)\n position = vec2( 0.15, -0.3);\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n vColor = aColor;\n }\n else {\n gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space\n }\n\n vAtlasId = aAtlasId;\n vVertType = aVertType;\n vIndex = aIndex;\n }\n "),r=this.batchManager.getIndexArray(),a="#version 300 es\n precision highp float;\n\n // declare texture unit for each texture atlas in the batch\n ".concat(r.map((function(e){return"uniform sampler2D uTexture".concat(e,";")})).join("\n\t"),"\n\n uniform vec4 uBGColor;\n uniform float uZoom;\n\n in vec2 vTexCoord;\n in vec4 vColor;\n in vec2 vPosition; // model coordinates\n\n flat in int vAtlasId;\n flat in vec4 vIndex;\n flat in int vVertType;\n flat in vec2 vTopRight;\n flat in vec2 vBotLeft;\n flat in vec4 vCornerRadius;\n flat in vec4 vBorderColor;\n flat in vec2 vBorderWidth;\n\n out vec4 outColor;\n\n ").concat("\n float circleSD(vec2 p, float r) {\n return distance(vec2(0), p) - r; // signed distance\n }\n","\n ").concat("\n float rectangleSD(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);\n }\n","\n ").concat("\n float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {\n cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;\n cr.x = (p.y > 0.0) ? cr.x : cr.y;\n vec2 q = abs(p) - b + cr.x;\n return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;\n }\n","\n ").concat("\n float ellipseSD(vec2 p, vec2 ab) {\n p = abs( p ); // symmetry\n\n // find root with Newton solver\n vec2 q = ab*(p-ab);\n float w = (q.x1.0) ? d : -d;\n }\n","\n\n vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha\n return vec4( \n top.rgb + (bot.rgb * (1.0 - top.a)),\n top.a + (bot.a * (1.0 - top.a)) \n );\n }\n\n vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance\n // scale to the zoom level so that borders don't look blurry when zoomed in\n // note 1.5 is an aribitrary value chosen because it looks good\n return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d))); \n }\n\n void main(void) {\n if(vVertType == ").concat(0,") {\n // look up the texel from the texture unit\n ").concat(r.map((function(e){return"if(vAtlasId == ".concat(e,") outColor = texture(uTexture").concat(e,", vTexCoord);")})).join("\n\telse "),"\n } \n else if(vVertType == ").concat(3,") {\n // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';\n outColor = blend(vColor, uBGColor);\n outColor.a = 1.0; // make opaque, masks out line under arrow\n }\n else if(vVertType == ").concat(4," && vBorderWidth == vec2(0.0)) { // simple rectangle with no border\n outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done\n }\n else if(vVertType == ").concat(4," || vVertType == ").concat(7," \n || vVertType == ").concat(5," || vVertType == ").concat(6,") { // use SDF\n\n float outerBorder = vBorderWidth[0];\n float innerBorder = vBorderWidth[1];\n float borderPadding = outerBorder * 2.0;\n float w = vTopRight.x - vBotLeft.x - borderPadding;\n float h = vTopRight.y - vBotLeft.y - borderPadding;\n vec2 b = vec2(w/2.0, h/2.0); // half width, half height\n vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center\n\n float d; // signed distance\n if(vVertType == ").concat(4,") {\n d = rectangleSD(p, b);\n } else if(vVertType == ").concat(7," && w == h) {\n d = circleSD(p, b.x); // faster than ellipse\n } else if(vVertType == ").concat(7,") {\n d = ellipseSD(p, b);\n } else {\n d = roundRectangleSD(p, b, vCornerRadius.wzyx);\n }\n\n // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling\n // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box\n if(d > 0.0) {\n if(d > outerBorder) {\n discard;\n } else {\n outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);\n }\n } else {\n if(d > innerBorder) {\n vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;\n vec4 innerBorderColor = blend(vBorderColor, vColor);\n outColor = distInterp(innerBorderColor, outerColor, d);\n } \n else {\n vec4 outerColor;\n if(innerBorder == 0.0 && outerBorder == 0.0) {\n outerColor = vec4(0);\n } else if(innerBorder == 0.0) {\n outerColor = vBorderColor;\n } else {\n outerColor = blend(vBorderColor, vColor);\n }\n outColor = distInterp(vColor, outerColor, d - innerBorder);\n }\n }\n }\n else {\n outColor = vColor;\n }\n\n ").concat(e.picking?"if(outColor.a == 0.0) discard;\n else outColor = vIndex;":"","\n }\n "),i=function(e,t,n){var r=Hd(e,e.VERTEX_SHADER,t),a=Hd(e,e.FRAGMENT_SHADER,n),i=e.createProgram();if(e.attachShader(i,r),e.attachShader(i,a),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("Could not initialize shaders");return i}(t,n,a);i.aPosition=t.getAttribLocation(i,"aPosition"),i.aIndex=t.getAttribLocation(i,"aIndex"),i.aVertType=t.getAttribLocation(i,"aVertType"),i.aTransform=t.getAttribLocation(i,"aTransform"),i.aAtlasId=t.getAttribLocation(i,"aAtlasId"),i.aTex=t.getAttribLocation(i,"aTex"),i.aPointAPointB=t.getAttribLocation(i,"aPointAPointB"),i.aPointCPointD=t.getAttribLocation(i,"aPointCPointD"),i.aLineWidth=t.getAttribLocation(i,"aLineWidth"),i.aColor=t.getAttribLocation(i,"aColor"),i.aCornerRadius=t.getAttribLocation(i,"aCornerRadius"),i.aBorderColor=t.getAttribLocation(i,"aBorderColor"),i.uPanZoomMatrix=t.getUniformLocation(i,"uPanZoomMatrix"),i.uAtlasSize=t.getUniformLocation(i,"uAtlasSize"),i.uBGColor=t.getUniformLocation(i,"uBGColor"),i.uZoom=t.getUniformLocation(i,"uZoom"),i.uTextures=[];for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:gh.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,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(e,t){return!!e.visible()&&(!t||!t.isVisible||t.isVisible(e))}},{key:"drawTexture",value:function(e,t,n){var a=this.atlasManager,o=this.batchManager,s=a.getRenderTypeOpts(n);if(this._isVisible(e,s)&&(!e.isEdge()||this._isValidEdge(e))){if(this.renderTarget.picking&&s.getTexPickingMode){var l=s.getTexPickingMode(e);if(l===vh)return;if(l==yh)return void this.drawPickingRectangle(e,t,n)}var u,c=r(a.getAtlasInfo(e,n));try{for(c.s();!(u=c.n()).done;){var d=u.value,h=d.atlas,f=d.tex1,p=d.tex2;o.canAddToCurrentBatch(h)||this.endBatch();for(var g=o.getAtlasIndexForBatch(h),v=0,y=[[f,!0],[p,!1]];v=this.maxInstances&&this.endBatch()}}}}catch(e){c.e(e)}finally{c.f()}}}},{key:"setTransformMatrix",value:function(e,t,n,r){var a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=0;if(n.shapeProps&&n.shapeProps.padding&&(i=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,l=r.tex2,u=s.w/(s.w+l.w);a||(u=1-u);var c=this._getAdjustedBB(o,i,a,u);this._applyTransformMatrix(t,c,n,e)}else{var d=n.getBoundingBox(e),h=this._getAdjustedBB(d,i,!0,1);this._applyTransformMatrix(t,h,n,e)}}},{key:"_applyTransformMatrix",value:function(e,t,n,r){var a,i;sh(e);var o=n.getRotation?n.getRotation(r):0;if(0!==o){var s=n.getRotationPoint(r);lh(e,e,[s.x,s.y]),uh(e,e,o);var l=n.getRotationOffset(r);a=l.x+(t.xOffset||0),i=l.y+(t.yOffset||0)}else a=t.x1,i=t.y1;lh(e,e,[a,i]),ch(e,e,[t.w,t.h])}},{key:"_getAdjustedBB",value:function(e,t,n,r){var a=e.x1,i=e.y1,o=e.w,s=e.h;t&&(a-=t,i-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(a+=l=o-u,o=u),{x1:a,y1:i,w:o,h:s,xOffset:l,yOffset:e.yOffset}}},{key:"drawPickingRectangle",value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),a=this.instanceCount;this.vertTypeBuffer.getView(a)[0]=4,Jd(t,this.indexBuffer.getView(a)),Qd([0,0,0],1,this.colorBuffer.getView(a));var i=this.transformBuffer.getMatrixView(a);this.setTransformMatrix(e,i,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:"drawNode",value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var a=r.shapeProps,i=this._getVertTypeForShape(e,a.shape);if(void 0===i||r.isSimple&&!r.isSimple(e,this.renderTarget))this.drawTexture(e,t,n);else{var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=i,5===i||6===i){var s=r.getBoundingBox(e),l=this._getCornerRadius(e,a.radius,s),u=this.cornerRadiusBuffer.getView(o);u[0]=l,u[1]=l,u[2]=l,u[3]=l,6===i&&(u[0]=0,u[2]=0)}Jd(t,this.indexBuffer.getView(o));var c=this.renderTarget.picking?1:"node-body"===n?e.effectiveOpacity():1,d=this.renderTarget.picking?1:e.pstyle(a.opacity).value*c;Qd(e.pstyle(a.color).value,d,this.colorBuffer.getView(o));var h=this.lineWidthBuffer.getView(o);if(h[0]=0,h[1]=0,a.border){var f=e.pstyle("border-width").value;if(f>0){Qd(e.pstyle("border-color").value,c*e.pstyle("border-opacity").value,this.borderColorBuffer.getView(o));var p=e.pstyle("border-position").value;if("inside"===p)h[0]=0,h[1]=-f;else if("outside"===p)h[0]=f,h[1]=0;else{var g=f/2;h[0]=g,h[1]=-g}}}var v=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,v,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:"_getVertTypeForShape",value:function(e,t){switch(e.pstyle(t).value){case"rectangle":return 4;case"ellipse":return 7;case"roundrectangle":case"round-rectangle":return 5;case"bottom-round-rectangle":return 6;default:return}}},{key:"_getCornerRadius",value:function(e,t,n){var r=n.w,a=n.h;if("auto"===e.pstyle(t).value)return Mn(r,a);var i=e.pstyle(t).pfValue,o=r/2,s=a/2;return Math.min(i,s,o)}},{key:"drawEdgeArrow",value:function(e,t,n){if(e.visible()){var r,a,i,o=e._private.rscratch;if("source"===n?(r=o.arrowStartX,a=o.arrowStartY,i=o.srcArrowAngle):(r=o.arrowEndX,a=o.arrowEndY,i=o.tgtArrowAngle),!(isNaN(r)||null==r||isNaN(a)||null==a||isNaN(i)||null==i))if("none"!==e.pstyle(n+"-arrow-shape").value){var s=e.pstyle(n+"-arrow-color").value,l=e.pstyle("opacity").value*e.pstyle("line-opacity").value,u=e.pstyle("width").pfValue,c=e.pstyle("arrow-scale").value,d=this.r.getArrowWidth(u,c),h=this.instanceCount,f=this.transformBuffer.getMatrixView(h);sh(f),lh(f,f,[r,a]),ch(f,f,[d,d]),uh(f,f,i),this.vertTypeBuffer.getView(h)[0]=3,Jd(t,this.indexBuffer.getView(h)),Qd(s,l,this.colorBuffer.getView(h)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:"drawEdgeLine",value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle("opacity").value,a=e.pstyle("line-opacity").value,i=e.pstyle("width").pfValue,o=e.pstyle("line-color").value,s=r*a;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),4==n.length){var l=this.instanceCount;this.vertTypeBuffer.getView(l)[0]=1,Jd(t,this.indexBuffer.getView(l)),Qd(o,s,this.colorBuffer.getView(l)),this.lineWidthBuffer.getView(l)[0]=i;var u=this.pointAPointBBuffer.getView(l);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var c=0;c=this.maxInstances&&this.endBatch()}}}}},{key:"_isValidEdge",value:function(e){var t=e._private.rscratch;return!t.badLine&&null!=t.allpts&&!isNaN(t.allpts[0])}},{key:"_getEdgePoints",value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(4==n.length)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:"_getNumSegments",value:function(e){return Math.min(Math.max(15,5),this.maxInstances)}},{key:"_getCurveSegmentPoints",value:function(e,t){if(4==e.length)return e;for(var n=Array(2*(t+1)),r=0;r<=t;r++)if(0==r)n[0]=e[0],n[1]=e[1];else if(r==t)n[2*r]=e[e.length-2],n[2*r+1]=e[e.length-1];else{var a=r/t;this._setCurvePoint(e,a,n,2*r)}return n}},{key:"_setCurvePoint",value:function(e,t,n,r){if(!(e.length<=2)){for(var a=Array(e.length-2),i=0;i0}},u=function(e){return"yes"===e.pstyle("text-events").strValue?yh:vh},c=function(e){var t=e.position(),n=t.x,r=t.y,a=e.outerWidth(),i=e.outerHeight();return{w:a,h:i,x1:n-a/2,y1:r-i/2}};n.drawing.addAtlasCollection("node",{texRows:e.webglTexRowsNodes}),n.drawing.addAtlasCollection("label",{texRows:e.webglTexRows}),n.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),n.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:c,isSimple:Zd,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),n.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:c,isVisible:l("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),n.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:c,isVisible:l("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),n.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:u,getKey:wh(t.getLabelKey,null),getBoundingBox:Eh(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:o(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:s("label")}),n.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:u,getKey:wh(t.getSourceLabelKey,"source"),getBoundingBox:Eh(t.getSourceLabelBox,"source"),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:o("source"),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:s("source-label")}),n.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:u,getKey:wh(t.getTargetLabelKey,"target"),getBoundingBox:Eh(t.getTargetLabelBox,"target"),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:o("target"),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:s("target-label")});var d=Ae((function(){console.log("garbage collect flag set"),n.data.gc=!0}),1e4);n.onUpdateEleCalcs((function(e,t){var r=!1;t&&t.length>0&&(r|=n.drawing.invalidate(t)),r&&d()})),function(e){var t=e.render;e.render=function(n){n=n||{};var r=e.cy;e.webgl&&(r.zoom()>gd?(!function(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}(e),t.call(e,n)):(!function(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}(e),Ch(e,n,gh.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,a,o){return function(e,t,n){var a,o,s,l=function(e,t,n){var r,a,o,s,l=Gd(e),u=l.pan,c=l.zoom,d=function(e,t,n,r,a){var i=r*n+t.x,o=a*n+t.y;return[i,o=Math.round(e.canvasHeight-o)]}(e,u,c,t,n),h=i(d,2),f=h[0],p=h[1],g=6;if(r=f-g/2,a=p-g/2,s=g,0===(o=g)||0===s)return[];var v=e.data.contexts[e.WEBGL];v.bindFramebuffer(v.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(v.viewport(0,0,v.canvas.width,v.canvas.height),Ch(e,null,gh.PICKING),e.pickingFrameBuffer.needsDraw=!1);var y=o*s,m=new Uint8Array(4*y);v.readPixels(r,a,o,s,v.RGBA,v.UNSIGNED_BYTE,m),v.bindFramebuffer(v.FRAMEBUFFER,null);for(var b=new Set,x=0;x=0&&b.add(w)}return b}(e,t,n),u=e.getCachedZSortedEles(),c=r(l);try{for(c.s();!(s=c.n()).done;){var d=u[s.value];if(!a&&d.isNode()&&(a=d),!o&&d.isEdge()&&(o=d),a&&o)break}}catch(e){c.e(e)}finally{c.f()}return[a,o].filter(Boolean)}(e,t,n)};var a=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){a.call(e),e.pickingFrameBuffer.needsDraw=!0};var o=e.notify;e.notify=function(t,n){o.call(e,t,n),"viewport"===t||"bounds"===t?e.pickingFrameBuffer.needsDraw=!0:"background"===t&&e.drawing.invalidate(n,{type:"node-body"})}}(n)};var wh=function(e,t){return function(n){var r=e(n),a=xh(n,t);return a.length>1?a.map((function(e,t){return"".concat(r,"_").concat(t)})):r}},Eh=function(e,t){return function(n,r){var a=e(n);if("string"==typeof r){var i=r.indexOf("_");if(i>0){var o=Number(r.substring(i+1)),s=xh(n,t),l=a.h/s.length,u=l*o,c=a.y1+u;return{x1:a.x1,w:a.w,y1:c,h:l,yOffset:u}}}return a}};function kh(e,t){var n=e.canvasWidth,r=e.canvasHeight,a=Gd(e),i=a.pan,o=a.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(i.x,i.y),t.scale(o,o)}function Th(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,"node-underlay"),r.drawNode(n,t,"node-body"),r.drawTexture(n,t,"label"),r.drawNode(n,t,"node-overlay")):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,"source"),r.drawEdgeArrow(n,t,"target"),r.drawTexture(n,t,"label"),r.drawTexture(n,t,"edge-source-label"),r.drawTexture(n,t,"edge-target-label"))}function Ch(e,t,n){var a;e.webglDebug&&(a=performance.now());var i=e.drawing,o=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&function(e,t){e.drawSelectionRectangle(t,(function(t){return kh(e,t)}))}(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var s=e.data.contexts[e.WEBGL];n.screen?(s.clearColor(0,0,0,0),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA)):s.disable(s.BLEND),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT),s.viewport(0,0,s.canvas.width,s.canvas.height);var l=function(e){var t=e.canvasWidth,n=e.canvasHeight,r=Gd(e),a=r.pan,i=r.zoom,o=oh();lh(o,o,[a.x,a.y]),ch(o,o,[i,i]);var s=oh();!function(e,t,n){e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1}(s,t,n);var l,u,c,d,h,f,p,g,v,y,m,b,x,w,E,k,T,C,P,S,B,D=oh();return l=D,c=o,d=(u=s)[0],h=u[1],f=u[2],p=u[3],g=u[4],v=u[5],y=u[6],m=u[7],b=u[8],x=c[0],w=c[1],E=c[2],k=c[3],T=c[4],C=c[5],P=c[6],S=c[7],B=c[8],l[0]=x*d+w*p+E*y,l[1]=x*h+w*g+E*m,l[2]=x*f+w*v+E*b,l[3]=k*d+T*p+C*y,l[4]=k*h+T*g+C*m,l[5]=k*f+T*v+C*b,l[6]=P*d+S*p+B*y,l[7]=P*h+S*g+B*m,l[8]=P*f+S*v+B*b,D}(e),u=e.getCachedZSortedEles();if(o=u.length,i.startFrame(l,n),n.screen){for(var c=0;c0&&i>0){h.clearRect(0,0,a,i),h.globalCompositeOperation="source-over";var f=this.getCachedZSortedEles();if(e.full)h.translate(-n.x1*l,-n.y1*l),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(n.x1*l,n.y1*l);else{var p=t.pan(),g={x:p.x*l,y:p.y*l};l*=t.zoom(),h.translate(g.x,g.y),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(-g.x,-g.y)}e.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=e.bg,h.rect(0,0,a,i),h.fill())}return d},Rh.png=function(e){return Nh(e,this.bufferCanvasImage(e),"image/png")},Rh.jpg=function(e){return Nh(e,this.bufferCanvasImage(e),"image/jpeg")};var Lh={nodeShapeImpl:function(e,t,n,r,a,i,o,s){switch(e){case"ellipse":return this.drawEllipsePath(t,n,r,a,i);case"polygon":return this.drawPolygonPath(t,n,r,a,i,o);case"round-polygon":return this.drawRoundPolygonPath(t,n,r,a,i,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,n,r,a,i,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,n,r,a,i,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,n,r,a,i,s);case"barrel":return this.drawBarrelPath(t,n,r,a,i)}}},zh=Vh,Oh=Vh.prototype;function Vh(e){var t=this,n=t.cy.window().document;e.webgl&&(Oh.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),t.data={canvases:new Array(Oh.CANVAS_LAYERS),contexts:new Array(Oh.CANVAS_LAYERS),canvasNeedsRedraw:new Array(Oh.CANVAS_LAYERS),bufferCanvases:new Array(Oh.BUFFER_COUNT),bufferContexts:new Array(Oh.CANVAS_LAYERS)};var r="-webkit-tap-highlight-color",a="rgba(0,0,0,0)";t.data.canvasContainer=n.createElement("div");var i=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=a,i.position="relative",i.zIndex="0",i.overflow="hidden";var o=e.cy.container();o.appendChild(t.data.canvasContainer),o.style[r]=a;var s={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};d&&d.userAgent.match(/msie|trident|edge/i)&&(s["-ms-touch-action"]="none",s["touch-action"]="none");for(var l=0;lto" → { from, to, seenAt, count }. */ const links = new Map(); -/** Width the last layout was computed for — 0 means "not yet visible", see observeSize. */ -let layoutWidth = 0; - // ─── Loading ─── -function loadScript(src) { - return new Promise((resolve, reject) => { +function loadElk() { + elkReady ??= new Promise((resolve, reject) => { const script = document.createElement("script"); - script.src = src; - script.onload = resolve; - script.onerror = () => reject(new Error(`Could not load ${src}`)); + script.src = ELK_SCRIPT; + script.onload = () => resolve(); + script.onerror = () => { + elkReady = null; + reject(new Error(`Could not load ${ELK_SCRIPT}`)); + }; document.head.append(script); }); -} - -function loadLibraries() { - librariesLoaded ??= (async () => { - // In order: cytoscape-elk registers against the globals of the two before it. - for (const src of LIBRARIES) await loadScript(src); - window.cytoscape.use(window.cytoscapeElk); - })(); - return librariesLoaded; -} - -function token(name) { - return getComputedStyle(document.documentElement).getPropertyValue(name).trim() || "#888"; + return elkReady; } // ─── View ─── @@ -102,19 +140,19 @@ export async function renderTeam() { if (!container) return; leaveTeam(); - const layout = erstelleElement("div", { klasse: "team-ansicht" }); - layout.append( - erstelleElement("h1", { text: t("team.title") }), - erstelleElement("p", { klasse: "gedaempft", text: t("team.subtitle") }) - ); - summary = erstelleElement("div", { klasse: "team-zusammenfassung gruppe-horizontal" }); - const canvas = erstelleElement("div", { klasse: "team-graph", id: "team-graph" }); + const head = erstelleElement("div", { klasse: "team-kopf" }, + erstelleElement("div", {}, + erstelleElement("h1", { text: t("team.title") }), + erstelleElement("p", { klasse: "gedaempft", text: t("team.subtitle") })), + summary); + + canvas = erstelleElement("div", { klasse: "team-leinwand" }); panel = erstelleElement("aside", { klasse: "team-seitenleiste" }); panel.hidden = true; - layout.append(summary, erstelleElement("div", { klasse: "team-flaeche" }, canvas, panel), buildLegend()); - container.replaceChildren(layout); + const area = erstelleElement("div", { klasse: "team-arbeitsflaeche" }, buildTree(), canvas, panel); + container.replaceChildren(erstelleElement("div", { klasse: "team-ansicht" }, head, area, buildLegend())); if (!holeAktiveInstanz()) { canvas.replaceChildren(erstelleElement("div", { klasse: "hinweis-zentriert", text: t("team.noInstance") })); @@ -124,397 +162,760 @@ export async function renderTeam() { canvas.replaceChildren(erstelleElement("div", { klasse: "hinweis-zentriert", text: t("common.loading") })); try { - await loadLibraries(); + await loadElk(); + elk ??= new window.ELK(); snapshot = await api("/team"); } catch (err) { canvas.replaceChildren(erstelleElement("div", { klasse: "fehler-zentriert", text: err.message })); return; } - canvas.replaceChildren(); + buildCanvas(); indexSnapshot(); - expanded = loadExpanded(); + expandedCards = loadExpandedCards(); for (const link of snapshot.links ?? []) recordLink(link); - drawGraph(canvas); + await render(); unsubscribe = abonnieren("activity", onActivity); refreshTimer = setInterval(refresh, REFRESH_MS); fadeTimer = setInterval(drawLinks, 1_000); } -/** Called when the route changes: stop listening, stop timers, free the graph. */ +/** Called when the route changes: stop listening, stop timers, forget the picture. */ export function leaveTeam() { unsubscribe?.(); unsubscribe = null; clearInterval(refreshTimer); clearInterval(fadeTimer); clearTimeout(refreshPending); - refreshTimer = fadeTimer = refreshPending = null; + clearTimeout(searchPending); + refreshTimer = fadeTimer = refreshPending = searchPending = null; resizeObserver?.disconnect(); resizeObserver = null; - cy?.destroy(); - cy = null; + layoutGeneration++; + canvas = world = cardLayer = edgeLayer = linkLayer = null; + cards = new Map(); + cardElements = new Map(); + positions = new Map(); + fitted = false; + treeOpen = null; + query = ""; + filter = "all"; + hits = null; selected = null; - structureKey = ""; - layoutWidth = 0; + revealAgent = null; links.clear(); } -// ─── The tree ─── +// ─── The model: cards and how they hang together ─── function indexSnapshot() { unitsById = new Map((snapshot.units ?? []).map((u) => [u.id, u])); membersById = new Map(snapshot.members.map((m) => [m.agentId, m])); + + // The instance itself is the top card: it holds the agents without a unit and counts + // everyone. The counts of the units come from the instance; only this total is added + // up here, from states the instance decided. + const states = {}; + for (const member of snapshot.members) states[member.state] = (states[member.state] ?? 0) + 1; + const worst = snapshot.members.map((m) => m.state).sort((a, b) => URGENCY[b] - URGENCY[a])[0] ?? "Idle"; + + cards = new Map(); + cards.set(ROOT, { + id: ROOT, + parent: null, + title: holeAktiveInstanz(), + subtitle: t("team.rootSubtitle"), + members: snapshot.members.filter((m) => !m.unitId || !unitsById.has(m.unitId)), + agents: snapshot.members.length, + states, + pendingApprovals: snapshot.members.reduce((sum, m) => sum + m.pendingApprovals, 0), + worst + }); + + for (const unit of snapshot.units ?? []) { + const lead = unit.leaderAgentId ? membersById.get(unit.leaderAgentId) : null; + cards.set(UNIT_PREFIX + unit.id, { + id: UNIT_PREFIX + unit.id, + parent: unit.parentId && unitsById.has(unit.parentId) ? UNIT_PREFIX + unit.parentId : ROOT, + unit, + title: unit.name, + subtitle: lead ? `★ ${lead.displayName || lead.agentId}` : unit.path, + members: snapshot.members.filter((m) => m.unitId === unit.id), + agents: unit.agents, + states: unit.states ?? {}, + pendingApprovals: unit.pendingApprovals, + worst: unit.worst + }); + } } -/** The unit and every unit above it, nearest first; stops at a cycle. */ -function chain(unitId) { +function cardOf(member) { + return member.unitId && unitsById.has(member.unitId) ? UNIT_PREFIX + member.unitId : ROOT; +} + +/** The card and every card above it, nearest first; stops at a cycle. */ +function cardChain(cardId) { const result = []; - for (let unit = unitsById.get(unitId); unit && result.length < MAX_DEPTH; unit = unitsById.get(unit.parentId)) { - if (result.includes(unit)) break; - result.push(unit); + for (let card = cards.get(cardId); card && result.length < MAX_DEPTH; card = cards.get(card.parent)) { + if (result.includes(card)) break; + result.push(card); } return result; } -/** Whether the unit and everything above it are expanded — then its content is drawn. */ -function isOpen(unitId) { - return chain(unitId).every((u) => expanded.has(u.id)); +function byName(a, b) { + return (a.displayName || a.agentId).localeCompare(b.displayName || b.agentId); } -/** Whether the unit itself is drawn, as a box or as a container. */ -function isVisible(unit) { - return !unit.parentId || !unitsById.has(unit.parentId) || isOpen(unit.parentId); +function isLead(member) { + return Boolean(member.isLead); +} + +// ─── Search and filter ─── + +function searching() { + return query !== "" || filter !== "all"; +} + +function memberMatches(member) { + const states = FILTERS[filter]; + if (states && !states.includes(member.state)) return false; + if (!query) return true; + const q = query.toLowerCase(); + return [member.displayName, member.agentId, member.model] + .some((text) => (text ?? "").toLowerCase().includes(q)); +} + +function cardMatches(card) { + // A unit is found by its name only while no state filter is set — "problems" asks for + // agents, not for units that happen to be called like the search. + if (!query || filter !== "all") return false; + const q = query.toLowerCase(); + return [card.title, card.unit?.path].some((text) => (text ?? "").toLowerCase().includes(q)); } /** - * Where an agent is drawn: itself if its unit is open, otherwise the topmost collapsed unit - * on its path. Links are drawn between these, so a collapsed unit collects the links of - * everyone inside it. + * What the search and filter found: the agents, the cards that match by name, and every + * card on the way down to either. Everything else is dimmed. */ -function representative(agentId) { - const member = membersById.get(agentId); - if (!member) return null; - let rep = null; - for (const unit of chain(member.unitId)) { - if (!expanded.has(unit.id)) rep = unit.id; +function computeHits() { + if (!searching()) { + hits = null; + return; } - return rep ? UNIT_PREFIX + rep : agentId; + const agents = new Set(snapshot.members.filter(memberMatches).map((m) => m.agentId)); + const matchedCards = new Set([...cards.values()].filter(cardMatches).map((c) => c.id)); + + const onPath = new Set(); + const ends = [...matchedCards, ...[...agents].map((id) => cardOf(membersById.get(id)))]; + for (const cardId of ends) for (const card of cardChain(cardId)) onPath.add(card.id); + + hits = { agents, cards: matchedCards, onPath }; } -function storageKey() { - return `clawd.team.expanded.${holeAktiveInstanz()}`; -} +// ─── Tree on the left ─── -function loadExpanded() { - try { - const stored = localStorage.getItem(storageKey()); - if (stored) return new Set(JSON.parse(stored)); - } catch { - // Private window or blocked storage: fall back to the default below. - } - // A small team is shown whole; a large one starts at the departments. - return snapshot.members.length <= EXPAND_ALL_UP_TO - ? new Set(unitsById.keys()) - : new Set(); -} - -function saveExpanded() { - try { - localStorage.setItem(storageKey(), JSON.stringify([...expanded])); - } catch { - // Only a convenience — the default applies next time. - } -} - -function toggleUnit(unitId, open) { - if (open ?? !expanded.has(unitId)) expanded.add(unitId); - else expanded.delete(unitId); - saveExpanded(); - applySnapshot(); -} - -// ─── Graph ─── - -function drawGraph(canvas) { - cy = window.cytoscape({ - container: canvas, - elements: [], - wheelSensitivity: 0.2, - minZoom: 0.2, - // A handful of collapsed units would otherwise fill the area with giant boxes. - maxZoom: 1.6, - // Nodes are not dragged: the layout comes from the structure, not the hand. - autoungrabify: true, - style: [ - { - selector: "node", - style: { - shape: "rectangle", - width: 190, - height: 58, - "background-color": token("--surface"), - "border-width": 2, - "border-color": "data(colour)", - label: "data(label)", - "text-wrap": "wrap", - "text-max-width": 176, - "text-valign": "center", - "text-halign": "center", - "font-family": "Barlow, sans-serif", - "font-size": 13, - color: token("--text") - } - }, - { selector: "node.aktiv", style: { "border-width": 4 } }, - { selector: "node.leitung", style: { "font-weight": "bold" } }, - // A collapsed unit: a box that stands for everyone inside it. - { - selector: "node.einheit", - style: { - shape: "round-rectangle", - width: 210, - height: 70, - "border-width": 3, - "border-style": "double", - "background-color": token("--surface-subtil"), - "font-weight": "bold" - } - }, - { selector: "node.einheit.aktiv", style: { "border-width": 5 } }, - // An expanded unit: a container around its members and sub-units. - { - selector: "node:parent", - style: { - shape: "round-rectangle", - padding: 20, - "border-width": 2, - "border-style": "dashed", - "background-color": token("--surface-subtil"), - "background-opacity": 0.5, - "text-valign": "top", - "text-halign": "center", - "text-margin-y": -4, - "text-max-width": 400, - "font-weight": "bold" - } - }, - { selector: "node:selected", style: { "overlay-color": token("--accent"), "overlay-opacity": 0.15 } }, - { - selector: "edge", - style: { - width: "data(width)", - "line-color": token("--accent"), - "target-arrow-color": token("--accent"), - "target-arrow-shape": "triangle", - "curve-style": "bezier", - opacity: "data(opacity)", - label: "data(label)", - "font-size": 11, - color: token("--text"), - "text-background-color": token("--surface"), - "text-background-opacity": 1, - "text-background-padding": 2 - } - } - ] +function buildTree() { + const input = erstelleElement("input", { + type: "search", + klasse: "team-suche", + placeholder: t("team.searchPlaceholder"), + "aria-label": t("team.searchPlaceholder") + }); + input.addEventListener("input", () => { + clearTimeout(searchPending); + searchPending = setTimeout(() => { + query = input.value.trim(); + render(); + }, 150); + }); + input.addEventListener("keydown", (event) => { + if (event.key !== "Enter") return; + clearTimeout(searchPending); + query = input.value.trim(); + render().then(focusFirstHit); }); - cy.on("tap", "node", (event) => { - const id = event.target.id(); - if (!id.startsWith(UNIT_PREFIX)) { - openPanel({ agent: id }); + const filters = erstelleElement("div", { klasse: "team-filter", role: "group", "aria-label": t("team.filterLabel") }); + for (const name of Object.keys(FILTERS)) { + filters.append(erstelleElement("button", { + type: "button", + text: t(`team.filter.${name}`), + "aria-pressed": String(name === filter), + dataset: { filter: name }, + onclick: () => { + filter = name; + for (const button of filters.children) button.setAttribute("aria-pressed", String(button.dataset.filter === name)); + render(); + } + })); + } + + matchInfo = erstelleElement("div", { klasse: "team-treffer-info", "aria-live": "polite" }); + treeList = erstelleElement("nav", { klasse: "team-baum-liste", "aria-label": t("team.structure") }); + + return erstelleElement("aside", { klasse: "team-baum" }, + erstelleElement("div", { klasse: "team-baum-kopf" }, + erstelleElement("div", { klasse: "team-baum-titel", text: t("team.structure") }), + input, filters, matchInfo), + treeList); +} + +function renderTree() { + if (!treeList || !snapshot) return; + + // A small organisation starts fully open, a large one at the top level. + treeOpen ??= new Set(unitsById.size <= 12 ? cards.keys() : [ROOT]); + + const list = erstelleElement("ul", { role: "tree" }); + list.append(treeCard(cards.get(ROOT), 0, new Set())); + treeList.replaceChildren(list); + + if (!hits) { + matchInfo.textContent = ""; + } else { + const n = hits.agents.size + hits.cards.size; + matchInfo.textContent = n === 0 ? t("team.noMatches") : n === 1 ? t("team.matchesOne") : t("team.matches", { n }); + } +} + +function treeCard(card, depth, seen) { + seen.add(card.id); + const children = [...cards.values()].filter((c) => c.parent === card.id && !seen.has(c.id)); + const members = [...card.members].sort((a, b) => (isLead(b) - isLead(a)) || byName(a, b)); + // While searching, the tree shows the way to what was found and opens it. + const open = hits ? hits.onPath.has(card.id) : treeOpen.has(card.id); + const worst = STATES[card.worst] ?? STATES.Idle; + const attention = Object.entries(card.states) + .filter(([state]) => URGENCY[state] >= 2) + .reduce((sum, [, n]) => sum + n, 0); + + const item = erstelleElement("li", { role: "treeitem", "aria-expanded": String(open) }); + item.append(erstelleElement("button", { + type: "button", + klasse: [ + "team-baum-eintrag", + `ton-${worst.tone}`, + hits?.cards.has(card.id) ? "treffer" : "", + hits && !hits.onPath.has(card.id) ? "gedimmt" : "", + selected?.card === card.id ? "ausgewaehlt" : "" + ].join(" "), + stil: `--tiefe: ${depth}`, + onclick: () => { + openPanel({ card: card.id }); + focusCard(card.id); + } + }, + erstelleElement("span", { + klasse: "team-pfeil", + text: children.length || members.length ? (open ? "▾" : "▸") : "", + onclick: (event) => { + event.stopPropagation(); + if (treeOpen.has(card.id)) treeOpen.delete(card.id); + else treeOpen.add(card.id); + renderTree(); + } + }), + erstelleElement("span", { klasse: "team-marker", text: worst.symbol }), + erstelleElement("span", { klasse: "team-baum-name", text: card.title }), + // Mixed states, so a neutral flag and not the symbol of one of them. + attention ? erstelleElement("span", { klasse: `team-zahl ton-${worst.tone}`, text: `⚑ ${attention}`, title: t("team.needsAttention", { n: attention }) }) : null, + erstelleElement("span", { klasse: "team-zahl", text: String(card.agents) }))); + + if (open) { + const group = erstelleElement("ul", { role: "group" }); + for (const member of members) { + if (hits && !hits.agents.has(member.agentId) && !hits.cards.has(card.id)) continue; + group.append(treeMember(member, depth + 1)); + } + for (const child of children) { + if (hits && !hits.onPath.has(child.id)) continue; + group.append(treeCard(child, depth + 1, seen)); + } + item.append(group); + } + return item; +} + +function treeMember(member, depth) { + const state = STATES[member.state] ?? STATES.Idle; + return erstelleElement("li", { role: "treeitem" }, + erstelleElement("button", { + type: "button", + klasse: [ + "team-baum-eintrag", + `ton-${state.tone}`, + hits?.agents.has(member.agentId) ? "treffer" : "", + selected?.agent === member.agentId ? "ausgewaehlt" : "" + ].join(" "), + stil: `--tiefe: ${depth}`, + title: t(`team.state.${member.state}`), + onclick: () => showAgent(member.agentId) + }, + erstelleElement("span", { klasse: "team-pfeil" }), + erstelleElement("span", { klasse: "team-marker", text: state.symbol }), + erstelleElement("span", { klasse: "team-baum-name", text: `${isLead(member) ? "★ " : ""}${member.displayName || member.agentId}` }))); +} + +/** Brings an agent into view: its card, its row (even in a compact card), and its details. */ +async function showAgent(agentId) { + const member = membersById.get(agentId); + if (!member) return; + revealAgent = agentId; + selected = { agent: agentId }; + await render(); + // The panel first: it narrows the canvas, and the card is centred in what is left. + openPanel({ agent: agentId }); + focusCard(cardOf(member)); + const row = rowElement(agentId); + if (row) { + row.classList.remove("blinkt"); + void row.offsetWidth; // restart the animation + row.classList.add("blinkt"); + } +} + +function focusFirstHit() { + if (!hits) return; + const agentId = [...hits.agents][0]; + if (agentId) { + showAgent(agentId); + return; + } + const cardId = [...hits.cards][0]; + if (cardId) { + openPanel({ card: cardId }); + focusCard(cardId); + } +} + +// ─── Canvas: pan and zoom ─── + +function buildCanvas() { + edgeLayer = document.createElementNS(SVG, "svg"); + edgeLayer.setAttribute("class", "team-kanten"); + linkLayer = document.createElementNS(SVG, "svg"); + linkLayer.setAttribute("class", "team-links"); + linkLayer.append(arrowMarker()); + cardLayer = erstelleElement("div", { klasse: "team-karten" }); + world = erstelleElement("div", { klasse: "team-welt" }); + world.append(edgeLayer, cardLayer, linkLayer); + + zoomValue = erstelleElement("span", { klasse: "team-zoomwert" }); + const liveToggle = erstelleElement("button", { + type: "button", + text: `⇢ ${t("team.liveLinks")}`, + "aria-pressed": String(showLinks), + onclick: () => { + showLinks = !showLinks; + liveToggle.setAttribute("aria-pressed", String(showLinks)); + drawLinks(); + } + }); + + canvas.replaceChildren( + world, + erstelleElement("div", { klasse: "team-leiste team-leiste-mitte" }, + liveToggle, + erstelleElement("button", { type: "button", text: `⤢ ${t("team.fit")}`, onclick: () => fit(true) })), + erstelleElement("div", { klasse: "team-leiste team-leiste-zoom" }, + erstelleElement("button", { type: "button", text: "−", title: t("team.zoomOut"), "aria-label": t("team.zoomOut"), onclick: () => zoomBy(1 / 1.25) }), + zoomValue, + erstelleElement("button", { type: "button", text: "+", title: t("team.zoomIn"), "aria-label": t("team.zoomIn"), onclick: () => zoomBy(1.25) }))); + + canvas.addEventListener("wheel", (event) => { + event.preventDefault(); + const box = canvas.getBoundingClientRect(); + zoomAt(event.clientX - box.left, event.clientY - box.top, Math.exp(-event.deltaY * 0.0015)); + }, { passive: false }); + + // Dragging pans — from anywhere, cards included. A drag is not a click: the click that + // ends it is swallowed before it reaches a card. + let drag = null; + let swallowClick = false; + canvas.addEventListener("pointerdown", (event) => { + if (event.button !== 0 || event.target.closest(".team-leiste")) return; + drag = { id: event.pointerId, x: event.clientX, y: event.clientY, vx: view.x, vy: view.y, moved: false }; + }); + canvas.addEventListener("pointermove", (event) => { + if (!drag || event.pointerId !== drag.id) return; + const dx = event.clientX - drag.x; + const dy = event.clientY - drag.y; + if (!drag.moved && Math.hypot(dx, dy) < 4) return; + if (!drag.moved) { + drag.moved = true; + canvas.setPointerCapture(event.pointerId); + canvas.classList.add("zieht"); + } + view.x = drag.vx + dx; + view.y = drag.vy + dy; + applyView(false); + }); + const endDrag = (event) => { + if (!drag || event.pointerId !== drag.id) return; + swallowClick = drag.moved; + drag = null; + canvas.classList.remove("zieht"); + }; + canvas.addEventListener("pointerup", endDrag); + canvas.addEventListener("pointercancel", endDrag); + canvas.addEventListener("click", (event) => { + if (swallowClick) { + swallowClick = false; + event.stopPropagation(); + event.preventDefault(); return; } - const unitId = id.slice(UNIT_PREFIX.length); - // A collapsed unit opens on the first click — looking inside is what the click is for. - if (!expanded.has(unitId)) toggleUnit(unitId, true); - openPanel({ unit: unitId }); - }); - cy.on("dbltap", "node:parent", (event) => toggleUnit(event.target.id().slice(UNIT_PREFIX.length), false)); - cy.on("tap", (event) => { if (event.target === cy) closePanel(); }); + if (event.target === canvas || event.target === world || event.target === cardLayer) closePanel(); + }, true); - applySnapshot(); - observeSize(canvas); -} - -/** - * The area can still be 0 px wide when the graph is first drawn — the page is being laid out - * around it. ELK then packs everything into one column, and nothing can be fitted. So: lay - * out again once the area has a width, and fit again whenever its size changes (the side - * panel opening, the window resizing). - */ -function observeSize(canvas) { + // The area can still be 0 px wide when the page is first laid out; fit once it has a size. resizeObserver = new ResizeObserver(() => { - if (!cy) return; - cy.resize(); - if (layoutWidth === 0 && canvas.clientWidth > 0) runLayout(); - else cy.fit(undefined, 30); + if (!fitted && canvas?.clientWidth > 0 && layoutSize.w > 0) fit(false); }); resizeObserver.observe(canvas); } -/** Counts layouts, so a layout overtaken by a newer one stops trying. */ -let layoutGeneration = 0; +function arrowMarker() { + const defs = document.createElementNS(SVG, "defs"); + const marker = document.createElementNS(SVG, "marker"); + marker.setAttribute("id", "team-pfeil"); + marker.setAttribute("viewBox", "0 0 10 10"); + marker.setAttribute("refX", "9"); + marker.setAttribute("refY", "5"); + marker.setAttribute("markerWidth", "7"); + marker.setAttribute("markerHeight", "7"); + marker.setAttribute("orient", "auto-start-reverse"); + const tip = document.createElementNS(SVG, "path"); + tip.setAttribute("d", "M0,0 L10,5 L0,10 z"); + tip.setAttribute("class", "team-pfeilspitze"); + marker.append(tip); + defs.append(marker); + return defs; +} -/** Runs one ELK layout with the given aspect ratio and returns the ratio it achieved. */ -function layoutOnce(aspectRatio) { - return new Promise((resolve) => { - const layout = cy.layout({ - name: "elk", - fit: false, - // The agents are packed evenly into the shape of the area, inside each container as - // on the top level. rectpacking keeps the order they were added in (units by path, - // the lead first), so a box does not jump around when a state changes. - elk: { - algorithm: "rectpacking", - "elk.spacing.nodeNode": 40, - "elk.aspectRatio": aspectRatio - }, - // Room for the container's own padding and its label above the members. - nodeLayoutOptions: (node) => node.isParent() - ? { - "elk.algorithm": "rectpacking", - "elk.padding": "[top=44,left=24,bottom=24,right=24]", - "elk.spacing.nodeNode": 24 - } - : {} - }); - // ELK computes asynchronously; measure once the positions are there. - layout.one("layoutstop", () => { - const box = cy?.elements().boundingBox(); - resolve(box && box.h > 0 ? box.w / box.h : 1); - }); - layout.run(); - }); +function clampZoom(s) { + return Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, s)); +} + +function applyView(animate) { + if (!world) return; + world.classList.toggle("gleitend", animate); + world.style.transform = `translate(${view.x}px, ${view.y}px) scale(${view.s})`; + // The dot grid moves and scales with the cards, so the canvas feels like one surface. + const grid = 20 * view.s; + canvas.style.backgroundSize = `${grid}px ${grid}px`; + canvas.style.backgroundPosition = `${view.x}px ${view.y}px`; + zoomValue.textContent = `${Math.round(view.s * 100)} %`; +} + +function zoomAt(cx, cy, factor) { + const s = clampZoom(view.s * factor); + view.x = cx - (cx - view.x) * (s / view.s); + view.y = cy - (cy - view.y) * (s / view.s); + view.s = s; + applyView(false); +} + +function zoomBy(factor) { + if (!canvas) return; + zoomAt(canvas.clientWidth / 2, canvas.clientHeight / 2, factor); +} + +function fit(animate) { + if (!canvas || canvas.clientWidth === 0 || layoutSize.w === 0) return; + const pad = 48; + const toolbar = 56; // the floating bar at the bottom must not cover a card + const s = clampZoom(Math.min( + (canvas.clientWidth - 2 * pad) / layoutSize.w, + (canvas.clientHeight - 2 * pad - toolbar) / layoutSize.h, + 1.1)); + view = { + s, + x: (canvas.clientWidth - layoutSize.w * s) / 2, + y: Math.max(pad, (canvas.clientHeight - toolbar - layoutSize.h * s) / 2) + }; + fitted = true; + applyView(animate); +} + +/** Moves a card into the middle — near its top, so a long list starts in view. */ +function focusCard(cardId) { + const pos = positions.get(cardId); + if (!pos || !canvas) return; + const s = clampZoom(Math.max(view.s, 0.85)); + view = { + s, + x: canvas.clientWidth / 2 - (pos.x + pos.w / 2) * s, + y: canvas.clientHeight / 2 - (pos.y + Math.min(pos.h / 2, 120)) * s + }; + applyView(true); +} + +// ─── Cards ─── + +function storageKey() { + return `clawd.team.cards.${holeAktiveInstanz()}`; +} + +function loadExpandedCards() { + try { + const stored = localStorage.getItem(storageKey()); + if (stored) return new Set(JSON.parse(stored)); + } catch { + // Private window or blocked storage: every card starts compact. + } + return new Set(); +} + +function saveExpandedCards() { + try { + localStorage.setItem(storageKey(), JSON.stringify([...expandedCards])); + } catch { + // Only a convenience. + } +} + +function toggleCard(cardId) { + if (expandedCards.has(cardId)) expandedCards.delete(cardId); + else expandedCards.add(cardId); + saveExpandedCards(); + render().then(() => { if (selected) openPanel(selected); }); +} + +function agentCount(n) { + return n === 1 ? t("team.unitAgentsOne") : t("team.unitAgents", { n }); +} + +/** "12 agents", "⚠ 1", "▶ 2" — everything that is not idle, most urgent first. */ +function chips(card) { + const result = [erstelleElement("span", { klasse: "team-chip", text: agentCount(card.agents) })]; + for (const state of Object.keys(URGENCY).sort((a, b) => URGENCY[b] - URGENCY[a])) { + const n = card.states[state]; + if (!n || state === "Idle") continue; + result.push(erstelleElement("span", { + klasse: `team-chip ton-${STATES[state].tone}`, + text: `${STATES[state].symbol} ${n}`, + title: t(`team.state.${state}`) + })); + } + return result; } /** - * Lays the graph out in the shape of the area. rectpacking treats the aspect ratio as a - * hint and, with a few large containers on the top level, jumps between a handful of - * shapes — asked for 1.4 it may deliver 0.6 or 2.6. So a few hints are tried and the - * result closest to the area is kept; with the fit afterwards, that is the one that shows - * the boxes largest. + * The rows a card shows. A small unit shows everyone, the lead first. A large one shows + * whom the search found and who needs attention, most urgent first, and "+n more" — + * unless it was opened by hand. */ -async function runLayout() { - const area = cy.container(); - layoutWidth = area.clientWidth; - const target = area.clientWidth > 0 && area.clientHeight > 0 - ? Math.max(0.5, area.clientWidth / area.clientHeight) - : 2; - const generation = ++layoutGeneration; - const miss = (ratio) => Math.abs(Math.log(ratio / target)); +function visibleMembers(card) { + const all = [...card.members].sort((a, b) => (isLead(b) - isLead(a)) || byName(a, b)); + if (all.length <= COMPACT_OVER || expandedCards.has(card.id)) return { rows: all, hidden: 0 }; - let best = null; - for (const hint of [target, target * 1.2, target * 1.45, target * 0.8]) { - const ratio = await layoutOnce(hint); - if (!cy || generation !== layoutGeneration) return; - if (!best || miss(ratio) < best.miss) best = { hint, miss: miss(ratio), last: true }; - else best.last = false; - if (best.miss < 0.15) break; - } - // The best one may not be the last one run. - if (!best.last) await layoutOnce(best.hint); - if (cy && generation === layoutGeneration) cy.fit(undefined, 30); + const forced = (m) => m.agentId === revealAgent || Boolean(hits?.agents.has(m.agentId)); + const attention = all + .filter((m) => !forced(m) && URGENCY[m.state] > 0) + .sort((a, b) => (URGENCY[b.state] - URGENCY[a.state]) || byName(a, b)) + .slice(0, COMPACT_SHOWN); + const shown = new Set([...all.filter(forced), ...attention]); + const rows = all.filter((m) => shown.has(m)); + return { rows, hidden: all.length - rows.length }; } -function agentLabel(member) { +function buildCard(card) { + const worst = STATES[card.worst] ?? STATES.Idle; + const dimmed = hits && !hits.onPath.has(card.id); + + const element = erstelleElement("section", { + klasse: [ + "team-karte", + `ton-${worst.tone}`, + card.id === ROOT ? "wurzel" : "", + dimmed ? "gedimmt" : "", + hits?.cards.has(card.id) ? "treffer" : "", + selected?.card === card.id ? "ausgewaehlt" : "" + ].join(" "), + dataset: { card: card.id }, + stil: { width: `${CARD_WIDTH}px` } + }); + + element.append(erstelleElement("button", { + type: "button", + klasse: "team-karte-kopf", + title: t("team.subtreeHint"), + onclick: () => openPanel({ card: card.id }) + }, + erstelleElement("div", { klasse: "team-karte-titel" }, + erstelleElement("span", { klasse: "team-marker", text: worst.symbol }), + erstelleElement("span", { klasse: "team-karte-name", text: card.title })), + erstelleElement("div", { klasse: "team-karte-unter", text: card.subtitle }), + erstelleElement("div", { klasse: "team-chips" }, ...chips(card)))); + + const { rows, hidden } = visibleMembers(card); + if (rows.length || hidden) { + const list = erstelleElement("div", { klasse: "team-karte-liste" }); + for (const member of rows) list.append(buildRow(member)); + if (hidden) { + list.append(erstelleElement("button", { + type: "button", + klasse: "team-mehr", + text: t("team.moreMembers", { n: hidden }), + onclick: () => toggleCard(card.id) + })); + } else if (card.members.length > COMPACT_OVER) { + list.append(erstelleElement("button", { + type: "button", + klasse: "team-mehr", + text: t("team.showFewer"), + onclick: () => toggleCard(card.id) + })); + } + element.append(list); + } + return element; +} + +function buildRow(member) { const state = STATES[member.state] ?? STATES.Idle; const runs = member.runs.length > 1 ? ` ×${member.runs.length}` : ""; - const lead = member.isLead ? "★ " : ""; - return `${state.symbol} ${lead}${member.displayName || member.agentId}${runs}\n${t(`team.state.${member.state}`)}`; + return erstelleElement("button", { + type: "button", + klasse: [ + "team-zeile", + `ton-${state.tone}`, + hits?.agents.has(member.agentId) ? "treffer" : "", + hits && !hits.agents.has(member.agentId) ? "gedimmt" : "", + selected?.agent === member.agentId ? "ausgewaehlt" : "" + ].join(" "), + dataset: { agent: member.agentId }, + onclick: () => openPanel({ agent: member.agentId }) + }, + erstelleElement("span", { klasse: "team-marker", text: state.symbol }), + erstelleElement("span", { klasse: "team-zeile-name", text: `${isLead(member) ? "★ " : ""}${member.displayName || member.agentId}${runs}` }), + erstelleElement("span", { klasse: "team-zeile-zustand", text: t(`team.state.${member.state}`) })); } -/** "5 agents · ▶ 2 · ⚠ 1" — everything that is not idle, most urgent first. */ -function unitCounts(unit) { - const parts = [unit.agents === 1 ? t("team.unitAgentsOne") : t("team.unitAgents", { n: unit.agents })]; - for (const state of ["Stuck", "Problem", "WaitingForApproval", "BudgetExhausted", "Working"]) { - const n = unit.states?.[state]; - if (n) parts.push(`${STATES[state].symbol} ${n}`); - } - return parts.join(" · "); +function rowElement(agentId) { + const member = membersById.get(agentId); + if (!member) return null; + return cardElements.get(cardOf(member))?.querySelector(`[data-agent="${CSS.escape(agentId)}"]`) ?? null; } -function unitLabel(unit, open) { - return open - ? `▾ ${unit.name} · ${unitCounts(unit)}` - : `▸ ${unit.name}\n${unitCounts(unit)}`; -} +// ─── Layout and drawing ─── /** - * The nodes as they should be now, parents before children and in a stable order: agents - * without a unit, then the units by path, each with its lead first. + * Builds every card, measures it, and lets ELK place the tree. Cards are rebuilt on each + * refresh — their height depends on who needs attention — but ELK is deterministic, so a + * card only moves when a size or the structure changed. The view (pan and zoom) stays. */ -function desiredNodes() { - const nodes = []; - const byName = (a, b) => (a.displayName || a.agentId).localeCompare(b.displayName || b.agentId); - const colour = (state) => token((STATES[state] ?? STATES.Idle).colour); - - for (const member of snapshot.members.filter((m) => !m.unitId || !unitsById.has(m.unitId)).sort(byName)) { - nodes.push({ id: member.agentId, member, colour: colour(member.state) }); - } - - for (const unit of snapshot.units ?? []) { - if (!isVisible(unit)) continue; - const open = expanded.has(unit.id); - const parent = unit.parentId && unitsById.has(unit.parentId) ? UNIT_PREFIX + unit.parentId : undefined; - nodes.push({ id: UNIT_PREFIX + unit.id, parent, unit, open, colour: colour(unit.worst) }); - if (!open) continue; - - const members = snapshot.members - .filter((m) => m.unitId === unit.id) - .sort((a, b) => (b.isLead - a.isLead) || byName(a, b)); - for (const member of members) { - nodes.push({ id: member.agentId, parent: UNIT_PREFIX + unit.id, member, colour: colour(member.state) }); - } - } - return nodes; -} - -/** - * Brings the graph up to date. When only states changed, the nodes are updated in place and - * nothing moves. When the structure changed — a unit opened or closed, an agent moved — the - * nodes are rebuilt and laid out again: Cytoscape cannot turn a box into a container. - */ -function applySnapshot() { - if (!cy || !snapshot) return; - - const nodes = desiredNodes(); - const key = nodes.map((n) => `${n.id}<${n.parent ?? ""}${n.open ? "+" : ""}`).join("|"); - const data = (n) => ({ - id: n.id, - parent: n.parent, - colour: n.colour, - label: n.unit ? unitLabel(n.unit, n.open) : agentLabel(n.member) - }); - - if (key !== structureKey) { - structureKey = key; - cy.elements().remove(); - cy.add(nodes.map((n) => ({ group: "nodes", data: data(n) }))); - for (const n of nodes) decorate(n); - drawLinks(); - runLayout(); - } else { - for (const n of nodes) { - const { parent: _parent, ...rest } = data(n); - cy.getElementById(n.id).data(rest); - decorate(n); - } - } +async function render() { + if (!cardLayer || !snapshot) return; + const generation = ++layoutGeneration; + computeHits(); + renderTree(); renderSummary(); - if (selected) openPanel(selected); + + cardElements = new Map(); + const elements = []; + for (const card of cards.values()) { + const element = buildCard(card); + const known = positions.get(card.id); + if (known) element.style.transform = `translate(${known.x}px, ${known.y}px)`; + cardElements.set(card.id, element); + elements.push(element); + } + cardLayer.replaceChildren(...elements); + + const graph = { + id: "team", + layoutOptions: { + "elk.algorithm": "layered", + "elk.direction": "DOWN", + "elk.edgeRouting": "ORTHOGONAL", + "elk.spacing.nodeNode": "36", + "elk.layered.spacing.nodeNodeBetweenLayers": "64", + "elk.layered.spacing.edgeNodeBetweenLayers": "24", + "elk.layered.nodePlacement.strategy": "BRANDES_KOEPF", + // A parent centred over its children, as in an org chart. + "elk.layered.nodePlacement.bk.fixedAlignment": "BALANCED", + // Keep the order of the units as the instance sends it (by path), so siblings do + // not swap places between two refreshes. + "elk.layered.considerModelOrder.strategy": "NODES_AND_EDGES" + }, + children: [...cards.values()].map((card) => ({ + id: card.id, + width: CARD_WIDTH, + height: cardElements.get(card.id).offsetHeight + })), + edges: [...cards.values()] + .filter((card) => card.parent && cards.has(card.parent)) + .map((card) => ({ id: `e:${card.id}`, sources: [card.parent], targets: [card.id] })) + }; + + let result; + try { + result = await elk.layout(graph); + } catch (err) { + console.error("Team overview: layout failed", err); + return; + } + if (generation !== layoutGeneration || !cardLayer) return; + + positions = new Map(); + for (const node of result.children) { + positions.set(node.id, { x: node.x, y: node.y, w: node.width, h: node.height }); + cardElements.get(node.id).style.transform = `translate(${node.x}px, ${node.y}px)`; + } + layoutSize = { w: result.width, h: result.height }; + for (const layer of [edgeLayer, linkLayer]) { + layer.setAttribute("width", String(result.width)); + layer.setAttribute("height", String(result.height)); + } + + drawStructure(result.edges ?? []); + drawLinks(); + if (!fitted) fit(false); + else applyView(false); } -function decorate(n) { - const node = cy.getElementById(n.id); - node.toggleClass("einheit", Boolean(n.unit) && !n.open); - node.toggleClass("aktiv", Boolean(n.member?.runs.length) || Boolean(n.unit && !n.open && n.unit.states?.Working)); - node.toggleClass("leitung", Boolean(n.member?.isLead)); +/** + * The lines of the tree. A line takes the colour of the most urgent state in the card it + * leads to — that card's state already includes everything below it, so the red lines + * form a path from the top to the fault. + */ +function drawStructure(edges) { + const paths = []; + for (const edge of edges) { + const section = edge.sections?.[0]; + if (!section) continue; + const target = cards.get(edge.targets[0]); + const tone = (STATES[target?.worst] ?? STATES.Idle).tone; + const dimmed = hits && !hits.onPath.has(target?.id) ? " gedimmt" : ""; + const points = [section.startPoint, ...(section.bendPoints ?? []), section.endPoint]; + + const path = document.createElementNS(SVG, "path"); + path.setAttribute("d", points.map((p, i) => `${i ? "L" : "M"}${p.x},${p.y}`).join(" ")); + path.setAttribute("class", `team-kante ton-${tone}${dimmed}`); + + // Square ports where a line leaves and enters a card — the blueprint connectors. + const ports = [section.startPoint, section.endPoint].map((p) => { + const port = document.createElementNS(SVG, "rect"); + port.setAttribute("x", String(p.x - 3.5)); + port.setAttribute("y", String(p.y - 3.5)); + port.setAttribute("width", "7"); + port.setAttribute("height", "7"); + port.setAttribute("class", `team-port ton-${tone}${dimmed}`); + return port; + }); + paths.push({ urgent: tone === "gefahr" ? 2 : tone === "warnung" ? 1 : 0, nodes: [path, ...ports] }); + } + // The urgent lines last, so they are drawn on top where lines share a segment. + paths.sort((a, b) => a.urgent - b.urgent); + edgeLayer.replaceChildren(...paths.flatMap((p) => p.nodes)); } -// ─── Live ─── +// ─── Live links ─── function forActiveInstance(data) { // The manager merges the streams of all instances and stamps each event. @@ -522,7 +923,7 @@ function forActiveInstance(data) { } function onActivity(data) { - if (!cy || !forActiveInstance(data)) return; + if (!cardLayer || !forActiveInstance(data)) return; if (data.kind === "link" && data.link) { recordLink(data.link); @@ -535,11 +936,12 @@ function onActivity(data) { } async function refresh() { - if (!cy) return; + if (!cardLayer) return; try { snapshot = await api("/team"); indexSnapshot(); - applySnapshot(); + await render(); + if (selected) openPanel(selected); } catch { // The next event or tick tries again; a failed refresh keeps the last picture. } @@ -556,47 +958,100 @@ function recordLink(link) { } /** - * The edges between what is drawn: links of agents inside a collapsed unit start or end at - * that unit, and several such links become one edge with a counter. A link that stays - * inside one collapsed unit is not drawn — it is the unit talking to itself. + * Where a link starts or ends: at the agent's row if its card shows it, otherwise at the + * head of its card — a compact card collects the links of the agents it does not list. */ +function anchor(agentId) { + const member = membersById.get(agentId); + if (!member) return null; + const cardId = cardOf(member); + const pos = positions.get(cardId); + if (!pos) return null; + const row = rowElement(agentId); + const y = row ? pos.y + row.offsetTop + row.offsetHeight / 2 : pos.y + 24; + return { key: row ? `a:${agentId}` : `c:${cardId}`, cardId, left: pos.x, right: pos.x + pos.w, y }; +} + +function linkPath(a, b) { + // Within one card: a loop out of its right side and back in. + if (a.cardId === b.cardId) { + const x = a.right; + const bulge = 36 + Math.min(60, Math.abs(b.y - a.y) / 3); + return { + d: `M${x},${a.y} C${x + bulge},${a.y} ${x + bulge},${b.y} ${x + 6},${b.y}`, + mid: { x: x + bulge * 0.75, y: (a.y + b.y) / 2 } + }; + } + const aMid = (a.left + a.right) / 2; + const bMid = (b.left + b.right) / 2; + + // One above the other: out of the right side and back into the right side. + if (Math.abs(aMid - bMid) < CARD_WIDTH) { + const bend = 80; + return { + d: `M${a.right},${a.y} C${a.right + bend},${a.y} ${b.right + bend},${b.y} ${b.right},${b.y}`, + mid: { x: Math.max(a.right, b.right) + bend * 0.6, y: (a.y + b.y) / 2 } + }; + } + + // Side by side: leave on the side facing the other card, arrive on the side facing back. + const rightwards = bMid > aMid; + const start = rightwards ? a.right : a.left; + const end = rightwards ? b.left : b.right; + const bend = Math.max(40, Math.abs(end - start) / 2) * (rightwards ? 1 : -1); + return { + d: `M${start},${a.y} C${start + bend},${a.y} ${end - bend},${b.y} ${end},${b.y}`, + mid: { x: (start + end) / 2, y: (a.y + b.y) / 2 } + }; +} + +/** The live links, bundled per pair of anchors, fading out over LINK_VISIBLE_MS. */ function drawLinks() { - if (!cy) return; + if (!linkLayer) return; const now = Date.now(); const bundles = new Map(); for (const [key, link] of links) { - const age = now - link.seenAt; - if (age > LINK_VISIBLE_MS) { + if (now - link.seenAt > LINK_VISIBLE_MS) { links.delete(key); continue; } - const from = representative(link.from); - const to = representative(link.to); - if (!from || !to || from === to) continue; - if (cy.getElementById(from).empty() || cy.getElementById(to).empty()) continue; + if (!showLinks) continue; + const from = anchor(link.from); + const to = anchor(link.to); + if (!from || !to || from.key === to.key) continue; - const id = `link:${from}->${to}`; - const bundle = bundles.get(id) ?? { id, source: from, target: to, seenAt: 0, count: 0 }; + const id = `${from.key}->${to.key}`; + const bundle = bundles.get(id) ?? { from, to, seenAt: 0, count: 0 }; bundle.seenAt = Math.max(bundle.seenAt, link.seenAt); bundle.count += link.count; bundles.set(id, bundle); } - cy.edges().filter((edge) => !bundles.has(edge.id())).remove(); + const nodes = [linkLayer.firstChild]; for (const bundle of bundles.values()) { - const data = { - id: bundle.id, - source: bundle.source, - target: bundle.target, - opacity: Math.max(0.15, 1 - (now - bundle.seenAt) / LINK_VISIBLE_MS), - width: Math.min(8, 2 + bundle.count), - label: bundle.count > 1 ? `×${bundle.count}` : "" - }; - const edge = cy.getElementById(bundle.id); - if (edge.nonempty()) edge.data(data); - else cy.add({ group: "edges", data }); + const opacity = Math.max(0.2, 1 - (now - bundle.seenAt) / LINK_VISIBLE_MS); + const { d, mid } = linkPath(bundle.from, bundle.to); + const path = document.createElementNS(SVG, "path"); + path.setAttribute("d", d); + path.setAttribute("class", "team-link"); + path.setAttribute("marker-end", "url(#team-pfeil)"); + path.style.opacity = String(opacity); + nodes.push(path); + + if (bundle.count > 1) { + const label = document.createElementNS(SVG, "text"); + label.setAttribute("x", String(mid.x)); + label.setAttribute("y", String(mid.y)); + label.setAttribute("class", "team-link-zahl"); + label.setAttribute("text-anchor", "middle"); + label.setAttribute("dominant-baseline", "middle"); + label.style.opacity = String(opacity); + label.textContent = `×${bundle.count}`; + nodes.push(label); + } } + linkLayer.replaceChildren(...nodes); } // ─── Summary and legend ─── @@ -608,22 +1063,29 @@ function renderSummary() { const parts = Object.keys(STATES) .filter((state) => counts[state]) - .map((state) => erstellePlakette(`${STATES[state].symbol} ${counts[state]} ${t(`team.state.${state}`)}`, STATES[state].tone)); + .map((state) => erstellePlakette(`${STATES[state].symbol} ${counts[state]} ${t(`team.state.${state}`)}`, badgeTone(STATES[state].tone))); summary.replaceChildren( ...(parts.length ? parts : [erstelleElement("span", { klasse: "gedaempft", text: t("team.empty") })]) ); } +/** The card tones by the names the badges use. */ +function badgeTone(tone) { + return { aktiv: "erfolg" }[tone] ?? tone; +} + function buildLegend() { return erstelleElement( "div", { klasse: "team-legende gruppe-horizontal gedaempft text-klein" }, ...Object.entries(STATES).map(([state, s]) => - erstelleElement("span", { text: `${s.symbol} ${t(`team.state.${state}`)}` })), + erstelleElement("span", { klasse: `ton-${s.tone}` }, + erstelleElement("span", { klasse: "team-marker", text: s.symbol }), + ` ${t(`team.state.${state}`)}`)), erstelleElement("span", { text: `★ ${t("team.legendLead")}` }), - erstelleElement("span", { text: `▸ ${t("team.legendUnit")}` }), - erstelleElement("span", { text: `→ ${t("team.legendLink")}` }) + erstelleElement("span", { text: `┃ ${t("team.legendLine")}` }), + erstelleElement("span", { text: `⇢ ${t("team.legendLink")}` }) ); } @@ -631,12 +1093,14 @@ function buildLegend() { function openPanel(target) { if (!panel || !snapshot) return; - const rows = target.unit ? unitRows(target.unit) : agentRows(target.agent); + const rows = target.card ? cardRows(target.card) : agentRows(target.agent); if (!rows) return; selected = target; - cy?.elements().unselect(); - cy?.getElementById(target.unit ? UNIT_PREFIX + target.unit : target.agent).select(); + for (const element of cardLayer?.querySelectorAll(".ausgewaehlt") ?? []) element.classList.remove("ausgewaehlt"); + if (target.card) cardElements.get(target.card)?.classList.add("ausgewaehlt"); + else rowElement(target.agent)?.classList.add("ausgewaehlt"); + renderTree(); panel.replaceChildren(...rows); panel.hidden = false; @@ -649,6 +1113,7 @@ function panelHead(title) { klasse: "schaltflaeche flach klein", text: "×", title: t("common.close"), + "aria-label": t("common.close"), onclick: closePanel })); } @@ -658,17 +1123,17 @@ function agentRows(agentId) { if (!member) return null; const state = STATES[member.state] ?? STATES.Idle; - const unit = unitsById.get(member.unitId); + const card = cards.get(cardOf(member)); const rows = [ panelHead(member.displayName || member.agentId), erstelleElement("p", { klasse: "gedaempft text-klein", text: `${member.agentId} · ${member.model}` }), - erstellePlakette(`${state.symbol} ${t(`team.state.${member.state}`)}`, state.tone) + erstellePlakette(`${state.symbol} ${t(`team.state.${member.state}`)}`, badgeTone(state.tone)) ]; - if (unit) { + if (card?.unit) { rows.push(erstelleElement("p", { klasse: "text-klein" }, - `${member.isLead ? `★ ${t("team.leads")} ` : `${t("team.memberOf")} `}`, - unitButton(unit))); + `${isLead(member) ? `★ ${t("team.leads")} ` : `${t("team.memberOf")} `}`, + cardButton(card))); } // Top layer: what is happening now. @@ -722,73 +1187,69 @@ function agentRows(agentId) { return rows; } -function unitRows(unitId) { - const unit = unitsById.get(unitId); - if (!unit) return null; +function cardRows(cardId) { + const card = cards.get(cardId); + if (!card) return null; - const worst = STATES[unit.worst] ?? STATES.Idle; const rows = [ - panelHead(unit.name), - erstelleElement("p", { klasse: "gedaempft text-klein", text: unit.path }), - erstellePlakette(`${worst.symbol} ${unitCounts(unit)}`, worst.tone) + panelHead(card.title), + erstelleElement("p", { klasse: "gedaempft text-klein", text: card.unit?.path ?? card.subtitle }), + erstelleElement("div", { klasse: "team-chips" }, ...chips(card)), + erstelleElement("p", { klasse: "gedaempft text-klein", text: t("team.subtreeHint") }) ]; - if (unit.goal) rows.push(erstelleElement("p", { klasse: "text-klein", text: unit.goal })); + if (card.unit?.goal) rows.push(erstelleElement("p", { klasse: "text-klein", text: card.unit.goal })); - if (unit.pendingApprovals > 0) { - rows.push(erstelleElement("p", { klasse: "text-klein", text: `✋ ${t("team.approvals", { n: unit.pendingApprovals })}` })); + if (card.pendingApprovals > 0) { + rows.push(erstelleElement("p", { klasse: "text-klein", text: `✋ ${t("team.approvals", { n: card.pendingApprovals })}` })); } // Direct members, the lead first; what is further down is one click on a sub-unit away. rows.push(erstelleElement("h3", { text: t("team.members") })); - const members = snapshot.members - .filter((m) => m.unitId === unit.id) - .sort((a, b) => (b.isLead - a.isLead) || (a.displayName || a.agentId).localeCompare(b.displayName || b.agentId)); + const members = [...card.members].sort((a, b) => (isLead(b) - isLead(a)) || byName(a, b)); if (!members.length) rows.push(erstelleElement("p", { klasse: "gedaempft text-klein", text: "—" })); for (const member of members) { const state = STATES[member.state] ?? STATES.Idle; rows.push(erstelleElement("button", { type: "button", - klasse: "flach klein team-eintrag", - text: `${state.symbol} ${member.isLead ? "★ " : ""}${member.displayName || member.agentId} — ${t(`team.state.${member.state}`)}`, - onclick: () => openPanel({ agent: member.agentId }) - })); + klasse: `team-zeile ton-${state.tone}`, + onclick: () => showAgent(member.agentId) + }, + erstelleElement("span", { klasse: "team-marker", text: state.symbol }), + erstelleElement("span", { klasse: "team-zeile-name", text: `${isLead(member) ? "★ " : ""}${member.displayName || member.agentId}` }), + erstelleElement("span", { klasse: "team-zeile-zustand", text: t(`team.state.${member.state}`) }))); } - const children = (snapshot.units ?? []).filter((u) => u.parentId === unit.id); + const children = [...cards.values()].filter((c) => c.parent === card.id); if (children.length) { rows.push(erstelleElement("h3", { text: t("team.subUnits") })); - for (const child of children) rows.push(erstelleElement("div", {}, unitButton(child))); + for (const child of children) rows.push(erstelleElement("div", {}, cardButton(child))); } const actions = erstelleElement("div", { klasse: "gruppe-vertikal team-aktionen" }); - const open = expanded.has(unit.id); - actions.append( - erstelleElement("button", { + if (card.members.length > COMPACT_OVER) { + actions.append(erstelleElement("button", { type: "button", klasse: "primaer klein", - text: open ? t("team.collapse") : t("team.expand"), - onclick: () => toggleUnit(unit.id, !open) - }), - link("#/organisation", t("team.openOrganisation")) - ); - rows.push(actions); + text: expandedCards.has(card.id) ? t("team.showFewer") : t("team.showAllMembers"), + onclick: () => toggleCard(card.id) + })); + } + if (card.unit) actions.append(link("#/organisation", t("team.openOrganisation"))); + if (actions.children.length) rows.push(actions); return rows; } -/** A unit as a link in the panel, with its most urgent state. */ -function unitButton(unit) { - const worst = STATES[unit.worst] ?? STATES.Idle; +/** A card as a link in the panel, with its most urgent state. */ +function cardButton(card) { + const worst = STATES[card.worst] ?? STATES.Idle; return erstelleElement("button", { type: "button", - klasse: "flach klein team-eintrag", - text: `${worst.symbol} ${unit.name} · ${unitCounts(unit)}`, + klasse: `flach klein team-eintrag ton-${worst.tone}`, + text: `${worst.symbol} ${card.title} · ${agentCount(card.agents)}`, onclick: () => { - // Show it in the graph too: open everything above it. - for (const above of chain(unit.parentId)) expanded.add(above.id); - saveExpanded(); - applySnapshot(); - openPanel({ unit: unit.id }); + openPanel({ card: card.id }); + focusCard(card.id); } }); } @@ -804,6 +1265,8 @@ function link(href, text, style = "flach") { function closePanel() { selected = null; - cy?.elements().unselect(); + revealAgent = null; + for (const element of cardLayer?.querySelectorAll(".ausgewaehlt") ?? []) element.classList.remove("ausgewaehlt"); + renderTree(); if (panel) panel.hidden = true; }