diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md
index 72a8feefa..b693e8e9a 100644
--- a/.claude/CLAUDE.md
+++ b/.claude/CLAUDE.md
@@ -5,12 +5,21 @@ Rust library for NP-hard problem reductions. Implements computational problems w
 
 ## Commands
 ```bash
-make test          # Run all tests
-make clippy        # Lint
-make export-graph  # Regenerate reduction graph
-make paper         # Build Typst paper
-make coverage      # Generate coverage report (>95% required)
-make qubo-testdata # Regenerate QUBO ground truth JSON
+make help           # Show all available targets
+make build          # Build the project
+make test           # Run all tests
+make fmt            # Format code with rustfmt
+make fmt-check      # Check code formatting
+make clippy         # Run clippy lints
+make doc            # Build mdBook documentation (includes reduction graph export)
+make mdbook         # Build and serve mdBook with live reload
+make paper          # Build Typst paper (runs examples + exports first)
+make coverage       # Generate coverage report (>95% required)
+make check          # Quick pre-commit check (fmt + clippy + test)
+make export-graph   # Regenerate reduction graph JSON
+make export-schemas # Regenerate problem schemas JSON
+make qubo-testdata  # Regenerate QUBO ground truth JSON
+make clean          # Clean build artifacts
 ```
 
 ## Verify Changes
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 7e7be0820..b87ca37a4 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -33,14 +33,20 @@ jobs:
           curl -sSL https://github.com/typst/typst/releases/download/v0.14.0/typst-x86_64-unknown-linux-musl.tar.xz | tar -xJ
           mv typst-x86_64-unknown-linux-musl/typst "$HOME/bin/"
 
+      - name: Generate data
+        run: |
+          cargo run --example export_graph
+          cargo run --example export_schemas
+          cp docs/paper/reduction_graph.json docs/src/reductions/
+
       - name: Build mdBook
         run: mdbook build
 
-      - name: Build PDF
-        run: typst compile docs/paper/reductions.typ book/reductions.pdf
+      - name: Build examples and PDF
+        run: make examples && typst compile docs/paper/reductions.typ book/reductions.pdf
 
       - name: Build rustdoc
-        run: cargo doc --no-deps
+        run: cargo doc --all-features --no-deps
 
       - name: Combine documentation
         run: |
diff --git a/Makefile b/Makefile
index d92960900..6e364f55e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Makefile for problemreductions
 
-.PHONY: help build test fmt clippy doc mdbook paper examples clean coverage rust-export compare qubo-testdata
+.PHONY: help build test fmt clippy doc mdbook paper examples clean coverage rust-export compare qubo-testdata export-schemas
 
 # Default target
 help:
@@ -19,6 +19,7 @@ help:
 	@echo "  rust-export  - Generate Rust mapping JSON exports"
 	@echo "  compare      - Generate and compare Rust mapping exports"
 	@echo "  examples     - Generate example JSON for paper"
+	@echo "  export-schemas - Export problem schemas to JSON"
 	@echo "  qubo-testdata - Regenerate QUBO test data (requires uv)"
 
 # Build the project
@@ -43,10 +44,20 @@ clippy:
 
 # Build mdBook documentation
 doc:
+	cargo run --example export_graph
+	cp docs/paper/reduction_graph.json docs/src/reductions/
 	mdbook build docs
+	cargo doc --all-features --no-deps
+	rm -rf docs/book/api
+	cp -r target/doc docs/book/api
 
 # Build and serve mdBook with live reload
 mdbook:
+	cargo run --example export_graph
+	cp docs/paper/reduction_graph.json docs/src/reductions/
+	cargo doc --all-features --no-deps
+	rm -rf docs/book/api
+	cp -r target/doc docs/book/api
 	mdbook serve docs --open
 
 # Generate all example JSON files for the paper
@@ -59,9 +70,14 @@ examples:
 	done
 	cargo run --all-features --example export_petersen_mapping
 
+# Export problem schemas to JSON
+export-schemas:
+	cargo run --example export_schemas
+
 # Build Typst paper (generates examples first)
 paper: examples
 	cargo run --example export_graph
+	cargo run --example export_schemas
 	cd docs/paper && typst compile reductions.typ reductions.pdf
 
 # Generate coverage report (requires: cargo install cargo-llvm-cov)
diff --git a/README.md b/README.md
index bc285e68a..faf10718e 100644
--- a/README.md
+++ b/README.md
@@ -56,21 +56,9 @@ assert_eq!(solution.iter().sum::<usize>(), 2); // Max IS size is 2
         Afterwards, the skill creates a PR starting with `[action]`, which automatically triggers Claude CI to implement the plan.
     - Otherwise, you can write a detailed plan manually ([sample](docs/plans/2026-01-31-factoring-ilp-design.md)). Then create a PR manually. You can start implementing this plan on the CI machine by adding `[action]` at the start of the PR description or comments.
 
-### Using Make
-
-```bash
-make help      # Show all available targets
-make build     # Build the project
-make test      # Run all tests
-make fmt       # Format code with rustfmt
-make fmt-check # Check code formatting
-make clippy    # Run clippy lints
-make doc       # Build and open documentation
-make coverage  # Generate coverage report (requires cargo-llvm-cov)
-make clean     # Clean build artifacts
-make check     # Quick check before commit (fmt + clippy + test)
-```
+### Developer Commands
 
+Run `make help` to see all available targets. See [CLAUDE.md](https://codingthrust.github.io/problem-reductions/claude.html) for the full command list and architecture details.
 
 ## Acknowledgments
 
diff --git a/docs/paper/problem_schemas.json b/docs/paper/problem_schemas.json
new file mode 100644
index 000000000..065c8bfa3
--- /dev/null
+++ b/docs/paper/problem_schemas.json
@@ -0,0 +1,412 @@
+[
+  {
+    "name": "BMF",
+    "category": "specialized",
+    "description": "Boolean matrix factorization",
+    "fields": [
+      {
+        "name": "matrix",
+        "type_name": "Vec<Vec<bool>>",
+        "description": "Target boolean matrix A"
+      },
+      {
+        "name": "m",
+        "type_name": "usize",
+        "description": "Number of rows"
+      },
+      {
+        "name": "n",
+        "type_name": "usize",
+        "description": "Number of columns"
+      },
+      {
+        "name": "k",
+        "type_name": "usize",
+        "description": "Factorization rank"
+      }
+    ]
+  },
+  {
+    "name": "BicliqueCover",
+    "category": "specialized",
+    "description": "Cover bipartite edges with k bicliques",
+    "fields": [
+      {
+        "name": "left_size",
+        "type_name": "usize",
+        "description": "Vertices in left partition"
+      },
+      {
+        "name": "right_size",
+        "type_name": "usize",
+        "description": "Vertices in right partition"
+      },
+      {
+        "name": "edges",
+        "type_name": "Vec<(usize, usize)>",
+        "description": "Bipartite edges"
+      },
+      {
+        "name": "k",
+        "type_name": "usize",
+        "description": "Number of bicliques"
+      }
+    ]
+  },
+  {
+    "name": "CircuitSAT",
+    "category": "satisfiability",
+    "description": "Find satisfying input to a boolean circuit",
+    "fields": [
+      {
+        "name": "circuit",
+        "type_name": "Circuit",
+        "description": "The boolean circuit"
+      },
+      {
+        "name": "variables",
+        "type_name": "Vec<String>",
+        "description": "Circuit variable names"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Assignment weights"
+      }
+    ]
+  },
+  {
+    "name": "Clique",
+    "category": "graph",
+    "description": "Find maximum weight clique in a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The underlying graph G=(V,E)"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Vertex weights w: V -> R"
+      }
+    ]
+  },
+  {
+    "name": "DominatingSet",
+    "category": "graph",
+    "description": "Find minimum weight dominating set in a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The underlying graph G=(V,E)"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Vertex weights w: V -> R"
+      }
+    ]
+  },
+  {
+    "name": "Factoring",
+    "category": "specialized",
+    "description": "Factor a composite integer into two factors",
+    "fields": [
+      {
+        "name": "m",
+        "type_name": "usize",
+        "description": "Bits for first factor"
+      },
+      {
+        "name": "n",
+        "type_name": "usize",
+        "description": "Bits for second factor"
+      },
+      {
+        "name": "target",
+        "type_name": "u64",
+        "description": "Number to factor"
+      }
+    ]
+  },
+  {
+    "name": "ILP",
+    "category": "optimization",
+    "description": "Optimize linear objective subject to linear constraints",
+    "fields": [
+      {
+        "name": "num_vars",
+        "type_name": "usize",
+        "description": "Number of integer variables"
+      },
+      {
+        "name": "bounds",
+        "type_name": "Vec<VarBounds>",
+        "description": "Variable bounds"
+      },
+      {
+        "name": "constraints",
+        "type_name": "Vec<LinearConstraint>",
+        "description": "Linear constraints"
+      },
+      {
+        "name": "objective",
+        "type_name": "Vec<(usize, f64)>",
+        "description": "Sparse objective coefficients"
+      },
+      {
+        "name": "sense",
+        "type_name": "ObjectiveSense",
+        "description": "Optimization direction"
+      }
+    ]
+  },
+  {
+    "name": "IndependentSet",
+    "category": "graph",
+    "description": "Find maximum weight independent set in a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The underlying graph G=(V,E)"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Vertex weights w: V -> R"
+      }
+    ]
+  },
+  {
+    "name": "KColoring",
+    "category": "graph",
+    "description": "Find valid k-coloring of a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The underlying graph G=(V,E)"
+      }
+    ]
+  },
+  {
+    "name": "KSatisfiability",
+    "category": "satisfiability",
+    "description": "SAT with exactly k literals per clause",
+    "fields": [
+      {
+        "name": "num_vars",
+        "type_name": "usize",
+        "description": "Number of Boolean variables"
+      },
+      {
+        "name": "clauses",
+        "type_name": "Vec<CNFClause>",
+        "description": "Clauses each with exactly K literals"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Clause weights for MAX-K-SAT"
+      }
+    ]
+  },
+  {
+    "name": "Matching",
+    "category": "graph",
+    "description": "Find maximum weight matching in a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The underlying graph G=(V,E)"
+      },
+      {
+        "name": "edge_weights",
+        "type_name": "Vec<W>",
+        "description": "Edge weights w: E -> R"
+      }
+    ]
+  },
+  {
+    "name": "MaxCut",
+    "category": "graph",
+    "description": "Find maximum weight cut in a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The graph with edge weights"
+      },
+      {
+        "name": "edge_weights",
+        "type_name": "Vec<W>",
+        "description": "Edge weights w: E -> R"
+      }
+    ]
+  },
+  {
+    "name": "MaximalIS",
+    "category": "graph",
+    "description": "Find maximum weight maximal independent set",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The underlying graph G=(V,E)"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Vertex weights w: V -> R"
+      }
+    ]
+  },
+  {
+    "name": "PaintShop",
+    "category": "specialized",
+    "description": "Minimize color changes in paint shop sequence",
+    "fields": [
+      {
+        "name": "sequence_indices",
+        "type_name": "Vec<usize>",
+        "description": "Car sequence as indices"
+      },
+      {
+        "name": "car_labels",
+        "type_name": "Vec<String>",
+        "description": "Unique car labels"
+      },
+      {
+        "name": "is_first",
+        "type_name": "Vec<bool>",
+        "description": "First occurrence flags"
+      },
+      {
+        "name": "num_cars",
+        "type_name": "usize",
+        "description": "Number of unique cars"
+      }
+    ]
+  },
+  {
+    "name": "QUBO",
+    "category": "optimization",
+    "description": "Minimize quadratic unconstrained binary objective",
+    "fields": [
+      {
+        "name": "num_vars",
+        "type_name": "usize",
+        "description": "Number of binary variables"
+      },
+      {
+        "name": "matrix",
+        "type_name": "Vec<Vec<W>>",
+        "description": "Upper-triangular Q matrix"
+      }
+    ]
+  },
+  {
+    "name": "Satisfiability",
+    "category": "satisfiability",
+    "description": "Find satisfying assignment for CNF formula",
+    "fields": [
+      {
+        "name": "num_vars",
+        "type_name": "usize",
+        "description": "Number of Boolean variables"
+      },
+      {
+        "name": "clauses",
+        "type_name": "Vec<CNFClause>",
+        "description": "Clauses in conjunctive normal form"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Clause weights for MAX-SAT"
+      }
+    ]
+  },
+  {
+    "name": "SetCovering",
+    "category": "set",
+    "description": "Find minimum weight collection covering the universe",
+    "fields": [
+      {
+        "name": "universe_size",
+        "type_name": "usize",
+        "description": "Size of the universe U"
+      },
+      {
+        "name": "sets",
+        "type_name": "Vec<Vec<usize>>",
+        "description": "Collection of subsets of U"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Weight for each set"
+      }
+    ]
+  },
+  {
+    "name": "SetPacking",
+    "category": "set",
+    "description": "Find maximum weight collection of disjoint sets",
+    "fields": [
+      {
+        "name": "sets",
+        "type_name": "Vec<Vec<usize>>",
+        "description": "Collection of sets over a universe"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Weight for each set"
+      }
+    ]
+  },
+  {
+    "name": "SpinGlass",
+    "category": "optimization",
+    "description": "Minimize Ising Hamiltonian on a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The interaction graph"
+      },
+      {
+        "name": "couplings",
+        "type_name": "Vec<W>",
+        "description": "Pairwise couplings J_ij"
+      },
+      {
+        "name": "fields",
+        "type_name": "Vec<W>",
+        "description": "On-site fields h_i"
+      }
+    ]
+  },
+  {
+    "name": "VertexCovering",
+    "category": "graph",
+    "description": "Find minimum weight vertex cover in a graph",
+    "fields": [
+      {
+        "name": "graph",
+        "type_name": "G",
+        "description": "The underlying graph G=(V,E)"
+      },
+      {
+        "name": "weights",
+        "type_name": "Vec<W>",
+        "description": "Vertex weights w: V -> R"
+      }
+    ]
+  }
+]
\ No newline at end of file
diff --git a/docs/paper/reduction-diagram.typ b/docs/paper/reduction-diagram.typ
deleted file mode 100644
index e4554f6e8..000000000
--- a/docs/paper/reduction-diagram.typ
+++ /dev/null
@@ -1,157 +0,0 @@
-#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
-#import "@preview/cetz:0.4.2": canvas, draw
-
-#let graph-data = json("reduction_graph.json")
-
-#let category-colors = (
-  "graph": rgb("#e0ffe0"),
-  "set": rgb("#ffe0e0"),
-  "optimization": rgb("#ffffd0"),
-  "satisfiability": rgb("#e0e0ff"),
-  "specialized": rgb("#ffe0f0"),
-  "other": rgb("#f0f0f0"),
-)
-
-#let get-color(category) = {
-  category-colors.at(category, default: rgb("#f0f0f0"))
-}
-
-// Build node ID from name + variant (new JSON format)
-// Format: "Name" for base, "Name/graph/weight" for variants
-#let build-node-id(n) = {
-  if n.variant == (:) or n.variant.keys().len() == 0 {
-    n.name
-  } else {
-    let parts = (n.name,)
-    if "graph" in n.variant and n.variant.graph != "" and n.variant.graph != "SimpleGraph" {
-      parts.push(n.variant.graph)
-    }
-    if "weight" in n.variant and n.variant.weight != "" and n.variant.weight != "Unweighted" {
-      parts.push(n.variant.weight)
-    }
-    parts.join("/")
-  }
-}
-
-// Build display label from name + variant
-#let build-node-label(n) = {
-  if n.variant == (:) or n.variant.keys().len() == 0 {
-    n.name
-  } else {
-    // For variants, show abbreviated form
-    let suffix = ()
-    if "graph" in n.variant and n.variant.graph != "" and n.variant.graph != "SimpleGraph" {
-      suffix.push(n.variant.graph)
-    }
-    // Filter out Unweighted and single-letter generic type params (W, K, T, etc.)
-    if "weight" in n.variant and n.variant.weight != "" and n.variant.weight != "Unweighted" and n.variant.weight.len() != 1 {
-      suffix.push(n.variant.weight)
-    }
-    if suffix.len() > 0 {
-      n.name + "/" + suffix.join("/")
-    } else {
-      n.name
-    }
-  }
-}
-
-// Check if node is a base problem (empty variant)
-#let is-base-problem(n) = {
-  n.variant == (:) or n.variant.keys().len() == 0
-}
-
-// Base problem positions
-#let base-positions = (
-  // Row 0: Root nodes
-  "Satisfiability": (-1.5, 0),
-  "Factoring": (2.5, 0),
-  // Row 1: Direct children of roots
-  "KSatisfiability": (-2.5, 1),
-  "IndependentSet": (-0.5, 1),
-  "Coloring": (0.5, 1),
-  "DominatingSet": (-1.5, 1),
-  "CircuitSAT": (2.5, 1),
-  // Row 2: Next level
-  "VertexCovering": (-0.5, 2),
-  "Matching": (-2, 2),
-  "SpinGlass": (2.5, 2),
-  "ILP": (3.5, 1),
-  // Row 3: Leaf nodes
-  "SetPacking": (-1.5, 3),
-  "SetCovering": (0.5, 3),
-  "MaxCut": (1.5, 3),
-  "QUBO": (3.5, 3),
-  "GridGraph": (0.5, 2),
-)
-
-// Get position for a node
-#let get-node-position(n) = {
-  if is-base-problem(n) {
-    // Base problem - use manual position
-    base-positions.at(n.name, default: (0, 0))
-  } else {
-    // Variant - position below parent with horizontal offset
-    let parent-pos = base-positions.at(n.name, default: (0, 0))
-    // Find variant index among siblings with same base name
-    let siblings = graph-data.nodes.filter(x => x.name == n.name and not is-base-problem(x))
-    let idx = siblings.position(x => build-node-id(x) == build-node-id(n))
-    let offset = if idx == none { 0 } else { idx * 0.4 }
-    (parent-pos.at(0) + offset, parent-pos.at(1) + 0.5)
-  }
-}
-
-// Filter to show only base problems in the main diagram
-#let base-nodes = graph-data.nodes.filter(n => is-base-problem(n))
-
-// Collect unique base problem names
-#let base-names = base-nodes.map(n => n.name)
-
-// Filter edges to only those between base problem names (ignoring variants)
-// This allows us to show the high-level structure even though edges connect variant nodes
-#let base-edges = graph-data.edges.filter(e => {
-  base-names.contains(e.source.name) and base-names.contains(e.target.name)
-})
-
-// Deduplicate edges by (source-name, target-name) pair, keeping bidirectionality
-#let edge-key(e) = if e.source.name < e.target.name {
-  (e.source.name, e.target.name)
-} else {
-  (e.target.name, e.source.name)
-}
-
-// Group edges by their base names and merge bidirectionality
-#let edge-map = (:)
-#for e in base-edges {
-  let key = e.source.name + "->" + e.target.name
-  let rev-key = e.target.name + "->" + e.source.name
-  if rev-key in edge-map {
-    // Reverse edge exists, mark as bidirectional
-    edge-map.at(rev-key).bidirectional = true
-  } else if key not in edge-map {
-    edge-map.insert(key, (source: e.source.name, target: e.target.name, bidirectional: e.bidirectional))
-  }
-}
-
-#let deduped-edges = edge-map.values()
-
-#let reduction-graph(width: 18mm, height: 14mm) = diagram(
-  spacing: (width, height),
-  node-stroke: 0.6pt,
-  edge-stroke: 0.6pt,
-  node-corner-radius: 2pt,
-  node-inset: 3pt,
-  ..base-nodes.map(n => {
-    let color = get-color(n.category)
-    let pos = get-node-position(n)
-    let node-label = build-node-label(n)
-    let node-id = build-node-id(n)
-    node(pos, text(size: 7pt)[#node-label], fill: color, name: label(node-id))
-  }),
-  ..deduped-edges.map(e => {
-    let arrow = if e.bidirectional { "<|-|>" } else { "-|>" }
-    // Use simple name as node ID since we're showing base problems
-    edge(label(e.source), label(e.target), arrow)
-  }),
-)
-
-#reduction-graph()
\ No newline at end of file
diff --git a/docs/paper/reduction_graph.json b/docs/paper/reduction_graph.json
index 3a1cebabb..1e7fd7f1d 100644
--- a/docs/paper/reduction_graph.json
+++ b/docs/paper/reduction_graph.json
@@ -3,7 +3,8 @@
     {
       "name": "CircuitSAT",
       "variant": {},
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/specialized/struct.CircuitSAT.html"
     },
     {
       "name": "CircuitSAT",
@@ -11,7 +12,8 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/specialized/struct.CircuitSAT.html"
     },
     {
       "name": "CircuitSAT",
@@ -19,12 +21,14 @@
         "graph": "SimpleGraph",
         "weight": "i32"
       },
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/specialized/struct.CircuitSAT.html"
     },
     {
       "name": "DominatingSet",
       "variant": {},
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.DominatingSet.html"
     },
     {
       "name": "DominatingSet",
@@ -32,12 +36,14 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.DominatingSet.html"
     },
     {
       "name": "Factoring",
       "variant": {},
-      "category": "specialized"
+      "category": "specialized",
+      "doc_path": "models/specialized/struct.Factoring.html"
     },
     {
       "name": "Factoring",
@@ -45,12 +51,14 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "specialized"
+      "category": "specialized",
+      "doc_path": "models/specialized/struct.Factoring.html"
     },
     {
       "name": "ILP",
       "variant": {},
-      "category": "optimization"
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.ILP.html"
     },
     {
       "name": "ILP",
@@ -58,12 +66,14 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "optimization"
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.ILP.html"
     },
     {
       "name": "IndependentSet",
       "variant": {},
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.IndependentSet.html"
     },
     {
       "name": "IndependentSet",
@@ -71,7 +81,8 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.IndependentSet.html"
     },
     {
       "name": "IndependentSet",
@@ -79,12 +90,14 @@
         "graph": "SimpleGraph",
         "weight": "i32"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.IndependentSet.html"
     },
     {
       "name": "KColoring",
       "variant": {},
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
     },
     {
       "name": "KColoring",
@@ -93,7 +106,8 @@
         "k": "N",
         "weight": "i32"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
     },
     {
       "name": "KColoring",
@@ -101,7 +115,8 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
     },
     {
       "name": "KColoring",
@@ -109,12 +124,14 @@
         "graph": "SimpleGraph",
         "weight": "i32"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
     },
     {
       "name": "KSatisfiability",
       "variant": {},
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.KSatisfiability.html"
     },
     {
       "name": "KSatisfiability",
@@ -122,7 +139,8 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.KSatisfiability.html"
     },
     {
       "name": "KSatisfiability",
@@ -130,12 +148,14 @@
         "graph": "SimpleGraph",
         "weight": "i32"
       },
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.KSatisfiability.html"
     },
     {
       "name": "Matching",
       "variant": {},
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.Matching.html"
     },
     {
       "name": "Matching",
@@ -143,12 +163,14 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.Matching.html"
     },
     {
       "name": "MaxCut",
       "variant": {},
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.MaxCut.html"
     },
     {
       "name": "MaxCut",
@@ -156,12 +178,14 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.MaxCut.html"
     },
     {
       "name": "QUBO",
       "variant": {},
-      "category": "optimization"
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.QUBO.html"
     },
     {
       "name": "QUBO",
@@ -169,12 +193,14 @@
         "graph": "SimpleGraph",
         "weight": "f64"
       },
-      "category": "optimization"
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.QUBO.html"
     },
     {
       "name": "Satisfiability",
       "variant": {},
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.Satisfiability.html"
     },
     {
       "name": "Satisfiability",
@@ -182,12 +208,14 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "satisfiability"
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.Satisfiability.html"
     },
     {
       "name": "SetCovering",
       "variant": {},
-      "category": "set"
+      "category": "set",
+      "doc_path": "models/set/struct.SetCovering.html"
     },
     {
       "name": "SetCovering",
@@ -195,12 +223,14 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "set"
+      "category": "set",
+      "doc_path": "models/set/struct.SetCovering.html"
     },
     {
       "name": "SetPacking",
       "variant": {},
-      "category": "set"
+      "category": "set",
+      "doc_path": "models/set/struct.SetPacking.html"
     },
     {
       "name": "SetPacking",
@@ -208,7 +238,8 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "set"
+      "category": "set",
+      "doc_path": "models/set/struct.SetPacking.html"
     },
     {
       "name": "SetPacking",
@@ -216,12 +247,14 @@
         "graph": "SimpleGraph",
         "weight": "i32"
       },
-      "category": "set"
+      "category": "set",
+      "doc_path": "models/set/struct.SetPacking.html"
     },
     {
       "name": "SpinGlass",
       "variant": {},
-      "category": "optimization"
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.SpinGlass.html"
     },
     {
       "name": "SpinGlass",
@@ -229,7 +262,8 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "optimization"
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.SpinGlass.html"
     },
     {
       "name": "SpinGlass",
@@ -237,12 +271,14 @@
         "graph": "SimpleGraph",
         "weight": "f64"
       },
-      "category": "optimization"
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.SpinGlass.html"
     },
     {
       "name": "VertexCovering",
       "variant": {},
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.VertexCovering.html"
     },
     {
       "name": "VertexCovering",
@@ -250,7 +286,8 @@
         "graph": "SimpleGraph",
         "weight": "Unweighted"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.VertexCovering.html"
     },
     {
       "name": "VertexCovering",
@@ -258,7 +295,8 @@
         "graph": "SimpleGraph",
         "weight": "i32"
       },
-      "category": "graph"
+      "category": "graph",
+      "doc_path": "models/graph/struct.VertexCovering.html"
     }
   ],
   "edges": [
@@ -418,37 +456,37 @@
     },
     {
       "source": {
-        "name": "MaxCut",
+        "name": "Satisfiability",
         "variant": {
           "graph": "SimpleGraph",
           "weight": "Unweighted"
         }
       },
       "target": {
-        "name": "SpinGlass",
+        "name": "DominatingSet",
         "variant": {
           "graph": "SimpleGraph",
           "weight": "Unweighted"
         }
       },
-      "bidirectional": true
+      "bidirectional": false
     },
     {
       "source": {
-        "name": "QUBO",
+        "name": "Satisfiability",
         "variant": {
           "graph": "SimpleGraph",
-          "weight": "f64"
+          "weight": "Unweighted"
         }
       },
       "target": {
-        "name": "SpinGlass",
+        "name": "IndependentSet",
         "variant": {
           "graph": "SimpleGraph",
-          "weight": "f64"
+          "weight": "Unweighted"
         }
       },
-      "bidirectional": true
+      "bidirectional": false
     },
     {
       "source": {
@@ -459,10 +497,10 @@
         }
       },
       "target": {
-        "name": "DominatingSet",
+        "name": "KColoring",
         "variant": {
           "graph": "SimpleGraph",
-          "weight": "Unweighted"
+          "weight": "i32"
         }
       },
       "bidirectional": false
@@ -476,58 +514,58 @@
         }
       },
       "target": {
-        "name": "IndependentSet",
+        "name": "KSatisfiability",
         "variant": {
           "graph": "SimpleGraph",
           "weight": "Unweighted"
         }
       },
-      "bidirectional": false
+      "bidirectional": true
     },
     {
       "source": {
-        "name": "Satisfiability",
+        "name": "SetPacking",
         "variant": {
           "graph": "SimpleGraph",
           "weight": "Unweighted"
         }
       },
       "target": {
-        "name": "KColoring",
+        "name": "IndependentSet",
         "variant": {
           "graph": "SimpleGraph",
-          "weight": "i32"
+          "weight": "Unweighted"
         }
       },
-      "bidirectional": false
+      "bidirectional": true
     },
     {
       "source": {
-        "name": "Satisfiability",
+        "name": "SetPacking",
         "variant": {
           "graph": "SimpleGraph",
-          "weight": "Unweighted"
+          "weight": "i32"
         }
       },
       "target": {
-        "name": "KSatisfiability",
+        "name": "QUBO",
         "variant": {
           "graph": "SimpleGraph",
-          "weight": "Unweighted"
+          "weight": "f64"
         }
       },
-      "bidirectional": true
+      "bidirectional": false
     },
     {
       "source": {
-        "name": "SetPacking",
+        "name": "SpinGlass",
         "variant": {
           "graph": "SimpleGraph",
           "weight": "Unweighted"
         }
       },
       "target": {
-        "name": "IndependentSet",
+        "name": "MaxCut",
         "variant": {
           "graph": "SimpleGraph",
           "weight": "Unweighted"
@@ -537,10 +575,10 @@
     },
     {
       "source": {
-        "name": "SetPacking",
+        "name": "SpinGlass",
         "variant": {
           "graph": "SimpleGraph",
-          "weight": "i32"
+          "weight": "f64"
         }
       },
       "target": {
@@ -550,7 +588,7 @@
           "weight": "f64"
         }
       },
-      "bidirectional": false
+      "bidirectional": true
     },
     {
       "source": {
diff --git a/docs/paper/reductions.typ b/docs/paper/reductions.typ
index 0cfc2a903..b4b4b794e 100644
--- a/docs/paper/reductions.typ
+++ b/docs/paper/reductions.typ
@@ -1,5 +1,5 @@
 // Problem Reductions: A Mathematical Reference
-#import "reduction-diagram.typ": reduction-graph, graph-data
+#let graph-data = json("reduction_graph.json")
 #import "@preview/cetz:0.4.2": canvas, draw
 #import "@preview/ctheorems:1.1.3": thmbox, thmplain, thmproof, thmrules
 
@@ -21,6 +21,17 @@
 // Load result JSON: { solutions: [{ source_config, target_config }, ...] }
 #let load-results(name) = json("examples/" + name + ".result.json")
 
+#let problem-schemas = json("problem_schemas.json")
+
+// Render a problem's Rust struct from the JSON schema
+#let render-struct(name) = {
+  let schema = problem-schemas.find(s => s.name == name)
+  if schema == none { return }
+  let s = schema
+  let fields = s.fields.map(f => "    " + f.name + ": " + f.type_name + ",").join("\n")
+  raw("pub struct " + name + " {\n" + fields + "\n}", lang: "rust", block: true)
+}
+
 // Extract primary variable count from an instance dict.
 #let instance-vars(inst) = {
   if "num_variables" in inst { inst.num_variables }
@@ -87,17 +98,12 @@
 
 = Introduction
 
-A _reduction_ from problem $A$ to problem $B$, denoted $A arrow.long B$, is a polynomial-time transformation of $A$-instances into $B$-instances such that: (1) the transformation runs in polynomial time, (2) solutions to $B$ can be efficiently mapped back to solutions of $A$, and (3) optimal solutions are preserved. @fig:reduction-graph shows the #graph-data.edges.len() reductions connecting #graph-data.nodes.len() problem types.
+A _reduction_ from problem $A$ to problem $B$, denoted $A arrow.long B$, is a polynomial-time transformation of $A$-instances into $B$-instances such that: (1) the transformation runs in polynomial time, (2) solutions to $B$ can be efficiently mapped back to solutions of $A$, and (3) optimal solutions are preserved. The library implements #graph-data.edges.len() reductions connecting #graph-data.nodes.len() problem types.
 
 == Notation
 
 We use the following notation throughout. An _undirected graph_ $G = (V, E)$ consists of a vertex set $V$ and edge set $E subset.eq binom(V, 2)$. For a set $S$, $overline(S)$ or $V backslash S$ denotes its complement. We write $|S|$ for cardinality. For Boolean variables, $overline(x)$ denotes negation ($not x$). A _literal_ is a variable $x$ or its negation $overline(x)$. A _clause_ is a disjunction of literals. A formula in _conjunctive normal form_ (CNF) is a conjunction of clauses. We abbreviate Independent Set as IS, Vertex Cover as VC, and use $n$ for problem size, $m$ for number of clauses, and $k_j = |C_j|$ for clause size.
 
-#figure(
-  reduction-graph(width: 18mm, height: 14mm),
-  caption: [Reduction graph. Colors: green (graph), red (set), yellow (optimization), blue (satisfiability), pink (specialized).]
-) <fig:reduction-graph>
-
 = Problem Definitions <sec:problems>
 
 == Graph Problems
@@ -109,12 +115,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ IS→VC (@thm:is-to-vc), IS→SetPacking (@thm:is-to-setpacking), IS→QUBO (@thm:is-to-qubo), IS→ILP (@thm:is-to-ilp), IS→GridGraph IS (@thm:is-to-gridgraph), VC→IS (@thm:is-to-vc), SAT→IS (@thm:sat-to-is).
 
-  ```rust
-  pub struct IndependentSet<W = i32> {
-      graph: UnGraph<(), ()>,
-      weights: Vec<W>,
-  }
-  ```
+  #render-struct("IndependentSet")
 
   Where `graph` represents $G = (V, E)$ with vertices indexed $0..n-1$, and `weights` stores vertex weights $w: V -> RR$ indexed by vertex ID. The solution is a subset $S subset.eq V$ represented as a `Vec<usize>` of vertex indices.
 ] <def:independent-set>
@@ -124,12 +125,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ VC→IS (@thm:is-to-vc), VC→SetCovering (@thm:vc-to-setcovering), VC→QUBO (@thm:vc-to-qubo), VC→ILP (@thm:vc-to-ilp), IS→VC (@thm:is-to-vc).
 
-  ```rust
-  pub struct VertexCovering<W = i32> {
-      graph: UnGraph<(), ()>,
-      weights: Vec<W>,
-  }
-  ```
+  #render-struct("VertexCovering")
 
   Where `graph` represents $G = (V, E)$ with vertices indexed $0..n-1$, and `weights` stores vertex weights $w: V -> RR$ indexed by vertex ID. The solution is a subset $S subset.eq V$ represented as a `Vec<usize>` of vertex indices.
 ] <def:vertex-cover>
@@ -139,13 +135,9 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ MaxCut→SpinGlass (@thm:spinglass-maxcut), SpinGlass→MaxCut (@thm:spinglass-maxcut).
 
-  ```rust
-  pub struct MaxCut<W = i32> {
-      graph: UnGraph<(), W>,
-  }
-  ```
+  #render-struct("MaxCut")
 
-  Where `graph` represents $G = (V, E)$ with edge weights $w: E -> RR$ stored in graph edge data. The solution is a partition $(S, overline(S))$ represented as a binary assignment `Vec<usize>` where 0/1 indicates partition membership.
+  Where `graph` represents $G = (V, E)$, and `edge_weights` stores weights $w: E -> RR$ indexed by edge index. The solution is a partition $(S, overline(S))$ represented as a binary assignment `Vec<usize>` where 0/1 indicates partition membership.
 ] <def:max-cut>
 
 #definition("Graph Coloring")[
@@ -153,14 +145,9 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ Coloring→ILP (@thm:coloring-to-ilp), Coloring→QUBO (@thm:coloring-to-qubo), SAT→Coloring (@thm:sat-to-coloring).
 
-  ```rust
-  pub struct Coloring {
-      num_colors: usize,
-      graph: UnGraph<(), ()>,
-  }
-  ```
+  #render-struct("KColoring")
 
-  Where `num_colors` is the number of colors $k$, and `graph` represents $G = (V, E)$ with vertices indexed $0..n-1$. The solution is a color assignment $c: V -> {0, ..., k-1}$ represented as a `Vec<usize>` indexed by vertex.
+  Where $k$ is a const generic parameter (not a struct field), and `graph` represents $G = (V, E)$ with vertices indexed $0..n-1$. The solution is a color assignment $c: V -> {0, ..., k-1}$ represented as a `Vec<usize>` indexed by vertex.
 ] <def:coloring>
 
 #definition("Dominating Set")[
@@ -168,12 +155,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ DominatingSet→ILP (@thm:dominatingset-to-ilp), SAT→DominatingSet (@thm:sat-to-dominatingset).
 
-  ```rust
-  pub struct DominatingSet<W = i32> {
-      graph: UnGraph<(), ()>,
-      weights: Vec<W>,
-  }
-  ```
+  #render-struct("DominatingSet")
 
   Where `graph` represents $G = (V, E)$ with vertices indexed $0..n-1$, and `weights` stores vertex weights $w: V -> RR$ indexed by vertex ID. The solution is a subset $S subset.eq V$ represented as a `Vec<usize>` of vertex indices.
 ] <def:dominating-set>
@@ -183,15 +165,9 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ Matching→SetPacking (@thm:matching-to-setpacking), Matching→ILP (@thm:matching-to-ilp).
 
-  ```rust
-  pub struct Matching<W = i32> {
-      num_vertices: usize,
-      graph: UnGraph<(), W>,
-      edge_weights: Vec<W>,
-  }
-  ```
+  #render-struct("Matching")
 
-  Where `num_vertices` is $|V|$, `graph` represents $G = (V, E)$ with edge weights, and `edge_weights` stores weights $w: E -> RR$ indexed by edge index. The solution is a subset $M subset.eq E$ represented as a `Vec<usize>` of edge indices.
+  Where `graph` represents $G = (V, E)$ with vertices indexed $0..n-1$, and `edge_weights` stores weights $w: E -> RR$ indexed by edge index. The solution is a subset $M subset.eq E$ represented as a `Vec<usize>` of edge indices.
 ] <def:matching>
 
 #definition("Clique")[
@@ -211,12 +187,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ IS→SetPacking (@thm:is-to-setpacking), SetPacking→QUBO (@thm:setpacking-to-qubo), SetPacking→ILP (@thm:setpacking-to-ilp), Matching→SetPacking (@thm:matching-to-setpacking).
 
-  ```rust
-  pub struct SetPacking<W = i32> {
-      sets: Vec<Vec<usize>>,
-      weights: Vec<W>,
-  }
-  ```
+  #render-struct("SetPacking")
 
   Where `sets` represents the collection $cal(S) = {S_1, ..., S_m}$ where each `Vec<usize>` contains universe element indices, and `weights` stores set weights $w: cal(S) -> RR$ indexed by set index. The solution is a subset $cal(P) subset.eq cal(S)$ represented as a `Vec<usize>` of set indices.
 ] <def:set-packing>
@@ -226,13 +197,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ SetCovering→ILP (@thm:setcovering-to-ilp), VC→SetCovering (@thm:vc-to-setcovering).
 
-  ```rust
-  pub struct SetCovering<W = i32> {
-      universe_size: usize,
-      sets: Vec<Vec<usize>>,
-      weights: Vec<W>,
-  }
-  ```
+  #render-struct("SetCovering")
 
   Where `universe_size` is $|U|$, `sets` represents the collection $cal(S)$ where each `Vec<usize>` contains universe element indices, and `weights` stores set weights $w: cal(S) -> RR$ indexed by set index. The solution is a subset $cal(C) subset.eq cal(S)$ represented as a `Vec<usize>` of set indices.
 ] <def:set-covering>
@@ -244,15 +209,9 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ SpinGlass→MaxCut (@thm:spinglass-maxcut), SpinGlass→QUBO (@thm:spinglass-qubo), Circuit→SpinGlass (@thm:circuit-to-spinglass), MaxCut→SpinGlass (@thm:spinglass-maxcut), QUBO→SpinGlass (@thm:spinglass-qubo).
 
-  ```rust
-  pub struct SpinGlass<W = f64> {
-      num_spins: usize,
-      interactions: Vec<((usize, usize), W)>,
-      fields: Vec<W>,
-  }
-  ```
+  #render-struct("SpinGlass")
 
-  Where `num_spins` is $n$, `interactions` stores pairwise couplings $J_(i j)$ as `Vec<((usize, usize), W)>`, and `fields` stores external fields $h_i$ as `Vec<W>` indexed by spin. The solution is a spin assignment $bold(s) in {-1, +1}^n$ encoded as `Vec<usize>` where 0 maps to $s=-1$ and 1 maps to $s=+1$.
+  Where `graph` encodes the interaction topology, `couplings` stores pairwise couplings $J_(i j)$ as `Vec<W>` in `graph.edges()` order, and `fields` stores external fields $h_i$ as `Vec<W>` indexed by spin. The solution is a spin assignment $bold(s) in {-1, +1}^n$ encoded as `Vec<usize>` where 0 maps to $s=-1$ and 1 maps to $s=+1$.
 ] <def:spin-glass>
 
 #definition("QUBO")[
@@ -260,12 +219,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ QUBO→SpinGlass (@thm:spinglass-qubo), IS→QUBO (@thm:is-to-qubo), VC→QUBO (@thm:vc-to-qubo), Coloring→QUBO (@thm:coloring-to-qubo), SetPacking→QUBO (@thm:setpacking-to-qubo), kSAT→QUBO (@thm:ksat-to-qubo), ILP→QUBO (@thm:ilp-to-qubo), SpinGlass→QUBO (@thm:spinglass-qubo).
 
-  ```rust
-  pub struct QUBO<W = f64> {
-      num_vars: usize,
-      matrix: Vec<Vec<W>>,
-  }
-  ```
+  #render-struct("QUBO")
 
   Where `num_vars` is $n$, and `matrix` stores the upper-triangular $Q in RR^(n times n)$ as `Vec<Vec<W>>` where `matrix[i][j]` ($i <= j$) stores $Q_(i j)$. The solution is a binary assignment $bold(x) in {0, 1}^n$ represented as `Vec<usize>`.
 ] <def:qubo>
@@ -275,22 +229,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ ILP→QUBO (@thm:ilp-to-qubo), Coloring→ILP (@thm:coloring-to-ilp), Factoring→ILP (@thm:factoring-to-ilp), IS→ILP (@thm:is-to-ilp), VC→ILP (@thm:vc-to-ilp), Matching→ILP (@thm:matching-to-ilp), SetPacking→ILP (@thm:setpacking-to-ilp), SetCovering→ILP (@thm:setcovering-to-ilp), DominatingSet→ILP (@thm:dominatingset-to-ilp), Clique→ILP (@thm:clique-to-ilp).
 
-  ```rust
-  pub struct ILP {
-      num_vars: usize,
-      bounds: Vec<VarBounds>,
-      constraints: Vec<LinearConstraint>,
-      objective: Vec<(usize, f64)>,
-      sense: ObjectiveSense,
-  }
-
-  pub struct VarBounds { lower: Option<i64>, upper: Option<i64> }
-  pub struct LinearConstraint {
-      terms: Vec<(usize, f64)>,
-      cmp: Comparison,
-      rhs: f64,
-  }
-  ```
+  #render-struct("ILP")
 
   Where `num_vars` is $n$, `bounds` stores per-variable bounds $x_i in [l_i, u_i]$ as `Vec<VarBounds>`, `constraints` encodes $A bold(x) <= bold(b)$ as `Vec<LinearConstraint>`, `objective` is the sparse objective $bold(c)$ as `Vec<(usize, f64)>`, and `sense` specifies maximize or minimize. The solution is $bold(x) in ZZ^n$ represented as `Vec<usize>`.
 ] <def:ilp>
@@ -302,17 +241,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ SAT→IS (@thm:sat-to-is), SAT→Coloring (@thm:sat-to-coloring), SAT→DominatingSet (@thm:sat-to-dominatingset), SAT→kSAT (@thm:sat-ksat), kSAT→SAT (@thm:sat-ksat).
 
-  ```rust
-  pub struct Satisfiability<W = i32> {
-      num_vars: usize,
-      clauses: Vec<CNFClause>,
-      weights: Vec<W>,
-  }
-
-  pub struct CNFClause {
-      literals: Vec<i32>,
-  }
-  ```
+  #render-struct("Satisfiability")
 
   Where `num_vars` is $n$, `clauses` stores CNF clauses $C_j$ as `Vec<CNFClause>`, and `weights` stores clause weights for MAX-SAT as `Vec<W>`. Each `CNFClause` has `literals: Vec<i32>` where $+i$ denotes $x_i$ and $-i$ denotes $not x_i$ (1-indexed). The solution is an assignment $bold(x) in {0, 1}^n$ represented as `Vec<usize>`.
 ] <def:satisfiability>
@@ -322,13 +251,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ kSAT→SAT (@thm:sat-ksat), kSAT→QUBO (@thm:ksat-to-qubo), SAT→kSAT (@thm:sat-ksat).
 
-  ```rust
-  pub struct KSatisfiability<const K: usize, W = i32> {
-      num_vars: usize,
-      clauses: Vec<CNFClause>,
-      weights: Vec<W>,
-  }
-  ```
+  #render-struct("KSatisfiability")
 
   Where `num_vars` is $n$, `clauses` stores clauses with exactly $k$ literals per clause as `Vec<CNFClause>`, and `weights` stores clause weights as `Vec<W>`. The solution is an assignment $bold(x) in {0, 1}^n$ represented as `Vec<usize>`.
 ] <def:k-sat>
@@ -338,13 +261,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ Circuit→SpinGlass (@thm:circuit-to-spinglass), Factoring→Circuit (@thm:factoring-to-circuit).
 
-  ```rust
-  pub struct CircuitSAT<W = i32> {
-      circuit: Circuit,
-      variables: Vec<String>,
-      weights: Vec<W>,
-  }
-  ```
+  #render-struct("CircuitSAT")
 
   Where `circuit` is the Boolean circuit of logic gates (AND, OR, NOT, XOR), `variables` stores input variable names as `Vec<String>`, and `weights` stores assignment weights as `Vec<W>`. The solution is an input assignment $bold(x) in {0,1}^n$ represented as `Vec<usize>`.
 ] <def:circuit-sat>
@@ -354,13 +271,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
 
   _Implemented reductions:_ Factoring→Circuit (@thm:factoring-to-circuit), Factoring→ILP (@thm:factoring-to-ilp).
 
-  ```rust
-  pub struct Factoring {
-      m: usize,
-      n: usize,
-      target: u64,
-  }
-  ```
+  #render-struct("Factoring")
 
   Where `m` is the number of bits for the first factor $p$, `n` is the number of bits for the second factor $q$, and `target` is the composite $N$ to factor. The solution is bit assignments for $p$ and $q$ represented as `Vec<usize>`.
 ] <def:factoring>
diff --git a/docs/plans/2026-02-10-dry-mdbook-docs.md b/docs/plans/2026-02-10-dry-mdbook-docs.md
new file mode 100644
index 000000000..5682c6a0b
--- /dev/null
+++ b/docs/plans/2026-02-10-dry-mdbook-docs.md
@@ -0,0 +1,372 @@
+# DRY mdBook Documentation Implementation Plan
+
+> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
+
+**Goal:** Remove hardcoded problem/reduction docs from mdBook, make the interactive graph the primary navigation hub linking to rustdoc, and deploy CLAUDE.md in the book.
+
+**Architecture:** The interactive reduction graph on the introduction page becomes the main entry point for browsing problems and reductions — nodes link to rustdoc struct pages, edges link to rustdoc reduction module pages. All category-specific problem pages and reduction detail pages are removed. Topology is explained as part of variant design in the introduction. CLAUDE.md is auto-copied into the book at build time.
+
+**Tech Stack:** Rust (registry metadata), JavaScript (Cytoscape.js graph), mdBook, Makefile
+
+---
+
+### Task 1: Add `doc_path` to `NodeJson` and `EdgeJson`
+
+**Files:**
+- Modify: `src/rules/graph.rs:35-62` (NodeJson, EdgeJson structs and `to_json()`)
+- Modify: `src/rules/registry.rs:37-49` (ReductionEntry struct)
+
+**Step 1: Add `doc_module` field to `ReductionEntry`**
+
+Add a `doc_module: &'static str` field to `ReductionEntry` in `src/rules/registry.rs`. This holds the module name for rustdoc linking (e.g., `"vertexcovering_independentset"`).
+
+**Step 2: Update the `#[reduction]` macro to emit `doc_module`**
+
+In the proc macro crate (`problemreductions-macros`), update the `#[reduction]` attribute to automatically set `doc_module` from the source file stem. The macro already generates `inventory::submit!` calls — add `doc_module: env!("CARGO_PKG_NAME")` or derive from the impl block's module context. Alternatively, use `module_path!()` at the submit site and strip the crate prefix at export time.
+
+**Step 3: Add `doc_path` to `NodeJson` and `EdgeJson`**
+
+```rust
+pub struct NodeJson {
+    pub name: String,
+    pub variant: BTreeMap<String, String>,
+    pub category: String,
+    pub doc_path: String,  // e.g., "models/graph/independent_set"
+}
+
+pub struct EdgeJson {
+    pub source: VariantRef,
+    pub target: VariantRef,
+    pub bidirectional: bool,
+    pub doc_module: String,  // e.g., "vertexcovering_independentset"
+}
+```
+
+**Step 4: Compute `doc_path` in `to_json()`**
+
+In `ReductionGraph::to_json()`, compute node doc paths from name + category using CamelCase→snake_case conversion:
+- `"IndependentSet"` + `"graph"` → `"models/graph/independent_set"`
+- `"CircuitSAT"` + `"specialized"` → `"models/specialized/circuit_sat"`
+
+For edges, use the `doc_module` from `ReductionEntry`.
+
+**Step 5: Verify JSON output**
+
+Run: `cargo run --example export_graph`
+
+Check that `docs/paper/reduction_graph.json` contains `doc_path` on nodes and `doc_module` on edges.
+
+**Step 6: Run tests**
+
+Run: `make test`
+Expected: All pass (JSON format change doesn't break existing tests since tests don't check JSON fields exhaustively).
+
+**Step 7: Commit**
+
+```bash
+git add src/rules/graph.rs src/rules/registry.rs
+git commit -m "feat(registry): add doc_path to reduction graph JSON nodes and edges"
+```
+
+---
+
+### Task 2: Update interactive graph to link to rustdoc
+
+**Files:**
+- Modify: `docs/src/introduction.md` (Cytoscape.js code)
+
+**Step 1: Update double-click handler for nodes**
+
+Change the existing `dbltap` handler to construct rustdoc URLs from `doc_path`:
+
+```javascript
+cy.on('dbltap', 'node', function(evt) {
+    var d = evt.target.data();
+    if (d.doc_path) {
+        window.location.href = '../' + d.doc_path + '/index.html';
+    }
+});
+```
+
+Note: the `../` prefix is needed because the introduction page is at `book/introduction.html` and rustdoc is at `book/api/problemreductions/...`.
+
+**Step 2: Pass `doc_path` through to Cytoscape node data**
+
+Update the node creation to include `doc_path` from the JSON:
+
+```javascript
+baseNodes.forEach(function(n) {
+    elements.push({ data: {
+        id: n.name, label: n.name,
+        category: n.category || 'other',
+        doc_path: n.doc_path || ''
+    }});
+});
+```
+
+**Step 3: Add edge click handler**
+
+Add a tap handler for edges that opens the reduction module docs:
+
+```javascript
+cy.on('tap', 'edge', function(evt) {
+    var d = evt.target.data();
+    if (d.doc_module) {
+        window.open('../api/problemreductions/rules/' + d.doc_module + '/index.html', '_blank');
+    }
+});
+```
+
+**Step 4: Pass `doc_module` through to Cytoscape edge data**
+
+Update edge creation to include `doc_module` from the JSON.
+
+**Step 5: Update tooltip to show link hints**
+
+Update the node tooltip to say "Double-click to view API docs" and add edge hover tooltip showing source→target with "Click to view reduction docs".
+
+**Step 6: Update instruction text**
+
+Change the hint text to mention all three interactions: path finding (click two nodes), API docs (double-click node), reduction docs (click edge).
+
+**Step 7: Test locally**
+
+Run: `make doc` then open `docs/book/introduction.html`
+
+Verify:
+- Double-click a node → navigates to rustdoc page for that problem
+- Click an edge → opens reduction module docs in new tab
+- Path finding still works (click node → click another node)
+
+**Step 8: Commit**
+
+```bash
+git add docs/src/introduction.md
+git commit -m "feat(docs): link graph nodes to rustdoc, edges to reduction modules"
+```
+
+---
+
+### Task 3: Add variant design and topology to introduction
+
+**Files:**
+- Modify: `docs/src/introduction.md`
+
+**Step 1: Add paper download link**
+
+After the library description, add:
+```markdown
+For theoretical background and correctness proofs, see the [PDF manual](https://codingthrust.github.io/problem-reductions/reductions.pdf).
+```
+
+**Step 2: Add variant design section**
+
+After the reduction graph, add a "## Problem Variants" section explaining:
+- Problems are parameterized by graph type `G` and weight type `W`
+- Base variant: `IndependentSet` (SimpleGraph, unweighted)
+- Graph variants: `IndependentSet/GridGraph`, `IndependentSet/UnitDiskGraph`
+- Weighted variants: `IndependentSet/Weighted`
+- How variants appear as separate nodes in the reduction graph
+
+Keep this concise — 2-3 paragraphs max. Link to rustdoc for full API details.
+
+**Step 3: Add topology overview**
+
+Within the variant design section, briefly describe the 4 graph types:
+- **SimpleGraph**: Standard adjacency-based graph (petgraph)
+- **GridGraph**: Regular grid layout
+- **UnitDiskGraph**: Geometric graph with distance threshold (for quantum hardware mapping)
+- **HyperGraph**: Edges can connect any number of vertices
+
+One sentence each, with links to their rustdoc pages.
+
+**Step 4: Remove problem categories table**
+
+The existing table duplicating problem names is no longer needed — the interactive graph serves this purpose. Remove the `## Problem Categories` section.
+
+**Step 5: Commit**
+
+```bash
+git add docs/src/introduction.md
+git commit -m "docs: add variant design, topology overview, and paper link to introduction"
+```
+
+---
+
+### Task 4: Merge reductions content into getting-started
+
+**Files:**
+- Modify: `docs/src/getting-started.md`
+- Delete: `docs/src/reductions/using.md`
+
+**Step 1: Add reduction chaining section**
+
+Add the "Chaining Reductions" example from `reductions/using.md` to `getting-started.md`, after the existing "Applying Reductions" section.
+
+**Step 2: Add type safety section**
+
+Add the "Type Safety" compile_fail example from `reductions/using.md`.
+
+**Step 3: Update "Next Steps" links**
+
+Replace the old links to problems/reductions with:
+- Link to the interactive reduction graph on the introduction page
+- Link to the API reference
+- Link to solvers
+
+**Step 4: Commit**
+
+```bash
+git add docs/src/getting-started.md
+git commit -m "docs: merge reduction usage into getting-started"
+```
+
+---
+
+### Task 5: Remove obsolete pages and update SUMMARY.md
+
+**Files:**
+- Delete: `docs/src/problems/index.md`
+- Delete: `docs/src/problems/graph.md`
+- Delete: `docs/src/problems/satisfiability.md`
+- Delete: `docs/src/problems/optimization.md`
+- Delete: `docs/src/problems/set.md`
+- Delete: `docs/src/problems/specialized.md`
+- Delete: `docs/src/reductions/index.md`
+- Delete: `docs/src/reductions/using.md`
+- Delete: `docs/src/reductions/available.md`
+- Delete: `docs/src/reductions/graph.md`
+- Delete: `docs/src/topology.md`
+- Modify: `docs/src/SUMMARY.md`
+
+**Step 1: Update SUMMARY.md**
+
+```markdown
+[Introduction](./introduction.md)
+
+# User Guide
+
+- [Getting Started](./getting-started.md)
+- [Solvers](./solvers.md)
+- [File I/O](./io.md)
+
+# Developer Guide
+
+- [API Reference](./api.md)
+- [Contributing](./contributing.md)
+- [CLAUDE.md](./claude.md)
+```
+
+**Step 2: Delete obsolete files**
+
+Remove all files listed above. Keep `docs/src/reductions/reduction_graph.json` (still needed by the interactive graph).
+
+**Step 3: Verify mdBook builds**
+
+Run: `make doc`
+Expected: No broken internal links (mdBook warns on dead links).
+
+**Step 4: Commit**
+
+```bash
+git add -A docs/src/
+git commit -m "refactor(docs): remove hardcoded problem/reduction pages"
+```
+
+---
+
+### Task 6: Deploy CLAUDE.md in mdBook and update contributing
+
+**Files:**
+- Modify: `Makefile` (doc and mdbook targets)
+- Modify: `docs/src/contributing.md`
+- Create (build step): `docs/src/claude.md` (auto-copied from `.claude/CLAUDE.md`)
+
+**Step 1: Update Makefile to copy CLAUDE.md**
+
+In both `doc:` and `mdbook:` targets, add before `mdbook build`:
+```makefile
+cp .claude/CLAUDE.md docs/src/claude.md
+```
+
+**Step 2: Rewrite contributing.md**
+
+Replace the current content with a human-oriented guide that does NOT duplicate CLAUDE.md:
+- Welcome message and link to [CLAUDE.md](./claude.md) for commands and architecture
+- How to find issues to work on (link to GitHub issues)
+- PR workflow: branch → implement → test → PR
+- Authorship recognition (from README)
+- Link to the AI-assisted workflow (`/issue-to-pr` skill)
+- Code style summary (fmt, clippy, doc comments — one sentence each)
+
+**Step 3: Add CLAUDE.md to .gitignore for docs/src/**
+
+Add `docs/src/claude.md` to `.gitignore` so the auto-copied file isn't committed.
+
+**Step 4: Verify build**
+
+Run: `make doc`
+Expected: CLAUDE.md page renders in the book, contributing.md links to it correctly.
+
+**Step 5: Commit**
+
+```bash
+git add Makefile docs/src/contributing.md .gitignore
+git commit -m "docs: deploy CLAUDE.md in mdBook, rewrite contributing page"
+```
+
+---
+
+### Task 7: Update README contributing section
+
+**Files:**
+- Modify: `README.md`
+
+**Step 1: Expand contributing section**
+
+Keep the existing authorship recognition and step-by-step workflow. Add/update:
+- Link to the deployed CLAUDE.md page in the mdBook for commands and architecture
+- Keep the `make help` reference
+- Ensure no overlap with CLAUDE.md content (don't list individual make commands or architecture details)
+
+**Step 2: Commit**
+
+```bash
+git add README.md
+git commit -m "docs: update README contributing section with CLAUDE.md link"
+```
+
+---
+
+### Task 8: Final verification
+
+**Step 1: Run full checks**
+
+```bash
+make test clippy
+make doc
+make paper
+```
+
+Expected: All pass, no warnings.
+
+**Step 2: Verify in browser**
+
+Open `docs/book/index.html` and check:
+- Interactive graph renders with all nodes
+- Double-click node → rustdoc struct page loads
+- Click edge → reduction module docs open
+- Path finding works
+- Variant design section is present
+- Paper download link works
+- Getting-started includes reduction chaining examples
+- Contributing links to CLAUDE.md page
+- CLAUDE.md page renders correctly
+- No dead internal links
+
+**Step 3: Commit any final fixes**
+
+```bash
+git add -A
+git commit -m "fix: final verification fixes for DRY mdBook docs"
+```
diff --git a/docs/plans/2026-02-10-json-schema-and-interactive-viz.md b/docs/plans/2026-02-10-json-schema-and-interactive-viz.md
new file mode 100644
index 000000000..7818daca9
--- /dev/null
+++ b/docs/plans/2026-02-10-json-schema-and-interactive-viz.md
@@ -0,0 +1,459 @@
+# JSON Schema & Interactive Visualization Implementation Plan
+
+> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
+
+**Goal:** Replace manual Rust struct definitions in typst with auto-generated JSON (issue #33), and move the reduction diagram from typst to an interactive Cytoscape.js page in mdBook (issue #34).
+
+**Architecture:** Use `inventory` crate (already used for `ReductionEntry`) to auto-register problem schema entries. Export to JSON via an example binary. For the interactive diagram, embed Cytoscape.js in an mdBook page with path exploration.
+
+**Tech Stack:** Rust (`inventory`, `serde_json`), Typst, Cytoscape.js (CDN), mdBook
+
+---
+
+### Task 1: Add `FieldInfo` and `ProblemSchemaEntry` to registry
+
+**Files:**
+- Modify: `src/registry/info.rs`
+- Create: `src/registry/schema.rs`
+- Modify: `src/registry/mod.rs`
+
+**Step 1: Add `FieldInfo` struct to `src/registry/info.rs`**
+
+Add after `ProblemInfo` impl block (after line 198):
+
+```rust
+/// Description of a struct field for JSON schema export.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct FieldInfo {
+    /// Field name as it appears in the Rust struct.
+    pub name: &'static str,
+    /// Type name (e.g., "Vec<W>", "UnGraph<(), ()>").
+    pub type_name: &'static str,
+    /// Human-readable description of what this field represents.
+    pub description: &'static str,
+}
+```
+
+Add `fields` to `ProblemInfo`:
+```rust
+pub fields: &'static [FieldInfo],
+```
+
+Update `ProblemInfo::new` to initialize `fields: &[]` and add builder:
+```rust
+pub const fn with_fields(mut self, fields: &'static [FieldInfo]) -> Self {
+    self.fields = fields;
+    self
+}
+```
+
+**Step 2: Create `src/registry/schema.rs`**
+
+```rust
+//! Problem schema registration via inventory.
+
+use super::FieldInfo;
+use serde::Serialize;
+
+/// A registered problem schema entry for static inventory registration.
+pub struct ProblemSchemaEntry {
+    /// Problem name (e.g., "IndependentSet").
+    pub name: &'static str,
+    /// Category (e.g., "graph", "optimization").
+    pub category: &'static str,
+    /// Human-readable description.
+    pub description: &'static str,
+    /// Struct fields.
+    pub fields: &'static [FieldInfo],
+}
+
+inventory::collect!(ProblemSchemaEntry);
+
+/// JSON-serializable problem schema.
+#[derive(Debug, Clone, Serialize)]
+pub struct ProblemSchemaJson {
+    pub name: String,
+    pub category: String,
+    pub description: String,
+    pub fields: Vec<FieldInfoJson>,
+}
+
+/// JSON-serializable field info.
+#[derive(Debug, Clone, Serialize)]
+pub struct FieldInfoJson {
+    pub name: String,
+    pub type_name: String,
+    pub description: String,
+}
+
+/// Collect all registered problem schemas into JSON-serializable form.
+pub fn collect_schemas() -> Vec<ProblemSchemaJson> {
+    let mut schemas: Vec<ProblemSchemaJson> = inventory::iter::<ProblemSchemaEntry>
+        .into_iter()
+        .map(|entry| ProblemSchemaJson {
+            name: entry.name.to_string(),
+            category: entry.category.to_string(),
+            description: entry.description.to_string(),
+            fields: entry
+                .fields
+                .iter()
+                .map(|f| FieldInfoJson {
+                    name: f.name.to_string(),
+                    type_name: f.type_name.to_string(),
+                    description: f.description.to_string(),
+                })
+                .collect(),
+        })
+        .collect();
+    schemas.sort_by(|a, b| a.name.cmp(&b.name));
+    schemas
+}
+```
+
+**Step 3: Update `src/registry/mod.rs`**
+
+Add `mod schema;` and re-export `ProblemSchemaEntry`, `ProblemSchemaJson`, `collect_schemas`.
+
+**Step 4: Run `cargo check`**
+
+Run: `cargo check`
+Expected: Compiles with no errors.
+
+**Step 5: Commit**
+
+```
+feat(registry): add FieldInfo and ProblemSchemaEntry for auto-discovery
+```
+
+---
+
+### Task 2: Register all problem schemas via inventory
+
+**Files:**
+- Modify: `src/models/graph/independent_set.rs`
+- Modify: `src/models/graph/vertex_covering.rs`
+- Modify: `src/models/graph/max_cut.rs`
+- Modify: `src/models/graph/kcoloring.rs`
+- Modify: `src/models/graph/dominating_set.rs`
+- Modify: `src/models/graph/matching.rs`
+- Modify: `src/models/graph/clique.rs`
+- Modify: `src/models/graph/maximal_is.rs`
+- Modify: `src/models/set/set_packing.rs`
+- Modify: `src/models/set/set_covering.rs`
+- Modify: `src/models/optimization/spin_glass.rs`
+- Modify: `src/models/optimization/qubo.rs`
+- Modify: `src/models/optimization/ilp.rs`
+- Modify: `src/models/satisfiability/sat.rs`
+- Modify: `src/models/satisfiability/ksat.rs`
+- Modify: `src/models/specialized/circuit.rs`
+- Modify: `src/models/specialized/factoring.rs`
+- Modify: `src/models/specialized/bmf.rs`
+- Modify: `src/models/specialized/biclique_cover.rs`
+- Modify: `src/models/specialized/paintshop.rs`
+
+**Step 1: Add `inventory::submit!` to each problem file**
+
+Pattern for each file — add at module level (outside impl blocks):
+
+```rust
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
+
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "IndependentSet",
+        category: "graph",
+        description: "Find maximum weight independent set in a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "UnGraph<(), ()>", description: "The underlying graph G=(V,E)" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Vertex weights w: V -> R" },
+        ],
+    }
+}
+```
+
+Full list of registrations (one per problem):
+
+| Problem | Category | Fields |
+|---------|----------|--------|
+| IndependentSet | graph | graph: UnGraph<(), ()>, weights: Vec\<W\> |
+| VertexCovering | graph | graph: UnGraph<(), ()>, weights: Vec\<W\> |
+| MaxCut | graph | graph: UnGraph<(), W>, edge_weights: Vec\<W\> |
+| KColoring | graph | num_colors: usize, graph: UnGraph<(), ()> |
+| DominatingSet | graph | graph: UnGraph<(), ()>, weights: Vec\<W\> |
+| Matching | graph | graph: UnGraph<(), W>, edge_weights: Vec\<W\> |
+| Clique | graph | graph: UnGraph<(), ()>, weights: Vec\<W\> |
+| MaximalIS | graph | graph: UnGraph<(), ()>, weights: Vec\<W\> |
+| SetPacking | set | sets: Vec<Vec\<usize\>>, weights: Vec\<W\> |
+| SetCovering | set | universe_size: usize, sets: Vec<Vec\<usize\>>, weights: Vec\<W\> |
+| SpinGlass | optimization | graph: G, couplings: Vec\<W\>, fields: Vec\<W\> |
+| QUBO | optimization | num_vars: usize, matrix: Vec<Vec\<W\>> |
+| ILP | optimization | num_vars: usize, bounds: Vec\<VarBounds\>, constraints: Vec\<LinearConstraint\>, objective: Vec<(usize, f64)>, sense: ObjectiveSense |
+| Satisfiability | satisfiability | num_vars: usize, clauses: Vec\<CNFClause\>, weights: Vec\<W\> |
+| KSatisfiability | satisfiability | num_vars: usize, clauses: Vec\<CNFClause\>, weights: Vec\<W\> |
+| CircuitSAT | satisfiability | circuit: Circuit, variables: Vec\<String\>, weights: Vec\<W\> |
+| Factoring | specialized | m: usize, n: usize, target: u64 |
+| BMF | specialized | matrix: Vec<Vec\<bool\>>, m: usize, n: usize, k: usize |
+| BicliqueCover | specialized | left_size: usize, right_size: usize, edges: Vec<(usize, usize)>, k: usize |
+| PaintShop | specialized | sequence_indices: Vec\<usize\>, car_labels: Vec\<String\>, is_first: Vec\<bool\>, num_cars: usize |
+
+**Step 2: Run `cargo test`**
+
+Run: `make test`
+Expected: All tests pass.
+
+**Step 3: Commit**
+
+```
+feat(models): register problem schemas for all 20 problem types
+```
+
+---
+
+### Task 3: Create export_schemas example and Makefile target
+
+**Files:**
+- Create: `examples/export_schemas.rs`
+- Modify: `Makefile`
+
+**Step 1: Create `examples/export_schemas.rs`**
+
+```rust
+use problemreductions::registry::collect_schemas;
+use std::path::Path;
+
+fn main() {
+    let schemas = collect_schemas();
+    println!("Collected {} problem schemas", schemas.len());
+
+    let output_path = Path::new("docs/paper/problem_schemas.json");
+    if let Some(parent) = output_path.parent() {
+        std::fs::create_dir_all(parent).expect("Failed to create output directory");
+    }
+
+    let json = serde_json::to_string(&schemas).expect("Failed to serialize");
+    std::fs::write(output_path, &json).expect("Failed to write file");
+    println!("Exported to: {}", output_path.display());
+}
+```
+
+**Step 2: Run the example**
+
+Run: `cargo run --example export_schemas`
+Expected: Creates `docs/paper/problem_schemas.json` with 20 entries.
+
+**Step 3: Add Makefile target**
+
+Add after `export-graph` section:
+
+```makefile
+# Export problem schemas to JSON
+export-schemas:
+	cargo run --example export_schemas
+```
+
+Update `paper` target to include `export-schemas`:
+
+```makefile
+paper: examples
+	cargo run --example export_graph
+	cargo run --example export_schemas
+	cd docs/paper && typst compile reductions.typ reductions.pdf
+```
+
+**Step 4: Run `make paper`**
+
+Run: `make paper`
+Expected: Generates JSON and compiles PDF.
+
+**Step 5: Commit**
+
+```
+feat: add export_schemas example and Makefile target
+```
+
+---
+
+### Task 4: Update typst to read struct definitions from JSON
+
+**Files:**
+- Modify: `docs/paper/reductions.typ`
+
+**Step 1: Add JSON loader and rendering function**
+
+Add after `load-results` (line 22):
+
+```typst
+#let problem-schemas = json("problem_schemas.json")
+
+// Render a problem's Rust struct from the JSON schema
+#let render-struct(name) = {
+  let schema = problem-schemas.find(s => s.name == name)
+  if schema == none { return }
+  let s = schema
+  let fields = s.fields.map(f => "    " + f.name + ": " + f.type_name + ",").join("\n")
+  raw("pub struct " + name + " {\n" + fields + "\n}", lang: "rust", block: true)
+}
+```
+
+**Step 2: Replace all manual Rust code blocks**
+
+For each definition in the typst file, replace the manual ` ```rust ... ``` ` struct block with `#render-struct("ProblemName")`.
+
+Example — for IndependentSet (lines 112-117), replace:
+```
+  ```rust
+  pub struct IndependentSet<W = i32> {
+      graph: UnGraph<(), ()>,
+      weights: Vec<W>,
+  }
+  ```
+```
+with:
+```
+  #render-struct("IndependentSet")
+```
+
+Apply the same pattern for all 15+ struct definitions found in the file:
+IndependentSet, VertexCovering, MaxCut, Coloring (KColoring), DominatingSet, Matching, SetPacking, SetCovering, SpinGlass, QUBO, ILP (including VarBounds and LinearConstraint), Satisfiability (including CNFClause), KSatisfiability, CircuitSAT, Factoring.
+
+**Note:** For ILP, Satisfiability, and CircuitSAT which show supporting structs (VarBounds, LinearConstraint, CNFClause) alongside the main struct, register these as separate schema entries or keep the supporting struct definitions inline.
+
+**Step 3: Run `make paper`**
+
+Run: `make paper`
+Expected: PDF compiles with struct definitions rendered from JSON.
+
+**Step 4: Commit**
+
+```
+refactor(paper): render struct definitions from JSON schema (#33)
+```
+
+---
+
+### Task 5: Remove reduction diagram from typst
+
+**Files:**
+- Modify: `docs/paper/reductions.typ`
+- Delete: `docs/paper/reduction-diagram.typ`
+
+**Step 1: Remove the import**
+
+Remove line 2:
+```typst
+#import "reduction-diagram.typ": reduction-graph, graph-data
+```
+
+**Step 2: Remove `graph-data` references**
+
+Line 90 references `#graph-data.edges.len()` and `#graph-data.nodes.len()`. Rewrite this sentence to not reference the graph data, or load the JSON directly for just the counts:
+```typst
+#let graph-data = json("reduction_graph.json")
+```
+Keep this minimal load only if the edge/node counts are needed in the text. Otherwise remove the sentence referencing the figure.
+
+**Step 3: Remove the figure**
+
+Remove lines 96-99:
+```typst
+#figure(
+  reduction-graph(width: 18mm, height: 14mm),
+  caption: [Reduction graph. Colors: ...]
+) <fig:reduction-graph>
+```
+
+Remove the `@fig:reduction-graph` reference from line 90.
+
+**Step 4: Delete `reduction-diagram.typ`**
+
+Delete `docs/paper/reduction-diagram.typ`.
+
+**Step 5: Run `make paper`**
+
+Run: `make paper`
+Expected: PDF compiles without the diagram.
+
+**Step 6: Commit**
+
+```
+refactor(paper): remove reduction diagram from typst (#34)
+```
+
+---
+
+### Task 6: Create interactive Cytoscape.js page in mdBook
+
+**Files:**
+- Modify: `docs/src/SUMMARY.md`
+- Modify: `docs/src/reductions/graph.md` (replace static mermaid diagram)
+- Modify: `Makefile` (add export-graph to doc target)
+
+**Step 1: Update Makefile doc target**
+
+```makefile
+doc:
+	cargo run --example export_graph
+	cp docs/paper/reduction_graph.json docs/src/reductions/
+	mdbook build docs
+```
+
+**Step 2: Replace mermaid diagram in `docs/src/reductions/graph.md`**
+
+Replace the mermaid code block and legend (lines 7-96) with embedded Cytoscape.js HTML. Keep the Usage, Registered Reductions, and API sections.
+
+The embedded HTML should include:
+- Controls bar: instructions text + "Clear Path" button
+- Canvas div for Cytoscape
+- Cytoscape.js loaded from CDN (`https://unpkg.com/cytoscape@3/dist/cytoscape.min.js`)
+- Inline `<script>` that:
+  1. Fetches `reduction_graph.json` (relative path)
+  2. Filters to base problem nodes (empty variant)
+  3. Deduplicates edges by base name, detects bidirectionality
+  4. Creates Cytoscape instance with cose layout
+  5. Styles nodes by category color
+  6. Adds hover tooltips
+  7. Implements two-click path highlighting using `cy.elements().dijkstra()`
+  8. Handles directed vs bidirectional edge arrows
+
+Category colors (matching the original typst diagram):
+- graph: `#c8f0c8`
+- set: `#f0c8c8`
+- optimization: `#f0f0a0`
+- satisfiability: `#c8c8f0`
+- specialized: `#f0c8e0`
+
+**Step 3: Test locally**
+
+Run: `mdbook serve docs --open`
+Expected: Interactive diagram renders with pan/zoom, colored nodes, hover tooltips, click-to-highlight paths.
+
+**Step 4: Commit**
+
+```
+feat(docs): interactive reduction diagram with Cytoscape.js (#34)
+```
+
+---
+
+### Task 7: Final verification
+
+**Step 1: Run full check**
+
+Run: `make test clippy`
+Expected: All pass.
+
+**Step 2: Build paper**
+
+Run: `make paper`
+Expected: PDF compiles. Struct definitions rendered from JSON. No reduction diagram.
+
+**Step 3: Build docs**
+
+Run: `make doc`
+Expected: mdBook builds. Interactive diagram works.
+
+**Step 4: Update CLAUDE.md if needed**
+
+Add `export-schemas` to the commands section if appropriate.
+
+**Step 5: Commit any final cleanup**
diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md
index 7ea7ecb66..c32e74af2 100644
--- a/docs/src/SUMMARY.md
+++ b/docs/src/SUMMARY.md
@@ -5,21 +5,11 @@
 # User Guide
 
 - [Getting Started](./getting-started.md)
-- [Problem Types](./problems/index.md)
-  - [Graph Problems](./problems/graph.md)
-  - [Satisfiability Problems](./problems/satisfiability.md)
-  - [Optimization Problems](./problems/optimization.md)
-  - [Set Problems](./problems/set.md)
-  - [Specialized Problems](./problems/specialized.md)
-- [Reductions](./reductions/index.md)
-  - [Using Reductions](./reductions/using.md)
-  - [Available Reductions](./reductions/available.md)
-  - [Reduction Graph](./reductions/graph.md)
 - [Solvers](./solvers.md)
-- [Topology Types](./topology.md)
 - [File I/O](./io.md)
 
 # Developer Guide
 
 - [API Reference](./api.md)
 - [Contributing](./contributing.md)
+- [CLAUDE.md](./claude.md)
diff --git a/docs/src/api.md b/docs/src/api.md
index 042274e1c..3025182bf 100644
--- a/docs/src/api.md
+++ b/docs/src/api.md
@@ -1,43 +1,9 @@
 # API Reference
 
-Full API documentation is available at [docs.rs/problemreductions](https://docs.rs/problemreductions) or in the generated rustdoc.
+<meta http-equiv="refresh" content="0; url=api/problemreductions/index.html">
 
-## Quick Links
+Full API documentation is auto-generated from source code via `rustdoc`.
 
-### Core Traits
+**[Browse the API &rarr;](api/problemreductions/index.html)**
 
-- [`Problem`](./api/problemreductions/traits/trait.Problem.html) - Base trait for all problems
-- [`ConstraintSatisfactionProblem`](./api/problemreductions/traits/trait.ConstraintSatisfactionProblem.html) - CSP-specific trait
-- [`ReduceTo`](./api/problemreductions/rules/trait.ReduceTo.html) - Reduction trait
-- [`ReductionResult`](./api/problemreductions/rules/trait.ReductionResult.html) - Reduction result trait
-- [`Solver`](./api/problemreductions/solvers/trait.Solver.html) - Solver trait
-
-### Problem Types
-
-#### Graph
-- [`IndependentSet`](./api/problemreductions/models/graph/struct.IndependentSet.html)
-- [`VertexCovering`](./api/problemreductions/models/graph/struct.VertexCovering.html)
-- [`MaxCut`](./api/problemreductions/models/graph/struct.MaxCut.html)
-- [`Coloring`](./api/problemreductions/models/graph/struct.Coloring.html)
-- [`DominatingSet`](./api/problemreductions/models/graph/struct.DominatingSet.html)
-- [`MaximalIS`](./api/problemreductions/models/graph/struct.MaximalIS.html)
-- [`Matching`](./api/problemreductions/models/graph/struct.Matching.html)
-
-#### Optimization
-- [`SpinGlass`](./api/problemreductions/models/optimization/struct.SpinGlass.html)
-- [`QUBO`](./api/problemreductions/models/optimization/struct.QUBO.html)
-
-#### Set
-- [`SetCovering`](./api/problemreductions/models/set/struct.SetCovering.html)
-- [`SetPacking`](./api/problemreductions/models/set/struct.SetPacking.html)
-
-#### Satisfiability
-- [`Satisfiability`](./api/problemreductions/models/satisfiability/struct.Satisfiability.html)
-- [`CircuitSAT`](./api/problemreductions/models/specialized/struct.CircuitSAT.html)
-- [`Factoring`](./api/problemreductions/models/specialized/struct.Factoring.html)
-
-### Utilities
-- [`ReductionGraph`](./api/problemreductions/rules/struct.ReductionGraph.html)
-- [`TruthTable`](./api/problemreductions/truth_table/struct.TruthTable.html)
-- [`HyperGraph`](./api/problemreductions/topology/struct.HyperGraph.html)
-- [`UnitDiskGraph`](./api/problemreductions/topology/struct.UnitDiskGraph.html)
+If not redirected automatically, run `make doc` to generate the API docs.
diff --git a/docs/src/claude.md b/docs/src/claude.md
new file mode 120000
index 000000000..7afdfd5ff
--- /dev/null
+++ b/docs/src/claude.md
@@ -0,0 +1 @@
+../../.claude/CLAUDE.md
\ No newline at end of file
diff --git a/docs/src/contributing.md b/docs/src/contributing.md
index 6afd09b18..9c4816b46 100644
--- a/docs/src/contributing.md
+++ b/docs/src/contributing.md
@@ -1,57 +1,33 @@
 # Contributing
 
-Contributions are welcome!
+Contributions are welcome! See [CLAUDE.md](./claude.md) for the full list of commands and architecture details.
 
-## Development Setup
+## Finding Issues
 
-```bash
-git clone https://github.com/liujinguo/problemreductions
-cd problemreductions
-cargo build
-cargo test
-```
+Browse [GitHub Issues](https://github.com/CodingThrust/problem-reductions/issues) to find tasks. Issues labeled `good first issue` are a great starting point.
 
-## Running Tests
+## Authorship Recognition
 
-```bash
-cargo test                    # Run all tests
-cargo test --test integration # Integration tests only
-cargo test --test reduction   # Reduction tests only
-```
+**Contribute 10 non-trivial reduction rules and you will be automatically added to the author list of the paper.**
 
-## Code Coverage
+## Workflow
 
-```bash
-cargo tarpaulin --skip-clean --ignore-tests
-```
+1. Find or create a GitHub issue describing your proposal.
+2. Write a detailed plan in `docs/plans/issue-<number>-<slug>.md`.
+3. Implement, test, and submit a PR.
 
-## Documentation
+If you use [Claude Code](https://github.com/anthropics/claude-code), the [`/issue-to-pr`](https://github.com/CodingThrust/problem-reductions/blob/main/.claude/skills/issue-to-pr.md) skill automates the brainstorming, planning, and PR creation workflow.
 
-```bash
-cargo doc --open              # Rustdoc
-mdbook serve                  # mdBook (requires mdbook installed)
-```
+## Before Submitting
 
-## Adding a New Problem
+- `cargo fmt --all` — format code
+- `cargo clippy --all-targets --all-features -- -D warnings` — no warnings
+- `cargo test --all-features -- --include-ignored` — all tests pass
+- New code must have >95% test coverage
 
-1. Create file in `src/models/<category>/`
-2. Implement `Problem` trait
-3. Optionally implement `ConstraintSatisfactionProblem`
-4. Add tests
-5. Export in `mod.rs` and `prelude`
+## Adding Problems and Reductions
 
-## Adding a New Reduction
-
-1. Create file in `src/rules/`
-2. Implement `ReductionResult` for the result type
-3. Implement `ReduceTo<Target> for Source`
-4. Add edge in `ReductionGraph`
-5. Add tests
-6. Export in `mod.rs`
-
-## Code Style
-
-- Run `cargo fmt` before committing
-- Run `cargo clippy` and fix warnings
-- Add doc comments for public items
-- Include examples in documentation
+See the developer guides in `.claude/rules/`:
+- [`adding-models.md`](https://github.com/CodingThrust/problem-reductions/blob/main/.claude/rules/adding-models.md) — how to add problem types
+- [`adding-reductions.md`](https://github.com/CodingThrust/problem-reductions/blob/main/.claude/rules/adding-reductions.md) — how to add reduction rules
+- [`testing.md`](https://github.com/CodingThrust/problem-reductions/blob/main/.claude/rules/testing.md) — testing requirements and patterns
diff --git a/docs/src/getting-started.md b/docs/src/getting-started.md
index 5e33632ca..fd741e3bb 100644
--- a/docs/src/getting-started.md
+++ b/docs/src/getting-started.md
@@ -64,8 +64,42 @@ let vc_solutions = solver.find_best(vc);
 let is_solution = result.extract_solution(&vc_solutions[0]);
 ```
 
+### Chaining Reductions
+
+```rust
+use problemreductions::prelude::*;
+
+let sp = SetPacking::<i32>::new(vec![
+    vec![0, 1],
+    vec![1, 2],
+    vec![2, 3],
+]);
+
+// SetPacking -> IndependentSet -> VertexCovering
+let sp_to_is = ReduceTo::<IndependentSet<i32>>::reduce_to(&sp);
+let is = sp_to_is.target_problem();
+
+let is_to_vc = ReduceTo::<VertexCovering<i32>>::reduce_to(is);
+let vc = is_to_vc.target_problem();
+
+// Solve and extract back through the chain
+let solver = BruteForce::new();
+let vc_solutions = solver.find_best(vc);
+let is_solution = is_to_vc.extract_solution(&vc_solutions[0]);
+let sp_solution = sp_to_is.extract_solution(&is_solution);
+```
+
+### Type Safety
+
+The reduction system is compile-time verified. Invalid reductions won't compile:
+
+```rust,compile_fail
+// This won't compile - no reduction from QUBO to SetPacking
+let result = ReduceTo::<SetPacking<i32>>::reduce_to(&qubo);
+```
+
 ## Next Steps
 
-- Learn about [Problem Types](./problems/index.md)
-- Explore [Available Reductions](./reductions/index.md)
-- Check out the [API Reference](./api.md)
+- Explore the [interactive reduction graph](./introduction.html) to discover available reductions
+- Browse the [API Reference](./api.md) for full documentation
+- Check out the [Solvers](./solvers.md) for different solving strategies
diff --git a/docs/src/introduction.md b/docs/src/introduction.md
index b372f2bbd..c7bc7e61a 100644
--- a/docs/src/introduction.md
+++ b/docs/src/introduction.md
@@ -6,14 +6,185 @@ A Rust library for reducing NP-hard problems.
 
 **problemreductions** provides implementations of various NP-hard computational problems and reduction rules between them. It is designed for algorithm research, education, and quantum optimization studies.
 
-## Features
+For theoretical background and correctness proofs, see the [PDF manual](https://codingthrust.github.io/problem-reductions/reductions.pdf).
 
-- **18+ Problem Types**: Implementations of classic NP-hard problems
-- **Type-Safe Reductions**: Compile-time verified problem transformations
-- **BruteForce Solver**: For testing and verification on small instances
-- **Topology Types**: HyperGraph and UnitDiskGraph support
-- **File I/O**: JSON serialization for all problem types
-- **Truth Tables**: Utilities for logic gadget construction
+## Reduction Graph
+
+<div id="cy" style="width: 100%; height: 500px; border: 1px solid #ddd; border-radius: 4px; background: #fafafa;"></div>
+<div style="margin-top: 8px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;">
+  <div id="legend" style="font-family: sans-serif; font-size: 13px;">
+    <span style="display:inline-block;width:14px;height:14px;background:#c8f0c8;border:1px solid #999;margin-right:3px;vertical-align:middle;border-radius:2px;"></span>Graph
+    <span style="display:inline-block;width:14px;height:14px;background:#f0c8c8;border:1px solid #999;margin-left:10px;margin-right:3px;vertical-align:middle;border-radius:2px;"></span>Set
+    <span style="display:inline-block;width:14px;height:14px;background:#f0f0a0;border:1px solid #999;margin-left:10px;margin-right:3px;vertical-align:middle;border-radius:2px;"></span>Optimization
+    <span style="display:inline-block;width:14px;height:14px;background:#c8c8f0;border:1px solid #999;margin-left:10px;margin-right:3px;vertical-align:middle;border-radius:2px;"></span>Satisfiability
+    <span style="display:inline-block;width:14px;height:14px;background:#f0c8e0;border:1px solid #999;margin-left:10px;margin-right:3px;vertical-align:middle;border-radius:2px;"></span>Specialized
+  </div>
+  <div>
+    <span id="instructions" style="font-family: sans-serif; font-size: 13px; color: #666;">Click a node to start path selection</span>
+    <button id="clear-btn" style="display:none; margin-left:8px; padding:3px 10px; cursor:pointer; font-size:12px;" onclick="clearPath()">Clear</button>
+  </div>
+</div>
+<div style="margin-top: 8px; font-family: sans-serif; font-size: 12px; color: #888;">
+  Click two nodes to find a reduction path. Double-click a node to view its API docs. Scroll to zoom, drag to pan.
+</div>
+<div id="tooltip" style="display:none; position:absolute; background:white; border:1px solid #ccc; padding:8px 12px; border-radius:4px; font-family:sans-serif; font-size:13px; box-shadow:0 2px 8px rgba(0,0,0,0.15); pointer-events:none; z-index:1000;"></div>
+
+<script src="static/cytoscape.min.js"></script>
+<script>
+(function() {
+  var categoryColors = {
+    graph: '#c8f0c8', set: '#f0c8c8', optimization: '#f0f0a0',
+    satisfiability: '#c8c8f0', specialized: '#f0c8e0'
+  };
+  var categoryBorders = {
+    graph: '#4a8c4a', set: '#8c4a4a', optimization: '#8c8c4a',
+    satisfiability: '#4a4a8c', specialized: '#8c4a6a'
+  };
+
+  fetch('reductions/reduction_graph.json')
+    .then(function(r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); })
+    .then(function(data) {
+      var baseNodes = data.nodes.filter(function(n) {
+        return !n.variant || Object.keys(n.variant).length === 0;
+      });
+      var baseNames = {};
+      baseNodes.forEach(function(n) { baseNames[n.name] = true; });
+
+      var edgeMap = {};
+      data.edges.forEach(function(e) {
+        if (!baseNames[e.source.name] || !baseNames[e.target.name]) return;
+        var fwd = e.source.name + '->' + e.target.name;
+        var rev = e.target.name + '->' + e.source.name;
+        if (edgeMap[rev]) { edgeMap[rev].bidirectional = true; }
+        else if (!edgeMap[fwd]) {
+          edgeMap[fwd] = { source: e.source.name, target: e.target.name, bidirectional: e.bidirectional || false };
+        }
+      });
+
+      var elements = [];
+      baseNodes.forEach(function(n) {
+        elements.push({ data: { id: n.name, label: n.name, category: n.category || 'other', doc_path: n.doc_path || '' } });
+      });
+      Object.keys(edgeMap).forEach(function(k) {
+        var e = edgeMap[k];
+        elements.push({ data: { id: k, source: e.source, target: e.target, bidirectional: e.bidirectional } });
+      });
+
+      var cy = cytoscape({
+        container: document.getElementById('cy'),
+        elements: elements,
+        style: [
+          { selector: 'node', style: {
+            'label': 'data(label)', 'text-valign': 'center', 'text-halign': 'center',
+            'font-size': '11px', 'font-family': 'monospace',
+            'width': function(ele) { return Math.max(ele.data('label').length * 8 + 16, 60); },
+            'height': 32, 'shape': 'round-rectangle',
+            'background-color': function(ele) { return categoryColors[ele.data('category')] || '#f0f0f0'; },
+            'border-width': 1.5,
+            'border-color': function(ele) { return categoryBorders[ele.data('category')] || '#999'; },
+            'text-wrap': 'none', 'padding': '6px', 'cursor': 'pointer'
+          }},
+          { selector: 'edge', style: {
+            'width': 2, 'line-color': '#999', 'target-arrow-color': '#999', 'target-arrow-shape': 'triangle',
+            'source-arrow-color': '#999',
+            'source-arrow-shape': function(ele) { return ele.data('bidirectional') ? 'triangle' : 'none'; },
+            'curve-style': 'bezier', 'arrow-scale': 0.8
+          }},
+          { selector: '.highlighted', style: {
+            'background-color': '#ff6b6b', 'border-color': '#cc0000', 'border-width': 3, 'z-index': 10
+          }},
+          { selector: 'edge.highlighted', style: {
+            'line-color': '#ff4444', 'target-arrow-color': '#ff4444', 'source-arrow-color': '#ff4444', 'width': 4, 'z-index': 10
+          }},
+          { selector: '.selected-node', style: {
+            'border-color': '#0066cc', 'border-width': 3, 'background-color': '#cce0ff'
+          }}
+        ],
+        layout: {
+          name: 'cose', animate: false,
+          nodeRepulsion: function() { return 8000; },
+          idealEdgeLength: function() { return 120; },
+          gravity: 0.3, numIter: 500, padding: 30
+        },
+        userZoomingEnabled: true, userPanningEnabled: true, boxSelectionEnabled: false
+      });
+
+      // Tooltip
+      var tooltip = document.getElementById('tooltip');
+      cy.on('mouseover', 'node', function(evt) {
+        var d = evt.target.data();
+        tooltip.innerHTML = '<strong>' + d.label + '</strong><br>Category: ' + d.category + '<br><em>Double-click to view API docs</em>';
+        tooltip.style.display = 'block';
+      });
+      cy.on('mousemove', 'node', function(evt) {
+        var pos = evt.renderedPosition || evt.position;
+        var rect = document.getElementById('cy').getBoundingClientRect();
+        tooltip.style.left = (rect.left + window.scrollX + pos.x + 15) + 'px';
+        tooltip.style.top = (rect.top + window.scrollY + pos.y - 10) + 'px';
+      });
+      cy.on('mouseout', 'node', function() { tooltip.style.display = 'none'; });
+
+      // Double-click to navigate to rustdoc API page
+      cy.on('dbltap', 'node', function(evt) {
+        var d = evt.target.data();
+        if (d.doc_path) {
+          window.location.href = 'api/problemreductions/' + d.doc_path;
+        }
+      });
+
+      // Single-click path selection
+      var selectedNode = null;
+      var instructions = document.getElementById('instructions');
+      var clearBtn = document.getElementById('clear-btn');
+
+      cy.on('tap', 'node', function(evt) {
+        var node = evt.target;
+        if (!selectedNode) {
+          selectedNode = node;
+          node.addClass('selected-node');
+          instructions.textContent = 'Now click a target node to find path from ' + node.data('label');
+        } else if (node === selectedNode) {
+          clearPath();
+        } else {
+          var dijkstra = cy.elements().dijkstra({ root: selectedNode, directed: true });
+          var path = dijkstra.pathTo(node);
+          cy.elements().removeClass('highlighted selected-node');
+          if (path && path.length > 0) {
+            path.addClass('highlighted');
+            instructions.textContent = 'Path: ' + path.nodes().map(function(n) { return n.data('label'); }).join(' \u2192 ');
+          } else {
+            instructions.textContent = 'No path from ' + selectedNode.data('label') + ' to ' + node.data('label');
+          }
+          clearBtn.style.display = 'inline';
+          selectedNode = null;
+        }
+      });
+
+      cy.on('tap', function(evt) { if (evt.target === cy) { clearPath(); } });
+
+      window.clearPath = function() {
+        cy.elements().removeClass('highlighted selected-node');
+        selectedNode = null;
+        instructions.textContent = 'Click a node to start path selection';
+        clearBtn.style.display = 'none';
+      };
+    })
+    .catch(function(err) {
+      document.getElementById('cy').innerHTML = '<p style="padding:1em;color:#c00;">Failed to load reduction graph: ' + err.message + '</p>';
+    });
+})();
+</script>
+
+## Problem Variants
+
+Problems are parameterized by graph type `G` and weight type `W`. The base variant uses `SimpleGraph` and `Unweighted` (e.g., `IndependentSet`). Graph variants specify a different topology (e.g., `IndependentSet/GridGraph`), and weighted variants use numeric weights (e.g., `IndependentSet/Weighted`). Variants appear as separate nodes in the reduction graph when they have distinct reductions.
+
+The library supports four graph topologies:
+
+- **SimpleGraph** — standard adjacency-based graph ([petgraph](https://docs.rs/petgraph))
+- **GridGraph** — vertices on a regular grid with nearest-neighbor edges
+- **UnitDiskGraph** — geometric graph where edges connect vertices within a distance threshold (for quantum hardware mapping)
+- **HyperGraph** — generalized edges connecting any number of vertices
 
 ## Quick Example
 
@@ -31,16 +202,6 @@ let solutions = solver.find_best(&problem);
 assert!(solutions.iter().all(|s| s.iter().sum::<usize>() == 1));
 ```
 
-## Problem Categories
-
-| Category | Problems |
-|----------|----------|
-| **Satisfiability** | SAT, K-SAT, CircuitSAT, Factoring |
-| **Graph** | IndependentSet, VertexCovering, MaxCut, Coloring, DominatingSet, MaximalIS, Matching |
-| **Set** | SetCovering, SetPacking |
-| **Optimization** | SpinGlass, QUBO |
-| **Specialized** | Paintshop, BicliqueCover, BMF |
-
 ## License
 
 MIT License
diff --git a/docs/src/problems/graph.md b/docs/src/problems/graph.md
deleted file mode 100644
index 3a37b54b5..000000000
--- a/docs/src/problems/graph.md
+++ /dev/null
@@ -1,192 +0,0 @@
-# Graph Problems
-
-Graph problems are optimization problems defined on graph structures. This library provides a **template-based** approach where all graph problems share common infrastructure while having problem-specific constraints.
-
-## Design Overview
-
-All graph problems use the `GraphProblem<C, G, W>` template:
-
-- `C: GraphConstraint` - Defines the problem-specific constraint (e.g., independent set, vertex cover)
-- `G: Graph` - The graph topology (defaults to `SimpleGraph`)
-- `W` - Weight type (defaults to `i32`)
-
-Type aliases provide convenient access:
-
-```rust
-use problemreductions::prelude::*;
-use problemreductions::topology::{SimpleGraph, UnitDiskGraph};
-
-// These are equivalent - defaults to SimpleGraph and i32 weights
-let problem: IndependentSetT = IndependentSetT::new(4, vec![(0, 1), (1, 2)]);
-let problem: IndependentSetT<SimpleGraph, i32> = IndependentSetT::new(4, vec![(0, 1), (1, 2)]);
-
-// With custom weight type
-let weighted: IndependentSetT<SimpleGraph, f64> = IndependentSetT::with_weights(
-    4,
-    vec![(0, 1), (1, 2)],
-    vec![1.0, 2.0, 3.0, 4.0]
-);
-
-// On different graph topology (e.g., for quantum hardware)
-let udg = UnitDiskGraph::new(vec![(0.0, 0.0), (1.0, 0.0), (2.0, 0.0)], 1.5);
-let quantum_problem: IndependentSetT<UnitDiskGraph> = IndependentSetT::from_graph(udg);
-```
-
-See [Graph Topology](../topology.md) for details on graph types.
-
-## IndependentSetT
-
-Find a maximum weight set of vertices where no two are adjacent.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem: IndependentSetT = IndependentSetT::new(4, vec![(0, 1), (1, 2), (2, 3)]);
-let solver = BruteForce::new();
-let solutions = solver.find_best(&problem);
-// Maximum IS on a path of 4 vertices has size 2 (vertices 0,2 or 1,3)
-```
-
-**Constraint**: For each edge (u, v), at most one of u or v can be selected.
-
-**Objective**: Maximize sum of weights of selected vertices.
-
-## VertexCoverT
-
-Find a minimum weight set of vertices that covers all edges.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem: VertexCoverT = VertexCoverT::new(4, vec![(0, 1), (1, 2), (2, 3)]);
-let solver = BruteForce::new();
-let solutions = solver.find_best(&problem);
-// Minimum vertex cover on a path of 4 vertices has size 2
-```
-
-**Constraint**: For each edge (u, v), at least one of u or v must be selected.
-
-**Objective**: Minimize sum of weights of selected vertices.
-
-**Relationship with Independent Set**: IS and VC are complements. For any graph with n vertices:
-```
-|max IS| + |min VC| = n
-```
-
-A set S is an independent set if and only if V \ S is a vertex cover.
-
-## CliqueT
-
-Find a maximum weight complete subgraph.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem: CliqueT = CliqueT::new(4, vec![(0, 1), (0, 2), (1, 2), (2, 3)]);
-// Vertices 0, 1, 2 form a triangle (clique of size 3)
-```
-
-**Constraint**: Every pair of selected vertices must be connected by an edge.
-
-**Objective**: Maximize sum of weights of selected vertices.
-
-**Relationship with Independent Set**: Finding a maximum clique in G is equivalent to finding a maximum independent set in the complement graph G'.
-
-## MaxCut
-
-Partition vertices into two sets to maximize the weight of edges between them.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = MaxCut::new(3, vec![(0, 1, 2), (1, 2, 3), (0, 2, 1)]);
-// Edge weights: (0,1)=2, (1,2)=3, (0,2)=1
-```
-
-**Note**: MaxCut uses a different structure as it requires edge weights directly.
-
-## Coloring
-
-Assign k colors to vertices minimizing adjacent same-color pairs.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = Coloring::new(4, 3, vec![(0, 1), (1, 2), (2, 3)]);
-// 4 vertices, 3 colors available
-```
-
-## Available Graph Problems
-
-| Problem | Type Alias | Objective | Constraint |
-|---------|------------|-----------|------------|
-| Independent Set | `IndependentSetT<G, W>` | Maximize | No adjacent selected |
-| Vertex Cover | `VertexCoverT<G, W>` | Minimize | All edges covered |
-| Clique | `CliqueT<G, W>` | Maximize | All selected adjacent |
-| Max Cut | `MaxCut` | Maximize | Cut weight |
-| Coloring | `Coloring` | Minimize | Adjacent same-color |
-| Dominating Set | `DominatingSet` | Minimize | All dominated |
-| Maximal IS | `MaximalIS` | - | Maximal independent |
-| Matching | `Matching` | Maximize | Non-adjacent edges |
-
-## Using with Different Topologies
-
-The template design enables **topology-aware reductions**. For example, reducing SAT to Independent Set can target different graph types:
-
-```rust
-use problemreductions::topology::{SimpleGraph, UnitDiskGraph};
-use problemreductions::models::graph::IndependentSetT;
-
-// Standard reduction produces arbitrary graph
-// impl ReduceTo<IndependentSetT<SimpleGraph>> for Satisfiability { ... }
-
-// Topology-aware reduction produces unit disk graph
-// impl ReduceTo<IndependentSetT<UnitDiskGraph>> for Satisfiability { ... }
-```
-
-This is particularly useful for quantum computing where neutral atom arrays naturally implement unit disk graph connectivity.
-
-## Common Operations
-
-All graph problems implement the `OptProblem` trait:
-
-```rust
-use problemreductions::prelude::*;
-
-let problem: IndependentSetT = IndependentSetT::new(4, vec![(0, 1), (1, 2), (2, 3)]);
-
-// Check solution validity and size
-let solution = vec![1, 0, 1, 0];  // Select vertices 0 and 2
-let result = problem.solution_size(&solution);
-assert!(result.is_valid);
-assert_eq!(result.size, 2);
-
-// Get problem parameters
-assert_eq!(problem.num_variables(), 4);
-assert_eq!(problem.num_flavors(), 2);  // Binary: selected (1) or not (0)
-
-// Check optimization direction
-assert!(problem.energy_mode().is_maximization());
-```
-
-## CSP Interface
-
-Graph problems also implement the `ConstraintSatisfactionProblem` trait:
-
-```rust
-use problemreductions::prelude::*;
-
-let problem: IndependentSetT = IndependentSetT::new(3, vec![(0, 1), (1, 2)]);
-
-// Get constraints (one per edge)
-let constraints = problem.constraints();
-assert_eq!(constraints.len(), 2);
-
-// Get objectives (one per vertex)
-let objectives = problem.objectives();
-assert_eq!(objectives.len(), 3);
-
-// Check if solution satisfies all constraints
-let solution = vec![1, 0, 1];
-assert!(problem.is_satisfied(&solution));
-```
diff --git a/docs/src/problems/index.md b/docs/src/problems/index.md
deleted file mode 100644
index c226a7d63..000000000
--- a/docs/src/problems/index.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# Problem Types
-
-This library implements 18+ NP-hard computational problems across several categories.
-
-## Categories
-
-### Graph Problems
-
-Problems defined on graphs with vertices and edges:
-- **IndependentSet**: Find maximum weight set of non-adjacent vertices
-- **VertexCovering**: Find minimum weight set covering all edges
-- **MaxCut**: Partition vertices to maximize cut weight
-- **Coloring**: Assign colors minimizing conflicts
-- **DominatingSet**: Find minimum set dominating all vertices
-- **MaximalIS**: Find maximal independent sets
-- **Matching**: Find maximum weight matching
-
-[Learn more about Graph Problems](./graph.md)
-
-### Satisfiability Problems
-
-Boolean satisfaction problems:
-- **Satisfiability (SAT)**: Find satisfying assignments for CNF formulas
-- **CircuitSAT**: Satisfy boolean circuits
-- **Factoring**: Factor integers (reducible to SAT)
-
-[Learn more about Satisfiability Problems](./satisfiability.md)
-
-### Optimization Problems
-
-Continuous optimization on discrete domains:
-- **SpinGlass**: Ising model Hamiltonian minimization
-- **QUBO**: Quadratic unconstrained binary optimization
-
-[Learn more about Optimization Problems](./optimization.md)
-
-### Set Problems
-
-Problems involving set collections:
-- **SetCovering**: Minimum weight cover of universe
-- **SetPacking**: Maximum weight packing of disjoint sets
-
-[Learn more about Set Problems](./set.md)
-
-### Specialized Problems
-
-Domain-specific problems:
-- **PaintShop**: Minimize color switches
-- **BicliqueCover**: Cover bipartite graph with bicliques
-- **BMF**: Boolean matrix factorization
-
-[Learn more about Specialized Problems](./specialized.md)
-
-## Common Interface
-
-All problems implement the `Problem` trait:
-
-```rust
-pub trait Problem {
-    type Size;
-
-    fn num_variables(&self) -> usize;
-    fn num_flavors(&self) -> usize;
-    fn problem_size(&self) -> ProblemSize;
-    fn solution_size(&self, config: &[usize]) -> SolutionSize<Self::Size>;
-    fn energy_mode(&self) -> EnergyMode;
-}
-```
diff --git a/docs/src/problems/optimization.md b/docs/src/problems/optimization.md
deleted file mode 100644
index 9b4276754..000000000
--- a/docs/src/problems/optimization.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Optimization Problems
-
-## SpinGlass (Ising Model)
-
-Minimize the Ising Hamiltonian: `H = Σ J_ij s_i s_j + Σ h_i s_i`
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = SpinGlass::new(
-    3,
-    vec![((0, 1), -1.0), ((1, 2), 1.0)],  // Interactions
-    vec![0.5, -0.5, 0.0],                  // On-site fields
-);
-
-let solver = BruteForce::new();
-let solutions = solver.find_best(&problem);
-```
-
-## QUBO
-
-Quadratic Unconstrained Binary Optimization: `minimize x^T Q x`
-
-```rust
-use problemreductions::prelude::*;
-
-// From matrix
-let problem = QUBO::from_matrix(vec![
-    vec![1.0, -2.0],
-    vec![0.0, 1.0],
-]);
-
-// From linear and quadratic terms
-let problem = QUBO::new(
-    vec![1.0, -1.0],           // Linear (diagonal)
-    vec![((0, 1), 0.5)],       // Quadratic (off-diagonal)
-);
-```
-
-## Relationship
-
-SpinGlass and QUBO are equivalent via the transformation `s = 2x - 1`:
-- `x = 0` corresponds to `s = -1`
-- `x = 1` corresponds to `s = +1`
-
-The library provides bidirectional reductions between them.
diff --git a/docs/src/problems/satisfiability.md b/docs/src/problems/satisfiability.md
deleted file mode 100644
index 44889dab9..000000000
--- a/docs/src/problems/satisfiability.md
+++ /dev/null
@@ -1,176 +0,0 @@
-# Satisfiability Problems
-
-Satisfiability problems involve finding assignments to boolean variables that satisfy given constraints.
-
-## SAT (Boolean Satisfiability)
-
-The Boolean Satisfiability Problem (SAT) asks whether there exists an assignment of truth values to variables that makes a given boolean formula evaluate to TRUE.
-
-**Definition**: Given a CNF (Conjunctive Normal Form) formula with n variables and m clauses, find an assignment that satisfies all clauses.
-
-A CNF formula is a conjunction (AND) of clauses, where each clause is a disjunction (OR) of literals. A literal is either a variable (x) or its negation (NOT x).
-
-```rust
-use problemreductions::prelude::*;
-
-// Formula: (x1 OR x2) AND (NOT x1 OR x3)
-let problem = Satisfiability::<i32>::new(
-    3,  // 3 variables
-    vec![
-        CNFClause::new(vec![1, 2]),     // x1 OR x2
-        CNFClause::new(vec![-1, 3]),    // NOT x1 OR x3
-    ],
-);
-
-let solver = BruteForce::new();
-let solutions = solver.find_best(&problem);
-```
-
-**Complexity**: SAT is NP-complete (Cook-Levin theorem, 1971).
-
-### KSatisfiability (k-SAT)
-
-A restricted version where every clause has exactly k literals.
-
-```rust
-use problemreductions::prelude::*;
-
-// 3-SAT formula: each clause has exactly 3 literals
-let problem = KSatisfiability::<3, i32>::new(
-    4,  // 4 variables
-    vec![
-        KSATClause::new([1, 2, 3]),      // x1 OR x2 OR x3
-        KSATClause::new([-1, -2, 4]),    // NOT x1 OR NOT x2 OR x4
-    ],
-);
-```
-
-**Note**: 3-SAT remains NP-complete, while 2-SAT is in P.
-
-## CircuitSAT
-
-CircuitSAT extends SAT to boolean circuits. Instead of a CNF formula, the input is a circuit of logic gates (AND, OR, NOT, XOR).
-
-**Definition**: Given a boolean circuit, find an assignment to input variables such that the circuit outputs TRUE.
-
-```rust
-use problemreductions::prelude::*;
-
-// Circuit computing: output = (x AND y) XOR z
-let circuit = Circuit::new(vec![
-    Assignment::new(
-        vec!["temp".to_string()],
-        BooleanExpr::and(vec![BooleanExpr::var("x"), BooleanExpr::var("y")]),
-    ),
-    Assignment::new(
-        vec!["output".to_string()],
-        BooleanExpr::xor(vec![BooleanExpr::var("temp"), BooleanExpr::var("z")]),
-    ),
-]);
-let problem = CircuitSAT::<i32>::new(circuit);
-
-let solver = BruteForce::new();
-let solutions = solver.find_best(&problem);
-```
-
-### Supported Gate Types
-
-- `BooleanExpr::and(inputs)` - AND gate
-- `BooleanExpr::or(inputs)` - OR gate
-- `BooleanExpr::not(input)` - NOT gate
-- `BooleanExpr::xor(inputs)` - XOR gate
-- `BooleanExpr::var(name)` - Input variable
-- `BooleanExpr::constant(value)` - Constant TRUE/FALSE
-
-**Complexity**: CircuitSAT is NP-complete.
-
-### Reduction to SpinGlass
-
-CircuitSAT can be reduced to SpinGlass (Ising model) using gate gadgets. Each logic gate is mapped to a set of spin interactions that encode the gate's truth table as energy penalties.
-
-```rust
-use problemreductions::prelude::*;
-
-let circuit = Circuit::new(vec![
-    Assignment::new(
-        vec!["c".to_string()],
-        BooleanExpr::and(vec![BooleanExpr::var("x"), BooleanExpr::var("y")]),
-    ),
-]);
-let problem = CircuitSAT::<i32>::new(circuit);
-
-// Reduce to SpinGlass
-let reduction = ReduceTo::<SpinGlass<i32>>::reduce_to(&problem);
-let sg = reduction.target_problem();
-```
-
-## Factoring
-
-Integer factorization expressed as a decision problem. Given a composite number N, find non-trivial factors p and q such that p * q = N.
-
-**Definition**: Given N and bit sizes m and n, find m-bit integer p and n-bit integer q such that p * q = N.
-
-```rust
-use problemreductions::prelude::*;
-
-// Factor 15 using 4-bit factors
-// Arguments: (m bits for p, n bits for q, target N)
-let problem = Factoring::new(4, 4, 15);
-
-// Read a candidate solution
-let solution = vec![1, 1, 0, 0, 1, 0, 1, 0]; // p=3, q=5 in little-endian
-let (p, q) = problem.read_factors(&solution);
-assert_eq!(p * q, 15);
-```
-
-### How it Works
-
-The `Factoring` problem stores:
-- `m`: Number of bits for the first factor
-- `n`: Number of bits for the second factor
-- `target`: The number to factor (N)
-
-Solutions are bit vectors where:
-- First m bits encode p (little-endian)
-- Next n bits encode q (little-endian)
-
-### Reduction to CircuitSAT
-
-Factoring reduces to CircuitSAT by constructing a multiplier circuit:
-
-```rust
-use problemreductions::prelude::*;
-
-let factoring = Factoring::new(4, 4, 15);
-
-// Reduce to CircuitSAT (multiplier circuit)
-let reduction = ReduceTo::<CircuitSAT<i32>>::reduce_to(&factoring);
-let circuit_sat = reduction.target_problem();
-
-// The circuit computes p * q and constrains output = 15
-// Solving gives the factors
-```
-
-The reduction builds an array multiplier circuit with:
-- Input variables for p (m bits) and q (n bits)
-- Multiplier cells computing partial products
-- Output constraints fixing the product to equal N
-
-**Complexity**: Factoring is believed to be hard classically but in BQP (solvable by quantum computers via Shor's algorithm).
-
-## Problem Relationships
-
-```
-Factoring --> CircuitSAT --> SpinGlass
-                  |
-                  v
-            Satisfiability --> IndependentSet
-                  |                  |
-                  v                  v
-              Coloring          SetPacking
-                  |
-                  v
-           DominatingSet
-```
-
-All these problems are NP-complete (except Factoring, whose complexity is unknown but believed to be intermediate).
diff --git a/docs/src/problems/set.md b/docs/src/problems/set.md
deleted file mode 100644
index 366e3e436..000000000
--- a/docs/src/problems/set.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Set Problems
-
-## SetCovering
-
-Find minimum weight collection of sets that covers all elements.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = SetCovering::<i32>::new(
-    5,  // Universe size
-    vec![
-        vec![0, 1, 2],
-        vec![2, 3, 4],
-        vec![0, 4],
-    ],
-);
-```
-
-## SetPacking
-
-Find maximum weight collection of pairwise disjoint sets.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = SetPacking::<i32>::new(vec![
-    vec![0, 1],
-    vec![1, 2],  // Overlaps with first
-    vec![2, 3],
-    vec![4],
-]);
-```
-
-## Relationship to Graph Problems
-
-SetPacking is equivalent to IndependentSet on the intersection graph:
-- Each set becomes a vertex
-- Overlapping sets are connected by edges
-
-The library provides reductions between them.
diff --git a/docs/src/problems/specialized.md b/docs/src/problems/specialized.md
deleted file mode 100644
index 5e67a0e21..000000000
--- a/docs/src/problems/specialized.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Specialized Problems
-
-## PaintShop
-
-Minimize color switches in a painting sequence where each car type needs both colors.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = PaintShop::new(vec!["a", "b", "a", "b", "c", "c"]);
-```
-
-## BicliqueCover
-
-Cover edges of a bipartite graph using k bicliques.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = BicliqueCover::new(
-    2,  // Left vertices
-    2,  // Right vertices
-    vec![(0, 2), (0, 3), (1, 2), (1, 3)],  // Edges
-    1,  // Number of bicliques
-);
-```
-
-## BMF (Boolean Matrix Factorization)
-
-Factor a boolean matrix M into A * B with minimum rank.
-
-```rust
-use problemreductions::prelude::*;
-
-let problem = BMF::new(
-    vec![
-        vec![true, true],
-        vec![true, false],
-    ],
-    1,  // Rank
-);
-```
diff --git a/docs/src/reductions/available.md b/docs/src/reductions/available.md
deleted file mode 100644
index 2227d9f23..000000000
--- a/docs/src/reductions/available.md
+++ /dev/null
@@ -1,206 +0,0 @@
-# Available Reductions
-
-This page documents all reduction rules implemented in the library, with academic citations.
-
-## Graph Problem Reductions
-
-### IndependentSet <-> VertexCovering
-
-These are complement problems on the same graph. A set S is an independent set if and only if V \ S is a vertex cover.
-
-**Citation**: Karp, R. M. (1972). "Reducibility among Combinatorial Problems". In Miller, R. E.; Thatcher, J. W. (eds.). Complexity of Computer Computations. Plenum Press. pp. 85-103.
-
-```rust
-use problemreductions::prelude::*;
-
-let is = IndependentSet::<i32>::new(4, vec![(0, 1), (1, 2)]);
-let result = ReduceTo::<VertexCovering<i32>>::reduce_to(&is);
-```
-
-For any graph: `|max IS| + |min VC| = n`
-
-### IndependentSet <-> SetPacking
-
-Based on the intersection graph equivalence. Each vertex becomes a set containing its incident edges.
-
-**Citation**: Gavril, F. (1972). "Algorithms for Minimum Coloring, Maximum Clique, Minimum Covering by Cliques, and Maximum Independent Set of a Chordal Graph". SIAM Journal on Computing. 1 (2): 180-187.
-
-```rust
-use problemreductions::prelude::*;
-
-let is = IndependentSet::<i32>::new(3, vec![(0, 1), (1, 2)]);
-let result = ReduceTo::<SetPacking<i32>>::reduce_to(&is);
-```
-
-### VertexCovering -> SetCovering
-
-Each vertex becomes a set containing the edges it covers. The universe is the set of all edges.
-
-**Citation**: Karp, R. M. (1972). "Reducibility among Combinatorial Problems". In Miller, R. E.; Thatcher, J. W. (eds.). Complexity of Computer Computations. Plenum Press. pp. 85-103.
-
-```rust
-use problemreductions::prelude::*;
-
-let vc = VertexCovering::<i32>::new(3, vec![(0, 1), (1, 2)]);
-let result = ReduceTo::<SetCovering<i32>>::reduce_to(&vc);
-```
-
-### Matching -> SetPacking
-
-Each edge (u, v) becomes a set {u, v}. A matching (no two edges share a vertex) corresponds to a set packing (no two sets overlap).
-
-**Citation**: Edmonds, J. (1965). "Paths, Trees, and Flowers". Canadian Journal of Mathematics. 17: 449-467.
-
-```rust
-use problemreductions::prelude::*;
-
-let matching = Matching::<i32>::new(4, vec![(0, 1), (1, 2), (2, 3)]);
-let result = ReduceTo::<SetPacking<i32>>::reduce_to(&matching);
-```
-
-## Optimization Reductions
-
-### SpinGlass <-> QUBO
-
-Uses variable substitution `s = 2x - 1` to convert between spin variables (±1) and binary variables (0/1).
-
-**Citation**: Lucas, A. (2014). "Ising formulations of many NP problems". Frontiers in Physics. 2: 5.
-
-```rust
-use problemreductions::prelude::*;
-
-let sg = SpinGlass::new(2, vec![((0, 1), -1.0)], vec![0.0, 0.0]);
-let result = ReduceTo::<QUBO>::reduce_to(&sg);
-```
-
-### SpinGlass <-> MaxCut
-
-Direct mapping for pure interaction terms. On-site fields require an ancilla vertex connected to all spins.
-
-**Citation**: Barahona, F. (1982). "On the computational complexity of Ising spin glass models". Journal of Physics A: Mathematical and General. 15 (10): 3241-3253.
-
-```rust
-use problemreductions::prelude::*;
-
-let sg = SpinGlass::new(3, vec![((0, 1), 1), ((1, 2), 1)], vec![0, 0, 0]);
-let result = ReduceTo::<MaxCut<i32>>::reduce_to(&sg);
-```
-
-## SAT-Based Reductions
-
-### Satisfiability <-> KSatisfiability
-
-Converts between general CNF-SAT and k-SAT (clauses with exactly k literals). Large clauses are split using auxiliary variables; small clauses are padded.
-
-**Citation**: Cook, S. A. (1971). "The Complexity of Theorem-Proving Procedures". Proceedings of the Third Annual ACM Symposium on Theory of Computing. pp. 151-158.
-
-```rust
-use problemreductions::prelude::*;
-
-let sat = Satisfiability::<i32>::new(3, vec![
-    CNFClause::new(vec![1, 2, 3]),
-    CNFClause::new(vec![-1, 2]),
-]);
-let result = ReduceTo::<KSatisfiability<3, i32>>::reduce_to(&sat);
-```
-
-### Satisfiability -> IndependentSet
-
-Each literal occurrence in a clause becomes a vertex. Edges connect conflicting literals (x and NOT x) and literals within the same clause.
-
-**Citation**: Karp, R. M. (1972). "Reducibility among Combinatorial Problems". In Miller, R. E.; Thatcher, J. W. (eds.). Complexity of Computer Computations. Plenum Press. pp. 85-103.
-
-```rust
-use problemreductions::prelude::*;
-
-let sat = Satisfiability::<i32>::new(2, vec![
-    CNFClause::new(vec![1, 2]),
-    CNFClause::new(vec![-1, -2]),
-]);
-let result = ReduceTo::<IndependentSet<i32>>::reduce_to(&sat);
-```
-
-### Satisfiability -> Coloring
-
-Uses gadget-based construction with three special colors (TRUE, FALSE, AUX). Variables are represented as vertex pairs, and OR-gadgets enforce clause satisfaction.
-
-**Citation**: Garey, M. R.; Johnson, D. S. (1979). Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman. ISBN 0-7167-1045-5.
-
-```rust
-use problemreductions::prelude::*;
-
-let sat = Satisfiability::<i32>::new(2, vec![
-    CNFClause::new(vec![1, 2]),
-]);
-let result = ReduceTo::<Coloring>::reduce_to(&sat);
-```
-
-### Satisfiability -> DominatingSet
-
-Variables and clauses become vertices. A variable vertex dominates clause vertices containing that literal.
-
-**Citation**: Garey, M. R.; Johnson, D. S. (1979). Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman. ISBN 0-7167-1045-5.
-
-```rust
-use problemreductions::prelude::*;
-
-let sat = Satisfiability::<i32>::new(2, vec![
-    CNFClause::new(vec![1, -2]),
-]);
-let result = ReduceTo::<DominatingSet<i32>>::reduce_to(&sat);
-```
-
-## Circuit Reductions
-
-### CircuitSAT -> SpinGlass
-
-Each logic gate is mapped to a spin glass gadget that encodes the gate's truth table as energy penalties.
-
-**Citation**: Whitfield, J. D.; Faccin, M.; Biamonte, J. D. (2012). "Ground-state spin logic". EPL (Europhysics Letters). 99 (5): 57004.
-
-```rust
-use problemreductions::prelude::*;
-
-let circuit = Circuit::new(vec![
-    Assignment::new(vec!["c".to_string()],
-        BooleanExpr::and(vec![BooleanExpr::var("x"), BooleanExpr::var("y")])),
-]);
-let problem = CircuitSAT::<i32>::new(circuit);
-let result = ReduceTo::<SpinGlass<i32>>::reduce_to(&problem);
-```
-
-### Factoring -> CircuitSAT
-
-Constructs a multiplier circuit that computes p * q and constrains the output to equal the target number N. A satisfying assignment reveals the factors.
-
-**Citation**: Folklore result using standard array multiplier circuits. The construction is well-known in hardware verification and circuit complexity.
-
-```rust
-use problemreductions::prelude::*;
-
-// Factor 15 with 4-bit factors
-let factoring = Factoring::new(4, 4, 15);
-let result = ReduceTo::<CircuitSAT<i32>>::reduce_to(&factoring);
-```
-
-## Reduction Summary Table
-
-| Source | Target | Type | Reference |
-|--------|--------|------|-----------|
-| IndependentSet | VertexCovering | Complement | Karp 1972 |
-| VertexCovering | IndependentSet | Complement | Karp 1972 |
-| IndependentSet | SetPacking | Intersection graph | Gavril 1972 |
-| SetPacking | IndependentSet | Intersection graph | Gavril 1972 |
-| VertexCovering | SetCovering | Edge covering | Karp 1972 |
-| Matching | SetPacking | Edge-to-set | Edmonds 1965 |
-| SpinGlass | QUBO | Variable substitution | Lucas 2014 |
-| QUBO | SpinGlass | Variable substitution | Lucas 2014 |
-| SpinGlass | MaxCut | Direct mapping | Barahona 1982 |
-| MaxCut | SpinGlass | Direct mapping | Barahona 1982 |
-| Satisfiability | KSatisfiability | Clause splitting | Cook 1971 |
-| KSatisfiability | Satisfiability | Direct embedding | Cook 1971 |
-| Satisfiability | IndependentSet | Gadget | Karp 1972 |
-| Satisfiability | Coloring | Gadget | Garey & Johnson 1979 |
-| Satisfiability | DominatingSet | Gadget | Garey & Johnson 1979 |
-| CircuitSAT | SpinGlass | Gate gadgets | Whitfield et al. 2012 |
-| Factoring | CircuitSAT | Multiplier circuit | Folklore |
diff --git a/docs/src/reductions/graph.md b/docs/src/reductions/graph.md
deleted file mode 100644
index 8a504105c..000000000
--- a/docs/src/reductions/graph.md
+++ /dev/null
@@ -1,163 +0,0 @@
-# Reduction Graph
-
-The `ReductionGraph` allows discovering reduction paths between problem types.
-
-## Reduction Diagram
-
-```mermaid
-flowchart TD
-    subgraph Specialized["Specialized Problems"]
-        Factoring
-    end
-
-    subgraph Circuit["Circuit Problems"]
-        CircuitSAT
-    end
-
-    subgraph SAT["Satisfiability Problems"]
-        Satisfiability
-        KSat["KSatisfiability&lt;3&gt;"]
-    end
-
-    subgraph Graph["Graph Problems"]
-        IS["IndependentSet"]
-        VC["VertexCovering"]
-        Coloring
-        DS["DominatingSet"]
-        Matching
-    end
-
-    subgraph Set["Set Problems"]
-        SP["SetPacking"]
-        SC["SetCovering"]
-    end
-
-    subgraph Optimization["Optimization Problems"]
-        SG_i32["SpinGlass&lt;i32&gt;"]
-        SG_f64["SpinGlass&lt;f64&gt;"]
-        QUBO["QUBO&lt;f64&gt;"]
-        MaxCut["MaxCut&lt;i32&gt;"]
-        ILP["ILP"]
-    end
-
-    %% Factoring chain
-    Factoring --> CircuitSAT
-    Factoring --> ILP
-    CircuitSAT --> SG_i32
-
-    %% SAT reductions
-    Satisfiability <--> KSat
-    Satisfiability --> IS
-    Satisfiability --> Coloring
-    Satisfiability --> DS
-
-    %% Graph problem reductions
-    IS <--> VC
-    IS <--> SP
-    VC --> SC
-    Matching --> SP
-
-    %% Optimization reductions
-    SG_f64 <--> QUBO
-    SG_i32 <--> MaxCut
-
-    %% ILP reductions
-    Coloring --> ILP
-
-    %% Styling
-    style Factoring fill:#f9f,stroke:#333
-    style CircuitSAT fill:#f9f,stroke:#333
-    style Satisfiability fill:#bbf,stroke:#333
-    style KSat fill:#bbf,stroke:#333
-    style IS fill:#bfb,stroke:#333
-    style VC fill:#bfb,stroke:#333
-    style Coloring fill:#bfb,stroke:#333
-    style DS fill:#bfb,stroke:#333
-    style Matching fill:#bfb,stroke:#333
-    style SP fill:#fbb,stroke:#333
-    style SC fill:#fbb,stroke:#333
-    style SG_i32 fill:#ff9,stroke:#333
-    style SG_f64 fill:#ff9,stroke:#333
-    style QUBO fill:#ff9,stroke:#333
-    style MaxCut fill:#ff9,stroke:#333
-    style ILP fill:#ff9,stroke:#333
-```
-
-## Legend
-
-| Color | Category |
-|-------|----------|
-| Pink | Specialized/Circuit Problems |
-| Blue | Satisfiability Problems |
-| Green | Graph Problems |
-| Red | Set Problems |
-| Yellow | Optimization Problems |
-
-Bidirectional arrows (`<-->`) indicate reductions exist in both directions.
-
-## Usage
-
-```rust
-use problemreductions::prelude::*;
-use problemreductions::rules::ReductionGraph;
-
-let graph = ReductionGraph::new();
-
-// Check if direct reduction exists
-let has_direct = graph.has_direct_reduction::<IndependentSet<i32>, VertexCovering<i32>>();
-
-// Find all paths between types
-let paths = graph.find_paths::<SetPacking<i32>, VertexCovering<i32>>();
-
-// Find shortest path
-let shortest = graph.find_shortest_path::<SetPacking<i32>, VertexCovering<i32>>();
-
-// Get statistics
-println!("Types: {}, Reductions: {}", graph.num_types(), graph.num_reductions());
-```
-
-## Registered Reductions
-
-| Source | Target | Bidirectional |
-|--------|--------|---------------|
-| IndependentSet | VertexCovering | Yes |
-| IndependentSet | SetPacking | Yes |
-| VertexCovering | SetCovering | No |
-| Matching | SetPacking | No |
-| SpinGlass&lt;f64&gt; | QUBO&lt;f64&gt; | Yes |
-| SpinGlass&lt;i32&gt; | MaxCut&lt;i32&gt; | Yes |
-| Satisfiability | KSatisfiability&lt;3&gt; | Yes |
-| Satisfiability | IndependentSet | No |
-| Satisfiability | Coloring | No |
-| Satisfiability | DominatingSet | No |
-| CircuitSAT | SpinGlass&lt;i32&gt; | No |
-| Factoring | CircuitSAT | No |
-| Coloring | ILP | No |
-| Factoring | ILP | No |
-
-## API
-
-```rust
-impl ReductionGraph {
-    /// Create a new reduction graph with all registered reductions.
-    pub fn new() -> Self;
-
-    /// Check if a direct reduction exists from S to T.
-    pub fn has_direct_reduction<S: 'static, T: 'static>(&self) -> bool;
-
-    /// Find all paths from source to target type.
-    pub fn find_paths<S: 'static, T: 'static>(&self) -> Vec<ReductionPath>;
-
-    /// Find the shortest path from source to target type.
-    pub fn find_shortest_path<S: 'static, T: 'static>(&self) -> Option<ReductionPath>;
-
-    /// Get all registered problem type names.
-    pub fn problem_types(&self) -> Vec<&'static str>;
-
-    /// Get the number of registered problem types.
-    pub fn num_types(&self) -> usize;
-
-    /// Get the number of registered reductions.
-    pub fn num_reductions(&self) -> usize;
-}
-```
diff --git a/docs/src/reductions/index.md b/docs/src/reductions/index.md
deleted file mode 100644
index d1b3c967d..000000000
--- a/docs/src/reductions/index.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# Reductions
-
-Problem reductions allow transforming one NP-hard problem into another while preserving solution structure.
-
-## Why Reductions?
-
-- **Solve problems indirectly**: Transform to a problem with a better solver
-- **Prove equivalence**: Show problems have the same computational complexity
-- **Hardware mapping**: Transform to problems supported by quantum hardware
-
-## Available Reductions
-
-| Source | Target | Notes |
-|--------|--------|-------|
-| IndependentSet | VertexCovering | Complement relationship |
-| VertexCovering | IndependentSet | Complement relationship |
-| IndependentSet | SetPacking | Intersection graph |
-| SetPacking | IndependentSet | Intersection graph |
-| VertexCovering | SetCovering | Edge covering |
-| Matching | SetPacking | Edge-to-set mapping |
-| SpinGlass | QUBO | Variable substitution |
-| QUBO | SpinGlass | Variable substitution |
-| SpinGlass | MaxCut | Direct mapping (may add ancilla) |
-| MaxCut | SpinGlass | Direct mapping |
-| Satisfiability | KSatisfiability | Clause splitting/padding |
-| KSatisfiability | Satisfiability | Direct embedding |
-| Satisfiability | IndependentSet | Gadget construction |
-| Satisfiability | Coloring | OR-gadget construction |
-| Satisfiability | DominatingSet | Variable-clause graph |
-| CircuitSAT | SpinGlass | Gate gadgets |
-| Factoring | CircuitSAT | Multiplier circuit |
-
-## Reduction Traits
-
-```rust
-pub trait ReduceTo<T: Problem>: Problem {
-    type Result: ReductionResult<Source = Self, Target = T>;
-    fn reduce_to(&self) -> Self::Result;
-}
-
-pub trait ReductionResult: Clone {
-    type Source: Problem;
-    type Target: Problem;
-
-    fn target_problem(&self) -> &Self::Target;
-    fn extract_solution(&self, target_solution: &[usize]) -> Vec<usize>;
-}
-```
-
-See:
-- [Using Reductions](./using.md)
-- [Available Reductions](./available.md)
-- [Reduction Graph](./graph.md)
diff --git a/docs/src/reductions/reduction_graph.json b/docs/src/reductions/reduction_graph.json
new file mode 100644
index 000000000..1e7fd7f1d
--- /dev/null
+++ b/docs/src/reductions/reduction_graph.json
@@ -0,0 +1,645 @@
+{
+  "nodes": [
+    {
+      "name": "CircuitSAT",
+      "variant": {},
+      "category": "satisfiability",
+      "doc_path": "models/specialized/struct.CircuitSAT.html"
+    },
+    {
+      "name": "CircuitSAT",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "satisfiability",
+      "doc_path": "models/specialized/struct.CircuitSAT.html"
+    },
+    {
+      "name": "CircuitSAT",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "i32"
+      },
+      "category": "satisfiability",
+      "doc_path": "models/specialized/struct.CircuitSAT.html"
+    },
+    {
+      "name": "DominatingSet",
+      "variant": {},
+      "category": "graph",
+      "doc_path": "models/graph/struct.DominatingSet.html"
+    },
+    {
+      "name": "DominatingSet",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.DominatingSet.html"
+    },
+    {
+      "name": "Factoring",
+      "variant": {},
+      "category": "specialized",
+      "doc_path": "models/specialized/struct.Factoring.html"
+    },
+    {
+      "name": "Factoring",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "specialized",
+      "doc_path": "models/specialized/struct.Factoring.html"
+    },
+    {
+      "name": "ILP",
+      "variant": {},
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.ILP.html"
+    },
+    {
+      "name": "ILP",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.ILP.html"
+    },
+    {
+      "name": "IndependentSet",
+      "variant": {},
+      "category": "graph",
+      "doc_path": "models/graph/struct.IndependentSet.html"
+    },
+    {
+      "name": "IndependentSet",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.IndependentSet.html"
+    },
+    {
+      "name": "IndependentSet",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "i32"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.IndependentSet.html"
+    },
+    {
+      "name": "KColoring",
+      "variant": {},
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
+    },
+    {
+      "name": "KColoring",
+      "variant": {
+        "graph": "SimpleGraph",
+        "k": "N",
+        "weight": "i32"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
+    },
+    {
+      "name": "KColoring",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
+    },
+    {
+      "name": "KColoring",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "i32"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.KColoring.html"
+    },
+    {
+      "name": "KSatisfiability",
+      "variant": {},
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.KSatisfiability.html"
+    },
+    {
+      "name": "KSatisfiability",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.KSatisfiability.html"
+    },
+    {
+      "name": "KSatisfiability",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "i32"
+      },
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.KSatisfiability.html"
+    },
+    {
+      "name": "Matching",
+      "variant": {},
+      "category": "graph",
+      "doc_path": "models/graph/struct.Matching.html"
+    },
+    {
+      "name": "Matching",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.Matching.html"
+    },
+    {
+      "name": "MaxCut",
+      "variant": {},
+      "category": "graph",
+      "doc_path": "models/graph/struct.MaxCut.html"
+    },
+    {
+      "name": "MaxCut",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.MaxCut.html"
+    },
+    {
+      "name": "QUBO",
+      "variant": {},
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.QUBO.html"
+    },
+    {
+      "name": "QUBO",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "f64"
+      },
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.QUBO.html"
+    },
+    {
+      "name": "Satisfiability",
+      "variant": {},
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.Satisfiability.html"
+    },
+    {
+      "name": "Satisfiability",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "satisfiability",
+      "doc_path": "models/satisfiability/struct.Satisfiability.html"
+    },
+    {
+      "name": "SetCovering",
+      "variant": {},
+      "category": "set",
+      "doc_path": "models/set/struct.SetCovering.html"
+    },
+    {
+      "name": "SetCovering",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "set",
+      "doc_path": "models/set/struct.SetCovering.html"
+    },
+    {
+      "name": "SetPacking",
+      "variant": {},
+      "category": "set",
+      "doc_path": "models/set/struct.SetPacking.html"
+    },
+    {
+      "name": "SetPacking",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "set",
+      "doc_path": "models/set/struct.SetPacking.html"
+    },
+    {
+      "name": "SetPacking",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "i32"
+      },
+      "category": "set",
+      "doc_path": "models/set/struct.SetPacking.html"
+    },
+    {
+      "name": "SpinGlass",
+      "variant": {},
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.SpinGlass.html"
+    },
+    {
+      "name": "SpinGlass",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.SpinGlass.html"
+    },
+    {
+      "name": "SpinGlass",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "f64"
+      },
+      "category": "optimization",
+      "doc_path": "models/optimization/struct.SpinGlass.html"
+    },
+    {
+      "name": "VertexCovering",
+      "variant": {},
+      "category": "graph",
+      "doc_path": "models/graph/struct.VertexCovering.html"
+    },
+    {
+      "name": "VertexCovering",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "Unweighted"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.VertexCovering.html"
+    },
+    {
+      "name": "VertexCovering",
+      "variant": {
+        "graph": "SimpleGraph",
+        "weight": "i32"
+      },
+      "category": "graph",
+      "doc_path": "models/graph/struct.VertexCovering.html"
+    }
+  ],
+  "edges": [
+    {
+      "source": {
+        "name": "CircuitSAT",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "SpinGlass",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "Factoring",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "CircuitSAT",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "i32"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "Factoring",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "ILP",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "ILP",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "QUBO",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "IndependentSet",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "i32"
+        }
+      },
+      "target": {
+        "name": "QUBO",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "KColoring",
+        "variant": {
+          "graph": "SimpleGraph",
+          "k": "N",
+          "weight": "i32"
+        }
+      },
+      "target": {
+        "name": "ILP",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "KColoring",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "QUBO",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "KSatisfiability",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "i32"
+        }
+      },
+      "target": {
+        "name": "QUBO",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "Matching",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "SetPacking",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "Satisfiability",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "DominatingSet",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "Satisfiability",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "IndependentSet",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "Satisfiability",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "KColoring",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "i32"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "Satisfiability",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "KSatisfiability",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": true
+    },
+    {
+      "source": {
+        "name": "SetPacking",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "IndependentSet",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": true
+    },
+    {
+      "source": {
+        "name": "SetPacking",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "i32"
+        }
+      },
+      "target": {
+        "name": "QUBO",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "SpinGlass",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "MaxCut",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": true
+    },
+    {
+      "source": {
+        "name": "SpinGlass",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "target": {
+        "name": "QUBO",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "bidirectional": true
+    },
+    {
+      "source": {
+        "name": "VertexCovering",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "IndependentSet",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": true
+    },
+    {
+      "source": {
+        "name": "VertexCovering",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "target": {
+        "name": "SetCovering",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "Unweighted"
+        }
+      },
+      "bidirectional": false
+    },
+    {
+      "source": {
+        "name": "VertexCovering",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "i32"
+        }
+      },
+      "target": {
+        "name": "QUBO",
+        "variant": {
+          "graph": "SimpleGraph",
+          "weight": "f64"
+        }
+      },
+      "bidirectional": false
+    }
+  ]
+}
\ No newline at end of file
diff --git a/docs/src/reductions/using.md b/docs/src/reductions/using.md
deleted file mode 100644
index d62ec48ee..000000000
--- a/docs/src/reductions/using.md
+++ /dev/null
@@ -1,58 +0,0 @@
-# Using Reductions
-
-## Basic Usage
-
-```rust
-use problemreductions::prelude::*;
-
-// Create source problem
-let is = IndependentSet::<i32>::new(4, vec![(0, 1), (1, 2), (2, 3)]);
-
-// Reduce to target problem
-let result = ReduceTo::<VertexCovering<i32>>::reduce_to(&is);
-let vc = result.target_problem();
-
-// Solve target problem
-let solver = BruteForce::new();
-let vc_solutions = solver.find_best(vc);
-
-// Extract solution back to source problem
-let is_solution = result.extract_solution(&vc_solutions[0]);
-
-// Verify solution is valid
-assert!(is.solution_size(&is_solution).is_valid);
-```
-
-## Chaining Reductions
-
-```rust
-use problemreductions::prelude::*;
-
-let sp = SetPacking::<i32>::new(vec![
-    vec![0, 1],
-    vec![1, 2],
-    vec![2, 3],
-]);
-
-// SetPacking -> IndependentSet -> VertexCovering
-let sp_to_is = ReduceTo::<IndependentSet<i32>>::reduce_to(&sp);
-let is = sp_to_is.target_problem();
-
-let is_to_vc = ReduceTo::<VertexCovering<i32>>::reduce_to(is);
-let vc = is_to_vc.target_problem();
-
-// Solve and extract back through the chain
-let solver = BruteForce::new();
-let vc_solutions = solver.find_best(vc);
-let is_solution = is_to_vc.extract_solution(&vc_solutions[0]);
-let sp_solution = sp_to_is.extract_solution(&is_solution);
-```
-
-## Type Safety
-
-The reduction system is compile-time verified. Invalid reductions won't compile:
-
-```rust,compile_fail
-// This won't compile - no reduction from QUBO to SetPacking
-let result = ReduceTo::<SetPacking<i32>>::reduce_to(&qubo);
-```
diff --git a/docs/src/static/cytoscape.min.js b/docs/src/static/cytoscape.min.js
new file mode 100644
index 000000000..c1364fdec
--- /dev/null
+++ b/docs/src/static/cytoscape.min.js
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2016-2025, 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<t;n++)r[n]=e[n];return r}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=u(e))||t){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=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,v,g,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!$(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"undefined"===Y?void 0:null!=e&&e instanceof HTMLElement},$=function(e){return Q(e)||J(e)},Q=function(e){return"collection"===q(e)&&e._private.single},J=function(e){return"collection"===q(e)&&!e._private.single},ee=function(e){return"core"===q(e)},te=function(e){return"stylesheet"===q(e)},ne=function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},re=function(e){return function(e){return null!=e&&l(e)===X}(e)&&U(e.then)},ae=function(e,t){t||(t=function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);return e.join("$")});var n=function(){var r,a=arguments,i=t.apply(this,a),o=n.cache;return(r=o[i])||(r=o[i]=e.apply(this,a)),r};return n.cache={},n},ie=ae((function(e){return e.replace(/([A-Z])/g,(function(e){return"-"+e.toLowerCase()}))})),oe=ae((function(e){return e.replace(/(-\w)/g,(function(e){return e[1].toUpperCase()}))})),se=ae((function(e,t){return e+t[0].toUpperCase()+t.substring(1)}),(function(e,t){return e+"$"+t})),le=function(e){return ne(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},ue=function(e,t){return e.slice(-1*t.length)===t},ce="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",de="rgb[a]?\\(("+ce+"[%]?)\\s*,\\s*("+ce+"[%]?)\\s*,\\s*("+ce+"[%]?)(?:\\s*,\\s*("+ce+"))?\\)",he="rgb[a]?\\((?:"+ce+"[%]?)\\s*,\\s*(?:"+ce+"[%]?)\\s*,\\s*(?:"+ce+"[%]?)(?:\\s*,\\s*(?:"+ce+"))?\\)",fe="hsl[a]?\\(("+ce+")\\s*,\\s*("+ce+"[%])\\s*,\\s*("+ce+"[%])(?:\\s*,\\s*("+ce+"))?\\)",pe="hsl[a]?\\((?:"+ce+")\\s*,\\s*(?:"+ce+"[%])\\s*,\\s*(?:"+ce+"[%])(?:\\s*,\\s*(?:"+ce+"))?\\)",ve=function(e,t){return e<t?-1:e>t?1:0},ge=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n<t.length;n++){var r=t[n];if(null!=r)for(var a=Object.keys(r),i=0;i<a.length;i++){var o=a[i];e[o]=r[o]}}return e},ye=function(e){return(H(e)?e:null)||function(e){return me[e.toLowerCase()]}(e)||function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,n,r,a=16;return 4===e.length?(t=parseInt(e[1]+e[1],a),n=parseInt(e[2]+e[2],a),r=parseInt(e[3]+e[3],a)):(t=parseInt(e[1]+e[2],a),n=parseInt(e[3]+e[4],a),r=parseInt(e[5]+e[6],a)),[t,n,r]}}(e)||function(e){var t,n=new RegExp("^"+de+"$").exec(e);if(n){t=[];for(var r=[],a=1;a<=3;a++){var i=n[a];if("%"===i[i.length-1]&&(r[a]=!0),i=parseFloat(i),r[a]&&(i=i/100*255),i<0||i>255)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("^"+fe+"$").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)},me={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]},be=function(e){for(var t=e.map,n=e.keys,r=n.length,a=0;a<r;a++){var i=n[a];if(K(i))throw Error("Tried to set map with object key");a<n.length-1?(null==t[i]&&(t[i]={}),t=t[i]):t[i]=e.value}},xe=function(e){for(var t=e.map,n=e.keys,r=n.length,a=0;a<r;a++){var i=n[a];if(K(i))throw Error("Tried to get map with object key");if(null==(t=t[i]))return t}return t},we="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ee(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ke(){if(f)return h;return f=1,h=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Te(){if(y)return g;y=1;var e=function(){if(v)return p;v=1;var e="object"==typeof we&&we&&we.Object===Object&&we;return p=e}(),t="object"==typeof self&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return g=n}function Ce(){if(k)return E;k=1;var e=function(){if(w)return x;w=1;var e=/\s/;return x=function(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n},x}(),t=/^\s+/;return E=function(n){return n?n.slice(0,e(n)+1).replace(t,""):n},E}function Pe(){if(C)return T;C=1;var e=Te().Symbol;return T=e}function Se(){if(A)return _;A=1;var e=Pe(),t=function(){if(S)return P;S=1;var e=Pe(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,a=e?e.toStringTag:void 0;return P=function(e){var t=n.call(e,a),i=e[a];try{e[a]=void 0;var o=!0}catch(e){}var s=r.call(e);return o&&(t?e[a]=i:delete e[a]),s}}(),n=function(){if(D)return B;D=1;var e=Object.prototype.toString;return B=function(t){return e.call(t)}}(),r=e?e.toStringTag:void 0;return _=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":r&&r in Object(e)?t(e):n(e)}}function Be(){if(N)return I;N=1;var e=Se(),t=R?M:(R=1,M=function(e){return null!=e&&"object"==typeof e});return I=function(n){return"symbol"==typeof n||t(n)&&"[object Symbol]"==e(n)}}var De=function(){if(V)return O;V=1;var e=ke(),t=function(){if(b)return m;b=1;var e=Te();return m=function(){return e.Date.now()}}(),n=function(){if(z)return L;z=1;var e=Ce(),t=ke(),n=Be(),r=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,o=parseInt;return L=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(t(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=t(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=e(s);var u=a.test(s);return u||i.test(s)?o(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),r=Math.max,a=Math.min;return O=function(i,o,s){var l,u,c,d,h,f,p=0,v=!1,g=!1,y=!0;if("function"!=typeof i)throw new TypeError("Expected a function");function m(e){var t=l,n=u;return l=u=void 0,p=e,d=i.apply(n,t)}function b(e){var t=e-f;return void 0===f||t>=o||t<0||g&&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 g?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),v?m(e):d}(f);if(g)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)&&(v=!!s.leading,c=(g="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}(),_e=Ee(De),Ae=c?c.performance:null,Me=Ae&&Ae.now?function(){return Ae.now()}:function(){return Date.now()},Re=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(Me())}),1e3/60)}}(),Ie=function(e){return Re(e)},Ne=Me,Le=9261,ze=5381,Oe=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Le;!(t=e.next()).done;)n=65599*n+t.value|0;return n},Ve=function(e){return 65599*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Le)+e|0},Fe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ze;return(t<<5)+t+e|0},Xe=function(e){return 2097152*e[0]+e[1]},je=function(e,t){return[Ve(e[0],t[0]),Fe(e[1],t[1])]},Ye=function(e,t){var n={value:0,done:!1},r=0,a=e.length;return Oe({next:function(){return r<a?n.value=e[r++]:n.done=!0,n}},t)},qe=function(e,t){var n={value:0,done:!1},r=0,a=e.length;return Oe({next:function(){return r<a?n.value=e.charCodeAt(r++):n.done=!0,n}},t)},We=function(){return Ue(arguments)},Ue=function(e){for(var t,n=0;n<e.length;n++){var r=e[n];t=0===n?qe(r):qe(r,t)}return t};function He(e,t,n){if(0===n)return e;var r=(t.x1+t.x2)/2,a=(t.y1+t.y2)/2,i=t.w/t.h,o=1/i,s=function(e,t,n,r,a){var i=a*Math.PI/180;return{x:Math.cos(i)*(e-n)-Math.sin(i)*(t-r)+n,y:Math.sin(i)*(e-n)+Math.cos(i)*(t-r)+r}}(e.x,e.y,r,a,n),l=function(e,t,n,r,a,i){return{x:(e-n)*a+n,y:(t-r)*i+r}}(s.x,s.y,r,a,i,o);return{x:l.x,y:l.y}}var Ke=!0,Ge=null!=console.warn,Ze=null!=console.trace,$e=Number.MAX_SAFE_INTEGER||9007199254740991,Qe=function(){return!0},Je=function(){return!1},et=function(){return 0},tt=function(){},nt=function(e){throw new Error(e)},rt=function(e){if(void 0===e)return Ke;Ke=!!e},at=function(e){rt()&&(Ge?console.warn(e):(console.log(e),Ze&&console.trace()))},it=function(e){return null==e?e:H(e)?e.slice():K(e)?function(e){return ge({},e)}(e):e},ot=function(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"-");return t},st={},lt=function(){return st},ut=function(e){var t=Object.keys(e);return function(n){for(var r={},a=0;a<t.length;a++){var i=t[a],o=null==n?void 0:n[i];r[i]=void 0===o?e[i]:o}return r}},ct=function(e,t,n){for(var r=e.length-1;r>=0;r--)e[r]===t&&e.splice(r,1)},dt=function(e){e.splice(0,e.length)},ht=function(e,t,n){return n&&(t=se(n,t)),e[t]},ft=function(e,t,n,r){n&&(t=se(n,t)),e[t]=r},pt="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;a<r.length;a++)this.add(r[a])}}),[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(e){var t=this._obj;1!==t[e]&&(t[e]=1,this.size++)}},{key:"delete",value:function(e){var t=this._obj;1===t[e]&&(t[e]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(e){return 1===this._obj[e]}},{key:"toArray",value:function(){var e=this;return Object.keys(this._obj).filter((function(t){return e.has(t)}))}},{key:"forEach",value:function(e,t){return this.toArray().forEach(e,t)}}])}(),gt="undefined"!==("undefined"==typeof Set?"undefined":l(Set))?Set:vt,yt=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&ee(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 gt,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;u<c;u++){var d=l[u];d&&""!==d&&a.classes.add(d)}this.createEmitter(),(void 0===n||n)&&this.restore();var h=t.style||t.css;h&&(at("Setting a `style` bypass at element creation should be done only when absolutely necessary.  Try to use the stylesheet instead."),this.style(h))}else nt("An element must be of type `nodes` or `edges`; you specified `"+r+"`")}else nt("An element must have a core reference and parameters set")},mt=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(t,n,r){var a;K(t)&&!$(t)&&(t=(a=t).roots||a.root,n=a.visit,r=a.directed),r=2!==arguments.length||U(n)?r:n,n=U(n)?n:function(){};for(var i,o=this._private.cy,s=t=W(t)?this.filter(t):t,l=[],u=[],c={},d={},h={},f=0,p=this.byGroup(),v=p.nodes,g=p.edges,y=0;y<s.length;y++){var m=s[y],b=m.id();m.isNode()&&(l.unshift(m),e.bfs&&(h[b]=!0,u.push(m)),d[b]=0)}for(var x,w=function(){var t=e.bfs?l.shift():l.pop(),a=t.id();if(e.dfs){if(h[a])return 0;h[a]=!0,u.push(t)}var o,s=d[a],p=c[a],y=null!=p?p.source():null,m=null!=p?p.target():null,b=null==p?void 0:t.same(y)?m[0]:y[0];if(!0===(o=n(t,p,b,f++,s)))return i=t,1;if(!1===o)return 1;for(var x=t.connectedEdges().filter((function(e){return(!r||e.source().same(t))&&g.has(e)})),w=0;w<x.length;w++){var E=x[w],k=E.connectedNodes().filter((function(e){return!e.same(t)&&v.has(e)})),T=k.id();0===k.length||h[T]||(k=k[0],l.push(k),e.bfs&&(h[T]=!0,u.push(k)),c[T]=E,d[T]=d[a]+1)}};0!==l.length&&(0===(x=w())||1!==x););for(var E=o.collection(),k=0;k<u.length;k++){var T=u[k],C=c[T.id()];null!=C&&E.push(C),E.push(T)}return{path:o.collection(E),found:o.collection(i)}}},bt={breadthFirstSearch:mt({bfs:!0}),depthFirstSearch:mt({dfs:!0})};bt.bfs=bt.breadthFirstSearch,bt.dfs=bt.depthFirstSearch;var xt,wt,Et,kt={exports:{}},Tt=kt.exports;function Ct(){return xt||(xt=1,function(e){(function(){var t,n,r,a,i,o,s,l,u,c,d,h,f,p,v;r=Math.floor,c=Math.min,n=function(e,t){return e<t?-1:e>t?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);a<i;)o(t,e[s=r((a+i)/2)])<0?i=s:a=s+1;return[].splice.apply(e,[a,a-a].concat(t)),t},o=function(e,t,r){return null==r&&(r=n),e.push(t),p(e,0,e.length-1,r)},i=function(e,t){var r,a;return null==t&&(t=n),r=e.pop(),e.length?(a=e[0],e[0]=r,v(e,0,t)):a=r,a},l=function(e,t,r){var a;return null==r&&(r=n),a=e[0],e[0]=t,v(e,0,r),a},s=function(e,t,r){var a;return null==r&&(r=n),e.length&&r(e[0],t)<0&&(t=(a=[e[0],t])[0],e[0]=a[1],v(e,0,r)),t},a=function(e,t){var a,i,o,s,l,u;for(null==t&&(t=n),l=[],i=0,o=(s=function(){u=[];for(var t=0,n=r(e.length/2);0<=n?t<n:t>n;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse()).length;i<o;i++)a=s[i],l.push(v(e,a,t));return l},f=function(e,t,r){var a;if(null==r&&(r=n),-1!==(a=e.indexOf(t)))return p(e,0,a,r),v(e,a,r)},d=function(e,t,r){var i,o,l,u,c;if(null==r&&(r=n),!(o=e.slice(0,t)).length)return o;for(a(o,r),l=0,u=(c=e.slice(t)).length;l<u;l++)i=c[l],s(o,i,r);return o.sort(r).reverse()},h=function(e,t,r){var o,s,l,d,h,f,p,v,g;if(null==r&&(r=n),10*t<=e.length){if(!(l=e.slice(0,t).sort(r)).length)return l;for(s=l[l.length-1],d=0,f=(p=e.slice(t)).length;d<f;d++)r(o=p[d],s)<0&&(u(l,o,0,null,r),l.pop(),s=l[l.length-1]);return l}for(a(e,r),g=[],h=0,v=c(t,e.length);0<=v?h<v:h>v;0<=v?++h:--h)g.push(i(e,r));return g},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},v=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;a<i;)(s=a+1)<i&&!(r(e[a],e[s])<0)&&(a=s),e[t]=e[a],a=2*(t=a)+1;return e[t]=o,p(e,l,t,r)},t=function(){function e(e){this.cmp=null!=e?e:n,this.nodes=[]}return e.push=o,e.pop=i,e.replace=l,e.pushpop=s,e.heapify=a,e.updateItem=f,e.nlargest=d,e.nsmallest=h,e.prototype.push=function(e){return o(this.nodes,e,this.cmp)},e.prototype.pop=function(){return i(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return l(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return s(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return a(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return f(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return(t=new e).nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),e.exports=t}).call(Tt)}(kt)),kt.exports}var Pt,St=Ee(Et?wt:(Et=1,wt=Ct())),Bt=ut({root:null,weight:function(e){return 1},directed:!1}),Dt={dijkstra:function(e){if(!K(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=Bt(e),r=n.root,a=n.weight,i=n.directed,o=this,s=a,l=W(r)?this.filter(r)[0]:r[0],u={},c={},d={},h=this.byGroup(),f=h.nodes,p=h.edges;p.unmergeBy((function(e){return e.isLoop()}));for(var v=function(e){return u[e.id()]},g=function(e,t){u[e.id()]=t,y.updateItem(e)},y=new St((function(e,t){return v(e)-v(t)})),m=0;m<f.length;m++){var b=f[m];u[b.id()]=b.same(l)?0:1/0,y.push(b)}for(var x=function(e,t){for(var n,r=(i?e.edgesTo(t):e.edgesWith(t)).intersect(p),a=1/0,o=0;o<r.length;o++){var l=r[o],u=s(l);(u<a||!n)&&(a=u,n=l)}return{edge:n,dist:a}};y.size()>0;){var w=y.pop(),E=v(w),k=w.id();if(d[k]=E,E!==1/0)for(var T=w.neighborhood().intersect(f),C=0;C<T.length;C++){var P=T[C],S=P.id(),B=x(w,P),D=E+B.dist;D<v(P)&&(g(P,D),c[S]={node:w,edge:B.edge})}}return{distanceTo:function(e){var t=W(e)?f.filter(e)[0]:e[0];return d[t.id()]},pathTo:function(e){var t=W(e)?f.filter(e)[0]:e[0],n=[],r=t,a=r.id();if(t.length>0)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)}}}},_t={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;t<i.length;t++){if(i[t].has(e))return t}},l=0;l<a;l++)i[l]=this.spawn(n[l]);for(var u=r.sort((function(t,n){return e(t)-e(n)})),c=0;c<u.length;c++){var d=u[c],h=d.source()[0],f=d.target()[0],p=s(h),v=s(f),g=i[p],y=i[v];p!==v&&(o.merge(d),g.merge(y),i.splice(v,1))}return o}},At=ut({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),Mt={aStar:function(e){var t=this.cy(),n=At(e),r=n.root,a=n.goal,i=n.heuristic,o=n.directed,s=n.weight;r=t.collection(r)[0],a=t.collection(a)[0];var l,u,c=r.id(),d=a.id(),h={},f={},p={},v=new St((function(e,t){return f[e.id()]-f[t.id()]})),g=new gt,y={},m={},b=function(e,t){v.push(e),g.add(t)};b(r,c),h[c]=0,f[c]=i(r);for(var x,w=0;v.size()>0;){if(l=v.pop(),u=l.id(),g.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;S<P.length;S++){var B=P[S];if(this.hasElementWithId(B.id())&&(!o||B.data("source")===u)){var D=B.source(),_=B.target(),A=D.id()!==u?D:_,M=A.id();if(this.hasElementWithId(M)&&!p[M]){var R=h[u]+s(B);x=M,g.has(x)?R<h[M]&&(h[M]=R,f[M]=R+i(A),y[M]=l,m[M]=B):(h[M]=R,f[M]=R+i(A),b(A,M),y[M]=l,m[M]=B)}}}}return{found:!1,distance:void 0,path:void 0,steps:w}}},Rt=ut({weight:function(e){return 1},directed:!1}),It={floydWarshall:function(e){for(var t=this.cy(),n=Rt(e),r=n.weight,a=n.directed,i=r,o=this.byGroup(),s=o.nodes,l=o.edges,u=s.length,c=u*u,d=function(e){return s.indexOf(e)},h=function(e){return s[e]},f=new Array(c),p=0;p<c;p++){var v=p%u,g=(p-v)/u;f[p]=g===v?0:1/0}for(var y=new Array(c),m=new Array(c),b=0;b<l.length;b++){var x=l[b],w=x.source()[0],E=x.target()[0];if(w!==E){var k=d(w),T=d(E),C=k*u+T,P=i(x);if(f[C]>P&&(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;B<u;B++)for(var D=0;D<u;D++)for(var _=D*u+B,A=0;A<u;A++){var M=D*u+A,R=B*u+A;f[_]+f[R]<f[M]&&(f[M]=f[_]+f[R],y[M]=y[_])}var I=function(e){return d(function(e){return(W(e)?t.filter(e):e)[0]}(e))},N={distance:function(e,t){var n=I(e),r=I(t);return f[n*u+r]},path:function(e,n){var r=I(e),a=I(n),i=h(r);if(r===a)return i.collection();if(null==y[r*u+a])return t.collection();var o,s=t.collection(),l=r;for(s.merge(i);r!==a;)l=r,r=y[r*u+a],o=m[l*u+r],s.merge(o),s.merge(h(r));return s}};return N}},Nt=ut({weight:function(e){return 1},directed:!1,root:null}),Lt={bellmanFord:function(e){var t=this,n=Nt(e),r=n.weight,a=n.directed,i=n.root,o=r,s=this,l=this.cy(),u=this.byGroup(),c=u.edges,d=u.nodes,h=d.length,f=new pt,p=!1,v=[];i=l.collection(i)[0],c.unmergeBy((function(e){return e.isLoop()}));for(var g=c.length,y=function(e){var t=f.get(e.id());return t||(t={},f.set(e.id(),t)),t},m=function(e){return(W(e)?l.$(e):e)[0]},b=0;b<h;b++){var x=d[b],w=y(x);x.same(i)?w.dist=0:w.dist=1/0,w.pred=null,w.edge=null}for(var E=!1,k=function(e,t,n,r,a,i){var o=r.dist+i;o<a.dist&&!n.same(r.edge)&&(a.dist=o,a.pred=e,a.edge=n,E=!0)},T=1;T<h;T++){E=!1;for(var C=0;C<g;C++){var P=c[C],S=P.source(),B=P.target(),D=o(P),_=y(S),A=y(B);k(S,0,P,_,A,D),a||k(B,0,P,A,_,D)}if(!E)break}if(E)for(var M=[],R=0;R<g;R++){var I=c[R],N=I.source(),L=I.target(),z=o(I),O=y(N).dist,V=y(L).dist;if(O+z<V||!a&&V+z<O){if(p||(at("Graph contains a negative weight cycle for Bellman-Ford"),p=!0),!1===e.findNegativeWeightCycles)break;var F=[];O+z<V&&F.push(N),!a&&V+z<O&&F.push(L);for(var X=F.length,j=0;j<X;j++){var Y=F[j],q=[Y];q.push(y(Y).edge);for(var U=y(Y).pred;-1===q.indexOf(U);)q.push(U),q.push(y(U).edge),U=y(U).pred;for(var H=(q=q.slice(q.indexOf(U)))[0].id(),K=0,G=2;G<q.length;G+=2)q[G].id()<H&&(H=q[G].id(),K=G);(q=q.slice(K).concat(q.slice(0,K))).push(q[0]);var Z=q.map((function(e){return e.id()})).join(",");-1===M.indexOf(Z)&&(v.push(s.spawn(q)),M.push(Z))}}}return{distanceTo:function(e){return y(m(e)).dist},pathTo:function(e){for(var n=arguments.length>1&&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:v}}},zt=Math.sqrt(2),Ot=function(e,t,n){0===n.length&&nt("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;f<l.length;f++){var p=l[f];p[1]===s?(l[f]=p.slice(),l[f][1]=o):p[2]===s&&(l[f]=p.slice(),l[f][2]=o)}for(var v=0;v<t.length;v++)t[v]===s&&(t[v]=o);return l},Vt=function(e,t,n,r){for(;n>r;){var a=Math.floor(Math.random()*t.length);t=Ot(a,e,t),n--}return t},Ft={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/zt);if(!(a<2)){for(var l=[],u=0;u<i;u++){var c=r[u];l.push([u,n.indexOf(c.source()),n.indexOf(c.target())])}for(var d=1/0,h=[],f=new Array(a),p=new Array(a),v=new Array(a),g=function(e,t){for(var n=0;n<a;n++)t[n]=e[n]},y=0;y<=o;y++){for(var m=0;m<a;m++)p[m]=m;var b=Vt(p,l.slice(),a,s),x=b.slice();g(p,v);var w=Vt(p,b,s,2),E=Vt(v,x,s,2);w.length<=E.length&&w.length<d?(d=w.length,h=w,g(p,f)):E.length<=w.length&&E.length<d&&(d=E.length,h=E,g(v,f))}for(var k=this.spawn(h.map((function(e){return r[e[0]]}))),T=this.spawn(),C=this.spawn(),P=f[0],S=0;S<f.length;S++){var B=f[S],D=n[S];B===P?T.merge(D):C.merge(D)}var _=function(t){var n=e.spawn();return t.forEach((function(t){n.merge(t),t.connectedEdges().forEach((function(t){e.contains(t)&&!k.contains(t)&&n.merge(t)}))})),n},A=[_(T),_(C)];return{cut:k,components:A,partition1:T,partition2:C}}nt("At least 2 nodes are required for Karger-Stein algorithm")}},Xt=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},jt=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},Yt=function(e){return{x:e[0],y:e[1]}},qt=function(e,t){return Math.atan2(t,e)-Math.PI/2},Wt=Math.log2||function(e){return Math.log(e)/Math.log(2)},Ut=function(e){return e>0?1:e<0?-1:0},Ht=function(e,t){return Math.sqrt(Kt(e,t))},Kt=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},Gt=function(e){for(var t=e.length,n=0,r=0;r<t;r++)n+=e[r];for(var a=0;a<t;a++)e[a]=e[a]/n;return e},Zt=function(e,t,n,r){return(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n},$t=function(e,t,n,r){return{x:Zt(e.x,t.x,n.x,r),y:Zt(e.y,t.y,n.y,r)}},Qt=function(e,t,n){return Math.max(e,Math.min(n,t))},Jt=function(e){if(null==e)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(null!=e.x1&&null!=e.y1){if(null!=e.x2&&null!=e.y2&&e.x2>=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}}},en=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},tn=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},nn=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},rn=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},an=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2<t.x1)&&(!(t.x2<e.x1)&&(!(e.y2<t.y1)&&(!(t.y2<e.y1)&&(!(e.y1>t.y2)&&!(t.y1>e.y2)))))))},on=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},sn=function(e,t){return on(e,t.x,t.y)},ln=function(e,t){return on(e,t.x1,t.y1)&&on(e,t.x2,t.y2)},un=null!==(Pt=Math.hypot)&&void 0!==Pt?Pt:function(e,t){return Math.sqrt(e*e+t*t)};function cn(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;n<e.length;n++){var r=e[n],a=e[(n+1)%e.length];t+=r.x*a.y-a.x*r.y}return t/2})(s)<0&&s.reverse();for(var l,u,c=s.length,d=[],h=0;h<c;h++){var f=s[h],p=s[(h+1)%c],v=r(p,f),g=(l={x:v.y,y:-v.x},u=void 0,0===(u=un(l.x,l.y))?{x:0,y:0}:{x:l.x/u,y:l.y/u});d.push(g)}for(var y=d.map((function(e,r){return{p1:n(s[r],a(e,t)),p2:n(s[(r+1)%c],a(e,t))}})),m=[],b=0;b<c;b++){var x=y[(b-1+c)%c],w=y[b],E=o(x.p1,x.p2,w.p1,w.p2);m.push(E)}return m}(Tn(e,t,n,r,a),i),s=Jt();return o.forEach((function(e){return en(s,e.x,e.y)})),s}var dn=function(e,t,n,r,a,i,o){var s,l,u=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"auto",c="auto"===u?_n(a,i):u,d=a/2,h=i/2,f=(c=Math.min(c,d,h))!==d,p=c!==h;if(f){var v=r-h-o;if((s=kn(e,t,n,r,n-d+c-o,v,n+d-c+o,v,!1)).length>0)return s}if(p){var g=n+d+o;if((s=kn(e,t,n,r,g,r-h+c-o,g,r+h-c+o,!1)).length>0)return s}if(f){var y=r+h+o;if((s=kn(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=kn(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=wn(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=wn(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=wn(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=wn(e,t,n,r,C,P,c+o)).length>0&&l[0]<=C&&l[1]>=P?[l[0],l[1]]:[]},hn=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},fn=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!(e<u||e>c||t<d||t>h)},pn=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,v=0;v<u.length;v++)d=Math.pow(1-u[v],2)*n+2*(1-u[v])*u[v]*a+u[v]*u[v]*o,h=Math.pow(1-u[v],2)*r+2*(1-u[v])*u[v]*i+u[v]*u[v]*s,f=Math.pow(d-e,2)+Math.pow(h-t,2),p>=0?f<p&&(p=f):p=f;return p},vn=function(e,t,n,r,a,i){var o=[e-n,t-r],s=[a-n,i-r],l=s[0]*s[0]+s[1]*s[1],u=o[0]*o[0]+o[1]*o[1],c=o[0]*s[0]+o[1]*s[1],d=c*c/l;return c<0?u:d>l?(e-a)*(e-a)+(t-i)*(t-i):u-d},gn=function(e,t,n){for(var r,a,i,o,s=0,l=0;l<n.length/2;l++)if(r=n[2*l],a=n[2*l+1],l+1<n.length/2?(i=n[2*(l+1)],o=n[2*(l+1)+1]):(i=n[2*(l+1-n.length/2)],o=n[2*(l+1-n.length/2)+1]),r==e&&i==e);else{if(!(r>=e&&e>=i||r<=e&&e<=i))continue;(e-r)/(i-r)*(o-a)+a>t&&s++}return s%2!=0},yn=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;p<c.length/2;p++)c[2*p]=i/2*(n[2*p]*h-n[2*p+1]*f),c[2*p+1]=o/2*(n[2*p+1]*h+n[2*p]*f),c[2*p]+=r,c[2*p+1]+=a;if(l>0){var v=bn(c,-l);d=mn(v)}else d=c;return gn(e,t,d)},mn=function(e){for(var t,n,r,a,i,o,s,l,u=new Array(e.length/2),c=0;c<e.length/4;c++){t=e[4*c],n=e[4*c+1],r=e[4*c+2],a=e[4*c+3],c<e.length/4-1?(i=e[4*(c+1)],o=e[4*(c+1)+1],s=e[4*(c+1)+2],l=e[4*(c+1)+3]):(i=e[0],o=e[1],s=e[2],l=e[3]);var d=kn(t,n,r,a,i,o,s,l,!0);u[2*c]=d[0],u[2*c+1]=d[1]}return u},bn=function(e,t){for(var n,r,a,i,o=new Array(2*e.length),s=0;s<e.length/2;s++){n=e[2*s],r=e[2*s+1],s<e.length/2-1?(a=e[2*(s+1)],i=e[2*(s+1)+1]):(a=e[0],i=e[1]);var l=i-r,u=-(a-n),c=Math.sqrt(l*l+u*u),d=l/c,h=u/c;o[4*s]=n+d*t,o[4*s+1]=r+h*t,o[4*s+2]=a+d*t,o[4*s+3]=i+h*t}return o},xn=function(e,t,n,r,a,i,o){return e-=a,t-=i,(e/=n/2+o)*e+(t/=r/2+o)*t<=1},wn=function(e,t,n,r,a,i,o){var s=[n-e,r-t],l=[e-a,t-i],u=s[0]*s[0]+s[1]*s[1],c=2*(l[0]*s[0]+l[1]*s[1]),d=c*c-4*u*(l[0]*l[0]+l[1]*l[1]-o*o);if(d<0)return[];var h=(-c+Math.sqrt(d))/(2*u),f=(-c-Math.sqrt(d))/(2*u),p=Math.min(h,f),v=Math.max(h,f),g=[];if(p>=0&&p<=1&&g.push(p),v>=0&&v<=1&&g.push(v),0===g.length)return[];var y=g[0]*s[0]+e,m=g[0]*s[1]+t;return g.length>1?g[0]==g[1]?[y,m]:[y,m,g[1]*s[0]+e,g[1]*s[1]+t]:[y,m]},En=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},kn=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,v=d*h-p*u,g=c*h-f*u,y=p*c-d*f;if(0!==y){var m=v/y,b=g/y,x=-.001;return x<=m&&m<=1.001&&x<=b&&b<=1.001||l?[e+m*c,t+m*f]:[]}return 0===v||0===g?En(e,n,o)===o?[o,s]:En(e,n,a)===a?[a,i]:En(a,o,n)===n?[n,r]:[]:[]},Tn=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;c<e.length/2;c++)i.push({x:l+o*e[2*c],y:u+s*e[2*c+1]});return i},Cn=function(e,t,n,r,a,i,o,s){var l,u,c,d,h,f,p=[],v=new Array(n.length),g=!0;if(null==i&&(g=!1),g){for(var y=0;y<v.length/2;y++)v[2*y]=n[2*y]*i+r,v[2*y+1]=n[2*y+1]*o+a;if(s>0){var m=bn(v,-s);u=mn(m)}else u=v}else u=n;for(var b=0;b<u.length/2;b++)c=u[2*b],d=u[2*b+1],b<u.length/2-1?(h=u[2*(b+1)],f=u[2*(b+1)+1]):(h=u[0],f=u[1]),0!==(l=kn(e,t,r,a,c,d,h,f)).length&&p.push(l[0],l[1]);return p},Pn=function(e,t,n){var r=[e[0]-t[0],e[1]-t[1]],a=Math.sqrt(r[0]*r[0]+r[1]*r[1]),i=(a-n)/a;return i<0&&(i=1e-5),[t[0]+i*r[0],t[1]+i*r[1]]},Sn=function(e,t){var n=Dn(e,t);return n=Bn(n)},Bn=function(e){for(var t,n,r=e.length/2,a=1/0,i=1/0,o=-1/0,s=-1/0,l=0;l<r;l++)t=e[2*l],n=e[2*l+1],a=Math.min(a,t),o=Math.max(o,t),i=Math.min(i,n),s=Math.max(s,n);for(var u=2/(o-a),c=2/(s-i),d=0;d<r;d++)t=e[2*d]=e[2*d]*u,n=e[2*d+1]=e[2*d+1]*c,a=Math.min(a,t),o=Math.max(o,t),i=Math.min(i,n),s=Math.max(s,n);if(i<-1)for(var h=0;h<r;h++)n=e[2*h+1]=e[2*h+1]+(-1-i);return e},Dn=function(e,t){var n=1/e*2*Math.PI,r=e%2==0?Math.PI/2+n/2:Math.PI/2;r+=t;for(var a,i=new Array(2*e),o=0;o<e;o++)a=o*n+r,i[2*o]=Math.cos(a),i[2*o+1]=Math.sin(-a);return i},_n=function(e,t){return Math.min(e/4,t/4,8)},An=function(e,t){return Math.min(e/10,t/10,8)},Mn=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}};function Rn(e,t){function n(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],a=e[(n+1)%e.length],i={x:a.x-r.x,y:a.y-r.y},o={x:-i.y,y:i.x},s=Math.sqrt(o.x*o.x+o.y*o.y);t.push({x:o.x/s,y:o.y/s})}return t}function a(e,t){var n,a=1/0,i=-1/0,o=r(e);try{for(o.s();!(n=o.n()).done;){var s=n.value,l=s.x*t.x+s.y*t.y;a=Math.min(a,l),i=Math.max(i,l)}}catch(e){o.e(e)}finally{o.f()}return{min:a,max:i}}function i(e,t){return!(e.max<t.min||t.max<e.min)}var s,l=r([].concat(o(n(e)),o(n(t))));try{for(l.s();!(s=l.n()).done;){var u=s.value;if(!i(a(e,u),a(t,u)))return!1}}catch(e){l.e(e)}finally{l.f()}return!0}var In=ut({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),Nn={pageRank:function(e){for(var t=In(e),n=t.dampingFactor,r=t.precision,a=t.iterations,i=t.weight,o=this._private.cy,s=this.byGroup(),l=s.nodes,u=s.edges,c=l.length,d=c*c,h=u.length,f=new Array(d),p=new Array(c),v=(1-n)/c,g=0;g<c;g++){for(var y=0;y<c;y++){f[g*c+y]=0}p[g]=0}for(var m=0;m<h;m++){var b=u[m],x=b.data("source"),w=b.data("target");if(x!==w){var E=l.indexOfId(x),k=l.indexOfId(w),T=i(b);f[k*c+E]+=T,p[E]+=T}}for(var C=1/c+v,P=0;P<c;P++)if(0===p[P])for(var S=0;S<c;S++){f[S*c+P]=C}else for(var B=0;B<c;B++){var D=B*c+P;f[D]=f[D]/p[P]+v}for(var _,A=new Array(c),M=new Array(c),R=0;R<c;R++)A[R]=1;for(var I=0;I<a;I++){for(var N=0;N<c;N++)M[N]=0;for(var L=0;L<c;L++)for(var z=0;z<c;z++){var O=L*c+z;M[L]+=f[O]*A[z]}Gt(M),_=A,A=M,M=_;for(var V=0,F=0;F<c;F++){var X=_[F]-A[F];V+=X*X}if(V<r)break}return{rank:function(e){return e=o.collection(e)[0],A[l.indexOf(e)]}}}},Ln=ut({root:null,weight:function(e){return 1},directed:!1,alpha:0}),zn={degreeCentralityNormalized:function(e){e=Ln(e);var t=this.cy(),n=this.nodes(),r=n.length;if(e.directed){for(var a={},i={},o=0,s=0,l=0;l<r;l++){var u=n[l],c=u.id();e.root=u;var d=this.degreeCentrality(e);o<d.indegree&&(o=d.indegree),s<d.outdegree&&(s=d.outdegree),a[c]=d.indegree,i[c]=d.outdegree}return{indegree:function(e){return 0==o?0:(W(e)&&(e=t.filter(e)),a[e.id()]/o)},outdegree:function(e){return 0===s?0:(W(e)&&(e=t.filter(e)),i[e.id()]/s)}}}for(var h={},f=0,p=0;p<r;p++){var v=n[p];e.root=v;var g=this.degreeCentrality(e);f<g.degree&&(f=g.degree),h[v.id()]=g.degree}return{degree:function(e){return 0===f?0:(W(e)&&(e=t.filter(e)),h[e.id()]/f)}}},degreeCentrality:function(e){e=Ln(e);var t=this.cy(),n=this,r=e,a=r.root,i=r.weight,o=r.directed,s=r.alpha;if(a=t.collection(a)[0],o){for(var l=a.connectedEdges(),u=l.filter((function(e){return e.target().same(a)&&n.has(e)})),c=l.filter((function(e){return e.source().same(a)&&n.has(e)})),d=u.length,h=c.length,f=0,p=0,v=0;v<u.length;v++)f+=i(u[v]);for(var g=0;g<c.length;g++)p+=i(c[g]);return{indegree:Math.pow(d,1-s)*Math.pow(f,s),outdegree:Math.pow(h,1-s)*Math.pow(p,s)}}for(var y=a.connectedEdges().intersection(n),m=y.length,b=0,x=0;x<y.length;x++)b+=i(y[x]);return{degree:Math.pow(m,1-s)*Math.pow(b,s)}}};zn.dc=zn.degreeCentrality,zn.dcn=zn.degreeCentralityNormalised=zn.degreeCentralityNormalized;var On=ut({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),Vn={closenessCentralityNormalized:function(e){for(var t=On(e),n=t.harmonic,r=t.weight,a=t.directed,i=this.cy(),o={},s=0,l=this.nodes(),u=this.floydWarshall({weight:r,directed:a}),c=0;c<l.length;c++){for(var d=0,h=l[c],f=0;f<l.length;f++)if(c!==f){var p=u.distance(h,l[f]);d+=n?1/p:p}n||(d=1/d),s<d&&(s=d),o[h.id()]=d}return{closeness:function(e){return 0==s?0:(e=W(e)?i.filter(e)[0].id():e.id(),o[e]/s)}}},closenessCentrality:function(e){var t=On(e),n=t.root,r=t.weight,a=t.directed,i=t.harmonic;n=this.filter(n)[0];for(var o=this.dijkstra({root:n,weight:r,directed:a}),s=0,l=this.nodes(),u=0;u<l.length;u++){var c=l[u];if(!c.same(n)){var d=o.distanceTo(c);s+=i?1/d:d}}return i?s:1/s}};Vn.cc=Vn.closenessCentrality,Vn.ccn=Vn.closenessCentralityNormalised=Vn.closenessCentralityNormalized;var Fn=ut({weight:null,directed:!1}),Xn={betweennessCentrality:function(e){for(var t=Fn(e),n=t.directed,r=t.weight,a=null!=r,i=this.cy(),o=this.nodes(),s={},l={},u=0,c=function(e,t){l[e]=t,t>u&&(u=t)},d=function(e){return l[e]},h=0;h<o.length;h++){var f=o[h],p=f.id();s[p]=n?f.outgoers().nodes():f.openNeighborhood().nodes(),c(p,0)}for(var v=function(){for(var e=o[g].id(),t=[],n={},l={},u={},h=new St((function(e,t){return u[e]-u[t]})),f=0;f<o.length;f++){var p=o[f].id();n[p]=[],l[p]=0,u[p]=1/0}for(l[e]=1,u[e]=0,h.push(e);!h.empty();){var v=h.pop();if(t.push(v),a)for(var y=0;y<s[v].length;y++){var m=s[v][y],b=i.getElementById(v),x=void 0;x=b.edgesTo(m).length>0?b.edgesTo(m)[0]:m.edgesTo(b)[0];var w=r(x);m=m.id(),u[m]>u[v]+w&&(u[m]=u[v]+w,h.nodes.indexOf(m)<0?h.push(m):h.updateItem(m),l[m]=0,n[m]=[]),u[m]==u[v]+w&&(l[m]=l[m]+l[v],n[m].push(v))}else for(var E=0;E<s[v].length;E++){var k=s[v][E].id();u[k]==1/0&&(h.push(k),u[k]=u[v]+1),u[k]==u[v]+1&&(l[k]=l[k]+l[v],n[k].push(v))}}for(var T={},C=0;C<o.length;C++)T[o[C].id()]=0;for(;t.length>0;){for(var P=t.pop(),S=0;S<n[P].length;S++){var B=n[P][S];T[B]=T[B]+l[B]/l[P]*(1+T[P])}P!=o[g].id()&&c(P,d(P)+T[P])}},g=0;g<o.length;g++)v();var y={betweenness:function(e){var t=i.collection(e).id();return d(t)},betweennessNormalized:function(e){if(0==u)return 0;var t=i.collection(e).id();return d(t)/u}};return y.betweennessNormalised=y.betweennessNormalized,y}};Xn.bc=Xn.betweennessCentrality;var jn=ut({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(e){return 1}]}),Yn=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r](e);return n},qn=function(e,t){for(var n,r=0;r<t;r++){n=0;for(var a=0;a<t;a++)n+=e[a*t+r];for(var i=0;i<t;i++)e[i*t+r]=e[i*t+r]/n}},Wn=function(e,t,n){for(var r=new Array(n*n),a=0;a<n;a++){for(var i=0;i<n;i++)r[a*n+i]=0;for(var o=0;o<n;o++)for(var s=0;s<n;s++)r[a*n+s]+=e[a*n+o]*t[o*n+s]}return r},Un=function(e,t,n){for(var r=e.slice(0),a=1;a<n;a++)e=Wn(e,r,t);return e},Hn=function(e,t,n){for(var r=new Array(t*t),a=0;a<t*t;a++)r[a]=Math.pow(e[a],n);return qn(r,t),r},Kn=function(e,t,n,r){for(var a=0;a<n;a++){if(Math.round(e[a]*Math.pow(10,r))/Math.pow(10,r)!==Math.round(t[a]*Math.pow(10,r))/Math.pow(10,r))return!1}return!0},Gn=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},Zn=function(e){for(var t=this.nodes(),n=this.edges(),r=this.cy(),a=function(e){return jn(e)}(e),i={},o=0;o<t.length;o++)i[t[o].id()]=o;for(var s,l=t.length,u=l*l,c=new Array(u),d=0;d<u;d++)c[d]=0;for(var h=0;h<n.length;h++){var f=n[h],p=i[f.source().id()],v=i[f.target().id()],g=Yn(f,a.attributes);c[p*l+v]+=g,c[v*l+p]+=g}!function(e,t,n){for(var r=0;r<t;r++)e[r*t+r]=n}(c,l,a.multFactor),qn(c,l);for(var y=!0,m=0;y&&m<a.maxIterations;)y=!1,s=Un(c,l,a.expandFactor),c=Hn(s,l,a.inflateFactor),Kn(c,s,u,4)||(y=!0),m++;var b=function(e,t,n,r){for(var a=[],i=0;i<t;i++){for(var o=[],s=0;s<t;s++)Math.round(1e3*e[i*t+s])/1e3>0&&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;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&Gn(e[t],e[n])&&e.splice(n,1);return e}(b),b},$n={markovClustering:Zn,mcl:Zn},Qn=function(e){return e},Jn=function(e,t){return Math.abs(t-e)},er=function(e,t,n){return e+Jn(t,n)},tr=function(e,t,n){return e+Math.pow(n-t,2)},nr=function(e){return Math.sqrt(e)},rr=function(e,t,n){return Math.max(e,Jn(t,n))},ar=function(e,t,n,r,a){for(var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:Qn,o=r,s=0;s<e;s++)o=a(o,t(s),n(s));return i(o)},ir={euclidean:function(e,t,n){return e>=2?ar(e,t,n,0,tr,nr):ar(e,t,n,0,er)},squaredEuclidean:function(e,t,n){return ar(e,t,n,0,tr)},manhattan:function(e,t,n){return ar(e,t,n,0,er)},max:function(e,t,n){return ar(e,t,n,-1/0,rr)}};function or(e,t,n,r,a,i){var o;return o=U(e)?e:ir[e]||ir.euclidean,0===t&&U(e)?o(a,i):o(t,n,r,a,i)}ir["squared-euclidean"]=ir.squaredEuclidean,ir.squaredeuclidean=ir.squaredEuclidean;var sr=ut({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),lr=function(e){return sr(e)},ur=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 or(e,r.length,i,(function(e){return r[e](t)}),o,s)},cr=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;l<r;l++)a[l]=e.min(n[l]).value,i[l]=e.max(n[l]).value;for(var u=0;u<t;u++){s=[];for(var c=0;c<r;c++)s[c]=Math.random()*(i[c]-a[c])+a[c];o[u]=s}return o},dr=function(e,t,n,r,a){for(var i=1/0,o=0,s=0;s<t.length;s++){var l=ur(n,e,t[s],r,a);l<i&&(i=l,o=s)}return o},hr=function(e,t,n){for(var r=[],a=null,i=0;i<t.length;i++)n[(a=t[i]).id()]===e&&r.push(a);return r},fr=function(e,t,n){return Math.abs(t-e)<=n},pr=function(e,t,n){for(var r=0;r<e.length;r++)for(var a=0;a<e[r].length;a++){if(Math.abs(e[r][a]-t[r][a])>n)return!1}return!0},vr=function(e,t,n){for(var r=0;r<n;r++)if(e===t[r])return!0;return!1},gr=function(e,t){var n=new Array(t);if(e.length<50)for(var r=0;r<t;r++){for(var a=e[Math.floor(Math.random()*e.length)];vr(a,n,r);)a=e[Math.floor(Math.random()*e.length)];n[r]=a}else for(var i=0;i<t;i++)n[i]=e[Math.floor(Math.random()*e.length)];return n},yr=function(e,t,n){for(var r=0,a=0;a<t.length;a++)r+=ur("manhattan",t[a],e,n,"kMedoids");return r},mr=function(e,t,n,r,a){for(var i,o,s=0;s<t.length;s++)for(var l=0;l<e.length;l++)r[s][l]=Math.pow(n[s][l],a.m);for(var u=0;u<e.length;u++)for(var c=0;c<a.attributes.length;c++){i=0,o=0;for(var d=0;d<t.length;d++)i+=r[d][u]*a.attributes[c](t[d]),o+=r[d][u];e[u][c]=i/o}},br=function(e,t,n,r,a){for(var i=0;i<e.length;i++)t[i]=e[i].slice();for(var o,s,l,u=2/(a.m-1),c=0;c<n.length;c++)for(var d=0;d<r.length;d++){o=0;for(var h=0;h<n.length;h++)s=ur(a.distance,r[d],n[c],a.attributes,"cmeans"),l=ur(a.distance,r[d],n[h],a.attributes,"cmeans"),o+=Math.pow(s/l,u);e[d][c]=1/o}},xr=function(e){var t,n,r,a,i,o=this.cy(),s=this.nodes(),l=lr(e);a=new Array(s.length);for(var u=0;u<s.length;u++)a[u]=new Array(l.k);r=new Array(s.length);for(var c=0;c<s.length;c++)r[c]=new Array(l.k);for(var d=0;d<s.length;d++){for(var h=0,f=0;f<l.k;f++)r[d][f]=Math.random(),h+=r[d][f];for(var p=0;p<l.k;p++)r[d][p]=r[d][p]/h}n=new Array(l.k);for(var v=0;v<l.k;v++)n[v]=new Array(l.attributes.length);i=new Array(s.length);for(var g=0;g<s.length;g++)i[g]=new Array(l.k);for(var y=!0,m=0;y&&m<l.maxIterations;)y=!1,mr(n,s,r,i,l),br(r,a,n,s,l),pr(r,a,l.sensitivityThreshold)||(y=!0),m++;return t=function(e,t,n,r){for(var a,i,o=new Array(n.k),s=0;s<o.length;s++)o[s]=[];for(var l=0;l<t.length;l++){a=-1/0,i=-1;for(var u=0;u<t[0].length;u++)t[l][u]>a&&(a=t[l][u],i=u);o[i].push(e[l])}for(var c=0;c<o.length;c++)o[c]=r.collection(o[c]);return o}(s,r,l,o),{clusters:t,degreeOfMembership:r}},wr={kMeans:function(e){var t,n=this.cy(),r=this.nodes(),a=null,i=lr(e),o=new Array(i.k),s={};i.testMode?"number"==typeof i.testCentroids?(i.testCentroids,t=cr(r,i.k,i.attributes)):t="object"===l(i.testCentroids)?i.testCentroids:cr(r,i.k,i.attributes):t=cr(r,i.k,i.attributes);for(var u=!0,c=0;u&&c<i.maxIterations;){for(var d=0;d<r.length;d++)s[(a=r[d]).id()]=dr(a,t,i.distance,i.attributes,"kMeans");u=!1;for(var h=0;h<i.k;h++){var f=hr(h,r,s);if(0!==f.length){for(var p=i.attributes.length,v=t[h],g=new Array(p),y=new Array(p),m=0;m<p;m++){y[m]=0;for(var b=0;b<f.length;b++)a=f[b],y[m]+=i.attributes[m](a);g[m]=y[m]/f.length,fr(g[m],v[m],i.sensitivityThreshold)||(u=!0)}t[h]=g,o[h]=n.collection(f)}}c++}return o},kMedoids:function(e){var t,n,r=this.cy(),a=this.nodes(),i=null,o=lr(e),s=new Array(o.k),u={},c=new Array(o.k);o.testMode?"number"==typeof o.testCentroids||(t="object"===l(o.testCentroids)?o.testCentroids:gr(a,o.k)):t=gr(a,o.k);for(var d=!0,h=0;d&&h<o.maxIterations;){for(var f=0;f<a.length;f++)u[(i=a[f]).id()]=dr(i,t,o.distance,o.attributes,"kMedoids");d=!1;for(var p=0;p<t.length;p++){var v=hr(p,a,u);if(0!==v.length){c[p]=yr(t[p],v,o.attributes);for(var g=0;g<v.length;g++)(n=yr(v[g],v,o.attributes))<c[p]&&(c[p]=n,t[p]=v[g],d=!0);s[p]=r.collection(v)}}h++}return s},fuzzyCMeans:xr,fcm:xr},Er=ut({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),kr={single:"min",complete:"max"},Tr=function(e,t,n,r,a){for(var i,o=0,s=1/0,l=a.attributes,u=function(e,t){return or(a.distance,l.length,(function(t){return l[t](e)}),(function(e){return l[e](t)}),e,t)},c=0;c<e.length;c++){var d=e[c].key,h=n[d][r[d]];h<s&&(o=d,s=h)}if("threshold"===a.mode&&s>=a.threshold||"dendrogram"===a.mode&&1===e.length)return!1;var f,p=t[o],v=t[r[o]];f="dendrogram"===a.mode?{left:p,right:v,key:p.key}:{value:p.value.concat(v.value),key:p.key},e[p.index]=f,e.splice(v.index,1),t[p.key]=f;for(var g=0;g<e.length;g++){var y=e[g];p.key===y.key?i=1/0:"min"===a.linkage?(i=n[p.key][y.key],n[p.key][y.key]>n[v.key][y.key]&&(i=n[v.key][y.key])):"max"===a.linkage?(i=n[p.key][y.key],n[p.key][y.key]<n[v.key][y.key]&&(i=n[v.key][y.key])):i="mean"===a.linkage?(n[p.key][y.key]*p.size+n[v.key][y.key]*v.size)/(p.size+v.size):"dendrogram"===a.mode?u(y.value,p.value):u(y.value[0],p.value[0]),n[p.key][y.key]=n[y.key][p.key]=i}for(var m=0;m<e.length;m++){var b=e[m].key;if(r[b]===p.key||r[b]===v.key){for(var x=b,w=0;w<e.length;w++){var E=e[w].key;n[b][E]<n[b][x]&&(x=E)}r[b]=x}e[m].index=m}return p.key=v.key=p.index=v.index=null,!0},Cr=function(e,t,n){e&&(e.value?t.push(e.value):(e.left&&Cr(e.left,t),e.right&&Cr(e.right,t)))},Pr=function(e,t){if(!e)return"";if(e.left&&e.right){var n=Pr(e.left,t),r=Pr(e.right,t),a=t.add({group:"nodes",data:{id:n+","+r}});return t.add({group:"edges",data:{source:n,target:a.id()}}),t.add({group:"edges",data:{source:r,target:a.id()}}),a.id()}return e.value?e.value.id():void 0},Sr=function(e,t,n){if(!e)return[];var r=[],a=[],i=[];return 0===t?(e.left&&Cr(e.left,r),e.right&&Cr(e.right,a),i=r.concat(a),[n.collection(i)]):1===t?e.value?[n.collection(e.value)]:(e.left&&Cr(e.left,r),e.right&&Cr(e.right,a),[n.collection(r),n.collection(a)]):e.value?[n.collection(e.value)]:(e.left&&(r=Sr(e.left,t-1,n)),e.right&&(a=Sr(e.right,t-1,n)),r.concat(a))},Br=function(e){for(var t=this.cy(),n=this.nodes(),r=function(e){var t=Er(e),n=kr[t.linkage];return null!=n&&(t.linkage=n),t}(e),a=r.attributes,i=function(e,t){return or(r.distance,a.length,(function(t){return a[t](e)}),(function(e){return a[e](t)}),e,t)},o=[],s=[],l=[],u=[],c=0;c<n.length;c++){var d={value:"dendrogram"===r.mode?n[c]:[n[c]],key:c,index:c};o[c]=d,u[c]=d,s[c]=[],l[c]=0}for(var h=0;h<o.length;h++)for(var f=0;f<=h;f++){var p=void 0;p="dendrogram"===r.mode?h===f?1/0:i(o[h].value,o[f].value):h===f?1/0:i(o[h].value[0],o[f].value[0]),s[h][f]=p,s[f][h]=p,p<s[h][l[h]]&&(l[h]=f)}for(var v,g=Tr(o,u,s,l,r);g;)g=Tr(o,u,s,l,r);return"dendrogram"===r.mode?(v=Sr(o[0],r.dendrogramDepth,t),r.addDendrogram&&Pr(o[0],t)):(v=new Array(o.length),o.forEach((function(e,n){e.key=e.index=null,v[n]=t.collection(e.value)}))),v},Dr={hierarchicalClustering:Br,hca:Br},_r=ut({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),Ar=function(e,t,n,r){var a=function(e,t){return r[t](e)};return-or(e,r.length,(function(e){return a(t,e)}),(function(e){return a(n,e)}),t,n)},Mr=function(e,t){var n=null;return n="median"===t?function(e){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=!(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]?(n<e.length&&e.splice(n,e.length-n),t>0&&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;i<n;i++){var o=e[i];isFinite(o)&&(r+=o,a++)}return r/a}(e):"min"===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=1/0,a=t;a<n;a++){var i=e[a];isFinite(i)&&(r=Math.min(i,r))}return r}(e):"max"===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=-1/0,a=t;a<n;a++){var i=e[a];isFinite(i)&&(r=Math.max(i,r))}return r}(e):t,n},Rr=function(e,t,n){for(var r=[],a=0;a<e;a++){for(var i=-1,o=-1/0,s=0;s<n.length;s++){var l=n[s];t[a*e+l]>o&&(i=l,o=t[a*e+l])}i>0&&r.push(i)}for(var u=0;u<n.length;u++)r[n[u]]=n[u];return r},Ir=function(e){for(var t,n,r,a,i,o,s=this.cy(),l=this.nodes(),u=function(e){var t=e.damping,n=e.preference;.5<=t&&t<1||nt("Damping must range on [0.5, 1).  Got: ".concat(t));var r=["median","mean","min","max"];return r.some((function(e){return e===n}))||G(n)||nt("Preference must be one of [".concat(r.map((function(e){return"'".concat(e,"'")})).join(", "),"] or a number.  Got: ").concat(n)),_r(e)}(e),c={},d=0;d<l.length;d++)c[l[d].id()]=d;n=(t=l.length)*t,r=new Array(n);for(var h=0;h<n;h++)r[h]=-1/0;for(var f=0;f<t;f++)for(var p=0;p<t;p++)f!==p&&(r[f*t+p]=Ar(u.distance,l[f],l[p],u.attributes));a=Mr(r,u.preference);for(var v=0;v<t;v++)r[v*t+v]=a;i=new Array(n);for(var g=0;g<n;g++)i[g]=0;o=new Array(n);for(var y=0;y<n;y++)o[y]=0;for(var m=new Array(t),b=new Array(t),x=new Array(t),w=0;w<t;w++)m[w]=0,b[w]=0,x[w]=0;for(var E,k=new Array(t*u.minIterations),T=0;T<k.length;T++)k[T]=0;for(E=0;E<u.maxIterations;E++){for(var C=0;C<t;C++){for(var P=-1/0,S=-1/0,B=-1,D=0,_=0;_<t;_++)m[_]=i[C*t+_],(D=o[C*t+_]+r[C*t+_])>=P?(S=P,P=D,B=_):D>S&&(S=D);for(var A=0;A<t;A++)i[C*t+A]=(1-u.damping)*(r[C*t+A]-P)+u.damping*m[A];i[C*t+B]=(1-u.damping)*(r[C*t+B]-S)+u.damping*m[B]}for(var M=0;M<t;M++){for(var R=0,I=0;I<t;I++)m[I]=o[I*t+M],b[I]=Math.max(0,i[I*t+M]),R+=b[I];R-=b[M],b[M]=i[M*t+M],R+=b[M];for(var N=0;N<t;N++)o[N*t+M]=(1-u.damping)*Math.min(0,R-b[N])+u.damping*m[N];o[M*t+M]=(1-u.damping)*(R-b[M])+u.damping*m[M]}for(var L=0,z=0;z<t;z++){var O=o[z*t+z]+i[z*t+z]>0?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;F<t;F++){x[F]=0;for(var X=0;X<u.minIterations;X++)x[F]+=k[X*t+F];0!==x[F]&&x[F]!==u.minIterations||V++}if(V===t)break}}for(var j=function(e,t,n){for(var r=[],a=0;a<e;a++)t[a*e+a]+n[a*e+a]>0&&r.push(a);return r}(t,i,o),Y=function(e,t,n){for(var r=Rr(e,t,n),a=0;a<n.length;a++){for(var i=[],o=0;o<r.length;o++)r[o]===n[a]&&i.push(o);for(var s=-1,l=-1/0,u=0;u<i.length;u++){for(var c=0,d=0;d<i.length;d++)c+=t[i[d]*e+i[u]];c>l&&(s=u,l=c)}n[a]=i[s]}return Rr(e,t,n)}(t,r,j),q={},W=0;W<j.length;W++)q[j[W]]=[];for(var U=0;U<l.length;U++){var H=Y[c[l[U].id()]];null!=H&&q[H].push(l[U])}for(var K=new Array(j.length),Z=0;Z<j.length;Z++)K[Z]=s.collection(q[j[Z]]);return K},Nr={affinityPropagation:Ir,ap:Ir},Lr=ut({root:void 0,directed:!1}),zr={hierholzer:function(e){if(!K(e)){var t=arguments;e={root:t[0],directed:t[1]}}var n,r,a,i=Lr(e),o=i.root,s=i.directed,l=this,u=!1;o&&(a=W(o)?this.filter(o)[0].id():o[0].id());var c={},d={};s?l.forEach((function(e){var t=e.id();if(e.isNode()){var a=e.indegree(!0),i=e.outdegree(!0),o=a-i,s=i-a;1==o?n?u=!0:n=t:1==s?r?u=!0:r=t:(s>1||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=[],v=[];for(v=f(a);1!=v.length;)0==c[v[0]].length?(p.unshift(l.getElementById(v.shift())),p.unshift(l.getElementById(v.shift()))):v=f(v.shift()).concat(v);for(var g in p.unshift(l.getElementById(v.shift())),c)if(c[g].length)return h;return h.found=!0,h.trail=this.spawn(p,!0),h}},Or=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,v=e.getElementById(u).connectedEdges().intersection(e);0===v.size()?a.push(e.spawn(e.getElementById(u))):v.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}},Vr=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}},Fr={};[bt,Dt,_t,Mt,It,Lt,Ft,Nn,zn,Vn,Xn,$n,wr,Dr,Nr,zr,{hopcroftTarjanBiconnected:Or,htbc:Or,htb:Or,hopcroftTarjanBiconnectedComponents:Or},{tarjanStronglyConnected:Vr,tsc:Vr,tscc:Vr,tarjanStronglyConnectedComponents:Vr}].forEach((function(e){ge(Fr,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 Xr=function(e){if(!(this instanceof Xr))return new Xr(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))};Xr.prototype={fulfill:function(e){return jr(this,1,"fulfillValue",e)},reject:function(e){return jr(this,2,"rejectReason",e)},then:function(e,t){var n=this,r=new Xr;return n.onFulfilled.push(Wr(e,r,"fulfill")),n.onRejected.push(Wr(t,r,"reject")),Yr(n),r.proxy}};var jr=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,Yr(e)),e},Yr=function(e){1===e.state?qr(e,"onFulfilled",e.fulfillValue):2===e.state&&qr(e,"onRejected",e.rejectReason)},qr=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var a=function(){for(var e=0;e<r.length;e++)r[e](n)};"function"==typeof setImmediate?setImmediate(a):setTimeout(a,0)}},Wr=function(e,t,n){return function(r){if("function"!=typeof e)t[n].call(t,r);else{var a;try{a=e(r)}catch(e){return void t.reject(e)}Ur(t,a)}}},Ur=function(e,t){if(e!==t&&e.proxy!==t){var n;if("object"===l(t)&&null!==t||"function"==typeof t)try{n=t.then}catch(t){return void e.reject(t)}if("function"!=typeof n)e.fulfill(t);else{var r=!1;try{n.call(t,(function(n){r||(r=!0,n===t?e.reject(new TypeError("circular thenable chain")):Ur(e,n))}),(function(t){r||(r=!0,e.reject(t))}))}catch(t){r||e.reject(t)}}}else e.reject(new TypeError("cannot resolve promise with itself"))};Xr.all=function(e){return new Xr((function(t,n){for(var r=new Array(e.length),a=0,i=function(n,i){r[n]=i,++a===e.length&&t(r)},o=0;o<e.length;o++)!function(t){var r=e[t];null!=r&&null!=r.then?r.then((function(e){i(t,e)}),(function(e){n(e)})):i(t,r)}(o)}))},Xr.resolve=function(e){return new Xr((function(t,n){t(e)}))},Xr.reject=function(e){return new Xr((function(t,n){n(e)}))};var Hr="undefined"!=typeof Promise?Promise:Xr,Kr=function(e,t,n){var r=ee(e),a=!r,i=this._private=ge({duration:1e3},t,n);if(i.target=e,i.style=i.style||i.css,i.started=!1,i.playing=!1,i.hooked=!1,i.applying=!1,i.progress=0,i.completes=[],i.frames=[],i.complete&&U(i.complete)&&i.completes.push(i.complete),a){var o=e.position();i.startPosition=i.startPosition||{x:o.x,y:o.y},i.startStyle=i.startStyle||e.cy().style().getAnimationStartStyle(e,i.style)}if(r){var s=e.pan();i.startPan={x:s.x,y:s.y},i.startZoom=e.zoom()}this.length=1,this[0]=this},Gr=Kr.prototype;ge(Gr,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var t=e.target._private.animation;(e.queue?t.queue:t.current).push(this),$(e.target)&&e.target.cy().addToAnimationPool(e.target),e.hooked=!0}return this},play:function(){var e=this._private;return 1===e.progress&&(e.progress=0),e.playing=!0,e.started=!1,e.stopped=!1,this.hook(),this},playing:function(){return this._private.playing},apply:function(){var e=this._private;return e.applying=!0,e.started=!1,e.stopped=!1,this.hook(),this},applying:function(){return this._private.applying},pause:function(){var e=this._private;return e.playing=!1,e.started=!1,this},stop:function(){var e=this._private;return e.playing=!1,e.started=!1,e.stopped=!0,this},rewind:function(){return this.progress(0)},fastforward:function(){return this.progress(1)},time:function(e){var t=this._private;return void 0===e?t.progress*t.duration:this.progress(e/t.duration)},progress:function(e){var t=this._private,n=t.playing;return void 0===e?t.progress:(n&&this.pause(),t.progress=e,t.started=!1,n&&this.play(),this)},completed:function(){return 1===this._private.progress},reverse:function(){var e=this._private,t=e.playing;t&&this.pause(),e.progress=1-e.progress,e.started=!1;var n=function(t,n){var r=e[t];null!=r&&(e[t]=e[n],e[n]=r)};if(n("zoom","startZoom"),n("pan","startPan"),n("position","startPosition"),e.style)for(var r=0;r<e.style.length;r++){var a=e.style[r],i=a.name,o=e.startStyle[i];e.startStyle[i]=a,e.style[r]=o}return t&&this.play(),this},promise:function(e){var t,n=this._private;if("frame"===e)t=n.frames;else t=n.completes;return new Hr((function(e,n){t.push((function(){e()}))}))}}),Gr.complete=Gr.completed,Gr.run=Gr.play,Gr.running=Gr.playing;var Zr,$r,Qr,Jr,ea,ta,na,ra,aa,ia,oa,sa,la,ua,ca,da,ha,fa,pa,va,ga,ya,ma,ba,xa,wa,Ea,ka,Ta,Ca,Pa,Sa,Ba,Da,_a,Aa,Ma,Ra,Ia,Na,La,za,Oa,Va,Fa,Xa,ja,Ya,qa,Wa,Ua,Ha,Ka,Ga,Za,$a,Qa,Ja,ei,ti,ni,ri,ai,ii,oi,si,li,ui,ci,di,hi,fi,pi,vi,gi,yi,mi,bi,xi,wi,Ei,ki,Ti,Ci,Pi,Si,Bi={animated:function(){return function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return!1;var n=t[0];return n?n._private.animation.current.length>0: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<t.length;n++){t[n]._private.animation.queue=[]}return this}},delay:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animate({delay:e,duration:e,complete:t}):this}},delayAnimation:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animation({delay:e,duration:e,complete:t}):this}},animation:function(){return function(e,t){var n=this,r=void 0!==n.length,a=r?n:[n],i=this._private.cy||this,o=!r,s=!o;if(!i.styleEnabled())return this;var l=i.style();if(e=ge({},e,t),0===Object.keys(e).length)return new Kr(a[0],e);switch(void 0===e.duration&&(e.duration=400),e.duration){case"slow":e.duration=600;break;case"fast":e.duration=200}if(s&&(e.style=l.getPropsList(e.style||e.css),e.css=void 0),s&&null!=e.renderedPosition){var u=e.renderedPosition,c=i.pan(),d=i.zoom();e.position=jt(u,d,c)}if(o&&null!=e.panBy){var h=e.panBy,f=i.pan();e.pan={x:f.x+h.x,y:f.y+h.y}}var p=e.center||e.centre;if(o&&null!=p){var v=i.getCenterPan(p.eles,e.zoom);null!=v&&(e.pan=v)}if(o&&null!=e.fit){var g=e.fit,y=i.getFitViewport(g.eles||g.boundingBox,g.padding);null!=y&&(e.pan=y.pan,e.zoom=y.zoom)}if(o&&K(e.zoom)){var m=i.getZoomedViewport(e.zoom);null!=m?(m.zoomed&&(e.zoom=m.zoom),m.panned&&(e.pan=m.pan)):e.zoom=null}return new Kr(a[0],e)}},animate:function(){return function(e,t){var n=this,r=void 0!==n.length?n:[n];if(!(this._private.cy||this).styleEnabled())return this;t&&(e=ge({},e,t));for(var a=0;a<r.length;a++){var i=r[a],o=i.animated()&&(void 0===e.queue||e.queue);i.animation(e,o?{queue:!0}:void 0).play()}return this}},stop:function(){return function(e,t){var n=this,r=void 0!==n.length?n:[n],a=this._private.cy||this;if(!a.styleEnabled())return this;for(var i=0;i<r.length;i++){for(var o=r[i]._private,s=o.animation.current,l=0;l<s.length;l++){var u=s[l]._private;t&&(u.duration=0)}e&&(o.animation.queue=[]),t||(o.animation.current=[])}return a.notify("draw"),this}}};function Di(){if($r)return Zr;$r=1;var e=Array.isArray;return Zr=e}function _i(){if(ia)return aa;ia=1;var e,t=function(){if(ra)return na;ra=1;var e=Te()["__core-js_shared__"];return na=e}(),n=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return aa=function(e){return!!n&&n in e}}function Ai(){if(ua)return la;ua=1;var e=function(){if(ta)return ea;ta=1;var e=Se(),t=ke();return ea=function(n){if(!t(n))return!1;var r=e(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}(),t=_i(),n=ke(),r=function(){if(sa)return oa;sa=1;var e=Function.prototype.toString;return oa=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),a=/^\[object .+?Constructor\]$/,i=Function.prototype,o=Object.prototype,s=i.toString,l=o.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return la=function(i){return!(!n(i)||t(i))&&(e(i)?u:a).test(r(i))}}function Mi(){if(fa)return ha;fa=1;var e=Ai(),t=(da||(da=1,ca=function(e,t){return null==e?void 0:e[t]}),ca);return ha=function(n,r){var a=t(n,r);return e(a)?a:void 0},ha}function Ri(){if(va)return pa;va=1;var e=Mi()(Object,"create");return pa=e}function Ii(){if(Sa)return Pa;Sa=1;var e=function(){if(ya)return ga;ya=1;var e=Ri();return ga=function(){this.__data__=e?e(null):{},this.size=0}}(),t=ba?ma:(ba=1,ma=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}),n=function(){if(wa)return xa;wa=1;var e=Ri(),t=Object.prototype.hasOwnProperty;return xa=function(n){var r=this.__data__;if(e){var a=r[n];return"__lodash_hash_undefined__"===a?void 0:a}return t.call(r,n)?r[n]:void 0},xa}(),r=function(){if(ka)return Ea;ka=1;var e=Ri(),t=Object.prototype.hasOwnProperty;return Ea=function(n){var r=this.__data__;return e?void 0!==r[n]:t.call(r,n)},Ea}(),a=function(){if(Ca)return Ta;Ca=1;var e=Ri();return Ta=function(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=e&&void 0===n?"__lodash_hash_undefined__":n,this},Ta}();function i(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,Pa=i}function Ni(){if(Aa)return _a;return Aa=1,_a=function(e,t){return e===t||e!=e&&t!=t}}function Li(){if(Ra)return Ma;Ra=1;var e=Ni();return Ma=function(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1},Ma}function zi(){if(Ya)return ja;Ya=1;var e=Da?Ba:(Da=1,Ba=function(){this.__data__=[],this.size=0}),t=function(){if(Na)return Ia;Na=1;var e=Li(),t=Array.prototype.splice;return Ia=function(n){var r=this.__data__,a=e(r,n);return!(a<0||(a==r.length-1?r.pop():t.call(r,a,1),--this.size,0))},Ia}(),n=function(){if(za)return La;za=1;var e=Li();return La=function(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]},La}(),r=function(){if(Va)return Oa;Va=1;var e=Li();return Oa=function(t){return e(this.__data__,t)>-1}}(),a=function(){if(Xa)return Fa;Xa=1;var e=Li();return Fa=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},Fa}();function i(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,ja=i}function Oi(){if(Ha)return Ua;Ha=1;var e=Ii(),t=zi(),n=function(){if(Wa)return qa;Wa=1;var e=Mi()(Te(),"Map");return qa=e}();return Ua=function(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}}function Vi(){if($a)return Za;$a=1;var e=Ga?Ka:(Ga=1,Ka=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return Za=function(t,n){var r=t.__data__;return e(n)?r["string"==typeof n?"string":"hash"]:r.map},Za}function Fi(){if(si)return oi;si=1;var e=Oi(),t=function(){if(Ja)return Qa;Ja=1;var e=Vi();return Qa=function(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}}(),n=function(){if(ti)return ei;ti=1;var e=Vi();return ei=function(t){return e(this,t).get(t)}}(),r=function(){if(ri)return ni;ri=1;var e=Vi();return ni=function(t){return e(this,t).has(t)}}(),a=function(){if(ii)return ai;ii=1;var e=Vi();return ai=function(t,n){var r=e(this,t),a=r.size;return r.set(t,n),this.size+=r.size==a?0:1,this},ai}();function i(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=a,oi=i}function Xi(){if(di)return ci;di=1;var e=function(){if(ui)return li;ui=1;var e=Fi();function t(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var a=function(){var e=arguments,t=r?r.apply(this,e):e[0],i=a.cache;if(i.has(t))return i.get(t);var o=n.apply(this,e);return a.cache=i.set(t,o)||i,o};return a.cache=new(t.Cache||e),a}return t.Cache=e,li=t}();return ci=function(t){var n=e(t,(function(e){return 500===r.size&&r.clear(),e})),r=n.cache;return n},ci}function ji(){if(fi)return hi;fi=1;var e=Xi(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e((function(e){var r=[];return 46===e.charCodeAt(0)&&r.push(""),e.replace(t,(function(e,t,a,i){r.push(a?i.replace(n,"$1"):t||e)})),r}));return hi=r}function Yi(){if(vi)return pi;return vi=1,pi=function(e,t){for(var n=-1,r=null==e?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a},pi}function qi(){if(bi)return mi;bi=1;var e=function(){if(yi)return gi;yi=1;var e=Pe(),t=Yi(),n=Di(),r=Be(),a=e?e.prototype:void 0,i=a?a.toString:void 0;return gi=function e(a){if("string"==typeof a)return a;if(n(a))return t(a,e)+"";if(r(a))return i?i.call(a):"";var o=a+"";return"0"==o&&1/a==-1/0?"-0":o},gi}();return mi=function(t){return null==t?"":e(t)}}function Wi(){if(wi)return xi;wi=1;var e=Di(),t=function(){if(Jr)return Qr;Jr=1;var e=Di(),t=Be(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return Qr=function(a,i){if(e(a))return!1;var o=typeof a;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=a&&!t(a))||r.test(a)||!n.test(a)||null!=i&&a in Object(i)},Qr}(),n=ji(),r=qi();return xi=function(a,i){return e(a)?a:t(a,i)?[a]:n(r(a))},xi}function Ui(){if(ki)return Ei;ki=1;var e=Be();return Ei=function(t){if("string"==typeof t||e(t))return t;var n=t+"";return"0"==n&&1/t==-1/0?"-0":n}}var Hi,Ki,Gi,Zi,$i,Qi,Ji,eo,to,no,ro,ao,io=function(){if(Si)return Pi;Si=1;var e=function(){if(Ci)return Ti;Ci=1;var e=Wi(),t=Ui();return Ti=function(n,r){for(var a=0,i=(r=e(r,n)).length;null!=n&&a<i;)n=n[t(r[a++])];return a&&a==i?n:void 0},Ti}();return Pi=function(t,n,r){var a=null==t?void 0:e(t,n);return void 0===a?r:a},Pi}(),oo=Ee(io);function so(){if(Zi)return Gi;Zi=1;var e=function(){if(Ki)return Hi;Ki=1;var e=Mi(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Hi=t}();return Gi=function(t,n,r){"__proto__"==n&&e?e(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r},Gi}function lo(){if(no)return to;no=1;var e=function(){if(Qi)return $i;Qi=1;var e=so(),t=Ni(),n=Object.prototype.hasOwnProperty;return $i=function(r,a,i){var o=r[a];n.call(r,a)&&t(o,i)&&(void 0!==i||a in r)||e(r,a,i)},$i}(),t=Wi(),n=function(){if(eo)return Ji;eo=1;var e=/^(?:0|[1-9]\d*)$/;return Ji=function(t,n){var r=typeof t;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&e.test(t))&&t>-1&&t%1==0&&t<n}}(),r=ke(),a=Ui();return to=function(i,o,s,l){if(!r(i))return i;for(var u=-1,c=(o=t(o,i)).length,d=c-1,h=i;null!=h&&++u<c;){var f=a(o[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=d){var v=h[f];void 0===(p=l?l(v,f,h):void 0)&&(p=r(v)?v:n(o[u+1])?[]:{})}e(h,f,p),h=h[f]}return i},to}var uo,co,ho,fo,po=function(){if(ao)return ro;ao=1;var e=lo();return ro=function(t,n,r){return null==t?t:e(t,n,r)},ro}(),vo=Ee(po);var go=function(){if(fo)return ho;fo=1;var e=Yi(),t=(co||(co=1,uo=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}),uo),n=Di(),r=Be(),a=ji(),i=Ui(),o=qi();return ho=function(s){return n(s)?e(s,i):r(s)?[s]:t(a(o(s)))}}(),yo=Ee(go),mo={data:function(e){return e=ge({},{field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,beforeGet:function(e){},beforeSet:function(e,t){},onSet:function(e){},canSet:function(e){return!0}},e),function(t,n){var r=e,i=this,o=void 0!==i.length,s=o?i:[i],l=o?i[0]:i;if(W(t)){var u,c=-1!==t.indexOf(".")&&yo(t);if(r.allowGetting&&void 0===n)return l&&(r.beforeGet(l),u=c&&void 0===l._private[r.field][t]?oo(l._private[r.field],c):l._private[r.field][t]),u;if(r.allowSetting&&void 0!==n&&!r.immutableKeys[t]){var d=a({},t,n);r.beforeSet(i,d);for(var h=0,f=s.length;h<f;h++){var p=s[h];r.canSet(p)&&(c&&void 0===l._private[r.field][t]?vo(p._private[r.field],c,n):p._private[r.field][t]=n)}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}}else if(r.allowSetting&&K(t)){var v,g,y=t,m=Object.keys(y);r.beforeSet(i,y);for(var b=0;b<m.length;b++){if(g=y[v=m[b]],!r.immutableKeys[v])for(var x=0;x<s.length;x++){var w=s[x];r.canSet(w)&&(w._private[r.field][v]=g)}}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}else if(r.allowBinding&&U(t)){var E=t;i.on(r.bindingEvent,E)}else if(r.allowGetting&&void 0===t){var k;return l&&(r.beforeGet(l),k=l._private[r.field]),k}return i}},removeData:function(e){return e=ge({},{field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}},e),function(t){var n=e,r=this,a=void 0!==r.length?r:[r];if(W(t)){for(var i=t.split(/\s+/),o=i.length,s=0;s<o;s++){var l=i[s];if(!ne(l))if(!n.immutableKeys[l])for(var u=0,c=a.length;u<c;u++)a[u]._private[n.field][l]=void 0}n.triggerEvent&&r[n.triggerFnName](n.event)}else if(void 0===t){for(var d=0,h=a.length;d<h;d++)for(var f=a[d]._private[n.field],p=Object.keys(f),v=0;v<p.length;v++){var g=p[v];!n.immutableKeys[g]&&(f[g]=void 0)}n.triggerEvent&&r[n.triggerFnName](n.event)}return r}}},bo={eventAliasesOn:function(e){var t=e;t.addListener=t.listen=t.bind=t.on,t.unlisten=t.unbind=t.off=t.removeListener,t.trigger=t.emit,t.pon=t.promiseOn=function(e,t){var n=this,r=Array.prototype.slice.call(arguments,0);return new Hr((function(e,t){var a=r.concat([function(t){n.off.apply(n,i),e(t)}]),i=a.concat([]);n.on.apply(n,a)}))}}},xo={};[Bi,mo,bo].forEach((function(e){ge(xo,e)}));var wo={animate:xo.animate(),animation:xo.animation(),animated:xo.animated(),clearQueue:xo.clearQueue(),delay:xo.delay(),delayAnimation:xo.delayAnimation(),stop:xo.stop()},Eo={classes:function(e){var t=this;if(void 0===e){var n=[];return t[0]._private.classes.forEach((function(e){return n.push(e)})),n}H(e)||(e=(e||"").match(/\S+/g)||[]);for(var r=[],a=new gt(e),i=0;i<t.length;i++){for(var o=t[i],s=o._private,l=s.classes,u=!1,c=0;c<e.length;c++){var d=e[c];if(!l.has(d)){u=!0;break}}u||(u=l.size!==e.length),u&&(s.classes=a,r.push(o))}return r.length>0&&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;i<o;i++)for(var s=n[i],l=s._private.classes,u=!1,c=0;c<e.length;c++){var d=e[c],h=l.has(d),f=!1;t||r&&!h?(l.add(d),f=!0):(!t||r&&h)&&(l.delete(d),f=!0),!u&&f&&(a.push(s),u=!0)}return a.length>0&&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}};Eo.className=Eo.classNames=Eo.classes;var ko={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:ce,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};ko.variable="(?:[\\w-.]|(?:\\\\"+ko.metaChar+"))+",ko.className="(?:[\\w-]|(?:\\\\"+ko.metaChar+"))+",ko.value=ko.string+"|"+ko.number,ko.id=ko.variable,function(){var e,t,n;for(e=ko.comparatorOp.split("|"),n=0;n<e.length;n++)t=e[n],ko.comparatorOp+="|@"+t;for(e=ko.comparatorOp.split("|"),n=0;n<e.length;n++)(t=e[n]).indexOf("!")>=0||"="!==t&&(ko.comparatorOp+="|\\!"+t)}();var To=0,Co=1,Po=2,So=3,Bo=4,Do=5,_o=6,Ao=7,Mo=8,Ro=9,Io=10,No=11,Lo=12,zo=13,Oo=14,Vo=15,Fo=16,Xo=17,jo=18,Yo=19,qo=20,Wo=[{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)})),Uo=function(){for(var e,t={},n=0;n<Wo.length;n++)t[(e=Wo[n]).selector]=e.matches;return t}(),Ho="("+Wo.map((function(e){return e.selector})).join("|")+")",Ko=function(e){return e.replace(new RegExp("\\\\("+ko.metaChar+")","g"),(function(e,t){return t}))},Go=function(e,t,n){e[e.length-1]=n},Zo=[{name:"group",query:!0,regex:"("+ko.group+")",populate:function(e,t,n){var r=i(n,1)[0];t.checks.push({type:To,value:"*"===r?r:r+"s"})}},{name:"state",query:!0,regex:Ho,populate:function(e,t,n){var r=i(n,1)[0];t.checks.push({type:Ao,value:r})}},{name:"id",query:!0,regex:"\\#("+ko.id+")",populate:function(e,t,n){var r=i(n,1)[0];t.checks.push({type:Mo,value:Ko(r)})}},{name:"className",query:!0,regex:"\\.("+ko.className+")",populate:function(e,t,n){var r=i(n,1)[0];t.checks.push({type:Ro,value:Ko(r)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+ko.variable+")\\s*\\]",populate:function(e,t,n){var r=i(n,1)[0];t.checks.push({type:Bo,field:Ko(r)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+ko.variable+")\\s*("+ko.comparatorOp+")\\s*("+ko.value+")\\s*\\]",populate:function(e,t,n){var r=i(n,3),a=r[0],o=r[1],s=r[2];s=null!=new RegExp("^"+ko.string+"$").exec(s)?s.substring(1,s.length-1):parseFloat(s),t.checks.push({type:So,field:Ko(a),operator:o,value:s})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+ko.boolOp+")\\s*("+ko.variable+")\\s*\\]",populate:function(e,t,n){var r=i(n,2),a=r[0],o=r[1];t.checks.push({type:Do,field:Ko(o),operator:a})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+ko.meta+")\\s*("+ko.comparatorOp+")\\s*("+ko.number+")\\s*\\]\\]",populate:function(e,t,n){var r=i(n,3),a=r[0],o=r[1],s=r[2];t.checks.push({type:_o,field:Ko(a),operator:o,value:parseFloat(s)})}},{name:"nextQuery",separator:!0,regex:ko.separator,populate:function(e,t){var n=e.currentSubject,r=e.edgeCount,a=e.compoundCount,i=e[e.length-1];return null!=n&&(i.subject=n,e.currentSubject=null),i.edgeCount=r,i.compoundCount=a,e.edgeCount=0,e.compoundCount=0,e[e.length++]={checks:[]}}},{name:"directedEdge",separator:!0,regex:ko.directedEdge,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r=t,a={checks:[]};return n.checks.push({type:No,source:r,target:a}),Go(e,0,n),e.edgeCount++,a}var i={checks:[]},o=t,s={checks:[]};return i.checks.push({type:Lo,source:o,target:s}),Go(e,0,i),e.edgeCount++,s}},{name:"undirectedEdge",separator:!0,regex:ko.undirectedEdge,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r=t,a={checks:[]};return n.checks.push({type:Io,nodes:[r,a]}),Go(e,0,n),e.edgeCount++,a}var i={checks:[]},o=t,s={checks:[]};return i.checks.push({type:Oo,node:o,neighbor:s}),Go(e,0,i),s}},{name:"child",separator:!0,regex:ko.child,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r={checks:[]},a=e[e.length-1];return n.checks.push({type:Vo,parent:a,child:r}),Go(e,0,n),e.compoundCount++,r}if(e.currentSubject===t){var i={checks:[]},o=e[e.length-1],s={checks:[]},l={checks:[]},u={checks:[]},c={checks:[]};return i.checks.push({type:Yo,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:qo}],c.checks.push({type:qo}),s.checks.push({type:Xo,parent:c,child:u}),Go(e,0,i),e.currentSubject=l,e.compoundCount++,u}var d={checks:[]},h={checks:[]},f=[{type:Xo,parent:d,child:h}];return d.checks=t.checks,t.checks=f,e.compoundCount++,h}},{name:"descendant",separator:!0,regex:ko.descendant,populate:function(e,t){if(null==e.currentSubject){var n={checks:[]},r={checks:[]},a=e[e.length-1];return n.checks.push({type:Fo,ancestor:a,descendant:r}),Go(e,0,n),e.compoundCount++,r}if(e.currentSubject===t){var i={checks:[]},o=e[e.length-1],s={checks:[]},l={checks:[]},u={checks:[]},c={checks:[]};return i.checks.push({type:Yo,left:o,right:s,subject:l}),l.checks=t.checks,t.checks=[{type:qo}],c.checks.push({type:qo}),s.checks.push({type:jo,ancestor:c,descendant:u}),Go(e,0,i),e.currentSubject=l,e.compoundCount++,u}var d={checks:[]},h={checks:[]},f=[{type:jo,ancestor:d,descendant:h}];return d.checks=t.checks,t.checks=f,e.compoundCount++,h}},{name:"subject",modifier:!0,regex:ko.subject,populate:function(e,t){if(null!=e.currentSubject&&e.currentSubject!==t)return at("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var n=e[e.length-1].checks[0],r=null==n?null:n.type;r===No?n.type=zo:r===Io&&(n.type=Oo,n.node=n.nodes[1],n.neighbor=n.nodes[0],n.nodes=null)}}];Zo.forEach((function(e){return e.regexObj=new RegExp("^"+e.regex)}));var $o=function(e){for(var t,n,r,a=0;a<Zo.length;a++){var i=Zo[a],o=i.name,s=e.match(i.regexObj);if(null!=s){n=s,t=i,r=o;var l=s[0];e=e.substring(l.length);break}}return{expr:t,match:n,name:r,remaining:e}},Qo={parse:function(e){var t=this,n=t.inputText=e,r=t[0]={checks:[]};for(t.length=1,n=function(e){var t=e.match(/^\s+/);if(t){var n=t[0];e=e.substring(n.length)}return e}(n);;){var a=$o(n);if(null==a.expr)return at("The selector `"+e+"`is invalid"),!1;var i=a.match.slice(1),o=a.expr.populate(t,r,i);if(!1===o)return!1;if(null!=o&&(r=o),(n=a.remaining).match(/^\s*$/))break}var s=t[t.length-1];null!=t.currentSubject&&(s.subject=t.currentSubject),s.edgeCount=t.edgeCount,s.compoundCount=t.compoundCount;for(var l=0;l<t.length;l++){var u=t[l];if(u.compoundCount>0&&u.edgeCount>0)return at("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(u.edgeCount>1)return at("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===u.edgeCount&&at("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 To:var l=e(s);return l.substring(0,l.length-1);case So:var u=r.field,c=r.operator;return"["+u+n(e(c))+t(s)+"]";case Do:var d=r.operator,h=r.field;return"["+e(d)+h+"]";case Bo:return"["+r.field+"]";case _o:var f=r.operator;return"[["+r.field+n(e(f))+t(s)+"]]";case Ao:return s;case Mo:return"#"+s;case Ro:return"."+s;case Xo:case Vo:return a(r.parent,i)+n(">")+a(r.child,i);case jo:case Fo:return a(r.ancestor,i)+" "+a(r.descendant,i);case Yo:var p=a(r.left,i),v=a(r.subject,i),g=a(r.right,i);return p+(p.length>0?" ":"")+v+g;case qo: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;o<this.length;o++){var s=this[o];i+=a(s,s.subject),this.length>1&&o<this.length-1&&(i+=", ")}return this.toStringCache=i,i}},Jo=function(e,t,n){var r,a,i,o=W(e),s=G(e),l=W(n),u=!1,c=!1,d=!1;switch(t.indexOf("!")>=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=e<n;break;case"<=":d=!0,r=e<=n;break;default:r=!1}return!c||null==e&&d||(r=!r),r},es=function(e,t){return e.data(t)},ts=[],ns=function(e,t){return e.checks.every((function(e){return ts[e.type](e,t)}))};ts[To]=function(e,t){var n=e.value;return"*"===n||n===t.group()},ts[Ao]=function(e,t){return function(e,t){return Uo[e](t)}(e.value,t)},ts[Mo]=function(e,t){var n=e.value;return t.id()===n},ts[Ro]=function(e,t){var n=e.value;return t.hasClass(n)},ts[_o]=function(e,t){var n=e.field,r=e.operator,a=e.value;return Jo(function(e,t){return e[t]()}(t,n),r,a)},ts[So]=function(e,t){var n=e.field,r=e.operator,a=e.value;return Jo(es(t,n),r,a)},ts[Do]=function(e,t){var n=e.field,r=e.operator;return function(e,t){switch(t){case"?":return!!e;case"!":return!e;case"^":return void 0===e}}(es(t,n),r)},ts[Bo]=function(e,t){var n=e.field;return e.operator,void 0!==es(t,n)},ts[Io]=function(e,t){var n=e.nodes[0],r=e.nodes[1],a=t.source(),i=t.target();return ns(n,a)&&ns(r,i)||ns(r,a)&&ns(n,i)},ts[Oo]=function(e,t){return ns(e.node,t)&&t.neighborhood().some((function(t){return t.isNode()&&ns(e.neighbor,t)}))},ts[No]=function(e,t){return ns(e.source,t.source())&&ns(e.target,t.target())},ts[Lo]=function(e,t){return ns(e.source,t)&&t.outgoers().some((function(t){return t.isNode()&&ns(e.target,t)}))},ts[zo]=function(e,t){return ns(e.target,t)&&t.incomers().some((function(t){return t.isNode()&&ns(e.source,t)}))},ts[Vo]=function(e,t){return ns(e.child,t)&&ns(e.parent,t.parent())},ts[Xo]=function(e,t){return ns(e.parent,t)&&t.children().some((function(t){return ns(e.child,t)}))},ts[Fo]=function(e,t){return ns(e.descendant,t)&&t.ancestors().some((function(t){return ns(e.ancestor,t)}))},ts[jo]=function(e,t){return ns(e.ancestor,t)&&t.descendants().some((function(t){return ns(e.descendant,t)}))},ts[Yo]=function(e,t){return ns(e.subject,t)&&ns(e.left,t)&&ns(e.right,t)},ts[qo]=function(){return!0},ts[Co]=function(e,t){return e.value.has(t)},ts[Po]=function(e,t){return(0,e.value)(t)};var rs={matches:function(e){for(var t=0;t<this.length;t++){var n=this[t];if(ns(n,e))return!0}return!1},filter:function(e){var t=this;if(1===t.length&&1===t[0].checks.length&&t[0].checks[0].type===Mo)return e.getElementById(t[0].checks[0].value).collection();var n=function(e){for(var n=0;n<t.length;n++){var r=t[n];if(ns(r,e))return!0}return!1};return null==t.text()&&(n=function(){return!0}),e.filter(n)}},as=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,null==e||W(e)&&e.match(/^\s*$/)||($(e)?this.addQuery({checks:[{type:Co,value:e.collection()}]}):U(e)?this.addQuery({checks:[{type:Po,value:e}]}):W(e)?this.parse(e)||(this.invalid=!0):nt("A selector must be created from a string; found "))},is=as.prototype;[Qo,rs].forEach((function(e){return ge(is,e)})),is.text=function(){return this.inputText},is.size=function(){return this.length},is.eq=function(e){return this[e]},is.sameText=function(e){return!this.invalid&&!e.invalid&&this.text()===e.text()},is.addQuery=function(e){this[this.length++]=e},is.selector=is.toString;var os={allAre:function(e){var t=new as(e);return this.every((function(e){return t.matches(e)}))},is:function(e){var t=new as(e);return this.some((function(e){return t.matches(e)}))},some:function(e,t){for(var n=0;n<this.length;n++){if(t?e.apply(t,[this[n],n,this]):e(this[n],n,this))return!0}return!1},every:function(e,t){for(var n=0;n<this.length;n++){if(!(t?e.apply(t,[this[n],n,this]):e(this[n],n,this)))return!1}return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var t=this.length;return t===e.length&&(1===t?this[0]===e[0]:this.every((function(t){return e.hasElementWithId(t.id())})))},anySame:function(e){return e=this.cy().collection(e),this.some((function(t){return e.hasElementWithId(t.id())}))},allAreNeighbors:function(e){e=this.cy().collection(e);var t=this.neighborhood();return e.every((function(e){return t.hasElementWithId(e.id())}))},contains:function(e){e=this.cy().collection(e);var t=this;return e.every((function(e){return t.hasElementWithId(e.id())}))}};os.allAreNeighbours=os.allAreNeighbors,os.has=os.contains,os.equal=os.equals=os.same;var ss,ls,us=function(e,t){return function(n,r,a,i){var o,s=n,l=this;if(null==s?o="":$(s)&&1===s.length&&(o=s.id()),1===l.length&&o){var u=l[0]._private,c=u.traversalCache=u.traversalCache||{},d=c[t]=c[t]||[],h=qe(o),f=d[h];return f||(d[h]=e.call(l,n,r,a,i))}return e.call(l,n,r,a,i)}},cs={parent:function(e){var t=[];if(1===this.length){var n=this[0]._private.parent;if(n)return n}for(var r=0;r<this.length;r++){var a=this[r]._private.parent;a&&t.push(a)}return this.spawn(t,!0).filter(e)},parents:function(e){for(var t=[],n=this.parent();n.nonempty();){for(var r=0;r<n.length;r++){var a=n[r];t.push(a)}n=n.parent()}return this.spawn(t,!0).filter(e)},commonAncestors:function(e){for(var t,n=0;n<this.length;n++){var r=this[n].parents();t=(t=t||r).intersect(r)}return t.filter(e)},orphans:function(e){return this.stdFilter((function(e){return e.isOrphan()})).filter(e)},nonorphans:function(e){return this.stdFilter((function(e){return e.isChild()})).filter(e)},children:us((function(e){for(var t=[],n=0;n<this.length;n++)for(var r=this[n]._private.children,a=0;a<r.length;a++)t.push(r[a]);return this.spawn(t,!0).filter(e)}),"children"),siblings:function(e){return this.parent().children().not(this).filter(e)},isParent:function(){var e=this[0];if(e)return e.isNode()&&0!==e._private.children.length},isChildless:function(){var e=this[0];if(e)return e.isNode()&&0===e._private.children.length},isChild:function(){var e=this[0];if(e)return e.isNode()&&null!=e._private.parent},isOrphan:function(){var e=this[0];if(e)return e.isNode()&&null==e._private.parent},descendants:function(e){var t=[];return function e(n){for(var r=0;r<n.length;r++){var a=n[r];t.push(a),a.children().nonempty()&&e(a.children())}}(this.children()),this.spawn(t,!0).filter(e)}};function ds(e,t,n,r){for(var a=[],i=new gt,o=e.cy().hasCompoundNodes(),s=0;s<e.length;s++){var l=e[s];n?a.push(l):o&&r(a,i,l)}for(;a.length>0;){var u=a.shift();t(u),i.add(u.id()),o&&r(a,i,u)}return e}function hs(e,t,n){if(n.isParent())for(var r=n._private.children,a=0;a<r.length;a++){var i=r[a];t.has(i.id())||e.push(i)}}function fs(e,t,n){if(n.isChild()){var r=n._private.parent;t.has(r.id())||e.push(r)}}function ps(e,t,n){fs(e,t,n),hs(e,t,n)}cs.forEachDown=function(e){return ds(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],hs)},cs.forEachUp=function(e){return ds(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],fs)},cs.forEachUpAndDown=function(e){return ds(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],ps)},cs.ancestors=cs.parents,(ss=ls={data:xo.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:xo.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:xo.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:xo.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:xo.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:xo.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=ss.data,ss.removeAttr=ss.removeData;var vs,gs,ys=ls,ms={};function bs(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;o<i.length;o++){var s=i[o];!t&&s.isLoop()||(r+=e(a,s))}return r}}}function xs(e,t){return function(n){for(var r,a=this.nodes(),i=0;i<a.length;i++){var o=a[i][e](n);void 0===o||void 0!==r&&!t(o,r)||(r=o)}return r}}ge(ms,{degree:bs((function(e,t){return t.source().same(t.target())?2:1})),indegree:bs((function(e,t){return t.target().same(e)?1:0})),outdegree:bs((function(e,t){return t.source().same(e)?1:0}))}),ge(ms,{minDegree:xs("degree",(function(e,t){return e<t})),maxDegree:xs("degree",(function(e,t){return e>t})),minIndegree:xs("indegree",(function(e,t){return e<t})),maxIndegree:xs("indegree",(function(e,t){return e>t})),minOutdegree:xs("outdegree",(function(e,t){return e<t})),maxOutdegree:xs("outdegree",(function(e,t){return e>t}))}),ge(ms,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r<n.length;r++)t+=n[r].degree(e);return t}});var ws=function(e,t,n){for(var r=0;r<e.length;r++){var a=e[r];if(!a.locked()){var i=a._private.position,o={x:null!=t.x?t.x-i.x:0,y:null!=t.y?t.y-i.y:0};!a.isParent()||0===o.x&&0===o.y||a.children().shift(o,n),a.dirtyBoundingBoxCache()}}},Es={field:"position",bindingEvent:"position",allowBinding:!0,allowSetting:!0,settingEvent:"position",settingTriggersEvent:!0,triggerFnName:"emitAndNotify",allowGetting:!0,validKeys:["x","y"],beforeGet:function(e){e.updateCompoundBounds()},beforeSet:function(e,t){ws(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};vs=gs={position:xo.data(Es),silentPosition:xo.data(ge({},Es,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){ws(e,t,!0)},onSet:function(e){e.dirtyCompoundBoundsCache()}})),positions:function(e,t){if(K(e))t?this.silentPosition(e):this.position(e);else if(U(e)){var n=e,r=this.cy();r.startBatch();for(var a=0;a<this.length;a++){var i,o=this[a];(i=n(o,a))&&(t?o.silentPosition(i):o.position(i))}r.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,n){var r;if(K(e)?(r={x:G(e.x)?e.x:0,y:G(e.y)?e.y:0},n=t):W(e)&&G(t)&&((r={x:0,y:0})[e]=t),null!=r){var a=this.cy();a.startBatch();for(var i=0;i<this.length;i++){var o=this[i];if(!(a.hasCompoundNodes()&&o.isChild()&&o.ancestors().anySame(this))){var s=o.position(),l={x:s.x+r.x,y:s.y+r.y};n?o.silentPosition(l):o.position(l)}}a.endBatch()}return this},silentShift:function(e,t){return K(e)?this.shift(e,!0):W(e)&&G(t)&&this.shift(e,t,!0),this},renderedPosition:function(e,t){var n=this[0],r=this.cy(),a=r.zoom(),i=r.pan(),o=K(e)?e:void 0,s=void 0!==o||void 0!==t&&W(e);if(n&&n.isNode()){if(!s){var l=n.position();return o=Xt(l,a,i),void 0===e?o:o[e]}for(var u=0;u<this.length;u++){var c=this[u];void 0!==t?c.position(e,(t-i[e])/a):void 0!==o&&c.position(jt(o,a,i))}}else if(!s)return;return this},relativePosition:function(e,t){var n=this[0],r=this.cy(),a=K(e)?e:void 0,i=void 0!==a||void 0!==t&&W(e),o=r.hasCompoundNodes();if(n&&n.isNode()){if(!i){var s=n.position(),l=o?n.parent():null,u=l&&l.length>0,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;h<this.length;h++){var f=this[h],p=o?f.parent():null,v=p&&p.length>0,g=v;v&&(p=p[0]);var y=g?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}},vs.modelPosition=vs.point=vs.position,vs.modelPositions=vs.points=vs.positions,vs.renderedPoint=vs.renderedPosition,vs.relativePoint=vs.relativePosition;var ks,Ts,Cs=gs;ks=Ts={},Ts.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}},Ts.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},Ts.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),v=p.biasDiff,g=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=(-v+i.y1+i.y2+g)/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;r<this.length;r++){var a=this[r],i=a._private;i.compoundBoundsClean&&!e||(n(a),t.batching()||(i.compoundBoundsClean=!0))}return this};var Ps=function(e){return e===1/0||e===-1/0?0:e},Ss=function(e,t,n,r,a){r-t!=0&&a-n!=0&&null!=t&&null!=n&&null!=r&&null!=a&&(e.x1=t<e.x1?t:e.x1,e.x2=r>e.x2?r:e.x2,e.y1=n<e.y1?n:e.y1,e.y2=a>e.y2?a:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Bs=function(e,t){return null==t?e:Ss(e,t.x1,t.y1,t.x2,t.y2)},Ds=function(e,t,n){return ht(e,t,n)},_s=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,tn(u,1),Ss(e,u.x1,u.y1,u.x2,u.y2)}}},As=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=Ds(i,"labelWidth",n),f=Ds(i,"labelHeight",n),p=Ds(i,"labelX",n),v=Ds(i,"labelY",n),g=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=v-P,u=v+P;else{switch(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(d.value){case"top":l=v-k,u=v;break;case"center":l=v-P,u=v+P;break;case"bottom":l=v,u=v+k}}var S=g-Math.max(x,w)-E-2,B=g+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?Ds(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(c.value){case"left":V=s;break;case"right":V=o}switch(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,Ss(e,o,l,s,u),Ss(a.labelBounds.all,o,l,s,u)}return e}},Ms=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;Rs(e,t,n,r,"outside",r/2)}},Rs=function(e,t,n,r,a,i){if(!(0===n||r<=0||"inside"===a)){var o=t.cy(),s=t.pstyle("shape").value,l=o.renderer().nodeShapes[s],u=t.position(),c=u.x,d=u.y,h=t.width(),f=t.height();if(l.hasMiterBounds){"center"===a&&(r/=2);var p=l.miterBounds(c,d,h,f,r);Bs(e,p)}else null!=i&&i>0&&nn(e,[i,i,i,i])}},Is=function(e,t){var n,r,a,i,o,s,l,u=e._private.cy,c=u.styleEnabled(),d=u.headless(),h=Jt(),f=e._private,p=e.isNode(),v=e.isEdge(),g=f.rstyle,y=p&&c?e.pstyle("bounds-expansion").pfValue:[0],m=function(e){return"none"!==e.pstyle("display").value},b=!c||m(e)&&(!v||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;Ss(h,n=o-C,a=s-P,r=o+C,i=s+P),c&&Ms(h,e),c&&t.includeOutlines&&!d&&Ms(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;Rs(e,t,n,r,a)}}(h,e)}else if(v&&t.includeEdges)if(c&&!d){var S=e.pstyle("curve-style").strValue;if(n=Math.min(g.srcX,g.midX,g.tgtX),r=Math.max(g.srcX,g.midX,g.tgtX),a=Math.min(g.srcY,g.midY,g.tgtY),i=Math.max(g.srcY,g.midY,g.tgtY),Ss(h,n-=k,a-=k,r+=k,i+=k),"haystack"===S){var B=g.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=_}Ss(h,n-k,a-k,r+k,i+k)}}else if("bezier"===S||"unbundled-bezier"===S||ue(S,"segments")||ue(S,"taxi")){var A;switch(S){case"bezier":case"unbundled-bezier":A=g.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":A=g.linePts}if(null!=A)for(var M=0;M<A.length;M++){var R=A[M];n=R.x-k,r=R.x+k,a=R.y-k,i=R.y+k,Ss(h,n,a,r,i)}}}else{var I=e.source().position(),N=e.target().position();if((n=I.x)>(r=N.x)){var L=n;n=r,r=L}if((a=I.y)>(i=N.y)){var z=a;a=i,i=z}Ss(h,n-=k,a-=k,r+=k,i+=k)}if(c&&t.includeEdges&&v&&(_s(h,e,"mid-source"),_s(h,e,"mid-target"),_s(h,e,"source"),_s(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;Ss(h,h.x1+O,h.y1+V,h.x2+O,h.y2+V)}var F=f.bodyBounds=f.bodyBounds||{};rn(F,h),nn(F,y),tn(F,1),c&&(n=h.x1,r=h.x2,a=h.y1,i=h.y2,Ss(h,n-E,a-E,r+E,i+E));var X=f.overlayBounds=f.overlayBounds||{};rn(X,h),nn(X,y),tn(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=Jt(),c&&t.includeLabels&&(t.includeMainLabels&&As(h,e,null),v&&(t.includeSourceLabels&&As(h,e,"source"),t.includeTargetLabels&&As(h,e,"target")))}return h.x1=Ps(h.x1),h.y1=Ps(h.y1),h.x2=Ps(h.x2),h.y2=Ps(h.y2),h.w=Ps(h.x2-h.x1),h.h=Ps(h.y2-h.y1),h.w>0&&h.h>0&&b&&(nn(h,y),tn(h,1)),h},Ns=function(e){var t=0,n=function(e){return(e?1:0)<<t++},r=0;return r+=n(e.incudeNodes),r+=n(e.includeEdges),r+=n(e.includeLabels),r+=n(e.includeMainLabels),r+=n(e.includeSourceLabels),r+=n(e.includeTargetLabels),r+=n(e.includeOverlays),r+=n(e.includeOutlines)},Ls=function(e){var t=function(e){return Math.round(e)};if(e.isEdge()){var n=e.source().position(),r=e.target().position();return Ye([t(n.x),t(n.y),t(r.x),t(r.y)])}var a=e.position();return Ye([t(a.x),t(a.y)])},zs=function(e,t){var n,r=e._private,a=e.isEdge(),i=(null==t?Vs:Ns(t))===Vs;if(null==r.bbCache?(n=Is(e,Os),r.bbCache=n,r.bbCachePosKey=Ls(e)):n=r.bbCache,!i){var o=e.isNode();n=Jt(),(t.includeNodes&&o||t.includeEdges&&!o)&&(t.includeOverlays?Bs(n,r.overlayBounds):Bs(n,r.bodyBounds)),t.includeLabels&&(t.includeMainLabels&&(!a||t.includeSourceLabels&&t.includeTargetLabels)?Bs(n,r.labelBounds.all):(t.includeMainLabels&&Bs(n,r.labelBounds.mainRot),t.includeSourceLabels&&Bs(n,r.labelBounds.sourceRot),t.includeTargetLabels&&Bs(n,r.labelBounds.targetRot))),n.w=n.x2-n.x1,n.h=n.y2-n.y1}return n},Os={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,includeOutlines:!0,useCache:!0},Vs=Ns(Os),Fs=ut(Os);Ts.boundingBox=function(e){var t,n=void 0===e||void 0===e.useCache||!0===e.useCache,r=ae((function(e){var t=e._private;return null==t.bbCache||t.styleDirty||t.bbCachePosKey!==Ls(e)}),(function(e){return e.id()}));if(n&&1===this.length&&!r(this[0]))e=void 0===e?Os:Fs(e),t=zs(this[0],e);else{t=Jt();var a=Fs(e=e||Os),i=this,o=i.cy().styleEnabled();this.edges().forEach(r),this.nodes().forEach(r),o&&this.recalculateRenderedStyle(n),this.updateCompoundBounds(!n);for(var s=0;s<i.length;s++){var l=i[s];r(l)&&l.dirtyBoundingBoxCache(),Bs(t,zs(l,a))}}return t.x1=Ps(t.x1),t.y1=Ps(t.y1),t.x2=Ps(t.x2),t.y2=Ps(t.y2),t.w=Ps(t.x2-t.x1),t.h=Ps(t.y2-t.y1),t},Ts.dirtyBoundingBoxCache=function(){for(var e=0;e<this.length;e++){var t=this[e]._private;t.bbCache=null,t.bbCachePosKey=null,t.bodyBounds=null,t.overlayBounds=null,t.labelBounds.all=null,t.labelBounds.source=null,t.labelBounds.target=null,t.labelBounds.main=null,t.labelBounds.sourceRot=null,t.labelBounds.targetRot=null,t.labelBounds.mainRot=null,t.arrowBounds.source=null,t.arrowBounds.target=null,t.arrowBounds["mid-source"]=null,t.arrowBounds["mid-target"]=null}return this.emitAndNotify("bounds"),this},Ts.boundingBoxAt=function(e){var t=this.nodes(),n=this.cy(),r=n.hasCompoundNodes(),a=n.collection();if(r&&(a=t.filter((function(e){return e.isParent()})),t=t.not(a)),K(e)){var i=e;e=function(){return i}}n.startBatch(),t.forEach((function(t,n){return t._private.bbAtOldPos=e(t,n)})).silentPositions(e),r&&(a.dirtyCompoundBoundsCache(),a.dirtyBoundingBoxCache(),a.updateCompoundBounds(!0));var o=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}}(this.boundingBox({useCache:!1}));return t.silentPositions((function(e){return e._private.bbAtOldPos})),r&&(a.dirtyCompoundBoundsCache(),a.dirtyBoundingBoxCache(),a.updateCompoundBounds(!0)),n.endBatch(),o},ks.boundingbox=ks.bb=ks.boundingBox,ks.renderedBoundingbox=ks.renderedBoundingBox;var Xs,js,Ys=Ts;Xs=js={};var qs=function(e){e.uppercaseName=le(e.name),e.autoName="auto"+e.uppercaseName,e.labelName="label"+e.uppercaseName,e.outerName="outer"+e.uppercaseName,e.uppercaseOuterName=le(e.outerName),Xs[e.name]=function(){var t=this[0],n=t._private,r=n.cy._private.styleEnabled;if(t){if(r){if(t.isParent())return t.updateCompoundBounds(),n[e.autoName]||0;var a=t.pstyle(e.name);return"label"===a.strValue?(t.recalculateRenderedStyle(),n.rstyle[e.labelName]||0):a.pfValue}return 1}},Xs["outer"+e.uppercaseName]=function(){var t=this[0],n=t._private.cy._private.styleEnabled;if(t){if(n){var r=t[e.name](),a=t.pstyle("border-position").value;return r+("center"===a?t.pstyle("border-width").pfValue:"outside"===a?2*t.pstyle("border-width").pfValue:0)+2*t.padding()}return 1}},Xs["rendered"+e.uppercaseName]=function(){var t=this[0];if(t)return t[e.name]()*this.cy().zoom()},Xs["rendered"+e.uppercaseOuterName]=function(){var t=this[0];if(t)return t[e.outerName]()*this.cy().zoom()}};qs({name:"width"}),qs({name:"height"}),js.padding=function(){var e=this[0],t=e._private;return e.isParent()?(e.updateCompoundBounds(),void 0!==t.autoPadding?t.autoPadding:e.pstyle("padding").pfValue):e.pstyle("padding").pfValue},js.paddedHeight=function(){var e=this[0];return e.height()+2*e.padding()},js.paddedWidth=function(){var e=this[0];return e.width()+2*e.padding()};var Ws=js,Us={controlPoints:{get:function(e){return e.renderer().getControlPoints(e)},mult:!0},segmentPoints:{get:function(e){return e.renderer().getSegmentPoints(e)},mult:!0},sourceEndpoint:{get:function(e){return e.renderer().getSourceEndpoint(e)}},targetEndpoint:{get:function(e){return e.renderer().getTargetEndpoint(e)}},midpoint:{get:function(e){return e.renderer().getEdgeMidpoint(e)}}},Hs=Object.keys(Us).reduce((function(e,t){var n=Us[t],r=function(e){return"rendered"+e[0].toUpperCase()+e.substr(1)}(t);return e[t]=function(){return function(e,t){if(e.isEdge()&&e.takesUpSpace())return t(e)}(this,n.get)},n.mult?e[r]=function(){return function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy(),r=n.pan(),a=n.zoom();return t(e).map((function(e){return Xt(e,a,r)}))}}(this,n.get)}:e[r]=function(){return function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy();return Xt(t(e),n.zoom(),n.pan())}}(this,n.get)},e}),{}),Ks=ge({},Cs,Ys,Ws,Hs),Gs=function(e,t){this.recycle(e,t)};function Zs(){return!1}function $s(){return!0}Gs.prototype={instanceString:function(){return"event"},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=Zs,null!=e&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?$s:Zs):null!=e&&e.type?t=e:this.type=e,null!=t&&(this.originalEvent=t.originalEvent,this.type=null!=t.type?t.type:this.type,this.cy=t.cy,this.target=t.target,this.position=t.position,this.renderedPosition=t.renderedPosition,this.namespace=t.namespace,this.layout=t.layout),null!=this.cy&&null!=this.position&&null==this.renderedPosition){var n=this.position,r=this.cy.zoom(),a=this.cy.pan();this.renderedPosition={x:n.x*r+a.x,y:n.y*r+a.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=$s;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=$s;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=$s,this.stopPropagation()},isDefaultPrevented:Zs,isPropagationStopped:Zs,isImmediatePropagationStopped:Zs};var Qs=/^([^.]+)(\.(?:[^.]+))?$/,Js={qualifierCompare:function(e,t){return e===t},eventMatches:function(){return!0},addEventFields:function(){},callbackContext:function(e){return e},beforeEmit:function(){},afterEmit:function(){},bubble:function(){return!1},parent:function(){return null},context:null},el=Object.keys(Js),tl={};function nl(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:tl,t=arguments.length>1?arguments[1]:void 0,n=0;n<el.length;n++){var r=el[n];this[r]=e[r]||Js[r]}this.context=t||this.context,this.listeners=[],this.emitting=0}var rl=nl.prototype,al=function(e,t,n,r,a,i,o){U(r)&&(a=r,r=null),o&&(i=null==i?o:ge({},i,o));for(var s=H(n)?n:n.split(/\s+/),l=0;l<s.length;l++){var u=s[l];if(!ne(u)){var c=u.match(Qs);if(c)if(!1===t(e,u,c[1],c[2]?c[2]:null,r,a,i))break}}},il=function(e,t){return e.addEventFields(e.context,t),new Gs(t.type,t)},ol=function(e,t,n){if("event"!==q(n))if(K(n))t(e,il(e,n));else for(var r=H(n)?n:n.split(/\s+/),a=0;a<r.length;a++){var i=r[a];if(!ne(i)){var o=i.match(Qs);if(o){var s=o[1],l=o[2]?o[2]:null;t(e,il(e,{type:s,namespace:l,target:e.context}))}}}else t(e,n)};rl.on=rl.addListener=function(e,t,n,r,a){return al(this,(function(e,t,n,r,a,i,o){U(i)&&e.listeners.push({event:t,callback:i,type:n,namespace:r,qualifier:a,conf:o})}),e,t,n,r,a),this},rl.one=function(e,t,n,r){return this.on(e,t,n,r,{one:!0})},rl.removeListener=rl.off=function(e,t,n,r){var a=this;0!==this.emitting&&(this.listeners=this.listeners.slice());for(var i=this.listeners,o=function(o){var s=i[o];al(a,(function(t,n,r,a,l,u){if((s.type===r||"*"===e)&&(!a&&".*"!==s.namespace||s.namespace===a)&&(!l||t.qualifierCompare(s.qualifier,l))&&(!u||s.callback===u))return i.splice(o,1),!1}),e,t,n,r)},s=i.length-1;s>=0;s--)o(s);return this},rl.removeAllListeners=function(){return this.removeListener("*")},rl.emit=rl.trigger=function(e,t,n){var r=this.listeners,a=r.length;return this.emitting++,H(t)||(t=[t]),ol(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;n<t.length;n++){var r=t[n];e.push(r)}}(a,t),e.beforeEmit(e.context,n,i),n.conf&&n.conf.one&&(e.listeners=e.listeners.filter((function(e){return e!==n})));var o=e.callbackContext(e.context,n,i),l=n.callback.apply(o,a);e.afterEmit(e.context,n,i),!1===l&&(i.stopPropagation(),i.preventDefault())}},s=0;s<a;s++)o();e.bubble(e.context)&&!i.isPropagationStopped()&&e.parent(e.context).emit(i,t)}),e),this.emitting--,this};var sl={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&&Q(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e.cy(),t.target=e},callbackContext:function(e,t,n){return null!=t.qualifier?n.target:e},beforeEmit:function(e,t){t.conf&&t.conf.once&&t.conf.onceCollection.removeListener(t.event,t.qualifier,t.callback)},bubble:function(){return!0},parent:function(e){return e.isChild()?e.parent():e.cy()}},ll=function(e){return W(e)?new as(e):e},ul={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],n=t._private;n.emitter||(n.emitter=new nl(sl,t))}return this},emitter:function(){return this._private.emitter},on:function(e,t,n){for(var r=ll(t),a=0;a<this.length;a++){this[a].emitter().on(e,r,n)}return this},removeListener:function(e,t,n){for(var r=ll(t),a=0;a<this.length;a++){this[a].emitter().removeListener(e,r,n)}return this},removeAllListeners:function(){for(var e=0;e<this.length;e++){this[e].emitter().removeAllListeners()}return this},one:function(e,t,n){for(var r=ll(t),a=0;a<this.length;a++){this[a].emitter().one(e,r,n)}return this},once:function(e,t,n){for(var r=ll(t),a=0;a<this.length;a++){this[a].emitter().on(e,r,n,{once:!0,onceCollection:this})}},emit:function(e,t){for(var n=0;n<this.length;n++){this[n].emitter().emit(e,t)}return this},emitAndNotify:function(e,t){if(0!==this.length)return this.cy().notify(e,this),this.emit(e,t),this}};xo.eventAliasesOn(ul);var cl={nodes:function(e){return this.filter((function(e){return e.isNode()})).filter(e)},edges:function(e){return this.filter((function(e){return e.isEdge()})).filter(e)},byGroup:function(){for(var e=this.spawn(),t=this.spawn(),n=0;n<this.length;n++){var r=this[n];r.isNode()?e.push(r):t.push(r)}return{nodes:e,edges:t}},filter:function(e,t){if(void 0===e)return this;if(W(e)||$(e))return new as(e).filter(this);if(U(e)){for(var n=this.spawn(),r=this,a=0;a<r.length;a++){var i=r[a];(t?e.apply(t,[i,a,r]):e(i,a,r))&&n.push(i)}return n}return this.spawn()},not:function(e){if(e){W(e)&&(e=this.filter(e));for(var t=this.spawn(),n=0;n<this.length;n++){var r=this[n];e.has(r)||t.push(r)}return t}return this},absoluteComplement:function(){return this.cy().mutableElements().not(this)},intersect:function(e){if(W(e)){var t=e;return this.filter(t)}for(var n=this.spawn(),r=e,a=this.length<e.length,i=a?this:r,o=a?r:this,s=0;s<i.length;s++){var l=i[s];o.has(l)&&n.push(l)}return n},xor:function(e){var t=this._private.cy;W(e)&&(e=t.$(e));var n=this.spawn(),r=e,a=function(e,t){for(var r=0;r<e.length;r++){var a=e[r],i=a._private.data.id;t.hasElementWithId(i)||n.push(a)}};return a(this,r),a(r,this),n},diff:function(e){var t=this._private.cy;W(e)&&(e=t.$(e));var n=this.spawn(),r=this.spawn(),a=this.spawn(),i=e,o=function(e,t,n){for(var r=0;r<e.length;r++){var i=e[r],o=i._private.data.id;t.hasElementWithId(o)?a.merge(i):n.push(i)}};return o(this,i,n),o(i,this,r),{left:n,right:r,both:a}},add:function(e){var t=this._private.cy;if(!e)return this;if(W(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=this.spawnSelf(),a=0;a<e.length;a++){var i=e[a],o=!this.has(i);o&&r.push(i)}return r},merge:function(e){var t=this._private,n=t.cy;if(!e)return this;if(e&&W(e)){var r=e;e=n.mutableElements().filter(r)}for(var a=t.map,i=0;i<e.length;i++){var o=e[i],s=o._private.data.id;if(!a.has(s)){var l=this.length++;this[l]=o,a.set(s,{ele:o,index:l})}}return this},unmergeAt:function(e){var t=this[e].id(),n=this._private.map;this[e]=void 0,n.delete(t);var r=e===this.length-1;if(this.length>1&&!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<e.length;r++)this.unmergeOne(e[r]);return this},unmergeBy:function(e){for(var t=this.length-1;t>=0;t--){e(this[t])&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],r=this,a=0;a<r.length;a++){var i=r[a],o=t?e.apply(t,[i,a,r]):e(i,a,r);n.push(o)}return n},reduce:function(e,t){for(var n=t,r=this,a=0;a<r.length;a++)n=e(n,r[a],a,r);return n},max:function(e,t){for(var n,r=-1/0,a=this,i=0;i<a.length;i++){var o=a[i],s=t?e.apply(t,[o,i,a]):e(o,i,a);s>r&&(r=s,n=o)}return{value:r,ele:n}},min:function(e,t){for(var n,r=1/0,a=this,i=0;i<a.length;i++){var o=a[i],s=t?e.apply(t,[o,i,a]):e(o,i,a);s<r&&(r=s,n=o)}return{value:r,ele:n}}},dl=cl;dl.u=dl["|"]=dl["+"]=dl.union=dl.or=dl.add,dl["\\"]=dl["!"]=dl["-"]=dl.difference=dl.relativeComplement=dl.subtract=dl.not,dl.n=dl["&"]=dl["."]=dl.and=dl.intersection=dl.intersect,dl["^"]=dl["(+)"]=dl["(-)"]=dl.symmetricDifference=dl.symdiff=dl.xor,dl.fnFilter=dl.filterFn=dl.stdFilter=dl.filter,dl.complement=dl.abscomp=dl.absoluteComplement;var hl=function(e,t){var n=e.cy().hasCompoundNodes();function r(e){var t=e.pstyle("z-compound-depth");return"auto"===t.value?n?e.zDepth():0:"bottom"===t.value?-1:"top"===t.value?$e:0}var a=r(e)-r(t);if(0!==a)return a;function i(e){return"auto"===e.pstyle("z-index-compare").value&&e.isNode()?1:0}var o=i(e)-i(t);if(0!==o)return o;var s=e.pstyle("z-index").value-t.pstyle("z-index").value;return 0!==s?s:e.poolIndex()-t.poolIndex()},fl={forEach:function(e,t){if(U(e))for(var n=this.length,r=0;r<n;r++){var a=this[r];if(!1===(t?e.apply(t,[a,r,this]):e(a,r,this)))break}return this},toArray:function(){for(var e=[],t=0;t<this.length;t++)e.push(this[t]);return e},slice:function(e,t){var n=[],r=this.length;null==t&&(t=r),null==e&&(e=0),e<0&&(e=r+e),t<0&&(t=r+t);for(var a=e;a>=0&&a<t&&a<r;a++)n.push(this[a]);return this.spawn(n)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return 0===this.length},nonempty:function(){return!this.empty()},sort:function(e){if(!U(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(hl)},zDepth:function(){var e=this[0];if(e){var t=e._private;if("nodes"===t.group){var n=t.data.parent?e.parents().size():0;return e.isParent()?n:$e-1}var r=t.source,a=t.target,i=r.zDepth(),o=a.zDepth();return Math.max(i,o,0)}}};fl.each=fl.forEach;var pl;pl="undefined",("undefined"==typeof Symbol?"undefined":l(Symbol))!=pl&&l(Symbol.iterator)!=pl&&(fl[Symbol.iterator]=function(){var e=this,t={value:void 0,done:!1},n=0,r=this.length;return a({next:function(){return n<r?t.value=e[n++]:(t.value=void 0,t.done=!0),t}},Symbol.iterator,(function(){return this}))});var vl=ut({nodeDimensionsIncludeLabels:!1}),gl={layoutDimensions:function(e){var t;if(e=vl(e),this.takesUpSpace())if(e.nodeDimensionsIncludeLabels){var n=this.boundingBox();t={w:n.w,h:n.h}}else t={w:this.outerWidth(),h:this.outerHeight()};else t={w:0,h:0};return 0!==t.w&&0!==t.h||(t.w=t.h=1),t},layoutPositions:function(e,t,n){var r=this.nodes().filter((function(e){return!e.isParent()})),a=this.cy(),i=t.eles,o=function(e){return e.id()},s=ae(n,o);e.emit({type:"layoutstart",layout:e}),e.animations=[];var l=t.spacingFactor&&1!==t.spacingFactor,u=function(){if(!l)return null;for(var e=Jt(),t=0;t<r.length;t++){var n=r[t],a=s(n,t);en(e,a.x,a.y)}return e}(),c=ae((function(e,n){var r=s(e,n);l&&(r=function(e,t,n){var r=t.x1+t.w/2,a=t.y1+t.h/2;return{x:r+(n.x-r)*e,y:a+(n.y-a)*e}}(Math.abs(t.spacingFactor),u,r));return null!=t.transform&&(r=t.transform(e,r)),r}),o);if(t.animate){for(var d=0;d<r.length;d++){var h=r[d],f=c(h,d);if(null==t.animateFilter||t.animateFilter(h,d)){var p=h.animation({position:f,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(p)}else h.position(f)}if(t.fit){var v=a.animation({fit:{boundingBox:i.boundingBoxAt(c),padding:t.padding},duration:t.animationDuration,easing:t.animationEasing});e.animations.push(v)}else if(void 0!==t.zoom&&void 0!==t.pan){var g=a.animation({zoom:t.zoom,pan:t.pan,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(g)}e.animations.forEach((function(e){return e.play()})),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),Hr.all(e.animations.map((function(e){return e.promise()}))).then((function(){e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e})}))}else r.positions(c),t.fit&&a.fit(t.eles,t.padding),null!=t.zoom&&a.zoom(t.zoom),t.pan&&a.pan(t.pan),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){return this.cy().makeLayout(ge({},e,{eles:this}))}};function yl(e,t,n){var r,a=n._private,i=a.styleCache=a.styleCache||[];return null!=(r=i[e])?r:r=i[e]=t(n)}function ml(e,t){return e=qe(e),function(n){return yl(e,t,n)}}function bl(e,t){e=qe(e);var n=function(e){return t.call(e)};return function(){var t=this[0];if(t)return yl(e,n,t)}}gl.createLayout=gl.makeLayout=gl.layout;var xl={recalculateRenderedStyle:function(e){var t=this.cy(),n=t.renderer(),r=t.styleEnabled();return n&&r&&n.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e,t=this.cy(),n=function(e){return e._private.styleCache=null};t.hasCompoundNodes()?((e=this.spawnSelf().merge(this.descendants()).merge(this.parents())).merge(e.connectedEdges()),e.forEach(n)):this.forEach((function(e){n(e),e.connectedEdges().forEach(n)}));return this},updateStyle:function(e){var t=this._private.cy;if(!t.styleEnabled())return this;if(t.batching())return t._private.batchStyleEles.merge(this),this;var n=this;e=!(!e&&void 0!==e),t.hasCompoundNodes()&&(n=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var r=n;return e?r.emitAndNotify("style"):r.emit("style"),n.forEach((function(e){return e._private.styleDirty=!0})),this},cleanStyle:function(){var e=this.cy();if(e.styleEnabled())for(var t=0;t<this.length;t++){var n=this[t];n._private.styleDirty&&(n._private.styleDirty=!1,e.style().apply(n))}},parsedStyle:function(e){var t=!(arguments.length>1&&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;i<a.length;i++){var o=a[i];r.removeAllBypasses(o,n)}else{e=e.split(/\s+/);for(var s=0;s<a.length;s++){var l=a[s];r.removeBypasses(l,e,n)}}return this.emitAndNotify("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},effectiveOpacity:function(){var e=this.cy();if(!e.styleEnabled())return 1;var t=e.hasCompoundNodes(),n=this[0];if(n){var r=n._private,a=n.pstyle("opacity").value;if(!t)return a;var i=r.data.parent?n.parents():null;if(i)for(var o=0;o<i.length;o++){a*=i[o].pstyle("opacity").value}return a}},transparent:function(){if(!this.cy().styleEnabled())return!1;var e=this[0],t=e.cy().hasCompoundNodes();return e?t?0===e.effectiveOpacity():0===e.pstyle("opacity").value:void 0},backgrounding:function(){return!!this.cy().styleEnabled()&&!!this[0]._private.backgrounding}};function wl(e,t){var n=e._private.data.parent?e.parents():null;if(n)for(var r=0;r<n.length;r++){if(!t(n[r]))return!1}return!0}function El(e){var t=e.ok,n=e.edgeOkViaNode||e.ok,r=e.parentOk||e.ok;return function(){var e=this.cy();if(!e.styleEnabled())return!0;var a=this[0],i=e.hasCompoundNodes();if(a){var o=a._private;if(!t(a))return!1;if(a.isNode())return!i||wl(a,r);var s=o.source,l=o.target;return n(s)&&(!i||wl(s,n))&&(s===l||n(l)&&(!i||wl(l,n)))}}}var kl=ml("eleTakesUpSpace",(function(e){return"element"===e.pstyle("display").value&&0!==e.width()&&(!e.isNode()||0!==e.height())}));xl.takesUpSpace=bl("takesUpSpace",El({ok:kl}));var Tl=ml("eleInteractive",(function(e){return"yes"===e.pstyle("events").value&&"visible"===e.pstyle("visibility").value&&kl(e)})),Cl=ml("parentInteractive",(function(e){return"visible"===e.pstyle("visibility").value&&kl(e)}));xl.interactive=bl("interactive",El({ok:Tl,parentOk:Cl,edgeOkViaNode:kl})),xl.noninteractive=function(){var e=this[0];if(e)return!e.interactive()};var Pl=ml("eleVisible",(function(e){return"visible"===e.pstyle("visibility").value&&0!==e.pstyle("opacity").pfValue&&kl(e)})),Sl=kl;xl.visible=bl("visible",El({ok:Pl,edgeOkViaNode:Sl})),xl.hidden=function(){var e=this[0];if(e)return!e.visible()},xl.isBundledBezier=bl("isBundledBezier",(function(){return!!this.cy().styleEnabled()&&(!this.removed()&&"bezier"===this.pstyle("curve-style").value&&this.takesUpSpace())})),xl.bypass=xl.css=xl.style,xl.renderedCss=xl.renderedStyle,xl.removeBypass=xl.removeCss=xl.removeStyle,xl.pstyle=xl.parsedStyle;var Bl={};function Dl(e){return function(){var t=arguments,n=[];if(2===t.length){var r=t[0],a=t[1];this.on(e.event,r,a)}else if(1===t.length&&U(t[0])){var i=t[0];this.on(e.event,i)}else if(0===t.length||1===t.length&&H(t[0])){for(var o=1===t.length?t[0]:null,s=0;s<this.length;s++){var l=this[s],u=!e.ableField||l._private[e.ableField],c=l._private[e.field]!=e.value;if(e.overrideAble){var d=e.overrideAble(l);if(void 0!==d&&(u=d,!d))return this}u&&(l._private[e.field]=e.value,c&&n.push(l))}var h=this.spawn(n);h.updateStyle(),h.emit(e.event),o&&h.emit(o)}return this}}function _l(e){Bl[e.field]=function(){var t=this[0];if(t){if(e.overrideField){var n=e.overrideField(t);if(void 0!==n)return n}return t._private[e.field]}},Bl[e.on]=Dl({event:e.on,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!0}),Bl[e.off]=Dl({event:e.off,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!1})}_l({field:"locked",overrideField:function(e){return!!e.cy().autolock()||void 0},on:"lock",off:"unlock"}),_l({field:"grabbable",overrideField:function(e){return!e.cy().autoungrabify()&&!e.pannable()&&void 0},on:"grabify",off:"ungrabify"}),_l({field:"selected",ableField:"selectable",overrideAble:function(e){return!e.cy().autounselectify()&&void 0},on:"select",off:"unselect"}),_l({field:"selectable",overrideField:function(e){return!e.cy().autounselectify()&&void 0},on:"selectify",off:"unselectify"}),Bl.deselect=Bl.unselect,Bl.grabbed=function(){var e=this[0];if(e)return e._private.grabbed},_l({field:"active",on:"activate",off:"unactivate"}),_l({field:"pannable",on:"panify",off:"unpanify"}),Bl.inactive=function(){var e=this[0];if(e)return!e._private.active};var Al={},Ml=function(e){return function(t){for(var n=[],r=0;r<this.length;r++){var a=this[r];if(a.isNode()){for(var i=!1,o=a.connectedEdges(),s=0;s<o.length;s++){var l=o[s],u=l.source(),c=l.target();if(e.noIncomingEdges&&c===a&&u!==a||e.noOutgoingEdges&&u===a&&c!==a){i=!0;break}}i||n.push(a)}}return this.spawn(n,!0).filter(t)}},Rl=function(e){return function(t){for(var n=[],r=0;r<this.length;r++){var a=this[r];if(a.isNode())for(var i=a.connectedEdges(),o=0;o<i.length;o++){var s=i[o],l=s.source(),u=s.target();e.outgoing&&l===a?(n.push(s),n.push(u)):e.incoming&&u===a&&(n.push(s),n.push(l))}}return this.spawn(n,!0).filter(t)}},Il=function(e){return function(t){for(var n=this,r=[],a={};;){var i=e.outgoing?n.outgoers():n.incomers();if(0===i.length)break;for(var o=!1,s=0;s<i.length;s++){var l=i[s],u=l.id();a[u]||(a[u]=!0,r.push(l),o=!0)}if(!o)break;n=i}return this.spawn(r,!0).filter(t)}};function Nl(e){return function(t){for(var n=[],r=0;r<this.length;r++){var a=this[r]._private[e.attr];a&&n.push(a)}return this.spawn(n,!0).filter(t)}}function Ll(e){return function(t){var n=[],r=this._private.cy,a=e||{};W(t)&&(t=r.$(t));for(var i=0;i<t.length;i++)for(var o=t[i]._private.edges,s=0;s<o.length;s++){var l=o[s],u=l._private.data,c=this.hasElementWithId(u.source)&&t.hasElementWithId(u.target),d=t.hasElementWithId(u.source)&&this.hasElementWithId(u.target);if(c||d){if(a.thisIsSrc||a.thisIsTgt){if(a.thisIsSrc&&!c)continue;if(a.thisIsTgt&&!d)continue}n.push(l)}}return this.spawn(n,!0)}}function zl(e){return e=ge({},{codirected:!1},e),function(t){for(var n=[],r=this.edges(),a=e,i=0;i<r.length;i++)for(var o=r[i]._private,s=o.source,l=s._private.data.id,u=o.data.target,c=s._private.edges,d=0;d<c.length;d++){var h=c[d],f=h._private.data,p=f.target,v=f.source,g=p===u&&v===l,y=l===p&&u===v;(a.codirected&&g||!a.codirected&&(g||y))&&n.push(h)}return this.spawn(n,!0).filter(t)}}Al.clearTraversalCache=function(){for(var e=0;e<this.length;e++)this[e]._private.traversalCache=null},ge(Al,{roots:Ml({noIncomingEdges:!0}),leaves:Ml({noOutgoingEdges:!0}),outgoers:us(Rl({outgoing:!0}),"outgoers"),successors:Il({outgoing:!0}),incomers:us(Rl({incoming:!0}),"incomers"),predecessors:Il({})}),ge(Al,{neighborhood:us((function(e){for(var t=[],n=this.nodes(),r=0;r<n.length;r++)for(var a=n[r],i=a.connectedEdges(),o=0;o<i.length;o++){var s=i[o],l=s.source(),u=s.target(),c=a===l?u:l;c.length>0&&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)}}),Al.neighbourhood=Al.neighborhood,Al.closedNeighbourhood=Al.closedNeighborhood,Al.openNeighbourhood=Al.openNeighborhood,ge(Al,{source:us((function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t}),"source"),target:us((function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t}),"target"),sources:Nl({attr:"source"}),targets:Nl({attr:"target"})}),ge(Al,{edgesWith:us(Ll(),"edgesWith"),edgesTo:us(Ll({thisIsSrc:!0}),"edgesTo")}),ge(Al,{connectedEdges:us((function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];if(r.isNode())for(var a=r._private.edges,i=0;i<a.length;i++){var o=a[i];t.push(o)}}return this.spawn(t,!0).filter(e)}),"connectedEdges"),connectedNodes:us((function(e){for(var t=[],n=0;n<this.length;n++){var r=this[n];r.isEdge()&&(t.push(r.source()[0]),t.push(r.target()[0]))}return this.spawn(t,!0).filter(e)}),"connectedNodes"),parallelEdges:us(zl(),"parallelEdges"),codirectedEdges:us(zl({codirected:!0}),"codirectedEdges")}),ge(Al,{components:function(e){var t=this,n=t.cy(),r=n.collection(),a=null==e?t.nodes():e.nodes(),i=[];null!=e&&a.empty()&&(a=e.sources());var o=function(e,t){r.merge(e),a.unmerge(e),t.merge(e)};if(a.empty())return t.spawn();var s=function(){var e=n.collection();i.push(e);var r=a[0];o(r,e),t.bfs({directed:!1,roots:r,visit:function(t){return o(t,e)}}),e.forEach((function(n){n.connectedEdges().forEach((function(n){t.has(n)&&e.has(n.source())&&e.has(n.target())&&e.merge(n)}))}))};do{s()}while(a.length>0);return i},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),Al.componentsOf=Al.components;var Ol=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 pt,i=!1;if(t){if(t.length>0&&K(t[0])&&!Q(t[0])){i=!0;for(var o=[],s=new gt,l=0,u=t.length;l<u;l++){var c=t[l];null==c.data&&(c.data={});var d=c.data;if(null==d.id)d.id=ot();else if(e.hasElementWithId(d.id)||s.has(d.id))continue;var h=new yt(e,c,!1);o.push(h),s.add(d.id)}t=o}}else t=[];this.length=0;for(var f=0,p=t.length;f<p;f++){var v=t[f][0];if(null!=v){var g=v._private.data.id;n&&a.has(g)||(n&&a.set(g,{index:this.length,ele:v}),this[this.length]=v,this.length++)}}this._private={eles:this,cy:e,get map(){return null==this.lazyMap&&this.rebuildMap(),this.lazyMap},set map(e){this.lazyMap=e},rebuildMap:function(){for(var e=this.lazyMap=new pt,t=this.eles,n=0;n<t.length;n++){var r=t[n];e.set(r.id(),{index:n,ele:r})}}},n&&(this._private.map=a),i&&!r&&this.restore()}else nt("A collection must have a reference to the core")},Vl=yt.prototype=Ol.prototype=Object.create(Array.prototype);Vl.instanceString=function(){return"collection"},Vl.spawn=function(e,t){return new Ol(this.cy(),e,t)},Vl.spawnSelf=function(){return this.spawn(this)},Vl.cy=function(){return this._private.cy},Vl.renderer=function(){return this._private.cy.renderer()},Vl.element=function(){return this[0]},Vl.collection=function(){return J(this)?this:new Ol(this._private.cy,[this])},Vl.unique=function(){return new Ol(this._private.cy,this,!0)},Vl.hasElementWithId=function(e){return e=""+e,this._private.map.has(e)},Vl.getElementById=function(e){e=""+e;var t=this._private.cy,n=this._private.map.get(e);return n?n.ele:new Ol(t)},Vl.$id=Vl.getElementById,Vl.poolIndex=function(){var e=this._private.cy._private.elements,t=this[0]._private.data.id;return e._private.map.get(t).index},Vl.indexOf=function(e){var t=e[0]._private.data.id;return this._private.map.get(t).index},Vl.indexOfId=function(e){return e=""+e,this._private.map.get(e).index},Vl.json=function(e){var t=this.element(),n=this.cy();if(null==t&&e)return this;if(null!=t){var r=t._private;if(K(e)){if(n.startBatch(),e.data){t.data(e.data);var a=r.data;if(t.isEdge()){var i=!1,o={},s=e.data.source,l=e.data.target;null!=s&&s!=a.source&&(o.source=""+s,i=!0),null!=l&&l!=a.target&&(o.target=""+l,i=!0),i&&(t=t.move(o))}else{var u="parent"in e.data,c=e.data.parent;!u||null==c&&null==a.parent||c==a.parent||(void 0===c&&(c=null),null!=c&&(c=""+c),t=t.move({parent:c}))}}e.position&&t.position(e.position);var d=function(n,a,i){var o=e[n];null!=o&&o!==r[n]&&(o?t[a]():t[i]())};return d("removed","remove","restore"),d("selected","select","unselect"),d("selectable","selectify","unselectify"),d("locked","lock","unlock"),d("grabbable","grabify","ungrabify"),d("pannable","panify","unpanify"),null!=e.classes&&t.classes(e.classes),n.endBatch(),this}if(void 0===e){var h={data:it(r.data),position:it(r.position),group:r.group,removed:r.removed,selected:r.selected,selectable:r.selectable,locked:r.locked,grabbable:r.grabbable,pannable:r.pannable,classes:null};h.classes="";var f=0;return r.classes.forEach((function(e){return h.classes+=0==f++?e:" "+e})),h}}},Vl.jsons=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t].json();e.push(n)}return e},Vl.clone=function(){for(var e=this.cy(),t=[],n=0;n<this.length;n++){var r=this[n].json(),a=new yt(e,r,!1);t.push(a)}return new Ol(e,t)},Vl.copy=Vl.clone,Vl.restore=function(){for(var e,t,n=!(arguments.length>0&&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;u<c;u++){var d=a[u];r&&!d.removed()||(d.isNode()?s.push(d):l.push(d))}e=s.concat(l);var h=function(){e.splice(t,1),t--};for(t=0;t<e.length;t++){var f=e[t],p=f._private,v=p.data;if(f.clearTraversalCache(),r||p.removed)if(void 0===v.id)v.id=ot();else if(G(v.id))v.id=""+v.id;else{if(ne(v.id)||!W(v.id)){nt("Can not create element with invalid string ID `"+v.id+"`"),h();continue}if(i.hasElementWithId(v.id)){nt("Can not create second element with ID `"+v.id+"`"),h();continue}}else;var g=v.id;if(f.isNode()){var y=p.position;null==y.x&&(y.x=0),null==y.y&&(y.y=0)}if(f.isEdge()){for(var m=f,b=["source","target"],x=b.length,w=!1,E=0;E<x;E++){var k=b[E],T=v[k];G(T)&&(T=v[k]=""+v[k]),null==T||""===T?(nt("Can not create edge `"+g+"` with unspecified "+k),w=!0):i.hasElementWithId(T)||(nt("Can not create edge `"+g+"` with nonexistant "+k+" `"+T+"`"),w=!0)}if(w){h();continue}var C=i.getElementById(v.source),P=i.getElementById(v.target);C.same(P)?C._private.edges.push(m):(C._private.edges.push(m),P._private.edges.push(m)),m._private.source=C,m._private.target=P}p.map=new pt,p.map.set(g,{ele:f,index:0}),p.removed=!1,r&&i.addToPool(f)}for(var S=0;S<s.length;S++){var B=s[S],D=B._private.data;G(D.parent)&&(D.parent=""+D.parent);var _=D.parent;if(null!=_||B._private.parent){var A=B._private.parent?i.collection().merge(B._private.parent):i.getElementById(_);if(A.empty())D.parent=void 0;else if(A[0].removed())at("Node added with missing parent, reference to parent removed"),D.parent=void 0,B._private.parent=null;else{for(var M=!1,R=A;!R.empty();){if(B.same(R)){M=!0,D.parent=void 0;break}R=R.parent()}M||(A[0]._private.children.push(B),B._private.parent=A[0],o.hasCompoundNodes=!0)}}}if(e.length>0){for(var I=e.length===a.length?a:new Ol(i,e),N=0;N<I.length;N++){var L=I[N];L.isNode()||(L.parallelEdges().clearTraversalCache(),L.source().clearTraversalCache(),L.target().clearTraversalCache())}(o.hasCompoundNodes?i.collection().merge(I).merge(I.connectedNodes()).merge(I.parent()):I).dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(n),n?I.emitAndNotify("add"):r&&I.emit("add")}return a},Vl.removed=function(){var e=this[0];return e&&e._private.removed},Vl.inside=function(){var e=this[0];return e&&!e._private.removed},Vl.remove=function(){var e=!(arguments.length>0&&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;n<t.length;n++)o(t[n])}(e),function(e){for(var t=e._private.children,n=0;n<t.length;n++)o(t[n])}(e)):r.unshift(e))}for(var s=0,l=n.length;s<l;s++){o(n[s])}function u(e,t){var n=e._private.edges;ct(n,t),e.clearTraversalCache()}function c(e){e.clearTraversalCache()}var d=[];function h(e,t){t=t[0];var n=(e=e[0])._private.children,r=e.id();ct(n,t),t._private.parent=null,d.ids[r]||(d.ids[r]=!0,d.push(e))}d.ids={},n.dirtyCompoundBoundsCache(),t&&i.removeFromPool(r);for(var f=0;f<r.length;f++){var p=r[f];if(p.isEdge()){var v=p.source()[0],g=p.target()[0];u(v,p),u(g,p);for(var y=p.parallelEdges(),m=0;m<y.length;m++){var b=y[m];c(b),b.isBundledBezier()&&b.dirtyBoundingBoxCache()}}else{var x=p.parent();0!==x.length&&h(x,p)}t&&(p._private.removed=!0)}var w=i._private.elements;i._private.hasCompoundNodes=!1;for(var E=0;E<w.length;E++){if(w[E].isParent()){i._private.hasCompoundNodes=!0;break}}var k=new Ol(this.cy(),r);k.size()>0&&(e?k.emitAndNotify("remove"):t&&k.emit("remove"));for(var T=0;T<d.length;T++){var C=d[T];t&&C.removed()||C.updateStyle()}return k},Vl.move=function(e){var t=this._private.cy,n=this,r=!1,a=!1,i=function(e){return null==e?e:""+e};if(void 0!==e.source||void 0!==e.target){var o=i(e.source),s=i(e.target),l=null!=o&&t.hasElementWithId(o),u=null!=s&&t.hasElementWithId(s);(l||u)&&(t.batch((function(){n.remove(r,a),n.emitAndNotify("moveout");for(var e=0;e<n.length;e++){var t=n[e],i=t._private.data;t.isEdge()&&(l&&(i.source=o),u&&(i.target=s))}n.restore(r,a)})),n.emitAndNotify("move"))}else if(void 0!==e.parent){var c=i(e.parent);if(null===c||t.hasElementWithId(c)){var d=null===c?void 0:c;t.batch((function(){var e=n.remove(r,a);e.emitAndNotify("moveout");for(var t=0;t<n.length;t++){var i=n[t],o=i._private.data;i.isNode()&&(o.parent=d)}e.restore(r,a)})),n.emitAndNotify("move")}}return this},[Fr,wo,Eo,os,cs,ys,ms,Ks,ul,cl,{isNode:function(){return"nodes"===this.group()},isEdge:function(){return"edges"===this.group()},isLoop:function(){return this.isEdge()&&this.source()[0]===this.target()[0]},isSimple:function(){return this.isEdge()&&this.source()[0]!==this.target()[0]},group:function(){var e=this[0];if(e)return e._private.group}},fl,gl,xl,Bl,Al].forEach((function(e){ge(Vl,e)}));var Fl={add:function(e){var t,n=this;if($(e)){var r=e;if(r._private.cy===n)t=r.restore();else{for(var a=[],i=0;i<r.length;i++){var o=r[i];a.push(o.json())}t=new Ol(n,a)}}else if(H(e)){t=new Ol(n,e)}else if(K(e)&&(H(e.nodes)||H(e.edges))){for(var s=e,l=[],u=["nodes","edges"],c=0,d=u.length;c<d;c++){var h=u[c],f=s[h];if(H(f))for(var p=0,v=f.length;p<v;p++){var g=ge({group:h},f[p]);l.push(g)}}t=new Ol(n,l)}else{t=new yt(n,e).collection()}return t},remove:function(e){if($(e));else if(W(e)){var t=e;e=this.$(t)}return e.remove()}};
+/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */function Xl(e,t,n,r){var a=.1,i="undefined"!=typeof Float32Array;if(4!==arguments.length)return!1;for(var o=0;o<4;++o)if("number"!=typeof arguments[o]||isNaN(arguments[o])||!isFinite(arguments[o]))return!1;e=Math.min(e,1),n=Math.min(n,1),e=Math.max(e,0),n=Math.max(n,0);var s=i?new Float32Array(11):new Array(11);function l(e,t){return 1-3*t+3*e}function u(e,t){return 3*t-6*e}function c(e){return 3*e}function d(e,t,n){return((l(t,n)*e+u(t,n))*e+c(t))*e}function h(e,t,n){return 3*l(t,n)*e*e+2*u(t,n)*e+c(t)}function f(t){for(var r=0,i=1;10!==i&&s[i]<=t;++i)r+=a;--i;var o=r+(t-s[i])/(s[i+1]-s[i])*a,l=h(o,e,n);return l>=.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 v(){p=!0,e===t&&n===r||function(){for(var t=0;t<11;++t)s[t]=d(t*a,e,n)}()}var g=function(a){return p||v(),e===t&&n===r?a:0===a?0:1===a?1:d(f(a),t,r)};g.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var y="generateBezier("+[e,t,n,r]+")";return g.toString=function(){return y},g}
+/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var jl=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}}(),Yl=function(e,t,n,r){var a=Xl(e,t,n,r);return function(e,t,n){return e+(t-e)*a(n)}},ql={linear:function(e,t,n){return e+(t-e)*n},ease:Yl(.25,.1,.25,1),"ease-in":Yl(.42,0,1,1),"ease-out":Yl(0,0,.58,1),"ease-in-out":Yl(.42,0,.58,1),"ease-in-sine":Yl(.47,0,.745,.715),"ease-out-sine":Yl(.39,.575,.565,1),"ease-in-out-sine":Yl(.445,.05,.55,.95),"ease-in-quad":Yl(.55,.085,.68,.53),"ease-out-quad":Yl(.25,.46,.45,.94),"ease-in-out-quad":Yl(.455,.03,.515,.955),"ease-in-cubic":Yl(.55,.055,.675,.19),"ease-out-cubic":Yl(.215,.61,.355,1),"ease-in-out-cubic":Yl(.645,.045,.355,1),"ease-in-quart":Yl(.895,.03,.685,.22),"ease-out-quart":Yl(.165,.84,.44,1),"ease-in-out-quart":Yl(.77,0,.175,1),"ease-in-quint":Yl(.755,.05,.855,.06),"ease-out-quint":Yl(.23,1,.32,1),"ease-in-out-quint":Yl(.86,0,.07,1),"ease-in-expo":Yl(.95,.05,.795,.035),"ease-out-expo":Yl(.19,1,.22,1),"ease-in-out-expo":Yl(1,0,0,1),"ease-in-circ":Yl(.6,.04,.98,.335),"ease-out-circ":Yl(.075,.82,.165,1),"ease-in-out-circ":Yl(.785,.135,.15,.86),spring:function(e,t,n){if(0===n)return ql.linear;var r=jl(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":Yl};function Wl(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 Ul(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function Hl(e,t,n,r,a){var i=null!=a?a.type:null;n<0?n=0:n>1&&(n=1);var o=Ul(e,a),s=Ul(t,a);if(G(o)&&G(s))return Wl(i,o,s,n,r);if(H(o)&&H(s)){for(var l=[],u=0;u<s.length;u++){var c=o[u],d=s[u];if(null!=c&&null!=d){var h=Wl(i,c,d,n,r);l.push(h)}else l.push(d)}return l}}function Kl(e,t,n,r){var a=!r,i=e._private,o=t._private,s=o.easing,l=o.startTime,u=(r?e:e.cy()).style();if(!o.easingImpl)if(null==s)o.easingImpl=ql.linear;else{var c,d,h;if(W(s))c=u.parse("transition-timing-function",s).value;else c=s;W(c)?(d=c,h=[]):(d=c[1],h=c.slice(2).map((function(e){return+e}))),h.length>0?("spring"===d&&h.push(o.duration),o.easingImpl=ql[d].apply(null,h)):o.easingImpl=ql[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 v=o.startPosition,g=o.position;if(g&&a&&!e.locked()){var y={};Gl(v.x,g.x)&&(y.x=Hl(v.x,g.x,f,p)),Gl(v.y,g.y)&&(y.y=Hl(v.y,g.y,f,p)),e.position(y)}var m=o.startPan,b=o.pan,x=i.pan,w=null!=b&&r;w&&(Gl(m.x,b.x)&&(x.x=Hl(m.x,b.x,f,p)),Gl(m.y,b.y)&&(x.y=Hl(m.y,b.y,f,p)),e.emit("pan"));var E=o.startZoom,k=o.zoom,T=null!=k&&r;T&&(Gl(E,k)&&(i.zoom=Qt(i.minZoom,Hl(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<C.length;P++){var S=C[P],B=S.name,D=S,_=o.startStyle[B],A=Hl(_,D,f,p,u.properties[_.name]);u.overrideBypass(e,B,A)}e.emit("style")}}return o.progress=f,f}function Gl(e,t){return null!=e&&null!=t&&(!(!G(e)||!G(t))||!(!e||!t))}function Zl(e,t,n,r){var a=t._private;a.started=!0,a.startTime=n-a.progress*a.duration}function $l(e,t){var n=t._private.aniEles,r=[];function a(t,n){var a=t._private,i=a.animation.current,o=a.animation.queue,s=!1;if(0===i.length){var l=o.shift();l&&i.push(l)}for(var u=function(e){for(var t=e.length-1;t>=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||Zl(0,d,e),Kl(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;o<n.length;o++){var s=a(n[o]);i=i||s}var l=a(t,!0);(i||l)&&(n.length>0?t.notify("draw",n):t.notify("draw")),n.unmerge(r),t.emit("step")}var Ql={animate:xo.animate(),animation:xo.animation(),animated:xo.animated(),clearQueue:xo.clearQueue(),delay:xo.delay(),delayAnimation:xo.delayAnimation(),stop:xo.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){$l(n,e)}),t.beforeRenderPriorities.animations):function t(){e._private.animationsRunning&&Ie((function(n){$l(n,e),t()}))}()}}},Jl={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&&Q(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}},eu=function(e){return W(e)?new as(e):e},tu={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new nl(Jl,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,eu(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,eu(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,eu(t),n),this},once:function(e,t,n){return this.emitter().one(e,eu(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}};xo.eventAliasesOn(tu);var nu={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)}};nu.jpeg=nu.jpg;var ru={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(ge({},e,{cy:t,eles:a}));return i}nt("No such layout `"+n+"` found.  Did you forget to import it and `cytoscape.use()` it?")}else nt("A `name` must be specified to make a layout");else nt("Layout options must be specified to make a layout")}};ru.createLayout=ru.makeLayout=ru.layout;var au={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;r<n.length;r++){var a=n[r],i=e[a];t.getElementById(a).data(i)}}))}},iu=ut({hideEdgesOnViewport:!1,textureOnViewport:!1,motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1,debug:!1,showFps:!1,webgl:!1,webglDebug:!1,webglDebugShowAtlases:!1,webglTexSize:2048,webglTexRows:36,webglTexRowsNodes:18,webglBatchSize:2048,webglTexPerBatch:14,webglBgColor:[255,255,255]}),ou={renderTo:function(e,t,n,r){return this._private.renderer.renderTo(e,t,n,r),this},renderer:function(){return this._private.renderer},forceRender:function(){return this.notify("draw"),this},resize:function(){return this.invalidateSize(),this.emitAndNotify("resize"),this},initRenderer:function(e){var t=this,n=t.extension("renderer",e.name);if(null!=n){void 0!==e.wheelSensitivity&&at("You have set a custom wheel sensitivity.  This will make your app zoom unnaturally when using mainstream mice.  You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");var r=iu(e);r.cy=t,t._private.renderer=new n(r),this.notify("init")}else nt("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"))},destroyRenderer:function(){var e=this;e.notify("destroy");var t=e.container();if(t)for(t._cyreg=null;t.childNodes.length>0;)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)}};ou.invalidateDimensions=ou.resize;var su={collection:function(e,t){return W(e)?this.$(e):$(e)?e.collection():H(e)?(t||(t={}),new Ol(this,e,t.unique,t.removed)):new Ol(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}};su.elements=su.filter=su.$;var lu={},uu="t";lu.apply=function(e){for(var t=this,n=t._private.cy.collection(),r=0;r<e.length;r++){var a=e[r],i=t.getContextMeta(a);if(!i.empty){var o=t.getContextStyle(i),s=t.applyContextStyle(i,o,a);a._private.appliedInitStyle?t.updateTransitions(a,s.diffProps):a._private.appliedInitStyle=!0,t.updateStyleHints(a)&&n.push(a)}}return n},lu.getPropertiesDiff=function(e,t){var n=this,r=n._private.propDiffs=n._private.propDiffs||{},a=e+"-"+t,i=r[a];if(i)return i;for(var o=[],s={},l=0;l<n.length;l++){var u=n[l],c=e[l]===uu,d=t[l]===uu,h=c!==d,f=u.mappedProperties.length>0;if(h||d&&f){var p=void 0;h&&f||h?p=u.properties:f&&(p=u.mappedProperties);for(var v=0;v<p.length;v++){for(var g=p[v],y=g.name,m=!1,b=l+1;b<n.length;b++){var x=n[b];if(t[b]===uu&&(m=null!=x.properties[g.name]))break}s[y]||m||(s[y]=!0,o.push(y))}}}return r[a]=o,o},lu.getContextMeta=function(e){for(var t,n=this,r="",a=e._private.styleCxtKey||"",i=0;i<n.length;i++){var o=n[i];r+=o.selector&&o.selector.matches(e)?uu:"f"}return t=n.getPropertiesDiff(a,r),e._private.styleCxtKey=r,{key:r,diffPropNames:t,empty:0===t.length}},lu.getContextStyle=function(e){var t=e.key,n=this._private.contextStyles=this._private.contextStyles||{};if(n[t])return n[t];for(var r={_private:{key:t}},a=0;a<this.length;a++){var i=this[a];if(t[a]===uu)for(var o=0;o<i.properties.length;o++){var s=i.properties[o];r[s.name]=s}}return n[t]=r,r},lu.applyContextStyle=function(e,t,n){for(var r=e.diffPropNames,a={},i=this.types,o=0;o<r.length;o++){var s=r[o],l=t[s],u=n.pstyle(s);if(!l){if(!u)continue;l=u.bypass?{name:s,deleteBypassed:!0}:{name:s,delete:!0}}if(u!==l){if(l.mapped===i.fn&&null!=u&&null!=u.mapping&&u.mapping.value===l.value){var c=u.mapping;if((c.fnValue=l.value(n))===c.prevFnValue)continue}var d=a[s]={prev:u};this.applyParsedProperty(n,l),d.next=n.pstyle(s),d.next&&d.next.bypass&&(d.next=d.next.bypassed)}}return{diffProps:a}},lu.updateStyleHints=function(e){var t=e._private,n=this,r=n.propertyGroupNames,a=n.propertyGroupKeys,i=function(e,t,r){return n.getPropertiesHash(e,t,r)},o=t.styleKey;if(e.removed())return!1;var s="nodes"===t.group,l=e._private.style;r=Object.keys(l);for(var u=0;u<a.length;u++){var c=a[u];t.styleKeys[c]=[Le,ze]}for(var d,h=function(e,n){return t.styleKeys[n][0]=Ve(e,t.styleKeys[n][0])},f=function(e,n){return t.styleKeys[n][1]=Fe(e,t.styleKeys[n][1])},p=function(e,t){h(e,t),f(e,t)},v=function(e,t){for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);h(r,t),f(r,t)}},g=0;g<r.length;g++){var y=r[g],m=l[y];if(null!=m){var b=this.properties[y],x=b.type,w=b.groupKey,E=void 0;null!=b.hashOverride?E=b.hashOverride(e,m):null!=m.pfValue&&(E=m.pfValue);var k=null==b.enums?m.value:null,T=null!=E,C=T||null!=k,P=m.units;if(x.number&&C&&!x.multiple)p(-128<(d=T?E:k)&&d<128&&Math.floor(d)!==d?2e9-(1024*d|0):d,w),T||null==P||v(P,w);else v(m.strValue,w)}}for(var S,B,D=[Le,ze],_=0;_<a.length;_++){var A=a[_],M=t.styleKeys[A];D[0]=Ve(M[0],D[0]),D[1]=Fe(M[1],D[1])}t.styleKey=(S=D[0],B=D[1],2097152*S+B);var R=t.styleKeys;t.labelDimsKey=Xe(R.labelDimensions);var I=i(e,["label"],R.labelDimensions);if(t.labelKey=Xe(I),t.labelStyleKey=Xe(je(R.commonLabel,I)),!s){var N=i(e,["source-label"],R.labelDimensions);t.sourceLabelKey=Xe(N),t.sourceLabelStyleKey=Xe(je(R.commonLabel,N));var L=i(e,["target-label"],R.labelDimensions);t.targetLabelKey=Xe(L),t.targetLabelStyleKey=Xe(je(R.commonLabel,L))}if(s){var z=t.styleKeys,O=z.nodeBody,V=z.nodeBorder,F=z.nodeOutline,X=z.backgroundImage,j=z.compound,Y=z.pie,q=z.stripe,W=[O,V,F,X,j,Y,q].filter((function(e){return null!=e})).reduce(je,[Le,ze]);t.nodeKey=Xe(W),t.hasPie=null!=Y&&Y[0]!==Le&&Y[1]!==ze,t.hasStripe=null!=q&&q[0]!==Le&&q[1]!==ze}return o!==t.styleKey},lu.clearStyleHints=function(e){var t=e._private;t.styleCxtKey="",t.styleKeys={},t.styleKey=null,t.labelKey=null,t.labelStyleKey=null,t.sourceLabelKey=null,t.sourceLabelStyleKey=null,t.targetLabelKey=null,t.targetLabelStyleKey=null,t.nodeKey=null,t.hasPie=null,t.hasStripe=null},lu.applyParsedProperty=function(e,t){var n,r=this,a=t,i=e._private.style,o=r.types,s=r.properties[a.name].type,l=a.bypass,u=i[a.name],c=u&&u.bypass,d=e._private,h="mapping",f=function(e){return null==e?null:null!=e.pfValue?e.pfValue:e.value},p=function(){var t=f(u),n=f(a);r.checkTriggers(e,a.name,t,n)};if("curve-style"===t.name&&e.isEdge()&&("bezier"!==t.value&&e.isLoop()||"haystack"===t.value&&(e.source().isParent()||e.target().isParent()))&&(a=t=this.parse(t.name,"bezier",l)),a.delete)return i[a.name]=void 0,p(),!0;if(a.deleteBypassed)return u?!!u.bypass&&(u.bypassed=void 0,p(),!0):(p(),!0);if(a.deleteBypass)return u?!!u.bypass&&(i[a.name]=u.bypassed,p(),!0):(p(),!0);var v=function(){at("Do not assign mappings to elements without corresponding data (i.e. ele `"+e.id()+"` has no mapping for property `"+a.name+"` with data field `"+a.field+"`); try a `["+a.field+"]` selector to limit scope to elements with `"+a.field+"` defined")};switch(a.mapped){case o.mapData:for(var g,y=a.field.split("."),m=d.data,b=0;b<y.length&&m;b++){m=m[y[b]]}if(null==m)return v(),!1;if(!G(m))return at("Do not use continuous mappers without specifying numeric data (i.e. `"+a.field+": "+m+"` for `"+e.id()+"` is non-numeric)"),!1;var x=a.fieldMax-a.fieldMin;if((g=0===x?0:(m-a.fieldMin)/x)<0?g=0:g>1&&(g=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)*g),Math.round(k+(T-k)*g),Math.round(C+(P-C)*g),Math.round(S+(B-S)*g)];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)*g;n=this.parse(a.name,_,a.bypass,h)}if(!n)return v(),!1;n.mapping=a,a=n;break;case o.data:for(var A=a.field.split("."),M=d.data,R=0;R<A.length&&M;R++){M=M[A[R]]}if(null!=M&&(n=this.parse(a.name,M,a.bypass,h)),!n)return v(),!1;n.mapping=a,a=n;break;case o.fn:var I=a.value,N=null!=a.fnValue?a.fnValue:I(e);if(a.prevFnValue=N,null==N)return at("Custom function mappers may not return null (i.e. `"+a.name+"` for ele `"+e.id()+"` is null)"),!1;if(!(n=this.parse(a.name,N,a.bypass,h)))return at("Custom function mappers may not return invalid values for the property type (i.e. `"+a.name+"` for ele `"+e.id()+"` is invalid)"),!1;n.mapping=it(a),a=n;break;case void 0:break;default:return!1}return l?(a.bypassed=c?u.bypassed:u,i[a.name]=a):c?u.bypassed=a:i[a.name]=a,p(),!0},lu.cleanElements=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(this.clearStyleHints(r),r.dirtyCompoundBoundsCache(),r.dirtyBoundingBoxCache(),t)for(var a=r._private.style,i=Object.keys(a),o=0;o<i.length;o++){var s=i[o],l=a[s];null!=l&&(l.bypass?l.bypassed=null:a[s]=null)}else r._private.style={}}},lu.update=function(){this._private.cy.mutableElements().updateStyle()},lu.updateTransitions=function(e,t){var n=this,r=e._private,a=e.pstyle("transition-property").value,i=e.pstyle("transition-duration").pfValue,o=e.pstyle("transition-delay").pfValue;if(a.length>0&&i>0){for(var s={},l=!1,u=0;u<a.length;u++){var c=a[u],d=e.pstyle(c),h=t[c];if(h){var f=h.prev,p=null!=h.next?h.next:d,v=!1,g=void 0,y=1e-6;f&&(G(f.pfValue)&&G(p.pfValue)?(v=p.pfValue-f.pfValue,g=f.pfValue+y*v):G(f.value)&&G(p.value)?(v=p.value-f.value,g=f.value+y*v):H(f.value)&&H(p.value)&&(v=f.value[0]!==p.value[0]||f.value[1]!==p.value[1]||f.value[2]!==p.value[2],g=f.strValue),v&&(s[c]=p.strValue,this.applyBypass(e,c,g),l=!0))}}if(!l)return;r.transitioning=!0,new Hr((function(t){o>0?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)},lu.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)},lu.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)}))},lu.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,(function(e){return e.triggersBounds}),(function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()}))},lu.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()}))}))},lu.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()}))}))},lu.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 cu={applyBypass:function(e,t,n,r){var a=[];if("*"===t||"**"===t){if(void 0!==n)for(var i=0;i<this.properties.length;i++){var o=this.properties[i].name,s=this.parse(o,n,!0);s&&a.push(s)}}else if(W(t)){var l=this.parse(t,n,!0);l&&a.push(l)}else{if(!K(t))return!1;var u=t;r=n;for(var c=Object.keys(u),d=0;d<c.length;d++){var h=c[d],f=u[h];if(void 0===f&&(f=u[oe(h)]),void 0!==f){var p=this.parse(h,f,!0);p&&a.push(p)}}}if(0===a.length)return!1;for(var v=!1,g=0;g<e.length;g++){for(var y=e[g],m={},b=void 0,x=0;x<a.length;x++){var w=a[x];if(r){var E=y.pstyle(w.name);b=m[w.name]={prev:E}}v=this.applyParsedProperty(y,it(w))||v,r&&(b.next=y.pstyle(w.name))}v&&this.updateStyleHints(y),r&&this.updateTransitions(y,m,true)}return v},overrideBypass:function(e,t,n){t=ie(t);for(var r=0;r<e.length;r++){var a=e[r],i=a._private.style[t],o=this.properties[t].type,s=o.color,l=o.mutiple,u=i?null!=i.pfValue?i.pfValue:i.value:null;i&&i.bypass?(i.value=n,null!=i.pfValue&&(i.pfValue=n),i.strValue=s?"rgb("+n.join(",")+")":l?n.join(" "):""+n,this.updateStyleHints(a)):this.applyBypass(a,t,n),this.checkTriggers(a,t,u,n)}},removeAllBypasses:function(e,t){return this.removeBypasses(e,this.propertyNames,t)},removeBypasses:function(e,t,n){for(var r=0;r<e.length;r++){for(var a=e[r],i={},o=0;o<t.length;o++){var s=t[o],l=this.properties[s],u=a.pstyle(l.name);if(u&&u.bypass){var c=this.parse(s,"",!0),d=i[l.name]={prev:u};this.applyParsedProperty(a,c),d.next=a.pstyle(l.name)}}this.updateStyleHints(a),n&&this.updateTransitions(a,i,true)}}},du={getEmSizeInPixels:function(){var e=this.containerCss("font-size");return null!=e?parseFloat(e):1},containerCss:function(e){var t=this._private.cy,n=t.container(),r=t.window();if(r&&n&&r.getComputedStyle)return r.getComputedStyle(n).getPropertyValue(e)}},hu={getRenderedStyle:function(e,t){return t?this.getStylePropertyValue(e,t,!0):this.getRawStyle(e,!0)},getRawStyle:function(e,t){var n=this;if(e=e[0]){for(var r={},a=0;a<n.properties.length;a++){var i=n.properties[a],o=n.getStylePropertyValue(e,i.name,t);null!=o&&(r[i.name]=o,r[oe(i.name)]=o)}return r}},getIndexedStyle:function(e,t,n,r){var a=e.pstyle(t)[n][r];return null!=a?a:e.cy().style().getDefaultProperty(t)[n][0]},getStylePropertyValue:function(e,t,n){if(e=e[0]){var r=this.properties[t];r.alias&&(r=r.pointsTo);var a=r.type,i=e.pstyle(r.name);if(i){var o=i.value,s=i.units,l=i.strValue;if(n&&a.number&&null!=o&&G(o)){var u=e.cy().zoom(),c=function(e){return e*u},d=function(e,t){return c(e)+t},h=H(o);return(h?s.every((function(e){return null!=e})):null!=s)?h?o.map((function(e,t){return d(e,s[t])})).join(" "):d(o,s):h?o.map((function(e){return W(e)?e:""+c(e)})).join(" "):""+c(o)}if(null!=l)return l}return null}},getAnimationStartStyle:function(e,t){for(var n={},r=0;r<t.length;r++){var a=t[r].name,i=e.pstyle(a);void 0!==i&&(i=K(i)?this.parse(a,i.strValue):this.parse(a,i)),i&&(n[a]=i)}return n},getPropsList:function(e){var t=[],n=e,r=this.properties;if(n)for(var a=Object.keys(n),i=0;i<a.length;i++){var o=a[i],s=n[o],l=r[o]||r[ie(o)],u=this.parse(l.name,s);u&&t.push(u)}return t},getNonDefaultPropertiesHash:function(e,t,n){var r,a,i,o,s,l,u=n.slice();for(s=0;s<t.length;s++)if(r=t[s],null!=(a=e.pstyle(r,!1)))if(null!=a.pfValue)u[0]=Ve(o,u[0]),u[1]=Fe(o,u[1]);else for(i=a.strValue,l=0;l<i.length;l++)o=i.charCodeAt(l),u[0]=Ve(o,u[0]),u[1]=Fe(o,u[1]);return u}};hu.getPropertiesHash=hu.getNonDefaultPropertiesHash;var fu={appendFromJson:function(e){for(var t=this,n=0;n<e.length;n++){var r=e[n],a=r.selector,i=r.style||r.css,o=Object.keys(i);t.selector(a);for(var s=0;s<o.length;s++){var l=o[s],u=i[l];t.css(l,u)}}return t},fromJson:function(e){var t=this;return t.resetToDefault(),t.appendFromJson(e),t},json:function(){for(var e=[],t=this.defaultLength;t<this.length;t++){for(var n=this[t],r=n.selector,a=n.properties,i={},o=0;o<a.length;o++){var s=a[o];i[s.name]=s.strValue}e.push({selector:r?r.toString():"core",style:i})}return e}},pu={appendFromString:function(e){var t,n,r,a=this,i=""+e;function o(){i=i.length>t.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){at("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 as(u).invalid){at("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){at("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],v=f[2];if(this.properties[p])a.parse(p,v)?(h.push({name:p,val:v}),s()):(at("Skipping property: Invalid property definition in: "+r),s());else at("Skipping property: Invalid property name in: "+r),s()}if(d){o();break}a.selector(u);for(var g=0;g<h.length;g++){var y=h[g];a.css(y.name,y.val)}o()}return a},fromString:function(e){var t=this;return t.resetToDefault(),t.appendFromString(e),t}},vu={};!function(){var e=ce,t=he,n=pe,r=function(e){return"^"+e+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},a=function(r){var a=e+"|\\w+|"+t+"|"+n+"|\\#[0-9a-fA-F]{3}|\\#[0-9a-fA-F]{6}";return"^"+r+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+e+")\\s*\\,\\s*("+e+")\\s*,\\s*("+a+")\\s*\\,\\s*("+a+")\\)$"},i=["^url\\s*\\(\\s*['\"]?(.+?)['\"]?\\s*\\)$","^(none)$","^(.+)$"];vu.types={time:{number:!0,min:0,units:"s|ms",implicitUnits:"ms"},percent:{number:!0,min:0,max:100,units:"%",implicitUnits:"%"},percentages:{number:!0,min:0,max:100,units:"%",implicitUnits:"%",multiple:!0},zeroOneNumber:{number:!0,min:0,max:1,unitless:!0},zeroOneNumbers:{number:!0,min:0,max:1,unitless:!0,multiple:!0},nOneOneNumber:{number:!0,min:-1,max:1,unitless:!0},nonNegativeInt:{number:!0,min:0,integer:!0,unitless:!0},nonNegativeNumber:{number:!0,min:0,unitless:!0},position:{enums:["parent","origin"]},nodeSize:{number:!0,min:0,enums:["label"]},number:{number:!0,unitless:!0},numbers:{number:!0,unitless:!0,multiple:!0},positiveNumber:{number:!0,unitless:!0,min:0,strictMin:!0},size:{number:!0,min:0},bidirectionalSize:{number:!0},bidirectionalSizeMaybePercent:{number:!0,allowPercent:!0},bidirectionalSizes:{number:!0,multiple:!0},sizeMaybePercent:{number:!0,min:0,allowPercent:!0},axisDirection:{enums:["horizontal","leftward","rightward","vertical","upward","downward","auto"]},axisDirectionExplicit:{enums:["leftward","rightward","upward","downward"]},axisDirectionPrimary:{enums:["horizontal","vertical"]},paddingRelativeTo:{enums:["width","height","average","min","max"]},bgWH:{number:!0,min:0,allowPercent:!0,enums:["auto"],multiple:!0},bgPos:{number:!0,allowPercent:!0,multiple:!0},bgRelativeTo:{enums:["inner","include-padding"],multiple:!0},bgRepeat:{enums:["repeat","repeat-x","repeat-y","no-repeat"],multiple:!0},bgFit:{enums:["none","contain","cover"],multiple:!0},bgCrossOrigin:{enums:["anonymous","use-credentials","null"],multiple:!0},bgClip:{enums:["none","node"],multiple:!0},bgContainment:{enums:["inside","over"],multiple:!0},boxSelection:{enums:["contain","overlap","none"]},color:{color:!0},colors:{color:!0,multiple:!0},fill:{enums:["solid","linear-gradient","radial-gradient"]},bool:{enums:["yes","no"]},bools:{enums:["yes","no"],multiple:!0},lineStyle:{enums:["solid","dotted","dashed"]},lineCap:{enums:["butt","round","square"]},linePosition:{enums:["center","inside","outside"]},lineJoin:{enums:["round","bevel","miter"]},borderStyle:{enums:["solid","dotted","dashed","double"]},curveStyle:{enums:["bezier","unbundled-bezier","haystack","segments","straight","straight-triangle","taxi","round-segments","round-taxi"]},radiusType:{enums:["arc-radius","influence-radius"],multiple:!0},fontFamily:{regex:'^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'},fontStyle:{enums:["italic","normal","oblique"]},fontWeight:{enums:["normal","bold","bolder","lighter","100","200","300","400","500","600","800","900",100,200,300,400,500,600,700,800,900]},textDecoration:{enums:["none","underline","overline","line-through"]},textTransform:{enums:["none","uppercase","lowercase"]},textWrap:{enums:["none","wrap","ellipsis"]},textOverflowWrap:{enums:["whitespace","anywhere"]},textBackgroundShape:{enums:["rectangle","roundrectangle","round-rectangle","circle"]},nodeShape:{enums:["rectangle","roundrectangle","round-rectangle","cutrectangle","cut-rectangle","bottomroundrectangle","bottom-round-rectangle","barrel","ellipse","triangle","round-triangle","square","pentagon","round-pentagon","hexagon","round-hexagon","concavehexagon","concave-hexagon","heptagon","round-heptagon","octagon","round-octagon","tag","round-tag","star","diamond","round-diamond","vee","rhomboid","right-rhomboid","polygon"]},overlayShape:{enums:["roundrectangle","round-rectangle","ellipse"]},cornerRadius:{number:!0,min:0,units:"px|em",implicitUnits:"px",enums:["auto"]},compoundIncludeLabels:{enums:["include","exclude"]},arrowShape:{enums:["tee","triangle","triangle-tee","circle-triangle","triangle-cross","triangle-backcurve","vee","square","circle","diamond","chevron","none"]},arrowFill:{enums:["filled","hollow"]},arrowWidth:{number:!0,units:"%|px|em",implicitUnits:"px",enums:["match-line"]},display:{enums:["element","none"]},visibility:{enums:["hidden","visible"]},zCompoundDepth:{enums:["bottom","orphan","auto","top"]},zIndexCompare:{enums:["auto","manual"]},valign:{enums:["top","center","bottom"]},halign:{enums:["left","center","right"]},justification:{enums:["left","center","right","auto"]},text:{string:!0},data:{mapping:!0,regex:r("data")},layoutData:{mapping:!0,regex:r("layoutData")},scratch:{mapping:!0,regex:r("scratch")},mapData:{mapping:!0,regex:a("mapData")},mapLayoutData:{mapping:!0,regex:a("mapLayoutData")},mapScratch:{mapping:!0,regex:a("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:i,singleRegexMatchValue:!0},urls:{regexes:i,singleRegexMatchValue:!0,multiple:!0},propList:{propList:!0},angle:{number:!0,units:"deg|rad",implicitUnits:"rad"},textRotation:{number:!0,units:"deg|rad",implicitUnits:"rad",enums:["none","autorotate"]},polygonPointList:{number:!0,multiple:!0,evenMultiple:!0,min:-1,max:1,unitless:!0},edgeDistances:{enums:["intersection","node-position","endpoints"]},edgeEndpoint:{number:!0,multiple:!0,units:"%|px|em|deg|rad",implicitUnits:"px",enums:["inside-to-node","outside-to-node","outside-to-node-or-label","outside-to-line","outside-to-line-or-label"],singleEnum:!0,validate:function(e,t){switch(e.length){case 2:return"deg"!==t[0]&&"rad"!==t[0]&&"deg"!==t[1]&&"rad"!==t[1];case 1:return W(e[0])||"deg"===t[0]||"rad"===t[0];default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+e+")\\s*,\\s*("+e+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")\\s*\\)$"],enums:["linear","ease","ease-in","ease-out","ease-in-out","ease-in-sine","ease-out-sine","ease-in-out-sine","ease-in-quad","ease-out-quad","ease-in-out-quad","ease-in-cubic","ease-out-cubic","ease-in-out-cubic","ease-in-quart","ease-out-quart","ease-in-out-quart","ease-in-quint","ease-out-quint","ease-in-out-quint","ease-in-expo","ease-out-expo","ease-in-out-expo","ease-in-circ","ease-out-circ","ease-in-out-circ"]},gradientDirection:{enums:["to-bottom","to-top","to-left","to-right","to-bottom-right","to-bottom-left","to-top-right","to-top-left","to-right-bottom","to-left-bottom","to-right-top","to-left-top"]},boundsExpansion:{number:!0,multiple:!0,min:0,validate:function(e){var t=e.length;return 1===t||2===t||4===t}}};var o={zeroNonZero:function(e,t){return(null==e||null==t)&&e!==t||(0==e&&0!=t||0!=e&&0==t)},any:function(e,t){return e!=t},emptyNonEmpty:function(e,t){var n=ne(e),r=ne(t);return n&&!r||!n&&r}},s=vu.types,l=[{name:"label",type:s.text,triggersBounds:o.any,triggersZOrder:o.emptyNonEmpty},{name:"text-rotation",type:s.textRotation,triggersBounds:o.any},{name:"text-margin-x",type:s.bidirectionalSize,triggersBounds:o.any},{name:"text-margin-y",type:s.bidirectionalSize,triggersBounds:o.any}],u=[{name:"source-label",type:s.text,triggersBounds:o.any},{name:"source-text-rotation",type:s.textRotation,triggersBounds:o.any},{name:"source-text-margin-x",type:s.bidirectionalSize,triggersBounds:o.any},{name:"source-text-margin-y",type:s.bidirectionalSize,triggersBounds:o.any},{name:"source-text-offset",type:s.size,triggersBounds:o.any}],c=[{name:"target-label",type:s.text,triggersBounds:o.any},{name:"target-text-rotation",type:s.textRotation,triggersBounds:o.any},{name:"target-text-margin-x",type:s.bidirectionalSize,triggersBounds:o.any},{name:"target-text-margin-y",type:s.bidirectionalSize,triggersBounds:o.any},{name:"target-text-offset",type:s.size,triggersBounds:o.any}],d=[{name:"font-family",type:s.fontFamily,triggersBounds:o.any},{name:"font-style",type:s.fontStyle,triggersBounds:o.any},{name:"font-weight",type:s.fontWeight,triggersBounds:o.any},{name:"font-size",type:s.size,triggersBounds:o.any},{name:"text-transform",type:s.textTransform,triggersBounds:o.any},{name:"text-wrap",type:s.textWrap,triggersBounds:o.any},{name:"text-overflow-wrap",type:s.textOverflowWrap,triggersBounds:o.any},{name:"text-max-width",type:s.size,triggersBounds:o.any},{name:"text-outline-width",type:s.size,triggersBounds:o.any},{name:"line-height",type:s.positiveNumber,triggersBounds:o.any}],h=[{name:"text-valign",type:s.valign,triggersBounds:o.any},{name:"text-halign",type:s.halign,triggersBounds:o.any},{name:"color",type:s.color},{name:"text-outline-color",type:s.color},{name:"text-outline-opacity",type:s.zeroOneNumber},{name:"text-background-color",type:s.color},{name:"text-background-opacity",type:s.zeroOneNumber},{name:"text-background-padding",type:s.size,triggersBounds:o.any},{name:"text-border-opacity",type:s.zeroOneNumber},{name:"text-border-color",type:s.color},{name:"text-border-width",type:s.size,triggersBounds:o.any},{name:"text-border-style",type:s.borderStyle,triggersBounds:o.any},{name:"text-background-shape",type:s.textBackgroundShape,triggersBounds:o.any},{name:"text-justification",type:s.justification},{name:"box-select-labels",type:s.bool,triggersBounds:o.any}],f=[{name:"events",type:s.bool,triggersZOrder:o.any},{name:"text-events",type:s.bool,triggersZOrder:o.any},{name:"box-selection",type:s.boxSelection,triggersZOrder:o.any}],p=[{name:"display",type:s.display,triggersZOrder:o.any,triggersBounds:o.any,triggersBoundsOfConnectedEdges:o.any,triggersBoundsOfParallelEdges:function(e,t,n){return e!==t&&"bezier"===n.pstyle("curve-style").value}},{name:"visibility",type:s.visibility,triggersZOrder:o.any},{name:"opacity",type:s.zeroOneNumber,triggersZOrder:o.zeroNonZero},{name:"text-opacity",type:s.zeroOneNumber},{name:"min-zoomed-font-size",type:s.size},{name:"z-compound-depth",type:s.zCompoundDepth,triggersZOrder:o.any},{name:"z-index-compare",type:s.zIndexCompare,triggersZOrder:o.any},{name:"z-index",type:s.number,triggersZOrder:o.any}],v=[{name:"overlay-padding",type:s.size,triggersBounds:o.any},{name:"overlay-color",type:s.color},{name:"overlay-opacity",type:s.zeroOneNumber,triggersBounds:o.zeroNonZero},{name:"overlay-shape",type:s.overlayShape,triggersBounds:o.any},{name:"overlay-corner-radius",type:s.cornerRadius}],g=[{name:"underlay-padding",type:s.size,triggersBounds:o.any},{name:"underlay-color",type:s.color},{name:"underlay-opacity",type:s.zeroOneNumber,triggersBounds:o.zeroNonZero},{name:"underlay-shape",type:s.overlayShape,triggersBounds:o.any},{name:"underlay-corner-radius",type:s.cornerRadius}],y=[{name:"transition-property",type:s.propList},{name:"transition-duration",type:s.time},{name:"transition-delay",type:s.time},{name:"transition-timing-function",type:s.easing}],m=function(e,t){return"label"===t.value?-e.poolIndex():t.pfValue},b=[{name:"height",type:s.nodeSize,triggersBounds:o.any,hashOverride:m},{name:"width",type:s.nodeSize,triggersBounds:o.any,hashOverride:m},{name:"shape",type:s.nodeShape,triggersBounds:o.any},{name:"shape-polygon-points",type:s.polygonPointList,triggersBounds:o.any},{name:"corner-radius",type:s.cornerRadius},{name:"background-color",type:s.color},{name:"background-fill",type:s.fill},{name:"background-opacity",type:s.zeroOneNumber},{name:"background-blacken",type:s.nOneOneNumber},{name:"background-gradient-stop-colors",type:s.colors},{name:"background-gradient-stop-positions",type:s.percentages},{name:"background-gradient-direction",type:s.gradientDirection},{name:"padding",type:s.sizeMaybePercent,triggersBounds:o.any},{name:"padding-relative-to",type:s.paddingRelativeTo,triggersBounds:o.any},{name:"bounds-expansion",type:s.boundsExpansion,triggersBounds:o.any}],x=[{name:"border-color",type:s.color},{name:"border-opacity",type:s.zeroOneNumber},{name:"border-width",type:s.size,triggersBounds:o.any},{name:"border-style",type:s.borderStyle},{name:"border-cap",type:s.lineCap},{name:"border-join",type:s.lineJoin},{name:"border-dash-pattern",type:s.numbers},{name:"border-dash-offset",type:s.number},{name:"border-position",type:s.linePosition}],w=[{name:"outline-color",type:s.color},{name:"outline-opacity",type:s.zeroOneNumber},{name:"outline-width",type:s.size,triggersBounds:o.any},{name:"outline-style",type:s.borderStyle},{name:"outline-offset",type:s.size,triggersBounds:o.any}],E=[{name:"background-image",type:s.urls},{name:"background-image-crossorigin",type:s.bgCrossOrigin},{name:"background-image-opacity",type:s.zeroOneNumbers},{name:"background-image-containment",type:s.bgContainment},{name:"background-image-smoothing",type:s.bools},{name:"background-position-x",type:s.bgPos},{name:"background-position-y",type:s.bgPos},{name:"background-width-relative-to",type:s.bgRelativeTo},{name:"background-height-relative-to",type:s.bgRelativeTo},{name:"background-repeat",type:s.bgRepeat},{name:"background-fit",type:s.bgFit},{name:"background-clip",type:s.bgClip},{name:"background-width",type:s.bgWH},{name:"background-height",type:s.bgWH},{name:"background-offset-x",type:s.bgPos},{name:"background-offset-y",type:s.bgPos}],k=[{name:"position",type:s.position,triggersBounds:o.any},{name:"compound-sizing-wrt-labels",type:s.compoundIncludeLabels,triggersBounds:o.any},{name:"min-width",type:s.size,triggersBounds:o.any},{name:"min-width-bias-left",type:s.sizeMaybePercent,triggersBounds:o.any},{name:"min-width-bias-right",type:s.sizeMaybePercent,triggersBounds:o.any},{name:"min-height",type:s.size,triggersBounds:o.any},{name:"min-height-bias-top",type:s.sizeMaybePercent,triggersBounds:o.any},{name:"min-height-bias-bottom",type:s.sizeMaybePercent,triggersBounds:o.any}],T=[{name:"line-style",type:s.lineStyle},{name:"line-color",type:s.color},{name:"line-fill",type:s.fill},{name:"line-cap",type:s.lineCap},{name:"line-opacity",type:s.zeroOneNumber},{name:"line-dash-pattern",type:s.numbers},{name:"line-dash-offset",type:s.number},{name:"line-outline-width",type:s.size},{name:"line-outline-color",type:s.color},{name:"line-gradient-stop-colors",type:s.colors},{name:"line-gradient-stop-positions",type:s.percentages},{name:"curve-style",type:s.curveStyle,triggersBounds:o.any,triggersBoundsOfParallelEdges:function(e,t){return e!==t&&("bezier"===e||"bezier"===t)}},{name:"haystack-radius",type:s.zeroOneNumber,triggersBounds:o.any},{name:"source-endpoint",type:s.edgeEndpoint,triggersBounds:o.any},{name:"target-endpoint",type:s.edgeEndpoint,triggersBounds:o.any},{name:"control-point-step-size",type:s.size,triggersBounds:o.any},{name:"control-point-distances",type:s.bidirectionalSizes,triggersBounds:o.any},{name:"control-point-weights",type:s.numbers,triggersBounds:o.any},{name:"segment-distances",type:s.bidirectionalSizes,triggersBounds:o.any},{name:"segment-weights",type:s.numbers,triggersBounds:o.any},{name:"segment-radii",type:s.numbers,triggersBounds:o.any},{name:"radius-type",type:s.radiusType,triggersBounds:o.any},{name:"taxi-turn",type:s.bidirectionalSizeMaybePercent,triggersBounds:o.any},{name:"taxi-turn-min-distance",type:s.size,triggersBounds:o.any},{name:"taxi-direction",type:s.axisDirection,triggersBounds:o.any},{name:"taxi-radius",type:s.number,triggersBounds:o.any},{name:"edge-distances",type:s.edgeDistances,triggersBounds:o.any},{name:"arrow-scale",type:s.positiveNumber,triggersBounds:o.any},{name:"loop-direction",type:s.angle,triggersBounds:o.any},{name:"loop-sweep",type:s.angle,triggersBounds:o.any},{name:"source-distance-from-node",type:s.size,triggersBounds:o.any},{name:"target-distance-from-node",type:s.size,triggersBounds:o.any}],C=[{name:"ghost",type:s.bool,triggersBounds:o.any},{name:"ghost-offset-x",type:s.bidirectionalSize,triggersBounds:o.any},{name:"ghost-offset-y",type:s.bidirectionalSize,triggersBounds:o.any},{name:"ghost-opacity",type:s.zeroOneNumber}],P=[{name:"selection-box-color",type:s.color},{name:"selection-box-opacity",type:s.zeroOneNumber},{name:"selection-box-border-color",type:s.color},{name:"selection-box-border-width",type:s.size},{name:"active-bg-color",type:s.color},{name:"active-bg-opacity",type:s.zeroOneNumber},{name:"active-bg-size",type:s.size},{name:"outside-texture-bg-color",type:s.color},{name:"outside-texture-bg-opacity",type:s.zeroOneNumber}],S=[];vu.pieBackgroundN=16,S.push({name:"pie-size",type:s.sizeMaybePercent}),S.push({name:"pie-hole",type:s.sizeMaybePercent}),S.push({name:"pie-start-angle",type:s.angle});for(var B=1;B<=vu.pieBackgroundN;B++)S.push({name:"pie-"+B+"-background-color",type:s.color}),S.push({name:"pie-"+B+"-background-size",type:s.percent}),S.push({name:"pie-"+B+"-background-opacity",type:s.zeroOneNumber});var D=[];vu.stripeBackgroundN=16,D.push({name:"stripe-size",type:s.sizeMaybePercent}),D.push({name:"stripe-direction",type:s.axisDirectionPrimary});for(var _=1;_<=vu.stripeBackgroundN;_++)D.push({name:"stripe-"+_+"-background-color",type:s.color}),D.push({name:"stripe-"+_+"-background-size",type:s.percent}),D.push({name:"stripe-"+_+"-background-opacity",type:s.zeroOneNumber});var A=[],M=vu.arrowPrefixes=["source","mid-source","target","mid-target"];[{name:"arrow-shape",type:s.arrowShape,triggersBounds:o.any},{name:"arrow-color",type:s.color},{name:"arrow-fill",type:s.arrowFill},{name:"arrow-width",type:s.arrowWidth}].forEach((function(e){M.forEach((function(t){var n=t+"-"+e.name,r=e.type,a=e.triggersBounds;A.push({name:n,type:r,triggersBounds:a})}))}),{});var R=vu.properties=[].concat(f,y,p,v,g,C,h,d,l,u,c,b,x,w,E,S,D,k,T,A,P),I=vu.propertyGroups={behavior:f,transition:y,visibility:p,overlay:v,underlay:g,ghost:C,commonLabel:h,labelDimensions:d,mainLabel:l,sourceLabel:u,targetLabel:c,nodeBody:b,nodeBorder:x,nodeOutline:w,backgroundImage:E,pie:S,stripe:D,compound:k,edgeLine:T,edgeArrow:A,core:P},N=vu.propertyGroupNames={};(vu.propertyGroupKeys=Object.keys(I)).forEach((function(e){N[e]=I[e].map((function(e){return e.name})),I[e].forEach((function(t){return t.groupKey=e}))}));var L=vu.aliases=[{name:"content",pointsTo:"label"},{name:"control-point-distance",pointsTo:"control-point-distances"},{name:"control-point-weight",pointsTo:"control-point-weights"},{name:"segment-distance",pointsTo:"segment-distances"},{name:"segment-weight",pointsTo:"segment-weights"},{name:"segment-radius",pointsTo:"segment-radii"},{name:"edge-text-rotation",pointsTo:"text-rotation"},{name:"padding-left",pointsTo:"padding"},{name:"padding-right",pointsTo:"padding"},{name:"padding-top",pointsTo:"padding"},{name:"padding-bottom",pointsTo:"padding"}];vu.propertyNames=R.map((function(e){return e.name}));for(var z=0;z<R.length;z++){var O=R[z];R[O.name]=O}for(var V=0;V<L.length;V++){var F=L[V],X=R[F.pointsTo],j={name:F.name,alias:!0,pointsTo:X};R.push(j),R[F.name]=j}}(),vu.getDefaultProperty=function(e){return this.getDefaultProperties()[e]},vu.getDefaultProperties=function(){var e=this._private;if(null!=e.defaultProperties)return e.defaultProperties;for(var t=ge({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125,events:"yes","text-events":"no","text-valign":"top","text-halign":"center","text-justification":"auto","line-height":1,color:"#000","box-selection":"contain","text-outline-color":"#000","text-outline-width":0,"text-outline-opacity":1,"text-opacity":1,"text-decoration":"none","text-transform":"none","text-wrap":"none","text-overflow-wrap":"whitespace","text-max-width":9999,"text-background-color":"#000","text-background-opacity":0,"text-background-shape":"rectangle","text-background-padding":0,"text-border-opacity":0,"text-border-width":0,"text-border-style":"solid","text-border-color":"#000","font-family":"Helvetica Neue, Helvetica, sans-serif","font-style":"normal","font-weight":"normal","font-size":16,"min-zoomed-font-size":0,"text-rotation":"none","source-text-rotation":"none","target-text-rotation":"none",visibility:"visible",display:"element",opacity:1,"z-compound-depth":"auto","z-index-compare":"auto","z-index":0,label:"","text-margin-x":0,"text-margin-y":0,"source-label":"","source-text-offset":0,"source-text-margin-x":0,"source-text-margin-y":0,"target-label":"","target-text-offset":0,"target-text-margin-x":0,"target-text-margin-y":0,"overlay-opacity":0,"overlay-color":"#000","overlay-padding":10,"overlay-shape":"round-rectangle","overlay-corner-radius":"auto","underlay-opacity":0,"underlay-color":"#000","underlay-padding":10,"underlay-shape":"round-rectangle","underlay-corner-radius":"auto","transition-property":"none","transition-duration":0,"transition-delay":0,"transition-timing-function":"linear","box-select-labels":"no","background-blacken":0,"background-color":"#999","background-fill":"solid","background-opacity":1,"background-image":"none","background-image-crossorigin":"anonymous","background-image-opacity":1,"background-image-containment":"inside","background-image-smoothing":"yes","background-position-x":"50%","background-position-y":"50%","background-offset-x":0,"background-offset-y":0,"background-width-relative-to":"include-padding","background-height-relative-to":"include-padding","background-repeat":"no-repeat","background-fit":"none","background-clip":"node","background-width":"auto","background-height":"auto","border-color":"#000","border-opacity":1,"border-width":0,"border-style":"solid","border-dash-pattern":[4,2],"border-dash-offset":0,"border-cap":"butt","border-join":"miter","border-position":"center","outline-color":"#999","outline-opacity":1,"outline-width":0,"outline-offset":0,"outline-style":"solid",height:30,width:30,shape:"ellipse","shape-polygon-points":"-1, -1,   1, -1,   1, 1,   -1, 1","corner-radius":"auto","bounds-expansion":0,"background-gradient-direction":"to-bottom","background-gradient-stop-colors":"#999","background-gradient-stop-positions":"0%",ghost:"no","ghost-offset-y":0,"ghost-offset-x":0,"ghost-opacity":0,padding:0,"padding-relative-to":"width",position:"origin","compound-sizing-wrt-labels":"include","min-width":0,"min-width-bias-left":0,"min-width-bias-right":0,"min-height":0,"min-height-bias-top":0,"min-height-bias-bottom":0},{"pie-size":"100%","pie-hole":0,"pie-start-angle":"0deg"},[{name:"pie-{{i}}-background-color",value:"black"},{name:"pie-{{i}}-background-size",value:"0%"},{name:"pie-{{i}}-background-opacity",value:1}].reduce((function(e,t){for(var n=1;n<=vu.pieBackgroundN;n++){var r=t.name.replace("{{i}}",n),a=t.value;e[r]=a}return e}),{}),{"stripe-size":"100%","stripe-direction":"horizontal"},[{name:"stripe-{{i}}-background-color",value:"black"},{name:"stripe-{{i}}-background-size",value:"0%"},{name:"stripe-{{i}}-background-opacity",value:1}].reduce((function(e,t){for(var n=1;n<=vu.stripeBackgroundN;n++){var r=t.name.replace("{{i}}",n),a=t.value;e[r]=a}return e}),{}),{"line-style":"solid","line-color":"#999","line-fill":"solid","line-cap":"butt","line-opacity":1,"line-outline-width":0,"line-outline-color":"#000","line-gradient-stop-colors":"#999","line-gradient-stop-positions":"0%","control-point-step-size":40,"control-point-weights":.5,"segment-weights":.5,"segment-distances":20,"segment-radii":15,"radius-type":"arc-radius","taxi-turn":"50%","taxi-radius":15,"taxi-turn-min-distance":10,"taxi-direction":"auto","edge-distances":"intersection","curve-style":"haystack","haystack-radius":0,"arrow-scale":1,"loop-direction":"-45deg","loop-sweep":"-90deg","source-distance-from-node":0,"target-distance-from-node":0,"source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","line-dash-pattern":[6,3],"line-dash-offset":0},[{name:"arrow-shape",value:"none"},{name:"arrow-color",value:"#999"},{name:"arrow-fill",value:"filled"},{name:"arrow-width",value:1}].reduce((function(e,t){return vu.arrowPrefixes.forEach((function(n){var r=n+"-"+t.name,a=t.value;e[r]=a})),e}),{})),n={},r=0;r<this.properties.length;r++){var a=this.properties[r];if(!a.pointsTo){var i=a.name,o=t[i],s=this.parse(i,o);n[i]=s}}return e.defaultProperties=n,e.defaultProperties},vu.addDefaultStylesheet=function(){this.selector(":parent").css({shape:"rectangle",padding:10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3}).selector(":loop").css({"curve-style":"bezier"}).selector("edge:compound").css({"curve-style":"bezier","source-endpoint":"outside-to-line","target-endpoint":"outside-to-line"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector(":parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}),this.defaultLength=this.length};var gu={parse:function(e,t,n,r){var a=this;if(U(t))return a.parseImplWarn(e,t,n,r);var i,o=We(e,""+t,n?"t":"f","mapping"===r||!0===r||!1===r||null==r?"dontcare":r),s=a.propCache=a.propCache||[];return(i=s[o])||(i=s[o]=a.parseImplWarn(e,t,n,r)),(n||"mapping"===r)&&(i=it(i))&&(i.value=it(i.value)),i},parseImplWarn:function(e,t,n,r){var a=this.parseImpl(e,t,n,r);return a||null==t||at("The style property `".concat(e,": ").concat(t,"` is invalid")),!a||"width"!==a.name&&"height"!==a.name||"label"!==t||at("The style value of `label` is deprecated for `"+a.name+"`"),a}};gu.parseImpl=function(e,t,n,r){var a=this;e=ie(e);var i=a.properties[e],o=t,s=a.types;if(!i)return null;if(void 0===t)return null;i.alias&&(i=i.pointsTo,e=i.name);var l=W(t);l&&(t=t.trim());var u,c,d=i.type;if(!d)return null;if(n&&(""===t||null===t))return{name:e,value:t,bypass:!0,deleteBypass:!0};if(U(t))return{name:e,value:t,strValue:"fn",mapped:s.fn,bypass:n};if(!l||r||t.length<7||"a"!==t[1]);else{if(t.length>=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 v=this.parse(e,c[5]);if(!v||v.mapped)return!1;if(p.pfValue===v.pfValue||p.strValue===v.strValue)return at("`"+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 g=p.value,y=v.value;if(!(g[0]!==y[0]||g[1]!==y[1]||g[2]!==y[2]||g[3]!==y[3]&&(null!=g[3]&&1!==g[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:v.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;T<m.length;T++){var C=a.parse(e,m[T],n,"multiple");k=k||W(C.value),b.push(C.value),w.push(null!=C.pfValue?C.pfValue:C.value),x.push(C.units),E+=(T>0?" ":"")+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,B=function(){for(var r=0;r<d.enums.length;r++){if(d.enums[r]===t)return{name:e,value:t,strValue:""+t,bypass:n}}return null};if(d.number){var D,_="px";if(d.units&&(D=d.units),d.implicitUnits&&(_=d.implicitUnits),!d.unitless)if(l){var A="px|em"+(d.allowPercent?"|\\%":"");D&&(A=D);var M=t.match("^("+ce+")("+A+")?$");M&&(t=M[1],D=M[2]||_)}else D&&!d.implicitUnits||(D=_);if(t=parseFloat(t),isNaN(t)&&void 0===d.enums)return null;if(isNaN(t)&&void 0!==d.enums)return t=o,B();if(d.integer&&(!G(S=t)||Math.floor(S)!==S))return null;if(void 0!==d.min&&(t<d.min||d.strictMin&&t===d.min)||void 0!==d.max&&(t>d.max||d.strictMax&&t===d.max))return null;var R={name:e,value:t,strValue:""+t+(D||""),units:D,bypass:n};return d.unitless||"px"!==D&&"em"!==D?R.pfValue=t:R.pfValue="px"!==D&&D?this.getEmSizeInPixels()*t:t,"ms"!==D&&"s"!==D||(R.pfValue="ms"===D?t:1e3*t),"deg"!==D&&"rad"!==D||(R.pfValue="rad"===D?t:(P=t,Math.PI*P/180)),"%"===D&&(R.pfValue=t/100),R}if(d.propList){var I=[],N=""+t;if("none"===N);else{for(var L=N.split(/\s*,\s*|\s+/),z=0;z<L.length;z++){var O=L[z].trim();a.properties[O]?I.push(O):at("`"+O+"` is not a valid property name")}if(0===I.length)return null}return{name:e,value:I,strValue:0===I.length?"none":I.join(" "),bypass:n}}if(d.color){var V=ye(t);return V?{name:e,value:V,pfValue:V,strValue:"rgb("+V[0]+","+V[1]+","+V[2]+")",bypass:n}:null}if(d.regex||d.regexes){if(d.enums){var F=B();if(F)return F}for(var X=d.regexes?d.regexes:[d.regex],j=0;j<X.length;j++){var Y=new RegExp(X[j]).exec(t);if(Y)return{name:e,value:d.singleRegexMatchValue?Y[1]:Y,strValue:""+t,bypass:n}}return null}return d.string?{name:e,value:""+t,strValue:""+t,bypass:n}:d.enums?B():null};var yu=function(e){if(!(this instanceof yu))return new yu(e);ee(e)?(this._private={cy:e,coreStyle:{}},this.length=0,this.resetToDefault()):nt("A style must have a core reference")},mu=yu.prototype;mu.instanceString=function(){return"style"},mu.clear=function(){for(var e=this._private,t=e.cy.elements(),n=0;n<this.length;n++)this[n]=void 0;return this.length=0,e.contextStyles={},e.propDiffs={},this.cleanElements(t,!0),t.forEach((function(e){var t=e[0]._private;t.styleDirty=!0,t.appliedInitStyle=!1})),this},mu.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this},mu.core=function(e){return this._private.coreStyle[e]||this.getDefaultProperty(e)},mu.selector=function(e){var t="core"===e?null:new as(e),n=this.length++;return this[n]={selector:t,properties:[],mappedProperties:[],index:n},this},mu.css=function(){var e=arguments;if(1===e.length)for(var t=e[0],n=0;n<this.properties.length;n++){var r=this.properties[n],a=t[r.name];void 0===a&&(a=t[oe(r.name)]),void 0!==a&&this.cssRule(r.name,a)}else 2===e.length&&this.cssRule(e[0],e[1]);return this},mu.style=mu.css,mu.cssRule=function(e,t){var n=this.parse(e,t);if(n){var r=this.length-1;this[r].properties.push(n),this[r].properties[n.name]=n,n.name.match(/pie-(\d+)-background-size/)&&n.value&&(this._private.hasPie=!0),n.name.match(/stripe-(\d+)-background-size/)&&n.value&&(this._private.hasStripe=!0),n.mapped&&this[r].mappedProperties.push(n),!this[r].selector&&(this._private.coreStyle[n.name]=n)}return this},mu.append=function(e){return te(e)?e.appendToStyle(this):H(e)?this.appendFromJson(e):W(e)&&this.appendFromString(e),this},yu.fromJson=function(e,t){var n=new yu(e);return n.fromJson(t),n},yu.fromString=function(e,t){return new yu(e).fromString(t)},[lu,cu,du,hu,fu,pu,vu,gu].forEach((function(e){ge(mu,e)})),yu.types=mu.types,yu.properties=mu.properties,yu.propertyGroups=mu.propertyGroups,yu.propertyGroupNames=mu.propertyGroupNames,yu.propertyGroupKeys=mu.propertyGroupKeys;var bu={style:function(e){e&&this.setStyle(e).update();return this._private.style},setStyle:function(e){var t=this._private;return te(e)?t.style=e.generateStyle(this):H(e)?t.style=yu.fromJson(this,e):W(e)?t.style=yu.fromString(this,e):t.style=yu(this),t.style},updateStyle:function(){this.mutableElements().updateStyle()}},xu={autolock:function(e){return void 0===e?this._private.autolock:(this._private.autolock=!!e,this)},autoungrabify:function(e){return void 0===e?this._private.autoungrabify:(this._private.autoungrabify=!!e,this)},autounselectify:function(e){return void 0===e?this._private.autounselectify:(this._private.autounselectify=!!e,this)},selectionType:function(e){var t=this._private;return null==t.selectionType&&(t.selectionType="single"),void 0===e?t.selectionType:("additive"!==e&&"single"!==e||(t.selectionType=e),this)},panningEnabled:function(e){return void 0===e?this._private.panningEnabled:(this._private.panningEnabled=!!e,this)},userPanningEnabled:function(e){return void 0===e?this._private.userPanningEnabled:(this._private.userPanningEnabled=!!e,this)},zoomingEnabled:function(e){return void 0===e?this._private.zoomingEnabled:(this._private.zoomingEnabled=!!e,this)},userZoomingEnabled:function(e){return void 0===e?this._private.userZoomingEnabled:(this._private.userZoomingEnabled=!!e,this)},boxSelectionEnabled:function(e){return void 0===e?this._private.boxSelectionEnabled:(this._private.boxSelectionEnabled=!!e,this)},pan:function(){var e,t,n,r,a,i=arguments,o=this._private.pan;switch(i.length){case 0:return o;case 1:if(W(i[0]))return o[e=i[0]];if(K(i[0])){if(!this._private.panningEnabled)return this;r=(n=i[0]).x,a=n.y,G(r)&&(o.x=r),G(a)&&(o.y=a),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;t=i[1],"x"!==(e=i[0])&&"y"!==e||!G(t)||(o[e]=t),this.emit("pan viewport")}return this.notify("viewport"),this},panBy:function(e,t){var n,r,a,i,o,s=arguments,l=this._private.pan;if(!this._private.panningEnabled)return this;switch(s.length){case 1:K(e)&&(i=(a=s[0]).x,o=a.y,G(i)&&(l.x+=i),G(o)&&(l.y+=o),this.emit("pan viewport"));break;case 2:r=t,"x"!==(n=e)&&"y"!==n||!G(r)||(l[n]+=r),this.emit("pan viewport")}return this.notify("viewport"),this},gc:function(){this.notify("gc")},fit:function(e,t){var n=this.getFitViewport(e,t);if(n){var r=this._private;r.zoom=n.zoom,r.pan=n.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,t){if(G(e)&&void 0===t&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){var n,r;if(W(e)){var a=e;e=this.$(a)}else if(K(r=e)&&G(r.x1)&&G(r.x2)&&G(r.y1)&&G(r.y2)){var i=e;(n={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2}).w=n.x2-n.x1,n.h=n.y2-n.y1}else $(e)||(e=this.mutableElements());if(!$(e)||!e.empty()){n=n||e.boundingBox();var o,s=this.width(),l=this.height();if(t=G(t)?t:0,!isNaN(s)&&!isNaN(l)&&s>0&&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)<this._private.minZoom?this._private.minZoom:o,pan:{x:(s-o*(n.x1+n.x2))/2,y:(l-o*(n.y1+n.y2))/2}}}}},zoomRange:function(e,t){var n=this._private;if(null==t){var r=e;e=r.min,t=r.max}return G(e)&&G(t)&&e<=t?(n.minZoom=e,n.maxZoom=t):G(e)&&void 0===t&&e<=n.maxZoom?n.minZoom=e:G(t)&&void 0===e&&t>=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=Xt(e.position,i,a):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||r.panningEnabled||(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)<r.minZoom?r.minZoom:n,o||!G(n)||n===i||null!=t&&(!G(t.x)||!G(t.y)))return null;if(null!=t){var s=a,l=i,u=n;return{zoomed:!0,panned:!0,zoom:u,pan:{x:-u/l*(t.x-s.x)+t.x,y:-u/l*(t.y-s.y)+t.y}}}return{zoomed:!0,panned:!1,zoom:n,pan:a}},zoom:function(e){if(void 0===e)return this._private.zoom;var t=this.getZoomedViewport(e),n=this._private;return null!=t&&t.zoomed?(n.zoom=t.zoom,t.panned&&(n.pan.x=t.pan.x,n.pan.y=t.pan.y),this.emit("zoom"+(t.panned?" pan":"")+" viewport"),this.notify("viewport"),this):this},viewport:function(e){var t=this._private,n=!0,r=!0,a=[],i=!1,o=!1;if(!e)return this;if(G(e.zoom)||(n=!1),K(e.pan)||(r=!1),!n&&!r)return this;if(n){var s=e.zoom;s<t.minZoom||s>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 $(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}};xu.centre=xu.center,xu.autolockNodes=xu.autolock,xu.autoungrabifyNodes=xu.autoungrabify;var wu={data:xo.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:xo.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:xo.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:xo.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};wu.attr=wu.data,wu.removeAttr=wu.removeData;var Eu=function(e){var t=this,n=(e=ge({},e)).container;n&&!Z(n)&&Z(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=ge({name:i?"grid":"null"},o.layout),o.renderer=ge({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 Ol(this),listeners:[],aniEles:new Ol(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=ge({},o,o.renderer);t.initRenderer(u);!function(e,t){if(e.some(re))return Hr.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=ge({},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;e<a.length;e++){var n=a[e];t.on("ready",n)}r&&(r.readies=[]),t.emit("ready")}),o.done)}))},ku=Eu.prototype;ge(ku,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},destroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){var e=this;if(!e.destroyed())return e.stopAnimationLoop(),e.destroyRenderer(),this.emit("destroy"),e._private.destroyed=!0,e},hasElementWithId:function(e){return this._private.elements.hasElementWithId(e)},getElementById:function(e){return this._private.elements.getElementById(e)},hasCompoundNodes:function(){return this._private.hasCompoundNodes},headless:function(){return this._private.renderer.isHeadless()},styleEnabled:function(){return this._private.styleEnabled},addToPool:function(e){return this._private.elements.merge(e),this},removeFromPool:function(e){return this._private.elements.unmerge(e),this},container:function(){return this._private.container||null},window:function(){if(null==this._private.container)return c;var e=this._private.container.ownerDocument;return void 0===e||null==e?c:e.defaultView||c},mount:function(e){if(null!=e){var t=this,n=t._private,r=n.options;return!Z(e)&&Z(e[0])&&(e=e[0]),t.stopAnimationLoop(),t.destroyRenderer(),n.container=e,n.styleEnabled=!0,t.invalidateSize(),t.initRenderer(ge({},r,r.renderer,{name:"null"===r.renderer.name?"canvas":r.renderer.name})),t.startAnimationLoop(),t.style(r.style),t.emit("mount"),t}},unmount:function(){var e=this;return e.stopAnimationLoop(),e.destroyRenderer(),e.initRenderer({name:"null"}),e.emit("unmount"),e},options:function(){return it(this._private.options)},json:function(e){var t=this,n=t._private,r=t.mutableElements();if(K(e)){if(t.startBatch(),e.elements){var a={},i=function(e,n){for(var r=[],i=[],o=0;o<e.length;o++){var s=e[o];if(s.data.id){var l=""+s.data.id,u=t.getElementById(l);a[l]=!0,0!==u.length?i.push({ele:u,json:s}):n?(s.group=n,r.push(s)):r.push(s)}else at("cy.json() cannot handle elements without an ID attribute")}t.add(r);for(var c=0;c<i.length;c++){var d=i[c],h=d.ele,f=d.json;h.json(f)}};if(H(e.elements))i(e.elements);else for(var o=["nodes","edges"],s=0;s<o.length;s++){var l=o[s],u=e.elements[l];H(u)&&i(u,l)}var c=t.collection();r.filter((function(e){return!a[e.id()]})).forEach((function(e){e.isParent()?c.merge(e):e.remove()})),c.forEach((function(e){return e.children().move({parent:null})})),c.forEach((function(e){return function(e){return t.getElementById(e.id())}(e).remove()}))}e.style&&t.style(e.style),null!=e.zoom&&e.zoom!==n.zoom&&t.zoom(e.zoom),e.pan&&(e.pan.x===n.pan.x&&e.pan.y===n.pan.y||t.pan(e.pan)),e.data&&t.data(e.data);for(var d=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify","multiClickDebounceTime"],h=0;h<d.length;h++){var f=d[h];null!=e[f]&&t[f](e[f])}return t.endBatch(),this}var p={};!!e?p.elements=this.elements().map((function(e){return e.json()})):(p.elements={},r.forEach((function(e){var t=e.group();p.elements[t]||(p.elements[t]=[]),p.elements[t].push(e.json())}))),this._private.styleEnabled&&(p.style=t.style().json()),p.data=it(t.data());var v=n.options;return p.zoomingEnabled=n.zoomingEnabled,p.userZoomingEnabled=n.userZoomingEnabled,p.zoom=n.zoom,p.minZoom=n.minZoom,p.maxZoom=n.maxZoom,p.panningEnabled=n.panningEnabled,p.userPanningEnabled=n.userPanningEnabled,p.pan=it(n.pan),p.boxSelectionEnabled=n.boxSelectionEnabled,p.renderer=it(v.renderer),p.hideEdgesOnViewport=v.hideEdgesOnViewport,p.textureOnViewport=v.textureOnViewport,p.wheelSensitivity=v.wheelSensitivity,p.motionBlur=v.motionBlur,p.multiClickDebounceTime=v.multiClickDebounceTime,p}}),ku.$id=ku.getElementById,[Fl,Ql,tu,nu,ru,au,ou,su,bu,xu,wu].forEach((function(e){ge(ku,e)}));var Tu={fit:!0,directed:!1,direction:"downward",padding:30,circle:!1,grid:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,depthSort: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}},Cu={maximal:!1,acyclic:!1},Pu=function(e){return e.scratch("breadthfirst")},Su=function(e,t){return e.scratch("breadthfirst",t)};function Bu(e){this.options=ge({},Tu,Cu,e)}Bu.prototype.run=function(){var e,t=this.options,n=t.cy,r=t.eles,a=r.nodes().filter((function(e){return e.isChildless()})),i=r,o=t.directed,s=t.acyclic||t.maximal||t.maximalAdjustments>0,l=!!t.boundingBox,u=Jt(l?t.boundingBox:structuredClone(n.extent()));if($(t.roots))e=t.roots;else if(H(t.roots)){for(var c=[],d=0;d<t.roots.length;d++){var h=t.roots[d],f=n.getElementById(h);c.push(f)}e=n.collection(c)}else if(W(t.roots))e=n.$(t.roots);else if(o)e=a.roots();else{var p=r.components();e=n.collection();for(var v=function(){var t=p[g],n=t.maxDegree(!1),r=t.filter((function(e){return e.degree(!1)===n}));e=e.add(r)},g=0;g<p.length;g++)v()}var y=[],m={},b=function(e,t){null==y[t]&&(y[t]=[]);var n=y[t].length;y[t].push(e),Su(e,{index:n,depth:t})};i.bfs({roots:e,directed:t.directed,visit:function(e,t,n,r,a){var i=e[0],o=i.id();i.isChildless()&&b(i,a),m[o]=!0}});for(var x=[],w=0;w<a.length;w++){var E=a[w];m[E.id()]||x.push(E)}var k=function(e){for(var t=y[e],n=0;n<t.length;n++){var r=t[n];null!=r?Su(r,{depth:e,index:n}):(t.splice(n,1),n--)}},T=function(e,n){for(var a=Pu(e),i=e.incomers().filter((function(e){return e.isNode()&&r.has(e)})),o=-1,s=e.id(),l=0;l<i.length;l++){var u=i[l],c=Pu(u);o=Math.max(o,c.depth)}if(a.depth<=o){if(!t.acyclic&&n[s])return null;var d=o+1;return function(e,t){var n=Pu(e),r=n.depth,a=n.index;y[r][a]=null,e.isChildless()&&b(e,t)}(e,d),n[s]=d,!0}return!1};if(o&&s){var C=[],P={},S=function(e){return C.push(e)};for(a.forEach((function(e){return C.push(e)}));C.length>0;){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){at("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;A<a.length;A++){var M=a[A].layoutDimensions(t),R=M.w,I=M.h;_=Math.max(_,R,I)}var N={},L=function(e){if(N[e.id()])return N[e.id()];for(var t=Pu(e).depth,n=e.neighborhood(),r=0,i=0,o=0;o<n.length;o++){var s=n[o];if(!s.isEdge()&&!s.isParent()&&a.has(s)){var l=Pu(s);if(null!=l){var u=l.index,c=l.depth;if(null!=u&&null!=c){var d=y[c].length;c<t&&(r+=u/d,i++)}}}}return r/=i=Math.max(1,i),0===i&&(r=0),N[e.id()]=r,r},z=function(e,t){var n=L(e)-L(t);return 0===n?ve(e.id(),t.id()):n};void 0!==t.depthSort&&(z=t.depthSort);for(var O=y.length,V=0;V<O;V++)y[V].sort(z),k(V);for(var F=[],X=0;X<x.length;X++)F.push(x[X]);F.length&&(y.unshift(F),O=y.length,function(){for(var e=0;e<O;e++)k(e)}());for(var j=0,Y=0;Y<O;Y++)j=Math.max(y[Y].length,j);var q=u.x1+u.w/2,U=u.y1+u.h/2,K=a.reduce((function(e,n){return r=n.boundingBox({includeLabels:t.nodeDimensionsIncludeLabels}),{w:-1===e.w?r.w:(e.w+r.w)/2,h:-1===e.h?r.h:(e.h+r.h)/2};var r}),{w:-1,h:-1}),G=Math.max(1===O?0:l?(u.h-2*t.padding-K.h)/(O-1):(u.h-2*t.padding-K.h)/(O+1),_),Z=y.reduce((function(e,t){return Math.max(e,t.length)}),0),Q={downward:0,leftward:90,upward:180,rightward:-90};-1===Object.keys(Q).indexOf(t.direction)&&nt("Invalid direction '".concat(t.direction,"' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(Q).join(", ")));return r.nodes().layoutPositions(this,t,(function(e){return He(function(e){var n=Pu(e),r=n.depth,a=n.index;if(t.circle){var i=Math.min(u.w/2/O,u.h/2/O),o=(i=Math.max(i,_))*r+i-(O>0&&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,Q[t.direction])})),this};var Du={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 _u(e){this.options=ge({},Du,e)}_u.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=Jt(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;h<i.length;h++){var f=i[h].layoutDimensions(t),p=f.w,v=f.h;d=Math.max(d,p,v)}if(o=G(t.radius)?t.radius:i.length<=1?0:Math.min(s.h,s.w)/2-d,i.length>1&&t.avoidOverlap){d*=1.75;var g=Math.cos(c)-Math.cos(0),y=Math.sin(c)-Math.sin(0),m=Math.sqrt(d*d/(g*g+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 Au,Mu={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 Ru(e){this.options=ge({},Mu,e)}Ru.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=Jt(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;d<i.length;d++){var h,f=i[d];h=t.concentric(f),u.push({value:h,node:f}),f._private.scratch.concentric=h}i.updateStyle();for(var p=0;p<i.length;p++){var v=i[p].layoutDimensions(t);c=Math.max(c,v.w,v.h)}u.sort((function(e,t){return t.value-e.value}));for(var g=t.levelWidth(i),y=[[]],m=y[0],b=0;b<u.length;b++){var x=u[b];if(m.length>0)Math.abs(m[0].value-x.value)>=g&&(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;C<y.length;C++){var P=y[C],S=void 0===t.sweep?2*Math.PI-2*Math.PI/P.length:t.sweep,B=P.dTheta=S/Math.max(1,P.length-1);if(P.length>1&&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<y.length;I++){var N=y[I].r-R;M=Math.max(M,N)}R=0;for(var L=0;L<y.length;L++){var z=y[L];0===L&&(R=z.r),z.r=R,R+=M}}for(var O={},V=0;V<y.length;V++)for(var F=y[V],X=F.dTheta,j=F.r,Y=0;Y<F.length;Y++){var q=F[Y],W=t.startAngle+(n?1:-1)*X*Y,U={x:s+j*Math.cos(W),y:l+j*Math.sin(W)};O[q.node.id()]=U}return a.nodes().layoutPositions(this,t,(function(e){var t=e.id();return O[t]})),this};var Iu={ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,t){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!1,randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:1e3,initialTemp:1e3,coolingFactor:.99,minTemp:1};function Nu(e){this.options=ge({},Iu,e),this.options.layout=this;var t=this.options.eles.nodes(),n=this.options.eles.edges().filter((function(e){var n=e.source().data("id"),r=e.target().data("id"),a=t.some((function(e){return e.data("id")===n})),i=t.some((function(e){return e.data("id")===r}));return!a||!i}));this.options.eles=this.options.eles.not(n)}Nu.prototype.run=function(){var e=this.options,t=e.cy,n=this;n.stopped=!1,!0!==e.animate&&!1!==e.animate||n.emit({type:"layoutstart",layout:n}),Au=!0===e.debug;var r=Lu(t,n,e);Au&&undefined(r),e.randomize&&Vu(r);var a=Ne(),i=function(){Xu(r,t,e),!0===e.fit&&t.fit(e.padding)},o=function(t){return!(n.stopped||t>=e.numIter)&&(ju(r,e),r.temperature=r.temperature*e.coolingFactor,!(r.temperature<e.minTemp))},s=function(){if(!0===e.animate||!1===e.animate)i(),n.one("layoutstop",e.stop),n.emit({type:"layoutstop",layout:n});else{var t=e.eles.nodes(),a=Fu(r,e,t);t.layoutPositions(n,e,a)}},l=0,u=!0;if(!0===e.animate){var c=function(){for(var t=0;u&&t<e.refresh;)u=o(l),l++,t++;u?(Ne()-a>=e.animationThreshold&&i(),Ie(c)):(ec(r,e),s())};c()}else{for(;u;)u=o(l),l++;ec(r,e),s()}return this},Nu.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},Nu.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Lu=function(e,t,n){for(var r=n.eles.edges(),a=n.eles.nodes(),i=Jt(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;u<s.length;u++)for(var c=s[u],d=0;d<c.length;d++){l[c[d].id()]=u}for(u=0;u<o.nodeSize;u++){var h=(y=a[u]).layoutDimensions(n);(R={}).isLocked=y.locked(),R.id=y.data("id"),R.parentId=y.data("parent"),R.cmptId=l[y.id()],R.children=[],R.positionX=y.position("x"),R.positionY=y.position("y"),R.offsetX=0,R.offsetY=0,R.height=h.w,R.width=h.h,R.maxX=R.positionX+R.width/2,R.minX=R.positionX-R.width/2,R.maxY=R.positionY+R.height/2,R.minY=R.positionY-R.height/2,R.padLeft=parseFloat(y.style("padding")),R.padRight=parseFloat(y.style("padding")),R.padTop=parseFloat(y.style("padding")),R.padBottom=parseFloat(y.style("padding")),R.nodeRepulsion=U(n.nodeRepulsion)?n.nodeRepulsion(y):n.nodeRepulsion,o.layoutNodes.push(R),o.idToIndex[R.id]=u}var f=[],p=0,v=-1,g=[];for(u=0;u<o.nodeSize;u++){var y,m=(y=o.layoutNodes[u]).parentId;null!=m?o.layoutNodes[o.idToIndex[m]].children.push(y.id):(f[++v]=y.id,g.push(y.id))}for(o.graphSet.push(g);p<=v;){var b=f[p++],x=o.idToIndex[b],w=o.layoutNodes[x].children;if(w.length>0){o.graphSet.push(w);for(u=0;u<w.length;u++)f[++v]=w[u]}}for(u=0;u<o.graphSet.length;u++){var E=o.graphSet[u];for(d=0;d<E.length;d++){var k=o.idToIndex[E[d]];o.indexToGraph[k]=u}}for(u=0;u<o.edgeSize;u++){var T=r[u],C={};C.id=T.data("id"),C.sourceId=T.data("source"),C.targetId=T.data("target");var P=U(n.idealEdgeLength)?n.idealEdgeLength(T):n.idealEdgeLength,S=U(n.edgeElasticity)?n.edgeElasticity(T):n.edgeElasticity,B=o.idToIndex[C.sourceId],D=o.idToIndex[C.targetId];if(o.indexToGraph[B]!=o.indexToGraph[D]){for(var _=zu(C.sourceId,C.targetId,o),A=o.graphSet[_],M=0,R=o.layoutNodes[B];-1===A.indexOf(R.id);)R=o.layoutNodes[o.idToIndex[R.parentId]],M++;for(R=o.layoutNodes[D];-1===A.indexOf(R.id);)R=o.layoutNodes[o.idToIndex[R.parentId]],M++;P*=M*n.nestingFactor}C.idealLength=P,C.elasticity=S,o.layoutEdges.push(C)}return o},zu=function(e,t,n){var r=Ou(e,t,0,n);return 2>r.count?0:r.graph},Ou=function(e,t,n,r){var a=r.graphSet[n];if(-1<a.indexOf(e)&&-1<a.indexOf(t))return{count:2,graph:n};for(var i=0,o=0;o<a.length;o++){var s=a[o],l=r.idToIndex[s],u=r.layoutNodes[l].children;if(0!==u.length){var c=r.indexToGraph[r.idToIndex[u[0]]],d=Ou(e,t,c,r);if(0!==d.count){if(1!==d.count)return d;if(2===++i)break}}}return{count:i,graph:n}},Vu=function(e,t){for(var n=e.clientWidth,r=e.clientHeight,a=0;a<e.nodeSize;a++){var i=e.layoutNodes[a];0!==i.children.length||i.isLocked||(i.positionX=Math.random()*n,i.positionY=Math.random()*r)}},Fu=function(e,t,n){var r=e.boundingBox,a={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return t.boundingBox&&(n.forEach((function(t){var n=e.layoutNodes[e.idToIndex[t.data("id")]];a.x1=Math.min(a.x1,n.positionX),a.x2=Math.max(a.x2,n.positionX),a.y1=Math.min(a.y1,n.positionY),a.y2=Math.max(a.y2,n.positionY)})),a.w=a.x2-a.x1,a.h=a.y2-a.y1),function(n,i){var o=e.layoutNodes[e.idToIndex[n.data("id")]];if(t.boundingBox){var s=0===a.w?.5:(o.positionX-a.x1)/a.w,l=0===a.h?.5:(o.positionY-a.y1)/a.h;return{x:r.x1+s*r.w,y:r.y1+l*r.h}}return{x:o.positionX,y:o.positionY}}},Xu=function(e,t,n){var r=n.layout,a=n.eles.nodes(),i=Fu(e,n,a);a.positions(i),!0!==e.ready&&(e.ready=!0,r.one("layoutready",n.ready),r.emit({type:"layoutready",layout:this}))},ju=function(e,t,n){Yu(e,t),Ku(e),Gu(e,t),Zu(e),$u(e)},Yu=function(e,t){for(var n=0;n<e.graphSet.length;n++)for(var r=e.graphSet[n],a=r.length,i=0;i<a;i++)for(var o=e.layoutNodes[e.idToIndex[r[i]]],s=i+1;s<a;s++){var l=e.layoutNodes[e.idToIndex[r[s]]];Wu(o,l,e,t)}},qu=function(e){return 2*e*Math.random()-1},Wu=function(e,t,n,r){if(e.cmptId===t.cmptId||n.isCompound){var a=t.positionX-e.positionX,i=t.positionY-e.positionY;0===a&&0===i&&(a=qu(1),i=qu(1));var o=Uu(e,t,a,i);if(o>0)var s=(u=r.nodeOverlap*o)*a/(v=Math.sqrt(a*a+i*i)),l=u*i/v;else{var u,c=Hu(e,a,i),d=Hu(t,-1*a,-1*i),h=d.x-c.x,f=d.y-c.y,p=h*h+f*f,v=Math.sqrt(p);s=(u=(e.nodeRepulsion+t.nodeRepulsion)/p)*h/v,l=u*f/v}e.isLocked||(e.offsetX-=s,e.offsetY-=l),t.isLocked||(t.offsetX+=s,t.offsetY+=l)}},Uu=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},Hu=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&&0<n||0===t&&0>n?(u.x=r,u.y=a+i/2,u):0<t&&-1*l<=s&&s<=l?(u.x=r+o/2,u.y=a+o*n/2/t,u):0>t&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=a-o*n/2/t,u):0<n&&(s<=-1*l||s>=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},Ku=function(e,t){for(var n=0;n<e.edgeSize;n++){var r=e.layoutEdges[n],a=e.idToIndex[r.sourceId],i=e.layoutNodes[a],o=e.idToIndex[r.targetId],s=e.layoutNodes[o],l=s.positionX-i.positionX,u=s.positionY-i.positionY;if(0!==l||0!==u){var c=Hu(i,l,u),d=Hu(s,-1*l,-1*u),h=d.x-c.x,f=d.y-c.y,p=Math.sqrt(h*h+f*f),v=Math.pow(r.idealLength-p,2)/r.elasticity;if(0!==p)var g=v*h/p,y=v*f/p;else g=0,y=0;i.isLocked||(i.offsetX+=g,i.offsetY+=y),s.isLocked||(s.offsetX-=g,s.offsetY-=y)}}},Gu=function(e,t){if(0!==t.gravity)for(var n=0;n<e.graphSet.length;n++){var r=e.graphSet[n],a=r.length;if(0===n)var i=e.clientHeight/2,o=e.clientWidth/2;else{var s=e.layoutNodes[e.idToIndex[r[0]]],l=e.layoutNodes[e.idToIndex[s.parentId]];i=l.positionX,o=l.positionY}for(var u=0;u<a;u++){var c=e.layoutNodes[e.idToIndex[r[u]]];if(!c.isLocked){var d=i-c.positionX,h=o-c.positionY,f=Math.sqrt(d*d+h*h);if(f>1){var p=t.gravity*d/f,v=t.gravity*h/f;c.offsetX+=p,c.offsetY+=v}}}}},Zu=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(0<l.length&&!s.isLocked){for(var u=s.offsetX,c=s.offsetY,d=0;d<l.length;d++){var h=e.layoutNodes[e.idToIndex[l[d]]];h.offsetX+=u,h.offsetY+=c,n[++a]=l[d]}s.offsetX=0,s.offsetY=0}}},$u=function(e,t){for(var n=0;n<e.nodeSize;n++){0<(a=e.layoutNodes[n]).children.length&&(a.maxX=void 0,a.minX=void 0,a.maxY=void 0,a.minY=void 0)}for(n=0;n<e.nodeSize;n++){if(!(0<(a=e.layoutNodes[n]).children.length||a.isLocked)){var r=Qu(a.offsetX,a.offsetY,e.temperature);a.positionX+=r.x,a.positionY+=r.y,a.offsetX=0,a.offsetY=0,a.minX=a.positionX-a.width,a.maxX=a.positionX+a.width,a.minY=a.positionY-a.height,a.maxY=a.positionY+a.height,Ju(a,e)}}for(n=0;n<e.nodeSize;n++){var a;0<(a=e.layoutNodes[n]).children.length&&!a.isLocked&&(a.positionX=(a.maxX+a.minX)/2,a.positionY=(a.maxY+a.minY)/2,a.width=a.maxX-a.minX,a.height=a.maxY-a.minY)}},Qu=function(e,t,n){var r=Math.sqrt(e*e+t*t);if(r>n)var a={x:n*e/r,y:n*t/r};else a={x:e,y:t};return a},Ju=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.padLeft<r.minX)&&(r.minX=e.minX-r.padLeft,a=!0),(null==r.maxY||e.maxY+r.padBottom>r.maxY)&&(r.maxY=e.maxY+r.padBottom,a=!0),(null==r.minY||e.minY-r.padTop<r.minY)&&(r.minY=e.minY-r.padTop,a=!0),a?Ju(r,t):void 0}},ec=function(e,t){for(var n=e.layoutNodes,r=[],a=0;a<n.length;a++){var i=n[a],o=i.cmptId;(r[o]=r[o]||[]).push(i)}var s=0;for(a=0;a<r.length;a++){if(v=r[a]){v.x1=1/0,v.x2=-1/0,v.y1=1/0,v.y2=-1/0;for(var l=0;l<v.length;l++){var u=v[l];v.x1=Math.min(v.x1,u.positionX-u.width/2),v.x2=Math.max(v.x2,u.positionX+u.width/2),v.y1=Math.min(v.y1,u.positionY-u.height/2),v.y2=Math.max(v.y2,u.positionY+u.height/2)}v.w=v.x2-v.x1,v.h=v.y2-v.y1,s+=v.w*v.h}}r.sort((function(e,t){return t.w*t.h-e.w*e.h}));var c=0,d=0,h=0,f=0,p=Math.sqrt(s)*e.clientWidth/e.clientHeight;for(a=0;a<r.length;a++){var v;if(v=r[a]){for(l=0;l<v.length;l++){(u=v[l]).isLocked||(u.positionX+=c-v.x1,u.positionY+=d-v.y1)}c+=v.w+t.componentSpacing,h+=v.w+t.componentSpacing,f=Math.max(f,v.h),h>p&&(d+=f+t.componentSpacing,c=0,h=0,f=0)}}},tc={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 nc(e){this.options=ge({},tc,e)}nc.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=Jt(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(),v=d();(p-1)*v>=o?c(p-1):(v-1)*p>=o&&d(v-1)}else for(;u*l<o;){var g=c(),y=d();(y+1)*g>=o?d(y+1):c(g+1)}var m=i.w/u,b=i.h/l;if(t.condense&&(m=0,b=0),t.avoidOverlap)for(var x=0;x<a.length;x++){var w=a[x],E=w._private.position;null!=E.x&&null!=E.y||(E.x=0,E.y=0);var k=w.layoutDimensions(t),T=t.avoidOverlapPadding,C=k.w+T,P=k.h+T;m=Math.max(m,C),b=Math.max(b,P)}for(var S={},B=function(e,t){return!!S["c-"+e+"-"+t]},D=function(e,t){S["c-"+e+"-"+t]=!0},_=0,A=0,M=function(){++A>=u&&(A=0,_++)},R={},I=0;I<a.length;I++){var N=a[I],L=t.position(N);if(L&&(void 0!==L.row||void 0!==L.col)){var z={row:L.row,col:L.col};if(void 0===z.col)for(z.col=0;B(z.row,z.col);)z.col++;else if(void 0===z.row)for(z.row=0;B(z.row,z.col);)z.row++;R[N.id()]=z,D(z.row,z.col)}}a.layoutPositions(this,t,(function(e,t){var n,r;if(e.locked()||e.isParent())return!1;var a=R[e.id()];if(a)n=a.col*m+m/2+i.x1,r=a.row*b+b/2+i.y1;else{for(;B(_,A);)M();n=A*m+m/2+i.x1,r=_*b+b/2+i.y1,D(_,A),M()}return{x:n,y:r}}))}return this};var rc={ready:function(){},stop:function(){}};function ac(e){this.options=ge({},rc,e)}ac.prototype.run=function(){var e=this.options,t=e.eles,n=this;return e.cy,n.emit("layoutstart"),t.nodes().positions((function(){return{x:0,y:0}})),n.one("layoutready",e.ready),n.emit("layoutready"),n.one("layoutstop",e.stop),n.emit("layoutstop"),this},ac.prototype.stop=function(){return this};var ic={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,spacingFactor: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=ge({},ic,e)}oc.prototype.run=function(){var e=this.options,t=e.eles.nodes(),n=U(e.positions);return t.layoutPositions(this,e,(function(t,r){var a=function(t){if(null==e.positions)return function(e){return{x:e.x,y:e.y}}(t.position());if(n)return e.positions(t);var r=e.positions[t._private.data.id];return null==r?null:r}(t);return!t.locked()&&null!=a&&a})),this};var sc={fit:!0,padding:30,boundingBox: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 lc(e){this.options=ge({},sc,e)}lc.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=Jt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});return n.nodes().layoutPositions(this,e,(function(e,t){return{x:r.x1+Math.round(Math.random()*r.w),y:r.y1+Math.round(Math.random()*r.h)}})),this};var uc=[{name:"breadthfirst",impl:Bu},{name:"circle",impl:_u},{name:"concentric",impl:Ru},{name:"cose",impl:Nu},{name:"grid",impl:nc},{name:"null",impl:ac},{name:"preset",impl:oc},{name:"random",impl:lc}];function cc(e){this.options=e,this.notifications=0}var dc=function(){},hc=function(){throw new Error("A headless instance can not render images")};cc.prototype={recalculateRenderedStyle:dc,notify:function(){this.notifications++},init:dc,isHeadless:function(){return!0},png:hc,jpg:hc};var fc={arrowShapeWidth:.3,registerArrowShapes:function(){var e=this.arrowShapes={},t=this,n=function(e,t,n,r,a,i,o){var s=a.x-n/2-o,l=a.x+n/2+o,u=a.y-n/2-o,c=a.y+n/2+o;return s<=e&&e<=l&&u<=t&&t<=c},r=function(e,t,n,r,a){var i=e*Math.cos(r)-t*Math.sin(r),o=(e*Math.sin(r)+t*Math.cos(r))*n;return{x:i*n+a.x,y:o+a.y}},a=function(e,t,n,a){for(var i=[],o=0;o<e.length;o+=2){var s=e[o],l=e[o+1];i.push(r(s,l,t,n,a))}return i},i=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r.x,r.y)}return t},o=function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").pfValue*2},s=function(r,s){W(s)&&(s=e[s]),e[r]=ge({name:r,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(e,t,n,r,o,s){var l=i(a(this.points,n+2*s,r,o));return gn(e,t,l)},roughCollide:n,draw:function(e,n,r,i){var o=a(this.points,n,r,i);t.arrowShapeImpl("polygon")(e,o)},spacing:function(e){return 0},gap:o},s)};s("none",{collide:Je,roughCollide:Je,draw:tt,spacing:et,gap:et}),s("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),s("arrow","triangle"),s("triangle-backcurve",{points:e.triangle.points,controlPoint:[0,-.15],roughCollide:n,draw:function(e,n,i,o,s){var l=a(this.points,n,i,o),u=this.controlPoint,c=r(u[0],u[1],n,i,o);t.arrowShapeImpl(this.name)(e,l,c)},gap:function(e){return.8*o(e)}}),s("triangle-tee",{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(e,t,n,r,o,s,l){var u=i(a(this.points,n+2*l,r,o)),c=i(a(this.pointsTee,n+2*l,r,o));return gn(e,t,u)||gn(e,t,c)},draw:function(e,n,r,i,o){var s=a(this.points,n,r,i),l=a(this.pointsTee,n,r,i);t.arrowShapeImpl(this.name)(e,s,l)}}),s("circle-triangle",{radius:.15,pointsTr:[0,-.15,.15,-.45,-.15,-.45,0,-.15],collide:function(e,t,n,r,o,s,l){var u=o,c=Math.pow(u.x-e,2)+Math.pow(u.y-t,2)<=Math.pow((n+2*l)*this.radius,2),d=i(a(this.points,n+2*l,r,o));return gn(e,t,d)||c},draw:function(e,n,r,i,o){var s=a(this.pointsTr,n,r,i);t.arrowShapeImpl(this.name)(e,s,i.x,i.y,this.radius*n)},spacing:function(e){return t.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.radius}}),s("triangle-cross",{points:[0,0,.15,-.3,-.15,-.3,0,0],baseCrossLinePts:[-.15,-.4,-.15,-.4,.15,-.4,.15,-.4],crossLinePts:function(e,t){var n=this.baseCrossLinePts.slice(),r=t/e;return n[3]=n[3]-r,n[5]=n[5]-r,n},collide:function(e,t,n,r,o,s,l){var u=i(a(this.points,n+2*l,r,o)),c=i(a(this.crossLinePts(n,s),n+2*l,r,o));return gn(e,t,u)||gn(e,t,c)},draw:function(e,n,r,i,o){var s=a(this.points,n,r,i),l=a(this.crossLinePts(n,o),n,r,i);t.arrowShapeImpl(this.name)(e,s,l)}}),s("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(e){return.525*o(e)}}),s("circle",{radius:.15,collide:function(e,t,n,r,a,i,o){var s=a;return Math.pow(s.x-e,2)+Math.pow(s.y-t,2)<=Math.pow((n+2*o)*this.radius,2)},draw:function(e,n,r,a,i){t.arrowShapeImpl(this.name)(e,a.x,a.y,this.radius*n)},spacing:function(e){return t.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.radius}}),s("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(e){return 1},gap:function(e){return 1}}),s("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),s("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(e){return e.pstyle("width").pfValue*e.pstyle("arrow-scale").value}}),s("chevron",{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(e){return.95*e.pstyle("width").pfValue*e.pstyle("arrow-scale").value}})}},pc={projectIntoViewport:function(e,t){var n=this.cy,r=this.findContainerClientCoords(),a=r[0],i=r[1],o=r[4],s=n.pan(),l=n.zoom();return[((e-a)/o-s.x)/l,((t-i)/o-s.y)/l]},findContainerClientCoords:function(){if(this.containerBB)return this.containerBB;var e=this.container,t=e.getBoundingClientRect(),n=this.cy.window().getComputedStyle(e),r=function(e){return parseFloat(n.getPropertyValue(e))},a=r("padding-left"),i=r("padding-right"),o=r("padding-top"),s=r("padding-bottom"),l=r("border-left-width"),u=r("border-right-width"),c=r("border-top-width"),d=(r("border-bottom-width"),e.clientWidth),h=e.clientHeight,f=a+i,p=o+s,v=l+u,g=t.width/(d+v),y=d-f,m=h-p,b=t.left+a+l,x=t.top+o+c;return this.containerBB=[b,x,y,m,g]},invalidateContainerClientCoordsCache:function(){this.containerBB=null},findNearestElement:function(e,t,n,r){return this.findNearestElements(e,t,n,r)[0]},findNearestElements:function(e,t,n,r){var a,i,o=this,s=this,l=s.getCachedZSortedEles(),u=[],c=s.cy.zoom(),d=s.cy.hasCompoundNodes(),h=(r?24:8)/c,f=(r?8:2)/c,p=(r?8:2)/c,v=1/0;function g(e,t){if(e.isNode()){if(i)return;i=e,u.push(e)}if(e.isEdge()&&(null==t||t<v))if(a){if(a.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value&&a.pstyle("z-compound-depth").value===e.pstyle("z-compound-depth").value)for(var n=0;n<u.length;n++)if(u[n].isEdge()){u[n]=e,a=e,v=null!=t?t:v;break}}else u.push(e),a=e,v=null!=t?t:v}function y(n){var r=n.outerWidth()+2*f,a=n.outerHeight()+2*f,i=r/2,l=a/2,u=n.position(),c="auto"===n.pstyle("corner-radius").value?"auto":n.pstyle("corner-radius").pfValue,d=n._private.rscratch;if(u.x-i<=e&&e<=u.x+i&&u.y-l<=t&&t<=u.y+l&&s.nodeShapes[o.getNodeShape(n)].checkPoint(e,t,0,r,a,u.x,u.y,c,d))return g(n,0),!0}function m(n){var r,a=n._private,i=a.rscratch,l=n.pstyle("width").pfValue,c=n.pstyle("arrow-scale").value,f=l/2+h,p=f*f,v=2*f,m=a.source,b=a.target;if("segments"===i.edgeType||"straight"===i.edgeType||"haystack"===i.edgeType){for(var x=i.allpts,w=0;w+3<x.length;w+=2)if(hn(e,t,x[w],x[w+1],x[w+2],x[w+3],v)&&p>(r=vn(e,t,x[w],x[w+1],x[w+2],x[w+3])))return g(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<i.allpts.length;w+=4)if(fn(e,t,x[w],x[w+1],x[w+2],x[w+3],x[w+4],x[w+5],v)&&p>(r=pn(e,t,x[w],x[w+1],x[w+2],x[w+3],x[w+4],x[w+5])))return g(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;w<k.length;w++){var T=k[w],C=s.arrowShapes[n.pstyle(T.name+"-arrow-shape").value],P=n.pstyle("width").pfValue;if(C.roughCollide(e,t,E,T.angle,{x:T.x,y:T.y},P,h)&&C.collide(e,t,E,T.angle,{x:T.x,y:T.y},P,h))return g(n),!0}d&&u.length>0&&(y(m),y(b))}function b(e,t,n){return ht(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,v=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(v,m),C=k(v,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(gn(e,t,B))return g(n),!0}else if(on(s,e,t))return g(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=Jt({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 v(e,t,n){return ht(e,t,n)}function g(e,t){var n=e._private,r=o;e.boundingBox();var a=n.labelBounds.main;if(!a)return null;var i=v(n.rscratch,"labelX",t),s=v(n.rscratch,"labelY",t),l=v(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 g=Math.cos(l),y=Math.sin(l),m=function(e,t){return{x:(e-=i)*g-(t-=s)*y+i,y:e*y+t*g+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;m<a.length;m++){var b=a[m];if(b.isNode()){var x=b,w="yes"===x.pstyle("text-events").strValue,E=x.pstyle("box-selection").strValue,k="yes"===x.pstyle("box-select-labels").strValue;if("none"===E)continue;var T=("overlap"===E||k)&&w,C=x.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:T});if("contain"===E){var P=!1;if(k&&w){var S=g(x);S&&Rn(S,f)&&(s.push(x),P=!0)}!P&&ln(h,C)&&s.push(x)}else if("overlap"===E&&an(h,C)){var B=x.boundingBox({includeNodes:!0,includeEdges:!0,includeLabels:!1,includeMainLabels:!1,includeSourceLabels:!1,includeTargetLabels:!1});if(Rn([{x:B.x1,y:B.y1},{x:B.x2,y:B.y1},{x:B.x2,y:B.y2},{x:B.x1,y:B.y2}],f))s.push(x);else{var D=g(x);D&&Rn(D,f)&&s.push(x)}}}else{var _=b,A=_._private,M=A.rscratch,R=_.pstyle("box-selection").strValue;if("none"===R)continue;if("contain"===R){if(null!=M.startX&&null!=M.startY&&!on(h,M.startX,M.startY))continue;if(null!=M.endX&&null!=M.endY&&!on(h,M.endX,M.endY))continue;if("bezier"===M.edgeType||"multibezier"===M.edgeType||"self"===M.edgeType||"compound"===M.edgeType||"segments"===M.edgeType||"haystack"===M.edgeType){for(var I=A.rstyle.bezierPts||A.rstyle.linePts||A.rstyle.haystackPts,N=!0,L=0;L<I.length;L++)if(!sn(h,I[L])){N=!1;break}N&&s.push(_)}else"straight"===M.edgeType&&s.push(_)}else if("overlap"===R){var z=!1;if(null!=M.startX&&null!=M.startY&&null!=M.endX&&null!=M.endY&&(on(h,M.startX,M.startY)||on(h,M.endX,M.endY)))s.push(_),z=!0;else if(!z&&"haystack"===M.edgeType)for(var O=A.rstyle.haystackPts,V=0;V<O.length;V++)if(sn(h,O[V])){s.push(_),z=!0;break}if(!z){var F=A.rstyle.bezierPts||A.rstyle.linePts||A.rstyle.haystackPts;if((!F||F.length<2)&&"straight"===M.edgeType&&null!=M.startX&&null!=M.startY&&null!=M.endX&&null!=M.endY&&(F=[{x:M.startX,y:M.startY},{x:M.endX,y:M.endY}]),!F||F.length<2)continue;for(var X=0;X<F.length-1;X++){for(var j=F[X],Y=F[X+1],q=0;q<p.length;q++){var W=i(p[q],2);if(y(j,Y,W[0],W[1])){s.push(_),z=!0;break}}if(z)break}}}}}return s}},vc={calculateArrowAngles:function(e){var t,n,r,a,i,o,s=e._private.rscratch,l="haystack"===s.edgeType,u="bezier"===s.edgeType,c="multibezier"===s.edgeType,d="segments"===s.edgeType,h="compound"===s.edgeType,f="self"===s.edgeType;if(l?(r=s.haystackPts[0],a=s.haystackPts[1],i=s.haystackPts[2],o=s.haystackPts[3]):(r=s.arrowStartX,a=s.arrowStartY,i=s.arrowEndX,o=s.arrowEndY),v=s.midX,g=s.midY,d)t=r-s.segpts[0],n=a-s.segpts[1];else if(c||h||f||u){var p=s.allpts;t=r-Zt(p[0],p[2],p[4],.1),n=a-Zt(p[1],p[3],p[5],.1)}else t=r-v,n=a-g;s.srcArrowAngle=qt(t,n);var v=s.midX,g=s.midY;if(l&&(v=(r+i)/2,g=(a+o)/2),t=i-r,n=o-a,d)if((p=s.allpts).length/2%2==0){var y=(C=p.length/2)-2;t=p[C]-p[y],n=p[C+1]-p[y+1]}else if(s.isRound)t=s.midVector[1],n=-s.midVector[0];else{y=(C=p.length/2-1)-2;t=p[C]-p[y],n=p[C+1]-p[y+1]}else if(c||h||f){var m,b,x,w,p=s.allpts;if(s.ctrlpts.length/2%2==0){var E=(k=(T=p.length/2-1)+2)+2;m=Zt(p[T],p[k],p[E],0),b=Zt(p[T+1],p[k+1],p[E+1],0),x=Zt(p[T],p[k],p[E],1e-4),w=Zt(p[T+1],p[k+1],p[E+1],1e-4)}else{var k,T;E=(k=p.length/2-1)+2;m=Zt(p[T=k-2],p[k],p[E],.4999),b=Zt(p[T+1],p[k+1],p[E+1],.4999),x=Zt(p[T],p[k],p[E],.5),w=Zt(p[T+1],p[k+1],p[E+1],.5)}t=x-m,n=w-b}if(s.midtgtArrowAngle=qt(t,n),s.midDispX=t,s.midDispY=n,t*=-1,n*=-1,d)if((p=s.allpts).length/2%2==0);else if(!s.isRound){var C,P=(C=p.length/2-1)+2;t=-(p[P]-p[C]),n=-(p[P+1]-p[C+1])}if(s.midsrcArrowAngle=qt(t,n),d)t=i-s.segpts[s.segpts.length-2],n=o-s.segpts[s.segpts.length-1];else if(c||h||f||u){var S=(p=s.allpts).length;t=i-Zt(p[S-6],p[S-4],p[S-2],.9),n=o-Zt(p[S-5],p[S-3],p[S-1],.9)}else t=i-v,n=o-g;s.tgtArrowAngle=qt(t,n)}};vc.getArrowWidth=vc.getArrowHeight=function(e,t){var n=this.arrowWidthCache=this.arrowWidthCache||{},r=n[e+", "+t];return r||(r=Math.max(Math.pow(13.37*e,.9),29)*t,n[e+", "+t]=r,r)};var gc,yc,mc,bc,xc,wc,Ec,kc,Tc,Cc,Pc,Sc,Bc,Dc,_c,Ac,Mc,Rc={},Ic={},Nc=function(e,t,n){n.x=t.x-e.x,n.y=t.y-e.y,n.len=Math.sqrt(n.x*n.x+n.y*n.y),n.nx=n.x/n.len,n.ny=n.y/n.len,n.ang=Math.atan2(n.ny,n.nx)},Lc=function(e,t,n,r,a){var i,o;if(e!==Mc?Nc(t,e,Rc):((o=Rc).x=-1*(i=Ic).x,o.y=-1*i.y,o.nx=-1*i.nx,o.ny=-1*i.ny,o.ang=i.ang>0?-(Math.PI-i.ang):Math.PI+i.ang),Nc(t,n,Ic),mc=Rc.nx*Ic.ny-Rc.ny*Ic.nx,bc=Rc.nx*Ic.nx-Rc.ny*-Ic.ny,Ec=Math.asin(Math.max(-1,Math.min(1,mc))),Math.abs(Ec)<1e-6)return gc=t.x,yc=t.y,void(Tc=Pc=0);xc=1,wc=!1,bc<0?Ec<0?Ec=Math.PI+Ec:(Ec=Math.PI-Ec,xc=-1,wc=!0):Ec>0&&(xc=-1,wc=!0),Pc=void 0!==t.radius?t.radius:r,kc=Ec/2,Sc=Math.min(Rc.len/2,Ic.len/2),a?(Cc=Math.abs(Math.cos(kc)*Pc/Math.sin(kc)))>Sc?(Cc=Sc,Tc=Math.abs(Cc*Math.sin(kc)/Math.cos(kc))):Tc=Pc:(Cc=Math.min(Sc,Pc),Tc=Math.abs(Cc*Math.sin(kc)/Math.cos(kc))),_c=t.x+Ic.nx*Cc,Ac=t.y+Ic.ny*Cc,gc=_c-Ic.ny*Tc*xc,yc=Ac+Ic.nx*Tc*xc,Bc=t.x+Rc.nx*Cc,Dc=t.y+Rc.ny*Cc,Mc=t};function zc(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 Oc(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}:(Lc(e,t,n,r,a),{cx:gc,cy:yc,radius:Tc,startX:Bc,startY:Dc,stopX:_c,stopY:Ac,startAngle:Rc.ang+Math.PI/2*xc,endAngle:Ic.ang-Math.PI/2*xc,counterClockwise:wc})}var Vc=.01,Fc=Math.sqrt(.02),Xc={};function jc(e){var t=[];if(null!=e){for(var n=0;n<e.length;n+=2){var r=e[n],a=e[n+1];t.push({x:r,y:a})}return t}}Xc.findMidptPtsEtc=function(e,t){var n,r=t.posPts,a=t.intersectionPts,o=t.vectorNormInverse,s=e.pstyle("source-endpoint"),l=e.pstyle("target-endpoint"),u=null!=s.units&&null!=l.units;switch(e.pstyle("edge-distances").value){case"node-position":n=r;break;case"intersection":n=a;break;case"endpoints":if(u){var c=i(this.manualEndptToPx(e.source()[0],s),2),d=c[0],h=c[1],f=i(this.manualEndptToPx(e.target()[0],l),2),p=f[0],v=f[1],g={x1:d,y1:h,x2:p,y2:v};o=function(e,t,n,r){var a=r-t,i=n-e,o=Math.sqrt(i*i+a*a);return{x:-a/o,y:i/o}}(d,h,p,v),n=g}else at("Edge ".concat(e.id()," has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint.  Falling back on edge-distances:intersection (default).")),n=a}return{midptPts:n,vectorNormInverse:o}},Xc.findHaystackPoints=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n._private,a=r.rscratch;if(!a.haystack){var i=2*Math.random()*Math.PI;a.source={x:Math.cos(i),y:Math.sin(i)},i=2*Math.random()*Math.PI,a.target={x:Math.cos(i),y:Math.sin(i)}}var o=r.source,s=r.target,l=o.position(),u=s.position(),c=o.width(),d=s.width(),h=o.height(),f=s.height(),p=n.pstyle("haystack-radius").value/2;a.haystackPts=a.allpts=[a.source.x*c*p+l.x,a.source.y*h*p+l.y,a.target.x*d*p+u.x,a.target.y*f*p+u.y],a.midX=(a.allpts[0]+a.allpts[2])/2,a.midY=(a.allpts[1]+a.allpts[3])/2,a.edgeType="haystack",a.haystack=!0,this.storeEdgeProjections(n),this.calculateArrowAngles(n),this.recalculateEdgeLabelProjections(n),this.calculateLabelAngles(n)}},Xc.findSegmentsPoints=function(e,t){var n=e._private.rscratch,r=e.pstyle("segment-weights"),a=e.pstyle("segment-distances"),i=e.pstyle("segment-radii"),o=e.pstyle("radius-type"),s=Math.min(r.pfValue.length,a.pfValue.length),l=i.pfValue[i.pfValue.length-1],u=o.pfValue[o.pfValue.length-1];n.edgeType="segments",n.segpts=[],n.radii=[],n.isArcRadius=[];for(var c=0;c<s;c++){var d=r.pfValue[c],h=a.pfValue[c],f=1-d,p=d,v=this.findMidptPtsEtc(e,t),g=v.midptPts,y=v.vectorNormInverse,m={x:g.x1*f+g.x2*p,y:g.y1*f+g.y2*p};n.segpts.push(m.x+y.x*h,m.y+y.y*h),n.radii.push(void 0!==i.pfValue[c]?i.pfValue[c]:l),n.isArcRadius.push("arc-radius"===(void 0!==o.pfValue[c]?o.pfValue[c]:u))}},Xc.findLoopPoints=function(e,t,n,r){var a=e._private.rscratch,i=t.dirCounts,o=t.srcPos,s=e.pstyle("control-point-distances"),l=s?s.pfValue[0]:void 0,u=e.pstyle("loop-direction").pfValue,c=e.pstyle("loop-sweep").pfValue,d=e.pstyle("control-point-step-size").pfValue;a.edgeType="self";var h=n,f=d;r&&(h=0,f=l);var p=u-Math.PI/2,v=p-c/2,g=p+c/2,y=String(u+"_"+c);h=void 0===i[y]?i[y]=0:++i[y],a.ctrlpts=[o.x+1.4*Math.cos(v)*f*(h/3+1),o.y+1.4*Math.sin(v)*f*(h/3+1),o.x+1.4*Math.cos(g)*f*(h/3+1),o.y+1.4*Math.sin(g)*f*(h/3+1)]},Xc.findCompoundLoopPoints=function(e,t,n,r){var a=e._private.rscratch;a.edgeType="compound";var i=t.srcPos,o=t.tgtPos,s=t.srcW,l=t.srcH,u=t.tgtW,c=t.tgtH,d=e.pstyle("control-point-step-size").pfValue,h=e.pstyle("control-point-distances"),f=h?h.pfValue[0]:void 0,p=n,v=d;r&&(p=0,v=f);var g={x:i.x-s/2,y:i.y-l/2},y={x:o.x-u/2,y:o.y-c/2},m={x:Math.min(g.x,y.x),y:Math.min(g.y,y.y)},b=Math.max(.5,Math.log(s*Vc)),x=Math.max(.5,Math.log(u*Vc));a.ctrlpts=[m.x,m.y-(1+Math.pow(50,1.12)/100)*v*(p/3+1)*b,m.x-(1+Math.pow(50,1.12)/100)*v*(p/3+1)*x,m.y]},Xc.findStraightEdgePoints=function(e){e._private.rscratch.edgeType="straight"},Xc.findBezierPoints=function(e,t,n,r,a){var i=e._private.rscratch,o=e.pstyle("control-point-step-size").pfValue,s=e.pstyle("control-point-distances"),l=e.pstyle("control-point-weights"),u=s&&l?Math.min(s.value.length,l.value.length):1,c=s?s.pfValue[0]:void 0,d=l.value[0],h=r;i.edgeType=h?"multibezier":"bezier",i.ctrlpts=[];for(var f=0;f<u;f++){var p=(.5-t.eles.length/2+n)*o*(a?-1:1),v=void 0,g=Ut(p);h&&(c=s?s.pfValue[f]:o,d=l.value[f]);var y=void 0!==(v=r?c:void 0!==c?g*c:void 0)?v:p,m=1-d,b=d,x=this.findMidptPtsEtc(e,t),w=x.midptPts,E=x.vectorNormInverse,k={x:w.x1*m+w.x2*b,y:w.y1*m+w.y2*b};i.ctrlpts.push(k.x+E.x*y,k.y+E.y*y)}},Xc.findTaxiPoints=function(e,t){var n=e._private.rscratch;n.edgeType="segments";var r="vertical",a="horizontal",i="leftward",o="rightward",s="downward",l="upward",u=t.posPts,c=t.srcW,d=t.srcH,h=t.tgtW,f=t.tgtH,p="node-position"!==e.pstyle("edge-distances").value,v=e.pstyle("taxi-direction").value,g=v,y=e.pstyle("taxi-turn"),m="%"===y.units,b=y.pfValue,x=b<0,w=e.pstyle("taxi-turn-min-distance").pfValue,E=p?(c+h)/2:0,k=p?(d+f)/2:0,T=u.x2-u.x1,C=u.y2-u.y1,P=function(e,t){return e>0?Math.max(e-t,0):Math.min(e+t,0)},S=P(T,E),B=P(C,k),D=!1;"auto"===g?v=Math.abs(S)>Math.abs(B)?a:r:g===l||g===s?(v=r,D=!0):g!==i&&g!==o||(v=a,D=!0);var _,A=v===r,M=A?B:S,R=A?C:T,I=Ut(R),N=!1;(D&&(m||x)||!(g===s&&R<0||g===l&&R>0||g===i&&R>0||g===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)<w||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)}},Xc.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,v=!G(n.startX)||!G(n.startY),g=!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=Ht({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),w=x<b,E=Ht({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.endX,y:n.endY}),k=E<b,T=!1;if(v||g||w){T=!0;var C={x:n.ctrlpts[0]-r.x,y:n.ctrlpts[1]-r.y},P=Math.sqrt(C.x*C.x+C.y*C.y),S={x:C.x/P,y:C.y/P},B=Math.max(i,o),D={x:n.ctrlpts[0]+2*S.x*B,y:n.ctrlpts[1]+2*S.y*B},_=u.intersectLine(r.x,r.y,i,o,D.x,D.y,0,d,f);w?(n.ctrlpts[0]=n.ctrlpts[0]+S.x*(b-x),n.ctrlpts[1]=n.ctrlpts[1]+S.y*(b-x)):(n.ctrlpts[0]=_[0]+S.x*b,n.ctrlpts[1]=_[1]+S.y*b)}if(y||m||k){T=!0;var A={x:n.ctrlpts[0]-a.x,y:n.ctrlpts[1]-a.y},M=Math.sqrt(A.x*A.x+A.y*A.y),R={x:A.x/M,y:A.y/M},I=Math.max(i,o),N={x:n.ctrlpts[0]+2*R.x*I,y:n.ctrlpts[1]+2*R.y*I},L=c.intersectLine(a.x,a.y,s,l,N.x,N.y,0,h,p);k?(n.ctrlpts[0]=n.ctrlpts[0]+R.x*(b-E),n.ctrlpts[1]=n.ctrlpts[1]+R.y*(b-E)):(n.ctrlpts[0]=L[0]+R.x*b,n.ctrlpts[1]=L[1]+R.y*b)}T&&this.findEndpoints(e)}},Xc.storeAllpts=function(e){var t=e._private.rscratch;if("multibezier"===t.edgeType||"bezier"===t.edgeType||"self"===t.edgeType||"compound"===t.edgeType){t.allpts=[],t.allpts.push(t.startX,t.startY);for(var n=0;n+1<t.ctrlpts.length;n+=2)t.allpts.push(t.ctrlpts[n],t.ctrlpts[n+1]),n+3<t.ctrlpts.length&&t.allpts.push((t.ctrlpts[n]+t.ctrlpts[n+2])/2,(t.ctrlpts[n+1]+t.ctrlpts[n+3])/2);var r;t.allpts.push(t.endX,t.endY),t.ctrlpts.length/2%2==0?(r=t.allpts.length/2-1,t.midX=t.allpts[r],t.midY=t.allpts[r+1]):(r=t.allpts.length/2-3,t.midX=Zt(t.allpts[r],t.allpts[r+2],t.allpts[r+4],.5),t.midY=Zt(t.allpts[r+1],t.allpts[r+3],t.allpts[r+5],.5))}else if("straight"===t.edgeType)t.allpts=[t.startX,t.startY,t.endX,t.endY],t.midX=(t.startX+t.endX+t.arrowStartX+t.arrowEndX)/4,t.midY=(t.startY+t.endY+t.arrowStartY+t.arrowEndY)/4;else if("segments"===t.edgeType){if(t.allpts=[],t.allpts.push(t.startX,t.startY),t.allpts.push.apply(t.allpts,t.segpts),t.allpts.push(t.endX,t.endY),t.isRound){t.roundCorners=[];for(var a=2;a+3<t.allpts.length;a+=2){var i=t.radii[a/2-1],o=t.isArcRadius[a/2-1];t.roundCorners.push(Oc({x:t.allpts[a-2],y:t.allpts[a-1]},{x:t.allpts[a],y:t.allpts[a+1],radius:i},{x:t.allpts[a+2],y:t.allpts[a+3]},i,o))}}if(t.segpts.length%4==0){var s=t.segpts.length/2,l=s-2;t.midX=(t.segpts[l]+t.segpts[s])/2,t.midY=(t.segpts[l+1]+t.segpts[s+1])/2}else{var u=t.segpts.length/2-1;if(t.isRound){var c={x:t.segpts[u],y:t.segpts[u+1]},d=t.roundCorners[u/2];if(0===d.radius){var h={x:t.segpts[u+2],y:t.segpts[u+3]};t.midX=c.x,t.midY=c.y,t.midVector=[c.y-h.y,h.x-c.x]}else{var f=[c.x-d.cx,c.y-d.cy],p=d.radius/Math.sqrt(Math.pow(f[0],2)+Math.pow(f[1],2));f=f.map((function(e){return e*p})),t.midX=d.cx+f[0],t.midY=d.cy+f[1],t.midVector=f}}else t.midX=t.segpts[u],t.midY=t.segpts[u+1]}}},Xc.checkForInvalidEdgeWarning=function(e){var t=e[0]._private.rscratch;t.nodesOverlap||G(t.startX)&&G(t.startY)&&G(t.endX)&&G(t.endY)?t.loggedErr=!1:t.loggedErr||(t.loggedErr=!0,at("Edge `"+e.id()+"` has invalid endpoints and so it is impossible to draw.  Adjust your edge style (e.g. control points) accordingly or use an alternative edge type.  This is expected behaviour when the source node and the target node overlap."))},Xc.findEdgeControlPoints=function(e){var t=this;if(e&&0!==e.length){for(var n=this,r=n.cy.hasCompoundNodes(),a=new pt,i=function(e,t){return[].concat(o(e),[t?1:0]).join("-")},s=[],l=[],u=0;u<e.length;u++){var c=e[u],d=c._private,h=c.pstyle("curve-style").value;if(!c.removed()&&c.takesUpSpace())if("haystack"!==h){var f="unbundled-bezier"===h||ue(h,"segments")||"straight"===h||"straight-triangle"===h||ue(h,"taxi"),p="unbundled-bezier"===h||"bezier"===h,v=d.source,g=d.target,y=[v.poolIndex(),g.poolIndex()].sort(),m=i(y,f),b=a.get(m);null==b&&(b={eles:[]},s.push({pairId:y,edgeIsUnbundled:f}),a.set(m,b)),b.eles.push(c),f&&(b.hasUnbundled=!0),p&&(b.hasBezier=!0)}else l.push(c)}for(var x=function(){var e,o=s[w],l=o.pairId,u=o.edgeIsUnbundled,c=i(l,u),d=a.get(c);if(!d.hasUnbundled){var h=d.eles[0].parallelEdges().filter((function(e){return e.isBundledBezier()}));dt(d.eles),h.forEach((function(e){return d.eles.push(e)})),d.eles.sort((function(e,t){return e.poolIndex()-t.poolIndex()}))}var f=d.eles[0],p=f.source(),v=f.target();if(p.poolIndex()>v.poolIndex()){var g=p;p=v,v=g}var y=d.srcPos=p.position(),m=d.tgtPos=v.position(),b=d.srcW=p.outerWidth(),x=d.srcH=p.outerHeight(),E=d.tgtW=v.outerWidth(),k=d.tgtH=v.outerHeight(),T=d.srcShape=n.nodeShapes[t.getNodeShape(p)],C=d.tgtShape=n.nodeShapes[t.getNodeShape(v)],P=d.srcCornerRadius="auto"===p.pstyle("corner-radius").value?"auto":p.pstyle("corner-radius").pfValue,S=d.tgtCornerRadius="auto"===v.pstyle("corner-radius").value?"auto":v.pstyle("corner-radius").pfValue,B=d.tgtRs=v._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;_<d.eles.length;_++){var A=d.eles[_],M=A[0]._private.rscratch,R=A.pstyle("curve-style").value,I="unbundled-bezier"===R||ue(R,"segments")||ue(R,"taxi"),N=!p.same(A.source());if(!d.calculatedIntersection&&p!==v&&(d.hasBezier||d.hasUnbundled)){d.calculatedIntersection=!0;var L=T.intersectLine(y.x,y.y,b,x,m.x,m.y,0,P,D),z=d.srcIntn=L,O=C.intersectLine(m.x,m.y,E,k,y.x,y.y,0,S,B),V=d.tgtIntn=O,F=d.intersectionPts={x1:L[0],x2:O[0],y1:L[1],y2:O[1]},X=d.posPts={x1:y.x,x2:m.x,y1:y.y,y2:m.y},j=O[1]-L[1],Y=O[0]-L[0],q=Math.sqrt(Y*Y+j*j);G(q)&&q>=Fc||(q=Math.sqrt(Math.max(Y*Y,Vc)+Math.max(j*j,Vc)));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()||v.isParent()||v.isChild())&&(p.parents().anySame(v)||v.parents().anySame(p)||p.same(v)&&p.isParent())?t.findCompoundLoopPoints(A,K,_,I):p===v?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;w<s.length;w++)x();this.findHaystackPoints(l)}},Xc.getSegmentPoints=function(e){var t=e[0]._private.rscratch;if(this.recalculateRenderedStyle(e),"segments"===t.edgeType)return jc(t.segpts)},Xc.getControlPoints=function(e){var t=e[0]._private.rscratch;this.recalculateRenderedStyle(e);var n=t.edgeType;if("bezier"===n||"multibezier"===n||"self"===n||"compound"===n)return jc(t.ctrlpts)},Xc.getEdgeMidpoint=function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),{x:t.midX,y:t.midY}};var Yc={manualEndptToPx:function(e,t){var n=e.position(),r=e.outerWidth(),a=e.outerHeight(),i=e._private.rscratch;if(2===t.value.length){var o=[t.pfValue[0],t.pfValue[1]];return"%"===t.units[0]&&(o[0]=o[0]*r),"%"===t.units[1]&&(o[1]=o[1]*a),o[0]+=n.x,o[1]+=n.y,o}var s=t.pfValue[0];s=-Math.PI/2+s;var l=2*Math.max(r,a),u=[n.x+Math.cos(s)*l,n.y+Math.sin(s)*l];return this.nodeShapes[this.getNodeShape(e)].intersectLine(n.x,n.y,r,a,u[0],u[1],0,"auto"===e.pstyle("corner-radius").value?"auto":e.pstyle("corner-radius").pfValue,i)},findEndpoints:function(e){var t,n,r,a,i,o,s,l,u,c=this,d=e.source()[0],h=e.target()[0],f=d.position(),p=h.position(),v=e.pstyle("target-arrow-shape").value,g=e.pstyle("source-arrow-shape").value,y=e.pstyle("target-distance-from-node").pfValue,m=e.pstyle("source-distance-from-node").pfValue,b=d._private.rscratch,x=h._private.rscratch,w=e.pstyle("curve-style").value,E=e._private.rscratch,k=E.edgeType,T=ue(w,"taxi"),C="self"===k||"compound"===k,P="bezier"===k||"multibezier"===k||C,S="bezier"!==k,B="straight"===k||"segments"===k,D="segments"===k,_=P||S||B,A=C||T,M=e.pstyle("source-endpoint"),R=A?"outside-to-node":M.value,I="auto"===d.pstyle("corner-radius").value?"auto":d.pstyle("corner-radius").pfValue,N=e.pstyle("target-endpoint"),L=A?"outside-to-node":N.value,z="auto"===h.pstyle("corner-radius").value?"auto":h.pstyle("corner-radius").pfValue;E.srcManEndpt=M,E.tgtManEndpt=N;var O=null!==(t=2===(null==N||null===(n=N.pfValue)||void 0===n?void 0:n.length)?N.pfValue:null)&&void 0!==t?t:[0,0],V=null!==(r=2===(null==M||null===(a=M.pfValue)||void 0===a?void 0:a.length)?M.pfValue:null)&&void 0!==r?r:[0,0];if(P){var F=[E.ctrlpts[0],E.ctrlpts[1]];o=S?[E.ctrlpts[E.ctrlpts.length-2],E.ctrlpts[E.ctrlpts.length-1]]:F,s=F}else if(B){var X=D?E.segpts.slice(0,2):[p.x+O[0],p.y+O[1]];o=D?E.segpts.slice(E.segpts.length-2):[f.x+V[0],f.y+V[1]],s=X}if("inside-to-node"===L)i=[p.x,p.y];else if(N.units)i=this.manualEndptToPx(h,N);else if("outside-to-line"===L)i=E.tgtIntn;else if("outside-to-node"===L||"outside-to-node-or-label"===L?l=o:"outside-to-line"!==L&&"outside-to-line-or-label"!==L||(l=[f.x,f.y]),i=c.nodeShapes[this.getNodeShape(h)].intersectLine(p.x,p.y,h.outerWidth(),h.outerHeight(),l[0],l[1],0,z,x),"outside-to-node-or-label"===L||"outside-to-line-or-label"===L){var j=h._private.rscratch,Y=j.labelWidth,q=j.labelHeight,W=j.labelX,U=j.labelY,H=Y/2,K=q/2,Z=h.pstyle("text-valign").value;"top"===Z?U-=K:"bottom"===Z&&(U+=K);var $=h.pstyle("text-halign").value;"left"===$?W-=H:"right"===$&&(W+=H);var Q=Cn(l[0],l[1],[W-H,U-K,W+H,U-K,W+H,U+K,W-H,U+K],p.x,p.y);if(Q.length>0){var J=f,ee=Kt(J,Yt(i)),te=Kt(J,Yt(Q)),ne=ee;if(te<ee&&(i=Q,ne=te),Q.length>2)Kt(J,{x:Q[2],y:Q[3]})<ne&&(i=[Q[2],Q[3]])}}var re=Pn(i,o,c.arrowShapes[v].spacing(e)+y),ae=Pn(i,o,c.arrowShapes[v].gap(e)+y);if(E.endX=ae[0],E.endY=ae[1],E.arrowEndX=re[0],E.arrowEndY=re[1],"inside-to-node"===R)i=[f.x,f.y];else if(M.units)i=this.manualEndptToPx(d,M);else if("outside-to-line"===R)i=E.srcIntn;else if("outside-to-node"===R||"outside-to-node-or-label"===R?u=s:"outside-to-line"!==R&&"outside-to-line-or-label"!==R||(u=[p.x,p.y]),i=c.nodeShapes[this.getNodeShape(d)].intersectLine(f.x,f.y,d.outerWidth(),d.outerHeight(),u[0],u[1],0,I,b),"outside-to-node-or-label"===R||"outside-to-line-or-label"===R){var ie=d._private.rscratch,oe=ie.labelWidth,se=ie.labelHeight,le=ie.labelX,ce=ie.labelY,de=oe/2,he=se/2,fe=d.pstyle("text-valign").value;"top"===fe?ce-=he:"bottom"===fe&&(ce+=he);var pe=d.pstyle("text-halign").value;"left"===pe?le-=de:"right"===pe&&(le+=de);var ve=Cn(u[0],u[1],[le-de,ce-he,le+de,ce-he,le+de,ce+he,le-de,ce+he],f.x,f.y);if(ve.length>0){var ge=p,ye=Kt(ge,Yt(i)),me=Kt(ge,Yt(ve)),be=ye;if(me<ye&&(i=[ve[0],ve[1]],be=me),ve.length>2)Kt(ge,{x:ve[2],y:ve[3]})<be&&(i=[ve[2],ve[3]])}}var xe=Pn(i,s,c.arrowShapes[g].spacing(e)+m),we=Pn(i,s,c.arrowShapes[g].gap(e)+m);E.startX=we[0],E.startY=we[1],E.arrowStartX=xe[0],E.arrowStartY=xe[1],_&&(G(E.startX)&&G(E.startY)&&G(E.endX)&&G(E.endY)?E.badLine=!1:E.badLine=!0)},getSourceEndpoint:function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),"haystack"===t.edgeType?{x:t.haystackPts[0],y:t.haystackPts[1]}:{x:t.arrowStartX,y:t.arrowStartY}},getTargetEndpoint:function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),"haystack"===t.edgeType?{x:t.haystackPts[2],y:t.haystackPts[3]}:{x:t.arrowEndX,y:t.arrowEndY}}},qc={};function Wc(e,t,n){for(var r=function(e,t,n,r){return Zt(e,t,n,r)},a=t._private.rstyle.bezierPts,i=0;i<e.bezierProjPcts.length;i++){var o=e.bezierProjPcts[i];a.push({x:r(n[0],n[2],n[4],o),y:r(n[1],n[3],n[5],o)})}}qc.storeEdgeProjections=function(e){var t=e._private,n=t.rscratch,r=n.edgeType;if(t.rstyle.bezierPts=null,t.rstyle.linePts=null,t.rstyle.haystackPts=null,"multibezier"===r||"bezier"===r||"self"===r||"compound"===r){t.rstyle.bezierPts=[];for(var a=0;a+5<n.allpts.length;a+=4)Wc(this,e,n.allpts.slice(a,a+6))}else if("segments"===r){var i=t.rstyle.linePts=[];for(a=0;a+1<n.allpts.length;a+=2)i.push({x:n.allpts[a],y:n.allpts[a+1]})}else if("haystack"===r){var o=n.haystackPts;t.rstyle.haystackPts=[{x:o[0],y:o[1]},{x:o[2],y:o[3]}]}t.rstyle.arrowWidth=this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth},qc.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)};var Uc={recalculateNodeLabelProjection:function(e){var t=e.pstyle("label").strValue;if(!ne(t)){var n,r,a=e._private,i=e.width(),o=e.height(),s=e.padding(),l=e.position(),u=e.pstyle("text-halign").strValue,c=e.pstyle("text-valign").strValue,d=a.rscratch,h=a.rstyle;switch(u){case"left":n=l.x-i/2-s;break;case"right":n=l.x+i/2+s;break;default:n=l.x}switch(c){case"top":r=l.y-o/2-s;break;case"bottom":r=l.y+o/2+s;break;default:r=l.y}d.labelX=n,d.labelY=r,h.labelX=n,h.labelY=r,this.calculateLabelAngles(e),this.applyLabelDimensions(e)}}},Hc=function(e,t){var n=Math.atan(t/e);return 0===e&&n<0&&(n*=-1),n},Kc=function(e,t){var n=t.x-e.x,r=t.y-e.y;return Hc(n,r)};Uc.recalculateEdgeLabelProjections=function(e){var t,n=e._private,r=n.rscratch,a=this,i={mid:e.pstyle("label").strValue,source:e.pstyle("source-label").strValue,target:e.pstyle("target-label").strValue};if(i.mid||i.source||i.target){t={x:r.midX,y:r.midY};var o=function(e,t,r){ft(n.rscratch,e,t,r),ft(n.rstyle,e,t,r)};o("labelX",null,t.x),o("labelY",null,t.y);var s=Hc(r.midDispX,r.midDispY);o("labelAutoAngle",null,s);var l=function(){if(l.cache)return l.cache;for(var e=[],t=0;t+5<r.allpts.length;t+=4){var i={x:r.allpts[t],y:r.allpts[t+1]},o={x:r.allpts[t+2],y:r.allpts[t+3]},s={x:r.allpts[t+4],y:r.allpts[t+5]};e.push({p0:i,p1:o,p2:s,startDist:0,length:0,segments:[]})}var u=n.rstyle.bezierPts,c=a.bezierProjPcts.length;function d(e,t,n,r,a){var i=Ht(t,n),o=e.segments[e.segments.length-1],s={p0:t,p1:n,t0:r,t1:a,startDist:o?o.startDist+o.length:0,length:i};e.segments.push(s),e.length+=i}for(var h=0;h<e.length;h++){var f=e[h],p=e[h-1];p&&(f.startDist=p.startDist+p.length),d(f,f.p0,u[h*c],0,a.bezierProjPcts[0]);for(var v=0;v<c-1;v++)d(f,u[h*c+v],u[h*c+v+1],a.bezierProjPcts[v],a.bezierProjPcts[v+1]);d(f,u[h*c+c-1],f.p2,a.bezierProjPcts[c-1],1)}return l.cache=e},u=function(n){var a,s="source"===n;if(i[n]){var u=e.pstyle(n+"-text-offset").pfValue;switch(r.edgeType){case"self":case"compound":case"bezier":case"multibezier":for(var c,d=l(),h=0,f=0,p=0;p<d.length;p++){for(var v=d[s?p:d.length-1-p],g=0;g<v.segments.length;g++){var y=v.segments[s?g:v.segments.length-1-g],m=p===d.length-1&&g===v.segments.length-1;if(h=f,(f+=y.length)>=u||m){c={cp:v,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=Qt(0,k,1),t=$t(b.p0,b.p1,b.p2,k),a=function(e,t,n,r){var a=Qt(0,r-.001,1),i=Qt(0,r+.001,1),o=$t(e,t,n,a),s=$t(e,t,n,i);return Kc(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<D&&(s?(P={x:r.allpts[_],y:r.allpts[_+1]},S={x:r.allpts[_+2],y:r.allpts[_+3]}):(P={x:r.allpts[D-2-_],y:r.allpts[D-1-_]},S={x:r.allpts[D-4-_],y:r.allpts[D-3-_]}),C=B,!((B+=T=Ht(P,S))>=u));_+=2);var A=(u-C)/T;A=Qt(0,A,1),t=function(e,t,n,r){var a=t.x-e.x,i=t.y-e.y,o=Ht(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=Kc(P,S)}o("labelX",n,t.x),o("labelY",n,t.y),o("labelAutoAngle",n,a)}};u("source"),u("target"),this.applyLabelDimensions(e)}},Uc.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},Uc.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),a=qe(r,e._private.labelDimsKey);if(ht(n.rscratch,"prefixedLabelDimsKey",t)!==a){ft(n.rscratch,"prefixedLabelDimsKey",t,a);var i=this.calculateLabelDimensions(e,r),o=e.pstyle("line-height").pfValue,s=e.pstyle("text-wrap").strValue,l=ht(n.rscratch,"labelWrapCachedLines",t)||[],u="wrap"!==s?1:Math.max(l.length,1),c=i.height/u,d=c*o,h=i.width,f=i.height+(u-1)*(o-1)*c;ft(n.rstyle,"labelWidth",t,h),ft(n.rscratch,"labelWidth",t,h),ft(n.rstyle,"labelHeight",t,f),ft(n.rscratch,"labelHeight",t,f),ft(n.rscratch,"labelLineHeight",t,d)}},Uc.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?(ft(n.rscratch,e,t,r),r):ht(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,v=0;v<c.length;v++){var g=c[v],y=this.calculateLabelDimensions(e,g).width;if(h){var m=g.split("").join("​");g=m}if(y>d){var b,x="",w=0,E=r(g.matchAll(p));try{for(E.s();!(b=E.n()).done;){var k=b.value,T=k[0],C=g.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(g)}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).width<S)return i;for(var _=0;_<i.length;_++){if(this.calculateLabelDimensions(e,B+i[_]+"…").width>S)break;B+=i[_],_===i.length-1&&(D=!0)}return D||(B+="…"),B}return i},Uc.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;if("auto"!==t)return t;if(!e.isNode())return"center";switch(n){case"left":return"right";case"right":return"left";default:return"center"}},Uc.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=this.labelCalcCanvas,l=this.labelCalcCanvasContext;if(!s){s=this.labelCalcCanvas=n.createElement("canvas"),l=this.labelCalcCanvasContext=s.getContext("2d");var u=s.style;u.position="absolute",u.left="-9999px",u.top="-9999px",u.zIndex="-1",u.visibility="hidden",u.pointerEvents="none"}l.font="".concat(r," ").concat(o," ").concat(a,"px ").concat(i);for(var c=0,d=0,h=t.split("\n"),f=0;f<h.length;f++){var p=h[f],v=l.measureText(p),g=Math.ceil(v.width),y=a;c=Math.max(g,c),d+=y}return{width:c+=0,height:d+=0}},Uc.calculateLabelAngle=function(e,t){var n=e._private.rscratch,r=e.isEdge(),a=t?t+"-":"",i=e.pstyle(a+"text-rotation"),o=i.strValue;return"none"===o?0:r&&"autorotate"===o?n.labelAutoAngle:"autorotate"===o?0:i.pfValue},Uc.calculateLabelAngles=function(e){var t=this,n=e.isEdge(),r=e._private.rscratch;r.labelAngle=t.calculateLabelAngle(e),n&&(r.sourceLabelAngle=t.calculateLabelAngle(e,"source"),r.targetLabelAngle=t.calculateLabelAngle(e,"target"))};var Gc={},Zc=!1;Gc.getNodeShape=function(e){var t=e.pstyle("shape").value;if("cutrectangle"===t&&(e.width()<28||e.height()<28))return Zc||(at("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),Zc=!0),"rectangle";if(e.isParent())return"rectangle"===t||"roundrectangle"===t||"round-rectangle"===t||"cutrectangle"===t||"cut-rectangle"===t||"barrel"===t?t:"rectangle";if("polygon"===t){var n=e.pstyle("shape-polygon-points").value;return this.nodeShapes.makePolygon(n).name}return t};var $c={registerCalculationListeners:function(){var e=this.cy,t=e.collection(),n=this,r=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t.merge(e),n)for(var r=0;r<e.length;r++){var a=e[r]._private.rstyle;a.clean=!1,a.cleanConnected=!1}};n.binder(e).on("bounds.* dirty.*",(function(e){var t=e.target;r(t)})).on("style.* background.*",(function(e){var t=e.target;r(t,!1)}));var a=function(a){if(a){var i=n.onUpdateEleCalcsFns;t.cleanStyle();for(var o=0;o<t.length;o++){var s=t[o],l=s._private.rstyle;s.isNode()&&!l.cleanConnected&&(r(s.connectedEdges()),l.cleanConnected=!0)}if(i)for(var u=0;u<i.length;u++){(0,i[u])(a,t)}n.recalculateRenderedStyle(t),t=e.collection()}};n.flushRenderedStyleQueue=function(){a(!0)},n.beforeRender(a,n.beforeRenderPriorities.eleCalcs)},onUpdateEleCalcs:function(e){(this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[]).push(e)},recalculateRenderedStyle:function(e,t){var n=function(e){return e._private.rstyle.cleanConnected};if(0!==e.length){var r=[],a=[];if(!this.destroyed){void 0===t&&(t=!0);for(var i=0;i<e.length;i++){var o=e[i],s=o._private,l=s.rstyle;!o.isEdge()||n(o.source())&&n(o.target())||(l.clean=!1),o.isEdge()&&o.isBundledBezier()&&o.parallelEdges().some((function(e){return!e._private.rstyle.clean&&e.isBundledBezier()}))&&(l.clean=!1),t&&l.clean||o.removed()||"none"!==o.pstyle("display").value&&("nodes"===s.group?a.push(o):r.push(o),l.clean=!0)}for(var u=0;u<a.length;u++){var c=a[u],d=c._private.rstyle,h=c.position();this.recalculateNodeLabelProjection(c),d.nodeX=h.x,d.nodeY=h.y,d.nodeW=c.pstyle("width").pfValue,d.nodeH=c.pstyle("height").pfValue}this.recalculateEdgeProjections(r);for(var f=0;f<r.length;f++){var p=r[f]._private,v=p.rstyle,g=p.rscratch;v.srcX=g.arrowStartX,v.srcY=g.arrowStartY,v.tgtX=g.arrowEndX,v.tgtY=g.arrowEndY,v.midX=g.midX,v.midY=g.midY,v.labelAngle=g.labelAngle,v.sourceLabelAngle=g.sourceLabelAngle,v.targetLabelAngle=g.targetLabelAngle}}}}},Qc={updateCachedGrabbedEles:function(){var e=this.cachedZSortedEles;if(e){e.drag=[],e.nondrag=[];for(var t=[],n=0;n<e.length;n++){var r=(a=e[n])._private.rscratch;a.grabbed()&&!a.isParent()?t.push(a):r.inDragLayer?e.drag.push(a):e.nondrag.push(a)}for(n=0;n<t.length;n++){var a=t[n];e.drag.push(a)}}},invalidateCachedZSortedEles:function(){this.cachedZSortedEles=null},getCachedZSortedEles:function(e){if(e||!this.cachedZSortedEles){var t=this.cy.mutableElements().toArray();t.sort(hl),t.interactive=t.filter((function(e){return e.interactive()})),this.cachedZSortedEles=t,this.updateCachedGrabbedEles()}else t=this.cachedZSortedEles;return t}},Jc={};[pc,vc,Xc,Yc,qc,Uc,Gc,$c,Qc].forEach((function(e){ge(Jc,e)}));var ed={getCachedImage:function(e,t,n){var r=this.imageCache=this.imageCache||{},a=r[e];if(a)return a.image.complete||a.image.addEventListener("load",n),a.image;var i=(a=r[e]=r[e]||{}).image=new Image;i.addEventListener("load",n),i.addEventListener("error",(function(){i.error=!0}));var o="data:";return e.substring(0,5).toLowerCase()===o||(t="null"===t?null:t,i.crossOrigin=t),i.src=e,i}},td={registerBinding:function(e,t,n,r){var a=Array.prototype.slice.apply(arguments,[1]);if(Array.isArray(e)){for(var i=[],o=0;o<e.length;o++){var s=e[o];if(void 0!==s){var l=this.binder(s);i.push(l.on.apply(l,a))}}return i}return(l=this.binder(e)).on.apply(l,a)}};td.binder=function(e){var t,n=this,r=n.cy.window(),a=e===r||e===r.document||e===r.document.body||(t=e,"undefined"!=typeof HTMLElement&&t instanceof HTMLElement);if(null==n.supportsPassiveEvents){var i=!1;try{var o=Object.defineProperty({},"passive",{get:function(){return i=!0,!0}});r.addEventListener("test",null,o)}catch(e){}n.supportsPassiveEvents=i}var s=function(t,r,i){var o=Array.prototype.slice.call(arguments);return a&&n.supportsPassiveEvents&&(o[2]={capture:null!=i&&i,passive:!1,once:!1}),n.bindings.push({target:e,args:o}),(e.addEventListener||e.on).apply(e,o),this};return{on:s,addEventListener:s,addListener:s,bind:s}},td.nodeIsDraggable=function(e){return e&&e.isNode()&&!e.locked()&&e.grabbable()},td.nodeIsGrabbable=function(e){return this.nodeIsDraggable(e)&&e.interactive()},td.load=function(){var e=this,t=e.cy.window(),n=function(e){return e.selected()},r=function(t,n,r,a){null==t&&(t=e.cy);for(var i=0;i<n.length;i++){var o=n[i];t.emit({originalEvent:r,type:o,position:a})}},a=function(e){return e.shiftKey||e.metaKey||e.ctrlKey},i=function(t,n){var r=!0;if(e.cy.hasCompoundNodes()&&t&&t.pannable())for(var a=0;n&&a<n.length;a++){if((t=n[a]).isNode()&&t.isParent()&&!t.pannable()){r=!1;break}}else r=!0;return r},o=function(e){e[0]._private.rscratch.inDragLayer=!0},s=function(e){e[0]._private.rscratch.isGrabTarget=!0},l=function(e,t){var n=t.addToList;n.has(e)||!e.grabbable()||e.locked()||(n.merge(e),function(e){e[0]._private.grabbed=!0}(e))},u=function(t,n){n=n||{};var r=t.cy().hasCompoundNodes();n.inDragLayer&&(t.forEach(o),t.neighborhood().stdFilter((function(e){return!r||e.isEdge()})).forEach(o)),n.addToList&&t.forEach((function(e){l(e,n)})),function(e,t){if(e.cy().hasCompoundNodes()&&(null!=t.inDragLayer||null!=t.addToList)){var n=e.descendants();t.inDragLayer&&(n.forEach(o),n.connectedEdges().forEach(o)),t.addToList&&l(n,t)}}(t,n),h(t,{inDragLayer:n.inDragLayer}),e.updateCachedGrabbedEles()},c=u,d=function(t){t&&(e.getCachedZSortedEles().forEach((function(e){!function(e){e[0]._private.grabbed=!1}(e),function(e){e[0]._private.rscratch.inDragLayer=!1}(e),function(e){e[0]._private.rscratch.isGrabTarget=!1}(e)})),e.updateCachedGrabbedEles())},h=function(e,t){if((null!=t.inDragLayer||null!=t.addToList)&&e.cy().hasCompoundNodes()){var n=e.ancestors().orphans();if(!n.same(e)){var r=n.descendants().spawnSelf().merge(n).unmerge(e).unmerge(e.descendants()),a=r.connectedEdges();t.inDragLayer&&(a.forEach(o),r.forEach(o)),t.addToList&&r.forEach((function(e){l(e,t)}))}}},f=function(){null!=document.activeElement&&null!=document.activeElement.blur&&document.activeElement.blur()},p="undefined"!=typeof MutationObserver,v="undefined"!=typeof ResizeObserver;p?(e.removeObserver=new MutationObserver((function(t){for(var n=0;n<t.length;n++){var r=t[n].removedNodes;if(r)for(var a=0;a<r.length;a++){if(r[a]===e.container){e.destroy();break}}}})),e.container.parentNode&&e.removeObserver.observe(e.container.parentNode,{childList:!0})):e.registerBinding(e.container,"DOMNodeRemoved",(function(t){e.destroy()}));var g=_e((function(){e.cy.resize()}),100);p&&(e.styleObserver=new MutationObserver(g),e.styleObserver.observe(e.container,{attributes:!0})),e.registerBinding(t,"resize",g),v&&(e.resizeObserver=new ResizeObserver(g),e.resizeObserver.observe(e.container));var y=function(){e.invalidateContainerClientCoordsCache()};!function(e,t){for(;null!=e;)t(e),e=e.parentNode}(e.container,(function(t){e.registerBinding(t,"transitionend",y),e.registerBinding(t,"animationend",y),e.registerBinding(t,"scroll",y)})),e.registerBinding(e.container,"contextmenu",(function(e){e.preventDefault()}));var m=function(t){for(var n=e.findContainerClientCoords(),r=n[0],a=n[1],i=n[2],o=n[3],s=t.touches?t.touches:[t],l=!1,u=0;u<s.length;u++){var c=s[u];if(r<=c.clientX&&c.clientX<=r+i&&a<=c.clientY&&c.clientY<=a+o){l=!0;break}}if(!l)return!1;for(var d=e.container,h=t.target.parentNode,f=!1;h;){if(h===d){f=!0;break}h=h.parentNode}return!!f};e.registerBinding(e.container,"mousedown",(function(t){if(m(t)&&(1!==e.hoverData.which||1===t.which)){t.preventDefault(),f(),e.hoverData.capture=!0,e.hoverData.which=t.which;var n=e.cy,a=[t.clientX,t.clientY],i=e.projectIntoViewport(a[0],a[1]),o=e.selection,l=e.findNearestElements(i[0],i[1],!0,!1),d=l[0],h=e.dragData.possibleDragElements;e.hoverData.mdownPos=i,e.hoverData.mdownGPos=a;var p=function(e){return{originalEvent:t,type:e,position:{x:i[0],y:i[1]}}};if(3==t.which){e.hoverData.cxtStarted=!0;var v={originalEvent:t,type:"cxttapstart",position:{x:i[0],y:i[1]}};d?(d.activate(),d.emit(v),e.hoverData.down=d):n.emit(v),e.hoverData.downTime=(new Date).getTime(),e.hoverData.cxtDragged=!1}else if(1==t.which){if(d&&d.activate(),null!=d&&e.nodeIsGrabbable(d)){if(s(d),d.selected()){h=e.dragData.possibleDragElements=n.collection();var g=n.$((function(t){return t.isNode()&&t.selected()&&e.nodeIsGrabbable(t)}));u(g,{addToList:h}),d.emit(p("grabon")),g.forEach((function(e){e.emit(p("grab"))}))}else h=e.dragData.possibleDragElements=n.collection(),c(d,{addToList:h}),d.emit(p("grabon")).emit(p("grab"));e.redrawHint("eles",!0),e.redrawHint("drag",!0)}e.hoverData.down=d,e.hoverData.downs=l,e.hoverData.downTime=(new Date).getTime(),r(d,["mousedown","tapstart","vmousedown"],t,{x:i[0],y:i[1]}),null==d?(o[4]=1,e.data.bgActivePosistion={x:i[0],y:i[1]},e.redrawHint("select",!0),e.redraw()):d.pannable()&&(o[4]=1),e.hoverData.tapholdCancelled=!1,clearTimeout(e.hoverData.tapholdTimeout),e.hoverData.tapholdTimeout=setTimeout((function(){if(!e.hoverData.tapholdCancelled){var t=e.hoverData.down;t?t.emit(p("taphold")):n.emit(p("taphold"))}}),e.tapholdDuration)}o[0]=o[2]=i[0],o[1]=o[3]=i[1]}}),!1);var b,x,w,E=function(e){var t=e.getRootNode();if(t&&11===t.nodeType&&void 0!==t.host)return t}(e.container);e.registerBinding([t,E],"mousemove",(function(t){if(e.hoverData.capture||m(t)){var n=!1,o=e.cy,s=o.zoom(),l=[t.clientX,t.clientY],c=e.projectIntoViewport(l[0],l[1]),h=e.hoverData.mdownPos,f=e.hoverData.mdownGPos,p=e.selection,v=null;e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.selecting||(v=e.findNearestElement(c[0],c[1],!0,!1));var g,y=e.hoverData.last,b=e.hoverData.down,x=[c[0]-p[2],c[1]-p[3]],w=e.dragData.possibleDragElements;if(f){var E=l[0]-f[0],k=E*E,T=l[1]-f[1],C=k+T*T;e.hoverData.isOverThresholdDrag=g=C>=e.desktopTapThreshold2}var P=a(t);g&&(e.hoverData.tapholdCancelled=!0);n=!0,r(v,["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(g){var D=S("cxtdrag");b?b.emit(D):o.emit(D),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&v===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit(S("cxtdragout")),e.hoverData.cxtOver=v,v&&v.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()||v==y||(y&&r(y,["mouseout","tapdragout"],t,{x:c[0],y:c[1]}),v&&r(v,["mouseover","tapdragover"],t,{x:c[0],y:c[1]}),e.hoverData.last=v),b)if(g){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(g){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=Yt(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 v=f("cxttap");c?c.emit(v):i.emit(v)}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 g=i.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint("select",!0),g.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(g).unselect(),g.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){var a=z;if(k=function(e,t){for(var n=0;n<e.length;n++)if(e[n]%t!=0)return!1;return!0}(a,5),!k){var i=Math.abs(a[0]);k=function(e){for(var t=Math.abs(e[0]),n=1;n<e.length;n++)if(Math.abs(e[n])!==t)return!1;return!0}(a)&&i>5}if(k)for(var o=0;o<a.length;o++)O=Math.min(Math.abs(a[o]),O)}else z.push(r),n=!0;else k&&(O=Math.min(Math.abs(r),O));if(!e.scrollingPage){var s=e.cy,l=s.zoom(),u=s.pan(),c=e.projectIntoViewport(t.clientX,t.clientY),d=[c[0]*l+u.x,c[1]*l+u.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||0!==e.selection[4])t.preventDefault();else if(s.panningEnabled()&&s.userPanningEnabled()&&s.zoomingEnabled()&&s.userZoomingEnabled()){var h;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*Ut(r)),h=r/-250,k&&(h/=O,h*=3),h*=e.wheelSensitivity,1===t.deltaMode&&(h*=33);var f=s.zoom()*Math.pow(10,h);"gesturechange"===t.type&&(f=e.gestureStartZoom*t.scale),s.zoom({level:f,renderedPosition:{x:d[0],y:d[1]}}),s.emit({type:"gesturechange"===t.type?"pinchzoom":"scrollzoom",originalEvent:t,position:{x:c[0],y:c[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(),v=n.zoom();B=H(T,C,P,S),D=K(T,C,P,S),A=[((_=[(T+P)/2,(C+S)/2])[0]-p.x)/v,(_[1]-p.y)/v];if(D<4e4&&!t.touches[2]){var g=e.findNearestElement(a[0],a[1],!0,!0),y=e.findNearestElement(a[2],a[3],!0,!0);return g&&g.isNode()?(g.activate().emit(l("cxttapstart")),e.touchData.start=g):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<a.length;z++)k[z]=i[z]=a[z];var O=t.touches[0];e.touchData.startGPosition=[O.clientX,O.clientY]}}},!1),e.registerBinding(t,"touchmove",X=function(t){var n=e.touchData.capture;if(n||m(t)){var a=e.selection,o=e.cy,s=e.touchData.now,l=e.touchData.earlier,c=o.zoom();if(t.touches[0]){var h=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=h[0],s[1]=h[1]}if(t.touches[1]){h=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=h[0],s[3]=h[1]}if(t.touches[2]){h=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=h[0],s[5]=h[1]}var f,p=function(e){return{originalEvent:t,type:e,position:{x:s[0],y:s[1]}}},v=e.touchData.startGPosition;if(n&&t.touches[0]&&v){for(var g=[],y=0;y<s.length;y++)g[y]=s[y]-l[y];var b=t.touches[0].clientX-v[0],x=b*b,w=t.touches[0].clientY-v[1];f=x+w*w>=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;V<te.length;V++){var F=te[V]._private;F.grabbed=!1,F.rscratch.inDragLayer=!1}}var X=e.touchData.start,j=(E=t.touches[0].clientX-M,k=t.touches[0].clientY-R,_=t.touches[1].clientX-M,I=t.touches[1].clientY-R,H(E,k,_,I)),Y=j/B;if(L){var q=(E-T+(_-P))/2,W=(k-C+(I-S))/2,U=o.zoom(),Z=U*Y,$=o.pan(),Q=A[0]*U+$.x,J=A[1]*U+$.y,ee={x:-Z/U*(Q-$.x-q)+Q,y:-Z/U*(J-$.y-W)+J};if(X&&X.active()){var te=e.dragData.touchDragEles;d(te),e.redrawHint("drag",!0),e.redrawHint("eles",!0),X.unactivate().emit(p("freeon")),te.emit(p("free")),e.dragData.didDrag&&(X.emit(p("dragfreeon")),te.emit(p("dragfree")))}o.viewport({zoom:Z,pan:ee,cancelOnFailedZoom:!0}),o.emit(p("pinchzoom")),B=j,T=E,C=k,P=_,S=I,e.pinching=!0}if(t.touches[0]){h=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=h[0],s[1]=h[1]}if(t.touches[1]){h=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=h[0],s[3]=h[1]}if(t.touches[2]){h=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=h[0],s[5]=h[1]}}else if(t.touches[0]&&!e.touchData.didSelect){var ne=e.touchData.start,re=e.touchData.last;if(e.hoverData.draggingEles||e.swipePanning||(O=e.findNearestElement(s[0],s[1],!0,!0)),n&&null!=ne&&t.preventDefault(),n&&null!=ne&&e.nodeIsDraggable(ne))if(f){te=e.dragData.touchDragEles;var ae=!e.dragData.didDrag;ae&&u(te,{inDragLayer:!0}),e.dragData.didDrag=!0;var ie={x:0,y:0};if(G(g[0])&&G(g[1]))if(ie.x+=g[0],ie.y+=g[1],ae)e.redrawHint("eles",!0),(oe=e.touchData.dragDelta)&&G(oe[0])&&G(oe[1])&&(ie.x+=oe[0],ie.y+=oe[1]);e.hoverData.draggingEles=!0,te.silentShift(ie).emit(p("position")).emit(p("drag")),e.redrawHint("drag",!0),e.touchData.startPosition[0]==l[0]&&e.touchData.startPosition[1]==l[1]&&e.redrawHint("eles",!0),e.redraw()}else{var oe;0===(oe=e.touchData.dragDelta=e.touchData.dragDelta||[]).length?(oe.push(g[0]),oe.push(g[1])):(oe[0]+=g[0],oe[1]+=g[1])}if(r(ne||O,["touchmove","tapdrag","vmousemove"],t,{x:s[0],y:s[1]}),ne&&ne.grabbed()||O==re||(re&&re.emit(p("tapdragout")),O&&O.emit(p("tapdragover"))),e.touchData.last=O,n)for(V=0;V<s.length;V++)s[V]&&e.touchData.startPosition[V]&&f&&(e.touchData.singleTouchMoved=!0);if(n&&(null==ne||ne.pannable())&&o.panningEnabled()&&o.userPanningEnabled()){i(ne,e.touchData.starts)&&(t.preventDefault(),e.data.bgActivePosistion||(e.data.bgActivePosistion=Yt(e.touchData.startPosition)),e.swipePanning?(o.panBy({x:g[0]*c,y:g[1]*c}),o.emit(p("dragpan"))):f&&(e.swipePanning=!0,o.panBy({x:b*c,y:w*c}),o.emit(p("dragpan")),ne&&(ne.unactivate(),e.redrawHint("select",!0),e.touchData.start=null)));h=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=h[0],s[1]=h[1]}}for(y=0;y<s.length;y++)l[y]=s[y];n&&t.touches.length>0&&!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 v=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"));v.emit(f("box")).stdFilter((function(e){return e.selectable()&&!e.selected()})).select().emit(f("boxselect")),v.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 g=e.dragData.touchDragEles;if(null!=a){var y=a._private.grabbed;d(g),e.redrawHint("drag",!0),e.redrawHint("eles",!0),y&&(a.emit(f("freeon")),g.emit(f("free")),e.dragData.didDrag&&(a.emit(f("dragfreeon")),g.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&&E<e.touchTapThreshold2&&!e.pinching&&("single"===o.selectionType()?(o.$(n).unmerge(a).unselect(["tapunselect"]),a.select(["tapselect"])):a.selected()?a.unselect(["tapunselect"]):a.select(["tapselect"]),e.redrawHint("eles",!0)),e.touchData.singleTouchMoved=!0}for(var k=0;k<l.length;k++)u[k]=l[k];e.dragData.didDrag=!1,0===t.touches.length&&(e.touchData.dragDelta=[],e.touchData.startPosition=[null,null,null,null,null,null],e.touchData.startGPosition=null,e.touchData.didSelect=!1),t.touches.length<2&&(1===t.touches.length&&(e.touchData.startGPosition=[t.touches[0].clientX,t.touches[0].clientY]),e.pinching=!1,e.redrawHint("eles",!0),e.redraw())}},!1),"undefined"==typeof TouchEvent){var Z=[],$=function(e){return{clientX:e.clientX,clientY:e.clientY,force:1,identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,radiusX:e.width/2,radiusY:e.height/2,screenX:e.screenX,screenY:e.screenY,target:e.target}},Q=function(e){Z.push(function(e){return{event:e,touch:$(e)}}(e))},J=function(e){for(var t=0;t<Z.length;t++){if(Z[t].event.pointerId===e.pointerId)return void Z.splice(t,1)}},ee=function(e){e.touches=Z.map((function(e){return e.touch}))},te=function(e){return"mouse"===e.pointerType||4===e.pointerType};e.registerBinding(e.container,"pointerdown",(function(e){te(e)||(e.preventDefault(),Q(e),ee(e),F(e))})),e.registerBinding(e.container,"pointerup",(function(e){te(e)||(J(e),ee(e),Y(e))})),e.registerBinding(e.container,"pointercancel",(function(e){te(e)||(J(e),ee(e),j())})),e.registerBinding(e.container,"pointermove",(function(e){te(e)||(e.preventDefault(),function(e){var t=Z.filter((function(t){return t.event.pointerId===e.pointerId}))[0];t.event=e,t.touch=$(e)}(e),ee(e),X(e))}))}};var nd={generatePolygon:function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,draw:function(e,t,n,r,a,i){this.renderer.nodeShapeImpl("polygon",e,t,n,r,a,this.points)},intersectLine:function(e,t,n,r,a,i,o,s){return Cn(a,i,this.points,e,t,n/2,r/2,o)},checkPoint:function(e,t,n,r,a,i,o,s){return yn(e,t,this.points,i,o,r,a,[0,-1],n)},hasMiterBounds:"rectangle"!==e,miterBounds:function(e,t,n,r,a,i){return cn(this.points,e,t,n,r,a)}}}};nd.generateEllipse=function(){return this.nodeShapes.ellipse={renderer:this,name:"ellipse",draw:function(e,t,n,r,a,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,a)},intersectLine:function(e,t,n,r,a,i,o,s){return function(e,t,n,r,a,i){var o=n-e,s=r-t;o/=a,s/=i;var l=Math.sqrt(o*o+s*s),u=l-1;if(u<0)return[];var c=u/l;return[(n-e)*c+e,(r-t)*c+t]}(a,i,e,t,n/2+o,r/2+o)},checkPoint:function(e,t,n,r,a,i,o,s){return xn(e,t,r,a,i,o,n)}}},nd.generateRoundPolygon=function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,getOrCreateCorners:function(e,n,r,a,i,o,s){if(void 0!==o[s]&&o[s+"-cx"]===e&&o[s+"-cy"]===n)return o[s];o[s]=new Array(t.length/2),o[s+"-cx"]=e,o[s+"-cy"]=n;var l=r/2,u=a/2;i="auto"===i?An(r,a):i;for(var c=new Array(t.length/2),d=0;d<t.length/2;d++)c[d]={x:e+l*t[2*d],y:n+u*t[2*d+1]};var h,f,p,v,g=c.length;for(f=c[g-1],h=0;h<g;h++)p=c[h%g],v=c[(h+1)%g],o[s][h]=Oc(f,p,v,i),f=p,p=v;return o[s]},draw:function(e,t,n,r,a,i,o){this.renderer.nodeShapeImpl("round-polygon",e,t,n,r,a,this.points,this.getOrCreateCorners(t,n,r,a,i,o,"drawCorners"))},intersectLine:function(e,t,n,r,a,i,o,s,l){return function(e,t,n,r,a,i,o,s,l){var u,c=[],d=new Array(2*n.length);l.forEach((function(n,i){0===i?(d[d.length-2]=n.startX,d[d.length-1]=n.startY):(d[4*i-2]=n.startX,d[4*i-1]=n.startY),d[4*i]=n.stopX,d[4*i+1]=n.stopY,0!==(u=wn(e,t,r,a,n.cx,n.cy,n.radius)).length&&c.push(u[0],u[1])}));for(var h=0;h<d.length/4;h++)0!==(u=kn(e,t,r,a,d[4*h],d[4*h+1],d[4*h+2],d[4*h+3],!1)).length&&c.push(u[0],u[1]);if(c.length>2){for(var f=[c[0],c[1]],p=Math.pow(f[0]-e,2)+Math.pow(f[1]-t,2),v=1;v<c.length/2;v++){var g=Math.pow(c[2*v]-e,2)+Math.pow(c[2*v+1]-t,2);g<=p&&(f[0]=c[2*v],f[1]=c[2*v+1],p=g)}return f}return c}(a,i,this.points,e,t,0,0,0,this.getOrCreateCorners(e,t,n,r,s,l,"corners"))},checkPoint:function(e,t,n,r,a,i,o,s,l){return function(e,t,n,r,a,i,o,s){for(var l=new Array(2*n.length),u=0;u<s.length;u++){var c=s[u];if(l[4*u+0]=c.startX,l[4*u+1]=c.startY,l[4*u+2]=c.stopX,l[4*u+3]=c.stopY,Math.pow(c.cx-e,2)+Math.pow(c.cy-t,2)<=Math.pow(c.radius,2))return!0}return gn(e,t,l)}(e,t,this.points,0,0,0,0,this.getOrCreateCorners(i,o,r,a,s,l,"corners"))}}},nd.generateRoundRectangle=function(){return this.nodeShapes["round-rectangle"]=this.nodeShapes.roundrectangle={renderer:this,name:"round-rectangle",points:Sn(4,0),draw:function(e,t,n,r,a,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,a,this.points,i)},intersectLine:function(e,t,n,r,a,i,o,s){return dn(a,i,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,a,i,o,s){var l=r/2,u=a/2;s="auto"===s?_n(r,a):s;var c=2*(s=Math.min(l,u,s));return!!yn(e,t,this.points,i,o,r,a-c,[0,-1],n)||(!!yn(e,t,this.points,i,o,r-c,a,[0,-1],n)||(!!xn(e,t,c,c,i-l+s,o-u+s,n)||(!!xn(e,t,c,c,i+l-s,o-u+s,n)||(!!xn(e,t,c,c,i+l-s,o+u-s,n)||!!xn(e,t,c,c,i-l+s,o+u-s,n)))))}}},nd.generateCutRectangle=function(){return this.nodeShapes["cut-rectangle"]=this.nodeShapes.cutrectangle={renderer:this,name:"cut-rectangle",cornerLength:8,points:Sn(4,0),draw:function(e,t,n,r,a,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,a,null,i)},generateCutTrianglePts:function(e,t,n,r,a){var i="auto"===a?this.cornerLength:a,o=t/2,s=e/2,l=n-s,u=n+s,c=r-o,d=r+o;return{topLeft:[l,c+i,l+i,c,l+i,c+i],topRight:[u-i,c,u,c+i,u-i,c+i],bottomRight:[u,d-i,u-i,d,u-i,d-i],bottomLeft:[l+i,d,l,d-i,l+i,d-i]}},intersectLine:function(e,t,n,r,a,i,o,s){var l=this.generateCutTrianglePts(n+2*o,r+2*o,e,t,s),u=[].concat.apply([],[l.topLeft.splice(0,4),l.topRight.splice(0,4),l.bottomRight.splice(0,4),l.bottomLeft.splice(0,4)]);return Cn(a,i,u,e,t)},checkPoint:function(e,t,n,r,a,i,o,s){var l="auto"===s?this.cornerLength:s;if(yn(e,t,this.points,i,o,r,a-2*l,[0,-1],n))return!0;if(yn(e,t,this.points,i,o,r-2*l,a,[0,-1],n))return!0;var u=this.generateCutTrianglePts(r,a,i,o);return gn(e,t,u.topLeft)||gn(e,t,u.topRight)||gn(e,t,u.bottomRight)||gn(e,t,u.bottomLeft)}}},nd.generateBarrel=function(){return this.nodeShapes.barrel={renderer:this,name:"barrel",points:Sn(4,0),draw:function(e,t,n,r,a,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,a)},intersectLine:function(e,t,n,r,a,i,o,s){var l=this.generateBarrelBezierPts(n+2*o,r+2*o,e,t),u=function(e){var t=$t({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.15),n=$t({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.5),r=$t({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.85);return[e[0],e[1],t.x,t.y,n.x,n.y,r.x,r.y,e[4],e[5]]},c=[].concat(u(l.topLeft),u(l.topRight),u(l.bottomRight),u(l.bottomLeft));return Cn(a,i,c,e,t)},generateBarrelBezierPts:function(e,t,n,r){var a=t/2,i=e/2,o=n-i,s=n+i,l=r-a,u=r+a,c=Mn(e,t),d=c.heightOffset,h=c.widthOffset,f=c.ctrlPtOffsetPct*e,p={topLeft:[o,l+d,o+f,l,o+h,l],topRight:[s-h,l,s-f,l,s,l+d],bottomRight:[s,u-d,s-f,u,s-h,u],bottomLeft:[o+h,u,o+f,u,o,u-d]};return p.topLeft.isTop=!0,p.topRight.isTop=!0,p.bottomLeft.isBottom=!0,p.bottomRight.isBottom=!0,p},checkPoint:function(e,t,n,r,a,i,o,s){var l=Mn(r,a),u=l.heightOffset,c=l.widthOffset;if(yn(e,t,this.points,i,o,r,a-2*u,[0,-1],n))return!0;if(yn(e,t,this.points,i,o,r-2*c,a,[0,-1],n))return!0;for(var d=this.generateBarrelBezierPts(r,a,i,o),h=function(e,t,n){var r,a,i=n[4],o=n[2],s=n[0],l=n[5],u=n[1],c=Math.min(i,s),d=Math.max(i,s),h=Math.min(l,u),f=Math.max(l,u);if(c<=e&&e<=d&&h<=t&&t<=f){var p=[(r=i)-2*(a=o)+s,2*(a-r),r],v=function(e,t,n,r){var a=t*t-4*e*(n-=r);if(a<0)return[];var i=Math.sqrt(a),o=2*e;return[(-t+i)/o,(-t-i)/o]}(p[0],p[1],p[2],e).filter((function(e){return 0<=e&&e<=1}));if(v.length>0)return v[0]}return null},f=Object.keys(d),p=0;p<f.length;p++){var v=d[f[p]],g=h(e,t,v);if(null!=g){var y=v[5],m=v[3],b=v[1],x=Zt(y,m,b,g);if(v.isTop&&x<=t)return!0;if(v.isBottom&&t<=x)return!0}}return!1}}},nd.generateBottomRoundrectangle=function(){return this.nodeShapes["bottom-round-rectangle"]=this.nodeShapes.bottomroundrectangle={renderer:this,name:"bottom-round-rectangle",points:Sn(4,0),draw:function(e,t,n,r,a,i){this.renderer.nodeShapeImpl(this.name,e,t,n,r,a,this.points,i)},intersectLine:function(e,t,n,r,a,i,o,s){var l=t-(r/2+o),u=kn(a,i,e,t,e-(n/2+o),l,e+(n/2+o),l,!1);return u.length>0?u:dn(a,i,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,a,i,o,s){var l=2*(s="auto"===s?_n(r,a):s);if(yn(e,t,this.points,i,o,r,a-l,[0,-1],n))return!0;if(yn(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!!gn(e,t,[i-u,o-c,i-u,o,i+u,o,i+u,o-c])||(!!xn(e,t,l,l,i+r/2-s,o+a/2-s,n)||!!xn(e,t,l,l,i-r/2+s,o+a/2-s,n))}}},nd.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",Sn(3,0)),this.generateRoundPolygon("round-triangle",Sn(3,0)),this.generatePolygon("rectangle",Sn(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",Sn(5,0)),this.generateRoundPolygon("round-pentagon",Sn(5,0)),this.generatePolygon("hexagon",Sn(6,0)),this.generateRoundPolygon("round-hexagon",Sn(6,0)),this.generatePolygon("heptagon",Sn(7,0)),this.generateRoundPolygon("round-heptagon",Sn(7,0)),this.generatePolygon("octagon",Sn(8,0)),this.generateRoundPolygon("round-octagon",Sn(8,0));var r=new Array(20),a=Dn(5,0),i=Dn(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s<i.length/2;s++)i[2*s]*=o,i[2*s+1]*=o;for(s=0;s<5;s++)r[4*s]=a[2*s],r[4*s+1]=a[2*s+1],r[4*s+2]=i[2*s],r[4*s+3]=i[2*s+1];r=Bn(r),this.generatePolygon("star",r),this.generatePolygon("vee",[-1,-1,0,-.333,1,-1,0,1]),this.generatePolygon("rhomboid",[-1,-1,.333,-1,1,1,-.333,1]),this.generatePolygon("right-rhomboid",[-.333,-1,1,-1,.333,1,-1,1]),this.nodeShapes.concavehexagon=this.generatePolygon("concave-hexagon",[-1,-.95,-.75,0,-1,.95,1,.95,.75,0,1,-.95]);var l=[-1,-1,.25,-1,1,0,.25,1,-1,1];this.generatePolygon("tag",l),this.generateRoundPolygon("round-tag",l),e.makePolygon=function(e){var n,r="polygon-"+e.join("$");return(n=this[r])?n:t.generatePolygon(r,e)}};var rd={timeToRender:function(){return this.redrawTotalTime/this.redrawCount},redraw:function(e){e=e||lt();var t=this;void 0===t.averageRedrawTime&&(t.averageRedrawTime=0),void 0===t.lastRedrawTime&&(t.lastRedrawTime=0),void 0===t.lastDrawTime&&(t.lastDrawTime=0),t.requestedFrame=!0,t.renderOptions=e},beforeRender:function(e,t){if(!this.destroyed){null==t&&nt("Priority is not optional for beforeRender");var n=this.beforeRenderCallbacks;n.push({fn:e,priority:t}),n.sort((function(e,t){return t.priority-e.priority}))}}},ad=function(e,t,n){for(var r=e.beforeRenderCallbacks,a=0;a<r.length;a++)r[a].fn(t,n)};rd.startRenderLoop=function(){var e=this,t=e.cy;if(!e.renderLoopStarted){e.renderLoopStarted=!0;var n=function(r){if(!e.destroyed){if(t.batching());else if(e.requestedFrame&&!e.skipFrame){ad(e,!0,r);var a=Ne();e.render(e.renderOptions);var i=e.lastDrawTime=Ne();void 0===e.averageRedrawTime&&(e.averageRedrawTime=i-a),void 0===e.redrawCount&&(e.redrawCount=0),e.redrawCount++,void 0===e.redrawTotalTime&&(e.redrawTotalTime=0);var o=i-a;e.redrawTotalTime+=o,e.lastRedrawTime=o,e.averageRedrawTime=e.averageRedrawTime/2+o/2,e.requestedFrame=!1}else ad(e,!1,r);e.skipFrame=!1,Ie(n)}};Ie(n)}};var id=function(e){this.init(e)},od=id.prototype;od.clientFunctions=["redrawHint","render","renderTo","matchCanvasSize","nodeShapeImpl","arrowShapeImpl"],od.init=function(e){var t=this;t.options=e,t.cy=e.cy;var n=t.container=e.cy.container(),r=t.cy.window();if(r){var a=r.document,i=a.head,o="__________cytoscape_stylesheet",s="__________cytoscape_container",l=null!=a.getElementById(o);if(n.className.indexOf(s)<0&&(n.className=(n.className||"")+" "+s),!l){var u=a.createElement("style");u.id=o,u.textContent="."+s+" { position: relative; }",i.insertBefore(u,i.children[0])}"static"===r.getComputedStyle(n).getPropertyValue("position")&&at("A Cytoscape container has style position:static and so can not use UI extensions properly")}t.selection=[void 0,void 0,void 0,void 0,0],t.bezierProjPcts=[.05,.225,.4,.5,.6,.775,.95],t.hoverData={down:null,last:null,downTime:null,triggerMode:null,dragging:!1,initialPan:[null,null],capture:!1},t.dragData={possibleDragElements:[]},t.touchData={start:null,capture:!1,startPosition:[null,null,null,null,null,null],singleTouchStartTime:null,singleTouchMoved:!0,now:[null,null,null,null,null,null],earlier:[null,null,null,null,null,null]},t.redraws=0,t.showFps=e.showFps,t.debug=e.debug,t.webgl=e.webgl,t.hideEdgesOnViewport=e.hideEdgesOnViewport,t.textureOnViewport=e.textureOnViewport,t.wheelSensitivity=e.wheelSensitivity,t.motionBlurEnabled=e.motionBlur,t.forcedPixelRatio=G(e.pixelRatio)?e.pixelRatio:null,t.motionBlur=e.motionBlur,t.motionBlurOpacity=e.motionBlurOpacity,t.motionBlurTransparency=1-t.motionBlurOpacity,t.motionBlurPxRatio=1,t.mbPxRBlurry=1,t.minMbLowQualFrames=4,t.fullQualityMb=!1,t.clearedForMotionBlur=[],t.desktopTapThreshold=e.desktopTapThreshold,t.desktopTapThreshold2=e.desktopTapThreshold*e.desktopTapThreshold,t.touchTapThreshold=e.touchTapThreshold,t.touchTapThreshold2=e.touchTapThreshold*e.touchTapThreshold,t.tapholdDuration=500,t.bindings=[],t.beforeRenderCallbacks=[],t.beforeRenderPriorities={animations:400,eleCalcs:300,eleTxrDeq:200,lyrTxrDeq:150,lyrTxrSkip:100},t.registerNodeShapes(),t.registerArrowShapes(),t.registerCalculationListeners()},od.notify=function(e,t){var n=this,r=n.cy;this.destroyed||("init"!==e?"destroy"!==e?(("add"===e||"remove"===e||"move"===e&&r.hasCompoundNodes()||"load"===e||"zorder"===e||"mount"===e)&&n.invalidateCachedZSortedEles(),"viewport"===e&&n.redrawHint("select",!0),"gc"===e&&n.redrawHint("gc",!0),"load"!==e&&"resize"!==e&&"mount"!==e||(n.invalidateContainerClientCoordsCache(),n.matchCanvasSize(n.container)),n.redrawHint("eles",!0),n.redrawHint("drag",!0),this.startRenderLoop(),this.redraw()):n.destroy():n.load())},od.destroy=function(){var e=this;e.destroyed=!0,e.cy.stopAnimationLoop();for(var t=0;t<e.bindings.length;t++){var n=e.bindings[t],r=n.target;(r.off||r.removeEventListener).apply(r,n.args)}if(e.bindings=[],e.beforeRenderCallbacks=[],e.onUpdateEleCalcsFns=[],e.removeObserver&&e.removeObserver.disconnect(),e.styleObserver&&e.styleObserver.disconnect(),e.resizeObserver&&e.resizeObserver.disconnect(),e.labelCalcDiv)try{document.body.removeChild(e.labelCalcDiv)}catch(e){}},od.isHeadless=function(){return!1},[fc,Jc,ed,td,nd,rd].forEach((function(e){ge(od,e)}));var sd=1e3/60,ld=function(e){return function(){var t=this,n=this.renderer;if(!t.dequeueingSetup){t.dequeueingSetup=!0;var r=_e((function(){n.redrawHint("eles",!0),n.redrawHint("drag",!0),n.redraw()}),e.deqRedrawThreshold),a=e.priority||tt;n.beforeRender((function(a,i){var o=Ne(),s=n.averageRedrawTime,l=n.lastRedrawTime,u=[],c=n.cy.extent(),d=n.getPixelRatio();for(a||n.flushRenderedStyleQueue();;){var h=Ne(),f=h-o,p=h-i;if(l<sd){var v=sd-(a?s:0);if(p>=e.deqFastCost*v)break}else if(a){if(f>=e.deqCost*l||f>=e.deqAvgCost*s)break}else if(p>=e.deqNoDrawCost*sd)break;var g=e.deq(t,d,c);if(!(g.length>0))break;for(var y=0;y<g.length;y++)u.push(g[y])}u.length>0&&(e.onDeqd(t,u),!a&&e.shouldRedraw(t,u,d,c)&&r())}),a(t))}}},ud=function(){return n((function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Je;t(this,e),this.idsByKey=new pt,this.keyForId=new pt,this.cachesByLvl=new pt,this.lvls=[],this.getKey=n,this.doesEleInvalidateKey=r}),[{key:"getIdsFor",value:function(e){null==e&&nt("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new gt,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 pt,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)}}])}(),cd=7.99,dd={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},hd=ut({getKey:null,doesEleInvalidateKey:Je,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Qe,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),fd=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=hd(t);ge(n,r),n.lookup=new ud(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},pd=fd.prototype;pd.reasons=dd,pd.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},pd.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},pd.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new St((function(e,t){return t.reqs-e.reqs}))},pd.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},pd.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(Wt(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 v=i.getTextureQueue(f),g=v[v.length-2],y=function(){return i.recycleTexture(f,d)||i.addTexture(f,d)};g||(g=v[v.length-1]),g||(g=y()),g.width-g.usedWidth<d&&(g=y());for(var m,b=function(e){return e&&e.scaledLabelShown===h},x=a&&a===dd.dequeue,w=a&&a===dd.highQuality,E=a&&a===dd.downscale,k=r+1;k<=3;k++){var T=l.get(e,k);if(T){m=T;break}}var C=m&&m.level===r+1?m:null,P=function(){g.context.drawImage(C.texture.canvas,C.x,0,C.width,C.height,g.usedWidth,0,d,c)};if(g.context.setTransform(1,0,0,1,0,0),g.context.clearRect(g.usedWidth,0,d,f),b(C))P();else if(b(m)){if(!w)return i.queueElement(e,m.level-1),m;for(var S=m.level;S>r;S--)C=i.getElement(e,t,n,S,dd.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;g.context.translate(g.usedWidth,0),g.context.scale(u,u),this.drawElement(g.context,e,t,h,!1),g.context.scale(1/u,1/u),g.context.translate(-g.usedWidth,0)}return p={x:g.usedWidth,texture:g,level:r,scale:u,width:d,height:c,scaledLabelShown:h},g.usedWidth+=Math.ceil(d+8),g.eleCaches.push(p),l.set(e,r,p),i.checkTextureFullness(g),p},pd.invalidateElements=function(e){for(var t=0;t<e.length;t++)this.invalidateElement(e[t])},pd.invalidateElement=function(e){var t=this,n=t.lookup,r=[];if(n.isInvalid(e)){for(var a=-4;a<=3;a++){var i=n.getForCachedKey(e,a);i&&r.push(i)}if(n.invalidate(e))for(var o=0;o<r.length;o++){var s=r[o],l=s.texture;l.invalidatedWidth+=s.width,s.invalidated=!0,t.checkTextureUtility(l)}t.removeFromQueue(e)}},pd.checkTextureUtility=function(e){e.invalidatedWidth>=.2*e.width&&this.retireTexture(e)},pd.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?ct(t,e):e.fullnessChecks++},pd.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;ct(n,e),e.retired=!0;for(var a=e.eleCaches,i=0;i<a.length;i++){var o=a[i];r.deleteCache(o.key,o.level)}dt(a),this.getRetiredTextureQueue(t).push(e)},pd.addTexture=function(e,t){var n={};return this.getTextureQueue(e).push(n),n.eleCaches=[],n.height=e,n.width=Math.max(1024,t),n.usedWidth=0,n.invalidatedWidth=0,n.fullnessChecks=0,n.canvas=this.renderer.makeOffscreenCanvas(n.width,n.height),n.context=n.canvas.getContext("2d"),n},pd.recycleTexture=function(e,t){for(var n=this.getTextureQueue(e),r=this.getRetiredTextureQueue(e),a=0;a<r.length;a++){var i=r[a];if(i.width>=t)return i.retired=!1,i.usedWidth=0,i.invalidatedWidth=0,i.fullnessChecks=0,dt(i.eleCaches),i.context.setTransform(1,0,0,1,0,0),i.context.clearRect(0,0,i.width,i.height),ct(r,i),n.push(i),i}},pd.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}},pd.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,dd.dequeue)}}return a},pd.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=$e,t.updateItem(a),t.pop(),n[r]=null):a.eles.unmerge(e))},pd.onDequeue=function(e){this.onDequeues.push(e)},pd.offDequeue=function(e){ct(this.onDequeues,e)},pd.setupDequeueing=ld({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<e.onDequeues.length;n++){(0,e.onDequeues[n])(t)}},shouldRedraw:function(e,t,n,r){for(var a=0;a<t.length;a++)for(var i=t[a].eles,o=0;o<i.length;o++){var s=i[o].boundingBox();if(an(s,r))return!0}return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var vd=function(e){var t=this,n=t.renderer=e,r=n.cy;t.layersByLevel={},t.firstGet=!0,t.lastInvalidationTime=Ne()-500,t.skipping=!1,t.eleTxrDeqs=r.collection(),t.scheduleElementRefinement=_e((function(){t.refineElementTextures(t.eleTxrDeqs),t.eleTxrDeqs.unmerge(t.eleTxrDeqs)}),50),n.beforeRender((function(e,n){n-t.lastInvalidationTime<=250?t.skipping=!0:t.skipping=!1}),n.beforeRenderPriorities.lyrTxrSkip);t.layersQueue=new St((function(e,t){return t.reqs-e.reqs})),t.setupDequeueing()},gd=vd.prototype,yd=0,md=Math.pow(2,53)-1;gd.makeLayer=function(e,t){var n=Math.pow(2,t),r=Math.ceil(e.w*n),a=Math.ceil(e.h*n),i=this.renderer.makeOffscreenCanvas(r,a),o={id:yd=++yd%md,bb:e,level:t,width:r,height:a,canvas:i,context:i.getContext("2d"),eles:[],elesQueue:[],reqs:0},s=o.context,l=-o.bb.x1,u=-o.bb.y1;return s.scale(n,n),s.translate(l,u),o},gd.getLayers=function(e,t,n){var r=this,a=r.renderer.cy.zoom(),i=r.firstGet;if(r.firstGet=!1,null==n)if((n=Math.ceil(Wt(a*t)))<-4)n=-4;else if(a>=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&&ct(c,o)}}();var d=function(t){var a=(t=t||{}).after;!function(){if(!o){o=Jt();for(var t=0;t<e.length;t++)n=o,r=e[t].boundingBox(),n.x1=Math.min(n.x1,r.x1),n.x2=Math.max(n.x2,r.x2),n.w=n.x2-n.x1,n.y1=Math.min(n.y1,r.y1),n.y2=Math.max(n.y2,r.y2),n.h=n.y2-n.y1}var n,r}();var i=Math.ceil(o.w*u),s=Math.ceil(o.h*u);if(i>32767||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,v=0;v<e.length;v++){var g=e[v],y=g._private.rscratch,m=y.imgLayerCaches=y.imgLayerCaches||{},b=m[n];if(b)h=b;else{if((!h||h.eles.length>=f||!ln(h.bb,g.boundingBox()))&&!(h=d({insert:!0,after:h})))return null;s||p?r.queueLayer(h,g):r.drawEleInLayer(h,g,n,t),h.eles.push(g),m[n]=h}}return s||(p?null:c)},gd.getEleLevelForLayerLevel=function(e,t){return e},gd.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))},gd.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,a=0;a<n.length;a++){var i=n[a];if(i.reqs>0)return!1;if(i.invalid)return!1;r+=i.eles.length}return r===t.length},gd.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r<n.length;r++){for(var a=n[r],i=-1,o=0;o<t.length;o++)if(a.eles[0]===t[o]){i=o;break}if(i<0)this.invalidateLayer(a);else{var s=i;for(o=0;o<a.eles.length;o++)if(a.eles[o]!==t[s+o]){this.invalidateLayer(a);break}}}},gd.updateElementsInLayers=function(e,t){for(var n=Q(e[0]),r=0;r<e.length;r++)for(var a=n?null:e[r],i=n?e[r]:e[r].ele,o=i._private.rscratch,s=o.imgLayerCaches=o.imgLayerCaches||{},l=-4;l<=2;l++){var u=s[l];u&&(a&&this.getEleLevelForLayerLevel(u.level)!==a.level||t(u,i,a))}},gd.haveLayers=function(){for(var e=!1,t=-4;t<=2;t++){var n=this.layersByLevel[t];if(n&&n.length>0){e=!0;break}}return e},gd.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=Ne(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,(function(e,n,r){t.invalidateLayer(e)})))},gd.invalidateLayer=function(e){if(this.lastInvalidationTime=Ne(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];ct(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var a=0;a<n.length;a++){var i=n[a]._private.rscratch.imgLayerCaches;i&&(i[t]=null)}}},gd.refineElementTextures=function(e){var t=this;t.updateElementsInLayers(e,(function(e,n,r){var a=e.replacement;if(a||((a=e.replacement=t.makeLayer(e.bb,e.level)).replaces=e,a.eles=e.eles),!a.reqs)for(var i=0;i<a.eles.length;i++)t.queueLayer(a,a.eles[i])}))},gd.enqueueElementRefinement=function(e){this.eleTxrDeqs.merge(e),this.scheduleElementRefinement()},gd.queueLayer=function(e,t){var n=this.layersQueue,r=e.elesQueue,a=r.hasId=r.hasId||{};if(!e.replacement){if(t){if(a[t.id()])return;r.push(t),a[t.id()]=!0}e.reqs?(e.reqs++,n.updateItem(e)):(e.reqs=1,n.push(e))}},gd.dequeue=function(e){for(var t=this,n=t.layersQueue,r=[],a=0;a<1&&0!==n.size();){var i=n.peek();if(i.replacement)n.pop();else if(i.replaces&&i!==i.replaces.replacement)n.pop();else if(i.invalid)n.pop();else{var o=i.elesQueue.shift();o&&(t.drawEleInLayer(i,o,i.level,e),a++),0===r.length&&r.push(!0),0===i.elesQueue.length&&(n.pop(),i.reqs=0,i.replaces&&t.applyLayerReplacement(i),t.requestRedraw())}}return r},gd.applyLayerReplacement=function(e){var t=this.layersByLevel[e.level],n=e.replaces,r=t.indexOf(n);if(!(r<0||n.invalid)){t[r]=e;for(var a=0;a<e.eles.length;a++){var i=e.eles[a]._private,o=i.imgLayerCaches=i.imgLayerCaches||{};o&&(o[e.level]=e)}this.requestRedraw()}},gd.requestRedraw=_e((function(){var e=this.renderer;e.redrawHint("eles",!0),e.redrawHint("drag",!0),e.redraw()}),100),gd.setupDequeueing=ld({deqRedrawThreshold:50,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t){return e.dequeue(t)},onDeqd:tt,shouldRedraw:Qe,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var bd,xd={};function wd(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.lineTo(r.x,r.y)}}function Ed(e,t,n){for(var r,a=0;a<t.length;a++){var i=t[a];0===a&&(r=i),e.lineTo(i.x,i.y)}e.quadraticCurveTo(n.x,n.y,r.x,r.y)}function kd(e,t,n){e.beginPath&&e.beginPath();for(var r=t,a=0;a<r.length;a++){var i=r[a];e.lineTo(i.x,i.y)}var o=n,s=n[0];e.moveTo(s.x,s.y);for(a=1;a<o.length;a++){i=o[a];e.lineTo(i.x,i.y)}e.closePath&&e.closePath()}function Td(e,t,n,r,a){e.beginPath&&e.beginPath(),e.arc(n,r,a,0,2*Math.PI,!1);var i=t,o=i[0];e.moveTo(o.x,o.y);for(var s=0;s<i.length;s++){var l=i[s];e.lineTo(l.x,l.y)}e.closePath&&e.closePath()}function Cd(e,t,n,r){e.arc(t,n,r,0,2*Math.PI,!1)}xd.arrowShapeImpl=function(e){return(bd||(bd={polygon:wd,"triangle-backcurve":Ed,"triangle-tee":kd,"circle-triangle":Td,"triangle-cross":kd,circle:Cd}))[e]};var Pd={drawElement:function(e,t,n,r,a,i){t.isNode()?this.drawNode(e,t,n,r,a,i):this.drawEdge(e,t,n,r,a,i)},drawElementOverlay:function(e,t){t.isNode()?this.drawNodeOverlay(e,t):this.drawEdgeOverlay(e,t)},drawElementUnderlay:function(e,t){t.isNode()?this.drawNodeUnderlay(e,t):this.drawEdgeUnderlay(e,t)},drawCachedElementPortion:function(e,t,n,r,a,i,o,s){var l=this,u=n.getBoundingBox(t);if(0!==u.w&&0!==u.h){var c=n.getElement(t,u,r,a,i);if(null!=c){var d=s(l,t);if(0===d)return;var h,f,p,v,g,y,m=o(l,t),b=u.x1,x=u.y1,w=u.w,E=u.h;if(0!==m){var k=n.getRotationPoint(t);p=k.x,v=k.y,e.translate(p,v),e.rotate(m),(g=l.getImgSmoothing(e))||l.setImgSmoothing(e,!0);var T=n.getRotationOffset(t);h=T.x,f=T.y}else h=b,f=x;1!==d&&(y=e.globalAlpha,e.globalAlpha=y*d),e.drawImage(c.texture.canvas,c.x,0,c.width,c.height,h,f,w,E),1!==d&&(e.globalAlpha=y),0!==m&&(e.rotate(-m),e.translate(-p,-v),g||l.setImgSmoothing(e,!1))}else n.drawElement(e,t)}}},Sd=function(){return 0},Bd=function(e,t){return e.getTextAngle(t,null)},Dd=function(e,t){return e.getTextAngle(t,"source")},_d=function(e,t){return e.getTextAngle(t,"target")},Ad=function(e,t){return t.effectiveOpacity()},Md=function(e,t){return t.pstyle("text-opacity").pfValue*t.effectiveOpacity()};Pd.drawCachedElement=function(e,t,n,r,a,i){var o=this,s=o.data,l=s.eleTxrCache,u=s.lblTxrCache,c=s.slbTxrCache,d=s.tlbTxrCache,h=t.boundingBox(),f=!0===i?l.reasons.highQuality:null;if(0!==h.w&&0!==h.h&&t.visible()&&(!r||an(h,r))){var p=t.isEdge(),v=t.element()._private.rscratch.badLine;o.drawElementUnderlay(e,t),o.drawCachedElementPortion(e,t,l,n,a,f,Sd,Ad),p&&v||o.drawCachedElementPortion(e,t,u,n,a,f,Bd,Md),p&&!v&&(o.drawCachedElementPortion(e,t,c,n,a,f,Dd,Md),o.drawCachedElementPortion(e,t,d,n,a,f,_d,Md)),o.drawElementOverlay(e,t)}},Pd.drawElements=function(e,t){for(var n=0;n<t.length;n++){var r=t[n];this.drawElement(e,r)}},Pd.drawCachedElements=function(e,t,n,r){for(var a=0;a<t.length;a++){var i=t[a];this.drawCachedElement(e,i,n,r)}},Pd.drawCachedNodes=function(e,t,n,r){for(var a=0;a<t.length;a++){var i=t[a];i.isNode()&&this.drawCachedElement(e,i,n,r)}},Pd.drawLayeredElements=function(e,t,n,r){var a=this.data.lyrTxrCache.getLayers(t,n);if(a)for(var i=0;i<a.length;i++){var o=a[i],s=o.bb;0!==s.w&&0!==s.h&&e.drawImage(o.canvas,s.x1,s.y1,s.w,s.h)}else this.drawCachedElements(e,t,n,r)};var Rd={drawEdge: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=!(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,v=t.pstyle("line-outline-width").value,g=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+v,e.lineCap=p,v>0?(o.colorStrokeStyle(e,g[0],g[1],g[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)}}},Id=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")}}}};Rd.drawEdgeOverlay=Id("overlay"),Rd.drawEdgeUnderlay=Id("underlay"),Rd.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+3<n.length;f+=4)t.quadraticCurveTo(n[f],n[f+1],n[f+2],n[f+3]);break;case"straight":case"haystack":for(var p=2;p+1<n.length;p+=2)t.lineTo(n[p],n[p+1]);break;case"segments":if(o.isRound){var v,g=r(o.roundCorners);try{for(g.s();!(v=g.n()).done;){zc(t,v.value)}}catch(e){g.e(e)}finally{g.f()}t.lineTo(n[n.length-2],n[n.length-1])}else for(var y=2;y+1<n.length;y+=2)t.lineTo(n[y],n[y+1])}t=s,u?t.stroke(i):t.stroke(),t.setLineDash&&t.setLineDash([])},Rd.drawEdgeTrianglePath=function(e,t,n){t.fillStyle=t.strokeStyle;for(var r=e.pstyle("width").pfValue,a=0;a+1<n.length;a+=2){var i=[n[a+2]-n[a],n[a+3]-n[a+1]],o=Math.sqrt(i[0]*i[0]+i[1]*i[1]),s=[i[1]/o,-i[0]/o],l=[s[0]*r/2,s[1]*r/2];t.beginPath(),t.moveTo(n[a]-l[0],n[a+1]-l[1]),t.lineTo(n[a]+l[0],n[a+1]+l[1]),t.lineTo(n[a+2],n[a+3]),t.closePath(),t.fill()}},Rd.drawArrowheads=function(e,t,n){var r=t._private.rscratch,a="haystack"===r.edgeType;a||this.drawArrowhead(e,t,"source",r.arrowStartX,r.arrowStartY,r.srcArrowAngle,n),this.drawArrowhead(e,t,"mid-target",r.midX,r.midY,r.midtgtArrowAngle,n),this.drawArrowhead(e,t,"mid-source",r.midX,r.midY,r.midsrcArrowAngle,n),a||this.drawArrowhead(e,t,"target",r.arrowEndX,r.arrowEndY,r.tgtArrowAngle,n)},Rd.drawArrowhead=function(e,t,n,r,a,i,o){if(!(isNaN(r)||null==r||isNaN(a)||null==a||isNaN(i)||null==i)){var s=this,l=t.pstyle(n+"-arrow-shape").value;if("none"!==l){var u="hollow"===t.pstyle(n+"-arrow-fill").value?"both":"filled",c=t.pstyle(n+"-arrow-fill").value,d=t.pstyle("width").pfValue,h=t.pstyle(n+"-arrow-width"),f="match-line"===h.value?d:h.pfValue;"%"===h.units&&(f*=d);var p=t.pstyle("opacity").value;void 0===o&&(o=p);var v=e.globalCompositeOperation;1===o&&"hollow"!==c||(e.globalCompositeOperation="destination-out",s.colorFillStyle(e,255,255,255,1),s.colorStrokeStyle(e,255,255,255,1),s.drawArrowShape(t,e,u,d,l,f,r,a,i),e.globalCompositeOperation=v);var g=t.pstyle(n+"-arrow-color").value;s.colorFillStyle(e,g[0],g[1],g[2],o),s.colorStrokeStyle(e,g[0],g[1],g[2],o),s.drawArrowShape(t,e,c,d,l,f,r,a,i)}}},Rd.drawArrowShape=function(e,t,n,r,a,i,o,s,l){var u,c=this,d=this.usePaths()&&"triangle-cross"!==a,h=!1,f=t,p={x:o,y:s},v=e.pstyle("arrow-scale").value,g=this.getArrowWidth(r,v),y=c.arrowShapes[a];if(d){var m=c.arrowPathCache=c.arrowPathCache||[],b=qe(a),x=m[b];null!=x?(u=t=x,h=!0):(u=t=new Path2D,m[b]=u)}h||(t.beginPath&&t.beginPath(),d?y.draw(t,1,0,{x:0,y:0},1):y.draw(t,g,l,p,r),t.closePath&&t.closePath()),t=f,d&&(t.translate(o,s),t.rotate(l),t.scale(g,g)),"filled"!==n&&"both"!==n||(d?t.fill(u):t.fill()),"hollow"!==n&&"both"!==n||(t.lineWidth=i/(d?g:1),t.lineJoin="miter",d?t.stroke(u):t.stroke()),d&&(t.scale(1/g,1/g),t.rotate(-l),t.translate(-o,-s))};var Nd={safeDrawImage:function(e,t,n,r,a,i,o,s,l,u){if(!(a<=0||i<=0||l<=0||u<=0))try{e.drawImage(t,n,r,a,i,o,s,l,u)}catch(e){at(e)}},drawInscribedImage:function(e,t,n,r,a){var i=this,o=n.position(),s=o.x,l=o.y,u=n.cy().style(),c=u.getIndexedStyle.bind(u),d=c(n,"background-fit","value",r),h=c(n,"background-repeat","value",r),f=n.width(),p=n.height(),v=2*n.padding(),g=f+("inner"===c(n,"background-width-relative-to","value",r)?0:v),y=p+("inner"===c(n,"background-height-relative-to","value",r)?0:v),m=n._private.rscratch,b="node"===c(n,"background-clip","value",r),x=c(n,"background-image-opacity","value",r)*a,w=c(n,"background-image-smoothing","value",r),E=n.pstyle("corner-radius").value;"auto"!==E&&(E=n.pstyle("corner-radius").pfValue);var k=t.width||t.cachedW,T=t.height||t.cachedH;null!=k&&null!=T||(document.body.appendChild(t),k=t.cachedW=t.width||t.offsetWidth,T=t.cachedH=t.height||t.offsetHeight,document.body.removeChild(t));var C=k,P=T;if("auto"!==c(n,"background-width","value",r)&&(C="%"===c(n,"background-width","units",r)?c(n,"background-width","pfValue",r)*g:c(n,"background-width","pfValue",r)),"auto"!==c(n,"background-height","value",r)&&(P="%"===c(n,"background-height","units",r)?c(n,"background-height","pfValue",r)*y:c(n,"background-height","pfValue",r)),0!==C&&0!==P){if("contain"===d)C*=S=Math.min(g/C,y/P),P*=S;else if("cover"===d){var S;C*=S=Math.max(g/C,y/P),P*=S}var B=s-g/2,D=c(n,"background-position-x","units",r),_=c(n,"background-position-x","pfValue",r);B+="%"===D?(g-C)*_:_;var A=c(n,"background-offset-x","units",r),M=c(n,"background-offset-x","pfValue",r);B+="%"===A?(g-C)*M:M;var R=l-y/2,I=c(n,"background-position-y","units",r),N=c(n,"background-position-y","pfValue",r);R+="%"===I?(y-P)*N:N;var L=c(n,"background-offset-y","units",r),z=c(n,"background-offset-y","pfValue",r);R+="%"===L?(y-P)*z:z,m.pathCache&&(B-=s,R-=l,s=0,l=0);var O=e.globalAlpha;e.globalAlpha=x;var V=i.getImgSmoothing(e),F=!1;if("no"===w&&V?(i.setImgSmoothing(e,!1),F=!0):"yes"!==w||V||(i.setImgSmoothing(e,!0),F=!0),"no-repeat"===h)b&&(e.save(),m.pathCache?e.clip(m.pathCache):(i.nodeShapes[i.getNodeShape(n)].draw(e,s,l,g,y,E,m),e.clip())),i.safeDrawImage(e,t,0,0,k,T,B,R,C,P),b&&e.restore();else{var X=e.createPattern(t,h);e.fillStyle=X,i.nodeShapes[i.getNodeShape(n)].draw(e,s,l,g,y,E,m),e.translate(B,R),e.fill(),e.translate(-B,-R)}e.globalAlpha=O,F&&i.setImgSmoothing(e,V)}}},Ld={};function zd(e,t,n,r,a){var i=arguments.length>5&&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()}Ld.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),a=Math.ceil(Wt(n*r));t=Math.pow(2,a)}return!(e.pstyle("font-size").pfValue*t<e.pstyle("min-zoomed-font-size").pfValue)},Ld.drawElementText=function(e,t,n,r,a){var i=!(arguments.length>5&&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);e.textAlign=l,e.textBaseline="bottom"}else{var u=t.element()._private.rscratch.badLine,c=t.pstyle("label"),d=t.pstyle("source-label"),h=t.pstyle("target-label");if(u||(!c||!c.value)&&(!d||!d.value)&&(!h||!h.value))return;e.textAlign="center",e.textBaseline="bottom"}var f,p=!n;n&&(f=n,e.translate(-f.x1,-f.y1)),null==a?(o.drawText(e,t,null,p,i),t.isEdge()&&(o.drawText(e,t,"source",p,i),o.drawText(e,t,"target",p,i))):o.drawText(e,t,a,p,i),n&&e.translate(f.x1,f.y1)},Ld.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n<this.fontCaches.length;n++)if((t=this.fontCaches[n]).context===e)return t;return t={context:e},this.fontCaches.push(t),t},Ld.setupTextStyle=function(e,t){var n=!(arguments.length>2&&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)},Ld.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=ht(r,"labelAngle",t);n=e.isEdge()?o:0}else n="none"===i.strValue?0:i.pfValue;return n},Ld.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=ht(i,"labelX",n),c=ht(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=ht(i,"labelWidth",n),v=ht(i,"labelHeight",n),g=t.pstyle(f+"text-margin-x").pfValue,y=t.pstyle(f+"text-margin-y").pfValue,m=t.isEdge(),b=t.pstyle("text-halign").value,x=t.pstyle("text-valign").value;switch(m&&(b="center",x="center"),u+=g,c+=y,0!==(h=r?this.getTextAngle(t,n):0)&&(s=u,l=c,e.translate(s,l),e.rotate(h),u=0,c=0),x){case"top":break;case"center":c+=v/2;break;case"bottom":c+=v}var w=t.pstyle("text-background-opacity").value,E=t.pstyle("text-border-opacity").value,k=t.pstyle("text-border-width").pfValue,T=t.pstyle("text-background-padding").pfValue,C=t.pstyle("text-background-shape").strValue,P="round-rectangle"===C||"roundrectangle"===C,S="circle"===C;if(w>0||k>0&&E>0){var B=e.fillStyle,D=e.strokeStyle,_=e.lineWidth,A=t.pstyle("text-background-color").value,M=t.pstyle("text-border-color").value,R=t.pstyle("text-border-style").value,I=w>0,N=k>0&&E>0,L=u-T;switch(b){case"left":L-=p;break;case"center":L-=p/2}var z=c-v-T,O=p+2*T,V=v+2*T;if(I&&(e.fillStyle="rgba(".concat(A[0],",").concat(A[1],",").concat(A[2],",").concat(w*o,")")),N&&(e.strokeStyle="rgba(".concat(M[0],",").concat(M[1],",").concat(M[2],",").concat(E*o,")"),e.lineWidth=k,e.setLineDash))switch(R){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=k/4,e.setLineDash([]);break;default:e.setLineDash([])}if(P?(e.beginPath(),zd(e,L,z,O,V,2)):S?(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,L,z,O,V)):(e.beginPath(),e.rect(L,z,O,V)),I&&e.fill(),N&&e.stroke(),N&&"double"===R){var F=k/2;e.beginPath(),P?zd(e,L+F,z+F,O-2*F,V-2*F,2):e.rect(L+F,z+F,O-2*F,V-2*F),e.stroke()}e.fillStyle=B,e.strokeStyle=D,e.lineWidth=_,e.setLineDash&&e.setLineDash([])}var X=2*t.pstyle("text-outline-width").pfValue;if(X>0&&(e.lineWidth=X),"wrap"===t.pstyle("text-wrap").value){var j=ht(i,"labelWrapCachedLines",n),Y=ht(i,"labelLineHeight",n),q=p/2,W=this.getLabelJustification(t);switch("auto"===W||("left"===b?"left"===W?u+=-p:"center"===W&&(u+=-q):"center"===b?"left"===W?u+=-q:"right"===W&&(u+=q):"right"===b&&("center"===W?u+=q:"right"===W&&(u+=p))),x){case"top":case"center":case"bottom":c-=(j.length-1)*Y}for(var U=0;U<j.length;U++)X>0&&e.strokeText(j[U],u,c),e.fillText(j[U],u,c),c+=Y}else X>0&&e.strokeText(d,u,c),e.fillText(d,u,c);0!==h&&(e.rotate(-h),e.translate(-s,-l))}}};var Od={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,v=l.usePaths(),g=!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;E<m.length;E++){var k=m[E];if(b[E]=null!=k&&"none"!==k){var T=t.cy().style().getIndexedStyle(t,"background-image-crossorigin","value",E);w++,x[E]=l.getCachedImage(k,T,(function(){u.backgroundTimestamp=Date.now(),t.emitAndNotify("background")}))}}var C=t.pstyle("background-blacken").value,P=t.pstyle("border-width").pfValue,S=t.pstyle("background-opacity").value*p,B=t.pstyle("border-color").value,D=t.pstyle("border-style").value,_=t.pstyle("border-join").value,A=t.pstyle("border-cap").value,M=t.pstyle("border-position").value,R=t.pstyle("border-dash-pattern").pfValue,I=t.pstyle("border-dash-offset").pfValue,N=t.pstyle("border-opacity").value*p,L=t.pstyle("outline-width").pfValue,z=t.pstyle("outline-color").value,O=t.pstyle("outline-style").value,V=t.pstyle("outline-opacity").value*p,F=t.pstyle("outline-offset").value,X=t.pstyle("corner-radius").value;"auto"!==X&&(X=t.pstyle("corner-radius").pfValue);var j=function(){var n=arguments.length>0&&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=We("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(v){e.translate(d.x,d.y);var K=W(r,a,U,H);h=K.path,g=K.cacheHit}var Z=function(){if(!g){var n=d;v&&(n={x:0,y:0}),l.nodeShapes[l.getNodeShape(t)].draw(h||e,n.x,n.y,r,a,X,c)}v?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;o<x.length;o++){var s=t.cy().style().getIndexedStyle(t,"background-image-containment","value",o);r&&"over"===s||!r&&"inside"===s?i++:b[o]&&x[o].complete&&!x[o].error&&(i++,l.drawInscribedImage(e,x[o],t,o,n))}u.backgrounding=!(i===w),a!==u.backgrounding&&t.updateStyle(!1)},Q=function(){var n=arguments.length>0&&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&&(v||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(),v?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&&(v||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),v?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)v?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")}v?e.stroke(h):e.stroke(),e.restore()}else v?e.stroke(h):e.stroke();if("double"===D){e.lineWidth=P/3;var n=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",v?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;v&&(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(v)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 g=0,y=0,m=0;"round-diamond"===i?g=1.4*(o+F+L):"round-heptagon"===i?(g=1.075*(o+F+L),m=-(o/2+F+L)/35):"round-hexagon"===i?g=1.12*(o+F+L):"round-pentagon"===i?(g=1.13*(o+F+L),m=-(o/2+F+L)/15):"round-tag"===i?(g=1.12*(o+F+L),y=.07*(o/2+L+F)):"round-triangle"===i&&(g=(o+F+L)*(Math.PI/2),m=-(o+F/2+L)/Math.PI),0!==g&&(h=r*(u=(r+g)/r),["round-hexagon","round-tag"].includes(i)||(f=a*(c=(a+g)/a)));for(var b=h/2,x=f/2,w=(X="auto"===X?An(h,f):X)+(o+L+F)/2,E=new Array(p.length/2),k=new Array(p.length/2),T=0;T<p.length/2;T++)E[T]={x:n.x+y+b*p[2*T],y:n.y+m+x*p[2*T+1]};var C,S,B,D,_=E.length;for(S=E[_-1],C=0;C<_;C++)B=E[C%_],D=E[(C+1)%_],k[C]=Oc(S,B,D,w),S=B,B=D;l.drawRoundPolygonPath(s||e,n.x+y,n.y+m,r*u,a*c,p,k)}else if(["roundrectangle","round-rectangle"].includes(i))X="auto"===X?_n(h,f):X,l.drawRoundRectanglePath(s||e,n.x,n.y,h,f,X+(o+L+F)/2);else if(["cutrectangle","cut-rectangle"].includes(i))X="auto"===X?8:X,l.drawCutRectanglePath(s||e,n.x,n.y,h,f,null,X+(o+L+F)/4);else if(["bottomroundrectangle","bottom-round-rectangle"].includes(i))X="auto"===X?_n(h,f):X,l.drawBottomRoundRectanglePath(s||e,n.x,n.y,h,f,X+(o+L+F)/2);else if("barrel"===i)l.drawBarrelPath(s||e,n.x,n.y,h,f);else if(i.startsWith("polygon")||["rhomboid","right-rhomboid","round-tag","tag","vee"].includes(i)){p=mn(bn(p,(o+L+F)/r)),l.drawPolygonPath(s||e,n.x,n.y,r,a,p)}else{p=mn(bn(p,-((o+L+F)/r))),l.drawPolygonPath(s||e,n.x,n.y,r,a,p)}if(v?e.stroke(s):e.stroke(),"double"===O){e.lineWidth=o/3;var A=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",v?e.stroke(s):e.stroke(),e.globalCompositeOperation=A}e.setLineDash&&e.setLineDash([])}};if("yes"===t.pstyle("ghost").value){var re=t.pstyle("ghost-offset-x").pfValue,ae=t.pstyle("ghost-offset-y").pfValue,ie=t.pstyle("ghost-opacity").value,oe=ie*p;e.translate(re,ae),q(),ne(),j(ie*S),Z(),$(oe,!0),Y(ie*N),te(),Q(0!==C||0!==P),J(0!==C||0!==P),$(oe,!1),ee(oe),e.translate(-re,-ae)}v&&e.translate(-d.x,-d.y),o&&l.drawNodeUnderlay(e,t,d,r,a),v&&e.translate(d.x,d.y),q(),ne(),j(),Z(),$(p,!0),Y(),te(),Q(0!==C||0!==P),J(0!==C||0!==P),$(p,!1),ee(),v&&e.translate(-d.x,-d.y),l.drawElementText(e,t,null,i),o&&l.drawNodeOverlay(e,t,d,r,a),n&&e.translate(f.x1,f.y1)}}},Vd=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n,r,a,i){if(n.visible()){var o=n.pstyle("".concat(e,"-padding")).pfValue,s=n.pstyle("".concat(e,"-opacity")).value,l=n.pstyle("".concat(e,"-color")).value,u=n.pstyle("".concat(e,"-shape")).value,c=n.pstyle("".concat(e,"-corner-radius")).value;if(s>0){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()}}}};Od.drawNodeOverlay=Vd("overlay"),Od.drawNodeUnderlay=Vd("underlay"),Od.hasPie=function(e){return(e=e[0])._private.hasPie},Od.hasStripe=function(e){return(e=e[0])._private.hasStripe},Od.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 v=1;v<=i.pieBackgroundN;v++){var g=t.pstyle("pie-"+v+"-background-size").value,y=t.pstyle("pie-"+v+"-background-color").value,m=t.pstyle("pie-"+v+"-background-opacity").value*n,b=g/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===g||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)}},Od.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 v=1;v<=a.stripeBackgroundN;v++){var g=t.pstyle("stripe-"+v+"-background-size").value,y=t.pstyle("stripe-"+v+"-background-color").value,m=t.pstyle("stripe-"+v+"-background-opacity").value*n,b=g/100;b+u>1&&(b=1-u),0===g||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 Fd,Xd={};function jd(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 Yd(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 qd(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 Wd(e){return"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 Ud(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Hd(e,t,n){var r=e[0]/255,a=e[1]/255,i=e[2]/255,o=t,s=n||new Array(4);return s[0]=r*o,s[1]=a*o,s[2]=i*o,s[3]=o,s}function Kd(e,t){var n=t||new Array(4);return n[0]=(255&e)/255,n[1]=(e>>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function Gd(e){return e[0]+(e[1]<<8)+(e[2]<<16)+(e[3]<<24)}function Zd(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 $d(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function Qd(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 Jd(e,t,n,r){var a=i(Zd(e,n),3),o=a[0],s=a[1],l=a[2],u=$d(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;f<t;f++)h[f]=Qd(e,s,u,c,o,f);return d.dataArray=u,d.stride=c,d.size=o,d.getView=function(e){return h[e]},d.setPoint=function(e,t,n){var r=h[e];r[0]=t,r[1]=n},d.bufferSubData=function(t){e.bindBuffer(e.ARRAY_BUFFER,d),t?e.bufferSubData(e.ARRAY_BUFFER,0,u,0,t*o):e.bufferSubData(e.ARRAY_BUFFER,0,u)},d}Xd.getPixelRatio=function(){var e=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var t=this.cy.window(),n=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(t.devicePixelRatio||1)/n},Xd.paintCache=function(e){for(var t,n=this.paintCaches=this.paintCaches||[],r=!0,a=0;a<n.length;a++)if((t=n[a]).context===e){r=!1;break}return r&&(t={context:e},n.push(t)),t},Xd.createGradientStyleFor=function(e,t,n,r,a){var i,o=this.usePaths(),s=n.pstyle(t+"-gradient-stop-colors").value,l=n.pstyle(t+"-gradient-stop-positions").pfValue;if("radial-gradient"===r)if(n.isEdge()){var u=n.sourceEndpoint(),c=n.targetEndpoint(),d=n.midpoint(),h=Ht(u,d),f=Ht(c,d);i=e.createRadialGradient(d.x,d.y,0,d.x,d.y,Math.max(h,f))}else{var p=o?{x:0,y:0}:n.position(),v=n.paddedWidth(),g=n.paddedHeight();i=e.createRadialGradient(p.x,p.y,0,p.x,p.y,Math.max(v,g))}else if(n.isEdge()){var y=n.sourceEndpoint(),m=n.targetEndpoint();i=e.createLinearGradient(y.x,y.y,m.x,m.y)}else{var b=o?{x:0,y:0}:n.position(),x=n.paddedWidth()/2,w=n.paddedHeight()/2;switch(n.pstyle("background-gradient-direction").value){case"to-bottom":i=e.createLinearGradient(b.x,b.y-w,b.x,b.y+w);break;case"to-top":i=e.createLinearGradient(b.x,b.y+w,b.x,b.y-w);break;case"to-left":i=e.createLinearGradient(b.x+x,b.y,b.x-x,b.y);break;case"to-right":i=e.createLinearGradient(b.x-x,b.y,b.x+x,b.y);break;case"to-bottom-right":case"to-right-bottom":i=e.createLinearGradient(b.x-x,b.y-w,b.x+x,b.y+w);break;case"to-top-right":case"to-right-top":i=e.createLinearGradient(b.x-x,b.y+w,b.x+x,b.y-w);break;case"to-bottom-left":case"to-left-bottom":i=e.createLinearGradient(b.x+x,b.y-w,b.x-x,b.y+w);break;case"to-top-left":case"to-left-top":i=e.createLinearGradient(b.x+x,b.y+w,b.x-x,b.y-w)}}if(!i)return null;for(var E=l.length===s.length,k=s.length,T=0;T<k;T++)i.addColorStop(E?l[T]:T/(k-1),"rgba("+s[T][0]+","+s[T][1]+","+s[T][2]+","+a+")");return i},Xd.gradientFillStyle=function(e,t,n,r){var a=this.createGradientStyleFor(e,"background",t,n,r);if(!a)return null;e.fillStyle=a},Xd.colorFillStyle=function(e,t,n,r,a){e.fillStyle="rgba("+t+","+n+","+r+","+a+")"},Xd.eleFillStyle=function(e,t,n){var r=t.pstyle("background-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientFillStyle(e,t,r,n);else{var a=t.pstyle("background-color").value;this.colorFillStyle(e,a[0],a[1],a[2],n)}},Xd.gradientStrokeStyle=function(e,t,n,r){var a=this.createGradientStyleFor(e,"line",t,n,r);if(!a)return null;e.strokeStyle=a},Xd.colorStrokeStyle=function(e,t,n,r,a){e.strokeStyle="rgba("+t+","+n+","+r+","+a+")"},Xd.eleStrokeStyle=function(e,t,n){var r=t.pstyle("line-fill").value;if("linear-gradient"===r||"radial-gradient"===r)this.gradientStrokeStyle(e,t,r,n);else{var a=t.pstyle("line-color").value;this.colorStrokeStyle(e,a[0],a[1],a[2],n)}},Xd.matchCanvasSize=function(e){var t=this,n=t.data,r=t.findContainerClientCoords(),a=r[2],i=r[3],o=t.getPixelRatio(),s=t.motionBlurPxRatio;e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE]&&e!==t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG]||(o=s);var l,u=a*o,c=i*o;if(u!==t.canvasWidth||c!==t.canvasHeight){t.fontCaches=null;var d=n.canvasContainer;d.style.width=a+"px",d.style.height=i+"px";for(var h=0;h<t.CANVAS_LAYERS;h++)(l=n.canvases[h]).width=u,l.height=c,l.style.width=a+"px",l.style.height=i+"px";for(h=0;h<t.BUFFER_COUNT;h++)(l=n.bufferCanvases[h]).width=u,l.height=c,l.style.width=a+"px",l.style.height=i+"px";t.textureMult=1,o<=1&&(l=n.bufferCanvases[t.TEXTURE_BUFFER],t.textureMult=2,l.width=u*t.textureMult,l.height=c*t.textureMult),t.canvasWidth=u,t.canvasHeight=c,t.pixelRatio=o}},Xd.renderTo=function(e,t,n,r){this.render({forcedContext:e,forcedZoom:t,forcedPan:n,drawAllLayers:!0,forcedPxRatio:r})},Xd.clearCanvas=function(){var e=this,t=e.data;function n(t){t.clearRect(0,0,e.canvasWidth,e.canvasHeight)}n(t.contexts[e.NODE]),n(t.contexts[e.DRAG])},Xd.render=function(e){var t=this;e=e||lt();var n=t.cy,r=e.forcedContext,a=e.drawAllLayers,i=e.drawOnlyNodeLayer,o=e.forcedZoom,s=e.forcedPan,l=void 0===e.forcedPxRatio?this.getPixelRatio():e.forcedPxRatio,u=t.data,c=u.canvasNeedsRedraw,d=t.textureOnViewport&&!r&&(t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming),h=void 0!==e.motionBlur?e.motionBlur:t.motionBlur,f=t.motionBlurPxRatio,p=n.hasCompoundNodes(),v=t.hoverData.draggingEles,g=!(!t.hoverData.selecting&&!t.touchData.selecting),y=h=h&&!r&&t.motionBlurEnabled&&!g;r||(t.prevPxRatio!==l&&(t.invalidateContainerClientCoordsCache(),t.matchCanvasSize(t.container),t.redrawHint("eles",!0),t.redrawHint("drag",!0)),t.prevPxRatio=l),!r&&t.motionBlurTimeout&&clearTimeout(t.motionBlurTimeout),h&&(null==t.mbFrames&&(t.mbFrames=0),t.mbFrames++,t.mbFrames<3&&(y=!1),t.mbFrames>t.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||v&&!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")},Xd.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 v=Math.round(1e3/p),g="1 frame = "+p+" ms = "+v+" 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",!Fd){var y=c.measureText(g);Fd=y.actualBoundingBoxAscent}c.fillText(g,0,Fd);c.strokeRect(0,Fd+10,250,20),c.fillRect(0,Fd+10,250*Math.min(v/60,1),20)}s||(l[n.SELECT_BOX]=!1)}};var eh="undefined"!=typeof Float32Array?Float32Array:Array;function th(){var e=new eh(9);return eh!=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 nh(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 rh(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 ah(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 ih(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 oh=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 v=n,g=(r.freePointer.row+1)*o,y=i;t&&t.context.drawImage(e,v,0,y,s,0,g,y,s),h[1]={x:0,y:g,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.row<n-1}},{key:"bufferIfNeeded",value:function(e){this.texture||(this.texture=function(e){var t=e.createTexture();return t.buffer=function(n){e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)},t.deleteTexture=function(){e.deleteTexture(t)},t}(e,this.debugID)),this.needsBuffer&&(this.texture.buffer(this.canvas),this.needsBuffer=!1,this.locked&&(this.canvas=null,this.scratch=null))}},{key:"dispose",value:function(){this.texture&&(this.texture.deleteTexture(),this.texture=null),this.canvas=null,this.scratch=null,this.locked=!0}}])}(),sh=function(){return n((function e(n,r,a,i){t(this,e),this.r=n,this.texSize=r,this.texRows=a,this.createTextureCanvas=i,this.atlases=[],this.styleKeyToAtlas=new Map,this.markedKeys=new Set}),[{key:"getKeys",value:function(){return new Set(this.styleKeyToAtlas.keys())}},{key:"_createAtlas",value:function(){var e=this.r,t=this.texSize,n=this.texRows,r=this.createTextureCanvas;return new oh(e,t,n,r)}},{key:"_getScratchCanvas",value:function(){if(!this.scratch){var e=this.r,t=this.texSize,n=this.texRows,r=this.createTextureCanvas,a=Math.floor(t/n);this.scratch=r(e,t,a,"scratch")}return this.scratch}},{key:"draw",value:function(e,t,n){var r=this.styleKeyToAtlas.get(e);return r||((r=this.atlases[this.atlases.length-1])&&r.canFit(t)||(r&&r.lock(),r=this._createAtlas(),this.atlases.push(r)),r.draw(e,t,n),this.styleKeyToAtlas.set(e,r)),r}},{key:"getAtlas",value:function(e){return this.styleKeyToAtlas.get(e)}},{key:"hasAtlas",value:function(e){return this.styleKeyToAtlas.has(e)}},{key:"markKeyForGC",value:function(e){this.markedKeys.add(e)}},{key:"gc",value:function(){var e=this,t=this.markedKeys;if(0!==t.size){var n,a=[],s=new Map,l=null,u=r(this.atlases);try{var c=function(){var u,c,d=n.value,h=d.getKeys(),f=(c=h,(u=t).intersection?u.intersection(c):new Set(o(u).filter((function(e){return c.has(e)}))));if(0===f.size)return a.push(d),h.forEach((function(e){return s.set(e,d)})),1;l||(l=e._createAtlas(),a.push(l));var p,v=r(h);try{for(v.s();!(p=v.n()).done;){var g=p.value;if(!f.has(g)){var y=i(d.getOffsets(g),2),m=y[0],b=y[1];l.canFit({w:m.w+b.w,h:m.h})||(l.lock(),l=e._createAtlas(),a.push(l)),d.canvas&&(e._copyTextureToNewAtlas(g,d,l),s.set(g,l))}}}catch(e){v.e(e)}finally{v.f()}d.dispose()};for(u.s();!(n=u.n()).done;)c()}catch(e){u.e(e)}finally{u.f()}this.atlases=a,this.styleKeyToAtlas=s,this.markedKeys=new Set}else console.log("nothing to garbage collect")}},{key:"_copyTextureToNewAtlas",value:function(e,t,n){var r=i(t.getOffsets(e),2),a=r[0],o=r[1];if(0===o.w)n.draw(e,a,(function(e){e.drawImage(t.canvas,a.x,a.y,a.w,a.h,0,0,a.w,a.h)}));else{var s=this._getScratchCanvas();s.clear(),s.context.drawImage(t.canvas,a.x,a.y,a.w,a.h,0,0,a.w,a.h),s.context.drawImage(t.canvas,o.x,o.y,o.w,o.h,a.w,0,o.w,o.h);var l=a.w+o.w,u=a.h;n.draw(e,{w:l,h:u},(function(e){e.drawImage(s,0,0,l,u,0,0,l,u)}))}}},{key:"getCounts",value:function(){return{keyCount:this.styleKeyToAtlas.size,atlasCount:new Set(this.styleKeyToAtlas.values()).size}}}])}();var lh=function(){return n((function e(n,r){t(this,e),this.r=n,this.globalOptions=r,this.atlasSize=r.webglTexSize,this.maxAtlasesPerBatch=r.webglTexPerBatch,this.renderTypes=new Map,this.collections=new Map,this.typeAndIdToKey=new Map}),[{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"addAtlasCollection",value:function(e,t){var n=this.globalOptions,r=n.webglTexSize,a=n.createTextureCanvas,i=t.texRows,o=this._cacheScratchCanvas(a),s=new sh(this.r,r,i,o);this.collections.set(e,s)}},{key:"addRenderType",value:function(e,t){var n=t.collection;if(!this.collections.has(n))throw new Error("invalid atlas collection name '".concat(n,"'"));var r=this.collections.get(n),a=ge({type:e,atlasCollection:r},t);this.renderTypes.set(e,a)}},{key:"getRenderTypeOpts",value:function(e){return this.renderTypes.get(e)}},{key:"getAtlasCollection",value:function(e){return this.collections.get(e)}},{key:"_cacheScratchCanvas",value:function(e){var t=-1,n=-1,r=null;return function(a,i,o,s){return s?(r&&i==t&&o==n||(t=i,n=o,r=e(a,i,o)),r):e(a,i,o)}}},{key:"_key",value:function(e,t){return"".concat(e,"-").concat(t)}},{key:"invalidate",value:function(e){var t,n=this,a=arguments.length>1&&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 v,g=r(this.renderTypes.values());try{var y=function(){var e=v.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||Ud(i,u)||(d=!0,n.typeAndIdToKey.delete(l),u.forEach((function(e){return r.markKeyForGC(e)})))}}};for(g.s();!(v=g.n()).done;)y()}catch(e){g.e(e)}finally{g.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}}])}(),uh=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}}])}(),ch={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},dh=1,hh=2,fh=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=Yd,this.atlasManager=new lh(n,a),this.batchManager=new uh(a),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(ch.SCREEN),this.pickingProgram=this._createShaderProgram(ch.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.x<q.y)? 1.570796327 : 0.0;\n    for( int i=0; i<5; i++ ) {\n      vec2 cs = vec2(cos(w),sin(w));\n      vec2 u = ab*vec2( cs.x,cs.y);\n      vec2 v = ab*vec2(-cs.y,cs.x);\n      w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));\n    }\n    \n    // compute final point and distance\n    float d = length(p-ab*vec2(cos(w),sin(w)));\n    \n    // return signed distance\n    return (dot(p/ab,p/ab)>1.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=jd(e,e.VERTEX_SHADER,t),a=jd(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;o<this.batchManager.getMaxAtlasesPerBatch();o++)i.uTextures.push(t.getUniformLocation(i,"uTexture".concat(o)));return i}},{key:"_createVAO",value:function(){var e=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=e.length/2;var t=this.maxInstances,n=this.gl,r=this.program,a=n.createVertexArray();return n.bindVertexArray(a),function(e,t,n,r){var a=i(Zd(e,t),2),o=a[0],s=a[1],l=$d(e,s,r),u=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,l,e.STATIC_DRAW),s===e.FLOAT?e.vertexAttribPointer(n,o,s,!1,0,0):s===e.INT&&e.vertexAttribIPointer(n,o,s,0,0),e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,null)}(n,"vec2",r.aPosition,e),this.transformBuffer=function(e,t,n){for(var r=new Float32Array(9*t),a=new Array(t),i=0;i<t;i++){var o=9*i*4;a[i]=new Float32Array(r.buffer,o,9)}var s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,r.byteLength,e.DYNAMIC_DRAW);for(var l=0;l<3;l++){var u=n+l;e.enableVertexAttribArray(u),e.vertexAttribPointer(u,3,e.FLOAT,!1,36,12*l),e.vertexAttribDivisor(u,1)}return e.bindBuffer(e.ARRAY_BUFFER,null),s.getMatrixView=function(e){return a[e]},s.setData=function(e,t){a[t].set(e,0)},s.bufferSubData=function(){e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferSubData(e.ARRAY_BUFFER,0,r)},s}(n,t,r.aTransform),this.indexBuffer=Jd(n,t,"vec4",r.aIndex),this.vertTypeBuffer=Jd(n,t,"int",r.aVertType),this.atlasIdBuffer=Jd(n,t,"int",r.aAtlasId),this.texBuffer=Jd(n,t,"vec4",r.aTex),this.pointAPointBBuffer=Jd(n,t,"vec4",r.aPointAPointB),this.pointCPointDBuffer=Jd(n,t,"vec4",r.aPointCPointD),this.lineWidthBuffer=Jd(n,t,"vec2",r.aLineWidth),this.colorBuffer=Jd(n,t,"vec4",r.aColor),this.cornerRadiusBuffer=Jd(n,t,"vec4",r.aCornerRadius),this.borderColorBuffer=Jd(n,t,"vec4",r.aBorderColor),n.bindVertexArray(null),a}},{key:"buffers",get:function(){var e=this;return this._buffers||(this._buffers=Object.keys(this).filter((function(e){return ue(e,"Buffer")})).map((function(t){return e[t]}))),this._buffers}},{key:"startFrame",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ch.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===dh)return;if(l==hh)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 v=o.getAtlasIndexForBatch(h),g=0,y=[[f,!0],[p,!1]];g<y.length;g++){var m=i(y[g],2),b=m[0],x=m[1];if(0!=b.w){var w=this.instanceCount;this.vertTypeBuffer.getView(w)[0]=0,Kd(t,this.indexBuffer.getView(w)),this.atlasIdBuffer.getView(w)[0]=v;var E=this.texBuffer.getView(w);E[0]=b.x,E[1]=b.y,E[2]=b.w,E[3]=b.h;var k=this.transformBuffer.getMatrixView(w);this.setTransformMatrix(e,k,s,d,x),this.instanceCount++,x||this.wrappedCount++,this.instanceCount>=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;nh(e);var o=n.getRotation?n.getRotation(r):0;if(0!==o){var s=n.getRotationPoint(r);rh(e,e,[s.x,s.y]),ah(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;rh(e,e,[a,i]),ih(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,Kd(t,this.indexBuffer.getView(a)),Hd([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.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)}Kd(t,this.indexBuffer.getView(o)),Hd(e.pstyle(a.color).value,e.pstyle(a.opacity).value,this.colorBuffer.getView(o));var c=this.lineWidthBuffer.getView(o);if(c[0]=0,c[1]=0,a.border){var d=e.pstyle("border-width").value;if(d>0){Hd(e.pstyle("border-color").value,e.pstyle("border-opacity").value,this.borderColorBuffer.getView(o));var h=e.pstyle("border-position").value;if("inside"===h)c[0]=0,c[1]=-d;else if("outside"===h)c[0]=d,c[1]=0;else{var f=d/2;c[0]=f,c[1]=-f}}}var p=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,p,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 _n(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);nh(f),rh(f,f,[r,a]),ih(f,f,[d,d]),ah(f,f,i),this.vertTypeBuffer.getView(h)[0]=3,Kd(t,this.indexBuffer.getView(h)),Hd(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,Kd(t,this.indexBuffer.getView(l)),Hd(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<n.length-2;c+=2){var d=this.instanceCount;this.vertTypeBuffer.getView(d)[0]=2,Kd(t,this.indexBuffer.getView(d)),Hd(o,s,this.colorBuffer.getView(d)),this.lineWidthBuffer.getView(d)[0]=i;var h=n[c-2],f=n[c-1],p=n[c],v=n[c+1],g=n[c+2],y=n[c+3],m=n[c+4],b=n[c+5];0==c&&(h=2*p-g+.001,f=2*v-y+.001),c==n.length-4&&(m=2*g-p+.001,b=2*y-v+.001);var x=this.pointAPointBBuffer.getView(d);x[0]=h,x[1]=f,x[2]=p,x[3]=v;var w=this.pointCPointDBuffer.getView(d);w[0]=g,w[1]=y,w[2]=m,w[3]=b,this.instanceCount++,this.instanceCount>=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;i<a.length;i+=2){var o=(1-t)*e[i]+t*e[i+2],s=(1-t)*e[i+1]+t*e[i+3];a[i]=o,a[i+1]=s}return this._setCurvePoint(a,t,n,r)}n[r]=e[0],n[r+1]=e[1]}},{key:"endBatch",value:function(){var e=this.gl,t=this.vao,n=this.vertexCount,a=this.instanceCount;if(0!==a){var i=this.renderTarget.picking?this.pickingProgram:this.program;e.useProgram(i),e.bindVertexArray(t);var o,s=r(this.buffers);try{for(s.s();!(o=s.n()).done;){o.value.bufferSubData(a)}}catch(e){s.e(e)}finally{s.f()}for(var l,u,c=this.batchManager.getAtlases(),d=0;d<c.length;d++)c[d].bufferIfNeeded(e);for(var h=0;h<c.length;h++)e.activeTexture(e.TEXTURE0+h),e.bindTexture(e.TEXTURE_2D,c[h].texture),e.uniform1i(i.uTextures[h],h);e.uniform1f(i.uZoom,(l=this.r,u=l.pixelRatio,l.cy.zoom()*u)),e.uniformMatrix3fv(i.uPanZoomMatrix,!1,this.panZoomMatrix),e.uniform1i(i.uAtlasSize,this.batchManager.getAtlasSize());var f=Hd(this.bgColor,1);e.uniform4fv(i.uBGColor,f),e.drawArraysInstanced(e.TRIANGLES,0,n,a),e.bindVertexArray(null),e.bindTexture(e.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:a,atlasCount:c.length}),this.startBatch()}}},{key:"getDebugInfo",value:function(){var e=this.atlasManager.getDebugInfo(),t=e.reduce((function(e,t){return e+t.atlasCount}),0),n=this.batchDebugInfo,r=n.reduce((function(e,t){return e+t.count}),0);return{atlasInfo:e,totalAtlases:t,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:r}}}])}(),ph={};function vh(e,t){var n=e._private.rscratch;return ht(n,"labelWrapCachedLines",t)||[]}ph.initWebgl=function(e,t){var n=this,a=n.data.contexts[n.WEBGL];e.bgColor=function(e){var t=e.cy.container(),n=t&&t.style&&t.style.backgroundColor||"white";return ye(n)}(n),e.webglTexSize=Math.min(e.webglTexSize,a.getParameter(a.MAX_TEXTURE_SIZE)),e.webglTexRows=Math.min(e.webglTexRows,54),e.webglTexRowsNodes=Math.min(e.webglTexRowsNodes,54),e.webglBatchSize=Math.min(e.webglBatchSize,16384),e.webglTexPerBatch=Math.min(e.webglTexPerBatch,a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)),n.webglDebug=e.webglDebug,n.webglDebugShowAtlases=e.webglDebugShowAtlases,n.pickingFrameBuffer=function(e){var t=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);var n=e.createTexture();return e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.bindFramebuffer(e.FRAMEBUFFER,null),t.setFramebufferAttachmentSizes=function(t,r){e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,null)},t}(a),n.pickingFrameBuffer.needsDraw=!0,n.drawing=new fh(n,a,e);var o=function(e){return function(t){return n.getTextAngle(t,e)}},s=function(e){return function(t){var n=t.pstyle(e);return n&&n.value}},l=function(e){return function(t){return t.pstyle("".concat(e,"-opacity")).value>0}},u=function(e){return"yes"===e.pstyle("text-events").strValue?hh:dh},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:Wd,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:gh(t.getLabelKey,null),getBoundingBox:yh(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:gh(t.getSourceLabelKey,"source"),getBoundingBox:yh(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:gh(t.getTargetLabelKey,"target"),getBoundingBox:yh(t.getTargetLabelBox,"target"),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:o("target"),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:s("target-label")});var d=_e((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()>cd?(!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),xh(e,n,ch.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=qd(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],v=6;if(r=f-v/2,a=p-v/2,s=v,0===(o=v)||0===s)return[];var g=e.data.contexts[e.WEBGL];g.bindFramebuffer(g.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(g.viewport(0,0,g.canvas.width,g.canvas.height),xh(e,null,ch.PICKING),e.pickingFrameBuffer.needsDraw=!1);var y=o*s,m=new Uint8Array(4*y);g.readPixels(r,a,o,s,g.RGBA,g.UNSIGNED_BYTE,m),g.bindFramebuffer(g.FRAMEBUFFER,null);for(var b=new Set,x=0;x<y;x++){var w=Gd(m.slice(4*x,4*x+4))-1;w>=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 gh=function(e,t){return function(n){var r=e(n),a=vh(n,t);return a.length>1?a.map((function(e,t){return"".concat(r,"_").concat(t)})):r}},yh=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=vh(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 mh(e,t){var n=e.canvasWidth,r=e.canvasHeight,a=qd(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 bh(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 xh(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 mh(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=qd(e),a=r.pan,i=r.zoom,o=th();rh(o,o,[a.x,a.y]),ih(o,o,[i,i]);var s=th();!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,v,g,y,m,b,x,w,E,k,T,C,P,S,B,D=th();return l=D,c=o,d=(u=s)[0],h=u[1],f=u[2],p=u[3],v=u[4],g=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*v+E*m,l[2]=x*f+w*g+E*b,l[3]=k*d+T*p+C*y,l[4]=k*h+T*v+C*m,l[5]=k*f+T*g+C*b,l[6]=P*d+S*p+B*y,l[7]=P*h+S*v+B*m,l[8]=P*f+S*g+B*b,D}(e),u=e.getCachedZSortedEles();if(o=u.length,i.startFrame(l,n),n.screen){for(var c=0;c<u.nondrag.length;c++)bh(e,c,u.nondrag[c]);for(var d=0;d<u.drag.length;d++)bh(e,d,u.drag[d])}else if(n.picking)for(var h=0;h<u.length;h++)bh(e,h,u[h]);i.endFrame(),n.screen&&e.webglDebugShowAtlases&&(function(e){var t=e.data.contexts[e.NODE];t.save(),mh(e,t),t.strokeStyle="rgba(0, 0, 0, 0.3)",t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}(e),function(e){var t=function(t,n,r){for(var a=t.atlasManager.getAtlasCollection(n),i=e.data.contexts[e.NODE],o=a.atlases,s=0;s<o.length;s++){var l=o[s].canvas;if(l){var u=l.width,c=l.height,d=u*s,h=l.height*r;i.save(),i.scale(.4,.4),i.drawImage(l,d,h),i.strokeStyle="black",i.rect(d,h,u,c),i.stroke(),i.restore()}}},n=0;t(e.drawing,"node",n++),t(e.drawing,"label",n++)}(e)),e.data.canvasNeedsRedraw[e.NODE]=!1,e.data.canvasNeedsRedraw[e.DRAG]=!1}if(e.webglDebug){var f=performance.now(),p=Math.ceil(f-a),v=i.getDebugInfo(),g=["".concat(o," elements"),"".concat(v.totalInstances," instances"),"".concat(v.batchCount," batches"),"".concat(v.totalAtlases," atlases"),"".concat(v.wrappedCount," wrapped textures"),"".concat(v.simpleCount," simple shapes")].join(", ");console.log("WebGL (".concat(n.name,") - frame time ").concat(p,"ms")),console.log("Totals:"),console.log("  ".concat(g)),console.log("Texture Atlases Used:");var y,m=r(v.atlasInfo);try{for(m.s();!(y=m.n()).done;){var b=y.value;console.log("  ".concat(b.type,": ").concat(b.keyCount," keys, ").concat(b.atlasCount," atlases"))}}catch(e){m.e(e)}finally{m.f()}console.log("")}e.data.gc&&(console.log("Garbage Collect!"),e.data.gc=!1,i.gc())}for(var wh={drawPolygonPath:function(e,t,n,r,a,i){var o=r/2,s=a/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*i[0],n+s*i[1]);for(var l=1;l<i.length/2;l++)e.lineTo(t+o*i[2*l],n+s*i[2*l+1]);e.closePath()},drawRoundPolygonPath:function(e,t,n,r,a,i,o){o.forEach((function(t){return zc(e,t)})),e.closePath()},drawRoundRectanglePath:function(e,t,n,r,a,i){var o=r/2,s=a/2,l="auto"===i?_n(r,a):Math.min(i,s,o);e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.arcTo(t+o,n-s,t+o,n,l),e.arcTo(t+o,n+s,t,n+s,l),e.arcTo(t-o,n+s,t-o,n,l),e.arcTo(t-o,n-s,t,n-s,l),e.lineTo(t,n-s),e.closePath()},drawBottomRoundRectanglePath:function(e,t,n,r,a,i){var o=r/2,s=a/2,l="auto"===i?_n(r,a):i;e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.lineTo(t+o,n-s),e.lineTo(t+o,n),e.arcTo(t+o,n+s,t,n+s,l),e.arcTo(t-o,n+s,t-o,n,l),e.lineTo(t-o,n-s),e.lineTo(t,n-s),e.closePath()},drawCutRectanglePath:function(e,t,n,r,a,i,o){var s=r/2,l=a/2,u="auto"===o?8:o;e.beginPath&&e.beginPath(),e.moveTo(t-s+u,n-l),e.lineTo(t+s-u,n-l),e.lineTo(t+s,n-l+u),e.lineTo(t+s,n+l-u),e.lineTo(t+s-u,n+l),e.lineTo(t-s+u,n+l),e.lineTo(t-s,n+l-u),e.lineTo(t-s,n-l+u),e.closePath()},drawBarrelPath:function(e,t,n,r,a){var i=r/2,o=a/2,s=t-i,l=t+i,u=n-o,c=n+o,d=Mn(r,a),h=d.widthOffset,f=d.heightOffset,p=d.ctrlPtOffsetPct*h;e.beginPath&&e.beginPath(),e.moveTo(s,u+f),e.lineTo(s,c-f),e.quadraticCurveTo(s+p,c,s+h,c),e.lineTo(l-h,c),e.quadraticCurveTo(l-p,c,l,c-f),e.lineTo(l,u+f),e.quadraticCurveTo(l-p,u,l-h,u),e.lineTo(s+h,u),e.quadraticCurveTo(s+p,u,s,u+f),e.closePath()}},Eh=Math.sin(0),kh=Math.cos(0),Th={},Ch={},Ph=Math.PI/40,Sh=0*Math.PI;Sh<2*Math.PI;Sh+=Ph)Th[Sh]=Math.sin(Sh),Ch[Sh]=Math.cos(Sh);wh.drawEllipsePath=function(e,t,n,r,a){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,a/2,0,0,2*Math.PI);else for(var i,o,s=r/2,l=a/2,u=0*Math.PI;u<2*Math.PI;u+=Ph)i=t-s*Th[u]*Eh+s*Ch[u]*kh,o=n+l*Ch[u]*Eh+l*Th[u]*kh,0===u?e.moveTo(i,o):e.lineTo(i,o);e.closePath()};var Bh={};function Dh(e){var t=e.indexOf(",");return e.substr(t+1)}function _h(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case"blob-promise":return new Hr((function(r,a){try{t.toBlob((function(e){null!=e?r(e):a(new Error("`canvas.toBlob()` sent a null value in its callback"))}),n,e.quality)}catch(e){a(e)}}));case"blob":return function(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),a=new Uint8Array(r),i=0;i<n.length;i++)a[i]=n.charCodeAt(i);return new Blob([r],{type:t})}(Dh(r()),n);case"base64":return Dh(r());default:return r()}}Bh.createBuffer=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,[n,n.getContext("2d")]},Bh.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),a=e.full?Math.ceil(n.w):r[2],i=e.full?Math.ceil(n.h):r[3],o=G(e.maxWidth)||G(e.maxHeight),s=this.getPixelRatio(),l=1;if(void 0!==e.scale)a*=e.scale,i*=e.scale,l=e.scale;else if(o){var u=1/0,c=1/0;G(e.maxWidth)&&(u=l*e.maxWidth/a),G(e.maxHeight)&&(c=l*e.maxHeight/i),a*=l=Math.min(u,c),i*=l}o||(a*=s,i*=s,l*=s);var d=document.createElement("canvas");d.width=a,d.height=i,d.style.width=a+"px",d.style.height=i+"px";var h=d.getContext("2d");if(a>0&&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(),v={x:p.x*l,y:p.y*l};l*=t.zoom(),h.translate(v.x,v.y),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(-v.x,-v.y)}e.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=e.bg,h.rect(0,0,a,i),h.fill())}return d},Bh.png=function(e){return _h(e,this.bufferCanvasImage(e),"image/png")},Bh.jpg=function(e){return _h(e,this.bufferCanvasImage(e),"image/jpeg")};var Ah={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)}}},Mh=Ih,Rh=Ih.prototype;function Ih(e){var t=this,n=t.cy.window().document;e.webgl&&(Rh.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),t.data={canvases:new Array(Rh.CANVAS_LAYERS),contexts:new Array(Rh.CANVAS_LAYERS),canvasNeedsRedraw:new Array(Rh.CANVAS_LAYERS),bufferCanvases:new Array(Rh.BUFFER_COUNT),bufferContexts:new Array(Rh.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;l<Rh.CANVAS_LAYERS;l++){var u=t.data.canvases[l]=n.createElement("canvas"),c=Rh.CANVAS_TYPES[l];t.data.contexts[l]=u.getContext(c),t.data.contexts[l]||nt("Could not create canvas of type "+c),Object.keys(s).forEach((function(e){u.style[e]=s[e]})),u.style.position="absolute",u.setAttribute("data-id","layer"+l),u.style.zIndex=String(Rh.CANVAS_LAYERS-l),t.data.canvasContainer.appendChild(u),t.data.canvasNeedsRedraw[l]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[Rh.NODE].setAttribute("data-id","layer"+Rh.NODE+"-node"),t.data.canvases[Rh.SELECT_BOX].setAttribute("data-id","layer"+Rh.SELECT_BOX+"-selectbox"),t.data.canvases[Rh.DRAG].setAttribute("data-id","layer"+Rh.DRAG+"-drag"),t.data.canvases[Rh.WEBGL]&&t.data.canvases[Rh.WEBGL].setAttribute("data-id","layer"+Rh.WEBGL+"-webgl");for(l=0;l<Rh.BUFFER_COUNT;l++)t.data.bufferCanvases[l]=n.createElement("canvas"),t.data.bufferContexts[l]=t.data.bufferCanvases[l].getContext("2d"),t.data.bufferCanvases[l].style.position="absolute",t.data.bufferCanvases[l].setAttribute("data-id","buffer"+l),t.data.bufferCanvases[l].style.zIndex=String(-l-1),t.data.bufferCanvases[l].style.visibility="hidden";t.pathsEnabled=!0;var h=Jt(),f=function(e){return{x:-e.w/2,y:-e.h/2}},p=function(e){return e[0]._private.nodeKey},v=function(e){return e[0]._private.labelStyleKey},g=function(e){return e[0]._private.sourceLabelStyleKey},y=function(e){return e[0]._private.targetLabelStyleKey},m=function(e,n,r,a,i){return t.drawElement(e,n,r,!1,!1,i)},b=function(e,n,r,a,i){return t.drawElementText(e,n,r,a,"main",i)},x=function(e,n,r,a,i){return t.drawElementText(e,n,r,a,"source",i)},w=function(e,n,r,a,i){return t.drawElementText(e,n,r,a,"target",i)},E=function(e){return e.boundingBox(),e[0]._private.bodyBounds},k=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||h},T=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||h},C=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||h},P=function(e,t){return t},S=function(e){return{x:((t=E(e)).x1+t.x2)/2,y:(t.y1+t.y2)/2};var t},B=function(e,t,n){var r=e?e+"-":"";return{x:t.x+n.pstyle(r+"text-margin-x").pfValue,y:t.y+n.pstyle(r+"text-margin-y").pfValue}},D=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},_=function(e){return B("",D(e,"labelX","labelY"),e)},A=function(e){return B("source",D(e,"sourceLabelX","sourceLabelY"),e)},M=function(e){return B("target",D(e,"targetLabelX","targetLabelY"),e)},R=function(e){return f(E(e))},I=function(e){return f(T(e))},N=function(e){return f(C(e))},L=function(e){var t=k(e),n=f(k(e));if(e.isNode()){switch(e.pstyle("text-halign").value){case"left":n.x=-t.w-(t.leftPad||0);break;case"right":n.x=-(t.rightPad||0)}switch(e.pstyle("text-valign").value){case"top":n.y=-t.h-(t.topPad||0);break;case"bottom":n.y=-(t.botPad||0)}}return n},z=t.data.eleTxrCache=new fd(t,{getKey:p,doesEleInvalidateKey:function(e){var t=e[0]._private;return!(t.oldBackgroundTimestamp===t.backgroundTimestamp)},drawElement:m,getBoundingBox:E,getRotationPoint:S,getRotationOffset:R,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),O=t.data.lblTxrCache=new fd(t,{getKey:v,drawElement:b,getBoundingBox:k,getRotationPoint:_,getRotationOffset:L,isVisible:P}),V=t.data.slbTxrCache=new fd(t,{getKey:g,drawElement:x,getBoundingBox:T,getRotationPoint:A,getRotationOffset:I,isVisible:P}),F=t.data.tlbTxrCache=new fd(t,{getKey:y,drawElement:w,getBoundingBox:C,getRotationPoint:M,getRotationOffset:N,isVisible:P}),X=t.data.lyrTxrCache=new vd(t);t.onUpdateEleCalcs((function(e,t){z.invalidateElements(t),O.invalidateElements(t),V.invalidateElements(t),F.invalidateElements(t),X.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}}));var j=function(e){for(var t=0;t<e.length;t++)X.enqueueElementRefinement(e[t].ele)};z.onDequeue(j),O.onDequeue(j),V.onDequeue(j),F.onDequeue(j),e.webgl&&t.initWebgl(e,{getStyleKey:p,getLabelKey:v,getSourceLabelKey:g,getTargetLabelKey:y,drawElement:m,drawLabel:b,drawSourceLabel:x,drawTargetLabel:w,getElementBox:E,getLabelBox:k,getSourceLabelBox:T,getTargetLabelBox:C,getElementRotationPoint:S,getElementRotationOffset:R,getLabelRotationPoint:_,getSourceLabelRotationPoint:A,getTargetLabelRotationPoint:M,getLabelRotationOffset:L,getSourceLabelRotationOffset:I,getTargetLabelRotationOffset:N})}Rh.CANVAS_LAYERS=3,Rh.SELECT_BOX=0,Rh.DRAG=1,Rh.NODE=2,Rh.WEBGL=3,Rh.CANVAS_TYPES=["2d","2d","2d","webgl2"],Rh.BUFFER_COUNT=3,Rh.TEXTURE_BUFFER=0,Rh.MOTIONBLUR_BUFFER_NODE=1,Rh.MOTIONBLUR_BUFFER_DRAG=2,Rh.redrawHint=function(e,t){var n=this;switch(e){case"eles":n.data.canvasNeedsRedraw[Rh.NODE]=t;break;case"drag":n.data.canvasNeedsRedraw[Rh.DRAG]=t;break;case"select":n.data.canvasNeedsRedraw[Rh.SELECT_BOX]=t;break;case"gc":n.data.gc=!0}};var Nh="undefined"!=typeof Path2D;Rh.path2dEnabled=function(e){if(void 0===e)return this.pathsEnabled;this.pathsEnabled=!!e},Rh.usePaths=function(){return Nh&&this.pathsEnabled},Rh.setImgSmoothing=function(e,t){null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled=t:(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t)},Rh.getImgSmoothing=function(e){return null!=e.imageSmoothingEnabled?e.imageSmoothingEnabled:e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled},Rh.makeOffscreenCanvas=function(e,t){var n;"undefined"!==("undefined"==typeof OffscreenCanvas?"undefined":l(OffscreenCanvas))?n=new OffscreenCanvas(e,t):((n=this.cy.window().document.createElement("canvas")).width=e,n.height=t);return n},[xd,Pd,Rd,Nd,Ld,Od,Xd,ph,wh,Bh,Ah].forEach((function(e){ge(Rh,e)}));var Lh=[{type:"layout",extensions:uc},{type:"renderer",extensions:[{name:"null",impl:cc},{name:"base",impl:id},{name:"canvas",impl:Mh}]}],zh={},Oh={};function Vh(e,t,n){var r=n,a=function(n){at("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if("core"===e){if(Eu.prototype[t])return a(t);Eu.prototype[t]=n}else if("collection"===e){if(Ol.prototype[t])return a(t);Ol.prototype[t]=n}else if("layout"===e){for(var i=function(e){this.options=e,n.call(this,e),K(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=i.prototype=Object.create(n.prototype),s=[],l=0;l<s.length;l++){var u=s[l];o[u]=o[u]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var c=n.prototype.stop;o.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return c?c.call(this):this.emit("layoutstop"),this},o.destroy||(o.destroy=function(){return this}),o.cy=function(){return this._private.cy};var d=function(e){return e._private.cy},h={addEventFields:function(e,t){t.layout=e,t.cy=d(e),t.target=e},bubble:function(){return!0},parent:function(e){return d(e)}};ge(o,{createEmitter:function(){return this._private.emitter=new nl(h,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),xo.eventAliasesOn(o),r=i}else if("renderer"===e&&"null"!==t&&"base"!==t){var f=Fh("renderer","base"),p=f.prototype,v=n,g=n.prototype,y=function(){f.apply(this,arguments),v.apply(this,arguments)},m=y.prototype;for(var b in p){var x=p[b];if(null!=g[b])return a(b);m[b]=x}for(var w in g)m[w]=g[w];p.clientFunctions.forEach((function(e){m[e]=m[e]||function(){nt("Renderer does not implement `renderer."+e+"()` on its prototype")}})),r=y}else if("__proto__"===e||"constructor"===e||"prototype"===e)return nt(e+" is an illegal type to be registered, possibly lead to prototype pollutions");return be({map:zh,keys:[e,t],value:r})}function Fh(e,t){return xe({map:zh,keys:[e,t]})}function Xh(e,t,n,r,a){return be({map:Oh,keys:[e,t,n,r],value:a})}function jh(e,t,n,r){return xe({map:Oh,keys:[e,t,n,r]})}var Yh=function(){return 2===arguments.length?Fh.apply(null,arguments):3===arguments.length?Vh.apply(null,arguments):4===arguments.length?jh.apply(null,arguments):5===arguments.length?Xh.apply(null,arguments):void nt("Invalid extension access syntax")};Eu.prototype.extension=Yh,Lh.forEach((function(e){e.extensions.forEach((function(t){Vh(e.type,t.name,t.impl)}))}));var qh=function(){if(!(this instanceof qh))return new qh;this.length=0},Wh=qh.prototype;Wh.instanceString=function(){return"stylesheet"},Wh.selector=function(e){return this[this.length++]={selector:e,properties:[]},this},Wh.css=function(e,t){var n=this.length-1;if(W(e))this[n].properties.push({name:e,value:t});else if(K(e))for(var r=e,a=Object.keys(r),i=0;i<a.length;i++){var o=a[i],s=r[o];if(null!=s){var l=yu.properties[o]||yu.properties[oe(o)];if(null!=l){var u=l.name,c=s;this[n].properties.push({name:u,value:c})}}}return this},Wh.style=Wh.css,Wh.generateStyle=function(e){var t=new yu(e);return this.appendToStyle(t)},Wh.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,a=n.properties;e.selector(r);for(var i=0;i<a.length;i++){var o=a[i];e.css(o.name,o.value)}}return e};var Uh=function(e){return void 0===e&&(e={}),K(e)?new Eu(e):W(e)?Yh.apply(Yh,arguments):void 0};return Uh.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(Uh),e.apply(null,t),this},Uh.warnings=function(e){return rt(e)},Uh.version="3.33.1",Uh.stylesheet=Uh.Stylesheet=qh,Uh}));
diff --git a/docs/src/topology.md b/docs/src/topology.md
deleted file mode 100644
index 4ba9d1dce..000000000
--- a/docs/src/topology.md
+++ /dev/null
@@ -1,195 +0,0 @@
-# Graph Topology
-
-This module provides the `Graph` trait and various graph implementations for defining computational problems on different graph structures.
-
-## Design Philosophy
-
-Following Julia's Graphs.jl pattern, problems are generic over graph type. This enables **topology-aware reductions**:
-
-```rust
-use problemreductions::topology::{Graph, SimpleGraph, UnitDiskGraph};
-use problemreductions::models::graph::IndependentSetT;
-
-// Standard problem on SimpleGraph (default)
-let is_simple: IndependentSetT = IndependentSetT::new(4, vec![(0, 1), (1, 2)]);
-
-// Same problem on UnitDiskGraph (for quantum hardware)
-let udg = UnitDiskGraph::new(positions, radius);
-let is_udg: IndependentSetT<UnitDiskGraph> = IndependentSetT::from_graph(udg);
-```
-
-Different reductions can target different topologies:
-
-```rust
-// Standard reduction -> arbitrary graph
-impl ReduceTo<IndependentSetT<SimpleGraph>> for Satisfiability { ... }
-
-// Topology-aware reduction -> unit disk graph (using geometric gadgets)
-impl ReduceTo<IndependentSetT<UnitDiskGraph>> for Satisfiability { ... }
-```
-
-## The Graph Trait
-
-All graph types implement the `Graph` trait:
-
-```rust
-pub trait Graph: Clone + Send + Sync {
-    fn num_vertices(&self) -> usize;
-    fn num_edges(&self) -> usize;
-    fn edges(&self) -> Vec<(usize, usize)>;
-    fn has_edge(&self, u: usize, v: usize) -> bool;
-    fn neighbors(&self, v: usize) -> Vec<usize>;
-    fn degree(&self, v: usize) -> usize;  // default impl
-    fn is_empty(&self) -> bool;            // default impl
-}
-```
-
-## SimpleGraph
-
-The default graph type for most problems. Wraps petgraph's `UnGraph` with convenient constructors:
-
-```rust
-use problemreductions::topology::SimpleGraph;
-
-// Create from vertices and edges
-let g = SimpleGraph::new(4, vec![(0, 1), (1, 2), (2, 3)]);
-
-// Factory methods
-let complete = SimpleGraph::complete(4);    // K4
-let path = SimpleGraph::path(5);            // 0-1-2-3-4
-let cycle = SimpleGraph::cycle(4);          // 0-1-2-3-0
-let star = SimpleGraph::star(5);            // 0 connected to 1,2,3,4
-let grid = SimpleGraph::grid(3, 4);         // 3x4 grid graph
-```
-
-## UnitDiskGraph
-
-Geometric graphs where vertices have 2D positions and edges connect vertices within a distance threshold. Useful for:
-
-- Quantum computing (neutral atom arrays)
-- Wireless network problems
-- Geometric constraint satisfaction
-
-```rust
-use problemreductions::topology::UnitDiskGraph;
-
-let positions = vec![
-    (0.0, 0.0),
-    (1.0, 0.0),   // Distance 1.0 from (0,0)
-    (2.5, 0.0),   // Distance 2.5 from (0,0)
-];
-
-let udg = UnitDiskGraph::new(positions, 1.5);
-// Edges: 0-1 (distance 1.0 <= 1.5)
-// No edge 0-2 (distance 2.5 > 1.5)
-// No edge 1-2 (distance 1.5 <= 1.5, so actually connected!)
-
-// Grid factory
-let grid_udg = UnitDiskGraph::grid(3, 4, 1.0, 1.5);
-```
-
-### Using with Problems
-
-```rust
-use problemreductions::topology::UnitDiskGraph;
-use problemreductions::models::graph::IndependentSetT;
-
-// Create UDG representing quantum hardware connectivity
-let udg = UnitDiskGraph::new(atom_positions, interaction_radius);
-
-// Define Independent Set problem on this topology
-let problem: IndependentSetT<UnitDiskGraph> = IndependentSetT::from_graph(udg);
-
-// Solve for maximum independent set
-let solutions = solver.find_best(&problem);
-```
-
-## HyperGraph
-
-Generalized graphs where edges (hyperedges) can connect any number of vertices. Note: HyperGraph does NOT implement the `Graph` trait since hyperedges are fundamentally different from 2-vertex edges.
-
-```rust
-use problemreductions::topology::HyperGraph;
-
-let hg = HyperGraph::new(5, vec![
-    vec![0, 1, 2],  // Hyperedge connecting 3 vertices
-    vec![2, 3, 4],  // Another hyperedge
-]);
-
-assert_eq!(hg.num_vertices(), 5);
-assert_eq!(hg.num_edges(), 2);
-
-// Get neighbors (vertices sharing a hyperedge)
-let neighbors = hg.neighbors(2);  // [0, 1, 3, 4]
-
-// Check if it's actually a regular graph
-if hg.is_regular_graph() {
-    let edges = hg.to_graph_edges().unwrap();
-}
-```
-
-## API Reference
-
-### Graph Trait
-
-```rust
-pub trait Graph: Clone + Send + Sync {
-    fn num_vertices(&self) -> usize;
-    fn num_edges(&self) -> usize;
-    fn edges(&self) -> Vec<(usize, usize)>;
-    fn has_edge(&self, u: usize, v: usize) -> bool;
-    fn neighbors(&self, v: usize) -> Vec<usize>;
-    fn degree(&self, v: usize) -> usize;
-    fn is_empty(&self) -> bool;
-    fn for_each_edge<F>(&self, f: F) where F: FnMut(usize, usize);
-}
-```
-
-### SimpleGraph
-
-```rust
-impl SimpleGraph {
-    pub fn new(num_vertices: usize, edges: Vec<(usize, usize)>) -> Self;
-    pub fn empty(num_vertices: usize) -> Self;
-    pub fn complete(num_vertices: usize) -> Self;
-    pub fn path(num_vertices: usize) -> Self;
-    pub fn cycle(num_vertices: usize) -> Self;
-    pub fn star(num_vertices: usize) -> Self;
-    pub fn grid(rows: usize, cols: usize) -> Self;
-}
-```
-
-### UnitDiskGraph
-
-```rust
-impl UnitDiskGraph {
-    pub fn new(positions: Vec<(f64, f64)>, radius: f64) -> Self;
-    pub fn unit(positions: Vec<(f64, f64)>) -> Self;  // radius = 1.0
-    pub fn grid(rows: usize, cols: usize, spacing: f64, radius: f64) -> Self;
-    pub fn radius(&self) -> f64;
-    pub fn position(&self, v: usize) -> Option<(f64, f64)>;
-    pub fn positions(&self) -> &[(f64, f64)];
-    pub fn vertex_distance(&self, u: usize, v: usize) -> Option<f64>;
-    pub fn bounding_box(&self) -> Option<((f64, f64), (f64, f64))>;
-}
-```
-
-### HyperGraph
-
-```rust
-impl HyperGraph {
-    pub fn new(num_vertices: usize, edges: Vec<Vec<usize>>) -> Self;
-    pub fn empty(num_vertices: usize) -> Self;
-    pub fn num_vertices(&self) -> usize;
-    pub fn num_edges(&self) -> usize;
-    pub fn edges(&self) -> &[Vec<usize>];
-    pub fn edge(&self, index: usize) -> Option<&Vec<usize>>;
-    pub fn has_edge(&self, edge: &[usize]) -> bool;
-    pub fn neighbors(&self, v: usize) -> Vec<usize>;
-    pub fn degree(&self, v: usize) -> usize;
-    pub fn edges_containing(&self, v: usize) -> Vec<&Vec<usize>>;
-    pub fn max_edge_size(&self) -> usize;
-    pub fn is_regular_graph(&self) -> bool;
-    pub fn to_graph_edges(&self) -> Option<Vec<(usize, usize)>>;
-}
-```
diff --git a/examples/export_schemas.rs b/examples/export_schemas.rs
new file mode 100644
index 000000000..c17b5b480
--- /dev/null
+++ b/examples/export_schemas.rs
@@ -0,0 +1,20 @@
+//! Export problem schemas to a JSON file.
+//!
+//! Run with: `cargo run --example export_schemas`
+
+use problemreductions::registry::collect_schemas;
+use std::path::Path;
+
+fn main() {
+    let schemas = collect_schemas();
+    println!("Collected {} problem schemas", schemas.len());
+
+    let output_path = Path::new("docs/paper/problem_schemas.json");
+    if let Some(parent) = output_path.parent() {
+        std::fs::create_dir_all(parent).expect("Failed to create output directory");
+    }
+
+    let json = serde_json::to_string_pretty(&schemas).expect("Failed to serialize");
+    std::fs::write(output_path, &json).expect("Failed to write file");
+    println!("Exported to: {}", output_path.display());
+}
diff --git a/src/models/graph/clique.rs b/src/models/graph/clique.rs
index b18b13a83..79f5bd1ff 100644
--- a/src/models/graph/clique.rs
+++ b/src/models/graph/clique.rs
@@ -3,12 +3,25 @@
 //! The Clique problem asks for a maximum weight subset of vertices
 //! such that all vertices in the subset are pairwise adjacent.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "Clique",
+        category: "graph",
+        description: "Find maximum weight clique in a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Vertex weights w: V -> R" },
+        ],
+    }
+}
+
 /// The Clique problem.
 ///
 /// Given a graph G = (V, E) and weights w_v for each vertex,
diff --git a/src/models/graph/dominating_set.rs b/src/models/graph/dominating_set.rs
index 24c7c36c4..e745d6cba 100644
--- a/src/models/graph/dominating_set.rs
+++ b/src/models/graph/dominating_set.rs
@@ -3,6 +3,7 @@
 //! The Dominating Set problem asks for a minimum weight subset of vertices
 //! such that every vertex is either in the set or adjacent to a vertex in the set.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
@@ -10,6 +11,18 @@ use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 use std::collections::HashSet;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "DominatingSet",
+        category: "graph",
+        description: "Find minimum weight dominating set in a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Vertex weights w: V -> R" },
+        ],
+    }
+}
+
 /// The Dominating Set problem.
 ///
 /// Given a graph G = (V, E) and weights w_v for each vertex,
diff --git a/src/models/graph/independent_set.rs b/src/models/graph/independent_set.rs
index 9c097e7a6..67f507079 100644
--- a/src/models/graph/independent_set.rs
+++ b/src/models/graph/independent_set.rs
@@ -3,12 +3,25 @@
 //! The Independent Set problem asks for a maximum weight subset of vertices
 //! such that no two vertices in the subset are adjacent.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "IndependentSet",
+        category: "graph",
+        description: "Find maximum weight independent set in a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Vertex weights w: V -> R" },
+        ],
+    }
+}
+
 /// The Independent Set problem.
 ///
 /// Given a graph G = (V, E) and weights w_v for each vertex,
diff --git a/src/models/graph/kcoloring.rs b/src/models/graph/kcoloring.rs
index 92d6c6652..b7559a71e 100644
--- a/src/models/graph/kcoloring.rs
+++ b/src/models/graph/kcoloring.rs
@@ -3,6 +3,7 @@
 //! The K-Coloring problem asks whether a graph can be colored with K colors
 //! such that no two adjacent vertices have the same color.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
@@ -10,6 +11,17 @@ use crate::variant::{const_usize_str, short_type_name};
 use serde::{Deserialize, Serialize};
 use std::marker::PhantomData;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "KColoring",
+        category: "graph",
+        description: "Find valid k-coloring of a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" },
+        ],
+    }
+}
+
 /// The Graph K-Coloring problem.
 ///
 /// Given a graph G = (V, E) and K colors, find an assignment of colors
diff --git a/src/models/graph/matching.rs b/src/models/graph/matching.rs
index 3a7b3229c..e0092b5ac 100644
--- a/src/models/graph/matching.rs
+++ b/src/models/graph/matching.rs
@@ -3,6 +3,7 @@
 //! The Maximum Matching problem asks for a maximum weight set of edges
 //! such that no two edges share a vertex.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
@@ -10,6 +11,18 @@ use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 use std::collections::HashMap;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "Matching",
+        category: "graph",
+        description: "Find maximum weight matching in a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" },
+            FieldInfo { name: "edge_weights", type_name: "Vec<W>", description: "Edge weights w: E -> R" },
+        ],
+    }
+}
+
 /// The Maximum Matching problem.
 ///
 /// Given a graph G = (V, E) with edge weights, find a maximum weight
diff --git a/src/models/graph/max_cut.rs b/src/models/graph/max_cut.rs
index 84bcd63d5..2de0c5079 100644
--- a/src/models/graph/max_cut.rs
+++ b/src/models/graph/max_cut.rs
@@ -3,12 +3,25 @@
 //! The Maximum Cut problem asks for a partition of vertices into two sets
 //! that maximizes the total weight of edges crossing the partition.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "MaxCut",
+        category: "graph",
+        description: "Find maximum weight cut in a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The graph with edge weights" },
+            FieldInfo { name: "edge_weights", type_name: "Vec<W>", description: "Edge weights w: E -> R" },
+        ],
+    }
+}
+
 /// The Maximum Cut problem.
 ///
 /// Given a weighted graph G = (V, E) with edge weights w_e,
diff --git a/src/models/graph/maximal_is.rs b/src/models/graph/maximal_is.rs
index 76549db7a..0ee6db3bb 100644
--- a/src/models/graph/maximal_is.rs
+++ b/src/models/graph/maximal_is.rs
@@ -3,12 +3,25 @@
 //! The Maximal Independent Set problem asks for an independent set that
 //! cannot be extended by adding any other vertex.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "MaximalIS",
+        category: "graph",
+        description: "Find maximum weight maximal independent set",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Vertex weights w: V -> R" },
+        ],
+    }
+}
+
 /// The Maximal Independent Set problem.
 ///
 /// Given a graph G = (V, E), find an independent set S that is maximal,
diff --git a/src/models/graph/vertex_covering.rs b/src/models/graph/vertex_covering.rs
index 33133b51e..e97dc3aba 100644
--- a/src/models/graph/vertex_covering.rs
+++ b/src/models/graph/vertex_covering.rs
@@ -3,12 +3,25 @@
 //! The Vertex Cover problem asks for a minimum weight subset of vertices
 //! such that every edge has at least one endpoint in the subset.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "VertexCovering",
+        category: "graph",
+        description: "Find minimum weight vertex cover in a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The underlying graph G=(V,E)" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Vertex weights w: V -> R" },
+        ],
+    }
+}
+
 /// The Vertex Covering problem.
 ///
 /// Given a graph G = (V, E) and weights w_v for each vertex,
diff --git a/src/models/optimization/ilp.rs b/src/models/optimization/ilp.rs
index 6c3f52403..36fa95f54 100644
--- a/src/models/optimization/ilp.rs
+++ b/src/models/optimization/ilp.rs
@@ -3,10 +3,26 @@
 //! ILP optimizes a linear objective over integer variables subject to linear constraints.
 //! This is a fundamental "hub" problem that many other NP-hard problems can be reduced to.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "ILP",
+        category: "optimization",
+        description: "Optimize linear objective subject to linear constraints",
+        fields: &[
+            FieldInfo { name: "num_vars", type_name: "usize", description: "Number of integer variables" },
+            FieldInfo { name: "bounds", type_name: "Vec<VarBounds>", description: "Variable bounds" },
+            FieldInfo { name: "constraints", type_name: "Vec<LinearConstraint>", description: "Linear constraints" },
+            FieldInfo { name: "objective", type_name: "Vec<(usize, f64)>", description: "Sparse objective coefficients" },
+            FieldInfo { name: "sense", type_name: "ObjectiveSense", description: "Optimization direction" },
+        ],
+    }
+}
+
 /// Variable bounds (None = unbounded in that direction).
 ///
 /// Represents the lower and upper bounds for an integer variable.
diff --git a/src/models/optimization/qubo.rs b/src/models/optimization/qubo.rs
index 771104cba..314374c7c 100644
--- a/src/models/optimization/qubo.rs
+++ b/src/models/optimization/qubo.rs
@@ -2,11 +2,24 @@
 //!
 //! QUBO minimizes a quadratic function over binary variables.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "QUBO",
+        category: "optimization",
+        description: "Minimize quadratic unconstrained binary objective",
+        fields: &[
+            FieldInfo { name: "num_vars", type_name: "usize", description: "Number of binary variables" },
+            FieldInfo { name: "matrix", type_name: "Vec<Vec<W>>", description: "Upper-triangular Q matrix" },
+        ],
+    }
+}
+
 /// The QUBO (Quadratic Unconstrained Binary Optimization) problem.
 ///
 /// Given n binary variables x_i ∈ {0, 1} and a matrix Q,
diff --git a/src/models/optimization/spin_glass.rs b/src/models/optimization/spin_glass.rs
index 373da699a..e5caeaa09 100644
--- a/src/models/optimization/spin_glass.rs
+++ b/src/models/optimization/spin_glass.rs
@@ -2,12 +2,26 @@
 //!
 //! The Spin Glass problem minimizes the Ising Hamiltonian energy.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::topology::{Graph, SimpleGraph};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "SpinGlass",
+        category: "optimization",
+        description: "Minimize Ising Hamiltonian on a graph",
+        fields: &[
+            FieldInfo { name: "graph", type_name: "G", description: "The interaction graph" },
+            FieldInfo { name: "couplings", type_name: "Vec<W>", description: "Pairwise couplings J_ij" },
+            FieldInfo { name: "fields", type_name: "Vec<W>", description: "On-site fields h_i" },
+        ],
+    }
+}
+
 /// The Spin Glass (Ising model) problem.
 ///
 /// Given n spin variables s_i in {-1, +1}, interaction coefficients J_ij,
diff --git a/src/models/satisfiability/ksat.rs b/src/models/satisfiability/ksat.rs
index 304059a39..baa8021cf 100644
--- a/src/models/satisfiability/ksat.rs
+++ b/src/models/satisfiability/ksat.rs
@@ -3,6 +3,7 @@
 //! K-SAT is a special case of SAT where each clause has exactly K literals.
 //! Common variants include 3-SAT (K=3) and 2-SAT (K=2).
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
@@ -10,6 +11,19 @@ use serde::{Deserialize, Serialize};
 
 use super::CNFClause;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "KSatisfiability",
+        category: "satisfiability",
+        description: "SAT with exactly k literals per clause",
+        fields: &[
+            FieldInfo { name: "num_vars", type_name: "usize", description: "Number of Boolean variables" },
+            FieldInfo { name: "clauses", type_name: "Vec<CNFClause>", description: "Clauses each with exactly K literals" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Clause weights for MAX-K-SAT" },
+        ],
+    }
+}
+
 /// K-Satisfiability problem where each clause has exactly K literals.
 ///
 /// This is a restricted form of SAT where every clause must contain
diff --git a/src/models/satisfiability/sat.rs b/src/models/satisfiability/sat.rs
index 489054b58..faeacb33c 100644
--- a/src/models/satisfiability/sat.rs
+++ b/src/models/satisfiability/sat.rs
@@ -3,11 +3,25 @@
 //! SAT is the problem of determining if there exists an assignment of
 //! Boolean variables that makes a given Boolean formula true.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "Satisfiability",
+        category: "satisfiability",
+        description: "Find satisfying assignment for CNF formula",
+        fields: &[
+            FieldInfo { name: "num_vars", type_name: "usize", description: "Number of Boolean variables" },
+            FieldInfo { name: "clauses", type_name: "Vec<CNFClause>", description: "Clauses in conjunctive normal form" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Clause weights for MAX-SAT" },
+        ],
+    }
+}
+
 /// A clause in conjunctive normal form (CNF).
 ///
 /// A clause is a disjunction (OR) of literals.
diff --git a/src/models/set/set_covering.rs b/src/models/set/set_covering.rs
index 7eac815a2..21c3fbeab 100644
--- a/src/models/set/set_covering.rs
+++ b/src/models/set/set_covering.rs
@@ -3,12 +3,26 @@
 //! The Set Covering problem asks for a minimum weight collection of sets
 //! that covers all elements in the universe.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 use std::collections::HashSet;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "SetCovering",
+        category: "set",
+        description: "Find minimum weight collection covering the universe",
+        fields: &[
+            FieldInfo { name: "universe_size", type_name: "usize", description: "Size of the universe U" },
+            FieldInfo { name: "sets", type_name: "Vec<Vec<usize>>", description: "Collection of subsets of U" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Weight for each set" },
+        ],
+    }
+}
+
 /// The Set Covering problem.
 ///
 /// Given a universe U of elements and a collection S of subsets of U,
diff --git a/src/models/set/set_packing.rs b/src/models/set/set_packing.rs
index 5d8bc4e14..06a20d319 100644
--- a/src/models/set/set_packing.rs
+++ b/src/models/set/set_packing.rs
@@ -3,12 +3,25 @@
 //! The Set Packing problem asks for a maximum weight collection of
 //! pairwise disjoint sets.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::{ConstraintSatisfactionProblem, Problem};
 use crate::types::{EnergyMode, LocalConstraint, LocalSolutionSize, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 use std::collections::HashSet;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "SetPacking",
+        category: "set",
+        description: "Find maximum weight collection of disjoint sets",
+        fields: &[
+            FieldInfo { name: "sets", type_name: "Vec<Vec<usize>>", description: "Collection of sets over a universe" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Weight for each set" },
+        ],
+    }
+}
+
 /// The Set Packing problem.
 ///
 /// Given a collection S of sets, each with a weight, find a maximum weight
diff --git a/src/models/specialized/biclique_cover.rs b/src/models/specialized/biclique_cover.rs
index d40b536a3..83eb7e2b6 100644
--- a/src/models/specialized/biclique_cover.rs
+++ b/src/models/specialized/biclique_cover.rs
@@ -3,11 +3,26 @@
 //! The Biclique Cover problem asks for the minimum number of bicliques
 //! (complete bipartite subgraphs) needed to cover all edges of a bipartite graph.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use serde::{Deserialize, Serialize};
 use std::collections::HashSet;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "BicliqueCover",
+        category: "specialized",
+        description: "Cover bipartite edges with k bicliques",
+        fields: &[
+            FieldInfo { name: "left_size", type_name: "usize", description: "Vertices in left partition" },
+            FieldInfo { name: "right_size", type_name: "usize", description: "Vertices in right partition" },
+            FieldInfo { name: "edges", type_name: "Vec<(usize, usize)>", description: "Bipartite edges" },
+            FieldInfo { name: "k", type_name: "usize", description: "Number of bicliques" },
+        ],
+    }
+}
+
 /// The Biclique Cover problem.
 ///
 /// Given a bipartite graph with vertex sets L and R, find k bicliques
diff --git a/src/models/specialized/bmf.rs b/src/models/specialized/bmf.rs
index 8addf66d7..ab57d04a1 100644
--- a/src/models/specialized/bmf.rs
+++ b/src/models/specialized/bmf.rs
@@ -4,10 +4,25 @@
 //! the boolean product B ⊙ C approximates A.
 //! The boolean product `(B ⊙ C)[i,j] = OR_k (B[i,k] AND C[k,j])`.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "BMF",
+        category: "specialized",
+        description: "Boolean matrix factorization",
+        fields: &[
+            FieldInfo { name: "matrix", type_name: "Vec<Vec<bool>>", description: "Target boolean matrix A" },
+            FieldInfo { name: "m", type_name: "usize", description: "Number of rows" },
+            FieldInfo { name: "n", type_name: "usize", description: "Number of columns" },
+            FieldInfo { name: "k", type_name: "usize", description: "Factorization rank" },
+        ],
+    }
+}
+
 /// The Boolean Matrix Factorization problem.
 ///
 /// Given an m×n boolean matrix A and rank k, find:
diff --git a/src/models/specialized/circuit.rs b/src/models/specialized/circuit.rs
index c324a5499..6f242cbe6 100644
--- a/src/models/specialized/circuit.rs
+++ b/src/models/specialized/circuit.rs
@@ -3,12 +3,26 @@
 //! CircuitSAT represents a boolean circuit satisfiability problem.
 //! The goal is to find variable assignments that satisfy the circuit constraints.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use crate::variant::short_type_name;
 use serde::{Deserialize, Serialize};
 use std::collections::HashMap;
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "CircuitSAT",
+        category: "satisfiability",
+        description: "Find satisfying input to a boolean circuit",
+        fields: &[
+            FieldInfo { name: "circuit", type_name: "Circuit", description: "The boolean circuit" },
+            FieldInfo { name: "variables", type_name: "Vec<String>", description: "Circuit variable names" },
+            FieldInfo { name: "weights", type_name: "Vec<W>", description: "Assignment weights" },
+        ],
+    }
+}
+
 /// Boolean expression node types.
 #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
 pub enum BooleanOp {
diff --git a/src/models/specialized/factoring.rs b/src/models/specialized/factoring.rs
index b9fbceacf..89dee27be 100644
--- a/src/models/specialized/factoring.rs
+++ b/src/models/specialized/factoring.rs
@@ -3,10 +3,24 @@
 //! The Factoring problem represents integer factorization as a computational problem.
 //! Given a number N, find two factors (a, b) such that a * b = N.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use serde::{Deserialize, Serialize};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "Factoring",
+        category: "specialized",
+        description: "Factor a composite integer into two factors",
+        fields: &[
+            FieldInfo { name: "m", type_name: "usize", description: "Bits for first factor" },
+            FieldInfo { name: "n", type_name: "usize", description: "Bits for second factor" },
+            FieldInfo { name: "target", type_name: "u64", description: "Number to factor" },
+        ],
+    }
+}
+
 /// The Integer Factoring problem.
 ///
 /// Given a number to factor, find two integers that multiply to give
diff --git a/src/models/specialized/paintshop.rs b/src/models/specialized/paintshop.rs
index f268e8fd8..27801fac9 100644
--- a/src/models/specialized/paintshop.rs
+++ b/src/models/specialized/paintshop.rs
@@ -5,11 +5,26 @@
 //! one color at its first occurrence and another at its second.
 //! The goal is to minimize color switches between adjacent positions.
 
+use crate::registry::{FieldInfo, ProblemSchemaEntry};
 use crate::traits::Problem;
 use crate::types::{EnergyMode, ProblemSize, SolutionSize};
 use serde::{Deserialize, Serialize};
 use std::collections::{HashMap, HashSet};
 
+inventory::submit! {
+    ProblemSchemaEntry {
+        name: "PaintShop",
+        category: "specialized",
+        description: "Minimize color changes in paint shop sequence",
+        fields: &[
+            FieldInfo { name: "sequence_indices", type_name: "Vec<usize>", description: "Car sequence as indices" },
+            FieldInfo { name: "car_labels", type_name: "Vec<String>", description: "Unique car labels" },
+            FieldInfo { name: "is_first", type_name: "Vec<bool>", description: "First occurrence flags" },
+            FieldInfo { name: "num_cars", type_name: "usize", description: "Number of unique cars" },
+        ],
+    }
+}
+
 /// The Paint Shop problem.
 ///
 /// Given a sequence where each car appears exactly twice, assign colors
diff --git a/src/registry/info.rs b/src/registry/info.rs
index 6564cede0..2cec1be19 100644
--- a/src/registry/info.rs
+++ b/src/registry/info.rs
@@ -126,6 +126,8 @@ pub struct ProblemInfo {
     pub canonical_reduction_from: Option<&'static str>,
     /// Wikipedia or reference URL.
     pub reference_url: Option<&'static str>,
+    /// Struct field descriptions for schema export.
+    pub fields: &'static [FieldInfo],
 }
 
 impl ProblemInfo {
@@ -140,6 +142,7 @@ impl ProblemInfo {
             optimization_version: true,
             canonical_reduction_from: None,
             reference_url: None,
+            fields: &[],
         }
     }
 
@@ -179,6 +182,12 @@ impl ProblemInfo {
         self
     }
 
+    /// Builder method to set struct field descriptions.
+    pub const fn with_fields(mut self, fields: &'static [FieldInfo]) -> Self {
+        self.fields = fields;
+        self
+    }
+
     /// Check if this problem is NP-complete.
     pub fn is_np_complete(&self) -> bool {
         self.complexity_class == ComplexityClass::NpComplete
@@ -198,6 +207,17 @@ impl fmt::Display for ProblemInfo {
     }
 }
 
+/// Description of a struct field for JSON schema export.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct FieldInfo {
+    /// Field name as it appears in the Rust struct.
+    pub name: &'static str,
+    /// Type name (e.g., "Vec<W>", "UnGraph<(), ()>").
+    pub type_name: &'static str,
+    /// Human-readable description of what this field represents.
+    pub description: &'static str,
+}
+
 /// Trait for problems that provide static metadata.
 ///
 /// Implement this trait to enable introspection and discovery for problem types.
diff --git a/src/registry/mod.rs b/src/registry/mod.rs
index f851be7dd..0f8c155ed 100644
--- a/src/registry/mod.rs
+++ b/src/registry/mod.rs
@@ -59,10 +59,12 @@
 
 mod category;
 mod info;
+mod schema;
 
 pub use category::{
     GraphSubcategory, NetworkSubcategory, OptimizationSubcategory, ProblemCategory,
     SatisfiabilitySubcategory, SchedulingSubcategory, SetSubcategory, SpecializedSubcategory,
     StringSubcategory,
 };
-pub use info::{ComplexityClass, ProblemInfo, ProblemMetadata};
+pub use info::{ComplexityClass, FieldInfo, ProblemInfo, ProblemMetadata};
+pub use schema::{collect_schemas, FieldInfoJson, ProblemSchemaEntry, ProblemSchemaJson};
diff --git a/src/registry/schema.rs b/src/registry/schema.rs
new file mode 100644
index 000000000..b743260ef
--- /dev/null
+++ b/src/registry/schema.rs
@@ -0,0 +1,69 @@
+//! Problem schema registration via inventory.
+
+use super::FieldInfo;
+use serde::Serialize;
+
+/// A registered problem schema entry for static inventory registration.
+pub struct ProblemSchemaEntry {
+    /// Problem name (e.g., "IndependentSet").
+    pub name: &'static str,
+    /// Category (e.g., "graph", "optimization").
+    pub category: &'static str,
+    /// Human-readable description.
+    pub description: &'static str,
+    /// Struct fields.
+    pub fields: &'static [FieldInfo],
+}
+
+inventory::collect!(ProblemSchemaEntry);
+
+/// JSON-serializable problem schema.
+#[derive(Debug, Clone, Serialize)]
+pub struct ProblemSchemaJson {
+    /// Problem name.
+    pub name: String,
+    /// Problem category.
+    pub category: String,
+    /// Problem description.
+    pub description: String,
+    /// Struct fields.
+    pub fields: Vec<FieldInfoJson>,
+}
+
+/// JSON-serializable field info.
+#[derive(Debug, Clone, Serialize)]
+pub struct FieldInfoJson {
+    /// Field name.
+    pub name: String,
+    /// Field type.
+    pub type_name: String,
+    /// Field description.
+    pub description: String,
+}
+
+/// Collect all registered problem schemas into JSON-serializable form.
+pub fn collect_schemas() -> Vec<ProblemSchemaJson> {
+    let mut schemas: Vec<ProblemSchemaJson> = inventory::iter::<ProblemSchemaEntry>
+        .into_iter()
+        .map(|entry| ProblemSchemaJson {
+            name: entry.name.to_string(),
+            category: entry.category.to_string(),
+            description: entry.description.to_string(),
+            fields: entry
+                .fields
+                .iter()
+                .map(|f| FieldInfoJson {
+                    name: f.name.to_string(),
+                    type_name: f.type_name.to_string(),
+                    description: f.description.to_string(),
+                })
+                .collect(),
+        })
+        .collect();
+    schemas.sort_by(|a, b| a.name.cmp(&b.name));
+    schemas
+}
+
+#[cfg(test)]
+#[path = "../unit_tests/registry/schema.rs"]
+mod tests;
diff --git a/src/rules/graph.rs b/src/rules/graph.rs
index e9c9cc510..61ae73e75 100644
--- a/src/rules/graph.rs
+++ b/src/rules/graph.rs
@@ -39,6 +39,8 @@ pub struct NodeJson {
     pub variant: std::collections::BTreeMap<String, String>,
     /// Category of the problem (e.g., "graph", "set", "optimization", "satisfiability", "specialized").
     pub category: String,
+    /// Relative rustdoc path (e.g., "models/graph/independent_set").
+    pub doc_path: String,
 }
 
 /// Reference to a problem variant in an edge.
@@ -592,15 +594,17 @@ impl ReductionGraph {
             ));
         }
 
-        // Build nodes with categories
+        // Build nodes with categories and doc paths
         let mut nodes: Vec<NodeJson> = node_set
             .iter()
             .map(|(name, variant)| {
                 let category = Self::categorize_type(name);
+                let doc_path = Self::compute_doc_path(name);
                 NodeJson {
                     name: name.clone(),
                     variant: variant.clone(),
                     category: category.to_string(),
+                    doc_path,
                 }
             })
             .collect();
@@ -662,6 +666,20 @@ impl ReductionGraph {
         std::fs::write(path, json_string)
     }
 
+    /// Compute the rustdoc path for a problem type.
+    /// Maps name → actual Rust module location (which may differ from the visualization category).
+    fn compute_doc_path(name: &str) -> String {
+        let module = match name {
+            "IndependentSet" | "MaximalIS" | "VertexCovering" | "DominatingSet" | "KColoring"
+            | "Matching" | "MaxCut" | "Clique" => "graph",
+            "Satisfiability" | "KSatisfiability" => "satisfiability",
+            "SpinGlass" | "QUBO" | "ILP" => "optimization",
+            "SetCovering" | "SetPacking" => "set",
+            _ => "specialized",
+        };
+        format!("models/{module}/struct.{name}.html")
+    }
+
     /// Categorize a type name into a problem category.
     fn categorize_type(name: &str) -> &'static str {
         if name.contains("IndependentSet")
diff --git a/src/unit_tests/registry/info.rs b/src/unit_tests/registry/info.rs
index 44aea1657..ce9ca0155 100644
--- a/src/unit_tests/registry/info.rs
+++ b/src/unit_tests/registry/info.rs
@@ -41,3 +41,15 @@ fn test_problem_info_versions() {
     assert!(!opt_only.decision_version);
     assert!(opt_only.optimization_version);
 }
+
+#[test]
+fn test_problem_info_with_fields() {
+    const FIELDS: &[FieldInfo] = &[
+        FieldInfo { name: "graph", type_name: "G", description: "The graph" },
+        FieldInfo { name: "weights", type_name: "Vec<W>", description: "Vertex weights" },
+    ];
+    let info = ProblemInfo::new("Test", "Test problem").with_fields(FIELDS);
+    assert_eq!(info.fields.len(), 2);
+    assert_eq!(info.fields[0].name, "graph");
+    assert_eq!(info.fields[1].type_name, "Vec<W>");
+}
diff --git a/src/unit_tests/registry/schema.rs b/src/unit_tests/registry/schema.rs
new file mode 100644
index 000000000..1af9a90b4
--- /dev/null
+++ b/src/unit_tests/registry/schema.rs
@@ -0,0 +1,59 @@
+use super::*;
+
+#[test]
+fn test_collect_schemas_returns_all_problems() {
+    let schemas = collect_schemas();
+    // We have 17 registered problems
+    assert!(schemas.len() >= 17, "Expected at least 17 schemas, got {}", schemas.len());
+}
+
+#[test]
+fn test_collect_schemas_sorted_by_name() {
+    let schemas = collect_schemas();
+    for w in schemas.windows(2) {
+        assert!(w[0].name <= w[1].name, "Schemas not sorted: {} > {}", w[0].name, w[1].name);
+    }
+}
+
+#[test]
+fn test_collect_schemas_known_problems() {
+    let schemas = collect_schemas();
+    let names: Vec<&str> = schemas.iter().map(|s| s.name.as_str()).collect();
+    for expected in &["IndependentSet", "VertexCovering", "QUBO", "SpinGlass", "Satisfiability", "KColoring"] {
+        assert!(names.contains(expected), "Missing schema for {}", expected);
+    }
+}
+
+#[test]
+fn test_schema_fields_populated() {
+    let schemas = collect_schemas();
+    let is_schema = schemas.iter().find(|s| s.name == "IndependentSet").unwrap();
+    assert_eq!(is_schema.category, "graph");
+    assert!(!is_schema.fields.is_empty(), "IndependentSet should have fields");
+    let field_names: Vec<&str> = is_schema.fields.iter().map(|f| f.name.as_str()).collect();
+    assert!(field_names.contains(&"graph"), "IndependentSet should have 'graph' field");
+    assert!(field_names.contains(&"weights"), "IndependentSet should have 'weights' field");
+}
+
+#[test]
+fn test_schema_json_serialization() {
+    let schemas = collect_schemas();
+    let json = serde_json::to_string(&schemas).expect("Schemas should serialize to JSON");
+    assert!(json.contains("IndependentSet"));
+    assert!(json.contains("graph"));
+}
+
+#[test]
+fn test_field_info_json_fields() {
+    let schemas = collect_schemas();
+    let sg = schemas.iter().find(|s| s.name == "SpinGlass").unwrap();
+    assert_eq!(sg.fields.len(), 3);
+    let field_names: Vec<&str> = sg.fields.iter().map(|f| f.name.as_str()).collect();
+    assert!(field_names.contains(&"graph"));
+    assert!(field_names.contains(&"couplings"));
+    assert!(field_names.contains(&"fields"));
+    for f in &sg.fields {
+        assert!(!f.type_name.is_empty());
+        assert!(!f.description.is_empty());
+    }
+}
