diff --git a/.gitignore b/.gitignore
index ee23e88..10da2e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,4 +48,5 @@ nuxt-shadcn-dashboard/
/dev/
/docs/
jmh-result.text
-*.text
\ No newline at end of file
+*.text
+/flash-extensions/flash-ext-routeviewer/routeviewer-ui/node_modules/
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 0a645a4..b1479bf 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -11,6 +11,8 @@
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 917c0db..f53c935 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,12 +4,26 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -30,7 +44,7 @@
-
+
@@ -69,50 +83,50 @@
- {
+ "keyToString": {
+ "Application.ExternalBenchmark (1).executor": "Run",
+ "Application.ExternalBenchmark.executor": "Run",
+ "Application.Main.executor": "Run",
+ "Application.dev.relism.bench.Main.executor": "Run",
+ "JUnit.RequestParserTest.executor": "Run",
+ "JUnit.RequestParserTest.headers_caseInsensitive.executor": "Debug",
+ "Maven.FlashPractice [test].executor": "Run",
+ "Maven.flash [compile].executor": "Run",
+ "Maven.flash [install].executor": "Run",
+ "Maven.flash [test].executor": "Run",
+ "Maven.flash-bench [clean].executor": "Run",
+ "Maven.flash-bench [install].executor": "Run",
+ "Maven.flash-bench [package].executor": "Run",
+ "Maven.flash-bench [validate].executor": "Run",
+ "Maven.flash-parent [install].executor": "Run",
+ "Maven.flash-parent [package].executor": "Run",
+ "ModuleVcsDetector.initialDetectionPerformed": "true",
+ "RunOnceActivity.MCP Project settings loaded": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "RunOnceActivity.typescript.service.memoryLimit.init": "true",
+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "git-widget-placeholder": "master",
+ "ignore.virus.scanning.warn.message": "true",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Users/elorc/Documents/Coding/Java/practice/Flash",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "npm.build.executor": "Run",
+ "onboarding.tips.debug.path": "C:/Users/elorc/Documents/Coding/Java/practice/FlashPractice/flash-bench/src/main/java/dev/relism/Main.java",
+ "project.structure.last.edited": "Modules",
+ "project.structure.proportion": "0.15",
+ "project.structure.side.proportion": "0.1150748",
+ "settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings",
+ "ts.external.directory.path": "C:\\Users\\elorc\\Documents\\Coding\\Java\\practice\\Flash\\nuxt-shadcn-dashboard\\node_modules\\typescript\\lib",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -251,7 +265,12 @@
-
+
+
+
+
+
+
@@ -309,7 +328,15 @@
1773952556190
-
+
+
+ 1774530802482
+
+
+
+ 1774530802482
+
+
@@ -346,7 +373,8 @@
-
+
+
diff --git a/README.md b/README.md
index 760fd5d..d35515a 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,194 @@
# Flash
+
+A high-performance HTTP/1.1 server library for Java 21, built around virtual threads and a zero-allocation FSM router.
+
+## Modules
+
+| Module | Description |
+|---|---|
+| `flash` | Core server library — router, request parser, HTTP I/O transport |
+| `flash-extensions/flash-ext-jackson` | Jackson JSON integration |
+| `flash-extensions/flash-ext-openapi` | OpenAPI 3.0 spec + Swagger UI |
+| `flash-extensions/flash-ext-oidc` | OIDC Authorization Code + PKCE flow |
+| `flash-bench` | Demo harness (OIDC + OpenAPI + Jackson) |
+
+## Requirements
+
+- Java 21+
+- Maven 3.8+
+
+## Quick start
+
+```java
+FlashApp.create(8080)
+ .get("/ping", (req, res) -> "pong")
+ .start();
+```
+
+With full configuration:
+
+```java
+FlashApp.create(
+ FlashConfiguration.builder()
+ .port(8080)
+ .host("0.0.0.0")
+ .maxHeaderBufferSize(65536)
+ .build()
+)
+.get("/ping", (req, res) -> "pong")
+.start();
+```
+
+## Route registration
+
+### Lambda routes
+
+```java
+FlashApp app = FlashApp.create(8080);
+
+app.get("/hello", (req, res) -> "world");
+
+app.post("/echo", (req, res) -> {
+ byte[] body = req.body().bytes();
+ return res.status(200).body(body);
+});
+
+app.get("/users/{id}", (req, res) -> {
+ String id = req.pathParam("id");
+ return "user:" + id;
+});
+```
+
+### Class-based handlers
+
+Extend `RequestHandler` (or a subclass like `JacksonHandler`) and annotate with `@Route`:
+
+```java
+@Route(method = HttpMethod.GET, path = "/api/users")
+public class ListUsers extends JacksonHandler {
+ @Override
+ public Object handle(Request req, Response res) throws Exception {
+ return json(res, List.of("alice", "bob"));
+ }
+}
+
+// Register:
+app.register(new ListUsers());
+```
+
+### Middleware
+
+Apply middleware via `.with()` on the `RouteHandle` returned by any registration call:
+
+```java
+Middleware authCheck = next -> (req, res) -> {
+ if (req.header("Authorization") == null)
+ return res.status(401).body("Unauthorized");
+ return next.handle(req, res);
+};
+
+app.get("/secure", (req, res) -> "secret data")
+ .with(authCheck);
+```
+
+Multiple middlewares are composed outermost-first (left-to-right in the call):
+
+```java
+app.get("/admin", handler).with(logging, auth, rateLimit);
+// execution order: logging → auth → rateLimit → handler
+```
+
+### Classpath scan
+
+Scans a package for classes that extend `RequestHandler` and carry `@Route`. Each is
+instantiated via its public no-arg constructor:
+
+```java
+app.scan("dev.example.handlers");
+```
+
+### Namespace mounting
+
+Mount a scoped sub-router under a prefix. All routes registered inside the scope get the
+prefix prepended automatically. The scope inherits the parent's extension context (annotation
+processors, services):
+
+```java
+app.mount("/api", scope -> {
+ scope.get("/health", (req, res) -> "ok"); // → GET /api/health
+ scope.register(new UserHandler()); // @Route(path="/users") → GET /api/users
+ scope.scan("dev.example.api");
+});
+```
+
+## Extensions
+
+Extensions are installed before route registration. Each extension receives the `FlashRegistrar`
+and `ExtensionContext` — it can register routes, expose services, and register annotation processors.
+
+```java
+FlashApp.create(8080)
+ .install(new JacksonExtension())
+ .install(new OpenApiExtension("/openapi", "My API", "1.0.0"))
+ .install(new OidcExtension(oidcConfig))
+ .register(new MyHandler())
+ .start();
+```
+
+See extension-specific READMEs for full details:
+- [`flash-ext-jackson`](flash-extensions/flash-ext-jackson/README.md)
+- [`flash-ext-openapi`](flash-extensions/flash-ext-openapi/README.md)
+- [`flash-ext-oidc`](flash-extensions/flash-ext-oidc/README.md)
+
+## Error handlers
+
+```java
+app.onNotFound((req, res) -> res.status(404).body("Not found: " + req.path()));
+
+app.onException((ex, req, res) -> {
+ if (ex instanceof IllegalArgumentException)
+ return res.status(400).body(ex.getMessage());
+ return res.status(500).body("Internal error");
+});
+```
+
+## FlashConfiguration
+
+| Field | Default | Description |
+|---|---|---|
+| `port` | — | TCP port to bind |
+| `host` | `"0.0.0.0"` | Bind address |
+| `maxHeaderBufferSize` | `65536` | Max size of the header buffer (bytes) |
+
+## Architecture
+
+```
+ServerSocket.accept()
+ → RequestParser.parse() # zero-alloc header parsing, buffer reuse across keep-alive
+ → GlobalRouter.route() # two-tier: mounted sub-routers (longest prefix) then FastPathRouterImpl
+ → RequestHandler.handle() # user handler; return value sets body
+ → Request.drain() # consume unread body for keep-alive
+ → HttpServer writes response # status line, headers, then fixed or chunked body
+ → loop or close socket # based on Connection header
+```
+
+- **Virtual threads** — each accepted socket runs on a virtual thread (`Executors.newVirtualThreadPerTaskExecutor()`). Java 21 required.
+- **Zero-allocation router** — `FastPathRouterImpl` uses `fpr-core`, a byte-level FSM that matches on `METHOD + path` bytes with no per-request allocation.
+- **Keep-alive** — `RequestParser` reuses its header buffer across requests on the same connection.
+- **Chunked transfer** — both chunked request bodies (decoded via `ChunkedInputStream`) and chunked response bodies are supported.
+
+## Build & test
+
+```bash
+# Build all modules (skip tests)
+mvn clean package -DskipTests
+
+# Run all tests
+mvn test
+
+# Run a single test class
+mvn test -pl flash -Dtest=RequestParserTest
+
+# Run the benchmark demo server
+java -jar flash-bench/target/flash-bench-1.0-SNAPSHOT.jar
+```
diff --git a/flash-extensions/flash-ext-jackson/README.md b/flash-extensions/flash-ext-jackson/README.md
index 57ba650..30ec01e 100644
--- a/flash-extensions/flash-ext-jackson/README.md
+++ b/flash-extensions/flash-ext-jackson/README.md
@@ -23,7 +23,7 @@ Jackson JSON integration for the Flash HTTP server.
Install before any extension that needs JSON (e.g. `flash-ext-openapi`, `flash-ext-oidc`):
```java
-FlashApp.of(new HttpServer(config))
+FlashApp.create(8080)
.install(new JacksonExtension())
// ... other extensions
```
@@ -36,7 +36,7 @@ ObjectMapper mapper = JsonMapper.builder()
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
-FlashApp.of(new HttpServer(config))
+FlashApp.create(8080)
.install(new JacksonExtension(mapper));
```
diff --git a/flash-extensions/flash-ext-jackson/src/main/java/dev/relism/ext/jackson/JacksonExtension.java b/flash-extensions/flash-ext-jackson/src/main/java/dev/relism/ext/jackson/JacksonExtension.java
index 0fc0bfd..908777b 100644
--- a/flash-extensions/flash-ext-jackson/src/main/java/dev/relism/ext/jackson/JacksonExtension.java
+++ b/flash-extensions/flash-ext-jackson/src/main/java/dev/relism/ext/jackson/JacksonExtension.java
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import dev.relism.exceptions.HttpException;
import dev.relism.extension.ExtensionContext;
-import dev.relism.extension.FlashApp;
import dev.relism.extension.FlashExtension;
+import dev.relism.extension.FlashRegistrar;
import dev.relism.http.ContentType;
/**
@@ -45,7 +45,7 @@ public class JacksonExtension implements FlashExtension {
}
@Override
- public void install(FlashApp app, ExtensionContext ctx) {
+ public void install(FlashRegistrar app, ExtensionContext ctx) {
ctx.provide(ObjectMapper.class, mapper);
JacksonHandler.mapper = mapper;
diff --git a/flash-extensions/flash-ext-oidc/README.md b/flash-extensions/flash-ext-oidc/README.md
index 004cad2..1814a03 100644
--- a/flash-extensions/flash-ext-oidc/README.md
+++ b/flash-extensions/flash-ext-oidc/README.md
@@ -32,7 +32,7 @@ Optional: `flash-ext-openapi` — if present, OIDC security schemes are added to
## Installation
```java
-FlashApp.of(new HttpServer(config))
+FlashApp.create(8080)
.install(new JacksonExtension())
.install(new OpenApiExtension(...)) // optional — enables Swagger security
.install(new OidcExtension(
@@ -144,17 +144,17 @@ OidcMiddleware oidc = app.ctx().require(OidcMiddleware.class);
app.get("/api/me", (req, res) -> {
OidcUser u = ClaimsHolder.user(); // never null here
return Map.of("sub", u.sub(), "email", u.email());
-}, oidc.protect());
+}).with(oidc.protect());
// Authentication + role check
app.delete("/api/admin/users/{id}", (req, res) -> {
OidcUser u = ClaimsHolder.user();
// ...
-}, oidc.requireRole("admin"));
+}).with(oidc.requireRole("admin"));
// Multiple roles (OR): passes if user holds any one of them
-app.get("/api/reports", (req, res) -> { ... },
- oidc.requireRole("admin", "reports-viewer"));
+app.get("/api/reports", (req, res) -> { ... })
+ .with(oidc.requireRole("admin", "reports-viewer"));
```
`oidc.protect()` / `oidc.requireRole(...)` return a `Middleware` — a composable
@@ -326,8 +326,8 @@ OidcMiddleware mwA = app.ctx().require(OidcMiddleware.class); // tenantA's mid
app.install(new OidcExtension(tenantB));
OidcMiddleware mwB = app.ctx().require(OidcMiddleware.class); // tenantB's middleware
-app.get("/a/dashboard", (req, res) -> { ... }, mwA.protect());
-app.get("/b/dashboard", (req, res) -> { ... }, mwB.protect());
+app.get("/a/dashboard", (req, res) -> { ... }).with(mwA.protect());
+app.get("/b/dashboard", (req, res) -> { ... }).with(mwB.protect());
```
Class-based handlers annotated with `@Authenticated` / `@RolesAllowed` get the last
diff --git a/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/Authenticated.java b/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/Authenticated.java
index 812a9b2..7a3158d 100644
--- a/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/Authenticated.java
+++ b/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/Authenticated.java
@@ -11,13 +11,30 @@ import java.lang.annotation.Target;
*
*
For role-based access use {@link RolesAllowed} instead (it implies authentication).
*
+ *
Set {@code optional = true} on public routes that personalise their response when
+ * the user happens to be logged in but should remain accessible to guests. The middleware
+ * will populate {@link ClaimsHolder} if credentials are present and silently skip it
+ * otherwise — the request is never rejected.
+ *
*
{@code
+ * // Hard auth — redirects / 401 when unauthenticated:
* @Route(method = HttpMethod.GET, path = "/api/profile")
* @Authenticated
* public class GetProfile extends JacksonHandler { ... }
+ *
+ * // Soft auth — guest-friendly, ClaimsHolder populated only when logged in:
+ * @Route(method = HttpMethod.GET, path = "/")
+ * @Authenticated(optional = true)
+ * public class HomePage extends HtmlHandler { ... }
* }
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Authenticated {
+ /**
+ * When {@code true} the middleware never rejects unauthenticated requests — it only
+ * populates {@link ClaimsHolder} when valid credentials are present.
+ * Defaults to {@code false} (hard authentication required).
+ */
+ boolean optional() default false;
}
diff --git a/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcExtension.java b/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcExtension.java
index 743047c..45c7648 100644
--- a/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcExtension.java
+++ b/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcExtension.java
@@ -1,8 +1,8 @@
package dev.relism.ext.oidc;
import dev.relism.extension.ExtensionContext;
-import dev.relism.extension.FlashApp;
import dev.relism.extension.FlashExtension;
+import dev.relism.extension.FlashRegistrar;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
@@ -59,7 +59,7 @@ public class OidcExtension implements FlashExtension {
}
@Override
- public void install(FlashApp app, ExtensionContext ctx) {
+ public void install(FlashRegistrar app, ExtensionContext ctx) {
// 1. Build the shared HttpClient (optionally with TLS verification disabled)
HttpClient http = buildHttpClient(config);
@@ -116,7 +116,7 @@ public class OidcExtension implements FlashExtension {
+ "&code_challenge=" + challenge
+ "&code_challenge_method=S256";
- res.status(302).header("Location", authUrl);
+ res.redirect(authUrl);
return null;
}).with();
@@ -165,9 +165,8 @@ public class OidcExtension implements FlashExtension {
);
config.sessionStore().save(session);
- res.status(302)
- .header("Set-Cookie", sessionCookie(session.id()))
- .header("Location", entry.originalUrl());
+ res.header("Set-Cookie", sessionCookie(session.id()))
+ .redirect(entry.originalUrl());
return null;
}).with();
@@ -200,9 +199,8 @@ public class OidcExtension implements FlashExtension {
location = config.postLogoutRedirectUri();
}
- res.status(302)
- .header("Set-Cookie", clearCookie)
- .header("Location", location);
+ res.header("Set-Cookie", clearCookie)
+ .redirect(location);
return null;
}).with();
@@ -212,7 +210,9 @@ public class OidcExtension implements FlashExtension {
if (roles != null) return List.of(oidcMw.rolesMiddleware(roles.value()));
Authenticated auth = handlerClass.getAnnotation(Authenticated.class);
- if (auth != null) return List.of(oidcMw.authenticatedMiddleware());
+ if (auth != null) return List.of(auth.optional()
+ ? oidcMw.optionalMiddleware()
+ : oidcMw.authenticatedMiddleware());
return List.of();
});
diff --git a/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcMiddleware.java b/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcMiddleware.java
index d3fb217..abcb4ab 100644
--- a/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcMiddleware.java
+++ b/flash-extensions/flash-ext-oidc/src/main/java/dev/relism/ext/oidc/OidcMiddleware.java
@@ -68,6 +68,29 @@ public class OidcMiddleware {
};
}
+ /**
+ * Silently populates {@link ClaimsHolder} if a valid bearer token or session cookie
+ * is present, but never rejects or redirects unauthenticated requests. Use this on
+ * public routes that want to personalise the response when the user happens to be
+ * logged in (e.g. showing a username on a landing page).
+ *
+ *
{@code
+ * app.get("/", handler).with(oidc.optional());
+ * // Inside handler: ClaimsHolder.user() is non-null iff the user is logged in.
+ * }
Produces a {@code {"nodes":[...],"edges":[...]}} payload compatible with
+ * {@code @xyflow/react}. No external JSON library required — the graph schema is
+ * simple and static enough for manual serialization.
+ *
+ *
The {@link RouteGraph} is frozen at startup; this handler is pure read-only
+ * and produces no allocations beyond the response string itself.
+ */
+class RouteViewerDataHandler {
+
+ private final RouteGraph graph;
+ /** Cached once — the graph never changes after boot. */
+ private volatile String cachedJson;
+
+ RouteViewerDataHandler(RouteGraph graph) {
+ this.graph = graph;
+ }
+
+ Object handle(Request req, Response res) {
+ if (cachedJson == null) cachedJson = GraphSerializer.toJson(graph);
+ res.setContentType(ContentType.JSON);
+ res.header("Cache-Control", "no-cache");
+ return cachedJson;
+ }
+}
diff --git a/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/RouteViewerExtension.java b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/RouteViewerExtension.java
new file mode 100644
index 0000000..8675c4b
--- /dev/null
+++ b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/RouteViewerExtension.java
@@ -0,0 +1,74 @@
+package dev.relism.ext.routeviewer;
+
+import dev.relism.ext.routeviewer.model.RouteGraph;
+import dev.relism.extension.ExtensionContext;
+import dev.relism.extension.FlashExtension;
+import dev.relism.extension.FlashRegistrar;
+import dev.relism.http.ContentType;
+
+/**
+ * Mounts an interactive route-graph viewer at a configurable HTTP endpoint.
+ *
+ *
The viewer is a React SPA ({@code @xyflow/react}) bundled into the JAR.
+ * It renders routers, routes, handler inheritance chains, and middleware chains
+ * as a draggable, zoomable node graph.
+ *
+ *
Endpoints registered
+ *
+ *
{@code GET } — SPA shell (index.html)
+ *
{@code GET /app.js} — React bundle
+ *
{@code GET /app.css} — styles
+ *
{@code GET /data} — graph JSON consumed by the SPA
+ *
+ *
+ *
Install order
+ * Install after extensions that register annotation processors
+ * (e.g. {@code OidcExtension}) but before {@code scan()} or
+ * {@code register()} calls so the listener captures all routes:
+ *
+ *
All route metadata is collected once at boot time via
+ * {@link ExtensionContext#addRouteListener}. Zero overhead on the request hot-path.
+ */
+public class RouteViewerExtension implements FlashExtension {
+
+ public static final String DEFAULT_PATH = "/routeviewer";
+
+ private final String path;
+ private final RouteGraph graph = new RouteGraph();
+
+ /** Installs the viewer at {@value #DEFAULT_PATH}. */
+ public RouteViewerExtension() { this(DEFAULT_PATH); }
+
+ /**
+ * Installs the viewer at a custom path.
+ * @param path e.g. {@code "/_routes"}
+ */
+ public RouteViewerExtension(String path) { this.path = path; }
+
+ @Override
+ public void install(FlashRegistrar app, ExtensionContext ctx) {
+ RouteViewerHandler shell = new RouteViewerHandler();
+ RouteViewerDataHandler data = new RouteViewerDataHandler(graph);
+
+ // Static assets (Vite build output, bundled in JAR)
+ app.get(path, shell::handle);
+ app.get(path + "/app.js", new RouteViewerStaticHandler("routeviewer/app.js", ContentType.TEXT_JAVASCRIPT)::handle);
+ app.get(path + "/app.css", new RouteViewerStaticHandler("routeviewer/app.css", ContentType.TEXT_CSS)::handle);
+
+ // Graph data API — must be registered before the listener so it is
+ // flushed and captured AFTER the listener is attached (shows in the graph)
+ app.get(path + "/data", data::handle);
+
+ // Start listening — routes registered after this point are captured
+ ctx.addRouteListener(graph::add);
+ }
+}
diff --git a/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/RouteViewerHandler.java b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/RouteViewerHandler.java
new file mode 100644
index 0000000..d0fb1df
--- /dev/null
+++ b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/RouteViewerHandler.java
@@ -0,0 +1,38 @@
+package dev.relism.ext.routeviewer;
+
+import dev.relism.http.ContentType;
+import dev.relism.models.Request;
+import dev.relism.models.Response;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Serves the route-viewer SPA shell ({@code index.html}) from the classpath.
+ *
+ *
The HTML file is produced by the Vite build of {@code routeviewer-ui/}
+ * and packaged into the JAR under {@code routeviewer/index.html}.
+ * The SPA then fetches {@code /routeviewer/data} for the graph payload.
+ */
+class RouteViewerHandler {
+
+ private static final String RESOURCE = "routeviewer/index.html";
+ private static final String FALLBACK =
+ "
Route Viewer UI not built." +
+ " Run: cd routeviewer-ui && pnpm build
Used to expose the Vite-built assets ({@code app.js}, {@code app.css})
+ * that the route-viewer SPA needs.
+ */
+class RouteViewerStaticHandler {
+
+ private final String classpathResource;
+ private final ContentType contentType;
+ /** Cached bytes — static assets never change after startup. */
+ private volatile byte[] cached;
+
+ RouteViewerStaticHandler(String classpathResource, ContentType contentType) {
+ this.classpathResource = classpathResource;
+ this.contentType = contentType;
+ }
+
+ Object handle(Request req, Response res) throws IOException {
+ if (cached == null) cached = load();
+ if (cached == null) {
+ res.setStatusCode(404);
+ return null;
+ }
+ res.setStatusCode(200);
+ res.setContentType(contentType);
+ res.header("Cache-Control", "public, max-age=3600");
+ return cached;
+ }
+
+ private byte[] load() throws IOException {
+ try (InputStream in = RouteViewerStaticHandler.class
+ .getClassLoader().getResourceAsStream(classpathResource)) {
+ return in == null ? null : in.readAllBytes();
+ }
+ }
+}
diff --git a/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouteGraph.java b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouteGraph.java
new file mode 100644
index 0000000..0ba2967
--- /dev/null
+++ b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouteGraph.java
@@ -0,0 +1,44 @@
+package dev.relism.ext.routeviewer.model;
+
+import dev.relism.extension.RouteEvent;
+
+import java.util.*;
+
+/**
+ * Accumulates {@link RouteEvent}s at boot time and organizes them into an
+ * ordered list of {@link RouterNode}s for rendering.
+ *
+ *
Thread-safety: events are emitted sequentially at registration time
+ * (single-threaded boot), so no synchronization is needed here.
+ */
+public class RouteGraph {
+
+ /** Events in registration order, grouped by namespace. */
+ private final Map> byNamespace = new LinkedHashMap<>();
+ /** Namespace → routerType, filled on first event for each namespace. */
+ private final Map routerTypes = new LinkedHashMap<>();
+
+ /** Called once per route by the {@link dev.relism.extension.RouteListener}. */
+ public void add(RouteEvent event) {
+ routerTypes.putIfAbsent(event.namespace(), event.routerType());
+ byNamespace
+ .computeIfAbsent(event.namespace(), k -> new ArrayList<>())
+ .add(RouteRecord.from(event));
+ }
+
+ /**
+ * Returns the route graph as an ordered list of {@link RouterNode}s,
+ * sorted from shortest namespace to longest (root first, deepest last).
+ */
+ public List nodes() {
+ return byNamespace.entrySet().stream()
+ .sorted(Comparator.comparingInt(e -> e.getKey().length()))
+ .map(e -> new RouterNode(e.getKey(), routerTypes.get(e.getKey()), List.copyOf(e.getValue())))
+ .toList();
+ }
+
+ /** Total number of registered routes across all routers. */
+ public int totalRoutes() {
+ return byNamespace.values().stream().mapToInt(List::size).sum();
+ }
+}
diff --git a/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouteRecord.java b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouteRecord.java
new file mode 100644
index 0000000..34b6691
--- /dev/null
+++ b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouteRecord.java
@@ -0,0 +1,118 @@
+package dev.relism.ext.routeviewer.model;
+
+import dev.relism.extension.RouteEvent;
+import dev.relism.routing.Middleware;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Enriched snapshot of a single registered route.
+ *
+ *
Built once at registration time from a {@link RouteEvent}.
+ * All expensive operations (superclass traversal, annotation reading)
+ * happen here — never on the request hot-path.
+ *
+ * @param event the raw event emitted by the Flash core
+ * @param abstractionChain handler class hierarchy, outermost first, stopping before
+ * {@code RequestHandler} (e.g. {@code ["EditPostPageHandler", "HtmlHandler"]}).
+ * Empty for anonymous lambda handlers.
+ * @param pointcuts semantic annotations declared on the handler class hierarchy,
+ * used as declarative pointcut descriptors
+ * @param middlewareNames cleaned simple class names of the middleware chain, outermost first
+ */
+public record RouteRecord(
+ RouteEvent event,
+ List abstractionChain,
+ List pointcuts,
+ List middlewareNames
+) {
+
+ /** The root class we stop at (exclusive) — always implied, never shown. */
+ private static final String ROOT_HANDLER = "RequestHandler";
+
+ /** Builds a {@code RouteRecord} from a raw {@link RouteEvent}. */
+ public static RouteRecord from(RouteEvent event) {
+ return new RouteRecord(
+ event,
+ buildAbstractionChain(event.handlerClass()),
+ buildPointcuts(event.handlerClass()),
+ buildMiddlewareNames(event.middlewareChain())
+ );
+ }
+
+ // ── Builders ──────────────────────────────────────────────────────────────
+
+ /**
+ * Walks the superclass chain, stopping before {@code RequestHandler}.
+ * {@code RequestHandler} is the universal root — showing it adds no information.
+ */
+ private static List buildAbstractionChain(Class> cls) {
+ if (cls == null) return List.of();
+ List chain = new ArrayList<>();
+ Class> c = cls;
+ while (c != null && !c.equals(Object.class)) {
+ if (ROOT_HANDLER.equals(c.getSimpleName())) break;
+ chain.add(c.getSimpleName());
+ c = c.getSuperclass();
+ }
+ return List.copyOf(chain);
+ }
+
+ private static List buildPointcuts(Class> cls) {
+ if (cls == null) return List.of();
+ List pointcuts = new ArrayList<>();
+ Class> c = cls;
+ while (c != null && !c.equals(Object.class)) {
+ if (ROOT_HANDLER.equals(c.getSimpleName())) break;
+ for (Annotation ann : c.getDeclaredAnnotations()) {
+ String name = ann.annotationType().getSimpleName();
+ if (!name.equals("Route") && !name.equals("Override"))
+ pointcuts.add(formatAnnotation(ann));
+ }
+ c = c.getSuperclass();
+ }
+ return List.copyOf(pointcuts);
+ }
+
+ /**
+ * Strips the synthetic lambda suffix ({@code $$Lambda/0x...}) from class names
+ * so that {@code OidcMiddleware$$Lambda/0x0000019c381f} becomes {@code OidcMiddleware}.
+ */
+ private static List buildMiddlewareNames(List> chain) {
+ List names = new ArrayList<>(chain.size());
+ for (Class extends Middleware> cls : chain) names.add(cleanName(cls.getSimpleName()));
+ return List.copyOf(names);
+ }
+
+ private static String cleanName(String simpleName) {
+ int dollar = simpleName.indexOf("$$");
+ return dollar >= 0 ? simpleName.substring(0, dollar) : simpleName;
+ }
+
+ /**
+ * Formats an annotation for display.
+ *
+ *
Marker annotations → {@code @Name}
+ *
{@code String} value → {@code @Name(value)}
+ *
{@code String[]} value → {@code @Name(a, b)}
+ *
Any other value type (annotation arrays, class refs, etc.) → {@code @Name}
+ * — avoids ugly {@code [Ldev.relism...;@hash} output
+ *
+ */
+ private static String formatAnnotation(Annotation ann) {
+ try {
+ Object value = ann.annotationType().getMethod("value").invoke(ann);
+ String v;
+ if (value instanceof String s) v = s;
+ else if (value instanceof String[] arr) v = String.join(", ", arr);
+ else return "@" + ann.annotationType().getSimpleName(); // complex type — skip value
+ return "@" + ann.annotationType().getSimpleName() + "(" + v + ")";
+ } catch (NoSuchMethodException ignored) {
+ return "@" + ann.annotationType().getSimpleName();
+ } catch (Exception e) {
+ return "@" + ann.annotationType().getSimpleName();
+ }
+ }
+}
diff --git a/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouterNode.java b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouterNode.java
new file mode 100644
index 0000000..eabef4c
--- /dev/null
+++ b/flash-extensions/flash-ext-routeviewer/src/main/java/dev/relism/ext/routeviewer/model/RouterNode.java
@@ -0,0 +1,27 @@
+package dev.relism.ext.routeviewer.model;
+
+import java.util.List;
+
+/**
+ * A node in the route graph representing a single router instance.
+ *
+ *
>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?di(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?di(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=v1.exec(e))?new je(t[1],t[2],t[3],1):(t=w1.exec(e))?new je(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=x1.exec(e))?di(t[1],t[2],t[3],t[4]):(t=S1.exec(e))?di(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=E1.exec(e))?Rf(t[1],t[2]/100,t[3]/100,1):(t=_1.exec(e))?Rf(t[1],t[2]/100,t[3]/100,t[4]):Pf.hasOwnProperty(e)?zf(Pf[e]):e==="transparent"?new je(NaN,NaN,NaN,0):null}function zf(e){return new je(e>>16&255,e>>8&255,e&255,1)}function di(e,t,n,r){return r<=0&&(e=t=n=NaN),new je(e,t,n,r)}function N1(e){return e instanceof Ho||(e=zn(e)),e?(e=e.rgb(),new je(e.r,e.g,e.b,e.opacity)):new je}function Du(e,t,n,r){return arguments.length===1?N1(e):new je(e,t,n,r??1)}function je(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ua(je,Du,fg(Ho,{brighter(e){return e=e==null?fs:Math.pow(fs,e),new je(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?No:Math.pow(No,e),new je(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new je(kn(this.r),kn(this.g),kn(this.b),ds(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Lf,formatHex:Lf,formatHex8:M1,formatRgb:Af,toString:Af}));function Lf(){return`#${Sn(this.r)}${Sn(this.g)}${Sn(this.b)}`}function M1(){return`#${Sn(this.r)}${Sn(this.g)}${Sn(this.b)}${Sn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Af(){const e=ds(this.opacity);return`${e===1?"rgb(":"rgba("}${kn(this.r)}, ${kn(this.g)}, ${kn(this.b)}${e===1?")":`, ${e})`}`}function ds(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function kn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Sn(e){return e=kn(e),(e<16?"0":"")+e.toString(16)}function Rf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ct(e,t,n,r)}function dg(e){if(e instanceof ct)return new ct(e.h,e.s,e.l,e.opacity);if(e instanceof Ho||(e=zn(e)),!e)return new ct;if(e instanceof ct)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,l=i-o,u=(i+o)/2;return l?(t===i?s=(n-r)/l+(n0&&u<1?0:s,new ct(s,l,u,e.opacity)}function P1(e,t,n,r){return arguments.length===1?dg(e):new ct(e,t,n,r??1)}function ct(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ua(ct,P1,fg(Ho,{brighter(e){return e=e==null?fs:Math.pow(fs,e),new ct(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?No:Math.pow(No,e),new ct(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new je(Il(e>=240?e-240:e+120,o,r),Il(e,o,r),Il(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new ct($f(this.h),hi(this.s),hi(this.l),ds(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ds(this.opacity);return`${e===1?"hsl(":"hsla("}${$f(this.h)}, ${hi(this.s)*100}%, ${hi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function $f(e){return e=(e||0)%360,e<0?e+360:e}function hi(e){return Math.max(0,Math.min(1,e||0))}function Il(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Ya=e=>()=>e;function T1(e,t){return function(n){return e+n*t}}function I1(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function z1(e){return(e=+e)==1?hg:function(t,n){return n-t?I1(t,n,e):Ya(isNaN(t)?n:t)}}function hg(e,t){var n=t-e;return n?T1(e,n):Ya(isNaN(e)?t:e)}const hs=function e(t){var n=z1(t);function r(o,i){var s=n((o=Du(o)).r,(i=Du(i)).r),l=n(o.g,i.g),u=n(o.b,i.b),a=hg(o.opacity,i.opacity);return function(d){return o.r=s(d),o.g=l(d),o.b=u(d),o.opacity=a(d),o+""}}return r.gamma=e,r}(1);function L1(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;on&&(i=t.slice(n,i),l[s]?l[s]+=i:l[++s]=i),(r=r[0])===(o=o[0])?l[s]?l[s]+=o:l[++s]=o:(l[++s]=null,u.push({i:s,x:wt(r,o)})),n=zl.lastIndex;return n180?d+=360:d-a>180&&(a+=360),f.push({i:c.push(o(c)+"rotate(",null,r)-2,x:wt(a,d)})):d&&c.push(o(c)+"rotate("+d+r)}function l(a,d,c,f){a!==d?f.push({i:c.push(o(c)+"skewX(",null,r)-2,x:wt(a,d)}):d&&c.push(o(c)+"skewX("+d+r)}function u(a,d,c,f,m,y){if(a!==c||d!==f){var w=m.push(o(m)+"scale(",null,",",null,")");y.push({i:w-4,x:wt(a,c)},{i:w-2,x:wt(d,f)})}else(c!==1||f!==1)&&m.push(o(m)+"scale("+c+","+f+")")}return function(a,d){var c=[],f=[];return a=e(a),d=e(d),i(a.translateX,a.translateY,d.translateX,d.translateY,c,f),s(a.rotate,d.rotate,c,f),l(a.skewX,d.skewX,c,f),u(a.scaleX,a.scaleY,d.scaleX,d.scaleY,c,f),a=d=null,function(m){for(var y=-1,w=f.length,x;++y=0&&e._call.call(void 0,t),e=e._next;--vr}function Of(){Ln=(gs=Po.now())+Vs,vr=Qr=0;try{X1()}finally{vr=0,G1(),Ln=0}}function Q1(){var e=Po.now(),t=e-gs;t>yg&&(Vs-=t,gs=e)}function G1(){for(var e,t=ps,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ps=n);Gr=e,ju(r)}function ju(e){if(!vr){Qr&&(Qr=clearTimeout(Qr));var t=e-Ln;t>24?(e<1/0&&(Qr=setTimeout(Of,e-Po.now()-Vs)),br&&(br=clearInterval(br))):(br||(gs=Po.now(),br=setInterval(Q1,yg)),vr=1,vg(Of))}}function jf(e,t,n){var r=new ms;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var K1=js("start","end","cancel","interrupt"),Z1=[],xg=0,Hf=1,Hu=2,Fi=3,Vf=4,Vu=5,Oi=6;function bs(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;q1(e,n,{name:t,index:r,group:o,on:K1,tween:Z1,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:xg})}function Qa(e,t){var n=mt(e,t);if(n.state>xg)throw new Error("too late; already scheduled");return n}function Ct(e,t){var n=mt(e,t);if(n.state>Fi)throw new Error("too late; already running");return n}function mt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function q1(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=wg(i,0,n.time);function i(a){n.state=Hf,n.timer.restart(s,n.delay,n.time),n.delay<=a&&s(a-n.delay)}function s(a){var d,c,f,m;if(n.state!==Hf)return u();for(d in r)if(m=r[d],m.name===n.name){if(m.state===Fi)return jf(s);m.state===Vf?(m.state=Oi,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[d]):+dHu&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function PS(e,t,n){var r,o,i=MS(t)?Qa:Ct;return function(){var s=i(this,e),l=s.on;l!==r&&(o=(r=l).copy()).on(t,n),s.on=o}}function TS(e,t){var n=this._id;return arguments.length<2?mt(this.node(),n).on.on(e):this.each(PS(n,e,t))}function IS(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function zS(){return this.on("end.remove",IS(this._id))}function LS(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ba(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s()=>e;function rE(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Lt(e,t,n){this.k=e,this.x=t,this.y=n}Lt.prototype={constructor:Lt,scale:function(e){return e===1?this:new Lt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Lt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Bs=new Lt(1,0,0);kg.prototype=Lt.prototype;function kg(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Bs;return e.__zoom}function Ll(e){e.stopImmediatePropagation()}function Br(e){e.preventDefault(),e.stopImmediatePropagation()}function oE(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function iE(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function bf(){return this.__zoom||Bs}function sE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function lE(){return navigator.maxTouchPoints||"ontouchstart"in this}function uE(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Cg(){var e=oE,t=iE,n=uE,r=sE,o=lE,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],l=250,u=Di,a=js("start","zoom","end"),d,c,f,m=500,y=150,w=0,x=10;function h(C){C.property("__zoom",bf).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",j).filter(o).on("touchstart.zoom",z).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}h.transform=function(C,A,I,D){var k=C.selection?C.selection():C;k.property("__zoom",bf),C!==k?E(C,A,I,D):k.interrupt().each(function(){_(this,arguments).event(D).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},h.scaleBy=function(C,A,I,D){h.scaleTo(C,function(){var k=this.__zoom.k,S=typeof A=="function"?A.apply(this,arguments):A;return k*S},I,D)},h.scaleTo=function(C,A,I,D){h.transform(C,function(){var k=t.apply(this,arguments),S=this.__zoom,T=I==null?v(k):typeof I=="function"?I.apply(this,arguments):I,O=S.invert(T),F=typeof A=="function"?A.apply(this,arguments):A;return n(p(g(S,F),T,O),k,s)},I,D)},h.translateBy=function(C,A,I,D){h.transform(C,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),s)},null,D)},h.translateTo=function(C,A,I,D,k){h.transform(C,function(){var S=t.apply(this,arguments),T=this.__zoom,O=D==null?v(S):typeof D=="function"?D.apply(this,arguments):D;return n(Bs.translate(O[0],O[1]).scale(T.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof I=="function"?-I.apply(this,arguments):-I),S,s)},D,k)};function g(C,A){return A=Math.max(i[0],Math.min(i[1],A)),A===C.k?C:new Lt(A,C.x,C.y)}function p(C,A,I){var D=A[0]-I[0]*C.k,k=A[1]-I[1]*C.k;return D===C.x&&k===C.y?C:new Lt(C.k,D,k)}function v(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function E(C,A,I,D){C.on("start.zoom",function(){_(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(D).end()}).tween("zoom",function(){var k=this,S=arguments,T=_(k,S).event(D),O=t.apply(k,S),F=I==null?v(O):typeof I=="function"?I.apply(k,S):I,W=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),V=k.__zoom,U=typeof A=="function"?A.apply(k,S):A,Y=u(V.invert(F).concat(W/V.k),U.invert(F).concat(W/U.k));return function(Q){if(Q===1)Q=U;else{var B=Y(Q),K=W/B[2];Q=new Lt(K,F[0]-B[0]*K,F[1]-B[1]*K)}T.zoom(null,Q)}})}function _(C,A,I){return!I&&C.__zooming||new N(C,A)}function N(C,A){this.that=C,this.args=A,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,A),this.taps=0}N.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,A){return this.mouse&&C!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var A=Ye(this.that).datum();a.call(C,this.that,new rE(C,{sourceEvent:this.sourceEvent,target:h,transform:this.that.__zoom,dispatch:a}),A)}};function P(C,...A){if(!e.apply(this,arguments))return;var I=_(this,A).event(C),D=this.__zoom,k=Math.max(i[0],Math.min(i[1],D.k*Math.pow(2,r.apply(this,arguments)))),S=ut(C);if(I.wheel)(I.mouse[0][0]!==S[0]||I.mouse[0][1]!==S[1])&&(I.mouse[1]=D.invert(I.mouse[0]=S)),clearTimeout(I.wheel);else{if(D.k===k)return;I.mouse=[S,D.invert(S)],ji(this),I.start()}Br(C),I.wheel=setTimeout(T,y),I.zoom("mouse",n(p(g(D,k),I.mouse[0],I.mouse[1]),I.extent,s));function T(){I.wheel=null,I.end()}}function L(C,...A){if(f||!e.apply(this,arguments))return;var I=C.currentTarget,D=_(this,A,!0).event(C),k=Ye(C.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",W,!0),S=ut(C,I),T=C.clientX,O=C.clientY;ug(C.view),Ll(C),D.mouse=[S,this.__zoom.invert(S)],ji(this),D.start();function F(V){if(Br(V),!D.moved){var U=V.clientX-T,Y=V.clientY-O;D.moved=U*U+Y*Y>w}D.event(V).zoom("mouse",n(p(D.that.__zoom,D.mouse[0]=ut(V,I),D.mouse[1]),D.extent,s))}function W(V){k.on("mousemove.zoom mouseup.zoom",null),ag(V.view,D.moved),Br(V),D.event(V).end()}}function j(C,...A){if(e.apply(this,arguments)){var I=this.__zoom,D=ut(C.changedTouches?C.changedTouches[0]:C,this),k=I.invert(D),S=I.k*(C.shiftKey?.5:2),T=n(p(g(I,S),D,k),t.apply(this,A),s);Br(C),l>0?Ye(this).transition().duration(l).call(E,T,D,C):Ye(this).call(h.transform,T,D,C)}}function z(C,...A){if(e.apply(this,arguments)){var I=C.touches,D=I.length,k=_(this,A,C.changedTouches.length===D).event(C),S,T,O,F;for(Ll(C),T=0;T"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},To=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ng=["Enter"," ","Escape"],Mg={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var wr;(function(e){e.Strict="strict",e.Loose="loose"})(wr||(wr={}));var Cn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Cn||(Cn={}));var Io;(function(e){e.Partial="partial",e.Full="full"})(Io||(Io={}));const Pg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Gt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Gt||(Gt={}));var xr;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(xr||(xr={}));var G;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(G||(G={}));const Bf={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top};function Tg(e){return e===null?null:e?"valid":"invalid"}const Ig=e=>"id"in e&&"source"in e&&"target"in e,aE=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ka=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Vo=(e,t=[0,0])=>{const{width:n,height:r}=Ht(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},zg=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let s=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(o):Ka(o)?o:t.nodeLookup.get(o.id));const l=s?ys(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Ws(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Us(n)},bo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=Ws(n,ys(o)),r=!0)}),r?Us(n):{x:0,y:0,width:0,height:0}},Za=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const l={...Wo(t,[n,r,o]),width:t.width/o,height:t.height/o},u=[];for(const a of e.values()){const{measured:d,selectable:c=!0,hidden:f=!1}=a;if(s&&!c||f)continue;const m=d.width??a.width??a.initialWidth??null,y=d.height??a.height??a.initialHeight??null,w=zo(l,Er(a)),x=(m??0)*(y??0),h=i&&w>0;(!a.internals.handleBounds||h||w>=x||a.dragging)&&u.push(a)}return u},cE=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function fE(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function dE({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const l=fE(e,s),u=bo(l),a=Ys(u,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(a,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Lg({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),l=s.parentId?n.get(s.parentId):void 0,{x:u,y:a}=l?l.internals.positionAbsolute:{x:0,y:0},d=s.origin??r;let c=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!l)i==null||i("005",kt.error005());else{const m=l.measured.width,y=l.measured.height;m&&y&&(c=[[u,a],[u+m,a+y]])}else l&&_r(s.extent)&&(c=[[s.extent[0][0]+u,s.extent[0][1]+a],[s.extent[1][0]+u,s.extent[1][1]+a]]);const f=_r(c)?An(t,c,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",kt.error015())),{position:{x:f.x-u+(s.measured.width??0)*d[0],y:f.y-a+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function hE({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const m=i.has(f.id),y=!m&&f.parentId&&s.find(w=>w.id===f.parentId);(m||y)&&s.push(f)}const l=new Set(t.map(f=>f.id)),u=r.filter(f=>f.deletable!==!1),d=cE(s,u);for(const f of u)l.has(f.id)&&!d.find(y=>y.id===f.id)&&d.push(f);if(!o)return{edges:d,nodes:s};const c=await o({nodes:s,edges:d});return typeof c=="boolean"?c?{edges:d,nodes:s}:{edges:[],nodes:[]}:c}const Sr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),An=(e={x:0,y:0},t,n)=>({x:Sr(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Sr(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ag(e,t,n){const{width:r,height:o}=Ht(n),{x:i,y:s}=n.internals.positionAbsolute;return An(e,[[i,s],[i+r,s+o]],t)}const Wf=(e,t,n)=>en?-Sr(Math.abs(e-n),1,t)/t:0,Rg=(e,t,n=15,r=40)=>{const o=Wf(e.x,r,t.width-r)*n,i=Wf(e.y,r,t.height-r)*n;return[o,i]},Ws=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),bu=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Us=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Er=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Ka(e)?e.internals.positionAbsolute:Vo(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},ys=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Ka(e)?e.internals.positionAbsolute:Vo(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},$g=(e,t)=>Us(Ws(bu(e),bu(t))),zo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Uf=e=>ft(e.width)&&ft(e.height)&&ft(e.x)&&ft(e.y),ft=e=>!isNaN(e)&&isFinite(e),pE=(e,t)=>{},Bo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Wo=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?Bo(l,s):l},vs=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function jn(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gE(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=jn(e,n),o=jn(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=jn(e.top??e.y??0,n),o=jn(e.bottom??e.y??0,n),i=jn(e.left??e.x??0,t),s=jn(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function mE(e,t,n,r,o,i){const{x:s,y:l}=vs(e,[t,n,r]),{x:u,y:a}=vs({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=o-u,c=i-a;return{left:Math.floor(s),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(c)}}const Ys=(e,t,n,r,o,i)=>{const s=gE(i,t,n),l=(t-s.x)/e.width,u=(n-s.y)/e.height,a=Math.min(l,u),d=Sr(a,r,o),c=e.x+e.width/2,f=e.y+e.height/2,m=t/2-c*d,y=n/2-f*d,w=mE(e,m,y,d,t,n),x={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:m-x.left+x.right,y:y-x.top+x.bottom,zoom:d}},Lo=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function _r(e){return e!=null&&e!=="parent"}function Ht(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Dg(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Fg(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const l=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function Yf(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function yE(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function vE(e){return{...Mg,...e||{}}}function so(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=dt(e),l=Wo({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:u,y:a}=n?Bo(l,t):l;return{xSnapped:u,ySnapped:a,...l}}const qa=e=>({width:e.offsetWidth,height:e.offsetHeight}),Og=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},wE=["INPUT","SELECT","TEXTAREA"];function jg(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:wE.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Hg=e=>"clientX"in e,dt=(e,t)=>{var i,s;const n=Hg(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},Xf=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const l=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...qa(s)}})};function Vg({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:l}){const u=e*.125+o*.375+s*.375+n*.125,a=t*.125+i*.375+l*.375+r*.125,d=Math.abs(u-e),c=Math.abs(a-t);return[u,a,d,c]}function mi(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Qf({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case G.Left:return[t-mi(t-r,i),n];case G.Right:return[t+mi(r-t,i),n];case G.Top:return[t,n-mi(n-o,i)];case G.Bottom:return[t,n+mi(o-n,i)]}}function bg({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top,curvature:s=.25}){const[l,u]=Qf({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[a,d]=Qf({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[c,f,m,y]=Vg({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:u,targetControlX:a,targetControlY:d});return[`M${e},${t} C${l},${u} ${a},${d} ${r},${o}`,c,f,m,y]}function Bg({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n0}const EE=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,_E=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),kE=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||EE;let o;return Ig(e)?o={...e}:o={...e,id:r(e)},_E(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function Wg({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,l]=Bg({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,l]}const Gf={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},CE=({source:e,sourcePosition:t=G.Bottom,target:n})=>t===G.Left||t===G.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function NE({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:r=G.Top,center:o,offset:i,stepPosition:s}){const l=Gf[t],u=Gf[r],a={x:e.x+l.x*i,y:e.y+l.y*i},d={x:n.x+u.x*i,y:n.y+u.y*i},c=CE({source:a,sourcePosition:t,target:d}),f=c.x!==0?"x":"y",m=c[f];let y=[],w,x;const h={x:0,y:0},g={x:0,y:0},[,,p,v]=Bg({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[f]*u[f]===-1){f==="x"?(w=o.x??a.x+(d.x-a.x)*s,x=o.y??(a.y+d.y)/2):(w=o.x??(a.x+d.x)/2,x=o.y??a.y+(d.y-a.y)*s);const _=[{x:w,y:a.y},{x:w,y:d.y}],N=[{x:a.x,y:x},{x:d.x,y:x}];l[f]===m?y=f==="x"?_:N:y=f==="x"?N:_}else{const _=[{x:a.x,y:d.y}],N=[{x:d.x,y:a.y}];if(f==="x"?y=l.x===m?N:_:y=l.y===m?_:N,t===r){const R=Math.abs(e[f]-n[f]);if(R<=i){const H=Math.min(i-1,i-R);l[f]===m?h[f]=(a[f]>e[f]?-1:1)*H:g[f]=(d[f]>n[f]?-1:1)*H}}if(t!==r){const R=f==="x"?"y":"x",H=l[f]===u[R],C=a[R]>d[R],A=a[R]=z?(w=(P.x+L.x)/2,x=y[0].y):(w=y[0].x,x=(P.y+L.y)/2)}return[[e,{x:a.x+h.x,y:a.y+h.y},...y,{x:d.x+g.x,y:d.y+g.y},n],w,x,p,v]}function ME(e,t,n,r){const o=Math.min(Kf(e,t)/2,Kf(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const a=e.x{let v="";return p>0&&pn.id===t):e[0])||null}function Wu(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function TE(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,l)=>([l.markerStart||r,l.markerEnd||o].forEach(u=>{if(u&&typeof u=="object"){const a=Wu(u,t);i.has(a)||(s.push({id:a,color:u.color||n,...u}),i.add(a))}}),s),[]).sort((s,l)=>s.id.localeCompare(l.id))}const Ug=1e3,IE=10,Ja={nodeOrigin:[0,0],nodeExtent:To,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},zE={...Ja,checkEquality:!0};function ec(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function LE(e,t,n){const r=ec(Ja,n);for(const o of e.values())if(o.parentId)nc(o,e,t,r);else{const i=Vo(o,r.nodeOrigin),s=_r(o.extent)?o.extent:r.nodeExtent,l=An(i,s,Ht(o));o.internals.positionAbsolute=l}}function AE(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function tc(e){return e==="manual"}function Uu(e,t,n,r={}){var a,d;const o=ec(zE,r),i={i:0},s=new Map(t),l=o!=null&&o.elevateNodesOnSelect&&!tc(o.zIndexMode)?Ug:0;let u=e.length>0;t.clear(),n.clear();for(const c of e){let f=s.get(c.id);if(o.checkEquality&&c===(f==null?void 0:f.internals.userNode))t.set(c.id,f);else{const m=Vo(c,o.nodeOrigin),y=_r(c.extent)?c.extent:o.nodeExtent,w=An(m,y,Ht(c));f={...o.defaults,...c,measured:{width:(a=c.measured)==null?void 0:a.width,height:(d=c.measured)==null?void 0:d.height},internals:{positionAbsolute:w,handleBounds:AE(c,f),z:Yg(c,l,o.zIndexMode),userNode:c}},t.set(c.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(u=!1),c.parentId&&nc(f,t,n,r,i)}return u}function RE(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function nc(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:l,zIndexMode:u}=ec(Ja,r),a=e.parentId,d=t.get(a);if(!d){console.warn(`Parent node ${a} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}RE(e,n),o&&!d.parentId&&d.internals.rootParentIndex===void 0&&u==="auto"&&(d.internals.rootParentIndex=++o.i,d.internals.z=d.internals.z+o.i*IE),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);const c=i&&!tc(u)?Ug:0,{x:f,y:m,z:y}=$E(e,d,s,l,c,u),{positionAbsolute:w}=e.internals,x=f!==w.x||m!==w.y;(x||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:m}:w,z:y}})}function Yg(e,t,n){const r=ft(e.zIndex)?e.zIndex:0;return tc(n)?r:r+(e.selected?t:0)}function $E(e,t,n,r,o,i){const{x:s,y:l}=t.internals.positionAbsolute,u=Ht(e),a=Vo(e,n),d=_r(e.extent)?An(a,e.extent,u):a;let c=An({x:s+d.x,y:l+d.y},r,u);e.extent==="parent"&&(c=Ag(c,u,t));const f=Yg(e,o,i),m=t.internals.z??0;return{x:c.x,y:c.y,z:m>=f?m+1:f}}function rc(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const l of e){const u=t.get(l.parentId);if(!u)continue;const a=((s=i.get(l.parentId))==null?void 0:s.expandedRect)??Er(u),d=$g(a,l.rect);i.set(l.parentId,{expandedRect:d,parent:u})}return i.size>0&&i.forEach(({expandedRect:l,parent:u},a)=>{var p;const d=u.internals.positionAbsolute,c=Ht(u),f=u.origin??r,m=l.x0||y>0||h||g)&&(o.push({id:a,type:"position",position:{x:u.position.x-m+h,y:u.position.y-y+g}}),(p=n.get(a))==null||p.forEach(v=>{e.some(E=>E.id===v.id)||o.push({id:v.id,type:"position",position:{x:v.position.x+m,y:v.position.y+y}})})),(c.width0){const m=rc(f,t,n,o);a.push(...m)}return{changes:a,updatedInternals:u}}async function FE({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r),l=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(l)}function ed(e,t,n,r,o,i){let s=o;const l=r.get(s)||new Map;r.set(s,l.set(n,t)),s=`${o}-${e}`;const u=r.get(s)||new Map;if(r.set(s,u.set(n,t)),i){s=`${o}-${e}-${i}`;const a=r.get(s)||new Map;r.set(s,a.set(n,t))}}function Xg(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:l=null}=r,u={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:l},a=`${o}-${s}--${i}-${l}`,d=`${i}-${l}--${o}-${s}`;ed("source",u,d,e,o,s),ed("target",u,a,e,i,l),t.set(r.id,r)}}function Qg(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Qg(n,t):!1}function td(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function OE(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!Qg(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const l=e.get(i);l&&o.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return o}function Al({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,l,u;const o=[];for(const[a,d]of t){const c=(s=n.get(a))==null?void 0:s.internals.userNode;c&&o.push({...c,position:d.position,dragging:r})}if(!e)return[o[0],o];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((u=t.get(e))==null?void 0:u.position)||i.position,dragging:r}:o[0],o]}function jE({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=Bo(i,t);return{x:s.x-i.x,y:s.y-i.y}}function HE({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,l=new Map,u=!1,a={x:0,y:0},d=null,c=!1,f=null,m=!1,y=!1,w=null;function x({noDragClassName:g,handleSelector:p,domNode:v,isSelectable:E,nodeId:_,nodeClickDistance:N=0}){f=Ye(v);function P({x:R,y:H}){const{nodeLookup:C,nodeExtent:A,snapGrid:I,snapToGrid:D,nodeOrigin:k,onNodeDrag:S,onSelectionDrag:T,onError:O,updateNodePositions:F}=t();i={x:R,y:H};let W=!1;const V=l.size>1,U=V&&A?bu(bo(l)):null,Y=V&&D?jE({dragItems:l,snapGrid:I,x:R,y:H}):null;for(const[Q,B]of l){if(!C.has(Q))continue;let K={x:R-B.distance.x,y:H-B.distance.y};D&&(K=Y?{x:Math.round(K.x+Y.x),y:Math.round(K.y+Y.y)}:Bo(K,I));let ee=null;if(V&&A&&!B.extent&&U){const{positionAbsolute:Z}=B.internals,ie=Z.x-U.x+A[0][0],ue=Z.x+B.measured.width-U.x2+A[1][0],oe=Z.y-U.y+A[0][1],Pe=Z.y+B.measured.height-U.y2+A[1][1];ee=[[ie,oe],[ue,Pe]]}const{position:J,positionAbsolute:q}=Lg({nodeId:Q,nextPosition:K,nodeLookup:C,nodeExtent:ee||A,nodeOrigin:k,onError:O});W=W||B.position.x!==J.x||B.position.y!==J.y,B.position=J,B.internals.positionAbsolute=q}if(y=y||W,!!W&&(F(l,!0),w&&(r||S||!_&&T))){const[Q,B]=Al({nodeId:_,dragItems:l,nodeLookup:C});r==null||r(w,l,Q,B),S==null||S(w,Q,B),_||T==null||T(w,B)}}async function L(){if(!d)return;const{transform:R,panBy:H,autoPanSpeed:C,autoPanOnNodeDrag:A}=t();if(!A){u=!1,cancelAnimationFrame(s);return}const[I,D]=Rg(a,d,C);(I!==0||D!==0)&&(i.x=(i.x??0)-I/R[2],i.y=(i.y??0)-D/R[2],await H({x:I,y:D})&&P(i)),s=requestAnimationFrame(L)}function j(R){var V;const{nodeLookup:H,multiSelectionActive:C,nodesDraggable:A,transform:I,snapGrid:D,snapToGrid:k,selectNodesOnDrag:S,onNodeDragStart:T,onSelectionDragStart:O,unselectNodesAndEdges:F}=t();c=!0,(!S||!E)&&!C&&_&&((V=H.get(_))!=null&&V.selected||F()),E&&S&&_&&(e==null||e(_));const W=so(R.sourceEvent,{transform:I,snapGrid:D,snapToGrid:k,containerBounds:d});if(i=W,l=OE(H,A,W,_),l.size>0&&(n||T||!_&&O)){const[U,Y]=Al({nodeId:_,dragItems:l,nodeLookup:H});n==null||n(R.sourceEvent,l,U,Y),T==null||T(R.sourceEvent,U,Y),_||O==null||O(R.sourceEvent,Y)}}const z=cg().clickDistance(N).on("start",R=>{const{domNode:H,nodeDragThreshold:C,transform:A,snapGrid:I,snapToGrid:D}=t();d=(H==null?void 0:H.getBoundingClientRect())||null,m=!1,y=!1,w=R.sourceEvent,C===0&&j(R),i=so(R.sourceEvent,{transform:A,snapGrid:I,snapToGrid:D,containerBounds:d}),a=dt(R.sourceEvent,d)}).on("drag",R=>{const{autoPanOnNodeDrag:H,transform:C,snapGrid:A,snapToGrid:I,nodeDragThreshold:D,nodeLookup:k}=t(),S=so(R.sourceEvent,{transform:C,snapGrid:A,snapToGrid:I,containerBounds:d});if(w=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||_&&!k.has(_))&&(m=!0),!m){if(!u&&H&&c&&(u=!0,L()),!c){const T=dt(R.sourceEvent,d),O=T.x-a.x,F=T.y-a.y;Math.sqrt(O*O+F*F)>D&&j(R)}(i.x!==S.xSnapped||i.y!==S.ySnapped)&&l&&c&&(a=dt(R.sourceEvent,d),P(S))}}).on("end",R=>{if(!(!c||m)&&(u=!1,c=!1,cancelAnimationFrame(s),l.size>0)){const{nodeLookup:H,updateNodePositions:C,onNodeDragStop:A,onSelectionDragStop:I}=t();if(y&&(C(l,!1),y=!1),o||A||!_&&I){const[D,k]=Al({nodeId:_,dragItems:l,nodeLookup:H,dragging:!1});o==null||o(R.sourceEvent,l,D,k),A==null||A(R.sourceEvent,D,k),_||I==null||I(R.sourceEvent,k)}}}).filter(R=>{const H=R.target;return!R.button&&(!g||!td(H,`.${g}`,v))&&(!p||td(H,p,v))});f.call(z)}function h(){f==null||f.on(".drag",null)}return{update:x,destroy:h}}function VE(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())zo(o,Er(i))>0&&r.push(i);return r}const bE=250;function BE(e,t,n,r){var l,u;let o=[],i=1/0;const s=VE(e,n,t+bE);for(const a of s){const d=[...((l=a.internals.handleBounds)==null?void 0:l.source)??[],...((u=a.internals.handleBounds)==null?void 0:u.target)??[]];for(const c of d){if(r.nodeId===c.nodeId&&r.type===c.type&&r.id===c.id)continue;const{x:f,y:m}=Rn(a,c,c.position,!0),y=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(m-e.y,2));y>t||(y1){const a=r.type==="source"?"target":"source";return o.find(d=>d.type===a)??o[0]}return o[0]}function Gg(e,t,n,r,o,i=!1){var a,d,c;const s=r.get(e);if(!s)return null;const l=o==="strict"?(a=s.internals.handleBounds)==null?void 0:a[t]:[...((d=s.internals.handleBounds)==null?void 0:d.source)??[],...((c=s.internals.handleBounds)==null?void 0:c.target)??[]],u=(n?l==null?void 0:l.find(f=>f.id===n):l==null?void 0:l[0])??null;return u&&i?{...u,...Rn(s,u,u.position,!0)}:u}function Kg(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function WE(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Zg=()=>!0;function UE(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:l,nodeLookup:u,lib:a,autoPanOnConnect:d,flowId:c,panBy:f,cancelConnection:m,onConnectStart:y,onConnect:w,onConnectEnd:x,isValidConnection:h=Zg,onReconnectEnd:g,updateConnection:p,getTransform:v,getFromHandle:E,autoPanSpeed:_,dragThreshold:N=1,handleDomNode:P}){const L=Og(e.target);let j=0,z;const{x:R,y:H}=dt(e),C=Kg(i,P),A=l==null?void 0:l.getBoundingClientRect();let I=!1;if(!A||!C)return;const D=Gg(o,C,r,u,t);if(!D)return;let k=dt(e,A),S=!1,T=null,O=!1,F=null;function W(){if(!d||!A)return;const[J,q]=Rg(k,A,_);f({x:J,y:q}),j=requestAnimationFrame(W)}const V={...D,nodeId:o,type:C,position:D.position},U=u.get(o);let Q={inProgress:!0,isValid:null,from:Rn(U,V,G.Left,!0),fromHandle:V,fromPosition:V.position,fromNode:U,to:k,toHandle:null,toPosition:Bf[V.position],toNode:null,pointer:k};function B(){I=!0,p(Q),y==null||y(e,{nodeId:o,handleId:r,handleType:C})}N===0&&B();function K(J){if(!I){const{x:Pe,y:Vt}=dt(J),Nt=Pe-R,pn=Vt-H;if(!(Nt*Nt+pn*pn>N*N))return;B()}if(!E()||!V){ee(J);return}const q=v();k=dt(J,A),z=BE(Wo(k,q,!1,[1,1]),n,u,V),S||(W(),S=!0);const Z=qg(J,{handle:z,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:h,doc:L,lib:a,flowId:c,nodeLookup:u});F=Z.handleDomNode,T=Z.connection,O=WE(!!z,Z.isValid);const ie=u.get(o),ue=ie?Rn(ie,V,G.Left,!0):Q.from,oe={...Q,from:ue,isValid:O,to:Z.toHandle&&O?vs({x:Z.toHandle.x,y:Z.toHandle.y},q):k,toHandle:Z.toHandle,toPosition:O&&Z.toHandle?Z.toHandle.position:Bf[V.position],toNode:Z.toHandle?u.get(Z.toHandle.nodeId):null,pointer:k};p(oe),Q=oe}function ee(J){if(!("touches"in J&&J.touches.length>0)){if(I){(z||F)&&T&&O&&(w==null||w(T));const{inProgress:q,...Z}=Q,ie={...Z,toPosition:Q.toHandle?Q.toPosition:null};x==null||x(J,ie),i&&(g==null||g(J,ie))}m(),cancelAnimationFrame(j),S=!1,O=!1,T=null,F=null,L.removeEventListener("mousemove",K),L.removeEventListener("mouseup",ee),L.removeEventListener("touchmove",K),L.removeEventListener("touchend",ee)}}L.addEventListener("mousemove",K),L.addEventListener("mouseup",ee),L.addEventListener("touchmove",K),L.addEventListener("touchend",ee)}function qg(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:l,flowId:u,isValidConnection:a=Zg,nodeLookup:d}){const c=i==="target",f=t?s.querySelector(`.${l}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y}=dt(e),w=s.elementFromPoint(m,y),x=w!=null&&w.classList.contains(`${l}-flow__handle`)?w:f,h={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const g=Kg(void 0,x),p=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),E=x.classList.contains("connectable"),_=x.classList.contains("connectableend");if(!p||!g)return h;const N={source:c?p:r,sourceHandle:c?v:o,target:c?r:p,targetHandle:c?o:v};h.connection=N;const L=E&&_&&(n===wr.Strict?c&&g==="source"||!c&&g==="target":p!==r||v!==o);h.isValid=L&&a(N),h.toHandle=Gg(p,g,v,d,n,!0)}return h}const Yu={onPointerDown:UE,isValid:qg};function YE({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Ye(e);function i({translateExtent:l,width:u,height:a,zoomStep:d=1,pannable:c=!0,zoomable:f=!0,inversePan:m=!1}){const y=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const v=n(),E=p.sourceEvent.ctrlKey&&Lo()?10:1,_=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,N=v[2]*Math.pow(2,_*E);t.scaleTo(N)};let w=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(w=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},h=p=>{const v=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const E=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],_=[E[0]-w[0],E[1]-w[1]];w=E;const N=r()*Math.max(v[2],Math.log(v[2]))*(m?-1:1),P={x:v[0]-_[0]*N,y:v[1]-_[1]*N},L=[[0,0],[u,a]];t.setViewportConstrained({x:P.x,y:P.y,zoom:v[2]},L,l)},g=Cg().on("start",x).on("zoom",c?h:null).on("zoom.wheel",f?y:null);o.call(g,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:ut}}const Xs=e=>({x:e.x,y:e.y,zoom:e.k}),Rl=({x:e,y:t,zoom:n})=>Bs.translate(e,t).scale(n),er=(e,t)=>e.target.closest(`.${t}`),Jg=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),XE=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,$l=(e,t=0,n=XE,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},em=e=>{const t=e.ctrlKey&&Lo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function QE({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:u,onPanZoomEnd:a}){return d=>{if(er(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(d.ctrlKey&&s){const x=ut(d),h=em(d),g=c*Math.pow(2,h);r.scaleTo(n,g,x,d);return}const f=d.deltaMode===1?20:1;let m=o===Cn.Vertical?0:d.deltaX*f,y=o===Cn.Horizontal?0:d.deltaY*f;!Lo()&&d.shiftKey&&o!==Cn.Vertical&&(m=d.deltaY*f,y=0),r.translateBy(n,-(m/c)*i,-(y/c)*i,{internal:!0});const w=Xs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(d,w),e.panScrollTimeout=setTimeout(()=>{a==null||a(d,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(d,w))}}function GE({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,l=er(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),s||l)return null;r.preventDefault(),n.call(this,r,o)}}function KE({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,l;if((i=r.sourceEvent)!=null&&i.internal)return;const o=Xs(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function ZE({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,l;e.usedRightMouseButton=!!(n&&Jg(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((l=i.sourceEvent)!=null&&l.internal)&&(o==null||o(i.sourceEvent,Xs(i.transform)))}}function qE({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var l;if(!((l=s.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&Jg(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const u=Xs(s.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,u)},n?150:0)}}}function JE({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:l,noPanClassName:u,lib:a,connectionInProgress:d}){return c=>{var x;const f=e||t,m=n&&c.ctrlKey,y=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(er(c,`${a}-flow__node`)||er(c,`${a}-flow__edge`)))return!0;if(!r&&!f&&!o&&!i&&!n||s||d&&!y||er(c,l)&&y||er(c,u)&&(!y||o&&y&&!e)||!n&&c.ctrlKey&&y)return!1;if(!n&&c.type==="touchstart"&&((x=c.touches)==null?void 0:x.length)>1)return c.preventDefault(),!1;if(!f&&!o&&!m&&y||!r&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(r)&&!r.includes(c.button)&&c.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||y)&&w}}function e_({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:l,onDraggingChange:u}){const a={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),c=Cg().scaleExtent([t,n]).translateExtent(r),f=Ye(e).call(c);g({x:o.x,y:o.y,zoom:Sr(o.zoom,t,n)},[[0,0],[d.width,d.height]],r);const m=f.on("wheel.zoom"),y=f.on("dblclick.zoom");c.wheelDelta(em);function w(z,R){return f?new Promise(H=>{c==null||c.interpolate((R==null?void 0:R.interpolate)==="linear"?io:Di).transform($l(f,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>H(!0)),z)}):Promise.resolve(!1)}function x({noWheelClassName:z,noPanClassName:R,onPaneContextMenu:H,userSelectionActive:C,panOnScroll:A,panOnDrag:I,panOnScrollMode:D,panOnScrollSpeed:k,preventScrolling:S,zoomOnPinch:T,zoomOnScroll:O,zoomOnDoubleClick:F,zoomActivationKeyPressed:W,lib:V,onTransformChange:U,connectionInProgress:Y,paneClickDistance:Q,selectionOnDrag:B}){C&&!a.isZoomingOrPanning&&h();const K=A&&!W&&!C;c.clickDistance(B?1/0:!ft(Q)||Q<0?0:Q);const ee=K?QE({zoomPanValues:a,noWheelClassName:z,d3Selection:f,d3Zoom:c,panOnScrollMode:D,panOnScrollSpeed:k,zoomOnPinch:T,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:l}):GE({noWheelClassName:z,preventScrolling:S,d3ZoomHandler:m});if(f.on("wheel.zoom",ee,{passive:!1}),!C){const q=KE({zoomPanValues:a,onDraggingChange:u,onPanZoomStart:s});c.on("start",q);const Z=ZE({zoomPanValues:a,panOnDrag:I,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:U});c.on("zoom",Z);const ie=qE({zoomPanValues:a,panOnDrag:I,panOnScroll:A,onPaneContextMenu:H,onPanZoomEnd:l,onDraggingChange:u});c.on("end",ie)}const J=JE({zoomActivationKeyPressed:W,panOnDrag:I,zoomOnScroll:O,panOnScroll:A,zoomOnDoubleClick:F,zoomOnPinch:T,userSelectionActive:C,noPanClassName:R,noWheelClassName:z,lib:V,connectionInProgress:Y});c.filter(J),F?f.on("dblclick.zoom",y):f.on("dblclick.zoom",null)}function h(){c.on("zoom",null)}async function g(z,R,H){const C=Rl(z),A=c==null?void 0:c.constrain()(C,R,H);return A&&await w(A),new Promise(I=>I(A))}async function p(z,R){const H=Rl(z);return await w(H,R),new Promise(C=>C(H))}function v(z){if(f){const R=Rl(z),H=f.property("__zoom");(H.k!==z.zoom||H.x!==z.x||H.y!==z.y)&&(c==null||c.transform(f,R,null,{sync:!0}))}}function E(){const z=f?kg(f.node()):{x:0,y:0,k:1};return{x:z.x,y:z.y,zoom:z.k}}function _(z,R){return f?new Promise(H=>{c==null||c.interpolate((R==null?void 0:R.interpolate)==="linear"?io:Di).scaleTo($l(f,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>H(!0)),z)}):Promise.resolve(!1)}function N(z,R){return f?new Promise(H=>{c==null||c.interpolate((R==null?void 0:R.interpolate)==="linear"?io:Di).scaleBy($l(f,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>H(!0)),z)}):Promise.resolve(!1)}function P(z){c==null||c.scaleExtent(z)}function L(z){c==null||c.translateExtent(z)}function j(z){const R=!ft(z)||z<0?0:z;c==null||c.clickDistance(R)}return{update:x,destroy:h,setViewport:p,setViewportConstrained:g,getViewport:E,scaleTo:_,scaleBy:N,setScaleExtent:P,setTranslateExtent:L,syncViewport:v,setClickDistance:j}}var kr;(function(e){e.Line="line",e.Handle="handle"})(kr||(kr={}));function t_({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,l=n-r,u=[s>0?1:s<0?-1:0,l>0?1:l<0?-1:0];return s&&o&&(u[0]=u[0]*-1),l&&i&&(u[1]=u[1]*-1),u}function nd(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Bt(e,t){return Math.max(0,t-e)}function Wt(e,t){return Math.max(0,e-t)}function yi(e,t,n){return Math.max(0,t-e,e-n)}function rd(e,t){return e?!t:t}function n_(e,t,n,r,o,i,s,l){let{affectsX:u,affectsY:a}=t;const{isHorizontal:d,isVertical:c}=t,f=d&&c,{xSnapped:m,ySnapped:y}=n,{minWidth:w,maxWidth:x,minHeight:h,maxHeight:g}=r,{x:p,y:v,width:E,height:_,aspectRatio:N}=e;let P=Math.floor(d?m-e.pointerX:0),L=Math.floor(c?y-e.pointerY:0);const j=E+(u?-P:P),z=_+(a?-L:L),R=-i[0]*E,H=-i[1]*_;let C=yi(j,w,x),A=yi(z,h,g);if(s){let k=0,S=0;u&&P<0?k=Bt(p+P+R,s[0][0]):!u&&P>0&&(k=Wt(p+j+R,s[1][0])),a&&L<0?S=Bt(v+L+H,s[0][1]):!a&&L>0&&(S=Wt(v+z+H,s[1][1])),C=Math.max(C,k),A=Math.max(A,S)}if(l){let k=0,S=0;u&&P>0?k=Wt(p+P,l[0][0]):!u&&P<0&&(k=Bt(p+j,l[1][0])),a&&L>0?S=Wt(v+L,l[0][1]):!a&&L<0&&(S=Bt(v+z,l[1][1])),C=Math.max(C,k),A=Math.max(A,S)}if(o){if(d){const k=yi(j/N,h,g)*N;if(C=Math.max(C,k),s){let S=0;!u&&!a||u&&!a&&f?S=Wt(v+H+j/N,s[1][1])*N:S=Bt(v+H+(u?P:-P)/N,s[0][1])*N,C=Math.max(C,S)}if(l){let S=0;!u&&!a||u&&!a&&f?S=Bt(v+j/N,l[1][1])*N:S=Wt(v+(u?P:-P)/N,l[0][1])*N,C=Math.max(C,S)}}if(c){const k=yi(z*N,w,x)/N;if(A=Math.max(A,k),s){let S=0;!u&&!a||a&&!u&&f?S=Wt(p+z*N+R,s[1][0])/N:S=Bt(p+(a?L:-L)*N+R,s[0][0])/N,A=Math.max(A,S)}if(l){let S=0;!u&&!a||a&&!u&&f?S=Bt(p+z*N,l[1][0])/N:S=Wt(p+(a?L:-L)*N,l[0][0])/N,A=Math.max(A,S)}}}L=L+(L<0?A:-A),P=P+(P<0?C:-C),o&&(f?j>z*N?L=(rd(u,a)?-P:P)/N:P=(rd(u,a)?-L:L)*N:d?(L=P/N,a=u):(P=L*N,u=a));const I=u?p+P:p,D=a?v+L:v;return{width:E+(u?-P:P),height:_+(a?-L:L),x:i[0]*P*(u?-1:1)+I,y:i[1]*L*(a?-1:1)+D}}const tm={width:0,height:0,x:0,y:0},r_={...tm,pointerX:0,pointerY:0,aspectRatio:1};function o_(e){return[[0,0],[e.measured.width,e.measured.height]]}function i_(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,l=n[0]*i,u=n[1]*s;return[[r-l,o-u],[r+i-l,o+s-u]]}function s_({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=Ye(e);let s={controlDirection:nd("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:a,boundaries:d,keepAspectRatio:c,resizeDirection:f,onResizeStart:m,onResize:y,onResizeEnd:w,shouldResize:x}){let h={...tm},g={...r_};s={boundaries:d,resizeDirection:f,keepAspectRatio:c,controlDirection:nd(a)};let p,v=null,E=[],_,N,P,L=!1;const j=cg().on("start",z=>{const{nodeLookup:R,transform:H,snapGrid:C,snapToGrid:A,nodeOrigin:I,paneDomNode:D}=n();if(p=R.get(t),!p)return;v=(D==null?void 0:D.getBoundingClientRect())??null;const{xSnapped:k,ySnapped:S}=so(z.sourceEvent,{transform:H,snapGrid:C,snapToGrid:A,containerBounds:v});h={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},g={...h,pointerX:k,pointerY:S,aspectRatio:h.width/h.height},_=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(_=R.get(p.parentId),N=_&&p.extent==="parent"?o_(_):void 0),E=[],P=void 0;for(const[T,O]of R)if(O.parentId===t&&(E.push({id:T,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const F=i_(O,p,O.origin??I);P?P=[[Math.min(F[0][0],P[0][0]),Math.min(F[0][1],P[0][1])],[Math.max(F[1][0],P[1][0]),Math.max(F[1][1],P[1][1])]]:P=F}m==null||m(z,{...h})}).on("drag",z=>{const{transform:R,snapGrid:H,snapToGrid:C,nodeOrigin:A}=n(),I=so(z.sourceEvent,{transform:R,snapGrid:H,snapToGrid:C,containerBounds:v}),D=[];if(!p)return;const{x:k,y:S,width:T,height:O}=h,F={},W=p.origin??A,{width:V,height:U,x:Y,y:Q}=n_(g,s.controlDirection,I,s.boundaries,s.keepAspectRatio,W,N,P),B=V!==T,K=U!==O,ee=Y!==k&&B,J=Q!==S&&K;if(!ee&&!J&&!B&&!K)return;if((ee||J||W[0]===1||W[1]===1)&&(F.x=ee?Y:h.x,F.y=J?Q:h.y,h.x=F.x,h.y=F.y,E.length>0)){const ue=Y-k,oe=Q-S;for(const Pe of E)Pe.position={x:Pe.position.x-ue+W[0]*(V-T),y:Pe.position.y-oe+W[1]*(U-O)},D.push(Pe)}if((B||K)&&(F.width=B&&(!s.resizeDirection||s.resizeDirection==="horizontal")?V:h.width,F.height=K&&(!s.resizeDirection||s.resizeDirection==="vertical")?U:h.height,h.width=F.width,h.height=F.height),_&&p.expandParent){const ue=W[0]*(F.width??0);F.x&&F.x{L&&(w==null||w(z,{...h}),o==null||o({...h}),L=!1)});i.call(j)}function u(){i.on(".drag",null)}return{update:l,destroy:u}}var nm={exports:{}},rm={},om={exports:{}},im={};/**
+ * @license React
+ * use-sync-external-store-shim.production.js
+ *
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */var Cr=$;function l_(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var u_=typeof Object.is=="function"?Object.is:l_,a_=Cr.useState,c_=Cr.useEffect,f_=Cr.useLayoutEffect,d_=Cr.useDebugValue;function h_(e,t){var n=t(),r=a_({inst:{value:n,getSnapshot:t}}),o=r[0].inst,i=r[1];return f_(function(){o.value=n,o.getSnapshot=t,Dl(o)&&i({inst:o})},[e,n,t]),c_(function(){return Dl(o)&&i({inst:o}),e(function(){Dl(o)&&i({inst:o})})},[e]),d_(n),n}function Dl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!u_(e,n)}catch{return!0}}function p_(e,t){return t()}var g_=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p_:h_;im.useSyncExternalStore=Cr.useSyncExternalStore!==void 0?Cr.useSyncExternalStore:g_;om.exports=im;var m_=om.exports;/**
+ * @license React
+ * use-sync-external-store-shim/with-selector.production.js
+ *
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */var Qs=$,y_=m_;function v_(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var w_=typeof Object.is=="function"?Object.is:v_,x_=y_.useSyncExternalStore,S_=Qs.useRef,E_=Qs.useEffect,__=Qs.useMemo,k_=Qs.useDebugValue;rm.useSyncExternalStoreWithSelector=function(e,t,n,r,o){var i=S_(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=__(function(){function u(m){if(!a){if(a=!0,d=m,m=r(m),o!==void 0&&s.hasValue){var y=s.value;if(o(y,m))return c=y}return c=m}if(y=c,w_(d,m))return y;var w=r(m);return o!==void 0&&o(y,w)?(d=m,y):(d=m,c=w)}var a=!1,d,c,f=n===void 0?null:n;return[function(){return u(t())},f===null?void 0:function(){return u(f())}]},[t,n,r,o]);var l=x_(e,i[0],i[1]);return E_(function(){s.hasValue=!0,s.value=l},[l]),k_(l),l};nm.exports=rm;var C_=nm.exports;const N_=Dd(C_),M_={},od=e=>{let t;const n=new Set,r=(d,c)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const m=t;t=c??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(y=>y(t,m))}},o=()=>t,u={setState:r,getState:o,getInitialState:()=>a,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(M_?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},a=t=e(r,o,u);return u},P_=e=>e?od(e):od,{useDebugValue:T_}=vy,{useSyncExternalStoreWithSelector:I_}=N_,z_=e=>e;function sm(e,t=z_,n){const r=I_(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return T_(r),r}const id=(e,t)=>{const n=P_(e),r=(o,i=t)=>sm(n,o,i);return Object.assign(r,n),r},L_=(e,t)=>e?id(e,t):id;function de(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Gs=$.createContext(null),A_=Gs.Provider,lm=kt.error001();function ne(e,t){const n=$.useContext(Gs);if(n===null)throw new Error(lm);return sm(n,e,t)}function he(){const e=$.useContext(Gs);if(e===null)throw new Error(lm);return $.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const sd={display:"none"},R_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},um="react-flow__node-desc",am="react-flow__edge-desc",$_="react-flow__aria-live",D_=e=>e.ariaLiveMessage,F_=e=>e.ariaLabelConfig;function O_({rfId:e}){const t=ne(D_);return M.jsx("div",{id:`${$_}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:R_,children:t})}function j_({rfId:e,disableKeyboardA11y:t}){const n=ne(F_);return M.jsxs(M.Fragment,{children:[M.jsx("div",{id:`${um}-${e}`,style:sd,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),M.jsx("div",{id:`${am}-${e}`,style:sd,children:n["edge.a11yDescription.default"]}),!t&&M.jsx(O_,{rfId:e})]})}const Ks=$.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return M.jsx("div",{className:xe(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});Ks.displayName="Panel";function H_({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:M.jsx(Ks,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:M.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const V_=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},vi=e=>e.id;function b_(e,t){return de(e.selectedNodes.map(vi),t.selectedNodes.map(vi))&&de(e.selectedEdges.map(vi),t.selectedEdges.map(vi))}function B_({onSelectionChange:e}){const t=he(),{selectedNodes:n,selectedEdges:r}=ne(V_,b_);return $.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const W_=e=>!!e.onSelectionChangeHandlers;function U_({onSelectionChange:e}){const t=ne(W_);return e||t?M.jsx(B_,{onSelectionChange:e}):null}const cm=[0,0],Y_={x:0,y:0,zoom:1},X_=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],ld=[...X_,"rfId"],Q_=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),ud={translateExtent:To,nodeOrigin:cm,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function G_(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:l,setDefaultNodesAndEdges:u}=ne(Q_,de),a=he();$.useEffect(()=>(u(e.defaultNodes,e.defaultEdges),()=>{d.current=ud,l()}),[]);const d=$.useRef(ud);return $.useEffect(()=>{for(const c of ld){const f=e[c],m=d.current[c];f!==m&&(typeof e[c]>"u"||(c==="nodes"?t(f):c==="edges"?n(f):c==="minZoom"?r(f):c==="maxZoom"?o(f):c==="translateExtent"?i(f):c==="nodeExtent"?s(f):c==="ariaLabelConfig"?a.setState({ariaLabelConfig:vE(f)}):c==="fitView"?a.setState({fitViewQueued:f}):c==="fitViewOptions"?a.setState({fitViewOptions:f}):a.setState({[c]:f})))}d.current=e},ld.map(c=>e[c])),null}function ad(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function K_(e){var r;const[t,n]=$.useState(e==="system"?null:e);return $.useEffect(()=>{if(e!=="system"){n(e);return}const o=ad(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=ad())!=null&&r.matches?"dark":"light"}const cd=typeof document<"u"?document:null;function Ao(e=null,t={target:cd,actInsideInputWithModifier:!0}){const[n,r]=$.useState(!1),o=$.useRef(!1),i=$.useRef(new Set([])),[s,l]=$.useMemo(()=>{if(e!==null){const a=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace("+",`
+`).replace(`
+
+`,`
++`).split(`
+`)),d=a.reduce((c,f)=>c.concat(...f),[]);return[a,d]}return[[],[]]},[e]);return $.useEffect(()=>{const u=(t==null?void 0:t.target)??cd,a=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=m=>{var x,h;if(o.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!o.current||o.current&&!a)&&jg(m))return!1;const w=dd(m.code,l);if(i.current.add(m[w]),fd(s,i.current,!1)){const g=((h=(x=m.composedPath)==null?void 0:x.call(m))==null?void 0:h[0])||m.target,p=(g==null?void 0:g.nodeName)==="BUTTON"||(g==null?void 0:g.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&m.preventDefault(),r(!0)}},c=m=>{const y=dd(m.code,l);fd(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(m[y]),m.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",d),u==null||u.addEventListener("keyup",c),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{u==null||u.removeEventListener("keydown",d),u==null||u.removeEventListener("keyup",c),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function fd(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function dd(e,t){return t.includes(e)?"code":"key"}const Z_=()=>{const e=he();return $.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:l}=e.getState(),u=Ys(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(u,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:l,y:u}=s.getBoundingClientRect(),a={x:t.x-l,y:t.y-u},d=n.snapGrid??o,c=n.snapToGrid??i;return Wo(a,r,c,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=vs(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function fm(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of t){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const l={...i};for(const u of s)q_(u,l);n.push(l)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function q_(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function dm(e,t){return fm(e,t)}function hm(e,t){return fm(e,t)}function yn(e,t){return{id:e,type:"select",selected:t}}function tr(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(yn(i.id,s)))}return r}function hd({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const l=t.get(s.id),u=((o=l==null?void 0:l.internals)==null?void 0:o.userNode)??l;u!==void 0&&u!==s&&n.push({id:s.id,item:s,type:"replace"}),u===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function pd(e){return{id:e.id,type:"remove"}}const gd=e=>aE(e),J_=e=>Ig(e);function pm(e){return $.forwardRef(e)}const e2=typeof window<"u"?$.useLayoutEffect:$.useEffect;function md(e){const[t,n]=$.useState(BigInt(0)),[r]=$.useState(()=>t2(()=>n(o=>o+BigInt(1))));return e2(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function t2(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const gm=$.createContext(null);function n2({children:e}){const t=he(),n=$.useCallback(l=>{const{nodes:u=[],setNodes:a,hasDefaultNodes:d,onNodesChange:c,nodeLookup:f,fitViewQueued:m,onNodesChangeMiddlewareMap:y}=t.getState();let w=u;for(const h of l)w=typeof h=="function"?h(w):h;let x=hd({items:w,lookup:f});for(const h of y.values())x=h(x);d&&a(w),x.length>0?c==null||c(x):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:h,nodes:g,setNodes:p}=t.getState();h&&p(g)})},[]),r=md(n),o=$.useCallback(l=>{const{edges:u=[],setEdges:a,hasDefaultEdges:d,onEdgesChange:c,edgeLookup:f}=t.getState();let m=u;for(const y of l)m=typeof y=="function"?y(m):y;d?a(m):c&&c(hd({items:m,lookup:f}))},[]),i=md(o),s=$.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return M.jsx(gm.Provider,{value:s,children:e})}function r2(){const e=$.useContext(gm);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const o2=e=>!!e.panZoom;function Uo(){const e=Z_(),t=he(),n=r2(),r=ne(o2),o=$.useMemo(()=>{const i=c=>t.getState().nodeLookup.get(c),s=c=>{n.nodeQueue.push(c)},l=c=>{n.edgeQueue.push(c)},u=c=>{var h,g;const{nodeLookup:f,nodeOrigin:m}=t.getState(),y=gd(c)?c:f.get(c.id),w=y.parentId?Fg(y.position,y.measured,y.parentId,f,m):y.position,x={...y,position:w,width:((h=y.measured)==null?void 0:h.width)??y.width,height:((g=y.measured)==null?void 0:g.height)??y.height};return Er(x)},a=(c,f,m={replace:!1})=>{s(y=>y.map(w=>{if(w.id===c){const x=typeof f=="function"?f(w):f;return m.replace&&gd(x)?x:{...w,...x}}return w}))},d=(c,f,m={replace:!1})=>{l(y=>y.map(w=>{if(w.id===c){const x=typeof f=="function"?f(w):f;return m.replace&&J_(x)?x:{...w,...x}}return w}))};return{getNodes:()=>t.getState().nodes.map(c=>({...c})),getNode:c=>{var f;return(f=i(c))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:c=[]}=t.getState();return c.map(f=>({...f}))},getEdge:c=>t.getState().edgeLookup.get(c),setNodes:s,setEdges:l,addNodes:c=>{const f=Array.isArray(c)?c:[c];n.nodeQueue.push(m=>[...m,...f])},addEdges:c=>{const f=Array.isArray(c)?c:[c];n.edgeQueue.push(m=>[...m,...f])},toObject:()=>{const{nodes:c=[],edges:f=[],transform:m}=t.getState(),[y,w,x]=m;return{nodes:c.map(h=>({...h})),edges:f.map(h=>({...h})),viewport:{x:y,y:w,zoom:x}}},deleteElements:async({nodes:c=[],edges:f=[]})=>{const{nodes:m,edges:y,onNodesDelete:w,onEdgesDelete:x,triggerNodeChanges:h,triggerEdgeChanges:g,onDelete:p,onBeforeDelete:v}=t.getState(),{nodes:E,edges:_}=await hE({nodesToRemove:c,edgesToRemove:f,nodes:m,edges:y,onBeforeDelete:v}),N=_.length>0,P=E.length>0;if(N){const L=_.map(pd);x==null||x(_),g(L)}if(P){const L=E.map(pd);w==null||w(E),h(L)}return(P||N)&&(p==null||p({nodes:E,edges:_})),{deletedNodes:E,deletedEdges:_}},getIntersectingNodes:(c,f=!0,m)=>{const y=Uf(c),w=y?c:u(c),x=m!==void 0;return w?(m||t.getState().nodes).filter(h=>{const g=t.getState().nodeLookup.get(h.id);if(g&&!y&&(h.id===c.id||!g.internals.positionAbsolute))return!1;const p=Er(x?h:g),v=zo(p,w);return f&&v>0||v>=p.width*p.height||v>=w.width*w.height}):[]},isNodeIntersecting:(c,f,m=!0)=>{const w=Uf(c)?c:u(c);if(!w)return!1;const x=zo(w,f);return m&&x>0||x>=f.width*f.height||x>=w.width*w.height},updateNode:a,updateNodeData:(c,f,m={replace:!1})=>{a(c,y=>{const w=typeof f=="function"?f(y):f;return m.replace?{...y,data:w}:{...y,data:{...y.data,...w}}},m)},updateEdge:d,updateEdgeData:(c,f,m={replace:!1})=>{d(c,y=>{const w=typeof f=="function"?f(y):f;return m.replace?{...y,data:w}:{...y,data:{...y.data,...w}}},m)},getNodesBounds:c=>{const{nodeLookup:f,nodeOrigin:m}=t.getState();return zg(c,{nodeLookup:f,nodeOrigin:m})},getHandleConnections:({type:c,id:f,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}-${c}${f?`-${f}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:c,handleId:f,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}${c?f?`-${c}-${f}`:`-${c}`:""}`))==null?void 0:y.values())??[])},fitView:async c=>{const f=t.getState().fitViewResolver??yE();return t.setState({fitViewQueued:!0,fitViewOptions:c,fitViewResolver:f}),n.nodeQueue.push(m=>[...m]),f.promise}}},[]);return $.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const yd=e=>e.selected,i2=typeof window<"u"?window:void 0;function s2({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=he(),{deleteElements:r}=Uo(),o=Ao(e,{actInsideInputWithModifier:!1}),i=Ao(t,{target:i2});$.useEffect(()=>{if(o){const{edges:s,nodes:l}=n.getState();r({nodes:l.filter(yd),edges:s.filter(yd)}),n.setState({nodesSelectionActive:!1})}},[o]),$.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function l2(e){const t=he();$.useEffect(()=>{const n=()=>{var o,i,s,l;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=qa(e.current);(r.height===0||r.width===0)&&((l=(s=t.getState()).onError)==null||l.call(s,"004",kt.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Zs={position:"absolute",width:"100%",height:"100%",top:0,left:0},u2=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function a2({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=Cn.Free,zoomOnDoubleClick:s=!0,panOnDrag:l=!0,defaultViewport:u,translateExtent:a,minZoom:d,maxZoom:c,zoomActivationKeyCode:f,preventScrolling:m=!0,children:y,noWheelClassName:w,noPanClassName:x,onViewportChange:h,isControlledViewport:g,paneClickDistance:p,selectionOnDrag:v}){const E=he(),_=$.useRef(null),{userSelectionActive:N,lib:P,connectionInProgress:L}=ne(u2,de),j=Ao(f),z=$.useRef();l2(_);const R=$.useCallback(H=>{h==null||h({x:H[0],y:H[1],zoom:H[2]}),g||E.setState({transform:H})},[h,g]);return $.useEffect(()=>{if(_.current){z.current=e_({domNode:_.current,minZoom:d,maxZoom:c,translateExtent:a,viewport:u,onDraggingChange:I=>E.setState(D=>D.paneDragging===I?D:{paneDragging:I}),onPanZoomStart:(I,D)=>{const{onViewportChangeStart:k,onMoveStart:S}=E.getState();S==null||S(I,D),k==null||k(D)},onPanZoom:(I,D)=>{const{onViewportChange:k,onMove:S}=E.getState();S==null||S(I,D),k==null||k(D)},onPanZoomEnd:(I,D)=>{const{onViewportChangeEnd:k,onMoveEnd:S}=E.getState();S==null||S(I,D),k==null||k(D)}});const{x:H,y:C,zoom:A}=z.current.getViewport();return E.setState({panZoom:z.current,transform:[H,C,A],domNode:_.current.closest(".react-flow")}),()=>{var I;(I=z.current)==null||I.destroy()}}},[]),$.useEffect(()=>{var H;(H=z.current)==null||H.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:l,zoomActivationKeyPressed:j,preventScrolling:m,noPanClassName:x,userSelectionActive:N,noWheelClassName:w,lib:P,onTransformChange:R,connectionInProgress:L,selectionOnDrag:v,paneClickDistance:p})},[e,t,n,r,o,i,s,l,j,m,x,N,w,P,R,L,v,p]),M.jsx("div",{className:"react-flow__renderer",ref:_,style:Zs,children:y})}const c2=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function f2(){const{userSelectionActive:e,userSelectionRect:t}=ne(c2,de);return e&&t?M.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Fl=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},d2=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function h2({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Io.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:l,onPaneClick:u,onPaneContextMenu:a,onPaneScroll:d,onPaneMouseEnter:c,onPaneMouseMove:f,onPaneMouseLeave:m,children:y}){const w=he(),{userSelectionActive:x,elementsSelectable:h,dragging:g,connectionInProgress:p}=ne(d2,de),v=h&&(e||x),E=$.useRef(null),_=$.useRef(),N=$.useRef(new Set),P=$.useRef(new Set),L=$.useRef(!1),j=k=>{if(L.current||p){L.current=!1;return}u==null||u(k),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},z=k=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){k.preventDefault();return}a==null||a(k)},R=d?k=>d(k):void 0,H=k=>{L.current&&(k.stopPropagation(),L.current=!1)},C=k=>{var U,Y;const{domNode:S}=w.getState();if(_.current=S==null?void 0:S.getBoundingClientRect(),!_.current)return;const T=k.target===E.current;if(!T&&!!k.target.closest(".nokey")||!e||!(i&&T||t)||k.button!==0||!k.isPrimary)return;(Y=(U=k.target)==null?void 0:U.setPointerCapture)==null||Y.call(U,k.pointerId),L.current=!1;const{x:W,y:V}=dt(k.nativeEvent,_.current);w.setState({userSelectionRect:{width:0,height:0,startX:W,startY:V,x:W,y:V}}),T||(k.stopPropagation(),k.preventDefault())},A=k=>{const{userSelectionRect:S,transform:T,nodeLookup:O,edgeLookup:F,connectionLookup:W,triggerNodeChanges:V,triggerEdgeChanges:U,defaultEdgeOptions:Y,resetSelectedElements:Q}=w.getState();if(!_.current||!S)return;const{x:B,y:K}=dt(k.nativeEvent,_.current),{startX:ee,startY:J}=S;if(!L.current){const oe=t?0:o;if(Math.hypot(B-ee,K-J)<=oe)return;Q(),s==null||s(k)}L.current=!0;const q={startX:ee,startY:J,x:Boe.id)),P.current=new Set;const ue=(Y==null?void 0:Y.selectable)??!0;for(const oe of N.current){const Pe=W.get(oe);if(Pe)for(const{edgeId:Vt}of Pe.values()){const Nt=F.get(Vt);Nt&&(Nt.selectable??ue)&&P.current.add(Vt)}}if(!Yf(Z,N.current)){const oe=tr(O,N.current,!0);V(oe)}if(!Yf(ie,P.current)){const oe=tr(F,P.current);U(oe)}w.setState({userSelectionRect:q,userSelectionActive:!0,nodesSelectionActive:!1})},I=k=>{var S,T;k.button===0&&((T=(S=k.target)==null?void 0:S.releasePointerCapture)==null||T.call(S,k.pointerId),!x&&k.target===E.current&&w.getState().userSelectionRect&&(j==null||j(k)),w.setState({userSelectionActive:!1,userSelectionRect:null}),L.current&&(l==null||l(k),w.setState({nodesSelectionActive:N.current.size>0})))},D=r===!0||Array.isArray(r)&&r.includes(0);return M.jsxs("div",{className:xe(["react-flow__pane",{draggable:D,dragging:g,selection:e}]),onClick:v?void 0:Fl(j,E),onContextMenu:Fl(z,E),onWheel:Fl(R,E),onPointerEnter:v?void 0:c,onPointerMove:v?A:f,onPointerUp:v?I:void 0,onPointerDownCapture:v?C:void 0,onClickCapture:v?H:void 0,onPointerLeave:m,ref:E,style:Zs,children:[y,M.jsx(f2,{})]})}function Xu({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:l,onError:u}=t.getState(),a=l.get(e);if(!a){u==null||u("012",kt.error012(e));return}t.setState({nodesSelectionActive:!1}),a.selected?(n||a.selected&&s)&&(i({nodes:[a],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):o([e])}function mm({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const l=he(),[u,a]=$.useState(!1),d=$.useRef();return $.useEffect(()=>{d.current=HE({getStoreItems:()=>l.getState(),onNodeMouseDown:c=>{Xu({id:c,store:l,nodeRef:e})},onDragStart:()=>{a(!0)},onDragStop:()=>{a(!1)}})},[]),$.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var c;(c=d.current)==null||c.destroy()}},[n,r,t,i,e,o,s]),u}const p2=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ym(){const e=he();return $.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:l,updateNodePositions:u,nodeLookup:a,nodeOrigin:d}=e.getState(),c=new Map,f=p2(s),m=o?i[0]:5,y=o?i[1]:5,w=n.direction.x*m*n.factor,x=n.direction.y*y*n.factor;for(const[,h]of a){if(!f(h))continue;let g={x:h.internals.positionAbsolute.x+w,y:h.internals.positionAbsolute.y+x};o&&(g=Bo(g,i));const{position:p,positionAbsolute:v}=Lg({nodeId:h.id,nextPosition:g,nodeLookup:a,nodeExtent:r,nodeOrigin:d,onError:l});h.position=p,h.internals.positionAbsolute=v,c.set(h.id,h)}u(c)},[])}const oc=$.createContext(null),g2=oc.Provider;oc.Consumer;const vm=()=>$.useContext(oc),m2=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),y2=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:l,toHandle:u,isValid:a}=s,d=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:d,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===wr.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!o,valid:d&&a}};function v2({type:e="source",position:t=G.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:l,children:u,className:a,onMouseDown:d,onTouchStart:c,...f},m){var A,I;const y=s||null,w=e==="target",x=he(),h=vm(),{connectOnClick:g,noPanClassName:p,rfId:v}=ne(m2,de),{connectingFrom:E,connectingTo:_,clickConnecting:N,isPossibleEndHandle:P,connectionInProcess:L,clickConnectionInProcess:j,valid:z}=ne(y2(h,y,e),de);h||(I=(A=x.getState()).onError)==null||I.call(A,"010",kt.error010());const R=D=>{const{defaultEdgeOptions:k,onConnect:S,hasDefaultEdges:T}=x.getState(),O={...k,...D};if(T){const{edges:F,setEdges:W}=x.getState();W(kE(O,F))}S==null||S(O),l==null||l(O)},H=D=>{if(!h)return;const k=Hg(D.nativeEvent);if(o&&(k&&D.button===0||!k)){const S=x.getState();Yu.onPointerDown(D.nativeEvent,{handleDomNode:D.currentTarget,autoPanOnConnect:S.autoPanOnConnect,connectionMode:S.connectionMode,connectionRadius:S.connectionRadius,domNode:S.domNode,nodeLookup:S.nodeLookup,lib:S.lib,isTarget:w,handleId:y,nodeId:h,flowId:S.rfId,panBy:S.panBy,cancelConnection:S.cancelConnection,onConnectStart:S.onConnectStart,onConnectEnd:(...T)=>{var O,F;return(F=(O=x.getState()).onConnectEnd)==null?void 0:F.call(O,...T)},updateConnection:S.updateConnection,onConnect:R,isValidConnection:n||((...T)=>{var O,F;return((F=(O=x.getState()).isValidConnection)==null?void 0:F.call(O,...T))??!0}),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:S.autoPanSpeed,dragThreshold:S.connectionDragThreshold})}k?d==null||d(D):c==null||c(D)},C=D=>{const{onClickConnectStart:k,onClickConnectEnd:S,connectionClickStartHandle:T,connectionMode:O,isValidConnection:F,lib:W,rfId:V,nodeLookup:U,connection:Y}=x.getState();if(!h||!T&&!o)return;if(!T){k==null||k(D.nativeEvent,{nodeId:h,handleId:y,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:h,type:e,id:y}});return}const Q=Og(D.target),B=n||F,{connection:K,isValid:ee}=Yu.isValid(D.nativeEvent,{handle:{nodeId:h,id:y,type:e},connectionMode:O,fromNodeId:T.nodeId,fromHandleId:T.id||null,fromType:T.type,isValidConnection:B,flowId:V,doc:Q,lib:W,nodeLookup:U});ee&&K&&R(K);const J=structuredClone(Y);delete J.inProgress,J.toPosition=J.toHandle?J.toHandle.position:null,S==null||S(D,J),x.setState({connectionClickStartHandle:null})};return M.jsx("div",{"data-handleid":y,"data-nodeid":h,"data-handlepos":t,"data-id":`${v}-${h}-${y}-${e}`,className:xe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,a,{source:!w,target:w,connectable:r,connectablestart:o,connectableend:i,clickconnecting:N,connectingfrom:E,connectingto:_,valid:z,connectionindicator:r&&(!L||P)&&(L||j?i:o)}]),onMouseDown:H,onTouchStart:H,onClick:g?C:void 0,ref:m,...f,children:u})}const Nr=$.memo(pm(v2));function w2({data:e,isConnectable:t,sourcePosition:n=G.Bottom}){return M.jsxs(M.Fragment,{children:[e==null?void 0:e.label,M.jsx(Nr,{type:"source",position:n,isConnectable:t})]})}function x2({data:e,isConnectable:t,targetPosition:n=G.Top,sourcePosition:r=G.Bottom}){return M.jsxs(M.Fragment,{children:[M.jsx(Nr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,M.jsx(Nr,{type:"source",position:r,isConnectable:t})]})}function S2(){return null}function E2({data:e,isConnectable:t,targetPosition:n=G.Top}){return M.jsxs(M.Fragment,{children:[M.jsx(Nr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const ws={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},vd={input:w2,default:x2,output:E2,group:S2};function _2(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const k2=e=>{const{width:t,height:n,x:r,y:o}=bo(e.nodeLookup,{filter:i=>!!i.selected});return{width:ft(t)?t:null,height:ft(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function C2({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=he(),{width:o,height:i,transformString:s,userSelectionActive:l}=ne(k2,de),u=ym(),a=$.useRef(null);$.useEffect(()=>{var m;n||(m=a.current)==null||m.focus({preventScroll:!0})},[n]);const d=!l&&o!==null&&i!==null;if(mm({nodeRef:a,disabled:!d}),!d)return null;const c=e?m=>{const y=r.getState().nodes.filter(w=>w.selected);e(m,y)}:void 0,f=m=>{Object.prototype.hasOwnProperty.call(ws,m.key)&&(m.preventDefault(),u({direction:ws[m.key],factor:m.shiftKey?4:1}))};return M.jsx("div",{className:xe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:M.jsx("div",{ref:a,className:"react-flow__nodesselection-rect",onContextMenu:c,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const wd=typeof window<"u"?window:void 0,N2=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function wm({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:l,deleteKeyCode:u,selectionKeyCode:a,selectionOnDrag:d,selectionMode:c,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:w,zoomActivationKeyCode:x,elementsSelectable:h,zoomOnScroll:g,zoomOnPinch:p,panOnScroll:v,panOnScrollSpeed:E,panOnScrollMode:_,zoomOnDoubleClick:N,panOnDrag:P,defaultViewport:L,translateExtent:j,minZoom:z,maxZoom:R,preventScrolling:H,onSelectionContextMenu:C,noWheelClassName:A,noPanClassName:I,disableKeyboardA11y:D,onViewportChange:k,isControlledViewport:S}){const{nodesSelectionActive:T,userSelectionActive:O}=ne(N2,de),F=Ao(a,{target:wd}),W=Ao(w,{target:wd}),V=W||P,U=W||v,Y=d&&V!==!0,Q=F||O||Y;return s2({deleteKeyCode:u,multiSelectionKeyCode:y}),M.jsx(a2,{onPaneContextMenu:i,elementsSelectable:h,zoomOnScroll:g,zoomOnPinch:p,panOnScroll:U,panOnScrollSpeed:E,panOnScrollMode:_,zoomOnDoubleClick:N,panOnDrag:!F&&V,defaultViewport:L,translateExtent:j,minZoom:z,maxZoom:R,zoomActivationKeyCode:x,preventScrolling:H,noWheelClassName:A,noPanClassName:I,onViewportChange:k,isControlledViewport:S,paneClickDistance:l,selectionOnDrag:Y,children:M.jsxs(h2,{onSelectionStart:f,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:V,isSelecting:!!Q,selectionMode:c,selectionKeyPressed:F,paneClickDistance:l,selectionOnDrag:Y,children:[e,T&&M.jsx(C2,{onSelectionContextMenu:C,noPanClassName:I,disableKeyboardA11y:D})]})})}wm.displayName="FlowRenderer";const M2=$.memo(wm),P2=e=>t=>e?Za(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function T2(e){return ne($.useCallback(P2(e),[e]),de)}const I2=e=>e.updateNodeInternals;function z2(){const e=ne(I2),[t]=$.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return $.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function L2({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=he(),i=$.useRef(null),s=$.useRef(null),l=$.useRef(e.sourcePosition),u=$.useRef(e.targetPosition),a=$.useRef(t),d=n&&!!e.internals.handleBounds;return $.useEffect(()=>{i.current&&!e.hidden&&(!d||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[d,e.hidden]),$.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),$.useEffect(()=>{if(i.current){const c=a.current!==t,f=l.current!==e.sourcePosition,m=u.current!==e.targetPosition;(c||f||m)&&(a.current=t,l.current=e.sourcePosition,u.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function A2({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:l,elementsSelectable:u,nodesConnectable:a,nodesFocusable:d,resizeObserver:c,noDragClassName:f,noPanClassName:m,disableKeyboardA11y:y,rfId:w,nodeTypes:x,nodeClickDistance:h,onError:g}){const{node:p,internals:v,isParent:E}=ne(B=>{const K=B.nodeLookup.get(e),ee=B.parentLookup.has(e);return{node:K,internals:K.internals,isParent:ee}},de);let _=p.type||"default",N=(x==null?void 0:x[_])||vd[_];N===void 0&&(g==null||g("003",kt.error003(_)),_="default",N=(x==null?void 0:x.default)||vd.default);const P=!!(p.draggable||l&&typeof p.draggable>"u"),L=!!(p.selectable||u&&typeof p.selectable>"u"),j=!!(p.connectable||a&&typeof p.connectable>"u"),z=!!(p.focusable||d&&typeof p.focusable>"u"),R=he(),H=Dg(p),C=L2({node:p,nodeType:_,hasDimensions:H,resizeObserver:c}),A=mm({nodeRef:C,disabled:p.hidden||!P,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:L,nodeClickDistance:h}),I=ym();if(p.hidden)return null;const D=Ht(p),k=_2(p),S=L||P||t||n||r||o,T=n?B=>n(B,{...v.userNode}):void 0,O=r?B=>r(B,{...v.userNode}):void 0,F=o?B=>o(B,{...v.userNode}):void 0,W=i?B=>i(B,{...v.userNode}):void 0,V=s?B=>s(B,{...v.userNode}):void 0,U=B=>{const{selectNodesOnDrag:K,nodeDragThreshold:ee}=R.getState();L&&(!K||!P||ee>0)&&Xu({id:e,store:R,nodeRef:C}),t&&t(B,{...v.userNode})},Y=B=>{if(!(jg(B.nativeEvent)||y)){if(Ng.includes(B.key)&&L){const K=B.key==="Escape";Xu({id:e,store:R,unselect:K,nodeRef:C})}else if(P&&p.selected&&Object.prototype.hasOwnProperty.call(ws,B.key)){B.preventDefault();const{ariaLabelConfig:K}=R.getState();R.setState({ariaLiveMessage:K["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),I({direction:ws[B.key],factor:B.shiftKey?4:1})}}},Q=()=>{var ie;if(y||!((ie=C.current)!=null&&ie.matches(":focus-visible")))return;const{transform:B,width:K,height:ee,autoPanOnNodeFocus:J,setCenter:q}=R.getState();if(!J)return;Za(new Map([[e,p]]),{x:0,y:0,width:K,height:ee},B,!0).length>0||q(p.position.x+D.width/2,p.position.y+D.height/2,{zoom:B[2]})};return M.jsx("div",{className:xe(["react-flow__node",`react-flow__node-${_}`,{[m]:P},p.className,{selected:p.selected,selectable:L,parent:E,draggable:P,dragging:A}]),ref:C,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:S?"all":"none",visibility:H?"visible":"hidden",...p.style,...k},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:T,onMouseMove:O,onMouseLeave:F,onContextMenu:W,onClick:U,onDoubleClick:V,onKeyDown:z?Y:void 0,tabIndex:z?0:void 0,onFocus:z?Q:void 0,role:p.ariaRole??(z?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${um}-${w}`,"aria-label":p.ariaLabel,...p.domAttributes,children:M.jsx(g2,{value:e,children:M.jsx(N,{id:e,data:p.data,type:_,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:p.selected??!1,selectable:L,draggable:P,deletable:p.deletable??!0,isConnectable:j,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:A,dragHandle:p.dragHandle,zIndex:v.z,parentId:p.parentId,...D})})})}var R2=$.memo(A2);const $2=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function xm(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=ne($2,de),s=T2(e.onlyRenderVisibleElements),l=z2();return M.jsx("div",{className:"react-flow__nodes",style:Zs,children:s.map(u=>M.jsx(R2,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},u))})}xm.displayName="NodeRenderer";const D2=$.memo(xm);function F2(e){return ne($.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&SE({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),de)}const O2=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return M.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},j2=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return M.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},xd={[xr.Arrow]:O2,[xr.ArrowClosed]:j2};function H2(e){const t=he();return $.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(xd,e)?xd[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",kt.error009(e)),null)},[e])}const V2=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const u=H2(t);return u?M.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:M.jsx(u,{color:n,strokeWidth:s})}):null},Sm=({defaultColor:e,rfId:t})=>{const n=ne(i=>i.edges),r=ne(i=>i.defaultEdgeOptions),o=$.useMemo(()=>TE(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?M.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:M.jsx("defs",{children:o.map(i=>M.jsx(V2,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Sm.displayName="MarkerDefinitions";var b2=$.memo(Sm);function Em({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:u,className:a,...d}){const[c,f]=$.useState({x:1,y:0,width:0,height:0}),m=xe(["react-flow__edge-textwrapper",a]),y=$.useRef(null);return $.useEffect(()=>{if(y.current){const w=y.current.getBBox();f({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?M.jsxs("g",{transform:`translate(${e-c.width/2} ${t-c.height/2})`,className:m,visibility:c.width?"visible":"hidden",...d,children:[o&&M.jsx("rect",{width:c.width+2*s[0],x:-s[0],y:-s[1],height:c.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),M.jsx("text",{className:"react-flow__edge-text",y:c.height/2,dy:"0.3em",ref:y,style:r,children:n}),u]}):null}Em.displayName="EdgeText";const B2=$.memo(Em);function qs({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:u,interactionWidth:a=20,...d}){return M.jsxs(M.Fragment,{children:[M.jsx("path",{...d,d:e,fill:"none",className:xe(["react-flow__edge-path",d.className])}),a?M.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:a,className:"react-flow__edge-interaction"}):null,r&&ft(t)&&ft(n)?M.jsx(B2,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:u}):null]})}function Sd({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===G.Left||e===G.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function _m({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top}){const[s,l]=Sd({pos:n,x1:e,y1:t,x2:r,y2:o}),[u,a]=Sd({pos:i,x1:r,y1:o,x2:e,y2:t}),[d,c,f,m]=Vg({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:l,targetControlX:u,targetControlY:a});return[`M${e},${t} C${s},${l} ${u},${a} ${r},${o}`,d,c,f,m]}function km(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:l,label:u,labelStyle:a,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:x,interactionWidth:h})=>{const[g,p,v]=_m({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l}),E=e.isInternal?void 0:t;return M.jsx(qs,{id:E,path:g,labelX:p,labelY:v,label:u,labelStyle:a,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:x,interactionWidth:h})})}const W2=km({isInternal:!1}),Cm=km({isInternal:!0});W2.displayName="SimpleBezierEdge";Cm.displayName="SimpleBezierEdgeInternal";function Nm(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:u,labelBgStyle:a,labelBgPadding:d,labelBgBorderRadius:c,style:f,sourcePosition:m=G.Bottom,targetPosition:y=G.Top,markerEnd:w,markerStart:x,pathOptions:h,interactionWidth:g})=>{const[p,v,E]=Bu({sourceX:n,sourceY:r,sourcePosition:m,targetX:o,targetY:i,targetPosition:y,borderRadius:h==null?void 0:h.borderRadius,offset:h==null?void 0:h.offset,stepPosition:h==null?void 0:h.stepPosition}),_=e.isInternal?void 0:t;return M.jsx(qs,{id:_,path:p,labelX:v,labelY:E,label:s,labelStyle:l,labelShowBg:u,labelBgStyle:a,labelBgPadding:d,labelBgBorderRadius:c,style:f,markerEnd:w,markerStart:x,interactionWidth:g})})}const Mm=Nm({isInternal:!1}),Pm=Nm({isInternal:!0});Mm.displayName="SmoothStepEdge";Pm.displayName="SmoothStepEdgeInternal";function Tm(e){return $.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return M.jsx(Mm,{...n,id:r,pathOptions:$.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const U2=Tm({isInternal:!1}),Im=Tm({isInternal:!0});U2.displayName="StepEdge";Im.displayName="StepEdgeInternal";function zm(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:l,labelShowBg:u,labelBgStyle:a,labelBgPadding:d,labelBgBorderRadius:c,style:f,markerEnd:m,markerStart:y,interactionWidth:w})=>{const[x,h,g]=Wg({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return M.jsx(qs,{id:p,path:x,labelX:h,labelY:g,label:s,labelStyle:l,labelShowBg:u,labelBgStyle:a,labelBgPadding:d,labelBgBorderRadius:c,style:f,markerEnd:m,markerStart:y,interactionWidth:w})})}const Y2=zm({isInternal:!1}),Lm=zm({isInternal:!0});Y2.displayName="StraightEdge";Lm.displayName="StraightEdgeInternal";function Am(e){return $.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=G.Bottom,targetPosition:l=G.Top,label:u,labelStyle:a,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:x,pathOptions:h,interactionWidth:g})=>{const[p,v,E]=bg({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:l,curvature:h==null?void 0:h.curvature}),_=e.isInternal?void 0:t;return M.jsx(qs,{id:_,path:p,labelX:v,labelY:E,label:u,labelStyle:a,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:x,interactionWidth:g})})}const X2=Am({isInternal:!1}),Rm=Am({isInternal:!0});X2.displayName="BezierEdge";Rm.displayName="BezierEdgeInternal";const Ed={default:Rm,straight:Lm,step:Im,smoothstep:Pm,simplebezier:Cm},_d={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Q2=(e,t,n)=>n===G.Left?e-t:n===G.Right?e+t:e,G2=(e,t,n)=>n===G.Top?e-t:n===G.Bottom?e+t:e,kd="react-flow__edgeupdater";function Cd({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:l}){return M.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:xe([kd,`${kd}-${l}`]),cx:Q2(t,r,e),cy:G2(n,r,e),r,stroke:"transparent",fill:"transparent"})}function K2({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:l,targetPosition:u,onReconnect:a,onReconnectStart:d,onReconnectEnd:c,setReconnecting:f,setUpdateHover:m}){const y=he(),w=(v,E)=>{if(v.button!==0)return;const{autoPanOnConnect:_,domNode:N,connectionMode:P,connectionRadius:L,lib:j,onConnectStart:z,cancelConnection:R,nodeLookup:H,rfId:C,panBy:A,updateConnection:I}=y.getState(),D=E.type==="target",k=(O,F)=>{f(!1),c==null||c(O,n,E.type,F)},S=O=>a==null?void 0:a(n,O),T=(O,F)=>{f(!0),d==null||d(v,n,E.type),z==null||z(O,F)};Yu.onPointerDown(v.nativeEvent,{autoPanOnConnect:_,connectionMode:P,connectionRadius:L,domNode:N,handleId:E.id,nodeId:E.nodeId,nodeLookup:H,isTarget:D,edgeUpdaterType:E.type,lib:j,flowId:C,cancelConnection:R,panBy:A,isValidConnection:(...O)=>{var F,W;return((W=(F=y.getState()).isValidConnection)==null?void 0:W.call(F,...O))??!0},onConnect:S,onConnectStart:T,onConnectEnd:(...O)=>{var F,W;return(W=(F=y.getState()).onConnectEnd)==null?void 0:W.call(F,...O)},onReconnectEnd:k,updateConnection:I,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},x=v=>w(v,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),h=v=>w(v,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),g=()=>m(!0),p=()=>m(!1);return M.jsxs(M.Fragment,{children:[(e===!0||e==="source")&&M.jsx(Cd,{position:l,centerX:r,centerY:o,radius:t,onMouseDown:x,onMouseEnter:g,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&M.jsx(Cd,{position:u,centerX:i,centerY:s,radius:t,onMouseDown:h,onMouseEnter:g,onMouseOut:p,type:"target"})]})}function Z2({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:l,onMouseMove:u,onMouseLeave:a,reconnectRadius:d,onReconnect:c,onReconnectStart:f,onReconnectEnd:m,rfId:y,edgeTypes:w,noPanClassName:x,onError:h,disableKeyboardA11y:g}){let p=ne(q=>q.edgeLookup.get(e));const v=ne(q=>q.defaultEdgeOptions);p=v?{...v,...p}:p;let E=p.type||"default",_=(w==null?void 0:w[E])||Ed[E];_===void 0&&(h==null||h("011",kt.error011(E)),E="default",_=(w==null?void 0:w.default)||Ed.default);const N=!!(p.focusable||t&&typeof p.focusable>"u"),P=typeof c<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),L=!!(p.selectable||r&&typeof p.selectable>"u"),j=$.useRef(null),[z,R]=$.useState(!1),[H,C]=$.useState(!1),A=he(),{zIndex:I,sourceX:D,sourceY:k,targetX:S,targetY:T,sourcePosition:O,targetPosition:F}=ne($.useCallback(q=>{const Z=q.nodeLookup.get(p.source),ie=q.nodeLookup.get(p.target);if(!Z||!ie)return{zIndex:p.zIndex,..._d};const ue=PE({id:e,sourceNode:Z,targetNode:ie,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:q.connectionMode,onError:h});return{zIndex:xE({selected:p.selected,zIndex:p.zIndex,sourceNode:Z,targetNode:ie,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode}),...ue||_d}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),de),W=$.useMemo(()=>p.markerStart?`url('#${Wu(p.markerStart,y)}')`:void 0,[p.markerStart,y]),V=$.useMemo(()=>p.markerEnd?`url('#${Wu(p.markerEnd,y)}')`:void 0,[p.markerEnd,y]);if(p.hidden||D===null||k===null||S===null||T===null)return null;const U=q=>{var oe;const{addSelectedEdges:Z,unselectNodesAndEdges:ie,multiSelectionActive:ue}=A.getState();L&&(A.setState({nodesSelectionActive:!1}),p.selected&&ue?(ie({nodes:[],edges:[p]}),(oe=j.current)==null||oe.blur()):Z([e])),o&&o(q,p)},Y=i?q=>{i(q,{...p})}:void 0,Q=s?q=>{s(q,{...p})}:void 0,B=l?q=>{l(q,{...p})}:void 0,K=u?q=>{u(q,{...p})}:void 0,ee=a?q=>{a(q,{...p})}:void 0,J=q=>{var Z;if(!g&&Ng.includes(q.key)&&L){const{unselectNodesAndEdges:ie,addSelectedEdges:ue}=A.getState();q.key==="Escape"?((Z=j.current)==null||Z.blur(),ie({edges:[p]})):ue([e])}};return M.jsx("svg",{style:{zIndex:I},children:M.jsxs("g",{className:xe(["react-flow__edge",`react-flow__edge-${E}`,p.className,x,{selected:p.selected,animated:p.animated,inactive:!L&&!o,updating:z,selectable:L}]),onClick:U,onDoubleClick:Y,onContextMenu:Q,onMouseEnter:B,onMouseMove:K,onMouseLeave:ee,onKeyDown:N?J:void 0,tabIndex:N?0:void 0,role:p.ariaRole??(N?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":N?`${am}-${y}`:void 0,ref:j,...p.domAttributes,children:[!H&&M.jsx(_,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:L,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:D,sourceY:k,targetX:S,targetY:T,sourcePosition:O,targetPosition:F,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:W,markerEnd:V,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),P&&M.jsx(K2,{edge:p,isReconnectable:P,reconnectRadius:d,onReconnect:c,onReconnectStart:f,onReconnectEnd:m,sourceX:D,sourceY:k,targetX:S,targetY:T,sourcePosition:O,targetPosition:F,setUpdateHover:R,setReconnecting:C})]})})}var q2=$.memo(Z2);const J2=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function $m({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:l,onEdgeMouseMove:u,onEdgeMouseLeave:a,onEdgeClick:d,reconnectRadius:c,onEdgeDoubleClick:f,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:w}){const{edgesFocusable:x,edgesReconnectable:h,elementsSelectable:g,onError:p}=ne(J2,de),v=F2(t);return M.jsxs("div",{className:"react-flow__edges",children:[M.jsx(b2,{defaultColor:e,rfId:n}),v.map(E=>M.jsx(q2,{id:E,edgesFocusable:x,edgesReconnectable:h,elementsSelectable:g,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:l,onMouseMove:u,onMouseLeave:a,onClick:d,reconnectRadius:c,onDoubleClick:f,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:w},E))]})}$m.displayName="EdgeRenderer";const ek=$.memo($m),tk=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function nk({children:e}){const t=ne(tk);return M.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function rk(e){const t=Uo(),n=$.useRef(!1);$.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const ok=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function ik(e){const t=ne(ok),n=he();return $.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function sk(e){return e.connection.inProgress?{...e.connection,to:Wo(e.connection.to,e.transform)}:{...e.connection}}function lk(e){return sk}function uk(e){const t=lk();return ne(t,de)}const ak=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ck({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:l,inProgress:u}=ne(ak,de);return!(i&&o&&u)?null:M.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:M.jsx("g",{className:xe(["react-flow__connection",Tg(l)]),children:M.jsx(Dm,{style:t,type:n,CustomComponent:r,isValid:l})})})}const Dm=({style:e,type:t=Gt.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:l,fromPosition:u,to:a,toNode:d,toHandle:c,toPosition:f,pointer:m}=uk();if(!o)return;if(n)return M.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:l,fromX:i.x,fromY:i.y,toX:a.x,toY:a.y,fromPosition:u,toPosition:f,connectionStatus:Tg(r),toNode:d,toHandle:c,pointer:m});let y="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:u,targetX:a.x,targetY:a.y,targetPosition:f};switch(t){case Gt.Bezier:[y]=bg(w);break;case Gt.SimpleBezier:[y]=_m(w);break;case Gt.Step:[y]=Bu({...w,borderRadius:0});break;case Gt.SmoothStep:[y]=Bu(w);break;default:[y]=Wg(w)}return M.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};Dm.displayName="ConnectionLine";const fk={};function Nd(e=fk){$.useRef(e),he(),$.useEffect(()=>{},[e])}function dk(){he(),$.useRef(!1),$.useEffect(()=>{},[])}function Fm({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:a,onNodeContextMenu:d,onSelectionContextMenu:c,onSelectionStart:f,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:w,connectionLineComponent:x,connectionLineContainerStyle:h,selectionKeyCode:g,selectionOnDrag:p,selectionMode:v,multiSelectionKeyCode:E,panActivationKeyCode:_,zoomActivationKeyCode:N,deleteKeyCode:P,onlyRenderVisibleElements:L,elementsSelectable:j,defaultViewport:z,translateExtent:R,minZoom:H,maxZoom:C,preventScrolling:A,defaultMarkerColor:I,zoomOnScroll:D,zoomOnPinch:k,panOnScroll:S,panOnScrollSpeed:T,panOnScrollMode:O,zoomOnDoubleClick:F,panOnDrag:W,onPaneClick:V,onPaneMouseEnter:U,onPaneMouseMove:Y,onPaneMouseLeave:Q,onPaneScroll:B,onPaneContextMenu:K,paneClickDistance:ee,nodeClickDistance:J,onEdgeContextMenu:q,onEdgeMouseEnter:Z,onEdgeMouseMove:ie,onEdgeMouseLeave:ue,reconnectRadius:oe,onReconnect:Pe,onReconnectStart:Vt,onReconnectEnd:Nt,noDragClassName:pn,noWheelClassName:Ir,noPanClassName:zr,disableKeyboardA11y:Lr,nodeExtent:el,rfId:Yo,viewport:Fn,onViewportChange:Ar}){return Nd(e),Nd(t),dk(),rk(n),ik(Fn),M.jsx(M2,{onPaneClick:V,onPaneMouseEnter:U,onPaneMouseMove:Y,onPaneMouseLeave:Q,onPaneContextMenu:K,onPaneScroll:B,paneClickDistance:ee,deleteKeyCode:P,selectionKeyCode:g,selectionOnDrag:p,selectionMode:v,onSelectionStart:f,onSelectionEnd:m,multiSelectionKeyCode:E,panActivationKeyCode:_,zoomActivationKeyCode:N,elementsSelectable:j,zoomOnScroll:D,zoomOnPinch:k,zoomOnDoubleClick:F,panOnScroll:S,panOnScrollSpeed:T,panOnScrollMode:O,panOnDrag:W,defaultViewport:z,translateExtent:R,minZoom:H,maxZoom:C,onSelectionContextMenu:c,preventScrolling:A,noDragClassName:pn,noWheelClassName:Ir,noPanClassName:zr,disableKeyboardA11y:Lr,onViewportChange:Ar,isControlledViewport:!!Fn,children:M.jsxs(nk,{children:[M.jsx(ek,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:Pe,onReconnectStart:Vt,onReconnectEnd:Nt,onlyRenderVisibleElements:L,onEdgeContextMenu:q,onEdgeMouseEnter:Z,onEdgeMouseMove:ie,onEdgeMouseLeave:ue,reconnectRadius:oe,defaultMarkerColor:I,noPanClassName:zr,disableKeyboardA11y:Lr,rfId:Yo}),M.jsx(ck,{style:w,type:y,component:x,containerStyle:h}),M.jsx("div",{className:"react-flow__edgelabel-renderer"}),M.jsx(D2,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:a,onNodeContextMenu:d,nodeClickDistance:J,onlyRenderVisibleElements:L,noPanClassName:zr,noDragClassName:pn,disableKeyboardA11y:Lr,nodeExtent:el,rfId:Yo}),M.jsx("div",{className:"react-flow__viewport-portal"})]})})}Fm.displayName="GraphView";const hk=$.memo(Fm),Md=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:u=.5,maxZoom:a=2,nodeOrigin:d,nodeExtent:c,zIndexMode:f="basic"}={})=>{const m=new Map,y=new Map,w=new Map,x=new Map,h=r??t??[],g=n??e??[],p=d??[0,0],v=c??To;Xg(w,x,h);const E=Uu(g,m,y,{nodeOrigin:p,nodeExtent:v,zIndexMode:f});let _=[0,0,1];if(s&&o&&i){const N=bo(m,{filter:z=>!!((z.width||z.initialWidth)&&(z.height||z.initialHeight))}),{x:P,y:L,zoom:j}=Ys(N,o,i,u,a,(l==null?void 0:l.padding)??.1);_=[P,L,j]}return{rfId:"1",width:o??0,height:i??0,transform:_,nodes:g,nodesInitialized:E,nodeLookup:m,parentLookup:y,edges:h,edgeLookup:x,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:u,maxZoom:a,translateExtent:To,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:l,fitViewResolver:null,connection:{...Pg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:pE,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Mg,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},pk=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:u,maxZoom:a,nodeOrigin:d,nodeExtent:c,zIndexMode:f})=>L_((m,y)=>{async function w(){const{nodeLookup:x,panZoom:h,fitViewOptions:g,fitViewResolver:p,width:v,height:E,minZoom:_,maxZoom:N}=y();h&&(await dE({nodes:x,width:v,height:E,panZoom:h,minZoom:_,maxZoom:N},g),p==null||p.resolve(!0),m({fitViewResolver:null}))}return{...Md({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:l,minZoom:u,maxZoom:a,nodeOrigin:d,nodeExtent:c,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:x=>{const{nodeLookup:h,parentLookup:g,nodeOrigin:p,elevateNodesOnSelect:v,fitViewQueued:E,zIndexMode:_}=y(),N=Uu(x,h,g,{nodeOrigin:p,nodeExtent:c,elevateNodesOnSelect:v,checkEquality:!0,zIndexMode:_});E&&N?(w(),m({nodes:x,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0})):m({nodes:x,nodesInitialized:N})},setEdges:x=>{const{connectionLookup:h,edgeLookup:g}=y();Xg(h,g,x),m({edges:x})},setDefaultNodesAndEdges:(x,h)=>{if(x){const{setNodes:g}=y();g(x),m({hasDefaultNodes:!0})}if(h){const{setEdges:g}=y();g(h),m({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:h,nodeLookup:g,parentLookup:p,domNode:v,nodeOrigin:E,nodeExtent:_,debug:N,fitViewQueued:P,zIndexMode:L}=y(),{changes:j,updatedInternals:z}=DE(x,g,p,v,E,_,L);z&&(LE(g,p,{nodeOrigin:E,nodeExtent:_,zIndexMode:L}),P?(w(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(j==null?void 0:j.length)>0&&(N&&console.log("React Flow: trigger node changes",j),h==null||h(j)))},updateNodePositions:(x,h=!1)=>{const g=[];let p=[];const{nodeLookup:v,triggerNodeChanges:E,connection:_,updateConnection:N,onNodesChangeMiddlewareMap:P}=y();for(const[L,j]of x){const z=v.get(L),R=!!(z!=null&&z.expandParent&&(z!=null&&z.parentId)&&(j!=null&&j.position)),H={id:L,type:"position",position:R?{x:Math.max(0,j.position.x),y:Math.max(0,j.position.y)}:j.position,dragging:h};if(z&&_.inProgress&&_.fromNode.id===z.id){const C=Rn(z,_.fromHandle,G.Left,!0);N({..._,from:C})}R&&z.parentId&&g.push({id:L,parentId:z.parentId,rect:{...j.internals.positionAbsolute,width:j.measured.width??0,height:j.measured.height??0}}),p.push(H)}if(g.length>0){const{parentLookup:L,nodeOrigin:j}=y(),z=rc(g,v,L,j);p.push(...z)}for(const L of P.values())p=L(p);E(p)},triggerNodeChanges:x=>{const{onNodesChange:h,setNodes:g,nodes:p,hasDefaultNodes:v,debug:E}=y();if(x!=null&&x.length){if(v){const _=dm(x,p);g(_)}E&&console.log("React Flow: trigger node changes",x),h==null||h(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:h,setEdges:g,edges:p,hasDefaultEdges:v,debug:E}=y();if(x!=null&&x.length){if(v){const _=hm(x,p);g(_)}E&&console.log("React Flow: trigger edge changes",x),h==null||h(x)}},addSelectedNodes:x=>{const{multiSelectionActive:h,edgeLookup:g,nodeLookup:p,triggerNodeChanges:v,triggerEdgeChanges:E}=y();if(h){const _=x.map(N=>yn(N,!0));v(_);return}v(tr(p,new Set([...x]),!0)),E(tr(g))},addSelectedEdges:x=>{const{multiSelectionActive:h,edgeLookup:g,nodeLookup:p,triggerNodeChanges:v,triggerEdgeChanges:E}=y();if(h){const _=x.map(N=>yn(N,!0));E(_);return}E(tr(g,new Set([...x]))),v(tr(p,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:h}={})=>{const{edges:g,nodes:p,nodeLookup:v,triggerNodeChanges:E,triggerEdgeChanges:_}=y(),N=x||p,P=h||g,L=[];for(const z of N){if(!z.selected)continue;const R=v.get(z.id);R&&(R.selected=!1),L.push(yn(z.id,!1))}const j=[];for(const z of P)z.selected&&j.push(yn(z.id,!1));E(L),_(j)},setMinZoom:x=>{const{panZoom:h,maxZoom:g}=y();h==null||h.setScaleExtent([x,g]),m({minZoom:x})},setMaxZoom:x=>{const{panZoom:h,minZoom:g}=y();h==null||h.setScaleExtent([g,x]),m({maxZoom:x})},setTranslateExtent:x=>{var h;(h=y().panZoom)==null||h.setTranslateExtent(x),m({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:h,triggerNodeChanges:g,triggerEdgeChanges:p,elementsSelectable:v}=y();if(!v)return;const E=h.reduce((N,P)=>P.selected?[...N,yn(P.id,!1)]:N,[]),_=x.reduce((N,P)=>P.selected?[...N,yn(P.id,!1)]:N,[]);g(E),p(_)},setNodeExtent:x=>{const{nodes:h,nodeLookup:g,parentLookup:p,nodeOrigin:v,elevateNodesOnSelect:E,nodeExtent:_,zIndexMode:N}=y();x[0][0]===_[0][0]&&x[0][1]===_[0][1]&&x[1][0]===_[1][0]&&x[1][1]===_[1][1]||(Uu(h,g,p,{nodeOrigin:v,nodeExtent:x,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:N}),m({nodeExtent:x}))},panBy:x=>{const{transform:h,width:g,height:p,panZoom:v,translateExtent:E}=y();return FE({delta:x,panZoom:v,transform:h,translateExtent:E,width:g,height:p})},setCenter:async(x,h,g)=>{const{width:p,height:v,maxZoom:E,panZoom:_}=y();if(!_)return Promise.resolve(!1);const N=typeof(g==null?void 0:g.zoom)<"u"?g.zoom:E;return await _.setViewport({x:p/2-x*N,y:v/2-h*N,zoom:N},{duration:g==null?void 0:g.duration,ease:g==null?void 0:g.ease,interpolate:g==null?void 0:g.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...Pg}})},updateConnection:x=>{m({connection:x})},reset:()=>m({...Md()})}},Object.is);function Om({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:l,initialFitViewOptions:u,fitView:a,nodeOrigin:d,nodeExtent:c,zIndexMode:f,children:m}){const[y]=$.useState(()=>pk({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:a,minZoom:s,maxZoom:l,fitViewOptions:u,nodeOrigin:d,nodeExtent:c,zIndexMode:f}));return M.jsx(A_,{value:y,children:M.jsx(n2,{children:m})})}function gk({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:l,fitViewOptions:u,minZoom:a,maxZoom:d,nodeOrigin:c,nodeExtent:f,zIndexMode:m}){return $.useContext(Gs)?M.jsx(M.Fragment,{children:e}):M.jsx(Om,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:l,initialFitViewOptions:u,initialMinZoom:a,initialMaxZoom:d,nodeOrigin:c,nodeExtent:f,zIndexMode:m,children:e})}const mk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function yk({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:l,onEdgeClick:u,onInit:a,onMove:d,onMoveStart:c,onMoveEnd:f,onConnect:m,onConnectStart:y,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:h,onNodeMouseEnter:g,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:_,onNodeDragStart:N,onNodeDrag:P,onNodeDragStop:L,onNodesDelete:j,onEdgesDelete:z,onDelete:R,onSelectionChange:H,onSelectionDragStart:C,onSelectionDrag:A,onSelectionDragStop:I,onSelectionContextMenu:D,onSelectionStart:k,onSelectionEnd:S,onBeforeDelete:T,connectionMode:O,connectionLineType:F=Gt.Bezier,connectionLineStyle:W,connectionLineComponent:V,connectionLineContainerStyle:U,deleteKeyCode:Y="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:B=!1,selectionMode:K=Io.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:J=Lo()?"Meta":"Control",zoomActivationKeyCode:q=Lo()?"Meta":"Control",snapToGrid:Z,snapGrid:ie,onlyRenderVisibleElements:ue=!1,selectNodesOnDrag:oe,nodesDraggable:Pe,autoPanOnNodeFocus:Vt,nodesConnectable:Nt,nodesFocusable:pn,nodeOrigin:Ir=cm,edgesFocusable:zr,edgesReconnectable:Lr,elementsSelectable:el=!0,defaultViewport:Yo=Y_,minZoom:Fn=.5,maxZoom:Ar=2,translateExtent:uc=To,preventScrolling:e0=!0,nodeExtent:tl,defaultMarkerColor:t0="#b1b1b7",zoomOnScroll:n0=!0,zoomOnPinch:r0=!0,panOnScroll:o0=!1,panOnScrollSpeed:i0=.5,panOnScrollMode:s0=Cn.Free,zoomOnDoubleClick:l0=!0,panOnDrag:u0=!0,onPaneClick:a0,onPaneMouseEnter:c0,onPaneMouseMove:f0,onPaneMouseLeave:d0,onPaneScroll:h0,onPaneContextMenu:p0,paneClickDistance:g0=1,nodeClickDistance:m0=0,children:y0,onReconnect:v0,onReconnectStart:w0,onReconnectEnd:x0,onEdgeContextMenu:S0,onEdgeDoubleClick:E0,onEdgeMouseEnter:_0,onEdgeMouseMove:k0,onEdgeMouseLeave:C0,reconnectRadius:N0=10,onNodesChange:M0,onEdgesChange:P0,noDragClassName:T0="nodrag",noWheelClassName:I0="nowheel",noPanClassName:ac="nopan",fitView:cc,fitViewOptions:fc,connectOnClick:z0,attributionPosition:L0,proOptions:A0,defaultEdgeOptions:R0,elevateNodesOnSelect:$0=!0,elevateEdgesOnSelect:D0=!1,disableKeyboardA11y:dc=!1,autoPanOnConnect:F0,autoPanOnNodeDrag:O0,autoPanSpeed:j0,connectionRadius:H0,isValidConnection:V0,onError:b0,style:B0,id:hc,nodeDragThreshold:W0,connectionDragThreshold:U0,viewport:Y0,onViewportChange:X0,width:Q0,height:G0,colorMode:K0="light",debug:Z0,onScroll:Xo,ariaLabelConfig:q0,zIndexMode:pc="basic",...J0},ey){const nl=hc||"1",ty=K_(K0),ny=$.useCallback(gc=>{gc.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Xo==null||Xo(gc)},[Xo]);return M.jsx("div",{"data-testid":"rf__wrapper",...J0,onScroll:ny,style:{...B0,...mk},ref:ey,className:xe(["react-flow",o,ty]),id:hc,role:"application",children:M.jsxs(gk,{nodes:e,edges:t,width:Q0,height:G0,fitView:cc,fitViewOptions:fc,minZoom:Fn,maxZoom:Ar,nodeOrigin:Ir,nodeExtent:tl,zIndexMode:pc,children:[M.jsx(hk,{onInit:a,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:g,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:_,nodeTypes:i,edgeTypes:s,connectionLineType:F,connectionLineStyle:W,connectionLineComponent:V,connectionLineContainerStyle:U,selectionKeyCode:Q,selectionOnDrag:B,selectionMode:K,deleteKeyCode:Y,multiSelectionKeyCode:J,panActivationKeyCode:ee,zoomActivationKeyCode:q,onlyRenderVisibleElements:ue,defaultViewport:Yo,translateExtent:uc,minZoom:Fn,maxZoom:Ar,preventScrolling:e0,zoomOnScroll:n0,zoomOnPinch:r0,zoomOnDoubleClick:l0,panOnScroll:o0,panOnScrollSpeed:i0,panOnScrollMode:s0,panOnDrag:u0,onPaneClick:a0,onPaneMouseEnter:c0,onPaneMouseMove:f0,onPaneMouseLeave:d0,onPaneScroll:h0,onPaneContextMenu:p0,paneClickDistance:g0,nodeClickDistance:m0,onSelectionContextMenu:D,onSelectionStart:k,onSelectionEnd:S,onReconnect:v0,onReconnectStart:w0,onReconnectEnd:x0,onEdgeContextMenu:S0,onEdgeDoubleClick:E0,onEdgeMouseEnter:_0,onEdgeMouseMove:k0,onEdgeMouseLeave:C0,reconnectRadius:N0,defaultMarkerColor:t0,noDragClassName:T0,noWheelClassName:I0,noPanClassName:ac,rfId:nl,disableKeyboardA11y:dc,nodeExtent:tl,viewport:Y0,onViewportChange:X0}),M.jsx(G_,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:y,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:h,nodesDraggable:Pe,autoPanOnNodeFocus:Vt,nodesConnectable:Nt,nodesFocusable:pn,edgesFocusable:zr,edgesReconnectable:Lr,elementsSelectable:el,elevateNodesOnSelect:$0,elevateEdgesOnSelect:D0,minZoom:Fn,maxZoom:Ar,nodeExtent:tl,onNodesChange:M0,onEdgesChange:P0,snapToGrid:Z,snapGrid:ie,connectionMode:O,translateExtent:uc,connectOnClick:z0,defaultEdgeOptions:R0,fitView:cc,fitViewOptions:fc,onNodesDelete:j,onEdgesDelete:z,onDelete:R,onNodeDragStart:N,onNodeDrag:P,onNodeDragStop:L,onSelectionDrag:A,onSelectionDragStart:C,onSelectionDragStop:I,onMove:d,onMoveStart:c,onMoveEnd:f,noPanClassName:ac,nodeOrigin:Ir,rfId:nl,autoPanOnConnect:F0,autoPanOnNodeDrag:O0,autoPanSpeed:j0,onError:b0,connectionRadius:H0,isValidConnection:V0,selectNodesOnDrag:oe,nodeDragThreshold:W0,connectionDragThreshold:U0,onBeforeDelete:T,debug:Z0,ariaLabelConfig:q0,zIndexMode:pc}),M.jsx(U_,{onSelectionChange:H}),y0,M.jsx(H_,{proOptions:A0,position:L0}),M.jsx(j_,{rfId:nl,disableKeyboardA11y:dc})]})})}var vk=pm(yk);function wk(e){const[t,n]=$.useState(e),r=$.useCallback(o=>n(i=>dm(o,i)),[]);return[t,n,r]}function xk(e){const[t,n]=$.useState(e),r=$.useCallback(o=>n(i=>hm(o,i)),[]);return[t,n,r]}function Sk({dimensions:e,lineWidth:t,variant:n,className:r}){return M.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:xe(["react-flow__background-pattern",n,r])})}function Ek({radius:e,className:t}){return M.jsx("circle",{cx:e,cy:e,r:e,className:xe(["react-flow__background-pattern","dots",t])})}var ln;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ln||(ln={}));const _k={[ln.Dots]:1,[ln.Lines]:1,[ln.Cross]:6},kk=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function jm({id:e,variant:t=ln.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:l,style:u,className:a,patternClassName:d}){const c=$.useRef(null),{transform:f,patternId:m}=ne(kk,de),y=r||_k[t],w=t===ln.Dots,x=t===ln.Cross,h=Array.isArray(n)?n:[n,n],g=[h[0]*f[2]||1,h[1]*f[2]||1],p=y*f[2],v=Array.isArray(i)?i:[i,i],E=x?[p,p]:g,_=[v[0]*f[2]||1+E[0]/2,v[1]*f[2]||1+E[1]/2],N=`${m}${e||""}`;return M.jsxs("svg",{className:xe(["react-flow__background",a]),style:{...u,...Zs,"--xy-background-color-props":l,"--xy-background-pattern-color-props":s},ref:c,"data-testid":"rf__background",children:[M.jsx("pattern",{id:N,x:f[0]%g[0],y:f[1]%g[1],width:g[0],height:g[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:w?M.jsx(Ek,{radius:p/2,className:d}):M.jsx(Sk,{dimensions:E,lineWidth:o,variant:t,className:d})}),M.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${N})`})]})}jm.displayName="Background";const Ck=$.memo(jm);function Nk(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:M.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Mk(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:M.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Pk(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:M.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Tk(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:M.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Ik(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:M.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function wi({children:e,className:t,...n}){return M.jsx("button",{type:"button",className:xe(["react-flow__controls-button",t]),...n,children:e})}const zk=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Hm({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:l,onInteractiveChange:u,className:a,children:d,position:c="bottom-left",orientation:f="vertical","aria-label":m}){const y=he(),{isInteractive:w,minZoomReached:x,maxZoomReached:h,ariaLabelConfig:g}=ne(zk,de),{zoomIn:p,zoomOut:v,fitView:E}=Uo(),_=()=>{p(),i==null||i()},N=()=>{v(),s==null||s()},P=()=>{E(o),l==null||l()},L=()=>{y.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),u==null||u(!w)},j=f==="horizontal"?"horizontal":"vertical";return M.jsxs(Ks,{className:xe(["react-flow__controls",j,a]),position:c,style:e,"data-testid":"rf__controls","aria-label":m??g["controls.ariaLabel"],children:[t&&M.jsxs(M.Fragment,{children:[M.jsx(wi,{onClick:_,className:"react-flow__controls-zoomin",title:g["controls.zoomIn.ariaLabel"],"aria-label":g["controls.zoomIn.ariaLabel"],disabled:h,children:M.jsx(Nk,{})}),M.jsx(wi,{onClick:N,className:"react-flow__controls-zoomout",title:g["controls.zoomOut.ariaLabel"],"aria-label":g["controls.zoomOut.ariaLabel"],disabled:x,children:M.jsx(Mk,{})})]}),n&&M.jsx(wi,{className:"react-flow__controls-fitview",onClick:P,title:g["controls.fitView.ariaLabel"],"aria-label":g["controls.fitView.ariaLabel"],children:M.jsx(Pk,{})}),r&&M.jsx(wi,{className:"react-flow__controls-interactive",onClick:L,title:g["controls.interactive.ariaLabel"],"aria-label":g["controls.interactive.ariaLabel"],children:w?M.jsx(Ik,{}):M.jsx(Tk,{})}),d]})}Hm.displayName="Controls";const Lk=$.memo(Hm);function Ak({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:l,strokeWidth:u,className:a,borderRadius:d,shapeRendering:c,selected:f,onClick:m}){const{background:y,backgroundColor:w}=i||{},x=s||y||w;return M.jsx("rect",{className:xe(["react-flow__minimap-node",{selected:f},a]),x:t,y:n,rx:d,ry:d,width:r,height:o,style:{fill:x,stroke:l,strokeWidth:u},shapeRendering:c,onClick:m?h=>m(h,e):void 0})}const Rk=$.memo(Ak),$k=e=>e.nodes.map(t=>t.id),Ol=e=>e instanceof Function?e:()=>e;function Dk({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Rk,onClick:s}){const l=ne($k,de),u=Ol(t),a=Ol(e),d=Ol(n),c=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return M.jsx(M.Fragment,{children:l.map(f=>M.jsx(Ok,{id:f,nodeColorFunc:u,nodeStrokeColorFunc:a,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:c},f))})}function Fk({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:l,onClick:u}){const{node:a,x:d,y:c,width:f,height:m}=ne(y=>{const w=y.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const x=w.internals.userNode,{x:h,y:g}=w.internals.positionAbsolute,{width:p,height:v}=Ht(x);return{node:x,x:h,y:g,width:p,height:v}},de);return!a||a.hidden||!Dg(a)?null:M.jsx(l,{x:d,y:c,width:f,height:m,style:a.style,selected:!!a.selected,className:r(a),color:t(a),borderRadius:o,strokeColor:n(a),strokeWidth:i,shapeRendering:s,onClick:u,id:a.id})}const Ok=$.memo(Fk);var jk=$.memo(Dk);const Hk=200,Vk=150,bk=e=>!e.hidden,Bk=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?$g(bo(e.nodeLookup,{filter:bk}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Wk="react-flow__minimap-desc";function Vm({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:l,bgColor:u,maskColor:a,maskStrokeColor:d,maskStrokeWidth:c,position:f="bottom-right",onClick:m,onNodeClick:y,pannable:w=!1,zoomable:x=!1,ariaLabel:h,inversePan:g,zoomStep:p=1,offsetScale:v=5}){const E=he(),_=$.useRef(null),{boundingRect:N,viewBB:P,rfId:L,panZoom:j,translateExtent:z,flowWidth:R,flowHeight:H,ariaLabelConfig:C}=ne(Bk,de),A=(e==null?void 0:e.width)??Hk,I=(e==null?void 0:e.height)??Vk,D=N.width/A,k=N.height/I,S=Math.max(D,k),T=S*A,O=S*I,F=v*S,W=N.x-(T-N.width)/2-F,V=N.y-(O-N.height)/2-F,U=T+F*2,Y=O+F*2,Q=`${Wk}-${L}`,B=$.useRef(0),K=$.useRef();B.current=S,$.useEffect(()=>{if(_.current&&j)return K.current=YE({domNode:_.current,panZoom:j,getTransform:()=>E.getState().transform,getViewScale:()=>B.current}),()=>{var Z;(Z=K.current)==null||Z.destroy()}},[j]),$.useEffect(()=>{var Z;(Z=K.current)==null||Z.update({translateExtent:z,width:R,height:H,inversePan:g,pannable:w,zoomStep:p,zoomable:x})},[w,x,g,p,z,R,H]);const ee=m?Z=>{var oe;const[ie,ue]=((oe=K.current)==null?void 0:oe.pointer(Z))||[0,0];m(Z,{x:ie,y:ue})}:void 0,J=y?$.useCallback((Z,ie)=>{const ue=E.getState().nodeLookup.get(ie).internals.userNode;y(Z,ue)},[]):void 0,q=h??C["minimap.ariaLabel"];return M.jsx(Ks,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof c=="number"?c*S:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:xe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:M.jsxs("svg",{width:A,height:I,viewBox:`${W} ${V} ${U} ${Y}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Q,ref:_,onClick:ee,children:[q&&M.jsx("title",{id:Q,children:q}),M.jsx(jk,{onClick:J,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:l}),M.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-F},${V-F}h${U+F*2}v${Y+F*2}h${-U-F*2}z
+ M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Vm.displayName="MiniMap";const Uk=$.memo(Vm),Yk=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Xk={[kr.Line]:"right",[kr.Handle]:"bottom-right"};function Qk({nodeId:e,position:t,variant:n=kr.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:l=10,minHeight:u=10,maxWidth:a=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:f,autoScale:m=!0,shouldResize:y,onResizeStart:w,onResize:x,onResizeEnd:h}){const g=vm(),p=typeof e=="string"?e:g,v=he(),E=$.useRef(null),_=n===kr.Handle,N=ne($.useCallback(Yk(_&&m),[_,m]),de),P=$.useRef(null),L=t??Xk[n];$.useEffect(()=>{if(!(!E.current||!p))return P.current||(P.current=s_({domNode:E.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:z,transform:R,snapGrid:H,snapToGrid:C,nodeOrigin:A,domNode:I}=v.getState();return{nodeLookup:z,transform:R,snapGrid:H,snapToGrid:C,nodeOrigin:A,paneDomNode:I}},onChange:(z,R)=>{const{triggerNodeChanges:H,nodeLookup:C,parentLookup:A,nodeOrigin:I}=v.getState(),D=[],k={x:z.x,y:z.y},S=C.get(p);if(S&&S.expandParent&&S.parentId){const T=S.origin??I,O=z.width??S.measured.width??0,F=z.height??S.measured.height??0,W={id:S.id,parentId:S.parentId,rect:{width:O,height:F,...Fg({x:z.x??S.position.x,y:z.y??S.position.y},{width:O,height:F},S.parentId,C,T)}},V=rc([W],C,A,I);D.push(...V),k.x=z.x?Math.max(T[0]*O,z.x):void 0,k.y=z.y?Math.max(T[1]*F,z.y):void 0}if(k.x!==void 0&&k.y!==void 0){const T={id:p,type:"position",position:{...k}};D.push(T)}if(z.width!==void 0&&z.height!==void 0){const O={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:z.width,height:z.height}};D.push(O)}for(const T of R){const O={...T,type:"position"};D.push(O)}H(D)},onEnd:({width:z,height:R})=>{const H={id:p,type:"dimensions",resizing:!1,dimensions:{width:z,height:R}};v.getState().triggerNodeChanges([H])}})),P.current.update({controlPosition:L,boundaries:{minWidth:l,minHeight:u,maxWidth:a,maxHeight:d},keepAspectRatio:c,resizeDirection:f,onResizeStart:w,onResize:x,onResizeEnd:h,shouldResize:y}),()=>{var z;(z=P.current)==null||z.destroy()}},[L,l,u,a,d,c,w,x,h,y]);const j=L.split("-");return M.jsx("div",{className:xe(["react-flow__resize-control","nodrag",...j,n,r]),ref:E,style:{...o,scale:N,...s&&{[_?"backgroundColor":"borderColor"]:s}},children:i})}$.memo(Qk);function Gk(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}const Kk=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function un(e){const t=[];for(let n=0,r=e.length;nWe||e.height>We)&&(e.width>We&&e.height>We?e.width>e.height?(e.height*=We/e.width,e.width=We):(e.width*=We/e.height,e.height=We):e.width>We?(e.height*=We/e.width,e.width=We):(e.width*=We/e.height,e.height=We))}function Ss(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function tC(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function nC(e,t,n){const r="http://www.w3.org/2000/svg",o=document.createElementNS(r,"svg"),i=document.createElementNS(r,"foreignObject");return o.setAttribute("width",`${t}`),o.setAttribute("height",`${n}`),o.setAttribute("viewBox",`0 0 ${t} ${n}`),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("externalResourcesRequired","true"),o.appendChild(i),i.appendChild(e),tC(o)}const Be=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Be(n,t)};function rC(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function oC(e,t){return bm(t).map(n=>{const r=e.getPropertyValue(n),o=e.getPropertyPriority(n);return`${n}: ${r}${o?" !important":""};`}).join(" ")}function iC(e,t,n,r){const o=`.${e}:${t}`,i=n.cssText?rC(n):oC(n,r);return document.createTextNode(`${o}{${i}}`)}function Pd(e,t,n,r){const o=window.getComputedStyle(e,n),i=o.getPropertyValue("content");if(i===""||i==="none")return;const s=Kk();try{t.className=`${t.className} ${s}`}catch{return}const l=document.createElement("style");l.appendChild(iC(s,n,o,r)),t.appendChild(l)}function sC(e,t,n){Pd(e,t,":before",n),Pd(e,t,":after",n)}const Td="application/font-woff",Id="image/jpeg",lC={woff:Td,woff2:Td,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Id,jpeg:Id,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function uC(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function ic(e){const t=uC(e).toLowerCase();return lC[t]||""}function aC(e){return e.split(/,/)[1]}function Qu(e){return e.search(/^(data:)/)!==-1}function cC(e,t){return`data:${t};base64,${e}`}async function Wm(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const o=await r.blob();return new Promise((i,s)=>{const l=new FileReader;l.onerror=s,l.onloadend=()=>{try{i(n({res:r,result:l.result}))}catch(u){s(u)}},l.readAsDataURL(o)})}const jl={};function fC(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function sc(e,t,n){const r=fC(e,t,n.includeQueryParams);if(jl[r]!=null)return jl[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let o;try{const i=await Wm(e,n.fetchRequestInit,({res:s,result:l})=>(t||(t=s.headers.get("Content-Type")||""),aC(l)));o=cC(i,t)}catch(i){o=n.imagePlaceholder||"";let s=`Failed to fetch resource: ${e}`;i&&(s=typeof i=="string"?i:i.message),s&&console.warn(s)}return jl[r]=o,o}async function dC(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):Ss(t)}async function hC(e,t){if(e.currentSrc){const i=document.createElement("canvas"),s=i.getContext("2d");i.width=e.clientWidth,i.height=e.clientHeight,s==null||s.drawImage(e,0,0,i.width,i.height);const l=i.toDataURL();return Ss(l)}const n=e.poster,r=ic(n),o=await sc(n,r,t);return Ss(o)}async function pC(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await Js(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function gC(e,t){return Be(e,HTMLCanvasElement)?dC(e):Be(e,HTMLVideoElement)?hC(e,t):Be(e,HTMLIFrameElement)?pC(e,t):e.cloneNode(Um(e))}const mC=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",Um=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function yC(e,t,n){var r,o;if(Um(t))return t;let i=[];return mC(e)&&e.assignedNodes?i=un(e.assignedNodes()):Be(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?i=un(e.contentDocument.body.childNodes):i=un(((o=e.shadowRoot)!==null&&o!==void 0?o:e).childNodes),i.length===0||Be(e,HTMLVideoElement)||await i.reduce((s,l)=>s.then(()=>Js(l,n)).then(u=>{u&&t.appendChild(u)}),Promise.resolve()),t}function vC(e,t,n){const r=t.style;if(!r)return;const o=window.getComputedStyle(e);o.cssText?(r.cssText=o.cssText,r.transformOrigin=o.transformOrigin):bm(n).forEach(i=>{let s=o.getPropertyValue(i);i==="font-size"&&s.endsWith("px")&&(s=`${Math.floor(parseFloat(s.substring(0,s.length-2)))-.1}px`),Be(e,HTMLIFrameElement)&&i==="display"&&s==="inline"&&(s="block"),i==="d"&&t.getAttribute("d")&&(s=`path(${t.getAttribute("d")})`),r.setProperty(i,s,o.getPropertyPriority(i))})}function wC(e,t){Be(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Be(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function xC(e,t){if(Be(e,HTMLSelectElement)){const n=t,r=Array.from(n.children).find(o=>e.value===o.getAttribute("value"));r&&r.setAttribute("selected","")}}function SC(e,t,n){return Be(t,Element)&&(vC(e,t,n),sC(e,t,n),wC(e,t),xC(e,t)),t}async function EC(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let i=0;igC(r,t)).then(r=>yC(e,r,t)).then(r=>SC(e,r,t)).then(r=>EC(r,t))}const Ym=/url\((['"]?)([^'"]+?)\1\)/g,_C=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,kC=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function CC(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function NC(e){const t=[];return e.replace(Ym,(n,r,o)=>(t.push(o),n)),t.filter(n=>!Qu(n))}async function MC(e,t,n,r,o){try{const i=n?Gk(t,n):t,s=ic(t);let l;return o||(l=await sc(i,s,r)),e.replace(CC(t),`$1${l}$3`)}catch{}return e}function PC(e,{preferredFontFormat:t}){return t?e.replace(kC,n=>{for(;;){const[r,,o]=_C.exec(n)||[];if(!o)return"";if(o===t)return`src: ${r};`}}):e}function Xm(e){return e.search(Ym)!==-1}async function Qm(e,t,n){if(!Xm(e))return e;const r=PC(e,n);return NC(r).reduce((i,s)=>i.then(l=>MC(l,s,t,n)),Promise.resolve(r))}async function Vn(e,t,n){var r;const o=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(o){const i=await Qm(o,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function TC(e,t){await Vn("background",e,t)||await Vn("background-image",e,t),await Vn("mask",e,t)||await Vn("-webkit-mask",e,t)||await Vn("mask-image",e,t)||await Vn("-webkit-mask-image",e,t)}async function IC(e,t){const n=Be(e,HTMLImageElement);if(!(n&&!Qu(e.src))&&!(Be(e,SVGImageElement)&&!Qu(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,o=await sc(r,ic(r),t);await new Promise((i,s)=>{e.onload=i,e.onerror=t.onImageErrorHandler?(...u)=>{try{i(t.onImageErrorHandler(...u))}catch(a){s(a)}}:s;const l=e;l.decode&&(l.decode=i),l.loading==="lazy"&&(l.loading="eager"),n?(e.srcset="",e.src=o):e.href.baseVal=o})}async function zC(e,t){const r=un(e.childNodes).map(o=>Gm(o,t));await Promise.all(r).then(()=>e)}async function Gm(e,t){Be(e,Element)&&(await TC(e,t),await IC(e,t),await zC(e,t))}function LC(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(o=>{n[o]=r[o]}),e}const zd={};async function Ld(e){let t=zd[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},zd[e]=t,t}async function Ad(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async s=>{let l=s.replace(r,"$1");return l.startsWith("https://")||(l=new URL(l,e.url).href),Wm(l,t.fetchRequestInit,({result:u})=>(n=n.replace(s,`url(${u})`),[s,u]))});return Promise.all(i).then(()=>n)}function Rd(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const o=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const u=o.exec(r);if(u===null)break;t.push(u[0])}r=r.replace(o,"");const i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",l=new RegExp(s,"gi");for(;;){let u=i.exec(r);if(u===null){if(u=l.exec(r),u===null)break;i.lastIndex=l.lastIndex}else l.lastIndex=i.lastIndex;t.push(u[0])}return t}async function AC(e,t){const n=[],r=[];return e.forEach(o=>{if("cssRules"in o)try{un(o.cssRules||[]).forEach((i,s)=>{if(i.type===CSSRule.IMPORT_RULE){let l=s+1;const u=i.href,a=Ld(u).then(d=>Ad(d,t)).then(d=>Rd(d).forEach(c=>{try{o.insertRule(c,c.startsWith("@import")?l+=1:o.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:c,error:f})}})).catch(d=>{console.error("Error loading remote css",d.toString())});r.push(a)}})}catch(i){const s=e.find(l=>l.href==null)||document.styleSheets[0];o.href!=null&&r.push(Ld(o.href).then(l=>Ad(l,t)).then(l=>Rd(l).forEach(u=>{s.insertRule(u,s.cssRules.length)})).catch(l=>{console.error("Error loading remote stylesheet",l)})),console.error("Error inlining remote css file",i)}}),Promise.all(r).then(()=>(e.forEach(o=>{if("cssRules"in o)try{un(o.cssRules||[]).forEach(i=>{n.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${o.href}`,i)}}),n))}function RC(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>Xm(t.style.getPropertyValue("src")))}async function $C(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=un(e.ownerDocument.styleSheets),r=await AC(n,t);return RC(r)}function Km(e){return e.trim().replace(/["']/g,"")}function DC(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(i=>{t.add(Km(i))}),Array.from(r.children).forEach(i=>{i instanceof HTMLElement&&n(i)})}return n(e),t}async function FC(e,t){const n=await $C(e,t),r=DC(e);return(await Promise.all(n.filter(i=>r.has(Km(i.style.fontFamily))).map(i=>{const s=i.parentStyleSheet?i.parentStyleSheet.href:null;return Qm(i.cssText,s,t)}))).join(`
+`)}async function OC(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await FC(e,t);if(n){const r=document.createElement("style"),o=document.createTextNode(n);r.appendChild(o),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function jC(e,t={}){const{width:n,height:r}=Bm(e,t),o=await Js(e,t,!0);return await OC(o,t),await Gm(o,t),LC(o,t),await nC(o,n,r)}async function HC(e,t={}){const{width:n,height:r}=Bm(e,t),o=await jC(e,t),i=await Ss(o),s=document.createElement("canvas"),l=s.getContext("2d"),u=t.pixelRatio||Jk(),a=t.canvasWidth||n,d=t.canvasHeight||r;return s.width=a*u,s.height=d*u,t.skipAutoScale||eC(s),s.style.width=`${a}`,s.style.height=`${d}`,t.backgroundColor&&(l.fillStyle=t.backgroundColor,l.fillRect(0,0,s.width,s.height)),l.drawImage(i,0,0,s.width,s.height),s}async function VC(e,t={}){return(await HC(e,t)).toDataURL()}function bC(e,t){const n=Object.fromEntries(e.map(h=>[h.id,h])),r=h=>e.filter(g=>g.type===h),o=r("route");r("handler");const i=new Map;o.forEach(h=>{var g,p;i.set(h.id,{method:((g=h.data)==null?void 0:g.method)||"GET",path:((p=h.data)==null?void 0:p.path)||"/",middleware:[]})});const s=t.filter(h=>h.edgeType==="wraps"),l=new Map;s.forEach(h=>l.set(h.target,h.source)),o.forEach(h=>{var v;const g=[];let p=l.get(h.id);for(;p&&((v=n[p])==null?void 0:v.type)==="middleware";)g.unshift(n[p].data.name),p=l.get(p);g.length&&(i.get(h.id).middleware=g)});const u=new Map;t.filter(h=>h.edgeType==="extends").forEach(h=>{var v,E;const g=n[h.source],p=n[h.target];(v=g==null?void 0:g.data)!=null&&v.name&&((E=p==null?void 0:p.data)!=null&&E.name)&&u.set(g.data.name,p.data.name)});const d=t.filter(h=>h.edgeType==="handles"),c=new Map;d.forEach(h=>{var p;const g=n[h.target];if((p=g==null?void 0:g.data)!=null&&p.name){const v=[];let E=g.data.name;for(;E;)v.push(E),E=u.get(E);c.set(h.source,v)}}),o.forEach(h=>{c.has(h.id)||c.set(h.id,[])});const f=new Set;c.forEach(h=>h.forEach(g=>f.add(g)));const m=new Map;[...f].forEach(h=>{const g="class:"+h;m.set(g,{id:g,name:h,isAbstract:!0,routes:[],parentId:null,isLambda:!1})}),u.forEach((h,g)=>{const p="class:"+g,v="class:"+h;m.has(p)&&m.has(v)&&(m.get(p).parentId=v)}),c.forEach((h,g)=>{if(h.length===0){const p=i.get(g),v="class:Lambda:"+p.method+":"+encodeURIComponent(p.path);m.set(v,{id:v,name:"Lambda Handler",isAbstract:!1,isLambda:!0,method:p.method,path:p.path,routes:[{method:p.method,path:p.path,middleware:p.middleware}],parentId:null})}else{const v="class:"+h[0];if(m.has(v)){const E=m.get(v);E.isAbstract=!1;const _=i.get(g);E.routes.push({method:_.method,path:_.path,middleware:_.middleware})}}});const y=[...m.values()].map(h=>({id:h.id,type:"handler",data:{name:h.name,isAbstract:h.isAbstract,isLambda:h.isLambda,method:h.method,path:h.path,routes:h.routes,middleware:h.routes.length>0?[...new Set(h.routes.flatMap(g=>g.middleware))]:[]}})),w=new Set,x=[];return m.forEach((h,g)=>{if(h.parentId){const p=h.parentId+"->"+g;w.has(p)||(w.add(p),x.push({id:p,source:h.parentId,target:g,edgeType:"extends"}))}}),{nodes:y,edges:x}}const BC=60,Zm=12,WC=48,xi=60,$d=60,UC=160,YC=50,XC=260,QC=230,GC=80;function qm(e){var t;return(t=e.data)!=null&&t.isAbstract?UC:XC}function lc(e){var r,o,i,s,l;if((r=e.data)!=null&&r.isAbstract)return YC;const t=((i=(o=e.data)==null?void 0:o.routes)==null?void 0:i.length)||1,n=(((l=(s=e.data)==null?void 0:s.middleware)==null?void 0:l.length)||0)>0;return 53+t*22+(n?22:0)+20}function Es(e,t,n){const r=t.get(e)||[],o=lc(n[e]);if(!r.length)return o;const i=r.reduce((s,l,u)=>s+Es(l,t,n)+(u>0?Zm:0),0);return Math.max(o,i)}function Jm(e,t,n,r,o,i){const s=o[e],l=r.get(e)||[],u=lc(s),a=qm(s),d=Es(e,r,o);if(i.set(e,{x:t,y:n+(d-u)/2}),l.length){const c=t+a+BC;let f=n;l.forEach(m=>{const y=Es(m,r,o);Jm(m,c,f,r,o,i),f+=y+Zm})}}function KC(e,t){const n=e.filter(w=>{var x;return(x=w.data)==null?void 0:x.isLambda}),r=e.filter(w=>{var x;return!((x=w.data)!=null&&x.isLambda)}),o=Object.fromEntries(r.map(w=>[w.id,w])),i=new Map,s=new Set;t.forEach(w=>{w.edgeType==="extends"&&(i.has(w.source)||i.set(w.source,[]),i.get(w.source).push(w.target),s.add(w.target))});const l=r.filter(w=>!s.has(w.id)),u=new Map;let a=$d;l.forEach(w=>{const x=Es(w.id,i,o);Jm(w.id,xi,a,i,o,u),a+=x+WC});let d=-1/0,c=-1/0,f=1/0;const m=r.map(w=>{const x=u.get(w.id)||{x:xi,y:$d},h=x.x+qm(w),g=x.y+lc(w);return h>d&&(d=h),g>c&&(c=g),x.y{m.push({..._,position:{x:v+N%x*h,y:E+Math.floor(N/x)*g}})})}const y=t.filter(w=>w.edgeType==="extends").map((w,x)=>({...w,id:w.id||`ext-${x}`,type:"bezier",pathOptions:{curvature:.35},style:{stroke:"#2e3347",strokeWidth:1.5},markerEnd:{type:"arrowclosed",width:11,height:11,color:"#2e3347"},animated:!1}));return{nodes:m,edges:y}}const Si={GET:{bg:"#0d4429",color:"#4ade80"},POST:{bg:"#172554",color:"#60a5fa"},PUT:{bg:"#451a03",color:"#fb923c"},PATCH:{bg:"#2e1065",color:"#c084fc"},DELETE:{bg:"#450a0a",color:"#f87171"},OPTIONS:{bg:"#1c1917",color:"#a8a29e"},HEAD:{bg:"#1c1917",color:"#a8a29e"}},Hl=M.jsx(Nr,{type:"target",position:G.Left,style:{left:0,top:"50%",transform:"translateY(-50%)"}}),Vl=M.jsx(Nr,{type:"source",position:G.Right,style:{right:0,top:"50%",transform:"translateY(-50%)"}});function ZC({data:e,selected:t}){var n,r,o,i;if(e.isAbstract)return M.jsxs("div",{style:{background:"rgba(239,68,68,0.05)",border:t?"2px solid #60a5fa":"1px solid #ef4444",borderRadius:8,padding:"8px 14px",width:160,fontFamily:"system-ui, sans-serif",boxSizing:"border-box"},children:[Hl,Vl,M.jsx("div",{style:{fontSize:9,color:"#ef4444",fontWeight:700,letterSpacing:.5,marginBottom:3},children:"ABSTRACT"}),M.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e2e8f0",fontFamily:"monospace"},children:e.name})]});if(e.isLambda){const s=e.method||"GET",l=e.path||"/",u=Si[s]||Si.OPTIONS,a=l.replace(/\{([^}]+)\}/g,'{$1}');return M.jsxs("div",{style:{background:"#1a1d27",border:t?"2px solid #60a5fa":"1px solid #3b82f6",borderRadius:8,padding:"10px 12px",width:230,fontFamily:"system-ui, sans-serif",boxSizing:"border-box"},children:[Hl,Vl,M.jsx("div",{style:{fontSize:9,color:"#60a5fa",fontWeight:700,letterSpacing:.5,marginBottom:7},children:"LAMBDA"}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[M.jsx("span",{style:{background:u.bg,color:u.color,fontSize:9,fontWeight:700,padding:"2px 5px",borderRadius:3,fontFamily:"monospace",flexShrink:0},children:s}),M.jsx("span",{style:{fontSize:10,fontFamily:"monospace",color:"#8892a4"},dangerouslySetInnerHTML:{__html:a}})]}),((n=e.middleware)==null?void 0:n.length)>0&&M.jsx("div",{style:{display:"flex",gap:3,flexWrap:"wrap",marginTop:7},children:e.middleware.map(d=>M.jsx("span",{style:{background:"#1f1a0e",color:"#f6ad55",fontSize:8,fontWeight:600,padding:"1px 4px",borderRadius:2,fontFamily:"monospace"},children:d},d))})]})}return M.jsxs("div",{style:{background:"#1a1d27",border:t?"2px solid #60a5fa":"1px solid #3b82f6",borderRadius:8,padding:"10px 12px",width:260,fontFamily:"system-ui, sans-serif",boxSizing:"border-box"},children:[Hl,Vl,M.jsxs("div",{style:{marginBottom:8},children:[M.jsx("div",{style:{fontSize:9,color:"#60a5fa",fontWeight:700,letterSpacing:.5,marginBottom:2},children:"HANDLER"}),M.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#e2e8f0",fontFamily:"monospace"},children:e.name})]}),M.jsx("div",{style:{height:1,background:"#2e3347",marginBottom:8}}),M.jsx("div",{style:{marginBottom:((r=e.middleware)==null?void 0:r.length)>0?8:0},children:(o=e.routes)==null?void 0:o.map((s,l)=>{const u=Si[s.method]||Si.OPTIONS,a=(s.path||"/").replace(/\{([^}]+)\}/g,'{$1}');return M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:l0&&M.jsx("div",{style:{display:"flex",gap:3,flexWrap:"wrap"},children:e.middleware.map(s=>M.jsx("span",{style:{background:"#1f1a0e",color:"#f6ad55",fontSize:8,fontWeight:600,padding:"1px 4px",borderRadius:2,fontFamily:"monospace"},children:s},s))})]})}const qC={handler:ZC};function JC(e){const{getNodes:t}=Uo();$.useEffect(()=>{e.current=()=>{const n=t();if(!n.length)return;const r=zg(n),o=60,i=Math.max(1920,r.width+o*2),s=Math.max(1080,r.height+o*2),l=Ys(r,i,s,.1,4,o);VC(document.querySelector(".react-flow__viewport"),{backgroundColor:"#0f1117",width:i,height:s,style:{width:i+"px",height:s+"px",transform:`translate(${l.x}px,${l.y}px) scale(${l.zoom})`}}).then(u=>{const a=document.createElement("a");a.download="flash-routes.png",a.href=u,a.click()}).catch(console.error)}},[t,e])}function eN({styledNodes:e,styledEdges:t,onNodesChange:n,onEdgesChange:r,onNodeMouseEnter:o,onNodeMouseLeave:i,showLambdas:s,searchQuery:l,exportRef:u}){const{fitView:a}=Uo();return JC(u),$.useEffect(()=>{setTimeout(()=>a({padding:.15,duration:300}),50)},[s,l,a]),M.jsxs(vk,{nodes:e,edges:t,onNodesChange:n,onEdgesChange:r,onNodeMouseEnter:o,onNodeMouseLeave:i,nodeTypes:qC,fitView:!0,fitViewOptions:{padding:.15},colorMode:"dark",minZoom:.03,maxZoom:2,panOnDrag:!0,panOnScroll:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,zoomOnDoubleClick:!0,children:[M.jsx(Ck,{color:"#161822",gap:32,size:1}),M.jsx(Lk,{showInteractive:!1,style:{background:"#12141c",border:"1px solid #1e2235"}}),M.jsx(Uk,{style:{background:"#12141c",border:"1px solid #1e2235"},maskColor:"rgba(0,0,0,0.5)",nodeColor:d=>{var c;return(c=d.data)!=null&&c.isAbstract?"#ef444499":"#3b82f666"}})]})}function tN(){const[e,t]=$.useState([]),[n,r]=$.useState([]),[o,i,s]=wk([]),[l,u,a]=xk([]),[d,c]=$.useState(!0),[f,m]=$.useState(null),[y,w]=$.useState(null),[x,h]=$.useState(null),[g,p]=$.useState({nodes:new Set,edges:new Set}),[v,E]=$.useState(!1),[_,N]=$.useState(""),[P,L]=$.useState(!1),j=$.useRef(null);$.useEffect(()=>{fetch("/routeviewer/data").then(S=>{if(!S.ok)throw new Error(S.statusText);return S.json()}).then(S=>{const T=S.nodes.filter(U=>U.type==="route").length,{nodes:O,edges:F}=bC(S.nodes,S.edges),{nodes:W,edges:V}=KC(O,F);t(W),r(V),w({routes:T}),c(!1)}).catch(S=>{m(S.message),c(!1)})},[]);const z=$.useMemo(()=>{const S=new Map;return n.forEach(T=>{T.edgeType==="extends"&&S.set(T.target,T.source)}),T=>{const O=new Set;let F=S.get(T);for(;F;)O.add(F),F=S.get(F);return O}},[n]);$.useEffect(()=>{const S=_.trim().toLowerCase(),T=new Set(e.filter(V=>{var U;return(U=V.data)==null?void 0:U.isLambda}).map(V=>V.id));let O=new Set(e.map(V=>V.id));if(S){const V=new Set(e.filter(Y=>{var Q,B;return(((Q=Y.data)==null?void 0:Q.name)||"").toLowerCase().includes(S)||(((B=Y.data)==null?void 0:B.routes)||[]).some(K=>K.path.toLowerCase().includes(S))}).map(Y=>Y.id)),U=new Set(V);V.forEach(Y=>z(Y).forEach(Q=>U.add(Q))),O=U}const F=e.filter(V=>T.has(V.id)&&!v?!1:O.has(V.id)),W=new Set(F.map(V=>V.id));i(F),u(n.filter(V=>W.has(V.source)&&W.has(V.target)))},[v,_,e,n,i,u,z]);const R=$.useCallback((S,T)=>{const O=new Map;l.forEach(U=>{U.edgeType==="extends"&&O.set(U.target,{pid:U.source,eid:U.id})});const F=new Set([T.id]),W=new Set,V=[T.id];for(;V.length;){const U=V.shift(),Y=O.get(U);Y&&!F.has(Y.pid)&&(W.add(Y.eid),F.add(Y.pid),V.push(Y.pid))}h(T.id),p({nodes:F,edges:W})},[l]),H=$.useCallback(()=>{h(null),p({nodes:new Set,edges:new Set})},[]),C=o.map(S=>({...S,style:{opacity:x&&!g.nodes.has(S.id)?.1:1,transition:"opacity 0.15s"}})),A=l.map(S=>{const T={type:"bezier",pathOptions:{curvature:.35},style:{stroke:"#1e2235",strokeWidth:1.5},markerEnd:{type:xr.ArrowClosed,width:10,height:10,color:"#1e2235"}};return x?g.edges.has(S.id)?{...S,type:"bezier",pathOptions:{curvature:.35},style:{stroke:"#60a5fa",strokeWidth:2.5},markerEnd:{type:xr.ArrowClosed,width:13,height:13,color:"#60a5fa"}}:{...S,...T,style:{...T.style,opacity:.04}}:{...S,...T}}),I=e.filter(S=>{var T;return(T=S.data)==null?void 0:T.isLambda}).length,D=e.filter(S=>{var T;return!((T=S.data)!=null&&T.isLambda)}).length,k=$.useCallback(()=>{L(!0),setTimeout(()=>{var S;(S=j.current)==null||S.call(j),setTimeout(()=>L(!1),1200)},50)},[]);return M.jsxs("div",{style:{display:"flex",width:"100vw",height:"100vh",overflow:"hidden",background:"#0f1117"},children:[M.jsxs("aside",{style:{width:"240px",minWidth:"240px",flexShrink:0,display:"flex",flexDirection:"column",background:"#0c0e15",borderRight:"1px solid #1a1d2a",fontFamily:"system-ui, sans-serif",color:"#c8cfe0"},children:[M.jsx("div",{style:{padding:"14px 16px 12px",borderBottom:"1px solid #1a1d2a",display:"flex",alignItems:"center",gap:8},children:M.jsx("span",{style:{fontSize:15,fontWeight:700,letterSpacing:"-0.3px"},children:"⚡ Route Viewer"})}),M.jsxs("div",{style:{padding:"14px 14px",overflowY:"auto",flex:1},children:[M.jsxs(Ei,{label:"SEARCH",children:[M.jsx("input",{type:"text",placeholder:"handler or path…",value:_,onChange:S=>N(S.target.value),style:{width:"100%",boxSizing:"border-box",background:"#12141e",border:"1px solid #1e2235",borderRadius:5,padding:"6px 9px",color:"#c8cfe0",fontSize:12,fontFamily:"monospace",outline:"none"}}),_&&M.jsxs("div",{style:{fontSize:11,color:"#4a5370",marginTop:5},children:[o.length," node",o.length!==1?"s":""," visible"]})]}),M.jsxs(Ei,{label:"DISPLAY",children:[M.jsxs("label",{style:{display:"flex",alignItems:"center",gap:9,cursor:"pointer",fontSize:12},children:[M.jsx("input",{type:"checkbox",checked:v,onChange:S=>E(S.target.checked),style:{cursor:"pointer",accentColor:"#3b82f6"}}),M.jsx("span",{style:{color:"#8892a4"},children:"Show lambda handlers"})]}),M.jsxs("div",{style:{fontSize:11,color:"#343b54",marginTop:4,paddingLeft:21},children:[I," lambda",I!==1?"s":""]})]}),M.jsx(Ei,{label:"STATS",children:[["Routes",(y==null?void 0:y.routes)||0],["Handlers",D],["Lambdas",I]].map(([S,T])=>M.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,marginBottom:5},children:[M.jsx("span",{style:{color:"#4a5370"},children:S}),M.jsx("span",{style:{color:"#e2e8f0",fontWeight:600,fontFamily:"monospace"},children:T})]},S))}),M.jsx(Ei,{label:"LEGEND",children:[{dot:"#3b82f6",border:"#3b82f6",label:"Handler"},{dot:"#ef4444",border:"#ef4444",label:"Abstract"},{dot:"#f6ad55",border:"#f6ad55",label:"Middleware"}].map(({dot:S,label:T})=>M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[M.jsx("div",{style:{width:9,height:9,borderRadius:2,background:S,flexShrink:0,opacity:.8}}),M.jsx("span",{style:{fontSize:12,color:"#4a5370"},children:T})]},T))}),M.jsxs("div",{style:{fontSize:11,color:"#2d3347",lineHeight:1.65,marginTop:4},children:["Hover a node to trace its ancestry.",M.jsx("br",{}),"Search filters nodes + parents."]})]}),M.jsx("div",{style:{padding:"12px 14px",borderTop:"1px solid #1a1d2a"},children:M.jsx("button",{onClick:k,disabled:P||d,style:{width:"100%",padding:"8px 0",background:P?"#1e2235":"#12141e",border:"1px solid #1e2235",borderRadius:6,color:P?"#4a5370":"#8892a4",fontSize:12,cursor:P?"default":"pointer",fontFamily:"system-ui, sans-serif",transition:"all 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:P?"⏳ Exporting…":"⬇ Export PNG"})})]}),M.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"},children:[M.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"9px 18px",background:"#0c0e15",borderBottom:"1px solid #1a1d2a",flexShrink:0,zIndex:10},children:[M.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#e2e8f0",letterSpacing:"-0.2px"},children:"Flash Route Graph"}),M.jsx("span",{style:{marginLeft:"auto",display:"flex",gap:18,fontSize:11,color:"#2d3347",fontFamily:"system-ui"},children:[["#3b82f6","handler"],["#ef4444","abstract"],["#f6ad55","middleware"]].map(([S,T])=>M.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[M.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:S,display:"inline-block",opacity:.8}}),T]},T))})]}),d&&M.jsx("div",{className:"center muted",children:"Loading…"}),f&&M.jsxs("div",{className:"center error",children:["Error: ",f]}),!d&&!f&&M.jsx("div",{style:{flex:1,position:"relative"},children:M.jsx(Om,{children:M.jsx(eN,{styledNodes:C,styledEdges:A,onNodesChange:s,onEdgesChange:a,onNodeMouseEnter:R,onNodeMouseLeave:H,showLambdas:v,searchQuery:_,exportRef:j})})})]})]})}function Ei({label:e,children:t}){return M.jsxs("div",{style:{marginBottom:18},children:[M.jsx("div",{style:{fontSize:9,fontWeight:700,letterSpacing:1,color:"#272d42",marginBottom:8,fontFamily:"monospace"},children:e}),t]})}Gp(document.getElementById("root")).render(M.jsx($.StrictMode,{children:M.jsx(tN,{})}));
diff --git a/flash-extensions/flash-ext-routeviewer/src/main/resources/routeviewer/index.html b/flash-extensions/flash-ext-routeviewer/src/main/resources/routeviewer/index.html
new file mode 100644
index 0000000..bab0ef8
--- /dev/null
+++ b/flash-extensions/flash-ext-routeviewer/src/main/resources/routeviewer/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Flash Route Viewer
+
+
+
+
+
+
+
diff --git a/flash-extensions/pom.xml b/flash-extensions/pom.xml
index 2db5efc..c6d1f05 100644
--- a/flash-extensions/pom.xml
+++ b/flash-extensions/pom.xml
@@ -17,6 +17,7 @@
flash-ext-jacksonflash-ext-openapiflash-ext-oidc
+ flash-ext-routeviewer
diff --git a/flash/src/main/java/dev/relism/HttpServer.java b/flash/src/main/java/dev/relism/HttpServer.java
index ac1c2f5..2e67475 100644
--- a/flash/src/main/java/dev/relism/HttpServer.java
+++ b/flash/src/main/java/dev/relism/HttpServer.java
@@ -4,9 +4,8 @@ import dev.relism.fpr.core.ByteView;
import dev.relism.http.ContentType;
import dev.relism.http.HttpStatus;
import dev.relism.models.*;
-import dev.relism.routing.AbstractRouter;
+import dev.relism.extension.FlashConfiguration;
import dev.relism.routing.GlobalRouter;
-import dev.relism.routing.Middleware;
import lombok.extern.slf4j.Slf4j;
@@ -22,29 +21,32 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
- * Flash HTTP server. Owns a {@link GlobalRouter} with two routing tiers:
- * mounted sub-routers (matched by longest namespace prefix) and an internal
- * router as fallback. Error handlers are scoped to their respective router.
+ * Pure I/O transport layer. Owns the {@link ServerSocket}, the virtual-thread executor,
+ * and the keep-alive accept loop. All routing is delegated to the {@link GlobalRouter}
+ * supplied at construction time.
+ *
+ *
This class is package-private — use {@link dev.relism.extension.FlashApp} as the
+ * single entry point for creating and configuring a Flash server.
*/
@Slf4j
-public class HttpServer {
- private final HttpServerConfiguration configuration;
- private final ServerSocket serverSocket;
- private final GlobalRouter globalRouter;
+class HttpServer implements ServerHandle {
+
+ private final FlashConfiguration configuration;
+ private final ServerSocket serverSocket;
+ private final GlobalRouter globalRouter;
private final ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor();
private final Set activeSockets = ConcurrentHashMap.newKeySet();
private volatile boolean stopped = false;
private final CompletableFuture readyFuture = new CompletableFuture<>();
- private static final byte[] HTTP_1_1 = "HTTP/1.1 ".getBytes(StandardCharsets.UTF_8);
- private static final byte[] CRLF = "\r\n".getBytes(StandardCharsets.UTF_8);
- private static final byte[] CONTENT_TYPE = "Content-Type: ".getBytes(StandardCharsets.UTF_8);
- private static final byte[] CONTENT_LENGTH = "Content-Length: ".getBytes(StandardCharsets.UTF_8);
+ private static final byte[] HTTP_1_1 = "HTTP/1.1 ".getBytes(StandardCharsets.UTF_8);
+ private static final byte[] CRLF = "\r\n".getBytes(StandardCharsets.UTF_8);
+ private static final byte[] CONTENT_TYPE = "Content-Type: ".getBytes(StandardCharsets.UTF_8);
+ private static final byte[] CONTENT_LENGTH = "Content-Length: ".getBytes(StandardCharsets.UTF_8);
private static final byte[] CONNECTION_CLOSE = "Connection: close\r\n".getBytes(StandardCharsets.UTF_8);
private static final byte[] CONNECTION_KEEPALIVE = "Connection: keep-alive\r\n".getBytes(StandardCharsets.UTF_8);
private static final byte[] TRANSFER_CHUNKED = "Transfer-Encoding: chunked\r\n".getBytes(StandardCharsets.UTF_8);
private static final byte[] FINAL_CHUNK = "0\r\n\r\n".getBytes(StandardCharsets.UTF_8);
-
private static final byte[] UNKNOWN_STATUS_SUFFIX = " Unknown".getBytes(StandardCharsets.UTF_8);
private static final byte[][] DIGITS = new byte[10][1];
@@ -54,16 +56,20 @@ public class HttpServer {
}
/**
- * Creates the server with optional server-level middlewares applied to every registered route.
- * Middlewares are pre-fused at construction time; the first element executes outermost.
+ * Creates the transport with a pre-built router. Called exclusively by
+ * {@link dev.relism.extension.FlashApp}.
+ *
+ * @param configuration server configuration (port, host, buffer sizes)
+ * @param globalRouter the fully-wired router to dispatch requests to
*/
- public HttpServer(HttpServerConfiguration configuration, Middleware... middlewares) throws IOException {
+ HttpServer(FlashConfiguration configuration, GlobalRouter globalRouter) throws IOException {
this.configuration = configuration;
this.serverSocket = new ServerSocket(configuration.getPort());
- this.globalRouter = new GlobalRouter(middlewares);
+ this.globalRouter = globalRouter;
}
/** Returns a future that completes once the accept loop is running and the server is ready. */
+ @Override
public CompletableFuture start() {
Thread.ofPlatform().name("flash-accept-loop").daemon(false).start(this::run);
return readyFuture;
@@ -85,6 +91,7 @@ public class HttpServer {
}
/** Closes all active connections and shuts down the executor. Returns when complete. */
+ @Override
public CompletableFuture stop() {
stopped = true;
try {
@@ -104,59 +111,7 @@ public class HttpServer {
return CompletableFuture.completedFuture(null);
}
- /**
- * Mounts a sub-router under {@code namespace}. Requests whose path starts with the
- * namespace are dispatched to {@code router}; longest prefix wins.
- *
- * @throws dev.relism.exceptions.DuplicateNamespaceException if {@code namespace} is already mounted
- */
- public HttpServer mount(String namespace, AbstractRouter router) {
- globalRouter.mount(namespace, router);
- return this;
- }
-
- public HttpServer onNotFound(SimpleHandler.FunctionalHandler handler) {
- globalRouter.onNotFound(handler);
- return this;
- }
-
- public HttpServer onException(AbstractRouter.ExceptionHandler handler) {
- globalRouter.onException(handler);
- return this;
- }
-
- // ── Direct registration (called by FlashApp via RouteHandle.with()) ──────
-
- public HttpServer doRegister(dev.relism.http.HttpMethod method, String path,
- SimpleHandler.FunctionalHandler handler,
- dev.relism.routing.Middleware[] middlewares) {
- globalRouter.doRegister(method, path, handler, middlewares);
- return this;
- }
-
- public HttpServer doRegister(RequestHandler handler,
- dev.relism.routing.Middleware[] middlewares) {
- globalRouter.doRegister(handler, middlewares);
- return this;
- }
-
- // ── Fluent registration (delegates to globalRouter) ───────────────────────
-
- public dev.relism.routing.RouteHandle register(RequestHandler handler) {
- return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(handler, m));
- }
-
- public dev.relism.routing.RouteHandle get (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.GET, path, h, m)); }
- public dev.relism.routing.RouteHandle post (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.POST, path, h, m)); }
- public dev.relism.routing.RouteHandle put (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.PUT, path, h, m)); }
- public dev.relism.routing.RouteHandle delete (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.DELETE, path, h, m)); }
- public dev.relism.routing.RouteHandle patch (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.PATCH, path, h, m)); }
- public dev.relism.routing.RouteHandle options(String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.OPTIONS, path, h, m)); }
- public dev.relism.routing.RouteHandle head (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.HEAD, path, h, m)); }
- public dev.relism.routing.RouteHandle trace (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.TRACE, path, h, m)); }
- public dev.relism.routing.RouteHandle connect(String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.CONNECT, path, h, m)); }
- public dev.relism.routing.RouteHandle purge (String path, SimpleHandler.FunctionalHandler h) { return new dev.relism.routing.RouteHandle<>(this, m -> globalRouter.doRegister(dev.relism.http.HttpMethod.PURGE, path, h, m)); }
-
+ // ── Hot-path ──────────────────────────────────────────────────────────────
private void process(Socket socket) {
activeSockets.add(socket);
@@ -210,7 +165,6 @@ public class HttpServer {
private static boolean isKeepAlive(Request request) {
if (request.headerEquals("Connection", "close")) return false;
- // Detect HTTP version from last byte of protocol field: "HTTP/1.1" → '1', "HTTP/1.0" → '0'
ByteView protocol = request.getRequestLine().getProtocol();
return protocol.length() == 8 && protocol.byteAt(7) == '1'
|| request.headerEquals("Connection", "keep-alive");
@@ -246,7 +200,6 @@ public class HttpServer {
out.flush();
}
- /** Streaming write path — extracted from {@link #writeResponse} to keep the hot method small. */
private static void writeStreamingBody(OutputStream out, Response response, boolean keepAlive) throws IOException {
if (!response.isChunked()) {
out.write(CONTENT_LENGTH);
diff --git a/flash/src/main/java/dev/relism/HttpServerConfiguration.java b/flash/src/main/java/dev/relism/HttpServerConfiguration.java
deleted file mode 100644
index f0ef5b8..0000000
--- a/flash/src/main/java/dev/relism/HttpServerConfiguration.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package dev.relism;
-
-import lombok.Builder;
-import lombok.Data;
-
-@Data
-@Builder
-public class HttpServerConfiguration {
- private int port;
- private String host;
- @Builder.Default
- private int acceptorThreads = 1;
- @Builder.Default
- private int maxHeaderBufferSize = 64 * 1024;
-}
diff --git a/flash/src/main/java/dev/relism/ServerHandle.java b/flash/src/main/java/dev/relism/ServerHandle.java
new file mode 100644
index 0000000..bec752f
--- /dev/null
+++ b/flash/src/main/java/dev/relism/ServerHandle.java
@@ -0,0 +1,26 @@
+package dev.relism;
+
+import dev.relism.extension.FlashConfiguration;
+import dev.relism.routing.GlobalRouter;
+
+import java.io.IOException;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Public handle to the underlying HTTP transport. Returned by {@link #create} so that
+ * {@link dev.relism.extension.FlashApp} can start and stop the server without holding
+ * a direct reference to the package-private {@link HttpServer}.
+ */
+public interface ServerHandle {
+
+ CompletableFuture start();
+ CompletableFuture stop();
+
+ /**
+ * Creates the HTTP transport. Called exclusively by
+ * {@link dev.relism.extension.FlashApp}.
+ */
+ static ServerHandle create(FlashConfiguration config, GlobalRouter router) throws IOException {
+ return new HttpServer(config, router);
+ }
+}
diff --git a/flash/src/main/java/dev/relism/extension/ExtensionContext.java b/flash/src/main/java/dev/relism/extension/ExtensionContext.java
index b0dd098..c9200bd 100644
--- a/flash/src/main/java/dev/relism/extension/ExtensionContext.java
+++ b/flash/src/main/java/dev/relism/extension/ExtensionContext.java
@@ -1,6 +1,7 @@
package dev.relism.extension;
import java.util.*;
+import java.util.stream.Stream;
/**
* Shared registry passed to every extension during {@link FlashExtension#install}.
@@ -9,14 +10,36 @@ import java.util.*;
*
Service sharing — provide/require typed objects (e.g. {@code ObjectMapper},
* {@code OpenApiBuilder}) so extensions can build on each other.
*
Annotation processing — register {@link AnnotationProcessor}s that
- * {@link FlashApp} calls for every handler, injecting middleware derived from
+ * are invoked for every handler, injecting middleware derived from
* annotations ({@code @RolesAllowed}, {@code @Authenticated}, etc.).
*
+ *
+ *
A child context (created via {@link #child()}) inherits all services and processors
+ * from its parent. Services provided and processors added on the child are scoped to it
+ * and not visible in the parent or sibling scopes.
*/
public class ExtensionContext {
- private final Map, Object> registry = new LinkedHashMap<>();
- private final List processors = new ArrayList<>();
+ private final ExtensionContext parent;
+ private final Map, Object> registry = new LinkedHashMap<>();
+ private final List processors = new ArrayList<>();
+ private final List routeListeners = new ArrayList<>();
+
+ public ExtensionContext() {
+ this.parent = null;
+ }
+
+ private ExtensionContext(ExtensionContext parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Creates a child context that inherits this context's services and processors.
+ * Services provided and processors added on the child do not affect the parent.
+ */
+ public ExtensionContext child() {
+ return new ExtensionContext(this);
+ }
// ── Service registry ─────────────────────────────────────────────────────
@@ -27,11 +50,13 @@ public class ExtensionContext {
/**
* Retrieves the service registered under {@code type}.
- * Throws {@link IllegalStateException} if not present — install order matters.
+ * Checks own scope first, then the parent chain.
+ * Throws {@link IllegalStateException} if not found — install order matters.
*/
@SuppressWarnings("unchecked")
public T require(Class type) {
T val = (T) registry.get(type);
+ if (val == null && parent != null) val = parent.find(type).orElse(null);
if (val == null)
throw new IllegalStateException(
"Extension dependency not found: " + type.getSimpleName() +
@@ -39,24 +64,58 @@ public class ExtensionContext {
return val;
}
- /** Returns the service under {@code type}, or empty if not installed. */
+ /** Returns the service under {@code type}, or empty if not installed in this scope or any parent. */
@SuppressWarnings("unchecked")
public Optional find(Class type) {
- return Optional.ofNullable((T) registry.get(type));
+ T val = (T) registry.get(type);
+ if (val != null) return Optional.of(val);
+ return parent != null ? parent.find(type) : Optional.empty();
}
// ── Annotation processors ────────────────────────────────────────────────
/**
* Registers an {@link AnnotationProcessor}. Called by extensions during
- * {@link FlashExtension#install}. Processors are invoked in registration order.
+ * {@link FlashExtension#install}. Processors are invoked in registration order
+ * (parent processors first, then own).
*/
public void addAnnotationProcessor(AnnotationProcessor processor) {
processors.add(processor);
}
- /** Returns an unmodifiable view of all registered processors. */
+ /**
+ * Returns all processors visible from this context: parent processors first,
+ * then processors added directly to this context.
+ */
List processors() {
- return Collections.unmodifiableList(processors);
+ if (parent == null) return Collections.unmodifiableList(processors);
+ List parentProcessors = parent.processors();
+ if (processors.isEmpty()) return parentProcessors;
+ return Stream.concat(parentProcessors.stream(), processors.stream()).toList();
+ }
+
+ // ── Route listeners ──────────────────────────────────────────────────────
+
+ /**
+ * Registers a {@link RouteListener} that will be notified once for every route
+ * registered on this context's {@link dev.relism.extension.FlashApp} or any
+ * {@link dev.relism.extension.FlashScope} that inherits from it.
+ *
+ *
Call this inside {@link FlashExtension#install} to observe all routes.
+ * If no listener is registered the emission path is a no-op.
+ */
+ public void addRouteListener(RouteListener listener) {
+ routeListeners.add(listener);
+ }
+
+ /**
+ * Returns all route listeners visible from this context: parent listeners first,
+ * then listeners added directly to this context.
+ */
+ List routeListeners() {
+ if (parent == null) return Collections.unmodifiableList(routeListeners);
+ List parentListeners = parent.routeListeners();
+ if (routeListeners.isEmpty()) return parentListeners;
+ return Stream.concat(parentListeners.stream(), routeListeners.stream()).toList();
}
}
diff --git a/flash/src/main/java/dev/relism/extension/FlashApp.java b/flash/src/main/java/dev/relism/extension/FlashApp.java
index 636f5e4..69fb22f 100644
--- a/flash/src/main/java/dev/relism/extension/FlashApp.java
+++ b/flash/src/main/java/dev/relism/extension/FlashApp.java
@@ -1,77 +1,107 @@
package dev.relism.extension;
-import dev.relism.HttpServer;
+import dev.relism.ServerHandle;
import dev.relism.http.HttpMethod;
import dev.relism.models.RequestHandler;
import dev.relism.models.SimpleHandler;
import dev.relism.routing.AbstractRouter;
+import dev.relism.routing.GlobalRouter;
import dev.relism.routing.Middleware;
+import dev.relism.routing.Route;
import dev.relism.routing.RouteHandle;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
+import java.util.function.Consumer;
import java.util.stream.Stream;
/**
- * Primary entry point for working with Flash. Wraps {@link HttpServer} and
- * wires the extension layer.
- *
- *
The key addition over raw {@link HttpServer} is the annotation-aware
- * {@link #register} override: before delegating to Flash it runs all registered
- * {@link AnnotationProcessor}s and prepends any injected middlewares
- * (e.g. from {@code @RolesAllowed}) to the explicit ones.
- *
- *
Route registration is lazy: calling {@code get()}, {@code post()}, or
- * {@code register()} returns a {@link RouteHandle} that is not yet registered.
- * The route is registered automatically before the next operation or at
- * {@link #start()}. Call {@link RouteHandle#with} explicitly to add middleware:
+ * Primary entry point for Flash. Creates and owns both the {@link GlobalRouter} and
+ * the {@link HttpServer} (pure I/O transport). All route registration goes through
+ * {@code FlashApp} or a {@link FlashScope} — never through the server or router directly.
*
+ *
+ * Calling any registration method returns a {@link RouteHandle}. Calling
+ * {@link RouteHandle#with} is optional — if omitted, the route is registered
+ * automatically before the next operation or at {@link #start()}. This means
+ * trailing {@code .with()} calls are never required for routes with no middleware.
*/
-public class FlashApp {
+public final class FlashApp implements FlashRegistrar {
- private final HttpServer server;
+ private final GlobalRouter router;
+ private final ServerHandle server;
private final ExtensionContext ctx = new ExtensionContext();
- /** The last returned RouteHandle that has not yet been registered. */
+ /** The last returned RouteHandle not yet registered — auto-flushed before the next operation. */
private RouteHandle> pending;
- private FlashApp(HttpServer server) {
- this.server = server;
+ /**
+ * Global middlewares applied to every route, regardless of how it is registered
+ * (lambda, class-based, or via {@link #scan}).
+ * Accumulated via {@link #use}; applied outermost in the chain (before injected and
+ * explicit middlewares).
+ */
+ private final List globalMiddlewares = new ArrayList<>();
+
+ private FlashApp(FlashConfiguration config) {
+ this.router = new GlobalRouter();
+ try {
+ this.server = ServerHandle.create(config, router);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to bind server socket on port " + config.getPort(), e);
+ }
}
- public static FlashApp of(HttpServer server) {
- return new FlashApp(server);
+ // ── Factories ─────────────────────────────────────────────────────────────
+
+ /**
+ * Creates a {@code FlashApp} listening on {@code port} with default configuration.
+ *
+ * @param port the TCP port to bind
+ */
+ public static FlashApp create(int port) {
+ return create(FlashConfiguration.builder().port(port).build());
+ }
+
+ /**
+ * Creates a {@code FlashApp} with full server configuration.
+ *
+ * @param config server configuration (port, host, buffer sizes, etc.)
+ */
+ public static FlashApp create(FlashConfiguration config) {
+ return new FlashApp(config);
}
// ── Pending flush ─────────────────────────────────────────────────────────
/**
- * Registers any pending route (returned by the previous {@code get/post/register}
- * call) with no middleware, if it has not already been registered via
- * {@link RouteHandle#with}.
+ * Registers any pending route (from the previous {@code get/post/register} call)
+ * with no middleware if it has not already been committed via {@link RouteHandle#with}.
*/
private void flushPending() {
if (pending != null) {
@@ -80,103 +110,239 @@ public class FlashApp {
}
}
- private
RouteHandle
pending(RouteHandle
handle) {
+ private
RouteHandle
track(RouteHandle
handle) {
flushPending();
pending = handle;
return handle;
}
- // ── Extension installation ────────────────────────────────────────────────
+ // ── FlashRegistrar — extension installation ───────────────────────────────
+ /**
+ * Installs an extension. Extensions receive this {@code FlashApp} as a
+ * {@link FlashRegistrar} so they can register routes and expose services.
+ *
+ * @param ext the extension to install
+ * @return {@code this} for chaining
+ */
+ @Override
public FlashApp install(FlashExtension ext) {
flushPending();
ext.install(this, ctx);
return this;
}
- /** Exposes the context so callers can retrieve services installed by extensions. */
+ // ── Global middleware ──────────────────────────────────────────────────────
+
+ /**
+ * Registers one or more global middlewares applied to every route on this app,
+ * regardless of how the route is registered (lambda, class-based, or via {@link #scan}).
+ *
+ *
Global middlewares execute outermost — before annotation-injected middlewares
+ * (e.g. {@code @Authenticated}) and before any explicit {@link RouteHandle#with} chain.
+ * Execution order mirrors the declaration order: the first argument wraps everything else.
+ *
+ *
Must be called before {@link #start()}. Calling {@code use} after routes have already
+ * been registered will not retroactively affect those routes.
+ *
+ *
+ */
+ @Override
+ public FlashApp scan(String packageName) {
+ flushPending();
+ PackageScanner.findHandlers(packageName).forEach(cls -> register(instantiate(cls)).ensureRegistered());
+ return this;
+ }
+
+ // ── Namespace mounting ────────────────────────────────────────────────────
+
+ /**
+ * Mounts a scoped sub-router under {@code namespace}. The {@code configure} consumer
+ * receives a {@link FlashScope} that has its own child {@link ExtensionContext}
+ * inheriting all parent services and annotation processors.
+ *
+ *
Routes registered on the scope automatically get the namespace prefix prepended.
+ * Annotation processors (e.g. from OIDC) apply identically inside the scope.
+ *
+ *
+ *
+ * @param namespace the path prefix (e.g. {@code "/api"})
+ * @param configure consumer that registers routes on the scope
+ */
+ public FlashApp mount(String namespace, Consumer configure) {
+ flushPending();
+ FlashScope scope = new FlashScope(new dev.relism.routing.routers.fastpathrouter.FastPathRouterImpl(),
+ namespace, ctx);
+ configure.accept(scope);
+ scope.flush();
+ router.mount(namespace, scope.router());
+ return this;
+ }
+
+ // ── FlashRegistrar — error handlers ──────────────────────────────────────
+
+ @Override
+ public FlashApp onException(AbstractRouter.ExceptionHandler handler) {
+ flushPending();
+ router.onException(handler);
+ return this;
+ }
+
+ @Override
+ public FlashApp onNotFound(SimpleHandler.FunctionalHandler handler) {
+ flushPending();
+ router.onNotFound(handler);
+ return this;
+ }
+
+ // ── FlashRegistrar — context ──────────────────────────────────────────────
+
+ @Override
public ExtensionContext ctx() {
return ctx;
}
- // ── Handler registration (annotation-aware) ───────────────────────────────
-
- /**
- * Begins registration of a class-based handler. Before registering, all
- * {@link AnnotationProcessor}s are called (e.g. to inject OIDC middleware from
- * {@code @Authenticated} / {@code @RolesAllowed}). Their middlewares are prepended
- * outermost to any extra middlewares supplied via {@link RouteHandle#with}.
- *
- *
Calling {@link RouteHandle#with} is optional when no extra middleware is needed —
- * the route is registered automatically before the next operation or at {@link #start()}.
- *
- *
Middleware execution order: injected (from annotations) → explicit (.with()) → handler.
- */
- public RouteHandle register(RequestHandler handler) {
- return pending(new RouteHandle<>(this, explicit -> {
- List injected = ctx.processors().stream()
- .flatMap(p -> p.process(handler.getClass()).stream())
- .toList();
- Middleware[] all = injected.isEmpty()
- ? explicit
- : Stream.concat(injected.stream(), Arrays.stream(explicit))
- .toArray(Middleware[]::new);
- server.doRegister(handler, all);
- }));
- }
-
- // ── Lambda route registration ─────────────────────────────────────────────
-
- /**
- * Begins registration of a lambda route. Calling {@link RouteHandle#with} is
- * optional when no middleware is needed — the route is registered automatically
- * before the next operation or at {@link #start()}.
- *
- *
- */
- public RouteHandle get (String path, SimpleHandler.FunctionalHandler h) { return pending(new RouteHandle<>(this, m -> server.doRegister(HttpMethod.GET, path, h, m))); }
- public RouteHandle post (String path, SimpleHandler.FunctionalHandler h) { return pending(new RouteHandle<>(this, m -> server.doRegister(HttpMethod.POST, path, h, m))); }
- public RouteHandle put (String path, SimpleHandler.FunctionalHandler h) { return pending(new RouteHandle<>(this, m -> server.doRegister(HttpMethod.PUT, path, h, m))); }
- public RouteHandle delete (String path, SimpleHandler.FunctionalHandler h) { return pending(new RouteHandle<>(this, m -> server.doRegister(HttpMethod.DELETE, path, h, m))); }
- public RouteHandle patch (String path, SimpleHandler.FunctionalHandler h) { return pending(new RouteHandle<>(this, m -> server.doRegister(HttpMethod.PATCH, path, h, m))); }
- public RouteHandle options(String path, SimpleHandler.FunctionalHandler h) { return pending(new RouteHandle<>(this, m -> server.doRegister(HttpMethod.OPTIONS, path, h, m))); }
- public RouteHandle head (String path, SimpleHandler.FunctionalHandler h) { return pending(new RouteHandle<>(this, m -> server.doRegister(HttpMethod.HEAD, path, h, m))); }
-
- public FlashApp mount(String namespace, AbstractRouter router) {
- flushPending();
- server.mount(namespace, router);
- return this;
- }
-
- public FlashApp onException(AbstractRouter.ExceptionHandler handler) {
- flushPending();
- server.onException(handler);
- return this;
- }
-
- public FlashApp onNotFound(SimpleHandler.FunctionalHandler handler) {
- flushPending();
- server.onNotFound(handler);
- return this;
- }
-
// ── Lifecycle ─────────────────────────────────────────────────────────────
+ /**
+ * Flushes any pending route registration and starts the HTTP server.
+ *
+ * @return a future that completes once the accept loop is running
+ */
public CompletableFuture start() {
flushPending();
return server.start();
}
+ /** Stops the HTTP server and closes all active connections. */
public CompletableFuture stop() {
return server.stop();
}
- /** Direct access to the underlying server for advanced use cases. */
- public HttpServer server() {
- return server;
+ // ── Internals ─────────────────────────────────────────────────────────────
+
+ @SuppressWarnings("unchecked")
+ private static RequestHandler instantiate(Class> cls) {
+ try {
+ return (RequestHandler) cls.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to instantiate handler: " + cls.getName() +
+ " — ensure it has a public no-arg constructor", e);
+ }
+ }
+
+ /**
+ * Emits a {@link RouteEvent} to all registered {@link RouteListener}s.
+ * No-op if no listener has been registered (fast empty-list check).
+ * Called once per route at boot time — never on the request hot-path.
+ */
+ @SuppressWarnings("unchecked")
+ private void emit(HttpMethod method, String path, Class> handlerClass,
+ List injected, Middleware[] explicit) {
+ List listeners = ctx.routeListeners();
+ if (listeners.isEmpty()) return;
+ Middleware[] routerMws = router.routerMiddlewares();
+ List> chain = new ArrayList<>(routerMws.length + injected.size() + explicit.length);
+ for (Middleware m : routerMws) chain.add((Class extends Middleware>) m.getClass());
+ for (Middleware m : injected) chain.add((Class extends Middleware>) m.getClass());
+ for (Middleware m : explicit) chain.add((Class extends Middleware>) m.getClass());
+ RouteEvent event = new RouteEvent(method, path, router.getNamespace(),
+ router.getClass().getSimpleName(), handlerClass, List.copyOf(chain));
+ listeners.forEach(l -> l.onRoute(event));
}
}
diff --git a/flash/src/main/java/dev/relism/extension/FlashConfiguration.java b/flash/src/main/java/dev/relism/extension/FlashConfiguration.java
new file mode 100644
index 0000000..486305b
--- /dev/null
+++ b/flash/src/main/java/dev/relism/extension/FlashConfiguration.java
@@ -0,0 +1,31 @@
+package dev.relism.extension;
+
+import lombok.Builder;
+import lombok.Value;
+
+/**
+ * Configuration for a {@link FlashApp} instance.
+ *
+ *
{@code
+ * // Minimal — port only
+ * FlashApp.create(8080);
+ *
+ * // Full control
+ * FlashApp.create(FlashConfiguration.builder()
+ * .port(8080)
+ * .host("127.0.0.1")
+ * .maxHeaderBufferSize(128 * 1024)
+ * .build());
+ * }
+ */
+@Value
+@Builder
+public class FlashConfiguration {
+
+ int port;
+ String host;
+
+ /** Maximum size of the request header buffer in bytes. Default: 64 KB. */
+ @Builder.Default
+ int maxHeaderBufferSize = 64 * 1024;
+}
diff --git a/flash/src/main/java/dev/relism/extension/FlashExtension.java b/flash/src/main/java/dev/relism/extension/FlashExtension.java
index 07615d6..5dd7199 100644
--- a/flash/src/main/java/dev/relism/extension/FlashExtension.java
+++ b/flash/src/main/java/dev/relism/extension/FlashExtension.java
@@ -1,25 +1,32 @@
package dev.relism.extension;
/**
- * Contract for all Flash extensions. An extension receives the full {@link FlashApp}
- * so it can both register handlers on the server and expose services through
- * {@link ExtensionContext} for other extensions.
+ * Contract for all Flash extensions. An extension receives a {@link FlashRegistrar}
+ * (either a {@link FlashApp} or a {@link FlashScope}) so it can register routes and
+ * expose shared services via {@link ExtensionContext}.
+ *
+ *
Extensions work identically whether installed at the top-level app or inside a
+ * mounted scope:
*
*
{@link FlashExtension#install} receives a {@code FlashRegistrar} so that extensions
+ * work identically whether installed at the top-level app or inside a mounted scope.
+ *
+ *
Route registration follows the auto-flush pattern: calling any registration method
+ * without a subsequent {@link RouteHandle#with} is equivalent to calling
+ * {@code .with()} with no arguments — the route is registered with no middleware.
+ *
+ *
Calling {@link RouteHandle#with} is optional — the route is registered
+ * automatically before the next operation or at {@code start()}.
+ */
+ RouteHandle> register(RequestHandler h);
+
+ /**
+ * Scans {@code packageName} for classes that extend {@link RequestHandler} and
+ * carry {@link dev.relism.routing.Route @Route}. Each is instantiated via its
+ * no-arg constructor, run through annotation processors, and registered.
+ */
+ FlashRegistrar scan(String packageName);
+
+ // ── Error handlers ────────────────────────────────────────────────────────
+
+ FlashRegistrar onException(AbstractRouter.ExceptionHandler h);
+ FlashRegistrar onNotFound(SimpleHandler.FunctionalHandler h);
+
+ // ── Context access ────────────────────────────────────────────────────────
+
+ /** Returns the {@link ExtensionContext} for this registrar (app or scope). */
+ ExtensionContext ctx();
+}
diff --git a/flash/src/main/java/dev/relism/extension/FlashScope.java b/flash/src/main/java/dev/relism/extension/FlashScope.java
new file mode 100644
index 0000000..ba40e42
--- /dev/null
+++ b/flash/src/main/java/dev/relism/extension/FlashScope.java
@@ -0,0 +1,216 @@
+package dev.relism.extension;
+
+import dev.relism.http.HttpMethod;
+import dev.relism.models.RequestHandler;
+import dev.relism.models.SimpleHandler;
+import dev.relism.routing.AbstractRouter;
+import dev.relism.routing.PathUtils;
+import dev.relism.routing.Route;
+import dev.relism.routing.RouteHandle;
+import dev.relism.routing.Middleware;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.stream.Stream;
+
+/**
+ * Scoped registration context for a mounted sub-router namespace.
+ *
+ *
Obtained via {@link FlashApp#mount(String, java.util.function.Consumer)}.
+ * A scope has its own child {@link ExtensionContext} that inherits all services and
+ * annotation processors from the parent app, so extensions like {@code @Authenticated}
+ * and {@code @RolesAllowed} work identically inside a scope.
+ *
+ *
Extensions installed on a scope are scoped to that namespace and not visible
+ * in the parent or sibling scopes.
+ *
+ *
+ */
+public final class FlashScope implements FlashRegistrar {
+
+ private final AbstractRouter router;
+ private final String namespace;
+ private final ExtensionContext ctx;
+
+ /** Pending RouteHandle awaiting .with() — auto-flushed before each new registration. */
+ private RouteHandle> pending;
+
+ /**
+ * Package-private — only {@link FlashApp} creates scopes.
+ *
+ * @param router the sub-router that will receive routes registered on this scope
+ * @param namespace the namespace prefix (e.g. {@code "/api"})
+ * @param parentCtx the parent app's ExtensionContext — a child is created from it
+ */
+ FlashScope(AbstractRouter router, String namespace, ExtensionContext parentCtx) {
+ this.router = router;
+ this.namespace = namespace;
+ this.ctx = parentCtx.child();
+ }
+
+ // ── Pending flush ─────────────────────────────────────────────────────────
+
+ private void flushPending() {
+ if (pending != null) {
+ pending.ensureRegistered();
+ pending = null;
+ }
+ }
+
+ private
RouteHandle
track(RouteHandle
handle) {
+ flushPending();
+ pending = handle;
+ return handle;
+ }
+
+ // ── FlashRegistrar — extension installation ───────────────────────────────
+
+ /**
+ * Installs an extension scoped to this namespace.
+ * The extension registers routes and services on this scope only.
+ */
+ @Override
+ public FlashScope install(FlashExtension ext) {
+ flushPending();
+ ext.install(this, ctx);
+ return this;
+ }
+
+ // ── FlashRegistrar — route registration ───────────────────────────────────
+
+ @Override public RouteHandle get (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.GET, path, h); }
+ @Override public RouteHandle post (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.POST, path, h); }
+ @Override public RouteHandle put (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.PUT, path, h); }
+ @Override public RouteHandle delete (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.DELETE, path, h); }
+ @Override public RouteHandle patch (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.PATCH, path, h); }
+ @Override public RouteHandle options(String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.OPTIONS, path, h); }
+ @Override public RouteHandle head (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.HEAD, path, h); }
+ @Override public RouteHandle trace (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.TRACE, path, h); }
+ @Override public RouteHandle connect(String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.CONNECT, path, h); }
+ @Override public RouteHandle purge (String path, SimpleHandler.FunctionalHandler h) { return routeLambda(HttpMethod.PURGE, path, h); }
+
+ private RouteHandle routeLambda(HttpMethod method, String path, SimpleHandler.FunctionalHandler h) {
+ return track(new RouteHandle<>(this, m -> {
+ String full = ns(path);
+ emit(method, full, null, List.of(), m);
+ router.doRegister(method, full, h, m);
+ }));
+ }
+
+ /**
+ * Begins registration of a class-based handler. Annotation processors from the
+ * parent app and any installed on this scope are applied. The {@link Route @Route}
+ * path is prepended with this scope's namespace automatically.
+ *
+ *
Calling {@link RouteHandle#with} is optional — the route is registered
+ * automatically before the next operation or when the scope consumer returns.
+ */
+ @Override
+ public RouteHandle register(RequestHandler handler) {
+ return track(new RouteHandle<>(this, explicit -> {
+ List injected = ctx.processors().stream()
+ .flatMap(p -> p.process(handler.getClass()).stream())
+ .toList();
+ Middleware[] all = injected.isEmpty()
+ ? explicit
+ : Stream.concat(injected.stream(), Arrays.stream(explicit)).toArray(Middleware[]::new);
+ Route annotation = handler.getClass().getAnnotation(Route.class);
+ if (annotation != null) {
+ String full = ns(annotation.path());
+ emit(annotation.method(), full, handler.getClass(), injected, explicit);
+ router.doRegister(annotation.method(), full, (RequestHandler) handler, all);
+ }
+ }));
+ }
+
+ /**
+ * Scans {@code packageName} for {@link RequestHandler} subclasses annotated with
+ * {@link Route @Route}. Each is instantiated via its no-arg constructor and registered
+ * with this scope's namespace prefix and annotation processors applied.
+ */
+ @Override
+ public FlashScope scan(String packageName) {
+ flushPending();
+ PackageScanner.findHandlers(packageName).forEach(cls -> register(instantiate(cls)).ensureRegistered());
+ return this;
+ }
+
+ @Override
+ public FlashScope onException(AbstractRouter.ExceptionHandler h) {
+ flushPending();
+ router.onException(h);
+ return this;
+ }
+
+ @Override
+ public FlashScope onNotFound(SimpleHandler.FunctionalHandler h) {
+ flushPending();
+ router.onNotFound(h);
+ return this;
+ }
+
+ @Override
+ public ExtensionContext ctx() {
+ return ctx;
+ }
+
+ // ── Internals ─────────────────────────────────────────────────────────────
+
+ /** Ensures any pending route is registered when the scope consumer returns. */
+ void flush() {
+ flushPending();
+ }
+
+ /** Returns the sub-router for GlobalRouter to mount. */
+ AbstractRouter router() {
+ return router;
+ }
+
+ /** Prepends this scope's namespace to the given path. */
+ private String ns(String path) {
+ return namespace + PathUtils.sanitize(path);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static RequestHandler instantiate(Class> cls) {
+ try {
+ return (RequestHandler) cls.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to instantiate handler: " + cls.getName() +
+ " — ensure it has a public no-arg constructor", e);
+ }
+ }
+
+ /**
+ * Emits a {@link RouteEvent} to all {@link RouteListener}s visible from this scope's context.
+ * Parent-level listeners (registered on the app) are included via context inheritance.
+ * No-op if no listener has been registered. Never called on the request hot-path.
+ */
+ @SuppressWarnings("unchecked")
+ private void emit(HttpMethod method, String path, Class> handlerClass,
+ List injected, Middleware[] explicit) {
+ List listeners = ctx.routeListeners();
+ if (listeners.isEmpty()) return;
+ Middleware[] routerMws = router.routerMiddlewares();
+ List> chain = new ArrayList<>(routerMws.length + injected.size() + explicit.length);
+ for (Middleware m : routerMws) chain.add((Class extends Middleware>) m.getClass());
+ for (Middleware m : injected) chain.add((Class extends Middleware>) m.getClass());
+ for (Middleware m : explicit) chain.add((Class extends Middleware>) m.getClass());
+ RouteEvent event = new RouteEvent(method, path, namespace,
+ router.getClass().getSimpleName(), handlerClass, List.copyOf(chain));
+ listeners.forEach(l -> l.onRoute(event));
+ }
+}
diff --git a/flash/src/main/java/dev/relism/extension/PackageScanner.java b/flash/src/main/java/dev/relism/extension/PackageScanner.java
new file mode 100644
index 0000000..21031e1
--- /dev/null
+++ b/flash/src/main/java/dev/relism/extension/PackageScanner.java
@@ -0,0 +1,106 @@
+package dev.relism.extension;
+
+import dev.relism.models.RequestHandler;
+import dev.relism.routing.Route;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * Minimal classpath scanner used by {@link FlashApp#scan} and {@link FlashScope#scan}.
+ * Finds all classes in a package that extend {@link RequestHandler} and carry {@link Route @Route}.
+ * Supports both exploded directories (development) and fat JARs (deployment).
+ */
+final class PackageScanner {
+
+ private PackageScanner() {}
+
+ /**
+ * Returns all {@link RequestHandler} subclasses in {@code packageName} that carry
+ * {@link Route @Route} and have a public no-arg constructor.
+ */
+ static List> findHandlers(String packageName) {
+ String resourcePath = packageName.replace('.', '/');
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ List> result = new ArrayList<>();
+ try {
+ Enumeration resources = cl.getResources(resourcePath);
+ while (resources.hasMoreElements()) {
+ URL url = resources.nextElement();
+ String protocol = url.getProtocol();
+ if ("file".equals(protocol)) {
+ scanDirectory(new File(url.toURI()), packageName, cl, result);
+ } else if ("jar".equals(protocol)) {
+ String jarPath = url.getPath();
+ // jar:file:/path/to/app.jar!/com/example → /path/to/app.jar
+ String filePart = jarPath.substring(jarPath.indexOf("file:") + 5, jarPath.indexOf('!'));
+ try (JarFile jar = new JarFile(filePart)) {
+ scanJar(jar, resourcePath, packageName, cl, result);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to scan package: " + packageName, e);
+ }
+ return result;
+ }
+
+ private static void scanDirectory(File dir, String packageName, ClassLoader cl, List> result) {
+ File[] files = dir.listFiles();
+ if (files == null) return;
+ for (File file : files) {
+ if (file.isDirectory()) {
+ scanDirectory(file, packageName + '.' + file.getName(), cl, result);
+ } else if (file.getName().endsWith(".class") && !isAnonymous(file.getName())) {
+ String className = packageName + '.' + file.getName().replace(".class", "");
+ tryLoad(className, cl, result);
+ }
+ }
+ }
+
+ private static void scanJar(JarFile jar, String resourcePath, String packageName,
+ ClassLoader cl, List> result) {
+ Enumeration entries = jar.entries();
+ while (entries.hasMoreElements()) {
+ String name = entries.nextElement().getName();
+ if (name.startsWith(resourcePath) && name.endsWith(".class") && !isAnonymous(name)) {
+ String className = name.replace('/', '.').replace(".class", "");
+ tryLoad(className, cl, result);
+ }
+ }
+ }
+
+ /**
+ * Returns {@code true} for anonymous/synthetic class files whose name segment after
+ * the last {@code $} starts with a digit (e.g. {@code Foo$1.class},
+ * {@code Foo$$Lambda$14.class}). Named static nested classes like
+ * {@code Outer$Inner.class} return {@code false} and are eligible for scanning.
+ */
+ private static boolean isAnonymous(String fileName) {
+ int dollar = fileName.lastIndexOf('$');
+ if (dollar < 0) return false;
+ // skip past any extra '$' (lambda desugaring may produce '$$Lambda$...')
+ int next = dollar + 1;
+ while (next < fileName.length() && fileName.charAt(next) == '$') next++;
+ return next < fileName.length() && Character.isDigit(fileName.charAt(next));
+ }
+
+ private static void tryLoad(String className, ClassLoader cl, List> result) {
+ try {
+ Class> cls = cl.loadClass(className);
+ if (RequestHandler.class.isAssignableFrom(cls)
+ && cls.isAnnotationPresent(Route.class)
+ && !java.lang.reflect.Modifier.isAbstract(cls.getModifiers())) {
+ cls.getDeclaredConstructor(); // verify no-arg constructor exists
+ result.add(cls);
+ }
+ } catch (Exception | Error ignored) {
+ // Skip classes that cannot be loaded or don't meet criteria
+ }
+ }
+}
diff --git a/flash/src/main/java/dev/relism/extension/RouteEvent.java b/flash/src/main/java/dev/relism/extension/RouteEvent.java
new file mode 100644
index 0000000..df98c98
--- /dev/null
+++ b/flash/src/main/java/dev/relism/extension/RouteEvent.java
@@ -0,0 +1,44 @@
+package dev.relism.extension;
+
+import dev.relism.http.HttpMethod;
+import dev.relism.routing.Middleware;
+
+import java.util.List;
+
+/**
+ * Immutable snapshot of a route captured at registration time.
+ *
+ *
Emitted by {@link FlashApp} and {@link FlashScope} to every registered
+ * {@link RouteListener} before the route is compiled into the routing engine.
+ * All information is derived automatically — no annotations or declarations
+ * are required from the developer.
+ *
+ *
Router-level middlewares (set on the router constructor)
+ *
Annotation-injected middlewares (e.g. from {@code @Authenticated})
+ *
Handler-level explicit middlewares (passed via {@code .with(...)})
+ *
+ *
+ *
Handler abstraction chain
+ * Walk {@link #handlerClass} upward via {@link Class#getSuperclass()} to reconstruct
+ * the full inheritance chain (e.g. {@code EditPostPageHandler → HtmlHandler → RequestHandler}).
+ * Read {@link Class#getAnnotations()} on each level to discover declared pointcuts
+ * ({@code @Authenticated}, {@code @RolesAllowed}, {@code @Route}, etc.).
+ *
+ * @param method HTTP method for this route
+ * @param path full path as declared (including namespace prefix for scoped routes)
+ * @param namespace namespace prefix of the router that owns this route ({@code "/"} for root)
+ * @param routerType simple class name of the owning router implementation
+ * @param handlerClass concrete handler class, or {@code null} for anonymous lambda handlers
+ * @param middlewareChain ordered middleware classes, outermost first
+ */
+public record RouteEvent(
+ HttpMethod method,
+ String path,
+ String namespace,
+ String routerType,
+ Class> handlerClass,
+ List> middlewareChain
+) {}
diff --git a/flash/src/main/java/dev/relism/extension/RouteListener.java b/flash/src/main/java/dev/relism/extension/RouteListener.java
new file mode 100644
index 0000000..dd6f3ee
--- /dev/null
+++ b/flash/src/main/java/dev/relism/extension/RouteListener.java
@@ -0,0 +1,22 @@
+package dev.relism.extension;
+
+/**
+ * Observer notified once for each route registered on a {@link FlashApp} or {@link FlashScope}.
+ *
+ *
Register via {@link ExtensionContext#addRouteListener}. The listener is called
+ * once per route at boot time, before the route is handed to the routing engine.
+ * There is zero overhead on the request hot-path.
+ *
+ *
Intended for extensions that need to introspect the route graph (e.g. a route viewer,
+ * OpenAPI schema builder, etc.) without polluting the routing or middleware infrastructure.
+ */
+@FunctionalInterface
+public interface RouteListener {
+
+ /**
+ * Called once for every registered route, in registration order.
+ *
+ * @param event immutable snapshot of the route's metadata at registration time
+ */
+ void onRoute(RouteEvent event);
+}
diff --git a/flash/src/main/java/dev/relism/models/Response.java b/flash/src/main/java/dev/relism/models/Response.java
index dc1c620..7769889 100644
--- a/flash/src/main/java/dev/relism/models/Response.java
+++ b/flash/src/main/java/dev/relism/models/Response.java
@@ -99,6 +99,37 @@ public class Response {
return this;
}
+ /**
+ * 302 Found redirect. Clears the body, sets status and {@code Location} header.
+ * Encoded once at call time; zero-alloc on the write path.
+ *
+ *
{@code
+ * return res.redirect("/login");
+ * }
+ */
+ public Response redirect(String url) {
+ return redirect(HttpStatus.FOUND, url);
+ }
+
+ /**
+ * Redirect with an explicit 3xx status. Use {@link HttpStatus#MOVED_PERMANENTLY},
+ * {@link HttpStatus#TEMPORARY_REDIRECT} (307), or {@link HttpStatus#PERMANENT_REDIRECT} (308)
+ * when semantics matter.
+ *
+ *
+ */
+ public Response redirect(HttpStatus status, String url) {
+ this.statusCode = status.code();
+ this.statusBytes = status.bytes();
+ this.body = null;
+ this.stream = null;
+ if (headers == null) headers = new ArrayList<>();
+ headers.add(("Location: " + url + "\r\n").getBytes(StandardCharsets.UTF_8));
+ return this;
+ }
+
/** Adds a response header. Encoded once at call time; zero-alloc on the write path. */
public Response header(String name, String value) {
if (headers == null) headers = new ArrayList<>();
diff --git a/flash/src/main/java/dev/relism/routing/AbstractRouter.java b/flash/src/main/java/dev/relism/routing/AbstractRouter.java
index c3f61c7..870dfc7 100644
--- a/flash/src/main/java/dev/relism/routing/AbstractRouter.java
+++ b/flash/src/main/java/dev/relism/routing/AbstractRouter.java
@@ -17,11 +17,15 @@ import java.nio.charset.StandardCharsets;
*
*
Router-level {@link Middleware middlewares} are passed at construction time and
* pre-fused into a single wrapper applied to every handler registered on this router.
- * Handler-level middlewares are passed to the {@link #register} / {@link #get} family of
- * methods and wrapped inside the router-level chain.
+ * Handler-level middlewares are passed to {@link #doRegister} and wrapped
+ * inside the router-level chain.
*
*
All middleware composition happens once at boot time; the hot-path sees only a plain
* {@link RequestHandler} call with zero allocation and zero lookup overhead.
+ *
+ *
Registration: use {@link dev.relism.extension.FlashApp} or
+ * {@link dev.relism.extension.FlashScope} — they are the public registration API.
+ * {@link #doRegister} is an infrastructure method for those entry points.
*/
public abstract class AbstractRouter {
@@ -35,7 +39,14 @@ public abstract class AbstractRouter {
* Pre-fused router-level middleware, or {@code null} when none were registered.
* A single null-check in {@link #compile} is the only cost when no router middleware exists.
*/
- private final Middleware routerMiddleware;
+ private final Middleware routerMiddleware;
+
+ /**
+ * Raw router-level middleware array, kept for route event emission by
+ * {@link dev.relism.extension.FlashApp} and {@link dev.relism.extension.FlashScope}.
+ * Never mutated after construction. Not used on the hot-path.
+ */
+ private final Middleware[] rawRouterMiddlewares;
protected SimpleHandler notFoundHandler = new SimpleHandler((req, res) -> {
res.setStatusCode(404);
@@ -56,15 +67,25 @@ public abstract class AbstractRouter {
* @param middlewares zero or more middlewares applied to every handler on this router
*/
protected AbstractRouter(Middleware... middlewares) {
+ this.rawRouterMiddlewares = middlewares;
this.routerMiddleware = middlewares.length == 0 ? null
: middlewares.length == 1 ? middlewares[0]
: Middleware.of(middlewares);
}
+ /**
+ * Returns the raw router-level middleware array as passed at construction.
+ * Used by {@link dev.relism.extension.FlashApp} and {@link dev.relism.extension.FlashScope}
+ * to populate {@link dev.relism.extension.RouteEvent#middlewareChain()}.
+ * Never mutated; never called on the hot-path.
+ */
+ public Middleware[] routerMiddlewares() { return rawRouterMiddlewares; }
+
// ── Internal wiring ───────────────────────────────────────────────────────
SimpleHandler getNotFoundHandler() { return notFoundHandler; }
ExceptionHandler getExceptionHandler() { return exceptionHandler; }
+
void setNamespace(String namespace) {
this.namespace = namespace;
this.namespaceBytes = namespace.getBytes(StandardCharsets.UTF_8);
@@ -81,10 +102,8 @@ public abstract class AbstractRouter {
*/
private RequestHandler compile(RequestHandler handler, Middleware[] handlerMiddlewares) {
RequestHandler compiled = handler;
- // handler-level: wrap from innermost outward; box FunctionalHandler → SimpleHandler once per layer
for (int i = handlerMiddlewares.length - 1; i >= 0; i--)
compiled = new SimpleHandler(handlerMiddlewares[i].wrap(compiled));
- // router-level: outermost wrapper, executes first
if (routerMiddleware != null)
compiled = new SimpleHandler(routerMiddleware.wrap(compiled));
return compiled;
@@ -102,11 +121,12 @@ public abstract class AbstractRouter {
return this;
}
- // ── Internal registration (package-private) ───────────────────────────────
+ // ── Infrastructure registration ───────────────────────────────────────────
+ // Used by FlashApp and FlashScope. Not part of the public user-facing API.
/**
* Registers a lambda handler immediately with a pre-built middleware array.
- * Called by {@link RouteHandle#with} and by {@link dev.relism.extension.FlashApp}.
+ * Infrastructure method — use {@link dev.relism.extension.FlashApp} instead.
*/
public AbstractRouter doRegister(HttpMethod method, String path,
SimpleHandler.FunctionalHandler handler, Middleware[] middlewares) {
@@ -116,7 +136,8 @@ public abstract class AbstractRouter {
/**
* Registers a class-based handler immediately with a pre-built middleware array.
- * Called by {@link RouteHandle#with} and by {@link dev.relism.extension.FlashApp}.
+ * Reads {@link Route @Route} for method and path.
+ * Infrastructure method — use {@link dev.relism.extension.FlashApp} instead.
*/
public AbstractRouter doRegister(RequestHandler handler, Middleware[] middlewares) {
Route annotation = handler.getClass().getAnnotation(Route.class);
@@ -126,42 +147,15 @@ public abstract class AbstractRouter {
return this;
}
- // ── Lambda handler registration ───────────────────────────────────────────
-
/**
- * Begins registration of a lambda handler. Call {@link RouteHandle#with} on the
- * returned handle to supply middlewares (if any) and complete the registration.
- *
- *